fix(client): restore preset prompt insertion on mobile - #14719
Open
RedwindA wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a mobile focus/keyboard regression when inserting sidebar preset prompts by moving prompt insertion from a DOM helper (which focuses the textarea) to updating the chat form state directly, while preserving cursor/selection behavior.
Changes:
- Insert active sidebar prompt via
useChatFormContext().setValue()instead ofinsertTextAtCursor()to avoid forcing textarea focus. - Preserve selection and reposition cursor after the inserted prompt, while keeping textarea resize + active-prompt cleanup behavior.
- Add a regression unit test covering insertion without relying on DOM focus.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| client/src/hooks/Input/useTextarea.ts | Reworks active prompt insertion to update form state and cursor position without focusing the textarea. |
| client/src/hooks/Input/useTextarea.spec.ts | Adds a regression test ensuring prompt insertion uses form state (not insertTextAtCursor) and updates cursor/selection. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
RedwindA
marked this pull request as ready for review
August 9, 2026 10:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #14620.
On mobile, selecting a preset prompt with Send prompts on select disabled left the composer unchanged. The insertion path relied on a DOM editing helper, which did not synchronize the selected text with the chat form state in the affected flow.
This change:
Users can now tap any preset prompt on mobile and have it appear in the composer for editing or manual submission.
Change Type
Testing
cd client && npm run test:ci -- src/hooks/Input/useTextarea.spec.ts— passed (1 suite, 1 test).npx eslint client/src/hooks/Input/useTextarea.ts client/src/hooks/Input/useTextarea.spec.ts— passed.npm --prefix client run typecheck— currently blocked by existing generated package/export mismatches ondev; none of the diagnostics reference the two files changed by this PR.Test Configuration:
test:ciscriptChecklist