From 542271e30515488deb59e3f42deb1571d6b9d225 Mon Sep 17 00:00:00 2001 From: Vignesh Natarajan Date: Sat, 14 Feb 2026 14:47:37 -0800 Subject: [PATCH] tui: cap local shell output buffering --- src/tui/tui-local-shell.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tui/tui-local-shell.ts b/src/tui/tui-local-shell.ts index 0ff12a54674..436a833ccf5 100644 --- a/src/tui/tui-local-shell.ts +++ b/src/tui/tui-local-shell.ts @@ -100,6 +100,11 @@ export function createLocalShellRunner(deps: LocalShellDeps) { deps.chatLog.addSystem(`[local] $ ${cmd}`); deps.tui.requestRender(); + const appendWithCap = (text: string, chunk: string) => { + const combined = text + chunk; + return combined.length > maxChars ? combined.slice(-maxChars) : combined; + }; + await new Promise((resolve) => { const child = spawnCommand(cmd, { shell: true, @@ -110,10 +115,10 @@ export function createLocalShellRunner(deps: LocalShellDeps) { let stdout = ""; let stderr = ""; child.stdout.on("data", (buf) => { - stdout += buf.toString("utf8"); + stdout = appendWithCap(stdout, buf.toString("utf8")); }); child.stderr.on("data", (buf) => { - stderr += buf.toString("utf8"); + stderr = appendWithCap(stderr, buf.toString("utf8")); }); child.on("close", (code, signal) => {