25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(sidebar): preserve connection search subtree state
t8y211fac631c7f9
diff --git a/apps/desktop/src/lib/sidebarSearchTree.ts b/apps/desktop/src/lib/sidebarSearchTree.tsindex bf24eb2005..24044f00d9 100644--- a/apps/desktop/src/lib/sidebarSearchTree.ts+++ b/apps/desktop/src/lib/sidebarSearchTree.ts@@ -1,7 +1,7 @@import type { TreeNode, TreeNodeType } from "@/types/database";import { createSidebarLabelMatcher, type SidebarLabelMatcher } from "@/lib/sidebarSearch";-const preserveMatchedSubtreeTypes = new Set(["database", "schema", "table", "view"]);+const preserveMatchedSubtreeTypes = new Set(["connection", "database", "schema", "table", "view"]);const normalizedLabelCache = new WeakMap<TreeNode, { label: string; normalized: string }>();@@ -51,7 +51,7 @@ function filterSidebarTreeWithMatcher(nodes: TreeNode[], matchLabel: SidebarLabenode: {...node,children,- isLoading: node.type === "connection" ? false : node.isLoading,+ isLoading: node.isLoading,isExpanded: children.length > 0 && !collapsedIds.has(node.id),},score: selfMatch?.score ?? 0,diff --git a/packages/app-tests/sidebarSearchTree.test.ts b/packages/app-tests/sidebarSearchTree.test.tsindex 10b5eee5a8..68616ead91 100644--- a/packages/app-tests/sidebarSearchTree.test.ts+++ b/packages/app-tests/sidebarSearchTree.test.ts@@ -84,6 +84,43 @@ test("preserves loaded schema children when the database itself matches search",assert.equal(filtered[0]?.children?.[0]?.label, "public");});+test("preserves loaded children when the connection itself matches search", () => {+ const nodes: TreeNode[] = [+ {+ id: "conn:1",+ label: "192.168.0.200_3306",+ type: "connection",+ connectionId: "conn:1",+ isExpanded: true,+ children: [+ {+ id: "conn:1:inventory",+ label: "inventory",+ type: "database",+ connectionId: "conn:1",+ database: "inventory",+ isExpanded: true,+ children: [+ {+ id: "conn:1:inventory:products",+ label: "products",+ type: "table",+ connectionId: "conn:1",+ database: "inventory",+ },+ ],+ },+ ],+ },+ ];++ const filtered = filterSidebarTree(nodes, "192.168.0.200", new Set());++ assert.equal(filtered[0]?.label, "192.168.0.200_3306");+ assert.equal(filtered[0]?.children?.[0]?.label, "inventory");+ assert.equal(filtered[0]?.children?.[0]?.children?.[0]?.label, "products");+});+test("matches table comments during sidebar search", () => {const nodes: TreeNode[] = [{@@ -173,7 +210,7 @@ test("connection search results stay visible before connecting", () => {);});-test("connection search copies do not keep stale loading state", () => {+test("connection search copies preserve loading state", () => {const nodes: TreeNode[] = [{id: "conn:1",@@ -196,5 +233,5 @@ test("connection search copies do not keep stale loading state", () => {const filtered = filterSidebarTree(nodes, "orders", new Set());assert.equal(filtered[0]?.type, "connection");- assert.equal(filtered[0]?.isLoading, false);+ assert.equal(filtered[0]?.isLoading, true);});