Skip to content

Load only the active admin tab - #301

Merged
luchobonatti merged 6 commits into
mainfrom
feat/288-active-admin-tab
Oct 22, 2026
Merged

luchobonatti merged 6 commits into
mainfrom
feat/288-active-admin-tab

Conversation

@luchobonatti

Copy link
Copy Markdown
Member

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

  • Each tab renders inside a React Activity: a hidden tab keeps its state but makes no RPC calls
  • Opening a tab loads its data with the existing loading state
  • The polling on/off arguments the hooks no longer need are removed; sections keep active only to hide a background tab's transaction modal

Deviations

  • Polling while the browser tab is hidden already stopped (React Query default); covered by a test, no code change
  • A hidden tab's pending signature polling waits until the tab is shown again; sent transactions still finish

Acceptance criteria

  • A cold load reads only the active tab's data
  • Switching tabs loads that tab's data, with a loading state
  • Hidden tabs make no RPC calls
  • Polling stops while the browser tab is hidden

Test plan

Automated tests

  1. npm test: 1708 passed, also with app-lib/clients empty
  2. npm run lint, npm run format:check, npm run build -w app: clean

Manual verification

  1. Open /admin/configuration on testnet as governance
  2. The network tab shows only that tab's reads; switching to Governance loads it then
  3. Measured cold loads, main vs this branch: Emergency 53 → 30 calls, Configuration 46 → 20; Cycle and Governance stay at ~46–54, since they read most shared data themselves

Breaking changes

None

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
Copilot AI balanced review requested due to automatic review settings October 21, 2026 20:43
@luchobonatti luchobonatti self-assigned this Oct 21, 2026
@luchobonatti
luchobonatti requested a review from hpmaxi October 21, 2026 20:43
@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
strata-vault-kit-app Ready Ready Preview Oct 22, 2026 7:43pm UTC

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 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 SurfaceBody in <Activity mode={...}> so hidden tabs make no RPC calls but keep state.
  • Remove the now-unnecessary active/poll gating arguments from the use*State/pause/oracle hooks; refetchInterval is now unconditional and Activity handles pausing.
  • Keep the active prop on sections solely to suppress a background tab's TransactionModal; 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

@luchobonatti
luchobonatti merged commit a41b205 into main Oct 22, 2026
3 checks passed
@luchobonatti
luchobonatti deleted the feat/288-active-admin-tab branch October 22, 2026 20:35

This branch was successfully deployed

1 active deployment
Preview — 2d80c04a Deployed Oct 22, 2026 by vercel[bot]
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.

Load only the active admin tab

3 participants