From 771b8ef180ff4de4e93186358f8b2e91f0a8fef5 Mon Sep 17 00:00:00 2001 From: Yunfei He Date: Mon, 25 May 2026 22:55:21 +0800 Subject: [PATCH] fix: emit empty frames so components rendering null produce output The frame writer initialized lastFrame to "" and also reset it to "" on clear(). Since commit() calls clear() then write(), any component that painted to an empty string (e.g. Transform with no children, or a component returning null after unmounting children) would be deduplicated against the cleared state and never emitted. Use null as the sentinel for "no previous frame" so the first write after a clear always goes through, even when the frame is empty. Fixes: Transform with null/undefined children tests Fixes: Focus unmount crash tests (stale frame persisted) Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/runtime/src/io/frame-writer.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/runtime/src/io/frame-writer.ts b/packages/runtime/src/io/frame-writer.ts index 639fed6..3b49b70 100644 --- a/packages/runtime/src/io/frame-writer.ts +++ b/packages/runtime/src/io/frame-writer.ts @@ -10,7 +10,9 @@ export function createFrameWriter( stream: NodeJS.WriteStream, options: { debug?: boolean }, ): FrameWriter { - let lastFrame = ""; + // Sentinel: use a value that can never equal a real frame so the very first + // write (even an empty string) is always emitted. + let lastFrame: string | null = null; const debug = options.debug ?? false; const update = debug ? null : createLogUpdate(stream); @@ -28,7 +30,7 @@ export function createFrameWriter( if (update) update.done(); }, clear() { - lastFrame = ""; + lastFrame = null; if (update) update.clear(); }, };