Fix OAuth sign-in app state handling#6
Conversation
|
🚀 Thank you @CheFu-code for the Pull Request! Our automated CI tests are spinning up now to check the changes. A maintainer will review your code shortly. 💖 Love what we're building? Support the ecosystem on GitHub Sponsors! |
|
Warning Review limit reached
More reviews will be available in 1 minute and 12 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 335a62da6e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| useEffect(() => { | ||
| const subscription = AppState.addEventListener("change", (nextState) => { | ||
| if (authPromptActiveRef.current) return; |
There was a problem hiding this comment.
Restore after canceled OAuth prompts
When sign-in is started while the initial restoreStoredSession() is still pending (the app opens login for any status other than authenticated) and the user cancels or dismisses the browser, this early return also suppresses the active transition that used to reload SecureStore. The cancel path then falls back to the stale session captured before restore, often null, leaving an existing valid stored session shown as guest until another app-state cycle or restart.
Useful? React with 👍 / 👎.
Motivation
AppStatetransitions were unconditionally starting a new auth operation which conflicted with an active external prompt.Description
authPromptActiveRefflag touseQuantumAuthand set it whilestartQuantumSignIn()is in progress to mark the OAuth prompt as active.AppStatechangelistener whenauthPromptActiveRef.currentistrueto avoid cancelling an in-flight sign-in when the app backgrounds.catchpaths to ensure the app resumes normalAppStatehandling after the prompt finishes.keeps the OAuth operation alive while the auth browser backgrounds the apptosrc/hooks/__tests__/useQuantumAuth.test.tsxthat mocksAppStateand verifies completion and persistence of the session.Testing
npm test -- useQuantumAuth.test.tsx --runInBand, which passed (4 passed, 4 total).npm run typecheck, which succeeded.npm run lint(expo lint), which completed without errors.Codex Task