Let the canvas endpoints be moved, and lift them on hover
Three things they were missing: they could not be dragged out of the lane they were placed in, they stayed the same weight whether or not you were reaching for one, and the label sat right against its connector dot. Where one has been dragged to is a view preference, not part of the flow — writing a position for a dashboard widget into flow.json would be a lie about what the document holds — so it lives in the browser, keyed by flow. Also folds the dashboard shot into `make verify` and drops the one-off scripts that had accumulated beside it; the durable coverage is the Playwright specs, which all pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011LF61rxW1FG5YCD2J9YqjY
This commit is contained in:
@@ -43,7 +43,13 @@ import { CommandPalette } from "./CommandPalette"
|
||||
import { bindingsKey, deriveEdges, portOf, qualify } from "./deriveEdges"
|
||||
import { EdgeInspector, type InspectedEdge } from "./EdgeInspector"
|
||||
import { EndpointNode } from "./EndpointNode"
|
||||
import { deriveEndpoints, ENDPOINT_TYPE, isEndpointNode } from "./endpoints"
|
||||
import {
|
||||
deriveEndpoints,
|
||||
ENDPOINT_TYPE,
|
||||
isEndpointNode,
|
||||
placementsFor,
|
||||
rememberPlacement,
|
||||
} from "./endpoints"
|
||||
import { FIT_VIEW, FlowDock } from "./FlowDock"
|
||||
import { FlowNode, type FlowNodeData } from "./FlowNode"
|
||||
import { FlowPanel } from "./FlowPanel"
|
||||
@@ -385,6 +391,12 @@ function FlowEditorInner({
|
||||
}
|
||||
}, [key])
|
||||
|
||||
// Endpoints are movable but are not the flow's to store, so where they were
|
||||
// put lives in the browser rather than in flow.json.
|
||||
const [moved, setMoved] = useState<Record<string, { x: number; y: number }>>(
|
||||
() => placementsFor(flowName),
|
||||
)
|
||||
|
||||
/** Where clicking an endpoint takes you: the thing it stands for. */
|
||||
const openEndpoint = useCallback(
|
||||
(id: string) => {
|
||||
@@ -415,8 +427,9 @@ function FlowEditorInner({
|
||||
definitions,
|
||||
flowName,
|
||||
new Map(canvasNodes.map((node) => [node.id, node.position])),
|
||||
moved,
|
||||
),
|
||||
[detail.endpoints, key, flowName],
|
||||
[detail.endpoints, key, flowName, moved],
|
||||
)
|
||||
|
||||
// Edges follow from the name bindings, so they are derived, never stored.
|
||||
@@ -727,12 +740,17 @@ function FlowEditorInner({
|
||||
nodes={shownNodes}
|
||||
edges={edges}
|
||||
onNodesChange={onNodesChange}
|
||||
onNodeDragStop={(_event, _node, dragged) =>
|
||||
commit(
|
||||
definitions,
|
||||
mergeDragged(canvasNodes, dragged.filter(isDocumentNode)),
|
||||
)
|
||||
}
|
||||
onNodeDragStop={(_event, _node, dragged) => {
|
||||
for (const node of dragged.filter(isEndpointNode)) {
|
||||
rememberPlacement(flowName, node.id, node.position)
|
||||
setMoved((current) => ({
|
||||
...current,
|
||||
[node.id]: node.position,
|
||||
}))
|
||||
}
|
||||
const own = dragged.filter(isDocumentNode)
|
||||
if (own.length) commit(definitions, mergeDragged(canvasNodes, own))
|
||||
}}
|
||||
onNodesDelete={(deleted) =>
|
||||
deleteNodes(deleted.filter(isDocumentNode).map((node) => node.id))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user