/** * OpenCode-style prompt editor. * * ┃ ask anything… * ┃ * ┃ 󰚩 BUILD Opus 5.5 Anthropic medium * tab mode · ctrl+p commands · ctrl+x leader * * A shaded panel with a heavy left rail in the mode colour (the brand primary for build, * the brand plan colour for plan) and the mode pill and model inside, like OpenCode's prompt; key hints sit under it. * pi's working status (spinner, retry countdown, compaction) is shown in the footer instead. * * Keys handled here before pi sees them: * - Tab on an empty prompt (and no autocomplete open): switch Build/Plan mode. Shift+Tab is left to * pi, which cycles the thinking level with it. * - Ctrl+X: leader key; the next key runs a leader action (see commands.ts) * - Ctrl+P: command palette. pi binds ctrl+p to model cycling, a reserved action that * registerShortcut() can't take over, so the editor intercepts it (model cycling stays on * ctrl+x m / ctrl+l). * Everything else goes to pi's CustomEditor, so app keybindings keep working. */ import { CustomEditor, type KeybindingsManager, type Theme } from "@earendil-works/pi-coding-agent"; import { type EditorTheme, type TUI } from "@earendil-works/pi-tui"; import { type ModelParts } from "./prompt-row.ts"; import type { UiState } from "./state.ts"; export interface EditorHooks { state: UiState; theme: () => Theme; /** The model, provider and thinking level for the bottom row. */ modelParts: () => ModelParts; /** Muted hint shown after the cursor while the prompt is empty (home screen). */ placeholder?: () => string | undefined; /** Left side of the key-hint row under the box (home screen brand line). */ hintLeft?: () => string | undefined; /** Blink the cursor (home screen only). */ blink?: () => boolean; onModeCycle: () => void; /** Called for the key after the leader. Return true if it was a leader action. */ onLeaderKey: (data: string) => boolean; /** Leader key pressed (show a hint) or cleared. */ onLeaderState: (pending: boolean) => void; /** Ctrl+P: open the command palette. */ onPalette: () => void; /** The working/retry indicator changed (footer repaint). */ onStatusChange?: () => void; leaderTimeoutMs: number; } export declare class PromptEditor extends CustomEditor { private leaderPending; private leaderTimer; private readonly hooks; constructor(tui: TUI, editorTheme: EditorTheme, keybindings: KeybindingsManager, hooks: EditorHooks); setPaddingX(_padding: number): void; /** * pi passes its working/retry/compaction indicator here (embedWorkingStatus). Keep it in shared * state for the footer instead of drawing it in the editor's top border. */ setWorkingStatusIndicator(indicator: Parameters[0]): void; private clearLeader; /** Cursor blink: off phase hides the editor's reverse-video cursor; a keypress resets it. */ private blinkOff; private blinkTimer; private static readonly BLINK_MS; private syncBlink; private stopBlink; dispose(): void; handleInput(data: string): void; private modeColor; render(width: number): string[]; }