Repository navigation
feat(mobile): default the iOS terminal command bar to autocorrect - #11290
brennanb2025 wants to merge 5 commits into
Conversation
…nd bar
RN maps autoCorrect={false} onto Android's NO_SUGGESTIONS inputType, and
Samsung Keyboard answers that flag by disabling IME composition outright —
Hangul then arrives as raw jamo (#6995). Omitting the prop is the only lever
that clears the flag without asking for autocorrect, so the new pure module
omits it rather than setting false. spellCheck is iOS-only in RN and now stays
off the Android path entirely.
The stored autocomplete preference becomes tri-state so unset stays
distinguishable from an explicit off: unset resolves to autocorrect ON for iOS
non-direct command entry (#4606), while direct/live entry stays raw on every
platform and an explicit Settings choice still wins everywhere.
📝 WalkthroughWalkthroughTerminal autocomplete now uses a tri-state preference of 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
Greptile SummaryThis PR introduces a tri-state autocomplete preference (
Confidence Score: 4/5Safe to merge for the iOS autocorrect fix; the Android IME composition fix for the default unset state is not in the code. The tri-state migration and iOS default are implemented correctly. However, getTerminalImeInputProps('android', 'unset') returns { autoCorrect: false } — the same value as 'off' — making the two states byte-identical on Android. Spreading this still passes autoCorrect={false} to the TextInput, which maps to Kotlin false → TYPE_TEXT_FLAG_NO_SUGGESTIONS, the exact flag that kills Samsung Keyboard composition. The TerminalImeInputProps type does not allow autoCorrect to be optional, so there is no code path that omits the prop. The stated Android fix is absent from the implementation. Files Needing Attention: mobile/src/terminal/terminal-ime-input-props.ts — the return type and logic of getTerminalImeInputProps need to support omitting autoCorrect (e.g., autoCorrect?: boolean) for the android/unset case, and the matching test expectations need updating.
|
| Filename | Overview |
|---|---|
| mobile/src/terminal/terminal-ime-input-props.ts | New pure module owning Android/iOS IME prop decisions, but getTerminalImeInputProps('android','unset') returns { autoCorrect: false } — identical to pre-PR behavior and to 'off', so the core Android fix is missing |
| mobile/src/terminal/terminal-ime-input-props.test.ts | Comprehensive unit tests and intentional source-inspection wiring guards; the 'defaults the iOS command bar' test asserts autoCorrect:false for android/unset, confirming the implementation gap is present in the test expectations too |
| mobile/src/storage/preferences.ts | Tri-state migration is clean: null/error maps to 'unset', 'true'→'on', 'false'→'off'; no previously-persisted boolean is misread |
| mobile/src/storage/preferences.test.ts | Tests updated to match tri-state load semantics; round-trip is correct |
| mobile/app/h/[hostId]/session/[worktreeId].tsx | Call sites updated to spread getTerminalImeInputProps and use getTerminalImeRemountKey; live input correctly stays hardcoded raw on all platforms |
| mobile/app/terminal-settings.tsx | Settings switch initializes and refreshes through isTerminalAutocorrectEnabled; description text derives the On/Off default dynamically; iOS/Android show correct defaults |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["User preference stored\n(AsyncStorage)"] -->|"loadTerminalAutocompletePreference()"| B["parseTerminalAutocompletePreference()"]
B -->|"'true'"| C["'on'"]
B -->|"'false'"| D["'off'"]
B -->|"null / error / other"| E["'unset'"]
C --> F["isTerminalAutocorrectEnabled(platform, pref)"]
D --> F
E --> F
F -->|"pref === 'on'"| G["true"]
F -->|"pref === 'off'"| H["false"]
F -->|"pref === 'unset' AND platform === 'ios'"| G
F -->|"pref === 'unset' AND platform ≠ 'ios'"| H
G --> I["getTerminalImeInputProps()"]
H --> I
I -->|"enabled=true"| J["autoCorrect: true\nspellCheck: true"]
I -->|"enabled=false ⚠️"| K["autoCorrect: false\nspellCheck: false"]
K --> L["Spread on Android TextInput"]
L --> M["Kotlin: false → TYPE_TEXT_FLAG_NO_SUGGESTIONS"]
M --> N["IME composition KILLED ⚠️\n(same as pre-PR for Android/unset)"]
J --> O["Kotlin: true → TYPE_TEXT_FLAG_AUTO_CORRECT\niOS autocorrect enabled ✅"]
style N fill:#f66,color:#fff
style O fill:#6a6,color:#fff
style K fill:#fa0,color:#000
Reviews (4): Last reviewed commit: "fix(mobile): narrow to #4606 — drop the ..." | Re-trigger Greptile
Review follow-up on the IME input props.
- Removed an assertion that compared getTerminalImeInputProps' output against
isTerminalAutocorrectEnabled, which the implementation calls internally — it
reduced to `enabled === enabled` and could not fail. The literal expected
objects already cover the mapping.
- The `autoCorrect={false}` guard was file-scoped on a 5387-line route with
non-terminal inputs of its own, so the next unrelated field would have failed
it with a misleading message. Both guards are now scoped to the two terminal
elements via anchored slices, and a missing anchor fails loudly instead of
slicing to EOF and passing vacuously.
- Dropped two negative guards that could never fire: one named an identifier
that no longer exists, the other asserted the exact formatting of a deleted
line.
Settings copy no longer hardcodes the per-platform default that the input
resolves through, and it stops claiming direct input is immune to suggestions —
on Android, clearing NO_SUGGESTIONS is what lets the strip reappear.
What this isAndroid's Verified in the installed RN 0.83.9 ( The tri-state preference is what unblocks #4606: collapsing to a boolean at read time made "never touched it" indistinguishable from "explicitly turned it off," so there was nowhere to hang a per-platform default. Reviewing thisTwo things worth your attention over the diff itself:
Tests are mutation-checked rather than just added: reverting each source file breaks the suite, and seven targeted mutations (including re-hardcoding Also relevant: #7495 (Chinese IME) plausibly shares this surface, since Pinyin composition depends on the same flag — but it's unconfirmed and deliberately left open rather than claimed. #7094 is explicitly not this surface; nothing here should change it. |
…gain Omitting autoCorrect fixes #6995, but it left 'off' and 'unset' emitting byte-identical props on Android — so the Settings switch's Off position did nothing and there was no way back to suppression. An explicit Off now emits autoCorrect={false} and gets NO_SUGGESTIONS back. That costs IME composition, which is precisely what the user asked for, and it is reversible; leaving the preference untouched still gets the #6995 fix. Scoped to the command bar. #6995 was reported on the live/direct path, and the settings copy never claimed the toggle governs direct entry, so live keeps composing on every preference. This exposed a latent bug in the remount key. Android caches IME inputType at mount, and the key tracked the resolved boolean — which cannot distinguish {} from {autoCorrect:false}, so an unset -> off transition would have kept the key and the user's Off would never have reached the IME. getTerminalImeRemountKey now derives the key from the emitted props, with a test asserting the key changes exactly when the props do.
Greptile flagged these as brittle. They are, on purpose: the module is pure and fully unit-tested, but nothing else proves the route still calls it, and rendering a 5k-line screen behind navigation, RPC and native deps is not a viable alternative. Says so inline, along with the known gap, so the next reader re-pins them instead of extracting variables to make them pass.
|
Updated after review. Three design questions I'd flagged have been decided rather than left open, and the description now follows the repo template (CodeRabbit's other check — docstring coverage — I'm declining: AGENTS.md asks for concise, non-obvious comments only, so adding docstrings to satisfy an 80% threshold would work against the house style). 1. The omission stays on both paths, live and command. #6995 was reported on the live terminal path, so gating it to 2. An explicit Off now emits This turned up a latent bug worth calling out: the Android remount key tracked the resolved boolean, which can't distinguish 3. #4606 ships globally, with a caveat. I read the issue rather than assuming: it asks for "auto correct on the keyboard for non direct entry" on iPhone, with no tab-type distinction, and a maintainer's follow-up asking whether it meant on-by-default went unanswered. So it's global for the command bar. The caveat is in Notes — that same bar sends raw shell commands in a terminal tab, and Now 19 tests, all mutation-checked — including mutants for each new decision (Off reverting to a no-op, Off leaking onto the live path, the remount key regressing to a boolean). Still not device-confirmed that this restores Samsung Keyboard composition; that needs physical hardware. |
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/terminal-settings.tsx (1)
337-342: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAvoid asserting universal Android IME breakage.
Line 341 says turning autocomplete off “also stops Korean and Chinese composing,” which is too broad unless Samsung-device and Korean/Chinese IME behavior is verified across keyboards. Use conditional wording such as “may affect composition on some keyboards” until this behavior is verified.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9a894e94-29e3-42e3-ae12-28f4f55c7c65
📒 Files selected for processing (4)
mobile/app/h/[hostId]/session/[worktreeId].tsxmobile/app/terminal-settings.tsxmobile/src/terminal/terminal-ime-input-props.test.tsmobile/src/terminal/terminal-ime-input-props.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- mobile/src/terminal/terminal-ime-input-props.test.ts
- mobile/app/h/[hostId]/session/[worktreeId].tsx
#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.
|
Narrowed in e2cbcb5: the Android @coderabbitai The outside-diff finding on |
|
Tip For best results, initiate chat on the files or code changes.
✏️ Learnings added
If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! This chat is LLM-generated and may be inaccurate. |
|
Closing this after device validation and product review. The implementation works—the iOS A/B showed QuickType and autocorrection correctly—but we don't want autocorrection enabled by default in a terminal command field. It can silently rewrite flags, paths, identifiers, and shell syntax. The current app already has the safer behavior: terminal autocorrection stays off by default, with an explicit opt-in under Settings → Terminal → Autocomplete & autocorrect. Direct terminal input remains raw. For people who primarily use Orca Mobile to chat with agents, the better fit is Settings → Chat UI → Open sessions in Chat UI. Supported agent sessions then open in the native chat interface, which uses normal phone text-entry behavior. An individual supported session can also be switched from its long-press menu. Thanks for the careful implementation and validation—closing because of the default-policy decision, not because the change failed technically. |
Fixes #4606
Summary
On iPhone, the terminal command bar now enables autocorrect by default. #4606 asked for phone-style autocorrect for non-direct entry — the buffered command bar where text is reviewed before send. Direct/live entry (keys streaming straight to the PTY) stays raw on every platform, and an explicit Settings choice wins everywhere.
What changed
'on' | 'off' | 'unset'). Collapsing to a boolean at read time made "never touched it" indistinguishable from "explicitly turned it off" — but the default is now per-platform, sounsethas to survive to the resolution point. An explicit choice still overrides the default in both directions.unsetresolves to autocorrect on for the iOS command bar and off everywhere else (Android and desktop keep the old raw-keystrokes default). A new pure modulemobile/src/terminal/terminal-ime-input-props.tsowns the decision; the command input spreads its result.inputTypeat mount, so the input must remount when its IME props change. Deriving the key from the same props the input receives (instead of a separately-maintained boolean) makes key-vs-props drift structurally impossible.What the user sees before and after
Before
The iPhone buffered command bar defaults to autocorrect and spelling suggestions being off, even though it behaves like a normal text-entry field.
After
The buffered command bar uses iPhone-style autocorrect, autocomplete, and spelling suggestions by default. Direct terminal input remains raw, and the user's explicit setting overrides the default without requiring a restart.
Screenshots
Exact-head iOS simulator A/B at
e2cbcb56da7289fda9e1e15e63570d062499fae8, using the same paired device, host, terminal, and client rig. Only the Metro-served client bundle changed.Before and after — default behavior
The parent command bar has no QuickType prediction strip. At the PR head, the strip appears by default.
Autocorrection works
Typing “teh” offers “the”; pressing space autocorrects the buffered command to “the ” before it is sent.
Explicit Off applies without restart
Turning the preference Off removes the prediction strip when returning to the same command bar without relaunching the app.
Full rig details, attribution, and caveats are recorded in
qa-device-lane-b/.qa-artifacts/QA-REPORT-LANE-B.mdItem 3.Testing
pnpm lint— clean (mobile oxlint + react-doctor oxlint, via the suite and the pre-commit hooks)pnpm typecheck— cleanpnpm test— 354 files / 2610 passed + 2 skipped, 0 failurespnpm format:check— cleanpnpm build— not run locally; this is mobile-only and touches no packaged desktop codeSuite vs. its own measured parent (
adc10cd21a, re-measured in the same checkout): 354 files / 2610 passed vs 353 / 2597 — +1 file, +13 tests.Non-vacuity was proven by revert, not assumed — restoring each changed source file to its merge-base version breaks the suite:
terminal-ime-input-props.ts(deleted)session/[worktreeId].tsxterminal-settings.tsxstorage/preferences.tsThe source-text wiring guards are anchored slices scoped to the two terminal elements; a rotted anchor fails loudly (
start anchor not found: …) rather than slicing to EOF and passing vacuously.AI Review Report
Brennan's same-model/same-reasoning review loop completed a fresh full pass against exact head
e2cbcb56da7289fda9e1e15e63570d062499fae8. It found no meaningful issues, so no source change or push was needed and the exact-head simulator evidence remains current.The pass covered tri-state migration and persistence, platform defaults, settings/input resolver agreement, Android remount behavior, direct-input raw-keystroke preservation, test non-vacuity, SSH and folder-workspace behavior, and scope. Mobile tests (354 files / 2610 passed / 2 skipped), typecheck, lint, format, and GitHub checks are green.
Security Audit
Low risk; no auth, secrets, IPC, dependency, or command-execution surface is touched. No new dependency, no network call, no filesystem access, no shell invocation.
autoCorrect={false}/spellCheck={false}, and a wiring guard now pins that (the settings copy promises direct input always sends raw keystrokes). Autocorrect applies only to the buffered command bar, where text is reviewed before it reaches the PTY.AsyncStoragedevice preference, never transmitted. Parsing is a closed allowlist ('true'/'false', everything else →unset), so a corrupted or attacker-written value degrades to the default rather than an arbitrary state.Notes
mainby Fix mobile terminal Korean IME composition on Android #7011 and Fix mobile live input keyboard and Korean IME #7273 (the live-text-commit / Hangul-mirror machinery), confirmed on a physical Samsung device running a build without the omission change. TheautoCorrect-omission theory was source-correct about RN's flag mapping but did not survive device testing as a needed fix.normalizeTerminalTextInputcurrently repairs only en/em dashes — smart quotes and autocorrected words are not repaired. If that proves noisy, the narrower fix is to extend normalization rather than revert the default.unset/offemitautoCorrect={false}exactly as before this PR, andonemitsautoCorrect={true}as before.