fix(desktop-sdk): type focusedUsage as Partial<UsageStats>, fix expect arity

ClientSessionState.usage is Partial<UsageStats> (app/types.ts) — the
backend streams whichever fields changed — so the computed produces
ReadableAtom<Partial<UsageStats> | null>. Annotate the entry honestly
instead of claiming full UsageStats, and document the fallback rule for
plugin authors. Also collapse the three-argument expect() calls in the
contract test (vitest takes one message arg). Addresses triage review on
PR #80461.
This commit is contained in:
lepetitprince716-prog
2026-08-06 15:18:04 -04:00
committed by Teknium
parent 74b7d5da2d
commit a445a81279
2 changed files with 8 additions and 5 deletions
+4 -3
View File
@@ -38,9 +38,9 @@ describe('host.state focused-session atoms', () => {
for (const key of ['focusedSessionId', 'focusedStoredSessionId', 'focusedUsage'] as const) {
const store = host.state[key]
expect(store, key).toBeDefined()
expect(typeof store.get, 'function', key)
expect(typeof store.listen, 'function', key)
expect(typeof store.subscribe, 'function', key)
expect(typeof store.get, key).toBe('function')
expect(typeof store.listen, key).toBe('function')
expect(typeof store.subscribe, key).toBe('function')
}
})
@@ -74,6 +74,7 @@ describe('host.state focused-session atoms', () => {
title: id
})
}
tree.declareDefaultTree(
model.split('row', [
model.group(['workspace'], { active: 'workspace', id: 'grp-main' }),
+4 -2
View File
@@ -145,8 +145,10 @@ export const host = {
focusedStoredSessionId: readonlyAtom<null | string>($focusedStoredSessionId),
/** Live usage snapshot of the focused session (`context_used` /
* `context_max` / `context_percent`, token counts, `cost_usd`) —
* streamed by the backend, no RPC needed. Null while unresolved. */
focusedUsage: readonlyAtom<null | UsageStats>($focusedUsage),
* streamed by the backend, no RPC needed. Null while unresolved.
* Partial: the backend streams whichever fields changed, so every
* field read needs a fallback. */
focusedUsage: readonlyAtom<null | Partial<UsageStats>>($focusedUsage),
/** Gateway socket state: 'idle' | 'connecting' | 'open' | …. Not turn-busy. */
gateway: readonlyAtom<string>($gatewayState),
/** Current main model slug. */