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
Refactor settings editor to include isSettingsChanged function
Muhammad Hamza Khanac0c024aa177
diff --git a/packages/app/src/builder-ui/components/Component.class/settings-editor.ts b/packages/app/src/builder-ui/components/Component.class/settings-editor.tsindex 41a96930..a82a76ad 100644--- a/packages/app/src/builder-ui/components/Component.class/settings-editor.ts+++ b/packages/app/src/builder-ui/components/Component.class/settings-editor.ts@@ -336,7 +336,6 @@ async function onSave(values) {//component.redrawSettings();component.domElement.classList.remove('active');- Component.curComponentSettings = null;await delay(100);component.workspace.saveAgent();@@ -354,6 +353,12 @@ async function onDraft(values) {component.emit('settingsDraftUpdated', preparedValues);}+function isSettingsChanged() {+ const component = this;+ const changed = component.settingsChanged();+ return changed;+}+const templateHelpSection = {html1: {type: 'div',@@ -1042,6 +1047,7 @@ export async function editSettings(component: Component) {onCancel,onLoad: onComponentLoad.bind(component),helpTooltip: helpTooltip,+ isSettingsChanged: isSettingsChanged.bind(component),});component.emit('settingsOpened', component.getSettingsSidebar());diff --git a/packages/app/src/builder-ui/ui/dialogs.ts b/packages/app/src/builder-ui/ui/dialogs.tsindex 666ec76d..d29f85fa 100644--- a/packages/app/src/builder-ui/ui/dialogs.ts+++ b/packages/app/src/builder-ui/ui/dialogs.ts@@ -1060,6 +1060,7 @@ interface SidebarOptions {onCancel?: (sidebar) => void;onLoad?: (sidebar: HTMLElement) => void;helpTooltip?: string;+ isSettingsChanged?: () => boolean;}export function sidebarEditValues({@@ -1076,6 +1077,7 @@ export function sidebarEditValues({onCancel = (sidebar) => {},onLoad = (sidebar) => {},helpTooltip = '',+ isSettingsChanged = () => false,}: SidebarOptions): Promise<any> | null {return new Promise(async (resolve) => {const sidebar = await createRightSidebar(@@ -1165,8 +1167,9 @@ export function sidebarEditValues({const values = await readRightSidebarValues(sidebar);if (values && typeof onDraft === 'function') {onDraft(values);+ performAutoSave();}- }, 300);+ }, 500);// Listen for immediate input changes (text inputs, textareas)_form.addEventListener(@@ -1212,10 +1215,14 @@ export function sidebarEditValues({handleTemplateVars(sidebarContent);}- const performSaveAndClose = async (e?: MouseEvent) => {+ const performAutoSave = async (e?: MouseEvent) => {+ const changed = isSettingsChanged();+ if (!changed) {+ return;+ }+const result = {};let saveBeforeCloseState = 0;- let validationToastShown = false;for (let tab in forms) {const form = forms[tab].form;@@ -1232,10 +1239,6 @@ export function sidebarEditValues({closestScrollable.scrollTo({ top: invalid.offsetTop - 50, behavior: 'smooth' });}if (invalid) {- if (!validationToastShown) {- errorToast('Please fix the highlighted fields and try again.', 'Validation Error');- validationToastShown = true;- }saveBeforeCloseState = 2;}@@ -1251,7 +1254,6 @@ export function sidebarEditValues({return false;}if (typeof onSave === 'function') onSave.apply({ sidebar }, [result]);- closeRightSidebar();window['workspace']?.emit?.('componentUpdated', result);resolve(result);};@@ -1260,11 +1262,6 @@ export function sidebarEditValues({if (closeBtn) {closeBtn.onclick = async (e) => {// Save on 'x' only for standard single-tab Settings sidebars- const tabKeys = Object.keys(forms || {});- const isStandardSettings = tabKeys.length === 1 && tabKeys[0] === 'Settings';- if (isStandardSettings) {- return performSaveAndClose(e as any);- }if (typeof onBeforeCancel === 'function') {const canClose = await onBeforeCancel.apply({ sidebar }, [sidebar]);