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 conflicts with dev branch
alaa-eddine885b1638bdfe
diff --cc packages/app/src/builder-ui/ui/form/misc.tsindex 8b5ada3f,d3b4816c..3c42e474--- a/packages/app/src/builder-ui/ui/form/misc.ts+++ b/packages/app/src/builder-ui/ui/form/misc.ts@@@ -152,8 -150,11 +152,13 @@@ const TEMPLATE_VAR_BTNS_WRAPPER_CLASSexport function generateTemplateVarBtns(variables: Map<string, { var: string; type?: string }>,compUid = '',+ parentContainer?: HTMLElement,): HTMLElement | null {- let wrapper = document.querySelector(`.${TEMPLATE_VAR_BTNS_WRAPPER_CLASS}`) as HTMLDivElement;+ // Look for existing wrapper within the specific parent container, not globally+ const searchScope = parentContainer || document;- let wrapper = searchScope.querySelector(`.${TEMPLATE_VAR_BTNS_WRAPPER_CLASS}.tvb-${compUid}`) as HTMLDivElement;++ let wrapper = searchScope.querySelector(++ `.${TEMPLATE_VAR_BTNS_WRAPPER_CLASS}.tvb-${compUid}`,++ ) as HTMLDivElement;if (!wrapper) {wrapper = document.createElement('div');@@@ -245,24 -234,24 +250,26 @@@ export function handleTemplateVars(targ`.template-var-button[data-var="${clickedElm.getAttribute('data-var')}"]`,);+ // Prioritize finding json-editor (ACE editor textarea) first, then fall back to regular fields+ const formGroup = buttonElm.closest('.form-group');const focusedField =- (buttonElm- .closest('.form-group')- .querySelector('[data-template-vars=true]') as HTMLTextAreaElement) ||- (buttonElm- .closest('.form-group')- .querySelector('[data-agent-vars=true]') as HTMLTextAreaElement) ||- (buttonElm- .closest('.form-group')- .querySelector('[data-trigger-vars=true]') as HTMLTextAreaElement);+ (formGroup?.querySelector('.json-editor') as HTMLTextAreaElement) ||+ (formGroup?.querySelector('textarea[data-template-vars=true]') as HTMLTextAreaElement) ||+ (formGroup?.querySelector('textarea[data-agent-vars=true]') as HTMLTextAreaElement) ||+ (formGroup?.querySelector('input[data-template-vars=true]') as HTMLTextAreaElement) ||+ (formGroup?.querySelector('input[data-agent-vars=true]') as HTMLTextAreaElement) ||++ (formGroup?.querySelector('textarea[data-trigger-vars=true]') as HTMLTextAreaElement) ||++ (formGroup?.querySelector('input[data-trigger-vars=true]') as HTMLTextAreaElement) ||+ (formGroup?.querySelector('textarea') as HTMLTextAreaElement);// changing select element does not remove template-var-buttons and these buttons can add inputs to readonly field- if (!focusedField.hasAttribute('readonly')) {- // check if it is ace editor- if (focusedField?.classList?.contains('json-editor')) {+ if (focusedField && !focusedField.hasAttribute('readonly')) {+ // check if it is ace editor by checking for _editor property+ const editor = (<any>focusedField)?._editor;+ if (editor) {const textToInsert: any = buttonElm.getAttribute('data-var');- const editor = (<any>focusedField)?._editor;+ // Insert text at current cursor position in ACE editoreditor.session.replace(editor?.selection?.getRange(), textToInsert);// Set the cursor to the new position@@@ -302,7 -292,13 +310,15 @@@// * Display template variable buttons only if the field is not readonlyconst inputVariables = window['__INPUT_TEMPLATE_VARIABLES__']?.[compUid] || new Map();- const fieldName = clickedElm?.name;+ // For ACE editors, find the actual textarea element to get the field name+ let fieldName = clickedElm?.name;+ if (!fieldName) {+ const formGroup = (clickedElm as HTMLElement).closest('.form-group');- const textarea = formGroup?.querySelector('textarea[data-template-vars=true]') as HTMLTextAreaElement;++ const textarea = formGroup?.querySelector(++ 'textarea[data-template-vars=true]',++ ) as HTMLTextAreaElement;+ fieldName = textarea?.name;+ }// set the last field with template vars to keep the field variables when add/remove inputwindow['__LAST_FIELD_WITH_TEMPLATE_VARS__'] = fieldName;@@@ -338,7 -334,8 +354,12 @@@}// #endregion- const buttonsContainer = generateTemplateVarBtns(variables, compUid) as HTMLDivElement;+ const focusedElmParent = clickedElm.closest('.form-group') as HTMLElement;- const buttonsContainer = generateTemplateVarBtns(variables, compUid, focusedElmParent) as HTMLDivElement;++ const buttonsContainer = generateTemplateVarBtns(++ variables,++ compUid,++ focusedElmParent,++ ) as HTMLDivElement;if (!buttonsContainer) return;@@@ -350,7 -347,13 +371,15 @@@) {// * Display template variable buttons only if the field is not readonly- const fieldName = clickedElm?.name;+ // For ACE editors, find the actual textarea element to get the field name+ let fieldName = clickedElm?.name;+ if (!fieldName) {+ const formGroup = (clickedElm as HTMLElement).closest('.form-group');- const textarea = formGroup?.querySelector('textarea[data-agent-vars=true]') as HTMLTextAreaElement;++ const textarea = formGroup?.querySelector(++ 'textarea[data-agent-vars=true]',++ ) as HTMLTextAreaElement;+ fieldName = textarea?.name;+ }// set the last field with template vars to keep the field variables when add/remove inputwindow['__LAST_FIELD_WITH_TEMPLATE_VARS__'] = fieldName;@@@ -362,39 -365,11 +391,43 @@@{ var: string; type: string }>;- const buttonsContainer = generateTemplateVarBtns(variables, compUid) as HTMLDivElement;+ const focusedElmParent = clickedElm.closest('.form-group') as HTMLElement;- const buttonsContainer = generateTemplateVarBtns(variables, compUid, focusedElmParent) as HTMLDivElement;++ const buttonsContainer = generateTemplateVarBtns(++ variables,++ compUid,++ focusedElmParent,++ ) as HTMLDivElement;if (!buttonsContainer) return;- const focusedElmParent = clickedElm.closest('.form-group');+ focusedElmParent.appendChild(buttonsContainer);+ } else if (+ clickedElm.getAttribute('data-trigger-vars') === 'true' &&+ !clickedElm?.hasAttribute('readonly')+ ) {+ console.log('clicked elm', clickedElm);+ let dataTriggers = clickedElm.getAttribute('data-triggers');+ if (!dataTriggers) return;++ const triggersList = Array.isArray(dataTriggers) ? dataTriggers.split(',') : [dataTriggers];+ const triggersSchema = triggersList.map((triggerId) => {+ const component = document.getElementById(triggerId);+ const control = (component as any)?._control;+ return control?.schema;+ });++ //generate variables from schema+ let variables = new Map();+ for (const schema of triggersSchema) {+ const triggerVariables = extractTriggerVariables(schema);+ for (const [key, value] of triggerVariables) {+ variables.set(key, value);+ }+ }++ const buttonsContainer = generateTemplateVarBtns(variables, compUid) as HTMLDivElement;+ if (!buttonsContainer) return;+ const focusedElmParent = clickedElm.closest('.form-group');focusedElmParent.appendChild(buttonsContainer);} else {// * Remove template variable buttons