Keep following a finished subagent's worktree while it exists - #109
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
When an isolated subagent finishes, its worktree survives exactly when it left changes behind — and the session usually keeps working there (review, fixes, commit) without ever announcing the move. The follower used to clear the thread's inferred cwd the moment the task ended, so the checkout chip and source-control panel snapped back to the configured checkout while all subsequent work landed in the worktree. The last task's checkout now lingers: after a short delay (skipping the harness's unchanged-worktree cleanup race), it stays followed while git still lists it as a checkout of the thread's repository. The linger ends when a new agent task starts, the session ends, or the worktree is gone. Session-reported cwds still override inference.
badcuban
force-pushed
the
subagent-worktree-linger
branch
from
August 4, 2026 05:38
77bba08 to
dd1eef1
Compare
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.
Problem
Observed live (thread
c9acfc40, Aug 4): launching an isolated subagent correctly flipped the thread's checkout indicator to the agent's worktree (SubagentWorktreeFollower, sourcesubagent), but the moment the task ended the follower cleared the inference and the indicator snapped back to the configured checkout — while the session went on reviewing, fixing, committing, and opening a PR in that worktree for hours. The session never announces such a move: it navigates with plaincdand absolute paths, which neither Claude's session metadata nor the EnterWorktree event path can see. Result: the checkout chip and the source-control panel watched the wrong checkout for the rest of the session.Fix
A followed worktree now lingers after its task ends. The heuristic: an isolated agent's worktree survives its task exactly when the agent left changes behind — which is exactly when the session keeps working there.
git worktree list, same validation as at follow time). If yes, it stays followed; if the worktree is gone, the inference clears as before.effectiveCwdSource: "session") still override inference, unchanged.makeis now parameterized (lingerValidationDelay) so tests don't sleep real seconds.Testing
ProviderRuntimeIngestionsuite 72/72: the old "stops when the subagent finishes" test now asserts the linger (worktree still listed → still followed), plus new coverage for worktree-gone-at-task-end → cleared, and new-task-supersedes-linger.vp fmt/vp lintclean (pre-existing CommandPalette warnings only).tscerrors (ProviderInstanceRegistryLive.test.ts,server.test.ts) and theforwards WebSocket compression optionstest failure — all reproduce with this diff stashed.