|
1 | 1 | import type { ThreadId } from "@okcode/contracts"; |
2 | 2 | import { ArrowDownIcon, FolderIcon, GitForkIcon, LoaderIcon } from "lucide-react"; |
3 | | -import { useCallback } from "react"; |
| 3 | +import { useCallback, useEffect } from "react"; |
4 | 4 | import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; |
5 | 5 |
|
6 | | -import { gitPullMutationOptions, gitStatusQueryOptions, invalidateGitQueries } from "../lib/gitReactQuery"; |
| 6 | +import { gitPullMutationOptions, gitQueryKeys, gitStatusQueryOptions, invalidateGitQueries } from "../lib/gitReactQuery"; |
7 | 7 | import { newCommandId } from "../lib/utils"; |
8 | 8 | import { readNativeApi } from "../nativeApi"; |
9 | 9 | import { useComposerDraftStore } from "../composerDraftStore"; |
@@ -121,6 +121,13 @@ export default function BranchToolbar({ |
121 | 121 | const isBehindUpstream = behindCount > 0 && !hasServerThread; |
122 | 122 | const pullMutation = useMutation(gitPullMutationOptions({ cwd: gitCwd, queryClient })); |
123 | 123 |
|
| 124 | + // Force a fresh git-status fetch when a draft thread mounts so we catch |
| 125 | + // upstream changes immediately instead of waiting for the next poll cycle. |
| 126 | + useEffect(() => { |
| 127 | + if (hasServerThread || !gitCwd) return; |
| 128 | + void queryClient.invalidateQueries({ queryKey: gitQueryKeys.status(gitCwd) }); |
| 129 | + }, [hasServerThread, gitCwd, queryClient]); |
| 130 | + |
124 | 131 | const handlePull = useCallback(() => { |
125 | 132 | if (pullMutation.isPending) return; |
126 | 133 | const promise = pullMutation.mutateAsync(); |
|
0 commit comments