TheYuchen commited on
Commit ·
4410c8a
1
Parent(s): 535c56c
Share-hash boot: plugin defaultData rehydrated once manifests arrive
Browse filesbuildInitialGraph runs synchronously at mount while plugin manifests
load async, so a share-hash boot mounted plugin nodes without their
spec's defaultData (built-in kinds merge theirs at boot; every other
mount path merges via resolveNodeSpec). A one-time FlowCanvas effect
(ref-guarded) now runs when `plugins` first becomes non-empty on a
share-hash boot and merges each plugin spec's defaultData UNDER the
node's existing params — missing keys only, the link author's explicit
values always win. Non-share boots skip it (presets never place plugin
kinds). Backlog entry removed.
docs/AUDIT_BACKLOG.md
CHANGED
|
@@ -10,10 +10,6 @@ deferred.
|
|
| 10 |
|
| 11 |
## FlowCanvas
|
| 12 |
|
| 13 |
-
- share-hash boot ignores plugin defaults [deferred — plugin manifests
|
| 14 |
-
load async AFTER buildInitialGraph runs, so the boot path cannot
|
| 15 |
-
resolve plugin defaultData; merging them retroactively needs a
|
| 16 |
-
rehydration pass over already-mounted nodes.]
|
| 17 |
|
| 18 |
## Evidence
|
| 19 |
|
|
|
|
| 10 |
|
| 11 |
## FlowCanvas
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
## Evidence
|
| 15 |
|
frontend/src/components/FlowCanvas.tsx
CHANGED
|
@@ -614,6 +614,39 @@ export function FlowCanvas() {
|
|
| 614 |
[nodes, edges, circuit, preflightPlugins],
|
| 615 |
);
|
| 616 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 617 |
// ---- Stale post-run encodings (audit S3) --------------------------
|
| 618 |
// Ribbons/edge labels describe the graph AS IT RAN. Editing the
|
| 619 |
// graph afterwards (params, wiring, blocks) leaves those marks
|
|
|
|
| 614 |
[nodes, edges, circuit, preflightPlugins],
|
| 615 |
);
|
| 616 |
|
| 617 |
+
// ---- Share-hash plugin-default rehydration (audit backlog) --------
|
| 618 |
+
// buildInitialGraph runs synchronously at mount, but plugin
|
| 619 |
+
// manifests arrive async (App.tsx fetches /api/plugins after boot).
|
| 620 |
+
// A share-hash boot therefore mounts plugin nodes with ONLY the
|
| 621 |
+
// params the link carried — resolveNodeSpec can't see the plugin's
|
| 622 |
+
// spec yet, so its defaultData never gets merged the way built-in
|
| 623 |
+
// kinds' (and every later add/restore path's) defaults do. Repair
|
| 624 |
+
// retroactively, exactly once, the first time `plugins` becomes
|
| 625 |
+
// non-empty: merge each plugin spec's defaultData UNDER the node's
|
| 626 |
+
// existing params (missing keys only — the author's explicit values
|
| 627 |
+
// always win). Non-share boots skip it: presets go through
|
| 628 |
+
// buildPresetGraph, which never places plugin kinds.
|
| 629 |
+
const pluginDefaultsRehydratedRef = useRef(false);
|
| 630 |
+
useEffect(() => {
|
| 631 |
+
if (pluginDefaultsRehydratedRef.current) return;
|
| 632 |
+
if (!initial.hashPayload) return; // only share-hash boots miss defaults
|
| 633 |
+
if (preflightPlugins.length === 0) return; // manifests not in yet
|
| 634 |
+
pluginDefaultsRehydratedRef.current = true;
|
| 635 |
+
setNodes((ns) =>
|
| 636 |
+
ns.map((n) => {
|
| 637 |
+
const spec = resolveNodeSpec(n.data.kind, preflightPlugins);
|
| 638 |
+
if (!spec || !("isPlugin" in spec)) return n;
|
| 639 |
+
const defaults = (spec.defaultData ?? {}) as Record<string, unknown>;
|
| 640 |
+
const params = n.data.params ?? {};
|
| 641 |
+
if (Object.keys(defaults).every((k) => k in params)) return n;
|
| 642 |
+
return {
|
| 643 |
+
...n,
|
| 644 |
+
data: { ...n.data, params: { ...defaults, ...params } },
|
| 645 |
+
};
|
| 646 |
+
}),
|
| 647 |
+
);
|
| 648 |
+
}, [initial.hashPayload, preflightPlugins, setNodes]);
|
| 649 |
+
|
| 650 |
// ---- Stale post-run encodings (audit S3) --------------------------
|
| 651 |
// Ribbons/edge labels describe the graph AS IT RAN. Editing the
|
| 652 |
// graph afterwards (params, wiring, blocks) leaves those marks
|