The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): show agentless context categories when the window is unknown
unsupportedpastels239c9d262828
diff --git a/apps/desktop/src/app/shell/hooks/use-context-breakdown.test.ts b/apps/desktop/src/app/shell/hooks/use-context-breakdown.test.tsindex dc3c734be4d..b1cb6bfd024 100644--- a/apps/desktop/src/app/shell/hooks/use-context-breakdown.test.ts+++ b/apps/desktop/src/app/shell/hooks/use-context-breakdown.test.ts@@ -204,6 +204,32 @@ describe('useContextBreakdown (#94001)', () => {expect(requestGateway).toHaveBeenCalledTimes(2)})+ it('serves an agentless breakdown that has categories but no known window', async () => {+ // `session.context_breakdown` after a restart or reap: measured from the+ // session's freeze, beside stored usage that carries no window.+ const agentless: ContextBreakdown = {+ categories: [{ color: '#888', id: 'system', label: 'System prompt', tokens: 3_200 }],+ context_estimated: false,+ context_max: 0,+ context_percent: 0,+ context_source: 'provider_usage',+ context_used: 0,+ estimated_total: 3_200,+ model: ''+ }++ const requestGateway = vi.fn(async () => agentless) as unknown as GatewayRequester++ const { result } = renderHook(props => useContextBreakdown(props), {+ initialProps: { busy: false, enabled: true, requestGateway, sessionId: 's1' as null | string }+ })++ await flushAsync()++ expect(result.current.breakdown).toEqual(agentless)+ expect(requestGateway).toHaveBeenCalledTimes(1)+ })+it('never serves a previous session’s cached numbers after its own refetch exhausts retries', async () => {// Scenario 1 guard: the s1 cache must not paint under s2 while s2's fetch// exhausts its retries against a failing backend.diff --git a/apps/desktop/src/app/shell/hooks/use-context-breakdown.ts b/apps/desktop/src/app/shell/hooks/use-context-breakdown.tsindex bd54844ffc3..5e58abe9788 100644--- a/apps/desktop/src/app/shell/hooks/use-context-breakdown.ts+++ b/apps/desktop/src/app/shell/hooks/use-context-breakdown.ts@@ -39,17 +39,19 @@ interface ContextBreakdownOptions {* `invalidateContextBreakdown` bumps a per-session generation that both* call sites (slash.ts after a successful compress, lifecycle.ts on* reclaim) fire, forcing an immediate refetch. An untrustworthy answer —- * an outright failure, or a ZEROED breakdown from the backend's- * agent-is-None branch (`context_max: 0`) — retries on a bounded backoff;+ * an outright failure, or a ZEROED breakdown (`context_max: 0` and no+ * categories) — retries on a bounded backoff;* once the ladder is exhausted the cached breakdown is EVICTED so the* meter goes dark honestly rather than showing numbers known to be* stale. *//** A breakdown the backend computed from a live agent carries a real- * context_max (the compressor's context_length). Zero means the- * `agent is None` branch answered from empty metadata — not data. */+ * context_max (the compressor's context_length). With no resident agent the+ * gateway still measures the session's frozen prompt, tools and transcript+ * but knows no window, so categories without a capacity are data; only a+ * breakdown with neither is empty. */function isZeroedBreakdown(breakdown: ContextBreakdown): boolean {- return !(breakdown.context_max > 0)+ return !(breakdown.context_max > 0) && !breakdown.categories?.length}const RETRY_DELAYS_MS = [1_000, 4_000, 12_000]