Skip to content

Sidebar route highlighting#527

Merged
softmarshmallow merged 1 commit intomainfrom
chore/sidebar-route-highlighting-b9ca
Feb 5, 2026
Merged

Sidebar route highlighting#527
softmarshmallow merged 1 commit intomainfrom
chore/sidebar-route-highlighting-b9ca

Conversation

@softmarshmallow
Copy link
Member

@softmarshmallow softmarshmallow commented Feb 5, 2026

Make console sidebars route-aware to highlight the current page.

This PR extracts the console resources and campaign-specific sidebars into dedicated components, implementing route-awareness to highlight the active menu item based on the current URL. The campaign sidebar's "Home" link is specifically configured not to highlight on sub-routes.


Open in Cursor Open in Web

Summary by CodeRabbit

Release Notes

  • Refactor
    • Introduced dedicated sidebar navigation components for campaign and resource management views, consolidating navigation layouts into organized, reusable components.
    • Streamlined sidebar structure in campaign and resources sections with enhanced active state tracking for menu items.

Co-authored-by: Universe <universe@grida.co>
@cursor
Copy link

cursor bot commented Feb 5, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@vercel
Copy link

vercel bot commented Feb 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Feb 5, 2026 1:17pm
grida Ready Ready Preview, Comment Feb 5, 2026 1:17pm
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
code Ignored Ignored Feb 5, 2026 1:17pm
legacy Ignored Ignored Feb 5, 2026 1:17pm
backgrounds Skipped Skipped Feb 5, 2026 1:17pm
blog Skipped Skipped Feb 5, 2026 1:17pm
viewer Skipped Skipped Feb 5, 2026 1:17pm

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

Walkthrough

Two new sidebar components—CampaignSidebar and ConsoleResourcesSidebar—are introduced to consolidate complex sidebar UI compositions. Corresponding layout files are refactored to use these new components instead of inline Sidebar structures, reducing boilerplate while maintaining the same navigation and layout behavior.

Changes

Cohort / File(s) Summary
Campaign Sidebar Component
editor/app/(workbench)/[org]/[proj]/(console)/(campaign)/campaigns/[campaign]/campaign-sidebar.tsx
New sidebar component with multi-section navigation (Home, Participants, Quests, Rewards, Observability), Design/Settings group, draggable header, and footer card; includes helper SidebarMenuLink for active state detection.
Campaign Layout Refactor
editor/app/(workbench)/[org]/[proj]/(console)/(campaign)/campaigns/[campaign]/layout.tsx
Replaces verbose inline Sidebar composition with CampaignSidebar component; derives baseUrl, campaignsUrl, and campaignTitle for prop passing.
Resources Sidebar Component
editor/app/(workbench)/[org]/[proj]/(console)/(resources)/console-resources-sidebar.tsx
New sidebar component with multi-section navigation (Dashboard, Customers, Tags, CIAM, Site, Domains, Analytics, Campaigns, Connections) and draggable header area; includes SidebarMenuLink helper with active state matching logic.
Resources Layout Refactor
editor/app/(workbench)/[org]/[proj]/(console)/(resources)/layout.tsx
Replaces large multi-block Sidebar composition with ConsoleResourcesSidebar component; removes nested sidebar JSX while retaining SidebarProvider wrapper.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • gridaco/grida#417: Modifies console sidebars' draggable header region with similar component-level sidebar refactoring.

Suggested labels

codex

Poem

🐰 Sidebars once sprawled with tangled ties,
Now bundled neat as whisker-wise,
Components born to bring delight,
Navigation clean, the structure tight! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Sidebar route highlighting' directly matches the main objective of making sidebars route-aware to highlight the current page, which is the primary focus of this PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 chore/sidebar-route-highlighting-b9ca

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

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

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 113030edf6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<ResourceTypeIcon type="connect" className="size-4" />
Connections
</SidebarMenuLink>
<SidebarMenuLink href={`${basePath}/ciam`}>

Choose a reason for hiding this comment

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

P2 Badge Remove duplicate active CIAM menu item

With the new usePathname-based highlighting, both CIAM entries now become active on /[org]/[proj]/ciam, so the sidebar shows two highlighted destinations for the same page. This ambiguity is introduced by adding route-aware SidebarMenuLink behavior while keeping duplicate ciam links in both the Customer and Advanced groups, and it undermines the goal of a single clear active navigation state.

Useful? React with 👍 / 👎.

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

🤖 Fix all issues with AI agents
In
`@editor/app/`(workbench)/[org]/[proj]/(console)/(resources)/console-resources-sidebar.tsx:
- Around line 98-101: There is a duplicated SidebarMenuLink for CIAM (the block
using SidebarMenuLink with ShieldCheckIcon and href `${basePath}/ciam`) present
in both the "Customer" group and the "Advanced" group; remove the redundant
occurrence so only one CIAM SidebarMenuLink remains (either keep it under
"Customer" or under "Advanced") and ensure no other code references the removed
duplicate; search for the SidebarMenuLink + ShieldCheckIcon + href
`${basePath}/ciam` snippet and delete the duplicate block accordingly.
🧹 Nitpick comments (3)
editor/app/(workbench)/[org]/[proj]/(console)/(resources)/console-resources-sidebar.tsx (1)

27-52: Consider reusing existing SidebarMenuLink from editor/components/sidebar/index.tsx.

There's an existing SidebarMenuLink component at editor/components/sidebar/index.tsx (lines 154-176) with similar path-matching logic. The implementations differ slightly (layout prop vs matchSubpaths, and this version wraps with SidebarMenuItem), but consolidating into a shared component would reduce duplication.

If the API differences are intentional, consider extending the existing component or creating a shared base utility for path matching.

editor/app/(workbench)/[org]/[proj]/(console)/(campaign)/campaigns/[campaign]/campaign-sidebar.tsx (2)

37-62: Duplicate SidebarMenuLink implementation.

This is identical to the SidebarMenuLink in console-resources-sidebar.tsx. Consider extracting this to a shared location (e.g., editor/components/sidebar/) to avoid maintaining multiple copies.

♻️ Suggested approach

Create a shared component that both sidebars can import:

// editor/components/sidebar/sidebar-menu-link.tsx
"use client";

import type { ReactNode } from "react";
import { SidebarMenuItem, SidebarMenuButton } from "@/components/ui/sidebar";
import Link from "next/link";
import { usePathname } from "next/navigation";

type SidebarMenuLinkProps = {
  href: string;
  children: ReactNode;
  size?: "default" | "sm" | "lg";
  matchSubpaths?: boolean;
};

export function SidebarMenuLink({
  href,
  children,
  size = "sm",
  matchSubpaths = true,
}: SidebarMenuLinkProps) {
  const pathname = usePathname();
  const isActive = matchSubpaths
    ? pathname === href || pathname.startsWith(`${href}/`)
    : pathname === href;

  return (
    <SidebarMenuItem>
      <SidebarMenuButton asChild size={size} isActive={isActive}>
        <Link href={href}>{children}</Link>
      </SidebarMenuButton>
    </SidebarMenuItem>
  );
}

89-89: Icon size inconsistency between sidebars.

This sidebar uses size-3 for icons while ConsoleResourcesSidebar uses size-4. If intentional (campaign sidebar has denser navigation), this is fine. Otherwise, consider aligning for visual consistency across the application.

Also applies to: 93-93, 97-97, 101-101, 105-105, 116-116, 120-120

Comment on lines +98 to +101
<SidebarMenuLink href={`${basePath}/ciam`}>
<ShieldCheckIcon className="size-4" />
CIAM
</SidebarMenuLink>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Duplicate CIAM menu item.

CIAM appears in both the "Customer" group (lines 98-101) and the "Advanced" group (lines 143-146) with the same href. This appears to be an unintentional duplicate.

🐛 Proposed fix: Remove the duplicate from one section

If CIAM belongs under "Advanced", remove it from "Customer":

             <SidebarMenu>
               <SidebarMenuLink href={`${basePath}/customers`}>
                 <ResourceTypeIcon type="customer" className="size-4" />
                 Customers
               </SidebarMenuLink>
               <SidebarMenuLink href={`${basePath}/tags`}>
                 <ResourceTypeIcon type="tag" className="size-4" />
                 Tags
               </SidebarMenuLink>
-              <SidebarMenuLink href={`${basePath}/ciam`}>
-                <ShieldCheckIcon className="size-4" />
-                CIAM
-              </SidebarMenuLink>
             </SidebarMenu>

Or if CIAM belongs under "Customer", remove it from "Advanced":

         <SidebarGroup>
           <SidebarGroupLabel>Advanced</SidebarGroupLabel>
           <SidebarGroupContent>
             <SidebarMenu>
               <SidebarMenuLink href={`${basePath}/integrations`}>
                 <ResourceTypeIcon type="connect" className="size-4" />
                 Connections
               </SidebarMenuLink>
-              <SidebarMenuLink href={`${basePath}/ciam`}>
-                <ShieldCheckIcon className="size-4" />
-                CIAM
-              </SidebarMenuLink>
             </SidebarMenu>
           </SidebarGroupContent>
         </SidebarGroup>

Also applies to: 143-146

🤖 Prompt for AI Agents
In
`@editor/app/`(workbench)/[org]/[proj]/(console)/(resources)/console-resources-sidebar.tsx
around lines 98 - 101, There is a duplicated SidebarMenuLink for CIAM (the block
using SidebarMenuLink with ShieldCheckIcon and href `${basePath}/ciam`) present
in both the "Customer" group and the "Advanced" group; remove the redundant
occurrence so only one CIAM SidebarMenuLink remains (either keep it under
"Customer" or under "Advanced") and ensure no other code references the removed
duplicate; search for the SidebarMenuLink + ShieldCheckIcon + href
`${basePath}/ciam` snippet and delete the duplicate block accordingly.

@softmarshmallow softmarshmallow merged commit 6d0849a into main Feb 5, 2026
10 checks passed
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