Skip to content

fix: insert newline on Enter in mobile new-chat composer - #212

Merged
yongkangc merged 2 commits into
cfal:mainfrom
0xSolarPunk:fix/mobile-newchat-enter-newline
Jun 23, 2026
Merged

fix: insert newline on Enter in mobile new-chat composer#212
yongkangc merged 2 commits into
cfal:mainfrom
0xSolarPunk:fix/mobile-newchat-enter-newline

Conversation

@0xSolarPunk

Copy link
Copy Markdown
Contributor

Problem

On mobile, pressing Enter in the initial new-chat composer (the "Project Path" / New Chat dialog) immediately starts the session instead of inserting a newline. This makes it impossible to type a multi-line first message on a phone without accidentally sending. The in-chat composer already behaves correctly (Enter inserts a newline; submit is via the send button).

Solution

NewChatForm already tracks isMobile via a (max-width: 768px) media query but never passed it to shouldSubmitOnEnter, so the mobile guard was inert. Pass isMobile into the call, matching PromptComposer. shouldSubmitOnEnter already returns false (do not submit) when isMobile is true.

Changes

  • web/src/lib/components/chat/NewChatForm.svelte: pass isMobile to shouldSubmitOnEnter.
  • web/src/lib/components/chat/__tests__/NewChatFormTestHost.svelte: expose onStartChat so tests can assert submission.
  • web/src/lib/components/chat/__tests__/NewChatForm.test.ts: add regression tests — Enter does not submit on mobile (newline), Enter still submits on desktop.

Expected Impact

On mobile, Enter inserts a newline in the new-chat composer; submission happens only via the send button. Desktop behavior is unchanged. Keyboard and button submit gates now stay consistent with the in-chat composer. Verified in-browser at a 390x844 viewport and with bun run check plus the full web test suite (1348 tests) passing.

The new-chat composer submitted on Enter even on mobile because NewChatForm did not pass isMobile to shouldSubmitOnEnter, unlike the in-chat PromptComposer. On mobile, Enter now inserts a newline; submission is via the send button only.
@yongkangc
yongkangc enabled auto-merge (squash) June 23, 2026 07:18
@yongkangc
yongkangc merged commit b865a4b into cfal:main Jun 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants