Commit edd6562
committed
refactor(codex-manager): extract login machinery (phase 4)
Audit roadmap §4.1.1 phase 4: move the interactive login control loop and
the OAuth/device sign-in machinery out of lib/codex-manager.ts into focused
modules under lib/codex-manager/, with zero behavior change. Bodies are
verbatim; the only mechanical edits are closure variable -> state field and
closure capture -> deps parameter.
Module map (new files):
- lib/codex-manager/login-oauth.ts (491 lines): runOAuthFlow, runSignInFlow,
promptManualCallback, resolveAccountSelection, persistAccountPool,
syncSelectionToCodex, isOAuthCancellation/isAbortError, token/mode types.
- lib/codex-manager/login-menu-actions.ts (413 lines): sign-in mode and
backup-restore prompts plus handleManageAction and its
selection-index/storage-matching helpers.
- lib/codex-manager/login-action-panel.ts (272 lines): runActionPanel and
the waitForMenuReturn return-to-menu prompt.
- lib/codex-manager/login-flow.ts (566 lines): runAuthLogin entry point,
runAuthLoginFlow outer loop (onboarding/add-account, restore-backup), and
runLoginDashboardLoop. The previously closure-mutable menu quota-refresh
variables (pendingMenuQuotaRefresh, menuQuotaRefreshStatus,
skipNextMenuQuotaAutoRefresh, menuQuotaRefreshGeneration) are now an
explicit MenuQuotaRefreshState object created in runAuthLoginFlow and
passed through; the loginFlow label-based control flow is preserved, with
the extracted dashboard loop signalling "add-account" | "exit" where it
previously used break/return.
runForecast and createRepairCommandDeps stay in lib/codex-manager.ts (both
are also used by the CLI command registry) and are handed to the login flow
via a LoginFlowDeps object, so no extracted module imports codex-manager.ts
back. The public facade of lib/codex-manager.ts is unchanged
(formatBackupSavedAt, styleAccountDetailText, autoSyncActiveAccountToCodex,
runCodexMultiAuthCli).
lib/codex-manager.ts: 2,266 -> 690 lines.
https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB1 parent eb92455 commit edd6562
5 files changed
Lines changed: 1746 additions & 1580 deletions
0 commit comments