@bian-womp/spark-workbench 0.3.52 → 0.3.54

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
@@ -1206,6 +1206,14 @@ class LocalGraphRunner extends AbstractGraphRunner {
1206
1206
  this.emit("transport", { runnerId: this.runnerId, state: "local" });
1207
1207
  }
1208
1208
  build(def, opts) {
1209
+ // Rebuilding should not leave the previous runtime alive.
1210
+ // In practice, launch() calls build() and can be triggered multiple times for the same UI "flow".
1211
+ // Disposing here avoids multiple GraphRuntime instances accumulating and emitting events.
1212
+ if (this.runtime) {
1213
+ console.info(`[LocalGraphRunner] Disposing previous runtime before building new one`);
1214
+ this.runtime.dispose();
1215
+ this.runtime = undefined;
1216
+ }
1209
1217
  const builder = new sparkGraph.GraphBuilder(this.registry);
1210
1218
  this.runtime = builder.build(def, opts);
1211
1219
  // Signal UI that freshly built graph should be considered invalidated
@@ -3922,6 +3930,7 @@ function WorkbenchProvider({ wb, runner, overrides, uiVersion, children, }) {
3922
3930
  const [registryErrors, setRegistryErrors] = React.useState([]);
3923
3931
  const [inputValidationErrors, setInputValidationErrors] = React.useState([]);
3924
3932
  const [registryVersion, setRegistryVersion] = React.useState(0);
3933
+ const [registryReady, setRegistryReady] = React.useState(false);
3925
3934
  const clearSystemErrors = React.useCallback(() => setSystemErrors([]), []);
3926
3935
  const clearRegistryErrors = React.useCallback(() => setRegistryErrors([]), []);
3927
3936
  const clearInputValidationErrors = React.useCallback(() => setInputValidationErrors([]), []);
@@ -4619,6 +4628,7 @@ function WorkbenchProvider({ wb, runner, overrides, uiVersion, children, }) {
4619
4628
  // Registry updates: swap registry and refresh graph validation/UI
4620
4629
  const offRunnerRegistry = runner.on("registry", async (registry) => {
4621
4630
  wb.setRegistry(registry);
4631
+ setRegistryReady(true);
4622
4632
  });
4623
4633
  const offFlowViewport = runner.on("viewport", (event) => {
4624
4634
  const viewport = event.viewport;
@@ -4627,6 +4637,17 @@ function WorkbenchProvider({ wb, runner, overrides, uiVersion, children, }) {
4627
4637
  }
4628
4638
  });
4629
4639
  const offRunnerTransport = runner.on("transport", (t) => {
4640
+ // Remote registry is only considered ready once we've received at least one "registry" event.
4641
+ // Reset readiness whenever transport is not stable.
4642
+ if (t.state === "local") {
4643
+ setRegistryReady(true);
4644
+ }
4645
+ else if (t.state === "connecting" || t.state === "retrying") {
4646
+ setRegistryReady(false);
4647
+ }
4648
+ else if (t.state === "disconnected") {
4649
+ setRegistryReady(false);
4650
+ }
4630
4651
  if (t.state === "disconnected") {
4631
4652
  console.info("[WorkbenchContext] Transport disconnected, resetting node status");
4632
4653
  // Reinitialize node status with invalidated=true for all nodes
@@ -4821,6 +4842,7 @@ function WorkbenchProvider({ wb, runner, overrides, uiVersion, children, }) {
4821
4842
  triggerExternal,
4822
4843
  uiVersion,
4823
4844
  registryVersion,
4845
+ registryReady,
4824
4846
  overrides,
4825
4847
  getNodeDisplayName,
4826
4848
  setNodeName,
@@ -4862,6 +4884,7 @@ function WorkbenchProvider({ wb, runner, overrides, uiVersion, children, }) {
4862
4884
  runner,
4863
4885
  uiVersion,
4864
4886
  registryVersion,
4887
+ registryReady,
4865
4888
  overrides,
4866
4889
  getNodeDisplayName,
4867
4890
  setNodeName,