UI Component Patterns
This page documents the reusable component patterns used throughout the Automatos AI frontend. These patterns establish consistency across all major pages (Agents, Workflows, Documents, Tools, etc.) and provide a composable architecture for building complex UIs with minimal code duplication.
For information about the overall frontend architecture and state management, see 14.1 and 14.2. For specific API integration patterns, see 14.3.
Overview
The frontend follows a shared component composition pattern where complex pages are assembled from reusable building blocks. All major management pages (Agent Management, Workflow Management, Document Management, Tools Dashboard) use identical structural patterns but compose different content within them.
Key Design Principles:
Composition over duplication: Shared components handle layout, animations, and state patterns
Consistent user experience: Same navigation, filtering, and action patterns across all pages
Type-safe props: TypeScript interfaces ensure correct component usage
Responsive by default: Mobile-first design with tablet/desktop enhancements
Loading state handling: Skeleton UIs during data fetching, error displays on failure
Sources: frontend/components/agents/agent-management.tsx:1-284, frontend/components/workflows/workflow-management.tsx:1-750, frontend/components/documents/document-management.tsx:1-1247
Standard Page Structure Pattern
All management pages follow a five-tier hierarchy:
Diagram: Standard Page Hierarchy
This structure appears in:
Agent Management: frontend/components/agents/agent-management.tsx:127-283
Workflow Management: frontend/components/workflows/workflow-management.tsx:536-748
Document Management: frontend/components/documents/document-management.tsx:556-1247
Tools Dashboard: frontend/components/tools/tools-dashboard.tsx:634-1440
Sources: frontend/components/agents/agent-management.tsx:127-283, frontend/components/workflows/workflow-management.tsx:536-748
Shared Component Library
PageHeader Component
The PageHeader component provides consistent page titles with optional accent text and action buttons.
Usage Pattern:
Props Interface:
title: string- Primary title texttitleAccent?: string- Gradient-styled accent textsubtitle?: string- Description below titleactions?: ReactNode- Right-aligned action buttons
The gradient styling on titleAccent uses the .gradient-text CSS class for consistent brand theming across all pages.
Sources: frontend/components/agents/agent-management.tsx:131-163, frontend/components/workflows/workflow-management.tsx:540-555, frontend/components/tools/tools-dashboard.tsx:637-649
StatsBar Component
The StatsBar displays 4 metric cards in a responsive grid, used on every management page.
Diagram: StatsBar Component Structure
StatItem Interface:
Example Usage:
The component automatically handles:
Loading skeleton states when
loading={true}Responsive grid: 2 columns on mobile, 4 on desktop
Consistent card styling with glass morphism effect
Icon rendering with specified colors
Sources: frontend/components/agents/agent-management.tsx:78-107, frontend/components/agents/agent-management.tsx:182, frontend/components/workflows/workflow-management.tsx:558-569
SearchInput Component
Provides a consistent search interface with icon and placeholder text.
Props:
value: string- Controlled input valueonChange: (value: string) => void- Change handlerplaceholder?: string- Search field placeholderclassName?: string- Additional styling
The component includes:
Magnifying glass icon positioned inside input
Debounced filtering (implementation in parent component)
Consistent styling matching the design system
Sources: frontend/components/agents/agent-management.tsx:191-196, frontend/components/workflows/workflow-management.tsx:590-597
FilterTabs Component
The FilterTabs component provides tab navigation with optional trailing elements (like ViewToggle).
Tab Definition Structure:
Sources: frontend/components/agents/agent-management.tsx:119-126, frontend/components/agents/agent-management.tsx:229-262
ViewToggle Component
Switches between grid and list view modes, with state persisted via useViewMode hook.
Usage:
The component renders two icon buttons (Grid3x3 and List icons) with active state styling. View mode preference is saved to localStorage and restored on page reload.
Sources: frontend/components/agents/agent-management.tsx:24-25, frontend/components/agents/agent-management.tsx:42, frontend/components/agents/agent-management.tsx:229
Modal Management Pattern
All pages use a consistent state-driven modal pattern with dedicated state variables and handler functions.
Diagram: Modal State Management Flow
Standard Modal State Pattern:
Common Modal Types:
Creation Modals: Create new resources (agents, workflows, recipes)
Details Modals: View/edit resource details with tabs
Confirmation Modals: Delete confirmations, destructive actions
Configuration Modals: Settings and configuration forms
Sources: frontend/components/agents/agent-management.tsx:44-46, frontend/components/agents/agent-management.tsx:113-117, frontend/components/agents/agent-management.tsx:264-282
Tab-Based Navigation Pattern
Complex pages use nested tabs for organizing related content.
Diagram: Nested Tabs Pattern in Document Management
Outer Tabs Structure:
Inner Tabs Structure:
This nested structure is used extensively in:
Document Management: frontend/components/documents/document-management.tsx:634-722
Tools Dashboard: frontend/components/tools/tools-dashboard.tsx:1149-1440
Workflow Management: frontend/components/workflows/workflow-management.tsx:577-675
Sources: frontend/components/documents/document-management.tsx:634-722, frontend/components/tools/tools-dashboard.tsx:1149-1440
Loading and Error States
All pages implement skeleton loading states and error displays using a consistent pattern.
Skeleton Loading Pattern
Key Characteristics:
Only shown on initial load (not on refetch/pagination)
Matches the layout of actual content
Uses
bg-secondary/50for skeleton elementsAnimates with pulse effect (optional)
Sources: frontend/components/tools/tools-dashboard.tsx:400-456
Error Display Pattern
Error Display Features:
Styled with destructive color scheme
Includes descriptive error message
Provides retry action button
Positioned below page header, above content
Sources: frontend/components/agents/agent-management.tsx:165-179, frontend/components/workflows/workflow-management.tsx:613-624
Card-Based Content Display
Content is displayed using card components with hover effects and consistent styling.
Grid View Cards
Styling Classes:
glass-card- Glass morphism background effectcard-glow- Subtle glow on hoverhover:border-primary/20- Border color transition on hover
Sources: frontend/components/tools/tools-dashboard.tsx:1260-1320
List View Pattern
List view uses a more compact layout with rows:
Sources: frontend/components/tools/tools-dashboard.tsx:1326-1393
Pagination Pattern
Pages with large datasets use the EnhancedPagination component.
Diagram: Pagination Data Flow
Implementation:
Dynamic Page Size: The page size adjusts based on view mode:
Grid view: 20 items per page (4 columns × 5 rows)
List view: 60 items per page (3 columns × 20 rows)
This provides optimal scrolling experience in each view mode.
Sources: frontend/components/tools/tools-dashboard.tsx:126-142, frontend/components/tools/tools-dashboard.tsx:153-163, frontend/components/tools/tools-dashboard.tsx:1419-1425
Responsive Design Patterns
Mobile-First Layout
All components use responsive Tailwind classes:
Breakpoint Strategy:
Base (mobile): Single column layouts
md:(tablet, ≥768px): 2-column grids, show more infolg:(desktop, ≥1024px): 3-4 column grids, full features
Mobile Sidebar Pattern
The sidebar uses different implementations for mobile vs desktop:
The useIsTabletOrBelow() hook determines which layout to render based on screen size.
Sources: frontend/components/layout/main-layout.tsx:23, frontend/components/layout/main-layout.tsx:63-88
Responsive Text Truncation
Long text fields use truncation with tooltips:
The truncate class applies:
overflow: hiddentext-overflow: ellipsiswhite-space: nowrap
Sources: frontend/components/agents/agent-management.tsx:229-244
Motion and Animation Patterns
All pages use Framer Motion for smooth transitions.
Page Entry Animation
Animation Characteristics:
initial: Start invisible and slightly belowanimate: Fade in and slide up when in viewduration: 0.8s for smooth, professional feeltriggerOnce: Animation only happens once
Staggered List Animation
List items animate with stagger delay:
Each item has a delay: index * 0.1, creating a cascading effect.
Sources: frontend/components/agents/agent-management.tsx:72-75, frontend/components/agents/agent-management.tsx:185-196, frontend/components/layout/sidebar.tsx:199-204
Settings Page Pattern
Settings pages use a tab-based layout with dedicated tab components.
Diagram: Settings Panel Component Structure
Tab Structure:
Key Features:
Each tab is a self-contained component
Tabs handle their own data fetching and state
Icons use
shrink-0to prevent flexbox squashingResponsive labels hide on small screens:
<span className="hidden sm:inline">
Sources: frontend/components/settings/SettingsPanel.tsx:15-113
Role-Based UI Filtering
Components filter content based on user roles using the useSystemRole hook.
Sidebar Navigation Filtering
Navigation Item Definition:
Conditional Rendering:
This pattern ensures admin-only features are completely hidden from non-admin users, not just disabled.
Sources: frontend/components/layout/sidebar.tsx:108-114, frontend/components/layout/sidebar.tsx:248-276
Component Composition Example
Here's how the patterns compose together in a typical page:
Diagram: Complete Page Component Composition
The data flow:
React Query hooks fetch data from API
Page component manages state (search, filters, modals)
Shared components render consistent UI elements
Tab content components display filtered/paginated data
Modal components handle creation/editing actions
Sources: frontend/components/agents/agent-management.tsx:40-284
Key Takeaways
PageHeader
Consistent page titles and actions
Reusable component with title/subtitle/actions props
StatsBar
Display key metrics
4-card grid with icons, values, and change indicators
FilterTabs
Tab navigation with trailing controls
Wrapper around shadcn Tabs with ViewToggle support
Modal Management
Controlled modals for actions
State variables + handler functions + conditional rendering
Skeleton Loading
Initial load state
Layout-matching skeletons, only on first load
Error Display
API error handling
Destructive-styled cards with retry buttons
Responsive Grid
Mobile-first layouts
grid-cols-1 md:grid-cols-2 lg:grid-cols-4 pattern
Motion Animations
Smooth page transitions
Framer Motion with useInView for scroll-triggered animations
Role Filtering
Admin-only features
useSystemRole hook + conditional rendering
Pagination
Large dataset navigation
EnhancedPagination component with API integration
All patterns prioritize:
Consistency: Same patterns across all pages
Type Safety: TypeScript interfaces for all props
Accessibility: Proper ARIA labels and keyboard navigation
Performance: Only render what's visible, lazy load modals
Developer Experience: Reusable components reduce boilerplate
Sources: frontend/components/agents/agent-management.tsx:1-284, frontend/components/workflows/workflow-management.tsx:1-750, frontend/components/documents/document-management.tsx:1-1247, frontend/components/tools/tools-dashboard.tsx:1-1440, frontend/components/layout/sidebar.tsx:1-280, frontend/components/settings/SettingsPanel.tsx:1-116
Last updated

