refactor(tui): extract standalone package (#31193)

This commit is contained in:
Dax
2026-06-07 05:24:27 +00:00
committed by GitHub
parent 7a2c49e762
commit 106f8e94d6
84 changed files with 1148 additions and 1919 deletions
+6 -9
View File
@@ -1,11 +1,8 @@
import { describe, expect, test } from "bun:test"
import { sessionExitSummary } from "../../src/util/presentation"
import { expect, test } from "bun:test"
import { sessionEpilogue } from "../../src/util/presentation"
describe("util.presentation", () => {
test("formats the ANSI session exit summary", () => {
const summary = sessionExitSummary({ title: "A session", sessionID: "ses_123" })
expect(summary.split("\n")).toHaveLength(8)
expect(summary).toContain("\x1b[90mSession \x1b[0m\x1b[1mA session\x1b[0m")
expect(summary).toContain("\x1b[1mopencode -s ses_123\x1b[0m")
})
test("formats session continuation summary", () => {
const epilogue = sessionEpilogue({ title: "A session", sessionID: "ses_123" })
expect(epilogue).toContain("A session")
expect(epilogue).toContain("opencode -s ses_123")
})
+30
View File
@@ -0,0 +1,30 @@
import { expect, test } from "bun:test"
import { destroyRenderer } from "../../src/util/renderer"
test("clears the terminal title before destroying the renderer", () => {
const calls: string[] = []
destroyRenderer({
isDestroyed: false,
setTerminalTitle(title) {
calls.push(`title:${title}`)
},
destroy() {
calls.push("destroy")
},
})
expect(calls).toEqual(["title:", "destroy"])
})
test("still clears the title after renderer destruction", () => {
const calls: string[] = []
destroyRenderer({
isDestroyed: true,
setTerminalTitle(title) {
calls.push(`title:${title}`)
},
destroy() {
calls.push("destroy")
},
})
expect(calls).toEqual(["title:"])
})