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
feat: configure concurrent ingest workers
nash_sua96a8989c551
diff --git a/src/App.tsx b/src/App.tsxindex a1ea47e0..bb020152 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -13,6 +13,7 @@ import { getLastProject, getRecentProjects, saveLastProject, loadLlmConfig, loadimport { loadReviewItems, loadLintItems, loadChatHistory, loadChatPreferences } from "@/lib/persist"import { setupAutoSave } from "@/lib/auto-save"import { startClipWatcher } from "@/lib/clip-watcher"+import { DEFAULT_SOURCE_WATCH_CONFIG } from "@/lib/source-watch-config"import { useGlobalShortcut } from "@/hooks/use-global-shortcut"import { AppLayout } from "@/components/layout/app-layout"import { WelcomeScreen } from "@/components/project/welcome-screen"@@ -467,6 +468,21 @@ function App() {useWikiStore.getState().bumpDataVersion()await saveLastProject(proj)+ // Apply the project-specific worker limit before restoring its queue so+ // newly enqueued tasks never start with another project's concurrency.+ const { setIngestWorkerLimit } = await import("@/lib/ingest-queue")+ try {+ const config = await loadSourceWatchConfig(proj.id)+ if (!isCurrentProject(proj)) return+ useWikiStore.getState().setSourceWatchConfig(config)+ setIngestWorkerLimit(config.ingestConcurrency)+ } catch (err) {+ console.error("Failed to load ingest concurrency:", err)+ if (!isCurrentProject(proj)) return+ useWikiStore.getState().setSourceWatchConfig(DEFAULT_SOURCE_WATCH_CONFIG)+ setIngestWorkerLimit(DEFAULT_SOURCE_WATCH_CONFIG.ingestConcurrency)+ }+// Restore ingest queue (resume interrupted tasks). Keyed by the// project's stable UUID so the queue still finds the right project// even if the filesystem path changed since the task was enqueued.diff --git a/src/components/settings/sections/source-watch-section.tsx b/src/components/settings/sections/source-watch-section.tsxindex da40096e..0a92cf29 100644--- a/src/components/settings/sections/source-watch-section.tsx+++ b/src/components/settings/sections/source-watch-section.tsx@@ -124,7 +124,30 @@ export function SourceWatchSection({ draft, setDraft, projectReady }: Props) {<p className="text-xs leading-relaxed text-muted-foreground">{t("settings.sections.sourceWatch.parsingConcurrencyDescription", {defaultValue:- "Parse up to this many imported documents at once before sequential Wiki generation. PDF parsing remains internally serialized for safety.",+ "Parse up to this many imported documents at once. PDF parsing remains internally serialized for safety.",+ })}+ </p>+ </label>++ <label className="block space-y-1.5">+ <span className="text-sm font-semibold">+ {t("settings.sections.sourceWatch.ingestConcurrency", {+ defaultValue: "Concurrent ingest tasks",+ })}+ </span>+ <input+ type="number"+ min={1}+ max={5}+ value={config.ingestConcurrency}+ onChange={(event) => updateConfig({ ingestConcurrency: Number(event.target.value) || 1 })}+ disabled={!projectReady}+ className="w-24 rounded-md border border-input bg-background px-2 py-1 text-sm"+ />+ <p className="text-xs leading-relaxed text-muted-foreground">+ {t("settings.sections.sourceWatch.ingestConcurrencyDescription", {+ defaultValue:+ "Prepare this many sources in parallel. Wiki writes remain ordered. Higher values use more LLM capacity and memory.",})}</p></label>diff --git a/src/components/settings/settings-view.tsx b/src/components/settings/settings-view.tsxindex fba479a3..000b316e 100644--- a/src/components/settings/settings-view.tsx+++ b/src/components/settings/settings-view.tsx@@ -29,6 +29,7 @@ import { loadSourceWatchConfig, saveLanguage, saveTheme, loadTheme } from "@/libimport { applyTheme, type AppTheme } from "@/lib/theme"import type { SettingsDraft, DraftSetter } from "./settings-types"import { normalizeSourceWatchConfig } from "@/lib/source-watch-config"+import { setIngestWorkerLimit } from "@/lib/ingest-queue"import { LlmProviderSection } from "./sections/llm-provider-section"import { EmbeddingSection } from "./sections/embedding-section"import { MultimodalSection } from "./sections/multimodal-section"@@ -261,11 +262,13 @@ export function SettingsView() {if (cancelled) returnconst normalized = normalizeSourceWatchConfig(config)setSourceWatchConfig(normalized)+ setIngestWorkerLimit(normalized.ingestConcurrency)setDraftState((prev) => ({ ...prev, sourceWatchConfig: normalized }))}).catch(() => {if (cancelled) returnconst fallback = normalizeSourceWatchConfig()setSourceWatchConfig(fallback)+ setIngestWorkerLimit(fallback.ingestConcurrency)setDraftState((prev) => ({ ...prev, sourceWatchConfig: fallback }))})return () => {@@ -449,6 +452,7 @@ export function SettingsView() {setOutputLanguage(draft.outputLanguage as typeof outputLanguage)setProxyConfig(newProxy)setSourceWatchConfig(newSourceWatch)+ setIngestWorkerLimit(newSourceWatch.ingestConcurrency)setScheduledImportConfig(newScheduledImport)setMaxHistoryMessages(draft.maxHistoryMessages)setMineruConfig(newMineruConfig)diff --git a/src/i18n/en.json b/src/i18n/en.jsonindex b1b2e549..04d3da5c 100644--- a/src/i18n/en.json+++ b/src/i18n/en.json@@ -724,7 +724,9 @@"persistExtractedMarkdown": "Keep parsed Markdown","persistExtractedMarkdownDescription": "Save extracted document text under raw/parsed using the same folder structure as raw/sources.","parsingConcurrency": "Concurrent document parsers",- "parsingConcurrencyDescription": "Parse up to this many imported documents at once before sequential Wiki generation. PDF parsing remains internally serialized for safety.",+ "parsingConcurrencyDescription": "Parse up to this many imported documents at once. PDF parsing remains internally serialized for safety.",+ "ingestConcurrency": "Concurrent ingest tasks",+ "ingestConcurrencyDescription": "Prepare this many sources in parallel. Wiki writes remain ordered. Higher values use more LLM capacity and memory.","noProject": "Open a project to change this project-level setting.","fileTypes": "Allowed file types","fileTypesDescription": "Document types are enabled by default. Media, binaries, source code, and config-like formats stay off unless selected.",diff --git a/src/i18n/it.json b/src/i18n/it.jsonindex 17cee631..794a11e6 100644--- a/src/i18n/it.json+++ b/src/i18n/it.json@@ -724,7 +724,9 @@"persistExtractedMarkdown": "Conserva il Markdown estratto","persistExtractedMarkdownDescription": "Salva il testo estratto dai documenti sotto raw/parsed con la stessa struttura di cartelle di raw/sources.","parsingConcurrency": "Parser di documenti in parallelo",- "parsingConcurrencyDescription": "Analizza fino a questo numero di documenti importati alla volta, prima della generazione sequenziale del wiki. Per sicurezza l'analisi dei PDF resta serializzata internamente.",+ "parsingConcurrencyDescription": "Analizza fino a questo numero di documenti importati alla volta. Per sicurezza l'analisi dei PDF resta serializzata internamente.",+ "ingestConcurrency": "Attività di importazione simultanee",+ "ingestConcurrencyDescription": "Prepara questo numero di fonti in parallelo. Le scritture nel wiki restano ordinate. Valori superiori usano più capacità del modello e memoria.","noProject": "Apri un progetto per modificare questa impostazione di progetto.","fileTypes": "Tipi di file consentiti","fileTypesDescription": "I tipi documento sono attivi per impostazione predefinita. Media, binari, codice sorgente e formati di configurazione restano disattivi se non selezionati.",diff --git a/src/i18n/ru.json b/src/i18n/ru.jsonindex ea20068d..47ec674e 100644--- a/src/i18n/ru.json+++ b/src/i18n/ru.json@@ -724,7 +724,9 @@"persistExtractedMarkdown": "Сохранять извлечённый Markdown","persistExtractedMarkdownDescription": "Сохранять извлечённый текст документов в raw/parsed по той же структуре папок, что и raw/sources.","parsingConcurrency": "Параллельные парсеры документов",- "parsingConcurrencyDescription": "Обрабатывать одновременно до этого количества импортированных документов перед последовательной генерацией вики. Разбор PDF для безопасности остаётся последовательным.",+ "parsingConcurrencyDescription": "Обрабатывать одновременно до этого количества импортированных документов. Разбор PDF для безопасности остаётся последовательным.",+ "ingestConcurrency": "Параллельные задачи импорта",+ "ingestConcurrencyDescription": "Подготавливать столько источников параллельно. Запись в вики сохраняет порядок. Большие значения требуют больше ресурсов модели и памяти.","noProject": "Откройте проект, чтобы изменить эту настройку уровня проекта.","fileTypes": "Разрешённые типы файлов","fileTypesDescription": "Типы документов включены по умолчанию. Медиа, бинарные файлы, исходный код и конфигурационные форматы остаются выключенными, пока их не выберут.",diff --git a/src/i18n/zh.json b/src/i18n/zh.jsonindex f4868e2e..60aa858c 100644--- a/src/i18n/zh.json+++ b/src/i18n/zh.json@@ -724,7 +724,9 @@"persistExtractedMarkdown": "保留解析后的 Markdown","persistExtractedMarkdownDescription": "将文档解析出的文本按 raw/sources 的目录结构保存到 raw/parsed。","parsingConcurrency": "文档解析并发数",- "parsingConcurrencyDescription": "进入串行 Wiki 生成前,最多同时解析这些文档。为保证安全,PDF 解析器内部仍会串行执行。",+ "parsingConcurrencyDescription": "最多同时解析这些数量的导入文档。为保证安全,PDF 解析器内部仍会串行执行。",+ "ingestConcurrency": "资料提取并发数",+ "ingestConcurrencyDescription": "同时准备这些数量的原始资料,Wiki 写入仍会保持顺序。更高的数值会占用更多模型容量和内存。","noProject": "打开项目后才能修改这个项目级设置。","fileTypes": "允许的文件类型","fileTypesDescription": "常见文档类型默认开启。媒体、二进制、源码和配置类格式默认关闭,需要时再手动选择。",diff --git a/src/lib/ingest-queue.test.ts b/src/lib/ingest-queue.test.tsindex 5ec3126d..ad058a25 100644--- a/src/lib/ingest-queue.test.ts+++ b/src/lib/ingest-queue.test.ts@@ -72,6 +72,7 @@ import {resumeProcessing,isQueuePaused,setIngestWorkerLimit,+ getIngestWorkerLimit,} from "./ingest-queue"import { autoIngest } from "./ingest"import { readFile, writeFile } from "@/commands/fs"@@ -118,6 +119,15 @@ beforeEach(async () => {})describe("ingest-queue — enqueue & basic processing", () => {+ it("clamps the configurable worker limit", () => {+ setIngestWorkerLimit(0)+ expect(getIngestWorkerLimit()).toBe(1)+ setIngestWorkerLimit(99)+ expect(getIngestWorkerLimit()).toBe(5)+ setIngestWorkerLimit(2.9)+ expect(getIngestWorkerLimit()).toBe(2)+ })+it("persists inactive-project tasks and starts them when that project opens", async () => {const ids = await enqueueInactiveProjectBatch(TEST_ID_B, TEST_PATH_B, [{diff --git a/src/lib/project-file-sync.test.ts b/src/lib/project-file-sync.test.tsindex 10a3a48e..ac7de743 100644--- a/src/lib/project-file-sync.test.ts+++ b/src/lib/project-file-sync.test.ts@@ -469,6 +469,7 @@ describe("project file sync", () => {autoIngest: true,persistExtractedMarkdown: false,parsingConcurrency: 2,+ ingestConcurrency: 1,includeExtensions: ["md", "xml"],excludeExtensions: [],excludeDirs: [],diff --git a/src/lib/source-lifecycle.test.ts b/src/lib/source-lifecycle.test.tsindex 086e3047..6d3cfd9c 100644--- a/src/lib/source-lifecycle.test.ts+++ b/src/lib/source-lifecycle.test.ts@@ -108,6 +108,7 @@ describe("source-lifecycle path helpers", () => {autoIngest: true,persistExtractedMarkdown: false,parsingConcurrency: 2,+ ingestConcurrency: 1,includeExtensions: ["md"],excludeExtensions: ["json"],excludeDirs: ["drafts"],@@ -169,6 +170,7 @@ describe("source-lifecycle path helpers", () => {autoIngest: true,persistExtractedMarkdown: false,parsingConcurrency: 2,+ ingestConcurrency: 1,includeExtensions: ["json", "yaml", "md"],excludeExtensions: [],excludeDirs: [],@@ -239,6 +241,7 @@ describe("source-lifecycle path helpers", () => {autoIngest: true,persistExtractedMarkdown: false,parsingConcurrency: 2,+ ingestConcurrency: 1,includeExtensions: ["md"],excludeExtensions: [],excludeDirs: ["drafts"],@@ -276,6 +279,7 @@ describe("source-lifecycle path helpers", () => {autoIngest: true,persistExtractedMarkdown: false,parsingConcurrency: 2,+ ingestConcurrency: 1,includeExtensions: ["md", "pdf"],excludeExtensions: [],excludeDirs: [],@@ -360,6 +364,7 @@ describe("source-lifecycle path helpers", () => {autoIngest: true,persistExtractedMarkdown: false,parsingConcurrency: 2,+ ingestConcurrency: 1,includeExtensions: ["md"],excludeExtensions: [],excludeDirs: [],diff --git a/src/lib/source-watch-config.test.ts b/src/lib/source-watch-config.test.tsindex 3da401f0..5b25c89c 100644--- a/src/lib/source-watch-config.test.ts+++ b/src/lib/source-watch-config.test.ts@@ -16,13 +16,19 @@ describe("source watch config", () => {expect(DEFAULT_SOURCE_WATCH_CONFIG).toEqual(sourceWatchDefaults)expect(normalizeSourceWatchConfig({}).persistExtractedMarkdown).toBe(false)expect(normalizeSourceWatchConfig({}).parsingConcurrency).toBe(2)+ expect(normalizeSourceWatchConfig({}).ingestConcurrency).toBe(1)expect(normalizeSourceWatchConfig({ persistExtractedMarkdown: true }).persistExtractedMarkdown,).toBe(true)expect(normalizeSourceWatchConfig({ parsingConcurrency: 20 }).parsingConcurrency).toBe(8)+ expect(normalizeSourceWatchConfig({ ingestConcurrency: 20 }).ingestConcurrency).toBe(5)+ expect(normalizeSourceWatchConfig({ ingestConcurrency: 0 }).ingestConcurrency).toBe(1)expect(normalizeSourceWatchConfig({ parsingConcurrency: Number.NaN }).parsingConcurrency,).toBe(2)+ expect(+ normalizeSourceWatchConfig({ ingestConcurrency: Number.NaN }).ingestConcurrency,+ ).toBe(1)})it("allows document types by default and rejects config/media/binaries", () => {diff --git a/src/lib/source-watch-config.ts b/src/lib/source-watch-config.tsindex 5b758dc7..bdf7c5a7 100644--- a/src/lib/source-watch-config.ts+++ b/src/lib/source-watch-config.ts@@ -47,12 +47,18 @@ export function normalizeSourceWatchConfig(config?: Partial<SourceWatchConfig> |const parsingConcurrency = Number.isFinite(rawParsingConcurrency)? Math.max(1, Math.min(8, Math.floor(rawParsingConcurrency))): DEFAULT_SOURCE_WATCH_CONFIG.parsingConcurrency+ const rawIngestConcurrency = config?.ingestConcurrency+ ?? DEFAULT_SOURCE_WATCH_CONFIG.ingestConcurrency+ const ingestConcurrency = Number.isFinite(rawIngestConcurrency)+ ? Math.max(1, Math.min(5, Math.floor(rawIngestConcurrency)))+ : DEFAULT_SOURCE_WATCH_CONFIG.ingestConcurrencyreturn {enabled: config?.enabled ?? DEFAULT_SOURCE_WATCH_CONFIG.enabled,autoIngest: config?.autoIngest ?? DEFAULT_SOURCE_WATCH_CONFIG.autoIngest,persistExtractedMarkdown:config?.persistExtractedMarkdown ?? DEFAULT_SOURCE_WATCH_CONFIG.persistExtractedMarkdown,parsingConcurrency,+ ingestConcurrency,includeExtensions: normalizeExtensions(config?.includeExtensions ?? DEFAULT_SOURCE_WATCH_CONFIG.includeExtensions),excludeExtensions: normalizeExtensions(config?.excludeExtensions ?? DEFAULT_SOURCE_WATCH_CONFIG.excludeExtensions),excludeDirs: normalizeList(config?.excludeDirs ?? DEFAULT_SOURCE_WATCH_CONFIG.excludeDirs),diff --git a/src/lib/source-watch-defaults.json b/src/lib/source-watch-defaults.jsonindex 9fc25172..4916f90a 100644--- a/src/lib/source-watch-defaults.json+++ b/src/lib/source-watch-defaults.json@@ -3,6 +3,7 @@"autoIngest": true,"persistExtractedMarkdown": false,"parsingConcurrency": 2,+ "ingestConcurrency": 1,"includeExtensions": ["md","mdx",diff --git a/src/stores/wiki-store.ts b/src/stores/wiki-store.tsindex b709dbd0..7a408f32 100644--- a/src/stores/wiki-store.ts+++ b/src/stores/wiki-store.ts@@ -264,6 +264,8 @@ interface SourceWatchConfig {persistExtractedMarkdown: boolean/** Maximum number of source text extraction jobs allowed at once. */parsingConcurrency: number+ /** Maximum number of ingest tasks allowed to prepare concurrently. */+ ingestConcurrency: numberincludeExtensions: string[]excludeExtensions: string[]excludeDirs: string[]