fix: clean up stale file tree paths on startup

Removes missing expanded folders from persisted Files state
Prevents repeated 404 noise for stale file tree paths
Avoids startup SDK race when restoring sessions
This commit is contained in:
Bohdan Triapitsyn
2026-06-26 12:47:01 +03:00
parent 8c1a24089d
commit 4a37b9a005
5 changed files with 100 additions and 17 deletions
@@ -220,6 +220,21 @@ function createChildStores(entries: Array<[string, StoreApi<DirectoryStore>]>) {
} as unknown as import("./child-store").ChildStoreManager
}
describe("fetchMessagesForSession startup race", () => {
test("does not reject before sync action refs are initialized", async () => {
const { fetchMessagesForSession } = await import("./session-actions")
let error: unknown = null
try {
await fetchMessagesForSession("session-a", "/test/project")
} catch (err) {
error = err
}
expect(error).toBe(null)
})
})
describe("shareSession live state", () => {
beforeEach(() => {
replyCalls.length = 0
+7 -7
View File
@@ -1126,19 +1126,19 @@ export async function fetchMessagesForSession(sessionID: string, directory?: str
const resolvedDir = directory ?? dir()
if (!resolvedDir) return
const s = sdk()
const store = directory
? dirStoreForDirectory(directory)
: dirStore()
if (getSessionMaterializationStatus(store.getState(), sessionID).renderable) return
const loadingKey = `${resolvedDir}:${sessionID}`
if (FETCH_MESSAGES_LOADING.has(loadingKey)) return
FETCH_MESSAGES_LOADING.add(loadingKey)
try {
const s = sdk()
const store = directory
? dirStoreForDirectory(directory)
: dirStore()
if (getSessionMaterializationStatus(store.getState(), sessionID).renderable) return
const result = await retry(async () => {
const response = await s.session.messages({
sessionID,