Skip to content

armgit / dbx

Public Imported from GitHub
0

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。

feat(editor): add shortcuts to open toolbar dropdowns

Saif Alaqqad63df21a9ce50
diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue
index b53f112343..3c37c48153 100644
--- a/apps/desktop/src/App.vue
+++ b/apps/desktop/src/App.vue
@@ -139,6 +139,9 @@ import {
handleTabHistoryNavigationShortcut,
isNewQueryShortcut,
isObjectSourceSaveShortcutTarget,
+ isOpenConnectionPickerShortcut,
+ isOpenDatabasePickerShortcut,
+ isOpenSchemaPickerShortcut,
isOpenSettingsShortcut,
isQuickOpenShortcut,
isGlobalSearchShortcut,
@@ -4556,6 +4559,17 @@ async function handleKeydown(e: KeyboardEvent) {
e.stopPropagation();
return;
}
+ if (isOpenConnectionPickerShortcut(e, shortcuts) || isOpenDatabasePickerShortcut(e, shortcuts) || isOpenSchemaPickerShortcut(e, shortcuts)) {
+ const target = e.target instanceof Element ? e.target : null;
+ const opened =
+ !target?.closest('[role="dialog"], [role="alertdialog"]') &&
+ ((isOpenConnectionPickerShortcut(e, shortcuts) && contentAreaRef.value?.openConnectionPicker?.()) || (isOpenDatabasePickerShortcut(e, shortcuts) && contentAreaRef.value?.openDatabasePicker?.()) || (isOpenSchemaPickerShortcut(e, shortcuts) && contentAreaRef.value?.openSchemaPicker?.()));
+ if (opened) {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ return;
+ }
const tabSwitcherDirection = tabSwitcherDirectionFromShortcut(e, shortcuts);
if (tabSwitcherDirection) {
diff --git a/apps/desktop/src/components/connection/ConnectionTreeSelect.vue b/apps/desktop/src/components/connection/ConnectionTreeSelect.vue
index b4a5cd1cc2..5e62b140db 100644
--- a/apps/desktop/src/components/connection/ConnectionTreeSelect.vue
+++ b/apps/desktop/src/components/connection/ConnectionTreeSelect.vue
@@ -44,6 +44,7 @@ const searchInput = ref<InstanceType<typeof Input>>();
const listContainer = ref<HTMLDivElement>();
const collapsedGroupIds = ref<Set<string>>(new Set());
const highlightIndex = ref(-1);
+let focusRestoreElement: HTMLElement | null = null;
const connectionById = computed(() => new Map(props.connections.map((connection) => [connection.id, connection])));
@@ -87,6 +88,15 @@ watch(open, async (value) => {
if (!value) {
searchText.value = "";
highlightIndex.value = -1;
+ const restoreTarget = focusRestoreElement;
+ focusRestoreElement = null;
+ if (restoreTarget) {
+ // Reka's modal popover refocuses the trigger synchronously on close, so
+ // the restore must land on the next tick to win for shortcut-opened
+ // dropdowns.
+ await nextTick();
+ if (restoreTarget.isConnected) restoreTarget.focus();
+ }
return;
}
await nextTick();
@@ -130,6 +140,15 @@ function handleKeydown(event: KeyboardEvent) {
open.value = false;
}
}
+
+defineExpose({
+ openDropdown: () => {
+ if (props.disabled) return false;
+ focusRestoreElement = document.activeElement instanceof HTMLElement ? document.activeElement : null;
+ open.value = true;
+ return true;
+ },
+});
</script>
<template>
diff --git a/apps/desktop/src/components/connection/__tests__/ConnectionTreeSelect.focusRestore.spec.ts b/apps/desktop/src/components/connection/__tests__/ConnectionTreeSelect.focusRestore.spec.ts
new file mode 100644
index 0000000000..f8edc57b40
--- /dev/null
+++ b/apps/desktop/src/components/connection/__tests__/ConnectionTreeSelect.focusRestore.spec.ts
@@ -0,0 +1,115 @@
+// @vitest-environment happy-dom
+
+import { createApp, defineComponent, h, nextTick, type App } from "vue";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import ConnectionTreeSelect from "@/components/connection/ConnectionTreeSelect.vue";
+import type { ConnectionConfig, SidebarLayout } from "@/types/database";
+
+vi.mock("@/components/ui/button", async () => {
+ const { createPassthroughStub } = await import("@/components/grid/__tests__/vueHostHarness");
+ return { Button: createPassthroughStub("Button", "button") };
+});
+
+vi.mock("@/components/ui/popover", async () => {
+ const { createPassthroughStub } = await import("@/components/grid/__tests__/vueHostHarness");
+ return {
+ Popover: createPassthroughStub("Popover"),
+ PopoverContent: createPassthroughStub("PopoverContent"),
+ PopoverTrigger: createPassthroughStub("PopoverTrigger"),
+ };
+});
+
+vi.mock("@/components/icons/DatabaseIcon.vue", () => ({
+ default: defineComponent({
+ name: "DatabaseIconStub",
+ setup: () => () => h("span"),
+ }),
+}));
+
+vi.mock("@/components/plugins/PluginIcon.vue", () => ({
+ default: defineComponent({
+ props: ["pluginId", "contributionId"],
+ setup: (props) => () => h("span", { "data-plugin-id": props.pluginId, "data-contribution-id": props.contributionId }),
+ }),
+}));
+
+const mountedApps: App[] = [];
+
+const connections: ConnectionConfig[] = [
+ {
+ id: "c1",
+ name: "Primary",
+ db_type: "mysql",
+ host: "localhost",
+ port: 3306,
+ username: "root",
+ password: "",
+ },
+];
+
+const layout: SidebarLayout = {
+ groups: [{ id: "g1", name: "Production", collapsed: false }],
+ order: [{ type: "group", id: "g1", children: [{ type: "connection", id: "c1" }] }],
+};
+
+function mountPicker() {
+ const editorInput = document.createElement("textarea");
+ const container = document.createElement("div");
+ document.body.append(editorInput, container);
+ const app = createApp(ConnectionTreeSelect, {
+ modelValue: "",
+ connections,
+ layout,
+ placeholder: "Select connection",
+ searchPlaceholder: "Search connections",
+ emptyText: "No connections",
+ });
+ mountedApps.push(app);
+ const instance = app.mount(container) as unknown as { openDropdown: () => boolean };
+ return { editorInput, instance };
+}
+
+function searchInput() {
+ const input = document.body.querySelector("input");
+ if (!(input instanceof HTMLInputElement)) throw new Error("Search input was not rendered");
+ return input;
+}
+
+afterEach(() => {
+ for (const app of mountedApps.splice(0)) app.unmount();
+ document.body.innerHTML = "";
+});
+
+describe("ConnectionTreeSelect shortcut focus restore", () => {
+ it("returns focus to the element focused before openDropdown once the picker closes", async () => {
+ const { editorInput, instance } = mountPicker();
+
+ editorInput.focus();
+ expect(document.activeElement).toBe(editorInput);
+ expect(instance.openDropdown()).toBe(true);
+ await nextTick();
+ await nextTick();
+ expect(document.activeElement).toBe(searchInput());
+
+ searchInput().dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }));
+ await nextTick();
+ await nextTick();
+
+ expect(document.activeElement).toBe(editorInput);
+ });
+
+ it("skips the focus restore when the captured element left the document before close", async () => {
+ const { editorInput, instance } = mountPicker();
+
+ editorInput.focus();
+ expect(instance.openDropdown()).toBe(true);
+ await nextTick();
+
+ editorInput.remove();
+ searchInput().dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }));
+ await nextTick();
+ await nextTick();
+
+ expect(document.activeElement).not.toBe(editorInput);
+ });
+});
diff --git a/apps/desktop/src/components/layout/EditorGroup.vue b/apps/desktop/src/components/layout/EditorGroup.vue
index cb6537806e..ee10b935ac 100644
--- a/apps/desktop/src/components/layout/EditorGroup.vue
+++ b/apps/desktop/src/components/layout/EditorGroup.vue
@@ -72,9 +72,13 @@ const contentEmits = createContentSurfaceEventForwarders(emit);
const surfaceBindings = computed(() => ({ ...surfaceProps.value, ...contentEmits }));
const activeSurfaceRef = ref<QueryEditorSurfaceHandle | null>(null);
+const toolbarRef = ref<InstanceType<typeof EditorToolbar> | null>(null);
defineExpose({
focusSearch: (target: Element | null = null) => activeSurfaceRef.value?.focusSearch(target) ?? false,
+ openConnectionPicker: () => toolbarRef.value?.openConnectionPicker() ?? false,
+ openDatabasePicker: () => toolbarRef.value?.openDatabasePicker() ?? false,
+ openSchemaPicker: () => toolbarRef.value?.openSchemaPicker() ?? false,
focusWhere: () => activeSurfaceRef.value?.focusWhere() ?? false,
openGoToColumn: () => activeSurfaceRef.value?.openGoToColumn() ?? false,
openTableStructureEditor: (initialTab?: TableInfoTab) => activeSurfaceRef.value?.openTableStructureEditor?.(initialTab) ?? false,
@@ -205,6 +209,7 @@ const groupExecutableSql = computed(() => {
<div v-show="!contentSuppressed" class="flex min-h-0 min-w-0 flex-1 flex-col">
<EditorToolbar
v-if="activeTab && showGroupToolbar"
+ ref="toolbarRef"
:active-tab="activeTab"
:active-connection="activeConnection"
:executable-sql="groupExecutableSql"
diff --git a/apps/desktop/src/components/layout/EditorToolbar.vue b/apps/desktop/src/components/layout/EditorToolbar.vue
index d53de106e6..0244e89f99 100644
--- a/apps/desktop/src/components/layout/EditorToolbar.vue
+++ b/apps/desktop/src/components/layout/EditorToolbar.vue
@@ -554,6 +554,16 @@ async function changeCatalog(selectedCatalog: string) {
switchingCatalog.value = false;
}
}
+
+const connectionPickerRef = ref<InstanceType<typeof ConnectionTreeSelect> | null>(null);
+const databasePickerRef = ref<InstanceType<typeof SearchableSelect> | null>(null);
+const schemaPickerRef = ref<InstanceType<typeof SearchableSelect> | null>(null);
+
+defineExpose({
+ openConnectionPicker: () => connectionPickerRef.value?.openDropdown() ?? false,
+ openDatabasePicker: () => databasePickerRef.value?.openDropdown() ?? false,
+ openSchemaPicker: () => schemaPickerRef.value?.openDropdown() ?? false,
+});
</script>
<template>
@@ -943,6 +953,7 @@ async function changeCatalog(selectedCatalog: string) {
<div class="flex shrink-0 items-center gap-1">
<span v-if="activeConnection?.color" class="h-4 w-1 rounded-full shrink-0" :style="{ backgroundColor: activeConnection.color }" />
<ConnectionTreeSelect
+ ref="connectionPickerRef"
:model-value="activeConnectionValue"
:connections="connectionStore.connections"
:layout="connectionStore.sidebarLayout"
@@ -1008,6 +1019,7 @@ async function changeCatalog(selectedCatalog: string) {
:class="{ 'database-required-prompt': databaseRequiredVisible }"
>
<SearchableSelect
+ ref="databasePickerRef"
:model-value="activeDatabaseValue"
:options="activeDatabaseOptions.length ? activeDatabaseOptions : activeDatabaseValue ? [activeDatabaseValue] : []"
:placeholder="t('editor.selectDatabase')"
@@ -1055,6 +1067,7 @@ async function changeCatalog(selectedCatalog: string) {
</div>
<div v-if="showSchemaSelector" class="flex shrink-0 items-center gap-1">
<SearchableSelect
+ ref="schemaPickerRef"
:model-value="activeSchemaValue"
:options="activeSchemaOptions.length ? activeSchemaOptions : activeSchemaValue ? [activeSchemaValue] : []"
:placeholder="t('editor.selectSchema')"
diff --git a/apps/desktop/src/components/layout/SqlEditorWorkspace.vue b/apps/desktop/src/components/layout/SqlEditorWorkspace.vue
index 598f88bd2f..0ea93b11f4 100644
--- a/apps/desktop/src/components/layout/SqlEditorWorkspace.vue
+++ b/apps/desktop/src/components/layout/SqlEditorWorkspace.vue
@@ -75,6 +75,9 @@ defineExpose({
},
focusWhere: () => activeEditorGroup()?.focusWhere() ?? false,
openGoToColumn: () => activeEditorGroup()?.openGoToColumn() ?? false,
+ openConnectionPicker: () => activeEditorGroup()?.openConnectionPicker() ?? false,
+ openDatabasePicker: () => activeEditorGroup()?.openDatabasePicker() ?? false,
+ openSchemaPicker: () => activeEditorGroup()?.openSchemaPicker() ?? false,
openTableStructureEditor: (initialTab?: TableInfoTab) => activeEditorGroup()?.openTableStructureEditor?.(initialTab) ?? false,
refreshData: (target: Element | null = null) => {
const element = commandTargetElement(target);
diff --git a/apps/desktop/src/components/ui/searchable-select/SearchableSelect.vue b/apps/desktop/src/components/ui/searchable-select/SearchableSelect.vue
index 3fc42de682..ebcfe0c2c1 100644
--- a/apps/desktop/src/components/ui/searchable-select/SearchableSelect.vue
+++ b/apps/desktop/src/components/ui/searchable-select/SearchableSelect.vue
@@ -82,6 +82,7 @@ const { t } = useI18n();
let shouldFocusAdjacentOnClose = false;
let tabDirection: 1 | -1 = 1;
+let focusRestoreElement: HTMLElement | null = null;
function getTriggerElement(): HTMLElement | undefined {
const target = triggerButton.value;
@@ -200,11 +201,19 @@ watch(open, async (value) => {
searchText.value = "";
highlightIndex.value = -1;
activeHelpOption.value = undefined;
+ const restoreTarget = focusRestoreElement;
+ focusRestoreElement = null;
if (shouldFocusAdjacentOnClose) {
const dir = tabDirection;
shouldFocusAdjacentOnClose = false;
await nextTick();
focusAdjacentElement(dir);
+ } else if (restoreTarget) {
+ // Reka's modal popover refocuses the trigger synchronously on close, so
+ // the restore must land on the next tick to win for shortcut-opened
+ // dropdowns.
+ await nextTick();
+ if (restoreTarget.isConnected) restoreTarget.focus();
}
return;
}
@@ -343,6 +352,15 @@ function handleKeydown(event: KeyboardEvent) {
open.value = false;
}
}
+
+defineExpose({
+ openDropdown: () => {
+ if (props.disabled) return false;
+ focusRestoreElement = document.activeElement instanceof HTMLElement ? document.activeElement : null;
+ open.value = true;
+ return true;
+ },
+});
</script>
<template>
diff --git a/apps/desktop/src/components/ui/searchable-select/__tests__/SearchableSelect.trigger.spec.ts b/apps/desktop/src/components/ui/searchable-select/__tests__/SearchableSelect.trigger.spec.ts
index 2c1b8583f6..8c93f4de41 100644
--- a/apps/desktop/src/components/ui/searchable-select/__tests__/SearchableSelect.trigger.spec.ts
+++ b/apps/desktop/src/components/ui/searchable-select/__tests__/SearchableSelect.trigger.spec.ts
@@ -308,4 +308,78 @@ describe("SearchableSelect trigger", () => {
expect(tabEvent.defaultPrevented).toBe(true);
expect(emitted.modelValue).toEqual(["int"]);
});
+
+ it("restores focus to the element focused before openDropdown once the popover closes", async () => {
+ const root = document.createElement("div");
+ const editorInput = document.createElement("textarea");
+ document.body.append(editorInput, root);
+ const app = createApp(SearchableSelect, {
+ modelValue: "Point",
+ options: ["Point", "LineString"],
+ placeholder: "type",
+ searchPlaceholder: "search",
+ emptyText: "empty",
+ });
+ mountedApps.push(app);
+ const instance = app.mount(root) as unknown as { openDropdown: () => boolean };
+
+ editorInput.focus();
+ expect(document.activeElement).toBe(editorInput);
+ expect(instance.openDropdown()).toBe(true);
+ await nextTick();
+
+ const input = document.body.querySelector<HTMLInputElement>("input")!;
+ expect(document.activeElement).toBe(input);
+
+ input.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }));
+ await nextTick();
+ await nextTick();
+
+ expect(document.activeElement).toBe(editorInput);
+ });
+
+ it("skips the focus restore when the captured element left the document before close", async () => {
+ const root = document.createElement("div");
+ const editorInput = document.createElement("textarea");
+ document.body.append(editorInput, root);
+ const app = createApp(SearchableSelect, {
+ modelValue: "Point",
+ options: ["Point", "LineString"],
+ placeholder: "type",
+ searchPlaceholder: "search",
+ emptyText: "empty",
+ });
+ mountedApps.push(app);
+ const instance = app.mount(root) as unknown as { openDropdown: () => boolean };
+
+ editorInput.focus();
+ expect(instance.openDropdown()).toBe(true);
+ await nextTick();
+
+ editorInput.remove();
+ const input = document.body.querySelector<HTMLInputElement>("input")!;
+ input.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }));
+ await nextTick();
+ await nextTick();
+
+ expect(document.activeElement).not.toBe(editorInput);
+ });
+
+ it("does not restore focus for dropdowns not opened via openDropdown", async () => {
+ const { root } = mountSelect();
+ const editorInput = document.createElement("textarea");
+ document.body.append(editorInput);
+ editorInput.focus();
+
+ const trigger = root.querySelector("button")!;
+ trigger.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowDown", bubbles: true, cancelable: true }));
+ await nextTick();
+
+ const input = document.body.querySelector<HTMLInputElement>("input")!;
+ input.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }));
+ await nextTick();
+ await nextTick();
+
+ expect(document.activeElement).not.toBe(editorInput);
+ });
});
diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.ts
index 7641354164..5772a27e5a 100644
--- a/apps/desktop/src/i18n/locales/az.ts
+++ b/apps/desktop/src/i18n/locales/az.ts
@@ -8194,6 +8194,9 @@ export default withEnglishFallback({
shortcutFocusSearch: "Cari görünüşün axtarış sahəsinə keç",
shortcutQuickOpen: "Sürətli açılış (bütün verilənlər bazası obyektlərini axtar)",
shortcutGlobalSearch: "Qlobal fayl məzmunu axtarışı",
+ shortcutOpenConnectionPicker: "Bağlantı seçicisini aç",
+ shortcutOpenDatabasePicker: "Verilənlər bazası seçicisini aç",
+ shortcutOpenSchemaPicker: "Sxem seçicisini aç",
shortcutNavigateTabHistoryBack: "Qlobal geri",
shortcutTabSwitcher: "Vərəq dəyişdiricisi (göstərmək üçün basılı saxla, keçmək üçün burax)",
shortcutNavigateTabHistoryForward: "Qlobal irəli",
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index 38515b8e59..ec51cd5dfa 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -9708,6 +9708,9 @@ export default {
shortcutFocusSearch: "Focus current view search",
shortcutQuickOpen: "Quick open (search all database objects)",
shortcutGlobalSearch: "Global file content search",
+ shortcutOpenConnectionPicker: "Open connection picker",
+ shortcutOpenDatabasePicker: "Open database picker",
+ shortcutOpenSchemaPicker: "Open schema picker",
shortcutNavigateTabHistoryBack: "Navigate back",
shortcutTabSwitcher: "Tab switcher (hold to show, release to switch)",
shortcutNavigateTabHistoryForward: "Navigate forward",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index 060ea8108f..0c0fa34d6a 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -8754,6 +8754,9 @@ export default withEnglishFallback({
shortcutFocusSearch: "Enfocar búsqueda de la vista actual",
shortcutQuickOpen: "Abrir rápido (buscar todos los objetos de base de datos)",
shortcutGlobalSearch: "Búsqueda global de contenido de archivos",
+ shortcutOpenConnectionPicker: "Abrir selector de conexiones",
+ shortcutOpenDatabasePicker: "Abrir selector de bases de datos",
+ shortcutOpenSchemaPicker: "Abrir selector de esquemas",
shortcutNavigateTabHistoryBack: "Navegar atrás",
shortcutTabSwitcher: "Selector de pestañas (mantén pulsado para mostrar, suelta para cambiar)",
shortcutNavigateTabHistoryForward: "Navegar adelante",
diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.ts
index 0484c52a05..20c74ce0f6 100644
--- a/apps/desktop/src/i18n/locales/id.ts
+++ b/apps/desktop/src/i18n/locales/id.ts
@@ -9005,6 +9005,9 @@ export default withEnglishFallback({
shortcutFocusSearch: "Fokus pencarian tampilan saat ini",
shortcutQuickOpen: "Buka cepat (cari semua objek database)",
shortcutGlobalSearch: "Pencarian konten file global",
+ shortcutOpenConnectionPicker: "Buka pemilih koneksi",
+ shortcutOpenDatabasePicker: "Buka pemilih database",
+ shortcutOpenSchemaPicker: "Buka pemilih skema",
shortcutNavigateTabHistoryBack: "Navigasi mundur",
shortcutTabSwitcher: "Pengalih tab (tahan untuk menampilkan, lepas untuk beralih)",
shortcutNavigateTabHistoryForward: "Navigasi maju",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 8d16e434ee..163edcd295 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -8515,6 +8515,9 @@ export default withEnglishFallback({
shortcutFocusSearch: "Focalizza la ricerca nella vista corrente",
shortcutQuickOpen: "Apertura rapida (ricerca tutti gli oggetti del database)",
shortcutGlobalSearch: "Ricerca globale nel contenuto dei file",
+ shortcutOpenConnectionPicker: "Apri il selettore di connessione",
+ shortcutOpenDatabasePicker: "Apri il selettore di database",
+ shortcutOpenSchemaPicker: "Apri il selettore di schema",
shortcutNavigateTabHistoryBack: "Navigazione indietro",
shortcutTabSwitcher: "Selettore schede (tieni premuto per mostrare, rilascia per cambiare)",
shortcutNavigateTabHistoryForward: "Navigazione avanti",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index e3801a5edb..21927f2904 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -8504,6 +8504,9 @@ export default withEnglishFallback({
shortcutFocusSearch: "現在のビューの検索にフォーカス",
shortcutQuickOpen: "クイックオープン (すべてのデータベースオブジェクトを検索)",
shortcutGlobalSearch: "グローバルファイル内容検索",
+ shortcutOpenConnectionPicker: "接続ピッカーを開く",
+ shortcutOpenDatabasePicker: "データベースピッカーを開く",
+ shortcutOpenSchemaPicker: "スキーマピッカーを開く",
shortcutNavigateTabHistoryBack: "グローバルに戻る",
shortcutTabSwitcher: "タブスイッチャー(押し続けて表示、離して切り替え)",
shortcutNavigateTabHistoryForward: "グローバルに進む",
diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts
index 0b689a026f..94cba35a30 100644
--- a/apps/desktop/src/i18n/locales/ko.ts
+++ b/apps/desktop/src/i18n/locales/ko.ts
@@ -8413,6 +8413,9 @@ export default withEnglishFallback({
shortcutFocusSearch: "현재 화면 검색에 포커스",
shortcutQuickOpen: "빠른 열기 (모든 데이터베이스 객체 검색)",
shortcutGlobalSearch: "전역 파일 내용 검색",
+ shortcutOpenConnectionPicker: "연결 선택기 열기",
+ shortcutOpenDatabasePicker: "데이터베이스 선택기 열기",
+ shortcutOpenSchemaPicker: "스키마 선택기 열기",
shortcutNavigateTabHistoryBack: "전체 뒤로",
shortcutTabSwitcher: "탭 전환기 (길게 눌러 표시, 놓으면 전환)",
shortcutNavigateTabHistoryForward: "전체 앞으로",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index 619c7107e3..ceb2485a69 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -8515,6 +8515,9 @@ export default withEnglishFallback({
shortcutFocusSearch: "Focar na pesquisa da tela atual",
shortcutQuickOpen: "Abrir rapidamente (pesquisar todos os objetos do banco de dados)",
shortcutGlobalSearch: "Pesquisa global de conteúdo de arquivos",
+ shortcutOpenConnectionPicker: "Abrir seletor de conexão",
+ shortcutOpenDatabasePicker: "Abrir seletor de banco de dados",
+ shortcutOpenSchemaPicker: "Abrir seletor de esquema",
shortcutNavigateTabHistoryBack: "Navegar para trás",
shortcutTabSwitcher: "Alternador de abas (segure para mostrar, solte para alternar)",
shortcutNavigateTabHistoryForward: "Navegar para frente",
diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.ts
index fd9ab8ae71..e944f2d3ed 100644
--- a/apps/desktop/src/i18n/locales/ru.ts
+++ b/apps/desktop/src/i18n/locales/ru.ts
@@ -9899,6 +9899,9 @@ export default withEnglishFallback({
shortcutFocusSearch: "Фокус на поиске в текущем представлении",
shortcutQuickOpen: "Быстрое открытие (поиск по всем объектам базы данных)",
shortcutGlobalSearch: "Глобальный поиск по содержимому файлов",
+ shortcutOpenConnectionPicker: "Открыть выбор подключения",
+ shortcutOpenDatabasePicker: "Открыть выбор базы данных",
+ shortcutOpenSchemaPicker: "Открыть выбор схемы",
shortcutNavigateTabHistoryBack: "Назад по навигации",
shortcutTabSwitcher: "Переключатель вкладок (удерживайте, чтобы показать, отпустите, чтобы переключиться)",
shortcutNavigateTabHistoryForward: "Вперёд по навигации",
diff --git a/apps/desktop/src/i18n/locales/th.ts b/apps/desktop/src/i18n/locales/th.ts
index 38ee329f53..863d622356 100644
--- a/apps/desktop/src/i18n/locales/th.ts
+++ b/apps/desktop/src/i18n/locales/th.ts
@@ -10337,6 +10337,9 @@ export default withEnglishFallback({
shortcutFocusSearch: "โฟกัสการค้นหามุมมองปัจจุบัน",
shortcutQuickOpen: "เปิดด่วน (ค้นหาออบเจ็กต์ฐานข้อมูลทั้งหมด)",
shortcutGlobalSearch: "ค้นหาเนื้อหาไฟล์ทั้งหมด",
+ shortcutOpenConnectionPicker: "เปิดตัวเลือกการเชื่อมต่อ",
+ shortcutOpenDatabasePicker: "เปิดตัวเลือกฐานข้อมูล",
+ shortcutOpenSchemaPicker: "เปิดตัวเลือกสキーマ",
shortcutNavigateTabHistoryBack: "ย้อนกลับ",
shortcutTabSwitcher: "ตัวสลับแท็บ (กดค้างเพื่อแสดง ปล่อยเพื่อสลับ)",
shortcutNavigateTabHistoryForward: "ไปข้างหน้า",
diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.ts
index a163f261a6..9887b6078e 100644
--- a/apps/desktop/src/i18n/locales/tr.ts
+++ b/apps/desktop/src/i18n/locales/tr.ts
@@ -8097,6 +8097,9 @@ export default withEnglishFallback({
shortcutFocusSearch: "Geçerli görünüm aramasına odaklan",
shortcutQuickOpen: "Hızlı aç (tüm veritabanı nesnelerinde ara)",
shortcutGlobalSearch: "Genel dosya içeriği arama",
+ shortcutOpenConnectionPicker: "Bağlantı seçicisini aç",
+ shortcutOpenDatabasePicker: "Veritabanı seçicisini aç",
+ shortcutOpenSchemaPicker: "Şema seçicisini aç",
shortcutNavigateTabHistoryBack: "Geri git",
shortcutTabSwitcher: "Sekme değiştirici (göstermek için basılı tutun, geçmek için bırakın)",
shortcutNavigateTabHistoryForward: "İleri git",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index 42747dc697..ea34dda888 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -9692,6 +9692,9 @@ export default withEnglishFallback({
shortcutFocusSearch: "聚焦当前页面搜索",
shortcutQuickOpen: "快速打开 (搜索所有数据库对象)",
shortcutGlobalSearch: "全局文件内容搜索",
+ shortcutOpenConnectionPicker: "打开连接选择器",
+ shortcutOpenDatabasePicker: "打开数据库选择器",
+ shortcutOpenSchemaPicker: "打开 Schema 选择器",
shortcutNavigateTabHistoryBack: "全局后退",
shortcutTabSwitcher: "标签页切换器(按住显示,松开切换)",
shortcutNavigateTabHistoryForward: "全局前进",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index 432221950c..1dcb5c54bd 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -7824,6 +7824,9 @@ export default withEnglishFallback({
shortcutFocusSearch: "聚焦目前頁面搜尋",
shortcutQuickOpen: "快速開啟 (搜尋所有資料庫物件)",
shortcutGlobalSearch: "全域檔案內容搜尋",
+ shortcutOpenConnectionPicker: "開啟連線選擇器",
+ shortcutOpenDatabasePicker: "開啟資料庫選擇器",
+ shortcutOpenSchemaPicker: "開啟 Schema 選擇器",
shortcutNavigateTabHistoryBack: "全域後退",
shortcutTabSwitcher: "分頁切換器(按住顯示,放開切換)",
shortcutNavigateTabHistoryForward: "全域前進",
diff --git a/apps/desktop/src/lib/__tests__/editor/keyboardShortcuts.spec.ts b/apps/desktop/src/lib/__tests__/editor/keyboardShortcuts.spec.ts
index 71ffc433be..a5ba0cd9f4 100644
--- a/apps/desktop/src/lib/__tests__/editor/keyboardShortcuts.spec.ts
+++ b/apps/desktop/src/lib/__tests__/editor/keyboardShortcuts.spec.ts
@@ -21,6 +21,9 @@ import {
isGoToNextPageShortcut,
isGoToPreviousPageShortcut,
isToggleZenModeShortcut,
+ isOpenConnectionPickerShortcut,
+ isOpenDatabasePickerShortcut,
+ isOpenSchemaPickerShortcut,
isSidebarFocusedTarget,
isToggleAiPanelShortcut,
matchesModifierOnlyShortcut,
@@ -226,6 +229,20 @@ describe("keyboard shortcut matching", () => {
expect(isToggleZenModeShortcut(platformModEvent, { toggleZenMode: "" })).toBe(false);
});
+ it("matches the toolbar picker shortcuts by default and with custom bindings", () => {
+ const modEvent = (key: string) => (isMacShortcutPlatform() ? { key, metaKey: true, altKey: true } : { key, ctrlKey: true, altKey: true });
+
+ expect(isOpenConnectionPickerShortcut(modEvent("c"))).toBe(true);
+ expect(isOpenDatabasePickerShortcut(modEvent("d"))).toBe(true);
+ expect(isOpenSchemaPickerShortcut(modEvent("s"))).toBe(true);
+ expect(isOpenConnectionPickerShortcut(modEvent("d"))).toBe(false);
+ expect(isOpenConnectionPickerShortcut({ ...modEvent("c"), altKey: false })).toBe(false);
+ expect(isOpenDatabasePickerShortcut({ key: "b", ctrlKey: true, altKey: true }, { openDatabasePicker: "Mod+Alt+B" })).toBe(true);
+ expect(isOpenDatabasePickerShortcut(modEvent("d"), { openDatabasePicker: "Mod+Alt+B" })).toBe(false);
+ expect(isOpenSchemaPickerShortcut(modEvent("s"), { openSchemaPicker: "" })).toBe(false);
+ expect(isOpenSchemaPickerShortcut({ ...modEvent("s"), isComposing: true })).toBe(false);
+ });
+
it("matches the platform-specific AI panel shortcut", () => {
expect(isToggleAiPanelShortcut({ key: "i", ctrlKey: true, metaKey: true }, undefined, "MacIntel")).toBe(true);
expect(isToggleAiPanelShortcut({ key: "i", ctrlKey: true, altKey: true }, undefined, "Win32")).toBe(true);
diff --git a/apps/desktop/src/lib/__tests__/editor/shortcutRegistry.spec.ts b/apps/desktop/src/lib/__tests__/editor/shortcutRegistry.spec.ts
index 311fa7868b..a9045de6ae 100644
--- a/apps/desktop/src/lib/__tests__/editor/shortcutRegistry.spec.ts
+++ b/apps/desktop/src/lib/__tests__/editor/shortcutRegistry.spec.ts
@@ -216,6 +216,21 @@ describe("shortcutRegistry editor actions", () => {
expect(findShortcutConflict("find", DEFAULT_SHORTCUT_SETTINGS.find, DEFAULT_SHORTCUT_SETTINGS)).toBeNull();
});
+ it("registers conflict-free global shortcuts for the toolbar connection, database, and schema pickers", () => {
+ const pickerDefaults: Array<[ShortcutActionId, string]> = [
+ ["openConnectionPicker", "Mod+Alt+C"],
+ ["openDatabasePicker", "Mod+Alt+D"],
+ ["openSchemaPicker", "Mod+Alt+S"],
+ ];
+
+ for (const [id, defaultShortcut] of pickerDefaults) {
+ const definition = SHORTCUT_DEFINITIONS.find((item) => item.id === id);
+ expect(definition).toMatchObject({ labelKey: `settings.shortcut${id[0]!.toUpperCase()}${id.slice(1)}`, scope: "global", defaultShortcut });
+ expect(DEFAULT_SHORTCUT_SETTINGS[id]).toBe(defaultShortcut);
+ expect(findShortcutConflict(id, defaultShortcut, DEFAULT_SHORTCUT_SETTINGS)).toBeNull();
+ }
+ });
+
it("registers a conflict-free global shortcut for Zen mode", () => {
const definition = SHORTCUT_DEFINITIONS.find((item) => item.id === "toggleZenMode");
diff --git a/apps/desktop/src/lib/editor/keyboardShortcuts.ts b/apps/desktop/src/lib/editor/keyboardShortcuts.ts
index 3700aa690c..b351665e32 100644
--- a/apps/desktop/src/lib/editor/keyboardShortcuts.ts
+++ b/apps/desktop/src/lib/editor/keyboardShortcuts.ts
@@ -378,6 +378,18 @@ export function isGlobalSearchShortcut(event: ShortcutLikeEvent, shortcuts?: Par
return matchesShortcut(event, actionShortcut("globalSearch", shortcuts));
}
+export function isOpenConnectionPickerShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>): boolean {
+ return matchesShortcut(event, actionShortcut("openConnectionPicker", shortcuts));
+}
+
+export function isOpenDatabasePickerShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>): boolean {
+ return matchesShortcut(event, actionShortcut("openDatabasePicker", shortcuts));
+}
+
+export function isOpenSchemaPickerShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>): boolean {
+ return matchesShortcut(event, actionShortcut("openSchemaPicker", shortcuts));
+}
+
export function isNavigateTabHistoryBackShortcut(event: ShortcutLikeEvent, shortcuts?: Partial<ShortcutSettings>, platform = globalThis.navigator?.platform || ""): boolean {
return matchesShortcut(event, actionShortcut("navigateTabHistoryBack", shortcuts, platform), platform);
}
diff --git a/apps/desktop/src/lib/editor/shortcutRegistry.ts b/apps/desktop/src/lib/editor/shortcutRegistry.ts
index cb4b5cd33b..b7f08ac75d 100644
--- a/apps/desktop/src/lib/editor/shortcutRegistry.ts
+++ b/apps/desktop/src/lib/editor/shortcutRegistry.ts
@@ -61,6 +61,9 @@ export type ShortcutActionId =
| "focusSearch"
| "quickOpen"
| "globalSearch"
+ | "openConnectionPicker"
+ | "openDatabasePicker"
+ | "openSchemaPicker"
| "toggleAiPanel"
| "navigateTabHistoryBack"
| "navigateTabHistoryForward"
@@ -541,6 +544,24 @@ export const SHORTCUT_DEFINITIONS: ShortcutDefinition[] = [
scope: "global",
defaultShortcut: "Mod+Alt+F",
},
+ {
+ id: "openConnectionPicker",
+ labelKey: "settings.shortcutOpenConnectionPicker",
+ scope: "global",
+ defaultShortcut: "Mod+Alt+C",
+ },
+ {
+ id: "openDatabasePicker",
+ labelKey: "settings.shortcutOpenDatabasePicker",
+ scope: "global",
+ defaultShortcut: "Mod+Alt+D",
+ },
+ {
+ id: "openSchemaPicker",
+ labelKey: "settings.shortcutOpenSchemaPicker",
+ scope: "global",
+ defaultShortcut: "Mod+Alt+S",
+ },
{
id: "toggleAiPanel",
labelKey: "settings.shortcutToggleAiPanel",