diff --git a/archon-ui-main/src/features/knowledge/inspector/components/InspectorSidebar.tsx b/archon-ui-main/src/features/knowledge/inspector/components/InspectorSidebar.tsx index da4f36aa..e3510f82 100644 --- a/archon-ui-main/src/features/knowledge/inspector/components/InspectorSidebar.tsx +++ b/archon-ui-main/src/features/knowledge/inspector/components/InspectorSidebar.tsx @@ -4,9 +4,10 @@ */ import { motion } from "framer-motion"; -import { Code, FileText, Globe, Hash, Loader2, Search, X } from "lucide-react"; -import { useMemo } from "react"; +import { Code, ExternalLink, FileText, Globe, Hash, Info, Loader2, Search } from "lucide-react"; +import { useMemo, useState } from "react"; import { Button, Input } from "../../../ui/primitives"; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../../ui/primitives/select"; import { cn } from "../../../ui/primitives/styles"; import type { CodeExample, DocumentChunk } from "../../types"; import { extractDomain } from "../../utils/knowledge-utils"; @@ -22,8 +23,8 @@ interface InspectorSidebarProps { hasNextPage: boolean; onLoadMore: () => void; isFetchingNextPage: boolean; - selectedDomains?: Set; - onDomainsChange?: (domains: Set) => void; + selectedDomain?: string; + onDomainChange?: (domain: string) => void; } export const InspectorSidebar: React.FC = ({ @@ -37,9 +38,11 @@ export const InspectorSidebar: React.FC = ({ hasNextPage, onLoadMore, isFetchingNextPage, - selectedDomains = new Set(), - onDomainsChange, + selectedDomain = "all", + onDomainChange, }) => { + const [showMetadata, setShowMetadata] = useState(null); + // Extract unique domains from documents const domainStats = useMemo(() => { if (viewMode !== "documents") return []; @@ -58,18 +61,18 @@ export const InspectorSidebar: React.FC = ({ .map(([domain, count]) => ({ domain, count })); }, [items, viewMode]); - // Filter items by selected domains + // Filter items by selected domain const filteredItems = useMemo(() => { - if (viewMode !== "documents" || selectedDomains.size === 0) { + if (viewMode !== "documents" || selectedDomain === "all") { return items; } return (items as DocumentChunk[]).filter((doc) => { const url = doc.url || doc.metadata?.url; if (!url) return false; - return selectedDomains.has(extractDomain(url)); + return extractDomain(url) === selectedDomain; }); - }, [items, selectedDomains, viewMode]); + }, [items, selectedDomain, viewMode]); const getItemTitle = (item: DocumentChunk | CodeExample) => { const idSuffix = String(item.id).slice(-6); if (viewMode === "documents") { @@ -115,63 +118,33 @@ export const InspectorSidebar: React.FC = ({ /> - {/* Domain Filter - Only show for documents */} - {viewMode === "documents" && domainStats.length > 0 && onDomainsChange && ( + {/* Domain Filter Dropdown - Only show for documents */} + {viewMode === "documents" && domainStats.length > 0 && onDomainChange && (
Domain Filter - {selectedDomains.size > 0 && ( - - )} -
-
- {domainStats.slice(0, 5).map(({ domain, count }) => { - const isSelected = selectedDomains.has(domain); - return ( - - ); - })} - {domainStats.length > 5 && ( - - +{domainStats.length - 5} more - - )}
+
)} @@ -230,16 +203,51 @@ export const InspectorSidebar: React.FC = ({ )} -
-

- {getItemDescription(item)} -

- {viewMode === "documents" && (item as DocumentChunk).url && ( - - {extractDomain((item as DocumentChunk).url || "")} - - )} -
+

+ {getItemDescription(item)} +

+ + {/* Action buttons for documents */} + {viewMode === "documents" && ( +
+ {(item as DocumentChunk).url && ( + e.stopPropagation()} + className="text-[10px] px-1.5 py-0.5 rounded bg-white/5 text-gray-500 hover:text-cyan-400 hover:bg-cyan-500/10 transition-colors flex items-center gap-1" + title="View source" + > + + View Source + + )} + {(item as DocumentChunk).metadata && ( + + )} +
+ )} + + {/* Metadata panel */} + {showMetadata === item.id && (item as DocumentChunk).metadata && ( +
+
+                          {JSON.stringify((item as DocumentChunk).metadata, null, 2)}
+                        
+
+ )} {item.metadata?.relevance_score != null && (