fix(claude): interrupt turn after plan is presented in plan mode - #114
Merged
Conversation
ExitPlanMode only denied subsequent tool calls without ending the turn, so if the model kept calling tools or narrating instead of stopping, the SDK stream never emitted a final `result` message and the turn stayed "in progress" forever. This left PlanViewer's Approve/Revise and the prompt input's stop button stuck, since `activeTurnIdsByTask` never cleared without a `done` event. Call Query.interrupt() as soon as ExitPlanMode is detected, mirroring Codex's requestPlanInterrupt(). interrupt() halts generation for the current turn (without closing the session), so a `result` message still follows and `done` fires normally.
JongSikLim
approved these changes
Jul 8, 2026
Merged
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
Plan-mode turns in the Claude provider could get stuck "in progress" after the plan was presented, leaving PlanViewer's Approve/Revise and the prompt input's stop button locked.
Changes
Fixes
Query.interrupt()as soon asExitPlanModeis detected, forcing the turn to end so aresultmessage (and thedoneevent) is always emitted, mirroring Codex'srequestPlanInterrupt().Test Evidence
bun run typecheck— passbun test tests/claude-sdk-runtime.test.ts tests/claude-sdk-runtime-cwd.test.ts— 86 pass, 0 failNotes
Root cause:
ExitPlanModeonly denied subsequent tool calls without ending the turn. If the model kept calling tools or narrating instead of stopping, the SDK stream never produced a finalresultmessage, soactiveTurnIdsByTaskinapp.store.tsnever cleared.