feat(auth): add first-run setup wizard#129
feat(auth): add first-run setup wizard#129ndycode wants to merge 5 commits intoclean/pr102-opencode-import-replay-finalfrom
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (9)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
📝 Coding Plan
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 |
3f06c8e to
e407350
Compare
Summary
#103clean/pr102-opencode-import-replay-finalWhat Changed
codex auth loginhands off into the normal account menu instead of exiting immediately after importValidation
npm run lintnpm run typechecknpm run buildnpm testnpm exec -- vitest run test/codex-manager-cli.test.ts test/storage.test.ts test/sync-history.test.ts --maxWorkers=1npm exec -- vitest run test/codex-manager-cli.test.ts test/storage.test.ts test/sync-history.test.ts test/cli-auth-menu.test.ts test/auth-menu-hotkeys.test.ts --maxWorkers=1Docs and Governance Checklist
docs/getting-started.mdupdated (if onboarding flow changed)docs/features.mdupdated (if capability surface changed)docs/reference/*pages updated (if commands/settings/paths changed)docs/upgrade.mdupdated (if migration behavior changed)SECURITY.mdandCONTRIBUTING.mdreviewed for alignmentRisk and Rollback
fd189feAdditional Notes
#103.9files instead of the old43-file PR.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 adds a first-run setup wizard that appears before oauth when no storage file exists, offering restore, opencode import, settings, doctor, and skip/login entry points. it's a clean 9-file slice that correctly fixes the post-import handoff so successful opencode imports flow into the normal account menu instead of exiting.
key changes:
runFirstRunWizard/buildFirstRunWizardOptions/showFirstRunWizardform the new wizard stack;skipEmptyStorageRecoveryMenuandfirstRunWizardShownInLoopflags thread the result into the existing login loopdetectOpencodeAccountPoolPathprobesLOCALAPPDATA,APPDATA, and~/.opencode;assessOpencodeAccountPoolwraps it with the existing restore-assessment pipeline; active-storage self-import guard added to bothassessOpencodeAccountPoolandimportAccountspruneAutoGeneratedSnapshots+enforceSnapshotRetentionadd per-reason snapshot retention (default 3) called after everysnapshotAccountStoragewrite; dynamic import ofsync-history.jsbreaks the circular depwithRetryableHistoryWriteadds retry onEBUSY/EPERM/EACCESfor all history file writes;pruneSyncHistoryEntriesis now a pure exported function; estimate-guard (HISTORY_TRIM_RELOAD_BUFFER) reduces trim-read I/O; drain-wait test is restoredredactFilesystemDetailsregex fixed from+back to*restoring single-segment path redaction;formatRedactedFilesystemErrorexported for consistent cross-module error formattingthe main open items after previous review threads:
buildFirstRunWizardOptionsruns three independent async probes sequentially (noticeable delay on windows/AV-heavy hosts — should bePromise.allSettled), andpruneAutoGeneratedSnapshotshas no direct vitest test verifying that old snapshots beyond the retention limit are actually unlinked from disk.Confidence Score: 3/5
buildFirstRunWizardOptionsfetches (perf, not correctness) and missing direct pruning test. the regex is correctly fixed to*.EACCESis now in the retry set. the drain-wait test is restored. no new token-safety or data-mutation regressions introduced.Important Files Changed
buildFirstRunWizardOptionswith sequential awaits (perf concern); the dead-code block at the inner wizard re-check was flagged in a previous review threaddetectOpencodeAccountPoolPath,assessOpencodeAccountPool,pruneAutoGeneratedSnapshots,formatRedactedFilesystemError, and snapshot-retention enforcement; regex fix restores single-segment path redaction; new function lacks direct pruning test coveragewithRetryableHistoryWrite(EBUSY/EPERM/EACCES),pruneSyncHistoryEntries,pruneSyncHistory, and estimate-guard to reduce trim-read I/O;ETIMEDOUTomitted from retry set (noted in prior thread); multi-process estimate drift noted in prior threadpruneAutoGeneratedSnapshotssuccess path (retention enforcement)Sequence Diagram
sequenceDiagram participant CLI as codex auth login participant CM as codex-manager participant WIZ as runFirstRunWizard participant ST as storage.ts participant SH as sync-history.ts CLI->>CM: runAuthLogin() CM->>ST: loadAccounts() ST-->>CM: null (no storage) CM->>CM: shouldShowFirstRunWizard() → true CM->>ST: buildFirstRunWizardOptions()<br/>(listNamedBackups, listRotatingBackups, assessOpencodeAccountPool — sequential) ST-->>CM: { namedBackupCount, rotatingBackupCount, hasOpencodeSource } CM->>WIZ: showFirstRunWizard(options) alt user picks "import-opencode" WIZ->>ST: assessOpencodeAccountPool() ST-->>WIZ: BackupRestoreAssessment WIZ->>ST: importAccounts(path) ST->>SH: appendSyncHistoryEntry (via snapshotAccountStorage) SH-->>ST: ok ST->>ST: enforceSnapshotRetention → pruneAutoGeneratedSnapshots ST-->>WIZ: { imported, skipped, total } WIZ->>ST: loadAccounts() ST-->>WIZ: AccountStorageV3 (accounts > 0) WIZ-->>CM: { outcome: "continue", latestStorage, firstAction: "import-opencode" } CM->>CM: enter loginFlow loop with populated storage else user picks "login" or "skip" WIZ-->>CM: { outcome: "continue", latestStorage: null, firstAction: "login"|"skip" } CM->>CM: firstRunWizardShownInLoop = true<br/>skipEmptyStorageRecoveryMenu = true CM->>CM: enter loginFlow → runOAuthFlow else user picks "cancel" WIZ-->>CM: { outcome: "cancelled" } CM-->>CLI: return 0 endComments Outside Diff (2)
lib/storage.ts, line 2088-2097 (link)removing
resolveFilesystemPathmeans that ifAPPDATAorLOCALAPPDATAcontains a relative path (possible in sandboxed environments, CI, or user misconfiguration), the candidate path will be relative too.existsSyncon a relative path resolves againstprocess.cwd(), which can differ from where the path was intended. the test "resolves relative app data candidates before detection" was deleted alongside this change, so there is now no coverage for relative env-var scenarios. the change is likely intentional, but it is worth noting that the previousresolve()call was a cheap safety net with no downside.Prompt To Fix With AI
lib/storage.ts, line 2401-2407 (link)homecandidate skipsresolvePathwhile appdata candidates use itthe appdata candidates now go through
resolvePath(join(base, ...))(with a try/catch for out-of-root paths), but the.opencodehome candidate uses a barejoin:homedir()returns an absolute path in normal environments, so in practice this rarely matters. but the inconsistency means: ifhomedir()returns a relative path (e.g. in a containerised build environment or stripped-down CI runner), this candidate is resolved relative toprocess.cwd()rather than an absolute root — the same class of bug thatresolvePathwas added to guard against for appdata.Prompt To Fix With AI
Prompt To Fix All With AI
Last reviewed commit: "fix(sync-history): r..."