Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
refactor(ui): CollapsibleSection -> shadcn Collapsible; NodeContextMenu styling -> Tailwind
trohitgec428cad10ec
diff --git a/client/src/components/ui/CollapsibleSection.tsx b/client/src/components/ui/CollapsibleSection.tsxindex 3fba8ed5..27fef738 100644--- a/client/src/components/ui/CollapsibleSection.tsx+++ b/client/src/components/ui/CollapsibleSection.tsx@@ -1,6 +1,11 @@import React from 'react';-import * as Collapsible from '@radix-ui/react-collapsible';-import { useAppTheme } from '../../hooks/useAppTheme';+import { ChevronDown } from 'lucide-react';+import { cn } from '@/lib/utils';+import {+ Collapsible,+ CollapsibleContent,+ CollapsibleTrigger,+} from '@/components/ui/collapsible';interface CollapsibleSectionProps {title: string | React.ReactNode;@@ -13,76 +18,32 @@ const CollapsibleSection: React.FC<CollapsibleSectionProps> = ({title,isCollapsed,onToggle,- children+ children,}) => {- const theme = useAppTheme();+ const open = !isCollapsed;return (- <Collapsible.Root open={!isCollapsed} onOpenChange={() => onToggle()}>- <div style={{- backgroundColor: theme.colors.background,- borderRadius: theme.borderRadius.lg,- overflow: 'hidden',- border: `1px solid ${theme.colors.border}`,- }}>- <Collapsible.Trigger- style={{- display: 'flex',- alignItems: 'center',- justifyContent: 'space-between',- width: '100%',- padding: `${theme.spacing.md} ${theme.spacing.lg}`,- backgroundColor: theme.colors.backgroundAlt,- border: 'none',- cursor: 'pointer',- fontFamily: 'system-ui, sans-serif',- fontSize: theme.fontSize.base,- color: theme.colors.text,- transition: `all ${theme.transitions.fast}`,- }}- onMouseEnter={(e) => {- e.currentTarget.style.backgroundColor = theme.colors.backgroundPanel;- }}- onMouseLeave={(e) => {- e.currentTarget.style.backgroundColor = theme.colors.backgroundAlt;- }}- >+ <Collapsible open={open} onOpenChange={() => onToggle()}>+ <div className="overflow-hidden rounded-lg border border-border bg-background">+ <CollapsibleTrigger className="flex w-full cursor-pointer items-center justify-between gap-2 border-none bg-muted px-4 py-3 text-base text-foreground transition-colors hover:bg-card">{typeof title === 'string' ? (- <>- <span style={{ fontWeight: theme.fontWeight.medium }}>{title}</span>- <span style={{- transform: isCollapsed ? 'rotate(-90deg)' : 'rotate(0deg)',- transition: `transform ${theme.transitions.fast}`,- fontSize: '12px',- color: theme.colors.textSecondary,- }}>- ▼- </span>- </>+ <span className="font-medium">{title}</span>) : (- <>- {title}- <span style={{- transform: isCollapsed ? 'rotate(-90deg)' : 'rotate(0deg)',- transition: `transform ${theme.transitions.fast}`,- fontSize: '12px',- color: theme.colors.textSecondary,- marginLeft: 'auto',- }}>- ▼- </span>- </>+ <div className="flex flex-1 items-center">{title}</div>)}- </Collapsible.Trigger>+ <ChevronDown+ className={cn(+ 'h-3 w-3 shrink-0 text-muted-foreground transition-transform',+ isCollapsed && '-rotate-90'+ )}+ />+ </CollapsibleTrigger>- <Collapsible.Content style={{- padding: isCollapsed ? 0 : theme.spacing.md,- transition: `padding ${theme.transitions.fast}`,- }}>+ <CollapsibleContent className={cn('transition-[padding]', open && 'p-3')}>{children}- </Collapsible.Content>+ </CollapsibleContent></div>- </Collapsible.Root>+ </Collapsible>);};-export default CollapsibleSection;\ No newline at end of file+export default CollapsibleSection;diff --git a/client/src/components/ui/NodeContextMenu.tsx b/client/src/components/ui/NodeContextMenu.tsxindex 0fdabc47..4654d36b 100644--- a/client/src/components/ui/NodeContextMenu.tsx+++ b/client/src/components/ui/NodeContextMenu.tsx@@ -2,10 +2,14 @@* NodeContextMenu - Right-click context menu for nodes** Provides actions: Rename, Copy, Delete- * Follows n8n-style UX patterns with keyboard shortcuts displayed+ * Hand-rolled positioning at cursor coords (Radix DropdownMenu attaches to+ * a trigger, which doesn't fit the right-click-anywhere pattern). Visual+ * style mirrors shadcn DropdownMenuContent so it lives consistently with+ * the rest of the surface.*/import React, { useEffect, useRef, useCallback } from 'react';-import { useAppTheme } from '../../hooks/useAppTheme';+import { Pencil, Copy as CopyIcon, Trash2 } from 'lucide-react';+import { cn } from '@/lib/utils';interface NodeContextMenuProps {nodeId: string;@@ -21,7 +25,7 @@ interface MenuItem {label: string;shortcut: string;action: () => void;- icon: string;+ Icon: typeof Pencil;danger?: boolean;}@@ -34,32 +38,28 @@ const NodeContextMenu: React.FC<NodeContextMenuProps> = ({onCopy,onDelete,}) => {- const theme = useAppTheme();const menuRef = useRef<HTMLDivElement>(null);const [focusedIndex, setFocusedIndex] = React.useState(0);const menuItems: MenuItem[] = [- { label: 'Rename', shortcut: 'F2', action: onRename, icon: '✏️' },- { label: 'Copy', shortcut: 'Ctrl+C', action: onCopy, icon: '📋' },- { label: 'Delete', shortcut: 'Del', action: onDelete, icon: '🗑️', danger: true },+ { label: 'Rename', shortcut: 'F2', action: onRename, Icon: Pencil },+ { label: 'Copy', shortcut: 'Ctrl+C', action: onCopy, Icon: CopyIcon },+ { label: 'Delete', shortcut: 'Del', action: onDelete, Icon: Trash2, danger: true },];// Calculate menu position to avoid overflowconst getMenuPosition = useCallback(() => {const menuWidth = 180;- const menuHeight = menuItems.length * 36 + 16; // items + padding+ const menuHeight = menuItems.length * 36 + 16;const viewportWidth = window.innerWidth;const viewportHeight = window.innerHeight;let left = x;let top = y;- // Prevent overflow on rightif (x + menuWidth > viewportWidth) {left = viewportWidth - menuWidth - 8;}-- // Prevent overflow on bottomif (y + menuHeight > viewportHeight) {top = viewportHeight - menuHeight - 8;}@@ -69,26 +69,20 @@ const NodeContextMenu: React.FC<NodeContextMenuProps> = ({const position = getMenuPosition();- // Handle click outside to close+ // Click outside / EscapeuseEffect(() => {const handleClickOutside = (event: MouseEvent) => {if (menuRef.current && !menuRef.current.contains(event.target as Node)) {onClose();}};-const handleEscape = (event: KeyboardEvent) => {- if (event.key === 'Escape') {- onClose();- }+ if (event.key === 'Escape') onClose();};-- // Add listeners with small delay to avoid immediate closeconst timeoutId = setTimeout(() => {document.addEventListener('mousedown', handleClickOutside);document.addEventListener('keydown', handleEscape);}, 0);-return () => {clearTimeout(timeoutId);document.removeEventListener('mousedown', handleClickOutside);@@ -96,7 +90,7 @@ const NodeContextMenu: React.FC<NodeContextMenuProps> = ({};}, [onClose]);- // Handle keyboard navigation+ // Keyboard navigationuseEffect(() => {const handleKeyDown = (event: KeyboardEvent) => {switch (event.key) {@@ -115,12 +109,10 @@ const NodeContextMenu: React.FC<NodeContextMenuProps> = ({break;}};-document.addEventListener('keydown', handleKeyDown);return () => document.removeEventListener('keydown', handleKeyDown);}, [focusedIndex, menuItems, onClose]);- // Focus the menu on mountuseEffect(() => {menuRef.current?.focus();}, []);@@ -134,57 +126,33 @@ const NodeContextMenu: React.FC<NodeContextMenuProps> = ({<divref={menuRef}tabIndex={-1}- style={{- position: 'fixed',- left: position.left,- top: position.top,- backgroundColor: theme.colors.backgroundElevated,- border: `1px solid ${theme.isDarkMode ? theme.colors.border : '#d1d5db'}`,- borderRadius: theme.borderRadius.lg,- boxShadow: theme.isDarkMode- ? `0 4px 12px ${theme.colors.shadow}`- : '0 4px 16px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08)',- padding: theme.spacing.xs,- zIndex: 10000,- minWidth: '160px',- outline: 'none',- }}+ // Position is dynamic (cursor coords) — must stay inline.+ style={{ left: position.left, top: position.top }}+ className="fixed z-[10000] min-w-[160px] rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-md outline-none">- {menuItems.map((item, index) => (- <div- key={item.label}- onClick={() => handleItemClick(item)}- onMouseEnter={() => setFocusedIndex(index)}- style={{- display: 'flex',- alignItems: 'center',- justifyContent: 'space-between',- padding: `${theme.spacing.sm} ${theme.spacing.md}`,- borderRadius: theme.borderRadius.md,- cursor: 'pointer',- backgroundColor: focusedIndex === index- ? theme.colors.backgroundHover- : 'transparent',- color: item.danger ? theme.dracula.red : theme.colors.text,- fontSize: theme.fontSize.sm,- transition: theme.transitions.fast,- }}- >- <div style={{ display: 'flex', alignItems: 'center', gap: theme.spacing.sm }}>- <span style={{ fontSize: theme.fontSize.sm }}>{item.icon}</span>- <span style={{ fontWeight: theme.fontWeight.medium }}>{item.label}</span>- </div>- <span- style={{- fontSize: theme.fontSize.xs,- color: theme.colors.textMuted,- fontFamily: 'monospace',- }}+ {menuItems.map((item, index) => {+ const focused = focusedIndex === index;+ return (+ <div+ key={item.label}+ onClick={() => handleItemClick(item)}+ onMouseEnter={() => setFocusedIndex(index)}+ className={cn(+ 'flex cursor-pointer items-center justify-between gap-2 rounded-md px-2 py-1.5 text-sm transition-colors',+ focused && 'bg-muted',+ item.danger ? 'text-destructive' : 'text-foreground'+ )}>- {item.shortcut}- </span>- </div>- ))}+ <div className="flex items-center gap-2">+ <item.Icon className="h-3.5 w-3.5" />+ <span className="font-medium">{item.label}</span>+ </div>+ <span className="font-mono text-xs text-muted-foreground">+ {item.shortcut}+ </span>+ </div>+ );+ })}</div>);};