diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue index b9da1933b1..5135f2a6bb 100644 --- a/apps/desktop/src/App.vue +++ b/apps/desktop/src/App.vue @@ -943,9 +943,16 @@ function requestActiveEditorExecute(source?: "pointer" | "keyboard", tabId?: str void tryExecute(undefined, targetTabId ? { tabId: targetTabId } : undefined); } -function requestActiveEditorExecuteInNewResultTab() { - if (contentAreaRef.value?.requestQueryEditorExecuteInNewResultTab?.()) return; - void tryExecuteInNewResultTab(); +function requestActiveEditorExecuteInNewResultTab(source?: "pointer" | "keyboard", tabId?: string) { + const snapshot = pendingToolbarExecutionSnapshot.value; + pendingToolbarExecutionSnapshot.value = undefined; + const targetTabId = tabId ?? (source === "pointer" ? snapshot?.tabId : undefined); + if (source === "pointer" && snapshot && snapshot.tabId === targetTabId) { + void tryExecuteInNewResultTab(snapshot, { tabId: targetTabId }); + return; + } + if (contentAreaRef.value?.requestQueryEditorExecuteInNewResultTab?.(targetTabId)) return; + void tryExecuteInNewResultTab(undefined, targetTabId ? { tabId: targetTabId } : undefined); } const toolbarAgentDriverUpdateCount = computed(() => Math.max(agentDriverUpdateCount.value, componentUpdates.driverUpdateCount.value)); @@ -989,6 +996,7 @@ provide(EDITOR_TOOLBAR_ACTIONS, { databaseRequiredSignalFor: (tabId: string) => (databaseRequiredTabId.value === tabId ? databaseRequiredSignal.value : 0), captureExecutionSnapshot: captureActiveEditorExecutionSnapshot, toolbarExecute: requestActiveEditorExecute, + toolbarExecuteInNewResultTab: requestActiveEditorExecuteInNewResultTab, cancelExecution: (tabId: string) => cancelActiveExecution(tabId), explain: (tabId: string) => tryExplain(undefined, { tabId }), formatSql: formatActiveSql, diff --git a/apps/desktop/src/components/layout/EditorGroup.vue b/apps/desktop/src/components/layout/EditorGroup.vue index 1dc9e4f9a4..e2dc0b0f02 100644 --- a/apps/desktop/src/components/layout/EditorGroup.vue +++ b/apps/desktop/src/components/layout/EditorGroup.vue @@ -208,6 +208,7 @@ const groupExecutableSql = computed(() => { @dismiss-auto-commit-session-txn-rolled-back="activeTab && (activeTab.autoCommitSessionTxnRolledBack = false)" @execute-pointer-down="toolbar.captureExecutionSnapshot(activeTab.id)" @toolbar-execute="toolbar.toolbarExecute($event, activeTab.id)" + @toolbar-execute-in-new-result-tab="toolbar.toolbarExecuteInNewResultTab($event, activeTab.id)" @multi-execute="toolbar.multiExecute()" @preview-changes="activeTab && toolbar.previewChanges(activeTab.id)" @cancel="activeTab && toolbar.cancelExecution(activeTab.id)" diff --git a/apps/desktop/src/components/layout/EditorToolbar.vue b/apps/desktop/src/components/layout/EditorToolbar.vue index d6fbaf7928..f2e917e556 100644 --- a/apps/desktop/src/components/layout/EditorToolbar.vue +++ b/apps/desktop/src/components/layout/EditorToolbar.vue @@ -1,7 +1,35 @@