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
This commit is contained in:
Thomas Camlong committed 2026-08-06 13:10:21 +02:00
1 parent fce950d406
commit f61e3591bd
6 files changed
+115 -17

No files matched your search

+22 -1
View File
@@ -30,7 +30,7 @@ import {
import type { createTRPCContext } from "../trpc";
import { fetchOpenRouterGenerationTelemetryAsync } from "../assistant-generation-telemetry";
import { verifyAssistantGenerationAccessToken } from "../assistant-generation-access";
import { createTRPCRouter, permissionRequiredProcedure, protectedProcedure } from "../trpc";
import { createTRPCRouter, isDemoMode, permissionRequiredProcedure, protectedProcedure } from "../trpc";
import { boardRouter } from "./board";
const adminProcedure = permissionRequiredProcedure.requiresPermission("admin");
@@ -448,6 +448,9 @@ export const assistantRouter = createTRPCRouter({
},
})
.query(async ({ ctx }) => {
if (isDemoMode) {
return { enabled: true };
}
const configuration = await getConfigurationAsync(ctx.db);
const requiresApiKey = configuration ? assistantProviderRequiresApiKey(configuration.provider) : false;
return {
@@ -495,6 +498,24 @@ export const assistantRouter = createTRPCRouter({
getRuntimeOptions: protectedProcedure.query(async ({ ctx }) => {
const configuration = await getConfigurationAsync(ctx.db);
if (isDemoMode) {
return {
provider: "homarr",
defaultModelId: "homarr-assistant",
models: [
{
id: "homarr-assistant",
name: "Homarr Assistant (Demo)",
description: null,
contextLength: null,
promptPrice: null,
completionPrice: null,
inputModalities: [],
toolSupport: "unknown" as const,
},
],
};
}
if (!configuration?.enabled || !configuration.modelId) {
throw new TRPCError({ code: "PRECONDITION_FAILED", message: "Homarr Assistant is not configured." });
}