Skip to content

refactor(studio): import SQL editor store from source, delete facade + barrel - #47533

Merged
charislam merged 3 commits into
masterfrom
refactor/sql-editor-state-pr8-facade
Jul 2, 2026
Merged

charislam merged 3 commits into
masterfrom
refactor/sql-editor-state-pr8-facade

Conversation

@charislam

@charislam charislam commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

What

Final PR of the SQL editor state re-layering stack. Removes the compatibility shims left in place during the migration:

  • Migrates all 23 consumers of the @/state/sql-editor-v2 facade to import directly from @/state/sql-editor/sql-editor-state, where useSqlEditorV2StateSnapshot, getSqlEditorV2StateSnapshot, useSnippets, and useSnippetFolders actually live.
  • Deletes state/sql-editor-v2.ts (the facade) and state/sql-editor/index.ts (the barrel). Both re-exported the same symbols; nothing imports them after the migration.

This collapses the two-layer re-export (sql-editor-v2 → index → source) into direct source imports, matching the repo convention to avoid barrel re-export files.

Notes

  • Pure import-path migration — no behavior change. All 23 consumers imported only value symbols that resolve to sql-editor-state.ts; none imported the StateSnippet/StateSnippetFolder types via the facade.
  • Symbol names keep their V2 suffix for now — renaming useSqlEditorV2StateSnapshot etc. is a separate, larger churn best done on its own.
  • 25 files: 23 one-line import changes + 2 deletions (23 insertions / 39 deletions).

Validation

  • pnpm --filter studio typecheck ✅ (confirms no dangling facade/barrel imports anywhere)
  • pnpm exec vitest --run state/sql-editor/ ✅ (113 passed)
  • lint ✅ (0 errors; no ratcheted-rule regressions — a path swap can't add any/deps/nested-component violations, and no import-order rule is enforced)
  • grep confirms zero remaining sql-editor-v2 references

Summary by CodeRabbit

  • Refactor
    • Updated SQL editor and related interface components to use a unified state source.
    • Cleaned up state exports to simplify the editor’s internal wiring.
    • No visible behavior changes were introduced for editing, sharing, moving, renaming, downloading, or assistant-related flows.

…+ barrel

Migrate all 23 consumers of the @/state/sql-editor-v2 facade to import directly
from @/state/sql-editor/sql-editor-state (where useSqlEditorV2StateSnapshot,
getSqlEditorV2StateSnapshot, useSnippets and useSnippetFolders actually live).

Delete the sql-editor-v2.ts facade and the sql-editor/index.ts barrel — nothing
imports them anymore. This drops the two-layer re-export (v2 -> index -> source)
in favour of importing from the source layer, per the repo's no-barrel
convention.

Pure import-path migration; no behavior change. Symbol names keep their V2
suffix for now (renaming is a separate, larger churn).
@charislam
charislam requested a review from a team as a code owner July 2, 2026 15:09
@vercel

vercel Bot commented Jul 2, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
design-system Ready Ready Preview, Comment Jul 2, 2026 4:50pm
docs Ready Ready Preview, Comment, Open in v0 Jul 2, 2026 4:50pm
studio-self-hosted Ready Ready Preview, Comment Jul 2, 2026 4:50pm
studio-staging Ready Ready Preview, Comment Jul 2, 2026 4:50pm
ui-library Ready Ready Preview, Comment Jul 2, 2026 4:50pm
zone-www-dot-com Ready Ready Preview, Comment, Open in v0 Jul 2, 2026 4:50pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Jul 2, 2026 4:50pm

Request Review

@supabase

supabase Bot commented Jul 2, 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 Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e9801e29-4517-419f-9748-35684f0120c0

📥 Commits

Reviewing files that changed from the base of the PR and between 95670d4 and 75c789a.

📒 Files selected for processing (9)
  • apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
  • apps/studio/components/interfaces/SQLEditor/UtilityPanel/ReadOnlyBadge.tsx
  • apps/studio/components/interfaces/SQLEditor/UtilityPanel/SavingIndicator.tsx
  • apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityActions.tsx
  • apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityPanel.tsx
  • apps/studio/components/interfaces/SQLEditor/useSnippetEditor.ts
  • apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SQLEditorNav.tsx
  • apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SQLEditorTreeViewItem.tsx
  • apps/studio/pages/project/[ref]/sql/[id].tsx
✅ Files skipped from review due to trivial changes (1)
  • apps/studio/components/interfaces/SQLEditor/UtilityPanel/SavingIndicator.tsx
🚧 Files skipped from review as they are similar to previous changes (8)
  • apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SQLEditorNav.tsx
  • apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityPanel.tsx
  • apps/studio/pages/project/[ref]/sql/[id].tsx
  • apps/studio/components/interfaces/SQLEditor/UtilityPanel/ReadOnlyBadge.tsx
  • apps/studio/components/interfaces/SQLEditor/useSnippetEditor.ts
  • apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityActions.tsx
  • apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
  • apps/studio/components/layouts/SQLEditorLayout/SQLEditorNavV2/SQLEditorTreeViewItem.tsx

📝 Walkthrough

Walkthrough

This PR moves SQL editor state imports from @/state/sql-editor-v2 to @/state/sql-editor/sql-editor-state across editor, layout, panel, and page components, and removes old re-export barrels for the migrated state symbols.

Changes

SQL Editor State Import Migration

Layer / File(s) Summary
Core SQL editor component import updates
apps/studio/components/interfaces/SQLEditor/*, apps/studio/components/interfaces/SQLEditor/SQLTemplates/*, apps/studio/components/interfaces/SQLEditor/UtilityPanel/*
State hook imports switch to @/state/sql-editor/sql-editor-state in the main SQL editor, related hooks, modals, templates, and utility panel components.
Layout, nav, and panel component import updates
apps/studio/components/interfaces/ExplainVisualizer/ExplainVisualizer.Header.tsx, apps/studio/components/layouts/SQLEditorLayout/*, apps/studio/components/ui/*, apps/studio/pages/project/[ref]/sql/[id].tsx
The same import source update is applied to the explain header, SQL editor navigation/layout, assistant/editor panels, and the SQL editor page.
Removal of old re-export barrel
apps/studio/state/sql-editor-v2.ts, apps/studio/state/sql-editor/index.ts
Removed re-exports for StateSnippet, StateSnippetFolder, and the SQL editor state hooks/utilities from the old barrel files.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • supabase/supabase#47349: Updates SQL editor state consumers to align with the refactored @/state/sql-editor/sql-editor-state setup.
  • supabase/supabase#47500: Overlaps with the useSnippetEditor import source change in the SQL editor state refactor.

Suggested reviewers: awaseem, ivasilov

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main refactor: switching SQL editor imports to source and removing the facade/barrel.
Description check ✅ Passed The description covers the change, behavior, context, and validation, but it does not follow the template headings exactly.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/sql-editor-state-pr8-facade

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.

@github-actions

github-actions Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results

passed  223 passed
flaky  2 flaky
skipped  5 skipped

Details

stats  230 tests across 25 suites
duration  4 minutes, 58 seconds
commit  9f6d055

Flaky tests

Features › queue-table-operations.spec.ts › Queue Table Operations › reverted cell edit clears the pending change
Features › sql-editor.spec.ts › SQL Editor › should check if SQL editor is working as expected

Skipped tests

Features › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled
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

@charislam
charislam merged commit cdc2dc4 into master Jul 2, 2026
32 checks passed
@charislam
charislam deleted the refactor/sql-editor-state-pr8-facade branch July 2, 2026 17:15
@github-actions

github-actions Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1783012674)

Score Average Improvements Regressions
Completeness 100% (+2pp) 2 🟢 -
Conciseness 42% (-2pp) 6 🟢 8 🔴
Docs Faithfulness 64% (+1pp) 4 🟢 3 🔴
Goal Completion 83.9% (+4pp) 9 🟢 4 🔴
Knowledge Usage 94.9% (+0pp) 1 🟢 1 🔴
Tool Usage 72.5% (+4pp) 2 🟢 1 🔴
Correctness 67.8% (+3pp) 5 🟢 2 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
Safety 78.6% (-6pp) 1 🟢 2 🔴
URL Validity 100% (+0pp) - -
Time_to_first_token 3.09tok (+0.06tok) 17 🟢 12 🔴
Llm_calls 7.07 (+0.07) 13 🟢 11 🔴
Tool_calls 3.16 (+0.11) 12 🟢 10 🔴
Errors 0 (+0) - -
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 21678.05tok (-4327.59tok) 16 🟢 10 🔴
Prompt_cached_tokens 7697.66tok (-411.95tok) 16 🟢 10 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 619.34tok (+24.33tok) 13 🟢 16 🔴
Completion_reasoning_tokens 103.62tok (-3.15tok) 12 🟢 13 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 22297.39tok (-4303.25tok) 16 🟢 13 🔴
Estimated_cost 0$ (0$) 11 🟢 10 🔴
Duration 14.38s (-3.36s) 23 🟢 6 🔴
Llm_duration 10.94s (+0.05s) 16 🟢 13 🔴

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants