@devries-cameron20 / t3code-1 / commits / bae3c1962c
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(settings): offer Use existing CLI in managed Codex settings (#23160)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Victor Vogel committed Oct 29, 2026 at 12:55 UTC bae3c1962ce31eefd09e9625586cbd6a904bedc2
2 files changed +67 -3
apps/web/src/components/settings/CodexSetupSection.tsx
+11 -1
@@ -914,7 +914,7 @@ function ManagedCodexSetup({
914 title="ChatGPT account"
915 description={accountDescription}
916 control={
917 - <div className="flex flex-wrap items-center justify-end gap-2">
917 + <div className="flex max-w-88 flex-wrap items-center justify-end gap-2">
918 {authActive ? (
919 <>
920 {waitingControl}
@@ -1001,6 +1001,16 @@ function ManagedCodexSetup({
1001 Use a different account
1002 </Button>
1003 ) : null}
1004 + {allowExistingCli ? (
1005 + <Button
1006 + size="sm"
1007 + variant="ghost"
1008 + disabled={readOnly || busy}
1009 + onClick={() => onModeChange("existing")}
1010 + >
1011 + Use existing CLI
1012 + </Button>
1013 + ) : null}
1014 </>
1015 )}
1016 </div>
apps/web/src/components/settings/ProviderSettingsPanel.environment.browser.test.tsx
+56 -2
@@ -4,6 +4,7 @@ import {
4 EnvironmentId,
5 ProviderDriverKind,
6 ProviderInstanceId,
7 + type ProviderAuthState,
8 type ServerProvider,
9 type UnifiedSettings,
10 } from "@t3tools/contracts";
@@ -17,6 +18,8 @@ import { act, render } from "../../../test/render";
18
19 const state = vi.hoisted(() => ({
20 providers: null as unknown as Atom.Writable<ReadonlyArray<ServerProvider>>,
21 + providerAuthQuery: null as unknown,
22 + providerAuth: null as ProviderAuthState | null,
23 settings: null as unknown as UnifiedSettings,
24 canManageProviders: true,
25 canWriteSettings: true,
@@ -40,6 +43,8 @@ vi.mock(import("../../state/server"), async (original) => {
43 const providers = Atom.make<ReadonlyArray<ServerProvider>>([]).pipe(Atom.keepAlive);
44 state.providers = providers;
45 const config = Atom.make(null);
46 + const providerAuth = Atom.make(null);
47 + state.providerAuthQuery = providerAuth;
48 const commandLabels = {
49 refreshProviders: "refresh",
50 updateProvider: "update",
@@ -59,6 +64,7 @@ vi.mock(import("../../state/server"), async (original) => {
64 ...actual.serverEnvironment,
65 ...labelled,
66 configValueAtom: (() => config) as never,
67 + providerAuthState: (() => providerAuth) as never,
68 providersValueAtom: (() => providers) as never,
69 } as never,
70 };
@@ -75,8 +81,8 @@ vi.mock(import("../../state/use-atom-command"), async (original) => ({
81 }));
82 vi.mock(import("../../state/query"), async (original) => ({
83 ...(await original()),
78 - useEnvironmentQuery: (() => ({
79 - data: null,
84 + useEnvironmentQuery: ((query: unknown) => ({
85 + data: query === state.providerAuthQuery ? state.providerAuth : null,
86 error: null,
87 isPending: false,
88 refresh: vi.fn(),
@@ -216,6 +222,7 @@ async function setup() {
222 state.canManageProviders = true;
223 state.canWriteSettings = true;
224 state.searchTargetId = null;
225 + state.providerAuth = null;
226 state.readEnvironmentIds = [];
227 state.updateEnvironmentIds = [];
228 state.mutationEnvironmentIds = [];
@@ -302,4 +309,51 @@ describe("EnvironmentProviderSettings routing", () => {
309 input: { instanceId, elicitationId: action.elicitationId },
310 });
311 });
312 +
313 + it("lets a signed-out managed Codex account switch to the existing CLI", async () => {
314 + await setup();
315 + const codex = ProviderDriverKind.make("codex");
316 + state.settings = {
317 + ...DEFAULT_UNIFIED_SETTINGS,
318 + providerInstances: {
319 + [codexId]: {
320 + driver: codex,
321 + enabled: true,
322 + config: { enabled: true, setupMode: "managed" },
323 + },
324 + },
325 + };
326 + state.providerAuth = {
327 + instanceId: codexId,
328 + phase: "idle",
329 + flowId: null,
330 + authorizationUrl: null,
331 + expiresAt: null,
332 + message: null,
333 + methods: [{ id: "chatgpt-profile:work", name: "Work", description: null, type: "agent" }],
334 + };
335 + await setProviders([
336 + {
337 + ...provider(),
338 + auth: { status: "unauthenticated" },
339 + setup: { canAuthenticate: true, canInstall: true },
340 + },
341 + ]);
342 + await using _screen = await render(panel({ targetInstanceId: codexId }));
343 + await expect.element(page.getByRole("button", { name: "Reconnect account" })).toBeVisible();
344 + await userEvent.click(page.getByRole("button", { name: "Use existing CLI" }).element());
345 +
346 + expect(state.mutateProviderInstance).toHaveBeenCalledWith(
347 + {
348 + operation: "upsert",
349 + instanceId: codexId,
350 + instance: {
351 + driver: codex,
352 + enabled: true,
353 + config: { enabled: true, setupMode: "existing" },
354 + },
355 + },
356 + {},
357 + );
358 + });
359 });