MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / MemoryPanel

Function MemoryPanel

ai-code-studio/src/components/MemoryPanel.tsx:19–259  ·  view source on GitHub ↗
({ open, workspaceDir, onClose }: MemoryPanelProps)

Source from the content-addressed store, hash-verified

17};
18
19export function MemoryPanel({ open, workspaceDir, onClose }: MemoryPanelProps) {
20 const [index, setIndex] = useState('');
21 const [manifest, setManifest] = useState<MemoryManifestItem[]>([]);
22 const [logs, setLogs] = useState('');
23 const [activeView, setActiveView] = useState<'overview' | 'file' | 'search'>('overview');
24 const [activeFile, setActiveFile] = useState<MemoryFile | null>(null);
25 const [editContent, setEditContent] = useState('');
26 const [searchQuery, setSearchQuery] = useState('');
27 const [searchResults, setSearchResults] = useState<MemoryFile[]>([]);
28 const [searching, setSearching] = useState(false);
29 const [dreaming, setDreaming] = useState(false);
30 const [saving, setSaving] = useState(false);
31
32 const loadOverview = useCallback(async () => {
33 try {
34 const data = await api<{ index: string; manifest: MemoryManifestItem[]; logs: string }>('/api/memory');
35 setIndex(data.index);
36 setManifest(data.manifest);
37 setLogs(data.logs);
38 } catch { /* ignore */ }
39 }, []);
40
41 useEffect(() => {
42 if (open && workspaceDir) loadOverview();
43 }, [open, workspaceDir, loadOverview]);
44
45 async function openFile(filename: string) {
46 try {
47 const file = await api<MemoryFile>(`/api/memory/file/${encodeURIComponent(filename)}`);
48 setActiveFile(file);
49 setEditContent(file.content);
50 setActiveView('file');
51 } catch { /* ignore */ }
52 }
53
54 async function handleSaveFile() {
55 if (!activeFile) return;
56 setSaving(true);
57 try {
58 await api(`/api/memory/file/${encodeURIComponent(activeFile.filename)}`, {
59 method: 'POST',
60 body: JSON.stringify({ content: editContent, frontmatter: activeFile.frontmatter }),
61 });
62 await loadOverview();
63 } catch { /* ignore */ }
64 setSaving(false);
65 }
66
67 async function handleDeleteFile(filename: string) {
68 try {
69 await api(`/api/memory/file/${encodeURIComponent(filename)}`, { method: 'DELETE' });
70 if (activeFile?.filename === filename) {
71 setActiveFile(null);
72 setActiveView('overview');
73 }
74 await loadOverview();
75 } catch { /* ignore */ }
76 }

Callers

nothing calls this directly

Calls 3

handleSearchFunction · 0.85
openFileFunction · 0.85
handleDeleteFileFunction · 0.85

Tested by

no test coverage detected