refactoring: graph state

This commit is contained in:
2026-03-12 17:40:05 +01:00
parent bfd1a40332
commit 4bd2f1b458
9 changed files with 176 additions and 58 deletions

View File

@@ -1,6 +1,11 @@
import { useCallback, useRef, useState } from 'react'
import type { AppNode, AppEdge } from '@/lib/graph/nodeTypes'
/**
* In-memory graph state. History is a past/future stack of GraphState snapshots.
* setNodes/setEdges push current state to past; setNodesSilent/setEdgesSilent update without history.
* setStateImmediate replaces state and clears history (e.g. load example, import).
*/
export type GraphState = { nodes: AppNode[]; edges: AppEdge[] }
function cloneState(state: GraphState): GraphState {