@terreno/admin-frontend 58.0.6 → 58.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -0
- package/dist/AdminNestedArrayField.d.ts.map +1 -1
- package/dist/AdminNestedArrayField.js +6 -5
- package/dist/AdminNestedArrayField.js.map +1 -1
- package/dist/AdminRolesList.d.ts +34 -1
- package/dist/AdminRolesList.d.ts.map +1 -1
- package/dist/AdminRolesList.js +53 -8
- package/dist/AdminRolesList.js.map +1 -1
- package/dist/AdminShell.d.ts.map +1 -1
- package/dist/AdminShell.js +7 -2
- package/dist/AdminShell.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/useAdminRoles.d.ts +8 -0
- package/dist/useAdminRoles.d.ts.map +1 -1
- package/dist/useAdminRoles.js +11 -0
- package/dist/useAdminRoles.js.map +1 -1
- package/dist/widgets/aiObservability/datasets/AiDatasetDetailScreen.d.ts.map +1 -1
- package/dist/widgets/aiObservability/datasets/AiDatasetDetailScreen.js +10 -36
- package/dist/widgets/aiObservability/datasets/AiDatasetDetailScreen.js.map +1 -1
- package/dist/widgets/aiObservability/datasets/AiDatasetDetailView.d.ts +4 -6
- package/dist/widgets/aiObservability/datasets/AiDatasetDetailView.d.ts.map +1 -1
- package/dist/widgets/aiObservability/datasets/AiDatasetDetailView.js +11 -64
- package/dist/widgets/aiObservability/datasets/AiDatasetDetailView.js.map +1 -1
- package/dist/widgets/aiObservability/datasets/AiDatasetItemScreen.d.ts +4 -0
- package/dist/widgets/aiObservability/datasets/AiDatasetItemScreen.d.ts.map +1 -0
- package/dist/widgets/aiObservability/datasets/AiDatasetItemScreen.js +204 -0
- package/dist/widgets/aiObservability/datasets/AiDatasetItemScreen.js.map +1 -0
- package/dist/widgets/aiObservability/datasets/AiDatasetItemView.d.ts +23 -0
- package/dist/widgets/aiObservability/datasets/AiDatasetItemView.d.ts.map +1 -0
- package/dist/widgets/aiObservability/datasets/AiDatasetItemView.js +31 -0
- package/dist/widgets/aiObservability/datasets/AiDatasetItemView.js.map +1 -0
- package/dist/widgets/aiObservability/datasets/ExpectedOutputForm.d.ts +12 -0
- package/dist/widgets/aiObservability/datasets/ExpectedOutputForm.d.ts.map +1 -0
- package/dist/widgets/aiObservability/datasets/ExpectedOutputForm.js +101 -0
- package/dist/widgets/aiObservability/datasets/ExpectedOutputForm.js.map +1 -0
- package/dist/widgets/aiObservability/datasets/datasetTypes.d.ts +5 -0
- package/dist/widgets/aiObservability/datasets/datasetTypes.d.ts.map +1 -1
- package/dist/widgets/aiObservability/datasets/datasetTypes.js +9 -0
- package/dist/widgets/aiObservability/datasets/datasetTypes.js.map +1 -1
- package/dist/widgets/aiObservability/datasets/expectedOutputModel.d.ts +44 -0
- package/dist/widgets/aiObservability/datasets/expectedOutputModel.d.ts.map +1 -0
- package/dist/widgets/aiObservability/datasets/expectedOutputModel.js +265 -0
- package/dist/widgets/aiObservability/datasets/expectedOutputModel.js.map +1 -0
- package/dist/widgets/aiObservability/datasets/useAiObservabilityDatasetsApi.d.ts +6 -0
- package/dist/widgets/aiObservability/datasets/useAiObservabilityDatasetsApi.d.ts.map +1 -1
- package/dist/widgets/aiObservability/datasets/useAiObservabilityDatasetsApi.js +8 -0
- package/dist/widgets/aiObservability/datasets/useAiObservabilityDatasetsApi.js.map +1 -1
- package/dist/widgets/aiObservability/prompts/AiPromptEditorView.d.ts.map +1 -1
- package/dist/widgets/aiObservability/prompts/AiPromptEditorView.js +5 -2
- package/dist/widgets/aiObservability/prompts/AiPromptEditorView.js.map +1 -1
- package/dist/widgets/aiObservability/prompts/AiPromptHubView.d.ts.map +1 -1
- package/dist/widgets/aiObservability/prompts/AiPromptHubView.js +4 -3
- package/dist/widgets/aiObservability/prompts/AiPromptHubView.js.map +1 -1
- package/dist/widgets/aiObservability/prompts/AiPromptsListScreen.d.ts.map +1 -1
- package/dist/widgets/aiObservability/prompts/AiPromptsListScreen.js +2 -1
- package/dist/widgets/aiObservability/prompts/AiPromptsListScreen.js.map +1 -1
- package/dist/widgets/aiObservability/prompts/AiPromptsListView.d.ts +2 -0
- package/dist/widgets/aiObservability/prompts/AiPromptsListView.d.ts.map +1 -1
- package/dist/widgets/aiObservability/prompts/AiPromptsListView.js +92 -26
- package/dist/widgets/aiObservability/prompts/AiPromptsListView.js.map +1 -1
- package/dist/widgets/aiObservability/prompts/promptTypes.d.ts +29 -5
- package/dist/widgets/aiObservability/prompts/promptTypes.d.ts.map +1 -1
- package/dist/widgets/aiObservability/prompts/promptTypes.js +114 -11
- package/dist/widgets/aiObservability/prompts/promptTypes.js.map +1 -1
- package/dist/widgets/aiObservability/shell/AiObservabilityScreenWidgets.d.ts.map +1 -1
- package/dist/widgets/aiObservability/shell/AiObservabilityScreenWidgets.js +2 -0
- package/dist/widgets/aiObservability/shell/AiObservabilityScreenWidgets.js.map +1 -1
- package/dist/widgets/aiObservability/shell/aiObservabilityNav.d.ts.map +1 -1
- package/dist/widgets/aiObservability/shell/aiObservabilityNav.js +1 -0
- package/dist/widgets/aiObservability/shell/aiObservabilityNav.js.map +1 -1
- package/dist/widgets/aiObservability/traces/AiTraceDetailView.d.ts.map +1 -1
- package/dist/widgets/aiObservability/traces/AiTraceDetailView.js +15 -1
- package/dist/widgets/aiObservability/traces/AiTraceDetailView.js.map +1 -1
- package/dist/widgets/aiObservability/traces/AiTracesListView.d.ts.map +1 -1
- package/dist/widgets/aiObservability/traces/AiTracesListView.js +20 -1
- package/dist/widgets/aiObservability/traces/AiTracesListView.js.map +1 -1
- package/dist/widgets/aiObservability/traces/traceTypes.d.ts +12 -0
- package/dist/widgets/aiObservability/traces/traceTypes.d.ts.map +1 -1
- package/dist/widgets/aiObservability/traces/traceTypes.js +33 -0
- package/dist/widgets/aiObservability/traces/traceTypes.js.map +1 -1
- package/dist/widgets/aiObservability/traces/useAiObservabilityTracesApi.d.ts.map +1 -1
- package/dist/widgets/aiObservability/traces/useAiObservabilityTracesApi.js +9 -0
- package/dist/widgets/aiObservability/traces/useAiObservabilityTracesApi.js.map +1 -1
- package/package.json +4 -4
- package/src/AdminNestedArrayField.tsx +6 -4
- package/src/AdminRolesList.test.tsx +119 -2
- package/src/AdminRolesList.tsx +171 -13
- package/src/AdminShell.test.tsx +14 -0
- package/src/AdminShell.tsx +7 -1
- package/src/index.tsx +13 -1
- package/src/isolated/AdminNestedArrayField.isolated.tsx +50 -8
- package/src/isolated/aiObservabilityDatasets.isolated.tsx +417 -67
- package/src/isolated/aiObservabilityPrompts.isolated.tsx +42 -24
- package/src/isolated/aiObservabilityTraces.isolated.tsx +2 -1
- package/src/isolated/aiTracesTable.isolated.tsx +17 -1
- package/src/useAdminRoles.test.ts +15 -1
- package/src/useAdminRoles.ts +25 -1
- package/src/widgets/aiObservability/datasets/AiDatasetDetailScreen.tsx +17 -48
- package/src/widgets/aiObservability/datasets/AiDatasetDetailView.test.tsx +40 -77
- package/src/widgets/aiObservability/datasets/AiDatasetDetailView.tsx +29 -153
- package/src/widgets/aiObservability/datasets/AiDatasetItemScreen.tsx +279 -0
- package/src/widgets/aiObservability/datasets/AiDatasetItemView.test.tsx +110 -0
- package/src/widgets/aiObservability/datasets/AiDatasetItemView.tsx +174 -0
- package/src/widgets/aiObservability/datasets/ExpectedOutputForm.test.tsx +234 -0
- package/src/widgets/aiObservability/datasets/ExpectedOutputForm.tsx +313 -0
- package/src/widgets/aiObservability/datasets/datasetTypes.test.ts +31 -0
- package/src/widgets/aiObservability/datasets/datasetTypes.ts +13 -0
- package/src/widgets/aiObservability/datasets/expectedOutputModel.test.ts +285 -0
- package/src/widgets/aiObservability/datasets/expectedOutputModel.ts +338 -0
- package/src/widgets/aiObservability/datasets/useAiObservabilityDatasetsApi.test.ts +11 -0
- package/src/widgets/aiObservability/datasets/useAiObservabilityDatasetsApi.ts +22 -0
- package/src/widgets/aiObservability/prompts/AiPromptEditorView.tsx +7 -2
- package/src/widgets/aiObservability/prompts/AiPromptHubView.tsx +10 -3
- package/src/widgets/aiObservability/prompts/AiPromptsListScreen.tsx +3 -0
- package/src/widgets/aiObservability/prompts/AiPromptsListView.test.tsx +149 -3
- package/src/widgets/aiObservability/prompts/AiPromptsListView.tsx +176 -42
- package/src/widgets/aiObservability/prompts/promptTypes.test.ts +87 -7
- package/src/widgets/aiObservability/prompts/promptTypes.ts +140 -15
- package/src/widgets/aiObservability/shell/AiObservabilityScreenWidgets.tsx +2 -0
- package/src/widgets/aiObservability/shell/aiObservabilityNav.ts +1 -0
- package/src/widgets/aiObservability/traces/AiTraceDetailView.test.tsx +107 -0
- package/src/widgets/aiObservability/traces/AiTraceDetailView.tsx +42 -7
- package/src/widgets/aiObservability/traces/AiTracesListView.tsx +20 -0
- package/src/widgets/aiObservability/traces/traceTypes.test.ts +42 -0
- package/src/widgets/aiObservability/traces/traceTypes.ts +45 -0
- package/src/widgets/aiObservability/traces/useAiObservabilityTracesApi.test.ts +38 -0
- package/src/widgets/aiObservability/traces/useAiObservabilityTracesApi.ts +9 -0
|
@@ -9,6 +9,7 @@ export interface PromptListItem {
|
|
|
9
9
|
latestVersion: number;
|
|
10
10
|
name: string;
|
|
11
11
|
production: number | "—";
|
|
12
|
+
tags?: string[];
|
|
12
13
|
type: "chat" | "text";
|
|
13
14
|
usage7d?: PromptUsage7d;
|
|
14
15
|
}
|
|
@@ -120,12 +121,120 @@ export interface PlaygroundRunResult {
|
|
|
120
121
|
tokens: {inputTokens?: number; outputTokens?: number; totalTokens?: number};
|
|
121
122
|
}
|
|
122
123
|
|
|
123
|
-
export
|
|
124
|
+
export const ALL_FOLDERS = "";
|
|
125
|
+
|
|
126
|
+
/** Split a folder or prompt name on `/`, dropping blank segments from extra slashes. */
|
|
127
|
+
export const pathSegments = (value: string): string[] => {
|
|
128
|
+
return value
|
|
129
|
+
.split("/")
|
|
130
|
+
.map((part) => part.trim())
|
|
131
|
+
.filter((part) => part.length > 0);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/** Render a slash path as nested folder segments, e.g. `appointmentAI / intake`. */
|
|
135
|
+
export const formatFolderPath = (folder: string): string => {
|
|
136
|
+
const segments = pathSegments(folder);
|
|
137
|
+
if (segments.length === 0) {
|
|
138
|
+
return folder.trim();
|
|
139
|
+
}
|
|
140
|
+
return segments.join(" / ");
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export interface PromptLocation {
|
|
144
|
+
/** Nested folder segments. A slash in `folder` or in `name` (except the last) is one level. */
|
|
145
|
+
directories: string[];
|
|
146
|
+
/** `directories` joined with `/`, or `""` when the prompt has no folder segments. */
|
|
147
|
+
directory: string;
|
|
148
|
+
/** Last segment of the name. This is the prompt, not a folder. */
|
|
149
|
+
leaf: string;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Where a prompt sits in the folder tree.
|
|
154
|
+
* Every `/` in the folder is a folder. Every `/` in the name is a folder too,
|
|
155
|
+
* except the last segment, which is the prompt itself.
|
|
156
|
+
*/
|
|
157
|
+
export const promptLocation = (prompt: Pick<PromptListItem, "folder" | "name">): PromptLocation => {
|
|
158
|
+
const folderParts = pathSegments(prompt.folder);
|
|
159
|
+
const nameParts = pathSegments(prompt.name);
|
|
160
|
+
const leaf =
|
|
161
|
+
nameParts.length > 0 ? (nameParts[nameParts.length - 1] ?? prompt.name) : prompt.name;
|
|
162
|
+
const nameParents = nameParts.slice(0, -1);
|
|
163
|
+
const folderKey = folderParts.join("/");
|
|
164
|
+
const nameParentKey = nameParents.join("/");
|
|
165
|
+
|
|
166
|
+
let directories = folderParts;
|
|
167
|
+
if (nameParents.length > 0) {
|
|
168
|
+
const nameExtendsFolder =
|
|
169
|
+
folderKey.length === 0 ||
|
|
170
|
+
nameParentKey === folderKey ||
|
|
171
|
+
nameParentKey.startsWith(`${folderKey}/`);
|
|
172
|
+
const folderExtendsName =
|
|
173
|
+
nameParentKey.length === 0 ||
|
|
174
|
+
folderKey === nameParentKey ||
|
|
175
|
+
folderKey.startsWith(`${nameParentKey}/`);
|
|
176
|
+
if (nameExtendsFolder) {
|
|
177
|
+
directories = nameParents;
|
|
178
|
+
} else if (folderExtendsName) {
|
|
179
|
+
directories = folderParts;
|
|
180
|
+
} else {
|
|
181
|
+
directories = [...folderParts, ...nameParents];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
directories,
|
|
187
|
+
directory: directories.join("/"),
|
|
188
|
+
leaf,
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export interface FolderNode {
|
|
124
193
|
count: number;
|
|
125
|
-
|
|
194
|
+
name: string;
|
|
195
|
+
path: string;
|
|
126
196
|
}
|
|
127
197
|
|
|
128
|
-
|
|
198
|
+
/** Immediate child folders under `parent` (`""` is the root), with subtree prompt counts. */
|
|
199
|
+
export const childFolders = (prompts: PromptListItem[], parent: string): FolderNode[] => {
|
|
200
|
+
const parentSegments = pathSegments(parent);
|
|
201
|
+
const counts = new Map<string, FolderNode>();
|
|
202
|
+
for (const prompt of prompts) {
|
|
203
|
+
const {directories} = promptLocation(prompt);
|
|
204
|
+
if (directories.length <= parentSegments.length) {
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const isInside = parentSegments.every((segment, index) => directories[index] === segment);
|
|
208
|
+
if (!isInside) {
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
const name = directories[parentSegments.length];
|
|
212
|
+
if (!name) {
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const path = [...parentSegments, name].join("/");
|
|
216
|
+
const current = counts.get(path);
|
|
217
|
+
counts.set(path, {
|
|
218
|
+
count: (current?.count ?? 0) + 1,
|
|
219
|
+
name,
|
|
220
|
+
path,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return [...counts.values()].sort((a, b) => a.path.localeCompare(b.path));
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
/** True when `folder` is the prompt's directory or a parent of it. `""` matches every prompt. */
|
|
227
|
+
const promptInFolder = (
|
|
228
|
+
prompt: Pick<PromptListItem, "folder" | "name">,
|
|
229
|
+
folder: string
|
|
230
|
+
): boolean => {
|
|
231
|
+
const selected = pathSegments(folder).join("/");
|
|
232
|
+
if (selected.length === 0) {
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
const directory = promptLocation(prompt).directory;
|
|
236
|
+
return directory === selected || directory.startsWith(`${selected}/`);
|
|
237
|
+
};
|
|
129
238
|
|
|
130
239
|
/**
|
|
131
240
|
* The registry tag that pulls another prompt's production body into this one.
|
|
@@ -182,16 +291,18 @@ export const unwrapPromptDetail = (raw: unknown): PromptDetail | undefined => {
|
|
|
182
291
|
return normalizePromptDetail(payload);
|
|
183
292
|
};
|
|
184
293
|
|
|
185
|
-
|
|
186
|
-
|
|
294
|
+
/** Sorted unique tags across the loaded prompts. Blank tags are dropped. */
|
|
295
|
+
export const promptTags = (prompts: PromptListItem[]): string[] => {
|
|
296
|
+
const tags = new Set<string>();
|
|
187
297
|
for (const prompt of prompts) {
|
|
188
|
-
|
|
298
|
+
for (const tag of prompt.tags ?? []) {
|
|
299
|
+
const trimmed = tag.trim();
|
|
300
|
+
if (trimmed.length > 0) {
|
|
301
|
+
tags.add(trimmed);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
189
304
|
}
|
|
190
|
-
return [...
|
|
191
|
-
.sort(([a], [b]) => {
|
|
192
|
-
return a.localeCompare(b);
|
|
193
|
-
})
|
|
194
|
-
.map(([folder, count]) => ({count, folder}));
|
|
305
|
+
return [...tags].sort((left, right) => left.localeCompare(right));
|
|
195
306
|
};
|
|
196
307
|
|
|
197
308
|
export const formatProduction = (production: number | "—"): string => {
|
|
@@ -205,22 +316,36 @@ export const filterPrompts = ({
|
|
|
205
316
|
folder,
|
|
206
317
|
prompts,
|
|
207
318
|
search,
|
|
319
|
+
tag,
|
|
208
320
|
}: {
|
|
209
321
|
folder: string;
|
|
210
322
|
prompts: PromptListItem[];
|
|
211
323
|
search: string;
|
|
324
|
+
tag?: string;
|
|
212
325
|
}): PromptListItem[] => {
|
|
213
326
|
const needle = search.trim().toLowerCase();
|
|
327
|
+
const selectedTag = tag?.trim() ?? "";
|
|
214
328
|
return prompts.filter((prompt) => {
|
|
215
|
-
if (
|
|
329
|
+
if (!promptInFolder(prompt, folder)) {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
if (selectedTag && !(prompt.tags ?? []).includes(selectedTag)) {
|
|
216
333
|
return false;
|
|
217
334
|
}
|
|
218
335
|
if (!needle) {
|
|
219
336
|
return true;
|
|
220
337
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
338
|
+
const location = promptLocation(prompt);
|
|
339
|
+
const haystack = [
|
|
340
|
+
prompt.name,
|
|
341
|
+
prompt.folder,
|
|
342
|
+
location.directory,
|
|
343
|
+
location.leaf,
|
|
344
|
+
...(prompt.tags ?? []),
|
|
345
|
+
]
|
|
346
|
+
.join("\n")
|
|
347
|
+
.toLowerCase();
|
|
348
|
+
return haystack.includes(needle);
|
|
224
349
|
});
|
|
225
350
|
};
|
|
226
351
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {ScreenWidgetComponent} from "../../../types";
|
|
2
2
|
import {AiDatasetDetailScreenWidget} from "../datasets/AiDatasetDetailScreen";
|
|
3
|
+
import {AiDatasetItemScreenWidget} from "../datasets/AiDatasetItemScreen";
|
|
3
4
|
import {AiDatasetsScreenWidget} from "../datasets/AiDatasetsListScreen";
|
|
4
5
|
import {AiEvaluatorDetailScreenWidget} from "../evaluators/AiEvaluatorDetailScreen";
|
|
5
6
|
import {AiEvaluatorNewScreenWidget} from "../evaluators/AiEvaluatorNewScreen";
|
|
@@ -29,6 +30,7 @@ export {
|
|
|
29
30
|
|
|
30
31
|
export const AI_OBSERVABILITY_WIDGETS: Record<string, ScreenWidgetComponent> = {
|
|
31
32
|
"ai-dataset-detail": AiDatasetDetailScreenWidget,
|
|
33
|
+
"ai-dataset-item": AiDatasetItemScreenWidget,
|
|
32
34
|
"ai-datasets": AiDatasetsScreenWidget,
|
|
33
35
|
"ai-evaluator-detail": AiEvaluatorDetailScreenWidget,
|
|
34
36
|
"ai-evaluator-new": AiEvaluatorNewScreenWidget,
|
|
@@ -32,6 +32,7 @@ const LIST_LEAVES = new Set(["Library", "List", "Queue"]);
|
|
|
32
32
|
|
|
33
33
|
export const AI_OBSERVABILITY_SCREENS: Record<string, AiObservabilityScreenMeta> = {
|
|
34
34
|
"ai-dataset-detail": {leaf: "Detail", section: "Datasets", title: "Dataset"},
|
|
35
|
+
"ai-dataset-item": {leaf: "Expected output", section: "Datasets", title: "Expected output"},
|
|
35
36
|
"ai-datasets": {leaf: "List", section: "Datasets", title: "Datasets"},
|
|
36
37
|
"ai-evaluator-detail": {leaf: "Detail", section: "Evaluators", title: "Evaluator"},
|
|
37
38
|
"ai-evaluator-new": {leaf: "New", section: "Evaluators", title: "New evaluator"},
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {describe, expect, it, mock} from "bun:test";
|
|
2
|
+
import {fireEvent} from "@testing-library/react-native";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import {renderWithTheme} from "../../../../../ui/src/test-utils";
|
|
5
|
+
import {AiTraceDetailView} from "./AiTraceDetailView";
|
|
6
|
+
import type {TraceDetail, TraceScore} from "./traceTypes";
|
|
7
|
+
|
|
8
|
+
const buildDetail = (scores: TraceScore[], sensitive = false): TraceDetail => ({
|
|
9
|
+
flaggedForDataset: false,
|
|
10
|
+
id: "trace-1",
|
|
11
|
+
name: "summarize",
|
|
12
|
+
prompts: [],
|
|
13
|
+
scoreCount: scores.length,
|
|
14
|
+
scores,
|
|
15
|
+
sensitive,
|
|
16
|
+
spanCount: 0,
|
|
17
|
+
spans: [],
|
|
18
|
+
startedAt: "2026-09-01T12:00:00.000Z",
|
|
19
|
+
status: "ok",
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const thumbsDown: TraceScore = {
|
|
23
|
+
comment: "Too long",
|
|
24
|
+
dataType: "boolean",
|
|
25
|
+
name: "thumbs_up",
|
|
26
|
+
source: "user-feedback",
|
|
27
|
+
value: false,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const copiedSignal: TraceScore = {
|
|
31
|
+
dataType: "boolean",
|
|
32
|
+
name: "copied",
|
|
33
|
+
source: "user-signal",
|
|
34
|
+
value: true,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const renderDetail = (detail: TraceDetail): ReturnType<typeof renderWithTheme> =>
|
|
38
|
+
renderWithTheme(<AiTraceDetailView detail={detail} onBack={mock(() => undefined)} />);
|
|
39
|
+
|
|
40
|
+
describe("AiTraceDetailView scores", () => {
|
|
41
|
+
it("shows the User badge and the comment under a user-feedback score", () => {
|
|
42
|
+
const {getByTestId, getByText} = renderDetail(buildDetail([thumbsDown]));
|
|
43
|
+
expect(getByText("User")).toBeTruthy();
|
|
44
|
+
expect(getByTestId("ai-trace-score-comment-0")).toBeTruthy();
|
|
45
|
+
expect(getByText("Too long")).toBeTruthy();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("shows the Signal badge and no comment row for a user-signal score", () => {
|
|
49
|
+
const {getByText, queryByTestId} = renderDetail(buildDetail([copiedSignal]));
|
|
50
|
+
expect(getByText("Signal")).toBeTruthy();
|
|
51
|
+
expect(queryByTestId("ai-trace-score-comment-0")).toBeNull();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("labels every score source with its badge text", () => {
|
|
55
|
+
const sources: Array<[string, string]> = [
|
|
56
|
+
["user-feedback", "User"],
|
|
57
|
+
["user-signal", "Signal"],
|
|
58
|
+
["human", "Human"],
|
|
59
|
+
["llm-judge", "Judge"],
|
|
60
|
+
["code", "Code"],
|
|
61
|
+
];
|
|
62
|
+
const scores = sources.map(([source], index) => ({
|
|
63
|
+
dataType: "boolean" as const,
|
|
64
|
+
name: `score_${index}`,
|
|
65
|
+
source,
|
|
66
|
+
value: true,
|
|
67
|
+
}));
|
|
68
|
+
const {getByText, queryByText} = renderDetail(buildDetail(scores));
|
|
69
|
+
for (const [source, label] of sources) {
|
|
70
|
+
expect(getByText(label)).toBeTruthy();
|
|
71
|
+
// The raw source string is replaced by the badge label.
|
|
72
|
+
expect(queryByText(source)).toBeNull();
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("keeps the empty message when there are no scores", () => {
|
|
77
|
+
const {getByText} = renderDetail(buildDetail([]));
|
|
78
|
+
expect(getByText("No scores on this trace.")).toBeTruthy();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("indexes comment rows by score position", () => {
|
|
82
|
+
const {getByTestId, queryByTestId, getByText} = renderDetail(
|
|
83
|
+
buildDetail([copiedSignal, {...thumbsDown, comment: "Missed the point"}])
|
|
84
|
+
);
|
|
85
|
+
expect(queryByTestId("ai-trace-score-comment-0")).toBeNull();
|
|
86
|
+
expect(getByTestId("ai-trace-score-comment-1")).toBeTruthy();
|
|
87
|
+
expect(getByText("Missed the point")).toBeTruthy();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("hides the comment on a sensitive trace until the disclosure is opened", () => {
|
|
91
|
+
const {getByTestId, queryByTestId, queryByText, getByText} = renderDetail(
|
|
92
|
+
buildDetail([thumbsDown], true)
|
|
93
|
+
);
|
|
94
|
+
expect(queryByText("Too long")).toBeNull();
|
|
95
|
+
|
|
96
|
+
// The disclosure may be an Accordion (toggle child) or a plain button; accept either.
|
|
97
|
+
const id = "ai-trace-score-comment-toggle-0";
|
|
98
|
+
fireEvent.press(queryByTestId(`${id}.toggle`) ?? getByTestId(id));
|
|
99
|
+
expect(getByText("Too long")).toBeTruthy();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("shows a non-sensitive comment without any disclosure", () => {
|
|
103
|
+
const {queryByTestId, getByText} = renderDetail(buildDetail([thumbsDown], false));
|
|
104
|
+
expect(getByText("Too long")).toBeTruthy();
|
|
105
|
+
expect(queryByTestId("ai-trace-score-comment-toggle-0")).toBeNull();
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -74,6 +74,19 @@ const SpanRow: React.FC<{
|
|
|
74
74
|
);
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
+
const SCORE_SOURCE_LABELS: Record<string, string> = {
|
|
78
|
+
code: "Code",
|
|
79
|
+
human: "Human",
|
|
80
|
+
"llm-judge": "Judge",
|
|
81
|
+
"user-feedback": "User",
|
|
82
|
+
"user-signal": "Signal",
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/** Short badge text for who wrote a score. */
|
|
86
|
+
const scoreSourceLabel = (source: string): string => {
|
|
87
|
+
return SCORE_SOURCE_LABELS[source] ?? source;
|
|
88
|
+
};
|
|
89
|
+
|
|
77
90
|
export const AiTraceDetailView: React.FC<AiTraceDetailViewProps> = ({detail, onBack}) => {
|
|
78
91
|
const flat = useMemo(() => flattenSpans(detail.spans), [detail.spans]);
|
|
79
92
|
const maxDuration = useMemo(() => {
|
|
@@ -175,13 +188,35 @@ export const AiTraceDetailView: React.FC<AiTraceDetailViewProps> = ({detail, onB
|
|
|
175
188
|
{detail.scores.length === 0 ? (
|
|
176
189
|
<Text color="secondaryDark">No scores on this trace.</Text>
|
|
177
190
|
) : (
|
|
178
|
-
detail.scores.map((score) =>
|
|
179
|
-
|
|
180
|
-
<
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
191
|
+
detail.scores.map((score, index) => {
|
|
192
|
+
const comment = score.comment ? (
|
|
193
|
+
<Box testID={`ai-trace-score-comment-${index}`}>
|
|
194
|
+
<Text size="sm">{score.comment}</Text>
|
|
195
|
+
</Box>
|
|
196
|
+
) : undefined;
|
|
197
|
+
return (
|
|
198
|
+
// Several human or code scores can share a name and source, so key by position.
|
|
199
|
+
<Box gap={1} key={`${index}-${score.name}-${score.source}`}>
|
|
200
|
+
<Box alignItems="center" direction="row" gap={2} wrap>
|
|
201
|
+
<Text bold>{score.name}</Text>
|
|
202
|
+
<Text>{String(score.value)}</Text>
|
|
203
|
+
<Badge status="neutral" value={scoreSourceLabel(score.source)} />
|
|
204
|
+
</Box>
|
|
205
|
+
{comment && detail.sensitive ? (
|
|
206
|
+
// A user's comment on a sensitive trace may hold PHI, so it starts collapsed like I/O.
|
|
207
|
+
<Accordion
|
|
208
|
+
isCollapsed
|
|
209
|
+
testID={`ai-trace-score-comment-toggle-${index}`}
|
|
210
|
+
title="Comment (sensitive)"
|
|
211
|
+
>
|
|
212
|
+
{comment}
|
|
213
|
+
</Accordion>
|
|
214
|
+
) : (
|
|
215
|
+
comment
|
|
216
|
+
)}
|
|
217
|
+
</Box>
|
|
218
|
+
);
|
|
219
|
+
})
|
|
185
220
|
)}
|
|
186
221
|
</Box>
|
|
187
222
|
</Box>
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
DEFAULT_TRACE_SORT,
|
|
24
24
|
type EvaluatorOption,
|
|
25
25
|
selectedSensitiveCount,
|
|
26
|
+
TRACE_FEEDBACK_SIGNALS,
|
|
26
27
|
TRACE_FILTER_FIELDS,
|
|
27
28
|
type TraceListItem,
|
|
28
29
|
type TraceSortKey,
|
|
@@ -60,6 +61,25 @@ const ADDITIONAL_FILTERS: DataTableColumnFilter[] = [
|
|
|
60
61
|
{field: TRACE_FILTER_FIELDS.sensitive, kind: "boolean", label: "Sensitive"},
|
|
61
62
|
{field: TRACE_FILTER_FIELDS.userId, kind: "text", label: "User"},
|
|
62
63
|
{field: TRACE_FILTER_FIELDS.sessionId, kind: "text", label: "Session"},
|
|
64
|
+
{
|
|
65
|
+
field: TRACE_FILTER_FIELDS.thumbs,
|
|
66
|
+
kind: "choice",
|
|
67
|
+
label: "Thumbs",
|
|
68
|
+
options: [
|
|
69
|
+
{label: "Up", value: "up"},
|
|
70
|
+
{label: "Down", value: "down"},
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
field: TRACE_FILTER_FIELDS.signal,
|
|
75
|
+
kind: "choice",
|
|
76
|
+
label: "Signal",
|
|
77
|
+
options: TRACE_FEEDBACK_SIGNALS.map((signal) => ({
|
|
78
|
+
label: signal.charAt(0).toUpperCase() + signal.slice(1),
|
|
79
|
+
value: signal,
|
|
80
|
+
})),
|
|
81
|
+
},
|
|
82
|
+
{field: TRACE_FILTER_FIELDS.hasComment, kind: "boolean", label: "Has comment"},
|
|
63
83
|
];
|
|
64
84
|
|
|
65
85
|
/** Two-line cells (name plus steps and user) need more than the default 54px row. */
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
promptCountLabel,
|
|
12
12
|
selectedSensitiveCount,
|
|
13
13
|
stringifyIo,
|
|
14
|
+
TRACE_FILTER_FIELDS,
|
|
14
15
|
type TraceListItem,
|
|
15
16
|
type TraceSpanNode,
|
|
16
17
|
traceFiltersToFilterValues,
|
|
@@ -173,4 +174,45 @@ describe("traceTypes helpers", () => {
|
|
|
173
174
|
assert.equal(filterValuesToTraceFilters({status: ["ok", "bogus"]}).status, "ok");
|
|
174
175
|
assert.equal(filterValuesToTraceFilters({hasScore: "false"}).hasScore, false);
|
|
175
176
|
});
|
|
177
|
+
|
|
178
|
+
it("exposes the feedback filter fields", () => {
|
|
179
|
+
expect(TRACE_FILTER_FIELDS.thumbs).toBe("thumbs");
|
|
180
|
+
expect(TRACE_FILTER_FIELDS.signal).toBe("signal");
|
|
181
|
+
expect(TRACE_FILTER_FIELDS.hasComment).toBe("hasComment");
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it("reads thumbs, signal, and hasComment from DataTable filter values", () => {
|
|
185
|
+
const filters = filterValuesToTraceFilters({
|
|
186
|
+
hasComment: true,
|
|
187
|
+
signal: ["dismissed"],
|
|
188
|
+
thumbs: ["down"],
|
|
189
|
+
});
|
|
190
|
+
expect(filters.thumbs).toBe("down");
|
|
191
|
+
expect(filters.signal).toBe("dismissed");
|
|
192
|
+
expect(filters.hasComment).toBe(true);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it("leaves feedback filters unset for Any and ignores unknown values", () => {
|
|
196
|
+
const any = filterValuesToTraceFilters({signal: [], thumbs: []});
|
|
197
|
+
expect(any.thumbs).toBeUndefined();
|
|
198
|
+
expect(any.signal).toBeUndefined();
|
|
199
|
+
expect(any.hasComment).toBeUndefined();
|
|
200
|
+
expect(filterValuesToTraceFilters({thumbs: ["up"]}).thumbs).toBe("up");
|
|
201
|
+
const bogus = filterValuesToTraceFilters({signal: ["nope"], thumbs: ["sideways"]});
|
|
202
|
+
expect(bogus.thumbs).toBeUndefined();
|
|
203
|
+
expect(bogus.signal).toBeUndefined();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it("round-trips feedback filters through the DataTable filter values", () => {
|
|
207
|
+
const filters = {
|
|
208
|
+
...emptyTraceFilters(),
|
|
209
|
+
hasComment: false,
|
|
210
|
+
signal: "copied" as const,
|
|
211
|
+
thumbs: "up" as const,
|
|
212
|
+
};
|
|
213
|
+
const roundTripped = filterValuesToTraceFilters(traceFiltersToFilterValues(filters));
|
|
214
|
+
expect(roundTripped.thumbs).toBe("up");
|
|
215
|
+
expect(roundTripped.signal).toBe("copied");
|
|
216
|
+
expect(roundTripped.hasComment).toBe(false);
|
|
217
|
+
});
|
|
176
218
|
});
|
|
@@ -72,15 +72,31 @@ export interface TraceListResponse {
|
|
|
72
72
|
total: number;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/** Passive feedback signals the backend records as `user-signal` scores. */
|
|
76
|
+
export const TRACE_FEEDBACK_SIGNALS = [
|
|
77
|
+
"accepted",
|
|
78
|
+
"dismissed",
|
|
79
|
+
"copied",
|
|
80
|
+
"edited",
|
|
81
|
+
"regenerated",
|
|
82
|
+
] as const;
|
|
83
|
+
export type TraceFeedbackSignal = (typeof TRACE_FEEDBACK_SIGNALS)[number];
|
|
84
|
+
|
|
75
85
|
export interface TraceListFilters {
|
|
76
86
|
flaggedForDataset?: boolean;
|
|
77
87
|
from: string;
|
|
88
|
+
/** Traces with (or without) an end-user comment. */
|
|
89
|
+
hasComment?: boolean;
|
|
78
90
|
hasScore?: boolean;
|
|
79
91
|
/** Prompt names; a trace matches when it used any of them. */
|
|
80
92
|
prompts: string[];
|
|
81
93
|
sensitive?: boolean;
|
|
82
94
|
sessionId: string;
|
|
95
|
+
/** A passive signal the user sent, e.g. `dismissed`. */
|
|
96
|
+
signal?: TraceFeedbackSignal;
|
|
83
97
|
status: "" | "error" | "ok";
|
|
98
|
+
/** End-user thumbs direction. */
|
|
99
|
+
thumbs?: "down" | "up";
|
|
84
100
|
to: string;
|
|
85
101
|
userId: string;
|
|
86
102
|
}
|
|
@@ -114,12 +130,15 @@ export const DEFAULT_TRACE_SORT = "-startedAt";
|
|
|
114
130
|
|
|
115
131
|
/** DataTable filter field keys used by the Traces screen. */
|
|
116
132
|
export const TRACE_FILTER_FIELDS = {
|
|
133
|
+
hasComment: "hasComment",
|
|
117
134
|
hasScore: "hasScore",
|
|
118
135
|
prompt: "prompt",
|
|
119
136
|
sensitive: "sensitive",
|
|
120
137
|
sessionId: "sessionId",
|
|
138
|
+
signal: "signal",
|
|
121
139
|
startedAt: "startedAt",
|
|
122
140
|
status: "status",
|
|
141
|
+
thumbs: "thumbs",
|
|
123
142
|
userId: "userId",
|
|
124
143
|
} as const;
|
|
125
144
|
|
|
@@ -178,6 +197,15 @@ export const traceFiltersToFilterValues = (filters: TraceListFilters): Record<st
|
|
|
178
197
|
if (filters.hasScore !== undefined) {
|
|
179
198
|
values[fields.hasScore] = filters.hasScore;
|
|
180
199
|
}
|
|
200
|
+
if (filters.thumbs) {
|
|
201
|
+
values[fields.thumbs] = [filters.thumbs];
|
|
202
|
+
}
|
|
203
|
+
if (filters.signal) {
|
|
204
|
+
values[fields.signal] = [filters.signal];
|
|
205
|
+
}
|
|
206
|
+
if (filters.hasComment !== undefined) {
|
|
207
|
+
values[fields.hasComment] = filters.hasComment;
|
|
208
|
+
}
|
|
181
209
|
if (filters.userId) {
|
|
182
210
|
values[fields.userId] = filters.userId;
|
|
183
211
|
}
|
|
@@ -215,6 +243,23 @@ export const filterValuesToTraceFilters = (
|
|
|
215
243
|
if (hasScore !== undefined) {
|
|
216
244
|
filters.hasScore = hasScore;
|
|
217
245
|
}
|
|
246
|
+
// Choice filters: one picked value narrows; none (Any) or several means no filter.
|
|
247
|
+
const thumbs = stringList(values[fields.thumbs]).filter(
|
|
248
|
+
(entry): entry is "down" | "up" => entry === "down" || entry === "up"
|
|
249
|
+
);
|
|
250
|
+
if (thumbs.length === 1) {
|
|
251
|
+
filters.thumbs = thumbs[0];
|
|
252
|
+
}
|
|
253
|
+
const signals = stringList(values[fields.signal]).filter((entry): entry is TraceFeedbackSignal =>
|
|
254
|
+
(TRACE_FEEDBACK_SIGNALS as readonly string[]).includes(entry)
|
|
255
|
+
);
|
|
256
|
+
if (signals.length === 1) {
|
|
257
|
+
filters.signal = signals[0];
|
|
258
|
+
}
|
|
259
|
+
const hasComment = optionalBoolean(values[fields.hasComment]);
|
|
260
|
+
if (hasComment !== undefined) {
|
|
261
|
+
filters.hasComment = hasComment;
|
|
262
|
+
}
|
|
218
263
|
if (previous?.flaggedForDataset !== undefined) {
|
|
219
264
|
filters.flaggedForDataset = previous.flaggedForDataset;
|
|
220
265
|
}
|
|
@@ -70,6 +70,44 @@ describe("useAiObservabilityTracesApi", () => {
|
|
|
70
70
|
expect(result.current.data).toEqual({data: [], limit: 20, more: false, page: 1, total: 0});
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
+
it("sends thumbs, signal, and hasComment and omits them when unset (Any)", async () => {
|
|
74
|
+
const calls = stub();
|
|
75
|
+
renderHook(
|
|
76
|
+
() =>
|
|
77
|
+
useAiObservabilityTracesApi().useListQuery({
|
|
78
|
+
...emptyTraceFilters(),
|
|
79
|
+
hasComment: true,
|
|
80
|
+
signal: "dismissed",
|
|
81
|
+
thumbs: "down",
|
|
82
|
+
}),
|
|
83
|
+
{wrapper: ObservabilityTestProvider}
|
|
84
|
+
);
|
|
85
|
+
renderHook(() => useAiObservabilityTracesApi().useListQuery(emptyTraceFilters()), {
|
|
86
|
+
wrapper: ObservabilityTestProvider,
|
|
87
|
+
});
|
|
88
|
+
await flushObservabilityRequests();
|
|
89
|
+
|
|
90
|
+
const withFeedback = new URL(calls[0]?.url ?? "", "http://localhost");
|
|
91
|
+
expect(withFeedback.searchParams.get("thumbs")).toBe("down");
|
|
92
|
+
expect(withFeedback.searchParams.get("signal")).toBe("dismissed");
|
|
93
|
+
expect(withFeedback.searchParams.get("hasComment")).toBe("true");
|
|
94
|
+
const any = new URL(calls[1]?.url ?? "", "http://localhost");
|
|
95
|
+
expect(any.searchParams.has("thumbs")).toBe(false);
|
|
96
|
+
expect(any.searchParams.has("signal")).toBe(false);
|
|
97
|
+
expect(any.searchParams.has("hasComment")).toBe(false);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("sends hasComment=false when the filter is explicitly false", async () => {
|
|
101
|
+
const calls = stub();
|
|
102
|
+
renderHook(
|
|
103
|
+
() => useAiObservabilityTracesApi().useListQuery({...emptyTraceFilters(), hasComment: false}),
|
|
104
|
+
{wrapper: ObservabilityTestProvider}
|
|
105
|
+
);
|
|
106
|
+
await flushObservabilityRequests();
|
|
107
|
+
const url = new URL(calls[0]?.url ?? "", "http://localhost");
|
|
108
|
+
expect(url.searchParams.get("hasComment")).toBe("false");
|
|
109
|
+
});
|
|
110
|
+
|
|
73
111
|
it("repeats prompt for each selected prompt and drops blank ones", async () => {
|
|
74
112
|
const calls = stub();
|
|
75
113
|
renderHook(
|
|
@@ -75,6 +75,15 @@ const listParams = (args: TraceListQueryArgs): Record<string, unknown> => {
|
|
|
75
75
|
if (args.sensitive !== undefined) {
|
|
76
76
|
params.sensitive = args.sensitive;
|
|
77
77
|
}
|
|
78
|
+
if (args.thumbs) {
|
|
79
|
+
params.thumbs = args.thumbs;
|
|
80
|
+
}
|
|
81
|
+
if (args.signal) {
|
|
82
|
+
params.signal = args.signal;
|
|
83
|
+
}
|
|
84
|
+
if (args.hasComment !== undefined) {
|
|
85
|
+
params.hasComment = args.hasComment;
|
|
86
|
+
}
|
|
78
87
|
return params;
|
|
79
88
|
};
|
|
80
89
|
|