fix(tui): normalize shell progress output
This commit is contained in:
parent
8454f94dbe
commit
a67a8235e1
3 changed files with 32 additions and 13 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { expect, test } from "bun:test"
|
||||
import { collapseToolOutput } from "../../../src/util/collapse-tool-output"
|
||||
import { collapseToolOutput, normalizeShellOutput } from "../../../src/util/collapse-tool-output"
|
||||
|
||||
test("limits command input and output to the same line budget", () => {
|
||||
const command = Array.from({ length: 8 }, (_, index) => `command ${index + 1}`).join("\n")
|
||||
|
|
@ -12,3 +12,13 @@ test("limits command input and output to the same line budget", () => {
|
|||
expect(collapsed.output).toContain("command 8\n\noutput 1…")
|
||||
expect(collapsed.output).not.toContain("output 2")
|
||||
})
|
||||
|
||||
test("normalizes carriage-return shell progress before collapsing", () => {
|
||||
const output = Array.from({ length: 30 }, (_, index) => `progress ${index + 1}`).join("\r")
|
||||
const collapsed = collapseToolOutput(normalizeShellOutput(output), 10, 1_000)
|
||||
|
||||
expect(collapsed.overflow).toBe(true)
|
||||
expect(collapsed.output.split("\n")).toHaveLength(10)
|
||||
expect(collapsed.output).toContain("progress 10…")
|
||||
expect(collapsed.output).not.toContain("progress 11")
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue