Repository navigation
fix(chat): keep a folded unclosed-diff chip folded - #19767
Conversation
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that a [DESIGN-REVIEWED] 5b69ce4 Description read[DESCRIPTION-READ] d65061b71a3138c6c8e4c152304ed69aff764b6b933ab059c3aebed6d870c977 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 |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (3 items) — 3 justifiedIntent: once a user folds a diff chip that the unclosed-fence warning opened, it stays folded. This is a FIX (#19766).
[FIRST-PRINCIPLES-REVIEWED] 5b69ce4 Description read[DESCRIPTION-READ] 321918ddb24c5ea1bd976a1c932fee9c0d68d650dd254752e2fb95010d0ed1f6 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. [UX-REVIEWED] 5b69ce4 Description read[DESCRIPTION-READ] 9a0a3c55a98e84fc29c005913f6ab3b9247e473a0215d513e0c49249b227e164 That sha256 names everything this verdict read: the PR description, plus the 3 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 |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
|
note (non-blocking): UX asked whether a fold should survive a page reload Yes, the reload behaviour is intended. |
572bffa to
5b69ce4
Compare
|
note: rebased on main, no behaviour change. Head 5b69ce4 is 572bffa rebased onto origin/main 7d33789 to refresh the green age. The rebase applied cleanly, and the two changed files are untouched by main. FoldableDiffBlock, MarkdownRendererCoverage and MarkdownRenderer.domGolden tests pass, 72 tests, and tsc -p tsconfig.app.json is clean. |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: FoldableDiffBlock remembers which warned fences already auto-opened, so a re-mount or a warning-language change no longer re-opens a chip the user folded, with tests.
Problem / Motivation
Goal: A diff chip the user folds under the unclosed-fence warning stays folded.
Since #18405, a finished reply whose code fence never closed shows its diff chip open under a warning. Folding that chip did not stick. A re-mount of the reply, or a switch of the UI language, opened it again.
Why it matters
The chip is only auto-opened so the swallowed text is visible. Once the user has read it and folded it, re-opening it on every re-mount undoes their choice and pushes the rest of the reply down again.
Not a goal
foldKey; they remember nothing across a re-mount today.What changed (motivation → approach → change)
The symptom came from the auto-open effect in
FoldableDiffBlock. It ran on every mount, and its dependency was the warning string, which a language switch replaces with a new translated value. Each run calledsetExpanded(true).FoldableDiffBlocknow records each warned fence it has auto-opened in a module-levelautoOpenedDiffFencesset, keyed byfoldKey, next to the existingexpandedDiffFences. The effect returns early for a fence already in that set, and it depends on!!warninginstead of the warning text.resetExpandedDiffFences()clears both sets.Backwards compatibility
Compatible: the first auto-open is unchanged, and the only difference is that a later re-mount or language switch no longer re-opens a chip.
Removes nothing: no key, prop, export or stored data is removed or renamed.
Tests
website/src/test/FoldableDiffBlock.test.tsxgains two tests. A folded warned chip stays folded after unmount and re-render with the samefoldKey, and it stays folded when thewarningtext changes. Both fail on main's component and pass with the change.FoldableDiffBlock.test.tsx,MarkdownRendererCoverage.test.tsxandMarkdownRenderer.domGolden.test.tsxpass, 72 tests.tsc -p tsconfig.app.jsonis clean.Manual verification
N/A. The change is in fold state only, and both re-open paths are covered by the new tests.
Screenshots / video
Why no screenshot: the chip, warning and folded state render exactly as on main; only whether a fold survives a re-mount changes, which a still image cannot show.
Related Issues
Fixes #19766
Pattern harvest
Rule candidate: review-prompt
Pattern: an effect that applies a one-time default to user-changeable state keys on a value with new identity each render, such as translated text, instead of on whether the trigger exists.
I searched
website/src/componentsfor otheruseEffectblocks that callsetExpanded(true)orsetOpen(true). The only other one, inAgentImportFlow.tsx, already fires on a false-to-true edge of a boolean prop, soFoldableDiffBlockwas the only one keyed on a translated string.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.