fix(sidebar): Gate turn-end git refresh on activeTabReady#202
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 betweengit worktree addbeing issued and the checkout completing). However, a second code path was left unguarded: when any agent's turn ends,turnEndTriggeris bumped and a separate effect callsgitFileStatusStore.refresh()unconditionally. If that turn-end fires while the active tab is still in its phase-0 window,git statusruns against a partially-checked-out worktree and reports every tracked file as deleted. Those bogus per-file counts flow into both the workspace-listDiffStatBadgeand the Files section's per-row badges, which both read from the same store.Modifications
activeTabReadymemo definition earlier inAppShell.tsxso it can gate both the turn-end effect and the active-tab-change effect.activeTabReady()guard to theturnEndTriggereffect: 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.activeTabReadymemo 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.