- Add saved_sessions table and CRUD endpoints (save, list, resume, update, delete) - Save is instant (no LLM summarization), stores exact conversation with tool calls - Resume loads full message history into chat UI, sends transcript to agent on first message - Auto-save updates DB after every agent response once a session is saved - Delete old filesystem-based session/group management (sessions router, useChatSessions, useChatGroups) - Clean up ChatHeader, SessionList, ChatDetailPanel for saved sessions flow Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
48 lines
1.9 KiB
TypeScript
48 lines
1.9 KiB
TypeScript
import { MessageSquare, Trash2 } from 'lucide-react';
|
|
import { Widget } from 'widgets/Widget';
|
|
import { useSavedSessions } from 'state/useSavedSessions';
|
|
|
|
export const ChatHistory = () => {
|
|
const { sessions, deleteSavedSession } = useSavedSessions();
|
|
|
|
return (
|
|
<Widget title="Saved Sessions">
|
|
<div className="px-4 pb-3 max-h-72 overflow-y-auto">
|
|
{sessions.length === 0 ? (
|
|
<p className="text-xs text-duck-dark/40 py-4 text-center">No saved sessions yet</p>
|
|
) : (
|
|
<ul className="space-y-0.5">
|
|
{sessions.map((session) => (
|
|
<li
|
|
key={session.id}
|
|
className="flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-duck-dark/5 group"
|
|
>
|
|
<div className="flex items-center gap-2 flex-1 min-w-0">
|
|
<MessageSquare className="h-4 w-4 shrink-0 text-duck-teal/60" />
|
|
<div className="min-w-0 flex-1">
|
|
<span className="text-sm text-duck-dark dark:text-foreground truncate block">{session.title}</span>
|
|
<span className="text-xs text-duck-dark/40 dark:text-foreground/40 truncate block">
|
|
{new Date(session.createdAt).toLocaleDateString(undefined, {
|
|
month: 'short',
|
|
day: 'numeric',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
})}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<button
|
|
onClick={() => deleteSavedSession(session.id)}
|
|
className="shrink-0 p-1 rounded text-duck-dark/20 md:opacity-0 md:group-hover:opacity-100 hover:text-red-500 transition-opacity cursor-pointer"
|
|
>
|
|
<Trash2 className="h-3.5 w-3.5" />
|
|
</button>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
)}
|
|
</div>
|
|
</Widget>
|
|
);
|
|
};
|