Skip to content

Conversation

@MananTank
Copy link
Member

@MananTank MananTank commented Sep 15, 2025


PR-Codex overview

This PR addresses an issue where the onSuccess callback was not correctly triggered in the CheckoutWidget and BuyWidget components, improving the handling of buy completion and post-buy transaction completion.

Detailed summary

  • Renamed handleBuyComplete to handleDoneOrContinueClick.
  • Updated the logic in handleExecutionComplete to call onComplete only if uiOptions.mode is not "transaction".
  • Changed the onDone prop in SuccessScreen to use handleDoneOrContinueClick.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue where the success/onComplete callback in Checkout and Buy widgets did not fire reliably; non-transaction flows now trigger completion after execution finishes, improving state reset and consistency.
  • Chores

    • Added a patch-level changeset entry documenting the fix.

@vercel
Copy link

vercel bot commented Sep 15, 2025

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

Project Deployment Preview Comments Updated (UTC)
docs-v2 Ready Ready Preview Comment Sep 17, 2025 11:08am
nebula Ready Ready Preview Comment Sep 17, 2025 11:08am
thirdweb_playground Ready Ready Preview Comment Sep 17, 2025 11:08am
thirdweb-www Ready Ready Preview Comment Sep 17, 2025 11:08am
wallet-ui Ready Ready Preview Comment Sep 17, 2025 11:08am

@changeset-bot
Copy link

changeset-bot bot commented Sep 15, 2025

🦋 Changeset detected

Latest commit: 15f0839

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
thirdweb Patch
@thirdweb-dev/nebula Patch
@thirdweb-dev/wagmi-adapter Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 15, 2025

Walkthrough

Moves the non-transaction onComplete invocation from the SuccessScreen "Done" action into the execution-complete phase in BridgeOrchestrator; renames and re-wires the done/continue handler. Adds a patch changeset entry documenting the fix for onSuccess in CheckoutWidget/BuyWidget.

Changes

Cohort / File(s) Summary
Release notes / changeset
.changeset/slimy-chefs-buy.md
Adds a patch-level changeset for thirdweb documenting a fix where the onSuccess/onComplete callback was not invoked correctly in CheckoutWidget and BuyWidget.
Bridge orchestration flow
packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx
Renames handleBuyCompletehandleDoneOrContinueClick; reworks flow so non-transaction mode calls onComplete during handleExecutionComplete (EXECUTION_COMPLETE) instead of on SuccessScreen "Done"; updates dependency array and wires SuccessScreen onDone to the renamed handler; transaction mode retains CONTINUE_TO_TRANSACTION behavior.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant BO as BridgeOrchestrator
  participant Exec as Execution Flow
  participant UI as SuccessScreen

  rect rgb(240,248,255)
    note over BO: Non-transaction mode (changed)
    U->>BO: Start checkout/buy
    BO->>Exec: Execute flow
    Exec-->>BO: EXECUTION_COMPLETE
    BO-->>U: onComplete() invoked
    BO->>UI: Show SuccessScreen
    U->>UI: Click Done
    UI->>BO: handleDoneOrContinueClick
    BO->>BO: Reset state (no onComplete here)
  end

  rect rgb(245,245,245)
    note over BO: Transaction mode (unchanged)
    U->>BO: Start checkout/buy
    BO->>Exec: Execute flow
    Exec-->>BO: EXECUTION_COMPLETE
    BO->>BO: CONTINUE_TO_TRANSACTION
    BO->>UI: Show SuccessScreen
    U->>UI: Click Continue/Done
    UI->>BO: handleDoneOrContinueClick
    BO->>BO: Continue to transaction (as applicable)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description contains a useful PR-Codex overview and a clear summary of code changes but only includes the repository template as an unfilled comment; required sections such as "Notes for the reviewer", an issue/Linear tag, and explicit "How to test" steps are missing. Because those template fields (especially testing instructions) are expected for reviewers to validate the change, the description is incomplete relative to the repository's required template. Please update the PR description to populate the repository template: add the formatted PR title or issue tag, fill "Notes for the reviewer" with any important context or risks, and provide concrete "How to test" steps (unit tests, playground instructions, reproduction steps and expected behavior). After those sections are added the description will meet the template requirements and be ready for review.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly and accurately summarizes the primary change—fixing the onSuccess prop invocation in CheckoutWidget and BuyWidget—and directly reflects the code updates described in the PR (BridgeOrchestrator adjustments). It is clear, specific, and short enough for a reviewer scanning history to understand the main purpose.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 09-16-sdk_fix_onsuccess_prop_not_called_properly_on_checkoutwidget_and_buywidget

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3a2a852 and 15f0839.

📒 Files selected for processing (2)
  • .changeset/slimy-chefs-buy.md (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • .changeset/slimy-chefs-buy.md
  • packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.

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

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Sep 15, 2025
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 15, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 63.96 KB (0%) 1.3 s (0%) 353 ms (+133.13% 🔺) 1.7 s
thirdweb (cjs) 361.44 KB (0%) 7.3 s (0%) 1.4 s (+12.39% 🔺) 8.7 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 166 ms (+2352.22% 🔺) 281 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 90 ms (+2766.32% 🔺) 100 ms
thirdweb/react (minimal + tree-shaking) 19.15 KB (0%) 383 ms (0%) 141 ms (+2182.12% 🔺) 524 ms

@codecov
Copy link

codecov bot commented Sep 15, 2025

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.53%. Comparing base (04862de) to head (15f0839).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...web/src/react/web/ui/Bridge/BridgeOrchestrator.tsx 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8054      +/-   ##
==========================================
- Coverage   56.54%   56.53%   -0.01%     
==========================================
  Files         904      904              
  Lines       58871    58873       +2     
  Branches     4170     4165       -5     
==========================================
- Hits        33287    33283       -4     
- Misses      25478    25484       +6     
  Partials      106      106              
Flag Coverage Δ
packages 56.53% <0.00%> (-0.01%) ⬇️
Files with missing lines Coverage Δ
...web/src/react/web/ui/Bridge/BridgeOrchestrator.tsx 6.93% <0.00%> (-0.06%) ⬇️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx (3)

229-237: onComplete moved to execution-complete (non-transaction): watch ordering divergence vs post‑buy path

Here you call send(...) before onComplete for non-transaction flows, but in handlePostBuyTransactionComplete you call onComplete then send. Divergent ordering can cause subtle differences (e.g., callbacks reading state/context before/after reset, or unmount timing). Pick one order and keep it consistent; I’d lean toward “send then onComplete” to avoid dispatching to an unmounted machine if onComplete closes the UI.

Option: standardize post‑buy to match this path (send first), leaving this block unchanged.

@@
-const handlePostBuyTransactionComplete = useCallback(() => {
-  onComplete?.();
-  send({ type: "RESET" });
-}, [onComplete, send]);
+const handlePostBuyTransactionComplete = useCallback(() => {
+  send({ type: "RESET" });
+  onComplete?.();
+}, [onComplete, send]);

Please sanity‑check both flows to ensure onComplete fires exactly once and the UI doesn’t flicker/close prematurely.


85-86: Optional chaining on required props is unnecessary; remove for type clarity

onComplete, onError, and onCancel are non‑optional in BridgeOrchestratorProps but are invoked with optional chaining. Drop the ?. to surface contract violations at compile time.

-  onComplete?.();
+  onComplete();

-  onError?.(error);
+  onError(error);

-            onCancel?.();
+            onCancel();

Also applies to: 90-91, 95-96, 192-196, 198-205, 260-269


141-158: Add explicit return type for BridgeOrchestrator

Per guidelines for .ts/.tsx, add an explicit return type.

-export function BridgeOrchestrator({
+export function BridgeOrchestrator({
   client,
   uiOptions,
   receiverAddress,
   onComplete,
   onError,
   onCancel,
   connectOptions,
   connectLocale,
   purchaseData,
   paymentLinkId,
   presetOptions,
   paymentMethods = ["crypto", "card"],
   showThirdwebBranding = true,
   supportedTokens,
   country = "US",
-}: BridgeOrchestratorProps) {
+}: BridgeOrchestratorProps): JSX.Element {
.changeset/slimy-chefs-buy.md (1)

5-5: Tighten wording for the changeset entry

Smoother phrasing and consistent naming.

-Fix `onSuccess` callback was not called correctly on `CheckoutWidget`, `BuyWidget` components
+Fix onSuccess not being called correctly in CheckoutWidget and BuyWidget components.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 210f631 and 3a2a852.

📒 Files selected for processing (2)
  • .changeset/slimy-chefs-buy.md (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

.changeset/*.md: Each change in packages/* must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API

Files:

  • .changeset/slimy-chefs-buy.md
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx
packages/thirdweb/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

packages/thirdweb/**/*.{ts,tsx}: Every public symbol must have comprehensive TSDoc with at least one compiling @example and a custom tag (@beta, @internal, @experimental, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g., const { jsPDF } = await import("jspdf"))

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Build Packages
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx (2)

395-395: SuccessScreen.onDone wired correctly to the new handler

This connects the success action to the unified handler; good.


183-190: Rename + behavior shift confirmed — SuccessScreen.onDone now only resets/continues

Verified: SuccessScreen’s Done button calls onDone (packages/thirdweb/src/react/web/ui/Bridge/payment-success/SuccessScreen.tsx) which is wired to BridgeOrchestrator.handleDoneOrContinueClick — it sends RESET for non-transaction flows or CONTINUE_TO_TRANSACTION for transaction flows. onComplete is still invoked from BridgeOrchestrator.handleExecutionComplete (non-transaction) and handlePostBuyTransactionComplete (post-transaction). No stale references to the old handler name found.

@graphite-app
Copy link
Contributor

graphite-app bot commented Sep 17, 2025

Merge activity

…Widget (#8054)

<!--

## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes"

If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000):

## Notes for the reviewer

Anything important to call out? Be sure to also clarify these in your comments.

## How to test

Unit tests, playground, etc.

-->

<!-- start pr-codex -->

---

## PR-Codex overview
This PR addresses an issue with the `onSuccess` callback not being triggered properly in the `CheckoutWidget` and `BuyWidget` components, improving the handling of buy completion and post-transaction actions.

### Detailed summary
- Renamed `handleBuyComplete` to `handleDoneOrContinueClick`.
- Adjusted the invocation of `onComplete` to only occur when `uiOptions.mode` is not "transaction".
- Updated the dependency array for `handleExecutionComplete` to include `onComplete` and `uiOptions.mode`.
- Changed the `onDone` prop in `SuccessScreen` to use `handleDoneOrContinueClick`.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Bug Fixes**
  * Fixed an issue where the success callback in checkout and buy widgets did not fire reliably.
  * Improved non-transaction flows so completion triggers after execution finishes (instead of on Done), ensuring proper state reset and more consistent behavior.

* **Chores**
  * Added a patch-level changeset entry documenting the fix.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@graphite-app graphite-app bot force-pushed the 09-16-sdk_fix_onsuccess_prop_not_called_properly_on_checkoutwidget_and_buywidget branch from 3a2a852 to 15f0839 Compare September 17, 2025 10:47
@graphite-app graphite-app bot merged commit 15f0839 into main Sep 17, 2025
24 of 25 checks passed
@graphite-app graphite-app bot deleted the 09-16-sdk_fix_onsuccess_prop_not_called_properly_on_checkoutwidget_and_buywidget branch September 17, 2025 11:09
@joaquim-verges joaquim-verges mentioned this pull request Sep 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages SDK Involves changes to the thirdweb SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants