LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。
TypeScript
Fix search config fallback handling
nash_suec2c42f8fb4a
diff --git a/src/lib/ingest-source-path-collision.test.ts b/src/lib/ingest-source-path-collision.test.tsindex 0124ae1d..5b8e2760 100644--- a/src/lib/ingest-source-path-collision.test.ts+++ b/src/lib/ingest-source-path-collision.test.ts@@ -205,6 +205,38 @@ describe("autoIngest source summary paths", () => {expect(content).toContain("project-a config")})+ it("does not migrate a legacy basename source summary when the basename is ambiguous", async () => {+ if (!tmp) throw new Error("missing temp project")+ sourceMarkers = ["project-a config"]++ const legacySummaryPath = path.join(tmp.path, "wiki", "sources", "config.md")+ const legacyContent = [+ "---",+ 'title: "Source: config.yaml"',+ 'sources: ["config.yaml"]',+ "---",+ "",+ "# Legacy config",+ "",+ "Ambiguous legacy source summary body.",+ ].join("\n")+ await writeFileRaw(legacySummaryPath, legacyContent)++ await autoIngest(+ tmp.path,+ `${tmp.path}/raw/sources/project-a/config.yaml`,+ useWikiStore.getState().llmConfig,+ undefined,+ "project-a",+ )++ const canonicalSummary = `wiki/sources/${sourceSummarySlugFromIdentity("project-a/config.yaml")}.md`+ const canonicalSummaryPath = path.join(tmp.path, canonicalSummary)++ expect(await fs.readFile(legacySummaryPath, "utf8")).toBe(legacyContent)+ expect(await fs.readFile(canonicalSummaryPath, "utf8")).toContain("project-a config")+ })+it("canonicalizes interactive source summary paths and sources frontmatter", async () => {if (!tmp) throw new Error("missing temp project")diff --git a/src/lib/web-search.test.ts b/src/lib/web-search.test.tsindex 70d9889a..96ffec64 100644--- a/src/lib/web-search.test.ts+++ b/src/lib/web-search.test.ts@@ -1,5 +1,5 @@import { beforeEach, describe, expect, it, vi } from "vitest"-import { hasConfiguredSearchProvider, webSearch } from "./web-search"+import { hasConfiguredSearchProvider, resolveSearchConfig, webSearch } from "./web-search"const fetchMock = vi.fn<typeof fetch>()@@ -198,6 +198,20 @@ describe("webSearch", () => {})).toBe(false)})+ it("does not leak a stale top-level Ollama URL into non-Ollama providers", () => {+ const resolved = resolveSearchConfig({+ provider: "serpapi",+ apiKey: "",+ ollamaUrl: "http://localhost:11434",+ providerConfigs: {+ serpapi: { apiKey: "serp-key" },+ ollama: { ollamaUrl: "https://ollama.com" },+ },+ })++ expect(resolved.ollamaUrl).toBe("https://ollama.com")+ })+it("calls the Ollama Web Search API with Bearer auth", async () => {fetchMock.mockResolvedValueOnce(jsonResponse({results: [diff --git a/src/lib/web-search.ts b/src/lib/web-search.tsindex 678560fe..0edf93c1 100644--- a/src/lib/web-search.ts+++ b/src/lib/web-search.ts@@ -69,6 +69,12 @@ export function resolveSearchConfig(config: SearchApiConfig): SearchApiConfig {}const activeProvider = config.provider as SearchProvider+ const activeOverride = activeProvider === "none" ? undefined : providerConfigs[activeProvider]+ const resolvedOllamaUrl =+ activeProvider === "ollama"+ ? activeOverride?.ollamaUrl ?? config.ollamaUrl ?? "https://ollama.com"+ : providerConfigs.ollama?.ollamaUrl ?? "https://ollama.com"+if (activeProvider === "none") {return {...config,@@ -77,12 +83,11 @@ export function resolveSearchConfig(config: SearchApiConfig): SearchApiConfig {serpApiEngine: config.serpApiEngine ?? providerConfigs.serpapi?.serpApiEngine ?? "google",searXngUrl: config.searXngUrl ?? providerConfigs.searxng?.searXngUrl ?? "",searXngCategories: config.searXngCategories ?? providerConfigs.searxng?.searXngCategories ?? ["general"],- ollamaUrl: config.ollamaUrl ?? providerConfigs.ollama?.ollamaUrl ?? "https://ollama.com",+ ollamaUrl: providerConfigs.ollama?.ollamaUrl ?? "https://ollama.com",providerConfigs,}}- const activeOverride = providerConfigs[activeProvider]return {...config,provider: activeProvider,@@ -90,7 +95,7 @@ export function resolveSearchConfig(config: SearchApiConfig): SearchApiConfig {serpApiEngine: activeOverride?.serpApiEngine ?? config.serpApiEngine ?? "google",searXngUrl: activeOverride?.searXngUrl ?? config.searXngUrl ?? "",searXngCategories: activeOverride?.searXngCategories ?? config.searXngCategories ?? ["general"],- ollamaUrl: activeOverride?.ollamaUrl ?? config.ollamaUrl ?? "https://ollama.com",+ ollamaUrl: resolvedOllamaUrl,providerConfigs,}}@@ -381,9 +386,7 @@ async function ollamaSearch(const headers: Record<string, string> = {Accept: "application/json","Content-Type": "application/json",- }- if (trimmedApiKey) {- headers.Authorization = `Bearer ${trimmedApiKey}`+ Authorization: `Bearer ${trimmedApiKey}`,}const httpFetch = await getHttpFetch()