fix(sidebar): preserve pinned sessions and folder refs on empty session list (#1706)
Added sessions.length === 0 guard to useSidebarPersistence.ts and sessions.length === 0 && archivedSessions.length === 0 guard to useSessionFolderCleanup.ts. Prevents data loss when server returns empty list during transient failures. Co-authored-by: Leonid Skorobogatyy <bash@opencode.itc.local>
This commit is contained in:
committed by
GitHub
co-authored by
Leonid Skorobogatyy
parent
2fd86db6a7
commit
83256ba924
@@ -38,6 +38,10 @@ export const useSessionFolderCleanup = (args: Args): void => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sessions.length === 0 && archivedSessions.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const idsByScope = new Map<string, Set<string>>();
|
||||
sessions.forEach((session) => {
|
||||
const directory = normalizePath((session as Session & { directory?: string | null }).directory ?? null);
|
||||
|
||||
@@ -154,6 +154,10 @@ export const useSidebarPersistence = (args: Args) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sessions.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const existingSessionIds = new Set(sessions.map((session) => session.id));
|
||||
setPinnedSessionIds((prev) => {
|
||||
let changed = false;
|
||||
|
||||
Reference in New Issue
Block a user