Skip to content

feat(mobile): support physical terminal keyboard input - #10148

Closed
bbingz wants to merge 6 commits into
stablyai:mainfrom
bbingz:feat/mobile-hardware-keyboard
Closed

bbingz wants to merge 6 commits into
stablyai:mainfrom
bbingz:feat/mobile-hardware-keyboard

Conversation

@bbingz

@bbingz bbingz commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add a local Expo native capture view for physical terminal keys on iOS and Android.
  • Keep the hidden live-input field silently focused across terminal switches while preserving explicit software-keyboard focus and modal ownership.
  • Map navigation, control, function, and local-edit keys through the existing ordered terminal send path without stealing IME, AltGr, or system-owned Command/Meta input.
  • Include maintainer review fixes for Android modifier handling, iOS key-command allocation/forward Delete behavior, modal focus ownership, and non-vacuous contract coverage.

Review fixes

The review found and fixed these material issues:

  1. Android's alternate-layout heuristic compared characters after removing Ctrl while retaining Shift/Caps Lock. Case changes were mistaken for AltGr output, suppressing Ctrl+letter (including Ctrl+C) whenever Shift or Caps Lock was active.
  2. The first correction isolated Alt but dropped Shift/Caps state from the comparison. AltGr is now compared with and without Alt under the same case modifiers, so shifted layout-specific text remains platform-owned.
  3. iOS rebuilt an invariant set of 226 UIKeyCommand objects during key resolution. The commands are now cached once per process.
  4. UIKit's UIKeyCommand.inputDelete is U+0008 (Backspace), so the prior canonicalization made forward Delete unreachable. Backspace and U+007F forward Delete are now distinct.
  5. Opening a modal disabled native capture but left the React Native TextInput focused, allowing printable input or Enter to leak beneath some modals. Modal open now blurs the field.
  6. Contract tests that could pass through unrelated source text were narrowed, and coverage now pins Command/Meta pass-through, modified Enter/function keys, software-keyboard focus, modal blur, Android case-modifier behavior, and iOS Delete behavior.

Issue scope

This PR intentionally does not close either issue:

Verification

  • Parent origin/main: 351 test files / 2,590 passed / 2 skipped
  • This branch: 355 test files / 2,646 passed / 2 skipped
  • Focused physical-keyboard slice: 6 files / 76 tests passed
  • Source-revert anti-vacuity probe: 6/6 focused files RED, with 9 behavioral failures while 18 pre-existing tests remained green
  • Earlier review mutation battery: submitted PR 14/22, fixed branch 24/24
  • Three targeted follow-up production reverts each made their regression test RED
  • pnpm lint (oxlint)
  • pnpm format:check (oxfmt; no Prettier)
  • pnpm typecheck (tsc --noEmit)
  • node config/scripts/check-max-lines-ratchet.mjs
  • git diff --check origin/main...HEAD
  • Expo prebuild and CocoaPods installation
  • ExpoHardwareKeyboard Xcode iOS Simulator build: BUILD SUCCEEDED, compiling the edited Swift

The full suites ran at two workers because the host was saturated. No silent or stalled lane was treated as success.

Review

The requested same-model adversarial review loop checked the full implementation for correctness, regression risk, and performance. It produced the Android AltGr, iOS forward Delete, and modal-focus fixes above; the final pass returned clean after focused tests and static gates.

No polling, provider scans, IPC fanout, or subprocess work was added. Android key classification remains bounded O(1), while iOS changes per-resolution command construction from 226 allocations to one process-lifetime static command array.

Desktop macOS/Linux/Windows input paths are untouched. Mobile local, daemon, relay, folder-workspace, git-worktree, and SSH terminals continue through the existing PTY send path; the native capture layer does not assume a local git worktree.

Device/build gaps before merge

Physical iPad verification (2026-08-07) — @littleq0903

  • Head: 005622e5a67bb3e64c94e9125895188a935a337a
  • Device: iPad Pro 13-inch (M5), iPadOS 26.5.2; Apple Magic Keyboard (US); host MacBook Pro M3 Max
  • Client: com.littleq0903.orca.mobile.dev with ExpoHardwareKeyboard, Metro over LAN
  • Pass: Arrows (incl. held-key repeat), Tab, Enter/Shift+Enter, Ctrl+C/D/Z/L, Backspace vs Forward Delete, ~2 min continuous typing through redraws, tab/session switch focus hold, modal dismiss refocus, soft-keyboard open/dismiss, CJK/IME + dead keys/Option accents, Cmd-Tab / Cmd-Space stay system-owned
  • First focus: Live input bar claim required once (expected); silent hold afterward worked
  • Capture physical-keyboard input on mobile terminal sessions #10447 Focus Engine (Tab/Up/Down): no observed steal of Tab/Up/Down into Orca chrome
  • N/A on Magic Keyboard: Home/End, PageUp/PageDown, F1–F4 (no keys on this hardware)
  • Residual failures / notes:
    • Shift+Tab freeform report: does not work while Tab does (checklist row was checked; freeform comment is the precise residual — needs follow-up)
    • Mouse/trackpad events do not work (out of scope for this keyboard PR unless maintainers want it tracked separately)
  • Full checklist: feat(mobile): support physical terminal keyboard input #10148 (comment)

Still open

  • No Android/Kotlin toolchain on the original review machine. Edited Kotlin has contract coverage but was not device-compiled after review fixes; a real Android build and physical-keyboard check remain required before merge if Android is in scope for land.

ELI5

Physical keyboards on mobile terminals only partly worked. Native capture now maps terminal keys without breaking IME or system shortcuts, and review fixes cover modifier edge cases, forward Delete, modal ownership, and a hot-path iOS allocation problem.

@coderabbitai

coderabbitai Bot commented Jul 23, 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

Adds a native Expo hardware keyboard capture package for Android and iOS with JavaScript fallbacks. Introduces terminal hardware-key mapping and commit handling for navigation, shortcuts, editing, and pending text. Adds focus coordination for soft-keyboard requests, modal state, and capture gating. Refactors the live-input bar into a reusable component and integrates hardware-key events and deferred focus behavior into the session route.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% 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
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.
Title check ✅ Passed The title clearly and concisely describes the main change: physical terminal keyboard input support for mobile.
Description check ✅ Passed The description explains the change, testing, review findings, scope, platform coverage, and remaining risks, but omits an explicit security audit section.

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.

🧹 Nitpick comments (1)
mobile/src/terminal/use-terminal-live-input-commit.ts (1)

209-212: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Derive local-edit bytes from the accessory-key definitions.

mobile/src/terminal/use-terminal-live-input-commit.ts:209-212 restates 'backspace'/'delete' bytes ('\x7f' and '\x1b[3~') that already live in mobile/src/terminal/terminal-accessory-keys.ts. Reuse a small helper/constant keyed by local-edit value so later byte changes do not diverge from the accessory key mapping.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d0478e6a-fb90-4cdf-83c3-c68226a8a9d0

📥 Commits

Reviewing files that changed from the base of the PR and between 7ab6014 and 1cf9247.

⛔ Files ignored due to path filters (1)
  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (28)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/package.json
  • 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/HardwareKeyboardCaptureView.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/HardwareKeyboardCaptureView.swift
  • mobile/packages/expo-hardware-keyboard/package.json
  • mobile/packages/expo-hardware-keyboard/src/ExpoHardwareKeyboard.types.ts
  • mobile/packages/expo-hardware-keyboard/src/ExpoHardwareKeyboardModule.ts
  • mobile/packages/expo-hardware-keyboard/src/ExpoHardwareKeyboardModule.web.ts
  • mobile/packages/expo-hardware-keyboard/src/HardwareKeyboardCaptureView.tsx
  • mobile/packages/expo-hardware-keyboard/src/index.ts
  • mobile/packages/expo-hardware-keyboard/tsconfig.json
  • mobile/src/session/MobileTerminalLiveInputBar.tsx
  • mobile/src/terminal/terminal-live-hardware-key-mapping.test.ts
  • mobile/src/terminal/terminal-live-hardware-key-mapping.ts
  • mobile/src/terminal/terminal-live-hardware-key-native-contract.test.ts
  • mobile/src/terminal/terminal-live-hardware-keyboard-focus.test.ts
  • mobile/src/terminal/terminal-live-hardware-keyboard-focus.ts
  • mobile/src/terminal/terminal-live-input-affordance.test.ts
  • mobile/src/terminal/use-terminal-live-hardware-keyboard.test.ts
  • mobile/src/terminal/use-terminal-live-hardware-keyboard.ts
  • mobile/src/terminal/use-terminal-live-input-commit.test.ts
  • mobile/src/terminal/use-terminal-live-input-commit.ts

@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks @bbingz for the original implementation and native groundwork. With maintainer approval, I rebased it onto current main and added the reviewed Android modifier/AltGr, iOS command-cache/forward-Delete, modal-focus, and test-oracle fixes in two follow-up commits; the updated description records the verification evidence and remaining device/build gaps.

@greptile-apps

greptile-apps Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR adds a new expo-hardware-keyboard native Expo module that wraps the live-terminal TextInput in a native view on iOS and Android, enabling physical keyboard input (navigation keys, function keys, Ctrl sequences) to reach the terminal PTY without interfering with IME, accented character input, or system shortcuts. Focus ownership is managed through a wantSoftKeyboard latch so the hidden field stays silently focused across terminal switches while the software keyboard only appears on explicit user request.

  • New native module: HardwareKeyboardCaptureView on iOS intercepts via a cached static UIKeyCommand array; on Android it overrides dispatchKeyEvent, correctly excluding Meta, Enter, Ctrl+Space, and AltGr printable characters.
  • Key mapping layer (terminal-live-hardware-key-mapping.ts): routes events through the existing buildTerminalShortcutKey/getTerminalLiveSpecialKeyDecision pipeline, with a flush-field-then-send decision to clear the IME mirror before sending a navigation key.
  • Focus orchestration (use-terminal-live-hardware-keyboard.ts): a pendingSoftFocusSeq counter defers .focus() calls until showSoftInputOnFocus commits; modal open drops the soft-keyboard latch during render (React 18 setState-during-render pattern) and blurs the field in an effect.

Confidence Score: 5/5

Safe to merge with awareness of the two unverified device gaps noted by the author: physical iPad keyboard behavior under the Focus Engine, and real-device Android compilation after the AltGr fix.

The implementation is thorough: review fixes addressed the known Android AltGr modifier bug, iOS forward-Delete conflation with Backspace, static UIKeyCommand allocation, and modal focus leakage. The 76-test focused suite covers the critical mapper paths, focus-latch states, modal blur, and native contract invariants with a source-revert anti-vacuity probe confirming the tests are non-trivial. The two findings are style-level: a redundant #available(iOS 15.0, *) check that is always satisfied by the iOS 15.1 podspec floor, and a deferred-focus sequence counter that does not reset after executing, which could trigger a redundant .focus() call if canSend toggles while the soft-keyboard latch is held — a low-probability edge case with a benign worst-case (keyboard re-appears without a new tap). Desktop and daemon/relay paths are entirely untouched.

Files Needing Attention: The unverified device scenarios called out in the PR description — physical iPad keyboard behavior and real Android compilation after the AltGr modifier fix — should be confirmed before shipping to users who rely on those platforms.

Important Files Changed

Filename Overview
mobile/packages/expo-hardware-keyboard/ios/HardwareKeyboardCaptureView.swift New iOS native capture view; correctly caches UIKeyCommands as a static let, maps Backspace/Delete distinctly, and guards Meta/Ctrl+Space. The #available(iOS 15.0, *) check inside buildTerminalKeyCommands is always-true given the podspec iOS 15.1 floor.
mobile/packages/expo-hardware-keyboard/android/src/main/java/expo/modules/hardwarekeyboard/HardwareKeyboardCaptureView.kt New Android capture view; AltGr heuristic correctly compares alternate and base characters under the same Shift/Caps state, Ctrl+Space/Meta/Enter are correctly passed through, and isCtrlPrintable excludes space (0x20 not in '!'..'~').
mobile/src/terminal/terminal-live-hardware-key-mapping.ts New TS key mapper; correctly ignores Meta/Enter/Ctrl+Space/plain-printable/alt-printable, routes special keys through getTerminalLiveSpecialKeyDecision, and routes Ctrl+printable/modifier+special through buildTerminalShortcutKey.
mobile/src/terminal/use-terminal-live-hardware-keyboard.ts New focus-latch hook; the setState-during-render pattern for modal open is React 18-endorsed. A stale pendingSoftFocusSeq can cause a deferred focus to fire when showSoftInputOnFocus toggles back to true after a canSend/liveInputEnabled cycle, potentially surfacing the software keyboard unexpectedly.
mobile/src/terminal/use-terminal-live-input-commit.ts Adds handleLiveInputHardwareKey alongside existing handlers; correctly reads heldText/sentText from stable refs, clears stale pending state on terminal-handle mismatch, and routes local-edit/send-bytes/flush-field-then-send correctly.
mobile/src/session/MobileTerminalLiveInputBar.tsx Clean extraction of the live-input bar into its own component; wraps TextInput in HardwareKeyboardCaptureView and correctly threads showSoftInputOnFocus and hardwareCaptureEnabled props.
mobile/app/h/[hostId]/session/[worktreeId].tsx Replaces inline live-input bar with MobileTerminalLiveInputBar, adds useTerminalLiveHardwareKeyboard hook, and wires hardwareKeyboardModalOpen from 15 modal-state signals with clearSoftKeyboardRequest threaded through keyboard-hide, tab action sheet, and dismiss paths.
mobile/src/terminal/terminal-live-hardware-keyboard-focus.ts Pure focus-decision functions; correctly returns silent-focus vs soft-focus vs idle, and planExplicitSoftKeyboardFocus handles all four focused×alreadyWantsSoftKeyboard combinations.
mobile/src/terminal/terminal-live-hardware-key-native-contract.test.ts Source-text contract tests anchored to specific guard bodies rather than whole-file substring matches; covers Meta, Enter, Ctrl+Space, AltGr, iOS Backspace/Delete distinction, and static command caching.
mobile/src/terminal/use-terminal-live-hardware-keyboard.test.ts Hook integration tests covering soft-focus latch deferral, modal open/close latch drop, stale-event rejection, and terminal-switch silent focus; uses react-test-renderer correctly with fake timers.
mobile/packages/expo-hardware-keyboard/src/HardwareKeyboardCaptureView.tsx Falls back to a plain View when native module is absent; correctly uses the try/catch loader in ExpoHardwareKeyboardModule.ts for web/test safety.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Physical Key Event] --> B{Platform}
    B --> |iOS| C[UIKeyCommand registered?]
    B --> |Android| D[dispatchKeyEvent ACTION_DOWN]

    C --> |No| E[TextInput/IME handles it]
    C --> |Yes| F{handleKeyCommand}
    F --> |Meta/Cmd| E
    F --> |Ctrl+Space| E
    F --> G[canonicalKey → key name]

    D --> |Meta| E
    D --> |Enter| E
    D --> |Ctrl+Space| E
    D --> H{isSpecial OR isCtrlPrintable?}
    H --> |No| E
    H --> |Yes| I[canonicalKey → key name]

    G --> J[onHardwareKey event dispatched]
    I --> J

    J --> K[useTerminalLiveHardwareKeyboard.onHardwareKey]
    K --> |liveInputEnabled=false OR canSend=false OR modalOpen=true| L[Dropped in JS]
    K --> M[handleLiveInputHardwareKey]

    M --> N[mapTerminalLiveHardwareKeyEvent]
    N --> |meta| O[ignore]
    N --> |Enter| O
    N --> |Ctrl+Space| O
    N --> |plain/shift/alt printable| O
    N --> |Backspace/Delete + field text| P[local-edit]
    N --> |special key no modifier| Q{getTerminalLiveSpecialKeyDecision}
    N --> |special+modifier or ctrl+printable| R[buildTerminalShortcutKey]

    Q --> |heldText present| S[flush-field-then-send]
    Q --> |empty field| T[send-bytes]
    R --> S
    R --> T

    P --> U[handleLiveInputAccessoryBytes]
    S --> V[flushPendingLiveInputText then sendLiveTerminalInput]
    T --> W[sendTerminalLiveControlAfterPendingFlush]
Loading

Reviews (4): Last reviewed commit: "fix(mobile): tighten hardware keyboard c..." | Re-trigger Greptile

bbingz and others added 6 commits July 31, 2026 09:26
The changed-code quality gate flags clearing wantSoftKeyboard from the
modal-open effect (react-doctor/no-adjust-state-on-prop-change). Adjust it
during render per React's prop-change pattern so the latch never renders a
frame stale; the effect keeps only its imperative timer/blur work.
The React Doctor changed-lines gate blocks on two counts: the modalOpen ref
was written during render, and every effect listed the caller-supplied ref
containers as dependencies, so it traced them as freshly built each render.

Move the ref write into an effect declared before the silent-focus effect
that reads it, and drop the ref containers from the dependency arrays --
refs are stable, so listing them never triggered a re-run anyway.
@bbingz
bbingz force-pushed the feat/mobile-hardware-keyboard branch from 589a4e5 to 005622e Compare July 31, 2026 01:26

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

🧹 Nitpick comments (6)
mobile/src/terminal/use-terminal-live-input-commit.ts (1)

199-248: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate guard/dispatch logic vs. handleLiveInputKeyPress.

handleLiveInputHardwareKey re-implements the same activeHandle/ownership guard and sendTerminalLiveControlAfterPendingFlush dispatch pattern already present in handleLiveInputKeyPress (Lines 141-182). Consider extracting the shared guard clause (and possibly the send-dispatch) into a small helper so future changes to pending-state ownership handling don't need to be applied in two places.

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

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

Reduce this docblock to one non-obvious rationale.

It restates the implementation and fallback behavior visible below. For example:

Proposed change
-/**
- * Wraps the live-terminal TextInput so physical keys enter the native
- * responder/view chain. Falls back to a plain View on web/tests.
- */
+/** Keeps terminal navigation and control keys in the native responder chain. */

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/android/src/main/java/expo/modules/hardwarekeyboard/HardwareKeyboardCaptureView.kt (1)

131-136: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Tighten the function-key test to the mapped set.

key.startsWith("F") is a prefix heuristic that happens to be safe only because canonicalKey lowercases fallback labels. A future canonical name starting with F (e.g. "Find") would silently be treated as a terminal special key.

♻️ Match F1–F12 explicitly
-      key == "Home" || key == "End" || key == "PageUp" || key == "PageDown" ||
-      key.startsWith("F")
+      key == "Home" || key == "End" || key == "PageUp" || key == "PageDown" ||
+      FUNCTION_KEYS.contains(key)
   }
+
+  private companion object {
+    val FUNCTION_KEYS = (1..12).map { "F$it" }.toSet()
+  }
mobile/src/terminal/terminal-live-hardware-keyboard-focus.test.ts (1)

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

Add an idle decision case.

getTerminalLiveHardwareKeyboardFocusDecision has three outcomes but only silent-focus and soft-focus are asserted; the !liveInputEnabled || !canSend gate (which prevents focus/capture on a non-sendable terminal) is untested.

💚 Suggested test
+  it('Given live input disabled When decided Then idle', () => {
+    expect(
+      getTerminalLiveHardwareKeyboardFocusDecision({
+        wantSoftKeyboard: true,
+        liveInputEnabled: false,
+        canSend: true
+      })
+    ).toEqual({ kind: 'idle' })
+  })
mobile/app/h/[hostId]/session/[worktreeId].tsx (1)

1085-1100: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the modal aggregation into a named, testable helper.

This 15-term chain is the single gate for hardware capture, soft-latch release, and blur-on-open. Any modal state added later must be remembered here or physical keys keep reaching the terminal while a sheet is open. Moving it next to the other session-route helpers (e.g. mobile-session-route-helpers.ts) makes it unit-testable and keeps the render body readable.

♻️ Sketch
-  const hardwareKeyboardModalOpen =
-    showHeaderMoreActions ||
-    showQuickCommands ||
-    ...
-    deleteKeyTarget != null
+  const hardwareKeyboardModalOpen = isMobileSessionModalOpen({
+    showHeaderMoreActions,
+    showQuickCommands,
+    showCreateTabDrawer,
+    showCreateBrowserModal,
+    showCustomKeyModal,
+    showDictationSetup,
+    pendingDiffNotesDelivery,
+    actionTarget,
+    markdownActionTarget,
+    fileActionTarget,
+    browserActionTarget,
+    leaveDrafts,
+    discardMarkdownTarget,
+    renameTarget,
+    deleteKeyTarget
+  })
mobile/src/terminal/use-terminal-live-hardware-keyboard.test.ts (1)

8-18: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Replace the react-test-renderer deprecation suppression.

@testing-library/react-native is already in the mobile test stack, and renderHook/RNTL event APIs can replace the React Test Renderer harness here so this test no longer depends on keeping the deprecated renderer warning hidden.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6dcd3746-519c-424f-baef-365c8020ed99

📥 Commits

Reviewing files that changed from the base of the PR and between 589a4e5 and 005622e.

⛔ Files ignored due to path filters (1)
  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (28)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/package.json
  • 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/HardwareKeyboardCaptureView.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/HardwareKeyboardCaptureView.swift
  • mobile/packages/expo-hardware-keyboard/package.json
  • mobile/packages/expo-hardware-keyboard/src/ExpoHardwareKeyboard.types.ts
  • mobile/packages/expo-hardware-keyboard/src/ExpoHardwareKeyboardModule.ts
  • mobile/packages/expo-hardware-keyboard/src/ExpoHardwareKeyboardModule.web.ts
  • mobile/packages/expo-hardware-keyboard/src/HardwareKeyboardCaptureView.tsx
  • mobile/packages/expo-hardware-keyboard/src/index.ts
  • mobile/packages/expo-hardware-keyboard/tsconfig.json
  • mobile/src/session/MobileTerminalLiveInputBar.tsx
  • mobile/src/terminal/terminal-live-hardware-key-mapping.test.ts
  • mobile/src/terminal/terminal-live-hardware-key-mapping.ts
  • mobile/src/terminal/terminal-live-hardware-key-native-contract.test.ts
  • mobile/src/terminal/terminal-live-hardware-keyboard-focus.test.ts
  • mobile/src/terminal/terminal-live-hardware-keyboard-focus.ts
  • mobile/src/terminal/terminal-live-input-affordance.test.ts
  • mobile/src/terminal/use-terminal-live-hardware-keyboard.test.ts
  • mobile/src/terminal/use-terminal-live-hardware-keyboard.ts
  • mobile/src/terminal/use-terminal-live-input-commit.test.ts
  • mobile/src/terminal/use-terminal-live-input-commit.ts

@littleq0903

Copy link
Copy Markdown

+1 to this, I am using iPad OS to work remotely on daily basis, would like to see this implemented, any help needed?

@bbingz

bbingz commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@littleq0903 yes — physical-iPad verification is the one gap this PR can't close from here. It's listed under "Device/build gaps before merge" in the description: simulator testing can't settle #10447's report that the iPadOS Focus Engine may consume Tab / Up / Down, and held-key repeat is device-unverified. The implementation relies on wantsPriorityOverSystemBehavior with no Focus Engine handling, so a real device is the only oracle.

If you can run a dev build on your iPad with a hardware keyboard, these five checks would unblock it:

  1. Tab, Up/Down, PageUp/PageDown reach the shell instead of moving focus between UI controls.
  2. Ctrl-C / Ctrl-D / Ctrl-Z reach the PTY.
  3. Holding an arrow key repeats at the system rate rather than firing once.
  4. IME (any non-Latin keyboard) and long-press accented characters still compose normally — the hidden field must stay silently focused without stealing composition.
  5. System shortcuts (Cmd-Tab, Cmd-Space) still go to iPadOS, not the terminal.

For any failure, note the key and whether the app swallowed it or the system did — that distinction picks the fix. @brennanb2025 owns the current head, so results should land here and he can sequence them.

@littleq0903

Copy link
Copy Markdown

I can help on that, I am using an iPad OS as my major command center to a heavy agentic workflow.

@bbingz

bbingz commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@littleq0903 thank you — that is exactly the gap. A short physical-iPad checklist if you have a few minutes while driving a real agent workflow:

Setup

  1. Build/install this PR's mobile head (or any TestFlight/dev client that includes the physical-key capture view).
  2. Pair the iPad to a desktop/host that has a live agent terminal (your normal command-center path is ideal).
  3. Open a session so the hidden live-input field is the focused terminal input path (not a modal text field, not Settings).

Must-pass

# Action Expected
1 Arrow keys / Home / End Cursor moves in the agent TUI; no spurious printable chars
2 Ctrl+C / Ctrl+D / Ctrl+L Delivered as control sequences (interrupt / EOF / clear)
3 Tab / Shift+Tab Completions or focus cycle inside the TUI, not the app chrome
4 Enter / Shift+Enter Submit vs newline — match what the agent expects on desktop
5 Function keys (F1–F4 if the agent uses them) Reach the PTY; do not open iPadOS system gestures only
6 Hardware keyboard connected continuously for ~2 min of agent work No silent focus loss; typing still lands after the agent redraws

Must-not-break

# Action Expected
7 Software keyboard toggle (globe / dismiss) Still opens when you ask; does not fight physical keys
8 Open a modal (rename, confirm, search) then dismiss Focus returns to the terminal without eating the next key
9 Cmd/Meta / system shortcuts (if any on your keyboard) Stay with iPadOS / Orca chrome; not injected as terminal text
10 CJK / dead keys / Option-letter if you use them IME composition still works when the software keyboard is up

Please report back

No need for a formal write-up — a short bullet list in this thread is enough. I will fold failures into the PR before asking for merge.

@littleq0903

littleq0903 commented Aug 7, 2026 •

Copy link
Copy Markdown

Physical iPad hardware-keyboard verification checklist

I’m taking the real-device verification requested above. I’ll test the current PR head and update this checklist with the results.

Test environment

  • PR commit: 005622e5a67bb3e64c94e9125895188a935a337a (feat/mobile-hardware-keyboard), matching the maintainer-held test head; tracked worktree clean.
  • iPad: iPad Pro 13-inch (M5), iPadOS 26.5.2 (23F84); Developer Mode enabled.
  • Physical keyboard: Apple Magic Keyboard for iPad Pro 13-inch (M5), standard US English layout.
  • Desktop host: MacBook Pro (Mac15,9, Apple M3 Max), macOS 26.5.2 (25F84); Xcode 26.6 (17F113).
  • Agent/TUI: pending selection (Codex, Claude, etc.).
  • Development client: com.littleq0903.orca.mobile.dev containing ExpoHardwareKeyboard is installed; the iPad is paired over the local network and Metro is running over LAN.
  • Live terminal state: open a session with the hidden live-input path focused (not a modal or Settings field). (Colin: I didn't know what does this mean)

PTY key delivery

  • Arrow keys: Left/Right/Up/Down move the cursor or selection in the agent TUI, with no spurious printable characters and no Orca UI focus movement.
  • Tab / Shift+Tab: trigger terminal completion or the TUI focus cycle, rather than moving focus between Orca controls.
  • Enter / Shift+Enter: submit versus insert a newline consistently with the same agent on desktop.
  • Ctrl+C: sends interrupt.
  • Ctrl+D: sends EOF.
  • Ctrl+Z: sends suspend.
  • Ctrl+L: clears/redraws the terminal.
  • Backspace / Forward Delete: remain distinct and perform the expected terminal editing action.
  • Held arrow keys: holding each arrow repeats at the iPadOS system rate instead of firing only once.
  • Home / End: reach the PTY and perform the expected terminal navigation. (Colin: not tested)
  • PageUp / PageDown: reach the PTY instead of moving focus or scrolling Orca chrome. (Colin: not tested)
  • F1–F4: reach the PTY when the active agent/TUI handles them, rather than being consumed only by iPadOS. (Colin: not tested)

Focus and input ownership

  • Use the physical keyboard continuously for about two minutes, including terminal redraws; typing never silently loses focus.
  • Switch terminal tabs/sessions and return; the next physical key still lands in the active terminal.
  • Open and dismiss a modal (for example rename, confirm, or search); focus returns to the terminal and the next key is not eaten.
  • Open and dismiss the software keyboard; it appears when requested and does not fight physical-key input.
  • Confirm whether iPadOS Focus Engine ever steals Tab, Up, or Down (the Capture physical-keyboard input on mobile terminal sessions #10447 risk). (I feel not, but I am not sure what does this look like)

Composition and system shortcuts

  • CJK/non-Latin IME: composition and commit work normally while the software keyboard is visible.
  • Dead keys, Option-letter, and long-press accented characters: compose normally; the hidden terminal field does not steal or prematurely commit composition.
  • Cmd-Tab: remains an iPadOS app-switching shortcut and is not injected into terminal text.
  • Cmd-Space: remains the iPadOS system shortcut and is not injected into terminal text.
  • Other Cmd/Meta system or Orca shortcuts remain owned by iPadOS/Orca rather than appearing as terminal text.

Failure reporting

  • For every failure, record the exact key/chord, what appeared (literal text, wrong sequence, or nothing), and whether Orca swallowed it or iPadOS/Focus Engine consumed it.
  • Post pass/fail results for every row, along with any useful screen recording or logs.

@bbingz

bbingz commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@littleq0903 thank you — perfect. Holding this head for your run so results stay unambiguous:

  • SHA: 005622e5a67bb3e64c94e9125895188a935a337a (feat/mobile-hardware-keyboard)
  • Branch is currently dirty vs main; not rebasing until after your pass/fail so the oracle matches what you built.

Whenever you post the checklist results (or any early failure notes), I will fold them into the PR description.

@littleq0903

Copy link
Copy Markdown

I am building it currently, I did have only iOS resources previously so i am setting up everything, almost done setting up and begin the testing.

@littleq0903

Copy link
Copy Markdown

I've been traveling with iPadOS for a few months now. Most of my work involves codex and claude sessions (maintaining more than 15 online production services), and as long as I have a terminal and remote access, everything runs pretty smoothly.

However, Orca has shown me that I might be able to access these resources with much lower latency and bandwidth, so I'm really looking forward to it. Hopefully this helps.

@littleq0903

Copy link
Copy Markdown

I am testing now, arrow keys worked now, but I had to click the Live input button at the bottom to be able to input anything.

@bbingz

bbingz commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@littleq0903 great signal — arrows reaching the PTY means the native capture path is live on real iPad hardware.

On needing the Live input control first: that first claim is expected. Hardware keys only route once the hidden live-input field owns focus; the bar/button is the explicit entry. After that first claim, the intended model is silent hold (keys keep working without re-tapping, and without forcing the software keyboard up). Worth checking next:

  1. After the first Live-input claim, type for ~2 min through redraws — do keys stay owned without another tap?
  2. Switch terminal tabs/sessions and return — does the next key still land without re-claiming Live input?
  3. Open/dismiss a modal — does focus return, or do you need Live input again?

Please keep going through the rest of your checklist (Ctrl-C/D/Z, Tab/Shift-Tab, held-key repeat, IME, Cmd-Tab/Cmd-Space). No code changes from me mid-run so the oracle stays on 005622e5….

@littleq0903

Copy link
Copy Markdown

Magic Keyboard doesn't have

  • F1-F4
  • Home/End
  • PageUp/PageDown

shift tab doesn't work while tab is working
mouse event doesn't work

I don't have any bluetooth keyboard unfortunately.

@littleq0903

Copy link
Copy Markdown

@bbingz the result posted.

@bbingz

bbingz commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@littleq0903 thank you — this is exactly the oracle we needed. Folded your results into the PR description.

Summary I recorded

  • Pass on Magic Keyboard / iPad Pro M5 @ 005622e5…: arrows (+ hold-repeat), Tab, Enter/Shift+Enter, Ctrl-C/D/Z/L, Backspace vs Forward Delete, focus hold across redraws / session switch / modal dismiss, soft keyboard coexistence, IME + accents, Cmd-Tab / Cmd-Space system-owned. Capture physical-keyboard input on mobile terminal sessions #10447 Tab/Up/Down chrome-steal not observed.
  • N/A: Home/End, PageUp/PageDown, F1–F4 (absent on Magic Keyboard).
  • Residual: Shift+Tab fails while Tab works (treating your freeform note as authoritative over the checklist row). Mouse/trackpad events out of scope for this keyboard PR unless maintainers want a separate issue.
  • Live terminal state row: that was the hidden live-input focus path — the Live input control you tapped first is the expected one-time claim; silent hold after that matches design.

No rebase from me this cycle (still dirty vs main; holding green test oracle). @brennanb2025 owns sequencing land/refresh if maintainers want Shift+Tab fixed before merge.

@bbingz

bbingz commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Closing as part of fork PR backlog cleanup.

This branch is long-conflicted (DIRTY) against current main and is not on the active campaign rebase list. Feel free to reopen or cut a fresh PR from an updated branch if the change is still needed.

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.

5 participants