From 0f0cc3da8d905a9c544bc287f8163d61b2d79aff Mon Sep 17 00:00:00 2001 From: Hadi Minooei Date: Fri, 20 Mar 2026 10:02:34 -0700 Subject: [PATCH] fix(simulator): use proper newlines and full static history for getScreen --- packages/cli/src/interactiveCli.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/interactiveCli.tsx b/packages/cli/src/interactiveCli.tsx index 87997220d3..60ad1ae260 100644 --- a/packages/cli/src/interactiveCli.tsx +++ b/packages/cli/src/interactiveCli.tsx @@ -144,6 +144,7 @@ export async function startInteractiveUI( const simulatedStdin = new PassThrough({ encoding: 'utf8' }); let lastFrame: string | undefined; + const staticHistory: string[] = []; const instance = render( process.env['DEBUG'] ? ( @@ -161,6 +162,12 @@ export async function startInteractiveUI( isScreenReaderEnabled: config.getScreenReader(), onRender: (metrics: RenderMetrics) => { lastFrame = metrics.output; + if (metrics.staticOutput) { + staticHistory.push(metrics.staticOutput); + if (staticHistory.length > 50) { + staticHistory.shift(); + } + } if (metrics.renderTime > SLOW_RENDER_MS) { recordSlowRender(config, metrics.renderTime); } @@ -196,7 +203,12 @@ export async function startInteractiveUI( if (simulateUser) { const simulator = new UserSimulator( config, - () => lastFrame, + () => { + if (lastFrame === undefined) return undefined; + // Combine history with latest frame for the simulator + const historyText = staticHistory.join('\n'); + return historyText ? `${historyText}\n${lastFrame}` : lastFrame; + }, simulatedStdin, ); simulator.start();