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: always show source file references on every assistant message

nash_su3ea8e088eff0
diff --git a/src/components/chat/chat-message.tsx b/src/components/chat/chat-message.tsx
index caad35bf..fa5f4476 100644
--- a/src/components/chat/chat-message.tsx
+++ b/src/components/chat/chat-message.tsx
@@ -203,20 +203,26 @@ function SourceFilesBar({ content }: { content: string }) {
/**
* 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.
+ * Falls back to showing all source files if no comment found (all sources are relevant
+ * since the wiki is built from them).
*/
function extractCitedSources(text: string): string[] {
// Try to parse the hidden comment
const commentMatch = text.match(/<!--\s*sources:\s*(.+?)\s*-->/)
if (commentMatch) {
- return commentMatch[1]
+ const cited = commentMatch[1]
.split(",")
.map((s) => s.trim())
.filter((s) => s.length > 0 && cachedSourceFiles.includes(s))
+ if (cited.length > 0) return cited
}
// Fallback: check which known source filenames appear in the text
- return cachedSourceFiles.filter((name) => text.includes(name))
+ const mentioned = cachedSourceFiles.filter((name) => text.includes(name))
+ if (mentioned.length > 0) return mentioned
+
+ // Final fallback: show all source files (wiki is built from all of them)
+ return [...cachedSourceFiles]
}
interface StreamingMessageProps {