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

feat: web clips auto-ingest + 🌐 icon + scrollable preview

nash_su6e63e49569c5
diff --git a/extension/popup.html b/extension/popup.html
index fd937d93..32d7c7e9 100644
--- a/extension/popup.html
+++ b/extension/popup.html
@@ -4,13 +4,14 @@
<meta charset="utf-8">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
- body {
+ html, body {
width: 480px;
- max-height: 600px;
+ height: 580px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
font-size: 13px;
color: #1a1a2e;
background: #fafafa;
+ overflow: hidden;
}
.header {
padding: 12px 16px;
@@ -22,7 +23,13 @@
}
.header h1 { font-size: 14px; font-weight: 600; }
.header .icon { font-size: 18px; }
- .content { padding: 12px 16px; }
+ .content {
+ padding: 12px 16px;
+ flex: 1;
+ overflow-y: auto;
+ display: flex;
+ flex-direction: column;
+ }
.status {
padding: 8px 12px;
border-radius: 6px;
@@ -111,7 +118,7 @@
}
</style>
</head>
-<body>
+<body style="display:flex;flex-direction:column;">
<div class="header">
<span class="icon">📚</span>
<h1>LLM Wiki Clipper</h1>
@@ -137,9 +144,9 @@
<div class="preview" id="urlPreview">—</div>
</div>
- <div class="field">
+ <div class="field" style="flex:1;display:flex;flex-direction:column;min-height:0;">
<label>Content Preview</label>
- <div class="preview" id="contentPreview">Extracting content...</div>
+ <div class="preview" id="contentPreview" style="flex:1;max-height:none;">Extracting content...</div>
</div>
<button class="btn btn-primary" id="clipBtn" disabled>
diff --git a/src-tauri/src/clip_server.rs b/src-tauri/src/clip_server.rs
index 9c3705cc..87d39ab0 100644
--- a/src-tauri/src/clip_server.rs
+++ b/src-tauri/src/clip_server.rs
@@ -4,6 +4,7 @@ use tiny_http::{Header, Method, Response, Server};
static CURRENT_PROJECT: Mutex<String> = Mutex::new(String::new());
static ALL_PROJECTS: Mutex<Vec<(String, String)>> = Mutex::new(Vec::new()); // (name, path)
+static PENDING_CLIPS: Mutex<Vec<(String, String)>> = Mutex::new(Vec::new()); // (projectPath, filePath)
pub fn start_clip_server() {
thread::spawn(|| {
@@ -115,6 +116,18 @@ pub fn start_clip_server() {
for h in &cors_headers { response.add_header(h.clone()); }
let _ = request.respond(response);
}
+ (&Method::Get, "/clips/pending") => {
+ let mut pending = PENDING_CLIPS.lock().unwrap();
+ let items: Vec<String> = pending.iter()
+ .map(|(proj, file)| format!(r#"{{"projectPath":"{}","filePath":"{}"}}"#,
+ proj.replace('"', r#"\""#), file.replace('"', r#"\""#)))
+ .collect();
+ let body = format!(r#"{{"ok":true,"clips":[{}]}}"#, items.join(","));
+ pending.clear();
+ let mut response = Response::from_string(body);
+ for h in &cors_headers { response.add_header(h.clone()); }
+ let _ = request.respond(response);
+ }
(&Method::Post, "/clip") => {
let mut body = String::new();
if let Err(e) = request.as_reader().read_to_string(&mut body) {
@@ -246,13 +259,14 @@ fn handle_clip(body: &str) -> String {
counter += 1;
}
- // Build markdown content
+ // Build markdown content with web-clip origin
let markdown = format!(
- "---\ntype: clip\ntitle: \"{}\"\nurl: \"{}\"\nclipped: {}\nsources: []\ntags: [web-clip]\n---\n\n# {}\n\n{}\n",
+ "---\ntype: clip\ntitle: \"{}\"\nurl: \"{}\"\nclipped: {}\norigin: web-clip\nsources: []\ntags: [web-clip]\n---\n\n# {}\n\nSource: {}\n\n{}\n",
title.replace('"', r#"\""#),
url.replace('"', r#"\""#),
date,
title,
+ url,
content,
);
@@ -264,5 +278,11 @@ fn handle_clip(body: &str) -> String {
}
let relative_path = file_path.replace(&format!("{}/", project_path), "");
+
+ // Add to pending clips for frontend to pick up and auto-ingest
+ if let Ok(mut pending) = PENDING_CLIPS.lock() {
+ pending.push((project_path, file_path.clone()));
+ }
+
format!(r#"{{"ok":true,"path":"{}"}}"#, relative_path)
}
diff --git a/src/App.tsx b/src/App.tsx
index b2eecdcb..de50eb40 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -8,6 +8,7 @@ import { listDirectory, openProject } from "@/commands/fs"
import { getLastProject, getRecentProjects, saveLastProject, loadLlmConfig, loadLanguage, loadSearchApiConfig } from "@/lib/project-store"
import { loadReviewItems, loadChatHistory } from "@/lib/persist"
import { setupAutoSave } from "@/lib/auto-save"
+import { startClipWatcher } from "@/lib/clip-watcher"
import { AppLayout } from "@/components/layout/app-layout"
import { WelcomeScreen } from "@/components/project/welcome-screen"
import { CreateProjectDialog } from "@/components/project/create-project-dialog"
@@ -22,9 +23,10 @@ function App() {
const [showCreateDialog, setShowCreateDialog] = useState(false)
const [loading, setLoading] = useState(true)
- // Set up auto-save once on mount
+ // Set up auto-save and clip watcher once on mount
useEffect(() => {
setupAutoSave()
+ startClipWatcher()
}, [])
// Auto-open last project on startup
diff --git a/src/components/layout/knowledge-tree.tsx b/src/components/layout/knowledge-tree.tsx
index 5e9a2172..920d0b37 100644
--- a/src/components/layout/knowledge-tree.tsx
+++ b/src/components/layout/knowledge-tree.tsx
@@ -1,6 +1,6 @@
import { useState, useEffect, useCallback } from "react"
import {
- FileText, Users, Lightbulb, BookOpen, HelpCircle, GitMerge, BarChart3, ChevronRight, ChevronDown, Layout,
+ FileText, Users, Lightbulb, BookOpen, HelpCircle, GitMerge, BarChart3, ChevronRight, ChevronDown, Layout, Globe,
} from "lucide-react"
import { ScrollArea } from "@/components/ui/scroll-area"
import { useWikiStore } from "@/stores/wiki-store"
@@ -12,6 +12,7 @@ interface WikiPageInfo {
title: string
type: string
tags: string[]
+ origin?: string
}
const TYPE_CONFIG: Record<string, { icon: typeof FileText; label: string; color: string; order: number }> = {
@@ -150,6 +151,7 @@ export function KnowledgeTree() {
}`}
title={page.path}
>
+ {page.origin === "web-clip" && <Globe className="h-3 w-3 shrink-0 text-blue-400" />}
<span className="truncate">{page.title}</span>
</button>
)
@@ -226,6 +228,7 @@ function parsePageInfo(path: string, fileName: string, content: string): WikiPag
let type = "other"
let title = fileName.replace(".md", "").replace(/-/g, " ")
const tags: string[] = []
+ let origin: string | undefined
// Parse YAML frontmatter
const fmMatch = content.match(/^---\n([\s\S]*?)\n---/)
@@ -241,6 +244,9 @@ function parsePageInfo(path: string, fileName: string, content: string): WikiPag
if (tagsMatch) {
tags.push(...tagsMatch[1].split(",").map((t) => t.trim().replace(/["']/g, "")))
}
+
+ const originMatch = fm.match(/^origin:\s*(.+)$/m)
+ if (originMatch) origin = originMatch[1].trim()
}
// Fallback: try first heading if no frontmatter title
@@ -260,7 +266,7 @@ function parsePageInfo(path: string, fileName: string, content: string): WikiPag
else if (fileName === "overview.md") type = "overview"
}
- return { path, title, type, tags }
+ return { path, title, type, tags, origin }
}
function flattenMdFiles(nodes: FileNode[]): FileNode[] {
diff --git a/src/lib/clip-watcher.ts b/src/lib/clip-watcher.ts
new file mode 100644
index 00000000..eb007cfd
--- /dev/null
+++ b/src/lib/clip-watcher.ts
@@ -0,0 +1,58 @@
+import { useWikiStore } from "@/stores/wiki-store"
+import { autoIngest } from "./ingest"
+import { listDirectory } from "@/commands/fs"
+
+const POLL_INTERVAL = 3000 // Check every 3 seconds
+let intervalId: ReturnType<typeof setInterval> | null = null
+
+/**
+ * Start polling the clip server for new web clips.
+ * When a clip is detected, triggers auto-ingest and refreshes the file tree.
+ */
+export function startClipWatcher() {
+ if (intervalId) return // Already running
+
+ intervalId = setInterval(async () => {
+ try {
+ const res = await fetch("http://127.0.0.1:19827/clips/pending", { method: "GET" })
+ const data = await res.json()
+
+ if (!data.ok || !data.clips || data.clips.length === 0) return
+
+ const store = useWikiStore.getState()
+ const project = store.project
+
+ for (const clip of data.clips) {
+ const clipProjectPath: string = clip.projectPath
+ const clipFilePath: string = clip.filePath
+
+ // Refresh file tree if clip is for current project
+ if (project && clipProjectPath === project.path) {
+ try {
+ const tree = await listDirectory(project.path)
+ store.setFileTree(tree)
+ } catch {
+ // ignore
+ }
+
+ // Auto-ingest the clipped file
+ const llmConfig = store.llmConfig
+ if (llmConfig.apiKey || llmConfig.provider === "ollama") {
+ autoIngest(clipProjectPath, clipFilePath, llmConfig).catch((err) => {
+ console.error("Failed to auto-ingest web clip:", err)
+ })
+ }
+ }
+ }
+ } catch {
+ // Server not running or network error — silently ignore
+ }
+ }, POLL_INTERVAL)
+}
+
+export function stopClipWatcher() {
+ if (intervalId) {
+ clearInterval(intervalId)
+ intervalId = null
+ }
+}