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:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user