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.
JavaScript a2aagentic-aiai-agentsdevtoolsmcp-clientn8n-alternativeno-codeopen-sourceorchestrationsmythosvisual-builder
fix(ApiEndpoint): sorting logic in compact mode
Ahmed Essamcc524dd3fa0b
diff --git a/packages/app/src/builder-ui/components/APIEndpoint.class.ts b/packages/app/src/builder-ui/components/APIEndpoint.class.tsindex a0f5dc4f..cc849798 100644--- a/packages/app/src/builder-ui/components/APIEndpoint.class.ts+++ b/packages/app/src/builder-ui/components/APIEndpoint.class.ts@@ -510,11 +510,11 @@ export class APIEndpoint extends Component {}public async addInput(parent: any, name: any, inputProperties: any = {}): Promise<any> {- const isRenderingAgent = this.workspace.locked; // if the agent is being rendered, the lock will be true+ // const isRenderingAgent = this.workspace.locked; // if the agent is being rendered, the lock will be trueif (this.isOnAdvancedMode ||- this.properties.defaultOutputs.includes(name) ||- isRenderingAgent+ this.properties.defaultOutputs.includes(name)+ // || isRenderingAgent) {const result = await super.addInput(parent, name, inputProperties);this.updateFormPreviewButton();@@ -550,6 +550,44 @@ export class APIEndpoint extends Component {return false;},++ onSortUp: (event) => {+ if (this.isOnAdvancedMode) return true;++ // 1) do not sort up above the first visible input (exclude the default inputs [body, headers, query])+ // we can know that by checking the prev sibling of the output item (from the event), if it is a default input, then we should not sort up+ const outputItem = event.target.closest('.output-endpoint');+ if (outputItem) {+ const prevSibling = outputItem.previousSibling;+ if (prevSibling) {+ const prevSiblingClass = prevSibling.classList;+ if (prevSiblingClass.contains('hidden')) {+ return false;+ }+ }+ }++ // 2) Sync the sort also to the input mapped item+ // next time we render, the order will be preserved correctly since the input and output do share the same order+ const sortUpInputBtn = inputDiv.querySelector('.btn-moveup-endpoint');+ if (sortUpInputBtn) {+ sortUpInputBtn.click();+ }+ return true; // continue the normal (super) sorting process+ },++ onSortDown: (event) => {+ if (this.isOnAdvancedMode) return true;++ // 1) Sync the sort also to the input mapped item+ // next time we render, the order will be preserved correctly since the input and output do share the same order+ const sortDownInputBtn = inputDiv.querySelector('.btn-movedown-endpoint');+ if (sortDownInputBtn) {+ sortDownInputBtn.click();+ }++ return true; // continue the normal (super) sorting process+ },},);@@ -579,8 +617,12 @@ export class APIEndpoint extends Component {}public async addOutput(parent: any, name: any, outputProperties: any = {}): Promise<any> {- const isRenderingAgent = this.workspace.locked; // if the agent is being rendered, the lock will be true- if (this.isOnAdvancedMode || this.properties.defaultOutputs.includes(name) || isRenderingAgent)+ // const isRenderingAgent = this.workspace.locked; // if the agent is being rendered, the lock will be true+ if (+ this.isOnAdvancedMode ||+ this.properties.defaultOutputs.includes(name)+ // || isRenderingAgent+ )return super.addOutput(parent, name, outputProperties);return null;diff --git a/packages/app/src/builder-ui/components/Component.class/index.ts b/packages/app/src/builder-ui/components/Component.class/index.tsindex 97ad97d3..167ba064 100644--- a/packages/app/src/builder-ui/components/Component.class/index.ts+++ b/packages/app/src/builder-ui/components/Component.class/index.ts@@ -1133,6 +1133,10 @@ export class Component extends EventEmitter {epMoveUpButton.innerHTML = '<span class="icon mif-arrow-up"></span>';epMoveUpButton.addEventListener('click', async (event) => {event.stopPropagation();+ if (options.onSortUp) {+ const result = await options.onSortUp(event);+ if (result === false) return;+ }outputDiv.parentElement.insertBefore(outputDiv, outputDiv.previousSibling);this.repaint();this.workspace.saveAgent();@@ -1145,6 +1149,10 @@ export class Component extends EventEmitter {epMoveDownButton.innerHTML = '<span class="icon mif-arrow-down"></span>';epMoveDownButton.addEventListener('click', async (event) => {event.stopPropagation();+ if (options.onSortDown) {+ const result = await options.onSortDown(event);+ if (result === false) return;+ }outputDiv?.parentElement?.insertBefore(outputDiv?.nextSibling, outputDiv);this.repaint();this.workspace.saveAgent();