diff --git a/components/ComposerPanels.subagents.test.mjs b/components/ComposerPanels.subagents.test.mjs
new file mode 100644
index 000000000..935517921
--- /dev/null
+++ b/components/ComposerPanels.subagents.test.mjs
@@ -0,0 +1,56 @@
+import "../tests/setup-dom.mjs";
+import assert from "node:assert/strict";
+import test, { afterEach, beforeEach } from "node:test";
+import React from "react";
+const { cleanup, render, screen } = await import("@testing-library/react/pure.js");
+
+const { ComposerPanels } = await import("./ComposerPanels.tsx");
+
+beforeEach(() => {
+ window.matchMedia = () => ({ matches: false, addEventListener() {}, removeEventListener() {} });
+ // Collapsible headers scroll their active row into view.
+ window.HTMLElement.prototype.scrollIntoView = () => {};
+});
+afterEach(() => {
+ cleanup();
+ localStorage.clear();
+ delete window.matchMedia;
+ delete window.HTMLElement.prototype.scrollIntoView;
+});
+
+function makeSubagent(index, status) {
+ return { id: `s${index}`, agent: "explore", index, status, task: `task ${index}`, source: "live" };
+}
+
+function renderPanels(subagents) {
+ render(React.createElement(ComposerPanels, {
+ todoPhases: [],
+ subagents,
+ onSelectSubagent() {},
+ defaultExpanded: true,
+ }));
+}
+
+test("subagents header shows the completed count once nothing is running (#352)", () => {
+ renderPanels(Array.from({ length: 6 }, (_, i) => makeSubagent(i, "completed")));
+ const counter = screen.getByLabelText("6/6 complete");
+ assert.equal(counter.textContent, "6/6 complete");
+});
+
+test("subagents header counts only truly completed runs, not failed ones (#352)", () => {
+ renderPanels([
+ ...Array.from({ length: 4 }, (_, i) => makeSubagent(i, "completed")),
+ ...Array.from({ length: 2 }, (_, i) => makeSubagent(i + 4, "failed")),
+ ]);
+ const counter = screen.getByLabelText("4/6 complete");
+ assert.equal(counter.textContent, "4/6 complete");
+});
+
+test("subagents header still shows the running count while any subagent runs", () => {
+ renderPanels([
+ ...Array.from({ length: 2 }, (_, i) => makeSubagent(i, "started")),
+ ...Array.from({ length: 4 }, (_, i) => makeSubagent(i + 2, "completed")),
+ ]);
+ const counter = screen.getByLabelText("2 running · 6 total");
+ assert.equal(counter.textContent, "2/6");
+});
diff --git a/components/ComposerPanels.tsx b/components/ComposerPanels.tsx
index 7d3c31187..a4af9d881 100644
--- a/components/ComposerPanels.tsx
+++ b/components/ComposerPanels.tsx
@@ -166,6 +166,15 @@ function SubagentsPanel({ subagents, onSelectSubagent, defaultExpanded = false,
(subagent.source !== "history" && subagent.status === "started" ? running : completed).push(subagent);
}
const runningCount = running.length;
+ // Once nothing runs, the header counts finished subagents instead of
+ // showing 0/N (#352): "0/6" reads as if nothing finished. Only
+ // status === "completed" counts: the `completed` bucket above also holds
+ // failed/aborted runs, and "6/6 complete" must not claim those.
+ const completedCount = subagents.filter((subagent) => subagent.status === "completed").length;
+ const headerCount = runningCount === 0 ? completedCount : runningCount;
+ const headerSummary = runningCount === 0
+ ? t("chatWindow.subagentCompletedSummary", { completed: completedCount, total: subagents.length })
+ : t("chatWindow.subagentSummary", { running: runningCount, total: subagents.length });
function renderChip(subagent: SubagentInfo) {
const stateLabel = t(SUBAGENT_STATE_KEYS[subagent.status]);
@@ -252,10 +261,10 @@ function SubagentsPanel({ subagents, onSelectSubagent, defaultExpanded = false,
) : null}
- {runningCount}/{subagents.length}
+ {runningCount === 0 ? headerSummary : `${headerCount}/${subagents.length}`}