The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import type { OrchestrationV2Run, WorktreeSetupSnapshot } from "@t3tools/contracts"; |
| 2 | |
| 3 | export 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; |
| 19 | } |
| 20 | |
| 21 | export function worktreeSetupAgentStarted(snapshot: WorktreeSetupSnapshot): boolean { |
| 22 | return snapshot.stages.some((stage) => stage.id === "agent" && stage.status === "done"); |
| 23 | } |