diff --git a/frontend/src/shared/providerUsage.test.ts b/frontend/src/shared/providerUsage.test.ts index b73ba917..4b6d0aac 100644 --- a/frontend/src/shared/providerUsage.test.ts +++ b/frontend/src/shared/providerUsage.test.ts @@ -21,8 +21,18 @@ test('summary leads with memory, names scale, and lists recent topics', () => { assert.match(s, /Swift concurrency; Deadlift form check; Tax on RSUs/); }); -test('summary is hard-capped so a heavy user never ships a wall of PII', () => { +test('titles are capped at 150 for breadth, so a heavy user ships a sample not all of them', () => { const titles = Array.from({ length: 1000 }, (_, i) => `conversation number ${i} about a very specific topic`); - const s = summarizeUsage({ ok: true, total: 1000, titles, memories: [] }); - assert.ok(s.length <= 4000, `summary length ${s.length} exceeded 4000`); + const s = summarizeUsage({ ok: true, total: 1000, capped: true, titles, memories: [] }); + assert.match(s, /1000\+ past AI conversations/); // capped => count is shown as an honest "N+" floor + assert.ok(s.includes('conversation number 0')); + assert.ok(s.includes('conversation number 149')); + assert.ok(!s.includes('conversation number 150'), 'only the first 150 titles ship'); +}); + +test('the full-convo payload (the real substance) is bounded by the char budget', () => { + const convos = Array.from({ length: 60 }, (_, i) => ({ title: `t${i}`, text: 'x'.repeat(5000) })); + const s = summarizeUsage({ ok: true, total: 60, titles: [], memories: [], convos }); + // Full recent-conversation text is intentionally large (distilled downstream), but never unbounded. + assert.ok(s.length <= 140000, `convo block should honor the ~130K budget, got ${s.length}`); });