Skip to content

refactor(studio): centralize query sources - #49027

Merged
joshenlim merged 5 commits into
masterfrom
chore/query-source-registry
Aug 13, 2026
Merged

joshenlim merged 5 commits into
masterfrom
chore/query-source-registry

Conversation

@SaxonF

@SaxonF SaxonF commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • define application-owned database and logs source contracts, defaults, validation, labels, and execution endpoints
  • extract controlled database and logs parameter controls for reuse outside SQL snippets
  • adapt the SQL editor to the shared source model without changing snippet behavior
  • standardize source icons at 16px with a 2px stroke
  • keep relative logs ranges aligned with the existing date picker units

To test

  1. Open an existing query in the SQL Editor and run it against the database.
  2. Switch the query source to Logs, change the time range, and confirm the query still runs as expected.

Why

Explorer queries and notebook query cells need to select an execution source without coupling that source to SQL snippets. This provides the shared registry and controlled UI foundation for those consumers.

Impact

Existing SQL snippets retain their current database/logs routing and session behavior. The registry documents the SQL editor legacy database-selector adapter while new consumers own their identifier inline. The shared Logs date picker remains unchanged; query ranges support its existing minute, hour, and day units. This PR does not add the Explorer query tab itself.

Validation

  • pnpm --filter studio typecheck
  • focused Vitest coverage for the registry, canonical log-range utilities, SQL execution adapters, source filtering, retention locking, custom ranges, and preset selection
  • pnpm --filter studio run lint:ratchet

Component and state tests cover this change per the Studio testing guidance; no E2E test is added.

Summary by CodeRabbit

  • New Features

    • Added a unified query-source menu for database queries and logs.
    • Added custom log time-range selection with calendar support and retention-aware upgrade prompts.
    • Added consistent source icons and improved database selection handling.
    • Added support for relative and absolute log time ranges.
  • Bug Fixes

    • Improved log-range validation, defaults, and current-time handling.
    • Updated query execution to use the correct source-specific endpoints.
  • Tests

    • Expanded coverage for query sources, log ranges, menus, and retention behavior.

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

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

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 Plus

Run ID: 3015d619-00f0-43b8-afe3-6d1cd0d42de7

📥 Commits

Reviewing files that changed from the base of the PR and between cfba2bf and e648a8c.

📒 Files selected for processing (2)
  • apps/studio/data/query-sources/query-source-registry.test.ts
  • apps/studio/data/query-sources/query-source-registry.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/studio/data/query-sources/query-source-registry.test.ts
  • apps/studio/data/query-sources/query-source-registry.ts

📝 Walkthrough

Walkthrough

The SQL editor now uses a shared query-source registry and LogTimeRange model. New utilities and controlled components handle log ranges, custom dates, source selection, database parameters, session state, validation, and registry-based SQL endpoints.

Changes

Query source and log range migration

Layer / File(s) Summary
Query-source registry contracts
apps/studio/data/query-sources/query-source-registry.ts, apps/studio/data/query-sources/query-source-registry.test.ts
Defines source contracts, defaults, labels, schemas, lookup, default cell sources, and validation tests.
Log time-range utilities
apps/studio/components/interfaces/QuerySources/LogTimeRange.utils.ts, apps/studio/components/interfaces/QuerySources/LogTimeRange.utils.test.ts
Adds conversion, comparison, normalization, resolution, fallback, and fixed-time test coverage.
Controlled logs controls
apps/studio/components/interfaces/QuerySources/LogsCustomRangeDialog.tsx, apps/studio/components/interfaces/QuerySources/LogsTimeRangeSubMenu.tsx, apps/studio/components/interfaces/QuerySources/useLogsCustomRange.ts, apps/studio/components/interfaces/QuerySources/QuerySourceIcon.tsx, apps/studio/components/interfaces/QuerySources/LogsTimeRangeSubMenu.test.tsx
Adds reusable log-range controls, custom date selection, entitlement handling, and source icons.
Menu, session, and execution wiring
apps/studio/components/interfaces/SQLEditor/UtilityPanel/QuerySourceMenu/QuerySourceMenu.tsx, apps/studio/components/interfaces/QuerySources/DatabaseParametersSubMenu.tsx, apps/studio/components/interfaces/SQLEditor/querySource.ts, apps/studio/state/sql-editor/sql-editor-session-state.ts, apps/studio/data/sql/execute-sql-mutation.ts, apps/studio/components/interfaces/SQLEditor/useLogsSqlExecution.ts, apps/studio/components/interfaces/SQLEditor/useRunSource.ts, apps/studio/tests/components/SQLEditor/QuerySourceMenu.test.tsx, apps/studio/components/interfaces/SQLEditor/*test*, apps/studio/tests/features/logs/Logs.Datepickers.test.tsx
Builds source options from the registry, uses controlled database and log selections, migrates session state to LogTimeRange, resolves log ranges, and uses registry endpoints for SQL requests.

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

Mergeability Score: 🔵 Low · up to e648a

The shared database source selector may fail to place the primary database first when results arrive in a different order, creating a bounded selection experience issue. The PR is otherwise mergeable with explicit owner awareness or follow-up for this ordering behavior.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant QuerySourceMenu
  participant LogsTimeRangeSubMenu
  participant useLogsCustomRange
  participant SQLExecution
  User->>QuerySourceMenu: open source menu
  QuerySourceMenu->>LogsTimeRangeSubMenu: provide selected LogTimeRange
  User->>LogsTimeRangeSubMenu: select preset or custom range
  LogsTimeRangeSubMenu->>useLogsCustomRange: validate custom range
  useLogsCustomRange->>QuerySourceMenu: return range or upgrade state
  QuerySourceMenu->>SQLExecution: execute query with source parameters
Loading

Possibly related PRs

Suggested reviewers: joshenlim

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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
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.
Title check ✅ Passed The title clearly summarizes the primary change: centralizing query-source contracts and behavior in Studio.
Description check ✅ Passed The description explains the change, current and new behavior, testing, impact, and context, but does not explicitly confirm CONTRIBUTING.md review.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/query-source-registry

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  4 minutes, 55 seconds
commit  f331cab

Flaky tests

Features › database.spec.ts › Database › Schema Visualizer › table actions work 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

@SaxonF
SaxonF marked this pull request as ready for review August 13, 2026 02:08
@SaxonF
SaxonF requested a review from a team as a code owner August 13, 2026 02:08

@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: 2

🧹 Nitpick comments (6)
apps/studio/components/interfaces/QuerySources/LogTimeRange.utils.ts (1)

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

Remove the unnecessary type assertion.

LogTimeRange stores absolute values as string. The IsoDateTimeString return annotation is not needed here. Remove the as IsoDateTimeString assertion.

Proposed fix
-import { isoDateTimeString, type IsoDateTimeString } from '`@/lib/iso-datetime`'
+import { isoDateTimeString } from '`@/lib/iso-datetime`'

-const nowIsoDateTime = (): IsoDateTimeString => dayjs().toISOString() as IsoDateTimeString
+const nowIsoDateTime = () => dayjs().toISOString()

As per coding guidelines: “Avoid TypeScript as casts.”

🤖 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/QuerySources/LogTimeRange.utils.ts` at line
14, Update nowIsoDateTime to return the dayjs().toISOString() result directly,
removing the unnecessary IsoDateTimeString annotation and as IsoDateTimeString
assertion while preserving the existing ISO timestamp behavior.

Source: Coding guidelines

apps/studio/components/interfaces/SQLEditor/UtilityPanel/QuerySourceMenu/QuerySourceMenu.tsx (2)

87-97: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Rename the internal handlers to the handleX form.

switchSource and updateDatabaseIdentifier are internal event handlers. The studio guidelines require handleX for internal handlers and reserve onX for prop callbacks.

♻️ Optional rename
-  const switchSource = (target: SqlSnippetSource) => {
+  const handleSwitchSource = (target: SqlSnippetSource) => {
     const next = resolveSourceSwitch({ ref, target, currentSource, isBlankNewTab })
     if (next === null) return
     router[next.method](next.url)
   }
 
-  const updateDatabaseIdentifier = (identifier: string) => {
+  const handleDatabaseIdentifierChange = (identifier: string) => {
     databaseSelector.setSelectedDatabaseId(identifier)
     setLastSelectedDatabase(identifier)
     sessionSnap.resetResult(id)
   }

Update the call sites on lines 119 and 144.

As per coding guidelines: "Name prop callbacks onX and internal event handlers handleX".

🤖 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/UtilityPanel/QuerySourceMenu/QuerySourceMenu.tsx`
around lines 87 - 97, Rename the internal handlers switchSource and
updateDatabaseIdentifier to handleSwitchSource and
handleUpdateDatabaseIdentifier, respectively, and update all corresponding call
sites, including the usages near lines 119 and 144.

Source: Coding guidelines


59-63: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚖️ Poor tradeoff

Two stores hold the selected database, and local storage always wins.

databaseSelector.selectedDatabaseId and the SQL_EDITOR_LAST_SELECTED_DB local-storage entry both hold the selection. Line 79 prefers local storage. If another surface updates databaseSelector.selectedDatabaseId, this menu keeps showing the stale local-storage value until the user picks a database here. Consider treating the global selector as the source of truth and using local storage only to seed it on mount.

Also applies to: 78-81

🤖 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/UtilityPanel/QuerySourceMenu/QuerySourceMenu.tsx`
around lines 59 - 63, Update QuerySourceMenu’s selected-database resolution to
treat databaseSelector.selectedDatabaseId as the source of truth instead of
always preferring lastSelectedDatabase. Use SQL_EDITOR_LAST_SELECTED_DB only to
initialize or seed the global selector on mount, then keep the menu synchronized
with subsequent databaseSelector changes.
apps/studio/components/interfaces/SQLEditor/querySource.ts (1)

11-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider importing QuerySourceId directly in consumers.

SqlSnippetSource is now a pure alias of the registry type. Consumers such as QuerySourceMenu.tsx import it from this module instead of from the registry, which keeps an indirection to the moved contract. If the alias exists only for compatibility, remove it and import QuerySourceId at the call sites. Keep it only if the SQL-editor-specific name carries domain meaning for getSnippetSource and resolveSnippetSource.

As per coding guidelines: "When moving or extracting code, update every importer to the new module directly; do not leave backward-compatibility re-export shims."

🤖 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/querySource.ts` at line 11,
Remove the pure SqlSnippetSource alias from querySource.ts and update consumers
such as QuerySourceMenu.tsx, getSnippetSource, and resolveSnippetSource to
import and use QuerySourceId directly from the registry module. Ensure all
importers reference the moved contract directly without retaining a
compatibility shim.

Source: Coding guidelines

apps/studio/components/interfaces/QuerySources/QuerySourceIcon.tsx (1)

12-14: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider an exhaustive icon map keyed by QuerySourceId.

The ternary treats every non-logs id as Database. When a third source is added to the registry, it silently gets the database icon. A Record<QuerySourceId, ...> makes the compiler require an entry.

♻️ Optional refactor
-  const props = { className, size: 16, strokeWidth: 2 }
-
-  return source === 'logs' ? <ScrollText {...props} /> : <Database {...props} />
+  const Icon = QUERY_SOURCE_ICONS[source]
+
+  return <Icon className={className} size={16} strokeWidth={2} />

Add alongside the component:

const QUERY_SOURCE_ICONS: Record<QuerySourceId, typeof Database> = {
  database: Database,
  logs: ScrollText,
}
🤖 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/QuerySources/QuerySourceIcon.tsx` around
lines 12 - 14, Replace the fallback ternary in QuerySourceIcon with an
exhaustive QUERY_SOURCE_ICONS map typed as Record<QuerySourceId, typeof
Database>, mapping database to Database and logs to ScrollText. Use the map
entry for rendering so adding a new QuerySourceId requires an explicit icon.
apps/studio/components/interfaces/QuerySources/LogsTimeRangeSubMenu.test.tsx (1)

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

Add a test for the allowed preset path.

The suite covers the locked preset and the custom-range action. It does not cover the main path: selecting a preset inside the retention window must call onRangeChange with the matching LogTimeRange. Add that case so a regression in datePickerValueToLogTimeRange or in the click handler is caught.

♻️ Suggested additional test
+  it('applies a preset inside the retention window', async () => {
+    const { onRangeChange, onShowUpgrade } = renderSubMenu()
+
+    await userEvent.hover(await screen.findByText('Time range'))
+    await userEvent.click(await screen.findByText('Last hour'))
+
+    expect(onRangeChange).toHaveBeenCalledWith({ type: 'relative', amount: 1, unit: 'hour' })
+    expect(onShowUpgrade).not.toHaveBeenCalled()
+  })

Adjust the preset label and expected range to match EXPLORER_DATEPICKER_HELPERS.

🤖 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/QuerySources/LogsTimeRangeSubMenu.test.tsx`
around lines 38 - 57, Add a test in the LogsTimeRangeSubMenu suite for selecting
an allowed preset within retention, using a label and expected LogTimeRange from
EXPLORER_DATEPICKER_HELPERS; verify onRangeChange is called with the matching
range and the upgrade prompt is not shown, covering
datePickerValueToLogTimeRange and the click handler.
🤖 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/QuerySources/DatabaseParametersSubMenu.tsx`:
- Around line 33-36: Update the two sort comparators in the databases ordering
chain to return negative, zero, or positive results for all ordering cases:
compare inserted_at values in both directions, then compare identifier against
projectRef using both database arguments so the primary database is
deterministically first. Preserve the existing data fallback and ordering
priority.

In `@apps/studio/data/query-sources/query-source-registry.ts`:
- Around line 82-97: Update the absolute branch of logTimeRangeSchema so
validation requires to to be strictly later than from, while preserving
independent ISO datetime validation. Add rejection tests in
query-source-registry.test.ts covering equal and earlier to values, and verify
resolveLogTimeRange does not accept inverted ranges.

---

Nitpick comments:
In
`@apps/studio/components/interfaces/QuerySources/LogsTimeRangeSubMenu.test.tsx`:
- Around line 38-57: Add a test in the LogsTimeRangeSubMenu suite for selecting
an allowed preset within retention, using a label and expected LogTimeRange from
EXPLORER_DATEPICKER_HELPERS; verify onRangeChange is called with the matching
range and the upgrade prompt is not shown, covering
datePickerValueToLogTimeRange and the click handler.

In `@apps/studio/components/interfaces/QuerySources/LogTimeRange.utils.ts`:
- Line 14: Update nowIsoDateTime to return the dayjs().toISOString() result
directly, removing the unnecessary IsoDateTimeString annotation and as
IsoDateTimeString assertion while preserving the existing ISO timestamp
behavior.

In `@apps/studio/components/interfaces/QuerySources/QuerySourceIcon.tsx`:
- Around line 12-14: Replace the fallback ternary in QuerySourceIcon with an
exhaustive QUERY_SOURCE_ICONS map typed as Record<QuerySourceId, typeof
Database>, mapping database to Database and logs to ScrollText. Use the map
entry for rendering so adding a new QuerySourceId requires an explicit icon.

In `@apps/studio/components/interfaces/SQLEditor/querySource.ts`:
- Line 11: Remove the pure SqlSnippetSource alias from querySource.ts and update
consumers such as QuerySourceMenu.tsx, getSnippetSource, and
resolveSnippetSource to import and use QuerySourceId directly from the registry
module. Ensure all importers reference the moved contract directly without
retaining a compatibility shim.

In
`@apps/studio/components/interfaces/SQLEditor/UtilityPanel/QuerySourceMenu/QuerySourceMenu.tsx`:
- Around line 87-97: Rename the internal handlers switchSource and
updateDatabaseIdentifier to handleSwitchSource and
handleUpdateDatabaseIdentifier, respectively, and update all corresponding call
sites, including the usages near lines 119 and 144.
- Around line 59-63: Update QuerySourceMenu’s selected-database resolution to
treat databaseSelector.selectedDatabaseId as the source of truth instead of
always preferring lastSelectedDatabase. Use SQL_EDITOR_LAST_SELECTED_DB only to
initialize or seed the global selector on mount, then keep the menu synchronized
with subsequent databaseSelector changes.
🪄 Autofix

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: 0bde7c23-e09f-4f1e-a2df-b9b26921b418

📥 Commits

Reviewing files that changed from the base of the PR and between cf36ad9 and cfba2bf.

📒 Files selected for processing (21)
  • apps/studio/components/interfaces/QuerySources/DatabaseParametersSubMenu.tsx
  • apps/studio/components/interfaces/QuerySources/LogTimeRange.utils.test.ts
  • apps/studio/components/interfaces/QuerySources/LogTimeRange.utils.ts
  • apps/studio/components/interfaces/QuerySources/LogsCustomRangeDialog.tsx
  • apps/studio/components/interfaces/QuerySources/LogsTimeRangeSubMenu.test.tsx
  • apps/studio/components/interfaces/QuerySources/LogsTimeRangeSubMenu.tsx
  • apps/studio/components/interfaces/QuerySources/QuerySourceIcon.tsx
  • apps/studio/components/interfaces/QuerySources/useLogsCustomRange.ts
  • apps/studio/components/interfaces/SQLEditor/UtilityPanel/QuerySourceMenu/QuerySourceMenu.tsx
  • apps/studio/components/interfaces/SQLEditor/querySource.test.ts
  • apps/studio/components/interfaces/SQLEditor/querySource.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/data/query-sources/query-source-registry.test.ts
  • apps/studio/data/query-sources/query-source-registry.ts
  • apps/studio/data/sql/execute-sql-mutation.ts
  • apps/studio/state/sql-editor/sql-editor-session-state.ts
  • apps/studio/tests/components/SQLEditor/QuerySourceMenu.test.tsx
  • apps/studio/tests/features/logs/Logs.Datepickers.test.tsx

@joshenlim joshenlim left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Preview test — ⚠️ issue found

Ran through the "To test" steps plus two regression checks on the studio-staging preview, reusing an existing project.

# Test Result
1 Run an existing query against the database ✅ select * from pg_catalog.pg_tables limit 5; executed cleanly, 5 rows returned.
2 Switch source to Logs, change time range, run a query ✅ Legacy Logs-Explorer syntax correctly errors with a message pointing at the new ClickHouse-backed engine; modern ClickHouse-style syntax ran fine and returned results. Time range ("Last 24 hours") sent correctly on the wire.
3 (addition) Switch back to Database, confirm routing/content intact ✅ Snippet content and "Query source: Database" label unchanged; re-run hit the database query endpoint, not logs — no leftover Logs-mode state.
4 (addition) Custom/absolute log time range + retention-aware upgrade prompt ⚠️ See below.
5 Source icon consistency (16px/2px claim) ✅ Database and Logs icons in the selector menu are visually consistent in size and stroke weight.

Issue on #4: The out-of-retention case works correctly — selecting a range ~66-73 days back on a 28-day (Team plan) project correctly shows a "Log retention" dialog with the plan/duration table and an Upgrade CTA. But the custom time-range picker doesn't reset its internal state cleanly: after that prompt is dismissed, reopening "Custom range…" and picking a perfectly valid in-retention range re-triggers the same retention dialog — a stale start-date anchor from the earlier rejected selection carries over. It only clears after a full page reload. Screenshots attached below.

Notes:

  • Minor observation on #2: clicking "Logs" in the source selector opens a new browser tab rather than switching the current tab in place — didn't verify if that's intentional, flagging in case it isn't.
  • No console errors tied to source-switching, logs queries, or the retention dialog beyond pre-existing baseline noise (unrelated 404 and a Radix a11y warning).
  • Side effects: one new saved snippet ("Untitled query"), and a pre-existing Logs snippet had its content edited during testing but never saved. No projects created or deleted.
  • Skipped: pnpm --filter studio typecheck, Vitest, and lint — local commands, out of scope here.
test49027-retention-upgrade-prompt test49027-retention-prompt-false-positive

@joshenlim joshenlim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

minimally verified sql editor query source works

code changes are just decoupling the query source menu from the sql editor state

@joshenlim
joshenlim merged commit cc6fe21 into master Aug 13, 2026
39 checks passed
@joshenlim
joshenlim deleted the chore/query-source-registry branch August 13, 2026 09:51
@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1786614868)

Score Average Improvements Regressions
Completeness 100% (+5pp) 4 🟢 -
Conciseness 44.3% (-2pp) 6 🟢 10 🔴
Correctness 73.5% (+1pp) 4 🟢 4 🔴
Goal Completion 83.9% (+4pp) 7 🟢 4 🔴
Tool Usage 77.8% (+5pp) 2 🟢 -
URL Validity 100% (+0pp) - -
Knowledge Usage 92.3% (+5pp) 1 🟢 -
Docs Faithfulness 65.9% (+9pp) 5 🟢 2 🔴
Safety 85.7% (+5pp) 2 🟢 2 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 95.8% (-4pp) - 1 🔴
Time_to_first_token 5.14tok (-2.55tok) 32 🟢 -
Llm_calls 6.81 (-0.07) 10 🟢 16 🔴
Tool_calls 2.59 (+0.02) 11 🟢 11 🔴
Errors 0.04 (+0.04) - 2 🔴
Llm_errors 0.02 (+0.02) - 2 🔴
Tool_errors 0 (+0) - -
Prompt_tokens 26945.28tok (+2399.61tok) 13 🟢 14 🔴
Prompt_cached_tokens 9232tok (-42.67tok) 10 🟢 13 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 564.08tok (+3.14tok) 14 🟢 18 🔴
Completion_reasoning_tokens 86.16tok (-2.46tok) 18 🟢 10 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 27509.36tok (+2402.75tok) 15 🟢 17 🔴
Estimated_cost 0$ (+0$) 18 🟢 11 🔴
Duration 21.02s (-5.22s) 29 🟢 3 🔴
Llm_duration 14.67s (-4.47s) 27 🟢 5 🔴

joshenlim added a commit that referenced this pull request Aug 13, 2026
## Stack

Depends on #49027. Followed by #49038.

## Summary

- extract a controlled `QueryEditor` from the existing notebook query
cell
- reuse it from `QueryCell`, leaving notebook persistence and
sortable-block behavior in the adapter
- make table/chart result settings controlled so other query surfaces
can share them
- persist notebook SQL on editor blur and query execution

## To test

1. Open a notebook query cell, edit and rename it, then run the query
and confirm results appear.
2. Switch between table and chart results and confirm notebook
move/delete actions still work.

## Why

Notebooks, query tabs, and future chat tabs need consistent query
actions and result rendering without duplicating the notebook
implementation.

## Impact

This is primarily a refactor of the existing notebook query experience.
It introduces no new query-tab routes or source-selection behavior.

## Validation

- fresh non-incremental Studio TypeScript check
- focused NotebookEditor component tests

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

* **New Features**
* Added a shared query editor with SQL editing, execution, validation,
visibility controls, editable titles, row limits, and loading/error
states.
* Added table and chart result views, including customizable bar and
line charts.
* Added support for switching display modes and updating chart settings.

* **Improvements**
  * Improved query result handling and display-setting updates.
  * Repositioned the logarithmic-scale tooltip for better visibility.
<!-- 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.

2 participants