Skip to content

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

fix(web): Topics setup explains a missing AI connection and helps non-admins (#19286)

Trang Nguyen7d8bac658525
diff --git a/web/src/features/topics/TopicSetupFlowController.tsx b/web/src/features/topics/TopicSetupFlowController.tsx
index 4e89f0be54..f29c9f6418 100644
--- a/web/src/features/topics/TopicSetupFlowController.tsx
+++ b/web/src/features/topics/TopicSetupFlowController.tsx
@@ -5,6 +5,7 @@ import { DialogController } from "@/src/components/design-system/DialogControlle
import { env } from "@/src/env.mjs";
import { type JudgeModel } from "@/src/features/evals/v2/judgeModel";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
+import { useHasProjectAccess } from "@/src/features/rbac";
import { api } from "@/src/utils/api";
import { type ConfigureTopicsSettingsInput } from "./TopicModelSettings";
import {
@@ -57,6 +58,8 @@ export function TopicSetupFlowController({
onDismiss={closeSetup}
renderDialog={({ closeDialog }) => (
<TopicSetupSession
+ // Rebuilds the draft with recommended models once the first connection arrives.
+ key={settings.connections.length > 0 ? "ready" : "none"}
projectId={projectId}
canWrite={canWrite}
settings={settings}
@@ -90,6 +93,23 @@ function TopicSetupSession({
}) {
const capture = usePostHogClientCapture();
const utils = api.useUtils();
+ const canAddConnection = useHasProjectAccess({
+ projectId,
+ scope: "llmApiKeys:create",
+ });
+ // A connection added in another tab shows up when this tab regains focus.
+ useEffect(() => {
+ const refetch = () => {
+ if (document.visibilityState === "visible")
+ utils.llmApiKey.effective.invalidate({ projectId });
+ };
+ window.addEventListener("focus", refetch);
+ document.addEventListener("visibilitychange", refetch);
+ return () => {
+ window.removeEventListener("focus", refetch);
+ document.removeEventListener("visibilitychange", refetch);
+ };
+ }, [utils, projectId]);
const save = api.topics.saveSetup.useMutation({
onSuccess: () => {
utils.topics.modelSettings.invalidate({ projectId });
@@ -99,6 +119,7 @@ function TopicSetupSession({
},
});
const startSetup = api.topics.startSetup.useMutation();
+ const connectionSettingsUrl = `${window.location.origin}${env.NEXT_PUBLIC_BASE_PATH ?? ""}/project/${projectId}/settings/llm-connections`;
const connections = settings.connections.map(
(connection): TopicSetupConnection => ({
id: connection.id,
@@ -273,6 +294,8 @@ function TopicSetupSession({
settings.stored.embedding?.model,
)}
connectionCaption={topicConnectionCaption(connections)}
+ hasConnection={connections.length > 0}
+ canAddConnection={canAddConnection}
advancedOpen={draft.advancedOpen}
waitMinutes={draft.waitMinutes}
samplePercent={draft.samplePercent}
@@ -288,12 +311,9 @@ function TopicSetupSession({
onEmbeddingChange={(model) => updateModel(setDraft, "embedding", model)}
onClusteringChange={(model) => updateModel(setDraft, "clustering", model)}
onConfigureProviders={() => {
- window.open(
- `${env.NEXT_PUBLIC_BASE_PATH ?? ""}/project/${projectId}/settings/llm-connections`,
- "_blank",
- "noopener,noreferrer",
- );
+ window.open(connectionSettingsUrl, "_blank", "noopener,noreferrer");
}}
+ connectionSettingsUrl={connectionSettingsUrl}
onAdvancedOpenChange={(advancedOpen) =>
setDraft((current) => ({ ...current, advancedOpen }))
}
diff --git a/web/src/features/topics/TopicSetupFlowDialog.stories.tsx b/web/src/features/topics/TopicSetupFlowDialog.stories.tsx
index b76919c436..8ff3b334a8 100644
--- a/web/src/features/topics/TopicSetupFlowDialog.stories.tsx
+++ b/web/src/features/topics/TopicSetupFlowDialog.stories.tsx
@@ -31,7 +31,14 @@ const questions: TopicSetupQuestion[] = TOPIC_SETUP_QUESTIONS.map(
}),
);
-function SetupStory({ step }: { step: "questions" | "traces" | "review" }) {
+function SetupStory({
+ step,
+ connection = "ready",
+}: {
+ step: "questions" | "traces" | "review";
+ /** "none": no AI connection yet; "viewer": none, and this user cannot add one. */
+ connection?: "ready" | "none" | "viewer";
+}) {
const [selected, setSelected] = useState(questions);
return (
<TopicSetupFlowDialog
@@ -42,7 +49,10 @@ function SetupStory({ step }: { step: "questions" | "traces" | "review" }) {
provider: "Amazon Bedrock",
model: "us.anthropic.claude-sonnet-5-5",
}}
+ projectId="demo-project"
connectionCaption="Amazon Bedrock"
+ hasConnection={connection === "ready"}
+ canAddConnection={connection !== "viewer"}
embedding={{
provider: "Amazon Bedrock",
model: "us.cohere.embed-v4:0",
@@ -53,6 +63,7 @@ function SetupStory({ step }: { step: "questions" | "traces" | "review" }) {
onBack={fn()}
onClusteringChange={fn()}
onConfigureProviders={fn()}
+ connectionSettingsUrl="https://cloud.langfuse.com/project/demo-project/settings/llm-connections"
onEdit={fn()}
onEmbeddingChange={fn()}
onNext={fn()}
@@ -102,6 +113,15 @@ export const Questions = meta.story({
args: { step: "questions" },
});
+export const NoConnection = meta.story({
+ args: { step: "questions", connection: "none" },
+});
+
+export const NoConnectionViewer = meta.story({
+ name: "No connection, cannot add one",
+ args: { step: "questions", connection: "viewer" },
+});
+
export const Traces = meta.story({
args: { step: "traces" },
});
diff --git a/web/src/features/topics/TopicSetupFlowDialog.tsx b/web/src/features/topics/TopicSetupFlowDialog.tsx
index ebebe48db7..793a48e2e4 100644
--- a/web/src/features/topics/TopicSetupFlowDialog.tsx
+++ b/web/src/features/topics/TopicSetupFlowDialog.tsx
@@ -1,11 +1,23 @@
/* eslint-disable @typescript-eslint/no-use-before-define */
+import { Slider } from "@/src/components/ui/Slider";
import { useState } from "react";
-import { ChevronDown, ChevronRight, Clock, RefreshCw } from "@langfuse/icons";
+import {
+ ChevronDown,
+ ChevronRight,
+ Clock,
+ ArrowUpRight,
+ Copy,
+ Lock,
+ Plug,
+ RefreshCw,
+} from "@langfuse/icons";
import { Alert } from "@/src/components/design-system/Alert/Alert";
+import { copyTextToClipboard } from "@/src/utils/clipboard";
import { Badge } from "@/src/components/design-system/Badge/Badge";
import { Button } from "@/src/components/design-system/Button/Button";
import { Checkbox } from "@/src/components/design-system/Checkbox/Checkbox";
import { Dialog } from "@/src/components/design-system/Dialog/Dialog";
+import { IconButton } from "@/src/components/design-system/IconButton/IconButton";
import { Input } from "@/src/components/design-system/Input/Input";
import { PopoverTrigger } from "@/src/components/ui/popover";
import { JudgeModelPicker } from "@/src/features/evals/v2/components/Evaluators/JudgeModelPicker/JudgeModelPicker";
@@ -51,6 +63,10 @@ export type TopicSetupFlowDialogProps = {
canWrite: boolean;
clustering: JudgeModel | null;
connectionCaption: string;
+ /** False when the project has no AI connection yet; models cannot be picked. */
+ hasConnection: boolean;
+ /** Whether this user may add an AI connection; others are asked to contact an admin. */
+ canAddConnection: boolean;
embedding: JudgeModel | null;
embeddingProviderGroups: Array<[string, string[]]>;
error: string | null;
@@ -58,6 +74,8 @@ export type TopicSetupFlowDialogProps = {
onBack: () => void;
onClusteringChange: (model: JudgeModel) => void;
onConfigureProviders: () => void;
+ /** Absolute link to the project's LLM connection settings, shared by non-admins. */
+ connectionSettingsUrl: string;
onEdit: (step: "questions" | "traces") => void;
onEmbeddingChange: (model: JudgeModel) => void;
onNext: () => void;
@@ -84,6 +102,8 @@ export function TopicSetupFlowDialog({
canWrite,
clustering,
connectionCaption,
+ hasConnection,
+ canAddConnection,
embedding,
embeddingProviderGroups,
error,
@@ -91,6 +111,7 @@ export function TopicSetupFlowDialog({
onBack,
onClusteringChange,
onConfigureProviders,
+ connectionSettingsUrl,
onEdit,
onEmbeddingChange,
onNext,
@@ -127,18 +148,27 @@ export function TopicSetupFlowDialog({
});
// The server picks its own traces, so a failed estimate must not block Start.
const canStart = canWrite && !busy && pastCount.status !== "loading";
- const nextDisabled = nextStepDisabled({
- step,
- busy,
- canWrite,
- canLeaveQuestions,
- canStart,
- });
+ // Without a connection, people who cannot add one only get a link to share and Close.
+ const viewerBlocked = !hasConnection && !canAddConnection;
+ // Without a connection Next stays clickable and opens the connection settings instead.
+ const needsConnection = step === "questions" && !hasConnection;
+ const nextDisabled = needsConnection
+ ? false
+ : nextStepDisabled({
+ step,
+ busy,
+ canWrite,
+ canLeaveQuestions,
+ canStart,
+ });
const notice =
pastCount.status === "ready" ? backfillNotice(pastCount.matched) : null;
return (
- <Dialog title={`${STEP_TITLES[step]} · ${STEP_NUMBERS[step]}`}>
+ <Dialog
+ title={`${STEP_TITLES[step]} · ${STEP_NUMBERS[step]}`}
+ {...(viewerBlocked ? { closeLabel: "Close" } : {})}
+ >
<div className="flex min-h-0 flex-1 flex-col">
<div className="flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto px-4 pb-4">
{step === "questions" ? (
@@ -172,31 +202,74 @@ export function TopicSetupFlowDialog({
<h2 className="text-sm font-bold">
Select models for analysis
</h2>
- <span className="text-muted-foreground text-xs">
- {connectionCaption}
- </span>
+ {hasConnection && (
+ <span className="text-muted-foreground text-xs">
+ {connectionCaption}
+ </span>
+ )}
</div>
- <div className="divide-y rounded-md border">
- {MODEL_ROWS.map((row) => {
- const model = models[row.slot];
- return (
- <ModelRow
+ {viewerBlocked && (
+ <AskAdminForConnection url={connectionSettingsUrl} />
+ )}
+ {!hasConnection && canAddConnection && (
+ <Alert variant="warning" icon={Plug}>
+ <Alert.Title>
+ No AI connection in this project yet
+ </Alert.Title>
+ <Alert.Description>
+ <div className="mt-2">
+ <Button
+ text="Add connection"
+ variant="secondary"
+ size="sm"
+ icon={ArrowUpRight}
+ onClick={onConfigureProviders}
+ />
+ </div>
+ </Alert.Description>
+ </Alert>
+ )}
+ {!viewerBlocked && !hasConnection && (
+ <div
+ aria-hidden="true"
+ className="pointer-events-none divide-y rounded-lg border text-sm opacity-45"
+ >
+ {MODEL_ROWS.map((row) => (
+ <div
key={row.slot}
- label={row.label}
- model={model}
- recommended={
- model
- ? isRecommendedTopicModel(row.slot, model.model)
- : false
- }
- disabled={!canWrite}
- providerGroups={groups[row.slot]}
- onConfigureProviders={onConfigureProviders}
- onSelect={onModelChange[row.slot]}
- />
- );
- })}
- </div>
+ className="grid grid-cols-[140px_minmax(0,1fr)] items-center gap-3 px-3.5 py-2.75"
+ >
+ <span>{row.label}</span>
+ <span className="text-muted-foreground">
+ No models yet
+ </span>
+ </div>
+ ))}
+ </div>
+ )}
+ {hasConnection && (
+ <div className="divide-y rounded-md border">
+ {MODEL_ROWS.map((row) => {
+ const model = models[row.slot];
+ return (
+ <ModelRow
+ key={row.slot}
+ label={row.label}
+ model={model}
+ recommended={
+ model
+ ? isRecommendedTopicModel(row.slot, model.model)
+ : false
+ }
+ disabled={!canWrite}
+ providerGroups={groups[row.slot]}
+ onConfigureProviders={onConfigureProviders}
+ onSelect={onModelChange[row.slot]}
+ />
+ );
+ })}
+ </div>
+ )}
{error ? (
<p className="text-destructive text-sm">{error}</p>
) : null}
@@ -216,28 +289,34 @@ export function TopicSetupFlowDialog({
)}
</button>
{advancedOpen ? (
- <div className="flex flex-wrap items-center gap-3">
- <span className="text-sm">Wait before summarizing</span>
- <div className="flex gap-1.5">
- {TOPIC_SETUP_WAIT_MINUTES.map((minutes) => {
- const selected = waitMinutes === minutes;
- return (
- <button
- key={minutes}
- type="button"
- className={
- selected
- ? "bg-primary text-primary-foreground border-primary rounded-full border px-3 py-1 text-sm"
- : "rounded-full border px-3 py-1 text-sm"
- }
- aria-pressed={selected}
- onClick={() => onWaitMinutesChange(minutes)}
- >
- {minutes} min
- </button>
- );
- })}
+ <div className="flex flex-col gap-1.5">
+ <div className="flex flex-wrap items-center gap-3">
+ <span className="text-sm">Wait before summarizing</span>
+ <div className="flex gap-1.5">
+ {TOPIC_SETUP_WAIT_MINUTES.map((minutes) => {
+ const selected = waitMinutes === minutes;
+ return (
+ <button
+ key={minutes}
+ type="button"
+ className={
+ selected
+ ? "bg-primary text-primary-foreground border-primary rounded-full border px-3 py-1 text-sm"
+ : "rounded-full border px-3 py-1 text-sm"
+ }
+ aria-pressed={selected}
+ onClick={() => onWaitMinutesChange(minutes)}
+ >
+ {minutes} min
+ </button>
+ );
+ })}
+ </div>
</div>
+ <p className="text-muted-foreground text-xs">
+ A trace is summarized once no new events arrive for this
+ long, so long-running traces aren&apos;t cut off.
+ </p>
</div>
) : null}
</div>
@@ -245,26 +324,24 @@ export function TopicSetupFlowDialog({
) : null}
{step === "traces" ? (
<div className="flex flex-col gap-4">
- <TopicTraceFilterSection
- projectId={projectId}
- description="Custom trace filters are coming soon. For now, the sample rate applies to all new traces."
- />
- <div className="grid grid-cols-[150px_minmax(0,1fr)] items-center gap-3">
+ <TopicTraceFilterSection projectId={projectId} />
+ <div className="flex flex-col gap-2">
<span className="text-sm font-bold">Sample rate</span>
- <div className="flex flex-wrap items-center gap-3">
- <input
- type="range"
- min={1}
- max={100}
- value={samplePercent}
- aria-label="Sample rate"
- className="accent-primary w-40"
- disabled={!canWrite}
- onChange={(event) =>
- onSamplePercentChange(Number(event.target.value))
- }
- />
- <div className="w-28">
+ <div className="flex items-center gap-3">
+ <div className="min-w-0 flex-1">
+ <Slider
+ min={1}
+ max={100}
+ step={1}
+ value={[samplePercent]}
+ aria-label="Sample rate"
+ disabled={!canWrite}
+ onValueChange={(value) =>
+ onSamplePercentChange(value[0] ?? samplePercent)
+ }
+ />
+ </div>
+ <div className="w-20">
<Input
type="number"
min={1}
@@ -280,14 +357,14 @@ export function TopicSetupFlowDialog({
}}
/>
</div>
- <span className="text-sm">%</span>
+ <span className="text-muted-foreground text-sm">%</span>
</div>
+ <p className="text-muted-foreground text-sm">
+ {pastCount.status === "ready"
+ ? `~${dailyEstimate(pastCount.dailyTraces, samplePercent)} new traces a day, based on the last ${TOPIC_SETUP_BACKFILL_DAYS} days`
+ : "Share of new traces analyzed once automatic processing is on"}
+ </p>
</div>
- <p className="text-muted-foreground text-xs">
- {pastCount.status === "ready"
- ? `~${dailyEstimate(pastCount.dailyTraces, samplePercent)} new traces a day, based on the last ${TOPIC_SETUP_BACKFILL_DAYS} days.`
- : "Share of new traces analyzed once automatic processing is on."}
- </p>
</div>
) : null}
{step === "review" ? (
@@ -363,25 +440,29 @@ export function TopicSetupFlowDialog({
<p className="text-destructive text-sm">{error}</p>
) : null}
</div>
- <div className="flex items-center justify-between border-t px-4 py-3">
- {step === "questions" ? (
- <span />
- ) : (
- <Button
- text="Back"
- variant="ghost"
- disabled={busy}
- onClick={onBack}
- />
- )}
- <Button
- text={step === "review" ? "Start analyzing" : "Next"}
- variant="primary"
- loading={busy}
- disabled={nextDisabled}
- onClick={onNext}
- />
- </div>
+ {!viewerBlocked && (
+ <div className="flex items-center justify-between border-t px-4 py-3">
+ {step === "questions" ? (
+ <span />
+ ) : (
+ <Button
+ text="Back"
+ variant="ghost"
+ disabled={busy}
+ onClick={onBack}
+ />
+ )}
+ <div className="flex items-center gap-3">
+ <Button
+ text={step === "review" ? "Start analyzing" : "Next"}
+ variant="primary"
+ loading={busy}
+ disabled={nextDisabled}
+ onClick={needsConnection ? onConfigureProviders : onNext}
+ />
+ </div>
+ </div>
+ )}
</div>
</Dialog>
);
@@ -527,3 +608,28 @@ function ReviewRow({
</div>
);
}
+
+function AskAdminForConnection({ url }: { url: string }) {
+ return (
+ <div className="flex flex-col gap-3 rounded-lg border p-4">
+ <div className="flex items-center gap-2.5 text-sm font-bold">
+ <Lock size="base" aria-hidden="true" />
+ An admin needs to add an AI connection
+ </div>
+ <p className="text-muted-foreground text-sm">
+ You don&apos;t have permission to add one. Share this with an admin:
+ </p>
+ <div className="bg-muted flex items-center gap-2 rounded-md py-1 pr-1 pl-3">
+ <span className="min-w-0 flex-1 truncate font-mono text-xs" title={url}>
+ {url}
+ </span>
+ <IconButton
+ icon={Copy}
+ label="Copy link"
+ size="sm"
+ onClick={() => copyTextToClipboard(url)}
+ />
+ </div>
+ </div>
+ );
+}
diff --git a/web/src/features/topics/TopicTraceFilterSection.tsx b/web/src/features/topics/TopicTraceFilterSection.tsx
index a59d450530..719ef83fd2 100644
--- a/web/src/features/topics/TopicTraceFilterSection.tsx
+++ b/web/src/features/topics/TopicTraceFilterSection.tsx
@@ -1,5 +1,6 @@
import { useState } from "react";
import { Badge } from "@/src/components/design-system/Badge/Badge";
+import { Input } from "@/src/components/design-system/Input/Input";
import { ObservationFilterBuilder } from "@/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/components/ObservationFilterBuilder/ObservationFilterBuilder";
import { FilterModeToggle } from "@/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/components/FilterModeToggle";
import { RULE_FIELD_REGISTRY } from "@/src/features/evals/v2/constants/ruleSearchRegistry";
@@ -8,7 +9,6 @@ import {
type toObservedOptions,
useEventsSearchBar,
} from "@/src/features/search-bar";
-import { SectionHeader } from "@/src/features/evals/v2/components/Evaluators/Testing/components/SectionHeader/SectionHeader";
import type { EvaluatorFilterExperience } from "@/src/features/evals/v2/types/evaluatorFilterExperience";
import {
type experimentEvalFilterColsWithOptions,
@@ -45,11 +45,30 @@ export type TopicTraceFilterSectionProps = {
onFiltersChange?: (filters: FilterState) => void;
onSearchQueryChange?: (query: string | null) => void;
onSearchTypeChange?: (searchType: TracingSearchType[]) => void;
- description?: string;
};
-/** The trace filter, shown disabled until custom filters ship. */
-export function TopicTraceFilterSection({
+/** Custom trace filters are not available yet; the live filter stays wired for when they ship. */
+const TRACE_FILTERS_AVAILABLE = false;
+
+function ComingSoonTraceFilter() {
+ return (
+ <section className="flex flex-col gap-2">
+ <div className="flex items-center gap-1.5">
+ <h3 className="text-muted-foreground text-sm font-bold">
+ Filter traces
+ </h3>
+ <Badge text="Coming soon" color="filled" size="sm" />
+ </div>
+ <Input
+ disabled
+ aria-label="Filter traces"
+ placeholder="level:ERROR -env:dev tags:billing"
+ />
+ </section>
+ );
+}
+
+function LiveTraceFilter({
projectId,
mode: modeProp,
filters: filtersProp,
@@ -63,7 +82,6 @@ export function TopicTraceFilterSection({
onFiltersChange,
onSearchQueryChange,
onSearchTypeChange,
- description = "The sampling rate applies to all incoming traces. Custom trace filters are coming soon.",
}: TopicTraceFilterSectionProps) {
const [localMode, setLocalMode] =
useState<EvaluatorFilterExperience>("query");
@@ -96,24 +114,22 @@ export function TopicTraceFilterSection({
return (
<section className="flex flex-col gap-2">
- <SectionHeader
- title="Filter traces"
- meta={<Badge text="Coming soon" color="blue" size="sm" />}
- description={description}
- tooltip="Only traces matching this filter will be summarized. Topics always runs on whole traces."
- trailing={
- <div inert className="opacity-50">
- <FilterModeToggle
- mode={mode}
- onChange={(next) => {
- if (next === "builder" && searchQuery !== null)
- search.applyFilters(filters);
- setMode(next);
- }}
- />
- </div>
- }
- />
+ <div className="flex items-center justify-between gap-2">
+ <div className="flex min-w-0 items-center gap-1.5">
+ <h3 className="text-sm font-bold whitespace-nowrap">Filter traces</h3>
+ <Badge text="Coming soon" color="blue" size="sm" />
+ </div>
+ <div inert className="opacity-50">
+ <FilterModeToggle
+ mode={mode}
+ onChange={(next) => {
+ if (next === "builder" && searchQuery !== null)
+ search.applyFilters(filters);
+ setMode(next);
+ }}
+ />
+ </div>
+ </div>
<div inert aria-disabled className="opacity-50">
{mode === "query" ? (
<EventsSearchBarRow
@@ -140,3 +156,9 @@ export function TopicTraceFilterSection({
</section>
);
}
+
+/** The trace filter, shown as coming soon until custom filters ship. */
+export function TopicTraceFilterSection(props: TopicTraceFilterSectionProps) {
+ if (!TRACE_FILTERS_AVAILABLE) return <ComingSoonTraceFilter />;
+ return <LiveTraceFilter {...props} />;
+}