Colors (GSD palette) untouched. New visual vocabulary across the whole GUI: - warm-tinted layered shadow tokens (--shadow-xs/sm/md) replacing flat rings; cards/dialogs framed with hairline border + real elevation - strict radii scale: xl cards / lg inputs / md controls / 2xl dialogs; buttons move from pills to rounded-md - third type register: --font-mono + tabular-nums on SQL, timers, dates, ids; standardized .thot-label micro-label tier - prose: framed tables with uppercase headers, elevated code blocks - SqlViewer badges moved from hardcoded Tailwind greens/reds to success/ destructive token tints; ResultsPanel inline styles replaced with classes - artifact gate: first option rendered as filled primary action Verified offline via Playwright against a mock backend replaying a real psd session (no VPN needed). tsc clean, 115/115 vitest. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import { useEffect, useRef, useState } from "react";
|
|
|
|
function fmt(ms: number): string {
|
|
const total = Math.max(0, Math.floor(ms / 1000));
|
|
return `${Math.floor(total / 60)}m ${total % 60}s`;
|
|
}
|
|
|
|
/**
|
|
* Processing-time indicator: accumulates ONLY the time the harness/model is
|
|
* actively working (`running`), pausing while a gate waits on the reviewer and
|
|
* freezing when the session ends. The parent keys this component on the session id,
|
|
* so it remounts (and restarts at zero) per session. In-memory: a page reload
|
|
* restarts the count.
|
|
*/
|
|
export function ElapsedTimer({ running }: { running: boolean }) {
|
|
const [accumMs, setAccumMs] = useState(0);
|
|
const runStartRef = useRef<number | null>(null);
|
|
const [, tick] = useState(0);
|
|
|
|
useEffect(() => {
|
|
if (!running) return;
|
|
runStartRef.current = Date.now();
|
|
const t = setInterval(() => tick((n) => n + 1), 1000);
|
|
return () => {
|
|
// Fold the just-finished run into the accumulator (setState re-renders so the
|
|
// frozen total shows), then stop ticking.
|
|
if (runStartRef.current != null) {
|
|
const started = runStartRef.current;
|
|
runStartRef.current = null;
|
|
setAccumMs((ms) => ms + (Date.now() - started));
|
|
}
|
|
clearInterval(t);
|
|
};
|
|
}, [running]);
|
|
|
|
const live = running && runStartRef.current != null ? Date.now() - runStartRef.current : 0;
|
|
return (
|
|
<span
|
|
className="shrink-0 font-mono tabular-nums text-xs text-muted-foreground"
|
|
aria-label="Processing time"
|
|
title="Processing time (excludes time spent waiting on the reviewer)"
|
|
>
|
|
{fmt(accumMs + live)}
|
|
</span>
|
|
);
|
|
}
|