repositories / pi-ext
pi-ext
bugabingas pi extensions
owned by bugabinga
extensions/iq/ui.ts
RawFile outline
- DashboardTab line 24
- DashboardAction line 30
- DashboardData line 32
- judge line 33
- judgeIsSessionFallback line 34
- stateDirectory line 35
- leaderboard line 36
- archetypes line 37
- agreements line 38
- records line 39
- checks line 40
- telemetry line 41
- pending line 42
- unranked line 43
- storageErrors line 44
- ARCHETYPE_TAGS line 47
- ScanDisplayState line 55
- phase line 56
- model line 57
- candidateModel line 58
- judgeModel line 59
- currentName line 60
- session line 61
- sessions line 62
- chunk line 63
- chunks line 64
- evidence line 65
- cost line 66
- failures line 67
- lastFailure line 68
- counterModel line 69
- startedAt line 70
- ProgressOutcome line 73
- value line 74
- error line 75
- cancelled line 76
- runProgress line 80
- finish line 92
- TABS line 110
- SPINNER line 117
- padRight line 119
- padLeft line 124
- joinEnds line 129
- dateLabel line 135
- scoreColor line 141
- scoreLabel line 148
- windowed line 152
- IqDashboardComponent line 166
- tab line 167
- selectedModel line 168
- selectedSession line 169
- expanded line 170
- constructor line 172
- handleInput line 179
- render line 231
- renderHeader line 256
- renderTabs line 279
- renderLeaderboard line 289
- archetypeTag line 297
- renderWideLeaderboard line 304
- renderNarrowLeaderboard line 330
- renderModelDetail line 355
- renderArchetypeDetail line 385
- renderSessions line 411
- renderChecks line 466
- renderTelemetry line 521
- renderMethod line 558
- invalidate line 599
- dispose line 600
- IqScanComponent line 603
- abortController line 604
- timer line 605
- constructor line 607
- signal line 616
- handleInput line 620
- render line 624
- invalidate line 669
- dispose line 673
import type {
ExtensionCommandContext,
Theme,
} from "@earendil-works/pi-coding-agent";
import {
matchesKey,
type TUI,
truncateToWidth,
visibleWidth,
wrapTextWithAnsi,
} from "@earendil-works/pi-tui";
import type { CheckSummary } from "./check/summary.js";
import {
ARCHETYPE_WEIGHTS,
asError,
DIMENSIONS,
type JudgeAgreement,
type ModelAggregate,
type ModelArchetypes,
type SessionScoreRecord,
type TelemetryAggregate,
} from "./core.js";
export type DashboardTab =
| "leaderboard"
| "sessions"
| "checks"
| "telemetry"
| "method";
export type DashboardAction = "scan" | "check" | undefined;
export interface DashboardData {
judge: string;
judgeIsSessionFallback: boolean;
stateDirectory: string;
leaderboard: ModelAggregate[];
archetypes: ModelArchetypes[];
agreements: JudgeAgreement[];
records: SessionScoreRecord[];
checks: CheckSummary[];
telemetry: TelemetryAggregate[];
pending: number;
unranked: number;
storageErrors: number;
}
const ARCHETYPE_TAGS: Record<string, string> = {
agentic: "AGT",
worker: "WRK",
texter: "TXT",
generalist: "GEN",
unrated: "·",
};
export interface ScanDisplayState {
phase: "prepare" | "judge" | "check";
model: string;
candidateModel?: string;
judgeModel?: string;
currentName: string;
session: number;
sessions: number;
chunk: number;
chunks: number;
evidence: number;
cost: number;
failures: number;
lastFailure?: string;
counterModel?: string;
startedAt: number;
}
export interface ProgressOutcome<T> {
value?: T;
error?: Error;
cancelled: boolean;
}
/** Runs scan/check work inside the progress overlay; Esc cancels. */
export async function runProgress<T>(
ctx: ExtensionCommandContext,
state: ScanDisplayState,
work: (
signal: AbortSignal,
state: ScanDisplayState,
requestRender: () => void,
) => Promise<T>,
): Promise<ProgressOutcome<T>> {
return ctx.ui.custom<ProgressOutcome<T>>((tui, theme, _keybindings, done) => {
const component = new IqScanComponent(tui, theme, state);
let finished = false;
const finish = (outcome: ProgressOutcome<T>) => {
if (finished) return;
finished = true;
component.dispose();
done(outcome);
};
void work(component.signal, state, () => tui.requestRender())
.then((value) => finish({ value, cancelled: false }))
.catch((error: unknown) =>
finish({
error: asError(error),
cancelled: component.signal.aborted,
}),
);
return component;
});
}
const TABS: DashboardTab[] = [
"leaderboard",
"sessions",
"checks",
"telemetry",
"method",
];
const SPINNER = ["◐", "◓", "◑", "◒"] as const;
function padRight(text: string, width: number): string {
const truncated = truncateToWidth(text, Math.max(0, width));
return truncated + " ".repeat(Math.max(0, width - visibleWidth(truncated)));
}
function padLeft(text: string, width: number): string {
const truncated = truncateToWidth(text, Math.max(0, width));
return " ".repeat(Math.max(0, width - visibleWidth(truncated))) + truncated;
}
function joinEnds(left: string, right: string, width: number): string {
if (visibleWidth(left) + visibleWidth(right) + 1 > width)
return truncateToWidth(left, width);
return `${left}${" ".repeat(width - visibleWidth(left) - visibleWidth(right))}${right}`;
}
function dateLabel(timestamp: string): string {
const date = new Date(timestamp);
if (Number.isNaN(date.valueOf())) return "?";
return date.toLocaleDateString("en-US", { month: "short", day: "numeric" });
}
function scoreColor(theme: Theme, score: number, text: string): string {
if (score >= 115) return theme.fg("success", text);
if (score >= 100) return theme.fg("accent", text);
if (score >= 85) return theme.fg("warning", text);
return theme.fg("error", text);
}
function scoreLabel(score: number | null): string {
return score === null ? "?" : score.toFixed(1);
}
function windowed<T>(
items: readonly T[],
selected: number,
maximum: number,
): T[] {
if (items.length <= maximum) return [...items];
const half = Math.floor(maximum / 2);
const start = Math.min(
Math.max(0, selected - half),
Math.max(0, items.length - maximum),
);
return items.slice(start, start + maximum);
}
export class IqDashboardComponent {
private tab: DashboardTab = "leaderboard";
private selectedModel = 0;
private selectedSession = 0;
private expanded = true;
constructor(
private readonly theme: Theme,
private readonly data: DashboardData,
private readonly requestRender: () => void,
private readonly done: (action: DashboardAction) => void,
) {}
handleInput(input: string): void {
if (matchesKey(input, "escape") || matchesKey(input, "q")) {
this.done(undefined);
return;
}
if (matchesKey(input, "s")) {
this.done("scan");
return;
}
if (matchesKey(input, "c")) {
this.done("check");
return;
}
if (matchesKey(input, "tab") || matchesKey(input, "right")) {
const index = TABS.indexOf(this.tab);
this.tab = TABS[(index + 1) % TABS.length] ?? this.tab;
this.requestRender();
return;
}
if (matchesKey(input, "shift+tab") || matchesKey(input, "left")) {
const index = TABS.indexOf(this.tab);
this.tab = TABS[(index - 1 + TABS.length) % TABS.length] ?? this.tab;
this.requestRender();
return;
}
const maximum =
this.tab === "leaderboard"
? this.data.leaderboard.length
: this.tab === "sessions"
? this.data.records.length
: 0;
if (matchesKey(input, "up") && maximum > 0) {
if (this.tab === "leaderboard")
this.selectedModel = Math.max(0, this.selectedModel - 1);
else this.selectedSession = Math.max(0, this.selectedSession - 1);
this.requestRender();
return;
}
if (matchesKey(input, "down") && maximum > 0) {
if (this.tab === "leaderboard")
this.selectedModel = Math.min(maximum - 1, this.selectedModel + 1);
else
this.selectedSession = Math.min(maximum - 1, this.selectedSession + 1);
this.requestRender();
return;
}
if (matchesKey(input, "enter") || matchesKey(input, "space")) {
this.expanded = !this.expanded;
this.requestRender();
}
}
render(width: number): string[] {
const safeWidth = Math.max(1, width);
const lines = [
...this.renderHeader(safeWidth),
...this.renderTabs(safeWidth),
...(this.tab === "leaderboard"
? this.renderLeaderboard(safeWidth)
: this.tab === "sessions"
? this.renderSessions(safeWidth)
: this.tab === "checks"
? this.renderChecks(safeWidth)
: this.tab === "telemetry"
? this.renderTelemetry(safeWidth)
: this.renderMethod(safeWidth)),
"",
this.theme.fg(
"dim",
safeWidth >= 72
? "Tab/←→ view · ↑↓ select · Enter detail · s scan · c check · q close"
: "Tab · ↑↓ · Enter · s scan · c check · q close",
),
];
return lines.map((line) => truncateToWidth(line, safeWidth));
}
private renderHeader(width: number): string[] {
const title = `${this.theme.fg("accent", this.theme.bold("IQ"))} ${this.theme.fg("dim", "personal work ability")}`;
const statusParts = this.data.pending
? [`${this.data.pending} unscored`]
: ["all scoreable sessions scored"];
if (this.data.unranked) statusParts.push(`${this.data.unranked} unranked`);
const statusText = statusParts.join(" · ");
const status = this.data.pending
? this.theme.fg("warning", statusText)
: this.theme.fg("dim", statusText);
const sharedLine = visibleWidth(title) + visibleWidth(status) + 1 <= width;
const lines = [sharedLine ? joinEnds(title, status, width) : title];
if (!sharedLine) lines.push(status);
if (this.data.storageErrors)
lines.push(
this.theme.fg(
"error",
`${this.data.storageErrors} unreadable persisted record${this.data.storageErrors === 1 ? "" : "s"}`,
),
);
return [...lines, ""];
}
private renderTabs(width: number): string[] {
const tabs = TABS.map((tab) => {
const label = tab.toUpperCase();
return tab === this.tab
? this.theme.fg("accent", `[${label}]`)
: this.theme.fg("dim", ` ${label} `);
}).join(width >= 44 ? " " : " ");
return [tabs, ""];
}
private renderLeaderboard(width: number): string[] {
if (this.data.leaderboard.length === 0)
return [this.theme.fg("dim", "No scored sessions. Press s to scan.")];
return width >= 72
? this.renderWideLeaderboard(width)
: this.renderNarrowLeaderboard(width);
}
private archetypeTag(model: string): string {
const found = this.data.archetypes.find(
(entry) => entry.model === model,
)?.label;
return found ? (ARCHETYPE_TAGS[found] ?? "·") : "·";
}
private renderWideLeaderboard(width: number): string[] {
const modelWidth = Math.max(20, width - 41);
const lines = [
this.theme.fg(
"muted",
`${padRight("MODEL", modelWidth)}${padLeft("TYPE", 6)}${padLeft("IQ", 8)}${padLeft("N", 5)}${padLeft("SPAN", 10)}${padLeft("LAST", 12)}`,
),
this.theme.fg("border", "─".repeat(Math.min(width, modelWidth + 41))),
];
const visible = windowed(this.data.leaderboard, this.selectedModel, 10);
const first = this.data.leaderboard.indexOf(visible[0] as ModelAggregate);
for (let offset = 0; offset < visible.length; offset++) {
const model = visible[offset];
if (!model) continue;
const selected = first + offset === this.selectedModel;
const marker = selected ? "▸ " : " ";
const name = `${marker}${model.model}`;
const row = `${padRight(name, modelWidth)}${padLeft(this.archetypeTag(model.model), 6)}${padLeft(model.score.toFixed(1), 8)}${padLeft(String(model.sessions), 5)}${padLeft(`${model.minimum.toFixed(0)}–${model.maximum.toFixed(0)}`, 10)}${padLeft(dateLabel(model.lastScoredAt), 12)}`;
lines.push(
selected ? this.theme.fg("accent", row) : truncateToWidth(row, width),
);
}
if (this.expanded) lines.push("", ...this.renderModelDetail(width));
return lines;
}
private renderNarrowLeaderboard(width: number): string[] {
const lines: string[] = [
this.theme.fg("border", "─".repeat(Math.max(1, width - 2))),
];
const visible = windowed(this.data.leaderboard, this.selectedModel, 6);
const first = this.data.leaderboard.indexOf(visible[0] as ModelAggregate);
for (let offset = 0; offset < visible.length; offset++) {
const model = visible[offset];
if (!model) continue;
const selected = first + offset === this.selectedModel;
lines.push(
(selected ? this.theme.fg("accent", "▸ ") : " ") +
(selected
? this.theme.fg("accent", truncateToWidth(model.model, width - 2))
: truncateToWidth(model.model, width - 2)),
);
lines.push(
` ${scoreColor(this.theme, model.score, model.score.toFixed(1))} · ${model.sessions} session${model.sessions === 1 ? "" : "s"} · ${model.minimum.toFixed(0)}–${model.maximum.toFixed(0)}`,
"",
);
}
if (this.expanded) lines.push(...this.renderModelDetail(width));
return lines;
}
private renderModelDetail(width: number): string[] {
const selected = this.data.leaderboard[this.selectedModel];
if (!selected) return [];
const title = `${this.theme.bold(selected.model)} · ${scoreColor(this.theme, selected.score, selected.score.toFixed(1))}`;
const parts = DIMENSIONS.map((dimension) => {
const score = selected.dimensions[dimension.name];
return `${dimension.label} ${scoreLabel(score)}`;
});
const lines = [title];
if (width >= 76) {
lines.push(this.theme.fg("dim", parts.slice(0, 3).join(" · ")));
lines.push(this.theme.fg("dim", parts.slice(3).join(" · ")));
} else {
lines.push(
...wrapTextWithAnsi(
this.theme.fg("dim", parts.join(" · ")),
Math.max(1, width),
),
);
}
lines.push(
this.theme.fg(
"dim",
`${selected.evidence} cited observations · equal session weighting`,
),
);
lines.push(...this.renderArchetypeDetail(selected.model, width));
return lines;
}
private renderArchetypeDetail(model: string, width: number): string[] {
const found = this.data.archetypes.find((entry) => entry.model === model);
if (!found) return [];
const lines: string[] = [];
for (const cell of found.cells) {
const parts = [
`${cell.archetype} ${cell.quality.toFixed(1)}`,
cell.fit === null ? "fit ?" : `fit ${cell.fit.toFixed(0)}`,
cell.outputTokensPerSecond === null
? "? tok/s"
: `${cell.outputTokensPerSecond.toFixed(0)} tok/s`,
cell.costPerSession === null
? "? $"
: `$${cell.costPerSession.toFixed(3)}/session`,
`${cell.sessions} session${cell.sessions === 1 ? "" : "s"}`,
];
lines.push(
...wrapTextWithAnsi(
this.theme.fg("dim", parts.join(" · ")),
Math.max(1, width),
),
);
}
return lines;
}
private renderSessions(width: number): string[] {
if (this.data.records.length === 0)
return [this.theme.fg("dim", "No scored sessions.")];
const visible = windowed(this.data.records, this.selectedSession, 10);
const first = this.data.records.indexOf(visible[0] as SessionScoreRecord);
const lines: string[] = [];
if (width >= 72) {
const nameWidth = Math.max(16, width - 36);
lines.push(
this.theme.fg(
"muted",
`${padRight("SESSION", nameWidth)}${padLeft("IQ", 8)}${padLeft("EVENTS", 9)}${padLeft("MODEL", 19)}`,
),
this.theme.fg("border", "─".repeat(width)),
);
for (let offset = 0; offset < visible.length; offset++) {
const record = visible[offset];
if (!record) continue;
const selected = first + offset === this.selectedSession;
const name = record.source.name || record.source.sessionId || "unnamed";
const model = record.source.model?.split("/").at(-1) ?? "?";
const row = `${padRight(`${selected ? "▸" : " "} ${name}`, nameWidth)}${padLeft(scoreLabel(record.score.overall), 8)}${padLeft(String(record.observations.length), 9)}${padLeft(model, 19)}`;
lines.push(selected ? this.theme.fg("accent", row) : row);
}
} else {
for (let offset = 0; offset < visible.length; offset++) {
const record = visible[offset];
if (!record) continue;
const selected = first + offset === this.selectedSession;
const name = record.source.name || record.source.sessionId || "unnamed";
lines.push(
`${selected ? this.theme.fg("accent", "▸") : " "} ${truncateToWidth(name, width - 2)}`,
` ${scoreLabel(record.score.overall)} · ${record.observations.length} observations · ${dateLabel(record.scoredAt)}`,
"",
);
}
}
if (this.expanded) {
const selected = this.data.records[this.selectedSession];
if (selected)
lines.push(
"",
this.theme.bold(selected.source.name || selected.source.sessionId),
...wrapTextWithAnsi(
this.theme.fg(
"dim",
`${selected.source.model ?? "unknown model"} · ${selected.source.userMessages} user turns · ${selected.source.toolResults} tool results · judge ${selected.judge}`,
),
Math.max(1, width),
),
);
}
return lines;
}
private renderChecks(width: number): string[] {
if (this.data.checks.length === 0)
return [
this.theme.fg(
"dim",
"No check runs yet. Press c to check the current model.",
),
];
const lines: string[] = [];
for (const summary of this.data.checks) {
const estimate = summary.estimate?.overall;
let passed = 0;
let totalChecks = 0;
for (const task of summary.tasks) {
passed += task.acceptancePassed;
totalChecks += task.acceptanceTotal;
}
const head =
estimate !== undefined && estimate !== null
? scoreColor(this.theme, estimate, `est ${estimate.toFixed(0)}`)
: this.theme.fg("dim", "uncalibrated");
lines.push(
`${this.theme.bold(truncateToWidth(summary.model, width - 2))} · ${head} · acceptance ${passed}/${totalChecks}`,
);
const states = summary.tasks
.map(
(task) =>
`${task.state === "complete" ? "✓" : "·"} ${task.id} ${task.acceptancePassed}/${task.acceptanceTotal}`,
)
.join(" · ");
lines.push(
...wrapTextWithAnsi(this.theme.fg("dim", states), Math.max(1, width)),
);
if (summary.validation) {
const deltas = DIMENSIONS.filter(
(d) =>
summary.validation?.predicted[d.name] !== null &&
summary.validation?.historical[d.name] !== null,
).map(
(d) =>
`${d.label} ${summary.validation?.predicted[d.name]?.toFixed(0)} vs ${(summary.validation?.historical[d.name] ?? 0).toFixed(0)}`,
);
if (deltas.length)
lines.push(
...wrapTextWithAnsi(
this.theme.fg("dim", `check vs history: ${deltas.join(" · ")}`),
Math.max(1, width),
),
);
}
lines.push("");
}
return lines;
}
private renderTelemetry(width: number): string[] {
if (this.data.telemetry.length === 0)
return [
this.theme.fg("dim", "No telemetry yet. Score sessions with /iq scan."),
];
const lines: string[] = [];
if (width >= 72) {
const modelWidth = Math.max(18, width - 58);
lines.push(
this.theme.fg(
"muted",
`${padRight("MODEL", modelWidth)}${padLeft("N", 4)}${padLeft("TURNS", 7)}${padLeft("TOOLS", 7)}${padLeft("EDITS", 7)}${padLeft("OUT/SESS", 10)}${padLeft("CACHE", 7)}${padLeft("MS", 7)}${padLeft("TOK/S", 8)}`,
),
this.theme.fg("border", "─".repeat(width)),
);
for (const row of this.data.telemetry) {
const line = `${padRight(truncateToWidth(row.model, modelWidth), modelWidth)}${padLeft(String(row.sessions), 4)}${padLeft(row.meanTurns.toFixed(0), 7)}${padLeft(row.meanToolCalls.toFixed(0), 7)}${padLeft(`${row.editShare.toFixed(0)}%`, 7)}${padLeft(String(Math.round(row.meanOutputTokens)), 10)}${padLeft(`${row.cacheReadShare.toFixed(0)}%`, 7)}${padLeft(row.meanLatencyMs ? String(Math.round(row.meanLatencyMs)) : "?", 7)}${padLeft(row.meanTokensPerSecond === null ? "?" : row.meanTokensPerSecond.toFixed(0), 8)}`;
lines.push(truncateToWidth(line, width));
}
} else {
for (const row of this.data.telemetry) {
lines.push(
this.theme.bold(truncateToWidth(row.model, width - 2)),
...wrapTextWithAnsi(
this.theme.fg(
"dim",
`${row.sessions} sessions · ${row.meanTurns.toFixed(0)} turns · ${row.meanToolCalls.toFixed(0)} tools · ${row.editShare.toFixed(0)}% edits · ${Math.round(row.meanOutputTokens)} out/session · ${row.cacheReadShare.toFixed(0)}% cache`,
),
Math.max(1, width),
),
"",
);
}
}
return lines;
}
private renderMethod(width: number): string[] {
const paragraphs = [
"The judge emits cited observations, never the final score.",
"Ratings: 1 severe · 2 weak · 3 competent · 4 strong · 5 exceptional.",
"Dimension score = 100 + 15 × (weighted mean rating − this judge's mean rating), so 100 is typical for this corpus and judge leniency cancels out.",
"Thin evidence is pulled toward that same mean, because anchoring on a fixed rating would turn long sessions into high scores.",
"Overall weights: judgment 25% · adaptation 25% · context 20% · reliability 20% · steerability 10%.",
"Sessions contribute equally to a model score. Mixed-model and trivial sessions remain unranked.",
`Archetypes come from session shape, not from the judge: fit mixes judged quality ${Math.round(ARCHETYPE_WEIGHTS.quality * 100)}%, measured speed ${Math.round(ARCHETYPE_WEIGHTS.speed * 100)}%, and current prices ${Math.round(ARCHETYPE_WEIGHTS.thrift * 100)}%, relative to the models present.`,
`Judge: ${this.data.judge}${this.data.judgeIsSessionFallback ? " (session model fallback, iq.judgeModel is unset)" : ""}`,
...(this.data.agreements.length
? this.data.agreements.map(
(agreement) =>
`Counter judge ${agreement.counter}: ${agreement.pairs} paired sessions, mean gap ${agreement.meanAbsolute.toFixed(1)}, bias ${agreement.bias > 0 ? "+" : ""}${agreement.bias.toFixed(1)}.`,
)
: [
"Counter judge: no paired sessions yet. Set iq.counterSampleRate or run /iq counter.",
]),
...this.data.agreements
.filter((agreement) => agreement.perModel.length > 0)
.map(
(agreement) =>
`Against ${agreement.counter} the judge differs most on: ${agreement.perModel
.slice(0, 3)
.map(
(entry) =>
`${entry.model} ${entry.bias > 0 ? "+" : ""}${entry.bias.toFixed(1)} (n=${entry.pairs})`,
)
.join(
" · ",
)}. A judge scoring its own family higher shows up here.`,
),
`State: ${this.data.stateDirectory}`,
];
const lines: string[] = [];
for (const paragraph of paragraphs) {
lines.push(...wrapTextWithAnsi(paragraph, Math.max(1, width)), "");
}
return lines;
}
invalidate(): void {}
dispose(): void {}
}
export class IqScanComponent {
private readonly abortController = new AbortController();
private readonly timer: ReturnType<typeof setInterval>;
constructor(
private readonly tui: TUI,
private readonly theme: Theme,
readonly state: ScanDisplayState,
) {
this.timer = setInterval(() => this.tui.requestRender(), 100);
this.timer.unref?.();
}
get signal(): AbortSignal {
return this.abortController.signal;
}
handleInput(input: string): void {
if (matchesKey(input, "escape")) this.abortController.abort();
}
render(width: number): string[] {
const safeWidth = Math.max(1, width);
const elapsed = Math.max(0, Date.now() - this.state.startedAt);
const spinner = SPINNER[Math.floor(elapsed / 100) % SPINNER.length] ?? "◐";
const phase =
this.state.phase === "prepare"
? "PREPARE"
: this.state.phase === "check"
? "CHECK"
: "JUDGE";
const progress = `${this.state.session}/${this.state.sessions}`;
const lines = [
`${this.theme.fg("accent", spinner)} ${this.theme.bold(`IQ ${phase}`)} · ${progress} · ${(elapsed / 1_000).toFixed(1)}s`,
truncateToWidth(
this.state.currentName || "Discovering sessions…",
safeWidth,
),
];
if (this.state.phase === "check") {
lines.push(
`step ${this.state.chunk}/${this.state.chunks} · evidence ${this.state.evidence}`,
`candidate ${this.state.candidateModel ?? this.state.model}`,
`judge ${this.state.judgeModel ?? this.state.model}`,
`cost $${this.state.cost.toFixed(3)}${this.state.failures ? ` · failures ${this.state.failures}` : ""}`,
);
if (this.state.lastFailure)
lines.push(this.theme.fg("error", this.state.lastFailure));
} else if (this.state.phase === "judge") {
lines.push(
`chunks ${this.state.chunk}/${this.state.chunks} · evidence ${this.state.evidence}`,
`judge ${this.state.counterModel ?? this.state.model}${this.state.counterModel ? " (counter)" : ""}`,
`cost $${this.state.cost.toFixed(3)} · failures ${this.state.failures}`,
);
if (this.state.lastFailure)
lines.push(this.theme.fg("error", this.state.lastFailure));
} else {
lines.push(
"Reading session metadata and estimating calls.",
`judge ${this.state.model}`,
);
}
lines.push("", this.theme.fg("dim", "Esc cancel"));
return lines.map((line) => truncateToWidth(line, safeWidth));
}
invalidate(): void {
this.tui.requestRender(true);
}
dispose(): void {
clearInterval(this.timer);
}
}