Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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/343-renderer-authors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
section: renderer-authors
---

- **`diff-changes` accepts changed entities listed in `data-entity-aliases`** (#343). The built-in check now passes a changed entity that has no element of its own when a visible entity element lists it in `data-entity-aliases`, matching how the SDK's hover, selection and filter already treat aliases. `EntitySample` adds an optional `aliases` field.
5 changes: 5 additions & 0 deletions changelog.d/343.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
section: renderers
---

- **Dependency graphs fold transitive churn into direct dependencies** (#343). Transitive packages that only change with a direct dependency that changes (arrives, leaves or moves to another version), or that only move to another version themselves, now fold into the summary card of the package that pulls them in. The owning card presents them so the host still finds them there. A webpack-to-Rspack migration used to draw about 150 transitive packages and push the workspace and its eight direct changes out of the image. It now draws the workspace, those eight changes and their summary cards, and so does a pull request that also refreshes the lockfile. A transitive package new to the dependency tree, or gone from it, under an unchanged dependency still shows. The `npm-bundler-migration` and `npm-mass-removal` scenarios show both cases.
4 changes: 4 additions & 0 deletions docs/builtins/extractors/workspace-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ a single modified package rather than a removal and an addition.

Unchanged transitive dependencies collapse into summary cards ("12 more
packages") to keep the diff focused; toggle **All packages** to expand them.
Transitive packages that only change with a direct dependency that changes, or
that only move to another version, fold the same way, into the card of the
package that pulls them in. A bundler migration, a major upgrade or a removed
workspace member then leads with its direct changes.

## Start from this definition

Expand Down
10 changes: 10 additions & 0 deletions docs/builtins/renderers/graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ what explains a change and summarizes the rest:
- **Always visible.** Roots, their direct dependencies, every changed package,
both ends of every changed dependency, and the shortest path from a root to
each of them stay expanded.
- **Churn folded.** A changed transitive package folds into the summary card of
the package that pulls it in when it only changes with a direct dependency
that changes (arrives, leaves or moves to another version), or when it only
moves to another version itself (a bump, or npm installing it under another
key). The card counts it in each revision and presents it, so selecting or
finding the package lands there. Replacing webpack with Rspack then reads as
eight direct dependency changes rather than 150 transitive packages, even
across a pull request that also refreshes the lockfile. A transitive package
new to the dependency tree, or gone from it, under an unchanged dependency
stays visible.
- **Collapsed subtrees.** Remaining packages group under the first visible
package that pulls them in as a single summary card ("12 more packages").
Selecting it expands that package by one level and turns the card into
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; Terraform modules: one NAT gateway per availability zone; 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); 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; Terraform modules: one NAT gateway per availability zone; Bicep: a private endpoint subnet; Terraform: one revision's plan; React 19.2 and clsx; Express 5 and React 19; webpack to Rspack; A workspace member removed; 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
7 changes: 1 addition & 6 deletions eslint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2064,7 +2064,7 @@
},
"packages/renderers/graph/src/dependencies/collapse.ts": {
"@typescript-eslint/no-non-null-assertion": {
"count": 6
"count": 3
}
},
"packages/renderers/graph/src/dependencies/facts.ts": {
Expand All @@ -2082,11 +2082,6 @@
"count": 1
}
},
"packages/renderers/graph/src/dependencies/model.ts": {
"@typescript-eslint/no-non-null-assertion": {
"count": 1
}
},
"packages/renderers/graph/src/dependencies/paths.ts": {
"@typescript-eslint/no-non-null-assertion": {
"count": 4
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/browser/viewer-documents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ test('a saved comparison plays, selects and discloses its details as a live one
// a reader would.
await page.getByRole('radiogroup', {name: 'Scope'}).getByRole('radio', {name: /^All/u}).click()
await expect(page.getByRole('radiogroup', {name: 'Scope'}).getByRole('radio', {name: /^All/u})).toBeChecked()
const summary = frame.locator('[data-graph-synthetic^="transitive:"]').first()
await expect(summary).toHaveAttribute('aria-expanded', 'false', {timeout: 15_000})
const first = frame.locator('[data-graph-synthetic^="transitive:"]').first()
await expect(first).toHaveAttribute('aria-expanded', 'false', {timeout: 15_000})
// Pinned by its ID: the packages it reveals bring summaries of their own, which may come before it.
const summary = frame.locator(`[data-graph-synthetic="${await first.getAttribute('data-graph-synthetic')}"]`)
const packages = frame.locator('[data-entity-id^="package:"]')
const shown = await packages.count()
await summary.click()
Expand Down
16 changes: 13 additions & 3 deletions packages/renderers/graph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,17 @@ the structure that explains a change and summarizes the rest:
- **Always shown:** the roots, every package they depend on directly, every
changed package, both ends of every changed relationship, and the shortest
path from a root that pulls each of them in (breadth-first in ID order, so the
same documents always present the same graph).
same documents always present the same graph). The exception is transitive
churn (`churn.ts`): a changed package that, in each revision it's in, is
reachable only through changed direct dependencies, or that only moved to
another version (a version bump, or npm installing it under another key while
a package of its name is in the other revision). It is summarized like an
unchanged package, counted per revision on the card of the shown package that
pulls it in there, and that card presents it (`data-entity-aliases`). A
migration such as webpack to Rspack, even across a pull request that also
refreshes the lockfile, reads as its direct changes. A summary card whose
count differs between revisions is marked modified, and steps referencing
folded packages map to their owners' summary cards.
- **Summarized:** every other package belongs to the first shown package that
pulls it in, nearest the roots first, and that package gets one summary card
("12 more packages"). Selecting a summary expands its owner by one level, and
Expand All @@ -175,8 +185,8 @@ the structure that explains a change and summarizes the rest:
open again with it. The host-drawn **All packages** toggle shows everything
(up to the canvas's entity limit) and no collapse cards. Summaries are
presentation only: they carry `data-graph-synthetic`, never a selection ID,
and arrive and leave in the step of the package that owns them, so they never
look changed at either endpoint.
and arrive and leave in the step of the package that owns them, so they look
changed at either endpoint only when folded churn changes their count.
- **Edges:** a shared package (`debug`, required by five others) would pull an
edge from each of its dependents across the graph, so each shown package keeps
the edge from the package that first pulls it in (its primary path,
Expand Down
14 changes: 9 additions & 5 deletions packages/renderers/graph/browser/dependencies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ test('the "All packages" control shows every transitive package', async ({page})
await expect(renderer.frame.locator('[data-graph-synthetic]')).toHaveCount(0)
})

test('every change is shown with the path that pulls it in, and version bumps read as upgrades', async ({page}) => {
test('direct changes are cards, the packages they bring are on their cards, and version bumps read as upgrades', async ({page}) => {
const renderer = await openRenderer(page, {renderer: 'dependencies', before, after, progress: 0})
const frame = renderer.frame
// body-parser is transitive but changed: it and express, which pulls it in, are cards.
for (const id of ['package:express', 'package:body-parser', 'package:lodash', 'package:react']) {
for (const id of ['package:express', 'package:lodash', 'package:react']) {
await expect(frame.locator(`[data-entity-id="${id}"]`)).toHaveCount(1)
}
// body-parser is transitive and moves with Express 5: express's card presents it.
await expect(frame.locator('[data-entity-id="package:body-parser"]')).toHaveCount(0)
await expect(frame.locator('[data-entity-id="package:express"]')).toHaveAttribute('data-entity-aliases', /package:body-parser/u)
await renderer.seek(1)
await expect(frame.locator('[data-entity-id="package:zod"]')).toHaveCount(1)
await expect(frame.locator('[data-entity-id="package:lodash"]')).toHaveCount(0)
Expand Down Expand Up @@ -189,15 +191,17 @@ test('a shared package keeps the edge that pulls it in and counts its other depe
const renderer = await openRenderer(page, {renderer: 'dependencies', before, after, comparisonMode: 'diff'})
const frame = renderer.frame
const edgesInto = (id: string) => frame.locator(`.graph-link[data-to="${id}"]`).count()
// Express 5's packages fold into its card; with every package shown,
// debug is pulled in by express first, and also used by body-parser, send and finalhandler: one edge, and a count.
await renderer.setOptions({transitive: true})
const debug = frame.locator('[data-entity-id="package:debug"]')
await expect(debug.locator('.node-kind')).toContainText(/\+\d+ dependents?/u)
const primary = await edgesInto('package:debug')
// Every dependency draws them all again.
await renderer.setOptions({paths: true})
await renderer.setOptions({transitive: true, paths: true})
await expect(debug.locator('.node-kind')).not.toContainText('dependent')
await expect.poll(() => edgesInto('package:debug')).toBeGreaterThan(primary)
await renderer.setOptions({paths: false})
await renderer.setOptions({transitive: true, paths: false})
await expect.poll(() => edgesInto('package:debug')).toBe(primary)
// Selected, its dependents and dependencies come forward, drawn edge or not; everything else recedes.
await renderer.select('package:debug')
Expand Down
Loading
Loading