From 95a465ad7c1f3ea1a11e223fa1a4172db5070678 Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" <70410625+michael-s-molina@users.noreply.github.com> Date: Mon, 26 Jan 2026 13:18:01 -0300 Subject: [PATCH] feat(sqllab): add getActivePanel API for panel visibility tracking (#37448) --- .../packages/superset-core/src/api/sqlLab.ts | 14 ++++++++++++++ superset-frontend/src/core/sqlLab/index.ts | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/superset-frontend/packages/superset-core/src/api/sqlLab.ts b/superset-frontend/packages/superset-core/src/api/sqlLab.ts index fb4984994dc..e5e501f9f1b 100644 --- a/superset-frontend/packages/superset-core/src/api/sqlLab.ts +++ b/superset-frontend/packages/superset-core/src/api/sqlLab.ts @@ -238,6 +238,20 @@ export interface QueryResult { * access to tab-specific state and events. */ +/** + * Gets the currently active panel in the current tab. + * The active panel defaults to 'Results' when SQL Lab loads. + * + * @returns The current active panel object. + * + * @example + * ```typescript + * const panel = getActivePanel(); + * console.log(`Active panel: ${panel.id}`); + * ``` + */ +export declare const getActivePanel: () => Panel; + /** * Gets the currently active tab in SQL Lab. * diff --git a/superset-frontend/src/core/sqlLab/index.ts b/superset-frontend/src/core/sqlLab/index.ts index c4c7ce92f28..4867f42bcfc 100644 --- a/superset-frontend/src/core/sqlLab/index.ts +++ b/superset-frontend/src/core/sqlLab/index.ts @@ -215,6 +215,11 @@ function createQueryErrorContext( const getCurrentTab: typeof sqlLabApi.getCurrentTab = () => getTab(activeEditorId()); +const getActivePanel: typeof sqlLabApi.getActivePanel = () => { + const { activeSouthPaneTab } = getSqlLabState(); + return new Panel(String(activeSouthPaneTab)); +}; + const getTabs: typeof sqlLabApi.getTabs = () => { const { queryEditors } = getSqlLabState(); return queryEditors @@ -389,6 +394,7 @@ const onDidChangeTabTitle: typeof sqlLabApi.onDidChangeTabTitle = ( export const sqlLab: typeof sqlLabApi = { CTASMethod, + getActivePanel, getCurrentTab, onDidChangeEditorDatabase, onDidChangeEditorSchema,