Files
arcadia-admin/vite.config.ts
jules 628691d2df ai: shake-out fixes from first end-to-end search_kb run
Three problems surfaced when driving search_kb / read_chunk through a
real DeepSeek chat for the first time:

1. vite.config.ts: minisearch wasn't in `aliasedDeps`, so when
   @crema/lexical-rag-ui imports it, Vite couldn't resolve the bare
   specifier from the sibling lib's location. Added it next to the
   other shared deps. tsconfig paths alone is not enough — the Vite
   alias is what propagates resolution to sibling-lib code.

2. ai.tsx reindexKB: was using `toast.show?.()` which doesn't exist on
   useToast()'s API. Optional chaining silently no-op'd, so the button
   click ran the fetch but produced zero UI feedback (success or
   failure). Switched to the actual API: toast.info / toast.success /
   toast.error. Added a console.error in the catch arm so the
   underlying exception is visible in DevTools when something does go
   wrong.

3. ai.tsx MAX_TOOL_ITERATIONS: cap was 3, which is too tight for
   agentic search→read→search loops on real questions. Bumped to 6.
   More importantly, when the cap IS reached, the runner now
   synthesises tool-error messages for each pending tool_call and
   continues the chat — instead of silently dropping them, which left
   the conversation with an assistant.tool_calls turn but no matching
   tool messages. DeepSeek (and the OpenAI spec) reject that
   conversation with 400 ("insufficient tool messages following
   tool_calls"), poisoning the thread. Now the model gets a clean
   "max iterations reached" signal and produces a final answer.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 22:18:18 +10:00

175 lines
5.7 KiB
TypeScript

import { resolve as resolvePath } from "node:path"
import { fileURLToPath } from "node:url"
import { reactRouter } from "@react-router/dev/vite"
import tailwindcss from "@tailwindcss/vite"
import { defineConfig } from "vite"
import tsconfigPaths from "vite-tsconfig-paths"
const contentUiSrc = fileURLToPath(
new URL("../lib-content-ui/src", import.meta.url),
)
const contentEditorUiSrc = fileURLToPath(
new URL("../lib-content-editor-ui/src", import.meta.url),
)
const contentMediaUiSrc = fileURLToPath(
new URL("../lib-content-media-ui/src", import.meta.url),
)
const colorUiSrc = fileURLToPath(
new URL("../lib-color-ui/src", import.meta.url),
)
const typographyUiSrc = fileURLToPath(
new URL("../lib-typography-ui/src", import.meta.url),
)
const dataUiSrc = fileURLToPath(
new URL("../lib-data-ui/src", import.meta.url),
)
const layoutUiSrc = fileURLToPath(
new URL("../lib-layout-ui/src", import.meta.url),
)
const mapUiSrc = fileURLToPath(
new URL("../lib-map-ui/src", import.meta.url),
)
const formUiSrc = fileURLToPath(
new URL("../lib-form-ui/src", import.meta.url),
)
const feedbackUiSrc = fileURLToPath(
new URL("../lib-feedback-ui/src", import.meta.url),
)
const diagramUiSrc = fileURLToPath(
new URL("../lib-diagram-ui/src", import.meta.url),
)
const chatUiSrc = fileURLToPath(
new URL("../lib-chat-ui/src", import.meta.url),
)
const calendarUiSrc = fileURLToPath(
new URL("../lib-calendar-ui/src", import.meta.url),
)
const codeUiSrc = fileURLToPath(
new URL("../lib-code-ui/src", import.meta.url),
)
const aiUiSrc = fileURLToPath(
new URL("../lib-ai-ui/src", import.meta.url),
)
const authUiSrc = fileURLToPath(
new URL("../lib-auth-ui/src", import.meta.url),
)
const tableUiSrc = fileURLToPath(
new URL("../lib-table-ui/src", import.meta.url),
)
const searchUiSrc = fileURLToPath(
new URL("../lib-search-ui/src", import.meta.url),
)
const arcadiaClientSrc = fileURLToPath(
new URL("../lib-arcadia-client/src", import.meta.url),
)
const arcadiaAuthUiSrc = fileURLToPath(
new URL("../lib-arcadia-auth-ui/src", import.meta.url),
)
const llmUiSrc = fileURLToPath(
new URL("../lib-llm-ui/src", import.meta.url),
)
const llmProvidersUiSrc = fileURLToPath(
new URL("../lib-llm-providers-ui/src", import.meta.url),
)
const fileUiSrc = fileURLToPath(
new URL("../lib-file-ui/src", import.meta.url),
)
const cardUiSrc = fileURLToPath(
new URL("../lib-card-ui/src", import.meta.url),
)
const dashboardUiSrc = fileURLToPath(
new URL("../lib-dashboard-ui/src", import.meta.url),
)
const chartUiSrc = fileURLToPath(
new URL("../lib-chart-ui/src", import.meta.url),
)
const statusUiSrc = fileURLToPath(
new URL("../lib-status-ui/src", import.meta.url),
)
// Sibling lib packages (lib-content-ui, lib-content-editor-ui) import bare
// deps like clsx and @tiptap/* but have no node_modules of their own. Pin
// each shared dep to pristine-ui's installed copy so Vite can resolve them
// regardless of the importer's location.
const nodeModules = fileURLToPath(new URL("./node_modules/", import.meta.url))
const aliasedDeps = [
"clsx",
"tailwind-merge",
"lucide-react",
"openapi-fetch",
"phoenix",
"@tiptap/core",
"@tiptap/react",
"@tiptap/starter-kit",
"@tiptap/extension-link",
"@tiptap/extension-placeholder",
"@tiptap/extension-image",
"minisearch",
]
const sharedDepAliases = Object.fromEntries(
aliasedDeps.map((name) => [name, resolvePath(nodeModules, name)]),
)
const dedupeDeps = [
"react",
"react-dom",
"react-router",
...aliasedDeps,
]
export default defineConfig({
plugins: [tailwindcss(), reactRouter(), tsconfigPaths()],
resolve: {
alias: {
"@crema/content-ui": `${contentUiSrc}/index.ts`,
"@crema/content-editor-ui": `${contentEditorUiSrc}/index.ts`,
"@crema/content-media-ui": `${contentMediaUiSrc}/index.tsx`,
"@crema/color-ui": `${colorUiSrc}/index.tsx`,
"@crema/typography-ui": `${typographyUiSrc}/index.tsx`,
"@crema/data-ui": `${dataUiSrc}/index.tsx`,
"@crema/layout-ui": `${layoutUiSrc}/index.tsx`,
"@crema/map-ui": `${mapUiSrc}/index.tsx`,
"@crema/form-ui": `${formUiSrc}/index.tsx`,
"@crema/feedback-ui": `${feedbackUiSrc}/index.tsx`,
"@crema/diagram-ui": `${diagramUiSrc}/index.tsx`,
"@crema/chat-ui": `${chatUiSrc}/index.tsx`,
"@crema/calendar-ui": `${calendarUiSrc}/index.tsx`,
"@crema/code-ui": `${codeUiSrc}/index.tsx`,
"@crema/ai-ui": `${aiUiSrc}/index.tsx`,
"@crema/auth-ui": `${authUiSrc}/index.tsx`,
"@crema/table-ui": `${tableUiSrc}/index.tsx`,
"@crema/search-ui": `${searchUiSrc}/index.tsx`,
"@crema/arcadia-client": `${arcadiaClientSrc}/index.tsx`,
"@crema/arcadia-auth-ui": `${arcadiaAuthUiSrc}/index.tsx`,
"@crema/llm-ui": `${llmUiSrc}/index.tsx`,
"@crema/llm-providers-ui": `${llmProvidersUiSrc}/index.tsx`,
"@crema/file-ui": `${fileUiSrc}/index.tsx`,
"@crema/card-ui": `${cardUiSrc}/index.tsx`,
"@crema/dashboard-ui": `${dashboardUiSrc}/index.tsx`,
"@crema/chart-ui": `${chartUiSrc}/index.tsx`,
"@crema/status-ui": `${statusUiSrc}/index.tsx`,
...sharedDepAliases,
},
dedupe: dedupeDeps,
},
// Pre-bundle deps that sibling libs reach for. Without this, Vite
// discovers them lazily as routes are hit and re-runs the optimizer,
// invalidating already-served module URLs (browser sees 504 "Outdated
// Optimize Dep"). Listing them here forces one optimizer pass on
// startup so the cache is stable before the browser connects.
optimizeDeps: {
include: [
"openapi-fetch",
"phoenix",
"lucide-react",
"clsx",
"tailwind-merge",
"class-variance-authority",
],
},
server: {
fs: {
allow: [fileURLToPath(new URL("..", import.meta.url))],
},
},
})