Skip to content

[FEATURE]: Graceful handling of queued messages after session interrupt #5333

@thoughtlesslabs

Description

@thoughtlesslabs

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem

When a user sends multiple messages while an operation is in progress, the messages are queued. However, if the current operation is interrupted (aborted), the queued messages are silently rejected and lost rather than being processed. This creates a poor user experience, especially when iterating quickly with the AI assistant.

Current behavior:

current-queue-system.mp4
  • User sends message A (starts processing)
  • User sends message B while A is processing (queued)
  • User interrupts message A
  • Message B is silently discarded ❌

Expected behavior:

  • User sends message A (starts processing)
  • User sends message B while A is processing (queued)
  • User interrupts message A
  • Message B begins processing automatically ✅

Proposed Solution

This feature adds graceful queue handling with full visibility and control:

Screen.Recording.2025-12-10.at.1.47.19.PM.mov

1. Queue Persistence After Interrupts

Queued messages remain in the queue and are processed in order after an interrupt, rather than being rejected.

2. Cancel Individual Queued Messages

Users can remove specific messages from the queue via the message action dialog (click on a queued message to see the "Cancel" option).

Image

3. Separated Queue Display

Queued messages are pinned in a dedicated section above the input prompt, visually separated from the scrolling conversation. A "Processing next task..." separator shows when tasks transition.

Image

Implementation

A working implementation is available in the fork branch:

🔗 https://github.com/thoughtlesslabs/opencode/tree/feat/queued-message-interrupt

Key Changes

File Description
packages/opencode/src/session/prompt.ts Queue handling logic with loopId tracking to prevent race conditions, cancelQueued() and getQueuedMessageIds() functions
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx Visual queue separation with queuedMessages and activeMessages memos, pinned queue section
packages/opencode/src/cli/cmd/tui/routes/session/dialog-message.tsx Cancel action for queued messages in the message dialog

Technical Details

  • Added loopId tracking using ulid() to prevent race conditions when canceling/restarting loops
  • Queue callbacks now include userMessageID for proper tracking
  • processQueuedCallbacks() handles ordered queue processing after interrupts
  • UI uses SolidJS reactive memos for efficient queue state management

Why It Belongs in OpenCode

  1. Improves UX - User input is never silently discarded
  2. Provides transparency - Users can see exactly what's queued and processing
  3. Gives users control - Ability to cancel individual queued messages
  4. Common workflow - Users frequently iterate quickly, sending follow-up messages before the AI finishes
  5. No breaking changes - Backward compatible enhancement to existing behavior

This feature request follows the CONTRIBUTING.md guidelines for net-new functionality.

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions