Skip to content

Commit d383942

Browse files
committed
fix(server): keep workflow phases visible in the Agents panel
Workflow phase chips (pending later phases) flickered out and back in the Agents panel during a run. The coordinator's phase list only rides on material workflow_progress ticks; a plain progress tick (token/tool update, no phases) upserting the shared task-progress activity id blanked the phase list until the next material tick. Emit phases under their own stable task-phases id so a phaseless tick can never overwrite them. The row is metadata-only (usageSnapshot) so the client fold does not read it as a status transition.
1 parent 9b2d043 commit d383942

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

‎apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.activity.test.ts‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,51 @@ describe("runtimeEventToActivities task progress", () => {
8181
expect(usagePayload.usageSnapshot).toBe(true);
8282
expect(usagePayload).not.toHaveProperty("status");
8383
});
84+
85+
it("keeps workflow phases in a dedicated snapshot a plain progress tick cannot blank", () => {
86+
const taskId = RuntimeTaskId.make("coordinator-1");
87+
const withPhases = {
88+
...base,
89+
type: "task.progress",
90+
eventId: EventId.make("evt-phases"),
91+
payload: {
92+
taskId,
93+
description: "workflow",
94+
phases: [
95+
{ index: 0, title: "Parallel" },
96+
{ index: 1, title: "Sequential" },
97+
],
98+
},
99+
} satisfies ProviderRuntimeEvent;
100+
const plainTick = {
101+
...base,
102+
type: "task.progress",
103+
eventId: EventId.make("evt-plain"),
104+
payload: {
105+
taskId,
106+
description: "workflow",
107+
summary: "collecting results",
108+
},
109+
} satisfies ProviderRuntimeEvent;
110+
111+
const phaseActivities = runtimeEventToActivities(withPhases);
112+
const plainActivities = runtimeEventToActivities(plainTick);
113+
114+
const phaseRow = phaseActivities.find(
115+
(activity) => activity.id === "task-phases:thread-1:coordinator-1",
116+
);
117+
expect(phaseRow).toBeDefined();
118+
const phasePayload = phaseRow?.payload as Record<string, unknown>;
119+
expect(phasePayload.phases).toEqual([
120+
{ index: 0, title: "Parallel" },
121+
{ index: 1, title: "Sequential" },
122+
]);
123+
expect(phasePayload.usageSnapshot).toBe(true);
124+
125+
expect(plainActivities.map((activity) => activity.id)).not.toContain(
126+
"task-phases:thread-1:coordinator-1",
127+
);
128+
});
84129
});
85130
describe("runtimeEventToActivities tool streaming persistence", () => {
86131
const accumulatedStdout = [

‎apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ export function runtimeEventToActivities(
591591
event.payload.lastToolName !== undefined ||
592592
event.payload.status !== undefined ||
593593
event.payload.error !== undefined;
594+
const hasPhases = Array.isArray(event.payload.phases) && event.payload.phases.length > 0;
594595
return [
595596
...(hasProgressState
596597
? [
@@ -646,6 +647,28 @@ export function runtimeEventToActivities(
646647
},
647648
]
648649
: []),
650+
...(hasPhases
651+
? [
652+
{
653+
// Phases only arrive on some progress ticks. Give them their own
654+
// row so a later tick without phases can't overwrite it and make
655+
// the panel flicker.
656+
id: EventId.make(`task-phases:${event.threadId}:${event.payload.taskId}`),
657+
createdAt: event.createdAt,
658+
tone: "info" as const,
659+
kind: "task.progress" as const,
660+
summary: "Workflow phases updated",
661+
payload: {
662+
taskId: event.payload.taskId,
663+
...title,
664+
...identityLinkage,
665+
usageSnapshot: true,
666+
},
667+
turnId: toTurnId(event.turnId) ?? null,
668+
...maybeSequence,
669+
},
670+
]
671+
: []),
649672
];
650673
}
651674

0 commit comments

Comments
 (0)