Update files
This commit is contained in:
@@ -9,16 +9,16 @@ const CHECKOUT_DIFF_STALE_TIME = 30_000;
|
||||
|
||||
function checkoutDiffQueryKey(
|
||||
serverId: string,
|
||||
agentId: string,
|
||||
cwd: string,
|
||||
mode: "uncommitted" | "base",
|
||||
baseRef?: string
|
||||
) {
|
||||
return ["checkoutDiff", serverId, agentId, mode, baseRef ?? ""] as const;
|
||||
return ["checkoutDiff", serverId, cwd, mode, baseRef ?? ""] as const;
|
||||
}
|
||||
|
||||
interface UseCheckoutDiffQueryOptions {
|
||||
serverId: string;
|
||||
agentId: string;
|
||||
cwd: string;
|
||||
mode: "uncommitted" | "base";
|
||||
baseRef?: string;
|
||||
enabled?: boolean;
|
||||
@@ -31,7 +31,7 @@ export type HighlightToken = NonNullable<DiffLine["tokens"]>[number];
|
||||
|
||||
export function useCheckoutDiffQuery({
|
||||
serverId,
|
||||
agentId,
|
||||
cwd,
|
||||
mode,
|
||||
baseRef,
|
||||
enabled = true,
|
||||
@@ -51,27 +51,27 @@ export function useCheckoutDiffQuery({
|
||||
const isOpen = isMobile ? mobileView === "file-explorer" : desktopFileExplorerOpen;
|
||||
|
||||
const query = useQuery({
|
||||
queryKey: checkoutDiffQueryKey(serverId, agentId, mode, baseRef),
|
||||
queryKey: checkoutDiffQueryKey(serverId, cwd, mode, baseRef),
|
||||
queryFn: async () => {
|
||||
if (!client) {
|
||||
throw new Error("Daemon client not available");
|
||||
}
|
||||
return await client.getCheckoutDiff(agentId, { mode, baseRef });
|
||||
return await client.getCheckoutDiff(cwd, { mode, baseRef });
|
||||
},
|
||||
enabled: !!client && isConnected && !!agentId && enabled,
|
||||
enabled: !!client && isConnected && !!cwd && enabled,
|
||||
staleTime: CHECKOUT_DIFF_STALE_TIME,
|
||||
refetchInterval: 10_000,
|
||||
});
|
||||
|
||||
// Revalidate when sidebar opens with "changes" tab active
|
||||
useEffect(() => {
|
||||
if (!isOpen || explorerTab !== "changes" || !agentId) {
|
||||
if (!isOpen || explorerTab !== "changes" || !cwd) {
|
||||
return;
|
||||
}
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: checkoutDiffQueryKey(serverId, agentId, mode, baseRef),
|
||||
queryKey: checkoutDiffQueryKey(serverId, cwd, mode, baseRef),
|
||||
});
|
||||
}, [isOpen, explorerTab, serverId, agentId, mode, baseRef, queryClient]);
|
||||
}, [isOpen, explorerTab, serverId, cwd, mode, baseRef, queryClient]);
|
||||
|
||||
const refresh = useCallback(() => {
|
||||
return query.refetch();
|
||||
|
||||
Reference in New Issue
Block a user