@terreno/admin-frontend 58.0.6 → 58.1.1
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 +58 -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 +23 -1
- package/dist/widgets/aiObservability/traces/AiTracesListView.js.map +1 -1
- package/dist/widgets/aiObservability/traces/traceTypes.d.ts +15 -0
- package/dist/widgets/aiObservability/traces/traceTypes.d.ts.map +1 -1
- package/dist/widgets/aiObservability/traces/traceTypes.js +39 -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 +12 -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 +24 -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 +120 -0
- package/src/widgets/aiObservability/traces/AiTraceDetailView.tsx +47 -7
- package/src/widgets/aiObservability/traces/AiTracesListView.tsx +23 -0
- package/src/widgets/aiObservability/traces/traceTypes.test.ts +46 -0
- package/src/widgets/aiObservability/traces/traceTypes.ts +53 -0
- package/src/widgets/aiObservability/traces/useAiObservabilityTracesApi.test.ts +40 -0
- package/src/widgets/aiObservability/traces/useAiObservabilityTracesApi.ts +12 -0
|
@@ -24,7 +24,7 @@ const idleHandlers = {
|
|
|
24
24
|
createOpen: false,
|
|
25
25
|
createSystem: "",
|
|
26
26
|
createTemplate: "",
|
|
27
|
-
folder: "
|
|
27
|
+
folder: "",
|
|
28
28
|
onCreate: mock(() => {}),
|
|
29
29
|
onCreateDescriptionChange: mock(() => {}),
|
|
30
30
|
onCreateFolderChange: mock(() => {}),
|
|
@@ -36,8 +36,10 @@ const idleHandlers = {
|
|
|
36
36
|
onOpenCreate: mock(() => {}),
|
|
37
37
|
onOpenPrompt: mock(() => {}),
|
|
38
38
|
onSearchChange: mock(() => {}),
|
|
39
|
+
onTagChange: mock(() => {}),
|
|
39
40
|
prompts,
|
|
40
41
|
search: "",
|
|
42
|
+
tag: "",
|
|
41
43
|
};
|
|
42
44
|
|
|
43
45
|
describe("AiPromptsListView", () => {
|
|
@@ -76,7 +78,7 @@ describe("AiPromptsListView", () => {
|
|
|
76
78
|
const view = renderWithTheme(
|
|
77
79
|
<AiPromptsListView
|
|
78
80
|
{...idleHandlers}
|
|
79
|
-
folder=""
|
|
81
|
+
folder="examples"
|
|
80
82
|
prompts={[
|
|
81
83
|
{
|
|
82
84
|
description: "Short summaries",
|
|
@@ -123,7 +125,7 @@ describe("AiPromptsListView", () => {
|
|
|
123
125
|
{folder: "examples", latestVersion: 7, name: "gamma", production: 7, type: "chat"},
|
|
124
126
|
];
|
|
125
127
|
const view = renderWithTheme(
|
|
126
|
-
<AiPromptsListView {...idleHandlers} folder="" prompts={library} />
|
|
128
|
+
<AiPromptsListView {...idleHandlers} folder="examples" prompts={library} />
|
|
127
129
|
);
|
|
128
130
|
const tableProps = (): DataTableProps =>
|
|
129
131
|
view.UNSAFE_root.find(
|
|
@@ -156,10 +158,154 @@ describe("AiPromptsListView", () => {
|
|
|
156
158
|
"ai-prompt-open-alpha",
|
|
157
159
|
]);
|
|
158
160
|
expect(view.getByText("v12")).toBeTruthy();
|
|
161
|
+
expect(view.queryByTestId("ai-prompts-folder-examples-clickable")).toBeNull();
|
|
159
162
|
|
|
160
163
|
act(() => {
|
|
161
164
|
tableProps().onFilterValuesChange?.({type: ["chat"]});
|
|
162
165
|
});
|
|
163
166
|
expect(openOrder()).toEqual(["ai-prompt-open-gamma", "ai-prompt-open-alpha"]);
|
|
164
167
|
});
|
|
168
|
+
|
|
169
|
+
it("nests slash folders and shows the prompt's last segment", async () => {
|
|
170
|
+
const onFolderChange = mock(() => {});
|
|
171
|
+
const library: PromptListItem[] = [
|
|
172
|
+
{
|
|
173
|
+
folder: "appointmentAI/intake",
|
|
174
|
+
latestVersion: 1,
|
|
175
|
+
name: "appointmentAI/intake/_preamble",
|
|
176
|
+
production: 1,
|
|
177
|
+
type: "text",
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
folder: "appointmentAI/intake/admission-safety-assessment",
|
|
181
|
+
latestVersion: 1,
|
|
182
|
+
name: "appointmentAI/intake/admission-safety-assessment/risk",
|
|
183
|
+
production: 1,
|
|
184
|
+
type: "text",
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
folder: "examples",
|
|
188
|
+
latestVersion: 1,
|
|
189
|
+
name: "summarize",
|
|
190
|
+
production: 1,
|
|
191
|
+
type: "chat",
|
|
192
|
+
},
|
|
193
|
+
];
|
|
194
|
+
const view = renderWithTheme(
|
|
195
|
+
<AiPromptsListView
|
|
196
|
+
{...idleHandlers}
|
|
197
|
+
folder=""
|
|
198
|
+
onFolderChange={onFolderChange}
|
|
199
|
+
prompts={library}
|
|
200
|
+
/>
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
expect(view.getByTestId("ai-prompts-folder-appointmentAI-clickable")).toBeTruthy();
|
|
204
|
+
expect(view.getByTestId("ai-prompts-folder-examples-clickable")).toBeTruthy();
|
|
205
|
+
expect(view.queryByText("_preamble")).toBeNull();
|
|
206
|
+
expect(view.queryByText("summarize")).toBeNull();
|
|
207
|
+
expect(view.getByText("2 prompts")).toBeTruthy();
|
|
208
|
+
|
|
209
|
+
await act(async () => {
|
|
210
|
+
fireEvent.press(view.getByTestId("ai-prompts-folder-appointmentAI-clickable"));
|
|
211
|
+
await Promise.resolve();
|
|
212
|
+
});
|
|
213
|
+
assert.deepEqual(onFolderChange.mock.calls[0], ["appointmentAI"]);
|
|
214
|
+
|
|
215
|
+
view.rerender(
|
|
216
|
+
<AiPromptsListView
|
|
217
|
+
{...idleHandlers}
|
|
218
|
+
folder="appointmentAI"
|
|
219
|
+
onFolderChange={onFolderChange}
|
|
220
|
+
prompts={library}
|
|
221
|
+
/>
|
|
222
|
+
);
|
|
223
|
+
expect(view.getByTestId("ai-prompts-folder-up-clickable")).toBeTruthy();
|
|
224
|
+
expect(view.getByText("All prompts")).toBeTruthy();
|
|
225
|
+
expect(view.getByTestId("ai-prompts-folder-appointmentAI/intake-clickable")).toBeTruthy();
|
|
226
|
+
expect(view.queryByTestId("ai-prompts-folder-examples-clickable")).toBeNull();
|
|
227
|
+
|
|
228
|
+
await act(async () => {
|
|
229
|
+
fireEvent.press(view.getByTestId("ai-prompts-folder-appointmentAI/intake-clickable"));
|
|
230
|
+
await Promise.resolve();
|
|
231
|
+
});
|
|
232
|
+
assert.deepEqual(onFolderChange.mock.calls[1], ["appointmentAI/intake"]);
|
|
233
|
+
|
|
234
|
+
view.rerender(
|
|
235
|
+
<AiPromptsListView
|
|
236
|
+
{...idleHandlers}
|
|
237
|
+
folder="appointmentAI/intake"
|
|
238
|
+
onFolderChange={onFolderChange}
|
|
239
|
+
prompts={library}
|
|
240
|
+
/>
|
|
241
|
+
);
|
|
242
|
+
expect(view.getByText("_preamble")).toBeTruthy();
|
|
243
|
+
expect(view.getByText("appointmentAI / intake")).toBeTruthy();
|
|
244
|
+
expect(view.queryByText("risk")).toBeNull();
|
|
245
|
+
expect(view.queryByText("summarize")).toBeNull();
|
|
246
|
+
expect(
|
|
247
|
+
view.getByTestId(
|
|
248
|
+
"ai-prompts-folder-appointmentAI/intake/admission-safety-assessment-clickable"
|
|
249
|
+
)
|
|
250
|
+
).toBeTruthy();
|
|
251
|
+
|
|
252
|
+
await act(async () => {
|
|
253
|
+
fireEvent.press(view.getByTestId("ai-prompts-folder-up-clickable"));
|
|
254
|
+
await Promise.resolve();
|
|
255
|
+
});
|
|
256
|
+
assert.deepEqual(onFolderChange.mock.calls[2], ["appointmentAI"]);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it("searches every folder even when a nested folder is open", () => {
|
|
260
|
+
const library: PromptListItem[] = [
|
|
261
|
+
{
|
|
262
|
+
folder: "appointmentAI/intake",
|
|
263
|
+
latestVersion: 1,
|
|
264
|
+
name: "appointmentAI/intake/_preamble",
|
|
265
|
+
production: 1,
|
|
266
|
+
type: "text",
|
|
267
|
+
},
|
|
268
|
+
{folder: "examples", latestVersion: 1, name: "summarize", production: 1, type: "chat"},
|
|
269
|
+
];
|
|
270
|
+
const view = renderWithTheme(
|
|
271
|
+
<AiPromptsListView
|
|
272
|
+
{...idleHandlers}
|
|
273
|
+
folder="appointmentAI/intake"
|
|
274
|
+
prompts={library}
|
|
275
|
+
search="summarize"
|
|
276
|
+
/>
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
expect(view.getByText("summarize")).toBeTruthy();
|
|
280
|
+
expect(view.getByText("examples")).toBeTruthy();
|
|
281
|
+
expect(view.queryByTestId("ai-prompts-folder-up-clickable")).toBeNull();
|
|
282
|
+
expect(view.queryByText("_preamble")).toBeNull();
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it("filters the table to prompts that have the selected tag", () => {
|
|
286
|
+
const library: PromptListItem[] = [
|
|
287
|
+
{
|
|
288
|
+
folder: "examples",
|
|
289
|
+
latestVersion: 1,
|
|
290
|
+
name: "summarize",
|
|
291
|
+
production: 1,
|
|
292
|
+
tags: ["gold"],
|
|
293
|
+
type: "chat",
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
folder: "ops",
|
|
297
|
+
latestVersion: 1,
|
|
298
|
+
name: "triage",
|
|
299
|
+
production: "—",
|
|
300
|
+
tags: ["ops"],
|
|
301
|
+
type: "text",
|
|
302
|
+
},
|
|
303
|
+
];
|
|
304
|
+
const view = renderWithTheme(
|
|
305
|
+
<AiPromptsListView {...idleHandlers} prompts={library} tag="gold" />
|
|
306
|
+
);
|
|
307
|
+
expect(view.getByTestId("ai-prompts-tag.label")).toBeTruthy();
|
|
308
|
+
expect(view.getByText("summarize")).toBeTruthy();
|
|
309
|
+
expect(view.queryByText("triage")).toBeNull();
|
|
310
|
+
});
|
|
165
311
|
});
|
|
@@ -3,8 +3,9 @@ import {
|
|
|
3
3
|
Box,
|
|
4
4
|
DataTable,
|
|
5
5
|
type DataTableCellData,
|
|
6
|
+
Icon,
|
|
6
7
|
Modal,
|
|
7
|
-
|
|
8
|
+
SelectField,
|
|
8
9
|
Spinner,
|
|
9
10
|
Text,
|
|
10
11
|
TextField,
|
|
@@ -13,7 +14,16 @@ import {DateTime} from "luxon";
|
|
|
13
14
|
import React, {useCallback, useMemo} from "react";
|
|
14
15
|
import {type ClientTableColumn, distinctChoiceOptions, useClientTable} from "../shell/clientTable";
|
|
15
16
|
import {ObservabilityEmptyState, ObservabilityErrorState} from "../shell/ObservabilityStates";
|
|
16
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
ALL_FOLDERS,
|
|
19
|
+
childFolders,
|
|
20
|
+
filterPrompts,
|
|
21
|
+
formatFolderPath,
|
|
22
|
+
type PromptListItem,
|
|
23
|
+
pathSegments,
|
|
24
|
+
promptLocation,
|
|
25
|
+
promptTags,
|
|
26
|
+
} from "./promptTypes";
|
|
17
27
|
|
|
18
28
|
/** List rows can carry a description and labels when the backend sends them. */
|
|
19
29
|
type PromptListRow = PromptListItem & {
|
|
@@ -54,9 +64,90 @@ const formatPromptLastUsed = (iso?: string): string => {
|
|
|
54
64
|
};
|
|
55
65
|
|
|
56
66
|
const promptSubline = (prompt: PromptListRow): string => {
|
|
57
|
-
|
|
67
|
+
const directory = formatFolderPath(promptLocation(prompt).directory);
|
|
68
|
+
if (prompt.description && directory) {
|
|
69
|
+
return `${directory} · ${prompt.description}`;
|
|
70
|
+
}
|
|
71
|
+
if (prompt.description) {
|
|
72
|
+
return prompt.description;
|
|
73
|
+
}
|
|
74
|
+
return directory || prompt.folder;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
interface FolderRowCell {
|
|
78
|
+
count: number;
|
|
79
|
+
kind: "folder";
|
|
80
|
+
name: string;
|
|
81
|
+
path: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface UpRowCell {
|
|
85
|
+
kind: "up";
|
|
86
|
+
label: string;
|
|
87
|
+
path: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
type NavigationCell = FolderRowCell | UpRowCell;
|
|
91
|
+
|
|
92
|
+
const isNavigationCell = (value: unknown): value is NavigationCell => {
|
|
93
|
+
if (!value || typeof value !== "object" || !("kind" in value)) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
const kind = (value as {kind?: unknown}).kind;
|
|
97
|
+
return kind === "folder" || kind === "up";
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const promptCountLabel = (count: number): string => {
|
|
101
|
+
return `${count} ${count === 1 ? "prompt" : "prompts"}`;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const FolderNameCell: React.FC<{
|
|
105
|
+
cell: NavigationCell;
|
|
106
|
+
onOpen: (path: string) => void;
|
|
107
|
+
}> = ({cell, onOpen}) => {
|
|
108
|
+
const handlePress = useCallback((): void => {
|
|
109
|
+
onOpen(cell.path);
|
|
110
|
+
}, [cell.path, onOpen]);
|
|
111
|
+
|
|
112
|
+
const isUp = cell.kind === "up";
|
|
113
|
+
const detail = isUp ? "Up one folder" : promptCountLabel(cell.count);
|
|
114
|
+
const testID = isUp ? "ai-prompts-folder-up" : `ai-prompts-folder-${cell.path}`;
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<Box
|
|
118
|
+
accessibilityHint={isUp ? "Goes up one folder" : "Shows the prompts in this folder"}
|
|
119
|
+
accessibilityLabel={isUp ? `Up to ${cell.label}` : `Open folder ${cell.name}, ${detail}`}
|
|
120
|
+
accessibilityRole="button"
|
|
121
|
+
alignItems="center"
|
|
122
|
+
direction="row"
|
|
123
|
+
flex="grow"
|
|
124
|
+
minWidth={0}
|
|
125
|
+
onClick={handlePress}
|
|
126
|
+
overflow="hidden"
|
|
127
|
+
testID={testID}
|
|
128
|
+
>
|
|
129
|
+
{/* A fixed width keeps the icon from collapsing under the label on web. */}
|
|
130
|
+
<Box alignItems="center" justifyContent="center" marginRight={2} width={20}>
|
|
131
|
+
<Icon color="secondaryDark" iconName={isUp ? "arrow-left" : "folder"} size="sm" />
|
|
132
|
+
</Box>
|
|
133
|
+
<Box flex="shrink" gap={1} minWidth={0} overflow="hidden">
|
|
134
|
+
<Text bold numberOfLines={1}>
|
|
135
|
+
{isUp ? cell.label : cell.name}
|
|
136
|
+
</Text>
|
|
137
|
+
<Text color="secondaryLight" numberOfLines={1} size="sm">
|
|
138
|
+
{detail}
|
|
139
|
+
</Text>
|
|
140
|
+
</Box>
|
|
141
|
+
</Box>
|
|
142
|
+
);
|
|
58
143
|
};
|
|
59
144
|
|
|
145
|
+
const DashCell: React.FC = () => (
|
|
146
|
+
<Box justifyContent="center">
|
|
147
|
+
<Text color="secondaryLight">—</Text>
|
|
148
|
+
</Box>
|
|
149
|
+
);
|
|
150
|
+
|
|
60
151
|
const buildColumns = (prompts: PromptListRow[]): ClientTableColumn<PromptListRow>[] => [
|
|
61
152
|
{
|
|
62
153
|
cell: (prompt) => ({value: prompt}),
|
|
@@ -129,6 +220,9 @@ const buildColumns = (prompts: PromptListRow[]): ClientTableColumn<PromptListRow
|
|
|
129
220
|
|
|
130
221
|
const TypeBadgeCell: React.FC<{cellData: DataTableCellData}> = ({cellData}) => {
|
|
131
222
|
const type = String(cellData.value ?? "") as PromptListItem["type"];
|
|
223
|
+
if (!PROMPT_TYPE_LABELS[type]) {
|
|
224
|
+
return <DashCell />;
|
|
225
|
+
}
|
|
132
226
|
return (
|
|
133
227
|
<Box alignItems="start" justifyContent="center">
|
|
134
228
|
<Badge
|
|
@@ -143,11 +237,7 @@ const TypeBadgeCell: React.FC<{cellData: DataTableCellData}> = ({cellData}) => {
|
|
|
143
237
|
|
|
144
238
|
const ProductionCell: React.FC<{cellData: DataTableCellData}> = ({cellData}) => {
|
|
145
239
|
if (typeof cellData.value !== "number") {
|
|
146
|
-
return
|
|
147
|
-
<Box justifyContent="center">
|
|
148
|
-
<Text color="secondaryLight">—</Text>
|
|
149
|
-
</Box>
|
|
150
|
-
);
|
|
240
|
+
return <DashCell />;
|
|
151
241
|
}
|
|
152
242
|
return (
|
|
153
243
|
<Box alignItems="start" justifyContent="center">
|
|
@@ -158,6 +248,9 @@ const ProductionCell: React.FC<{cellData: DataTableCellData}> = ({cellData}) =>
|
|
|
158
248
|
|
|
159
249
|
const NewestCell: React.FC<{cellData: DataTableCellData}> = ({cellData}) => {
|
|
160
250
|
const prompt = cellData.value as PromptListRow;
|
|
251
|
+
if (!prompt || typeof prompt !== "object" || !("latestVersion" in prompt)) {
|
|
252
|
+
return <DashCell />;
|
|
253
|
+
}
|
|
161
254
|
return (
|
|
162
255
|
<Box alignItems="center" direction="row" gap={2}>
|
|
163
256
|
<Text>{`v${prompt.latestVersion}`}</Text>
|
|
@@ -197,8 +290,10 @@ export interface AiPromptsListViewProps {
|
|
|
197
290
|
onOpenPrompt: (name: string) => void;
|
|
198
291
|
onRetry?: () => void;
|
|
199
292
|
onSearchChange: (value: string) => void;
|
|
293
|
+
onTagChange: (tag: string) => void;
|
|
200
294
|
prompts: PromptListItem[];
|
|
201
295
|
search: string;
|
|
296
|
+
tag: string;
|
|
202
297
|
}
|
|
203
298
|
|
|
204
299
|
export const AiPromptsListView: React.FC<AiPromptsListViewProps> = ({
|
|
@@ -226,31 +321,49 @@ export const AiPromptsListView: React.FC<AiPromptsListViewProps> = ({
|
|
|
226
321
|
onOpenPrompt,
|
|
227
322
|
onRetry,
|
|
228
323
|
onSearchChange,
|
|
324
|
+
onTagChange,
|
|
229
325
|
prompts,
|
|
230
326
|
search,
|
|
327
|
+
tag,
|
|
231
328
|
}) => {
|
|
329
|
+
const currentDirectory = useMemo(() => pathSegments(folder).join("/"), [folder]);
|
|
330
|
+
const browsing = search.trim().length === 0 && tag.trim().length === 0;
|
|
232
331
|
const visible = useMemo((): PromptListRow[] => {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return
|
|
237
|
-
}, [prompts]);
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
332
|
+
if (!browsing) {
|
|
333
|
+
return filterPrompts({folder: ALL_FOLDERS, prompts, search, tag});
|
|
334
|
+
}
|
|
335
|
+
return prompts.filter((prompt) => promptLocation(prompt).directory === currentDirectory);
|
|
336
|
+
}, [browsing, currentDirectory, prompts, search, tag]);
|
|
337
|
+
const foldersHere = useMemo(() => {
|
|
338
|
+
if (!browsing) {
|
|
339
|
+
return [];
|
|
340
|
+
}
|
|
341
|
+
return childFolders(prompts, currentDirectory);
|
|
342
|
+
}, [browsing, currentDirectory, prompts]);
|
|
343
|
+
const upRow = useMemo((): UpRowCell | undefined => {
|
|
344
|
+
const segments = pathSegments(currentDirectory);
|
|
345
|
+
if (!browsing || segments.length === 0) {
|
|
346
|
+
return undefined;
|
|
347
|
+
}
|
|
348
|
+
const parentSegments = segments.slice(0, -1);
|
|
349
|
+
return {
|
|
350
|
+
kind: "up",
|
|
351
|
+
label:
|
|
352
|
+
parentSegments.length === 0
|
|
353
|
+
? "All prompts"
|
|
354
|
+
: (parentSegments[parentSegments.length - 1] ?? "All prompts"),
|
|
355
|
+
path: parentSegments.join("/"),
|
|
356
|
+
};
|
|
357
|
+
}, [browsing, currentDirectory]);
|
|
358
|
+
const tags = useMemo(() => promptTags(prompts), [prompts]);
|
|
249
359
|
|
|
250
360
|
const customColumnComponentMap = useMemo(
|
|
251
361
|
() => ({
|
|
252
362
|
number: NumberCell,
|
|
253
363
|
promptName: ({cellData}: {cellData: DataTableCellData}) => {
|
|
364
|
+
if (isNavigationCell(cellData.value)) {
|
|
365
|
+
return <FolderNameCell cell={cellData.value} onOpen={onFolderChange} />;
|
|
366
|
+
}
|
|
254
367
|
const prompt = cellData.value as PromptListRow;
|
|
255
368
|
return (
|
|
256
369
|
<Box
|
|
@@ -265,7 +378,7 @@ export const AiPromptsListView: React.FC<AiPromptsListViewProps> = ({
|
|
|
265
378
|
>
|
|
266
379
|
<Box testID={`ai-prompt-open-${prompt.name}`}>
|
|
267
380
|
<Text bold numberOfLines={1}>
|
|
268
|
-
{prompt.
|
|
381
|
+
{promptLocation(prompt).leaf}
|
|
269
382
|
</Text>
|
|
270
383
|
</Box>
|
|
271
384
|
<Text color="secondaryLight" numberOfLines={1} size="sm">
|
|
@@ -278,9 +391,27 @@ export const AiPromptsListView: React.FC<AiPromptsListViewProps> = ({
|
|
|
278
391
|
promptProduction: ProductionCell,
|
|
279
392
|
promptType: TypeBadgeCell,
|
|
280
393
|
}),
|
|
281
|
-
[onOpenPrompt]
|
|
394
|
+
[onFolderChange, onOpenPrompt]
|
|
282
395
|
);
|
|
283
396
|
|
|
397
|
+
const navigationRows = useMemo((): DataTableCellData[][] => {
|
|
398
|
+
const blank = {value: "—"};
|
|
399
|
+
const rest = [blank, blank, blank, blank, blank];
|
|
400
|
+
const rows: DataTableCellData[][] = [];
|
|
401
|
+
if (upRow) {
|
|
402
|
+
rows.push([{value: upRow}, ...rest]);
|
|
403
|
+
}
|
|
404
|
+
for (const entry of foldersHere) {
|
|
405
|
+
rows.push([
|
|
406
|
+
{
|
|
407
|
+
value: {count: entry.count, kind: "folder", name: entry.name, path: entry.path},
|
|
408
|
+
},
|
|
409
|
+
...rest,
|
|
410
|
+
]);
|
|
411
|
+
}
|
|
412
|
+
return rows;
|
|
413
|
+
}, [foldersHere, upRow]);
|
|
414
|
+
|
|
284
415
|
const tableColumnsInput = useMemo(() => buildColumns(visible), [visible]);
|
|
285
416
|
// The search box above the table already covers names, so the table adds no search.
|
|
286
417
|
const {rows: _sortedPrompts, ...table} = useClientTable({
|
|
@@ -312,10 +443,10 @@ export const AiPromptsListView: React.FC<AiPromptsListViewProps> = ({
|
|
|
312
443
|
/>
|
|
313
444
|
);
|
|
314
445
|
}
|
|
315
|
-
if (visible.length === 0) {
|
|
446
|
+
if (visible.length === 0 && navigationRows.length === 0) {
|
|
316
447
|
return (
|
|
317
448
|
<ObservabilityEmptyState
|
|
318
|
-
description="Try another
|
|
449
|
+
description="Try another tag, or clear the search."
|
|
319
450
|
iconName="magnifying-glass"
|
|
320
451
|
testID="ai-prompts-no-matches"
|
|
321
452
|
title="No prompts match"
|
|
@@ -326,6 +457,7 @@ export const AiPromptsListView: React.FC<AiPromptsListViewProps> = ({
|
|
|
326
457
|
<DataTable
|
|
327
458
|
{...table}
|
|
328
459
|
customColumnComponentMap={customColumnComponentMap}
|
|
460
|
+
data={[...navigationRows, ...table.data]}
|
|
329
461
|
emptyContent={
|
|
330
462
|
<ObservabilityEmptyState
|
|
331
463
|
description="Clear a column filter to see more prompts."
|
|
@@ -343,24 +475,24 @@ export const AiPromptsListView: React.FC<AiPromptsListViewProps> = ({
|
|
|
343
475
|
return (
|
|
344
476
|
<Box gap={4} testID="ai-prompts-list">
|
|
345
477
|
{prompts.length > 0 ? (
|
|
346
|
-
<Box alignItems="end" direction="row" gap={4} justifyContent="
|
|
347
|
-
|
|
348
|
-
<
|
|
349
|
-
|
|
350
|
-
{
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
478
|
+
<Box alignItems="end" direction="row" gap={4} justifyContent="end" wrap>
|
|
479
|
+
{tags.length > 0 ? (
|
|
480
|
+
<Box minWidth={200} width={240}>
|
|
481
|
+
<SelectField
|
|
482
|
+
onChange={onTagChange}
|
|
483
|
+
options={tags.map((entry) => ({label: entry, value: entry}))}
|
|
484
|
+
placeholder="All tags"
|
|
485
|
+
testID="ai-prompts-tag"
|
|
486
|
+
title="Tag"
|
|
487
|
+
value={tag}
|
|
488
|
+
/>
|
|
489
|
+
</Box>
|
|
490
|
+
) : null}
|
|
359
491
|
<Box minWidth={240} width={320}>
|
|
360
492
|
<TextField
|
|
361
493
|
iconName="magnifying-glass"
|
|
362
494
|
onChange={onSearchChange}
|
|
363
|
-
placeholder="Search by name or
|
|
495
|
+
placeholder="Search by name, folder, or tag"
|
|
364
496
|
testID="ai-prompts-search"
|
|
365
497
|
type="search"
|
|
366
498
|
value={search}
|
|
@@ -388,12 +520,14 @@ export const AiPromptsListView: React.FC<AiPromptsListViewProps> = ({
|
|
|
388
520
|
>
|
|
389
521
|
<Box gap={3} testID="ai-prompts-create-form">
|
|
390
522
|
<TextField
|
|
523
|
+
helperText="Use a slash for each nested folder, such as appointmentAI/intake."
|
|
391
524
|
onChange={onCreateFolderChange}
|
|
392
525
|
testID="ai-prompts-create-folder"
|
|
393
526
|
title="Folder"
|
|
394
527
|
value={createFolder}
|
|
395
528
|
/>
|
|
396
529
|
<TextField
|
|
530
|
+
helperText="A slash nests the name too. The last segment is the prompt."
|
|
397
531
|
onChange={onCreateNameChange}
|
|
398
532
|
testID="ai-prompts-create-name"
|
|
399
533
|
title="Name"
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {describe, expect, it} from "bun:test";
|
|
2
2
|
import {
|
|
3
3
|
appendPromptReference,
|
|
4
|
+
childFolders,
|
|
4
5
|
filterPrompts,
|
|
5
|
-
|
|
6
|
+
formatFolderPath,
|
|
6
7
|
formatPlaygroundMetrics,
|
|
7
8
|
formatProduction,
|
|
8
9
|
judgeOutputSchemaFromDetail,
|
|
@@ -13,6 +14,8 @@ import {
|
|
|
13
14
|
type PromptListItem,
|
|
14
15
|
type PromptVersionDetail,
|
|
15
16
|
productionVersionFromDetail,
|
|
17
|
+
promptLocation,
|
|
18
|
+
promptTags,
|
|
16
19
|
schemaSummary,
|
|
17
20
|
templateVariableKeys,
|
|
18
21
|
unwrapPromptDetail,
|
|
@@ -26,10 +29,11 @@ const sample: PromptListItem[] = [
|
|
|
26
29
|
latestVersion: 2,
|
|
27
30
|
name: "summarize",
|
|
28
31
|
production: 1,
|
|
32
|
+
tags: ["gold"],
|
|
29
33
|
type: "chat",
|
|
30
34
|
usage7d: {calls: 4, costUsd: 0.0123},
|
|
31
35
|
},
|
|
32
|
-
{folder: "ops", latestVersion: 1, name: "triage", production: "—", type: "text"},
|
|
36
|
+
{folder: "ops", latestVersion: 1, name: "triage", production: "—", tags: ["ops"], type: "text"},
|
|
33
37
|
];
|
|
34
38
|
|
|
35
39
|
const version = (
|
|
@@ -81,17 +85,93 @@ describe("promptTypes helpers", () => {
|
|
|
81
85
|
});
|
|
82
86
|
});
|
|
83
87
|
|
|
84
|
-
it("
|
|
85
|
-
expect(folderCounts(sample)).toEqual([
|
|
86
|
-
{count: 1, folder: "examples"},
|
|
87
|
-
{count: 1, folder: "ops"},
|
|
88
|
-
]);
|
|
88
|
+
it("filters by folder, tag, and search", () => {
|
|
89
89
|
expect(
|
|
90
90
|
filterPrompts({folder: "ops", prompts: sample, search: ""}).map((row) => row.name)
|
|
91
91
|
).toEqual(["triage"]);
|
|
92
92
|
expect(
|
|
93
93
|
filterPrompts({folder: "", prompts: sample, search: "sum"}).map((row) => row.name)
|
|
94
94
|
).toEqual(["summarize"]);
|
|
95
|
+
expect(promptTags(sample)).toEqual(["gold", "ops"]);
|
|
96
|
+
expect(
|
|
97
|
+
filterPrompts({folder: "", prompts: sample, search: "", tag: "gold"}).map((row) => row.name)
|
|
98
|
+
).toEqual(["summarize"]);
|
|
99
|
+
expect(
|
|
100
|
+
filterPrompts({folder: "", prompts: sample, search: "ops"}).map((row) => row.name)
|
|
101
|
+
).toEqual(["triage"]);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("treats every slash in the folder or the name as a nested folder", () => {
|
|
105
|
+
const nested: PromptListItem[] = [
|
|
106
|
+
{
|
|
107
|
+
folder: "appointmentAI/intake",
|
|
108
|
+
latestVersion: 1,
|
|
109
|
+
name: "appointmentAI/intake/_preamble",
|
|
110
|
+
production: 1,
|
|
111
|
+
type: "text",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
folder: "appointmentAI/intake/admission-safety-assessment",
|
|
115
|
+
latestVersion: 1,
|
|
116
|
+
name: "appointmentAI/intake/admission-safety-assessment/risk",
|
|
117
|
+
production: 1,
|
|
118
|
+
type: "text",
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
folder: "appointmentAI/intake/admission-safety-assessment",
|
|
122
|
+
latestVersion: 1,
|
|
123
|
+
name: "appointmentAI/intake/admission-safety-assessment/plan",
|
|
124
|
+
production: "—",
|
|
125
|
+
type: "text",
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
folder: "examples",
|
|
129
|
+
latestVersion: 1,
|
|
130
|
+
name: "summarize",
|
|
131
|
+
production: 1,
|
|
132
|
+
type: "chat",
|
|
133
|
+
},
|
|
134
|
+
];
|
|
135
|
+
|
|
136
|
+
const preamble = nested[0];
|
|
137
|
+
const risk = nested[1];
|
|
138
|
+
const summarize = nested[3];
|
|
139
|
+
if (!preamble || !risk || !summarize) {
|
|
140
|
+
throw new Error("nested folder fixture is missing a prompt");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
expect(formatFolderPath("appointmentAI/intake/")).toBe("appointmentAI / intake");
|
|
144
|
+
expect(promptLocation(preamble).leaf).toBe("_preamble");
|
|
145
|
+
expect(promptLocation(preamble).directory).toBe("appointmentAI/intake");
|
|
146
|
+
expect(promptLocation(risk).directory).toBe("appointmentAI/intake/admission-safety-assessment");
|
|
147
|
+
expect(promptLocation(risk).leaf).toBe("risk");
|
|
148
|
+
expect(promptLocation(summarize).directory).toBe("examples");
|
|
149
|
+
expect(promptLocation(summarize).leaf).toBe("summarize");
|
|
150
|
+
|
|
151
|
+
expect(childFolders(nested, "")).toEqual([
|
|
152
|
+
{count: 3, name: "appointmentAI", path: "appointmentAI"},
|
|
153
|
+
{count: 1, name: "examples", path: "examples"},
|
|
154
|
+
]);
|
|
155
|
+
expect(childFolders(nested, "appointmentAI")).toEqual([
|
|
156
|
+
{count: 3, name: "intake", path: "appointmentAI/intake"},
|
|
157
|
+
]);
|
|
158
|
+
expect(childFolders(nested, "appointmentAI/intake").map((entry) => entry.name)).toEqual([
|
|
159
|
+
"admission-safety-assessment",
|
|
160
|
+
]);
|
|
161
|
+
|
|
162
|
+
const namesIn = (folder: string): string[] =>
|
|
163
|
+
filterPrompts({folder, prompts: nested, search: ""}).map((row) => row.name);
|
|
164
|
+
expect(namesIn("appointmentAI")).toContain(preamble.name);
|
|
165
|
+
expect(namesIn("appointmentAI/intake")).toContain(preamble.name);
|
|
166
|
+
expect(namesIn("appointmentAI/intake/admission-safety-assessment")).not.toContain(
|
|
167
|
+
preamble.name
|
|
168
|
+
);
|
|
169
|
+
expect(namesIn("appointmentAI")).not.toContain(summarize.name);
|
|
170
|
+
expect(
|
|
171
|
+
filterPrompts({folder: "appointmentAI/intake", prompts: nested, search: "plan"}).map(
|
|
172
|
+
(row) => row.name
|
|
173
|
+
)
|
|
174
|
+
).toEqual(["appointmentAI/intake/admission-safety-assessment/plan"]);
|
|
95
175
|
});
|
|
96
176
|
|
|
97
177
|
it("formats production as a version or em dash", () => {
|