Repository navigation
fix(chat): recover a closing fence glued to prose - #18405
Conversation
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that the glued-closer heuristic doesn't close HTML/JSX code fences: [DESIGN-REVIEWED] 5760c45 Description read[DESCRIPTION-READ] 4c5d545dc138eed4f0f3330100934de5a564b62a00009ded78756c6549815e48 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
UX Review (Opus 5.5, fork) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS No first-time reader has seen the new warning or the auto-opened chip. Screenshots and a recording show both, so the verdict is capped at CONCERNS. Watch
[UX-REVIEWED] 5760c45 Description read[DESCRIPTION-READ] 3c6a40a9472f6bb68571b07572806c236f17dc9f3bcdc19af524ac268ce6ffe4 That sha256 names everything this verdict read: the PR description, plus the 5 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The widget-fence recovery copies the diff fix with no reported defect behind it, and a glued closer now has two rules for one job that already disagree. Not justified as shipped
What this change shipsInventory (6 items) — 4 justifiedIntent: a reply whose diff fence is glued to the prose after it, or never closes, still shows that prose. FIX.
[FIRST-PRINCIPLES-REVIEWED] 5760c45 Description read[DESCRIPTION-READ] 062cd1ef3d7aa422b2f6c5ce6834904b15fa95e4ddd90cd35998f1e0bdbccde1 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed Review detailsFINDING — website/src/components/FoldableDiffBlock.tsx:82 — the effect keyed on [OPUS-REVIEWED] 5760c45 |
2c2edc9 to
79269c9
Compare
|
suggestion (non-blocking): the warning uses parser words
|
|
thought (non-blocking): the chip turns into an expanded diff when streaming ends
|
|
issue (non-blocking): two glued-closer rules that disagree on ```358KB
|
79269c9 to
c0f6811
Compare
|
issue (blocking): the chip is replaced by a different block when streaming ends
|
|
note: severity is rare, confusing when it happens
|
|
suggestion (non-blocking): the warning line is too faint on a light theme
|
|
issue (blocking): the chip unmounts and a plain DiffBlock mounts in its place
|
|
issue (blocking): the chip vanishes and new content appears in its spot
|
|
suggestion (blocking): keep FoldableDiffBlock mounted and force it open, then attach a recording
|
|
thought (non-blocking): "diff" in the warning is developer vocabulary
|
|
note: recording of the streaming finish is now in the description The UX lane's evidence gap at c0f6811 asked for a recording of a live stream ending with an unclosed diff. The description now links one. It is the real |
issue (non-blocking): the ```` ```{r} ```` exemption in `fixCodeFences` rides along
|
|
note: Frontend Tests (3) at 7be1735 is a timing flake in The one failure is "pressing the highlighted control on the last step finishes the guide, as Done does": a |
…nclosed diff A reply that closed its diff fence with ```**Financial summary** kept the rest of the reply, widget included, inside the fence, and the chat folded it behind a collapsed diff chip. parseBlocks now closes a fence on a backtick run glued to prose and re-reads the glued text as a normal line. One predicate, isGluedProse, decides what counts as glued text, and fixCodeFences reuses it for the split it already did on markdown blocks. A finished reply that leaves a fence open marks the block unclosed, and the renderer opens that diff's chip in place, with a warning above it, instead of leaving it folded. The warning string is translated in every authored catalog. Fixes kirodotdev#18347
7be1735 to
5760c45
Compare
|
chore (non-blocking): rebased on main, no behaviour change. The conflict was only in the 13 locale files, where main added closed_session_* keys next to this PR's unclosed_diff_warning key; both sets are kept. On 5760c45, tsc, i18n:check and 384 targeted frontend tests pass. This push also gives the GuideLayer flake in Frontend Tests (3) a fresh run. |
|
thought (non-blocking): the widget-fence glued-close recovery rides along
|
|
thought (non-blocking): two glued-closer rules that disagree on
|
|
thought (non-blocking): no first-time reader has seen the warning sentence
|
|
thought (non-blocking): the recovered answer shows up as diff content
|
|
todo (non-blocking): the auto-open effect in
|
|
note (non-blocking): Design asked whether Yes, for a three-backtick fence. A line inside that fence starting with three backticks and then |
iamwhatever
left a comment
There was a problem hiding this comment.
This fixes the root cause of a reply's summary and widget vanishing inside a folded diff chip: parseBlocks in website/src/hooks/useBlockAssembler.ts now treats a backtick run glued to prose (**Summary**) as a closer and re-reads the glued text as an ordinary line, and a finished reply whose fence never closed gets an unclosed flag, so FoldableDiffBlock opens that chip under a warning instead of hiding it. I re-checked our change request from 5caee8b on head 5760c45 and both points are met: INFO_STRING_SHAPE is now the letter-first tag that runs to the first space, backtick or {, so rust,ignore, rust,no_run and js= stay openers and have tests, fixCodeFences is back to main's rule byte for byte, """ is excluded by PROSE_START, and the widget-fence sibling has the same recovery with its own test and a disposition. I tried to break the parser. The re-read text can never start with a backtick, so lines[i] = glued[2]; i-- cannot loop or reopen a fence. Diff body lines start with +, - or a space, so a glued run inside a patch never matches. A shorter run never closes a longer fence, and a nested markdown example is counted before the glued check. The one gap I see is the Design lane's note that `<` counts as a prose start, so
Problem / Motivation
Goal: A reply whose closing diff fence is glued to the prose after it still shows that prose and its widget, and a diff that never closes is never folded out of sight.
A reply closed its diff fence with
```**Financial summary**, three backticks followed straight away by prose on the same line. The chat showed only the introduction and one collapsed diff chip. The summary and the inline widget were in the saved transcript but not on the page, with no warning.parseBlocksonly accepts a closing fence that stands alone on its line, so the glued line did not close the fence. Everything after it, the<mcwidget>tag included, became diff content. At the end of a finished reply the still-open fence was flushed as a complete block, and the transcript's diff folding hid it behind the chip.Why it matters
The substantive answer of a reply disappears without any sign that something is missing. A reader sees a short intro and a chip and has no reason to open a patch to look for the answer. Formatting slips like this one are rare but not avoidable, so the renderer has to fail visibly instead of silently.
Not a goal
src/kiro_crew/config/prompt.mdandsrc/kiro_crew/context.py. Merging them into one shorter contract is a separate PR.chat_runner.py, where the end of one reply and the start of the next can share one stored row. Tracked separately.What changed (motivation → approach → change)
The summary and widget were hidden in a collapsed diff chip. The parser does not treat a glued closer as a closer, so the fence runs to the end of the reply. The renderer also cannot tell "streaming finished" from "a closer was seen". The fix makes two narrow changes.
Recovery inside block segmentation, in
website/src/hooks/useBlockAssembler.ts. Inside a fence, a line that is a backtick run followed straight away by text closes the fence, and the text is read again as an ordinary line, so a summary or widget tag gets its own block. It applies only when all of these hold:markdown,mdand similar) a line that opens a nested example is still counted as one first*,_,#,<,>,!,~or a non-ASCII letter, so a code line such as```"""stays content```python,```rust,ignore,```js {1,3},```{r}and```js:app.jsstay contentLetter-first text such as
```Summaryis ambiguous and is not recovered; the fallback below covers it when the fence never closes. A fence inside a widget gets the same recovery, so a glued</mcwidget>still ends the widget.The last three conditions are one exported predicate,
isGluedProse, used inside a fence and inside a widget's fence.fixCodeFencesinMarkdownRenderer.tsxkeeps its own split rule for glued closers such as```358KBon markdown blocks, and that rule is unchanged from main.A visible fallback.
ContentBlockinwebsite/src/types/index.tsgainsunclosed, set only when a finished reply ends with a fence still open. It is tracked apart fromcomplete, which means streaming has finished. In the transcript,website/src/components/MarkdownRenderer.tsxpasses the warning toFoldableDiffBlock, which keeps the chip mounted, opens it and shows the warning above it. A diff still being streamed collapses as before, so when such a reply finishes the user sees the chip they were watching open in place rather than a different block replacing it. A closed diff is unchanged. The warning names what the reader sees, "The formatting broke here, so the rest of the reply may appear inside this diff." It is one new key, translated in all 12 authored catalogs, withen-XA.jsonregenerated byscripts/gen-pseudolocale.mjs.Response assembly does not cause this. On main, the text either side of a tool call is stored as separate assistant rows, and token deltas inside one message are joined with nothing in between. The new tests pin both. Two messages parse independently, and one message split into chunks parses the same as the whole string.
Backwards compatibility
Compatible: a fence that closes on its own line parses as before, and a non-transcript surface renders a diff expanded as before. The only new behavior is that a glued line meeting the conditions above now closes its fence.
Removes nothing a caller relies on: the change adds one optional field, one recovery predicate and one rendering branch.
Tests
website/src/test/useBlockAssembler.gluedFence.test.ts(new):rust,ignore, attributed info strings,```"""in Python, backticks and a spaced remainder stay content</mcwidget>end itwebsite/src/test/fixCodeFences.test.ts:rust,ignore,rust,no_run, andjs=openers stay whole, and glued"x",(a),-1and358KBremainders still splitunclosedon a finished open fence, never on a streaming or a closed onewebsite/src/test/MarkdownRendererCoverage.test.tsx, full renderer DOM path:Manual verification
Two disposable pods, one at this branch's head and one at main 6968f00, each loaded with the same synthetic two-reply transcript and opened in the dashboard.
Gates run locally:
tsc -p tsconfig.app.json, the full frontend suite in 4 shards (11070 passed, 1 expected fail), andnpm run i18n:checkwithI18N_BASE_REF=origin/main.Screenshots / video
Main, glued reply and unclosed reply. Both answers are folded away:
This branch at the current head. The summary and the widget show after the chip. The unclosed diff's chip is open under the shipped warning, and the sentence after the patch shows inside it:
Recording of a live stream finishing, rendered by the real
MarkdownRendererin a scratch page at this commit. The reply streams in with the diff folded to its chip. When the reply ends with the fence still open, the warning appears above the chip and the same chip opens in place:streaming-finish.webm
Related Issues
Fixes #18347
Pattern harvest
Rule candidate: review-prompt
Pattern: a renderer that folds or hides content by default needs a visible fallback for input that failed to parse, so a malformed block can never hide the text after it
Checklist
Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.