opencode/packages/tui/test/util/session.test.ts
usrnk1 7b33bcea4e
feat(desktop): show session tokens and cost on the session view (#53785)
Co-authored-by: LukeParkerDev <10430890+Hona@users.noreply.github.com>
2026-10-13 23:14:04 +00:00

25 lines
948 B
TypeScript

import { describe, expect, test } from "bun:test"
import { sessionFamily } from "../../src/util/session"
describe("util.session", () => {
test("flattens nested subagents from any session in the family", () => {
const sessions = [
{ id: "root" },
{ id: "child-a", parentID: "root" },
{ id: "grandchild-a", parentID: "child-a" },
{ id: "great-grandchild-a", parentID: "grandchild-a" },
{ id: "grandchild-a2", parentID: "child-a" },
{ id: "child-b", parentID: "root" },
{ id: "grandchild-b", parentID: "child-b" },
]
expect(sessionFamily(sessions, "great-grandchild-a")).toEqual([
{ session: sessions[1], prefix: "" },
{ session: sessions[2], prefix: "├─ " },
{ session: sessions[3], prefix: "│ └─ " },
{ session: sessions[4], prefix: "└─ " },
{ session: sessions[5], prefix: "" },
{ session: sessions[6], prefix: "└─ " },
])
})
})