diff --git a/.changeset/six-foxes-smoke.md b/.changeset/six-foxes-smoke.md new file mode 100644 index 0000000000..da36432e09 --- /dev/null +++ b/.changeset/six-foxes-smoke.md @@ -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. diff --git a/apps/kimi-code/src/tui/components/editor/custom-editor.ts b/apps/kimi-code/src/tui/components/editor/custom-editor.ts index e3532b157c..3c577d9902 100644 --- a/apps/kimi-code/src/tui/components/editor/custom-editor.ts +++ b/apps/kimi-code/src/tui/components/editor/custom-editor.ts @@ -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; @@ -441,6 +442,11 @@ export class CustomEditor extends Editor { if (this.onCtrlB?.() === true) return; } + if (matchesKey(normalized, Key.ctrl('y'))) { + this.onCtrlY?.(); + return; + } + 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. diff --git a/apps/kimi-code/src/tui/controllers/editor-keyboard.ts b/apps/kimi-code/src/tui/controllers/editor-keyboard.ts index 383694c073..de73066053 100644 --- a/apps/kimi-code/src/tui/controllers/editor-keyboard.ts +++ b/apps/kimi-code/src/tui/controllers/editor-keyboard.ts @@ -46,6 +46,7 @@ export interface EditorKeyboardHost { openUndoSelector(): void; stop(exitCode?: number): Promise; handlePlanToggle(next: boolean): void; + handleYoloToggle(): void; handleInputModeChange(mode: 'prompt' | 'bash'): void; clearQueuedMessages(): void; setExternalEditorRunning(running: boolean): void; @@ -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); diff --git a/apps/kimi-code/src/tui/kimi-tui.ts b/apps/kimi-code/src/tui/kimi-tui.ts index 62d1b2370b..10d71d16bf 100644 --- a/apps/kimi-code/src/tui/kimi-tui.ts +++ b/apps/kimi-code/src/tui/kimi-tui.ts @@ -917,6 +917,10 @@ export class KimiTUI { void slashCommands.handlePlanCommand(this, next ? 'on' : 'off'); } + handleYoloToggle(): void { + void slashCommands.handleYoloCommand(this, ''); + } + handleInputModeChange(mode: 'prompt' | 'bash'): void { this.setAppState({ inputMode: mode }); this.updateEditorBorderHighlight();