Add readline kill ring and editing commands to the prompt - #155
Conversation
Frees Ctrl+Y for the prompt's readline yank command. The MCP auth prompt hint and docs follow the new binding.
The prompt now supports C-b/C-f character movement, C-d delete-char, and a kill ring backing C-k, C-u, C-w, M-d, and M-backspace, with C-y yank and M-y yank-pop. Consecutive kills accumulate into one ring entry and any other keystroke breaks the sequence, matching readline. The kill/yank layer is a pure function dispatched ahead of the existing key handling, and the help overlay lists the new bindings.
TheGreatAxios
left a comment
There was a problem hiding this comment.
Non Blocking Feedback, I can cleanup these separately if preferred.
-
Inconsistent copy-URL affordance. mcp-auth-prompt.tsx moved its "copy URL" hint from Ctrl+Y → Alt+C, but codex-login-modal.tsx:186 still uses Ctrl+Y for the same "copy the authorize URL" action. No functional conflict (it's a self-contained modal handler active only during login, when the prompt isn't), but the same action now has two different bindings across the two auth prompts. Worth aligning.
-
Image-paste doesn't break the kill sequence. The C-v/\u0016 image-paste branch (chat-input.tsx:461) returns early before the breakKillSequence call, unlike text paste (line ~656) which breaks it. So C-k → image-paste → C-k would incorrectly accumulate into one ring entry. Extremely minor readline-fidelity edge.
-
C-d divergence (non-issue). C-d at end-of-buffer/empty is a no-op rather than readline's EOF — a sensible, deliberate divergence for a prompt.
|
We will address (1) from the first comment in a different PR |
Add readline kill ring and editing commands to the prompt
Add readline kill ring and editing commands to the prompt
Add readline kill ring and editing commands to the prompt
Add readline kill ring and editing commands to the prompt
Add readline kill ring and editing commands to the prompt
What
Brings the prompt's line editing closer to readline: character movement and deletion (C-b, C-f, C-d), a kill ring with kill commands (C-k, C-u, C-w, M-d, M-backspace), and yank / yank-pop (C-y, M-y).
Why
The prompt previously supported only a small readline subset (C-a/C-e, word movement, backspace/delete). Kill and yank are the workhorse editing commands for anyone with shell muscle memory, and C-d/C-b/C-f round out cursor-local editing.
Changes
src/tui/kill-ring.ts: pure kill-ring model (10 entries) — consecutive kills accumulate into a single entry (forward kills append, backward kills prepend),C-yyanks the newest kill,M-yimmediately after a yank rotates through older kills; any other keystroke or paste breaks the sequence, matching readline.chat-input.tsx: new pureapplyKillYanklayer dispatched ahead of existing key handling;applyKeygains C-b/C-f movement and C-d delete-char (not ring-recorded, same as readline).kill-ring.test.ts(16 cases), kill/yank and movement cases inchat-input.test.ts, keymap regression that Ctrl+Y no longer opens copy mode.Verified with
bun run typecheck,bun run build, and the fullbun testsuite (2448 pass).