From a30a36a615f346a6ca1170edae583fca22bf3b26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rey=20F=2E=20D=C3=ADaz?= <707196+rfdiazpr@users.noreply.github.com> Date: Sat, 7 Nov 2026 23:00:00 -0500 Subject: [PATCH] fix(pulse): a closed session's card stops saying "running" (#2663) SessionExpanded showed "running" and now-minus-start for every untracked session. It now shows running time only while active, "ended after " for an explicit end, and "not active, end not recorded" otherwise. Display only. --- .../activity/WorkBoard.session.test.tsx | 36 +++++++++++++++++++ .../src/components/activity/WorkBoard.tsx | 19 ++++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 LifeOS/install/LIFEOS/PULSE/Observability/src/components/activity/WorkBoard.session.test.tsx diff --git a/LifeOS/install/LIFEOS/PULSE/Observability/src/components/activity/WorkBoard.session.test.tsx b/LifeOS/install/LIFEOS/PULSE/Observability/src/components/activity/WorkBoard.session.test.tsx new file mode 100644 index 0000000000..cb709c932e --- /dev/null +++ b/LifeOS/install/LIFEOS/PULSE/Observability/src/components/activity/WorkBoard.session.test.tsx @@ -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 { + 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().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"); + }); +}); diff --git a/LifeOS/install/LIFEOS/PULSE/Observability/src/components/activity/WorkBoard.tsx b/LifeOS/install/LIFEOS/PULSE/Observability/src/components/activity/WorkBoard.tsx index 4ec167c683..9836368a42 100644 --- a/LifeOS/install/LIFEOS/PULSE/Observability/src/components/activity/WorkBoard.tsx +++ b/LifeOS/install/LIFEOS/PULSE/Observability/src/components/activity/WorkBoard.tsx @@ -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 @@ -287,8 +287,21 @@ function SessionExpanded({ s, bare = false }: { s: AlgorithmState; bare?: boolea started {fmtClock(s.algorithmStartedAt)} - · running - {formatElapsed(Date.now() - (s.algorithmStartedAt || Date.now()))} + {s.active ? ( + <> + · running + {formatElapsed(Date.now() - (s.algorithmStartedAt || Date.now()))} + + ) : s.currentPhase === "COMPLETE" && s.completedAt ? ( + // A closed session's length stops at its end, not at now. + <> + · ended after + {formatElapsed(s.completedAt - s.algorithmStartedAt)} + + ) : ( + // Inactive without a recorded end (stale): its outcome is unknown, so it is not called finished. + · not active, end not recorded + )} last activity