Skip to content

Graph renderer: wrap wide fan-outs into blocks, and lay out large graphs faster - #272

Merged
agorischek merged 8 commits into
mainfrom
graph-wide-fanouts
Dec 2, 2026
Merged

agorischek merged 8 commits into
mainfrom
graph-wide-fanouts

Conversation

@agorischek

@agorischek agorischek commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: eb7b87a03ad2d119d57089dc2b0fccf3225fc6e0

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ Layouts of every existing graph fixture are identical to main, both orientations (compared point by point and route by route).
↑ Screenshots of service platform, its dark mode, Terraform and npm workspace are pixel-identical to main.
↑ CI passes on this revision (45 checks). Two browser shards timed out on slow runners in the first attempt and passed on rerun; locally the graph arrowheads test takes 33 s of its 360 s budget.
↑ Copilot review raised one issue (a mutated ReadonlyMap), fixed and resolved.
↓ The MCP scenario's built-in checks take about 76 s locally against a 360 s CI budget, so a very slow runner can still time them out.
↓ The few-hundred-node graph is about 2× faster but a full transition still takes about 17 s in Node.

What changed

The shared graph renderer handles wide fan-outs and large graphs. Prompted by the GitHub MCP Server's "MCP tools, toolsets and OAuth scopes" projection (github/github-mcp-server#3719), where the copilot_automations toolset's 11 new tools stood in one row far wider than the screen, each routed separately into the repo scope.

Sibling blocks (packages/renderers/kit/src/layout/blocks.ts, block-layout.ts). Six or more cards (blockMinimum) that share every relationship (same sources and targets, same kinds, drawn the same way) wrap into a block:

  • ELK lays the block out as one node. Its cards fill lines in reading order inside an inset tray about three times as broad as deep. Top to bottom, the cards sit on the graph's column grid.
  • The block's relationships run as one: one route from each source into the tray (straight down whenever the source is over it), one route out to each target. Each relationship keeps its own link on that route, so selection, hover and diff marks still work per relationship.
  • The tray is captioned with its count and, while emphasized, each change's count (11 tools +11), in the summary bar's style.
  • Transitions keep the union's blocks in every step (GraphLayoutOptions.blocks). Trays fade with their most visible card and never scale. Framing includes trays.
  • fanInWidths counts a block's routes into a hub once, so repo no longer grows 4× for routes that now arrive as a few.

Performance, profiled first. One MCP layout took 72 s. 57 s of it was untangleConverging testing every pair of the 120 routes converging on repo, round after round. Changes:

  • Once a hub's staggers are spent, only neighbouring ports are tested. The other pairs could no longer change anything, so this is exact.
  • Indexed or cached work that gives identical results: card clearance and gap searches use a cell index, unhide samples a route only once a route drawn differently comes near, trunk moves look only at neighbouring tracks, bundle separation rebuilds and recounts only the bundles that moved, and crossingMorphs indexes where cards sweep.
  • Every non-block fixture lays out identically to main (checked point by point and route by route).
Before After
MCP tools, one layout 72 s, 39,616 px wide 0.45 s, 21,400 px
MCP tools, transition ~150 s 1.0 s
MCP tools, built-in checks (one batch) timed out ~76 s (limit 90 s)
320 modules, 592 imports, one layout 8.5 s 3.6 s
320 modules, transition 27.6 s ~17 s

Fixtures and scenarios. graph/mcp-tools is generated from the server's public list-scopes inventory (fixtures/make-mcp-tools.mjs): 150 tools, 23 toolsets, 12 scopes, with copilot_automations and its 11 tools added. module-graph-large (320 modules) is for the performance budget. Graph browser fixture wideFanOut adds an animated case.

Not in this PR: folding a very large block into one expandable stack card. The tray keeps big groups readable for now, and a fold can build on GraphLayout.blocks later.

Evidence

  • tools check --fast and tools check --affected pass. The affected build gate needed host-vscode built first, which is unrelated to this change.

  • tools test --affected passes. New kit tests: blocks wrap and route as one, mixed bundles stay apart, a transition keeps the union's block IDs, crossing budgets for the MCP hub and for 320 cards.

  • Graph browser suites (chromium-desktop): 57 passed, including dense scrubbing of wideFanOut in both orientations. The frame invariants now judge a block's arrowheads against its tray.

  • Built-in renderer checks pass for every graph/* scenario on chromium-desktop, chromium-mobile and webkit-desktop.

  • Scrubbed wideFanOut and mcp-tools frames (0 to 1) and reviewed the images. Before and after screenshots (desktop, dark, 390 px) were shared with the coordinator.

  • Documentation that this change affects is updated (graph README, renderer kit graphs guide).

  • Fixes include a regression test.

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

agorischek added a commit that referenced this pull request Dec 2, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@agorischek
agorischek marked this pull request as ready for review December 2, 2026 19:03
@agorischek
agorischek requested a balanced review from Copilot December 2, 2026 19:05

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

1 open issue
What changed in this PR

This PR enhances the graph renderer’s scalability by collapsing large sets of “relationship-identical” sibling cards into blocks (with shared routing) and by reducing routing/crossing work for large graphs, while also adding fixtures/tests/docs to validate and demonstrate the behavior.

Changes:

  • Add sibling “block” support across layout, routing, transitions, rendering, CSS, and browser invariants (including GraphLayout.blocks, frame blocks, and edgeEnd).
  • Optimize routing/crossing computation paths and add performance regression tests for wide fan-outs and large graphs.
  • Add new graph scenarios/fixtures and documentation updates describing blocks and the new APIs.
File Description
packages/​renderers/​kit/​test/​performance.test.mjs Adds perf regression tests for block fan-outs and large graphs.
packages/​renderers/​kit/​test/​layout.test.mjs Updates layout invariants/tests to account for blocks and tray endpoints.
packages/​renderers/​kit/​styles/​graph.css Styles for block trays/captions and “receded” appearance.
packages/​renderers/​kit/​src/​routes/​courses.ts Makes route sampling lazy based on bounds intersection to reduce work.
packages/​renderers/​kit/​src/​react/​graph-canvas/​laid-out-graph.tsx Renders block trays and passes block membership into link drawing.
packages/​renderers/​kit/​src/​react/​graph-canvas/​graph-link.tsx Uses tray endpoints for block member edges; adds data attributes for block endpoints.
packages/​renderers/​kit/​src/​react/​graph-canvas/​framing.ts Includes blocks in framing/fit computations.
packages/​renderers/​kit/​src/​react/​graph-canvas/​block-tray.tsx New component to draw a block tray + caption with change counts.
packages/​renderers/​kit/​src/​layout/​routing/​trunk-moves.ts Reduces neighbor checks by track bucketing.
packages/​renderers/​kit/​src/​layout/​routing/​ports.ts Adds special port placement for block in-faces.
packages/​renderers/​kit/​src/​layout/​routing/​converge.ts Limits swap checks after staggers are exhausted.
packages/​renderers/​kit/​src/​layout/​routing/​context.ts Factors clearance into dedicated module and adds cardsNear.
packages/​renderers/​kit/​src/​layout/​routing/​clearance.ts New spatial index for clearance checks and nearby-card queries.
packages/​renderers/​kit/​src/​layout/​routing/​bundles.ts Avoids rebuilds when runs unchanged; caches samples/crossings.
packages/​renderers/​kit/​src/​layout/​routing/​build.ts Uses cardsNear to limit blocking-card scans for gap discovery.
packages/​renderers/​kit/​src/​layout/​model.ts Adds GraphLayout.blocks and GraphLayoutOptions.blocks.
packages/​renderers/​kit/​src/​layout/​layout-graph.ts Incorporates options.blocks into layout cache key inputs.
packages/​renderers/​kit/​src/​layout/​lay-out.ts Integrates block arrangement/placement/routing into layout pipeline.
packages/​renderers/​kit/​src/​layout/​grid.ts Adds cardBreadth helper for block/grid pitch decisions.
packages/​renderers/​kit/​src/​layout/​elk-input.ts Computes sibling blocks, replaces block members with a synthetic ELK node, and routes edges “as the block”.
packages/​renderers/​kit/​src/​layout/​blocks.ts New block grouping + arrangement logic (blockMinimum, IDs, grid wrapping).
packages/​renderers/​kit/​src/​layout/​block-layout.ts New block placement + route projection back to card edges.
packages/​renderers/​kit/​src/​layout.ts Exposes blockMinimum and LayoutBlock.
packages/​renderers/​kit/​src/​index.ts Exposes edgeEnd from the kit entrypoint.
packages/​renderers/​kit/​src/​graph-transition/​layouts.ts Propagates reference blocks through transition steps.
packages/​renderers/​kit/​src/​graph-transition/​frame.ts Adds frame-level block interpolation via frameBlocks.
packages/​renderers/​kit/​src/​graph-transition/​diff-frame.ts Includes blocks in diff frames.
packages/​renderers/​kit/​src/​graph-transition/​crossing.ts Uses cell-based lookup to reduce morph card intersection tests.
packages/​renderers/​kit/​src/​graph-transition.ts Adds TransitionBlock and frame blocks.
packages/​renderers/​kit/​src/​graph-canvas/​view-change.ts Shifts/morphs blocks along with nodes/edges.
packages/​renderers/​kit/​src/​graph-canvas/​fan-in.ts Counts block member routes once for hub-width calculation.
packages/​renderers/​kit/​src/​graph-canvas/​edges.ts Adds edgeEnd helper for tray endpoints (no scale).
packages/​renderers/​kit/​browser/​invariants/​frame.ts Treats block trays like boundaries for overlap/target checks.
packages/​renderers/​kit/​browser/​invariants/​contacts.ts Targets arrow contacts against block trays when applicable.
packages/​renderers/​kit/​browser/​fixtures.ts Adds wideFanOut fixture for block behavior.
packages/​renderers/​graph/​scenarios.json Adds the MCP tools scenario to scenarios list.
packages/​renderers/​graph/​fixtures/​module-graph-large-before.json Adds large module graph fixture (before) for perf coverage.
packages/​renderers/​graph/​fixtures/​module-graph-large-after.json Adds large module graph fixture (after) for perf coverage.
packages/​renderers/​graph/​fixtures/​make-module-graphs.mjs Updates fixture generator to produce the large graph.
packages/​renderers/​graph/​fixtures/​make-mcp-tools.mjs New generator for MCP tools scenario fixtures.
packages/​renderers/​graph/​browser/​graph.spec.ts Adds Playwright coverage for block tray routing and membership.
packages/​renderers/​graph/​README.md Documents block behavior in the graph renderer.
eslint-suppressions.json Updates suppression counts after refactors.
docs/​reference/​renderers.md Adds MCP scenario mention in renderer reference.
docs/​reference/​renderer-kit.md Documents new APIs (blockMinimum, LayoutBlock, TransitionBlock, edgeEnd, frame blocks).
docs/​guides/​renderer-kit-graphs.md Adds guide section explaining sibling blocks and data attributes.
changelog.d/​272.md Changelog entry for renderer behavior + perf improvements.
changelog.d/​272-kit.md Changelog entry for kit API additions around blocks.

Review effort: Lite

agorischek and others added 8 commits December 2, 2026 11:34
…hs faster

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
… the tray; browser coverage

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ths, tests

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@agorischek
agorischek merged commit 7d2a46b into main Dec 2, 2026
93 of 96 checks passed
@agorischek
agorischek deleted the graph-wide-fanouts branch December 2, 2026 20:39
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