The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as DateTime from "effect/DateTime"; |
| 2 | import { describe, expect, it } from "vite-plus/test"; |
| 3 | import { subagentCardElapsed } from "./subagent-card-presentation"; |
| 4 | |
| 5 | describe("subagent card", () => { |
| 6 | const start = DateTime.makeUnsafe("2026-09-21T12:00:00Z"); |
| 7 | const end = DateTime.makeUnsafe("2026-09-21T12:01:00Z"); |
| 8 | const later = DateTime.makeUnsafe("2026-09-21T12:02:00Z"); |
| 9 | const done = { status: "completed" as const, startedAt: start, completedAt: end }; |
| 10 | |
| 11 | it("counts live work but never uses a settled agent's age as its duration", () => { |
| 12 | const unfinished = { ...done, completedAt: null }; |
| 13 | expect(subagentCardElapsed([unfinished], DateTime.toEpochMillis(later))).toBeNull(); |
| 14 | expect( |
| 15 | subagentCardElapsed([{ ...unfinished, status: "running" }], DateTime.toEpochMillis(later)), |
| 16 | ).toBe("2m 0s"); |
| 17 | expect( |
| 18 | subagentCardElapsed([{ ...unfinished, status: "idle" }], DateTime.toEpochMillis(later)), |
| 19 | ).toBeNull(); |
| 20 | expect( |
| 21 | subagentCardElapsed([{ ...done, startedAt: null }], DateTime.toEpochMillis(later)), |
| 22 | ).toBeNull(); |
| 23 | }); |
| 24 | }); |