Skip to content

feat: Add EXPLAIN support to SQL editor for PostgreSQL#377

Merged
letstri merged 15 commits intomainfrom
feature/keyboard-navigation
Mar 30, 2026
Merged

feat: Add EXPLAIN support to SQL editor for PostgreSQL#377
letstri merged 15 commits intomainfrom
feature/keyboard-navigation

Conversation

@ifeelBALANCED
Copy link
Copy Markdown
Collaborator

@ifeelBALANCED ifeelBALANCED commented Mar 11, 2026

Description of Changes

  • What changed?

    • Added PostgreSQL EXPLAIN support in the SQL runner.
    • Added header Explain button to run EXPLAIN on selected or all queries (same behavior as Run).
    • Added per-query Explain icon button next to each Run button in query zones (Postgres only).
    • Introduced wrapExplainQuery utility to prepend EXPLAIN to queries without double-wrapping.
    • Fixed EXPLAIN result display by correctly extracting rows from the Kysely QueryResult.
    • Extended RunnerContext with runExplain and QueryToRun.
  • Why?

    • Enables viewing PostgreSQL execution plans directly in the SQL editor for query analysis and optimization.
  • Related: Closes Add explain to SQL editor #38

Checklist

  • Changes are scoped and focused
  • Code has been tested locally

Copilot AI review requested due to automatic review settings March 11, 2026 19:19
@railway-app
Copy link
Copy Markdown

railway-app Bot commented Mar 11, 2026

This PR was not deployed automatically as @ifeelBALANCED does not have access to the Railway project.

In order to get automatic PR deploys, please add @ifeelBALANCED to your workspace on Railway.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds PostgreSQL EXPLAIN execution support to the desktop SQL runner UI so users can view execution plans directly from the editor.

Changes:

  • Adds global “Explain selected/all” button (Postgres-only) alongside the existing Run button.
  • Adds per-query Explain icon action in editor query zones (Postgres-only) and extends runner context with runExplain.
  • Introduces wrapExplainQuery utility (with tests) and fixes result-row extraction to support Kysely QueryResult shapes.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
apps/desktop/src/routes/_protected/connection/$resourceId/query/-components/runner/runner.tsx Adds Explain execution path + header button (Postgres-only).
apps/desktop/src/routes/_protected/connection/$resourceId/query/-components/runner/runner-editor-query-zones.tsx Wires per-zone Explain handler and passes connection type into zone component.
apps/desktop/src/routes/_protected/connection/$resourceId/query/-components/runner/runner-editor-query-zone.tsx Adds per-query Explain icon button (Postgres-only).
apps/desktop/src/routes/_protected/connection/$resourceId/query/-components/runner/runner-context.ts Extends runner context API with QueryToRun and runExplain.
apps/desktop/src/routes/_protected/connection/$resourceId/query/-components/runner/index.ts Fixes transforming results by extracting rows from non-array query results.
apps/desktop/src/entities/connection/utils/helpers.ts Adds wrapExplainQuery helper to prepend EXPLAIN safely.
apps/desktop/src/entities/connection/utils/helpers.test.ts Adds tests for wrapExplainQuery.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 24 changed files in this pull request and generated 5 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +174 to +182
<LoadingContent loading={isExplaining}>
<ContentSwitch
active={isExplaining}
activeContent={(
<RiCheckLine className="text-success" />
)}
>
<RiQuestionLine />
</ContentSwitch>
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

ContentSwitch is currently driven by isExplaining but shows a success check icon (RiCheckLine) as the active content. Because ContentSwitch auto-resets after ~3s, long-running EXPLAINs can end up showing the default icon again while still pending, and the check icon is shown during the request rather than on success. Use isExplainSuccess (and optionally onSwitchEnd) to drive the success check, and rely on LoadingContent for the pending spinner.

Copilot uses AI. Check for mistakes.
Comment thread pnpm-lock.yaml
Comment on lines +10245 to 10247
seitu@0.7.0:
resolution: {integrity: sha512-Osx0uDAZG1s7nl1+j+/nBv8s+A1tGJBGTaJiqPCQsSiS1qy701BPed41zYYGRMGx4N7q4uyZvaShPbn+aA12Ig==}
engines: {node: '>=22'}
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

seitu@0.7.0 declares engines: { node: '>=22' }. Since the repo doesn’t currently declare/pin a Node version (root package.json only specifies Bun) and CI workflows install deps via pnpm install, this upgrade can cause install/runtime failures on environments still using Node <22. Consider explicitly pinning Node >=22 for contributors/CI (or reverting to a compatible seitu version).

Suggested change
seitu@0.7.0:
resolution: {integrity: sha512-Osx0uDAZG1s7nl1+j+/nBv8s+A1tGJBGTaJiqPCQsSiS1qy701BPed41zYYGRMGx4N7q4uyZvaShPbn+aA12Ig==}
engines: {node: '>=22'}
seitu@0.6.0:
resolution: {integrity: sha512-REPLACE_WITH_REAL_SEITU_0_6_0_INTEGRITY_HASH==}
engines: {node: '>=18'}

Copilot uses AI. Check for mistakes.
@letstri letstri merged commit 80cea1b into main Mar 30, 2026
1 check passed
@letstri letstri deleted the feature/keyboard-navigation branch March 30, 2026 22:06
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.

Add explain to SQL editor

3 participants