diff --git a/ui/desktop/src/components/Layout/NavigationPanel.tsx b/ui/desktop/src/components/Layout/NavigationPanel.tsx index dc0a6129c..cfa514d93 100644 --- a/ui/desktop/src/components/Layout/NavigationPanel.tsx +++ b/ui/desktop/src/components/Layout/NavigationPanel.tsx @@ -135,8 +135,14 @@ export const Navigation: React.FC<{ className?: string }> = ({ className }) => { const isActive = useCallback((path: string) => location.pathname === path, [location.pathname]); - const { recentSessions, recentSessionsByProject, activeSessionId, fetchSessions, handleNavClick, handleSessionClick } = - useNavigationSessions(); + const { + recentSessions, + recentSessionsByProject, + activeSessionId, + fetchSessions, + handleNavClick, + handleSessionClick, + } = useNavigationSessions(); const [sessionStatuses, setSessionStatuses] = useState>(new Map()); @@ -181,6 +187,19 @@ export const Navigation: React.FC<{ className?: string }> = ({ className }) => { }, [isNavExpanded, fetchSessions]); const [isChatsExpanded, setIsChatsExpanded] = useState(true); + const [collapsedProjects, setCollapsedProjects] = useState>(new Set()); + + const toggleProjectCollapsed = useCallback((path: string) => { + setCollapsedProjects((prev) => { + const next = new Set(prev); + if (next.has(path)) { + next.delete(path); + } else { + next.add(path); + } + return next; + }); + }, []); if (!isNavExpanded) return null; @@ -226,29 +245,40 @@ export const Navigation: React.FC<{ className?: string }> = ({ className }) => { {intl.formatMessage(i18n.noChats)} ) : recentSessionsByProject.length > 1 ? ( - recentSessionsByProject.map((group: ProjectGroup) => ( - -
- {group.label} -
- {group.sessions.map((session) => ( - { - clearUnread(session.id); - handleSessionClick(session.id); - }} - onRenamed={fetchSessions} - /> - ))} -
- )) + recentSessionsByProject.map((group: ProjectGroup) => { + const isCollapsed = collapsedProjects.has(group.path); + return ( + + + {!isCollapsed && + group.sessions.map((session) => ( + { + clearUnread(session.id); + handleSessionClick(session.id); + }} + onRenamed={fetchSessions} + /> + ))} + + ); + }) ) : ( recentSessions.map((session) => (