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(tabs): restore plugin tab group icons and names
ezreal1af2b62f948a
diff --git a/apps/desktop/src/components/layout/EditorGroupTabBar.vue b/apps/desktop/src/components/layout/EditorGroupTabBar.vueindex 40dfccb22f..3466839d1c 100644--- a/apps/desktop/src/components/layout/EditorGroupTabBar.vue+++ b/apps/desktop/src/components/layout/EditorGroupTabBar.vue@@ -498,6 +498,8 @@ function databaseTabGroupKey(tab: QueryTab) {}function tabGroupKey(tab: QueryTab) {+ // Standalone plugin pages must not share the unbound SQL tabs' empty key.+ if (isConnectionlessPluginTab(tab)) return "connectionless:plugin";const connection = connectionStore.getConfig(tab.connectionId);if (settingsStore.editorSettings.tabGroupMode === "sidebar") return tab.connectionId;if (settingsStore.editorSettings.tabGroupMode === "connection") return tab.connectionId;@@ -614,6 +616,7 @@ const editingTabGroupColor = ref("");const editingTabGroupFallbackColor = ref(tabGroupPalette[0]!);function tabGroupDefaultLabel(tab: QueryTab) {+ if (!tab.connectionId) return t(isConnectionlessPluginTab(tab) ? "tabs.pluginTabs" : "tabs.ungroupedTabs");const connection = connectionStore.getConfig(tab.connectionId);if (settingsStore.editorSettings.tabGroupMode === "sidebar") return tabConnectionLabel(tab);if (settingsStore.editorSettings.tabGroupMode === "connection") return connection?.name || tab.connectionId;@@ -1190,9 +1193,7 @@ const twoRowGroupItems = computed<TwoRowGroupItem[]>(() => {const tab = tabs[0]!;return {key,- // An unlabeled cluster is usually connectionless plugin tabs: a lone one- // names itself, several of them read better as "Plugins" than "Ungrouped".- label: tabGroupLabel(tab) || (tabs.length === 1 ? tabTitleText(tab) : tabs.every(isConnectionlessPluginTab) ? t("tabs.pluginTabs") : t("tabs.ungroupedTabs")),+ label: tabGroupLabel(tab) || (tabs.length === 1 ? tabTitleText(tab) : t("tabs.ungroupedTabs")),count: tabs.length,tab,tabIds: tabs.map((item) => item.id),@@ -1384,6 +1385,12 @@ function isConnectionlessPluginTab(tab: QueryTab): boolean {return (tab.mode === "plugin-workbench" || tab.mode === "plugin-filesystem") && !tab.connectionId;}+function isPluginTabGroup(tab: QueryTab): boolean {+ const connection = connectionStore.getConfig(tab.connectionId);+ // A plugin page can also belong to a regular database connection.+ return connection ? connection.db_type === "plugin" : tab.mode === "plugin-workbench" || tab.mode === "plugin-filesystem";+}+/*** Drag visuals for a pill, ported from the legacy tab bar's tabDropStyle: the* dragged pill dims, and the hovered pill shows an inset ring line marking@@ -2144,7 +2151,8 @@ watch([() => props.specialPageTabs?.settingsActive, () => props.specialPageTabs?><span class="tab-group-header-content"><span class="tab-group-marker" aria-hidden="true" />- <ConnectionIcon v-if="group.key && settingsStore.editorSettings.tabGroupMode === 'sidebar'" :connection="connectionStore.getConfig(group.tab.connectionId)" class="tab-group-database-icon" aria-hidden="true" />+ <PlugZap v-if="isPluginTabGroup(group.tab)" class="tab-group-database-icon text-violet-600 dark:text-violet-400" aria-hidden="true" />+ <ConnectionIcon v-else-if="group.key && settingsStore.editorSettings.tabGroupMode === 'sidebar'" :connection="connectionStore.getConfig(group.tab.connectionId)" class="tab-group-database-icon" aria-hidden="true" /><DatabaseIcon v-else :db-type="tabDatabaseIconType(group.tab)" class="tab-group-database-icon" aria-hidden="true" /><span class="tab-group-label">{{ group.label }}</span><span class="tab-group-count">{{ group.count }}</span>@@ -2262,7 +2270,8 @@ watch([() => props.specialPageTabs?.settingsActive, () => props.specialPageTabs?<span class="tab-group-marker" aria-hidden="true" /><Pin v-if="entry.pinned" class="tab-group-pin" aria-hidden="true" /><ChevronDown class="tab-group-chevron" :class="{ 'tab-group-chevron--collapsed': isGroupCollapsed(entry.groupId) }" aria-hidden="true" />- <ConnectionIcon v-if="entry.level === 'connection' && settingsStore.editorSettings.tabGroupMode === 'sidebar'" :connection="connectionStore.getConfig(entry.tab.connectionId)" class="tab-group-database-icon tab-group-connection-icon" aria-hidden="true" />+ <PlugZap v-if="entry.level === 'connection' && isPluginTabGroup(entry.tab)" class="tab-group-database-icon tab-group-connection-icon text-violet-600 dark:text-violet-400" aria-hidden="true" />+ <ConnectionIcon v-else-if="entry.level === 'connection' && settingsStore.editorSettings.tabGroupMode === 'sidebar'" :connection="connectionStore.getConfig(entry.tab.connectionId)" class="tab-group-database-icon tab-group-connection-icon" aria-hidden="true" /><DatabaseIcon v-else-if="entry.level === 'connection'" :db-type="tabDatabaseIconType(entry.tab)" class="tab-group-database-icon tab-group-connection-icon" aria-hidden="true" /><Database v-else class="tab-group-database-icon tab-group-library-icon text-yellow-500" aria-hidden="true" /><span class="tab-group-label">{{ entry.label }}</span>diff --git a/apps/desktop/src/components/layout/__tests__/EditorGroupTabBar.groups.spec.ts b/apps/desktop/src/components/layout/__tests__/EditorGroupTabBar.groups.spec.tsindex c28b0ab24c..08d3eea5ff 100644--- a/apps/desktop/src/components/layout/__tests__/EditorGroupTabBar.groups.spec.ts+++ b/apps/desktop/src/components/layout/__tests__/EditorGroupTabBar.groups.spec.ts@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";import { beforeEach, describe, expect, it, vi } from "vitest";import { createPinia, setActivePinia } from "pinia";import { createI18n } from "vue-i18n";-import { createApp, nextTick, reactive } from "vue";+import { createApp, h, nextTick, reactive } from "vue";import EditorGroupTabBar from "../EditorGroupTabBar.vue";import { useConnectionStore } from "@/stores/connectionStore";import { useQueryStore } from "@/stores/queryStore";@@ -50,11 +50,9 @@ async function settle() {function mountBar(groupId: string, tabs: ReturnType<ReturnType<typeof useQueryStore>["tabs"]>[number][], activeTabId: string | null, activePinia: ReturnType<typeof createPinia>, extraProps: Record<string, unknown> = {}) {const host = createHost();- const app = createApp(EditorGroupTabBar, {- groupId,- tabs,- activeTabId,- ...extraProps,+ const activeTab = reactive({ id: activeTabId });+ const app = createApp({+ render: () => h(EditorGroupTabBar, { groupId, tabs, activeTabId: activeTab.id, ...extraProps }),});app.use(activePinia);app.use(@@ -116,6 +114,8 @@ function mountBar(groupId: string, tabs: ReturnType<ReturnType<typeof useQueryStopenTabs: "Open tabs",searchOpenTabs: "Search",noMatchingTabs: "No matching tabs",+ pluginTabs: "Plugins",+ ungroupedTabs: "Ungrouped",},common: { cancel: "Cancel", save: "Save" },toolbar: { formatSqlFailed: "Format failed" },@@ -126,7 +126,7 @@ function mountBar(groupId: string, tabs: ReturnType<ReturnType<typeof useQuerySt}),);app.mount(host);- return { app, host };+ return { app, host, activeTab };}describe("EditorGroupTabBar group behavior", () => {@@ -590,12 +590,12 @@ describe("EditorGroupTabBar group behavior", () => {host.remove();});- it("renders standalone plugin workbenches outside the connection hierarchy", async () => {+ it.each(["plugin-workbench", "plugin-filesystem"] as const)("renders standalone %s tabs outside the connection hierarchy", async (mode) => {const store = useQueryStore();const settings = useSettingsStore();settings.editorSettings.tabGroupMode = "sidebar";settings.editorSettings.tabPlacement = "left";- const pluginTabId = store.openPluginWorkbench("io.dbx.ssh", "io.dbx.ssh.workbench", { title: "SSH server" });+ const pluginTabId = mode === "plugin-workbench" ? store.openPluginWorkbench("io.dbx.ssh", "io.dbx.ssh.workbench", { title: "SSH server" }) : store.openPluginFilesystem("io.dbx.ssh", "io.dbx.ssh.files", { title: "SSH server" });const { app, host } = mountBar(store.groups[0]!.id, store.tabs.slice(), pluginTabId, pinia);await settle();@@ -606,7 +606,32 @@ describe("EditorGroupTabBar group behavior", () => {host.remove();});- it("uses plugin-aware icons for sidebar connection headers", async () => {+ it.each((["connection", "database", "database-type"] as const).flatMap((groupMode) => (["single", "two-row"] as const).map((rows) => ({ groupMode, rows }))))("labels connectionless plugins with the plugin center icon in $groupMode $rows groups", async ({ groupMode, rows }) => {+ const store = useQueryStore();+ const settings = useSettingsStore();+ settings.editorSettings.tabGroupMode = groupMode;+ settings.editorSettings.tabGroupRows = rows;+ settings.editorSettings.tabPlacement = rows === "single" ? "left" : "top";+ const workbenchId = store.openPluginWorkbench("io.dbx.ssh", "io.dbx.ssh.workbench", { title: "SSH server" });+ const filesystemId = store.openPluginFilesystem("io.dbx.ssh", "io.dbx.ssh.files", { title: "SSH files" });+ const { app, host } = mountBar(store.groups[0]!.id, store.tabs.slice(), workbenchId, pinia);++ try {+ await settle();+ const headers = host.querySelectorAll<HTMLButtonElement>(".tab-group-header");+ expect(headers).toHaveLength(1);+ expect(headers[0]!.title).toBe("Plugins");+ expect(headers[0]!.querySelector(".lucide-plug-zap.text-violet-600")).not.toBeNull();+ expect(headers[0]!.querySelector("img.database-logo")).toBeNull();+ expect(host.querySelector(`[data-tab-id="${workbenchId}"]`)?.textContent).toContain("SSH server");+ expect(host.querySelector(`[data-tab-id="${filesystemId}"]`)?.textContent).toContain("SSH files");+ } finally {+ app.unmount();+ host.remove();+ }+ });++ it.each((["connection", "sidebar"] as const).flatMap((groupMode) => (["single", "two-row"] as const).map((rows) => ({ groupMode, rows }))))("uses the plugin center icon for real plugin connections in $groupMode $rows headers", async ({ groupMode, rows }) => {const connectionStore = useConnectionStore();connectionStore.connections = [{@@ -623,18 +648,90 @@ describe("EditorGroupTabBar group behavior", () => {];const store = useQueryStore();const settings = useSettingsStore();- settings.editorSettings.tabGroupMode = "sidebar";- settings.editorSettings.tabPlacement = "left";+ settings.editorSettings.tabGroupMode = groupMode;+ settings.editorSettings.tabGroupRows = rows;+ settings.editorSettings.tabPlacement = rows === "single" ? "left" : "top";const pluginTabId = store.openPluginWorkbench("io.dbx.ssh", "io.dbx.ssh.workbench", { title: "SSH server", connectionId: "ssh-1" });const { app, host } = mountBar(store.groups[0]!.id, store.tabs.slice(), pluginTabId, pinia);- for (let index = 0; index < 20 && !host.querySelector("[data-tree-level='connection'] img"); index += 1) {- await new Promise((resolveTimeout) => setTimeout(resolveTimeout, 5));+ try {+ await settle();+ const header = host.querySelector<HTMLButtonElement>(".tab-group-header")!;+ expect(header.title).toBe("SSH");+ expect(header.querySelector(".lucide-plug-zap.text-violet-600")).not.toBeNull();+ expect(header.querySelector("img")).toBeNull();+ // The group uses the common plugin icon; the page keeps its own asset.+ for (let index = 0; index < 20 && !host.querySelector(`[data-tab-id="${pluginTabId}"] img`); index += 1) {+ await new Promise((resolveTimeout) => setTimeout(resolveTimeout, 5));+ }+ expect(host.querySelector(`[data-tab-id="${pluginTabId}"] img`)).not.toBeNull();+ } finally {+ app.unmount();+ host.remove();}+ });- expect(host.querySelector("[data-tree-level='connection'] img")).not.toBeNull();+ it("keeps connectionless plugin and SQL groups separate when switching the two-row rail", async () => {+ const store = useQueryStore();+ const settings = useSettingsStore();+ settings.editorSettings.tabGroupMode = "connection";+ settings.editorSettings.tabGroupRows = "two-row";+ settings.editorSettings.tabPlacement = "top";+ const pluginTabId = store.openPluginWorkbench("io.dbx.ssh", "io.dbx.ssh.workbench", { title: "SSH server" });+ const queryTabId = store.createTab("", "", "Unbound SQL", "query");+ const { app, host, activeTab } = mountBar(store.groups[0]!.id, store.tabs.slice(), queryTabId, pinia, {+ "onActivate-tab": (tabId: string) => {+ activeTab.id = tabId;+ },+ });- app.unmount();- host.remove();+ try {+ await settle();+ const headers = Array.from(host.querySelectorAll<HTMLButtonElement>(".tab-group-rail-scroll .tab-group-header"));+ expect(headers.map((header) => header.title).sort()).toEqual(["Plugins", "Ungrouped"]);+ const pluginHeader = headers.find((header) => header.title === "Plugins")!;+ const queryHeader = headers.find((header) => header.title === "Ungrouped")!;+ expect(pluginHeader.querySelector(".lucide-plug-zap")).not.toBeNull();+ expect(queryHeader.querySelector(".lucide-database")).not.toBeNull();+ expect(host.querySelector(".tab-group-header img[src$='/pulsar.svg']")).toBeNull();+ expect(host.querySelector(`[data-tab-id="${queryTabId}"]`)).not.toBeNull();+ expect(host.querySelector(`[data-tab-id="${pluginTabId}"]`)).toBeNull();++ pluginHeader.click();+ await settle();+ expect(host.querySelector(`[data-tab-id="${pluginTabId}"]`)).not.toBeNull();+ expect(host.querySelector(`[data-tab-id="${queryTabId}"]`)).toBeNull();++ queryHeader.click();+ await settle();+ expect(host.querySelector(`[data-tab-id="${queryTabId}"]`)).not.toBeNull();+ expect(host.querySelector(`[data-tab-id="${pluginTabId}"]`)).toBeNull();+ } finally {+ app.unmount();+ host.remove();+ }+ });++ it.each(["single", "two-row"] as const)("keeps database icons for database-bound plugin pages in %s groups", async (rows) => {+ const connectionStore = useConnectionStore();+ connectionStore.connections = [{ id: "pg-1", name: "Postgres", db_type: "postgres", driver_profile: "postgres" } as ConnectionConfig];+ const store = useQueryStore();+ const settings = useSettingsStore();+ settings.editorSettings.tabGroupMode = "connection";+ settings.editorSettings.tabGroupRows = rows;+ settings.editorSettings.tabPlacement = rows === "single" ? "left" : "top";+ const pluginTabId = store.openPluginWorkbench("io.dbx.example", "io.dbx.example.workbench", { title: "Database tool", connectionId: "pg-1" });+ const { app, host } = mountBar(store.groups[0]!.id, store.tabs.slice(), pluginTabId, pinia);++ try {+ await settle();+ const header = host.querySelector<HTMLButtonElement>(".tab-group-header")!;+ expect(header.title).toBe("Postgres");+ expect(header.querySelector("img[src$='/postgres.svg']")).not.toBeNull();+ expect(header.querySelector(".lucide-plug-zap")).toBeNull();+ } finally {+ app.unmount();+ host.remove();+ }});it("labels Redis database branches with their indexes and aliases", async () => {diff --git a/apps/desktop/src/lib/__tests__/tabs/tabPresentation.spec.ts b/apps/desktop/src/lib/__tests__/tabs/tabPresentation.spec.tsindex 5a9a8ac971..441aec3a91 100644--- a/apps/desktop/src/lib/__tests__/tabs/tabPresentation.spec.ts+++ b/apps/desktop/src/lib/__tests__/tabs/tabPresentation.spec.ts@@ -1089,18 +1089,27 @@ describe("shared tab presentation helpers", () => {expect(tabConnectionColor("conn-2")).toBe("#abcdef");});- it("resolves MQ driver icons from the connection store", () => {+ it.each(["query", "plugin-workbench", "plugin-filesystem"] as const)("does not use an MQ icon for a %s tab without a connection", (mode) => {+ expect(tabDatabaseIconType(queryTab({ connectionId: "", mode }))).toBe("unknown");+ expect(tabDatabaseIconType(queryTab({ connectionId: "deleted-connection", mode }))).toBe("unknown");+ });++ it("preserves the MQ fallback for an MQ tab without a connection", () => {+ expect(tabDatabaseIconType(queryTab({ connectionId: "deleted-mq", mode: "mq" }))).toBe("mq");+ });++ it.each(["kafka", "rabbitmq", "rocketmq", "pulsar"])("resolves the %s MQ driver icon from the connection store", (driver) => {const connectionStore = useConnectionStore();connectionStore.connections = [{id: "mq-1",name: "MQ",db_type: "mq",- driver_profile: "kafka",+ driver_profile: driver,color: "",} as ConnectionConfig,];- expect(tabDatabaseIconType(queryTab({ connectionId: "mq-1", mode: "mq" }))).toBe("kafka");+ expect(tabDatabaseIconType(queryTab({ connectionId: "mq-1", mode: "mq" }))).toBe(driver);});it("returns a dirty-title style only when the tab is dirty", () => {diff --git a/apps/desktop/src/lib/tabs/tabPresentation.ts b/apps/desktop/src/lib/tabs/tabPresentation.tsindex bf76406c79..669c042d45 100644--- a/apps/desktop/src/lib/tabs/tabPresentation.ts+++ b/apps/desktop/src/lib/tabs/tabPresentation.ts@@ -788,7 +788,7 @@ export function tabModeLabel(tab: QueryTab, t: Translate): string {export function tabDatabaseIconType(tab: QueryTab): string {const connectionStore = useConnectionStore();const connection = connectionStore.getConfig(tab.connectionId);- if (!connection) return "mq";+ if (!connection) return tab.mode === "mq" ? "mq" : "unknown";if (connection.db_type === "mq") {const externalConfig = connection.external_config as { systemKind?: unknown } | undefined;const systemKind = typeof externalConfig?.systemKind === "string" ? externalConfig.systemKind : "";