Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(codex): pick up a new login without restarting T3 #11147

ClosedGigioxx(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/11147/headopened View on GitHub

Showing 3 changed files with 114 additions and 2 deletions.

x
0 of 3 viewed, 3 left
25 additions and 1 deletionapps/server/src/provider/Drivers/CodexDriver.tsModified
View file
@@ -35,11 +35,12 @@
import { ServerConfig } from "../../config.ts";
import { expandHomePath } from "../../pathExpansion.ts";
import { ServerSettingsService } from "../../serverSettings.ts";
-import { ProviderDriverError } from "../Errors.ts";
+import { ProviderDriverError, type ProviderAdapterError } from "../Errors.ts";
import { makeCodexAdapter } from "../Layers/CodexAdapter.ts";
import * as ResetCreditCoordinator from "../Layers/resetCreditCoordinator.ts";
import {
checkCodexProviderStatus,
+ makeCodexAccountSwitchTracker,
makePendingCodexProvider,
probeCodexSkillsForCwd,
withCodexAppServerClient,
@@ -188,6 +189,19 @@
​
+ // Live sessions keep the account they spawned with. When a probe shows a
+ // different login, stop them so the next send respawns app-server with
+ // the current credentials (the same path as Stop or the idle reaper).
+ const trackAccountSwitch = yield* makeCodexAccountSwitchTracker(
+ Effect.logInfo("Codex account changed; stopping live sessions.", { instanceId }).pipe(
+ // `adapter` is created below; suspend so the stop resolves it lazily.
+ // The annotation breaks the inference cycle through `adapter`.
+ Effect.andThen(
+ Effect.suspend((): Effect.Effect<void, ProviderAdapterError> => adapter.stopAll()),
+ ),
+ ),