Files
t3code/apps/web/src/lib/contextWindow.test.ts
T
Julius Marminge b7f71acd29 Complete orchestration V2 frontend cutover
- Migrate web and mobile state, commands, and persistence to V2 projections
- Render conversations from authoritative visible turn items
- Harden runtime policy, launch handling, attachments, and cache invalidation
2026-08-14 11:23:08 +02:00

45 lines
1.4 KiB
TypeScript

import { describe, expect, it } from "vite-plus/test";
import { deriveLatestContextWindowSnapshot, formatContextWindowTokens } from "./contextWindow";
describe("V2 context window presentation", () => {
it("uses retained compaction token data when available", () => {
const snapshot = deriveLatestContextWindowSnapshot([
{
id: "compaction-1",
createdAt: "2026-06-20T00:00:00.000Z",
runId: null,
label: "Context compacted",
tone: "info",
itemType: "compaction",
toolLifecycleStatus: "completed",
structuredPayload: {
id: "compaction-1" as never,
threadId: "thread-1" as never,
runId: null,
nodeId: null,
providerThreadId: null,
providerTurnId: null,
nativeItemRef: null,
parentItemId: null,
ordinal: 1,
status: "completed",
title: null,
startedAt: null,
completedAt: null,
updatedAt: {} as never,
type: "compaction",
driver: null,
beforeTokenCount: 10_000,
afterTokenCount: 2_000,
},
},
]);
expect(snapshot?.usedTokens).toBe(2_000);
expect(snapshot?.totalProcessedTokens).toBe(10_000);
});
it("formats compact token values", () => {
expect(formatContextWindowTokens(1_500)).toBe("1.5k");
});
});