@devries-cameron20 / t3code-1 / commits / daa720a986
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(workflows): keep completed workflows reachable (#24587)

Co-authored-by: maria-rcks <maria@kuuro.net>

Bilal Bakr committed Oct 27, 2026 at 05:12 UTC daa720a986ca40e59b063206bb03ccef87f008de
2 files changed +34 -9
packages/client-runtime/src/state/threadSubagents.test.ts
+21
@@ -182,4 +182,25 @@ describe("deriveThreadTurnSubagents", () => {
182 expect(turn?.settledCount).toBe(1);
183 expect(turn?.subagents).toHaveLength(3);
184 });
185 +
186 + it("keeps settled workflows reachable without counting idle agents as done", () => {
187 + const turn = deriveThreadTurnSubagents({
188 + runs: [finishedRun, run("run-2", "completed")],
189 + subagents: [
190 + subagent({ id: "workflow", status: "completed", workflow: { phases: [], agents: [] } }),
191 + subagent({
192 + id: "idle",
193 + runId: RunId.make("run-2"),
194 + status: "idle",
195 + updatedAt: at("2026-06-20T00:00:09.000Z"),
196 + }),
197 + ],
198 + });
199 +
200 + expect(turn?.subagents.map((entry) => entry.id)).toEqual(["idle", "workflow"]);
201 + expect(resolveSubagentPillSegment(turn)).toEqual({
202 + label: "1 done",
203 + accessibilityLabel: "1 agent done",
204 + });
205 + });
206 });
packages/client-runtime/src/state/threadSubagents.ts
+13 -9
@@ -26,11 +26,6 @@ function orderKey(subagent: Subagent): number {
26 return DateTime.toEpochMillis(subagent.startedAt ?? subagent.updatedAt);
27 }
28
29 -/**
30 - * The pill and sheet include the active run's agents, or the most recently updated agent's run when idle.
31 - * Include agents still working from other runs so background work stays counted and reachable.
32 - * Exclude rolled-back runs, matching the Waiting strip.
33 - */
29 export function deriveThreadTurnSubagents(
30 projection: Pick<Projection, "runs" | "subagents">,
31 ): ThreadTurnSubagents | null {
@@ -53,7 +48,10 @@ export function deriveThreadTurnSubagents(
48 const runId = activeRun?.id ?? latestUpdated.runId;
49 const subagents = copySorted(
50 eligible.filter(
56 - (subagent) => subagent.runId === runId || isActiveSubagentStatus(subagent.status),
51 + (subagent) =>
52 + subagent.runId === runId ||
53 + isActiveSubagentStatus(subagent.status) ||
54 + subagent.workflow !== undefined,
55 ),
56 (left, right) => orderKey(left) - orderKey(right) || left.id.localeCompare(right.id),
57 );
@@ -72,7 +70,13 @@ export function resolveSubagentPillSegment(
70 turn: ThreadTurnSubagents | null,
71 ): SubagentPillSegment | null {
72 if (turn === null) return null;
75 - if (!turn.turnActive && turn.liveCount === 0) return null;
73 + if (
74 + !turn.turnActive &&
75 + turn.liveCount === 0 &&
76 + !turn.subagents.some((subagent) => subagent.workflow !== undefined)
77 + ) {
78 + return null;
79 + }
80 const total = turn.subagents.length;
81 if (turn.liveCount > 0) {
82 return {
@@ -81,7 +85,7 @@ export function resolveSubagentPillSegment(
85 };
86 }
87 return {
84 - label: `${total} done`,
85 - accessibilityLabel: `${total} ${total === 1 ? "agent" : "agents"} done`,
88 + label: `${turn.settledCount} done`,
89 + accessibilityLabel: `${turn.settledCount} ${turn.settledCount === 1 ? "agent" : "agents"} done`,
90 };
91 }