Skip to content

fix(site/src): swap Stop for Queue once a draft exists while streaming - #29507

Merged
jscottmiller merged 4 commits into
mainfrom
scott/mobile-queue-send
Sep 22, 2026
Merged

jscottmiller merged 4 commits into
mainfrom
scott/mobile-queue-send

Conversation

@jscottmiller

@jscottmiller jscottmiller commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

On viewports below 640 px, Enter inserts a newline, so once a turn was streaming the footer offered only Stop and there was no way to queue a follow-up message from touch.

The rightmost footer slot now follows one rule while a turn streams: Stop while the draft is empty, and the send button labelled Queue once the draft has sendable text, an active upload, or a live voice recording. Editing a history message while streaming keeps Stop. When not streaming, nothing changes. Exactly one of Stop or the send button renders in the slot at any time.

Two fixes from the UAT report are included:

  • Below 640 px, the send button omits aria-keyshortcuts and the tooltip shortcut suffix, and the queued list hides its Enter hint (hidden sm:flex), since Enter does not send there.
  • Voice input is available while a turn streams. The mic renders whenever speech recognition is supported, so a recording can start mid-stream; Accept holds the primary slot while recording, then Queue once the transcript lands, and Cancel with an empty draft returns to Stop. Accept and Cancel refocus the editor on non-mobile viewports.

UAT report: https://github.com/coder/scott-misc/blob/main/uat/mobile-queue-send-uat/README.md

Merge point with #29216: that PR changes the label to isEditingMessage ? "Save Edit" : isChatPaused ? "Queue" : "Send" and renames isEditingHistoryMessage to isEditingMessage. Whichever lands second should resolve the label to isEditingMessage ? "Save Edit" : isStreaming || isChatPaused ? "Queue" : "Send".

UAT findings disposition
# Finding Disposition
1 Stop unreachable while a draft exists; live Stop returns under thumb after Queue Accepted as designed (single-slot rule)
2 Queue tooltip and aria-keyshortcuts say Enter below 640 px; queued-list hint mismatches Fixed here
3 Focus lands on body after Queue on phone Deferred until #29216 lands (rewrites the same button block)
4 Interrupt with queued messages promotes the queue instead of stopping Skipped; pre-existing chatd behavior, needs design atop #29215 hold semantics
5 Voice recording loses Accept and Cancel when a turn starts Fixed here, extended: the mic is available throughout a stream, not only for a recording already in progress
6 384 px attachment-error toast covers the footer on a 390 px phone Skipped; global Toaster width, needs design sign-off
Implementation plan

Repository: /home/coder/coder, branch scott/mobile-queue-send off origin/main.

Confirmed reading

  • AgentChatInput.tsx: handleSubmit does not check isStreaming; the editor's onEnter={handleSubmit} therefore queues a message while a turn streams, and the page's send path handles response.queued. Footer right group: voice input hidden while streaming, context usage visible, Stop under isStreaming && onInterrupt, send button only under !isStreaming. sendButtonLabel is "Save Edit" | "Send"; open PR feat(site): edit queued chat messages #29216 changes it to isEditingMessage ? "Save Edit" : isChatPaused ? "Queue" : "Send".
  • Gap: on touch/narrow viewports Enter inserts a newline, so there is no way to queue.

Decisions and constraints

  • Do not add a Queue button beside Stop. Render one primary footer button whose role depends on the composer draft while a turn streams: draft empty shows Stop; draft non-empty shows the send button labelled "Queue", submitting through the existing handleSubmit path. Not streaming: unchanged. The button stays in the rightmost footer slot.
  • "Draft non-empty" is draftOccupiesSlot = hasSendableContent || hasActiveUploads: an attachment still uploading shows a transiently disabled Queue, an errored-only attachment keeps Stop. Stop is also kept while a history message is being edited during a stream; Enter still saves the edit.
  • While streaming with an empty draft and no onInterrupt, nothing renders in the slot (same as main).
  • Smallest change, Vitest for behaviour, setup-only stories with a narrow-viewport streaming story.

Scope

Single component change plus test and story. No page wiring, no server change.

Changes

  1. AgentChatInput.tsx: label isEditingHistoryMessage ? "Save Edit" : isStreaming ? "Queue" : "Send"; footer slot shows Stop when isStreaming && onInterrupt && !draftOccupiesSlot, the send button when !isStreaming || draftOccupiesSlot; spinner only when isLoading && !isInterruptPending; tooltip Queue: <shortcut> follows from the label.
  2. AgentChatInput.test.tsx: Stop -> Queue -> Stop after draft clear, with callback assertions; interrupt-pending with a draft renders a disabled Queue that does not call onSend.
  3. AgentChatInput.stories.tsx: narrow-viewport streaming story with a draft so the 390 px footer with Queue in the Stop slot is captured.
  4. ChatPageContent.stories.tsx InterruptingShowsBusyComposer: the absent-send-button assertion queries the streaming label "Queue".

UAT follow-up (this PR)

  • Item 2: mobileViewportMediaQuery constant in utils/mobile.ts; useMediaQuery in AgentChatInput drops aria-keyshortcuts and the tooltip suffix below 640 px; queued-list hint hidden sm:flex.
  • Item 5: mic cluster rendered whenever speech.isSupported; speech.isRecording added to draftOccupiesSlot; a live recording takes precedence over history editing in the slot.

This PR was generated by Coder Agents on behalf of @jscottmiller.

On viewports below 640px a streaming turn previously left only Stop in the
footer, so queued sends were unreachable from touch. The rightmost footer
slot now shows Stop while the draft is empty and a send button labelled
Queue once there is sendable text, an active upload, or a live voice
recording. History-message editing while streaming keeps Stop.

Below 640px, Enter inserts a newline, so the send button omits
aria-keyshortcuts and the tooltip shortcut suffix there, and the queued
list hides its Enter hint. The mic cluster stays mounted while a recording
outlives the start of a turn so Accept and Cancel remain reachable.
@jscottmiller
jscottmiller force-pushed the scott/mobile-queue-send branch from 503f2d9 to 7d6c7d0 Compare September 17, 2026 22:54
Scott Miller added 2 commits September 18, 2026 02:46
The mic renders whenever speech recognition is supported, so a recording can
start mid-stream and land in the Queue slot. Recognition errors clear after
five seconds instead of persisting until the next recording.
…xt recording

Restores useSpeechRecognition to its main behaviour: a recognition error
stays exposed until start() or cancel() clears it.
@jscottmiller
jscottmiller marked this pull request as ready for review September 18, 2026 03:14
bpmct added a commit that referenced this pull request Sep 20, 2026
Enter and Cmd/Ctrl+Enter inserted newlines instead of sending when the
Coder Agents window was narrower than 640px. This broke desktop split
views even with the Cmd/Ctrl+Enter preference enabled.

Use pointer capability instead of window width for touch keyboard
behavior. Narrow desktop windows respect the send preference,
Cmd/Ctrl+Enter works at every width, and Shift+Enter still inserts a
newline.

Fixes #28438. Refs
[CODAGT-1006](https://linear.app/codercom/issue/CODAGT-1006).

Tested on web (macOS/Chrome):


https://github.com/user-attachments/assets/10e3fc49-d5b5-4438-96b8-5fe740b6acbb

Tested on iOS:



https://github.com/user-attachments/assets/0a3844f8-721a-469e-a822-7e8ea89586d9



<details>
<summary>Implementation and verification notes</summary>

The change is limited to the shared composer Enter handler, its existing
tests, and the mobile composer story. Plain Enter inserts a newline when
the primary pointer is coarse, including on larger touch devices.
Cmd/Ctrl+Enter bypasses that check. Pointer capability is a proxy for
touch input, not a physical-keyboard detector.

Regression tests reproduced the bug before the fix. All 87 targeted unit
tests and 99 composer stories pass, along with frontend formatting,
lint, typechecking, and the full make pre-commit checks. Browser checks
confirmed submit callbacks at 390px and 1280px with both send
preferences and touch emulation. A dev-instance chat also completed
through dogfood AI Gateway.

The related queue-button work in #29507 is not a dependency.

</details>

Generated by Coder Agents on behalf of @bpmct.
DanielleMaywood

This comment was marked as low quality.

…int and tidy viewport stub

Add a phone Pixel viewport to the SeveralMessages story so the hidden
Enter-to-send hint is visually covered, capture matchMedia once so
stubViewport does not nest stubs when called twice in a test, and rename
the shortcut test to match what it asserts.
@jscottmiller
jscottmiller merged commit fb61a1f into main Sep 22, 2026
25 of 26 checks passed
@jscottmiller
jscottmiller deleted the scott/mobile-queue-send branch September 22, 2026 22:12
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants