This is an automated email from the ASF dual-hosted git repository.

xiaozhenliu pushed a commit to branch xiaozhen-fix-undoredo
in repository https://gitbox.apache.org/repos/asf/texera.git


The following commit(s) were added to refs/heads/xiaozhen-fix-undoredo by this 
push:
     new 5d343ace3e fix(gui): enable frontend undo-redo with bugfix for shared 
editing
5d343ace3e is described below

commit 5d343ace3e59ccf47a50b1d193a074201171a288
Author: Xiao-zhen-Liu <[email protected]>
AuthorDate: Tue Oct 7 11:34:35 2025 -0700

    fix(gui): enable frontend undo-redo with bugfix for shared editing
---
 .../workflow-graph/model/shared-model-change-handler.ts     |  1 +
 .../service/workflow-graph/model/workflow-graph.ts          | 13 +++++++++++++
 2 files changed, 14 insertions(+)

diff --git 
a/core/gui/src/app/workspace/service/workflow-graph/model/shared-model-change-handler.ts
 
b/core/gui/src/app/workspace/service/workflow-graph/model/shared-model-change-handler.ts
index 00e5343412..a401731681 100644
--- 
a/core/gui/src/app/workspace/service/workflow-graph/model/shared-model-change-handler.ts
+++ 
b/core/gui/src/app/workspace/service/workflow-graph/model/shared-model-change-handler.ts
@@ -155,6 +155,7 @@ export class SharedModelChangeHandler {
           const newLink = 
this.texeraGraph.sharedModel.operatorLinkMap.get(key) as OperatorLink;
           // Validate the link first
           try {
+            this.texeraGraph.assertLinkNotDuplicated(newLink);
             this.texeraGraph.assertLinkIsValid(newLink);
             const jointLinkCell = JointUIService.getJointLinkCell(newLink);
             jointElementsToAdd.push(jointLinkCell);
diff --git 
a/core/gui/src/app/workspace/service/workflow-graph/model/workflow-graph.ts 
b/core/gui/src/app/workspace/service/workflow-graph/model/workflow-graph.ts
index 8a3ff7a51c..0a8f85ae6c 100644
--- a/core/gui/src/app/workspace/service/workflow-graph/model/workflow-graph.ts
+++ b/core/gui/src/app/workspace/service/workflow-graph/model/workflow-graph.ts
@@ -1111,6 +1111,19 @@ export class WorkflowGraph {
     }
   }
 
+  /**
+   * Checks if a link is unique in the graph. Throws an error if more than one 
link with the same source and target
+   * as the given link exists.
+   */
+  public assertLinkNotDuplicated(link: OperatorLink): void {
+    const links = this.getAllLinks().filter(
+      value => isEqual(value.source, link.source) && isEqual(value.target, 
link.target)
+    );
+    if (links.length > 1) {
+      throw new Error(`duplicate link found with same source and target as 
link ${link}`);
+    }
+  }
+
   /**
    * Retrieves a subgraph (subDAG) from the workflow graph. This method 
excludes disabled operators and links.
    *

Reply via email to