Skip to content

feat(studio): add sources to Explorer queries - #49028

Closed
SaxonF wants to merge 17 commits into
masterfrom
chore/explorer-query-sources
Closed

SaxonF wants to merge 17 commits into
masterfrom
chore/explorer-query-sources

Conversation

@SaxonF

@SaxonF SaxonF commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor
image

Stack

Depends on #49038. Followed by #49039.

Summary

  • store a validated database or logs source binding with each Explorer query
  • expose database, replica, logs, and log time-range controls in the shared query editor
  • dispatch runs to Postgres or logs using the selected source configuration
  • retain safe defaults when restoring older drafts without source metadata
  • gate unavailable logs sources and surface source-specific execution errors

To test

  1. Open Explorer, select Run SQL, and run a query using the default database source.
  2. Select another database or Logs from the source menu, adjust its options, and confirm the query runs against that source.

Why

Explorer queries need the same source model as the SQL editor and future notebook or chat query surfaces, without coupling drafts to SQL snippets.

Impact

The shared query editor now owns source selection and execution. Query tabs provide source state in this layer; notebook query cells continue using the primary database until notebook source metadata is introduced.

Validation

  • mise exec node@22 -- pnpm --dir apps/studio exec vitest --run components/interfaces/Explorer/ExplorerQuerySourceMenu.test.tsx state/explorer-query.test.ts state/tabs.test.ts
  • 23 tests passed at this stack boundary

@vercel

vercel Bot commented Aug 13, 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 Aug 13, 2026 10:56am
studio-staging Ready Ready Preview Aug 13, 2026 10:56am
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Aug 13, 2026 10:56am
design-system Skipped Skipped Aug 13, 2026 10:56am
docs Skipped Skipped Aug 13, 2026 10:56am
ui-library Skipped Skipped Aug 13, 2026 10:56am
zone-www-dot-com Skipped Skipped Aug 13, 2026 10:56am

Request Review

@supabase

supabase Bot commented Aug 13, 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 Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 75f1442a-d8e6-4f52-a453-8c6ede033efd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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 Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results (next)

passed  242 passed
flaky  1 flaky
skipped  5 skipped

Details

stats  248 tests across 29 suites
duration  6 minutes, 51 seconds
commit  cee673b

Flaky tests

Features › queue-table-operations.spec.ts › Queue Table Operations - queue identity fixes › deleting a newly inserted row removes it from pending changes

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

@SaxonF
SaxonF force-pushed the chore/explorer-query-sources branch 2 times, most recently from f5f0771 to bf7940f Compare August 13, 2026 01:54
@SaxonF
SaxonF marked this pull request as ready for review August 13, 2026 03:20
@SaxonF
SaxonF requested a review from a team as a code owner August 13, 2026 03:20
@SaxonF
SaxonF force-pushed the chore/query-source-registry branch from e648a8c to f331cab Compare August 13, 2026 03:22
@SaxonF
SaxonF force-pushed the chore/explorer-query-sources branch 2 times, most recently from dfc8bf7 to 529d033 Compare August 13, 2026 05:04
@SaxonF
SaxonF changed the base branch from chore/query-source-registry to chore/explorer-query-tabs August 13, 2026 05:05
@SaxonF SaxonF changed the title feat(studio): add Explorer query tabs with sources feat(studio): add sources to Explorer queries Aug 13, 2026
@SaxonF
SaxonF force-pushed the chore/explorer-query-sources branch 2 times, most recently from 47464d0 to 65f9a99 Compare August 13, 2026 06:02
@SaxonF
SaxonF force-pushed the chore/explorer-query-tabs branch from 643aa5d to 72379eb Compare August 13, 2026 06:20
@SaxonF
SaxonF force-pushed the chore/explorer-query-sources branch from 65f9a99 to 7c621e8 Compare August 13, 2026 06:20
…y-editor

# Conflicts:
#	apps/studio/components/interfaces/Explorer/QueryCell/DisplaySettingsButton.tsx
#	apps/studio/components/interfaces/Explorer/QueryCell/QueryResultChart.tsx
#	apps/studio/components/interfaces/Explorer/QueryCell/index.tsx
@joshenlim
joshenlim force-pushed the chore/explorer-query-tabs branch from da658e1 to c9ac48c Compare August 13, 2026 10:59
Base automatically changed from chore/explorer-query-tabs to master August 13, 2026 16:03
joshenlim added a commit that referenced this pull request Aug 13, 2026
<img width="1693" height="1037" alt="image"
src="https://github.com/user-attachments/assets/51fdf618-f06e-45ca-bf30-e1307dfbb372"
/>


## Stack

Depends on #49041. Followed by #49028.

## Summary

- add a dedicated ad-hoc query tab type and route under Explorer
- connect query tabs to the shared `QueryEditor` through a `QueryTab`
lifecycle adapter
- add local query draft/result state and restore query tabs from their
routes
- confirm before closing populated local-only drafts and clean up their
state on close

## To test

1. Open Explorer, select **Run SQL**, enter `select 1`, and run the
query.
2. Rename the query, reload the page, then close the tab and confirm the
discard prompt appears.

## Why

Explorer needs a lightweight place to run SQL without creating a
snippet. This layer adds the query-tab lifecycle on top of the shared
editor foundation.

## Impact

Queries in this layer run against the selected project's primary
database. Drafts are local to the browser and are discarded when their
tabs are closed.

## Validation

- fresh non-incremental Studio TypeScript check
- 22 focused tests across query draft state, tab state, and notebook tab
registration

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

* **New Features**
* Added support for creating, opening, editing, and running SQL queries
in Explorer.
  * Added project-scoped persistence for query drafts and results.
  * Added dedicated query routes, query icons, and query tabs.
  * Added unsaved-changes warnings when closing query tabs.
  * Added a pinned Explorer Home tab and “New query” option.
  * Improved notebook tab registration and editor tab organization.

* **Bug Fixes**
  * Improved tab navigation, closing behavior, and layout.

* **Tests**
* Added coverage for query persistence, cleanup, restoration, and tab
navigation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Joshen Lim <[email protected]>
joshenlim added a commit that referenced this pull request Aug 13, 2026
## Context

This is just pulling out the relevant changes from
#49028 as I might have messed
up the stack while making changes down the PRs 🙏

Builds on the Query Tab in the Explorer UI, adds the source selector
component to run either a database query or a logs query - will
subsequently be looking into have the source selector component in the
QueryCell as well (within notebooks)

<img width="1095" height="594" alt="image"
src="https://github.com/user-attachments/assets/ab6e8d91-aed3-4845-9777-acbd7a3a7cb1"
/>
<img width="1086" height="667" alt="image"
src="https://github.com/user-attachments/assets/75d99063-755d-4ba6-a128-7ddcbbc9f161"
/>


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

## Summary by CodeRabbit

- **New Features**
  - Added query-source selection for Explorer and notebook queries.
- Supports log queries, database selection, and read-replica
connections.
- Added validation for custom log time ranges and retention limits, with
upgrade guidance when applicable.
  - Query source choices are saved and restored across sessions.
  - Changing sources clears previous results to prevent stale data.

- **Bug Fixes**
- Improved handling of unavailable log querying and missing database
connections.
- Legacy saved queries now fall back safely to the default database
source.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@SaxonF SaxonF closed this Aug 25, 2026
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