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) <noreply@anthropic.com>
This commit is contained in:
Yunfei He
2026-05-25 22:55:21 +08:00
parent 04707e82d9
commit 771b8ef180
+4 -2
View File
@@ -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();
},
};