Skip to content

Async CSV export#3330

Merged
tom2drum merged 17 commits intomainfrom
tom2drum/issue-3319
Apr 7, 2026
Merged

Async CSV export#3330
tom2drum merged 17 commits intomainfrom
tom2drum/issue-3319

Conversation

@tom2drum
Copy link
Copy Markdown
Collaborator

@tom2drum tom2drum commented Mar 31, 2026

Description and Related Issue(s)

Resolves #3319

This PR adds frontend support for async CSV export when the API reports async_enabled: true (non-multichain). Exports are started from a dialog instead of the old standalone CSV export page; the app tracks pending jobs, polls status, and surfaces completed downloads (including a downloads list with status indicators). Multichain keeps synchronous export only (async is disabled when multichain is on). CSV endpoints can return HTTP 429 with a "too many pending requests" style message; that message is shown to the user without CAPTCHA or automatic retry.

Proposed Changes

  • New CSV export feature module: dialog flow, async/sync download helpers, local storage/context for export jobs, download file naming, and downloads UI with polling and status (pending/completed/failed).
  • Removed the dedicated /csv-export page and related routes/components; export entry points on address, token, txs, advanced filter, etc. now open the dialog.
  • Top bar integration for export/downloads where applicable; minor API/types cleanup for removed CSV-export-only config.
  • UI toolkit: status recipe/component and button recipe tweaks for the new flows; Playwright snapshots and tests updated.

Breaking or Incompatible Changes

  • The standalone CSV export page URL is removed; users who bookmarked it need to use export from the relevant list pages/dialog instead.

Additional Information

  • Issue labels on Async CSV export #3319 are empty, so there are no labels to copy from the issue.
  • package.json and docs/ENVS.md are unchanged vs main — no dependencies or ENVs PR labels from this diff.

Checklist for PR author

  • I have tested these changes locally.
  • I added tests to cover any new functionality, following this guide
  • Whenever I fix a bug, I include a regression test to ensure that the bug does not reappear silently.
  • If I have added a feature or functionality that is not privacy-compliant (e.g., tracking, analytics, third-party services), I have disabled it for private mode.
  • If I have added, changed, renamed, or removed an environment variable
    • I updated the list of environment variables in the documentation
    • I made the necessary changes to the validator script according to the guide
    • I added "ENVs" label to this pull request

Note

Medium Risk
Adds new async CSV export flow with polling, localStorage persistence, and download-link generation, plus removes the old /csv-export pages; these changes touch user-facing data export behavior and routing but not auth or payments.

Overview
Introduces a new client/features/csv-export module that replaces the standalone CSV export pages with an in-place export dialog (period picker + reCAPTCHA) and unified export button used across address, token holders, tx lists, and advanced filter.

When general:config_csv_export reports async_enabled (and multichain is off), exports are now started asynchronously: the UI stores a request_id in localStorage, polls general:csv_exports_item for completion/expiry, and surfaces results via a TopBar downloads popover with status indicators and one-click file download; otherwise it falls back to the existing synchronous blob download.

Removes /csv-export and /chain/[chain_slug]/csv-export routes/SSR guards and cleans up related metadata/sitemap entries, updates API typings/resources for the new status endpoint, and adds a Status toolkit component/recipe plus minor theme/button tweaks to support the new UI states.

Written by Cursor Bugbot for commit 4fc87b8. This will update automatically on new commits. Configure here.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 31, 2026

Important

Review skipped

Auto reviews are disabled on this repository. To trigger a review, include @coderabbitai review in the PR description. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 52710bf5-c7d3-4210-b4d2-f33a20ce2a70

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@tom2drum
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

Bugbot Autofix prepared fixes for all 3 issues found in the latest run.

  • ✅ Fixed: Dialog cancel/confirm logic is inverted
    • I swapped the close-confirmation branch so declining keeps the dialog/request unchanged while confirming now calls onCancel() before closing.
  • ✅ Fixed: Context value recomputes every render due to unstable queries
    • I switched useQueries to use a memoized queries array plus combine and now memoize context value from the combined result to avoid per-render reference churn.
  • ✅ Fixed: eslint-disable comment lacks required explanation
    • I kept the react-hooks/exhaustive-deps suppression and added an inline reason explaining why queryClient is intentionally omitted.

Create PR

Or push these changes by commenting:

@cursor push 3aed5894e2
Preview (3aed5894e2)
diff --git a/client/features/csv-export/components/dialog/CsvExportDialog.tsx b/client/features/csv-export/components/dialog/CsvExportDialog.tsx
--- a/client/features/csv-export/components/dialog/CsvExportDialog.tsx
+++ b/client/features/csv-export/components/dialog/CsvExportDialog.tsx
@@ -34,9 +34,9 @@
     if (formState.isSubmitting && !open) {
       const confirm = window.confirm('Are you sure you want to close the dialog? The export will be cancelled.');
       if (!confirm) {
-        onCancel();
         return;
       }
+      onCancel();
     }
     onOpenChange({ open });
   }, [ onOpenChange, formState.isSubmitting, onCancel ]);

diff --git a/client/features/csv-export/components/downloads/CsvExportDownloadsItem.tsx b/client/features/csv-export/components/downloads/CsvExportDownloadsItem.tsx
--- a/client/features/csv-export/components/downloads/CsvExportDownloadsItem.tsx
+++ b/client/features/csv-export/components/downloads/CsvExportDownloadsItem.tsx
@@ -56,7 +56,7 @@
       window.clearInterval(intervalId);
     };
 
-  // eslint-disable-next-line react-hooks/exhaustive-deps
+  // eslint-disable-next-line react-hooks/exhaustive-deps -- queryClient is intentionally omitted to avoid restarting interval on client identity changes
   }, [ data.expires_at, data.status ]);
 
   const markItemAsViewed = React.useCallback(() => {

diff --git a/client/features/csv-export/utils/context.tsx b/client/features/csv-export/utils/context.tsx
--- a/client/features/csv-export/utils/context.tsx
+++ b/client/features/csv-export/utils/context.tsx
@@ -34,8 +34,8 @@
 
   const [ items, setItems ] = React.useState<Array<StorageItem>>(isBrowser() ? storage.getItems() : []);
 
-  const queries = useQueries<Array<UseQueryOptions<StorageItem | undefined, Error, StorageItem | undefined>>>({
-    queries: items.map((item) => ({
+  const queryOptions = React.useMemo(() => (
+    items.map((item) => ({
       queryKey: [ 'general:csv_exports_item', item.request_id ],
       queryFn: async() => {
         try {
@@ -64,7 +64,6 @@
             storage.updateItems([ newItem ]);
             return newItem;
           }
-
         } catch (error) {
           const statusCode = getErrorObjStatusCode(error);
           if (statusCode === 404) {
@@ -85,7 +84,14 @@
         return status === 'pending' ? 10 * SECOND : false;
       },
       refetchOnMount: false,
-    })),
+    })) satisfies Array<UseQueryOptions<StorageItem | undefined, Error, StorageItem | undefined>>
+  ), [ items, apiFetch ]);
+
+  const queriedItems = useQueries({
+    queries: queryOptions,
+    combine: React.useCallback((results) => {
+      return results.map(({ data }) => data).filter((item): item is StorageItem => Boolean(item));
+    }, [ ]),
   });
 
   const addItems = React.useCallback((items: Array<StorageItem>) => {
@@ -94,14 +100,13 @@
   }, [ ]);
 
   const value = React.useMemo(() => {
-    const items = queries.map(({ data }) => data).filter(Boolean);
     return {
       dialogOpen: dialog.open,
       onDialogOpenChange: dialog.onOpenChange,
-      items,
+      items: queriedItems,
       addItems,
     };
-  }, [ queries, dialog.open, dialog.onOpenChange, addItems ]);
+  }, [ queriedItems, dialog.open, dialog.onOpenChange, addItems ]);
 
   return (
     <CsvExportContext.Provider value={ value }>

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Comment thread client/features/csv-export/components/dialog/CsvExportDialog.tsx
Comment thread client/features/csv-export/utils/context.tsx Outdated
Comment thread client/features/csv-export/components/downloads/CsvExportDownloadsItem.tsx Outdated
@tom2drum tom2drum changed the title Async CSV export (dialog + downloads) Async CSV export Mar 31, 2026
@tom2drum
Copy link
Copy Markdown
Collaborator Author

@cursor push 3aed589

@tom2drum tom2drum linked an issue Apr 7, 2026 that may be closed by this pull request
@tom2drum tom2drum added the feature New substantial feature label Apr 7, 2026
@tom2drum tom2drum merged commit a640f69 into main Apr 7, 2026
12 checks passed
@tom2drum tom2drum deleted the tom2drum/issue-3319 branch April 7, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New substantial feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Async CSV export UI/UX: Export CSV feature

2 participants