Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: add feature flag to pretty explain (#47052)

Ali Waseembd537706f922
diff --git a/apps/studio/components/interfaces/SQLEditor/MonacoEditor.tsx b/apps/studio/components/interfaces/SQLEditor/MonacoEditor.tsx
index 2d8df00e0e2..b745fd9d666 100644
--- a/apps/studio/components/interfaces/SQLEditor/MonacoEditor.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/MonacoEditor.tsx
@@ -30,6 +30,7 @@ export type MonacoEditorProps = {
autoFocus?: boolean
executeQuery: () => void
executeExplainQuery: () => void
+ showExplainAction?: boolean
prettifyQuery: () => void
onHasSelection: (value: boolean) => void
onMount?: (editor: IStandaloneCodeEditor) => void
@@ -53,6 +54,7 @@ const MonacoEditor = ({
className,
executeQuery,
executeExplainQuery,
+ showExplainAction = true,
prettifyQuery,
onHasSelection,
onPrompt,
@@ -145,16 +147,18 @@ const MonacoEditor = ({
},
})
- editor.addAction({
- id: 'run-explain-query',
- label: 'Run EXPLAIN ANALYZE',
- keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.Enter],
- contextMenuGroupId: 'operation',
- contextMenuOrder: 1,
- run: () => {
- executeExplainQueryRef.current()
- },
- })
+ if (showExplainAction) {
+ editor.addAction({
+ id: 'run-explain-query',
+ label: 'Run EXPLAIN ANALYZE',
+ keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.Enter],
+ contextMenuGroupId: 'operation',
+ contextMenuOrder: 1,
+ run: () => {
+ executeExplainQueryRef.current()
+ },
+ })
+ }
editor.addAction({
id: 'save-query',
diff --git a/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx b/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
index 5a16a2e14cb..1fb030732f9 100644
--- a/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
@@ -121,6 +121,9 @@ export const SQLEditor = () => {
const { aiOptInLevel } = useOrgAiOptInLevel()
const showPrettyExplain = useFlag('ShowPrettyExplain')
+ // [Ali] Kill switch to hide the SQL Editor Explain tab and its entry points
+ const disablePrettyExplain = useFlag('DisablePrettyExplainOnSqlEditor')
+
const {
sourceSqlDiff,
setSourceSqlDiff,
@@ -223,7 +226,7 @@ export const SQLEditor = () => {
if (id) {
snapV2.addResult(id, data.result, vars.autoLimit)
- if (showPrettyExplain && isExplainQuery(data.result)) {
+ if (!disablePrettyExplain && showPrettyExplain && isExplainQuery(data.result)) {
snapV2.addExplainResult(id, data.result)
setActiveUtilityTab('explain')
} else if (activeUtilityTab === 'explain') {
@@ -535,6 +538,7 @@ export const SQLEditor = () => {
])
useShortcut(SHORTCUT_IDS.SQL_EDITOR_EXPLAIN, executeExplainQuery, {
+ enabled: !disablePrettyExplain,
registerInCommandMenu: true,
})
@@ -958,6 +962,7 @@ export const SQLEditor = () => {
monacoRef={monacoRef}
executeQuery={executeQuery}
executeExplainQuery={executeExplainQuery}
+ showExplainAction={!disablePrettyExplain}
prettifyQuery={prettifyQuery}
onHasSelection={setHasSelection}
onMount={onMount}
@@ -1022,6 +1027,7 @@ export const SQLEditor = () => {
prettifyQuery={prettifyQuery}
executeQuery={executeQueryFromButton}
executeExplainQuery={executeExplainQuery}
+ showExplainTab={!disablePrettyExplain}
onDebug={onDebug}
buildDebugPrompt={buildDebugPrompt}
activeTab={activeUtilityTab}
diff --git a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityPanel.tsx b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityPanel.tsx
index 662dec0fc50..d8ab07d67c4 100644
--- a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityPanel.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityPanel.tsx
@@ -22,6 +22,7 @@ export type UtilityPanelProps = {
prettifyQuery: () => void
executeQuery: () => void
executeExplainQuery: () => void
+ showExplainTab?: boolean
onDebug: () => void
buildDebugPrompt: () => string
activeTab?: string
@@ -47,6 +48,7 @@ export const UtilityPanel = ({
prettifyQuery,
executeQuery,
executeExplainQuery,
+ showExplainTab = true,
onDebug,
buildDebugPrompt,
activeTab = 'results',
@@ -136,9 +138,11 @@ export const UtilityPanel = ({
<TabsTrigger_Shadcn_ className="py-3 text-xs" value="results">
<span className="translate-y-px">Results</span>
</TabsTrigger_Shadcn_>
- <TabsTrigger_Shadcn_ className="py-3 text-xs" value="explain">
- <span className="translate-y-px">Explain</span>
- </TabsTrigger_Shadcn_>
+ {showExplainTab && (
+ <TabsTrigger_Shadcn_ className="py-3 text-xs" value="explain">
+ <span className="translate-y-px">Explain</span>
+ </TabsTrigger_Shadcn_>
+ )}
<TabsTrigger_Shadcn_ className="py-3 text-xs" value="chart">
<span className="translate-y-px">Chart</span>
</TabsTrigger_Shadcn_>
@@ -177,9 +181,11 @@ export const UtilityPanel = ({
/>
</TabsContent_Shadcn_>
- <TabsContent_Shadcn_ asChild value="explain" className="mt-0 grow">
- <UtilityTabExplain id={id} isExecuting={isExplainExecuting} />
- </TabsContent_Shadcn_>
+ {showExplainTab && (
+ <TabsContent_Shadcn_ asChild value="explain" className="mt-0 grow">
+ <UtilityTabExplain id={id} isExecuting={isExplainExecuting} />
+ </TabsContent_Shadcn_>
+ )}
<TabsContent_Shadcn_ asChild value="chart" className="mt-0 grow">
<ChartConfig results={result} config={chartConfig} onConfigChange={onConfigChange} />