Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/libswamp/data/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface DataSearchItem {
createdAt: string;
tags: Record<string, string>;
workflowTag?: string;
jobTag?: string;
stepTag?: string;
}

Expand Down Expand Up @@ -303,6 +304,7 @@ export async function* dataSearch(
createdAt: data.createdAt.toISOString(),
tags: data.tags,
workflowTag: data.tags.workflow,
jobTag: data.tags.job,
stepTag: data.tags.step,
});
}
Expand Down
39 changes: 39 additions & 0 deletions src/libswamp/data/search_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,45 @@ Deno.test("dataSearch: filters by tags with AND logic", async () => {
assertEquals(completed.data.results[0].id, "d1");
});

Deno.test("dataSearch: surfaces workflowTag/jobTag/stepTag from data tags", async () => {
const items = [
makeDataItem({
id: "d1",
tags: { workflow: "my-wf", job: "my-job", step: "my-step" },
}),
];
const deps = makeDeps(items);
const events = await collect<DataSearchEvent>(
dataSearch(createLibSwampContext(), deps, {}),
);

const completed = events[1] as Extract<
DataSearchEvent,
{ kind: "completed" }
>;
assertEquals(completed.data.results.length, 1);
assertEquals(completed.data.results[0].workflowTag, "my-wf");
assertEquals(completed.data.results[0].jobTag, "my-job");
assertEquals(completed.data.results[0].stepTag, "my-step");
});

Deno.test("dataSearch: jobTag is undefined when data has no job tag", async () => {
const items = [
makeDataItem({ id: "d1", tags: {} }),
];
const deps = makeDeps(items);
const events = await collect<DataSearchEvent>(
dataSearch(createLibSwampContext(), deps, {}),
);

const completed = events[1] as Extract<
DataSearchEvent,
{ kind: "completed" }
>;
assertEquals(completed.data.results.length, 1);
assertEquals(completed.data.results[0].jobTag, undefined);
});

Deno.test("dataSearch: yields error when model not found", async () => {
const deps = makeDeps([], {
findDefinitionByIdOrName: () => Promise.resolve(null),
Expand Down
3 changes: 2 additions & 1 deletion src/presentation/renderers/data_search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class InkDataSearchRenderer implements DataSearchRenderer {
(item) =>
`${item.name} ${item.modelName} ${item.modelType} ${item.type} ${
item.workflowTag ?? ""
} ${item.stepTag ?? ""} ${
} ${item.jobTag ?? ""} ${item.stepTag ?? ""} ${
Object.entries(item.tags).map(([k, v]) => `${k}=${v}`).join(" ")
}`,
renderDataResultLine,
Expand Down Expand Up @@ -179,6 +179,7 @@ function buildMetadataMarkdown(item: DataSearchItem): string {
];

if (item.workflowTag) lines.push(`**Workflow:** ${item.workflowTag}`);
if (item.jobTag) lines.push(`**Job:** ${item.jobTag}`);
if (item.stepTag) lines.push(`**Step:** ${item.stepTag}`);

if (tagEntries.length > 0) {
Expand Down
Loading