The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: update height for SQL editor when showing pretty explain (#41351)
Ali Waseemf80731024880
diff --git a/apps/studio/components/interfaces/ExplainVisualizer/ExplainVisualizer.tsx b/apps/studio/components/interfaces/ExplainVisualizer/ExplainVisualizer.tsxindex aef5f50ee87..28642532e61 100644--- a/apps/studio/components/interfaces/ExplainVisualizer/ExplainVisualizer.tsx+++ b/apps/studio/components/interfaces/ExplainVisualizer/ExplainVisualizer.tsx@@ -29,7 +29,7 @@ export function ExplainVisualizer({ rows, onShowRaw }: ExplainVisualizerProps) {{onShowRaw && <ExplainHeader mode="visual" onToggleMode={onShowRaw} summary={summary} />}{/* Tree visualization */}- <div className="p-4 mb-10 overflow-auto flex-1">+ <div className="p-4 pb-10 overflow-auto flex-1">{parsedTree.map((node, idx) => (<ExplainNodeRenderer key={idx} node={node} depth={0} maxCost={maxCost} isRoot={true} />))}diff --git a/apps/studio/components/interfaces/ExplainVisualizer/ExplainVisualizer.utils.ts b/apps/studio/components/interfaces/ExplainVisualizer/ExplainVisualizer.utils.tsindex 02421e0d211..f1a731f095c 100644--- a/apps/studio/components/interfaces/ExplainVisualizer/ExplainVisualizer.utils.ts+++ b/apps/studio/components/interfaces/ExplainVisualizer/ExplainVisualizer.utils.ts@@ -9,7 +9,6 @@ import {Layers,type LucideIcon,} from 'lucide-react'-import type { ExplainNode } from './ExplainVisualizer.types'// Get human-readable description for an operationexport function getOperationDescription(operation: string): string {@@ -126,3 +125,9 @@ export function getOperationColor(operation: string): string {if (op.includes('sort') || op.includes('aggregate')) return 'text-foreground-light'return 'text-foreground-light'}++export function isExplainQuery(rows: readonly any[]): boolean {+ return (+ rows.length > 0 && rows[0].hasOwnProperty('QUERY PLAN') && Object.keys(rows[0]).length === 1+ )+}diff --git a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/Results.tsx b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/Results.tsxindex 14a034d51ea..df65ad64d7e 100644--- a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/Results.tsx+++ b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/Results.tsx@@ -15,6 +15,7 @@ import { CellDetailPanel } from './CellDetailPanel'import { ExplainHeader } from 'components/interfaces/ExplainVisualizer/ExplainVisualizer.Header'import { ExplainVisualizer } from 'components/interfaces/ExplainVisualizer/ExplainVisualizer'import { useFeatureFlags, useFlag } from 'common'+import { isExplainQuery } from 'components/interfaces/ExplainVisualizer/ExplainVisualizer.utils'function formatClipboardValue(value: any) {if (value === null) return ''@@ -32,8 +33,7 @@ const Results = ({ rows }: { rows: readonly any[] }) => {const showPrettyExplain = useFlag('ShowPrettyExplain')// Check if this is an EXPLAIN query result- const isExplainQuery =- rows.length > 0 && rows[0].hasOwnProperty('QUERY PLAN') && Object.keys(rows[0]).length === 1+ const isValidExplainQuery = isExplainQuery(rows)const formatter = (column: any, row: any) => {const cellValue = row[column]@@ -117,7 +117,7 @@ const Results = ({ rows }: { rows: readonly any[] }) => {})// Show pretty explain query results as diagram- if (showPrettyExplain && isExplainQuery) {+ if (showPrettyExplain && isValidExplainQuery) {if (showRaw) {return (<div className="bg-studio border-t h-full flex flex-col">diff --git a/apps/studio/components/ui/EditorPanel/EditorPanel.tsx b/apps/studio/components/ui/EditorPanel/EditorPanel.tsxindex 29ae1f57d3b..10e5ffa1a5c 100644--- a/apps/studio/components/ui/EditorPanel/EditorPanel.tsx+++ b/apps/studio/components/ui/EditorPanel/EditorPanel.tsx@@ -43,6 +43,7 @@ import { containsUnknownFunction, isReadOnlySelect } from '../AIAssistantPanel/Aimport AIEditor from '../AIEditor'import { ButtonTooltip } from '../ButtonTooltip'import { SqlWarningAdmonition } from '../SqlWarningAdmonition'+import { isExplainQuery } from 'components/interfaces/ExplainVisualizer/ExplainVisualizer.utils'import { generateSnippetTitle } from 'components/interfaces/SQLEditor/SQLEditor.constants'export const EditorPanel = () => {@@ -130,6 +131,9 @@ export const EditorPanel = () => {})}+ // Check if this is an EXPLAIN query result+ const isValidExplainQuery = isExplainQuery(results ?? [])+const handleChange = (value: string) => {setValue(value)onChange?.(value)@@ -337,9 +341,15 @@ export const EditorPanel = () => {)}{results !== undefined && results.length > 0 && (- <div className={cn(`max-h-72 shrink-0 flex flex-col`, showResults && 'h-full')}>+ <div+ className={cn(+ `shrink-0 flex flex-col`,+ isValidExplainQuery ? 'max-h-[600px]' : 'max-h-72',+ showResults && 'h-full'+ )}+ >{showResults && (- <div className="border-t flex-1 overflow-auto">+ <div className="border-t flex-1 overflow-hidden"><Results rows={results} /></div>)}