/** * A multiple-choice list overlay, bounded to the terminal. * * Harness's question contract lets one question carry several answers * (`multiSelect`), which the single-choice picker in `./select.ts` cannot * express: its confirm is whichever row the cursor rests on. This overlay is * that picker with the confirm decoupled from the cursor — space flips the row * under it, and enter submits every flipped row at once. The Other… route is * the one row Enter reads by its state: while its answer is unwritten, Enter * opens the editor; once committed, the row is the finished answer and Enter * confirms in place, with tab back into the text. Movement, bounding, * framing, and the once-only settlement discipline are the same, and anything * beyond the offered rows (an `Other…` route, the editor behind it) is composed * by the caller: the overlay draws the row and hands back what was committed, * the way the picker hands back a value it does not interpret. * * The list is a viewport over its rows for the reason `./select.ts` is: a * picker that draws a row per choice hands `Screen` a live region taller than * the screen, and the rows that scrolled off can no longer be reached or * erased. There is deliberately no query box: a question's options are one * model turn's worth, not a provider's route catalogue, and the viewport keeps * a long list reachable without spending a row on search. * @module dshline/multiselect */ import type { Context } from '@deepseek-ai/cordis'; import type { SelectChoice } from './select.ts'; import type { TuiOverlay } from './slots.ts'; /** * The Other… row's display text for one question's offer. * @param offered - every label the question itself offers. * @returns a display text no offered option shares, so the custom route can * always be told apart from the choices around it. The routing value stays * the caller's private sentinel; only what is drawn adapts. */ export declare function otherDisplay(offered: readonly string[]): string; /** What a confirmed multi-select carries, ready for the Harness answer item. */ export interface MultiSelectAnswer { /** Labels of the checked rows, in the order they were offered. */ readonly selected: readonly string[]; /** The free-text answer committed through `Other…`, when one is present. */ readonly custom?: string; } /** How a multi-select overlay is built and what it reports. */ export interface MultiSelectSpec { /** Headline shown above the list. */ title: string; /** Concise identity shown in the shared root chrome. */ readonly view?: string; /** Optional supporting text between the title and the list. */ detail?: string; /** The offered rows; an empty list is a programming error and renders as such. */ choices: readonly SelectChoice[]; /** * Opens the editor behind the `Other…` row, which exists only when this is * given. Resolves with the committed text — an empty string clears an * existing supplement — or with undefined when the reader backed out, which * keeps what was there. */ editCustom?(current: string): Promise; /** * Called once with the confirmed answer, or with undefined when the user * cancelled. The overlay never calls this twice. */ settle(answer: MultiSelectAnswer | undefined): void; /** Asks the runner to redraw after a move, a toggle, or a committed edit. */ invalidate(): void; } /** * Build a multi-select overlay. * @param spec - the prompt, the offered rows, and the settlement callback. * @returns the overlay to push onto the slot registry. */ export declare function createMultiSelectOverlay(spec: MultiSelectSpec): TuiOverlay; /** * Show a multi-select list and wait for the answer. * * The twin of `promptSelect` in `./select.ts`: same push-await-dismiss dance, * same once-only settlement, so a caller alternating between picking one and * picking many writes the same three lines for both. The optional `signal` * takes the question down without an answer, for a caller whose request can * stop being worth asking. * @param ctx - context carrying the slot registry. * @param spec - the prompt and its choices; settlement is this function's. * @returns the confirmed answer, or undefined when the user cancelled or the * question was withdrawn. */ export declare function promptMultiSelect(ctx: Context, spec: Omit & { signal?: AbortSignal; }): Promise; //# sourceMappingURL=multiselect.d.ts.map