Skip to content

[Bug] FileWatcher misses vcs.branch.updated events in linked worktrees #1016

@Astro-Han

Description

@Astro-Han

What happened?

When PawWork runs inside a Git linked worktree (a worktree created by git worktree add), running git checkout <branch> inside the session does not emit a vcs.branch.updated SSE event. The right-panel Status branch row and any other consumer of that event keep showing the previous branch until the page is reloaded.

Which area seems affected?

Model harness, prompts, tools, or session mechanics

How much does this affect you?

Makes a workflow harder, but there is a workaround

Steps to reproduce

  1. Open PawWork inside a Git linked worktree (any path created via git worktree add)
  2. Create a new session and have the agent run git checkout <other-branch>
  3. Watch the right-panel Status section's branch row — it still shows the previous branch
  4. Open DevTools and confirm no vcs.branch.updated event is logged

What did you expect to happen?

The branch row updates to the new branch within a second or two, the same way it does in a regular non-linked repository, because the file watcher should observe the HEAD change.

PawWork version

v2026.5.29 (also reproduces on the claude/status-panel-redesign dev branch as of 2026-05-31)

OS version

macOS (Darwin 25.5.0)

Can you reproduce it again?

Yes, every time

Diagnostics

Root cause: FileWatcher (packages/opencode/src/file/watcher.ts) derives the watch path from ctx.project.worktree, but in a linked worktree the live HEAD lives at <gitcommondir>/worktrees/<name>/HEAD, not the main repository's .git/HEAD. The Vcs service's FileWatcher subscription therefore never sees the HEAD change, so vcs.branch.updated is not published.

Suggested fix: in packages/opencode/src/file/watcher.ts, resolve the actual per-worktree git metadata directory via git rev-parse --git-dir (or git rev-parse --git-path HEAD) instead of assuming <worktree>/.git/HEAD.

Reported during PR #1013 debugging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium prioritybugSomething isn't workingharnessModel harness, prompts, tool descriptions, and session mechanics

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions