The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
fix(shared): count each pending subagent thread once (#39501)
Yash Singh committed
Nov 19, 2026 at 21:20 UTC
9bb92a46ddbce6c169b46aa785961a49e3f28115
2 files changed
+35
-2
packages/shared/src/orchestrationV2PendingBackgroundWork.test.ts
+27
-1
@@ -324,6 +324,12 @@ describe("derivePendingBackgroundWork kinds", () => {
324
{ taskId: "tests", kind: "command", awaited: true },
325
{ taskId: "watch", kind: "monitor" },
326
{ taskId: "workflow", kind: "background_task" },
327
+ {
328
+ taskId: "followup",
329
+ kind: "subagent",
330
+ description: "Review src/math.ts",
331
+ childThreadId: "thread:child" as never,
332
+ },
333
],
334
},
335
],
@@ -336,6 +342,20 @@ describe("derivePendingBackgroundWork kinds", () => {
342
nativeItemRef: { nativeId: "sub" },
343
childThreadId: "thread:child" as never,
344
},
345
+ {
346
+ id: "item-sub-followup" as never,
347
+ type: "subagent",
348
+ status: "waiting",
349
+ title: "Review src/math.ts",
350
+ childThreadId: "thread:child" as never,
351
+ },
352
+ {
353
+ id: "item-sub-other" as never,
354
+ type: "subagent",
355
+ status: "running",
356
+ title: "Review src/math.ts",
357
+ childThreadId: "thread:other" as never,
358
+ },
359
{
360
id: "item-cmd" as never,
361
type: "command_execution",
@@ -352,11 +372,17 @@ describe("derivePendingBackgroundWork kinds", () => {
372
{ taskId: "watch", kind: "monitor" },
373
{ taskId: "workflow", kind: "background_task" },
374
{
355
- taskId: "sub",
375
+ taskId: "followup",
376
description: "Review src/math.ts",
377
kind: "subagent",
378
childThreadId: "thread:child",
379
},
380
+ {
381
+ taskId: "item-sub-other",
382
+ description: "Review src/math.ts",
383
+ kind: "subagent",
384
+ childThreadId: "thread:other",
385
+ },
386
{ taskId: "cmd", description: "npm test", kind: "command" },
387
]);
388
});
packages/shared/src/orchestrationV2PendingBackgroundWork.ts
+8
-1
@@ -319,7 +319,14 @@ export function derivePendingBackgroundWork(input: {
319
320
for (const task of pullRequestWatchTasks(input.pullRequests)) byTaskId.set(task.taskId, task);
321
322
- return Array.from(byTaskId.values());
322
+ // Follow-up tasks can share a child thread; the pending list counts agents, not messages.
323
+ const childThreadIds = new Set<ThreadId>();
324
+ return Array.from(byTaskId.values()).filter((task) => {
325
+ if (task.kind !== "subagent" || task.childThreadId == null) return true;
326
+ if (childThreadIds.has(task.childThreadId)) return false;
327
+ childThreadIds.add(task.childThreadId);
328
+ return true;
329
+ });
330
}
331
332
function pullRequestWatchTasks(