Skip to content

feat(chat): queue messages while a turn is active#237

Merged
remarkablemark merged 3 commits into
masterfrom
feat/messages
Jul 12, 2026
Merged

feat(chat): queue messages while a turn is active#237
remarkablemark merged 3 commits into
masterfrom
feat/messages

Conversation

@remarkablemark

@remarkablemark remarkablemark commented Jul 11, 2026

Copy link
Copy Markdown
Member

What is the motivation for this pull request?

Feature: allow users to type and submit messages while a chat turn is in progress. Instead of discarding or blocking input, messages are queued and processed sequentially once the current turn completes.

plan.md

What is the current behavior?

When the chat is loading / processing a turn, ChatInput is disabled (isDisabled) and any submitted input is silently dropped.

What is the new behavior?

  • Plain text messages submitted while a turn is active are enqueued and displayed as "Queued messages" below the input.
  • The queue drains automatically in FIFO order once the chat is no longer paused (loading, pending plan, or pending tool call).
  • Pressing ↑ while the input is empty and active restores the last queued message back into the input field.
  • Commands (/, !) and image attachments cannot be queued; attempting to queue them shows an inline error.
  • Escape / Ctrl-C while active interrupts the current turn.
  • A new useMessageQueue hook encapsulates all queue state and drain logic, extracted from Chat for clarity and testability.

Checklist:

Allow users to compose and queue follow-up messages while the current model turn is running. Display the pending FIFO queue directly above the chat input under the label **“Queued messages:”**, then submit each message as a separate turn after the preceding turn fully completes.

---

Changes

- Keep `ChatInput` editable during streaming; retain Esc/Ctrl+C as active-turn interruption controls.
- In `Chat`, store queued `SubmittedInput` values separately from persisted conversation messages.
- When a normal text prompt is submitted while `isLoading`, append it to the queue instead of starting another turn. Do not add it to session history until execution begins.
- Drain one queued message when the chat becomes idle, provided no tool approval or plan review is pending. Preserve FIFO execution and start the next item through the existing turn flow.
- Render a compact queue preview above `ChatInput`:
  - Header: `Queued messages:`
  - Show each message in submission order with a dimmed `↳` prefix.
  - Truncate only the visual preview; retain the full queued content.
- When the input is empty during an active turn, Up Arrow removes the most recently queued message and restores it to the composer. The user can edit and resubmit it or clear the composer to delete it. Normal history navigation resumes when no queued messages remain.
- Clear queued messages when switching sessions. Interrupting the active turn leaves the queue intact and allows it to continue afterward.
- Do not queue slash commands, `!` shell commands, `/compact`, or image attachments in the initial version; keep their current behavior unavailable while a turn is active.

---

Interfaces and State

- Add queue state and dequeue/restore handlers at the `Chat` level.
- Extend `ChatInput` with:
  - active-turn status distinct from full input disablement;
  - an optional callback for restoring the latest queued message;
  - queue-aware submission behavior and hints.
- Add a small colocated queue-preview component if extracting the rendering keeps `Chat` focused; no public package API or persisted session format changes.
Added `src/components/Chat/hooks/useMessageQueue.ts` and
exported it through the hooks barrel.

The hook now owns:

- FIFO queue draining
- Pause handling
- Duplicate-drain protection
- LIFO restoration for editing
- Session-reset clearing

`Chat` retains message classification and rendering.
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/components/Chat/Chat.tsx 100.00% <100.00%> (ø)
src/components/Chat/ChatInput.tsx 100.00% <100.00%> (ø)
src/components/Chat/hooks/useMessageQueue.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@remarkablemark remarkablemark self-assigned this Jul 11, 2026
@remarkablemark remarkablemark added the enhancement New feature or request label Jul 11, 2026
@remarkablemark remarkablemark merged commit 689758f into master Jul 12, 2026
16 checks passed
@remarkablemark remarkablemark deleted the feat/messages branch July 12, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant