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 22, 13:15 UTC
feat(server): agents list snoozed threads across all projects in one call (#26442)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Theo Browne committed
Oct 28, 2026 at 05:05 UTC
0160c448f61bf24244411781ccc47829a1a51a17
6 files changed
+108
-29
apps/server/src/mcp/OrchestratorMcpService.test.ts
+65
@@ -2694,6 +2694,71 @@ describe("OrchestratorMcpService thread lookup", () => {
2694
);
2695
});
2696
2697
+describe("OrchestratorMcpService thread list", () => {
2698
+ const client: McpInvocationScope = {
2699
+ environmentId: EnvironmentId.make("environment:thread-list"),
2700
+ requestNamespace: "client:thread-list",
2701
+ thread: undefined,
2702
+ client: { sessionId: "thread-list", label: "Claude Code", access: "full-access" },
2703
+ capabilities: new Set(["orchestration"]),
2704
+ issuedAt: 1,
2705
+ };
2706
+ const shell = (id: string, projectId: string, snoozed: boolean) => ({
2707
+ ...liveThreadShell(ThreadId.make(id)),
2708
+ projectId: ProjectId.make(projectId),
2709
+ status: "completed" as const,
2710
+ snoozedUntil: snoozed ? DateTime.makeUnsafe("2099-01-01T00:00:00Z") : null,
2711
+ });
2712
+ const shells = [
2713
+ shell("thread:a-snoozed", "project:a", true),
2714
+ shell("thread:a-awake", "project:a", false),
2715
+ shell("thread:b-snoozed", "project:b", true),
2716
+ ];
2717
+ const service = layerOrchestratorService.pipe(
2718
+ Layer.provide(
2719
+ Layer.mergeAll(
2720
+ NodeServices.layer,
2721
+ Layer.mock(ThreadManagementService.ThreadManagementService)({
2722
+ listProjectThreads: (input) =>
2723
+ Effect.succeed(
2724
+ shells.filter(
2725
+ (thread) => input.projectId === undefined || thread.projectId === input.projectId,
2726
+ ),
2727
+ ),
2728
+ }),
2729
+ ServerSettings.layerTest(),
2730
+ Layer.mock(ProviderRegistry.ProviderRegistry)({ getProviders: Effect.succeed([]) }),
2731
+ Layer.mock(ProviderAdapterRegistry.ProviderAdapterRegistryV2)({
2732
+ list: () => Effect.succeed([]),
2733
+ }),
2734
+ Layer.mock(ProjectService.ProjectService)({}),
2735
+ Layer.mock(SecretRequests.SecretRequests)({}),
2736
+ Layer.mock(RemoteDelegation.RemoteDelegation)({}),
2737
+ Layer.mock(ScheduledTaskService.ScheduledTaskService)({}),
2738
+ ),
2739
+ ),
2740
+ );
2741
+
2742
+ it.effect("lists snoozed threads across every project with allProjects", () =>
2743
+ Effect.gen(function* () {
2744
+ const mcp = yield* OrchestratorMcpService.OrchestratorMcpService;
2745
+ const listed = yield* mcp.listThreads(client, {
2746
+ allProjects: true,
2747
+ projectId: ProjectId.make("project:a"),
2748
+ snoozed: true,
2749
+ });
2750
+ assert.equal(listed.projectId, null);
2751
+ assert.deepStrictEqual(
2752
+ listed.threads.map((thread) => [thread.threadId, thread.projectId]),
2753
+ [
2754
+ ["thread:a-snoozed", "project:a"],
2755
+ ["thread:b-snoozed", "project:b"],
2756
+ ],
2757
+ );
2758
+ }).pipe(Effect.provide(service)),
2759
+ );
2760
+});
2761
+
2762
describe("OrchestratorMcpService thread stop", () => {
2763
const driver = ProviderDriverKind.make("codex");
2764
const instanceId = ProviderInstanceId.make("codex");
apps/server/src/mcp/OrchestratorMcpService.ts
+5
-2
@@ -755,6 +755,7 @@ function listItemFromShell(
755
): OrchestratorMcpThreadListItem {
756
return {
757
threadId: shell.id,
758
+ projectId: shell.projectId,
759
title: shell.title,
760
link: formatThreadLink({ environmentId, threadId: shell.id }),
761
createdBy: shell.createdBy,
@@ -2764,10 +2765,12 @@ const make = Effect.gen(function* () {
2765
),
2766
listThreads: Effect.fn("OrchestratorMcpService.listThreads")(function* (scope, input) {
2767
const { parent } = yield* loadCaller(scope);
2767
- const projectId = yield* resolveProjectTarget(parent, input.projectId);
2768
+ const projectId = input.allProjects
2769
+ ? null
2770
+ : yield* resolveProjectTarget(parent, input.projectId);
2771
const projectThreads = yield* threadManagement
2772
.listProjectThreads({
2770
- projectId,
2773
+ projectId: projectId ?? undefined,
2774
includeSubagents: input.includeSubagents !== false,
2775
})
2776
.pipe(
apps/server/src/mcp/toolkits/orchestrator/tools.ts
+1
-1
@@ -222,7 +222,7 @@ const CreateThreadsTool = Tool.make("create_threads", {
222
223
const ThreadListTool = Tool.make("t3_thread_list", {
224
description:
225
- "List threads in a project, newest first. Omit `projectId` for yours. Filter by status, title, settled, or snoozed. Page with the cursor.",
225
+ "List threads newest first, in one project or with `allProjects`. Page with `cursor`.",
226
parameters: OrchestratorMcpThreadListInput,
227
success: OrchestratorMcpThreadListResult,
228
failure: OrchestratorMcpFailure,
apps/server/src/orchestration-v2/ThreadManagementService.ts
+32
-24
@@ -279,12 +279,14 @@ export class ThreadManagementProjectionLoadError extends Schema.TaggedError<Thre
279
export class ThreadManagementProjectThreadsListError extends Schema.TaggedError<ThreadManagementProjectThreadsListError>()(
280
"ThreadManagementProjectThreadsListError",
281
{
282
- projectId: ProjectId,
282
+ projectId: Schema.optional(ProjectId),
283
cause: Schema.Defect(),
284
},
285
) {
286
override get message(): string {
287
- return `Unable to list threads in project ${this.projectId}.`;
287
+ return this.projectId === undefined
288
+ ? "Unable to list threads."
289
+ : `Unable to list threads in project ${this.projectId}.`;
290
}
291
}
292
@@ -404,8 +406,9 @@ export interface ThreadManagementServiceShape {
406
Orchestrator.OrchestratorV2Error
407
>;
408
readonly getThreadShell: Orchestrator.OrchestratorV2["Service"]["getThreadShell"];
409
+ /** Omit `projectId` to list every project's threads. */
410
readonly listProjectThreads: (input: {
408
- readonly projectId: ProjectId;
411
+ readonly projectId?: ProjectId | undefined;
412
readonly includeSubagents: boolean;
413
}) => Effect.Effect<ReadonlyArray<OrchestrationV2ThreadShell>, ThreadManagementError>;
414
readonly sendToThread: (
@@ -736,27 +739,32 @@ const make = Effect.gen(function* () {
739
);
740
741
const listProjectThreads: ThreadManagementServiceShape["listProjectThreads"] = (input) =>
739
- orchestrator.getShellSnapshot({ projectId: input.projectId, location: "active" }).pipe(
740
- Effect.mapError(
741
- (cause) =>
742
- new ThreadManagementProjectThreadsListError({
743
- projectId: input.projectId,
744
- cause,
745
- }),
746
- ),
747
- Effect.map((snapshot) =>
748
- snapshot.threads
749
- .filter(
750
- (thread) =>
751
- input.includeSubagents || thread.lineage.relationshipToParent !== "subagent",
752
- )
753
- .toSorted(
754
- (left, right) =>
755
- DateTime.toEpochMillis(right.updatedAt) - DateTime.toEpochMillis(left.updatedAt) ||
756
- right.id.localeCompare(left.id),
757
- ),
758
- ),
759
- );
742
+ orchestrator
743
+ .getShellSnapshot({
744
+ location: "active",
745
+ ...(input.projectId === undefined ? {} : { projectId: input.projectId }),
746
+ })
747
+ .pipe(
748
+ Effect.mapError(
749
+ (cause) =>
750
+ new ThreadManagementProjectThreadsListError({
751
+ projectId: input.projectId,
752
+ cause,
753
+ }),
754
+ ),
755
+ Effect.map((snapshot) =>
756
+ snapshot.threads
757
+ .filter(
758
+ (thread) =>
759
+ input.includeSubagents || thread.lineage.relationshipToParent !== "subagent",
760
+ )
761
+ .toSorted(
762
+ (left, right) =>
763
+ DateTime.toEpochMillis(right.updatedAt) - DateTime.toEpochMillis(left.updatedAt) ||
764
+ right.id.localeCompare(left.id),
765
+ ),
766
+ ),
767
+ );
768
769
const sendToThread: ThreadManagementServiceShape["sendToThread"] = Effect.fn(
770
"ThreadManagementService.sendToThread",
apps/server/src/provider/agentContextBudget.json
+1
-1
@@ -1,5 +1,5 @@
1
{
2
"claudeSystemAppendBytes": 5135,
3
"codexAdditionalContextBytes": 5687,
4
- "mcpToolListJsonBytes": 45861
4
+ "mcpToolListJsonBytes": 45842
5
}
packages/contracts/src/orchestratorMcp.ts
+4
-1
@@ -330,6 +330,7 @@ export const OrchestratorMcpEnvironmentTarget = Schema.optional(
330
export const OrchestratorMcpThreadListInput = Schema.Struct({
331
environmentId: OrchestratorMcpEnvironmentTarget,
332
projectId: OrchestratorMcpProjectTarget,
333
+ allProjects: Schema.optional(Schema.Boolean),
334
statuses: Schema.optional(
335
Schema.Array(OrchestratorMcpThreadStatus).check(Schema.isMaxLength(10)),
336
),
@@ -353,6 +354,7 @@ export type OrchestratorMcpThreadPullRequest = typeof OrchestratorMcpThreadPullR
354
355
export const OrchestratorMcpThreadListItem = Schema.Struct({
356
threadId: ThreadId,
357
+ projectId: ProjectId,
358
title: Schema.String,
359
link: Schema.optional(Schema.String),
360
createdBy: OrchestrationV2Actor,
@@ -378,7 +380,8 @@ export const OrchestratorMcpThreadListItem = Schema.Struct({
380
export type OrchestratorMcpThreadListItem = typeof OrchestratorMcpThreadListItem.Type;
381
382
export const OrchestratorMcpThreadListResult = Schema.Struct({
381
- projectId: ProjectId,
383
+ /** null with `allProjects`. */
384
+ projectId: Schema.NullOr(ProjectId),
385
currentThreadId: Schema.NullOr(ThreadId),
386
threads: Schema.Array(OrchestratorMcpThreadListItem),
387
nextCursor: Schema.NullOr(NonNegativeInt),