Skip to content

fix(mobile): hold-to-dictate, repeat keys and the browser long-press survive the page's long-press - #24277

Merged
Jinwoo-H merged 13 commits into
mainfrom
mobile-page-hold-dictation
Oct 1, 2026
Merged

Jinwoo-H merged 13 commits into
mainfrom
mobile-page-hold-dictation

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​436 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​430
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​300 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​296

What

On the OTA page, holding the mic in hold-to-dictate mode stopped recording about half a second in and sometimes selected nearby text (the "Model" chip). The same thing killed the terminal's repeat keys (Backspace, Del, the arrows) and the browser pane's long-press right-click. Native is unaffected.

Cause, traced on the Android WebView. A held touch becomes the WebView's long-press: selectstart → contextmenu → selectionchange → touchcancel. react-native-web ends a press on selectionchange and on touchcancel, and refuses only the contextmenu leg, and only when the Pressable declares onLongPress. Our hold surfaces declared none. The selection is what drives the cancel: with no selectable text under the finger, the WebView sends no touchcancel at all (measured; see the trace in the lane's proof).

Fix, two halves that only work together.

  • Page text is unselectable unless it opts in, as native. React Native Text is unselectable by default; react-native-web's is not. One rule in the page's native-parity style: body gets user-select: none and no touch callout; inputs, textareas and the editor stay selectable and keep their callout; <Text selectable> (chat, markdown, diff rows, file preview) opts back in through react-native-web's own user-select: text. This also closes the audit's finding that every button and chip label on the page could be selected on long press.
  • Hold surfaces declare onLongPress. One shared no-op, keepHeldPressThroughLongPress, on both mics in hold mode and the six repeatable keys. That is the library's own switch for "this control owns the long press"; with no selection in play it is sufficient. Nothing changes natively (onPress is undefined in hold mode; the repeat keys act on press-in).

Two independent fixes ride along:

  • Chat mic release. The chat mic swaps its icon from Mic to Square at press-in. A browser pins a touch to the element it started on, so the release went to the removed SVG and never reached the button: the recording never stopped. Reproduced on Android and on WebKit. The icons now take pointerEvents="none" so the button is the target.
  • Browser pane. Its PanResponder refuses termination by contextmenu (a no-op natively), so the 550 ms right-click outlives the 500 ms long-press.

No new module, no seam, no dependency. The same page rule is a prerequisite for the iOS shell fix in #24270, which must land after this.

Tests (red first)

  • Held-press render test (Chromium): each mic held until the finger lifts, Arrow Up keeps repeating (red: expected 1 to be greater than 20), long-press on Esc selects nothing, the browser pane right-clicks on a 1 s hold (red: toasts: []).
  • Native-parity render test (Chromium and WebKit): plain Text is unselectable, <Text selectable> and TextInput select (red: expected 'label' to be '' and expected '\n' to be '').
  • Rich-markdown render test: the in-page editor types and double-click selects under the shipped style.
  • Session suites that mount the composer and dock unchanged.

Device (Pixel_API_37 emulator, OTA shell from main, page from this branch)

Check Before After
Mic held 2 s, terminal and chat views stopped ~0.5 s in, handles on nearby text records until release, no handles
Arrow Up held 2 s 1 send repeats until release
Swipe starting on Arrow Up scrolls the bar scrolls the bar
Browser pane held 1 s no right-click right-click
Long-press "Esc" / "Model" selection handles none
Long-press a word in a text field selects selects

iOS (iPhone 17 Pro simulator, OTA shell with #24270, page built with this rule): long-press in the composer shows the Paste / Select / AutoFill menu; the Model chip opens its picker and the Esc key selects nothing; a chat message selects with the Copy / Look Up / Translate menu; a 600 ms hold on a worktree row opens its sheet with no callout; the terminal mic hold runs to release. The chat mic's release bug reproduced there without this branch's icon fix. The rich editor was not driven on a device (the headless runtime cannot open a Markdown Note); the WebKit rig covers it.

react-native-web ends a Pressable's press on a touch contextmenu unless it
declares onLongPress, and Android WebView sends one ~500 ms into a hold, so
the mic's press-out stopped the recording and the unprevented default began a
text selection. Both hold-mode mics now declare a no-op onLongPress.

The chat mic also swaps its icon on press; as the touch target, the removed
icon received touchend detached from the document, so the release was lost.
The icons opt out of pointer events so the Pressable is the target.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
… WebView

On an Android emulator the hold still ended ~500 ms in with onLongPress in
place: the WebView's long-press starts a text selection, whose
selectionchange react-native-web treats as a termination, and then sends
touchcancel even when contextmenu is prevented. Cancelling touchstart on the
hold-mode mic stops the WebView generating the long-press gesture at all.
React's touch listeners are passive, so a platform seam attaches a native
non-passive listener on the page; natively it is a no-op. The onLongPress
no-op is removed: with no gesture there is no contextmenu to refuse.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…override

The guard now names the three device facts that make onLongPress
insufficient, arms through a testable holdTouchesOn, and is covered for
element scoping, re-arming when the mode flips without a remount, and
removal on unmount. The .web.ts sibling is listed in web-overrides.json.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…n the page

The key bar's repeatable keys (Backspace, Del, arrows) and the browser pane's
550 ms long-press right-click are held touches, and Android WebView's ~500 ms
long-press ends them the same way it ended hold-to-dictate. Both now take the
hold-press guard: built-in keys move to MobileTerminalAccessoryKey so each has
its own ref (react-native-web's merged refs drop React 19 ref cleanups, so one
shared callback ref cannot arm several keys), and only repeatable keys arm it,
since cancelling touchstart also drops a tap key's click. The pane's viewport
arms it only while no browser dialog is open, because the dialog's buttons sit
inside the viewport and need their click.

The held-press rig now covers the mic, the keys and the pane, playing the
WebView's long-press whenever an element left touchstart uncancelled.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…viewport

The content the previous commit's message describes; that commit carried
only the rig's file renames. Repeatable built-in keys move to
MobileTerminalAccessoryKey so each owns its ref and arms the guard; tap keys
keep their click. The browser viewport arms it while no dialog is open. The
held-press rig gains the key-bar and browser-pane probes and plays the
WebView's long-press whenever touchstart went uncancelled.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…e root

A device trace showed the WebView sends no touchcancel on a long-press
when no text selection starts, so the touchstart guard is not needed and
its cost (a key-bar scroll could not start on a repeat key) goes with it.
The seam, its test, its override entry and the per-key component are
removed.

Held presses (both mics in hold mode, the six repeatable keys) declare a
shared no-op onLongPress, so react-native-web refuses the long-press
contextmenu's termination. The page's native-parity style makes #root
unselectable with no touch callout, as native text is unless it opts in;
<Text selectable> still sets user-select: text. The browser pane's
responder refuses termination by contextmenu, so its 550 ms right-click
outlives the WebView's own long-press. The chat mic icons keep
pointerEvents="none".

The held-press rig mounts the real command dock and plays the WebView's
long-press, with the selection and cancel only where text is selectable.
The parity and rich-markdown rigs prove plain text no longer selects,
selectable text and TextInput still do, and the editor edits and selects.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…d one

The page-wide native-parity selection rule lands from the iOS lane in the
next commit, unchanged, so both branches carry the identical rule. This
removes the #root variant and its parity case first so that pick applies
cleanly.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ative

react-native-web leaves every Text selectable, where native RN Text is not.
In the iOS shell a hold on plain text then raises WebKit's selection callout
(Copy, Look Up, Translate) over the page's own long-press action sheet once
WebKit text interaction is on. Body is user-select: none; inputs, textareas
and contenteditable stay selectable, and `selectable` Text keeps its own rule.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…wn gestures

On top of the shared rule: a double-click selects nothing in plain Text,
selects in `<Text selectable>` (react-native-web's Text/index.js:115) and in
a TextInput; a long-press of a tap key plays no selection and selects
nothing; the held presses survive because no selection starts.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…he body scope

Fields now also reset -webkit-touch-callout to default: WebKit inherits it,
and an inherited none is the known cause of a missing Paste callout in iOS
fields. The rule stays on body rather than #root because react-native-web's
Modal portals to document.body; the parity rig now mounts a modal and shows
its text unselectable and its field selectable in Chromium and WebKit. The
WHY above the constant says both, the shared onLongPress no-op names both
halves of the contract, and the probe routes drop the deleted guard.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Fixes hold-to-dictate and repeat keys on mobile web.

The PR appears safe to merge; no outstanding finding or new actionable defect remains.

Summary

The PR prevents page text selection and WebView context menus from ending held mobile presses. It also keeps the chat mic’s touch target stable and adds browser-render checks for dictation, repeat keys, text selection, and right-click delivery.

Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Touch[Held touch] --> Page[Unselectable page text]
  Page --> Press{Press surface}
  Press -->|Mic or repeat key| LongPress[Retain press through contextmenu]
  Press -->|Browser pane| Pan[Retain PanResponder through contextmenu]
  LongPress --> Release[Stop on finger release]
  Pan --> Timer[550 ms right-click timer]
  Timer --> Request[browser.mouseClick request]
Loading

Reviews (2) · Last reviewed commit: "test(mobile): the pane rig reads the rig..."

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: bd3f3e2c-ec0c-429a-8283-4b6e895497cf

📥 Commits

Reviewing files that changed from the base of the PR and between ee0979b and e4d8852.

📒 Files selected for processing (2)
  • config/scripts/mobile-web-app-held-press-probe-routes.mjs
  • config/scripts/mobile-web-app-held-press-render.test.mjs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The mobile web parity style now disables text selection and touch callouts across the body, with editable elements opting back in. Hold-mode microphones, repeatable command keys, and browser context-menu interactions have updated long-press handling. New render tests cover selection behavior, dictation holds, repeating keys, and browser-pane holds.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to e4d88

No concrete merge-blocking issue is identified. The selection exceptions and hold/release behavior have targeted render coverage; merge after normal checks pass.

Security Architecture Review

Security architecture risk: 🔵 Low · up to e4d88

The reviewed changes preserve existing release handlers and do not demonstrate a new public route or increased privileges. Remaining uncertainty concerns interruption races and the underlying recording and repeat-input cleanup.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The routed browser probe does not expand production attacker reachability: it uses fixed test page data, a temporary loopback server and local request capture. Its use of the real interaction hook does not confer the production transport's authority.

Trust Boundaries and Controls

  • observed — The generated probe routes declare empty grants. Their injected client records requests in memory, browser forwarding is a no-op, and the shell double's fault grant serves render diagnostics rather than browser-action authorization.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main mobile behavior fix: hold-to-dictate, repeat keys, and browser long-press interactions now survive the page long-press.
Description check ✅ Passed The description is detailed and mostly complete. It explains the user impact, root cause, implementation, rationale, testing, device coverage, and before-and-after behavior. It does not reproduce ever…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

✅ No new issues found.

Reviewed changes — the mobile OTA page's held presses (hold-to-dictate, repeatable dock keys) and the browser pane's long-press right-click, plus the page-wide selection rule and the render-test coverage.

  • Hold presses through onLongPress — a shared no-op (mobile/src/session/held-press-long-press.ts) is wired onto both hold-mode mics and the repeatable dock keys, which is RNW's own switch for refusing contextmenu termination. Matches PressResponder's onResponderTerminationRequest/onContextMenu gating (onLongPress != null && _isPointerTouch).
  • Page text unselectable unless marked selectable — body gets user-select:none + no touch callout and fields opt back in, so no selection is raised under the finger and the WebView sends no selectionchange/touchcancel. body scope (not #root) correctly covers RNW Modals.
  • Chat mic release — pointerEvents="none" on the swapped icons keeps the press target on the Pressable, so the release reaches onPressOut.
  • Browser pane — onPanResponderTerminationRequest now refuses contextmenu, letting the 550 ms right-click timer outlive the ~500 ms WebView long-press.
  • Tests — new held-press render suite plus native-parity and rich-markdown cases; specialists confirmed the mic/repeat/browser assertions fail against the pre-fix code. The mobile_web_app CI job is green on ee0979b, so these run for real.

Two notes, neither requiring action here: test / tests node 24 2/5 is red on an unrelated unhandled AgentSessionJournalError in src/main/native-chat/agent-session-journal/journal-per-session-import.test.ts (the verify job only fails because it gates on it), and the field callout exemption implies -webkit-touch-callout inheritance matters for selectable <Text> too — not observable in desktop WebKit, and the iOS device result in the description covers it.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

…s toast

The probe's stub client records requests; a 1 s hold sends one right mouseClick and its release
none, and a tap sends one left click and no toast.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

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

✅ No new issues found.

Reviewed changes — the delta since Pullfrog's prior review at ee0979b, a test-only strengthening of the browser pane probe.

  • Browser probe records host requests — the stub client now records every sendRequest (method + params) and pageParams returns real values, so the pane's sendPointerClick actually runs instead of short-circuiting on a null client; the "Right click" toast is no longer the only witness.
  • Right-click test asserts the host call — it now checks the recorded browser.mouseClick with { button: 'right', page: 'held-press-page' } mid-hold and confirms the release sends no left click.
  • New tap regression test — a plain tap() on the viewport must yield exactly one { button: 'left' } click and no toast, guarding the onPanResponderTerminationRequest change against swallowing ordinary taps.

The assertions are exact and read the request where the host would see it, so the new coverage is real rather than toast-deep.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit e9ec631 into main Oct 1, 2026
35 checks passed
Jinwoo-H added a commit that referenced this pull request Oct 1, 2026
…s take text (#24270)

With isTextInteractionEnabled = false (#21589) WebKit delivered keydown to a focused page field but never inserted text. The page's user-select rule (#24277) now keeps WebKit's selection off long presses. Needs an iOS shell release.
@Jinwoo-H
Jinwoo-H deleted the mobile-page-hold-dictation branch October 1, 2026 05:19
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.

1 participant