# Vector Inspector Implementation Guide ## Changes to /workspaces/ruvector/crates/rvlite/examples/dashboard/src/App.tsx ### 1. Add VectorEntry import (Line 90) **FIND:** ```typescript import useRvLite, { type SearchResult, type CypherResult, type SparqlResult, type SqlResult } from './hooks/useRvLite'; ``` **REPLACE WITH:** ```typescript import useRvLite, { type SearchResult, type CypherResult, type SparqlResult, type SqlResult, type VectorEntry } from './hooks/useRvLite'; ``` ### 2. Add Eye icon import (Line 31-74) **FIND the lucide-react imports ending with:** ```typescript ChevronDown, ChevronRight, } from 'lucide-react'; ``` **REPLACE WITH:** ```typescript ChevronDown, ChevronRight, Eye, } from 'lucide-react'; ``` ### 3. Add getVector to useRvLite destructuring (Line ~460) **FIND:** ```typescript const { isReady, isLoading, error: rvliteError, stats, insertVector, insertVectorWithId, searchVectors, searchVectorsWithFilter, deleteVector, getAllVectors, ``` **REPLACE WITH:** ```typescript const { isReady, isLoading, error: rvliteError, stats, insertVector, insertVectorWithId, searchVectors, searchVectorsWithFilter, getVector, deleteVector, getAllVectors, ``` ### 4. Add modal disclosure (after line ~507) **FIND:** ```typescript const { isOpen: isScenariosOpen, onOpen: onScenariosOpen, onClose: onScenariosClose } = useDisclosure(); ``` **ADD AFTER:** ```typescript const { isOpen: isVectorDetailOpen, onOpen: onVectorDetailOpen, onClose: onVectorDetailClose } = useDisclosure(); ``` ### 5. Add state variables (after line ~519) **FIND:** ```typescript const [importJson, setImportJson] = useState(''); ``` **ADD AFTER:** ```typescript const [selectedVectorId, setSelectedVectorId] = useState(null); const [selectedVectorData, setSelectedVectorData] = useState(null); ``` ### 6. Add handler function (after refreshVectors function, around line ~650) **ADD NEW FUNCTION:** ```typescript const handleViewVector = useCallback(async (id: string) => { try { const vectorData = getVector(id); if (vectorData) { setSelectedVectorId(id); setSelectedVectorData(vectorData); onVectorDetailOpen(); addLog('info', `Viewing vector: ${id}`); } else { addLog('error', `Vector not found: ${id}`); } } catch (err) { addLog('error', `Failed to get vector: ${formatError(err)}`); } }, [getVector, onVectorDetailOpen, addLog]); ``` ### 7. Update Vector Table Cell to make ID clickable (around line 1218-1222) **FIND:** ```typescript
{vector.id}
``` **REPLACE WITH:** ```typescript
handleViewVector(vector.id)} > {vector.id}
``` ### 8. Update View Details button (around line 1236-1240) **FIND:** ```typescript ``` **REPLACE WITH:** ```typescript ``` ### 9. Add Vector Detail Modal (after Sample Scenarios Modal, around line 2350+) **ADD NEW MODAL:** ```typescript {/* Vector Detail Modal */} Vector Inspector {selectedVectorId && ( {selectedVectorId} )} {selectedVectorData ? ( <> {/* Vector ID Section */}
Vector ID
{selectedVectorData.id}
{/* Dimensions */}
Dimensions
{selectedVectorData.vector.length}D ({selectedVectorData.vector.length} values)
{/* Embedding Values */}
Embedding Values
                      {selectedVectorData.vector.length <= 20
                        ? `[${selectedVectorData.vector.map(v => v.toFixed(6)).join(', ')}]`
                        : `[${selectedVectorData.vector.slice(0, 20).map(v => v.toFixed(6)).join(', ')}\n  ... ${selectedVectorData.vector.length - 20} more values]`
                      }
                    
{selectedVectorData.vector.length > 20 && (

Showing first 20 of {selectedVectorData.vector.length} values

)}
{/* Metadata */}
Metadata
{selectedVectorData.metadata && ( )}
{selectedVectorData.metadata ? (
                        {JSON.stringify(selectedVectorData.metadata, null, 2)}
                      
) : (

No metadata

)}
) : (

Vector data not available

)}
``` ## Summary of Changes 1. **Imports**: Added `VectorEntry` type and `Eye` icon 2. **Hook**: Added `getVector` function from useRvLite 3. **State**: Added `selectedVectorId` and `selectedVectorData` state variables 4. **Modal**: Added `isVectorDetailOpen` disclosure 5. **Handler**: Created `handleViewVector` function 6. **Table**: Made vector IDs clickable and updated View Details button 7. **Modal Component**: Added complete Vector Inspector modal with: - Vector ID display with copy button - Dimensions display - Embedding values (first 20 + count if more) - Metadata as formatted JSON - Copy buttons for embedding and metadata - Dark theme styling matching existing UI