Skip to content

feat(sql-editor): consolidate controls into a single top bar - #47792

Merged
charislam merged 2 commits into
masterfrom
charislam/sql-editor-top-bar-controls
Jul 10, 2026
Merged

charislam merged 2 commits into
masterfrom
charislam/sql-editor-top-bar-controls

Conversation

@charislam

@charislam charislam commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

I have read the CONTRIBUTING.md file.

YES

What kind of change does this PR introduce?

Refactor / UI improvement

What is the current behavior?

SQL editor controls are split across two rows: a bar between the editor and results (tabs, download, run/save/format/db-selector/role/favorite/intellisense) and a separate footer at the very bottom (row count + limit dropdown).

What is the new behavior?

All controls are consolidated into a single top bar above the editor (⋮ overflow menu, database selector, role impersonation, limit, save, run). The bar between the editor and results now holds only result-relevant information: the Results/Explain/Chart tabs, the row-count summary, and the Export button. The limit dropdown is now always visible as a persistent query setting.

Summary by CodeRabbit

  • New Features

    • Added a dedicated editor actions bar with query execution, formatting, and result-limit controls.
    • Added a dropdown for selecting the number of results to display.
    • Added a tooltip showing result counts and automatic result limits.
  • Improvements

    • Reorganized SQL editor controls for a clearer, more streamlined layout.

Move all SQL editor controls (run, save, database selector, role impersonation, limit, prettify, intellisense, favorite) into a single top bar above the editor. The bar between the editor and results now holds only result-relevant info: the Results/Explain/Chart tabs, row-count summary, and Export button.
@charislam
charislam requested a review from a team as a code owner July 9, 2026 17:50
@vercel

vercel Bot commented Jul 9, 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 10, 2026 2:11pm
docs Ready Ready Preview, Comment, Open in v0 Jul 10, 2026 2:11pm
studio-self-hosted Ready Ready Preview, Comment Jul 10, 2026 2:11pm
studio-staging Ready Ready Preview, Comment Jul 10, 2026 2:11pm
ui-library Ready Ready Preview, Comment Jul 10, 2026 2:11pm
zone-www-dot-com Ready Ready Preview, Comment, Open in v0 Jul 10, 2026 2:11pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Jul 10, 2026 2:11pm

Request Review

@supabase

supabase Bot commented Jul 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 Jul 9, 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: 703134d5-3905-43fc-ad60-61cd2edadf14

📥 Commits

Reviewing files that changed from the base of the PR and between 940e58e and 8be61da.

📒 Files selected for processing (1)
  • apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityActions.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityActions.tsx

📝 Walkthrough

Walkthrough

SQL Editor UI is restructured: row limit and results-count controls move from SQLEditor’s GridFooter into UtilityActions, which is rendered above the resizable editor panels. UtilityPanel drops action-related props and gains a row-count tooltip.

Changes

Row Limit and Results UI Relocation

Layer / File(s) Summary
Add Limit dropdown to UtilityActions
apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityActions.tsx
Adds an optional className prop and a Limit dropdown bound to sessionSnap.limit and sessionSnap.setLimit, using ROWS_PER_PAGE_OPTIONS.
Wire UtilityActions into SQLEditor and remove old footer
apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
Renders UtilityActions above the resizable panels, removes local result and GridFooter handling, updates imports, and trims props passed to UtilityPanel.
Simplify UtilityPanel props and add row-count tooltip
apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityPanel.tsx
Removes action props and UtilityActions rendering, and adds a tooltip showing result row count and auto-limit information.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: awaseem, myerekapan, joshenlim

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: consolidating SQL editor controls into a single top bar.
Description check ✅ Passed The description covers the required sections and main behavior change; only the optional additional-context section is omitted.
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 charislam/sql-editor-top-bar-controls

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 9, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results (tanstack)

passed  238 passed
skipped  5 skipped

Details

stats  243 tests across 28 suites
duration  3 minutes, 36 seconds
commit  8be61da

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 3461d60 into master Jul 10, 2026
37 checks passed
@charislam
charislam deleted the charislam/sql-editor-top-bar-controls branch July 10, 2026 14:27
@github-actions

github-actions Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1783693824)

Score Average Improvements Regressions
Knowledge Usage 97.4% (-3pp) - 1 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
Tool Usage 72.5% (+1pp) 1 🟢 -
Time_to_first_token 3.05tok (-6.72tok) 20 🟢 9 🔴
Llm_calls 2.61 (-0.11) 7 🟢 12 🔴
Tool_calls 2.92 (-0.11) 7 🟢 11 🔴
Errors 5.24 (-0.09) 9 🟢 3 🔴
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 23814.92tok (-981.07tok) 12 🟢 13 🔴
Prompt_cached_tokens 7321.01tok (-759.17tok) 7 🟢 14 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 591.86tok (+4.68tok) 17 🟢 12 🔴
Completion_reasoning_tokens 97.09tok (+1.28tok) 16 🟢 10 🔴
Total_tokens 24406.78tok (-976.39tok) 14 🟢 15 🔴
Estimated_cost 0$ (0$) 12 🟢 13 🔴
Duration 15.98s (-9.39s) 16 🟢 13 🔴
Llm_duration 10.78s (-10.19s) 17 🟢 12 🔴

charislam added a commit that referenced this pull request Jul 10, 2026
#47820)

## Summary

Add some tests for the SQL editor so I can refactor it without
regressions. Tests are not best practice because they are intended to be
temporary and improving them would require refactoring first (currently
they are over-mocking and asserting on internal details).

Stacked on top of #47792 (`charislam/sql-editor-top-bar-controls`).

## What this adds

`apps/studio/tests/components/SQLEditor/SQLEditor.test.tsx` (11 tests):

- Run success → `addResult` + Results tab; EXPLAIN-shaped result
auto-switches to the explain tab; a non-EXPLAIN run switches back.
- Run error with `position` → error-highlight line math +
`deltaDecorations` + `revealLineInCenter`; the next run clears the
highlight.
- Run button refocuses the editor; disabled + short-circuits while a
diff is open.
- Diff request queued before mount drains exactly once (one-shot; no
re-apply on remount).
- Ask-AI widget renders only while the prompt is open (render-time
`editorRef.current` read).
- Destructive query → warning modal → confirm forces the re-run;
confirm-with-RLS appends enable-RLS statements.

## Test approach

Real Monaco / DiffEditor are replaced with lightweight fakes exposing a
controllable editor; child panels + orthogonal context hooks are
stubbed; the execute mutation runs for real against an MSW-mocked
`/platform/pg-meta/:ref/query`. Tests assert on public behavior so they
survive the internal refactor unchanged.

## Verification

- `pnpm --filter studio exec vitest run
tests/components/SQLEditor/SQLEditor.test.tsx` — 11/11 pass (stable
across repeated runs)
- `pnpm --filter studio typecheck` — clean
- `eslint` — 0 errors

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Tests**
* Added comprehensive coverage for SQL editor behavior, including query
execution, result and explain views, error highlighting, editor focus,
and diff mode.
* Added validation for destructive-query confirmations, including RLS
confirmation flows.
* Added coverage for queued diff requests and conditional AI prompt
display.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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