Skip to content

Conversation

@MananTank
Copy link
Member

@MananTank MananTank commented Jun 16, 2025


PR-Codex overview

This PR introduces pagination functionality to the useEngine hook and the BackendWalletsSection component, allowing users to navigate through backend wallets in a paginated manner.

Detailed summary

  • Added optional limit and page parameters to the useEngine hook.
  • Updated the fetch URL in useEngine to include dynamic limit and page values.
  • Introduced pagination controls in BackendWalletsSection.
  • Added state management for page and pageSize.
  • Included logic to disable pagination buttons based on wallet data length.

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

Summary by CodeRabbit

  • New Features
    • Added pagination controls to the backend wallets list, allowing users to navigate through multiple pages of wallets.
  • Improvements
    • Users can now view backend wallets in pages of 10, with "Previous" and "Next" buttons for easier navigation. Pagination controls are only visible when applicable.

@linear
Copy link

linear bot commented Jun 16, 2025

@changeset-bot
Copy link

changeset-bot bot commented Jun 16, 2025

⚠️ No Changeset found

Latest commit: 3f74760

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@vercel
Copy link

vercel bot commented Jun 16, 2025

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

Name Status Preview Comments Updated (UTC)
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 16, 2025 9:07pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Skipped (Inspect) Jun 16, 2025 9:07pm
login ⬜️ Skipped (Inspect) Jun 16, 2025 9:07pm
thirdweb_playground ⬜️ Skipped (Inspect) Jun 16, 2025 9:07pm
wallet-ui ⬜️ Skipped (Inspect) Jun 16, 2025 9:07pm

@vercel vercel bot temporarily deployed to Preview – wallet-ui June 16, 2025 20:27 Inactive
@vercel vercel bot temporarily deployed to Preview – login June 16, 2025 20:27 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground June 16, 2025 20:27 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 June 16, 2025 20:27 Inactive
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 16, 2025

Walkthrough

Pagination was added to the engine v2 backend wallets list on the Overview page. The useEngineBackendWallets hook now supports limit and page parameters, and the UI in BackendWalletsSection implements pagination controls with state management for page navigation.

Changes

File(s) Change Summary
apps/dashboard/src/@3rdweb-sdk/react/hooks/useEngine.ts Updated useEngineBackendWallets to accept optional limit and page params; fetch URL and query key updated.
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/.../overview/components/engine-overview.tsx Enhanced BackendWalletsSection to support pagination, added page state, and pagination controls in UI.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BackendWalletsSection
    participant useEngineBackendWallets
    participant Backend API

    User->>BackendWalletsSection: Loads Overview page
    BackendWalletsSection->>useEngineBackendWallets: Fetch wallets (limit=10, page=1)
    useEngineBackendWallets->>Backend API: GET /wallets?limit=10&page=1
    Backend API-->>useEngineBackendWallets: Returns wallets data
    useEngineBackendWallets-->>BackendWalletsSection: Returns wallets data
    BackendWalletsSection->>User: Displays wallets and pagination controls

    User->>BackendWalletsSection: Clicks "Next"
    BackendWalletsSection->>useEngineBackendWallets: Fetch wallets (limit=10, page=2)
    useEngineBackendWallets->>Backend API: GET /wallets?limit=10&page=2
    Backend API-->>useEngineBackendWallets: Returns next page of wallets
    useEngineBackendWallets-->>BackendWalletsSection: Returns wallets data
    BackendWalletsSection->>User: Updates wallets list
Loading

Assessment against linked issues

Objective Addressed Explanation
Add pagination to engine v2 wallet list on Overview page (TOOL-4819)

Suggested reviewers

  • jnsdls

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 the Dashboard Involves changes to the Dashboard. label Jun 16, 2025
@MananTank MananTank marked this pull request as ready for review June 16, 2025 20:27
@MananTank MananTank requested review from a team as code owners June 16, 2025 20:27
Copy link
Member Author

MananTank commented Jun 16, 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.

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

@MananTank MananTank force-pushed the 06-17-_tool-4819_dashboard_load_all_engine_backend_wallets_add_pagination_in_table branch from 0532382 to 123fb06 Compare June 16, 2025 20:28
@vercel vercel bot temporarily deployed to Preview – wallet-ui June 16, 2025 20:28 Inactive
@vercel vercel bot temporarily deployed to Preview – login June 16, 2025 20:28 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground June 16, 2025 20:28 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 June 16, 2025 20:28 Inactive
@codecov
Copy link

codecov bot commented Jun 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.58%. Comparing base (9253c54) to head (3f74760).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7347   +/-   ##
=======================================
  Coverage   55.58%   55.58%           
=======================================
  Files         909      909           
  Lines       58683    58683           
  Branches     4163     4163           
=======================================
  Hits        32617    32617           
  Misses      25959    25959           
  Partials      107      107           
Flag Coverage Δ
packages 55.58% <ø> (ø)
🚀 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 Jun 16, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 62.44 KB (0%) 1.3 s (0%) 540 ms (+51.61% 🔺) 1.8 s
thirdweb (cjs) 350.62 KB (0%) 7.1 s (0%) 2.9 s (+3.72% 🔺) 9.9 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 163 ms (+844.76% 🔺) 277 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 53 ms (+478.81% 🔺) 63 ms
thirdweb/react (minimal + tree-shaking) 19.59 KB (0%) 392 ms (0%) 151 ms (+216.41% 🔺) 543 ms

@MananTank MananTank force-pushed the 06-17-_tool-4819_dashboard_load_all_engine_backend_wallets_add_pagination_in_table branch from 123fb06 to e47f864 Compare June 16, 2025 20:43
@vercel vercel bot temporarily deployed to Preview – wallet-ui June 16, 2025 20:43 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground June 16, 2025 20:43 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 June 16, 2025 20:43 Inactive
@vercel vercel bot temporarily deployed to Preview – login June 16, 2025 20:43 Inactive
@graphite-app graphite-app bot changed the base branch from 06-17-_tool-4821_improve_team_members_search to graphite-base/7347 June 16, 2025 20:47
@graphite-app
Copy link
Contributor

graphite-app bot commented Jun 16, 2025

Merge activity

@graphite-app graphite-app bot changed the base branch from graphite-base/7347 to main June 16, 2025 20:58
…n in table (#7347)

<!--

## 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 enhances the `useEngine` hook and the `BackendWalletsSection` component by adding pagination functionality for backend wallets retrieval, allowing users to navigate through pages of wallet data.

### Detailed summary
- Added optional `limit` and `page` parameters to the `useEngine` hook.
- Updated the fetch URL in the hook to accommodate pagination.
- Introduced pagination controls in `BackendWalletsSection` using `Button` components.
- Managed pagination state with `useState` for current page tracking.

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

<!-- end pr-codex -->
@graphite-app graphite-app bot force-pushed the 06-17-_tool-4819_dashboard_load_all_engine_backend_wallets_add_pagination_in_table branch from e47f864 to 3f74760 Compare June 16, 2025 20:59
@vercel vercel bot temporarily deployed to Preview – wallet-ui June 16, 2025 20:59 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground June 16, 2025 20:59 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 June 16, 2025 20:59 Inactive
@vercel vercel bot temporarily deployed to Preview – login June 16, 2025 20:59 Inactive
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 (5)
apps/dashboard/src/@3rdweb-sdk/react/hooks/useEngine.ts (2)

78-83: Preserve cache while paginating by re-using previous data

When paginating, the list flickers because the cache is cleared while the next page is loading.
Adding placeholderData: keepPreviousData (or the keepPreviousData helper) – exactly as you already did for useEngineTransactions – will keep the previous page rendered until the new one arrives.

   return useQuery({
     queryKey: [
       ...engineKeys.backendWallets(instanceUrl),
       authToken,
       params.limit,
       params.page,
     ],
+    placeholderData: keepPreviousData,

85-92: Build the URL with URL/URLSearchParams to avoid subtle encoding bugs

Manual string interpolation becomes fragile once more query params creep in (e.g. a future search term or address filter).
Using new URL() keeps things readable and automatically escapes values:

-      const res = await fetch(
-        `${instanceUrl}backend-wallet/get-all?limit=${params.limit ?? 1000}&page=${params.page ?? 1}`,
-        {
+      const url = new URL(`${instanceUrl}backend-wallet/get-all`);
+      url.searchParams.set("limit", String(params.limit ?? 1_000));
+      url.searchParams.set("page",  String(params.page  ?? 1));
+
+      const res = await fetch(url, {
         method: "GET",
         headers: getEngineRequestHeaders(authToken),
-        },
-      );
+      });
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/dedicated/(instance)/[engineId]/overview/components/engine-overview.tsx (3)

67-69: Reset the page index when dependencies change

If the component receives a new instance or authToken, the current page may be invalid (e.g. you were on page 5 of the previous engine, but the new one only has 1 page).
Add an effect to reset page back to 1 when instance.url or authToken changes:

useEffect(() => {
  setPage(1);
}, [instance.url, authToken]);

82-85: Keep pagination visible while loading to avoid layout shift

showPagination becomes false during the loading state because backendWallets.data is undefined, hiding the controls and causing a jank when they re-appear.
Consider basing the flag on backendWallets.isFetched instead, or always rendering the controls and just disabling the buttons.

-const disableNextButton   = (backendWallets.data?.length || 0) < pageSize;
-const disablePreviousButton = page === 1;
-const showPagination = !disableNextButton || !disablePreviousButton;
+const disableNextButton     = (backendWallets.data?.length ?? pageSize) < pageSize;
+const disablePreviousButton = page === 1;
+const showPagination        = backendWallets.isFetched;

168-176: Use functional setState to avoid stale closures

setPage(page - 1) / setPage(page + 1) capture the value of page at render time.
Switching pages quickly can enqueue multiple updates and drop clicks.
Use the functional form to always work with the latest value:

-onClick={() => setPage(page - 1)}
+onClick={() => setPage((p) => p - 1)}-onClick={() => setPage(page + 1)}
+onClick={() => setPage((p) => p + 1)}

Also applies to: 178-184

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9253c54 and 3f74760.

📒 Files selected for processing (2)
  • apps/dashboard/src/@3rdweb-sdk/react/hooks/useEngine.ts (1 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/dedicated/(instance)/[engineId]/overview/components/engine-overview.tsx (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/dedicated/(instance)/[engineId]/overview/components/engine-overview.tsx (1)
apps/dashboard/src/@3rdweb-sdk/react/hooks/useEngine.ts (2)
  • useEngineBackendWallets (70-99)
  • useEngineWalletConfig (425-443)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Build Packages
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)

@graphite-app graphite-app bot merged commit 3f74760 into main Jun 16, 2025
24 checks passed
@graphite-app graphite-app bot deleted the 06-17-_tool-4819_dashboard_load_all_engine_backend_wallets_add_pagination_in_table branch June 16, 2025 21:08
@vercel vercel bot temporarily deployed to Production – docs-v2 June 16, 2025 21:08 Inactive
@vercel vercel bot temporarily deployed to Production – thirdweb_playground June 16, 2025 21:08 Inactive
@vercel vercel bot temporarily deployed to Production – login June 16, 2025 21:08 Inactive
@vercel vercel bot temporarily deployed to Production – wallet-ui June 16, 2025 21:08 Inactive
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants