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(sidebar): centralize tree action handling
t8y2ee85033068ed
diff --git a/apps/desktop/src/components/sidebar/ConnectionTree.vue b/apps/desktop/src/components/sidebar/ConnectionTree.vueindex 4573c759f4..a85870ffd6 100644--- a/apps/desktop/src/components/sidebar/ConnectionTree.vue+++ b/apps/desktop/src/components/sidebar/ConnectionTree.vue@@ -6,10 +6,10 @@ import { useConnectionStore } from "@/stores/connectionStore";import { useQueryStore } from "@/stores/queryStore";import { useSettingsStore } from "@/stores/settingsStore";import { useToast } from "@/composables/useToast";-import type { TreeNode, TreeNodeType } from "@/types/database";+import type { ObjectSourceKind, TreeNode, TreeNodeType } from "@/types/database";import { filterSidebarSearchRootsByConnectionState, filterSidebarTree } from "@/lib/sidebar/sidebarSearchTree";import { isCancelSearchShortcut, isCopySidebarSelectionShortcut, isEditSidebarConnectionShortcut, isPasteSidebarSelectionShortcut } from "@/lib/editor/keyboardShortcuts";-import { copyNameForTreeNode } from "@/lib/sidebar/treeNodeClick";+import { copyNameForTreeNode, objectSourceKindForTreeNode } from "@/lib/sidebar/treeNodeClick";import { copyToClipboard } from "@/lib/common/clipboard";import { connectionPasteTargetGroupId, selectedConnectionClipboardNodes, selectedConnectionEditTarget } from "@/lib/sidebar/sidebarConnectionSelection";import { isEditableSidebarTypeSearchTarget, sidebarTypeSearchNextQuery } from "@/lib/sidebar/sidebarTypeSearch";@@ -17,14 +17,24 @@ import { usesTreeSchemaMode } from "@/lib/database/databaseFeatureSupport";import { connectionUsesDatabaseObjectTreeMode, effectiveDatabaseTypeForConnection } from "@/lib/database/jdbcDialect";import { activeTabSidebarTarget, findSidebarNodeForActiveTab, findSidebarNodeForTarget, findNodePathForTarget, scrollTopForSidebarNode, shouldScrollActiveSidebarSelection, type ActiveTabSidebarTarget, type SidebarNodeScrollAlign } from "@/lib/sidebar/sidebarActiveTabTarget";import { findLoadedTableTargetForCandidate, queryContextTargetFromCandidate, queryCursorTableCandidate, type QueryCursorTableCandidate } from "@/lib/sql/queryCursorTableTarget";-import { SIDEBAR_TREE_ROW_HEIGHT, SIDEBAR_TREE_PRERENDER_COUNT, SIDEBAR_TREE_SCROLL_BUFFER, flattenTree, shouldVirtualizeFlatTree, type FlatTreeNode } from "@/composables/useFlatTree";+import { createFlatTreeIndex, SIDEBAR_TREE_ROW_HEIGHT, SIDEBAR_TREE_PRERENDER_COUNT, SIDEBAR_TREE_SCROLL_BUFFER, flattenTree, shouldVirtualizeFlatTree, type FlatTreeNode } from "@/composables/useFlatTree";import { sidebarTreeContextKey } from "@/lib/sidebar/sidebarTreeContext";import { createSidebarPasteHandlerRegistry } from "@/lib/sidebar/sidebarPasteHandlerRegistry";import { insertSidebarTableSearchControls, isSidebarTableSearchControlNode } from "@/lib/sidebar/sidebarTableSearchControl";import TreeItem from "./TreeItem.vue";+import SidebarTreeItemDialogs from "./SidebarTreeItemDialogs.vue";+import InstallExtensionDialog from "@/components/objects/InstallExtensionDialog.vue";import { RecycleScroller } from "vue-virtual-scroller";import "vue-virtual-scroller/dist/vue-virtual-scroller.css";import LightDropdown from "@/components/ui/LightDropdown.vue";+import { cancelPendingSidebarDataOpen, runSidebarDataOpenImmediately, type SidebarDataOpenRequest } from "@/lib/sidebar/sidebarDataOpenCoordinator";+import CustomContextMenu, { type ContextMenuItem } from "@/components/ui/CustomContextMenu.vue";+import { codeMirrorSqlDialect } from "@/lib/database/jdbcDialect";+import { sqlFormatDialectForDbType } from "@/lib/sql/sqlFormatter";+import { createSidebarActionTarget, findSidebarActionTarget, type SidebarActionTarget } from "@/lib/sidebar/sidebarActionTarget";+import type { SidebarDangerDialogRequest } from "@/lib/sidebar/sidebarDangerDialog";+import { resetSidebarTreeDialogState } from "./sidebarTreeDialogState";+import { SidebarDangerConfirmDialog, SidebarDdlViewDialog, SidebarObjectSourceDialog, SidebarProcedureExecutionDialog, SidebarVisibleDatabasesDialog, SidebarVisibleSchemasDialog } from "./sidebarAsyncDialogs";const { t } = useI18n();const store = useConnectionStore();@@ -39,6 +49,37 @@ const pointerInsideTree = ref(false);const treeScrollerRef = ref<InstanceType<typeof RecycleScroller> | null>(null);const plainTreeScrollerRef = ref<HTMLElement | null>(null);const sidebarScrollbarTrackRef = ref<HTMLElement | null>(null);+const sidebarContextMenuRef = ref<{ close: () => void } | null>(null);+const sidebarContextMenuItems = ref<ContextMenuItem[]>([]);+const sidebarContextMenuTarget = ref<SidebarActionTarget | null>(null);+const sidebarDangerDialogRequest = ref<SidebarDangerDialogRequest | null>(null);+const sidebarDangerDialogOpen = ref(false);+const sidebarDangerDialogConfirming = ref(false);+const sidebarTreeItemDialogController = ref<Record<string, any> | null>(null);+const sidebarInstallExtensionTarget = ref<TreeNode | null>(null);+const sidebarInstallExtensionDialogRef = ref<InstanceType<typeof InstallExtensionDialog> | null>(null);+const sidebarDdlTarget = ref<TreeNode | null>(null);+const sidebarDdlOpen = ref(false);+const sidebarObjectSourceTarget = ref<{ node: TreeNode; initialEditing: boolean } | null>(null);+const sidebarObjectSourceOpen = ref(false);+const sidebarProcedureTarget = ref<TreeNode | null>(null);+const sidebarProcedureOpen = ref(false);+const sidebarVisibleDatabasesTarget = ref<TreeNode | null>(null);+const sidebarVisibleDatabasesOpen = ref(false);+const sidebarVisibleSchemasTarget = ref<TreeNode | null>(null);+const sidebarVisibleSchemasOpen = ref(false);+let sidebarActionGeneration = 0;+const sidebarDdlDatabaseType = computed(() => {+ const connectionId = sidebarDdlTarget.value?.connectionId;+ return connectionId ? effectiveDatabaseTypeForConnection(store.getConfig(connectionId)) : undefined;+});+const sidebarObjectSourceType = computed(() => (sidebarObjectSourceTarget.value ? objectSourceKindForTreeNode(sidebarObjectSourceTarget.value.node.type) : null));+const sidebarObjectSourceDatabaseType = computed(() => {+ const connectionId = sidebarObjectSourceTarget.value?.node.connectionId;+ return connectionId ? effectiveDatabaseTypeForConnection(store.getConfig(connectionId)) : undefined;+});+const sidebarObjectSourceDialect = computed(() => codeMirrorSqlDialect(sidebarObjectSourceDatabaseType.value));+const sidebarObjectSourceFormatDialect = computed(() => sqlFormatDialectForDbType(sidebarObjectSourceDatabaseType.value));type SearchScope = "connection" | "database" | "schema" | "table" | "view";const selectedSearchScopes = ref<SearchScope[]>([]);const searchCollapsedIds = ref<Set<string>>(new Set());@@ -288,13 +329,19 @@ const flatNodes = computed<FlatTreeNode[]>(() =>activeQueries: store.sidebarTableSearchQueries,}),);-const visibleNodes = computed<TreeNode[]>(() => flatNodes.value.map((item) => item.node));-const selectableVisibleNodes = computed<TreeNode[]>(() => visibleNodes.value.filter((node) => !isSidebarTableSearchControlNode(node)));-const selectableVisibleNodeIndexById = computed(() => {- const next = new Map<string, number>();- selectableVisibleNodes.value.forEach((node, index) => next.set(node.id, index));- return next;-});+// Build all lookup tables in one linear pass whenever the visible tree changes.+// Selection, scrolling and sticky headers then avoid repeated full-array scans.+const flatTreeIndex = computed(() =>+ createFlatTreeIndex(flatNodes.value, {+ isSelectable: (node) => !isSidebarTableSearchControlNode(node),+ isBoundary: (type) => type === "connection" || type === "connection-group",+ isDatabaseContainer: (type) => DATABASE_LEVEL_TYPES.has(type),+ isSchemaContainer: (type) => SCHEMA_LEVEL_TYPES.has(type),+ }),+);+const visibleNodes = computed<TreeNode[]>(() => flatTreeIndex.value.visibleNodes);+const selectableVisibleNodes = computed<TreeNode[]>(() => flatTreeIndex.value.selectableVisibleNodes);+const selectableVisibleNodeIndexById = computed(() => flatTreeIndex.value.selectableVisibleNodeIndexById);const useVirtualTree = computed(() => shouldVirtualizeFlatTree(flatNodes.value.length));const activeTab = computed(() => queryStore.tabs.find((tab) => tab.id === queryStore.activeTabId));@@ -382,51 +429,19 @@ const stickyNode = computed<FlatTreeNode | null>(() => {if (len === 0) return null;const topIndex = Math.min(Math.floor(stickyScrollTop.value / SIDEBAR_TREE_ROW_HEIGHT), len - 1);- // flatNodes is a DFS preorder spanning ALL connections, so walking up from a- // leaf visits `... -> schema -> database -> connection -> <other connection>`.- // Stop at the connection boundary so the sticky row never leaks across into a- // different connection's subtree (e.g. MySQL's last database sticking while- // scrolling Dameng). Within one connection: track both candidates and prefer- // database-level; only fall back to schema when the whole path has no- // database-level container (Dameng/Oracle-style trees).- let schemaCandidate: FlatTreeNode | null = null;- let schemaCandidateTop = 0;- for (let i = topIndex; i >= 0; i--) {- const item = nodes[i];- if (item.type === "connection" || item.type === "connection-group") break;- if (DATABASE_LEVEL_TYPES.has(item.type)) {- const rowTop = i * SIDEBAR_TREE_ROW_HEIGHT;- return stickyScrollTop.value > rowTop ? item : null;- }- if (item.type === "schema" && !schemaCandidate) {- schemaCandidate = item;- schemaCandidateTop = i * SIDEBAR_TREE_ROW_HEIGHT;- }- }- if (!schemaCandidate) return null;- return stickyScrollTop.value > schemaCandidateTop ? schemaCandidate : null;+ const containerIndex = flatTreeIndex.value.stickyContainerIndexByIndex[topIndex] ?? -1;+ if (containerIndex < 0) return null;+ return stickyScrollTop.value > containerIndex * SIDEBAR_TREE_ROW_HEIGHT ? nodes[containerIndex] : null;});const stickyHeaderStyle = computed<CSSProperties>(() => {const node = stickyNode.value;if (!node) return {};- const nodes = flatNodes.value;- const currentIndex = nodes.findIndex((item) => item.id === node.id);+ const currentIndex = flatTreeIndex.value.flatNodeIndexById.get(node.id) ?? -1;if (currentIndex < 0) return {};- // Look forward for the next sibling container at the SAME level as the sticky- // node so the push-up only fires when a peer scrolls in (database-to-database,- // or schema-to-schema for Dameng/Oracle), never schema-into-database. Stop at- // the connection boundary so we never reach into the next connection's rows.- const nextTypes = SCHEMA_LEVEL_TYPES.has(node.type) ? SCHEMA_LEVEL_TYPES : DATABASE_LEVEL_TYPES;- let nextDatabaseIndex = -1;- for (let i = currentIndex + 1; i < nodes.length; i++) {- const item = nodes[i];- if (item.type === "connection" || item.type === "connection-group") break;- if (nextTypes.has(item.type)) {- nextDatabaseIndex = i;- break;- }- }+ // The next peer index is precomputed with the flat-tree snapshot so scrolling+ // never scans the remaining tree. Connection boundaries reset the lookup.+ const nextDatabaseIndex = SCHEMA_LEVEL_TYPES.has(node.type) ? flatTreeIndex.value.nextSchemaContainerIndexByIndex[currentIndex] : flatTreeIndex.value.nextDatabaseContainerIndexByIndex[currentIndex];if (nextDatabaseIndex < 0) return {};const distanceToNext = nextDatabaseIndex * SIDEBAR_TREE_ROW_HEIGHT - stickyScrollTop.value;if (distanceToNext >= SIDEBAR_TREE_ROW_HEIGHT) return {};@@ -438,6 +453,11 @@ const stickyHeaderStyle = computed<CSSProperties>(() => {// Reset tracking when the tree rebuilds (connect/disconnect/collapse) so a// stale scrollTop doesn't keep the overlay mounted after a structural change.watch(flatNodes, () => {+ // Menu actions originate from a rendered row instance. Close the singleton+ // before a structural update can recycle that row onto another node.+ sidebarContextMenuRef.value?.close();+ sidebarContextMenuItems.value = [];+ sidebarContextMenuTarget.value = null;stickyScrollTop.value = 0;void nextTick(scheduleSidebarScrollMetricsUpdate);});@@ -567,7 +587,7 @@ function topOcclusionHeightForSidebarNode(nodeId: string): number {async function scrollToSidebarNode(nodeId: string, options?: { align?: SidebarNodeScrollAlign }) {await nextTick();- const index = flatNodes.value.findIndex((item) => item.id === nodeId);+ const index = flatTreeIndex.value.flatNodeIndexById.get(nodeId) ?? -1;const scroller = currentTreeScroller();if (!scroller || index < 0) return;@@ -845,10 +865,177 @@ function onSearchToggle(node: TreeNode) {searchCollapsedIds.value = next;}+function openSidebarContextMenu(event: MouseEvent, node: TreeNode, items: ContextMenuItem[], openContextMenu: (event: MouseEvent, itemsOverride?: ContextMenuItem[]) => void) {+ sidebarContextMenuTarget.value = createSidebarActionTarget(node);+ sidebarContextMenuItems.value = items;+ // Pass the current row's resolved menu atomically. Waiting for the items prop+ // to flush would let the singleton menu briefly reuse the previous row menu.+ openContextMenu(event, items);+}++function openSidebarDangerDialog(request: SidebarDangerDialogRequest) {+ sidebarDangerDialogRequest.value = request;+ sidebarDangerDialogConfirming.value = false;+ sidebarDangerDialogOpen.value = true;+}++async function confirmSidebarDangerDialog() {+ const request = sidebarDangerDialogRequest.value;+ if (!request || sidebarDangerDialogConfirming.value) return;+ if (request.closeOnConfirm !== false) sidebarDangerDialogOpen.value = false;+ sidebarDangerDialogConfirming.value = true;+ try {+ await request.confirm();+ sidebarDangerDialogOpen.value = false;+ } finally {+ sidebarDangerDialogConfirming.value = false;+ }+}++function updateSidebarDangerDialogOption(event: Event) {+ const option = sidebarDangerDialogRequest.value?.option;+ if (!option) return;+ option.checked = (event.target as HTMLInputElement).checked;+ void option.onChange?.(option.checked);+}++function updateSidebarTreeItemDialogController(controller: Record<string, any> | null) {+ sidebarTreeItemDialogController.value = controller;+}++async function openSidebarInstallExtension(node: TreeNode) {+ sidebarInstallExtensionTarget.value = createSidebarActionTarget(node);+ await nextTick();+ sidebarInstallExtensionDialogRef.value?.show();+}++function beginSidebarAction(): number {+ sidebarActionGeneration += 1;+ sidebarDdlOpen.value = false;+ sidebarObjectSourceOpen.value = false;+ sidebarProcedureOpen.value = false;+ sidebarVisibleDatabasesOpen.value = false;+ sidebarVisibleSchemasOpen.value = false;+ sidebarDdlTarget.value = null;+ sidebarObjectSourceTarget.value = null;+ sidebarProcedureTarget.value = null;+ sidebarVisibleDatabasesTarget.value = null;+ sidebarVisibleSchemasTarget.value = null;+ return sidebarActionGeneration;+}++function tableDdlObjectTypeForSidebarNode(type: TreeNodeType): ObjectSourceKind | undefined {+ if (type === "view") return "VIEW";+ if (type === "materialized_view") return "MATERIALIZED_VIEW";+ return undefined;+}++function openSidebarDdl(node: TreeNode) {+ if (!node.connectionId || !node.database) return;+ beginSidebarAction();+ sidebarDdlTarget.value = createSidebarActionTarget(node);+ sidebarDdlOpen.value = true;+}++function openSidebarObjectSource(node: TreeNode, initialEditing: boolean) {+ if (!node.connectionId || !node.database || !objectSourceKindForTreeNode(node.type)) return;+ const target = createSidebarActionTarget(node);+ const requestGeneration = beginSidebarAction();+ void store+ .ensureConnected(target.connectionId!)+ .then(() => {+ if (requestGeneration !== sidebarActionGeneration) return;+ store.activeConnectionId = target.connectionId!;+ sidebarObjectSourceTarget.value = { node: target, initialEditing };+ sidebarObjectSourceOpen.value = true;+ })+ .catch((error: any) => {+ if (requestGeneration === sidebarActionGeneration) toast(error?.message || String(error), 5000);+ });+}++function openSidebarProcedure(node: TreeNode) {+ if (node.type !== "procedure" || !node.connectionId || !node.database) return;+ beginSidebarAction();+ sidebarProcedureTarget.value = createSidebarActionTarget(node);+ sidebarProcedureOpen.value = true;+}++function openSidebarData(node: TreeNode, requireSelection: boolean, runner: (node: TreeNode, request: SidebarDataOpenRequest) => Promise<void>) {+ const target = createSidebarActionTarget(node);+ runSidebarDataOpenImmediately((request) => {+ if (requireSelection && store.selectedTreeNodeId !== target.id) return;+ return runner(target, request);+ });+}++function openSidebarVisibleDatabases(node: TreeNode) {+ if (node.type !== "connection" || !node.connectionId) return;+ beginSidebarAction();+ sidebarVisibleDatabasesTarget.value = createSidebarActionTarget(node);+ sidebarVisibleDatabasesOpen.value = true;+}++function openSidebarVisibleSchemas(node: TreeNode) {+ if ((node.type !== "connection" && node.type !== "database") || !node.connectionId) return;+ const database = node.type === "database" ? node.database : store.getConfig(node.connectionId)?.database;+ if (database == null) return;+ beginSidebarAction();+ sidebarVisibleSchemasTarget.value = createSidebarActionTarget({ ...node, database });+ sidebarVisibleSchemasOpen.value = true;+}++function openSidebarProcedureSql(sql: string) {+ const target = sidebarProcedureTarget.value;+ if (!target?.connectionId || !target.database || !sql) return;+ const tabId = queryStore.createTab(target.connectionId, target.database, `Execute - ${target.label}`, "query", target.schema);+ queryStore.updateSql(tabId, sql);+}++async function executeSidebarProcedureSql(sql: string) {+ const target = sidebarProcedureTarget.value;+ if (!target?.connectionId || !target.database || !sql) return;+ const tabId = queryStore.createTab(target.connectionId, target.database, `Execute - ${target.label}`, "query", target.schema);+ queryStore.updateSql(tabId, sql);+ await queryStore.executeTabSql(tabId, sql);+}++async function refreshSidebarActionTarget() {+ const target = sidebarObjectSourceTarget.value?.node || sidebarDdlTarget.value;+ if (!target) return;+ const currentTarget = findSidebarActionTarget(store.treeNodes, target);+ if (!currentTarget) return;+ try {+ await store.refreshTreeNode(currentTarget);+ } catch (error: any) {+ toast(error?.message || String(error), 5000);+ }+}++watch(sidebarDdlOpen, (open) => {+ if (!open) sidebarDdlTarget.value = null;+});++watch(sidebarObjectSourceOpen, (open) => {+ if (!open) sidebarObjectSourceTarget.value = null;+});++watch(sidebarProcedureOpen, (open) => {+ if (!open) sidebarProcedureTarget.value = null;+});++watch(sidebarVisibleDatabasesOpen, (open) => {+ if (!open) sidebarVisibleDatabasesTarget.value = null;+});++watch(sidebarVisibleSchemasOpen, (open) => {+ if (!open) sidebarVisibleSchemasTarget.value = null;+});+function collapseAllTreeNodes() {store.collapseAllTreeNodes();if (isSearching.value) {- searchCollapsedIds.value = new Set(flatNodes.value.filter((item) => item.node.children?.length).map((item) => item.id));+ searchCollapsedIds.value = new Set(flatTreeIndex.value.expandableNodeIds);}}@@ -866,7 +1053,7 @@ async function selectActiveTabSidebarNode(options: { scroll: boolean }) {await nextTick();- const index = flatNodes.value.findIndex((item) => item.id === match.id);+ const index = flatTreeIndex.value.flatNodeIndexById.get(match.id) ?? -1;const scroller = currentTreeScroller();if (!scroller || index < 0) return;@@ -985,7 +1172,7 @@ function isEditConnectionShortcut(event: KeyboardEvent): boolean {function requestSelectedConnectionEdit(): boolean {const selectedNodeId = store.selectedTreeNodeId;- const currentNode = selectedNodeId ? visibleNodes.value.find((node) => node.id === selectedNodeId) : null;+ const currentNode = selectedNodeId ? flatTreeIndex.value.nodeById.get(selectedNodeId) : null;if (!currentNode) return false;const editTarget = selectedConnectionEditTarget(currentNode, selectedSidebarNodesInVisibleOrder());if (!editTarget) return false;@@ -1025,7 +1212,7 @@ function requestSelectedSidebarPaste(): boolean {const clipboard = store.treeClipboard;const selectedNodeId = store.selectedTreeNodeId;if (clipboard?.kind === "connection-copy") {- const selectedNode = selectedNodeId ? visibleNodes.value.find((node) => node.id === selectedNodeId) : null;+ const selectedNode = selectedNodeId ? flatTreeIndex.value.nodeById.get(selectedNodeId) : null;const targetGroupId = connectionPasteTargetGroupId(selectedNode, (connectionId) => store.groupIdForConnection(connectionId));void store.pasteConnectionClipboard(targetGroupId)@@ -1045,7 +1232,19 @@ onMounted(() => {});onUnmounted(() => {+ sidebarActionGeneration += 1;+ sidebarContextMenuTarget.value = null;+ sidebarContextMenuItems.value = [];+ sidebarDdlTarget.value = null;+ sidebarObjectSourceTarget.value = null;+ sidebarProcedureTarget.value = null;+ sidebarVisibleDatabasesTarget.value = null;+ sidebarVisibleSchemasTarget.value = null;+ sidebarTreeItemDialogController.value = null;+ sidebarDangerDialogRequest.value = null;+ resetSidebarTreeDialogState();window.removeEventListener("keydown", onWindowKeydown);+ cancelPendingSidebarDataOpen();for (const timer of tableSearchTimers.values()) {window.clearTimeout(timer);}@@ -1107,60 +1306,172 @@ defineExpose({ focusSearch, createNewGroup, collapseAllTreeNodes });/></div></div>- <div v-if="flatNodes.length > 0 && useVirtualTree" class="connection-tree-scroll-shell relative min-h-0 flex-1">- <RecycleScroller- ref="treeScrollerRef"- class="sidebar-tree connection-tree-scroller h-full overflow-y-auto"- :class="sidebarTreeOverflowClass"- @click="clearSidebarSelection"- :items="flatNodes"- :item-size="SIDEBAR_TREE_ROW_HEIGHT"- :buffer="SIDEBAR_TREE_SCROLL_BUFFER"- :prerender="SIDEBAR_TREE_PRERENDER_COUNT"- :skip-hover="true"- key-field="id"- type-field="poolType"- flow-mode- >- <template #default="{ item }">+ <CustomContextMenu ref="sidebarContextMenuRef" :items="sidebarContextMenuItems" v-slot="contextMenuSlot">+ <div v-if="flatNodes.length > 0 && useVirtualTree" class="connection-tree-scroll-shell relative min-h-0 flex-1">+ <RecycleScroller+ ref="treeScrollerRef"+ class="sidebar-tree connection-tree-scroller h-full overflow-y-auto"+ :class="sidebarTreeOverflowClass"+ @click="clearSidebarSelection"+ :items="flatNodes"+ :item-size="SIDEBAR_TREE_ROW_HEIGHT"+ :buffer="SIDEBAR_TREE_SCROLL_BUFFER"+ :prerender="SIDEBAR_TREE_PRERENDER_COUNT"+ :skip-hover="true"+ key-field="id"+ type-field="poolType"+ flow-mode+ >+ <template #default="{ item }">+ <TreeItem+ :node="item.node"+ :depth="item.depth"+ :drag-disabled="isFiltering"+ :pending-rename="pendingRenameGroupId === item.node.id"+ :highlighted="highlightedNodeId === item.node.id"+ @search-toggle="onSearchToggle"+ @context-menu="(event, node, items) => openSidebarContextMenu(event, node, items, contextMenuSlot.onContextMenu)"+ @open-ddl="openSidebarDdl"+ @open-object-source="openSidebarObjectSource"+ @open-procedure="openSidebarProcedure"+ @open-data="openSidebarData"+ @open-visible-databases="openSidebarVisibleDatabases"+ @open-visible-schemas="openSidebarVisibleSchemas"+ @open-danger-dialog="openSidebarDangerDialog"+ @open-dialog-controller="updateSidebarTreeItemDialogController"+ @open-install-extension="openSidebarInstallExtension"+ @rename-started="pendingRenameGroupId = null"+ @group-created="startRenamingCreatedGroup"+ />+ </template>+ </RecycleScroller>+ <div v-if="stickyNode" class="sticky-database-header pointer-events-auto absolute inset-x-0 top-0 z-[5] border-b border-border/60" :style="stickyHeaderStyle"><TreeItem+ :node="stickyNode.node"+ :depth="stickyNode.depth"+ :drag-disabled="true"+ @search-toggle="onSearchToggle"+ @context-menu="(event, node, items) => openSidebarContextMenu(event, node, items, contextMenuSlot.onContextMenu)"+ @open-ddl="openSidebarDdl"+ @open-object-source="openSidebarObjectSource"+ @open-procedure="openSidebarProcedure"+ @open-data="openSidebarData"+ @open-visible-databases="openSidebarVisibleDatabases"+ @open-visible-schemas="openSidebarVisibleSchemas"+ @open-danger-dialog="openSidebarDangerDialog"+ @open-dialog-controller="updateSidebarTreeItemDialogController"+ @open-install-extension="openSidebarInstallExtension"+ />+ </div>+ <div v-if="hasSidebarVerticalOverflow" ref="sidebarScrollbarTrackRef" class="sidebar-tree-scrollbar" :class="{ 'sidebar-tree-scrollbar--scrolling': isScrollingSidebar, 'sidebar-tree-scrollbar--dragging': isDraggingSidebarScrollbar }" @pointerdown="onSidebarScrollbarTrackPointerDown">+ <div class="sidebar-tree-scrollbar__thumb" :style="sidebarScrollbarThumbStyle" @pointerdown.stop="onSidebarScrollbarThumbPointerDown" />+ </div>+ </div>+ <div v-else-if="flatNodes.length > 0" class="connection-tree-scroll-shell relative min-h-0 flex-1">+ <div ref="plainTreeScrollerRef" class="sidebar-tree connection-tree-scroller h-full overflow-y-auto" :class="sidebarTreeOverflowClass" @click="clearSidebarSelection" @scroll.passive="onTreeScroll">+ <TreeItem+ v-for="item in flatNodes"+ :key="item.id":node="item.node":depth="item.depth":drag-disabled="isFiltering":pending-rename="pendingRenameGroupId === item.node.id"- :highlighted="highlightedNodeId === item.node.id"+ :highlighted="highlightedNodeId === item.id"@search-toggle="onSearchToggle"+ @context-menu="(event, node, items) => openSidebarContextMenu(event, node, items, contextMenuSlot.onContextMenu)"+ @open-ddl="openSidebarDdl"+ @open-object-source="openSidebarObjectSource"+ @open-procedure="openSidebarProcedure"+ @open-data="openSidebarData"+ @open-visible-databases="openSidebarVisibleDatabases"+ @open-visible-schemas="openSidebarVisibleSchemas"+ @open-danger-dialog="openSidebarDangerDialog"+ @open-dialog-controller="updateSidebarTreeItemDialogController"+ @open-install-extension="openSidebarInstallExtension"@rename-started="pendingRenameGroupId = null"@group-created="startRenamingCreatedGroup"/>- </template>- </RecycleScroller>- <div v-if="stickyNode" class="sticky-database-header pointer-events-auto absolute inset-x-0 top-0 z-[5] border-b border-border/60" :style="stickyHeaderStyle">- <TreeItem :node="stickyNode.node" :depth="stickyNode.depth" :drag-disabled="true" @search-toggle="onSearchToggle" />- </div>- <div v-if="hasSidebarVerticalOverflow" ref="sidebarScrollbarTrackRef" class="sidebar-tree-scrollbar" :class="{ 'sidebar-tree-scrollbar--scrolling': isScrollingSidebar, 'sidebar-tree-scrollbar--dragging': isDraggingSidebarScrollbar }" @pointerdown="onSidebarScrollbarTrackPointerDown">- <div class="sidebar-tree-scrollbar__thumb" :style="sidebarScrollbarThumbStyle" @pointerdown.stop="onSidebarScrollbarThumbPointerDown" />- </div>- </div>- <div v-else-if="flatNodes.length > 0" class="connection-tree-scroll-shell relative min-h-0 flex-1">- <div ref="plainTreeScrollerRef" class="sidebar-tree connection-tree-scroller h-full overflow-y-auto" :class="sidebarTreeOverflowClass" @click="clearSidebarSelection" @scroll.passive="onTreeScroll">- <TreeItem- v-for="item in flatNodes"- :key="item.id"- :node="item.node"- :depth="item.depth"- :drag-disabled="isFiltering"- :pending-rename="pendingRenameGroupId === item.node.id"- :highlighted="highlightedNodeId === item.id"- @search-toggle="onSearchToggle"- @rename-started="pendingRenameGroupId = null"- @group-created="startRenamingCreatedGroup"- />- </div>- <div v-if="hasSidebarVerticalOverflow" ref="sidebarScrollbarTrackRef" class="sidebar-tree-scrollbar" :class="{ 'sidebar-tree-scrollbar--scrolling': isScrollingSidebar, 'sidebar-tree-scrollbar--dragging': isDraggingSidebarScrollbar }" @pointerdown="onSidebarScrollbarTrackPointerDown">- <div class="sidebar-tree-scrollbar__thumb" :style="sidebarScrollbarThumbStyle" @pointerdown.stop="onSidebarScrollbarThumbPointerDown" />+ </div>+ <div v-if="hasSidebarVerticalOverflow" ref="sidebarScrollbarTrackRef" class="sidebar-tree-scrollbar" :class="{ 'sidebar-tree-scrollbar--scrolling': isScrollingSidebar, 'sidebar-tree-scrollbar--dragging': isDraggingSidebarScrollbar }" @pointerdown="onSidebarScrollbarTrackPointerDown">+ <div class="sidebar-tree-scrollbar__thumb" :style="sidebarScrollbarThumbStyle" @pointerdown.stop="onSidebarScrollbarThumbPointerDown" />+ </div></div>- </div>+ </CustomContextMenu>+ <SidebarDdlViewDialog+ v-if="sidebarDdlTarget"+ v-model:open="sidebarDdlOpen"+ :connection-id="sidebarDdlTarget.connectionId!"+ :database="sidebarDdlTarget.database!"+ :schema="sidebarDdlTarget.schema"+ :table-name="sidebarDdlTarget.label"+ :object-type="tableDdlObjectTypeForSidebarNode(sidebarDdlTarget.type)"+ :database-type="sidebarDdlDatabaseType"+ :dialect="codeMirrorSqlDialect(sidebarDdlDatabaseType)"+ :format-dialect="sqlFormatDialectForDbType(sidebarDdlDatabaseType)"+ />++ <SidebarObjectSourceDialog+ v-if="sidebarObjectSourceTarget && sidebarObjectSourceType"+ v-model:open="sidebarObjectSourceOpen"+ :connection-id="sidebarObjectSourceTarget.node.connectionId!"+ :database="sidebarObjectSourceTarget.node.database!"+ :schema="sidebarObjectSourceTarget.node.schema"+ :name="sidebarObjectSourceTarget.node.objectName || sidebarObjectSourceTarget.node.label"+ :signature="sidebarObjectSourceTarget.node.signature"+ :object-type="sidebarObjectSourceType"+ :database-type="sidebarObjectSourceDatabaseType"+ :dialect="sidebarObjectSourceDialect"+ :format-dialect="sidebarObjectSourceFormatDialect"+ :initial-editing="sidebarObjectSourceTarget.initialEditing"+ @saved="refreshSidebarActionTarget"+ />++ <SidebarProcedureExecutionDialog+ v-if="sidebarProcedureTarget?.connectionId && sidebarProcedureTarget.database"+ v-model:open="sidebarProcedureOpen"+ :connection-id="sidebarProcedureTarget.connectionId"+ :database="sidebarProcedureTarget.database"+ :database-type="effectiveDatabaseTypeForConnection(store.getConfig(sidebarProcedureTarget.connectionId))"+ :schema="sidebarProcedureTarget.schema"+ :routine-name="sidebarProcedureTarget.label"+ @open-sql="openSidebarProcedureSql"+ @execute="executeSidebarProcedureSql"+ />++ <SidebarVisibleDatabasesDialog v-if="sidebarVisibleDatabasesTarget?.connectionId" v-model:open="sidebarVisibleDatabasesOpen" :connection-id="sidebarVisibleDatabasesTarget.connectionId" :connection-name="sidebarVisibleDatabasesTarget.label" />++ <SidebarVisibleSchemasDialog+ v-if="sidebarVisibleSchemasTarget?.connectionId && sidebarVisibleSchemasTarget.database != null"+ v-model:open="sidebarVisibleSchemasOpen"+ :connection-id="sidebarVisibleSchemasTarget.connectionId"+ :connection-name="sidebarVisibleSchemasTarget.label"+ :database="sidebarVisibleSchemasTarget.database"+ />+ <SidebarDangerConfirmDialog+ v-if="sidebarDangerDialogRequest"+ v-model:open="sidebarDangerDialogOpen"+ :title="sidebarDangerDialogRequest.title"+ :message="sidebarDangerDialogRequest.message"+ :sql="sidebarDangerDialogRequest.sql"+ :details="sidebarDangerDialogRequest.details"+ :details-text="sidebarDangerDialogRequest.detailsText"+ :confirm-label="sidebarDangerDialogRequest.confirmLabel"+ :loading="sidebarDangerDialogConfirming || sidebarDangerDialogRequest.loading"+ :close-on-confirm="false"+ @confirm="confirmSidebarDangerDialog"+ >+ <template v-if="sidebarDangerDialogRequest.option" #options>+ <label class="mb-3 flex items-start gap-2 rounded-md border bg-muted/20 px-3 py-2 text-sm">+ <input :checked="sidebarDangerDialogRequest.option.checked" type="checkbox" class="mt-0.5 h-3.5 w-3.5 shrink-0 accent-primary" @change="updateSidebarDangerDialogOption" />+ <span class="grid gap-0.5">+ <span class="font-medium text-foreground">{{ sidebarDangerDialogRequest.option.label }}</span>+ <span class="text-xs leading-5 text-muted-foreground">{{ sidebarDangerDialogRequest.option.hint }}</span>+ </span>+ </label>+ </template>+ </SidebarDangerConfirmDialog>+ <SidebarTreeItemDialogs v-if="sidebarTreeItemDialogController" :key="sidebarTreeItemDialogController.node?.id" :controller="sidebarTreeItemDialogController" @closed="sidebarTreeItemDialogController = null" />+ <InstallExtensionDialog v-if="sidebarInstallExtensionTarget" ref="sidebarInstallExtensionDialogRef" :node="sidebarInstallExtensionTarget" @close="refreshSidebarActionTarget" /><div v-if="store.treeNodes.length === 0" class="px-3 py-8 text-center text-muted-foreground text-xs">{{ t("sidebar.noConnections") }}</div>diff --git a/apps/desktop/src/components/sidebar/SidebarAsyncDialogError.vue b/apps/desktop/src/components/sidebar/SidebarAsyncDialogError.vuenew file mode 100644index 0000000000..c1c2d3a5c4--- /dev/null+++ b/apps/desktop/src/components/sidebar/SidebarAsyncDialogError.vue@@ -0,0 +1,14 @@+<script setup lang="ts">+import { AlertTriangle } from "@lucide/vue";++defineProps<{ error?: unknown }>();+</script>++<template>+ <div class="fixed inset-0 z-[100] flex items-center justify-center bg-black/20">+ <div class="flex max-w-md items-start gap-2 rounded-md border border-destructive/40 bg-background p-4 text-sm text-destructive shadow-lg">+ <AlertTriangle class="mt-0.5 h-4 w-4 shrink-0" />+ <span class="break-all">{{ error instanceof Error ? error.message : String(error || "Dialog failed to load") }}</span>+ </div>+ </div>+</template>diff --git a/apps/desktop/src/components/sidebar/SidebarAsyncDialogLoading.vue b/apps/desktop/src/components/sidebar/SidebarAsyncDialogLoading.vuenew file mode 100644index 0000000000..d50dcdbb63--- /dev/null+++ b/apps/desktop/src/components/sidebar/SidebarAsyncDialogLoading.vue@@ -0,0 +1,11 @@+<script setup lang="ts">+import { Loader2 } from "@lucide/vue";+</script>++<template>+ <div class="fixed inset-0 z-[100] flex items-center justify-center bg-black/20" aria-busy="true">+ <div class="rounded-md border border-border bg-background p-4 shadow-lg">+ <Loader2 class="h-5 w-5 animate-spin text-muted-foreground" />+ </div>+ </div>+</template>diff --git a/apps/desktop/src/components/sidebar/SidebarTreeItemDialogs.vue b/apps/desktop/src/components/sidebar/SidebarTreeItemDialogs.vuenew file mode 100644index 0000000000..8f770c73ec--- /dev/null+++ b/apps/desktop/src/components/sidebar/SidebarTreeItemDialogs.vue@@ -0,0 +1,503 @@+<script setup lang="ts">+import { toRefs, watch } from "vue";+import { Loader2, Clipboard, Upload } from "@lucide/vue";+import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog";+import { Button } from "@/components/ui/button";+import { Input } from "@/components/ui/input";+import { SearchableSelect } from "@/components/ui/searchable-select";++const props = defineProps<{ controller: Record<string, any> }>();+const emit = defineEmits<{ closed: [] }>();+const {+ node,+ t,+ highlight,+ showDeleteConfirm,+ connectionDeleteConfirmMessage,+ confirmDelete,+ connectionDeleteMenuLabel,+ showMoveToNewGroupDialog,+ moveToNewGroupName,+ confirmMoveToNewGroup,+ showDeleteGroupConfirm,+ confirmDeleteGroup,+ showRenameObjectDialog,+ renameObjectName,+ renameObjectPreviewSql,+ renameObjectError,+ confirmRenameObject,+ showStructurePreviewDialog,+ structurePreviewTitle,+ isLoadingStructurePreview,+ structurePreviewError,+ structurePreviewSql,+ copyStructurePreview,+ saveStructurePreview,+ showStructureDocCopyDialog,+ structureDocCopyTitle,+ structureDocCopyText,+ selectTextareaContent,+ copyStructureDocText,+ showDuplicateDialog,+ duplicateTableName,+ confirmDuplicateStructure,+ showPasteDialog,+ pasteTableEntries,+ pasteTableMode,+ pasteTableDataCopySupported,+ confirmPasteTable,+ showCreateDatabaseDialog,+ createDatabaseName,+ createDatabaseCharset,+ createDatabaseCharsetOptions,+ createDatabaseCharsetLoading,+ normalizeCreateDatabaseCharset,+ createDatabaseCollation,+ createDatabaseCollationOptionsForCharset,+ createDatabaseCollationsByCharset,+ confirmCreateDatabase,+ showEditDatabasePropertiesDialog,+ editDatabasePropertiesLoading,+ editDatabaseCharset,+ editDatabaseCollation,+ canEditDatabaseComment,+ editDatabaseCommentText,+ editDatabasePropertiesPreviewSql,+ confirmEditDatabaseProperties,+ showCreateNacosNamespaceDialog,+ createNacosNamespaceId,+ createNacosNamespaceName,+ createNacosNamespaceDesc,+ createNacosNamespaceLoading,+ confirmCreateNacosNamespace,+ showEditNacosNamespaceDialog,+ editNacosNamespaceName,+ editNacosNamespaceDesc,+ editNacosNamespaceLoading,+ confirmEditNacosNamespace,+ showCreateSchemaDialog,+ createSchemaName,+ confirmCreateSchema,+ showEditSchemaCommentDialog,+ schemaCommentText,+ schemaCommentLoading,+ schemaCommentPreviewSql,+ confirmEditSchemaComment,+ canSetCreateDatabaseCharset,+ updateCreateDatabaseCharset,+ canEditDatabaseCharsetCollation,+ updateEditDatabaseCharset,+} = toRefs(props.controller);++function pasteTargetsMissing(entries: Array<{ targetName: string }>): boolean {+ return entries.every((entry) => !entry.targetName.trim());+}++watch(+ [+ showDeleteConfirm,+ showMoveToNewGroupDialog,+ showDeleteGroupConfirm,+ showRenameObjectDialog,+ showStructurePreviewDialog,+ showStructureDocCopyDialog,+ showDuplicateDialog,+ showPasteDialog,+ showCreateDatabaseDialog,+ showEditDatabasePropertiesDialog,+ showCreateNacosNamespaceDialog,+ showEditNacosNamespaceDialog,+ showCreateSchemaDialog,+ showEditSchemaCommentDialog,+ ],+ (open) => {+ if (open.every((value) => !value)) emit("closed");+ },+);+</script>++<template>+ <Dialog v-model:open="showDeleteConfirm">+ <DialogContent class="sm:max-w-[400px]">+ <DialogHeader>+ <DialogTitle>{{ t("contextMenu.confirmDeleteTitle") }}</DialogTitle>+ </DialogHeader>+ <p class="text-sm text-muted-foreground">+ {{ connectionDeleteConfirmMessage() }}+ </p>+ <DialogFooter>+ <Button variant="outline" @click="showDeleteConfirm = false">{{ t("dangerDialog.cancel") }}</Button>+ <Button+ variant="destructive"+ @click="+ showDeleteConfirm = false;+ confirmDelete();+ "+ >{{ connectionDeleteMenuLabel() }}</Button+ >+ </DialogFooter>+ </DialogContent>+ </Dialog>++ <Dialog v-model:open="showMoveToNewGroupDialog">+ <DialogContent class="sm:max-w-[360px]">+ <DialogHeader>+ <DialogTitle>{{ t("connectionGroup.createGroup") }}</DialogTitle>+ </DialogHeader>+ <Input v-model="moveToNewGroupName" :placeholder="t('connectionGroup.groupNamePlaceholder')" @keydown.enter.prevent="confirmMoveToNewGroup" />+ <DialogFooter>+ <Button variant="outline" @click="showMoveToNewGroupDialog = false">{{ t("dangerDialog.cancel") }}</Button>+ <Button :disabled="!moveToNewGroupName.trim()" @click="confirmMoveToNewGroup">{{ t("connectionGroup.createGroup") }}</Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>++ <Dialog v-model:open="showDeleteGroupConfirm">+ <DialogContent class="sm:max-w-[400px]">+ <DialogHeader>+ <DialogTitle>{{ t("connectionGroup.deleteGroupConfirmTitle") }}</DialogTitle>+ </DialogHeader>+ <p class="text-sm text-muted-foreground">+ {{ t("connectionGroup.deleteGroupConfirmMessage", { name: node.label }) }}+ </p>+ <DialogFooter>+ <Button variant="outline" @click="showDeleteGroupConfirm = false">{{ t("dangerDialog.cancel") }}</Button>+ <Button variant="destructive" @click="confirmDeleteGroup">{{ t("connectionGroup.deleteGroup") }}</Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>++ <Dialog v-model:open="showRenameObjectDialog">+ <DialogContent class="sm:max-w-[420px]">+ <DialogHeader>+ <DialogTitle>{{ t("contextMenu.renameObjectTitle") }}</DialogTitle>+ </DialogHeader>+ <div class="grid gap-3">+ <Input v-model="renameObjectName" :placeholder="t('contextMenu.renameObjectNamePlaceholder')" @keydown.enter.prevent="confirmRenameObject" />+ <pre v-if="renameObjectPreviewSql" class="max-h-32 overflow-auto rounded bg-muted p-3 text-xs whitespace-pre-wrap" v-html="highlight(renameObjectPreviewSql)"></pre>+ <p v-if="renameObjectError" class="text-sm text-destructive">{{ renameObjectError }}</p>+ </div>+ <DialogFooter>+ <Button variant="outline" @click="showRenameObjectDialog = false">{{ t("dangerDialog.cancel") }}</Button>+ <Button :disabled="!renameObjectName.trim() || renameObjectName.trim() === node.label" @click="confirmRenameObject">+ {{ t("contextMenu.renameObject") }}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>++ <Dialog v-model:open="showStructurePreviewDialog">+ <DialogContent class="sm:max-w-[760px]">+ <DialogHeader>+ <DialogTitle>{{ structurePreviewTitle || t("contextMenu.exportStructure") }}</DialogTitle>+ </DialogHeader>+ <div class="grid gap-3">+ <div v-if="isLoadingStructurePreview" class="flex items-center gap-2 text-sm text-muted-foreground">+ <Loader2 class="h-4 w-4 animate-spin" />+ <span>{{ t("contextMenu.exportStructureLoading") }}</span>+ </div>+ <p v-else-if="structurePreviewError" class="text-sm text-destructive">{{ structurePreviewError }}</p>+ <pre v-else class="max-h-[56vh] min-h-64 overflow-auto rounded bg-muted p-3 text-xs whitespace-pre-wrap" v-html="highlight(structurePreviewSql)"></pre>+ </div>+ <DialogFooter>+ <Button variant="outline" @click="showStructurePreviewDialog = false">{{ t("dangerDialog.cancel") }}</Button>+ <Button variant="outline" :disabled="isLoadingStructurePreview || !structurePreviewSql" @click="copyStructurePreview">+ <Clipboard class="h-4 w-4" />+ {{ t("contextMenu.copyStructure") }}+ </Button>+ <Button :disabled="isLoadingStructurePreview || !structurePreviewSql" @click="saveStructurePreview">+ <Upload class="h-4 w-4" />+ {{ t("contextMenu.saveStructure") }}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>++ <Dialog v-model:open="showStructureDocCopyDialog">+ <DialogContent class="sm:max-w-[760px]">+ <DialogHeader>+ <DialogTitle>{{ structureDocCopyTitle || t("contextMenu.copyStructureAs") }}</DialogTitle>+ </DialogHeader>+ <div class="grid gap-3">+ <p class="text-sm text-muted-foreground">{{ t("contextMenu.structureDocCopyFallbackHint") }}</p>+ <textarea readonly class="max-h-[56vh] min-h-64 resize-y overflow-auto rounded bg-muted p-3 font-mono text-xs whitespace-pre" :value="structureDocCopyText" @focus="selectTextareaContent"></textarea>+ </div>+ <DialogFooter>+ <Button variant="outline" @click="showStructureDocCopyDialog = false">{{ t("dangerDialog.cancel") }}</Button>+ <Button :disabled="!structureDocCopyText" @click="copyStructureDocText">+ <Clipboard class="h-4 w-4" />+ {{ t("contextMenu.copyStructure") }}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>++ <Dialog v-model:open="showDuplicateDialog">+ <DialogContent class="sm:max-w-[400px]">+ <DialogHeader>+ <DialogTitle>{{ t("contextMenu.duplicateNameTitle") }}</DialogTitle>+ </DialogHeader>+ <Input v-model="duplicateTableName" :placeholder="t('contextMenu.duplicateNamePlaceholder')" @keydown.enter.prevent="confirmDuplicateStructure" />+ <DialogFooter>+ <Button variant="outline" @click="showDuplicateDialog = false">{{ t("dangerDialog.cancel") }}</Button>+ <Button :disabled="!duplicateTableName.trim()" @click="confirmDuplicateStructure">{{ t("dangerDialog.confirm") }}</Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>++ <Dialog v-model:open="showPasteDialog">+ <DialogContent class="sm:max-w-[500px]">+ <DialogHeader>+ <DialogTitle>{{ pasteTableEntries.length > 1 ? t("contextMenu.batchPasteTitle") : t("contextMenu.pasteTableConfirmTitle") }}</DialogTitle>+ </DialogHeader>+ <div class="space-y-4">+ <div class="flex gap-2">+ <label class="flex items-center gap-1.5 text-sm cursor-pointer" :class="{ 'opacity-50 cursor-not-allowed': !pasteTableDataCopySupported }">+ <input v-model="pasteTableMode" type="radio" value="structure-and-data" class="accent-primary" :disabled="!pasteTableDataCopySupported" />+ {{ t("contextMenu.pasteOptionStructureAndData") }}+ </label>+ <label class="flex items-center gap-1.5 text-sm cursor-pointer">+ <input v-model="pasteTableMode" type="radio" value="structure-only" class="accent-primary" />+ {{ t("contextMenu.pasteOptionStructureOnly") }}+ </label>+ <label class="flex items-center gap-1.5 text-sm cursor-pointer" :class="{ 'opacity-50 cursor-not-allowed': !pasteTableDataCopySupported }">+ <input v-model="pasteTableMode" type="radio" value="data-only" class="accent-primary" :disabled="!pasteTableDataCopySupported" />+ {{ t("contextMenu.pasteOptionDataOnly") }}+ </label>+ </div>+ <div class="space-y-2 max-h-64 overflow-y-auto">+ <div v-for="(entry, idx) in pasteTableEntries" :key="idx" class="flex items-center gap-2">+ <span class="text-sm text-muted-foreground truncate min-w-0 flex-shrink basis-1/3" :title="entry.sourceName">{{ entry.sourceName }}</span>+ <span class="text-xs text-muted-foreground flex-shrink-0">→</span>+ <Input v-model="entry.targetName" class="flex-1 h-8 text-sm" :placeholder="t('contextMenu.duplicateNamePlaceholder')" />+ </div>+ </div>+ </div>+ <DialogFooter>+ <Button variant="outline" @click="showPasteDialog = false">{{ t("dangerDialog.cancel") }}</Button>+ <Button :disabled="pasteTargetsMissing(pasteTableEntries)" @click="confirmPasteTable">{{ t("dangerDialog.confirm") }}</Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>++ <Dialog v-model:open="showCreateDatabaseDialog">+ <DialogContent class="sm:max-w-[400px]">+ <DialogHeader>+ <DialogTitle>{{ t("contextMenu.createDatabase") }}</DialogTitle>+ </DialogHeader>+ <Input v-model="createDatabaseName" :placeholder="t('contextMenu.createDatabaseNamePlaceholder')" @keydown.enter.prevent="confirmCreateDatabase" />+ <div v-if="canSetCreateDatabaseCharset" class="grid gap-2">+ <div class="grid gap-1.5">+ <label class="text-xs font-medium text-muted-foreground">{{ t("contextMenu.createDatabaseCharset") }}</label>+ <SearchableSelect+ :model-value="createDatabaseCharset"+ :options="createDatabaseCharsetOptions"+ :placeholder="t('contextMenu.createDatabaseCharsetPlaceholder')"+ :search-placeholder="t('contextMenu.createDatabaseCharsetSearchPlaceholder')"+ :empty-text="t('contextMenu.createDatabaseCharsetEmpty')"+ :loading-text="t('contextMenu.createDatabaseCharsetLoading')"+ :loading="createDatabaseCharsetLoading"+ :normalize-custom="normalizeCreateDatabaseCharset"+ allow-custom+ trigger-variant="outline"+ trigger-class="h-9 w-full max-w-none justify-between border bg-background px-3 text-sm shadow-xs hover:bg-accent"+ content-class="w-[var(--reka-popover-trigger-width)]"+ @update:model-value="updateCreateDatabaseCharset"+ >+ <template #custom-option-label="{ value }">+ <span class="truncate">{{ t("contextMenu.createDatabaseCharsetCustomOption", { value }) }}</span>+ </template>+ </SearchableSelect>+ </div>+ <div class="grid gap-1.5">+ <label class="text-xs font-medium text-muted-foreground">{{ t("contextMenu.createDatabaseCollation") }}</label>+ <SearchableSelect+ v-model="createDatabaseCollation"+ :options="createDatabaseCollationOptionsForCharset(createDatabaseCharset, createDatabaseCollationsByCharset)"+ :placeholder="t('contextMenu.createDatabaseCollationPlaceholder')"+ :search-placeholder="t('contextMenu.createDatabaseCollationSearchPlaceholder')"+ :empty-text="t('contextMenu.createDatabaseCollationEmpty')"+ :loading-text="t('contextMenu.createDatabaseCollationLoading')"+ :loading="createDatabaseCharsetLoading"+ :normalize-custom="normalizeCreateDatabaseCharset"+ allow-custom+ trigger-variant="outline"+ trigger-class="h-9 w-full max-w-none justify-between border bg-background px-3 text-sm shadow-xs hover:bg-accent"+ content-class="w-[var(--reka-popover-trigger-width)]"+ >+ <template #custom-option-label="{ value }">+ <span class="truncate">{{ t("contextMenu.createDatabaseCollationCustomOption", { value }) }}</span>+ </template>+ </SearchableSelect>+ </div>+ </div>+ <DialogFooter>+ <Button variant="outline" @click="showCreateDatabaseDialog = false">{{ t("dangerDialog.cancel") }}</Button>+ <Button :disabled="!createDatabaseName.trim()" @click="confirmCreateDatabase">{{ t("dangerDialog.confirm") }}</Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>++ <Dialog v-model:open="showEditDatabasePropertiesDialog">+ <DialogContent class="sm:max-w-[460px]">+ <DialogHeader>+ <DialogTitle>{{ t("contextMenu.editDatabasePropertiesTitle", { name: node.label }) }}</DialogTitle>+ </DialogHeader>+ <div class="grid gap-3">+ <div v-if="canEditDatabaseCharsetCollation" class="grid gap-3">+ <div class="grid gap-1.5">+ <label class="text-xs font-medium text-muted-foreground">{{ t("contextMenu.createDatabaseCharset") }}</label>+ <SearchableSelect+ :model-value="editDatabaseCharset"+ :options="createDatabaseCharsetOptions"+ :placeholder="t('contextMenu.createDatabaseCharsetPlaceholder')"+ :search-placeholder="t('contextMenu.createDatabaseCharsetSearchPlaceholder')"+ :empty-text="t('contextMenu.createDatabaseCharsetEmpty')"+ :loading-text="t('contextMenu.createDatabaseCharsetLoading')"+ :loading="createDatabaseCharsetLoading"+ :normalize-custom="normalizeCreateDatabaseCharset"+ allow-custom+ trigger-variant="outline"+ trigger-class="h-9 w-full max-w-none justify-between border bg-background px-3 text-sm shadow-xs hover:bg-accent"+ content-class="w-[var(--reka-popover-trigger-width)]"+ @update:model-value="updateEditDatabaseCharset"+ >+ <template #custom-option-label="{ value }">+ <span class="truncate">{{ t("contextMenu.createDatabaseCharsetCustomOption", { value }) }}</span>+ </template>+ </SearchableSelect>+ </div>+ <div class="grid gap-1.5">+ <label class="text-xs font-medium text-muted-foreground">{{ t("contextMenu.createDatabaseCollation") }}</label>+ <SearchableSelect+ v-model="editDatabaseCollation"+ :options="createDatabaseCollationOptionsForCharset(editDatabaseCharset, createDatabaseCollationsByCharset)"+ :placeholder="t('contextMenu.createDatabaseCollationPlaceholder')"+ :search-placeholder="t('contextMenu.createDatabaseCollationSearchPlaceholder')"+ :empty-text="t('contextMenu.createDatabaseCollationEmpty')"+ :loading-text="t('contextMenu.createDatabaseCollationLoading')"+ :loading="createDatabaseCharsetLoading"+ :normalize-custom="normalizeCreateDatabaseCharset"+ allow-custom+ trigger-variant="outline"+ trigger-class="h-9 w-full max-w-none justify-between border bg-background px-3 text-sm shadow-xs hover:bg-accent"+ content-class="w-[var(--reka-popover-trigger-width)]"+ >+ <template #custom-option-label="{ value }">+ <span class="truncate">{{ t("contextMenu.createDatabaseCollationCustomOption", { value }) }}</span>+ </template>+ </SearchableSelect>+ </div>+ </div>+ <div v-if="canEditDatabaseComment" class="grid gap-1.5">+ <label class="text-xs font-medium text-muted-foreground">{{ t("contextMenu.editDatabaseComment") }}</label>+ <textarea+ v-model="editDatabaseCommentText"+ class="min-h-28 w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm outline-none transition-colors focus:border-ring focus:ring-1 focus:ring-ring/40"+ :placeholder="t('contextMenu.editDatabaseCommentPlaceholder')"+ :disabled="editDatabasePropertiesLoading"+ @keydown.meta.enter.prevent="confirmEditDatabaseProperties"+ @keydown.ctrl.enter.prevent="confirmEditDatabaseProperties"+ ></textarea>+ </div>+ <pre v-if="editDatabasePropertiesPreviewSql" class="max-h-32 overflow-auto rounded bg-muted p-3 text-xs whitespace-pre-wrap" v-html="highlight(editDatabasePropertiesPreviewSql)"></pre>+ </div>+ <DialogFooter>+ <Button variant="outline" :disabled="editDatabasePropertiesLoading" @click="showEditDatabasePropertiesDialog = false">{{ t("dangerDialog.cancel") }}</Button>+ <Button :disabled="editDatabasePropertiesLoading" @click="confirmEditDatabaseProperties">+ {{ editDatabasePropertiesLoading ? t("contextMenu.editDatabasePropertiesSaving") : t("dangerDialog.confirm") }}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>++ <Dialog v-model:open="showCreateNacosNamespaceDialog">+ <DialogContent class="sm:max-w-[420px]">+ <DialogHeader>+ <DialogTitle>{{ t("nacos.createNamespace") }}</DialogTitle>+ </DialogHeader>+ <div class="grid gap-3">+ <div class="grid gap-1.5">+ <label class="text-xs font-medium text-muted-foreground">{{ t("nacos.namespaceId") }}</label>+ <Input v-model="createNacosNamespaceId" :placeholder="t('nacos.namespaceIdPlaceholder')" @keydown.enter.prevent="confirmCreateNacosNamespace" />+ </div>+ <div class="grid gap-1.5">+ <label class="text-xs font-medium text-muted-foreground">{{ t("nacos.namespaceName") }}</label>+ <Input v-model="createNacosNamespaceName" :placeholder="t('nacos.namespaceNamePlaceholder')" @keydown.enter.prevent="confirmCreateNacosNamespace" />+ </div>+ <div class="grid gap-1.5">+ <label class="text-xs font-medium text-muted-foreground">{{ t("nacos.namespaceDesc") }}</label>+ <Input v-model="createNacosNamespaceDesc" :placeholder="t('nacos.namespaceDescPlaceholder')" @keydown.enter.prevent="confirmCreateNacosNamespace" />+ </div>+ </div>+ <DialogFooter>+ <Button variant="outline" :disabled="createNacosNamespaceLoading" @click="showCreateNacosNamespaceDialog = false">{{ t("dangerDialog.cancel") }}</Button>+ <Button :disabled="!createNacosNamespaceName.trim() || createNacosNamespaceLoading" @click="confirmCreateNacosNamespace">+ {{ createNacosNamespaceLoading ? t("nacos.creatingNamespace") : t("dangerDialog.confirm") }}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>++ <Dialog v-model:open="showEditNacosNamespaceDialog">+ <DialogContent class="sm:max-w-[420px]">+ <DialogHeader>+ <DialogTitle>{{ t("nacos.editNamespace") }}</DialogTitle>+ </DialogHeader>+ <div class="grid gap-3">+ <div class="grid gap-1.5">+ <label class="text-xs font-medium text-muted-foreground">{{ t("nacos.namespaceName") }}</label>+ <Input v-model="editNacosNamespaceName" :placeholder="t('nacos.namespaceNamePlaceholder')" @keydown.enter.prevent="confirmEditNacosNamespace" />+ </div>+ <div class="grid gap-1.5">+ <label class="text-xs font-medium text-muted-foreground">{{ t("nacos.namespaceDesc") }}</label>+ <Input v-model="editNacosNamespaceDesc" :placeholder="t('nacos.namespaceDescPlaceholder')" @keydown.enter.prevent="confirmEditNacosNamespace" />+ </div>+ </div>+ <DialogFooter>+ <Button variant="outline" :disabled="editNacosNamespaceLoading" @click="showEditNacosNamespaceDialog = false">{{ t("dangerDialog.cancel") }}</Button>+ <Button :disabled="!editNacosNamespaceName.trim() || editNacosNamespaceLoading" @click="confirmEditNacosNamespace">+ {{ editNacosNamespaceLoading ? t("nacos.updatingNamespace") : t("dangerDialog.confirm") }}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>++ <Dialog v-model:open="showCreateSchemaDialog">+ <DialogContent class="sm:max-w-[400px]">+ <DialogHeader>+ <DialogTitle>{{ t("contextMenu.createSchema") }}</DialogTitle>+ </DialogHeader>+ <Input v-model="createSchemaName" :placeholder="t('contextMenu.createSchemaNamePlaceholder')" @keydown.enter.prevent="confirmCreateSchema" />+ <DialogFooter>+ <Button variant="outline" @click="showCreateSchemaDialog = false">{{ t("dangerDialog.cancel") }}</Button>+ <Button :disabled="!createSchemaName.trim()" @click="confirmCreateSchema">{{ t("dangerDialog.confirm") }}</Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>++ <Dialog v-model:open="showEditSchemaCommentDialog">+ <DialogContent class="sm:max-w-[520px]">+ <DialogHeader>+ <DialogTitle>{{ t("contextMenu.editSchemaCommentTitle", { name: node.label }) }}</DialogTitle>+ </DialogHeader>+ <div class="grid gap-3">+ <textarea+ v-model="schemaCommentText"+ class="min-h-28 w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm outline-none transition-colors focus:border-ring focus:ring-1 focus:ring-ring/40"+ :placeholder="t('contextMenu.schemaCommentPlaceholder')"+ :disabled="schemaCommentLoading"+ @keydown.meta.enter.prevent="confirmEditSchemaComment"+ @keydown.ctrl.enter.prevent="confirmEditSchemaComment"+ ></textarea>+ <pre v-if="schemaCommentPreviewSql" class="max-h-32 overflow-auto rounded bg-muted p-3 text-xs whitespace-pre-wrap" v-html="highlight(schemaCommentPreviewSql)"></pre>+ </div>+ <DialogFooter>+ <Button variant="outline" :disabled="schemaCommentLoading" @click="showEditSchemaCommentDialog = false">{{ t("dangerDialog.cancel") }}</Button>+ <Button :disabled="schemaCommentLoading" @click="confirmEditSchemaComment">+ {{ schemaCommentLoading ? t("contextMenu.schemaCommentSaving") : t("dangerDialog.confirm") }}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+</template>diff --git a/apps/desktop/src/components/sidebar/TreeItem.vue b/apps/desktop/src/components/sidebar/TreeItem.vueindex 417e480264..d22df9bd40 100644--- a/apps/desktop/src/components/sidebar/TreeItem.vue+++ b/apps/desktop/src/components/sidebar/TreeItem.vue@@ -1,5 +1,5 @@<script setup lang="ts">-import { ref, computed, nextTick, watch, onBeforeUnmount, inject, type Component } from "vue";+import { ref, computed, nextTick, watch, onBeforeUnmount, inject, reactive } from "vue";import { useSqlHighlighter } from "@/composables/useSqlHighlighter";import { useI18n } from "vue-i18n";import { translateBackendError } from "@/i18n/backend-errors";@@ -63,7 +63,7 @@ import {Square,X,} from "@lucide/vue";-import CustomContextMenu from "@/components/ui/CustomContextMenu.vue";+import type { ContextMenuItem } from "@/components/ui/CustomContextMenu.vue";import { CONNECTION_ATTEMPT_CANCELLED_MESSAGE, useConnectionStore } from "@/stores/connectionStore";import { useQueryStore } from "@/stores/queryStore";import { useSettingsStore } from "@/stores/settingsStore";@@ -133,14 +133,12 @@ import { buildRenameObjectSql, supportsObjectRename, type RenameableObjectType }import { buildRoutineRenameObjectSourceStatements, supportsSourceBackedRoutineRename } from "@/lib/table/objectSourceEditor";import { buildViewDdl } from "@/lib/table/viewDdl";import { formatSqlForDisplay, sqlFormatDialectForDbType } from "@/lib/sql/sqlFormatter";-import DdlViewDialog from "@/components/objects/DdlViewDialog.vue";-import ObjectSourceDialog from "@/components/objects/ObjectSourceDialog.vue";import { getTableStructureCapabilities } from "@/lib/table/tableStructureCapabilities";-import { codeMirrorSqlDialect, connectionObjectTreeNodeSchema, connectionObjectTreeQuerySchema, connectionUsesDatabaseObjectTreeMode, effectiveDatabaseTypeForConnection, tableStructureDatabaseTypeForConnection } from "@/lib/database/jdbcDialect";+import { connectionObjectTreeNodeSchema, connectionObjectTreeQuerySchema, connectionUsesDatabaseObjectTreeMode, effectiveDatabaseTypeForConnection, tableStructureDatabaseTypeForConnection } from "@/lib/database/jdbcDialect";import { hexToRgba } from "@/lib/common/color";import { focusSidebarRenameInput } from "@/lib/sidebar/sidebarRenameFocus";import { hasTreeNodeDatabaseContext } from "@/lib/sidebar/treeNodeContext";-import { defaultPasteTableMode, pasteTableModeCopiesData, supportsWholeRowTableDataCopy, tableClipboardMatchesTarget, tableDataCopyColumnOptions, type PasteTableMode, type TableClipboardContext } from "@/lib/table/tableClipboard";+import { defaultPasteTableMode, pasteTableModeCopiesData, supportsWholeRowTableDataCopy, tableClipboardMatchesTarget, tableDataCopyColumnOptions, type TableClipboardContext } from "@/lib/table/tableClipboard";import { sidebarDisplayTableName } from "@/lib/sidebar/sidebarTableNameDisplay";import { shouldMeasureSidebarLabelOverflow } from "@/lib/sidebar/sidebarLabelTooltip";import { selectedTreeNodesInVisibleOrder as orderSelectedTreeNodes, treeSelectionRangeIdsByIndex, treeSelectionRangeIds } from "@/lib/sidebar/sidebarTreeSelection";@@ -152,9 +150,6 @@ import { canCloseSidebarDatabaseConnection, isSidebarDatabaseOpened } from "@/liimport { sidebarTreeContextKey } from "@/lib/sidebar/sidebarTreeContext";import { batchTableEmptyFeedback, runBatchTableEmpty } from "@/lib/sidebar/batchTableEmpty";import { runBatchTableTruncate } from "@/lib/table/batchTableTruncate";-import DangerConfirmDialog from "@/components/editor/DangerConfirmDialog.vue";-import ProcedureExecutionDialog from "@/components/objects/ProcedureExecutionDialog.vue";-import InstallExtensionDialog from "@/components/objects/InstallExtensionDialog.vue";import { useExportTracker, type ExportTask } from "@/composables/useExportTracker";import { isTauriRuntime } from "@/lib/backend/tauriRuntime";import { copyToClipboard } from "@/lib/common/clipboard";@@ -166,18 +161,110 @@ import DatabaseIcon from "@/components/icons/DatabaseIcon.vue";import ConnectionErrorIndicator from "@/components/connection/ConnectionErrorIndicator.vue";import ProductionContextBadge from "@/components/common/ProductionContextBadge.vue";import { isSchemaAware } from "@/lib/database/databaseFeatureSupport";-import VisibleDatabasesDialog from "@/components/sidebar/VisibleDatabasesDialog.vue";-import SchemaFilterDialog from "@/components/sidebar/VisibleSchemasDialog.vue";-import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog";-import { Button } from "@/components/ui/button";import { Badge } from "@/components/ui/badge";import { Input } from "@/components/ui/input";-import { SearchableSelect } from "@/components/ui/searchable-select";import LightTooltip from "@/components/ui/LightTooltip.vue";import { flattenTree } from "@/composables/useFlatTree";-import { createDatabaseCollationOptionsForCharset, fallbackCreateDatabaseCharsetMetadata, nextCreateDatabaseCollation, normalizeCreateDatabaseCharset, parseCreateDatabaseCharsetMetadata } from "@/lib/database/createDatabaseCharsetOptions";+import { createDatabaseCollationOptionsForCharset, nextCreateDatabaseCollation, normalizeCreateDatabaseCharset, parseCreateDatabaseCharsetMetadata } from "@/lib/database/createDatabaseCharsetOptions";import { productionContextForDatabase } from "@/lib/database/productionSafety";import { executeWithProductionSqlGuard } from "@/lib/database/productionExecutionGuard";+import type { SidebarDataOpenRequest } from "@/lib/sidebar/sidebarDataOpenCoordinator";+import { createSidebarActionTarget, findSidebarActionTarget } from "@/lib/sidebar/sidebarActionTarget";+import type { SidebarDangerDialogRequest } from "@/lib/sidebar/sidebarDangerDialog";+import {+ fallbackCreateDatabaseCharset,+ sidebarTreeDialogOwner,+ sidebarDangerTarget,+ sidebarFormTarget,+ connectionDeleteTargetSnapshot,+ showDeleteConfirm,+ showDropTableConfirm,+ showDropTableChildObjectConfirm,+ showBatchDropConfirm,+ showBatchEmptyConfirm,+ showBatchTruncateConfirm,+ showStructurePreviewDialog,+ showStructureDocCopyDialog,+ structurePreviewSql,+ structurePreviewTitle,+ structurePreviewDefaultFileName,+ structurePreviewError,+ structureDocCopyText,+ structureDocCopyTitle,+ isLoadingStructurePreview,+ showEmptyTableConfirm,+ showTruncateTableConfirm,+ showRenameObjectDialog,+ renameObjectName,+ renameObjectError,+ renameObjectPreviewSql,+ dropTablePreviewSql,+ dropTableCascade,+ batchDropCascade,+ emptyTablePreviewSql,+ truncateTablePreviewSql,+ truncateTableCascade,+ dropObjectPreviewSql,+ showDropObjectConfirm,+ dropTableChildObjectPreviewSql,+ batchDropPreviewSql,+ batchEmptyPreviewSql,+ batchEmptyTargets,+ batchDropTargets,+ batchTruncateTargets,+ batchTruncatePreviewSql,+ batchTruncateCascade,+ dropDatabasePreviewSql,+ dropSchemaPreviewSql,+ showDuplicateDialog,+ duplicateTableName,+ duplicateStructureSource,+ showPasteDialog,+ pasteTableMode,+ pasteTableEntries,+ showCreateDatabaseDialog,+ createDatabaseName,+ createDatabaseCharset,+ createDatabaseCollation,+ showCreateNacosNamespaceDialog,+ createNacosNamespaceId,+ createNacosNamespaceName,+ createNacosNamespaceDesc,+ createNacosNamespaceLoading,+ showEditNacosNamespaceDialog,+ editNacosNamespaceName,+ editNacosNamespaceDesc,+ editNacosNamespaceLoading,+ createDatabaseCharsetOptions,+ createDatabaseCollationsByCharset,+ createDatabaseCharsetLoading,+ showDropDatabaseConfirm,+ dropDatabaseLoading,+ showDropMongoCollectionConfirm,+ dropMongoCollectionLoading,+ showDropMongoIndexConfirm,+ dropMongoIndexLoading,+ showDropAllMongoIndexesConfirm,+ dropAllMongoIndexesLoading,+ showFlushRedisDbConfirm,+ showCreateSchemaDialog,+ createSchemaName,+ showDropSchemaConfirm,+ showEditDatabasePropertiesDialog,+ editDatabasePropertiesLoading,+ editDatabasePropertiesPreviewSql,+ editDatabaseCharset,+ editDatabaseCollation,+ editDatabaseCommentText,+ showEditSchemaCommentDialog,+ schemaCommentText,+ schemaCommentLoading,+ schemaCommentPreviewSql,+ showDeleteGroupConfirm,+ showMoveToNewGroupDialog,+ moveToNewGroupName,+ type DuplicateStructureSource,+} from "./sidebarTreeDialogState";const { t } = useI18n();const labelRef = ref<HTMLElement>();@@ -186,19 +273,6 @@ const labelOverflowing = ref(false);let labelResizeObserver: ResizeObserver | null = null;let labelMeasureFrame = 0;-interface ContextMenuItem {- label: string;- action?: () => void;- disabled?: boolean;- separator?: boolean;- icon?: Component;- iconClass?: string;- shortcut?: string;- variant?: "default" | "destructive";- visible?: boolean;- children?: ContextMenuItem[];-}-function cancelLabelOverflowMeasure() {if (!labelMeasureFrame) return;window.cancelAnimationFrame(labelMeasureFrame);@@ -257,11 +331,8 @@ const { highlight } = useSqlHighlighter();const useWindowsSidebarCommentFont = isWindows();type StructureCopyFormat = "tsv" | "markdown";-type DuplicateStructureSource = TreeNode & { connectionId: string; database: string };const DATA_TAB_METADATA_TTL_MS = TABLE_METADATA_CACHE_TTL_MS;const { getDatabaseOptions } = useDatabaseOptions();-const showVisibleDatabasesDialog = ref(false);-const showVisibleSchemasDialog = ref(false);const { addTask: addExportTask } = useExportTracker();const props = defineProps<{@@ -277,7 +348,34 @@ const emit = defineEmits<{"group-created": [groupId: string];"node-toggled": [node: TreeNode, wasExpanded: boolean];"search-toggle": [node: TreeNode];+ "context-menu": [event: MouseEvent, node: TreeNode, items: ContextMenuItem[]];+ "open-ddl": [node: TreeNode];+ "open-object-source": [node: TreeNode, initialEditing: boolean];+ "open-procedure": [node: TreeNode];+ "open-data": [node: TreeNode, requireSelection: boolean, runner: (node: TreeNode, request: SidebarDataOpenRequest) => Promise<void>];+ "open-visible-databases": [node: TreeNode];+ "open-visible-schemas": [node: TreeNode];+ "open-danger-dialog": [request: SidebarDangerDialogRequest];+ "open-dialog-controller": [controller: Record<string, any> | null];+ "open-install-extension": [node: TreeNode];}>();+const treeItemDialogOwner = Symbol("sidebar-tree-dialog-owner");++function claimTreeItemDialogOwnership() {+ sidebarTreeDialogOwner.value = treeItemDialogOwner;+}++function routeTreeItemDialogController() {+ const controller = getTreeItemDialogController();+ const target = createSidebarActionTarget(props.node);+ sidebarFormTarget.value = target;+ controller.node = target;+ controller.pasteTableDataCopySupported = pasteTableDataCopySupported.value;+ controller.canSetCreateDatabaseCharset = canSetCreateDatabaseCharset.value;+ controller.canEditDatabaseCharsetCollation = canEditDatabaseCharsetCollation.value;+ controller.canEditDatabaseComment = canEditDatabaseComment.value;+ emit("open-dialog-controller", controller);+}const usesFullWidthLabel = computed(() => usesFullWidthTreeLabel(props.node.type, settingsStore.editorSettings.sidebarAllowHorizontalScroll));const sidebarTreeContext = inject(sidebarTreeContextKey, null);@@ -740,7 +838,7 @@ function runRowClickAction(clickDetail: number) {const action = treeNodeRowAction(node.type, canExpand.value, settingsStore.editorSettings.sidebarActivation);if (!shouldRunTreeNodeRowAction(action, clickDetail)) return;if (action === "open-data") {- openData();+ scheduleOpenData(node);} else if (isDocumentBrowserTreeNode(node.type)) {openMongoTreeData(node);} else if (node.type === "procedure" || node.type === "function" || node.type === "sequence" || node.type === "package" || node.type === "package-body") {@@ -893,14 +991,17 @@ function onClick(event: MouseEvent) {runRowClickAction(event.detail);}-function onTreeItemContextMenu(event: MouseEvent, openContextMenu: (event: MouseEvent) => void) {+function onTreeItemContextMenu(event: MouseEvent) {+ claimTreeItemDialogOwnership();+ ensureDangerDialogRouting();+ routeTreeItemDialogController();if (!connectionStore.selectedTreeNodeIds.includes(props.node.id)) {selectSingleTreeNode(props.node);} else {connectionStore.selectedTreeNodeId = props.node.id;}rowRef.value?.focus({ preventScroll: true });- openContextMenu(event);+ emit("context-menu", event, props.node, treeItemMenuItems());}function isEditableShortcutTarget(target: EventTarget | null): boolean {@@ -909,6 +1010,7 @@ function isEditableShortcutTarget(target: EventTarget | null): boolean {}function onKeydown(event: KeyboardEvent) {+ claimTreeItemDialogOwnership();if ((!isSelected.value && !isMultiSelected.value) || isEditableShortcutTarget(event.target)) return;if (isPasteTreeClipboardShortcut(event)) {if (!requestPasteTreeClipboard()) return;@@ -977,6 +1079,9 @@ function canPasteTreeClipboardToCurrentNode(): boolean {}function requestPasteTreeClipboard(): boolean {+ claimTreeItemDialogOwnership();+ ensureDangerDialogRouting();+ routeTreeItemDialogController();const clipboard = connectionStore.treeClipboard;if (clipboard?.kind === "connection-copy") {const targetGroupId = connectionPasteTargetGroupId(props.node, (connectionId) => connectionStore.groupIdForConnection(connectionId));@@ -1042,6 +1147,9 @@ function requestEditSelectedConnection(): boolean {}function requestDeleteSelectedNode(): boolean {+ claimTreeItemDialogOwnership();+ ensureDangerDialogRouting();+ routeTreeItemDialogController();if (requestDropSelectedNodes()) return true;if (props.node.type === "connection") {deleteConnection();@@ -1078,7 +1186,7 @@ function onDoubleClick() {void openObjectBrowser();if (!props.node.isExpanded) void toggle();} else if (action === "open-data") {- openData();+ openDataImmediately(props.node);} else if (action === "open-source") {openObjectSourceDialog(false);} else if (action === "open-saved-sql") {@@ -1193,8 +1301,15 @@ async function openDamengJobAdmin() {}}-async function openData() {- const node = props.node;+function scheduleOpenData(node: TreeNode) {+ emit("open-data", node, true, openData);+}++function openDataImmediately(node: TreeNode = props.node) {+ emit("open-data", node, false, openData);+}++async function openData(node: TreeNode, request?: SidebarDataOpenRequest) {if (!(node.type === "table" || node.type === "view" || node.type === "materialized_view") || !hasNodeDatabaseContext(node)) return;const config = connectionStore.getConfig(node.connectionId);const traceId = uuid().slice(0, 8);@@ -1252,7 +1367,7 @@ async function openData() {tab.queryEditabilityReason = undefined;};- if (existingSameTableTab && canActivateExistingDataTableTab(existingSameTableTab)) {+ if (existingSameTableTab && canActivateExistingDataTableTab(existingSameTableTab, { activateExecuting: false })) {queryStore.switchTab(existingSameTableTab.id);logPhase("existing-tab-activated", { table: node.label });return;@@ -1325,6 +1440,12 @@ async function openData() {},);queryStore.setExecutingWithId(tabId, openDataId);+ request?.registerCancel(async () => {+ const current = queryStore.tabs.find((item) => item.id === tabId);+ if (current?.isExecuting && current.executionId === openDataId) {+ await queryStore.cancelTabExecution(tabId);+ }+ });logPhase("state-prepared", { tabId });// Yield to Vue's scheduler so the new tab becomes visible in the UI (tab@@ -1334,8 +1455,9 @@ async function openData() {await nextTick();// Helper to check if this openData call is still active (not superseded by a newer click)- const isActive = () => queryStore.tabs.find((t) => t.id === tabId)?.executionId === openDataId;+ const isActive = () => (request?.isCurrent() ?? true) && queryStore.tabs.find((t) => t.id === tabId)?.executionId === openDataId;const isCurrentDataTab = () => {+ if (!(request?.isCurrent() ?? true)) return false;const current = queryStore.tabs.find((t) => t.id === tabId);return current?.mode === "data" && current.connectionId === node.connectionId && current.database === node.database && current.schema === tableSchema && current.title === node.label;};@@ -1671,9 +1793,8 @@ async function refresh() {}}-const showDeleteConfirm = ref(false);-function connectionDeleteTargets() {+ if (showDeleteConfirm.value && connectionDeleteTargetSnapshot.value.length) return connectionDeleteTargetSnapshot.value;return selectedConnectionDeleteTargets(props.node, selectedTreeNodesInVisibleOrder());}@@ -1693,11 +1814,13 @@ function connectionDuplicateMenuLabel(): string {function connectionDeleteConfirmMessage(): string {const targets = connectionDeleteTargets();- return targets.length > 1 ? t("contextMenu.confirmDeleteSelectedMessage", { count: targets.length }) : t("contextMenu.confirmDeleteMessage", { name: props.node.label });+ return targets.length > 1 ? t("contextMenu.confirmDeleteSelectedMessage", { count: targets.length }) : t("contextMenu.confirmDeleteMessage", { name: targets[0]?.label || sidebarFormTarget.value?.label || props.node.label });}function deleteConnection() {- if (!connectionDeleteTargets().length) return;+ const targets = selectedConnectionDeleteTargets(props.node, selectedTreeNodesInVisibleOrder());+ if (!targets.length) return;+ connectionDeleteTargetSnapshot.value = targets.slice();showDeleteConfirm.value = true;}@@ -1793,122 +1916,14 @@ async function duplicateConnection() {}// --- Table Management Operations ----const showDropTableConfirm = ref(false);-const showDropTableChildObjectConfirm = ref(false);-const showBatchDropConfirm = ref(false);-const showBatchEmptyConfirm = ref(false);-const showBatchTruncateConfirm = ref(false);-const showStructurePreviewDialog = ref(false);-const showStructureDocCopyDialog = ref(false);-const structurePreviewSql = ref("");-const structurePreviewTitle = ref("");-const structurePreviewDefaultFileName = ref("structure.sql");-const structurePreviewError = ref("");-const structureDocCopyText = ref("");-const structureDocCopyTitle = ref("");-const isLoadingStructurePreview = ref(false);-const showEmptyTableConfirm = ref(false);-const showTruncateTableConfirm = ref(false);-const showRenameObjectDialog = ref(false);-const renameObjectName = ref("");-const renameObjectError = ref("");-const renameObjectPreviewSql = ref("");-const dropTablePreviewSql = ref("");-const dropTableCascade = ref(false);-const batchDropCascade = ref(false);-const emptyTablePreviewSql = ref("");-const truncateTablePreviewSql = ref("");-const truncateTableCascade = ref(false);-const dropObjectPreviewSql = ref("");-const dropTableChildObjectPreviewSql = ref("");-const batchDropPreviewSql = ref("");-const batchEmptyPreviewSql = ref("");-const batchEmptyTargets = ref<TreeNode[]>([]);-const batchTruncatePreviewSql = ref("");-const batchTruncateCascade = ref(false);-const dropDatabasePreviewSql = ref("");-const dropSchemaPreviewSql = ref("");-const showDuplicateDialog = ref(false);-const duplicateTableName = ref("");-const duplicateStructureSource = ref<DuplicateStructureSource | null>(null);--// Paste table dialog state-const showPasteDialog = ref(false);-const pasteTableMode = ref<PasteTableMode>("structure-and-data");-const pasteTableEntries = ref<{ sourceName: string; targetName: string; connectionId: string; database: string; schema?: string }[]>([]);const pasteTableDataCopySupported = computed(() => supportsWholeRowTableDataCopy(currentDatabaseType()));-const ddlTarget = ref<TreeNode | null>(null);-const showDdlDialog = ref(false);-const ddlDatabaseType = computed(() => {- if (!ddlTarget.value?.connectionId) return undefined;- return effectiveDatabaseTypeForConnection(connectionStore.getConfig(ddlTarget.value.connectionId));-});-const ddlDialect = computed(() => {- return codeMirrorSqlDialect(ddlDatabaseType.value);-});-const ddlFormatDialect = computed(() => {- return sqlFormatDialectForDbType(ddlDatabaseType.value);-});-const objectSourceTarget = ref<{ node: TreeNode; initialEditing: boolean } | null>(null);-const showObjectSourceDialog = ref(false);-const objectSourceType = computed(() => (objectSourceTarget.value ? objectSourceKindForTreeNode(objectSourceTarget.value.node.type) : null));-const objectSourceDatabaseType = computed(() => {- const connectionId = objectSourceTarget.value?.node.connectionId;- return connectionId ? effectiveDatabaseTypeForConnection(connectionStore.getConfig(connectionId)) : undefined;-});-const objectSourceDialect = computed(() => codeMirrorSqlDialect(objectSourceDatabaseType.value));-const objectSourceFormatDialect = computed(() => sqlFormatDialectForDbType(objectSourceDatabaseType.value));-const showCreateDatabaseDialog = ref(false);-const createDatabaseName = ref("");-const createDatabaseCharset = ref("utf8mb4");-const createDatabaseCollation = ref("utf8mb4_unicode_ci");-const showCreateNacosNamespaceDialog = ref(false);-const createNacosNamespaceId = ref("");-const createNacosNamespaceName = ref("");-const createNacosNamespaceDesc = ref("");-const createNacosNamespaceLoading = ref(false);-const showEditNacosNamespaceDialog = ref(false);-const editNacosNamespaceName = ref("");-const editNacosNamespaceDesc = ref("");-const editNacosNamespaceLoading = ref(false);-const fallbackCreateDatabaseCharset = fallbackCreateDatabaseCharsetMetadata();-const createDatabaseCharsetOptions = ref<string[]>(fallbackCreateDatabaseCharset.charsets);-const createDatabaseCollationsByCharset = ref<Record<string, string[]>>(fallbackCreateDatabaseCharset.collationsByCharset);-const createDatabaseCharsetLoading = ref(false);-const showDropDatabaseConfirm = ref(false);-const dropDatabaseLoading = ref(false);-const showDropMongoCollectionConfirm = ref(false);-const dropMongoCollectionLoading = ref(false);-const showDropMongoIndexConfirm = ref(false);-const dropMongoIndexLoading = ref(false);-const showDropAllMongoIndexesConfirm = ref(false);-const dropAllMongoIndexesLoading = ref(false);-const showFlushRedisDbConfirm = ref(false);-const showCreateSchemaDialog = ref(false);-const createSchemaName = ref("");-const showDropSchemaConfirm = ref(false);-const showEditDatabasePropertiesDialog = ref(false);-const editDatabasePropertiesLoading = ref(false);-const editDatabasePropertiesPreviewSql = ref("");-const editDatabaseCharset = ref("utf8mb4");-const editDatabaseCollation = ref("utf8mb4_unicode_ci");-const editDatabaseCommentText = ref("");-const showEditSchemaCommentDialog = ref(false);-const schemaCommentText = ref("");-const schemaCommentLoading = ref(false);-// --- Extension Management ----const installExtensionDialogRef = ref<InstanceType<typeof InstallExtensionDialog> | null>(null);--function openInstallExtensionDialog(_node: TreeNode) {- installExtensionDialogRef.value?.show();+function openInstallExtensionDialog(node: TreeNode) {+ emit("open-install-extension", node);}// --- Procedure / Function Management ----const showDropObjectConfirm = ref(false);-const showProcedureExecutionConfirm = ref(false);-function dropObjectSqlOptions(): DropObjectSqlOptions | null {return dropObjectSqlOptionsForNode(props.node);}@@ -2039,8 +2054,7 @@ function openObjectSourceDialog(initialEditing: boolean) {.ensureConnected(node.connectionId).then(() => {connectionStore.activeConnectionId = node.connectionId!;- objectSourceTarget.value = { node, initialEditing };- showObjectSourceDialog.value = true;+ emit("open-object-source", node, initialEditing);}).catch((e: any) => {toast(e?.message || String(e), 5000);@@ -2050,22 +2064,7 @@ function openObjectSourceDialog(initialEditing: boolean) {function openProcedureExecution() {const node = props.node;if (node.type !== "procedure" || !node.connectionId || !node.database) return;- showProcedureExecutionConfirm.value = true;-}--function openProcedureExecutionSql(sql: string) {- const node = props.node;- if (node.type !== "procedure" || !node.connectionId || !node.database || !sql) return;- const tabId = queryStore.createTab(node.connectionId, node.database, `Execute - ${node.label}`, "query", node.schema);- queryStore.updateSql(tabId, sql);-}--async function executeProcedureSql(sql: string) {- const node = props.node;- if (node.type !== "procedure" || !node.connectionId || !node.database || !sql) return;- const tabId = queryStore.createTab(node.connectionId, node.database, `Execute - ${node.label}`, "query", node.schema);- queryStore.updateSql(tabId, sql);- await queryStore.executeTabSql(tabId, sql);+ emit("open-procedure", node);}function requestDropObject() {@@ -2166,11 +2165,6 @@ function selectedBatchEmptyTargets(): TreeNode[] {return selectedBatchTableTargets();}-function selectedBatchMongoIndexTargets(): TreeNode[] {- const targets = selectedBatchDropTargets();- return targets.length > 1 && targets.every((node) => canDropMongoIndexNode(node)) ? targets : [];-}-function selectedBatchIndexTableName(targets: TreeNode[]): string | null {const first = targets[0];if (!first) return null;@@ -2187,7 +2181,7 @@ function batchDropMenuLabel(): string {}function batchDropConfirmTitle(): string {- const targets = selectedBatchDropTargets();+ const targets = batchDropTargets.value;if (targets.length > 1 && targets.every((node) => node.type === "index")) {return t("contextMenu.confirmDropIndexTitle");}@@ -2195,7 +2189,7 @@ function batchDropConfirmTitle(): string {}function batchDropConfirmMessage(): string {- const targets = selectedBatchDropTargets();+ const targets = batchDropTargets.value;const table = selectedBatchIndexTableName(targets);if (targets.length > 1 && targets.every((node) => node.type === "index") && table) {return t("contextMenu.confirmDropBatchIndexesMessage", { count: targets.length, table });@@ -2224,11 +2218,11 @@ function batchEmptyConfirmLabel(): string {}function batchTruncateConfirmTitle(): string {- return t("contextMenu.confirmBatchTruncateTitle", { count: selectedBatchTruncateTargets().length });+ return t("contextMenu.confirmBatchTruncateTitle", { count: batchTruncateTargets.value.length });}function batchTruncateConfirmMessage(): string {- return t("contextMenu.confirmBatchTruncateMessage", { count: selectedBatchTruncateTargets().length });+ return t("contextMenu.confirmBatchTruncateMessage", { count: batchTruncateTargets.value.length });}async function dropSqlForTreeNode(node: TreeNode, options?: { cascade?: boolean }): Promise<string | null> {@@ -2270,8 +2264,8 @@ async function emptySqlForTreeNode(node: TreeNode): Promise<string | null> {}async function refreshBatchDropPreviewSql() {- const targets = selectedBatchDropTargets();- const mongoIndexTargets = selectedBatchMongoIndexTargets();+ const targets = batchDropTargets.value;+ const mongoIndexTargets = targets.filter(canDropMongoIndexNode);if (mongoIndexTargets.length) {batchDropPreviewSql.value = mongoIndexTargets.map((target) => mongoIndexDropPreview(target, mongoIndexNameForNode(target))).join("\n");return;@@ -2286,7 +2280,7 @@ async function refreshBatchDropPreviewSql() {}async function refreshBatchTruncatePreviewSql() {- const targets = selectedBatchTruncateTargets();+ const targets = batchTruncateTargets.value;const statements: string[] = [];const useCascade = canBatchTruncateCascade.value && batchTruncateCascade.value;for (const target of targets) {@@ -2306,14 +2300,18 @@ async function refreshBatchEmptyPreviewSql(targets: TreeNode[]) {}function requestBatchDrop() {- if (!selectedBatchDropTargets().length) return;+ const targets = selectedBatchDropTargets();+ if (!targets.length) return;+ batchDropTargets.value = targets.slice();batchDropCascade.value = false;void refreshBatchDropPreviewSql();showBatchDropConfirm.value = true;}function requestBatchTruncate() {- if (!selectedBatchTruncateTargets().length) return;+ const targets = selectedBatchTruncateTargets();+ if (!targets.length) return;+ batchTruncateTargets.value = targets.slice();batchTruncateCascade.value = false;void refreshBatchTruncatePreviewSql();showBatchTruncateConfirm.value = true;@@ -2380,6 +2378,8 @@ const canRenameObject = computed(() => {});function openRenameObjectDialog() {+ claimTreeItemDialogOwnership();+ routeTreeItemDialogController();renameObjectName.value = props.node.label;renameObjectError.value = "";renameObjectPreviewSql.value = "";@@ -2431,13 +2431,13 @@ watch([showRenameObjectDialog, renameObjectName, () => props.node.label, () => p});async function confirmRenameObject() {- const node = props.node;- const objectType = nodeRenameObjectType();+ const node = sidebarFormTarget.value ?? props.node;+ const objectType = node.type === "table" ? "TABLE" : node.type === "view" ? "VIEW" : node.type === "materialized_view" ? "MATERIALIZED_VIEW" : node.type === "procedure" ? "PROCEDURE" : node.type === "function" ? "FUNCTION" : null;const newName = renameObjectName.value.trim();if (!objectType || !newName || newName === node.label || !node.connectionId || !node.database) return;renameObjectError.value = "";try {- const dbType = currentDatabaseType();+ const dbType = databaseTypeForNode(node);await connectionStore.ensureConnected(node.connectionId);if (supportsSourceBackedRoutineRename(dbType, objectType as any)) {const schema = node.schema || node.database;@@ -2472,9 +2472,9 @@ async function confirmRenameObject() {}async function confirmDropObject() {- const node = props.node;+ const node = sidebarDangerTarget.value ?? props.node;if (!node.connectionId || !node.database) return;- const options = dropObjectSqlOptions();+ const options = dropObjectSqlOptionsForNode(node);if (!options) return;try {await connectionStore.ensureConnected(node.connectionId);@@ -2494,9 +2494,9 @@ async function confirmDropObject() {}async function confirmDropTableChildObject() {- const node = props.node;+ const node = sidebarDangerTarget.value ?? props.node;if (!node.connectionId || !node.database) return;- const options = dropTableChildObjectSqlOptions();+ const options = dropTableChildObjectSqlOptionsForNode(node);if (!options) return;try {await connectionStore.ensureConnected(node.connectionId);@@ -2510,10 +2510,10 @@ async function confirmDropTableChildObject() {}async function confirmBatchDrop() {- const targets = selectedBatchDropTargets();+ const targets = batchDropTargets.value.slice();if (!targets.length) return;try {- const mongoIndexTargets = selectedBatchMongoIndexTargets();+ const mongoIndexTargets = targets.filter(canDropMongoIndexNode);if (mongoIndexTargets.length) {const grouped = new Map<string, TreeNode[]>();for (const target of mongoIndexTargets) {@@ -2539,7 +2539,7 @@ async function confirmBatchDrop() {showBatchDropConfirm.value = false;return;}- const useCascade = canBatchDropCascade.value && batchDropCascade.value;+ const useCascade = batchDropCascade.value && targets.every((node) => node.type !== "table" || supportsDropTableCascade(databaseTypeForNode(node)));for (const target of targets) {if (!target.connectionId || !target.database) continue;await connectionStore.ensureConnected(target.connectionId);@@ -2557,10 +2557,10 @@ async function confirmBatchDrop() {}async function confirmBatchTruncate() {- const targets = selectedBatchTruncateTargets();+ const targets = batchTruncateTargets.value.slice();if (!targets.length) return;try {- const useCascade = canBatchTruncateCascade.value && batchTruncateCascade.value;+ const useCascade = batchTruncateCascade.value && targets.every((node) => supportsTruncateTableCascade(databaseTypeForNode(node)));await runBatchTableTruncate(targets,async (target) => {@@ -2741,6 +2741,16 @@ function tableAdminSqlOptions(options?: { cascade?: boolean }): TableAdminSqlOptreturn result;}+function tableAdminSqlOptionsForNode(node: TreeNode, options?: { cascade?: boolean }): TableAdminSqlOptions {+ const result: TableAdminSqlOptions = {+ databaseType: databaseTypeForNode(node),+ schema: node.schema,+ tableName: node.label,+ };+ if (options?.cascade) result.cascade = true;+ return result;+}+function dropTableSqlOptions(): TableAdminSqlOptions {return tableAdminSqlOptions({ cascade: canDropTableCascade.value && dropTableCascade.value });}@@ -2776,11 +2786,11 @@ async function refreshTableList(node: TreeNode) {}async function confirmDropTable() {- const node = props.node;+ const node = sidebarDangerTarget.value ?? props.node;if (!node.connectionId || !node.database) return;try {await connectionStore.ensureConnected(node.connectionId);- const sql = dropTablePreviewSql.value || (await buildDropTableSql(dropTableSqlOptions()));+ const sql = dropTablePreviewSql.value || (await buildDropTableSql(tableAdminSqlOptionsForNode(node, { cascade: dropTableCascade.value && supportsDropTableCascade(databaseTypeForNode(node)) })));await executeTreeNodeSqlWithProductionGuard(node, sql, { database: node.database, schema: node.schema });toast(t("contextMenu.dropTableSuccess", { name: node.label }), 3000);closeDroppedTableObjectTabsForNode(node);@@ -2796,13 +2806,13 @@ function emptyTable() {}async function confirmEmptyTable() {- const node = props.node;+ const node = sidebarDangerTarget.value ?? props.node;if (!node.connectionId || !node.database) return;try {await connectionStore.ensureConnected(node.connectionId);- const sql = emptyTablePreviewSql.value || (await buildEmptyTableSql(tableAdminSqlOptions()));+ const sql = emptyTablePreviewSql.value || (await buildEmptyTableSql(tableAdminSqlOptionsForNode(node)));await executeTreeNodeSqlWithProductionGuard(node, sql, { database: node.database, schema: node.schema });- const messageKey = currentDatabaseType() === "clickhouse" ? "contextMenu.emptyTableSubmitted" : "contextMenu.emptyTableSuccess";+ const messageKey = databaseTypeForNode(node) === "clickhouse" ? "contextMenu.emptyTableSubmitted" : "contextMenu.emptyTableSuccess";toast(t(messageKey, { name: node.label }), 3000);await refreshMutatedTableDataTabsForNode(node);} catch (e: any) {@@ -2817,11 +2827,11 @@ function truncateTable() {}async function confirmTruncateTable() {- const node = props.node;+ const node = sidebarDangerTarget.value ?? props.node;if (!node.connectionId || !node.database) return;try {await connectionStore.ensureConnected(node.connectionId);- const sql = truncateTablePreviewSql.value || (await buildTruncateTableSql(truncateTableSqlOptions()));+ const sql = truncateTablePreviewSql.value || (await buildTruncateTableSql(tableAdminSqlOptionsForNode(node, { cascade: truncateTableCascade.value && supportsTruncateTableCascade(databaseTypeForNode(node)) })));await executeTreeNodeSqlWithProductionGuard(node, sql, { database: node.database, schema: node.schema });toast(t("contextMenu.truncateTableSuccess", { name: node.label }), 3000);await refreshMutatedTableDataTabsForNode(node);@@ -2949,15 +2959,23 @@ async function openEditDatabasePropertiesDialog() {}async function confirmEditDatabaseProperties() {- const node = props.node;- if (!canEditDatabaseProperties.value || !node.connectionId || editDatabasePropertiesLoading.value) return;+ const node = sidebarFormTarget.value ?? props.node;+ const config = node.connectionId ? connectionStore.getConfig(node.connectionId) : undefined;+ const propertyGroups = editableDatabasePropertyGroups(config, node);+ if (!propertyGroups.length || !node.connectionId || editDatabasePropertiesLoading.value) return;editDatabasePropertiesLoading.value = true;try {await connectionStore.ensureConnected(node.connectionId);- const options = databasePropertyEditOptions();+ const base = {+ databaseType: databaseTypeForNode(node),+ driverProfile: config?.driver_profile,+ target: "database" as const,+ name: node.database || node.label,+ };+ const options = propertyGroups.includes("charsetCollation") ? { ...base, charset: editDatabaseCharset.value, collation: editDatabaseCollation.value } : propertyGroups.includes("databaseComment") ? { ...base, comment: editDatabaseCommentText.value } : null;if (!options) return;const sql = await buildUpdateDatabasePropertiesSql(options);- await executeTreeNodeSqlWithProductionGuard(node, sql, { database: databasePropertyName() });+ await executeTreeNodeSqlWithProductionGuard(node, sql, { database: node.database || node.label });toast(t("contextMenu.editDatabasePropertiesSuccess", { name: node.label }), 3000);showEditDatabasePropertiesDialog.value = false;await connectionStore.loadDatabases(node.connectionId, { force: true });@@ -2972,8 +2990,6 @@ watch([editDatabaseCharset, editDatabaseCollation, editDatabaseCommentText], ()if (showEditDatabasePropertiesDialog.value) void refreshEditDatabasePropertiesPreviewSql();});-const schemaCommentPreviewSql = ref("");-async function refreshSchemaCommentPreviewSql() {if (!canEditSchemaComment.value) {schemaCommentPreviewSql.value = "";@@ -3019,13 +3035,13 @@ async function openEditSchemaCommentDialog() {}async function confirmEditSchemaComment() {- const node = props.node;+ const node = sidebarFormTarget.value ?? props.node;if (!canEditSchemaComment.value || !node.connectionId || !node.database || schemaCommentLoading.value) return;schemaCommentLoading.value = true;try {await connectionStore.ensureConnected(node.connectionId);const sql = await buildUpdateDatabasePropertiesSql({- databaseType: currentDatabaseType(),+ databaseType: databaseTypeForNode(node),target: "schema",name: node.schema || node.label,comment: schemaCommentText.value,@@ -3129,7 +3145,7 @@ function openCreateNacosNamespaceDialog() {}async function confirmCreateNacosNamespace() {- const node = props.node;+ const node = sidebarFormTarget.value ?? props.node;const namespaceName = createNacosNamespaceName.value.trim();if (!node.connectionId || !namespaceName || createNacosNamespaceLoading.value) return;createNacosNamespaceLoading.value = true;@@ -3141,7 +3157,8 @@ async function confirmCreateNacosNamespace() {});showCreateNacosNamespaceDialog.value = false;await connectionStore.loadNacosNamespaces(node.connectionId, { force: true });- node.isExpanded = true;+ const liveNode = findSidebarActionTarget(connectionStore.treeNodes, node);+ if (liveNode) liveNode.isExpanded = true;toast(t("nacos.namespaceCreated", { name: namespaceName }), 3000);} catch (e: any) {toast(t("contextMenu.tableOperationFailed", { message: translateBackendError(t, e?.message || String(e)) }), 5000);@@ -3157,7 +3174,7 @@ function openEditNacosNamespaceDialog() {}async function confirmEditNacosNamespace() {- const node = props.node;+ const node = sidebarFormTarget.value ?? props.node;const namespaceId = node.nacosNamespace?.trim() || "";const namespaceName = editNacosNamespaceName.value.trim();if (!node.connectionId || !namespaceId || !namespaceName || editNacosNamespaceLoading.value) return;@@ -3225,7 +3242,7 @@ async function createDuckDbAttachedDatabaseFile() {}async function confirmCreateDatabase() {- const node = props.node;+ const node = sidebarFormTarget.value ?? props.node;const name = createDatabaseName.value.trim();if (!name || !node.connectionId) return;showCreateDatabaseDialog.value = false;@@ -3282,7 +3299,7 @@ function flushRedisDb() {}async function confirmFlushRedisDb() {- const node = props.node;+ const node = sidebarDangerTarget.value ?? props.node;if (node.type !== "redis-db" || !node.connectionId || !node.database) return;try {await connectionStore.ensureConnected(node.connectionId);@@ -3300,7 +3317,7 @@ async function confirmFlushRedisDb() {}async function confirmDropDatabase() {- const node = props.node;+ const node = sidebarDangerTarget.value ?? props.node;if (!node.connectionId || dropDatabaseLoading.value) return;dropDatabaseLoading.value = true;try {@@ -3315,7 +3332,7 @@ async function confirmDropDatabase() {const sql =dropDatabasePreviewSql.value ||(await buildDropDatabaseSql({- databaseType: currentDatabaseType(),+ databaseType: databaseTypeForNode(node),name: node.label,}));await executeTreeNodeSqlWithProductionGuard(node, sql, { database: "" });@@ -3330,7 +3347,7 @@ async function confirmDropDatabase() {}async function confirmDropMongoCollection() {- const node = props.node;+ const node = sidebarDangerTarget.value ?? props.node;if (node.type !== "mongo-collection" || !node.connectionId || !node.database || dropMongoCollectionLoading.value) return;dropMongoCollectionLoading.value = true;try {@@ -3359,7 +3376,7 @@ async function refreshMongoIndexTree(node: Pick<TreeNode, "connectionId" | "data}async function confirmDropMongoIndex() {- const node = props.node;+ const node = sidebarDangerTarget.value ?? props.node;if (!canDropMongoIndexNode(node) || !node.connectionId || !node.database || !node.tableName || dropMongoIndexLoading.value) return;dropMongoIndexLoading.value = true;try {@@ -3377,7 +3394,7 @@ async function confirmDropMongoIndex() {}async function confirmDropAllMongoIndexes() {- const node = props.node;+ const node = sidebarDangerTarget.value ?? props.node;if (node.type !== "mongo-collection" || !node.connectionId || !node.database || dropAllMongoIndexesLoading.value) return;dropAllMongoIndexesLoading.value = true;try {@@ -3399,7 +3416,7 @@ function openCreateSchemaDialog() {}async function confirmCreateSchema() {- const node = props.node;+ const node = sidebarFormTarget.value ?? props.node;const name = createSchemaName.value.trim();const config = node.connectionId ? connectionStore.getConfig(node.connectionId) : undefined;const isConnectionLevelSchemaCreation = node.type === "connection" && connectionNamespaceCreationTarget(config) === "schema";@@ -3432,14 +3449,14 @@ function dropSchema() {}async function confirmDropSchema() {- const node = props.node;+ const node = sidebarDangerTarget.value ?? props.node;if (!node.connectionId || !node.database) return;try {await connectionStore.ensureConnected(node.connectionId);const sql =dropSchemaPreviewSql.value ||(await buildDropSchemaSql({- databaseType: currentDatabaseType(),+ databaseType: databaseTypeForNode(node),name: node.label,}));await executeTreeNodeSqlWithProductionGuard(node, sql, { database: node.database });@@ -4195,7 +4212,7 @@ const canOpenStructureEditor = computed(() => {const canOpenFieldLineage = computed(() => {return props.node.type === "column" && !!props.node.database && !!props.node.tableName && supportsFieldLineage(currentDatabaseType());});-const isPinned = computed(() => props.node.pinned || connectionStore.isTreeNodePinned(props.node.id));+const isPinned = computed(() => props.node.pinned || connectionStore.isTreeNodePinned(props.node));const isNodeDefaultDatabase = computed(() => (props.node.type === "database" || props.node.type === "redis-db" || props.node.type === "mongo-db") && !!props.node.connectionId && !!props.node.database && connectionStore.isDefaultDatabase(props.node.connectionId, props.node.database));const hasTypeMenu = computed(() => {const t = props.node.type;@@ -4221,7 +4238,7 @@ const isConnecting = computed(() => props.node.type === "connection" && !!props.const isConnectionReadonly = computed(() => props.node.type === "connection" && !!props.node.connectionId && (connectionStore.getConfig(props.node.connectionId)?.read_only ?? false));const isOpenedDatabase = computed(() => isSidebarDatabaseOpened(props.node, connectionStore.isTreeNodeChildrenLoaded));const showsDatabaseOpenIndicator = computed(() => props.node.type === "database" && (isOpenedDatabase.value || (!!props.node.connectionId && props.node.database != null && queryStore.openDatabaseKeys.has(`${props.node.connectionId}\x00${props.node.database}`))));-const canCloseDatabaseConnection = computed(() => canCloseSidebarDatabaseConnection(props.node, connectionStore.isTreeNodeChildrenLoaded));+const canCloseDatabaseConnection = computed(() => canCloseSidebarDatabaseConnection(props.node, connectionStore.isTreeNodeChildrenLoaded, (connectionId, database) => queryStore.openDatabaseKeys.has(`${connectionId}\x00${database}`)));const nodeIconClass = computed(() => {const infoClass = getIconInfo(props.node)?.colorClass;if (props.node.type !== "database") return infoClass;@@ -4288,7 +4305,7 @@ const tableSearchStyle = computed(() => {});function togglePin() {- connectionStore.toggleTreeNodePin(props.node.id);+ connectionStore.toggleTreeNodePin(props.node);}function updateTableSearchQuery(value: string | number) {@@ -4308,11 +4325,11 @@ function clearTableSearchQuery() {}function openVisibleDatabasesDialog() {- showVisibleDatabasesDialog.value = true;+ emit("open-visible-databases", props.node);}function openVisibleSchemasDialog() {- showVisibleSchemasDialog.value = true;+ emit("open-visible-schemas", props.node);}// --- Connection Group Management ---@@ -4377,21 +4394,267 @@ function newSubgroup() {}function confirmDeleteGroup() {- connectionStore.deleteConnectionGroup(props.node.id);+ const node = sidebarFormTarget.value ?? props.node;+ connectionStore.deleteConnectionGroup(node.id);showDeleteGroupConfirm.value = false;toast(t("connection.groupDeleted"), 2000);}-const showDeleteGroupConfirm = ref(false);-function moveToGroup(groupId: string | null) {if (props.node.connectionId) {connectionStore.moveConnectionToGroup(props.node.connectionId, groupId);}}-const showMoveToNewGroupDialog = ref(false);-const moveToNewGroupName = ref("");+const dangerDialogRoutes: Array<{ flag: { value: boolean }; createRequest: () => SidebarDangerDialogRequest }> = [];+let stopDangerDialogRouting: (() => void) | null = null;++function routeDangerDialog(flag: { value: boolean }, createRequest: () => SidebarDangerDialogRequest) {+ dangerDialogRoutes.push({ flag, createRequest });+}++function ensureDangerDialogRouting() {+ if (stopDangerDialogRouting) return;+ stopDangerDialogRouting = watch(+ dangerDialogRoutes.map((route) => route.flag),+ (openFlags) => {+ if (sidebarTreeDialogOwner.value !== treeItemDialogOwner) return;+ openFlags.forEach((open, index) => {+ if (!open) return;+ const route = dangerDialogRoutes[index];+ route.flag.value = false;+ emit("open-danger-dialog", route.createRequest());+ });+ },+ );+}++function dangerRequest(request: Omit<SidebarDangerDialogRequest, "target">): SidebarDangerDialogRequest {+ const routedRequest = request as SidebarDangerDialogRequest;+ routedRequest.target = createSidebarActionTarget(props.node);+ sidebarDangerTarget.value = routedRequest.target;+ return routedRequest;+}++routeDangerDialog(showDropTableConfirm, () =>+ dangerRequest({+ title: t("contextMenu.confirmDropTableTitle"),+ message: t("contextMenu.confirmDropTableMessage", { name: props.node.label }),+ get sql() {+ return dropTablePreviewSql.value;+ },+ confirmLabel: t("contextMenu.dropTable"),+ option: canDropTableCascade.value+ ? {+ checked: dropTableCascade.value,+ label: t("contextMenu.dropTableCascade"),+ hint: t("contextMenu.dropTableCascadeHint"),+ async onChange(checked) {+ dropTableCascade.value = checked;+ await refreshDropTablePreviewSql();+ },+ }+ : undefined,+ confirm: confirmDropTable,+ }),+);++routeDangerDialog(showEmptyTableConfirm, () =>+ dangerRequest({+ title: t("contextMenu.confirmEmptyTableTitle"),+ message: t("contextMenu.confirmEmptyTableMessage", { name: props.node.label }),+ get sql() {+ return emptyTablePreviewSql.value;+ },+ confirmLabel: t("contextMenu.emptyTable"),+ confirm: confirmEmptyTable,+ }),+);++routeDangerDialog(showBatchEmptyConfirm, () =>+ dangerRequest({+ title: batchEmptyConfirmTitle(),+ message: batchEmptyConfirmMessage(),+ get sql() {+ return batchEmptyPreviewSql.value;+ },+ confirmLabel: batchEmptyConfirmLabel(),+ confirm: confirmBatchEmpty,+ }),+);++routeDangerDialog(showTruncateTableConfirm, () =>+ dangerRequest({+ title: t("contextMenu.confirmTruncateTableTitle"),+ message: t("contextMenu.confirmTruncateTableMessage", { name: props.node.label }),+ get sql() {+ return truncateTablePreviewSql.value;+ },+ confirmLabel: t("contextMenu.truncateTable"),+ option: canTruncateTableCascade.value+ ? {+ checked: truncateTableCascade.value,+ label: t("contextMenu.truncateTableCascade"),+ hint: t("contextMenu.truncateTableCascadeHint"),+ async onChange(checked) {+ truncateTableCascade.value = checked;+ await refreshTruncateTablePreviewSql();+ },+ }+ : undefined,+ confirm: confirmTruncateTable,+ }),+);++routeDangerDialog(showDropObjectConfirm, () =>+ dangerRequest({+ title: dropObjectConfirmTitle(),+ message: dropObjectConfirmMessage(),+ get sql() {+ return dropObjectPreviewSql.value;+ },+ confirmLabel: dropObjectMenuLabel(),+ confirm: confirmDropObject,+ }),+);++routeDangerDialog(showDropTableChildObjectConfirm, () =>+ dangerRequest({+ title: dropTableChildObjectConfirmTitle(),+ message: dropTableChildObjectConfirmMessage(),+ get sql() {+ return dropTableChildObjectPreviewSql.value;+ },+ confirmLabel: dropTableChildObjectMenuLabel(),+ confirm: confirmDropTableChildObject,+ }),+);++routeDangerDialog(showBatchDropConfirm, () =>+ dangerRequest({+ title: batchDropConfirmTitle(),+ message: batchDropConfirmMessage(),+ get sql() {+ return batchDropPreviewSql.value;+ },+ confirmLabel: batchDropMenuLabel(),+ option: canBatchDropCascade.value+ ? {+ checked: batchDropCascade.value,+ label: t("contextMenu.dropTableCascade"),+ hint: t("contextMenu.dropTableCascadeHint"),+ async onChange(checked) {+ batchDropCascade.value = checked;+ await refreshBatchDropPreviewSql();+ },+ }+ : undefined,+ confirm: confirmBatchDrop,+ }),+);++routeDangerDialog(showBatchTruncateConfirm, () =>+ dangerRequest({+ title: batchTruncateConfirmTitle(),+ message: batchTruncateConfirmMessage(),+ get sql() {+ return batchTruncatePreviewSql.value;+ },+ confirmLabel: batchTruncateMenuLabel(),+ option: canBatchTruncateCascade.value+ ? {+ checked: batchTruncateCascade.value,+ label: t("contextMenu.truncateTableCascade"),+ hint: t("contextMenu.truncateTableCascadeHint"),+ async onChange(checked) {+ batchTruncateCascade.value = checked;+ await refreshBatchTruncatePreviewSql();+ },+ }+ : undefined,+ confirm: confirmBatchTruncate,+ }),+);++routeDangerDialog(showDropDatabaseConfirm, () =>+ dangerRequest({+ title: t("contextMenu.confirmDropDatabaseTitle"),+ message: t("contextMenu.confirmDropDatabaseMessage", { name: props.node.label }),+ get sql() {+ return dropDatabasePreviewSql.value;+ },+ confirmLabel: t("contextMenu.dropDatabase"),+ get loading() {+ return dropDatabaseLoading.value;+ },+ closeOnConfirm: false,+ confirm: confirmDropDatabase,+ }),+);++routeDangerDialog(showDropMongoCollectionConfirm, () =>+ dangerRequest({+ title: t("contextMenu.confirmDropCollectionTitle"),+ message: t("contextMenu.confirmDropCollectionMessage", { name: props.node.label }),+ confirmLabel: t("contextMenu.dropCollection"),+ get loading() {+ return dropMongoCollectionLoading.value;+ },+ closeOnConfirm: false,+ confirm: confirmDropMongoCollection,+ }),+);++routeDangerDialog(showDropMongoIndexConfirm, () =>+ dangerRequest({+ title: t("contextMenu.confirmDropIndexTitle"),+ message: t("contextMenu.confirmDropMongoIndexMessage", { name: mongoIndexNameForNode(props.node), collection: props.node.tableName || "" }),+ details: mongoIndexDropPreview(props.node, mongoIndexNameForNode(props.node)),+ confirmLabel: t("contextMenu.dropIndex"),+ get loading() {+ return dropMongoIndexLoading.value;+ },+ closeOnConfirm: false,+ confirm: confirmDropMongoIndex,+ }),+);++routeDangerDialog(showDropAllMongoIndexesConfirm, () =>+ dangerRequest({+ title: t("contextMenu.dropAllIndexes"),+ message: t("contextMenu.confirmDropMongoAllIndexesMessage", { name: props.node.label }),+ detailsText: t("contextMenu.confirmDropMongoAllIndexesDetails"),+ sql: mongoDropAllIndexesPreview(props.node),+ confirmLabel: t("contextMenu.dropAllIndexes"),+ get loading() {+ return dropAllMongoIndexesLoading.value;+ },+ closeOnConfirm: false,+ confirm: confirmDropAllMongoIndexes,+ }),+);++routeDangerDialog(showFlushRedisDbConfirm, () =>+ dangerRequest({+ title: t("redis.flushDb"),+ message: t("redis.flushDbMessage"),+ details: t("redis.flushDbDetails", { db: props.node.database }),+ confirmLabel: t("redis.flushDbConfirm"),+ confirm: confirmFlushRedisDb,+ }),+);++routeDangerDialog(showDropSchemaConfirm, () =>+ dangerRequest({+ title: t("contextMenu.confirmDropSchemaTitle"),+ message: t("contextMenu.confirmDropSchemaMessage", { name: props.node.label }),+ get sql() {+ return dropSchemaPreviewSql.value;+ },+ confirmLabel: t("contextMenu.dropSchema"),+ confirm: confirmDropSchema,+ }),+);function moveToNewGroup() {moveToNewGroupName.value = "";@@ -4400,13 +4663,101 @@ function moveToNewGroup() {function confirmMoveToNewGroup() {const name = moveToNewGroupName.value.trim();- if (name && props.node.connectionId) {+ const node = sidebarFormTarget.value ?? props.node;+ if (name && node.connectionId) {const groupId = connectionStore.createConnectionGroup(name);- connectionStore.moveConnectionToGroup(props.node.connectionId, groupId);+ connectionStore.moveConnectionToGroup(node.connectionId, groupId);}showMoveToNewGroupDialog.value = false;}+let treeItemDialogController: Record<string, any> | null = null;++function getTreeItemDialogController(): Record<string, any> {+ if (treeItemDialogController) return treeItemDialogController;+ treeItemDialogController = reactive<Record<string, any>>({+ node: createSidebarActionTarget(props.node),+ t,+ highlight,+ showDeleteConfirm,+ connectionDeleteConfirmMessage,+ confirmDelete,+ connectionDeleteMenuLabel,+ showMoveToNewGroupDialog,+ moveToNewGroupName,+ confirmMoveToNewGroup,+ showDeleteGroupConfirm,+ confirmDeleteGroup,+ showRenameObjectDialog,+ renameObjectName,+ renameObjectPreviewSql,+ renameObjectError,+ confirmRenameObject,+ showStructurePreviewDialog,+ structurePreviewTitle,+ isLoadingStructurePreview,+ structurePreviewError,+ structurePreviewSql,+ copyStructurePreview,+ saveStructurePreview,+ showStructureDocCopyDialog,+ structureDocCopyTitle,+ structureDocCopyText,+ selectTextareaContent,+ copyStructureDocText,+ showDuplicateDialog,+ duplicateTableName,+ confirmDuplicateStructure,+ showPasteDialog,+ pasteTableEntries,+ pasteTableMode,+ pasteTableDataCopySupported: pasteTableDataCopySupported.value,+ confirmPasteTable,+ showCreateDatabaseDialog,+ createDatabaseName,+ canSetCreateDatabaseCharset: canSetCreateDatabaseCharset.value,+ createDatabaseCharset,+ createDatabaseCharsetOptions,+ createDatabaseCharsetLoading,+ normalizeCreateDatabaseCharset,+ createDatabaseCollation,+ createDatabaseCollationOptionsForCharset,+ createDatabaseCollationsByCharset,+ confirmCreateDatabase,+ showEditDatabasePropertiesDialog,+ updateCreateDatabaseCharset,+ canEditDatabaseCharsetCollation: canEditDatabaseCharsetCollation.value,+ updateEditDatabaseCharset,+ editDatabasePropertiesLoading,+ editDatabaseCharset,+ editDatabaseCollation,+ canEditDatabaseComment: canEditDatabaseComment.value,+ editDatabaseCommentText,+ editDatabasePropertiesPreviewSql,+ confirmEditDatabaseProperties,+ showCreateNacosNamespaceDialog,+ createNacosNamespaceId,+ createNacosNamespaceName,+ createNacosNamespaceDesc,+ createNacosNamespaceLoading,+ confirmCreateNacosNamespace,+ showEditNacosNamespaceDialog,+ editNacosNamespaceName,+ editNacosNamespaceDesc,+ editNacosNamespaceLoading,+ confirmEditNacosNamespace,+ showCreateSchemaDialog,+ createSchemaName,+ confirmCreateSchema,+ showEditSchemaCommentDialog,+ schemaCommentText,+ schemaCommentLoading,+ schemaCommentPreviewSql,+ confirmEditSchemaComment,+ });+ return treeItemDialogController;+}+const availableGroups = computed(() => connectionStore.sidebarLayout.groups);const currentGroupId = computed(() => {@@ -4592,6 +4943,7 @@ onBeforeUnmount(() => {handleMouseLeave();stopPasteHandlerRegistration();finishTableReferenceDrag();+ stopDangerDialogRouting?.();});const shortcutCopyName = computed(() => settingsStore.editorSettings.shortcuts.copySidebarSelection);@@ -5040,14 +5392,11 @@ function treeItemMenuItems(): ContextMenuItem[] {const destructiveActions: ContextMenuItem[] = [];items.push({ label: t("contextMenu.copyName"), action: copyName, icon: Copy, shortcut: shortcutCopyName.value });items.push({ label: "", separator: true });- items.push({ label: t("contextMenu.viewData"), action: openData, icon: TableProperties });+ items.push({ label: t("contextMenu.viewData"), action: openDataImmediately, icon: TableProperties });if (node.type === "table") {items.push({label: t("contextMenu.viewDdl"),- action: () => {- ddlTarget.value = node;- showDdlDialog.value = true;- },+ action: () => emit("open-ddl", node),icon: FileCode,});}@@ -5056,10 +5405,7 @@ function treeItemMenuItems(): ContextMenuItem[] {items.push({ label: t("contextMenu.viewSource"), action: () => openObjectSourceDialog(false), icon: Code2 });items.push({label: t("contextMenu.viewDdl"),- action: () => {- ddlTarget.value = node;- showDdlDialog.value = true;- },+ action: () => emit("open-ddl", node),icon: FileCode,});}@@ -5333,668 +5679,122 @@ function treeItemMenuItems(): ContextMenuItem[] {</div></div>- <CustomContextMenu v-else :items="treeItemMenuItems" v-slot="contextMenuSlot">- <div @contextmenu="onTreeItemContextMenu($event, contextMenuSlot.onContextMenu)">- <LightTooltip :text="displayLabel(node)" :disabled="isTooltipDisabled()" side="right" :side-offset="8" :delay="0" :close-delay="0" :surface="detailTooltip ? 'popover' : 'foreground'">- <div- ref="rowRef"- class="group flex items-center gap-1.5 py-1 px-2 cursor-pointer relative outline-none"- style="contain: layout style"- :class="[- rowWidthClass,- {- 'group/sidebar-row': true,- 'ring-1 ring-primary/50 bg-primary/5': showDropInside,- 'opacity-50': isDragging,- 'tree-item-connection-tint': connectionColor,- 'hover:bg-accent': node.type !== 'connection',- 'hover:bg-secondary/60': node.type === 'connection',- rounded: !isTreeRowSelected,- 'tree-item-active': isTreeRowSelected,- 'tree-item-active--selection-set': usesSelectionSetHighlight && isTreeRowSelected,- 'tree-item-highlight': highlighted,- },- ]"- :tabindex="isSelected || isMultiSelected ? 0 : -1"- :style="rowStyle"- @click="onClick"- @dblclick="onDoubleClick"- @keydown="onKeydown"- @mousedown="onRowMouseDown"- @mousemove="isDropTarget ? updateTarget($event, node.id, node.type) : undefined"- @mouseenter="handleMouseEnter"- @mouseleave="- clearTarget(node.id);- handleMouseLeave();- "- >- <div v-if="showDropBefore" class="absolute right-2 top-0 h-0.5 bg-primary rounded-full pointer-events-none" :style="{ left: paddingLeft }" />- <div v-if="showDropAfter" class="absolute right-2 bottom-0 h-0.5 bg-primary rounded-full pointer-events-none" :style="{ left: paddingLeft }" />- <template v-if="canExpand">- <button type="button" class="-m-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground" @mousedown.stop="onToggleMouseDown" @click.stop="onToggleClick">- <Loader2 v-if="node.isLoading" class="w-3.5 h-3.5 animate-spin" />- <ChevronDown v-else-if="node.isExpanded" class="w-3.5 h-3.5" />- <ChevronRight v-else class="w-3.5 h-3.5" />- </button>- </template>- <span v-else class="w-3.5 h-3.5 shrink-0" />- <DatabaseIcon v-if="node.type === 'connection'" :db-type="connectionIconType(node.connectionId)" class="h-3.5 w-3.5 shrink-0" />- <Loader2 v-else-if="node.type === 'load-more' && node.isLoading" class="w-3.5 h-3.5 shrink-0 animate-spin text-primary" />- <component v-else :is="getIconInfo(node)?.icon || Database" class="w-3.5 h-3.5 shrink-0" :class="nodeIconClass" />- <input- v-if="isRenamingGroup"- ref="renameInputRef"- v-model="renameInput"- class="min-w-0 flex-1 truncate bg-transparent border border-primary/50 rounded px-1 outline-none"- @blur="finishRenameGroup"- @keydown.enter.prevent="finishRenameGroup"- @keydown.escape.prevent="isRenamingGroup = false"- @click.stop- />- <span v-else ref="labelRef" :class="labelWidthClass">{{ visibleLabel(node) }}</span>- <ProductionContextBadge v-if="showProductionBadge" compact />- <span- v-if="- (node.type === 'group-tables' || node.type === 'group-views' || node.type === 'group-materialized-views' || node.type === 'group-procedures' || node.type === 'group-functions' || node.type === 'group-sequences' || node.type === 'group-packages' || node.type === 'group-partitions') &&- node.objectCount != null- "- class="text-muted-foreground text-[10px] shrink-0"- >{{ node.objectCount }}</span- >- <Badge v-if="isNodeDefaultDatabase" variant="secondary" class="h-4 px-1.5 text-[10px]">- {{ t("editor.defaultDatabase") }}- </Badge>- <span v-if="columnComment" class="sidebar-object-comment ml-auto max-w-[20%] shrink-0 truncate text-right" :class="{ 'sidebar-object-comment--windows': useWindowsSidebarCommentFont }">{{ columnComment }}</span>- <span v-if="tableComment" class="sidebar-object-comment ml-auto max-w-[20%] shrink-0 truncate text-right" :class="{ 'sidebar-object-comment--windows': useWindowsSidebarCommentFont }">{{ tableComment }}</span>- <span v-if="node.type === 'connection' && node.connectionId && connectionStore.connectedIds.has(node.connectionId)" class="w-1.5 h-1.5 rounded-full bg-green-500 shrink-0" />- <span v-if="showsDatabaseOpenIndicator" class="w-1.5 h-1.5 rounded-full bg-green-500 shrink-0" />- <Badge v-if="isConnectionReadonly" variant="secondary" class="h-4 px-1.5 text-[10px] gap-0.5"><Lock class="w-2.5 h-2.5" />{{ t("connection.readOnlyBadge") }}</Badge>- <ConnectionErrorIndicator v-if="node.type === 'connection'" :connection-id="node.connectionId" trigger-class="h-4 w-4" />- <Pin v-if="isPinned" class="w-3 h-3 shrink-0 text-primary fill-current" aria-hidden="true" />- <button- v-if="isConnecting"- type="button"- class="ml-auto flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-secondary/45 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"- :aria-label="t('connection.cancelConnecting')"- :title="t('connection.cancelConnecting')"- @mousedown.stop- @click.stop="cancelConnectionAttempt"- >- <X class="h-3 w-3" />- </button>- <button- v-if="node.type === 'connection'"- type="button"- class="flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground/55 opacity-0 transition-colors transition-opacity hover:bg-secondary/45 hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover/sidebar-row:opacity-100"- :class="[{ 'opacity-100': isConnectionSelectionChecked || connectionStore.connectionMultiSelectActive }, isConnecting ? '' : 'ml-auto']"- :aria-label="isConnectionSelectionChecked ? t('connectionGroup.deselectConnection') : t('connectionGroup.selectConnection')"- @mousedown.stop- @click="toggleConnectionMultiSelection"- >- <Check v-if="isConnectionSelectionChecked" class="h-3 w-3 text-primary" />- <Square v-else class="h-3 w-3 stroke-[1.7]" />+ <div v-else @contextmenu="onTreeItemContextMenu">+ <LightTooltip :text="displayLabel(node)" :disabled="isTooltipDisabled()" side="right" :side-offset="8" :delay="0" :close-delay="0" :surface="detailTooltip ? 'popover' : 'foreground'">+ <div+ ref="rowRef"+ class="group flex items-center gap-1.5 py-1 px-2 cursor-pointer relative outline-none"+ style="contain: layout style"+ :class="[+ rowWidthClass,+ {+ 'group/sidebar-row': true,+ 'ring-1 ring-primary/50 bg-primary/5': showDropInside,+ 'opacity-50': isDragging,+ 'tree-item-connection-tint': connectionColor,+ 'hover:bg-accent': node.type !== 'connection',+ 'hover:bg-secondary/60': node.type === 'connection',+ rounded: !isTreeRowSelected,+ 'tree-item-active': isTreeRowSelected,+ 'tree-item-active--selection-set': usesSelectionSetHighlight && isTreeRowSelected,+ 'tree-item-highlight': highlighted,+ },+ ]"+ :tabindex="isSelected || isMultiSelected ? 0 : -1"+ :style="rowStyle"+ @click="onClick"+ @dblclick="onDoubleClick"+ @keydown="onKeydown"+ @mousedown="onRowMouseDown"+ @mousemove="isDropTarget ? updateTarget($event, node.id, node.type) : undefined"+ @mouseenter="handleMouseEnter"+ @mouseleave="+ clearTarget(node.id);+ handleMouseLeave();+ "+ >+ <div v-if="showDropBefore" class="absolute right-2 top-0 h-0.5 bg-primary rounded-full pointer-events-none" :style="{ left: paddingLeft }" />+ <div v-if="showDropAfter" class="absolute right-2 bottom-0 h-0.5 bg-primary rounded-full pointer-events-none" :style="{ left: paddingLeft }" />+ <template v-if="canExpand">+ <button type="button" class="-m-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground" @mousedown.stop="onToggleMouseDown" @click.stop="onToggleClick">+ <Loader2 v-if="node.isLoading" class="w-3.5 h-3.5 animate-spin" />+ <ChevronDown v-else-if="node.isExpanded" class="w-3.5 h-3.5" />+ <ChevronRight v-else class="w-3.5 h-3.5" /></button>- </div>- <template v-if="detailTooltip" #content>- <div class="w-max min-w-40 max-w-[min(28rem,calc(100vw-24px))] rounded-md border border-border bg-popover p-2 text-popover-foreground shadow-lg">- <div class="space-y-1">- <div v-for="row in detailTooltip.rows" :key="row.label" class="grid grid-cols-[max-content_minmax(0,1fr)] gap-2 text-xs leading-5">- <span class="text-muted-foreground">{{ row.label }}</span>- <span v-if="row.multiline" class="max-h-20 overflow-hidden whitespace-pre-wrap break-words text-foreground/90">- {{ row.value }}- </span>- <span v-else class="truncate font-mono text-foreground/90" :title="row.value">{{ row.value }}</span>- </div>- </div>- </div></template>- </LightTooltip>- </div>- </CustomContextMenu>-- <VisibleDatabasesDialog v-if="node.type === 'connection' && node.connectionId" v-model:open="showVisibleDatabasesDialog" :connection-id="node.connectionId" :connection-name="node.label" />-- <SchemaFilterDialog v-if="node.type === 'database' && node.connectionId && node.database != null" v-model:open="showVisibleSchemasDialog" :connection-id="node.connectionId" :connection-name="node.label" :database="node.database ?? ''" />-- <SchemaFilterDialog v-else-if="node.type === 'connection' && node.connectionId && canConfigureVisibleSchemas" v-model:open="showVisibleSchemasDialog" :connection-id="node.connectionId" :connection-name="node.label" :database="connectionStore.getConfig(node.connectionId)?.database || ''" />-- <Dialog v-model:open="showDeleteConfirm">- <DialogContent class="sm:max-w-[400px]">- <DialogHeader>- <DialogTitle>{{ t("contextMenu.confirmDeleteTitle") }}</DialogTitle>- </DialogHeader>- <p class="text-sm text-muted-foreground">- {{ connectionDeleteConfirmMessage() }}- </p>- <DialogFooter>- <Button variant="outline" @click="showDeleteConfirm = false">{{ t("dangerDialog.cancel") }}</Button>- <Button- variant="destructive"- @click="- showDeleteConfirm = false;- confirmDelete();+ <span v-else class="w-3.5 h-3.5 shrink-0" />+ <DatabaseIcon v-if="node.type === 'connection'" :db-type="connectionIconType(node.connectionId)" class="h-3.5 w-3.5 shrink-0" />+ <Loader2 v-else-if="node.type === 'load-more' && node.isLoading" class="w-3.5 h-3.5 shrink-0 animate-spin text-primary" />+ <component v-else :is="getIconInfo(node)?.icon || Database" class="w-3.5 h-3.5 shrink-0" :class="nodeIconClass" />+ <input+ v-if="isRenamingGroup"+ ref="renameInputRef"+ v-model="renameInput"+ class="min-w-0 flex-1 truncate bg-transparent border border-primary/50 rounded px-1 outline-none"+ @blur="finishRenameGroup"+ @keydown.enter.prevent="finishRenameGroup"+ @keydown.escape.prevent="isRenamingGroup = false"+ @click.stop+ />+ <span v-else ref="labelRef" :class="labelWidthClass">{{ visibleLabel(node) }}</span>+ <ProductionContextBadge v-if="showProductionBadge" compact />+ <span+ v-if="+ (node.type === 'group-tables' || node.type === 'group-views' || node.type === 'group-materialized-views' || node.type === 'group-procedures' || node.type === 'group-functions' || node.type === 'group-sequences' || node.type === 'group-packages' || node.type === 'group-partitions') &&+ node.objectCount != null"- >{{ connectionDeleteMenuLabel() }}</Button+ class="text-muted-foreground text-[10px] shrink-0"+ >{{ node.objectCount }}</span>- </DialogFooter>- </DialogContent>- </Dialog>-- <Dialog v-model:open="showMoveToNewGroupDialog">- <DialogContent class="sm:max-w-[360px]">- <DialogHeader>- <DialogTitle>{{ t("connectionGroup.createGroup") }}</DialogTitle>- </DialogHeader>- <Input v-model="moveToNewGroupName" :placeholder="t('connectionGroup.groupNamePlaceholder')" @keydown.enter.prevent="confirmMoveToNewGroup" />- <DialogFooter>- <Button variant="outline" @click="showMoveToNewGroupDialog = false">{{ t("dangerDialog.cancel") }}</Button>- <Button :disabled="!moveToNewGroupName.trim()" @click="confirmMoveToNewGroup">{{ t("connectionGroup.createGroup") }}</Button>- </DialogFooter>- </DialogContent>- </Dialog>-- <Dialog v-model:open="showDeleteGroupConfirm">- <DialogContent class="sm:max-w-[400px]">- <DialogHeader>- <DialogTitle>{{ t("connectionGroup.deleteGroupConfirmTitle") }}</DialogTitle>- </DialogHeader>- <p class="text-sm text-muted-foreground">- {{ t("connectionGroup.deleteGroupConfirmMessage", { name: node.label }) }}- </p>- <DialogFooter>- <Button variant="outline" @click="showDeleteGroupConfirm = false">{{ t("dangerDialog.cancel") }}</Button>- <Button variant="destructive" @click="confirmDeleteGroup">{{ t("connectionGroup.deleteGroup") }}</Button>- </DialogFooter>- </DialogContent>- </Dialog>-- <Dialog v-model:open="showRenameObjectDialog">- <DialogContent class="sm:max-w-[420px]">- <DialogHeader>- <DialogTitle>{{ t("contextMenu.renameObjectTitle") }}</DialogTitle>- </DialogHeader>- <div class="grid gap-3">- <Input v-model="renameObjectName" :placeholder="t('contextMenu.renameObjectNamePlaceholder')" @keydown.enter.prevent="confirmRenameObject" />- <pre v-if="renameObjectPreviewSql" class="max-h-32 overflow-auto rounded bg-muted p-3 text-xs whitespace-pre-wrap" v-html="highlight(renameObjectPreviewSql)"></pre>- <p v-if="renameObjectError" class="text-sm text-destructive">{{ renameObjectError }}</p>- </div>- <DialogFooter>- <Button variant="outline" @click="showRenameObjectDialog = false">{{ t("dangerDialog.cancel") }}</Button>- <Button :disabled="!renameObjectName.trim() || renameObjectName.trim() === node.label" @click="confirmRenameObject">- {{ t("contextMenu.renameObject") }}- </Button>- </DialogFooter>- </DialogContent>- </Dialog>-- <Dialog v-model:open="showStructurePreviewDialog">- <DialogContent class="sm:max-w-[760px]">- <DialogHeader>- <DialogTitle>{{ structurePreviewTitle || t("contextMenu.exportStructure") }}</DialogTitle>- </DialogHeader>- <div class="grid gap-3">- <div v-if="isLoadingStructurePreview" class="flex items-center gap-2 text-sm text-muted-foreground">- <Loader2 class="h-4 w-4 animate-spin" />- <span>{{ t("contextMenu.exportStructureLoading") }}</span>- </div>- <p v-else-if="structurePreviewError" class="text-sm text-destructive">{{ structurePreviewError }}</p>- <pre v-else class="max-h-[56vh] min-h-64 overflow-auto rounded bg-muted p-3 text-xs whitespace-pre-wrap" v-html="highlight(structurePreviewSql)"></pre>- </div>- <DialogFooter>- <Button variant="outline" @click="showStructurePreviewDialog = false">{{ t("dangerDialog.cancel") }}</Button>- <Button variant="outline" :disabled="isLoadingStructurePreview || !structurePreviewSql" @click="copyStructurePreview">- <Clipboard class="h-4 w-4" />- {{ t("contextMenu.copyStructure") }}- </Button>- <Button :disabled="isLoadingStructurePreview || !structurePreviewSql" @click="saveStructurePreview">- <Upload class="h-4 w-4" />- {{ t("contextMenu.saveStructure") }}- </Button>- </DialogFooter>- </DialogContent>- </Dialog>-- <Dialog v-model:open="showStructureDocCopyDialog">- <DialogContent class="sm:max-w-[760px]">- <DialogHeader>- <DialogTitle>{{ structureDocCopyTitle || t("contextMenu.copyStructureAs") }}</DialogTitle>- </DialogHeader>- <div class="grid gap-3">- <p class="text-sm text-muted-foreground">{{ t("contextMenu.structureDocCopyFallbackHint") }}</p>- <textarea readonly class="max-h-[56vh] min-h-64 resize-y overflow-auto rounded bg-muted p-3 font-mono text-xs whitespace-pre" :value="structureDocCopyText" @focus="selectTextareaContent"></textarea>- </div>- <DialogFooter>- <Button variant="outline" @click="showStructureDocCopyDialog = false">{{ t("dangerDialog.cancel") }}</Button>- <Button :disabled="!structureDocCopyText" @click="copyStructureDocText">- <Clipboard class="h-4 w-4" />- {{ t("contextMenu.copyStructure") }}- </Button>- </DialogFooter>- </DialogContent>- </Dialog>-- <DangerConfirmDialog v-model:open="showDropTableConfirm" :title="t('contextMenu.confirmDropTableTitle')" :message="t('contextMenu.confirmDropTableMessage', { name: node.label })" :sql="dropTablePreviewSql" :confirm-label="t('contextMenu.dropTable')" @confirm="confirmDropTable">- <template v-if="canDropTableCascade" #options>- <label class="mb-3 flex items-start gap-2 rounded-md border bg-muted/20 px-3 py-2 text-sm">- <input v-model="dropTableCascade" type="checkbox" class="mt-0.5 h-3.5 w-3.5 shrink-0 accent-primary" @change="refreshDropTablePreviewSql()" />- <span class="grid gap-0.5">- <span class="font-medium text-foreground">{{ t("contextMenu.dropTableCascade") }}</span>- <span class="text-xs leading-5 text-muted-foreground">{{ t("contextMenu.dropTableCascadeHint") }}</span>- </span>- </label>- </template>- </DangerConfirmDialog>-- <DangerConfirmDialog v-model:open="showEmptyTableConfirm" :title="t('contextMenu.confirmEmptyTableTitle')" :message="t('contextMenu.confirmEmptyTableMessage', { name: node.label })" :sql="emptyTablePreviewSql" :confirm-label="t('contextMenu.emptyTable')" @confirm="confirmEmptyTable" />-- <DangerConfirmDialog v-model:open="showBatchEmptyConfirm" :title="batchEmptyConfirmTitle()" :message="batchEmptyConfirmMessage()" :sql="batchEmptyPreviewSql" :confirm-label="batchEmptyConfirmLabel()" @confirm="confirmBatchEmpty" />-- <DangerConfirmDialog- v-model:open="showTruncateTableConfirm"- :title="t('contextMenu.confirmTruncateTableTitle')"- :message="t('contextMenu.confirmTruncateTableMessage', { name: node.label })"- :sql="truncateTablePreviewSql"- :confirm-label="t('contextMenu.truncateTable')"- @confirm="confirmTruncateTable"- >- <template v-if="canTruncateTableCascade" #options>- <label class="mb-3 flex items-start gap-2 rounded-md border bg-muted/20 px-3 py-2 text-sm">- <input v-model="truncateTableCascade" type="checkbox" class="mt-0.5 h-3.5 w-3.5 shrink-0 accent-primary" @change="refreshTruncateTablePreviewSql()" />- <span class="grid gap-0.5">- <span class="font-medium text-foreground">{{ t("contextMenu.truncateTableCascade") }}</span>- <span class="text-xs leading-5 text-muted-foreground">{{ t("contextMenu.truncateTableCascadeHint") }}</span>- </span>- </label>- </template>- </DangerConfirmDialog>-- <DangerConfirmDialog v-model:open="showDropObjectConfirm" :title="dropObjectConfirmTitle()" :message="dropObjectConfirmMessage()" :sql="dropObjectPreviewSql" :confirm-label="dropObjectMenuLabel()" @confirm="confirmDropObject" />-- <DangerConfirmDialog v-model:open="showDropTableChildObjectConfirm" :title="dropTableChildObjectConfirmTitle()" :message="dropTableChildObjectConfirmMessage()" :sql="dropTableChildObjectPreviewSql" :confirm-label="dropTableChildObjectMenuLabel()" @confirm="confirmDropTableChildObject" />-- <DangerConfirmDialog v-model:open="showBatchDropConfirm" :title="batchDropConfirmTitle()" :message="batchDropConfirmMessage()" :sql="batchDropPreviewSql" :confirm-label="batchDropMenuLabel()" @confirm="confirmBatchDrop">- <template v-if="canBatchDropCascade" #options>- <label class="mb-3 flex items-start gap-2 rounded-md border bg-muted/20 px-3 py-2 text-sm">- <input v-model="batchDropCascade" type="checkbox" class="mt-0.5 h-3.5 w-3.5 shrink-0 accent-primary" @change="refreshBatchDropPreviewSql()" />- <span class="grid gap-0.5">- <span class="font-medium text-foreground">{{ t("contextMenu.dropTableCascade") }}</span>- <span class="text-xs leading-5 text-muted-foreground">{{ t("contextMenu.dropTableCascadeHint") }}</span>- </span>- </label>- </template>- </DangerConfirmDialog>-- <DangerConfirmDialog v-model:open="showBatchTruncateConfirm" :title="batchTruncateConfirmTitle()" :message="batchTruncateConfirmMessage()" :sql="batchTruncatePreviewSql" :confirm-label="batchTruncateMenuLabel()" @confirm="confirmBatchTruncate">- <template v-if="canBatchTruncateCascade" #options>- <label class="mb-3 flex items-start gap-2 rounded-md border bg-muted/20 px-3 py-2 text-sm">- <input v-model="batchTruncateCascade" type="checkbox" class="mt-0.5 h-3.5 w-3.5 shrink-0 accent-primary" @change="refreshBatchTruncatePreviewSql()" />- <span class="grid gap-0.5">- <span class="font-medium text-foreground">{{ t("contextMenu.truncateTableCascade") }}</span>- <span class="text-xs leading-5 text-muted-foreground">{{ t("contextMenu.truncateTableCascadeHint") }}</span>- </span>- </label>- </template>- </DangerConfirmDialog>-- <ProcedureExecutionDialog- v-if="node.type === 'procedure' && node.connectionId && node.database"- v-model:open="showProcedureExecutionConfirm"- :connection-id="node.connectionId"- :database="node.database"- :database-type="currentDatabaseType()"- :schema="node.schema"- :routine-name="node.label"- @open-sql="openProcedureExecutionSql"- @execute="executeProcedureSql"- />-- <Dialog v-model:open="showDuplicateDialog">- <DialogContent class="sm:max-w-[400px]">- <DialogHeader>- <DialogTitle>{{ t("contextMenu.duplicateNameTitle") }}</DialogTitle>- </DialogHeader>- <Input v-model="duplicateTableName" :placeholder="t('contextMenu.duplicateNamePlaceholder')" @keydown.enter.prevent="confirmDuplicateStructure" />- <DialogFooter>- <Button variant="outline" @click="showDuplicateDialog = false">{{ t("dangerDialog.cancel") }}</Button>- <Button :disabled="!duplicateTableName.trim()" @click="confirmDuplicateStructure">{{ t("dangerDialog.confirm") }}</Button>- </DialogFooter>- </DialogContent>- </Dialog>-- <Dialog v-model:open="showPasteDialog">- <DialogContent class="sm:max-w-[500px]">- <DialogHeader>- <DialogTitle>{{ pasteTableEntries.length > 1 ? t("contextMenu.batchPasteTitle") : t("contextMenu.pasteTableConfirmTitle") }}</DialogTitle>- </DialogHeader>- <div class="space-y-4">- <div class="flex gap-2">- <label class="flex items-center gap-1.5 text-sm cursor-pointer" :class="{ 'opacity-50 cursor-not-allowed': !pasteTableDataCopySupported }">- <input v-model="pasteTableMode" type="radio" value="structure-and-data" class="accent-primary" :disabled="!pasteTableDataCopySupported" />- {{ t("contextMenu.pasteOptionStructureAndData") }}- </label>- <label class="flex items-center gap-1.5 text-sm cursor-pointer">- <input v-model="pasteTableMode" type="radio" value="structure-only" class="accent-primary" />- {{ t("contextMenu.pasteOptionStructureOnly") }}- </label>- <label class="flex items-center gap-1.5 text-sm cursor-pointer" :class="{ 'opacity-50 cursor-not-allowed': !pasteTableDataCopySupported }">- <input v-model="pasteTableMode" type="radio" value="data-only" class="accent-primary" :disabled="!pasteTableDataCopySupported" />- {{ t("contextMenu.pasteOptionDataOnly") }}- </label>- </div>- <div class="space-y-2 max-h-64 overflow-y-auto">- <div v-for="(entry, idx) in pasteTableEntries" :key="idx" class="flex items-center gap-2">- <span class="text-sm text-muted-foreground truncate min-w-0 flex-shrink basis-1/3" :title="entry.sourceName">{{ entry.sourceName }}</span>- <span class="text-xs text-muted-foreground flex-shrink-0">→</span>- <Input v-model="entry.targetName" class="flex-1 h-8 text-sm" :placeholder="t('contextMenu.duplicateNamePlaceholder')" />- </div>- </div>- </div>- <DialogFooter>- <Button variant="outline" @click="showPasteDialog = false">{{ t("dangerDialog.cancel") }}</Button>- <Button :disabled="pasteTableEntries.every((e) => !e.targetName.trim())" @click="confirmPasteTable">{{ t("dangerDialog.confirm") }}</Button>- </DialogFooter>- </DialogContent>- </Dialog>-- <Dialog v-model:open="showCreateDatabaseDialog">- <DialogContent class="sm:max-w-[400px]">- <DialogHeader>- <DialogTitle>{{ t("contextMenu.createDatabase") }}</DialogTitle>- </DialogHeader>- <Input v-model="createDatabaseName" :placeholder="t('contextMenu.createDatabaseNamePlaceholder')" @keydown.enter.prevent="confirmCreateDatabase" />- <div v-if="canSetCreateDatabaseCharset" class="grid gap-2">- <div class="grid gap-1.5">- <label class="text-xs font-medium text-muted-foreground">{{ t("contextMenu.createDatabaseCharset") }}</label>- <SearchableSelect- :model-value="createDatabaseCharset"- :options="createDatabaseCharsetOptions"- :placeholder="t('contextMenu.createDatabaseCharsetPlaceholder')"- :search-placeholder="t('contextMenu.createDatabaseCharsetSearchPlaceholder')"- :empty-text="t('contextMenu.createDatabaseCharsetEmpty')"- :loading-text="t('contextMenu.createDatabaseCharsetLoading')"- :loading="createDatabaseCharsetLoading"- :normalize-custom="normalizeCreateDatabaseCharset"- allow-custom- trigger-variant="outline"- trigger-class="h-9 w-full max-w-none justify-between border bg-background px-3 text-sm shadow-xs hover:bg-accent"- content-class="w-[var(--reka-popover-trigger-width)]"- @update:model-value="updateCreateDatabaseCharset"- >- <template #custom-option-label="{ value }">- <span class="truncate">{{ t("contextMenu.createDatabaseCharsetCustomOption", { value }) }}</span>- </template>- </SearchableSelect>- </div>- <div class="grid gap-1.5">- <label class="text-xs font-medium text-muted-foreground">{{ t("contextMenu.createDatabaseCollation") }}</label>- <SearchableSelect- v-model="createDatabaseCollation"- :options="createDatabaseCollationOptionsForCharset(createDatabaseCharset, createDatabaseCollationsByCharset)"- :placeholder="t('contextMenu.createDatabaseCollationPlaceholder')"- :search-placeholder="t('contextMenu.createDatabaseCollationSearchPlaceholder')"- :empty-text="t('contextMenu.createDatabaseCollationEmpty')"- :loading-text="t('contextMenu.createDatabaseCollationLoading')"- :loading="createDatabaseCharsetLoading"- :normalize-custom="normalizeCreateDatabaseCharset"- allow-custom- trigger-variant="outline"- trigger-class="h-9 w-full max-w-none justify-between border bg-background px-3 text-sm shadow-xs hover:bg-accent"- content-class="w-[var(--reka-popover-trigger-width)]"- >- <template #custom-option-label="{ value }">- <span class="truncate">{{ t("contextMenu.createDatabaseCollationCustomOption", { value }) }}</span>- </template>- </SearchableSelect>- </div>+ <Badge v-if="isNodeDefaultDatabase" variant="secondary" class="h-4 px-1.5 text-[10px]">+ {{ t("editor.defaultDatabase") }}+ </Badge>+ <span v-if="columnComment" class="sidebar-object-comment ml-auto max-w-[20%] shrink-0 truncate text-right" :class="{ 'sidebar-object-comment--windows': useWindowsSidebarCommentFont }">{{ columnComment }}</span>+ <span v-if="tableComment" class="sidebar-object-comment ml-auto max-w-[20%] shrink-0 truncate text-right" :class="{ 'sidebar-object-comment--windows': useWindowsSidebarCommentFont }">{{ tableComment }}</span>+ <span v-if="node.type === 'connection' && node.connectionId && connectionStore.connectedIds.has(node.connectionId)" class="w-1.5 h-1.5 rounded-full bg-green-500 shrink-0" />+ <span v-if="showsDatabaseOpenIndicator" class="w-1.5 h-1.5 rounded-full bg-green-500 shrink-0" />+ <Badge v-if="isConnectionReadonly" variant="secondary" class="h-4 px-1.5 text-[10px] gap-0.5"><Lock class="w-2.5 h-2.5" />{{ t("connection.readOnlyBadge") }}</Badge>+ <ConnectionErrorIndicator v-if="node.type === 'connection'" :connection-id="node.connectionId" trigger-class="h-4 w-4" />+ <Pin v-if="isPinned" class="w-3 h-3 shrink-0 text-primary fill-current" aria-hidden="true" />+ <button+ v-if="isConnecting"+ type="button"+ class="ml-auto flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-secondary/45 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"+ :aria-label="t('connection.cancelConnecting')"+ :title="t('connection.cancelConnecting')"+ @mousedown.stop+ @click.stop="cancelConnectionAttempt"+ >+ <X class="h-3 w-3" />+ </button>+ <button+ v-if="node.type === 'connection'"+ type="button"+ class="flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground/55 opacity-0 transition-colors transition-opacity hover:bg-secondary/45 hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover/sidebar-row:opacity-100"+ :class="[{ 'opacity-100': isConnectionSelectionChecked || connectionStore.connectionMultiSelectActive }, isConnecting ? '' : 'ml-auto']"+ :aria-label="isConnectionSelectionChecked ? t('connectionGroup.deselectConnection') : t('connectionGroup.selectConnection')"+ @mousedown.stop+ @click="toggleConnectionMultiSelection"+ >+ <Check v-if="isConnectionSelectionChecked" class="h-3 w-3 text-primary" />+ <Square v-else class="h-3 w-3 stroke-[1.7]" />+ </button></div>- <DialogFooter>- <Button variant="outline" @click="showCreateDatabaseDialog = false">{{ t("dangerDialog.cancel") }}</Button>- <Button :disabled="!createDatabaseName.trim()" @click="confirmCreateDatabase">{{ t("dangerDialog.confirm") }}</Button>- </DialogFooter>- </DialogContent>- </Dialog>-- <Dialog v-model:open="showEditDatabasePropertiesDialog">- <DialogContent class="sm:max-w-[460px]">- <DialogHeader>- <DialogTitle>{{ t("contextMenu.editDatabasePropertiesTitle", { name: node.label }) }}</DialogTitle>- </DialogHeader>- <div class="grid gap-3">- <div v-if="canEditDatabaseCharsetCollation" class="grid gap-3">- <div class="grid gap-1.5">- <label class="text-xs font-medium text-muted-foreground">{{ t("contextMenu.createDatabaseCharset") }}</label>- <SearchableSelect- :model-value="editDatabaseCharset"- :options="createDatabaseCharsetOptions"- :placeholder="t('contextMenu.createDatabaseCharsetPlaceholder')"- :search-placeholder="t('contextMenu.createDatabaseCharsetSearchPlaceholder')"- :empty-text="t('contextMenu.createDatabaseCharsetEmpty')"- :loading-text="t('contextMenu.createDatabaseCharsetLoading')"- :loading="createDatabaseCharsetLoading"- :normalize-custom="normalizeCreateDatabaseCharset"- allow-custom- trigger-variant="outline"- trigger-class="h-9 w-full max-w-none justify-between border bg-background px-3 text-sm shadow-xs hover:bg-accent"- content-class="w-[var(--reka-popover-trigger-width)]"- @update:model-value="updateEditDatabaseCharset"- >- <template #custom-option-label="{ value }">- <span class="truncate">{{ t("contextMenu.createDatabaseCharsetCustomOption", { value }) }}</span>- </template>- </SearchableSelect>- </div>- <div class="grid gap-1.5">- <label class="text-xs font-medium text-muted-foreground">{{ t("contextMenu.createDatabaseCollation") }}</label>- <SearchableSelect- v-model="editDatabaseCollation"- :options="createDatabaseCollationOptionsForCharset(editDatabaseCharset, createDatabaseCollationsByCharset)"- :placeholder="t('contextMenu.createDatabaseCollationPlaceholder')"- :search-placeholder="t('contextMenu.createDatabaseCollationSearchPlaceholder')"- :empty-text="t('contextMenu.createDatabaseCollationEmpty')"- :loading-text="t('contextMenu.createDatabaseCollationLoading')"- :loading="createDatabaseCharsetLoading"- :normalize-custom="normalizeCreateDatabaseCharset"- allow-custom- trigger-variant="outline"- trigger-class="h-9 w-full max-w-none justify-between border bg-background px-3 text-sm shadow-xs hover:bg-accent"- content-class="w-[var(--reka-popover-trigger-width)]"- >- <template #custom-option-label="{ value }">- <span class="truncate">{{ t("contextMenu.createDatabaseCollationCustomOption", { value }) }}</span>- </template>- </SearchableSelect>+ <template v-if="detailTooltip" #content>+ <div class="w-max min-w-40 max-w-[min(28rem,calc(100vw-24px))] rounded-md border border-border bg-popover p-2 text-popover-foreground shadow-lg">+ <div class="space-y-1">+ <div v-for="row in detailTooltip.rows" :key="row.label" class="grid grid-cols-[max-content_minmax(0,1fr)] gap-2 text-xs leading-5">+ <span class="text-muted-foreground">{{ row.label }}</span>+ <span v-if="row.multiline" class="max-h-20 overflow-hidden whitespace-pre-wrap break-words text-foreground/90">+ {{ row.value }}+ </span>+ <span v-else class="truncate font-mono text-foreground/90" :title="row.value">{{ row.value }}</span>+ </div></div></div>- <div v-if="canEditDatabaseComment" class="grid gap-1.5">- <label class="text-xs font-medium text-muted-foreground">{{ t("contextMenu.editDatabaseComment") }}</label>- <textarea- v-model="editDatabaseCommentText"- class="min-h-28 w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm outline-none transition-colors focus:border-ring focus:ring-1 focus:ring-ring/40"- :placeholder="t('contextMenu.editDatabaseCommentPlaceholder')"- :disabled="editDatabasePropertiesLoading"- @keydown.meta.enter.prevent="confirmEditDatabaseProperties"- @keydown.ctrl.enter.prevent="confirmEditDatabaseProperties"- ></textarea>- </div>- <pre v-if="editDatabasePropertiesPreviewSql" class="max-h-32 overflow-auto rounded bg-muted p-3 text-xs whitespace-pre-wrap" v-html="highlight(editDatabasePropertiesPreviewSql)"></pre>- </div>- <DialogFooter>- <Button variant="outline" :disabled="editDatabasePropertiesLoading" @click="showEditDatabasePropertiesDialog = false">{{ t("dangerDialog.cancel") }}</Button>- <Button :disabled="editDatabasePropertiesLoading" @click="confirmEditDatabaseProperties">- {{ editDatabasePropertiesLoading ? t("contextMenu.editDatabasePropertiesSaving") : t("dangerDialog.confirm") }}- </Button>- </DialogFooter>- </DialogContent>- </Dialog>-- <Dialog v-model:open="showCreateNacosNamespaceDialog">- <DialogContent class="sm:max-w-[420px]">- <DialogHeader>- <DialogTitle>{{ t("nacos.createNamespace") }}</DialogTitle>- </DialogHeader>- <div class="grid gap-3">- <div class="grid gap-1.5">- <label class="text-xs font-medium text-muted-foreground">{{ t("nacos.namespaceId") }}</label>- <Input v-model="createNacosNamespaceId" :placeholder="t('nacos.namespaceIdPlaceholder')" @keydown.enter.prevent="confirmCreateNacosNamespace" />- </div>- <div class="grid gap-1.5">- <label class="text-xs font-medium text-muted-foreground">{{ t("nacos.namespaceName") }}</label>- <Input v-model="createNacosNamespaceName" :placeholder="t('nacos.namespaceNamePlaceholder')" @keydown.enter.prevent="confirmCreateNacosNamespace" />- </div>- <div class="grid gap-1.5">- <label class="text-xs font-medium text-muted-foreground">{{ t("nacos.namespaceDesc") }}</label>- <Input v-model="createNacosNamespaceDesc" :placeholder="t('nacos.namespaceDescPlaceholder')" @keydown.enter.prevent="confirmCreateNacosNamespace" />- </div>- </div>- <DialogFooter>- <Button variant="outline" :disabled="createNacosNamespaceLoading" @click="showCreateNacosNamespaceDialog = false">{{ t("dangerDialog.cancel") }}</Button>- <Button :disabled="!createNacosNamespaceName.trim() || createNacosNamespaceLoading" @click="confirmCreateNacosNamespace">- {{ createNacosNamespaceLoading ? t("nacos.creatingNamespace") : t("dangerDialog.confirm") }}- </Button>- </DialogFooter>- </DialogContent>- </Dialog>-- <Dialog v-model:open="showEditNacosNamespaceDialog">- <DialogContent class="sm:max-w-[420px]">- <DialogHeader>- <DialogTitle>{{ t("nacos.editNamespace") }}</DialogTitle>- </DialogHeader>- <div class="grid gap-3">- <div class="grid gap-1.5">- <label class="text-xs font-medium text-muted-foreground">{{ t("nacos.namespaceName") }}</label>- <Input v-model="editNacosNamespaceName" :placeholder="t('nacos.namespaceNamePlaceholder')" @keydown.enter.prevent="confirmEditNacosNamespace" />- </div>- <div class="grid gap-1.5">- <label class="text-xs font-medium text-muted-foreground">{{ t("nacos.namespaceDesc") }}</label>- <Input v-model="editNacosNamespaceDesc" :placeholder="t('nacos.namespaceDescPlaceholder')" @keydown.enter.prevent="confirmEditNacosNamespace" />- </div>- </div>- <DialogFooter>- <Button variant="outline" :disabled="editNacosNamespaceLoading" @click="showEditNacosNamespaceDialog = false">{{ t("dangerDialog.cancel") }}</Button>- <Button :disabled="!editNacosNamespaceName.trim() || editNacosNamespaceLoading" @click="confirmEditNacosNamespace">- {{ editNacosNamespaceLoading ? t("nacos.updatingNamespace") : t("dangerDialog.confirm") }}- </Button>- </DialogFooter>- </DialogContent>- </Dialog>-- <DangerConfirmDialog- v-model:open="showDropDatabaseConfirm"- :title="t('contextMenu.confirmDropDatabaseTitle')"- :message="t('contextMenu.confirmDropDatabaseMessage', { name: node.label })"- :sql="dropDatabasePreviewSql"- :confirm-label="t('contextMenu.dropDatabase')"- :loading="dropDatabaseLoading"- :close-on-confirm="false"- @confirm="confirmDropDatabase"- />-- <DangerConfirmDialog- v-model:open="showDropMongoCollectionConfirm"- :title="t('contextMenu.confirmDropCollectionTitle')"- :message="t('contextMenu.confirmDropCollectionMessage', { name: node.label })"- :confirm-label="t('contextMenu.dropCollection')"- :loading="dropMongoCollectionLoading"- :close-on-confirm="false"- @confirm="confirmDropMongoCollection"- />-- <DangerConfirmDialog- v-model:open="showDropMongoIndexConfirm"- :title="t('contextMenu.confirmDropIndexTitle')"- :message="t('contextMenu.confirmDropMongoIndexMessage', { name: mongoIndexNameForNode(node), collection: node.tableName || '' })"- :details="mongoIndexDropPreview(node, mongoIndexNameForNode(node))"- :confirm-label="t('contextMenu.dropIndex')"- :loading="dropMongoIndexLoading"- :close-on-confirm="false"- @confirm="confirmDropMongoIndex"- />-- <DangerConfirmDialog- v-model:open="showDropAllMongoIndexesConfirm"- :title="t('contextMenu.dropAllIndexes')"- :message="t('contextMenu.confirmDropMongoAllIndexesMessage', { name: node.label })"- :details-text="t('contextMenu.confirmDropMongoAllIndexesDetails')"- :sql="mongoDropAllIndexesPreview(node)"- :confirm-label="t('contextMenu.dropAllIndexes')"- :loading="dropAllMongoIndexesLoading"- :close-on-confirm="false"- @confirm="confirmDropAllMongoIndexes"- />-- <DangerConfirmDialog v-model:open="showFlushRedisDbConfirm" :title="t('redis.flushDb')" :message="t('redis.flushDbMessage')" :details="t('redis.flushDbDetails', { db: node.database })" :confirm-label="t('redis.flushDbConfirm')" @confirm="confirmFlushRedisDb" />-- <Dialog v-model:open="showCreateSchemaDialog">- <DialogContent class="sm:max-w-[400px]">- <DialogHeader>- <DialogTitle>{{ t("contextMenu.createSchema") }}</DialogTitle>- </DialogHeader>- <Input v-model="createSchemaName" :placeholder="t('contextMenu.createSchemaNamePlaceholder')" @keydown.enter.prevent="confirmCreateSchema" />- <DialogFooter>- <Button variant="outline" @click="showCreateSchemaDialog = false">{{ t("dangerDialog.cancel") }}</Button>- <Button :disabled="!createSchemaName.trim()" @click="confirmCreateSchema">{{ t("dangerDialog.confirm") }}</Button>- </DialogFooter>- </DialogContent>- </Dialog>-- <Dialog v-model:open="showEditSchemaCommentDialog">- <DialogContent class="sm:max-w-[520px]">- <DialogHeader>- <DialogTitle>{{ t("contextMenu.editSchemaCommentTitle", { name: node.label }) }}</DialogTitle>- </DialogHeader>- <div class="grid gap-3">- <textarea- v-model="schemaCommentText"- class="min-h-28 w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm outline-none transition-colors focus:border-ring focus:ring-1 focus:ring-ring/40"- :placeholder="t('contextMenu.schemaCommentPlaceholder')"- :disabled="schemaCommentLoading"- @keydown.meta.enter.prevent="confirmEditSchemaComment"- @keydown.ctrl.enter.prevent="confirmEditSchemaComment"- ></textarea>- <pre v-if="schemaCommentPreviewSql" class="max-h-32 overflow-auto rounded bg-muted p-3 text-xs whitespace-pre-wrap" v-html="highlight(schemaCommentPreviewSql)"></pre>- </div>- <DialogFooter>- <Button variant="outline" :disabled="schemaCommentLoading" @click="showEditSchemaCommentDialog = false">{{ t("dangerDialog.cancel") }}</Button>- <Button :disabled="schemaCommentLoading" @click="confirmEditSchemaComment">- {{ schemaCommentLoading ? t("contextMenu.schemaCommentSaving") : t("dangerDialog.confirm") }}- </Button>- </DialogFooter>- </DialogContent>- </Dialog>-- <DangerConfirmDialog v-model:open="showDropSchemaConfirm" :title="t('contextMenu.confirmDropSchemaTitle')" :message="t('contextMenu.confirmDropSchemaMessage', { name: node.label })" :sql="dropSchemaPreviewSql" :confirm-label="t('contextMenu.dropSchema')" @confirm="confirmDropSchema" />-- <DdlViewDialog- v-if="ddlTarget"- :connection-id="ddlTarget.connectionId!"- :database="ddlTarget.database!"- :schema="ddlTarget.schema"- :table-name="ddlTarget.label"- :object-type="tableDdlObjectTypeForNode(ddlTarget.type)"- :database-type="ddlDatabaseType"- :dialect="ddlDialect"- :format-dialect="ddlFormatDialect"- v-model:open="showDdlDialog"- />-- <ObjectSourceDialog- v-if="objectSourceTarget && objectSourceType"- v-model:open="showObjectSourceDialog"- :connection-id="objectSourceTarget.node.connectionId!"- :database="objectSourceTarget.node.database!"- :schema="objectSourceTarget.node.schema"- :name="objectSourceTarget.node.objectName || objectSourceTarget.node.label"- :signature="objectSourceTarget.node.signature"- :object-type="objectSourceType"- :database-type="objectSourceDatabaseType"- :dialect="objectSourceDialect"- :format-dialect="objectSourceFormatDialect"- :initial-editing="objectSourceTarget.initialEditing"- @saved="refresh"- />-- <InstallExtensionDialog ref="installExtensionDialogRef" :node="node" @close="refresh" />+ </template>+ </LightTooltip>+ </div></template><style>diff --git a/apps/desktop/src/components/sidebar/sidebarAsyncDialogs.ts b/apps/desktop/src/components/sidebar/sidebarAsyncDialogs.tsnew file mode 100644index 0000000000..1ee61bebbf--- /dev/null+++ b/apps/desktop/src/components/sidebar/sidebarAsyncDialogs.ts@@ -0,0 +1,24 @@+import { defineAsyncComponent, type Component } from "vue";+import SidebarAsyncDialogError from "./SidebarAsyncDialogError.vue";+import SidebarAsyncDialogLoading from "./SidebarAsyncDialogLoading.vue";++function lazySidebarDialog(loader: () => Promise<Component>) {+ return defineAsyncComponent({+ loader,+ loadingComponent: SidebarAsyncDialogLoading,+ errorComponent: SidebarAsyncDialogError,+ delay: 120,+ timeout: 15_000,+ onError(_error, retry, fail, attempts) {+ if (attempts < 2) retry();+ else fail();+ },+ });+}++export const SidebarDangerConfirmDialog = lazySidebarDialog(() => import("@/components/editor/DangerConfirmDialog.vue"));+export const SidebarVisibleDatabasesDialog = lazySidebarDialog(() => import("@/components/sidebar/VisibleDatabasesDialog.vue"));+export const SidebarVisibleSchemasDialog = lazySidebarDialog(() => import("@/components/sidebar/VisibleSchemasDialog.vue"));+export const SidebarDdlViewDialog = lazySidebarDialog(() => import("@/components/objects/DdlViewDialog.vue"));+export const SidebarObjectSourceDialog = lazySidebarDialog(() => import("@/components/objects/ObjectSourceDialog.vue"));+export const SidebarProcedureExecutionDialog = lazySidebarDialog(() => import("@/components/objects/ProcedureExecutionDialog.vue"));diff --git a/apps/desktop/src/components/sidebar/sidebarTreeDialogState.ts b/apps/desktop/src/components/sidebar/sidebarTreeDialogState.tsnew file mode 100644index 0000000000..3a97f3707a--- /dev/null+++ b/apps/desktop/src/components/sidebar/sidebarTreeDialogState.ts@@ -0,0 +1,139 @@+import { ref, shallowRef } from "vue";+import type { TreeNode } from "@/types/database";+import type { PasteTableMode } from "@/lib/table/tableClipboard";+import { fallbackCreateDatabaseCharsetMetadata } from "@/lib/database/createDatabaseCharsetOptions";++export type DuplicateStructureSource = TreeNode & { connectionId: string; database: string };+type ConnectionDeleteTarget = TreeNode & { connectionId: string };++export const fallbackCreateDatabaseCharset = fallbackCreateDatabaseCharsetMetadata();++export const sidebarTreeDialogOwner = shallowRef<symbol | null>(null);+export const sidebarDangerTarget = shallowRef<TreeNode | null>(null);+export const sidebarFormTarget = shallowRef<TreeNode | null>(null);+export const connectionDeleteTargetSnapshot = ref<ConnectionDeleteTarget[]>([]);+export const showDeleteConfirm = ref(false);+export const showDropTableConfirm = ref(false);+export const showDropTableChildObjectConfirm = ref(false);+export const showBatchDropConfirm = ref(false);+export const showBatchEmptyConfirm = ref(false);+export const showBatchTruncateConfirm = ref(false);+export const showStructurePreviewDialog = ref(false);+export const showStructureDocCopyDialog = ref(false);+export const structurePreviewSql = ref("");+export const structurePreviewTitle = ref("");+export const structurePreviewDefaultFileName = ref("structure.sql");+export const structurePreviewError = ref("");+export const structureDocCopyText = ref("");+export const structureDocCopyTitle = ref("");+export const isLoadingStructurePreview = ref(false);+export const showEmptyTableConfirm = ref(false);+export const showTruncateTableConfirm = ref(false);+export const showRenameObjectDialog = ref(false);+export const renameObjectName = ref("");+export const renameObjectError = ref("");+export const renameObjectPreviewSql = ref("");+export const dropTablePreviewSql = ref("");+export const dropTableCascade = ref(false);+export const batchDropCascade = ref(false);+export const emptyTablePreviewSql = ref("");+export const truncateTablePreviewSql = ref("");+export const truncateTableCascade = ref(false);+export const dropObjectPreviewSql = ref("");+export const showDropObjectConfirm = ref(false);+export const dropTableChildObjectPreviewSql = ref("");+export const batchDropPreviewSql = ref("");+export const batchEmptyPreviewSql = ref("");+export const batchEmptyTargets = ref<TreeNode[]>([]);+export const batchDropTargets = ref<TreeNode[]>([]);+export const batchTruncateTargets = ref<TreeNode[]>([]);+export const batchTruncatePreviewSql = ref("");+export const batchTruncateCascade = ref(false);+export const dropDatabasePreviewSql = ref("");+export const dropSchemaPreviewSql = ref("");+export const showDuplicateDialog = ref(false);+export const duplicateTableName = ref("");+export const duplicateStructureSource = ref<DuplicateStructureSource | null>(null);+export const showPasteDialog = ref(false);+export const pasteTableMode = ref<PasteTableMode>("structure-and-data");+export const pasteTableEntries = ref<Array<{ sourceName: string; targetName: string; connectionId: string; database: string; schema?: string }>>([]);+export const showCreateDatabaseDialog = ref(false);+export const createDatabaseName = ref("");+export const createDatabaseCharset = ref("utf8mb4");+export const createDatabaseCollation = ref("utf8mb4_unicode_ci");+export const showCreateNacosNamespaceDialog = ref(false);+export const createNacosNamespaceId = ref("");+export const createNacosNamespaceName = ref("");+export const createNacosNamespaceDesc = ref("");+export const createNacosNamespaceLoading = ref(false);+export const showEditNacosNamespaceDialog = ref(false);+export const editNacosNamespaceName = ref("");+export const editNacosNamespaceDesc = ref("");+export const editNacosNamespaceLoading = ref(false);+export const createDatabaseCharsetOptions = ref<string[]>(fallbackCreateDatabaseCharset.charsets);+export const createDatabaseCollationsByCharset = ref<Record<string, string[]>>(fallbackCreateDatabaseCharset.collationsByCharset);+export const createDatabaseCharsetLoading = ref(false);+export const showDropDatabaseConfirm = ref(false);+export const dropDatabaseLoading = ref(false);+export const showDropMongoCollectionConfirm = ref(false);+export const dropMongoCollectionLoading = ref(false);+export const showDropMongoIndexConfirm = ref(false);+export const dropMongoIndexLoading = ref(false);+export const showDropAllMongoIndexesConfirm = ref(false);+export const dropAllMongoIndexesLoading = ref(false);+export const showFlushRedisDbConfirm = ref(false);+export const showCreateSchemaDialog = ref(false);+export const createSchemaName = ref("");+export const showDropSchemaConfirm = ref(false);+export const showEditDatabasePropertiesDialog = ref(false);+export const editDatabasePropertiesLoading = ref(false);+export const editDatabasePropertiesPreviewSql = ref("");+export const editDatabaseCharset = ref("utf8mb4");+export const editDatabaseCollation = ref("utf8mb4_unicode_ci");+export const editDatabaseCommentText = ref("");+export const showEditSchemaCommentDialog = ref(false);+export const schemaCommentText = ref("");+export const schemaCommentLoading = ref(false);+export const schemaCommentPreviewSql = ref("");+export const showDeleteGroupConfirm = ref(false);+export const showMoveToNewGroupDialog = ref(false);+export const moveToNewGroupName = ref("");++const openFlags = [+ showDeleteConfirm,+ showDropTableConfirm,+ showDropTableChildObjectConfirm,+ showBatchDropConfirm,+ showBatchEmptyConfirm,+ showBatchTruncateConfirm,+ showStructurePreviewDialog,+ showStructureDocCopyDialog,+ showEmptyTableConfirm,+ showTruncateTableConfirm,+ showDropObjectConfirm,+ showRenameObjectDialog,+ showDuplicateDialog,+ showPasteDialog,+ showCreateDatabaseDialog,+ showCreateNacosNamespaceDialog,+ showEditNacosNamespaceDialog,+ showDropDatabaseConfirm,+ showDropMongoCollectionConfirm,+ showDropMongoIndexConfirm,+ showDropAllMongoIndexesConfirm,+ showFlushRedisDbConfirm,+ showCreateSchemaDialog,+ showDropSchemaConfirm,+ showEditDatabasePropertiesDialog,+ showEditSchemaCommentDialog,+ showDeleteGroupConfirm,+ showMoveToNewGroupDialog,+];++export function resetSidebarTreeDialogState() {+ for (const flag of openFlags) flag.value = false;+ sidebarTreeDialogOwner.value = null;+ sidebarDangerTarget.value = null;+ sidebarFormTarget.value = null;+ connectionDeleteTargetSnapshot.value = [];+}diff --git a/apps/desktop/src/components/ui/CustomContextMenu.vue b/apps/desktop/src/components/ui/CustomContextMenu.vueindex 21e2354038..c8f77e68b0 100644--- a/apps/desktop/src/components/ui/CustomContextMenu.vue+++ b/apps/desktop/src/components/ui/CustomContextMenu.vue@@ -70,6 +70,8 @@ function close() {show.value = false;}+defineExpose({ close });+function onPointerDownOutside(e: PointerEvent) {// Only respond to primary (left) button presses. This avoids a macOS// issue where Ctrl+right-click generates a synthetic click event on@@ -125,9 +127,12 @@ function handleSubItemClick(item: ContextMenuItem) {item.action?.();}-function onContextMenu(event: MouseEvent) {+function onContextMenu(event: MouseEvent, itemsOverride?: ContextMenuItem[]) {// Some callers build large context menus; resolve them only for actual opens.- const items = typeof props.items === "function" ? props.items() : props.items;+ // Tree-level hosts may replace their items and open in the same event turn.+ // Accepting the resolved items directly avoids reading the previous prop+ // value before Vue has flushed the parent-to-child update.+ const items = itemsOverride ?? (typeof props.items === "function" ? props.items() : props.items);if (items.length === 0) return;activeItems.value = items;event.preventDefault();diff --git a/apps/desktop/src/composables/__tests__/useFlatTree.spec.ts b/apps/desktop/src/composables/__tests__/useFlatTree.spec.tsnew file mode 100644index 0000000000..64bc6c5a40--- /dev/null+++ b/apps/desktop/src/composables/__tests__/useFlatTree.spec.ts@@ -0,0 +1,131 @@+import { describe, expect, it } from "vitest";+import { createFlatTreeIndex, flattenTree, mutateFlatTreeExpansion, replaceFlatTreeChildren, type FlatTreeNode } from "@/composables/useFlatTree";+import type { TreeNode, TreeNodeType } from "@/types/database";++function item(id: string, type: TreeNodeType, depth: number, children?: TreeNode[]): FlatTreeNode {+ const node: TreeNode = { id, label: id, type, children };+ return { id, type, depth, node, poolType: type };+}++function createIndex(nodes: FlatTreeNode[]) {+ const databaseTypes = new Set<TreeNodeType>(["database", "redis-db", "mongo-db"]);+ return createFlatTreeIndex(nodes, {+ isSelectable: (node) => node.type !== "table-search-control",+ isBoundary: (type) => type === "connection" || type === "connection-group",+ isDatabaseContainer: (type) => databaseTypes.has(type),+ isSchemaContainer: (type) => type === "schema",+ });+}++describe("createFlatTreeIndex", () => {+ it("builds selection and lookup indexes in visible order", () => {+ const nodes = [item("connection", "connection", 0, [{ id: "child", label: "child", type: "database" }]), item("database", "database", 1), item("search", "table-search-control", 2), item("table", "table", 2)];++ const index = createIndex(nodes);++ expect(index.visibleNodes.map((node) => node.id)).toEqual(["connection", "database", "search", "table"]);+ expect(index.selectableVisibleNodes.map((node) => node.id)).toEqual(["connection", "database", "table"]);+ expect(index.selectableVisibleNodeIndexById.get("table")).toBe(2);+ expect(index.selectableVisibleNodeIndexById.has("search")).toBe(false);+ expect(index.flatNodeIndexById.get("table")).toBe(3);+ expect(index.nodeById.get("database")).toBe(nodes[1].node);+ expect(index.expandableNodeIds).toEqual(["connection"]);+ });++ it("prefers database containers and falls back to schemas per connection", () => {+ const nodes = [+ item("connection-a", "connection", 0),+ item("database-a", "database", 1),+ item("schema-a", "schema", 2),+ item("table-a", "table", 3),+ item("schema-b", "schema", 2),+ item("table-b", "table", 3),+ item("database-b", "database", 1),+ item("table-c", "table", 2),+ item("connection-b", "connection", 0),+ item("schema-c", "schema", 1),+ item("table-d", "table", 2),+ ];++ const index = createIndex(nodes);++ expect([...index.stickyContainerIndexByIndex]).toEqual([-1, 1, 1, 1, 1, 1, 6, 6, -1, 9, 9]);+ expect(index.nextDatabaseContainerIndexByIndex[1]).toBe(6);+ expect(index.nextDatabaseContainerIndexByIndex[6]).toBe(-1);+ expect(index.nextSchemaContainerIndexByIndex[2]).toBe(4);+ expect(index.nextSchemaContainerIndexByIndex[4]).toBe(-1);+ expect(index.nextSchemaContainerIndexByIndex[9]).toBe(-1);+ });++ it("keeps indexes isolated across connections without database containers", () => {+ const nodes = [item("connection-a", "connection", 0), item("schema-a", "schema", 1), item("table-a", "table", 2), item("connection-b", "connection", 0), item("table-b", "table", 1)];++ const index = createIndex(nodes);++ expect(index.stickyContainerIndexByIndex[2]).toBe(1);+ expect(index.stickyContainerIndexByIndex[4]).toBe(-1);+ expect(index.nextSchemaContainerIndexByIndex[1]).toBe(-1);+ expect(index.flatNodeIndexById.get("table-b")).toBe(4);+ });++ it("indexes a synthetic large visible tree in one pass", () => {+ const nodes: FlatTreeNode[] = [item("connection", "connection", 0)];+ for (let index = 0; index < 20_000; index += 1) {+ nodes.push(item(`table-${index}`, "table", 1));+ }++ const index = createIndex(nodes);++ expect(index.visibleNodes).toHaveLength(20_001);+ expect(index.flatNodeIndexById.get("table-19999")).toBe(20_000);+ expect(index.stickyContainerIndexByIndex).toHaveLength(20_001);+ });+});++describe("flat-tree range mutations", () => {+ it("expands and collapses only the affected descendant range", () => {+ const table: TreeNode = { id: "table", label: "table", type: "table" };+ const schema: TreeNode = { id: "schema", label: "schema", type: "schema", children: [table] };+ const database: TreeNode = { id: "database", label: "database", type: "database", children: [schema] };+ const connection: TreeNode = { id: "connection", label: "connection", type: "connection", isExpanded: true, children: [database] };+ const sibling: TreeNode = { id: "sibling", label: "sibling", type: "connection" };+ const initial = flattenTree([connection, sibling]);++ const expandedDatabase = mutateFlatTreeExpansion(initial, 1, database, true);+ expect(expandedDatabase.map((entry) => entry.id)).toEqual(["connection", "database", "schema", "sibling"]);+ expect(expandedDatabase.at(-1)?.node).toBe(sibling);++ const expandedSchema = mutateFlatTreeExpansion(expandedDatabase, 2, schema, true);+ expect(expandedSchema.map((entry) => entry.id)).toEqual(["connection", "database", "schema", "table", "sibling"]);++ const collapsedDatabase = mutateFlatTreeExpansion(expandedSchema, 1, database, false);+ expect(collapsedDatabase.map((entry) => entry.id)).toEqual(["connection", "database", "sibling"]);+ expect(collapsedDatabase[2].node).toBe(sibling);+ });++ it("atomically replaces refreshed children and preserves surrounding rows", () => {+ const oldTable: TreeNode = { id: "old-table", label: "old-table", type: "table" };+ const database: TreeNode = { id: "database", label: "database", type: "database", isExpanded: true, children: [oldTable] };+ const connection: TreeNode = { id: "connection", label: "connection", type: "connection", isExpanded: true, children: [database] };+ const sibling: TreeNode = { id: "sibling", label: "sibling", type: "connection" };+ const initial = flattenTree([connection, sibling]);+ const newTable: TreeNode = { id: "new-table", label: "new-table", type: "table" };+ database.children = [newTable];++ const refreshed = replaceFlatTreeChildren(initial, 1, database);++ expect(refreshed.map((entry) => entry.id)).toEqual(["connection", "database", "new-table", "sibling"]);+ expect(refreshed[0]).toBe(initial[0]);+ expect(refreshed[3]).toBe(initial[3]);+ });++ it("falls back to an unchanged copy when the indexed parent no longer matches", () => {+ const nodes = [item("connection", "connection", 0)];+ const other: TreeNode = { id: "other", label: "other", type: "connection", isExpanded: true, children: [] };++ const result = replaceFlatTreeChildren(nodes, 0, other);++ expect(result).toEqual(nodes);+ expect(result).not.toBe(nodes);+ });+});diff --git a/apps/desktop/src/composables/useFlatTree.ts b/apps/desktop/src/composables/useFlatTree.tsindex 81a95aff68..13662280df 100644--- a/apps/desktop/src/composables/useFlatTree.ts+++ b/apps/desktop/src/composables/useFlatTree.ts@@ -12,6 +12,25 @@ export interface FlatTreeNode {poolType: string;}+export interface FlatTreeIndex {+ visibleNodes: TreeNode[];+ selectableVisibleNodes: TreeNode[];+ selectableVisibleNodeIndexById: Map<string, number>;+ flatNodeIndexById: Map<string, number>;+ nodeById: Map<string, TreeNode>;+ expandableNodeIds: string[];+ stickyContainerIndexByIndex: Int32Array;+ nextDatabaseContainerIndexByIndex: Int32Array;+ nextSchemaContainerIndexByIndex: Int32Array;+}++interface FlatTreeIndexOptions {+ isSelectable: (node: TreeNode) => boolean;+ isBoundary: (type: TreeNodeType) => boolean;+ isDatabaseContainer: (type: TreeNodeType) => boolean;+ isSchemaContainer: (type: TreeNodeType) => boolean;+}+function walk(children: TreeNode[], depth: number, result: FlatTreeNode[]) {for (const node of children) {result.push({@@ -27,12 +46,113 @@ function walk(children: TreeNode[], depth: number, result: FlatTreeNode[]) {}}+function flatTreeNode(node: TreeNode, depth: number): FlatTreeNode {+ return {+ node,+ depth,+ id: node.id,+ type: node.type,+ poolType: node.type === "connection-group" ? `${node.type}:${node.id}` : node.type,+ };+}++function visibleDescendantEnd(nodes: readonly FlatTreeNode[], parentIndex: number): number {+ const parentDepth = nodes[parentIndex]?.depth;+ if (parentDepth == null) return parentIndex;+ let end = parentIndex + 1;+ while (end < nodes.length && nodes[end].depth > parentDepth) end += 1;+ return end;+}+export function flattenTree(nodes: TreeNode[]): FlatTreeNode[] {const result: FlatTreeNode[] = [];walk(nodes, 0, result);return result;}+export function replaceFlatTreeChildren(nodes: readonly FlatTreeNode[], parentIndex: number, parent: TreeNode): FlatTreeNode[] {+ if (parentIndex < 0 || parentIndex >= nodes.length || nodes[parentIndex].id !== parent.id) return [...nodes];++ const end = visibleDescendantEnd(nodes, parentIndex);+ const replacement: FlatTreeNode[] = [];+ if (parent.isExpanded && parent.children) walk(parent.children, nodes[parentIndex].depth + 1, replacement);++ // One splice-shaped replacement keeps recycled-list consumers from observing+ // an intermediate state where old and new child ranges coexist.+ return [...nodes.slice(0, parentIndex), flatTreeNode(parent, nodes[parentIndex].depth), ...replacement, ...nodes.slice(end)];+}++export function mutateFlatTreeExpansion(nodes: readonly FlatTreeNode[], parentIndex: number, parent: TreeNode, expanded: boolean): FlatTreeNode[] {+ if (parent.isExpanded !== expanded) parent.isExpanded = expanded;+ return replaceFlatTreeChildren(nodes, parentIndex, parent);+}+export function shouldVirtualizeFlatTree(count: number): boolean {return count > 0;}++export function createFlatTreeIndex(nodes: readonly FlatTreeNode[], options: FlatTreeIndexOptions): FlatTreeIndex {+ const visibleNodes: TreeNode[] = [];+ const selectableVisibleNodes: TreeNode[] = [];+ const selectableVisibleNodeIndexById = new Map<string, number>();+ const flatNodeIndexById = new Map<string, number>();+ const nodeById = new Map<string, TreeNode>();+ const expandableNodeIds: string[] = [];+ const stickyContainerIndexByIndex = new Int32Array(nodes.length);+ const nextDatabaseContainerIndexByIndex = new Int32Array(nodes.length);+ const nextSchemaContainerIndexByIndex = new Int32Array(nodes.length);+ stickyContainerIndexByIndex.fill(-1);+ nextDatabaseContainerIndexByIndex.fill(-1);+ nextSchemaContainerIndexByIndex.fill(-1);++ let databaseContainerIndex = -1;+ let schemaContainerIndex = -1;+ for (let index = 0; index < nodes.length; index += 1) {+ const item = nodes[index];+ const node = item.node;+ visibleNodes.push(node);+ flatNodeIndexById.set(item.id, index);+ nodeById.set(item.id, node);+ if (node.children?.length) expandableNodeIds.push(item.id);+ if (options.isSelectable(node)) {+ selectableVisibleNodeIndexById.set(item.id, selectableVisibleNodes.length);+ selectableVisibleNodes.push(node);+ }++ if (options.isBoundary(item.type)) {+ databaseContainerIndex = -1;+ schemaContainerIndex = -1;+ continue;+ }+ if (options.isDatabaseContainer(item.type)) databaseContainerIndex = index;+ if (options.isSchemaContainer(item.type)) schemaContainerIndex = index;+ stickyContainerIndexByIndex[index] = databaseContainerIndex >= 0 ? databaseContainerIndex : schemaContainerIndex;+ }++ let nextDatabaseContainerIndex = -1;+ let nextSchemaContainerIndex = -1;+ for (let index = nodes.length - 1; index >= 0; index -= 1) {+ const item = nodes[index];+ if (options.isBoundary(item.type)) {+ nextDatabaseContainerIndex = -1;+ nextSchemaContainerIndex = -1;+ continue;+ }+ nextDatabaseContainerIndexByIndex[index] = nextDatabaseContainerIndex;+ nextSchemaContainerIndexByIndex[index] = nextSchemaContainerIndex;+ if (options.isDatabaseContainer(item.type)) nextDatabaseContainerIndex = index;+ if (options.isSchemaContainer(item.type)) nextSchemaContainerIndex = index;+ }++ return {+ visibleNodes,+ selectableVisibleNodes,+ selectableVisibleNodeIndexById,+ flatNodeIndexById,+ nodeById,+ expandableNodeIds,+ stickyContainerIndexByIndex,+ nextDatabaseContainerIndexByIndex,+ nextSchemaContainerIndexByIndex,+ };+}diff --git a/apps/desktop/src/lib/__tests__/app/pinnedItems.spec.ts b/apps/desktop/src/lib/__tests__/app/pinnedItems.spec.tsindex b7ba65ca20..828496eaed 100644--- a/apps/desktop/src/lib/__tests__/app/pinnedItems.spec.ts+++ b/apps/desktop/src/lib/__tests__/app/pinnedItems.spec.ts@@ -1,5 +1,5 @@import { describe, expect, it } from "vitest";-import { updatePinnedTreeNodeInPlace } from "@/lib/app/pinnedItems";+import { migrateLegacyPinnedTreeNodeIds, syncPinnedTreeNodeStateInPlace, treeNodePinKey, updatePinnedTreeNodeInPlace } from "@/lib/app/pinnedItems";import { buildTreeNodesFromLayout } from "@/lib/sidebar/sidebarLayout";import type { ConnectionConfig, SidebarLayout, TreeNode } from "@/types/database";@@ -17,7 +17,7 @@ describe("sidebar pinned tree nodes", () => {},];- expect(updatePinnedTreeNodeInPlace(tree, "conn:db:b", true)).toBe("siblings");+ expect(updatePinnedTreeNodeInPlace(tree, tree[0].children![1], true)).toBe("siblings");expect(tree[0].children?.map((node) => node.id)).toEqual(["conn:db:b", "conn:db:a"]);expect(tree[0].children?.[0].pinned).toBe(true);@@ -29,12 +29,57 @@ describe("sidebar pinned tree nodes", () => {{ id: "group-b", label: "B", type: "connection-group" },];- expect(updatePinnedTreeNodeInPlace(tree, "group-b", true)).toBe("root");+ expect(updatePinnedTreeNodeInPlace(tree, tree[1], true)).toBe("root");expect(tree.map((node) => node.id)).toEqual(["group-b", "group-a"]);expect(tree[0].pinned).toBe(true);});+ it("scopes duplicate node ids by database when pinning", () => {+ const databaseA: TreeNode = {+ id: "conn:a",+ label: "A",+ type: "database",+ children: [{ id: "duplicate-table-id", label: "users", type: "table", connectionId: "conn", database: "a" }],+ };+ const databaseB: TreeNode = {+ id: "conn:b",+ label: "B",+ type: "database",+ children: [{ id: "duplicate-table-id", label: "users", type: "table", connectionId: "conn", database: "b" }],+ };+ const tree: TreeNode[] = [{ id: "conn", label: "Connection", type: "connection", children: [databaseA, databaseB] }];++ expect(updatePinnedTreeNodeInPlace(tree, databaseA.children![0], true)).toBe("siblings");++ expect(databaseA.children![0].pinned).toBe(true);+ expect(databaseB.children![0].pinned).not.toBe(true);+ });++ it("clears stale legacy duplicate pins after switching to scoped keys", () => {+ const tableA: TreeNode = { id: "duplicate-table-id", label: "users", type: "table", connectionId: "conn", database: "a", pinned: true };+ const tableB: TreeNode = { id: "duplicate-table-id", label: "users", type: "table", connectionId: "conn", database: "b", pinned: true };+ const tree: TreeNode[] = [+ { id: "conn:a", label: "A", type: "database", children: [tableA] },+ { id: "conn:b", label: "B", type: "database", children: [tableB] },+ ];++ syncPinnedTreeNodeStateInPlace(tree, new Set([treeNodePinKey(tableA)]));++ expect(tableA.pinned).toBe(true);+ expect(tableB.pinned).toBe(false);+ });++ it("migrates a legacy id once instead of pinning every colliding node", () => {+ const tableA: TreeNode = { id: "duplicate-table-id", label: "users", type: "table", connectionId: "conn", database: "a" };+ const tableB: TreeNode = { id: "duplicate-table-id", label: "users", type: "table", connectionId: "conn", database: "b" };++ const migrated = migrateLegacyPinnedTreeNodeIds([tableA, tableB], new Set(["duplicate-table-id"]));++ expect(migrated.changed).toBe(true);+ expect(migrated.ids).toEqual(new Set([treeNodePinKey(tableA)]));+ });+it("applies pinned state to connection groups when rebuilding from layout", () => {const layout: SidebarLayout = {groups: [diff --git a/apps/desktop/src/lib/__tests__/sidebar/sidebarActionTarget.spec.ts b/apps/desktop/src/lib/__tests__/sidebar/sidebarActionTarget.spec.tsnew file mode 100644index 0000000000..ef76ded575--- /dev/null+++ b/apps/desktop/src/lib/__tests__/sidebar/sidebarActionTarget.spec.ts@@ -0,0 +1,62 @@+import { describe, expect, it } from "vitest";+import type { TreeNode } from "@/types/database";+import { createSidebarActionRequest, createSidebarActionTarget, findSidebarActionTarget } from "@/lib/sidebar/sidebarActionTarget";++function tableNode(): TreeNode {+ return {+ id: "table-1",+ label: "users",+ type: "table",+ connectionId: "connection-1",+ database: "app",+ schema: "public",+ children: [{ id: "column-1", label: "id", type: "column" }],+ };+}++describe("sidebar action targets", () => {+ it("captures a frozen shallow snapshot without retaining children", () => {+ const node = tableNode();+ const target = createSidebarActionTarget(node);++ node.label = "recycled-row";+ node.connectionId = "connection-2";++ expect(target).toMatchObject({ label: "users", connectionId: "connection-1", children: undefined, hiddenChildren: undefined });+ expect(Object.isFrozen(target)).toBe(true);+ });++ it("captures selection independently from later selection changes", () => {+ const selectedNodeIds = ["table-1", "table-2"];+ const request = createSidebarActionRequest(tableNode(), selectedNodeIds, { initialEditing: true });++ selectedNodeIds.splice(0, selectedNodeIds.length, "table-3");++ expect(request.selectedNodeIds).toEqual(["table-1", "table-2"]);+ expect(request.payload).toEqual({ initialEditing: true });+ expect(Object.isFrozen(request.selectedNodeIds)).toBe(true);+ expect(Object.isFrozen(request)).toBe(true);+ });++ it("does not resolve a recycled row with the same local id", () => {+ const target = createSidebarActionTarget(tableNode());+ const recycled = tableNode();+ recycled.connectionId = "connection-2";++ expect(findSidebarActionTarget([recycled], target)).toBeNull();+ });++ it("returns null when the action target was removed", () => {+ const target = createSidebarActionTarget(tableNode());++ expect(findSidebarActionTarget([], target)).toBeNull();+ });++ it("resolves targets stored only in hidden children", () => {+ const node = tableNode();+ const target = createSidebarActionTarget(node);+ const root: TreeNode = { id: "root", label: "root", type: "database", hiddenChildren: [node] };++ expect(findSidebarActionTarget([root], target)).toBe(node);+ });+});diff --git a/apps/desktop/src/lib/__tests__/sidebar/sidebarDataOpenCoordinator.spec.ts b/apps/desktop/src/lib/__tests__/sidebar/sidebarDataOpenCoordinator.spec.tsnew file mode 100644index 0000000000..b3dae50285--- /dev/null+++ b/apps/desktop/src/lib/__tests__/sidebar/sidebarDataOpenCoordinator.spec.ts@@ -0,0 +1,95 @@+import { afterEach, describe, expect, it, vi } from "vitest";+import { cancelPendingSidebarDataOpen, runSidebarDataOpenImmediately } from "@/lib/sidebar/sidebarDataOpenCoordinator";++describe("sidebarDataOpenCoordinator", () => {+ afterEach(() => {+ cancelPendingSidebarDataOpen();+ });++ it("cancels the active request when a newer open starts", async () => {+ const cancel = vi.fn();+ let firstIsCurrent = true;++ runSidebarDataOpenImmediately(async (request) => {+ request.registerCancel(cancel);+ await Promise.resolve();+ firstIsCurrent = request.isCurrent();+ });+ runSidebarDataOpenImmediately(() => undefined);+ await Promise.resolve();++ expect(cancel).toHaveBeenCalledOnce();+ expect(firstIsCurrent).toBe(false);+ });++ it("runs registered cancellation immediately for an already stale request", async () => {+ const cancel = vi.fn();+ let registerLateCancel: (() => void) | undefined;++ runSidebarDataOpenImmediately((request) => {+ registerLateCancel = () => request.registerCancel(cancel);+ });+ runSidebarDataOpenImmediately(() => undefined);+ registerLateCancel?.();+ await Promise.resolve();++ expect(cancel).toHaveBeenCalledOnce();+ });++ it("recovers after a runner throws synchronously", async () => {+ const nextRunner = vi.fn();++ runSidebarDataOpenImmediately(() => {+ throw new Error("boom");+ });+ await Promise.resolve();+ runSidebarDataOpenImmediately(nextRunner);+ await Promise.resolve();++ expect(nextRunner).toHaveBeenCalledOnce();+ });++ it("keeps only the newest rapid navigation request current", async () => {+ const states: boolean[] = [];+ const captures: Array<() => void> = [];++ for (let index = 0; index < 3; index += 1) {+ runSidebarDataOpenImmediately((request) => {+ captures.push(() => states.push(request.isCurrent()));+ });+ }+ captures.forEach((capture) => capture());++ expect(states).toEqual([false, false, true]);+ });++ it("does not cancel work that was not registered as sidebar-owned", async () => {+ const sidebarCancel = vi.fn();+ const unrelatedEditorCancel = vi.fn();++ runSidebarDataOpenImmediately((request) => request.registerCancel(sidebarCancel));+ runSidebarDataOpenImmediately(() => undefined);+ await Promise.resolve();++ expect(sidebarCancel).toHaveBeenCalledOnce();+ expect(unrelatedEditorCancel).not.toHaveBeenCalled();+ });++ it("prevents a superseded connection completion from becoming current", async () => {+ let finishConnection: (() => void) | undefined;+ let completionWasCurrent = true;++ runSidebarDataOpenImmediately(async (request) => {+ await new Promise<void>((resolve) => {+ finishConnection = resolve;+ });+ completionWasCurrent = request.isCurrent();+ });+ runSidebarDataOpenImmediately(() => undefined);+ finishConnection?.();+ await Promise.resolve();+ await Promise.resolve();++ expect(completionWasCurrent).toBe(false);+ });+});diff --git a/apps/desktop/src/lib/app/pinnedItems.ts b/apps/desktop/src/lib/app/pinnedItems.tsindex 2e6dc6ac57..0c419cc87e 100644--- a/apps/desktop/src/lib/app/pinnedItems.ts+++ b/apps/desktop/src/lib/app/pinnedItems.ts@@ -2,6 +2,33 @@ import type { TreeNode } from "@/types/database";export type PinnedTreeNodeUpdateScope = "missing" | "root" | "siblings";+export function treeNodePinKey(node: TreeNode): string {+ if (!node.connectionId) return node.id;+ const identity = [node.database || "", node.schema || "", node.catalog || "", node.type, node.objectName || node.tableName || node.label, node.signature || "", node.id];+ return `${node.connectionId}:pin:v2:${encodeURIComponent(JSON.stringify(identity))}`;+}++export function migrateLegacyPinnedTreeNodeIds(nodes: readonly TreeNode[], pinnedIds: Set<string>): { ids: Set<string>; changed: boolean } {+ const next = new Set(pinnedIds);+ let changed = false;+ const visit = (items: readonly TreeNode[]) => {+ for (const node of items) {+ const pinKey = treeNodePinKey(node);+ if (pinKey !== node.id && next.has(node.id) && !next.has(pinKey)) {+ // A legacy id cannot distinguish colliding nodes. Claim it once for the+ // first matching loaded node, then persist the fully scoped identity.+ next.delete(node.id);+ next.add(pinKey);+ changed = true;+ }+ if (node.children) visit(node.children);+ if (node.hiddenChildren) visit(node.hiddenChildren);+ }+ };+ visit(nodes);+ return { ids: next, changed };+}+export function orderPinnedFirst<T>(items: T[], isPinned: (item: T) => boolean): T[] {const pinned: T[] = [];const unpinned: T[] = [];@@ -14,19 +41,20 @@ export function orderPinnedFirst<T>(items: T[], isPinned: (item: T) => boolean):return [...pinned, ...unpinned];}-function findTreeNodeLocation(nodes: TreeNode[], id: string, parent: TreeNode | null = null): { node: TreeNode; parent: TreeNode | null } | null {+function findTreeNodeLocation(nodes: TreeNode[], target: TreeNode, parent: TreeNode | null = null): { node: TreeNode; parent: TreeNode | null } | null {+ const targetKey = treeNodePinKey(target);for (const node of nodes) {- if (node.id === id) return { node, parent };+ if (node === target || treeNodePinKey(node) === targetKey) return { node, parent };if (node.children) {- const found = findTreeNodeLocation(node.children, id, node);+ const found = findTreeNodeLocation(node.children, target, node);if (found) return found;}}return null;}-export function updatePinnedTreeNodeInPlace(nodes: TreeNode[], id: string, pinned: boolean): PinnedTreeNodeUpdateScope {- const location = findTreeNodeLocation(nodes, id);+export function updatePinnedTreeNodeInPlace(nodes: TreeNode[], target: TreeNode, pinned: boolean): PinnedTreeNodeUpdateScope {+ const location = findTreeNodeLocation(nodes, target);if (!location) return "missing";location.node.pinned = pinned;@@ -42,13 +70,47 @@ export function updatePinnedTreeNodeInPlace(nodes: TreeNode[], id: string, pinnereturn "root";}-export function applyPinnedTreeNodeState(nodes: TreeNode[], pinnedIds: Set<string>): TreeNode[] {+function clonePinnedTreeNode(node: TreeNode, pinnedIds: Set<string>, clones: WeakMap<TreeNode, TreeNode>): TreeNode {+ const existing = clones.get(node);+ if (existing) return existing;+ const clone: TreeNode = {+ ...node,+ pinned: pinnedIds.has(treeNodePinKey(node)) || pinnedIds.has(node.id),+ };+ clones.set(node, clone);+ if (node.children) clone.children = applyPinnedTreeNodeStateInternal(node.children, pinnedIds, clones);+ if (node.hiddenChildren) clone.hiddenChildren = applyPinnedTreeNodeStateInternal(node.hiddenChildren, pinnedIds, clones);+ return clone;+}++function applyPinnedTreeNodeStateInternal(nodes: TreeNode[], pinnedIds: Set<string>, clones: WeakMap<TreeNode, TreeNode>): TreeNode[] {return orderPinnedFirst(- nodes.map((node) => ({- ...node,- pinned: pinnedIds.has(node.id),- children: node.children ? applyPinnedTreeNodeState(node.children, pinnedIds) : node.children,- })),+ nodes.map((node) => clonePinnedTreeNode(node, pinnedIds, clones)),(node) => !!node.pinned,);}++export function applyPinnedTreeNodeState(nodes: TreeNode[], pinnedIds: Set<string>): TreeNode[] {+ return applyPinnedTreeNodeStateInternal(nodes, pinnedIds, new WeakMap());+}++function syncPinnedTreeNodeStateInPlaceInternal(nodes: TreeNode[], pinnedIds: Set<string>, visited: WeakSet<TreeNode>): void {+ for (const node of nodes) {+ if (visited.has(node)) continue;+ visited.add(node);+ node.pinned = pinnedIds.has(treeNodePinKey(node)) || pinnedIds.has(node.id);+ if (node.children) {+ syncPinnedTreeNodeStateInPlaceInternal(node.children, pinnedIds, visited);+ node.children = orderPinnedFirst(node.children, (child) => !!child.pinned);+ }+ if (node.hiddenChildren) {+ syncPinnedTreeNodeStateInPlaceInternal(node.hiddenChildren, pinnedIds, visited);+ node.hiddenChildren = orderPinnedFirst(node.hiddenChildren, (child) => !!child.pinned);+ }+ }+ nodes.splice(0, nodes.length, ...orderPinnedFirst(nodes, (node) => !!node.pinned));+}++export function syncPinnedTreeNodeStateInPlace(nodes: TreeNode[], pinnedIds: Set<string>): void {+ syncPinnedTreeNodeStateInPlaceInternal(nodes, pinnedIds, new WeakSet());+}diff --git a/apps/desktop/src/lib/sidebar/sidebarActionTarget.ts b/apps/desktop/src/lib/sidebar/sidebarActionTarget.tsnew file mode 100644index 0000000000..b08b2d7391--- /dev/null+++ b/apps/desktop/src/lib/sidebar/sidebarActionTarget.ts@@ -0,0 +1,45 @@+import type { TreeNode } from "@/types/database";++export type SidebarActionTarget = Readonly<TreeNode>;++export interface SidebarActionRequest<TPayload = undefined> {+ target: SidebarActionTarget;+ selectedNodeIds: readonly string[];+ payload: TPayload;+}++function sameActionTarget(left: TreeNode, right: SidebarActionTarget): boolean {+ return left.id === right.id && left.type === right.type && left.connectionId === right.connectionId && left.database === right.database && left.schema === right.schema && left.catalog === right.catalog && left.label === right.label && left.signature === right.signature;+}++export function findSidebarActionTarget(nodes: readonly TreeNode[], target: SidebarActionTarget): TreeNode | null {+ const visited = new WeakSet<TreeNode>();+ const find = (items: readonly TreeNode[]): TreeNode | null => {+ for (const node of items) {+ if (visited.has(node)) continue;+ visited.add(node);+ if (sameActionTarget(node, target)) return node;+ const child = node.children ? find(node.children) : null;+ if (child) return child;+ const hiddenChild = node.hiddenChildren ? find(node.hiddenChildren) : null;+ if (hiddenChild) return hiddenChild;+ }+ return null;+ };+ return find(nodes);+}++export function createSidebarActionTarget(node: TreeNode): SidebarActionTarget {+ // Virtual rows can be recycled while an async dialog is opening, so actions+ // must never retain the mutable row node or its potentially large child tree.+ const meta = node.meta && typeof node.meta === "object" ? Object.freeze({ ...node.meta }) : node.meta;+ return Object.freeze({ ...node, children: undefined, hiddenChildren: undefined, meta });+}++export function createSidebarActionRequest<TPayload>(node: TreeNode, selectedNodeIds: readonly string[], payload: TPayload): SidebarActionRequest<TPayload> {+ return Object.freeze({+ target: createSidebarActionTarget(node),+ selectedNodeIds: Object.freeze([...selectedNodeIds]),+ payload,+ });+}diff --git a/apps/desktop/src/lib/sidebar/sidebarDangerDialog.ts b/apps/desktop/src/lib/sidebar/sidebarDangerDialog.tsnew file mode 100644index 0000000000..5a10a6bea9--- /dev/null+++ b/apps/desktop/src/lib/sidebar/sidebarDangerDialog.ts@@ -0,0 +1,22 @@+import type { SidebarActionTarget } from "@/lib/sidebar/sidebarActionTarget";++export interface SidebarDangerDialogOption {+ checked: boolean;+ label: string;+ hint: string;+ onChange?: (checked: boolean) => void | Promise<void>;+}++export interface SidebarDangerDialogRequest {+ target: SidebarActionTarget;+ title: string;+ message: string;+ confirmLabel: string;+ sql?: string;+ details?: string;+ detailsText?: string;+ loading?: boolean;+ closeOnConfirm?: boolean;+ option?: SidebarDangerDialogOption;+ confirm: () => void | Promise<void>;+}diff --git a/apps/desktop/src/lib/sidebar/sidebarDataOpenCoordinator.ts b/apps/desktop/src/lib/sidebar/sidebarDataOpenCoordinator.tsnew file mode 100644index 0000000000..53365ffe9e--- /dev/null+++ b/apps/desktop/src/lib/sidebar/sidebarDataOpenCoordinator.ts@@ -0,0 +1,60 @@+export interface SidebarDataOpenRequest {+ isCurrent: () => boolean;+ registerCancel: (cancel: () => void | Promise<void>) => void;+}++type OpenDataRunner = (request: SidebarDataOpenRequest) => void | Promise<void>;++let generation = 0;+let activeGeneration = 0;+let activeCancel: (() => void | Promise<void>) | null = null;++function runCancellation(cancel: (() => void | Promise<void>) | null) {+ if (!cancel) return;+ void Promise.resolve(cancel()).catch(() => undefined);+}++function supersedeCurrentRequest(): number {+ generation += 1;+ runCancellation(activeCancel);+ activeCancel = null;+ activeGeneration = 0;+ return generation;+}++function executeRequest(requestGeneration: number, runner: OpenDataRunner) {+ if (requestGeneration !== generation) return;+ const request: SidebarDataOpenRequest = {+ isCurrent: () => requestGeneration === generation,+ registerCancel: (cancel) => {+ if (requestGeneration !== generation) {+ runCancellation(cancel);+ return;+ }+ activeGeneration = requestGeneration;+ activeCancel = cancel;+ },+ };+ let result: void | Promise<void>;+ try {+ result = runner(request);+ } catch {+ result = undefined;+ }+ void Promise.resolve(result)+ .catch(() => undefined)+ .finally(() => {+ if (activeGeneration !== requestGeneration) return;+ activeGeneration = 0;+ activeCancel = null;+ });+}++export function runSidebarDataOpenImmediately(runner: OpenDataRunner) {+ const requestGeneration = supersedeCurrentRequest();+ executeRequest(requestGeneration, runner);+}++export function cancelPendingSidebarDataOpen() {+ supersedeCurrentRequest();+}diff --git a/apps/desktop/src/lib/sidebar/sidebarDatabaseOpenState.ts b/apps/desktop/src/lib/sidebar/sidebarDatabaseOpenState.tsindex 740d88d4c5..8fa06960e9 100644--- a/apps/desktop/src/lib/sidebar/sidebarDatabaseOpenState.ts+++ b/apps/desktop/src/lib/sidebar/sidebarDatabaseOpenState.ts@@ -4,6 +4,6 @@ export function isSidebarDatabaseOpened(node: TreeNode, isTreeNodeChildrenLoadedreturn (node.type === "database" || node.type === "mongo-db" || node.type === "vector-database") && !!node.connectionId && node.database != null && isTreeNodeChildrenLoaded(node.id);}-export function canCloseSidebarDatabaseConnection(node: TreeNode, isTreeNodeChildrenLoaded: (nodeId: string) => boolean): boolean {- return node.type === "database" && !!node.connectionId && node.database != null && isTreeNodeChildrenLoaded(node.id);+export function canCloseSidebarDatabaseConnection(node: TreeNode, isTreeNodeChildrenLoaded: (nodeId: string) => boolean, isDatabaseUsedByOpenTab: (connectionId: string, database: string) => boolean = () => false): boolean {+ return node.type === "database" && !!node.connectionId && node.database != null && (isTreeNodeChildrenLoaded(node.id) || isDatabaseUsedByOpenTab(node.connectionId, node.database));}diff --git a/apps/desktop/src/lib/tabs/dataTabActivation.ts b/apps/desktop/src/lib/tabs/dataTabActivation.tsindex 7ab657ea3d..ddf5aae3ee 100644--- a/apps/desktop/src/lib/tabs/dataTabActivation.ts+++ b/apps/desktop/src/lib/tabs/dataTabActivation.ts@@ -4,8 +4,8 @@ function isErrorResult(result: QueryResult | undefined): boolean {return result?.columns.length === 1 && result.columns[0] === "Error";}-export function canActivateExistingDataTableTab(tab: QueryTab): boolean {- if (tab.isExecuting) return true;+export function canActivateExistingDataTableTab(tab: QueryTab, options: { activateExecuting?: boolean } = {}): boolean {+ if (tab.isExecuting) return options.activateExecuting !== false;if (isErrorResult(tab.result)) return false;return !!tab.result || !!tab.results?.length;}diff --git a/apps/desktop/src/stores/connectionStore.ts b/apps/desktop/src/stores/connectionStore.tsindex a04111dc62..518b1addf8 100644--- a/apps/desktop/src/stores/connectionStore.ts+++ b/apps/desktop/src/stores/connectionStore.ts@@ -2,7 +2,7 @@ import { defineStore } from "pinia";import { uuid } from "@/lib/common/utils";import { ref, computed, watch, markRaw } from "vue";import type { ColumnInfo, CompletionAssistantCandidate, CompletionAssistantObjectKind, CompletionAssistantRequest, ConnectionConfig, CatalogInfo, ForeignKeyInfo, ObjectInfo, SchemaInfo, SidebarLayout, TableInfo, TreeNode, TunnelProfile, VectorCollectionMeta } from "@/types/database";-import { applyPinnedTreeNodeState, updatePinnedTreeNodeInPlace } from "@/lib/app/pinnedItems";+import { applyPinnedTreeNodeState, migrateLegacyPinnedTreeNodeIds, syncPinnedTreeNodeStateInPlace, treeNodePinKey } from "@/lib/app/pinnedItems";import {reconcileLayout,buildTreeNodesFromLayout,@@ -912,8 +912,9 @@ export const useConnectionStore = defineStore("connection", () => {localStorage.setItem(PINNED_TREE_NODES_STORAGE_KEY, JSON.stringify([...pinnedTreeNodeIds.value]));}- function isTreeNodePinned(id: string): boolean {- return pinnedTreeNodeIds.value.has(id);+ function isTreeNodePinned(node: TreeNode | string): boolean {+ if (typeof node === "string") return pinnedTreeNodeIds.value.has(node);+ return pinnedTreeNodeIds.value.has(treeNodePinKey(node)) || pinnedTreeNodeIds.value.has(node.id);}function isConnectionUtilityNode(node: TreeNode): boolean {@@ -972,7 +973,12 @@ export const useConnectionStore = defineStore("connection", () => {return child;});}- parent.children = markRawLeafTreeNodes(applyPinnedTreeNodeState(children, pinnedTreeNodeIds.value));+ const migratedPins = migrateLegacyPinnedTreeNodeIds(children, pinnedTreeNodeIds.value);+ if (migratedPins.changed) {+ pinnedTreeNodeIds.value = migratedPins.ids;+ persistPinnedTreeNodeIds();+ }+ parent.children = markRawLeafTreeNodes(applyPinnedTreeNodeState(children, migratedPins.ids));loadedTreeNodeChildrenIds.value.add(parent.id);}@@ -1584,15 +1590,21 @@ export const useConnectionStore = defineStore("connection", () => {return null;}- function toggleTreeNodePin(id: string) {+ function toggleTreeNodePin(node: TreeNode) {+ const pinKey = treeNodePinKey(node);const next = new Set(pinnedTreeNodeIds.value);- if (next.has(id)) next.delete(id);- else next.add(id);+ const wasPinned = next.has(pinKey) || next.has(node.id);+ // Remove the legacy bare id as part of every toggle so old ambiguous pins+ // cannot continue matching objects in a different database.+ next.delete(node.id);+ if (wasPinned) next.delete(pinKey);+ else next.add(pinKey);pinnedTreeNodeIds.value = next;persistPinnedTreeNodeIds();- const scope = updatePinnedTreeNodeInPlace(treeNodes.value, id, next.has(id));- if (scope === "root") rebuildTreeNodes();+ // Pinning is infrequent; synchronizing the loaded tree here also clears any+ // stale flags created by legacy unscoped ids without rebuilding metadata.+ syncPinnedTreeNodeStateInPlace(treeNodes.value, next);}async function addConnection(config: ConnectionConfig, targetGroupId?: string | null) {diff --git a/packages/app-tests/codemirrorSqlDialect.test.ts b/packages/app-tests/codemirrorSqlDialect.test.tsindex f14a387f39..5fb224f55c 100644--- a/packages/app-tests/codemirrorSqlDialect.test.ts+++ b/packages/app-tests/codemirrorSqlDialect.test.ts@@ -85,10 +85,12 @@ test("keeps MySQL-compatible double-dash whitespace rules", () => {test("propagates database type to every DDL viewer entrypoint", () => {const ddlViewDialog = readFileSync("apps/desktop/src/components/objects/DdlViewDialog.vue", "utf8");- const treeItem = readFileSync("apps/desktop/src/components/sidebar/TreeItem.vue", "utf8");+ const connectionTree = readFileSync("apps/desktop/src/components/sidebar/ConnectionTree.vue", "utf8");const app = readFileSync("apps/desktop/src/App.vue", "utf8");assert.match(ddlViewDialog, /createDbxCodeMirrorSqlDialect\(langSql, props\.dialect, props\.databaseType\)/);- assert.match(treeItem, /<DdlViewDialog[\s\S]*?:database-type="ddlDatabaseType"[\s\S]*?v-model:open="showDdlDialog"/);+ assert.match(connectionTree, /<SidebarDdlViewDialog/);+ assert.match(connectionTree, /:database-type="sidebarDdlDatabaseType"/);+ assert.match(connectionTree, /v-model:open="sidebarDdlOpen"/);assert.match(app, /<DdlViewDialog[^>]*:database-type="queryEditorDdlDatabaseType"[^>]*\/>/);});diff --git a/packages/app-tests/dataTabActivation.test.ts b/packages/app-tests/dataTabActivation.test.tsindex 82652e21f1..efbc8408e0 100644--- a/packages/app-tests/dataTabActivation.test.ts+++ b/packages/app-tests/dataTabActivation.test.ts@@ -22,6 +22,10 @@ test("activates an existing data table tab while it is still loading", () => {assert.equal(canActivateExistingDataTableTab(dataTab({ isExecuting: true })), true);});+test("sidebar can restart a loading tab after superseding its request", () => {+ assert.equal(canActivateExistingDataTableTab(dataTab({ isExecuting: true }), { activateExecuting: false }), false);+});+test("activates an existing data table tab with a usable result", () => {assert.equal(canActivateExistingDataTableTab(diff --git a/packages/app-tests/sidebarContextMenuHost.test.ts b/packages/app-tests/sidebarContextMenuHost.test.tsnew file mode 100644index 0000000000..a828607b75--- /dev/null+++ b/packages/app-tests/sidebarContextMenuHost.test.ts@@ -0,0 +1,38 @@+import { strict as assert } from "node:assert";+import { readFileSync } from "node:fs";+import { test } from "vitest";++test("tree-level context menu opens with the current row items atomically", () => {+ const connectionTree = readFileSync("apps/desktop/src/components/sidebar/ConnectionTree.vue", "utf8");+ const contextMenu = readFileSync("apps/desktop/src/components/ui/CustomContextMenu.vue", "utf8");++ assert.match(connectionTree, /openContextMenu\(event, items\)/);+ assert.match(connectionTree, /sidebarContextMenuRef\.value\?\.close\(\)/);+ assert.match(connectionTree, /sidebarContextMenuTarget\.value = createSidebarActionTarget\(node\)/);+ assert.match(connectionTree, /sidebarContextMenuTarget\.value = null/);+ assert.match(connectionTree, /<CustomContextMenu ref="sidebarContextMenuRef"/);+ assert.match(contextMenu, /function onContextMenu\(event: MouseEvent, itemsOverride\?: ContextMenuItem\[\]\)/);+ assert.match(contextMenu, /const items = itemsOverride \?\?/);+ assert.match(contextMenu, /defineExpose\(\{ close \}\)/);+});++test("rare sidebar dialogs share module-level async wrappers with fallbacks", () => {+ const treeItem = readFileSync("apps/desktop/src/components/sidebar/TreeItem.vue", "utf8");+ const asyncDialogs = readFileSync("apps/desktop/src/components/sidebar/sidebarAsyncDialogs.ts", "utf8");++ assert.doesNotMatch(treeItem, /defineAsyncComponent/);+ assert.match(asyncDialogs, /loadingComponent: SidebarAsyncDialogLoading/);+ assert.match(asyncDialogs, /errorComponent: SidebarAsyncDialogError/);+ assert.match(asyncDialogs, /timeout: 15_000/);+});++test("tree host owns sidebar data-open generations", () => {+ const treeItem = readFileSync("apps/desktop/src/components/sidebar/TreeItem.vue", "utf8");+ const connectionTree = readFileSync("apps/desktop/src/components/sidebar/ConnectionTree.vue", "utf8");++ assert.doesNotMatch(treeItem, /runSidebarDataOpenImmediately/);+ assert.match(treeItem, /emit\("open-data", node, true, openData\)/);+ assert.match(connectionTree, /function openSidebarData/);+ assert.match(connectionTree, /runSidebarDataOpenImmediately/);+ assert.match(connectionTree, /createSidebarActionTarget\(node\)/);+});diff --git a/packages/app-tests/sidebarDatabaseOpenState.test.ts b/packages/app-tests/sidebarDatabaseOpenState.test.tsindex 0da6e0c2c5..0ed201fd69 100644--- a/packages/app-tests/sidebarDatabaseOpenState.test.ts+++ b/packages/app-tests/sidebarDatabaseOpenState.test.ts@@ -41,3 +41,12 @@ test("non-SQL database nodes can be marked open without showing close database cassert.equal(isSidebarDatabaseOpened(mongoDatabase, isLoaded), true);assert.equal(canCloseSidebarDatabaseConnection(mongoDatabase, isLoaded), false);});++test("database connections can be closed while an open tab still uses the database", () => {+ const node = databaseNode("conn-1:app");++ assert.equal(+ canCloseSidebarDatabaseConnection(node, () => false, (connectionId, database) => connectionId === "conn-1" && database === "app"),+ true,+ );+});diff --git a/packages/app-tests/sidebarDialogRouting.test.ts b/packages/app-tests/sidebarDialogRouting.test.tsnew file mode 100644index 0000000000..292524ae7b--- /dev/null+++ b/packages/app-tests/sidebarDialogRouting.test.ts@@ -0,0 +1,55 @@+import { strict as assert } from "node:assert";+import { readFileSync } from "node:fs";+import { test } from "vitest";++const connectionTree = readFileSync("apps/desktop/src/components/sidebar/ConnectionTree.vue", "utf8");+const treeItem = readFileSync("apps/desktop/src/components/sidebar/TreeItem.vue", "utf8");+const dialogHost = readFileSync("apps/desktop/src/components/sidebar/SidebarTreeItemDialogs.vue", "utf8");+const dialogState = readFileSync("apps/desktop/src/components/sidebar/sidebarTreeDialogState.ts", "utf8");++function occurrences(source: string, value: string): number {+ return source.split(value).length - 1;+}++test("sidebar routes destructive confirmations through one tree-level host", () => {+ assert.match(treeItem, /emit\("open-danger-dialog", route\.createRequest\(\)\)/);+ assert.match(connectionTree, /function openSidebarDangerDialog\(request: SidebarDangerDialogRequest\)/);+ assert.equal(occurrences(connectionTree, "<SidebarDangerConfirmDialog"), 1);+ assert.doesNotMatch(treeItem, /<DangerConfirmDialog/);+});++test("tree-level danger routing preserves cancel and close-on-confirm behavior", () => {+ assert.match(connectionTree, /v-model:open="sidebarDangerDialogOpen"/);+ assert.match(connectionTree, /if \(request\.closeOnConfirm !== false\) sidebarDangerDialogOpen\.value = false/);+ assert.match(connectionTree, /await request\.confirm\(\)/);+ assert.match(connectionTree, /sidebarDangerDialogOpen\.value = false/);+ assert.match(connectionTree, /sidebarDangerDialogConfirming\.value = false/);+});++test("remaining form dialogs render once at tree level and keep confirm/cancel bindings", () => {+ assert.equal(occurrences(connectionTree, "<SidebarTreeItemDialogs"), 1);+ assert.doesNotMatch(treeItem, /<Dialog(?:\s|>)/);+ assert.doesNotMatch(treeItem, /<InstallExtensionDialog/);+ assert.match(dialogHost, /v-model:open="showCreateDatabaseDialog"/);+ assert.match(dialogHost, /@click="showCreateDatabaseDialog = false"/);+ assert.match(dialogHost, /@click="confirmCreateDatabase"/);+ assert.match(dialogHost, /v-model:open="showPasteDialog"/);+ assert.match(dialogHost, /@click="confirmPasteTable"/);+});++test("saved object dialogs refresh the immutable active target", () => {+ assert.match(connectionTree, /<SidebarObjectSourceDialog[\s\S]*?@saved="refreshSidebarActionTarget"/);+ assert.match(connectionTree, /<InstallExtensionDialog[\s\S]*?@close="refreshSidebarActionTarget"/);+ assert.match(connectionTree, /findSidebarActionTarget\(store\.treeNodes, target\)/);+});++test("shared dialog state is owner-gated and confirm handlers use snapshots", () => {+ assert.match(dialogState, /export const sidebarTreeDialogOwner = shallowRef<symbol \| null>\(null\)/);+ assert.match(dialogState, /export const sidebarDangerTarget = shallowRef<TreeNode \| null>\(null\)/);+ assert.match(dialogState, /export const sidebarFormTarget = shallowRef<TreeNode \| null>\(null\)/);+ assert.match(treeItem, /sidebarTreeDialogOwner\.value !== treeItemDialogOwner/);+ assert.match(treeItem, /const node = sidebarDangerTarget\.value \?\? props\.node/);+ assert.match(treeItem, /const node = sidebarFormTarget\.value \?\? props\.node/);+ assert.match(treeItem, /batchDropTargets\.value = targets\.slice\(\)/);+ assert.match(treeItem, /batchTruncateTargets\.value = targets\.slice\(\)/);+});diff --git a/packages/app-tests/sidebarLargeTree.test.ts b/packages/app-tests/sidebarLargeTree.test.tsnew file mode 100644index 0000000000..02fdafe2b9--- /dev/null+++ b/packages/app-tests/sidebarLargeTree.test.ts@@ -0,0 +1,54 @@+import { strict as assert } from "node:assert";+import { test } from "vitest";+import { createFlatTreeIndex, flattenTree } from "../../apps/desktop/src/composables/useFlatTree.ts";+import { filterSidebarTree } from "../../apps/desktop/src/lib/sidebar/sidebarSearchTree.ts";+import { scrollTopForSidebarNode } from "../../apps/desktop/src/lib/sidebar/sidebarActiveTabTarget.ts";+import type { TreeNode } from "../../apps/desktop/src/types/database.ts";++function largeTree(): TreeNode[] {+ return Array.from({ length: 5 }, (_, connectionIndex) => ({+ id: `connection-${connectionIndex}`,+ label: `connection-${connectionIndex}`,+ type: "connection" as const,+ isExpanded: true,+ children: Array.from({ length: 5 }, (_, databaseIndex) => ({+ id: `connection-${connectionIndex}:database-${databaseIndex}`,+ label: `database-${databaseIndex}`,+ type: "database" as const,+ connectionId: `connection-${connectionIndex}`,+ database: `database-${databaseIndex}`,+ isExpanded: true,+ children: Array.from({ length: 500 }, (_, tableIndex) => ({+ id: `connection-${connectionIndex}:database-${databaseIndex}:table-${tableIndex}`,+ label: `table_${connectionIndex}_${databaseIndex}_${tableIndex}`,+ type: "table" as const,+ connectionId: `connection-${connectionIndex}`,+ database: `database-${databaseIndex}`,+ })),+ })),+ }));+}++test("large sidebar tree keeps expansion, filtering and scroll indexes consistent", () => {+ const tree = largeTree();+ const flat = flattenTree(tree);+ const index = createFlatTreeIndex(flat, {+ isSelectable: () => true,+ isBoundary: (type) => type === "connection" || type === "connection-group",+ isDatabaseContainer: (type) => type === "database",+ isSchemaContainer: (type) => type === "schema",+ });++ assert.equal(flat.length, 12_530);+ const targetId = "connection-4:database-4:table-499";+ const targetIndex = index.flatNodeIndexById.get(targetId);+ assert.equal(typeof targetIndex, "number");+ assert.equal(index.nodeById.get(targetId)?.label, "table_4_4_499");+ assert.ok(scrollTopForSidebarNode({ index: targetIndex!, currentScrollTop: 0, viewportHeight: 560 }) > 0);++ const filtered = flattenTree(filterSidebarTree(tree, "table_4_4_499", new Set()));+ assert.deepEqual(+ filtered.map((item) => item.id),+ ["connection-4", "connection-4:database-4", targetId],+ );+});diff --git a/packages/app-tests/sidebarTreeAffordances.test.ts b/packages/app-tests/sidebarTreeAffordances.test.tsnew file mode 100644index 0000000000..1555594e00--- /dev/null+++ b/packages/app-tests/sidebarTreeAffordances.test.ts@@ -0,0 +1,24 @@+import { strict as assert } from "node:assert";+import { readFileSync } from "node:fs";+import { test } from "vitest";++const treeItem = readFileSync("apps/desktop/src/components/sidebar/TreeItem.vue", "utf8");+const connectionTree = readFileSync("apps/desktop/src/components/sidebar/ConnectionTree.vue", "utf8");++test("sidebar rows retain database-specific node affordances", () => {+ for (const nodeType of ["connection", "database", "schema", "table", "column", "mongo-db", "mongo-collection", "redis-db", "nacos-namespace", "mq-tenant"]) {+ assert.ok(treeItem.includes(`node.type === "${nodeType}"`) || treeItem.includes(`node.type === '${nodeType}'`), nodeType);+ }+ assert.match(treeItem, /@dblclick="onDoubleClick"/);+ assert.match(treeItem, /@keydown="onKeydown"/);+ assert.match(treeItem, /@mousedown="onRowMouseDown"/);+ assert.match(treeItem, /@contextmenu="onTreeItemContextMenu"/);+});++test("complex tree changes retain the full rebuild fallback", () => {+ assert.match(connectionTree, /const filteredNodes = computed/);+ assert.match(connectionTree, /filterSidebarTree\(/);+ assert.match(connectionTree, /const flatNodes = computed<FlatTreeNode\[]>/);+ assert.match(connectionTree, /flattenTree\(filteredNodes\.value\)/);+ assert.match(connectionTree, /watch\(flatNodes,/);+});diff --git a/packages/app-tests/sidebarTreeItemCleanup.test.ts b/packages/app-tests/sidebarTreeItemCleanup.test.tsnew file mode 100644index 0000000000..26afae80cd--- /dev/null+++ b/packages/app-tests/sidebarTreeItemCleanup.test.ts@@ -0,0 +1,26 @@+import { strict as assert } from "node:assert";+import { readFileSync } from "node:fs";+import { test } from "vitest";++const treeItem = readFileSync("apps/desktop/src/components/sidebar/TreeItem.vue", "utf8");++test("recycled sidebar rows re-register paste handlers by node id", () => {+ assert.match(treeItem, /watch\(\s*\(\) => props\.node\.id,/);+ assert.match(treeItem, /registerPasteHandler\?\.\(nodeId, requestPasteTreeClipboard\)/);+ assert.match(treeItem, /if \(unregister\) onCleanup\(unregister\)/);+});++test("sidebar row unmount clears observers, handlers and drag state", () => {+ assert.match(treeItem, /function handleMouseLeave\(\)[\s\S]*?labelResizeObserver\?\.disconnect\(\)/);+ assert.match(treeItem, /function finishTableReferenceDrag\(\)[\s\S]*?document\.removeEventListener\("mousemove"/);+ assert.match(treeItem, /onBeforeUnmount\(\(\) => \{[\s\S]*?handleMouseLeave\(\)[\s\S]*?stopPasteHandlerRegistration\(\)[\s\S]*?finishTableReferenceDrag\(\)/);+ assert.match(treeItem, /stopDangerDialogRouting\?\.\(\)/);+});++test("sidebar rows do not own dialog templates or eager dialog state", () => {+ assert.doesNotMatch(treeItem, /<Dialog(?:\s|>)/);+ assert.doesNotMatch(treeItem, /<DangerConfirmDialog/);+ assert.doesNotMatch(treeItem, /const show[A-Z][A-Za-z]+(?:Dialog|Confirm) = ref\(/);+ assert.match(treeItem, /function getTreeItemDialogController\(\)/);+ assert.match(treeItem, /if \(treeItemDialogController\) return treeItemDialogController/);+});