import { useEffect, useState } from "react"; import { Modal, Stack, Textarea, Group, Button, Alert, Text, } from "@mantine/core"; import { IconAlertTriangle } from "@tabler/icons-react"; import { notifications } from "@mantine/notifications"; import { getMemory, putMemory } from "../api"; interface Props { opened: boolean; onClose: () => void; } export function MemoryEditor({ opened, onClose }: Props) { const [content, setContent] = useState(""); const [original, setOriginal] = useState(""); const [loading, setLoading] = useState(false); const [saving, setSaving] = useState(false); useEffect(() => { if (!opened) return; setLoading(true); getMemory() .then((c) => { setContent(c); setOriginal(c); }) .catch((e) => notifications.show({ title: "Could not load memory", message: String(e), color: "red", }) ) .finally(() => setLoading(false)); }, [opened]); const dirty = content !== original; async function onSave() { setSaving(true); try { await putMemory(content); setOriginal(content); notifications.show({ title: "Memory saved", message: `${content.length} characters written to /work/agent_memory.md`, color: "teal", }); } catch (e) { notifications.show({ title: "Save failed", message: String(e), color: "red", }); } finally { setSaving(false); } } return ( } title="Edit at your own risk" > The agent reads this file at the start of every conversation and updates it on its own when it learns something new. Hand-editing is fine — but if you delete relevant context here, the agent will not know about it next time. Avoid wiping the whole file unless you want to reset the agent's memory.