@bian-womp/spark-remote 0.3.75 → 0.3.77

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
@@ -566,9 +566,22 @@ async function createServerRuntimeAdapter(id, createRegistry, send, extensions)
566
566
  const def = payload.def;
567
567
  if (!def)
568
568
  return;
569
- // Only build if skipBuild is not true
569
+ // Only rebuild when needed. If runtime already exists, update in place so
570
+ // the current engine stays attached (important for undo/redo flows).
570
571
  if (!options?.skipBuild) {
571
- await originalAdapter.build(def, { environment: payload.environment });
572
+ if (!graphRuntime) {
573
+ await originalAdapter.build(def, { environment: payload.environment });
574
+ }
575
+ else {
576
+ const releasePause = graphRuntime.requestPause();
577
+ try {
578
+ graphRuntime.setEnvironment(payload.environment || {});
579
+ graphRuntime.update(def, registry);
580
+ }
581
+ finally {
582
+ releasePause();
583
+ }
584
+ }
572
585
  }
573
586
  else if (!graphRuntime) {
574
587
  // If skipping build but no runtime exists, we still need to build