Skip to content

feat(opencode): Add "Cancel" action on Message Actions Dialog to cancel a queued user prompt#27399

Open
veenified wants to merge 5 commits into
anomalyco:devfrom
veenified:dev
Open

feat(opencode): Add "Cancel" action on Message Actions Dialog to cancel a queued user prompt#27399
veenified wants to merge 5 commits into
anomalyco:devfrom
veenified:dev

Conversation

@veenified
Copy link
Copy Markdown

@veenified veenified commented May 13, 2026

Issue for this PR

Closes #20090 #6942 #21906 #4821

Type of change

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

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 QUEUED badge but there is no way to remove them without waiting for the assistant to process every preceding turn.

Solution:

  1. Removes the busy-session gate from deleteMessage (packages/opencode/src/server/routes/instance/httpapi/handlers/session.ts)

    • The endpoint previously blocked deletions via mapBusy(runState.assertNotBusy(...)), which prevented removing a queued message while an earlier turn was running.
    • Removing this guard is safe because deleteMessage only removes the target message record and its parts from the session DB — it does not revert file changes or interrupt the runner state.
  2. Adds a conditional Cancel action to DialogMessage (packages/opencode/src/cli/cmd/tui/routes/session/dialog-message.tsx)

    • Adds an optional queued?: boolean prop.
    • When queued is true, the dialog prepends a "Cancel" option that calls sdk.client.session.deleteMessage({ sessionID, messageID }).
    • Added the missing DialogContext type import to fix an implicit any parameter.
  3. Wires queued state from the session view (packages/opencode/src/cli/cmd/tui/routes/session/index.tsx)

    • Computes isQueued using the same existing rule that renders the QUEUED badge (message.id > pending()).
    • Passes queued={isQueued} to DialogMessage and pending={pending()} to DialogTimeline.
  4. Propagates queued state through the timeline dialog (packages/opencode/src/cli/cmd/tui/routes/session/dialog-timeline.tsx)

    • Adds pending?: string prop and computes isQueued for each entry before passing it to DialogMessage.

How did you verify your code works?

  • Type-checking: bun turbo typecheck passes across all 14 packages with zero errors.
  • Relevant tests: bun test test/cli/run/runtime.queue.test.ts: 10 pass, 0 fail.
  • Manual audit of the call chain:
    • DialogMessage.receives queuedfrom the samepending()memo that drives the existingQUEUED` badge.
    • deleteMessage is a pre-existing SDK endpoint that removes only the target message and its parts; it does not touch SessionRunState or the active runner fiber.
    • Cancelling a queued message therefore does not interrupt the currently running assistant turn.

Screenshots / recordings

SCR-20260513-qxrl

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:title needs:compliance This means the issue will auto-close after 2 hours. labels May 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title Add "Cancel" action on Message Actions Dialog to cancel a queued user prompt doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate PRs Found

I found two related PRs that address similar functionality:

  1. PR feat: Add queued message editing, cancellation, and wrap-up behavior #24471: "feat: Add queued message editing, cancellation, and wrap-up behavior"

  2. PR feat: Add server-owned Steer/Queue pending messages #26199: "feat: Add server-owned Steer/Queue pending messages"

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.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@veenified veenified changed the title Add "Cancel" action on Message Actions Dialog to cancel a queued user prompt feat(opencode): Add "Cancel" action on Message Actions Dialog to cancel a queued user prompt May 13, 2026
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.

How do you dequeue a message?

2 participants