Add undo on the canvas, and sharpen the flow chrome

Deleting a node cost its source with no way back. Every mutation already
funnels through one commit, so undo/redo is a bounded stack of node
snapshots replayed through the same debounced save. Deleting a node only
drops it from flow.json — the source file survives — so restoring the id
restores the code. Renaming a message now offers to follow the rename
across every node still bound to the old name, as one undoable step.

Autosave never fired: flush depended on the whole mutation object, which
react-query rebuilds every render, so the effect re-ran and its cleanup
cancelled the pending timer. Unmounting now flushes rather than drops.

The canvas looked blurry zoomed out because Background scales the dot
radius by zoom, leaving quarter-pixel dots on a drifting tile; radius
and spacing now divide the zoom back out, spacing in octaves so the grid
halves. Edge value labels are opaque, the edge popover fits its summary
on one row with a trash icon and scrolls names that overflow, and flow
settings moved to the flowbar. The flowbar was sized against the
viewport rather than the canvas, so its buttons left the screen once
enough flows were open.
This commit is contained in:
Melvin Strobl
2026-08-15 21:19:53 +02:00
parent e600fbfcd2
commit 235dca5915
8 changed files with 410 additions and 75 deletions
+9 -3
View File
@@ -64,6 +64,11 @@ export function useAutosave(name: string): {
},
})
// react-query hands back a new mutation object on every render, so flushing
// has to hang off `mutate`, which is stable. Depending on the whole mutation
// re-ran the effect below on every render, and its cleanup cancelled the
// pending save before it ever fired.
const { mutate } = mutation
const flush = useCallback(() => {
if (timer.current) {
clearTimeout(timer.current)
@@ -72,9 +77,9 @@ export function useAutosave(name: string): {
const definition = pending.current
pending.current = null
if (definition) {
mutation.mutate(definition)
mutate(definition)
}
}, [mutation])
}, [mutate])
const save = useCallback(
(definition: FlowDef_Input) => {
@@ -93,7 +98,8 @@ export function useAutosave(name: string): {
document.addEventListener("visibilitychange", onHidden)
return () => {
document.removeEventListener("visibilitychange", onHidden)
if (timer.current) clearTimeout(timer.current)
// Unmounting is a flow switch, not a reason to drop a queued edit.
flush()
}
}, [flush])