fix(source-control): do not reset defaultBaseRef on worktree switch (#811)

The defaultBaseRef resolver is repo-scoped, not worktree-scoped. Resetting
it to 'origin/main' on every worktree switch within the same repo clobbered
the correct value (e.g. 'origin/master'), causing persistent 'Branch compare
unavailable' errors.
This commit is contained in:
Jinjing 2026-04-18 19:02:14 -07:00 committed by GitHub
parent eacdc2b946
commit ffcc144a75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -274,7 +274,13 @@ function SourceControlInner(): React.JSX.Element {
setScope('all')
setCollapsedSections(new Set())
setBaseRefDialogOpen(false)
setDefaultBaseRef('origin/main')
// Why: do NOT reset defaultBaseRef here. It is repo-scoped, not
// worktree-scoped, and is resolved by the effect above on activeRepo
// change. Resetting it to a hard-coded 'origin/main' on every worktree
// switch within the same repo clobbered the correct value (e.g.
// 'origin/master' for repos whose default branch isn't main), causing
// a persistent "Branch compare unavailable" until the user switched
// repos and back to re-trigger the resolver.
setFilterQuery('')
setIsExecutingBulk(false)
}, [activeWorktreeId])