feat(tui): add OverlayOptions API and fix width overflow crash

Adds positioning/sizing options for overlays and fixes crash when compositing
lines with complex ANSI sequences exceed terminal width.
This commit is contained in:
Nico Bailon 2026-01-12 07:39:33 -08:00
parent 842a65f06a
commit 0c0aac6599
7 changed files with 962 additions and 28 deletions

View file

@ -165,4 +165,35 @@ describe("TUI differential rendering", () => {
tui.stop();
});
it("handles transition from content to empty and back to content", async () => {
const terminal = new VirtualTerminal(40, 10);
const tui = new TUI(terminal);
const component = new TestComponent();
tui.addChild(component);
// Start with content
component.lines = ["Line 0", "Line 1", "Line 2"];
tui.start();
await terminal.flush();
let viewport = terminal.getViewport();
assert.ok(viewport[0]?.includes("Line 0"), "Initial content rendered");
// Clear to empty
component.lines = [];
tui.requestRender();
await terminal.flush();
// Add content back - this should work correctly even after empty state
component.lines = ["New Line 0", "New Line 1"];
tui.requestRender();
await terminal.flush();
viewport = terminal.getViewport();
assert.ok(viewport[0]?.includes("New Line 0"), `New content rendered: ${viewport[0]}`);
assert.ok(viewport[1]?.includes("New Line 1"), `New content line 1: ${viewport[1]}`);
tui.stop();
});
});