Skip to content

Branch name in TUI footer / sidebar does not refresh after switching branches #31469

Description

@vbcssc

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

  1. Open OpenCode in a git repository (TUI mode).
  2. Observe the bottom-right footer showing ~/repo:main (or similar).
  3. In a separate terminal, run git checkout other-branch.
  4. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions