Skip to content

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.

revert some changes

Ahmed Essam3f8d5cc101ad
diff --git a/packages/app/views/pages/partials/studio/left-sidebar-category.ejs b/packages/app/views/pages/partials/studio/left-sidebar-category.ejs
new file mode 100644
index 00000000..0fc6acb0
--- /dev/null
+++ b/packages/app/views/pages/partials/studio/left-sidebar-category.ejs
@@ -0,0 +1,168 @@
+<%
+let dynamic = (typeof entry === 'object' && entry?.type === 'dynamic');
+let sanitizedId = id.replace(/[^a-zA-Z0-9]/g, '');
+let category = id;
+const categoryIcon = icon || '';
+let cssstyle = '';
+let svgstyle = '';
+if (typeof color == 'string' && color) {
+ cssstyle += `color:${color};`;
+ svgstyle += `fill:${color};`;
+}
+%>
+<% if ((Array.isArray(entry) && entry.length > 0) || (!Array.isArray(entry) && entry)) { %>
+<li>
+ <div class="items-group-container navview-menu-group group-<%= category %>"
+ x-data="{
+ open: true,
+ hasItems: false,
+ observer: null,
+ storageKey: 'toggle<%= sanitizedId %>',
+
+ init() {
+ // Initialize from localStorage
+ this.open = localStorage.getItem(this.storageKey) !== 'false';
+
+ if (<%= dynamic %>) {
+ this.initDynamicCategory();
+ } else {
+ this.hasItems = true;
+ }
+ },
+
+ initDynamicCategory() {
+ // Initial check
+ this.checkItems();
+
+ // Set up observer
+ this.setupObserver();
+
+ // Fallback check every 500ms
+ setInterval(() => this.checkItems(), 500);
+ },
+
+ setupObserver() {
+ // Clean up existing observer if any
+ if (this.observer) {
+ this.observer.disconnect();
+ }
+
+ // Create new observer
+ this.observer = new MutationObserver(() => this.checkItems());
+
+ // Observe the entire document for changes
+ this.observer.observe(document.body, {
+ childList: true,
+ subtree: true
+ });
+ },
+
+ checkItems() {
+ const items = document.querySelectorAll('.comp-menuitem-list-<%= category %> li');
+ let hasValidItems = false;
+
+ // Check and clean up items
+ items.forEach(item => {
+ if (item.innerHTML.trim() !== '' && item.querySelector('a')) {
+ hasValidItems = true;
+ } else {
+ item.remove();
+ }
+ });
+
+ // Update state and auto-close if needed
+ this.hasItems = hasValidItems;
+ if (!hasValidItems && this.open) {
+ this.open = false;
+ localStorage.setItem(this.storageKey, 'false');
+ }
+ },
+
+ toggleOpen() {
+ if (this.hasItems) {
+ this.open = !this.open;
+ localStorage.setItem(this.storageKey, this.open);
+ }
+ }
+ }"
+ x-init="init()">
+ <div @click="toggleOpen()"
+ class="group-btn flex justify-between w-full text-sm items-center p-3 text-black transition duration-75 group bg-white"
+ :class="{ 'cursor-pointer': hasItems, 'cursor-default': !hasItems }"
+ :aria-expanded="hasItems ? open.toString() : 'false'"
+ aria-controls="<%= sanitizedId %>">
+ <div class="flex w-full items-center">
+ <div class="w-[calc(100%_-_16px)]">
+ <span class="flex-1 text-left flex items-center justify-between gap-2 select-none" sidebar-toggle-item>
+ <div class="flex items-center gap-2">
+ <% if (categoryIcon) { %>
+ <span class="icon" style="<%= cssstyle %>">
+ <% if (categoryIcon.startsWith('fa-')) { %>
+ <i class="<%= categoryIcon %>"></i>
+ <% } else if (categoryIcon.trim().startsWith('<svg')) { %>
+ <span class="svg-icon w-6 h-6">
+ <%- categoryIcon.match(/<path(?=.*?\sfill="[^"]*")[^>]*>/gm) ? categoryIcon : categoryIcon.replace(/<path /gm, '<path style="'+svgstyle+'"') %>
+ </span>
+ <% } else { %>
+ <span class="svg-icon <%= categoryIcon %> w-6 h-6"></span>
+ <% } %>
+ </span>
+ <% } %>
+ <span class="name max-w-[150px] truncate inline-block"><%= label %></span>
+ </div>
+ <% if (dynamic) { %>
+ <button id="btn-import-<%= category %>"
+ @click.stop
+ class="btn-import outline-1 outline-gray-200 cursor-pointer items-center justify-center w-4 h-4 p-2 text-sm font-medium text-gray-500 bg-gray-200 rounded-sm hover:text-white hover:font-bold hover:bg-gray-400 inline-flex">+</button>
+ <% } %>
+ </span>
+ </div>
+ <template x-if="hasItems">
+ <i class="text-xs fa-solid fa-chevron-down transition-transform duration-200"
+ :class="open ? 'rotate-0' : '-rotate-90'"></i>
+ </template>
+ </div>
+ </div>
+
+ <% if (!dynamic) { %>
+ <!-- Static category content -->
+ <ul id="<%= sanitizedId %>"
+ x-show="open"
+ class="items-group space-y-2 py-2 origin-top"
+ x-transition:enter="transition ease-out duration-200"
+ x-transition:enter-start="opacity-0 transform scale-y-50"
+ x-transition:enter-end="opacity-100 transform scale-y-100"
+ x-transition:leave="transition ease-out duration-100"
+ x-transition:leave-end="opacity-0 transform scale-y-50">
+
+ <% entry.forEach((item, index) => { %>
+ <%- include('left-sidebar-cptItem', {
+ name: item.name,
+ level: 1,
+ description: item.description,
+ label: item.label||item.name,
+ visible: (typeof item.visible === 'undefined') || item.visible,
+ color: item.color,
+ icon: item.icon||item.name,
+ attributes: item.attributes||{},
+ children: item.children,
+ externalLink: item.externalLink
+ }) %>
+ <% }) %>
+ </ul>
+ <% } else { %>
+ <!-- Dynamic category content -->
+ <ul id="<%= sanitizedId %>"
+ x-show="hasItems && open"
+ x-cloak
+ class="comp-menuitem-list comp-menuitem-list-<%= category %> py-2 space-y-2"
+ x-transition:enter="transition ease-out duration-200"
+ x-transition:enter-start="opacity-0 transform scale-y-50"
+ x-transition:enter-end="opacity-100 transform scale-y-100"
+ x-transition:leave="transition ease-out duration-100"
+ x-transition:leave-end="opacity-0 transform scale-y-50">
+ </ul>
+ <% } %>
+ </div>
+</li>
+<% } %>
\ No newline at end of file
diff --git a/packages/app/views/pages/partials/studio/left-sidebar-cptItem.ejs b/packages/app/views/pages/partials/studio/left-sidebar-cptItem.ejs
new file mode 100644
index 00000000..fad8b673
--- /dev/null
+++ b/packages/app/views/pages/partials/studio/left-sidebar-cptItem.ejs
@@ -0,0 +1,109 @@
+<li title="<%= label %>">
+ <%
+ let cssstyle = '';
+ let svgstyle = '';
+ if (typeof color == 'string' && color) {
+ cssstyle += `color:${color};`;
+ svgstyle += `fill:${color};`;
+ }
+ if (typeof children !== 'undefined' && Array.isArray(children)) {
+ let sanitizedId = name.replace(/[^a-zA-Z0-9]/g, '');
+ %>
+ <div class="items-group-container px-2 <%=(!visible || children.length < 1)?'hidden':''%>" x-data="{ open: false }"
+ x-init="open = localStorage.getItem('toggle<%= sanitizedId %>') === 'true'">
+
+ <button @click="open = !open; localStorage.setItem('toggle<%= sanitizedId %>', open)"
+ class="group-btn group flex w-full max-w-[232px] items-center px-2 py-2 text-sm text-black rounded-md bg-gray-100"
+ :aria-expanded="open.toString()" aria-controls="<%= sanitizedId %>">
+
+ <span class="icon" style="<%= cssstyle %>">
+ <% if (icon.startsWith('fa-')) { %>
+ <i class="<%= icon %>"></i>
+ <% } else if (icon.trim().startsWith('<svg')) { %>
+ <span class="svg-icon w-6 h-6">
+ <%- icon.match(/<path(?=.*?\sfill="[^"]*")[^>]*>/gm) ? icon : icon.replace(/<path /gm, '<path style="'+svgstyle+'"') %>
+ </span>
+ <% } else { %>
+ <span class="svg-icon <%= icon %> w-6 h-6"></span>
+ <% } %>
+ </span>
+
+ <span class="flex-1 ml-2 whitespace-nowrap text-left max-w-[150px] truncate select-none" data-label="<%= label %>" data-group="true"
+ sidebar-toggle-item><span class="name"><%= label %></span></span>
+
+ <span class="expand-btn cursor-pointer items-center justify-center
+ w-3.5 h-3.5 p-1 ml-2 text-xs font-semibold border
+ border-solid border-gray-800 text-gray-800 rounded-full inline-flex" x-text="open ? '-' : '+'"></span>
+ </button>
+
+ <ul id="<%= sanitizedId %>" x-show="open" x-cloak class="items-group py-2 space-y-2">
+ <% children.forEach((item, index) => { %>
+ <%- include('left-sidebar-cptItem', { name: item.name, level:2, description: item.description, visible: (typeof item.visible === 'undefined') || item.visible, color:item.color||color, label:item.label||item.name, icon:item.icon||icon||item.name, attributes:item.attributes||{}, children:item.children }) %>
+ <% }) %>
+ </ul>
+ </div>
+ <% } else {
+ if (visible || isSmythStaff) {
+ %>
+ <div class="h-9" data-visible="<%= visible%>">
+ <% if (typeof externalLink !== 'undefined') { %>
+ <a href="<%= externalLink %>" target="_blank" rel="noopener noreferrer"
+ class="group flex items-center justify-between h-full pr-2 text-sm rounded-md bg-white <%=level==1 ? 'mx-2 pl-2': 'pl-1'%> text-black">
+ <% if (icon) { %>
+ <span class="icon" style="<%= cssstyle %>">
+ <% if (icon.startsWith('fa')) { %>
+ <i class="<%= icon %>"></i>
+ <% } else if (icon.trim().startsWith('<svg')) { %>
+ <span class="svg-icon w-6 h-6">
+ <%- icon.match(/<path(?=.*?\sfill="[^"]*")[^>]*>/gm) ? icon : icon.replace(/<path /gm, '<path style="'+svgstyle+'"') %>
+ </span>
+ <% } else { %>
+ <span class="svg-icon <%= icon %> w-6 h-6"></span>
+ <% } %>
+ </span>
+ <% } %>
+ <span class="name flex-1 whitespace-nowrap max-w-[150px] truncate"><%= label %></span>
+ <span class="external-link-icon">
+ <svg class="w-4 h-4" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <path d="M3.5 3C3.22386 3 3 3.22386 3 3.5C3 3.77614 3.22386 4 3.5 4H7.29289L2.64645 8.64645C2.45118 8.84171 2.45118 9.15829 2.64645 9.35355C2.84171 9.54882 3.15829 9.54882 3.35355 9.35355L8 4.70711V8.5C8 8.77614 8.22386 9 8.5 9C8.77614 9 9 8.77614 9 8.5V3.5C9 3.22386 8.77614 3 8.5 3H3.5Z" fill="currentColor"/>
+ </svg>
+ </span>
+ </a>
+ <% } else { %>
+ <a href="#" data-label="<%= label %>"
+ class="group flex items-center justify-between h-full pr-2 text-sm rounded-md bg-white <%=level==1 ? 'mx-2 pl-2': 'pl-1'%> <%= visible ? 'text-black' : 'text-red-600' %>"
+ smt-component="<%= name %>" <% for (const attr in attributes) { %><%= attr %>="<%= attributes[attr] %>"
+ <% } %>>
+
+ <span class="icon" style="<%= cssstyle %>">
+ <% if (icon?.startsWith('fa')) { %>
+ <i class="<%= icon %>"></i>
+ <% } else if (icon?.trim()?.startsWith('<svg')) { %>
+ <span class="svg-icon w-6 h-6">
+ <%- icon?.match(/<path(?=.*?\sfill="[^"]*")[^>]*>/gm) ? icon : icon?.replace(/<path /gm, '<path style="'+svgstyle+'"') %>
+ </span>
+ <% } else { %>
+ <span class="svg-icon <%= icon %> w-6 h-6"></span>
+ <% } %>
+ </span>
+
+ <span class="name flex-1 whitespace-nowrap max-w-[150px] truncate"><%= label %></span>
+
+ <span class="cursor-grab [.dragging_&]:hidden">
+ <svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M9.26468 18.2891C9.82267 18.2891 10.2754 18.7413 10.2754 19.2998C10.2754 19.8576 9.82326 20.3106 9.26468 20.3106C8.70609 20.3106 8.25391 19.8576 8.25391 19.2998C8.25391 18.7413 8.70669 18.2891 9.26468 18.2891Z" fill="#797979"/>
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M9.26468 12.2656C9.82267 12.2656 10.2754 12.7179 10.2754 13.2763C10.2754 13.8342 9.82326 14.2872 9.26468 14.2872C8.70609 14.2872 8.25391 13.8342 8.25391 13.2763C8.25391 12.7179 8.70669 12.2656 9.26468 12.2656Z" fill="#797979"/>
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M9.26468 6.24609C9.82267 6.24609 10.2754 6.69833 10.2754 7.25679C10.2754 7.81467 9.82326 8.26765 9.26468 8.26765C8.70609 8.26765 8.25391 7.81467 8.25391 7.25679C8.25391 6.69832 8.70669 6.24609 9.26468 6.24609Z" fill="#797979"/>
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M15.7334 18.2891C16.2914 18.2891 16.7442 18.7413 16.7442 19.2998C16.7442 19.8576 16.292 20.3106 15.7334 20.3106C15.1748 20.3106 14.7227 19.8576 14.7227 19.2998C14.7227 18.7413 15.1754 18.2891 15.7334 18.2891Z" fill="#797979"/>
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M15.7334 12.2656C16.2914 12.2656 16.7442 12.7179 16.7442 13.2763C16.7442 13.8342 16.292 14.2872 15.7334 14.2872C15.1748 14.2872 14.7227 13.8342 14.7227 13.2763C14.7227 12.7179 15.1754 12.2656 15.7334 12.2656Z" fill="#797979"/>
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M15.7334 6.24609C16.2914 6.24609 16.7442 6.69833 16.7442 7.25679C16.7442 7.81467 16.292 8.26765 15.7334 8.26765C15.1748 8.26765 14.7227 7.81467 14.7227 7.25679C14.7227 6.69832 15.1754 6.24609 15.7334 6.24609Z" fill="#797979"/>
+ </svg>
+ </span>
+ </a>
+ <% } %>
+ </div>
+ <%
+ }
+ } %>
+
+</li>
\ No newline at end of file