fix(codex): restart daemon after system account promotion - #4006
Conversation
Refresh an already-running managed app-server for the destination Codex home after replacing auth. Preserve successful promotion and show a recovery note if daemon verification or restart fails. Reuse account-promotion adapters and auth preparation to keep production code size below the baseline. Fixes #3990. Thanks @massdo for isolating the persistent daemon auth state.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. Reviewed September 25, 2026, 4:47 PM ET / 20:47 UTC. ClawSweeper reviewWhat this changesAfter switching the Codex System Account, the branch checks for a managed background app-server in that Codex home, restarts it to reload authentication, and adds a recovery note when the command fails. Merge readiness⛔ Needs changes before merge - 2 items remain This PR addresses a reproduced stale-daemon account mismatch that current main and v0.66.0 do not fix. One blocking edge remains: a stuck restart command can leave promotion waiting indefinitely, without showing the promised recovery note. Priority: P1 Review scores
Verification
How this fits togetherCodexBar copies a selected managed account’s credentials into the live Codex home when the user switches the System Account. A persistent Codex app-server can keep its earlier authentication state, which then affects CLI sessions that reconnect to it. flowchart LR
A[System Account selection] --> B[Publish selected credentials]
B --> C[Check home daemon PID and process]
C --> D[Verify daemon socket and status]
D --> E[Restart managed daemon]
E --> F[CLI sessions use refreshed account]
D --> G[Show recovery note on failure]
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep the home-scoped daemon refresh, but give the menu operation a bounded, truthful pending or failure state while allowing an already-launched restart to finish safely. Do we have a high-confidence way to reproduce the issue? Yes. The linked reporter supplied a controlled A/B account-switch sequence and observed that restarting the persistent daemon corrected the mismatch; current main still has the auth-swap path without daemon handling. Is this the best way to solve the issue? Yes, a verified home-scoped refresh addresses the observed stale managed daemon. The awaited restart needs a bounded UI completion path. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ce1b80863e4b. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Switching CodexBar's System Account replaces auth.json, but an already-running Codex app-server daemon can retain the previous account. After a successful promotion, CodexBar now verifies the destination home's daemon PID, native app-server command, and home-scoped daemon version response, then runs
codex app-server daemon restartwith that home'sCODEX_HOME.Restart failures and older CLIs without daemon commands preserve the successful account switch and show a one-line recovery note in the menu/settings. No running daemon means no CLI invocation. Profile-home usage selection remains read-only. Nearby promotion cleanup removes redundant adapters, result wrappers, unused state, and duplicate auth preparation; production code decreases by 3 lines (161 added, 164 removed).
Thanks @massdo for isolating the persistent-daemon behavior. The installed CLI's read-only help reports 0.156.1; the PID/command/socket contract was also checked against upstream Codex 0.157.0 source. Verification used temporary homes and injected runners, with no real daemon restart or running-app relaunch.
Validation:
The regression verifies both daemon PID filenames, exactly one restart for the correct home after auth publication, no command for absent/stale processes, rejection of another home or unmanaged server, and successful promotion plus a visible menu note for unsupported/failing commands. UI note publication is verified through the synthetic menu descriptor. Independent Codex review: scoped-clean at P0–P2.
Fixes #3990