History opens a seat's conversation from the Waiting card, table row and inspector. It pages the whole branch through the CHAT-02 board routes, renders untrusted text inert, polls with the follow cursor, and marks every switch (branch, newer, reconcile, gone). The WebUI proxy passes only the two conversation routes' queries upstream. Dewey authored it. Filbert asked for changes on r1 (24b046af) and approved r2 (d06de6a7) in review 160dd68d. A relaunch shows 'newer', not 'reconcile', a deviation from brief 2.3 item 6 that Filbert accepted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
20 lines
1.7 KiB
JavaScript
20 lines
1.7 KiB
JavaScript
import { mkdirSync, writeFileSync, appendFileSync, mkdtempSync, realpathSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { tmpdir } from "node:os";
|
|
import { createReader } from "../../../../packages/conversation/src/reader.mjs";
|
|
const proj = realpathSync(mkdtempSync(join(tmpdir(), "fb-proj-")));
|
|
const dir = join(proj, ".pi", "state", "x", "sessions"); mkdirSync(dir, { recursive: true });
|
|
const f = join(dir, "s.jsonl");
|
|
const L = (o) => JSON.stringify(o) + "\n";
|
|
const msg = (id, parentId, role, text) => L({ type: "message", id, parentId, timestamp: "2026-09-26T00:00:00Z", message: role === "assistant" ? { role, content: [{ type: "text", text }], stopReason: "stop" } : { role, content: text } });
|
|
writeFileSync(f, L({ type: "session", id: "sess", cwd: proj, timestamp: "2026-09-26T00:00:00Z" }) + msg("a", null, "user", "hi") + msg("b", "a", "assistant", "hello"));
|
|
const reader = createReader({ roots: [{ seat: "x", project: "p", projectRoot: proj, dir, harness: "pi", unsupportedReason: null, engineStartedAt: null }] });
|
|
const conv = reader.catalogue().conversations[0].conversation;
|
|
const p1 = reader.open({ conversation: conv });
|
|
console.log("open branch", p1.page.branch, "entries", p1.page.entries.map(e => e.id + "@" + e.branch));
|
|
appendFileSync(f, msg("c", "b", "user", "more") + msg("d", "c", "assistant", "ok"));
|
|
const p2 = reader.next({ cursor: p1.follow.id, conversation: conv, branch: p1.page.branch });
|
|
console.log("follow ok", p2.ok, "page branch", p2.page?.branch, "entries", p2.page?.entries.map(e => e.id + "@" + e.branch), "view", JSON.stringify(p2.view?.branches));
|
|
const p3 = reader.open({ conversation: conv, branch: p1.page.branch });
|
|
console.log("reopen with first branch id:", JSON.stringify(p3.refusal ?? p3.page.branch));
|