Repository navigation
fix(terminal): send ESC d for Option+Forward-Delete on macOS (#21491) - #33296
Merged
Merged
Conversation
…o macOS Ghostty, VTE, xterm and ConPTY send CSI 3;3~ for Alt+Delete, and local PSReadLine would see ESC d as Alt+D, so only macOS mirrors iTerm2's Natural Text Editing ESC d. Trim the regression test to the platform split. Co-authored-by: Bing.Z <[email protected]>
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
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 |
…ull-screen apps vim/nano read ESC d as Escape + d (vim leaves insert mode with a pending delete). Send ESC d only when the pane is on the normal buffer (shells, inline agents) or a known agent owns it (foreground process, live hook row, launch config, or agent title).
Closed
9 tasks done
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.
ELI5
On macOS, Option + Forward-Delete (⌥⌦, fn+⌥+⌫ on laptops) in an Orca terminal now deletes the word to the right of the cursor. Before this change it wiped everything to the end of the line in Claude Code, and in a shell it could print a stray
~.This builds on #21893 by @bbingz and keeps their commit. The follow-up commit limits the change to macOS.
Root cause
xterm.js encodes Alt+Delete as
CSI 3;3~, and Orca had no policy mapping for it. That differs from how readline and Claude Code read the key:CSI 3;3~as kill-to-end-of-line and treatsESC das forward-kill-word (PTY probe below).f728-0x80000) toEsc+d(iTerm2/plists/PresetKeyMappings.plist). Orca already copies the rest of that preset: ⌥⌫ →ESC DEL, ⌥←/→ →ESC b/f, ⌘⌫ →^U.CSI 3;3~(ghostty/src/input/function_keys.zig:85) and has no ⌥⌦ default inConfig.zig. Terminal.app'skeyMappings.plisthas no~F728entry.What changed
terminal-shortcut-policy.ts: when kitty keyboard is inactive, Option+Delete (not numpad) sendsESC don macOS. The existing Alt+Backspace branch already sendsESC DEL.CSI >7u, so it getsCSI 3;3~and handles it as Alt+Delete (codex-rs/tui/src/bottom_pane/textarea.rsdelete_forward_word_with_without_alt_modifier).CSI 3;3~. That is what VTE, xterm and Ghostty send there. On a local ConPTY,ESC dwould arrive in PSReadLine as Alt+D, which is a different key.Verification
I ran each real TUI under node-pty with
@xterm/headless(the kitty-capable xterm.js that Orca uses), typedalpha beta gamma, pressed Ctrl+A, then sent the bytes:ESC d(new macOS bytes)CSI 3;3~(old bytes)❯ beta gamma>7u)› beta gamma› beta gamma┃ beta gamma┃ beta gammaI got the same Claude results under tmux. With
TERM_PROGRAM=Orca, Claude does not push kitty flags, so it takes the legacy path that this fix covers.pnpm test terminal-shortcut-forward-delete.test.ts terminal-shortcut-policy.test.ts: 38 passed. The macOS case fails on main, and the Linux/Windows case fails on fix(terminal): translate Option/Alt + Forward-Delete to readline forward-kill-word (#21491) #21893 as submitted.pnpm tc:webandcheck:code-quality:changedpass.Risk
The change is small and macOS-only. A user whose shell binds
CSI 3;3~itself (for example zshbindkey '^[[3;3~') will now get readline'sESC d(kill-word) instead. That matches iTerm2's preset.Fixes #21491
Supersedes #21893
Co-authored-by: Bing.Z [email protected]