CoDEVX / lib /work-package-ui.ts
Tiger's Macbook Air
Build agentic PM demo app
3f76ff4
raw
history blame contribute delete
768 Bytes
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;
}