saved sessions: make routable via /chat/saved/:id URLs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 20:15:36 +00:00
co-authored by Claude Opus 4.6
parent 2a8df0def1
commit 406d8f9e54
3 changed files with 50 additions and 10 deletions
@@ -1,5 +1,5 @@
import { useState, useRef, useCallback } from 'react';
import { useNavigate } from 'react-router';
import { useNavigate, useLocation } from 'react-router';
import { Plus, MessageSquare, Loader2 } from 'lucide-react';
import { usePanelChannel } from 'hooks/usePanelChannel';
import { useSavedSessions, messagesToTranscript, type RawMessage } from 'state/useSavedSessions';
@@ -9,6 +9,8 @@ import { SessionContextMenu } from './SessionContextMenu';
export const SessionList = () => {
const navigate = useNavigate();
const location = useLocation();
const isOnChatPage = location.pathname.startsWith('/chat');
const { sessions, deleteSavedSession, resumeSession } = useSavedSessions();
const [selected, setSelected] = usePanelChannel<SelectedSession>('chat:selected-session', null);
const [isResuming, setIsResuming] = useState<number | null>(null);
@@ -22,6 +24,10 @@ export const SessionList = () => {
}, []);
const handleSelect = async (session: (typeof sessions)[number]) => {
if (isOnChatPage) {
navigate(`/chat/saved/${session.id}`);
return;
}
setIsResuming(session.id);
try {
const result = await resumeSession(session.id);
@@ -43,12 +49,11 @@ export const SessionList = () => {
});
const transcript = messagesToTranscript(rawMessages);
setSelected({
id: `resume:${session.id}`,
id: `saved:${session.id}`,
model: result.model,
resumeSummary: transcript,
initialMessages: chatMessages,
});
navigate(`/chat/new`, { replace: true });
} catch {
// Failed to resume
} finally {
@@ -57,9 +62,9 @@ export const SessionList = () => {
};
const handleDelete = async (id: number) => {
if (selected?.id === `resume:${id}`) {
if (selected?.id === `saved:${id}`) {
setSelected(null);
navigate('/chat', { replace: true });
if (isOnChatPage) navigate('/chat', { replace: true });
}
await deleteSavedSession(id);
};
@@ -90,7 +95,7 @@ export const SessionList = () => {
)}
{sessions.map((session) => {
const isActive = selected?.id === `resume:${session.id}`;
const isActive = selected?.id === `saved:${session.id}`;
return (
<div
key={session.id}