import React, { useState, useEffect } from 'react'; import { Button } from './ui/button'; import { Input } from './ui/input'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from './ui/card'; import { Alert, AlertDescription } from './ui/alert'; import { Folder, FolderOpen, AlertCircle, CheckCircle, RefreshCw } from 'lucide-react'; import { useApiHelpers } from '@/hooks/useApiHelpers'; interface PathInfo { path: string; exists: boolean; isDirectory: boolean; absolute: string; fromEnv: boolean; } interface PathSuggestion { name: string; memories: string; tasks: string; discovered?: boolean; lastModified?: string; stats?: { memoryCount: number; taskCount: number; projectCount: number; }; } export function PathConfiguration() { const [memoryPath, setMemoryPath] = useState(''); const [taskPath, setTaskPath] = useState(''); const [currentPaths, setCurrentPaths] = useState<{ memories: PathInfo; tasks: PathInfo; suggestions: PathSuggestion[]; } | null>(null); const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const [success, setSuccess] = useState(''); const { apiGet, apiPost } = useApiHelpers(); useEffect(() => { fetchCurrentPaths(); }, []); const fetchCurrentPaths = async () => { try { const response = await apiGet('/api/paths'); if (!response.ok) throw new Error('Failed to fetch paths'); const data = await response.json(); setCurrentPaths(data); setMemoryPath(data.memories.path); setTaskPath(data.tasks.path); } catch (err) { setError('Failed to load current paths'); console.error('Error fetching paths:', err); } }; const handleUpdatePaths = async () => { setLoading(true); setError(''); setSuccess(''); try { const response = await apiPost('/api/paths', { memoryPath, taskPath, }); if (!response.ok) { const data = await response.json(); throw new Error(data.error || 'Failed to update paths'); } setSuccess('Paths updated successfully! The dashboard will now use the new locations.'); await fetchCurrentPaths(); } catch (err: any) { setError(err.message || 'Failed to update paths'); } finally { setLoading(false); } }; const applySuggestion = (suggestion: PathSuggestion) => { setMemoryPath(suggestion.memories); setTaskPath(suggestion.tasks); }; if (!currentPaths) { return
Loading path configuration...
; } return (
Path Configuration Configure where Like-I-Said stores memories and tasks. This should match your Claude Desktop configuration. {error && ( {error} )} {success && ( {success} )}
setMemoryPath(e.target.value)} placeholder="C:\Users\YourName\like-i-said-mcp\memories" />
{currentPaths.memories.exists ? : }

Current: {currentPaths.memories.absolute} {currentPaths.memories.exists ? '(exists)' : '(not found)'}

setTaskPath(e.target.value)} placeholder="C:\Users\YourName\like-i-said-mcp\tasks" />
{currentPaths.tasks.exists ? : }

Current: {currentPaths.tasks.absolute} {currentPaths.tasks.exists ? '(exists)' : '(not found)'}

Path Suggestions {currentPaths.suggestions.some(s => s.discovered) ? '🔍 Auto-discovered existing installations and common paths' : 'Common locations where memories might be stored'}
{/* Show discovered folders first */} {currentPaths.suggestions.filter(s => s.discovered).length > 0 && ( <>
✨ Discovered Installations
{currentPaths.suggestions.filter(s => s.discovered).map((suggestion, index) => ( ))}
)} {/* Show standard suggestions */}
📍 Standard Locations
{currentPaths.suggestions.filter(s => !s.discovered).map((suggestion, index) => ( ))}
{/* Spacer to ensure content is not hidden behind Windows taskbar */} ); }