feat(opencode): Add "Cancel" action on Message Actions Dialog to cancel a queued user prompt#27399
feat(opencode): Add "Cancel" action on Message Actions Dialog to cancel a queued user prompt#27399veenified wants to merge 5 commits into
Conversation
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate PRs FoundI found two related PRs that address similar functionality:
Please check these PRs to determine if they've already implemented the cancel functionality or if there's been a merge conflict/regression that requires this PR. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Issue for this PR
Closes #20090 #6942 #21906 #4821
Type of change
What does this PR do?
This PR adds the ability to cancel queued prompts directly from the TUI message actions dialog.
Problem: When multiple prompts are queued in the TUI, later user messages show a
QUEUEDbadge but there is no way to remove them without waiting for the assistant to process every preceding turn.Solution:
Removes the busy-session gate from
deleteMessage(packages/opencode/src/server/routes/instance/httpapi/handlers/session.ts)mapBusy(runState.assertNotBusy(...)), which prevented removing a queued message while an earlier turn was running.deleteMessageonly removes the target message record and its parts from the session DB — it does not revert file changes or interrupt the runner state.Adds a conditional Cancel action to
DialogMessage(packages/opencode/src/cli/cmd/tui/routes/session/dialog-message.tsx)queued?: booleanprop.queuedis true, the dialog prepends a "Cancel" option that callssdk.client.session.deleteMessage({ sessionID, messageID }).DialogContexttype import to fix an implicitanyparameter.Wires queued state from the session view (
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx)isQueuedusing the same existing rule that renders theQUEUEDbadge (message.id > pending()).queued={isQueued}toDialogMessageandpending={pending()}toDialogTimeline.Propagates queued state through the timeline dialog (
packages/opencode/src/cli/cmd/tui/routes/session/dialog-timeline.tsx)pending?: stringprop and computesisQueuedfor each entry before passing it toDialogMessage.How did you verify your code works?
bun turbo typecheckpasses across all 14 packages with zero errors.bun test test/cli/run/runtime.queue.test.ts: 10 pass, 0 fail.DialogMessage.receivesqueuedfrom the samepending()memo that drives the existingQUEUED` badge.deleteMessageis a pre-existing SDK endpoint that removes only the target message and its parts; it does not touchSessionRunStateor the active runner fiber.Screenshots / recordings
Checklist