Fix: Cut and Paste functionality #9
Reference in New Issue
Block a user
Delete Branch "claude/issue-8"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements cut and paste functionality for graph nodes (closes #8).
Summary
CutStoreZustand store (src/stores/CutStore.ts) to hold cut node IDs, nodes, edges, and source graph IDgraphToDot()inGraphviz.tsxto render cut nodes with dashed grey fill as visual indicatorGraph.tsxsubscribes tocutNodeIdsso the graph re-renders automatically on cut; clears cut store on file loade2e/cut-paste.spec.tsAssumptions
Test plan
🤖 Generated with Claude Code
Change assumption: "Nodes linked with link direction from selected nodes" = direct outgoing neighbours (one hop)
It should be:
Nodes that are outgoing neighbours and structure for which they are root nodes = outgoing structure (all hops)
Addressed the feedback: changed the cut operation from collecting only direct outgoing neighbours (one hop) to a full BFS traversal following outgoing edges from all selected nodes (all hops).
The
case 'cut'inNodeContextMenu.tsxnow uses a BFS queue starting from the base nodes, expanding through each outgoing edge until no new nodes are found. This means cutting a node now captures its entire outgoing subtree, not just its immediate children.Please re-check
src/components/NodeContextMenu.tsxlines 115–124.Another issue to address: when a tree of nodes is subject of cut and paste action, the navigation tree is not updated - if some nodes with subgraphs are moved this way it should be also visible in the tree. Example: in main graph there are nodes - 'sky' and 'apple', 'sky' has a subgraph that contains 'wave' which also contains a subgraph. 'wave' in the tree is displayed as child of 'sky'. User cuts 'wave' then navigates to 'apple' and pastes - node 'wave' now should be displayed as child of 'apple' in the navigation tree and breadcrumbs also should be consistent with the new state.
Addressed the feedback — the navigation tree now updates correctly when nodes with subgraphs are cut and pasted.
What changed:
move(nodeId, newParentId)function toTreeStorethat reparents a tree node: removes it from its current parent (or root) and places it under the new parent, updatingparentIdByChildId, the parent'schildrenarray, and rebuilding the tree.NodeContextMenu.tsx), after transferring nodes/edges between graphs, the code now iterates over the cut node IDs and callsmoveTreeNodefor any that have a tree entry (i.e. have a subgraph). Only nodes whose tree parent matches the source graph are reparented — nested tree nodes (subgraphs within the cut structure) keep their existing parent relationships intact.Example from the review: After cutting
wavefromsky's subgraph and pasting intoapple's subgraph,wavenow appears as a child ofapplein the sidebar tree, and breadcrumbs reflect the new hierarchy. Sub-subgraphs (e.g. nodes with subgraphs nested insidewave) continue to appear correctly underwave.f7f2938bb1tod5107ac6d3