Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ function App() {
} = sessionsHook;

const currentSession = useMemo(
() => sessions.find((session) => session.sessionId === selectedSessionId),
[sessions, selectedSessionId],
() =>
sessions.find((session) => session.sessionId === selectedSessionId) ??
archivedSessions.find((session) => session.sessionId === selectedSessionId),
[sessions, archivedSessions, selectedSessionId],
);

const [streamStatus, setStreamStatus] = useState<ChatStatus>("ready");
Expand Down Expand Up @@ -226,23 +228,32 @@ function App() {

// Validate session exists once session list loads, clear URL if not found
useEffect(() => {
if (sessions.length === 0 || !selectedSessionId) {
if ((sessions.length === 0 && archivedSessions.length === 0) || !selectedSessionId) {
return;
}

if (searchQuery.trim() || hasMoreSessions) {
if (searchQuery.trim() || hasMoreSessions || hasMoreArchivedSessions || isLoadingArchived) {
return;
Comment on lines +235 to 236
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not block URL validation on archived pagination state

Guarding validation with hasMoreArchivedSessions causes ?session=... cleanup to be skipped indefinitely whenever the user has at least one additional archived page (e.g. >100 archived sessions) but never clicks “Load more”. In that case an invalid or deleted session ID remains selected forever, because this effect never reaches the sessionExists check even after initial archived loading finishes; previously this path only depended on active-session pagination.

Useful? React with 👍 / 👎.

}

const sessionExists = sessions.some(
(s) => s.sessionId === selectedSessionId,
);
const sessionExists =
sessions.some((s) => s.sessionId === selectedSessionId) ||
archivedSessions.some((s) => s.sessionId === selectedSessionId);
if (!sessionExists) {
console.log("[App] Session from URL not found, clearing selection");
updateUrlWithSession(null);
selectSession("");
}
}, [sessions, selectedSessionId, selectSession, hasMoreSessions, searchQuery]);
}, [
sessions,
archivedSessions,
selectedSessionId,
selectSession,
hasMoreSessions,
hasMoreArchivedSessions,
isLoadingArchived,
searchQuery,
]);

// Update URL when selected session changes
useEffect(() => {
Expand Down
Loading