AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
feat(web): unify app and admin sidebars into one component (#16200)
moaaz4a9721d798e3
diff --git a/packages/web/public/locales/en/translation.json b/packages/web/public/locales/en/translation.jsonindex 7eff33ea9a6..67a5dcaba48 100644--- a/packages/web/public/locales/en/translation.json+++ b/packages/web/public/locales/en/translation.json@@ -467,6 +467,9 @@"No language found.": "No language found.","Help translate Activepieces →": "Help translate Activepieces →","Theme": "Theme",+ "Light": "Light",+ "Dark": "Dark",+ "System": "System","Switch to the Enterprise edition to access billing and usage management.": "Switch to the Enterprise edition to access billing and usage management.","Read the docs": "Read the docs","Upgrade plan": "Upgrade plan",@@ -532,7 +535,7 @@"platform": "platform","Close sidebar": "Close sidebar","Platform Admin": "Platform Admin",- "Sort pinned projects": "Sort pinned projects",+ "Sort projects": "Sort projects","Recently added": "Recently added","Recently used": "Recently used","Alphabetical": "Alphabetical",diff --git a/packages/web/src/app/components/account-settings/index.tsx b/packages/web/src/app/components/account-settings/index.tsxindex 5bd9732fce5..672981c9076 100644--- a/packages/web/src/app/components/account-settings/index.tsx+++ b/packages/web/src/app/components/account-settings/index.tsx@@ -4,30 +4,23 @@ import {} from '@activepieces/shared';import { useQueryClient } from '@tanstack/react-query';import { t } from 'i18next';-import { Camera, Mail } from 'lucide-react';+import { Camera } from 'lucide-react';import { useRef } from 'react';import { toast } from 'sonner';+import { TextWithTooltip } from '@/components/custom/text-with-tooltip';import { UserAvatar } from '@/components/custom/user-avatar';import {Dialog,DialogContent,- DialogFooter,DialogHeader,DialogTitle,} from '@/components/ui/dialog';-import { ScrollArea } from '@/components/ui/scroll-area';-import { Separator } from '@/components/ui/separator';import { userHooks, userMutations } from '@/hooks/user-hooks';import { LanguageToggle } from './language-toggle';import { ThemeToggle } from './theme-toggle';-export interface AccountSettingsDialogProps {- open: boolean;- onClose: () => void;-}-export function AccountSettingsDialog({open,onClose,@@ -48,6 +41,7 @@ export function AccountSettingsDialog({const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {const file = event.target.files?.[0];+ event.target.value = '';if (file) {if (file.size > AP_MAXIMUM_PROFILE_PICTURE_SIZE) {toast.error(t('File size exceeds 5MB limit'));@@ -61,72 +55,78 @@ export function AccountSettingsDialog({}uploadMutation.mutate(file);}- event.target.value = '';};const handleAvatarClick = () => {+ if (uploadMutation.isPending) {+ return;+ }fileInputRef.current?.click();};+ const fullName = [user?.firstName, user?.lastName].filter(Boolean).join(' ');+ const email = user?.email ?? '';+return (<Dialog open={open} onOpenChange={onClose}>- <DialogContent className="max-w-2xl w-full max-h-[90vh] pb-4 flex flex-col px-5">+ <DialogContent className="max-h-[90svh] max-w-md gap-5 overflow-y-auto"><DialogHeader>- <DialogTitle className="font-semibold">- {t('Account Settings')}- </DialogTitle>+ <DialogTitle>{t('Account Settings')}</DialogTitle></DialogHeader>- <ScrollArea className="flex-1" viewPortClassName="px-1">- <div className="space-y-6">- <div className="flex items-center gap-4">- <div- className="relative group cursor-pointer"- onClick={handleAvatarClick}- >- <UserAvatar- name={(user?.firstName ?? '') + ' ' + (user?.lastName ?? '')}- email={user?.email ?? ''}- size={64}- disableTooltip- imageUrl={user?.imageUrl}- />- <div- data-theme="dark"- className="absolute inset-0 flex items-center justify-center bg-scrim rounded-full opacity-0 group-hover:opacity-100 transition-opacity"- >- <Camera className="h-5 w-5 text-gray-12" />- </div>- <input- ref={fileInputRef}- type="file"- accept="image/jpeg,image/png,image/gif,image/webp"- className="hidden"- onChange={handleFileChange}- disabled={uploadMutation.isPending}- />- </div>- <div className="flex-1">- <div className="text-sm font-semibold">- {user?.firstName} {user?.lastName}- </div>- <div className="text-xs text-gray-11 flex items-center gap-1">- <Mail className="w-3.5 h-3.5" />- {user?.email}- </div>- </div>- </div>-- <Separator />-- <div className="grid grid-cols-1 md:grid-cols-2 gap-4">- <ThemeToggle />- <LanguageToggle />- </div>+ <div className="flex items-center gap-3">+ <button+ type="button"+ aria-label={t('Upload File')}+ className="group relative shrink-0 rounded-full outline-none focus-visible:ring-[3px] focus-visible:ring-gray-8/50 aria-disabled:cursor-not-allowed"+ onClick={handleAvatarClick}+ aria-disabled={uploadMutation.isPending}+ aria-busy={uploadMutation.isPending}+ >+ <UserAvatar+ name={fullName}+ email={email}+ size={40}+ disableTooltip+ imageUrl={user?.imageUrl}+ />+ <span+ data-theme="dark"+ className="absolute inset-0 flex items-center justify-center rounded-full bg-scrim opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100"+ >+ <Camera className="size-4 text-gray-12" />+ </span>+ </button>+ <input+ ref={fileInputRef}+ type="file"+ accept="image/jpeg,image/png,image/gif,image/webp"+ className="hidden"+ onChange={handleFileChange}+ disabled={uploadMutation.isPending}+ />+ <div className="flex min-w-0 flex-1 flex-col">+ <TextWithTooltip tooltipMessage={fullName}>+ <p className="truncate text-sm font-medium text-gray-12">+ {fullName}+ </p>+ </TextWithTooltip>+ <TextWithTooltip tooltipMessage={email}>+ <p className="truncate text-xs text-gray-11">{email}</p>+ </TextWithTooltip></div>- </ScrollArea>- <DialogFooter />+ </div>++ <div className="flex flex-col divide-y divide-gray-6 rounded-xl border border-gray-6">+ <ThemeToggle />+ <LanguageToggle />+ </div></DialogContent></Dialog>);}++export interface AccountSettingsDialogProps {+ open: boolean;+ onClose: () => void;+}diff --git a/packages/web/src/app/components/account-settings/language-toggle.tsx b/packages/web/src/app/components/account-settings/language-toggle.tsxindex a0cad570096..bebee9b95ad 100644--- a/packages/web/src/app/components/account-settings/language-toggle.tsx+++ b/packages/web/src/app/components/account-settings/language-toggle.tsx@@ -1,7 +1,7 @@import { ApFlagId } from '@activepieces/shared';import { useMutation } from '@tanstack/react-query';import { t } from 'i18next';-import { Check, ChevronsUpDown, Globe } from 'lucide-react';+import { Check, ChevronsUpDown } from 'lucide-react';import { useState } from 'react';import { useTranslation } from 'react-i18next';import { Link } from 'react-router-dom';@@ -16,7 +16,6 @@ import {CommandItem,CommandList,} from '@/components/ui/command';-import { Label } from '@/components/ui/label';import {Popover,PopoverContent,@@ -27,6 +26,8 @@ import { flagsHooks } from '@/hooks/flags-hooks';import { localesMap } from '@/lib/locale-utils';import { cn } from '@/lib/utils';+import { SETTING_TRIGGER_CLASS, SettingRow } from './setting-row';+export const LanguageToggle = () => {const { i18n } = useTranslation();const [isOpen, setIsOpen] = useState(false);@@ -47,41 +48,55 @@ export const LanguageToggle = () => {},});+ const languageLabel = selectedLanguage+ ? localesMap[selectedLanguage as keyof typeof localesMap]+ : t('Select language');+return (- <div className="space-y-2">- <Label className="text-sm font-medium flex items-center gap-2">- <Globe className="w-4 h-4" />- {t('Language')}- </Label>+ <SettingRow+ title={t('Language')}+ description={+ showCommunity ? (+ <Link+ className="text-accent-11 hover:underline"+ rel="noopener noreferrer"+ target="_blank"+ to="https://www.activepieces.com/docs/about/i18n"+ >+ {t('Help translate Activepieces →')}+ </Link>+ ) : undefined+ }+ ><Popover modal={true} open={isOpen} onOpenChange={setIsOpen}><PopoverTrigger asChild><Buttonvariant="outline"+ size="sm"role="combobox"+ aria-label={`${t('Language')}, ${languageLabel}`}className={cn(- 'w-full justify-between font-normal',+ SETTING_TRIGGER_CLASS,!selectedLanguage && 'text-gray-11',)}disabled={isPending}>{isPending ? (- <LoadingSpinner className="w-4 h-4" />- ) : selectedLanguage ? (- localesMap[selectedLanguage as keyof typeof localesMap]+ <LoadingSpinner className="size-4" />) : (- t('Select language')+ <span className="truncate">{languageLabel}</span>)}- <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />+ <ChevronsUpDown className="text-gray-11" /></Button></PopoverTrigger>- <PopoverContent className="w-full p-0" align="start">+ <PopoverContent className="w-60 p-0" align="end"><Command><CommandInputplaceholder={i18n.t('Search language...')}className="h-8 text-sm"/><CommandList>- <ScrollArea className="h-[200px] w-[300px]">+ <ScrollArea className="h-[200px]"><CommandEmpty className="py-4 text-center text-sm">{i18n.t('No language found.')}</CommandEmpty>@@ -89,14 +104,15 @@ export const LanguageToggle = () => {{Object.entries(localesMap).map(([value, label]) => (<CommandItemvalue={value}+ keywords={[label]}key={value}onSelect={(value) => mutate(value)}- className="flex items-center justify-between py-2 text-sm"+ className="justify-between text-sm">- <div className="flex items-center gap-2">{label}</div>+ {label}<CheckclassName={cn(- 'h-4 w-4',+ 'size-4',value === selectedLanguage? 'opacity-100': 'opacity-0',@@ -110,18 +126,6 @@ export const LanguageToggle = () => {</Command></PopoverContent></Popover>- {showCommunity && (- <div className="pt-1">- <Link- className="text-xs text-accent-11 hover:underline font-medium"- rel="noopener noreferrer"- target="_blank"- to="https://www.activepieces.com/docs/about/i18n"- >- {t('Help translate Activepieces →')}- </Link>- </div>- )}- </div>+ </SettingRow>);};diff --git a/packages/web/src/app/components/account-settings/setting-row.tsx b/packages/web/src/app/components/account-settings/setting-row.tsxnew file mode 100644index 00000000000..b43e4d08ba8--- /dev/null+++ b/packages/web/src/app/components/account-settings/setting-row.tsx@@ -0,0 +1,25 @@+import React from 'react';++export function SettingRow({+ title,+ description,+ children,+}: {+ title: string;+ description?: React.ReactNode;+ children: React.ReactNode;+}) {+ return (+ <div className="flex items-center justify-between gap-4 px-4 py-3">+ <div className="flex min-w-0 flex-col gap-0.5">+ <span className="text-sm font-medium text-gray-12">{title}</span>+ {description && (+ <span className="text-xs text-gray-11">{description}</span>+ )}+ </div>+ <div className="shrink-0">{children}</div>+ </div>+ );+}++export const SETTING_TRIGGER_CLASS = 'w-40 justify-between font-normal';diff --git a/packages/web/src/app/components/account-settings/theme-toggle.tsx b/packages/web/src/app/components/account-settings/theme-toggle.tsxindex a7c168f849a..ca5d3c07092 100644--- a/packages/web/src/app/components/account-settings/theme-toggle.tsx+++ b/packages/web/src/app/components/account-settings/theme-toggle.tsx@@ -1,50 +1,76 @@import { t } from 'i18next';-import { Monitor, Moon, Palette, Sun } from 'lucide-react';+import { ChevronsUpDown, Monitor, Moon, Sun } from 'lucide-react';-import { useTheme } from '@/components/providers/theme-provider';-import { Label } from '@/components/ui/label';import {- Select,- SelectContent,- SelectItem,- SelectTrigger,- SelectValue,-} from '@/components/ui/select';+ ThemePreference,+ useTheme,+} from '@/components/providers/theme-provider';+import { Button } from '@/components/ui/button';+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuRadioGroup,+ DropdownMenuRadioItem,+ DropdownMenuTrigger,+} from '@/components/ui/dropdown-menu';++import { SETTING_TRIGGER_CLASS, SettingRow } from './setting-row';export const ThemeToggle = () => {const { preference, setPreference } = useTheme();+ const options = themeOptions();+ const current = options.find((option) => option.value === preference);return (- <div className="space-y-2">- <Label className="text-sm font-medium flex items-center gap-2">- <Palette className="w-4 h-4" />- {t('Theme')}- </Label>- <Select value={preference} onValueChange={setPreference}>- <SelectTrigger>- <SelectValue />- </SelectTrigger>- <SelectContent>- <SelectItem value="light" className="text-sm py-2">- <div className="flex items-center gap-2">- <Sun className="w-4 h-4" />- Light- </div>- </SelectItem>- <SelectItem value="dark" className="text-sm py-2">- <div className="flex items-center gap-2">- <Moon className="w-4 h-4" />- Dark- </div>- </SelectItem>- <SelectItem value="system" className="text-sm py-2">- <div className="flex items-center gap-2">- <Monitor className="w-4 h-4" />- System- </div>- </SelectItem>- </SelectContent>- </Select>- </div>+ <SettingRow title={t('Theme')}>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button+ variant="outline"+ size="sm"+ aria-label={`${t('Theme')}, ${current?.label ?? ''}`}+ className={SETTING_TRIGGER_CLASS}+ >+ <span className="flex min-w-0 items-center gap-2">+ {current && <current.icon className="text-gray-11" />}+ <span className="truncate">{current?.label}</span>+ </span>+ <ChevronsUpDown className="text-gray-11" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" className="w-40">+ <DropdownMenuRadioGroup+ value={preference}+ onValueChange={(value) => {+ const next = options.find((option) => option.value === value);+ if (next) {+ setPreference(next.value);+ }+ }}+ >+ {options.map((option) => (+ <DropdownMenuRadioItem key={option.value} value={option.value}>+ <option.icon className="text-gray-11" />+ {option.label}+ </DropdownMenuRadioItem>+ ))}+ </DropdownMenuRadioGroup>+ </DropdownMenuContent>+ </DropdownMenu>+ </SettingRow>);};++function themeOptions(): ThemeOption[] {+ return [+ { value: 'light', label: t('Light'), icon: Sun },+ { value: 'dark', label: t('Dark'), icon: Moon },+ { value: 'system', label: t('System'), icon: Monitor },+ ];+}++type ThemeOption = {+ value: ThemePreference;+ label: string;+ icon: typeof Sun;+};diff --git a/packages/web/src/app/components/builder-layout/index.tsx b/packages/web/src/app/components/builder-layout/index.tsxindex 621095546ea..4e73fc87aae 100644--- a/packages/web/src/app/components/builder-layout/index.tsx+++ b/packages/web/src/app/components/builder-layout/index.tsx@@ -10,7 +10,7 @@ import {GlobalSearchProvider,useGlobalSearch,} from '../global-search/global-search-context';-import { PrimaryRail } from '../primary-rail';+import { AppSidebar } from '../sidebar/app-sidebar';export function BuilderLayout({ children }: { children: React.ReactNode }) {return (@@ -26,12 +26,21 @@ function BuilderLayoutInner({ children }: { children: React.ReactNode }) {const { open: searchOpen } = useGlobalSearch();return (- <div className="flex h-full w-full overflow-hidden">- {!embedState.isEmbedded && <PrimaryRail />}+ <div+ className={cn(+ 'flex h-full w-full overflow-hidden',+ !embedState.isEmbedded && 'max-md:h-svh max-md:flex-col',+ )}+ >+ {!embedState.isEmbedded && <AppSidebar mode="app" />}<SidebarProviderhoverMode={!searchOpen}defaultOpen={false}- className="flex-1 min-w-0 w-auto will-change-transform"+ keyboardShortcut={embedState.isEmbedded}+ className={cn(+ 'flex-1 min-w-0 w-auto will-change-transform',+ !embedState.isEmbedded && 'max-md:h-auto max-md:min-h-0',+ )}><SidebarInset className="flex flex-col h-full overflow-hidden bg-gray-2"><divdiff --git a/packages/web/src/app/components/help-and-feedback.tsx b/packages/web/src/app/components/help-and-feedback.tsxindex 1c745c34a72..60cf1144d8f 100644--- a/packages/web/src/app/components/help-and-feedback.tsx+++ b/packages/web/src/app/components/help-and-feedback.tsx@@ -19,7 +19,7 @@ export const HelpAndFeedback = () => {return (<DropdownMenuSub><DropdownMenuSubTrigger className="flex items-center w-full text-left px-2 py-1.5 text-sm rounded-md cursor-pointer">- <CircleHelp className="w-4 h-4 mr-2" />+ <CircleHelp className="size-4" />{t('Help & Feedback')}</DropdownMenuSubTrigger><DropdownMenuSubContent className="w-[220px]">diff --git a/packages/web/src/app/components/platform-layout.tsx b/packages/web/src/app/components/platform-layout.tsxindex bdb1e942147..e47271cf3a0 100644--- a/packages/web/src/app/components/platform-layout.tsx+++ b/packages/web/src/app/components/platform-layout.tsx@@ -9,7 +9,7 @@ import { flagsHooks } from '@/hooks/flags-hooks';import { AllowOnlyLoggedInUserOnlyGuard } from './allow-logged-in-user-only-guard';import { GlobalSearchProvider } from './global-search/global-search-context';-import { PlatformSidebar } from './sidebar/platform';+import { AppSidebar } from './sidebar/app-sidebar';export function PlatformLayout({ children }: { children: React.ReactNode }) {const { data: edition } = flagsHooks.useFlag<ApEdition>(ApFlagId.EDITION);@@ -19,21 +19,27 @@ export function PlatformLayout({ children }: { children: React.ReactNode }) {<AllowOnlyLoggedInUserOnlyGuard><GlobalSearchProvider>{showPlatformAdminDashboard ? (- <SidebarProvider open={true} style={PLATFORM_SIDEBAR_STYLE}>- <PlatformSidebar />- <SidebarInset className="flex flex-col h-full overflow-hidden bg-gray-2">- <div className="flex-1 flex flex-col pr-2 pt-3 pb-3 overflow-hidden">- <div- id="dashboard-content-container"- className="relative flex flex-col h-full bg-gray-1 rounded-xl shadow-panel border overflow-clip"- >- <div className="flex flex-col flex-1 overflow-auto">- {children}+ <div className="flex h-full w-full overflow-hidden max-md:h-svh max-md:flex-col">+ <AppSidebar mode="platform" />+ <SidebarProvider+ open={true}+ keyboardShortcut={false}+ className="flex-1 min-w-0 w-auto max-md:h-auto max-md:min-h-0"+ >+ <SidebarInset className="flex flex-col h-full overflow-hidden bg-gray-2">+ <div className="flex-1 flex flex-col pr-2 pt-3 pb-3 overflow-hidden max-md:pl-2 max-md:pt-2">+ <div+ id="dashboard-content-container"+ className="relative flex flex-col h-full bg-gray-1 rounded-xl shadow-panel border overflow-clip"+ >+ <div className="flex flex-col flex-1 overflow-auto">+ {children}+ </div></div></div>- </div>- </SidebarInset>- </SidebarProvider>+ </SidebarInset>+ </SidebarProvider>+ </div>) : (<Navigate to="/" />)}@@ -42,9 +48,3 @@ export function PlatformLayout({ children }: { children: React.ReactNode }) {</AllowOnlyLoggedInUserOnlyGuard>);}--const PLATFORM_SIDEBAR_STYLE: React.CSSProperties & {- '--sidebar-width': string;-} = {- '--sidebar-width': '16rem',-};diff --git a/packages/web/src/app/components/primary-rail/index.tsx b/packages/web/src/app/components/primary-rail/index.tsxdeleted file mode 100644index 9cf99618e74..00000000000--- a/packages/web/src/app/components/primary-rail/index.tsx+++ /dev/null@@ -1,808 +0,0 @@-import {- ApEdition,- ApFlagId,- isNil,- PlatformRole,- PROJECT_COLOR_PALETTE,- ProjectType,- ProjectWithLimits,- TemplateTelemetryEventType,-} from '@activepieces/shared';-import { useQueryClient } from '@tanstack/react-query';-import { t } from 'i18next';-import {- Bot,- ChartLine,- ChevronsUpDown,- Compass,- Lock,- LogOut,- PanelLeftClose,- Search,- Settings,- Shield,- SlidersHorizontal,- SquarePen,- Unplug,- UserCogIcon,-} from 'lucide-react';-import { motion, useReducedMotion } from 'motion/react';-import { ComponentType, useState } from 'react';-import { Link, useLocation, useNavigate } from 'react-router-dom';--import { UserAvatar } from '@/components/custom/user-avatar';-import { useEmbedding } from '@/components/providers/embed-provider';-import { Button } from '@/components/ui/button';-import {- DropdownMenu,- DropdownMenuContent,- DropdownMenuGroup,- DropdownMenuItem,- DropdownMenuLabel,- DropdownMenuSeparator,- DropdownMenuTrigger,-} from '@/components/ui/dropdown-menu';-import {- Tooltip,- TooltipContent,- TooltipProvider,- TooltipTrigger,-} from '@/components/ui/tooltip';-import { useAgentsNavVisible } from '@/features/agents';-import { SidebarUsageLimits } from '@/features/billing';-import { chatUtils } from '@/features/chat/lib/chat-utils';-import {- CreateProjectButton,- getProjectName,- PlatformSwitcher,- projectCollectionUtils,-} from '@/features/projects';-import { templatesTelemetryApi } from '@/features/templates';-import {- railIsCollapsed,- useRailCollapsed,-} from '@/features/workspace/lib/rail-collapsed';-import { useIsPlatformAdmin } from '@/hooks/authorization-hooks';-import { flagsHooks } from '@/hooks/flags-hooks';-import { platformHooks } from '@/hooks/platform-hooks';-import { userHooks } from '@/hooks/user-hooks';-import { authenticationSession } from '@/lib/authentication-session';-import { cn } from '@/lib/utils';--import { AccountSettingsDialog } from '../account-settings';-import { recordAccess } from '../global-search/access-history';-import { useGlobalSearch } from '../global-search/global-search-context';-import { HelpAndFeedback } from '../help-and-feedback';-import { mcpHooks } from '../project-settings/mcp-server/utils/mcp-hooks';--export function PrimaryRail() {- const { embedState } = useEmbedding();- const { platform } = platformHooks.useCurrentPlatform();- const { data: currentUser } = userHooks.useCurrentUser();- const { preference, setCollapsed, toggle } = useRailCollapsed();- const { pathname } = useLocation();- const [openedOn, setOpenedOn] = useState<string | null>(null);- const collapsed = railIsCollapsed({ preference, pathname, openedOn });- const showAgents = useAgentsNavVisible();- const isRailHidden = embedState.isEmbedded || embedState.hideSideNav;- const { reachesMcp } = mcpHooks.useMcpReach({ enabled: !isRailHidden });-- if (isRailHidden) {- return null;- }-- const openSidebar = () => {- setOpenedOn(pathname);- setCollapsed(false);- };- const toggleCollapsed = () => {- setOpenedOn(pathname);- toggle();- };-- return (- <TooltipProvider delayDuration={300}>- <div- onClick={collapsed ? openSidebar : undefined}- title={collapsed ? t('Open sidebar') : undefined}- className={cn(- 'flex h-svh shrink-0 flex-col overflow-hidden whitespace-nowrap bg-gray-2 py-3 transition-[width] duration-200 motion-reduce:transition-none',- collapsed ? 'w-14 cursor-ew-resize items-center' : 'w-62',- )}- >- <RailHeader collapsed={collapsed} onToggle={toggleCollapsed} />-- <div- className={cn(- 'mt-2 flex min-h-0 flex-1 flex-col',- collapsed ? 'items-center px-2' : 'px-2',- )}- >- <div- className={cn(- 'flex shrink-0 flex-col gap-1',- collapsed && 'items-center',- )}- >- {platform.plan.chatEnabled && (- <RailNavButton- collapsed={collapsed}- to="/chat"- icon={SquarePen}- label={t('Chat')}- isActive={({ pathname }) => pathname.startsWith('/chat')}- onClick={() =>- window.dispatchEvent(new Event(chatUtils.newChatEvent))- }- />- )}- {reachesMcp && (- <RailNavButton- collapsed={collapsed}- to="/mcp-server"- icon={Unplug}- label={t('MCP')}- isActive={({ pathname }) => pathname.startsWith('/mcp-server')}- />- )}- {showAgents && (- <RailNavButton- collapsed={collapsed}- to="/agents"- icon={Bot}- label={t('Agents')}- isActive={({ pathname }) => pathname.startsWith('/agents')}- />- )}- <RailNavButton- collapsed={collapsed}- to="/templates"- icon={Compass}- label={t('Explore')}- isActive={({ pathname }) => pathname.startsWith('/templates')}- onClick={() =>- templatesTelemetryApi.sendEvent({- eventType: TemplateTelemetryEventType.EXPLORE_VIEW,- userId: currentUser?.id,- })- }- />- <RailNavButton- collapsed={collapsed}- to="/impact"- icon={ChartLine}- label={t('Impact')}- isActive={({ pathname }) => pathname.startsWith('/impact')}- />- </div>- <RailPinnedProjects collapsed={collapsed} />- </div>-- {!collapsed && (- <div className="mx-2 mb-1">- <SidebarUsageLimits />- </div>- )}- <RailPlatformAdminButton collapsed={collapsed} />- <RailAccountRow collapsed={collapsed} />- </div>- </TooltipProvider>- );-}--function RailHeader({- collapsed,- onToggle,-}: {- collapsed: boolean;- onToggle: () => void;-}) {- const branding = flagsHooks.useWebsiteBranding();- const { setOpen: setSearchOpen } = useGlobalSearch();- const { embedState } = useEmbedding();- const { data: edition } = flagsHooks.useFlag<ApEdition>(ApFlagId.EDITION);- const { platform: currentPlatform } = platformHooks.useCurrentPlatform();- const showSwitcher = edition === ApEdition.CLOUD && !embedState.isEmbedded;-- if (collapsed) {- return (- <div className="flex flex-col items-center gap-1 px-2">- <Tooltip>- <TooltipTrigger asChild>- <button- type="button"- onClick={onToggle}- aria-label={t('Open sidebar')}- className="flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-md hover:bg-gray-4"- >- <img- src={branding.logos.logoIconUrl}- alt={branding.websiteName}- className="size-5 shrink-0"- draggable={false}- />- </button>- </TooltipTrigger>- <TooltipContent side="right">{t('Open sidebar')}</TooltipContent>- </Tooltip>-- <Tooltip>- <TooltipTrigger asChild>- <button- type="button"- onClick={(e) => {- e.stopPropagation();- setSearchOpen(true);- }}- aria-label={t('Search')}- className="flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-full text-gray-11 hover:bg-gray-4 hover:text-gray-12"- >- <Search className="size-4" />- </button>- </TooltipTrigger>- <TooltipContent side="right">{t('Search')}</TooltipContent>- </Tooltip>- </div>- );- }-- return (- <div className="flex items-center gap-1 px-2">- <Tooltip>- <TooltipTrigger asChild>- <Link- to="/"- className="flex size-9 shrink-0 items-center justify-center rounded-md hover:bg-gray-4"- >- <img- src={branding.logos.logoIconUrl}- alt={branding.websiteName}- className="size-5 shrink-0"- draggable={false}- />- </Link>- </TooltipTrigger>- <TooltipContent side="right">{branding.websiteName}</TooltipContent>- </Tooltip>-- {showSwitcher ? (- <div className="min-w-0 flex-1">- <PlatformSwitcher>- <button- type="button"- className="flex h-9 w-full items-center gap-2 rounded-md px-2 text-left hover:bg-gray-4"- >- <span className="flex-1 truncate text-sm font-medium">- {currentPlatform?.name ?? t('platform')}- </span>- <ChevronsUpDown className="ml-auto size-3 shrink-0" />- </button>- </PlatformSwitcher>- </div>- ) : (- <h1 className="min-w-0 flex-1 truncate text-sm font-medium">- {branding.websiteName}- </h1>- )}-- <div className="flex shrink-0 items-center gap-0.5">- <Tooltip>- <TooltipTrigger asChild>- <Button- variant="ghost"- size="icon"- className="size-8 shrink-0 rounded-full text-gray-11 hover:bg-gray-4 hover:text-gray-12"- onClick={() => setSearchOpen(true)}- aria-label={t('Search')}- >- <Search className="size-4" />- </Button>- </TooltipTrigger>- <TooltipContent side="right">{t('Search')}</TooltipContent>- </Tooltip>-- <Tooltip>- <TooltipTrigger asChild>- <Button- variant="ghost"- size="icon"- className="size-8 shrink-0 rounded-full text-gray-11 hover:bg-gray-4 hover:text-gray-12"- onClick={onToggle}- aria-label={t('Close sidebar')}- >- <PanelLeftClose className="size-4" />- </Button>- </TooltipTrigger>- <TooltipContent side="right">{t('Close sidebar')}</TooltipContent>- </Tooltip>- </div>- </div>- );-}--function RailPlatformAdminButton({ collapsed }: { collapsed: boolean }) {- const showPlatformAdmin = useIsPlatformAdmin();- const { embedState } = useEmbedding();-- if (embedState.isEmbedded || !showPlatformAdmin) {- return null;- }-- return (- <div className={cn('flex flex-col px-2 pb-1', collapsed && 'items-center')}>- <div- className={cn(- 'mb-1 h-px shrink-0 bg-gray-6',- collapsed ? 'w-6' : 'mx-3',- )}- />- <RailNavButton- collapsed={collapsed}- to="/platform/projects"- icon={Shield}- label={t('Platform Admin')}- isActive={({ pathname }) => pathname.startsWith('/platform')}- />- </div>- );-}--function RailNavButton({- collapsed,- to,- icon: Icon,- label,- isActive,- onClick,-}: {- collapsed: boolean;- to: string;- icon: ComponentType<{ className?: string }>;- label: string;- isActive: (location: { pathname: string; search: string }) => boolean;- onClick?: () => void;-}) {- const location = useLocation();- const active = isActive(location);-- const link = (- <Link- to={to}- aria-label={label}- onClick={(e) => {- e.stopPropagation();- onClick?.();- }}- className={cn(- 'flex shrink-0 items-center gap-3 rounded-full text-sm text-gray-12 hover:bg-gray-4 hover:text-gray-12',- collapsed ? 'size-9 cursor-pointer justify-center' : 'h-10 px-3',- active && 'bg-gray-4 font-medium text-gray-12',- )}- >- <Icon- className={cn('size-[18px] shrink-0', active && 'text-accent-11')}- />- {!collapsed && <span className="truncate">{label}</span>}- </Link>- );-- if (!collapsed) {- return link;- }-- return (- <Tooltip>- <TooltipTrigger asChild>{link}</TooltipTrigger>- <TooltipContent side="right">{label}</TooltipContent>- </Tooltip>- );-}--function RailPinnedProjects({ collapsed }: { collapsed: boolean }) {- const { data: projects } = projectCollectionUtils.useAll();- const { platform } = platformHooks.useCurrentPlatform();- const { data: currentUser } = userHooks.useCurrentUser();- const location = useLocation();- const navigate = useNavigate();- const showCreateProject =- platform.plan.billedTeamProjectsLimit !== 0 &&- currentUser?.platformRole === PlatformRole.ADMIN;- const [sort, setSort] = useState<PinnedSort>(() =>- readStoredSort(localStorage.getItem(PINNED_SORT_KEY)),- );-- const changeSort = (next: PinnedSort) => {- setSort(next);- localStorage.setItem(PINNED_SORT_KEY, next);- };-- if (projects.length === 0) {- return null;- }-- const ordered = orderProjects({- projects,- sort,- });-- const openProject = ({- projectId,- name,- }: {- projectId: string;- name: string;- }) => {- recordAccess({- id: `project-${projectId}`,- type: 'project',- label: name,- href: `/projects/${projectId}/automations`,- });- if (projectId !== authenticationSession.getProjectId()) {- authenticationSession.switchToProject(projectId);- }- navigate(`/projects/${projectId}/automations`);- };-- return (- <div- className={cn(- 'mt-2 flex min-h-0 flex-1 flex-col',- collapsed && 'items-center',- )}- >- <div- className={cn(- 'mb-1 h-px shrink-0 bg-gray-6',- collapsed ? 'w-6' : 'mx-3',- )}- />- {!collapsed && (- <div className="flex shrink-0 items-center gap-1 py-0.5 pl-3 pr-1">- <span className="text-xs font-medium text-gray-11">- {t('Projects')}- </span>- <div className="ml-auto flex items-center gap-0.5">- {showCreateProject && (- <CreateProjectButton- variant="icon"- projects={projects ?? []}- className={RAIL_HEADER_ICON_BUTTON}- onCreate={(project) => {- navigate(`/projects/${project.id}/automations`);- }}- />- )}- <PinnedSortMenu sort={sort} onChange={changeSort} />- </div>- </div>- )}- <div- className={cn(- 'flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto',- collapsed && 'items-center',- )}- >- {ordered.map((project) => (- <ProjectRow- key={project.id}- project={project}- collapsed={collapsed}- active={location.pathname.includes(`/projects/${project.id}`)}- onOpen={openProject}- />- ))}- </div>- </div>- );-}--function ProjectRow({- project,- collapsed,- active,- onOpen,-}: {- project: ProjectWithLimits;- collapsed: boolean;- active: boolean;- onOpen: (params: { projectId: string; name: string }) => void;-}) {- const prefersReducedMotion = useReducedMotion();- const name = getProjectName(project);- const isTeam = project.type === ProjectType.TEAM;- const palette =- isTeam && project.icon ? PROJECT_COLOR_PALETTE[project.icon.color] : null;-- const badge = (- <span- className="flex size-4.5 shrink-0 items-center justify-center rounded-sm text-xs font-semibold leading-none"- style={- palette- ? { backgroundColor: palette.color, color: palette.textColor }- : undefined- }- >- {isTeam ? (- name.charAt(0).toUpperCase()- ) : (- <Lock className="size-3 text-gray-11" />- )}- </span>- );-- const row = (- <motion.button- layout={!prefersReducedMotion}- transition={{ duration: 0.4, ease: [0.16, 1, 0.3, 1] }}- type="button"- onClick={(e) => {- e.stopPropagation();- onOpen({ projectId: project.id, name });- }}- aria-label={name}- className={cn(- 'flex shrink-0 items-center gap-3 rounded-full text-sm text-gray-12 hover:bg-gray-4 hover:text-gray-12',- collapsed ? 'size-9 cursor-pointer justify-center' : 'h-9 w-full px-3',- active && 'bg-gray-4 font-medium text-gray-12',- )}- >- {badge}- {!collapsed && (- <span className="min-w-0 flex-1 truncate text-left">{name}</span>- )}- </motion.button>- );-- if (!collapsed) {- return row;- }-- return (- <Tooltip>- <TooltipTrigger asChild>{row}</TooltipTrigger>- <TooltipContent side="right">{name}</TooltipContent>- </Tooltip>- );-}--function PinnedSortMenu({- sort,- onChange,-}: {- sort: PinnedSort;- onChange: (next: PinnedSort) => void;-}) {- return (- <DropdownMenu>- <DropdownMenuTrigger- aria-label={t('Sort pinned projects')}- className={cn(- RAIL_HEADER_ICON_BUTTON,- 'flex items-center justify-center data-[state=open]:bg-gray-4',- )}- >- <SlidersHorizontal className="size-3.5" />- </DropdownMenuTrigger>- <DropdownMenuContent align="start" side="right" className="w-48">- <PinnedMenuOption- label={t('Recently added')}- active={sort === 'added'}- onClick={() => onChange('added')}- />- <PinnedMenuOption- label={t('Recently used')}- active={sort === 'recency'}- onClick={() => onChange('recency')}- />- <PinnedMenuOption- label={t('Alphabetical')}- active={sort === 'alphabetical'}- onClick={() => onChange('alphabetical')}- />- </DropdownMenuContent>- </DropdownMenu>- );-}--function PinnedMenuOption({- label,- active,- onClick,-}: {- label: string;- active: boolean;- onClick: () => void;-}) {- return (- <DropdownMenuItem onClick={onClick} className="justify-between">- {label}- {active && <span className="text-accent-11">✓</span>}- </DropdownMenuItem>- );-}--function readStoredSort(stored: string | null): PinnedSort {- return PINNED_SORTS.find((sort) => sort === stored) ?? 'added';-}--function lastFlowUpdatedAt(project: ProjectWithLimits): number {- const lastFlowUpdated = project.analytics.lastFlowUpdated;- if (isNil(lastFlowUpdated)) {- return 0;- }- return new Date(lastFlowUpdated).getTime();-}--function compareProjects({ sort }: { sort: PinnedSort }) {- return (a: ProjectWithLimits, b: ProjectWithLimits): number => {- if (sort === 'alphabetical') {- return getProjectName(a).localeCompare(getProjectName(b));- }- if (sort === 'added') {- return new Date(b.created).getTime() - new Date(a.created).getTime();- }- const flowA = lastFlowUpdatedAt(a);- const flowB = lastFlowUpdatedAt(b);- if (flowA !== flowB) {- return flowB - flowA;- }- return new Date(b.updated).getTime() - new Date(a.updated).getTime();- };-}--function orderProjects({- projects,- sort,-}: {- projects: ProjectWithLimits[];- sort: PinnedSort;-}): ProjectWithLimits[] {- const compare = compareProjects({ sort });- const personal = projects.filter(- (project) => project.type !== ProjectType.TEAM,- );- const others = projects.filter(- (project) => project.type === ProjectType.TEAM,- );- return [...personal.sort(compare), ...others.sort(compare)];-}--function RailAccountRow({ collapsed }: { collapsed: boolean }) {- const [accountSettingsOpen, setAccountSettingsOpen] = useState(false);- const { data: user } = userHooks.useCurrentUser();- const queryClient = useQueryClient();- const navigate = useNavigate();-- if (!user) {- return null;- }-- const handleLogout = () => {- userHooks.invalidateCurrentUser(queryClient);- authenticationSession.logOut();- navigate('/sign-in');- };-- return (- <div- className={cn(- 'mt-2 flex items-center',- collapsed ? 'flex-col-reverse gap-1' : 'justify-between px-2',- )}- >- <DropdownMenu modal>- <Tooltip>- <TooltipTrigger asChild>- <DropdownMenuTrigger asChild>- <button- type="button"- aria-label={t('Account')}- onClick={(e) => e.stopPropagation()}- className={cn(- 'flex items-center gap-2 rounded-full hover:bg-gray-4',- collapsed- ? 'size-9 cursor-pointer justify-center'- : 'h-10 min-w-0 flex-1 px-2',- )}- >- <div className="size-[22px] shrink-0 overflow-hidden rounded-full">- <UserAvatar- className={cn('size-full object-cover', {- 'scale-150': isNil(user.imageUrl),- })}- name={user.firstName + ' ' + user.lastName}- email={user.email}- imageUrl={user.imageUrl}- size={22}- disableTooltip={true}- />- </div>- {!collapsed && (- <span className="min-w-0 flex-1 truncate text-left text-sm">- {user.firstName + ' ' + user.lastName}- </span>- )}- </button>- </DropdownMenuTrigger>- </TooltipTrigger>- {collapsed && (- <TooltipContent side="right">{t('Account')}</TooltipContent>- )}- </Tooltip>- <DropdownMenuContent- className="w-56"- side="right"- align="end"- sideOffset={10}- >- <DropdownMenuLabel className="p-0 font-normal">- <div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm">- <div className="size-8 shrink-0 overflow-hidden rounded-full">- <UserAvatar- className="size-full object-cover"- name={user.firstName + ' ' + user.lastName}- email={user.email}- imageUrl={user.imageUrl}- size={32}- disableTooltip={true}- />- </div>- <div className="grid flex-1 text-left text-sm leading-tight">- <span className="truncate font-medium">- {user.firstName + ' ' + user.lastName}- </span>- <span className="truncate text-xs">{user.email}</span>- </div>- </div>- </DropdownMenuLabel>- <DropdownMenuSeparator />- <DropdownMenuGroup>- <DropdownMenuItem onClick={() => setAccountSettingsOpen(true)}>- <UserCogIcon className="w-4 h-4 mr-2" />- {t('Account Settings')}- </DropdownMenuItem>- <HelpAndFeedback />- </DropdownMenuGroup>- <DropdownMenuSeparator />- <DropdownMenuItem onClick={handleLogout}>- <LogOut className="w-4 h-4 mr-2" />- {t('Log out')}- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>-- <Tooltip>- <TooltipTrigger asChild>- <Button- variant="ghost"- size="icon"- className="size-8 shrink-0 cursor-pointer rounded-full text-gray-11 hover:bg-gray-4 hover:text-gray-12"- onClick={(e) => {- e.stopPropagation();- setAccountSettingsOpen(true);- }}- aria-label={t('Settings')}- >- <Settings className="size-4" />- </Button>- </TooltipTrigger>- <TooltipContent side="right">{t('Settings')}</TooltipContent>- </Tooltip>-- <AccountSettingsDialog- open={accountSettingsOpen}- onClose={() => setAccountSettingsOpen(false)}- />- </div>- );-}--const RAIL_HEADER_ICON_BUTTON =- 'size-6 rounded-md text-gray-11 hover:bg-gray-4 hover:text-gray-12 [&_svg]:size-3.5!';--const PINNED_SORT_KEY = 'rail-pinned-sort';--const PINNED_SORTS = ['added', 'recency', 'alphabetical'] as const;--type PinnedSort = (typeof PINNED_SORTS)[number];diff --git a/packages/web/src/app/components/project-layout/index.tsx b/packages/web/src/app/components/project-layout/index.tsxindex 91778ff88b2..21ead72ae16 100644--- a/packages/web/src/app/components/project-layout/index.tsx+++ b/packages/web/src/app/components/project-layout/index.tsx@@ -20,7 +20,7 @@ import {GlobalSearchProvider,useGlobalSearch,} from '../global-search/global-search-context';-import { PrimaryRail } from '../primary-rail';+import { AppSidebar } from '../sidebar/app-sidebar';import { ProjectDashboardLayoutHeader } from './project-dashboard-layout-header';@@ -139,18 +139,27 @@ function ProjectDashboardLayoutInner({const { open: searchOpen } = useGlobalSearch();return (- <div className="flex h-full w-full overflow-hidden">- {!isEmbedded && <PrimaryRail />}+ <div+ className={cn(+ 'flex h-full w-full overflow-hidden',+ !isEmbedded && 'max-md:h-svh max-md:flex-col',+ )}+ >+ {!isEmbedded && <AppSidebar mode="app" />}<SidebarProviderdefaultOpen={false}hoverMode={!searchOpen}- className="flex-1 min-w-0 w-auto will-change-transform"+ keyboardShortcut={isEmbedded}+ className={cn(+ 'flex-1 min-w-0 w-auto will-change-transform',+ !isEmbedded && 'max-md:h-auto max-md:min-h-0',+ )}><SidebarInset className="flex flex-col h-full overflow-hidden bg-gray-2"><divclassName={cn('flex-1 flex flex-col overflow-hidden',- !isEmbedded && 'pr-2 pt-3 pb-3',+ !isEmbedded && 'pr-2 pt-3 pb-3 max-md:pl-2 max-md:pt-2',)}><divdiff --git a/packages/web/src/app/components/sidebar/ap-sidebar-item.tsx b/packages/web/src/app/components/sidebar/ap-sidebar-item.tsxindex 2b0eb510f6c..b157cc71614 100644--- a/packages/web/src/app/components/sidebar/ap-sidebar-item.tsx+++ b/packages/web/src/app/components/sidebar/ap-sidebar-item.tsx@@ -1,7 +1,7 @@import { ApEdition, ApFlagId, TelemetryEventName } from '@activepieces/shared';import { t } from 'i18next';-import { ChevronDown, ChevronRight, Crown } from 'lucide-react';-import React, { ComponentType, useEffect, useRef, useState } from 'react';+import { ChevronRight } from 'lucide-react';+import React, { ComponentType, ReactNode, useRef, useState } from 'react';import { Link, matchPath, useLocation } from 'react-router-dom';import { useTelemetry } from '@/components/providers/telemetry-provider';@@ -24,26 +24,35 @@ import { flagsHooks } from '@/hooks/flags-hooks';import { cn } from '@/lib/utils';import { sidebarItemUtils } from './ap-sidebar-item-utils';+import { sidebarStyles } from './sidebar-styles';export const ApSidebarItem = (item: SidebarItemType) => {const location = useLocation();- const { state } = useSidebar();+ const { state, isMobile, setOpenMobile } = useSidebar();const { capture } = useTelemetry();const iconRef = useRef<AnimatedIconHandle | null>(null);- const [isHovered, setIsHovered] = useState(false);+ const [expandOverride, setExpandOverride] = useState<ExpandOverride | null>(+ null,+ );const pathname = location.pathname;- const isLinkActive = isRouteActive({ pathname, to: item.to });- const isCollapsed = state === 'collapsed';+ const isLinkActive = isRouteActive({+ pathname,+ to: item.activeOn ?? item.to,+ });+ const isCollapsed = state === 'collapsed' && !isMobile;const subItems = item.subItems ?? [];const hasSubItems = subItems.length > 0;- const [isExpanded, setIsExpanded] = useState(isLinkActive);+ const isExpanded =+ expandOverride?.pathname === pathname ? expandOverride.open : isLinkActive;const showSubItems = hasSubItems && isExpanded && !isCollapsed;const isSubItemLocked = (subItem: SidebarSubItemType) =>Boolean(item.locked) || Boolean(subItem.locked);- const isCrowned = hasSubItems+ const isPremium = hasSubItems? subItems.every(isSubItemLocked): Boolean(item.locked);- const isRowHighlighted = !hasSubItems && isLinkActive;+ const isRowHighlighted = hasSubItems+ ? isLinkActive && !showSubItems+ : isLinkActive;const parentTier = item.tier ?? subItems.find(isSubItemLocked)?.tier;const captureLockedClick = ({ path, tier }: LockedClick) =>@@ -52,6 +61,12 @@ export const ApSidebarItem = (item: SidebarItemType) => {payload: { path, tier },});+ const closeMobileSheet = () => {+ if (isMobile) {+ setOpenMobile(false);+ }+ };+const keepSearchWithinSection = (to: string) => {if (!hasSubItems || !isLinkActive) {return to;@@ -60,54 +75,88 @@ export const ApSidebarItem = (item: SidebarItemType) => {return shared === '' ? to : `${to}?${shared}`;};- useEffect(() => {- if (isLinkActive) {- setIsExpanded(true);+ const isSubItemActive = (subItem: SidebarSubItemType) =>+ isRouteActive({ pathname, to: subItem.to, end: subItem.end });++ const handleSubItemClick = (subItem: SidebarSubItemType) => {+ closeMobileSheet();+ if (+ isSubItemLocked(subItem) &&+ !isRouteActive({ pathname, to: subItem.to, end: true })+ ) {+ captureLockedClick({ path: subItem.to, tier: subItem.tier ?? item.tier });}- }, [isLinkActive]);+ };++ const hoverHandlers = {+ onMouseEnter: () => iconRef.current?.startAnimation?.(),+ onMouseLeave: () => iconRef.current?.stopAnimation?.(),+ };++ const plainIcon = item.icon && renderIcon({ Icon: item.icon, ref: iconRef });+ const icon = isPremium ? <PremiumGlyph className="size-4" /> : plainIcon;+ const lockedLabel = `${item.label}, ${t('Requires a plan upgrade')}`;+ const collapsedName = isPremium ? lockedLabel : item.label;- useEffect(() => {- if (isHovered) {- iconRef.current?.startAnimation?.();- } else {- iconRef.current?.stopAnimation?.();+ const collapsedTooltip = isPremium+ ? {+ children: (+ <span className="flex flex-col">+ <span>{item.label}</span>+ <span className="opacity-70">+ <LockedText tier={parentTier} />+ </span>+ </span>+ ),+ }+ : item.label;++ const toggleGroup = () => setExpandOverride({ pathname, open: !isExpanded });++ const handleRowClick = () => {+ closeMobileSheet();+ item.onClick?.();+ if (hasSubItems) {+ setExpandOverride({ pathname: item.to, open: true });}- }, [isHovered]);+ if (isPremium && !isRouteActive({ pathname, to: item.to, end: true })) {+ captureLockedClick({ path: item.to, tier: parentTier });+ }+ };++ const label = (+ <span+ className={cn(+ 'flex min-w-0 flex-1 items-center gap-1.5',+ sidebarStyles.labelFade,+ )}+ >+ <span className="truncate">{item.label}</span>+ {isPremium && (+ <span className="sr-only">{t('Requires a plan upgrade')}</span>+ )}+ </span>+ );const button = (<SidebarMenuButtonasChild- className={cn('h-8 [&_svg]:block [&_svg]:size-5', {- 'bg-gray-4 hover:bg-gray-4!': isRowHighlighted,- 'pr-8': hasSubItems && !isCollapsed,- })}+ isActive={isRowHighlighted}+ tooltip={collapsedTooltip}+ className={cn(hasSubItems && 'pr-8')}><Linkto={keepSearchWithinSection(item.to)}+ aria-label={isCollapsed ? collapsedName : undefined}aria-current={isRowHighlighted ? 'page' : undefined}- onClick={() => {- if (hasSubItems) {- setIsExpanded(true);- }- if (- isCrowned &&- !isRouteActive({ pathname, to: item.to, end: true })- ) {- captureLockedClick({ path: item.to, tier: parentTier });- }- }}- onMouseEnter={() => setIsHovered(true)}- onMouseLeave={() => setIsHovered(false)}+ onClick={handleRowClick}+ {...hoverHandlers}>- {item.icon && renderIcon({ Icon: item.icon, ref: iconRef })}- {!isCollapsed && (- <span className="flex min-w-0 items-center gap-1.5">- <span- className={cn('truncate', { 'font-medium': isRowHighlighted })}- >- {item.label}- </span>- {isCrowned && <CrownMark />}+ {icon}+ {label}+ {item.badge && (+ <span className={cn('ml-auto flex', sidebarStyles.labelFade)}>+ {item.badge}</span>)}</Link>@@ -116,98 +165,122 @@ export const ApSidebarItem = (item: SidebarItemType) => {return (<SidebarMenuItem>- {isCrowned && !isCollapsed ? (- <LockedTooltip tier={parentTier}>{button}</LockedTooltip>+ {isPremium ? (+ <LockedTooltip tier={parentTier} disabled={isCollapsed}>+ {button}+ </LockedTooltip>) : (button)}- {!isCollapsed && hasSubItems && (+ {hasSubItems && (<SidebarMenuAction- className="right-1.5 text-gray-9"aria-label={isExpanded ? t('Collapse') : t('Expand')}- aria-expanded={isExpanded}- onClick={() => setIsExpanded((expanded) => !expanded)}+ aria-expanded={showSubItems}+ aria-hidden={isCollapsed || undefined}+ tabIndex={isCollapsed ? -1 : undefined}+ onClick={toggleGroup}+ className="text-gray-9">- {isExpanded ? (- <ChevronDown aria-hidden />- ) : (- <ChevronRight aria-hidden />- )}+ <ChevronRight+ aria-hidden+ className={cn(sidebarStyles.rotate, isExpanded && 'rotate-90')}+ /></SidebarMenuAction>)}- {showSubItems && (- <SidebarMenuSub className="mx-0 ml-7 border-0 px-0 py-1">- {subItems.map((subItem) => {- const shut = isSubItemLocked(subItem);- const subItemTier = subItem.tier ?? item.tier;- const subItemActive = isRouteActive({- pathname,- to: subItem.to,- end: subItem.end,- });- const subButton = (- <SidebarMenuSubButton- asChild- isActive={subItemActive}- className="h-8"- >- <Link- to={keepSearchWithinSection(subItem.to)}- aria-current={subItemActive ? 'page' : undefined}- onClick={- shut &&- !isRouteActive({ pathname, to: subItem.to, end: true })- ? () =>- captureLockedClick({- path: subItem.to,- tier: subItemTier,- })- : undefined- }- >- <span className="flex min-w-0 items-center gap-1.5">- <span className="truncate">{subItem.label}</span>- {shut && !isCrowned && <CrownMark />}- </span>- </Link>- </SidebarMenuSubButton>- );- return (- <SidebarMenuSubItem key={subItem.to}>- {shut && !isCrowned ? (- <LockedTooltip tier={subItemTier}>{subButton}</LockedTooltip>- ) : (- subButton- )}- </SidebarMenuSubItem>- );- })}- </SidebarMenuSub>+ {hasSubItems && (+ <div+ className={cn(+ sidebarStyles.expand,+ showSubItems+ ? 'visible grid-rows-[1fr] opacity-100'+ : 'invisible grid-rows-[0fr] opacity-0',+ )}+ >+ <div className="min-h-0 overflow-hidden">+ <SidebarMenuSub>+ {subItems.map((subItem) => {+ const shut = isSubItemLocked(subItem);+ const active = isSubItemActive(subItem);+ const subButton = (+ <SidebarMenuSubButton asChild isActive={active}>+ <Link+ to={keepSearchWithinSection(subItem.to)}+ aria-current={active ? 'page' : undefined}+ onClick={() => handleSubItemClick(subItem)}+ >+ <span className="flex min-w-0 flex-1 items-center gap-1.5 whitespace-nowrap">+ <span className="truncate">{subItem.label}</span>+ {shut && !isPremium && (+ <PremiumMark className="size-3.5" />+ )}+ </span>+ </Link>+ </SidebarMenuSubButton>+ );+ return (+ <SidebarMenuSubItem key={subItem.to}>+ {shut && !isPremium ? (+ <LockedTooltip tier={subItem.tier ?? item.tier}>+ {subButton}+ </LockedTooltip>+ ) : (+ subButton+ )}+ </SidebarMenuSubItem>+ );+ })}+ </SidebarMenuSub>+ </div>+ </div>)}</SidebarMenuItem>);};-function LockedTooltip({ tier, children }: LockedTooltipProps) {+function LockedText({ tier }: { tier?: FeatureTier }) {const { data: edition } = flagsHooks.useFlag<ApEdition>(ApFlagId.EDITION);const namedTier = edition === ApEdition.COMMUNITY ? undefined : tier;+ return namedTier === undefined+ ? t('Not included in your plan')+ : t('Included in the {tier} plan', { tier: TIER_LABELS[namedTier] });+}++function LockedTooltip({ tier, disabled, children }: LockedTooltipProps) {return (<Tooltip><TooltipTrigger asChild>{children}</TooltipTrigger>- <TooltipContent side="right" align="center">- {namedTier === undefined- ? t('Not included in your plan')- : t('Included in the {tier} plan', { tier: TIER_LABELS[namedTier] })}+ <TooltipContent side="right" align="center" hidden={disabled}>+ <LockedText tier={tier} /></TooltipContent></Tooltip>);}-function CrownMark() {+// Phosphor's "sketch-logo" gem (MIT), traced as a Lucide-style stroke icon.+function PremiumGlyph({ className }: { className: string }) {+ return (+ <svg+ aria-hidden+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth={1.75}+ strokeLinecap="round"+ strokeLinejoin="round"+ className={cn('shrink-0 text-accent-11', className)}+ >+ <path d="M6.75 3.75h10.5l5.25 6L12 20.75 1.5 9.75z" />+ <path d="M1.5 9.75h21" />+ <path d="M8 9.75 12 3.75l4 6L12 20.75z" />+ </svg>+ );+}++function PremiumMark({ className }: { className: string }) {return (<>- <Crown aria-hidden className="size-3.5! shrink-0 text-gray-9" />+ <PremiumGlyph className={className} /><span className="sr-only">{t('Requires a plan upgrade')}</span></>);@@ -233,7 +306,7 @@ function renderIcon({ref: React.RefObject<AnimatedIconHandle | null>;}) {return React.createElement(Icon, {- className: 'size-5 shrink-0 pointer-events-none',+ className: 'size-4 shrink-0 pointer-events-none',ref,} as { className: string });}@@ -254,10 +327,19 @@ export type SidebarItemType = {locked?: boolean;tier?: FeatureTier;subItems?: SidebarSubItemType[];+ activeOn?: string;+ badge?: ReactNode;+ onClick?: () => void;+};++type ExpandOverride = {+ pathname: string;+ open: boolean;};type LockedTooltipProps = {tier?: FeatureTier;+ disabled?: boolean;children: React.ReactElement;};diff --git a/packages/web/src/app/components/sidebar/app-nav.tsx b/packages/web/src/app/components/sidebar/app-nav.tsxnew file mode 100644index 00000000000..28cebc2b32e--- /dev/null+++ b/packages/web/src/app/components/sidebar/app-nav.tsx@@ -0,0 +1,465 @@+import {+ isNil,+ PlatformRole,+ PROJECT_COLOR_PALETTE,+ ProjectType,+ ProjectWithLimits,+ TemplateTelemetryEventType,+ tryCatchSync,+} from '@activepieces/shared';+import { t } from 'i18next';+import {+ Bot,+ ChartLine,+ Compass,+ Lock,+ Shield,+ SlidersHorizontal,+ SquarePen,+ Unplug,+} from 'lucide-react';+import { motion, useReducedMotion } from 'motion/react';+import { useEffect, useRef, useState } from 'react';+import { useLocation, useNavigate } from 'react-router-dom';++import { LogoPlate } from '@/components/custom/logo-plate';+import { TextWithTooltip } from '@/components/custom/text-with-tooltip';+import { useEmbedding } from '@/components/providers/embed-provider';+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuRadioGroup,+ DropdownMenuRadioItem,+ DropdownMenuTrigger,+} from '@/components/ui/dropdown-menu';+import {+ SidebarGroup,+ SidebarMenu,+ SidebarMenuButton,+ SidebarMenuItem,+ SidebarSeparator,+ useSidebar,+} from '@/components/ui/sidebar-shadcn';+import { useAgentsNavVisible } from '@/features/agents';+import { chatUtils } from '@/features/chat/lib/chat-utils';+import {+ CreateProjectButton,+ getProjectName,+ projectCollectionUtils,+} from '@/features/projects';+import { templatesTelemetryApi } from '@/features/templates';+import { useIsPlatformAdmin } from '@/hooks/authorization-hooks';+import { platformHooks } from '@/hooks/platform-hooks';+import { userHooks } from '@/hooks/user-hooks';+import { authenticationSession } from '@/lib/authentication-session';+import { cn } from '@/lib/utils';++import { MCP_CLIENT_BRANDING } from '../../routes/mcp-server/mcp-client-display';+import { recordAccess } from '../global-search/access-history';+import { mcpHooks } from '../project-settings/mcp-server/utils/mcp-hooks';++import { ApSidebarItem } from './ap-sidebar-item';+import { sidebarStyles } from './sidebar-styles';++export function AppNav() {+ const { data: currentUser } = userHooks.useCurrentUser();+ const showAgents = useAgentsNavVisible();++ return (+ <>+ <DriversGroup />+ <SidebarGroup>+ <SidebarMenu>+ {showAgents && (+ <ApSidebarItem+ type="link"+ to="/agents"+ icon={Bot}+ label={t('Agents')}+ />+ )}+ <ApSidebarItem+ type="link"+ to="/templates"+ icon={Compass}+ label={t('Explore')}+ onClick={() =>+ templatesTelemetryApi.sendEvent({+ eventType: TemplateTelemetryEventType.EXPLORE_VIEW,+ userId: currentUser?.id,+ })+ }+ />+ <ApSidebarItem+ type="link"+ to="/impact"+ icon={ChartLine}+ label={t('Impact')}+ />+ </SidebarMenu>+ </SidebarGroup>+ <ProjectsGroup />+ </>+ );+}++function DriversGroup() {+ const { platform } = platformHooks.useCurrentPlatform();+ const { reachesMcp } = mcpHooks.useMcpReach({ enabled: true });+ const showChat = platform.plan.chatEnabled;++ if (!showChat && !reachesMcp) {+ return null;+ }++ return (+ <>+ <SidebarGroup className="pb-1">+ <SidebarMenu>+ {showChat && (+ <ApSidebarItem+ type="link"+ to="/chat"+ icon={SquarePen}+ label={t('Chat')}+ onClick={() =>+ window.dispatchEvent(new Event(chatUtils.newChatEvent))+ }+ />+ )}+ {reachesMcp && (+ <ApSidebarItem+ type="link"+ to="/mcp-server"+ icon={Unplug}+ label={t('MCP')}+ badge={<McpClientLogos />}+ />+ )}+ </SidebarMenu>+ </SidebarGroup>+ <SidebarSeparator className="mx-4 my-1" />+ </>+ );+}++export function PlatformAdminNavItem() {+ const showPlatformAdmin = useIsPlatformAdmin();+ const { embedState } = useEmbedding();++ if (embedState.isEmbedded || !showPlatformAdmin) {+ return null;+ }++ return (+ <>+ <SidebarSeparator className="mx-2 my-1" />+ <SidebarMenu className="pb-1">+ <ApSidebarItem+ type="link"+ to="/platform/projects"+ activeOn="/platform"+ icon={Shield}+ label={t('Platform Admin')}+ />+ </SidebarMenu>+ </>+ );+}++function McpClientLogos() {+ return (+ <span aria-hidden className="ml-auto flex shrink-0 items-center gap-0.5">+ {MCP_SIDEBAR_CLIENTS.map((client) => (+ <LogoPlate+ key={client}+ size="xxs"+ src={MCP_CLIENT_BRANDING[client].icon}+ alt=""+ className="size-4.5 rounded-md border border-gray-6"+ innerClassName="p-px"+ />+ ))}+ </span>+ );+}++function ProjectsGroup() {+ const { data: projects } = projectCollectionUtils.useAll();+ const { platform } = platformHooks.useCurrentPlatform();+ const { data: currentUser } = userHooks.useCurrentUser();+ const location = useLocation();+ const navigate = useNavigate();+ const { state, isMobile, setOpenMobile } = useSidebar();+ const isCollapsed = state === 'collapsed' && !isMobile;+ const showCreateProject =+ platform.plan.billedTeamProjectsLimit !== 0 &&+ currentUser?.platformRole === PlatformRole.ADMIN;+ const [sort, setSort] = useState<ProjectSort>(readStoredSort);+ const listRef = useRef<HTMLUListElement>(null);++ useEffect(() => {+ scrollActiveProjectIntoView(listRef.current);+ }, [location.pathname, projects.length, sort]);++ if (projects.length === 0) {+ return null;+ }++ const changeSort = (next: ProjectSort) => {+ setSort(next);+ tryCatchSync(() => localStorage.setItem(PROJECT_SORT_KEY, next));+ };++ const openProject = ({+ projectId,+ name,+ }: {+ projectId: string;+ name: string;+ }) => {+ recordAccess({+ id: `project-${projectId}`,+ type: 'project',+ label: name,+ href: `/projects/${projectId}/automations`,+ });+ if (projectId !== authenticationSession.getProjectId()) {+ authenticationSession.switchToProject(projectId);+ }+ navigate(`/projects/${projectId}/automations`);+ };++ return (+ <>+ <SidebarSeparator className="mx-4" />+ <SidebarGroup className="min-h-36 flex-1">+ <div+ inert={isCollapsed}+ className={cn('shrink-0', sidebarStyles.hideWhenCollapsed)}+ >+ <div className="min-h-0 overflow-hidden">+ <div className="flex h-7 items-center gap-0.5 pl-2">+ <span className="flex-1 truncate text-xs font-medium text-gray-11">+ {t('Projects')}+ </span>+ {showCreateProject && (+ <CreateProjectButton+ variant="icon"+ projects={projects ?? []}+ className={PROJECTS_HEADER_ICON_BUTTON}+ onCreate={(project) => {+ if (isMobile) {+ setOpenMobile(false);+ }+ navigate(`/projects/${project.id}/automations`);+ }}+ />+ )}+ <ProjectSortMenu+ key={String(isCollapsed)}+ sort={sort}+ onChange={changeSort}+ />+ </div>+ </div>+ </div>+ <SidebarMenu+ ref={listRef}+ className={cn(+ 'min-h-0 flex-1 gap-0.5',+ sidebarStyles.scrollArea,+ sidebarStyles.fadeEdges,+ )}+ >+ {orderProjects({ projects, sort }).map((project) => (+ <ProjectItem+ key={project.id}+ project={project}+ active={location.pathname.includes(`/projects/${project.id}`)}+ onOpen={openProject}+ />+ ))}+ </SidebarMenu>+ </SidebarGroup>+ </>+ );+}++function ProjectItem({+ project,+ active,+ onOpen,+}: {+ project: ProjectWithLimits;+ active: boolean;+ onOpen: (params: { projectId: string; name: string }) => void;+}) {+ const prefersReducedMotion = useReducedMotion();+ const { isMobile, setOpenMobile, state } = useSidebar();+ const isCollapsed = state === 'collapsed' && !isMobile;+ const name = getProjectName(project);+ const isTeam = project.type === ProjectType.TEAM;+ const palette =+ isTeam && project.icon ? PROJECT_COLOR_PALETTE[project.icon.color] : null;++ return (+ <SidebarMenuItem>+ <SidebarMenuButton asChild isActive={active} tooltip={name}>+ <motion.button+ layout={prefersReducedMotion ? false : 'position'}+ transition={{ duration: 0.4, ease: [0.16, 1, 0.3, 1] }}+ type="button"+ aria-current={active ? 'page' : undefined}+ onClick={(event) => {+ event.stopPropagation();+ if (isMobile) {+ setOpenMobile(false);+ }+ onOpen({ projectId: project.id, name });+ }}+ >+ <span+ className="flex size-4 shrink-0 items-center justify-center rounded-sm text-xs font-bold leading-none"+ style={+ palette+ ? { backgroundColor: palette.color, color: palette.textColor }+ : undefined+ }+ >+ {isTeam ? (+ name.charAt(0).toUpperCase()+ ) : (+ <Lock className="size-3! text-gray-11" />+ )}+ </span>+ {isCollapsed ? (+ <span>{name}</span>+ ) : (+ <TextWithTooltip tooltipMessage={name}>+ <span>{name}</span>+ </TextWithTooltip>+ )}+ </motion.button>+ </SidebarMenuButton>+ </SidebarMenuItem>+ );+}++function ProjectSortMenu({+ sort,+ onChange,+}: {+ sort: ProjectSort;+ onChange: (next: ProjectSort) => void;+}) {+ return (+ <DropdownMenu>+ <DropdownMenuTrigger+ aria-label={t('Sort projects')}+ className={cn(+ PROJECTS_HEADER_ICON_BUTTON,+ 'flex items-center justify-center data-[state=open]:bg-gray-5',+ )}+ >+ <SlidersHorizontal />+ </DropdownMenuTrigger>+ <DropdownMenuContent+ align="start"+ side="right"+ className={cn('w-48', sidebarStyles.menuSurface)}+ >+ <DropdownMenuRadioGroup+ value={sort}+ onValueChange={(value) => onChange(parseSort(value))}+ >+ <DropdownMenuRadioItem value="added">+ {t('Recently added')}+ </DropdownMenuRadioItem>+ <DropdownMenuRadioItem value="recency">+ {t('Recently used')}+ </DropdownMenuRadioItem>+ <DropdownMenuRadioItem value="alphabetical">+ {t('Alphabetical')}+ </DropdownMenuRadioItem>+ </DropdownMenuRadioGroup>+ </DropdownMenuContent>+ </DropdownMenu>+ );+}++function scrollActiveProjectIntoView(list: HTMLUListElement | null) {+ const active = list?.querySelector('[data-active=true]');+ if (!list || !active) {+ return;+ }+ const listRect = list.getBoundingClientRect();+ const activeRect = active.getBoundingClientRect();+ if (activeRect.top >= listRect.top && activeRect.bottom <= listRect.bottom) {+ return;+ }+ list.scrollTop +=+ activeRect.top - listRect.top - (listRect.height - activeRect.height) / 2;+}++function readStoredSort(): ProjectSort {+ const { data } = tryCatchSync(() => localStorage.getItem(PROJECT_SORT_KEY));+ return parseSort(data);+}++function parseSort(value: string | null): ProjectSort {+ return PROJECT_SORTS.find((sort) => sort === value) ?? 'added';+}++function lastFlowUpdatedAt(project: ProjectWithLimits): number {+ const lastFlowUpdated = project.analytics.lastFlowUpdated;+ if (isNil(lastFlowUpdated)) {+ return 0;+ }+ return new Date(lastFlowUpdated).getTime();+}++function compareProjects({ sort }: { sort: ProjectSort }) {+ return (a: ProjectWithLimits, b: ProjectWithLimits): number => {+ if (sort === 'alphabetical') {+ return getProjectName(a).localeCompare(getProjectName(b));+ }+ if (sort === 'added') {+ return new Date(b.created).getTime() - new Date(a.created).getTime();+ }+ const flowA = lastFlowUpdatedAt(a);+ const flowB = lastFlowUpdatedAt(b);+ if (flowA !== flowB) {+ return flowB - flowA;+ }+ return new Date(b.updated).getTime() - new Date(a.updated).getTime();+ };+}++function orderProjects({+ projects,+ sort,+}: {+ projects: ProjectWithLimits[];+ sort: ProjectSort;+}): ProjectWithLimits[] {+ const compare = compareProjects({ sort });+ const personal = projects.filter(+ (project) => project.type !== ProjectType.TEAM,+ );+ const others = projects.filter(+ (project) => project.type === ProjectType.TEAM,+ );+ return [...personal.sort(compare), ...others.sort(compare)];+}++const MCP_SIDEBAR_CLIENTS = ['claude', 'chatgpt', 'cursor'] as const;++const PROJECTS_HEADER_ICON_BUTTON =+ 'size-6 rounded-md text-gray-11 hover:bg-gray-4 hover:text-gray-12 [&_svg]:size-3.5!';++const PROJECT_SORT_KEY = 'rail-pinned-sort';++const PROJECT_SORTS = ['added', 'recency', 'alphabetical'] as const;++type ProjectSort = (typeof PROJECT_SORTS)[number];diff --git a/packages/web/src/app/components/sidebar/app-sidebar.tsx b/packages/web/src/app/components/sidebar/app-sidebar.tsxnew file mode 100644index 00000000000..ff445f47031--- /dev/null+++ b/packages/web/src/app/components/sidebar/app-sidebar.tsx@@ -0,0 +1,339 @@+import { ApEdition, ApFlagId } from '@activepieces/shared';+import { t } from 'i18next';+import { ChevronsUpDown, PanelLeftClose, Search } from 'lucide-react';+import React, { ComponentType, useRef } from 'react';+import { Link } from 'react-router-dom';++import {+ ChevronLeftIcon,+ ChevronLeftIconHandle,+} from '@/components/icons/chevron-left';+import { useEmbedding } from '@/components/providers/embed-provider';+import { Button } from '@/components/ui/button';+import {+ Sidebar,+ SidebarContent,+ SidebarFooter,+ SidebarHeader,+ SidebarMenu,+ SidebarMenuButton,+ SidebarMenuItem,+ SidebarProvider,+ SidebarSeparator,+ useSidebar,+} from '@/components/ui/sidebar-shadcn';+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from '@/components/ui/tooltip';+import { SidebarUsageLimits } from '@/features/billing';+import { PlatformSwitcher } from '@/features/projects';+import { useRailOpenState } from '@/features/workspace/lib/rail-collapsed';+import { useAuthorization } from '@/hooks/authorization-hooks';+import { flagsHooks } from '@/hooks/flags-hooks';+import { platformHooks } from '@/hooks/platform-hooks';+import { determineDefaultRoute } from '@/lib/route-utils';+import { cn } from '@/lib/utils';++import { useGlobalSearch } from '../global-search/global-search-context';++import { AppNav, PlatformAdminNavItem } from './app-nav';+import { MobileSidebarBar } from './mobile-sidebar-bar';+import { PlatformNav } from './platform';+import { sidebarStyles } from './sidebar-styles';+import { SidebarUser } from './sidebar-user';++export function AppSidebar({ mode }: { mode: AppSidebarMode }) {+ const { embedState } = useEmbedding();+ const rail = useRailOpenState();+ const isPlatform = mode === 'platform';+ const isHidden =+ !isPlatform && (embedState.isEmbedded || embedState.hideSideNav);++ if (isHidden) {+ return null;+ }++ return (+ <SidebarProvider+ open={isPlatform || rail.open}+ onOpenChange={isPlatform ? keepOpen : rail.onOpenChange}+ keyboardShortcut={!isPlatform}+ shortcutIgnoresEditable+ className="contents"+ style={SIDEBAR_STYLE}+ >+ <TooltipProvider delayDuration={300}>+ <MobileSidebarBar />+ <Sidebar collapsible="icon" className="border-r-0">+ {mode === 'app' ? <AppHeader /> : <PlatformHeader />}+ <SidebarContent+ className={cn(+ sidebarStyles.scrollArea,+ 'group-data-[collapsible=icon]:overflow-y-auto',+ isPlatform && sidebarStyles.fadeBottom,+ )}+ >+ {mode === 'app' ? <AppNav /> : <PlatformNav />}+ </SidebarContent>+ <SidebarFooter className="gap-1 overflow-hidden">+ {mode === 'app' ? (+ <AppFooterExtras />+ ) : (+ <SidebarSeparator className="mx-2 my-1" />+ )}+ <SidebarUser />+ </SidebarFooter>+ </Sidebar>+ </TooltipProvider>+ </SidebarProvider>+ );+}++function AppHeader() {+ const branding = flagsHooks.useWebsiteBranding();+ const { setOpen: setSearchOpen } = useGlobalSearch();+ const { embedState } = useEmbedding();+ const { state, isMobile, toggleSidebar, setOpenMobile } = useSidebar();+ const collapsed = state === 'collapsed' && !isMobile;+ const closeMobileSheet = () => {+ if (isMobile) {+ setOpenMobile(false);+ }+ };+ const openSearch = () => {+ closeMobileSheet();+ setSearchOpen(true);+ };+ const { data: edition } = flagsHooks.useFlag<ApEdition>(ApFlagId.EDITION);+ const { platform: currentPlatform } = platformHooks.useCurrentPlatform();+ const showSwitcher = edition === ApEdition.CLOUD && !embedState.isEmbedded;++ const logo = (+ <img+ src={branding.logos.logoIconUrl}+ alt=""+ className="size-5 max-w-none shrink-0"+ draggable={false}+ />+ );+ const brandName = (+ <span className={sidebarStyles.labelFade}>+ {showSwitcher+ ? currentPlatform?.name ?? t('platform')+ : branding.websiteName}+ </span>+ );++ const brandButton =+ showSwitcher && !collapsed ? (+ <PlatformSwitcher>+ <SidebarMenuButton className={BRAND_BUTTON}>+ {logo}+ <span+ className={cn('min-w-0 flex-1 truncate', sidebarStyles.labelFade)}+ >+ {currentPlatform?.name ?? t('platform')}+ </span>+ <ChevronsUpDown className="text-gray-9" />+ </SidebarMenuButton>+ </PlatformSwitcher>+ ) : collapsed ? (+ <SidebarMenuButton+ className={BRAND_BUTTON}+ tooltip={t('Open sidebar')}+ aria-label={t('Open sidebar')}+ aria-expanded={false}+ onClick={toggleSidebar}+ >+ {logo}+ {brandName}+ </SidebarMenuButton>+ ) : (+ <SidebarMenuButton asChild className={BRAND_BUTTON}>+ <Link+ to="/"+ onClick={(event) => {+ if (event.detail > 1) {+ event.preventDefault();+ return;+ }+ closeMobileSheet();+ }}+ >+ {logo}+ {brandName}+ </Link>+ </SidebarMenuButton>+ );++ return (+ <SidebarHeader className="gap-0 overflow-hidden">+ <SidebarMenu>+ <SidebarMenuItem>+ {brandButton}+ <HeaderActions>+ <HeaderIconButton+ label={t('Search')}+ icon={Search}+ onClick={openSearch}+ />+ <HeaderIconButton+ label={t('Close sidebar')}+ icon={PanelLeftClose}+ onClick={toggleSidebar}+ />+ </HeaderActions>+ </SidebarMenuItem>+ </SidebarMenu>+ <CollapsedOnlyRow>+ <SidebarMenuButton+ tooltip={t('Search')}+ aria-label={t('Search')}+ className="text-gray-11"+ onClick={(event) => {+ event.stopPropagation();+ openSearch();+ }}+ >+ <Search />+ </SidebarMenuButton>+ </CollapsedOnlyRow>+ </SidebarHeader>+ );+}++function PlatformHeader() {+ const { platform } = platformHooks.useCurrentPlatform();+ const { checkAccess } = useAuthorization();+ const chevronRef = useRef<ChevronLeftIconHandle>(null);+ const defaultRoute = determineDefaultRoute({+ checkAccess,+ chatEnabled: platform.plan.chatEnabled,+ });++ return (+ <SidebarHeader>+ <SidebarMenu>+ <SidebarMenuItem>+ <SidebarMenuButton asChild>+ <Link+ to={defaultRoute}+ onMouseEnter={() => chevronRef.current?.startAnimation()}+ onMouseLeave={() => chevronRef.current?.stopAnimation()}+ >+ <ChevronLeftIcon ref={chevronRef} className="size-4" size={16} />+ <span>{t('Back to app')}</span>+ </Link>+ </SidebarMenuButton>+ </SidebarMenuItem>+ </SidebarMenu>+ </SidebarHeader>+ );+}++function HeaderActions({ children }: { children: React.ReactNode }) {+ const { state, isMobile } = useSidebar();++ return (+ <div+ inert={state === 'collapsed' && !isMobile}+ className="absolute top-0 left-[calc(var(--sidebar-width)-1rem-4.125rem)] flex w-[4.125rem] items-center justify-end gap-0.5 transition-opacity duration-150 ease-[cubic-bezier(0.22,1,0.36,1)] group-data-[collapsible=icon]:opacity-0 motion-reduce:transition-none"+ >+ {children}+ </div>+ );+}++function CollapsedOnlyRow({ children }: { children: React.ReactNode }) {+ const { state, isMobile } = useSidebar();++ return (+ <div+ inert={state === 'expanded' || isMobile}+ className={sidebarStyles.showWhenCollapsed}+ >+ <div className="min-h-0 overflow-hidden">+ <SidebarMenu className="pt-1">+ <SidebarMenuItem>{children}</SidebarMenuItem>+ </SidebarMenu>+ </div>+ </div>+ );+}++function AppFooterExtras() {+ const { state, isMobile } = useSidebar();++ return (+ <>+ <div+ inert={state === 'collapsed' && !isMobile}+ className={cn(+ sidebarStyles.hideWhenCollapsed,+ '[@media(max-height:600px)]:hidden',+ )}+ >+ <div className="min-h-0 overflow-hidden">+ <div className="w-[calc(var(--sidebar-width)-1rem)]">+ <SidebarUsageLimits />+ </div>+ </div>+ </div>+ <PlatformAdminNavItem />+ </>+ );+}++function HeaderIconButton({+ label,+ icon: Icon,+ onClick,+}: {+ label: string;+ icon: ComponentType<{ className?: string }>;+ onClick: () => void;+}) {+ const { isMobile } = useSidebar();+ const button = (+ <Button+ variant="ghost"+ size="icon"+ className="size-8 shrink-0 rounded-md text-gray-11 hover:bg-gray-4 hover:text-gray-12"+ onClick={onClick}+ aria-label={label}+ >+ <Icon className="size-4" />+ </Button>+ );++ if (isMobile) {+ return button;+ }++ return (+ <Tooltip>+ <TooltipTrigger asChild>{button}</TooltipTrigger>+ <TooltipContent side="right">{label}</TooltipContent>+ </Tooltip>+ );+}++function keepOpen() {+ return undefined;+}++const BRAND_BUTTON =+ 'px-1.5 pr-18 font-medium group-data-[collapsible=icon]:pr-1.5';++const SIDEBAR_STYLE: React.CSSProperties & {+ '--sidebar-width': string;+ '--sidebar-width-icon': string;+} = {+ '--sidebar-width': '15.5rem',+ '--sidebar-width-icon': '3rem',+};++export type AppSidebarMode = 'app' | 'platform';diff --git a/packages/web/src/app/components/sidebar/mobile-sidebar-bar.tsx b/packages/web/src/app/components/sidebar/mobile-sidebar-bar.tsxnew file mode 100644index 00000000000..9d49a181adb--- /dev/null+++ b/packages/web/src/app/components/sidebar/mobile-sidebar-bar.tsx@@ -0,0 +1,39 @@+import { t } from 'i18next';+import { Menu } from 'lucide-react';++import { Button } from '@/components/ui/button';+import { useSidebar } from '@/components/ui/sidebar-shadcn';+import { flagsHooks } from '@/hooks/flags-hooks';++export function MobileSidebarBar() {+ const { isMobile, openMobile, setOpenMobile } = useSidebar();+ const branding = flagsHooks.useWebsiteBranding();++ if (!isMobile) {+ return null;+ }++ return (+ <div className="flex shrink-0 items-center gap-2 bg-gray-2 px-2 pt-2">+ <Button+ variant="ghost"+ size="icon"+ className="size-8 rounded-md"+ aria-label={t('Open menu')}+ aria-expanded={openMobile}+ onClick={() => setOpenMobile(true)}+ >+ <Menu className="size-4" />+ </Button>+ <img+ src={branding.logos.logoIconUrl}+ alt=""+ className="size-5 shrink-0"+ draggable={false}+ />+ <span className="truncate text-sm font-medium text-gray-12">+ {branding.websiteName}+ </span>+ </div>+ );+}diff --git a/packages/web/src/app/components/sidebar/platform/index.tsx b/packages/web/src/app/components/sidebar/platform/index.tsxindex 69fc14f4dc6..a0a2f0b2986 100644--- a/packages/web/src/app/components/sidebar/platform/index.tsx+++ b/packages/web/src/app/components/sidebar/platform/index.tsx@@ -1,14 +1,8 @@import { ApEdition, ApFlagId } from '@activepieces/shared';import { t } from 'i18next';-import { useRef } from 'react';-import { Link } from 'react-router-dom';import { McpSvg } from '@/assets/img/custom/mcp';import { ChartLineIcon } from '@/components/icons/chart-line';-import {- ChevronLeftIcon,- ChevronLeftIconHandle,-} from '@/components/icons/chevron-left';import { FileHeartIcon } from '@/components/icons/file-heart';import { FileJson2Icon } from '@/components/icons/file-json2';import { FrameIcon } from '@/components/icons/frame';@@ -25,37 +19,21 @@ import { SparklesIcon } from '@/components/icons/sparkles';import { SquareDashedBottomCodeIcon } from '@/components/icons/square-dashed-bottom-code';import { UnplugIcon } from '@/components/icons/unplug';import { UsersIcon } from '@/components/icons/users';-import { buttonVariants } from '@/components/ui/button';-import { ScrollArea } from '@/components/ui/scroll-area';import {- Sidebar,- SidebarContent,- SidebarFooter,- SidebarMenu,- SidebarHeader,SidebarGroup,SidebarGroupContent,SidebarGroupLabel,+ SidebarMenu,} from '@/components/ui/sidebar-shadcn';import { PLATFORM_FEATURES } from '@/features/billing';-import { useAuthorization } from '@/hooks/authorization-hooks';import { flagsHooks } from '@/hooks/flags-hooks';import { platformHooks } from '@/hooks/platform-hooks';-import { determineDefaultRoute } from '@/lib/route-utils';-import { cn } from '@/lib/utils';import { ApSidebarItem, SidebarItemType } from '../ap-sidebar-item';-import { SidebarUser } from '../sidebar-user';-export function PlatformSidebar() {+export function PlatformNav() {const { platform } = platformHooks.useCurrentPlatform();const { data: edition } = flagsHooks.useFlag<ApEdition>(ApFlagId.EDITION);- const { checkAccess } = useAuthorization();- const defaultRoute = determineDefaultRoute({- checkAccess,- chatEnabled: platform.plan.chatEnabled,- });- const chevronRef = useRef<ChevronLeftIconHandle>(null);const groups: { label: string; items: PlatformNavItem[] }[] = [{@@ -287,65 +265,29 @@ export function PlatformSidebar() {];return (- <Sidebar className="border-r-0!">- <SidebarHeader className="px-3 pb-0">- <Link- to={defaultRoute}- className={cn(- buttonVariants({ variant: 'ghost' }),- 'w-full justify-start gap-2 px-2',- )}- onMouseEnter={() => chevronRef.current?.startAnimation()}- onMouseLeave={() => chevronRef.current?.stopAnimation()}- >- <ChevronLeftIcon ref={chevronRef} className="size-4" size={16} />- <span className="truncate text-sm">{t('Back to app')}</span>- </Link>- </SidebarHeader>- <SidebarContent className="gap-0 overflow-hidden">- <ScrollArea- type="hover"- className="min-h-0 flex-1"- scrollBarClassName="py-1 pr-0.5"- showGradient- gradientClassName="h-12"- >- {groups.map((group, idx) => (- <SidebarGroup- key={group.label}- className={cn(- 'cursor-default shrink-0 px-3 py-0',- idx > 0 && 'mt-4',- )}- >- <SidebarGroupLabel className="h-8 text-sm">- {group.label}- </SidebarGroupLabel>- <SidebarGroupContent>- <SidebarMenu>- {group.items.map((item) => (- <ApSidebarItem- type="link"- key={item.to}- to={item.to}- label={item.label}- icon={item.icon}- locked={item.locked}- tier={item.tier}- subItems={item.subItems}- />- ))}- </SidebarMenu>- </SidebarGroupContent>- </SidebarGroup>- ))}- </ScrollArea>- </SidebarContent>-- <SidebarFooter className="px-3 pb-3">- <SidebarUser />- </SidebarFooter>- </Sidebar>+ <>+ {groups.map((group) => (+ <SidebarGroup key={group.label} className="py-1">+ <SidebarGroupLabel>{group.label}</SidebarGroupLabel>+ <SidebarGroupContent>+ <SidebarMenu>+ {group.items.map((item) => (+ <ApSidebarItem+ type="link"+ key={item.to}+ to={item.to}+ label={item.label}+ icon={item.icon}+ locked={item.locked}+ tier={item.tier}+ subItems={item.subItems}+ />+ ))}+ </SidebarMenu>+ </SidebarGroupContent>+ </SidebarGroup>+ ))}+ </>);}diff --git a/packages/web/src/app/components/sidebar/sidebar-styles.ts b/packages/web/src/app/components/sidebar/sidebar-styles.tsnew file mode 100644index 00000000000..2e080b6aa89--- /dev/null+++ b/packages/web/src/app/components/sidebar/sidebar-styles.ts@@ -0,0 +1,38 @@+const labelFade =+ 'whitespace-nowrap transition-opacity duration-150 ease-[cubic-bezier(0.22,1,0.36,1)] group-data-[collapsible=icon]:opacity-0 motion-reduce:transition-none';++const hideWhenCollapsed =+ 'grid grid-rows-[1fr] opacity-100 transition-[grid-template-rows,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] group-data-[collapsible=icon]:grid-rows-[0fr] group-data-[collapsible=icon]:opacity-0 motion-reduce:transition-none';++const showWhenCollapsed =+ 'grid grid-rows-[0fr] opacity-0 transition-[grid-template-rows,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] group-data-[collapsible=icon]:grid-rows-[1fr] group-data-[collapsible=icon]:opacity-100 motion-reduce:transition-none';++const expand =+ 'grid transition-[grid-template-rows,opacity,visibility] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none';++const rotate =+ 'transition-transform duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none';++const menuSurface =+ 'rounded-xl p-1.5 [&_[data-slot=dropdown-menu-item]]:rounded-md [&_[data-slot=dropdown-menu-radio-item]]:rounded-md [&_[data-slot=dropdown-menu-sub-trigger]]:rounded-md';++const scrollArea =+ 'overflow-x-hidden overflow-y-auto overscroll-contain [scrollbar-width:thin] group-data-[collapsible=icon]:[scrollbar-width:none] group-data-[collapsible=icon]:[&::-webkit-scrollbar]:hidden';++const fadeEdges =+ 'snap-y snap-mandatory scroll-py-1.5 py-1.5 [mask-image:linear-gradient(to_bottom,transparent,black_6px,black_calc(100%-6px),transparent)] [&>li]:snap-start';++const fadeBottom =+ 'pt-2 pb-3 [mask-image:linear-gradient(to_bottom,transparent,black_8px,black_calc(100%-20px),transparent)]';++export const sidebarStyles = {+ labelFade,+ hideWhenCollapsed,+ showWhenCollapsed,+ expand,+ rotate,+ menuSurface,+ scrollArea,+ fadeEdges,+ fadeBottom,+};diff --git a/packages/web/src/app/components/sidebar/sidebar-user.tsx b/packages/web/src/app/components/sidebar/sidebar-user.tsxindex d9c3bb49ba8..a794d9631e3 100644--- a/packages/web/src/app/components/sidebar/sidebar-user.tsx+++ b/packages/web/src/app/components/sidebar/sidebar-user.tsx@@ -1,11 +1,15 @@import { isNil } from '@activepieces/core-utils';+import { PlatformRole } from '@activepieces/shared';import { useQueryClient } from '@tanstack/react-query';import { t } from 'i18next';import { ChevronsUpDown, LogOut, UserCogIcon } from 'lucide-react';import { useState } from 'react';+import { useNavigate } from 'react-router-dom';+import { TextWithTooltip } from '@/components/custom/text-with-tooltip';import { UserAvatar } from '@/components/custom/user-avatar';import { useEmbedding } from '@/components/providers/embed-provider';+import { Badge } from '@/components/ui/badge';import {DropdownMenu,DropdownMenuContent,@@ -28,90 +32,119 @@ import { cn } from '@/lib/utils';import { AccountSettingsDialog } from '../account-settings';import { HelpAndFeedback } from '../help-and-feedback';+import { sidebarStyles } from './sidebar-styles';+export function SidebarUser() {const [accountSettingsOpen, setAccountSettingsOpen] = useState(false);const { embedState } = useEmbedding();const { data: user } = userHooks.useCurrentUser();const queryClient = useQueryClient();- const { state } = useSidebar();- const isCollapsed = state === 'collapsed';+ const navigate = useNavigate();+ const { state, isMobile } = useSidebar();+ const isCollapsed = state === 'collapsed' && !isMobile;+if (!user || embedState.isEmbedded) {return null;}+ const fullName = `${user.firstName} ${user.lastName}`;+const handleLogout = () => {userHooks.invalidateCurrentUser(queryClient);authenticationSession.logOut();+ navigate('/sign-in');};return (<SidebarMenu><SidebarMenuItem><DropdownMenu modal>- <DropdownMenuTrigger asChild className="w-full">- <SidebarMenuButton className="h-10! pl-2! group-data-[collapsible=icon]:h-10! group-data-[collapsible=icon]:pl-2!">- <div className="size-[22px] shrink-0 overflow-hidden flex items-center justify-center rounded-full">+ <DropdownMenuTrigger asChild>+ <SidebarMenuButton+ size="lg"+ tooltip={fullName}+ className="h-10 p-1 pr-2 data-[state=open]:bg-gray-4"+ onClick={(event) => event.stopPropagation()}+ >+ <span className="flex size-6 shrink-0 items-center justify-center overflow-hidden rounded-full"><UserAvatarclassName={cn('size-full object-cover', {'scale-150': isNil(user.imageUrl),})}- name={user.firstName + ' ' + user.lastName}+ name={fullName}email={user.email}imageUrl={user.imageUrl}- size={22}+ size={24}disableTooltip={true}/>- </div>-- {!isCollapsed && (- <>- <span className="truncate">- {user.firstName + ' ' + user.lastName}- </span>- <ChevronsUpDown className="ml-auto size-4" />- </>- )}+ </span>+ <span+ className={cn(+ 'flex min-w-0 flex-1 flex-col',+ sidebarStyles.labelFade,+ )}+ >+ <SidebarRowText+ text={fullName}+ className="font-medium text-gray-12"+ plain={isCollapsed}+ />+ <SidebarRowText+ text={user.email}+ className="text-xs text-gray-11"+ plain={isCollapsed}+ />+ </span>+ <ChevronsUpDown+ className={cn('ml-auto text-gray-9', sidebarStyles.labelFade)}+ /></SidebarMenuButton></DropdownMenuTrigger><DropdownMenuContent- className="w-(--radix-dropdown-menu-trigger-width) min-w-56 z-999"+ className={cn(+ 'w-(--radix-dropdown-menu-trigger-width) min-w-60',+ sidebarStyles.menuSurface,+ )}side="top"align="start"- sideOffset={10}+ sideOffset={8}>- <DropdownMenuLabel className="p-0 font-normal">- <div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm">- <div className="size-8 shrink-0 overflow-hidden rounded-full">- <UserAvatar- className="size-full object-cover"- name={user.firstName + ' ' + user.lastName}- email={user.email}- imageUrl={user.imageUrl}- size={32}- disableTooltip={true}+ <DropdownMenuLabel className="flex flex-col items-start gap-2 px-2 py-1.5 font-normal">+ <span className="flex w-full min-w-0 items-center gap-2.5">+ <UserAvatar+ className="size-8 shrink-0 overflow-hidden rounded-full object-cover"+ name={fullName}+ email={user.email}+ imageUrl={user.imageUrl}+ size={32}+ disableTooltip={true}+ />+ <span className="flex min-w-0 flex-col">+ <SidebarRowText+ text={fullName}+ className="text-sm font-medium text-gray-12"/>- </div>-- <div className="grid flex-1 text-left text-sm leading-tight">- <span className="truncate font-medium">- {user.firstName + ' ' + user.lastName}- </span>- <span className="truncate text-xs">{user.email}</span>- </div>- </div>+ <SidebarRowText+ text={user.email}+ className="text-xs text-gray-11"+ />+ </span>+ </span>+ <Badge variant="secondary">+ {platformRoleLabel(user.platformRole)}+ </Badge></DropdownMenuLabel><DropdownMenuSeparator /><DropdownMenuGroup><DropdownMenuItem onClick={() => setAccountSettingsOpen(true)}>- <UserCogIcon className="w-4 h-4 mr-2" />+ <UserCogIcon className="size-4" />{t('Account Settings')}</DropdownMenuItem>-<HelpAndFeedback /></DropdownMenuGroup><DropdownMenuSeparator /><DropdownMenuItem onClick={handleLogout}>- <LogOut className="w-4 h-4 mr-2" />+ <LogOut className="size-4" />{t('Log out')}</DropdownMenuItem></DropdownMenuContent>@@ -125,3 +158,32 @@ export function SidebarUser() {</SidebarMenu>);}++function SidebarRowText({+ text,+ className,+ plain = false,+}: {+ text: string;+ className: string;+ plain?: boolean;+}) {+ if (plain) {+ return <span className={cn('truncate', className)}>{text}</span>;+ }+ return (+ <TextWithTooltip tooltipMessage={text}>+ <span className={className}>{text}</span>+ </TextWithTooltip>+ );+}++function platformRoleLabel(role: PlatformRole): string {+ if (role === PlatformRole.ADMIN) {+ return t('Platform Admin');+ }+ if (role === PlatformRole.OPERATOR) {+ return t('Operator');+ }+ return t('Member');+}diff --git a/packages/web/src/components/custom/text-with-tooltip.tsx b/packages/web/src/components/custom/text-with-tooltip.tsxindex b39bfabc010..af988931be3 100644--- a/packages/web/src/components/custom/text-with-tooltip.tsx+++ b/packages/web/src/components/custom/text-with-tooltip.tsx@@ -38,10 +38,18 @@ export const TextWithTooltip = ({}, [clampsItsOwnLines]);useEffect(() => {+ const element = textRef.current;+ if (!element) {+ return;+ }checkTruncation();- window.addEventListener('resize', checkTruncation);- return () => window.removeEventListener('resize', checkTruncation);- }, [checkTruncation]);+ if (typeof ResizeObserver === 'undefined') {+ return;+ }+ const observer = new ResizeObserver(checkTruncation);+ observer.observe(element);+ return () => observer.disconnect();+ }, [checkTruncation, isTruncated]);const childWithRef = React.cloneElement(children, {ref: textRef,diff --git a/packages/web/src/components/ui/sidebar-shadcn.tsx b/packages/web/src/components/ui/sidebar-shadcn.tsxindex 0ca6e3e993a..2dc00c43692 100644--- a/packages/web/src/components/ui/sidebar-shadcn.tsx+++ b/packages/web/src/components/ui/sidebar-shadcn.tsx@@ -47,6 +47,8 @@ function SidebarProvider({open: openProp,onOpenChange: setOpenProp,hoverMode = false,+ shortcutIgnoresEditable = false,+ keyboardShortcut = true,className,style,children,@@ -56,6 +58,8 @@ function SidebarProvider({open?: boolean;onOpenChange?: (open: boolean) => void;hoverMode?: boolean;+ shortcutIgnoresEditable?: boolean;+ keyboardShortcut?: boolean;}) {const isMobile = useIsMobile();const [openMobile, setOpenMobile] = React.useState(false);@@ -83,10 +87,9 @@ function SidebarProvider({typeof value === 'function' ? value(persistedOpen) : value;if (setOpenProp) {setOpenProp(openState);- } else {- _setOpen(openState);+ return;}-+ _setOpen(openState);localStorage.setItem(SIDEBAR_COOKIE_NAME, String(openState));document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;},@@ -138,10 +141,14 @@ function SidebarProvider({}, [isMobile, setOpen, setOpenMobile]);React.useEffect(() => {+ if (!keyboardShortcut) {+ return;+ }const handleKeyDown = (event: KeyboardEvent) => {if (event.key === SIDEBAR_KEYBOARD_SHORTCUT &&- (event.metaKey || event.ctrlKey)+ (event.metaKey || event.ctrlKey) &&+ !(shortcutIgnoresEditable && isEditableTarget(event.target))) {event.preventDefault();toggleSidebar();@@ -150,7 +157,7 @@ function SidebarProvider({window.addEventListener('keydown', handleKeyDown);return () => window.removeEventListener('keydown', handleKeyDown);- }, [toggleSidebar]);+ }, [toggleSidebar, shortcutIgnoresEditable, keyboardShortcut]);const state = open ? 'expanded' : 'collapsed';@@ -287,7 +294,7 @@ function Sidebar({<divdata-slot="sidebar-gap"className={cn(- 'relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear',+ 'relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none','group-data-[collapsible=offcanvas]:w-0','group-data-[side=right]:rotate-180',variant === 'floating' || variant === 'inset'@@ -302,7 +309,7 @@ function Sidebar({<divdata-slot="sidebar-container"className={cn(- 'fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex',+ 'fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none md:flex',side === 'left'? 'left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]': 'right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]',@@ -316,7 +323,7 @@ function Sidebar({!hoverMode &&state === 'collapsed' &&collapsible === 'icon' &&- '[&_*]:!cursor-nesw-resize [&_button]:!cursor-pointer [&_button]:relative [&_button]:z-20 [&_button_*]:!cursor-pointer [&_a]:!cursor-pointer [&_a]:relative [&_a]:z-20 [&_a_*]:!cursor-pointer [&_[role=button]]:!cursor-pointer [&_[role=button]]:relative [&_[role=button]]:z-20 [&_[role=button]_*]:!cursor-pointer [&_[data-sidebar=menu-button]]:!cursor-pointer [&_[data-sidebar=menu-button]]:relative [&_[data-sidebar=menu-button]]:z-20 [&_[data-sidebar=menu-button]_*]:!cursor-pointer cursor-nesw-resize',+ 'cursor-ew-resize [&_a]:cursor-pointer [&_button]:cursor-pointer [&_[role=button]]:cursor-pointer',shouldElevateZIndex && 'z-55',className,)}@@ -325,21 +332,21 @@ function Sidebar({<divdata-sidebar="sidebar"data-slot="sidebar-inner"- className={cn(- 'flex h-full w-full flex-col bg-gray-2 group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-gray-6 group-data-[variant=floating]:shadow',- !hoverMode &&- state === 'collapsed' &&- collapsible === 'icon' &&- 'relative',- )}+ className="flex h-full w-full flex-col bg-gray-2 group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-gray-6 group-data-[variant=floating]:shadow"+ onClick={+ !hoverMode && state === 'collapsed' && collapsible === 'icon'+ ? (event) => {+ if (+ event.target instanceof Node &&+ event.currentTarget.contains(event.target) &&+ !isInteractiveTarget(event.target)+ ) {+ setOpen(true);+ }+ }+ : undefined+ }>- {!hoverMode && state === 'collapsed' && collapsible === 'icon' && (- <div- className="absolute inset-0 z-10 !cursor-nesw-resize"- onClick={() => setOpen(true)}- aria-hidden="true"- />- )}{children}</div></div>@@ -503,8 +510,8 @@ function SidebarGroupLabel({data-slot="sidebar-group-label"data-sidebar="group-label"className={cn(- 'flex h-7 shrink-0 items-center rounded-md px-2 text-xs font-normal text-gray-11 ring-gray-8 outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',- 'group-data-[collapsible=icon]:-mt-7 group-data-[collapsible=icon]:opacity-0',+ 'flex h-7 shrink-0 items-center overflow-hidden rounded-md px-2 text-xs font-medium text-gray-11 ring-gray-8 outline-hidden transition-[height,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',+ 'group-data-[collapsible=icon]:h-0 group-data-[collapsible=icon]:opacity-0',className,)}{...props}@@ -571,18 +578,18 @@ function SidebarMenuItem({ className, ...props }: React.ComponentProps<'li'>) {}const sidebarMenuButtonVariants = cva(- 'peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 group-data-[collapsible=icon]:p-0 group-data-[collapsible=icon]:justify-center text-left text-sm ring-gray-8 outline-hidden transition-[width,height,padding] hover:bg-gray-4 hover:text-gray-12 focus-visible:ring-2 active:text-gray-12 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:font-normal data-[active=true]:text-gray-12 data-open:hover:bg-gray-4 data-open:hover:text-gray-12 group-has-data-[sidebar=menu-action]/menu-item:pr-8 [&>span:last-child]:truncate [&_svg]:size-4 [&_svg]:shrink-0',+ 'peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm text-gray-12 ring-gray-8 outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 hover:bg-gray-4 hover:text-gray-12 focus-visible:ring-2 focus-visible:ring-inset active:bg-gray-5 active:text-gray-12 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-gray-4 data-open:hover:text-gray-12 data-[active=true]:bg-gray-5 data-[active=true]:hover:bg-gray-5 data-[active=true]:font-medium data-[active=true]:text-gray-12 [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate',{variants: {variant: {- default: 'hover:bg-gray-4 active:bg-gray-4 hover:text-gray-12',+ default: 'hover:bg-gray-4 hover:text-gray-12',outline:- 'bg-gray-1 shadow-[0_0_0_1px_var(--gray-6)] hover:bg-gray-4 hover:text-gray-12 hover:shadow-[0_0_0_1px_var(--gray-4)]',+ 'bg-gray-1 shadow-edge hover:bg-gray-4 hover:text-gray-12 hover:shadow-edge',},size: {- default: 'h-7 text-sm',- sm: 'h-6 text-xs',- lg: 'h-12 text-sm ',+ default: 'h-8 text-sm',+ sm: 'h-7 text-sm',+ lg: 'h-11 text-sm',},},defaultVariants: {@@ -658,12 +665,12 @@ function SidebarMenuAction({data-slot="sidebar-menu-action"data-sidebar="menu-action"className={cn(- 'absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-gray-12 ring-gray-8 outline-hidden transition-transform peer-hover/menu-button:text-gray-12 hover:bg-gray-4 hover:text-gray-12 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',+ 'absolute top-1 right-1 flex aspect-square w-6 items-center justify-center rounded-md p-0 text-gray-12 ring-gray-8 outline-hidden transition-transform peer-hover/menu-button:text-gray-12 hover:bg-gray-5 hover:text-gray-12 focus-visible:ring-2 focus-visible:ring-inset [&>svg]:size-4 [&>svg]:shrink-0','after:absolute after:-inset-2 md:after:hidden',- 'peer-data-[size=sm]/menu-button:top-1',- 'peer-data-[size=default]/menu-button:top-1.5',+ 'peer-data-[size=sm]/menu-button:top-0.5',+ 'peer-data-[size=default]/menu-button:top-1','peer-data-[size=lg]/menu-button:top-2.5',- 'group-data-[collapsible=icon]:hidden',+ 'transition-opacity duration-150 ease-[cubic-bezier(0.22,1,0.36,1)] group-data-[collapsible=icon]:pointer-events-none group-data-[collapsible=icon]:opacity-0 motion-reduce:transition-none',showOnHover &&'peer-data-[active=true]/menu-button:text-gray-12 group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-open:opacity-100 md:opacity-0',className,@@ -737,11 +744,7 @@ function SidebarMenuSub({ className, ...props }: React.ComponentProps<'ul'>) {<uldata-slot="sidebar-menu-sub"data-sidebar="menu-sub"- className={cn(- 'mx-3.5 flex min-w-0 flex-col gap-1 border-l border-gray-6 px-2.5 py-0.5',- 'group-data-[collapsible=icon]:hidden',- className,- )}+ className={cn('ml-6 flex min-w-0 flex-col gap-0.5 py-0.5', className)}{...props}/>);@@ -781,11 +784,10 @@ function SidebarMenuSubButton({data-size={size}data-active={isActive}className={cn(- 'flex h-7 min-w-0 items-center gap-2 overflow-hidden rounded-md px-2 text-gray-12 ring-gray-8 outline-hidden hover:bg-gray-4 hover:text-gray-12 focus-visible:ring-2 active:bg-gray-4 active:text-gray-12 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-gray-12',- 'data-[active=true]:bg-gray-4 data-[active=true]:font-medium data-[active=true]:text-gray-12',+ 'flex h-8 min-w-0 items-center gap-2 overflow-hidden rounded-md px-2 text-gray-11 ring-gray-8 outline-hidden hover:bg-gray-4 hover:text-gray-12 focus-visible:ring-2 focus-visible:ring-inset active:bg-gray-5 active:text-gray-12 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-gray-12',+ 'data-[active=true]:bg-gray-5 data-[active=true]:hover:bg-gray-5 data-[active=true]:font-medium data-[active=true]:text-gray-12',size === 'sm' && 'text-xs',size === 'md' && 'text-sm',- 'group-data-[collapsible=icon]:hidden',className,)}{...props}@@ -793,6 +795,24 @@ function SidebarMenuSubButton({);}+function isInteractiveTarget(target: EventTarget | null) {+ return (+ target instanceof Element &&+ target.closest(+ 'a, button, input, select, textarea, [role="button"], [role^="menuitem"], [role="option"]',+ ) !== null+ );+}++function isEditableTarget(target: EventTarget | null) {+ return (+ target instanceof HTMLElement &&+ (target.isContentEditable ||+ target.closest('input, textarea, select, [contenteditable="true"]') !==+ null)+ );+}+export {Sidebar,SidebarContent,diff --git a/packages/web/src/features/projects/components/create-project-button.tsx b/packages/web/src/features/projects/components/create-project-button.tsxindex 987dfa1f201..07e32baeee9 100644--- a/packages/web/src/features/projects/components/create-project-button.tsx+++ b/packages/web/src/features/projects/components/create-project-button.tsx@@ -8,6 +8,11 @@ import { PlusIcon } from '@/components/icons/plus';import { useTelemetry } from '@/components/providers/telemetry-provider';import { Button } from '@/components/ui/button';import { SidebarMenuButton } from '@/components/ui/sidebar-shadcn';+import {+ Tooltip,+ TooltipContent,+ TooltipTrigger,+} from '@/components/ui/tooltip';import {PLATFORM_FEATURES,useFeatureGate,@@ -40,7 +45,7 @@ export function CreateProjectButton({locked: projectsGate.locked,});- return (+ const dialog = (<NewProjectDialogonCreate={onCreate}onBlocked={() =>@@ -57,9 +62,40 @@ export function CreateProjectButton({content: teamProjectLimitContent,}}>- {trigger}+ {variant === 'icon' ? (+ <TooltipTrigger+ asChild+ aria-label={+ projectsGate.locked+ ? `${t('Create Project')}, ${t('Requires a plan upgrade')}`+ : t('Create Project')+ }+ >+ {trigger}+ </TooltipTrigger>+ ) : (+ trigger+ )}</NewProjectDialog>);++ if (variant !== 'icon') {+ return dialog;+ }++ return (+ <Tooltip>+ {dialog}+ <TooltipContent side="bottom">+ <span className="flex flex-col">+ <span>{t('Create Project')}</span>+ {projectsGate.locked && (+ <span className="opacity-70">{t('Requires a plan upgrade')}</span>+ )}+ </span>+ </TooltipContent>+ </Tooltip>+ );}function triggerFor({ variant, className, crown, locked }: TriggerForParams) {diff --git a/packages/web/src/features/workspace/lib/rail-collapsed.ts b/packages/web/src/features/workspace/lib/rail-collapsed.tsindex 4b53f4f0bb3..33a41a279cc 100644--- a/packages/web/src/features/workspace/lib/rail-collapsed.ts+++ b/packages/web/src/features/workspace/lib/rail-collapsed.ts@@ -1,4 +1,5 @@-import { matchPath } from 'react-router-dom';+import { useCallback, useState } from 'react';+import { matchPath, useLocation } from 'react-router-dom';import { create } from 'zustand';import { routesThatRequireProjectId } from '@/lib/route-utils';@@ -27,13 +28,29 @@ function persist(value: boolean): boolean {return value;}-export const useRailCollapsed = create<RailCollapsedState>((set) => ({+const useRailCollapsed = create<RailCollapsedState>((set) => ({preference: readInitial(),setCollapsed: (value) => set({ preference: persist(value) }),- toggle: () => set((state) => ({ preference: persist(!state.preference) })),}));-export function railIsCollapsed({+export function useRailOpenState() {+ const { preference, setCollapsed } = useRailCollapsed();+ const { pathname } = useLocation();+ const [openedOn, setOpenedOn] = useState<string | null>(null);+ const collapsed = railIsCollapsed({ preference, pathname, openedOn });++ const onOpenChange = useCallback(+ (open: boolean) => {+ setOpenedOn(pathname);+ setCollapsed(!open);+ },+ [pathname, setCollapsed],+ );++ return { open: !collapsed, onOpenChange };+}++function railIsCollapsed({preference,pathname,openedOn,@@ -53,5 +70,4 @@ export function railIsCollapsed({type RailCollapsedState = {preference: boolean;setCollapsed: (value: boolean) => void;- toggle: () => void;};diff --git a/packages/web/test/app/components/sidebar/platform/index.test.tsx b/packages/web/test/app/components/sidebar/platform/index.test.tsxindex a78cbd8f868..35f2e581c7a 100644--- a/packages/web/test/app/components/sidebar/platform/index.test.tsx+++ b/packages/web/test/app/components/sidebar/platform/index.test.tsx@@ -6,7 +6,7 @@ import * as React from 'react';import { MemoryRouter } from 'react-router-dom';import { describe, expect, it, vi } from 'vitest';-import { PlatformSidebar } from '@/app/components/sidebar/platform';+import { PlatformNav } from '@/app/components/sidebar/platform';const plan = vi.hoisted(() => ({ aiProvidersEnabled: false }));@@ -80,7 +80,7 @@ vi.mock('@/app/components/sidebar/ap-sidebar-item', () => ({function renderSidebar() {render(<MemoryRouter>- <PlatformSidebar />+ <PlatformNav /></MemoryRouter>,);}