perf(voting): stop fetching proposal lists that are not on screen - #442
Open
yhabib wants to merge 1 commit into
Open
perf(voting): stop fetching proposal lists that are not on screen#442yhabib wants to merge 1 commit into
yhabib wants to merge 1 commit into
Conversation
The voting page keeps its proposals list behind a "show proposals" toggle and renders one filter at a time, but it called `useGovernanceProposals` twice unconditionally. Both filters fetched on every visit, each as a query/update pair, so a default visit — list collapsed — spent four governance calls on a list nobody had asked to see. Measured on nns.icp.net, /voting issued 8 concurrent update calls that took 4.2-4.9s each; the same reads as plain queries came back in 26-379ms. Update-call latency degrades sharply with concurrency (three concurrent were ~1.4s each), so dropping calls helps the ones that remain more than the count alone suggests. Both hooks now take an `enabled` gate keyed on the toggle and the active filter, and the route loader mirrors it — a loader that warmed a list the component never asks for would just put the calls straight back. Tests cover both halves of that agreement. Nothing loses certification here; the calls that remain are unchanged.
|
✅ No security or compliance issues detected. Reviewed everything up to 37ba527. Security Overview
Detected Code Changes
|
📊 Build Bundle StatsThe latest build generated the following assets: |
artkorotkikh-dfinity
approved these changes
Aug 7, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces unnecessary governance traffic on the voting page by ensuring proposal lists are only fetched/prefetched when the proposals section is actually visible and only for the active filter, aligning loader prefetch behavior with the component’s query enabled gates.
Changes:
- Added an
enabledoption touseGovernanceProposalsso callers can prevent proposal fetching entirely. - Updated the voting route + component to only fetch proposals when
showProposalsis on and only for the currently selected filter. - Updated voting route loader prefetching to mirror the UI gating, and added tests to enforce that agreement.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/governance-app-frontend/src/routes/_auth/voting/index.tsx |
Adds proposalsToPrefetch, includes showProposals in loader deps, and gates proposal queries so only visible data is fetched. |
src/governance-app-frontend/src/common/queries/routeLoaders.ts |
Adds PrefetchedProposals and updates prefetchVotingRoute to optionally skip prefetching proposals entirely or prefetch only one filter. |
src/governance-app-frontend/src/common/queries/routeLoaders.test.tsx |
Adds tests asserting proposal prefetching is skipped when collapsed and that exactly one filter is warmed when expanded. |
src/governance-app-frontend/src/common/hooks/governance/useGovernanceProposals.ts |
Extends the hook API with an enabled option and wires it into the underlying query options. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The voting page keeps its proposals list behind a "show proposals" toggle and only ever renders one filter, but it called
useGovernanceProposalstwice unconditionally. Both filters fetched on every visit, each as a query/update pair, so a default visit with the list collapsed spent four governance calls on a list nobody had asked to see.This is the first piece of finding #3 from the perf audit. On nns.icp.net,
/votingfired 8 concurrent certified update calls taking 4.2-4.9s each, while the same reads as plain queries came back in 26-379ms. Update latency gets worse fast with concurrency (three concurrent were ~1.4s each), so removing calls helps the ones left more than the count suggests.Nothing loses certification here. The calls that remain are unchanged.
Changes
enabledoption touseGovernanceProposals.showProposalstoggle and the active filter, so only the list actually on screen is fetched.Prev. #441