Skip to content

feat(mobile): add terminal keyboard autocomplete toggle - #5348

Merged
Jinwoo-H merged 7 commits into
stablyai:mainfrom
gsxdsm:feat/mobile-terminal-autocomplete
Jun 15, 2026
Merged

Jinwoo-H merged 7 commits into
stablyai:mainfrom
gsxdsm:feat/mobile-terminal-autocomplete

Conversation

@gsxdsm

@gsxdsm gsxdsm commented Jun 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a Settings → Terminal → "Autocomplete & autocorrect" toggle that lets users opt into phone-style keyboard autocomplete/autocorrect for the terminal command bar.

The terminal command input deliberately disables autoCorrect/spellCheck and uses a password-class keyboard (visible-password on Android, ascii-capable on iOS) so the OS never rewrites commands, flags, or paths. That's the right default, but some users want normal phone typing with suggestions — this makes it a per-device preference (orca:terminalAutocompleteEnabled, default off) instead of hardcoded behavior.

  • When on, the command bar enables autoCorrect/spellCheck and switches to the default keyboard (Android suggestion strip appears; iOS drops the ascii-capable restriction). On Android the TextInput is remounted on toggle because the IME inputType is cached at mount.
  • The session screen reloads the pref on focus, so toggling in Settings takes effect on return.
  • The direct keyboard-capture input (keystrokes streamed straight to the PTY) is intentionally left raw — suggestions can't apply to a per-keystroke stream — and the settings copy says so.

Screenshots

Visual change is limited to: (1) a new "Autocomplete & autocorrect" Switch row under a "KEYBOARD INPUT" group in Terminal settings, and (2) when enabled, the OS suggestion strip over the terminal command bar. No other UI changes. Verified visually on an Android device (see Testing).

Testing

  • pnpm lint (oxlint clean in mobile/)
  • pnpm typecheck (tsc --noEmit clean in mobile/)
  • pnpm test (vitest suite passes in mobile/)
  • pnpm build (release APK built)
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed — no unit test added: the change is a UI preference wired to TextInput props/AsyncStorage; behavior was verified on-device. The storage helpers are thin AsyncStorage get/set.

On-device (Android): toggle off → no suggestions (unchanged); toggle on → suggestion strip appears in the command bar; direct-capture input stays raw either way.

AI Review Report

Reviewed with Claude Code. Main risks checked:

  • Async hydration race (flagged by CodeRabbit): the initial loadTerminalAutocompleteEnabled() could clobber a fast user toggle. Fixed in b6dc2bf with a userToggledAutocompleteRef guard plus a stale flag, and the session focus-effect now guards setState with an active flag so it can't fire after unfocus/unmount.
  • Cross-platform: this is a mobile-only (Expo/React Native) change; no Electron/desktop, shell, or filesystem-path code is touched, so macOS/Linux/Windows desktop behavior is unaffected. The only platform branch is keyboardType (ascii-capable on iOS, visible-password on Android, default when enabled), gated on Platform.OS.

Security Audit

Low risk. The change persists a single boolean to local AsyncStorage and toggles TextInput props. No command execution, path handling, auth, secrets, network, or IPC surface is involved. Enabling autocomplete routes typed text through the OS IME/suggestion engine (standard for any text field); the raw direct-capture PTY path is unchanged. No new dependencies.

Notes

  • Android-specific: the command TextInput is remounted (via a key change) on toggle because Android caches the IME inputType at mount; without the remount, suggestions wouldn't switch on/off until the field was recreated.
  • Default-off preserves existing behavior for all current users.

🤖 Generated with Claude Code

github-actions Bot and others added 4 commits June 5, 2026 22:28
# Conflicts:
#	package.json
Terminal command inputs disable autocorrect/suggestions and use a
password-class keyboard so the OS never rewrites commands, flags, or
paths. Some users want phone-style typing in the command bar.

Add a Settings → Terminal "Autocomplete & autocorrect" toggle
(persisted locally, default off). When on, the command bar enables
autoCorrect/spellCheck and uses the default keyboard so Android shows
its suggestion strip; iOS drops the ascii-capable restriction. The
direct keyboard-capture input is unchanged — it streams raw keystrokes
where suggestions cannot apply.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ac728a32-f228-480c-a3af-fe98d22d89cb

📥 Commits

Reviewing files that changed from the base of the PR and between b6dc2bf and b40f772.

📒 Files selected for processing (2)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/src/storage/preferences.test.ts

📝 Walkthrough

Walkthrough

A new terminal keyboard autocomplete/autocorrect preference is added across four files. preferences.ts gains two exported async functions (loadTerminalAutocompleteEnabled, saveTerminalAutocompleteEnabled) that read and write a boolean flag under the orca:terminalAutocompleteEnabled key in AsyncStorage, defaulting to false. TerminalSettingsScreen gains a new "KEYBOARD INPUT" section with a Switch toggle that loads the stored value on mount and persists changes immediately. The session screen imports the load helper, tracks the preference in local state, reloads it via useFocusEffect on screen focus, remounts the command TextInput based on the preference, and applies it to TextInput props (autoCorrect, spellCheck, keyboardType). A test module verifies correct defaulting, loading, error handling, and persistence of the preference value.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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 and concisely describes the main feature: adding a terminal keyboard autocomplete toggle in the mobile app settings.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description is comprehensive and well-structured, following the template with all major sections completed: Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b2cf4a1b-b560-400a-999c-869c7cb6de87

📥 Commits

Reviewing files that changed from the base of the PR and between 86a2441 and 433b1c1.

📒 Files selected for processing (3)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/app/terminal-settings.tsx
  • mobile/src/storage/preferences.ts

Comment thread mobile/app/terminal-settings.tsx Resolved
Android caches the IME inputType at mount, so flipping the toggle did
not switch suggestions on until the field remounted.

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

2310-2314: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add cleanup to prevent state updates after unfocus.

The useFocusEffect callback can resolve after the screen unfocuses or unmounts, causing a React warning when setAutocompleteEnabled runs on an unmounted component. Add a cleanup function with an active flag to skip the state update if the effect has been torn down, matching the pattern used at lines 2038-2050.

♻️ Suggested fix
  useFocusEffect(
    useCallback(() => {
-      void loadTerminalAutocompleteEnabled().then(setAutocompleteEnabled)
+      let active = true
+      void loadTerminalAutocompleteEnabled().then((enabled) => {
+        if (active) {
+          setAutocompleteEnabled(enabled)
+        }
+      })
+      return () => {
+        active = false
+      }
    }, [])
  )

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0fdcb239-8459-4495-b728-1fb98aa2d7b6

📥 Commits

Reviewing files that changed from the base of the PR and between 433b1c1 and 0e77a2b.

📒 Files selected for processing (1)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx

…oggle

Address review feedback: the settings toggle's initial load could clobber
a fast user toggle, and the session focus-effect could setState after the
screen unfocused. Both now use a guard flag.
@gsxdsm

gsxdsm commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review feedback in b6dc2bf:

  • Settings toggle: the initial async load now skips if the user has already toggled (a userToggledAutocompleteRef guard + stale flag), so a fast toggle is no longer clobbered by the delayed read.
  • Session focus-effect: added an active flag so it won't setState after the screen unfocuses/unmounts.

@Jinwoo-H Jinwoo-H 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 default-off mobile preference for users who want normal phone typing in the terminal command bar without changing the raw/live terminal input path.

I made one small maintainer follow-up:

  • added storage preference tests for default-off, load/save, and read-failure behavior
  • limited the forced command-input remount to Android, where the IME caches keyboard type; iOS can update without that focus-costly remount

Validated:

  • mobile: oxlint
  • mobile: tsc --noEmit
  • mobile: Vitest full suite, 67 files / 326 passed / 2 skipped

Live device verification was handled separately before merge.

@Jinwoo-H
Jinwoo-H merged commit d17c22c into stablyai:main Jun 15, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* release: v1.4.48-rc.0 [rc-slot:2026-06-05-15]

* release: v0.0.1-rc.0 [rc-slot:2026-06-06-03]

* feat(mobile): add terminal keyboard autocomplete toggle

Terminal command inputs disable autocorrect/suggestions and use a
password-class keyboard so the OS never rewrites commands, flags, or
paths. Some users want phone-style typing in the command bar.

Add a Settings → Terminal "Autocomplete & autocorrect" toggle
(persisted locally, default off). When on, the command bar enables
autoCorrect/spellCheck and uses the default keyboard so Android shows
its suggestion strip; iOS drops the ascii-capable restriction. The
direct keyboard-capture input is unchanged — it streams raw keystrokes
where suggestions cannot apply.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(mobile): remount command input when autocomplete toggles

Android caches the IME inputType at mount, so flipping the toggle did
not switch suggestions on until the field remounted.

* fix(mobile): guard autocomplete pref loads against unmount and fast toggle

Address review feedback: the settings toggle's initial load could clobber
a fast user toggle, and the session focus-effect could setState after the
screen unfocused. Both now use a guard flag.

* test mobile terminal autocomplete preference

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Jinwoo-H <[email protected]>
Co-authored-by: Orca <[email protected]>
@gsxdsm
gsxdsm deleted the feat/mobile-terminal-autocomplete branch October 31, 2026 17:58
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.

2 participants