Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions apps/web/src/components/BranchToolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ThreadId } from "@okcode/contracts";
import { ArrowDownIcon, FolderIcon, GitForkIcon, LoaderIcon } from "lucide-react";
import { useCallback } from "react";
import { useCallback, useEffect } from "react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";

import { gitPullMutationOptions, gitStatusQueryOptions, invalidateGitQueries } from "../lib/gitReactQuery";
import { gitPullMutationOptions, gitQueryKeys, gitStatusQueryOptions, invalidateGitQueries } from "../lib/gitReactQuery";
import { newCommandId } from "../lib/utils";
import { readNativeApi } from "../nativeApi";
import { useComposerDraftStore } from "../composerDraftStore";
Expand Down Expand Up @@ -121,6 +121,13 @@ export default function BranchToolbar({
const isBehindUpstream = behindCount > 0 && !hasServerThread;
const pullMutation = useMutation(gitPullMutationOptions({ cwd: gitCwd, queryClient }));

// Force a fresh git-status fetch when a draft thread mounts so we catch
// upstream changes immediately instead of waiting for the next poll cycle.
useEffect(() => {
if (hasServerThread || !gitCwd) return;
void queryClient.invalidateQueries({ queryKey: gitQueryKeys.status(gitCwd) });
}, [hasServerThread, gitCwd, queryClient]);

const handlePull = useCallback(() => {
if (pullMutation.isPending) return;
const promise = pullMutation.mutateAsync();
Expand Down
Loading