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
Revert "fix(plugins): preserve inactive workbench tab layout geometry" (#13831)
二丫讲梵842fc17ffdd8
diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vueindex 5e6ab4f68c..540c7089a3 100644--- a/apps/desktop/src/App.vue+++ b/apps/desktop/src/App.vue@@ -661,7 +661,7 @@ function updatePluginAiRecommendations(tabId: string, update: PluginAiRecommenda// iframe moved out of the DOM reloads from scratch, so KeepAlive/ContentArea// remounts flash the whole webview and drop its live session state.const mountedPluginWorkbenchTabs = computed(() => queryStore.tabs.filter((tab) => tab.mode === "plugin-workbench" && tab.pluginWorkbench));-type PluginWorkbenchTabHandle = { refresh: () => Promise<unknown>; notifyLayout?: () => void };+type PluginWorkbenchTabHandle = { refresh: () => Promise<unknown> };const pluginWorkbenchTabRefs = new Map<string, PluginWorkbenchTabHandle>();let detachedEventUnlisteners: Array<() => void> = [];let floatingEventUnlisteners: Array<() => void> = [];@@ -5622,7 +5622,7 @@ onUnmounted(() => {</Dialog><divv-show="!driverStoreActive && !pluginCenterActive && !settingsStore.settingsPageActive"- class="relative flex min-h-0 min-w-0 flex-1"+ class="flex min-h-0 min-w-0 flex-1":class="activeTab?.mode === 'plugin-workbench' && isVerticalTabPlacement ? (settingsStore.editorSettings.tabPlacement === 'right' ? 'flex-row-reverse' : 'flex-row') : 'flex-col'"><div class="flex min-h-0" :class="activeTab?.mode === 'plugin-workbench' ? (isVerticalTabPlacement ? 'h-full flex-none flex-col' : 'flex-none flex-col') : 'flex-1 flex-col'">@@ -5784,24 +5784,21 @@ onUnmounted(() => {</SqlEditorWorkspace></div><!-- Always-mounted plugin workbench layer: switching tabs only- toggles visibility without destroying iframes. Inactive- tabs are preserved offscreen at full container bounds- (visibility:hidden, absolute inset-0) rather than display:none,- preventing terminal/layout collapse (0x0) during periodic- background redraws (#13734). -->- <div v-if="mountedPluginWorkbenchTabs.length > 0" class="relative min-h-0 min-w-0" :class="activeTab?.mode === 'plugin-workbench' ? 'flex flex-1 flex-col' : 'pointer-events-none absolute inset-0 -z-10 invisible size-full'">- <div v-for="workbenchTab in mountedPluginWorkbenchTabs" :key="workbenchTab.id" class="size-full min-h-0 flex-col" :class="activeTab && workbenchTab.id === activeTab.id ? 'relative flex flex-1' : 'pointer-events-none absolute inset-0 -z-10 invisible'">- <PluginWorkbenchTab- :ref="(element) => setPluginWorkbenchTabRef(workbenchTab.id, element)"- :tab-id="workbenchTab.id"- :active="activeTab?.id === workbenchTab.id"- :plugin-id="workbenchTab.pluginWorkbench!.pluginId"- :contribution-id="workbenchTab.pluginWorkbench!.contributionId"- :context="workbenchTab.pluginWorkbench!.context"- @close-tab="queryStore.closeTab(workbenchTab.id)"- @recommendations="updatePluginAiRecommendations(workbenchTab.id, $event)"- />- </div>+ toggles visibility, so plugin webviews (SSH terminals) are+ never destroyed and reloaded. SqlEditorWorkspace no longer+ renders plugin tabs — this layer owns them. It in turn+ yields the layout (display:none) while a plugin tab is+ active, or both flex-1 siblings would split the column. -->+ <div v-for="workbenchTab in mountedPluginWorkbenchTabs" :key="workbenchTab.id" v-show="activeTab && workbenchTab.id === activeTab.id" class="flex min-h-0 flex-1 flex-col">+ <PluginWorkbenchTab+ :ref="(element) => setPluginWorkbenchTabRef(workbenchTab.id, element)"+ :tab-id="workbenchTab.id"+ :plugin-id="workbenchTab.pluginWorkbench!.pluginId"+ :contribution-id="workbenchTab.pluginWorkbench!.contributionId"+ :context="workbenchTab.pluginWorkbench!.context"+ @close-tab="queryStore.closeTab(workbenchTab.id)"+ @recommendations="updatePluginAiRecommendations(workbenchTab.id, $event)"+ /></div></div><PluginBottomDock v-if="!isDetachedWindowContext" />diff --git a/apps/desktop/src/components/plugins/PluginBottomDock.vue b/apps/desktop/src/components/plugins/PluginBottomDock.vueindex 5ed9e77d36..48d57c5e19 100644--- a/apps/desktop/src/components/plugins/PluginBottomDock.vue+++ b/apps/desktop/src/components/plugins/PluginBottomDock.vue@@ -640,12 +640,11 @@ onScopeDispose(() => window.removeEventListener("blur", onPlusMenuWindowBlur));<X class="h-3.5 w-3.5" /></Button></div>- <div class="relative min-h-0 flex-1 overflow-hidden">- <div v-for="entry in entries" :key="entry.id" class="size-full min-h-0" :class="entry.id === activeEntryId && !collapsed ? 'relative flex size-full' : 'pointer-events-none absolute inset-0 -z-10 invisible'">+ <div class="min-h-0 flex-1 overflow-hidden">+ <div v-for="entry in entries" v-show="entry.id === activeEntryId && !collapsed" :key="entry.id" class="h-full w-full"><PluginWorkbenchHostv-if="workbenchContributionFor(entry)":ref="setWorkbenchHostRef(entry.id)"- :active="entry.id === activeEntryId && !collapsed":plugin="definitionFor(entry.pluginId)!":contribution="workbenchContributionFor(entry)!":context="entry.context"diff --git a/apps/desktop/src/components/plugins/PluginWorkbenchHost.spec.ts b/apps/desktop/src/components/plugins/PluginWorkbenchHost.spec.tsindex 3a72252ce6..90f8335fd8 100644--- a/apps/desktop/src/components/plugins/PluginWorkbenchHost.spec.ts+++ b/apps/desktop/src/components/plugins/PluginWorkbenchHost.spec.ts@@ -449,37 +449,4 @@ describe("PluginWorkbenchHost initialization", () => {),);});-- it("posts a layout message to the iframe when active becomes true", async () => {- const activeRef = ref(false);- app = createApp({- components: { PluginWorkbenchHost },- setup() {- return { activeRef, plugin, contribution };- },- template: '<PluginWorkbenchHost :plugin="plugin" :contribution="contribution" :active="activeRef" />',- });- app.mount(root);- await flushWorkbenchLoad();-- const frame = root.querySelector("iframe")!;- const target = frame.contentWindow!;- const postMessage = vi.spyOn(target, "postMessage").mockImplementation(() => {});-- // Initially inactive: no layout message- expect(postMessage).not.toHaveBeenCalledWith(expect.objectContaining({ type: "layout" }), "*");-- // Transition to active- activeRef.value = true;- await nextTick();- await vi.waitFor(() =>- expect(postMessage).toHaveBeenCalledWith(- expect.objectContaining({- source: "dbx-host",- type: "layout",- }),- "*",- ),- );- });});diff --git a/apps/desktop/src/components/plugins/PluginWorkbenchHost.vue b/apps/desktop/src/components/plugins/PluginWorkbenchHost.vueindex 06a1d96452..dc8ff4cac0 100644--- a/apps/desktop/src/components/plugins/PluginWorkbenchHost.vue+++ b/apps/desktop/src/components/plugins/PluginWorkbenchHost.vue@@ -41,11 +41,10 @@ const props = withDefaults(plugin: InstalledPlugin;contribution: PluginUiContribution;context?: PluginWorkbenchContext;- active?: boolean;setTitle?: (title: string | null) => Promise<void> | void;getTitle?: () => Promise<string> | string;}>(),- { context: () => ({}), active: true },+ { context: () => ({}) },);const emit = defineEmits<{@@ -900,20 +899,6 @@ watch(() => bridge?.updateTheme(currentBridgeTheme()),);-function notifyLayout(): void {- bridge?.notifyLayout();-}--watch(- () => props.active,- async (active) => {- if (active) {- await nextTick();- notifyLayout();- }- },-);-/** §8.3/§7.4 two-phase close: parents await this before removing the entry so* the plugin can release its workbench scope (PTY sessions, subscriptions);* the bridge bounds the wait and resolves false on legacy/hung plugins. */@@ -921,7 +906,7 @@ function requestClose(): Promise<boolean> {return bridge ? bridge.requestWorkbenchClose() : Promise.resolve(false);}-defineExpose({ requestClose, notifyLayout });+defineExpose({ requestClose });onBeforeUnmount(() => {disposed = true;diff --git a/apps/desktop/src/components/plugins/PluginWorkbenchTab.spec.ts b/apps/desktop/src/components/plugins/PluginWorkbenchTab.spec.tsindex b0341e7f14..8e5c35b738 100644--- a/apps/desktop/src/components/plugins/PluginWorkbenchTab.spec.ts+++ b/apps/desktop/src/components/plugins/PluginWorkbenchTab.spec.ts@@ -256,25 +256,4 @@ describe("PluginWorkbenchTab restore self-heal", () => {await vi.waitFor(() => expect(root.textContent).toContain("pluginPlatform.reloadRequired"));expect(root.querySelector("iframe")).toBeNull();});-- it("forwards the active prop to PluginWorkbenchHost and exposes notifyLayout", async () => {- mocks.connectedIds.add("conn-1");- let tabInstance: any;- app = createApp({- components: { PluginWorkbenchTab },- setup() {- const tabRef = ref();- return { tabRef };- },- mounted() {- tabInstance = (this as any).tabRef;- },- template: '<PluginWorkbenchTab ref="tabRef" plugin-id="com.example.graph" contribution-id="graph.main" :active="false" />',- });- app.mount(root);-- await vi.waitFor(() => expect(root.querySelector("iframe")).toBeInstanceOf(HTMLIFrameElement));- expect(typeof tabInstance?.notifyLayout).toBe("function");- expect(() => tabInstance.notifyLayout()).not.toThrow();- });});diff --git a/apps/desktop/src/components/plugins/PluginWorkbenchTab.vue b/apps/desktop/src/components/plugins/PluginWorkbenchTab.vueindex 4e0136ea38..00c906fecc 100644--- a/apps/desktop/src/components/plugins/PluginWorkbenchTab.vue+++ b/apps/desktop/src/components/plugins/PluginWorkbenchTab.vue@@ -11,17 +11,13 @@ import { useQueryStore } from "@/stores/queryStore";import { useI18n } from "vue-i18n";import { useConnectionStore } from "@/stores/connectionStore";-const props = withDefaults(- defineProps<{- tabId?: string;- active?: boolean;- pluginId: string;- contributionId: string;- connectionId?: string;- context?: PluginWorkbenchContext;- }>(),- { active: true },-);+const props = defineProps<{+ tabId?: string;+ pluginId: string;+ contributionId: string;+ connectionId?: string;+ context?: PluginWorkbenchContext;+}>();const { t, locale: appLocale } = useI18n();const emit = defineEmits<{@@ -162,16 +158,10 @@ function onGetTitle(): string {return "";}-const hostRef = ref<{ requestClose: () => Promise<boolean>; notifyLayout?: () => void } | null>(null);--function notifyLayout() {- hostRef.value?.notifyLayout?.();-}-onMounted(start);watch(() => [props.pluginId, props.contributionId, props.connectionId, props.context?.connectionId], start);-defineExpose({ refresh, notifyLayout });+defineExpose({ refresh });</script><template>@@ -184,9 +174,7 @@ defineExpose({ refresh, notifyLayout });</div><PluginWorkbenchHostv-else- ref="hostRef"class="min-h-0 flex-1"- :active="props.active":plugin="entry.plugin":contribution="entry.contribution":context="hostContext"diff --git a/apps/desktop/src/components/plugins/__tests__/PluginWorkbenchInactiveLayout.spec.ts b/apps/desktop/src/components/plugins/__tests__/PluginWorkbenchInactiveLayout.spec.tsdeleted file mode 100644index 934080b0d7..0000000000--- a/apps/desktop/src/components/plugins/__tests__/PluginWorkbenchInactiveLayout.spec.ts+++ /dev/null@@ -1,80 +0,0 @@-// @vitest-environment happy-dom--import { createApp, defineComponent, h, ref } from "vue";-import { describe, expect, it } from "vitest";--describe("Plugin workbench tab inactive layout preservation (#13734)", () => {- it("preserves inactive tab containers at full bounds without collapsing to display:none", async () => {- const tabs = [- { id: "tab-ssh-1", title: "SSH 1", mode: "plugin-workbench" },- { id: "tab-ssh-2", title: "SSH 2", mode: "plugin-workbench" },- { id: "tab-http", title: "HTTP Client", mode: "plugin-workbench" },- ];- const activeTabId = ref("tab-ssh-1");-- const root = document.createElement("div");- document.body.appendChild(root);-- // Host workspace layer mirroring App.vue's mountedPluginWorkbenchTabs- const HostComponent = defineComponent({- setup() {- return { tabs, activeTabId };- },- template: `- <div class="relative flex size-full flex-col">- <div- v-for="tab in tabs"- :key="tab.id"- :data-testid="'container-' + tab.id"- class="size-full min-h-0 flex-col"- :class="activeTabId === tab.id- ? 'relative flex flex-1'- : 'pointer-events-none absolute inset-0 -z-10 invisible'"- >- <div :data-testid="'webview-' + tab.id" class="size-full">content-{{ tab.title }}</div>- </div>- </div>- `,- });-- const app = createApp(HostComponent);- app.mount(root);-- const c1 = root.querySelector<HTMLElement>("[data-testid='container-tab-ssh-1']")!;- const c2 = root.querySelector<HTMLElement>("[data-testid='container-tab-ssh-2']")!;- const c3 = root.querySelector<HTMLElement>("[data-testid='container-tab-http']")!;-- // Initial state: tab-ssh-1 is active- expect(c1.classList.contains("relative")).toBe(true);- expect(c1.classList.contains("flex")).toBe(true);- expect(c1.classList.contains("flex-1")).toBe(true);- expect(c1.classList.contains("invisible")).toBe(false);-- // Inactive tabs retain absolute inset-0 and invisible instead of display:none- expect(c2.classList.contains("absolute")).toBe(true);- expect(c2.classList.contains("inset-0")).toBe(true);- expect(c2.classList.contains("invisible")).toBe(true);- expect(c2.classList.contains("pointer-events-none")).toBe(true);- expect(c2.style.display).not.toBe("none");-- expect(c3.classList.contains("absolute")).toBe(true);- expect(c3.classList.contains("inset-0")).toBe(true);- expect(c3.classList.contains("invisible")).toBe(true);- expect(c3.style.display).not.toBe("none");-- // Switch to tab-ssh-2- activeTabId.value = "tab-ssh-2";- await new Promise((r) => setTimeout(r, 0));-- expect(c1.classList.contains("invisible")).toBe(true);- expect(c1.classList.contains("absolute")).toBe(true);- expect(c1.style.display).not.toBe("none");-- expect(c2.classList.contains("relative")).toBe(true);- expect(c2.classList.contains("flex-1")).toBe(true);- expect(c2.classList.contains("invisible")).toBe(false);-- app.unmount();- root.remove();- });-});diff --git a/apps/desktop/src/lib/plugins/pluginHostBridge.spec.ts b/apps/desktop/src/lib/plugins/pluginHostBridge.spec.tsindex 8a532079ec..1e79456e7d 100644--- a/apps/desktop/src/lib/plugins/pluginHostBridge.spec.ts+++ b/apps/desktop/src/lib/plugins/pluginHostBridge.spec.ts@@ -1843,9 +1843,7 @@ describe("plugin SDK source", () => {onDragState: (listener: (active: boolean, position?: { x: number; y: number }) => void) => () => void;onDrop: (listener: (files: unknown[], drop: unknown) => void) => () => void;};- onLayout: (listener: (event: unknown) => void) => () => void;};- dispatchEvent: ReturnType<typeof vi.fn>;document: {dispatchEvent: ReturnType<typeof vi.fn>;};@@ -1853,9 +1851,7 @@ describe("plugin SDK source", () => {}function loadSdk(posted: unknown[], initialTheme?: { appearance: "dark" | "light"; tokens: Record<string, string> }): SdkWindow {- const sandbox = {- dispatchEvent: vi.fn(),- } as unknown as SdkWindow;+ const sandbox = {} as SdkWindow;const document = {documentElement: {dataset: {} as Record<string, string>,@@ -2226,39 +2222,6 @@ describe("plugin SDK source", () => {await expect(bridge.requestWorkbenchClose(5000)).resolves.toBe(false);expect(messages.some((message) => message.type === "workbench/close")).toBe(true);});-- it("notifies the plugin of layout recalculations and dispatches window resize inside SDK", () => {- const messages: any[] = [];- const target = { postMessage: (message: unknown) => messages.push(message) } as unknown as Window;- const bridge = new PluginHostBridge(plugin(), workbench, {}, () => target, {- invoke: vi.fn(),- notify: vi.fn(),- sendBinary: vi.fn(),- readAsset: vi.fn(),- });-- bridge.notifyLayout();- expect(messages).toHaveLength(1);- expect(messages[0]).toEqual({- source: "dbx-host",- version: 1,- type: "layout",- });-- const posted: unknown[] = [];- const sdk = loadSdk(posted);- let sdkListenerFired = false;-- sdk.dbxPlugin!.onLayout(() => {- sdkListenerFired = true;- });-- sdk.receiveHostMessage(messages[0]);-- expect(sdk.dispatchEvent).toHaveBeenCalledWith(expect.objectContaining({ type: "resize" }));- expect(sdk.document.dispatchEvent).toHaveBeenCalledWith(expect.objectContaining({ type: "dbx-plugin-layout" }));- expect(sdkListenerFired).toBe(true);- });});describe("AI completion bridge", () => {diff --git a/apps/desktop/src/lib/plugins/pluginHostBridge.ts b/apps/desktop/src/lib/plugins/pluginHostBridge.tsindex b9a1c1cb96..e25e734686 100644--- a/apps/desktop/src/lib/plugins/pluginHostBridge.ts+++ b/apps/desktop/src/lib/plugins/pluginHostBridge.ts@@ -635,15 +635,6 @@ export class PluginHostBridge {});}- /** Tell the plugin UI that its workbench container was resized or transitioned to active. */- notifyLayout(): void {- this.post({- source: HOST_MESSAGE_SOURCE,- version: BRIDGE_VERSION,- type: "layout",- });- }-private async handleRequest(request: PluginRequestMessage, target: Window): Promise<void> {try {enforcePayloadLimit(request.params);@@ -1325,7 +1316,7 @@ export function pluginSdkSource(initialTheme?: PluginBridgeTheme): string {.replace(/\u2029/g, "\\u2029");return `(() => {const pending = new Map();- const listeners = { event: new Set(), binary: new Set(), init: new Set(), context: new Set(), filedrop: new Set(), dragstate: new Set(), close: new Set(), layout: new Set() };+ const listeners = { event: new Set(), binary: new Set(), init: new Set(), context: new Set(), filedrop: new Set(), dragstate: new Set(), close: new Set() };let sequence = 0;let contributionId;let context;@@ -1577,7 +1568,6 @@ export function pluginSdkSource(initialTheme?: PluginBridgeTheme): string {onBinary: (listener) => { listeners.binary.add(listener); return () => listeners.binary.delete(listener); },onContext: (listener) => { listeners.context.add(listener); return () => listeners.context.delete(listener); },onInit: (listener) => { listeners.init.add(listener); if (context !== undefined) listener(context); return () => listeners.init.delete(listener); },- onLayout: (listener) => { listeners.layout.add(listener); return () => listeners.layout.delete(listener); },// §8.3 workbench/close handshake: the host sends workbench/close before// tearing the webview down; the plugin releases its workbench scope (PTY// sessions, subscriptions) in the listeners and the SDK acks once every@@ -1647,12 +1637,6 @@ export function pluginSdkSource(initialTheme?: PluginBridgeTheme): string {: undefined;listeners.dragstate.forEach((listener) => listener(active, position));document.dispatchEvent(new CustomEvent('dbx-plugin-dragstate', { detail: active }));- } else if (message.type === 'layout') {- try {- window.dispatchEvent(new Event('resize'));- } catch {}- listeners.layout.forEach((listener) => listener(message));- document.dispatchEvent(new CustomEvent('dbx-plugin-layout', { detail: message }));} else if (message.type === 'workbench/close') {const notifyClose = (listener) => Promise.resolve().then(listener).catch(() => undefined);Promise.allSettled([...listeners.close].map(notifyClose)).finally(() => {