The best way to control Claude Code, Codex and more from any computer or phone
fix(server): t3_thread_list counts threads waiting on background work as live (#34674)
Julius Marminge committed
Nov 11, 2026 at 17:26 UTC
34e7b6601ba735b979d5484347a185b8f2cde0d6
2 files changed
+32
-4
apps/server/src/mcp/OrchestratorMcpService.test.ts
+21
@@ -3886,6 +3886,13 @@ describe("OrchestratorMcpService thread list", () => {
3886
shell("thread:a-snoozed", "project:a", true),
3887
shell("thread:a-awake", "project:a", false),
3888
shell("thread:b-snoozed", "project:b", true),
3889
+ {
3890
+ ...shell("thread:a-awaiting-command", "project:a", false),
3891
+ activityRunStatus: null,
3892
+ pendingBackgroundTasks: [
3893
+ { taskId: "sleep-600", kind: "command" as const, awaited: true as const },
3894
+ ],
3895
+ },
3896
];
3897
const service = layerOrchestratorService.pipe(
3898
Layer.provide(
@@ -3932,6 +3939,20 @@ describe("OrchestratorMcpService thread list", () => {
3939
}).pipe(Effect.provide(service)),
3940
);
3941
3942
+ it.effect("counts a thread holding awaited background work as live in the status filter", () =>
3943
+ Effect.gen(function* () {
3944
+ const mcp = yield* OrchestratorMcpService.OrchestratorMcpService;
3945
+ const listed = yield* mcp.listThreads(client, {
3946
+ projectId: ProjectId.make("project:a"),
3947
+ statuses: ["preparing", "queued", "starting", "running", "waiting"],
3948
+ });
3949
+ assert.deepStrictEqual(
3950
+ listed.threads.map((thread) => thread.threadId),
3951
+ ["thread:a-awaiting-command"],
3952
+ );
3953
+ }).pipe(Effect.provide(service)),
3954
+ );
3955
+
3956
it.effect("points a caller outside any thread at allProjects when it omits projectId", () =>
3957
Effect.gen(function* () {
3958
const mcp = yield* OrchestratorMcpService.OrchestratorMcpService;
apps/server/src/mcp/OrchestratorMcpService.ts
+11
-4
@@ -68,6 +68,7 @@ import {
68
SECRET_REQUEST_UNSAVED_NOTE,
69
} from "@t3tools/contracts";
70
import { getProviderOptionCurrentValue, withLegacyUltracodeEffort } from "@t3tools/shared/model";
71
+import { backgroundWorkHoldsCompletion } from "@t3tools/shared/orchestrationV2PendingBackgroundWork";
72
import { runRanAfter } from "@t3tools/shared/orchestrationV2ThreadError";
73
import { formatThreadLink } from "@t3tools/shared/threadLinks";
74
import {
@@ -814,6 +815,14 @@ function threadPullRequests(
815
}));
816
}
817
818
+// Awaited background work keeps a thread live after its turn ends, as auto-settle and the sidebar treat it.
819
+function listedThreadStatus(shell: OrchestrationV2ThreadShell) {
820
+ if (shell.activityRunStatus != null) return shell.activityRunStatus;
821
+ return backgroundWorkHoldsCompletion(shell.pendingBackgroundTasks ?? [])
822
+ ? "waiting"
823
+ : shell.status;
824
+}
825
+
826
function listItemFromShell(
827
scope: McpInvocationScope,
828
shell: OrchestrationV2ThreadShell,
@@ -826,7 +835,7 @@ function listItemFromShell(
835
link: threadLinkFor(scope, shell.id, shell.title),
836
createdBy: shell.createdBy,
837
creationSource: shell.creationSource,
829
- status: shell.activityRunStatus ?? shell.status,
838
+ status: listedThreadStatus(shell),
839
latestRunId: shell.latestRunId,
840
providerInstanceId: shell.modelSelection.instanceId,
841
model: shell.modelSelection.model,
@@ -2978,9 +2987,7 @@ const make = Effect.gen(function* () {
2987
: new Set(input.statuses);
2988
const titleContains = input.titleContains?.toLocaleLowerCase();
2989
const filtered = projectThreads
2981
- .filter(
2982
- (thread) => statuses === null || statuses.has(thread.activityRunStatus ?? thread.status),
2983
- )
2990
+ .filter((thread) => statuses === null || statuses.has(listedThreadStatus(thread)))
2991
.filter(
2992
(thread) =>
2993
input.settled === undefined || threadSettlement(thread).settled === input.settled,