fix(question): reject pending questions on abort and interrupt - #46269
Open
jiffyaneesh wants to merge 1 commit into
Open
fix(question): reject pending questions on abort and interrupt#46269jiffyaneesh wants to merge 1 commit into
jiffyaneesh wants to merge 1 commit into
Conversation
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.
Issue for this PR
Closes #46163
Type of change
What does this PR do?
When a user aborts a turn while the
questiontool is waiting for input (or when the turn halts/times out), the pending question was previously orphaned in memory:GET /questionstill reported the request for a dead session.question.rejectedorquestion.repliedevent was ever published over the wire.This fix:
cancel(sessionID)method toQuestion/QuestionV2service that removes pending requests for a session, emitsquestion.rejectedevents, and fails pending deferreds withRejectedError.cancel(sessionID)intoSessionPrompt.cancelandSessionProcessor.cleanup().Effect.onInterrupttoQuestion.askso direct fiber interruptions reject the deferred and publishquestion.rejected.event-reducer.tsandtui/src/context/sync.tsxto prune pending questions when their corresponding tool part errors or completes.How did you verify your code works?
packages/opencode/test/question/question.test.tsverifying event publishing on interrupt andquestion.cancel().packages/core/test/question.test.tsfor V2QuestionV2.cancel()and fiber interruption.packages/app/src/context/global-sync/event-reducer.test.tsverifying tool part error cleanup.bun testacrosspackages/opencode,packages/core, andpackages/app— all passed (18/18 opencode, 5/5 core, 17/17 app).tsgo --noEmit/bun typecheckacrosspackages/opencode,packages/core,packages/app, andpackages/tui— 0 errors.Checklist