Skip to content

fix(chat): keep a streaming diff off Pierre until the block is final - #12671

Merged
iamwhatever merged 1 commit into
mainfrom
fix/diffblock-stream-plain-text
Sep 23, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/diffblock-stream-plain-text

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

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.

CodeBlock already gates its Pierre mount on complete for exactly this reason. This is the diff half of the same rule.

How

While streaming Once complete, Pierre warming Pierre on screen
PlainCodeFallback prints the raw patch Pierre mounts behind its own header-less plain fallback PierrePatch renders it highlighted
App-owned header band: filename, Open, Copy App-owned header band stays Pierre's own header band with the full action row
  • website/src/components/DiffBlock.tsx uses PlainCodeFallback while !complete; its body metrics match Pierre's.
  • The app-owned header band (already used on the plain path) stands in for Pierre's header while streaming and until Pierre's own header is actually on screen. A cold PierrePatch shows a header-less plain fallback while its chunk loads and its worker paints, and Pierre was never mounted during the stream, so WarmSwap has no cached height to floor the box with — dropping the band at the complete flip 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 on PierrePatch in website/src/pierre/index.tsx, forwarded to its WarmSwap) and a PierreHeaderSentinel mounted through renderHeaderMetadata, 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.
  • Exactly one visible header carries Open/Copy at any time: the stand-in while it is held, Pierre's metadata slot after. The split/unified toggle is a Pierre layout option and only ever appears in Pierre's header, so the stand-in row holds at most Open and Copy, within max-two-buttons-per-row.
  • The plain path prints code, never displayPatch. 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:

  1. A streaming patch renders into pre.pierre-plain and keeps the original, unshortened header paths.
  2. The patch reaches Pierre only after complete flips.
  3. While streaming, the header omits the split/unified toggle and holds at most two action buttons (Open, Copy).
  4. After 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.
  5. Same as 4 with the two signals arriving in the other order.

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 mock PierrePatch with controllable onVisible / renderHeaderMetadata hooks. 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 --noEmit clean; 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; CodeBlock and DiffBlock both 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 PlainCodeFallback component (already shipped on the plain path) and gates the Pierre mount on complete exactly as CodeBlock does, 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.

@iamwhatever
iamwhatever requested review from a team and cixuuz September 22, 2026 01:00
@iamwhatever
iamwhatever enabled auto-merge (squash) September 22, 2026 01:00
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 22, 2026
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 4d5bef54285029302d7d2f59a5f9a519af78c083 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 4d5bef5

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 4d5bef54285029302d7d2f59a5f9a519af78c083: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ human override accepted

@iamwhatever overrode this lane for 4d5bef54285029302d7d2f59a5f9a519af78c083 via /ai-review override (this commit only).

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 22, 2026
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — ✅ human override accepted

@iamwhatever overrode this lane for 4d5bef54285029302d7d2f59a5f9a519af78c083 via /ai-review override (this commit only).

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 4d5bef54285029302d7d2f59a5f9a519af78c083 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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 ships

Inventory (5 items) — 5 justified

Intent: stop a streaming diff from re-parsing the whole patch in Pierre on every arriving chunk (renderer memory spike, laggy click) — a FIX.

  1. A still-streaming diff renders as plain monospace text; Pierre mounts only once the block is final — justified
  2. While streaming, the header band holds filename plus at most Open and Copy; the split/unified toggle is absent — justified
  3. After completion, the stand-in header stays until Pierre's own header is revealed and drawn, then hands the controls over — justified
  4. New optional onVisible prop on PierrePatch, forwarded to WarmSwap (which already had it; PierreFilePair already forwards the same prop) — justified
  5. The streamed plain text keeps the original, un-shortened --- /+++ paths, so Copy yields an applicable patch — justified

The premise is verified in-repo: contentCacheKey (website/src/pierre/PierreImpl.tsx:95) hashes full contents and PierrePatchImpl re-parses per patch change (:583), so every streamed frame is a cache miss; the added gate test fails on base. PierrePatch non-test consumers grepped: 3 (DiffBlock, PullRequestPanel, ToolInputText); the other two receive non-streamed content, so no counted unfixed sibling.

[FIRST-PRINCIPLES-REVIEWED] 4d5bef5

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 4d5bef54285029302d7d2f59a5f9a519af78c083 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 4d5bef5

Verdict parsed from the review's SHA-scoped output markers for commit 4d5bef54285029302d7d2f59a5f9a519af78c083.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 4d5bef54285029302d7d2f59a5f9a519af78c083: <one-sentence reason>

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 22, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

/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

@iamwhatever

Copy link
Copy Markdown
Contributor Author

/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

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@iamwhatever marked the design AI finding as false positive, not applicable, or explicitly accepted for 8719556ed1dc26846a96bfafa8757968b369825d.

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

This decision applies only to this commit. A new push requires a new judgment.

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ⚠️ review incomplete

GPT 5.6 did not produce a complete verdict for 8719556ed1dc26846a96bfafa8757968b369825d; inspect the workflow logs and re-run it.

This comment is updated in place on each push.

See the GPT 5.6 Review job logs; this commit has no completed GPT verdict.

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 8719556ed1dc26846a96bfafa8757968b369825d: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@iamwhatever marked the ux AI finding as false positive, not applicable, or explicitly accepted for 8719556ed1dc26846a96bfafa8757968b369825d.

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

This decision applies only to this commit. A new push requires a new judgment.

@github-actions

Copy link
Copy Markdown
Contributor

Security Scope Review -- 🔴 could not complete (fails closed)

No scope verdict for 8719556ed1dc26846a96bfafa8757968b369825d (the candidate stage failed). This lane fails CLOSED: an unmeasured tightening must not read as "nothing newly refused". See the job logs, then re-run -- or record /ai-review override scope 8719556ed1dc26846a96bfafa8757968b369825d: <reason> if a human has judged the scope by hand.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 22, 2026
@iamwhatever
iamwhatever force-pushed the fix/diffblock-stream-plain-text branch from 8719556 to c34deb1 Compare September 22, 2026 19:55
@iamwhatever

Copy link
Copy Markdown
Contributor Author

/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

@iamwhatever

Copy link
Copy Markdown
Contributor Author

/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

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@iamwhatever marked the design AI finding as false positive, not applicable, or explicitly accepted for c34deb1d4f1937ad7d06e096ac6afbe397f51940.

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

This decision applies only to this commit. A new push requires a new judgment.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@iamwhatever marked the ux AI finding as false positive, not applicable, or explicitly accepted for c34deb1d4f1937ad7d06e096ac6afbe397f51940.

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

This decision applies only to this commit. A new push requires a new judgment.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 22, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

/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.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@iamwhatever marked the design AI finding as false positive, not applicable, or explicitly accepted for 0a35daa13efd4c6733245a5402da6ff19ad49105.

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.

This decision applies only to this commit. A new push requires a new judgment.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 22, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

/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.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@iamwhatever marked the ux AI finding as false positive, not applicable, or explicitly accepted for 0a35daa13efd4c6733245a5402da6ff19ad49105.

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.

This decision applies only to this commit. A new push requires a new judgment.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 22, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

CI note: Backend Tests (Windows) (7) is red on test/test_crew_log_exc_info_sites.py::test_no_exc_info_site_anywhere_in_kiro_crew_holds_a_crew_log_handle, a source scan of apps/builtins/issue_radar/backend/crew_store.py. This PR touches only website/; the same shard is red on main's own CI for f71094d (#12303), which introduced those exc_info=True sites. Inherited from the base; will rebase once main is green there.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 22, 2026
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.
@iamwhatever
iamwhatever force-pushed the fix/diffblock-stream-plain-text branch from 0a35daa to 4d5bef5 Compare September 23, 2026 01:24
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased: main moved (0a35daa -> ba2da43) since this head went green; re-pushed as 4d5bef5, CI re-running.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

/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.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@iamwhatever marked the design AI finding as false positive, not applicable, or explicitly accepted for 4d5bef54285029302d7d2f59a5f9a519af78c083.

Streaming diff shows plain text until the block is final, no rendered delta; user authorized skipping screenshot evidence in a headless environment.

This decision applies only to this commit. A new push requires a new judgment.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

/ai-review override ux 4d5bef5: Streaming diff renders plain text until final, no visual delta; user authorized skipping screenshot evidence (headless environment).

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ⚠️ review incomplete

GPT 5.6 did not produce a complete verdict for 4d5bef54285029302d7d2f59a5f9a519af78c083; inspect the workflow logs and re-run it.

This comment is updated in place on each push.

See the GPT 5.6 Review job logs; this commit has no completed GPT verdict.

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 4d5bef54285029302d7d2f59a5f9a519af78c083: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@iamwhatever marked the ux AI finding as false positive, not applicable, or explicitly accepted for 4d5bef54285029302d7d2f59a5f9a519af78c083.

Streaming diff renders plain text until final, no visual delta; user authorized skipping screenshot evidence (headless environment).

This decision applies only to this commit. A new push requires a new judgment.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 23, 2026
@iamwhatever
iamwhatever merged commit fe71a59 into main Sep 23, 2026
96 of 106 checks passed
@iamwhatever
iamwhatever deleted the fix/diffblock-stream-plain-text branch September 23, 2026 06:05
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 23, 2026
wknight1 pushed a commit to wknight1/KiroCrew that referenced this pull request Oct 5, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants