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

Add retry-all ingest queue action

sunilkumarvalmiki722a970f529d
diff --git a/src/components/layout/activity-panel.tsx b/src/components/layout/activity-panel.tsx
index 7f27ac41..b28d2222 100644
--- a/src/components/layout/activity-panel.tsx
+++ b/src/components/layout/activity-panel.tsx
@@ -8,7 +8,15 @@ import { useActivityStore, type ActivityItem } from "@/stores/activity-store"
import { useWikiStore } from "@/stores/wiki-store"
import { useFileSyncStore } from "@/stores/file-sync-store"
import { normalizePath, getFileName, isAbsolutePath } from "@/lib/path-utils"
-import { getQueue, getQueueSummary, retryTask, cancelTask, cancelAllTasks, type IngestTask } from "@/lib/ingest-queue"
+import {
+ getQueue,
+ getQueueSummary,
+ retryTask,
+ retryAllFailedTasks,
+ cancelTask,
+ cancelAllTasks,
+ type IngestTask,
+} from "@/lib/ingest-queue"
import {
ignoreFileChangeTask,
rescanProjectFiles,
@@ -76,6 +84,11 @@ export function ActivityPanel() {
retryTask(taskId)
}, [project])
+ const handleRetryAllFailed = useCallback(() => {
+ if (!project) return
+ void retryAllFailedTasks().then(() => setQueueTasks([...getQueue()]))
+ }, [project])
+
const handleIngestCancel = useCallback((taskId: string) => {
if (!project) return
cancelTask(taskId)
@@ -226,6 +239,15 @@ export function ActivityPanel() {
Cancel all
</button>
)}
+ {queueSummary.failed > 0 && (
+ <button
+ onClick={handleRetryAllFailed}
+ className="rounded px-1.5 py-0.5 text-[10px] hover:bg-accent hover:text-foreground"
+ title="Retry all failed ingest tasks"
+ >
+ Retry failed
+ </button>
+ )}
</div>
<div className="h-1.5 rounded-full bg-muted overflow-hidden">
<div
@@ -236,6 +258,24 @@ export function ActivityPanel() {
</div>
)}
+ {hasQueue && queueSummary.processing === 0 && queueSummary.pending === 0 && queueSummary.failed > 0 && (
+ <div className="px-3 py-1.5 border-b border-border/50">
+ <div className="flex items-center justify-between text-[10px] text-muted-foreground gap-2">
+ <span>Ingest Queue</span>
+ <span className="flex-1 text-right">
+ {queueSummary.failed} failed
+ </span>
+ <button
+ onClick={handleRetryAllFailed}
+ className="rounded px-1.5 py-0.5 text-[10px] hover:bg-accent hover:text-foreground"
+ title="Retry all failed ingest tasks"
+ >
+ Retry failed
+ </button>
+ </div>
+ </div>
+ )}
+
{/* Queue tasks */}
{queueTasks.filter((t) => t.status === "processing").map((task) => (
<QueueRow key={task.id} task={task} onRetry={handleIngestRetry} onCancel={handleIngestCancel} />
diff --git a/src/lib/ingest-queue.test.ts b/src/lib/ingest-queue.test.ts
index 78a80dd3..16fb3b5a 100644
--- a/src/lib/ingest-queue.test.ts
+++ b/src/lib/ingest-queue.test.ts
@@ -54,6 +54,7 @@ import {
enqueueIngest,
enqueueBatch,
retryTask,
+ retryAllFailedTasks,
cancelTask,
cancelAllTasks,
clearCompletedTasks,
@@ -212,6 +213,52 @@ describe("ingest-queue — retry & failure", () => {
expect(getQueue()).toHaveLength(0)
})
+
+ it("retryAllFailedTasks requeues every failed task and resumes processing", async () => {
+ const saved = [
+ {
+ id: "ingest-failed-a",
+ sourcePath: "a.md",
+ folderContext: "",
+ status: "failed",
+ addedAt: 0,
+ error: "rate limit",
+ retryCount: 3,
+ },
+ {
+ id: "ingest-failed-b",
+ sourcePath: "b.md",
+ folderContext: "",
+ status: "failed",
+ addedAt: 1,
+ error: "timeout",
+ retryCount: 3,
+ },
+ ]
+ mockReadFile.mockResolvedValue(JSON.stringify(saved))
+ mockAutoIngest.mockImplementation(() => new Promise(() => {}))
+
+ await restoreQueue(TEST_ID, TEST_PATH)
+ mockWriteFile.mockClear()
+
+ const requeued = await retryAllFailedTasks()
+ await flushMicrotasks(2)
+
+ expect(requeued).toBe(2)
+ expect(mockAutoIngest).toHaveBeenCalledOnce()
+ expect(getQueue().map((task) => task.error)).toEqual([null, null])
+ expect(getQueue().map((task) => task.status)).toEqual(["processing", "pending"])
+ expect(mockWriteFile).toHaveBeenCalled()
+ })
+
+ it("retryAllFailedTasks returns 0 when there are no failed tasks", async () => {
+ mockAutoIngest.mockImplementation(() => new Promise(() => {}))
+
+ const requeued = await retryAllFailedTasks()
+
+ expect(requeued).toBe(0)
+ expect(mockAutoIngest).not.toHaveBeenCalled()
+ })
})
describe("ingest-queue — cancel", () => {
diff --git a/src/lib/ingest-queue.ts b/src/lib/ingest-queue.ts
index d8d1b1b9..c6a74b16 100644
--- a/src/lib/ingest-queue.ts
+++ b/src/lib/ingest-queue.ts
@@ -236,6 +236,28 @@ export async function retryTask(taskId: string): Promise<void> {
processNext(currentProjectId)
}
+/**
+ * Retry every failed task for the active project.
+ * Returns the number of tasks requeued.
+ */
+export async function retryAllFailedTasks(): Promise<number> {
+ if (!currentProjectId) return 0
+
+ let requeued = 0
+ for (const task of queue) {
+ if (task.projectId !== currentProjectId || task.status !== "failed") continue
+ task.status = "pending"
+ task.error = null
+ requeued++
+ }
+
+ if (requeued === 0) return 0
+
+ await saveQueue(currentProjectPath)
+ processNext(currentProjectId)
+ return requeued
+}
+
/**
* Cancel a pending or processing task.
* If processing, aborts the LLM call and cleans up generated files.