Skip to content

feat(ENG-12551): add polling mechanism#131

Merged
adefreitas merged 4 commits intoStackOneHQ:mainfrom
adefreitas:ENG-12551/add-polling-mechanism
Apr 15, 2026
Merged

feat(ENG-12551): add polling mechanism#131
adefreitas merged 4 commits intoStackOneHQ:mainfrom
adefreitas:ENG-12551/add-polling-mechanism

Conversation

@adefreitas
Copy link
Copy Markdown
Collaborator

@adefreitas adefreitas commented Apr 15, 2026

Summary by cubic

Add server-driven OAuth polling to complete connections in cross-origin embeds where COOP breaks window.opener. This meets ENG-12551 by removing reliance on cross-origin messaging and improving reliability.

  • New Features

    • Create/poll/cancel connect attempts via /connect_sessions/connection_attempts; include connection_attempt_id in the OAuth URL; poll every 2s and handle authenticated/error/cancelled/expired.
    • Keep existing postMessage/BroadcastChannel/localStorage paths; automatically tear down polling/popup when any channel resolves.
    • Add a “Cancel and start over” action in the loading view (appears after 8s) that closes the popup and cancels the server attempt.
  • Refactors

    • Extract startPolling and startPopupWatcher; switch to self-scheduling setTimeout to avoid overlap; use debugRef to prevent stale closures; flatten popup watcher with early returns; clean up and cancel server attempts when the popup is blocked or closed.
    • Update dev server: set cross-origin-opener-policy: same-origin and change port to 3000.
    • Thread onCancelOAuth through IntegrationPicker → content → loading component; remove default integrationId in dev for cleaner testing.

Written for commit 2541138. Summary will update on new commits.

Copilot AI review requested due to automatic review settings April 15, 2026 16:17
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.

Comment thread src/modules/integration-picker/hooks/useIntegrationPicker.ts
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

Adds a connection-attempt polling flow to the Integration Picker’s OAuth path so the hub can detect completion/cancellation even when popup messaging is unreliable.

Changes:

  • Add API helpers for creating/polling/cancelling connection_attempts.
  • Update useIntegrationPicker to create an attempt, poll for status, and expose a cancel action.
  • Extend loading UI to optionally show a delayed “Cancel and start over” action.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
vite.config.ts Adjusts dev server port and adds COOP header configuration.
src/shared/components/loading.tsx Adds optional cancel callback with an 8s delayed cancel prompt.
src/modules/integration-picker/queries.ts Adds create/poll/cancel connection attempt request helpers and types.
src/modules/integration-picker/hooks/useIntegrationPicker.ts Implements connection attempt creation, polling loop, teardown, and cancel handler.
src/modules/integration-picker/components/views/LoadingView.tsx Passes optional onCancel through to Loading.
src/modules/integration-picker/components/IntegrationPickerContent.tsx Wires onCancelOAuth into the loading view.
src/modules/integration-picker/IntegrationPicker.tsx Exposes handleCancelOAuth from the hook down into content.
dev/main.tsx Modifies dev demo integrationId initialization.
dev/SuspenseMRE.tsx Updates hook dependency arrays and adds a React import.

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

Comment thread src/modules/integration-picker/hooks/useIntegrationPicker.ts
Comment thread src/modules/integration-picker/hooks/useIntegrationPicker.ts
Comment thread src/modules/integration-picker/hooks/useIntegrationPicker.ts Outdated
Comment thread vite.config.ts
Comment thread vite.config.ts
Comment thread dev/main.tsx Outdated
Comment thread dev/SuspenseMRE.tsx Outdated
Comment thread src/modules/integration-picker/hooks/useIntegrationPicker.ts
…back

- Extract startPolling and startPopupWatcher into standalone callbacks
- Replace setInterval with self-scheduling setTimeout to prevent overlap
- Use debugRef to avoid stale debug closure in all callbacks
- Clean up server-side attempt when popup is blocked
- Cancel leaked attempt on popup block

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread src/modules/integration-picker/hooks/useIntegrationPicker.ts Outdated
adefreitas and others added 2 commits April 15, 2026 17:31
- Flatten startPopupWatcher nesting with early returns
- Fix SuspenseMRE lint: remove unused React import, remove unnecessary setConnectState deps
- Cancel leaked server-side attempt on popup block

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@adefreitas adefreitas merged commit cdcc8df into StackOneHQ:main Apr 15, 2026
3 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