Repository navigation
fix(mobile): stop held terminal keys when you switch terminals or leave the app - #31712
Conversation
0ed9b09 to
b357506
Compare
Walkthrough
Priority: Merge Risk:
|
The selection hook replaced the established repeat controller with unbounded timers, allowing held keys to cross terminal/client changes. Reintegrate the existing pinned sender, lifecycle cancellation and backpressure.
… hook main now reads
…gh the current live-input mode
e5f4e2a to
8167a5c
Compare
[Medium impact] The PR appears safe to merge; no actionable defects were found. SummaryReplaces separate repeat timers with the existing controller.
No actionable issues were found. This review checked code paths; it did not run tests or verify native touch behavior.
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

Minor · Invalidate the repeat on release and unmount. · use-mobile-session-accessory-selection.ts:68-72
mobile/src/session/use-mobile-session-accessory-selection.ts:68-72
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winInvalidate the repeat on release and unmount.
startAccessoryRepeat()sends immediately and waits for the asynchronous live-input preflight.stopAccessoryRepeat()only advances the repeat generation, so it does not invalidate that in-flight preflight. After release or accessory-strip unmount, the preflight can still pass the unchanged owner-revision predicate and callsendTerminalLiveAccessoryRawBytes(...). This can send one terminal byte after the user releases the key or after its owning component disappears.Make
stopAccessoryRepeat()use the owner-invalidating cancellation path. BothonPressOutand the unmount effect already call this callback.Suggested fix
- const stopAccessoryRepeat = useCallback(() => accessoryRepeat.stop(), [accessoryRepeat]) - const cancelAccessoryRepeat = useCallback(() => { + const stopAccessoryRepeat = useCallback(() => { repeatOwnerRevisionRef.current += 1 accessoryRepeat.cancel() }, [accessoryRepeat]) + const cancelAccessoryRepeat = stopAccessoryRepeat

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
926d7788-ca87-4a64-8fac-66f5524d60cc
Files selected for processing: 1-
config/scripts/mobile-web-app/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; 3 remain after this review.
-
ELI5
Hold a repeating terminal key, such as an arrow, then switch terminals or leave the app. The repeats can keep going or reach the wrong terminal. This fix stops the hold when its terminal or connection changes, and waits for the computer to accept one repeat before sending the next.
What Changed
Why
A key you held in one terminal should not keep acting after you move somewhere else.
Linked Issue
Maintainer-discovered regression. Bounded GitHub symptom and exact-file searches found no exact duplicate. Restores the pinned, acknowledgement-paced controller introduced in merged #14219 after the extracted selection hook stopped using it.
Visual Proof
Captured with the visual-proof skill. Before uses base
15246eb4a45; after uses this PR's standalone commit514d883f824. The scenario passed asserted capture runs 3 times per version before representative screenshots were selected. The captures were visually inspected.Evidence scope: production-hook harness. Explicitly labeled custom HTML rendering of real hook output with deterministic transport; not the native app or production terminal renderer. Captures hold across terminal switch with real accessory/send hooks; no native IME, touch, focus or AppState claim.
The hook/transport boundary harnesses are labeled in the captures. These are browser evidence where stated; they do not establish native keyboard, gesture, permission dialog, safe-area or real-network behavior. Full code regressions cover additional cases described above.
Testing
The combined review checkout
aa6fe5dae109contains this PR at0ed9b095dd0dand the other mobile PRs reviewed together. Validation ran withORCA_BACKGROUND_LAUNCH=1on macOS.An earlier attempt using the shared checkout’s newer Vitest crashed. The reported full run and recording recheck used the mobile package’s pinned Vitest 4.1.12 with four workers. These are combined-checkout results; separate CI must validate each PR against current main. Native-device coverage remains limited as described in Visual Proof and Review.
AI Disclosure
Risk-reduction checks
Second pass: Rechecked the actual repeat controller, slow-send backpressure, terminal replacement, app backgrounding, and refusal/disconnect recovery. No additional reproducible defect found in this pass.
Current PR head:
0ed9b095dd0d. Combined review head:aa6fe5dae109.Carry-over (2026-10-28): rebased onto current main. The web held-press render check now expects the key bar's press to start the repeat controller without sending on its own, since the controller owns the first send. A second finger switching terminals mid-hold changes the active terminal, which cancels the hold and fails every later send's ownership check, so it is covered rather than a separate bug.
Review
Merge risk: Medium. Native held-touch and keyboard/IME lifecycle behavior still need device testing.
Previously reviewed by a separate agent team; this pass traced the production paths again and added failing-before regressions for the three newly reproduced defects.
Agent skill upstream boundary
Notes
Existing RPC methods and wire compatibility are retained. Review considered desktop host changes, remote execution authority, folder workspaces, and native/web consumers. Native simulator follow-up was limited after the three owned simulators became stuck shutting down; no unrelated simulator/process was reset.
Checklist