fix: palette-add mints unique node ids against live topology - #1
Draft
Dahhrk wants to merge 2 commits into
Draft
Conversation
makeNode uses a module counter that resets on page load, causing duplicate ids when adding nodes of the same kind. handleAddNode now overrides the id using freshId (exported from clipboard.ts), which scans the live node id set — matching the pattern freshAnnId already uses for annotations. Closes xevrion#46
…ral tests handleAddNode now reads topoLiveRef.current instead of the React topology closure, preventing two rapid adds from dropping the first node. topology removed from the dependency array. New test file handleAddNode.wiring.test.ts: - Source assertion: handleAddNode spreads topoLiveRef.current, not the React topology binding, and freshId is called. - Behavioral test: two sequential cache adds against the default preset produce unique ids, both nodes survive, isTopology accepts.
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.
What this changes
Palette-add (
handleAddNode) now mints node ids against the live topology mirror instead of a module counter that resets on page load. Closes xevrion#46.Why
makeNodeuses a module-levelnodeCounterthat resets on load. Two palette-adds of the same kind mint the same id.isTopologyrejects the save, andloadSessionsilently falls back toPRESETS[0].Changes
src/clipboard.ts: exportfreshId(contract unchanged)src/App.tsx:handleAddNodereadstopoLiveRef.current(not the Reacttopologyclosure), overridesidwithfreshId, and dropstopologyfrom the dependency array. Two rapid adds no longer drop the first node.src/clipboard.test.ts:freshIdunit tests (unique mints, skip-existing,isTopologyaccepts)src/handleAddNode.wiring.test.ts(new):handleAddNodespreadstopoLiveRef.current, not the Reacttopologybinding;freshIdis called;topologyis not in the dep array.isTopologyaccepts.Verification
bun run testpasses (904 tests, 37 files)bun run typecheckandbun run lintpassbun run buildpassesGitHub CI
No GitHub Actions check_runs exist on this repo. The only status is Vercel deployment, which reports "Authorization required to deploy" (not a CI gate, not proof of correctness).
Keep
Upstream PR (same branch): xevrion#47