Skip to content

Commit 55ea365

Browse files
saphidclaude
andauthored
fix(server): side chats no longer open with a model switch from the parent's turn (#29752)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent e27e12d commit 55ea365

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7274,7 +7274,12 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
72747274
...(command.context ? { context: command.context } : {}),
72757275
attachments: command.attachments,
72767276
...(run.contextHandoffId === null
7277-
? modelSwitchSince(projection, modelSelection, sourceRun?.modelSelection)
7277+
? modelSwitchSince(
7278+
projection,
7279+
modelSelection,
7280+
// Side chats do not show the parent's runs.
7281+
sideChatFork ? undefined : sourceRun?.modelSelection,
7282+
)
72787283
: {}),
72797284
};
72807285
const activeHandoff = portableForkHandoff ?? mergeBackHandoff ?? providerSwitchHandoff;

‎apps/server/src/orchestration-v2/ThreadFork.execution.test.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,11 @@ const forkSideChat = (commandId: string, sourceThreadId: ThreadId, targetThreadI
852852
});
853853
});
854854

855-
const askSideChat = (threadId: ThreadId, commandId: string) =>
855+
const askSideChat = (
856+
threadId: ThreadId,
857+
commandId: string,
858+
modelSelection?: (typeof forkCases)[number]["modelSelection"],
859+
) =>
856860
Effect.gen(function* () {
857861
const orchestrator = yield* Orchestrator.OrchestratorV2;
858862
yield* orchestrator.dispatch({
@@ -862,6 +866,7 @@ const askSideChat = (threadId: ThreadId, commandId: string) =>
862866
messageId: MessageId.make(commandId),
863867
text: "What is the main thread doing?",
864868
attachments: [],
869+
...(modelSelection === undefined ? {} : { modelSelection }),
865870
dispatchMode: { type: "start_immediately" },
866871
createdBy: "user",
867872
creationSource: "web",
@@ -954,10 +959,17 @@ it.effect("a side chat of an idle parent still starts with the framing note", ()
954959
query.includes("FROM orchestration_v2_projection_context_transfers"),
955960
),
956961
);
957-
yield* askSideChat(sideChatId, "side-chat-idle-first-message");
962+
yield* askSideChat(sideChatId, "side-chat-idle-first-message", {
963+
...forkCases[0]!.modelSelection,
964+
model: "side-chat-model",
965+
});
958966

959967
const started = yield* orchestrator.getThreadProjection(sideChatId);
960968
assert.isNotNull(started.providerThreads[0]?.forkedFrom);
969+
// The side chat does not show the parent's run, so it is no baseline.
970+
assert.isFalse(
971+
started.turnItems.some((item) => item.type === "user_message" && item.modelSwitch),
972+
);
961973
assert.lengthOf(started.contextHandoffs, 1);
962974
const [handoff] = started.contextHandoffs;
963975
assert.isTrue(

0 commit comments

Comments
 (0)