enhance assistant batch responses

This commit is contained in:
ajnart committed 2026-08-03 15:48:41 +02:00
1 parent 6a98036c50
commit bd3e4c33f3
11 files changed
+167 -11

No files matched your search

+1 -1
View File
@@ -1485,7 +1485,7 @@ export const boardRouter = createTRPCRouter({
mcp: {
enabled: true,
description:
"Add a widget/app item to a board. Automatically places it in the first empty section at the next free grid position. Provide boardId (from board_getAllBoards), kind (widget type like 'app', 'weather', etc.), optional options map, and optional integrationIds array. Returns { itemId }",
"Add a widget/app item to a board. Automatically places it in the first empty section at the next free grid position. Provide boardId (from board_getAllBoards), kind (widget type like 'app', 'weather', etc.), optional options map, and optional integrationIds array. To create a formatted dashboard note, use kind 'notebook' with options { content: Tiptap-compatible HTML, showToolbar: boolean, allowReadOnlyCheck: boolean }. Notebook content may use semantic paragraphs, headings, lists, task lists, blockquotes, tables, links, emphasis, and images, but must not contain scripts, styles, iframes, event handlers, or unsafe URL protocols. Returns { itemId }",
},
})
.input(addItemToBoardSchema)
+9 -4
View File
@@ -10,7 +10,7 @@ export const iconsRouter = createTRPCRouter({
mcp: {
enabled: true,
description:
"Search for icons by name across all icon repositories. OPTIONAL: searchText (string to filter), limitPerGroup (number 1-500, default 12). Call with no arguments to browse all icons",
"Search for icons by name across all icon repositories. Returns matching icon names and exact image URLs; use those URLs directly for app icons and Markdown image previews. OPTIONAL: searchText (string to filter), limitPerGroup (number 1-500, default 12). Call with no arguments to browse all icons",
},
})
.input(iconsFindSchema)
@@ -23,8 +23,8 @@ export const iconsRouter = createTRPCRouter({
whereCondition = and(...keywords.map((keyword) => like(icons.name, `%${keyword}%`)));
}
return {
icons: await ctx.db.query.iconRepositories.findMany({
const [repositories, countIcons] = await Promise.all([
ctx.db.query.iconRepositories.findMany({
with: {
icons: {
columns: { id: true, name: true, url: true },
@@ -47,7 +47,12 @@ export const iconsRouter = createTRPCRouter({
},
},
}),
countIcons: await ctx.db.$count(icons),
ctx.db.$count(icons),
]);
return {
icons: term.length > 0 ? repositories.filter((repository) => repository.icons.length > 0) : repositories,
countIcons,
};
}),
});
@@ -0,0 +1,54 @@
// @vitest-environment node
import { describe, expect, test } from "vitest";
import { iconRepositories, icons } from "@homarr/db/schema";
import { createDb } from "@homarr/db/test";
import { iconsRouter } from "../icons";
describe("findIcons", () => {
test("returns only repositories containing matches for a search", async () => {
const db = createDb();
await db.insert(iconRepositories).values([
{ id: "dashboard-icons", slug: "homarr-labs/dashboard-icons" },
{ id: "other-icons", slug: "example/other-icons" },
]);
await db.insert(icons).values([
{
id: "discord-svg",
name: "discord.svg",
url: "https://cdn.example.com/discord.svg",
checksum: "discord",
iconRepositoryId: "dashboard-icons",
},
{
id: "homarr-svg",
name: "homarr.svg",
url: "https://cdn.example.com/homarr.svg",
checksum: "homarr",
iconRepositoryId: "other-icons",
},
]);
const caller = iconsRouter.createCaller({ db, deviceType: undefined, session: null });
const result = await caller.findIcons({ searchText: "discord", limitPerGroup: 6 });
expect(result.countIcons).toBe(2);
expect(result.icons).toHaveLength(1);
expect(result.icons[0]).toMatchObject({
slug: "homarr-labs/dashboard-icons",
icons: [{ name: "discord.svg", url: "https://cdn.example.com/discord.svg" }],
});
});
test("keeps repositories when browsing without a search", async () => {
const db = createDb();
await db.insert(iconRepositories).values({ id: "empty", slug: "example/empty" });
const caller = iconsRouter.createCaller({ db, deviceType: undefined, session: null });
const result = await caller.findIcons({ limitPerGroup: 6 });
expect(result.icons).toMatchObject([{ slug: "example/empty", icons: [] }]);
});
});