fix the learning
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
2026-06-26 16:09:04 +01:00
parent 4ae37e84dd
commit 1e0a4c97b3
9 changed files with 623 additions and 32 deletions

View File

@@ -321,24 +321,67 @@ function MemoryRow({ memory, onChange }: { memory: Memory; onChange: () => void
}
function SuggestionRow({ suggestion, onChange }: { suggestion: Suggestion; onChange: () => void }) {
const [editing, setEditing] = useState(false);
const [title, setTitle] = useState(suggestion.title);
const [content, setContent] = useState(suggestion.content);
const [category, setCategory] = useState(suggestion.category);
return (
<div className="retro-window p-2 text-sm border-l-4 border-[var(--xp-blue)]">
<p className="font-bold">{suggestion.title}</p>
<p className="text-xs mt-1">{suggestion.content}</p>
<p className="text-[10px] text-[var(--warm-grey)]">
{MEMORY_CATEGORIES[suggestion.category as MemoryCategory]} · confidence {suggestion.confidence}
</p>
{editing ? (
<div className="space-y-2">
<input
className="retro-window-inset w-full p-1 text-xs"
value={title}
onChange={(e) => setTitle(e.target.value)}
/>
<select
className="retro-window-inset w-full p-1 text-xs"
value={category}
onChange={(e) => setCategory(e.target.value)}
>
{Object.entries(MEMORY_CATEGORIES).map(([key, label]) => (
<option key={key} value={key}>{label}</option>
))}
</select>
<textarea
className="retro-window-inset w-full p-1 text-xs min-h-20"
value={content}
onChange={(e) => setContent(e.target.value)}
/>
</div>
) : (
<>
<p className="font-bold">{suggestion.title}</p>
<p className="text-xs mt-1">{suggestion.content}</p>
<p className="text-[10px] text-[var(--warm-grey)]">
{MEMORY_CATEGORIES[suggestion.category as MemoryCategory]} · confidence {suggestion.confidence}
</p>
</>
)}
<div className="flex gap-2 mt-2">
<button
type="button"
className="retro-btn retro-btn-primary text-xs"
onClick={async () => {
await fetch(`/api/ai/memory/suggestions/${suggestion.id}/accept`, { method: "POST" });
await fetch(`/api/ai/memory/suggestions/${suggestion.id}/accept`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(editing ? { title, content, category } : {}),
});
onChange();
}}
disabled={!title.trim() || !content.trim()}
>
Accept
</button>
<button
type="button"
className="retro-btn text-xs"
onClick={() => setEditing((value) => !value)}
>
{editing ? "Cancel edit" : "Edit"}
</button>
<button
type="button"
className="retro-btn text-xs"