Skip to content

database: fold mass removals and additions - #402

Open
agorischek wants to merge 4 commits into
kit/fold-mass-removalsfrom
database/fold-mass-changes
Open

agorischek wants to merge 4 commits into
kit/fold-mass-removalsfrom
database/fold-mass-changes

Conversation

@agorischek

Copy link
Copy Markdown
Collaborator

Stacked on #396 (base kit/fold-mass-removals). It will be retargeted to main after #396 merges.

Refs #396

What changed

#396 folds a dozen or more sibling items that are removed (or added) together into one expandable summary card in the kit's GraphCanvas and CardGrid. The database renderer lays out its own schema canvas, so #396 didn't fold its tables. This PR gives the database renderer the same behaviour:

  • Kit: useMassFolds(props) (@githubnext/projections-renderer-kit/react) is the graph canvas's fold logic pulled out for any renderer that lays out its own model. It returns the props to draw: model and schedule folded, emphasis taken from what each card stands for, selection and focus requests moved onto the card, and onSelect of a fold or its links opening and closing it. It also returns each closed fold's aliases. GraphCanvas now uses the same hook, so the behaviour is shared rather than copied.
  • Database renderer:
    • A dozen or more tables, views or enums removed (or added) together become one header-only card in the removed (or added) style, labelled with the definition's plural noun ("48 tables removed"). Activating it opens the tables in place, and the card stays as "Hide 48 removed tables".
    • A dozen or more columns or keys removed together from a table that stays fold into one row of that table ("17 columns removed").
    • A fold card carries data-entity-id (pk-mass:…), data-entity-aliases, data-fold and data-projections-action, so the host's selection, hover, filter and --entity focus find it.
    • Foreign keys and enum types from folded tables are drawn once from the fold card's header. Fold links carry no data-entity-id.
  • Design rules: fold labels use pk-label. The fold card's header is its only part, so it draws no rule of its own (a single border) and takes the card's bottom corners. The fold button adds no accent colour inside the card's change tint.
  • Scenario and tests:
    • New database/prisma-partners scenario: a real prisma-schema extraction, generated by fixtures/make-schemas.mjs, in which a partner program of 14 tables and 2 enums is retired.
    • Unit tests: test/mass-fold.test.mjs.
    • Browser test: browser/mass-fold.spec.ts, mirroring Kit: fold mass removals into one summary card #396's graph test.
    • The scenario is also added to the diff overlap spec.
  • Docs: the database README, the graph canvas guide (own-layout renderers), and docs/reference/renderer-kit.md, regenerated with node tools/scripts/reference-docs.mjs --only renderer-sdk. The regenerated page also picks up Kit: fold mass removals into one summary card #396's foldMassChanges exports, which weren't regenerated there.

Evidence

dub (dubinc/dub) #4783 ("Simplify Dub", 48 tables removed): projections compare b57281e..751c363 -p prisma-schema --trust --definition-revision working-tree --png …, run between the merge commit's parent and the merge commit.

Base (kit/fold-mass-removals) This branch
Schema frame, All scope (animated) 1862 × 81,546 px 1047 × 21,779 px
Schema frame, Changes scope (the default for compare --png) 1538 × 56,584 px 1246 × 1,440 px
compare --png (default, diff) Wrote a PNG cut off at 4,096 px. The CLI noted the renderer "asked for 20033 px of height", which is over rendererLimits, and the image is mostly blank. Wrote a 1280 × 1449 PNG with no notes
--mode side-by-side / --mode animated Cut off at 4,096 px (asked for 20,084 and 20,033 px) 1280 × 2503 and 1280 × 1449, with no notes

The All scope is still above 20,000 px. That isn't caused by the mass change: the head revision alone measures 975 × 20,661 px in the All scope.

Before (base branch):

dub #4783 on the base branch: the frame is cut off and mostly blank

After (this branch):

dub #4783 on this branch: 48 tables removed and 47 enums removed as fold cards, and 17 columns removed as a row of Project

Checks I ran, all on chromium-desktop for the browser suites:

  • npm run tools -- check --fast: pass

  • npm run tools -- check --affected: pass

  • npm run typecheck for the kit and database workspaces, and eslint on the changed files: pass

  • npm run tools -- test packages/renderers/database: 48 passed

  • npm run tools -- test packages/renderers/kit: 206 passed

  • npx playwright test --project chromium-desktop database/browser (harness): 34 passed

  • npx playwright test --project chromium-desktop --grep "database/" (harness checks on every database scenario): 112 passed

  • npx playwright test --project chromium-desktop graph/browser/graph.spec.ts (the graph canvas, after the hook refactor): 19 passed

  • Harness scenario-wide checks (^database: , every built-in scenario, in every scenario, nested accents, extractions present): 15 passed

  • Not run: WebKit and mobile projects, and the full npm run docs:check, which needs the pinned Rust nightly for the Rust SDK pages.

  • Documentation that this change affects is updated, and generated reference
    pages are regenerated (npm run docs:generate).

  • 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 4 commits December 4, 2026 22:35
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>

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

Fold interactions can report synthetic IDs to the host instead of expanding, while read-only fold tags remain keyboard-inaccessible and incorrectly marked disabled.

2 open issues
What changed in this PR

Extends #396’s mass-change folding to the database renderer, keeping large schema comparisons compact while allowing users to expand folded items.

Changes:

  • Extracts a shared useMassFolds hook and reuses it in GraphCanvas.
  • Adds database fold cards, rows, host aliases, and relationship routing.
  • Adds a Prisma scenario, regression coverage, documentation, and changelog entries.
File Description
packages/​renderers/​kit/​src/​react/​mass-folds.ts Adds the shared folding hook.
packages/​renderers/​kit/​src/​react/​graph-canvas/​mass-folds.ts Reuses the shared hook.
packages/​renderers/​kit/​src/​react.ts Exports the folding API.
packages/​renderers/​database/​test/​mass-fold.test.mjs Tests folding, aliases, and links.
packages/​renderers/​database/​src/​view.tsx Integrates folding into the renderer.
packages/​renderers/​database/​src/​tags.tsx Adds fold attributes to tags.
packages/​renderers/​database/​src/​table.tsx Renders expandable fold cards and rows.
packages/​renderers/​database/​src/​styles.css Styles fold headers and rows.
packages/​renderers/​database/​src/​schema-model.ts Measures fold labels as prose.
packages/​renderers/​database/​src/​schema-links.ts Routes folded links and orders rows.
packages/​renderers/​database/​src/​mass-folds.tsx Provides fold attributes and icons.
packages/​renderers/​database/​src/​links-view.tsx Omits host IDs from synthetic links.
packages/​renderers/​database/​src/​geometry.ts Sizes folds as header-only cards.
packages/​renderers/​database/​scenarios.json Registers the partner-retirement scenario.
packages/​renderers/​database/​README.md Documents database folding.
packages/​renderers/​database/​fixtures/​prisma-partners/​before/​prisma/​schema.prisma Defines the original partner schema.
packages/​renderers/​database/​fixtures/​prisma-partners/​after/​prisma/​schema.prisma Defines the reduced schema.
packages/​renderers/​database/​fixtures/​prisma-partners-after.json Supplies the extracted after fixture.
packages/​renderers/​database/​fixtures/​make-schemas.mjs Adds partner fixture generation.
packages/​renderers/​database/​browser/​mass-fold.spec.ts Tests fold interactions and focus.
packages/​renderers/​database/​browser/​diff.spec.ts Adds scenario overlap coverage.
docs/​reference/​renderer-kit.md Updates generated API documentation.
docs/​guides/​renderer-kit-graphs.md Explains folding for custom layouts.
changelog.d/​402.md Announces database folding.
changelog.d/​402-kit.md Announces the shared hook.

Review effort: Balanced

className={`database-table pk-frame database-mass-fold${props.selectedId === change.id ? ' selected' : ''}`}
aria-label={entity.label}
data-entity-id={change.id}
{...useFoldAttributes(entity)}
data-entity-id={id}
{...foldAttributes}
aria-label={`${shown}${status}${former ? `, was ${former}` : ''}`}
{...selectControl(props.selectedId === id)}

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