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(plugins): add settings shortcut entry and drag edge avoidance
ezreale444c15e0c9b
diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vueindex c44ead14e2..d03aeafcaa 100644--- a/apps/desktop/src/App.vue+++ b/apps/desktop/src/App.vue@@ -96,7 +96,7 @@ import { openQueryResultArchiveFile } from "@/lib/query/queryResultArchiveFile";import { activeTabExternalSqlFileTarget, rememberExternalSqlFileTarget, resolveExternalSqlFileTarget, resolveExternalSqlFileTargetForActiveTab, unassociatedExternalSqlFileTarget, type ExternalSqlFileTarget } from "@/lib/sql/externalSqlFileTarget";import { externalSqlFileOpenErrorMessage, externalSqlEditorMaxBytes, isSqlFilePath, readBrowserSqlFile, sqlFileTitleFromPath } from "@/lib/sql/sqlFileOpen";import type { ConnectionConfig, DatabaseType, ObjectBrowserFilter, ObjectSourceKind, QueryTab, TabOutputView, TreeNode } from "@/types/database";-import type { PluginCenterFocus } from "@/lib/plugins/pluginCenterNavigation";+import { OPEN_PLUGIN_SETTINGS, type PluginCenterFocus } from "@/lib/plugins/pluginCenterNavigation";import { parsePluginInstallDeepLink } from "@/lib/plugins/pluginInstallDeepLink";import { createFrontendPluginRegistry } from "@/lib/plugins/frontendPlugin";import { parseConnectionDeepLink, parseConnectionDeepLinkUpdate, type ConnectionDeepLinkDraft, type ConnectionDeepLinkUpdate } from "@/lib/connection/connectionDeepLink";@@ -1276,6 +1276,8 @@ function openPluginCenterPage(focus?: PluginCenterFocus | null) {activateMainContentSurface("pluginCenter");}+provide(OPEN_PLUGIN_SETTINGS, () => openPluginCenterPage({ section: "settings" }));+function closePluginCenterPage() {pluginCenterTabOpen.value = false;pluginCenterFocus.value = null;diff --git a/apps/desktop/src/components/plugins/PluginContributionsPanel.vue b/apps/desktop/src/components/plugins/PluginContributionsPanel.vueindex 93768b978d..f669de9c8b 100644--- a/apps/desktop/src/components/plugins/PluginContributionsPanel.vue+++ b/apps/desktop/src/components/plugins/PluginContributionsPanel.vue@@ -252,7 +252,9 @@ async function refresh(preferredPluginId = props.focusTarget?.pluginId || selecttry {[installedPlugins.value, trustedKeys.value, repositories.value] = await Promise.all([api.listPlugins(), api.listPluginTrustedKeys(), api.listPluginRepositories()]);await refreshMarketplace();- if (props.focusTarget) applyFocusTarget(props.focusTarget);+ // Settings navigation is handled immediately by the watcher; replaying it+ // after loading would overwrite any subsequent navigation by the user.+ if (props.focusTarget && props.focusTarget.section !== "settings") applyFocusTarget(props.focusTarget);else selectFirstProvider(preferredPluginId);} catch (cause) {error.value = cause instanceof Error ? cause.message : String(cause);@@ -278,6 +280,10 @@ async function refreshMarketplace() {}function applyFocusTarget(focus: PluginCenterFocus) {+ if (focus.section === "settings") {+ activeSection.value = "settings";+ return;+ }activeSection.value = "installed";if (!focus.pluginId) return selectFirstProvider();const provider = connectionProviders.value.find((entry) => entry.plugin.manifest.id === focus.pluginId && (!focus.providerId || entry.contribution.id === focus.providerId));@@ -907,9 +913,9 @@ watch(providerConnections, (connections) => {watch(() => props.focusTarget,(focus) => {- if (focus && installedPlugins.value.length) applyFocusTarget(focus);+ if (focus && (focus.section === "settings" || installedPlugins.value.length)) applyFocusTarget(focus);},- { deep: true },+ { deep: true, immediate: true },);let lastHandledInstallRequestId = 0;watch(diff --git a/apps/desktop/src/components/plugins/PluginShortcutBar.spec.ts b/apps/desktop/src/components/plugins/PluginShortcutBar.spec.tsindex 3677a8aa36..93f6ca104b 100644--- a/apps/desktop/src/components/plugins/PluginShortcutBar.spec.ts+++ b/apps/desktop/src/components/plugins/PluginShortcutBar.spec.ts@@ -1,10 +1,11 @@// @vitest-environment happy-domimport { createApp, h, nextTick, reactive, ref } from "vue";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { OPEN_PLUGIN_SETTINGS } from "@/lib/plugins/pluginCenterNavigation";import PluginShortcutBar from "./PluginShortcutBar.vue";import { normalizePluginShortcutSettings, type PluginShortcutPosition } from "@/lib/plugins/pluginShortcuts";-const mocks = vi.hoisted(() => ({ open: vi.fn(), save: vi.fn(), toast: vi.fn(), state: null as any, entries: null as any }));+const mocks = vi.hoisted(() => ({ openSettings: vi.fn(), open: vi.fn(), save: vi.fn(), toast: vi.fn(), state: null as any, entries: null as any }));vi.mock("vue-i18n", () => ({ useI18n: () => ({ t: (key: string) => key }) }));vi.mock("@/stores/settingsStore", () => ({ useSettingsStore: () => mocks.state }));vi.mock("@/composables/useToast", () => ({ useToast: () => ({ toast: mocks.toast }) }));@@ -27,6 +28,7 @@ function mount(position: PluginShortcutPosition) {container = document.createElement("div");document.body.append(container);app = createApp({ render: () => h(PluginShortcutBar, { position }) });+ app.provide(OPEN_PLUGIN_SETTINGS, mocks.openSettings);app.mount(container);const scroll = container.querySelector("[data-shortcut-scroll]") as HTMLElement;scroll.getBoundingClientRect = () => box(0, 0, 100, 200);@@ -41,16 +43,62 @@ function pointer(element: EventTarget, type: string, x: number, y: number) {}beforeEach(() => {vi.clearAllMocks();- mocks.state = reactive({ isEditorSettingsLoaded: true, editorSettings: { pluginShortcuts: normalizePluginShortcutSettings({}) }, updateEditorSettingsAndPersist: mocks.save });+ mocks.state = reactive({ isEditorSettingsLoaded: true, editorSettings: { pluginShortcuts: normalizePluginShortcutSettings({ showSettingsEntry: false }) }, updateEditorSettingsAndPersist: mocks.save });mocks.entries = ref(["a", "b", "c"].map((id) => ({ id, pluginId: id, label: `Function ${id}`, pluginName: `Plugin ${id}`, kind: "workbench", targetId: id, disabled: false })));mocks.save.mockResolvedValue(undefined);});afterEach(() => {app?.unmount();container?.remove();+ vi.restoreAllMocks();});describe("plugin shortcut bar", () => {+ it.each(["left-top", "right-top", "sidebar-bottom"] as const)("keeps the measured preview inside both edges at %s", async (position) => {+ const original = HTMLElement.prototype.getBoundingClientRect;+ vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(function (this: HTMLElement) {+ return this.hasAttribute("data-shortcut-drag-preview") ? box(0, 0, 180, 32) : original.call(this);+ });+ const items = mount(position);+ pointer(items[0], "pointerdown", 16, 16);+ pointer(window, "pointermove", window.innerWidth - 2, window.innerHeight - 2);+ await flush();+ const preview = document.querySelector<HTMLElement>("[data-shortcut-drag-preview]")!;+ expect(preview.style.left).toBe(`${window.innerWidth - 194}px`);+ expect(preview.style.top).toBe(`${window.innerHeight - 46}px`);+ pointer(window, "pointermove", 2, 2);+ await flush();+ expect(preview.style.left).toBe("14px");+ expect(preview.style.top).toBe("14px");+ expect(preview.style.visibility).not.toBe("hidden");+ });++ it.each(["left-top", "left-bottom", "right-top", "right-bottom", "sidebar-bottom"] as const)("keeps settings last and outside sorting at %s", async (position) => {+ mocks.state.editorSettings.pluginShortcuts.showSettingsEntry = true;+ mount(position);+ const button = container.querySelector<HTMLElement>("[data-plugin-shortcut-settings]")!;+ const buttons = container.querySelectorAll("button");+ if (position === "sidebar-bottom") {+ expect(container.querySelector("[data-shortcut-header]")?.contains(button)).toBe(true);+ expect(container.querySelector("[data-shortcut-scroll] [data-plugin-shortcut-settings]")).toBeNull();+ } else expect(buttons[buttons.length - 1]).toBe(button);+ expect(button.closest("[data-shortcut-id]")).toBeNull();+ pointer(button, "pointerdown", 16, 120);+ pointer(window, "pointermove", 1, 1);+ pointer(window, "pointerup", 1, 1);+ await flush();+ expect(mocks.save).not.toHaveBeenCalled();+ expect(document.querySelector(".shortcut-drag-preview")).toBeNull();+ button.click();+ expect(mocks.openSettings).toHaveBeenCalledOnce();+ mocks.entries.value = [];+ await flush();+ expect(container.querySelector("[data-plugin-shortcut-settings]")).toBeNull();+ expect(container.querySelector("nav")).toBeNull();+ mocks.state.editorSettings.pluginShortcuts.showSettingsEntry = false;+ await flush();+ expect(container.querySelector("nav")).toBeNull();+ });it.each(["left-top", "left-bottom", "right-top", "right-bottom", "sidebar-bottom"] as const)("sorts with pointer events at %s without launching on release", async (position) => {const items = mount(position);await nextTick();@@ -62,7 +110,7 @@ describe("plugin shortcut bar", () => {expect(document.querySelector(".shortcut-drag-preview")).not.toBeNull();pointer(window, "pointerup", 1, 1);await flush();- expect(mocks.save).toHaveBeenCalledWith({ pluginShortcuts: { ...normalizePluginShortcutSettings({}), order: ["c", "a", "b"] } });+ expect(mocks.save).toHaveBeenCalledWith({ pluginShortcuts: { ...normalizePluginShortcutSettings({ showSettingsEntry: false }), order: ["c", "a", "b"] } });(items[2].querySelector("button") as HTMLElement).click();expect(mocks.open).not.toHaveBeenCalled();expect(document.querySelector(".shortcut-drag-preview")).toBeNull();diff --git a/apps/desktop/src/components/plugins/PluginShortcutBar.vue b/apps/desktop/src/components/plugins/PluginShortcutBar.vueindex 7f84625807..8d1f18689c 100644--- a/apps/desktop/src/components/plugins/PluginShortcutBar.vue+++ b/apps/desktop/src/components/plugins/PluginShortcutBar.vue@@ -1,5 +1,7 @@<script setup lang="ts">-import { computed, ref, watch } from "vue";+import { computed, inject, ref, watch } from "vue";+import { Settings2 } from "@lucide/vue";+import { OPEN_PLUGIN_SETTINGS } from "@/lib/plugins/pluginCenterNavigation";import { useI18n } from "vue-i18n";import { Button } from "@/components/ui/button";import LightTooltip from "@/components/ui/LightTooltip.vue";@@ -7,6 +9,7 @@ import PluginIcon from "./PluginIcon.vue";import { usePluginShortcuts } from "@/composables/usePluginShortcuts";import { usePluginShortcutPreferences } from "@/composables/usePluginShortcutPreferences";import { usePluginShortcutSort } from "@/composables/usePluginShortcutSort";+import { useCursorFloatingPosition } from "@/composables/useCursorFloatingPosition";import { usePluginShortcutHeight } from "@/composables/usePluginShortcutHeight";import { useSettingsStore } from "@/stores/settingsStore";import { useToast } from "@/composables/useToast";@@ -15,6 +18,8 @@ import { movePluginShortcut, type PluginShortcutEntry, type PluginShortcutPositiconst props = defineProps<{ position: PluginShortcutPosition }>();const { t } = useI18n();const settings = useSettingsStore();+const openSettings = inject(OPEN_PLUGIN_SETTINGS, () => {});+const showSettingsEntry = computed(() => settings.editorSettings.pluginShortcuts.showSettingsEntry);const { toast } = useToast();const { entries, open, isActive } = usePluginShortcuts();const { update, saving } = usePluginShortcutPreferences();@@ -56,6 +61,8 @@ const sorting = usePluginShortcutSort({},});const { drag } = sorting;+const preview = ref<HTMLElement | null>(null);+const previewStyle = useCursorFloatingPosition(preview, drag, () => (right.value ? "left" : "right"));const draggedEntry = computed(() => entries.value.find((entry) => entry.id === drag.source));watch(() => props.position, sorting.cancel);function activate(entry: PluginShortcutEntry) {@@ -66,6 +73,9 @@ function activate(entry: PluginShortcutEntry) {toast(String(error), 5000);}}+function activateSettings() {+ if (!sorting.suppressClick()) openSettings();+}</script><template>@@ -79,7 +89,7 @@ function activate(entry: PluginShortcutEntry) {@dragstart.prevent><div- v-if="sidebarList"+ v-if="sidebarList && entries.length"data-shortcut-resizerole="separator"tabindex="0"@@ -92,7 +102,15 @@ function activate(entry: PluginShortcutEntry) {@dblclick="!saving && sizing.reset()"@keydown="!saving && sizing.resizeWithKeyboard($event)"/>- <div ref="scroll" data-shortcut-scroll class="min-h-0 overflow-y-auto overflow-x-hidden p-1" :class="sidebarList ? 'shrink-0' : 'flex-1'" :style="sidebarList ? { height: `${sizing.height.value}px` } : undefined">+ <div v-if="sidebarList" data-shortcut-header class="flex h-8 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3" :class="{ 'border-t': !entries.length }">+ <span class="min-w-0 truncate text-xs font-medium text-muted-foreground">{{ t("pluginPlatform.shortcutsHeading") }}</span>+ <LightTooltip v-if="showSettingsEntry" :text="t('pluginPlatform.shortcutsSettings')" :disabled="drag.active || sizing.resizing.value" side="top">+ <Button variant="ghost" size="icon" data-plugin-shortcut-settings class="shortcut-button size-6 shrink-0" :aria-label="t('pluginPlatform.shortcutsSettings')" @click="activateSettings">+ <Settings2 class="size-3.5 text-foreground" />+ </Button>+ </LightTooltip>+ </div>+ <div v-show="!sidebarList || entries.length" ref="scroll" data-shortcut-scroll class="min-h-0 overflow-y-auto overflow-x-hidden p-1" :class="sidebarList ? 'shrink-0' : 'flex-1'" :style="sidebarList ? { height: `${sizing.height.value}px` } : undefined"><div class="shortcut-items flex flex-col" :class="sidebarList ? 'gap-0' : ['min-h-full gap-1', { 'shortcut-items--bottom': bottom }]"><LightTooltip v-for="(entry, index) in entries" :key="entry.id" :text="entry.label" :disabled="drag.active || sizing.resizing.value" :side="sidebarList ? 'top' : left ? 'right' : 'left'" content-class="shortcut-tooltip"><span@@ -124,14 +142,24 @@ function activate(entry: PluginShortcutEntry) {</Button></span></LightTooltip>+ <LightTooltip v-if="showSettingsEntry && !sidebarList" :text="t('pluginPlatform.shortcutsSettings')" :disabled="drag.active || sizing.resizing.value" :side="left ? 'right' : 'left'" content-class="shortcut-tooltip">+ <span class="relative flex shrink-0" :class="{ 'mt-auto': bottom && !entries.length, 'pt-2': entries.length > 0 }">+ <span v-if="entries.length" class="pointer-events-none absolute inset-x-2 top-0 z-10 h-px bg-border/60" aria-hidden="true" />+ <Button variant="ghost" size="icon" data-plugin-shortcut-settings class="shortcut-button size-8 shrink-0" :aria-label="t('pluginPlatform.shortcutsSettings')" @click="activateSettings">+ <Settings2 class="size-4 shrink-0 text-foreground" />+ </Button>+ </span>+ </LightTooltip></div></div><Teleport to="body"><div v-if="drag.active || sizing.resizing.value" class="shortcut-pointer-overlay fixed inset-0 select-none touch-none" :style="{ cursor: drag.active ? 'grabbing' : 'row-resize' }" aria-hidden="true" /><divv-if="drag.active && draggedEntry"- class="shortcut-drag-preview pointer-events-none fixed flex w-max max-w-xs items-center gap-2 rounded-md border border-primary/50 bg-popover px-2 py-1.5 text-xs text-popover-foreground shadow-md"- :style="{ left: `${drag.x + (right ? -12 : 12)}px`, top: `${drag.y + 12}px`, transform: right ? 'translateX(-100%)' : undefined }"+ ref="preview"+ data-shortcut-drag-preview+ class="shortcut-drag-preview pointer-events-none fixed flex w-max max-w-xs overflow-hidden items-center gap-2 rounded-md border border-primary/50 bg-popover px-2 py-1.5 text-xs text-popover-foreground shadow-md"+ :style="previewStyle"aria-hidden="true"><PluginIcon :plugin-id="draggedEntry.pluginId" :icon="draggedEntry.icon" class="size-4 [&_svg]:text-current" />diff --git a/apps/desktop/src/components/plugins/PluginShortcutSettings.spec.ts b/apps/desktop/src/components/plugins/PluginShortcutSettings.spec.tsindex a522dcc1da..5e33b8973d 100644--- a/apps/desktop/src/components/plugins/PluginShortcutSettings.spec.ts+++ b/apps/desktop/src/components/plugins/PluginShortcutSettings.spec.ts@@ -36,6 +36,16 @@ afterEach(() => {container.remove();});describe("plugin shortcut settings", () => {+ it("saves the settings shortcut choice without affecting plugin order", async () => {+ (container.querySelector("#plugin-shortcuts-settings-entry") as HTMLElement).click();+ await vi.waitFor(() => expect(mocks.state.editorSettings.pluginShortcuts.showSettingsEntry).toBe(false));+ expect(mocks.state.editorSettings.pluginShortcuts.order).toEqual(["saved"]);+ await vi.waitFor(() => expect(container.querySelector("#plugin-shortcuts-settings-entry")?.hasAttribute("disabled")).toBe(false));+ mocks.save.mockRejectedValueOnce(new Error("disk full"));+ (container.querySelector("#plugin-shortcuts-settings-entry") as HTMLElement).click();+ await vi.waitFor(() => expect(mocks.toast).toHaveBeenCalled());+ expect(mocks.state.editorSettings.pluginShortcuts.showSettingsEntry).toBe(false);+ });it("selects the Plugin Center dropdown and preserves unrelated preferences", async () => {const trigger = container.querySelector<HTMLElement>('[role="combobox"]')!;trigger.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }));@@ -48,8 +58,8 @@ describe("plugin shortcut settings", () => {});it("shows one toggle per plugin and preserves choices under the global switch", async () => {const switches = container.querySelectorAll<HTMLElement>('[role="switch"]');- expect(switches).toHaveLength(2);- switches[1].click();+ expect(switches).toHaveLength(3);+ switches[2].click();await vi.waitFor(() => expect(mocks.state.editorSettings.pluginShortcuts.hiddenPluginIds).toEqual(["p"]));await vi.waitFor(() => expect(switches[0].hasAttribute("disabled")).toBe(false));switches[0].click();diff --git a/apps/desktop/src/components/plugins/PluginShortcutSettings.vue b/apps/desktop/src/components/plugins/PluginShortcutSettings.vueindex 60bf815c67..93341cd9f7 100644--- a/apps/desktop/src/components/plugins/PluginShortcutSettings.vue+++ b/apps/desktop/src/components/plugins/PluginShortcutSettings.vue@@ -47,6 +47,10 @@ async function togglePlugin(pluginId: string, visible: boolean) {<Label for="plugin-shortcuts-enabled" class="text-xs">{{ t("pluginPlatform.shortcutsEnabled") }}</Label><Switch id="plugin-shortcuts-enabled" :model-value="settings.editorSettings.pluginShortcuts.enabled" :disabled="saving || !settings.isEditorSettingsLoaded" @update:model-value="update({ enabled: $event })" /></div>+ <div v-if="settings.editorSettings.pluginShortcuts.enabled" class="flex items-center justify-between gap-4">+ <Label for="plugin-shortcuts-settings-entry" class="text-xs">{{ t("pluginPlatform.shortcutsShowSettings") }}</Label>+ <Switch id="plugin-shortcuts-settings-entry" :model-value="settings.editorSettings.pluginShortcuts.showSettingsEntry" :disabled="saving || !settings.isEditorSettingsLoaded" @update:model-value="update({ showSettingsEntry: $event })" />+ </div><div v-if="settings.editorSettings.pluginShortcuts.enabled" class="flex items-center justify-between gap-4"><Label for="plugin-shortcuts-position" class="text-xs">{{ t("pluginPlatform.shortcutsPosition") }}</Label><Select :model-value="settings.editorSettings.pluginShortcuts.position" :disabled="saving || !settings.isEditorSettingsLoaded" @update:model-value="update({ position: String($event) as PluginShortcutSettings['position'] })">diff --git a/apps/desktop/src/components/plugins/PluginShortcutToolbar.spec.ts b/apps/desktop/src/components/plugins/PluginShortcutToolbar.spec.tsindex fb61db4b19..e4f30d7e3c 100644--- a/apps/desktop/src/components/plugins/PluginShortcutToolbar.spec.ts+++ b/apps/desktop/src/components/plugins/PluginShortcutToolbar.spec.ts@@ -1,10 +1,11 @@// @vitest-environment happy-domimport { createApp, h, nextTick, reactive, ref } from "vue";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { OPEN_PLUGIN_SETTINGS } from "@/lib/plugins/pluginCenterNavigation";import PluginShortcutToolbar from "./PluginShortcutToolbar.vue";import { normalizePluginShortcutSettings } from "@/lib/plugins/pluginShortcuts";-const mocks = vi.hoisted(() => ({ open: vi.fn(), save: vi.fn(), toast: vi.fn(), state: null as any, entries: null as any }));+const mocks = vi.hoisted(() => ({ openSettings: vi.fn(), open: vi.fn(), save: vi.fn(), toast: vi.fn(), state: null as any, entries: null as any }));vi.mock("vue-i18n", () => ({ useI18n: () => ({ t: (key: string) => key }) }));vi.mock("@/stores/settingsStore", () => ({ useSettingsStore: () => mocks.state }));vi.mock("@/composables/useToast", () => ({ useToast: () => ({ toast: mocks.toast }) }));@@ -27,7 +28,7 @@ beforeEach(() => {vi.clearAllMocks();width = undefined;dropdownOnly.value = false;- mocks.state = reactive({ isEditorSettingsLoaded: true, editorSettings: { pluginShortcuts: normalizePluginShortcutSettings({ position: "toolbar", toolbarCount: 2 }) }, updateEditorSettingsAndPersist: mocks.save });+ mocks.state = reactive({ isEditorSettingsLoaded: true, editorSettings: { pluginShortcuts: normalizePluginShortcutSettings({ position: "toolbar", toolbarCount: 2, showSettingsEntry: false }) }, updateEditorSettingsAndPersist: mocks.save });mocks.entries = ref(["a", "b", "c", "d", "e"].map((id) => ({ id, pluginId: id, label: `Function ${id}`, pluginName: `Plugin ${id}`, kind: "workbench", targetId: id, disabled: false })));mocks.save.mockResolvedValue(undefined);vi.spyOn(HTMLElement.prototype, "offsetWidth", "get").mockImplementation(function (this: HTMLElement) {@@ -47,6 +48,7 @@ beforeEach(() => {host = document.createElement("div");document.body.append(host);app = createApp({ render: () => h(PluginShortcutToolbar, { dropdownOnly: dropdownOnly.value }) });+ app.provide(OPEN_PLUGIN_SETTINGS, mocks.openSettings);app.mount(host);});afterEach(() => {@@ -70,6 +72,76 @@ function pointer(target: EventTarget, type: string, x: number, y: number) {}describe("floating plugin shortcuts", () => {+ it.each([false, true])("keeps drag previews in the viewport (dropdownOnly=%s)", async (menuOnly) => {+ dropdownOnly.value = menuOnly;+ if (menuOnly) await openMenu();+ else await flush();+ const original = HTMLElement.prototype.getBoundingClientRect;+ vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(function (this: HTMLElement) {+ return this.hasAttribute("data-shortcut-drag-preview") ? rect(0, 0, 180, 32) : original.call(this);+ });+ const item = document.querySelector<HTMLElement>("[data-shortcut-id]")!;+ pointer(item, "pointerdown", 16, 16);+ pointer(window, "pointermove", window.innerWidth - 2, window.innerHeight - 2);+ await flush();+ const preview = document.querySelector<HTMLElement>("[data-shortcut-drag-preview]")!;+ expect(preview.style.left).toBe(`${window.innerWidth - 194}px`);+ expect(preview.style.top).toBe(`${window.innerHeight - 46}px`);+ pointer(window, "pointermove", 2, 2);+ await flush();+ expect(preview.style.left).toBe("14px");+ expect(preview.style.top).toBe("14px");+ });++ it.each([false, true])("keeps settings as the last non-sortable menu action (dropdownOnly=%s)", async (menuOnly) => {+ dropdownOnly.value = menuOnly;+ mocks.state.editorSettings.pluginShortcuts.showSettingsEntry = true;+ await openMenu();+ const menu = document.querySelector<HTMLElement>("[data-plugin-shortcut-overflow]")!;+ const action = menu.querySelector<HTMLElement>("[data-plugin-shortcut-settings]")!;+ expect(menu.lastElementChild).toBe(action);+ expect(action.hasAttribute("data-shortcut-id")).toBe(false);+ pointer(action, "pointerdown", 16, 80);+ pointer(window, "pointermove", 1, 1);+ pointer(window, "pointerup", 1, 1);+ await flush();+ expect(mocks.save).not.toHaveBeenCalled();+ action.click();+ expect(mocks.openSettings).toHaveBeenCalledOnce();+ await flush();+ expect(document.querySelector("[data-plugin-shortcut-overflow]")).toBeNull();+ });+ it("reserves room for inline settings and moves it to overflow when the toolbar shrinks", async () => {+ mocks.state.editorSettings.pluginShortcuts.showSettingsEntry = true;+ mocks.state.editorSettings.pluginShortcuts.toolbarCount = 10;+ await flush();+ const buttons = host.querySelectorAll("button");+ expect(buttons[buttons.length - 1]?.hasAttribute("data-plugin-shortcut-settings")).toBe(true);+ width = 34;+ resize();+ await flush();+ expect(host.querySelector("[data-plugin-shortcut-settings]")).toBeNull();+ await openMenu();+ expect(document.querySelector("[data-plugin-shortcut-overflow]")?.lastElementChild?.hasAttribute("data-plugin-shortcut-settings")).toBe(true);+ mocks.state.editorSettings.pluginShortcuts.showSettingsEntry = false;+ await flush();+ expect(document.querySelector("[data-plugin-shortcut-settings]")).toBeNull();+ });+ it.each([false, true])("hides the entire area without visible plugins even when settings is enabled (dropdownOnly=%s)", async (menuOnly) => {+ dropdownOnly.value = menuOnly;+ mocks.state.editorSettings.pluginShortcuts.showSettingsEntry = true;+ await openMenu();+ const originalEntries = mocks.entries.value;+ mocks.entries.value = [];+ await flush();+ expect(host.querySelector("nav")).toBeNull();+ expect(document.querySelector("[data-plugin-shortcut-settings]")).toBeNull();+ expect(document.querySelector("[data-plugin-shortcut-overflow]")).toBeNull();+ mocks.entries.value = originalEntries;+ await flush();+ expect(host.querySelector("nav")).not.toBeNull();+ expect(document.querySelector("[data-plugin-shortcut-overflow]")).toBeNull();+ });it("shows all shortcuts beside Plugin Center regardless of the floating icon count", async () => {dropdownOnly.value = true;mocks.state.editorSettings.pluginShortcuts.toolbarCount = 10;diff --git a/apps/desktop/src/components/plugins/PluginShortcutToolbar.vue b/apps/desktop/src/components/plugins/PluginShortcutToolbar.vueindex 96dbcc5877..8f2130e7c1 100644--- a/apps/desktop/src/components/plugins/PluginShortcutToolbar.vue+++ b/apps/desktop/src/components/plugins/PluginShortcutToolbar.vue@@ -1,7 +1,8 @@<script setup lang="ts">-import { computed, nextTick, onScopeDispose, ref, watch } from "vue";+import { computed, inject, nextTick, onScopeDispose, ref, watch } from "vue";+import { OPEN_PLUGIN_SETTINGS } from "@/lib/plugins/pluginCenterNavigation";import { useI18n } from "vue-i18n";-import { ChevronDown } from "@lucide/vue";+import { ChevronDown, Settings2 } from "@lucide/vue";import { Button } from "@/components/ui/button";import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";import LightTooltip from "@/components/ui/LightTooltip.vue";@@ -9,6 +10,7 @@ import PluginIcon from "./PluginIcon.vue";import { usePluginShortcuts } from "@/composables/usePluginShortcuts";import { usePluginShortcutPreferences } from "@/composables/usePluginShortcutPreferences";import { usePluginShortcutSort } from "@/composables/usePluginShortcutSort";+import { useCursorFloatingPosition } from "@/composables/useCursorFloatingPosition";import { useSettingsStore } from "@/stores/settingsStore";import { useToast } from "@/composables/useToast";import { movePluginShortcut, pluginShortcutToolbarCount, pluginShortcutToolbarWidth, type PluginShortcutEntry } from "@/lib/plugins/pluginShortcuts";@@ -17,6 +19,8 @@ const props = defineProps<{ dropdownOnly?: boolean; menuAnchor?: HTMLElement | nconst emit = defineEmits<{ "layout-change": [] }>();const { t } = useI18n();const settings = useSettingsStore();+const openSettings = inject(OPEN_PLUGIN_SETTINGS, () => {});+const showSettingsEntry = computed(() => settings.editorSettings.pluginShortcuts.showSettingsEntry);const { toast } = useToast();const { entries, open, isActive } = usePluginShortcuts();const { update, saving } = usePluginShortcutPreferences();@@ -26,10 +30,11 @@ const moreTrigger = ref<HTMLElement | null>(null);const menuOpen = ref(false);const measuredWidth = ref<number | null>(null);const requested = computed(() => (props.dropdownOnly ? 0 : settings.editorSettings.pluginShortcuts.toolbarCount));-const preferredWidth = computed(() => pluginShortcutToolbarWidth(entries.value.length, requested.value));-const count = computed(() => pluginShortcutToolbarCount(entries.value.length, requested.value, measuredWidth.value ?? preferredWidth.value));+const preferredWidth = computed(() => pluginShortcutToolbarWidth(entries.value.length, requested.value) + (showSettingsEntry.value && entries.value.length <= requested.value ? (entries.value.length ? 30 : 34) : 0));+const count = computed(() => Math.min(entries.value.length, requested.value, pluginShortcutToolbarCount(entries.value.length + Number(showSettingsEntry.value), requested.value + Number(showSettingsEntry.value), measuredWidth.value ?? preferredWidth.value)));const inlineEntries = computed(() => entries.value.slice(0, count.value));const overflowEntries = computed(() => entries.value.slice(count.value));+const hasMenu = computed(() => entries.value.length > 0 && (overflowEntries.value.length > 0 || (props.dropdownOnly && showSettingsEntry.value)));const ids = computed(() => entries.value.map((entry) => entry.id));const sorting = usePluginShortcutSort({container: root,@@ -46,6 +51,8 @@ const sorting = usePluginShortcutSort({},});const { drag } = sorting;+const preview = ref<HTMLElement | null>(null);+const previewStyle = useCursorFloatingPosition(preview, drag);const draggedEntry = computed(() => entries.value.find((entry) => entry.id === drag.source));let observer: ResizeObserver | null = null;let hoverTimer: ReturnType<typeof setTimeout> | null = null;@@ -70,8 +77,8 @@ watch({ flush: "post" },);watch(preferredWidth, () => void nextTick(measure));-watch(overflowEntries, (entries) => {- if (!entries.length) menuOpen.value = false;+watch(hasMenu, (visible) => {+ if (!visible) menuOpen.value = false;});watch(menuOpen, (open) => {if (!open) sorting.cancel();@@ -111,6 +118,14 @@ function activate(entry: PluginShortcutEntry, event?: Event) {toast(String(error), 5000);}}+function activateSettings(event?: Event) {+ if (sorting.suppressClick()) {+ event?.preventDefault();+ return;+ }+ menuOpen.value = false;+ openSettings();+}onScopeDispose(() => {observer?.disconnect();clearHoverTimer();@@ -119,7 +134,7 @@ onScopeDispose(() => {<template><nav- v-if="settings.isEditorSettingsLoaded && entries.length"+ v-if="settings.isEditorSettingsLoaded && settings.editorSettings.pluginShortcuts.enabled && entries.length"ref="root"data-plugin-shortcut-toolbar:aria-label="t('pluginPlatform.shortcutsTitle')"@@ -141,10 +156,16 @@ onScopeDispose(() => {</Button></span></LightTooltip>- <DropdownMenu v-if="overflowEntries.length" v-model:open="menuOpen" :modal="false">+ <DropdownMenu v-if="hasMenu" v-model:open="menuOpen" :modal="false"><span ref="moreTrigger" class="flex shrink-0"><DropdownMenuTrigger as-child>- <Button variant="ghost" size="icon" class="shortcut-toolbar-button shrink-0" :class="[dropdownOnly ? 'h-8 w-7 rounded-l-none' : 'size-7', { 'bg-accent text-accent-foreground': menuOpen }]" :aria-label="t('pluginPlatform.shortcutsMore', { count: overflowEntries.length })">+ <Button+ variant="ghost"+ size="icon"+ class="shortcut-toolbar-button shrink-0"+ :class="[dropdownOnly ? 'h-8 w-7 rounded-l-none' : 'size-7', { 'bg-accent text-accent-foreground': menuOpen }]"+ :aria-label="overflowEntries.length ? t('pluginPlatform.shortcutsMore', { count: overflowEntries.length }) : t('pluginPlatform.shortcutsSettings')"+ ><ChevronDown class="size-3.5 transition-transform" :class="{ 'rotate-180': menuOpen }" /></Button></DropdownMenuTrigger>@@ -166,15 +187,28 @@ onScopeDispose(() => {<span class="min-w-0 flex-1 truncate" :title="entry.label">{{ entry.label }}</span><span v-if="isActive(entry)" class="size-1.5 shrink-0 rounded-full bg-green-500" aria-hidden="true" /></DropdownMenuItem>+ <DropdownMenuItem v-if="showSettingsEntry" data-plugin-shortcut-settings :text-value="t('pluginPlatform.shortcutsSettings')" class="relative min-h-8 gap-2 rounded-sm text-xs" @select="activateSettings">+ <span v-if="overflowEntries.length" class="pointer-events-none absolute inset-x-2 top-0 h-px bg-border/60" aria-hidden="true" />+ <Settings2 class="size-4 shrink-0 text-foreground" />+ <span class="min-w-0 flex-1 truncate">{{ t("pluginPlatform.shortcutsSettings") }}</span>+ </DropdownMenuItem></div></DropdownMenuContent></DropdownMenu>+ <LightTooltip v-if="showSettingsEntry && !hasMenu" :text="t('pluginPlatform.shortcutsSettings')" :disabled="drag.active" side="bottom" content-class="shortcut-toolbar-tooltip">+ <Button variant="ghost" size="icon" data-plugin-shortcut-settings class="shortcut-toolbar-button relative size-7 shrink-0" :aria-label="t('pluginPlatform.shortcutsSettings')" @click="activateSettings">+ <span v-if="inlineEntries.length" class="pointer-events-none absolute -left-0.5 inset-y-1 w-px bg-border/60" aria-hidden="true" />+ <Settings2 class="size-4 text-foreground" />+ </Button>+ </LightTooltip><Teleport to="body"><div v-if="drag.active" class="fixed inset-0 z-[2147483646] cursor-grabbing touch-none select-none" aria-hidden="true" /><divv-if="drag.active && draggedEntry"- class="pointer-events-none fixed z-[2147483647] flex max-w-xs items-center gap-2 rounded-md border border-primary/50 bg-popover px-2 py-1.5 text-xs text-popover-foreground shadow-md"- :style="{ left: `${drag.x + 12}px`, top: `${drag.y + 12}px` }"+ ref="preview"+ data-shortcut-drag-preview+ class="pointer-events-none fixed z-[2147483647] flex w-max max-w-xs overflow-hidden items-center gap-2 rounded-md border border-primary/50 bg-popover px-2 py-1.5 text-xs text-popover-foreground shadow-md"+ :style="previewStyle"aria-hidden="true"><PluginIcon :plugin-id="draggedEntry.pluginId" :icon="draggedEntry.icon" class="size-4 [&_svg]:text-current" />diff --git a/apps/desktop/src/components/plugins/__tests__/PluginContributionsPanelBatch.spec.ts b/apps/desktop/src/components/plugins/__tests__/PluginContributionsPanelBatch.spec.tsindex fb492b5c65..a69aa1be9c 100644--- a/apps/desktop/src/components/plugins/__tests__/PluginContributionsPanelBatch.spec.ts+++ b/apps/desktop/src/components/plugins/__tests__/PluginContributionsPanelBatch.spec.ts@@ -1,6 +1,6 @@// @vitest-environment happy-dom-import { createApp, nextTick, type App, type ComponentPublicInstance } from "vue";+import { createApp, h, ref, nextTick, type App, type ComponentPublicInstance } from "vue";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import type { InstalledPlugin, PluginRepositoryCatalogResult } from "@/types/database";import { formatMarketplaceReleasedDate, type MarketplacePluginListing } from "@/lib/plugins/pluginMarketplace";@@ -65,6 +65,7 @@ vi.mock("@/components/plugins/PluginShortcutSettings.vue", async () => ({ defaulimport PluginContributionsPanel from "@/components/plugins/PluginContributionsPanel.vue";type PanelState = {+ activeSection: "marketplace" | "installed" | "settings";batchRunning: boolean;batchMode: boolean;marketplaceViewMode: "grid" | "list";@@ -939,3 +940,49 @@ describe("PluginContributionsPanel single uninstall outcomes", () => {expect(state.error).toBe('pluginPlatform.batchRefreshFailed:{"error":"refresh offline"}');});});++describe("PluginContributionsPanel settings navigation", () => {+ it.each(["marketplace", "installed"] as const)("preserves navigation to %s while the initial refresh is pending", async (section) => {+ app.unmount();+ const pending = deferred<InstalledPlugin[]>();+ mocks.listPlugins.mockReturnValue(pending.promise);+ app = createApp(PluginContributionsPanel, { focusTarget: { section: "settings" } });+ const instance = app.mount(host) as ComponentPublicInstance & { $: { setupState: PanelState } };+ const current = instance.$.setupState;+ expect(current.activeSection).toBe("settings");+ current.activeSection = section;+ await nextTick();+ pending.resolve([installed("a")]);+ await flushUi();+ expect(current.activeSection).toBe(section);+ });++ it.each(["empty", "installed", "load-failure"])("opens and reopens settings without depending on plugin loading (%s)", async (scenario) => {+ app.unmount();+ host.remove();+ host = document.createElement("div");+ document.body.append(host);+ if (scenario === "load-failure") mocks.listPlugins.mockRejectedValue(new Error("unavailable"));+ else mocks.listPlugins.mockResolvedValue(scenario === "empty" ? [] : [installed("a")]);+ const focus = ref<{ section: "settings" }>({ section: "settings" });+ let panel!: ComponentPublicInstance;+ app = createApp({+ render: () =>+ h(PluginContributionsPanel, {+ focusTarget: focus.value,+ ref: (value) => {+ panel = value as ComponentPublicInstance;+ },+ }),+ });+ app.mount(host);+ const current = (panel as ComponentPublicInstance & { $: { setupState: PanelState } }).$.setupState;+ expect(current.activeSection).toBe("settings");+ await flushUi();+ expect(current.activeSection).toBe("settings");+ current.activeSection = "marketplace";+ focus.value = { section: "settings" };+ await nextTick();+ expect(current.activeSection).toBe("settings");+ });+});diff --git a/apps/desktop/src/composables/__tests__/useCursorFloatingPosition.spec.ts b/apps/desktop/src/composables/__tests__/useCursorFloatingPosition.spec.tsnew file mode 100644index 0000000000..59c301c61b--- /dev/null+++ b/apps/desktop/src/composables/__tests__/useCursorFloatingPosition.spec.ts@@ -0,0 +1,67 @@+// @vitest-environment happy-dom+import { createApp, h, nextTick, reactive, ref } from "vue";+import { afterEach, expect, it, vi } from "vitest";+import { useCursorFloatingPosition } from "../useCursorFloatingPosition";++let app: ReturnType<typeof createApp>;+let host: HTMLDivElement;+afterEach(() => {+ app?.unmount();+ host?.remove();+ vi.restoreAllMocks();+ vi.unstubAllGlobals();+});++it("remeasures content and window changes, limits long previews, and cleans up observers", async () => {+ vi.stubGlobal("innerWidth", 300);+ vi.stubGlobal("innerHeight", 200);+ let resized!: () => void;+ const disconnect = vi.fn();+ vi.stubGlobal(+ "ResizeObserver",+ class {+ constructor(callback: () => void) {+ resized = callback;+ }+ observe() {}+ disconnect = disconnect;+ },+ );+ const removeListener = vi.spyOn(window, "removeEventListener");+ let contentWidth = 180;+ vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(function (this: HTMLElement) {+ const width = Math.min(contentWidth, parseFloat(this.style.maxWidth.split(",")[1]));+ return { width, height: 32 } as DOMRect;+ });+ const cursor = reactive({ x: 290, y: 190 });+ const visible = ref(true);+ app = createApp({+ setup() {+ const preview = ref<HTMLElement | null>(null);+ const style = useCursorFloatingPosition(preview, cursor);+ return () => (visible.value ? h("div", { ref: preview, style: style.value }) : null);+ },+ });+ host = document.createElement("div");+ document.body.append(host);+ app.mount(host);+ await nextTick();+ await nextTick();+ const preview = host.firstElementChild as HTMLElement;+ expect(preview.style.left).toBe("98px");+ expect(preview.style.top).toBe("146px");+ contentWidth = 1000;+ resized();+ await nextTick();+ expect(preview.style.left).toBe("8px");+ expect(preview.style.maxWidth).toBe("min(20rem, 284px)");+ vi.stubGlobal("innerWidth", 160);+ window.dispatchEvent(new Event("resize"));+ await nextTick();+ expect(preview.style.maxWidth).toBe("min(20rem, 144px)");+ expect(preview.style.left).toBe("8px");+ visible.value = false;+ await nextTick();+ expect(disconnect).toHaveBeenCalledOnce();+ expect(removeListener).toHaveBeenCalledWith("resize", expect.any(Function));+});diff --git a/apps/desktop/src/composables/__tests__/usePluginShortcutHeight.spec.ts b/apps/desktop/src/composables/__tests__/usePluginShortcutHeight.spec.tsindex dbbd711cc8..144d1148f7 100644--- a/apps/desktop/src/composables/__tests__/usePluginShortcutHeight.spec.ts+++ b/apps/desktop/src/composables/__tests__/usePluginShortcutHeight.spec.ts@@ -76,6 +76,16 @@ async function setup() {};}describe("shortcut sidebar height", () => {+ it("reserves the title row as well as 120px for the connection tree", async () => {+ const { sizing, savedHeight, setTotal } = await setup();+ const header = document.createElement("div");+ header.setAttribute("data-shortcut-header", "");+ Object.defineProperty(header, "offsetHeight", { get: () => 32 });+ root.querySelector("nav")!.append(header);+ savedHeight.value = 500;+ setTotal(300);+ expect(sizing.height.value).toBe(142);+ });it("does not attach a resize observer after disposal during a pending measurement", async () => {const observe = vi.fn();vi.stubGlobal(diff --git a/apps/desktop/src/composables/useCursorFloatingPosition.ts b/apps/desktop/src/composables/useCursorFloatingPosition.tsnew file mode 100644index 0000000000..dfd187da0a--- /dev/null+++ b/apps/desktop/src/composables/useCursorFloatingPosition.ts@@ -0,0 +1,37 @@+import { ref, watch, type CSSProperties, type Ref } from "vue";+import { floatingCursorPosition } from "@/lib/common/floatingViewportPosition";++/** Measure after mounting and whenever the preview or viewport changes. Coordinates are CSS pixels. */+export function useCursorFloatingPosition(element: Ref<HTMLElement | null>, cursor: { x: number; y: number }, preferredSide: () => "left" | "right" = () => "right") {+ const style = ref<CSSProperties>({ visibility: "hidden" });+ function update() {+ const preview = element.value;+ if (!preview) return;+ const width = window.innerWidth;+ const height = window.innerHeight;+ // Apply constraints before measuring so truncation and narrow windows use the actual rendered size.+ preview.style.maxWidth = `min(20rem, ${Math.max(0, width - 16)}px)`;+ preview.style.maxHeight = `${Math.max(0, height - 16)}px`;+ const position = floatingCursorPosition(cursor, preview.getBoundingClientRect(), { width, height }, preferredSide());+ style.value = { left: `${position.x}px`, top: `${position.y}px`, maxWidth: preview.style.maxWidth, maxHeight: preview.style.maxHeight };+ }+ watch([element, () => cursor.x, () => cursor.y, preferredSide], update, { flush: "post" });+ watch(+ element,+ (preview, _, onCleanup) => {+ if (!preview) {+ style.value = { visibility: "hidden" };+ return;+ }+ const observer = new ResizeObserver(update);+ observer.observe(preview);+ window.addEventListener("resize", update);+ onCleanup(() => {+ observer.disconnect();+ window.removeEventListener("resize", update);+ });+ },+ { flush: "post" },+ );+ return style;+}diff --git a/apps/desktop/src/composables/usePluginShortcutHeight.ts b/apps/desktop/src/composables/usePluginShortcutHeight.tsindex dd91984777..416bcb7936 100644--- a/apps/desktop/src/composables/usePluginShortcutHeight.ts+++ b/apps/desktop/src/composables/usePluginShortcutHeight.ts@@ -24,8 +24,9 @@ export function usePluginShortcutHeight(options: { section: Ref<HTMLElement | nuif (!section || !scroll || !options.sidebarList.value) return;const tree = section.previousElementSibling as HTMLElement | null;const divider = section.querySelector<HTMLElement>("[data-shortcut-resize]");- available.value = (tree?.offsetHeight ?? 0) + section.offsetHeight - (divider?.offsetHeight ?? 0);- const item = scroll.querySelector<HTMLElement>("[data-shortcut-id]");+ const header = section.querySelector<HTMLElement>("[data-shortcut-header]");+ available.value = (tree?.offsetHeight ?? 0) + section.offsetHeight - (divider?.offsetHeight ?? 0) - (header?.offsetHeight ?? 0);+ const item = scroll.querySelector<HTMLElement>("[data-shortcut-id], [data-plugin-shortcut-settings]");const grid = scroll.firstElementChild;itemSize.value = item?.offsetHeight || 28;gap.value = grid ? parseFloat(getComputedStyle(grid).gap) || 0 : 0;diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.tsindex 3d0e45fc01..a84346a79b 100644--- a/apps/desktop/src/i18n/locales/az.ts+++ b/apps/desktop/src/i18n/locales/az.ts@@ -105,6 +105,9 @@ export default withEnglishFallback({missingConnection: "Silinmiş bağlantı ({id})",revokeFailed: "Giriş ləğv edilmədi: {message}",},+ shortcutsHeading: "Plaginlər",+ shortcutsSettings: "Plagin parametrləri",+ shortcutsShowSettings: "Plagin parametrləri qısayolunu göstər",shortcutsPluginCenter: "Plagin mərkəzinin yanında (açılan menyu)",shortcutsToolbar: "Yeniləmə düyməsinin solunda (üzən)",shortcutsToolbarCount: "Görünən nişanların sayı",diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.tsindex eca09714d3..97bd86fe49 100644--- a/apps/desktop/src/i18n/locales/en.ts+++ b/apps/desktop/src/i18n/locales/en.ts@@ -205,6 +205,9 @@ export default {globalSettingsTitle: "Global settings",shortcutsTitle: "Plugin shortcuts",shortcutsDescription: "Choose where plugin shortcuts appear. Drag icons to reorder them.",+ shortcutsHeading: "Plugins",+ shortcutsSettings: "Plugin settings",+ shortcutsShowSettings: "Show plugin settings shortcut",shortcutsEnabled: "Show plugin shortcuts",shortcutsPosition: "Position",shortcutsBottom: "Connection tree bottom",diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.tsindex 4b9bcb7703..dff815f321 100644--- a/apps/desktop/src/i18n/locales/es.ts+++ b/apps/desktop/src/i18n/locales/es.ts@@ -208,6 +208,9 @@ export default withEnglishFallback({globalSettingsTitle: "Configuración global",shortcutsTitle: "Accesos a complementos",shortcutsDescription: "Elige la ubicación de los accesos. Arrastra los iconos para reordenarlos.",+ shortcutsHeading: "Plugins",+ shortcutsSettings: "Ajustes de plugins",+ shortcutsShowSettings: "Mostrar acceso a ajustes de plugins",shortcutsEnabled: "Mostrar accesos a complementos",shortcutsPosition: "Ubicación",shortcutsBottom: "Debajo del árbol de conexiones",diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.tsindex 4c329b5af9..0bf17e17ed 100644--- a/apps/desktop/src/i18n/locales/it.ts+++ b/apps/desktop/src/i18n/locales/it.ts@@ -208,6 +208,9 @@ export default withEnglishFallback({globalSettingsTitle: "Impostazioni globali",shortcutsTitle: "Scorciatoie dei plugin",shortcutsDescription: "Scegli la posizione delle scorciatoie. Trascina le icone per riordinarle.",+ shortcutsHeading: "Plugin",+ shortcutsSettings: "Impostazioni plugin",+ shortcutsShowSettings: "Mostra collegamento alle impostazioni plugin",shortcutsEnabled: "Mostra scorciatoie dei plugin",shortcutsPosition: "Posizione",shortcutsBottom: "Sotto l’albero delle connessioni",diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.tsindex 30805a7c4a..3a685bcdba 100644--- a/apps/desktop/src/i18n/locales/ja.ts+++ b/apps/desktop/src/i18n/locales/ja.ts@@ -208,6 +208,9 @@ export default withEnglishFallback({globalSettingsTitle: "グローバル設定",shortcutsTitle: "プラグインショートカット",shortcutsDescription: "表示位置を選択します。アイコンをドラッグして並べ替えできます。",+ shortcutsHeading: "プラグイン",+ shortcutsSettings: "プラグイン設定",+ shortcutsShowSettings: "プラグイン設定のショートカットを表示",shortcutsEnabled: "プラグインショートカットを表示",shortcutsPosition: "表示位置",shortcutsBottom: "接続ツリーの下部",diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.tsindex 2e5b0ea312..8312763ab4 100644--- a/apps/desktop/src/i18n/locales/ko.ts+++ b/apps/desktop/src/i18n/locales/ko.ts@@ -207,6 +207,9 @@ export default withEnglishFallback({globalSettingsTitle: "전역 설정",shortcutsTitle: "플러그인 바로가기",shortcutsDescription: "표시 위치를 선택하세요. 아이콘을 드래그하여 순서를 변경할 수 있습니다.",+ shortcutsHeading: "플러그인",+ shortcutsSettings: "플러그인 설정",+ shortcutsShowSettings: "플러그인 설정 바로가기 표시",shortcutsEnabled: "플러그인 바로가기 표시",shortcutsPosition: "표시 위치",shortcutsBottom: "연결 트리 하단",diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.tsindex 54391d7f20..31adde4c54 100644--- a/apps/desktop/src/i18n/locales/pt-BR.ts+++ b/apps/desktop/src/i18n/locales/pt-BR.ts@@ -208,6 +208,9 @@ export default withEnglishFallback({globalSettingsTitle: "Configurações globais",shortcutsTitle: "Atalhos de plugins",shortcutsDescription: "Escolha a posição dos atalhos. Arraste os ícones para reordená-los.",+ shortcutsHeading: "Plugins",+ shortcutsSettings: "Configurações de plugins",+ shortcutsShowSettings: "Mostrar atalho das configurações de plugins",shortcutsEnabled: "Mostrar atalhos de plugins",shortcutsPosition: "Posição",shortcutsBottom: "Abaixo da árvore de conexões",diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.tsindex e38342ed28..655115fda8 100644--- a/apps/desktop/src/i18n/locales/ru.ts+++ b/apps/desktop/src/i18n/locales/ru.ts@@ -155,6 +155,9 @@ export default withEnglishFallback({globalSettingsTitle: "Общие настройки",shortcutsTitle: "Быстрый доступ к плагинам",shortcutsDescription: "Выберите расположение панели. Перетаскивайте значки, чтобы изменить их порядок.",+ shortcutsHeading: "Плагины",+ shortcutsSettings: "Настройки плагинов",+ shortcutsShowSettings: "Показывать ярлык настроек плагинов",shortcutsEnabled: "Показывать быстрый доступ к плагинам",shortcutsPosition: "Расположение",shortcutsBottom: "Под деревом подключений",diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.tsindex f891cc0625..5fe3db8665 100644--- a/apps/desktop/src/i18n/locales/tr.ts+++ b/apps/desktop/src/i18n/locales/tr.ts@@ -107,6 +107,9 @@ export default withEnglishFallback({missingConnection: "Silinmiş bağlantı ({id})",revokeFailed: "Erişim iptal edilemedi: {message}",},+ shortcutsHeading: "Eklentiler",+ shortcutsSettings: "Eklenti ayarları",+ shortcutsShowSettings: "Eklenti ayarları kısayolunu göster",shortcutsPluginCenter: "Eklenti merkezinin yanında (açılır menü)",shortcutsToolbar: "Güncelle düğmesinin solunda (kayan)",shortcutsToolbarCount: "Görünür simge sayısı",diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.tsindex 4c509461c4..c1cb73ee18 100644--- a/apps/desktop/src/i18n/locales/zh-CN.ts+++ b/apps/desktop/src/i18n/locales/zh-CN.ts@@ -130,6 +130,9 @@ export default withEnglishFallback({globalSettingsTitle: "全局配置",shortcutsTitle: "插件快捷入口",shortcutsDescription: "选择插件快捷入口的显示位置,拖动图标可调整顺序。",+ shortcutsHeading: "插件",+ shortcutsSettings: "插件设置",+ shortcutsShowSettings: "显示“插件设置”快捷入口",shortcutsEnabled: "显示插件快捷入口",shortcutsPosition: "显示位置",shortcutsBottom: "连接树底部",diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.tsindex 2091a562cc..d949a93da0 100644--- a/apps/desktop/src/i18n/locales/zh-TW.ts+++ b/apps/desktop/src/i18n/locales/zh-TW.ts@@ -208,6 +208,9 @@ export default withEnglishFallback({globalSettingsTitle: "全域設定",shortcutsTitle: "外掛程式快捷入口",shortcutsDescription: "選擇外掛程式快捷入口的顯示位置,拖曳圖示可調整順序。",+ shortcutsHeading: "外掛",+ shortcutsSettings: "外掛設定",+ shortcutsShowSettings: "顯示「外掛設定」快捷入口",shortcutsEnabled: "顯示外掛程式快捷入口",shortcutsPosition: "顯示位置",shortcutsBottom: "連線樹底部",diff --git a/apps/desktop/src/lib/__tests__/common/floatingViewportPosition.spec.ts b/apps/desktop/src/lib/__tests__/common/floatingViewportPosition.spec.tsindex a2f32f174c..a0afefe14f 100644--- a/apps/desktop/src/lib/__tests__/common/floatingViewportPosition.spec.ts+++ b/apps/desktop/src/lib/__tests__/common/floatingViewportPosition.spec.ts@@ -1,7 +1,23 @@import { describe, expect, it } from "vitest";-import { floatingArrowOffset, floatingViewportShift } from "@/lib/common/floatingViewportPosition";+import { floatingArrowOffset, floatingCursorPosition, floatingViewportShift } from "@/lib/common/floatingViewportPosition";describe("floating viewport position", () => {+ it.each([+ { cursor: { x: 400, y: 300 }, side: "right", expected: { x: 412, y: 312 } },+ { cursor: { x: 400, y: 300 }, side: "left", expected: { x: 188, y: 312 } },+ { cursor: { x: 790, y: 590 }, side: "right", expected: { x: 578, y: 538 } },+ { cursor: { x: 2, y: 2 }, side: "left", expected: { x: 14, y: 14 } },+ { cursor: { x: -30, y: -30 }, side: "left", expected: { x: 8, y: 8 } },+ { cursor: { x: 900, y: 700 }, side: "right", expected: { x: 592, y: 552 } },+ ] as const)("follows and flips around $cursor with $side preference", ({ cursor, side, expected }) => {+ expect(floatingCursorPosition(cursor, { width: 200, height: 40 }, { width: 800, height: 600 }, side)).toEqual(expected);+ });++ it("clamps when neither side has enough room, including oversized surfaces", () => {+ expect(floatingCursorPosition({ x: 150, y: 40 }, { width: 284, height: 64 }, { width: 300, height: 80 })).toEqual({ x: 8, y: 8 });+ expect(floatingCursorPosition({ x: 1, y: 1 }, { width: 200, height: 40 }, { width: 4, height: 4 })).toEqual({ x: 2, y: 2 });+ });+it("moves a floating element inside each viewport edge", () => {expect(floatingViewportShift({ left: -24, right: 296, top: 40, bottom: 80 }, { width: 800, height: 600 })).toEqual({ x: 32, y: 0 });expect(floatingViewportShift({ left: 600, right: 840, top: 40, bottom: 80 }, { width: 800, height: 600 })).toEqual({ x: -48, y: 0 });diff --git a/apps/desktop/src/lib/common/floatingViewportPosition.ts b/apps/desktop/src/lib/common/floatingViewportPosition.tsindex cd29da3eda..9af79d741f 100644--- a/apps/desktop/src/lib/common/floatingViewportPosition.ts+++ b/apps/desktop/src/lib/common/floatingViewportPosition.ts@@ -10,6 +10,23 @@ export interface FloatingViewport {height: number;}+/** Place a cursor-following surface, flipping each axis before clamping to the viewport. */+export function floatingCursorPosition(cursor: { x: number; y: number }, size: { width: number; height: number }, viewport: FloatingViewport, preferredSide: "left" | "right" = "right", gap = 12, margin = 8): { x: number; y: number } {+ function axis(pointer: number, length: number, extent: number, before: boolean) {+ const inset = Math.min(margin, Math.max(0, extent / 2));+ const maximum = Math.max(inset, extent - inset - length);+ const preferred = before ? pointer - gap - length : pointer + gap;+ const alternative = before ? pointer + gap : pointer - gap - length;+ const fits = (value: number) => value >= inset && value + length <= extent - inset;+ const position = fits(preferred) ? preferred : fits(alternative) ? alternative : preferred;+ return Math.min(maximum, Math.max(inset, position));+ }+ return {+ x: axis(cursor.x, size.width, viewport.width, preferredSide === "left"),+ y: axis(cursor.y, size.height, viewport.height, false),+ };+}+export function floatingViewportShift(rect: FloatingRect, viewport: FloatingViewport, margin = 8): { x: number; y: number } {let x = 0;let y = 0;diff --git a/apps/desktop/src/lib/plugins/pluginCenterNavigation.ts b/apps/desktop/src/lib/plugins/pluginCenterNavigation.tsindex eeac2ea8d5..8bdb25af58 100644--- a/apps/desktop/src/lib/plugins/pluginCenterNavigation.ts+++ b/apps/desktop/src/lib/plugins/pluginCenterNavigation.ts@@ -1,4 +1,9 @@+import type { InjectionKey } from "vue";++export const OPEN_PLUGIN_SETTINGS: InjectionKey<() => void> = Symbol("open-plugin-settings");+export interface PluginCenterFocus {+ section?: "settings";pluginId?: string;providerId?: string;}diff --git a/apps/desktop/src/lib/plugins/pluginShortcuts.spec.ts b/apps/desktop/src/lib/plugins/pluginShortcuts.spec.tsindex e6cd56bda8..c57cd5c5f2 100644--- a/apps/desktop/src/lib/plugins/pluginShortcuts.spec.ts+++ b/apps/desktop/src/lib/plugins/pluginShortcuts.spec.ts@@ -45,8 +45,10 @@ describe("plugin shortcuts", () => {expect(clampPluginShortcutHeight(40, 130)).toBe(10);});it("normalizes old and malformed preferences with independent default arrays", () => {- expect(normalizePluginShortcutSettings(null)).toEqual({ enabled: true, position: "right-top", order: [], hiddenPluginIds: [], sidebarHeight: null, toolbarCount: 3 });- expect(normalizePluginShortcutSettings({ enabled: "false", position: "top", order: [null, "a", "", "a", "b"] })).toEqual({ enabled: true, position: "right-top", order: ["a", "b"], hiddenPluginIds: [], sidebarHeight: null, toolbarCount: 3 });+ expect(normalizePluginShortcutSettings({ showSettingsEntry: "false" }).showSettingsEntry).toBe(true);+ expect(normalizePluginShortcutSettings({ showSettingsEntry: false }).showSettingsEntry).toBe(false);+ expect(normalizePluginShortcutSettings(null)).toEqual({ enabled: true, position: "right-top", order: [], hiddenPluginIds: [], sidebarHeight: null, toolbarCount: 3, showSettingsEntry: true });+ expect(normalizePluginShortcutSettings({ enabled: "false", position: "top", order: [null, "a", "", "a", "b"] })).toEqual({ enabled: true, position: "right-top", order: ["a", "b"], hiddenPluginIds: [], sidebarHeight: null, toolbarCount: 3, showSettingsEntry: true });expect(normalizePluginShortcutSettings({ enabled: false, position: "sidebar-bottom" }).enabled).toBe(false);});it("includes legacy standalone workbenches and filesystems but not connection-bound surfaces", () => {diff --git a/apps/desktop/src/lib/plugins/pluginShortcuts.ts b/apps/desktop/src/lib/plugins/pluginShortcuts.tsindex 546ce00743..ebe816d74f 100644--- a/apps/desktop/src/lib/plugins/pluginShortcuts.ts+++ b/apps/desktop/src/lib/plugins/pluginShortcuts.ts@@ -4,6 +4,7 @@ import type { PluginCommandContribution } from "@/types/database";export type PluginShortcutPosition = "left-top" | "left-bottom" | "right-top" | "right-bottom" | "sidebar-bottom" | "toolbar" | "plugin-center";export interface PluginShortcutSettings {enabled: boolean;+ showSettingsEntry: boolean;position: PluginShortcutPosition;order: string[];hiddenPluginIds: string[];@@ -17,6 +18,7 @@ export function normalizePluginShortcutSettings(value: unknown): PluginShortcutSconst strings = (values: unknown): string[] => (Array.isArray(values) ? [...new Set(values.filter((id): id is string => typeof id === "string" && id.length > 0))] : []);return {enabled: typeof input.enabled === "boolean" ? input.enabled : true,+ showSettingsEntry: typeof input.showSettingsEntry === "boolean" ? input.showSettingsEntry : true,position: position === "left" ? "left-top" : position === "left-top" || position === "left-bottom" || position === "right-bottom" || position === "sidebar-bottom" || position === "toolbar" || position === "plugin-center" ? position : "right-top",order: strings(input.order),hiddenPluginIds: strings(input.hiddenPluginIds),diff --git a/apps/desktop/src/stores/__tests__/settingsStore.pluginShortcuts.spec.ts b/apps/desktop/src/stores/__tests__/settingsStore.pluginShortcuts.spec.tsindex 7475a72810..a425ece50d 100644--- a/apps/desktop/src/stores/__tests__/settingsStore.pluginShortcuts.spec.ts+++ b/apps/desktop/src/stores/__tests__/settingsStore.pluginShortcuts.spec.ts@@ -18,7 +18,7 @@ describe("plugin shortcut persistence", () => {});const first = useSettingsStore();await first.initEditorSettings();- const pluginShortcuts = { enabled: false, position, order: ["b", "missing", "a"], hiddenPluginIds: ["hidden"], sidebarHeight: 132, toolbarCount: 6 };+ const pluginShortcuts = { enabled: false, position, order: ["b", "missing", "a"], hiddenPluginIds: ["hidden"], sidebarHeight: 132, toolbarCount: 6, showSettingsEntry: false };await first.updateEditorSettingsAndPersist({ pluginShortcuts });setActivePinia(createPinia());const second = useSettingsStore();diff --git a/docs/content/docs/plugin-development.cn.mdx b/docs/content/docs/plugin-development.cn.mdxindex ede8dd51a6..7ea7710520 100644--- a/docs/content/docs/plugin-development.cn.mdx+++ b/docs/content/docs/plugin-development.cn.mdx@@ -17,8 +17,12 @@ DBX 插件是独立安装的 `.dbxp` 包,可以提供连接类型、工作台在 **插件中心 → 设置 → 全局配置** 中管理快捷入口。默认开启并显示在右侧顶部;可选择左侧或右侧的顶部/底部优先、连接树底部,或更新按钮左侧的浮动栏。浮动栏默认显示 3 个图标,可设置 0–10 个,空间不足的入口放入下拉菜单,以图标和名称逐行显示。+连接树底部区域的「插件」标题栏右上角默认提供「插件设置」入口,其他显示位置则将该入口固定在末尾,点击直达插件中心的设置页,不参与拖动排序。浮动栏溢出时,该入口位于下拉菜单末尾。在「全局配置」中关闭「显示“插件设置”快捷入口」可隐藏它;仍可从插件中心的「设置」页重新开启。没有可显示的插件快捷入口时,整个快捷区域(包括设置入口)隐藏,不占用布局空间。+每个功能有独立图标,可以拖动排序;显示开关按插件生效,关闭后隐藏该插件的所有入口。所有位置共用保存的顺序。隐藏或卸载不会删除已有排序记录,重新出现的相同入口恢复原位置,未记录的入口排列在已保存入口之后。排序标识由插件 ID、入口类型和功能 ID 组成,修改这些 ID 会被视为新入口。+拖动预览跟随光标,靠近窗口边缘时自动调整方向和位置;右侧停靠优先显示在光标左侧,长名称会根据可用宽度省略显示。+选择「插件中心右侧(下拉)」可通过插件中心按钮旁的箭头展开全部快捷入口,每行显示图标和名称,支持拖动排序;该位置不受浮动栏显示数量限制。连接树底部采用左侧图标、右侧名称的单列列表,行样式和字号与连接树一致。默认按入口数量显示所需行数,最多五行,超出后竖向滚动。拖动分隔线可保存自定义高度,双击恢复自动高度。拖动图标时按 Esc、切换窗口或在区域外释放会取消排序;保存失败会提示并回滚。diff --git a/docs/content/docs/plugin-development.mdx b/docs/content/docs/plugin-development.mdxindex 6e3a8339da..c16ce0ebb9 100644--- a/docs/content/docs/plugin-development.mdx+++ b/docs/content/docs/plugin-development.mdx@@ -17,8 +17,12 @@ DBX plugins are independently installed `.dbxp` packages that can contribute conManage shortcuts in **Plugin Center → Settings → Global settings**. They are enabled by default at the top right. Choose the top or bottom of either side, below the connection tree, or a floating strip before Update. The floating strip shows 3 icons by default, configurable from 0 to 10; remaining entries appear in a dropdown, one icon and name per row. Limited space moves additional entries into the dropdown.+Below the connection tree, **Plugin settings** sits at the top right of the **Plugins** header. Other positions include it as a fixed entry at the end by default. It opens the Plugin Center settings page directly and cannot be reordered. When the floating toolbar overflows, this entry is last in its dropdown. Disable **Show plugin settings shortcut** in global settings to hide it; you can enable it again from Plugin Center → Settings. When no plugin shortcuts are visible, the entire shortcut area, including the settings entry, is hidden and takes up no layout space.+Each function has its own draggable icon. Visibility switches apply to a whole plugin. All positions share the saved order. Hiding or uninstalling a plugin retains its recorded positions, so the same entries return to those positions; unrecorded entries follow saved entries. Entry identity consists of the plugin ID, entry kind, and function ID. Changing these IDs creates a new entry.+Drag previews follow the cursor and adjust their direction and position near window edges. Right-docked shortcuts prefer the left side of the cursor; long names are truncated to the available width.+Choose **Beside Plugin Center (dropdown)** to show all shortcuts as icon-and-name rows in the menu beside the Plugin Center button. Rows support drag sorting; the floating toolbar icon count does not apply here.Below the connection tree, shortcuts form a single-column list with an icon on the left and a name on the right, using the tree’s row style and font size. Automatic height fits one entry per row up to five rows, with vertical scrolling for remaining entries. Drag the divider to save a custom height; double-click it to restore automatic height. Escape, window blur, or releasing outside the sorting area cancels sorting. Failed saves show an error and roll back.