Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002) | 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; | |
| 3 | ||
| 4 | import { Recent } from "./chat-cache.ts"; | |
| 5 | ||
| 6 | test("the conversation cache keeps the most recently used, and no more", () => { | |
| 7 | const recent = new Recent<number>(3); | |
| 8 | recent.set("a", 1); | |
| 9 | recent.set("b", 2); | |
| 10 | recent.set("c", 3); | |
| 11 | // Reading a moves it to the end, so b is the oldest. | |
| 12 | assert.equal(recent.get("a")?.value, 1); | |
| 13 | recent.set("d", 4); | |
| 14 | assert.deepEqual(recent.keys(), ["c", "a", "d"]); | |
| 15 | assert.equal(recent.has("b"), false); | |
| 16 | // Setting again replaces and refreshes. | |
| 17 | recent.set("c", 30); | |
| 18 | assert.deepEqual(recent.keys(), ["a", "d", "c"]); | |
| 19 | assert.equal(recent.get("c")?.value, 30); | |
| 20 | }); |
This file's history is long; its oldest lines are credited to the oldest commit read.