Skip to content

Chore/fix storage explorer when switching buckets - #43541

Merged
joshenlim merged 2 commits into
masterfrom
chore/fix-storage-explorer-when-switching-buckets
Mar 9, 2026
Merged

joshenlim merged 2 commits into
masterfrom
chore/fix-storage-explorer-when-switching-buckets

Conversation

@joshenlim

@joshenlim joshenlim commented Mar 9, 2026 •

Copy link
Copy Markdown
Member

Context

Taking a slightly different approach to this PR

Original problem was that if you opened some folders while in a bucket and then switched to a different bucket, the folder UI will persists (folders from Bucket A will render when landing on Bucket B)

Changes involved

  • Shift StorageExplorerStateContextProvider into [bucketId].tsx] instead of ProjectContext
    • The valtio store here only applies for the storage explorer so having it so high in the project's context was unnecessary
    • This also just implies that the valtio store will automatically reset whenever the bucket changes
  • Simplify storage explorer valtio store by initializing the store with the bucket
    • We'll initialize the selected bucket with the store now (Same as previous PR)
    • Removes unnecessary setSelectedBucket method which required a separate useEffect in StorageExplorer.tsx

To test

  • Verify that the original is resolved
  • General smoke test of the storage explorer - i've also re-added the e2e test that Gildas wrote up in his PR

@joshenlim
joshenlim requested a review from a team as a code owner March 9, 2026 06:19
@vercel

vercel Bot commented Mar 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
studio-self-hosted Ready Ready Preview, Comment Mar 9, 2026 6:19am
studio-staging Ready Ready Preview, Comment Mar 9, 2026 6:19am
7 Skipped Deployments
Project Deployment Actions Updated (UTC)
cms Ignored Ignored Mar 9, 2026 6:19am
studio Ignored Ignored Mar 9, 2026 6:19am
design-system Skipped Skipped Mar 9, 2026 6:19am
docs Skipped Skipped Open in v0 Mar 9, 2026 6:19am
learn Skipped Skipped Mar 9, 2026 6:19am
ui-library Skipped Skipped Mar 9, 2026 6:19am
zone-www-dot-com Skipped Skipped Open in v0 Mar 9, 2026 6:19am

Request Review

@supabase

supabase Bot commented Mar 9, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 490061f6-adaf-4087-ade2-af7cf24990dd

📥 Commits

Reviewing files that changed from the base of the PR and between 4a173ee and 58e817a.

📒 Files selected for processing (6)
  • apps/studio/components/interfaces/Storage/StorageExplorer/StorageExplorer.tsx
  • apps/studio/components/layouts/ProjectLayout/ProjectContext.tsx
  • apps/studio/components/layouts/StorageLayout/StorageBucketsLayout.tsx
  • apps/studio/pages/project/[ref]/storage/files/buckets/[bucketId].tsx
  • apps/studio/state/storage-explorer.tsx
  • e2e/studio/features/storage.spec.ts

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Storage view now properly resets when switching between buckets, ensuring no stale data from previously viewed buckets remains visible.

Walkthrough

The changes restructure the Storage Explorer state management to integrate bucket context. The StorageExplorerStateContextProvider is moved from the global ProjectContextProvider tree to be scoped per route within the bucket detail page. The state initialization now accepts an optional bucket parameter from useSelectedBucket and integrates it into the state creation, removing the previously exposed mutable setSelectedBucket. The initialization effect is reworked to respond to bucket changes alongside project context, ensuring storage contents refresh when switching buckets. A new e2e test validates that storage view resets when switching between buckets.

Sequence Diagram

sequenceDiagram
    participant User as User/Router
    participant Page as Bucket Page<br/>[bucketId].tsx
    participant Provider as StorageExplorerStateContextProvider
    participant Hooks as useSelectedBucket
    participant State as Storage Explorer State

    User->>Page: Navigate to bucket page
    Page->>Provider: Wrap content with provider
    Provider->>Hooks: Call useSelectedBucket()
    Hooks-->>Provider: Return current bucket data
    Provider->>State: createStorageExplorerState({<br/>projectRef,<br/>bucket,<br/>... config})
    State->>State: Initialize selectedBucket<br/>from provided bucket
    State->>State: Setup effect: watch<br/>bucket & projectRef changes
    State-->>Provider: Return initialized state
    Provider-->>Page: Provide state context
    Page->>State: fetchContents triggered<br/>on bucket change
    State-->>Page: Return storage contents<br/>for current bucket
Loading

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results

passed  151 passed
flaky  4 flaky
skipped  4 skipped

Details

stats  159 tests across 20 suites
duration  8 minutes, 47 seconds
commit  58e817a

Flaky tests

Features › cron-jobs.spec.ts › High Query Cost Banner › shows banner and still displays cron jobs when query cost exceeds threshold
Features › database.spec.ts › Database › Schema Visualizer › actions works as expected
Features › realtime-inspector.spec.ts › Realtime Inspector › Broadcast Messages › clicking broadcast message shows detail panel
Features › table-editor.spec.ts › table editor › importing, pagination and large data actions works as expected

Skipped tests

Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

@djhi djhi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Tested on staging

@joshenlim
joshenlim merged commit 9b0dc8d into master Mar 9, 2026
25 of 28 checks passed
@joshenlim
joshenlim deleted the chore/fix-storage-explorer-when-switching-buckets branch March 9, 2026 07:32
@github-actions

github-actions Bot commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1773041651)

Score Average Improvements Regressions
Completeness 97.2% (+6pp) 2 🟢 1 🔴
Conciseness 1.4% (+1pp) 1 🟢 -
Correctness 100% (+0pp) - -
Docs Faithfulness 61.1% (+11pp) 2 🟢 -
Goal Completion 97.2% (+4pp) 2 🟢 -
Tool Usage 100% (+0pp) - -
URL Validity 100% (+19pp) 1 🟢 -
SQL Identifier Quoting 93.3% (-7.000000000000001pp) - 1 🔴
SQL Validity 86.7% (-13pp) - 1 🔴
Time_to_first_token 0.32tok (+0.08tok) 1 🟢 11 🔴
Llm_calls 8.44 (+0.11) 4 🟢 3 🔴
Tool_calls 3.19 (-0.11) 4 🟢 4 🔴
Errors 0 (+0) - -
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 55868.72tok (+11577.64tok) 3 🟢 9 🔴
Prompt_cached_tokens 25052.44tok (+2883.56tok) 7 🟢 4 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Completion_tokens 2687.33tok (+173tok) 5 🟢 7 🔴
Completion_reasoning_tokens 1889.78tok (+58.67tok) 5 🟢 7 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 58556.06tok (+11750.64tok) 4 🟢 8 🔴
Estimated_cost 0.01$ (+0$) 5 🟢 7 🔴
Duration 31.62s (-3.63s) 10 🟢 2 🔴
Llm_duration 61.17s (-9.74s) 11 🟢 1 🔴

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants