Skip to content

perf: memoize VaultTransactions filtering, windowing, and totals#523

Open
DevALVIN-24 wants to merge 1 commit into
Disciplr-Org:mainfrom
DevALVIN-24:perf/vault-transactions-memo
Open

perf: memoize VaultTransactions filtering, windowing, and totals#523
DevALVIN-24 wants to merge 1 commit into
Disciplr-Org:mainfrom
DevALVIN-24:perf/vault-transactions-memo

Conversation

@DevALVIN-24

Copy link
Copy Markdown
Contributor

This pr closes #505

Description:
This PR addresses the performance issue in src/pages/VaultTransactions.tsx where derived state—specifically the filtered status arrays (pending, failed, rest), their respective window slices, and transaction totals—were recomputed on every render. This caused intensive array methods to run even when interacting with unrelated local state (like copying hashes, or opening the detail modal).

Changes Included:

  1. Memoization (src/pages/VaultTransactions.tsx):
    • Wrapped the filter operations for pending, failed, and rest arrays in useMemo so they only recalculate when the actively visible filtered list changes.
    • Wrapped the windowing slice calculations (pendingWindow, failedWindow, restWindow) in useMemo so they only recalculate when their respective status list or anchorIndex changes.
  2. Testing Updates (src/pages/__tests__/VaultTransactions.test.tsx):
    • Added an integration test using vi.spyOn against the windowRange and computeTxTotals modules to verify that derivations do NOT re-run during unrelated state changes (like opening the transaction detail modal) but DO re-run when filters are actively changed.
    • Fixed a query ambiguity in the tests where our added Tooltip content inadvertently appeared multiple times, and resolved a window.matchMedia rendering crash in the test suite setup.
  3. Documentation Update (docs/PERFORMANCE.md):
    • Added a new Component Rendering Optimization section documenting the strategy implemented in the VaultTransactions component.

Verification:

  • Verified that all lines, including our modifications, are covered by passing Vitest unit tests meeting the >95% threshold requirement.
  • Visually, the data output and total derivations remain perfectly untouched.

The push to your remote repository was successful! Let me know if you need any additional changes to this implementation or if there is anything else I can help you with.

@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@DevALVIN-24 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@DevALVIN-24

Copy link
Copy Markdown
Contributor Author

okay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memoize the VaultTransactions filtered rows and totals to avoid recomputation on render

1 participant