fix: сохранил pinned sessions после reload (#943)

This commit is contained in:
Artёm
2026-04-21 23:13:54 +03:00
committed by GitHub
parent 2eb71d5fdd
commit 125094d371
2 changed files with 9 additions and 1 deletions
@@ -275,6 +275,7 @@ export const SessionSidebar: React.FC<SessionSidebarProps> = ({
const sync = useSync();
const liveSessions = useAllLiveSessions();
const liveSessionStatuses = useAllSessionStatuses();
const hasLoadedGlobalSessions = useGlobalSessionsStore((state) => state.hasLoaded);
const globalActiveSessions = useGlobalSessionsStore((state) => state.activeSessions);
const archivedSessions = useGlobalSessionsStore((state) => state.archivedSessions);
const currentSessionId = useSessionUIStore((state) => state.currentSessionId);
@@ -476,6 +477,7 @@ export const SessionSidebar: React.FC<SessionSidebarProps> = ({
const { scheduleCollapsedProjectsPersist } = useSidebarPersistence({
isVSCode,
hasLoadedGlobalSessions,
safeStorage,
keys: {
sessionExpanded: SESSION_EXPANDED_STORAGE_KEY,
@@ -19,6 +19,7 @@ type Keys = {
type Args = {
isVSCode: boolean;
hasLoadedGlobalSessions: boolean;
safeStorage: SafeStorageLike;
keys: Keys;
sessions: Session[];
@@ -34,6 +35,7 @@ type Args = {
export const useSidebarPersistence = (args: Args) => {
const {
isVSCode,
hasLoadedGlobalSessions,
safeStorage,
keys,
sessions,
@@ -114,6 +116,10 @@ export const useSidebarPersistence = (args: Args) => {
}, [keys.projectCollapse, keys.sessionExpanded, safeStorage, setCollapsedProjects, setExpandedParents]);
React.useEffect(() => {
if (!hasLoadedGlobalSessions) {
return;
}
const existingSessionIds = new Set(sessions.map((session) => session.id));
setPinnedSessionIds((prev) => {
let changed = false;
@@ -127,7 +133,7 @@ export const useSidebarPersistence = (args: Args) => {
});
return changed ? next : prev;
});
}, [sessions, setPinnedSessionIds]);
}, [hasLoadedGlobalSessions, sessions, setPinnedSessionIds]);
React.useEffect(() => {
try {