Skip to content

Capture physical-keyboard input on mobile terminal sessions - #10447

Closed
smk508 wants to merge 21 commits into
stablyai:mainfrom
smk508:feat/mobile-hardware-keyboard-capture
Closed

smk508 wants to merge 21 commits into
stablyai:mainfrom
smk508:feat/mobile-hardware-keyboard-capture

Conversation

@smk508

@smk508 smk508 commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

On mobile clients like iPad, a physical keyboard would not register all the keys and only accepted character inputs before. This PR updates the text input layer to accept non-character keys so that the macros, etc. can be used.

Notably, this fix doesn't yet yield a 100% keyboard pass through. Doing so would potentially require a bigger refactor which I did not want to throw out unprompted. If it is of interest, consider refactoring the input layer to utilize the Kitty Key protocol or similar to getter generalize input device passthrough to the underlying terminal UI.

Summary

RN's TextInput only surfaces printable characters and Backspace on iOS, so a
physical Ctrl, Alt, arrow, Esc, Tab, or function key produced no JS event and
never reached the PTY — a hardware keyboard attached to an iPad could only
type text, nothing else.

  • Add an expo-hardware-keyboard native module (iOS Swift + Android Kotlin)
    that captures raw hardware key presses and forwards {key, modifiers} to
    JS, reusing the existing buildTerminalShortcutKey() byte encoding and
    sendLiveTerminalInput() delivery path.
  • Fold physical-keyboard capture into the existing Live input toggle
    rather than a separate mode: with a hardware keyboard attached (detected via
    isHardwareKeyboardConnected(), polled while live input is on since there's
    no attach/detach push event), live input mounts the native capture view and
    never raises the software keyboard; without one it falls back to the
    existing TextInput path exactly as before.

Device fixes

Three interception bugs only reproduced on a real iPad, not the simulator —
each is documented with a // Why: comment at its fix site in
OrcaKeyCaptureView.swift:

  • Tab/Up/Down never reached the view at all. iPadOS's Focus Engine — a
    navigation system separate from the responder chain — was claiming them
    first. Fixed by opting into canBecomeFocused and driving it explicitly.
  • Tab, Backspace, and the arrow keys were inconsistently swallowed by
    ancestor responders (field navigation, UIScrollView's built-in
    hardware-keyboard scrolling). Fixed by claiming them as explicit
    UIKeyCommands so this view wins resolution first.
  • Ctrl+<letter> combos reported ctrlKey: false. Same fix — explicit
    UIKeyCommands for the shell-relevant combos (^C ^D ^L ^Z ^R ^A ^E ^W ^U).

Known follow-ups (not fixed here)

  • Key repeat while held (Backspace, arrows). An explicit repeat timer was
    tried and pulled back out: on-device behavior didn't match what it was
    written to produce, and something already appears to generate repeat
    invocations at a ~150-200ms cadence without any special handling here —
    stacking a second repeat source on top risked over-repeating rather than
    fixing anything. Needs an attached debugger to diagnose properly rather
    than remote log scraping.
  • Full keyboard-event passthrough (e.g. Kitty keyboard protocol / CSI u).
    Right now Enter and Shift+Enter both produce \r — this matches standard
    terminal behavior (Terminal.app, iTerm) but means a terminal app that wants
    to disambiguate them (e.g. Shift+Enter for a literal newline) can't. The
    proper fix is a separate, larger feature: a keyboard-passthrough protocol
    that reports precise key-down/up and modifier state to the far end instead
    of collapsing everything to control bytes. Worth exploring on its own; out
    of scope here.

How to verify

Tested hands-on on a real iPad (simulator does not exercise a hardware
keyboard) with a physical keyboard attached:

  • Live input auto-switches to native capture when the keyboard is attached,
    and back to the software-keyboard path when it's detached — no separate
    toggle to manage.
  • Tab, Shift+Tab, arrows, Backspace all reach the terminal correctly.
  • Ctrl+<letter> shortcuts (^C, ^D, ^L, ^Z, ^R, ^A, ^E, ^W,
    ^U) all work at a real shell prompt.
  • Repo checks: npx tsc --noEmit, npx oxlint, npx oxfmt --check,
    node config/scripts/check-max-lines-ratchet.mjs, npx vitest run
    (352 files / 2592 tests) — all clean.

Not covered: Android (module ships a Kotlin implementation mirroring the iOS
logic but wasn't hands-on tested this round), and the two follow-ups above.

ELI5

On iPad with a hardware keyboard, only normal typing and Backspace reached the mobile terminal—Ctrl, arrows, Esc, Tab, and function keys did nothing. This adds a native module so physical special keys work in terminal sessions.

smk508 and others added 11 commits June 28, 2026 15:27
Repeatable rung-1/2/3 recipe for verifying client-owned display changes
(theme + terminal render options) on a macOS workstation with Xcode.

- notes/client-display-verify-harness.md: the recipe (SSOT) — three rungs,
  artifact convention, env prereqs, and the two named setup costs (web must be
  paired to a host; mobile needs a one-time Expo dev-client build).
- config/scripts/verify-client-display.mjs: automates rung-1 repo gates and the
  rung-2 iOS-simulator light/dark capture via the simctl path (no WebDriverAgent).
- .gitignore: ignore .verify-orca/ artifacts (attach to PRs, don't commit).

Co-authored-by: Claude Opus 4.8 <[email protected]>
…1302] (#4)

The runtime graph delivered one host-resolved RuntimeMobileTerminalTheme
per terminal tab, so a mobile client was pinned to the host's current
light/dark choice. Resolve and emit both palettes instead, applying
terminalColorOverrides / terminalBackgroundOpacity / terminalCursorOpacity
to each, so a client can pick its own appearance.

The change is additive and backward-compatible: `mode` + `theme` stay
populated with the host's systemPrefersDark-driven default (a client
reading only those still renders), and an optional `palettes` field
carries the light/dark pair alongside. Metadata only — the PTY byte
stream and terminal content are untouched.

Co-authored-by: Claude Opus 4.8 <[email protected]>
Record the already-made design decisions for the Client-owned display
preferences effort: a paired mobile/web client picks its own light/dark
instead of inheriting the desktop host's resolved terminal palette.

Captures the three-bucket classification (host/PTY-authoritative, client
render options, host-global behavior) and four decisions with their
rejected alternatives and protected constraints:
- terminal palette transport (host resolves both palettes, client picks)
- CSI 997 arbitration via the existing floor-holder concept
- client-local-by-default render prefs (server-persisted store out of v1)
- web scope is verification-only

Co-authored-by: Claude Opus 4.8 <[email protected]>
The mobile app chrome was hardcoded dark. Add a light palette and a theme
context that resolves the effective light/dark scheme from a stored
appearance preference plus the device's OS color scheme, then drive the app
chrome (root Stack screenOptions, home/pairing screen, settings) from it.

- mobile-theme.ts: add `lightColors` alongside `darkColors` with identical
  token keys; `colors` still points at the dark palette so unmigrated screens
  compile and render dark (the clean dark fallback the AC allows).
- theme-context.tsx: `ThemeProvider` + `useThemeColors()`; resolves 'system'
  against React Native `useColorScheme()`, falling back to dark.
- preferences.ts: `appAppearance` ('system' | 'light' | 'dark', default
  'system') load/save, following the terminalLinkOpenMode precedent.
- _layout.tsx: wrap the tree in ThemeProvider; Stack screenOptions and the
  StatusBar style now read the active palette.
- index.tsx, settings.tsx: consume `useThemeColors()` via a memoized
  StyleSheet factory; settings adds a System/Light/Dark control.

Other screens stay on the static dark `colors` fallback (AC-compliant).

Co-authored-by: Claude Opus 4.8 <[email protected]>
#6)

* feat(mobile): client-owned terminal light/dark color scheme [CHE-1303]

The mobile terminal rendered whatever palette the host baked in, so a paired
iPad mirrored the host Mac's light/dark. CHE-1302 made the host ship both
palettes; this lets the client pick its own.

- preferences.ts: terminalColorScheme ('system'|'light'|'dark', default
  'system') load/save, following the appAppearance precedent. A separate
  per-device choice from app-chrome appearance.
- theme-context.tsx: ThemeProvider also resolves the terminal scheme
  (resolvedTerminalScheme) from the stored pref + useColorScheme(), so a
  change in settings or an OS appearance flip re-renders the session live.
- terminal-color-scheme.ts: pure resolveTerminalThemeForScheme() picks
  palettes[scheme] into {mode, theme}; falls back to the host's single
  palette unchanged when palettes are absent (older host).
- session screen: applies the pick to each terminal's theme at render.
- terminal-settings.tsx: a Color theme picker (System / Light / Dark).
- tests for the pref round-trip and the palette-pick helper.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* test(mobile): cover the terminal color-scheme resolution seam [CHE-1303]

Extract the appearance→effective-scheme resolver into a pure resolve-scheme.ts
(theme-context now imports it instead of defining it inline) and test the full
decision the feature makes end-to-end without rendering: a stored
terminalColorScheme plus the device OS scheme compose through
resolveScheme → resolveTerminalThemeForScheme to the palette that renders.

Covers: 'system' tracks the OS, an override wins over the OS, flipping the OS
flips the palette on 'system', and the older-host single-palette fallback —
the wiring a screenshot of the helper alone didn't exercise.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
# Conflicts:
#	mobile/app/_layout.tsx
#	mobile/app/index.tsx
#	mobile/app/settings.tsx
#	mobile/src/storage/preferences.test.ts
#	mobile/src/storage/preferences.ts
RN's TextInput only surfaces printable characters and Backspace on iOS, so a
physical Ctrl, Alt, arrow, Esc, Tab, or function key produced no JS event and
never reached the PTY — a hardware keyboard on iPad could only type text.

Add an expo-hardware-keyboard native module (iOS Swift + Android Kotlin) that
captures raw hardware key presses and forwards {key, modifiers} to JS, where the
existing buildTerminalShortcutKey() encodes the control bytes and the existing
sendLiveTerminalInput() delivers them. Wire a "physical keyboard" toggle into
the terminal session screen as a third input mode alongside buffered and live.

The byte-encoding reuses the audited terminal-accessory-keys logic; only the
native event source is new. terminal-hardware-key.ts is covered by unit tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…interception

Redesign the hardware-keyboard capture UX from a separate "physical keyboard"
toggle into a single "Live input" mode that auto-detects a connected hardware
keyboard via isHardwareKeyboardConnected() (polled while live input is on,
since no push event exists for attach/detach). With a keyboard attached, live
input mounts OrcaKeyCaptureView instead of the TextInput path and never raises
the software keyboard; without one it falls back to TextInput as before. This
collapses two competing input-capture surfaces down to one and removes the
now-redundant accessory-bar toggle button.

Fix three device-only interception bugs found testing on a real iPad, none of
which reproduced in the simulator:

- Tab/Up/Down never reached this view at all: iPadOS's Focus Engine, a
  navigation system separate from the responder chain, was claiming them
  before pressesBegan/keyCommands ever fired. Opt into canBecomeFocused and
  drive it explicitly alongside becomeFirstResponder().
- Tab, Backspace, and the arrow keys were inconsistently swallowed by
  ancestor responders (field navigation, UIScrollView's built-in
  hardware-keyboard scrolling). Claim them as explicit UIKeyCommands so this
  view wins resolution before an ancestor sees them.
- Ctrl+<letter> shortcuts reached pressesBegan with ctrlKey read as false.
  Same fix: claim the common shell-relevant combos (^C, ^D, ^L, ^Z, ^R, ^A,
  ^E, ^W, ^U) as explicit UIKeyCommands.

Held-key repeat (Backspace, arrows) is a known follow-up, not fixed here: an
explicit repeat timer was tried and pulled back out after on-device behavior
didn't match expectations, and the device already appears to generate its own
repeat invocations at a ~150-200ms cadence, so stacking a second repeat
source on top risked over-repeating rather than fixing anything. See the
comment above OrcaKeyCaptureView for detail.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
CI's format:check caught pre-existing formatting drift in two files from the
original commit that predated this branch's lint-staged setup.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The changes add client-owned app and terminal appearance preferences with persisted storage and system-scheme resolution. Host runtime data now carries light and dark terminal palettes. Mobile screens consume theme tokens and expose appearance selectors. A new Expo module captures hardware keyboard events on Android and iOS, translates them into terminal bytes, and integrates them with session input. The changes also add terminal input extraction tests and a display verification harness for gates and simulator captures.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.75% which is insufficient. The required threshold is 80.00%. 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 and concisely describes the main change: adding physical-keyboard input support for mobile terminal sessions.
Description check ✅ Passed The description clearly covers the change, testing, device verification, and follow-ups, but omits the required AI Review Report, Security Audit, and Screenshots or No visual change sections.
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.

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.

@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: 10

🧹 Nitpick comments (5)
mobile/app/h/[hostId]/session/mobile-session-command-input-styles.ts (1)

168-170: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Condense or remove this implementation comment.

The three-line rationale is more detail than this style entry needs; use one brief non-obvious sentence if the comment is retained. As per coding guidelines, “Comments must be concise, limited to non-obvious information, and preferably one line.”

Source: Coding guidelines

mobile/packages/expo-hardware-keyboard/src/OrcaKeyCaptureView.tsx (1)

5-10: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Condense these TypeScript comments.

  • mobile/packages/expo-hardware-keyboard/src/OrcaKeyCaptureView.tsx#L5-L10: reduce this to the cross-platform event distinction.
  • mobile/src/terminal/terminal-hardware-key.ts#L7-L10: retain only why the structural type is local.
  • mobile/src/terminal/terminal-hardware-key.ts#L22-L24: reduce to the HID-map purpose.
  • mobile/src/terminal/terminal-hardware-key.ts#L55-L56: remove or reduce the self-evident function description.
  • mobile/src/terminal/terminal-hardware-key.ts#L79-L81: reduce to the reason unmodified characters are used.

As per coding guidelines, comments must be concise, limited to non-obvious information, and preferably one line.

Source: Coding guidelines

mobile/app/settings.tsx (1)

129-149: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add accessibilityRole="radiogroup" to the container.

The rows declare radio, but the wrapping View doesn't declare the group, so screen readers announce three unrelated radios instead of a set with position/count context.

♿ Proposed tweak
-        <View style={styles.section}>
+        <View style={styles.section} accessibilityRole="radiogroup">
mobile/app/h/[hostId]/session/[worktreeId].tsx (1)

1099-1108: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Consider pausing the 1s poll while backgrounded.

The interval keeps firing a native query every second for as long as live input is on, including while the app is in the background (this screen already tracks AppState elsewhere). Gating on AppState.currentState === 'active' — or re-probing on AppState 'active' plus a slower interval — would cut needless wakeups without changing behavior.

mobile/src/theme/resolve-scheme.test.ts (1)

23-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Shorten or remove this test walkthrough.

The test title and calls already convey this composition; retain at most a concise rationale.

As per coding guidelines, comments must be concise, limited to non-obvious information, and preferably one line.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6980c23d-1545-4701-82ac-f7b10182909a

📥 Commits

Reviewing files that changed from the base of the PR and between 402b5a1 and b904d7f.

⛔ Files ignored due to path filters (1)
  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (40)
  • .gitignore
  • config/scripts/verify-client-display.mjs
  • mobile/.oxlintrc.json
  • mobile/app/_layout.tsx
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/app/h/[hostId]/session/mobile-session-command-input-styles.ts
  • mobile/app/index.tsx
  • mobile/app/settings.tsx
  • mobile/app/terminal-settings.tsx
  • mobile/package.json
  • mobile/packages/expo-hardware-keyboard/README.md
  • mobile/packages/expo-hardware-keyboard/android/build.gradle
  • mobile/packages/expo-hardware-keyboard/android/src/main/AndroidManifest.xml
  • mobile/packages/expo-hardware-keyboard/android/src/main/java/expo/modules/hardwarekeyboard/ExpoHardwareKeyboardModule.kt
  • mobile/packages/expo-hardware-keyboard/android/src/main/java/expo/modules/hardwarekeyboard/OrcaKeyCaptureView.kt
  • mobile/packages/expo-hardware-keyboard/expo-module.config.json
  • mobile/packages/expo-hardware-keyboard/ios/ExpoHardwareKeyboard.podspec
  • mobile/packages/expo-hardware-keyboard/ios/ExpoHardwareKeyboardModule.swift
  • mobile/packages/expo-hardware-keyboard/ios/OrcaKeyCaptureView.swift
  • mobile/packages/expo-hardware-keyboard/package.json
  • mobile/packages/expo-hardware-keyboard/src/ExpoHardwareKeyboardModule.ts
  • mobile/packages/expo-hardware-keyboard/src/OrcaKeyCaptureView.tsx
  • mobile/packages/expo-hardware-keyboard/src/index.ts
  • mobile/packages/expo-hardware-keyboard/tsconfig.json
  • mobile/src/storage/preferences.test.ts
  • mobile/src/storage/preferences.ts
  • mobile/src/terminal/terminal-color-scheme.test.ts
  • mobile/src/terminal/terminal-color-scheme.ts
  • mobile/src/terminal/terminal-hardware-key.test.ts
  • mobile/src/terminal/terminal-hardware-key.ts
  • mobile/src/terminal/terminal-live-input-affordance.test.ts
  • mobile/src/theme/mobile-theme.ts
  • mobile/src/theme/resolve-scheme.test.ts
  • mobile/src/theme/resolve-scheme.ts
  • mobile/src/theme/theme-context.tsx
  • notes/client-display-verify-harness.md
  • notes/client-owned-display-preferences-design.md
  • src/renderer/src/runtime/sync-runtime-graph.test.ts
  • src/renderer/src/runtime/sync-runtime-graph.ts
  • src/shared/runtime-types.ts

Comment thread mobile/.oxlintrc.json Resolved
Comment thread mobile/app/terminal-settings.tsx Resolved
Comment thread mobile/src/theme/theme-context.tsx Resolved
Comment thread mobile/src/theme/theme-context.tsx Resolved
@nwparker nwparker added the enhancement New feature or request label Jul 27, 2026
smk508 and others added 2 commits July 27, 2026 12:05
Ten actionable findings plus five nitpicks from the stablyai#10447
review, spanning the hardware-keyboard feature and the theme feature it
shipped alongside.

Hardware-keyboard capture:

- Guard isHardwareKeyboardConnected() against the native module being absent
  (older dev client, Expo Go): a throw during useState's lazy initializer
  would previously crash the whole session screen's first render instead of
  degrading to the TextInput fallback.
- Gate the keyboard-connection poll on AppState — it no longer wakes every
  second while the app is backgrounded.
- Serialize hardware-key sends per terminal handle (new
  createKeyedSendSequencer) so rapid/held typing can't fire concurrent
  terminal.send RPCs that resolve out of order and transpose characters.
- Restore dictation/attach (MobileTerminalInputActions) in the
  hardware-keyboard input-bar branch, which silently dropped it; reorder
  OrcaKeyCaptureView to render behind the row instead of absoluteFill on top
  of it, so it no longer swallows taps on those buttons.
- Fix isHardwareKeyboardConnected() unconditionally returning true on iOS
  <14 (GCKeyboard only exists 14+) — this suppressed the software-keyboard
  fallback for every pre-14 user, keyboard or not. Now returns false there.
- Strengthen the Android key-precedence test: it always passed a non-
  conflicting keyCode (0), so it couldn't actually prove `key` wins over
  `keyCode` when they disagree.
- Fix a missing StyleSheet import in the package README's usage example.
- Extract the input-bar JSX (three input surfaces: hardware-keyboard capture,
  live TextInput, buffered command entry) into TerminalSessionInputBar, and
  the keyboard-connection state + send sequencing into useHardwareKeyInput,
  bringing the session screen back under its pre-existing max-lines budget
  instead of raising the cap.

Theme feature (bundled into the same PR, not otherwise touched by the
keyboard work, but flagged in the same review):

- terminal-settings.tsx and TerminalShortcutSettings.tsx still rendered from
  the static build-time palette instead of useTheme()/makeStyles(colors), so
  Light appearance left this screen half-themed. Migrated both to the same
  factory pattern settings.tsx already uses.
- theme-context.tsx: guard hydration so a load* resolving after the user has
  already changed a preference can't clobber it with the stale stored value;
  stop silently swallowing AsyncStorage write failures (now logged).
- Add accessibilityRole="radiogroup" to the appearance picker.

Condensed several over-long inline comments per the review's coding-
guideline nitpicks; no behavior change.

Not addressed: held-key repeat and full keyboard-passthrough remain the
PR's stated known follow-ups, unrelated to this review pass.

Verification: tsc --noEmit, oxlint, oxfmt --check, the repo's max-lines
ratchet gate, and the full vitest suite (353 files / 2595 tests) all pass.
Rebuilt clean on a real iPad (pre-fix, confirming the base feature still
works) and on iOS Simulator (post-fix, confirming build/boot — hardware-
keyboard capture itself isn't exercisable in-simulator; the iPad was
offline for this pass and needs a hands-on re-check before merge).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…keyboard-capture

# Conflicts:
#	mobile/src/storage/preferences.ts
@smk508

smk508 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Addressed all 10 actionable findings from CodeRabbit's review plus the 5 nitpicks, and merged current main to clear the conflict that had built up.

Hardware-keyboard capture

  • Guarded isHardwareKeyboardConnected() against the native module being absent (previously could crash the whole session screen's first render on an older dev client).
  • Gated the keyboard-connection poll on AppState so it doesn't wake every second while backgrounded.
  • Added a small serialized send queue (createKeyedSendSequencer) so rapid/held hardware typing can't fire concurrent terminal.send RPCs that resolve out of order.
  • Restored dictation/attach actions in the hardware-keyboard input bar (previously dropped entirely) and reordered the capture view so it no longer sits on top swallowing taps.
  • Fixed isHardwareKeyboardConnected() unconditionally returning true on iOS <14, which suppressed the software-keyboard fallback for every pre-14 user regardless of whether a keyboard was attached.
  • Strengthened the Android key-precedence test (it previously always passed a non-conflicting keyCode, so it couldn't prove key actually wins).
  • Fixed a missing import in the package README's example.

max-lines cap — reverted to the original 5015 rather than bumping it; extracted the input-bar JSX into TerminalSessionInputBar and the keyboard-connection/send logic into useHardwareKeyInput instead.

Theme feature (bundled into this PR, flagged in the same review) — migrated terminal-settings.tsx and TerminalShortcutSettings.tsx off the static build-time palette onto useTheme()/makeStyles(), so Light appearance no longer leaves this screen half-themed. Guarded theme-context.tsx hydration against a race with a fast user preference change, and stopped silently swallowing AsyncStorage write failures.

Verification — tsc --noEmit, oxlint, oxfmt --check, the repo's max-lines ratchet gate, and the full vitest suite (353 files / 2595 tests) all pass. Rebuilt clean on a real iPad prior to this fix pass (confirming the base feature), and on iOS Simulator after (confirming build/boot with no crash — hardware-keyboard capture itself isn't exercisable in-simulator). The iPad used for hands-on testing is offline right now, so a device re-check of the input-bar/tap-ordering changes is still pending before merge.

Not addressed — held-key repeat and full keyboard-passthrough remain the PR's stated known follow-ups; unrelated to this review pass.

CI shows action_required on the new commits — first-time-contributor workflow approval gate, needs a maintainer to approve running Actions on this PR.

@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: 1

🧹 Nitpick comments (2)
build-plugins/plain-node-entry-guard.js (1)

3-13: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Condense the implementation comments.

These multi-line comments restate behavior evident from the guard and entry list. Keep only the non-obvious plain-Node/Electron constraint in a short rationale. As per coding guidelines, “Comments must be concise, limited to non-obvious information, and preferably one line.”

Also applies to: 55-58, 88-89

Source: Coding guidelines

mobile/src/terminal/terminal-hardware-key-send-sequencer.ts (1)

1-7: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Shorten implementation-walkthrough comments. Keep only the non-obvious rationale; these can each be concise one-line comments.

  • mobile/src/terminal/terminal-hardware-key-send-sequencer.ts#L1-L7: reduce to the ordering rationale.
  • mobile/src/terminal/use-hardware-key-input.ts#L8-L10: retain only the missing-native-module fallback reason.
  • mobile/src/terminal/use-hardware-key-input.ts#L31-L33: retain only the polling limitation.
  • mobile/app/h/[hostId]/session/terminal-session-input-bar.tsx#L44-L49: remove extraction and branch walkthrough details.
  • mobile/app/h/[hostId]/session/terminal-session-input-bar.tsx#L95-L99: retain only the capture-view layering rationale.

As per coding guidelines, comments must be concise, limited to non-obvious information, and preferably one line.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a4dc9cf2-5e86-4e87-8740-dedac8a51ce3

📥 Commits

Reviewing files that changed from the base of the PR and between b904d7f and 5770b40.

📒 Files selected for processing (23)
  • build-plugins/plain-node-entry-guard.js
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/app/h/[hostId]/session/mobile-session-command-input-styles.ts
  • mobile/app/h/[hostId]/session/terminal-session-input-bar.tsx
  • mobile/app/index.tsx
  • mobile/app/settings.tsx
  • mobile/app/terminal-settings.tsx
  • mobile/packages/expo-hardware-keyboard/README.md
  • mobile/packages/expo-hardware-keyboard/ios/ExpoHardwareKeyboardModule.swift
  • mobile/packages/expo-hardware-keyboard/src/OrcaKeyCaptureView.tsx
  • mobile/src/components/TerminalShortcutSettings.tsx
  • mobile/src/storage/preferences.test.ts
  • mobile/src/storage/preferences.ts
  • mobile/src/terminal/terminal-hardware-key-send-sequencer.test.ts
  • mobile/src/terminal/terminal-hardware-key-send-sequencer.ts
  • mobile/src/terminal/terminal-hardware-key.test.ts
  • mobile/src/terminal/terminal-hardware-key.ts
  • mobile/src/terminal/terminal-ios-dictation-write-back.test.ts
  • mobile/src/terminal/terminal-ios-ime-keyboard.test.ts
  • mobile/src/terminal/terminal-live-input-affordance.test.ts
  • mobile/src/terminal/use-hardware-key-input.ts
  • mobile/src/theme/resolve-scheme.test.ts
  • mobile/src/theme/theme-context.tsx
🚧 Files skipped from review as they are similar to previous changes (12)
  • mobile/packages/expo-hardware-keyboard/README.md
  • mobile/packages/expo-hardware-keyboard/src/OrcaKeyCaptureView.tsx
  • mobile/src/terminal/terminal-hardware-key.test.ts
  • mobile/src/theme/resolve-scheme.test.ts
  • mobile/src/theme/theme-context.tsx
  • mobile/src/storage/preferences.test.ts
  • mobile/src/terminal/terminal-hardware-key.ts
  • mobile/app/index.tsx
  • mobile/app/terminal-settings.tsx
  • mobile/app/settings.tsx
  • mobile/src/storage/preferences.ts
  • mobile/app/h/[hostId]/session/[worktreeId].tsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@smk508

smk508 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Verified on physical ipad with keyboard. Previously non-character keys like arrow or combos (CTRL+A, CTRL+E, etc.) would not work

[

20260724_153857.mp4

](url)

smk508 and others added 3 commits July 27, 2026 16:45
…keyboard-capture

# Conflicts:
#	build-plugins/plain-node-entry-guard.js
…ure' into feat/mobile-hardware-keyboard-capture
…, run oxfmt

Add a regression test for the fix CodeRabbit caught on the previous push
(applied directly via GitHub): a rejected send whose key is never enqueued
again left an unhandled promise rejection, since only the *next* read of the
chain caught it. Confirmed the new test fails against the prior
implementation and passes against the fix. Also runs oxfmt on the file,
which the GitHub-applied commit didn't go through.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…keyboard-capture

# Conflicts:
#	mobile/app/h/[hostId]/session/[worktreeId].tsx
#	mobile/app/index.tsx
#	mobile/pnpm-lock.yaml
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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: 2

🧹 Nitpick comments (1)
mobile/src/theme/mobile-theme.ts (1)

92-98: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reduce implementation comments that repeat visible code.

  • mobile/src/theme/mobile-theme.ts#L92-L98: Replace the visual-design narrative with one short rationale, or remove it.
  • mobile/app/settings.tsx#L40-L41: Remove the comment because the array order and values are self-evident.

As per coding guidelines, comments must be concise and limited to non-obvious information.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6cbd7b3b-267e-4c4b-810b-93b66186a6a8

📥 Commits

Reviewing files that changed from the base of the PR and between 3e6b93f and 7c3fee2.

⛔ Files ignored due to path filters (1)
  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (48)
  • .gitignore
  • config/scripts/verify-client-display.mjs
  • mobile/app/_layout.tsx
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/app/index.tsx
  • mobile/app/settings.tsx
  • mobile/app/terminal-settings.tsx
  • mobile/package.json
  • mobile/packages/expo-hardware-keyboard/README.md
  • mobile/packages/expo-hardware-keyboard/android/build.gradle
  • mobile/packages/expo-hardware-keyboard/android/src/main/AndroidManifest.xml
  • mobile/packages/expo-hardware-keyboard/android/src/main/java/expo/modules/hardwarekeyboard/ExpoHardwareKeyboardModule.kt
  • mobile/packages/expo-hardware-keyboard/android/src/main/java/expo/modules/hardwarekeyboard/OrcaKeyCaptureView.kt
  • mobile/packages/expo-hardware-keyboard/expo-module.config.json
  • mobile/packages/expo-hardware-keyboard/ios/ExpoHardwareKeyboard.podspec
  • mobile/packages/expo-hardware-keyboard/ios/ExpoHardwareKeyboardModule.swift
  • mobile/packages/expo-hardware-keyboard/ios/OrcaKeyCaptureView.swift
  • mobile/packages/expo-hardware-keyboard/package.json
  • mobile/packages/expo-hardware-keyboard/src/ExpoHardwareKeyboardModule.ts
  • mobile/packages/expo-hardware-keyboard/src/OrcaKeyCaptureView.tsx
  • mobile/packages/expo-hardware-keyboard/src/index.ts
  • mobile/packages/expo-hardware-keyboard/tsconfig.json
  • mobile/src/components/TerminalShortcutSettings.tsx
  • mobile/src/ime/ime-submit-carry.test.ts
  • mobile/src/session/mobile-session-command-input-styles.ts
  • mobile/src/session/terminal-session-input-bar.tsx
  • mobile/src/storage/preferences.test.ts
  • mobile/src/storage/preferences.ts
  • mobile/src/terminal/terminal-color-scheme.test.ts
  • mobile/src/terminal/terminal-color-scheme.ts
  • mobile/src/terminal/terminal-hardware-key-send-sequencer.test.ts
  • mobile/src/terminal/terminal-hardware-key-send-sequencer.ts
  • mobile/src/terminal/terminal-hardware-key.test.ts
  • mobile/src/terminal/terminal-hardware-key.ts
  • mobile/src/terminal/terminal-input-connection-gate.test.ts
  • mobile/src/terminal/terminal-ios-dictation-write-back.test.ts
  • mobile/src/terminal/terminal-ios-ime-keyboard.test.ts
  • mobile/src/terminal/terminal-live-input-affordance.test.ts
  • mobile/src/terminal/use-hardware-key-input.ts
  • mobile/src/theme/mobile-theme.ts
  • mobile/src/theme/resolve-scheme.test.ts
  • mobile/src/theme/resolve-scheme.ts
  • mobile/src/theme/theme-context.tsx
  • notes/client-display-verify-harness.md
  • notes/client-owned-display-preferences-design.md
  • src/renderer/src/runtime/sync-runtime-graph.test.ts
  • src/renderer/src/runtime/sync-runtime-graph.ts
  • src/shared/runtime-types.ts
🚧 Files skipped from review as they are similar to previous changes (37)
  • mobile/packages/expo-hardware-keyboard/expo-module.config.json
  • mobile/src/terminal/terminal-hardware-key-send-sequencer.ts
  • mobile/packages/expo-hardware-keyboard/src/ExpoHardwareKeyboardModule.ts
  • mobile/packages/expo-hardware-keyboard/android/src/main/AndroidManifest.xml
  • mobile/src/storage/preferences.test.ts
  • mobile/src/terminal/terminal-ios-dictation-write-back.test.ts
  • mobile/src/terminal/terminal-color-scheme.test.ts
  • mobile/packages/expo-hardware-keyboard/ios/ExpoHardwareKeyboardModule.swift
  • mobile/packages/expo-hardware-keyboard/src/index.ts
  • .gitignore
  • mobile/packages/expo-hardware-keyboard/README.md
  • mobile/packages/expo-hardware-keyboard/android/build.gradle
  • mobile/src/terminal/terminal-live-input-affordance.test.ts
  • mobile/src/terminal/terminal-color-scheme.ts
  • mobile/packages/expo-hardware-keyboard/tsconfig.json
  • mobile/packages/expo-hardware-keyboard/package.json
  • mobile/src/terminal/terminal-hardware-key.test.ts
  • mobile/src/theme/resolve-scheme.test.ts
  • mobile/app/index.tsx
  • mobile/package.json
  • src/renderer/src/runtime/sync-runtime-graph.test.ts
  • mobile/src/storage/preferences.ts
  • config/scripts/verify-client-display.mjs
  • mobile/src/terminal/terminal-hardware-key-send-sequencer.test.ts
  • mobile/src/theme/resolve-scheme.ts
  • mobile/packages/expo-hardware-keyboard/ios/OrcaKeyCaptureView.swift
  • mobile/packages/expo-hardware-keyboard/src/OrcaKeyCaptureView.tsx
  • mobile/src/components/TerminalShortcutSettings.tsx
  • mobile/app/_layout.tsx
  • src/shared/runtime-types.ts
  • mobile/src/terminal/terminal-ios-ime-keyboard.test.ts
  • mobile/src/terminal/terminal-hardware-key.ts
  • mobile/app/terminal-settings.tsx
  • mobile/packages/expo-hardware-keyboard/android/src/main/java/expo/modules/hardwarekeyboard/OrcaKeyCaptureView.kt
  • mobile/src/theme/theme-context.tsx
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/packages/expo-hardware-keyboard/ios/ExpoHardwareKeyboard.podspec

Comment thread mobile/app/settings.tsx Resolved
Comment thread notes/client-display-verify-harness.md Resolved
smk508 added 2 commits August 8, 2026 18:57
Expose the appearance radio's checked state via accessibilityState.checked
instead of selected, per React Native's accessibility contract for
accessibilityRole="radio". Scope the display-verify harness doc to the
JS/TS/CSS effort it actually covers, since this PR now also ships the
native expo-hardware-keyboard module. Trim two comments that only
restated adjacent code.
…keyboard-capture

# Conflicts:
#	mobile/app/h/[hostId]/session/[worktreeId].tsx
#	mobile/pnpm-lock.yaml
#	mobile/src/ime/ime-submit-carry.test.ts
#	mobile/src/terminal/terminal-input-connection-gate.test.ts
#	mobile/src/terminal/terminal-ios-dictation-write-back.test.ts
@smk508

smk508 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

@AmethystLiang what do you guys need for this

…keyboard-capture

# Conflicts:
#	mobile/app/h/[hostId]/session/[worktreeId].tsx
@nwparker nwparker removed the P1 label Aug 19, 2026
@smk508 smk508 closed this Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants