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:
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user