/** Width-safe styled physical rows for bounded terminal panels. */ import { type TranscriptEntry } from './projection.ts'; import { type MdStyle } from './markdown.ts'; /** Presentation classes mapped to Ink colors by the app boundary. */ export type LineStyle = MdStyle | 'brand' | 'success' | 'error' | 'warn' | 'dimItalic' | 'diffAdd' | 'diffDel' | 'promptRow' | 'promptQueuedRow' | 'promptSteeredRow'; /** One styled run within a physical terminal row. */ export interface StyledSegment { text: string; style: LineStyle; } /** One row guaranteed not to exceed the requested terminal width. */ export interface StyledLine { segments: readonly StyledSegment[]; } /** Construct one segment without leaking mutable objects into cached rows. */ export declare function lineSegment(text: string, style?: LineStyle): StyledSegment; /** * Classify one unified-diff row for coloring: additions and deletions carry * the diff tint styles (background on rich terminals), hunk headers and file * markers stay brand-blue, and everything else is dim context. */ export declare function diffLineStyle(line: string): LineStyle; /** * Extend pure diff-tinted rows to the full width with same-styled padding so * the tint reads as one unbroken bar (GitHub-style), including wrapped * continuation rows; mixed or non-diff rows pass through untouched. */ export declare function fillDiffLineBars(lines: readonly StyledLine[], columns: number): readonly StyledLine[]; /** * Sanitize and hard-wrap styled content into exact physical rows. * Tabs become two visible spaces because terminal tab stops are contextual * and therefore cannot participate in a deterministic row budget. */ export declare function styledLines(segments: readonly StyledSegment[], columns: number): readonly StyledLine[]; /** Plain/dim text convenience over {@link styledLines}. */ export declare function textLines(text: string, columns: number, style?: LineStyle): readonly StyledLine[]; /** Markdown rows re-hardened so a single long word cannot escape the budget. */ export declare function markdownLines(text: string, columns: number): readonly StyledLine[]; /** * Codex-style reasoning rows: the marker occupies the reply gutter and every * wrapped or explicit continuation starts with the same two-column indent, so * reasoning content and assistant Markdown share one left edge. */ export declare function reasoningLines(text: string, columns: number): readonly StyledLine[]; /** * Style the lines of one user prompt for display: plain verbatim, except * inside ```diff / ```patch fences where added and removed lines take the * shared diff tints (the review prompt pastes its diff this way, and the * user row does not go through the markdown renderer). The fence markers * and file headers stay plain. */ export declare function userPromptSegments(text: string): readonly StyledSegment[]; /** * Convert one durable transcript entry to its complete scrollable row model. * The source entry stays intact; only the caller's visible slice is rendered. * Wrapped continuations keep a hanging indent aligned under each row's * content (Codex history-cell alignment) instead of resetting to column 0. */ export declare function transcriptEntryLines(entry: TranscriptEntry, columns: number, showReasoning?: boolean, reasoningToggleHint?: boolean, showToolDetails?: boolean): readonly StyledLine[]; /** Settled-history variant carrying the Ctrl+R reasoning fold. */ export declare function settledEntryLines(entry: TranscriptEntry, columns: number, showReasoning: boolean): readonly StyledLine[]; /** The flexible rows of the live region; chrome (composer/notice/status) is never reduced. */ export interface LiveAllocation { /** Settled tail rows currently rendered in the live tree. */ readonly live: number; /** Rows reserved for the streaming reasoning tail or its marker. */ readonly reasoning: number; /** Rows reserved for the streaming answer tail. */ readonly answer: number; } /** A clamped allocation plus the invariant-trip warning that triggered it. */ export interface LiveAllocationAudit { readonly allocation: LiveAllocation; readonly warning?: string; } /** * Clamp the live-region allocation so the flexible dynamic rows never exceed * the post-chrome budget. By construction the caller derives these rows from * the same budget; this is the runtime tripwire for a future edit that breaks * that derivation. Reduction order: answer first (the freshest content is the * live tail), then reasoning, then settled live rows; nothing goes negative. * @param allocation - the intended row allocation. * @param dynamicRows - the post-chrome row budget. * @returns the clamped allocation and a warning string when clamping fired. */ export declare function clampLiveAllocation(allocation: LiveAllocation, dynamicRows: number): LiveAllocationAudit;