Files
pi/packages/coding-agent/src/tui/custom-editor.ts
T
Mario ZechnerandTino Ehrich fecf9734b0 Add --models parameter for quick model cycling with Ctrl+P
- Add --models CLI arg accepting comma-separated patterns
- Implement smart matching: prefers aliases over dated versions
- Add Ctrl+P to cycle through scoped models (or all if no scope)
- Show model scope hint at startup
- Update help text with examples

Co-authored-by: Tino Ehrich <tino.ehrich@hey.com>
2025-11-20 12:57:20 +01:00

42 lines
991 B
TypeScript

import { Editor } from "@mariozechner/pi-tui";
/**
* Custom editor that handles Escape and Ctrl+C keys for coding-agent
*/
export class CustomEditor extends Editor {
public onEscape?: () => void;
public onCtrlC?: () => void;
public onShiftTab?: () => void;
public onCtrlP?: () => void;
handleInput(data: string): void {
// Intercept Ctrl+P for model cycling
if (data === "\x10" && this.onCtrlP) {
this.onCtrlP();
return;
}
// Intercept Shift+Tab for thinking level cycling
if (data === "\x1b[Z" && this.onShiftTab) {
this.onShiftTab();
return;
}
// Intercept Escape key - but only if autocomplete is NOT active
// (let parent handle escape for autocomplete cancellation)
if (data === "\x1b" && this.onEscape && !this.isShowingAutocomplete()) {
this.onEscape();
return;
}
// Intercept Ctrl+C
if (data === "\x03" && this.onCtrlC) {
this.onCtrlC();
return;
}
// Pass to parent for normal handling
super.handleInput(data);
}
}