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

workflowCardPresentation.ts

33 lines1.4 KB

1/**
2 * Pure presentation helpers for the mobile workflow card. Grouping comes from
3 * the shared client-runtime model (`deriveAgentPanelModel`); these helpers turn
4 * one group into the strings and counts a row renders, so the card's
5 * invariants are exercised without a renderer: a phase is only "done" once the
6 * run reached it, and an unreached phase in a finished run reads "not reached"
7 * rather than "pending".
8 */
9import {
10 isTerminalSubagentStatus,
11 type RuntimeSubagent,
12} from "@t3tools/client-runtime/state/subagentRuntime";
13import type {
14 WorkflowAgentGroup,
15 WorkflowPhaseGroup,
16} from "@t3tools/client-runtime/state/workflow-groups";
17​
18/** Phase members in order, then members whose phase row was lost. */
19export function workflowMembers(group: WorkflowAgentGroup): ReadonlyArray<RuntimeSubagent> {
20 return [...group.phases.flatMap((phase) => phase.members), ...group.unphasedMembers];
22​
23/** A terminal coordinator means the run is over; a paused one is resumable. */
24export function workflowIsLive(group: WorkflowAgentGroup): boolean {
25 return !isTerminalSubagentStatus(group.workflow.status);
27​
28export function workflowPhaseSummary(phase: WorkflowPhaseGroup): string {
29 if (phase.state === "skipped") return "not reached";
30 if (phase.state === "pending" && phase.members.length === 0) return "pending";
31 if (phase.state === "done") return `${phase.settledCount} done`;
32 return `${phase.activeCount} active · ${phase.settledCount} done`;