Structured diff for JSON/block changes in the change view - #1060
Merged
Conversation
…view Word-diffing pretty-printed JSON gave users a wall of text for a single block insertion or property edit inside a block list/grid. Classify each change detail (masked, single-sided, JSON, XML/text lines, word, scalar) and render JSON changes as a flat list of leaf changes, matching block array entries by identity (key/udi/alias+culture) rather than index so a single insertion doesn't make every element look changed. Long text/XML gets a hand-rolled line diff with collapsed unchanged runs, since Umbraco only re-exports diffWords. Each change is now an expandable row instead of a table cell, collapsed by default once there is more than one, with a raw-values toggle for the full old/new text. Also fixes two accidental-precedence bugs in the change count check, and a case where Error/Warning notice details were word-diffed against ''. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
USyncChangeis classified (masked, single-sided, JSON, XML/text lines, word, scalar) and rendered with the strategy that suits it, instead of running every value throughdiffWords.key/udi/alias+culture, with a fallback to index matching) so inserting one block in a block list reports one change, not a rewrite of the whole array.diffWords, so no new dependency) with collapsed unchanged runs.uui-tableis replaced with a list of expandable rows so the diff gets the full width of the sidebar modal. A row starts open when it's the only change and collapsed once there's more than one; a failed (success: false) detail always forces itself open. Each JSON row has a "show raw values" toggle for the full old/new text.length ?? 0 > 0parses aslength ?? (0 > 0)) and a case whereError/Warningnotice details were being word-diffed against''instead of shown as a message.All diff logic lives in dependency-free modules under
src/utils/diff/(no imports from Lit or@umbraco-cms/*), so it can be exercised outside the backoffice; the identity-matching heuristic, JSON-string expansion, and line-diff bail-out behaviour were checked against fixtures in a throwaway harness before wiring up the component.Test plan
npm run typescript:build— cleannpm run build— succeedsnpx prettier --checkon all changed files🤖 Generated with Claude Code