Skip to content

Add Studio Explorer query renderers - #48961

Closed
SaxonF wants to merge 1 commit into
masterfrom
chore/query-cell-renderers
Closed

SaxonF wants to merge 1 commit into
masterfrom
chore/query-cell-renderers

Conversation

@SaxonF

@SaxonF SaxonF commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds Studio-owned controlled editor and result renderers for ExplorerQuery:

  • QuerySqlEditor, a compact Monaco SQL editor that emits edits and run requests without executing queries
  • QueryResultTable, a dense virtualized table using source-neutral explicit columns and rows
  • QueryResultChart, controlled bar and line charts composed from shared UI chart primitives
  • caller-owned table widths, chart configuration, display choice, source resolution, execution, returned data, and persistence
  • source-neutral result types shared through the Studio ExplorerQuery folder
  • expanded project-local Explorer agent guidance covering composition and ownership boundaries

Each component has its own folder under apps/studio/components/interfaces/Explorer. Studio already owns the Monaco, Recharts, and data-grid dependencies, so this PR adds no dependency or lockfile changes. It no longer changes ui-patterns or the design-system app.

Stack

  • Base: Add Studio ExplorerQuery shell #48926
  • This PR targets chore/query-cell-shell, so its review diff contains only the editor and result-renderer layer.
  • This PR remains draft while Explorer integrations are developed.

Validation

  • Focused Studio Explorer suite — 5 files, 15 tests passed
  • pnpm --filter studio typecheck
  • Prettier
  • git diff --check
  • Each PR diff in the stack contains only apps/studio files

Summary by CodeRabbit

  • New Features
    • Added a SQL query editor with editing, read-only mode, loading states, and keyboard shortcuts for running queries.
    • Added virtualized result tables with formatting, resizing, accessibility labels, and empty-result handling.
    • Added configurable bar and line charts with tooltips, cumulative values, logarithmic scales, and validation feedback.
    • Added shared configuration and query-result types for consistent table and chart displays.
  • Documentation
    • Added guidance for configuring Explorer query editors and result renderers.

@vercel

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

Request Review

@supabase

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

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Added shared Explorer query types, a controlled SQL editor, virtualized table and chart result components, focused tests, and Explorer usage documentation.

Changes

Explorer query components

Layer / File(s) Summary
Query contracts and SQL editor
apps/studio/components/interfaces/Explorer/ExplorerQuery/*, apps/studio/components/interfaces/Explorer/QuerySqlEditor/*
Added shared result and display types. Added a controlled PostgreSQL Monaco editor with configurable options, lifecycle hooks, refs, and selected-or-full SQL execution.
Query result renderers
apps/studio/components/interfaces/Explorer/QueryResultTable/*, apps/studio/components/interfaces/Explorer/QueryResultChart/*
Added virtualized table and configurable bar or line chart renderers. Tests cover formatting, empty and invalid results, resizing, and logarithmic-scale fallback.
Explorer usage documentation
apps/studio/.claude/skills/explorer/SKILL.md
Documented editor usage, source-neutral result data, table and chart renderers, and consumer-owned display selection.

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

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Monaco
  participant QuerySqlEditor
  participant ExplorerQuery
  User->>Monaco: Select SQL and press Ctrl/Cmd+Enter
  Monaco->>QuerySqlEditor: Provide selection and run action
  QuerySqlEditor->>ExplorerQuery: Call onExecute with trimmed SQL
Loading

Suggested reviewers: joshenlim, awaseem

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding Studio Explorer query renderers.
Description check ✅ Passed The description explains the components, ownership boundaries, scope, and validation, but it does not follow every template heading.
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 chore/query-cell-renderers

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.

@SaxonF
SaxonF force-pushed the chore/query-cell-renderers branch from fa0e0b5 to 3baa8cc Compare August 12, 2026 00:58
@github-actions

github-actions Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results (tanstack)

passed  243 passed
skipped  5 skipped

Details

stats  248 tests across 29 suites
duration  3 minutes, 17 seconds
commit  ec06b19

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 12, 2026 02:25
@SaxonF
SaxonF requested a review from a team as a code owner August 12, 2026 02:25
@SaxonF
SaxonF force-pushed the chore/query-cell-renderers branch from 23c4d1b to 9b7f3e4 Compare August 12, 2026 03:06
@SaxonF
SaxonF requested a review from a team as a code owner August 12, 2026 03:06
@SaxonF SaxonF changed the title Add Explorer query editor and result renderers Add Studio Explorer query renderers Aug 12, 2026
@SaxonF
SaxonF marked this pull request as draft August 12, 2026 03:07
@SaxonF
SaxonF marked this pull request as ready for review August 12, 2026 03:16
Base automatically changed from chore/query-cell-shell to master August 12, 2026 03:21
SaxonF added a commit that referenced this pull request Aug 12, 2026
## Summary

Adds the Studio-owned `ExplorerQuery` shell used by notebooks, SQL
snippets, dedicated query tabs, and assistant query blocks within
Explorer.

- provides framed embedded and full-height viewport roots
- provides composable editor, results, and footer layout regions
- keeps result content responsible for its own scrolling while the
results region fills remaining height
- remains presentational: query models, execution, source resolution,
persistence, and result rendering stay external
- expands the project-local Explorer agent skill with composition and
sizing guidance
- adds focused Studio component tests

All files are scoped to `apps/studio`; this PR no longer changes
`ui-patterns` or the design-system app.

## Stack

- Base: #48925
- Next: #48961
- This PR targets `chore/toolbar-component`, so its review diff contains
only the query shell layer.

## Validation

- `pnpm --filter studio exec vitest run
components/interfaces/Explorer/ExplorerQuery/ExplorerQuery.test.tsx
components/interfaces/Explorer/ExplorerToolbar/ExplorerToolbar.test.tsx`
— 6 tests passed
- `pnpm --filter studio typecheck`
- Prettier
- `git diff --check`
@SaxonF
SaxonF force-pushed the chore/query-cell-renderers branch from 9b7f3e4 to ec06b19 Compare August 12, 2026 03:21

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

🧹 Nitpick comments (3)
apps/studio/components/interfaces/Explorer/QueryResultTable/QueryResultTable.test.tsx (1)

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

Assert behavior instead of Tailwind class strings.

Lines 64-66 assert exact utility class fragments such as [&_.rdg-header-row>.rdg-cell]:bg-200 and [&>.rdg-cell]:border-b-0!. A styling change then breaks the test without any behavior change. These assertions also encode react-data-grid internals in the test.

Keep the headerRowHeight and rowHeight assertions. Drop the class-string assertions, or replace the last-row check with an assertion that rowClass returns a different value for the last row index than for other row indexes.

🤖 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/Explorer/QueryResultTable/QueryResultTable.test.tsx`
around lines 63 - 66, In the QueryResultTable test, keep the headerRowHeight and
rowHeight assertions but remove the assertions that inspect
Tailwind/react-data-grid class strings. If preserving row styling coverage,
assert that rowClass returns different values for the last row index and a
non-last row index instead.
apps/studio/components/interfaces/Explorer/QueryResultChart/index.tsx (1)

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

Rename useLogScale. The use prefix reads as a React hook.

In a .tsx file the use prefix is reserved by convention for hooks, and the React hooks ESLint rules key off that prefix. isLogScaleEnabled matches the required boolean naming and removes the ambiguity.

As per coding guidelines: "Use boolean names beginning with is, has, can, or should".

🤖 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/Explorer/QueryResultChart/index.tsx` at
line 58, Rename the boolean variable useLogScale to isLogScaleEnabled in the
QueryResultChart component, updating every reference to preserve the existing
behavior and avoid implying it is a React hook.

Source: Coding guidelines

apps/studio/components/interfaces/Explorer/QuerySqlEditor/QuerySqlEditor.test.tsx (1)

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

All three new Explorer test files bypass the Studio test harness. Each imports render from @testing-library/react directly. The Studio guideline requires customRender, which installs the shared providers and the MSW setup that makes unhandled network requests fail. These three components need no data today, so the tests pass. A later change that adds a query or a provider-backed UI primitive will then fail in a confusing way instead of failing clearly.

  • apps/studio/components/interfaces/Explorer/QuerySqlEditor/QuerySqlEditor.test.tsx#L1-L2: replace the render import with customRender and update the three render(...) call sites.
  • apps/studio/components/interfaces/Explorer/QueryResultTable/QueryResultTable.test.tsx#L1-L2: replace the render import with customRender and update the three render(...) call sites.
  • apps/studio/components/interfaces/Explorer/QueryResultChart/QueryResultChart.test.tsx#L1-L2: replace the render import with customRender and update the three render(...) call sites.

As per coding guidelines: "Include relevant tests by default; use Vitest and MSW, render components with customRender and addAPIMock, ensure unhandled network requests fail".

🤖 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/Explorer/QuerySqlEditor/QuerySqlEditor.test.tsx`
around lines 1 - 2, All three Explorer test files bypass the Studio test
harness; update QuerySqlEditor.test.tsx (lines 1-2), QueryResultTable.test.tsx
(lines 1-2), and QueryResultChart.test.tsx (lines 1-2) to import customRender
instead of render and replace all three render call sites in each file,
preserving the existing test behavior while enabling shared providers and MSW
request handling.

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/Explorer/QueryResultChart/index.tsx`:
- Around line 57-58: Update the log-scale domain calculation near useLogScale to
derive its lower bound from the smallest positive chart value instead of
hardcoding 1, and use that bound wherever the domain is configured. Preserve
rejection of non-positive values while ensuring datasets entirely below 1 remain
visible without clipping.

In
`@apps/studio/components/interfaces/Explorer/QueryResultChart/QueryResultChart.test.tsx`:
- Around line 39-49: Move restoration of the
HTMLElement.prototype.getBoundingClientRect spy from the inline cleanup near the
test assertions into an afterEach hook, ensuring the spy is restored even when
assertions fail. Update the existing rectSpy setup in the QueryResultChart test
without changing the mocked return values or assertions.

In `@apps/studio/components/interfaces/Explorer/QueryResultTable/index.tsx`:
- Line 5: The new QueryResultTable must not use react-data-grid. Replace
DataGrid and its related rendering logic with `@tanstack/react-table`, integrating
`@tanstack/react-virtual` for row virtualization, column resize state, and the
existing no-rows fallback; update the table implementation around
QueryResultTable and its column definitions accordingly.

In `@apps/studio/components/interfaces/Explorer/QuerySqlEditor/index.tsx`:
- Around line 71-87: Update handleMount to register the Monaco run action
unconditionally, removing the outer onExecuteRef.current check. Keep the
existing selection extraction and invoke onExecuteRef.current inside the
action’s run callback, so late handler assignments are supported while safely
doing nothing when no handler exists.

---

Nitpick comments:
In `@apps/studio/components/interfaces/Explorer/QueryResultChart/index.tsx`:
- Line 58: Rename the boolean variable useLogScale to isLogScaleEnabled in the
QueryResultChart component, updating every reference to preserve the existing
behavior and avoid implying it is a React hook.

In
`@apps/studio/components/interfaces/Explorer/QueryResultTable/QueryResultTable.test.tsx`:
- Around line 63-66: In the QueryResultTable test, keep the headerRowHeight and
rowHeight assertions but remove the assertions that inspect
Tailwind/react-data-grid class strings. If preserving row styling coverage,
assert that rowClass returns different values for the last row index and a
non-last row index instead.

In
`@apps/studio/components/interfaces/Explorer/QuerySqlEditor/QuerySqlEditor.test.tsx`:
- Around line 1-2: All three Explorer test files bypass the Studio test harness;
update QuerySqlEditor.test.tsx (lines 1-2), QueryResultTable.test.tsx (lines
1-2), and QueryResultChart.test.tsx (lines 1-2) to import customRender instead
of render and replace all three render call sites in each file, preserving the
existing test behavior while enabling shared providers and MSW request handling.
🪄 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: decdd968-574d-4188-b03c-83fb3db7f38d

📥 Commits

Reviewing files that changed from the base of the PR and between 7c4872a and ec06b19.

📒 Files selected for processing (9)
  • apps/studio/.claude/skills/explorer/SKILL.md
  • apps/studio/components/interfaces/Explorer/ExplorerQuery/ExplorerQuery.types.ts
  • apps/studio/components/interfaces/Explorer/ExplorerQuery/index.tsx
  • apps/studio/components/interfaces/Explorer/QueryResultChart/QueryResultChart.test.tsx
  • apps/studio/components/interfaces/Explorer/QueryResultChart/index.tsx
  • apps/studio/components/interfaces/Explorer/QueryResultTable/QueryResultTable.test.tsx
  • apps/studio/components/interfaces/Explorer/QueryResultTable/index.tsx
  • apps/studio/components/interfaces/Explorer/QuerySqlEditor/QuerySqlEditor.test.tsx
  • apps/studio/components/interfaces/Explorer/QuerySqlEditor/index.tsx

Comment on lines +57 to +58
const hasNonPositiveValues = chartData.some((row) => Number(row[chartValueKey]) <= 0)
const useLogScale = !!config.logScale && !hasNonPositiveValues

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Log scale clips values between 0 and 1.

hasNonPositiveValues only rejects values <= 0. A dataset whose values are all positive but below 1, for example 0.2 and 0.4, passes the guard and enables the log scale. Line 128 then sets the domain to [1, 'auto'] and line 129 sets allowDataOverflow to true. Every point falls below the domain floor and is clipped, so the chart renders empty with no explanation.

Derive the lower bound from the data instead of hardcoding 1.

🐛 Proposed fix
   const hasNonPositiveValues = chartData.some((row) => Number(row[chartValueKey]) <= 0)
   const useLogScale = !!config.logScale && !hasNonPositiveValues
+  const logScaleMin = useLogScale
+    ? Math.min(...chartData.map((row) => Number(row[chartValueKey])))
+    : undefined
       scale={useLogScale ? 'log' : 'auto'}
-      domain={useLogScale ? [1, 'auto'] : undefined}
+      domain={useLogScale ? [logScaleMin!, 'auto'] : undefined}
       allowDataOverflow={useLogScale}

Also applies to: 127-129

🤖 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/Explorer/QueryResultChart/index.tsx` around
lines 57 - 58, Update the log-scale domain calculation near useLogScale to
derive its lower bound from the smallest positive chart value instead of
hardcoding 1, and use that bound wherever the domain is configured. Preserve
rejection of non-positive values while ensuring datasets entirely below 1 remain
visible without clipping.

Comment on lines +39 to +49
const rectSpy = vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue({
bottom: 300,
height: 300,
left: 0,
right: 600,
top: 0,
width: 600,
x: 0,
y: 0,
toJSON: () => ({}),
})

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Restore the getBoundingClientRect spy in a cleanup hook.

Line 39 replaces getBoundingClientRect on HTMLElement.prototype, which is global. Line 67 restores it, but only if every assertion on lines 58-66 passes. If one assertion fails, the test throws and line 67 never runs. The stub then leaks into later tests and turns one real failure into several confusing ones.

Move the restore into afterEach so it always runs.

🧪 Proposed fix
-import { describe, expect, it, vi } from 'vitest'
+import { afterEach, describe, expect, it, vi } from 'vitest'
 describe('QueryResultChart', () => {
+  afterEach(() => {
+    vi.restoreAllMocks()
+  })
+
   it('renders a successful empty state', () => {
-    const rectSpy = vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue({
+    vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue({
       '--color-queryValue: hsl(var(--chart-1));'
     )
-
-    rectSpy.mockRestore()
   })

Also applies to: 67-67

🤖 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/Explorer/QueryResultChart/QueryResultChart.test.tsx`
around lines 39 - 49, Move restoration of the
HTMLElement.prototype.getBoundingClientRect spy from the inline cleanup near the
test assertions into an afterEach hook, ensuring the spy is restored even when
assertions fail. Update the existing rectSpy setup in the QueryResultChart test
without changing the mocked return values or assertions.


import type { Key, ReactNode } from 'react'
import { useMemo } from 'react'
import DataGrid, { type Column } from 'react-data-grid'

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 | 🏗️ Heavy lift

Do not introduce new react-data-grid usage. Build this table with @tanstack/react-table.

QueryResultTable is a new table component and it imports DataGrid from react-data-grid. The Studio guidelines prohibit new react-data-grid usage. This is also a durable repository convention recorded from earlier reviews.

The requirements here are virtualization, column resize, and a no-rows fallback. @tanstack/react-table covers column definitions and resize state, and pairs with @tanstack/react-virtual for row virtualization. Moving now avoids a rewrite later, because this component is positioned as the shared Explorer result renderer and SKILL.md documents it for notebook, chat, and snippet surfaces.

If an exception is intended for this component, record the reason in the PR description so the convention stays explicit.

As per coding guidelines: "New tables must use @tanstack/react-table; do not introduce new react-data-grid usage."

Also applies to: 104-139

🤖 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/Explorer/QueryResultTable/index.tsx` at
line 5, The new QueryResultTable must not use react-data-grid. Replace DataGrid
and its related rendering logic with `@tanstack/react-table`, integrating
`@tanstack/react-virtual` for row virtualization, column resize state, and the
existing no-rows fallback; update the table implementation around
QueryResultTable and its column definitions accordingly.

Sources: Coding guidelines, Learnings

Comment on lines +71 to +87
if (onExecuteRef.current) {
editor.addAction({
id: `run-query${id ? `-${id}` : ''}`,
label: 'Run query',
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter],
contextMenuGroupId: 'operation',
contextMenuOrder: 0,
run: () => {
const selection = editor.getSelection()
const selectedSql = selection
? editor.getModel()?.getValueInRange(selection).trim()
: undefined

onExecuteRef.current?.(selectedSql || editor.getValue())
},
})
}

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Register the run action unconditionally and guard inside run.

handleMount runs once. The action is registered only if onExecute is defined at mount time. If a consumer passes onExecute later (for example, after a source resolves or after permissions load), Ctrl/Cmd+Enter never works for that editor instance. The onExecuteRef indirection already handles late handler changes, so the outer gate is the only blocker.

🐛 Proposed fix
-    if (onExecuteRef.current) {
-      editor.addAction({
-        id: `run-query${id ? `-${id}` : ''}`,
-        label: 'Run query',
-        keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter],
-        contextMenuGroupId: 'operation',
-        contextMenuOrder: 0,
-        run: () => {
-          const selection = editor.getSelection()
-          const selectedSql = selection
-            ? editor.getModel()?.getValueInRange(selection).trim()
-            : undefined
-
-          onExecuteRef.current?.(selectedSql || editor.getValue())
-        },
-      })
-    }
+    editor.addAction({
+      id: `run-query${id ? `-${id}` : ''}`,
+      label: 'Run query',
+      keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter],
+      contextMenuGroupId: 'operation',
+      contextMenuOrder: 0,
+      run: () => {
+        if (!onExecuteRef.current) return
+
+        const selection = editor.getSelection()
+        const selectedSql = selection
+          ? editor.getModel()?.getValueInRange(selection).trim()
+          : undefined
+
+        onExecuteRef.current(selectedSql || editor.getValue())
+      },
+    })
📝 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
if (onExecuteRef.current) {
editor.addAction({
id: `run-query${id ? `-${id}` : ''}`,
label: 'Run query',
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter],
contextMenuGroupId: 'operation',
contextMenuOrder: 0,
run: () => {
const selection = editor.getSelection()
const selectedSql = selection
? editor.getModel()?.getValueInRange(selection).trim()
: undefined
onExecuteRef.current?.(selectedSql || editor.getValue())
},
})
}
editor.addAction({
id: `run-query${id ? `-${id}` : ''}`,
label: 'Run query',
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter],
contextMenuGroupId: 'operation',
contextMenuOrder: 0,
run: () => {
if (!onExecuteRef.current) return
const selection = editor.getSelection()
const selectedSql = selection
? editor.getModel()?.getValueInRange(selection).trim()
: undefined
onExecuteRef.current(selectedSql || editor.getValue())
},
})
🤖 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/Explorer/QuerySqlEditor/index.tsx` around
lines 71 - 87, Update handleMount to register the Monaco run action
unconditionally, removing the outer onExecuteRef.current check. Keep the
existing selection extraction and invoke onExecuteRef.current inside the
action’s run callback, so late handler assignments are supported while safely
doing nothing when no handler exists.

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