Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { describe, expect, test } from "bun:test";
import { renderToStaticMarkup } from "react-dom/server";
import type { AlgorithmState } from "@/types/algorithm";
import { SessionExpanded } from "./WorkBoard";

// An untracked session (no ISA) as observability.ts builds it. Started 10 minutes before its last activity.
const START = Date.now() - 6 * 60 * 60 * 1000;
function session(over: Partial<AlgorithmState>): AlgorithmState {
return {
active: false, sessionId: "synthetic-session", taskDescription: "Synthetic task", currentPhase: "COMPLETE",
phaseStartedAt: START + 10 * 60 * 1000, algorithmStartedAt: START, criteria: [], agents: [], capabilities: [],
progress: { done: 0, total: 0 }, rawTask: "synthetic ask", tracked: false, climb: [], ...over,
};
}
const timing = (s: AlgorithmState) => renderToStaticMarkup(<SessionExpanded s={s} bare />).replace(/<[^>]+>/g, "");

describe("SessionExpanded timing line", () => {
test("a completed session is not shown as running and shows how long it ran", () => {
const text = timing(session({ completedAt: START + 10 * 60 * 1000 }));
expect(text).not.toContain("running");
expect(text).toContain("ended after 10m 0s");
});

test("an active session still shows running and its elapsed time", () => {
const text = timing(session({ active: true, currentPhase: "OBSERVE" }));
expect(text).toMatch(/running 6h 0m/);
});

test("an inactive session with no recorded end is neither running nor called finished", () => {
// observability.ts gives a stale session a completedAt (its last activity) without phase COMPLETE.
const text = timing(session({ currentPhase: "OBSERVE", completedAt: START + 10 * 60 * 1000 }));
expect(text).not.toContain("running");
expect(text).not.toContain("ended after");
expect(text).toContain("end not recorded");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ function ClaimRow({ c }: { c: AlgorithmCriterion }) {
// timing, liveness. Exists because "I don't know anything about them"
// (principal, 2026-07-15) — every card must open into whatever we do know.

function SessionExpanded({ s, bare = false }: { s: AlgorithmState; bare?: boolean }) {
export function SessionExpanded({ s, bare = false }: { s: AlgorithmState; bare?: boolean }) {
// bare: plain always-open panel for the spotlight — see ClimbExpanded.
const Wrapper = bare ? "div" : motion.div;
const motionProps = bare
Expand All @@ -287,8 +287,21 @@ function SessionExpanded({ s, bare = false }: { s: AlgorithmState; bare?: boolea
<span>
<span className="text-ink-3">started </span>
{fmtClock(s.algorithmStartedAt)}
<span className="text-ink-3"> · running </span>
{formatElapsed(Date.now() - (s.algorithmStartedAt || Date.now()))}
{s.active ? (
<>
<span className="text-ink-3"> · running </span>
{formatElapsed(Date.now() - (s.algorithmStartedAt || Date.now()))}
</>
) : s.currentPhase === "COMPLETE" && s.completedAt ? (
// A closed session's length stops at its end, not at now.
<>
<span className="text-ink-3"> · ended after </span>
{formatElapsed(s.completedAt - s.algorithmStartedAt)}
</>
) : (
// Inactive without a recorded end (stale): its outcome is unknown, so it is not called finished.
<span className="text-ink-3"> · not active, end not recorded</span>
)}
</span>
<span>
<span className="text-ink-3">last activity </span>
Expand Down