🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
refactor(web): Cleanup navigation sidebar (#15493)
Ben Bachem97bdb089d41d
diff --git a/web/.storybook/main.ts b/web/.storybook/main.tsindex ce069e6f90..2ccb47d079 100644--- a/web/.storybook/main.ts+++ b/web/.storybook/main.ts@@ -13,6 +13,7 @@ const DESIGN_COMPONENT_STORIES = ["Checkbox/Checkbox","Codeblock/Codeblock","LangfuseIcon/LangfuseIcon",+ "LangfuseLogo/LangfuseLogo","Progress/Progress","Spinner/Spinner","Switch/Switch",diff --git a/web/src/components/VersionLabel.tsx b/web/src/components/VersionLabel.tsxdeleted file mode 100644index 6e17f80e1b..0000000000--- a/web/src/components/VersionLabel.tsx+++ /dev/null@@ -1,191 +0,0 @@-import {- ArrowUp10,- BadgeCheck,- HardDriveDownload,- Info,- Map,- Newspaper,-} from "lucide-react";-import { SiGithub } from "react-icons/si";-import { VERSION } from "@/src/constants";-import Link from "next/link";-import {- DropdownMenu,- DropdownMenuTrigger,- DropdownMenuContent,- DropdownMenuItem,- DropdownMenuLabel,- DropdownMenuSeparator,-} from "@/src/components/ui/dropdown-menu";-import { ArrowUp } from "lucide-react";-import { api } from "@/src/utils/api";-import { Button } from "@/src/components/ui/button";-import { cn } from "@/src/utils/tailwind";-import { usePlan } from "@/src/features/entitlements/hooks";-import { isSelfHostedPlan, planLabels } from "@langfuse/shared";-import { StatusBadge } from "@/src/components/layouts/status-badge";-import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";--export const VersionLabel = ({ className }: { className?: string }) => {- const { isLangfuseCloud } = useLangfuseCloudRegion();-- const backgroundMigrationStatus = api.backgroundMigrations.status.useQuery(- undefined,- {- refetchOnMount: false,- refetchOnWindowFocus: false,- refetchOnReconnect: false,- enabled: !isLangfuseCloud, // do not check for updates on Langfuse Cloud- throwOnError: false, // do not render default error message- },- );-- const checkUpdate = api.public.checkUpdate.useQuery(undefined, {- refetchOnMount: false,- refetchOnWindowFocus: false,- refetchOnReconnect: false,- enabled: !isLangfuseCloud, // do not check for updates on Langfuse Cloud- throwOnError: false, // do not render default error message- });-- const plan = usePlan();-- const selfHostedPlanLabel = !isLangfuseCloud- ? plan && isSelfHostedPlan(plan)- ? // self-host plan- // TODO: clean up to use planLabels in packages/shared/src/features/entitlements/plans.ts- {- short: plan === "self-hosted:pro" ? "Pro" : "EE",- long: planLabels[plan],- }- : // no plan, oss- {- short: "OSS",- long: "Open Source",- }- : // null on cloud- null;-- const showBackgroundMigrationStatus =- !isLangfuseCloud &&- backgroundMigrationStatus.data &&- backgroundMigrationStatus.data.status !== "FINISHED";-- const hasUpdate =- !isLangfuseCloud && checkUpdate.data && checkUpdate.data.updateType;-- const color =- checkUpdate.data?.updateType === "major"- ? "text-dark-red"- : checkUpdate.data?.updateType === "minor"- ? "text-dark-yellow"- : undefined;-- return (- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button- variant="ghost"- size="xs"- className={cn("mt-[0.2px] text-[0.625rem]", className)}- >- {VERSION}- {selfHostedPlanLabel ? <> {selfHostedPlanLabel.short}</> : null}- {showBackgroundMigrationStatus && (- <StatusBadge- type={backgroundMigrationStatus.data?.status.toLowerCase()}- showText={false}- className="bg-transparent"- />- )}- {hasUpdate && !showBackgroundMigrationStatus && (- <ArrowUp className={`h-3 w-3 ${color}`} />- )}- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent onClick={(e) => e.stopPropagation()}>- {hasUpdate ? (- <>- <DropdownMenuLabel>- New {checkUpdate.data?.updateType} version:{" "}- {checkUpdate.data?.latestRelease}- </DropdownMenuLabel>- <DropdownMenuSeparator />- </>- ) : !isLangfuseCloud ? (- <>- <DropdownMenuLabel>This is the latest release</DropdownMenuLabel>- <DropdownMenuSeparator />- </>- ) : null}- {selfHostedPlanLabel && (- <>- <DropdownMenuLabel className="flex items-center font-normal">- <BadgeCheck size={16} className="mr-2" />- {selfHostedPlanLabel.long}- </DropdownMenuLabel>- <DropdownMenuSeparator />- </>- )}- <DropdownMenuItem asChild>- <Link- href="https://github.com/langfuse/langfuse/releases"- target="_blank"- >- <SiGithub size={16} className="mr-2" />- Releases- </Link>- </DropdownMenuItem>- {!isLangfuseCloud && (- <DropdownMenuItem asChild>- <Link href="/background-migrations">- <ArrowUp10 size={16} className="mr-2" />- Background Migrations- {showBackgroundMigrationStatus && (- <StatusBadge- type={backgroundMigrationStatus.data?.status.toLowerCase()}- showText={false}- className="bg-transparent"- />- )}- </Link>- </DropdownMenuItem>- )}- <DropdownMenuItem asChild>- <Link href="https://langfuse.com/changelog" target="_blank">- <Newspaper size={16} className="mr-2" />- Changelog- </Link>- </DropdownMenuItem>- <DropdownMenuItem asChild>- <Link href="https://langfuse.com/roadmap" target="_blank">- <Map size={16} className="mr-2" />- Roadmap- </Link>- </DropdownMenuItem>- {!isLangfuseCloud && (- <DropdownMenuItem asChild>- <Link href="https://langfuse.com/pricing-self-host" target="_blank">- <Info size={16} className="mr-2" />- Compare Versions- </Link>- </DropdownMenuItem>- )}- {hasUpdate && (- <>- <DropdownMenuSeparator />- <DropdownMenuItem asChild>- <Link- href="https://langfuse.com/docs/deployment/self-host#update"- target="_blank"- >- <HardDriveDownload size={16} className="mr-2" />- Update- </Link>- </DropdownMenuItem>- </>- )}- </DropdownMenuContent>- </DropdownMenu>- );-};diff --git a/web/src/components/design-system/LangfuseLogo/LangfuseLogo.stories.tsx b/web/src/components/design-system/LangfuseLogo/LangfuseLogo.stories.tsxnew file mode 100644index 0000000000..47de305624--- /dev/null+++ b/web/src/components/design-system/LangfuseLogo/LangfuseLogo.stories.tsx@@ -0,0 +1,15 @@+import preview from "../../../../.storybook/preview";+import { LangfuseLogo } from "./LangfuseLogo";++const meta = preview.meta({+ component: LangfuseLogo,+});++export const Default = meta.story({});++export const Customized = meta.story({+ args: {+ logoLightModeHref: "/wordart-black.svg",+ logoDarkModeHref: "/wordart-white.svg",+ },+});diff --git a/web/src/components/LangfuseLogo.tsx b/web/src/components/design-system/LangfuseLogo/LangfuseLogo.tsxsimilarity index 65%rename from web/src/components/LangfuseLogo.tsxrename to web/src/components/design-system/LangfuseLogo/LangfuseLogo.tsxindex d5c38096d8..d590b04fe8 100644--- a/web/src/components/LangfuseLogo.tsx+++ b/web/src/components/design-system/LangfuseLogo/LangfuseLogo.tsx@@ -1,21 +1,22 @@-import { cn } from "@/src/utils/tailwind";-import Link from "next/link";-import { VersionLabel } from "./VersionLabel";+import { LangfuseIcon } from "@/src/components/design-system/LangfuseIcon/LangfuseIcon";import { env } from "@/src/env.mjs";-import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";+import { cn } from "@/src/utils/tailwind";import { PlusIcon } from "lucide-react";-import { LangfuseIcon } from "@/src/components/design-system/LangfuseIcon/LangfuseIcon";--const LangfuseLogotypeOrCustomized = () => {- const uiCustomization = useUiCustomization();- if (uiCustomization?.logoLightModeHref && uiCustomization?.logoDarkModeHref) {+export const LangfuseLogo = ({+ logoLightModeHref,+ logoDarkModeHref,+}: {+ logoLightModeHref?: string;+ logoDarkModeHref?: string;+}) => {+ if (logoLightModeHref && logoDarkModeHref) {// logo is a url, maximum aspect ratio of 1:3 needs to be supported according to docsreturn (<div className="flex items-center gap-1">{/* eslint-disable-next-line @next/next/no-img-element */}<img- src={uiCustomization.logoLightModeHref}+ src={logoLightModeHref}alt="Langfuse Logo"className={cn("group-data-[collapsible=icon]:hidden dark:hidden",@@ -24,7 +25,7 @@ const LangfuseLogotypeOrCustomized = () => {/>{/* eslint-disable-next-line @next/next/no-img-element */}<img- src={uiCustomization.logoDarkModeHref}+ src={logoDarkModeHref}alt="Langfuse Logo"className={cn("hidden group-data-[collapsible=icon]:hidden dark:block",@@ -57,19 +58,3 @@ const LangfuseLogotypeOrCustomized = () => {</div>);};--export const LangfuseLogo = ({ version = false }: { version?: boolean }) => {- return (- <div className="-mt-2 ml-1 flex flex-wrap gap-4 lg:flex-col lg:items-start">- {/* Langfuse Logo */}- <div className="flex items-center">- <Link href="/" className="flex items-center">- <LangfuseLogotypeOrCustomized />- </Link>- {version && (- <VersionLabel className="ml-2 group-data-[collapsible=icon]:hidden" />- )}- </div>- </div>- );-};diff --git a/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx b/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsxindex 934266a3da..d71b5d30d6 100644--- a/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx+++ b/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx@@ -4,11 +4,20 @@* Used for all main application pages when user is authenticated*/-import { useEffect, useState, type PropsWithChildren } from "react";+import {+ useEffect,+ useState,+ type ComponentProps,+ type PropsWithChildren,+} from "react";import Head from "next/head";import { useRouter, type NextRouter } from "next/router";-import { SidebarProvider, SidebarInset } from "@/src/components/ui/sidebar";-import { AppSidebar } from "@/src/components/nav/app-sidebar";+import {+ SidebarProvider,+ SidebarInset,+ useSidebar,+} from "@/src/components/ui/sidebar";+import { AppSidebar } from "@/src/components/nav/AppSidebar/AppSidebar";import { SidebarPresenceProvider } from "@/src/components/nav/sidebar-presence";import { Toaster } from "@/src/components/ui/sonner";import { Layer } from "@/src/components/ui/layer";@@ -27,6 +36,18 @@ import type { RouteGroup } from "@/src/components/layouts/routes";import dynamic from "next/dynamic";import { ControlledFeaturePreviewModal } from "@/src/features/feature-previews/components/ControlledFeaturePreviewModal";import { InAppAgentWindowHost } from "@/src/ee/features/in-app-agent/components/InAppAgentWindowHost";+import { useV4UpgradeUiEnabled } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";+import { api } from "@/src/utils/api";+import { usePlan } from "@/src/features/entitlements/hooks";+import { env } from "@/src/env.mjs";+import useLocalStorage from "@/src/components/useLocalStorage";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useSession } from "next-auth/react";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";+import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";++const DISMISSED_SIDEBAR_NOTIFICATIONS_KEY = "dismissed-sidebar-notifications";const CommandMenu = dynamic(() =>@@ -102,6 +123,7 @@ export function AuthenticatedLayout({const regionMenuItems = getAvailableCloudRegionOptions(currentRegion).map((region) => ({+ type: "action" as const,name: region.name,content: `${region.flag} ${region.name}`,onClick: () => {@@ -118,42 +140,51 @@ export function AuthenticatedLayout({const hasFeaturePreviews = isLangfuseCloud || user.v4BetaEnabled === true;// User navigation items for sidebar dropdown- const userNavProps = {- user: {- name: user.name ?? "",- email: user.email ?? "",- avatar: user.image ?? "",- },- items: [- { name: "Account Settings", href: "/account/settings" },- { name: "Theme", onClick: () => {}, content: <ThemeToggle /> },- ...(hasFeaturePreviews- ? [- {- name: "Feature Preview",- onClick: () => setFeaturePreviewOpen(true),- },- ]- : []),- ...(isLangfuseCloud- ? [- {- name: "Regions",- subItems: regionMenuItems,- content: (- <>- Regions- <div className="ml-2 inline-flex rounded bg-black/5 p-1 text-xs dark:bg-white/10">- Current: {currentRegion}- </div>- </>- ),- },- ]- : []),- { name: "Sign out", onClick: onSignOut },- ],+ const sidebarUser = {+ name: user.name ?? "",+ email: user.email ?? "",+ avatar: user.image ?? "",};+ const userMenuItems = [+ {+ type: "link" as const,+ name: "Account Settings",+ href: "/account/settings",+ },+ {+ type: "action" as const,+ name: "Theme",+ onClick: () => {},+ content: <ThemeToggle />,+ },+ ...(hasFeaturePreviews+ ? [+ {+ type: "action" as const,+ name: "Feature Preview",+ onClick: () => setFeaturePreviewOpen(true),+ },+ ]+ : []),+ ...(isLangfuseCloud+ ? [+ {+ type: "submenu" as const,+ name: "Regions",+ subItems: regionMenuItems,+ content: (+ <>+ Regions+ <div className="ml-2 inline-flex rounded bg-black/5 p-1 text-xs dark:bg-white/10">+ Current: {currentRegion}+ </div>+ </>+ ),+ },+ ]+ : []),+ { type: "action" as const, name: "Sign out", onClick: onSignOut },+ ];return (<>@@ -176,10 +207,17 @@ export function AuthenticatedLayout({<PaymentBanner /><VersionUpdateBanner /><div className="pt-banner-offset flex min-h-0 flex-1">- <AppSidebar+ <ConnectedAppSidebarnavItems={navigation.mainNavigation}secondaryNavItems={navigation.secondaryNavigation}- userNavProps={userNavProps}+ user={sidebarUser}+ userMenuItems={userMenuItems}+ isLangfuseCloud={isLangfuseCloud}+ routerProjectId={+ typeof router.query.projectId === "string"+ ? router.query.projectId+ : undefined+ }/><SidebarInset className="h-screen-with-banner max-w-full md:peer-data-[state=collapsed]:w-[calc(100vw-var(--sidebar-width-icon))] md:peer-data-[state=expanded]:w-[calc(100vw-var(--sidebar-width))]"><AppContentWithRightDrawer>@@ -214,6 +252,128 @@ export function AuthenticatedLayout({);}+function ConnectedAppSidebar({+ navItems,+ secondaryNavItems,+ user,+ userMenuItems,+ isLangfuseCloud,+ routerProjectId,+}: {+ navItems: GroupedNavigation;+ secondaryNavItems: GroupedNavigation;+ user: ComponentProps<typeof AppSidebar>["user"];+ userMenuItems: ComponentProps<typeof AppSidebar>["userMenuItems"];+ isLangfuseCloud: boolean;+ routerProjectId?: string;+}) {+ const { isMobile } = useSidebar();+ const uiCustomization = useUiCustomization();+ const v4UpgradeUiEnabled = useV4UpgradeUiEnabled();+ const plan = usePlan();+ const capture = usePostHogClientCapture();+ const session = useSession();+ const { organization, project } = useQueryProjectOrOrganization();+ const canCreateProjects = useHasOrganizationAccess({+ organizationId: organization?.id,+ scope: "projects:create",+ });+ const [dismissedNotificationIds, setDismissedNotificationIds] =+ useLocalStorage<string[]>(DISMISSED_SIDEBAR_NOTIFICATIONS_KEY, []);++ const backgroundMigrationStatus = api.backgroundMigrations.status.useQuery(+ undefined,+ {+ refetchOnMount: false,+ refetchOnWindowFocus: false,+ refetchOnReconnect: false,+ enabled: !isLangfuseCloud,+ throwOnError: false,+ },+ );++ const checkUpdate = api.public.checkUpdate.useQuery(undefined, {+ refetchOnMount: false,+ refetchOnWindowFocus: false,+ refetchOnReconnect: false,+ enabled: !isLangfuseCloud,+ throwOnError: false,+ });++ const selfHostedPlan =+ plan === "self-hosted:pro" || plan === "self-hosted:enterprise"+ ? plan+ : "oss";++ const versionState: ComponentProps<typeof AppSidebar>["versionState"] =+ isLangfuseCloud+ ? { deployment: "cloud" }+ : {+ deployment: "self-hosted",+ plan: selfHostedPlan,+ release: checkUpdate.data?.updateType+ ? {+ status: "update-available",+ updateType: checkUpdate.data.updateType,+ latestRelease: checkUpdate.data.latestRelease,+ }+ : { status: "current" },+ migration:+ backgroundMigrationStatus.data &&+ backgroundMigrationStatus.data.status !== "FINISHED"+ ? {+ status: "in-progress",+ phase: backgroundMigrationStatus.data.status.toLowerCase(),+ }+ : { status: "idle" },+ };++ return (+ <AppSidebar+ navItems={navItems}+ secondaryNavItems={secondaryNavItems}+ user={user}+ userMenuItems={userMenuItems}+ isMobile={isMobile}+ logo={{+ lightModeHref: uiCustomization?.logoLightModeHref,+ darkModeHref: uiCustomization?.logoDarkModeHref,+ }}+ versionState={versionState}+ v4UpgradeUiEnabled={v4UpgradeUiEnabled}+ notificationState={{+ dismissedIds: dismissedNotificationIds,+ onDismiss: (id) => {+ capture("notification:dismiss_notification", {+ notification_id: id,+ });+ setDismissedNotificationIds((current) => [...current, id]);+ },+ onLinkClick: (id) => {+ capture("notification:click_link", {+ notification_id: id,+ });+ },+ }}+ organization={+ organization ? { id: organization.id, name: organization.name } : null+ }+ project={project ? { id: project.id, name: project.name } : null}+ organizations={session.data?.user?.organizations ?? null}+ canCreateOrganizations={+ session.data?.user?.canCreateOrganizations ?? false+ }+ canCreateProjects={canCreateProjects}+ showDemoBadge={Boolean(+ env.NEXT_PUBLIC_DEMO_ORG_ID &&+ env.NEXT_PUBLIC_DEMO_PROJECT_ID &&+ routerProjectId === env.NEXT_PUBLIC_DEMO_PROJECT_ID &&+ isLangfuseCloud,+ )}+ />+ );+}+/** useProjectCookie pings the visit beacon so the project sentinel can route the user back here. */function useProjectCookie(router: NextRouter) {const projectId = router.query.projectId;diff --git a/web/src/components/nav/AppSidebar/AppSidebar.stories.tsx b/web/src/components/nav/AppSidebar/AppSidebar.stories.tsxnew file mode 100644index 0000000000..b780f3e1dc--- /dev/null+++ b/web/src/components/nav/AppSidebar/AppSidebar.stories.tsx@@ -0,0 +1,230 @@+import type { ComponentProps } from "react";+import { Activity, BookOpen, Home, Settings } from "lucide-react";+import { expect, fn } from "storybook/test";++import preview from "../../../../.storybook/preview";+import { SidebarInset, SidebarProvider } from "@/src/components/ui/sidebar";+import { AppSidebar } from "./AppSidebar";++type AppSidebarProps = ComponentProps<typeof AppSidebar>;+type VersionState = AppSidebarProps["versionState"];+type NotificationState = AppSidebarProps["notificationState"];++const launchWeekNotificationIds = ["lw5-1", "lw5-2", "lw5-3", "lw5-4", "lw5-5"];+const duringLaunchWeek = new Date("2026-05-29T12:00:00Z").getTime();++const setCurrentTimestamp = (timestamp: number) => {+ const originalDateNow = Date.now;+ Date.now = () => timestamp;+ return () => {+ Date.now = originalDateNow;+ };+};++const meta = preview.meta({+ component: AppSidebar,+ render: (args) => <SidebarStory open args={args} />,+ args: {+ navItems: {+ ungrouped: [+ { title: "Home", url: "/", icon: Home, isActive: true },+ { title: "Traces", url: "/traces", icon: Activity },+ { title: "Prompts", url: "/prompts", icon: BookOpen },+ ],+ grouped: null,+ },+ secondaryNavItems: {+ ungrouped: [{ title: "Settings", url: "/settings", icon: Settings }],+ grouped: null,+ },+ user: {+ name: "Ada Lovelace",+ email: "[email protected]",+ avatar: "",+ },+ userMenuItems: [+ {+ type: "link",+ name: "Account Settings",+ href: "/account/settings",+ },+ { type: "action", name: "Sign out", onClick: fn() },+ ] satisfies AppSidebarProps["userMenuItems"],+ isMobile: false,+ logo: {},+ versionState: {+ deployment: "cloud",+ } satisfies VersionState,+ showDemoBadge: false,+ v4UpgradeUiEnabled: true,+ notificationState: {+ dismissedIds: [],+ onDismiss: fn(),+ onLinkClick: fn(),+ } satisfies NotificationState,+ organization: null,+ project: null,+ organizations: null,+ canCreateOrganizations: false,+ canCreateProjects: false,+ },+});++const SidebarStory = ({+ open,+ args,+}: {+ open: boolean;+ args: AppSidebarProps;+}) => (+ <SidebarProvider open={open}>+ <AppSidebar {...args} />+ <SidebarInset>+ <div className="bg-muted/30 h-full" />+ </SidebarInset>+ </SidebarProvider>+);++export const Default = meta.story({});++export const CurrentOpenSource = meta.story({+ args: {+ versionState: {+ deployment: "self-hosted",+ plan: "oss",+ release: { status: "current" },+ migration: { status: "idle" },+ },+ },+});++export const UpdateAvailable = meta.story({+ args: {+ versionState: {+ deployment: "self-hosted",+ plan: "self-hosted:pro",+ release: {+ status: "update-available",+ updateType: "minor",+ latestRelease: "3.128.0",+ },+ migration: { status: "idle" },+ },+ },+});++export const MigrationInProgress = meta.story({+ args: {+ versionState: {+ deployment: "self-hosted",+ plan: "self-hosted:enterprise",+ release: { status: "current" },+ migration: { status: "in-progress", phase: "running" },+ },+ },+});++export const UpdateDuringMigration = meta.story({+ args: {+ versionState: {+ deployment: "self-hosted",+ plan: "self-hosted:enterprise",+ release: {+ status: "update-available",+ updateType: "major",+ latestRelease: "4.0.0",+ },+ migration: { status: "in-progress", phase: "pending" },+ },+ },+});++export const LaunchWeekStack = meta.story({+ beforeEach: () => setCurrentTimestamp(duringLaunchWeek),+ args: {+ v4UpgradeUiEnabled: false,+ notificationState: {+ dismissedIds: [],+ onDismiss: fn(),+ onLinkClick: fn(),+ } satisfies NotificationState,+ },+});++export const LatestLaunchWeek = meta.story({+ beforeEach: () => setCurrentTimestamp(duringLaunchWeek),+ args: {+ v4UpgradeUiEnabled: false,+ notificationState: {+ dismissedIds: launchWeekNotificationIds.slice(0, 4),+ onDismiss: fn(),+ onLinkClick: fn(),+ } satisfies NotificationState,+ },+});++export const GitHubStar = meta.story({+ args: {+ v4UpgradeUiEnabled: false,+ notificationState: {+ dismissedIds: launchWeekNotificationIds,+ onDismiss: fn(),+ onLinkClick: fn(),+ } satisfies NotificationState,+ },+ play: async ({ canvas }) => {+ await expect(canvas.getByAltText("Langfuse GitHub stars")).toHaveAttribute(+ "src",+ "https://img.shields.io/github/stars/langfuse/langfuse?label=langfuse&style=social",+ );+ },+});++export const AllNotificationsDismissed = meta.story({+ args: {+ v4UpgradeUiEnabled: false,+ notificationState: {+ dismissedIds: [...launchWeekNotificationIds, "github-star"],+ onDismiss: fn(),+ onLinkClick: fn(),+ } satisfies NotificationState,+ },+});++export const MobileNavigation = meta.story({+ args: {+ isMobile: true,+ organization: { id: "org-acme", name: "Acme Inc." },+ project: { id: "project-analytics", name: "Analytics" },+ organizations: [+ {+ id: "org-acme",+ name: "Acme Inc.",+ role: "OWNER",+ cloudConfig: undefined,+ plan: "cloud:hobby",+ metadata: {},+ aiFeaturesEnabled: false,+ aiTelemetryEnabled: false,+ projects: [+ {+ id: "project-analytics",+ name: "Analytics",+ role: "ADMIN",+ deletedAt: null,+ retentionDays: null,+ hasTraces: false,+ metadata: {},+ createdAt: "2026-01-01T00:00:00.000Z",+ },+ ],+ },+ ],+ canCreateOrganizations: true,+ canCreateProjects: true,+ },+});++export const Collapsed = meta.story({+ render: (args) => <SidebarStory open={false} args={args} />,+});diff --git a/web/src/components/nav/AppSidebar/AppSidebar.tsx b/web/src/components/nav/AppSidebar/AppSidebar.tsxnew file mode 100644index 0000000000..285b29c8ef--- /dev/null+++ b/web/src/components/nav/AppSidebar/AppSidebar.tsx@@ -0,0 +1,700 @@+"use client";++import * as React from "react";+import { NavMain, type NavMainItem } from "@/src/components/nav/nav-main";+import {+ Sidebar,+ SidebarContent,+ SidebarFooter,+ SidebarGroup,+ SidebarGroupContent,+ SidebarGroupLabel,+ SidebarHeader,+ SidebarMenu,+ SidebarMenuButton,+ SidebarMenuItem,+ SidebarRail,+} from "@/src/components/ui/sidebar";+import Link from "next/link";+import { LangfuseLogo } from "@/src/components/design-system/LangfuseLogo/LangfuseLogo";+import { type RouteGroup } from "@/src/components/layouts/routes";+import {+ ArrowUp,+ ArrowUp10,+ BadgeCheck,+ ChevronsUpDown,+ ChevronDownIcon,+ ExternalLink,+ Grid2X2,+ HardDriveDownload,+ Info,+ Map,+ Newspaper,+ X,+} from "lucide-react";+import { SiGithub } from "react-icons/si";+import { VERSION } from "@/src/constants";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuGroup,+ DropdownMenuItem,+ DropdownMenuLabel,+ DropdownMenuSeparator,+ DropdownMenuSub,+ DropdownMenuSubContent,+ DropdownMenuSubTrigger,+ DropdownMenuTrigger,+} from "@/src/components/ui/dropdown-menu";+import { Button } from "@/src/components/ui/button";+import { StatusBadge } from "@/src/components/layouts/status-badge";+import { planLabels, type Plan } from "@langfuse/shared";+import {+ Avatar,+ AvatarFallback,+ AvatarImage,+} from "@/src/components/ui/avatar";+import {+ Card,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+} from "@/src/components/ui/card";+import { OrganizationDropdownMenu } from "@/src/components/OrganizationDropdownMenu/OrganizationDropdownMenu";+import { ProjectDropdownMenu } from "@/src/components/ProjectDropdownMenu/ProjectDropdownMenu";+import { assertUnreachable } from "@/src/utils/types";+import { SIDEBAR_NOTIFICATIONS, type SidebarNotification } from "./utils";+import { useOrgProjectSwitchPaths } from "@/src/features/projects/hooks";++const TWO_WEEKS_MS = 14 * 24 * 60 * 60 * 1000;++type SelfHostedPlan = Extract<Plan, "oss" | `self-hosted:${string}`>;++type SidebarVersionState =+ | { deployment: "cloud" }+ | {+ deployment: "self-hosted";+ plan: SelfHostedPlan;+ release:+ | { status: "current" }+ | {+ status: "update-available";+ updateType: "major" | "minor" | "patch";+ latestRelease: string;+ };+ migration: { status: "idle" } | { status: "in-progress"; phase: string };+ };++const selfHostedPlanLabels = {+ oss: { short: "OSS", long: "Open Source" },+ "self-hosted:pro": {+ short: "Pro",+ long: planLabels["self-hosted:pro"],+ },+ "self-hosted:enterprise": {+ short: "EE",+ long: planLabels["self-hosted:enterprise"],+ },+} satisfies Record<SelfHostedPlan, { short: string; long: string }>;++type UserNavigationItemBase = {+ name: string;+ content?: React.ReactNode;+};++type UserNavigationLeafItem =+ | (UserNavigationItemBase & {+ type: "action";+ onClick: () => void;+ })+ | (UserNavigationItemBase & {+ type: "link";+ href: string;+ });++type UserNavigationItem =+ | UserNavigationLeafItem+ | (UserNavigationItemBase & {+ type: "submenu";+ subItems: UserNavigationLeafItem[];+ });++type SidebarUser = {+ name: string;+ email: string;+ avatar: string;+};++type SidebarNotificationState = {+ dismissedIds: string[];+ onDismiss: (id: string) => void;+ onLinkClick: (id: string) => void;+};++type OrganizationDropdownOption = Extract<+ React.ComponentProps<typeof OrganizationDropdownMenu>,+ { state: "loaded" }+>["organizations"][number];++type ProjectOption = Extract<+ React.ComponentProps<typeof ProjectDropdownMenu>,+ { state: "loaded" }+>["projects"][number];++type OrganizationOption = OrganizationDropdownOption & {+ projects: ProjectOption[];+};++type AppSidebarProps = {+ navItems: {+ grouped: Partial<Record<RouteGroup, NavMainItem[]>> | null;+ ungrouped: NavMainItem[];+ };+ secondaryNavItems: {+ grouped: Partial<Record<RouteGroup, NavMainItem[]>> | null;+ ungrouped: NavMainItem[];+ };+ user: SidebarUser;+ userMenuItems: UserNavigationItem[];+ isMobile: boolean;+ logo: {+ lightModeHref?: string;+ darkModeHref?: string;+ };+ versionState: SidebarVersionState;+ showDemoBadge: boolean;+ v4UpgradeUiEnabled: boolean;+ notificationState: SidebarNotificationState;+ organization: { id: string; name: string } | null;+ project: { id: string; name: string } | null;+ organizations: OrganizationOption[] | null;+ canCreateOrganizations: boolean;+ canCreateProjects: boolean;+};++export function AppSidebar({+ navItems,+ secondaryNavItems,+ user,+ userMenuItems,+ isMobile,+ logo,+ versionState,+ showDemoBadge,+ v4UpgradeUiEnabled,+ notificationState,+ organization,+ project,+ organizations,+ canCreateOrganizations,+ canCreateProjects,+}: AppSidebarProps) {+ const activeNotifications = !v4UpgradeUiEnabled+ ? SIDEBAR_NOTIFICATIONS.filter((notification) => {+ if (notificationState.dismissedIds.includes(notification.id)) {+ return false;+ }+ if (!notification.createdAt) return true;++ const createdAt = new Date(notification.createdAt).getTime();+ return Date.now() <= createdAt + (notification.ttlMs ?? TWO_WEEKS_MS);+ })+ : [];++ return (+ <Sidebar collapsible="icon" variant="sidebar">+ <SidebarHeader>+ <div className="flex min-h-9 min-w-0 items-center py-2 pr-2 pl-3 group-data-[collapsible=icon]:p-3">+ <Link href="/" className="flex items-center">+ <LangfuseLogo+ logoLightModeHref={logo.lightModeHref}+ logoDarkModeHref={logo.darkModeHref}+ />+ </Link>+ <div className="ml-auto flex min-w-0 items-center overflow-hidden pl-2 group-data-[collapsible=icon]:hidden">+ <VersionLabel state={versionState} />+ </div>+ </div>+ <div className="h-1 flex-1 border-b" />+ {showDemoBadge && <DemoBadge />}+ </SidebarHeader>+ <SidebarContent>+ {isMobile && organization && (+ <MobileNavSwitcher+ organization={organization}+ project={project}+ organizations={organizations}+ canCreateOrganizations={canCreateOrganizations}+ canCreateProjects={canCreateProjects}+ />+ )}+ <NavMain items={navItems} />+ <div className="flex-1" />+ {activeNotifications.length > 0 && (+ <div className="flex flex-col gap-2 p-2">+ <SidebarNotifications+ state={notificationState}+ activeNotifications={activeNotifications}+ />+ </div>+ )}+ <NavMain items={secondaryNavItems} />+ </SidebarContent>+ <SidebarFooter>+ <NavUser user={user} items={userMenuItems} isMobile={isMobile} />+ </SidebarFooter>+ <SidebarRail />+ </Sidebar>+ );+}++function MobileNavSwitcher({+ organization,+ project,+ organizations,+ canCreateOrganizations,+ canCreateProjects,+}: {+ organization: { id: string; name: string };+ project: { id: string; name: string } | null;+ organizations: OrganizationOption[] | null;+ canCreateOrganizations: boolean;+ canCreateProjects: boolean;+}) {+ const { getProjectPath, getOrgPath } = useOrgProjectSwitchPaths();++ return (+ <SidebarGroup className="border-b">+ <SidebarGroupContent>+ <SidebarMenu>+ <SidebarMenuItem>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <SidebarMenuButton>+ <span+ className="min-w-0 flex-1 truncate text-left"+ title={organization.name}+ >+ {organization.name}+ </span>+ <ChevronDownIcon className="ml-auto h-4 w-4 shrink-0" />+ </SidebarMenuButton>+ </DropdownMenuTrigger>+ <OrganizationDropdownMenu+ {...(organizations+ ? { state: "loaded", organizations }+ : { state: "loading" })}+ canCreateOrganizations={canCreateOrganizations}+ getOrgPath={getOrgPath}+ />+ </DropdownMenu>+ </SidebarMenuItem>+ {project && (+ <SidebarMenuItem>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <SidebarMenuButton>+ <span+ className="min-w-0 flex-1 truncate text-left"+ title={project.name}+ >+ {project.name}+ </span>+ <ChevronDownIcon className="ml-auto h-4 w-4 shrink-0" />+ </SidebarMenuButton>+ </DropdownMenuTrigger>+ <ProjectDropdownMenu+ organizationId={organization.id}+ {...(organizations+ ? {+ state: "loaded",+ projects:+ organizations.find(+ (item) => item.id === organization.id,+ )?.projects ?? [],+ }+ : { state: "loading" })}+ canCreateProjects={canCreateProjects}+ getProjectPath={getProjectPath}+ />+ </DropdownMenu>+ </SidebarMenuItem>+ )}+ </SidebarMenu>+ </SidebarGroupContent>+ </SidebarGroup>+ );+}++function SidebarNotifications({+ state,+ activeNotifications,+}: {+ state: SidebarNotificationState;+ activeNotifications: SidebarNotification[];+}) {+ const visibleNotifications = activeNotifications.slice(0, 3);+ const frontNotification = visibleNotifications[0];+ const backCount = visibleNotifications.length - 1;+ const peekOffset = 8;+ const peekScaleStep = 0.05;++ return (+ <div+ className="group-data-[collapsible=icon]:hidden"+ style={{ paddingBottom: backCount * peekOffset + 2 }}+ >+ <div className="relative">+ {Array.from({ length: backCount }).map((_, index) => {+ const stackIndex = index + 1;+ return (+ <Card+ key={`stack-${stackIndex}`}+ aria-hidden+ className="bg-card pointer-events-none absolute inset-0 rounded-md shadow-none"+ style={{+ transform: `translateY(${stackIndex * peekOffset}px) scaleX(${+ 1 - stackIndex * peekScaleStep+ })`,+ transformOrigin: "top center",+ zIndex: visibleNotifications.length - stackIndex,+ }}+ />+ );+ })}+ <Card+ key={frontNotification.id}+ className="bg-card relative max-h-60 overflow-hidden rounded-md shadow-none"+ style={{ zIndex: visibleNotifications.length }}+ >+ <Button+ variant="ghost"+ size="sm"+ className="absolute top-2.5 right-1.5 h-5 w-5 p-0"+ onClick={() => state.onDismiss(frontNotification.id)}+ title="Dismiss"+ >+ <X className="h-3.5 w-3.5" />+ </Button>+ <CardHeader className="px-3 pt-2.5 pr-6 pb-0">+ <CardTitle className="text-sm">{frontNotification.title}</CardTitle>+ <CardDescription className="mt-1">+ {frontNotification.description}+ </CardDescription>+ </CardHeader>+ <CardContent className="px-3 pt-1.5 pb-2.5">+ {frontNotification.link &&+ (frontNotification.linkImage ? (+ <Link+ href={frontNotification.link}+ target="_blank"+ onClick={() => state.onLinkClick(frontNotification.id)}+ >+ {/* eslint-disable-next-line @next/next/no-img-element */}+ <img+ alt={frontNotification.linkImage.alt}+ src={frontNotification.linkImage.src}+ />+ </Link>+ ) : (+ <Button+ variant="secondary"+ size="sm"+ className="w-full"+ asChild+ >+ <Link+ href={frontNotification.link}+ target="_blank"+ onClick={() => state.onLinkClick(frontNotification.id)}+ >+ {frontNotification.linkTitle ?? "Learn more"} →+ </Link>+ </Button>+ ))}+ </CardContent>+ </Card>+ </div>+ </div>+ );+}++function NavUser({+ user,+ items,+ isMobile,+}: {+ user: SidebarUser;+ items: UserNavigationItem[];+ isMobile: boolean;+}) {+ const initials = user.name+ .split(" ")+ .slice(0, 2)+ .map((word) => word[0])+ .join("")+ .toUpperCase();++ const renderMenuItem = (item: UserNavigationItem) => {+ if (item.type === "submenu") {+ return (+ <DropdownMenuSub key={item.name}>+ <DropdownMenuSubTrigger>+ {item.content ?? item.name}+ </DropdownMenuSubTrigger>+ <DropdownMenuSubContent>+ {item.subItems.map(renderMenuItem)}+ </DropdownMenuSubContent>+ </DropdownMenuSub>+ );+ }++ if (item.type === "link") {+ return (+ <DropdownMenuItem key={item.name} asChild>+ <Link href={item.href}>{item.content ?? item.name}</Link>+ </DropdownMenuItem>+ );+ }++ if (item.type === "action") {+ return (+ <DropdownMenuItem key={item.name} onClick={item.onClick}>+ {item.content ?? item.name}+ </DropdownMenuItem>+ );+ }++ return assertUnreachable(item);+ };++ return (+ <SidebarMenu>+ <SidebarMenuItem>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <SidebarMenuButton+ size="lg"+ className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"+ >+ <Avatar className="h-8 w-8 rounded-lg">+ <AvatarImage src={user.avatar} alt={user.name} />+ <AvatarFallback className="rounded-lg">+ {initials}+ </AvatarFallback>+ </Avatar>+ <div className="grid flex-1 text-left text-sm leading-tight">+ <span className="truncate font-bold" title={user.name}>+ {user.name}+ </span>+ <span className="truncate text-xs" title={user.email}>+ {user.email}+ </span>+ </div>+ <ChevronsUpDown className="ml-auto size-4" />+ </SidebarMenuButton>+ </DropdownMenuTrigger>+ <DropdownMenuContent+ className="w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg"+ side={isMobile ? "bottom" : "right"}+ align="end"+ sideOffset={4}+ >+ <DropdownMenuLabel className="p-0 font-normal">+ <div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm">+ <Avatar className="h-8 w-8 rounded-lg">+ <AvatarImage src={user.avatar} alt={user.name} />+ <AvatarFallback className="rounded-lg">+ {initials}+ </AvatarFallback>+ </Avatar>+ <div className="grid flex-1 text-left text-sm leading-tight">+ <span className="truncate font-bold" title={user.name}>+ {user.name}+ </span>+ <span className="truncate text-xs" title={user.email}>+ {user.email}+ </span>+ </div>+ </div>+ </DropdownMenuLabel>+ <DropdownMenuSeparator />+ <DropdownMenuGroup>{items.map(renderMenuItem)}</DropdownMenuGroup>+ </DropdownMenuContent>+ </DropdownMenu>+ </SidebarMenuItem>+ </SidebarMenu>+ );+}++const DemoBadge = () => {+ return (+ <SidebarGroup className="border-b">+ <SidebarGroupLabel>Demo Project (view only)</SidebarGroupLabel>+ <SidebarGroupContent>+ <SidebarMenu>+ <SidebarMenuItem>+ <SidebarMenuButton+ asChild+ tooltip="Use Demo App to create traces"+ variant="cta"+ >+ <Link+ href="https://langfuse.com/docs/demo"+ target="_blank"+ rel="noopener noreferrer"+ >+ <ExternalLink className="h-4 w-4" />+ <span>Use Demo App</span>+ </Link>+ </SidebarMenuButton>+ </SidebarMenuItem>+ <SidebarMenuItem>+ <SidebarMenuButton asChild tooltip="Your Langfuse Organizations">+ <Link href="/">+ <Grid2X2 className="h-4 w-4" />+ <span>Your Langfuse Orgs</span>+ </Link>+ </SidebarMenuButton>+ </SidebarMenuItem>+ </SidebarMenu>+ </SidebarGroupContent>+ </SidebarGroup>+ );+};++const VersionLabel = ({ state }: { state: SidebarVersionState }) => {+ const selfHostedPlanLabel =+ state.deployment === "self-hosted"+ ? selfHostedPlanLabels[state.plan]+ : null;+ const backgroundMigrationStatus =+ state.deployment === "self-hosted" &&+ state.migration.status === "in-progress"+ ? state.migration.phase+ : null;+ const update =+ state.deployment === "self-hosted" &&+ state.release.status === "update-available"+ ? state.release+ : null;+ const versionText = `${VERSION}${+ selfHostedPlanLabel ? ` ${selfHostedPlanLabel.short}` : ""+ }`;+ const color = React.useMemo(() => {+ if (!update) return undefined;+ if (update.updateType === "major") return "text-dark-red";+ if (update.updateType === "minor") return "text-dark-yellow";+ if (update.updateType === "patch") return undefined;+ return assertUnreachable(update.updateType);+ }, [update]);++ return (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button+ variant="ghost"+ size="xs"+ className="h-5 max-w-full min-w-0 py-0.5 text-[0.625rem]"+ >+ <span className="truncate" title={versionText}>+ {versionText}+ </span>+ {backgroundMigrationStatus && (+ <StatusBadge+ type={backgroundMigrationStatus}+ showText={false}+ className="bg-transparent"+ />+ )}+ {update && !backgroundMigrationStatus && (+ <ArrowUp className={`h-3 w-3 ${color}`} />+ )}+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent onClick={(e) => e.stopPropagation()}>+ {update ? (+ <>+ <DropdownMenuLabel>+ New {update.updateType} version: {update.latestRelease}+ </DropdownMenuLabel>+ <DropdownMenuSeparator />+ </>+ ) : state.deployment === "self-hosted" ? (+ <>+ <DropdownMenuLabel>This is the latest release</DropdownMenuLabel>+ <DropdownMenuSeparator />+ </>+ ) : null}+ {selfHostedPlanLabel && (+ <>+ <DropdownMenuLabel className="flex items-center font-normal">+ <BadgeCheck size={16} className="mr-2" />+ {selfHostedPlanLabel.long}+ </DropdownMenuLabel>+ <DropdownMenuSeparator />+ </>+ )}+ <DropdownMenuItem asChild>+ <Link+ href="https://github.com/langfuse/langfuse/releases"+ target="_blank"+ >+ <SiGithub size={16} className="mr-2" />+ Releases+ </Link>+ </DropdownMenuItem>+ {state.deployment === "self-hosted" && (+ <DropdownMenuItem asChild>+ <Link href="/background-migrations">+ <ArrowUp10 size={16} className="mr-2" />+ Background Migrations+ {backgroundMigrationStatus && (+ <StatusBadge+ type={backgroundMigrationStatus}+ showText={false}+ className="bg-transparent"+ />+ )}+ </Link>+ </DropdownMenuItem>+ )}+ <DropdownMenuItem asChild>+ <Link href="https://langfuse.com/changelog" target="_blank">+ <Newspaper size={16} className="mr-2" />+ Changelog+ </Link>+ </DropdownMenuItem>+ <DropdownMenuItem asChild>+ <Link href="https://langfuse.com/roadmap" target="_blank">+ <Map size={16} className="mr-2" />+ Roadmap+ </Link>+ </DropdownMenuItem>+ {state.deployment === "self-hosted" && (+ <DropdownMenuItem asChild>+ <Link href="https://langfuse.com/pricing-self-host" target="_blank">+ <Info size={16} className="mr-2" />+ Compare Versions+ </Link>+ </DropdownMenuItem>+ )}+ {update && (+ <>+ <DropdownMenuSeparator />+ <DropdownMenuItem asChild>+ <Link+ href="https://langfuse.com/docs/deployment/self-host#update"+ target="_blank"+ >+ <HardDriveDownload size={16} className="mr-2" />+ Update+ </Link>+ </DropdownMenuItem>+ </>+ )}+ </DropdownMenuContent>+ </DropdownMenu>+ );+};diff --git a/web/src/components/nav/AppSidebar/utils.ts b/web/src/components/nav/AppSidebar/utils.tsnew file mode 100644index 0000000000..99f5a7853c--- /dev/null+++ b/web/src/components/nav/AppSidebar/utils.ts@@ -0,0 +1,71 @@+export type SidebarNotification = {+ id: string;+ title: string;+ description: string;+ createdAt?: string;+ link?: string;+ linkTitle?: string;+ linkImage?: {+ alt: string;+ src: string;+ };+ ttlMs?: number;+};++export const SIDEBAR_NOTIFICATIONS: SidebarNotification[] = [+ {+ id: "lw5-1",+ title: "Launch Week: Day 1",+ description:+ "Run experiments inside GitHub Actions to test every PR against a Langfuse dataset.",+ link: "https://langfuse.com/changelog/2026-05-25-experiment-ci-cd-gates",+ linkTitle: "Learn more",+ createdAt: "2026-05-25",+ },+ {+ id: "lw5-2",+ title: "Launch Week: Day 2",+ description:+ "Langfuse agent skill turns Langfuse into a headless platform to evaluate, query and instrument your application.",+ link: "https://langfuse.com/changelog/2026-05-26-langfuse-agent-skill",+ linkTitle: "Learn more",+ createdAt: "2026-05-26",+ },+ {+ id: "lw5-3",+ title: "Launch Week: Day 3",+ description: "Fast full-text search on observation I/O via the UI and API",+ link: "https://langfuse.com/changelog/2026-05-27-clickhouse-full-text-search-fast-mode",+ linkTitle: "Learn more",+ createdAt: "2026-05-27",+ },+ {+ id: "lw5-4",+ title: "Launch Week: Day 4",+ description:+ "Code evaluators let you score observations and experiments with Python/TypeScript checks.",+ link: "https://langfuse.com/changelog/2026-05-28-code-evaluators",+ linkTitle: "Learn more",+ createdAt: "2026-05-28",+ },+ {+ id: "lw5-5",+ title: "Launch Week: Day 5",+ description:+ "Langfuse MCP now covers observations, metrics, scores, datasets, comments, and more.",+ link: "https://langfuse.com/changelog/2026-05-29-mcp-update",+ linkTitle: "Learn more",+ createdAt: "2026-05-29",+ },+ {+ id: "github-star",+ title: "Star Langfuse",+ description:+ "See the latest releases and help grow the community on GitHub",+ link: "https://github.com/langfuse/langfuse",+ linkImage: {+ alt: "Langfuse GitHub stars",+ src: "https://img.shields.io/github/stars/langfuse/langfuse?label=langfuse&style=social",+ },+ },+];diff --git a/web/src/components/nav/app-sidebar.tsx b/web/src/components/nav/app-sidebar.tsxdeleted file mode 100644index eb6c152a39..0000000000--- a/web/src/components/nav/app-sidebar.tsx+++ /dev/null@@ -1,133 +0,0 @@-"use client";--import * as React from "react";-import { NavMain, type NavMainItem } from "@/src/components/nav/nav-main";-import {- NavUser,- type UserNavigationProps,-} from "@/src/components/nav/nav-user";-import {- Sidebar,- SidebarContent,- SidebarFooter,- SidebarGroup,- SidebarGroupContent,- SidebarGroupLabel,- SidebarHeader,- SidebarMenu,- SidebarMenuButton,- SidebarMenuItem,- SidebarRail,- useSidebar,-} from "@/src/components/ui/sidebar";-import { env } from "@/src/env.mjs";-import { useRouter } from "next/router";-import Link from "next/link";-import { LangfuseLogo } from "@/src/components/LangfuseLogo";-import { MobileNavSwitcher } from "@/src/components/nav/mobile-nav-switcher";-import { SidebarNotifications } from "@/src/components/nav/sidebar-notifications";-import { type RouteGroup } from "@/src/components/layouts/routes";-import { ExternalLink, Grid2X2 } from "lucide-react";-import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";-import { useV4UpgradeUiEnabled } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";--type AppSidebarProps = {- navItems: {- grouped: Partial<Record<RouteGroup, NavMainItem[]>> | null;- ungrouped: NavMainItem[];- };- secondaryNavItems: {- grouped: Partial<Record<RouteGroup, NavMainItem[]>> | null;- ungrouped: NavMainItem[];- };- userNavProps: UserNavigationProps;-} & React.ComponentProps<typeof Sidebar>;--export function AppSidebar({- navItems,- secondaryNavItems,- userNavProps,- ...props-}: AppSidebarProps) {- const { isMobile } = useSidebar();- const v4UpgradeUiEnabled = useV4UpgradeUiEnabled();-- return (- <Sidebar collapsible="icon" variant="sidebar" {...props}>- <SidebarHeader>- <div className="flex min-h-9 items-center gap-2 py-2 pr-0 pl-2 group-data-[collapsible=icon]:p-3">- <LangfuseLogo version />- </div>- <div className="h-1 flex-1 border-b" />- <DemoBadge />- </SidebarHeader>- <SidebarContent>- {isMobile && <MobileNavSwitcher />}- <NavMain items={navItems} />- <div className="flex-1" />- {/* Hidden for v4-upgrade users only: the "Update" nav entry is trialled- in this slot. Everyone else keeps the notifications stack. */}- {!v4UpgradeUiEnabled && (- <div className="flex flex-col gap-2 p-2">- <SidebarNotifications />- </div>- )}- <NavMain items={secondaryNavItems} />- </SidebarContent>- <SidebarFooter>- <NavUser {...userNavProps} />- </SidebarFooter>- <SidebarRail />- </Sidebar>- );-}--const DemoBadge = () => {- const router = useRouter();- const { isLangfuseCloud } = useLangfuseCloudRegion();- const routerProjectId = router.query.projectId as string | undefined;-- if (- !(- env.NEXT_PUBLIC_DEMO_ORG_ID &&- env.NEXT_PUBLIC_DEMO_PROJECT_ID &&- routerProjectId === env.NEXT_PUBLIC_DEMO_PROJECT_ID &&- isLangfuseCloud- )- )- return null;-- return (- <SidebarGroup className="border-b">- <SidebarGroupLabel>Demo Project (view only)</SidebarGroupLabel>- <SidebarGroupContent>- <SidebarMenu>- <SidebarMenuItem>- <SidebarMenuButton- asChild- tooltip="Use Demo App to create traces"- variant="cta"- >- <Link- href="https://langfuse.com/docs/demo"- target="_blank"- rel="noopener noreferrer"- >- <ExternalLink className="h-4 w-4" />- <span>Use Demo App</span>- </Link>- </SidebarMenuButton>- </SidebarMenuItem>- <SidebarMenuItem>- <SidebarMenuButton asChild tooltip="Your Langfuse Organizations">- <Link href="/">- <Grid2X2 className="h-4 w-4" />- <span>Your Langfuse Orgs</span>- </Link>- </SidebarMenuButton>- </SidebarMenuItem>- </SidebarMenu>- </SidebarGroupContent>- </SidebarGroup>- );-};diff --git a/web/src/components/nav/mobile-nav-switcher.tsx b/web/src/components/nav/mobile-nav-switcher.tsxdeleted file mode 100644index f878cdc817..0000000000--- a/web/src/components/nav/mobile-nav-switcher.tsx+++ /dev/null@@ -1,108 +0,0 @@-import { ChevronDownIcon } from "lucide-react";-import { useSession } from "next-auth/react";-import {- DropdownMenu,- DropdownMenuTrigger,-} from "@/src/components/ui/dropdown-menu";-import {- SidebarGroup,- SidebarGroupContent,- SidebarMenu,- SidebarMenuButton,- SidebarMenuItem,-} from "@/src/components/ui/sidebar";-import { OrganizationDropdownMenu } from "@/src/components/OrganizationDropdownMenu/OrganizationDropdownMenu";-import { ProjectDropdownMenu } from "@/src/components/ProjectDropdownMenu/ProjectDropdownMenu";-import {- useOrgProjectSwitchPaths,- useQueryProjectOrOrganization,-} from "@/src/features/projects/hooks";-import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";--/**- * Org + project switcher for the TOP of the mobile nav drawer.- *- * The mobile drawer (the `Sheet` branch of `Sidebar`, see ui/sidebar.tsx)- * otherwise only lists section links — the same switching affordance the- * desktop breadcrumb offers (`BreadcrumbComponent`) is easy to miss on- * mobile, since the breadcrumb sits in the page body. This reuses the exact- * dropdown menus and path builders the breadcrumb uses, so switching- * behavior is identical between both entry points; only rendered by- * `AppSidebar` when `useSidebar().isMobile` is true.- */-export function MobileNavSwitcher() {- const session = useSession();- const { organization, project } = useQueryProjectOrOrganization();- const { getProjectPath, getOrgPath } = useOrgProjectSwitchPaths();-- const organizations = session.data?.user?.organizations;- const canCreateOrganizations = session.data?.user?.canCreateOrganizations;- const canCreateProjects = useHasOrganizationAccess({- organizationId: organization?.id,- scope: "projects:create",- });-- if (!organization) return null;-- return (- <SidebarGroup className="border-b">- <SidebarGroupContent>- <SidebarMenu>- <SidebarMenuItem>- <DropdownMenu>- <DropdownMenuTrigger asChild>- <SidebarMenuButton>- <span- className="min-w-0 flex-1 truncate text-left"- title={organization.name}- >- {organization.name}- </span>- <ChevronDownIcon className="ml-auto h-4 w-4 shrink-0" />- </SidebarMenuButton>- </DropdownMenuTrigger>- <OrganizationDropdownMenu- {...(organizations- ? { state: "loaded", organizations }- : { state: "loading" })}- canCreateOrganizations={!!canCreateOrganizations}- getOrgPath={getOrgPath}- />- </DropdownMenu>- </SidebarMenuItem>- {project && (- <SidebarMenuItem>- <DropdownMenu>- <DropdownMenuTrigger asChild>- <SidebarMenuButton>- <span- className="min-w-0 flex-1 truncate text-left"- title={project.name}- >- {project.name}- </span>- <ChevronDownIcon className="ml-auto h-4 w-4 shrink-0" />- </SidebarMenuButton>- </DropdownMenuTrigger>- <ProjectDropdownMenu- organizationId={organization.id}- {...(organizations- ? {- state: "loaded",- projects:- organizations.find(- (org) => org.id === organization.id,- )?.projects ?? [],- }- : { state: "loading" })}- canCreateProjects={!!canCreateProjects}- getProjectPath={getProjectPath}- />- </DropdownMenu>- </SidebarMenuItem>- )}- </SidebarMenu>- </SidebarGroupContent>- </SidebarGroup>- );-}diff --git a/web/src/components/nav/nav-user.tsx b/web/src/components/nav/nav-user.tsxdeleted file mode 100644index 48566f5564..0000000000--- a/web/src/components/nav/nav-user.tsx+++ /dev/null@@ -1,147 +0,0 @@-"use client";--import { ChevronsUpDown } from "lucide-react";-import Link from "next/link";--import {- Avatar,- AvatarFallback,- AvatarImage,-} from "@/src/components/ui/avatar";-import {- DropdownMenu,- DropdownMenuContent,- DropdownMenuGroup,- DropdownMenuItem,- DropdownMenuLabel,- DropdownMenuSeparator,- DropdownMenuSub,- DropdownMenuSubContent,- DropdownMenuSubTrigger,- DropdownMenuTrigger,-} from "@/src/components/ui/dropdown-menu";-import {- SidebarMenu,- SidebarMenuButton,- SidebarMenuItem,- useSidebar,-} from "@/src/components/ui/sidebar";--export type UserNavigationItem = {- name: string;- onClick?: () => void;- content?: React.ReactNode;- href?: string;- subItems?: UserNavigationItem[];-};--export type UserNavigationProps = {- user: {- name: string;- email: string;- avatar: string;- };- items: UserNavigationItem[];-};--export function NavUser({ user, items }: UserNavigationProps) {- const { isMobile } = useSidebar();-- const initials = user.name- .split(" ")- .slice(0, 2)- .map((word) => word[0])- .join("")- .toUpperCase();-- const renderMenuItem = (item: UserNavigationItem) => {- if (item.subItems?.length) {- return (- <DropdownMenuSub key={item.name}>- <DropdownMenuSubTrigger>- {item.content ?? item.name}- </DropdownMenuSubTrigger>- <DropdownMenuSubContent>- {item.subItems.map(renderMenuItem)}- </DropdownMenuSubContent>- </DropdownMenuSub>- );- }-- if (item.href) {- return (- <DropdownMenuItem key={item.name} asChild>- <Link href={item.href}>{item.content ?? item.name}</Link>- </DropdownMenuItem>- );- }-- return (- <DropdownMenuItem key={item.name} onClick={item.onClick}>- {item.content ?? item.name}- </DropdownMenuItem>- );- };-- return (- <SidebarMenu>- <SidebarMenuItem>- <DropdownMenu>- <DropdownMenuTrigger asChild>- <SidebarMenuButton- size="lg"- className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"- >- <Avatar className="h-8 w-8 rounded-lg">- <AvatarImage src={user.avatar} alt={user.name} />- <AvatarFallback className="rounded-lg">- {initials}- </AvatarFallback>- </Avatar>- <div className="grid flex-1 text-left text-sm leading-tight">- <span className="truncate font-bold" title={user.name}>- {user.name}- </span>- <span className="truncate text-xs" title={user.email}>- {user.email}- </span>- </div>- <ChevronsUpDown className="ml-auto size-4" />- </SidebarMenuButton>- </DropdownMenuTrigger>- <DropdownMenuContent- // No z-index: this dropdown portals into the `popover` overlay- // layer, which sits above the `agent` layer (the assistant window)- // by layer ORDER — so it opens above the window with no magic- // number. See components/ui/layer.tsx.- className="w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg"- side={isMobile ? "bottom" : "right"}- align="end"- sideOffset={4}- >- <DropdownMenuLabel className="p-0 font-normal">- <div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm">- <Avatar className="h-8 w-8 rounded-lg">- <AvatarImage src={user.avatar} alt={user.name} />- <AvatarFallback className="rounded-lg">- {initials}- </AvatarFallback>- </Avatar>- <div className="grid flex-1 text-left text-sm leading-tight">- <span className="truncate font-bold" title={user.name}>- {user.name}- </span>- <span className="truncate text-xs" title={user.email}>- {user.email}- </span>- </div>- </div>- </DropdownMenuLabel>- <DropdownMenuSeparator />- <DropdownMenuGroup>{items.map(renderMenuItem)}</DropdownMenuGroup>- </DropdownMenuContent>- </DropdownMenu>- </SidebarMenuItem>- </SidebarMenu>- );-}diff --git a/web/src/components/nav/sidebar-notifications.clienttest.tsx b/web/src/components/nav/sidebar-notifications.clienttest.tsxdeleted file mode 100644index 6b244d1243..0000000000--- a/web/src/components/nav/sidebar-notifications.clienttest.tsx+++ /dev/null@@ -1,32 +0,0 @@-import { render, screen } from "@testing-library/react";-import { SidebarNotifications, notifications } from "./sidebar-notifications";--const GITHUB_STAR_ID = "github-star";--const mockState = vi.hoisted(() => ({ dismissed: [] as string[] }));--vi.mock("../useLocalStorage", () => ({- __esModule: true,- default: () => [mockState.dismissed, vi.fn()],-}));--describe("SidebarNotifications", () => {- beforeEach(() => {- // Dismiss every notification except the GitHub star one so it surfaces- // as the front card regardless of how many launch-week notifications- // are added over time.- mockState.dismissed = notifications- .filter((n) => n.id !== GITHUB_STAR_ID)- .map((n) => n.id);- });-- it("renders the GitHub stars badge with social style query params", () => {- render(<SidebarNotifications />);-- const badge = screen.getByAltText("Langfuse GitHub stars");- const src = badge.getAttribute("src");-- expect(src).toContain("style=social");- expect(src).not.toContain("&");- });-});diff --git a/web/src/components/nav/sidebar-notifications.tsx b/web/src/components/nav/sidebar-notifications.tsxdeleted file mode 100644index 5c272dbb65..0000000000--- a/web/src/components/nav/sidebar-notifications.tsx+++ /dev/null@@ -1,213 +0,0 @@-import { Button } from "@/src/components/ui/button";-import {- Card,- CardContent,- CardDescription,- CardHeader,- CardTitle,-} from "@/src/components/ui/card";-import { X } from "lucide-react";-import useLocalStorage from "../useLocalStorage";-import Link from "next/link";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";--const TWO_WEEKS_MS = 14 * 24 * 60 * 60 * 1000;--type SidebarNotification = {- id: string; // Add unique ID for each notification- title: string;- description: React.ReactNode;- createdAt?: string; // optional, used to expire the notification- link?: string;- // defaults to "Learn more" if no linkContent and no linkTitle- linkTitle?: string;- linkContent?: React.ReactNode;- // Time-to-live in milliseconds from createdAt. Defaults to TWO_WEEKS_MS.- ttlMs?: number;-};--export const notifications: SidebarNotification[] = [- {- id: "lw5-1",- title: "Launch Week: Day 1",- description:- "Run experiments inside GitHub Actions to test every PR against a Langfuse dataset.",- link: "https://langfuse.com/changelog/2026-05-25-experiment-ci-cd-gates",- linkTitle: "Learn more",- createdAt: "2026-05-25",- },- {- id: "lw5-2",- title: "Launch Week: Day 2",- description:- "Langfuse agent skill turns Langfuse into a headless platform to evaluate, query and instrument your application.",- link: "https://langfuse.com/changelog/2026-05-26-langfuse-agent-skill",- linkTitle: "Learn more",- createdAt: "2026-05-26",- },- {- id: "lw5-3",- title: "Launch Week: Day 3",- description: "Fast full-text search on observation I/O via the UI and API",- link: "https://langfuse.com/changelog/2026-05-27-clickhouse-full-text-search-fast-mode",- linkTitle: "Learn more",- createdAt: "2026-05-27",- },- {- id: "lw5-4",- title: "Launch Week: Day 4",- description:- "Code evaluators let you score observations and experiments with Python/TypeScript checks.",- link: "https://langfuse.com/changelog/2026-05-28-code-evaluators",- linkTitle: "Learn more",- createdAt: "2026-05-28",- },- {- id: "lw5-5",- title: "Launch Week: Day 5",- description:- "Langfuse MCP now covers observations, metrics, scores, datasets, comments, and more.",- link: "https://langfuse.com/changelog/2026-05-29-mcp-update",- linkTitle: "Learn more",- createdAt: "2026-05-29",- },- {- id: "github-star",- title: "Star Langfuse",- description:- "See the latest releases and help grow the community on GitHub",- link: "https://github.com/langfuse/langfuse",- linkContent: (- // eslint-disable-next-line @next/next/no-img-element- <img- alt="Langfuse GitHub stars"- src="https://img.shields.io/github/stars/langfuse/langfuse?label=langfuse&style=social"- />- ),- },-];--const STORAGE_KEY = "dismissed-sidebar-notifications";--export function SidebarNotifications() {- const capture = usePostHogClientCapture();-- const [dismissedNotifications, setDismissedNotifications] = useLocalStorage<- string[]- >(STORAGE_KEY, []);-- const isExpired = (notif: SidebarNotification) => {- if (!notif.createdAt) return false;- const created = new Date(notif.createdAt).getTime();- const ttl = notif.ttlMs ?? TWO_WEEKS_MS;- return Date.now() > created + ttl;- };-- const dismissNotification = (id: string) => {- setDismissedNotifications([...dismissedNotifications, id]);- };-- const activeNotifications = notifications.filter(- (notif) => !dismissedNotifications.includes(notif.id) && !isExpired(notif),- );-- if (activeNotifications.length === 0) {- return null;- }-- const MAX_STACK = 3;- const visibleNotifications = activeNotifications.slice(0, MAX_STACK);- const frontNotification = visibleNotifications[0];- const backCount = visibleNotifications.length - 1;- const peekOffset = 8;- const peekScaleStep = 0.05;- const extraBottomPadding = backCount * peekOffset + 2;-- return (- <div- className="group-data-[collapsible=icon]:hidden"- style={{ paddingBottom: extraBottomPadding }}- >- <div className="relative">- {Array.from({ length: backCount }).map((_, i) => {- const index = i + 1;- return (- <Card- key={`stack-${index}`}- aria-hidden- className="bg-card pointer-events-none absolute inset-0 rounded-md shadow-none"- style={{- transform: `translateY(${index * peekOffset}px) scaleX(${- 1 - index * peekScaleStep- })`,- transformOrigin: "top center",- zIndex: visibleNotifications.length - index,- }}- />- );- })}- <Card- key={frontNotification.id}- className="bg-card relative max-h-60 overflow-hidden rounded-md shadow-none"- style={{ zIndex: visibleNotifications.length }}- >- <Button- variant="ghost"- size="sm"- className="absolute top-2.5 right-1.5 h-5 w-5 p-0"- onClick={() => {- capture("notification:dismiss_notification", {- notification_id: frontNotification.id,- });- dismissNotification(frontNotification.id);- }}- title="Dismiss"- >- <X className="h-3.5 w-3.5" />- </Button>- <CardHeader className="px-3 pt-2.5 pr-6 pb-0">- <CardTitle className="text-sm">{frontNotification.title}</CardTitle>- <CardDescription className="mt-1">- {frontNotification.description}- </CardDescription>- </CardHeader>- <CardContent className="px-3 pt-1.5 pb-2.5">- {frontNotification.link &&- (frontNotification.linkContent ? (- <Link- href={frontNotification.link}- target="_blank"- onClick={() => {- capture("notification:click_link", {- notification_id: frontNotification.id,- });- }}- >- {frontNotification.linkContent}- </Link>- ) : (- <Button- variant="secondary"- size="sm"- className="w-full"- asChild- >- <Link- href={frontNotification.link}- target="_blank"- onClick={() => {- capture("notification:click_link", {- notification_id: frontNotification.id,- });- }}- >- {frontNotification.linkTitle ?? "Learn more"} →- </Link>- </Button>- ))}- </CardContent>- </Card>- </div>- </div>- );-}