Skip to content

fix(chat): stop Return from sending a half-written prompt on a phone - #23215

Merged
KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
yashl:fix/phone-return-newline
Nov 19, 2026
Merged

KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
yashl:fix/phone-return-newline

Conversation

@yashl

@yashl yashl commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Desktop and tablet behaviour: Settings → Chat → Composer → Send shortcut still decides what Return does there.
  • Comment boxes (artifact comment threads, the comments sidebar, the selection toolbar's comment box): a slip there posts an editable comment, not a prompt.
  • The queued-message editor: a one-row inline edit that commits on Return or blur and sends nothing.
  • The Channels page composers: the channel thread reply has no Send button, so Return is its only send control.
  • App bundles with their own composers.

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 in ComposerDockView's sendOnEnter prop, so only the Chat page composer had it. The other hosts of components/ChatInput.tsx (the side panel, the split panes, a mate's chat and a crew session window) leave that prop out and fall back to useComposerSendMode(), which returned the stored setting alone. The ThreadPanel and UserMessage (Edit & Resend) textareas submit on Enter themselves.

The rule moves into hooks/useComposerSendMode.ts. useReturnInsertsNewline() reports a phone, and useComposerSendMode() returns 'ctrl-enter' there, so every ChatInput host that omits sendOnEnter gets the rule through the fallback from #11411. ThreadPanel and UserMessage skip their Enter submit when useReturnInsertsNewline() is true. ComposerDockView drops its copy of the rule along with the isMobile/isTouch props that only fed it, and pageEnvironment stops computing isTouch. An explicit sendOnEnter prop on ChatInput still wins. docs/guides/remote-and-mobile.md says 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 its isTouch and the only caller passing isMobile/isTouch to ComposerDockView; 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 sendOnEnter line.

Tests

  • ChatInputSendMode.test.tsx: on a phone with Enter-sends stored, Enter inserts a new line; an explicit sendOnEnter prop still wins; a narrow desktop window and a wide touch screen keep Enter-sends. These viewport and pointer cases move here from ChatPage.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 no sendOnEnter, so ChatInput'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):

# main @ 6bd6d5b3ce plus only this PR's four test files
npx vitest run src/test/ChatInputSendMode.test.tsx src/pages/members/ThreadPanel.test.tsx src/test/UserMessage.test.tsx src/test/ChatPage.sendOnEnterNarrow.test.tsx
  Test Files  4 failed (4)
       Tests  4 failed | 113 passed (117)

# this branch: 20 repeats, then 5 shuffled orders
for i in $(seq 20); do npx vitest run <same four files> || break; done
  20 of 20 passed
npx vitest run <same four files> --sequence.shuffle --sequence.seed=$SEED
  seed=4242 117 passed | seed=31337 117 passed | seed=27182 117 passed | seed=16180 117 passed | seed=9001 117 passed

# this branch with sendOnEnter={chatConfig.sendOnEnter} put back on ComposerDockView's ChatInput
npx vitest run src/test/ChatPage.sendOnEnterNarrow.test.tsx
  Tests  1 failed (1): expected [ 'enter', 'enter', 'enter', …(3) ] to deeply equal []

Local gates on this branch (base 6bd6d5b), same image:

scripts/run_scoped_tests.py --surface frontend          738 files, 18212 tests passed
scripts/run_scoped_tests.py --surface backend           1368 files: 27073 passed, 268 skipped; 25 needed Node or lsof, and their 4 files pass with both (195 passed)
tsc -p tsconfig.app.json, eslint src/ --max-warnings 0   pass
i18n:check, i18n:render, lint:phantom-classes, lint:restyle-ratchet, gen:ui --check   pass
npm run build; vite build --mode analyze (fresh install, as CI runs it) with check-bundle-size and check-chunk-cycles   pass
bench:render --fail-on dispatches,selectorCalls          pass
jscpd                                                    0 clones
semgrep 1.78.0 scan --config semgrep/ on the 11 changed website/src files   0 findings
the profile's 47 standalone Python gates (comment history, brand name, docs lint, file line cap, focus cue, ...)   pass
not run: isort, flake8, mypy, black, cfn-lint, test:electron (no Python, CloudFormation or Electron files in the diff)

Manual verification

The real built dashboard, served with /api stubbed, 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 (the useComposerSendMode hook, ChatInput's fallback, the ComposerDockView rule and the ThreadPanel and UserMessage Enter handlers) reads the same at that commit and at this PR's base, 6bd6d5b. Since then useIsMobile() 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.

Box Before: Return After: Return After: tap Send
Chat composer new line new line sent
Mate chat sent POST /api/chat new line sent
Edit & Resend sent POST /api/chat/slots/:slot/rewind new line sent

On 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

Mate chat on an iPhone: before the fix Return sends the half-written draft; after it, Return adds a line and tapping Send sends

Edit & Resend

Edit and Resend on an iPhone: before the fix Return resends and replaces the answer below; after it, Return adds a line and the answer stays
Chat page composer, unchanged Chat page composer on an iPhone: Return adds a line before and after the fix

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 <ChatInput host and every submitOnEnter caller
Sibling: 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

Same defect, left out by Not a goal: the Channels page composer (website/src/pages/ChannelPage.tsx:634; it has a Send button, but its MentionInput also serves the thread reply, which has none), the app SDK chat embed (website/src/app-sdk/useComposerDraft.ts:474, used by Spec Builder and Ops Mission Control) and Research Lab's guidance box (website/src/apps/auto-research/ResearchLabPage.tsx:648).

Pattern harvest

Rule candidate: semgrep
Pattern: a <textarea> onKeyDown that submits on e.key === 'Enter' && !e.shiftKey without reading useReturnInsertsNewline() or useComposerSendMode().

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (docs/guides/remote-and-mobile.md)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 22, 2026
@yashl
yashl force-pushed the fix/phone-return-newline branch from c023f90 to ab5baa7 Compare November 5, 2026 23:31
@yashl
yashl marked this pull request as ready for review November 5, 2026 23:33
@yashl
yashl requested review from a team and KiroCrewCaptain as code owners November 5, 2026 23:33
@yashl
yashl requested a review from cruisercohen November 5, 2026 23:33
@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 5, 2026

@cruisercohen cruisercohen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 captured sendOnEnter is 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.

@bolichen97

Copy link
Copy Markdown
Contributor

Hi @yashl, sorry this sat so long without a review. The fix is still needed: on current main, ComposerDockView.tsx still applies the narrow-touch Return rule only to the main composer (sendOnEnter={isMobile && isTouch ? 'ctrl-enter' : chatConfig.sendOnEnter}), so a mate chat, the side panel, thread replies and Edit & Resend still send on Return on a phone.

Main has moved a lot since 10-22, and the PR now conflicts in website/src/pages/ChatPage.tsx and website/src/pages/chat/page/ComposerDockView.tsx. Could you rebase onto main? I will review the rebased head right away.

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.

@yashl

yashl commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@bolichen97 Thanks, and sorry for the wait. Rebased onto main, so the conflict is gone.

@cruisercohen On your notes:

  1. Fixed: ChatPage.sendOnEnterNarrow.test.tsx stays, slimmed to one case that fails if the Chat page passes sendOnEnter to ChatInput on a phone.
  2. Leaving it as is, since it matches ChatInput's Ctrl+Enter path and nothing gets sent.
  3. Fixed: both comments now say "mate's chat".

The workflow runs on the new head need maintainer approval again. Could one of you approve them?

@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 17, 2026
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.
@yashl
yashl force-pushed the fix/phone-return-newline branch from 1ba7f59 to 9ea68fa Compare November 18, 2026 21:03
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 18, 2026
@yashl

yashl commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

@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.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 9ea68fa2f445a5683002549e8d9da673a1ce54eb via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The phone rule now lives in the one shared send-key hook, ChatInput is the only thing that reads that hook, and the two hand-written Enter handlers use the same helper.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 9ea68fa2f445a5683002549e8d9da673a1ce54eb via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. One more box that sends a prompt on Return was left out.

Notes

  • Item 2 — symptom-level: grepping key === 'Enter' && !e.shiftKey in non-test website/src finds one more box that sends a prompt on Return and is not in ## Not a goal. It is pages/chat-sidebar/NeedsMeHoverCard.tsx:541, which calls void send() → sendTurn, and this diff leaves it alone. Subtraction: gate its Enter branch on useReturnInsertsNewline() the same way, or name it in ## Not a goal.

What this change ships

Inventory (7 items) — 7 justified

Intent: stop a phone user's stray Return from sending an unfinished prompt (or replacing the conversation in Edit & Resend) to an agent. FIX.

  1. On a phone, Return adds a line in a mate's chat, the side panel, split panes and crew windows — justified
  2. On a phone, Return adds a line in a mate thread reply — justified
  3. On a phone, Return adds a line in Edit & Resend — justified
  4. Chat page's own phone rule removed, along with the isMobile/isTouch props and pageEnvironment.isTouch — justified
  5. New exported useReturnInsertsNewline() hook, used by useComposerSendMode, ThreadPanel and UserMessage — justified
  6. Remote-and-mobile guide now says what Return does on a phone — justified
  7. Viewport/pointer tests moved from the ChatPage harness to ChatInputSendMode — justified

[FIRST-PRINCIPLES-REVIEWED] 9ea68fa

Description read

[DESCRIPTION-READ] 3b9cf59bd0e4beb2170c9ea7e04f12c9ba634c479ed703b0c325c5d4446158b6

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS

UX-level review of 9ea68fa2f445a5683002549e8d9da673a1ce54eb via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • The thread reply box isn't in any capture. Only the unit test covers it. One more still, like the mate-chat strip, would cover the last box the Goal names.
  • On a phone, Settings → Chat → Composer → Send shortcut now has no effect in any composer, and the settings row doesn't say so. Add a line under it, for example "On a phone, Return always starts a new line." That way someone who picks "Enter sends" on a phone isn't left thinking the setting is broken.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 9ea68fa2f445a5683002549e8d9da673a1ce54eb via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 9ea68fa

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 9ea68fa2f445a5683002549e8d9da673a1ce54eb via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 9ea68fa

@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Nov 18, 2026
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 18, 2026

@cruisercohen cruisercohen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@iamwhatever iamwhatever reopened this Nov 19, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 19, 2026
@KiroCrewCaptain
KiroCrewCaptain merged commit 40a079e into kirodotdev:main Nov 19, 2026
187 of 189 checks passed

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 verification section (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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On a phone, Return sends the message in crewmate chat, Edit & Resend and thread replies

5 participants