Open History to see the last commit
1import { ProviderInstanceId } from "@t3tools/contracts";
2import { describe, expect, it } from "vite-plus/test";
3import {
4 formatContextWindowCompactionMessage,
5 resolveContextWindowModelDisplayName,
6} from "./ContextWindowMeter.logic";
7
8describe("resolveContextWindowModelDisplayName", () => {
9 it("uses the selected model from the exact provider instance", () => {
10 const primaryInstanceId = ProviderInstanceId.make("codex");
11 const selectedInstanceId = ProviderInstanceId.make("codex-work");
12 const modelOptionsByInstance = new Map([
13 [
14 primaryInstanceId,
15 [{ slug: "gpt-5.6-sol", name: "Primary profile model", shortName: "Primary" }],
16 ],
17 [selectedInstanceId, [{ slug: "gpt-5.6-sol", name: "GPT-5.6 Sol", shortName: "5.6 Sol" }]],
18 ]);
19
20 expect(
21 resolveContextWindowModelDisplayName(
22 {
23 instanceId: selectedInstanceId,
24 model: "gpt-5.6-sol",
25 },
26 modelOptionsByInstance,
27 ),
28 ).toBe("5.6 Sol");
29 });
30
31 it("falls back to the selected model slug when model metadata is unavailable", () => {
32 const selectedInstanceId = ProviderInstanceId.make("codex-work");
33
34 expect(
35 resolveContextWindowModelDisplayName(
36 {
37 instanceId: selectedInstanceId,
38 model: "custom-model",
39 },
40 new Map(),
41 ),
42 ).toBe("custom-model");
43 });
44});
45
46describe("formatContextWindowCompactionMessage", () => {
47 it("describes compaction in terms of the selected model", () => {
48 expect(formatContextWindowCompactionMessage("GPT-5.6 Sol")).toBe(
49 "Context for GPT-5.6 Sol compacts automatically when needed.",
50 );
51 });
52
53 it("uses neutral copy when the model is unavailable", () => {
54 expect(formatContextWindowCompactionMessage(null)).toBe(
55 "Context compacts automatically when needed.",
56 );
57 });
58});