🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
refactor(web): Fix some no-null-render issues (#17021)
Ben Bachemc2ee6303b02f
diff --git a/web/src/components/ChatMessages/ChatMessageComponent.tsx b/web/src/components/ChatMessages/ChatMessageComponent.tsxindex 4911a255cf..f354d51505 100644--- a/web/src/components/ChatMessages/ChatMessageComponent.tsx+++ b/web/src/components/ChatMessages/ChatMessageComponent.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import capitalize from "lodash/capitalize";import { GripVertical, MinusCircleIcon } from "lucide-react";import {@@ -87,8 +86,6 @@ const getRoleNamePlaceholder = (role: string) => {};const ToolCalls: React.FC<{ toolCalls: LLMToolCall[] }> = ({ toolCalls }) => {- if (!toolCalls || toolCalls.length === 0) return null;-return (<div className="w-full space-y-2">{toolCalls.map((toolCall) => (@@ -367,9 +364,10 @@ export const ChatMessageComponent: React.FC<ChatMessageProps> = ({/>)}</div>- {message.type === ChatMessageType.AssistantToolCall && (- <ToolCalls toolCalls={message.toolCalls as LLMToolCall[]} />- )}+ {message.type === ChatMessageType.AssistantToolCall &&+ message.toolCalls.length > 0 && (+ <ToolCalls toolCalls={message.toolCalls as LLMToolCall[]} />+ )}</div><Buttonvariant="ghost"diff --git a/web/src/components/JSONSchemaEditor.tsx b/web/src/components/JSONSchemaEditor.tsxindex 59c1be6861..fccab4f5d4 100644--- a/web/src/components/JSONSchemaEditor.tsx+++ b/web/src/components/JSONSchemaEditor.tsx@@ -1,9 +1,10 @@-/* eslint-disable @repo/no-style-props, @repo/no-null-render */+/* eslint-disable @repo/no-style-props */import React from "react";import { ArrowUpRight } from "lucide-react";import { Button } from "@/src/components/ui/button";import { CodeMirrorEditor } from "@/src/components/editor";import { showErrorToast } from "@/src/features/notifications/showErrorToast";+import { assertUnreachable } from "@langfuse/shared";type JSONSchemaEditorMode = "json"; // Future: "json" | "builder"@@ -107,5 +108,5 @@ export const JSONSchemaEditor: React.FC<JSONSchemaEditorProps> = ({}// Future mode implementations go here- return null;+ return assertUnreachable(mode);};diff --git a/web/src/components/ScoreBadge/ScoreBadge.tsx b/web/src/components/ScoreBadge/ScoreBadge.tsxindex fcc6799ab9..d28a42eaf3 100644--- a/web/src/components/ScoreBadge/ScoreBadge.tsx+++ b/web/src/components/ScoreBadge/ScoreBadge.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-margin-on-root-elements, @repo/no-null-render */import { type LastUserScore, type ScoreDomain } from "@langfuse/shared";import {BracesIcon,@@ -35,16 +34,15 @@ const hasMetadata = (const ExecutionTraceLink = ({executionTraceId,+ projectId,}: {executionTraceId: string;+ projectId: string;}) => {- const projectId = useProjectIdFromURL();- if (!projectId) return null;-return (<Linkhref={`/project/${projectId}/traces/${encodeURIComponent(executionTraceId)}`}- className="mt-2 flex items-center gap-1 text-blue-600 hover:underline"+ className="flex items-center gap-1 text-blue-600 hover:underline"target="_blank"><ExternalLinkIcon className="h-3 w-3" />@@ -67,6 +65,8 @@ export const ScoreBadge = </** Render this group's level tags when the selection mixes score levels. */showLevels?: boolean;}) => {+ const projectId = useProjectIdFromURL();+const levels = showLevels? Array.from(new Set(scores.map((score) => scoreLevelFromScore(score)))): [];@@ -103,10 +103,14 @@ export const ScoreBadge = <<HoverCardContent className="max-h-[50dvh] overflow-y-auto text-xs break-normal whitespace-normal"><p className="whitespace-pre-wrap">{score.comment}</p>{"executionTraceId" in score &&- score.executionTraceId && (- <ExecutionTraceLink- executionTraceId={score.executionTraceId}- />+ score.executionTraceId &&+ projectId && (+ <div className="mt-2">+ <ExecutionTraceLink+ executionTraceId={score.executionTraceId}+ projectId={projectId}+ />+ </div>)}</HoverCardContent></HoverCard>diff --git a/web/src/components/TruncatedLabels.tsx b/web/src/components/TruncatedLabels.tsxindex d11b27a686..fe27ea0afe 100644--- a/web/src/components/TruncatedLabels.tsx+++ b/web/src/components/TruncatedLabels.tsx@@ -1,4 +1,4 @@-/* eslint-disable @repo/no-style-props, @repo/no-null-render */+/* eslint-disable @repo/no-style-props */import React from "react";import { Button } from "@/src/components/ui/button";import {@@ -42,10 +42,6 @@ export function TruncatedLabels({const hiddenLabels = sortedLabels.slice(maxVisibleLabels);const hasHiddenLabels = hiddenLabels.length > 0;- if (sortedLabels.length === 0) {- return null;- }-return (<div className={cn("flex flex-wrap gap-1", className)}>{visibleLabels.map((label) =>diff --git a/web/src/components/layouts/app-layout/hooks/useFilteredNavigation.ts b/web/src/components/layouts/app-layout/hooks/useFilteredNavigation.tsindex a3153365f7..bc0b6467f8 100644--- a/web/src/components/layouts/app-layout/hooks/useFilteredNavigation.ts+++ b/web/src/components/layouts/app-layout/hooks/useFilteredNavigation.ts@@ -21,6 +21,7 @@ import { applyNavigationFilters } from "../utils/navigationFilters";import type { NavigationFilterContext } from "../utils/navigationFilters.types";import { isPathActive } from "../utils/pathClassification";import { resolveRoutePathname } from "../utils/routePathname";+import { api } from "@/src/utils/api";/** Organization type from user session (can be null when not in project/org context) */type Organization =@@ -89,6 +90,17 @@ export function useFilteredNavigation(const entitlements = useEntitlements();const uiCustomization = useUiCustomization();const { isLangfuseCloud } = useLangfuseCloudRegion();+ const { data: cloudStatus } = api.cloudStatus.getStatus.useQuery(undefined, {+ refetchOnMount: false,+ refetchOnReconnect: false,+ refetchOnWindowFocus: false,+ // Refresh status data every 5 minutes, keep response cached for 5 minutes.+ refetchInterval: 5 * 60 * 1000,+ staleTime: 5 * 60 * 1000,+ enabled: isLangfuseCloud,+ });+ const hasActiveCloudIncident =+ cloudStatus?.status === "degraded" || cloudStatus?.status === "downtime";const routerProjectId = router.query.projectId as string | undefined;const forceV3Experience = useForceV3Experience(routerProjectId);@@ -108,6 +120,8 @@ export function useFilteredNavigation(entitlements,uiCustomization,isLangfuseCloud,+ hasActiveCloudIncident,+ forceV3Experience,currentPath: router.asPath,}),[@@ -118,6 +132,8 @@ export function useFilteredNavigation(uiCustomization,router.asPath,isLangfuseCloud,+ hasActiveCloudIncident,+ forceV3Experience,],);diff --git a/web/src/components/layouts/app-layout/index.tsx b/web/src/components/layouts/app-layout/index.tsxindex 48ecd4a993..4b26b995e1 100644--- a/web/src/components/layouts/app-layout/index.tsx+++ b/web/src/components/layouts/app-layout/index.tsx@@ -138,14 +138,14 @@ export function AppLayout(props: PropsWithChildren) {// Authenticated layout// At this point, all auth guards have passed and session.data is guaranteed to exist// The authGuard hook ensures we don't reach here without a valid session- if (!sessionData) {+ if (!sessionData?.user) {// This should never happen due to guards above, but TypeScript needs thisreturn <LoadingLayout message="Loading" />;}return (<AuthenticatedLayout- session={sessionData}+ user={sessionData.user}navigation={navigation}metadata={metadata}onSignOut={signOutCleanly}diff --git a/web/src/components/layouts/app-layout/utils/navigationFilters.ts b/web/src/components/layouts/app-layout/utils/navigationFilters.tsindex ded8951f52..90a41a0860 100644--- a/web/src/components/layouts/app-layout/utils/navigationFilters.ts+++ b/web/src/components/layouts/app-layout/utils/navigationFilters.ts@@ -170,6 +170,9 @@ const filters = {organization: organization ?? undefined,projectId: ctx.routerProjectId,isLangfuseCloud: ctx.isLangfuseCloud,+ hasActiveCloudIncident: ctx.hasActiveCloudIncident,+ canToggleV4: ctx.session?.user?.canToggleV4 === true,+ forceV3Experience: ctx.forceV3Experience,v4WriteMode: ctx.session?.environment?.v4WriteMode,v4UpgradeUiAvailable: ctx.session?.user?.v4UpgradeUiAvailable === true,})diff --git a/web/src/components/layouts/app-layout/utils/navigationFilters.types.ts b/web/src/components/layouts/app-layout/utils/navigationFilters.types.tsindex 11a1fc32ea..5172270803 100644--- a/web/src/components/layouts/app-layout/utils/navigationFilters.types.ts+++ b/web/src/components/layouts/app-layout/utils/navigationFilters.types.ts@@ -26,6 +26,10 @@ export type NavigationFilterContext = {uiCustomization: { visibleModules: string[] } | null;/** Whether the deployment is a Langfuse Cloud environment */isLangfuseCloud: boolean;+ /** Whether Langfuse Cloud currently has a degraded or downtime incident */+ hasActiveCloudIncident: boolean;+ /** Whether the current project must remain on the v3 experience */+ forceV3Experience: boolean;/** Current router path for active state detection */currentPath: string;};diff --git a/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx b/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsxindex 4bc317e5ae..87eba7f125 100644--- a/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx+++ b/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx@@ -22,7 +22,10 @@ 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 } from "@/src/features/version-update";+import {+ VersionUpdateBanner,+ useVersionUpdatePrompt,+} from "@/src/features/version-update";import { AppContentWithRightDrawer } from "../right-drawer/AppContentWithRightDrawer";import { ThemeToggle } from "@/src/features/theming/ThemeToggle";import {@@ -91,7 +94,7 @@ type GroupedNavigation = {};type AuthenticatedLayoutProps = PropsWithChildren<{- session: Session;+ user: NonNullable<Session["user"]>;navigation: {mainNavigation: GroupedNavigation;secondaryNavigation: GroupedNavigation;@@ -117,7 +120,7 @@ type AuthenticatedLayoutProps = PropsWithChildren<{*/export function AuthenticatedLayout({children,- session,+ user,navigation,metadata,onSignOut,@@ -127,18 +130,11 @@ export function AuthenticatedLayout({const router = useRouter();useProjectCookie(router);const uiCustomization = useUiCustomization();+ const versionUpdatePrompt = useVersionUpdatePrompt();// Account-level entry: use the raw flag (same as account settings tabs), not// project-scoped force-v3 suppression.const showV4Migration = useV4UpgradeUiFlag();- // Safe assertion: AuthenticatedLayout is only rendered after auth checks pass- // in AppLayout, which guarantees session.user exists at this point- const user = session.user;- if (!user) {- // This should never happen due to guards in AppLayout, but TypeScript needs this- return null;- }-const regionMenuItems = getAvailableCloudRegionOptions(currentRegion).map((region) => ({type: "action" as const,@@ -267,7 +263,12 @@ export function AuthenticatedLayout({<div className="flex h-dvh w-full flex-col"><PaymentBanner /><PreviewDeploymentBanner />- <VersionUpdateBanner />+ {versionUpdatePrompt.isVisible && (+ <VersionUpdateBanner+ onReload={versionUpdatePrompt.reload}+ onDismiss={versionUpdatePrompt.dismiss}+ />+ )}<div className="pt-banner-offset flex min-h-0 flex-1"><ConnectedAppSidebarnavItems={navigation.mainNavigation}diff --git a/web/src/components/layouts/routes.tsx b/web/src/components/layouts/routes.tsxindex c861c744ec..7d44592aca 100644--- a/web/src/components/layouts/routes.tsx+++ b/web/src/components/layouts/routes.tsx@@ -68,6 +68,9 @@ export type Route = {| undefined;projectId: string | undefined;isLangfuseCloud: boolean;+ hasActiveCloudIncident: boolean;+ canToggleV4: boolean;+ forceV3Experience: boolean;v4WriteMode: undefined | "legacy" | "dual" | "events_only"; // undefined until the session has loadedv4UpgradeUiAvailable: boolean; // deployment shows the v4 migration UI (see isV4UpgradeUiAvailable)}) => boolean;@@ -214,6 +217,8 @@ export const ROUTES: Route[] = [title: "Cloud Status",section: RouteSection.Secondary,pathname: "",+ show: ({ isLangfuseCloud, hasActiveCloudIncident }) =>+ isLangfuseCloud && hasActiveCloudIncident,menuNode: <CloudStatusMenu />,},{@@ -221,6 +226,9 @@ export const ROUTES: Route[] = [pathname: "",section: RouteSection.Secondary,featureFlag: "v4BetaToggleVisible",+ // v4-upgrade users get this toggle inside the migration panel instead.+ show: ({ canToggleV4, forceV3Experience, v4UpgradeUiAvailable }) =>+ canToggleV4 && (!v4UpgradeUiAvailable || forceV3Experience),menuNode: <V4SidebarToggle />,},{diff --git a/web/src/components/session/SessionObservationIO.tsx b/web/src/components/session/SessionObservationIO.tsxindex 4c17e13e4b..40e7c9501e 100644--- a/web/src/components/session/SessionObservationIO.tsx+++ b/web/src/components/session/SessionObservationIO.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import React from "react";import { Download, ExternalLinkIcon, Loader2 } from "lucide-react";import { Button } from "@/src/components/ui/button";@@ -52,7 +51,6 @@ const TruncatedIOSection = ({fullLength: number;truncated: boolean;}) => {- if (value === null || value === undefined || value === "") return null;const text = typeof value === "string" ? value : JSON.stringify(value);const shown =text.length > PREVIEW_DISPLAY_CHARS@@ -239,18 +237,26 @@ export const SessionObservationIO = ({This observation's input/output is too large to display in thesession view.</p>- <TruncatedIOSection- label="Input"- value={observation.input}- fullLength={observation.inputLength}- truncated={observation.inputTruncated}- />- <TruncatedIOSection- label="Output"- value={observation.output}- fullLength={observation.outputLength}- truncated={observation.outputTruncated}- />+ {observation.input !== null &&+ observation.input !== undefined &&+ observation.input !== "" && (+ <TruncatedIOSection+ label="Input"+ value={observation.input}+ fullLength={observation.inputLength}+ truncated={observation.inputTruncated}+ />+ )}+ {observation.output !== null &&+ observation.output !== undefined &&+ observation.output !== "" && (+ <TruncatedIOSection+ label="Output"+ value={observation.output}+ fullLength={observation.outputLength}+ truncated={observation.outputTruncated}+ />+ )}{/* Metadata stays visible when I/O is truncated — it shipped with theobservation and was always shown alongside I/O before the cap. */}{hasMetadataForDisplay && (diff --git a/web/src/components/session/SessionTraceActionButtons.tsx b/web/src/components/session/SessionTraceActionButtons.tsxindex dd7cfabf04..be4b09b264 100644--- a/web/src/components/session/SessionTraceActionButtons.tsx+++ b/web/src/components/session/SessionTraceActionButtons.tsx@@ -176,10 +176,12 @@ export function SessionTraceActionButtons({><span className="relative mr-1 text-xs"><ChevronDown className="h-3 w-3" />- <AnnotationQueueItemCountBadge- totalCount={totalCount}- layout="toolbar"- />+ {totalCount > 0 && (+ <AnnotationQueueItemCountBadge+ totalCount={totalCount}+ layout="toolbar"+ />+ )}</span></Button>)}diff --git a/web/src/components/session/index.tsx b/web/src/components/session/index.tsxindex 095756ba4e..2080ecaf4c 100644--- a/web/src/components/session/index.tsx+++ b/web/src/components/session/index.tsx@@ -53,7 +53,10 @@ import {} from "@langfuse/shared";import { AnnotationQueueItemDropdownMenuController } from "@/src/features/annotation-queues/components/AnnotationQueueItemDropdownMenuController";import { AnnotationQueueItemCountBadge } from "@/src/features/annotation-queues/components/AnnotationQueueItemCountBadge";-import { WebCalloutButton } from "@/src/features/web-callouts/components/WebCalloutMenuItem";+import {+ useWebCalloutAction,+ WebCalloutButton,+} from "@/src/features/web-callouts/components/WebCalloutMenuItem";import { TablePeekViewTraceDetail } from "@/src/components/table/peek/peek-trace-detail";import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";import { type WithStringifiedMetadata } from "@/src/utils/clientSideDomainTypes";@@ -382,6 +385,15 @@ export const SessionPage: React.FC<{},},);+ const webCalloutAction = useWebCalloutAction(+ {+ projectId,+ traceId: null,+ observationId: null,+ sessionId,+ },+ Boolean(session.data),+ );const [showCorrections, setShowCorrections] = useLocalStorage("showCorrections",@@ -532,12 +544,9 @@ export const SessionPage: React.FC<{),actionButtonsRight: (<>- <WebCalloutButton- projectId={projectId}- traceId={null}- observationId={null}- sessionId={sessionId}- />+ {webCalloutAction && (+ <WebCalloutButton action={webCalloutAction} />+ )}<Buttonvariant="outline"size="icon"@@ -638,10 +647,12 @@ export const SessionPage: React.FC<{><span className="relative mr-1 text-xs"><ChevronDown className="h-3 w-3" />- <AnnotationQueueItemCountBadge- totalCount={totalCount}- layout="toolbar"- />+ {totalCount > 0 && (+ <AnnotationQueueItemCountBadge+ totalCount={totalCount}+ layout="toolbar"+ />+ )}</span></Button>)}@@ -751,20 +762,18 @@ export const SessionPage: React.FC<{><ListPlus className="h-4 w-4" /><span className="text-sm">Add to queue</span>- <AnnotationQueueItemCountBadge- totalCount={totalCount}- layout="menu"- />+ {totalCount > 0 && (+ <AnnotationQueueItemCountBadge+ totalCount={totalCount}+ layout="menu"+ />+ )}</Button>)}</AnnotationQueueItemDropdownMenuController>- <WebCalloutButton- projectId={projectId}- traceId={null}- observationId={null}- sessionId={sessionId}- layout="menu"- />+ {webCalloutAction && (+ <WebCalloutButton action={webCalloutAction} layout="menu" />+ )}<Buttonvariant="ghost"size="sm"@@ -971,6 +980,15 @@ const LoadedSessionEventsPage: React.FC<{});const isMobile = useIsMobile();const parentRef = useRef<HTMLDivElement>(null);+ const webCalloutAction = useWebCalloutAction(+ {+ projectId,+ traceId: null,+ observationId: null,+ sessionId,+ },+ true,+ );const defaultPresetResolvedSessionRef = useRef<string | null>(null);const [showCorrections, setShowCorrections] = useLocalStorage(@@ -1545,12 +1563,9 @@ const LoadedSessionEventsPage: React.FC<{) : undefined,actionButtonsRight: (<>- <WebCalloutButton- projectId={projectId}- traceId={null}- observationId={null}- sessionId={sessionId}- />+ {webCalloutAction && (+ <WebCalloutButton action={webCalloutAction} />+ )}{!router.query.peek && (<DetailPageNavkey="nav"@@ -1648,10 +1663,12 @@ const LoadedSessionEventsPage: React.FC<{><span className="relative mr-1 text-xs"><ChevronDown className="h-3 w-3" />- <AnnotationQueueItemCountBadge- totalCount={totalCount}- layout="toolbar"- />+ {totalCount > 0 && (+ <AnnotationQueueItemCountBadge+ totalCount={totalCount}+ layout="toolbar"+ />+ )}</span></Button>)}@@ -1788,20 +1805,18 @@ const LoadedSessionEventsPage: React.FC<{><ListPlus className="h-4 w-4" /><span className="text-sm">Add to queue</span>- <AnnotationQueueItemCountBadge- totalCount={totalCount}- layout="menu"- />+ {totalCount > 0 && (+ <AnnotationQueueItemCountBadge+ totalCount={totalCount}+ layout="menu"+ />+ )}</Button>)}</AnnotationQueueItemDropdownMenuController>- <WebCalloutButton- projectId={projectId}- traceId={null}- observationId={null}- sessionId={sessionId}- layout="menu"- />+ {webCalloutAction && (+ <WebCalloutButton action={webCalloutAction} layout="menu" />+ )}{!isModernSessionEnabled ? (<label className="hover:bg-accent flex w-full items-center justify-between gap-4 rounded-md px-2 py-1.5"><span className="text-sm">Show corrections</span>diff --git a/web/src/components/table/peek/peek-evaluator-config-detail.tsx b/web/src/components/table/peek/peek-evaluator-config-detail.tsxindex 2cb54f839d..a4da02a825 100644--- a/web/src/components/table/peek/peek-evaluator-config-detail.tsx+++ b/web/src/components/table/peek/peek-evaluator-config-detail.tsx@@ -147,11 +147,14 @@ const PeekViewEvaluatorConfigDetail = ({) : null}</div>- <EvaluatorPausedCallout- projectId={projectId}- evalConfig={evalConfig}- allowReactivation={!readOnly}- />+ {evalConfig.blockedAt && (+ <EvaluatorPausedCallout+ projectId={projectId}+ evalConfig={evalConfig}+ blockedAt={evalConfig.blockedAt}+ allowReactivation={!readOnly}+ />+ )}<CardDescription className="flex items-center text-sm"><span className="mr-2 text-sm font-bold">Referenced Evaluator</span>diff --git a/web/src/components/table/use-cases/models.tsx b/web/src/components/table/use-cases/models.tsxindex 6ebfab651a..c19896fd5b 100644--- a/web/src/components/table/use-cases/models.tsx+++ b/web/src/components/table/use-cases/models.tsx@@ -187,6 +187,8 @@ export default function ModelTable({ projectId }: { projectId: string }) {const prices: Record<string, number> | undefined =row.getValue("prices");+ if (!prices) return;+return (<PriceBreakdownTooltipmodelName={row.original.modelName}diff --git a/web/src/components/table/use-cases/observations.tsx b/web/src/components/table/use-cases/observations.tsxindex 1735d59634..ca5ce50cc1 100644--- a/web/src/components/table/use-cases/observations.tsx+++ b/web/src/components/table/use-cases/observations.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import { api } from "@/src/utils/api";import { DataTable } from "@/src/components/table/data-table";import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";@@ -112,6 +111,7 @@ import {useObservationsTableStore,} from "@/src/features/tracing-tables/observations/ObservationsTableStoreProvider";import { useObservationsTableView } from "@/src/features/tracing-tables/observations/useObservationsTableView";+import { useStore } from "zustand";export type ObservationsTableRow = {// Shown by default@@ -207,6 +207,10 @@ export default function ObservationsTable({const { store: observationsTableStore } = useObservationsTableView({projectId,});+ const showAddToDatasetDialog = useStore(+ observationsTableStore,+ (state) => state.showAddToDatasetDialog,+ );const [rawRefreshInterval, setRawRefreshInterval] =useSessionStorage<RefreshInterval>(`tableRefreshInterval-${projectId}`,@@ -904,17 +908,17 @@ export default function ObservationsTable({enableHiding: true,enableSorting,cell: ({ row }) => {- const model = row.getValue("model") as string;+ const model = row.getValue("model") as string | null | undefined;const modelId = row.getValue("modelId") as string | undefined;- return (+ return model ? (<ProvidedModelNameCellmodelName={model}modelId={modelId}projectId={projectId}usageDetails={row.original.usageDetails}/>- );+ ) : undefined;},},createIdTableColumn<ObservationsTableRow>({@@ -1408,15 +1412,17 @@ export default function ObservationsTable({)}</div>- <ObservationsAddToDatasetDialog- projectId={projectId}- rows={rows}- backendFilterState={backendFilterState}- orderByState={orderByState}- searchQuery={searchQuery}- searchType={searchType}- totalCount={totalCount}- />+ {showAddToDatasetDialog && (+ <ObservationsAddToDatasetDialog+ projectId={projectId}+ rows={rows}+ backendFilterState={backendFilterState}+ orderByState={orderByState}+ searchQuery={searchQuery}+ searchType={searchType}+ totalCount={totalCount}+ />+ )}</>);@@ -1527,17 +1533,12 @@ function ObservationsAddToDatasetDialog({searchType: TracingSearchType[];totalCount: number | null;}) {- const showAddToDatasetDialog = useObservationsTableStore(- (state) => state.showAddToDatasetDialog,- );const selectedObservationIds = useObservationsTableStore((state) => state.selectedPageRowIds,);const selectAll = useObservationsTableStore((state) => state.selectAll);const actions = useObservationsTableStore((state) => state.actions);- if (!showAddToDatasetDialog) return null;-const firstId = selectedObservationIds[0];const firstRow = rows.find((row) => row.id === firstId);diff --git a/web/src/ee/features/billing/components/BillingDiscountView.tsx b/web/src/ee/features/billing/components/BillingDiscountView.tsxindex 4dc6524c93..cfd04796cc 100644--- a/web/src/ee/features/billing/components/BillingDiscountView.tsx+++ b/web/src/ee/features/billing/components/BillingDiscountView.tsx@@ -1,19 +1,17 @@-/* eslint-disable @repo/no-null-render */import { api } from "@/src/utils/api";import { Badge } from "@/src/components/ui/badge";-import { useBillingInformation } from "@/src/ee/features/billing/components/useBillingInformation";import { BillingDiscountCodeButton } from "@/src/ee/features/billing/components/BillingDiscountCodeButton";-export const BillingDiscountView = () => {- const { organization, billingProvider } = useBillingInformation();-- const shouldRenderComponent = Boolean(- organization?.cloudConfig?.stripe?.customerId,- );-+export const BillingDiscountView = ({+ orgId,+ hasStripeCustomer,+}: {+ orgId: string;+ hasStripeCustomer: boolean;+}) => {const { data } = api.cloudBilling.getSubscriptionInfo.useQuery(- { orgId: organization?.id ?? "" },- { enabled: Boolean(organization?.id && shouldRenderComponent) },+ { orgId },+ { enabled: hasStripeCustomer },);const discounts = data?.discounts ?? [];@@ -32,21 +30,10 @@ export const BillingDiscountView = () => {}};- // No promotion-code API on the ClickHouse Billing path yet- if (billingProvider === "clickhouse") {- return null;- }-- // Hide promotion code view and button when user is on Hobby Plan- // Hobby plan users don't have an active subscription ID- if (!organization?.cloudConfig?.stripe?.activeSubscriptionId) {- return null;- }-- if (!shouldRenderComponent) {+ if (!hasStripeCustomer) {return (<div className="flex items-center">- <BillingDiscountCodeButton orgId={organization?.id} />+ <BillingDiscountCodeButton orgId={orgId} /></div>);}@@ -69,7 +56,7 @@ export const BillingDiscountView = () => {</Badge>);})}- <BillingDiscountCodeButton orgId={organization?.id} />+ <BillingDiscountCodeButton orgId={orgId} /></div></div>);diff --git a/web/src/ee/features/billing/components/BillingSettings.tsx b/web/src/ee/features/billing/components/BillingSettings.tsxindex ce79b398f9..6205fce9d1 100644--- a/web/src/ee/features/billing/components/BillingSettings.tsx+++ b/web/src/ee/features/billing/components/BillingSettings.tsx@@ -28,7 +28,12 @@ export const BillingSettings = () => {const isCloudBillingAvailable = useIsCloudBillingAvailable();const isCloudBillingEntitled = useHasEntitlement("cloud-billing");const isSpendAlertEntitled = useHasEntitlement("cloud-spend-alerts");- const { hasActiveSubscription } = useBillingInformation();+ const { organization, billingProvider, hasActiveSubscription } =+ useBillingInformation();+ const showBillingDiscount = Boolean(+ organization?.cloudConfig?.stripe?.activeSubscriptionId &&+ billingProvider !== "clickhouse",+ );// Don't render billing settings if cloud billing is not availableif (!isCloudBillingAvailable) {@@ -60,7 +65,14 @@ export const BillingSettings = () => {<div className="space-y-6"><BillingUsageChart /><BillingPlanPeriodView />- <BillingDiscountView />+ {showBillingDiscount && organization && (+ <BillingDiscountView+ orgId={organization.id}+ hasStripeCustomer={Boolean(+ organization.cloudConfig?.stripe?.customerId,+ )}+ />+ )}<BillingActionButtons /><BillingInvoiceTable />{isSpendAlertEntitled && orgId && hasActiveSubscription && (diff --git a/web/src/features/annotation-queues/components/AnnotationQueueItemCountBadge.stories.tsx b/web/src/features/annotation-queues/components/AnnotationQueueItemCountBadge.stories.tsxindex e930b4c12b..b0cb1762ae 100644--- a/web/src/features/annotation-queues/components/AnnotationQueueItemCountBadge.stories.tsx+++ b/web/src/features/annotation-queues/components/AnnotationQueueItemCountBadge.stories.tsx@@ -21,13 +21,6 @@ export const Menu = meta.story({},});-export const Empty = meta.story({- args: {- totalCount: 0,- layout: "toolbar",- },-});-export const CountIsCapped = meta.story({name: "(Test) Caps Queue Count",args: {diff --git a/web/src/features/annotation-queues/components/AnnotationQueueItemCountBadge.tsx b/web/src/features/annotation-queues/components/AnnotationQueueItemCountBadge.tsxindex 83e342dfaf..605477f6d2 100644--- a/web/src/features/annotation-queues/components/AnnotationQueueItemCountBadge.tsx+++ b/web/src/features/annotation-queues/components/AnnotationQueueItemCountBadge.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import { cn } from "@/src/utils/tailwind";type AnnotationQueueItemCountBadgeProps = {@@ -10,8 +9,6 @@ export function AnnotationQueueItemCountBadge({totalCount,layout,}: AnnotationQueueItemCountBadgeProps) {- if (totalCount <= 0) return null;-return (<spanclassName={cn(diff --git a/web/src/features/auth/components/AuthCloudPrivacyNotice.tsx b/web/src/features/auth/components/AuthCloudPrivacyNotice.tsxindex dbb18acb42..c3fb047b4e 100644--- a/web/src/features/auth/components/AuthCloudPrivacyNotice.tsx+++ b/web/src/features/auth/components/AuthCloudPrivacyNotice.tsx@@ -1,36 +1,32 @@-/* eslint-disable @repo/no-null-render */-import { env } from "@/src/env.mjs";--export const CloudPrivacyNotice = ({ action }: { action: string }) =>- env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== undefined ? (- <div className="text-muted-foreground mx-auto mt-10 max-w-lg text-center text-xs">- By {action} you are agreeing to our{" "}- <a- href="https://clickhouse.com/legal/clickhouse-general-terms-and-conditions"- target="_blank"- rel="noopener noreferrer"- className="italic"- >- ClickHouse General Terms and Conditions- </a>- ,{" "}- <a- href="https://clickhouse.com/legal/langfuse-cloud-addendum"- target="_blank"- rel="noopener noreferrer"- className="italic"- >- Langfuse Cloud Addendum- </a>- , and{" "}- <a- href="https://langfuse.com/privacy"- target="_blank"- rel="noopener noreferrer"- className="italic"- >- Langfuse Privacy Policy- </a>- . You also confirm that the entered data is accurate.- </div>- ) : null;+export const CloudPrivacyNotice = ({ action }: { action: string }) => (+ <div className="text-muted-foreground mx-auto mt-10 max-w-lg text-center text-xs">+ By {action} you are agreeing to our{" "}+ <a+ href="https://clickhouse.com/legal/clickhouse-general-terms-and-conditions"+ target="_blank"+ rel="noopener noreferrer"+ className="italic"+ >+ ClickHouse General Terms and Conditions+ </a>+ ,{" "}+ <a+ href="https://clickhouse.com/legal/langfuse-cloud-addendum"+ target="_blank"+ rel="noopener noreferrer"+ className="italic"+ >+ Langfuse Cloud Addendum+ </a>+ , and{" "}+ <a+ href="https://langfuse.com/privacy"+ target="_blank"+ rel="noopener noreferrer"+ className="italic"+ >+ Langfuse Privacy Policy+ </a>+ . You also confirm that the entered data is accurate.+ </div>+);diff --git a/web/src/features/auth/components/AuthCloudRegionSwitch.tsx b/web/src/features/auth/components/AuthCloudRegionSwitch.tsxindex 565677976d..adf1c9b372 100644--- a/web/src/features/auth/components/AuthCloudRegionSwitch.tsx+++ b/web/src/features/auth/components/AuthCloudRegionSwitch.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import { env } from "@/src/env.mjs";import { CloudRegionPicker } from "@/src/features/auth/components/CloudRegionPicker";import { getAvailableCloudRegionOptions } from "@/src/features/organizations/cloudRegions";@@ -11,13 +10,11 @@ export function CloudRegionSwitch({isSignUpPage?: boolean;}) {const capture = usePostHogClientCapture();- const { isLangfuseCloud, region: cloudRegion } = useLangfuseCloudRegion();+ const { region: cloudRegion } = useLangfuseCloudRegion();const regions = getAvailableCloudRegionOptions(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION ?? cloudRegion,);- if (!isLangfuseCloud) return null;-const currentRegion = regions.find((region) => region.name === cloudRegion);return (diff --git a/web/src/features/automations/components/AutomationDetails.tsx b/web/src/features/automations/components/AutomationDetails.tsxindex 52ac67c208..a667b0317d 100644--- a/web/src/features/automations/components/AutomationDetails.tsx+++ b/web/src/features/automations/components/AutomationDetails.tsx@@ -38,6 +38,8 @@ export const AutomationDetails: React.FC<AutomationDetailsProps> = ({onDelete,}) => {const [isEditing, setIsEditing] = useState(false);+ const [isFailureBannerDismissed, setIsFailureBannerDismissed] =+ useState(false);const [activeTab, setActiveTab] = useQueryParam("tab",withDefault(StringParam, "executions"),@@ -57,6 +59,17 @@ export const AutomationDetails: React.FC<AutomationDetailsProps> = ({},);+ const { data: failureData } =+ api.automations.getCountOfConsecutiveFailures.useQuery(+ {+ projectId,+ automationId,+ },+ {+ enabled: Boolean(automation),+ },+ );+const handleEdit = () => {if (onEdit && automation) {onEdit(automation);@@ -146,10 +159,14 @@ export const AutomationDetails: React.FC<AutomationDetailsProps> = ({}/>- <AutomationFailureBanner- projectId={projectId}- automationId={automationId}- />+ {!isFailureBannerDismissed &&+ failureData &&+ failureData.count >= 5 && (+ <AutomationFailureBanner+ failureCount={failureData.count}+ onDismiss={() => setIsFailureBannerDismissed(true)}+ />+ )}{automation.trigger.eventSource === TriggerEventSource.Monitor ? (<AutomationFormdiff --git a/web/src/features/automations/components/AutomationFailureBanner.tsx b/web/src/features/automations/components/AutomationFailureBanner.tsxindex 4e8bab3f3c..b48a6cf1d3 100644--- a/web/src/features/automations/components/AutomationFailureBanner.tsx+++ b/web/src/features/automations/components/AutomationFailureBanner.tsx@@ -1,30 +1,16 @@-/* eslint-disable @repo/no-null-render */-import React from "react";import { AlertTriangle, X } from "lucide-react";import { Button } from "@/src/components/ui/button";import { Alert } from "@/src/components/design-system/Alert/Alert";-import { api } from "@/src/utils/api";interface AutomationFailureBannerProps {- projectId: string;- automationId: string;+ failureCount: number;+ onDismiss: () => void;}-export const AutomationFailureBanner: React.FC<- AutomationFailureBannerProps-> = ({ projectId, automationId }) => {- const [dismissed, setDismissed] = React.useState(false);-- const { data: failureData } =- api.automations.getCountOfConsecutiveFailures.useQuery({- projectId,- automationId,- });-- if (dismissed || !failureData || failureData.count < 5) {- return null;- }-+export const AutomationFailureBanner = ({+ failureCount,+ onDismiss,+}: AutomationFailureBannerProps) => {return (<div className="mb-4"><Alert variant="destructive" icon={AlertTriangle}>@@ -33,7 +19,7 @@ export const AutomationFailureBanner: React.FC<<div className="flex-1"><strong>This automation was automatically disabled due to at least{" "}- {failureData.count} consecutive webhook failures.+ {failureCount} consecutive webhook failures.</strong><div className="mt-2 text-sm">Check the execution history below, fix any issues with your@@ -43,7 +29,7 @@ export const AutomationFailureBanner: React.FC<<Buttonvariant="ghost"size="sm"- onClick={() => setDismissed(true)}+ onClick={onDismiss}className="ml-4 h-6 w-6 p-0"><X className="h-4 w-4" />diff --git a/web/src/features/blobstorage-integration/components/BlobStorageIntegrationForm.tsx b/web/src/features/blobstorage-integration/components/BlobStorageIntegrationForm.tsxindex db2044afe3..be65d11888 100644--- a/web/src/features/blobstorage-integration/components/BlobStorageIntegrationForm.tsx+++ b/web/src/features/blobstorage-integration/components/BlobStorageIntegrationForm.tsx@@ -1,10 +1,11 @@import { useMemo, type ReactNode } from "react";-import { useForm } from "react-hook-form";+import { useForm, useWatch } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";import { Button } from "@/src/components/ui/button";import {Form,FormControl,+ FormDescription,FormField,FormItem,FormLabel,@@ -13,6 +14,7 @@ import {import { Switch } from "@/src/components/design-system/Switch/Switch";import {type AnalyticsIntegrationExportSource,+ BlobStorageIntegrationFileType,type ExportSourceContext,} from "@langfuse/shared";import {@@ -25,7 +27,6 @@ import { StorageProviderFields } from "@/src/features/blobstorage-integration/coimport { ExportScheduleFields } from "@/src/features/blobstorage-integration/components/ExportScheduleFields";import { ExportSourceField } from "@/src/features/blobstorage-integration/components/ExportSourceField";import { ExportFieldGroupsField } from "@/src/features/blobstorage-integration/components/ExportFieldGroupsField";-import { GzipCompressionField } from "@/src/features/blobstorage-integration/components/GzipCompressionField";// Disposable draft layer. The container mounts one instance per entity// identity (project + config existence, via React key) after all async@@ -76,6 +77,7 @@ export const BlobStorageIntegrationForm = ({});const control = blobStorageForm.control;+ const fileType = useWatch({ control, name: "fileType" });return (<Form {...blobStorageForm}>@@ -91,7 +93,31 @@ export const BlobStorageIntegrationForm = ({exportSourceCtx={exportSourceCtx}/><ExportFieldGroupsField control={control} />- <GzipCompressionField control={control} />+ {/* Parquet compresses internally — gzip does not apply. */}+ {fileType !== BlobStorageIntegrationFileType.PARQUET && (+ <FormField+ control={control}+ name="compressed"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Gzip Compression</FormLabel>+ <FormControl>+ <div className="mt-1 ml-4">+ <Switch+ checked={field.value}+ onCheckedChange={field.onChange}+ />+ </div>+ </FormControl>+ <FormDescription>+ Compress exported files with gzip (.csv.gz, .json.gz,+ .jsonl.gz)+ </FormDescription>+ <FormMessage />+ </FormItem>+ )}+ />+ )}<FormFieldcontrol={control}name="enabled"diff --git a/web/src/features/blobstorage-integration/components/GzipCompressionField.tsx b/web/src/features/blobstorage-integration/components/GzipCompressionField.tsxdeleted file mode 100644index 44d04a0cc5..0000000000--- a/web/src/features/blobstorage-integration/components/GzipCompressionField.tsx+++ /dev/null@@ -1,44 +0,0 @@-/* eslint-disable @repo/no-null-render */-import { useWatch } from "react-hook-form";-import {- FormControl,- FormDescription,- FormField,- FormItem,- FormLabel,- FormMessage,-} from "@/src/components/ui/form";-import { Switch } from "@/src/components/design-system/Switch/Switch";-import { BlobStorageIntegrationFileType } from "@langfuse/shared";-import { type BlobStorageFormControl } from "@/src/features/blobstorage-integration/components/formValues";--export const GzipCompressionField = ({- control,-}: {- control: BlobStorageFormControl;-}) => {- const watchedFileType = useWatch({ control, name: "fileType" });- // Parquet compresses internally — gzip does not apply.- if (watchedFileType === BlobStorageIntegrationFileType.PARQUET) return null;-- return (- <FormField- control={control}- name="compressed"- render={({ field }) => (- <FormItem>- <FormLabel>Gzip Compression</FormLabel>- <FormControl>- <div className="mt-1 ml-4">- <Switch checked={field.value} onCheckedChange={field.onChange} />- </div>- </FormControl>- <FormDescription>- Compress exported files with gzip (.csv.gz, .json.gz, .jsonl.gz)- </FormDescription>- <FormMessage />- </FormItem>- )}- />- );-};diff --git a/web/src/features/chart-view/EventsChartView.tsx b/web/src/features/chart-view/EventsChartView.tsxindex 9f4fa43f7a..a773ed09ab 100644--- a/web/src/features/chart-view/EventsChartView.tsx+++ b/web/src/features/chart-view/EventsChartView.tsx@@ -7,6 +7,7 @@ import { chartConfigToWidgetInput } from "./lib/chartConfigToWidget";import { toChartFilters } from "./lib/chartFilterCompatibility";import { ChartViewPanel } from "./components/ChartViewPanel";import { AddToDashboardButton } from "./components/AddToDashboardButton";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";/*** Production chart view for the v4 events table. Builds the observations@@ -30,6 +31,10 @@ export function EventsChartView({config: ChartViewConfig;onConfigChange: (patch: Partial<ChartViewConfig>) => void;}) {+ const canManageDashboards = useHasProjectAccess({+ projectId,+ scope: "dashboards:CUD",+ });const filters = useMemo(() => toChartFilters(filterState), [filterState]);const query = useMemo(@@ -76,7 +81,12 @@ export function EventsChartView({isLoading={validRange && queryResult.isPending && !queryResult.isError}error={error}chartActions={- <AddToDashboardButton projectId={projectId} widgetInput={widgetInput} />+ canManageDashboards && (+ <AddToDashboardButton+ projectId={projectId}+ widgetInput={widgetInput}+ />+ )}/>);diff --git a/web/src/features/chart-view/components/AddToDashboardButton.tsx b/web/src/features/chart-view/components/AddToDashboardButton.tsxindex 7c234dd0ad..d905d0425f 100644--- a/web/src/features/chart-view/components/AddToDashboardButton.tsx+++ b/web/src/features/chart-view/components/AddToDashboardButton.tsx@@ -1,11 +1,9 @@-/* eslint-disable @repo/no-null-render */-import { showErrorToast } from "@/src/features/notifications";import React, { useCallback, useState } from "react";import { useRouter } from "next/router";import { LayoutDashboard } from "lucide-react";import { Button } from "@/src/components/ui/button";import { api } from "@/src/utils/api";-import { useHasProjectAccess } from "@/src/features/rbac";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { SelectDashboardDialog } from "@/src/features/dashboard/components/SelectDashboardDialog";import { type ChartWidgetInput } from "../lib/chartConfigToWidget";@@ -32,7 +30,6 @@ export const AddToDashboardButton = React.memo(function AddToDashboardButton({}) {const router = useRouter();const [open, setOpen] = useState(false);- const hasAccess = useHasProjectAccess({ projectId, scope: "dashboards:CUD" });const createWidget = api.dashboardWidgets.create.useMutation();const onSelectDashboard = useCallback(@@ -58,8 +55,6 @@ export const AddToDashboardButton = React.memo(function AddToDashboardButton({[createWidget, projectId, widgetInput, router],);- if (!hasAccess) return null;-return (<><Buttondiff --git a/web/src/features/cloud-status-notification/components/CloudStatusMenu.tsx b/web/src/features/cloud-status-notification/components/CloudStatusMenu.tsxindex e053c87fdb..ca8db7f585 100644--- a/web/src/features/cloud-status-notification/components/CloudStatusMenu.tsx+++ b/web/src/features/cloud-status-notification/components/CloudStatusMenu.tsx@@ -1,35 +1,7 @@-/* eslint-disable @repo/no-null-render */-import { api } from "@/src/utils/api";import Link from "next/link";import { SidebarMenuButton } from "@/src/components/ui/sidebar";-import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";export function CloudStatusMenu() {- const { isLangfuseCloud } = useLangfuseCloudRegion();- const { data, isLoading } = api.cloudStatus.getStatus.useQuery(undefined, {- refetchOnMount: false,- refetchOnReconnect: false,- refetchOnWindowFocus: false,- // Refresh status data every 5 minutes, keep response cached for 5 minutes- refetchInterval: 5 * 60 * 1000,- staleTime: 5 * 60 * 1000,- enabled: !!isLangfuseCloud,- });-- // Skip component rendering if not running on Langfuse Cloud- if (!isLangfuseCloud) {- return null;- }-- // Only show during an actual incident; maintenance (incl. scheduled)- // isn't worth a nav item- if (- isLoading ||- (data?.status !== "degraded" && data?.status !== "downtime")- ) {- return null;- }-return (<SidebarMenuButton asChild tooltip="Active incident"><Linkdiff --git a/web/src/features/comments/CommentCountIcon.tsx b/web/src/features/comments/CommentCountIcon.tsxindex 3b98396716..a8df249da1 100644--- a/web/src/features/comments/CommentCountIcon.tsx+++ b/web/src/features/comments/CommentCountIcon.tsx@@ -1,11 +1,6 @@-/* eslint-disable @repo/no-null-render */-// LFE-7628: general comment counts use the square speech bubble, matching the-// CommentDrawerController, to stay distinct from per-score comment indicators.import { MessageSquareMore } from "lucide-react";-export function CommentCountIcon({ count }: { count?: number }) {- if (!count) return null;-+export function CommentCountIcon({ count }: { count: number }) {return (// The count overlaps the bubble's corner by a negative margin rather than by// `absolute`: positioned absolutely it sat OUTSIDE this span's own box, so itdiff --git a/web/src/features/comments/ReactionBar.tsx b/web/src/features/comments/ReactionBar.tsxindex 6d7ac0f868..4bfd1e5e77 100644--- a/web/src/features/comments/ReactionBar.tsx+++ b/web/src/features/comments/ReactionBar.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import { Button } from "@/src/components/ui/button";import {HoverCard,@@ -24,13 +23,9 @@ export function ReactionBar({commentId,});- if (!reactions || reactions.length === 0) {- return null;- }-return (<div className="flex flex-wrap items-center gap-1">- {reactions.map((reaction) => {+ {(reactions ?? []).map((reaction) => {const button = (<Buttontype="button"diff --git a/web/src/features/comments/components/InlineCommentBubble.tsx b/web/src/features/comments/components/InlineCommentBubble.tsxindex 7e23f3d08d..314ec8e2ba 100644--- a/web/src/features/comments/components/InlineCommentBubble.tsx+++ b/web/src/features/comments/components/InlineCommentBubble.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render *//*** InlineCommentBubble - floating button shown when text is selected in JSON view*@@ -6,41 +5,17 @@*/import { Button } from "@/src/components/ui/button";-import { useInlineCommentSelectionOptional } from "../contexts/InlineCommentSelectionContext";import { MessageSquarePlus } from "lucide-react";-import { useEffect, useState } from "react";interface InlineCommentBubbleProps {onAddComment: () => void;+ positionRect: DOMRect;}export function InlineCommentBubble({onAddComment,+ positionRect,}: InlineCommentBubbleProps) {- const context = useInlineCommentSelectionOptional();- const [position, setPosition] = useState<{- top: number;- left: number;- } | null>(null);-- useEffect(() => {- const selection = context?.selection;- if (!selection?.anchorRect) {- setPosition(null);- return;- }-- // Use startRect if available (position of selection start), fallback to anchorRect- const posRect = selection.startRect ?? selection.anchorRect;- // Position just above where the selection starts- setPosition({- top: posRect.top - 6,- left: posRect.left,- });- }, [context?.selection]);-- if (!context?.selection || !position) return null;-const handleClick = () => {onAddComment();};@@ -49,8 +24,8 @@ export function InlineCommentBubble({<divstyle={{position: "fixed",- top: position.top,- left: position.left,+ top: positionRect.top - 6,+ left: positionRect.left,transform: "translateY(-100%)",zIndex: 50,}}diff --git a/web/src/features/datasets/components/DatasetItemFieldSchemaErrors.tsx b/web/src/features/datasets/components/DatasetItemFieldSchemaErrors.tsxindex 49983a1d42..3a5334afd8 100644--- a/web/src/features/datasets/components/DatasetItemFieldSchemaErrors.tsx+++ b/web/src/features/datasets/components/DatasetItemFieldSchemaErrors.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import { AlertCircle } from "lucide-react";type DatasetError = {@@ -19,8 +18,6 @@ type DatasetItemFieldSchemaErrorsProps = {export const DatasetItemFieldSchemaErrors: React.FC<DatasetItemFieldSchemaErrorsProps> = ({ errors, showDatasetName = false }) => {- if (errors.length === 0) return null;-return (<div className="border-destructive/50 bg-destructive/10 rounded-md border p-3"><div className="flex items-start gap-2">diff --git a/web/src/features/evals/components/eval-template-type-selector.tsx b/web/src/features/evals/components/eval-template-type-selector.tsxindex 99b9fed0df..1a5932bbe5 100644--- a/web/src/features/evals/components/eval-template-type-selector.tsx+++ b/web/src/features/evals/components/eval-template-type-selector.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import { useRef } from "react";import { type UseFormReturn } from "react-hook-form";import { type z } from "zod";@@ -40,13 +39,11 @@ export function EvalTemplateTypeSelector({form,codeEvalCapabilities,mode,- hasExistingTemplate,onChange,}: {form: EvalTemplateFormReturn;codeEvalCapabilities: CodeEvalCapabilities;- mode: EvalTemplateTypeSelectorMode;- hasExistingTemplate: boolean;+ mode: Exclude<EvalTemplateTypeSelectorMode, "hidden">;onChange?: () => void;}) {const sourceCodeDraftsRef = useRef<CodeEvalSourceDrafts>({});@@ -54,11 +51,6 @@ export function EvalTemplateTypeSelector({const sourceCodeLanguage =form.watch("sourceCodeLanguage") ??EvalTemplateSourceCodeLanguage.TYPESCRIPT;- const shouldShow =- codeEvalCapabilities.enabled && !hasExistingTemplate && mode !== "hidden";-- if (!shouldShow) return null;-const selectedValue =evalTemplateType === EvalTemplateType.CODE? sourceCodeLanguagediff --git a/web/src/features/evals/components/evaluator-detail.tsx b/web/src/features/evals/components/evaluator-detail.tsxindex f3d0ae727f..eceacd2052 100644--- a/web/src/features/evals/components/evaluator-detail.tsx+++ b/web/src/features/evals/components/evaluator-detail.tsx@@ -156,6 +156,7 @@ export const EvaluatorDetail = () => {<EvaluatorPausedCalloutprojectId={projectId}evalConfig={existingEvaluator}+ blockedAt={existingEvaluator.blockedAt}allowReactivation/></div>diff --git a/web/src/features/evals/components/evaluator-paused-callout.tsx b/web/src/features/evals/components/evaluator-paused-callout.tsxindex 8019397446..4011f6bd7e 100644--- a/web/src/features/evals/components/evaluator-paused-callout.tsx+++ b/web/src/features/evals/components/evaluator-paused-callout.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import { Button } from "@/src/components/ui/button";import { showErrorToast, showSuccessToast } from "@/src/features/notifications";import { api } from "@/src/utils/api";@@ -18,10 +17,8 @@ import { Fragment } from "react";type EvaluatorPausedCalloutProps = {projectId: string;allowReactivation: boolean;- evalConfig: Pick<- JobConfiguration,- "id" | "blockedAt" | "blockReason" | "blockMessage"- > & {+ blockedAt: NonNullable<JobConfiguration["blockedAt"]>;+ evalConfig: Pick<JobConfiguration, "id" | "blockReason" | "blockMessage"> & {evalTemplate?: Pick<EvalTemplate, "id"> | null;};};@@ -52,6 +49,7 @@ function getResolutionActionLabel(params: {export function EvaluatorPausedCallout({projectId,allowReactivation,+ blockedAt,evalConfig,}: EvaluatorPausedCalloutProps) {const utils = api.useUtils();@@ -70,10 +68,6 @@ export function EvaluatorPausedCallout({},});- if (!evalConfig.blockedAt) {- return null;- }-const blockReason =evalConfig.blockReason ?? EvaluatorBlockReason.EVAL_MODEL_CONFIG_INVALID;const blockMetadata = getEvaluatorBlockMetadata(blockReason);@@ -87,10 +81,10 @@ export function EvaluatorPausedCallout({templateId: evalConfig.evalTemplate?.id,});const blockMessage = evalConfig.blockMessage ?? DEFAULT_BLOCK_MESSAGE;- const blockedAt = new Date(evalConfig.blockedAt);- const blockedAtLabel = Number.isNaN(blockedAt.getTime())+ const blockedAtDate = new Date(blockedAt);+ const blockedAtLabel = Number.isNaN(blockedAtDate.getTime())? null- : formatDistanceToNow(blockedAt, { addSuffix: true });+ : formatDistanceToNow(blockedAtDate, { addSuffix: true });return (<section@@ -114,7 +108,7 @@ export function EvaluatorPausedCallout({{blockedAtLabel ? (<Fragment><span className="bg-border h-1 w-1 rounded-full" />- <span title={blockedAt.toLocaleString()}>+ <span title={blockedAtDate.toLocaleString()}>Paused {blockedAtLabel}</span></Fragment>diff --git a/web/src/features/evals/components/template-form.tsx b/web/src/features/evals/components/template-form.tsxindex 23adfa81d9..a344a5c42e 100644--- a/web/src/features/evals/components/template-form.tsx+++ b/web/src/features/evals/components/template-form.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import { useState } from "react";import Link from "next/link";import { useFieldArray, useForm } from "react-hook-form";@@ -76,10 +75,7 @@ import {type EvalTemplateTypeSelectorMode,} from "@/src/features/evals/components/eval-template-type-selector";import { Alert } from "@/src/components/design-system/Alert/Alert";-import {- useEvalCapabilities,- type EvalCapabilities,-} from "@/src/features/evals/hooks/useEvalCapabilities";+import { useEvalCapabilities } from "@/src/features/evals/hooks/useEvalCapabilities";type PartialEvalTemplate = Partial<EvalTemplate> &Pick<EvalTemplate, "name" | "prompt" | "vars" | "outputDefinition">;@@ -599,22 +595,52 @@ const InnerEvalTemplateForm = (props: {</>) : undefined}- <EvalTemplateTypeSelector- form={form}- codeEvalCapabilities={codeEvalCapabilities}- mode={templateTypeSelectorMode}- hasExistingTemplate={Boolean(props.existingEvalTemplateId)}- onChange={() => {- resetCodeEvalSourceValidation();- setFormError(null);- }}- />+ {codeEvalCapabilities.enabled &&+ !props.existingEvalTemplateId &&+ templateTypeSelectorMode !== "hidden" && (+ <EvalTemplateTypeSelector+ form={form}+ codeEvalCapabilities={codeEvalCapabilities}+ mode={templateTypeSelectorMode}+ onChange={() => {+ resetCodeEvalSourceValidation();+ setFormError(null);+ }}+ />+ )}{showCodeTemplateForm ? (<div className="space-y-3">- {props.isEditing ? (- <CodeEvalSdkVersionCallout evalCapabilities={evalCapabilities} />- ) : null}+ {props.isEditing &&+ !evalCapabilities.isLoading &&+ evalCapabilities.compatibilityCheckWasPerformed &&+ !evalCapabilities.isNewCompatible && (+ <div className="w-full max-w-4xl">+ <Alert variant="warning" icon={AlertTriangle}>+ <Alert.Description>+ <div className="flex flex-col gap-1">+ <span className="text-foreground font-bold">+ Please verify your SDK version+ </span>+ <span className="text-foreground text-sm">+ Code evaluators require JS SDK v4+ or Python SDK v3+.+ You can create this evaluator now, but it will only run+ once your project ingests data with a compatible SDK.{" "}+ <a+ href="https://langfuse.com/docs/observability/sdk/upgrade-path"+ target="_blank"+ rel="noopener noreferrer"+ className="text-dark-blue font-bold hover:opacity-80"+ >+ Learn more+ </a>+ .+ </span>+ </div>+ </Alert.Description>+ </Alert>+ </div>+ )}<FormFieldcontrol={form.control}name="sourceCode"@@ -741,9 +767,11 @@ const InnerEvalTemplateForm = (props: {/></FormControl><FormMessage />- <PromptVariableListPreview- variables={extractedVariables ?? []}- />+ {extractedVariables?.length ? (+ <PromptVariableListPreview+ variables={extractedVariables}+ />+ ) : null}</FormItem></>)}@@ -1008,45 +1036,3 @@ const InnerEvalTemplateForm = (props: {</Form>);};--function CodeEvalSdkVersionCallout({- evalCapabilities,-}: {- evalCapabilities: EvalCapabilities;-}) {- if (- evalCapabilities.isLoading ||- !evalCapabilities.compatibilityCheckWasPerformed ||- evalCapabilities.isNewCompatible- ) {- return null;- }-- return (- <div className="w-full max-w-4xl">- <Alert variant="warning" icon={AlertTriangle}>- <Alert.Description>- <div className="flex flex-col gap-1">- <span className="text-foreground font-bold">- Please verify your SDK version- </span>- <span className="text-foreground text-sm">- Code evaluators require JS SDK v4+ or Python SDK v3+. You can- create this evaluator now, but it will only run once your project- ingests data with a compatible SDK.{" "}- <a- href="https://langfuse.com/docs/observability/sdk/upgrade-path"- target="_blank"- rel="noopener noreferrer"- className="text-dark-blue font-bold hover:opacity-80"- >- Learn more- </a>- .- </span>- </div>- </Alert.Description>- </Alert>- </div>- );-}diff --git a/web/src/features/evals/pages/new-template.tsx b/web/src/features/evals/pages/new-template.tsxindex dbfb2a8ab3..0df8cefdfe 100644--- a/web/src/features/evals/pages/new-template.tsx+++ b/web/src/features/evals/pages/new-template.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import Page from "@/src/components/layouts/page";import { EvalTemplateForm } from "@/src/features/evals/components/template-form";import { useHasProjectAccess } from "@/src/features/rbac";@@ -14,7 +13,7 @@ export default function NewTemplatesPage() {});if (!hasAccess) {- return null;+ return <div>You do not have access to this page.</div>;}return (diff --git a/web/src/features/evals/pages/templates.tsx b/web/src/features/evals/pages/templates.tsxindex 76199b7b8f..79ff84948b 100644--- a/web/src/features/evals/pages/templates.tsx+++ b/web/src/features/evals/pages/templates.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import Page from "@/src/components/layouts/page";import { useRouter } from "next/router";import { Button } from "@/src/components/ui/button";@@ -29,7 +28,7 @@ export default function TemplatesPage() {});if (!hasReadAccess) {- return null;+ return <div>You do not have access to this page.</div>;}return (diff --git a/web/src/features/events/components/EventsTable.tsx b/web/src/features/events/components/EventsTable.tsxindex 524bae2a0a..1d15d5ff04 100644--- a/web/src/features/events/components/EventsTable.tsx+++ b/web/src/features/events/components/EventsTable.tsx@@ -1414,17 +1414,20 @@ export default function ObservationsEventsTable({enableHiding: true,enableSorting,cell: ({ row }) => {- const model = row.getValue("providedModelName") as string;+ const model = row.getValue("providedModelName") as+ | string+ | null+ | undefined;const modelId = row.getValue("modelId") as string | undefined;- return (+ return model ? (<ProvidedModelNameCellmodelName={model}modelId={modelId}projectId={projectId}usageDetails={row.original.usageDetails}/>- );+ ) : undefined;},},createIdTableColumn<EventsTableRow>({diff --git a/web/src/features/events/components/V4SidebarToggle.tsx b/web/src/features/events/components/V4SidebarToggle.tsxindex 358872aa69..53c829b584 100644--- a/web/src/features/events/components/V4SidebarToggle.tsx+++ b/web/src/features/events/components/V4SidebarToggle.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import { Switch } from "@/src/components/design-system/Switch/Switch";import { Label } from "@/src/components/ui/label";import { SidebarMenuButton } from "@/src/components/ui/sidebar";@@ -12,12 +11,10 @@ import { setReadPath } from "@/src/features/events/actions/setReadPath";import { usePendingReadPath } from "@/src/features/events/stores/readPathToggleStore";import { V4IntroDialog } from "@/src/features/events/components/V4IntroDialog";import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { useV4UpgradeUiEnabled } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";import {getV4PreviewDisabledRedirect,getV4PreviewEnabledRedirect,} from "@/src/features/events/lib/v4PreviewRedirect";-import { useQueryProject } from "@/src/features/projects/hooks";import { api } from "@/src/utils/api";import { ZapIcon } from "lucide-react";import { useId, useState } from "react";@@ -51,7 +48,7 @@ const INTRO_DIALOG_SEEN_KEY = "v4-beta-intro-dialog-seen";// shared `setReadPath` workflow; only the intro dialog lives here.function useV4PreviewToggle(source: "sidebar" | "migration_panel") {const router = useRouter();- const { isV4, canToggleV4 } = useReadPath();+ const { isV4 } = useReadPath();const pendingReadPath = usePendingReadPath();const { update: updateSession } = useSession();const mutation = api.userAccount.setV4BetaEnabled.useMutation();@@ -157,7 +154,6 @@ function useV4PreviewToggle(source: "sidebar" | "migration_panel") {return {isChecked,- canToggleV4,isLoading,handleToggle,showIntroDialog,@@ -169,20 +165,12 @@ function useV4PreviewToggle(source: "sidebar" | "migration_panel") {export function V4SidebarToggle() {const {isChecked,- canToggleV4,isLoading,handleToggle,showIntroDialog,confirmIntroDialog,dismissIntroDialog,} = useV4PreviewToggle("sidebar");- const { project } = useQueryProject();- const v4UpgradeUiEnabled = useV4UpgradeUiEnabled(project?.id);-- // v4-upgrade users get this toggle inside the migration panel instead.- if (!canToggleV4 || v4UpgradeUiEnabled) {- return null;- }return (<>@@ -245,7 +233,6 @@ export function V4PreviewToggleRow({ projectId }: { projectId?: string }) {const descriptionId = useId();const {isChecked,- canToggleV4,isLoading,handleToggle,showIntroDialog,@@ -253,10 +240,6 @@ export function V4PreviewToggleRow({ projectId }: { projectId?: string }) {dismissIntroDialog,} = useV4PreviewToggle("migration_panel");- if (!canToggleV4) {- return null;- }-const handlePanelToggle = (enabled: boolean) => {handleToggle(enabled,diff --git a/web/src/features/experiments/components/CreateExperimentsForm.tsx b/web/src/features/experiments/components/CreateExperimentsForm.tsxindex f0cf13ac3e..321c732058 100644--- a/web/src/features/experiments/components/CreateExperimentsForm.tsx+++ b/web/src/features/experiments/components/CreateExperimentsForm.tsx@@ -86,6 +86,10 @@ export const CreateExperimentsForm = ({projectId,scope: "promptExperiments:CUD",});+ const hasDatasetAccess = useHasProjectAccess({+ projectId,+ scope: "datasets:CUD",+ });const fixedDatasetId = defaultValues.datasetId;const [remoteExperimentDataset, setRemoteExperimentDataset] = useState<{ id: string; name?: string } | undefined@@ -306,14 +310,25 @@ export const CreateExperimentsForm = ({<div className="flex w-full items-start"><ButtonclassName="w-full rounded-r-none"- disabled={!datasetId || !isRemoteExperimentEnabled}+ disabled={+ !datasetId ||+ !isRemoteExperimentEnabled ||+ !hasDatasetAccess+ }title={- isRemoteExperimentEnabled- ? undefined- : "please edit and enable webhook"+ !hasDatasetAccess+ ? "You do not have permission to run remote experiments"+ : isRemoteExperimentEnabled+ ? undefined+ : "please edit and enable webhook"}onClick={() => {- if (!datasetId || !isRemoteExperimentEnabled) return;+ if (+ !datasetId ||+ !isRemoteExperimentEnabled ||+ !hasDatasetAccess+ )+ return;setShowRemoteExperimentTriggerModal(true);}}>@@ -366,7 +381,8 @@ export const CreateExperimentsForm = ({if (showRemoteExperimentTriggerModal &&datasetId &&- existingRemoteExperiment.data+ existingRemoteExperiment.data &&+ hasDatasetAccess) {return (<RemoteExperimentTriggerModaldiff --git a/web/src/features/experiments/components/ExperimentMetadataSection.tsx b/web/src/features/experiments/components/ExperimentMetadataSection.tsxindex ffe27b771a..15bfee3e79 100644--- a/web/src/features/experiments/components/ExperimentMetadataSection.tsx+++ b/web/src/features/experiments/components/ExperimentMetadataSection.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import { PrettyJsonView } from "@/src/components/ui/PrettyJsonView";import {Collapsible,@@ -11,12 +10,10 @@ import { useState } from "react";export const ExperimentMetadataSection = ({metadata,}: {- metadata: Record<string, unknown> | undefined;+ metadata: Record<string, unknown>;}) => {const [isOpen, setIsOpen] = useState(false);- if (Object.keys(metadata ?? {}).length === 0) return null;-return (<Collapsible open={isOpen} onOpenChange={setIsOpen}><div className="border-t pt-4">diff --git a/web/src/features/experiments/components/ExperimentOverviewPanel.tsx b/web/src/features/experiments/components/ExperimentOverviewPanel.tsxindex 0c61c1074b..3a0c5499af 100644--- a/web/src/features/experiments/components/ExperimentOverviewPanel.tsx+++ b/web/src/features/experiments/components/ExperimentOverviewPanel.tsx@@ -60,6 +60,7 @@ export function ExperimentOverviewPanel({}if (safePullRequestUrl) delete additionalMetadata["langfuse.pr_url"];if (safeGithubJobUrl) delete additionalMetadata["langfuse.github_job_url"];+ const hasAdditionalMetadata = Object.keys(additionalMetadata).length > 0;// Get the first prompt name and version from the prompts arrayconst [promptName, promptVersion] =@@ -179,7 +180,9 @@ export function ExperimentOverviewPanel({</div></div>- <ExperimentMetadataSection metadata={additionalMetadata} />+ {hasAdditionalMetadata && (+ <ExperimentMetadataSection metadata={additionalMetadata} />+ )}</>) : (<p className="text-muted-foreground text-sm">diff --git a/web/src/features/experiments/components/RemoteExperimentTriggerModal.tsx b/web/src/features/experiments/components/RemoteExperimentTriggerModal.tsxindex b7db894b15..a927c79c66 100644--- a/web/src/features/experiments/components/RemoteExperimentTriggerModal.tsx+++ b/web/src/features/experiments/components/RemoteExperimentTriggerModal.tsx@@ -1,5 +1,3 @@-/* eslint-disable @repo/no-null-render */-import { showSuccessToast, showErrorToast } from "@/src/features/notifications";import React from "react";import { useForm } from "react-hook-form";import { zodResolver } from "@hookform/resolvers/zod";@@ -23,7 +21,8 @@ import {} from "@/src/components/ui/form";import { CodeMirrorEditor } from "@/src/components/editor/CodeMirrorEditor";import { api } from "@/src/utils/api";-import { useHasProjectAccess } from "@/src/features/rbac";+import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";+import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { getFormattedPayload } from "@/src/features/experiments/utils/format";import { type Prisma } from "@langfuse/shared";import Spinner from "@/src/components/design-system/Spinner/Spinner";@@ -50,11 +49,6 @@ export const RemoteExperimentTriggerModal = ({};setShowTriggerModal: (show: boolean) => void;}) => {- const hasDatasetAccess = useHasProjectAccess({- projectId,- scope: "datasets:CUD",- });-const dataset = api.datasets.byId.useQuery({projectId,datasetId,@@ -112,10 +106,6 @@ export const RemoteExperimentTriggerModal = ({});};- if (!hasDatasetAccess) {- return null;- }-return (<><DialogHeader>diff --git a/web/src/features/in-app-agent/components/InAppAgentActivityCards.stories.tsx b/web/src/features/in-app-agent/components/InAppAgentActivityCards.stories.tsxindex ffc356fe4a..2492dba338 100644--- a/web/src/features/in-app-agent/components/InAppAgentActivityCards.stories.tsx+++ b/web/src/features/in-app-agent/components/InAppAgentActivityCards.stories.tsx@@ -20,12 +20,9 @@ const meta = preview.meta({args: {onOpen: fn(),onDismiss: fn(),- cards: [],},});-export const Empty = meta.story({});-export const ApprovalRequired = meta.story({args: {cards: [diff --git a/web/src/features/in-app-agent/components/InAppAgentActivityCards.tsx b/web/src/features/in-app-agent/components/InAppAgentActivityCards.tsxindex 0218f007f1..b6d555f75a 100644--- a/web/src/features/in-app-agent/components/InAppAgentActivityCards.tsx+++ b/web/src/features/in-app-agent/components/InAppAgentActivityCards.tsx@@ -1,19 +1,9 @@-/* eslint-disable @repo/no-null-render */import { BotMessageSquare, X } from "lucide-react";import { Button } from "@/src/components/ui/button";import { cn } from "@/src/utils/tailwind";import type { InAppAgentActivityState } from "@/src/features/in-app-agent/lib/inAppAgentActivity";-/** Approvals first: a question outranks a result the user can read later. */-const CARD_PRIORITY: Record<string, number> = {- approval: 0,- "failed-unread": 1,- "done-unread": 2,-};--const MAX_VISIBLE_CARDS = 3;-export type InAppAgentActivityCard = {conversationId: string;activityKey: string;@@ -22,16 +12,6 @@ export type InAppAgentActivityCard = {state: Exclude<InAppAgentActivityState, "running">;};-export function selectInAppAgentActivityCards(- cards: readonly InAppAgentActivityCard[],-): InAppAgentActivityCard[] {- return [...cards]- .sort(- (a, b) => (CARD_PRIORITY[a.state] ?? 9) - (CARD_PRIORITY[b.state] ?? 9),- )- .slice(0, MAX_VISIBLE_CARDS);-}-function getCardCopy(state: InAppAgentActivityCard["state"]) {// Lead with "Assistant" so the toast reads as the same product as the// launcher (BotMessageSquare), not a generic system alert.@@ -55,19 +35,13 @@ export function InAppAgentActivityCards({onOpen,onDismiss,}: {- cards: readonly InAppAgentActivityCard[];+ cards: readonly [InAppAgentActivityCard, ...InAppAgentActivityCard[]];onOpen: (card: InAppAgentActivityCard) => void;onDismiss: (card: InAppAgentActivityCard) => void;}) {- const visible = selectInAppAgentActivityCards(cards);-- if (visible.length === 0) {- return null;- }-return (<div className="top-banner-offset pointer-events-none fixed right-4 flex w-80 flex-col gap-2 pt-4">- {visible.map((card) => {+ {cards.map((card) => {const { label, tone } = getCardCopy(card.state);const conversationTitle = card.title?.trim() || "Untitled conversation";diff --git a/web/src/features/in-app-agent/components/InAppAgentActivityNotifications.tsx b/web/src/features/in-app-agent/components/InAppAgentActivityNotifications.tsxindex ef3bdd2e6e..2519202cb8 100644--- a/web/src/features/in-app-agent/components/InAppAgentActivityNotifications.tsx+++ b/web/src/features/in-app-agent/components/InAppAgentActivityNotifications.tsx@@ -5,15 +5,31 @@ import { useEffect, useMemo, useRef, useState } from "react";import { Layer } from "@/src/components/ui/layer";import {InAppAgentActivityCards,- selectInAppAgentActivityCards,type InAppAgentActivityCard,} from "@/src/features/in-app-agent/components/InAppAgentActivityCards";/** Same TTL for results and approvals: toast is heads-up, not a sticky prompt. */const CARD_TTL_MS = 8_000;+/** Approvals first: a question outranks a result the user can read later. */+const CARD_PRIORITY: Record<string, number> = {+ approval: 0,+ "failed-unread": 1,+ "done-unread": 2,+};+const MAX_VISIBLE_CARDS = 3;export type InAppAgentActivityNotification = InAppAgentActivityCard;+function selectInAppAgentActivityCards(+ cards: readonly InAppAgentActivityCard[],+) {+ return [...cards]+ .sort(+ (a, b) => (CARD_PRIORITY[a.state] ?? 9) - (CARD_PRIORITY[b.state] ?? 9),+ )+ .slice(0, MAX_VISIBLE_CARDS);+}+/*** Lifecycle for the floating stack. Cap before timers so hidden cards stay undelivered.* Assistant-owned (not Sonner) so long-lived approvals do not mute other toasts.@@ -50,6 +66,7 @@ export function InAppAgentActivityNotifications({),[dismissedKeys, notifications],);+ const [firstSelectedCard, ...remainingSelectedCards] = selected;// Deliver previously-shown cards that leave the top-3 window (eviction).// setState-during-render so we do not sync dismissedKeys from props in an@@ -166,16 +183,18 @@ export function InAppAgentActivityNotifications({return (<Layer name="toast">- <InAppAgentActivityCards- cards={selected}- onOpen={(card) => {- retire([card]);- onOpenConversation(card.conversationId);- }}- onDismiss={(card) => {- retire([card]);- }}- />+ {firstSelectedCard && (+ <InAppAgentActivityCards+ cards={[firstSelectedCard, ...remainingSelectedCards]}+ onOpen={(card) => {+ retire([card]);+ onOpenConversation(card.conversationId);+ }}+ onDismiss={(card) => {+ retire([card]);+ }}+ />+ )}</Layer>);}diff --git a/web/src/features/in-app-agent/components/InAppAgentToolCallDetails.tsx b/web/src/features/in-app-agent/components/InAppAgentToolCallDetails.tsxindex fe20334098..bd14007fb4 100644--- a/web/src/features/in-app-agent/components/InAppAgentToolCallDetails.tsx+++ b/web/src/features/in-app-agent/components/InAppAgentToolCallDetails.tsx@@ -108,7 +108,9 @@ function SandboxToolCallDetails({return (<div className="flex flex-col gap-2">{children}- <InAppAgentToolResultPayload tool={{ ...tool, result: undefined }} />+ {tool.error !== undefined && (+ <InAppAgentToolResultPayload status={tool.status} value={tool.error} />+ )}</div>);}@@ -272,6 +274,8 @@ function SandboxFooter({ children }: { children: React.ReactNode }) {}function DefaultToolCallDetails({ tool }: { tool: InAppAgentToolCallContent }) {+ const result = tool.error ?? tool.result;+return (<div className="flex flex-col gap-2"><InAppAgentToolPayload@@ -279,7 +283,9 @@ function DefaultToolCallDetails({ tool }: { tool: InAppAgentToolCallContent }) {value={tool.args}variant="default"/>- <InAppAgentToolResultPayload tool={tool} />+ {result !== undefined && (+ <InAppAgentToolResultPayload status={tool.status} value={result} />+ )}</div>);}diff --git a/web/src/features/in-app-agent/components/InAppAgentToolResultPayload.tsx b/web/src/features/in-app-agent/components/InAppAgentToolResultPayload.tsxindex 5a376ff59d..e36ad2a2d9 100644--- a/web/src/features/in-app-agent/components/InAppAgentToolResultPayload.tsx+++ b/web/src/features/in-app-agent/components/InAppAgentToolResultPayload.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */"use client";import { InAppAgentToolPayload } from "./InAppAgentToolPayload";@@ -18,20 +17,18 @@ const TOOL_CALL_RESULT_PRESENTATION = {>;export function InAppAgentToolResultPayload({- tool,+ status,+ value,}: {- tool: InAppAgentToolCallContent;+ status: InAppAgentToolCallContent["status"];+ value: string;}) {- if (tool.result === undefined && tool.error === undefined) {- return null;- }-- const presentation = TOOL_CALL_RESULT_PRESENTATION[tool.status];+ const presentation = TOOL_CALL_RESULT_PRESENTATION[status];return (<InAppAgentToolPayloadlabel={presentation.label}- value={tool.error ?? tool.result ?? ""}+ value={value}variant={presentation.variant}/>);diff --git a/web/src/features/in-app-agent/components/InAppAgentWidgetComposer.clienttest.tsx b/web/src/features/in-app-agent/components/InAppAgentWidgetComposer.clienttest.tsxindex 31988b445e..ccb3b3dfdc 100644--- a/web/src/features/in-app-agent/components/InAppAgentWidgetComposer.clienttest.tsx+++ b/web/src/features/in-app-agent/components/InAppAgentWidgetComposer.clienttest.tsx@@ -3,29 +3,26 @@ import { fireEvent, render, screen, waitFor } from "@testing-library/react";import { InAppAgentWidgetComposer } from "./InAppAgentWidgetComposer";const agentContext = vi.hoisted(() => ({- isAvailable: true,- isRunning: false,- isSubmitting: false,openAssistant: vi.fn().mockReturnValue(true),submit: vi.fn().mockResolvedValue(true),}));const { openAssistant, submit } = agentContext;-vi.mock("./InAppAiAgentProvider", () => ({- useInAppAiAgent: () => agentContext,-}));-describe("InAppAgentWidgetComposer", () => {beforeEach(() => {- agentContext.isRunning = false;- agentContext.isSubmitting = false;openAssistant.mockClear().mockReturnValue(true);submit.mockClear().mockResolvedValue(true);});it("starts a fresh Assistant conversation with the widget request", async () => {const onSubmitted = vi.fn();- render(<InAppAgentWidgetComposer onSubmitted={onSubmitted} />);+ render(+ <InAppAgentWidgetComposer+ onSubmitted={onSubmitted}+ openAssistant={openAssistant}+ submit={submit}+ />,+ );fireEvent.change(screen.getByLabelText("Describe the widget you want"), {target: { value: " Show p95 latency by model " },@@ -45,7 +42,13 @@ describe("InAppAgentWidgetComposer", () => {});it("disables submit for whitespace-only input", () => {- render(<InAppAgentWidgetComposer onSubmitted={vi.fn()} />);+ render(+ <InAppAgentWidgetComposer+ onSubmitted={vi.fn()}+ openAssistant={openAssistant}+ submit={submit}+ />,+ );fireEvent.change(screen.getByLabelText("Describe the widget you want"), {target: { value: " " },@@ -57,10 +60,14 @@ describe("InAppAgentWidgetComposer", () => {});it("starts a new widget conversation while the selected conversation is busy", async () => {- agentContext.isRunning = true;- agentContext.isSubmitting = true;const onSubmitted = vi.fn();- render(<InAppAgentWidgetComposer onSubmitted={onSubmitted} />);+ render(+ <InAppAgentWidgetComposer+ onSubmitted={onSubmitted}+ openAssistant={openAssistant}+ submit={submit}+ />,+ );fireEvent.change(screen.getByLabelText("Describe the widget you want"), {target: { value: "Show p95 latency" },@@ -81,7 +88,13 @@ describe("InAppAgentWidgetComposer", () => {it("keeps the picker open and preserves the request when submit does not start", async () => {submit.mockResolvedValue(false);const onSubmitted = vi.fn();- render(<InAppAgentWidgetComposer onSubmitted={onSubmitted} />);+ render(+ <InAppAgentWidgetComposer+ onSubmitted={onSubmitted}+ openAssistant={openAssistant}+ submit={submit}+ />,+ );const input = screen.getByLabelText("Describe the widget you want");fireEvent.change(input, { target: { value: "Show error rate" } });diff --git a/web/src/features/in-app-agent/components/InAppAgentWidgetComposer.tsx b/web/src/features/in-app-agent/components/InAppAgentWidgetComposer.tsxindex 86b08ee4ca..9526c9f856 100644--- a/web/src/features/in-app-agent/components/InAppAgentWidgetComposer.tsx+++ b/web/src/features/in-app-agent/components/InAppAgentWidgetComposer.tsx@@ -1,10 +1,9 @@-/* eslint-disable @repo/no-null-render */import { type KeyboardEvent, type SyntheticEvent, useState } from "react";import { SendHorizontal, Sparkles } from "lucide-react";import { Button } from "@/src/components/ui/button";import { Textarea } from "@/src/components/ui/textarea";-import { useInAppAiAgent } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";+import type { useInAppAiAgent } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";const MAX_TEXTAREA_HEIGHT_PX = 160;@@ -24,16 +23,13 @@ const getWidgetCreationPrompt = (request: string) =>export function InAppAgentWidgetComposer({onSubmitted,+ openAssistant,+ submit,}: {onSubmitted: () => void;-}) {- const { isAvailable, openAssistant, submit } = useInAppAiAgent();+} & Pick<ReturnType<typeof useInAppAiAgent>, "openAssistant" | "submit">) {const [request, setRequest] = useState("");- if (!isAvailable) {- return null;- }-const handleSubmit = async (event: SyntheticEvent<HTMLFormElement>) => {event.preventDefault();const trimmedRequest = request.trim();diff --git a/web/src/features/models/components/PriceBreakdownTooltip.tsx b/web/src/features/models/components/PriceBreakdownTooltip.tsxindex c572e3801f..0b48ec39c0 100644--- a/web/src/features/models/components/PriceBreakdownTooltip.tsx+++ b/web/src/features/models/components/PriceBreakdownTooltip.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import Decimal from "decimal.js";import { InfoIcon } from "lucide-react";import { useMemo, useState } from "react";@@ -21,7 +20,7 @@ export const PriceBreakdownTooltip = ({rowHeight,}: {modelName: string;- prices?: Record<string, number>;+ prices: Record<string, number>;priceUnit: PriceUnit;rowHeight: RowHeight;}) => {@@ -31,15 +30,13 @@ export const PriceBreakdownTooltip = ({const maxDecimals = useMemo(() =>Math.max(- ...Object.values(prices ?? {}).map((price) => {+ ...Object.values(prices).map((price) => {return getMaxDecimals(price, priceUnitMultiplier);}),),[prices, priceUnitMultiplier],);- if (!prices) return null;-return (<>{Object.keys(prices).length === 0 ? (diff --git a/web/src/features/models/components/ProvidedModelNameCell.tsx b/web/src/features/models/components/ProvidedModelNameCell.tsxindex 49052cc87c..283c4becf3 100644--- a/web/src/features/models/components/ProvidedModelNameCell.tsx+++ b/web/src/features/models/components/ProvidedModelNameCell.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import { PlusCircle } from "lucide-react";import { IdTableCell } from "@/src/components/design-system/table/components/IdTableCell/IdTableCell";import { UpsertModelFormDialog } from "@/src/features/models/components/UpsertModelFormDialog/UpsertModelFormDialog";@@ -20,13 +19,11 @@ export function ProvidedModelNameCell({projectId,usageDetails,}: {- modelName: string | undefined;+ modelName: string;modelId: string | undefined;projectId: string;usageDetails: Record<string, number>;}) {- if (!modelName) return null;-// Both states wrap the name in the same inline-flex so the text sits at an// identical baseline whether or not the trailing affordance is present.if (modelId) {diff --git a/web/src/features/notifications/components/ProjectNotificationChannels.tsx b/web/src/features/notifications/components/ProjectNotificationChannels.tsxindex 2c164a6f3b..2a547952a1 100644--- a/web/src/features/notifications/components/ProjectNotificationChannels.tsx+++ b/web/src/features/notifications/components/ProjectNotificationChannels.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import Header from "@/src/components/layouts/header";import { Button } from "@/src/components/ui/button";import {@@ -62,7 +61,6 @@ export function ProjectNotificationChannels({projectId: string;}) {const {- hasAccess,channels,isLoading,mode,@@ -76,8 +74,6 @@ export function ProjectNotificationChannels({const hasChannels = Boolean(channels?.length);- if (!hasAccess) return null;-return (<div><Header title="Project Notifications" />diff --git a/web/src/features/notifications/hooks/useProjectNotificationChannels.ts b/web/src/features/notifications/hooks/useProjectNotificationChannels.tsindex 844046c660..ea0a04fda8 100644--- a/web/src/features/notifications/hooks/useProjectNotificationChannels.ts+++ b/web/src/features/notifications/hooks/useProjectNotificationChannels.ts@@ -1,7 +1,6 @@import { useState } from "react";import { api } from "@/src/utils/api";-import { useHasProjectAccess } from "@/src/features/rbac";import {TriggerEventSource,type AutomationDomain,@@ -20,14 +19,9 @@ export type ProjectNotificationChannelsMode = "list" | "create" | "edit";*/export function useProjectNotificationChannels(projectId: string) {const utils = api.useUtils();- const hasAccess = useHasProjectAccess({- projectId,- scope: "automations:CUD",- });const { data: channels, isLoading } = api.automations.getAutomations.useQuery({ projectId, eventSource: TriggerEventSource.ProjectNotification },- { enabled: Boolean(projectId) && hasAccess },);const [mode, setMode] = useState<ProjectNotificationChannelsMode>("list");@@ -73,7 +67,6 @@ export function useProjectNotificationChannels(projectId: string) {};return {- hasAccess,channels,isLoading,mode,diff --git a/web/src/features/organizations/components/ProjectOverview.tsx b/web/src/features/organizations/components/ProjectOverview.tsxindex e4148f4b0c..8e7f5562b4 100644--- a/web/src/features/organizations/components/ProjectOverview.tsx+++ b/web/src/features/organizations/components/ProjectOverview.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import {BookOpen,LockIcon,@@ -35,12 +34,17 @@ import ContainerPage from "@/src/components/layouts/container-page";import { type Session } from "next-auth";import { usePostHogClientCapture } from "@/src/features/posthog-analytics";import { AgentToolsBanner } from "@/src/features/developer-tools/components/AgentToolsBanner";-import { V4MigrationBanner } from "@/src/features/v4-migration/V4MigrationBanner";+import {+ V4MigrationBanner,+ useV4MigrationBannerState,+} from "@/src/features/v4-migration/V4MigrationBanner";import { V4MigrationProjectChip } from "@/src/features/v4-migration/V4MigrationProjectChip";import { api } from "@/src/utils/api";import { formatCompactRelativeTime } from "@/src/utils/dates";import { useV4UpgradeUiEnabled } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";import { useAccountV4MigrationData } from "@/src/features/v4-migration/hooks/useV4MigrationData";+import { getProjectMigrationReadiness } from "@/src/features/v4-migration/migrationData";+import { ErrorPage } from "@/src/components/error-page";const OrganizationProjectTiles = ({org,@@ -72,8 +76,13 @@ const OrganizationProjectTiles = ({.filter((p) => !search || p.name.toLowerCase().includes(search.toLowerCase()),)- .map((project) =>- v4UpgradeUiEnabled ? (+ .map((project) => {+ const migrationStatus = migrationStatusByProjectId.get(project.id);+ const migrationReadiness = migrationStatus+ ? getProjectMigrationReadiness(migrationStatus)+ : "checking";++ return v4UpgradeUiEnabled ? (<Cardkey={project.id}className="group hover:bg-muted/50 relative transition-colors"@@ -93,12 +102,14 @@ const OrganizationProjectTiles = ({>{project.name}</CardTitle>- {!project.deletedAt && (- <V4MigrationProjectChip- project={{ id: project.id, name: project.name }}- status={migrationStatusByProjectId.get(project.id)}- />- )}+ {!project.deletedAt &&+ (migrationReadiness === "action-needed" ||+ migrationReadiness === "partner-managed") && (+ <V4MigrationProjectChip+ project={{ id: project.id, name: project.name }}+ readiness={migrationReadiness}+ />+ )}</div></CardHeader>{!project.deletedAt && (@@ -147,8 +158,8 @@ const OrganizationProjectTiles = ({</CardContent>)}</Card>- ),- )}+ );+ })}</div>);};@@ -231,21 +242,14 @@ const OrganizationActionButtons = ({};const SingleOrganizationPage = ({- orgId,+ org,search,}: {- orgId: string;+ org: NonNullable<Session["user"]>["organizations"][number];search?: string;}) => {- const session = useSession();- const org = session.data?.user?.organizations.find((o) => o.id === orgId);-- if (!org) {- return null;- }-const isDemoOrg =- env.NEXT_PUBLIC_DEMO_ORG_ID === orgId &&+ env.NEXT_PUBLIC_DEMO_ORG_ID === org.id &&org.projects.some((p) => p.id === env.NEXT_PUBLIC_DEMO_PROJECT_ID);if (isDemoOrg) {@@ -263,8 +267,8 @@ const SingleOrganizationPage = ({return (<ContainerPageheaderProps={{- title: org?.name ?? "Organization",- actionButtonsRight: <OrganizationActionButtons orgId={orgId} />,+ title: org.name,+ actionButtonsRight: <OrganizationActionButtons orgId={org.id} />,}}><OrganizationProjectTiles org={org} search={search} />@@ -273,38 +277,31 @@ const SingleOrganizationPage = ({};const SingleOrganizationProjectOverviewTile = ({- orgId,+ org,search,}: {- orgId: string;+ org: NonNullable<Session["user"]>["organizations"][number];search?: string;}) => {- const session = useSession();- const org = session.data?.user?.organizations.find((o) => o.id === orgId);-- if (!org) {- return null;- }-const isDemoOrg =- env.NEXT_PUBLIC_DEMO_ORG_ID === orgId &&+ env.NEXT_PUBLIC_DEMO_ORG_ID === org.id &&org.projects.some((p) => p.id === env.NEXT_PUBLIC_DEMO_PROJECT_ID);if (isDemoOrg) {return (- <div key={orgId}>+ <div key={org.id}><DemoOrganizationTile /></div>);}return (- <div key={orgId}>+ <div key={org.id}><Headertitle={org.name}className="truncate"labelBadge={- orgId === env.NEXT_PUBLIC_DEMO_ORG_ID ? "Demo Org" : undefined+ org.id === env.NEXT_PUBLIC_DEMO_ORG_ID ? "Demo Org" : undefined}label={isCloudPlan(org.plan)@@ -316,7 +313,7 @@ const SingleOrganizationProjectOverviewTile = ({}actionButtons={<OrganizationActionButtons- orgId={orgId}+ orgId={org.id}primaryButtonVariant="secondary"/>}@@ -334,6 +331,7 @@ export const OrganizationProjectOverview = () => {const canCreateOrg = session.data?.user?.canCreateOrganizations;const organizations = session.data?.user?.organizations;const [{ search }, setQueryParams] = useQueryParams({ search: StringParam });+ const v4MigrationBannerState = useV4MigrationBannerState(v4UpgradeUiEnabled);if (organizations === undefined) {return "loading...";@@ -347,12 +345,15 @@ export const OrganizationProjectOverview = () => {const org = organizations.find((org) => org.id === queryOrgId);if (!org) {- return null;+ return (+ <ErrorPage+ title="Organization not found"+ message="This organization does not exist or you do not have access to it."+ />+ );}- return (- <SingleOrganizationPage orgId={org.id} search={search ?? undefined} />- );+ return <SingleOrganizationPage org={org} search={search ?? undefined} />;}return (@@ -389,7 +390,18 @@ export const OrganizationProjectOverview = () => {),}}>- {v4UpgradeUiEnabled ? <V4MigrationBanner /> : <AgentToolsBanner />}+ {v4UpgradeUiEnabled ? (+ v4MigrationBannerState.projectsNeedingMigration > 0 && (+ <V4MigrationBanner+ projectsNeedingMigration={+ v4MigrationBannerState.projectsNeedingMigration+ }+ totalProjects={v4MigrationBannerState.totalProjects}+ />+ )+ ) : (+ <AgentToolsBanner />+ )}{showOnboarding && <Onboarding />}{organizations.map((org) => {@@ -407,7 +419,7 @@ export const OrganizationProjectOverview = () => {{!queryOrgId && isDemo && <Separator className="my-8" />}<div key={org.id} className={index > 0 && !isDemo ? "mt-8" : ""}><SingleOrganizationProjectOverviewTile- orgId={org.id}+ org={org}search={search ?? undefined}/></div>diff --git a/web/src/features/prompts/components/NewPromptForm/index.tsx b/web/src/features/prompts/components/NewPromptForm/index.tsxindex f59c11c8da..acbdeb5377 100644--- a/web/src/features/prompts/components/NewPromptForm/index.tsx+++ b/web/src/features/prompts/components/NewPromptForm/index.tsx@@ -381,7 +381,9 @@ export const NewPromptForm: React.FC<NewPromptFormProps> = (props) => {</div></Tabs></FormItem>- <PromptVariableListPreview variables={currentExtractedVariables} />+ {currentExtractedVariables.length > 0 && (+ <PromptVariableListPreview variables={currentExtractedVariables} />+ )}</>{/* Prompt Config field */}diff --git a/web/src/features/prompts/components/PromptVariableListPreview.tsx b/web/src/features/prompts/components/PromptVariableListPreview.tsxindex 3c26c687e4..2ca4085102 100644--- a/web/src/features/prompts/components/PromptVariableListPreview.tsx+++ b/web/src/features/prompts/components/PromptVariableListPreview.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import { Badge } from "@/src/components/ui/badge";export const PromptVariableListPreview = ({@@ -6,10 +5,6 @@ export const PromptVariableListPreview = ({}: {variables: string[];}) => {- if (variables.length === 0) {- return null;- }-return (<div><p className="text-muted-foreground mb-2 text-sm">diff --git a/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx b/web/src/features/prompts/components/SetPromptVersionLabels/index.tsxindex 3077caf98f..0d3834df75 100644--- a/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx+++ b/web/src/features/prompts/components/SetPromptVersionLabels/index.tsx@@ -178,10 +178,12 @@ export function SetPromptVersionLabels({)}>{title && title}- <TruncatedLabels- labels={promptLabels}- maxVisibleLabels={maxVisibleLabels}- />+ {promptLabels.length > 0 && (+ <TruncatedLabels+ labels={promptLabels}+ maxVisibleLabels={maxVisibleLabels}+ />+ )}<Buttonvariant="outline"title="Add prompt label"diff --git a/web/src/features/prompts/components/prompt-detail.tsx b/web/src/features/prompts/components/prompt-detail.tsxindex aad763bc06..ebfaa14efe 100644--- a/web/src/features/prompts/components/prompt-detail.tsx+++ b/web/src/features/prompts/components/prompt-detail.tsx@@ -622,7 +622,9 @@ export const PromptDetail = ({<JSONView json={prompt.prompt} title="Prompt" />)}</PromptReferenceProvider>- <PromptVariableListPreview variables={extractedVariables} />+ {extractedVariables.length > 0 && (+ <PromptVariableListPreview variables={extractedVariables} />+ )}</div></TabsBarContent><TabsBarContentdiff --git a/web/src/features/prompts/components/prompt-history.tsx b/web/src/features/prompts/components/prompt-history.tsxindex 8a9e8c686a..ae4840f40f 100644--- a/web/src/features/prompts/components/prompt-history.tsx+++ b/web/src/features/prompts/components/prompt-history.tsx@@ -26,6 +26,7 @@ const PromptHistoryTraceNode = (props: {const [isHovered, setIsHovered] = useState(false);const [isLabelPopoverOpen, setIsLabelPopoverOpen] = useState(false);const { prompt } = props;+ const commentCount = props.commentCounts?.get(prompt.id);// Add ref for scroll into viewconst currentPromptRef = useRef<HTMLDivElement>(null);@@ -108,7 +109,7 @@ const PromptHistoryTraceNode = (props: {setIsOpen={setIsLabelPopoverOpen}showOnlyOnHover/>- {props.commentCounts?.get(prompt.id) ? (+ {commentCount ? (<spanonClick={(e) => {e.stopPropagation();@@ -130,7 +131,7 @@ const PromptHistoryTraceNode = (props: {className="cursor-pointer"role="button">- <CommentCountIcon count={props.commentCounts.get(prompt.id)} />+ <CommentCountIcon count={commentCount} /></span>) : null}</div>diff --git a/web/src/features/public-api/components/ApiKeyList.tsx b/web/src/features/public-api/components/ApiKeyList.tsxindex 47597adfad..321c3986f9 100644--- a/web/src/features/public-api/components/ApiKeyList.tsx+++ b/web/src/features/public-api/components/ApiKeyList.tsx@@ -49,12 +49,15 @@ export function ApiKeyList(props: { entityId: string; scope: ApiKeyScope }) {}// Viewing the list only needs apiKeys:read, which project MEMBERs hold.- // Create, delete, and note editing stay behind apiKeys:CUD and are gated- // individually by CreateApiKeyButton, DeleteApiKeyButton, and ApiKeyNote.+ // Create, delete, and note editing stay behind apiKeys:CUD.const hasProjectReadAccess = useHasProjectAccess({projectId: props.entityId,scope: "apiKeys:read",});+ const hasProjectWriteAccess = useHasProjectAccess({+ projectId: props.entityId,+ scope: "apiKeys:CUD",+ });const hasOrganizationAccess = useHasOrganizationAccess({organizationId: props.entityId,scope: "organization:CRUD_apiKeys",@@ -62,6 +65,8 @@ export function ApiKeyList(props: { entityId: string; scope: ApiKeyScope }) {const hasAccess =props.scope === "project" ? hasProjectReadAccess : hasOrganizationAccess;+ const hasCreateAccess =+ props.scope === "project" ? hasProjectWriteAccess : hasOrganizationAccess;const projectApiKeysQuery = api.projectApiKeys.byProjectId.useQuery({ projectId: entityId },@@ -100,7 +105,11 @@ export function ApiKeyList(props: { entityId: string; scope: ApiKeyScope }) {? "https://langfuse.com/docs/api#authentication": "https://langfuse.com/docs/api#org-scoped-routes",}}- actionButtons={<CreateApiKeyButton entityId={entityId} scope={scope} />}+ actionButtons={+ hasCreateAccess ? (+ <CreateApiKeyButton entityId={entityId} scope={scope} />+ ) : undefined+ }/><CodeViewcontent={envCode}diff --git a/web/src/features/public-api/components/CreateApiKeyButton.tsx b/web/src/features/public-api/components/CreateApiKeyButton.tsxindex 0a1112fc10..12b7aa8881 100644--- a/web/src/features/public-api/components/CreateApiKeyButton.tsx+++ b/web/src/features/public-api/components/CreateApiKeyButton.tsx@@ -1,14 +1,9 @@-/* eslint-disable @repo/no-null-render */-import {- useHasProjectAccess,- useHasOrganizationAccess,-} from "@/src/features/rbac";import { Button } from "@/src/components/ui/button";import { Dialog, DialogTrigger } from "@/src/components/ui/dialog";import { api, reportNonTrpcError } from "@/src/utils/api";import { useState } from "react";import { PlusIcon } from "lucide-react";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { useLangfuseBaseUrl } from "@/src/features/public-api/hooks/useLangfuseEnvCode";import { ApiKeyCreateDialogContent } from "@/src/features/public-api/components/ApiKeyCreateDialogContent";@@ -21,18 +16,6 @@ export function CreateApiKeyButton(props: {const utils = api.useUtils();const capture = usePostHogClientCapture();- const hasProjectAccess = useHasProjectAccess({- projectId: props.entityId,- scope: "apiKeys:CUD",- });- const hasOrganizationAccess = useHasOrganizationAccess({- organizationId: props.entityId,- scope: "organization:CRUD_apiKeys",- });-- const hasAccess =- props.scope === "project" ? hasProjectAccess : hasOrganizationAccess;-const mutCreateProjectApiKey = api.projectApiKeys.create.useMutation({onSuccess: () => utils.projectApiKeys.invalidate(),});@@ -89,8 +72,6 @@ export function CreateApiKeyButton(props: {}};- if (!hasAccess) return null;-return (<Dialog open={open} onOpenChange={handleOpenChange}><DialogTrigger asChild>diff --git a/web/src/features/public-api/components/LLMApiKeyList.tsx b/web/src/features/public-api/components/LLMApiKeyList.tsxindex 7dbc705ccf..2035c37902 100644--- a/web/src/features/public-api/components/LLMApiKeyList.tsx+++ b/web/src/features/public-api/components/LLMApiKeyList.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import { useHasProjectAccess } from "@/src/features/rbac";import { TrashIcon } from "lucide-react";import { useState } from "react";@@ -28,6 +27,10 @@ export function LlmApiKeyList(props: { projectId: string }) {projectId: props.projectId,scope: "llmApiKeys:read",});+ const hasDeleteAccess = useHasProjectAccess({+ projectId: props.projectId,+ scope: "llmApiKeys:delete",+ });const apiKeys = api.llmApiKey.all.useQuery({@@ -139,10 +142,12 @@ export function LlmApiKeyList(props: { projectId: string }) {}}}/>- <DeleteApiKeyButton- projectId={props.projectId}- apiKeyId={apiKey.id}- />+ {hasDeleteAccess && (+ <DeleteApiKeyButton+ projectId={props.projectId}+ apiKeyId={apiKey.id}+ />+ )}</div></TableCell></TableRow>@@ -159,10 +164,6 @@ export function LlmApiKeyList(props: { projectId: string }) {// show dialog to let user confirm that this is a destructive actionfunction DeleteApiKeyButton(props: { projectId: string; apiKeyId: string }) {const capture = usePostHogClientCapture();- const hasAccess = useHasProjectAccess({- projectId: props.projectId,- scope: "llmApiKeys:delete",- });const utils = api.useUtils();const mutDeleteApiKey = api.llmApiKey.delete.useMutation({@@ -170,8 +171,6 @@ function DeleteApiKeyButton(props: { projectId: string; apiKeyId: string }) {});const [open, setOpen] = useState(false);- if (!hasAccess) return null;-return (<ConfirmDialogopen={open}diff --git a/web/src/features/score-analytics/components/ScoreAnalyticsDashboard.tsx b/web/src/features/score-analytics/components/ScoreAnalyticsDashboard.tsxindex 20aecc3ad1..35546ced39 100644--- a/web/src/features/score-analytics/components/ScoreAnalyticsDashboard.tsx+++ b/web/src/features/score-analytics/components/ScoreAnalyticsDashboard.tsx@@ -4,8 +4,54 @@ import { DistributionNumericCard } from "./cards/DistributionNumericCard";import { DistributionCategoricalCard } from "./cards/DistributionCategoricalCard";import { DistributionBooleanCard } from "./cards/DistributionBooleanCard";import { HeatmapCard } from "./cards/HeatmapCard";-import { useScoreAnalytics } from "./ScoreAnalyticsProvider";+import {+ useScoreAnalytics,+ type ScoreAnalyticsContextValue,+} from "./ScoreAnalyticsProvider";import { ScoreAnalyticsNoticeBanner } from "./ScoreAnalyticsNoticeBanner";+import { useEffect, useState } from "react";++type ScoreAnalyticsNotice =+ | {+ status: "loading";+ estimate: ScoreAnalyticsContextValue["estimate"];+ }+ | {+ status: "sampled";+ data: NonNullable<ScoreAnalyticsContextValue["data"]>;+ };++function useScoreAnalyticsNotice(): ScoreAnalyticsNotice | undefined {+ const { data, estimate, isEstimating, isLoading } = useScoreAnalytics();+ const [showLoadingBanner, setShowLoadingBanner] = useState(false);++ useEffect(() => {+ if (isEstimating || (estimate && isLoading)) {+ const timer = setTimeout(() => {+ setShowLoadingBanner(true);+ }, 1500);++ return () => clearTimeout(timer);+ }++ setShowLoadingBanner(false);+ }, [isEstimating, estimate, isLoading]);++ const isLoadingAnalytics = isEstimating || Boolean(estimate && isLoading);+ const showLargeDataset = Boolean(+ estimate && estimate.estimatedMatchedCount > 100_000,+ );++ if (isLoadingAnalytics && (showLoadingBanner || showLargeDataset)) {+ return { status: "loading", estimate };+ }++ if (!isLoadingAnalytics && estimate && data?.samplingMetadata.isSampled) {+ return { status: "sampled", data };+ }++ return undefined;+}/*** ScoreAnalyticsDashboard - Layout component for score analytics@@ -30,6 +76,7 @@ import { ScoreAnalyticsNoticeBanner } from "./ScoreAnalyticsNoticeBanner";*/export function ScoreAnalyticsDashboard() {const { data } = useScoreAnalytics();+ const notice = useScoreAnalyticsNotice();// Route to appropriate distribution card based on data typeconst renderDistributionCard = () => {@@ -55,8 +102,14 @@ export function ScoreAnalyticsDashboard() {return (<>- {/* Unified notice banner (transitions: loading → sampling notice) */}- <ScoreAnalyticsNoticeBanner />+ {notice?.status === "loading" ? (+ <ScoreAnalyticsNoticeBanner+ variant="loading"+ estimate={notice.estimate}+ />+ ) : notice?.status === "sampled" ? (+ <ScoreAnalyticsNoticeBanner variant="sampled" data={notice.data} />+ ) : null}{/* Main grid */}<div className="grid grid-cols-1 gap-4 xl:grid-cols-2">diff --git a/web/src/features/score-analytics/components/ScoreAnalyticsNoticeBanner.tsx b/web/src/features/score-analytics/components/ScoreAnalyticsNoticeBanner.tsxindex 3484493531..e949dd754c 100644--- a/web/src/features/score-analytics/components/ScoreAnalyticsNoticeBanner.tsx+++ b/web/src/features/score-analytics/components/ScoreAnalyticsNoticeBanner.tsx@@ -1,41 +1,26 @@-/* eslint-disable @repo/no-null-render */import { Clock, Info } from "lucide-react";-import { useScoreAnalytics } from "./ScoreAnalyticsProvider";-import { useState, useEffect } from "react";+import { assertUnreachable } from "@/src/utils/types";+import type { ScoreAnalyticsContextValue } from "./ScoreAnalyticsProvider";import { SamplingDetailsHoverCard } from "./SamplingDetailsHoverCard";-export function ScoreAnalyticsNoticeBanner() {- const { isEstimating, estimate, isLoading, data } = useScoreAnalytics();- const [showLoadingBanner, setShowLoadingBanner] = useState(false);-- // Track when estimation starts and set delay for showing loading banner- useEffect(() => {- if (isEstimating || (estimate && isLoading)) {- // Start timer - show banner after 1.5 seconds- const timer = setTimeout(() => {- setShowLoadingBanner(true);- }, 1500);-- return () => clearTimeout(timer);+type ScoreAnalyticsNoticeBannerProps =+ | {+ variant: "loading";+ estimate: ScoreAnalyticsContextValue["estimate"];}- // Reset when loading completes- setShowLoadingBanner(false);- }, [isEstimating, estimate, isLoading]);-- // Don't show anything if we haven't started- if (!isEstimating && !estimate) return null;-- // State 1: Estimating (loading)- if (isEstimating || (estimate && isLoading)) {- const showLargeDataset =- estimate && estimate.estimatedMatchedCount > 100_000;+ | {+ variant: "sampled";+ data: NonNullable<ScoreAnalyticsContextValue["data"]>;+ };- // Only show banner if:- // 1. Delay has passed, OR- // 2. We have estimate data showing it's a large dataset- if (!showLoadingBanner && !showLargeDataset) {- return null;- }+export function ScoreAnalyticsNoticeBanner(+ props: ScoreAnalyticsNoticeBannerProps,+) {+ if (props.variant === "loading") {+ const { estimate } = props;+ const showLargeDataset = Boolean(+ estimate && estimate.estimatedMatchedCount > 100_000,+ );return (<div className="bg-muted mb-4 rounded-md px-4 py-3">@@ -64,8 +49,9 @@ export function ScoreAnalyticsNoticeBanner() {);}- // State 2: Loaded with sampling- if (data?.samplingMetadata.isSampled) {+ if (props.variant === "sampled") {+ const { data } = props;+return (<div className="bg-muted mb-4 rounded-md px-4 py-3"><div className="flex items-start gap-3">@@ -89,6 +75,5 @@ export function ScoreAnalyticsNoticeBanner() {);}- // State 3: Loaded without sampling (don't show banner)- return null;+ return assertUnreachable(props);}diff --git a/web/src/features/score-configs/components/ScoreConfigDetails.tsx b/web/src/features/score-configs/components/ScoreConfigDetails.tsxindex d6ff1d70f3..2dbeac035b 100644--- a/web/src/features/score-configs/components/ScoreConfigDetails.tsx+++ b/web/src/features/score-configs/components/ScoreConfigDetails.tsx@@ -1,11 +1,8 @@-/* eslint-disable @repo/no-null-render */import { isNumericDataType } from "@/src/features/scores/lib/helpers";import { isPresent, type ScoreConfigDomain } from "@langfuse/shared";-import React from "react";export function ScoreConfigDetails({ config }: { config: ScoreConfigDomain }) {const { name, description, minValue, maxValue, dataType } = config;- if (!description && !isPresent(minValue) && !isPresent(maxValue)) return null;const isNameTruncated = name.length > 20;return (diff --git a/web/src/features/score-configs/components/ScoreConfigSettings.tsx b/web/src/features/score-configs/components/ScoreConfigSettings.tsxindex f785571f10..a8755681a2 100644--- a/web/src/features/score-configs/components/ScoreConfigSettings.tsx+++ b/web/src/features/score-configs/components/ScoreConfigSettings.tsx@@ -1,17 +1,7 @@-/* eslint-disable @repo/no-null-render */-import React from "react";import Header from "@/src/components/layouts/header";-import { useHasProjectAccess } from "@/src/features/rbac";import { ScoreConfigsTable } from "@/src/components/table/use-cases/score-configs";export function ScoreConfigSettings({ projectId }: { projectId: string }) {- const hasReadAccess = useHasProjectAccess({- projectId: projectId,- scope: "scoreConfigs:read",- });-- if (!hasReadAccess) return null;-return (<div id="score-configs"><Header title="Score Configs" />diff --git a/web/src/features/scores-chart-view/components/ScoresChartView.tsx b/web/src/features/scores-chart-view/components/ScoresChartView.tsxindex 16afb95970..fe113f35fd 100644--- a/web/src/features/scores-chart-view/components/ScoresChartView.tsx+++ b/web/src/features/scores-chart-view/components/ScoresChartView.tsx@@ -14,6 +14,7 @@ import { ScoreChartViewPanel } from "@/src/features/scores-chart-view/components// Shared with the observations chart view; only the widget-input mapper// passed to it (`scoreChartConfigToWidgetInput`) is scores-specific.import { AddToDashboardButton } from "@/src/features/chart-view/components/AddToDashboardButton";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";/*** Production chart view for the scores table. Mirrors `EventsChartView` (the@@ -55,6 +56,10 @@ export function ScoresChartView({onConfigChange: (patch: Partial<ScoreChartViewConfig>) => void;viewVersion: ViewVersion;}) {+ const canManageDashboards = useHasProjectAccess({+ projectId,+ scope: "dashboards:CUD",+ });const filters = useMemo(() =>mapLegacyUiTableFilterToView(@@ -110,7 +115,12 @@ export function ScoresChartView({isLoading={validRange && queryResult.isPending && !queryResult.isError}error={error}chartActions={- <AddToDashboardButton projectId={projectId} widgetInput={widgetInput} />+ canManageDashboards && (+ <AddToDashboardButton+ projectId={projectId}+ widgetInput={widgetInput}+ />+ )}/>);diff --git a/web/src/features/setup/components/SetupTracingButton.tsx b/web/src/features/setup/components/SetupTracingButton.tsxdeleted file mode 100644index 052bcc25ce..0000000000--- a/web/src/features/setup/components/SetupTracingButton.tsx+++ /dev/null@@ -1,68 +0,0 @@-/* eslint-disable @repo/no-null-render */-import { Button } from "@/src/components/ui/button";-import Link from "next/link";-import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";-import { api } from "@/src/utils/api";-import { setupTracingRoute } from "@/src/features/setup/setupRoutes";-import { useHasProjectAccess } from "@/src/features/rbac";-import { LockIcon } from "lucide-react";-import { useRouter } from "next/router";-import { useEffect, useRef } from "react";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";--const SetupTracingButton = () => {- const { project } = useQueryProjectOrOrganization();-- const router = useRouter();- const queryProjectId = router.query.projectId as string | undefined;-- const { data: hasTracingConfigured, isLoading } =- api.traces.hasTracingConfigured.useQuery(- { projectId: queryProjectId as string },- {- enabled: queryProjectId !== undefined,- trpc: {- context: {- skipBatch: true,- },- },- },- );-- // dedupe result via useRef, otherwise we'll capture the event multiple times on session refresh- const capturedEventAlready = useRef<boolean | undefined>(undefined);- const capture = usePostHogClientCapture();- useEffect(() => {- if (hasTracingConfigured !== undefined && !capturedEventAlready.current) {- capture("onboarding:tracing_check_active", {- active: hasTracingConfigured,- });- capturedEventAlready.current = true;- }- }, [hasTracingConfigured, capture]);-- const hasAccess = useHasProjectAccess({- projectId: project?.id,- scope: "apiKeys:CUD",- });-- if (isLoading || hasTracingConfigured || !project) {- return null;- }-- if (!hasAccess)- return (- <Button disabled>- <LockIcon className="mr-2 -ml-0.5 h-4 w-4" aria-hidden="true" />- Configure Tracing- </Button>- );-- return (- <Link href={setupTracingRoute(project.id)}>- <Button>Configure Tracing</Button>- </Link>- );-};--export default SetupTracingButton;diff --git a/web/src/features/tag/components/TagCreateItem.tsx b/web/src/features/tag/components/TagCreateItem.tsxdeleted file mode 100644index e0ddc94dfd..0000000000--- a/web/src/features/tag/components/TagCreateItem.tsx+++ /dev/null@@ -1,36 +0,0 @@-/* eslint-disable @repo/no-null-render */-import React from "react";-import { CommandItem } from "cmdk";--type TagItemCreateProps = {- inputValue: string;- options: string[];- onSelect: () => void;-};--const TagItemCreate = ({- inputValue,- options,- onSelect,-}: TagItemCreateProps) => {- const hasNoOption = !options- .map((value) => value.toLowerCase())- .includes(inputValue.toLowerCase());-- const render = inputValue !== "" && hasNoOption;-- if (!render) return null;-- return (- <CommandItem- key={inputValue}- value={inputValue.trim()}- className="text-muted-foreground hover:bg-secondary/80 flex min-h-8 cursor-pointer items-center rounded-sm px-3 py-1 text-sm"- onSelect={onSelect}- >- Create new tag: "{inputValue.trim()}"- </CommandItem>- );-};--export default TagItemCreate;diff --git a/web/src/features/tag/components/TagManager.tsx b/web/src/features/tag/components/TagManager.tsxindex b7ea7af9f6..86c826914e 100644--- a/web/src/features/tag/components/TagManager.tsx+++ b/web/src/features/tag/components/TagManager.tsx@@ -1,6 +1,5 @@/* eslint-disable @repo/no-style-props, @repo/no-abstracted-overlay-trigger */import TagCommandItem from "@/src/features/tag/components/TagCommandItem";-import TagCreateItem from "@/src/features/tag/components/TagCreateItem";import { TagInput } from "@/src/features/tag/components/TagInput";import TagList from "@/src/features/tag/components/TagList";import { useTagManager } from "@/src/features/tag/hooks/useTagManager";@@ -10,7 +9,7 @@ import {PopoverTrigger,PopoverContent,} from "@/src/components/ui/popover";-import { Command, CommandList, CommandGroup } from "cmdk";+import { Command, CommandGroup, CommandItem, CommandList } from "cmdk";import { cn } from "@/src/utils/tailwind";import { usePostHogClientCapture } from "@/src/features/posthog-analytics";import { Label } from "@/src/components/ui/label";@@ -56,6 +55,11 @@ const TagManager = ({value.toLowerCase().includes(inputValue.trim().toLowerCase()) &&!selectedTags.includes(value),);+ const canCreateTag =+ inputValue !== "" &&+ !filteredTags.some(+ (value) => value.toLowerCase() === inputValue.toLowerCase(),+ );const handlePopoverChange = (open: boolean) => {if (open) {@@ -172,12 +176,16 @@ const TagManager = ({/>))}</CommandGroup>- <TagCreateItem- key={inputValue}- onSelect={handleItemCreate}- inputValue={inputValue}- options={filteredTags}- />+ {canCreateTag && (+ <CommandItem+ key={inputValue}+ value={inputValue.trim()}+ className="text-muted-foreground hover:bg-secondary/80 flex min-h-8 cursor-pointer items-center rounded-sm px-3 py-1 text-sm"+ onSelect={handleItemCreate}+ >+ Create new tag: "{inputValue.trim()}"+ </CommandItem>+ )}</CommandList></Command></PopoverContent>diff --git a/web/src/features/traces/components/BreakdownTooltip.tsx b/web/src/features/traces/components/BreakdownTooltip.tsxindex 05b4e2e1e6..98bed12dc6 100644--- a/web/src/features/traces/components/BreakdownTooltip.tsx+++ b/web/src/features/traces/components/BreakdownTooltip.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import {Tooltip,TooltipContent,@@ -52,6 +51,17 @@ export const BreakdownTooltip = ({const formatValue = (value: number) =>isCost ? usdFormatter(value, 2, 12) : value ? value.toLocaleString() : "0";+ const otherEntries = Object.entries(aggregatedDetails)+ .filter(+ ([key]) =>+ !key.includes("input") && !key.includes("output") && key !== "total",+ )+ .sort(([, a], [, b]) => (b ?? 0) - (a ?? 0));+ const otherTotal = otherEntries.reduce((acc, [, value]) => {+ if (typeof value !== "number") return acc;++ return acc + value;+ }, 0);return (<TooltipProvider>@@ -117,11 +127,23 @@ export const BreakdownTooltip = ({/>{/* Other Section */}- <OtherSection- details={aggregatedDetails}- isCost={isCost}- formatValue={formatValue}- />+ {otherEntries.length > 0 && (+ <div className="flex min-w-0 flex-col gap-2">+ <BreakdownRow+ label={isCost ? "Other cost" : "Other usage"}+ value={formatValue(otherTotal)}+ variant="section"+ />+ {otherEntries.map(([key, value]) => (+ <BreakdownRow+ key={key}+ label={key}+ value={formatValue(value ?? 0)}+ variant="item"+ />+ ))}+ </div>+ )}{/* Total */}<BreakdownRow@@ -209,44 +231,3 @@ const Section = ({ title, details, filterFn, formatValue }: SectionProps) => {</div>);};--interface OtherSectionProps {- details: Details;- isCost: boolean;- formatValue: (value: number) => string;-}--const OtherSection = ({ details, isCost, formatValue }: OtherSectionProps) => {- const otherEntries = Object.entries(details)- .filter(- ([key]) =>- !key.includes("input") && !key.includes("output") && key !== "total",- )- .sort(([, a], [, b]) => (b ?? 0) - (a ?? 0));-- if (otherEntries.length === 0) return null;-- const otherTotal = otherEntries.reduce((acc, val) => {- if (typeof val[1] !== "number") return acc;-- return acc + (val[1] ?? 0);- }, 0);-- return (- <div className="flex min-w-0 flex-col gap-2">- <BreakdownRow- label={isCost ? "Other cost" : "Other usage"}- value={formatValue(otherTotal)}- variant="section"- />- {otherEntries.map(([key, value]) => (- <BreakdownRow- key={key}- label={key}- value={formatValue(value ?? 0)}- variant="item"- />- ))}- </div>- );-};diff --git a/web/src/features/traces/components/DetailHeaderActionsMenuController.tsx b/web/src/features/traces/components/DetailHeaderActionsMenuController.tsxindex 0ddf932da4..f1f1439ec9 100644--- a/web/src/features/traces/components/DetailHeaderActionsMenuController.tsx+++ b/web/src/features/traces/components/DetailHeaderActionsMenuController.tsx@@ -1,6 +1,6 @@import { useRouter } from "next/router";import { CheckIcon, CopyIcon } from "lucide-react";-import { useState, type ComponentProps } from "react";+import { useState, type ComponentProps, type ReactNode } from "react";import {DropdownMenuItem,DropdownMenuSeparator,@@ -12,7 +12,10 @@ import {} from "@/src/features/events/lib/eventsTablePaths";import { copyTextToClipboard } from "@/src/utils/clipboard";import { type ObservationType } from "@langfuse/shared";-import { WebCalloutMenuItem } from "@/src/features/web-callouts/components/WebCalloutMenuItem";+import {+ useWebCalloutAction,+ WebCalloutMenuItem,+} from "@/src/features/web-callouts/components/WebCalloutMenuItem";type IdItem = {name: string;@@ -32,6 +35,28 @@ type DetailHeaderActionsMenuControllerProps = {children: ComponentProps<typeof DropdownMenuController>["children"];};+function WebCalloutActionController({+ projectId,+ webCallout,+ children,+}: {+ projectId: string;+ webCallout: NonNullable<DetailHeaderActionsMenuControllerProps["webCallout"]>;+ children: (action: ReturnType<typeof useWebCalloutAction>) => ReactNode;+}) {+ const webCalloutAction = useWebCalloutAction(+ {+ projectId,+ traceId: webCallout.traceId,+ observationId: webCallout.observationId,+ sessionId: webCallout.sessionId,+ },+ true,+ );++ return children(webCalloutAction);+}+export function DetailHeaderActionsMenuController({idItems,observationType,@@ -75,13 +100,16 @@ export function DetailHeaderActionsMenuController({renderMenu={() => (<>{webCallout && (- <WebCalloutMenuItem+ <WebCalloutActionControllerprojectId={projectId}- traceId={webCallout.traceId}- observationId={webCallout.observationId}- sessionId={webCallout.sessionId}- withSeparator- />+ webCallout={webCallout}+ >+ {(webCalloutAction) =>+ webCalloutAction ? (+ <WebCalloutMenuItem action={webCalloutAction} withSeparator />+ ) : null+ }+ </WebCalloutActionController>)}{(href || typeHref) && (<>diff --git a/web/src/features/traces/components/IOPreview/IOPreviewJSON.tsx b/web/src/features/traces/components/IOPreview/IOPreviewJSON.tsxindex bf7fd8f452..d4e32a3d8d 100644--- a/web/src/features/traces/components/IOPreview/IOPreviewJSON.tsx+++ b/web/src/features/traces/components/IOPreview/IOPreviewJSON.tsx@@ -145,6 +145,10 @@ function IOPreviewJSONInner({showCorrections = true,}: IOPreviewJSONProps) {const selectionContext = useInlineCommentSelectionOptional();+ const inlineCommentPositionRect = selectionContext?.selection?.anchorRect+ ? (selectionContext.selection.startRect ??+ selectionContext.selection.anchorRect)+ : null;const handleAddComment = useCallback(() => {if (selectionContext?.selection && onAddInlineComment) {@@ -650,8 +654,11 @@ function IOPreviewJSONInner({return (<div className="ph-no-capture flex min-h-0 flex-1 flex-col border-t border-b">{/* Inline comment bubble - shows when text is selected */}- {enableInlineComments && (- <InlineCommentBubble onAddComment={handleAddComment} />+ {enableInlineComments && inlineCommentPositionRect && (+ <InlineCommentBubble+ onAddComment={handleAddComment}+ positionRect={inlineCommentPositionRect}+ />)}{/* Header - matches LogViewToolbar styling */}diff --git a/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader.tsx b/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader.tsxindex f70f93029c..fbe47e67ee 100644--- a/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader.tsx+++ b/web/src/features/traces/components/ObservationDetailView/components/ObservationDetailViewHeader/ObservationDetailViewHeader.tsx@@ -186,6 +186,11 @@ export const ObservationDetailViewHeader = memo(date: observation.startTime,accuracy: "millisecond",});+ const displayedTotalCost = subtreeMetrics+ ? (treeNodeTotalCost?.toNumber() ?? subtreeMetrics.totalCost)+ : totalCost;+ const displayedCostDetails =+ subtreeMetrics?.costDetails ?? observation.costDetails;return (<div className="@container shrink-0 space-y-2 border-b p-2">@@ -392,10 +397,12 @@ export const ObservationDetailViewHeader = memo(><ListPlus className="h-4 w-4" /><span className="text-sm">Add to queue</span>- <AnnotationQueueItemCountBadge- totalCount={totalCount}- layout="menu"- />+ {totalCount > 0 && (+ <AnnotationQueueItemCountBadge+ totalCount={totalCount}+ layout="menu"+ />+ )}</Button>)}</AnnotationQueueItemDropdownMenuController>@@ -605,10 +612,12 @@ export const ObservationDetailViewHeader = memo(><span className="relative mr-1 text-xs"><ChevronDown className="h-3 w-3" />- <AnnotationQueueItemCountBadge- totalCount={totalCount}- layout="toolbar"- />+ {totalCount > 0 && (+ <AnnotationQueueItemCountBadge+ totalCount={totalCount}+ layout="toolbar"+ />+ )}</span></Button>)}@@ -714,55 +723,49 @@ export const ObservationDetailViewHeader = memo(/><EnvironmentBadge environment={observation.environment} /><ReleaseBadge release={observation.release} />- <CostBadge- totalCost={- subtreeMetrics- ? (treeNodeTotalCost?.toNumber() ??- subtreeMetrics.totalCost)- : totalCost- }- costDetails={- subtreeMetrics?.costDetails ?? observation.costDetails- }- priceSource={- isGenerationLike(observation.type) &&- observation.internalModelId &&- observation.model &&- observation.usagePricingTierId &&- observation.usagePricingTierName &&- Object.keys(observation.providedCostDetails).length === 0 &&- (!subtreeMetrics ||- treeNodeTotalCost?.eq(totalCost ?? 0) === true)- ? {- projectId,- modelId: observation.internalModelId,- modelName: observation.model,- pricingTierId: observation.usagePricingTierId,- pricingTierName: observation.usagePricingTierName,- }- : undefined- }- />- {subtreeMetrics ? (- subtreeMetrics.hasGenerationLike &&- subtreeMetrics.usageDetails && (- <UsageBadge- type="GENERATION"- inputUsage={subtreeMetrics.inputUsage}- outputUsage={subtreeMetrics.outputUsage}- totalUsage={subtreeMetrics.totalUsage}- usageDetails={subtreeMetrics.usageDetails}- />- )- ) : (- <UsageBadge- type={observation.type}- inputUsage={inputUsage}- outputUsage={outputUsage}- totalUsage={totalUsage}- usageDetails={observation.usageDetails}+ {displayedTotalCost != null && displayedCostDetails && (+ <CostBadge+ totalCost={displayedTotalCost}+ costDetails={displayedCostDetails}+ priceSource={+ isGenerationLike(observation.type) &&+ observation.internalModelId &&+ observation.model &&+ observation.usagePricingTierId &&+ observation.usagePricingTierName &&+ Object.keys(observation.providedCostDetails).length === 0 &&+ (!subtreeMetrics ||+ treeNodeTotalCost?.eq(totalCost ?? 0) === true)+ ? {+ projectId,+ modelId: observation.internalModelId,+ modelName: observation.model,+ pricingTierId: observation.usagePricingTierId,+ pricingTierName: observation.usagePricingTierName,+ }+ : undefined+ }/>)}+ {subtreeMetrics+ ? subtreeMetrics.hasGenerationLike &&+ subtreeMetrics.usageDetails && (+ <UsageBadge+ inputUsage={subtreeMetrics.inputUsage}+ outputUsage={subtreeMetrics.outputUsage}+ totalUsage={subtreeMetrics.totalUsage}+ usageDetails={subtreeMetrics.usageDetails}+ />+ )+ : isGenerationLike(observation.type) &&+ observation.usageDetails && (+ <UsageBadge+ inputUsage={inputUsage}+ outputUsage={outputUsage}+ totalUsage={totalUsage}+ usageDetails={observation.usageDetails}+ />+ )}<VersionBadge version={observation.version} /><ModelBadgemodel={observation.model}diff --git a/web/src/features/traces/components/ObservationMetadataBadgesTooltip.tsx b/web/src/features/traces/components/ObservationMetadataBadgesTooltip.tsxindex 6f5c5dd460..9d00e28953 100644--- a/web/src/features/traces/components/ObservationMetadataBadgesTooltip.tsx+++ b/web/src/features/traces/components/ObservationMetadataBadgesTooltip.tsx@@ -1,10 +1,8 @@-/* eslint-disable @repo/no-null-render *//*** Tooltip-based metadata badges for ObservationDetailView* These badges use BreakdownTooltip to show detailed cost/usage information*/-import { type ObservationType, isGenerationLike } from "@langfuse/shared";import { Badge, BadgeShell } from "@/src/components/design-system/Badge/Badge";import {BreakdownTooltip,@@ -18,13 +16,10 @@ export function CostBadge({costDetails,priceSource,}: {- totalCost: number | null;- costDetails: Record<string, number> | undefined;+ totalCost: number;+ costDetails: Record<string, number>;priceSource?: PriceSource;}) {- // Don't show if no cost data. Explicit 0 is a real value and should render.- if (totalCost == null || !costDetails) return null;-return (<BreakdownTooltipdetails={costDetails}@@ -37,21 +32,16 @@ export function CostBadge({}export function UsageBadge({- type,inputUsage,outputUsage,totalUsage,usageDetails,}: {- type: ObservationType;inputUsage: number;outputUsage: number;totalUsage: number;- usageDetails: Record<string, number> | undefined;+ usageDetails: Record<string, number>;}) {- // Only show for generation-like observations- if (!isGenerationLike(type) || !usageDetails) return null;-const tokenText = formatTokenCounts(inputUsage,outputUsage,diff --git a/web/src/features/traces/components/SpanContent.tsx b/web/src/features/traces/components/SpanContent.tsxindex dd5d06166b..59cf91abff 100644--- a/web/src/features/traces/components/SpanContent.tsx+++ b/web/src/features/traces/components/SpanContent.tsx@@ -131,9 +131,9 @@ export function SpanContent({<div className="flex items-center gap-x-2">{/* Comment count */}- {showComments && commentCount !== undefined && (- <CommentCountIcon count={commentCount} />- )}+ {showComments &&+ commentCount !== undefined &&+ commentCount !== 0 && <CommentCountIcon count={commentCount} />}{/* Level badge */}{node.type !== "TRACE" &&diff --git a/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx b/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsxindex 668a4d9841..a062e3ccb0 100644--- a/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx+++ b/web/src/features/traces/components/TraceDetailView/components/TraceDetailViewHeader.tsx@@ -282,10 +282,12 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({><ListPlus className="h-4 w-4" /><span className="text-sm">Add to queue</span>- <AnnotationQueueItemCountBadge- totalCount={totalCount}- layout="menu"- />+ {totalCount > 0 && (+ <AnnotationQueueItemCountBadge+ totalCount={totalCount}+ layout="menu"+ />+ )}</Button>)}</AnnotationQueueItemDropdownMenuController>@@ -430,10 +432,12 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({><span className="relative mr-1 text-xs"><ChevronDown className="h-3 w-3" />- <AnnotationQueueItemCountBadge- totalCount={totalCount}- layout="toolbar"- />+ {totalCount > 0 && (+ <AnnotationQueueItemCountBadge+ totalCount={totalCount}+ layout="toolbar"+ />+ )}</span></Button>)}@@ -499,14 +503,16 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({<EnvironmentBadge environment={trace.environment} /><ReleaseBadge release={trace.release} /><VersionBadge version={trace.version} />- <CostBadge- totalCost={aggregatedMetrics.totalCost}- costDetails={aggregatedMetrics.costDetails}- />+ {aggregatedMetrics.totalCost != null &&+ aggregatedMetrics.costDetails && (+ <CostBadge+ totalCost={aggregatedMetrics.totalCost}+ costDetails={aggregatedMetrics.costDetails}+ />+ )}{aggregatedMetrics.hasGenerationLike &&aggregatedMetrics.usageDetails && (<UsageBadge- type="GENERATION"inputUsage={aggregatedMetrics.inputUsage}outputUsage={aggregatedMetrics.outputUsage}totalUsage={aggregatedMetrics.totalUsage}diff --git a/web/src/features/traces/components/TraceMetadataBadges.clienttest.tsx b/web/src/features/traces/components/TraceMetadataBadges.clienttest.tsxindex bbb5af452b..d354f78a04 100644--- a/web/src/features/traces/components/TraceMetadataBadges.clienttest.tsx+++ b/web/src/features/traces/components/TraceMetadataBadges.clienttest.tsx@@ -48,7 +48,6 @@ describe("UsageBadge", () => {it("keeps custom usage details accessible without aggregate token totals", () => {render(<UsageBadge- type="GENERATION"inputUsage={0}outputUsage={0}totalUsage={0}diff --git a/web/src/features/v4-migration/V4MigrationBanner.clienttest.tsx b/web/src/features/v4-migration/V4MigrationBanner.clienttest.tsxindex 718ed74893..eb268261d0 100644--- a/web/src/features/v4-migration/V4MigrationBanner.clienttest.tsx+++ b/web/src/features/v4-migration/V4MigrationBanner.clienttest.tsx@@ -1,11 +1,14 @@-import { render, screen } from "@testing-library/react";+import { render, renderHook, screen } from "@testing-library/react";import { beforeEach, describe, expect, it, vi } from "vitest";-import { V4MigrationBanner } from "./V4MigrationBanner";+import {+ V4MigrationBanner,+ useV4MigrationBannerState,+} from "./V4MigrationBanner";import { type ProjectMigrationStatus } from "./migrationData";const mocks = vi.hoisted(() => ({- statusByProjectId: new Map<string, object>(),+ statusByProjectId: new Map<string, ProjectMigrationStatus>(),organizationsArg: undefined as unknown,}));@@ -71,61 +74,57 @@ describe("V4MigrationBanner", () => {});it("shows while the only project still needs migration work", () => {- mocks.statusByProjectId.set(- "project-1",- status({ evals: { status: "loaded", count: 2 } }),+ render(+ <V4MigrationBanner projectsNeedingMigration={1} totalProjects={1} />,);- render(<V4MigrationBanner />);expect(screen.getByText(/Your project needs an upgrade/),).toBeInTheDocument();});it("says all projects need an upgrade only when they all do", () => {- mocks.statusByProjectId.set(- "project-1",- status({ evals: { status: "loaded", count: 2 } }),+ render(+ <V4MigrationBanner projectsNeedingMigration={2} totalProjects={2} />,);- mocks.statusByProjectId.set(- "project-2",- status({ apis: { status: "loaded", count: 1 } }),- );- render(<V4MigrationBanner />);expect(screen.getByText(/All projects need an upgrade/),).toBeInTheDocument();});it("counts the projects needing an upgrade in mixed accounts", () => {- mocks.statusByProjectId.set(- "project-1",- status({ evals: { status: "loaded", count: 2 } }),+ render(+ <V4MigrationBanner projectsNeedingMigration={1} totalProjects={2} />,);- mocks.statusByProjectId.set("project-2", status());- render(<V4MigrationBanner />);expect(screen.getByText(/1 of your 2 projects needs an upgrade/),).toBeInTheDocument();});- it("hides once every project is ready", () => {+ it("returns no migration work once every project is ready", () => {mocks.statusByProjectId.set("project-1", status());- render(<V4MigrationBanner />);- expect(screen.queryByText(/an upgrade/)).not.toBeInTheDocument();++ const { result } = renderHook(() => useV4MigrationBannerState(true));++ expect(result.current).toEqual({+ projectsNeedingMigration: 0,+ totalProjects: 1,+ });});- it("hides while readiness is still being checked", () => {+ it("returns no migration work while readiness is still being checked", () => {mocks.statusByProjectId.set("project-1",status({ evals: { status: "loading", count: 0 } }),);- render(<V4MigrationBanner />);- expect(screen.queryByText(/an upgrade/)).not.toBeInTheDocument();++ const { result } = renderHook(() => useV4MigrationBannerState(true));++ expect(result.current.projectsNeedingMigration).toBe(0);});it("excludes the demo org and deleted projects from the queried scope", () => {- mocks.statusByProjectId.set("project-1", status());- render(<V4MigrationBanner />);+ renderHook(() => useV4MigrationBannerState(true));+expect(mocks.organizationsArg).toEqual([{id: "org-1",diff --git a/web/src/features/v4-migration/V4MigrationBanner.tsx b/web/src/features/v4-migration/V4MigrationBanner.tsxindex 03270ea782..815a74dd15 100644--- a/web/src/features/v4-migration/V4MigrationBanner.tsx+++ b/web/src/features/v4-migration/V4MigrationBanner.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import Link from "next/link";import { useSession } from "next-auth/react";import { Zap } from "lucide-react";@@ -15,15 +14,7 @@ const V4_DOCS_URL = "https://langfuse.com/docs/v4";// migration deadline approaches.const DISMISS_TTL_MS = 7 * 24 * 60 * 60 * 1000;-/**- * Org-overview banner announcing v4 with links to the migration status page- * and docs. Replaces the agent-tools banner for v4-upgrade users. Only shown- * while at least one project still needs migration work — the queries are the- * same ones the project tiles' migration chips use, so react-query dedupes- * them.- */-export function V4MigrationBanner() {- const capture = usePostHogClientCapture();+export function useV4MigrationBannerState(enabled: boolean) {const session = useSession();// The demo org is not the user's to migrate, so it never triggers the banner.@@ -38,16 +29,30 @@ export function V4MigrationBanner() {}));const migrationStatusByProjectId = useAccountV4MigrationData({organizations,- enabled: organizations.length > 0,+ enabled: enabled && organizations.length > 0,});const statuses = Array.from(migrationStatusByProjectId.values());- const projectsNeedingMigration = statuses.filter(- (status) => getProjectMigrationReadiness(status) === "action-needed",- ).length;- if (projectsNeedingMigration === 0) {- return null;- }+ return {+ projectsNeedingMigration: statuses.filter(+ (status) => getProjectMigrationReadiness(status) === "action-needed",+ ).length,+ totalProjects: statuses.length,+ };+}++/**+ * Org-overview banner announcing v4 with links to the migration status page and+ * docs. The overview owns visibility through useV4MigrationBannerState.+ */+export function V4MigrationBanner({+ projectsNeedingMigration,+ totalProjects,+}: {+ projectsNeedingMigration: number;+ totalProjects: number;+}) {+ const capture = usePostHogClientCapture();return (<DismissController@@ -94,11 +99,11 @@ export function V4MigrationBanner() {<span className="font-bold">Langfuse v4 is here: real-time and up to 165× faster.</span>{" "}- {projectsNeedingMigration === statuses.length+ {projectsNeedingMigration === totalProjects? projectsNeedingMigration === 1? "Your project needs an upgrade.": "All projects need an upgrade."- : `${projectsNeedingMigration} of your ${statuses.length} projects ${projectsNeedingMigration === 1 ? "needs" : "need"} an upgrade.`}+ : `${projectsNeedingMigration} of your ${totalProjects} projects ${projectsNeedingMigration === 1 ? "needs" : "need"} an upgrade.`}</span></div></Callout>diff --git a/web/src/features/v4-migration/V4MigrationEntryPoints.clienttest.tsx b/web/src/features/v4-migration/V4MigrationEntryPoints.clienttest.tsxindex 968c6e97de..20ee92517b 100644--- a/web/src/features/v4-migration/V4MigrationEntryPoints.clienttest.tsx+++ b/web/src/features/v4-migration/V4MigrationEntryPoints.clienttest.tsx@@ -89,18 +89,9 @@ describe("v4 migration entry points", () => {expect(upgradeIndex).toBeGreaterThan(updateIndex);});- it("hides the project chip and sidebar item when the project is up to date", () => {- render(- <>- <V4MigrationProjectChip- project={{ id: "project-1", name: "Project 1" }}- status={mocks.migrationData}- />- <V4MigrationNavItem />- </>,- );+ it("hides the sidebar item when the project is up to date", () => {+ render(<V4MigrationNavItem />);- expect(screen.queryByText("Up to date")).not.toBeInTheDocument();expect(screen.queryByRole("button")).not.toBeInTheDocument();});@@ -114,7 +105,7 @@ describe("v4 migration entry points", () => {<><V4MigrationProjectChipproject={{ id: "project-1", name: "Project 1" }}- status={mocks.migrationData}+ readiness="action-needed"/><V4MigrationNavItem /></>,@@ -124,21 +115,13 @@ describe("v4 migration entry points", () => {expect(screen.getByText("Action required")).toBeInTheDocument();});- it("hides both entry points while checks are pending or unavailable", () => {+ it("hides the sidebar item while checks are pending or unavailable", () => {for (const status of [migrationStatus({ evals: { status: "loading", count: 0 } }),migrationStatus({ evals: { status: "error", count: 0 } }),]) {mocks.migrationData = status;- const { unmount } = render(- <>- <V4MigrationProjectChip- project={{ id: "project-1", name: "Project 1" }}- status={status}- />- <V4MigrationNavItem />- </>,- );+ const { unmount } = render(<V4MigrationNavItem />);expect(screen.queryByRole("button")).not.toBeInTheDocument();unmount();diff --git a/web/src/features/v4-migration/V4MigrationProjectChip.tsx b/web/src/features/v4-migration/V4MigrationProjectChip.tsxindex fa237c9429..c972d8d513 100644--- a/web/src/features/v4-migration/V4MigrationProjectChip.tsx+++ b/web/src/features/v4-migration/V4MigrationProjectChip.tsx@@ -1,24 +1,22 @@-/* eslint-disable @repo/no-null-render */import { type V4MigrationTargetProject } from "@/src/features/v4-migration/V4MigrationPanelProvider";import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import {- getProjectMigrationReadiness,- type ProjectMigrationStatus,-} from "@/src/features/v4-migration/migrationData";+import { type ProjectMigrationReadiness } from "@/src/features/v4-migration/migrationData";import { useOpenV4MigrationPanel } from "@/src/features/v4-migration/hooks/useOpenV4MigrationPanel";import { PARTNER_INTEGRATION_FAQ_URL } from "@/src/features/v4-migration/partnerIntegrationDocs";export function V4MigrationProjectChip({project,- status,+ readiness,}: {project: V4MigrationTargetProject;- status: ProjectMigrationStatus | undefined;+ readiness: Extract<+ ProjectMigrationReadiness,+ "action-needed" | "partner-managed"+ >;}) {const openMigrationPanel = useOpenV4MigrationPanel();const capture = usePostHogClientCapture();- const readiness = status ? getProjectMigrationReadiness(status) : "checking";// Forced-v3 projects show no migration action — the upgrade is handled by// their integration partner. Point them at the FAQ instead.if (readiness === "partner-managed") {@@ -39,10 +37,6 @@ export function V4MigrationProjectChip({);}- if (readiness !== "action-needed") {- return null;- }-const handleClick = () => {capture("v4_migration:project_chip_clicked");openMigrationPanel(project, "project_chip");diff --git a/web/src/features/version-update/VersionUpdateBanner.clienttest.tsx b/web/src/features/version-update/VersionUpdateBanner.clienttest.tsxindex b1ffb6ca70..9f1fc11ace 100644--- a/web/src/features/version-update/VersionUpdateBanner.clienttest.tsx+++ b/web/src/features/version-update/VersionUpdateBanner.clienttest.tsx@@ -1,7 +1,13 @@-import { act, render, screen, fireEvent } from "@testing-library/react";+import {+ act,+ render,+ renderHook,+ screen,+ fireEvent,+} from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { VersionUpdateBanner } from "./VersionUpdateBanner";-import { VersionUpdateBannerView } from "./VersionUpdateBannerView";+import { useVersionUpdatePrompt } from "./useVersionUpdatePrompt";import {createVersionUpdateStore,VERSION_UPDATE_MIN_STALENESS_MS,@@ -87,10 +93,10 @@ afterEach(() => {vi.restoreAllMocks();});-it("VersionUpdateBannerView renders both controls and invokes their callbacks", () => {+it("VersionUpdateBanner renders both controls and invokes their callbacks", () => {const onReload = vi.fn();const onDismiss = vi.fn();- render(<VersionUpdateBannerView onReload={onReload} onDismiss={onDismiss} />);+ render(<VersionUpdateBanner onReload={onReload} onDismiss={onDismiss} />);fireEvent.click(screen.getByRole("button", { name: "Reload" }));expect(onReload).toHaveBeenCalledTimes(1);@@ -98,9 +104,9 @@ it("VersionUpdateBannerView renders both controls and invokes their callbacks",expect(onDismiss).toHaveBeenCalledTimes(1);});-it("VersionUpdateBannerView opts out of outside-interaction dismissal", () => {+it("VersionUpdateBanner opts out of outside-interaction dismissal", () => {render(- <VersionUpdateBannerView+ <VersionUpdateBanneronReload={() => undefined}onDismiss={() => undefined}/>,@@ -111,10 +117,11 @@ it("VersionUpdateBannerView opts out of outside-interaction dismissal", () => {);});-describe("VersionUpdateBanner (connected)", () => {- it("shows and reports banner_shown exactly once when available and settled", () => {- render(<VersionUpdateBanner />);- expect(screen.getByRole("button", { name: "Reload" })).toBeInTheDocument();+describe("useVersionUpdatePrompt", () => {+ it("becomes visible and reports banner_shown exactly once when available and settled", () => {+ const { result } = renderHook(() => useVersionUpdatePrompt());++ expect(result.current.isVisible).toBe(true);expect(h.capture.mock.calls.filter((c) => c[0] === "version_update:banner_shown",@@ -122,33 +129,31 @@ describe("VersionUpdateBanner (connected)", () => {).toHaveLength(1);});- it("renders nothing (and captures nothing) while unsettled or without an update", () => {+ it("stays hidden and captures nothing while unsettled or without an update", () => {h.settled = false;- const unsettled = render(<VersionUpdateBanner />);- expect(- screen.queryByRole("button", { name: "Reload" }),- ).not.toBeInTheDocument();+ const unsettled = renderHook(() => useVersionUpdatePrompt());+ expect(unsettled.result.current.isVisible).toBe(false);unsettled.unmount();h.settled = true;h.available = false;- render(<VersionUpdateBanner />);- expect(- screen.queryByRole("button", { name: "Reload" }),- ).not.toBeInTheDocument();+ const unavailable = renderHook(() => useVersionUpdatePrompt());+ expect(unavailable.result.current.isVisible).toBe(false);expect(h.capture).not.toHaveBeenCalled();});it("captures reload_clicked and reloads on Reload", () => {- render(<VersionUpdateBanner />);- fireEvent.click(screen.getByRole("button", { name: "Reload" }));+ const { result } = renderHook(() => useVersionUpdatePrompt());++ act(() => result.current.reload());+expect(h.capture).toHaveBeenCalledWith("version_update:reload_clicked");expect(window.location.reload).toHaveBeenCalledTimes(1);});});-describe("VersionUpdateBanner (integration: real store + fake storage)", () => {- it("renders nothing and fires no banner_shown until the frontend is 48 h stale", () => {+describe("useVersionUpdatePrompt (integration: real store + fake storage)", () => {+ it("stays hidden and fires no banner_shown until the frontend is 48 h stale", () => {const storage = createFakeStorage();let now = 0;const store = createVersionUpdateStore(() => "running", {@@ -158,13 +163,11 @@ describe("VersionUpdateBanner (integration: real store + fake storage)", () => {});h.store = store;- render(<VersionUpdateBanner />);+ const { result } = renderHook(() => useVersionUpdatePrompt());act(() => {store.reportObservedBuildId("deployed");});- expect(- screen.queryByRole("button", { name: "Reload" }),- ).not.toBeInTheDocument();+ expect(result.current.isVisible).toBe(false);expect(h.capture).not.toHaveBeenCalled();// 48 h later the next response surfaces it; banner_shown fires once.@@ -172,7 +175,7 @@ describe("VersionUpdateBanner (integration: real store + fake storage)", () => {now = VERSION_UPDATE_MIN_STALENESS_MS;store.reportObservedBuildId("deployed");});- expect(screen.getByRole("button", { name: "Reload" })).toBeInTheDocument();+ expect(result.current.isVisible).toBe(true);expect(h.capture.mock.calls.filter((c) => c[0] === "version_update:banner_shown",@@ -191,17 +194,15 @@ describe("VersionUpdateBanner (integration: real store + fake storage)", () => {});h.store = store;- render(<VersionUpdateBanner />);+ const { result } = renderHook(() => useVersionUpdatePrompt());act(() => {store.reportObservedBuildId("deployed");});- expect(screen.getByRole("button", { name: "Reload" })).toBeInTheDocument();+ expect(result.current.isVisible).toBe(true);- fireEvent.click(screen.getByRole("button", { name: "Dismiss" }));+ act(() => result.current.dismiss());expect(h.capture).toHaveBeenCalledWith("version_update:dismissed");- expect(- screen.queryByRole("button", { name: "Reload" }),- ).not.toBeInTheDocument();+ expect(result.current.isVisible).toBe(false);expect(storage.getItem(VERSION_UPDATE_SUPPRESSED_UNTIL_KEY)).toBe(String(1_000 + VERSION_UPDATE_DISMISS_SUPPRESSION_MS),);@@ -210,8 +211,6 @@ describe("VersionUpdateBanner (integration: real store + fake storage)", () => {now = 2_000;store.reportObservedBuildId("deployed-2"); // genuinely new — still quiet});- expect(- screen.queryByRole("button", { name: "Reload" }),- ).not.toBeInTheDocument();+ expect(result.current.isVisible).toBe(false);});});diff --git a/web/src/features/version-update/VersionUpdateBanner.tsx b/web/src/features/version-update/VersionUpdateBanner.tsxindex 1f88fe5521..5cc38d66b9 100644--- a/web/src/features/version-update/VersionUpdateBanner.tsx+++ b/web/src/features/version-update/VersionUpdateBanner.tsx@@ -1,58 +1,20 @@-/* eslint-disable @repo/no-null-render */-import { useEffect } from "react";import { Layer } from "@/src/components/ui/layer";-import { usePostHogClientCapture } from "@/src/features/posthog-analytics";-import { versionUpdateStore } from "./versionUpdateStore";-import { useVersionUpdateAvailable } from "./useVersionUpdateAvailable";-import { useAppSettled } from "./useAppSettled";import { VersionUpdateBannerView } from "./VersionUpdateBannerView";/**- * App-wide notification prompting the user to reload when a newer build has- * been deployed while their tab stayed open (LFE-10978, §4.9).- *- * Visibility is `updateAvailable && appSettled` — both read from module-level- * external stores via `useSyncExternalStore` (no effect-driven state sync).- * `updateAvailable` comes from {@link versionUpdateStore} (fed by the tRPC- * `buildIdLink`); {@link useAppSettled} holds the banner out of the noisy- * startup window. Keeping both in module scope means the state survives banner- * remounts (e.g. AppLayout switching between AuthenticatedLayout and- * MinimalLayout) rather than re-hiding for the grace period each time.- *- * Renders into the top-most overlay layer (`toast`) so it floats above content- * rather than pushing page chrome down. Analytics: `banner_shown` once per- * appearance, plus the reload / dismiss actions.+ * App-wide notification rendered into the top-most overlay layer (`toast`) so+ * it floats above content rather than pushing page chrome down.*/-export function VersionUpdateBanner() {- const updateAvailable = useVersionUpdateAvailable();- const appSettled = useAppSettled();- const isVisible = updateAvailable && appSettled;- const capture = usePostHogClientCapture();-- // Analytics side-effect (external system = PostHog): report `banner_shown`- // once per appearance. The once-guard lives in the store, so a banner remount- // cannot double-count one continuous appearance and a StrictMode-double-- // invoked effect still fires the event only once.- useEffect(() => {- if (isVisible && versionUpdateStore.markShownReported()) {- capture("version_update:banner_shown");- }- }, [isVisible, capture]);-- if (!isVisible) return null;-+export function VersionUpdateBanner({+ onReload,+ onDismiss,+}: {+ onReload: () => void;+ onDismiss: () => void;+}) {return (<Layer name="toast">- <VersionUpdateBannerView- onReload={() => {- capture("version_update:reload_clicked");- window.location.reload();- }}- onDismiss={() => {- capture("version_update:dismissed");- versionUpdateStore.dismiss();- }}- />+ <VersionUpdateBannerView onReload={onReload} onDismiss={onDismiss} /></Layer>);}diff --git a/web/src/features/version-update/VersionUpdateBannerView.tsx b/web/src/features/version-update/VersionUpdateBannerView.tsxindex 18365ef8c4..df77897aef 100644--- a/web/src/features/version-update/VersionUpdateBannerView.tsx+++ b/web/src/features/version-update/VersionUpdateBannerView.tsx@@ -21,8 +21,7 @@ export type VersionUpdateBannerViewProps = {* instead of overlapping it.** Purely props-driven (no store/context/data) so it renders in isolation — see- * `VersionUpdateBannerView.stories.tsx`. The connected {@link VersionUpdateBanner}- * wires it to the store, the overlay layer, and analytics.+ * `VersionUpdateBannerView.stories.tsx`.** We prompt rather than auto-reload: reloading would discard unsaved work (open* annotations, editors); the user reloads when it is safe for them.diff --git a/web/src/features/version-update/index.ts b/web/src/features/version-update/index.tsindex 275260baf6..f45808957c 100644--- a/web/src/features/version-update/index.ts+++ b/web/src/features/version-update/index.ts@@ -1 +1,2 @@export { VersionUpdateBanner } from "./VersionUpdateBanner";+export { useVersionUpdatePrompt } from "./useVersionUpdatePrompt";diff --git a/web/src/features/version-update/useVersionUpdatePrompt.ts b/web/src/features/version-update/useVersionUpdatePrompt.tsnew file mode 100644index 0000000000..1c4943165d--- /dev/null+++ b/web/src/features/version-update/useVersionUpdatePrompt.ts@@ -0,0 +1,30 @@+import { useEffect } from "react";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useAppSettled } from "./useAppSettled";+import { useVersionUpdateAvailable } from "./useVersionUpdateAvailable";+import { versionUpdateStore } from "./versionUpdateStore";++export function useVersionUpdatePrompt() {+ const updateAvailable = useVersionUpdateAvailable();+ const appSettled = useAppSettled();+ const isVisible = updateAvailable && appSettled;+ const capture = usePostHogClientCapture();++ useEffect(() => {+ if (isVisible && versionUpdateStore.markShownReported()) {+ capture("version_update:banner_shown");+ }+ }, [isVisible, capture]);++ return {+ isVisible,+ reload: () => {+ capture("version_update:reload_clicked");+ window.location.reload();+ },+ dismiss: () => {+ capture("version_update:dismissed");+ versionUpdateStore.dismiss();+ },+ };+}diff --git a/web/src/features/web-callouts/components/WebCalloutMenuItem.tsx b/web/src/features/web-callouts/components/WebCalloutMenuItem.tsxindex 78ca554d0e..e9f59c2ed9 100644--- a/web/src/features/web-callouts/components/WebCalloutMenuItem.tsx+++ b/web/src/features/web-callouts/components/WebCalloutMenuItem.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import { Webhook } from "lucide-react";import { Button } from "@/src/components/ui/button";@@ -21,11 +20,12 @@ type WebCalloutTarget = {sessionId?: string | null;};-function useWebCalloutAction(props: WebCalloutTarget) {+export function useWebCalloutAction(props: WebCalloutTarget, enabled: boolean) {const endpoint = api.webCallouts.enabled.useQuery({ projectId: props.projectId },{staleTime: 60_000,+ enabled,},);const invokeMutation = api.webCallouts.invoke.useMutation({@@ -58,34 +58,26 @@ function useWebCalloutAction(props: WebCalloutTarget) {});};+ if (!enabled || endpoint.data?.enabled !== true) {+ return undefined;+ }+return {endpointName: endpoint.data?.name ?? "Web callout",isLoading: invokeMutation.isPending,- isVisible: endpoint.data?.enabled === true,invokeCallout,};}+type WebCalloutAction = NonNullable<ReturnType<typeof useWebCalloutAction>>;+export function WebCalloutMenuItem({- projectId,- traceId,- observationId,- sessionId,+ action,withSeparator,-}: WebCalloutTarget & {+}: {+ action: WebCalloutAction;withSeparator?: boolean;}) {- const action = useWebCalloutAction({- projectId,- traceId,- observationId,- sessionId,- });-- if (!action.isVisible) {- return null;- }-return (<><DropdownMenuItem@@ -111,12 +103,10 @@ export function WebCalloutMenuItem({}export function WebCalloutButton({- projectId,- traceId,- observationId,- sessionId,+ action,layout = "toolbar",-}: WebCalloutTarget & {+}: {+ action: WebCalloutAction;/*** "toolbar" (default) is the inline icon button; "menu" renders the same* action as a full-width labeled row for the mobile header overflow popover.@@ -125,17 +115,6 @@ export function WebCalloutButton({*/layout?: "toolbar" | "menu";}) {- const action = useWebCalloutAction({- projectId,- traceId,- observationId,- sessionId,- });-- if (!action.isVisible) {- return null;- }-const label = `Call ${action.endpointName}`;if (layout === "menu") {diff --git a/web/src/features/widgets/chart-library/AreaChartTimeSeries.tsx b/web/src/features/widgets/chart-library/AreaChartTimeSeries.tsxindex 8837ca330c..17e4347a5d 100644--- a/web/src/features/widgets/chart-library/AreaChartTimeSeries.tsx+++ b/web/src/features/widgets/chart-library/AreaChartTimeSeries.tsx@@ -120,10 +120,12 @@ export const AreaChartTimeSeries: React.FC<ChartProps> = ({setSelfHovered(false);}}>- <SeriesOverflowNote- visibleCount={dimensions.length}- totalCount={series.total}- />+ {series.total > dimensions.length && (+ <SeriesOverflowNote+ visibleCount={dimensions.length}+ totalCount={series.total}+ />+ )}<ChartContainerref={chartBoxRef}config={config}@@ -218,15 +220,16 @@ export const AreaChartTimeSeries: React.FC<ChartProps> = ({/></AreaChart></ChartContainer>- {(legendPosition === "below" ||- (legendPosition === "auto" && legendItems.length > 1)) && (- <TimeSeriesLegend- items={legendItems}- interaction={legendInteraction}- onItemClick={onLegendClick}- formatSummary={tooltipFormatter}- />- )}+ {legendItems.length > 0 &&+ (legendPosition === "below" ||+ (legendPosition === "auto" && legendItems.length > 1)) && (+ <TimeSeriesLegend+ items={legendItems}+ interaction={legendInteraction}+ onItemClick={onLegendClick}+ formatSummary={tooltipFormatter}+ />+ )}</div>);};diff --git a/web/src/features/widgets/chart-library/LineChartTimeSeries.tsx b/web/src/features/widgets/chart-library/LineChartTimeSeries.tsxindex d8d2c0cd87..6b19bcaf48 100644--- a/web/src/features/widgets/chart-library/LineChartTimeSeries.tsx+++ b/web/src/features/widgets/chart-library/LineChartTimeSeries.tsx@@ -296,10 +296,12 @@ export const LineChartTimeSeries: React.FC<ChartProps> = ({setSelfHovered(false);}}>- <SeriesOverflowNote- visibleCount={dimensions.length}- totalCount={series.total}- />+ {series.total > dimensions.length && (+ <SeriesOverflowNote+ visibleCount={dimensions.length}+ totalCount={series.total}+ />+ )}<ChartContainerref={chartBoxRef}config={config}@@ -416,15 +418,16 @@ export const LineChartTimeSeries: React.FC<ChartProps> = ({/></LineChart></ChartContainer>- {(legendPosition === "below" ||- (legendPosition === "auto" && legendItems.length > 1)) && (- <TimeSeriesLegend- items={legendItems}- interaction={legendInteraction}- onItemClick={onLegendClick}- formatSummary={tooltipFormatter}- />- )}+ {legendItems.length > 0 &&+ (legendPosition === "below" ||+ (legendPosition === "auto" && legendItems.length > 1)) && (+ <TimeSeriesLegend+ items={legendItems}+ interaction={legendInteraction}+ onItemClick={onLegendClick}+ formatSummary={tooltipFormatter}+ />+ )}</div>);};diff --git a/web/src/features/widgets/chart-library/TimeSeriesLegend.tsx b/web/src/features/widgets/chart-library/TimeSeriesLegend.tsxindex 2b2575da8b..93ed1e4f9f 100644--- a/web/src/features/widgets/chart-library/TimeSeriesLegend.tsx+++ b/web/src/features/widgets/chart-library/TimeSeriesLegend.tsx@@ -1,4 +1,3 @@-/* eslint-disable @repo/no-null-render */import React, { useEffect, useMemo, useRef, useState } from "react";import { type ChartConfig } from "@/src/components/ui/chart";import {@@ -160,7 +159,6 @@ export function SeriesOverflowNote({visibleCount: number;totalCount: number;}) {- if (totalCount <= visibleCount) return null;return (<div className="text-muted-foreground shrink-0 pb-1 text-right text-xs">Showing top {visibleCount} of {totalCount} series@@ -183,8 +181,6 @@ export function TimeSeriesLegend({onItemClick: (dimension: string) => void;formatSummary: (value: number) => string;}) {- if (items.length === 0) return null;-return (// Wrap onto multiple rows so every series stays visible, but cap the// legend's height and scroll inside it — a chart with hundreds of seriesdiff --git a/web/src/features/widgets/chart-library/VerticalBarChartTimeSeries.tsx b/web/src/features/widgets/chart-library/VerticalBarChartTimeSeries.tsxindex afd903281d..7789395b48 100644--- a/web/src/features/widgets/chart-library/VerticalBarChartTimeSeries.tsx+++ b/web/src/features/widgets/chart-library/VerticalBarChartTimeSeries.tsx@@ -105,10 +105,12 @@ export const VerticalBarChartTimeSeries: React.FC<ChartProps> = ({setSelfHovered(false);}}>- <SeriesOverflowNote- visibleCount={dimensions.length}- totalCount={series.total}- />+ {series.total > dimensions.length && (+ <SeriesOverflowNote+ visibleCount={dimensions.length}+ totalCount={series.total}+ />+ )}<ChartContainerref={chartBoxRef}config={config}@@ -193,15 +195,16 @@ export const VerticalBarChartTimeSeries: React.FC<ChartProps> = ({/></BarChart></ChartContainer>- {(legendPosition === "below" ||- (legendPosition === "auto" && legendItems.length > 1)) && (- <TimeSeriesLegend- items={legendItems}- interaction={legendInteraction}- onItemClick={onLegendClick}- formatSummary={formatValue}- />- )}+ {legendItems.length > 0 &&+ (legendPosition === "below" ||+ (legendPosition === "auto" && legendItems.length > 1)) && (+ <TimeSeriesLegend+ items={legendItems}+ interaction={legendInteraction}+ onItemClick={onLegendClick}+ formatSummary={formatValue}+ />+ )}</div>);};diff --git a/web/src/features/widgets/components/SelectWidgetDialog.tsx b/web/src/features/widgets/components/SelectWidgetDialog.tsxindex 514a353ce3..931b8a7c1b 100644--- a/web/src/features/widgets/components/SelectWidgetDialog.tsx+++ b/web/src/features/widgets/components/SelectWidgetDialog.tsx@@ -27,6 +27,7 @@ import {import { useReadPath } from "@/src/features/events/hooks/useReadPath";import { type DashboardWidgetChartType } from "@langfuse/shared/src/db";import { InAppAgentWidgetComposer } from "@/src/features/in-app-agent/components/InAppAgentWidgetComposer";+import { useInAppAiAgent } from "@/src/features/in-app-agent/components/InAppAiAgentProvider";export type WidgetItem = {id: string;@@ -105,6 +106,7 @@ export function SelectWidgetDialog({}: SelectWidgetDialogProps) {const router = useRouter();const capture = usePostHogClientCapture();+ const { isAvailable, openAssistant, submit } = useInAppAiAgent();const openCapturedRef = useRef(false);useEffect(() => {@@ -178,9 +180,13 @@ export function SelectWidgetDialog({</div>) : (<div className="flex flex-col gap-3 p-1">- <InAppAgentWidgetComposer- onSubmitted={() => onOpenChange(false)}- />+ {isAvailable && (+ <InAppAgentWidgetComposer+ onSubmitted={() => onOpenChange(false)}+ openAssistant={openAssistant}+ submit={submit}+ />+ )}<buttontype="button"onClick={() => {diff --git a/web/src/pages/auth/sign-in.tsx b/web/src/pages/auth/sign-in.tsxindex baa48f8496..dae611d8d5 100644--- a/web/src/pages/auth/sign-in.tsx+++ b/web/src/pages/auth/sign-in.tsx@@ -896,7 +896,7 @@ export default function SignIn({</div>)}- <CloudRegionSwitch />+ {isLangfuseCloud && <CloudRegionSwitch />}<div className="bg-background mt-14 px-6 py-10 shadow-sm sm:mx-auto sm:w-full sm:max-w-[480px] sm:rounded-lg sm:px-10"><div className="space-y-6">@@ -1025,7 +1025,9 @@ export default function SignIn({</p>) : null}</div>- <CloudPrivacyNotice action="signing in" />+ {env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== undefined && (+ <CloudPrivacyNotice action="signing in" />+ )}</div></>);diff --git a/web/src/pages/auth/sign-up.tsx b/web/src/pages/auth/sign-up.tsxindex e1c93275db..bf3b4aa563 100644--- a/web/src/pages/auth/sign-up.tsx+++ b/web/src/pages/auth/sign-up.tsx@@ -476,12 +476,14 @@ function SignupPageShell({ children }: { children: React.ReactNode }) {</div>) : null}- <CloudRegionSwitch isSignUpPage />+ {isLangfuseCloud && <CloudRegionSwitch isSignUpPage />}<div className="bg-background mt-14 px-6 py-10 shadow-sm sm:mx-auto sm:w-full sm:max-w-[480px] sm:rounded-lg sm:px-10">{children}</div>- <CloudPrivacyNotice action="creating an account" />+ {env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== undefined && (+ <CloudPrivacyNotice action="creating an account" />+ )}</div></>);diff --git a/web/src/pages/project/[projectId]/index.tsx b/web/src/pages/project/[projectId]/index.tsxindex dfd265f7f3..02acefec89 100644--- a/web/src/pages/project/[projectId]/index.tsx+++ b/web/src/pages/project/[projectId]/index.tsx@@ -19,7 +19,6 @@ import {} from "@/src/utils/date-range-utils";import { useDashboardDateRange } from "@/src/hooks/useDashboardDateRange";import { useDebounce } from "@/src/hooks/useDebounce";-import SetupTracingButton from "@/src/features/setup/components/SetupTracingButton";import { useEntitlementLimit } from "@/src/features/entitlements/hooks";import Page from "@/src/components/layouts/page";import { MultiSelect } from "@/src/features/filters/components/multi-select";@@ -40,13 +39,15 @@ import {useDashboardQueryScheduler,} from "@/src/features/dashboard/hooks/useDashboardQueryScheduler";import Link from "next/link";-import { PencilIcon } from "lucide-react";+import { LockIcon, PencilIcon } from "lucide-react";import { showErrorToast } from "@/src/features/notifications/showErrorToast";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";import { Button } from "@/src/components/ui/button";import { DashboardGrid } from "@/src/features/widgets/components/DashboardGrid";import { HomeDashboardSelect } from "@/src/features/dashboard/components/HomeDashboardSelect";+import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";+import { setupTracingRoute } from "@/src/features/setup/setupRoutes";// Controller: no widget query may fire before the session resolves the v3/v4// read path — an unresolved session used to read as v3, fire a full wave of@@ -69,6 +70,28 @@ function HomeDashboard({ readPath }: { readPath: ResolvedReadPath }) {const utils = api.useUtils();const capture = usePostHogClientCapture();const projectId = router.query.projectId as string;+ const { project } = useQueryProjectOrOrganization();+ const { data: hasTracingConfigured, isLoading: isTracingCheckLoading } =+ api.traces.hasTracingConfigured.useQuery(+ { projectId },+ {+ enabled: Boolean(projectId),+ trpc: {+ context: {+ skipBatch: true,+ },+ },+ },+ );+ const tracingCheckCaptured = useRef(false);+ useEffect(() => {+ if (hasTracingConfigured !== undefined && !tracingCheckCaptured.current) {+ capture("onboarding:tracing_check_active", {+ active: hasTracingConfigured,+ });+ tracingCheckCaptured.current = true;+ }+ }, [hasTracingConfigured, capture]);const { timeRange, setTimeRange } = useDashboardDateRange();const isV4 = readPath === "v4";const metricsVersion: ViewVersion = isV4 ? "v2" : "v1";@@ -198,6 +221,10 @@ function HomeDashboard({ readPath }: { readPath: ResolvedReadPath }) {projectId,scope: "dashboards:CUD",});+ const hasSetupTracingAccess = useHasProjectAccess({+ projectId: project?.id,+ scope: "apiKeys:CUD",+ });// Silent on success: the "Set default" button disappearing is the feedback.const setHomeDashboard = api.dashboard.setHomeDashboard.useMutation({@@ -367,7 +394,22 @@ function HomeDashboard({ readPath }: { readPath: ResolvedReadPath }) {</span></Link></Button>- <SetupTracingButton />+ {!isTracingCheckLoading &&+ !hasTracingConfigured &&+ project &&+ (hasSetupTracingAccess ? (+ <Link href={setupTracingRoute(project.id)}>+ <Button>Configure Tracing</Button>+ </Link>+ ) : (+ <Button disabled>+ <LockIcon+ className="mr-2 -ml-0.5 h-4 w-4"+ aria-hidden="true"+ />+ Configure Tracing+ </Button>+ ))}</>),}}diff --git a/web/src/pages/project/[projectId]/prompts/metrics.tsx b/web/src/pages/project/[projectId]/prompts/metrics.tsxindex 0c5767c741..3d7138369f 100644--- a/web/src/pages/project/[projectId]/prompts/metrics.tsx+++ b/web/src/pages/project/[projectId]/prompts/metrics.tsx@@ -198,7 +198,8 @@ export default function PromptVersionTable({cell: ({ row }) => {const values: string[] = row.getValue("labels");return (- values && (+ values &&+ values.length > 0 && (<TruncatedLabelslabels={values}maxVisibleLabels={3}diff --git a/web/src/pages/project/[projectId]/settings/index.tsx b/web/src/pages/project/[projectId]/settings/index.tsxindex 082a6b4d05..aab69329a6 100644--- a/web/src/pages/project/[projectId]/settings/index.tsx+++ b/web/src/pages/project/[projectId]/settings/index.tsx@@ -51,6 +51,14 @@ export function useProjectSettingsPages(): ProjectSettingsPage[] {const showProtectedLabelsSettings = useHasEntitlement("prompt-protected-labels",);+ const showProjectNotificationChannels = useHasProjectAccess({+ projectId: project?.id,+ scope: "automations:CUD",+ });+ const showScoreConfigSettings = useHasProjectAccess({+ projectId: project?.id,+ scope: "scoreConfigs:read",+ });const showV4Migration = useV4UpgradeUiFlag();if (!project || !organization || !router.query.projectId) {return [];@@ -63,6 +71,8 @@ export function useProjectSettingsPages(): ProjectSettingsPage[] {showRetentionSettings,showLLMConnectionsSettings: true,showProtectedLabelsSettings,+ showProjectNotificationChannels,+ showScoreConfigSettings,showV4Migration,});}@@ -74,6 +84,8 @@ export const getProjectSettingsPages = ({showRetentionSettings,showLLMConnectionsSettings,showProtectedLabelsSettings,+ showProjectNotificationChannels,+ showScoreConfigSettings,showV4Migration,}: {project: { id: string; name: string; metadata: Record<string, unknown> };@@ -82,6 +94,8 @@ export const getProjectSettingsPages = ({showRetentionSettings: boolean;showLLMConnectionsSettings: boolean;showProtectedLabelsSettings: boolean;+ showProjectNotificationChannels: boolean;+ showScoreConfigSettings: boolean;showV4Migration: boolean;}): ProjectSettingsPage[] => [{@@ -225,6 +239,7 @@ export const getProjectSettingsPages = ({slug: "scores",cmdKKeywords: ["config"],content: <ScoreConfigSettings projectId={project.id} />,+ show: showScoreConfigSettings,},{title: "Members",@@ -278,7 +293,9 @@ export const getProjectSettingsPages = ({content: (<div className="flex flex-col gap-6"><PersonalNotificationSettings />- <ProjectNotificationChannels projectId={project.id} />+ {showProjectNotificationChannels && (+ <ProjectNotificationChannels projectId={project.id} />+ )}</div>),},