"use client"; // Shared anatomy-card primitives — extracted so the agent command center // (ClawCommandCenter) reuses the exact cards/styling. Behavior copied verbatim // from Dashboard.tsx's in-file helpers. import { useState, type CSSProperties } from "react"; import { Check, Pencil, ScrollText, X } from "lucide-react"; export const mono = "'JetBrains Mono', ui-monospace, monospace"; /** A brain section: rendered read-only with a pencil; click to edit as raw text * and PATCH it back to `/api/claws/{id}/brain`. `children` is the display; * `value` is the editable source. `onSaved` should re-fetch the brain. */ export function EditableSection({ clawId, field, value, onSaved, children, placeholder }: { clawId: string; field: "system_prompt" | "agent_md" | "persona" | "skills_md"; value: string; onSaved?: () => void; children: React.ReactNode; placeholder?: string; }) { const [editing, setEditing] = useState(false); const [draft, setDraft] = useState(value); const [saving, setSaving] = useState(false); const save = async () => { setSaving(true); try { await fetch(`/api/claws/${clawId}/brain`, { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ [field]: draft }) }); setEditing(false); onSaved?.(); } catch { /* keep the editor open on failure */ } finally { setSaving(false); } }; if (editing) { return (