Skip to content

Kit: fold mass removals into one summary card - #396

Open
agorischek wants to merge 10 commits into
mainfrom
kit/fold-mass-removals
Open

agorischek wants to merge 10 commits into
mainfrom
kit/fold-mass-removals

Conversation

@agorischek

Copy link
Copy Markdown
Collaborator

What changed

A comparison that removes a whole schema, package set or job list used to draw every removed item as its own card. On one Next.js app, 48 removed tables made a database frame 1862 × 81,546 px, over rendererLimits.maxHeight (20,000), so the PNG failed. On a monorepo's workspace dependencies the image was a wall of red. Refs #343.

The renderer kit now folds mass changes in its shared primitives, so the graph canvas and the card grid fold them for every renderer built on them, with no per-renderer code.

  • Graph canvas: one card for a mass removal. When a dozen or more sibling cards are removed together (massFoldMinimum, 12), GraphCanvas draws one card in the removed style, labelled with the plural of the definition's noun: "48 tables removed". Siblings are items of one kind with the same status in the same container (or at the top level). The parts they contain fold with them, and their relationships to items that stay are drawn once from the card for each other end, kind and direction. The card and its links take the first step that changes what they stand for. Mass additions fold the same way ("14 tables added").
  • Expandable, like Fold. Activating the card (or one of its links) opens the items in place. The card stays, labelled "Hide 48 removed tables", as the way to fold them again, until the document changes.
  • Selection, focus and --entity. Following Dependency graphs lead with direct changes: churn folds into the dependency it came with #343's data-entity-aliases pattern, the card keeps an ID of its own (pk-mass:…) and lists everything it stands for in data-entity-aliases, so the host's selection, hover, filter and annotations of a folded item find it. The canvas moves a selection, a focus request (--entity) or a focus of a folded item onto the card, and the shell's opening reveal finds an item on the fold that presents it. The card is its own action (data-projections-action): activating it opens the fold and reports no selection.
  • Card grid: the same fold, and bands for unchanged runs. CardGrid folds a dozen or more of its EntityCards removed (or added) together, of one kind, into one card in their style ("14 jobs removed"). It also folds a run of a dozen or more unchanged cards with nothing between them into a full-width Fold band ("14 unchanged services") that opens in place. The Changes scope shows its unchanged cards as context, so no bands are drawn under it. A single revision folds nothing. Each card reports its status and kind from its change row, and keeps its place in the grid, hidden, while a fold takes it, so runs stay correct as folds open and close. Fold takes an id and the IDs it presents for a fold that stands for selectable items.
  • Design principles. The fold's container stays neutral, so accent colours never nest. Neighbouring cards share single borders. Fold labels use pk-label. A diff doesn't strike a fold's count the way it strikes a removed name, because "removed" is already in words.
  • Checks. This carries Dependency graphs lead with direct changes: churn folds into the dependency it came with #343's alias support in diff-changes, diff-neutral and highlight-scope verbatim, so the two merge cleanly. The selection round trip now passes by an entity element that is its own action (data-projections-action), using a new selectable probe measurement.

Why 12. It is twice a sibling block's blockMinimum (6): two full lines of a block's tray, past which more cards add height without saying more than their count. It is also about where a stack of removed tables alone outgrows a frame: the 48-table frame works out to about 1,700 px a table, so a dozen pass the 20,000 px limit.

Not covered. The database renderer lays out its own schema canvas, not GraphCanvas or CardGrid, so this change doesn't fold its tables and doesn't by itself fix the 81,546 px frame. foldMassChanges is exported from the kit for it. I'd suggest that as a follow-up rather than patching the renderer here.

Before and after

graph/mass-removal, a new scenario: a reporting service retires with the 16 reports it ran, and an analytics service arrives. Diff mode, desktop.

Before (main):

Before: 16 removed report cards in a tray between the reporting service and postgres

After:

After: one "16 reports removed" card in the removed style, linked once from reporting and once to postgres

The card grid folds 14 removed jobs into one card, and a run of 14 unchanged jobs into a band:

A card grid with build, test and one "14 jobs removed" card in the removed style

A card grid with a full-width "14 unchanged jobs" band above the added deploy job

Evidence

  • npm run tools -- check --fast: pass. This covers lint, typecheck, format (oxfmt), Considered size and complexity limits, and repository rules.

  • npm run tools -- test packages/renderers/kit: 206 pass, plus the new mass-fold.test.mjs (6 cases: folding in a container, aliases, step placement both ways, open folds, threshold, additions, and nouns).

  • npm run tools -- test packages/renderers/testing: 29 pass (including Dependency graphs lead with direct changes: churn folds into the dependency it came with #343's alias test). npm run tools -- test packages/renderers/graph: 50 pass.

  • Browser, Chromium desktop, through the harness config (npx playwright test -c packages/renderers/harness/playwright.config.ts --project chromium-desktop):

    • graph.spec.ts "16 reports removed together fold into one card…" passes. It covers the card's label and aliases, host selection and hover ringing the card, opening and closing it with no selection reported, in animated and diff modes, and focus: {id} on a folded report.
    • The scrub suite on the new massRemoval pair (1% steps both ways, plus 0.5% through the first window) passes with no overlaps, detached arrows or framing changes, and the endpoints show their revisions. The suite now counts items a card presents in data-entity-aliases. file reflow and wide fan-out still pass.
    • card-grid.spec.ts (3 cases: the removed fold in diff and transition modes, and the unchanged band in and out of the Changes scope) passes.
    • The built-in renderer checks for graph/mass-removal (checks.spec.ts, run locally on Chromium, since the sharding gives it the WebKit project) pass.
  • Starter renderer (packages/cli, scaffolded, installed and built): starter.spec.ts passes the built-in checks for the new catalog and existing split scenarios and the new band test. starter-repository.spec.ts passes with three scenarios.

  • I checked the frames in the renderer gallery at desktop width in diff mode, with the fold both closed and open. I didn't run WebKit, the phone projects or the full harness suite locally.

  • Documentation that this change affects is updated, and generated reference
    pages are regenerated (npm run docs:generate). The renderer kit graph and components guides and the testing README describe the folds and the check changes. No generated pages are affected.

  • Fixes include a regression test.

  • A changelog fragment at changelog.d/<this PR's number>.md describes what
    users will notice, or the PR has the no changelog label (see
    changelog.d/README.md).

  • No credentials, private source or machine-specific paths are included.

agorischek and others added 7 commits December 4, 2026 22:00
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…gress)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
… folds

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@agorischek
agorischek requested a balanced review from Copilot December 4, 2026 22:01
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Grid folds can hide changed relationships inside otherwise unchanged cards; remapping folded relationship endpoints can discard a valid revision; and summaries that inherit the leading card’s timing can leave members scheduled for earlier steps invisible. These issues conceal meaningful changes in the rendered diff.

5 open issues
What changed in this PR

Adds shared folding to the renderer kit so large comparisons remain readable without per-renderer changes. The database renderer’s custom canvas remains a follow-up.

Changes:

  • Folds mass additions/removals into expandable cards and unchanged grid runs into bands.
  • Adds alias-aware selection, focus and renderer checks.
  • Adds scenarios, regression coverage, documentation and changelog entries.
File Description
packages/​renderers/​testing/​test/​helpers.test.mjs Tests alias-aware comparison checks.
packages/​renderers/​testing/​src/​types.ts Adds aliases and selectable probe types.
packages/​renderers/​testing/​src/​probe.ts Registers selectable probing.
packages/​renderers/​testing/​src/​measure/​entities.ts Measures aliases and selectable entities.
packages/​renderers/​testing/​src/​checks/​interaction.ts Excludes fold actions from selection checks.
packages/​renderers/​testing/​src/​checks/​comparison/​steps.ts Accepts alias-based emphasis.
packages/​renderers/​testing/​src/​checks/​comparison/​diff.ts Recognizes changes presented through aliases.
packages/​renderers/​testing/​src/​checks/​catalog.ts Updates check descriptions.
packages/​renderers/​testing/​README.md Documents alias-aware checks.
packages/​renderers/​kit/​test/​mass-fold.test.mjs Tests folding models and schedules.
packages/​renderers/​kit/​styles/​layout.css Styles summary cards and grid bands.
packages/​renderers/​kit/​styles/​diff.css Prevents striking fold counts.
packages/​renderers/​kit/​src/​summary.ts Resolves kind-specific nouns.
packages/​renderers/​kit/​src/​react/​shell/​kit-renderer.tsx Provides nouns to kit components.
packages/​renderers/​kit/​src/​react/​shell/​focus.ts Reveals items through fold aliases.
packages/​renderers/​kit/​src/​react/​layout-components.tsx Integrates folding into card grids.
packages/​renderers/​kit/​src/​react/​kind-nouns.ts Adds noun context and hook.
packages/​renderers/​kit/​src/​react/​grid-folds.tsx Implements grid folding and controls.
packages/​renderers/​kit/​src/​react/​graph-canvas/​mass-folds.ts Adapts graph props for folds.
packages/​renderers/​kit/​src/​react/​graph-canvas/​entity-card.tsx Makes summary cards expandable.
packages/​renderers/​kit/​src/​react/​graph-canvas/​canvas.tsx Applies folding before graph layout.
packages/​renderers/​kit/​src/​react/​fold.tsx Adds fold identity and aliases.
packages/​renderers/​kit/​src/​mass-fold/​model.ts Defines fold types, threshold and labels.
packages/​renderers/​kit/​src/​mass-fold/​links.ts Consolidates folded relationships.
packages/​renderers/​kit/​src/​mass-fold/​groups.ts Groups siblings and creates summaries.
packages/​renderers/​kit/​src/​mass-fold.ts Transforms models and step schedules.
packages/​renderers/​kit/​src/​index.ts Exports mass-fold APIs.
packages/​renderers/​kit/​browser/​suite.ts Counts presented items during scrubbing.
packages/​renderers/​kit/​browser/​invariants/​frame.ts Measures card aliases.
packages/​renderers/​kit/​browser/​fixtures.ts Adds mass-removal fixture.
packages/​renderers/​kit/​browser/​card-grid.spec.ts Tests grid folds and expansion.
packages/​renderers/​kit/​browser/​card-grid-page.ts Provides grid browser-test fixture.
packages/​renderers/​graph/​scenarios.json Registers mass-removal scenario.
packages/​renderers/​graph/​fixtures/​mass-removal-before.json Defines reports before removal.
packages/​renderers/​graph/​fixtures/​mass-removal-after.json Defines graph after removal.
packages/​renderers/​graph/​browser/​graph.spec.ts Tests graph folding and host interactions.
packages/​cli/​templates/​renderer/​scenarios.json Adds unchanged-service catalog scenario.
packages/​cli/​browser/​starter.spec.ts Tests starter grid bands.
packages/​cli/​browser/​starter-repository.spec.ts Updates expected scenario count.
docs/​guides/​renderer-kit-graphs.md Documents folding behavior and APIs.
docs/​guides/​renderer-kit-components.md Links card grids to folding guidance.
changelog.d/​396.md Announces graph folding.
changelog.d/​396-renderer-authors.md Describes author-facing changes.
changelog.d/​396-kit.md Summarizes kit folding APIs.

Review effort: Balanced

Comment on lines +31 to +32
if (!touched.length) kept.push(row)
for (const {side, item} of touched) {
run = []
}
for (const entry of read.entries) {
if (entry?.status === 'unchanged') run.push(entry)
return (
<>
{fold.type === 'mass' ? (
<GridFoldCard fold={fold} onToggle={place.toggle} emphasis={emphasis} mark={mark} presence={presence} />
Comment on lines +60 to +61
const id = child.getAttribute(slotAttribute)
return [id === null ? null : {id, status: child.getAttribute(statusAttribute) ?? '', kind: child.getAttribute(kindAttribute) ?? ''}]
{...(fold.open ? {} : {[entityAliasesAttribute]: JSON.stringify(fold.members)})}
data-projections-unit=""
data-fold={fold.open ? 'open' : 'closed'}
data-projections-action=""
…s and timing

Siblings with no container fold only when they share their neighbours, so a
dependency graph's scattered removals stay apart. A relationship rewired from a
folded item keeps the revision that still has both ends. A card grid keeps the
cards a fold takes, hidden, with their parts, so a fold presents those too; it
leaves an unchanged card whose relationships change out of its bands, and takes
its presence and emphasis from all its cards. A click anywhere in an element
that is its own action selects nothing. Regenerated the reference pages.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

2 participants