Skip to content

Fix OAuth sign-in app state handling#6

Merged
CheFu-code merged 1 commit into
mainfrom
codex/fix-signing-implementation-issue
Jun 20, 2026
Merged

Fix OAuth sign-in app state handling#6
CheFu-code merged 1 commit into
mainfrom
codex/fix-signing-implementation-issue

Conversation

@CheFu-code

Copy link
Copy Markdown
Owner

Motivation

  • The OAuth sign-in flow could be cancelled when the external auth browser backgrounds the app, invalidating the in-flight handshake and breaking sign-in completion.
  • AppState transitions were unconditionally starting a new auth operation which conflicted with an active external prompt.
  • Preserve the pending OAuth operation while the system browser is active so the redirect result can be processed correctly.

Description

  • Add an authPromptActiveRef flag to useQuantumAuth and set it while startQuantumSignIn() is in progress to mark the OAuth prompt as active.
  • Short-circuit the AppState change listener when authPromptActiveRef.current is true to avoid cancelling an in-flight sign-in when the app backgrounds.
  • Clear the flag in both the success and catch paths to ensure the app resumes normal AppState handling after the prompt finishes.
  • Add a regression test keeps the OAuth operation alive while the auth browser backgrounds the app to src/hooks/__tests__/useQuantumAuth.test.tsx that mocks AppState and verifies completion and persistence of the session.

Testing

  • Ran the focused unit tests with npm test -- useQuantumAuth.test.tsx --runInBand, which passed (4 passed, 4 total).
  • Ran the TypeScript check with npm run typecheck, which succeeded.
  • Ran the linter with npm run lint (expo lint), which completed without errors.

Codex Task

@github-actions

Copy link
Copy Markdown

🚀 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!

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@CheFu-code, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 994aec1a-0b69-476b-bdd6-fb840d3a41b5

📥 Commits

Reviewing files that changed from the base of the PR and between dc490ac and 335a62d.

📒 Files selected for processing (2)
  • src/hooks/__tests__/useQuantumAuth.test.tsx
  • src/hooks/useQuantumAuth.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-signing-implementation-issue

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@CheFu-code CheFu-code merged commit 0166d53 into main Jun 20, 2026
4 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant