fix(settings): offer Use existing CLI in managed Codex settings #23160
main fromrefs/pull/23160/head·merged by maria-rcks View on GitHubProblem#
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 rememberedchatgpt-profile:*method andauth.status: "unauthenticated". It clicks Use existing CLI and checks that the panel upserts the instance withsetupMode: "existing". The suite's query mock now returns an auth state forproviderAuthState; the other cases still getnull. - 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 --checkandvp linton both files, andtypecheckforapps/web: clean.vp lintwith the newer test rules from current main (#22560 to #22565): clean.


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.

This branch adds Use existing CLI to the same row.

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.

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
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
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.
View limit details
-
Limit details: You’ve used all 10 included reviews currently available.
Review configuration:
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: f40c7c6
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
8ca6fbf1-33bb-41b7-9c4b-f9453d975a07
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.tsxapps/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.tsxapps/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
Priority: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.tsxThe settings control shows “Use existing CLI” when allowed and disables it when read-only or busy. The browser test verifies the setupModeupdate and retention of the provider’s enabled state and driver. LowEstimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers:
juliusmarminge
Merge Risk:
Minimal · up tod5d29-
The new action enables the intended CLI recovery path. No issue remains that should block merging after normal checks.
Pre-merge checks:
4-
Check name Status Explanation Title check The title clearly and concisely identifies the main change: adding the Use existing CLI action to managed Codex settings. Description check 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… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check 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
-
Note
Written by
gpt-6.1-solon 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 CLIis absent. With the fix, all 4 tests pass. - Blacksmith
vp run check:changedpasses 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.



- Reproduced the regression against current main: the existing browser test fails because
Note
Written by
gpt-6.1-solon behalf of MariaVerified in a real dev environment#
Verified unchanged head
6a8266b52d715ce1946bdb045c5e30af5a128ee7on 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-solin 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 withCLI_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:changedpasses 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



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.
- Reproduced on
maria-rcks merged thisbae3c19
maria-rcks closed this
Sign in to join this conversation.
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).