feat: add session history sidebar with delete and navigation

- SessionSidebar component listing past sessions sorted by recency
- Session title preview and relative date display
- Click to switch sessions, delete with confirmation
- Added deleteSession method to session store
- Integrated sidebar into chat page layout

Closes #12

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shahondin1624
2026-03-12 11:55:58 +01:00
parent ed0a01c857
commit 19c3c2bcdc
5 changed files with 165 additions and 43 deletions

View File

@@ -91,6 +91,16 @@ function createSessionStore() {
}
}
function deleteSession(id: string) {
sessions.delete(id);
if (activeSessionId === id) {
const remaining = getAllSessions();
activeSessionId = remaining.length > 0 ? remaining[0].id : null;
if (activeSessionId) saveActiveSessionId(activeSessionId);
}
saveSessions(sessions);
}
function getAllSessions(): Session[] {
return [...sessions.values()].sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
}
@@ -102,6 +112,7 @@ function createSessionStore() {
getOrCreateSession,
updateMessages,
switchSession,
deleteSession,
getAllSessions
};
}