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: harden dialogs and lint configuration
nash_sueb5302cd77b6
diff --git a/src/components/app-dialog-host.tsx b/src/components/app-dialog-host.tsxindex 39976cec..ea908daf 100644--- a/src/components/app-dialog-host.tsx+++ b/src/components/app-dialog-host.tsx@@ -23,7 +23,7 @@ export function AppDialogHost() {key={current.id}openonOpenChange={(open) => {- if (!open) settle(false)+ if (!open) settle(current.id, false)}}><DialogContent showCloseButton={false}>@@ -37,13 +37,13 @@ export function AppDialogHost() {</DialogHeader><DialogFooter>{current.kind === "confirm" && (- <Button variant="outline" onClick={() => settle(false)}>+ <Button variant="outline" onClick={() => settle(current.id, false)}>{current.cancelLabel ?? t("common.cancel")}</Button>)}<Buttonvariant={destructive ? "destructive" : "default"}- onClick={() => settle(true)}+ onClick={() => settle(current.id, true)}autoFocus>{current.confirmLabel ?? t("common.ok")}diff --git a/src/components/lint/lint-view.tsx b/src/components/lint/lint-view.tsxindex ce2060a7..f08ba6b7 100644--- a/src/components/lint/lint-view.tsx+++ b/src/components/lint/lint-view.tsx@@ -97,9 +97,14 @@ export function LintView() {useEffect(() => {let active = true+ // Do not expose the previous project's draft while this project's config+ // is loading, and do not carry a completed save's busy state across a+ // project switch.+ setLintConfig(DEFAULT_LINT_CONFIG)+ setIgnoredPagesDraft("")+ setSavingConfig(false)+ setConfigError(null)if (!project) {- setLintConfig(DEFAULT_LINT_CONFIG)- setIgnoredPagesDraft("")return () => { active = false }}const projectPath = project.pathdiff --git a/src/lib/lint-structural-core.test.ts b/src/lib/lint-structural-core.test.tsindex b9cbc83b..4c5affaa 100644--- a/src/lib/lint-structural-core.test.ts+++ b/src/lib/lint-structural-core.test.ts@@ -56,4 +56,15 @@ describe("computeStructuralLint", () => {expect(findings.some((finding) => finding.page === "folder/ignored.md")).toBe(false)expect(findings.some((finding) => finding.type === "broken-link" && finding.brokenTarget === "folder/ignored")).toBe(false)})++ it("does not apply a top-level ignored slug to same-named nested pages", () => {+ const pages = [+ { ...page(0, 2), shortName: "foo.md", slug: "foo", outlinks: [] },+ { ...page(1, 2), shortName: "archive/foo.md", slug: "archive/foo", outlinks: [] },+ ]+ const findings = computeStructuralLint(pages, undefined, { ignorePages: ["foo"] })++ expect(findings.some((finding) => finding.page === "foo.md")).toBe(false)+ expect(findings.some((finding) => finding.page === "archive/foo.md")).toBe(true)+ })})diff --git a/src/lib/lint-structural-core.ts b/src/lib/lint-structural-core.tsindex 7ec86c88..c1847004 100644--- a/src/lib/lint-structural-core.ts+++ b/src/lib/lint-structural-core.ts@@ -181,7 +181,9 @@ export function computeStructuralLint(const results: StructuralLintFinding[] = []const ignoredPages = new Set((config.ignorePages ?? []).map(normalizeTarget).filter(Boolean))pages.forEach((page, pageIndex) => {- const pageKeys = [page.slug, page.shortName, fileName(page.shortName).replace(/\.md$/i, "")]+ // Ignore entries are slugs/paths. Do not match a bare basename against+ // every nested page with that name ("foo" must not hide "archive/foo").+ const pageKeys = [page.slug, page.shortName].map(normalizeTarget)const ignored = pageKeys.some((key) => ignoredPages.has(key))if (!ignored && !config.ignoreOrphan && !inboundCounts.has(pageIndex)) {diff --git a/src/stores/app-dialog-store.test.ts b/src/stores/app-dialog-store.test.tsindex 08e381ee..b733e27b 100644--- a/src/stores/app-dialog-store.test.ts+++ b/src/stores/app-dialog-store.test.ts@@ -14,19 +14,35 @@ describe("app dialog store", () => {expect(useAppDialogStore.getState().current?.message).toBe("first")expect(useAppDialogStore.getState().queue).toHaveLength(1)- useAppDialogStore.getState().settle(true)+ const firstId = useAppDialogStore.getState().current!.id+ useAppDialogStore.getState().settle(firstId, true)await expect(first).resolves.toBe(true)expect(useAppDialogStore.getState().current?.message).toBe("second")- useAppDialogStore.getState().settle(false)+ useAppDialogStore.getState().settle(useAppDialogStore.getState().current!.id, false)await expect(second).resolves.toBe(false)expect(useAppDialogStore.getState().current).toBeNull()})it("resolves alerts after dismissal", async () => {const pending = useAppDialog().alert({ message: "notice" })- useAppDialogStore.getState().settle(false)+ useAppDialogStore.getState().settle(useAppDialogStore.getState().current!.id, false)await expect(pending).resolves.toBeUndefined()})-})+ it("ignores stale events from the previous dialog", async () => {+ const dialogs = useAppDialog()+ const first = dialogs.confirm({ message: "first" })+ const second = dialogs.confirm({ message: "second" })+ const firstId = useAppDialogStore.getState().current!.id++ useAppDialogStore.getState().settle(firstId, true)+ useAppDialogStore.getState().settle(firstId, true)++ await expect(first).resolves.toBe(true)+ expect(useAppDialogStore.getState().current?.message).toBe("second")+ expect(useAppDialogStore.getState().queue).toHaveLength(0)+ useAppDialogStore.getState().settle(useAppDialogStore.getState().current!.id, false)+ await expect(second).resolves.toBe(false)+ })+})diff --git a/src/stores/app-dialog-store.ts b/src/stores/app-dialog-store.tsindex 01fde187..cb60fddb 100644--- a/src/stores/app-dialog-store.ts+++ b/src/stores/app-dialog-store.ts@@ -20,7 +20,7 @@ interface AppDialogState {current: DialogRequest | nullqueue: DialogRequest[]enqueue: (request: DialogRequest) => void- settle: (value: boolean) => void+ settle: (requestId: number, value: boolean) => void}export const useAppDialogStore = create<AppDialogState>((set, get) => ({@@ -33,9 +33,12 @@ export const useAppDialogStore = create<AppDialogState>((set, get) => ({}set((state) => ({ queue: [...state.queue, request] }))},- settle: (value) => {+ settle: (requestId, value) => {const { current, queue } = get()- if (!current) return+ // Events from a dialog that has just been replaced can arrive late (for+ // example a double-click or a closing transition). Never let an old host+ // settle the next queued confirmation.+ if (!current || current.id !== requestId) returnconst [next, ...rest] = queueset({ current: next ?? null, queue: rest })current.resolve(value)