Repository navigation
Conversation
📝 WalkthroughWalkthroughAdds a cross-platform Expo terminal input package with Android and iOS native views that handle committed text, IME composition, Enter, focus, blur, and backspace events. The session route now uses the shared 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
mobile/packages/expo-terminal-live-input/android/src/main/java/expo/modules/terminalliveinput/TerminalLiveInputView.kt (2)
259-278: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDeduplicate the two
deleteSurroundingText*overrides.Both overrides share the identical empty-field guard and only differ in which
supermethod they call. Extract a small private helper to avoid the two copies drifting.♻️ Proposed refactor
+ private fun handleDeleteAtEmpty(beforeLength: Int): Boolean { + val current = editText.text?.toString() ?: "" + if (current.isEmpty() && beforeLength > 0) { + onKeyPress(mapOf("key" to "Backspace")) + return true + } + return false + } + override fun deleteSurroundingText(beforeLength: Int, afterLength: Int): Boolean { - val current = editText.text?.toString() ?: "" - if (current.isEmpty() && beforeLength > 0) { - onKeyPress(mapOf("key" to "Backspace")) - return true - } - return super.deleteSurroundingText(beforeLength, afterLength) + if (handleDeleteAtEmpty(beforeLength)) return true + return super.deleteSurroundingText(beforeLength, afterLength) } override fun deleteSurroundingTextInCodePoints( beforeLength: Int, afterLength: Int ): Boolean { - val current = editText.text?.toString() ?: "" - if (current.isEmpty() && beforeLength > 0) { - onKeyPress(mapOf("key" to "Backspace")) - return true - } - return super.deleteSurroundingTextInCodePoints(beforeLength, afterLength) + if (handleDeleteAtEmpty(beforeLength)) return true + return super.deleteSurroundingTextInCodePoints(beforeLength, afterLength) }
186-207: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winName the shared ~50ms IME-confirm heuristic window instead of repeating it as a magic literal per platform. Both platforms independently hardcode the same "dedupe/suppress Enter around IME confirmation" timing window without a shared, documented constant, risking silent drift if one side is tuned without the other.
mobile/packages/expo-terminal-live-input/android/src/main/java/expo/modules/terminalliveinput/TerminalLiveInputView.kt#L186-L207: extract the two50Loccurrences (armTerminalEnterDispatchGuard,armSuppressTerminalEnter) into one named constant (e.g. a companion objectIME_ENTER_HEURISTIC_WINDOW_MS).mobile/packages/expo-terminal-live-input/ios/TerminalLiveInputView.swift#L91-L135: extract the0.05literal inarmTerminalEnterSuppressioninto a similarly named constant, and consider documenting that it should track the Android value.mobile/packages/expo-terminal-live-input/expo-module.config.json (1)
2-5: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winUse
applefor module registration instead ofios.Keep
"ios"in"platforms"if needed, but move the module list to the documented Apple config key:"apple": { "modules": ["ExpoTerminalLiveInputModule"] }This avoids relying on legacy iOS-specific module config syntax and keeps the package consistent with the current Expo module config.
mobile/packages/expo-terminal-live-input/src/ExpoTerminalLiveInput.types.ts (1)
31-40: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winModel native async functions on the ref, not as JSX props.
Expo
ViewAsyncFunctions are attached to the React ref. DeclaringfocusAsync,blurAsync, andsetTextAsyncas optional props makes the bridge contract misleading and leaves the actual native ref API untyped. Define a separate native ref handle and use it when typing the wrapper’s native ref. (docs.expo.dev)Proposed type split
+export type NativeTerminalLiveInputViewHandle = { + focusAsync: () => Promise<boolean> + blurAsync: () => Promise<boolean> + setTextAsync: (text: string) => Promise<void> +} + export type NativeTerminalLiveInputViewProps = ViewProps & { readonly editable?: boolean readonly onCommittedText?: (event: TerminalLiveInputCommittedTextEvent) => void readonly onInputFocus?: (event: TerminalLiveInputFocusEvent) => void readonly onInputBlur?: (event: TerminalLiveInputFocusEvent) => void readonly onKeyPress?: (event: TerminalLiveInputKeyPressEvent) => void readonly onTerminalEnter?: (event: TerminalLiveInputTerminalEnterEvent) => void - readonly focusAsync?: () => Promise<boolean> - readonly blurAsync?: () => Promise<boolean> - readonly setTextAsync?: (text: string) => Promise<void> }Source: MCP tools
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 206d789c-2e57-4772-a1d5-dec0f99b393d
⛔ Files ignored due to path filters (1)
mobile/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (27)
mobile/app/h/[hostId]/session/[worktreeId].tsxmobile/package.jsonmobile/packages/expo-terminal-live-input/android/build.gradlemobile/packages/expo-terminal-live-input/android/src/main/AndroidManifest.xmlmobile/packages/expo-terminal-live-input/android/src/main/java/expo/modules/terminalliveinput/ExpoTerminalLiveInputModule.ktmobile/packages/expo-terminal-live-input/android/src/main/java/expo/modules/terminalliveinput/TerminalLiveInputView.ktmobile/packages/expo-terminal-live-input/expo-module.config.jsonmobile/packages/expo-terminal-live-input/ios/ExpoTerminalLiveInput.podspecmobile/packages/expo-terminal-live-input/ios/ExpoTerminalLiveInputModule.swiftmobile/packages/expo-terminal-live-input/ios/TerminalLiveInputView.swiftmobile/packages/expo-terminal-live-input/package.jsonmobile/packages/expo-terminal-live-input/src/ExpoTerminalLiveInput.types.tsmobile/packages/expo-terminal-live-input/src/ExpoTerminalLiveInputModule.tsmobile/packages/expo-terminal-live-input/src/ExpoTerminalLiveInputModule.web.tsmobile/packages/expo-terminal-live-input/src/TerminalLiveInputView.tsxmobile/packages/expo-terminal-live-input/src/index.tsmobile/packages/expo-terminal-live-input/tsconfig.jsonmobile/src/terminal/terminal-live-composition-mirror.test.tsmobile/src/terminal/terminal-live-composition-mirror.tsmobile/src/terminal/terminal-live-hangul-mirror.tsmobile/src/terminal/terminal-live-ime-native-contract.test.tsmobile/src/terminal/terminal-live-input-affordance.test.tsmobile/src/terminal/terminal-live-input-capture-handle.tsmobile/src/terminal/use-terminal-live-accessory-input-commit.tsmobile/src/terminal/use-terminal-live-input-commit.test.tsmobile/src/terminal/use-terminal-live-input-commit.tsmobile/src/terminal/use-terminal-live-pending-input-flush.ts
💤 Files with no reviewable changes (1)
- mobile/src/terminal/terminal-live-hangul-mirror.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
mobile/src/terminal/terminal-live-input-fallback.test.ts (1)
2-2: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAvoid adding new tests with deprecated
react-test-renderer.This package is deprecated in React 19, and suppressing the deprecation warning hides the React migration signal. Prefer the project’s supported React Native testing harness instead.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2dee70f9-6381-44a5-81b7-028e717335ff
📒 Files selected for processing (2)
mobile/packages/expo-terminal-live-input/src/TerminalLiveInputView.tsxmobile/src/terminal/terminal-live-input-fallback.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- mobile/packages/expo-terminal-live-input/src/TerminalLiveInputView.tsx
| beforeEach(() => { | ||
| globalThis.IS_REACT_ACT_ENVIRONMENT = true | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| act(() => renderer?.unmount()) | ||
| renderer = null |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate and inspect the target test file and nearby global flag usage.
printf 'Files:\n'
git ls-files | grep -F 'mobile/src/terminal/terminal-live-input-fallback.test.ts' || true
printf '\nTest file excerpt:\n'
if [ -f mobile/src/terminal/terminal-live-input-fallback.test.ts ]; then
nl -ba mobile/src/terminal/terminal-live-input-fallback.test.ts | sed -n '1,80p'
fi
printf '\nGlobal IS_REACT_ACT_ENVIRONMENT usages:\n'
rg -n "IS_REACT_ACT_ENVIRONMENT|beforeEach|afterEach" mobile/src/terminal --glob '*.test.ts' || true
printf '\nAll repository usages (concise):\n'
rg -n "IS_REACT_ACT_ENVIRONMENT|beforeEach|afterEach" --glob '*.test.ts' --glob '*.tsx' --glob '*.ts' . | head -200 || trueRepository: stablyai/orca
Length of output: 276
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE=mobile/src/terminal/terminal-live-input-fallback.test.ts
printf 'Target file exists and line count:\n'
wc -l "$FILE" || true
printf '\nTarget file excerpt with line numbers:\n'
awk '{printf "%6d\t%s\n", NR, $0}' "$FILE" | sed -n '1,90p'
printf '\nRepository IS_REACT_ACT_ENVIRONMENT usages:\n'
rg -n "IS_REACT_ACT_ENVIRONMENT" . | sed -n '1,200p' || trueRepository: stablyai/orca
Length of output: 12936
Restore IS_REACT_ACT_ENVIRONMENT in this suite.
This test mutates the process-global React act flag in beforeEach and never writes it back, so later tests can inherit the changed act warning behavior depending on run order. Capture the prior value before assigning and restore it in afterEach.
|
Thank you for the substantial native IME work. We reproduced the original Japanese failure in a source-built iOS app, audited both f94b83b and the newer 8453378 head, and confirmed the latest fallback-Enter commit does not change the native causal path. The remaining design cannot deterministically distinguish intentional ASCII s from the provisional first key of Japanese sa: iOS exposes the same unmarked text callback for both, so immediate delivery corrupts sa to さ while the 300 ms hold makes correctness depend on timing. The 50 ms Enter/dedupe windows, corrective DEL after PTY delivery, lifecycle clearing, and unacknowledged send queue likewise leave slow-device, reconnect, grapheme, Korean-rewrite, and Android behavior unproved. The native event-name collision finding is valid, but it does not make the text-delivery contract safe. We need a replacement built around native revisioned editor transactions and one acknowledged, idempotent input queue shared with #7094 and composed with #10447, followed by physical iOS/Android/Korean matrices. Closing this PR rather than asking for more timer tuning; a replacement PR that proves that lifecycle contract would be welcome. |
Summary
Addresses #7427.
Screenshots
No visual change.
Testing
cd mobile && ./node_modules/.bin/vitest run— 317 files passed; 2,315 tests passed and 2 skippedcd mobile && ./node_modules/.bin/tsc --noEmitcd mobile && ./node_modules/.bin/tsc --noEmit -p packages/expo-terminal-live-input/tsconfig.jsoncd mobile && ./node_modules/.bin/oxlintcd mobile && ./node_modules/.bin/oxfmt --check .:app:assembleDebugExpoTerminalLiveInputschemeIME_ACTION_NONE, focus state, empty Backspace, and route wiringLinkPreviewNativeActionView.swiftuse of the iOS 16-onlysubtitleAPI while the app target is iOS 15.1AI Review Report
Grok ran three adversarial review rounds. It initially flagged possible Android double Enter delivery, leaking Japanese modifier bases, stale focus state, and incomplete editor-action/fallback coverage. Those paths were changed or covered with tests; its final review reported no actionable findings.
Claude independently reviewed the complete change and then reran an exact-head gate on
8a23618310..f94b83b34a. It verified the diff, focused tests, type checking, lint/format checks, and the absence of overlap with the latest upstream terminal-routing change; both reports ended with no actionable findings.Cross-platform review confirmed that this PR is limited to the mobile iOS/Android input bridge plus its web/test fallback. It does not change Electron desktop shortcuts or labels, filesystem paths, shell commands, or platform-specific desktop behavior. The existing shared PTY send path, including SSH sessions, remains unchanged.
Security Audit
terminal.sendpath and its 256 KiB payload guard.Notes
Addresses #7427rather than claiming the issue is fully fixed.LinkPreviewNativeActionView.swiftbecausesubtitlerequires iOS 16.ELI5
Japanese IME on mobile terminal could send composing text and break kana modifiers. Composing text stays local until committed, Enter is not double-sent, and Hangul behavior is preserved.