Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog.d/396-kit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
section: kit
---

- **The renderer kit folds mass changes in `GraphCanvas` and `CardGrid`** (#396). `GraphCanvas` folds a dozen or more sibling cards (`massFoldMinimum`) removed or added together into one card that presents them in `data-entity-aliases` and opens in place. `CardGrid` folds its `EntityCard`s the same way, and folds a run of a dozen or more unchanged cards into a full-width `Fold` band ("14 unchanged services") outside the Changes scope. `foldMassChanges` folds a `ComparisonModel` for a renderer with its own layout, and `Fold` takes an `id` and the IDs it `presents`. See [the graph canvas guide](docs/guides/renderer-kit-graphs.md).
5 changes: 5 additions & 0 deletions changelog.d/396-renderer-authors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
section: renderer-authors
---

- **`CardGrid` folds runs of cards in comparisons** (#396). A custom renderer's `CardGrid` now folds a dozen or more `EntityCard`s removed (or added) together, of one kind, into one card, and in the All scope folds a run of a dozen or more unchanged ones into a band; each opens in place. It reads each card's status and kind from the `change` row you pass, and folds nothing for a single revision. The `diff-changes`, `diff-neutral` and `highlight-scope` checks accept a change drawn on a card that lists it in `data-entity-aliases`, and the selection round trip passes by an entity element marked `data-projections-action`, as a fold's card is.
5 changes: 5 additions & 0 deletions changelog.d/396.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
section: renderers
---

- **Graph renderers fold a dozen or more cards removed together into one card** (#396). A comparison that removes a whole set of siblings (tables in a schema, reports a service ran, packages a workspace dropped) used to draw every removed card, which could make a frame too tall to render as an image. The graph, DAG, architecture, infrastructure and dependency graphs now draw one card in the removed style, such as "48 tables removed", worded with the definition's noun, with each relationship to what stays drawn once from it. Activating the card opens its cards in place. The host's selection, hover, filter and focus (`--entity`) of a folded item find the card. Additions of a dozen or more fold the same way.
2 changes: 1 addition & 1 deletion docs/guides/renderer-kit-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ accept token scale steps rather than raw lengths or colors—this is how
inset, so it lines up with the title. Tables stay unpadded, so their rows run
edge to edge.
- `CardGrid` lays cards out in as many columns as fit, collapsing to one column
on phones.
on phones, folding [mass changes](renderer-kit-graphs.md).
- `EntityCard` renders a single entity as a ring unit with `data-entity-id`, a
select button, `label`, `identifier`, `children`, and worded change status. In
progress modes, its leading edge picks up the change hue as `emphasis` rises
Expand Down
24 changes: 24 additions & 0 deletions docs/guides/renderer-kit-graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,30 @@ subgraphs share layers, and cards within a layer align along the edge where
their incoming relationships arrive (top or left) so each layer forms a clean
baseline.

**Mass changes.** In a comparison, a dozen or more sibling cards
(`massFoldMinimum`, twice `blockMinimum`) removed together fold into one card
(`foldMassChanges`): cards of one kind with the same status in the same
container, or at the top level, whose container stays. The card takes their kind
and status, so it is drawn in the removed style, and counts them with the
definition's noun (`presentation.kinds.<kind>.noun`, else the renderer's
`nouns`, else the host's words): "48 tables removed". It stands for the cards,
the parts they contain and their relationships: a relationship to a card that
stays is drawn once from the fold for each other end, kind and direction, and
the fold and its links join the first step that changes any of them. Additions
fold the same way. The card keeps a `data-entity-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, focus request (`--entity`) or `focus` of a folded item onto
the card. Activating the card, or one of its links, opens its cards in place;
the card stays, labeled "Hide 48 removed tables", as the way to fold them again,
until the document changes. `CardGrid` folds its `EntityCard`s the same way, and
folds a run of a dozen or more unchanged cards with nothing between them into a
`Fold` band across the grid ("14 unchanged services"), except under the Changes
scope, which shows its unchanged cards as context. A grid reads each card's
status and kind from its `change` row, and a card a fold takes keeps its place,
hidden. A single revision folds nothing. `Fold` takes an `id` and the IDs it
`presents` for a fold the host can find its items on.

**Sibling blocks.** When six or more cards (`blockMinimum`) share every
relationship, they wrap into a block instead of stretching their layer into one
long row. Sharing every relationship means having the same sources and targets,
Expand Down
139 changes: 135 additions & 4 deletions docs/reference/renderer-kit.md
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,30 @@ A list with every run of items `shown` leaves out folded into one entry, keyed b
names is listed after its fold, `open`. A run of one item stays, as its fold would take as much room. Every item is shown when `shown` is
undefined. Fold the union of a comparison (or each pane's list in the union's order) so both revisions fold alike.

### `foldMassChanges`

```ts
foldMassChanges<X extends Extraction>(model: ComparisonModel<X>, options?: MassFoldOptions): MassFolded<X>
```

Folds every run of `minimum` or more sibling items removed together, or added together, into one card: items of
one kind with the same status in the same container (or at the top level, outside any) when the container itself
stays. The card takes their kind and status, so it is drawn in the removed (or added) style, and counts them with the
definition's noun (`48 tables removed`). It stands for the items, the parts they contain and the relationships among
them; a relationship from one of them to an item that stays is drawn once from the card, for each item, kind and
direction. Steps place the card and its links in the first step that changes what they stand for. A fold in `open`
draws its items, and its card stays, labeled `Hide 48 removed tables`, as the way to fold them again. A model with no
such run is returned as it is.

### `foldMassSteps`

```ts
foldMassSteps<S extends PresentedStep>(steps: Array<S>, folding: Pick<MassFolded<Extraction>, "folded" | "folds" | "stands">): Array<S>
```

Steps (a model's, or a schedule) with a fold's cards and links in place of what they stand for: each in the first
step that changes any of it, and in no other. A step left with nothing keeps its place, so timing doesn't move.

### `foldPrefix`

```ts
Expand Down Expand Up @@ -1990,6 +2014,14 @@ isKind(change: EntityChange<Entity>, ...kinds: Array<string>): false | true

Whether either version of the row has one of `kinds`, so a row that changed kind matches both.

### `isMassFold`

```ts
isMassFold(id: string): false | true
```

Whether an item is a card or link `foldMassChanges` adds.

### `isSortable`

```ts
Expand Down Expand Up @@ -2044,6 +2076,15 @@ kindNote(kind: KindLineText | undefined, inferred: false | true): string

The note after a kind line (the renderer's, then `Inferred`), or nothing.

### `kindNoun`

```ts
kindNoun(kind: string, kinds?: Record<string, RendererKind> | undefined, nouns?: Readonly<Record<string, SummaryKindCount | SummaryNoun | false>> | undefined | { (kind: string, collection: "entities" | "relationships"): SummaryKindCount | SummaryNoun | false | undefined }): SummaryNoun
```

A kind's words, as the summary bar words its count: the definition's noun (`presentation.kinds.<kind>.noun`), else
the renderer's (`SummaryNouns`), else the host's (`humanizeKind`).

### `kindText`

```ts
Expand Down Expand Up @@ -2216,6 +2257,89 @@ lineSpline(from: Point, to: Point): Spline

A straight segment as one cubic, so every route is a uniform chain.

### `MassFold`

```ts
interface MassFold
```

One fold of sibling items removed or added together.

| Member | Signature | Description |
|---|---|---|
| `id` | `"id": string` | The fold card's row ID (`massFoldPrefix`). |
| `items` | `"items": Array<string>` | The sibling entity rows it folds, in the model's order. |
| `kind` | `"kind": string` | The folded items' kind, which the card takes. |
| `label` | `"label": string` | The card's label: `48 tables removed`, or open, `Hide 48 removed tables`. |
| `open` | `"open": false \| true` | Whether it is open: its items drawn on their own, and the card the way to fold them again. |
| `presents` | `"presents": Array<string>` | Every row the card presents while closed: the siblings, the parts they contain and the relationships among them or to them, for the card's `data-entity-aliases`. |
| `status` | `"status": MassStatus` | Whether its items were removed or added: the card's status, and so its style. |

### `MassFolded`

```ts
interface MassFolded<X extends Extraction = Extraction>
```

A model with its mass changes folded (`foldMassChanges`), and what each fold stands for.

| Member | Signature | Description |
|---|---|---|
| `folded` | `"folded": ReadonlyMap<string, string>` | Each row a closed fold hides (entity or relationship), and the card or link drawn for it. |
| `folds` | `"folds": ReadonlyMap<string, MassFold>` | Each fold, by its card's ID; empty when nothing folds (and `model` is the one passed). |
| `model` | `"model": ComparisonModel<X>` | The model with each fold's card and links in place of what they stand for, steps included. |
| `stands` | `"stands": ReadonlyMap<string, Array<string>>` | Each card and link a fold adds, and the rows it stands for: their step and emphasis are its. |

### `massFoldLabel`

```ts
massFoldLabel(count: number, status: MassStatus, noun: SummaryNoun, open?: false | true, locale?: string): string
```

A fold's card label: `48 tables removed`; open, `Hide 48 removed tables`.

### `massFoldMinimum`

```ts
massFoldMinimum: 12
```

The fewest sibling items removed (or added) together that fold into one card: twice a sibling block's
`blockMinimum`, two full lines of its tray, past which more cards add height without saying more than their count.
It is also where a stack of removed database tables alone outgrows a frame: on one schema, 48 removed tables drew a
frame 81,546 px tall, about 1,700 px a table, so a dozen pass the 20,000 px most hosts render.

### `MassFoldOptions`

```ts
interface MassFoldOptions
```

How `foldMassChanges` folds.

| Member | Signature | Description |
|---|---|---|
| `locale` | `"locale"?: string` | BCP 47 locale for the count (`en-US` by default). |
| `minimum` | `"minimum"?: number` | The fewest siblings that fold (`massFoldMinimum` by default). |
| `noun` | `"noun"?: { (kind: string): SummaryNoun \| undefined }` | A kind's words (the definition's noun); `humanizeKind` by default. |
| `open` | `"open"?: ReadonlySet<string>` | Folds the person opened, by card ID: their items are drawn, and the card stays as the way to fold them again. |

### `massFoldPrefix`

```ts
massFoldPrefix: "pk-mass:"
```

The ID prefix of the cards and links `foldMassChanges` adds.

### `MassStatus`

```ts
type MassStatus = "added" | "removed"
```

The statuses that fold: items that only one revision has.

### `maxZoom`

```ts
Expand Down Expand Up @@ -4047,7 +4171,10 @@ The corner radius a graph card's shape is drawn with, in card units, where the t
CardGrid(__0: { "children": ReactNode; "label"?: string }): Element
```

Cards in a responsive grid: as many columns as fit, one on a phone.
Cards in a responsive grid: as many columns as fit, one on a phone. In a comparison, a dozen or more of its
`EntityCard`s removed (or added) together, of one kind, fold into one card that counts them and opens in place
(`GridFoldCard`), and a run of a dozen or more unchanged ones folds into a band across the grid (`GridBand`), except
under the Changes scope.

### `CategoriesView`

Expand Down Expand Up @@ -4363,12 +4490,14 @@ labels ("Runs on"), use `Facts` and `Fact`.
### `Fold`

```ts
Fold(__0: { "as"?: ElementType; "className"?: string; "columns"?: number; "count": number; "noun": string; "onToggle": { (): void }; "open"?: false | true | undefined }): Element
Fold(__0: { "as"?: ElementType; "className"?: string; "columns"?: number; "count": number; "id"?: string | undefined; "noun": string; "onToggle": { (): void }; "open"?: false | true | undefined; "presents"?: Array<string> | undefined }): Element
```

A fold: "12 unchanged declarations", a button that opens the run in place; `open`, "Hide 12 unchanged declarations"
above the opened run, which folds it again. `as` sets its element (`div` by default, `tr` or `li` in tables and lists;
a `tr` puts the button in one cell spanning `columns`).
a `tr` puts the button in one cell spanning `columns`). Given an `id`, the fold is an item the host sees, and while
closed it presents the items it folds (`presents`, in `data-entity-aliases`), so the host's selection, hover and
filter of one find it.

### `GeneratedMark`

Expand Down Expand Up @@ -4423,7 +4552,9 @@ The staged graph canvas shared by the graph, DAG and architecture renderers:
ELK layouts per comparison step (laid out off the main thread before the
first paint), identity-stable cards, spline relationships that morph on the
same clock as their cards, stable framing across the whole transition, and
host-driven change emphasis.
host-driven change emphasis. A dozen or more sibling cards removed (or added)
together fold into one card that counts them and opens in place
(`foldMassChanges`).

### `graphCanvasControls`

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/renderers.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Built-in Projections graph renderer: staged, identity-stable graph transitions (
- Handles: `graph`, `graph-horizontal`, `dag`, `architecture`, `infrastructure`, `dependencies`
- Comparison modes: `diff`, `side-by-side`, `animated`, `swipe`
- Package: `@githubnext/projections-renderer-graph`
- Example scenarios ([`scenarios.json`](../../packages/renderers/graph/scenarios.json)): Service platform; Service platform, payments first (custom order); Test timings with volatile durations; Class summaries, generated by a model; Source references, left to right; Declared rename; Feature flags; Feature flags, one revision; Single extraction; CI pipeline restructure; Release workflow; Platform gains a worker; Storage module split; Single extraction; Card icons; OpenRewrite: JUnit 4 to JUnit 5; Terraform: the database is replaced; Bicep: a private endpoint subnet; Terraform: one revision's plan; React 19.2 and clsx; Express 5 and React 19; npm workspace (one revision); NuGet package update; NuGet library with long package names; A layered module graph; A layered module graph (one revision); A wide module graph; A wide module graph (one revision); A hub-heavy module graph (one revision); MCP tools, toolsets and OAuth scopes; An architecture of 42 components (one revision); Who may reach what: 6 callers, 16 owners, 74 relationships (graph); Who may reach what: 6 callers, 16 owners, 74 relationships (architecture)
- Example scenarios ([`scenarios.json`](../../packages/renderers/graph/scenarios.json)): Service platform; Service platform, payments first (custom order); Reporting retired, 16 reports with it; Test timings with volatile durations; Class summaries, generated by a model; Source references, left to right; Declared rename; Feature flags; Feature flags, one revision; Single extraction; CI pipeline restructure; Release workflow; Platform gains a worker; Storage module split; Single extraction; Card icons; OpenRewrite: JUnit 4 to JUnit 5; Terraform: the database is replaced; Bicep: a private endpoint subnet; Terraform: one revision's plan; React 19.2 and clsx; Express 5 and React 19; npm workspace (one revision); NuGet package update; NuGet library with long package names; A layered module graph; A layered module graph (one revision); A wide module graph; A wide module graph (one revision); A hub-heavy module graph (one revision); MCP tools, toolsets and OAuth scopes; An architecture of 42 components (one revision); Who may reach what: 6 callers, 16 owners, 74 relationships (graph); Who may reach what: 6 callers, 16 owners, 74 relationships (architecture)

## `runtime-policy`

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/browser/starter-repository.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test('the repository Inspector presents the renderer package scenarios beside th
await page.goto(harness.url)
// The Explorer's Compare section lists them as "Renderer scenarios", beside the Before → After pair.
const scenarios = page.getByRole('list', {name: 'Renderer scenarios'})
await expect(scenarios.getByRole('button')).toHaveCount(2)
await expect(scenarios.getByRole('button')).toHaveCount(3)
await expect(scenarios.getByRole('button', {name: /^Checkout splits out payments/u})).toHaveAttribute('aria-pressed', 'false')
await scenarios.getByRole('button', {name: /^Checkout splits out payments/u}).click()
await expect(scenarios.getByRole('button', {name: /^Checkout splits out payments/u})).toHaveAttribute('aria-pressed', 'true')
Expand Down
24 changes: 24 additions & 0 deletions packages/cli/browser/starter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,27 @@ test('the starter renderer lays out only what the Changes scope shows', async ({
await stage.filter({query: '', changesOnly: false, ids: null, scope: null})
await expect(card('service:orders')).toBeVisible()
})

test('the starter renderer folds a run of unchanged cards into a band in All, which opens in place', async ({page, inspector}) => {
const stage = await openStage(page, inspector, {
scenario: 'renderer/catalog',
comparisonMode: 'diff',
filter: {query: '', changesOnly: false, ids: null, scope: null},
})
const band = stage.frame.locator('.pk-grid-band')
await expect(band).toHaveCount(1)
await expect(band).toHaveText(/14 unchanged services/u)
await expect(stage.frame.locator('[data-entity-id="service:search"]')).toBeHidden()
await expect(stage.frame.locator('[data-entity-id="service:wallet"]')).toBeVisible()
// The host's selection of a folded service finds the band.
await stage.select('service:search')
await expect(band).toHaveAttribute('data-projections-ring-selected', /.*/u)
await stage.select(null)
await band.getByRole('button').click()
await expect(stage.frame.locator('[data-entity-id="service:search"]')).toBeVisible()
await expect(band).toHaveText(/Hide 14 unchanged services/u)
// The Changes scope shows only the changes and their context: nothing to fold.
await stage.filter({query: '', changesOnly: true, ids: null, scope: ['service:accounts', 'service:wallet', 'calls:accounts->wallet']})
await expect(stage.frame.locator('.pk-grid-band')).toHaveCount(0)
await expect(stage.frame.locator('[data-entity-id="service:wallet"]')).toBeVisible()
})
Loading
Loading