fix(grok): discard resume cursor when a thread's workspace changes#5
Merged
Merged
Conversation
Resuming a grok session against a different working directory than the one the cursor was recorded in produces a stale/invalid resume, so a thread that moves to a new worktree must start a fresh session instead of replaying the old cursor. - ProviderCommandReactor: when the preferred provider is grok and the cwd changed, pass an explicit `null` resume cursor (a "discard" sentinel, distinct from `undefined` which means "use the persisted cursor") when restarting the session, and log `shouldDiscardResumeCursorForCwdChange`. - ProviderService: honor the `null` sentinel by dropping the cursor, and independently refuse to reuse a persisted cursor when an explicit `cwd` differs from the persisted one. Persisted cwd lookup is hoisted so both the cursor-reuse guard and `effectiveCwd` share it. Adds reactor- and service-level regression tests covering the worktree/cwd-change paths. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
A grok resume cursor is only valid against the working directory it was recorded in. When a thread moves to a different worktree/cwd, replaying the old cursor produces a stale or invalid resume. This change makes a thread start a fresh grok session whenever its workspace changes.
Changes
ProviderCommandReactor: when the preferred provider isgrokand the cwd changed, pass an explicitnullresume cursor when restarting the session.nullis a discard sentinel, distinct fromundefined("use the persisted cursor"). AddsshouldDiscardResumeCursorForCwdChangeto the restart log.ProviderService: honor thenullsentinel by dropping the cursor, and — independently — refuse to reuse a persisted cursor when an explicitcwddiffers from the persisted one. Persisted-cwd lookup is hoisted so the cursor-reuse guard andeffectiveCwdshare it.Tests
resumeCursor: nulland the new cwd on the secondstartSession).🤖 Generated with Claude Code