Skip to content

Commit 05087f3

Browse files
fix(server): t3_thread_list counts threads waiting on background work as live
A thread whose turn ended while it holds awaited background work listed as completed and dropped out of live-status filters, though auto-settle and the sidebar treat it as waiting. The list item and its statuses filter now share one status that reads such a thread as waiting. Fixes #34668 AI-assisted; verified with the tests and tools listed above. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 13dc3d8 commit 05087f3

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

‎apps/server/src/mcp/OrchestratorMcpService.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3889,7 +3889,9 @@ describe("OrchestratorMcpService thread list", () => {
38893889
{
38903890
...shell("thread:a-awaiting-command", "project:a", false),
38913891
activityRunStatus: null,
3892-
pendingBackgroundTasks: [{ taskId: "sleep-600", kind: "command" as const, awaited: true }],
3892+
pendingBackgroundTasks: [
3893+
{ taskId: "sleep-600", kind: "command" as const, awaited: true as const },
3894+
],
38933895
},
38943896
];
38953897
const service = layerOrchestratorService.pipe(

‎apps/server/src/mcp/OrchestratorMcpService.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ import {
6868
SECRET_REQUEST_UNSAVED_NOTE,
6969
} from "@t3tools/contracts";
7070
import { getProviderOptionCurrentValue, withLegacyUltracodeEffort } from "@t3tools/shared/model";
71+
import { backgroundWorkHoldsCompletion } from "@t3tools/shared/orchestrationV2PendingBackgroundWork";
7172
import { runRanAfter } from "@t3tools/shared/orchestrationV2ThreadError";
7273
import { formatThreadLink } from "@t3tools/shared/threadLinks";
7374
import {
@@ -814,6 +815,14 @@ function threadPullRequests(
814815
}));
815816
}
816817

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+
817826
function listItemFromShell(
818827
scope: McpInvocationScope,
819828
shell: OrchestrationV2ThreadShell,
@@ -826,7 +835,7 @@ function listItemFromShell(
826835
link: threadLinkFor(scope, shell.id, shell.title),
827836
createdBy: shell.createdBy,
828837
creationSource: shell.creationSource,
829-
status: shell.activityRunStatus ?? shell.status,
838+
status: listedThreadStatus(shell),
830839
latestRunId: shell.latestRunId,
831840
providerInstanceId: shell.modelSelection.instanceId,
832841
model: shell.modelSelection.model,
@@ -2978,9 +2987,7 @@ const make = Effect.gen(function* () {
29782987
: new Set(input.statuses);
29792988
const titleContains = input.titleContains?.toLocaleLowerCase();
29802989
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)))
29842991
.filter(
29852992
(thread) =>
29862993
input.settled === undefined || threadSettlement(thread).settled === input.settled,

0 commit comments

Comments
 (0)