Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/six-foxes-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---

Add Ctrl+Y keyboard shortcut to toggle YOLO permission mode. Press Ctrl+Y to switch YOLO mode on or off.
6 changes: 6 additions & 0 deletions apps/kimi-code/src/tui/components/editor/custom-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export class CustomEditor extends Editor {
/** Return `true` to consume Ctrl+B; return `false`/`undefined` to fall through to the editor default (cursor-left). */
public onCtrlB?: () => boolean;
/** Return `true` to consume Ctrl+T (the todo list had overflow to toggle); return `false`/`undefined` to fall through to the editor default. */
public onCtrlY?: () => void;
public onToggleTodoExpand?: () => boolean;
public onUndo?: () => void;
public onTextPaste?: () => void;
Expand Down Expand Up @@ -441,6 +442,11 @@ export class CustomEditor extends Editor {
if (this.onCtrlB?.() === true) return;
}

if (matchesKey(normalized, Key.ctrl('y'))) {
this.onCtrlY?.();
return;
Comment on lines +445 to +447

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid stealing the editor yank binding

When a user is editing a prompt after killing text with Ctrl-K/Ctrl-U/Ctrl-W, pi-tui's editor expects Ctrl-Y to yank the kill ring (packages/pi-tui/src/keybindings.ts:115). This early return runs before super.handleInput, so the yank handler is never reached and Ctrl-Y toggles YOLO instead, leaving killed text unrecoverable from the keyboard; choose a non-editor binding or add context/fallthrough so prompt editing still works.

Useful? React with 👍 / 👎.

}

if (matchesKey(normalized, Key.ctrl('t'))) {
// Only consume the key when the todo list actually has overflow to
// expand/collapse; otherwise fall through to the editor default.
Expand Down
6 changes: 6 additions & 0 deletions apps/kimi-code/src/tui/controllers/editor-keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface EditorKeyboardHost {
openUndoSelector(): void;
stop(exitCode?: number): Promise<void>;
handlePlanToggle(next: boolean): void;
handleYoloToggle(): void;
handleInputModeChange(mode: 'prompt' | 'bash'): void;
clearQueuedMessages(): void;
setExternalEditorRunning(running: boolean): void;
Expand Down Expand Up @@ -201,6 +202,11 @@ export class EditorKeyboardController {
this.armPendingUndoEsc();
};

editor.onCtrlY = () => {
host.track('shortcut_yolo_toggle');
host.handleYoloToggle();
};

editor.onShiftTab = () => {
if (host.session === undefined) {
host.showError(NO_ACTIVE_SESSION_MESSAGE);
Expand Down
4 changes: 4 additions & 0 deletions apps/kimi-code/src/tui/kimi-tui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,10 @@ export class KimiTUI {
void slashCommands.handlePlanCommand(this, next ? 'on' : 'off');
}

handleYoloToggle(): void {
void slashCommands.handleYoloCommand(this, '');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Don't bypass /yolo error handling

When session.setPermission(...) rejects (for example after the server/RPC connection drops), the typed /yolo path reports the failure because built-in slash commands are wrapped in executeSlashCommand's try/catch, but this shortcut calls the async handler with void and no catch. That leaves the rejection unhandled (potentially terminating the TUI under Node's unhandled-rejection behavior) and the user gets no error; attach a catch/showError or route through the same dispatch path.

Useful? React with 👍 / 👎.

}

handleInputModeChange(mode: 'prompt' | 'bash'): void {
this.setAppState({ inputMode: mode });
this.updateEditorBorderHighlight();
Expand Down