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
Enhance CanvasContextMenu with component selection functionality
Muhammad Hamza Khan5178926aa00d
diff --git a/packages/app/src/builder-ui/workspace/CanvasContextMenu.ts b/packages/app/src/builder-ui/workspace/CanvasContextMenu.tsindex 74462e32..de500ea1 100644--- a/packages/app/src/builder-ui/workspace/CanvasContextMenu.ts+++ b/packages/app/src/builder-ui/workspace/CanvasContextMenu.ts@@ -46,9 +46,44 @@ function buildMenuItem(label: string, onClick: () => void, disabled = false): HTreturn item;}+/**+ * Find the component element that was right-clicked+ */+function findClickedComponent(event: MouseEvent): HTMLElement | null {+ // If there's already a selection, don't try to select a component+ if (document.querySelectorAll('.component.selected').length > 1) return;++ const target = event.target as HTMLElement;+ // Check if the target is a component or is inside a component+ const component = target.closest('.component') as HTMLElement;+ return component;+}++/**+ * Select a component and update the workspace selection+ */+function selectComponent(workspace: Workspace, component: HTMLElement): void {+ // Clear any existing selection+ document.querySelectorAll('.component.selected').forEach((c) => c.classList.remove('selected'));++ // Select the clicked component+ component.classList.add('selected');++ // Update workspace selection state+ workspace.refreshComponentSelection(component);+}+async function createAndShowMenu(event: MouseEvent, workspace: Workspace) {destroyMenu();+ // Find if we clicked on a component+ const clickedComponent = findClickedComponent(event);++ // If we clicked on a component, select it+ if (clickedComponent) {+ selectComponent(workspace, clickedComponent);+ }+const containerRect = workspace.container.getBoundingClientRect();const workspaceRect = workspace.domElement.getBoundingClientRect();