Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

worktreeSetup.ts

23 lines1004 Bytes

1import type { OrchestrationV2Run, WorktreeSetupSnapshot } from "@t3tools/contracts";
2​
3export function resolveVisibleWorktreeSetup(input: {
4 live: WorktreeSetupSnapshot | null;
5 recorded: WorktreeSetupSnapshot | null;
6 runs: ReadonlyArray<Pick<OrchestrationV2Run, "startedAt">>;
7 followUpSent: boolean;
8}): WorktreeSetupSnapshot | null {
9 const snapshot =
10 input.live && (!input.recorded || input.live.sequence >= input.recorded.sequence)
11 ? input.live
12 : input.recorded;
13 if (!snapshot) return null;
14 if (snapshot.phase === "running") return snapshot;
15 if (input.followUpSent) return null;
16 if (snapshot.phase !== "done") return snapshot;
17 if (!input.runs.some((run) => run.startedAt !== null)) return snapshot;
18 return snapshot.stages.some((stage) => stage.status === "failed") ? snapshot : null;
20​
21export function worktreeSetupAgentStarted(snapshot: WorktreeSetupSnapshot): boolean {
22 return snapshot.stages.some((stage) => stage.id === "agent" && stage.status === "done");