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: complete history and preview integration

nash_su72bbf451018a
diff --git a/src-tauri/src/agent/tools.rs b/src-tauri/src/agent/tools.rs
index f22af309..26158d0e 100644
--- a/src-tauri/src/agent/tools.rs
+++ b/src-tauri/src/agent/tools.rs
@@ -915,13 +915,23 @@ async fn run_shell_exec(
}
stderr.push_str(&message);
}
+ let generated_files = changed_workspace_files(&workspace, before_files);
+ for output in &generated_files {
+ if let Some(relative) = output.path.strip_prefix(&format!("{AGENT_WORKSPACE_DIR}/")) {
+ crate::commands::file_history::record_file_version(
+ &workspace.join(relative),
+ "agent",
+ "shell.exec",
+ );
+ }
+ }
Ok(ShellExecToolOutput {
command: command.to_string(),
exit_code,
stdout,
stderr,
timed_out,
- generated_files: changed_workspace_files(&workspace, before_files),
+ generated_files,
})
}
diff --git a/src/components/editor/file-history-panel.tsx b/src/components/editor/file-history-panel.tsx
index b6c1cfcb..a7a96f8f 100644
--- a/src/components/editor/file-history-panel.tsx
+++ b/src/components/editor/file-history-panel.tsx
@@ -1,10 +1,12 @@
import { useState } from "react"
+import { useTranslation } from "react-i18next"
import { Clock3, RotateCcw, X } from "lucide-react"
import { listFileHistory, restoreFileHistory, type FileHistoryEntry } from "@/commands/fs"
import { summarizeAgentFileChange } from "@/lib/agent-file-activity"
import { useWikiStore } from "@/stores/wiki-store"
export function FileHistoryButton({ filePath, currentContent }: { filePath: string; currentContent: string }) {
+ const { t } = useTranslation()
const project = useWikiStore((state) => state.project)
const openFileInPreview = useWikiStore((state) => state.openFileInPreview)
const [open, setOpen] = useState(false)
@@ -28,13 +30,13 @@ export function FileHistoryButton({ filePath, currentContent }: { filePath: stri
}).diff : ""
return <>
- <button type="button" onClick={() => void show()} className="absolute right-3 top-3 z-20 rounded-md border bg-background/90 p-1.5 text-muted-foreground shadow-sm hover:text-foreground" title="File history"><Clock3 className="h-4 w-4" /></button>
+ <button type="button" onClick={() => void show()} className="absolute right-3 top-3 z-20 rounded-md border bg-background/90 p-1.5 text-muted-foreground shadow-sm hover:text-foreground" title={t("preview.history")}><Clock3 className="h-4 w-4" /></button>
{open && <div className="absolute inset-0 z-40 flex bg-background">
<aside className="w-72 shrink-0 border-r p-3">
- <div className="mb-3 flex items-center justify-between"><strong className="text-sm">File history</strong><button type="button" onClick={() => setOpen(false)}><X className="h-4 w-4" /></button></div>
+ <div className="mb-3 flex items-center justify-between"><strong className="text-sm">{t("preview.history")}</strong><button type="button" onClick={() => setOpen(false)}><X className="h-4 w-4" /></button></div>
<div className="space-y-1 overflow-auto">
- {loading && <p className="text-xs text-muted-foreground">Loading...</p>}
- {!loading && entries.length === 0 && <p className="text-xs text-muted-foreground">No recorded versions yet.</p>}
+ {loading && <p className="text-xs text-muted-foreground">{t("preview.historyLoading")}</p>}
+ {!loading && entries.length === 0 && <p className="text-xs text-muted-foreground">{t("preview.historyEmpty")}</p>}
{entries.map((entry) => <button key={entry.id} type="button" onClick={() => setSelected(entry)} className={`w-full rounded border px-2 py-2 text-left text-xs ${selected?.id === entry.id ? "border-primary bg-primary/5" : "border-transparent hover:bg-muted"}`}>
<div className="font-medium">{entry.author} · {entry.tool}</div>
<div className="mt-1 text-[10px] text-muted-foreground">{new Date(entry.timestamp).toLocaleString()}</div>
@@ -46,7 +48,7 @@ export function FileHistoryButton({ filePath, currentContent }: { filePath: stri
const content = await restoreFileHistory(project.path, filePath, selected.id)
openFileInPreview(filePath, content)
setOpen(false)
- }}><RotateCcw className="h-3.5 w-3.5" />Restore this version</button></div><pre className="whitespace-pre-wrap break-words rounded-md bg-muted/40 p-3 font-mono text-xs">{diff}</pre></> : <div className="grid h-full place-items-center text-sm text-muted-foreground">Select a version to compare.</div>}
+ }}><RotateCcw className="h-3.5 w-3.5" />{t("preview.historyRestore")}</button></div><pre className="whitespace-pre-wrap break-words rounded-md bg-muted/40 p-3 font-mono text-xs">{diff}</pre></> : <div className="grid h-full place-items-center text-sm text-muted-foreground">{t("preview.historySelect")}</div>}
</main>
</div>}
</>
diff --git a/src/components/editor/file-preview.tsx b/src/components/editor/file-preview.tsx
index 95e44155..7604ed6d 100644
--- a/src/components/editor/file-preview.tsx
+++ b/src/components/editor/file-preview.tsx
@@ -95,6 +95,7 @@ function FilePreviewContent({ filePath, textContent }: FilePreviewProps) {
}
function PdfPreview({ filePath, content }: { filePath: string; content: string }) {
+ const { t } = useTranslation()
const [showText, setShowText] = useState(false)
const [page, setPage] = useState(1)
const [zoom, setZoom] = useState(100)
@@ -102,8 +103,8 @@ function PdfPreview({ filePath, content }: { filePath: string; content: string }
return <div className="flex h-full min-h-0 flex-col p-4">
<div className="mb-2 flex items-center gap-1.5 text-xs text-muted-foreground">
<span className="min-w-0 flex-1 truncate" title={filePath}>{filePath}</span>
- <button type="button" className="rounded border px-2 py-1 hover:bg-muted" onClick={() => setShowText((value) => !value)}>{showText ? "PDF" : "Text"}</button>
- {!showText && <><button type="button" className="rounded p-1 hover:bg-muted" onClick={() => setZoom((value) => Math.max(50, value - 25))}><Minus className="h-3.5 w-3.5" /></button><span className="w-10 text-center">{zoom}%</span><button type="button" className="rounded p-1 hover:bg-muted" onClick={() => setZoom((value) => Math.min(300, value + 25))}><Plus className="h-3.5 w-3.5" /></button><label className="ml-1 flex items-center gap-1">Page<input value={page} min={1} type="number" onChange={(event) => setPage(Math.max(1, Number(event.target.value) || 1))} className="w-14 rounded border bg-background px-1 py-0.5" /></label></>}
+ <button type="button" className="rounded border px-2 py-1 hover:bg-muted" onClick={() => setShowText((value) => !value)}>{showText ? t("preview.pdfDocument") : t("preview.pdfText")}</button>
+ {!showText && <><button type="button" className="rounded p-1 hover:bg-muted" onClick={() => setZoom((value) => Math.max(50, value - 25))}><Minus className="h-3.5 w-3.5" /></button><span className="w-10 text-center">{zoom}%</span><button type="button" className="rounded p-1 hover:bg-muted" onClick={() => setZoom((value) => Math.min(300, value + 25))}><Plus className="h-3.5 w-3.5" /></button><label className="ml-1 flex items-center gap-1">{t("preview.pdfPage")}<input value={page} min={1} type="number" onChange={(event) => setPage(Math.max(1, Number(event.target.value) || 1))} className="w-14 rounded border bg-background px-1 py-0.5" /></label></>}
</div>
<div className="min-h-0 flex-1 overflow-hidden rounded-md border bg-white">
{showText ? <TextPreview filePath={filePath} content={content} label="PDF text" /> : <object key={src} data={src} type="application/pdf" className="h-full w-full"><iframe title={filePath} src={src} className="h-full w-full" /></object>}
diff --git a/src/i18n/en.json b/src/i18n/en.json
index ca1bd20b..c840017e 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -737,7 +737,15 @@
"openWithSystem": "Open with system app",
"showSource": "Show source",
"showRendered": "Show rendered preview",
- "reload": "Reload preview"
+ "reload": "Reload preview",
+ "history": "File history",
+ "historyLoading": "Loading...",
+ "historyEmpty": "No recorded versions yet.",
+ "historySelect": "Select a version to compare.",
+ "historyRestore": "Restore this version",
+ "pdfText": "Text",
+ "pdfDocument": "PDF",
+ "pdfPage": "Page"
},
"activity": {
"processing": "Processing: {{title}}",
diff --git a/src/i18n/zh.json b/src/i18n/zh.json
index 72837ffa..0af70196 100644
--- a/src/i18n/zh.json
+++ b/src/i18n/zh.json
@@ -737,7 +737,15 @@
"openWithSystem": "使用系统应用打开",
"showSource": "查看源码",
"showRendered": "查看渲染结果",
- "reload": "重新加载预览"
+ "reload": "重新加载预览",
+ "history": "文件历史",
+ "historyLoading": "正在加载...",
+ "historyEmpty": "暂无已记录的版本。",
+ "historySelect": "选择一个版本进行比较。",
+ "historyRestore": "恢复此版本",
+ "pdfText": "文本",
+ "pdfDocument": "PDF",
+ "pdfPage": "页码"
},
"activity": {
"processing": "处理中:{{title}}",