From 9e4566cc1d2126fe7ddc46167cc1d208fb3ae086 Mon Sep 17 00:00:00 2001 From: chihlasm Date: Sun, 15 Mar 2026 15:15:56 -0400 Subject: [PATCH] feat: restructure sidebar with stats bar, activity feed, and grouped nav Dashboard-first layout with Resolve/Build/Insights groups. AI split: FlowPilot (Resolve) + Flow Assist (Build). Stats bar: Resolved/Active/In Session daily counters. Activity feed: active sessions with CW ticket #, recent completions. Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/components/layout/Sidebar.tsx | 116 +++++++++++---------- 1 file changed, 63 insertions(+), 53 deletions(-) diff --git a/frontend/src/components/layout/Sidebar.tsx b/frontend/src/components/layout/Sidebar.tsx index 03ecb6da..1bda0fb1 100644 --- a/frontend/src/components/layout/Sidebar.tsx +++ b/frontend/src/components/layout/Sidebar.tsx @@ -1,11 +1,17 @@ import { useEffect, useState } from 'react' -import { LayoutGrid, Network, Wrench, Clock, FileOutput, BarChart3, Settings, PanelLeftClose, PanelLeftOpen, MessageSquareText, BotMessageSquare, BookOpen, Lightbulb, Code2, Library } from 'lucide-react' +import { useLocation } from 'react-router-dom' +import { + LayoutGrid, Network, Wrench, Clock, FileOutput, BarChart3, + Settings, PanelLeftClose, PanelLeftOpen, MessageSquareText, + BookOpen, Lightbulb, Code2, Library, Brain, WandSparkles, +} from 'lucide-react' import { cn } from '@/lib/utils' import { useUserPreferencesStore } from '@/store/userPreferencesStore' -import { usePinnedFlowsStore } from '@/store/pinnedFlowsStore' -import { PinnedFlowsSection } from '@/components/sidebar/PinnedFlowsSection' +import { sidebarApi } from '@/api' +import type { SidebarStatsResponse } from '@/api/sidebar' +import { SidebarStatsBar } from '@/components/sidebar/SidebarStatsBar' +import { SidebarActivityFeed } from '@/components/sidebar/SidebarActivityFeed' import { NavItem } from './NavItem' -import { sessionsApi, treesApi } from '@/api' // Semantic icon colors — each nav item gets a unique color for visual landmarks const NAV_COLORS = { @@ -14,7 +20,8 @@ const NAV_COLORS = { editor: '#f59e0b', // amber-500 sessions: '#34d399', // emerald-400 exports: '#60a5fa', // blue-400 - ai: '#e879f9', // fuchsia-400 + flowPilot: '#e879f9', // fuchsia-400 + flowAssist:'#f472b6', // pink-400 stepLib: '#fb923c', // orange-400 scripts: '#2dd4bf', // teal-400 kb: '#fb7185', // rose-400 @@ -26,40 +33,14 @@ const NAV_COLORS = { export function Sidebar() { const sidebarCollapsed = useUserPreferencesStore(s => s.sidebarCollapsed) const toggleSidebar = useUserPreferencesStore(s => s.toggleSidebar) + const location = useLocation() - const pinnedItems = usePinnedFlowsStore((s) => s.items) - const loadPinned = usePinnedFlowsStore((s) => s.load) - const unpinFlow = usePinnedFlowsStore((s) => s.unpin) + const [stats, setStats] = useState(null) - const [activeSessionCount, setActiveSessionCount] = useState(0) - const [treeCounts, setTreeCounts] = useState({ total: 0, troubleshooting: 0, procedural: 0, maintenance: 0 }) - - // Load pinned flows on mount + // Fetch sidebar stats — refreshes on navigation useEffect(() => { - loadPinned() - }, [loadPinned]) - - // Fetch sidebar data on mount - useEffect(() => { - const fetchData = async () => { - try { - const [activeSessions, allTrees] = await Promise.all([ - sessionsApi.list({ completed: false, size: 50 }).catch(() => []), - treesApi.list({ sort_by: 'name' }).catch(() => []), - ]) - setActiveSessionCount(activeSessions.length) - - const total = allTrees.length - const troubleshooting = allTrees.filter(t => t.tree_type === 'troubleshooting').length - const procedural = allTrees.filter(t => t.tree_type === 'procedural').length - const maintenance = allTrees.filter(t => t.tree_type === 'maintenance').length - setTreeCounts({ total, troubleshooting, procedural, maintenance }) - } catch { - // Silently handle errors - } - } - fetchData() - }, []) + sidebarApi.getStats().then(setStats).catch(() => {}) + }, [location.pathname]) const handleSidebarWheel = (e: React.WheelEvent) => { const sidebar = e.currentTarget @@ -93,14 +74,15 @@ export function Sidebar() { {/* Collapsed: icon-only nav */}
+ - - - - - + + + + + @@ -108,34 +90,62 @@ export function Sidebar() { ) : ( <> - {/* Pinned Flows */} - + {/* Stats Bar */} + + + {/* Activity Feed */} +
- {/* Primary Navigation */} + {/* Navigation */}
+ {/* Dashboard (standalone) */} + + {/* Resolve */} +
+ Resolve +
+ - - - - - + + + {/* Build */} +
+ Build +
+ + + + + {/* Insights */} +
+ Insights +
+