@bian-womp/spark-workbench 0.2.33 → 0.2.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.cjs CHANGED
@@ -567,7 +567,10 @@ class LocalGraphRunner extends AbstractGraphRunner {
567
567
  this.build(payload.def);
568
568
  this.setEnvironment?.(payload.environment || {}, { merge: false });
569
569
  // Hydrate via runtime for exact restore and re-emit
570
- this.runtime?.hydrate({ inputs: payload.inputs || {}, outputs: payload.outputs || {} }, { reemit: true });
570
+ this.runtime?.hydrate({
571
+ inputs: payload.inputs || {},
572
+ outputs: payload.outputs || {},
573
+ });
571
574
  }
572
575
  dispose() {
573
576
  super.dispose();
@@ -1629,7 +1632,7 @@ function toReactFlow(def, positions, registry, opts) {
1629
1632
  });
1630
1633
  const edges = def.edges.map((e) => {
1631
1634
  const st = opts.edgeStatus?.[e.id];
1632
- const isRunning = !!st?.activeRuns;
1635
+ const isRunning = (st?.activeRuns || 0) > 0;
1633
1636
  const hasError = !!st?.lastError;
1634
1637
  const isInvalidEdge = !!opts.edgeValidation?.[e.id];
1635
1638
  const sourceMissing = !validHandleMap[e.source.nodeId]?.outputs.has(e.source.handle);
@@ -1666,7 +1669,7 @@ function getNodeBorderClassNames(args) {
1666
1669
  const hasError = !!status.lastError;
1667
1670
  const hasValidationError = issues.some((i) => i.level === "error");
1668
1671
  const hasValidationWarning = !hasValidationError && issues.length > 0;
1669
- const isRunning = !!status.activeRuns;
1672
+ const isRunning = (status.activeRuns || 0) > 0;
1670
1673
  const isInvalid = !!status.invalidated && !isRunning && !hasError;
1671
1674
  // Keep border width constant to avoid layout reflow on selection toggles
1672
1675
  const borderWidth = "border";
@@ -2051,8 +2054,12 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
2051
2054
  const isValidRunId = runId && typeof runId === "string" && runId.length > 0;
2052
2055
  setNodeStatus((prev) => {
2053
2056
  const current = prev[id]?.activeRuns ?? 0;
2054
- const nextActive = current - 1;
2055
2057
  const currentRunIds = prev[id]?.activeRunIds ?? [];
2058
+ if (isValidRunId && !currentRunIds.includes(runId)) {
2059
+ console.warn(`[WorkbenchContext] node-done event for unknown runId: node=${id} runId=${runId}`, { event: s, currentRunIds });
2060
+ return prev; // Ignore stale event
2061
+ }
2062
+ const nextActive = Math.max(0, current - 1); // Prevent negative values
2056
2063
  const nextRunIds = isValidRunId
2057
2064
  ? currentRunIds.filter((rid) => rid !== runId)
2058
2065
  : currentRunIds;
@@ -2097,7 +2104,7 @@ function WorkbenchProvider({ wb, runner, registry, setRegistry, overrides, uiVer
2097
2104
  const current = prev[id]?.activeRuns ?? 0;
2098
2105
  return {
2099
2106
  ...prev,
2100
- [id]: { ...prev[id], activeRuns: current - 1 },
2107
+ [id]: { ...prev[id], activeRuns: Math.max(0, current - 1) }, // Prevent negative values
2101
2108
  };
2102
2109
  });
2103
2110
  }