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
Harden file sync startup dedupe
nash_sude97cfbe08e2
diff --git a/src/lib/project-file-sync.test.ts b/src/lib/project-file-sync.test.tsindex 7348babc..7f5c1538 100644--- a/src/lib/project-file-sync.test.ts+++ b/src/lib/project-file-sync.test.ts@@ -370,6 +370,46 @@ describe("project file sync", () => {])})+ it("does not suppress a retried file-change task that reuses the same id", async () => {+ vi.useFakeTimers()+ const { startProjectFileSync } = await import("@/lib/project-file-sync")+ const { useWikiStore } = await import("@/stores/wiki-store")++ const project = { id: "A", name: "A", path: "/tmp/a" }+ useWikiStore.getState().setProject(project)+ void startProjectFileSync(project)++ await vi.waitFor(() => {+ expect(mocks.listen).toHaveBeenCalledTimes(2)+ })++ const baseTask = {+ id: "retryable-task",+ projectId: "A",+ path: "raw/sources/retry.pdf",+ kind: "modified" as const,+ status: "done" as const,+ createdAt: 1,+ retryCount: 0,+ needsRerun: false,+ }++ mocks.emit("file-sync://changed", {+ projectId: "A",+ tasks: [{ ...baseTask, updatedAt: 1 }],+ })+ await vi.advanceTimersByTimeAsync(300)+ expect(mocks.enqueueBatch).toHaveBeenCalledTimes(1)++ mocks.emit("file-sync://changed", {+ projectId: "A",+ tasks: [{ ...baseTask, updatedAt: 2 }],+ })+ await vi.advanceTimersByTimeAsync(300)++ expect(mocks.enqueueBatch).toHaveBeenCalledTimes(2)+ })+it("manual rescan uses returned changed tasks while the watcher is running", async () => {const { startProjectFileSync, rescanProjectFileSync } = await import("@/lib/project-file-sync")const { useWikiStore } = await import("@/stores/wiki-store")diff --git a/src/lib/project-file-sync.ts b/src/lib/project-file-sync.tsindex cfd25ee8..f879b55f 100644--- a/src/lib/project-file-sync.ts+++ b/src/lib/project-file-sync.ts@@ -159,7 +159,10 @@ function mergeChangeTasks(tasks: FileChangeTask[]): FileChangeTask[] {}function changeTaskKey(task: FileChangeTask): string {- return task.id || `${task.projectId}:${task.path}:${task.kind}`+ const version = task.updatedAt ?? task.createdAt ?? 0+ return task.id+ ? `${task.id}:${version}`+ : `${task.projectId}:${task.path}:${task.kind}:${version}`}async function processFileChangeBatch(@@ -170,6 +173,9 @@ async function processFileChangeBatch(for (const task of tasks) {handledChangeTaskKeys.add(changeTaskKey(task))}+ if (handledChangeTaskKeys.size > 4096) {+ handledChangeTaskKeys = new Set([...handledChangeTaskKeys].slice(-2048))+ }await cleanupDeletedFiles(project, tasks)await enqueueRawSourceChanges(project, tasks)await refreshAfterFileChanges(project, paths)