Repository navigation
refactor(core): layoutMultipleSystems options object + shared group-collapse machinery - #2057
Merged
Merged
Conversation
…-collapse machinery layoutMultipleSystems() took 10 mostly-optional positional params that just re-splat the LayoutOptions object layout() already received. Change the signature to layoutMultipleSystems(viewSlice, options) and pass the options object straight through from the layout() call site. Also extract collapseAndAssignGroupLayers(), the group-collapse + assignGroupedLayers sequence duplicated between layout()'s single-system path and layoutMultipleSystems()'s per-system loop. The two callers differ on whether they commit the collapsed nodes/edges when band assignment fails to produce groups (layout() always keeps them once the block runs; layoutMultipleSystems() only adopts them when grouping succeeds) — that decision stays at each call site so both paths keep today's behavior exactly. Zero behavior change: full core test suite passes, and all 25 bundled example projects (en+ja) rendered via buildAllViewsSvgProject in both shape and icon display modes (50 SVGs) are byte-identical against main. Refs #2014 Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
This was referenced Aug 15, 2026
Closed
Merged
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Point 4 of the
packages/corerefactoring analysis in #2014.Step 1 (signature):
layoutMultipleSystemstook 10 mostly-optional positional params that just re-splat theLayoutOptionsobjectlayout()already received. Changed the signature tolayoutMultipleSystems(viewSlice, options: LayoutOptions); the call site inlayout()now passesoptionsstraight through instead of destructuring into positionals.Step 2 (shared machinery):
layout()'s single-system path andlayoutMultipleSystems()'s per-system loop both duplicated the group-collapse (collapseGroups) + grouped-layer-assignment (assignGroupedLayers) sequence — the multi-system path's comments literally said "mirrors layout()". ExtractedcollapseAndAssignGroupLayers(), a pure helper returning{ nodes, edges, stubGroup, remapEndpoint, foldedEdgeDiffState, groupIdOf, grouped }; both functions now call it.Preserved asymmetry
The two callers differ on whether they commit the collapse when
assignGroupedLayersfails to produce bands:layout()always adoptsallNodes/allEdgesfrom the collapse result once thegroupBy && groupIndexblock runs, regardless of whether grouping succeeded.layoutMultipleSystems()only adoptsworkNodes/workEdges(and the grouped-layer results) whencollapsed.groupedis non-null — on failure it keeps the original uncollapsedrawNodes/sys.edges.Per the issue's explicit instruction, this difference was not unified — each call site still decides independently what to do with the helper's
groupedresult, exactly matching pre-refactor behavior. (In practice the divergence is a no-op today:collapseGroupsis identity when nothing is configured to collapse, and the only path whereassignGroupedLayerscan returnnullafter a real collapse is one an existing bug guard already handles the same way on both sides — this PR does not change that.)Verification
pnpm --filter @karasu-tools/core testpnpm typecheck(full repo)pnpm check:cyclespnpm knip@resvg/resvg-wasmconfig hint only)pnpm lintexamples/en/*,examples/ja/*) rendered viabuildAllViewsSvgProjectin bothshapeandicondisplay modes — 50/50 SVGs byte-identical betweenmainand this branchNo changeset — internal refactor, zero user-visible change (per
.claude/rules/changesets.md).Refs #2014
🤖 Generated with Claude Code