File size: 768 Bytes
3f76ff4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import type { WorkPackage } from "./work-package-types";

export type WorkPackageVisualState = "idle" | "running" | "done";

export function getWorkPackageVersion(workPackage: WorkPackage) {
  if (!workPackage.outputs.length) return undefined;
  return `v${workPackage.outputs.length}`;
}

export function getWorkPackageVisualState(args: {
  workPackage: WorkPackage;
  activeWorkPackageId?: string;
}) {
  const { workPackage, activeWorkPackageId } = args;

  if (activeWorkPackageId && workPackage.id === activeWorkPackageId) {
    return "running" satisfies WorkPackageVisualState;
  }

  if (workPackage.status === "done" && workPackage.outputs.length) {
    return "done" satisfies WorkPackageVisualState;
  }

  return "idle" satisfies WorkPackageVisualState;
}