diff --git a/ui/litellm-dashboard/src/components/lens/model/live.test.ts b/ui/litellm-dashboard/src/components/lens/model/live.test.ts index 98030136f08..e9814c5d7a9 100644 --- a/ui/litellm-dashboard/src/components/lens/model/live.test.ts +++ b/ui/litellm-dashboard/src/components/lens/model/live.test.ts @@ -4,6 +4,7 @@ import { briefReasoning, checkLabel, conclusions, + doneLine, durationLabel, newestFirst, nowLine, @@ -370,6 +371,17 @@ describe("honest live list", () => { expect(inFlight({ status: "running" } as Job)).toEqual([]); }); + it("sums up a finished run from when reading started", () => { + const job = { + reviewed: 30, + created_at: "2026-10-03T16:00:00Z", + finished_at: "2026-10-03T16:00:41Z", + steps: [{ kind: "stage", label: "Reading executions", at: "2026-10-03T16:00:10Z" }], + } as unknown as Job; + expect(doneLine(job)).toBe("Reviewed 30 traces in 31s with"); + expect(doneLine({ ...job, reviewed: 1, finished_at: null })).toBe("Reviewed 1 trace with"); + }); + it("formats review time", () => { expect(durationLabel(420)).toBe("420ms"); expect(durationLabel(1420)).toBe("1.4s"); diff --git a/ui/litellm-dashboard/src/components/lens/model/live.ts b/ui/litellm-dashboard/src/components/lens/model/live.ts index ca6f9a5a27e..67f659623d2 100644 --- a/ui/litellm-dashboard/src/components/lens/model/live.ts +++ b/ui/litellm-dashboard/src/components/lens/model/live.ts @@ -1,3 +1,4 @@ +import { durationText } from "./format"; import type { Job, Review, ReviewVerdict, Settings } from "./types"; export type Outcome = "issue" | "clear" | "unknown"; @@ -239,3 +240,10 @@ export function durationLabel(ms: number): string { if (ms < 1000) return `${Math.max(0, Math.round(ms))}ms`; return ms < 60_000 ? `${(ms / 1000).toFixed(1)}s` : `${Math.floor(ms / 60_000)}m ${Math.round((ms % 60_000) / 1000)}s`; } + +export function doneLine(job: Pick): string { + const end = job.finished_at ? Date.parse(job.finished_at) : Number.NaN; + const seconds = Math.round((end - Date.parse(readingStart(job))) / 1000); + const took = Number.isFinite(seconds) && seconds >= 0 ? ` in ${durationText(seconds)}` : ""; + return `Reviewed ${job.reviewed} ${job.reviewed === 1 ? "trace" : "traces"}${took} with`; +}