Repository navigation
fix(chat): stop Return from sending a half-written prompt on a phone - #23215
Conversation
c023f90 to
ab5baa7
Compare
cruisercohen
left a comment
There was a problem hiding this comment.
Reviewed ab5baa7. Moving the narrow+touch rule into useComposerSendMode fixes this at the root: it is ChatInput's only send-mode fallback, so every host that omits sendOnEnter (side panel, split panes, mate chat, crew session window) now gets it, an explicit prop still wins, and desktop/tablet behaviour is unchanged. The ThreadPanel and Edit & Resend handlers skip Enter-submit on a phone and keep their Send buttons. Reading the tests, the three new phone cases target exactly the old behaviour, and the narrow-desktop / wide-touch cases guard the non-phone paths.
No frontend CI or AI review lane has run on this head yet (the fork workflows are waiting for maintainer approval), so this is a comment for now; happy to approve once CI is green. The red Fork PR Description check is not about the description: its log says all required template sections are present, and it failed listing check-runs.
Non-blocking:
- website/src/test/ChatPage.sendOnEnterNarrow.test.tsx (deleted): this was the only test that the Chat page composer reaches the phone rule. If ComposerDockView ever passes
sendOnEnter={chatConfig.sendOnEnter}to ChatInput again, nothing fails. Consider keeping a slim version of that harness that asserts the capturedsendOnEnteris undefined. - website/src/pages/members/ThreadPanel.tsx:385, website/src/pages/chat/UserMessage.tsx:566: on a phone these skip
ime.claimEnter, so a WebKit post-compositionend Enter from a hardware keyboard can add a blank line. This matches ChatInput's ctrl-enter path today and nothing gets sent; noting it only. - website/src/components/ChatInput.tsx:394, website/src/test/ChatInputSendMode.test.tsx:195: "crewmate's chat" -> "mate's chat" to match the docs.
|
Hi @yashl, sorry this sat so long without a review. The fix is still needed: on current main, Main has moved a lot since 10-22, and the PR now conflicts in If you can't get to it in the next day, I can carry it forward in a new PR that keeps your commit and credits you as the author. |
ab5baa7 to
1ba7f59
Compare
|
@bolichen97 Thanks, and sorry for the wait. Rebased onto main, so the conflict is gone. @cruisercohen On your notes:
The workflow runs on the new head need maintainer approval again. Could one of you approve them? |
The main Chat composer already treated Return as a new line on a narrow touch screen, but the rule lived in ComposerDockView, so a mate's chat, the side panel, a mate thread reply and Edit & Resend still sent on Return. A phone keyboard has no Shift+Return, so those boxes could not take a second line, and one slip sent a half-written prompt; in Edit & Resend it also replaced every reply below the edited message. useComposerSendMode now applies the phone rule, so every ChatInput host that leaves sendOnEnter unset gets it through its fallback, and ThreadPanel and UserMessage read the same predicate. Desktop and tablet behaviour is unchanged.
1ba7f59 to
9ea68fa
Compare
|
@bolichen97 @cruisercohen Rebased onto main again to clear new conflicts with #38454 and #37861. The workflow runs on the new head need maintainer approval. Could one of you approve them? @bolichen97, if carrying this forward in your own PR is easier, as you offered, that works for me too. |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The phone rule now lives in the one shared send-key hook, [DESIGN-REVIEWED] 9ea68fa Description read[DESCRIPTION-READ] a1e76558b6137f8f364ad9b4aca6ce6cf20618f0dc4fb5ddbf2b2afde7d35b42 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. One more box that sends a prompt on Return was left out. Notes
What this change shipsInventory (7 items) — 7 justifiedIntent: stop a phone user's stray Return from sending an unfinished prompt (or replacing the conversation in Edit & Resend) to an agent. FIX.
[FIRST-PRINCIPLES-REVIEWED] 9ea68fa Description read[DESCRIPTION-READ] 3b9cf59bd0e4beb2170c9ea7e04f12c9ba634c479ed703b0c325c5d4446158b6 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS No control is added or changed, only what Return does in existing boxes. The attached iPhone captures show Return adding a new line in mate chat, Edit & Resend and the Chat page. No blind reader has seen them in this fork lane. Notes
[UX-REVIEWED] 9ea68fa Description read[DESCRIPTION-READ] 50ce9024d8d60f24ddff4958e112771169bdcfbd8ce8b8e743224676c7179ab9 That sha256 names everything this verdict read: the PR description, plus the 6 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
cruisercohen
left a comment
There was a problem hiding this comment.
Re-reviewed 9ea68fa after the rebase. Against ab5baa7 the product logic is unchanged: ChatPage and ComposerDockView only pick up main's new forkUnavailable prop, the comments now say "mate's chat", and the slim ChatPage.sendOnEnterNarrow test now checks that ChatInput never gets sendOnEnter, which closes the coverage gap from my earlier review. The diff is docs/ and website/src/ only. Desktop Enter-to-send, IME, tablets in desktop mode and Edit & Resend behave as before, and the Lexical composer gets the phone rule through ChatInput. The AI review lanes pass on this head. The F2 note from 5880107082 (stray blank line from a hardware-keyboard IME Enter on a phone) still applies and is non-blocking.
Backend Tests (3.12, 8), and Coverage Gate as a knock-on, fail on test_kas_token_refresh_recovery.py:245. That failure comes from main: d032162 already fixed it there, and updating this branch onto current main will clear it.
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Verified on head 9ea68fa. The phone rule now lives in useReturnInsertsNewline() / useComposerSendMode(), so every ChatInput host that leaves out sendOnEnter gets it. No host passes that prop at this head. ThreadPanel and Edit & Resend skip their own Enter submit on a phone and keep a Send button. Desktop keeps the stored choice. The removed isMobile/isTouch props have no readers left, and the PR merges cleanly onto current main. Each production hunk has a test that goes red when it is reverted, and both halves of the phone check are pinned.
Done well: this removes a duplicated rule rather than adding a third copy, and the tests assert the synchronous keyDown result, so a submit cannot slip through.
Optional:
- Add a
## Real-machine verificationsection (machine, before on main, after on this head, cleanup). One pass on a real phone keyboard would be ideal, because the harness cannot drive it. A body edit is enough. - The header comment in
useComposerSendMode.ts(lines 6 to 11) still says a host that omits the prop gets the stored mode. It could mention the phone case. - #38238 edits the ComposerDockView line this PR deletes. When it rebases, its fold rule belongs in
useReturnInsertsNewline(), not in an explicit prop.
Problem / Motivation
Goal: On a phone, Return never sends a half-written message from a chat composer, a mate thread reply or Edit & Resend; the Send button does.
On a phone the Chat page composer treats Return as a new line, but the other places you message an agent send on Return: a mate's chat, the side panel, the split panes, a crew session window, a mate thread reply and Edit & Resend. A phone's on-screen keyboard has no Shift+Return, so those boxes cannot take a second line, and one slip sends the draft. In Edit & Resend the same slip replaces every reply below the edited message.
Why it matters
Anyone driving the dashboard from a phone, the case the remote-and-mobile guide is written for, can send an unfinished instruction to an agent, which then starts work on the wrong request. In Edit & Resend the slip throws away the conversation below the edited message.
Not a goal
What changed (motivation → approach → change)
On a phone, every box that sends a prompt follows one rule: Return adds a line, and the Send button sends.
The phone rule (
useIsMobile()on a touch screen, from #16585) sat inComposerDockView'ssendOnEnterprop, so only the Chat page composer had it. The other hosts ofcomponents/ChatInput.tsx(the side panel, the split panes, a mate's chat and a crew session window) leave that prop out and fall back touseComposerSendMode(), which returned the stored setting alone. TheThreadPanelandUserMessage(Edit & Resend) textareas submit on Enter themselves.The rule moves into
hooks/useComposerSendMode.ts.useReturnInsertsNewline()reports a phone, anduseComposerSendMode()returns'ctrl-enter'there, so everyChatInputhost that omitssendOnEntergets the rule through the fallback from #11411.ThreadPanelandUserMessageskip their Enter submit whenuseReturnInsertsNewline()is true.ComposerDockViewdrops its copy of the rule along with theisMobile/isTouchprops that only fed it, andpageEnvironmentstops computingisTouch. An explicitsendOnEnterprop onChatInputstill wins.docs/guides/remote-and-mobile.mdsays what Return does on a phone.Backwards compatibility
Compatible: no stored setting, API or prop used outside this diff changes; desktop and tablet keep the stored send key, and the Chat page composer behaves as before on a phone.
Reader: website/src/pages/ChatPage.tsx:ChatPage -- chat -- the only caller of
useChatPageEnvironment(), the only reader of itsisTouchand the only caller passingisMobile/isTouchtoComposerDockView; updated in this diff (checked on origin/main @ 6bd6d5b).Reader: website/src/pages/chat/page/ComposerDockView.tsx:ComposerDockView -- chat -- its only use of the two props was the removed
sendOnEnterline.Tests
ChatInputSendMode.test.tsx: on a phone with Enter-sends stored, Enter inserts a new line; an explicitsendOnEnterprop still wins; a narrow desktop window and a wide touch screen keep Enter-sends. These viewport and pointer cases move here fromChatPage.sendOnEnterNarrow.test.tsx, so they sit next to the rule.ChatPage.sendOnEnterNarrow.test.tsx: keeps its Chat page harness for one case: on a phone the page passes nosendOnEnter, soChatInput's fallback applies the rule.ThreadPanel.test.tsx: on a phone, Return does not reply, and Send reply does.UserMessage.test.tsx: on a phone, Return does not resend, and Send does.Proof: not provable -- frontend test (prove.py runs Python only)
Red on the parent, green here, and stable under repeats and shuffling (vitest 4.1.12, Node 24, in the Playwright 1.58.2 image):
Local gates on this branch (base 6bd6d5b), same image:
Manual verification
The real built dashboard, served with
/apistubbed, in Playwright WebKit with the iPhone 15 Pro device profile. Before is main @ 8623713 and after is this diff applied to the same commit. The code that decides what Return does (theuseComposerSendModehook,ChatInput's fallback, theComposerDockViewrule and theThreadPanelandUserMessageEnter handlers) reads the same at that commit and at this PR's base, 6bd6d5b. Since thenuseIsMobile()also gives a touch-first browser in mobile mode the phone layout at any width (#30619); the iPhone profile gets the phone layout at both commits. For each box: type a draft, press Return, record whether a send request left the page, then tap Send.POST /api/chatPOST /api/chat/slots/:slot/rewindOn a 1280x860 desktop with no touch, Return sends in all three boxes, before and after.
Not covered by the capture: the thread reply (unit test above), the side panel, and the iOS on-screen keyboard itself (the harness presses Enter through Playwright). The image captions use the feature's older name, crewmate.
Screenshots / video
Mate chat
Edit & Resend
Chat page composer, unchanged
Related Issues
Closes #22909
Builds on #16585 (the phone rule for the Chat page composer) and #11411 (one send-key source for every composer).
Sibling sweep
Swept: git grep -nE "key === 'Enter' && !e.shiftKey" -- website/src, plus every
<ChatInputhost and everysubmitOnEntercallerSibling: website/src/components/ChatInput.tsx:412 -- changed here
Sibling: website/src/pages/members/ThreadPanel.tsx:385 -- changed here
Sibling: website/src/pages/chat/UserMessage.tsx:636 -- changed here
Sibling: website/src/components/CommentThreadPopover.tsx:248 -- not affected -- posts an editable comment, not a prompt
Sibling: website/src/components/CommentsSidebar.tsx:95 -- not affected -- its three boxes post editable comments, not prompts
Sibling: website/src/components/SelectionToolbar.tsx:1673 -- not affected -- posts an editable comment, not a prompt
Sibling: website/src/components/QueueStack.tsx:438 -- not affected -- edits a queued message in place and sends nothing
Sibling: website/src/pages/chat-sidebar/NeedsMeHoverCard.tsx:541 -- not affected -- desktop only; the card never opens for touch
Sibling: website/src/apps/md-notebook/BlockEditor.tsx:132 -- not affected -- Return splits a notebook block and sends nothing
Sibling: website/src/apps/auto-research/GrillTree.tsx:40 -- not affected -- Return keeps the answer in the form and sends nothing
Sibling: website/src/apps/mochi/src/renderer/ChatPanel.tsx:1459 -- not affected -- a desktop-only window the Electron shell opens; no dashboard page links to it
Pattern harvest
Rule candidate: semgrep
Pattern: a
<textarea>onKeyDownthat submits one.key === 'Enter' && !e.shiftKeywithout readinguseReturnInsertsNewline()oruseComposerSendMode().Checklist
docs/guides/remote-and-mobile.md)Contribution License Agreement
Contributed under the project's Apache-2.0 license.