Skip to content

testing(fix[diff]): Pair multi-row diffs and nested dict boxes - #151

Merged
tony merged 5 commits into
masterfrom
fix/146-vt-diff-pairing-and-dicts
Dec 5, 2026
Merged

tony merged 5 commits into
masterfrom
fix/146-vt-diff-pairing-and-dicts

Conversation

@tony

@tony tony commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #146

Summary

  • Pair changed box rows by viewport index in format_vt_diff_lines() with column-aligned carets (or ANSI-styled lines when color callbacks are supplied). Persist measured columns when the stored text is ambiguous.
  • Format styles: summaries as concise changed span deltas capped at three spans per side ((+N more)), including (none) transitions and span reorderings.
  • Skip synthetic row summaries and duplicate carets when diffing already-diffed vt_screen(..., diff=...) delta boxes.
  • Store nested Syrupy frames in sections keyed by their container paths, preserving dictionary key types. Label frame changes by path and use Syrupy's line diff for legacy containers and ordinary values.

Review affected serialized expectations and update them with pytest --snapshot-update.

Test plan

  • Multi-row box diff pairing, color callback styling, trailing row handling, styles: span deltas, and diff= box guards in test_format_vt_diff_lines_multirow_pairing_style_deltas_and_diff_guard
  • Typed key paths, measured columns, legacy fallback, and nested frame labels in the Syrupy adapter
  • ruff format --check ., ruff check ., ty check, pytest including doctests, and Sphinx HTML build with just -f docs/justfile sphinxopts="-W --keep-going" html

tony pushed a commit that referenced this pull request Dec 2, 2026
why: Diffing vt_screen(..., diff=...) snapshots treated inner caret
lines as screen rows, container section pairing ignored dict keys when
entries flipped from '(unchanged)', and header diffs shared the row
summary cap.

what:
- Skip inner rows and caret bars inside already-diffed VT boxes
- Pair .ambr container sections by key and prefix multi-box summaries
- Budget header, row, and styles summaries independently
- Match only r<N>[<C0>..<C1>]: spans in styles: and cite #151 in CHANGES
tony pushed a commit that referenced this pull request Dec 2, 2026
why: Keep libvt.testing decoupled from Syrupy's Amber container syntax
while pairing multi-row VT diffs, style span deltas, and .ambr container
blocks cleanly in their owning modules.

what:
- Pair multi-row box runs, style deltas, and diff= guards in testing.py
- Parse and pair .ambr container VT blocks in contrib/syrupy.py
- Update docs/topics/testing.md doctest and CHANGES (#151)
- Add multi-row, style-delta, diff=, and .ambr container diff tests
tony added a commit that referenced this pull request Dec 3, 2026
why: Record the branch's user-visible change in the unreleased notes.

what:
- Add the #151 entry under Breaking changes in CHANGES
- Add the #151 entry under Fixes in CHANGES
@tony
tony force-pushed the fix/146-vt-diff-pairing-and-dicts branch from c89daac to c148e5e Compare December 3, 2026 02:48
@tony
tony force-pushed the fix/146-vt-diff-pairing-and-dicts branch from c148e5e to eef35d1 Compare December 3, 2026 23:58
@tony
tony force-pushed the fix/146-vt-diff-pairing-and-dicts branch from eef35d1 to 7925df1 Compare December 5, 2026 11:56
tony added 5 commits December 5, 2026 07:53
why: A multi-row diff can list removals before insertions, leaving
     changed screen rows without column carets.

what:
- Pair adjacent box rows and render column-aligned carets
- Report style span changes and cover nested boxes
why: Diffing already rendered deltas must keep their summary and
     alignment intelligible.

what:
- Distinguish inner delta lines and labels from captured rows
- Track style, row and header summaries independently
why: Syrupy's extension owns Amber container syntax and can identify
     screens by key.

what:
- Pair core VT frames in testing and Amber containers in Syrupy
- Cover row, style, nested-container and delta comparisons
why: Snapshot diffs need captured display columns and unambiguous
     identities for screens inside containers.

what:
- Preserve ambiguous cell layouts with optional column metadata
- Validate complete frames and pair nested screens by typed key paths
- Use the Syrupy fallback for unsupported or ordinary values
- Cover frame, color and key ambiguity and document snapshot updates
why: Stored expectations can omit display columns or contain several
     keyed terminal frames.

what:
- Explain which goldens to refresh and how the diff pairs rows and
  styles.
@tony
tony force-pushed the fix/146-vt-diff-pairing-and-dicts branch from 7925df1 to 510e58d Compare December 5, 2026 13:54
@tony
tony changed the base branch from master to fix/148-pathlike-scrubbers December 5, 2026 13:54
@tony
tony changed the base branch from fix/148-pathlike-scrubbers to master December 5, 2026 14:00
@tony
tony merged commit 1c4b620 into master Dec 5, 2026
9 checks passed
@tony tony mentioned this pull request Dec 5, 2026
35 of 38 tasks
@tony
tony deleted the fix/146-vt-diff-pairing-and-dicts branch December 5, 2026 20:41

This branch was successfully deployed

1 active deployment
docs — 510e58d4 Deployed Dec 5, 2026 by tony via build (3.14) #459
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

format_vt_diff_lines mis-pairs rows and skips dict box diffs

1 participant