Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

contextWindow.test.ts

38 lines1.2 KB

1import { describe, expect, it } from "vite-plus/test";
2import * as DateTime from "effect/DateTime";
3import { deriveLatestContextWindowSnapshot, formatContextWindowTokens } from "./contextWindow";
4​
5describe("V2 context window presentation", () => {
6 it("uses retained compaction token data when available", () => {
7 const snapshot = deriveLatestContextWindowSnapshot([
8 {
9 item: {
10 id: "compaction-1" as never,
11 threadId: "thread-1" as never,
12 runId: null,
13 nodeId: null,
14 providerThreadId: null,
15 providerTurnId: null,
16 nativeItemRef: null,
17 parentItemId: null,
18 ordinal: 1,
19 status: "completed",
20 title: null,
21 startedAt: null,
22 completedAt: null,
23 updatedAt: DateTime.makeUnsafe("2026-06-20T00:00:00.000Z"),
24 type: "compaction",
25 driver: null,
26 beforeTokenCount: 10_000,
27 afterTokenCount: 2_000,
28 },
29 },
30 ]);
31 expect(snapshot?.usedTokens).toBe(2_000);
32 expect(snapshot?.totalProcessedTokens).toBe(10_000);
33 });
34​
35 it("formats compact token values", () => {
36 expect(formatContextWindowTokens(1_500)).toBe("1.5k");
37 });
38});