Skip to content

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

feat(topics): show facet descriptions in Configure Topics (#18753)

Lysander Kieselc900b110501e
diff --git a/web/src/features/topics/ConfigureTopicsDialog.stories.tsx b/web/src/features/topics/ConfigureTopicsDialog.stories.tsx
index 4e89151811..5205348b64 100644
--- a/web/src/features/topics/ConfigureTopicsDialog.stories.tsx
+++ b/web/src/features/topics/ConfigureTopicsDialog.stories.tsx
@@ -20,6 +20,7 @@ const builtInFacets = [
{
id: "intent",
name: "Intent",
+ description: "What the run was asked to do.",
question: "What is the user trying to do?",
builtIn: true,
enabled: true,
@@ -27,6 +28,7 @@ const builtInFacets = [
{
id: "outcome",
name: "Outcome",
+ description: "Where the run ended and whether that is confirmed.",
question: "Did the assistant resolve the request?",
builtIn: true,
enabled: true,
diff --git a/web/src/features/topics/ConfigureTopicsDialog.tsx b/web/src/features/topics/ConfigureTopicsDialog.tsx
index d917ddb32b..9cc35d3dcf 100644
--- a/web/src/features/topics/ConfigureTopicsDialog.tsx
+++ b/web/src/features/topics/ConfigureTopicsDialog.tsx
@@ -45,6 +45,7 @@ import { relativeTopicTimeRange } from "./time-range";
type FacetDraft = {
id: string;
name: string;
+ description?: string;
question: string;
builtIn: boolean;
enabled: boolean;
@@ -528,6 +529,11 @@ function FacetPicker({
</div>
{browsed ? (
<div className="flex flex-col gap-2">
+ {browsed.description && (
+ <p className="text-muted-foreground text-sm break-words">
+ {browsed.description}
+ </p>
+ )}
<div className="bg-muted/50 max-h-48 overflow-y-auto rounded-md border px-3 py-2 text-sm leading-5 break-words whitespace-pre-wrap">
{browsed.question}
</div>
diff --git a/web/src/features/topics/ConfigureTopicsDialogController.tsx b/web/src/features/topics/ConfigureTopicsDialogController.tsx
index c570e60d42..1f9c0caffc 100644
--- a/web/src/features/topics/ConfigureTopicsDialogController.tsx
+++ b/web/src/features/topics/ConfigureTopicsDialogController.tsx
@@ -390,12 +390,17 @@ function facetDrafts(
facets: TopicFacet[],
enabledIds: ReadonlySet<string> | null,
) {
- const byName = new Map(facets.map((facet) => [facet.name, facet]));
+ const builtInsByName = new Map(
+ facets
+ .filter((facet) => facet.isBuiltIn)
+ .map((facet) => [facet.name, facet]),
+ );
const builtIn = DEFAULT_TOPIC_FACETS.map((preset) => {
- const existing = byName.get(preset.name);
+ const existing = builtInsByName.get(preset.name);
return {
id: existing?.id ?? preset.name,
name: preset.name,
+ description: existing?.description || preset.description,
question: existing?.versions[0]?.prompt ?? preset.prompt,
builtIn: true,
enabled: enabledIds
@@ -411,6 +416,7 @@ function facetDrafts(
{
id: facet.id,
name: facet.name,
+ description: facet.description,
question,
builtIn: false,
enabled: enabledIds?.has(facet.id) ?? false,
@@ -419,3 +425,5 @@ function facetDrafts(
});
return [...builtIn, ...custom];
}
+
+export const __test = { facetDrafts };
diff --git a/web/src/features/topics/TopicModelSettings.clienttest.ts b/web/src/features/topics/TopicModelSettings.clienttest.ts
new file mode 100644
index 0000000000..dc57a710ba
--- /dev/null
+++ b/web/src/features/topics/TopicModelSettings.clienttest.ts
@@ -0,0 +1,96 @@
+import { DEFAULT_TOPIC_FACETS, type TopicFacet } from "@langfuse/shared/topics";
+import { describe, expect, it } from "vitest";
+import { __test } from "./ConfigureTopicsDialogController";
+
+const intentPreset = DEFAULT_TOPIC_FACETS.find(
+ (facet) => facet.name === "Intent",
+);
+if (!intentPreset) throw new Error("Intent preset missing");
+
+function facet(input: {
+ id: string;
+ name: string;
+ isBuiltIn: boolean;
+ description?: string;
+ prompt: string;
+}): TopicFacet {
+ return {
+ id: input.id,
+ projectId: "project",
+ name: input.name,
+ description: input.description ?? "",
+ isBuiltIn: input.isBuiltIn,
+ versions: [
+ {
+ projectId: "project",
+ facetId: input.id,
+ version: 1,
+ prompt: input.prompt,
+ createdAt: "2026-01-01T00:00:00.000Z",
+ },
+ ],
+ };
+}
+
+describe("facetDrafts", () => {
+ it("keeps a built-in facet when a custom facet reuses its name", () => {
+ const drafts = __test.facetDrafts(
+ [
+ facet({
+ id: "built-in-intent",
+ name: "Intent",
+ isBuiltIn: true,
+ description: "Stored built-in description.",
+ prompt: "Built-in question",
+ }),
+ facet({
+ id: "custom-intent",
+ name: "Intent",
+ isBuiltIn: false,
+ description: "Custom description.",
+ prompt: "Custom question",
+ }),
+ ],
+ new Set(["built-in-intent"]),
+ );
+
+ expect(
+ drafts.find((draft) => draft.builtIn && draft.name === "Intent"),
+ ).toMatchObject({
+ id: "built-in-intent",
+ description: "Stored built-in description.",
+ question: "Built-in question",
+ enabled: true,
+ });
+ expect(drafts.filter((draft) => draft.id === "custom-intent")).toEqual([
+ expect.objectContaining({
+ name: "Intent",
+ description: "Custom description.",
+ question: "Custom question",
+ builtIn: false,
+ enabled: false,
+ }),
+ ]);
+ });
+
+ it("uses the preset description when a built-in has none stored", () => {
+ const drafts = __test.facetDrafts(
+ [
+ facet({
+ id: "built-in-intent",
+ name: "Intent",
+ isBuiltIn: true,
+ description: "",
+ prompt: "Built-in question",
+ }),
+ ],
+ null,
+ );
+
+ expect(drafts.find((draft) => draft.name === "Intent")).toMatchObject({
+ id: "built-in-intent",
+ description: intentPreset.description,
+ question: "Built-in question",
+ });
+ });
+});