fix(web): avoid double-counting workflow failures
This commit is contained in:
1 parent
ee333b1929
commit
da996a85f9
2 files changed
+79
-14
No files matched your search
@@ -1441,10 +1441,73 @@ describe("MessagesTimeline", () => {
|
||||
);
|
||||
|
||||
expect(markup).toContain("Ran 1 subagent");
|
||||
expect(markup).toContain("1 failed");
|
||||
expect(markup).toContain(">failed</span>");
|
||||
expect(markup).not.toContain("1 failed");
|
||||
expect(markup).not.toContain("✓ completed");
|
||||
});
|
||||
|
||||
it("does not count a failed workflow coordinator as an extra subagent", () => {
|
||||
const coordinator = runtimeAgent("workflow-review", {
|
||||
kind: "workflow",
|
||||
status: "failed",
|
||||
workflowName: "Review",
|
||||
phases: [{ index: 0, title: "Inspect" }],
|
||||
});
|
||||
const members = ["first", "second"].map((suffix) =>
|
||||
runtimeAgent(`workflow-review:${suffix}`, {
|
||||
kind: "workflow_agent",
|
||||
status: "failed",
|
||||
parentAgentId: coordinator.id,
|
||||
phaseIndex: 0,
|
||||
completedAt: MESSAGE_CREATED_AT,
|
||||
}),
|
||||
);
|
||||
const agentPanelModel = {
|
||||
workflows: [
|
||||
{
|
||||
workflow: coordinator,
|
||||
phases: [
|
||||
{
|
||||
index: 0,
|
||||
title: "Inspect",
|
||||
members,
|
||||
state: "done",
|
||||
activeCount: 0,
|
||||
settledCount: 2,
|
||||
},
|
||||
],
|
||||
unphasedMembers: [],
|
||||
},
|
||||
],
|
||||
directAgents: [],
|
||||
runningCount: 0,
|
||||
waitingCount: 0,
|
||||
idleCount: 0,
|
||||
settledCount: 3,
|
||||
totalTokens: 0,
|
||||
hasAgents: true,
|
||||
liveCount: 0,
|
||||
} satisfies AgentPanelModel;
|
||||
const markup = renderToStaticMarkup(
|
||||
<MessagesTimeline
|
||||
{...buildProps()}
|
||||
agentPanelModel={agentPanelModel}
|
||||
timelineEntries={[
|
||||
subagentTimelineEntry({
|
||||
itemId: "workflow-review-item",
|
||||
subagentId: coordinator.id,
|
||||
runId: "run-workflow-review",
|
||||
status: "failed",
|
||||
}),
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain("Ran 2 subagents");
|
||||
expect(markup).toContain("2 failed");
|
||||
expect(markup).not.toContain("3 failed");
|
||||
});
|
||||
|
||||
it("keeps an older CTA on its activation after the agent identity is reused", () => {
|
||||
const now = DateTime.makeUnsafe(MESSAGE_CREATED_AT);
|
||||
const subagentId = NodeId.make("node-subagent-reused");
|
||||
|
||||
@@ -1636,13 +1636,11 @@ const AgentSpawnCtaRow = memo(function AgentSpawnCtaRow(props: {
|
||||
else if (status === "cancelled" || status === "interrupted") stopped += 1;
|
||||
}
|
||||
const coordinatorStatus = workflowGroup?.workflow.status;
|
||||
if (coordinatorStatus === "failed") failed += 1;
|
||||
if (coordinatorStatus === "cancelled" || coordinatorStatus === "interrupted") stopped += 1;
|
||||
const coordinatorFailed = coordinatorStatus === "failed";
|
||||
const coordinatorStopped =
|
||||
coordinatorStatus === "cancelled" || coordinatorStatus === "interrupted";
|
||||
const coordinatorSettled =
|
||||
coordinatorStatus === "completed" ||
|
||||
coordinatorStatus === "failed" ||
|
||||
coordinatorStatus === "cancelled" ||
|
||||
coordinatorStatus === "interrupted";
|
||||
coordinatorStatus === "completed" || coordinatorFailed || coordinatorStopped;
|
||||
const live = workflowGroup === undefined ? running + waiting > 0 : !coordinatorSettled;
|
||||
const totalTokens = agentStates.reduce(
|
||||
(sum, agent) => sum + agent.totalTokens,
|
||||
@@ -1656,9 +1654,9 @@ const AgentSpawnCtaRow = memo(function AgentSpawnCtaRow(props: {
|
||||
const working = running + waiting;
|
||||
const dotClass = live
|
||||
? "bg-info"
|
||||
: failed > 0
|
||||
: failed > 0 || coordinatorFailed
|
||||
? "bg-destructive"
|
||||
: idle > 0 || stopped > 0
|
||||
: idle > 0 || stopped > 0 || coordinatorStopped
|
||||
? "bg-muted-foreground/50"
|
||||
: "bg-success";
|
||||
const lead =
|
||||
@@ -1677,11 +1675,15 @@ const AgentSpawnCtaRow = memo(function AgentSpawnCtaRow(props: {
|
||||
: "working"
|
||||
: failed > 0
|
||||
? `${failed} failed`
|
||||
: idle > 0
|
||||
? `${idle} idle`
|
||||
: stopped > 0
|
||||
? `${stopped} stopped`
|
||||
: "✓ completed";
|
||||
: coordinatorFailed
|
||||
? "failed"
|
||||
: idle > 0
|
||||
? `${idle} idle`
|
||||
: stopped > 0
|
||||
? `${stopped} stopped`
|
||||
: coordinatorStopped
|
||||
? "stopped"
|
||||
: "✓ completed";
|
||||
|
||||
return (
|
||||
<button
|
||||
|
||||
Reference in new issue
Block a user