Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

hotfix for connection rewiring

alaa-eddine7398a4523413
diff --git a/packages/app/src/builder-ui/workspace/Workspace.class.ts b/packages/app/src/builder-ui/workspace/Workspace.class.ts
index 23c38232..668e18e9 100644
--- a/packages/app/src/builder-ui/workspace/Workspace.class.ts
+++ b/packages/app/src/builder-ui/workspace/Workspace.class.ts
@@ -1563,20 +1563,22 @@ export class Workspace extends EventEmitter {
const sourceComponent = source.closest('.component');
const targetComponent = target.closest('.component');
+ const sourceName = source.getAttribute('smt-name');
+ const targetName = target.getAttribute('smt-name');
+ const sourceExpression = source.getAttribute('smt-expression');
+ const targetExpression = target.getAttribute('smt-expression');
+
if (!sourceComponent || !targetComponent) return null; //exclude connections that are not connected to components, these can be used for other visual stuff
return {
sourceId: source.closest('.component').id,
- sourceIndex: [...source.parentElement.querySelectorAll('.output-endpoint')].findIndex(
- (c) => c === source,
- ),
+ sourceExpression, // will be used as a fallback/backup in case of missing or unmatched source name
+ sourceIndex: sourceName,
targetId: target.closest('.component').id,
- targetIndex: [...target.parentElement.querySelectorAll('.input-endpoint')].findIndex(
- (r) => r === target,
- ),
+ targetIndex: targetName,
+ targetExpression, // will be used as a fallback/backup in case of missing or unmatched target name
};
})
.filter((c) => c);
-
const debugSessionEnabled = this.domElement.classList.contains('debug-enabled');
let auth = this.agent.data?.auth;
const variables = this.agent.data.variables;
@@ -2068,24 +2070,25 @@ export class Workspace extends EventEmitter {
}
}
- public getJsplumbConnection(connection) {
- const sourceComponent = document.querySelector(`#${connection.sourceId}`);
- const targetComponent = document.querySelector(`#${connection.targetId}`);
- if (!sourceComponent || !targetComponent) return null;
- const sourceEndpoint = sourceComponent.querySelector(
- `.output-endpoint:nth-child(${connection.sourceIndex + 1})`,
- );
- const targetEndpoint = targetComponent.querySelector(
- `.input-endpoint:nth-child(${connection.targetIndex + 1})`,
- );
- if (!sourceEndpoint || !targetEndpoint) return null;
-
- const source = sourceEndpoint;
- const target = targetEndpoint;
-
- const jsPlumbInstance: any = this.jsPlumbInstance;
- return jsPlumbInstance.getConnections({ source, target })[0];
- }
+ // No more used ?
+ // public getJsplumbConnection(connection) {
+ // const sourceComponent = document.querySelector(`#${connection.sourceId}`);
+ // const targetComponent = document.querySelector(`#${connection.targetId}`);
+ // if (!sourceComponent || !targetComponent) return null;
+ // const sourceEndpoint = sourceComponent.querySelector(
+ // `.output-endpoint:nth-child(${connection.sourceIndex + 1})`,
+ // );
+ // const targetEndpoint = targetComponent.querySelector(
+ // `.input-endpoint:nth-child(${connection.targetIndex + 1})`,
+ // );
+ // if (!sourceEndpoint || !targetEndpoint) return null;
+
+ // const source = sourceEndpoint;
+ // const target = targetEndpoint;
+
+ // const jsPlumbInstance: any = this.jsPlumbInstance;
+ // return jsPlumbInstance.getConnections({ source, target })[0];
+ // }
public async checkConnectionsConsistency(newConnection = null) {
const jsPlumbInstance: any = this.jsPlumbInstance;
let conflict = false;