Skip to content

fix(client): restore preset prompt insertion on mobile - #14719

Open
RedwindA wants to merge 1 commit into
danny-avila:devfrom
RedwindA:fix/14620-mobile-preset-send
Open

fix(client): restore preset prompt insertion on mobile#14719
RedwindA wants to merge 1 commit into
danny-avila:devfrom
RedwindA:fix/14620-mobile-preset-send

Conversation

@RedwindA

@RedwindA RedwindA commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

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:

  • writes the selected prompt directly through the chat form state;
  • inserts it at the textarea's current selection and places the cursor after the new text;
  • keeps textarea resizing and active-prompt cleanup behavior;
  • adds a regression test proving that prompt insertion no longer depends on the DOM editing helper.

Users can now tap any preset prompt on mobile and have it appear in the composer for editing or manual submission.

Change Type

  • Bug fix (non-breaking change which fixes an issue)

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 on dev; none of the diagnostics reference the two files changed by this PR.

Test Configuration:

  • Node.js v24.13.1
  • Jest with jsdom via the client test:ci script

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes

Copilot AI lite review requested due to automatic review settings August 9, 2026 09:49

Copilot AI 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.

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 of insertTextAtCursor() 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.

Comment thread client/src/hooks/Input/useTextarea.ts
@RedwindA RedwindA changed the title fix(client): insert sidebar prompts without focusing composer fix(client): restore preset prompt insertion on mobile Aug 9, 2026
@RedwindA
RedwindA marked this pull request as ready for review August 9, 2026 10:00
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