import type { ExtensionContext } from "@earendil-works/pi-coding-agent"; import type { UiState } from "./types"; export const STATUS_KEY = "llmiterate"; export function renderLlmiterateStatus( ctx: ExtensionContext | undefined, state: UiState, ): void { if (!ctx?.hasUI) return; ctx.ui.setStatus(STATUS_KEY, statusLine(ctx, state)); } function statusLine(ctx: ExtensionContext, state: UiState): string | undefined { if (!state.config) return undefined; if (!state.config.enabled) return undefined; const theme = ctx.ui.theme; if (state.lockError) return theme.fg("dim", "llmiterate standby"); if (state.watchErrors > 0) return theme.fg( "warning", `llmiterate ${state.watchErrors} watch error(s)`, ); if (state.activeRun) return theme.fg( "accent", `llmiterate ${state.activeRun.status} ${state.activeRun.block.file}:${state.activeRun.block.startLine}`, ); if (state.queuedRuns > 0) return theme.fg("warning", `llmiterate queued ${state.queuedRuns}`); return theme.fg("dim", "llmiterate watching ."); }