tui: cap local shell output buffering

This commit is contained in:
Vignesh Natarajan
2026-02-14 14:47:37 -08:00
parent a5ca0df4f4
commit 542271e305

View File

@@ -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<void>((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) => {