feat(tui): unify session history and context

This commit is contained in:
Xubin Ren
2026-08-17 20:56:10 +08:00
parent b3c3a82075
commit 6301c0ab57
24 changed files with 880 additions and 84 deletions
+27
View File
@@ -0,0 +1,27 @@
import { afterEach, describe, expect, test } from "bun:test"
import { mkdtemp, readFile, rm } from "node:fs/promises"
import { tmpdir } from "node:os"
import { join } from "node:path"
import { rememberChat } from "./session-state"
describe("TUI session state", () => {
let directory = ""
afterEach(async () => {
if (directory) await rm(directory, { recursive: true, force: true })
directory = ""
})
test("atomically remembers the last attached gateway chat", async () => {
directory = await mkdtemp(join(tmpdir(), "nanobot-tui-state-"))
const path = join(directory, "nested", "state.json")
await rememberChat(path, "chat-123")
expect(JSON.parse(await readFile(path, "utf8"))).toEqual({
schema_version: 1,
chat_id: "chat-123",
})
})
})