/** * [WHO]: Provides PromptHost, PromptHostContext — single-active-prompt slot for extension dialogs * [FROM]: Depends on @catui/tui (Component/Container/TUI), keybindings (KeybindingsManager), * extensions-host (ExtensionUIDialogOptions), components (Extension{Selector,Input,Editor}Component) * [TO]: Consumed by modes/interactive/interactive-mode.ts (held as `this.promptHost`; wired into * ExtensionUIContext select/confirm/input/editor; focus restore called by handleEvent + resetExtensionUI) * [HERE]: modes/interactive/controllers/extension-ui/prompt-host.ts — P5 extension-ui rewrite, host 2/4 (UI02, 重写) * * Rewrite of the three byte-identical show/hide/dismiss lifecycles (selector / input / editor) into a * single "active prompt" slot (see extension-ui-analysis.md §3, rewrite-acceptance.md). The three prompt * types are now thin builders plugged into one generic `show` that owns the shared skeleton: abort * handling, single-active-prompt invariant, mount-into-editor-shell + focus, and dismiss → dispose + * remount + restore focus. NOT a generic overlay stack — there is one slot (no nesting need today). * Behavior of select/confirm/input/editor is identical to the former InteractiveMode methods. */ import type { Component, Container, TUI } from "@catui/tui"; import type { ExtensionUIDialogOptions } from "../../../../core/extensions-host/index.js"; import type { KeybindingsManager } from "../../../../core/platform/keybindings.js"; /** Narrow capability seam: the editor-shell handles the prompt slot mounts into. */ export interface PromptHostContext { getEditorContainer(): Container; getUi(): TUI; /** The editor component (focused when the prompt is dismissed and the shell is mounted). */ getEditor(): Component; /** The editor/buddy layout node — its presence means the editor shell is mounted. */ getEditorBuddyLayout(): Component; getKeybindings(): KeybindingsManager; /** Rebuild the editor shell (attachments bar + editor row) after a prompt is removed. */ remountEditorShell(): void; } export declare class PromptHost { private readonly ctx; private active; constructor(ctx: PromptHostContext); hasActivePrompt(): boolean; /** Focus the editor when no prompt is active and the editor shell is mounted. */ restoreEditorFocusIfPossible(): void; /** Dismiss the active prompt (dispose + remount editor shell + restore focus + render). */ dismiss(restoreFocus?: boolean): void; selector(title: string, options: string[], opts?: ExtensionUIDialogOptions): Promise; confirm(title: string, message: string, opts?: ExtensionUIDialogOptions): Promise; input(title: string, placeholder?: string, opts?: ExtensionUIDialogOptions): Promise; editor(title: string, prefill?: string): Promise; /** * Show one prompt as the single active slot. `build` receives a `settle` callback * to resolve the promise (with the chosen value, or undefined on cancel/abort); * it must wire that into the component's submit/cancel callbacks. */ private show; private mount; private clear; }