Repository navigation
♻️ refactor(graph): extract createScene and createLabelLayer - #122
Merged
Merged
Conversation
Validation, degree, displayed states, the layout seed and the solver's graph now come from a pure prepareGraph. boot keeps writing idToIndexRef, the dropped-edge warning, visualRandom and createPhysics/setParams. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
packNodes then packEdges, so every node seed is drawn before any edge seed. boot still calls it after the Scene and Camera, whose uuids draw from Math.random when the graph is unseeded. The iP2 slot constants and EDGE_END_TRIM move with the code that writes them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Covers the orphan state, the three seed modes, dropped edges, the fray encoding, the alternating bow sign and the order of random draws, plus the patch changeset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A second `* as THREE` namespace made the bundler rename GraphCanvas's to THREE2, so dist/index.js changed far beyond the relocated code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tests Split the shape/tier/colour and gain tests so each asserts one behaviour. Add unit tests that fail if a node's category is looked up by position, if the edge end trim drifts from 1.15, or if the iP2 slot constants move. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Renderer Releases register through a track callback on boot's disposal stack, so the renderer entry stays first and drains last. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…reateScene The edge, pad, node and fade builders live in scene-meshes.ts; the post-process builders sit beside resize in scene.ts, which sizes the targets they make, and keep scene-meshes.ts under the 300-line file limit. Every three object is created in the same order as before, and the three releases are tracked at the end, as the inline pushes were. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ayer Labels are appended and tracked before the tooltip, so the tooltip still paints over them and the two removals keep their places on the stack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…teLabelLayer Covers what the recordings leave out to stay under their size cap: renderer options, autoClear, culling and infinite bounds, the six disposal entries and their inner order, resize's call order, syncNodes reading the caller's arrays, and the label layer's DOM order. Adds the patch changeset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tooltip's cssText moved there with createLabelLayer; the secondary text colour is still read from GraphCanvas.tsx. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 11, 2026
main's tree is identical to #121's head, which this branch already contains, so this branch's tree is kept unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JadRizk
added a commit
that referenced
this pull request
Oct 11, 2026
#121 and #122 moved code out of GraphCanvas.tsx into prepare.ts, buffers.ts, scene.ts, scene-meshes.ts and label-layer.ts, carrying 36 assertions the compiler doesn't need. Drop them, and keep the 2d-context one in label-layer.ts with the reason it had in GraphCanvas.tsx. Restore the reason on the contrast test's kept assertion, lost when main's side of that hunk won. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JadRizk
added a commit
that referenced
this pull request
Oct 11, 2026
…ed (#118) * 🏷️ types(graph): drop the non-null assertions the compiler doesn't need Graph builds under plain strict without noUncheckedIndexedAccess, so 371 of the 454 assertions inherited from qrntn's stricter config assert nothing: their operand's type already excludes null and undefined, or (one case) tsc accepts the nullable value as is. Each was removed as a single-character deletion; no other token changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * 🏷️ types(graph): justify the non-null assertions the compiler needs 83 assertions remain because their operand's type admits null or undefined and tsc rejects the code without them. Each holds by construction (a guard, a loop invariant, or a test's own setup), so each keeps its `!` with an eslint-disable-next-line that says why, as docs/code-style.md asks. The rest of the diff is prettier re-wrapping lines the first commit shortened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * 📝 docs(changeset): empty changeset for the graph non-null clean-up The built JS and .d.ts are byte-identical to main, so there is nothing to release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * 🏷️ types(graph): redo the non-null cleanup over the moved modules #121 and #122 moved code out of GraphCanvas.tsx into prepare.ts, buffers.ts, scene.ts, scene-meshes.ts and label-layer.ts, carrying 36 assertions the compiler doesn't need. Drop them, and keep the 2d-context one in label-layer.ts with the reason it had in GraphCanvas.tsx. Restore the reason on the contrast test's kept assertion, lost when main's side of that hunk won. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
⏸ Held until 2.0 ships (see #107)
Stacked on #121
Closes #112
Part of #107
What moved
All under
packages/graph/src/. None of it is exported from the package.scene.tscreateRenderer(the renderer, main Scene and Camera),createScene,resize, the post-process builders (createTargets,screenTriangle,buildPost), and theTracktypescene-meshes.tsFALLBACK_BGlabel-layer.tscreateLabelLayer: the label pool, the measured placer and the tooltipGraphCanvas.tsxtrack, and keeps the view state, theResizeObserver, and its ownresize(it setsviewWidth/viewHeight/viewport, then callsscene.ts'sresize)One change from the scope's file list: the post builders live in
scene.ts, notscene-meshes.ts. With them included,scene-meshes.tscame to 377 code lines, over the 300-line file limit. They also make the render targets thatresizesizes, so they sit next to it. Every material builder is under 60 lines, so no exception is needed.Order kept by construction
createRendererruns where the renderer was built before, thenpackBuffers, thencreateScene. Extract prepareGraph and packBuffers #111's rule that Math.random is drawn by the Scene and Camera uuids before any shader seed still holds.createScene, three objects are created in the same order as before: edge geometry → edge/live materials and meshes → pads → nodes → fade → render targets → screen geometry → blur and composite → screen quad → post scene and camera. Two allocations without a uuid moved: the six edgeInstancedBufferAttributes are now created before the edge geometry rather than just after it, and thebufferSizescratchVector2is now created increateScene.trackinto the same 6 entries: renderer, targets, materials, geometries, labels, tooltip. The order inside each entry is unchanged, and each entry keeps its own try/catch indispose.syncNodesreads GraphCanvas'snodeDepths/nodeMarks/nodeHiddenby reference and still runs once during construction.Evidence
All of this was run on this branch at its tip, with #121's branch at 3722de7 merged in.
vitest runpasses without-u(338 graph tests).git diff --exit-code origin/refactor/111-prepare-pack -- packages/graph/src/__recordings__ browseris clean, solifecycle.unmount's dispose order andboot.resizeare unchanged.browser/graph.spec.tsin the pinned Playwright container: 14 passed, baselines unchanged.dist/index.d.tsanddist/index.d.ctsare byte-identical (cmp) to a build of ♻️ refactor(graph): extract prepareGraph and packBuffers from boot #121's branch from agit archivecopy. Thenpm pack --dry-runfile list is identical (10 files).packages/graphhas 511 warnings and 0 errors, the same as ♻️ refactor(graph): extract prepareGraph and packBuffers from boot #121's branch. The new files contain only the 12!assertions that moved with the code. They add no size, complexity, params or depth warnings.node scripts/test-react.mjs 18. All pass.scene.test.ts,label-layer.test.ts) cover what the recordings leave out to stay under their size cap: the renderer options,autoClear = false,frustumCulled = falsewith an infinite bounding sphere on every mesh, the count, grouping and inner order of the 6trackentries,resize's call order,syncNodesreading the caller's arrays, and the DOM order inside the label layer.GraphCanvas.contrast.test.tsnow reads the tooltip background fromlabel-layer.ts, where its cssText now lives. This is a test-only change.dist/index.js, prettier-formatted: relocation onlyThe diff is +518/−386. I paired every removed line against an added line after trimming whitespace. The lines left unpaired fall into four groups:
opticsConfig.xbecomesoptics.x,POOLbecomesLABEL_POOL_SIZE, and the bundler's ownTHREE→THREE2andresize→resize2aliases.setEdgeInstances, used by the edge and pad geometries, andaddMesh, which builds a mesh withfrustumCulled = false, itsrenderOrder, andscene.add.No other statement or literal changes.
🤖 Generated with Claude Code