Repository navigation
fix(git): refresh branch labels after branch changes - #439
Merged
Merged
Conversation
Invalidate the repo siblings cache with repo metadata so the session header branch updates after a switch, refresh the repo list git status and worktree siblings on vcs.branch.updated, and refresh repo metadata after continuing or aborting an operation.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Switching branches in the Source Control panel did not update the branch shown in the session header. The header resolves its branch from
GET /api/repos/:id/siblings, which includes the repo itself, and no git mutation invalidated that cache. Branch changes made outside the panel had related gaps.Shared invalidation (
lib/queryInvalidation.ts)invalidateRepoGitCachesinvalidates['repo', 'siblings']whenever it invalidates repo metadata, so switch, create, rename, fetch and pull refresh header and worktree branch labels.invalidateRepoGitCachesDebounced(used forvcs.branch.updated) also invalidates the batched repo list git status, which repo cards prefer for their branch label.External branch changes (
contexts/EventContext.tsx)vcs.branch.updatedevent for a directory that matches no repo row, such as a worktree, now invalidates the sibling caches instead of being ignored.Operations (
hooks/useGit.ts)HEADduring a rebase returns to the branch name.Type of Change
Checklist
pnpm lint:frontendpasses locallyTests
queryInvalidation.test.ts: sibling caches invalidated with repo metadata and kept when skipped; debounced flush invalidates the matching repo list status only.EventContext.test.tsx: unmatchedvcs.branch.updatedinvalidates siblings; matched event updates the repo cache and invalidates siblings.useGit.test.tsx: continue and abort invalidate the repo and sibling caches.Validation
vitest run src/lib src/contexts src/hooks src/components/source-control src/components/repo src/pages: 126 files, 1511 tests passed.tsc -bandpnpm lint:frontend: clean.Summary by CodeRabbit