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

refactor: scheduled import path now relative to project

skfan13540deba1f2007
diff --git a/src/components/settings/sections/scheduled-import-section.tsx b/src/components/settings/sections/scheduled-import-section.tsx
index 7d589087..554cf328 100644
--- a/src/components/settings/sections/scheduled-import-section.tsx
+++ b/src/components/settings/sections/scheduled-import-section.tsx
@@ -7,7 +7,7 @@ import { Button } from "@/components/ui/button"
import { Folder, Play, RefreshCw } from "lucide-react"
import type { SettingsDraft, DraftSetter } from "../settings-types"
import { useWikiStore } from "@/stores/wiki-store"
-import { startScheduledImport, stopScheduledImport, scanAndImport } from "@/lib/scheduled-import"
+import { startScheduledImport, stopScheduledImport, scanAndImport, resolveImportPath } from "@/lib/scheduled-import"
interface Props {
draft: SettingsDraft
@@ -34,11 +34,13 @@ export function ScheduledImportSection({ draft, setDraft }: Props) {
}
const handleManualScan = useCallback(async () => {
- if (!project || !draft.scheduledImportPath || isScanning) return
+ if (!project || isScanning) return
+
+ const resolvedPath = resolveImportPath(project.path, draft.scheduledImportPath)
setIsScanning(true)
try {
- await scanAndImport(project.path, draft.scheduledImportPath)
+ await scanAndImport(project.path, resolvedPath)
} catch (err) {
console.error("[Scheduled Import] Manual scan failed:", err)
} finally {
@@ -110,7 +112,7 @@ export function ScheduledImportSection({ draft, setDraft }: Props) {
<Input
value={draft.scheduledImportPath}
onChange={(e) => setDraft("scheduledImportPath", e.target.value)}
- placeholder={project ? `${project.path}/raw` : "/path/to/monitor"}
+ placeholder="raw"
disabled={!draft.scheduledImportEnabled}
className="flex-1"
/>
diff --git a/src/components/settings/settings-view.tsx b/src/components/settings/settings-view.tsx
index 6927b5c4..da43e78d 100644
--- a/src/components/settings/settings-view.tsx
+++ b/src/components/settings/settings-view.tsx
@@ -79,10 +79,11 @@ function initialDraft(
scheduledImport: ReturnType<typeof useWikiStore.getState>["scheduledImportConfig"],
maxHistoryMessages: number,
uiLanguage: string,
- projectPath?: string,
): SettingsDraft {
- // Default scheduled import path to project/raw if not set
- const defaultImportPath = scheduledImport.path || (projectPath ? `${projectPath}/raw` : "")
+ // Resolve the display path: if path is empty, show default "raw"
+ // If path is relative, show it as-is (user sees relative path)
+ // If path is absolute, show it as-is
+ const displayPath = scheduledImport.path || "raw"
return {
provider: llm.provider,
@@ -115,7 +116,7 @@ function initialDraft(
proxyUrl: proxy.url,
proxyBypassLocal: proxy.bypassLocal,
scheduledImportEnabled: scheduledImport.enabled,
- scheduledImportPath: defaultImportPath,
+ scheduledImportPath: displayPath,
scheduledImportInterval: scheduledImport.interval,
uiLanguage,
}
@@ -123,7 +124,6 @@ function initialDraft(
export function SettingsView() {
const { t } = useTranslation()
- const project = useWikiStore((s) => s.project)
const llmConfig = useWikiStore((s) => s.llmConfig)
const setLlmConfig = useWikiStore((s) => s.setLlmConfig)
const searchApiConfig = useWikiStore((s) => s.searchApiConfig)
@@ -163,7 +163,6 @@ export function SettingsView() {
scheduledImportConfig,
maxHistoryMessages,
i18n.language,
- project?.path,
),
)
@@ -187,7 +186,6 @@ export function SettingsView() {
scheduledImportConfig,
maxHistoryMessages,
prev.uiLanguage,
- project?.path,
),
)
}, [
@@ -199,7 +197,6 @@ export function SettingsView() {
proxyConfig,
scheduledImportConfig,
maxHistoryMessages,
- project,
])
const setDraft: DraftSetter = useCallback((key, value) => {
diff --git a/src/i18n/en.json b/src/i18n/en.json
index fe8a545e..6dede40f 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -202,7 +202,7 @@
"description": "Automatically monitor a directory and import new or modified files at regular intervals.",
"enable": "Enable scheduled import",
"directory": "Monitor Directory",
- "directoryHelp": "Files in this directory (and subdirectories) will be automatically imported. New files are copied to sources; modified files are re-ingested. Defaults to the project's raw/ directory.",
+ "directoryHelp": "Relative path from project root (e.g., 'raw', 'docs/input'). Files in this directory will be automatically imported. Defaults to 'raw'.",
"browse": "Browse",
"selectDirectory": "Select Directory to Monitor",
"interval": "Scan Interval (minutes)",
diff --git a/src/i18n/zh.json b/src/i18n/zh.json
index 6595da97..95c06f3f 100644
--- a/src/i18n/zh.json
+++ b/src/i18n/zh.json
@@ -202,7 +202,7 @@
"description": "自动监控指定目录,按固定间隔导入新增或修改的文件。",
"enable": "启用定时导入",
"directory": "监控目录",
- "directoryHelp": "该目录(含子目录)中的文件将被自动导入。新文件会复制到 sources;修改过的文件会重新摄入。默认为项目下的 raw/ 目录。",
+ "directoryHelp": "相对于项目根目录的路径(如 'raw'、'docs/input')。该目录中的文件将被自动导入。默认为 'raw'。",
"browse": "浏览",
"selectDirectory": "选择监控目录",
"interval": "扫描间隔(分钟)",
diff --git a/src/lib/scheduled-import.ts b/src/lib/scheduled-import.ts
index 8af03928..2458cb44 100644
--- a/src/lib/scheduled-import.ts
+++ b/src/lib/scheduled-import.ts
@@ -198,20 +198,37 @@ export async function scanAndImport(projectPath: string, importPath: string): Pr
}
}
+/**
+ * Resolve the absolute path for scheduled import.
+ * If the config path is relative (not absolute), prepend the project path.
+ * If the config path is empty, use the default "raw" directory.
+ */
+export function resolveImportPath(projectPath: string, configPath: string): string {
+ const pp = normalizePath(projectPath)
+ // Default to "raw" if path is empty
+ const path = configPath || "raw"
+ // If path is already absolute, use it as-is
+ if (path.startsWith("/") || path.match(/^[a-zA-Z]:\\/)) {
+ return normalizePath(path)
+ }
+ // Otherwise, treat as relative to project path
+ return `${pp}/${path}`
+}
+
/**
* Start the scheduled import timer.
*/
export function startScheduledImport(projectPath: string, config: ScheduledImportConfig): void {
stopScheduledImport()
- if (!config.enabled || !config.path || config.interval <= 0) {
+ if (!config.enabled || config.interval <= 0) {
return
}
const pp = normalizePath(projectPath)
- const ip = normalizePath(config.path)
+ const ip = resolveImportPath(pp, config.path)
- console.log(`[Scheduled Import] Starting with interval ${config.interval} minutes`)
+ console.log(`[Scheduled Import] Starting with interval ${config.interval} minutes, path: ${ip}`)
// Run first scan immediately
scanAndImport(pp, ip).catch((err) => {
diff --git a/src/stores/wiki-store.ts b/src/stores/wiki-store.ts
index 6c9dbcdb..f6e16caa 100644
--- a/src/stores/wiki-store.ts
+++ b/src/stores/wiki-store.ts
@@ -89,7 +89,7 @@ interface ProxyConfig {
interface ScheduledImportConfig {
enabled: boolean
- path: string // 监控目录的绝对路径
+ path: string // 监控目录的相对路径(相对于项目根目录),空字符串表示使用默认的 "raw"
interval: number // 扫描间隔(分钟)
lastScan: number | null // 上次扫描时间戳
}