Repository navigation
Load only the active admin tab - #301
Conversation
Each held surface renders inside a React Activity, so a hidden tab keeps its state but makes no RPC calls. Opening a tab loads its data with the existing loading state, and polling already stops while the browser tab is hidden. Refs #288
Hidden tabs no longer subscribe, so the active and poll arguments that only turned polling on and off are gone. The sections keep active to hide a background tab's transaction modal. Closes #288
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
🔵 Needs a closer look
Correctness hinges on a subtle new React 19.2 <Activity> + React Query effect-teardown interaction that governs the whole admin console's data lifecycle and warrants human verification in the real runtime beyond jsdom tests.
No open issues 🎉
What changed in this PR
This PR fixes an inefficiency in the admin console (#288) where every tab the connected wallet holds mounted and polled its data simultaneously, so opening one tab triggered reads for all of them. It leverages React 19.2's stable <Activity> component to keep hidden tabs mounted (preserving their state) while tearing down their effects, which stops their React Query hooks from subscribing — so hidden tabs make no RPC calls and resume loading only when shown.
Changes:
- Wrap each admin tab's
SurfaceBodyin<Activity mode={...}>so hidden tabs make no RPC calls but keep state. - Remove the now-unnecessary
active/pollgating arguments from theuse*State/pause/oracle hooks;refetchIntervalis now unconditional and Activity handles pausing. - Keep the
activeprop on sections solely to suppress a background tab'sTransactionModal; add integration tests verifying cold-load, tab-switch loading, and hidden-tab polling behavior.
| File | Description |
|---|---|
| app/src/pages/AdminPanel.tsx | Imports Activity and wraps each SurfaceBody in <Activity mode> to pause hidden tabs' effects. |
| app/src/pages/AdminPanel.test.tsx | Adds QueryClient-backed SurfaceRead probe and tests for cold-load, open-tab loading, and hidden-tab polling halt. |
| app/src/hooks/useVaultPaused.test.ts | New test asserting polling stops while the browser tab is hidden and resumes when shown. |
| app/src/hooks/useTokenPaused.ts | Drops the poll option; now always sets refetchInterval. |
| app/src/hooks/useOracleState.ts | Drops the poll option; now always sets refetchInterval. |
| app/src/hooks/useGovernanceState.ts | Removes active threading through useUpgrades/useGovernanceState. |
| app/src/hooks/useCycleState.ts | useCycleReads/useCycleState drop the active argument. |
| app/src/hooks/useCycleState.test.ts | Removes the obsolete "stops refetching while inactive" test. |
| app/src/hooks/useConfigurationState.ts | Drops the active argument; unconditional refetchInterval. |
| app/src/hooks/useConfigurationState.test.ts | Removes the obsolete active-gating test. |
| app/src/hooks/useComplianceState.ts | Drops the active argument; unconditional refetchInterval. |
| app/src/components/admin/*Section.tsx | Stop passing active/poll into data hooks; keep active only for modal visibility. |
| app/src/components/admin/*Section.test.tsx | Update/remove assertions tied to the removed active-gating. |
Review effort: Balanced
Summary
Closes #288
The admin console mounted and loaded every tab the wallet holds at once, so opening one tab read the data of all of them.
Changes
Activity: a hidden tab keeps its state but makes no RPC callsactiveonly to hide a background tab's transaction modalDeviations
Acceptance criteria
Test plan
Automated tests
npm test: 1708 passed, also withapp-lib/clientsemptynpm run lint,npm run format:check,npm run build -w app: cleanManual verification
/admin/configurationon testnet as governanceBreaking changes
None