Repository navigation
fix: support option/alt+arrow word navigation in terminal - #699
Merged
Jinwoo-H merged 1 commit intoApr 16, 2026
Merged
Conversation
xterm.js emits \e[1;3D / \e[1;3C for option/alt+arrow, which default readline (bash, zsh) does not bind — so word-by-word navigation silently doesn't work. Translate to \eb / \ef inside the terminal shortcut policy so option+←/→ on macOS and alt+←/→ on Linux/Windows match iTerm2's "Esc+" option-key mode. Extends the stablyai#519 allowlist; no scope beyond that. Fixes stablyai#696
Jinwoo-H
approved these changes
Apr 16, 2026
Jinwoo-H
left a comment
Contributor
There was a problem hiding this comment.
Thank you for contributing, lgtm!
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
option+←/→on macOS (alt+←/→on Linux/Windows) now navigates word-by-word in Orca's integrated terminal, matching iTerm2 / Ghostty / Terminal.app behavior with default shell configs. Before this fix, the keys emitted the xterm CSI sequences\e[1;3D/\e[1;3C, which readline doesn't bind — the cursor wouldn't move, and depending on the shell the escape bytes could appear at the prompt as literal garbage.Fixes #696.
Root cause
macOptionIsMeta: true, which is whyoption+b/option+falready work (xterm.js emits\eb/\ef, readline's default bindings).\e[1;3D/\e[1;3C) that default readline doesn't recognize as word-nav.terminal-shortcut-policy.ts(the pure allowlist introduced by fix: audit terminal shortcut interception #519) and translate to\eb/\efbefore xterm.js sees the event. Same pattern iTerm2's "Esc+" option-key mode uses.Scope
One new
ifblock interminal-shortcut-policy.ts; one newit(...)block in its sibling test file covering macOS + Linux/Windows + three passthrough regression cases (alt+shift+arrow,alt+ctrl+arrow, plain arrow). No refactors.Platform testing
pnpm dev—catshows^[b/^[fon option+←/→; at a shell prompt, cursor jumps word-by-word. Regression checks pass: option+b, option+f, option+Backspace still work; Cmd+F still opens terminal search.altKeysemantics on all three OSes), and the unit test pins the non-Mac branch, so there's no reasonable path for this to regress on those platforms without also regressing on macOS.Before / after
Test plan
pnpm lint— cleanpnpm typecheck— cleanpnpm test— 1716 tests passpnpm build— cleancatwithoption+←/→before/after the fix on macOSAI code-review summary
!metaKey && !ctrlKey && altKey && !shiftKeyandkey === 'ArrowLeft' | 'ArrowRight'— the same shape as the existingAlt+Backspacebranch directly above. On macOS this matchesoptiononly; on Linux/Windows it matchesaltonly. Other chords (alt+shift,alt+ctrl,cmd+alt) fall through to xterm.js unchanged, and unit tests pin that.\x1bb,\x1bf) — no user input is interpolated, no path traversal or injection surface.sendInputis the same IPC path already used byAlt+Backspace,Cmd+Backspace,Cmd+Delete, andShift+Enter.alt+shift+arrow,alt+ctrl+arrow, plain arrow) are explicitly tested so a later edit to this file can't silently start swallowing select-word chords or plain cursor moves.Related: #519 (terminal-shortcut audit), #443 (Ctrl+R), #586 (Ctrl+D / EOF split fix).
X/Twitter: @dylanklohr