fix(tui): preserved visible ANSI content when truncating terminal rows

- Replaced the TUI row truncation path with per-character and ANSI-sequence iteration that tracks visible cells before clipping output.
- Added ANSI helpers to parse sequence boundaries and preserve OSC66 visible payloads while enforcing max source length during truncation.
- Added natives regression coverage for Ghostty super+alt backspace key matching and parsing.
This commit is contained in:
can1357
2026-06-08 01:22:26 +02:00
parent d930f4c82d
commit a89bb76444
3 changed files with 89 additions and 2 deletions
+13
View File
@@ -14,7 +14,9 @@ import {
invalidateFsScanCache,
listWorkspace,
MacOSPowerAssertion,
matchesKey,
PtySession,
parseKey,
summarizeCode,
truncateToWidth,
visibleWidth,
@@ -148,6 +150,17 @@ describe("pi-natives", () => {
expect(summarizeCode({ path: "fixture.ts", code, minBodyLines: 3 }).elided).toBe(true);
});
});
describe("keys", () => {
it("matches Ghostty's super+alt Backspace Kitty wire", () => {
const ghosttyOptionBackspace = "\x1b[127;11u";
expect(matchesKey(ghosttyOptionBackspace, "super+alt+backspace", true)).toBe(true);
expect(matchesKey(ghosttyOptionBackspace, "alt+super+backspace", true)).toBe(true);
expect(matchesKey(ghosttyOptionBackspace, "alt+backspace", true)).toBe(false);
expect(parseKey(ghosttyOptionBackspace, true)).toBe("alt+super+backspace");
});
});
describe("grep", () => {
it("should find patterns in files", async () => {
const result = await grep({