Skip to content

fix(mobile): end a keyboard hold whose release the phone bar never hears - #52769

Merged
AmethystLiang merged 5 commits into
mainfrom
AmethystLiang/sta-19926-space-repeat
Nov 30, 2026
Merged

AmethystLiang merged 5 commits into
mainfrom
AmethystLiang/sta-19926-space-repeat

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

On a phone with a hardware keyboard, holding Space on the toolbar's ⌫ or arrow keys could keep deleting or scrolling history after you let go. Now the key stops as soon as you release it, even if focus moved away first.

Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​606 $\color{#cf222e}{\Huge{\mathbf{−}}}$​23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​583
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​348 $\color{#cf222e}{\Huge{\mathbf{−}}}$​26 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​322

What Changed

Since #52645 the phone bar's ⌫ ↑ ↓ are buttons, so a hardware Space presses them and holding it repeats. react-native-web only counts a Space release that comes up on a button. If focus left the key before Space came up, the press never ended and the key kept sending to the terminal. A window blur lost the release of Space or Enter on every key row (phone bar, ⋯ sheet, tablet row).

A held keyboard press is now tracked per key:

  • If its key comes up anywhere else, the hold ends there.
  • If the held key loses focus or the window blurs, the hold is abandoned: the repeat stops and never resumes. That same physical press's auto-repeats and release send nothing.
  • Either way react-native-web is shown a release on the key, so it looks released and the next press is a fresh one. That release never sends a key itself. If it ends another key's live touch press, that touch hold stops at its own finger lift.
  • A keyboard hold only stops the session's repeat while it is the latest hold, so it never cuts a touch hold in the bar or the ⋯ sheet.

Touch presses, repeat timing, layout and which keys Space and Enter activate are unchanged.

Why

Patching react-native-web or reverting the buttons would be broader or undo #52645's Space and assistive-tech support. Cancelling only on window blur in the session would miss the main case, where focus moves before Space comes up.

Linked Issue

No GitHub issue. This fixes a regression from #52645.

Visual Proof

N/A for layout: nothing looks different. This is an interaction fix, so the evidence is the write counts below from a seeded page with trusted keyboard input.

Testing

  • Regression tests in MobileSessionAccessoryKeys.web-keyboard.test.tsx run real react-native-web in happy-dom with the real repeat timer. They cover:

    • focus leaving the key, a window blur, and the release coming up elsewhere (phone bar, row and sheet);
    • fresh taps and holds afterwards;
    • no resume or send from the lost press's auto-repeats or release;
    • touch holds and a ⋯ sheet hold surviving keyboard releases, including a touch hold that a recovery release ends early;
    • no write from the recovery release on a row or sheet key that an assistive click already used;
    • field typing left alone, unmount, and the pressed look clearing.
      20 of them fail on main. Each new listener or branch was removed in turn to confirm its test goes red.
  • pnpm check:changed and the mobile typecheck (app and tests) pass locally.

  • One native-renderer test checks that an ↑ hold survives a rerender while ⌫ sits in ⋯.

  • Seeded page in headless Chromium, trusted keyboard input:

    Scenario Writes
    Space tap 1
    Enter with 2 auto-repeats 1
    Space held, focus moved to a field none from then on
    Fresh tap after that 1
    Fresh hold after that repeats, then stops on release
    Focus back on the key, old Space released or Enter auto-repeating 0, with no native click
    Tab away mid-hold 0
    Tablet row Enter recovery 1
    Unmount mid-hold 0
  • Not covered: a real window blur (headless Chromium does not produce one, so blur is unit-tested only), and physical iOS/Android WebViews with hardware keyboards.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

Performance

None measurable: work happens only while a key is held from a hardware keyboard. Each such press adds at most four event listeners, removed when it ends. A press whose release was lost keeps two document listeners until that key's next keyup or keydown. A touch hold ended early by a recovery release keeps six listeners until its finger lifts. There is no work per repeat tick, no polling, I/O or caching. The phone bar and its sheet are the only two rows mounted together.

Risk

Level: Low. The riskiest part is the release shown to react-native-web after a lost press. If it misbehaved, a key could need a second press, or a touch hold could stop early. It is confined to the terminal key rows on the mobile page build; the native app has no DOM and is untouched. Back out with a plain revert.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

A hardware Space held on a phone bar ⌫ or arrow kept repeating once focus left
the key before Space came up: react-native-web only takes a Space release on a
button, so the press never ended. A window blur lost the release of Space or
Enter on every key row.

The hold now also ends when its key comes up elsewhere, and is abandoned when
its key loses focus or the window blurs. The repeat stops, the rest of that
press sends nothing, and react-native-web is shown a release on the key, so the
next press is fresh. A keyboard hold only stops the session's repeat while it
is the latest hold, so it never cuts a touch hold in the bar or its sheet.
…touch hold

The release shown to react-native-web after a lost keyboard hold reached the
tablet row and sheet keys' onPress. Once an assistive click had used up that
hold's prepared press, the release sent one more key. The key is now held as a
keyboard press through the reset, so that onPress sends nothing.

The same release can end another key's live touch press through a listener an
earlier keyboard press left on it. That press's finger lift then goes unheard,
so its hold now ends at the lift instead of at once.
@AmethystLiang
AmethystLiang marked this pull request as ready for review November 30, 2026 00:45
@greptile-apps

greptile-apps Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge; no new blocking issue was found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issue was found.

Summary

The PR stops mobile toolbar keys from repeating after a keyboard release is lost.

  • Mobile terminal keys stop repeating when a hardware-key release is missed.

Reviews (2) · Last reviewed commit: "fix(mobile): end a reset-ended touch hol..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds a hook that tracks keyboard holds, repeat ownership, and recovery from lost web key releases. Accessory-key events use this coordinator to manage repeat cancellation and touch disarming. The keyboard-press hook memoizes its returned object. Tests cover keyboard and touch hold interactions, recovery scenarios, and repeat persistence across rerenders.

Merge Risk: Low · up to 4280c

This fixes hardware-keyboard Space holds that kept deleting or scrolling after the key was released elsewhere. Two narrow edge cases remain: a held Space can still act on a different key the focus has moved to, and a touch on the same key can lift the guard early. Neither is likely to affect normal use, and the change is easy to revert, so it can merge with awareness of these follow-ups.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a fix in the mobile app that ends a keyboard hold when the phone bar never receives the release event. It follows a conventional commit format and is specific to the c…
Description check Passed The description follows the template well. It includes ELI5, What Changed, Why, Visual Proof (N/A with reason), Testing with checkboxes, Performance, Risk with level and back-out plan, and Checklist. …
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.
Full details: Title check

Explanation

The title names the main change: a fix in the mobile app that ends a keyboard hold when the phone bar never receives the release event. It follows a conventional commit format and is specific to the changeset, which adds per-key keyboard hold tracking and recovery on focus loss, window blur, or release elsewhere.

Full details: Description check

Explanation

The description follows the template well. It includes ELI5, What Changed, Why, Visual Proof (N/A with reason), Testing with checkboxes, Performance, Risk with level and back-out plan, and Checklist. The Linked Issue section states there is no GitHub issue and links the regression to #52645, which the template requires for outside contributors. The author is a maintainer, so the template allows that. The AI Disclosure and Review sections are empty, and the Performance line is completed with reasoning. These are minor gaps.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent 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: 39d564b1-8da8-400e-8060-5cab15fc4fd7
Commits

Reviewing files that changed from the base of the PR and between d4be0ec and 4280c38.

Files selected for processing: 2

  • mobile/src/terminal/session/accessory-keys/MobileSessionAccessoryKeys.web-keyboard.test.tsx
  • mobile/src/terminal/session/accessory-keys/use-keyboard-hold-release.ts

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

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: e311ec48-e406-4b1c-8b83-b7d41bcdab7a
Commits

Reviewing files that changed from the base of the PR and between 915a485 and 1d1f779.

Files selected for processing: 6

  • mobile/src/terminal/session/accessory-keys/MobileSessionAccessoryKeys.test.tsx
  • mobile/src/terminal/session/accessory-keys/MobileSessionAccessoryKeys.tsx
  • mobile/src/terminal/session/accessory-keys/MobileSessionAccessoryKeys.web-keyboard.test.tsx
  • mobile/src/terminal/session/accessory-keys/use-keyboard-button-presses.ts
  • mobile/src/terminal/session/accessory-keys/use-keyboard-hold-release.ts
  • mobile/src/terminal/session/accessory-keys/use-terminal-key-row-touch.ts

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

When the release shown to react-native-web after a lost keyboard hold ended
another key's live touch press, that hold stopped at the first touch or mouse
lift anywhere, so a second finger lifting elsewhere cut it short. The press-in
now records the finger (or mouse) the touch began with, and the hold ends only
when that contact is gone from the page's touches, the mouse comes up, or the
window blurs. A newer hold is left alone.
… touch

react-native-web folds touch identifiers (101 and 121 both become 1), so
matching the owning finger by identifier let a finger elsewhere keep a
reset-ended hold alive after its own finger lifted. The hold now ends as
react-native-web ends a touch press: when no remaining touch is on the key,
or the mouse comes up. A finger elsewhere still leaves it running.
@AmethystLiang
AmethystLiang merged commit 3ae6caa into main Nov 30, 2026
28 checks passed
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