Skip to content

Fix mobile terminal Korean IME composition on Android - #7011

Merged
AmethystLiang merged 21 commits into
stablyai:mainfrom
realitsyourman:fix/korean-ime-mobile-terminal
Jul 2, 2026
Merged

AmethystLiang merged 21 commits into
stablyai:mainfrom
realitsyourman:fix/korean-ime-mobile-terminal

Conversation

@realitsyourman

@realitsyourman realitsyourman commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Fix mobile terminal live input so Korean/Hangul IME preedit values are deferred instead of sent as split jamo.
  • Add a pure terminal live text commit model plus regression tests for Hangul, ASCII, submit, Backspace/Delete, accessory keys, pending flush ordering, and terminal.send acceptance.
  • Extract live-input commit orchestration from the large session route so timer cleanup, stale-handle guards, RPC acceptance, and in-flight flush sequencing are explicit.

Closes #7000

Screenshots

  • No visual change; terminal input behavior only.

Testing

  • pnpm lint — root command not run; mobile-scoped pnpm --dir mobile lint passed for this mobile-only PR.
  • pnpm typecheck — root command not run; mobile-scoped pnpm --dir mobile exec tsc --noEmit passed.
  • pnpm test — mobile-scoped pnpm --dir mobile test passed: 158 files, 1049 passed, 2 skipped.
  • pnpm build — not run; mobile build requires platform build credentials/devices not available in this environment.
  • Added or updated high-quality tests that would catch regressions: Hangul composition, multi-syllable 한글, accessory local edit vs raw custom bytes, strict terminal.send acceptance, and queued pending-flush ordering while a prior flush is in flight.

Additional verification

  • pnpm --dir mobile exec oxfmt --check passed on changed mobile TypeScript files (the command reported all matched files formatted correctly).
  • TypeScript no-excuse checker passed for all 17 changed 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.
  • GitHub Actions PR Checks and Mobile Checks for latest head a52c661 are blocked in action_required because fork workflow approval requires upstream repository admin rights; no jobs ran.

AI Review Report

  • Reviewed the IME fix across terminal decision helpers, pending flush state, React Native hooks, and the mobile session RPC boundary.
  • Main risks checked: Hangul jamo separation, flushing before Enter/Tab/accessory controls, failed/stale 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.
  • Findings addressed during review:
    • Accessory keys now route through the pending IME commit path.
    • Multi-syllable Hangul (한글) is covered by tests.
    • Follow-up controls are sent only after the pending IME text is accepted by terminal.send.
    • Pending flush timers are cleaned up on unmount.
    • Built-in Backspace/Delete use semantic local edits; custom keys with the same bytes keep raw terminal behavior.
    • In-flight pending flushes now queue newer pending snapshots before control bytes can proceed.
  • Cross-platform compatibility was explicitly reviewed for macOS, Linux, and Windows: this PR does not change desktop shortcuts, shortcut labels, file paths, shell behavior, Electron menu accelerators, or platform-specific desktop code. The touched surface is Android/mobile live terminal input and the existing provider-neutral terminal.send RPC boundary.
  • SSH/remote/local compatibility: the payload shape and runtime method for terminal.send are unchanged; the fix only gates and orders mobile client sends before they reach the existing local/SSH runtime boundary.
  • Supported agents/integrations/git providers: no agent launch, source-control, GitHub/GitLab provider, or review-provider behavior changed.
  • Performance: ASCII input remains immediate. Hangul candidates stay pending until explicit submit/control/accessory flush so paused composition cannot leak jamo; non-Hangul IME text keeps the bounded settle timer and promise barrier for ordering.
  • UI quality: no layout/color/typography changes; behavior remains in the terminal live-input field and accessory bar.

Security Audit

  • No new dependency, native module, credential handling, network endpoint, auth/authz surface, command execution path, file path handling, or IPC method.
  • terminal.send RPC method and payload shape are unchanged; the mobile client now additionally checks response.ok and send.accepted === true before sending follow-up control bytes.
  • Input-size guard remains in place through isTerminalLiveInputWithinByteLimit before live terminal sends.
  • No secrets or tokens were added.

Notes

  • Physical Galaxy Fold7/Samsung Keyboard manual QA remains unavailable in this environment; automated model/unit/mobile test coverage is recorded above.
  • CodeRabbit latest incremental review on head c78467f reported no actionable comments; a fresh review is being requested for head a52c661 after locally suppressing only the react-test-renderer deprecation warning while keeping the effect-running hook harness and unmount cleanup coverage.
  • Upstream fork PR checks require repository-admin approval (action_required) before GitHub Actions jobs can run.
  • X handle: not provided.

Open in Stage

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

ghost commented Jul 1, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 7 individual chapters for you:

Title
1 Add test dependencies
2 Define core terminal input types and utilities
3 Implement IME composition and commit logic
4 Manage pending flush state and ordering
5 Create hooks for terminal input orchestration
6 Integrate commit logic into session route
7 Other changes
Open in Stage

Chapters generated by Stage for commit a52c661 on Jul 1, 2026 5:28pm UTC.

@coderabbitai

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

Changes

This 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.
Related PRs: None identified.
Suggested labels: mobile, terminal, refactor
Suggested reviewers: None identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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
Title check ✅ Passed The title accurately summarizes the main change: fixing Korean IME composition behavior in the mobile terminal on Android.
Description check ✅ Passed The description follows the template well, covering summary, screenshots, testing, AI review, security audit, and notes.
Linked Issues check ✅ Passed The changes address #7000 by deferring Hangul IME composition, preserving ASCII immediacy, flushing before submit, and covering regressions.
Out of Scope Changes check ✅ Passed The added hooks, tests, and dependency updates all support the terminal IME fix and do not appear unrelated to the stated scope.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

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

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

Document 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 150 as 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 = 150

As 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

📥 Commits

Reviewing files that changed from the base of the PR and between 16a14ec and a4dc4d5.

📒 Files selected for processing (4)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/src/terminal/terminal-live-text-commit.test.ts
  • mobile/src/terminal/terminal-live-text-commit.ts
  • mobile/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.

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

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 win

Cancel 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 win

Document why accessory Delete leaves pendingText unchanged.

Because '\x1b[3~' is treated as local-edit above but falls through to return pendingText here, 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

📥 Commits

Reviewing files that changed from the base of the PR and between a4dc4d5 and da9face.

📒 Files selected for processing (5)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/src/terminal/terminal-live-text-commit.test.ts
  • mobile/src/terminal/terminal-live-text-commit.ts
  • mobile/src/terminal/use-terminal-live-accessory-input-commit.ts
  • mobile/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.

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

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 win

Keep pending IME state visible until the async flush settles.

flushPendingLiveInputText() clears pendingLiveInputHandleRef / pendingLiveInputTextRef before 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

📥 Commits

Reviewing files that changed from the base of the PR and between ae22ba3 and da54d7a.

📒 Files selected for processing (7)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/src/terminal/terminal-live-control-send-order.test.ts
  • mobile/src/terminal/terminal-live-control-send-order.ts
  • mobile/src/terminal/terminal-live-text-commit.test.ts
  • mobile/src/terminal/terminal-live-text-commit.ts
  • mobile/src/terminal/use-terminal-live-accessory-input-commit.ts
  • mobile/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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 89906f62-0f4a-4ed3-981d-67c3b7011a43

📥 Commits

Reviewing files that changed from the base of the PR and between da54d7a and ba9cf61.

📒 Files selected for processing (10)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • 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/terminal-live-pending-flush-state.ts
  • mobile/src/terminal/terminal-send-rpc-response.test.ts
  • mobile/src/terminal/terminal-send-rpc-response.ts
  • mobile/src/terminal/use-terminal-live-accessory-input-commit.ts
  • mobile/src/terminal/use-terminal-live-input-commit.ts
  • mobile/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.
@realitsyourman

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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-accessory-input-commit.ts (1)

67-71: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider 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 a suppress-raw result 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

📥 Commits

Reviewing files that changed from the base of the PR and between da54d7a and a9d11e8.

📒 Files selected for processing (10)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • 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/terminal-live-pending-flush-state.ts
  • mobile/src/terminal/terminal-send-rpc-response.test.ts
  • mobile/src/terminal/terminal-send-rpc-response.ts
  • mobile/src/terminal/use-terminal-live-accessory-input-commit.ts
  • mobile/src/terminal/use-terminal-live-input-commit.ts
  • mobile/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.
@realitsyourman

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

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 win

Don'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 when sendLiveTerminalInput returns false because 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6a3839f and 9ec00c1.

📒 Files selected for processing (3)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/src/terminal/terminal-live-accessory-raw-send-target.test.ts
  • mobile/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.
@realitsyourman

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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.test.ts (1)

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

Switch this harness to @testing-library/react-native’s renderHook. renderToString never runs useEffect, so the pending-commit cleanup path in this hook is currently untested. @testing-library/react-native already 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

📥 Commits

Reviewing files that changed from the base of the PR and between ab190a8 and 2702e15.

📒 Files selected for processing (5)
  • mobile/src/terminal/terminal-live-accessory-raw-send-target.test.ts
  • mobile/src/terminal/terminal-live-text-commit.test.ts
  • mobile/src/terminal/terminal-live-text-commit.ts
  • mobile/src/terminal/use-terminal-live-accessory-input-commit.ts
  • mobile/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.
@realitsyourman

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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.test.ts (1)

1-65: 🎯 Functional Correctness | 🔵 Trivial | ⚖️ Poor tradeoff

Avoid react-test-renderer here React 19 emits a deprecation warning on every create() 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

📥 Commits

Reviewing files that changed from the base of the PR and between 33ca4c1 and e8379b7.

⛔ Files ignored due to path filters (1)
  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • mobile/package.json
  • mobile/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.
@realitsyourman

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@AmethystLiang
AmethystLiang requested review from AmethystLiang and removed request for Jinwoo-H July 2, 2026 05:08

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

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.

@AmethystLiang

Copy link
Copy Markdown
Contributor

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:

  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • pnpm --dir mobile exec vitest run src/terminal/terminal-webview-tap-routing.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

@AmethystLiang
AmethystLiang merged commit 4f0a141 into stablyai:main Jul 2, 2026
2 checks passed
brennanb2025 added a commit that referenced this pull request Jul 30, 2026
#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.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Mobile terminal Korean IME input sends decomposed jamo on Android

3 participants