Skip to content
Source
Sign inSign up
pingdotgg/t3code

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

Mergedonly21mil(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/23160/headmerged by maria-rcks View on GitHub

Problem

When a managed Codex instance has a remembered ChatGPT account but no usable managed session (#17461), Settings → Providers offers only Reconnect account and Use a different account. You can't switch it to a Codex CLI that is already logged in on the same machine. The reporter's only way out was to edit settings.json by hand and change setupMode from "managed" to "existing".

ManagedCodexSetup already has a Use existing CLI button, but only in the onboarding card, and only when no account is remembered. The Settings branch for a signed-out instance never calls onModeChange, even though ProviderSettingsPanel already wires it to write config.setupMode.

Change

CodexSetupSection.tsx: the signed-out Settings row also shows Use existing CLI, after the existing account buttons. It calls the same onModeChange("existing") as the onboarding button. It uses the same allowExistingCli gate, so the Add account dialog, which passes false, is unchanged. Like the onboarding button, it is disabled while the panel is read-only or busy.

The authenticated, sign-in-in-progress and installing branches don't change, and neither does onboarding.

Scope and approval

Refs #17461. In the triage comment, @juliusmarminge found this control missing from Settings even though the setter is wired, and called it "more like a recovery gap than a separate product surface". The first direction listed there is to offer Use existing CLI from managed Settings when unauthenticated, "at least when a CLI ChatGPT login is detected", including the remembered-account state. This PR does that without a detection check: the button shows whenever the instance is signed out, and the onboarding button doesn't check for a CLI login either. It leaves alone the callback error and port handling that the same comment discusses.

@ahmed-besic reported the issue and verified the setupMode workaround that this button now performs.

Verification

Linux (Fedora 44), in apps/web:

  • New case in ProviderSettingsPanel.environment.browser.test.tsx: a managed Codex instance with a remembered chatgpt-profile:* method and auth.status: "unauthenticated". It clicks Use existing CLI and checks that the panel upserts the instance with setupMode: "existing". The suite's query mock now returns an auth state for providerAuthState; the other cases still get null.
  • With main's CodexSetupSection.tsx, the new case fails at once because the button doesn't exist. On this branch all 4 cases in the file pass.
  • vp fmt --check and vp lint on both files, and typecheck for apps/web: clean. vp lint with the newer test rules from current main (#22560 to #22565): clean.

Vitest on main: the new case fails, no Use existing CLI button in the Codex setup region

Vitest on this branch: 4 of 4 pass

Real app: production builds of main and this branch (vp build for apps/web, vp pack for apps/server) from separate copies, each with a fresh state dir, in Chrome 156 on Linux. Each run started from a codex instance with setupMode: "managed" and one remembered ChatGPT registration (a client id and an example email, no credentials), so the provider reported Not authenticated. The server ran with the hostname demo-host.

Main shows only the two account buttons.

Main: Codex is Not authenticated and Setup offers Reconnect account and Use a different account

This branch adds Use existing CLI to the same row.

This branch: the same row with Use existing CLI after the two account buttons

After the click, settings.json has setupMode: "existing". The instance passes through a short "not checked yet" status and then settles on Available, with the existing-CLI runtime fields (binary path, CODEX_HOME). Main shows the same screen when setupMode is set to "existing" in settings.json by hand.

This branch after clicking Use existing CLI: Codex is Available and Setup shows the Runtime fields

Not checked:

  • Sending a message with a logged-in CLI after the switch. The isolated home had no Codex login. Running a logged-in CLI is existing behavior, which the reporter confirmed after editing settings.json.
  • Desktop (Electron), macOS and Windows. The button lives in the shared web Settings UI.

Prior PRs: none for this control. #21249 (open) adds Update Codex to the authenticated branch of the same row, and #15185 (open) changes the card icon. Neither touches the signed-out branch.

Production fix, tests, PR description and images written with Claude Opus 5.5 in T3 Code Nightly.

🤖 Generated with Claude Opus 5.5 in T3 Code Nightly

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — This adds a tested Settings control that lets users switch a managed Codex instance to the existing CLI mode, persisting a different authentication/runtime configuration. The change is narrowly scoped, but the authentication-mode change warrants human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      Warning

      Review limit reached

      Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.

      Next included review available in 28 minutes.

      Check out review usage here.

      View limit details

      Limit details: You’ve used all 10 included reviews currently available.

      Learn how review limits work.

      Review configuration:

      Run configuration
      Commits

      Reviewing files that changed from the base of the PR and between d5d2921484eb3f3cb88f08299fad04ae179d8742 and 6a8266b52d715ce1946bdb045c5e30af5a128ee7.

      Files selected for processing: 2
      • apps/web/src/components/settings/CodexSetupSection.tsx
      • apps/web/src/components/settings/ProviderSettingsPanel.environment.browser.test.tsx

      No actionable comments were generated in the recent review.

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 532d6bb4-6b2a-4a97-ae0c-88aaf781715f
      📥 Commits

      Reviewing files that changed from the base of the PR and between b5a226e49c52ecab4ddc2d678a7012d97e651a6a and d5d2921484eb3f3cb88f08299fad04ae179d8742.

      📒 Files selected for processing: 2
      • apps/web/src/components/settings/CodexSetupSection.tsx
      • apps/web/src/components/settings/ProviderSettingsPanel.environment.browser.test.tsx

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

      Walkthrough

      The Codex settings panel now offers an existing CLI setup option when allowed. A browser test verifies that selecting it updates the provider setup mode while retaining its enabled state and driver.

      Changes: Codex existing CLI option

      Layer / File(s)Summary
      Add and verify the existing CLI action
      apps/web/src/components/settings/CodexSetupSection.tsx, apps/web/src/components/settings/ProviderSettingsPanel.environment.browser.test.tsx
      The settings control shows “Use existing CLI” when allowed and disables it when read-only or busy. The browser test verifies the setupMode update and retention of the provider’s enabled state and driver.
      Priority: Low

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix

      Suggested reviewers: juliusmarminge

      Merge Risk: Minimal · up to d5d29

      The new action enables the intended CLI recovery path. No issue remains that should block merging after normal checks.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title clearly and concisely identifies the main change: adding the Use existing CLI action to managed Codex settings.
      Description checkPassedThe description includes the required Problem, Change, Scope and approval, and Verification sections. It explains the issue, implementation, approval reference, test results, screenshots, and untested…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Description check

      Explanation

      The description includes the required Problem, Change, Scope and approval, and Verification sections. It explains the issue, implementation, approval reference, test results, screenshots, and untested scenarios.

      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    4. maria-rckscommented

      Note

      Written by gpt-6.1-sol on behalf of Maria

      @only21mil, thanks for the focused recovery control and remembered-account regression. I kept both commits, merged current main, and added one layout constraint so the third action wraps without crowding the account label. The existing account actions, permission guards, and Add account exclusion are preserved. Nothing from the original fix was dropped.

      Verification at 6a8266b52d715ce1946bdb045c5e30af5a128ee7:

      • Reproduced the regression against current main: the existing browser test fails because Use existing CLI is absent. With the fix, all 4 tests pass.
      • Blacksmith vp run check:changed passes format, lint, Knip, affected typechecks, and the browser test file.
      • Real Chrome client/server: signed-out managed Codex with a remembered account switches to setupMode: "existing", shows the runtime fields and Available status, and retains the mode after reload. Inspected light/dark layouts at 1440, 1280, and 1000px widths.
      • GitHub CI passes on this head, including Build and Typecheck, Test Web, Test, all 8 server shards, and the required Check aggregate.
      • Two independent code reviews approve this head with no findings.

      Unverified: sending a provider turn after switching, native Electron/mobile clients, Windows/macOS, and remote/tunnel connections. The server and provider adapters are unchanged. CodeRabbit's latest automatic review hit its organization review-budget limit; its prior review found no actionable issue. The existing Macroscope human-approval note remains for Maria's review.

      before: main lacks existing-cli recovery for a remembered signed-out account

      after: existing-cli recovery wraps below the unchanged account actions

      switching to the existing cli shows its runtime and available status

    5. Note

      Written by gpt-6.1-sol on behalf of Maria

      Verified in a real dev environment

      Verified unchanged head 6a8266b52d715ce1946bdb045c5e30af5a128ee7 on Linux with repo Playwright and /usr/bin/google-chrome. No mocks, fixtures, demo data, or source edits.

      • Reproduced on github/main (c4606e564d) in a separate installed worktree: Settings → Providers → Add provider → Continue with ChatGPT → account name “Recovery verification” → Finish later → cancel sign-in. The signed-out managed instance has no Use existing CLI action.
      • Repeated that actual flow on the exact PR head. Use existing CLI appears; clicking it persists config.setupMode: "existing", shows Available and the CLI runtime fields, and survives reload.
      • Added /home/user/main as a project through the app, selected the recovered account and gpt-6.1-sol in the composer, and sent a real Codex turn through the local proxy. Both command tool calls completed with exit 0. A follow-up in the same thread completed with CLI_RESUME_OK.
      • Nearby behavior: the Add account flow excludes Use existing CLI; an active sign-in flow excludes it and retains Cancel; cancelling restores recovery. The original default Codex instance remains Available.
      • Blacksmith vp run check:changed passes format, lint, Knip, affected typechecks and all 4 existing browser tests, including the remembered-account regression. The worker required Git history and Chromium installation before that passing run. Existing head CI reports 28 successful checks, 0 failed/pending.
      • Ran one dev server at a time and stopped the task's servers afterward.

      Short runtime transcript, read from the real server's persisted provider session and turn items:

      provider_instance_id = codex_dc72e01d-a6fe-4c31-bc4c-74765db480b5
      driver = codex; model = gpt-6.1-sol
      turn 1 = completed; turn 2 = completed
      /bin/bash -lc pwd → /home/user/main (exit 0)
      /bin/bash -lc 'git rev-parse --is-inside-work-tree' → true (exit 0)
      client replies: CLI_RECOVERY_OK; CLI_RESUME_OK

      main: signed-out managed recovery account has no existing-cli action

      pr: the same signed-out managed recovery account offers use existing cli

      recording: selecting use existing cli switches the account to available and exposes runtime fields

      real recovered-provider turn and same-thread follow-up complete successfully

      Not verified

      A remembered ChatGPT account with expired/missing credentials, and successful ChatGPT OAuth login: this VM has proxy-backed Codex access, not a ChatGPT browser login. The live recovery above starts with an actual newly created signed-out managed account; no remembered-account data was fabricated. The remembered-account branch is covered by the existing passing browser test, not claimed as real-provider verification.

      Native Electron, iOS/Android, macOS/Windows, remote/relay/tunnel connections, and read-only permission mode were not exercised. Uploaded images and the animated GIF were reopened and inspected in Chrome; the GIF visibly plays the transition.

    6. maria-rcks merged thisbae3c19

    7. maria-rcks closed this

Sign in to join this conversation.