From f61e3591bd29723817ae3de69e4d05d3bbdc2749 Mon Sep 17 00:00:00 2001 From: Thomas Camlong Date: Thu, 6 Aug 2026 09:53:51 +0200 Subject: [PATCH] feat: mock Homarr Assistant in demo mode and fix board page crash - demo mode now enables the assistant at runtime: getAvailability and getRuntimeOptions report an enabled Homarr Assistant (Demo) model without requiring a provider configuration or API key - the assistant chat route returns a canned, streamed answer in demo mode instead of calling a real language model - align the provider/endpoint fields in the assistant configuration page - catch NOT_FOUND/BAD_REQUEST in the board page so a missing home board renders a 404 instead of crashing - use the camelCase provider options key expected by @ai-sdk/openai-compatible to silence the deprecation warning --- .../[locale]/boards/(content)/_creator.tsx | 11 ++++- .../_components/assistant-configuration.tsx | 18 ++++---- .../chat/assistant-provider-options.spec.ts | 18 ++++++++ .../chat/assistant-provider-options.ts | 17 +++++++ .../src/app/api/assistant/chat/route.ts | 45 ++++++++++++++++--- packages/api/src/router/assistant.ts | 23 +++++++++- 6 files changed, 115 insertions(+), 17 deletions(-) create mode 100644 apps/nextjs/src/app/api/assistant/chat/assistant-provider-options.spec.ts create mode 100644 apps/nextjs/src/app/api/assistant/chat/assistant-provider-options.ts diff --git a/apps/nextjs/src/app/[locale]/boards/(content)/_creator.tsx b/apps/nextjs/src/app/[locale]/boards/(content)/_creator.tsx index 16be5c478..99d1a2584 100644 --- a/apps/nextjs/src/app/[locale]/boards/(content)/_creator.tsx +++ b/apps/nextjs/src/app/[locale]/boards/(content)/_creator.tsx @@ -1,5 +1,6 @@ import type { Metadata } from "next"; import { Suspense } from "react"; +import { notFound } from "next/navigation"; import { TRPCError } from "@trpc/server"; // Placed here because gridstack styles are used for board content @@ -50,7 +51,15 @@ export const createBoardContentPage = >( const resolvedParams = await params; const queryClient = getQueryClient(); - const [board, session] = await Promise.all([getInitialBoard(resolvedParams), auth()]); + const [board, session] = await Promise.all([ + getInitialBoard(resolvedParams).catch((error) => { + if (error instanceof TRPCError && (error.code === "NOT_FOUND" || error.code === "BAD_REQUEST")) { + notFound(); + } + throw error; + }), + auth(), + ]); const itemsMap = board.items.reduce((acc, item) => { const existing = acc.get(item.kind); diff --git a/apps/nextjs/src/app/[locale]/manage/assistant/_components/assistant-configuration.tsx b/apps/nextjs/src/app/[locale]/manage/assistant/_components/assistant-configuration.tsx index 8f8c538b4..f97c53e2f 100644 --- a/apps/nextjs/src/app/[locale]/manage/assistant/_components/assistant-configuration.tsx +++ b/apps/nextjs/src/app/[locale]/manage/assistant/_components/assistant-configuration.tsx @@ -462,7 +462,7 @@ export const AssistantConfiguration = () => { } > - +