Skip to content

[WEB-4779] chore: app sidebar wrapper component for consistency and reusability#7655

Merged
sriramveeraghanta merged 4 commits intopreviewfrom
chore-app-sidebar-enhancements
Aug 27, 2025
Merged

[WEB-4779] chore: app sidebar wrapper component for consistency and reusability#7655
sriramveeraghanta merged 4 commits intopreviewfrom
chore-app-sidebar-enhancements

Conversation

@anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Aug 26, 2025

Description

This PR introduces a new app sidebar wrapper component to centralize and standardize sidebar ui and layout logic.

Type of Change

  • Improvement
  • Code refactoring

Summary by CodeRabbit

  • New Features

    • Unified Projects sidebar with a cleaner header and optional quick actions.
    • Favorites and team/project lists preserved; visibility still respects workspace permissions.
  • Refactor

    • Streamlined, wrapper-based sidebar layout with fewer controls and less visual clutter.
    • Improved responsive behavior: sidebar auto-collapses on small screens and closes on outside click.
    • No breaking changes to public components.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 26, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Replaces the stateful, multi-section Projects AppSidebar with a new SidebarWrapper component and refactors sidebar.tsx to render menu children inside the wrapper. Removes window-size/outside-click logic and several UI controls from the old file; adds a new responsive SidebarWrapper that manages collapse and outside-click behavior.

Changes

Cohort / File(s) Summary
Projects sidebar refactor
apps/web/app/(all)/[workspaceSlug]/(projects)/sidebar.tsx
Replaces the previous AppSidebar structure with SidebarWrapper usage; removes header/project toggle, app-rail controls, bottom help/edition area, and client-side size/outside-click state/hooks; preserves permission checks (Favorites) and renders menu lists as children.
New Sidebar wrapper component
apps/web/core/components/sidebar/sidebar-wrapper.tsx
Adds SidebarWrapper (exported observer FC) implementing top/middle/bottom layout, optional quickActions, responsive collapse on small widths (<768px), and outside-click collapse using existing hooks and UI elements (Dropdown, Toggle, Help, EditionBadge).

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant SidebarWrapper
  participant Hooks as AppRail/Theme/Size Hooks
  participant DOM as Viewport/OutsideClickDetector

  User->>SidebarWrapper: interact / toggle
  SidebarWrapper->>Hooks: read app rail & window size
  SidebarWrapper->>DOM: attach outside-click detector
  alt window width < 768
    SidebarWrapper->>SidebarWrapper: auto-collapse / expand
    User-->>DOM: click outside
    DOM->>SidebarWrapper: notify -> collapse
  else window width >= 768
    SidebarWrapper->>SidebarWrapper: remain expanded
  end
  SidebarWrapper->>User: render top (title/actions), middle (children), bottom (edition/help)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

🛠️refactor, 🧹chore, 🌐frontend

Suggested reviewers

  • prateekshourya29
  • vamsikrishnamathala
  • sriramveeraghanta

Poem

I hopped in quick and wrapped the side,
Tidied controls where toggles hide.
Small screens bow and clicks retreat,
Menus snug and tidy—neat! 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 529e6f4 and 7e5e6ae.

📒 Files selected for processing (2)
  • apps/web/app/(all)/[workspaceSlug]/(projects)/sidebar.tsx (1 hunks)
  • apps/web/core/components/sidebar/sidebar-wrapper.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/web/app/(all)/[workspaceSlug]/(projects)/sidebar.tsx
  • apps/web/core/components/sidebar/sidebar-wrapper.tsx
⏰ 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). (2)
  • GitHub Check: Build and lint web apps
  • GitHub Check: Analyze (javascript)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore-app-sidebar-enhancements

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@makeplane
Copy link

makeplane bot commented Aug 26, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

@anmolsinghbhatia anmolsinghbhatia marked this pull request as ready for review August 27, 2025 12:08
Copilot AI review requested due to automatic review settings August 27, 2025 12:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new SidebarWrapper component to centralize and standardize sidebar UI and layout logic across the application, improving code reusability and consistency.

  • Extracts common sidebar layout patterns into a reusable wrapper component
  • Refactors the existing projects sidebar to use the new wrapper
  • Consolidates duplicate UI logic for sidebar header, footer, and responsive behavior

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
apps/web/core/components/sidebar/sidebar-wrapper.tsx New reusable wrapper component containing sidebar layout, responsive behavior, and common UI elements
apps/web/app/(all)/[workspaceSlug]/(projects)/sidebar.tsx Refactored to use the new SidebarWrapper, removing duplicated layout code

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@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

🧹 Nitpick comments (4)
apps/web/app/(all)/[workspaceSlug]/(projects)/sidebar.tsx (1)

32-32: Localize the title string.

Hardcoding "Projects" may skip i18n. Prefer passing a localized string.

Example:

-import { FC } from "react";
+import { FC } from "react";
+import { useTranslation } from "next-i18next";
...
-export const AppSidebar: FC = observer(() => {
+export const AppSidebar: FC = observer(() => {
+  const { t } = useTranslation();
...
-    <SidebarWrapper title="Projects" quickActions={<SidebarQuickActions />}>
+    <SidebarWrapper title={t("projects")} quickActions={<SidebarQuickActions />}>
apps/web/core/components/sidebar/sidebar-wrapper.tsx (3)

39-43: Avoid silencing exhaustive-deps; include stable deps.

Include sidebarCollapsed and toggleSidebar to prevent stale closures. The guard prevents loops.

   useEffect(() => {
     if (windowSize[0] < 768 && !sidebarCollapsed) toggleSidebar();
-    // eslint-disable-next-line react-hooks/exhaustive-deps
-  }, [windowSize]);
+  }, [windowSize, sidebarCollapsed, toggleSidebar]);

1-1: Use type-only ReactNode to reduce runtime imports.

Slightly cleaner and avoids pulling the React namespace for types.

-import { FC, useEffect, useRef } from "react";
+import { FC, useEffect, useRef, type ReactNode } from "react";
@@
 type TSidebarWrapperProps = {
   title: string;
-  children: React.ReactNode;
-  quickActions?: React.ReactNode;
+  children: ReactNode;
+  quickActions?: ReactNode;
 };

Also applies to: 16-20


31-37: Prefer using windowSize over window.innerWidth inside the handler.

Keeps a single source of truth for viewport width.

-  useOutsideClickDetector(ref, () => {
-    if (sidebarCollapsed === false) {
-      if (window.innerWidth < 768) {
-        toggleSidebar();
-      }
-    }
-  });
+  useOutsideClickDetector(ref, () => {
+    if (!sidebarCollapsed && windowSize[0] < 768) toggleSidebar();
+  });
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6d1275d and 529e6f4.

📒 Files selected for processing (2)
  • apps/web/app/(all)/[workspaceSlug]/(projects)/sidebar.tsx (1 hunks)
  • apps/web/core/components/sidebar/sidebar-wrapper.tsx (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
apps/web/app/(all)/[workspaceSlug]/(projects)/sidebar.tsx (1)
apps/web/core/components/sidebar/sidebar-wrapper.tsx (1)
  • SidebarWrapper (22-74)
apps/web/core/components/sidebar/sidebar-wrapper.tsx (6)
apps/web/core/hooks/use-app-rail.tsx (1)
  • useAppRail (4-10)
packages/hooks/src/use-outside-click-detector.tsx (1)
  • useOutsideClickDetector (3-29)
apps/web/core/components/workspace/sidebar/dropdown.tsx (1)
  • SidebarDropdown (11-22)
apps/web/core/components/sidebar/sidebar-toggle-button.tsx (1)
  • AppSidebarToggleButton (8-23)
apps/web/ce/components/workspace/edition-badge.tsx (1)
  • WorkspaceEditionBadge (12-40)
apps/web/core/components/workspace/sidebar/help-menu.tsx (1)
  • HelpMenu (27-152)
⏰ 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). (1)
  • GitHub Check: Build and lint web apps
🔇 Additional comments (2)
apps/web/app/(all)/[workspaceSlug]/(projects)/sidebar.tsx (1)

32-40: Refactor to SidebarWrapper looks good.

The composition reads cleanly and preserves existing permission checks. No functional concerns here.

apps/web/core/components/sidebar/sidebar-wrapper.tsx (1)

50-57: Confirm toggle placement UX with product.

When app rail is disabled, the header (title + toggle) is hidden and the toggle is only in the footer. If that’s intentional, ignore; otherwise consider always showing the title, and moving the toggle consistently to one place.

Also applies to: 68-70

@sriramveeraghanta sriramveeraghanta merged commit cfe710d into preview Aug 27, 2025
6 of 7 checks passed
@sriramveeraghanta sriramveeraghanta deleted the chore-app-sidebar-enhancements branch August 27, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants