Skip to content

fix(app): insert newline on Enter for mobile prompt input#32830

Open
gjuoun wants to merge 1 commit into
anomalyco:devfrom
gjuoun:mobile-enter-newline
Open

fix(app): insert newline on Enter for mobile prompt input#32830
gjuoun wants to merge 1 commit into
anomalyco:devfrom
gjuoun:mobile-enter-newline

Conversation

@gjuoun

@gjuoun gjuoun commented Jun 18, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #20965

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Mobile virtual keyboards have no Shift key, so the existing Shift+Enter → newline / Enter → submit contract leaves mobile users with no way to insert newlines — every Enter press submits.

This adds one branch in handleKeyDown (packages/app/src/components/prompt-input.tsx) that detects touch-only devices via createMediaQuery("(hover: none)") — the same primitive already used in sidebar-workspace.tsx — and routes Enter to the existing newline-insertion path on those devices. The send button (IconButton type="submit") remains the submit path on touch.

Desktop behavior is unchanged: Enter still submits, Shift+Enter still inserts a newline. The new branch sits AFTER the popover-navigation block so popover-Enter (e.g., @-mention selection) still works on mobile.

Prior attempt: #9362 (closed for inactivity, confirmed working by users) used UA sniffing; this PR uses the codebase's existing media-query pattern instead.

How did you verify your code works?

  • bun lint — clean
  • bun typecheck in packages/app/ — clean
  • bun test in packages/app/ — no regressions
  • Manual: Chrome DevTools device mode (iPhone profile) — Enter inserts newline, send button submits. With device mode off, Enter submits as before.

Screenshots / recordings

Happy to record a before/after demo on request.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Detect touch-only devices via createMediaQuery("(hover: none)") and
route Enter (no modifiers) to the existing newline-insertion path so
mobile users — who have no Shift key on their virtual keyboard — can
add newlines without accidentally submitting. The send button remains
the sole submit path on touch devices; desktop behavior is unchanged.

Fixes anomalyco#20965
@gjuoun gjuoun requested review from Brendonovich and Hona as code owners June 18, 2026 11:52
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jun 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

web: mobile Enter key submits prompt instead of inserting newline

1 participant