Refresh upstream state after branch checkout and invalidate git queries#46
Refresh upstream state after branch checkout and invalidate git queries#46juliusmarminge merged 3 commits intomainfrom
Conversation
- fetch tracked remote after checkout to update ahead/behind counts - add integration test for behind count when remote branch advances - invalidate git React Query data on `turn/completed` events in the web app
WalkthroughAdds best-effort upstream refresh after branch checkout in the server Git service, two tests validating upstream behind-count and checkout resilience to fetch failures, and client-side invalidation of Git queries on "turn/completed" events. Changes
Sequence Diagram(s)mermaid mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
Greptile SummaryAdded upstream branch refresh after checkout to ensure accurate ahead/behind counts when remote branches advance, plus UI query invalidation on agent turn completion. Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant UI as App.tsx
participant API as Git API
participant Git as GitCoreService
participant Remote as Git Remote
User->>API: checkout branch
API->>Git: checkoutBranch()
Git->>Git: executeGit(["checkout", branch])
Note over Git: Checkout succeeds
Git->>Git: refreshCheckedOutBranchUpstream()
Git->>Git: gitStdout(["rev-parse", "@{upstream}"])
Git-->>Git: "origin/feature-branch"
Git->>Git: Parse remote name and branch
Git->>Remote: git fetch --quiet --no-tags origin +refs/heads/feature:refs/remotes/origin/feature
alt Fetch succeeds
Remote-->>Git: Updated refs
Git-->>API: Checkout complete
else Fetch fails
Note over Git: Silently catch error
Git-->>API: Checkout complete (best effort)
end
API-->>UI: Checkout result
Note over UI: On turn/completed event
UI->>UI: invalidateGitQueries(queryClient)
UI->>API: Re-fetch git status
API->>Git: statusDetails()
Git-->>API: Current ahead/behind counts
API-->>UI: Updated git state
Note over UI: UI shows fresh git status
Last reviewed commit: 147f433 |
Refresh the checked-out branch’s upstream after
|
- treat post-checkout upstream fetch as best effort so checkout still succeeds - route refresh fetch through `this.git(...)` for consistent behavior - add regression test for fetch-timeout during branch checkout
|
@greptileai review |
- derive upstream branch from `branch@{upstream}` and guard empty values
- fetch only `+refs/heads/<branch>:refs/remotes/<remote>/<branch>` instead of all remote refs
- add integration test asserting scoped fetch args during `checkoutBranch`
|
@greptileai review |
Port upstream commits ac3f22c..268016d: - Inline branch picker filtering and drop PR-only shortcut (pingdotgg#46) - Fix PR thread upstream tracking for fork branches (pingdotgg#47) Removes filterBranchPickerItems shared function in favor of inline filtering, adds URL-derived fork identity resolution, ensures upstream tracking is restored on local checkouts and reused worktrees, and simulates real git checkout in fake GH CLI for integration tests.
Summary
git checkoutby fetching the checked-out branch's remote (quiet, no-tags)turn/completedevents so UI git state refreshes promptlyTesting
apps/server/src/git.test.tsthat:aheadCount === 0andbehindCount === 1apps/server/src/git.tscalls upstream refresh after successful checkoutSummary by CodeRabbit
New Features
Bug Fixes / Resiliency
Tests