[front] fix: stop the new usage page from double-fetching the credit pool - #32258
Open
avervaet wants to merge 5 commits into
Open
[front] fix: stop the new usage page from double-fetching the credit pool#32258avervaet wants to merge 5 commits into
avervaet wants to merge 5 commits into
Conversation
avervaet
force-pushed
the
avervaet/usage-page-dedupe-pool-fetch
branch
from
September 10, 2026 14:58
6661b21 to
a5fbba2
Compare
…pool CreditPoolCards (shown on the new usage page behind enable_new_usage_page) fetches the current-cycle and cycle-history credit-pool endpoints itself. UsagePage was separately fetching the same current-cycle figures again through the awu-pool-summary endpoint, purely for the legacy pool section and the top-up dialog. Every one of those extra requests still resolves a full session/auth context against Postgres before the handler runs, so each redundant fetch adds real DB load on every pageview of the new usage page. Read the current-cycle data through the same useAwuPoolCurrentCycle hook CreditPoolCards already calls instead: SWR dedupes identical keys, so the two call sites now share a single request rather than issuing two.
…ool-summary UsagePage no longer mounts a live (non-disabled) useAwuPoolSummary; every remaining call site passes disabled: true purely to grab a mutate handle. The refresh-interval/counter machinery that re-polled awu-pool-summary 5 times after a purchase has no subscriber left to poll, so it's dead code.
avervaet
force-pushed
the
avervaet/usage-page-dedupe-pool-fetch
branch
from
September 10, 2026 15:03
a5fbba2 to
3d56b63
Compare
Contributor
Author
|
r? @tdraier |
The outer guard previously hid the whole section during loading, making the nested spinner unreachable.
PokeCreditPoolCard fetched the heavier awu-pool-summary endpoint (current-cycle + full cycle history) just to read fields already returned by the lighter awu-pool-current-cycle endpoint the pool cards elsewhere already use. Same pattern fixed for the customer- facing usage page in #32258.
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.
Description
CreditPoolCards) fetch the pool current-cycle and cycle-history endpoints themselves.UsagePagewas separately fetching the same current-cycle figures again through theawu-pool-summaryendpoint, only to feed the legacy pool section and the top-up dialog.useAwuPoolCurrentCyclehookCreditPoolCardsalready calls, instead of the separateawu-pool-summarycall. SWR dedupes identical keys, so the two call sites now share a single request instead of issuing two.UsagePageno longer mounting a liveuseAwuPoolSummary, its post-purchase refresh-polling machinery (awuPostPurchaseRefreshState/resetAwuPostPurchaseRefreshCountand the hook'srefreshInterval) had no subscriber left to poll — removed it, along with the calls to it fromuseAwuPurchaseanduseRedeemPoolTopupCoupon.awu-pool-current-cyclewas loading, making its own nested spinner unreachable. It now shows during loading too.PokeCreditPoolCard(poke's workspace usage tab) fetched the same heavierawu-pool-summaryendpoint just to read fields already returned byawu-pool-current-cycle. Swapped it tousePokeAwuPoolCurrentCycleand removed the now-unusedusePokeAwuPoolSummaryhook.Tests
npx tsgo --noEmitand Biome pass on all changed files.Risk
Low-to-moderate. The data-source swap itself is equivalent (same backend computation, same defaulting), but two assumptions aren't independently verified:
awu-pool-summaryassumed the balance is already consistent by the time a purchase reports "succeeded." That polling existed for a reason (likely billing eventual-consistency); removing it trades a retry safety net for a single refetch onawu-pool-current-cycle, which has no equivalent retry.Recommend a quick manual check on staging (purchase credits, watch the legacy pool section and top-up dialog update; check poke's workspace usage tab) before merging.
Deploy Plan
Deploy front