From b63fce8de97c7117eaeee1eee2f7ee550f77e7c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Tu=E1=BA=A5n=20Anh?= Date: Tue, 10 Nov 2026 21:45:07 +0700 Subject: [PATCH 1/3] fix(chat): show completed subagents in the panel header once nothing runs --- components/ComposerPanels.subagents.test.mjs | 47 ++++++++++++++++++++ components/ComposerPanels.tsx | 12 +++-- 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 components/ComposerPanels.subagents.test.mjs diff --git a/components/ComposerPanels.subagents.test.mjs b/components/ComposerPanels.subagents.test.mjs new file mode 100644 index 000000000..401f983d2 --- /dev/null +++ b/components/ComposerPanels.subagents.test.mjs @@ -0,0 +1,47 @@ +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"); +}); + +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..ed11658eb 100644 --- a/components/ComposerPanels.tsx +++ b/components/ComposerPanels.tsx @@ -166,6 +166,12 @@ 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. + const headerCount = runningCount === 0 ? completed.length : runningCount; + const headerSummary = runningCount === 0 + ? t("chatWindow.subagentCompletedSummary", { completed: completed.length, 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 +258,10 @@ function SubagentsPanel({ subagents, onSelectSubagent, defaultExpanded = false, ) : null} - {runningCount}/{subagents.length} + {headerCount}/{subagents.length} Date: Tue, 10 Nov 2026 21:46:10 +0700 Subject: [PATCH 2/3] fix(chat): show completed subagents in the panel header once nothing runs --- lib/i18n/locales/en.json | 1 + lib/i18n/locales/ja.json | 1 + lib/i18n/locales/zh-CN.json | 1 + 3 files changed, 3 insertions(+) diff --git a/lib/i18n/locales/en.json b/lib/i18n/locales/en.json index 139cd4e94..17f18fe10 100644 --- a/lib/i18n/locales/en.json +++ b/lib/i18n/locales/en.json @@ -606,6 +606,7 @@ "chatWindow.subagentState.failed": "Failed", "chatWindow.subagentState.started": "Running", "chatWindow.subagentSummary": "{running} running · {total} total", + "chatWindow.subagentCompletedSummary": "{completed}/{total} complete", "chatWindow.completedSubagents": "Completed ({count})", "chatWindow.subagentsPanel": "Subagents", "chatWindow.subagentRetrying": "retrying {attempt}/{max}", diff --git a/lib/i18n/locales/ja.json b/lib/i18n/locales/ja.json index 08c590c72..69c1b7c9a 100644 --- a/lib/i18n/locales/ja.json +++ b/lib/i18n/locales/ja.json @@ -589,6 +589,7 @@ "chatWindow.subagentState.failed": "失敗", "chatWindow.subagentState.started": "実行中", "chatWindow.subagentSummary": "{running} 実行中 · {total} 件", + "chatWindow.subagentCompletedSummary": "{completed}/{total} 完了", "chatWindow.completedSubagents": "完了 ({count})", "chatWindow.subagentsPanel": "サブエージェント", "chatWindow.subagentRetrying": "再試行中 {attempt}/{max}", diff --git a/lib/i18n/locales/zh-CN.json b/lib/i18n/locales/zh-CN.json index 0a982a3c6..7cdb0cb02 100644 --- a/lib/i18n/locales/zh-CN.json +++ b/lib/i18n/locales/zh-CN.json @@ -589,6 +589,7 @@ "chatWindow.subagentState.failed": "失败", "chatWindow.subagentState.started": "运行中", "chatWindow.subagentSummary": "{running} 运行中 · 共 {total} 个", + "chatWindow.subagentCompletedSummary": "已完成 {completed}/{total}", "chatWindow.completedSubagents": "已完成 ({count})", "chatWindow.subagentsPanel": "子代理", "chatWindow.subagentRetrying": "重试 {attempt}/{max}", From 9b66e39aec63e56972bb97fce06a75bf1f86272f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Tu=E1=BA=A5n=20Anh?= Date: Thu, 12 Nov 2026 04:44:43 +0700 Subject: [PATCH 3/3] fix(chat): count only completed subagents in the header and show the completed label --- components/ComposerPanels.subagents.test.mjs | 11 ++++++++++- components/ComposerPanels.tsx | 11 +++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/components/ComposerPanels.subagents.test.mjs b/components/ComposerPanels.subagents.test.mjs index 401f983d2..935517921 100644 --- a/components/ComposerPanels.subagents.test.mjs +++ b/components/ComposerPanels.subagents.test.mjs @@ -34,7 +34,16 @@ function renderPanels(subagents) { 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"); + 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", () => { diff --git a/components/ComposerPanels.tsx b/components/ComposerPanels.tsx index ed11658eb..a4af9d881 100644 --- a/components/ComposerPanels.tsx +++ b/components/ComposerPanels.tsx @@ -167,10 +167,13 @@ function SubagentsPanel({ subagents, onSelectSubagent, defaultExpanded = false, } 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. - const headerCount = runningCount === 0 ? completed.length : runningCount; + // 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: completed.length, total: subagents.length }) + ? t("chatWindow.subagentCompletedSummary", { completed: completedCount, total: subagents.length }) : t("chatWindow.subagentSummary", { running: runningCount, total: subagents.length }); function renderChip(subagent: SubagentInfo) { @@ -261,7 +264,7 @@ function SubagentsPanel({ subagents, onSelectSubagent, defaultExpanded = false, aria-label={headerSummary} title={headerSummary} > - {headerCount}/{subagents.length} + {runningCount === 0 ? headerSummary : `${headerCount}/${subagents.length}`}