Skip to content

Conversation

@MananTank
Copy link
Member

@MananTank MananTank commented Oct 23, 2025


PR-Codex overview

This PR addresses an issue where the Select Token UI gets stuck in a loading state when the wallet is connected to an unsupported chain in the BuyWidget, SwapWidget, and BridgeWidget. It refines the chain selection logic to improve functionality.

Detailed summary

  • Updated function name from getDefaultSelectedChain to findChain.
  • Added a check to return undefined if activeChainId is not provided.
  • Modified the logic to find the selected chain using findChain for better clarity and functionality.

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

Summary by CodeRabbit

  • Bug Fixes
    • Fixed Select Token components from remaining in a loading state when the connected wallet chain isn't supported by the Bridge (affects BuyWidget, SwapWidget, BridgeWidget).
  • Chores
    • Added a changeset entry for a patch release documenting the bugfix.

@linear
Copy link

linear bot commented Oct 23, 2025

@vercel
Copy link

vercel bot commented Oct 23, 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 Oct 24, 2025 0:20am
nebula Ready Ready Preview Comment Oct 24, 2025 0:20am
thirdweb_playground Ready Ready Preview Comment Oct 24, 2025 0:20am
thirdweb-www Ready Ready Preview Comment Oct 24, 2025 0:20am
wallet-ui Ready Ready Preview Comment Oct 24, 2025 0:20am

@changeset-bot
Copy link

changeset-bot bot commented Oct 23, 2025

🦋 Changeset detected

Latest commit: 3e9eb49

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

This PR includes changesets to release 4 packages
Name Type
thirdweb Patch
@thirdweb-dev/nebula Patch
@thirdweb-dev/wagmi-adapter Patch
wagmi-inapp 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

@MananTank MananTank marked this pull request as ready for review October 23, 2025 18:14
@MananTank MananTank requested review from a team as code owners October 23, 2025 18:14
@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Oct 23, 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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 23, 2025

Walkthrough

Change updates a changeset and modifies Select Token chain-resolution logic so the component sequentially tries the token's chain, the active wallet chain, then chain ID 1 to avoid persistent loading when the wallet is on an unsupported chain.

Changes

Cohort / File(s) Change Summary
Changeset metadata
/.changeset/fine-bobcats-rhyme.md
Added a patch release changeset describing a bugfix: Select Token components (BuyWidget, SwapWidget, BridgeWidget) no longer remain in a loading state when the connected wallet chain is unsupported by the thirdweb Bridge.
Select Token UI logic
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
Renamed internal helper (getDefaultSelectedChainfindChain) and updated chain-resolution to try sequential fallbacks: `findChain(data, selectedToken?.chainId)

Sequence Diagram(s)

sequenceDiagram
  participant UI as SelectTokenUI
  participant Data as AvailableChains
  participant Wallet as WalletState

  Note over UI: User opens Select Token component

  UI->>Data: findChain(selectedToken?.chainId)
  alt found
    Data-->>UI: chain
    UI->>UI: select chain
  else not found
    UI->>Wallet: get activeChain.id
    Wallet-->>UI: activeChain.id (may be undefined/unsupported)
    UI->>Data: findChain(activeChain.id)
    alt found
      Data-->>UI: chain
      UI->>UI: select chain
    else not found
      UI->>Data: findChain(1)
      Data-->>UI: fallback chain (1)
      UI->>UI: select fallback chain
    end
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description Check ⚠️ Warning The PR description does not adequately follow the provided template structure. While the author included the template comments and provided a PR-Codex generated overview of the changes, the required "Notes for the reviewer" and "How to test" sections are not filled out or addressed. The PR objectives confirm that "no additional testing instructions provided." The title includes the Linear issue tag (MNY-289) but the description itself lacks the specific reviewer notes and testing guidance that the template requires. The auto-generated PR-Codex summary describes the functional changes but does not substitute for the missing template sections. The author should fill out the "Notes for the reviewer" section with any important implementation details or considerations for reviewers, and must provide a "How to test" section with clear testing instructions such as unit test coverage, manual testing steps on the playground, or other validation methods to verify the bugfix works as intended. These sections are essential for effective code review of this bugfix affecting multiple widgets.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "[MNY-289] SDK: Fix token selection UI loading state when wallet is connected to a chain that is not supported by tw bridge" is fully related to the main change in the changeset. It clearly and specifically summarizes the bug being fixed: the Select Token UI remaining in a loading state when the wallet is connected to an unsupported chain. The title is concise, avoids vague terms or noise, and provides sufficient context for teammates scanning the pull request history to understand the primary fix.
Linked Issues Check ✅ Passed The code changes align with the objectives from linked issue MNY-289. The refactored chain selection logic (renaming getDefaultSelectedChain to findChain, handling undefined activeChainId, and implementing proper fallback logic) directly addresses the bug where the token selection UI remained stuck in a loading state when the wallet was connected to an unsupported chain. The changes ensure that appropriate chain fallbacks are applied across BuyWidget, SwapWidget, and BridgeWidget, meeting all stated objectives for fixing the UI bug and handling unsupported chains predictably.
Out of Scope Changes Check ✅ Passed All changes in this pull request are directly in scope with the linked issue MNY-289. The modification to select-token-ui.tsx implements the specific chain selection logic refinement needed to fix the UI loading state bug, and the changeset entry is a standard documentation practice for release management. No extraneous changes, refactoring, or unrelated features have been introduced.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 10-23-_mny-289_sdk_fix_token_selection_ui_loading_state_when_wallet_is_connected_to_a_chain_that_is_not_supported_by_tw_bridge

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.

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: 1

📜 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 d5d5939 and 4126563.

📒 Files selected for processing (2)
  • .changeset/fine-bobcats-rhyme.md (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx (2 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/fine-bobcats-rhyme.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/swap-widget/select-token-ui.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/swap-widget/select-token-ui.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/swap-widget/select-token-ui.tsx
🧬 Code graph analysis (1)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx (1)
packages/thirdweb/src/bridge/types/Chain.ts (1)
  • BridgeChain (42-42)
⏰ 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). (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx (1)

70-72: Excellent fix for the loading state bug.

The sequential fallback logic correctly handles unsupported chains. When the active wallet's chain ID is undefined, findChain returns undefined instead of forcing a default, allowing the loading UI (Lines 464-475) to properly display a spinner until a valid chain is selected or defaults to chain 1 as a final fallback.

.changeset/fine-bobcats-rhyme.md (1)

1-5: LGTM! Changeset properly documents the bug fix.

The patch version bump is appropriate for this non-breaking UI bug fix, and the description accurately captures the issue and affected widgets.

@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.90%. Comparing base (630edad) to head (3e9eb49).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...eact/web/ui/Bridge/swap-widget/select-token-ui.tsx 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8304      +/-   ##
==========================================
+ Coverage   54.89%   54.90%   +0.01%     
==========================================
  Files         919      919              
  Lines       60677    60675       -2     
  Branches     4125     4126       +1     
==========================================
+ Hits        33310    33315       +5     
+ Misses      27265    27259       -6     
+ Partials      102      101       -1     
Flag Coverage Δ
packages 54.90% <0.00%> (+0.01%) ⬆️
Files with missing lines Coverage Δ
...eact/web/ui/Bridge/swap-widget/select-token-ui.tsx 4.72% <0.00%> (+0.01%) ⬆️

... 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.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 23, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.55 KB (0%) 1.3 s (0%) 228 ms (+89.76% 🔺) 1.6 s
thirdweb (cjs) 365.82 KB (0%) 7.4 s (0%) 1.1 s (+8.15% 🔺) 8.4 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 72 ms (+1164.31% 🔺) 186 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 45 ms (+1762.44% 🔺) 56 ms
thirdweb/react (minimal + tree-shaking) 19.09 KB (0%) 382 ms (0%) 38 ms (+635.72% 🔺) 419 ms

@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 23, 2025

Merge activity

…nnected to a chain that is not supported by tw bridge (#8304)

<!--

## 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 `Select Token` UI being stuck in a loading state when the wallet is connected to an unsupported chain by the `thirdweb Bridge`. It modifies the logic for selecting the default chain in various widgets.

### Detailed summary
- Updated the function from `getDefaultSelectedChain` to `findChain` for clarity.
- Improved logic to handle cases where `activeChainId` is undefined.
- Adjusted the selection of `selectedChain` to use the new `findChain` function, ensuring proper fallback options.

> ✨ 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 Select Token components from remaining in loading state when the connected wallet chain is not supported by thirdweb Bridge. This affects BuyWidget, SwapWidget, and BridgeWidget.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@graphite-app graphite-app bot merged commit 3e9eb49 into main Oct 24, 2025
23 of 24 checks passed
@graphite-app graphite-app bot deleted the 10-23-_mny-289_sdk_fix_token_selection_ui_loading_state_when_wallet_is_connected_to_a_chain_that_is_not_supported_by_tw_bridge branch October 24, 2025 00:21
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.

2 participants