snapshot restore node sizes

This commit is contained in:
2026-03-29 22:10:39 -07:00
parent e84b6c033e
commit adfb3ea354
3 changed files with 26 additions and 4 deletions

View File

@@ -1075,7 +1075,7 @@ function CustomNode({ id, data }) {
} }
if (opts?.hidden) { if (opts?.hidden) {
hiddenWidgets.add(name); hiddenWidgets.add(name);
} else if (isDataSocketSpec(spec)) { } else if (isDataSocketSpec(spec) || opts?.socket_only) {
dataInputs.push({ name, type, label: formatUiLabel(opts?.label || name) }); dataInputs.push({ name, type, label: formatUiLabel(opts?.label || name) });
visibleInputNames.add(name); visibleInputNames.add(name);
} else { } else {
@@ -1267,7 +1267,7 @@ function CustomNode({ id, data }) {
<div className="node-warning">{data.warning}</div> <div className="node-warning">{data.warning}</div>
)} )}
{scalarDisplay && ( {scalarDisplay && !standaloneWidgets.some((w) => w.opts?.text_input) && (
<div className="node-value-display"> <div className="node-value-display">
<div className="node-value-box"> <div className="node-value-box">
<span className="node-value-box-number">{scalarDisplay.valueText}</span> <span className="node-value-box-number">{scalarDisplay.valueText}</span>

View File

@@ -177,16 +177,26 @@ export function buildNodeClipboardPayloadForIds(
)) ))
: []; : [];
const snapDim = (v) => {
const n = Math.round(Number(v));
return Number.isFinite(n) && n > 0 ? n : undefined;
};
return { return {
kind: NODE_CLIPBOARD_KIND, kind: NODE_CLIPBOARD_KIND,
version: 1, version: 1,
nodes: selectedNodes.map((node) => ({ nodes: selectedNodes.map((node) => {
const width = snapDim(node.measured?.width ?? node.width);
const height = snapDim(node.measured?.height ?? node.height);
return {
id: String(node.id), id: String(node.id),
type: node.type || 'custom', type: node.type || 'custom',
position: { position: {
x: Number(node.position?.x) || 0, x: Number(node.position?.x) || 0,
y: Number(node.position?.y) || 0, y: Number(node.position?.y) || 0,
}, },
...(width != null ? { width } : {}),
...(height != null ? { height } : {}),
...(node.className ? { className: node.className } : {}), ...(node.className ? { className: node.className } : {}),
...(node.parentId ? { parentId: String(node.parentId) } : {}), ...(node.parentId ? { parentId: String(node.parentId) } : {}),
...(node.extent ? { extent: node.extent } : {}), ...(node.extent ? { extent: node.extent } : {}),
@@ -200,7 +210,8 @@ export function buildNodeClipboardPayloadForIds(
runtimeValues: clonePlainObject(node.data?.runtimeValues), runtimeValues: clonePlainObject(node.data?.runtimeValues),
extraData: clonePlainObject(extractExtraData(node.data)), extraData: clonePlainObject(extractExtraData(node.data)),
}, },
})), };
}),
edges: capturedEdges.map((edge) => ({ edges: capturedEdges.map((edge) => ({
source: String(edge.source), source: String(edge.source),
sourceHandle: edge.sourceHandle, sourceHandle: edge.sourceHandle,
@@ -267,6 +278,8 @@ export function instantiateNodeClipboardPayload(
x: (Number(node.position?.x) || 0) + (Number(offset?.x) || 0), x: (Number(node.position?.x) || 0) + (Number(offset?.x) || 0),
y: (Number(node.position?.y) || 0) + (Number(offset?.y) || 0), y: (Number(node.position?.y) || 0) + (Number(offset?.y) || 0),
}, },
...(node.width != null ? { width: node.width } : {}),
...(node.height != null ? { height: node.height } : {}),
...(node.parentId ? { parentId: idMap.get(String(node.parentId)) || String(node.parentId) } : {}), ...(node.parentId ? { parentId: idMap.get(String(node.parentId)) || String(node.parentId) } : {}),
...(node.extent ? { extent: node.extent } : {}), ...(node.extent ? { extent: node.extent } : {}),
...(node.hidden ? { hidden: true } : {}), ...(node.hidden ? { hidden: true } : {}),

View File

@@ -26,14 +26,23 @@ export function serializeWorkflowState(nodes, edges) {
sanitizeRuntimeValuesForPersistence(node.data?.className, node.data?.runtimeValues), sanitizeRuntimeValuesForPersistence(node.data?.className, node.data?.runtimeValues),
); );
const snapDim = (v) => {
const n = Math.round(Number(v));
return Number.isFinite(n) && n > 0 ? n : undefined;
};
return { return {
version: 1, version: 1,
nodes: nodes.map((node) => { nodes: nodes.map((node) => {
const runtimeValues = getRuntimeValues(node); const runtimeValues = getRuntimeValues(node);
const width = snapDim(node.measured?.width ?? node.width);
const height = snapDim(node.measured?.height ?? node.height);
return { return {
id: node.id, id: node.id,
type: node.type || 'custom', type: node.type || 'custom',
position: node.position, position: node.position,
...(width != null ? { width } : {}),
...(height != null ? { height } : {}),
...(node.className ? { className: node.className } : {}), ...(node.className ? { className: node.className } : {}),
...(node.parentId ? { parentId: node.parentId } : {}), ...(node.parentId ? { parentId: node.parentId } : {}),
...(node.extent ? { extent: node.extent } : {}), ...(node.extent ? { extent: node.extent } : {}),