Skip to content

fix(chat): keep a folded unclosed-diff chip folded - #19767

Merged
KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:fix/diff-chip-refold
Oct 13, 2026
Merged

KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:fix/diff-chip-refold

Conversation

@Pearcekieser

@Pearcekieser Pearcekieser commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Changing when a chip is first auto-opened, or the warning text.
  • Remembering folds for chips without a 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 called setExpanded(true).

FoldableDiffBlock now records each warned fence it has auto-opened in a module-level autoOpenedDiffFences set, keyed by foldKey, next to the existing expandedDiffFences. The effect returns early for a fence already in that set, and it depends on !!warning instead 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.tsx gains two tests. A folded warned chip stays folded after unmount and re-render with the same foldKey, and it stays folded when the warning text changes. Both fail on main's component and pass with the change.
  • FoldableDiffBlock.test.tsx, MarkdownRendererCoverage.test.tsx and MarkdownRenderer.domGolden.test.tsx pass, 72 tests.
  • tsc -p tsconfig.app.json is 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/components for other useEffect blocks that call setExpanded(true) or setOpen(true). The only other one, in AgentImportFlow.tsx, already fires on a false-to-true edge of a boolean prop, so FoldableDiffBlock was the only one keyed on a translated string.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • 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.

@Pearcekieser
Pearcekieser requested review from a team and KiroCrewCaptain as code owners October 13, 2026 08:24
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 13, 2026
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 5b69ce430a15ee9a21ce78e3ed79d3140cdb87c1 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 a foldKey stays the same fence across load-earlier and variant switches, so the auto-open record cannot suppress a different fence's first open.

[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 .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 13, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 5b69ce430a15ee9a21ce78e3ed79d3140cdb87c1 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: PASS

Nothing to check.

What this change ships

Inventory (3 items) — 3 justified

Intent: once a user folds a diff chip that the unclosed-fence warning opened, it stays folded. This is a FIX (#19766).

  1. A folded warned chip stays folded when the reply re-mounts (a new autoOpenedDiffFences set keyed by foldKey). — justified
  2. A folded warned chip stays folded when the UI language changes (the effect now depends on !!warning, not on the warning text). — justified
  3. The test reset resetExpandedDiffFences() now clears the new set too. — justified

[FIRST-PRINCIPLES-REVIEWED] 5b69ce4

Description read

[DESCRIPTION-READ] 321918ddb24c5ea1bd976a1c932fee9c0d68d650dd254752e2fb95010d0ed1f6

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 13, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS

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

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 .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 13, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 5b69ce4

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

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

Review details

No findings.
[GPT-REVIEWED] 5b69ce4

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 13, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

note (non-blocking): UX asked whether a fold should survive a page reload

Yes, the reload behaviour is intended. autoOpenedDiffFences sits next to expandedDiffFences in FoldableDiffBlock.tsx, and both are module-level sets that live as long as the page does. On main, every chip's open or folded state already resets on reload, so after a reload a warned chip opens itself once again, the same as on first view. The goal of this PR is that the user's fold sticks across a re-mount or a language switch within one page load. Keeping folds across reloads would need persisted per-message state, which is new scope for this fix.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

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.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: passed Eligible automated validation passed for the current revision readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 13, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) October 13, 2026 11:04

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@KiroCrewCaptain
KiroCrewCaptain merged commit 2598f22 into kirodotdev:main Oct 13, 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.

Folded unclosed-diff chip re-opens on re-mount or language switch

2 participants