fix(app): terminal disconnect and resync (#14004)

This commit is contained in:
Adam
2026-02-17 12:54:28 -06:00
committed by GitHub
parent fb79dd7bf8
commit 20f43372f6
3 changed files with 91 additions and 12 deletions

View File

@@ -6,7 +6,10 @@ describe("terminalWriter", () => {
const calls: string[] = []
const scheduled: VoidFunction[] = []
const writer = terminalWriter(
(data) => calls.push(data),
(data, done) => {
calls.push(data)
done?.()
},
(flush) => scheduled.push(flush),
)
@@ -24,10 +27,38 @@ describe("terminalWriter", () => {
test("flush is a no-op when empty", () => {
const calls: string[] = []
const writer = terminalWriter(
(data) => calls.push(data),
(data, done) => {
calls.push(data)
done?.()
},
(flush) => flush(),
)
writer.flush()
expect(calls).toEqual([])
})
test("flush waits for pending write completion", () => {
const calls: string[] = []
let done: VoidFunction | undefined
const writer = terminalWriter(
(data, finish) => {
calls.push(data)
done = finish
},
(flush) => flush(),
)
writer.push("a")
let settled = false
writer.flush(() => {
settled = true
})
expect(calls).toEqual(["a"])
expect(settled).toBe(false)
done?.()
expect(settled).toBe(true)
})
})