Skip to content

fix(sidebar): Gate turn-end git refresh on activeTabReady#202

Merged
trustin merged 1 commit intomainfrom
victorious-grumpy-apartment
Apr 26, 2026
Merged

fix(sidebar): Gate turn-end git refresh on activeTabReady#202
trustin merged 1 commit intomainfrom
victorious-grumpy-apartment

Conversation

@trustin
Copy link
Copy Markdown
Contributor

@trustin trustin commented Apr 26, 2026

Motivation

Commit 3b038ca gated gitFileStatusStore.refresh() in the active-tab-change effect so it would not fire during a worktree's phase-0 window (the window between git worktree add being issued and the checkout completing). However, a second code path was left unguarded: when any agent's turn ends, turnEndTrigger is bumped and a separate effect calls gitFileStatusStore.refresh() unconditionally. If that turn-end fires while the active tab is still in its phase-0 window, git status runs against a partially-checked-out worktree and reports every tracked file as deleted. Those bogus per-file counts flow into both the workspace-list DiffStatBadge and the Files section's per-row badges, which both read from the same store.

Modifications

  • Moved the activeTabReady memo definition earlier in AppShell.tsx so it can gate both the turn-end effect and the active-tab-change effect.
  • Added an activeTabReady() guard to the turnEndTrigger effect: if the active tab is still in its phase-0 window, the turn-end refresh is skipped entirely. The already-gated active-tab-change effect re-fires once readiness flips, so no git status update is lost.
  • Simplified the active-tab-change effect's guard from a multi-line block to a single-line check, and consolidated the phase-0 rationale into one comment block co-located with the activeTabReady memo definition.

Result

gitFileStatusStore.refresh() is now suppressed on both code paths (tab change and turn end) while a worktree is mid-checkout. Spurious "all files deleted" diff stat badges no longer appear in the workspace list or the Files section when another agent's turn ends during a new worktree's phase-0 window.

The active-tab effect was already gated on activeTabReady (commit
3b038ca) so a STARTING tab in its phase-0 worktree-creation window
doesn't fire a mid-checkout `git status`. The turn-end effect shared
the same `gitFileStatusStore` but was un-gated: another agent's turn
ending while the active tab is mid-checkout would still blast bogus
diff stats into both the workspace-list badges and the Files section
(both consumers read the same store).

- Hoist activeTabReady memo above the turn-end effect so both
  effects share a single readiness signal.
- Skip the turn-end refresh when activeTabReady is false; the
  active-tab effect re-fires when readiness flips, so no signal is
  lost.
- Consolidate phase-0 rationale to live at activeTabReady to avoid
  three near-duplicate comment blocks.
@trustin trustin merged commit c3ac314 into main Apr 26, 2026
6 checks passed
@trustin trustin deleted the victorious-grumpy-apartment branch April 26, 2026 06:39
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.

1 participant