Description
Describe the bug
After running git checkout <branch> (or equivalent) outside of OpenCode, the branch name displayed in the bottom-right corner of the TUI (home footer and sidebar footer) does not update to reflect the new branch. The stale branch name persists until OpenCode is restarted or the user navigates to a different session and back.
Root cause analysis (for maintainers)
The event pipeline is:
git checkout → .git/HEAD change → FileWatcher → Vcs service detects change
→ bus.publish(Event.BranchUpdated, { branch })
→ GlobalBus.emit → SDK → TUI event subscription
→ sync.tsx case "vcs.branch.updated"
The breakage is in packages/opencode/src/cli/cmd/tui/context/sync.tsx, line 367:
case "vcs.branch.updated": {
if (workspace === project.workspace.current()) { // ← blocks the update
setStore("vcs", { branch: event.properties.branch })
}
break
}
workspace from the event is always undefined — the local VCS InstanceState has no WorkspaceRef injected.
- Once the user opens a session,
project.workspace.current() is set to a real workspace ID.
undefined !== "some-workspace-id" → false → the store is never updated.
- Even on the home screen (where both are
undefined), timing issues can cause the update to be missed.
The fix would be to either remove the workspace guard for this event type (the event is already scoped to the correct project by event.ts:19), or change it to only block when a non-matching workspace is explicitly set on both sides.
Expected behavior
The branch name (and directory path containing it) in the TUI footer and sidebar should update automatically within a few seconds of switching branches, without requiring a restart or session navigation.
Plugins
No response
OpenCode version
1.16.2
Steps to reproduce
- Open OpenCode in a git repository (TUI mode).
- Observe the bottom-right footer showing
~/repo:main (or similar).
- In a separate terminal, run
git checkout other-branch.
- Return to OpenCode — the footer still shows
~/repo:main instead of ~/repo:other-branch.
Screenshot and/or share link
No response
Operating System
win10 LTSC 21H2
Terminal
git bash
Description
Describe the bug
After running
git checkout <branch>(or equivalent) outside of OpenCode, the branch name displayed in the bottom-right corner of the TUI (home footer and sidebar footer) does not update to reflect the new branch. The stale branch name persists until OpenCode is restarted or the user navigates to a different session and back.Root cause analysis (for maintainers)
The event pipeline is:
The breakage is in
packages/opencode/src/cli/cmd/tui/context/sync.tsx, line 367:workspacefrom the event is alwaysundefined— the local VCSInstanceStatehas noWorkspaceRefinjected.project.workspace.current()is set to a real workspace ID.undefined !== "some-workspace-id"→false→ the store is never updated.undefined), timing issues can cause the update to be missed.The fix would be to either remove the workspace guard for this event type (the event is already scoped to the correct project by
event.ts:19), or change it to only block when a non-matching workspace is explicitly set on both sides.Expected behavior
The branch name (and directory path containing it) in the TUI footer and sidebar should update automatically within a few seconds of switching branches, without requiring a restart or session navigation.
Plugins
No response
OpenCode version
1.16.2
Steps to reproduce
~/repo:main(or similar).git checkout other-branch.~/repo:maininstead of~/repo:other-branch.Screenshot and/or share link
No response
Operating System
win10 LTSC 21H2
Terminal
git bash