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: address cross-module review findings
nash_su5455c17a16de
diff --git a/src-tauri/src/api_server.rs b/src-tauri/src/api_server.rsindex 50e54067..ff581253 100644--- a/src-tauri/src/api_server.rs+++ b/src-tauri/src/api_server.rs@@ -346,7 +346,10 @@ fn handle_request(if !is_authorized(app, query, headers) {return err(401, "Unauthorized");}- if !matches!(method, &Method::Get | &Method::Post | &Method::Patch | &Method::Delete) {+ if !matches!(+ method,+ &Method::Get | &Method::Post | &Method::Patch | &Method::Delete+ ) {return err(405, "Method not allowed");}diff --git a/src-tauri/src/commands/file_sync.rs b/src-tauri/src/commands/file_sync.rsindex 998b5f5f..edb5d001 100644--- a/src-tauri/src/commands/file_sync.rs+++ b/src-tauri/src/commands/file_sync.rs@@ -1483,30 +1483,38 @@ mod tests {#[test]fn read_only_access_events_do_not_count_as_content_changes() {- assert!(!is_content_change_event(&EventKind::Access(AccessKind::Open(- AccessMode::Any- ))));- assert!(!is_content_change_event(&EventKind::Access(AccessKind::Open(- AccessMode::Read- ))));- assert!(!is_content_change_event(&EventKind::Access(AccessKind::Read)));- assert!(!is_content_change_event(&EventKind::Access(AccessKind::Close(- AccessMode::Read- ))));- assert!(!is_content_change_event(&EventKind::Access(AccessKind::Any)));+ assert!(!is_content_change_event(&EventKind::Access(+ AccessKind::Open(AccessMode::Any)+ )));+ assert!(!is_content_change_event(&EventKind::Access(+ AccessKind::Open(AccessMode::Read)+ )));+ assert!(!is_content_change_event(&EventKind::Access(+ AccessKind::Read+ )));+ assert!(!is_content_change_event(&EventKind::Access(+ AccessKind::Close(AccessMode::Read)+ )));+ assert!(!is_content_change_event(&EventKind::Access(+ AccessKind::Any+ )));}#[test]fn finished_writes_and_non_access_events_still_count() {- assert!(is_content_change_event(&EventKind::Access(AccessKind::Close(- AccessMode::Write- ))));- assert!(is_content_change_event(&EventKind::Create(CreateKind::File)));+ assert!(is_content_change_event(&EventKind::Access(+ AccessKind::Close(AccessMode::Write)+ )));+ assert!(is_content_change_event(&EventKind::Create(+ CreateKind::File+ )));assert!(is_content_change_event(&EventKind::Modify(ModifyKind::Any)));- assert!(is_content_change_event(&EventKind::Modify(ModifyKind::Name(- RenameMode::To- ))));- assert!(is_content_change_event(&EventKind::Remove(RemoveKind::File)));+ assert!(is_content_change_event(&EventKind::Modify(+ ModifyKind::Name(RenameMode::To)+ )));+ assert!(is_content_change_event(&EventKind::Remove(+ RemoveKind::File+ )));assert!(is_content_change_event(&EventKind::Any));assert!(is_content_change_event(&EventKind::Other));}diff --git a/src-tauri/src/cors.rs b/src-tauri/src/cors.rsindex 309da781..d5bedb29 100644--- a/src-tauri/src/cors.rs+++ b/src-tauri/src/cors.rs@@ -24,7 +24,11 @@ pub fn is_allowed_browser_origin(origin: &str) -> bool {pub fn local_cors_headers(origin: Option<&str>, allow_headers: &str) -> Vec<Header> {let mut headers = vec![- Header::from_bytes("Access-Control-Allow-Methods", "GET, POST, PATCH, OPTIONS").unwrap(),+ Header::from_bytes(+ "Access-Control-Allow-Methods",+ "GET, POST, PATCH, DELETE, OPTIONS",+ )+ .unwrap(),Header::from_bytes("Access-Control-Allow-Headers", allow_headers).unwrap(),Header::from_bytes("Content-Type", "application/json").unwrap(),];@@ -89,7 +93,7 @@ mod tests {);assert_eq!(header_value(&allowed, "Access-Control-Allow-Methods").as_deref(),- Some("GET, POST, PATCH, OPTIONS")+ Some("GET, POST, PATCH, DELETE, OPTIONS"));assert_eq!(header_value(&allowed, "Access-Control-Allow-Headers").as_deref(),diff --git a/src/lib/mineru.test.ts b/src/lib/mineru.test.tsindex 30f661a8..4a0a087c 100644--- a/src/lib/mineru.test.ts+++ b/src/lib/mineru.test.ts@@ -423,6 +423,39 @@ describe("parseWithMineru", () => {expect(mockHttpFetch.mock.calls[3]?.[1]?.headers).toEqual({ "X-Upload-Token": "signed" })})+ it("resolves relative V1 upload URLs below the V1 API base", async () => {+ mockHttpFetch+ .mockResolvedValueOnce(new Response("not found", { status: 404 }))+ .mockResolvedValueOnce(jsonResponse({ status: "ok" }))+ .mockResolvedValueOnce(jsonResponse({+ id: "upload-1",+ status: "pending",+ upload_url: "uploads/upload-1/content",+ upload_method: "PUT",+ }))+ .mockResolvedValueOnce(new Response(null, { status: 200 }))+ .mockResolvedValueOnce(jsonResponse({ status: "completed", file: { id: "source-1" } }))+ .mockResolvedValueOnce(jsonResponse({+ job_id: "job-1",+ status: "completed",+ files: [{ status: "completed", output_files: { zip: { file_id: "zip-1" } } }],+ }))+ .mockResolvedValueOnce(await zipResponse({ "full.md": "parsed" }))++ await parseWithMineru({+ enabled: true,+ backend: "local",+ localToken: "local-secret",+ localBackend: "hybrid-engine",+ token: "",+ modelVersion: "vlm",+ }, "/tmp/report.pdf")++ expect(mockHttpFetch.mock.calls[3]?.[0]).toBe(+ "http://127.0.0.1:8000/v1/uploads/upload-1/content",+ )+ })+it("submits a Windows-path PDF and pipeline mode to a custom local endpoint", async () => {mockHttpFetch.mockResolvedValueOnce(jsonResponse({diff --git a/src/lib/mineru.ts b/src/lib/mineru.tsindex 6f455957..f8ef4543 100644--- a/src/lib/mineru.ts+++ b/src/lib/mineru.ts@@ -775,7 +775,7 @@ async function parseWithLocalMineruV1(if (!uploadId || typeof upload.upload_url !== "string") {throw new Error("Local MinerU V1 returned an invalid upload session")}- const uploadUrl = new URL(upload.upload_url, apiBase).toString()+ const uploadUrl = new URL(upload.upload_url, `${apiBase}/`).toString()const returnedHeaders = upload.upload_headers && typeof upload.upload_headers === "object"? Object.fromEntries(Object.entries(upload.upload_headers).filter((entry): entry is [string, string] => typeof entry[1] === "string")): {}diff --git a/src/lib/wiki-page-delete.test.ts b/src/lib/wiki-page-delete.test.tsindex 295446c5..0ef311ea 100644--- a/src/lib/wiki-page-delete.test.ts+++ b/src/lib/wiki-page-delete.test.ts@@ -511,4 +511,20 @@ describe("cascadeDeleteWikiPagesWithRefs", () => {{ id: "general" },])})++ it("preserves case-distinct review paths on case-sensitive project paths", async () => {+ const target = `${PROJECT}/wiki/entities/Foo.md`+ mockReadFile.mockImplementation(async (path: string) => {+ if (path === target) return "---\ntitle: Foo\n---\n"+ throw new Error(`unexpected read ${path}`)+ })+ mockListDirectory.mockResolvedValueOnce([])+ mockLoadReviewItems.mockResolvedValueOnce([+ { id: "lowercase", affectedPages: ["entities/foo.md"] },+ ])++ await cascadeDeleteWikiPagesWithRefs(PROJECT, [target])++ expect(mockSaveReviewItems).not.toHaveBeenCalled()+ })})diff --git a/src/lib/wiki-page-delete.ts b/src/lib/wiki-page-delete.tsindex d2244f94..25132378 100644--- a/src/lib/wiki-page-delete.ts+++ b/src/lib/wiki-page-delete.ts@@ -134,12 +134,19 @@ async function pruneDeletedPagesFromReviews(projectPath: string,deletedPaths: readonly string[],): Promise<void> {- const deleted = new Set(deletedPaths.map((path) => normalizePath(path).toLowerCase()))+ const pathKey = (path: string) => {+ const normalized = normalizePath(path)+ return /^[A-Za-z]:\//.test(normalized) || normalized.startsWith("//")+ ? normalized.toLowerCase()+ : normalized+ }+ const projectKey = pathKey(projectPath)+ const deleted = new Set(deletedPaths.map(pathKey))const toAbsolute = (path: string) => {const normalized = normalizePath(path)- if (normalized.startsWith(`${projectPath}/`)) return normalized.toLowerCase()+ if (pathKey(normalized).startsWith(`${projectKey}/`)) return pathKey(normalized)const relative = normalized.replace(/^wiki\//i, "")- return `${projectPath}/wiki/${relative}`.toLowerCase()+ return pathKey(`${projectPath}/wiki/${relative}`)}try {const reviews = await loadReviewItems(projectPath)@@ -154,7 +161,7 @@ async function pruneDeletedPagesFromReviews(if (!changed) returnawait saveReviewItems(projectPath, remaining)const activeProject = (await import("@/stores/wiki-store")).useWikiStore.getState().project- if (activeProject && normalizePath(activeProject.path) === projectPath) {+ if (activeProject && pathKey(activeProject.path) === projectKey) {useReviewStore.getState().setItems(remaining)}} catch (err) {