@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
77 lines • 3.81 kB
TypeScript
/**
* Pure interaction state for the ask-user question overlay.
*
* Owns per-question selections, own-answer texts, the active tab, the
* highlighted row and the response-building rules. Rendering and key decoding
* live in ask-user-question.ts; this module must stay free of pi-tui imports
* so the rules are unit-testable headless.
*/
import type { QuestionRequest, QuestionResponse } from "../../../core/extensions/types.ts";
export type QuestionAnswers = QuestionResponse["answers"];
export type QuestionDraft = {
answers?: QuestionAnswers;
comment?: string;
};
export type QuestionFocus = "options" | "own-answer" | "submit";
export declare const COMMENT_LABEL = "Comment (optional; unanswered questions are reported)";
export declare const OWN_ANSWER_LABEL = "Type your own answer...";
export declare const NOT_ANSWERED_NOTICE = "You have not answered all questions";
export declare const DISMISS_NOTICE = "Press Esc again to dismiss (answers will be discarded)";
export declare const PARTIAL_SUBMIT_NOTICE = "Press Enter again to submit with unanswered questions";
/** Countdown chip label: minutes above five minutes, mm:ss at or below. */
export declare function formatCountdownLabel(remainingMs: number): string;
export declare class AskUserQuestionState {
readonly request: QuestionRequest;
activeIndex: number;
highlightIndex: number;
focus: QuestionFocus;
/** Highlighted row on the Submit tab: a review row per question, then the comment editor. */
submitRowIndex: number;
notice: string | undefined;
comment: string | undefined;
private dismissPending;
private readonly selected;
private readonly texts;
constructor(request: QuestionRequest);
get activeQuestion(): QuestionRequest["questions"][number];
/** Highlightable rows for the active question: options plus the own-answer row. */
get ownAnswerRowIndex(): number;
get rowCount(): number;
get activeTabIndex(): number;
get commentRowIndex(): number;
get isCommentFocused(): boolean;
switchQuestion(delta: number): void;
switchTab(delta: number): void;
advance(): void;
jumpToQuestion(index: number): void;
enterSubmit(): void;
returnToOptions(): void;
/** Close the own-answer editor and highlight `row` of the active question. */
leaveOwnAnswer(row: number): void;
/** Move the Submit-tab highlight by `delta`, clamped to the review rows and the comment editor. */
moveSubmitRow(delta: number): void;
focusComment(): void;
private clearTransient;
requestDismiss(): "confirm" | "cancel";
acceptPartialSubmit(): void;
private hasDraft;
selectedFor(questionId: string): string[];
textFor(questionId: string): string | undefined;
isSelected(questionId: string, label: string): boolean;
isAnswered(questionId: string): boolean;
answeredCount(): number;
/** Select (single) or toggle (multi) an option of the active question. */
activateOption(questionId: string, label: string): void;
/** Replace the question's answer with typed text; empty text is a no-op so existing option selections survive. */
setOwnAnswer(questionId: string, text: string): void;
clearAnswer(questionId: string): void;
/** Seed selections, own texts and the comment from a previously captured draft. */
restoreDraft(draft: QuestionDraft): void;
answers(): QuestionAnswers;
unanswered(): string[];
/** Submit outcome: comment wins, then answers; undefined means stay open. */
submitOutcome(forcePartial?: boolean): "answered" | "comment-submitted" | undefined;
buildResponse(status: QuestionResponse["status"], autoResolvedAfterMs?: number): QuestionResponse;
refreshDraft(): QuestionDraft;
}
//# sourceMappingURL=ask-user-question-state.d.ts.map