@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.
Files changed (130) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/AdminNestedArrayField.d.ts.map +1 -1
  3. package/dist/AdminNestedArrayField.js +6 -5
  4. package/dist/AdminNestedArrayField.js.map +1 -1
  5. package/dist/AdminRolesList.d.ts +34 -1
  6. package/dist/AdminRolesList.d.ts.map +1 -1
  7. package/dist/AdminRolesList.js +53 -8
  8. package/dist/AdminRolesList.js.map +1 -1
  9. package/dist/AdminShell.d.ts.map +1 -1
  10. package/dist/AdminShell.js +7 -2
  11. package/dist/AdminShell.js.map +1 -1
  12. package/dist/index.d.ts +2 -1
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +2 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/useAdminRoles.d.ts +8 -0
  17. package/dist/useAdminRoles.d.ts.map +1 -1
  18. package/dist/useAdminRoles.js +11 -0
  19. package/dist/useAdminRoles.js.map +1 -1
  20. package/dist/widgets/aiObservability/datasets/AiDatasetDetailScreen.d.ts.map +1 -1
  21. package/dist/widgets/aiObservability/datasets/AiDatasetDetailScreen.js +10 -36
  22. package/dist/widgets/aiObservability/datasets/AiDatasetDetailScreen.js.map +1 -1
  23. package/dist/widgets/aiObservability/datasets/AiDatasetDetailView.d.ts +4 -6
  24. package/dist/widgets/aiObservability/datasets/AiDatasetDetailView.d.ts.map +1 -1
  25. package/dist/widgets/aiObservability/datasets/AiDatasetDetailView.js +11 -64
  26. package/dist/widgets/aiObservability/datasets/AiDatasetDetailView.js.map +1 -1
  27. package/dist/widgets/aiObservability/datasets/AiDatasetItemScreen.d.ts +4 -0
  28. package/dist/widgets/aiObservability/datasets/AiDatasetItemScreen.d.ts.map +1 -0
  29. package/dist/widgets/aiObservability/datasets/AiDatasetItemScreen.js +204 -0
  30. package/dist/widgets/aiObservability/datasets/AiDatasetItemScreen.js.map +1 -0
  31. package/dist/widgets/aiObservability/datasets/AiDatasetItemView.d.ts +23 -0
  32. package/dist/widgets/aiObservability/datasets/AiDatasetItemView.d.ts.map +1 -0
  33. package/dist/widgets/aiObservability/datasets/AiDatasetItemView.js +31 -0
  34. package/dist/widgets/aiObservability/datasets/AiDatasetItemView.js.map +1 -0
  35. package/dist/widgets/aiObservability/datasets/ExpectedOutputForm.d.ts +12 -0
  36. package/dist/widgets/aiObservability/datasets/ExpectedOutputForm.d.ts.map +1 -0
  37. package/dist/widgets/aiObservability/datasets/ExpectedOutputForm.js +101 -0
  38. package/dist/widgets/aiObservability/datasets/ExpectedOutputForm.js.map +1 -0
  39. package/dist/widgets/aiObservability/datasets/datasetTypes.d.ts +5 -0
  40. package/dist/widgets/aiObservability/datasets/datasetTypes.d.ts.map +1 -1
  41. package/dist/widgets/aiObservability/datasets/datasetTypes.js +9 -0
  42. package/dist/widgets/aiObservability/datasets/datasetTypes.js.map +1 -1
  43. package/dist/widgets/aiObservability/datasets/expectedOutputModel.d.ts +44 -0
  44. package/dist/widgets/aiObservability/datasets/expectedOutputModel.d.ts.map +1 -0
  45. package/dist/widgets/aiObservability/datasets/expectedOutputModel.js +265 -0
  46. package/dist/widgets/aiObservability/datasets/expectedOutputModel.js.map +1 -0
  47. package/dist/widgets/aiObservability/datasets/useAiObservabilityDatasetsApi.d.ts +6 -0
  48. package/dist/widgets/aiObservability/datasets/useAiObservabilityDatasetsApi.d.ts.map +1 -1
  49. package/dist/widgets/aiObservability/datasets/useAiObservabilityDatasetsApi.js +8 -0
  50. package/dist/widgets/aiObservability/datasets/useAiObservabilityDatasetsApi.js.map +1 -1
  51. package/dist/widgets/aiObservability/prompts/AiPromptEditorView.d.ts.map +1 -1
  52. package/dist/widgets/aiObservability/prompts/AiPromptEditorView.js +5 -2
  53. package/dist/widgets/aiObservability/prompts/AiPromptEditorView.js.map +1 -1
  54. package/dist/widgets/aiObservability/prompts/AiPromptHubView.d.ts.map +1 -1
  55. package/dist/widgets/aiObservability/prompts/AiPromptHubView.js +4 -3
  56. package/dist/widgets/aiObservability/prompts/AiPromptHubView.js.map +1 -1
  57. package/dist/widgets/aiObservability/prompts/AiPromptsListScreen.d.ts.map +1 -1
  58. package/dist/widgets/aiObservability/prompts/AiPromptsListScreen.js +2 -1
  59. package/dist/widgets/aiObservability/prompts/AiPromptsListScreen.js.map +1 -1
  60. package/dist/widgets/aiObservability/prompts/AiPromptsListView.d.ts +2 -0
  61. package/dist/widgets/aiObservability/prompts/AiPromptsListView.d.ts.map +1 -1
  62. package/dist/widgets/aiObservability/prompts/AiPromptsListView.js +92 -26
  63. package/dist/widgets/aiObservability/prompts/AiPromptsListView.js.map +1 -1
  64. package/dist/widgets/aiObservability/prompts/promptTypes.d.ts +29 -5
  65. package/dist/widgets/aiObservability/prompts/promptTypes.d.ts.map +1 -1
  66. package/dist/widgets/aiObservability/prompts/promptTypes.js +114 -11
  67. package/dist/widgets/aiObservability/prompts/promptTypes.js.map +1 -1
  68. package/dist/widgets/aiObservability/shell/AiObservabilityScreenWidgets.d.ts.map +1 -1
  69. package/dist/widgets/aiObservability/shell/AiObservabilityScreenWidgets.js +2 -0
  70. package/dist/widgets/aiObservability/shell/AiObservabilityScreenWidgets.js.map +1 -1
  71. package/dist/widgets/aiObservability/shell/aiObservabilityNav.d.ts.map +1 -1
  72. package/dist/widgets/aiObservability/shell/aiObservabilityNav.js +1 -0
  73. package/dist/widgets/aiObservability/shell/aiObservabilityNav.js.map +1 -1
  74. package/dist/widgets/aiObservability/traces/AiTraceDetailView.d.ts.map +1 -1
  75. package/dist/widgets/aiObservability/traces/AiTraceDetailView.js +15 -1
  76. package/dist/widgets/aiObservability/traces/AiTraceDetailView.js.map +1 -1
  77. package/dist/widgets/aiObservability/traces/AiTracesListView.d.ts.map +1 -1
  78. package/dist/widgets/aiObservability/traces/AiTracesListView.js +20 -1
  79. package/dist/widgets/aiObservability/traces/AiTracesListView.js.map +1 -1
  80. package/dist/widgets/aiObservability/traces/traceTypes.d.ts +12 -0
  81. package/dist/widgets/aiObservability/traces/traceTypes.d.ts.map +1 -1
  82. package/dist/widgets/aiObservability/traces/traceTypes.js +33 -0
  83. package/dist/widgets/aiObservability/traces/traceTypes.js.map +1 -1
  84. package/dist/widgets/aiObservability/traces/useAiObservabilityTracesApi.d.ts.map +1 -1
  85. package/dist/widgets/aiObservability/traces/useAiObservabilityTracesApi.js +9 -0
  86. package/dist/widgets/aiObservability/traces/useAiObservabilityTracesApi.js.map +1 -1
  87. package/package.json +4 -4
  88. package/src/AdminNestedArrayField.tsx +6 -4
  89. package/src/AdminRolesList.test.tsx +119 -2
  90. package/src/AdminRolesList.tsx +171 -13
  91. package/src/AdminShell.test.tsx +14 -0
  92. package/src/AdminShell.tsx +7 -1
  93. package/src/index.tsx +13 -1
  94. package/src/isolated/AdminNestedArrayField.isolated.tsx +50 -8
  95. package/src/isolated/aiObservabilityDatasets.isolated.tsx +417 -67
  96. package/src/isolated/aiObservabilityPrompts.isolated.tsx +42 -24
  97. package/src/isolated/aiObservabilityTraces.isolated.tsx +2 -1
  98. package/src/isolated/aiTracesTable.isolated.tsx +17 -1
  99. package/src/useAdminRoles.test.ts +15 -1
  100. package/src/useAdminRoles.ts +25 -1
  101. package/src/widgets/aiObservability/datasets/AiDatasetDetailScreen.tsx +17 -48
  102. package/src/widgets/aiObservability/datasets/AiDatasetDetailView.test.tsx +40 -77
  103. package/src/widgets/aiObservability/datasets/AiDatasetDetailView.tsx +29 -153
  104. package/src/widgets/aiObservability/datasets/AiDatasetItemScreen.tsx +279 -0
  105. package/src/widgets/aiObservability/datasets/AiDatasetItemView.test.tsx +110 -0
  106. package/src/widgets/aiObservability/datasets/AiDatasetItemView.tsx +174 -0
  107. package/src/widgets/aiObservability/datasets/ExpectedOutputForm.test.tsx +234 -0
  108. package/src/widgets/aiObservability/datasets/ExpectedOutputForm.tsx +313 -0
  109. package/src/widgets/aiObservability/datasets/datasetTypes.test.ts +31 -0
  110. package/src/widgets/aiObservability/datasets/datasetTypes.ts +13 -0
  111. package/src/widgets/aiObservability/datasets/expectedOutputModel.test.ts +285 -0
  112. package/src/widgets/aiObservability/datasets/expectedOutputModel.ts +338 -0
  113. package/src/widgets/aiObservability/datasets/useAiObservabilityDatasetsApi.test.ts +11 -0
  114. package/src/widgets/aiObservability/datasets/useAiObservabilityDatasetsApi.ts +22 -0
  115. package/src/widgets/aiObservability/prompts/AiPromptEditorView.tsx +7 -2
  116. package/src/widgets/aiObservability/prompts/AiPromptHubView.tsx +10 -3
  117. package/src/widgets/aiObservability/prompts/AiPromptsListScreen.tsx +3 -0
  118. package/src/widgets/aiObservability/prompts/AiPromptsListView.test.tsx +149 -3
  119. package/src/widgets/aiObservability/prompts/AiPromptsListView.tsx +176 -42
  120. package/src/widgets/aiObservability/prompts/promptTypes.test.ts +87 -7
  121. package/src/widgets/aiObservability/prompts/promptTypes.ts +140 -15
  122. package/src/widgets/aiObservability/shell/AiObservabilityScreenWidgets.tsx +2 -0
  123. package/src/widgets/aiObservability/shell/aiObservabilityNav.ts +1 -0
  124. package/src/widgets/aiObservability/traces/AiTraceDetailView.test.tsx +107 -0
  125. package/src/widgets/aiObservability/traces/AiTraceDetailView.tsx +42 -7
  126. package/src/widgets/aiObservability/traces/AiTracesListView.tsx +20 -0
  127. package/src/widgets/aiObservability/traces/traceTypes.test.ts +42 -0
  128. package/src/widgets/aiObservability/traces/traceTypes.ts +45 -0
  129. package/src/widgets/aiObservability/traces/useAiObservabilityTracesApi.test.ts +38 -0
  130. package/src/widgets/aiObservability/traces/useAiObservabilityTracesApi.ts +9 -0
@@ -0,0 +1,338 @@
1
+ /** One step into a JSON value: an object key or an array index. */
2
+ export type ValuePath = Array<string | number>;
3
+
4
+ /** The subset of JSON Schema the dataset expected-output form understands. */
5
+ export interface JsonSchema {
6
+ description?: string;
7
+ enum?: unknown[];
8
+ items?: JsonSchema;
9
+ properties?: Record<string, JsonSchema>;
10
+ required?: string[];
11
+ title?: string;
12
+ type?: string | string[];
13
+ }
14
+
15
+ export interface FormFieldNode {
16
+ description?: string;
17
+ enumValues?: string[];
18
+ kind: "boolean" | "number" | "text";
19
+ label: string;
20
+ multiline: boolean;
21
+ path: ValuePath;
22
+ type: "field";
23
+ }
24
+
25
+ export interface FormGroupNode {
26
+ children: FormNode[];
27
+ /** Schema for one new list entry, when this node is a list. */
28
+ itemSchema?: JsonSchema;
29
+ path: ValuePath;
30
+ title?: string;
31
+ type: "group" | "list";
32
+ }
33
+
34
+ export type FormNode = FormFieldNode | FormGroupNode;
35
+
36
+ const schemaTypeName = (schema?: JsonSchema): string | undefined => {
37
+ if (!schema?.type) {
38
+ return undefined;
39
+ }
40
+ if (Array.isArray(schema.type)) {
41
+ return schema.type.find((entry) => entry !== "null");
42
+ }
43
+ return schema.type;
44
+ };
45
+
46
+ /** "privacyLeak" and "privacy_leak" both read as "Privacy Leak". */
47
+ const labelFromKey = (key: string, schema?: JsonSchema): string => {
48
+ if (schema?.title && schema.title.trim().length > 0) {
49
+ return schema.title.trim();
50
+ }
51
+ const spaced = key
52
+ .replace(/[_-]+/g, " ")
53
+ .replace(/([a-z0-9])([A-Z])/g, "$1 $2")
54
+ .trim();
55
+ if (spaced.length === 0) {
56
+ return key;
57
+ }
58
+ return spaced.charAt(0).toUpperCase() + spaced.slice(1);
59
+ };
60
+
61
+ const isRecord = (value: unknown): value is Record<string, unknown> => {
62
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
63
+ };
64
+
65
+ export const readPath = (root: unknown, path: ValuePath): unknown => {
66
+ let current = root;
67
+ for (const segment of path) {
68
+ if (!isRecord(current) && !Array.isArray(current)) {
69
+ return undefined;
70
+ }
71
+ current = (current as Record<string | number, unknown>)[segment];
72
+ }
73
+ return current;
74
+ };
75
+
76
+ /** Returns a new value with `path` set to `next`. An empty path replaces the root. */
77
+ export const setAtPath = (root: unknown, path: ValuePath, next: unknown): unknown => {
78
+ if (path.length === 0) {
79
+ return next;
80
+ }
81
+ const [head, ...rest] = path;
82
+ if (typeof head === "number") {
83
+ const list = Array.isArray(root) ? [...root] : [];
84
+ list[head] = setAtPath(list[head], rest, next);
85
+ return list;
86
+ }
87
+ const record = isRecord(root) ? {...root} : {};
88
+ record[head] = setAtPath(record[head], rest, next);
89
+ return record;
90
+ };
91
+
92
+ /** Drops one array entry. `path` points at the array. */
93
+ export const removeAtIndex = (root: unknown, path: ValuePath, index: number): unknown => {
94
+ const current = readPath(root, path);
95
+ const list = Array.isArray(current) ? current.filter((_, itemIndex) => itemIndex !== index) : [];
96
+ return setAtPath(root, path, list);
97
+ };
98
+
99
+ const enumValues = (schema?: JsonSchema): string[] | undefined => {
100
+ if (!schema?.enum || schema.enum.length === 0) {
101
+ return undefined;
102
+ }
103
+ return schema.enum.map((entry) => String(entry));
104
+ };
105
+
106
+ /** A blank value that matches the schema, used for a new golden row or a new list entry. */
107
+ const blankFromSchema = (schema?: JsonSchema): unknown => {
108
+ const kind = schemaTypeName(schema);
109
+ if (schema?.properties || kind === "object") {
110
+ const record: Record<string, unknown> = {};
111
+ for (const [key, child] of Object.entries(schema?.properties ?? {})) {
112
+ record[key] = blankFromSchema(child);
113
+ }
114
+ return record;
115
+ }
116
+ if (kind === "array") {
117
+ return [];
118
+ }
119
+ if (kind === "boolean") {
120
+ return false;
121
+ }
122
+ if (kind === "number" || kind === "integer") {
123
+ return null;
124
+ }
125
+ return "";
126
+ };
127
+
128
+ /**
129
+ * Fills missing schema fields without overwriting a value that is already there.
130
+ * A value whose type does not match the schema is replaced by the blank schema shape.
131
+ */
132
+ const mergeWithSchema = (schema: JsonSchema | undefined, value: unknown): unknown => {
133
+ if (!schema) {
134
+ return value;
135
+ }
136
+ const kind = schemaTypeName(schema);
137
+ if (schema.properties || kind === "object") {
138
+ const source = isRecord(value) ? value : {};
139
+ const record: Record<string, unknown> = {...source};
140
+ for (const [key, child] of Object.entries(schema.properties ?? {})) {
141
+ record[key] = mergeWithSchema(child, source[key]);
142
+ }
143
+ return record;
144
+ }
145
+ if (kind === "array") {
146
+ if (!Array.isArray(value)) {
147
+ return [];
148
+ }
149
+ return value.map((entry) => mergeWithSchema(schema.items, entry));
150
+ }
151
+ if (kind === "boolean") {
152
+ return typeof value === "boolean" ? value : false;
153
+ }
154
+ if (kind === "number" || kind === "integer") {
155
+ return typeof value === "number" ? value : null;
156
+ }
157
+ if (enumValues(schema)) {
158
+ return typeof value === "string" ? value : "";
159
+ }
160
+ if (kind === "string" && (typeof value === "number" || typeof value === "boolean")) {
161
+ return String(value);
162
+ }
163
+ if (typeof value === "string") {
164
+ return value;
165
+ }
166
+ if (value === undefined || value === null) {
167
+ return "";
168
+ }
169
+ return value;
170
+ };
171
+
172
+ /** Same shape as `value`, with every leaf cleared. Used to start a new item from a sibling. */
173
+ export const emptyLike = (value: unknown): unknown => {
174
+ if (typeof value === "string") {
175
+ return "";
176
+ }
177
+ if (typeof value === "number") {
178
+ return null;
179
+ }
180
+ if (typeof value === "boolean") {
181
+ return false;
182
+ }
183
+ if (Array.isArray(value)) {
184
+ const first = value[0];
185
+ if (first === undefined) {
186
+ return [];
187
+ }
188
+ return [emptyLike(first)];
189
+ }
190
+ if (isRecord(value)) {
191
+ const record: Record<string, unknown> = {};
192
+ for (const [key, child] of Object.entries(value)) {
193
+ record[key] = emptyLike(child);
194
+ }
195
+ return record;
196
+ }
197
+ return "";
198
+ };
199
+
200
+ /** Value the form edits. Schema wins the shape; otherwise a missing value is an empty string. */
201
+ export const prepareFormValue = (schema: JsonSchema | undefined, value: unknown): unknown => {
202
+ if (schema) {
203
+ return mergeWithSchema(schema, value);
204
+ }
205
+ if (value === undefined) {
206
+ return "";
207
+ }
208
+ return value;
209
+ };
210
+
211
+ const textIsLong = (value: unknown): boolean => {
212
+ return typeof value === "string" && (value.length > 80 || value.includes("\n"));
213
+ };
214
+
215
+ const buildField = ({
216
+ label,
217
+ path,
218
+ schema,
219
+ value,
220
+ }: {
221
+ label: string;
222
+ path: ValuePath;
223
+ schema?: JsonSchema;
224
+ value: unknown;
225
+ }): FormFieldNode => {
226
+ const kindName = schemaTypeName(schema);
227
+ const choices = enumValues(schema);
228
+ if (choices) {
229
+ return {
230
+ description: schema?.description,
231
+ enumValues: choices,
232
+ kind: "text",
233
+ label,
234
+ multiline: false,
235
+ path,
236
+ type: "field",
237
+ };
238
+ }
239
+ // A declared schema type picks the control; the stored value's type only decides untyped fields.
240
+ const isUntyped = kindName === undefined;
241
+ if (kindName === "boolean" || (isUntyped && typeof value === "boolean")) {
242
+ return {
243
+ description: schema?.description,
244
+ kind: "boolean",
245
+ label,
246
+ multiline: false,
247
+ path,
248
+ type: "field",
249
+ };
250
+ }
251
+ if (kindName === "number" || kindName === "integer" || (isUntyped && typeof value === "number")) {
252
+ return {
253
+ description: schema?.description,
254
+ kind: "number",
255
+ label,
256
+ multiline: false,
257
+ path,
258
+ type: "field",
259
+ };
260
+ }
261
+ return {
262
+ description: schema?.description,
263
+ kind: "text",
264
+ label,
265
+ multiline: path.length === 0 || textIsLong(value),
266
+ path,
267
+ type: "field",
268
+ };
269
+ };
270
+
271
+ const buildNode = ({
272
+ label,
273
+ path,
274
+ schema,
275
+ value,
276
+ }: {
277
+ label?: string;
278
+ path: ValuePath;
279
+ schema?: JsonSchema;
280
+ value: unknown;
281
+ }): FormNode => {
282
+ const kindName = schemaTypeName(schema);
283
+ const objectSchema = Boolean(schema?.properties) || kindName === "object";
284
+ const arraySchema = kindName === "array";
285
+ if (objectSchema || (schema === undefined && isRecord(value))) {
286
+ const source = isRecord(value) ? value : {};
287
+ const propertyNames = Object.keys(schema?.properties ?? {});
288
+ const extraNames = Object.keys(source).filter((key) => !propertyNames.includes(key));
289
+ const children = [...propertyNames, ...extraNames].map((key) => {
290
+ const childSchema = schema?.properties?.[key];
291
+ return buildNode({
292
+ label: labelFromKey(key, childSchema),
293
+ path: [...path, key],
294
+ schema: childSchema,
295
+ value: source[key],
296
+ });
297
+ });
298
+ return {children, path, title: label, type: "group"};
299
+ }
300
+ if (arraySchema || (schema === undefined && Array.isArray(value))) {
301
+ const list = Array.isArray(value) ? value : [];
302
+ const children = list.map((entry, index) => {
303
+ return buildNode({
304
+ label: `Item ${index + 1}`,
305
+ path: [...path, index],
306
+ schema: schema?.items,
307
+ value: entry,
308
+ });
309
+ });
310
+ return {
311
+ children,
312
+ itemSchema: schema?.items,
313
+ path,
314
+ title: label,
315
+ type: "list",
316
+ };
317
+ }
318
+ return buildField({label: label ?? "Expected output", path, schema, value});
319
+ };
320
+
321
+ /** Form tree for `value`, using `schema` when the dataset declared an expected shape. */
322
+ export const buildForm = (schema: JsonSchema | undefined, value: unknown): FormNode => {
323
+ return buildNode({path: [], schema, value});
324
+ };
325
+
326
+ /** Appends one blank entry to the list at `path`. */
327
+ export const appendListItem = (
328
+ root: unknown,
329
+ path: ValuePath,
330
+ itemSchema?: JsonSchema
331
+ ): unknown => {
332
+ const current = readPath(root, path);
333
+ const list = Array.isArray(current) ? [...current] : [];
334
+ const last = list[list.length - 1];
335
+ const nextItem = last === undefined ? blankFromSchema(itemSchema) : emptyLike(last);
336
+ list.push(nextItem);
337
+ return setAtPath(root, path, list);
338
+ };
@@ -56,6 +56,7 @@ describe("useAiObservabilityDatasetsApi", () => {
56
56
  create: api.useCreateMutation(),
57
57
  createItem: api.useCreateItemMutation(),
58
58
  importItems: api.useImportMutation(),
59
+ updateItem: api.useUpdateItemMutation(),
59
60
  };
60
61
  },
61
62
  {wrapper: ObservabilityTestProvider}
@@ -69,6 +70,11 @@ describe("useAiObservabilityDatasetsApi", () => {
69
70
  datasetId: "ds-1",
70
71
  }).unwrap();
71
72
  await result.current.addTraces[0]({datasetId: "ds-1", traceIds: ["t-1"]}).unwrap();
73
+ await result.current.updateItem[0]({
74
+ body: {expectedOutput: {answer: "ok"}, proofread: true},
75
+ datasetId: "ds-1",
76
+ itemId: "item 1",
77
+ }).unwrap();
72
78
  });
73
79
 
74
80
  expect(calls.map(({body, method, url}) => ({body, method, url}))).toEqual([
@@ -84,6 +90,11 @@ describe("useAiObservabilityDatasetsApi", () => {
84
90
  method: "POST",
85
91
  url: "/ai/observability/traces/add-to-dataset",
86
92
  },
93
+ {
94
+ body: {expectedOutput: {answer: "ok"}, proofread: true},
95
+ method: "PATCH",
96
+ url: "/ai/observability/datasets/ds-1/items/item%201",
97
+ },
87
98
  ]);
88
99
  });
89
100
 
@@ -26,6 +26,7 @@ export interface DatasetItemWriteBody {
26
26
  input: unknown;
27
27
  metadata?: Record<string, unknown>;
28
28
  origin?: "manual" | "synthetic" | "trace";
29
+ outcomeClass?: "fn" | "fp" | "tn" | "tp" | null;
29
30
  proofread?: boolean;
30
31
  sourceTraceId?: string;
31
32
  tags?: string[];
@@ -56,6 +57,10 @@ export interface AiObservabilityDatasetsApi {
56
57
  options?: ObservabilityQueryOptions
57
58
  ) => AdminRpcQueryState<DatasetItemRecord[] | {data: DatasetItemRecord[]}>;
58
59
  useListQuery: () => AdminRpcQueryState<DatasetRecord[] | {data: DatasetRecord[]}>;
60
+ useUpdateItemMutation: () => ObservabilityMutation<
61
+ {body: Partial<DatasetItemWriteBody>; datasetId: string; itemId: string},
62
+ DatasetItemRecord
63
+ >;
59
64
  }
60
65
 
61
66
  const datasetUrl = (id: string): string => `${DATASETS_URL}/${encodeURIComponent(id)}`;
@@ -112,5 +117,22 @@ export const useAiObservabilityDatasetsApi = (): AiObservabilityDatasetsApi => {
112
117
  url: `${datasetUrl(id)}/items`,
113
118
  }),
114
119
  useListQuery: () => useObservabilityQuery({providesTags: DATASETS_TAGS, url: DATASETS_URL}),
120
+ useUpdateItemMutation: () =>
121
+ useObservabilityMutation({
122
+ invalidatesTags: DATASET_AND_ITEMS_TAGS,
123
+ toRequest: ({
124
+ body,
125
+ datasetId,
126
+ itemId,
127
+ }: {
128
+ body: Partial<DatasetItemWriteBody>;
129
+ datasetId: string;
130
+ itemId: string;
131
+ }) => ({
132
+ body: asJsonBody(body),
133
+ method: "PATCH",
134
+ url: `${datasetUrl(datasetId)}/items/${encodeURIComponent(itemId)}`,
135
+ }),
136
+ }),
115
137
  };
116
138
  };
@@ -15,12 +15,14 @@ import React, {useCallback, useState} from "react";
15
15
  import {AiPromptPlaygroundView} from "./AiPromptPlaygroundView";
16
16
  import {
17
17
  appendPromptReference,
18
+ formatFolderPath,
18
19
  nextVersionFromDetail,
19
20
  outgoingProductionCopy,
20
21
  type PlaygroundRunResult,
21
22
  type PromptDetail,
22
23
  type PromptVersionDetail,
23
24
  productionVersionFromDetail,
25
+ promptLocation,
24
26
  schemaSummary,
25
27
  TEMPERATURE_PRESETS,
26
28
  } from "./promptTypes";
@@ -343,6 +345,9 @@ export const AiPromptEditorView: React.FC<AiPromptEditorViewProps> = ({
343
345
  }) => {
344
346
  const productionVersion = productionVersionFromDetail(detail);
345
347
  const nextVersion = nextVersionFromDetail(detail);
348
+ const location = promptLocation(detail);
349
+ const folderLabel = formatFolderPath(location.directory);
350
+ const storedName = location.leaf === detail.name ? "" : ` · ${detail.name}`;
346
351
  const current = detail.versions.find((entry) => entry.version === selectedVersion);
347
352
  const [tabIndex, setTabIndex] = useState(0);
348
353
  const [confirmProduction, setConfirmProduction] = useState(false);
@@ -425,9 +430,9 @@ export const AiPromptEditorView: React.FC<AiPromptEditorViewProps> = ({
425
430
  ) : undefined}
426
431
  </Box>
427
432
  <Box flex="grow" gap={3}>
428
- <Heading size="md">{detail.name}</Heading>
433
+ <Heading size="md">{location.leaf}</Heading>
429
434
  <Text color="secondaryDark">
430
- {`${detail.folder} · immutable versions — save creates v${nextVersion}`}
435
+ {`${folderLabel}${storedName} · immutable versions — save creates v${nextVersion}`}
431
436
  </Text>
432
437
  <Text color="secondaryDark" size="sm" testID="ai-prompt-outgoing-version">
433
438
  {outgoingCopy}
@@ -9,11 +9,13 @@ import {
9
9
  import type {PromptActionPermissions} from "../shell/observabilityPermissions";
10
10
  import {AiPromptEditorView} from "./AiPromptEditorView";
11
11
  import {
12
+ formatFolderPath,
12
13
  formatProduction,
13
14
  latestVersionFromDetail,
14
15
  type PlaygroundRunResult,
15
16
  type PromptDetail,
16
17
  productionVersionFromDetail,
18
+ promptLocation,
17
19
  } from "./promptTypes";
18
20
 
19
21
  export interface AiPromptHubViewProps {
@@ -88,7 +90,11 @@ const PromptOverviewPanel: React.FC<{
88
90
  </Text>
89
91
  )}
90
92
  <Box direction="row" gap={2} wrap>
91
- <Badge status="info" testID="ai-prompt-folder" value={`Folder: ${detail.folder}`} />
93
+ <Badge
94
+ status="info"
95
+ testID="ai-prompt-folder"
96
+ value={`Folder: ${formatFolderPath(promptLocation(detail).directory) || detail.folder}`}
97
+ />
92
98
  <Badge status="neutral" testID="ai-prompt-latest" value={`Latest: v${latest}`} />
93
99
  <Badge
94
100
  status={production === undefined ? "warning" : "success"}
@@ -118,7 +124,7 @@ const PromptOverviewPanel: React.FC<{
118
124
  <Text testID={`ai-prompt-used-by-${entry.name}`}>{entry.name}</Text>
119
125
  )}
120
126
  <Text color="secondaryDark" size="sm">
121
- {`${entry.folder} · ${entry.versions.map((version) => `v${version}`).join(", ")}`}
127
+ {`${formatFolderPath(promptLocation(entry).directory) || entry.folder} · ${entry.versions.map((version) => `v${version}`).join(", ")}`}
122
128
  </Text>
123
129
  </Box>
124
130
  ))}
@@ -218,6 +224,7 @@ export const AiPromptHubView: React.FC<AiPromptHubViewProps> = ({
218
224
  selectedVersion,
219
225
  }) => {
220
226
  const [tabIndex, setTabIndex] = useState(0);
227
+ const location = promptLocation(detail);
221
228
 
222
229
  const traceRows: ObservabilityTableRow[] = useMemo(() => {
223
230
  return detail.relationships.traces.items.map((trace) => ({
@@ -245,7 +252,7 @@ export const AiPromptHubView: React.FC<AiPromptHubViewProps> = ({
245
252
 
246
253
  return (
247
254
  <Box flex="grow" gap={4} testID="ai-prompt-hub">
248
- <Heading size="md">{detail.name}</Heading>
255
+ <Heading size="md">{location.leaf}</Heading>
249
256
  <SegmentedControl
250
257
  items={HUB_TABS}
251
258
  onChange={setTabIndex}
@@ -25,6 +25,7 @@ export const AiPromptsScreenWidget: React.FC<AdminScreenWidgetProps> = (props) =
25
25
  const [createPrompt, createState] = useCreateMutation();
26
26
  const [search, setSearch] = useState("");
27
27
  const [folder, setFolder] = useState(ALL_FOLDERS);
28
+ const [tag, setTag] = useState("");
28
29
  const [createOpen, setCreateOpen] = useState(false);
29
30
  const [createFolder, setCreateFolder] = useState("examples");
30
31
  const [createName, setCreateName] = useState("");
@@ -135,8 +136,10 @@ export const AiPromptsScreenWidget: React.FC<AdminScreenWidgetProps> = (props) =
135
136
  onOpenPrompt={handleOpen}
136
137
  onRetry={refetch}
137
138
  onSearchChange={setSearch}
139
+ onTagChange={setTag}
138
140
  prompts={prompts}
139
141
  search={search}
142
+ tag={tag}
140
143
  />
141
144
  )}
142
145
  </AiObservabilityChrome>