🪢 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
feat(layouts): show Langfuse brand mark in the mobile top bar (LFE-11067) (#15224)
Nikita Kabardind70f258e8230
diff --git a/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx b/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsxindex 4bcb90291d..b1fe59f2ba 100644--- a/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx+++ b/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx@@ -9,6 +9,7 @@ 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 { SidebarPresenceProvider } from "@/src/components/nav/sidebar-presence";import { Toaster } from "@/src/components/ui/sonner";import { Layer } from "@/src/components/ui/layer";import { TopBannerProvider } from "@/src/features/top-banner";@@ -168,42 +169,44 @@ export function AuthenticatedLayout({</Head><TopBannerProvider>- <SidebarProvider>- <div className="flex h-dvh w-full flex-col">- <PaymentBanner />- <div className="pt-banner-offset flex min-h-0 flex-1">- <AppSidebar- navItems={navigation.mainNavigation}- secondaryNavItems={navigation.secondaryNavigation}- userNavProps={userNavProps}- />- <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>- {children}- </AppContentWithRightDrawer>- {/* Toasts render in the `toast` overlay layer — the last layer- in LAYER_ORDER — so they paint above every overlay (incl. a- non-modal peek) by DOM order alone, no z-index. Sonner's- Toaster is position:fixed, so nesting it in the fixed- full-screen layer container is positionally identical. */}- <Layer name="toast">- <Toaster visibleToasts={1} />- </Layer>- <CommandMenu mainNavigation={navigation.navigation} />- {/* Assistant window host lives here (not in PageHeader with- its launcher button) so the open window and its geometry- survive route changes. */}- <InAppAgentWindowHost />- </SidebarInset>+ <SidebarPresenceProvider>+ <SidebarProvider>+ <div className="flex h-dvh w-full flex-col">+ <PaymentBanner />+ <div className="pt-banner-offset flex min-h-0 flex-1">+ <AppSidebar+ navItems={navigation.mainNavigation}+ secondaryNavItems={navigation.secondaryNavigation}+ userNavProps={userNavProps}+ />+ <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>+ {children}+ </AppContentWithRightDrawer>+ {/* Toasts render in the `toast` overlay layer — the last layer+ in LAYER_ORDER — so they paint above every overlay (incl. a+ non-modal peek) by DOM order alone, no z-index. Sonner's+ Toaster is position:fixed, so nesting it in the fixed+ full-screen layer container is positionally identical. */}+ <Layer name="toast">+ <Toaster visibleToasts={1} />+ </Layer>+ <CommandMenu mainNavigation={navigation.navigation} />+ {/* Assistant window host lives here (not in PageHeader with+ its launcher button) so the open window and its geometry+ survive route changes. */}+ <InAppAgentWindowHost />+ </SidebarInset>+ </div>+ {hasFeaturePreviews ? (+ <ControlledFeaturePreviewModal+ open={featurePreviewOpen}+ onOpenChange={setFeaturePreviewOpen}+ />+ ) : null}</div>- {hasFeaturePreviews ? (- <ControlledFeaturePreviewModal- open={featurePreviewOpen}- onOpenChange={setFeaturePreviewOpen}- />- ) : null}- </div>- </SidebarProvider>+ </SidebarProvider>+ </SidebarPresenceProvider></TopBannerProvider></>);diff --git a/web/src/components/layouts/page-header.tsx b/web/src/components/layouts/page-header.tsxindex db36043ea1..fedbd0483d 100644--- a/web/src/components/layouts/page-header.tsx+++ b/web/src/components/layouts/page-header.tsx@@ -3,6 +3,7 @@ import { ItemBadge, type LangfuseItemType } from "@/src/components/ItemBadge";import BreadcrumbComponent from "@/src/components/layouts/breadcrumb";import { PageHeaderControlsSlotTarget } from "@/src/components/layouts/page-header-controls-slot";import { InAppAiAgentButton } from "@/src/components/nav/in-app-ai-agent-button";+import { TopbarBrand } from "@/src/components/nav/topbar-brand";import DocPopup from "@/src/components/layouts/doc-popup";import { SidebarTrigger } from "@/src/components/ui/sidebar";import {@@ -103,7 +104,17 @@ const PageHeader = ({><div className="flex min-w-0 flex-wrap items-center gap-3">{showSidebarTrigger ? (- <SidebarTrigger />+ <>+ <SidebarTrigger />+ {/* Brand the app in the top bar while the sidebar (which+ owns the logo) is off-canvas below `md`. Hidden on+ desktop where the sidebar logo is visible. Gated on the+ same condition as the trigger so it only appears where a+ sidebar actually exists to mirror — never on the+ sidebar-less MinimalLayout (e.g. the public/shared trace+ view, which supplies its own leadingControl). */}+ <TopbarBrand className="md:hidden" />+ </>) : (leadingControl && (<div className="flex items-center">{leadingControl}</div>diff --git a/web/src/components/nav/sidebar-presence.tsx b/web/src/components/nav/sidebar-presence.tsxnew file mode 100644index 0000000000..dea85f85a8--- /dev/null+++ b/web/src/components/nav/sidebar-presence.tsx@@ -0,0 +1,29 @@+import { createContext, useContext, type ReactNode } from "react";++/**+ * Signals whether the real app navigation sidebar (`AppSidebar`) is mounted in+ * the current layout.+ *+ * Only `AuthenticatedLayout` mounts `AppSidebar`. The sidebar-less+ * `MinimalLayout` / `UnauthenticatedLayout` (public share views, auth pages)+ * leave this at its default `false`.+ *+ * Top-bar chrome that exists purely to mirror the sidebar — e.g. the mobile+ * `TopbarBrand` — reads this so it never renders on a page that has no sidebar+ * to mirror, regardless of which `PageHeader` props a given route happens to+ * set. That keeps the invariant in one place instead of relying on every+ * MinimalLayout-reachable caller to opt out.+ */+const SidebarPresenceContext = createContext(false);++export const SidebarPresenceProvider = ({+ children,+}: {+ children: ReactNode;+}) => (+ <SidebarPresenceContext.Provider value={true}>+ {children}+ </SidebarPresenceContext.Provider>+);++export const useHasAppSidebar = () => useContext(SidebarPresenceContext);diff --git a/web/src/components/nav/topbar-brand.tsx b/web/src/components/nav/topbar-brand.tsxnew file mode 100644index 0000000000..a13afe3ba7--- /dev/null+++ b/web/src/components/nav/topbar-brand.tsx@@ -0,0 +1,60 @@+import { cn } from "@/src/utils/tailwind";+import Link from "next/link";+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";+import { PlusIcon } from "lucide-react";+import { LangfuseIcon } from "@/src/components/design-system/LangfuseIcon/LangfuseIcon";+import { useHasAppSidebar } from "@/src/components/nav/sidebar-presence";++/**+ * Compact Langfuse brand mark for the top bar.+ *+ * The primary brand lives in the sidebar header. Once the sidebar goes+ * off-canvas (below `md`, where it collapses into a Sheet) nothing brands the+ * app, so the page header renders this compact mark instead — mirroring the+ * icon the sidebar itself shows when collapsed.+ *+ * Respects the self-host UI-customization logo entitlement, same as+ * `LangfuseLogo`, and links to `/` like the sidebar logo.+ */+export const TopbarBrand = ({ className }: { className?: string }) => {+ const hasAppSidebar = useHasAppSidebar();+ const uiCustomization = useUiCustomization();+ const logoLight = uiCustomization?.logoLightModeHref;+ const logoDark = uiCustomization?.logoDarkModeHref;++ // Nothing to mirror when there is no sidebar (sidebar-less MinimalLayout,+ // e.g. public/shared trace and session views). Guarding here keeps the+ // brand off every such route without each caller having to opt out.+ if (!hasAppSidebar) return null;++ return (+ <Link+ href="/"+ aria-label="Langfuse home"+ className={cn("flex shrink-0 items-center gap-1", className)}+ >+ {logoLight && logoDark ? (+ // Custom logo (max aspect ratio 1:3 per docs) + the Langfuse mark,+ // matching LangfuseLogo's customized layout.+ <>+ {/* eslint-disable-next-line @next/next/no-img-element */}+ <img+ src={logoLight}+ alt="Logo"+ className="max-h-5 max-w-16 dark:hidden"+ />+ {/* eslint-disable-next-line @next/next/no-img-element */}+ <img+ src={logoDark}+ alt="Logo"+ className="hidden max-h-5 max-w-16 dark:block"+ />+ <PlusIcon size={8} className="text-muted-foreground" />+ <LangfuseIcon size={16} />+ </>+ ) : (+ <LangfuseIcon size={28} />+ )}+ </Link>+ );+};