Skip to content

Conversation

@MananTank
Copy link
Member

@MananTank MananTank commented Dec 4, 2025


PR-Codex overview

This PR focuses on improving the SelectToken component in the token selection UI of the SwapWidget by removing tabs, consolidating token limits, and enhancing the handling of token lists.

Detailed summary

  • Removed tab functionality from the token selection UI.
  • Consolidated token limits into a single INITIAL_LIMIT variable.
  • Updated state management for token limits.
  • Simplified token data handling by removing unnecessary .data references.
  • Improved rendering logic for owned and other tokens.
  • Enhanced loading states and button functionality for loading more tokens.

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

Summary by CodeRabbit

  • UI Improvements

    • Redesigned token selection in SwapWidget: removed tab navigation, now shows clear "Your Tokens" and "Other Tokens" sections, unified list behavior, and updated icons for quicker recognition.
  • Bug Fixes

    • Improved search and loading behavior so filters reset correctly and loading/no-results states are handled consistently.
  • Chores

    • Patch release prepared for the project.

✏️ Tip: You can customize this high-level summary in your review settings.

@linear
Copy link

linear bot commented Dec 4, 2025

@vercel
Copy link

vercel bot commented Dec 4, 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 Dec 4, 2025 10:19pm
nebula Ready Ready Preview Comment Dec 4, 2025 10:19pm
thirdweb_playground Ready Ready Preview Comment Dec 4, 2025 10:19pm
thirdweb-www Ready Ready Preview Comment Dec 4, 2025 10:19pm
wallet-ui Ready Ready Preview Comment Dec 4, 2025 10:19pm

@changeset-bot
Copy link

changeset-bot bot commented Dec 4, 2025

🦋 Changeset detected

Latest commit: b0eccf3

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 December 4, 2025 21:41
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

Walkthrough

SwapWidget's token selection UI removes tab-based navigation, consolidates dual per-section limits into a single INITIAL_LIMIT with unified limit state, flattens token data into arrays, aggregates fetching state, and conditionally renders "Your Tokens" and "Other Tokens" sections with icons.

Changes

Cohort / File(s) Summary
Changeset declaration
​.changeset/rotten-loops-draw.md
New changeset file for a patch release noting the SwapWidget token selection UI refinement (tabs removed).
Token selection UI refactor
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
Removed tab-based navigation and TabButton. Replaced separate ALL/OWNED token limits with a single INITIAL_LIMIT and unified limit state reset on search. Flattened data shapes to allTokens: Token[] and ownedTokens: TokenBalance[]; unified isFetching from both queries; centralized show-more logic; added CoinsIcon and WalletDotIcon; conditional "Your Tokens"/"Other Tokens" headers; simplified desktop/mobile render and loading/empty handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify INITIAL_LIMIT reset behavior on search term change and potential re-render impacts.
  • Confirm isFetching = tokensQuery.isFetching || ownedTokensQuery.isFetching correctly represents combined loading state.
  • Check conditional rendering for "Your Tokens" and "Other Tokens" in edge cases (no owned tokens, no other tokens).
  • Ensure removal of TabButton didn't leave unused exports or break external references.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR removes tabs but does not implement the core requirements from MNY-318: showing only 'Your Tokens' for sell variant, removing balanceless chains, or adjusting copy text. Implement sell/buy variant logic to show 'Your Tokens' only for sell tokens, filter balanceless chains, and adjust UI copy as specified in MNY-318.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive While the description includes a PR-Codex overview, it lacks specific details about sell/buy variant behavior and testing instructions, creating ambiguity about completeness. Add explicit testing instructions and clarify whether sell/buy token variants are addressed as specified in MNY-318.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: removing tabs from token selection UI in SwapWidget, which aligns with the primary refactoring shown in the code changes.
Out of Scope Changes check ✅ Passed The tab removal refactoring and unified limit consolidation are directly scoped to the token selection UI improvements mentioned in the linked issue.
✨ 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 mny-318

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.

@MananTank MananTank requested review from a team as code owners December 4, 2025 21:41
@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Dec 4, 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.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx (1)

528-590: "Other Tokens" header condition likely should depend on otherTokens

Currently, the "Other Tokens" header is rendered only when props.ownedTokens.length > 0 (Line 566), not when props.otherTokens is non-empty. That means if a wallet has no owned tokens but otherTokens are available, the list renders without any section header.

If the intent is to label the secondary list whenever there are "other" tokens, you likely want:

-            {!props.isFetching && props.ownedTokens.length > 0 && (
+            {!props.isFetching && props.otherTokens.length > 0 && (
               <Container
                 px="xs"
                 py="xs"
                 flex="row"
                 gap="xs"
                 center="y"
                 color="secondaryText"
                 style={{
                   marginTop: spacing.sm,
                 }}
               >
                 <CoinsIcon size="14" />
                 <Text
                   size="sm"
                   color="secondaryText"
                   style={{
                     overflow: "unset",
                   }}
                 >
                   Other Tokens
                 </Text>
               </Container>
             )}

If hiding this header when there are no owned tokens is intentional, consider adding a different label or comment to make that behavior explicit.

🧹 Nitpick comments (5)
packages/thirdweb/src/react/web/ui/ConnectWallet/icons/SectionIcon.tsx (1)

3-21: Make size prop slightly more flexible to match other icons

To keep this aligned with other icon components (like WalletDotIcon) and avoid friction if callers pass numeric sizes, consider widening the prop type:

-export const SectionIcon: React.FC<{ size: string }> = ({ size }) => {
+export const SectionIcon: React.FC<{ size: number | string }> = ({ size }) => {

If you have a shared IconFC alias for icons in this folder, you could also type SectionIcon with that for consistency.

packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx (4)

13-14: Use design-system icon sizes instead of hard-coded "14"

You already import iconSize, so these section headers can avoid magic numbers:

-                <WalletDotIcon size="14" />
+                <WalletDotIcon size={iconSize.sm} />
...
-                <CoinsIcon size="14" />
+                <CoinsIcon size={iconSize.sm} />

This keeps icon sizing consistent with the rest of the design system and easier to tweak centrally.

Also applies to: 528-547, 566-588


55-69: Unified pagination looks good; prefer functional state update for limit

The shared INITIAL_LIMIT + single limit state and resetting it on search is a nice simplification; wiring limit into both queries and showMore is clear.

For the showMore handler, a functional state update is slightly safer against stale closures:

      showMore={
        tokensQuery.data?.length === limit
          ? () => {
-              setLimit(limit + INITIAL_LIMIT);
+              setLimit((prev) => prev + INITIAL_LIMIT);
            }
          : undefined
      }

This avoids depending on the captured limit value if the handler ever gets reused across renders.

Also applies to: 83-99, 112-119, 126-133, 607-617


158-167: Avoid mutating props when sorting token arrays

At Line 158 and Line 183 you call .sort directly on props.ownedTokens and otherTokens. Since Array.prototype.sort mutates in place, this can lead to subtle bugs if those arrays are reused elsewhere or across renders.

Safer pattern:

  const sortedOwnedTokens = useMemo(() => {
-    return props.ownedTokens.sort((a, b) => {
+    return [...props.ownedTokens].sort((a, b) => {
       if (a.icon_uri && !b.icon_uri) return -1;
       if (!a.icon_uri && b.icon_uri) return 1;
       return 0;
     });
  }, [props.ownedTokens]);

  const sortedOtherTokens = useMemo(() => {
-    return otherTokens.sort((a, b) => {
+    return [...otherTokens].sort((a, b) => {
       if (a.iconUri && !b.iconUri) return -1;
       if (!a.iconUri && b.iconUri) return 1;
       return 0;
     });
  }, [otherTokens]);

This keeps props immutable and avoids cross-render mutation of memoized arrays.

Also applies to: 169-179, 182-193


438-448: Verify sell vs buy variant behavior and copy requirements are satisfied

MNY-318 calls out differing behavior for sell (from) vs buy (to) token selection (sell: “Your Tokens” only, balanceless chains hidden, adjusted copy; buy: existing behavior). TokenSelectionScreen currently:

  • Uses a fixed title and description (“Select Token”, “Select a token from the list or use the search”) regardless of context (Lines 450–466).
  • Always derives noTokensFound from both ownedTokens and otherTokens (Lines 445–448, 619–632).
  • Relies on ownedTokens / otherTokens props but does not have an explicit variant flag.

Please double-check that the caller of SelectToken / TokenSelectionScreen passes variant-specific props (e.g., omits otherTokens for the sell case and adjusts copy), or else consider threading a variant: "sell" | "buy" prop down so this component can:

  • Hide or skip rendering the otherTokens section in the sell variant.
  • Adjust the header/description copy as per the spec.
  • Potentially tweak the empty state text if needed.

If you’d like, I can sketch how to add a variant prop and gate otherTokens + copy on it.

Also applies to: 450-467, 522-527, 619-632

📜 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 e516b4d and 8fbc826.

📒 Files selected for processing (3)
  • .changeset/rotten-loops-draw.md (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx (15 hunks)
  • packages/thirdweb/src/react/web/ui/ConnectWallet/icons/SectionIcon.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each TypeScript 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 in TypeScript
Avoid any and unknown in TypeScript unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.) in TypeScript

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

Files:

  • packages/thirdweb/src/react/web/ui/ConnectWallet/icons/SectionIcon.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
packages/thirdweb/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/thirdweb/src/**/*.{ts,tsx}: Comment only ambiguous logic in SDK code; avoid restating TypeScript in prose
Load heavy dependencies inside async paths to keep initial bundle lean (e.g. const { jsPDF } = await import("jspdf");)

Lazy-load heavy dependencies inside async paths to keep the initial bundle lean (e.g., const { jsPDF } = await import('jspdf');)

Files:

  • packages/thirdweb/src/react/web/ui/ConnectWallet/icons/SectionIcon.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
**/*.{js,jsx,ts,tsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Biome governs formatting and linting; its rules live in biome.json. Run pnpm fix & pnpm lint before committing, ensure there are no linting errors

Files:

  • packages/thirdweb/src/react/web/ui/ConnectWallet/icons/SectionIcon.tsx
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Lazy-import optional features; avoid top-level side-effects

Files:

  • packages/thirdweb/src/react/web/ui/ConnectWallet/icons/SectionIcon.tsx
  • 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 (5)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts (2)
  • useTokenBalances (74-121)
  • TokenBalance (42-60)
packages/thirdweb/src/bridge/types/Chain.ts (1)
  • BridgeChain (42-42)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (1)
  • TokenSelection (149-152)
packages/thirdweb/src/react/web/ui/ConnectWallet/icons/WalletDotIcon.tsx (1)
  • WalletDotIcon (6-22)
packages/thirdweb/src/react/web/ui/components/text.tsx (1)
  • Text (18-34)
⏰ 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: Vercel Agent Review
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Unit Tests
  • GitHub Check: Size
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
.changeset/rotten-loops-draw.md (1)

1-5: Changeset summary and patch bump look appropriate

The changeset correctly marks a patch release for "thirdweb" and succinctly describes the token selection UI change. No issues here.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

size-limit report 📦

Path Size
@thirdweb-dev/nexus (esm) 105.66 KB (0%)
@thirdweb-dev/nexus (cjs) 319.47 KB (0%)

@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 3.12500% with 93 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.65%. Comparing base (f3525c7) to head (b0eccf3).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...eact/web/ui/Bridge/swap-widget/select-token-ui.tsx 3.12% 93 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8501      +/-   ##
==========================================
+ Coverage   54.62%   54.65%   +0.03%     
==========================================
  Files         920      920              
  Lines       61142    61102      -40     
  Branches     4142     4144       +2     
==========================================
+ Hits        33397    33398       +1     
+ Misses      27643    27602      -41     
  Partials      102      102              
Flag Coverage Δ
packages 54.65% <3.12%> (+0.03%) ⬆️
Files with missing lines Coverage Δ
...eact/web/ui/Bridge/swap-widget/select-token-ui.tsx 4.88% <3.12%> (+0.53%) ⬆️
🚀 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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx (1)

100-110: Pass search term to useTokenBalances API or document the limitation.

The owned tokens are filtered client-side (lines 100–110), while tokensQuery passes debouncedSearch server-side (line 86). The useTokenBalances API endpoint does not accept a search parameter, so if a user owns more than limit tokens, a search will only filter within the initially fetched batch and miss matching tokens beyond that boundary. Either extend useTokenBalances to accept and pass a search parameter to the API, or clearly document this limitation in the component.

🧹 Nitpick comments (1)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx (1)

445-448: LGTM: Correct empty state handling.

The noTokensFound logic correctly distinguishes between loading states and genuinely empty results. The loading skeleton approach is functional.

Optional: Consider showing a loading indicator on the "Load More" button during pagination instead of replacing the entire list with skeletons, which would provide better continuity during "Load More" operations.

Also applies to: 522-526, 619-632

📜 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 8fbc826 and d9e3b24.

📒 Files selected for processing (2)
  • .changeset/rotten-loops-draw.md (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx (15 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/rotten-loops-draw.md
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each TypeScript 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 in TypeScript
Avoid any and unknown in TypeScript unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.) in TypeScript

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

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
packages/thirdweb/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/thirdweb/src/**/*.{ts,tsx}: Comment only ambiguous logic in SDK code; avoid restating TypeScript in prose
Load heavy dependencies inside async paths to keep initial bundle lean (e.g. const { jsPDF } = await import("jspdf");)

Lazy-load heavy dependencies inside async paths to keep the initial bundle lean (e.g., const { jsPDF } = await import('jspdf');)

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
**/*.{js,jsx,ts,tsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Biome governs formatting and linting; its rules live in biome.json. Run pnpm fix & pnpm lint before committing, ensure there are no linting errors

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Lazy-import optional features; avoid top-level side-effects

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 (3)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts (2)
  • useTokenBalances (74-121)
  • TokenBalance (42-60)
packages/thirdweb/src/bridge/types/Chain.ts (1)
  • BridgeChain (42-42)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (1)
  • TokenSelection (149-152)
⏰ 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). (3)
  • GitHub Check: Size
  • GitHub Check: Unit Tests
  • GitHub Check: Vercel Agent Review
🔇 Additional comments (4)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx (4)

13-14: LGTM: Clean consolidation of pagination constants.

The icon imports support the new section headers, and unifying the token limits into a single INITIAL_LIMIT simplifies the pagination logic.

Also applies to: 55-55


64-69: LGTM: Clean search-triggered limit reset.

Resetting the limit to INITIAL_LIMIT when the search term changes provides correct pagination behavior for new search results.


157-192: LGTM: Correct token deduplication and sorting.

The logic properly constructs a Set of owned token identifiers and filters them from allTokens, accounting for the different property names (token_address/chain_id vs address/chainId) between the two types. Sorting by icon presence improves visual consistency.


217-233: LGTM: Consistent prop passing across responsive variants.

Both desktop and mobile code paths receive the same simplified data structure, maintaining consistency and reducing complexity.

Also applies to: 241-257

@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 4, 2025

Merge activity

<!--

## 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 focuses on enhancing the `SelectToken` component by simplifying token limit management, improving UI consistency, and refactoring token display logic. It also removes unnecessary tabs and optimizes the selection process for better user experience.

### Detailed summary
- Replaced constants `ALL_TOKENS_LIMIT` and `OWNED_TOKENS_LIMIT` with `INITIAL_LIMIT`.
- Unified token limit state management into a single `limit` state.
- Refactored token fetching and display logic to streamline data handling.
- Removed unnecessary tab UI for better clarity.
- Simplified the structure of token data handling in `SelectTokenUI`.
- Updated the rendering logic for owned and other tokens to improve performance and readability.

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

* **UI Improvements**
  * Redesigned token selection UI in SwapWidget: removed tab navigation and consolidated token lists into dedicated "Your Tokens" and "Other Tokens" sections for a clearer, more intuitive experience.

* **Bug Fixes**
  * Enhanced search functionality to properly reset token filtering, improving responsiveness.

<sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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

♻️ Duplicate comments (2)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx (2)

64-69: showMore ignores owned-tokens pagination; extra owned tokens may be unreachable

showMore is only enabled when tokensQuery.data?.length === limit, but ownedTokensQuery is also paginated by the same limit. If ownedTokensQuery.data?.tokens?.length === limit while tokensQuery.data is shorter, the “Load More” button will never appear, and users can’t access additional owned tokens beyond the first page.

Consider updating the condition to account for both queries:

-      showMore={
-        tokensQuery.data?.length === limit
-          ? () => {
-              setLimit(limit + INITIAL_LIMIT);
-            }
-          : undefined
-      }
+      showMore={
+        (tokensQuery.data?.length === limit ||
+          ownedTokensQuery.data?.tokens?.length === limit)
+          ? () => {
+              setLimit(limit + INITIAL_LIMIT);
+            }
+          : undefined
+      }

Also applies to: 82-99, 112-112, 117-119, 126-132


528-548: “Other Tokens” header condition should depend on otherTokens presence, not ownedTokens

The “Your Tokens” section correctly gates on props.ownedTokens.length > 0, but the “Other Tokens” header currently uses props.ownedTokens.length > 0 as well. This causes two UX issues:

  • If the user has no owned tokens but otherTokens.length > 0, the “Other Tokens” header never shows, even though that’s what’s being listed.
  • If the user has owned tokens but no other tokens, the “Other Tokens” header appears with no items beneath it.

You can align the header with the list it labels:

-            {!props.isFetching && props.ownedTokens.length > 0 && (
+            {!props.isFetching && props.otherTokens.length > 0 && (
               <Container

This way, “Other Tokens” appears whenever (and only when) there are otherTokens to render, regardless of how many owned tokens exist.

Also applies to: 550-565, 566-589, 591-605

🧹 Nitpick comments (1)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx (1)

157-168: Avoid mutating props/derived arrays when sorting; use copies instead

props.ownedTokens.sort(...) and otherTokens.sort(...) both mutate their input arrays. Mutating props is an anti-pattern and mutating memo inputs can lead to subtle bugs or confusing re-renders, even if it happens to work with the current data flow.

You can keep the logic but sort copies:

-  const sortedOwnedTokens = useMemo(() => {
-    return props.ownedTokens.sort((a, b) => {
+  const sortedOwnedTokens = useMemo(() => {
+    return [...props.ownedTokens].sort((a, b) => {
       if (a.icon_uri && !b.icon_uri) {
         return -1;
       }
       if (!a.icon_uri && b.icon_uri) {
         return 1;
       }
       return 0;
     });
   }, [props.ownedTokens]);

-  const sortedOtherTokens = useMemo(() => {
-    return otherTokens.sort((a, b) => {
+  const sortedOtherTokens = useMemo(() => {
+    return [...otherTokens].sort((a, b) => {
       if (a.iconUri && !b.iconUri) {
         return -1;
       }
       if (!a.iconUri && b.iconUri) {
         return 1;
       }
       return 0;
     });
   }, [otherTokens]);

Also applies to: 169-180, 182-192

📜 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 d9e3b24 and b0eccf3.

📒 Files selected for processing (2)
  • .changeset/rotten-loops-draw.md (1 hunks)
  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx (15 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each TypeScript 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 in TypeScript
Avoid any and unknown in TypeScript unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.) in TypeScript

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

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
packages/thirdweb/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/thirdweb/src/**/*.{ts,tsx}: Comment only ambiguous logic in SDK code; avoid restating TypeScript in prose
Load heavy dependencies inside async paths to keep initial bundle lean (e.g. const { jsPDF } = await import("jspdf");)

Lazy-load heavy dependencies inside async paths to keep the initial bundle lean (e.g., const { jsPDF } = await import('jspdf');)

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
**/*.{js,jsx,ts,tsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Biome governs formatting and linting; its rules live in biome.json. Run pnpm fix & pnpm lint before committing, ensure there are no linting errors

Files:

  • packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Lazy-import optional features; avoid top-level side-effects

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 (7)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts (2)
  • useTokenBalances (74-121)
  • TokenBalance (42-60)
packages/thirdweb/src/bridge/types/Chain.ts (1)
  • BridgeChain (42-42)
packages/thirdweb/src/react/web/ui/Bridge/swap-widget/types.ts (1)
  • TokenSelection (149-152)
apps/playground-web/src/app/x402/components/constants.ts (1)
  • token (4-9)
packages/thirdweb/src/react/web/ui/components/Spacer.tsx (1)
  • Spacer (6-15)
packages/thirdweb/src/react/web/ui/ConnectWallet/icons/WalletDotIcon.tsx (1)
  • WalletDotIcon (6-22)
packages/thirdweb/src/react/web/ui/components/text.tsx (1)
  • Text (18-34)
⏰ 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). (9)
  • GitHub Check: Vercel Agent Review
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
.changeset/rotten-loops-draw.md (1)

1-5: Changeset format and content are appropriate.

The changeset correctly identifies the package ("thirdweb") and assigns a "patch" bump, which is fitting for a UI refinement. The description accurately captures the primary user-facing change (removing tabs from token selection UI).

packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx (1)

445-448: Loading / empty-state handling in TokenSelectionScreen looks consistent

The combined isFetching flag, skeleton placeholder rendering, “Load More” button, and noTokensFound computation (!isFetching && ownedTokens.length === 0 && otherTokens.length === 0) are coherent and should produce the expected UX for loading and empty search states.

Also applies to: 522-527, 607-617, 619-632

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