@devries-cameron20 / t3code Mirror · read-only / commits / 16ca47b3d3
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 04:30 UTC

fix(shared): ignore unsupported command output erase modes (#29737)

Romil committed Nov 4, 2026 at 10:42 UTC 16ca47b3d3590462747deccead8f0ae46d62d25c
2 files changed +12 -2
packages/shared/src/terminalOutput.test.ts
+10
@@ -87,6 +87,16 @@ describe("appendTerminalOutput", () => {
87 });
88
89 describe("appendTerminalOutput edge cases from review", () => {
90 + it("leaves the screen and cursor alone for unsupported erase modes", () => {
91 + for (const sequence of ["3K", "4J", "99K", "99J"]) {
92 + const input = `a\nb\nc\u001b[${sequence}X`;
93 + expect(feed([input]).text).toBe("a\nb\ncX");
94 + for (let cut = 1; cut < input.length; cut += 1) {
95 + expect(feed([input.slice(0, cut), input.slice(cut)]).text).toBe("a\nb\ncX");
96 + }
97 + }
98 + });
99 +
100 it("clears only scrollback on ESC[3J", () => {
101 const lines = Array.from({ length: 70 }, (_, index) => `line ${index}`).join("\n");
102 const state = feed([lines, "\u001b[3J"]);
packages/shared/src/terminalOutput.ts
+2 -2
@@ -132,7 +132,7 @@ function eraseLine(line: Line, col: number, mode: number): Line {
132 for (const run of sliceLine(line, col + 1, length)) pushRun(runs, run);
133 return runs;
134 }
135 - return [];
135 + return mode === 2 ? [] : line;
136 }
137
138 function serializeLine(line: Line): string {
@@ -443,7 +443,7 @@ class Terminal {
443 if (this.settledHead !== "" || this.settledTail !== "") this.dropped = true;
444 this.settledHead = "";
445 this.settledTail = "";
446 - } else {
446 + } else if (mode === 2) {
447 this.lines = [[]];
448 this.row = 0;
449 this.col = 0;