fix(usage): only auto-poll Copilot/ChatGPT quota for current provider

CopilotQuotaFooter and CodexOauthQuotaFooter called their hooks with a
hardcoded `enabled: true` plus an unconditional 5-minute refetch and
refetchOnWindowFocus, so non-current reverse-proxy cards kept polling
in violation of the project's "only the active provider auto-queries
on cooldown" rule. With multiple Copilot or ChatGPT accounts bound to
different cards, every card kept hitting its own usage endpoint.

Adopt the same pattern as useUsageQuery: keep `enabled` independent of
isCurrent so first-fetch and manual refresh still work, but gate
refetchInterval / refetchIntervalInBackground / refetchOnWindowFocus on
a new `autoQuery` option, and thread `isCurrent` from ProviderCard
through the footers into the hooks.
This commit is contained in:
Jason
2026-04-08 22:37:16 +08:00
parent 62fc1d9151
commit df5cb6d771
5 changed files with 43 additions and 10 deletions
+10 -2
View File
@@ -357,9 +357,17 @@ export function ProviderCard({
<div className="ml-auto">
<div className="flex items-center gap-1">
{isCopilot ? (
<CopilotQuotaFooter meta={provider.meta} inline={true} />
<CopilotQuotaFooter
meta={provider.meta}
inline={true}
isCurrent={isCurrent}
/>
) : isCodexOauth ? (
<CodexOauthQuotaFooter meta={provider.meta} inline={true} />
<CodexOauthQuotaFooter
meta={provider.meta}
inline={true}
isCurrent={isCurrent}
/>
) : isOfficial ? (
<SubscriptionQuotaFooter appId={appId} inline={true} />
) : hasMultiplePlans ? (