Skip to content
Source
Sign inSign up

worktreeSetup.ts

23 lines915 Bytes

1import type { WorktreeSetupSnapshot } from "@t3tools/contracts";
2​
3export function resolveVisibleWorktreeSetup(input: {
4 live: WorktreeSetupSnapshot | null;
5 recorded: WorktreeSetupSnapshot | null;
6 turnStarted: boolean;
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.turnStarted) 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");