fix: discard stale prefix searches and guard load-more reveals

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011HeHeGLWDuu62fxjBZA15P
This commit is contained in:
Diego Imbert
2026-07-28 12:10:33 +02:00
co-authored by Claude Fable 5
parent a9b194bba8
commit 8da23fda22
2 changed files with 15 additions and 2 deletions
+1 -1
View File
@@ -1 +1 @@
9198f30466965db1305daf9d6694855de6fe8d93
6bf95f5b160283d5eeb0ac29f199644dcecd6149
@@ -203,7 +203,7 @@
// Sorted after every real child of the folder but before the folder's own
// siblings, so the row lands at the bottom of the level it pages.
const LOAD_MORE_SUFFIX = '￿'
const LOAD_MORE_SUFFIX = '\uffff'
function loadMoreKey(folderKey: string | undefined): string {
return (folderKey ?? '') + LOAD_MORE_SUFFIX
}
@@ -267,6 +267,7 @@
}
async function loadFilesFlat() {
const generation = loadGeneration
let availableFiles = await listStoredFilesRequest({
workspace: ws!,
maxKeys: maxKeys, // fixed pages of 1000 files for now
@@ -275,6 +276,11 @@
storage: storage,
s3ResourcePath
})
// Debounced prefix searches overlap, so a slower earlier one must not
// land in the tree a later one already rebuilt.
if (generation !== loadGeneration) {
return
}
if (
availableFiles.restricted_access === null ||
availableFiles.restricted_access === undefined ||
@@ -447,6 +453,7 @@
if (marker === undefined) {
return
}
const generation = loadGeneration
const loadingKey = loadMoreKey(parentKey)
loadingFolderKeys.add(loadingKey)
try {
@@ -457,6 +464,12 @@
} finally {
loadingFolderKeys.delete(loadingKey)
}
// The tree may have been rebuilt, or the folder collapsed, while the page
// was in flight — either way its children must stay hidden.
const parentNode = parentKey !== undefined ? allFilesByKey[parentKey] : undefined
if (generation !== loadGeneration || parentNode?.collapsed === true) {
return
}
revealChildren(parentKey)
}