@devries-cameron20 / t3code Mirror · read-only / commits / 46fff7943e
Fork 0

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 21, 12:15 UTC

fix(server): Codex model changes no longer restart a shared session from another worktree (#34129)

Julius Marminge committed Nov 14, 2026 at 20:48 UTC 46fff7943e9a2eb84e2b281cb69f0edec3e4f380
2 files changed +34 -8
apps/server/src/orchestration-v2/ProviderSwitchService.test.ts
+28
@@ -314,3 +314,31 @@ it.effect("distinguishes compatible and incompatible instances of the same drive
314 ),
315 ),
316 );
317 +
318 +it.effect(
319 + "applies a next-turn selection change when a shared session's cwd is another thread's",
320 + () =>
321 + Effect.gen(function* () {
322 + const service = yield* ProviderSwitch.ProviderSwitchServiceV2;
323 + const thread = projection();
324 + const result = yield* service.plan({
325 + projection: {
326 + ...thread,
327 + providerSessions: [{ ...thread.providerSessions[0]!, cwd: "/other-thread-worktree" }],
328 + },
329 + targetModelSelection: {
330 + instanceId: currentInstanceId,
331 + model: "gpt-5.1-codex",
332 + options: [{ id: "fastMode", value: true }],
333 + },
334 + });
335 + assert.equal(result.transition.type, "switch_model_in_session");
336 + assert.deepEqual(result.releaseProviderSessionIds, []);
337 + }).pipe(
338 + Effect.provide(
339 + layerTest({ [currentInstanceId]: { continuationKey: "codex:account:primary" } }, () =>
340 + Effect.succeed({ type: "apply_on_next_turn" }),
341 + ),
342 + ),
343 + ),
344 +);
apps/server/src/orchestration-v2/ProviderSwitchService.ts
+6 -8
@@ -113,6 +113,10 @@ export const layer: Layer.Layer<
113 sessionCapabilities: negotiatedCapabilities,
114 })
115 : undefined;
116 + // A selection change keeps the thread where it is. A shared session's cwd is the
117 + // workspace of whichever thread opened it, not a move of this thread.
118 + const workspace =
119 + projection.thread.worktreePath ?? currentSession?.cwd ?? "<unresolved-workspace>";
120 const transition =
121 Option.isNone(targetInstance) || Option.isNone(targetAdapter)
122 ? ({
@@ -133,10 +137,7 @@ export const layer: Layer.Layer<
137 modelSelection: current,
138 runtimeMode: projection.thread.runtimeMode,
139 interactionMode: projection.thread.interactionMode,
136 - workspace:
137 - currentSession?.cwd ??
138 - projection.thread.worktreePath ??
139 - "<unresolved-workspace>",
140 + workspace,
141 },
142 target: {
143 driver: targetInstance.value.driver,
@@ -147,10 +148,7 @@ export const layer: Layer.Layer<
148 modelSelection: targetModelSelection,
149 runtimeMode: projection.thread.runtimeMode,
150 interactionMode: projection.thread.interactionMode,
150 - workspace:
151 - projection.thread.worktreePath ??
152 - currentSession?.cwd ??
153 - "<unresolved-workspace>",
151 + workspace,
152 available: targetInstance.value.enabled,
153 },
154 ...(selectionTransition === undefined ? {} : { selectionTransition }),