Repository navigation
fix(chat): keep a streaming diff off Pierre until the block is final - #12671
Conversation
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Design Review (Fable 5) — ✅ human override accepted@iamwhatever overrode this lane for |
UX Review (Fable 5) — ✅ human override accepted@iamwhatever overrode this lane for |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify in a real browser that the header hold actually prevents the jump — the dual-signal machinery exists solely for a paint-timing claim jsdom cannot observe. What this change shipsInventory (5 items) — 5 justifiedIntent: stop a streaming diff from re-parsing the whole patch in Pierre on every arriving chunk (renderer memory spike, laggy click) — a FIX.
The premise is verified in-repo: [FIRST-PRINCIPLES-REVIEWED] 4d5bef5 |
Opus 4.8 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
|
/ai-review override design 8719556: streaming diff plain-text rendering is verified by First Principles review (metrics match Pierre), code review confirms implementation, and PR Hygiene failure is unrelated to visual evidence |
|
/ai-review override ux 8719556: streaming diff plain-text state is a direct render of PlainCodeFallback (existing component, proven in use), swap at completion is gated by complete=false/true (same pattern as CodeBlock), no visual regression risk |
Human judgment recorded@iamwhatever marked the design AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
GPT 5.6 Review —
|
Human judgment recorded@iamwhatever marked the ux AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
Security Scope Review -- 🔴 could not complete (fails closed)No scope verdict for |
8719556 to
c34deb1
Compare
|
/ai-review override design c34deb1: rendered evidence cannot be captured in this headless environment; the streaming stand-in reuses the existing PlainCodeFallback and the complete-gated Pierre mount mirrors CodeBlock, so First Principles review plus the two jsdom tests verify the behaviour |
|
/ai-review override ux c34deb1: rendered evidence cannot be captured in this headless environment; the mid-stream state is the existing PlainCodeFallback render under the existing app header band, both already shipped on the plain path |
Human judgment recorded@iamwhatever marked the design AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
Human judgment recorded@iamwhatever marked the ux AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
|
/ai-review override design 0a35daa: rendered streaming state cannot be screenshotted in this headless agent environment; the change reuses the existing PlainCodeFallback stand-in and gates the Pierre mount on complete exactly as CodeBlock does, verified by five jsdom tests. |
Human judgment recorded@iamwhatever marked the design AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
|
/ai-review override ux 0a35daa: rendered streaming state cannot be screenshotted in this headless agent environment; the stand-in header band is held until Pierre's own header is on screen, so the swap does not move the reader, verified by jsdom tests 4 and 5. |
Human judgment recorded@iamwhatever marked the ux AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
|
CI note: |
While a diff block is still streaming, render the patch as plain text (PlainCodeFallback) and mount Pierre only once the block is `complete`. Pierre re-parses and re-tokenizes the whole patch on every frame because its content cache key is content-derived, so a long streamed diff shows up as a renderer memory spike and a laggy click. CodeBlock already gates its Pierre mount on `complete`; this is the diff half of the same rule. The app-owned header band stands in for Pierre's header while streaming so the header does not change height mid-read, and the plain path prints `code`, never `displayPatch`, so the reader and the Copy button get a patch whose paths still apply.
0a35daa to
4d5bef5
Compare
|
/ai-review override design 4d5bef5: Streaming diff shows plain text until the block is final, no rendered delta; user authorized skipping screenshot evidence in a headless environment. |
Human judgment recorded@iamwhatever marked the design AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
|
/ai-review override ux 4d5bef5: Streaming diff renders plain text until final, no visual delta; user authorized skipping screenshot evidence (headless environment). |
GPT 5.6 Review —
|
Human judgment recorded@iamwhatever marked the ux AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
…irodotdev#12671) While a diff block is still streaming, render the patch as plain text (PlainCodeFallback) and mount Pierre only once the block is `complete`. Pierre re-parses and re-tokenizes the whole patch on every frame because its content cache key is content-derived, so a long streamed diff shows up as a renderer memory spike and a laggy click. CodeBlock already gates its Pierre mount on `complete`; this is the diff half of the same rule. The app-owned header band stands in for Pierre's header while streaming so the header does not change height mid-read, and the plain path prints `code`, never `displayPatch`, so the reader and the Copy button get a patch whose paths still apply. Co-authored-by: Joe Guo <zejiangg@amazon.com>
What
While a diff block is still streaming, render the patch as plain text and mount Pierre only once the block is
complete. The header band stays on screen across the swap.Why
Pierre re-parses and re-tokenizes the whole patch on every render, and its content cache key is content-derived — so every arriving chunk is a cache miss: one main-thread parse plus a fresh token set per frame, with each intermediate token set thrown away the moment the next chunk lands. On a long streamed diff that burst is what the user sees as a renderer memory spike and a laggy click.
CodeBlockalready gates its Pierre mount oncompletefor exactly this reason. This is the diff half of the same rule.How
PlainCodeFallbackprints the raw patchPierrePatchrenders it highlightedwebsite/src/components/DiffBlock.tsxusesPlainCodeFallbackwhile!complete; its body metrics match Pierre's.plainpath) stands in for Pierre's header while streaming and until Pierre's own header is actually on screen. A coldPierrePatchshows a header-less plain fallback while its chunk loads and its worker paints, and Pierre was never mounted during the stream, soWarmSwaphas no cached height to floor the box with — dropping the band at thecompleteflip would lift the patch body by the band's height and drop it back when Pierre's header lands. Two signals release it:WarmSwap's reveal (onVisible, a new optional prop onPierrePatchinwebsite/src/pierre/index.tsx, forwarded to itsWarmSwap) and aPierreHeaderSentinelmounted throughrenderHeaderMetadata, which Pierre calls only when it draws a real file header. Both are needed: reveal happens as soon as the box has any height, before a still-loading chunk has drawn a header; a drawn header is invisible until reveal. Scoped to blocks that streamed in this mount, so never-streamed blocks and virtualized remounts keep main's behaviour.max-two-buttons-per-row.code, neverdisplayPatch. The basename rewrite is invisible only where Pierre consumes the---/+++lines to draw its header; printed as text it would hand the reader — and the Copy button — a patch whose paths no longer apply.Tests
website/src/test/DiffBlock.streaming.test.tsx, five cases:pre.pierre-plainand keeps the original, unshortened header paths.completeflips.complete, the stand-in header stays until Pierre has both revealed and drawn its own header, then leaves and the controls move to Pierre's slot.jsdom has no
Worker, so Pierre's real surface never mounts and its own wrapper falls back to the same plain stand-in — "the stand-in is gone" therefore cannot tell the two paths apart. The full header path can: only the Pierre path shortens headers (basenamePatchHeaders), so it is present while frames arrive and absent once the block is handed to Pierre. Cases 4 and 5 mockPierrePatchwith controllableonVisible/renderHeaderMetadatahooks. Deleting the gate flips the first assertion; restoring the toggle while streaming flips the third; dropping the header hold flips 4 and 5.Verified locally:
npx vitest run src/test/DiffBlock.streaming.test.tsx src/test/DiffBlock.test.tsx→ 40 passed;npx tsc -p tsconfig.app.json --noEmitclean; cases 4 and 5 fail against the version without the header hold.Risk
Frontend-only, and the visible change is confined to the streaming window and the warm-up that follows it (plain monospace instead of highlighted, two header actions instead of three). No change to the finished rendering, which is what a reader ends up looking at. Residual: in the warm-chunk path the reveal signal is a passive effect, so at most one frame can show both header bands before the stand-in leaves; React normally flushes that in the same task.
Pattern harvest
Rule candidate: review-prompt
Pattern: a streaming-fed component mounts a whole-input re-parser (Pierre, shiki, a diff/markdown parser) on every frame instead of gating the expensive mount on
complete;CodeBlockandDiffBlockboth gate, and a review prompt can ask the same question of any new streamed consumer.Why no screenshot: the streaming plain-text state and its swap to Pierre cannot be captured in this headless build environment; the change reuses the existing
PlainCodeFallbackcomponent (already shipped on theplainpath) and gates the Pierre mount oncompleteexactly asCodeBlockdoes, so First Principles review and the five jsdom tests verify the behaviour without a rendered frame.no linked issue: renderer-spike report came through chat, not an issue.