🪢 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
fix(ai-gateway): settings accessibility, cost accuracy, stable analytics loading, and consistent copy (#19543)
Hassieb Pakzad8ee97c448b23
diff --git a/ai-gateway/tests/observability.rs b/ai-gateway/tests/observability.rsindex 7b17806633..7c05e0dbe9 100644--- a/ai-gateway/tests/observability.rs+++ b/ai-gateway/tests/observability.rs@@ -17,7 +17,7 @@ use std::{sync::{Arc, Mutex, mpsc},time::{Duration, Instant},};-use tokio::{io::AsyncWriteExt, task::JoinHandle};+use tokio::task::JoinHandle;struct Gateway {child: Child,@@ -181,6 +181,53 @@ async fn start_collector() -> (String, Arc<Mutex<Vec<(String, Bytes)>>>, JoinHan(endpoint, captured, server)}+/// Wait until the gateway has read everything `client` sent it.+///+/// Graceful shutdown stops accepting and closes connections whose HTTP version+/// is still being sniffed, so a connection only holds the drain open once the+/// gateway has accepted it and parsed its first bytes. Both happen out of sight+/// of the client; the kernel's socket queues show when they are done: the+/// client's send queue empties when loopback delivers, and the gateway's+/// receive queue empties when it reads.+#[cfg(target_os = "linux")]+#[expect(+ clippy::unwrap_used,+ clippy::expect_used,+ reason = "test helper outside #[test]; a panic fails the test"+)]+async fn wait_until_gateway_read(client: &tokio::net::TcpStream) {+ let client_port = client.local_addr().unwrap().port();+ let gateway_port = client.peer_addr().unwrap().port();+ let queued = |table: &str, local: u16, remote: u16| {+ table.lines().skip(1).find_map(|row| {+ let columns: Vec<&str> = row.split_whitespace().collect();+ let port = |address: &str| {+ u16::from_str_radix(address.rsplit(':').next().unwrap(), 16).unwrap()+ };+ (port(columns[1]) == local && port(columns[2]) == remote).then(|| {+ let (tx, rx) = columns[4].split_once(':').unwrap();+ (+ u64::from_str_radix(tx, 16).unwrap(),+ u64::from_str_radix(rx, 16).unwrap(),+ )+ })+ })+ };+ tokio::time::timeout(Duration::from_secs(10), async {+ loop {+ let table = std::fs::read_to_string("/proc/net/tcp").unwrap();+ let unsent = queued(&table, client_port, gateway_port).map(|(tx, _)| tx);+ let unread = queued(&table, gateway_port, client_port).map(|(_, rx)| rx);+ if unsent == Some(0) && unread == Some(0) {+ break;+ }+ tokio::time::sleep(Duration::from_millis(10)).await;+ }+ })+ .await+ .expect("gateway reads the stalled request");+}+impl Drop for Gateway {fn drop(&mut self) {let _ = self.child.kill();@@ -422,8 +469,11 @@ async fn an_unresponsive_collector_does_not_extend_the_shutdown_deadline() {server.abort();}+#[cfg(target_os = "linux")]#[tokio::test]async fn a_drain_timeout_leaves_the_telemetry_flush_its_own_budget() {+ use tokio::io::AsyncWriteExt;+let (endpoint, captured, server) = start_collector().await;let mut gateway = Gateway::start(&endpoint, "1", "3", "info");gateway.request(true).await;@@ -435,6 +485,7 @@ async fn a_drain_timeout_leaves_the_telemetry_flush_its_own_budget() {.write_all(b"POST /openai/v1/responses HTTP/1.1\r\nhost: gateway\r\n").await.unwrap();+ wait_until_gateway_read(&stalled).await;let start = Instant::now();assert!(!gateway.terminate().await.success());assert!(start.elapsed() >= Duration::from_secs(1));diff --git a/packages/shared/scripts/seeder/scenarios/gateway-traffic.ts b/packages/shared/scripts/seeder/scenarios/gateway-traffic.tsindex 9ae371b0e3..3b4b1c4eed 100644--- a/packages/shared/scripts/seeder/scenarios/gateway-traffic.ts+++ b/packages/shared/scripts/seeder/scenarios/gateway-traffic.ts@@ -45,10 +45,12 @@ import { countRows, escapeLike } from "./verify";* sends requests whose user ID the caller set.*/-const MODELS = [+/** A `null` rate is a model without a Langfuse price: requests carry usage but no cost. */+const MODELS: ReadonlyArray<{ name: string; rate: number | null }> = [{ name: "gpt-5.4-mini", rate: 1 },{ name: "claude-haiku-4-5", rate: 1.5 },{ name: "gpt-5.6-sol", rate: 6 },+ { name: "self-hosted-llama", rate: null },];const SDK_EVENTS_PER_DAY = 3;@@ -177,13 +179,21 @@ const ensureServiceKey = async (params: {const generationCost = (usageInput: number,usageOutput: number,- rate: number,+ rate: number | null,) => {const usage = {input: usageInput,output: usageOutput,total: usageInput + usageOutput,};+ if (rate === null) {+ return {+ provided_usage_details: usage,+ usage_details: usage,+ provided_cost_details: {},+ cost_details: {},+ };+ }const inputCost = usageInput * GEN_INPUT_PRICE * rate;const outputCost = usageOutput * GEN_OUTPUT_PRICE * rate;const cost = {@@ -447,7 +457,7 @@ const run = async (export const gatewayTrafficScenario: ScenarioDefinition = {name: "gateway-traffic",description:- "AI Gateway requests in the organization's gateway ingestion project: one GENERATION per request attributed to the gateway service, its gateway key, and the key's user, plus a few SDK events. Creates gateway keys up to --keys, plus one service key bound to no user. Built for the AI Gateway analytics settings tab.",+ "AI Gateway requests in the organization's gateway ingestion project: one GENERATION per request attributed to the gateway service, its gateway key, and the key's user, plus a few SDK events. One model has no price, so its requests carry usage but no cost. Creates gateway keys up to --keys, plus one service key bound to no user. Built for the AI Gateway analytics settings tab.",supportsV4: true,flags: [{diff --git a/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts b/web/src/__tests__/server/ai-gateway-control-plane.servertest.tsindex e1a4a15600..e5d52d7f78 100644--- a/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts+++ b/web/src/__tests__/server/ai-gateway-control-plane.servertest.ts@@ -1160,7 +1160,7 @@ describe("AI gateway control plane", () => {await expect(caller.aiGateway.revokeApiKey({ orgId: org.id, id: created.id }),- ).rejects.toThrow("Gateway API key not found");+ ).rejects.toThrow("Gateway key not found");});it("scopes gateway API keys to their creator for members", async () => {@@ -1217,7 +1217,7 @@ describe("AI gateway control plane", () => {await expect(member.aiGateway.revokeApiKey({ orgId: owner.org.id, id: ownerKey.id }),- ).rejects.toThrow("Gateway API key not found");+ ).rejects.toThrow("Gateway key not found");await expect(member.aiGateway.revokeApiKey({ orgId: owner.org.id, id: memberKey.id }),).resolves.toEqual({ success: true });@@ -1406,7 +1406,7 @@ describe("AI gateway control plane", () => {apiKeyId: key.id,session,}),- ).rejects.toThrow("Gateway API key not found");+ ).rejects.toThrow("Gateway key not found");expect(await prisma.auditLog.count({ where: { orgId: org.id } })).toBe(auditCountAfterSuccess,);@@ -1954,7 +1954,7 @@ describe("AI gateway control plane", () => {id: connection.id,status: "ENABLED",}),- ).rejects.toThrow("credential update or successful retry");+ ).rejects.toThrow("credential update or a successful retry");const automaticRefresh = vi.fn<typeof fetch>();await new GatewayModelCatalogService(prisma,diff --git a/web/src/components/PagedSettingsContainer.tsx b/web/src/components/PagedSettingsContainer.tsxindex 12958c6c8c..b2eacf8987 100644--- a/web/src/components/PagedSettingsContainer.tsx+++ b/web/src/components/PagedSettingsContainer.tsx@@ -170,7 +170,7 @@ export const PagedSettingsContainer = ({key={pageKey(page)}page={page}isActive={page === currentPage}- onSelect={onChange}+ contentHref={settingsPath(router.asPath, page.slug)}/>),)}@@ -190,42 +190,40 @@ export const PagedSettingsContainer = ({);};+const navEntryClassName =+ "hover:bg-muted hover:text-foreground focus-visible:ring-ring flex h-8 items-center gap-2 rounded-sm px-2 focus-visible:ring-2 focus-visible:outline-hidden";+function NavEntry({page,isActive,- onSelect,+ contentHref,}: {page: SettingsPage;isActive: boolean;- onSelect: (slug: string) => void;+ contentHref: string;}) {if ("href" in page) {return (- <Link- href={page.href}- className="hover:bg-muted hover:text-foreground flex h-8 flex-row items-center gap-2 rounded-sm px-2"- >+ <Link href={page.href} className={navEntryClassName}>{page.title}{page.indicator && <NavIndicator />}{!page.internal && <ArrowUpRight size="base" __rawClassName="inline" />}</Link>);}- function handleSelect() {- onSelect(page.slug);- }return (- <span- onClick={handleSelect}+ <Link+ href={contentHref}+ aria-current={isActive ? "page" : undefined}className={cn(- "hover:bg-muted hover:text-foreground flex h-8 cursor-pointer items-center gap-2 rounded-sm px-2",+ navEntryClassName,isActive && "bg-muted text-primary font-bold",)}>{page.title}{page.indicator && <NavIndicator />}- </span>+ </Link>);}@@ -253,7 +251,7 @@ function DisabledNavEntry({role="link"aria-disabled="true"tabIndex={0}- className="text-muted-foreground/50 flex h-8 w-fit cursor-not-allowed items-center rounded-sm px-2"+ className="text-muted-foreground/50 focus-visible:ring-ring flex h-8 w-fit cursor-not-allowed items-center rounded-sm px-2 focus-visible:ring-2 focus-visible:outline-hidden">{title}</span>diff --git a/web/src/components/design-system/Dialog/Dialog.tsx b/web/src/components/design-system/Dialog/Dialog.tsxindex b5d4bcfc2f..df144337cd 100644--- a/web/src/components/design-system/Dialog/Dialog.tsx+++ b/web/src/components/design-system/Dialog/Dialog.tsx@@ -45,6 +45,8 @@ type DialogProps = {/** Defaults to "Cancel". Without `actions`, the close button is the only, primary button. */closeLabel?: string;closeOnInteractionOutside?: boolean;+ /** Only the footer close button closes the dialog: Escape and the header close button are disabled. */+ requireExplicitClose?: boolean;/** Disable when a child interaction handles activation keys on the document. */stopPropagationOnEnterSpace?: boolean;size?: VariantProps<typeof dialogContentVariants>["size"];@@ -62,6 +64,7 @@ function DialogRoot({children,closeLabel,closeOnInteractionOutside = false,+ requireExplicitClose = false,stopPropagationOnEnterSpace = true,size,text,@@ -140,11 +143,16 @@ function DialogRoot({event.stopPropagation();}}}+ onEscapeKeyDown={(event) => {+ if (requireExplicitClose) event.preventDefault();+ }}onPointerDownOutside={(event) => {- if (!closeOnInteractionOutside) event.preventDefault();+ if (!closeOnInteractionOutside || requireExplicitClose)+ event.preventDefault();}}onInteractOutside={(event) => {- if (!closeOnInteractionOutside) event.preventDefault();+ if (!closeOnInteractionOutside || requireExplicitClose)+ event.preventDefault();}}><div className="isolate flex min-h-0 flex-1 flex-col overflow-hidden">@@ -153,13 +161,15 @@ function DialogRoot({<DialogPrimitive.Title className="min-w-0 flex-1 text-lg leading-none font-bold tracking-tight">{title}</DialogPrimitive.Title>- <DialogPrimitive.Close- className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:bg-accent z-20 -mt-2 -mr-2 inline-flex size-8 shrink-0 items-center justify-center rounded-md opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none"- tabIndex={-1}- >- <X size="base" />- <span className="sr-only">Close</span>- </DialogPrimitive.Close>+ {requireExplicitClose ? null : (+ <DialogPrimitive.Close+ className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:bg-accent z-20 -mt-2 -mr-2 inline-flex size-8 shrink-0 items-center justify-center rounded-md opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none"+ tabIndex={-1}+ >+ <X size="base" />+ <span className="sr-only">Close</span>+ </DialogPrimitive.Close>+ )}</div></header><PopoverLayerProvider container={popoverContainer}>diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/GatewayAnalyticsPage.tsx b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/GatewayAnalyticsPage.tsxindex 4fa01aa101..f4ee2a45e7 100644--- a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/GatewayAnalyticsPage.tsx+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/GatewayAnalyticsPage.tsx@@ -1,13 +1,29 @@+import { useState } from "react";import { ChartColumn } from "@langfuse/icons";import Header from "@/src/components/layouts/header";+import { TimeRangePicker } from "@/src/components/date-picker";+import { PageHeaderControlsPortal } from "@/src/components/layouts/page-header-controls-slot";import { Alert } from "@/src/components/design-system/Alert/Alert";import { Button } from "@/src/components/design-system/Button/Button";import { Skeleton } from "@/src/components/ui/skeleton";import { GatewayAnalyticsDashboard } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsDashboard/GatewayAnalyticsDashboard";+import { GatewayAnalyticsHeader } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsHeader/GatewayAnalyticsHeader";+import { GATEWAY_ANALYTICS_WIDGET_SIZE_CLASSES } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/constants/gatewayAnalyticsWidgetSizeClasses";+import { GATEWAY_ANALYTICS_WIDGETS } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/constants/gatewayAnalyticsWidgets";import { GatewaySetupEmptyState } from "@/src/features/ai-gateway/components/GatewaySetupEmptyState/GatewaySetupEmptyState";import { useGatewayConfig } from "@/src/features/ai-gateway/components/GatewaySetupPage/hooks/useGatewayConfig";import { useLangfuseV4WriteMode } from "@/src/features/organizations/hooks";+import type { TimeRange } from "@/src/utils/date-range-utils";+import { cn } from "@/src/utils/tailwind";++const TIME_RANGE_PRESETS = [+ "last1Day",+ "last7Days",+ "last30Days",+ "last90Days",+ "last1Year",+] as const;/** Managers only; the settings route sends them to Setup until ingestion is configured. */export function GatewayAnalyticsPage({@@ -17,31 +33,52 @@ export function GatewayAnalyticsPage({}) {const configState = useGatewayConfig(organizationId);const v4WriteMode = useLangfuseV4WriteMode();+ const [timeRange, setTimeRange] = useState<TimeRange>({+ range: "last30Days",+ });// Widgets run v2 queries, which legacy write mode does not serve.if (v4WriteMode === "legacy") {return <AnalyticsNeedEvents />;}- if (configState.status === "pending") {- return <AnalyticsSkeleton />;- }if (configState.status === "error") {return <AnalyticsLoadError retry={configState.retry} />;}- const project = configState.config?.defaultIngestionProject;+ const project =+ configState.status === "success"+ ? configState.config?.defaultIngestionProject+ : undefined;if (- configState.config?.ingestionMode === "NONE" ||- !project ||- project.deletedAt+ configState.status === "success" &&+ (configState.config?.ingestionMode === "NONE" ||+ !project ||+ project.deletedAt)) {return <AnalyticsUnavailable organizationId={organizationId} />;}return (- <GatewayAnalyticsDashboard- organizationId={organizationId}- projectId={project.id}- />+ <>+ {/* Rendered while the config loads too, so the header controls do not pop in. */}+ <PageHeaderControlsPortal>+ <TimeRangePicker+ timeRange={timeRange}+ onTimeRangeChange={setTimeRange}+ timeRangePresets={TIME_RANGE_PRESETS}+ className="my-0 max-w-full overflow-x-auto"+ triggerClassName="px-2"+ />+ </PageHeaderControlsPortal>+ {project ? (+ <GatewayAnalyticsDashboard+ organizationId={organizationId}+ projectId={project.id}+ timeRange={timeRange}+ />+ ) : (+ <AnalyticsSkeleton />+ )}+ </>);}@@ -95,14 +132,30 @@ function AnalyticsLoadError({ retry }: { retry: () => void }) {);}+/** Mirrors the dashboard's header, filters and widget grid so nothing moves when it loads. */function AnalyticsSkeleton() {return (<divclassName="flex flex-col gap-4"data-testid="gateway-analytics-loading">- <Skeleton className="h-7 w-48" />- <Skeleton className="h-80 w-full" />+ <GatewayAnalyticsHeader>+ <div className="flex items-center gap-2">+ <Skeleton className="h-8 w-20" />+ <Skeleton className="h-8 w-24" />+ </div>+ </GatewayAnalyticsHeader>+ <div className="grid grid-cols-1 gap-3 lg:grid-cols-6">+ {GATEWAY_ANALYTICS_WIDGETS.map((widget) => (+ <Skeleton+ key={widget.id}+ className={cn(+ "rounded-lg",+ GATEWAY_ANALYTICS_WIDGET_SIZE_CLASSES[widget.size],+ )}+ />+ ))}+ </div></div>);}diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsDashboard/GatewayAnalyticsDashboard.tsx b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsDashboard/GatewayAnalyticsDashboard.tsxindex 20b3b9f89c..f26ee7f63b 100644--- a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsDashboard/GatewayAnalyticsDashboard.tsx+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsDashboard/GatewayAnalyticsDashboard.tsx@@ -1,54 +1,39 @@-import { useMemo, useState } from "react";+import { useMemo } from "react";+import type { FilterState } from "@langfuse/shared";-import { TimeRangePicker } from "@/src/components/date-picker";-import Header from "@/src/components/layouts/header";-import { PageHeaderControlsPortal } from "@/src/components/layouts/page-header-controls-slot";+import { GatewayAnalyticsHeader } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsHeader/GatewayAnalyticsHeader";import { GatewayAnalyticsWidgetCard } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsWidgetCard/GatewayAnalyticsWidgetCard";+import { GatewayUnpricedUsageAlert } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayUnpricedUsageAlert/GatewayUnpricedUsageAlert";import { GATEWAY_ANALYTICS_WIDGETS } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/constants/gatewayAnalyticsWidgets";import { useGatewayAnalyticsFilters } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/hooks/useGatewayAnalyticsFilters";import { useGatewayAnalyticsLabels } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/hooks/useGatewayAnalyticsLabels";+import { useGatewayUnpricedUsage } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/hooks/useGatewayUnpricedUsage";import { MultiSelect } from "@/src/features/filters";import {toAbsoluteTimeRange,type TimeRange,} from "@/src/utils/date-range-utils";-const TIME_RANGE_PRESETS = [- "last1Day",- "last7Days",- "last30Days",- "last90Days",- "last1Year",-] as const;-export function GatewayAnalyticsDashboard({organizationId,projectId,+ timeRange,}: {organizationId: string;projectId: string;+ timeRange: TimeRange;}) {- const [timeRange, setTimeRange] = useState<TimeRange>({- range: "last30Days",- });const absoluteTimeRange = useMemo(() => toAbsoluteTimeRange(timeRange),[timeRange],);- const labels = useGatewayAnalyticsLabels(organizationId);+ const { labels, isPending: labelsPending } =+ useGatewayAnalyticsLabels(organizationId);const { filters, user, apiKey } = useGatewayAnalyticsFilters({ labels });return (<div className="flex flex-col gap-4">- <div className="flex flex-wrap items-center gap-3">- <Header- title="Gateway analytics"- className="mb-0!"- help={{- description:- "Cost and usage of requests made through the AI Gateway, read from its ingestion project.",- }}- />+ <GatewayAnalyticsHeader>{/* Option labels are member and API key names. */}<div className="ph-no-capture flex flex-wrap items-center gap-2"><MultiSelect@@ -58,38 +43,73 @@ export function GatewayAnalyticsDashboard({{...user}/><MultiSelect- title="API key"- label="API key"+ title="Gateway key"+ label="Gateway key"className="my-0 w-auto overflow-hidden"{...apiKey}/></div>- </div>- <PageHeaderControlsPortal>- <TimeRangePicker- timeRange={timeRange}- onTimeRangeChange={setTimeRange}- timeRangePresets={TIME_RANGE_PRESETS}- className="my-0 max-w-full overflow-x-auto"- triggerClassName="px-2"- />- </PageHeaderControlsPortal>+ </GatewayAnalyticsHeader>{absoluteTimeRange && (- <div className="grid grid-cols-1 gap-3 lg:grid-cols-6">- {GATEWAY_ANALYTICS_WIDGETS.map((widget) => (- <GatewayAnalyticsWidgetCard- key={widget.id}- projectId={projectId}- widget={widget}- timeRange={absoluteTimeRange}- filters={filters}- dimensionLabelMap={- widget.dimensionLabels && labels[widget.dimensionLabels]- }- />- ))}- </div>+ <GatewayAnalyticsWidgets+ projectId={projectId}+ timeRange={absoluteTimeRange}+ filters={filters}+ labels={labels}+ labelsPending={labelsPending}+ />)}</div>);}++function GatewayAnalyticsWidgets({+ projectId,+ timeRange,+ filters,+ labels,+ labelsPending,+}: {+ projectId: string;+ timeRange: { from: Date; to: Date };+ filters: FilterState;+ labels: ReturnType<typeof useGatewayAnalyticsLabels>["labels"];+ labelsPending: boolean;+}) {+ const unpricedUsage = useGatewayUnpricedUsage({+ projectId,+ timeRange,+ filters,+ });+ const hasUnpricedUsage = (unpricedUsage?.requests ?? 0) > 0;++ return (+ <>+ <div className="grid grid-cols-1 gap-3 lg:grid-cols-6">+ {GATEWAY_ANALYTICS_WIDGETS.map((widget) => (+ <GatewayAnalyticsWidgetCard+ key={widget.id}+ projectId={projectId}+ widget={widget}+ timeRange={timeRange}+ filters={filters}+ dimensionLabelMap={+ widget.dimensionLabels && labels[widget.dimensionLabels]+ }+ isWaitingForLabels={+ Boolean(widget.dimensionLabels) && labelsPending+ }+ unpricedUsage={hasUnpricedUsage ? unpricedUsage : undefined}+ />+ ))}+ </div>+ {/* Below the grid: it loads after the widgets and must not push them down. */}+ {unpricedUsage && hasUnpricedUsage ? (+ <GatewayUnpricedUsageAlert+ projectId={projectId}+ usage={unpricedUsage}+ />+ ) : null}+ </>+ );+}diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsHeader/GatewayAnalyticsHeader.tsx b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsHeader/GatewayAnalyticsHeader.tsxnew file mode 100644index 0000000000..a9ba8c6bd3--- /dev/null+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsHeader/GatewayAnalyticsHeader.tsx@@ -0,0 +1,26 @@+import type { ReactNode } from "react";++import Header from "@/src/components/layouts/header";++export type GatewayAnalyticsHeaderProps = {+ /** Filters shown next to the title. */+ children: ReactNode;+};++export function GatewayAnalyticsHeader({+ children,+}: GatewayAnalyticsHeaderProps) {+ return (+ <div className="flex flex-wrap items-center gap-3">+ <Header+ title="Gateway analytics"+ className="mb-0!"+ help={{+ description:+ "Cost and usage of requests made through the AI Gateway, read from its ingestion project.",+ }}+ />+ {children}+ </div>+ );+}diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsWidgetCard/GatewayAnalyticsWidgetCard.tsx b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsWidgetCard/GatewayAnalyticsWidgetCard.tsxindex 24987657c8..b276ba58b1 100644--- a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsWidgetCard/GatewayAnalyticsWidgetCard.tsx+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayAnalyticsWidgetCard/GatewayAnalyticsWidgetCard.tsx@@ -1,19 +1,17 @@import { useMemo } from "react";import type { FilterState } from "@langfuse/shared";+import { GatewayUnpricedCostBadge } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayUnpricedCostBadge/GatewayUnpricedCostBadge";+import { GATEWAY_ANALYTICS_WIDGET_SIZE_CLASSES } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/constants/gatewayAnalyticsWidgetSizeClasses";import { buildGatewayAnalyticsQuery } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/buildGatewayAnalyticsQuery";+import type { GatewayUnpricedUsage } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/summarizeUnpricedUsage";import type { GatewayAnalyticsWidget } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/types/gatewayAnalyticsWidget";import { DashboardCard } from "@/src/features/dashboard/components/cards/DashboardCard";import { WidgetContent } from "@/src/features/widgets";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";+import { Skeleton } from "@/src/components/ui/skeleton";import { cn } from "@/src/utils/tailwind";-const SIZE_CLASSES: Record<GatewayAnalyticsWidget["size"], string> = {- small: "h-40",- medium: "h-96 lg:col-span-3",- full: "h-96 lg:col-span-6",-};-// A breakdown bar chart draws nothing but empty axes when there are no rows,// unlike the time-series and number tiles that already fail into a "No data"// card themselves. Hand it one explicitly. Stable node so the chart memo holds.@@ -30,52 +28,77 @@ export function GatewayAnalyticsWidgetCard({timeRange,filters,dimensionLabelMap,+ isWaitingForLabels = false,+ unpricedUsage,}: {projectId: string;widget: GatewayAnalyticsWidget;timeRange: { from: Date; to: Date };filters: FilterState;dimensionLabelMap?: ReadonlyMap<string, string>;+ /** Covers the chart, which keeps loading underneath, so raw IDs never flash before their labels. */+ isWaitingForLabels?: boolean;+ /** Flags cost widgets whose totals exclude usage of models without a price. */+ unpricedUsage?: GatewayUnpricedUsage;}) {const query = useMemo(() => buildGatewayAnalyticsQuery(widget, timeRange, filters),[widget, timeRange, filters],);+ const excludedUnpricedUsage = widget.metrics.some(+ ({ measure }) => measure === "totalCost",+ )+ ? unpricedUsage+ : undefined;return (<DashboardCardclassName={cn(// Series labels can be member names, emails and key notes.- "ph-no-capture min-w-0 lg:col-span-2",- SIZE_CLASSES[widget.size],+ "ph-no-capture min-w-0",+ GATEWAY_ANALYTICS_WIDGET_SIZE_CLASSES[widget.size],)}- title={widget.name}+ title={+ excludedUnpricedUsage ? (+ // The title line is tall enough that the badge never reflows the card.+ <span className="flex items-center gap-2">+ {widget.name}+ <GatewayUnpricedCostBadge usage={excludedUnpricedUsage} />+ </span>+ ) : (+ widget.name+ )+ }description={widget.description}// WidgetContent renders its own loading state.isLoading={false}cardContentClassName="min-h-0">- <WidgetContent- // The loading skeleton has a min height taller than the small tiles;- // clip it to the content area like dashboard widgets do.- className="overflow-hidden"- projectId={projectId}- query={query}- version="v2"- chartType={widget.chartType}- chartConfig={widget.chartConfig}- metrics={widget.metrics}- dimensions={widget.dimensions}- view={widget.view}- schedulerId={`ai-gateway-analytics:${widget.id}`}- layoutHint="compact"- dimensionLabelMap={dimensionLabelMap}- emptyState={- BAR_CHART_TYPES.has(widget.chartType)- ? NO_DATA_PLACEHOLDER- : undefined- }- />+ <div className="relative flex min-h-0 flex-1 flex-col">+ <WidgetContent+ // The loading skeleton has a min height taller than the small tiles;+ // clip it to the content area like dashboard widgets do.+ className={cn("overflow-hidden", isWaitingForLabels && "invisible")}+ projectId={projectId}+ query={query}+ version="v2"+ chartType={widget.chartType}+ chartConfig={widget.chartConfig}+ metrics={widget.metrics}+ dimensions={widget.dimensions}+ view={widget.view}+ schedulerId={`ai-gateway-analytics:${widget.id}`}+ layoutHint="compact"+ dimensionLabelMap={dimensionLabelMap}+ emptyState={+ BAR_CHART_TYPES.has(widget.chartType)+ ? NO_DATA_PLACEHOLDER+ : undefined+ }+ usdPrecision="cents"+ />+ {isWaitingForLabels ? <Skeleton className="absolute inset-0" /> : null}+ </div></DashboardCard>);}diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayUnpricedCostBadge/GatewayUnpricedCostBadge.tsx b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayUnpricedCostBadge/GatewayUnpricedCostBadge.tsxnew file mode 100644index 0000000000..b887d0d5e2--- /dev/null+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayUnpricedCostBadge/GatewayUnpricedCostBadge.tsx@@ -0,0 +1,36 @@+import { AlertTriangle } from "@langfuse/icons";++import { Badge } from "@/src/components/design-system/Badge/Badge";+import { Tooltip } from "@/src/components/design-system/Tooltip/Tooltip";+import { describeUnpricedUsage } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/describeUnpricedUsage";+import type { GatewayUnpricedUsage } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/summarizeUnpricedUsage";++export type GatewayUnpricedCostBadgeProps = {+ usage: GatewayUnpricedUsage;+};++export function GatewayUnpricedCostBadge({+ usage,+}: GatewayUnpricedCostBadgeProps) {+ return (+ <Tooltip+ label={`Excludes ${describeUnpricedUsage(usage)} to models without a price.`}+ >+ {({ getTriggerProps }) => (+ <span+ {...getTriggerProps()}+ tabIndex={0}+ className="focus-visible:ring-ring h-fit shrink-0 rounded-sm focus-visible:ring-2 focus-visible:outline-hidden"+ >+ <Badge+ size="sm"+ color="yellow"+ leadingIcon={AlertTriangle}+ interactive+ text="Excludes unpriced"+ />+ </span>+ )}+ </Tooltip>+ );+}diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayUnpricedUsageAlert/GatewayUnpricedUsageAlert.tsx b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayUnpricedUsageAlert/GatewayUnpricedUsageAlert.tsxnew file mode 100644index 0000000000..c65584a613--- /dev/null+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/components/GatewayUnpricedUsageAlert/GatewayUnpricedUsageAlert.tsx@@ -0,0 +1,34 @@+import { AlertTriangle } from "@langfuse/icons";++import { Alert } from "@/src/components/design-system/Alert/Alert";+import { Button } from "@/src/components/design-system/Button/Button";+import { describeUnpricedUsage } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/describeUnpricedUsage";+import type { GatewayUnpricedUsage } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/summarizeUnpricedUsage";++export type GatewayUnpricedUsageAlertProps = {+ projectId: string;+ usage: GatewayUnpricedUsage;+};++export function GatewayUnpricedUsageAlert({+ projectId,+ usage,+}: GatewayUnpricedUsageAlertProps) {+ return (+ <Alert variant="warning" size="sm" icon={AlertTriangle}>+ <Alert.Title>Cost excludes unpriced usage</Alert.Title>+ <Alert.Description>+ <p>+ {describeUnpricedUsage(usage)} used models without a price (+ <span className="ph-no-capture">{usage.models.join(", ")}</span>), so+ the cost widgets count them as $0.{" "}+ <Button+ variant="text"+ text="Add model prices"+ href={`/project/${encodeURIComponent(projectId)}/settings/models`}+ />+ </p>+ </Alert.Description>+ </Alert>+ );+}diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/constants/gatewayAnalyticsWidgetSizeClasses.ts b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/constants/gatewayAnalyticsWidgetSizeClasses.tsnew file mode 100644index 0000000000..73d61e9ca5--- /dev/null+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/constants/gatewayAnalyticsWidgetSizeClasses.ts@@ -0,0 +1,11 @@+import type { GatewayAnalyticsWidget } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/types/gatewayAnalyticsWidget";++/** Grid placement per widget size, shared by the cards and their loading skeleton. */+export const GATEWAY_ANALYTICS_WIDGET_SIZE_CLASSES: Record<+ GatewayAnalyticsWidget["size"],+ string+> = {+ small: "h-40 lg:col-span-2",+ medium: "h-96 lg:col-span-3",+ full: "h-96 lg:col-span-6",+};diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/constants/gatewayAnalyticsWidgets.ts b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/constants/gatewayAnalyticsWidgets.tsindex 9ede87ab99..9971f9ea50 100644--- a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/constants/gatewayAnalyticsWidgets.ts+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/constants/gatewayAnalyticsWidgets.ts@@ -87,7 +87,7 @@ export const GATEWAY_ANALYTICS_WIDGETS: readonly GatewayAnalyticsWidget[] = [},{id: "cost-by-api-key",- name: "Cost by API key",+ name: "Cost by gateway key",description: `Top ${BREAKDOWN_ROW_LIMIT} gateway keys by cost`,view: "observations",dimensions: [{ field: "aiGatewayKeyId" }],@@ -111,3 +111,21 @@ export const GATEWAY_ANALYTICS_WIDGETS: readonly GatewayAnalyticsWidget[] = [size: "medium",},];++/** Not rendered: a per-model breakdown that finds usage without a model price. */+export const GATEWAY_UNPRICED_USAGE_QUERY: GatewayAnalyticsWidget = {+ id: "unpriced-usage",+ name: "Unpriced usage",+ description: "Requests and tokens of models without a price",+ view: "observations",+ dimensions: [{ field: "providedModelName" }],+ metrics: [+ { measure: "count", agg: "count" },+ { measure: "totalTokens", agg: "sum" },+ { measure: "totalCost", agg: "sum" },+ ],+ filters: [],+ chartType: "HORIZONTAL_BAR",+ chartConfig: { type: "HORIZONTAL_BAR", row_limit: 1000 },+ size: "full",+};diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/describeUnpricedUsage.ts b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/describeUnpricedUsage.tsnew file mode 100644index 0000000000..3b4b4d8e65--- /dev/null+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/describeUnpricedUsage.ts@@ -0,0 +1,8 @@+import type { GatewayUnpricedUsage } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/summarizeUnpricedUsage";+import { compactNumberFormatter, numberFormatter } from "@/src/utils/numbers";++/** "12 requests (3.4K tokens)" */+export function describeUnpricedUsage(usage: GatewayUnpricedUsage) {+ const requests = `${numberFormatter(usage.requests, 0)} ${usage.requests === 1 ? "request" : "requests"}`;+ return `${requests} (${compactNumberFormatter(usage.tokens)} tokens)`;+}diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/summarizeUnpricedUsage.clienttest.ts b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/summarizeUnpricedUsage.clienttest.tsnew file mode 100644index 0000000000..7421b6a248--- /dev/null+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/summarizeUnpricedUsage.clienttest.ts@@ -0,0 +1,47 @@+import { describe, expect, it } from "vitest";++import { summarizeUnpricedUsage } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/summarizeUnpricedUsage";++describe("summarizeUnpricedUsage", () => {+ it("sums requests and tokens of models without recorded cost", () => {+ expect(+ summarizeUnpricedUsage([+ {+ providedModelName: "gpt-5.4-mini",+ count_count: "40",+ sum_totalTokens: "9000",+ sum_totalCost: "1.25",+ },+ {+ providedModelName: "self-hosted-llama",+ count_count: "12",+ sum_totalTokens: "3400",+ sum_totalCost: "0",+ },+ {+ providedModelName: "",+ count_count: 3,+ sum_totalTokens: 600,+ sum_totalCost: null,+ },+ ]),+ ).toEqual({+ requests: 15,+ tokens: 4000,+ models: ["self-hosted-llama", "Unknown model"],+ });+ });++ it("reports nothing when every model is priced", () => {+ expect(+ summarizeUnpricedUsage([+ {+ providedModelName: "gpt-5.4-mini",+ count_count: 4,+ sum_totalTokens: 900,+ sum_totalCost: 0.004,+ },+ ]),+ ).toEqual({ requests: 0, tokens: 0, models: [] });+ });+});diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/summarizeUnpricedUsage.ts b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/summarizeUnpricedUsage.tsnew file mode 100644index 0000000000..f16d5b9dc4--- /dev/null+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/summarizeUnpricedUsage.ts@@ -0,0 +1,25 @@+export type GatewayUnpricedUsage = {+ requests: number;+ tokens: number;+ models: string[];+};++/**+ * Picks the models whose requests recorded no cost from a per-model breakdown.+ * Events store a missing price as a zero cost, so a model with requests and a+ * zero total has no Langfuse price and its spend reads as $0.+ */+export function summarizeUnpricedUsage(+ rows: Record<string, unknown>[],+): GatewayUnpricedUsage {+ const summary: GatewayUnpricedUsage = { requests: 0, tokens: 0, models: [] };+ for (const row of rows) {+ const requests = Number(row.count_count ?? 0);+ const cost = Number(row.sum_totalCost ?? 0);+ if (requests <= 0 || cost !== 0) continue;+ summary.requests += requests;+ summary.tokens += Number(row.sum_totalTokens ?? 0);+ summary.models.push(String(row.providedModelName || "Unknown model"));+ }+ return summary;+}diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/hooks/useGatewayAnalyticsLabels.ts b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/hooks/useGatewayAnalyticsLabels.tsindex 79b3b6e36c..45202aa2e4 100644--- a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/hooks/useGatewayAnalyticsLabels.ts+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/hooks/useGatewayAnalyticsLabels.ts@@ -4,19 +4,21 @@ import { toLabelMap } from "@/src/features/ai-gateway/components/GatewayAnalyticimport type { GatewayAnalyticsLabelSource } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/types/gatewayAnalyticsWidget";import { api } from "@/src/utils/api";-/** Label maps per source; empty until loaded, so charts fall back to raw IDs. */-export function useGatewayAnalyticsLabels(- organizationId: string,-): Record<GatewayAnalyticsLabelSource, ReadonlyMap<string, string>> {- const { data } = api.aiGateway.getAnalyticsLabels.useQuery({+/** Label maps per source; empty while `isPending`, when charts would fall back to raw IDs. */+export function useGatewayAnalyticsLabels(organizationId: string): {+ labels: Record<GatewayAnalyticsLabelSource, ReadonlyMap<string, string>>;+ isPending: boolean;+} {+ const { data, isPending } = api.aiGateway.getAnalyticsLabels.useQuery({orgId: organizationId,});- return useMemo(+ const labels = useMemo(() => ({apiKeys: toLabelMap(data?.apiKeys ?? []),users: toLabelMap(data?.users ?? []),}),[data],);+ return { labels, isPending };}diff --git a/web/src/features/ai-gateway/components/GatewayAnalyticsPage/hooks/useGatewayUnpricedUsage.ts b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/hooks/useGatewayUnpricedUsage.tsnew file mode 100644index 0000000000..2f4ad22e85--- /dev/null+++ b/web/src/features/ai-gateway/components/GatewayAnalyticsPage/hooks/useGatewayUnpricedUsage.ts@@ -0,0 +1,41 @@+import { useMemo } from "react";+import type { FilterState } from "@langfuse/shared";++import { GATEWAY_UNPRICED_USAGE_QUERY } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/constants/gatewayAnalyticsWidgets";+import { buildGatewayAnalyticsQuery } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/buildGatewayAnalyticsQuery";+import { summarizeUnpricedUsage } from "@/src/features/ai-gateway/components/GatewayAnalyticsPage/fns/summarizeUnpricedUsage";+import { useScheduledDashboardExecuteQuery } from "@/src/features/dashboard/hooks/DashboardQuerySchedulerProvider";++/** Usage the cost widgets count as $0 because its model has no price; undefined until loaded. */+export function useGatewayUnpricedUsage({+ projectId,+ timeRange,+ filters,+}: {+ projectId: string;+ timeRange: { from: Date; to: Date };+ filters: FilterState;+}) {+ const query = useMemo(+ () =>+ buildGatewayAnalyticsQuery(+ GATEWAY_UNPRICED_USAGE_QUERY,+ timeRange,+ filters,+ ),+ [timeRange, filters],+ );+ const result = useScheduledDashboardExecuteQuery(+ { projectId, version: "v2", query },+ {+ trpc: { context: { skipBatch: true } },+ queryId: `ai-gateway-analytics:${GATEWAY_UNPRICED_USAGE_QUERY.id}`,+ meta: { silentHttpCodes: [412, 422] },+ },+ );++ return useMemo(+ () => (result.data ? summarizeUnpricedUsage(result.data) : undefined),+ [result.data],+ );+}diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/GatewayApiKeysPage.tsx b/web/src/features/ai-gateway/components/GatewayApiKeysPage/GatewayApiKeysPage.tsxindex 27aefbf770..69e8a265d7 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/GatewayApiKeysPage.tsx+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/GatewayApiKeysPage.tsx@@ -24,16 +24,16 @@ export function GatewayApiKeysPage({}/** Managers are redirected to Setup by the settings route. */if (!canManageGateway && isIngestionConfigured === false) {- return <GatewayNotSetUpNotice title="Gateway API keys" />;+ return <GatewayNotSetUpNotice title="Gateway keys" />;}return (<div className="flex flex-col gap-4"><div>- <Header title="Gateway API keys" />+ <Header title="Gateway keys" /><p className="text-muted-foreground text-sm">{canManageGateway- ? "Keys authenticate requests to the AI Gateway only. User keys are revoked when their owner leaves the organization; service account keys keep working."- : "Your keys authenticate requests to the AI Gateway only. They are revoked when you leave the organization or lose gateway access."}{" "}+ ? "Gateway keys authenticate requests to the AI Gateway only. User keys are revoked when their owner leaves the organization; service account keys keep working."+ : "Your gateway keys authenticate requests to the AI Gateway only. They are revoked when you leave the organization or lose gateway access."}{" "}<Buttonvariant="text"text="How gateway keys work"diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/CreateGatewayApiKeyDialogController/CreateGatewayApiKeyDialogController.clienttest.tsx b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/CreateGatewayApiKeyDialogController/CreateGatewayApiKeyDialogController.clienttest.tsxnew file mode 100644index 0000000000..c9937e493e--- /dev/null+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/CreateGatewayApiKeyDialogController/CreateGatewayApiKeyDialogController.clienttest.tsx@@ -0,0 +1,97 @@+import { fireEvent, render, screen, waitFor } from "@testing-library/react";+import { beforeAll, describe, expect, it, vi } from "vitest";++import { TooltipProvider } from "@/src/components/ui/tooltip";++import { CreateGatewayApiKeyDialogController } from "./CreateGatewayApiKeyDialogController";++const mocks = vi.hoisted(() => ({+ mutateAsync: vi.fn(async () => ({ secretKey: "sk-lf-test-secret" })),+ invalidate: vi.fn(async () => undefined),+}));++vi.mock("next-auth/react", () => ({+ useSession: () => ({ status: "authenticated", data: null }),+}));++vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({+ usePostHogClientCapture: () => vi.fn(),+}));++vi.mock("@/src/features/rbac", () => ({+ useHasOrganizationAccess: () => false,+}));++vi.mock(+ "@/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/GeneratedKeyContent",+ () => ({+ GeneratedKeyContent: ({ secretKey }: { secretKey: string }) => (+ <div>{secretKey}</div>+ ),+ }),+);++vi.mock("@/src/utils/api", () => ({+ api: {+ useUtils: () => ({+ aiGateway: { listApiKeys: { invalidate: mocks.invalidate } },+ }),+ aiGateway: {+ createApiKey: {+ useMutation: () => ({+ mutateAsync: mocks.mutateAsync,+ isPending: false,+ }),+ },+ },+ },+ reportNonTrpcError: vi.fn(),+ reportTrpcErrorWithoutToast: vi.fn(),+}));++async function renderCreatedKeyDialog() {+ render(+ <TooltipProvider>+ <CreateGatewayApiKeyDialogController organizationId="org-1">+ {({ openDialog }) => (+ <button type="button" onClick={openDialog}>+ Open+ </button>+ )}+ </CreateGatewayApiKeyDialogController>+ </TooltipProvider>,+ );+ fireEvent.click(screen.getByRole("button", { name: "Open" }));+ fireEvent.change(screen.getByRole("textbox", { name: /name/i }), {+ target: { value: "laptop" },+ });+ fireEvent.click(screen.getByRole("button", { name: "Create key" }));+ await screen.findByText("sk-lf-test-secret");+}++describe("CreateGatewayApiKeyDialogController", () => {+ beforeAll(() => {+ vi.stubGlobal(+ "ResizeObserver",+ class {+ observe() {}+ unobserve() {}+ disconnect() {}+ },+ );+ });++ it("keeps the one-time key open on Escape and closes only on Done", async () => {+ await renderCreatedKeyDialog();++ expect(screen.queryByRole("button", { name: "Close" })).toBeNull();++ fireEvent.keyDown(screen.getByRole("dialog"), { key: "Escape" });+ expect(screen.getByText("sk-lf-test-secret")).toBeInTheDocument();++ fireEvent.click(screen.getByRole("button", { name: "Done" }));+ await waitFor(() =>+ expect(screen.queryByText("sk-lf-test-secret")).toBeNull(),+ );+ });+});diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/CreateGatewayApiKeyDialogController/CreateGatewayApiKeyDialogController.tsx b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/CreateGatewayApiKeyDialogController/CreateGatewayApiKeyDialogController.tsxindex ce15bf7b2a..ca5d4233ea 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/CreateGatewayApiKeyDialogController/CreateGatewayApiKeyDialogController.tsx+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/CreateGatewayApiKeyDialogController/CreateGatewayApiKeyDialogController.tsx@@ -134,7 +134,12 @@ export function CreateGatewayApiKeyDialogController({onBeforeClose={() => !create.isPending}renderDialog={() =>generatedSecretKey ? (- <Dialog title="Gateway key created" size="md" closeLabel="Done">+ <Dialog+ title="Gateway key created"+ size="md"+ closeLabel="Done"+ requireExplicitClose+ ><GeneratedKeyContentorganizationId={organizationId}secretKey={generatedSecretKey}@@ -142,7 +147,7 @@ export function CreateGatewayApiKeyDialogController({</Dialog>) : (<Dialog- title="Issue API key"+ title="Create gateway key"size="md"actions={[{diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/ConnectedGatewayApiKeysTable.tsx b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/ConnectedGatewayApiKeysTable.tsxindex 5c5133f6a6..b3975d4a6d 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/ConnectedGatewayApiKeysTable.tsx+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/ConnectedGatewayApiKeysTable.tsx@@ -46,7 +46,7 @@ export function ConnectedGatewayApiKeysTable({return (<div className="flex flex-col gap-4"><Alert variant="destructive">- <Alert.Title>Gateway API keys could not be loaded</Alert.Title>+ <Alert.Title>Gateway keys could not be loaded</Alert.Title><Alert.Description>Retry to manage keys for this organization.</Alert.Description>@@ -64,7 +64,7 @@ export function ConnectedGatewayApiKeysTable({return (<ConfirmationDialogController<string>- title="Revoke gateway API key"+ title="Revoke gateway key"text="Requests using this key will immediately be rejected. This action cannot be undone."confirmLabel="Revoke key"variant="destructive"diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/GatewayApiKeysTable.tsx b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/GatewayApiKeysTable.tsxindex b58afe71b4..46c7a5ec39 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/GatewayApiKeysTable.tsx+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/GatewayApiKeysTable.tsx@@ -134,8 +134,8 @@ export function GatewayApiKeysTable({]}noResultsMessage={hasSearch- ? "No gateway API keys match the current search."- : "No gateway API keys created."+ ? "No gateway keys match the current search."+ : "No gateway keys created."}emptyState={hasNoKeys ? <GatewayApiKeysEmptyState /> : undefined}/>diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/components/GatewayApiKeysEmptyState/GatewayApiKeysEmptyState.tsx b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/components/GatewayApiKeysEmptyState/GatewayApiKeysEmptyState.tsxindex 430b043617..ab7195ea06 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/components/GatewayApiKeysEmptyState/GatewayApiKeysEmptyState.tsx+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GatewayApiKeysTable/components/GatewayApiKeysEmptyState/GatewayApiKeysEmptyState.tsx@@ -6,8 +6,8 @@ export function GatewayApiKeysEmptyState() {return (<GatewaySetupEmptyStateicon={KeyRound}- title="No gateway API keys yet"- description="Create a key to send requests through the AI Gateway from Claude Code, Codex, or your own code."+ title="No gateway keys yet"+ description="Create a gateway key to send requests through the AI Gateway from Claude Code, Codex, or your own code."/>);}diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/SetupInstructionsTabs/SetupInstructionsTabs.stories.tsx b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/SetupInstructionsTabs/SetupInstructionsTabs.stories.tsxindex 28da61a574..68be447b7b 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/SetupInstructionsTabs/SetupInstructionsTabs.stories.tsx+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/SetupInstructionsTabs/SetupInstructionsTabs.stories.tsx@@ -48,7 +48,7 @@ export const TestWarnsWithoutAnthropic = meta.story({await userEvent.click(canvas.getByRole("tab", { name: "Claude" }));await expect(- canvas.getByText(/needs an Anthropic provider connection/),+ canvas.getByText(/needs an Anthropic provider credential/),).toBeVisible();},});diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildApiInstructions.ts b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildApiInstructions.tsindex cbdf01dc5f..09c0f1198c 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildApiInstructions.ts+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildApiInstructions.ts@@ -12,7 +12,8 @@ import type { GatewayProvider } from "@/src/features/ai-gateway/types/gatewayProconst LIST_MODELS_STEPS: Record<GatewayProvider, AgentSetupStep> = {OPENAI: {title: "List models through the OpenAI route",- description: "A model list means the key and the provider connection work.",+ description:+ "A model list means the gateway key and the provider credential work.",language: "sh",code: ['curl -s "$LANGFUSE_GATEWAY_HOST/openai/v1/models" \\',@@ -21,7 +22,8 @@ const LIST_MODELS_STEPS: Record<GatewayProvider, AgentSetupStep> = {},ANTHROPIC: {title: "List models through the Anthropic route",- description: "A model list means the key and the provider connection work.",+ description:+ "A model list means the gateway key and the provider credential work.",language: "sh",code: ['curl -s "$LANGFUSE_GATEWAY_HOST/anthropic/v1/models?limit=1000" \\',@@ -46,7 +48,7 @@ export function buildApiInstructions(docsUrl: AGENT_SETUP_DOCS_URLS.api,warning:context.providers.length === 0- ? "No provider connection is enabled yet. Requests fail until an organization admin adds one."+ ? "No provider credential is enabled yet. Requests fail until an organization admin adds one.": undefined,steps: [{diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildClaudeCodeInstructions.ts b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildClaudeCodeInstructions.tsindex c70b37a1df..12fa936007 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildClaudeCodeInstructions.ts+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildClaudeCodeInstructions.ts@@ -19,7 +19,7 @@ export function buildClaudeCodeInstructions(docsUrl: AGENT_SETUP_DOCS_URLS["claude-code"],warning: context.providers.includes("ANTHROPIC")? undefined- : "Claude Code needs an Anthropic provider connection, and none is enabled yet.",+ : "Claude Code needs an Anthropic provider credential, and none is enabled yet.",steps: [{title: "Log out of any existing session",diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildClaudeDesktopInstructions.ts b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildClaudeDesktopInstructions.tsindex a79b662785..3e00dfd61c 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildClaudeDesktopInstructions.ts+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildClaudeDesktopInstructions.ts@@ -16,7 +16,7 @@ export function buildClaudeDesktopInstructions(docsUrl: AGENT_SETUP_DOCS_URLS["claude-desktop"],warning: context.providers.includes("ANTHROPIC")? undefined- : "Claude Desktop needs an Anthropic provider connection, and none is enabled yet.",+ : "Claude Desktop needs an Anthropic provider credential, and none is enabled yet.",steps: [{title: "Open the third-party inference settings",diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCodexInstructions.ts b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCodexInstructions.tsindex d0b4efe4f2..5967511a68 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCodexInstructions.ts+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCodexInstructions.ts@@ -19,7 +19,7 @@ export function buildCodexInstructions(docsUrl: AGENT_SETUP_DOCS_URLS.codex,warning: context.providers.includes("OPENAI")? undefined- : "Codex needs an OpenAI provider connection, and none is enabled yet.",+ : "Codex needs an OpenAI provider credential, and none is enabled yet.",steps: [{title: "Store the key in Codex's .env",diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCopilotCliInstructions.ts b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCopilotCliInstructions.tsindex fb88390aae..f727371136 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCopilotCliInstructions.ts+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCopilotCliInstructions.ts@@ -43,13 +43,13 @@ export function buildCopilotCliInstructions(docsUrl: AGENT_SETUP_DOCS_URLS["copilot-cli"],warning:context.providers.length === 0- ? "Copilot CLI needs an Anthropic or OpenAI provider connection, and none is enabled yet."+ ? "Copilot CLI needs an Anthropic or OpenAI provider credential, and none is enabled yet.": undefined,steps: [{title: "Point Copilot CLI at the gateway",description:- "Replace the placeholders with your gateway key and a model from your provider connection. If ~/.copilot/providers.json lists providers, it takes precedence over these variables.",+ "Replace the placeholders with your gateway key and a model from your provider credential. If ~/.copilot/providers.json lists providers, it takes precedence over these variables.",language: "sh",code: [...env,diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCopilotDesktopInstructions.ts b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCopilotDesktopInstructions.tsindex 27d623b0e8..bd5fa6eb9c 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCopilotDesktopInstructions.ts+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCopilotDesktopInstructions.ts@@ -16,7 +16,7 @@ export function buildCopilotDesktopInstructions(docsUrl: AGENT_SETUP_DOCS_URLS["copilot-desktop"],warning: context.providers.includes("OPENAI")? undefined- : "The GitHub Copilot app needs an OpenAI provider connection, and none is enabled yet.",+ : "The GitHub Copilot app needs an OpenAI provider credential, and none is enabled yet.",steps: [{title: "Add a custom endpoint",@@ -37,7 +37,7 @@ export function buildCopilotDesktopInstructions({title: "Pick a model",description:- "The models of your OpenAI provider connection appear in the model picker alongside the GitHub-hosted models. Select one to start a session.",+ "The models of your OpenAI provider credential appear in the model picker alongside the GitHub-hosted models. Select one to start a session.",},],};diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildOpenCodeInstructions.ts b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildOpenCodeInstructions.tsindex 101c6bfdb6..ae93d8c53f 100644--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildOpenCodeInstructions.ts+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildOpenCodeInstructions.ts@@ -46,7 +46,7 @@ export function buildOpenCodeInstructions(docsUrl: AGENT_SETUP_DOCS_URLS.opencode,warning:context.providers.length === 0- ? "OpenCode needs an Anthropic or OpenAI provider connection, and none is enabled yet."+ ? "OpenCode needs an Anthropic or OpenAI provider credential, and none is enabled yet.": undefined,steps: [{diff --git a/web/src/features/ai-gateway/components/GatewayLaunch/GatewayLaunchBanner.tsx b/web/src/features/ai-gateway/components/GatewayLaunch/GatewayLaunchBanner.tsxindex 32b9b33b0f..8e76d4fa84 100644--- a/web/src/features/ai-gateway/components/GatewayLaunch/GatewayLaunchBanner.tsx+++ b/web/src/features/ai-gateway/components/GatewayLaunch/GatewayLaunchBanner.tsx@@ -16,7 +16,7 @@ import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePosimport { cn } from "@/src/utils/tailwind";function ctaLabel(state: GatewayLaunchState) {- if (state === "get-key") return "Get API key";+ if (state === "get-key") return "Get gateway key";if (state === "ask-admin") return "Learn more";return "Set up";}diff --git a/web/src/features/ai-gateway/components/GatewayLaunch/GatewayLaunchDialog.tsx b/web/src/features/ai-gateway/components/GatewayLaunch/GatewayLaunchDialog.tsxindex 627d41d73a..88a6faae45 100644--- a/web/src/features/ai-gateway/components/GatewayLaunch/GatewayLaunchDialog.tsx+++ b/web/src/features/ai-gateway/components/GatewayLaunch/GatewayLaunchDialog.tsx@@ -150,7 +150,7 @@ export function GatewayLaunchDialog({><Buttonvariant="primary"- text="Get API key"+ text="Get gateway key"href={`/organization/${organizationId}/settings/ai-gateway-api-keys`}/></span>diff --git a/web/src/features/ai-gateway/components/GatewayModelsPage/components/ConnectedGatewayModelsTable/ConnectedGatewayModelsTable.tsx b/web/src/features/ai-gateway/components/GatewayModelsPage/components/ConnectedGatewayModelsTable/ConnectedGatewayModelsTable.tsxindex baa0c0691d..894bd03cdb 100644--- a/web/src/features/ai-gateway/components/GatewayModelsPage/components/ConnectedGatewayModelsTable/ConnectedGatewayModelsTable.tsx+++ b/web/src/features/ai-gateway/components/GatewayModelsPage/components/ConnectedGatewayModelsTable/ConnectedGatewayModelsTable.tsx@@ -132,9 +132,11 @@ export function ConnectedGatewayModelsTable({{failedProviderCount > 0 ? (<Alert variant="warning">- <Alert.Title>Some providers could not be reached</Alert.Title>+ <Alert.Title>+ Some provider credentials could not be synced+ </Alert.Title><Alert.Description>- Showing models from successful providers. {failedProviderCount} of{" "}+ Showing models from the other credentials. {failedProviderCount} of{" "}{providerCount} credentials failed to sync.</Alert.Description></Alert>@@ -217,6 +219,6 @@ function getEmptyMessage({}) {if (hasActiveFilters)return "No models match the current search and filters.";- if (hasSynced) return "No models were returned by the configured providers.";- return "Models will appear here after provider discovery completes.";+ if (hasSynced) return "No models were returned by your provider credentials.";+ return "Models will appear here after model discovery completes.";}diff --git a/web/src/features/ai-gateway/components/GatewayModelsPage/components/ConnectedGatewayModelsTable/components/GatewayModelsEmptyState/GatewayModelsEmptyState.tsx b/web/src/features/ai-gateway/components/GatewayModelsPage/components/ConnectedGatewayModelsTable/components/GatewayModelsEmptyState/GatewayModelsEmptyState.tsxindex 7cbbf9f475..fb242b71ef 100644--- a/web/src/features/ai-gateway/components/GatewayModelsPage/components/ConnectedGatewayModelsTable/components/GatewayModelsEmptyState/GatewayModelsEmptyState.tsx+++ b/web/src/features/ai-gateway/components/GatewayModelsPage/components/ConnectedGatewayModelsTable/components/GatewayModelsEmptyState/GatewayModelsEmptyState.tsx@@ -6,7 +6,7 @@ import { GatewaySetupEmptyState } from "@/src/features/ai-gateway/components/Gatconst EMPTY_STATE_COPY = {noProviders: {icon: Plug,- title: "No active providers",+ title: "No active provider credentials",managerDescription:"Add an OpenAI or Anthropic credential, or fix an existing one, so the gateway can route requests and discover models.",memberDescription:@@ -16,7 +16,7 @@ const EMPTY_STATE_COPY = {icon: Boxes,title: "No models available",managerDescription:- "Your provider credentials returned no enabled models. Enable models on a credential, or add another provider.",+ "Your provider credentials returned no enabled models. Enable models on a credential, or add another credential.",/** Members read cached models only, so an empty list can mean "not discovered yet" rather than "disabled". */memberDescription:"No models have been discovered for your organization's provider credentials yet. Check back later, or ask your organization admin if this persists.",@@ -57,13 +57,13 @@ export function GatewayModelsEmptyState({actions={[{type: "button",- label: "Add provider",+ label: "Add credential",icon: Plus,onClick: onAddProvider,},{type: "link",- label: "Manage providers",+ label: "Manage credentials",href: `/organization/${encodeURIComponent(organizationId)}/settings/ai-gateway`,},]}diff --git a/web/src/features/ai-gateway/components/GatewayModelsPage/components/ConnectedGatewayModelsTable/components/GatewayModelsTable/GatewayModelsTable.stories.tsx b/web/src/features/ai-gateway/components/GatewayModelsPage/components/ConnectedGatewayModelsTable/components/GatewayModelsTable/GatewayModelsTable.stories.tsxindex 0d9d18daa4..c9adeb1119 100644--- a/web/src/features/ai-gateway/components/GatewayModelsPage/components/ConnectedGatewayModelsTable/components/GatewayModelsTable/GatewayModelsTable.stories.tsx+++ b/web/src/features/ai-gateway/components/GatewayModelsPage/components/ConnectedGatewayModelsTable/components/GatewayModelsTable/GatewayModelsTable.stories.tsx@@ -6,7 +6,7 @@ import { GatewayModelsTable } from "./GatewayModelsTable";const meta = preview.meta({ component: GatewayModelsTable });const actions = {- noResultsMessage: "No models were returned by the configured providers.",+ noResultsMessage: "No models were returned by your provider credentials.",organizationId: "org-story",canManageGateway: true,pagination: {diff --git a/web/src/features/ai-gateway/components/GatewayNotDeployedNotice/GatewayNotDeployedNotice.tsx b/web/src/features/ai-gateway/components/GatewayNotDeployedNotice/GatewayNotDeployedNotice.tsxindex 1a49471e3e..f6e2db9aa3 100644--- a/web/src/features/ai-gateway/components/GatewayNotDeployedNotice/GatewayNotDeployedNotice.tsx+++ b/web/src/features/ai-gateway/components/GatewayNotDeployedNotice/GatewayNotDeployedNotice.tsx@@ -12,7 +12,7 @@ export function GatewayNotDeployedNotice() {<GatewaySetupEmptyStateicon={Server}title="The AI Gateway isn't deployed"- description="On self-hosted Langfuse, the AI Gateway runs as a separate service. Deploy it next to your Langfuse instance to configure providers, models and gateway keys."+ description="On self-hosted Langfuse, the AI Gateway runs as a separate service. Deploy it next to your Langfuse instance to configure provider credentials, models and gateway keys."actions={[{type: "link",diff --git a/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/GatewayProvidersTable/GatewayProvidersTable.tsx b/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/GatewayProvidersTable/GatewayProvidersTable.tsxindex eb99f223b5..ed0ba075bd 100644--- a/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/GatewayProvidersTable/GatewayProvidersTable.tsx+++ b/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/GatewayProvidersTable/GatewayProvidersTable.tsx@@ -3,9 +3,10 @@ import { useMemo } from "react";import { ListTree, Pencil, RefreshCw, Trash2 } from "@langfuse/icons";import { SettingsTable } from "@/src/components/SettingsTable/SettingsTable";-import { createStatusTableColumn } from "@/src/components/design-system/table/columns/createStatusTableColumn";+import { Tooltip } from "@/src/components/design-system/Tooltip/Tooltip";import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";import type { LangfuseColumnDef } from "@/src/components/table/types";+import { StatusBadge } from "@/src/components/ui/StatusBadge/StatusBadge";import { GatewayProvidersEmptyState } from "@/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/GatewayProvidersTable/components/GatewayProvidersEmptyState/GatewayProvidersEmptyState";import { GatewayProviderMark } from "@/src/features/ai-gateway/components/GatewayProviderMark";import { providerLabels } from "@/src/features/ai-gateway/constants/providerLabels";@@ -32,6 +33,10 @@ const connectionStatus = {DISABLED: "disabled",} as const satisfies Record<GatewayConnection["status"], string>;+/** Model discovery marks a connection as errored only when the provider rejects its credential. */+const connectionErrorReason =+ "The provider rejected this credential. Update the credential or retry validation.";+export function GatewayProvidersTable({connections,modelCounts,@@ -62,19 +67,23 @@ export function GatewayProvidersTable({size: 180,sensitive: true,}),- createStatusTableColumn<GatewayConnection, GatewayConnection["status"]>({+ {accessorKey: "status",header: "Status",size: 110,- getStatus: (status) => (status ? connectionStatus[status] : undefined),- isLive: false,- }),+ cell: ({ row }) => <ConnectionStatus status={row.original.status} />,+ },{accessorKey: "id",id: "models",header: "Models",size: 180,- cell: ({ row }) => <ModelCount value={modelCounts[row.original.id]} />,+ cell: ({ row }) =>+ row.original.status === "ERROR" ? (+ <span className="text-destructive">Credential rejected</span>+ ) : (+ <ModelCount value={modelCounts[row.original.id]} />+ ),},],[modelCounts],@@ -95,7 +104,7 @@ export function GatewayProvidersTable({{id: "retry",type: "item",- title: "Retry provider validation",+ title: "Retry validation",icon: RefreshCw,disabled: retryDisabled,onClick: () => onRetry(connection),@@ -126,6 +135,24 @@ export function GatewayProvidersTable({);}+function ConnectionStatus({ status }: { status: GatewayConnection["status"] }) {+ const badge = <StatusBadge type={connectionStatus[status]} isLive={false} />;+ if (status !== "ERROR") return badge;+ return (+ <Tooltip label={connectionErrorReason}>+ {({ getTriggerProps }) => (+ <span+ {...getTriggerProps()}+ tabIndex={0}+ className="focus-visible:ring-ring inline-flex rounded-sm focus-visible:ring-2 focus-visible:outline-hidden"+ >+ {badge}+ </span>+ )}+ </Tooltip>+ );+}+function ModelCount({value,}: {diff --git a/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/GatewayProvidersTable/components/GatewayProvidersEmptyState/GatewayProvidersEmptyState.tsx b/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/GatewayProvidersTable/components/GatewayProvidersEmptyState/GatewayProvidersEmptyState.tsxindex e77a469664..81291ad2f7 100644--- a/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/GatewayProvidersTable/components/GatewayProvidersEmptyState/GatewayProvidersEmptyState.tsx+++ b/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/GatewayProvidersTable/components/GatewayProvidersEmptyState/GatewayProvidersEmptyState.tsx@@ -6,7 +6,7 @@ export function GatewayProvidersEmptyState() {return (<GatewaySetupEmptyStateicon={Plug}- title="No providers set up yet"+ title="No provider credentials yet"description="Add an OpenAI or Anthropic credential so the gateway can route requests and discover models."/>);diff --git a/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/IngestionDialogController/components/IngestionDialog/IngestionDialog.stories.tsx b/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/IngestionDialogController/components/IngestionDialog/IngestionDialog.stories.tsxindex 96d3fffd2d..db69724ac4 100644--- a/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/IngestionDialogController/components/IngestionDialog/IngestionDialog.stories.tsx+++ b/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/IngestionDialogController/components/IngestionDialog/IngestionDialog.stories.tsx@@ -74,3 +74,44 @@ export const TestClosesOnlyAfterSave = meta.story({await expect(args.onSaved).not.toHaveBeenCalled();},});++export const TestUsageModeAccessWarning = meta.story({+ name: "(Test) Warns that everyone with project access sees gateway traffic",+ args: SavedConfig.input.args,+ play: async () => {+ const dialog = within(document.body).getByRole("dialog");+ const alert = within(dialog).getByRole("alert");+ await expect(alert).toHaveTextContent(+ "Everyone with project access sees gateway traffic",+ );+ await expect(alert).toHaveTextContent("organization member and viewer");+ await expect(alert).toHaveTextContent("costs, and gateway key owners");+ await expect(alert).not.toHaveTextContent("prompts and responses");+ },+});++export const TestFullModeAccessWarning = meta.story({+ name: "(Test) Full mode warning includes prompts and responses",+ args: {+ ...SavedConfig.input.args,+ config: {+ ...SavedConfig.input.args.config,+ ingestionMode: "FULL",+ },+ },+ play: async () => {+ const dialog = within(document.body).getByRole("dialog");+ await expect(within(dialog).getByRole("alert")).toHaveTextContent(+ "prompts and responses",+ );+ },+});++export const TestNoAccessWarningWithoutRecording = meta.story({+ name: "(Test) No access warning when nothing is recorded",+ args: NotRecording.input.args,+ play: async () => {+ const dialog = within(document.body).getByRole("dialog");+ await expect(within(dialog).queryByRole("alert")).not.toBeInTheDocument();+ },+});diff --git a/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/IngestionDialogController/components/IngestionDialog/IngestionDialog.tsx b/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/IngestionDialogController/components/IngestionDialog/IngestionDialog.tsxindex bdb270a2b9..84dcfd4cf3 100644--- a/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/IngestionDialogController/components/IngestionDialog/IngestionDialog.tsx+++ b/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/IngestionDialogController/components/IngestionDialog/IngestionDialog.tsx@@ -3,6 +3,7 @@ import { useState } from "react";import { Button } from "@/src/components/design-system/Button/Button";import { Dialog } from "@/src/components/design-system/Dialog/Dialog";import { IngestionSettingsFields } from "@/src/features/ai-gateway/components/GatewaySetupPage/components/IngestionSettingsFields/IngestionSettingsFields";+import { IngestionProjectAccessAlert } from "@/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/IngestionDialogController/components/IngestionDialog/components/IngestionProjectAccessAlert";import { GATEWAY_SETUP } from "@/src/features/ai-gateway/components/GatewaySetupPage/constants/gatewaySetup";import { getInitialIngestionSettings } from "@/src/features/ai-gateway/components/GatewaySetupPage/fns/getInitialIngestionSettings";import { isIngestionSettingsValid } from "@/src/features/ai-gateway/components/GatewaySetupPage/fns/isIngestionSettingsValid";@@ -63,6 +64,9 @@ export function IngestionDialog({projects={projects}onChange={setSettings}/>+ {settings.ingestionMode === "NONE" ? null : (+ <IngestionProjectAccessAlert ingestionMode={settings.ingestionMode} />+ )}</Dialog.Body></Dialog>);diff --git a/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/IngestionDialogController/components/IngestionDialog/components/IngestionProjectAccessAlert.tsx b/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/IngestionDialogController/components/IngestionDialog/components/IngestionProjectAccessAlert.tsxnew file mode 100644index 0000000000..9dc3452049--- /dev/null+++ b/web/src/features/ai-gateway/components/GatewaySetupPage/components/GatewayCredentialsOverview/components/IngestionDialogController/components/IngestionDialog/components/IngestionProjectAccessAlert.tsx@@ -0,0 +1,32 @@+import { AlertTriangle } from "@langfuse/icons";+import type { GatewayIngestionMode } from "@langfuse/shared";++import { Alert } from "@/src/components/design-system/Alert/Alert";++export type IngestionProjectAccessAlertProps = {+ ingestionMode: Exclude<GatewayIngestionMode, "NONE">;+};++/** Org members and viewers get implicit access to every project through their org role. */+export function IngestionProjectAccessAlert({+ ingestionMode,+}: IngestionProjectAccessAlertProps) {+ return (+ <Alert variant="warning" size="sm" icon={AlertTriangle}>+ <Alert.Title>+ Everyone with project access sees gateway traffic+ </Alert.Title>+ <Alert.Description>+ <p>+ Anyone who can open the ingestion project, including every+ organization member and viewer through their organization role, can+ see gateway requests, costs, and gateway key owners+ {ingestionMode === "FULL"+ ? ", plus the full prompts and responses"+ : ""}+ . Use a dedicated project and restrict who can access it.+ </p>+ </Alert.Description>+ </Alert>+ );+}diff --git a/web/src/features/ai-gateway/components/GatewaySetupPage/components/ProviderDialogController/ProviderDialogController.tsx b/web/src/features/ai-gateway/components/GatewaySetupPage/components/ProviderDialogController/ProviderDialogController.tsxindex a7263d263d..889bfa56a5 100644--- a/web/src/features/ai-gateway/components/GatewaySetupPage/components/ProviderDialogController/ProviderDialogController.tsx+++ b/web/src/features/ai-gateway/components/GatewaySetupPage/components/ProviderDialogController/ProviderDialogController.tsx@@ -87,7 +87,7 @@ export function ProviderDialogController({: null;const isError = test.isError || (Boolean(saveError) && !serverNameError);const errorTitle = test.isError- ? "Provider validation failed"+ ? "Credential validation failed": "Provider credential could not be saved";/** Skips the live check after saving, as the refetched list already holds the saved name. */diff --git a/web/src/features/ai-gateway/constants/gatewayConnection.ts b/web/src/features/ai-gateway/constants/gatewayConnection.tsindex 58690e6caa..5788c89d44 100644--- a/web/src/features/ai-gateway/constants/gatewayConnection.ts+++ b/web/src/features/ai-gateway/constants/gatewayConnection.ts@@ -2,8 +2,8 @@ export const GATEWAY_CONNECTION_NAME_MAX_LENGTH = 64;export const GATEWAY_CONNECTION_NAME_ERRORS = {duplicate: "A provider credential with this name already exists.",- required: "Enter a connection name.",- tooLong: `Connection names can be at most ${GATEWAY_CONNECTION_NAME_MAX_LENGTH} characters.`,+ required: "Enter a credential name.",+ tooLong: `Credential names can be at most ${GATEWAY_CONNECTION_NAME_MAX_LENGTH} characters.`,invalidCharacters:"Use only letters, numbers, hyphens, and underscores, starting with a letter or number.",reserved: "“ft” is reserved for OpenAI fine-tuned model IDs.",diff --git a/web/src/features/ai-gateway/server/apiKey/gatewayApiKeyService.ts b/web/src/features/ai-gateway/server/apiKey/gatewayApiKeyService.tsindex dadbbaa7d9..90649b1280 100644--- a/web/src/features/ai-gateway/server/apiKey/gatewayApiKeyService.ts+++ b/web/src/features/ai-gateway/server/apiKey/gatewayApiKeyService.ts@@ -109,7 +109,7 @@ export class GatewayApiKeyService {}): Promise<void> {const association = await this.repository.getGatewayApiKey(params);if (!association) {- throw new LangfuseNotFoundError("Gateway API key not found");+ throw new LangfuseNotFoundError("Gateway key not found");}// Read the hash before the row is gone; it is the resolve cache key.const revoked = await this.prisma.apiKey.findFirst({@@ -128,7 +128,7 @@ export class GatewayApiKeyService {redis: this.redis,});if (!deleted) {- throw new InternalServerError("Failed to revoke gateway API key");+ throw new InternalServerError("Failed to revoke gateway key");}if (revoked?.fastHashedSecretKey) {await invalidateGatewayResolveCacheForApiKey(revoked.fastHashedSecretKey);diff --git a/web/src/features/ai-gateway/server/provider/connection/gatewayProviderService.ts b/web/src/features/ai-gateway/server/provider/connection/gatewayProviderService.tsindex e674091b47..222436fe21 100644--- a/web/src/features/ai-gateway/server/provider/connection/gatewayProviderService.ts+++ b/web/src/features/ai-gateway/server/provider/connection/gatewayProviderService.ts@@ -45,7 +45,7 @@ export class GatewayProviderService {async get(params: { organizationId: string; id: string }) {const connection = await this.repository.getSafeConnection(params);- if (!connection) throw new LangfuseNotFoundError("Gateway connection");+ if (!connection) throw new LangfuseNotFoundError("Provider credential");return connection;}@@ -125,7 +125,7 @@ export class GatewayProviderService {organizationId: params.organizationId,id: params.id,});- if (!existing) throw new LangfuseNotFoundError("Gateway connection");+ if (!existing) throw new LangfuseNotFoundError("Provider credential");/** Unchanged names skip validation so pre-existing names stay editable. */const name =params.name === undefined || params.name.trim() === existing.name@@ -144,7 +144,7 @@ export class GatewayProviderService {!params.credential) {throw new InvalidRequestError(- "Errored gateway connections require a credential update or successful retry",+ "Errored provider credentials need a credential update or a successful retry",);}if (params.credential) {diff --git a/web/src/features/ai-gateway/server/provider/models/gatewayModelCatalogService.ts b/web/src/features/ai-gateway/server/provider/models/gatewayModelCatalogService.tsindex f53e120285..da2cd20446 100644--- a/web/src/features/ai-gateway/server/provider/models/gatewayModelCatalogService.ts+++ b/web/src/features/ai-gateway/server/provider/models/gatewayModelCatalogService.ts@@ -220,7 +220,7 @@ export class GatewayModelCatalogService {organizationId: params.organizationId,id: params.connectionId,});- if (!connection) throw new LangfuseNotFoundError("Gateway connection");+ if (!connection) throw new LangfuseNotFoundError("Provider credential");if (params.forceRefresh) {await this.clearModelCache(params.organizationId, params.connectionId);diff --git a/web/src/features/settings/SettingsPage.clienttest.tsx b/web/src/features/settings/SettingsPage.clienttest.tsxindex 4b4c54985b..0e25d259da 100644--- a/web/src/features/settings/SettingsPage.clienttest.tsx+++ b/web/src/features/settings/SettingsPage.clienttest.tsx@@ -1,4 +1,4 @@-import { fireEvent, render, screen } from "@testing-library/react";+import { render, screen } from "@testing-library/react";import { PagedSettingsContainer } from "@/src/components/PagedSettingsContainer";import { buildSettingsPages } from "@/src/features/settings/SettingsPage";@@ -139,14 +139,14 @@ describe("buildSettingsPages", () => {/>,);- expect(screen.getAllByRole("link", { name: "General" })).toHaveLength(1);+ expect(screen.getAllByRole("link", { name: "General" })).toHaveLength(2);expect(screen.getByRole("link", { name: "Billing" })).toHaveAttribute("href","/organization/org-1/settings/billing",);});- it("drops table query params when switching pages", () => {+ it("renders in-page entries as focusable links and drops table query params", () => {router.asPath = "/organization/org-1/settings/members?search=alice";render(<PagedSettingsContainer@@ -156,13 +156,22 @@ describe("buildSettingsPages", () => {accountPages,organizationPages,})}+ activeSlug="billing"/>,);- fireEvent.click(screen.getByText("Billing"));-- expect(router.push).toHaveBeenCalledWith(+ const billing = screen.getByRole("link", { name: "Billing" });+ expect(billing).toHaveAttribute(+ "href","/organization/org-1/settings/billing",);+ expect(billing).toHaveAttribute("aria-current", "page");+ billing.focus();+ expect(billing).toHaveFocus();+ expect(+ screen+ .getAllByRole("link", { name: "General" })+ .map((link) => link.getAttribute("href")),+ ).toContain("/organization/org-1/settings");});});diff --git a/web/src/features/widgets/chart-library/BigNumber.tsx b/web/src/features/widgets/chart-library/BigNumber.tsxindex eddd3fdbeb..36f93de3d7 100644--- a/web/src/features/widgets/chart-library/BigNumber.tsx+++ b/web/src/features/widgets/chart-library/BigNumber.tsx@@ -1,5 +1,5 @@/* eslint-disable @repo/no-style-props */-import React, { useEffect, useRef, useState, useMemo } from "react";+import React, { useLayoutEffect, useRef, useState, useMemo } from "react";import { cn } from "@/src/utils/tailwind";import { type ChartProps } from "@/src/features/widgets/chart-library/chart-props";@@ -80,8 +80,9 @@ export const BigNumber: React.FC<ChartProps> = ({};}, [calculatedMetric, maxCharacters, metricFormatter]);- useEffect(() => {- const resizeObserver = new ResizeObserver(() => {+ // Fits before the first paint so the number never renders at the default size and shrinks.+ useLayoutEffect(() => {+ const fit = () => {if (!containerRef.current || !textRef.current) return;const container = containerRef.current;@@ -131,8 +132,10 @@ export const BigNumber: React.FC<ChartProps> = ({setFontSize(selectedFontSize);setMaxCharacters(calculatedMaxChars);- });+ };+ fit();+ const resizeObserver = new ResizeObserver(fit);if (containerRef.current) {resizeObserver.observe(containerRef.current);}diff --git a/web/src/features/widgets/chart-library/chart-props.ts b/web/src/features/widgets/chart-library/chart-props.tsindex 4098c24703..a2ab53e358 100644--- a/web/src/features/widgets/chart-library/chart-props.ts+++ b/web/src/features/widgets/chart-library/chart-props.ts@@ -79,6 +79,11 @@ export type FormatMetricOptions = {unit?: string;style: "full" | "compact";maxCharacters?: number;+ /**+ * `"cents"` rounds USD to two decimals and shows non-zero values below one+ * cent as `<$0.01`. By default values under $5 keep up to six decimals.+ */+ usdPrecision?: "cents";};export type MetricFormatterFunction = (diff --git a/web/src/features/widgets/chart-library/utils.clienttest.ts b/web/src/features/widgets/chart-library/utils.clienttest.tsindex 37a050d1ee..6b9ebaa51c 100644--- a/web/src/features/widgets/chart-library/utils.clienttest.ts+++ b/web/src/features/widgets/chart-library/utils.clienttest.ts@@ -4,6 +4,7 @@ import {formatMetric,getDimensionSummaries,getEvenTickInterval,+ toFullMetricString,} from "@/src/features/widgets/chart-library/utils";import { type DataPoint } from "@/src/features/widgets/chart-library/chart-props";@@ -94,6 +95,28 @@ describe("formatMetric", () => {});});+ it("rounds USD to cents and floors tiny non-zero values when opted in", () => {+ const usd = (value: number, style: "compact" | "full") =>+ toFullMetricString(+ formatMetric(value, { unit: "USD", style, usdPrecision: "cents" }),+ );++ for (const style of ["compact", "full"] as const) {+ expect(usd(2.036571, style)).toBe("$2.04");+ expect(usd(0.5, style)).toBe("$0.50");+ expect(usd(1234.5, style)).toBe("$1,234.50");+ expect(usd(0.004, style)).toBe("<$0.01");+ expect(usd(0.0000001, style)).toBe("<$0.01");+ expect(usd(0, style)).toBe("$0.00");+ }+ });++ it("keeps sub-cent USD precision by default", () => {+ expect(+ toFullMetricString(formatMetric(0.0023, { unit: "USD", style: "full" })),+ ).toBe("$0.0023");+ });+it("keeps negative currency sign ahead of the currency prefix", () => {expect(formatMetric(-1.234567, { unit: "USD", style: "compact" })).toEqual({negative: true,diff --git a/web/src/features/widgets/chart-library/utils.ts b/web/src/features/widgets/chart-library/utils.tsindex 28f5ccb5b9..ef312a3290 100644--- a/web/src/features/widgets/chart-library/utils.ts+++ b/web/src/features/widgets/chart-library/utils.ts@@ -279,6 +279,8 @@ const formatCompactMetric = (return formatExponentialMetric(value, maxCharacters);};+const MIN_DISPLAYED_USD = 0.01;+const durationDivisors = [1, 1_000, 60_000, 3_600_000, 86_400_000] as const;const durationUnits = ["millisecond",@@ -350,7 +352,8 @@ const formatWithConstrainedDecimals = ({* - `unit === "millisecond"` auto-scales across ms/s/min/h/d and can reduce* fractional precision to satisfy `maxCharacters`.* - `unit === "USD"` formats with a currency prefix and can reduce fractional- * precision to satisfy `maxCharacters`.+ * precision to satisfy `maxCharacters`. With `usdPrecision: "cents"` it keeps+ * at most two decimals and renders non-zero values below one cent as `<$0.01`.* - `style === "compact"` uses compact suffixes for large values (`K`, `M`,* `B`, `T`), decimal formatting for `1e-3 <= |value| < 1`, and exponential* notation below `1e-3`.@@ -365,7 +368,7 @@ export function formatMetric(value: number,options: FormatMetricOptions,): FormattedMetric {- const { unit, style, maxCharacters } = options;+ const { unit, style, maxCharacters, usdPrecision } = options;const negative = value < 0;const absValue = Math.abs(value);@@ -407,7 +410,12 @@ export function formatMetric(}if (unit === "USD") {- const maxFractionDigits = value && absValue < 5 ? 6 : 2;+ const roundsToCents = usdPrecision === "cents";+ if (roundsToCents && absValue > 0 && absValue < MIN_DISPLAYED_USD) {+ return applyNegative({ prefix: "<$", main: "0.01" });+ }+ const keepsSubCentDigits = !roundsToCents && absValue > 0 && absValue < 5;+ const maxFractionDigits = keepsSubCentDigits ? 6 : 2;return applyNegative(formatWithConstrainedDecimals({diff --git a/web/src/features/widgets/components/InlineWidget.tsx b/web/src/features/widgets/components/InlineWidget.tsxindex c30a27da4e..8262e9e2d8 100644--- a/web/src/features/widgets/components/InlineWidget.tsx+++ b/web/src/features/widgets/components/InlineWidget.tsx@@ -10,7 +10,10 @@ import {} from "@langfuse/shared/query";import { useScheduledDashboardExecuteQuery } from "@/src/features/dashboard/hooks/DashboardQuerySchedulerProvider";import { Chart } from "@/src/features/widgets/chart-library/Chart";-import { type LegendPosition } from "@/src/features/widgets/chart-library/chart-props";+import {+ type FormatMetricOptions,+ type LegendPosition,+} from "@/src/features/widgets/chart-library/chart-props";import { ChartLoadingState } from "@/src/features/widgets/chart-library/ChartLoadingState";import {getChartLoadingProgress,@@ -106,6 +109,7 @@ export interface WidgetContentProps {* short for it. Pass a stable node (see `Chart`).*/emptyState?: ReactNode;+ usdPrecision?: FormatMetricOptions["usdPrecision"];}// ============================================================================@@ -157,6 +161,7 @@ export function WidgetContent({legendPosition,zeroBaseline,emptyState,+ usdPrecision,}: WidgetContentProps) {// Transport-only: `version` is a prop here, so an unresolved session can// never change WHAT is queried — only whether it streams (SSE) or not.@@ -351,8 +356,9 @@ export function WidgetContent({metric,view,version,+ usdPrecision,});- }, [chartType, metrics, view, version]);+ }, [chartType, metrics, view, version, usdPrecision]);// Loading stateconst chartLoadingState = getChartLoadingStateProps({diff --git a/web/src/features/widgets/utils.ts b/web/src/features/widgets/utils.tsindex c5daf47332..464792809c 100644--- a/web/src/features/widgets/utils.ts+++ b/web/src/features/widgets/utils.ts@@ -9,6 +9,7 @@ import {} from "@langfuse/shared/query";import { formatMetric } from "@/src/features/widgets/chart-library/utils";import {+ type FormatMetricOptions,type MetricFormatterFunction,type MissingBucketValue,} from "@/src/features/widgets/chart-library/chart-props";@@ -289,6 +290,7 @@ export function getWidgetMetricPresentation(params: {metric: { measure: string; agg: string };view: string;version: ViewVersion;+ usdPrecision?: FormatMetricOptions["usdPrecision"];}): {label: string;metricFormatter?: MetricFormatterFunction;@@ -311,7 +313,11 @@ export function getWidgetMetricPresentation(params: {return {label: widgetUnitLabels[measureDefinition.unit],metricFormatter: (value, options) =>- formatMetric(value, { ...options, unit: measureDefinition.unit }),+ formatMetric(value, {+ ...options,+ unit: measureDefinition.unit,+ usdPrecision: params.usdPrecision,+ }),};}