Skip to content

fix(chat): recover a closing fence glued to prose - #18405

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:fix/malformed-diff-fence
Oct 12, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:fix/malformed-diff-fence

Conversation

@Pearcekieser

@Pearcekieser Pearcekieser commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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.

parseBlocks only 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

  • Changing the output rules in src/kiro_crew/config/prompt.md and src/kiro_crew/context.py. Merging them into one shorter contract is a separate PR.
  • The mid-turn steer seam in chat_runner.py, where the end of one reply and the start of the next can share one stored row. Tracked separately.
  • Glued openers and mid-sentence backticks, which fix(chat): keep a mid-sentence triple backtick as prose #17539 covers.
  • Rewriting fence handling to full CommonMark.

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.

  1. 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:

    • the run is at least as long as the opening fence, so a shorter run never closes a longer one
    • no nested example is open, and for a markup fence (markdown, md and similar) a line that opens a nested example is still counted as one first
    • the text has no backtick, so code such as a template literal keeps its run
    • the text starts like prose: a digit, *, _, #, <, >, !, ~ or a non-ASCII letter, so a code line such as ```""" stays content
    • the text does not have the shape of an info string, so ```python, ```rust,ignore, ```js {1,3}, ```{r} and ```js:app.js stay content

    Letter-first text such as ```Summary is 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. fixCodeFences in MarkdownRenderer.tsx keeps its own split rule for glued closers such as ```358KB on markdown blocks, and that rule is unchanged from main.

  2. A visible fallback. ContentBlock in website/src/types/index.ts gains unclosed, set only when a finished reply ends with a fence still open. It is tracked apart from complete, which means streaming has finished. In the transcript, website/src/components/MarkdownRenderer.tsx passes the warning to FoldableDiffBlock, 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, with en-XA.json regenerated by scripts/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):
    • the reported sample gives diff, markdown and widget blocks, the same as the correctly separated control
    • a widget tag glued straight to the closer, and a plain code fence with a glued closer
    • fence lengths: a shorter run never closes a longer fence, and a matching four-backtick run does
    • language tags, rust,ignore, attributed info strings, ```""" in Python, backticks and a spaced remainder stay content
    • a glued closer inside a widget's fence still lets </mcwidget> end it
  • website/src/test/fixCodeFences.test.ts: rust,ignore, rust,no_run, and js= openers stay whole, and glued "x", (a), -1 and 358KB remainders still split
    • nested markdown examples, including one with an attributed inner opener
    • a literal widget tag inside a closed code block stays code
    • every streaming prefix of the sample, and a closer split across token chunks
    • unclosed on a finished open fence, never on a streaming or a closed one
  • website/src/test/MarkdownRendererCoverage.test.tsx, full renderer DOM path:
    • glued sample: the chip renders for the patch, and the summary is visible
    • glued sample with a real widget: the widget renders as a frame
    • a finished unclosed diff shows the warning, its chip expanded, and its text
    • a streaming unclosed diff folds, and once finalized the same chip element opens under the warning
  • Reverting the two production files on the branch makes 18 of these tests fail.

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.

  • Main: the glued reply shows the intro and one diff chip. The summary and the widget are gone. The unclosed reply shows its intro and a second chip, and the sentence after the patch is gone.
  • Branch: the glued reply shows the chip, then the summary heading and text, then the widget frame. The unclosed reply shows the warning above its chip, the chip is open, and the sentence after the patch is visible inside the patch.

Gates run locally: tsc -p tsconfig.app.json, the full frontend suite in 4 shards (11070 passed, 1 expected fail), and npm run i18n:check with I18N_BASE_REF=origin/main.

Screenshots / video

Main, glued reply and unclosed reply. Both answers are folded away:

Main: the summary, widget and final sentence are missing behind two diff chips

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:

Branch: the summary heading, the widget, and an expanded unclosed diff with a warning line

Recording of a live stream finishing, rendered by the real MarkdownRenderer in 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

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@Pearcekieser
Pearcekieser requested review from a team and KiroCrewCaptain as code owners October 9, 2026 08:45
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 5760c4549afb0f31b4ff48bec40ea8737252d505 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check that the glued-closer heuristic doesn't close HTML/JSX code fences: < counts as a prose start, so a line like ```<div> inside code would end the fence.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — 🟡 CONCERNS

UX-level review of 5760c4549afb0f31b4ff48bec40ea8737252d505 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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

  • The warning sentence is unread by a first-time reader. The new line "The formatting broke here, so the rest of the reply may appear inside this diff." appears in attachment-02 above the open notes.md +4 chip. It uses amber text with an icon, so it does not rely on colour alone. Whether a first-time reader understands "formatting broke" and "this diff" is unknown, because this lane has no blind read. This affects only rare malformed replies, but there it is the only clue that part of the answer is missing. A maintainer can get the blind read by pushing the branch to this repository.
  • The recovered answer shows up as diff content. In attachment-02, the swallowed sentence ("This sentence is the actual answer and must stay visible.") renders as numbered monospace diff lines on both sides of a split view. The user has to read their answer out of a patch. It is visible, which meets the PR's goal, but it is hard to read. It is rare and follows the warning, so this is a concern, not a blocker.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — 🟡 CONCERNS

Premise-level review of 5760c4549afb0f31b4ff48bec40ea8737252d505 via the fork AI-review pipeline — 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: 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

  • Item 3 — inherited: the hunk calls itself "The same glued-closer recovery as the 'fence' state". The description reports no reply where a glued </mcwidget> was lost. The fix only needs the outer-fence rule.
    Subtraction: delete the GLUED_CLOSE branch and widgetFenceLen from the 'widget-fence' case. Strict close only.
    Clears when: a transcript or issue shows a glued closer inside a widget fence losing content.
  • Item 5 — duplicate of website/src/components/MarkdownRenderer.tsx:655 (fixCodeFences closer split): I grepped for glued-closer rules and found 2 in core. The two disagree today: "x", (a) and -1 split there but stay content under isGluedProse. The description says the old rule "keeps its own split rule".
    Subtraction: replace the fixCodeFences closer regex with isGluedProse, so one rule decides.
    Clears when: one predicate decides glued closers on both paths, or a test shows a markdown block that needs the wider rule.

What this change ships

Inventory (6 items) — 4 justified

Intent: a reply whose diff fence is glued to the prose after it, or never closes, still shows that prose. FIX.

  1. A glued closer such as ```**Summary** now ends a diff or code fence, and the text after it renders as its own block — justified
  2. A finished reply whose diff never closed now opens its chip under a warning — justified
  3. A glued closer inside a widget's code fence now ends that fence — rides along, inherited
  4. One new warning string, translated in 12 catalogs plus the pseudolocale — justified
  5. A second predicate for glued closers, isGluedProse, beside the fixCodeFences split rule — duplicate of MarkdownRenderer.tsx:655
  6. A new optional unclosed field on ContentBlock — justified

[FIRST-PRINCIPLES-REVIEWED] 5760c45

Description read

[DESCRIPTION-READ] 062cd1ef3d7aa422b2f6c5ce6834904b15fa95e4ddd90cd35998f1e0bdbccde1

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 5760c4549afb0f31b4ff48bec40ea8737252d505 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 5760c45

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 5760c4549afb0f31b4ff48bec40ea8737252d505 via the fork AI-review pipeline; updated in place on each push.

Review details

FINDING — website/src/components/FoldableDiffBlock.tsx:82 — the effect keyed on [warning, foldKey] reopens an unclosed-diff chip the user folded. On remount (load-earlier, variant switch or tab return, which the expandedDiffFences doc names), useState starts collapsed because toggle deleted the key, then the effect calls setExpanded(true) and adds the key back. A language switch also re-fires it, because i18nT returns a new warning string. So the user's fold does not survive, which is the case the module-level set exists to prevent → Fix: key the effect on !!warning, and record "auto-opened once" per foldKey in a module-level set, so the effect never undoes a fold the user chose.

[OPUS-REVIEWED] 5760c45

@Pearcekieser
Pearcekieser force-pushed the fix/malformed-diff-fence branch from 2c2edc9 to 79269c9 Compare October 9, 2026 09:43
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

suggestion (non-blocking): the warning uses parser words

Outcome: fixed in 79269c9.
The warning now reads "The formatting broke here, so the rest of the reply may appear inside this diff." It names what the reader sees on the page, the reply text sitting inside the patch, and drops "never closed". The key is translated in all 12 authored catalogs, and the renderer test asserts the new text.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

thought (non-blocking): the chip turns into an expanded diff when streaming ends

Outcome: kept as shipped.
While a reply streams, every diff is open until its closer arrives, so the renderer cannot tell an unclosed diff from one that is still being written. Showing the warning during streaming would flag every diff in every reply for the length of its stream. The flip happens once, at the end of the turn, and only on the rare reply whose fence never closed. A reload or a replay of that reply renders the expanded diff and warning directly, with no chip first; the pod screenshots on the PR are that reload path.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (non-blocking): two glued-closer rules that disagree on ```358KB

Outcome: fixed in 79269c9, both layers now use one predicate.
isGluedProse is exported from useBlockAssembler.ts, and the glued-closer split in fixCodeFences calls it instead of its own lookahead. A tag must now start with a letter or _, so 358KB is glued text in both layers. A new test closes a diff fence on 358KB in parseBlocks, and the existing fixCodeFences test for the same input still passes. The one change on the fixCodeFences side is that ```{r} stays an opener instead of being split. The line-625 pass stays because it serves markdown blocks that parseBlocks never sees inside a fence.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 9, 2026
@Pearcekieser
Pearcekieser force-pushed the fix/malformed-diff-fence branch from 79269c9 to c0f6811 Compare October 9, 2026 12:15
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (blocking): the chip is replaced by a different block when streaming ends

Outcome: fixed in c0f6811.
MarkdownRenderer no longer swaps components for an unclosed diff. It renders FoldableDiffBlock in both states and passes a warning prop once the fence is known to be unclosed. With the prop set, the chip stays mounted, opens itself and shows the warning above it, so the user sees the chip they were watching expand. They can still fold it again. The streaming test now holds the chip element from the streaming render and asserts that the finalized render has the same element with aria-expanded="true".
The warning line also gained an alert icon and medium weight, which answers the contrast watch item.
The screenshot in the PR body is new, taken in a pod at this commit, and shows the shipped warning text "The formatting broke here, so the rest of the reply may appear inside this diff." No recording of a live stream is attached; the element-identity test is the evidence for the in-place open.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note: severity is rare, confusing when it happens

Outcome: addressed by the same fix as span a7168c960f08 in c0f6811. The open happens on the chip the user is already reading, so the moment it happens reads as that chip expanding.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

suggestion (non-blocking): the warning line is too faint on a light theme

Outcome: fixed in c0f6811. The line is now medium weight with an alert icon before the text, both in text-warn. The screenshot in the PR body is the light theme at this commit.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (blocking): the chip unmounts and a plain DiffBlock mounts in its place

Outcome: fixed in c0f6811. The unclosed branch now renders the same FoldableDiffBlock with a warning prop, so nothing unmounts. The test named in the finding was replaced by "opens the same chip in place when a streaming unclosed diff is finalized", which asserts the chip element is identical across the two renders.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

issue (blocking): the chip vanishes and new content appears in its spot

Outcome: fixed in c0f6811. The notes.md +4 chip stays where it was, turns to its open state with the chevron up, and the patch opens below it. The warning appears above the chip. The new screenshot in the PR body shows this state at the current head.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

suggestion (blocking): keep FoldableDiffBlock mounted and force it open, then attach a recording

Outcome: the fix is applied as suggested in c0f6811: the chip stays mounted, a warning prop opens it once and shows the note above it. No live-stream recording is attached. A component test holds the streaming chip element and asserts the finalized render reuses it with aria-expanded="true", which is the property a recording would show.

@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 Oct 9, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

thought (non-blocking): "diff" in the warning is developer vocabulary

Outcome: kept as shipped.
The warning sits directly above a chip labelled with a file name and a +4 line count, and the open patch below it shows red and green rows, so the thing it names is on screen next to it. The transcript already calls these blocks diffs in the chip's own accessible label. Swapping to "the change below" would need a new string in all 12 catalogs for a rare path, and "below" stops being true if the layout ever puts the note elsewhere.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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 MarkdownRenderer from this commit in a scratch page: the reply streams in with the diff folded, then the warning appears above the chip and the same chip opens in place. No code changed, so the head stays c0f6811.

@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Oct 9, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author
issue (non-blocking): the ```` ```{r} ```` exemption in `fixCodeFences` rides along

Outcome: fixed in 0fdcbdfa91 by reverting the alternative.

fixCodeFences in MarkdownRenderer.tsx is now byte-identical to main, so this PR no longer changes how markdown blocks split a glued closer. The ```{r} test in fixCodeFences.test.ts is removed. The rust,ignore, rust,no_run and js= tests stay, and they pass on main's rule. The description no longer claims a behaviour change there.

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

Copy link
Copy Markdown
Contributor Author

note: Frontend Tests (3) at 7be1735 is a timing flake in GuideLayer.test.tsx

The one failure is "pressing the highlighted control on the last step finishes the guide, as Done does": a waitFor with a 4000 ms timeout saw 1 progress write instead of 2. This PR does not touch src/guide. The full --shard=3/4 run passes locally on this head (701 files, 11661 tests), and so does the test alone under --coverage. I can't re-run the job from the fork, so I will push the same tree again at the next slot to get a fresh run.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 11, 2026
…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
@Pearcekieser
Pearcekieser force-pushed the fix/malformed-diff-fence branch from 7be1735 to 5760c45 Compare October 12, 2026 19:42
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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.

@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 12, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

thought (non-blocking): the widget-fence glued-close recovery rides along

Outcome: kept as shipped. The 'widget-fence' branch was added in 9ef7c44 to answer First Principles span 847920c87406 on head 5caee8b, which named a ```</mcwidget> glued closer inside a widget's code fence as the sibling case: with a strict close only, the widget's closing tag stays inside the code fence and the rest of the reply renders as widget source. Deleting the branch reopens that finding. Two rounds of this lane ask for opposite shapes here, so the PR keeps the one the earlier round asked for, and the branch is covered by its own test in useBlockAssembler.test.ts.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

thought (non-blocking): two glued-closer rules that disagree on ```"x", ```(a) and ```-1

Outcome: kept as shipped. This PR first used isGluedProse on both paths, and span 6336f7a22a00 on head 9ef7c44 flagged exactly that swap as unjustified, so 0fdcbdfa91 put fixCodeFences back byte-for-byte on main's rule. Swapping it again would undo that fix. The rules also guard different costs. A wrong close in parseBlocks ends a diff early and hides the patch lines after it, so it accepts only text that starts like prose. A wrong split in fixCodeFences moves one line out of a markdown code block, which main has shipped with. Merging them into one predicate is a behaviour change to markdown rendering that no report asks for, so it is left out of this fix.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

thought (non-blocking): no first-time reader has seen the warning sentence

Outcome: kept as shipped, same as span 31f1adec6836 on head 40dfa2f. The line sits inside the reply bubble directly above that reply's diff chip, so "the formatting" and "this diff" both point at the thing right below it. A reword means a new string in all 12 authored catalogs plus the regenerated en-XA for a path that shows only when a fence never closes, so it fits a later copy pass on the transcript strings better than this fix.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

thought (non-blocking): the recovered answer shows up as diff content

Outcome: kept as shipped, same as span 6560a1ae3874 on head 40dfa2f. When the fence never closes, nothing in the reply marks where the patch ends, so any split point is a guess, and a wrong guess hides real patch lines. Rendering the tail as patch context keeps every character visible, and the warning above the chip says why it is there.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

todo (non-blocking): the auto-open effect in FoldableDiffBlock.tsx can undo a fold the user chose

Outcome: deferred to a follow-up PR after this one merges. The finding is right: the effect keyed on [warning, foldKey] runs again on remount and on a language switch, because toggle removed the key and i18nT returns a new string, so a folded unclosed-diff chip opens again. The fix is the one suggested, keying on !!warning and recording "auto-opened once" per foldKey in a module-level set, with a remount test. The lane marks it non-blocking and readiness has passed on this head, so it goes in its own small PR rather than a push that resets every lane here. It only affects a chip that is already showing the unclosed-fence warning.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): Design asked whether ```<div> inside an HTML code fence would end the fence

Yes, for a three-backtick fence. A line inside that fence starting with three backticks and then < is read as a glued closer, because < is in PROSE_START. That character is there so ```</mcwidget> and ```<details> glued after a diff are recovered. Two limits keep it narrow. The closer must have at least as many backticks as the opener, so a snippet inside a four-backtick fence is never cut. And the line has to start with the backticks themselves, so <div> or `<div>` in ordinary HTML code is untouched. CommonMark would keep ```<div> as content, so this is a real trade: a code line that opens with three backticks and a tag, inside a three-backtick fence, closes early and its text still renders below. That is a narrower loss than the one this PR fixes, where everything after a glued closer vanished into the diff, so I left the rule as it is.

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

inside an HTML fence would close it; that line is itself malformed and rare, and the worst case is an early close that leaves the text visible. The Opus note that a user's fold of the warned chip reopens on remount is real but cosmetic, and the author has committed to a follow-up PR for it. Checks are green and the base is main, so this replaces our earlier change request. — crew-pr-reviewer (deep re-check)

@iamwhatever
iamwhatever enabled auto-merge (squash) October 12, 2026 23:54
@iamwhatever
iamwhatever merged commit 90dc149 into kirodotdev:main Oct 12, 2026
104 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat hides the rest of a reply when a closing diff fence is glued to prose

2 participants