@@ -38,7 +38,6 @@ export type DashboardCorePoll = {
3838 startupHealthSeed : SettingsData [ "startupHealth" ] | null | undefined ;
3939 sidecar : SidecarData | null ;
4040 shadowCall : ShadowCallData | null | undefined ;
41- usage30d : UsageSummary30d | null ;
4241 maMode : "v1" | "default" | "v2" ;
4342 maModeResolved : boolean ;
4443 /** Absent when the optional endpoint failed — callers must keep prior UI state. */
@@ -89,6 +88,14 @@ export async function fetchDashboardModels(apiBase: string, signal: AbortSignal)
8988 return requireJson < ModelInfo [ ] > ( response ) ;
9089}
9190
91+ export async function fetchDashboardUsage ( apiBase : string , signal : AbortSignal ) : Promise < UsageSummary30d > {
92+ const response = await fetch ( `${ apiBase } /api/usage?range=30d` , { signal } ) ;
93+ // Usage can be expensive on an older server. Keeping it in its own resource means
94+ // it cannot delay health/provider/settings commits, and a failed refresh retains
95+ // the last good usage snapshot.
96+ return requireJson < UsageSummary30d > ( response ) ;
97+ }
98+
9299export async function fetchDashboardCore (
93100 apiBase : string ,
94101 signal : AbortSignal ,
@@ -112,7 +119,6 @@ export async function fetchDashboardCore(
112119 startupHealthSeed : undefined ,
113120 sidecar : null ,
114121 shadowCall : undefined ,
115- usage30d : null ,
116122 maMode : "default" ,
117123 maModeResolved : true ,
118124 injection : undefined ,
@@ -121,13 +127,12 @@ export async function fetchDashboardCore(
121127 } ;
122128
123129 try {
124- const [ hRes , pRes , sRes , scRes , shRes , uRes ] = await Promise . all ( [
130+ const [ hRes , pRes , sRes , scRes , shRes ] = await Promise . all ( [
125131 fetch ( `${ apiBase } /healthz` , { signal } ) ,
126132 fetch ( `${ apiBase } /api/providers` , { signal } ) ,
127133 fetch ( `${ apiBase } /api/settings` , { signal } ) ,
128134 fetch ( `${ apiBase } /api/sidecar-settings` , { signal } ) ,
129135 fetch ( `${ apiBase } /api/shadow-call-settings` , { signal } ) ,
130- fetch ( `${ apiBase } /api/usage?range=30d` , { signal } ) ,
131136 ] ) ;
132137
133138 const health = await requireJson < HealthData > ( hRes ) ;
@@ -176,14 +181,6 @@ export async function fetchDashboardCore(
176181 }
177182 }
178183
179- // Usage is best-effort: a malformed/empty body must not mark the whole dashboard offline.
180- let usage30d : UsageSummary30d | null = null ;
181- try {
182- usage30d = ( await readJsonIfOk < UsageSummary30d > ( uRes ) ) ?? null ;
183- } catch {
184- usage30d = null ;
185- }
186-
187184 let maMode : "v1" | "default" | "v2" = "default" ;
188185 let maModeResolved = false ;
189186 try {
@@ -236,7 +233,6 @@ export async function fetchDashboardCore(
236233 startupHealthSeed,
237234 sidecar,
238235 shadowCall,
239- usage30d,
240236 maMode,
241237 maModeResolved,
242238 injection,
0 commit comments