🪢 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): minimal-chrome mobile shell (LFE-11067) (#15244)
Nikita Kabardin11f7206aaa9f
diff --git a/web/src/components/layouts/app-layout/index.tsx b/web/src/components/layouts/app-layout/index.tsxindex 32d189070a..a94616f4be 100644--- a/web/src/components/layouts/app-layout/index.tsx+++ b/web/src/components/layouts/app-layout/index.tsx@@ -12,8 +12,7 @@import { type PropsWithChildren, useEffect } from "react";import { useRouter } from "next/router";import { signOut } from "next-auth/react";-import posthog from "posthog-js";-import { env } from "@/src/env.mjs";+import { signOutCleanly } from "@/src/features/auth/lib/signOut";import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";import { ErrorPage } from "@/src/components/error-page";@@ -131,22 +130,12 @@ export function AppLayout(props: PropsWithChildren) {return <LoadingLayout message="Loading" />;}- const handleSignOut = async () => {- sessionStorage.clear();- if (env.NEXT_PUBLIC_POSTHOG_KEY && env.NEXT_PUBLIC_POSTHOG_HOST) {- posthog.reset();- }- await signOut({- callbackUrl: `${env.NEXT_PUBLIC_BASE_PATH ?? ""}/auth/sign-in`,- });- };-return (<AuthenticatedLayoutsession={session.data}navigation={navigation}metadata={metadata}- onSignOut={handleSignOut}+ onSignOut={signOutCleanly}>{props.children}</AuthenticatedLayout>diff --git a/web/src/components/layouts/container-page.tsx b/web/src/components/layouts/container-page.tsxindex b3647423cf..0704c16e02 100644--- a/web/src/components/layouts/container-page.tsx+++ b/web/src/components/layouts/container-page.tsx@@ -1,6 +1,9 @@import PageHeader, {type PageHeaderProps,} from "@/src/components/layouts/page-header";+import { MobileTopBar } from "@/src/components/layouts/mobile-top-bar";+import { MobilePageTitle } from "@/src/components/layouts/mobile-page-title";+import { useIsMobile } from "@/src/hooks/use-mobile";import { cn } from "@/src/utils/tailwind";type SettingsContainerProps = {@@ -12,11 +15,24 @@ const containerLayoutClassName ="lg:mx-auto lg:w-full lg:max-w-screen-lg lg:px-8 xl:max-w-screen-xl 2xl:max-w-[1400px]";const ContainerPage = ({ children, headerProps }: SettingsContainerProps) => {+ // Same minimal-chrome mobile shell as Page (slim top bar + page-title block),+ // so settings/container pages match the rest of the app on mobile. Desktop is+ // unchanged: the existing container PageHeader renders on `md` and up.+ const isMobile = useIsMobile();+return (<div className="min-h-screen-with-banner relative flex flex-1 flex-col"><header className="sticky top-0 z-50 w-full">- <PageHeader {...headerProps} container />+ {isMobile ? (+ <MobileTopBar+ showSidebarTrigger={headerProps.showSidebarTrigger}+ leadingControl={headerProps.leadingControl}+ />+ ) : (+ <PageHeader {...headerProps} container />+ )}</header>+ {isMobile && <MobilePageTitle headerProps={headerProps} />}<mainclassName={cn("relative flex min-h-0 flex-1 flex-col p-3",diff --git a/web/src/components/layouts/mobile-page-title.tsx b/web/src/components/layouts/mobile-page-title.tsxnew file mode 100644index 0000000000..9f893fae86--- /dev/null+++ b/web/src/components/layouts/mobile-page-title.tsx@@ -0,0 +1,113 @@+import { ItemBadge } from "@/src/components/ItemBadge";+import BreadcrumbComponent from "@/src/components/layouts/breadcrumb";+import DocPopup from "@/src/components/layouts/doc-popup";+import { PageHeaderControlsSlotTarget } from "@/src/components/layouts/page-header-controls-slot";+import { InAppAiAgentButton } from "@/src/components/nav/in-app-ai-agent-button";+import { PageTabs } from "@/src/components/layouts/page-tabs";+import { type PageHeaderProps } from "@/src/components/layouts/page-header";+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "@/src/components/ui/tooltip";++/**+ * The page-specific block for the minimal-chrome mobile shell. Rendered between+ * the slim sticky chrome and the page content (not inside the sticky bar), so+ * the title reads as part of the page and scrolls with it. Holds the+ * org/project context switcher, the large page title, page actions, the hoisted+ * controls slot (time range / refresh), the agent launcher, and the section+ * tabs.+ *+ * Takes the same `headerProps` the desktop PageHeader gets, so any Page-style+ * wrapper renders it consistently. Controls + agent live here for now; they+ * migrate into the expandable bottom bar as that lands.+ */+export const MobilePageTitle = ({+ headerProps,+}: {+ headerProps: Omit<PageHeaderProps, "container">;+}) => {+ const {+ title,+ titleContent,+ titleTooltip,+ help,+ itemType,+ actionButtonsLeft,+ actionButtonsRight,+ titleBadges,+ breadcrumb,+ breadcrumbBadges,+ tabsProps,+ } = headerProps;++ return (+ <div className="bg-background border-b px-3 pt-2 pb-3">+ {/* Context line: org / project switcher plus any page-supplied+ breadcrumb items (detail pages rely on these for back-navigation). */}+ <div className="flex items-center gap-2">+ <BreadcrumbComponent items={breadcrumb} />+ {breadcrumbBadges}+ </div>++ <div className="mt-1.5 flex items-start justify-between gap-2">+ <div className="flex min-w-0 items-center gap-2">+ {itemType && <ItemBadge type={itemType} showLabel />}+ <h1 className="text-primary text-2xl leading-tight font-bold wrap-break-word">+ {titleContent ? (+ titleContent+ ) : titleTooltip ? (+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <span className="cursor-help">{title}</span>+ </TooltipTrigger>+ <TooltipContent side="bottom" className="max-w-xs">+ {titleTooltip}+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ ) : (+ <span title={title}>{title}</span>+ )}+ {help && (+ <span className="align-middle whitespace-nowrap">+ + <DocPopup+ description={help.description}+ href={help.href}+ className={help.className}+ />+ </span>+ )}+ </h1>+ {titleBadges && (+ <div className="flex items-center gap-1">{titleBadges}</div>+ )}+ </div>+ {actionButtonsRight && (+ <div className="flex shrink-0 items-center gap-1">+ {actionButtonsRight}+ </div>+ )}+ </div>++ {actionButtonsLeft && (+ <div className="mt-2 flex flex-wrap items-center gap-1">+ {actionButtonsLeft}+ </div>+ )}++ {/* Hoisted page controls (time range, auto-refresh) + agent launcher.+ Temporary home until the expandable bottom bar owns them. */}+ <div className="mt-2 flex flex-wrap items-center gap-2">+ <PageHeaderControlsSlotTarget />+ <InAppAiAgentButton />+ </div>++ {tabsProps && <PageTabs {...tabsProps} scrollable className="mt-2" />}+ </div>+ );+};diff --git a/web/src/components/layouts/mobile-top-bar.tsx b/web/src/components/layouts/mobile-top-bar.tsxnew file mode 100644index 0000000000..b645076412--- /dev/null+++ b/web/src/components/layouts/mobile-top-bar.tsx@@ -0,0 +1,62 @@+import { type ReactNode } from "react";+import { Menu } from "lucide-react";+import { Button } from "@/src/components/ui/button";+import { useSidebar } from "@/src/components/ui/sidebar";+import { TopbarBrand } from "@/src/components/nav/topbar-brand";+import { useHasAppSidebar } from "@/src/components/nav/sidebar-presence";+import { TopbarAccount } from "@/src/components/nav/topbar-account";+import { EnvLabel } from "@/src/components/EnvLabel";++/**+ * Slim mobile top chrome for the minimal-chrome shell: hamburger · centered+ * Langfuse wordmark · account. Everything page-specific (title, actions,+ * controls, tabs) lives below in the scrollable content (see MobilePageTitle),+ * so this stays a thin, sticky brand bar.+ *+ * Rendered only below `md` (the caller hides it on desktop, where PageHeader+ * takes over). On the sidebar-less MinimalLayout (public shares) there is no+ * hamburger to show — the page's own leadingControl takes the left slot.+ */+export const MobileTopBar = ({+ showSidebarTrigger = true,+ leadingControl,+}: {+ showSidebarTrigger?: boolean;+ leadingControl?: ReactNode;+}) => {+ const { toggleSidebar } = useSidebar();+ const hasAppSidebar = useHasAppSidebar();+ const showHamburger = showSidebarTrigger && hasAppSidebar;++ return (+ <div className="bg-background flex h-12 items-center gap-2 border-b px-2">+ {/* Left: hamburger (opens the nav sheet) or the page's leading control. */}+ <div className="flex min-w-0 flex-1 items-center gap-2">+ {showHamburger ? (+ <Button+ variant="ghost"+ size="icon"+ className="h-9 w-9"+ aria-label="Open menu"+ onClick={() => toggleSidebar()}+ >+ <Menu className="size-5" />+ </Button>+ ) : (+ leadingControl+ )}+ {/* EnvLabel defaults to self-stretch (to fill the desktop header row);+ keep it centered here so it doesn't span the full bar height. */}+ <EnvLabel className="self-center" />+ </div>++ {/* Center: the Langfuse wordmark. */}+ <TopbarBrand variant="wordmark" />++ {/* Right: account. Balances the left slot so the brand stays centered. */}+ <div className="flex min-w-0 flex-1 items-center justify-end">+ <TopbarAccount />+ </div>+ </div>+ );+};diff --git a/web/src/components/layouts/page-header.tsx b/web/src/components/layouts/page-header.tsxindex 7e23dd0849..6f239dc873 100644--- a/web/src/components/layouts/page-header.tsx+++ b/web/src/components/layouts/page-header.tsx@@ -13,31 +13,13 @@ import {TooltipProvider,TooltipTrigger,} from "@/src/components/ui/tooltip";+import {+ PageTabs,+ type PageTabsProps,+} from "@/src/components/layouts/page-tabs";import { cn } from "@/src/utils/tailwind";-import Link from "next/link";-import { useRouter } from "next/router";-import { type ParsedUrlQuery } from "querystring";import { type ReactNode } from "react";-type TabDefinition = {- value: string;- label: string;- href?: string;- onClick?: () => void;- querySelector?: (- query: ParsedUrlQuery,- ) => Record<string, string | string[] | undefined>;- disabled?: boolean;- className?: string;-};--type PageTabsProps = {- tabs: TabDefinition[];- activeTab: string;- className?: string;- listClassName?: string;-};-const containerLayoutClassName ="lg:mx-auto lg:w-full lg:max-w-screen-lg lg:px-8 xl:max-w-screen-xl 2xl:max-w-[1400px]";@@ -78,7 +60,6 @@ const PageHeader = ({titleBadges,breadcrumbBadges,}: PageHeaderProps) => {- const router = useRouter();const hasAppSidebar = useHasAppSidebar();// The sidebar trigger + brand mark only make sense where a real AppSidebar// exists to toggle/mirror. On the sidebar-less MinimalLayout (public/shared@@ -225,52 +206,10 @@ const PageHeader = ({</div>{tabsProps && (- <div className={cn("ml-2", tabsProps.className)}>- <div- className={cn(- "inline-flex h-8 items-center justify-start",- tabsProps.listClassName,- )}- >- {tabsProps.tabs.map((tab) => {- const tabClassName = cn(- "hover:bg-muted/50 focus-visible:ring-ring text-muted-foreground font-bold inline-flex h-full items-center justify-center rounded-none border-b-4 border-transparent px-2 py-0.5 text-sm whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden",- tab.value === tabsProps.activeTab- ? "border-primary-accent text-foreground bg-transparent shadow-none"- : "",- tab.disabled && "pointer-events-none opacity-50",- tab.className,- );-- if (tab.onClick) {- return (- <button- key={tab.value}- type="button"- onClick={tab.onClick}- className={tabClassName}- disabled={tab.disabled}- >- {tab.label}- </button>- );- }-- return (- <Link- key={tab.value}- href={{- pathname: tab.href ?? "",- query: tab.querySelector?.(router.query),- }}- className={tabClassName}- >- {tab.label}- </Link>- );- })}- </div>- </div>+ <PageTabs+ {...tabsProps}+ className={cn("ml-2", tabsProps.className)}+ />)}</div></div>diff --git a/web/src/components/layouts/page-tabs.tsx b/web/src/components/layouts/page-tabs.tsxnew file mode 100644index 0000000000..a64d3bb0a1--- /dev/null+++ b/web/src/components/layouts/page-tabs.tsx@@ -0,0 +1,87 @@+import { cn } from "@/src/utils/tailwind";+import Link from "next/link";+import { useRouter } from "next/router";+import { type ParsedUrlQuery } from "querystring";++export type TabDefinition = {+ value: string;+ label: string;+ href?: string;+ onClick?: () => void;+ querySelector?: (+ query: ParsedUrlQuery,+ ) => Record<string, string | string[] | undefined>;+ disabled?: boolean;+ className?: string;+};++export type PageTabsProps = {+ tabs: TabDefinition[];+ activeTab: string;+ className?: string;+ listClassName?: string;+ /** Horizontal scroll for narrow viewports (mobile). */+ scrollable?: boolean;+};++/**+ * The page-level tab strip (sub-navigation within a section). Extracted so both+ * the desktop page header and the mobile page-title block can render it.+ */+export const PageTabs = ({+ tabs,+ activeTab,+ className,+ listClassName,+ scrollable = false,+}: PageTabsProps) => {+ const router = useRouter();+ return (+ <div className={cn(scrollable && "-mx-1 overflow-x-auto px-1", className)}>+ <div+ className={cn(+ "inline-flex h-8 items-center justify-start",+ listClassName,+ )}+ >+ {tabs.map((tab) => {+ const tabClassName = cn(+ "hover:bg-muted/50 focus-visible:ring-ring text-muted-foreground font-bold inline-flex h-full items-center justify-center rounded-none border-b-4 border-transparent px-2 py-0.5 text-sm whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden",+ tab.value === activeTab+ ? "border-primary-accent text-foreground bg-transparent shadow-none"+ : "",+ tab.disabled && "pointer-events-none opacity-50",+ tab.className,+ );++ if (tab.onClick) {+ return (+ <button+ key={tab.value}+ type="button"+ onClick={tab.onClick}+ className={tabClassName}+ disabled={tab.disabled}+ >+ {tab.label}+ </button>+ );+ }++ return (+ <Link+ key={tab.value}+ href={{+ pathname: tab.href ?? "",+ query: tab.querySelector?.(router.query),+ }}+ className={tabClassName}+ >+ {tab.label}+ </Link>+ );+ })}+ </div>+ </div>+ );+};diff --git a/web/src/components/layouts/page.tsx b/web/src/components/layouts/page.tsxindex 4d1713f0df..b0302de590 100644--- a/web/src/components/layouts/page.tsx+++ b/web/src/components/layouts/page.tsx@@ -2,6 +2,9 @@ import PageHeader, {type PageHeaderProps,} from "@/src/components/layouts/page-header";import { PageHeaderControlsSlotProvider } from "@/src/components/layouts/page-header-controls-slot";+import { MobileTopBar } from "@/src/components/layouts/mobile-top-bar";+import { MobilePageTitle } from "@/src/components/layouts/mobile-page-title";+import { useIsMobile } from "@/src/hooks/use-mobile";import { cn } from "@/src/utils/tailwind";type PageContainerProps = {@@ -17,6 +20,13 @@ const Page = ({scrollable = false,withPadding = false,}: PageContainerProps) => {+ // Minimal-chrome mobile shell: a slim sticky top bar (menu + brand + account)+ // plus a page-title block that lives in the scrollable content. We mount one+ // header path (rather than CSS-toggle both) so there is a single+ // controls-slot target for the time-range / refresh portal — two live targets+ // would fight over the single slot node.+ const isMobile = useIsMobile();+return (<PageHeaderControlsSlotProvider><div@@ -29,8 +39,16 @@ const Page = ({id="page"><header className="sticky top-0 z-50 w-full">- <PageHeader {...headerProps} container={false} className="top-0" />+ {isMobile ? (+ <MobileTopBar+ showSidebarTrigger={headerProps.showSidebarTrigger}+ leadingControl={headerProps.leadingControl}+ />+ ) : (+ <PageHeader {...headerProps} container={false} className="top-0" />+ )}</header>+ {isMobile && <MobilePageTitle headerProps={headerProps} />}<mainclassName={cn("flex flex-1 flex-col",diff --git a/web/src/components/nav/topbar-account.tsx b/web/src/components/nav/topbar-account.tsxnew file mode 100644index 0000000000..a2318b5a08--- /dev/null+++ b/web/src/components/nav/topbar-account.tsx@@ -0,0 +1,93 @@+"use client";++import Link from "next/link";+import { useSession } from "next-auth/react";+import { signOutCleanly } from "@/src/features/auth/lib/signOut";+import {+ Avatar,+ AvatarFallback,+ AvatarImage,+} from "@/src/components/ui/avatar";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuLabel,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+} from "@/src/components/ui/dropdown-menu";+import { ThemeToggle } from "@/src/features/theming/ThemeToggle";+import { cn } from "@/src/utils/tailwind";++/**+ * Compact account affordance for the mobile top bar: the user's avatar opening+ * a small menu (settings, theme, sign out). The sidebar keeps the full NavUser;+ * this is the always-visible shell-level shortcut in the minimal mobile chrome.+ */+export const TopbarAccount = ({ className }: { className?: string }) => {+ const session = useSession();+ const user = session.data?.user;++ if (!user) return null;++ const name = user.name ?? "";+ const email = user.email ?? "";+ const initials =+ name+ .split(" ")+ .slice(0, 2)+ .map((word) => word[0])+ .join("")+ .toUpperCase() ||+ email[0]?.toUpperCase() ||+ "?";++ return (+ <DropdownMenu>+ <DropdownMenuTrigger+ className={cn(+ "focus-visible:ring-ring rounded-full focus-visible:ring-2 focus-visible:outline-hidden",+ className,+ )}+ aria-label="Account menu"+ >+ <Avatar className="h-8 w-8">+ <AvatarImage src={user.image ?? undefined} alt={name} />+ <AvatarFallback className="text-xs">{initials}</AvatarFallback>+ </Avatar>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" sideOffset={4} className="min-w-56">+ <DropdownMenuLabel className="font-normal">+ <div className="grid text-left text-sm leading-tight">+ <span className="truncate font-bold" title={name}>+ {name}+ </span>+ <span+ className="text-muted-foreground truncate text-xs"+ title={email}+ >+ {email}+ </span>+ </div>+ </DropdownMenuLabel>+ <DropdownMenuSeparator />+ <DropdownMenuItem asChild>+ <Link href="/account/settings">Account settings</Link>+ </DropdownMenuItem>+ {/* ThemeToggle stops propagation itself; keep the row from closing the+ menu so the user can flip themes and keep the menu open. */}+ <DropdownMenuItem onSelect={(e) => e.preventDefault()}>+ <ThemeToggle />+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ <DropdownMenuItem+ onClick={() => {+ signOutCleanly().catch(() => {});+ }}+ >+ Sign out+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ );+};diff --git a/web/src/components/nav/topbar-brand.tsx b/web/src/components/nav/topbar-brand.tsxindex a13afe3ba7..cc08df276b 100644--- a/web/src/components/nav/topbar-brand.tsx+++ b/web/src/components/nav/topbar-brand.tsx@@ -1,5 +1,6 @@import { cn } from "@/src/utils/tailwind";import Link from "next/link";+import { env } from "@/src/env.mjs";import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";import { PlusIcon } from "lucide-react";import { LangfuseIcon } from "@/src/components/design-system/LangfuseIcon/LangfuseIcon";@@ -13,18 +14,28 @@ import { useHasAppSidebar } from "@/src/components/nav/sidebar-presence";* app, so the page header renders this compact mark instead — mirroring the* icon the sidebar itself shows when collapsed.*+ * `variant="icon"` (default) renders just the Langfuse mark; `variant="wordmark"`+ * renders the full logotype, for the centered brand in the mobile top bar.+ ** Respects the self-host UI-customization logo entitlement, same as* `LangfuseLogo`, and links to `/` like the sidebar logo.*/-export const TopbarBrand = ({ className }: { className?: string }) => {+export const TopbarBrand = ({+ className,+ variant = "icon",+}: {+ className?: string;+ variant?: "icon" | "wordmark";+}) => {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.+ // Only brand where a real sidebar exists to mirror. On the sidebar-less+ // MinimalLayout (public/shared trace & session views) the page supplies its+ // own "Sign in / Back to Langfuse" leadingControl, so an extra brand mark+ // here would be redundant.if (!hasAppSidebar) return null;return (@@ -52,6 +63,21 @@ export const TopbarBrand = ({ className }: { className?: string }) => {<PlusIcon size={8} className="text-muted-foreground" /><LangfuseIcon size={16} /></>+ ) : variant === "wordmark" ? (+ <>+ {/* eslint-disable-next-line @next/next/no-img-element */}+ <img+ className="max-h-5 max-w-24 dark:hidden"+ src={`${env.NEXT_PUBLIC_BASE_PATH ?? ""}/wordart-black.svg`}+ alt="Langfuse Logo"+ />+ {/* eslint-disable-next-line @next/next/no-img-element */}+ <img+ className="hidden max-h-5 max-w-24 dark:block"+ src={`${env.NEXT_PUBLIC_BASE_PATH ?? ""}/wordart-white.svg`}+ alt="Langfuse Logo"+ />+ </>) : (<LangfuseIcon size={28} />)}diff --git a/web/src/features/auth/lib/signOut.ts b/web/src/features/auth/lib/signOut.tsnew file mode 100644index 0000000000..36c61bc358--- /dev/null+++ b/web/src/features/auth/lib/signOut.ts@@ -0,0 +1,23 @@+import { signOut } from "next-auth/react";+import posthog from "posthog-js";+import { env } from "@/src/env.mjs";++/**+ * Canonical client-side sign-out.+ *+ * Clears session-scoped storage and resets the PostHog identity (so+ * post-logout analytics aren't attributed to the previous user on shared+ * devices), then signs out to the base-path-aware sign-in route.+ *+ * Used by every sign-out entry point — the sidebar NavUser (via AppLayout) and+ * the mobile TopbarAccount — so cleanup stays in one place.+ */+export const signOutCleanly = async () => {+ sessionStorage.clear();+ if (env.NEXT_PUBLIC_POSTHOG_KEY && env.NEXT_PUBLIC_POSTHOG_HOST) {+ posthog.reset();+ }+ await signOut({+ callbackUrl: `${env.NEXT_PUBLIC_BASE_PATH ?? ""}/auth/sign-in`,+ });+};