diff --git a/src/components/JobCob.svelte b/src/components/JobCob.svelte index 7a23e1f22..fa7cf8738 100644 --- a/src/components/JobCob.svelte +++ b/src/components/JobCob.svelte @@ -65,6 +65,10 @@ return run.runId.slice(0, 8); } + function isTerminal(status: Status): boolean { + return status === "succeeded" || status === "failed"; + } + function aggregateStatus(c: Counts): Status { if (c.failed) return "failed"; if (c.started) return "started"; @@ -92,7 +96,11 @@ function groupJobs(jobs: Job[]): NodeGroup[] { const byNode: Record< string, - { author: Author; byHost: Record } + { + author: Author; + byHost: Record; + seen: Map; + } > = {}; const nodeOrder: string[] = []; for (const job of jobs) { @@ -109,10 +117,25 @@ const key = run.node.did; let entry = byNode[key]; if (!entry) { - entry = { author: run.node, byHost: {} }; + entry = { author: run.node, byHost: {}, seen: new Map() }; byNode[key] = entry; nodeOrder.push(key); } + const existing = entry.seen.get(run.runId); + if (existing) { + // The same run can appear under multiple job COBs. Keep one view + // per runId, but let a terminal status override a stale "started" + // one when COBs polled at different times disagree. We mutate the + // existing view in place because it is the same object referenced + // from its host bucket below. + if (!isTerminal(existing.run.status) && isTerminal(run.status)) { + existing.run = run; + existing.label = view.label; + existing.safeLog = view.safeLog; + } + continue; + } + entry.seen.set(run.runId, view); const bucket = entry.byHost[host] ?? (entry.byHost[host] = []); bucket.push(view); }