Skip to content

Commit cc1cd4d

Browse files
test(server): align workspace handoff test with main's run execution layer
Provide PreviewAgentActivity, use mockEventSink and rootAppThread like the neighbouring tests, and trim the handoff comment to the comment length cap. AI-assisted; verified with the tests and tools listed above.
1 parent f7dac93 commit cc1cd4d

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

‎apps/server/src/orchestration-v2/RunExecutionService.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,11 +2590,12 @@ it.effect("settles native subagents when a workspace handoff completes the root
25902590
Layer.provide(
25912591
Layer.mergeAll(
25922592
McpAppModelContext.layerEmpty,
2593+
PreviewAgentActivity.layer,
25932594
Layer.mock(CheckpointService.CheckpointServiceV2)({
25942595
captureBaseline: () => Effect.void,
25952596
}),
25962597
layerTurnItemPositionsTest,
2597-
Layer.mock(EventSink.EventSinkV2)({
2598+
mockEventSink({
25982599
write: () => Effect.succeed([]),
25992600
writeWithEffects: (input) =>
26002601
Ref.update(written, (current) => [...current, ...input.events]).pipe(Effect.as([])),
@@ -2627,7 +2628,7 @@ it.effect("settles native subagents when a workspace handoff completes the root
26272628
const runExecution = yield* RunExecutionService.RunExecutionServiceV2;
26282629
yield* runExecution.startRootRun({
26292630
commandId: CommandId.make("command:subagent-workspace-handoff"),
2630-
appThread: { id: ids.threadId } as OrchestrationV2AppThread,
2631+
appThread: rootAppThread(ids.threadId),
26312632
providerSessionId: ProviderSessionId.make("session:subagent-workspace-handoff"),
26322633
session: {
26332634
events: Stream.empty,

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,13 +1153,10 @@ export const layer: Layer.Layer<
11531153
(cause) => new RunExecutionIngestError({ runId: input.run.id, cause }),
11541154
),
11551155
);
1156-
// Moving the thread to another workspace detaches its provider
1157-
// session, which stops the turn that asked for the move. That ends
1158-
// the turn as the handoff intended; only a Stop makes it an interrupt.
1159-
// Its native subagents died with the session, so they still settle as
1160-
// interrupted from the raw terminal. The completed write refuses in
1161-
// the same transaction as a committed Stop request, so a Stop racing
1162-
// the handoff falls back to the interrupted terminal.
1156+
// A workspace handoff detaches the session and stops the turn that asked
1157+
// for it: the run completes, while its native subagents still settle
1158+
// as interrupted. The completed write refuses in the same transaction
1159+
// as a stored Stop request, so a racing Stop stays authoritative.
11631160
const handedOff =
11641161
terminal.status === "interrupted" &&
11651162
input.shouldFinalizeRun !== undefined &&

0 commit comments

Comments
 (0)