Skip to content

Commit ee3d3da

Browse files
vaststudiosclaude
andcommitted
feat(web): nest agent-launched threads under their launcher in the legacy sidebar
Threads an agent starts through t3_thread_launch or create_threads now record launchedByThreadId, and the legacy sidebar nests them under that thread with a connector line. Provider subagents nest under their lineage parent and start folded; a hover-only toggle folds or unfolds a launcher's children. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 4b1024d commit ee3d3da

16 files changed

Lines changed: 524 additions & 19 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,6 +2314,7 @@ const make = Effect.gen(function* () {
23142314
interactionMode,
23152315
branch: parent.thread.branch,
23162316
worktreePath: parent.thread.worktreePath,
2317+
launchedByThreadId: scope.thread.threadId,
23172318
})
23182319
.pipe(
23192320
Effect.mapError((error) =>

‎apps/server/src/mcp/OrchestratorMcpToolkit.integration.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,6 +2076,7 @@ describe("orchestrator MCP toolkit", () => {
20762076
expect(emptyProjection.thread).toMatchObject({
20772077
createdBy: "agent",
20782078
creationSource: "mcp",
2079+
launchedByThreadId: parentThreadId,
20792080
});
20802081
expect(emptyProjection.thread.forkedFrom).toBeNull();
20812082
expect(emptyProjection.runs).toEqual([]);

‎apps/server/src/mcp/toolkits/project/handlers.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import * as McpToolAccess from "../../McpToolAccess.ts";
2929
import * as ProjectHandlers from "./handlers.ts";
3030
import { ProjectToolkit } from "./tools.ts";
3131

32-
it.effect("attributes a launched thread's first message to the calling thread", () =>
32+
it.effect("attributes a launched thread and its first message to the calling thread", () =>
3333
Effect.gen(function* () {
3434
const sourceThreadId = ThreadId.make("source-thread");
3535
const projectId = ProjectId.make("project");
@@ -47,6 +47,7 @@ it.effect("attributes a launched thread's first message to the calling thread",
4747
deletedAt: null,
4848
} as OrchestrationV2ThreadShell;
4949
let launchedSender: ThreadId | undefined;
50+
let launchedBy: ThreadId | undefined;
5051
const layerDependencies = Layer.mergeAll(
5152
ServerSettings.layerTest(),
5253
NodeCrypto.layer,
@@ -68,6 +69,7 @@ it.effect("attributes a launched thread's first message to the calling thread",
6869
Layer.mock(ThreadLaunch.ThreadLaunchService)({
6970
launch: (input) => {
7071
launchedSender = input.initialMessage?.senderThreadId;
72+
launchedBy = input.launchedByThreadId;
7173
return Effect.succeed({
7274
threadId: input.threadId,
7375
projection: {
@@ -98,6 +100,7 @@ it.effect("attributes a launched thread's first message to the calling thread",
98100
.pipe(Stream.unwrap, Stream.runCollect, Effect.provide(layerDependencies));
99101
expect(result.at(-1)?.result).toMatchObject({ projectId, modelSelection });
100102
expect(launchedSender).toBe(sourceThreadId);
103+
expect(launchedBy).toBe(sourceThreadId);
101104
}),
102105
);
103106

@@ -392,6 +395,7 @@ it.effect("a client launches at its ceiling with the project's default model", (
392395
expect(result.at(-1)?.result).toMatchObject({ projectId, modelSelection });
393396
expect(launched[0]?.runtimeMode).toBe("auto-accept-edits");
394397
expect(launched[0]?.initialMessage?.senderThreadId).toBeUndefined();
398+
expect(launched[0]?.launchedByThreadId).toBeUndefined();
395399

396400
const escalated = yield* handle({ title: "Fix", projectId, runtimeMode: "full-access" });
397401
expect(escalated.at(-1)?.result).toMatchObject({ code: "runtime_mode_escalation_denied" });

‎apps/server/src/mcp/toolkits/project/handlers.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, {
154154
}),
155155
createdBy: "agent",
156156
creationSource: "mcp",
157+
...(caller === undefined ? {} : { launchedByThreadId: caller.id }),
157158
}).pipe(
158159
Effect.mapError((error) => {
159160
if (error._tag === "AttachmentClaimError") {

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,6 +2230,9 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
22302230
rootThreadId: command.threadId,
22312231
},
22322232
forkedFrom: null,
2233+
...(command.launchedByThreadId === undefined
2234+
? {}
2235+
: { launchedByThreadId: command.launchedByThreadId }),
22332236
createdAt: now,
22342237
updatedAt: now,
22352238
archivedAt: null,

‎apps/server/src/orchestration-v2/ProjectionStore.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,9 @@ export function threadShellFromProjection(
15151515
: { activeOrderKey: projection.thread.activeOrderKey }),
15161516
lineage: projection.thread.lineage,
15171517
forkedFrom: projection.thread.forkedFrom,
1518+
...(projection.thread.launchedByThreadId === undefined
1519+
? {}
1520+
: { launchedByThreadId: projection.thread.launchedByThreadId }),
15181521
activeProviderThreadId: projection.thread.activeProviderThreadId,
15191522
...(projection.thread.historyOrigin === undefined
15201523
? {}
@@ -1772,6 +1775,9 @@ function shellFromState(input: {
17721775
: { activeOrderKey: input.state.thread.activeOrderKey }),
17731776
lineage: input.state.thread.lineage,
17741777
forkedFrom: input.state.thread.forkedFrom,
1778+
...(input.state.thread.launchedByThreadId === undefined
1779+
? {}
1780+
: { launchedByThreadId: input.state.thread.launchedByThreadId }),
17751781
activeProviderThreadId: input.state.thread.activeProviderThreadId,
17761782
...(input.state.thread.historyOrigin === undefined
17771783
? {}

‎apps/server/src/orchestration-v2/ThreadLaunchService.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export interface ThreadLaunchInput {
9595
};
9696
readonly createdBy: OrchestrationV2Actor;
9797
readonly creationSource: OrchestrationV2CreationSource;
98+
readonly launchedByThreadId?: ThreadId;
9899
}
99100

100101
type PreparationInput = Pick<
@@ -919,6 +920,9 @@ const make = Effect.gen(function* () {
919920
...(input.importedNativeThread === undefined
920921
? {}
921922
: { importedNativeThread: input.importedNativeThread }),
923+
...(input.launchedByThreadId === undefined
924+
? {}
925+
: { launchedByThreadId: input.launchedByThreadId }),
922926
createdBy: input.createdBy,
923927
creationSource: input.creationSource,
924928
});

0 commit comments

Comments
 (0)