feat: add kill_ring_system_clipboard config option#2260
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8121e870e9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
8121e87 to
0f26cf8
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0f26cf83a2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| @_kb.add("c-w", eager=True) | ||
| def _(event: KeyPressEvent) -> None: |
There was a problem hiding this comment.
Don't override selection cut with Ctrl-W kill handler
When kill_ring_system_clipboard=false, this eager c-w binding runs unconditionally and preempts prompt_toolkit’s built-in c-w selection-cut path (c-w with has_selection). In any state where text is selected, pressing Ctrl-W now deletes the previous word instead of cutting the selection, so users lose the expected cut behavior and the documented guarantee that intentional cut operations still use the system clipboard.
Useful? React with 👍 / 👎.
Add a configurable option to prevent emacs-style kill commands (Ctrl-W, Ctrl-K, Ctrl-U, etc.) from writing deleted text to the system clipboard. When set to false, these commands use an in-memory kill ring instead, avoiding clipboard pollution. Intentional cut/copy/paste operations (Ctrl-W with selection, Alt-W, Ctrl-Y, Ctrl-V) continue to use the system clipboard regardless of this setting. Files changed: - config.py: add kill_ring_system_clipboard field (default: true) - shell/__init__.py: pass config value to CustomPromptSession - shell/prompt.py: add eager keybinding overrides when disabled - docs: document the new option
0f26cf8 to
b2f1aef
Compare
|
Author response to review bot comments: The core design choice here is intentional: when Specific responses:
|
Related Issue
N/A — This change is under 100 lines (per CONTRIBUTING.md), so no prior issue discussion is required.
Description
Add a
kill_ring_system_clipboardconfiguration option (default:true) that allows users to prevent emacs-style kill commands from polluting the system clipboard.Problem: Kimi CLI uses
prompt_toolkit'sPyperclipClipboard, which means all built-in emacs "kill" commands (Ctrl-W,Ctrl-K,Ctrl-U,Ctrl-Delete,Alt-D,Alt-Backspace) write deleted text to the system clipboard viapyperclip. This silently destroys existing clipboard content and pollutes clipboard history managers.Solution: When
kill_ring_system_clipboard = false, eager keybinding overrides intercept the 6 kill commands before prompt_toolkit's built-in handlers can touch the clipboard. The text is deleted without being copied. The in-memory kill ring still works forCtrl-Ywithin the same session.Intentional cut/copy/paste operations (
Ctrl-Wwith text selected,Alt-W,Ctrl-Y,Ctrl-V) continue to use the system clipboard regardless of this setting.Files changed:
src/kimi_cli/config.py: Addedkill_ring_system_clipboard: bool = Field(default=True, ...)src/kimi_cli/ui/shell/__init__.py: Pass config value intoCustomPromptSessionsrc/kimi_cli/ui/shell/prompt.py: Add conditional eager keybinding overrides for the 6 kill commandsdocs/en/configuration/config-files.md: Document the new optionChecklist
make gen-changelogto update the changelog.make gen-docsto update the user documentation.