fix(oauth): stabilize macOS embedded login popups - #852
Merged
Conversation
Collaborator
Author
|
The failing Rust job is a shared |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #845.
On macOS, opening an embedded Claude Code or Codex OAuth surface could close and recreate the native webview in a loop. Commit
61a08e2a3addeddocument.visibilityStateto the host visibility predicate; WKWebView can mark the parent document hidden while a native child webview owns the active login surface. The setup components then interpreted the closed webview as a signal to start a fresh login, repeatedly regenerating PKCE state and driving CPU usage to 75-95%.Google sign-in also used
WebviewWindowBuilder::build()synchronously inside the WebKitcreateNewPagecallback on macOS. That reentrant window construction matches the reported SIGABRT path and could terminate ORG2 when Google requested a popup.Solution
NewWindowResponse::Allow. Wry reuses the caller WKWebView configuration, preserveswindow.opener, and avoids constructing a Tauri window from insidecreateNewPage.The resulting invariants are: parent document visibility alone cannot close an active login surface; a mounted browser surface cannot start an unbounded sequence of PKCE attempts; and macOS OAuth popup callbacks do not synchronously build another Tauri window.
Potential risks
Verification
Automated checks:
pnpm vitest run src/features/SessionSetup/hooks/useEmbeddedWebview.test.ts src/features/SessionSetup/hooks/useOAuthBrowserAutoStart.test.ts src/features/SessionSetup/hooks/__tests__/useOAuthCapture.test.ts— 22 passed.cargo test --lib oauth::tests --no-fail-fast— 7 passed.pnpm typecheck— passed.pnpm run check:e2e-oauth-guards— passed.rustfmt --edition 2021 --checkon both changed OAuth adapters — passed.cargo clippy -p org2— passed.pnpm run tauri:build:fast -- --instance 3— produced the isolated macOS instance app.Manual checks on macOS 26.2 (25C56), isolated Instance 3:
accounts.google.comClaude popup three times without SIGABRT or crash logs.4b6e228ad; the resulting Instance 3 app rendered successfully from the isolated profile.The full frontend and Rust test suites were not run; verification was scoped to the owning OAuth boundaries, full TypeScript checking, clippy, a complete macOS app build, and end-to-end Claude Code OAuth authorization.
Audit