Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

refactor(web): Fix `@repo/no-null-render` suppressions (#17354)

Ben Bachem99ecfca16d72
diff --git a/web/src/components/BatchExportTableButton.tsx b/web/src/components/BatchExportTableButton.tsx
index b1c8c80f27..99a7d2fb92 100644
--- a/web/src/components/BatchExportTableButton.tsx
+++ b/web/src/components/BatchExportTableButton.tsx
@@ -1,4 +1,4 @@
-/* eslint-disable @repo/no-abstracted-overlay-trigger, @repo/no-null-render */
+/* eslint-disable @repo/no-abstracted-overlay-trigger */
import {
DropdownMenu,
DropdownMenuContent,
@@ -21,7 +21,6 @@ import {
import React from "react";
import { api } from "@/src/utils/api";
import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";
-import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
export type BatchExportTableButtonProps = {
projectId: string;
@@ -52,11 +51,6 @@ export const BatchExportTableButton: React.FC<BatchExportTableButtonProps> = (
});
},
});
- const hasAccess = useHasProjectAccess({
- projectId: props.projectId,
- scope: "batchExports:create",
- });
-
const handleExport = async (format: BatchExportFileFormat) => {
setIsExporting(true);
await createExport.mutateAsync({
@@ -73,8 +67,6 @@ export const BatchExportTableButton: React.FC<BatchExportTableButtonProps> = (
});
};
- if (!hasAccess) return null;
-
const getWarningMessage = () => {
switch (props.tableName) {
case BatchTableNames.Traces:
diff --git a/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx b/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx
index 38e770ee6d..043f0b060b 100644
--- a/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx
+++ b/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx
@@ -21,7 +21,6 @@ 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";
-import { TopBannerProvider } from "@/src/features/top-banner";
import {
VersionUpdateBanner,
useVersionUpdatePrompt,
@@ -53,6 +52,11 @@ import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePos
import { useSession } from "next-auth/react";
import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";
import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";
+import {
+ PaymentBannerView,
+ usePaymentBanner,
+} from "@/src/features/payment-banner";
+import { useTopBannerHeight } from "@/src/features/top-banner";
const DISMISSED_SIDEBAR_NOTIFICATIONS_KEY = "dismissed-sidebar-notifications";
@@ -66,16 +70,6 @@ const CommandMenu = dynamic(
},
);
-const PaymentBanner = dynamic(
- () =>
- import("@/src/features/payment-banner").then((mod) => ({
- default: mod.PaymentBanner,
- })),
- {
- ssr: false,
- },
-);
-
const PreviewDeploymentBanner = dynamic(
() =>
import("@/src/features/preview-deployment-banner").then((mod) => ({
@@ -131,6 +125,8 @@ export function AuthenticatedLayout({
useProjectCookie(router);
const uiCustomization = useUiCustomization();
const versionUpdatePrompt = useVersionUpdatePrompt();
+ const paymentBanner = usePaymentBanner();
+ const topBannerRef = useTopBannerHeight();
// Account-level entry: use the raw flag (same as account settings tabs), not
// project-scoped force-v3 suppression.
const showV4Migration = useV4UpgradeUiFlag();
@@ -257,70 +253,79 @@ export function AuthenticatedLayout({
<link rel="apple-touch-icon" href={metadata.appleTouchIconPath} />
</Head>
- <TopBannerProvider>
- <SidebarPresenceProvider>
- <SidebarProvider>
- <div className="flex h-dvh w-full flex-col">
- <PaymentBanner />
+ <SidebarPresenceProvider>
+ <SidebarProvider>
+ <div className="flex h-dvh w-full flex-col">
+ <div
+ ref={topBannerRef}
+ className="fixed top-0 z-51 flex w-full flex-col"
+ >
+ {paymentBanner && (
+ <PaymentBannerView
+ organizationName={paymentBanner.organizationName}
+ billingSettingsHref={paymentBanner.billingSettingsHref}
+ severity={paymentBanner.severity}
+ />
+ )}
{env.NEXT_PUBLIC_PREVIEW_PR_URL && (
<PreviewDeploymentBanner
prUrl={env.NEXT_PUBLIC_PREVIEW_PR_URL}
/>
)}
- {versionUpdatePrompt.isVisible && (
- <VersionUpdateBanner
- onReload={versionUpdatePrompt.reload}
- onDismiss={versionUpdatePrompt.dismiss}
- />
- )}
- <div className="pt-banner-offset flex min-h-0 flex-1">
- <ConnectedAppSidebar
- navItems={navigation.mainNavigation}
- secondaryNavItems={navigation.secondaryNavigation}
- user={sidebarUser}
- userMenuItems={userMenuItems}
- isLangfuseCloud={isLangfuseCloud}
- routerProjectId={
- typeof router.query.projectId === "string"
- ? router.query.projectId
- : undefined
- }
- />
- {/* `min-w-0`, not a `100vw`-derived width: viewport units ignore
+ </div>
+ {versionUpdatePrompt.isVisible && (
+ <VersionUpdateBanner
+ onReload={versionUpdatePrompt.reload}
+ onDismiss={versionUpdatePrompt.dismiss}
+ />
+ )}
+ <div className="pt-banner-offset flex min-h-0 flex-1">
+ <ConnectedAppSidebar
+ navItems={navigation.mainNavigation}
+ secondaryNavItems={navigation.secondaryNavigation}
+ user={sidebarUser}
+ userMenuItems={userMenuItems}
+ isLangfuseCloud={isLangfuseCloud}
+ routerProjectId={
+ typeof router.query.projectId === "string"
+ ? router.query.projectId
+ : undefined
+ }
+ />
+ {/* `min-w-0`, not a `100vw`-derived width: viewport units ignore
scrollbars, and a definite width also floors `min-width:
auto`, so on a wide page the inset stayed pinned 15px past
the space beside the sidebar once a space-taking vertical
scrollbar showed — spawning a horizontal one. Flex already
sizes the inset to that space. */}
- <SidebarInset className="h-screen-with-banner max-w-full min-w-0">
- <AppContentWithRightDrawer>
- {children}
- </AppContentWithRightDrawer>
- {/* Toasts render in the `toast` overlay layer — the last layer
+ <SidebarInset className="h-screen-with-banner max-w-full min-w-0">
+ <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
+ <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}
+ <InAppAgentWindowHost />
+ </SidebarInset>
</div>
- </SidebarProvider>
- </SidebarPresenceProvider>
- </TopBannerProvider>
+ {hasFeaturePreviews ? (
+ <ControlledFeaturePreviewModal
+ open={featurePreviewOpen}
+ onOpenChange={setFeaturePreviewOpen}
+ />
+ ) : null}
+ </div>
+ </SidebarProvider>
+ </SidebarPresenceProvider>
</>
);
}
diff --git a/web/src/components/layouts/app-shell-chrome.clienttest.tsx b/web/src/components/layouts/app-shell-chrome.clienttest.tsx
index f5be75f01d..87d5acd837 100644
--- a/web/src/components/layouts/app-shell-chrome.clienttest.tsx
+++ b/web/src/components/layouts/app-shell-chrome.clienttest.tsx
@@ -48,6 +48,10 @@ vi.mock("@/src/components/nav/in-app-ai-agent-button", () => ({
InAppAiAgentButton: () => null,
}));
+vi.mock("@/src/features/in-app-agent/components/InAppAiAgentProvider", () => ({
+ useIsInAppAgentLauncherVisible: () => true,
+}));
+
vi.mock("@/src/components/nav/topbar-brand", () => ({
TopbarBrand: () => null,
}));
diff --git a/web/src/components/layouts/mobile-top-bar.tsx b/web/src/components/layouts/mobile-top-bar.tsx
index a8a0576336..a86ad5408c 100644
--- a/web/src/components/layouts/mobile-top-bar.tsx
+++ b/web/src/components/layouts/mobile-top-bar.tsx
@@ -1,4 +1,5 @@
import { type ReactNode } from "react";
+import { useSession } from "next-auth/react";
import { Menu } from "lucide-react";
import { Button } from "@/src/components/ui/button";
import { useSidebar } from "@/src/components/ui/sidebar";
@@ -8,6 +9,7 @@ import { TopbarAccount } from "@/src/components/nav/topbar-account";
import { InAppAiAgentButton } from "@/src/components/nav/in-app-ai-agent-button";
import { EnvLabelBadge } from "@/src/components/EnvLabelBadge";
import { useEnvLabel } from "@/src/hooks/useEnvLabel";
+import { useIsInAppAgentLauncherVisible } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";
/**
* Slim mobile top chrome for the minimal-chrome shell: hamburger · centered
@@ -27,8 +29,10 @@ export const MobileTopBar = ({
leadingControl?: ReactNode;
}) => {
const { toggleSidebar } = useSidebar();
+ const session = useSession();
const hasAppSidebar = useHasAppSidebar();
const envLabel = useEnvLabel();
+ const isInAppAgentLauncherVisible = useIsInAppAgentLauncherVisible();
const showHamburger = showSidebarTrigger && hasAppSidebar;
return (
@@ -54,14 +58,14 @@ export const MobileTopBar = ({
</div>
{/* Center: the Langfuse wordmark. */}
- <TopbarBrand variant="wordmark" />
+ {hasAppSidebar && <TopbarBrand variant="wordmark" />}
{/* Right: the assistant launcher (prominent, gradient-bordered so it
reads as a real entry point here) + account. Balances the left slot
so the brand stays centered. */}
<div className="flex min-w-0 flex-1 items-center justify-end gap-1">
- <InAppAiAgentButton prominent />
- <TopbarAccount />
+ {isInAppAgentLauncherVisible && <InAppAiAgentButton prominent />}
+ {session.data?.user && <TopbarAccount user={session.data.user} />}
</div>
</div>
);
diff --git a/web/src/components/layouts/page-header.tsx b/web/src/components/layouts/page-header.tsx
index fa4921423d..7cbe67aeed 100644
--- a/web/src/components/layouts/page-header.tsx
+++ b/web/src/components/layouts/page-header.tsx
@@ -7,6 +7,7 @@ import { PageHeaderControlsSlotTarget } from "@/src/components/layouts/page-head
import { InAppAiAgentButton } from "@/src/components/nav/in-app-ai-agent-button";
import { TopbarBrand } from "@/src/components/nav/topbar-brand";
import { useHasAppSidebar } from "@/src/components/nav/sidebar-presence";
+import { useIsInAppAgentLauncherVisible } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";
import DocPopup from "@/src/components/layouts/doc-popup";
import { SidebarTrigger } from "@/src/components/ui/sidebar";
import {
@@ -77,6 +78,7 @@ const PageHeader = ({
}: PageHeaderProps) => {
const hasAppSidebar = useHasAppSidebar();
const envLabel = useEnvLabel();
+ const isInAppAgentLauncherVisible = useIsInAppAgentLauncherVisible();
// The sidebar trigger + brand mark only make sense where a real AppSidebar
// exists to toggle/mirror. On the sidebar-less MinimalLayout (public/shared
// trace and session views) show the page's own leadingControl instead — no
@@ -145,7 +147,7 @@ const PageHeader = ({
Empty on pages that don't use it. */}
<div className="flex flex-wrap items-center gap-2">
<PageHeaderControlsSlotTarget />
- <InAppAiAgentButton />
+ {isInAppAgentLauncherVisible && <InAppAiAgentButton />}
</div>
</div>
</div>
diff --git a/web/src/components/nav/in-app-ai-agent-button.clienttest.tsx b/web/src/components/nav/in-app-ai-agent-button.clienttest.tsx
index 2c75d6b7da..98052e1470 100644
--- a/web/src/components/nav/in-app-ai-agent-button.clienttest.tsx
+++ b/web/src/components/nav/in-app-ai-agent-button.clienttest.tsx
@@ -10,7 +10,6 @@ const mocks = vi.hoisted(() => ({
}));
vi.mock("@/src/features/in-app-agent/components/InAppAiAgentProvider", () => ({
- useIsInAppAgentLauncherVisible: () => true,
useInAppAiAgent: () => ({
open: mocks.open,
attentionCount: mocks.attentionCount,
diff --git a/web/src/components/nav/in-app-ai-agent-button.tsx b/web/src/components/nav/in-app-ai-agent-button.tsx
index 9ebfa9dd98..2bf81af70f 100644
--- a/web/src/components/nav/in-app-ai-agent-button.tsx
+++ b/web/src/components/nav/in-app-ai-agent-button.tsx
@@ -1,11 +1,9 @@
-/* eslint-disable @repo/no-null-render */
import { useCallback, useEffect } from "react";
import { BotMessageSquare } from "lucide-react";
import { Button } from "@/src/components/ui/button";
import { KeyboardShortcut } from "@/src/components/design-system/KeyboardShortcut/KeyboardShortcut";
import {
- useIsInAppAgentLauncherVisible,
useInAppAiAgent,
type InAppAgentEntryPoint,
} from "@/src/features/in-app-agent/components/InAppAiAgentProvider";
@@ -25,7 +23,6 @@ export const InAppAiAgentButton = ({
prominent?: boolean;
} = {}) => {
const { open, setOpen, openAssistant, attentionCount } = useInAppAiAgent();
- const isInAppAgentLauncherVisible = useIsInAppAgentLauncherVisible();
const toggleAssistant = useCallback(
(source: InAppAgentEntryPoint) => {
@@ -40,10 +37,6 @@ export const InAppAiAgentButton = ({
);
useEffect(() => {
- if (!isInAppAgentLauncherVisible) {
- return;
- }
-
const handleKeyDown = (event: KeyboardEvent) => {
if (
event.repeat ||
@@ -61,11 +54,7 @@ export const InAppAiAgentButton = ({
document.addEventListener("keydown", handleKeyDown);
return () => document.removeEventListener("keydown", handleKeyDown);
- }, [isInAppAgentLauncherVisible, toggleAssistant]);
-
- if (!isInAppAgentLauncherVisible) {
- return null;
- }
+ }, [toggleAssistant]);
const attentionSuffix =
attentionCount > 0
diff --git a/web/src/components/nav/topbar-account.tsx b/web/src/components/nav/topbar-account.tsx
index 6a9f10b7cd..07c8e4311e 100644
--- a/web/src/components/nav/topbar-account.tsx
+++ b/web/src/components/nav/topbar-account.tsx
@@ -1,8 +1,8 @@
-/* eslint-disable @repo/no-style-props, @repo/no-abstracted-overlay-trigger, @repo/no-null-render */
+/* eslint-disable @repo/no-style-props, @repo/no-abstracted-overlay-trigger */
"use client";
import Link from "next/link";
-import { useSession } from "next-auth/react";
+import type { Session } from "next-auth";
import { signOutCleanly } from "@/src/features/auth/lib/signOut";
import { Avatar } from "@/src/components/design-system/Avatar/Avatar";
import {
@@ -22,12 +22,14 @@ import { cn } from "@/src/utils/tailwind";
* 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();
+export const TopbarAccount = ({
+ user,
+ className,
+}: {
+ user: NonNullable<Session["user"]>;
+ className?: string;
+}) => {
const showV4Migration = useV4UpgradeUiFlag();
- const user = session.data?.user;
-
- if (!user) return null;
const name = user.name ?? "";
const email = user.email ?? "";
diff --git a/web/src/components/nav/topbar-brand.tsx b/web/src/components/nav/topbar-brand.tsx
index ba2830e6fe..03a365e183 100644
--- a/web/src/components/nav/topbar-brand.tsx
+++ b/web/src/components/nav/topbar-brand.tsx
@@ -1,11 +1,10 @@
-/* eslint-disable @repo/no-style-props, @repo/no-null-render */
+/* eslint-disable @repo/no-style-props */
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";
-import { useHasAppSidebar } from "@/src/components/nav/sidebar-presence";
/**
* Compact Langfuse brand mark for the top bar.
@@ -28,17 +27,10 @@ export const TopbarBrand = ({
className?: string;
variant?: "icon" | "wordmark";
}) => {
- const hasAppSidebar = useHasAppSidebar();
const uiCustomization = useUiCustomization();
const logoLight = uiCustomization?.logoLightModeHref;
const logoDark = uiCustomization?.logoDarkModeHref;
- // 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 (
<Link
href="/"
diff --git a/web/src/components/table/filtered-run-pills.tsx b/web/src/components/table/filtered-run-pills.tsx
index 0f9ee49b1e..0b6b3242d7 100644
--- a/web/src/components/table/filtered-run-pills.tsx
+++ b/web/src/components/table/filtered-run-pills.tsx
@@ -1,4 +1,4 @@
-/* eslint-disable @repo/no-style-props, @repo/no-null-render */
+/* eslint-disable @repo/no-style-props */
import { Badge } from "@/src/components/ui/badge";
import {
HoverCard,
@@ -84,10 +84,6 @@ export function FilteredRunPills({
})),
);
- if (allFilters.length === 0) {
- return null;
- }
-
return (
<div className={`flex flex-wrap items-center gap-1 ${className ?? ""}`}>
{allFilters.map((item) => {
diff --git a/web/src/components/table/peek/peek-evaluator-config-detail.tsx b/web/src/components/table/peek/peek-evaluator-config-detail.tsx
index a4da02a825..0eab82d86b 100644
--- a/web/src/components/table/peek/peek-evaluator-config-detail.tsx
+++ b/web/src/components/table/peek/peek-evaluator-config-detail.tsx
@@ -2,7 +2,10 @@ import { useRouter } from "next/router";
import { Skeleton } from "@/src/components/ui/skeleton";
import { TextLink } from "@/src/components/design-system/TextLink/TextLink";
import { CardDescription } from "@/src/components/ui/card";
-import { EvaluatorForm } from "@/src/features/evals/components/evaluator-form";
+import {
+ EvaluatorForm,
+ useEvaluatorFormTemplate,
+} from "@/src/features/evals/components/evaluator-form";
import { usePeekEvalConfigData } from "@/src/components/table/peek/hooks/usePeekEvalConfigData";
import {
Tooltip,
@@ -46,6 +49,10 @@ const PeekViewEvaluatorConfigDetail = ({
jobConfigurationId: peekId,
projectId,
});
+ const evalTemplate = useEvaluatorFormTemplate({
+ evalTemplates: [],
+ evalTemplate: evalConfig?.evalTemplate ?? undefined,
+ });
const lazyExecutionCounts = useLazyEvaluatorExecutionCounts({
projectId,
evaluatorId: evalConfig?.id,
@@ -184,27 +191,29 @@ const PeekViewEvaluatorConfigDetail = ({
</CardDescription>
<div className="flex max-h-full w-full flex-col items-start justify-between space-y-2 overflow-y-auto pb-4">
{evalConfig.evalTemplate ? (
- <EvaluatorForm
- key={`${evalConfig.id}-${evalConfig.updatedAt}-${isEditMode}`}
- projectId={projectId}
- evalTemplates={[evalConfig.evalTemplate]}
- existingEvaluator={{
- ...evalConfig,
- evalTemplate: evalConfig.evalTemplate,
- }}
- mode="edit"
- disabled={!isEditMode}
- shouldWrapVariables={true}
- useDialog={false}
- onFormSuccess={() => {
- setIsEditMode(false);
- utils.evals.invalidate();
- showSuccessToast({
- title: "Running Evaluator updated",
- description: "The evaluator configuration has been updated.",
- });
- }}
- />
+ evalTemplate ? (
+ <EvaluatorForm
+ key={`${evalConfig.id}-${evalConfig.updatedAt}-${isEditMode}`}
+ projectId={projectId}
+ evalTemplate={evalTemplate}
+ existingEvaluator={{
+ ...evalConfig,
+ evalTemplate: evalConfig.evalTemplate,
+ }}
+ mode="edit"
+ disabled={!isEditMode}
+ shouldWrapVariables={true}
+ useDialog={false}
+ onFormSuccess={() => {
+ setIsEditMode(false);
+ utils.evals.invalidate();
+ showSuccessToast({
+ title: "Running Evaluator updated",
+ description: "The evaluator configuration has been updated.",
+ });
+ }}
+ />
+ ) : null
) : (
<Alert icon={AlertTriangle}>
<Alert.Title>Referenced evaluator unavailable</Alert.Title>
diff --git a/web/src/components/table/use-cases/observations.tsx b/web/src/components/table/use-cases/observations.tsx
index c80ca70cfc..9cfbb1dbe5 100644
--- a/web/src/components/table/use-cases/observations.tsx
+++ b/web/src/components/table/use-cases/observations.tsx
@@ -68,6 +68,7 @@ import {
import { TableHeaderControls } from "@/src/components/table/table-header-controls";
import useColumnOrder from "@/src/features/column-visibility/hooks/useColumnOrder";
import { BatchExportTableButton } from "@/src/components/BatchExportTableButton";
+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import {
BreakdownTooltip,
calculateAggregatedUsage,
@@ -1532,6 +1533,10 @@ function ObservationsDataTableToolbar({
totalCount,
...toolbarProps
}: ObservationsDataTableToolbarProps) {
+ const hasBatchExportAccess = useHasProjectAccess({
+ projectId,
+ scope: "batchExports:create",
+ });
const selectedObservationIds = useObservationsTableStore(
(state) => state.selectedPageRowIds,
);
@@ -1547,17 +1552,19 @@ function ObservationsDataTableToolbar({
{...toolbarProps}
orderByState={orderByState}
actionButtons={[
- <BatchExportTableButton
- {...{
- projectId,
- filterState: backendFilterState,
- orderByState,
- searchQuery,
- searchType,
- }}
- tableName={BatchExportTableName.Observations}
- key="batchExport"
- />,
+ hasBatchExportAccess ? (
+ <BatchExportTableButton
+ {...{
+ projectId,
+ filterState: backendFilterState,
+ orderByState,
+ searchQuery,
+ searchType,
+ }}
+ tableName={BatchExportTableName.Observations}
+ key="batchExport"
+ />
+ ) : null,
selectedObservationIds.length > 0 || selectAll ? (
<TableActionMenu
key="observations-multi-select-actions"
diff --git a/web/src/components/table/use-cases/scores.tsx b/web/src/components/table/use-cases/scores.tsx
index 444c807215..7d10e820bd 100644
--- a/web/src/components/table/use-cases/scores.tsx
+++ b/web/src/components/table/use-cases/scores.tsx
@@ -63,6 +63,7 @@ import React, { useState, useRef, useCallback, useMemo } from "react";
import type { TableAction } from "@/src/features/table/types";
import type { RowSelectionState } from "@tanstack/react-table";
import { useHasEntitlement } from "@/src/features/entitlements/hooks";
+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import { useSelectAll } from "@/src/features/table/hooks/useSelectAll";
import { TableSelectionManager } from "@/src/features/table/components/TableSelectionManager";
import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";
@@ -165,6 +166,10 @@ export default function ScoresTable({
showAllEnvironments = false,
}: ScoresTableProps) {
const peekContext = usePeekTableState();
+ const hasBatchExportAccess = useHasProjectAccess({
+ projectId,
+ scope: "batchExports:create",
+ });
const scoresFilterConfig = useMemo(
() => getScoreFilterConfig(hiddenColumns),
@@ -1154,11 +1159,17 @@ export default function ScoresTable({
}}
/>
) : null,
- <BatchExportTableButton
- {...{ projectId, filterState: backendFilterState, orderByState }}
- tableName={BatchExportTableName.Scores}
- key="batchExport"
- />,
+ hasBatchExportAccess ? (
+ <BatchExportTableButton
+ {...{
+ projectId,
+ filterState: backendFilterState,
+ orderByState,
+ }}
+ tableName={BatchExportTableName.Scores}
+ key="batchExport"
+ />
+ ) : null,
]}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
diff --git a/web/src/components/table/use-cases/traces.tsx b/web/src/components/table/use-cases/traces.tsx
index c8a92d65ab..10e3c76d8e 100644
--- a/web/src/components/table/use-cases/traces.tsx
+++ b/web/src/components/table/use-cases/traces.tsx
@@ -187,6 +187,10 @@ function TracesTableInternal({
projectId,
scope: "traces:delete",
});
+ const hasBatchExportAccess = useHasProjectAccess({
+ projectId,
+ scope: "batchExports:create",
+ });
const tracesFilterConfig = useMemo(
() => getTraceFilterConfig(omittedFilter),
[omittedFilter],
@@ -1458,17 +1462,19 @@ function TracesTableInternal({
)}
</AddTracesToAnnotationQueueDialogController>
) : null,
- <BatchExportTableButton
- {...{
- projectId,
- filterState,
- orderByState,
- searchQuery,
- searchType,
- }}
- tableName={BatchExportTableName.Traces}
- key="batchExport"
- />,
+ hasBatchExportAccess ? (
+ <BatchExportTableButton
+ {...{
+ projectId,
+ filterState,
+ orderByState,
+ searchQuery,
+ searchType,
+ }}
+ tableName={BatchExportTableName.Traces}
+ key="batchExport"
+ />
+ ) : null,
]}
orderByState={orderByState}
columnVisibility={columnVisibility}
diff --git a/web/src/components/ui/calendar.tsx b/web/src/components/ui/calendar.tsx
index 709ef32cb3..f3ae01d952 100644
--- a/web/src/components/ui/calendar.tsx
+++ b/web/src/components/ui/calendar.tsx
@@ -1,4 +1,4 @@
-/* eslint-disable @repo/no-style-props, @repo/no-null-render */
+/* eslint-disable @repo/no-style-props */
"use client";
import * as React from "react";
@@ -77,19 +77,20 @@ function Calendar({
}
Calendar.displayName = "Calendar";
-const Chevron = ({ orientation = "left" }) => {
- switch (orientation) {
- case "left":
- return <ChevronLeft className="h-4 w-4" />;
- case "right":
- return <ChevronRight className="h-4 w-4" />;
- case "up":
- return <ChevronUp className="h-4 w-4" />;
- case "down":
- return <ChevronDown className="h-4 w-4" />;
- default:
- return null;
- }
+const chevronIcons = {
+ left: ChevronLeft,
+ right: ChevronRight,
+ up: ChevronUp,
+ down: ChevronDown,
+};
+
+const Chevron = ({
+ orientation = "left",
+}: {
+ orientation?: keyof typeof chevronIcons;
+}) => {
+ const Icon = chevronIcons[orientation];
+ return <Icon className="h-4 w-4" />;
};
export { Calendar };
diff --git a/web/src/ee/features/audit-log-viewer/AuditLogsTable.tsx b/web/src/ee/features/audit-log-viewer/AuditLogsTable.tsx
index 8648592aac..f5d221ca99 100644
--- a/web/src/ee/features/audit-log-viewer/AuditLogsTable.tsx
+++ b/web/src/ee/features/audit-log-viewer/AuditLogsTable.tsx
@@ -12,6 +12,7 @@ import { SettingsTableCard } from "@/src/components/layouts/settings-table-card"
import { BatchExportTableButton } from "@/src/components/BatchExportTableButton";
import { BatchExportTableName } from "@langfuse/shared";
import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";
+import { useHasProjectAccess } from "@/src/features/rbac";
// Both endpoints return the same shape
type AuditLogRow = RouterOutputs["auditLogs"]["all"]["data"][number];
@@ -21,6 +22,10 @@ type AuditLogsTableProps =
| { scope: "organization"; orgId: string };
export function AuditLogsTable(props: AuditLogsTableProps) {
+ const hasBatchExportAccess = useHasProjectAccess({
+ projectId: props.scope === "project" ? props.projectId : undefined,
+ scope: "batchExports:create",
+ });
const [paginationState, setPaginationState] = useQueryParams({
pageIndex: withDefault(NumberParam, 0),
pageSize: withDefault(NumberParam, 50),
@@ -136,7 +141,7 @@ export function AuditLogsTable(props: AuditLogsTableProps) {
rowHeight={rowHeight}
setRowHeight={setRowHeight}
actionButtons={
- props.scope === "project"
+ props.scope === "project" && hasBatchExportAccess
? [
<BatchExportTableButton
key="audit-logs-export"
diff --git a/web/src/ee/features/billing/components/BillingDiscountCodeButton.tsx b/web/src/ee/features/billing/components/BillingDiscountCodeButton.tsx
index d7265a5dd9..24fe738082 100644
--- a/web/src/ee/features/billing/components/BillingDiscountCodeButton.tsx
+++ b/web/src/ee/features/billing/components/BillingDiscountCodeButton.tsx
@@ -1,4 +1,4 @@
-/* eslint-disable @repo/no-abstracted-overlay-trigger, @repo/no-null-render */
+/* eslint-disable @repo/no-abstracted-overlay-trigger */
import { useState } from "react";
import { Button } from "@/src/components/ui/button";
import {
@@ -16,11 +16,7 @@ import { api } from "@/src/utils/api";
import { toast } from "sonner";
import { nanoid } from "nanoid";
-export const BillingDiscountCodeButton = ({
- orgId,
-}: {
- orgId: string | undefined;
-}) => {
+export const BillingDiscountCodeButton = ({ orgId }: { orgId: string }) => {
const [code, setCode] = useState("");
const [open, setOpen] = useState(false);
const [processing, setProcessing] = useState(false);
@@ -46,8 +42,6 @@ export const BillingDiscountCodeButton = ({
},
});
- if (!orgId) return null;
-
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
diff --git a/web/src/ee/features/billing/components/BillingScheduleNotification.tsx b/web/src/ee/features/billing/components/BillingScheduleNotification.tsx
index 4ed075be00..fd76179a35 100644
--- a/web/src/ee/features/billing/components/BillingScheduleNotification.tsx
+++ b/web/src/ee/features/billing/components/BillingScheduleNotification.tsx
@@ -1,45 +1,49 @@
-/* eslint-disable @repo/no-null-render */
// Langfuse Cloud only
import { InfoIcon } from "lucide-react";
-import { useBillingInformation } from "./useBillingInformation";
+import type { UseBillingInformationResult } from "./useBillingInformation";
-export const BillingScheduleNotification = () => {
- const { planLabel, cancellation, scheduledPlanSwitch } =
- useBillingInformation();
+type BillingScheduleNotificationProps =
+ | {
+ type: "cancellation";
+ planLabel: string;
+ cancellation: NonNullable<UseBillingInformationResult["cancellation"]>;
+ }
+ | {
+ type: "scheduled-plan-switch";
+ planLabel: string;
+ scheduledPlanSwitch: NonNullable<
+ UseBillingInformationResult["scheduledPlanSwitch"]
+ >;
+ };
- if (!scheduledPlanSwitch && !cancellation) {
- return null;
- }
-
- if (cancellation) {
+export const BillingScheduleNotification = (
+ props: BillingScheduleNotificationProps,
+) => {
+ if (props.type === "cancellation") {
return (
<div className="mt-6 mb-4 flex overflow-x-auto rounded-lg border border-blue-200 bg-blue-100 py-2 text-sm text-blue-900 contrast-more:border-current ltr:pr-4 rtl:pl-4 dark:border-blue-200/30 dark:bg-blue-900/30 dark:text-blue-200 contrast-more:dark:border-current">
<div className="flex items-center gap-2 pl-3 leading-7">
<InfoIcon className="h-4 w-4" />
- {`Your organization cancelled the subscription. Features of the ${planLabel} plan will be available until ${cancellation.formatted}.`}
+ {`Your organization cancelled the subscription. Features of the ${props.planLabel} plan will be available until ${props.cancellation.formatted}.`}
</div>
</div>
);
}
- if (scheduledPlanSwitch) {
- return (
- <div className="mt-6 mb-4 flex overflow-x-auto rounded-lg border border-blue-200 bg-blue-100 py-2 text-sm text-blue-900 contrast-more:border-current ltr:pr-4 rtl:pl-4 dark:border-blue-200/30 dark:bg-blue-900/30 dark:text-blue-200 contrast-more:dark:border-current">
- <div className="flex gap-2 pl-3">
- <InfoIcon className="mt-1 h-4 w-4 shrink-0" />
- <div>
- <div className="leading-5">{`Your organization is scheduled to switch from ${planLabel} to ${scheduledPlanSwitch.newPlanLabel} on ${scheduledPlanSwitch.formatted}.`}</div>
- {scheduledPlanSwitch.message && (
- <div className="mt-2 leading-5 text-blue-800 dark:text-blue-300">
- {scheduledPlanSwitch.message}
- </div>
- )}
- </div>
+ return (
+ <div className="mt-6 mb-4 flex overflow-x-auto rounded-lg border border-blue-200 bg-blue-100 py-2 text-sm text-blue-900 contrast-more:border-current ltr:pr-4 rtl:pl-4 dark:border-blue-200/30 dark:bg-blue-900/30 dark:text-blue-200 contrast-more:dark:border-current">
+ <div className="flex gap-2 pl-3">
+ <InfoIcon className="mt-1 h-4 w-4 shrink-0" />
+ <div>
+ <div className="leading-5">{`Your organization is scheduled to switch from ${props.planLabel} to ${props.scheduledPlanSwitch.newPlanLabel} on ${props.scheduledPlanSwitch.formatted}.`}</div>
+ {props.scheduledPlanSwitch.message && (
+ <div className="mt-2 leading-5 text-blue-800 dark:text-blue-300">
+ {props.scheduledPlanSwitch.message}
+ </div>
+ )}
</div>
</div>
- );
- }
-
- return null;
+ </div>
+ );
};
diff --git a/web/src/ee/features/billing/components/BillingSettings.tsx b/web/src/ee/features/billing/components/BillingSettings.tsx
index 9912070ad6..cf29edf265 100644
--- a/web/src/ee/features/billing/components/BillingSettings.tsx
+++ b/web/src/ee/features/billing/components/BillingSettings.tsx
@@ -16,6 +16,8 @@ import { BillingPlanPeriodView } from "@/src/ee/features/billing/components/Bill
import { useIsCloudBillingAvailable } from "@/src/ee/features/billing/utils/isCloudBilling";
import { SpendAlertsSection } from "./SpendAlerts/SpendAlertsSection";
import { useBillingInformation } from "./useBillingInformation";
+import { api } from "@/src/utils/api";
+import { MAX_EVENTS_FREE_PLAN } from "@/src/ee/features/billing/constants";
export const BillingSettings = () => {
const router = useRouter();
@@ -28,8 +30,30 @@ export const BillingSettings = () => {
const isCloudBillingAvailable = useIsCloudBillingAvailable();
const isCloudBillingEntitled = useHasEntitlement("cloud-billing");
const isSpendAlertEntitled = useHasEntitlement("cloud-spend-alerts");
- const { organization, billingProvider, hasActiveSubscription } =
- useBillingInformation();
+ const {
+ organization,
+ billingProvider,
+ hasActiveSubscription,
+ planLabel,
+ cancellation,
+ scheduledPlanSwitch,
+ } = useBillingInformation();
+ const usage = api.cloudBilling.getUsage.useQuery(
+ { orgId: organization?.id ?? "" },
+ {
+ enabled: Boolean(
+ organization &&
+ isCloudBillingAvailable &&
+ isCloudBillingEntitled &&
+ hasAccess,
+ ),
+ trpc: {
+ context: {
+ skipBatch: true,
+ },
+ },
+ },
+ );
const showBillingDiscount = Boolean(
organization?.cloudConfig?.stripe?.activeSubscriptionId &&
billingProvider !== "clickhouse",
@@ -59,11 +83,32 @@ export const BillingSettings = () => {
return (
<div>
- <BillingScheduleNotification />
+ {cancellation ? (
+ <BillingScheduleNotification
+ type="cancellation"
+ planLabel={planLabel}
+ cancellation={cancellation}
+ />
+ ) : scheduledPlanSwitch ? (
+ <BillingScheduleNotification
+ type="scheduled-plan-switch"
+ planLabel={planLabel}
+ scheduledPlanSwitch={scheduledPlanSwitch}
+ />
+ ) : null}
<Header title="Usage & Billing" />
<div className="space-y-6">
- <BillingUsageChart />
+ {usage.data !== null && (
+ <BillingUsageChart
+ usage={usage.data}
+ hobbyPlanLimit={
+ organization?.cloudConfig?.monthlyObservationLimit ??
+ MAX_EVENTS_FREE_PLAN
+ }
+ plan={organization?.plan ?? "cloud:hobby"}
+ />
+ )}
<BillingPlanPeriodView />
{showBillingDiscount && organization && (
<BillingDiscountView
diff --git a/web/src/ee/features/billing/components/BillingUsageChart.tsx b/web/src/ee/features/billing/components/BillingUsageChart.tsx
index 4d08f5b7ef..1d148365bb 100644
--- a/web/src/ee/features/billing/components/BillingUsageChart.tsx
+++ b/web/src/ee/features/billing/components/BillingUsageChart.tsx
@@ -1,61 +1,40 @@
-/* eslint-disable @repo/no-null-render */
// Langfuse Cloud only
-import { api } from "@/src/utils/api";
-import { useQueryOrganization } from "@/src/features/organizations/hooks";
import { Card } from "@/src/components/ui/card";
import { numberFormatter, compactNumberFormatter } from "@/src/utils/numbers";
import { type Plan } from "@langfuse/shared";
-import { MAX_EVENTS_FREE_PLAN } from "@/src/ee/features/billing/constants";
+import type { RouterOutput } from "@/src/utils/types";
-export const BillingUsageChart = () => {
- const organization = useQueryOrganization();
-
- const usage = api.cloudBilling.getUsage.useQuery(
- {
- orgId: organization?.id as string,
- },
- {
- enabled: organization !== undefined,
- trpc: {
- context: {
- skipBatch: true,
- },
- },
- },
- );
-
- const hobbyPlanLimit =
- organization?.cloudConfig?.monthlyObservationLimit ?? MAX_EVENTS_FREE_PLAN;
- const plan: Plan = organization?.plan ?? "cloud:hobby";
- const usageType = usage.data?.usageType
- ? usage.data.usageType.charAt(0).toUpperCase() +
- usage.data.usageType.slice(1)
+export const BillingUsageChart = ({
+ usage,
+ hobbyPlanLimit,
+ plan,
+}: {
+ usage: Exclude<RouterOutput["cloudBilling"]["getUsage"], null> | undefined;
+ hobbyPlanLimit: number;
+ plan: Plan;
+}) => {
+ const usageType = usage?.usageType
+ ? usage.usageType.charAt(0).toUpperCase() + usage.usageType.slice(1)
: "Events";
- if (usage.data === null) {
- // Might happen in dev mode if STRIPE_SECRET_KEY is not set
- // This avoids errors for all developers not working on or testing the billing features
- return null;
- }
-
return (
<div>
<Card className="p-3">
- {usage.data !== undefined ? (
+ {usage !== undefined ? (
<>
<p className="text-muted-foreground text-sm">
- {usage.data.billingPeriod
+ {usage.billingPeriod
? `Consumed ${usageType} in current billing period (updated about once every 60 minutes)`
: `Consumed ${usageType} / last 30d`}
</p>
<div className="text-3xl font-bold">
- {numberFormatter(usage.data.usageCount, 0)}
+ {numberFormatter(usage.usageCount, 0)}
</div>
{plan === "cloud:hobby" && (
<>
<div className="mt-4 flex justify-between">
- <span className="text-sm">{`${numberFormatter((usage.data.usageCount / hobbyPlanLimit) * 100)}%`}</span>
+ <span className="text-sm">{`${numberFormatter((usage.usageCount / hobbyPlanLimit) * 100)}%`}</span>
<span className="text-sm">
Plan limit: {compactNumberFormatter(hobbyPlanLimit)}
</span>
@@ -64,7 +43,7 @@ export const BillingUsageChart = () => {
className="bg-muted mt-3 h-2 w-full overflow-hidden rounded-full"
role="progressbar"
aria-valuenow={Math.min(
- (usage.data.usageCount / hobbyPlanLimit) * 100,
+ (usage.usageCount / hobbyPlanLimit) * 100,
100,
)}
aria-valuemin={0}
@@ -74,7 +53,7 @@ export const BillingUsageChart = () => {
className="bg-primary h-full rounded-full transition-all"
style={{
width: `${Math.min(
- (usage.data.usageCount / hobbyPlanLimit) * 100,
+ (usage.usageCount / hobbyPlanLimit) * 100,
100,
)}%`,
}}
diff --git a/web/src/features/datasets/components/DatasetCompareRunsTable.tsx b/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
index c7dbc2abce..5eab9b588b 100644
--- a/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
+++ b/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
@@ -233,12 +233,14 @@ function DatasetCompareRunsTableInternal(props: {
setSelectedFields(["output", "scores", "resourceMetrics"]),
}}
/>
- <FilteredRunPills
- projectId={props.projectId}
- datasetId={props.datasetId}
- filteredRuns={activeRunFilters}
- className="px-2 pb-2"
- />
+ {hasActiveRunFilters && (
+ <FilteredRunPills
+ projectId={props.projectId}
+ datasetId={props.datasetId}
+ filteredRuns={activeRunFilters}
+ className="px-2 pb-2"
+ />
+ )}
<DataTable
tableName="datasetCompareRuns"
columns={columns}
diff --git a/web/src/features/datasets/components/DatasetItemsTable.tsx b/web/src/features/datasets/components/DatasetItemsTable.tsx
index 77ad7032bd..879187a765 100644
--- a/web/src/features/datasets/components/DatasetItemsTable.tsx
+++ b/web/src/features/datasets/components/DatasetItemsTable.tsx
@@ -90,6 +90,10 @@ export function DatasetItemsTable({
useFullTextSearch();
const hasAccess = useHasProjectAccess({ projectId, scope: "datasets:CUD" });
+ const hasBatchExportAccess = useHasProjectAccess({
+ projectId,
+ scope: "batchExports:create",
+ });
const { selectedVersion } = useDatasetVersion();
const [editDialogOpen, setEditDialogOpen] = useState(false);
const [selectedItemForEdit, setSelectedItemForEdit] = useState<string | null>(
@@ -335,7 +339,7 @@ export function DatasetItemsTable({
columns,
);
- const batchExportButton = (
+ const batchExportButton = hasBatchExportAccess ? (
<BatchExportTableButton
key="batchExport"
projectId={projectId}
@@ -350,7 +354,7 @@ export function DatasetItemsTable({
},
]}
/>
- );
+ ) : null;
const setFilterStateWithDebounce = useDebounce(setFilterState);
diff --git a/web/src/features/evals/components/evaluator-form.tsx b/web/src/features/evals/components/evaluator-form.tsx
index dde3233eb0..c2478ef717 100644
--- a/web/src/features/evals/components/evaluator-form.tsx
+++ b/web/src/features/evals/components/evaluator-form.tsx
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-null-render */
import { type EvalTemplate, type EvalTargetObject } from "@langfuse/shared";
import { InnerEvaluatorForm } from "@/src/features/evals/components/inner-evaluator-form";
import { type PartialConfig } from "@/src/features/evals/types";
@@ -12,14 +11,13 @@ import {
export const EvaluatorForm = (props: {
projectId: string;
- evalTemplates: EvalTemplate[];
+ evalTemplate: EvalTemplate;
useDialog: boolean;
disabled?: boolean;
existingEvaluator?: PartialConfig & { evalTemplate: EvalTemplate };
onFormSuccess?: () => void;
mode?: "create" | "edit";
shouldWrapVariables?: boolean;
- templateId?: string;
hideTargetSection?: boolean;
hideTargetSelection?: boolean;
preventRedirect?: boolean;
@@ -28,29 +26,10 @@ export const EvaluatorForm = (props: {
hidePreviewTable?: boolean;
defaultTarget?: EvalTargetObject;
}) => {
- const codeEvalCapabilities = useIsCodeEvalEnabled();
-
- const currentTemplate =
- props.existingEvaluator?.evalTemplate ??
- props.evalTemplates
- .filter((template) =>
- shouldShowEvalTemplate(template, codeEvalCapabilities),
- )
- .find((t) => t.id === props.templateId);
-
const evalCapabilities = useEvalCapabilities(props.projectId, {
- isCodeEvalTemplate:
- !!currentTemplate && isCodeEvalTemplate(currentTemplate),
+ isCodeEvalTemplate: isCodeEvalTemplate(props.evalTemplate),
});
- if (
- !currentTemplate ||
- (isCodeEvalTemplate(currentTemplate) &&
- !shouldShowEvalTemplate(currentTemplate, codeEvalCapabilities))
- ) {
- return null;
- }
-
return (
<>
{evalCapabilities.isLoading ? (
@@ -60,9 +39,7 @@ export const EvaluatorForm = (props: {
projectId={props.projectId}
disabled={props.disabled}
existingEvaluator={props.existingEvaluator}
- evalTemplate={
- props.existingEvaluator?.evalTemplate ?? currentTemplate
- }
+ evalTemplate={props.evalTemplate}
onFormSuccess={props.onFormSuccess}
shouldWrapVariables={props.shouldWrapVariables}
hideTargetSection={props.hideTargetSection}
@@ -80,3 +57,28 @@ export const EvaluatorForm = (props: {
</>
);
};
+
+export function useEvaluatorFormTemplate({
+ evalTemplates,
+ evalTemplate,
+ templateId,
+}: {
+ evalTemplates: EvalTemplate[];
+ evalTemplate?: EvalTemplate;
+ templateId?: string;
+}) {
+ const codeEvalCapabilities = useIsCodeEvalEnabled();
+ const currentTemplate =
+ evalTemplate ??
+ evalTemplates.find((template) => template.id === templateId);
+
+ if (
+ !currentTemplate ||
+ (isCodeEvalTemplate(currentTemplate) &&
+ !shouldShowEvalTemplate(currentTemplate, codeEvalCapabilities))
+ ) {
+ return undefined;
+ }
+
+ return currentTemplate;
+}
diff --git a/web/src/features/evals/components/evaluator-table.tsx b/web/src/features/evals/components/evaluator-table.tsx
index 8d87d7e1a1..d5bdfc9137 100644
--- a/web/src/features/evals/components/evaluator-table.tsx
+++ b/web/src/features/evals/components/evaluator-table.tsx
@@ -41,7 +41,10 @@ import {
DialogHeader,
DialogTitle,
} from "@/src/components/ui/dialog";
-import { EvaluatorForm } from "@/src/features/evals/components/evaluator-form";
+import {
+ EvaluatorForm,
+ useEvaluatorFormTemplate,
+} from "@/src/features/evals/components/evaluator-form";
import { useRouter } from "next/router";
import { DeleteEvalConfigButton } from "@/src/components/deleteButton";
import { MaintainerTooltip } from "@/src/features/evals/components/maintainer-tooltip";
@@ -125,6 +128,10 @@ export default function EvaluatorTable({ projectId }: { projectId: string }) {
enabled: !!editConfigId,
},
);
+ const evalTemplate = useEvaluatorFormTemplate({
+ evalTemplates: [],
+ evalTemplate: existingEvaluator.data?.evalTemplate ?? undefined,
+ });
const hasAccess = useHasProjectAccess({
projectId,
@@ -512,10 +519,10 @@ export default function EvaluatorTable({ projectId }: { projectId: string }) {
<div className="flex items-center justify-center p-4">
<Spinner size="lg" />
</div>
- ) : (
+ ) : evalTemplate ? (
<EvaluatorForm
projectId={projectId}
- evalTemplates={[]}
+ evalTemplate={evalTemplate}
existingEvaluator={
existingEvaluator.data && existingEvaluator.data.evalTemplate
? {
@@ -539,7 +546,7 @@ export default function EvaluatorTable({ projectId }: { projectId: string }) {
});
}}
/>
- )}
+ ) : null}
</DialogContent>
</Dialog>
</DataTableControlsProvider>
diff --git a/web/src/features/evals/components/run-evaluator-form.tsx b/web/src/features/evals/components/run-evaluator-form.tsx
index 8ca7eddc9f..5e5819cdc7 100644
--- a/web/src/features/evals/components/run-evaluator-form.tsx
+++ b/web/src/features/evals/components/run-evaluator-form.tsx
@@ -1,5 +1,8 @@
import { Card } from "@/src/components/ui/card";
-import { EvaluatorForm } from "@/src/features/evals/components/evaluator-form";
+import {
+ EvaluatorForm,
+ useEvaluatorFormTemplate,
+} from "@/src/features/evals/components/evaluator-form";
import { type RouterOutputs } from "@/src/utils/api";
type RunEvaluatorFormProps = {
@@ -13,15 +16,21 @@ export function RunEvaluatorForm({
evaluatorId,
evalTemplates,
}: RunEvaluatorFormProps) {
+ const evalTemplate = useEvaluatorFormTemplate({
+ evalTemplates,
+ templateId: evaluatorId,
+ });
+
return (
<Card className="grid p-3">
- <EvaluatorForm
- projectId={projectId}
- evalTemplates={evalTemplates}
- templateId={evaluatorId}
- preventRedirect={false}
- useDialog={false}
- />
+ {evalTemplate && (
+ <EvaluatorForm
+ projectId={projectId}
+ evalTemplate={evalTemplate}
+ preventRedirect={false}
+ useDialog={false}
+ />
+ )}
</Card>
);
}
diff --git a/web/src/features/events/components/EventsTable.tsx b/web/src/features/events/components/EventsTable.tsx
index de462f9631..994c95c3c1 100644
--- a/web/src/features/events/components/EventsTable.tsx
+++ b/web/src/features/events/components/EventsTable.tsx
@@ -100,6 +100,7 @@ import {
useColumnVisibility,
} from "@/src/features/column-visibility";
import { BatchExportTableButton } from "@/src/components/BatchExportTableButton";
+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import { BreakdownTooltip } from "@/src/features/traces";
import { InfoIcon, LightbulbIcon } from "lucide-react";
import { ProvidedModelNameCell } from "@/src/features/models/components/ProvidedModelNameCell";
@@ -307,6 +308,10 @@ export default function ObservationsEventsTable({
isolateTableState = false,
}: EventsTableProps) {
const peekContext = usePeekTableState();
+ const hasBatchExportAccess = useHasProjectAccess({
+ projectId,
+ scope: "batchExports:create",
+ });
const eventsFilterConfig = useMemo(
() => getObservationEventsFilterConfig(omittedFilter),
[omittedFilter],
@@ -2046,17 +2051,19 @@ export default function ObservationsEventsTable({
showControlsInPageHeader ? undefined : refreshConfig
}
actionButtons={[
- <BatchExportTableButton
- {...{
- projectId,
- filterState,
- orderByState,
- searchQuery,
- searchType,
- }}
- tableName={BatchExportTableName.Events}
- key="batchExport"
- />,
+ hasBatchExportAccess ? (
+ <BatchExportTableButton
+ {...{
+ projectId,
+ filterState,
+ orderByState,
+ searchQuery,
+ searchType,
+ }}
+ tableName={BatchExportTableName.Events}
+ key="batchExport"
+ />
+ ) : null,
!chartActive &&
(selectedObservationIds.length > 0 || selectAll) ? (
<AddTracesToAnnotationQueueDialogController
diff --git a/web/src/features/experiments/components/steps/EvaluatorsStep.tsx b/web/src/features/experiments/components/steps/EvaluatorsStep.tsx
index 3c747efd0b..19e38c8e2c 100644
--- a/web/src/features/experiments/components/steps/EvaluatorsStep.tsx
+++ b/web/src/features/experiments/components/steps/EvaluatorsStep.tsx
@@ -7,7 +7,10 @@ import {
DialogTitle,
} from "@/src/components/ui/dialog";
import { TemplateSelector } from "@/src/features/evals/components/template-selector";
-import { EvaluatorForm } from "@/src/features/evals/components/evaluator-form";
+import {
+ EvaluatorForm,
+ useEvaluatorFormTemplate,
+} from "@/src/features/evals/components/evaluator-form";
import { type EvaluatorsStepProps } from "@/src/features/experiments/types/stepProps";
import { StepHeader } from "@/src/features/experiments/components/shared/StepHeader";
import { ExperimentEvaluatorAssignments } from "@/src/features/experiments/components/ExperimentEvaluatorAssignments/ExperimentEvaluatorAssignments";
@@ -22,6 +25,14 @@ export const EvaluatorsStep: React.FC<EvaluatorsStepProps> = ({
permissions,
}) => {
const { hasEvalReadAccess, hasEvalWriteAccess } = permissions;
+ const legacyEvaluatorState =
+ evaluatorState.version === "legacy" ? evaluatorState : undefined;
+ const evalTemplate = useEvaluatorFormTemplate({
+ evalTemplates: legacyEvaluatorState?.evalTemplates ?? [],
+ evalTemplate:
+ legacyEvaluatorState?.selectedEvaluatorData?.evaluator.evalTemplate,
+ templateId: legacyEvaluatorState?.selectedEvaluatorData?.templateId,
+ });
return (
<div className="space-y-6">
<StepHeader
@@ -78,7 +89,8 @@ export const EvaluatorsStep: React.FC<EvaluatorsStepProps> = ({
{/* Dialog for configuring evaluators */}
{evaluatorState.version === "legacy" &&
- evaluatorState.selectedEvaluatorData && (
+ evaluatorState.selectedEvaluatorData &&
+ evalTemplate && (
<Dialog
open={evaluatorState.showEvaluatorForm}
onOpenChange={(open) => {
@@ -99,8 +111,7 @@ export const EvaluatorsStep: React.FC<EvaluatorsStepProps> = ({
<EvaluatorForm
useDialog={true}
projectId={projectId}
- evalTemplates={evaluatorState.evalTemplates}
- templateId={evaluatorState.selectedEvaluatorData.templateId}
+ evalTemplate={evalTemplate}
existingEvaluator={
evaluatorState.selectedEvaluatorData.evaluator
}
diff --git a/web/src/features/payment-banner/PaymentBanner.tsx b/web/src/features/payment-banner/PaymentBanner.tsx
index 61de3f1ef2..76ef1f4e86 100644
--- a/web/src/features/payment-banner/PaymentBanner.tsx
+++ b/web/src/features/payment-banner/PaymentBanner.tsx
@@ -1,21 +1,14 @@
-/* eslint-disable @repo/no-null-render */
-import { useMemo, useRef } from "react";
+import { useMemo } from "react";
import { useSession } from "next-auth/react";
import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";
import { useIsCloudBillingAvailable } from "@/src/ee/features/billing/utils/isCloudBilling";
-import { useTopBannerRegistration } from "@/src/features/top-banner";
import { env } from "@/src/env.mjs";
import { hasOrganizationAccess } from "@/src/features/rbac";
-import { PaymentBannerView } from "./PaymentBannerView";
-const PAYMENT_BANNER_ID = "payment-banner";
-const PAYMENT_BANNER_ORDER = 10;
-
-export function PaymentBanner() {
+export function usePaymentBanner() {
const session = useSession();
const { organization } = useQueryProjectOrOrganization();
const isCloudBilling = useIsCloudBillingAvailable();
- const bannerRef = useRef<HTMLDivElement>(null);
const subscriptionStatus = useMemo(() => {
// Don't show banner if:
@@ -50,25 +43,15 @@ export function PaymentBanner() {
organization && hasBillingIssue && canManageBilling,
);
- useTopBannerRegistration({
- bannerId: PAYMENT_BANNER_ID,
- order: PAYMENT_BANNER_ORDER,
- isVisible,
- elementRef: bannerRef,
- });
-
const basePath = env.NEXT_PUBLIC_BASE_PATH ?? "";
if (!isVisible || !organization) {
return null;
}
- return (
- <PaymentBannerView
- ref={bannerRef}
- organizationName={organization.name}
- billingSettingsHref={`${basePath}/organization/${organization.id}/settings/billing`}
- severity={subscriptionStatus === "unpaid" ? "critical" : "info"}
- />
- );
+ return {
+ organizationName: organization.name,
+ billingSettingsHref: `${basePath}/organization/${organization.id}/settings/billing`,
+ severity: subscriptionStatus === "unpaid" ? "critical" : "info",
+ } as const;
}
diff --git a/web/src/features/payment-banner/PaymentBannerView.tsx b/web/src/features/payment-banner/PaymentBannerView.tsx
index 9df0dad28f..1702c7f99a 100644
--- a/web/src/features/payment-banner/PaymentBannerView.tsx
+++ b/web/src/features/payment-banner/PaymentBannerView.tsx
@@ -6,7 +6,7 @@ import { Button } from "@/src/components/ui/button";
import { cn } from "@/src/utils/tailwind";
const paymentBannerVariants = cva(
- "fixed top-0 z-51 flex w-full flex-col gap-1 px-4 py-1.5 sm:flex-row sm:items-center sm:gap-3 sm:py-1",
+ "flex w-full flex-col gap-1 px-4 py-1.5 sm:flex-row sm:items-center sm:gap-3 sm:py-1",
{
variants: {
severity: {
diff --git a/web/src/features/payment-banner/index.ts b/web/src/features/payment-banner/index.ts
index 10490a1c70..f65b2b6f50 100644
--- a/web/src/features/payment-banner/index.ts
+++ b/web/src/features/payment-banner/index.ts
@@ -1 +1,2 @@
-export { PaymentBanner } from "./PaymentBanner";
+export { usePaymentBanner } from "./PaymentBanner";
+export { PaymentBannerView } from "./PaymentBannerView";
diff --git a/web/src/features/preview-deployment-banner/PreviewDeploymentBanner.clienttest.tsx b/web/src/features/preview-deployment-banner/PreviewDeploymentBanner.clienttest.tsx
index 9c836681bb..d8ca1d4559 100644
--- a/web/src/features/preview-deployment-banner/PreviewDeploymentBanner.clienttest.tsx
+++ b/web/src/features/preview-deployment-banner/PreviewDeploymentBanner.clienttest.tsx
@@ -8,12 +8,6 @@ const h = vi.hoisted(() => ({
}));
vi.mock("@/src/env.mjs", () => ({ env: h.env }));
-// The container only reads the offset and registers its height; neither
-// affects the rendered content under test.
-vi.mock("@/src/features/top-banner", () => ({
- useTopBanner: () => ({ getTopBannerOffset: () => 0 }),
- useTopBannerRegistration: () => {},
-}));
describe("PreviewDeploymentBanner", () => {
afterEach(() => {
diff --git a/web/src/features/preview-deployment-banner/PreviewDeploymentBanner.tsx b/web/src/features/preview-deployment-banner/PreviewDeploymentBanner.tsx
index ec26ba475f..490e4ab03c 100644
--- a/web/src/features/preview-deployment-banner/PreviewDeploymentBanner.tsx
+++ b/web/src/features/preview-deployment-banner/PreviewDeploymentBanner.tsx
@@ -1,31 +1,13 @@
-import { useRef } from "react";
import { formatDistanceToNow } from "date-fns";
-import {
- useTopBanner,
- useTopBannerRegistration,
-} from "@/src/features/top-banner";
import { env } from "@/src/env.mjs";
import { PreviewDeploymentBannerView } from "./PreviewDeploymentBannerView";
-const PREVIEW_BANNER_ID = "preview-deployment-banner";
-const PREVIEW_BANNER_ORDER = 20;
-
/**
* Top-of-page strip shown on PR preview deployments only. The env vars are
* baked into preview web images by .github/workflows/preview-build.yml; they
* are unset everywhere else, so the banner never renders outside previews.
*/
export function PreviewDeploymentBanner({ prUrl }: { prUrl: string }) {
- const bannerRef = useRef<HTMLDivElement>(null);
- const { getTopBannerOffset } = useTopBanner();
-
- useTopBannerRegistration({
- bannerId: PREVIEW_BANNER_ID,
- order: PREVIEW_BANNER_ORDER,
- isVisible: true,
- elementRef: bannerRef,
- });
-
const parsed = env.NEXT_PUBLIC_PREVIEW_LAST_UPDATED
? new Date(env.NEXT_PUBLIC_PREVIEW_LAST_UPDATED)
: undefined;
@@ -34,7 +16,6 @@ export function PreviewDeploymentBanner({ prUrl }: { prUrl: string }) {
return (
<PreviewDeploymentBannerView
- ref={bannerRef}
prUrl={prUrl}
prNumber={/\/pull\/(\d+)/.exec(prUrl)?.[1]}
author={env.NEXT_PUBLIC_PREVIEW_PR_AUTHOR}
@@ -44,7 +25,6 @@ export function PreviewDeploymentBanner({ prUrl }: { prUrl: string }) {
: undefined
}
updatedTitle={lastUpdated?.toLocaleString()}
- topOffset={getTopBannerOffset(PREVIEW_BANNER_ORDER)}
/>
);
}
diff --git a/web/src/features/preview-deployment-banner/PreviewDeploymentBannerView.tsx b/web/src/features/preview-deployment-banner/PreviewDeploymentBannerView.tsx
index 1c681d2396..9f65e526c3 100644
--- a/web/src/features/preview-deployment-banner/PreviewDeploymentBannerView.tsx
+++ b/web/src/features/preview-deployment-banner/PreviewDeploymentBannerView.tsx
@@ -1,5 +1,3 @@
-import { type Ref } from "react";
-
export type PreviewDeploymentBannerViewProps = {
/** Link back to the pull request this preview deployment belongs to. */
prUrl: string;
@@ -12,9 +10,6 @@ export type PreviewDeploymentBannerViewProps = {
/** Absolute timestamp shown on hover — the relative text is computed at render
* time and goes stale in a long-lived tab. */
updatedTitle?: string;
- /** Vertical offset when stacked below other top banners. */
- topOffset?: number;
- ref?: Ref<HTMLDivElement>;
};
export function PreviewDeploymentBannerView({
@@ -23,15 +18,9 @@ export function PreviewDeploymentBannerView({
author,
updatedText,
updatedTitle,
- topOffset = 0,
- ref,
}: PreviewDeploymentBannerViewProps) {
return (
- <div
- ref={ref}
- className="border-preview-banner-border bg-preview-banner text-preview-banner-foreground fixed z-51 flex w-full items-center justify-center border-b px-4 py-1"
- style={{ top: topOffset }}
- >
+ <div className="border-preview-banner-border bg-preview-banner text-preview-banner-foreground flex w-full items-center justify-center border-b px-4 py-1">
<span className="text-sm">
Preview deployment of{" "}
<a
diff --git a/web/src/features/public-api/components/LLMApiKeyList.tsx b/web/src/features/public-api/components/LLMApiKeyList.tsx
index 2035c37902..42dedd2521 100644
--- a/web/src/features/public-api/components/LLMApiKeyList.tsx
+++ b/web/src/features/public-api/components/LLMApiKeyList.tsx
@@ -31,6 +31,10 @@ export function LlmApiKeyList(props: { projectId: string }) {
projectId: props.projectId,
scope: "llmApiKeys:delete",
});
+ const hasUpdateAccess = useHasProjectAccess({
+ projectId: props.projectId,
+ scope: "llmApiKeys:update",
+ });
const apiKeys = api.llmApiKey.all.useQuery(
{
@@ -130,18 +134,20 @@ export function LlmApiKeyList(props: { projectId: string }) {
className="flex justify-end space-x-2"
onClick={(e) => e.stopPropagation()}
>
- <UpdateLLMApiKeyDialog
- apiKey={apiKey}
- projectId={props.projectId}
- open={editingKeyId === apiKey.id}
- onOpenChange={(open: boolean) => {
- if (open) {
- setEditingKeyId(apiKey.id);
- } else {
- setEditingKeyId(null);
- }
- }}
- />
+ {hasUpdateAccess && (
+ <UpdateLLMApiKeyDialog
+ apiKey={apiKey}
+ projectId={props.projectId}
+ open={editingKeyId === apiKey.id}
+ onOpenChange={(open: boolean) => {
+ if (open) {
+ setEditingKeyId(apiKey.id);
+ } else {
+ setEditingKeyId(null);
+ }
+ }}
+ />
+ )}
{hasDeleteAccess && (
<DeleteApiKeyButton
projectId={props.projectId}
diff --git a/web/src/features/public-api/components/UpdateLLMApiKeyDialog.tsx b/web/src/features/public-api/components/UpdateLLMApiKeyDialog.tsx
index 864c9ca961..9909af85d6 100644
--- a/web/src/features/public-api/components/UpdateLLMApiKeyDialog.tsx
+++ b/web/src/features/public-api/components/UpdateLLMApiKeyDialog.tsx
@@ -1,5 +1,4 @@
-/* eslint-disable @repo/no-abstracted-overlay-trigger, @repo/no-null-render */
-import { useState } from "react";
+/* eslint-disable @repo/no-abstracted-overlay-trigger */
import { Button } from "@/src/components/ui/button";
import {
Dialog,
@@ -10,7 +9,6 @@ import {
} from "@/src/components/ui/dialog";
import { CreateLLMApiKeyForm } from "./CreateLLMApiKeyForm";
import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";
-import { useHasProjectAccess } from "@/src/features/rbac";
import { PencilIcon } from "lucide-react";
import { type RouterOutputs } from "@/src/utils/api";
@@ -24,25 +22,13 @@ export function UpdateLLMApiKeyDialog({
}: {
apiKey: LlmApiKeyListItem;
projectId: string;
- open?: boolean;
- onOpenChange?: (open: boolean) => void;
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
}) {
- const [internalOpen, setInternalOpen] = useState(false);
const uiCustomization = useUiCustomization();
- // Use external state if provided, otherwise use internal state
- const isOpen = open !== undefined ? open : internalOpen;
- const setIsOpen = onOpenChange || setInternalOpen;
-
- const hasAccess = useHasProjectAccess({
- projectId,
- scope: "llmApiKeys:update",
- });
-
- if (!hasAccess) return null;
-
return (
- <Dialog open={isOpen} onOpenChange={setIsOpen}>
+ <Dialog open={open} onOpenChange={onOpenChange}>
<DialogTrigger asChild>
<Button variant="ghost" size="icon">
<PencilIcon className="h-4 w-4" />
@@ -55,10 +41,10 @@ export function UpdateLLMApiKeyDialog({
<DialogHeader>
<DialogTitle>Update LLM Connection</DialogTitle>
</DialogHeader>
- {isOpen && (
+ {open && (
<CreateLLMApiKeyForm
projectId={projectId}
- onSuccess={() => setIsOpen(false)}
+ onSuccess={() => onOpenChange(false)}
customization={uiCustomization}
mode="update"
existingKey={apiKey}
diff --git a/web/src/features/sessions/SessionsTable.tsx b/web/src/features/sessions/SessionsTable.tsx
index 48a59c57d4..b9ca10a533 100644
--- a/web/src/features/sessions/SessionsTable.tsx
+++ b/web/src/features/sessions/SessionsTable.tsx
@@ -68,6 +68,7 @@ import { BatchExportTableButton } from "@/src/components/BatchExportTableButton"
import { sessionsFieldRegistry } from "@/src/features/filters/config/sessionsSearchRegistry";
import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";
import { TableSearchBar } from "@/src/features/search-bar/components/TableSearchBar";
+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
export type SessionTableRow = {
id: string;
@@ -113,6 +114,10 @@ export default function SessionsTable({
);
const { setDetailPageList } = useDetailPageLists();
const { timeRange, setTimeRange } = useTableDateRange(projectId);
+ const hasBatchExportAccess = useHasProjectAccess({
+ projectId,
+ scope: "batchExports:create",
+ });
// Convert timeRange to absolute date range for compatibility
const dateRange = useMemo(() => {
@@ -808,15 +813,17 @@ export default function SessionsTable({
}}
/>
) : null,
- <BatchExportTableButton
- {...{
- projectId,
- filterState: backendFilterState,
- orderByState,
- }}
- tableName={BatchExportTableName.Sessions}
- key="batchExport"
- />,
+ hasBatchExportAccess ? (
+ <BatchExportTableButton
+ {...{
+ projectId,
+ filterState: backendFilterState,
+ orderByState,
+ }}
+ tableName={BatchExportTableName.Sessions}
+ key="batchExport"
+ />
+ ) : null,
]}
columns={columns}
columnVisibility={columnVisibility}
diff --git a/web/src/features/support-chat/SupportDrawer.tsx b/web/src/features/support-chat/SupportDrawer.tsx
index 7c5a6d1e6c..6ea7665bbb 100644
--- a/web/src/features/support-chat/SupportDrawer.tsx
+++ b/web/src/features/support-chat/SupportDrawer.tsx
@@ -1,4 +1,4 @@
-/* eslint-disable @repo/no-style-props, @repo/no-null-render */
+/* eslint-disable @repo/no-style-props */
import { useSupportDrawer } from "@/src/features/support-chat/SupportDrawerProvider";
import { useState } from "react";
import { Button } from "@/src/components/ui/button";
@@ -20,9 +20,7 @@ export const SupportDrawer = (props: {
showCloseButton?: boolean;
className?: string;
}) => {
- const { open, openEpoch } = useSupportDrawer();
-
- if (!open) return null;
+ const { openEpoch } = useSupportDrawer();
// Keyed by openEpoch so re-opening (openWithMode while already open)
// remounts the content and re-seeds mode/topic from the provider.
diff --git a/web/src/features/top-banner/TopBannerContext.tsx b/web/src/features/top-banner/TopBannerContext.tsx
deleted file mode 100644
index 1e25f754a8..0000000000
--- a/web/src/features/top-banner/TopBannerContext.tsx
+++ /dev/null
@@ -1,118 +0,0 @@
-import {
- createContext,
- useCallback,
- useContext,
- useEffect,
- useMemo,
- useState,
- type ReactNode,
-} from "react";
-
-type TopBannerEntry = {
- height: number;
- order: number;
-};
-
-interface TopBannerContextValue {
- bannerHeight: number;
- setTopBannerHeight: (bannerId: string, height: number, order: number) => void;
- getTopBannerOffset: (order: number) => number;
-}
-
-const TopBannerContext = createContext<TopBannerContextValue | null>(null);
-
-export function TopBannerProvider({ children }: { children: ReactNode }) {
- const [topBannerHeights, setTopBannerHeights] = useState<
- Record<string, TopBannerEntry>
- >({});
-
- const setTopBannerHeight = useCallback(
- (bannerId: string, height: number, order: number) => {
- setTopBannerHeights((prev) => {
- if (height <= 0) {
- if (!(bannerId in prev)) {
- return prev;
- }
- const next = { ...prev };
- delete next[bannerId];
- return next;
- }
-
- const current = prev[bannerId];
- if (current && current.height === height && current.order === order) {
- return prev;
- }
-
- return {
- ...prev,
- [bannerId]: { height, order },
- };
- });
- },
- [],
- );
-
- const orderedTopBanners = useMemo(
- () =>
- Object.entries(topBannerHeights)
- .map(([id, entry]) => ({
- id,
- ...entry,
- }))
- .sort((a, b) => a.order - b.order || a.id.localeCompare(b.id)),
- [topBannerHeights],
- );
-
- const bannerHeight = useMemo(
- () =>
- orderedTopBanners.reduce((totalHeight, banner) => {
- return totalHeight + banner.height;
- }, 0),
- [orderedTopBanners],
- );
-
- const getTopBannerOffset = useCallback(
- (targetOrder: number) => {
- let offset = 0;
- for (const banner of orderedTopBanners) {
- if (banner.order >= targetOrder) {
- break;
- }
- offset += banner.height;
- }
- return offset;
- },
- [orderedTopBanners],
- );
-
- useEffect(() => {
- // Note: CSS vars allow us to reduce re-renders of child-components and correct
- // CSS animations. Prefer using the CSS var over consuming the hook below to adjust layouts.
- // Example:
- // - <div className="h-[calc(100svh-var(--banner-height,0px))]"> --> correct height calculation
- document.documentElement.style.setProperty(
- "--banner-height",
- `${bannerHeight}px`,
- );
- }, [bannerHeight]);
-
- return (
- <TopBannerContext.Provider
- value={{
- bannerHeight,
- setTopBannerHeight,
- getTopBannerOffset,
- }}
- >
- {children}
- </TopBannerContext.Provider>
- );
-}
-
-export function useTopBanner() {
- const context = useContext(TopBannerContext);
- if (!context) {
- throw new Error("useTopBanner must be used within TopBannerProvider");
- }
- return context;
-}
diff --git a/web/src/features/top-banner/index.ts b/web/src/features/top-banner/index.ts
index c4351dec84..955978f4fc 100644
--- a/web/src/features/top-banner/index.ts
+++ b/web/src/features/top-banner/index.ts
@@ -1,2 +1 @@
-export { TopBannerProvider, useTopBanner } from "./TopBannerContext";
-export { useTopBannerRegistration } from "./useTopBannerRegistration";
+export { useTopBannerHeight } from "./useTopBannerHeight";
diff --git a/web/src/features/top-banner/useTopBannerHeight.ts b/web/src/features/top-banner/useTopBannerHeight.ts
new file mode 100644
index 0000000000..e87758305c
--- /dev/null
+++ b/web/src/features/top-banner/useTopBannerHeight.ts
@@ -0,0 +1,28 @@
+import { useEffect, useRef } from "react";
+
+export function useTopBannerHeight() {
+ const topBannerRef = useRef<HTMLDivElement>(null);
+
+ useEffect(() => {
+ const element = topBannerRef.current;
+ if (!element) return;
+
+ const updateBannerHeight = () => {
+ document.documentElement.style.setProperty(
+ "--banner-height",
+ `${element.offsetHeight}px`,
+ );
+ };
+
+ updateBannerHeight();
+ const resizeObserver = new ResizeObserver(updateBannerHeight);
+ resizeObserver.observe(element);
+
+ return () => {
+ resizeObserver.disconnect();
+ document.documentElement.style.setProperty("--banner-height", "0px");
+ };
+ }, []);
+
+ return topBannerRef;
+}
diff --git a/web/src/features/top-banner/useTopBannerRegistration.ts b/web/src/features/top-banner/useTopBannerRegistration.ts
deleted file mode 100644
index a4791b356e..0000000000
--- a/web/src/features/top-banner/useTopBannerRegistration.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import { useEffect, type RefObject } from "react";
-import { useTopBanner } from "./TopBannerContext";
-
-type UseTopBannerRegistrationParams<T extends HTMLElement> = {
- bannerId: string;
- order: number;
- isVisible: boolean;
- elementRef: RefObject<T | null>;
-};
-
-export function useTopBannerRegistration<T extends HTMLElement>({
- bannerId,
- order,
- isVisible,
- elementRef,
-}: UseTopBannerRegistrationParams<T>) {
- const { setTopBannerHeight } = useTopBanner();
-
- useEffect(() => {
- if (!isVisible || !elementRef.current) {
- setTopBannerHeight(bannerId, 0, order);
- return;
- }
-
- const updateHeight = () => {
- if (elementRef.current) {
- setTopBannerHeight(bannerId, elementRef.current.offsetHeight, order);
- } else {
- setTopBannerHeight(bannerId, 0, order);
- }
- };
-
- updateHeight();
-
- const resizeObserver = new ResizeObserver(updateHeight);
- resizeObserver.observe(elementRef.current);
-
- return () => {
- resizeObserver.disconnect();
- setTopBannerHeight(bannerId, 0, order);
- };
- }, [bannerId, order, isVisible, setTopBannerHeight, elementRef]);
-}
diff --git a/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader.tsx b/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader.tsx
index 9cbfd744c8..e601d3c7dd 100644
--- a/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader.tsx
+++ b/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader.tsx
@@ -739,14 +739,18 @@ export const ObservationDetailViewHeader = memo(
<TimeToFirstTokenBadge
timeToFirstToken={observation.timeToFirstToken}
/>
- <SessionBadge
- sessionId={observation.sessionId ?? null}
- projectId={projectId}
- />
- <UserIdBadge
- userId={observation.userId ?? null}
- projectId={projectId}
- />
+ {observation.sessionId && (
+ <SessionBadge
+ sessionId={observation.sessionId}
+ projectId={projectId}
+ />
+ )}
+ {observation.userId && (
+ <UserIdBadge
+ userId={observation.userId}
+ projectId={projectId}
+ />
+ )}
{evaluatorId &&
(observation.environment ===
LangfuseInternalTraceEnvironment.LLMJudge ||
diff --git a/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx b/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx
index 65fa0afdde..eb32df336b 100644
--- a/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx
+++ b/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx
@@ -487,15 +487,23 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
{!isAnnotationMode && (
<CollapsibleBadgeRow>
<LatencyBadge latencySeconds={trace.latency ?? null} />
- <SessionBadge sessionId={trace.sessionId} projectId={projectId} />
- <UserIdBadge userId={trace.userId} projectId={projectId} />
- <TargetTraceBadge
- targetTraceId={targetTraceId}
- projectId={projectId}
- />
- <EnvironmentBadge environment={trace.environment} />
- <ReleaseBadge release={trace.release} />
- <VersionBadge version={trace.version} />
+ {trace.sessionId && (
+ <SessionBadge sessionId={trace.sessionId} projectId={projectId} />
+ )}
+ {trace.userId && (
+ <UserIdBadge userId={trace.userId} projectId={projectId} />
+ )}
+ {targetTraceId && (
+ <TargetTraceBadge
+ targetTraceId={targetTraceId}
+ projectId={projectId}
+ />
+ )}
+ {trace.environment && (
+ <EnvironmentBadge environment={trace.environment} />
+ )}
+ {trace.release && <ReleaseBadge release={trace.release} />}
+ {trace.version && <VersionBadge version={trace.version} />}
{aggregatedMetrics.totalCost != null &&
aggregatedMetrics.costDetails && (
<CostBadge
diff --git a/web/src/features/traces/components/TraceMetadataBadges.tsx b/web/src/features/traces/components/TraceMetadataBadges.tsx
index e4b0da8548..0aa14ca800 100644
--- a/web/src/features/traces/components/TraceMetadataBadges.tsx
+++ b/web/src/features/traces/components/TraceMetadataBadges.tsx
@@ -1,9 +1,7 @@
-/* eslint-disable @repo/no-null-render */
/**
* TraceMetadataBadges - Extracted badge components for trace metadata
*
* Following the pattern from ObservationDetailView/ObservationMetadataBadgesSimple.tsx
- * Each badge handles its own null check and returns null when data is unavailable.
*/
import Link from "next/link";
@@ -14,11 +12,9 @@ export function SessionBadge({
sessionId,
projectId,
}: {
- sessionId: string | null;
+ sessionId: string;
projectId: string;
}) {
- if (!sessionId) return null;
-
const text = `Session: ${sessionId}`;
return (
@@ -35,11 +31,9 @@ export function UserIdBadge({
userId,
projectId,
}: {
- userId: string | null;
+ userId: string;
projectId: string;
}) {
- if (!userId) return null;
-
const text = `User ID: ${userId}`;
return (
@@ -56,11 +50,9 @@ export function TargetTraceBadge({
targetTraceId,
projectId,
}: {
- targetTraceId: string | null;
+ targetTraceId: string;
projectId: string;
}) {
- if (!targetTraceId) return null;
-
const text = `Target Trace: ${targetTraceId}`;
return (
@@ -73,21 +65,14 @@ export function TargetTraceBadge({
);
}
-export function EnvironmentBadge({
- environment,
-}: {
- environment: string | null;
-}) {
- if (!environment) return null;
+export function EnvironmentBadge({ environment }: { environment: string }) {
return <Badge text={`Env: ${environment}`} />;
}
-export function ReleaseBadge({ release }: { release: string | null }) {
- if (!release) return null;
+export function ReleaseBadge({ release }: { release: string }) {
return <Badge text={`Release: ${release}`} />;
}
-export function VersionBadge({ version }: { version: string | null }) {
- if (!version) return null;
+export function VersionBadge({ version }: { version: string }) {
return <Badge text={`Version: ${version}`} />;
}
diff --git a/web/src/features/widgets/chart-library/BigNumber.tsx b/web/src/features/widgets/chart-library/BigNumber.tsx
index afd4831743..eddd3fdbeb 100644
--- a/web/src/features/widgets/chart-library/BigNumber.tsx
+++ b/web/src/features/widgets/chart-library/BigNumber.tsx
@@ -1,4 +1,4 @@
-/* eslint-disable @repo/no-style-props, @repo/no-null-render */
+/* eslint-disable @repo/no-style-props */
import React, { useEffect, useRef, useState, useMemo } from "react";
import { cn } from "@/src/utils/tailwind";
import { type ChartProps } from "@/src/features/widgets/chart-library/chart-props";
@@ -52,12 +52,7 @@ export const BigNumber: React.FC<ChartProps> = ({
const [fontSize, setFontSize] = useState<FontSizeClass>("text-6xl");
const [maxCharacters, setMaxCharacters] = useState<number>();
- // Calculate metric value from data - show loading if no data
- const isLoading = !data || data.length === 0;
-
const calculatedMetric = useMemo(() => {
- if (isLoading) return 0;
-
// Show the sum of all metrics, or just the first metric if only one
if (data.length === 1) {
return typeof data[0].metric === "number" ? data[0].metric : 0;
@@ -67,13 +62,9 @@ export const BigNumber: React.FC<ChartProps> = ({
const metric = typeof d.metric === "number" ? d.metric : 0;
return acc + metric;
}, 0);
- }, [data, isLoading]);
+ }, [data]);
const displayValue = useMemo(() => {
- if (isLoading) {
- return { main: "0" };
- }
-
return metricFormatter
? metricFormatter(
calculatedMetric,
@@ -87,7 +78,7 @@ export const BigNumber: React.FC<ChartProps> = ({
: {
main: calculatedMetric.toString(),
};
- }, [calculatedMetric, isLoading, maxCharacters, metricFormatter]);
+ }, [calculatedMetric, maxCharacters, metricFormatter]);
useEffect(() => {
const resizeObserver = new ResizeObserver(() => {
@@ -112,13 +103,11 @@ export const BigNumber: React.FC<ChartProps> = ({
const maxChars = Math.floor(availableWidth / charWidth);
// Quick test with current display value
- const testDisplayValue = !isLoading
- ? metricFormatter
- ? metricFormatter(calculatedMetric, {
- style: "compact",
- maxCharacters: maxChars,
- })
- : { main: "0" }
+ const testDisplayValue = metricFormatter
+ ? metricFormatter(calculatedMetric, {
+ style: "compact",
+ maxCharacters: maxChars,
+ })
: { main: "0" };
const textLength = (
@@ -149,11 +138,7 @@ export const BigNumber: React.FC<ChartProps> = ({
}
return () => resizeObserver.disconnect();
- }, [calculatedMetric, isLoading, metricFormatter]);
-
- if (isLoading) {
- return null;
- }
+ }, [calculatedMetric, metricFormatter]);
return (
<div
diff --git a/web/src/features/widgets/chart-library/Chart.tsx b/web/src/features/widgets/chart-library/Chart.tsx
index 46c41bc2f9..aa5924a70d 100644
--- a/web/src/features/widgets/chart-library/Chart.tsx
+++ b/web/src/features/widgets/chart-library/Chart.tsx
@@ -43,6 +43,7 @@ const EMPTY_STATE_CHART_TYPES = new Set<DashboardWidgetChartType>([
"LINE_TIME_SERIES",
"AREA_TIME_SERIES",
"BAR_TIME_SERIES",
+ "NUMBER",
]);
const ChartComponent = ({
@@ -169,10 +170,10 @@ const ChartComponent = ({
// mark.
if (
(EMPTY_STATE_CHART_TYPES.has(chartType) || emptyState !== undefined) &&
- !isLoading &&
+ (chartType === "NUMBER" || !isLoading) &&
isChartDataEmpty(data)
) {
- return emptyState ?? <NoDataOrLoading isLoading={false} />;
+ return emptyState ?? <NoDataOrLoading isLoading={isLoading} />;
}
switch (chartType) {
diff --git a/web/src/pages/project/[projectId]/datasets/[datasetId]/experiments/index.tsx b/web/src/pages/project/[projectId]/datasets/[datasetId]/experiments/index.tsx
index 0d7a06c825..a08170820e 100644
--- a/web/src/pages/project/[projectId]/datasets/[datasetId]/experiments/index.tsx
+++ b/web/src/pages/project/[projectId]/datasets/[datasetId]/experiments/index.tsx
@@ -37,7 +37,10 @@ import { TemplateSelector } from "@/src/features/evals/components/template-selec
import { useEvaluatorDefaults } from "@/src/features/experiments/hooks/useEvaluatorDefaults";
import { useExperimentEvaluatorData } from "@/src/features/experiments/hooks/useExperimentEvaluatorData";
import { useExperimentAccess } from "@/src/features/experiments/hooks/useExperimentAccess";
-import { EvaluatorForm } from "@/src/features/evals/components/evaluator-form";
+import {
+ EvaluatorForm,
+ useEvaluatorFormTemplate,
+} from "@/src/features/evals/components/evaluator-form";
import useLocalStorage from "@/src/components/useLocalStorage";
import { getDatasetBreadcrumb } from "@/src/features/datasets/utils/getDatasetBreadcrumb";
import { ExperimentsTable } from "@/src/features/experiments/components/table";
@@ -182,6 +185,11 @@ function DatasetExperimentsView({
evalTemplatesData: evalTemplates.data,
refetchEvaluators: evaluators.refetch,
});
+ const evalTemplate = useEvaluatorFormTemplate({
+ evalTemplates: evalTemplates.data?.templates ?? [],
+ evalTemplate: selectedEvaluatorData?.evaluator.evalTemplate,
+ templateId: selectedEvaluatorData?.templateId,
+ });
// Callback for preprocessing evaluator form values
// For experiment evaluators, we only run on new data (not historic)
const preprocessFormValues = useCallback((values: any) => values, []);
@@ -398,7 +406,7 @@ function DatasetExperimentsView({
setScoreOptions={setScoreOptions}
/>
{/* Dialog for configuring evaluators */}
- {selectedEvaluatorData && (
+ {selectedEvaluatorData && evalTemplate && (
<Dialog
open={showEvaluatorForm}
onOpenChange={(open) => {
@@ -417,8 +425,7 @@ function DatasetExperimentsView({
<EvaluatorForm
useDialog={true}
projectId={projectId}
- evalTemplates={evalTemplates.data?.templates ?? []}
- templateId={selectedEvaluatorData.templateId}
+ evalTemplate={evalTemplate}
existingEvaluator={selectedEvaluatorData.evaluator}
mode={selectedEvaluatorData.evaluator.id ? "edit" : "create"}
hideTargetSection={!selectedEvaluatorData.evaluator.id}