Skip to content

Add readline kill ring and editing commands to the prompt - #155

Merged
brianjfox merged 2 commits into
mainfrom
feat/readline-kill-ring
Jul 21, 2026
Merged

Add readline kill ring and editing commands to the prompt#155
brianjfox merged 2 commits into
mainfrom
feat/readline-kill-ring

Conversation

@brianjfox

Copy link
Copy Markdown
Collaborator

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

  • New 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-y yanks the newest kill, M-y immediately after a yank rotates through older kills; any other keystroke or paste breaks the sequence, matching readline.
  • chat-input.tsx: new pure applyKillYank layer dispatched ahead of existing key handling; applyKey gains C-b/C-f movement and C-d delete-char (not ring-recorded, same as readline).
  • Copy mode moved from Ctrl+Y to Alt+C to free Ctrl+Y for yank (keymap, help table, MCP auth prompt hint, docs/MCP.md).
  • Help overlay lists the new bindings.
  • Tests: new kill-ring.test.ts (16 cases), kill/yank and movement cases in chat-input.test.ts, keymap regression that Ctrl+Y no longer opens copy mode.

Verified with bun run typecheck, bun run build, and the full bun test suite (2448 pass).

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 TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non Blocking Feedback, I can cleanup these separately if preferred.

  1. 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.

  2. 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.

  3. 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.

@brianjfox

Copy link
Copy Markdown
Collaborator Author

We will address (1) from the first comment in a different PR

@brianjfox
brianjfox merged commit 4e368e9 into main Jul 21, 2026
@brianjfox
brianjfox deleted the feat/readline-kill-ring branch July 21, 2026 19:02
TheGreatAxios pushed a commit that referenced this pull request Jul 21, 2026
Add readline kill ring and editing commands to the prompt
TheGreatAxios pushed a commit that referenced this pull request Jul 21, 2026
Add readline kill ring and editing commands to the prompt
TheGreatAxios pushed a commit that referenced this pull request Jul 21, 2026
Add readline kill ring and editing commands to the prompt
TheGreatAxios pushed a commit that referenced this pull request Jul 25, 2026
Add readline kill ring and editing commands to the prompt
TheGreatAxios pushed a commit that referenced this pull request Jul 25, 2026
Add readline kill ring and editing commands to the prompt
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