/** * TUI input handler — extracted from tui.ts to separate input-processing * concerns (keyboard dispatch, picker navigation, approval shortcuts, global * hotkeys) from rendering and state management. * * This module owns: * - {@link isLikelyMouseInput} — filters SGR/legacy mouse-report bytes * - {@link ApprovalChoice} + helpers — approval-prompt keyboard logic * - {@link handleGlobalInput} — the global useInput callback body (session * picker, model picker, approval, Ctrl+O / Ctrl+D / Shift+Tab / Esc) */ /** Minimal key shape from Ink's useInput callback. */ export interface InputKey { escape?: boolean; upArrow?: boolean; downArrow?: boolean; leftArrow?: boolean; rightArrow?: boolean; return?: boolean; tab?: boolean; shift?: boolean; ctrl?: boolean; delete?: boolean; } /** Session picker state used by keyboard navigation. */ export interface SessionPickerState { sessions: S[]; selectedIndex: number; } /** Model picker state used by keyboard navigation. */ export interface ModelPickerState { list: { choices: M[]; provider: string; }; selectedIndex: number; } /** Approval prompt state used by keyboard navigation. */ export interface ApprovalPromptState { resolve: (answer: string) => void; selectedIndex: number; question: string; } /** ask_user_question prompt state (arrow/number select + freeform). */ export interface UserQuestionPromptState { resolve: (answer: string) => void; selectedIndex: number; selectedIndices: number[]; freeform: string; question: string; options: { label: string; description?: string; }[]; multiSelect: boolean; } /** All dependencies the global input handler needs from the TUI component. * * Setter types use `any` to stay free of React's Dispatch/SetStateAction * types — this module owns input logic, not React type plumbing. The handler * body is type-safe internally (it only passes well-typed values to setters). */ export interface GlobalInputDeps { sessionPicker: SessionPickerState | null; setSessionPicker: (updater: any) => void; modelPicker: ModelPickerState | null; setModelPicker: (updater: any) => void; approval: ApprovalPromptState | null; setApproval: (updater: any) => void; userQuestion?: UserQuestionPromptState | null; setUserQuestion?: (updater: any) => void; input: string; setInput: (v: string) => void; setInputCursor: (updater: (prev: number) => number) => void; pendingAttachments: unknown[]; setPendingAttachments: (v: any[]) => void; setPendingAttachmentBlocks: (v: any[]) => void; suppressedAutoAttachInputRef: { current: string | null; }; activeRunControllerRef: { current: unknown; }; runtime?: { deviceSession?: unknown; }; showFlash: (msg: string) => void; requestStop: () => void; addTranscript: (type: any, text: string) => void; switchModelForSession: (model: string, provider: string) => void; resumeSession: (session: any) => void | Promise; setToolsExpanded: (updater: (prev: boolean) => boolean) => void; /** Optional: toggle sticky todo panel collapse (Ctrl+T). */ setTodosCollapsed?: (updater: (prev: boolean) => boolean) => void; setInteractionMode: (updater: any) => void; disconnectDeviceForSession: (agent: any, runtime: any) => string | Promise; removeAttachmentRefsFromInput: (input: string) => string; clampPromptCursor: (input: string, cursor: number) => number; agent: any; } /** SGR/legacy mouse report bytes. Every useInput must ignore them so a stray * wheel never types bytes or fires keys. */ export declare function isLikelyMouseInput(s: string): boolean; export interface ApprovalChoice { label: string; shortcut: string; decision: 'allow-once' | 'allow-always' | 'deny'; description: string; } export declare const APPROVAL_CHOICES: ApprovalChoice[]; export declare function clampApprovalChoiceIndex(index: number, choiceCount?: number): number; export declare function approvalAnswerFromDecision(decision: 'allow-once' | 'allow-always' | 'deny'): string; export declare function approvalAnswerForIndex(index: number, question?: string): string; export declare function approvalChoicesForQuestion(question: string): ApprovalChoice[]; /** * The body of the global `useInput` callback in MossTui. * Handles (in priority order): session picker → model picker → approval → * global hotkeys (Ctrl+O, Ctrl+D, Shift+Tab, Esc). * * Returns `true` if the key was consumed, `false` if it should bubble. */ export declare function handleGlobalInput(inputChar: string, key: InputKey, deps: GlobalInputDeps): boolean; //# sourceMappingURL=tui-input-handler.d.ts.map