Repository navigation
Refresh upstream state after branch checkout and invalidate git queries - #46
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.
…ments it Design for task pingdotgg#47, written now so the implementing lane gets a contract rather than a paragraph. The one decision worth recording: a command frame is FLAT, not nested. The protocol already documents an inbound-flat / outbound-nested asymmetry, and the stated reason is that an inbound frame describes one editor's own state while an outbound frame carries a set of editors each needing a key. A command is addressed to exactly one editor, so the same rule makes it flat. That asymmetry has already caused one wrong implementation that failed SILENTLY -- the parser just dropped the frame while the connection looked healthy -- so getting it right up front is worth a spec. Capability advertisement is required rather than optional, because the engines genuinely differ: frame-step exists only on Unity through supported APIs. The toolbar must not offer what an engine cannot do, and a hello without capabilities defaults to play+stop so older plugins keep working. Two rules that are easy to get backwards, both written down: - A failed command is an in-band result, NOT a close code. The close-code set is a named set (4400/4401 = stop retrying), not a threshold, so closing a socket because Play failed would disconnect an engine over a recoverable error. - Presence is a level; commands are edges. A Play queued while an editor was disconnected must not fire on reconnect -- the user's intent is stale by then. Also records that pingdotgg#46 (authorization) gates this: the route authenticates but does not authorize, and sits outside the compile-time net that would catch that. No-scope-check on a read-only feed is a low-stakes bug; on a channel that makes an editor execute code it is not.
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