25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(settings): apply the sidebarExpandTreeOnConnect toggle (#13549) (#13574)
OkaneGai0a1ae793c268
diff --git a/apps/desktop/src/stores/__tests__/settingsStore.spec.ts b/apps/desktop/src/stores/__tests__/settingsStore.spec.tsindex ac5723ea86..9d26a5588e 100644--- a/apps/desktop/src/stores/__tests__/settingsStore.spec.ts+++ b/apps/desktop/src/stores/__tests__/settingsStore.spec.ts@@ -28,6 +28,7 @@ import {} from "@/stores/settingsStore";import type { AiConfigItem } from "@/types/ai";import { DATA_GRID_DEFAULT_VISIBLE_COPY_EXTRACTORS, DATA_GRID_EXTRACTOR_OPTIONS_MIGRATION_VERSION } from "@/lib/dataGrid/dataGridCopyExtractor";+import { editorSettingsDraftChanged, editorSettingsDraftFromSettings, editorSettingsPatchFromDraft } from "@/lib/settings/editorSettingsDraft";import { DEFAULT_MONO_FONT_FAMILY } from "@/lib/app/appFonts";describe("normalizeEditorSettings", () => {@@ -1317,6 +1318,60 @@ describe("normalizeEditorSettings - sidebarExpandTreeOnConnect", () => {});});+// #13549: the toggle was registered on the interface, the defaults, the normalize+// whitelist and the settings-dialog draft, but never on the patch applier. Every+// apply dropped the key, so the store value never changed, the dialog compared its+// draft against a base that never moved, and "apply and close" kept reporting+// unsaved changes.+describe("updateEditorSettings - sidebarExpandTreeOnConnect", () => {+ beforeEach(() => {+ vi.resetModules();+ setActivePinia(createPinia());+ });++ it("applies and persists the sidebarExpandTreeOnConnect toggle", async () => {+ const loadEditorSettings = vi.fn().mockResolvedValue({});+ const saveEditorSettings = vi.fn().mockResolvedValue(undefined);+ vi.doMock("@/lib/backend/api", () => ({ loadEditorSettings, saveEditorSettings }));++ const { useSettingsStore } = await import("@/stores/settingsStore");+ const store = useSettingsStore();+ await store.initEditorSettings();+ saveEditorSettings.mockClear();++ store.updateEditorSettings({ sidebarExpandTreeOnConnect: true });+ expect(store.editorSettings.sidebarExpandTreeOnConnect).toBe(true);+ await vi.waitFor(() => expect(saveEditorSettings).toHaveBeenCalledOnce());+ expect(saveEditorSettings).toHaveBeenLastCalledWith(expect.objectContaining({ sidebarExpandTreeOnConnect: true }));++ store.updateEditorSettings({ sidebarExpandTreeOnConnect: false });+ expect(store.editorSettings.sidebarExpandTreeOnConnect).toBe(false);+ });++ it("clears the settings-dialog dirty state once the toggle is applied", async () => {+ const loadEditorSettings = vi.fn().mockResolvedValue({});+ const saveEditorSettings = vi.fn().mockResolvedValue(undefined);+ vi.doMock("@/lib/backend/api", () => ({ loadEditorSettings, saveEditorSettings }));++ const { useSettingsStore } = await import("@/stores/settingsStore");+ const store = useSettingsStore();+ await store.initEditorSettings();++ // The dialog compares its draft against a base snapshot that is rebuilt from the+ // store after every apply. A key that never reaches the store keeps the two apart+ // forever, which is what made the dialog report unsaved changes and refuse to close.+ const base = editorSettingsDraftFromSettings(store.editorSettings);+ const draft = { ...base, sidebarExpandTreeOnConnect: true };+ expect(editorSettingsDraftChanged(draft, base)).toBe(true);++ store.updateEditorSettings(editorSettingsPatchFromDraft(draft, base));++ const appliedBase = editorSettingsDraftFromSettings(store.editorSettings);+ expect(appliedBase.sidebarExpandTreeOnConnect).toBe(true);+ expect(editorSettingsDraftChanged(draft, appliedBase)).toBe(false);+ });+});+describe("normalizeEditorSettings - preferredExportPath", () => {it("defaults preferredExportPath to empty string", () => {expect(normalizeEditorSettings({}).preferredExportPath).toBe("");diff --git a/apps/desktop/src/stores/settingsStore.ts b/apps/desktop/src/stores/settingsStore.tsindex 450a596dc4..3856038432 100644--- a/apps/desktop/src/stores/settingsStore.ts+++ b/apps/desktop/src/stores/settingsStore.ts@@ -3206,6 +3206,11 @@ export const useSettingsStore = defineStore("settings", () => {if (partial.autoSelectActiveSidebarNode !== undefined) editorSettings.value.autoSelectActiveSidebarNode = partial.autoSelectActiveSidebarNode;if (partial.sidebarPinDefaultDatabase !== undefined) editorSettings.value.sidebarPinDefaultDatabase = partial.sidebarPinDefaultDatabase === true;if (partial.sidebarBrowseObjectsOnDatabaseActivation !== undefined) editorSettings.value.sidebarBrowseObjectsOnDatabaseActivation = partial.sidebarBrowseObjectsOnDatabaseActivation === true;+ // #13549: this key reached the interface, the defaults, the normalize whitelist and the+ // settings dialog draft, but never this patch applier. Without the branch below the+ // toggle was dropped on every apply, so the value never reached the store or disk and+ // the dialog stayed permanently dirty.+ if (partial.sidebarExpandTreeOnConnect !== undefined) editorSettings.value.sidebarExpandTreeOnConnect = partial.sidebarExpandTreeOnConnect === true;if (partial.openQueryOnConnectionOpen !== undefined) editorSettings.value.openQueryOnConnectionOpen = partial.openQueryOnConnectionOpen === true;if (partial.openTabsRestoreMode !== undefined) editorSettings.value.openTabsRestoreMode = normalizeOpenTabsRestoreMode(partial.openTabsRestoreMode);if (partial.autoReloadRestoredDataTabsOnOpen !== undefined) editorSettings.value.autoReloadRestoredDataTabsOnOpen = partial.autoReloadRestoredDataTabsOnOpen === true;