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
feat(sidebar): add shortcut to open the table structure editor
lxk9556b1d4fa64ce1
diff --git a/apps/desktop/src/components/layout/AppSidebar.vue b/apps/desktop/src/components/layout/AppSidebar.vueindex 44fc73876c..d53d780115 100644--- a/apps/desktop/src/components/layout/AppSidebar.vue+++ b/apps/desktop/src/components/layout/AppSidebar.vue@@ -203,7 +203,11 @@ function confirmCreateSelectedGroup() {showCreateSelectedGroupDialog.value = false;}-defineExpose({ focusSearch, locateTabInSidebar, disconnectAllActiveConnections });+function openTableStructureForSelection(): boolean {+ return connectionTreeRef.value?.openTableStructureForSelection?.() ?? false;+}++defineExpose({ focusSearch, locateTabInSidebar, disconnectAllActiveConnections, openTableStructureForSelection });</script><template>diff --git a/apps/desktop/src/components/sidebar/ConnectionTree.vue b/apps/desktop/src/components/sidebar/ConnectionTree.vueindex bb46873adb..fc30bb9154 100644--- a/apps/desktop/src/components/sidebar/ConnectionTree.vue+++ b/apps/desktop/src/components/sidebar/ConnectionTree.vue@@ -32,7 +32,7 @@ import { needsSidebarObjectGroupDiscovery } from "@/lib/sidebar/sidebarSearchDisimport { isSidebarSearchPrunedDatabaseNode, resolveSidebarSearchDatabaseScope } from "@/lib/sidebar/sidebarSearchDatabaseScope";import { createSidebarSearchExpansionState } from "@/lib/sidebar/sidebarSearchExpansionState";import { createSidebarSearchLoadingTracker } from "@/lib/sidebar/sidebarSearchLoadingTracker";-import { isCancelSearchShortcut, isCopySidebarSelectionShortcut, isDisconnectSidebarConnectionShortcut, isEditSidebarConnectionShortcut, isPasteSidebarSelectionShortcut, isViewTableDdlShortcut } from "@/lib/editor/keyboardShortcuts";+import { isCancelSearchShortcut, isCopySidebarSelectionShortcut, isDisconnectSidebarConnectionShortcut, isEditSidebarConnectionShortcut, isEditSidebarTableStructureShortcut, isPasteSidebarSelectionShortcut, isViewTableDdlShortcut } from "@/lib/editor/keyboardShortcuts";import { sidebarNodeSupportsDdlView } from "@/lib/sidebar/sidebarTreeDdlShortcut";import { hasTreeNodeDatabaseContext } from "@/lib/sidebar/treeNodeContext";import { objectSourceTargetForTreeNode } from "@/lib/sidebar/treeNodeClick";@@ -2204,6 +2204,13 @@ function openSidebarDdlForSelection(): boolean {return true;}+function openSidebarTableStructureForSelection(): boolean {+ const selectedNodeId = store.selectedTreeNodeId;+ const node = selectedNodeId ? flatTreeIndex.value.nodeById.get(selectedNodeId) : null;+ if (!node) return false;+ return sidebarTreeRuntimeHostRef.value?.openStructureEditorForSelection?.(node) ?? false;+}+function openSidebarElasticsearchIndexMetadata(node: TreeNode, kind: ElasticsearchIndexMetadataKind) {if (!node.connectionId) return;beginSidebarAction();@@ -2523,6 +2530,13 @@ function onWindowKeydown(event: KeyboardEvent) {}return;}+ if (sidebarShortcutTargetAllowsAppShortcut(event.target) && isEditSidebarTableStructureShortcut(event, settingsStore.editorSettings.shortcuts)) {+ if (openSidebarTableStructureForSelection()) {+ event.preventDefault();+ event.stopPropagation();+ }+ return;+ }}if (!pointerInsideTree.value || isEditableSidebarTypeSearchTarget(event.target) || isEditableSidebarTypeSearchTarget(document.activeElement)) return;@@ -2691,7 +2705,7 @@ onUnmounted(() => {if (sidebarTreeContentMeasureFrame) window.cancelAnimationFrame(sidebarTreeContentMeasureFrame);});-defineExpose({ focusSearch, createNewGroup, collapseAllTreeNodes, locateTabInSidebar, disconnectAllActiveConnections });+defineExpose({ focusSearch, createNewGroup, collapseAllTreeNodes, locateTabInSidebar, disconnectAllActiveConnections, openTableStructureForSelection: openSidebarTableStructureForSelection });</script><template>diff --git a/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue b/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vueindex 0615597fd7..953a5ac85d 100644--- a/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue+++ b/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue@@ -162,8 +162,9 @@ import {import { customTypeCapabilities, supportsTypeObjectSource } from "@/lib/database/databaseObjectCapabilities";import { mongoCollectionTableTypeFromNode, mongoCreateDatabasePreview, mongoDropIndexFailureCount } from "@/lib/sidebar/mongoCollectionMutation";import { dataTabOpenModeFromTreeClick, type DataTabOpenMode } from "@/lib/sidebar/dataTabOpenPolicy";-import { isCopySidebarSelectionShortcut, isDisconnectSidebarConnectionShortcut, isEditSidebarConnectionShortcut, isModRShortcut, isPasteSidebarSelectionShortcut } from "@/lib/editor/keyboardShortcuts";+import { isCopySidebarSelectionShortcut, isDisconnectSidebarConnectionShortcut, isEditSidebarConnectionShortcut, isEditSidebarTableStructureShortcut, isModRShortcut, isPasteSidebarSelectionShortcut } from "@/lib/editor/keyboardShortcuts";import { handleSidebarTreeDeleteShortcut } from "@/lib/sidebar/sidebarTreeDeleteShortcut";+import { sidebarNodeSupportsStructureEdit } from "@/lib/sidebar/sidebarTreeStructureShortcut";import { dataTableDoubleClickAction } from "@/lib/tabs/dataTabActivation";import { attachedDatabaseNameFromPath, buildCreateDatabaseSql, buildDuckDbAttachDatabaseSql, buildSqliteAttachDatabaseSql, supportsCreateDatabaseCharset, supportsCreateDatabaseLocale, uniqueAttachedDatabaseName } from "@/lib/database/createDatabaseSql";import { appendCreateDatabaseErrorHint } from "@/lib/database/createDatabaseErrorHints";@@ -1339,6 +1340,14 @@ function onKeydown(event: KeyboardEvent) {event.stopPropagation();return;}+ if (isEditSidebarTableStructureShortcut(event, settingsStore.editorSettings.shortcuts)) {+ if (canOpenStructureEditor.value) {+ openStructureEditor();+ event.preventDefault();+ event.stopPropagation();+ return;+ }+ }if (isSidebarTreeArrowKey(event) && handleSidebarTreeArrowKey(event)) {event.preventDefault();event.stopPropagation();@@ -2503,6 +2512,13 @@ async function openDdlForSelection(node: TreeNode, selectedNodeIds: readonly strreturn true;}+function openStructureEditorForSelection(node: TreeNode): boolean {+ activateRuntimeNode(node);+ if (!canOpenStructureEditor.value) return false;+ openStructureEditor();+ return true;+}+function selectedColumnNodes(node: TreeNode): Array<TreeNode & { connectionId: string; database: string; tableName: string }> {if (node.type !== "column" || !node.connectionId || !node.database || !node.tableName) return [];const selectedIds = acceptedSelectionIds ?? connectionStore.selectedTreeNodeIds;@@ -5201,8 +5217,7 @@ const canOpenTableImport = computed(() => {});const canOpenStructureEditor = computed(() => {- const editableNode = activeNode.value.type === "table" || ((activeNode.value.type === "column" || activeNode.value.type === "index") && !!activeNode.value.tableName);- return editableNode && !isSqlServerLinkedNode(activeNode.value) && !!activeNode.value.connectionId && !!activeNode.value.database && supportsTableStructureEditing(currentTableStructureDatabaseType());+ return sidebarNodeSupportsStructureEdit(activeNode.value, currentTableStructureDatabaseType());});const canOpenFieldLineage = computed(() => {@@ -7604,6 +7619,7 @@ defineExpose({openPrimaryVisibleFilter,openDataInNewTab,openDdlForSelection,+ openStructureEditorForSelection,requestPaste,toggleNode,});diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.tsindex 1a3e275b97..fdc0250d3f 100644--- a/apps/desktop/src/i18n/locales/az.ts+++ b/apps/desktop/src/i18n/locales/az.ts@@ -8107,6 +8107,7 @@ export default withEnglishFallback({shortcutDisconnectSidebarConnection: "Yan paneldəki əlaqəni kəs",shortcutOpenDataInNewTab: "Məlumatları yeni vərəqdə aç (siçan klikləməsi)",shortcutViewTableDdl: "Cədvəlin DDL-inə bax",+ shortcutEditSidebarTableStructure: "Cədvəlin quruluşunu redaktə et",shortcutSendSelectionToAi: "Seçimi AI-yə göndər",shortcutToggleAiPanel: "AI panelini aç/bağla",shortcutSqlIntentionActions: "SQL niyyət əməliyyatları (* işarəsini genişləndir / identifikatoru tam adla göstər)",diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.tsindex 627dc287a4..1afe7c61c5 100644--- a/apps/desktop/src/i18n/locales/en.ts+++ b/apps/desktop/src/i18n/locales/en.ts@@ -9261,6 +9261,7 @@ export default {shortcutDisconnectSidebarConnection: "Disconnect sidebar connection",shortcutOpenDataInNewTab: "Open data in new tab (mouse click)",shortcutViewTableDdl: "View table DDL",+ shortcutEditSidebarTableStructure: "Edit table structure",shortcutSendSelectionToAi: "Send selection to AI",shortcutToggleAiPanel: "Toggle AI panel",shortcutSqlIntentionActions: "SQL Intention Actions (Expand * / Qualify Identifier)",diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.tsindex 00b4573048..1285c65616 100644--- a/apps/desktop/src/i18n/locales/es.ts+++ b/apps/desktop/src/i18n/locales/es.ts@@ -8466,6 +8466,7 @@ export default withEnglishFallback({shortcutDisconnectSidebarConnection: "Desconectar conexión de la barra lateral",shortcutOpenDataInNewTab: "Abrir datos en una pestaña nueva (clic del ratón)",shortcutViewTableDdl: "Ver DDL de la tabla",+ shortcutEditSidebarTableStructure: "Editar estructura de tabla",shortcutSendSelectionToAi: "Enviar selección a IA",shortcutToggleAiPanel: "Alternar panel de IA",shortcutSqlIntentionActions: "Acciones de intención SQL (Expandir * / Calificar identificador)",diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.tsindex 9ed77accb0..d474c913c2 100644--- a/apps/desktop/src/i18n/locales/id.ts+++ b/apps/desktop/src/i18n/locales/id.ts@@ -8919,6 +8919,7 @@ export default withEnglishFallback({shortcutDisconnectSidebarConnection: "Putuskan koneksi bilah sisi",shortcutOpenDataInNewTab: "Buka data di tab baru (klik mouse)",shortcutViewTableDdl: "Lihat DDL tabel",+ shortcutEditSidebarTableStructure: "Edit struktur tabel",shortcutSendSelectionToAi: "Kirim seleksi ke AI",shortcutToggleAiPanel: "Aktifkan/nonaktifkan panel AI",shortcutSqlIntentionActions: "Aksi Intensi SQL (Perluas * / Kualifikasi Identifier)",diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.tsindex e5aeab00ea..8a17a3eb88 100644--- a/apps/desktop/src/i18n/locales/it.ts+++ b/apps/desktop/src/i18n/locales/it.ts@@ -8229,6 +8229,7 @@ export default withEnglishFallback({shortcutDisconnectSidebarConnection: "Disconnetti connessione barra laterale",shortcutOpenDataInNewTab: "Apri dati in una nuova scheda (clic del mouse)",shortcutViewTableDdl: "Visualizza DDL tabella",+ shortcutEditSidebarTableStructure: "Modifica struttura tabella",shortcutSendSelectionToAi: "Invia selezione ad AI",shortcutToggleAiPanel: "Attiva/disattiva pannello AI",shortcutSqlIntentionActions: "Azioni di intento SQL (Espandi * / Qualifica identificatore)",diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.tsindex b658ba6f79..67298286ca 100644--- a/apps/desktop/src/i18n/locales/ja.ts+++ b/apps/desktop/src/i18n/locales/ja.ts@@ -8218,6 +8218,7 @@ export default withEnglishFallback({shortcutDisconnectSidebarConnection: "サイドバー接続を切断",shortcutOpenDataInNewTab: "新しいデータタブで開く(マウスクリック)",shortcutViewTableDdl: "テーブルDDLを表示",+ shortcutEditSidebarTableStructure: "テーブル構造を編集",shortcutSendSelectionToAi: "選択範囲をAIに送信",shortcutToggleAiPanel: "AIパネルを切り替え",shortcutSqlIntentionActions: "SQL インテント操作(* の展開 / 識別子の修飾)",diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.tsindex 10e7ed5053..1a39d93395 100644--- a/apps/desktop/src/i18n/locales/ko.ts+++ b/apps/desktop/src/i18n/locales/ko.ts@@ -8111,6 +8111,7 @@ export default withEnglishFallback({shortcutDisconnectSidebarConnection: "사이드바 연결 끊기",shortcutOpenDataInNewTab: "새 탭에서 데이터 열기 (마우스 클릭)",shortcutViewTableDdl: "테이블 DDL 보기",+ shortcutEditSidebarTableStructure: "테이블 구조 편집",shortcutSendSelectionToAi: "선택 영역을 AI로 보내기",shortcutToggleAiPanel: "AI 패널 전환",shortcutSqlIntentionActions: "SQL 인텐트 동작 (* 펼치기 / 식별자 한정)",diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.tsindex b023ee4547..ecc3ac8675 100644--- a/apps/desktop/src/i18n/locales/pt-BR.ts+++ b/apps/desktop/src/i18n/locales/pt-BR.ts@@ -8227,6 +8227,7 @@ export default withEnglishFallback({shortcutDisconnectSidebarConnection: "Desconectar conexão da barra lateral",shortcutOpenDataInNewTab: "Abrir dados em nova aba (clique do mouse)",shortcutViewTableDdl: "Ver DDL da tabela",+ shortcutEditSidebarTableStructure: "Editar estrutura da tabela",shortcutSendSelectionToAi: "Enviar seleção para IA",shortcutToggleAiPanel: "Alternar painel de IA",shortcutSqlIntentionActions: "Ações de intenção SQL (Expandir * / Qualificar identificador)",diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.tsindex 745b628449..a92ae6dcc5 100644--- a/apps/desktop/src/i18n/locales/ru.ts+++ b/apps/desktop/src/i18n/locales/ru.ts@@ -9595,6 +9595,7 @@ export default withEnglishFallback({shortcutDisconnectSidebarConnection: "Отключить подключение в боковой панели",shortcutOpenDataInNewTab: "Открыть данные в новой вкладке (клик мышью)",shortcutViewTableDdl: "Просмотреть DDL таблицы",+ shortcutEditSidebarTableStructure: "Изменить структуру таблицы",shortcutSendSelectionToAi: "Отправить выделенное в AI",shortcutToggleAiPanel: "Переключить панель AI",shortcutSqlIntentionActions: "SQL-действия по намерению (развернуть * / уточнить идентификатор)",diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.tsindex d9e817cea6..8a89d38626 100644--- a/apps/desktop/src/i18n/locales/tr.ts+++ b/apps/desktop/src/i18n/locales/tr.ts@@ -8008,6 +8008,7 @@ export default withEnglishFallback({shortcutDisconnectSidebarConnection: "Kenar çubuğu bağlantısını kes",shortcutOpenDataInNewTab: "Verileri yeni sekmede aç (fare tıklaması)",shortcutViewTableDdl: "Tablo DDL'ini görüntüle",+ shortcutEditSidebarTableStructure: "Tablo yapısını düzenle",shortcutSendSelectionToAi: "Seçimi yapay zekâya gönder",shortcutToggleAiPanel: "Yapay zeka panelini değiştir",shortcutSqlIntentionActions: "SQL Amaç İşlemleri (* Genişlet / Tanımlayıcıyı Nitele)",diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.tsindex 1f203036dd..178ee48565 100644--- a/apps/desktop/src/i18n/locales/zh-CN.ts+++ b/apps/desktop/src/i18n/locales/zh-CN.ts@@ -9245,6 +9245,7 @@ export default withEnglishFallback({shortcutDisconnectSidebarConnection: "断开侧边栏连接",shortcutOpenDataInNewTab: "在新数据标签页中打开(鼠标点击)",shortcutViewTableDdl: "查看表 DDL",+ shortcutEditSidebarTableStructure: "编辑表结构",shortcutSendSelectionToAi: "发送选中代码到 AI",shortcutToggleAiPanel: "切换 AI 面板",shortcutSqlIntentionActions: "SQL 意图操作(展开 * / 限定标识符)",diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.tsindex 19dd4b298b..b3db92d600 100644--- a/apps/desktop/src/i18n/locales/zh-TW.ts+++ b/apps/desktop/src/i18n/locales/zh-TW.ts@@ -7538,6 +7538,7 @@ export default withEnglishFallback({shortcutDisconnectSidebarConnection: "中斷側邊欄連線",shortcutOpenDataInNewTab: "在新資料分頁中開啟(滑鼠點擊)",shortcutViewTableDdl: "檢視資料表 DDL",+ shortcutEditSidebarTableStructure: "編輯資料表結構",shortcutSendSelectionToAi: "傳送選取程式碼至 AI",shortcutToggleAiPanel: "切換 AI 面板",shortcutSqlIntentionActions: "SQL 意圖操作(展開 * / 限定識別碼)",diff --git a/apps/desktop/src/lib/__tests__/editor/keyboardShortcuts.spec.ts b/apps/desktop/src/lib/__tests__/editor/keyboardShortcuts.spec.tsindex e71a22f004..73e3bb3750 100644--- a/apps/desktop/src/lib/__tests__/editor/keyboardShortcuts.spec.ts+++ b/apps/desktop/src/lib/__tests__/editor/keyboardShortcuts.spec.ts@@ -7,6 +7,7 @@ import {shouldBlockCaretBrowsing,isConvertNamingStyleShortcut,isEditCellShortcut,+ isEditSidebarTableStructureShortcut,isEditTableStructureShortcut,isExecuteSqlInNewResultTabShortcut,isGoToColumnShortcut,@@ -248,6 +249,19 @@ describe("keyboard shortcut matching", () => {expect(isEditTableStructureShortcut({ key: "d", ctrlKey: true, isComposing: true }, undefined, "Win32")).toBe(false);});+ it("matches the sidebar edit-table-structure shortcut F4", () => {+ expect(isEditSidebarTableStructureShortcut({ key: "F4" }, undefined, "Win32")).toBe(true);+ expect(isEditSidebarTableStructureShortcut({ key: "F4" }, undefined, "MacIntel")).toBe(true);+ expect(isEditSidebarTableStructureShortcut({ key: "F4", ctrlKey: true }, undefined, "Win32")).toBe(false);+ });++ it("honors custom and disabled sidebar edit-table-structure shortcuts", () => {+ expect(isEditSidebarTableStructureShortcut({ key: "s", ctrlKey: true, altKey: true }, { editSidebarTableStructure: "Mod+Alt+S" }, "Win32")).toBe(true);+ expect(isEditSidebarTableStructureShortcut({ key: "F4" }, { editSidebarTableStructure: "Mod+Alt+S" }, "Win32")).toBe(false);+ expect(isEditSidebarTableStructureShortcut({ key: "F4" }, { editSidebarTableStructure: "" }, "Win32")).toBe(false);+ expect(isEditSidebarTableStructureShortcut({ key: "F4", isComposing: true }, undefined, "Win32")).toBe(false);+ });+it.each([["goToFirstPage", isGoToFirstPageShortcut, "F1"],["goToPreviousPage", isGoToPreviousPageShortcut, "F2"],diff --git a/apps/desktop/src/lib/__tests__/editor/shortcutRegistry.spec.ts b/apps/desktop/src/lib/__tests__/editor/shortcutRegistry.spec.tsindex 3af9c55cab..b4fa0fc413 100644--- a/apps/desktop/src/lib/__tests__/editor/shortcutRegistry.spec.ts+++ b/apps/desktop/src/lib/__tests__/editor/shortcutRegistry.spec.ts@@ -51,7 +51,7 @@ describe("shortcutRegistry editor actions", () => {"foldAll","unfoldAll",];- const sidebarShortcutActionIds: ShortcutActionId[] = ["copySidebarSelection", "pasteSidebarSelection", "editSidebarConnection", "disconnectSidebarConnection", "viewTableDdl"];+ const sidebarShortcutActionIds: ShortcutActionId[] = ["copySidebarSelection", "pasteSidebarSelection", "editSidebarConnection", "disconnectSidebarConnection", "viewTableDdl", "editSidebarTableStructure"];it("registers pagination navigation as unassigned grid shortcuts", () => {const paginationActions = [@@ -461,6 +461,13 @@ describe("shortcutRegistry editor actions", () => {}});+ it("registers editSidebarTableStructure F4 as a conflict-free sidebar default", () => {+ const definition = SHORTCUT_DEFINITIONS.find((item) => item.id === "editSidebarTableStructure");+ expect(definition).toMatchObject({ scope: "sidebar", defaultShortcut: "F4", labelKey: "settings.shortcutEditSidebarTableStructure" });+ expect(DEFAULT_SHORTCUT_SETTINGS.editSidebarTableStructure).toBe("F4");+ expect(findShortcutConflict("editSidebarTableStructure", DEFAULT_SHORTCUT_SETTINGS.editSidebarTableStructure, DEFAULT_SHORTCUT_SETTINGS)).toBeNull();+ });+it("detects conflicts only within sidebar shortcuts", () => {const shortcuts = normalizeShortcutSettings({ copySidebarSelection: "Mod+E" });diff --git a/apps/desktop/src/lib/__tests__/sidebar/sidebarTreeStructureShortcut.spec.ts b/apps/desktop/src/lib/__tests__/sidebar/sidebarTreeStructureShortcut.spec.tsnew file mode 100644index 0000000000..3d45a7bc1f--- /dev/null+++ b/apps/desktop/src/lib/__tests__/sidebar/sidebarTreeStructureShortcut.spec.ts@@ -0,0 +1,48 @@+import { readFileSync } from "node:fs";+import { describe, expect, it } from "vitest";+import type { TreeNode } from "@/types/database";+import { sidebarNodeSupportsStructureEdit } from "@/lib/sidebar/sidebarTreeStructureShortcut";++function node(type: TreeNode["type"], extra: Partial<TreeNode> = {}): TreeNode {+ return { id: "n", label: "n", type, connectionId: "c", database: "db", ...extra };+}++describe("sidebar tree structure shortcut", () => {+ it("supports table nodes on databases that support table structure editing", () => {+ expect(sidebarNodeSupportsStructureEdit(node("table"), "mysql")).toBe(true);+ expect(sidebarNodeSupportsStructureEdit(node("table"), "postgres")).toBe(true);+ expect(sidebarNodeSupportsStructureEdit(node("table"), "redis")).toBe(false);+ });++ it("supports column and index nodes that have a tableName", () => {+ expect(sidebarNodeSupportsStructureEdit(node("column", { tableName: "users" }), "mysql")).toBe(true);+ expect(sidebarNodeSupportsStructureEdit(node("index", { tableName: "users" }), "mysql")).toBe(true);+ expect(sidebarNodeSupportsStructureEdit(node("column"), "mysql")).toBe(false);+ expect(sidebarNodeSupportsStructureEdit(node("index"), "mysql")).toBe(false);+ });++ it("rejects nodes without connection or database", () => {+ expect(sidebarNodeSupportsStructureEdit({ id: "n", label: "n", type: "table" }, "mysql")).toBe(false);+ expect(sidebarNodeSupportsStructureEdit({ id: "n", label: "n", type: "table", connectionId: "c" }, "mysql")).toBe(false);+ });++ it("rejects non-table nodes", () => {+ expect(sidebarNodeSupportsStructureEdit(node("connection"), "mysql")).toBe(false);+ expect(sidebarNodeSupportsStructureEdit(node("database"), "mysql")).toBe(false);+ expect(sidebarNodeSupportsStructureEdit(node("schema"), "mysql")).toBe(false);+ expect(sidebarNodeSupportsStructureEdit(node("procedure"), "mysql")).toBe(false);+ expect(sidebarNodeSupportsStructureEdit(node("view"), "mysql")).toBe(false);+ });++ it("rejects SQL Server linked server nodes", () => {+ expect(sidebarNodeSupportsStructureEdit(node("table", { linkedServer: "REMOTE" }), "sqlserver")).toBe(false);+ });++ const LOCALES = ["en", "zh-CN", "zh-TW", "ja", "ko", "es", "it", "pt-BR", "ru", "az", "tr", "id"] as const;++ it.each(LOCALES)("declares shortcutEditSidebarTableStructure in locale %s", (locale) => {+ const file = new URL(`../../../i18n/locales/${locale}.ts`, import.meta.url);+ const content = readFileSync(file, "utf8");+ expect(content).toMatch(/^\s*shortcutEditSidebarTableStructure:\s*".+",\s*$/m);+ });+});diff --git a/apps/desktop/src/lib/editor/keyboardShortcuts.ts b/apps/desktop/src/lib/editor/keyboardShortcuts.tsindex 8561baa9b4..c43cbda4fa 100644--- a/apps/desktop/src/lib/editor/keyboardShortcuts.ts+++ b/apps/desktop/src/lib/editor/keyboardShortcuts.ts@@ -349,6 +349,10 @@ export function isViewTableDdlShortcut(event: ShortcutLikeEvent, shortcuts?: Parreturn matchesShortcut(event, actionShortcut("viewTableDdl", shortcuts));}+export function isEditSidebarTableStructureShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>, platform = globalThis.navigator?.platform || ""): boolean {+ return matchesShortcut(event, actionShortcut("editSidebarTableStructure", shortcuts, platform), platform);+}+export function isQuickOpenShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>): boolean {return matchesShortcut(event, actionShortcut("quickOpen", shortcuts));}diff --git a/apps/desktop/src/lib/editor/shortcutRegistry.ts b/apps/desktop/src/lib/editor/shortcutRegistry.tsindex 784026a7c1..1b16984144 100644--- a/apps/desktop/src/lib/editor/shortcutRegistry.ts+++ b/apps/desktop/src/lib/editor/shortcutRegistry.ts@@ -94,6 +94,7 @@ export type ShortcutActionId =| "disconnectAllActiveConnections"| "openDataInNewTab"| "viewTableDdl"+ | "editSidebarTableStructure"| "sendSelectionToAi"| "sqlIntentionActions";@@ -738,6 +739,12 @@ export const SHORTCUT_DEFINITIONS: ShortcutDefinition[] = [scope: "sidebar",defaultShortcut: "Shift+Mod+D",},+ {+ id: "editSidebarTableStructure",+ labelKey: "settings.shortcutEditSidebarTableStructure",+ scope: "sidebar",+ defaultShortcut: "F4",+ },{id: "sendSelectionToAi",labelKey: "settings.shortcutSendSelectionToAi",diff --git a/apps/desktop/src/lib/sidebar/sidebarTreeRuntime.ts b/apps/desktop/src/lib/sidebar/sidebarTreeRuntime.tsindex 40949e5415..bb02144a80 100644--- a/apps/desktop/src/lib/sidebar/sidebarTreeRuntime.ts+++ b/apps/desktop/src/lib/sidebar/sidebarTreeRuntime.ts@@ -22,6 +22,7 @@ export interface SidebarTreeRuntimeHost {openPrimaryVisibleFilter(node: TreeNode): void;openDataInNewTab(node: TreeNode): void;openDdlForSelection(node: TreeNode, selectedNodeIds: readonly string[]): Promise<boolean>;+ openStructureEditorForSelection?(node: TreeNode): boolean;requestPaste(node: TreeNode): boolean;toggleNode(node: TreeNode): void;}diff --git a/apps/desktop/src/lib/sidebar/sidebarTreeStructureShortcut.ts b/apps/desktop/src/lib/sidebar/sidebarTreeStructureShortcut.tsnew file mode 100644index 0000000000..e6f3526fe3--- /dev/null+++ b/apps/desktop/src/lib/sidebar/sidebarTreeStructureShortcut.ts@@ -0,0 +1,12 @@+import type { DatabaseType, TreeNode } from "@/types/database";+import { isSqlServerLinkedNode } from "@/lib/database/sqlServerLinkedServers";+import { supportsTableStructureEditing } from "@/lib/database/databaseFeatureSupport";++/**+ * 侧边栏中支持“编辑表结构”的节点类型与条件,与右键菜单的+ * “编辑表结构”菜单项可见条件保持一致。+ */+export function sidebarNodeSupportsStructureEdit(node: TreeNode, dbType?: DatabaseType): boolean {+ const editableNode = node.type === "table" || ((node.type === "column" || node.type === "index") && !!node.tableName);+ return editableNode && !isSqlServerLinkedNode(node) && !!node.connectionId && !!node.database && supportsTableStructureEditing(dbType);+}diff --git a/packages/app-tests/settingsStore.test.ts b/packages/app-tests/settingsStore.test.tsindex 4103b1377e..f695a276d3 100644--- a/packages/app-tests/settingsStore.test.ts+++ b/packages/app-tests/settingsStore.test.ts@@ -507,6 +507,7 @@ test("defaults shortcut settings", () => {assert.equal(settings.shortcuts.pasteSidebarSelection, "Mod+V");assert.equal(settings.shortcuts.editSidebarConnection, "Mod+E");assert.equal(settings.shortcuts.disconnectSidebarConnection, "Shift+Mod+E");+ assert.equal(settings.shortcuts.editSidebarTableStructure, "F4");});test("keeps saved shortcut overrides", () => {