Skip to content

refactor(sidebar): add reusable Sidebar UI component with responsive layouts#13879

Draft
jidan745le wants to merge 2 commits intoCherryHQ:v2from
jidan745le:refractor/v2/sidebar-refractor
Draft

refactor(sidebar): add reusable Sidebar UI component with responsive layouts#13879
jidan745le wants to merge 2 commits intoCherryHQ:v2from
jidan745le:refractor/v2/sidebar-refractor

Conversation

@jidan745le
Copy link
Copy Markdown
Collaborator

What this PR does

Before this PR:

  • The v2 sidebar was a simple inline implementation with basic menu items using Tailwind classes directly in the app-level Sidebar.tsx
  • No reusable sidebar component existed in @cherrystudio/ui
  • Missing route definitions for /app/agents and /app/openclaw caused "Page Not Found" when clicking those menu items

After this PR:

  • Adds a full-featured Sidebar component to packages/ui/src/components/sidebar/ with:
    • Responsive layouts: icon-only, vertical-card, and full-width modes based on sidebar width
    • Drag support: useSidebarDrag hook for docking/undocking tabs to/from the sidebar
    • Tab management: useSidebarTabs hook for managing sidebar tabs and mini-app tabs
    • Resizable: Users can drag to resize the sidebar between different layout modes
  • Refactors app-level Sidebar.tsx to consume the new UISidebar component
  • Adds CSS custom properties for sidebar theming (light/dark mode)
  • Includes the upstream sidebar-simplify fixes (route definitions for agents/openclaw)

Why we need it and why it was done in this way

The v2 UI migration requires moving from antd/styled-components to @cherrystudio/ui (Tailwind + Shadcn). The sidebar is a core navigation component that benefits from being a reusable, well-structured UI primitive in the shared package.

The following tradeoffs were made:

  • Built as a standalone component in packages/ui rather than inline in the app, to enable reuse across windows (main, mini) and easier testing

The following alternatives were considered:

  • Keeping the inline Tailwind implementation from sidebar-simplify — rejected because it doesn't support responsive layout modes or drag interactions

Breaking changes

None. This builds on top of the sidebar-simplify refactor.

Special notes for your reviewer

  • This is a draft PR — the sidebar component is a first version and may need further iteration
  • Built on top of refactor/v2/sidebar-simplify (upstream) which fixed the agents/openclaw routing
  • The useSidebarDrag and useSidebarTabs hooks are not yet fully wired into the app-level code

Checklist

  • PR: The PR description is expressive enough and will help future contributors
  • Code: Write code that humans can understand and Keep it simple
  • Refactor: You have left the code cleaner than you found it (Boy Scout Rule)
  • Upgrade: Impact of this change on upgrade flows was considered and addressed if required
  • Documentation: A user-guide update was considered and is present or not required
  • Self-review: I have reviewed my own code before requesting review from others

Release note

```release-note
NONE
```

kangfenmao and others added 2 commits March 29, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants