Skip to content

[Dashboard] Refactor: Bridge UI Cleanup and Fixes #7165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2025

Conversation

gregfromstl
Copy link
Member

@gregfromstl gregfromstl commented May 27, 2025


PR-Codex overview

This PR introduces a Providers component for managing themes and notifications in the dashboard app, enhances error handling in the ConfirmationScreen and TransferConfirmationScreen, and updates the UniversalBridgeEmbed to use a new client setup.

Detailed summary

  • Added Providers component in Providers.client.tsx for theme and notification management.
  • Updated BridgeLayout to include the Providers component.
  • Enhanced error messages for insufficient funds in SwapConfirmationScreen and TransferConfirmationScreen.
  • Refactored UniversalBridgeEmbed to use bridgeAppThirdwebClient.
  • Introduced a function to create the bridgeAppThirdwebClient with environment-specific configurations in constants.ts.
  • Renamed RoutesPage to BridgePage in page.tsx and adjusted client handling.

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

Summary by CodeRabbit

  • New Features

    • Introduced a new layout and context providers for the Bridge section, including blockchain integration, dark theme support, and toast notifications.
    • Added a dedicated Bridge layout with improved styling and font integration.
  • Improvements

    • Enhanced error messages in swap and transfer confirmation screens to clearly indicate when there are insufficient native funds for gas.
    • Improved detection and messaging for user-rejected actions during transaction flows.
  • Updates

    • Simplified Bridge embed usage by removing the need to manually pass a client prop; the client is now managed internally.
    • Updated component and function names for clarity in the Bridge section.

…perience

- Added `constants.ts` to configure Thirdweb client for the bridge application.
- Created `BridgeLayout` component to structure the bridge page layout.
- Developed `BridgePage` to handle the main functionality of the Universal Bridge, including metadata and dynamic content.
- Introduced `Providers.client.tsx` to wrap the application with necessary context providers.
- Implemented `UniversalBridgeEmbed` component for embedding payment functionalities with theme support.

This commit establishes the foundational components for the Universal Bridge feature, improving the overall user interface and experience.
- Added specific error messages for insufficient native funds in both `SwapConfirmationScreen` and `TransferConfirmationScreen`.
- Improved user feedback by providing clear titles and messages when transactions cannot be approved or confirmed due to lack of funds for gas.
@gregfromstl gregfromstl requested review from a team as code owners May 27, 2025 01:52
Copy link

vercel bot commented May 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 1:54am
login ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 1:54am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 1:54am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 1:54am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 27, 2025 1:54am

Copy link
Contributor

graphite-app bot commented May 27, 2025

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.

Copy link
Contributor

coderabbitai bot commented May 27, 2025

Walkthrough

A new context provider component and a layout were introduced for the dashboard bridge app. The bridge embed component was refactored to use a shared client instance from new constants. The bridge page logic was updated to await search parameters and simplified to use the new client setup. Error handling for insufficient gas funds was enhanced in wallet swap and transfer confirmation screens.

Changes

File(s) Change Summary
apps/dashboard/src/app/bridge/components/client/Providers.client.tsx Added a new Providers component wrapping children with blockchain, theme, and toast providers.
apps/dashboard/src/app/bridge/layout.tsx Introduced BridgeLayout component applying global styles and wrapping content with Providers.
apps/dashboard/src/app/bridge/constants.ts Added export for bridgeAppThirdwebClient, a preconfigured Thirdweb client for the bridge app.
apps/dashboard/src/app/bridge/components/client/UniversalBridgeEmbed.tsx Refactored to use shared bridgeAppThirdwebClient; removed client prop; updated import paths.
apps/dashboard/src/app/bridge/page.tsx Renamed exported function, changed search param handling to async, removed custom client logic, updated CSS class.
packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.tsx Enhanced error handling to display specific messages for insufficient native funds during swap/approval.
packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx Improved error detection for insufficient gas funds and expanded user rejection cases in UI error messages.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BridgePage
    participant BridgeLayout
    participant Providers
    participant UniversalBridgeEmbed
    participant bridgeAppThirdwebClient

    User->>BridgePage: Access bridge page
    BridgePage->>BridgeLayout: Render layout with children
    BridgeLayout->>Providers: Wrap children with providers
    Providers->>UniversalBridgeEmbed: Render embed component
    UniversalBridgeEmbed->>bridgeAppThirdwebClient: Use shared client for PayEmbed
Loading

Suggested labels

Dashboard, packages

Suggested reviewers

  • joaquim-verges

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.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added Dashboard Involves changes to the Dashboard. packages SDK Involves changes to the thirdweb SDK labels May 27, 2025
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

🧹 Nitpick comments (2)
apps/dashboard/src/app/bridge/constants.ts (1)

20-22: Consider removing or conditional logging for the console.log.

The console.log statement will execute in all non-production environments. Consider using a more specific condition or removing it to avoid cluttering logs in staging/development.

-    console.log("Setting domains for bridge app", THIRDWEB_BRIDGE_URL);
+    // Optional: Use conditional logging or remove entirely
+    // console.log("Setting domains for bridge app", THIRDWEB_BRIDGE_URL);
apps/dashboard/src/app/bridge/page.tsx (1)

18-21: Good refactoring for Next.js async searchParams pattern.

The function rename to BridgePage improves clarity, and the async searchParams handling aligns with Next.js 15 patterns. However, consider adding error handling for the await operation.

Consider adding error handling for robustness:

export default async function BridgePage({
  searchParams,
}: { searchParams: Promise<Record<string, string | string[]>> }) {
-  const { chainId } = await searchParams;
+  const { chainId } = await searchParams.catch(() => ({}));
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec7bc2b and a4d1da1.

📒 Files selected for processing (7)
  • apps/dashboard/src/app/bridge/components/client/Providers.client.tsx (1 hunks)
  • apps/dashboard/src/app/bridge/components/client/UniversalBridgeEmbed.tsx (1 hunks)
  • apps/dashboard/src/app/bridge/constants.ts (1 hunks)
  • apps/dashboard/src/app/bridge/layout.tsx (1 hunks)
  • apps/dashboard/src/app/bridge/page.tsx (2 hunks)
  • packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.tsx (3 hunks)
  • packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
apps/dashboard/src/app/bridge/constants.ts (3)
apps/dashboard/src/constants/urls.ts (2)
  • THIRDWEB_BRIDGE_URL (27-28)
  • THIRDWEB_INSIGHT_API_DOMAIN (24-25)
packages/thirdweb/src/exports/thirdweb.ts (1)
  • createThirdwebClient (24-24)
apps/dashboard/src/@/constants/public-envs.ts (2)
  • NET_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID (1-2)
  • NEXT_PUBLIC_IPFS_GATEWAY_URL (13-15)
apps/dashboard/src/app/bridge/components/client/UniversalBridgeEmbed.tsx (1)
apps/dashboard/src/app/bridge/constants.ts (1)
  • bridgeAppThirdwebClient (46-46)
apps/dashboard/src/app/bridge/layout.tsx (1)
apps/dashboard/src/app/bridge/components/client/Providers.client.tsx (1)
  • Providers (6-20)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Lint Packages
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Unit Tests
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (11)
packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx (3)

129-135: Good enhancement for gas fund error detection.

The addition of specific error handling for insufficient gas funds during the approval step provides clearer user feedback compared to generic error messages.


148-152: Improved user rejection error detection.

Expanding the user rejection detection to include "user closed modal" and "user denied" covers more wallet implementations and user interaction patterns, which improves the robustness of error handling.


158-164: Consistent gas fund error handling for transfer step.

The error handling for insufficient gas funds during transfer/execute operations is consistent with the approval step, providing a cohesive user experience.

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.tsx (3)

81-87: Consistent gas fund error detection for approval.

The error handling enhancement matches the pattern established in TransferConfirmationScreen.tsx, ensuring consistent user experience across different wallet flows.


106-112: Consistent gas fund error detection for swap confirmation.

This maintains the same error handling pattern for the swap step, providing clear feedback when users lack sufficient native funds for gas.


350-350: Critical fix: Ensure error message is captured in state.

Adding setError((e as Error).message) is essential for the UI error handling logic to access and display specific error messages. This was a missing piece that could have prevented proper error feedback to users.

apps/dashboard/src/app/bridge/components/client/Providers.client.tsx (1)

6-20: LGTM! Clean provider setup with proper configuration.

The provider hierarchy is well-structured with appropriate configurations:

  • ThemeProvider correctly configured for bridge app's dark theme requirements
  • Toaster properly positioned for toast notifications
  • Clean component composition pattern

Note: The ThirdwebProvider has no explicit client prop, which appears intentional since the client is now centrally managed via the constants file.

apps/dashboard/src/app/bridge/constants.ts (1)

35-43: Excellent client configuration pattern.

The centralized client setup with explicit configuration is well-implemented:

  • Proper use of public client ID for frontend usage
  • Explicit secretKey: undefined for clarity
  • IPFS gateway configuration with environment variable fallback
  • Clean separation of concerns with the helper function
apps/dashboard/src/app/bridge/components/client/UniversalBridgeEmbed.tsx (1)

7-15: Great refactor! Simplified component interface with centralized client usage.

The removal of the client prop and adoption of the shared bridgeAppThirdwebClient improves:

  • Component reusability (no need to pass client everywhere)
  • Maintainability (centralized client configuration)
  • API surface reduction (cleaner component interface)

The relative import paths are also an improvement for maintainability.

apps/dashboard/src/app/bridge/layout.tsx (1)

12-29: Well-structured layout component following Next.js best practices.

The layout implementation is excellent:

  • Proper Inter font configuration with variable and display swap
  • Appropriate HTML structure with lang attribute
  • suppressHydrationWarning correctly used for theme-dependent rendering
  • Clean utility class composition with cn
  • Proper provider wrapping to establish context for all bridge components

This creates a solid foundation for the bridge app's UI structure.

apps/dashboard/src/app/bridge/page.tsx (1)

35-35: Minor UI adjustment approved.

The bottom spacing reduction from bottom-24 to bottom-8 appears to be a visual refinement for better layout spacing.

Copy link

codecov bot commented May 27, 2025

Codecov Report

Attention: Patch coverage is 0% with 34 lines in your changes missing coverage. Please review.

Project coverage is 55.66%. Comparing base (ec7bc2b) to head (a4d1da1).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...et/screens/Buy/swap/TransferConfirmationScreen.tsx 0.00% 19 Missing ⚠️
...nectWallet/screens/Buy/swap/ConfirmationScreen.tsx 0.00% 15 Missing ⚠️

❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7165      +/-   ##
==========================================
- Coverage   55.70%   55.66%   -0.05%     
==========================================
  Files         904      904              
  Lines       58358    58391      +33     
  Branches     4114     4111       -3     
==========================================
- Hits        32510    32505       -5     
- Misses      25743    25781      +38     
  Partials      105      105              
Flag Coverage Δ
packages 55.66% <0.00%> (-0.05%) ⬇️
Files with missing lines Coverage Δ
...nectWallet/screens/Buy/swap/ConfirmationScreen.tsx 7.21% <0.00%> (-0.38%) ⬇️
...et/screens/Buy/swap/TransferConfirmationScreen.tsx 6.32% <0.00%> (-0.25%) ⬇️

... and 1 file 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

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 61.75 KB (0%) 1.3 s (0%) 226 ms (+201.86% 🔺) 1.5 s
thirdweb (cjs) 344.4 KB (0%) 6.9 s (0%) 649 ms (+5.14% 🔺) 7.6 s
thirdweb (minimal + tree-shaking) 5.69 KB (0%) 114 ms (0%) 86 ms (+1794.7% 🔺) 200 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 28 ms (+1694.83% 🔺) 39 ms
thirdweb/react (minimal + tree-shaking) 19.54 KB (0%) 391 ms (0%) 93 ms (+596.18% 🔺) 484 ms

@gregfromstl gregfromstl merged commit 80207ae into main May 27, 2025
24 of 25 checks passed
@gregfromstl gregfromstl deleted the greg/improved-bridge-ui branch May 27, 2025 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dashboard Involves changes to the Dashboard. packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant