25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(query): honor the multi-statement default view
二丫讲梵6189837ac520
diff --git a/apps/desktop/src/components/layout/ContentArea.vue b/apps/desktop/src/components/layout/ContentArea.vueindex 86438a3786..bcd0359c51 100644--- a/apps/desktop/src/components/layout/ContentArea.vue+++ b/apps/desktop/src/components/layout/ContentArea.vue@@ -1207,13 +1207,12 @@ watch(// surface (a background group's editor) must never redirect the global// view when its own tab finishes executing.if (props.editorOnly) return;- // A batch run reports its progress statement by statement, and only the- // summary view shows that, so a run of several statements opens there- // instead of on the first statement's grid. The switch is recorded against- // the run it happened in: a user who picks another view mid-run keeps it,- // and the next run switches again.+ // Show statement-by-statement progress only when summary is the configured+ // default; otherwise this watcher would override the execution entry point's+ // result-grid selection. Record the switch per run so a user's subsequent+ // manual view selection survives progress updates.const batchExecution = props.activeTab.batchSqlExecution;- if (batchExecution && batchExecution.finishedAt === undefined && batchExecution.total > 1 && props.activeOutputView === "result" && props.activeTab.uiState?.batchSummaryExecutionId !== batchExecution.executionId) {+ if (settingsStore.editorSettings.multiStatementDefaultView === "summary" && batchExecution && batchExecution.finishedAt === undefined && batchExecution.total > 1 && props.activeOutputView === "result" && props.activeTab.uiState?.batchSummaryExecutionId !== batchExecution.executionId) {queryStore.updateTabUiState(props.activeTab.id, { activeOutputView: "summary", batchSummaryExecutionId: batchExecution.executionId });emit("update:activeOutputView", props.activeTab.id, "summary");return;diff --git a/apps/desktop/src/components/layout/__tests__/ContentArea.batchSummary.spec.ts b/apps/desktop/src/components/layout/__tests__/ContentArea.batchSummary.spec.tsindex e79b9b7299..16e7cb62c4 100644--- a/apps/desktop/src/components/layout/__tests__/ContentArea.batchSummary.spec.ts+++ b/apps/desktop/src/components/layout/__tests__/ContentArea.batchSummary.spec.ts@@ -12,6 +12,7 @@ vi.mock("@/components/grid/DataGrid.vue", () => ({ __esModule: true, default: {import ContentArea from "../ContentArea.vue";import { useConnectionStore } from "@/stores/connectionStore";import { useQueryStore } from "@/stores/queryStore";+import { useSettingsStore } from "@/stores/settingsStore";const cleanups: Array<() => void> = [];afterEach(() => {@@ -34,9 +35,10 @@ function batch(executionId: string, total: number, finishedAt?: number): BatchSq};}-async function mountTab(options: { batch?: BatchSqlExecution; isExecuting?: boolean; results?: QueryResult[] }) {+async function mountTab(options: { batch?: BatchSqlExecution; isExecuting?: boolean; results?: QueryResult[]; defaultView?: "result" | "summary" }) {const pinia = createPinia();setActivePinia(pinia);+ useSettingsStore().editorSettings.multiStatementDefaultView = options.defaultView ?? "result";const connection = { id: "mysql", name: "MySQL", db_type: "mysql" as const, host: "localhost", port: 3306, username: "", password: "" };useConnectionStore().connections = [connection];const results = options.results ?? [];@@ -67,6 +69,7 @@ async function mountTab(options: { batch?: BatchSqlExecution; isExecuting?: boolexecutableSql: "",formatSqlRequest: null,compressSqlRequest: null,+ keywordCaseRequest: null,selectedSql: "",cursorPos: 0,resultOnly: true,@@ -88,14 +91,14 @@ async function mountTab(options: { batch?: BatchSqlExecution; isExecuting?: booldescribe("batch execution output view", () => {it("opens the summary while a multi-statement run is in progress", async () => {- const { state, tab } = await mountTab({ batch: batch("run-1", 3) });+ const { state, tab } = await mountTab({ batch: batch("run-1", 3), defaultView: "summary" });expect(state.view).toBe("summary");expect(useQueryStore().tabs.find((candidate) => candidate.id === tab.id)?.uiState?.batchSummaryExecutionId).toBe("run-1");});it("keeps the view the user picks during that run", async () => {- const { state, tab } = await mountTab({ batch: batch("run-1", 3) });+ const { state, tab } = await mountTab({ batch: batch("run-1", 3), defaultView: "summary" });expect(state.view).toBe("summary");state.view = "result";@@ -107,7 +110,7 @@ describe("batch execution output view", () => {});it("opens the summary again for the next run", async () => {- const { state, tab } = await mountTab({ batch: batch("run-1", 3) });+ const { state, tab } = await mountTab({ batch: batch("run-1", 3), defaultView: "summary" });state.view = "result";await nextTick();@@ -119,6 +122,61 @@ describe("batch execution output view", () => {expect(useQueryStore().tabs.find((candidate) => candidate.id === tab.id)?.uiState?.batchSummaryExecutionId).toBe("run-2");});+ it("keeps the default result grid across multiple runs and completion", async () => {+ const { state, tab } = await mountTab({ batch: batch("run-1", 2) });+ expect(state.view).toBe("result");++ for (const executionId of ["run-1", "run-2"]) {+ tab.isExecuting = true;+ tab.batchSqlExecution = batch(executionId, 2);+ await nextTick();+ expect(state.view).toBe("result");+ tab.result = { columns: ["a"], rows: [[1]], affected_rows: 0, execution_time_ms: 1 };+ tab.results = [tab.result];+ tab.batchSqlExecution = batch(executionId, 2, Date.now());+ tab.isExecuting = false;+ await nextTick();+ expect(state.view).toBe("result");+ }+ });++ it("honors summary to result and back to summary between executions", async () => {+ const { state, tab } = await mountTab({ batch: batch("run-1", 2), defaultView: "summary" });+ expect(state.view).toBe("summary");+ tab.result = { columns: ["a"], rows: [[1]], affected_rows: 0, execution_time_ms: 1 };+ tab.results = [tab.result];+ tab.batchSqlExecution = batch("run-1", 2, Date.now());+ tab.isExecuting = false;+ await nextTick();++ useSettingsStore().editorSettings.multiStatementDefaultView = "result";+ await nextTick();+ expect(state.view).toBe("summary");+ // The execution entry point selects the configured view before starting.+ state.view = "result";+ tab.isExecuting = true;+ tab.batchSqlExecution = batch("run-2", 2);+ await nextTick();+ await nextTick();+ expect(state.view).toBe("result");+ tab.batchSqlExecution = batch("run-2", 2, Date.now());+ tab.isExecuting = false;+ await nextTick();+ expect(state.view).toBe("result");++ useSettingsStore().editorSettings.multiStatementDefaultView = "summary";+ tab.isExecuting = true;+ tab.batchSqlExecution = batch("run-3", 2);+ await nextTick();+ await nextTick();+ expect(state.view).toBe("summary");+ });++ it("still shows the summary when a completed batch has no tabular results", async () => {+ const { state } = await mountTab({ batch: batch("run-1", 2, Date.now()), isExecuting: false, results: [{ columns: [], rows: [], affected_rows: 1, execution_time_ms: 1 }] });+ expect(state.view).toBe("summary");+ });+it("leaves a single-statement execution on its result grid", async () => {const { state } = await mountTab({ batch: batch("run-1", 1), results: [{ columns: ["a"], rows: [[1]], affected_rows: 1, execution_time_ms: 1 }] });diff --git a/apps/desktop/src/composables/__tests__/useSqlExecution.spec.ts b/apps/desktop/src/composables/__tests__/useSqlExecution.spec.tsindex 98f0b9060e..2b8db93d10 100644--- a/apps/desktop/src/composables/__tests__/useSqlExecution.spec.ts+++ b/apps/desktop/src/composables/__tests__/useSqlExecution.spec.ts@@ -517,7 +517,7 @@ describe("useSqlExecution", () => {expect(activeOutputView.value).toBe("result");});- it("opens the execution summary for a multi-statement batch when configured", async () => {+ it("reads the latest multi-statement default view on each execution in the same tab", async () => {const sql = "SELECT 1;\nSELECT 2;";const activeTab = ref<QueryTab | undefined>({ ...queryTab("app"), sql });const activeConnection = ref<ConnectionConfig | undefined>(connection("mysql"));@@ -536,9 +536,11 @@ describe("useSqlExecution", () => {activeOutputView,});- await execution.tryExecute();-- expect(activeOutputView.value).toBe("summary");+ for (const view of ["summary", "result", "summary"] as const) {+ useSettingsStore().editorSettings.multiStatementDefaultView = view;+ await execution.tryExecute();+ expect(activeOutputView.value).toBe(view);+ }});it("does not change the current output view when a background tab finishes", async () => {