From a445a812792801eff3a3ab514c96973bbf8431c5 Mon Sep 17 00:00:00 2001 From: lepetitprince716-prog Date: Thu, 6 Aug 2026 15:18:04 -0400 Subject: [PATCH] fix(desktop-sdk): type focusedUsage as Partial, fix expect arity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ClientSessionState.usage is Partial (app/types.ts) — the backend streams whichever fields changed — so the computed produces ReadableAtom | 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. --- apps/desktop/src/sdk/host-state.test.ts | 7 ++++--- apps/desktop/src/sdk/index.ts | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/desktop/src/sdk/host-state.test.ts b/apps/desktop/src/sdk/host-state.test.ts index ddbc314df2..1dd2590092 100644 --- a/apps/desktop/src/sdk/host-state.test.ts +++ b/apps/desktop/src/sdk/host-state.test.ts @@ -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' }), diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.ts index 9a86fc3134..1d71e32287 100644 --- a/apps/desktop/src/sdk/index.ts +++ b/apps/desktop/src/sdk/index.ts @@ -145,8 +145,10 @@ export const host = { focusedStoredSessionId: readonlyAtom($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($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>($focusedUsage), /** Gateway socket state: 'idle' | 'connecting' | 'open' | …. Not turn-busy. */ gateway: readonlyAtom($gatewayState), /** Current main model slug. */