import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { createContext, runInContext } from "node:vm"; import { afterAll, beforeAll, describe, expect, it } from "vitest"; import { exportFromFile } from "../src/core/export-html/index.ts"; import { CURRENT_SESSION_VERSION, type SessionHeader, type SessionMessageEntry } from "../src/core/session-manager.ts"; import { initTheme } from "../src/modes/interactive/theme/theme.ts"; interface TreeNode { entry: { id: string }; children: TreeNode[]; } interface TreeApi { buildTree: () => TreeNode[]; buildActivePathIds: (targetId: string) => Set; flattenTree: (roots: TreeNode[], activePathIds: Set) => Array<{ node: TreeNode }>; findNewestLeaf: (nodeId: string) => string; getPath: (targetId: string) => Array<{ id: string }>; } function loadTreeApi(html: string): TreeApi { const sessionData = html.match(/