feat(tui): refine quiet terminal interactions

This commit is contained in:
Xubin Ren
2026-08-17 20:56:10 +08:00
parent 7ed37e5b70
commit 8f9bdb210e
12 changed files with 401 additions and 48 deletions
+28
View File
@@ -0,0 +1,28 @@
import { describe, expect, test } from "bun:test"
import { ComposerDraft } from "./composer-draft"
describe("ComposerDraft", () => {
test("keeps ordinary pastes editable as ordinary text", () => {
const draft = new ComposerDraft()
const insertion = draft.paste("first\r\nsecond")
expect(insertion).toEqual({ text: "first\nsecond", compacted: false, description: "" })
expect(draft.expand(`before ${insertion.text} after`)).toBe("before first\nsecond after")
})
test("compacts large pastes and expands only placeholders that remain", () => {
const draft = new ComposerDraft()
const content = Array.from({ length: 12 }, (_, index) => `line ${index}`).join("\n")
const first = draft.paste(content)
const second = draft.paste(content)
expect(first.text).toBe("[Pasted 12 lines] ")
expect(second.text).toBe("[Pasted 12 lines #2] ")
expect(draft.expand(`review ${first.text.trim()}`)).toBe(`review ${content}`)
draft.prune(second.text)
expect(draft.expand(first.text.trim())).toBe(first.text.trim())
expect(draft.expand(second.text.trim())).toBe(content)
})
})