From 9fb303841400f2bf5dae88d24b7260823f2ec14d Mon Sep 17 00:00:00 2001 From: Yilin Jing Date: Wed, 7 Oct 2026 20:50:42 -0400 Subject: [PATCH] A picture still being written draws nothing, not an with no source remend 1.4 (#204) rewrites a half-written image to `![alt](streamdown:incomplete-image)` where 1.3 dropped it. DOMPurify strips that source, so the chat showed a broken picture until the closing bracket arrived. Co-Authored-By: Claude Opus 5.5 --- canvas/src/markdown.test.ts | 7 +++++++ canvas/src/markdown.ts | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/canvas/src/markdown.test.ts b/canvas/src/markdown.test.ts index 52e83444..a408c121 100644 --- a/canvas/src/markdown.test.ts +++ b/canvas/src/markdown.test.ts @@ -15,6 +15,13 @@ describe("renderMarkdown", () => { expect(renderMarkdown("run `bun test")).toContain("bun test"); }); + it("draws no picture until its source has arrived whole", () => { + expect(renderMarkdown("see ![shot](https://x.dev/a")).not.toContain(" { expect(renderMarkdown("| a | b |")).not.toContain("` is the project's server @@ -21,6 +21,11 @@ const md = new Marked({ token.href = `file${url.pathname}${url.search}${url.hash}`; } }, + // A picture a delta cut open comes out of remend under a source only Streamdown draws, which + // DOMPurify drops, leaving an `` with none. Nothing is drawn until the rest arrives. + renderer: { + image: ({ href }) => (href === INCOMPLETE_IMAGE_PLACEHOLDER ? "" : false), + }, }); export function renderMarkdown(text: string): string {