Fat-prompt state, visual model, and byte templates.
This module owns the policy for prompt chrome: prompt rows, token bar, thinking ticker state, spacing, receipts, and the visual frame model used by tests. It may construct ANSI byte templates for those prompt frames, but it does not write them. terminal.nim is the only module that serializes those bytes to the terminal.
Types
BashViewport = object active*: bool idx*: int lines*: seq[string] maxLines*: int
FatPrompt = object width*: int height*: int scrollback*: seq[string] editorText*: string editorCursor*: int tokenBar*: TokenBarState ticker*: string bash*: BashViewport
FatPromptEvent = object case kind*: FatPromptEventKind of fpeSetPromptMode: promptMode*: PromptMode of fpeSetBar: barLabel*: string barHasGap*: bool of fpeSetTicker: ticker*: string of fpeSetPendingHint: usage*: Usage window*: int elapsed*: int of fpeClearBar, fpeClearTicker, fpeClearPendingHint: nil
FatPromptEventKind = enum fpeSetPromptMode, fpeSetBar, fpeClearBar, fpeSetTicker, fpeClearTicker, fpeSetPendingHint, fpeClearPendingHint
FatPromptGeometry = object tickerRows*: int hasBar*: bool barRows*: int editorRows*: int reservedRows*: int
- Width-aware size of the volatile fat-prompt area.
FatPromptState = object footer*: FooterState
PendingHint = object active*: bool usage*: Usage window*: int elapsed*: int
PromptMarker = enum pmUser, pmAssistant, pmBash, pmRead, pmWrite, pmPatch, pmOther
PromptMode = enum pmIdle, pmTurnRunning, pmBufferedInput
TokenBarState = object usage*: Usage window*: int apiActive*: bool spinner*: string elapsedS*: int
Consts
ClearBarBelowBytes = "\n\r\e[J\e[1A\e[3G"
ClearBarPromptBytes = "\r\e[J"
DefaultHeight = 24
DefaultWidth = 80
DeferredSubmitMarker = "⧖"
EditorPromptBytes = "❯ "
Procs
proc absoluteBarTickFrame(row: int; label: string; activeEditor: bool; termW = 0): string {. ...raises: [], tags: [], forbids: [].}
proc addScrollLine(p: var FatPrompt; line: string) {....raises: [], tags: [], forbids: [].}
proc addTranscriptItem(p: var FatPrompt; marker: PromptMarker; body: string; receipt = "") {....raises: [], tags: [], forbids: [].}
- Append one transcript item using the spacing contract. There is exactly one blank visual row between items, and no blank row between body and token receipt.
proc apply(s: var FatPromptState; ev: FatPromptEvent) {....raises: [], tags: [], forbids: [].}
proc barWrapRows(visibleCells, termW: int): int {....raises: [], tags: [], forbids: [].}
proc bashVisibleRows(p: FatPrompt): seq[string] {....raises: [], tags: [], forbids: [].}
proc clampToWidth(s: string; width: int): string {....raises: [], tags: [], forbids: [].}
- Truncate s (which may contain ANSI CSI escapes) so its visible width fits in width cells. Escapes are preserved; once the accumulated visible width reaches width the remainder is dropped.
proc clearBarBelowAtColBytes(col: int): string {....raises: [], tags: [], forbids: [].}
proc clearBarEvent(): FatPromptEvent {....raises: [], tags: [], forbids: [].}
proc clearBarRowBytes(): string {....raises: [], tags: [], forbids: [].}
proc clearPendingHintEvent(): FatPromptEvent {....raises: [], tags: [], forbids: [].}
proc clearPromptAfterPendingReceiptBytes(): string {....raises: [], tags: [], forbids: [].}
proc clearTickerEvent(): FatPromptEvent {....raises: [], tags: [], forbids: [].}
proc editorHeight(p: FatPrompt): int {....raises: [], tags: [], forbids: [].}
proc editorRows(p: FatPrompt): seq[string] {....raises: [], tags: [], forbids: [].}
proc endTurnBytes(label: string; repaintPrompt: bool; termW = 0; gapAlready = false): string {....raises: [], tags: [], forbids: [].}
proc finishBash(p: var FatPrompt; code = 0; elapsedS = -1) {....raises: [], tags: [], forbids: [].}
- Commit the final bash tool item exactly once, replacing the live viewport.
proc formatUserPromptItem(line: string): string {....raises: [], tags: [ReadEnvEffect], forbids: [].}
- Format a user prompt as a scrollback item body. No trailing separator is included; the controller/transcript emitter owns inter-item spacing.
proc hasElapsedSuffix(label: string): bool {....raises: [], tags: [], forbids: [].}
proc hasNonNewlineBytes(s: string): bool {....raises: [], tags: [], forbids: [].}
proc hideRealCaretBytes(): string {....raises: [], tags: [], forbids: [].}
proc initFatPrompt(width = DefaultWidth; height = DefaultHeight; window = 0): FatPrompt {. ...raises: [], tags: [], forbids: [].}
proc initFatPromptState(): FatPromptState {....raises: [], tags: [], forbids: [].}
proc labelCells(label: string): int {....raises: [], tags: [], forbids: [].}
proc liveBarBytes(label: string): string {....raises: [], tags: [], forbids: [].}
proc liveEditorBarTickFrame(label: string): string {....raises: [], tags: [], forbids: [].}
proc liveEditorSpinnerBarBytes(frame, label: string; elapsed: int): string {. ...raises: [], tags: [], forbids: [].}
proc moveToBarBelowBytes(): string {....raises: [], tags: [], forbids: [].}
proc paintBarBytes(label: string): string {....raises: [], tags: [], forbids: [].}
proc promptOnlyBytes(): string {....raises: [], tags: [], forbids: [].}
proc promptOnlyResetBytes(): string {....raises: [], tags: [], forbids: [].}
proc pushBashOutput(p: var FatPrompt; line: string) {....raises: [], tags: [], forbids: [].}
proc receiptBarBytes(label: string): string {....raises: [], tags: [], forbids: [].}
proc setBarEvent(label: string; hasGap = false): FatPromptEvent {....raises: [], tags: [], forbids: [].}
proc setPendingHintEvent(usage: Usage; window, elapsed: int): FatPromptEvent {. ...raises: [], tags: [], forbids: [].}
proc setPromptModeEvent(mode: PromptMode): FatPromptEvent {....raises: [], tags: [], forbids: [].}
proc setTickerEvent(ticker: string): FatPromptEvent {....raises: [], tags: [], forbids: [].}
proc setTokenBar(p: var FatPrompt; usage: Usage; window: int; apiActive = false; spinner = ""; elapsedS = -1) {....raises: [], tags: [], forbids: [].}
proc spinnerBarBytes(frame, label: string; elapsed: int): string {....raises: [], tags: [], forbids: [].}
proc spinnerCleanupBytes(tickerRows = 1): string {....raises: [], tags: [], forbids: [].}
proc tokenBarFrame(label: string; ticker = ""): FooterFrame {....raises: [], tags: [], forbids: [].}
proc tokenBarRows(s: FatPromptState; termW = 0): int {....raises: [], tags: [], forbids: [].}
- Number of terminal rows occupied by the current token bar.
proc tokenBarText(state: TokenBarState): string {....raises: [], tags: [], forbids: [].}