feat(prompt): queue prompts while the agent is busy - #194
Open
hcsum wants to merge 1 commit into
Open
Conversation
Instead of rejecting a prompt sent while a run is in flight, park it in a per-session queue and dispatch it (one at a time) when the session goes idle, mirroring the OpenCode TUI. Queued prompts get an inline cancel button; the guard lets plain prompts through as queueable while blocking reply-keyboard buttons and pending interactions. Reliability fixes: - Drain the queue from busy-state reconciliation, so a run whose session.idle event was missed no longer strands queued prompts forever (injected via setQueueFlusherForReconciliation to keep the app layer free of a bot-layer import). - Clear the queue explicitly on /abort local release instead of relying on a session.error event that may never arrive when abort is confirmed via status polling. - On a failed async prompt start, flip the queued item's ack to failed and advance the rest of the queue, which no idle event would drain. UX: - Add /unqueue to drop the most recent queued prompt from the bottom of the chat, where a scrolled-away inline cancel button is out of reach. - On batch clears, post a single summary instead of editing each (already scrolled-away) queued bubble in place. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
hcsum
force-pushed
the
feat/queue-prompts-while-busy
branch
from
July 27, 2026 15:21
4690df8 to
828a812
Compare
hcsum
marked this pull request as ready for review
July 29, 2026 03:33
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.
Description of changes
A prompt sent while a run is in flight is currently rejected. This queues it instead and dispatches it when the session goes idle, one at a time, like the OpenCode TUI.
/unqueueremoves the newest queued prompt, for when the bubble has scrolled out of reach./abort,/detach,session.error,session.idlewas missed doesn't strand the queue.On the visibility concern in #119 — a queued message scrolls away fast in a busy session. This PR does not solve that; it only adds the per-message bubble and
/unqueueand leaves the pinned message alone. If queue state should live in the pinned message or elsewhere, that's a separate call and I'd rather have the queue mechanics reviewed first.Closes issue (optional)
How it was tested
Manual: queue several prompts mid-run and let them execute; cancel via the inline button;
/unqueue;/abortwith items queued;/detachwith items queued. Note that switching sessions while a run is in flight isn't possible in the current UI, so that path is covered by unit tests only.Unit tests cover the queue lifecycle (ack, ordering, cap, cancel,
/unqueue, failed dispatch, session change) plus the guard, abort, detach and reconciliation paths:tests/bot/handlers/prompt-queue.test.tsand additions to the interaction-guard, abort, detach, busy-reconciliation and command-router suites.Checklist
<type>(<scope>)?: <description>mainnpm run lint,npm run build, andnpm testDraft — #119 hasn't been confirmed by a maintainer yet, so this is here to review the shape against.