## Problem
Studio Storage hides `.emptyFolderPlaceholder` objects after listing a
folder, but `fetchMoreFolderContents` calculated the next page offset
from the number of visible items. When a page includes the placeholder,
the API returns 200 objects but Studio keeps 199, so the next request
uses offset 199 instead of 200 and the last file of the previous page
appears twice. The duplicates compound with every further page.
Fixes FE-4843. Closes#52607.
Before:
<img width="521" height="458" alt="Screenshot 2026-11-03 at 14 51 09"
src="https://github.com/user-attachments/assets/1ed20ded-08c6-4c56-92d7-5c97ef82cd00"
/>
After:
<img width="532" height="460" alt="Screenshot 2026-11-03 at 14 53 58"
src="https://github.com/user-attachments/assets/64891f27-7fa0-44cb-8076-39b405df0ee4"
/>
## Solution
Each storage column now records `hiddenItemsCount`, the number of API
objects hidden from the visible list (the placeholder).
`fetchMoreFolderContents` offsets the next page by `items.length +
hiddenItemsCount`.
Because the offset is still derived from `items.length`, local edits to
a column (creating a folder, uploads, deletes, renames) keep it in step
with the server, as they did before.
Added tests to `state/storage-explorer.test.ts`: a folder with a
placeholder plus 300 files lists each file exactly once and requests
offsets 0 and 200, and a folder without a placeholder still pages at 0,
200, 400. Reverting the offset line makes the placeholder test fail.
## Review instructions
1. In a bucket, create a `docs` folder and, using the Storage API,
upload a zero-byte `docs/.emptyFolderPlaceholder` plus files
`file-000.txt` through `file-299.txt`.
2. Open `docs` in Studio and sort by Name ascending.
3. Scroll to load further pages and check the list requests in the
network tab: offsets should be 0 and 200, and no file should appear
twice.
4. Run `pnpm --filter studio exec vitest run
state/storage-explorer.test.ts`.
## Checklist
- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill (not applicable)
## Context
_TLDR: Changes here speeds up unit tests on CI from ~14 minutes to ~3
minutes_ 😂
_TLDR 2: The file changes are solely only test files +
`studio-unit-tests.yml`_
We've currently got a lot of unit tests in the repository which while
great for coverage, hasn't been ideally written. There's a lot of
redundancy + overly specific tests that break easily, and our current
unit test takes about 15 minutes to run in the GHA per PR. Hence am
doing a audit clean up of all existing unit tests in the studio repo.
## Changes involved
- `.test.ts` files now run in `node`, `.test.tsx` in `jsdom`
- jsdom costs about 1s of setup per file. A `.ts` test that needs the
DOM opts in with `// @vitest-environment jsdom` (46 files do).
- Removed redundant and over-specific tests
- Duplicates are merged into `test.each`. Tests that only covered
libraries, existed for coverage, or asserted class names and snapshots
are deleted. 19 files are merged into a sibling or deleted.
- Fixed about 15 tests that couldn't fail
- Examples: unawaited assertions, fixtures equal to the default, and a
`semverGte` test calling `semverLte`.
- Sped up the slowest files
- Real sleeps are replaced with fake timers, `user.type` with paste, and
Radix option queries are scoped to the open listbox. For example,
`RestoringState` went from 18s to 0.3s and
`useTableEditorFiltersSort.navigation` from 20s to 3s.
- These ^ already shave down the unit tests time from 14 mins to 9 mins,
but am also sharding unit tests across 4 jobs to increase speed up
further which then shaves down time to 3 mins now
## This PR
Adds **Show archived** to the file explorer's view options and list them
in the file explorer.
- `useStoragePreference` — `showArchivedInline`, stored per project
- `ArchivedFilesContext` — owns the archived list and which object is
selected
- `FileExplorer` — merges archived rows into each column and re-sorts,
since the server-side sort never sees them
- `FileExplorerRow` — dimmed striped rendering, no checkbox, no context
menu
- `FileExplorerHeader` — the toggle, rendered only behind the feature
preview
- `StorageExplorer` — mounts the provider
https://github.com/user-attachments/assets/a26551b4-b22d-485e-9d23-3e78c4a89315
Clicking an archived row opens a preview panel: where the file used to
live, when it was archived, its retained versions, and the actions to
bring it back or delete it permanently.
- `ArchivedFilePreviewPane` — the pane, replacing `PreviewPane` while an
archived row is selected
- `ArchivedVersionRestoreWidget` — takes over the top of the pane when a
specific retained version is selected
- `ArchivedVersionRow` — one version, with its restore / delete actions
- `StorageExplorerContent` — the pane swap
https://github.com/user-attachments/assets/03c9eae6-e9e3-4bd0-8145-953625e125d1
Other additions behind the feature preview:
- The buckets list show a **Versioning** column.
- `BucketVersioningPill` — a `file-stack` badge beside the bucket name
in the breadcrumbs, brand when versioning is enabled and warning when it
is suspended, so the bucket's state is visible from inside the explorer
rather than only from the buckets list.
https://github.com/user-attachments/assets/f4827aac-a9ff-4300-92ac-073848d63606
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
| | PR | Base | Branch |
| --- | --- | --- | --- |
| 1 | **this PR** | `master` | pre-existing correctness fixes |
| 2 | #50413 | `fix/storage-explorer-listing-and-scroll` |
`?path`/`?preview` deep-linking + copy row actions |
| 3 | #50478 | `feat/storage-nav-improvement` | end-to-end deep-link
test |
| 4 | #50480 | `test/storage-deep-link-e2e` | copy path / copy link row
actions |
To read the whole change in one view:
```bash
git diff master...test/storage-deep-link-e2e -- apps/studio e2e
```
## What is the current behavior?
Four independent bugs in the storage explorer, all pre-existing on
`master`:
- `hasMoreItems` is derived from the *formatted* listing, but
`formatFolderItems` drops the `.emptyFolderPlaceholder` — so a full page
can format to `LIMIT - 1` and stop pagination a page early.
- A failed listing is indistinguishable from an empty folder, so a fetch
error reads as "this folder has nothing in it".
- `fetchFoldersByPath` commits its result against whichever bucket is
selected when the requests resolve. Switching buckets mid-flight files
the old bucket's items under the new bucket's name — and because
`columns[0].name` then matches, nothing downstream notices and
refetches.
- The horizontal auto-scroll never runs its guard (`if
(fileExplorerRef)` is always truthy), scrolls relatively so repeated
runs drift, and depends on the `columns` array identity — so a
background refetch yanks the view back to the right. It also scrolls in
list view, where there is nothing to scroll.
## What is the new behavior?
Each of the above is fixed at its source. Pagination and the
exhaustiveness check now compare the raw page length; listings carry an
`isComplete` flag; `fetchFoldersByPath` captures the bucket id at entry
and discards a stale result; the scroll is absolute, guarded, keyed on
`columns.length`, and skipped in list view.
Two new test files cover the parts that were silently wrong before:
`state/storage-explorer.test.ts` (MSW, the bucket race) and
`FileExplorer.test.tsx` (scroll geometry, with the container's layout
defined by hand since jsdom reports everything as zero-sized). Both were
checked by reverting the fix and confirming they fail.
## Additional context
`fetchFoldersByPath` also starts returning `{ missingPaths }` here.
Nothing reads it yet — the first consumer is in PR 2 — but it shares a
hunk with the `isComplete` work, so separating it would mean two PRs
editing the same lines. It is backward-compatible: all three existing
call sites ignore the return value.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
## Bug Fixes
- Improved Storage Explorer column-view scrolling so the newest column
remains visible, including when the preview pane opens.
- Prevented folder results from a previously selected bucket from
appearing after switching buckets during loading.
- Improved handling of incomplete or partial folder listings to avoid
incorrectly treating failed results as empty folders.
- Preserved the correct scroll position when using list view.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>