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: only show actually cited source files, not all sources
nash_sub9d55125f02e
diff --git a/src/components/chat/chat-message.tsx b/src/components/chat/chat-message.tsxindex b15de692..a8a68cb0 100644--- a/src/components/chat/chat-message.tsx+++ b/src/components/chat/chat-message.tsx@@ -74,25 +74,46 @@ export function ChatMessage({ message }: ChatMessageProps) {<MarkdownContent content={message.content} />)}</div>- {isAssistant && cachedSourceFiles.length > 0 && (- <SourceFilesBar />- )}+ {isAssistant && <SourceFilesBar content={message.content} />}</div></div>)}-function SourceFilesBar() {+function SourceFilesBar({ content }: { content: string }) {+ const cited = useMemo(() => extractCitedSources(content), [content])++ if (cited.length === 0) return null+return (<div className="flex flex-wrap items-center gap-1 px-1"><span className="text-[10px] text-muted-foreground">Sources:</span>- {cachedSourceFiles.map((fileName) => (+ {cited.map((fileName) => (<SourceRef key={fileName} fileName={fileName} />))}</div>)}+/**+ * Extract cited source files from the hidden comment at the end of the response.+ * Format: <!-- sources: file1.pdf, file2.md -->+ * Falls back to matching known source filenames in the text if no comment found.+ */+function extractCitedSources(text: string): string[] {+ // Try to parse the hidden comment+ const commentMatch = text.match(/<!--\s*sources:\s*(.+?)\s*-->/)+ if (commentMatch) {+ return commentMatch[1]+ .split(",")+ .map((s) => s.trim())+ .filter((s) => s.length > 0 && cachedSourceFiles.includes(s))+ }++ // Fallback: check which known source filenames appear in the text+ return cachedSourceFiles.filter((name) => text.includes(name))+}+interface StreamingMessageProps {content: string}@@ -112,7 +133,9 @@ export function StreamingMessage({ content }: StreamingMessageProps) {}function MarkdownContent({ content }: { content: string }) {- const processed = useMemo(() => processContent(content), [content])+ // Strip hidden sources comment before rendering+ const cleaned = content.replace(/<!--\s*sources:.*?-->/g, "").trimEnd()+ const processed = useMemo(() => processContent(cleaned), [cleaned])return (<div className="chat-markdown prose prose-sm max-w-none dark:prose-invert prose-p:my-1 prose-headings:my-2 prose-ul:my-1 prose-ol:my-1 prose-li:my-0 prose-pre:my-2 prose-code:text-xs prose-code:before:content-none prose-code:after:content-none">diff --git a/src/components/chat/chat-panel.tsx b/src/components/chat/chat-panel.tsxindex fd9871a1..f06687a6 100644--- a/src/components/chat/chat-panel.tsx+++ b/src/components/chat/chat-panel.tsx@@ -69,11 +69,12 @@ export function ChatPanel() {"","## Citation Rules (CRITICAL)","- Your answers are derived from the user's uploaded source documents.",- "- At the end of your answer, under '**References:**', list the source files your answer draws from.",- "- Reference format: use @filename exactly as listed below (e.g., @2603.25723v1.pdf). One per line.",- "- Use the EXACT original file names. NEVER rename, paraphrase, or invent file names.","- If the wiki doesn't have enough information to answer, say so honestly.",- "- You may also use [[wikilink]] syntax to reference wiki pages in the index.",+ "- You may use [[wikilink]] syntax to reference wiki pages in the index.",+ "- At the VERY END of your response, add an HTML comment listing ONLY the source files you actually used:",+ " <!-- sources: file1.pdf, file2.md -->",+ "- Use EXACT file names from the Source Files list. Only include files your answer actually draws from.",+ "- This comment MUST be the last line of your response. Do NOT skip it.","","Use markdown formatting for clarity.","",