feat: improve workshop publishing flow
This commit is contained in:
19 files changed
+254
-82
No files matched your search
@@ -35,6 +35,7 @@ describe("assistant chat input", () => {
|
||||
clientContext: { pathname: "/en/boards/Home/settings", timeZone: "Europe/Paris" },
|
||||
currentTime: new Date("2026-08-13T08:00:00.000Z"),
|
||||
userName: "Alex",
|
||||
workshopWebUrl: "https://community.example.com/workshop",
|
||||
entities: [
|
||||
{ id: "board-1", type: "board", label: "Home", description: "Home board" },
|
||||
{ id: "app-1", type: "app", label: "Jellyfin", description: "Media" },
|
||||
@@ -51,6 +52,7 @@ describe("assistant chat input", () => {
|
||||
|
||||
expect(context).toContain('"currentTimeUtc":"2026-08-13T08:00:00.000Z"');
|
||||
expect(context).toContain('"currentUser":"Alex"');
|
||||
expect(context).toContain('"workshopWebUrl":"https://community.example.com/workshop"');
|
||||
expect(context).toContain('"currentBoard":{"id":"board-1","name":"Home"}');
|
||||
expect(context).toContain('"availableResources":{"boards":1,"apps":1,"integrations":1,"widgets":1}');
|
||||
expect(context).toContain('"explicitMentions":[{"type":"app","id":"app-1","label":"Jellyfin"');
|
||||
|
||||
@@ -59,12 +59,14 @@ export const buildAssistantRequestContext = ({
|
||||
entities,
|
||||
messages,
|
||||
userName,
|
||||
workshopWebUrl,
|
||||
}: {
|
||||
clientContext?: AssistantClientContext;
|
||||
currentTime: Date;
|
||||
entities: AssistantContextEntity[];
|
||||
messages: { role: "user" | "assistant"; parts: unknown[] }[];
|
||||
userName: string | null | undefined;
|
||||
workshopWebUrl?: string;
|
||||
}) => {
|
||||
const boards = entities.filter((entity) => entity.type === "board");
|
||||
const homeBoard = boards.find((board) => board.description === "Home board");
|
||||
@@ -88,6 +90,7 @@ export const buildAssistantRequestContext = ({
|
||||
currentTimeUtc: currentTime.toISOString(),
|
||||
userTimeZone: clientContext?.timeZone ?? "UTC",
|
||||
currentUser: userName?.trim() || "Signed-in user",
|
||||
workshopWebUrl: workshopWebUrl ?? null,
|
||||
currentPage: clientContext?.pathname ?? null,
|
||||
currentBoard: currentBoard ? { id: currentBoard.id, name: currentBoard.label } : null,
|
||||
homeBoard: homeBoard ? { id: homeBoard.id, name: homeBoard.label } : null,
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
assistantProviderRequiresApiKey,
|
||||
assistantReasoningModes,
|
||||
} from "@homarr/definitions";
|
||||
import { resolveHomarrUrlConfig } from "@homarr/workshop/schema";
|
||||
|
||||
import { browserToolContracts } from "~/components/assistant/assistant-tool-contracts";
|
||||
import { env as appEnv } from "~/env";
|
||||
@@ -461,6 +462,11 @@ export async function POST(request: Request) {
|
||||
entities: contextEntities,
|
||||
messages: parsed.data.messages,
|
||||
userName: session.user.name,
|
||||
workshopWebUrl: resolveHomarrUrlConfig({
|
||||
homarrWebsiteUrl: appEnv.HOMARR_WEBSITE_URL,
|
||||
workshopApiUrl: appEnv.WORKSHOP_API_URL,
|
||||
workshopWebUrl: appEnv.WORKSHOP_WEB_URL,
|
||||
}).workshopWebUrl,
|
||||
});
|
||||
if (modelLookup.error !== null) {
|
||||
logger.warn("Assistant model discovery failed before the response started", {
|
||||
|
||||
Reference in new issue
Block a user