From 3b7448d156aab5af1e21fd9ab45d19e4f10865a8 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Thu, 9 Apr 2026 03:32:59 +0200 Subject: [PATCH] fix(tui): replace spread-into-push in Container.render() to prevent stack overflow, closes #2651 --- packages/tui/CHANGELOG.md | 4 ++++ packages/tui/src/tui.ts | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/tui/CHANGELOG.md b/packages/tui/CHANGELOG.md index 6642b81f..49d39c60 100644 --- a/packages/tui/CHANGELOG.md +++ b/packages/tui/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Fixed `Container.render()` stack overflow on long sessions by replacing `Array.push(...spread)` with a loop-based push, preventing `RangeError: Maximum call stack size exceeded` when child output exceeds the V8 call stack argument limit ([#2651](https://github.com/badlogic/pi-mono/issues/2651)) + ## [0.66.1] - 2026-04-08 ## [0.66.0] - 2026-04-08 diff --git a/packages/tui/src/tui.ts b/packages/tui/src/tui.ts index 0c1fa4d7..c5fb8701 100644 --- a/packages/tui/src/tui.ts +++ b/packages/tui/src/tui.ts @@ -202,7 +202,10 @@ export class Container implements Component { render(width: number): string[] { const lines: string[] = []; for (const child of this.children) { - lines.push(...child.render(width)); + const childLines = child.render(width); + for (const line of childLines) { + lines.push(line); + } } return lines; }