Skip to content

Conversation

@AnthonyRonning
Copy link
Contributor

@AnthonyRonning AnthonyRonning commented Dec 2, 2025

Summary

Adds the ability to collapse/expand the sidebar on desktop and web views, bringing feature parity with the existing mobile behavior.

Changes

  • Sidebar.tsx: Modified to allow hiding on desktop when closed; toggle button now visible on all screen sizes
  • UnifiedChat.tsx: Grid layout now responds dynamically to sidebar state; "New Chat" button appears in header when sidebar is closed

Behavior

  • Desktop default: Sidebar open (unchanged)
  • Mobile default: Sidebar closed (unchanged)
  • Toggle button visible on all screen sizes
  • Click-outside-to-close only applies on mobile (preserves desktop behavior)
  • "New Chat" button in sidebar only closes sidebar on mobile
  • "New Chat" button appears in header when sidebar is collapsed (any screen size)

Summary by CodeRabbit

  • Improvements
    • Enhanced responsive layout behavior for improved mobile and desktop viewing experience.
    • Optimized sidebar visibility, interaction controls, and toggle button display across different screen sizes.
    • Streamlined chat interface rendering logic to dynamically adjust layout based on sidebar state.
    • Improved consistency of control visibility and positioning throughout the application.

✏️ Tip: You can customize this high-level summary in your review settings.

Allow users to collapse/expand the history sidebar on desktop and web views.
The toggle button is now visible on all screen sizes. Click-outside-to-close
behavior remains mobile-only to preserve desktop UX.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@coderabbitai
Copy link

coderabbitai bot commented Dec 2, 2025

Walkthrough

These changes refactor the Sidebar and UnifiedChat components to use centralized mobile detection (useIsMobile hook) and sidebar state for controlling responsive behavior, replacing static CSS media queries with dynamic state-driven rendering and conditional display logic.

Changes

Cohort / File(s) Summary
Sidebar mobile detection and close behavior
frontend/src/components/Sidebar.tsx
Introduced centralized mobile detection via useIsMobile() hook; narrowed close behavior to mobile-only (addChat and handleClickOutside now check isOpen && isMobile); updated dependency tracking and simplified render logic to use uniform hidden state when closed; adjusted UI controls (toggle and new chat button no longer hidden on md screens); passed isMobile prop to ChatHistoryList.
Chat layout responsive adjustments
frontend/src/components/UnifiedChat.tsx
Modified main grid container to toggle column layout based on isSidebarOpen state; sidebar toggle no longer wrapped with responsive hiding; reintroduced conditional rendering for mobile new-chat button (shown only when sidebar closed) instead of always rendering with responsive visibility.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify that useIsMobile() hook is properly imported and functioning across both components
  • Ensure consistent mobile vs. desktop behavior in Sidebar close logic and layout toggling
  • Confirm all prop dependencies (e.g., isMobile to ChatHistoryList) are correctly wired and don't cause prop-drilling issues
  • Validate that conditional rendering for the new-chat button doesn't introduce unintended visibility flicker or state misalignment

Possibly related PRs

  • Search title feature #36: Modifies the same UI components (Sidebar.tsx, ChatBox.tsx usage) and introduces/shares the useIsMobile mobile-detection logic utility, indicating parallel responsive refactoring efforts.
  • Responses final #263: Modifies the same UI components (Sidebar.tsx and UnifiedChat.tsx) and related props (ChatHistoryList isMobile), indicating coordinated responsive and visibility adjustments across the chat interface.

Poem

🐰 A hop through layouts, mobile and wide,
useIsMobile now our responsive guide,
State drives the sidebar's dance so fine,
No more media queries—just logic divine!
The grid adapts with a elegant glide.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add collapsible sidebar on desktop/web views' directly and accurately describes the primary change: adding collapsible sidebar functionality for desktop/web platforms.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/collapsible-sidebar-desktop

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link

Deploying maple with  Cloudflare Pages  Cloudflare Pages

Latest commit: e4eb242
Status: ✅  Deploy successful!
Preview URL: https://8a032e54.maple-ca8.pages.dev
Branch Preview URL: https://feature-collapsible-sidebar.maple-ca8.pages.dev

View logs

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 2, 2025

Greptile Overview

Greptile Summary

Adds collapsible sidebar functionality to desktop and web views, bringing feature parity with mobile. The implementation correctly uses the existing useIsMobile hook to differentiate behavior: desktop users can toggle the sidebar with a button (no auto-close), while mobile users retain the existing click-outside-to-close behavior. Key changes include:

  • Modified Sidebar.tsx to restrict auto-close behaviors (click-outside, new-chat-button-close) to mobile only
  • Updated UnifiedChat.tsx grid layout to dynamically respond to sidebar state on all screen sizes
  • Made toggle button and conditional "New Chat" header button visible on all screen sizes when appropriate
  • Preserved existing mobile defaults (closed) and desktop defaults (open)

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-structured, use existing hooks correctly, maintain backward compatibility, and properly separate mobile/desktop behavior without introducing logical errors or security concerns
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
frontend/src/components/Sidebar.tsx 5/5 Added desktop collapse functionality by making toggle button visible on all screens and restricting click-outside/auto-close behaviors to mobile only
frontend/src/components/UnifiedChat.tsx 5/5 Updated grid layout to respond to sidebar state and made toggle/new-chat buttons visible when sidebar is closed on all screen sizes

Sequence Diagram

sequenceDiagram
    participant User
    participant UnifiedChat
    participant Sidebar
    participant useIsMobile

    Note over UnifiedChat: Initial render
    UnifiedChat->>useIsMobile: Check viewport size
    useIsMobile-->>UnifiedChat: isMobile = true/false
    UnifiedChat->>UnifiedChat: setState(!isMobile)
    
    alt Desktop (sidebar open by default)
        UnifiedChat->>Sidebar: render(isOpen=true)
        Sidebar->>Sidebar: Show with toggle & new chat buttons
    else Mobile (sidebar closed by default)
        UnifiedChat->>UnifiedChat: Show SidebarToggle in header
        UnifiedChat->>Sidebar: render(isOpen=false)
        Sidebar->>Sidebar: Hidden
    end

    Note over User,Sidebar: User clicks toggle button
    
    alt On Desktop
        User->>Sidebar: Click toggle (close)
        Sidebar->>UnifiedChat: onToggle()
        UnifiedChat->>UnifiedChat: setState(false)
        UnifiedChat->>UnifiedChat: Remove grid column layout
        UnifiedChat->>UnifiedChat: Show SidebarToggle + NewChat in header
        UnifiedChat->>Sidebar: render(isOpen=false)
    else On Mobile
        User->>UnifiedChat: Click SidebarToggle
        UnifiedChat->>UnifiedChat: onToggle()
        UnifiedChat->>UnifiedChat: setState(true)
        UnifiedChat->>Sidebar: render(isOpen=true)
        Sidebar->>Sidebar: Show sidebar overlay
        
        alt User clicks outside
            User->>Sidebar: Click outside
            Sidebar->>useIsMobile: Check if mobile
            useIsMobile-->>Sidebar: true
            Sidebar->>UnifiedChat: onToggle()
            UnifiedChat->>UnifiedChat: setState(false)
        end
    end

    Note over User,Sidebar: New Chat button behavior
    
    alt Sidebar open on mobile
        User->>Sidebar: Click New Chat
        Sidebar->>useIsMobile: Check if mobile
        useIsMobile-->>Sidebar: true
        Sidebar->>UnifiedChat: onToggle()
        Sidebar->>Sidebar: Navigate to new chat
    else Sidebar open on desktop
        User->>Sidebar: Click New Chat
        Sidebar->>useIsMobile: Check if mobile
        useIsMobile-->>Sidebar: false
        Sidebar->>Sidebar: Navigate (no close)
    else Sidebar closed (any size)
        User->>UnifiedChat: Click header New Chat
        UnifiedChat->>UnifiedChat: Clear conversation
        UnifiedChat->>UnifiedChat: Navigate to new chat
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 77fe97f and e4eb242.

📒 Files selected for processing (2)
  • frontend/src/components/Sidebar.tsx (5 hunks)
  • frontend/src/components/UnifiedChat.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx}: Use 2-space indentation, double quotes, and a 100-character line limit for formatting
Use camelCase for variable and function names
Use try/catch with specific error types for error handling

Files:

  • frontend/src/components/Sidebar.tsx
  • frontend/src/components/UnifiedChat.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use strict TypeScript typing and avoid any when possible

Files:

  • frontend/src/components/Sidebar.tsx
  • frontend/src/components/UnifiedChat.tsx
🧬 Code graph analysis (1)
frontend/src/components/Sidebar.tsx (2)
frontend/src/utils/utils.ts (1)
  • useIsMobile (16-54)
frontend/src/components/ui/button.tsx (1)
  • Button (62-62)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: build-ios
  • GitHub Check: build-android
  • GitHub Check: build-linux
  • GitHub Check: build-macos (universal-apple-darwin)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (7)
frontend/src/components/Sidebar.tsx (4)

25-29: LGTM! Mobile-only sidebar close logic is correct.

The conditional check ensures the sidebar only closes on mobile when starting a new chat, preserving desktop behavior as intended.


77-78: LGTM! Centralized mobile detection and proper dependency tracking.

The useIsMobile() hook is correctly used and included in all relevant dependency arrays. The click-outside behavior is properly scoped to mobile only.

Also applies to: 82-96


139-139: LGTM! Visibility logic enables desktop collapsibility.

Removing the md:block class when closed allows the sidebar to be hidden on desktop, which is the core feature of this PR. The toggle buttons (lines 146, 208) provide a way to reopen it.


196-196: ChatHistoryList correctly accepts the isMobile prop.

The component signature has been properly updated. The ChatHistoryListProps interface (line 20) defines isMobile?: boolean, and the component function (line 43) correctly destructures it with a default value of false.

frontend/src/components/UnifiedChat.tsx (3)

2258-2260: LGTM! Responsive grid layout adapts to sidebar state.

The conditional grid columns correctly implement the collapsible sidebar feature. When closed, the layout is single-column on all screen sizes. When open, it shows two columns on desktop (md+) with the sidebar taking exactly 280px.


2276-2281: LGTM! Fixed toggle button positioning is correct.

The sidebar toggle is now always visible when the sidebar is closed, regardless of screen size. The fixed positioning at top-[9.5px] appears to align with the header, though this specific value seems precise—ensure it aligns correctly across different viewport sizes during testing.

If the 9.5px value causes misalignment issues on certain screen sizes, consider using a more standard spacing value or aligning with the header height programmatically.


630-630: LGTM! Sidebar state initialization matches requirements.

The initial state !isMobile correctly implements the PR requirement: sidebar defaults to open on desktop and closed on mobile.

@AnthonyRonning AnthonyRonning merged commit 6873907 into master Dec 2, 2025
9 checks passed
@AnthonyRonning AnthonyRonning deleted the feature/collapsible-sidebar-desktop branch December 2, 2025 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants