#18247 · @sdip15fa · opened Mar 19, 2026 at 1:41 PM UTC · last updated Mar 21, 2026 at 4:17 AM UTC
fix: resolve TUI branch display in git worktrees
Score breakdown
Impact
Clarity
Urgency
Ease Of Review
Guidelines
Readiness
Size
Trust
Traction
Summary
This PR fixes a TUI bug where the displayed branch was incorrect in local git worktrees. The solution involves adjusting git command CWDs to resolve against the active worktree and includes new test coverage.
Description
Issue for this PR
Closes #18246
Type of change
- [x] Bug fix
- [ ] New feature
- [ ] Refactor / code improvement
- [ ] Documentation
What does this PR do?
This fixes TUI branch display in local git worktrees. The branch lookup was resolving against the primary repo checkout, so opening OpenCode from a linked worktree could show the wrong branch. I changed branch resolution and git metadata watching to use the active worktree directory, and added linked-worktree coverage for initial branch detection plus branch updates after startup.
How did you verify your code works?
- Ran
bun test test/project/vcs.test.tsinpackages/opencodeand confirmed the suite loads cleanly; it is skipped in this environment by the existing test guard. - Ran
bun typecheckinpackages/opencodesuccessfully.
Screenshots / recordings
Not included. This is a branch-label behavior fix in the TUI rather than a visual UI change.
Checklist
- [x] I have tested my changes locally
- [x] I have not included unrelated changes in this PR
Linked Issues
#18246 TUI shows the wrong branch in local git worktrees
View issueComments
No comments.
Changed Files
packages/opencode/src/file/watcher.ts
+2−2packages/opencode/src/project/vcs.ts
+1−1packages/opencode/test/project/vcs.test.ts
+51−0