Skip to content

fix(ENG-12551): fix popup close not resetting state without COOP#133

Merged
adefreitas merged 2 commits intoStackOneHQ:mainfrom
adefreitas:ENG-12551/fix-popup-close-without-coop
Apr 16, 2026
Merged

fix(ENG-12551): fix popup close not resetting state without COOP#133
adefreitas merged 2 commits intoStackOneHQ:mainfrom
adefreitas:ENG-12551/fix-popup-close-without-coop

Conversation

@adefreitas
Copy link
Copy Markdown
Collaborator

@adefreitas adefreitas commented Apr 16, 2026

Summary

  • Detects COOP by checking if the popup appears closed immediately after window.open (browsers sever the reference under Cross-Origin-Opener-Policy: same-origin)
  • Only defers to server-side polling when COOP is actually detected
  • Without COOP, closing the popup now correctly cancels the connection attempt and resets to the form

Context

After merging the polling mechanism (#131), closing the OAuth popup without COOP left the Hub stuck in a loading state because active polling prevented the popup-close handler from resetting. This fix restores the original behavior for non-COOP environments while preserving the polling fallback for COOP.

Test plan

  • Open OAuth popup without COOP header → close it → Hub resets to form
  • Open OAuth popup with COOP header → popup appears closed immediately → Hub stays loading, polling continues
  • Complete OAuth flow normally with and without COOP → success state works

🤖 Generated with Claude Code


Summary by cubic

Fixes OAuth popup close behavior by detecting COOP and only using server-side polling when COOP is active. Without COOP, closing the popup now cancels the attempt and resets the Hub to the form (per ENG-12551).

  • Bug Fixes
    • Detect COOP by checking if the popup appears closed right after window.open.
    • Only keep polling when COOP is detected; otherwise, tear down OAuth, cancel the connection attempt, and reset state on popup close.
    • Capture attemptId before teardownOAuth clears the ref to ensure cancellation always fires.
    • Added coopDetectedRef and related logs to help debug popup and polling state.

Written for commit 21fecd6. Summary will update on new commits.

Without COOP, closing the OAuth popup should reset to the form.
Previously, active polling prevented this. Now we detect COOP by
checking if the popup appears closed immediately after opening
(browsers sever the window reference under same-origin COOP).
Only defer to polling when COOP is actually detected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 16, 2026 10:28
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Requires human review: Modifies core OAuth connection flow and polling logic, which is a high-impact business path that requires human verification.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts the OAuth popup lifecycle handling in the Integration Picker to avoid getting stuck in a loading state after popup close in non-COOP environments, while preserving the polling fallback behavior for COOP scenarios.

Changes:

  • Add COOP detection (coopDetectedRef) based on the popup appearing closed immediately after window.open.
  • Update the popup-close watcher to only “ignore close” when COOP is detected and polling is active; otherwise teardown + reset state.
  • Expand debug logging around popup-close handling to include COOP detection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/modules/integration-picker/hooks/useIntegrationPicker.ts Outdated
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

0 issues found across 1 file (changes from recent commits).

Requires human review: This PR modifies core business logic in the OAuth connection flow, specifically handling popup state and connection cancellation, which is a critical path requiring human review.

@adefreitas adefreitas merged commit fdae063 into StackOneHQ:main Apr 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants