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: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
add ChatGPT device-code login flow
add ChatGPT device-code login flow
Summary
ChatGPT Plus/Pro MULTI (Device Code)login path, extracted shared account-selection and persistence helpers, and updated the browser/manual fallback messaging around localhost callback failures.Testing
npm run lintnpm run buildnpm testCompliance Confirmation
Notes
persistAccountPoolstays behindwithAccountStorageTransactionwith overlapping-write coverage intest/login-runner.test.ts.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 device-code login path (
lib/auth/device-code.ts) for ssh, wsl, and headless users and extracts the sharedresolveAccountSelection+persistAccountPoolhelpers intolib/auth/login-runner.ts, deduplicating the three previously-inline copies inindex.ts. the new auth method sits between the browser-oauth and manual-url-paste entries in the methods list.key things done well
getRedactedErrorBodytruncates error bodies to 120 chars before logging — addresses the prior review concern on both the usercode and poll paths, with dedicated test coverage intest/device-code.test.tspersistAccountPoolis documented with a JSDoc block explaining whywithAccountStorageTransactionserialises concurrent writes and handles the windows lock-retry pathtest/login-runner.test.tsincludes a concrete concurrency regression test that blocks the firstfs.renameand verifies both accounts survive a simultaneous login — directly exercises the windows-safety claimparseIntervalSecondsenforces a floor of 1 second, preventing a busy-loop on a server returning 0remaining p2 items
authorizecallback always passesfalseasreplaceAlltopersistAuthenticatedSelections, so a "start fresh" login via device code silently keeps existing accounts rather than replacing them — this is consistent with the manual-url-paste flow and noted in the PR, but a short inline comment would prevent confusion for future maintainerscompleteDeviceCodeSessionhardcodes "15 minutes" regardless of themaxWaitMsoption — fine for production use, minor inaccuracy in testsConfidence Score: 4/5
startFreshgap acknowledged — no production bugs, no data loss risklogin-runner.tsis a faithful lift with no logic changes. test coverage covers the new paths including concurrent persist and body-truncation.startFresh: falsehardcoding is the only item that deserves a follow-up if "start fresh via device code" behaviour is ever neededImportant Files Changed
Sequence Diagram
sequenceDiagram participant U as User participant P as Plugin (index.ts) participant DC as device-code.ts participant AS as Auth Server participant LR as login-runner.ts participant S as Storage (withAccountStorageTransaction) U->>P: select "Device Code" auth method P->>DC: createDeviceCodeSession() DC->>AS: POST /api/accounts/deviceauth/usercode AS-->>DC: { device_auth_id, user_code, interval } DC-->>P: DeviceCodeReadyResult { session } P-->>U: show verificationUrl + userCode instructions U->>AS: open verificationUrl, enter userCode P->>DC: completeDeviceCodeSession(session) loop poll every intervalSeconds (403/404 = pending) DC->>AS: POST /api/accounts/deviceauth/token AS-->>DC: 403 (pending) or { authorization_code, code_verifier } end DC->>AS: exchangeAuthorizationCode(authCode, codeVerifier, redirectUri) AS-->>DC: TokenResult (access + refresh tokens) DC-->>P: TokenResult success P->>LR: resolveAccountSelection(tokens) LR-->>P: AccountSelectionResult { primary, variantsForPersistence } P->>LR: persistAccountPool(variants, replaceAll=false) LR->>S: withAccountStorageTransaction (serialized write) S-->>LR: persisted P-->>U: login completePrompt To Fix All With AI
Reviews (2): Last reviewed commit: "fix(auth): redact device-code logs" | Re-trigger Greptile
Context used: