fix: prevent S3 file browser crash when selecting storage (#8444)

VirtualList crashes with 'Requested index 0 is outside of range 0..0'
when it mounts with itemCount=0 and a positive height. This happened
because the old condition allowed VirtualList to remount during loading
with zero items but a stale listDivHeight from a previous mount.

Change the guard to displayedFileKeys.length === 0 so VirtualList is
never rendered when there are no items. Show a centered loading spinner
or "no files" message instead.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-03-19 05:49:44 +00:00
committed by GitHub
parent f2334e6564
commit a8fa0cccef

View File

@@ -592,10 +592,18 @@
<input type="text" placeholder="Folder prefix" bind:value={filter} class="text-xl" />
</div>
{/if}
{#if fileListLoading === false && displayedFileKeys.length === 0}
<div class="p-4 text-primary text-xs text-center italic">
No files in the workspace S3 bucket at that prefix
</div>
{#if displayedFileKeys.length === 0}
{#if fileListLoading}
<div class="grow min-h-0 flex justify-center items-center">
<div class="flex text-secondary text-xs items-center">
<Loader2 size={12} class="animate-spin mr-1" /> Loading content
</div>
</div>
{:else}
<div class="p-4 text-primary text-xs text-center italic">
No files in the workspace S3 bucket at that prefix
</div>
{/if}
{:else}
<div class="grow min-h-0" bind:clientHeight={listDivHeight}>
<VirtualList