perf(ui): narrow session switch fanout
Keep sidebar rows independent from the active sync directory by moving export history loading behind an explicit-directory command. Make active-project selection preserve project topology and remove activeProjectId from mounted group render props. Reuse a per-session-array ID index so subscription snapshots do not repeatedly scan session lists.
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
useSyncSDK,
|
||||
useSyncRuntime,
|
||||
resyncBlockingRequestsForDirectory,
|
||||
buildSessionMessageRecordsSnapshot,
|
||||
} from "./sync-context"
|
||||
import { stripSessionDiffSnapshots } from "./sanitize"
|
||||
import { isVSCodeRuntime } from "@/lib/desktop"
|
||||
@@ -412,3 +413,17 @@ export function usePrefetchSessionMessages() {
|
||||
touch(sessionID, directory)
|
||||
}, [messageLoader, runtimeKey, touch])
|
||||
}
|
||||
|
||||
export function useSessionMessageRecordsForExport() {
|
||||
const { childStores, messageLoader, runtimeKey } = useSyncRuntime()
|
||||
const touch = useSessionCacheTouch()
|
||||
|
||||
return useCallback(async ({ directory, sessionID }: { directory: string; sessionID: string }) => {
|
||||
if (getRuntimeKey() !== runtimeKey) return null
|
||||
const store = childStores.ensureChild(directory, { bootstrap: false })
|
||||
touch(sessionID, directory)
|
||||
await messageLoader.loadComplete({ directory, sessionID })
|
||||
if (getRuntimeKey() !== runtimeKey) return null
|
||||
return buildSessionMessageRecordsSnapshot(store.getState(), sessionID).list
|
||||
}, [childStores, messageLoader, runtimeKey, touch])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user