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: restructure layout — center Chat, right Preview panel
nash_suc8c21875161a
diff --git a/src/components/layout/app-layout.tsx b/src/components/layout/app-layout.tsxindex 8903adaa..209ab837 100644--- a/src/components/layout/app-layout.tsx+++ b/src/components/layout/app-layout.tsx@@ -4,6 +4,7 @@ import { listDirectory } from "@/commands/fs"import { IconSidebar } from "./icon-sidebar"import { FileTree } from "./file-tree"import { ContentArea } from "./content-area"+import { PreviewPanel } from "./preview-panel"import { ActivityPanel } from "./activity-panel"interface AppLayoutProps {@@ -12,9 +13,12 @@ interface AppLayoutProps {export function AppLayout({ onSwitchProject }: AppLayoutProps) {const project = useWikiStore((s) => s.project)+ const selectedFile = useWikiStore((s) => s.selectedFile)const setFileTree = useWikiStore((s) => s.setFileTree)- const [sidebarWidth, setSidebarWidth] = useState(260)- const isDragging = useRef(false)+ const [leftWidth, setLeftWidth] = useState(220)+ const [rightWidth, setRightWidth] = useState(400)+ const isDraggingLeft = useRef(false)+ const isDraggingRight = useRef(false)const containerRef = useRef<HTMLDivElement>(null)const loadFileTree = useCallback(async () => {@@ -31,40 +35,51 @@ export function AppLayout({ onSwitchProject }: AppLayoutProps) {loadFileTree()}, [loadFileTree])- const handleMouseDown = useCallback((e: React.MouseEvent) => {- e.preventDefault()- isDragging.current = true- document.body.style.cursor = "col-resize"- document.body.style.userSelect = "none"+ const startDrag = useCallback(+ (side: "left" | "right") => (e: React.MouseEvent) => {+ e.preventDefault()+ if (side === "left") isDraggingLeft.current = true+ else isDraggingRight.current = true+ document.body.style.cursor = "col-resize"+ document.body.style.userSelect = "none"- const handleMouseMove = (e: MouseEvent) => {- if (!isDragging.current || !containerRef.current) return- const containerRect = containerRef.current.getBoundingClientRect()- const newWidth = e.clientX - containerRect.left- const minWidth = 150- const maxWidth = containerRect.width * 0.5- setSidebarWidth(Math.max(minWidth, Math.min(maxWidth, newWidth)))- }+ const handleMouseMove = (e: MouseEvent) => {+ if (!containerRef.current) return+ const rect = containerRef.current.getBoundingClientRect()- const handleMouseUp = () => {- isDragging.current = false- document.body.style.cursor = ""- document.body.style.userSelect = ""- document.removeEventListener("mousemove", handleMouseMove)- document.removeEventListener("mouseup", handleMouseUp)- }+ if (isDraggingLeft.current) {+ const newWidth = e.clientX - rect.left+ setLeftWidth(Math.max(150, Math.min(rect.width * 0.3, newWidth)))+ }+ if (isDraggingRight.current) {+ const newWidth = rect.right - e.clientX+ setRightWidth(Math.max(250, Math.min(rect.width * 0.5, newWidth)))+ }+ }++ const handleMouseUp = () => {+ isDraggingLeft.current = false+ isDraggingRight.current = false+ document.body.style.cursor = ""+ document.body.style.userSelect = ""+ document.removeEventListener("mousemove", handleMouseMove)+ document.removeEventListener("mouseup", handleMouseUp)+ }- document.addEventListener("mousemove", handleMouseMove)- document.addEventListener("mouseup", handleMouseUp)- }, [])+ document.addEventListener("mousemove", handleMouseMove)+ document.addEventListener("mouseup", handleMouseUp)+ },+ []+ )return (<div className="flex h-screen bg-background text-foreground"><IconSidebar onSwitchProject={onSwitchProject} /><div ref={containerRef} className="flex min-w-0 flex-1 overflow-hidden">+ {/* Left: File tree + Activity */}<divclassName="flex shrink-0 flex-col overflow-hidden border-r"- style={{ width: sidebarWidth }}+ style={{ width: leftWidth }}><div className="flex-1 overflow-hidden"><FileTree />@@ -73,11 +88,29 @@ export function AppLayout({ onSwitchProject }: AppLayoutProps) {</div><divclassName="w-1.5 shrink-0 cursor-col-resize bg-border/40 transition-colors hover:bg-primary/30 active:bg-primary/40"- onMouseDown={handleMouseDown}+ onMouseDown={startDrag("left")}/>++ {/* Center: Chat or view (sources/settings/review) */}<div className="min-w-0 flex-1 overflow-hidden"><ContentArea /></div>++ {/* Right: File preview (shown when a file is selected) */}+ {selectedFile && (+ <>+ <div+ className="w-1.5 shrink-0 cursor-col-resize bg-border/40 transition-colors hover:bg-primary/30 active:bg-primary/40"+ onMouseDown={startDrag("right")}+ />+ <div+ className="shrink-0 overflow-hidden border-l"+ style={{ width: rightWidth }}+ >+ <PreviewPanel />+ </div>+ </>+ )}</div></div>)diff --git a/src/components/layout/content-area.tsx b/src/components/layout/content-area.tsxindex 15fb288a..75a554a2 100644--- a/src/components/layout/content-area.tsx+++ b/src/components/layout/content-area.tsx@@ -1,115 +1,20 @@-import { useEffect, useCallback, useRef } from "react"import { useWikiStore } from "@/stores/wiki-store"-import { readFile, writeFile } from "@/commands/fs"-import { getFileCategory, isBinary } from "@/lib/file-types"-import { WikiEditor } from "@/components/editor/wiki-editor"-import { FilePreview } from "@/components/editor/file-preview"-import { ChatBar } from "./chat-bar"+import { ChatPanel } from "@/components/chat/chat-panel"import { SettingsView } from "@/components/settings/settings-view"import { SourcesView } from "@/components/sources/sources-view"import { ReviewView } from "@/components/review/review-view"export function ContentArea() {- const selectedFile = useWikiStore((s) => s.selectedFile)const activeView = useWikiStore((s) => s.activeView)- const fileContent = useWikiStore((s) => s.fileContent)- const setFileContent = useWikiStore((s) => s.setFileContent)- const chatExpanded = useWikiStore((s) => s.chatExpanded)- const saveTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)- useEffect(() => {- if (!selectedFile) {- setFileContent("")- return- }-- const category = getFileCategory(selectedFile)-- if (isBinary(category)) {- setFileContent("")- return- }-- readFile(selectedFile)- .then(setFileContent)- .catch((err) => setFileContent(`Error loading file: ${err}`))- }, [selectedFile, setFileContent])-- const handleSave = useCallback(- (markdown: string) => {- if (!selectedFile) return- if (saveTimerRef.current) clearTimeout(saveTimerRef.current)- saveTimerRef.current = setTimeout(() => {- writeFile(selectedFile, markdown).catch((err) =>- console.error("Failed to save:", err)- )- }, 1000)- },- [selectedFile]- )-- useEffect(() => {- return () => {- if (saveTimerRef.current) clearTimeout(saveTimerRef.current)- }- }, [])-- // Render the main view content based on activeView- function renderMainContent() {- switch (activeView) {- case "settings":- return <SettingsView />- case "sources":- return <SourcesView />- case "review":- return <ReviewView />- default: {- // Wiki view: show editor or file preview- const category = selectedFile ? getFileCategory(selectedFile) : null- return (- <div className="h-full min-w-0 overflow-auto">- {selectedFile ? (- category === "markdown" ? (- <WikiEditor- key={selectedFile}- content={fileContent}- onSave={handleSave}- />- ) : (- <FilePreview- key={selectedFile}- filePath={selectedFile}- textContent={fileContent}- />- )- ) : (- <div className="flex h-full items-center justify-center text-muted-foreground">- Select a file from the tree to view- </div>- )}- </div>- )- }- }- }-- // Chat bar is always visible at the bottom, regardless of activeView- if (!chatExpanded) {- return (- <div className="flex h-full min-w-0 flex-col overflow-hidden">- <div className="flex-1 overflow-hidden">{renderMainContent()}</div>- <ChatBar />- </div>- )+ switch (activeView) {+ case "settings":+ return <SettingsView />+ case "sources":+ return <SourcesView />+ case "review":+ return <ReviewView />+ default:+ return <ChatPanel />}-- return (- <div className="flex h-full min-w-0 flex-col overflow-hidden">- <div className="flex-1 overflow-hidden">{renderMainContent()}</div>- <div className="h-1.5 shrink-0 cursor-row-resize bg-border/40 transition-colors hover:bg-primary/30" />- <div className="h-64 shrink-0 overflow-hidden">- <ChatBar />- </div>- </div>- )}diff --git a/src/components/layout/preview-panel.tsx b/src/components/layout/preview-panel.tsxnew file mode 100644index 00000000..1fcee9e4--- /dev/null+++ b/src/components/layout/preview-panel.tsx@@ -0,0 +1,94 @@+import { useEffect, useCallback, useRef } from "react"+import { X } from "lucide-react"+import { useWikiStore } from "@/stores/wiki-store"+import { readFile, writeFile } from "@/commands/fs"+import { getFileCategory, isBinary } from "@/lib/file-types"+import { WikiEditor } from "@/components/editor/wiki-editor"+import { FilePreview } from "@/components/editor/file-preview"++export function PreviewPanel() {+ const selectedFile = useWikiStore((s) => s.selectedFile)+ const fileContent = useWikiStore((s) => s.fileContent)+ const setFileContent = useWikiStore((s) => s.setFileContent)+ const setSelectedFile = useWikiStore((s) => s.setSelectedFile)+ const saveTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)++ useEffect(() => {+ if (!selectedFile) {+ setFileContent("")+ return+ }++ const category = getFileCategory(selectedFile)++ if (isBinary(category)) {+ setFileContent("")+ return+ }++ readFile(selectedFile)+ .then(setFileContent)+ .catch((err) => setFileContent(`Error loading file: ${err}`))+ }, [selectedFile, setFileContent])++ const handleSave = useCallback(+ (markdown: string) => {+ if (!selectedFile) return+ if (saveTimerRef.current) clearTimeout(saveTimerRef.current)+ saveTimerRef.current = setTimeout(() => {+ writeFile(selectedFile, markdown).catch((err) =>+ console.error("Failed to save:", err)+ )+ }, 1000)+ },+ [selectedFile]+ )++ useEffect(() => {+ return () => {+ if (saveTimerRef.current) clearTimeout(saveTimerRef.current)+ }+ }, [])++ if (!selectedFile) {+ return (+ <div className="flex h-full items-center justify-center text-sm text-muted-foreground">+ Select a file to preview+ </div>+ )+ }++ const category = getFileCategory(selectedFile)+ const fileName = selectedFile.split("/").pop() ?? selectedFile++ return (+ <div className="flex h-full flex-col">+ <div className="flex items-center justify-between border-b px-3 py-1.5">+ <span className="truncate text-xs text-muted-foreground" title={selectedFile}>+ {fileName}+ </span>+ <button+ onClick={() => setSelectedFile(null)}+ className="shrink-0 rounded p-1 text-muted-foreground hover:bg-accent"+ >+ <X className="h-3.5 w-3.5" />+ </button>+ </div>+ <div className="flex-1 min-w-0 overflow-auto">+ {category === "markdown" ? (+ <WikiEditor+ key={selectedFile}+ content={fileContent}+ onSave={handleSave}+ />+ ) : (+ <FilePreview+ key={selectedFile}+ filePath={selectedFile}+ textContent={fileContent}+ />+ )}+ </div>+ </div>+ )+}