Skip to content

feat(studio): logs SQL execution wiring + source-aware run gestures - #48414

Merged
charislam merged 3 commits into
masterfrom
charislam/execution-wiring-run-gestures
Jul 29, 2026
Merged

charislam merged 3 commits into
masterfrom
charislam/execution-wiring-run-gestures

Conversation

@charislam

@charislam charislam commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

I have read the CONTRIBUTING.md file.

YES

What kind of change does this PR introduce?

Feature (SQL editor: execution wiring for logs-source snippets). Part of the stacked SQL-editor "Database vs Logs" query-source series.

What is the current behavior?

The SQL editor only ever runs queries against the user's Postgres database. There is no execution path for a logs (log_sql) snippet, and the run-button telemetry event carries no backend discriminator.

What is the new behavior?

  • useRunSource(id) derives the run backend from the snippet type; a log_sql snippet resolves to { type: 'logs', dateRange }, pairing the run with its session time range (default: last hour).
  • useLogsSqlExecution runs a promoted SafeLogSqlFragment against the analytics OTEL (ClickHouse) endpoint with the resolved time range as iso_timestamp_start/iso_timestamp_end request params. The endpoint is pinned to OTEL — a snippet's dialect must not flip with org migration.
  • The run gestures (toolbar button and Cmd+Enter) branch on the source and promote with the matching acceptUntrusted* right at the user action, preserving the auditable promotion-at-gesture boundary. pg intellisense is gated off for logs snippets.
  • The sql_editor_query_run_button_clicked telemetry event gains a required { source: 'database' | 'logs' } property, fired from both execution paths.
  • Capability guard: a log_sql snippet is reachable by direct URL regardless of the (later) entry-point flag gating, so executeLogsQuery short-circuits when otelLegacyLogs is off — recording a clear "not available yet" result message instead of firing a request that would only return an opaque backend error on a non-ClickHouse project. This is a guard on the gesture, not endpoint selection.
  • Tests: useRunSource routing, useLogsSqlExecution endpoint/range/structured-error/capability-guard, and a reusable flags option on renderSqlEditorHook.

No UI entry points are added — the feature runs dark until the flag-gated creation/nav PRs later in the stack.

Additional context

Stacked on the query-source series; base branch is master now that PR 4 (log date range domain + session state, #48401) is merged. Follow-ups in the stack add the toolbar/creation UI (with a run-affordance gate on otelLegacyLogs), nav section, AI dialect support, and reports guard.

Summary by CodeRabbit

  • New Features

    • Added support for running log queries directly from the SQL editor.
    • Log query results, errors, and time ranges are now handled within the editor session.
    • Added automatic selection between database and log query execution, including support for custom date ranges.
    • SQL assistance is disabled while editing log queries where database definitions do not apply.
  • Tests

    • Added coverage for log query execution, date ranges, feature availability, and execution source selection.

- Add useRunSource(id): QuerySource, deriving the run backend from the
  snippet type and pairing logs runs with their session time range.
- Add useLogsSqlExecution: runs a promoted SafeLogSqlFragment against the
  analytics OTEL endpoint (pinned to ClickHouse) with the resolved range as
  request params; success/structured-error write to the session result store.
- Extend the Run context with runSource, executeLogsQuery, and
  readEditorLogsSql; the toolbar and Cmd+Enter gestures branch on the source
  and promote with the matching acceptUntrusted* at the user action.
- Gate pg intellisense off for logs snippets via useAddDefinitions({ enabled }).
- Add a required { source: 'database' | 'logs' } property to the run-button
  telemetry event and fire it from both execution paths.
- Tests: useRunSource routing + useLogsSqlExecution endpoint/range/error.
A log_sql snippet is reachable by direct URL regardless of the entry-point
flag gating, so a project still on legacy (BigQuery) logs could reach the
run gesture. Short-circuit executeLogsQuery when otelLegacyLogs is off,
recording a clear "not available yet" result-pane message instead of firing
a request that would only return an opaque backend error. This is a
capability guard on the gesture, not endpoint selection — the endpoint stays
pinned to OTEL. Extend renderSqlEditorHook with a `flags` option so tests can
set feature flags, and cover the guard.
@charislam
charislam requested review from a team as code owners July 28, 2026 19:05
@vercel

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

Request Review

@supabase

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

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The SQL editor now identifies database and logs snippets, routes each to its corresponding execution pipeline, sends logs SQL with an active time range, stores OTEL results in session state, and records the execution source in telemetry.

Changes

SQL Editor Execution

Layer / File(s) Summary
Execution source and SQL contracts
apps/studio/components/interfaces/SQLEditor/SQLEditor.types.ts, apps/studio/components/interfaces/SQLEditor/SQLEditor.utils.ts, apps/studio/components/interfaces/SQLEditor/SQLEditorContext.tsx, apps/studio/components/interfaces/SQLEditor/querySource.ts, apps/studio/components/interfaces/SQLEditor/useRunSource.ts, apps/studio/components/interfaces/SQLEditor/useRunSource.test.tsx
SQL extraction accepts string snippets, while useRunSource resolves database or logs execution with default or stored log ranges.
Logs execution and session results
apps/studio/components/interfaces/SQLEditor/useLogsSqlExecution.ts, apps/studio/components/interfaces/SQLEditor/useLogsSqlExecution.test.tsx, apps/studio/tests/lib/sql-editor-test-utils.tsx
Logs SQL is sent to the OTEL endpoint with resolved timestamps; rows, errors, feature-flag behavior, and test flag provisioning are covered.
Run context and database definitions
apps/studio/components/interfaces/SQLEditor/SQLEditorControllers.tsx, apps/studio/components/interfaces/SQLEditor/useAddDefinitions.ts, apps/studio/components/interfaces/SQLEditor/useSqlEditorExecution.ts, packages/common/telemetry-constants.ts
The run context exposes logs execution fields, combines execution states, disables database definitions for logs, and adds execution-source telemetry metadata.
Source-aware editor run actions
apps/studio/components/interfaces/SQLEditor/SQLEditorEditorPanel.tsx, apps/studio/components/interfaces/SQLEditor/SQLEditorLayout.tsx
Editor and toolbar run actions route logs and database SQL through their respective acceptance and execution functions.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: alaister, myerekapan

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: logs SQL execution wiring with source-aware run behavior.
Description check ✅ Passed The description matches the template sections and provides the required current behavior, new behavior, and additional context.
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/execution-wiring-run-gestures

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
apps/studio/components/interfaces/SQLEditor/useLogsSqlExecution.test.tsx (1)

34-34: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Parse the mocked request payload instead of asserting it.

request.json() is unknown; validate it with a local Zod schema before pushing it into captured rather than bypassing the shape check with as CapturedBody. As per coding guidelines, “Avoid TypeScript as casts; parse external data with zod using parse or safeParse.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/studio/components/interfaces/SQLEditor/useLogsSqlExecution.test.tsx` at
line 34, Replace the CapturedBody type assertion in the mocked request handler
with a local Zod schema that validates request.json() using parse or safeParse,
then push the validated result into captured. Keep the existing captured payload
behavior unchanged while removing the unsafe cast.

Source: Coding guidelines

apps/studio/components/interfaces/SQLEditor/SQLEditorLayout.tsx (1)

73-93: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the source-branching run logic into a shared hook. Both the toolbar and the editor's Cmd+Enter gesture independently implement the same runSource.type === 'logs' branch → read matching SQL → promote via matching acceptUntrusted* → call matching execute function. Centralizing this into a single hook (e.g., useRunQueryGesture()) would prevent the two call sites from silently diverging as sources evolve.

  • apps/studio/components/interfaces/SQLEditor/SQLEditorLayout.tsx#L73-L93: extract this branching body (plus its refocus calls) into a shared hook that both this toolbar and the editor panel consume.
  • apps/studio/components/interfaces/SQLEditor/SQLEditorEditorPanel.tsx#L140-L149: replace this near-duplicate branching body with a call into the same shared hook (optionally parameterized to skip the refocus calls this call site doesn't use).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/studio/components/interfaces/SQLEditor/SQLEditorLayout.tsx` around lines
73 - 93, The duplicated source-specific query execution logic should be
centralized in a shared hook such as useRunQueryGesture. In
apps/studio/components/interfaces/SQLEditor/SQLEditorLayout.tsx lines 73-93,
move the runSource branching, SQL reads, trust promotion, execution calls, and
refocus handling into the hook; in
apps/studio/components/interfaces/SQLEditor/SQLEditorEditorPanel.tsx lines
140-149, replace the duplicate branching with the same hook, allowing refocus
behavior to be disabled for this call site if needed.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/studio/components/interfaces/SQLEditor/useLogsSqlExecution.test.tsx`:
- Line 36: Remove the explicit any generic from both HttpResponse.json calls in
the test handlers, allowing MSW to infer the response type; if inference is
insufficient, use a concrete response type instead.

---

Nitpick comments:
In `@apps/studio/components/interfaces/SQLEditor/SQLEditorLayout.tsx`:
- Around line 73-93: The duplicated source-specific query execution logic should
be centralized in a shared hook such as useRunQueryGesture. In
apps/studio/components/interfaces/SQLEditor/SQLEditorLayout.tsx lines 73-93,
move the runSource branching, SQL reads, trust promotion, execution calls, and
refocus handling into the hook; in
apps/studio/components/interfaces/SQLEditor/SQLEditorEditorPanel.tsx lines
140-149, replace the duplicate branching with the same hook, allowing refocus
behavior to be disabled for this call site if needed.

In `@apps/studio/components/interfaces/SQLEditor/useLogsSqlExecution.test.tsx`:
- Line 34: Replace the CapturedBody type assertion in the mocked request handler
with a local Zod schema that validates request.json() using parse or safeParse,
then push the validated result into captured. Keep the existing captured payload
behavior unchanged while removing the unsafe cast.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0ff2dc33-53c0-40a0-8f21-c0df9754d124

📥 Commits

Reviewing files that changed from the base of the PR and between 944b41c and a1a14e1.

📒 Files selected for processing (15)
  • apps/studio/components/interfaces/SQLEditor/SQLEditor.types.ts
  • apps/studio/components/interfaces/SQLEditor/SQLEditor.utils.ts
  • apps/studio/components/interfaces/SQLEditor/SQLEditorContext.tsx
  • apps/studio/components/interfaces/SQLEditor/SQLEditorControllers.tsx
  • apps/studio/components/interfaces/SQLEditor/SQLEditorEditorPanel.tsx
  • apps/studio/components/interfaces/SQLEditor/SQLEditorLayout.tsx
  • apps/studio/components/interfaces/SQLEditor/querySource.ts
  • apps/studio/components/interfaces/SQLEditor/useAddDefinitions.ts
  • apps/studio/components/interfaces/SQLEditor/useLogsSqlExecution.test.tsx
  • apps/studio/components/interfaces/SQLEditor/useLogsSqlExecution.ts
  • apps/studio/components/interfaces/SQLEditor/useRunSource.test.tsx
  • apps/studio/components/interfaces/SQLEditor/useRunSource.ts
  • apps/studio/components/interfaces/SQLEditor/useSqlEditorExecution.ts
  • apps/studio/tests/lib/sql-editor-test-utils.tsx
  • packages/common/telemetry-constants.ts

response: async ({ request }) => {
const body = (await request.json()) as CapturedBody
captured.push(body)
return HttpResponse.json<any>({ result: rows })

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== file excerpt =="
sed -n '1,120p' apps/studio/components/interfaces/SQLEditor/useLogsSqlExecution.test.tsx || true

echo
echo "== occurrences of HttpResponse.json<any> in tracked files =="
rg -n "HttpResponse\\.json<any>|HttpResponse\\.json<" apps/studio || true

echo
echo "== lint:ratchet config/scripts if present =="
if [ -f package.json ]; then jq -r '.scripts["lint:ratchet"] // empty' package.json; fi
if [ -f apps/studio/package.json ]; then jq -r '.scripts["lint:ratchet"] // empty' apps/studio/package.json || true; fi

echo
echo "== eslint any relevant configs =="
rg -n "no-explicit-any|`@typescript-eslint/`.*any|ratchet|allowUnused" .github apps/studio package.json apps/studio/package.json 2>/dev/null || true

Repository: supabase/supabase

Length of output: 50374


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== target test file excerpts =="
sed -n '1,110p' apps/studio/components/interfaces/SQLEditor/useLogsSqlExecution.test.tsx

echo
echo "== targeted HttpResponse.json<any> count =="
python3 - <<'PY'
from pathlib import Path
import re
p=Path('apps/studio/components/interfaces/SQLEditor/useLogsSqlExecution.test.tsx')
text=p.read_text()
print(len(re.findall(r'HttpResponse\.json<any>', text)))
for i,line in enumerate(text.splitlines(),1):
    if 'HttpResponse.json<any>' in line:
        print(f'{i}: {line.strip()}')
PY

echo
echo "== lint:ratchet scripts =="
for f in package.json apps/studio/package.json; do
  if [ -f "$f" ]; then
    echo "-- $f --"
    node -e "const fs=require('fs'); const pkg=JSON.parse(fs.readFileSync('$f','utf8')); console.log(JSON.stringify(pkg.scripts?.['lint:ratchet']??null,null,2))"
  fi
done

echo
echo "== any count relevant config mentions =="
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' "lint:ratchet|no-explicit-any|explicit-any|allowUnsafe|allowUnnecessary|`@typescript-eslint`" .github apps/studio package.json apps/studio/package.json .eslintrc* eslint.config.* 2>/dev/null | head -200 || true

Repository: supabase/supabase

Length of output: 8985


Remove the explicit any response types.

apps/studio/components/interfaces/SQLEditor/useLogsSqlExecution.test.tsx now adds explicit any, which is tracked by the studio ratcheted @typescript-eslint/no-explicit-any baseline. Let MSW infer the response type at both HttpResponse.json<any> calls, or replace them with concrete response types.

Proposed fix
-      return HttpResponse.json<any>({ result: rows })
+      return HttpResponse.json({ result: rows })
...
-        HttpResponse.json<any>({
+        HttpResponse.json({
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return HttpResponse.json<any>({ result: rows })
return HttpResponse.json({ result: rows })
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/studio/components/interfaces/SQLEditor/useLogsSqlExecution.test.tsx` at
line 36, Remove the explicit any generic from both HttpResponse.json calls in
the test handlers, allowing MSW to infer the response type; if inference is
insufficient, use a concrete response type instead.

Source: Coding guidelines

@github-actions

github-actions Bot commented Jul 28, 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  5 minutes, 22 seconds
commit  a1a14e1

Flaky tests

Features › table-editor.spec.ts › table editor › should show rls accordingly

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

@seanoliver seanoliver 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.

LGTM!

Comment on lines +40 to +45
if (!isOtelLogsEnabled) {
getSqlEditorSessionSnapshot().addResultError(id, {
message: "Querying logs from the SQL editor isn't available for this project yet.",
})
return
}

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.

Do we want to track or log the error here? This looks like the only code path where we're not sending an event.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is just a failsafe while the feature flag is being rolled out, there is a very niche way in which users can manually reach this screen which requires bypassing the rest of the UI, I think it's safe to not track it.

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.

SGTM! Thanks for following up!

@charislam
charislam merged commit 4c8ed10 into master Jul 29, 2026
37 checks passed
@charislam
charislam deleted the charislam/execution-wiring-run-gestures branch July 29, 2026 14:43
@github-actions

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1785336424)

Score Average Improvements Regressions
Completeness 98.9% (-1pp) - 1 🔴
Conciseness 39.7% (-4pp) 8 🟢 9 🔴
Correctness 67.8% (-3pp) 1 🟢 3 🔴
Docs Faithfulness 69.3% (+8pp) 5 🟢 3 🔴
Goal Completion 79.9% (+1pp) 4 🟢 5 🔴
Knowledge Usage 97.4% (+0pp) - -
Tool Usage 74.5% (+6pp) 2 🟢 -
Safety 100% (+0pp) - -
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
Time_to_first_token 3.27tok (-0.02tok) 19 🟢 10 🔴
Llm_calls 7.11 (+1.36) 22 🟢 5 🔴
Tool_calls 3.05 (+0.16) 12 🟢 8 🔴
Errors 0 (-2.34) 24 🟢 -
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 23833.34tok (+601.59tok) 11 🟢 14 🔴
Prompt_cached_tokens 6579.49tok (-276.6tok) 11 🟢 13 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 607.45tok (+10.32tok) 16 🟢 13 🔴
Completion_reasoning_tokens 94.22tok (-8.82tok) 13 🟢 13 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 24440.79tok (+611.91tok) 13 🟢 16 🔴
Estimated_cost 0$ (+0$) 13 🟢 14 🔴
Duration 18.68s (+0.78s) 13 🟢 16 🔴
Llm_duration 12.55s (+0.37s) 16 🟢 13 🔴

charislam added a commit that referenced this pull request Jul 30, 2026
…8452)

## What

PR 6 of the SQL-editor "query source (Database vs Logs)" stack (builds
on the merged PR 5, #48414). Adds the user-facing toolbar surface for
the logs query source and consolidates the SQL-editor toolbar into a
single **source menu**.

Everything stays behind `sqlEditorLogsSource` + `otelLegacyLogs`
(dual-flag gated); with the flags off the toolbar is unchanged.

## Changes

- **Consolidated source menu** (`QuerySourceMenu`) — one `Database ▾` /
`Logs ▾` dropdown that both labels the snippet's source and hosts the
source-specific controls as flyout submenus:
- Database: database selector (`Primary` / read replicas), `Run as`
(role impersonation), and `Row limit`.
- Logs: `Time range` — the same relative presets as the Logs Explorer
plus a `Custom range…` calendar dialog.
- **Source is immutable** — the Database/Logs rows aren't a toggle. An
existing (materialized) snippet opens a *fresh* tab of the target source
(never reinterpreting a query against the wrong backend); a blank new
tab re-flavors in place. Extracted as the pure, unit-tested
`resolveSourceSwitch`.
- **New-snippet-with-source** threaded through `/sql/new?source=`, the
nav "Create a new logs query" entry, and the duplicate flow. Logs
snippets hide the (db-dialect) Export action.
- **Run-affordance guard** — the Run button is disabled + annotated for
a logs snippet on a non-ClickHouse org (sits above PR 5's execution
short-circuit).
- **Retention entitlement gating** — both preset and custom logs ranges
past `log.retention_days` surface the upgrade prompt instead of applying
silently. Prettify is disabled for logs (sql-formatter mangles
ClickHouse).

## Tests

- `querySource.test.ts` — `logDateRangesEqual` (structural
relative/absolute matching, incl. the "Last hour" vs "Last 1 hour" label
case).
- `QuerySourceMenu.utils.test.ts` — `resolveSourceSwitch`
push-vs-replace / no-op behavior.

`pnpm --filter studio typecheck` · `lint:ratchet` · Prettier · SQL
editor suite (307 tests) all green.

## For reviewers

To test manually, enable the `sqlEditorLogsSource` feature flag for
yourself on local/staging. There is no nav for Log SQL snippets
currently (that is by design, this PR is big enough as-is), so to check
an existing logs snippet, you can create one using the existing Logs
Explorer, copy its UUID, and force navigate to that snippet in the SQL
editor via URL.

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

## Summary by CodeRabbit

* **New Features**
* Added support for creating and switching between database and logs
queries.
  * Added log time-range presets and custom date-range selection.
  * Added database, run-as role, and row-limit controls.
* Added read-replica selection, including options to create a new
replica when available.
* **Improvements**
  * Added clearer explanations when query execution is unavailable.
* Disabled SQL formatting and query export where unsupported for logs
queries.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Joshen Lim <[email protected]>
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.

3 participants