refactor: route switch through command module#157
refactor: route switch through command module#157ndycode wants to merge 1 commit intorefactor/pr1-remove-inline-features-wrapperfrom
Conversation
|
Important Review skippedAuto reviews are limited based on label configuration. 🚫 Review skipped — only excluded labels are configured. (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Summary
lib/codex-manager.tsWhat Changed
runSwitch()helpercodex auth switchdispatch to callrunSwitchCommand(...)directlyValidation
npm run test -- test/codex-manager-switch-command.test.ts test/codex-manager-cli.test.tsnpm run lintnpm run typechecknpm run buildRisk and Rollback
9bfbcc6to restore the inline switch wrapperAdditional Notes
note: greptile review for oc-chatgpt-multi-auth. cite files like
lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.Greptile Summary
this pr removes the now-redundant
runSwitchinline helper fromlib/codex-manager.tsand routes both thecodex auth switchcli path and the login-menu manage flow directly throughrunSwitchCommandfrom the extracted switch command module. the deps object (setStoragePath,loadAccounts,persistAndSyncSelectedAccount) is identical at both call sites, so behavior is unchanged — this is a clean dead-code removal.command === "switch"inrunCodexMultiAuthCli): now callsrunSwitchCommand(rest, deps)directly instead of throughrunSwitchhandleManageActionwhenswitchAccountIndexis set): same direct call, same index-offset arithmetic (index + 1→ parsed back totargetIndex = parsed - 1)persistAndSyncSelectedAccountuses the existingunified-settingsretry queue, unchangedhandleManageActiondiscards thenumberreturn fromrunSwitchCommand(it'sPromise<void>), so switch failures from the menu are only surfaced viaconsole.error; a negative-path vitest case would make this contract explicit (see inline comment)Confidence Score: 5/5
Important Files Changed
runSwitchwrapper; both CLI and menu paths now callrunSwitchCommanddirectly with identical deps — behavior is unchanged, deps are correct, no token/storage safety regressionsFlowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[runCodexMultiAuthCli] -->|command === 'switch'| B["runSwitchCommand(rest, deps)"] C[handleManageAction] -->|switchAccountIndex is number| D["index = switchAccountIndex\nrunSwitchCommand([String(index+1)], deps)"] B --> E[runSwitchCommand] D --> E E --> F{validate args} F -->|missing arg| G["logError / return 1"] F -->|invalid index| H["logError / return 1"] F -->|valid| I[loadAccounts] I --> J{index in range?} J -->|no| K["logError / return 1"] J -->|yes| L[persistAndSyncSelectedAccount] L --> M{synced?} M -->|no| N[logWarn] M -->|yes| O[logInfo] N --> O O --> P[return 0] style D fill:#d4edda,stroke:#28a745 style B fill:#d4edda,stroke:#28a745 style G fill:#f8d7da,stroke:#dc3545 style H fill:#f8d7da,stroke:#dc3545 style K fill:#f8d7da,stroke:#dc3545Prompt To Fix All With AI
Last reviewed commit: "refactor: route swit..."