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: address full review findings

nash_suc55cfe8e6185
diff --git a/src-tauri/src/api_server.rs b/src-tauri/src/api_server.rs
index ccc00bd7..7e23b1fb 100644
--- a/src-tauri/src/api_server.rs
+++ b/src-tauri/src/api_server.rs
@@ -2677,6 +2677,10 @@ fn build_graph_from_files(
let links = commands::search::extract_graph_links(&content);
raw.insert(id, (title, node_type, relative_path, links));
}
+ // Query pages are intermediate artifacts rather than graph nodes. Remove
+ // them before link resolution so the API cannot emit edges whose source
+ // or target is absent from the returned node set.
+ raw.retain(|_, (_, node_type, _, _)| node_type != "query");
let aliases = graph_aliases(&raw);
let mut link_count: BTreeMap<String, usize> = raw.keys().map(|id| (id.clone(), 0)).collect();
let mut seen = BTreeSet::new();
@@ -2707,7 +2711,6 @@ fn build_graph_from_files(
}
let nodes = raw
.into_iter()
- .filter(|(_, (_, node_type, _, _))| node_type != "query")
.map(|(id, (label, node_type, path, _))| ApiGraphNode {
link_count: *link_count.get(&id).unwrap_or(&0),
id,
@@ -2979,6 +2982,26 @@ mod tests {
let _ = fs::remove_dir_all(root);
}
+ #[test]
+ fn graph_drops_edges_to_hidden_query_pages() {
+ let root = test_project_dir();
+ fs::write(
+ root.join("wiki/source.md"),
+ "---\nrelated: [hidden]\n---\n# Source",
+ )
+ .unwrap();
+ fs::write(
+ root.join("wiki/hidden.md"),
+ "---\ntype: query\n---\n# Hidden\n[[source]]",
+ )
+ .unwrap();
+
+ let (nodes, edges) = build_graph(root.to_string_lossy().as_ref()).unwrap();
+ assert!(nodes.iter().all(|node| node.id != "hidden"));
+ assert!(edges.is_empty());
+ let _ = fs::remove_dir_all(root);
+ }
+
#[test]
fn graph_does_not_resolve_ambiguous_bare_stems() {
let root = test_project_dir();
diff --git a/src/components/graph/graph-view.tsx b/src/components/graph/graph-view.tsx
index 57139a79..2f4d03f1 100644
--- a/src/components/graph/graph-view.tsx
+++ b/src/components/graph/graph-view.tsx
@@ -1469,7 +1469,14 @@ export function GraphView() {
</span>
<span className="text-muted-foreground/60 ml-auto shrink-0">{c.nodeCount}</span>
{c.meanIntraDegree < 2 && c.nodeCount >= 3 && (
- <span className="text-amber-500 shrink-0" title={`Low internal connectivity: ${c.meanIntraDegree.toFixed(1)} links per page`}>!</span>
+ <span
+ className="text-amber-500 shrink-0"
+ title={t("graph.lowInternalConnectivity", {
+ count: c.meanIntraDegree.toFixed(1),
+ })}
+ >
+ !
+ </span>
)}
</div>
))}
diff --git a/src/components/review/review-view.tsx b/src/components/review/review-view.tsx
index 665a14b6..306acc6a 100644
--- a/src/components/review/review-view.tsx
+++ b/src/components/review/review-view.tsx
@@ -19,8 +19,8 @@ import { writeFile, readFile, deleteFile, fileExists } from "@/commands/fs"
import { normalizePath } from "@/lib/path-utils"
import { refreshProjectFileTree } from "@/lib/project-file-tree-refresh"
import { hasConfiguredDeepResearchSources } from "@/lib/web-search"
-import { makeQueryFileName, makeQuerySlug } from "@/lib/wiki-filename"
-import { createReviewPageDrafts, reviewPageFileName } from "@/lib/review-create-page"
+import { makeQueryFileName } from "@/lib/wiki-filename"
+import { availableReviewPageFileName, createReviewPageDrafts } from "@/lib/review-create-page"
import { cleanAssistantContentForWikiSave, titleFromCleanAssistantContent } from "@/lib/chat-save-to-wiki"
import { useTranslation } from "react-i18next"
import { useAppDialog } from "@/stores/app-dialog-store"
@@ -241,11 +241,9 @@ export function ReviewView() {
}> = []
for (const draft of drafts) {
- const baseFileName = `${makeQuerySlug(draft.title)}.md`
- const baseFilePath = `${pp}/wiki/${draft.dir}/${baseFileName}`
- const { date, fileName } = reviewPageFileName(
+ const { date, fileName } = await availableReviewPageFileName(
draft.title,
- await fileExists(baseFilePath),
+ (candidate) => fileExists(`${pp}/wiki/${draft.dir}/${candidate}`),
)
const filePath = `${pp}/wiki/${draft.dir}/${fileName}`
const frontmatter = `---\ntype: ${draft.pageType}\ntitle: "${draft.title.replace(/"/g, '\\"')}"\ncreated: ${date}\ntags: []\nrelated: []\n---\n\n`
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 148cb090..457594aa 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -1141,6 +1141,7 @@
"communitiesLabel": "Communities",
"showAll": "Show all",
"cluster": "Cluster {{id}}",
+ "lowInternalConnectivity": "Low internal connectivity: {{count}} links per page",
"surprisingConnections": "Surprising Connections",
"knowledgeGaps": "Knowledge Gaps",
"deepResearch": "Deep Research",
diff --git a/src/i18n/it.json b/src/i18n/it.json
index 0775a03d..5711f761 100644
--- a/src/i18n/it.json
+++ b/src/i18n/it.json
@@ -1141,6 +1141,7 @@
"communitiesLabel": "Comunità",
"showAll": "Mostra tutto",
"cluster": "Cluster {{id}}",
+ "lowInternalConnectivity": "Connettività interna bassa: {{count}} link per pagina",
"surprisingConnections": "Connessioni inaspettate",
"knowledgeGaps": "Lacune di conoscenza",
"deepResearch": "Deep Research",
diff --git a/src/i18n/ru.json b/src/i18n/ru.json
index 91ee0da3..80a591d7 100644
--- a/src/i18n/ru.json
+++ b/src/i18n/ru.json
@@ -1141,6 +1141,7 @@
"communitiesLabel": "Сообщества",
"showAll": "Показать все",
"cluster": "Кластер {{id}}",
+ "lowInternalConnectivity": "Слабая внутренняя связность: {{count}} ссылок на страницу",
"surprisingConnections": "Неожиданные связи",
"knowledgeGaps": "Пробелы в знаниях",
"deepResearch": "Глубокое исследование",
diff --git a/src/i18n/zh.json b/src/i18n/zh.json
index 98e6185c..adc9e3da 100644
--- a/src/i18n/zh.json
+++ b/src/i18n/zh.json
@@ -1141,6 +1141,7 @@
"communitiesLabel": "社区",
"showAll": "显示全部",
"cluster": "簇 {{id}}",
+ "lowInternalConnectivity": "内部连接较少:平均每页 {{count}} 条链接",
"surprisingConnections": "意外连接",
"knowledgeGaps": "知识缺口",
"deepResearch": "深度研究",
diff --git a/src/lib/review-create-page.test.ts b/src/lib/review-create-page.test.ts
index 3c9009bd..922bb69a 100644
--- a/src/lib/review-create-page.test.ts
+++ b/src/lib/review-create-page.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest"
import type { ReviewItem } from "@/stores/review-store"
-import { createReviewPageDrafts, reviewPageFileName } from "./review-create-page"
+import { availableReviewPageFileName, createReviewPageDrafts } from "./review-create-page"
function review(overrides: Partial<ReviewItem>): ReviewItem {
return {
@@ -48,18 +48,36 @@ describe("createReviewPageDrafts", () => {
})
})
-describe("reviewPageFileName", () => {
+describe("availableReviewPageFileName", () => {
const now = new Date("2026-09-16T12:34:56.000Z")
- it("uses a stable slug when the destination is free", () => {
- expect(reviewPageFileName("Clash Detection", false, now)).toEqual({
+ it("uses a stable slug when the destination is free", async () => {
+ await expect(availableReviewPageFileName("Clash Detection", async () => false, now)).resolves.toEqual({
fileName: "clash-detection.md",
date: "2026-09-16",
})
})
- it("adds a timestamp only when the stable slug already exists", () => {
- expect(reviewPageFileName("Clash Detection", true, now).fileName)
- .toBe("clash-detection-2026-09-16-123456.md")
+ it("adds a timestamp only when the stable slug already exists", async () => {
+ const result = await availableReviewPageFileName(
+ "Clash Detection",
+ async (fileName) => fileName === "clash-detection.md",
+ now,
+ )
+ expect(result.fileName).toBe("clash-detection-2026-09-16-123456.md")
+ })
+
+ it("adds a numeric suffix when both stable and timestamped names exist", async () => {
+ const existing = new Set([
+ "clash-detection.md",
+ "clash-detection-2026-09-16-123456.md",
+ "clash-detection-2026-09-16-123456-2.md",
+ ])
+ const result = await availableReviewPageFileName(
+ "Clash Detection",
+ async (fileName) => existing.has(fileName),
+ now,
+ )
+ expect(result.fileName).toBe("clash-detection-2026-09-16-123456-3.md")
})
})
diff --git a/src/lib/review-create-page.ts b/src/lib/review-create-page.ts
index 6ecccdeb..18fca571 100644
--- a/src/lib/review-create-page.ts
+++ b/src/lib/review-create-page.ts
@@ -97,14 +97,26 @@ export function createReviewPageDrafts(item: ReviewItem, action: string): Review
}))
}
-export function reviewPageFileName(
+export async function availableReviewPageFileName(
title: string,
- baseNameExists: boolean,
+ fileExists: (fileName: string) => Promise<boolean>,
now: Date = new Date(),
-): { fileName: string; date: string } {
+): Promise<{ fileName: string; date: string }> {
const timestamped = makeQueryFileName(title, now)
- return {
- fileName: baseNameExists ? timestamped.fileName : `${makeQuerySlug(title)}.md`,
- date: timestamped.date,
+ const stableName = `${makeQuerySlug(title)}.md`
+ if (!(await fileExists(stableName))) {
+ return { fileName: stableName, date: timestamped.date }
}
+ if (!(await fileExists(timestamped.fileName))) {
+ return { fileName: timestamped.fileName, date: timestamped.date }
+ }
+
+ const stem = timestamped.fileName.replace(/\.md$/, "")
+ for (let suffix = 2; suffix <= 10_000; suffix += 1) {
+ const candidate = `${stem}-${suffix}.md`
+ if (!(await fileExists(candidate))) {
+ return { fileName: candidate, date: timestamped.date }
+ }
+ }
+ throw new Error("Could not allocate a unique wiki page filename")
}