Skip to content

fix: coinbase popup polling fallback, retry reset, and animated alerts#2453

Merged
broody merged 1 commit intomainfrom
fix/coinbase-popup-improvements
Feb 27, 2026
Merged

fix: coinbase popup polling fallback, retry reset, and animated alerts#2453
broody merged 1 commit intomainfrom
fix/coinbase-popup-improvements

Conversation

@broody
Copy link
Contributor

@broody broody commented Feb 27, 2026

Summary

Three fixes for the Coinbase payment popup flow, plus a UX polish.

1. Fallback polling prevents stuck 'Complete in Popup'

Problem: If the BroadcastChannel signal from the popup was lost (e.g. browser restrictions, timing), the keychain would stay stuck on 'Complete in Popup' forever.

Fix: Start a slow 5s fallback poll as soon as the popup opens. This detects payment completion on the backend even without the popup signal. When polling_success arrives from the popup, the poll upgrades to 1s fast poll with a 15s timeout (same as before).

2. Terminal ref set on polling_success (race condition fix)

Problem: After successful payment, the popup closes after 1.5s. The popup-close watcher would detect this and set popupClosed=true before the backend confirmation poll completed, causing the UI to show 'Payment Window Closed' instead of progressing.

Fix: Set terminalReachedRef.current = true immediately on polling_success, not just when the backend confirms Completed.

3. Retry clears cancelled state in popup

Problem: After cancelling a payment and retrying within the same popup, the 'Payment Cancelled' alert stayed visible because pending_payment_auth, payment_authorized, and apple_pay_button_pressed events only set committed=true without clearing failed and error.

Fix: Clear failed and error on all active-payment events.

4. Animated status bar alerts

Problem: Status bar alerts popped in abruptly and shifted the Coinbase iframe down.

Fix: Status bar now overlays the top of the iframe with a translate-y slide-down animation (300ms ease-out). The iframe always fills the full screen.

Polling Strategy

Popup opens → 5s fallback poll (backend)
                    ↓ (if BroadcastChannel polling_success received)
              1s fast poll (15s timeout)
                    ↓ (on Completed/Failed)
              Stop all polls → navigate

@vercel
Copy link

vercel bot commented Feb 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
controller-example-next Ready Ready Preview Feb 27, 2026 6:52pm
keychain Ready Ready Preview Feb 27, 2026 6:52pm
keychain-storybook Ready Ready Preview Feb 27, 2026 6:52pm

Request Review

- Add 5s fallback poll that starts immediately when popup opens, so the
  keychain can detect payment completion even if BroadcastChannel signal
  is lost. Upgrades to 1s fast poll on polling_success from popup.
- Set terminalReachedRef on polling_success to prevent popup-closed race
  condition (stuck 'Complete in Popup' after successful payment).
- Clear failed/error state on retry events (pending_payment_auth,
  payment_authorized, apple_pay_button_pressed) so popup shows
  'Payment Processing' instead of lingering 'Payment Cancelled'.
- Animate status bar alerts with slide-down transition instead of
  abruptly shifting the iframe.
@broody broody force-pushed the fix/coinbase-popup-improvements branch from f162258 to cfbcb0a Compare February 27, 2026 18:51
@broody broody merged commit d882002 into main Feb 27, 2026
12 checks passed
@broody broody deleted the fix/coinbase-popup-improvements branch February 27, 2026 19:03
@claude
Copy link
Contributor

claude bot commented Feb 27, 2026

Claude finished @broody's task —— View job


Documentation Analysis

  • Analyze PR changes for user-facing impact
  • Determine documentation requirements

Result

No documentation updates needed.

This PR contains internal reliability improvements and UX polish for the Coinbase payment popup flow:

  1. Fallback polling mechanism - Internal reliability improvement to prevent stuck states
  2. Race condition fix - Internal timing fix for proper state transitions
  3. Retry state clearing - Internal bug fix for popup state management
  4. Animated status alerts - Visual polish (CSS transitions)

Why no docs changes:

  • No API changes - developers using @cartridge/controller or @cartridge/keychain see no difference in how they integrate
  • No new features or configuration options exposed
  • No behavioral changes that require developer action
  • Changes are entirely within the keychain's internal payment flow implementation

These improvements make the payment experience more reliable for end users, but the developer-facing integration remains unchanged.


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.

1 participant