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
Improve Ace editor tooltip and scrolling behavior for compact and expanded mode
samme-abduld9ea887c7d11
diff --git a/packages/app/src/builder-ui/ui/dom.ts b/packages/app/src/builder-ui/ui/dom.tsindex 7be327fa..a29fbad7 100644--- a/packages/app/src/builder-ui/ui/dom.ts+++ b/packages/app/src/builder-ui/ui/dom.ts@@ -135,7 +135,7 @@ export function setCodeEditor(const wrapLine = textArea?.getAttribute('data-wrap-line') === 'true';const div: any = document.createElement('div');div.id = 'ace-editor-styles';- div.className = 'ace-editor ' + textArea?.className;+ div.className = 'ace-editor ace-editor-sidebar ' + textArea?.className;textArea.parentNode.insertBefore(div, textArea?.nextSibling);textArea?.classList?.add('hidden');@@ -168,10 +168,15 @@ export function setCodeEditor(let errorTooltips = {};+ // Generate a unique ID for this editor's tooltips to avoid conflicts with other editors+ const editorTooltipId = `editor-tooltip-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;+function createTooltip(message, type) {const tooltip = document.createElement('div');tooltip.style.position = 'absolute';tooltip.style.display = 'none';+ // Add unique identifier to each tooltip+ tooltip.setAttribute('data-editor-tooltip-id', editorTooltipId);switch (type) {case 'error':@@ -225,8 +230,14 @@ export function setCodeEditor(});editor.on('guttermousemove', function (e) {+ // Hide all tooltips from this editorObject.values(errorTooltips).forEach((tooltip: any) => (tooltip.style.display = 'none'));+ // Hide all tooltips from other editors to prevent duplicates+ document.querySelectorAll(`.ace_tooltip:not([data-editor-tooltip-id="${editorTooltipId}"])`).forEach((tooltip: any) => {+ tooltip.style.display = 'none';+ });+const row = e.getDocumentPosition().row;const gutterRegion = e.domEvent.target.className;if (gutterRegion.includes('ace_gutter-cell') && errorTooltips.hasOwnProperty(row)) {@@ -236,6 +247,11 @@ export function setCodeEditor(const pageWidth = window.innerWidth;const pageHeight = window.innerHeight;+ // Check if this editor has internal scrolling enabled (maxLines !== Infinity)+ // Only apply scroll offset for editors with internal scrolling+ const hasInternalScrolling = editor.getOption('maxLines') === null || editor.getOption('maxLines') === undefined;+ const scrollTop = hasInternalScrolling ? (editor.renderer.scrollTop || 0) : 0;+// Temporarily display the tooltip to measure its dimensionstooltip.style.visibility = 'hidden';tooltip.style.display = 'block';@@ -245,17 +261,18 @@ export function setCodeEditor(const tooltipWidth = tooltip.offsetWidth;// Calculate the top and left positions of the tooltip- let tooltipTop = editorCoords.top + lineHeight * row - tooltipHeight - 5; // Adjust 5 pixels above the error line+ // Subtract scrollTop to account for editor's internal scroll position+ let tooltipTop = editorCoords.top + lineHeight * row - tooltipHeight - 5 - scrollTop; // Adjust 5 pixels above the error linelet tooltipLeft = editorCoords.left + 4; // Left align with gutter// Adjust if tooltip goes above the top of the windowif (tooltipTop < window.scrollY) {- tooltipTop = editorCoords.top + lineHeight * (row + 1) + 5;+ tooltipTop = editorCoords.top + lineHeight * (row + 1) + 5 - scrollTop;}// Adjust if tooltip goes below the bottom of the windowif (tooltipTop + tooltipHeight > window.scrollY + pageHeight) {- tooltipTop = editorCoords.top + lineHeight * row - tooltipHeight - 5;+ tooltipTop = editorCoords.top + lineHeight * row - tooltipHeight - 5 - scrollTop;}// Adjust if tooltip goes beyond the right side of the window@@ -264,7 +281,10 @@ export function setCodeEditor(}// Set the tooltip's top and left positions to keep it on-screen- tooltip.style.top = `${tooltipTop + 20}px`;+ // For expanded mode (modal with internal scrolling), position 5px above the error line+ // For compact mode (sidebar without scrolling), use default 20px offset+ const verticalOffset = hasInternalScrolling ? 5 : 20;+ tooltip.style.top = `${tooltipTop + verticalOffset}px`;tooltip.style.left = `${tooltipLeft}px`;tooltip.style.visibility = 'visible';}@@ -272,7 +292,11 @@ export function setCodeEditor(editor.on('mousemove', function (e) {if (!e.domEvent.target.className.includes('ace_gutter-cell')) {- Object.values(errorTooltips).forEach((tooltip: any) => (tooltip.style.display = 'none'));+ // Hide all tooltips from this editor and other editors+ Object.values(errorTooltips)?.forEach((tooltip: any) => (tooltip.style.display = 'none'));+ document.querySelectorAll(`.ace_tooltip:not([data-editor-tooltip-id="${editorTooltipId}"])`).forEach((tooltip: any) => {+ tooltip.style.display = 'none';+ });}});@@ -286,9 +310,13 @@ export function setCodeEditor(editorContainer?.addEventListener('mouseout', function (event) {// Check if the mouse has actually left the containerif (!editorContainer.contains(event.relatedTarget)) {+ // Hide all tooltips from this editor and other editorsObject?.values(errorTooltips)?.forEach?.((tooltip: any) => (tooltip.style.display = 'none'),);+ document.querySelectorAll(`.ace_tooltip:not([data-editor-tooltip-id="${editorTooltipId}"])`)?.forEach((tooltip: any) => {+ tooltip.style.display = 'none';+ });}});diff --git a/packages/app/src/builder-ui/ui/form/fields.ts b/packages/app/src/builder-ui/ui/form/fields.tsindex 82ade396..8921c7bb 100644--- a/packages/app/src/builder-ui/ui/form/fields.ts+++ b/packages/app/src/builder-ui/ui/form/fields.ts@@ -292,6 +292,8 @@ interface TextAreaWithEditor extends HTMLTextAreaElement {setValue: (value: string) => void;focus: () => void;container?: HTMLElement;+ setOption?: (option: string, value: number | boolean | null) => void;+ resize?: (force: boolean) => void;};}@@ -701,6 +703,25 @@ async function initializeCodeEditor(textarea._editor.setValue(initialValue);textarea._editor.focus();+ // For modal context, configure the ace editor to handle scrolling properly+ // The ace editor is configured with maxLines: Infinity which makes it grow to show all content+ // We need to enable the ace editor's internal scrolling for long content in modals+ if (textarea._editor.container && textarea._editor.setOption && textarea._editor.resize) {+ const editorContainer = textarea._editor.container;+ // Override maxLines to enable internal scrolling instead of infinite growth+ textarea._editor.setOption('maxLines', null);+ // Set a reasonable height that fits within the modal+ editorContainer.style.height = '100%';+ editorContainer.style.minHeight = '200px';+ // Ensure the ace editor's scrollbars are visible+ textarea._editor.setOption('vScrollBarAlwaysVisible', false);+ textarea._editor.setOption('hScrollBarAlwaysVisible', false);+ // Remove the sidebar class to allow scrollbars in modals+ editorContainer.classList.remove('ace-editor-sidebar');+ // Trigger resize to apply new dimensions+ textarea._editor.resize(true);+ }+// Setup bracket selection for Ace editor contentconst aceContentElement = textarea._editor.container?.querySelector('.ace_content') as HTMLElement | null;if (aceContentElement) {diff --git a/packages/app/static/css/smyth-builder.css b/packages/app/static/css/smyth-builder.cssindex 03cb59c7..dec05199 100644--- a/packages/app/static/css/smyth-builder.css+++ b/packages/app/static/css/smyth-builder.css@@ -1939,6 +1939,18 @@ ul.agents-list-dlg .btn-delete {border-right: none !important;}+/* Hide scrollbars for ace editors in compact/sidebar mode (maxLines: Infinity) */+/* These editors grow to show all content and don't need internal scrolling */+/* Use class-based targeting to only affect sidebar editors, not modal editors */+.ace-editor-sidebar .ace_scrollbar {+ display: none !important;+}++.ace-editor-sidebar .ace_scrollbar-v,+.ace-editor-sidebar .ace_scrollbar-h {+ display: none !important;+}+/* css for tooltip in ace editor, to show error, warning, info */.ace_tooltip {font: