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
show tooltip only when truncated
ali-inkcoe7f318fa1c30
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 e610df42..09c1cc3a 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@@ -1315,10 +1315,10 @@ function generateSidebarTitleHTML(component: Component): string {<div class="inline-flex items-center gap-2 max-w-full min-w-0"><span class="shrink-0 inline-flex items-center">${iconHTML}</span><span class="relative min-w-0 max-w-full flex-1">- <span class="truncate block min-w-0 max-w-full leading-tight">${templateName}</span>+ <span class="truncate block min-w-0 max-w-full leading-tight truncatable-text">${templateName}</span><divrole="tooltip"- class="absolute left-0 top-full mt-1 z-50 inline-block text-sm w-max bg-black shadow-lg text-white py-2 px-4 rounded-lg opacity-0 invisible tooltip whitespace-normal break-words text-left max-w-full pointer-events-none"+ class="absolute left-0 top-full mt-1 z-50 inline-block text-sm w-max bg-black shadow-lg text-white py-2 px-4 rounded-lg opacity-0 invisible tooltip whitespace-normal break-words text-left max-w-full pointer-events-none conditional-tooltip">${templateName}</div>diff --git a/packages/app/src/builder-ui/ui/dialogs.ts b/packages/app/src/builder-ui/ui/dialogs.tsindex c624689e..ef70d1d7 100644--- a/packages/app/src/builder-ui/ui/dialogs.ts+++ b/packages/app/src/builder-ui/ui/dialogs.ts@@ -25,6 +25,7 @@ import config from '../config';import { openLLMEmbodiment } from '../pages/builder/llm-embodiment';import { smythValidator } from './form/';import { getIconFormEmbTab, rightSidebarTitle } from './right-sidebar-title';+import { setupTooltipTruncationDetection } from './tooltip-truncation-utils';// Add this near the top of the file with other declarationsconst embodimentHandlers = {@@ -225,6 +226,13 @@ export async function createRightSidebar(title?, content?, actions?, trActions?,export async function closeRightSidebar() {const rightSidebar: any = document.querySelector('#right-sidebar');++ // Cleanup tooltip observers and listeners before closing+ if (rightSidebar?._tooltipCleanup && typeof rightSidebar._tooltipCleanup === 'function') {+ rightSidebar._tooltipCleanup();+ rightSidebar._tooltipCleanup = null;+ }+rightSidebar.closest('.sidebar-container').classList.remove('open');await delay(150);@@ -1110,6 +1118,17 @@ export function sidebarEditValues({// Ensure tooltip inside title is not clipped by container overflow from truncatesidebarTitleEl.classList.remove('truncate');sidebarTitleEl.style.overflow = 'visible';++ // Setup truncation detection and tooltip visibility management+ const cleanupTooltip = setupTooltipTruncationDetection(+ sidebarTitleEl,+ sidebar.closest('.sidebar-container') as HTMLElement,+ );+ if (cleanupTooltip) {+ // Store cleanup function on the sidebar element so it can be called later+ (sidebar as Record<string, unknown>)._tooltipCleanup = cleanupTooltip;+ }+const sidebarContent = sidebar.querySelector('.content');const sidebarActions = sidebar.querySelector('.actions .action-content');sidebarContent.innerHTML = '';diff --git a/packages/app/src/builder-ui/ui/tooltip-truncation-utils.ts b/packages/app/src/builder-ui/ui/tooltip-truncation-utils.tsnew file mode 100644index 00000000..95cee76e--- /dev/null+++ b/packages/app/src/builder-ui/ui/tooltip-truncation-utils.ts@@ -0,0 +1,80 @@+/**+ * Utility functions for managing tooltip visibility based on text truncation detection.+ * This module is intentionally separate to avoid circular dependencies.+ */++/**+ * Sets up truncation detection and tooltip visibility management for an element.+ * This function should be called after the HTML has been inserted into the DOM.+ *+ * The element must contain:+ * - A child with class '.truncatable-text' (the text element with CSS truncate class)+ * - A child with class '.conditional-tooltip' (the tooltip element to show/hide)+ *+ * @param element - The container element with the truncatable text and tooltip+ * @param parentElement - Optional parent element to observe for resize. If provided,+ * will update tooltip visibility when this element resizes.+ * If not provided, only window resize will be observed.+ * @returns Cleanup function to remove observers and listeners, or null if required elements not found+ */+export function setupTooltipTruncationDetection(+ element: HTMLElement,+ parentElement?: HTMLElement,+): (() => void) | null {+ const truncatableText = element.querySelector('.truncatable-text') as HTMLElement;+ const conditionalTooltip = element.querySelector('.conditional-tooltip') as HTMLElement;++ if (!truncatableText || !conditionalTooltip) {+ return null;+ }++ /**+ * Checks if the text is truncated and updates tooltip visibility accordingly.+ * This function is called on load, resize, and parent element width changes (if provided).+ */+ const updateTooltipVisibility = (): void => {+ // Compare scrollWidth with offsetWidth to determine if text is truncated+ const scrollW = truncatableText.scrollWidth;+ const offsetW = truncatableText.offsetWidth;+ const isTruncated = scrollW > offsetW;++ if (!isTruncated) {+ // If text is not truncated, aggressively hide the tooltip with !important+ // This overrides any hover CSS that might try to show it+ conditionalTooltip.style.cssText =+ 'display: none !important; opacity: 0 !important; visibility: hidden !important; pointer-events: none !important;';+ } else {+ // If text is truncated, reset styles to allow tooltip to show on hover+ conditionalTooltip.style.cssText = '';+ }+ };++ // Initial check on load - use requestAnimationFrame to ensure DOM is fully rendered+ requestAnimationFrame(() => {+ updateTooltipVisibility();+ });++ // Watch for parent element resize if provided (handles container width changes)+ let resizeObserver: ResizeObserver | null = null;++ if (parentElement && typeof ResizeObserver !== 'undefined') {+ resizeObserver = new ResizeObserver(() => {+ updateTooltipVisibility();+ });+ resizeObserver.observe(parentElement);+ }++ // Always listen to window resize+ const handleWindowResize = (): void => {+ updateTooltipVisibility();+ };+ window.addEventListener('resize', handleWindowResize);++ // Return cleanup function+ return () => {+ if (resizeObserver) {+ resizeObserver.disconnect();+ }+ window.removeEventListener('resize', handleWindowResize);+ };+}