import { useState } from 'react' interface TeachPanelProps { onTeach: (question: string, answer: string) => Promise loading: boolean } interface TeachResult { question: string answer: string tokensWritten: number message: string timestamp: number } export function TeachPanel({ onTeach, loading }: TeachPanelProps) { const [question, setQuestion] = useState('') const [answer, setAnswer] = useState('') const [history, setHistory] = useState([]) const handleTeach = async () => { if (!question.trim() || !answer.trim() || loading) return try { const resp = await onTeach(question.trim(), answer.trim()) setHistory(prev => [{ question: question.trim(), answer: answer.trim(), tokensWritten: resp.tokens_written, message: resp.message, timestamp: Date.now(), }, ...prev]) setQuestion('') setAnswer('') } catch { setHistory(prev => [{ question: question.trim(), answer: answer.trim(), tokensWritten: 0, message: 'Error: API not reachable', timestamp: Date.now(), }, ...prev]) } } return (
📚

Teach

O(1) learning
{/* Input form */}
setQuestion(e.target.value)} onKeyDown={e => e.key === 'Enter' && !e.shiftKey && handleTeach()} placeholder="what is the capital of france" className="w-full bg-pal-surface border border-pal-border rounded-lg px-3 py-2 text-sm text-pal-text placeholder:text-pal-muted focus:outline-none focus:border-pal-green/50 transition-all" />
setAnswer(e.target.value)} onKeyDown={e => e.key === 'Enter' && !e.shiftKey && handleTeach()} placeholder="paris" className="w-full bg-pal-surface border border-pal-border rounded-lg px-3 py-2 text-sm text-pal-text placeholder:text-pal-muted focus:outline-none focus:border-pal-green/50 transition-all" />
{/* History */} {history.length > 0 && (
Taught ({history.length}) {history.map((h, i) => (
{h.question}
→ {h.answer}
{h.tokensWritten > 0 && ( +{h.tokensWritten} tok )}
{h.message && (

{h.message}

)}
))}
)} {history.length === 0 && (
âš¡

Teach PALIMPSESTE new facts.
Each fact is written to memory in O(1) —
instantly retrievable, never forgotten.

)}
) }