/** * KHAELOR * File: src/tui/components/error-panel.ts * Description: Error presentation per CLAUDE.md §17 — what failed, where, what happens next; never a bare "command failed". * * Author: Simon-Pierre Boucher * Contact: contact@spboucher.ai */ import { truncateAnsi } from "../renderer/ansi.js"; import type { Theme } from "../theme.js"; export interface ErrorPanelData { /** What failed, concretely: `npm test failed`. */ title: string; /** The specifics: counts, files, failing test names. */ detailLines?: string[]; /** What happens next, e.g. `KHAELOR is inspecting the failure.` */ followUp?: string; } /** * Settled error block: * * npm test failed * 2 tests failed * src/context/engine.test.ts * context compaction preserves running processes * KHAELOR is inspecting the failure. */ export function renderErrorPanel(data: ErrorPanelData, width: number, theme: Theme): string[] { const out: string[] = [truncateAnsi(" " + theme.paint("error", data.title), width)]; for (const line of data.detailLines ?? []) { out.push(truncateAnsi(" " + line, width)); } if (data.followUp !== undefined) { out.push(truncateAnsi(" " + theme.paint("dim", data.followUp), width)); } return out; }