From 4e1422248737ec03c61ebcf9fd6493e5abd325df Mon Sep 17 00:00:00 2001 From: simos Date: Fri, 31 Oct 2025 09:36:14 +0000 Subject: [PATCH] feat(ui): add collapsible sidebar functionality Implement a collapsible sidebar feature for the desktop view that allows users to toggle between expanded and collapsed states. The sidebar state is persisted using localStorage to maintain user preference across sessions. Changes include: - Add sidebarVisible state with localStorage persistence - Import Sparkles and SettingsIcon from lucide-react - Implement smooth transition animation (300ms) for sidebar collapse - Add collapsed sidebar view with icon-only navigation buttons - Pass onToggleSidebar prop to Sidebar component - Adjust sidebar width dynamically (80 -> 14 when collapsed) This improves the user experience by providing more screen real estate for the main content area when needed, while keeping quick access to essential navigation through the collapsed icon view. --- src/App.jsx | 95 +++++++++++++++++++++++++------- src/components/ChatInterface.jsx | 1 - src/components/Sidebar.jsx | 76 ++++++++++++++++--------- 3 files changed, 124 insertions(+), 48 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index c018dc3..3a84f0f 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -20,6 +20,7 @@ import React, { useState, useEffect, useCallback } from 'react'; import { BrowserRouter as Router, Routes, Route, useNavigate, useParams } from 'react-router-dom'; +import { Settings as SettingsIcon, Sparkles } from 'lucide-react'; import Sidebar from './components/Sidebar'; import MainContent from './components/MainContent'; import MobileNav from './components/MobileNav'; @@ -60,6 +61,7 @@ function AppContent() { const [showThinking, setShowThinking] = useLocalStorage('showThinking', true); const [autoScrollToBottom, setAutoScrollToBottom] = useLocalStorage('autoScrollToBottom', true); const [sendByCtrlEnter, setSendByCtrlEnter] = useLocalStorage('sendByCtrlEnter', false); + const [sidebarVisible, setSidebarVisible] = useLocalStorage('sidebarVisible', true); // Session Protection System: Track sessions with active conversations to prevent // automatic project updates from interrupting ongoing chats. When a user sends // a message, the session is marked as "active" and project updates are paused @@ -734,28 +736,78 @@ function AppContent() {
{/* Fixed Desktop Sidebar */} {!isMobile && ( -
+
- setShowSettings(true)} - updateAvailable={updateAvailable} - latestVersion={latestVersion} - currentVersion={currentVersion} - releaseInfo={releaseInfo} - onShowVersionModal={() => setShowVersionModal(true)} - isPWA={isPWA} - isMobile={isMobile} - /> + {sidebarVisible ? ( + setShowSettings(true)} + updateAvailable={updateAvailable} + latestVersion={latestVersion} + currentVersion={currentVersion} + releaseInfo={releaseInfo} + onShowVersionModal={() => setShowVersionModal(true)} + isPWA={isPWA} + isMobile={isMobile} + onToggleSidebar={() => setSidebarVisible(false)} + /> + ) : ( + /* Collapsed Sidebar */ +
+ {/* Expand Button */} + + + {/* Settings Icon */} + + + {/* Update Indicator */} + {updateAvailable && ( + + )} +
+ )}
)} @@ -805,6 +857,7 @@ function AppContent() { onShowVersionModal={() => setShowVersionModal(true)} isPWA={isPWA} isMobile={isMobile} + onToggleSidebar={() => setSidebarVisible(false)} />
diff --git a/src/components/ChatInterface.jsx b/src/components/ChatInterface.jsx index 981ab7b..f9c5e96 100644 --- a/src/components/ChatInterface.jsx +++ b/src/components/ChatInterface.jsx @@ -514,7 +514,6 @@ const MessageComponent = memo(({ message, index, prevMessage, createDiff, onFile - 📝 View edit diff for - - + )} {/* Mobile Header */} @@ -914,9 +905,9 @@ function Sidebar({ )} - {/* Search Filter */} + {/* Search Filter and Actions */} {projects.length > 0 && !isLoading && ( -
+
)}
+ + {/* Action Buttons - Desktop only */} + {!isMobile && ( +
+ + +
+ )}
)}