Repository navigation
Fix mobile terminal Korean IME composition on Android - #7011
Conversation
The mobile terminal capture field previously sent and cleared every TextInput change, which can break Hangul composition on Android keyboards. Introduce a small commit model and extracted live-input hook so composed text is flushed deliberately while ASCII remains immediate. Constraint: React Native TextInput has no portable composition event for this path; the fix uses a bounded commit delay for likely IME text. Rejected: Native-module IME integration | unnecessary for the confirmed JS dispatch/clear failure and higher maintenance risk. Confidence: high Scope-risk: moderate Directive: Keep terminal.send payload shape and buffered command input unchanged; do not claim physical Samsung Keyboard QA without device evidence. Tested: cd mobile && pnpm exec vitest run src/terminal/terminal-live-text-commit.test.ts src/terminal/terminal-live-input.test.ts src/terminal/terminal-text-input-normalization.test.ts src/terminal/terminal-keyboard-type.test.ts --reporter=verbose Tested: cd mobile && pnpm exec tsc --noEmit Tested: cd mobile && pnpm exec oxlint src/terminal/terminal-live-text-commit.ts src/terminal/terminal-live-text-commit.test.ts src/terminal/use-terminal-live-input-commit.ts app/h/[hostId]/session/[worktreeId].tsx Not-tested: Physical Galaxy Fold7/Samsung Keyboard and Android emulator/Gboard QA were unavailable; device probes recorded no attached Android device.
|
Ready to review this PR? Stage has broken it down into 7 individual chapters for you: Chapters generated by Stage for commit a52c661 on Jul 1, 2026 5:28pm UTC. |
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughChangesThis PR adds terminal live-input decision helpers, pending-flush state and ordering, accessory commit handling, raw-send targeting, RPC response acceptance checks, and session-screen wiring for live input. It also adds Vitest coverage for the new decision and ordering logic, and updates cleanup paths to clear pending live-input commits during reuse, detach, and toggle flows. Related issues: None identified. 🚥 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: 3
🧹 Nitpick comments (1)
mobile/src/terminal/terminal-live-text-commit.ts (1)
3-3: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument why this fixed delay exists.
Line 3 introduces the core IME-settle heuristic, but the reason is only visible later in the hook. Add a short local comment so future edits don’t treat
150as arbitrary.Proposed comment
+// Why: React Native does not expose portable composition events here, so probable +// IME text gets a short settle window before being sent to the PTY. export const TERMINAL_LIVE_TEXT_COMMIT_DELAY_MS = 150As per coding guidelines,
**/*.{ts,tsx,js,jsx}changes driven by non-obvious constraints should include a short why-comment.Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 3d3f3d47-5e06-461d-85b6-3c542d540cb4
📒 Files selected for processing (4)
mobile/app/h/[hostId]/session/[worktreeId].tsxmobile/src/terminal/terminal-live-text-commit.test.tsmobile/src/terminal/terminal-live-text-commit.tsmobile/src/terminal/use-terminal-live-input-commit.ts
Accessory keys share the same pending live-input commit gate as TextInput keypress and submit paths, so control bytes cannot race ahead of composed Hangul. Constraint: React Native mobile input does not expose portable composition events for Samsung/Gboard IME paths. Rejected: Let accessory buttons keep sending directly | Direct sends can drop pending Hangul before Tab/Esc/Enter/Backspace reaches the PTY. Confidence: high Scope-risk: narrow Directive: Keep all terminal control-byte paths behind the pending live-input flush/local-edit decision before sending to the PTY. Tested: pnpm --dir mobile test; pnpm --dir mobile lint; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile exec oxfmt --check src/terminal/terminal-live-text-commit.ts src/terminal/terminal-live-text-commit.test.ts src/terminal/use-terminal-live-input-commit.ts src/terminal/use-terminal-live-accessory-input-commit.ts app/h/[hostId]/session/[worktreeId].tsx; git diff --cached --check Not-tested: Physical Galaxy Fold7 Samsung keyboard manual QA is still external-device only.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
mobile/src/terminal/use-terminal-live-input-commit.ts (1)
103-131: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winCancel the pending commit timer on unmount.
This hook schedules delayed commits, but it never tears that timer down when the owner unmounts. If the screen disappears inside the settle window, the callback can still flush buffered text into the PTY after teardown.
Suggested fix
const schedulePendingLiveInputCommit = useCallback( (handle: string, text: string, delayMs: number) => { if (liveInputCommitTimerRef.current) { clearTimeout(liveInputCommitTimerRef.current) @@ }, [flushPendingLiveInputText] ) + + useEffect(() => { + return () => { + if (liveInputCommitTimerRef.current) { + clearTimeout(liveInputCommitTimerRef.current) + liveInputCommitTimerRef.current = null + } + pendingLiveInputHandleRef.current = null + pendingLiveInputTextRef.current = '' + } + }, []) useEffect(() => {
🧹 Nitpick comments (1)
mobile/src/terminal/terminal-live-text-commit.ts (1)
91-97: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument why accessory Delete leaves
pendingTextunchanged.Because
'\x1b[3~'is treated aslocal-editabove but falls through toreturn pendingTexthere, this reads like an accidental omission unless the reason is written down. Please add a short why-comment on this branch. As per coding guidelines,**/*.{ts,tsx,js,jsx}: “When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does.”Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 04b1f22d-cd9c-4f77-ad93-9179afe7e11c
📒 Files selected for processing (5)
mobile/app/h/[hostId]/session/[worktreeId].tsxmobile/src/terminal/terminal-live-text-commit.test.tsmobile/src/terminal/terminal-live-text-commit.tsmobile/src/terminal/use-terminal-live-accessory-input-commit.tsmobile/src/terminal/use-terminal-live-input-commit.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- mobile/src/terminal/terminal-live-text-commit.test.ts
- mobile/app/h/[hostId]/session/[worktreeId].tsx
Pending live-input timers now clear on hook unmount, and accessory Delete documents why it stays local without trimming pending IME text. Constraint: React Native TextInput lacks a portable composition lifecycle, so pending IME text is guarded by a bounded timer that must not survive screen teardown. Rejected: Use clearPendingLiveInputCommit during unmount | it would also touch React state/native props during teardown when only timer/ref cleanup is required. Confidence: high Scope-risk: narrow Directive: Any delayed terminal input commit must have an owner-lifecycle cleanup path before sending to the PTY. Tested: pnpm --dir mobile test; pnpm --dir mobile lint; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile exec vitest run src/terminal/terminal-live-text-commit.test.ts --reporter=verbose; pnpm --dir mobile exec oxfmt --check src/terminal/terminal-live-text-commit.ts src/terminal/use-terminal-live-input-commit.ts; git diff --check Not-tested: Physical Galaxy Fold7 Samsung keyboard manual QA remains unavailable in this environment.
Accessory Backspace/Delete now carry semantic local-edit intent from built-in keys instead of inferring intent from raw bytes, and submit handling is reconnected to the pure submit-sequence model. Constraint: Custom terminal accessory keys may produce the same bytes as built-ins but should still flush pending IME text before sending rather than being silently treated as hidden-input edits. Rejected: Classify local accessory edits by raw bytes | That couples future custom controls to current built-in byte encodings. Confidence: high Scope-risk: narrow Directive: Keep semantic input intent separate from terminal byte payloads when pending IME text is present. Tested: pnpm --dir mobile test; pnpm --dir mobile lint; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile exec oxfmt --check src/terminal/terminal-live-text-commit.ts src/terminal/terminal-live-text-commit.test.ts src/terminal/use-terminal-live-input-commit.ts src/terminal/use-terminal-live-accessory-input-commit.ts app/h/[hostId]/session/[worktreeId].tsx; git diff --check Not-tested: Physical Galaxy Fold7 Samsung keyboard manual QA remains unavailable in this environment.
Propagate terminal.send success from pending Korean IME text before sending Enter, Tab, or accessory bytes, while keeping custom no-pending accessory bytes on the original direct path. Constraint: PR stablyai#7011 review required follow-up control bytes only after the pending composed text send actually succeeds. Rejected: Treating send invocation as success | It can still reject or no-op when RPC state changed. Confidence: high Scope-risk: narrow Directive: Keep pending IME flush paths async-success-aware before adding new terminal control inputs. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; pnpm --dir mobile exec oxfmt --check changed files; targeted no-excuse clean for mobile/src/terminal changed files. Not-tested: Physical Galaxy Fold7 Samsung keyboard; full session file no-excuse audit still reports pre-existing unrelated violations.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
mobile/src/terminal/use-terminal-live-input-commit.ts (1)
75-93: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winKeep pending IME state visible until the async flush settles.
flushPendingLiveInputText()clearspendingLiveInputHandleRef/pendingLiveInputTextRefbefore awaiting the send. If the timer flush starts and the user immediately presses Enter/Tab/accessory, those handlers see no pending text and can send control bytes while the composed text send is still in flight, breaking the flush-before-control guarantee. Track an in-flight flush promise or only clear the pending refs after the send settles successfully, so control paths can await or suppress correctly.Also applies to: 112-115, 204-208, 242-247
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: f91c2bd0-df54-47ad-8c55-6da513e66fbe
📒 Files selected for processing (7)
mobile/app/h/[hostId]/session/[worktreeId].tsxmobile/src/terminal/terminal-live-control-send-order.test.tsmobile/src/terminal/terminal-live-control-send-order.tsmobile/src/terminal/terminal-live-text-commit.test.tsmobile/src/terminal/terminal-live-text-commit.tsmobile/src/terminal/use-terminal-live-accessory-input-commit.tsmobile/src/terminal/use-terminal-live-input-commit.ts
✅ Files skipped from review due to trivial changes (2)
- mobile/src/terminal/terminal-live-control-send-order.test.ts
- mobile/src/terminal/terminal-live-control-send-order.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- mobile/src/terminal/terminal-live-text-commit.ts
- mobile/src/terminal/terminal-live-text-commit.test.ts
- mobile/app/h/[hostId]/session/[worktreeId].tsx
Treat terminal.send as successful only when the RPC response is ok and the runtime send result is accepted, then route all live-input control sends through a shared in-flight pending-flush barrier. Constraint: PR stablyai#7011 review found that resolved RPC promises and per-call sequencing were not enough to prove pending Hangul text reached the PTY before follow-up controls. Rejected: Only awaiting each flush-then-send call | Repeatable accessory keys and no-pending sends can arrive while the first flush is still in flight. Confidence: high Scope-risk: moderate Directive: Keep future mobile terminal control paths behind the pending-flush barrier whenever IME text may be in flight. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; pnpm --dir mobile exec oxfmt --check changed files; no-excuse clean for terminal changed files. Not-tested: Physical Galaxy Fold7 Samsung keyboard; full session file no-excuse audit still reports pre-existing unrelated violations.
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 89906f62-0f4a-4ed3-981d-67c3b7011a43
📒 Files selected for processing (10)
mobile/app/h/[hostId]/session/[worktreeId].tsxmobile/src/terminal/terminal-live-accessory-input.tsmobile/src/terminal/terminal-live-input-sender.tsmobile/src/terminal/terminal-live-pending-flush-state.test.tsmobile/src/terminal/terminal-live-pending-flush-state.tsmobile/src/terminal/terminal-send-rpc-response.test.tsmobile/src/terminal/terminal-send-rpc-response.tsmobile/src/terminal/use-terminal-live-accessory-input-commit.tsmobile/src/terminal/use-terminal-live-input-commit.tsmobile/src/terminal/use-terminal-live-pending-input-flush.ts
✅ Files skipped from review due to trivial changes (2)
- mobile/src/terminal/terminal-live-accessory-input.ts
- mobile/src/terminal/terminal-live-pending-flush-state.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- mobile/app/h/[hostId]/session/[worktreeId].tsx
Drain the pending snapshot captured by a control action after any already-active terminal send, and make accessory commit handling explicit so raw fallback is not encoded as an inverted boolean. Constraint: Architecture review found the previous single-slot barrier could wait for an older flush while skipping newly pending Hangul text. Rejected: Reusing the prior in-flight promise as the current flush result | It proves only an older snapshot, not the current pending buffer. Confidence: high Scope-risk: narrow Directive: New mobile terminal control paths must distinguish allow-raw, handled, and suppress-raw outcomes explicitly. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; pnpm --dir mobile exec oxfmt --check changed files; no-excuse clean for terminal changed files. Not-tested: Physical Galaxy Fold7 Samsung keyboard; full session file no-excuse audit still reports pre-existing unrelated violations.
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
mobile/src/terminal/use-terminal-live-accessory-input-commit.ts (1)
67-71: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider a short "Why" comment for the flush-barrier wait.
The
'send-now'branch implements the PR's core non-obvious requirement — serializing accessory control sends behind the shared pending-flush barrier so composed text lands before follow-up controls — but has no inline comment, unlike the'local-edit'branch just below it. A one-line "Why" comment here would match the pattern used elsewhere in this file (and in the sibling hook) and help future readers understand why asuppress-rawresult is possible.📝 Proposed comment addition
switch (decision.kind) { case 'send-now': + // Why: wait for any in-flight pending-flush so composed IME text + // reaches the PTY before this raw accessory byte send. return (await waitForPendingLiveInputFlush()) ? { kind: 'allow-raw' } : { kind: 'suppress-raw' }As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: f17c4fc5-25d1-4f15-bdf2-b76708c39831
📒 Files selected for processing (10)
mobile/app/h/[hostId]/session/[worktreeId].tsxmobile/src/terminal/terminal-live-accessory-input.tsmobile/src/terminal/terminal-live-input-sender.tsmobile/src/terminal/terminal-live-pending-flush-state.test.tsmobile/src/terminal/terminal-live-pending-flush-state.tsmobile/src/terminal/terminal-send-rpc-response.test.tsmobile/src/terminal/terminal-send-rpc-response.tsmobile/src/terminal/use-terminal-live-accessory-input-commit.tsmobile/src/terminal/use-terminal-live-input-commit.tsmobile/src/terminal/use-terminal-live-pending-input-flush.ts
✅ Files skipped from review due to trivial changes (1)
- mobile/src/terminal/terminal-send-rpc-response.ts
🚧 Files skipped from review as they are similar to previous changes (8)
- mobile/src/terminal/terminal-live-accessory-input.ts
- mobile/src/terminal/terminal-live-input-sender.ts
- mobile/src/terminal/terminal-live-pending-flush-state.test.ts
- mobile/src/terminal/use-terminal-live-pending-input-flush.ts
- mobile/src/terminal/terminal-live-pending-flush-state.ts
- mobile/src/terminal/use-terminal-live-input-commit.ts
- mobile/src/terminal/terminal-send-rpc-response.test.ts
- mobile/app/h/[hostId]/session/[worktreeId].tsx
Capture the terminal handle at accessory keypress time and suppress raw fallback if the active live terminal changes while waiting for pending IME flushes. Constraint: Independent review found raw accessory bytes could retarget to a different terminal after an async IME flush barrier. Rejected: Re-reading activeHandleRef as the send target after await | It can point at a different terminal than the keypress belonged to. Confidence: high Scope-risk: narrow Directive: Raw accessory fallback must use the keypress-time target and revalidate it after any await. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; pnpm --dir mobile exec oxfmt --check changed files; no-excuse clean for terminal changed files. Not-tested: Physical Galaxy Fold7 Samsung keyboard; full session file no-excuse audit still reports pre-existing unrelated violations.
Make the non-obvious raw accessory wait/suppress behavior explicit so future changes preserve IME-before-control ordering. Constraint: CodeRabbit requested a why-comment for the send-now accessory branch. Rejected: Leaving the barrier semantics implicit | The branch can otherwise look like unnecessary async defensive code. Confidence: high Scope-risk: narrow Directive: Keep comments focused on why raw accessory bytes wait behind IME flushes. Tested: targeted terminal vitest suite; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; oxfmt check for changed file. Not-tested: Physical Galaxy Fold7 Samsung keyboard.
|
@coderabbitai review |
✅ Action performedReview finished.
|
Keep the stale-handle guard focused on the captured active terminal instead of live-input opt-in state, so buffered mode keeps existing accessory key behavior while async live-input waits still cannot retarget to another terminal. Constraint: Buffered command input behavior must remain unchanged while fixing mobile Korean IME live input ordering. Rejected: Requiring live-input enabled handles for raw accessory fallback | suppresses valid buffered-mode accessory sends. Confidence: high Scope-risk: narrow Directive: Do not use live-input opt-in state as terminal liveness for raw accessory sends; validate captured target, active terminal tab, connection, and client instead. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; oxfmt --check changed mobile terminal/session files; TypeScript no-excuse checker for changed terminal files. Not-tested: Physical Galaxy Fold7 Samsung Keyboard manual QA and GitHub Actions jobs, blocked by unavailable device and upstream fork workflow approval.
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
mobile/app/h/[hostId]/session/[worktreeId].tsx (1)
1266-1273: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winDon't show a dictation success toast before the live send is accepted.
Lines 1271-1272 ignore the new
Promise<boolean>contract and always toast success, even whensendLiveTerminalInputreturnsfalsebecause the terminal changed, disconnected, exceeded the byte cap, or rejected the send.Suggested fix
- void sendLiveTerminalInput(insertHandle, route.text) - showToast('Dictation inserted') + void sendLiveTerminalInput(insertHandle, route.text).then((sent) => { + if (sent) { + showToast('Dictation inserted') + } + }) return
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: cf6c9d92-a159-4b12-adc3-105b6d54bf27
📒 Files selected for processing (3)
mobile/app/h/[hostId]/session/[worktreeId].tsxmobile/src/terminal/terminal-live-accessory-raw-send-target.test.tsmobile/src/terminal/terminal-live-accessory-raw-send-target.ts
Avoid timer-driven PTY writes for Hangul candidates so paused Korean composition cannot leak intermediate jamo, while preserving the bounded settle timer for non-Hangul IME text. Also keep disabled live-input accessory fallback behind any existing pending flush barrier. Constraint: React Native TextInput does not expose a portable composition lifecycle on this mobile surface. Rejected: Fixed 150ms auto-flush for Hangul | can emit ㅎ or 하 if the user pauses mid-composition. Confidence: high Scope-risk: narrow Directive: Treat Hangul candidates as pending until submit/control/accessory flush; do not reintroduce idle timer commits for Hangul without device-level composition evidence. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; oxfmt --check changed mobile terminal/session files; TypeScript no-excuse checker for changed terminal files. Not-tested: Physical Galaxy Fold7 Samsung Keyboard manual QA and GitHub Actions jobs, blocked by unavailable device and upstream fork workflow approval.
|
@coderabbitai review |
✅ Action performedReview finished.
|
Honor the async live-input sender contract so the mobile UI reports dictation insertion only after terminal.send is accepted. Constraint: sendLiveTerminalInput now returns false for stale, disconnected, oversized, or rejected terminal sends. Rejected: Toasting immediately after dispatch | reports success for sends that never reached the PTY. Confidence: high Scope-risk: narrow Directive: Treat live-input UI success as terminal.send acceptance, not request dispatch. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; oxfmt --check app/h/[hostId]/session/[worktreeId].tsx. Not-tested: Physical Galaxy Fold7 Samsung Keyboard manual QA and GitHub Actions jobs, blocked by unavailable device and upstream fork workflow approval.
|
@coderabbitai review |
✅ Action performedReview finished.
|
Document why async IME flush paths re-check terminal/client refs before sending raw bytes or reporting live-send success. Constraint: CodeRabbit review requested short why comments for non-obvious stale-send safety gates. Rejected: Leaving the gates undocumented | future edits could remove the stale-target suppression contract. Confidence: high Scope-risk: narrow Directive: Keep async terminal sends guarded by current client, active handle, tab type, and connection state. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; pnpm --dir mobile exec oxfmt --check changed mobile files; terminal no-excuse checker Not-tested: Physical Galaxy Fold Samsung Keyboard manual QA is not available in this environment.
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
mobile/src/terminal/use-terminal-live-input-commit.test.ts (1)
1-54: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSwitch this harness to
@testing-library/react-native’srenderHook.renderToStringnever runsuseEffect, so the pending-commit cleanup path in this hook is currently untested.@testing-library/react-nativealready exists in the repo and provides the supported hook-testing API.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: cc32e24a-79d7-418d-aca2-b70df20440bf
📒 Files selected for processing (5)
mobile/src/terminal/terminal-live-accessory-raw-send-target.test.tsmobile/src/terminal/terminal-live-text-commit.test.tsmobile/src/terminal/terminal-live-text-commit.tsmobile/src/terminal/use-terminal-live-accessory-input-commit.tsmobile/src/terminal/use-terminal-live-input-commit.test.ts
💤 Files with no reviewable changes (1)
- mobile/src/terminal/terminal-live-accessory-raw-send-target.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- mobile/src/terminal/terminal-live-text-commit.test.ts
- mobile/src/terminal/use-terminal-live-accessory-input-commit.ts
- mobile/src/terminal/terminal-live-text-commit.ts
Move the Hangul live-input hook regression from server rendering to react-test-renderer so effect cleanup and unmount timer cancellation are exercised. Constraint: @testing-library/react-native imports React Native's Flow entry under this Vitest setup, so the narrow effect-running renderer is the compatible test surface. Rejected: Keeping renderToString | it never runs useEffect cleanup and missed the pending timer cleanup path. Rejected: Adding @testing-library/react-native directly | it failed before tests with React Native Flow syntax under the current Vitest transform. Confidence: high Scope-risk: narrow Directive: Hook-level IME tests must use a renderer that runs effects when asserting pending flush cleanup. Tested: vitest targeted terminal tests; pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; oxfmt --check changed mobile files; terminal no-excuse checker Not-tested: Physical Galaxy Fold Samsung Keyboard manual QA is not available in this environment.
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
mobile/src/terminal/use-terminal-live-input-commit.test.ts (1)
1-65: 🎯 Functional Correctness | 🔵 Trivial | ⚖️ Poor tradeoffAvoid
react-test-rendererhere React 19 emits a deprecation warning on everycreate()call, so this will add noisy test output and depend on an unmaintained package. If this hook really needs that renderer for its effect/timer behavior, suppress the warning locally; otherwise switch to a maintained RN testing utility.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: b7d0ba2f-d3d6-4fdb-a0d2-ed1b5273591b
⛔ Files ignored due to path filters (1)
mobile/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
mobile/package.jsonmobile/src/terminal/use-terminal-live-input-commit.test.ts
✅ Files skipped from review due to trivial changes (1)
- mobile/package.json
Suppress only the react-test-renderer deprecation warning around the effect-running hook harness so real console errors still surface. Constraint: CodeRabbit flagged React 19 renderer warning noise; @testing-library/react-native remains incompatible with the current Vitest/RN Flow transform path. Rejected: Global console silencing | it would hide unrelated test failures. Confidence: high Scope-risk: narrow Directive: Keep the renderer warning suppression scoped to this hook harness and pass all other console errors through. Tested: vitest targeted terminal tests; pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; oxfmt --check changed mobile files; terminal no-excuse checker Not-tested: Physical Galaxy Fold Samsung Keyboard manual QA is not available in this environment.
|
@coderabbitai review |
✅ Action performedReview finished.
|
AmethystLiang
left a comment
There was a problem hiding this comment.
Thanks, this is a good fix for the Android Korean IME regression.
I pushed a maintainer follow-up commit that:
- flushes pending mobile IME text before external terminal sends such as paste, dictation, and image attachment, so those sends cannot overtake composed input;
- adds explicit Chinese and Vietnamese regression coverage to confirm non-Hangul IME text keeps the bounded 150ms settle path instead of the Hangul-only indefinite defer;
- keeps ASCII input immediate and keeps the existing terminal.send RPC shape unchanged.
Validation passed locally:
- pnpm --dir mobile exec vitest run src/terminal/terminal-live-text-commit.test.ts src/terminal/use-terminal-live-input-commit.test.ts src/session/mobile-image-attachment.test.ts
- pnpm --dir mobile test
- pnpm --dir mobile lint
- pnpm --dir mobile exec tsc --noEmit
- pnpm --dir mobile format:check
- pnpm typecheck
- pnpm lint
- git diff --check
Residual caveat: I still did not physically validate Samsung Keyboard or iOS Korean/Chinese/Vietnamese IMEs in this environment, so CI plus unit/model coverage is the evidence here.
|
Update after CI: I merged current main into the PR branch because the PR workflow tests the merge ref, then fixed the resulting base-integration failure in the terminal command-finished event helper. The guard is limited to partial/non-DOM window shims and preserves real renderer dispatch behavior. Additional local validation after the merge:
|
#6995 turned out to be already fixed on main by #7011 (4f0a141) and #7273 (e8c2b79): a physical Samsung with Samsung Keyboard composes Hangul correctly on a build that does not contain the omission change. Shipping it anyway would surface the suggestion strip over the invisible live-input buffer to fix nothing. What stays is the #4606 half: the tri-state autocomplete preference, autocorrect defaulting on for the iOS command bar, and the props-derived Android remount key.
* Fix Korean IME composition by deferring live terminal preedit The mobile terminal capture field previously sent and cleared every TextInput change, which can break Hangul composition on Android keyboards. Introduce a small commit model and extracted live-input hook so composed text is flushed deliberately while ASCII remains immediate. Constraint: React Native TextInput has no portable composition event for this path; the fix uses a bounded commit delay for likely IME text. Rejected: Native-module IME integration | unnecessary for the confirmed JS dispatch/clear failure and higher maintenance risk. Confidence: high Scope-risk: moderate Directive: Keep terminal.send payload shape and buffered command input unchanged; do not claim physical Samsung Keyboard QA without device evidence. Tested: cd mobile && pnpm exec vitest run src/terminal/terminal-live-text-commit.test.ts src/terminal/terminal-live-input.test.ts src/terminal/terminal-text-input-normalization.test.ts src/terminal/terminal-keyboard-type.test.ts --reporter=verbose Tested: cd mobile && pnpm exec tsc --noEmit Tested: cd mobile && pnpm exec oxlint src/terminal/terminal-live-text-commit.ts src/terminal/terminal-live-text-commit.test.ts src/terminal/use-terminal-live-input-commit.ts app/h/[hostId]/session/[worktreeId].tsx Not-tested: Physical Galaxy Fold7/Samsung Keyboard and Android emulator/Gboard QA were unavailable; device probes recorded no attached Android device. * Preserve pending Korean IME text before mobile accessory controls Accessory keys share the same pending live-input commit gate as TextInput keypress and submit paths, so control bytes cannot race ahead of composed Hangul. Constraint: React Native mobile input does not expose portable composition events for Samsung/Gboard IME paths. Rejected: Let accessory buttons keep sending directly | Direct sends can drop pending Hangul before Tab/Esc/Enter/Backspace reaches the PTY. Confidence: high Scope-risk: narrow Directive: Keep all terminal control-byte paths behind the pending live-input flush/local-edit decision before sending to the PTY. Tested: pnpm --dir mobile test; pnpm --dir mobile lint; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile exec oxfmt --check src/terminal/terminal-live-text-commit.ts src/terminal/terminal-live-text-commit.test.ts src/terminal/use-terminal-live-input-commit.ts src/terminal/use-terminal-live-accessory-input-commit.ts app/h/[hostId]/session/[worktreeId].tsx; git diff --cached --check Not-tested: Physical Galaxy Fold7 Samsung keyboard manual QA is still external-device only. * Prevent stale IME timer flushes after mobile terminal teardown Pending live-input timers now clear on hook unmount, and accessory Delete documents why it stays local without trimming pending IME text. Constraint: React Native TextInput lacks a portable composition lifecycle, so pending IME text is guarded by a bounded timer that must not survive screen teardown. Rejected: Use clearPendingLiveInputCommit during unmount | it would also touch React state/native props during teardown when only timer/ref cleanup is required. Confidence: high Scope-risk: narrow Directive: Any delayed terminal input commit must have an owner-lifecycle cleanup path before sending to the PTY. Tested: pnpm --dir mobile test; pnpm --dir mobile lint; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile exec vitest run src/terminal/terminal-live-text-commit.test.ts --reporter=verbose; pnpm --dir mobile exec oxfmt --check src/terminal/terminal-live-text-commit.ts src/terminal/use-terminal-live-input-commit.ts; git diff --check Not-tested: Physical Galaxy Fold7 Samsung keyboard manual QA remains unavailable in this environment. * Use semantic accessory edits for mobile IME commits Accessory Backspace/Delete now carry semantic local-edit intent from built-in keys instead of inferring intent from raw bytes, and submit handling is reconnected to the pure submit-sequence model. Constraint: Custom terminal accessory keys may produce the same bytes as built-ins but should still flush pending IME text before sending rather than being silently treated as hidden-input edits. Rejected: Classify local accessory edits by raw bytes | That couples future custom controls to current built-in byte encodings. Confidence: high Scope-risk: narrow Directive: Keep semantic input intent separate from terminal byte payloads when pending IME text is present. Tested: pnpm --dir mobile test; pnpm --dir mobile lint; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile exec oxfmt --check src/terminal/terminal-live-text-commit.ts src/terminal/terminal-live-text-commit.test.ts src/terminal/use-terminal-live-input-commit.ts src/terminal/use-terminal-live-accessory-input-commit.ts app/h/[hostId]/session/[worktreeId].tsx; git diff --check Not-tested: Physical Galaxy Fold7 Samsung keyboard manual QA remains unavailable in this environment. * Respect IME flush failures before control input Propagate terminal.send success from pending Korean IME text before sending Enter, Tab, or accessory bytes, while keeping custom no-pending accessory bytes on the original direct path. Constraint: PR stablyai#7011 review required follow-up control bytes only after the pending composed text send actually succeeds. Rejected: Treating send invocation as success | It can still reject or no-op when RPC state changed. Confidence: high Scope-risk: narrow Directive: Keep pending IME flush paths async-success-aware before adding new terminal control inputs. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; pnpm --dir mobile exec oxfmt --check changed files; targeted no-excuse clean for mobile/src/terminal changed files. Not-tested: Physical Galaxy Fold7 Samsung keyboard; full session file no-excuse audit still reports pre-existing unrelated violations. * Serialize mobile IME flushes before live controls Treat terminal.send as successful only when the RPC response is ok and the runtime send result is accepted, then route all live-input control sends through a shared in-flight pending-flush barrier. Constraint: PR stablyai#7011 review found that resolved RPC promises and per-call sequencing were not enough to prove pending Hangul text reached the PTY before follow-up controls. Rejected: Only awaiting each flush-then-send call | Repeatable accessory keys and no-pending sends can arrive while the first flush is still in flight. Confidence: high Scope-risk: moderate Directive: Keep future mobile terminal control paths behind the pending-flush barrier whenever IME text may be in flight. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; pnpm --dir mobile exec oxfmt --check changed files; no-excuse clean for terminal changed files. Not-tested: Physical Galaxy Fold7 Samsung keyboard; full session file no-excuse audit still reports pre-existing unrelated violations. * Queue current IME snapshots behind active flushes Drain the pending snapshot captured by a control action after any already-active terminal send, and make accessory commit handling explicit so raw fallback is not encoded as an inverted boolean. Constraint: Architecture review found the previous single-slot barrier could wait for an older flush while skipping newly pending Hangul text. Rejected: Reusing the prior in-flight promise as the current flush result | It proves only an older snapshot, not the current pending buffer. Confidence: high Scope-risk: narrow Directive: New mobile terminal control paths must distinguish allow-raw, handled, and suppress-raw outcomes explicitly. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; pnpm --dir mobile exec oxfmt --check changed files; no-excuse clean for terminal changed files. Not-tested: Physical Galaxy Fold7 Samsung keyboard; full session file no-excuse audit still reports pre-existing unrelated violations. * Preserve accessory raw-send terminal targets Capture the terminal handle at accessory keypress time and suppress raw fallback if the active live terminal changes while waiting for pending IME flushes. Constraint: Independent review found raw accessory bytes could retarget to a different terminal after an async IME flush barrier. Rejected: Re-reading activeHandleRef as the send target after await | It can point at a different terminal than the keypress belonged to. Confidence: high Scope-risk: narrow Directive: Raw accessory fallback must use the keypress-time target and revalidate it after any await. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; pnpm --dir mobile exec oxfmt --check changed files; no-excuse clean for terminal changed files. Not-tested: Physical Galaxy Fold7 Samsung keyboard; full session file no-excuse audit still reports pre-existing unrelated violations. * Document accessory flush barrier intent Make the non-obvious raw accessory wait/suppress behavior explicit so future changes preserve IME-before-control ordering. Constraint: CodeRabbit requested a why-comment for the send-now accessory branch. Rejected: Leaving the barrier semantics implicit | The branch can otherwise look like unnecessary async defensive code. Confidence: high Scope-risk: narrow Directive: Keep comments focused on why raw accessory bytes wait behind IME flushes. Tested: targeted terminal vitest suite; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; oxfmt check for changed file. Not-tested: Physical Galaxy Fold7 Samsung keyboard. * Preserve buffered accessory raw sends Keep the stale-handle guard focused on the captured active terminal instead of live-input opt-in state, so buffered mode keeps existing accessory key behavior while async live-input waits still cannot retarget to another terminal. Constraint: Buffered command input behavior must remain unchanged while fixing mobile Korean IME live input ordering. Rejected: Requiring live-input enabled handles for raw accessory fallback | suppresses valid buffered-mode accessory sends. Confidence: high Scope-risk: narrow Directive: Do not use live-input opt-in state as terminal liveness for raw accessory sends; validate captured target, active terminal tab, connection, and client instead. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; oxfmt --check changed mobile terminal/session files; TypeScript no-excuse checker for changed terminal files. Not-tested: Physical Galaxy Fold7 Samsung Keyboard manual QA and GitHub Actions jobs, blocked by unavailable device and upstream fork workflow approval. * Keep Hangul IME text pending until explicit flush Avoid timer-driven PTY writes for Hangul candidates so paused Korean composition cannot leak intermediate jamo, while preserving the bounded settle timer for non-Hangul IME text. Also keep disabled live-input accessory fallback behind any existing pending flush barrier. Constraint: React Native TextInput does not expose a portable composition lifecycle on this mobile surface. Rejected: Fixed 150ms auto-flush for Hangul | can emit ㅎ or 하 if the user pauses mid-composition. Confidence: high Scope-risk: narrow Directive: Treat Hangul candidates as pending until submit/control/accessory flush; do not reintroduce idle timer commits for Hangul without device-level composition evidence. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; oxfmt --check changed mobile terminal/session files; TypeScript no-excuse checker for changed terminal files. Not-tested: Physical Galaxy Fold7 Samsung Keyboard manual QA and GitHub Actions jobs, blocked by unavailable device and upstream fork workflow approval. * Gate dictation toast on accepted live send Honor the async live-input sender contract so the mobile UI reports dictation insertion only after terminal.send is accepted. Constraint: sendLiveTerminalInput now returns false for stale, disconnected, oversized, or rejected terminal sends. Rejected: Toasting immediately after dispatch | reports success for sends that never reached the PTY. Confidence: high Scope-risk: narrow Directive: Treat live-input UI success as terminal.send acceptance, not request dispatch. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; oxfmt --check app/h/[hostId]/session/[worktreeId].tsx. Not-tested: Physical Galaxy Fold7 Samsung Keyboard manual QA and GitHub Actions jobs, blocked by unavailable device and upstream fork workflow approval. * Keep accessory edits on Hangul pending path Make accessory local edits reuse the Hangul-aware defer policy so built-in Backspace/Delete cannot reintroduce timer-driven Hangul PTY writes. Constraint: Hangul IME candidates must remain pending until explicit submit/control/accessory flush. Rejected: Reusing the non-Hangul 150ms settle timer for accessory local edits | can leak pending Hangul after Backspace/Delete. Confidence: high Scope-risk: narrow Directive: Any future pending-text reschedule must use getTerminalLiveDeferredTextDelayMs instead of a hardcoded timer. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; oxfmt --check changed mobile terminal/session files; TypeScript no-excuse checker for changed terminal files. Not-tested: Physical Galaxy Fold7 Samsung Keyboard manual QA and GitHub Actions jobs, blocked by unavailable device and upstream fork workflow approval. * Prove Hangul live-input hook ordering Add a direct hook-level regression so Android Korean IME fixes are covered at the orchestration boundary, not only by lower-level helpers. Constraint: React Native mobile TextInput lacks portable composition lifecycle events in this path. Rejected: Relying only on helper tests | misses hook-level pending flush and submit ordering. Confidence: high Scope-risk: narrow Directive: Keep Hangul candidates pending until an explicit terminal action flushes them. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; oxfmt --check changed mobile files; no-excuse on terminal modules Not-tested: Physical Galaxy Fold Samsung Keyboard manual QA is not available in this environment. * Keep accessory raw-send tests precise Remove a duplicate raw-target assertion whose title implied disabled live-input behavior that is covered at the accessory commit boundary instead. Constraint: Anti-slop cleanup must preserve existing Hangul/accessory behavior and stay within changed terminal tests. Rejected: Keeping the duplicate disabled-input wording | it tests the same active-terminal predicate as the preceding case. Confidence: high Scope-risk: narrow Directive: Test disabled live-input buffering in the accessory commit layer, not in the raw-target predicate helper. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; pnpm --dir mobile exec oxfmt --check changed mobile files; terminal no-excuse checker Not-tested: Physical Galaxy Fold Samsung Keyboard manual QA is not available in this environment. * Explain stale mobile terminal send gates Document why async IME flush paths re-check terminal/client refs before sending raw bytes or reporting live-send success. Constraint: CodeRabbit review requested short why comments for non-obvious stale-send safety gates. Rejected: Leaving the gates undocumented | future edits could remove the stale-target suppression contract. Confidence: high Scope-risk: narrow Directive: Keep async terminal sends guarded by current client, active handle, tab type, and connection state. Tested: pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; pnpm --dir mobile exec oxfmt --check changed mobile files; terminal no-excuse checker Not-tested: Physical Galaxy Fold Samsung Keyboard manual QA is not available in this environment. * Run mobile IME hook tests through effects Move the Hangul live-input hook regression from server rendering to react-test-renderer so effect cleanup and unmount timer cancellation are exercised. Constraint: @testing-library/react-native imports React Native's Flow entry under this Vitest setup, so the narrow effect-running renderer is the compatible test surface. Rejected: Keeping renderToString | it never runs useEffect cleanup and missed the pending timer cleanup path. Rejected: Adding @testing-library/react-native directly | it failed before tests with React Native Flow syntax under the current Vitest transform. Confidence: high Scope-risk: narrow Directive: Hook-level IME tests must use a renderer that runs effects when asserting pending flush cleanup. Tested: vitest targeted terminal tests; pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; oxfmt --check changed mobile files; terminal no-excuse checker Not-tested: Physical Galaxy Fold Samsung Keyboard manual QA is not available in this environment. * Keep hook lifecycle tests quiet Suppress only the react-test-renderer deprecation warning around the effect-running hook harness so real console errors still surface. Constraint: CodeRabbit flagged React 19 renderer warning noise; @testing-library/react-native remains incompatible with the current Vitest/RN Flow transform path. Rejected: Global console silencing | it would hide unrelated test failures. Confidence: high Scope-risk: narrow Directive: Keep the renderer warning suppression scoped to this hook harness and pass all other console errors through. Tested: vitest targeted terminal tests; pnpm --dir mobile test; pnpm --dir mobile exec tsc --noEmit; pnpm --dir mobile lint; oxfmt --check changed mobile files; terminal no-excuse checker Not-tested: Physical Galaxy Fold Samsung Keyboard manual QA is not available in this environment. * fix: flush pending mobile IME input before external sends * fix: guard terminal command finished event dispatch --------- Co-authored-by: Jinjing <[email protected]>
Summary
Closes #7000
Screenshots
Testing
pnpm lint— root command not run; mobile-scopedpnpm --dir mobile lintpassed for this mobile-only PR.pnpm typecheck— root command not run; mobile-scopedpnpm --dir mobile exec tsc --noEmitpassed.pnpm test— mobile-scopedpnpm --dir mobile testpassed: 158 files, 1049 passed, 2 skipped.pnpm build— not run; mobile build requires platform build credentials/devices not available in this environment.한글, accessory local edit vs raw custom bytes, strictterminal.sendacceptance, and queued pending-flush ordering while a prior flush is in flight.Additional verification
pnpm --dir mobile exec oxfmt --checkpassed on changed mobile TypeScript files (the command reported all matched files formatted correctly).mobile/src/terminal/*files, including the new hook-level Hangul regression test. The large session route still has pre-existing unrelated no-excuse findings outside this diff; no new no-excuse findings were introduced in the touched hunks.PR ChecksandMobile Checksfor latest heada52c661are blocked inaction_requiredbecause fork workflow approval requires upstream repository admin rights; no jobs ran.AI Review Report
terminal.send, repeated accessory input while a previous flush is in flight, custom accessory raw-byte behavior, stale active handles after awaits, timer cleanup on unmount, and SSH/remote terminal behavior.한글) is covered by tests.terminal.send.terminal.sendRPC boundary.terminal.sendare unchanged; the fix only gates and orders mobile client sends before they reach the existing local/SSH runtime boundary.Security Audit
terminal.sendRPC method and payload shape are unchanged; the mobile client now additionally checksresponse.okandsend.accepted === truebefore sending follow-up control bytes.isTerminalLiveInputWithinByteLimitbefore live terminal sends.Notes
c78467freported no actionable comments; a fresh review is being requested for heada52c661after locally suppressing only the react-test-renderer deprecation warning while keeping the effect-running hook harness and unmount cleanup coverage.action_required) before GitHub Actions jobs can run.