Skip to content

fix(question): reject pending questions on abort and interrupt - #46269

Open
jiffyaneesh wants to merge 1 commit into
anomalyco:devfrom
jiffyaneesh:abort-question-46163
Open

fix(question): reject pending questions on abort and interrupt#46269
jiffyaneesh wants to merge 1 commit into
anomalyco:devfrom
jiffyaneesh:abort-question-46163

Conversation

@jiffyaneesh

Copy link
Copy Markdown

Issue for this PR

Closes #46163

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When a user aborts a turn while the question tool is waiting for input (or when the turn halts/times out), the pending question was previously orphaned in memory:

  1. GET /question still reported the request for a dead session.
  2. No question.rejected or question.replied event was ever published over the wire.
  3. The desktop and web apps kept the composer locked with the question dock open because the store was never notified to clear the request.

This fix:

  • Adds a cancel(sessionID) method to Question / QuestionV2 service that removes pending requests for a session, emits question.rejected events, and fails pending deferreds with RejectedError.
  • Hooks cancel(sessionID) into SessionPrompt.cancel and SessionProcessor.cleanup().
  • Adds Effect.onInterrupt to Question.ask so direct fiber interruptions reject the deferred and publish question.rejected.
  • Adds finalizer publishing to clean up pending questions on instance disposal.
  • Adds client-side defense-in-depth in event-reducer.ts and tui/src/context/sync.tsx to prune pending questions when their corresponding tool part errors or completes.

How did you verify your code works?

  • Added new unit test cases to packages/opencode/test/question/question.test.ts verifying event publishing on interrupt and question.cancel().
  • Added new test cases to packages/core/test/question.test.ts for V2 QuestionV2.cancel() and fiber interruption.
  • Added new test cases to packages/app/src/context/global-sync/event-reducer.test.ts verifying tool part error cleanup.
  • Ran bun test across packages/opencode, packages/core, and packages/app — all passed (18/18 opencode, 5/5 core, 17/17 app).
  • Ran tsgo --noEmit / bun typecheck across packages/opencode, packages/core, packages/app, and packages/tui — 0 errors.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • All typechecks and test suites pass cleanly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

question tool: aborting mid-question leaves the request pending forever and never publishes question.rejected

1 participant