Skip to content

fix(app): refresh review panel on external git commits - #49294

Open
lxqddd wants to merge 1 commit into
anomalyco:devfrom
lxqddd:fix/review-refresh-external-git-commit
Open

lxqddd wants to merge 1 commit into
anomalyco:devfrom
lxqddd:fix/review-refresh-external-git-commit

Conversation

@lxqddd

@lxqddd lxqddd commented Sep 16, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #40795
Relates to #11856

Type of change

  • Bug fix

What does this PR do?

The review panel caches its vcs.diff query with every refetch hook disabled (refetchOnWindowFocus/Mount/Reconnect: false), so it only refreshes through explicit invalidation. Most terminal git operations still refresh it by accident — pull/checkout/merge rewrite workspace files and produce non-.git watcher events, and switching tabs or the review mode re-triggers the query.

But an out-of-band git commit / git add / git commit --amend rewrites only files under .git, and none of that produced an event, so the panel kept showing the pre-commit changes until some unrelated event happened to refresh it (a file edit, a session finishing, reopening the panel):

  • Server-side, the .git subscription watches only HEAD, and a regular commit doesn't change HEAD's content — it's still the same symbolic ref
  • Client-side, the session VCS listener dropped every .git path anyway (that check also compared a relative .git/... prefix against absolute event paths, so it never actually matched)
  • The branch name (part of the query key) doesn't change either, so the query never re-ran

Fix:

  • core watcher: also exempt index from the .git ignore list — staging and commits rewrite it; the rest of .git stays ignored so we don't flood events
  • app session: treat paths under .git whose basename is index or HEAD as VCS state changes and call the existing debounced refreshVcs(); basename matching also covers git worktrees (.git/worktrees/<name>/index)
  • test: flip ignores .git/index changes to assert the event is published, and add coverage that other .git files (COMMIT_EDITMSG) remain ignored

How did you verify your code works?

  • bun test test/filesystem/watcher.test.ts — 7/7 pass, including the new publishes .git/index events and ignores other .git changes tests
  • typecheck passes for packages/core and packages/app
  • Manually in the desktop app: review panel open, git commit / git add from a terminal → panel refreshes within the 100ms debounce; unrelated .git churn stays silent

Screenshots / recordings

No visual UI change — behavior fix only.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The review panel caches its vcs.diff query with every refetch hook
disabled, so it only refreshes through explicit invalidation. Most
terminal git operations still refresh it by accident because they
rewrite workspace files, but a git commit/add/amend only rewrites files
under .git, which produced no event:

- the server's .git subscription watches only HEAD, and a regular
  commit does not change HEAD's content
- the client's session VCS listener dropped every .git path anyway
  (that check also compared a relative prefix against absolute event
  paths, so it never actually matched)

The panel then kept showing pre-commit changes until an unrelated event
happened to refresh it.

- watch .git/index alongside HEAD in the core watcher (staging and
  commits rewrite it; everything else under .git stays ignored)
- in the session VCS listener, treat paths under .git whose basename is
  index or HEAD as VCS state changes and call the existing debounced
  refreshVcs(); basename matching also covers git worktrees, where the
  path is .git/worktrees/<name>/index
- flip the watcher test to assert .git/index events are published and
  add coverage that other .git files remain ignored

Co-Authored-By: Claude Code <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sidebar changes panel does not refresh after external git rm + commit (or any external commit)

1 participant