feat: delete session from sidebar with confirmation dialog

This commit is contained in:
Nicolas Varrot
2026-02-12 16:57:18 +00:00
parent 94df362001
commit e94325b38a
5 changed files with 63 additions and 5 deletions

View File

@@ -388,6 +388,24 @@ export function useGateway() {
setupClient(url, token);
}, [setupClient]);
const deleteSession = useCallback(async (key: string) => {
try {
await clientRef.current?.send('sessions.delete', { key, deleteTranscript: true });
} catch {
// Ignore delete failures
}
// Remove from local state
setSessions(prev => prev.filter(s => s.key !== key));
// If we deleted the active session, switch to main
if (activeSessionRef.current === key) {
const mainKey = 'agent:main:main';
setActiveSession(mainKey);
activeSessionRef.current = mainKey;
setMessages([]);
loadHistory(mainKey);
}
}, [loadHistory]);
const logout = useCallback(() => {
if (clientRef.current) {
clientRef.current.disconnect();
@@ -416,7 +434,7 @@ export function useGateway() {
return {
status, messages, sessions: enrichedSessions, activeSession, isGenerating, isLoadingHistory,
sendMessage, abort, switchSession, loadSessions,
sendMessage, abort, switchSession, loadSessions, deleteSession,
authenticated, login, logout, connectError, isConnecting,
};
}