Skip to content

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: mark failed deep research sources as errors

nash_su100cc6c12985
diff --git a/src/lib/deep-research.test.ts b/src/lib/deep-research.test.ts
index 5143796e..bb69fafa 100644
--- a/src/lib/deep-research.test.ts
+++ b/src/lib/deep-research.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it, vi } from "vitest"
-import { collectResearchSources, makeDeepResearchFileName } from "./deep-research"
+import { collectResearchSources, makeDeepResearchFileName, noResearchSourcesTaskPatch } from "./deep-research"
import type { SearchApiConfig } from "@/stores/wiki-store"
import type { WebSearchResult } from "./web-search"
@@ -48,6 +48,24 @@ describe("makeDeepResearchFileName", () => {
})
})
+describe("noResearchSourcesTaskPatch", () => {
+ it("marks source failures as an error instead of completed", () => {
+ expect(noResearchSourcesTaskPatch(["Firecrawl blocked this IP", "AnyTXT offline"])).toEqual({
+ status: "error",
+ synthesis: "",
+ error: "Firecrawl blocked this IP\nAnyTXT offline",
+ })
+ })
+
+ it("marks an empty successful search as done", () => {
+ expect(noResearchSourcesTaskPatch([])).toEqual({
+ status: "done",
+ synthesis: "No research sources found.",
+ error: null,
+ })
+ })
+})
+
describe("collectResearchSources", () => {
it("uses only Web Search when source mode is web", async () => {
const webSearch = vi.fn().mockResolvedValue([webResult])
diff --git a/src/lib/deep-research.ts b/src/lib/deep-research.ts
index 7f6e0853..febc12b4 100644
--- a/src/lib/deep-research.ts
+++ b/src/lib/deep-research.ts
@@ -25,6 +25,28 @@ interface ResearchSourceCollection {
errors: string[]
}
+export function noResearchSourcesTaskPatch(sourceErrors: string[]): {
+ status: "done" | "error"
+ synthesis: string
+ error: string | null
+} {
+ // If every selected source produced zero usable results and at least
+ // one source failed, surface the failure state explicitly. Otherwise
+ // the UI shows "completed" for a task that could not actually search.
+ if (sourceErrors.length > 0) {
+ return {
+ status: "error",
+ synthesis: "",
+ error: sourceErrors.join("\n"),
+ }
+ }
+ return {
+ status: "done",
+ synthesis: "No research sources found.",
+ error: null,
+ }
+}
+
export function makeDeepResearchFileName(topic: string, now: Date = new Date()): {
fileName: string
date: string
@@ -189,10 +211,7 @@ async function executeResearch(
if (!updateTaskIfActive(pp, taskId, { webResults })) return
if (webResults.length === 0) {
- if (!updateTaskIfActive(pp, taskId, {
- status: "done",
- synthesis: sourceErrors.length > 0 ? sourceErrors.join("\n") : "No research sources found.",
- })) return
+ if (!updateTaskIfActive(pp, taskId, noResearchSourcesTaskPatch(sourceErrors))) return
if (isActiveProjectPath(pp)) onTaskFinished(pp, llmConfig, searchConfig)
return
}