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): finish database loads across root refreshes
t8y25730b6473d6c
diff --git a/apps/desktop/src/stores/__tests__/connectionStore.metadataLoading.spec.ts b/apps/desktop/src/stores/__tests__/connectionStore.metadataLoading.spec.tsindex 439f3f678d..43908af7df 100644--- a/apps/desktop/src/stores/__tests__/connectionStore.metadataLoading.spec.ts+++ b/apps/desktop/src/stores/__tests__/connectionStore.metadataLoading.spec.ts@@ -2791,6 +2791,79 @@ describe("connectionStore metadata loading", () => {expect(dbNode.isLoading).toBe(false);});+ it("finishes an expanding database when the connection refresh adds siblings", async () => {+ let resolveSchemas!: (schemas: { name: string; comment: null }[]) => void;+ const listSchemaInfos = vi.fn(+ () =>+ new Promise<{ name: string; comment: null }[]>((resolve) => {+ resolveSchemas = resolve;+ }),+ );+ const listDatabases = vi.fn().mockResolvedValue([+ { name: "app", comment: null },+ { name: "postgres", comment: null },+ ]);++ vi.doMock("@/lib/backend/tauriRuntime", () => ({ isTauriRuntime: () => false }));+ vi.doMock("@/lib/backend/api", () => ({+ checkConnectionHealth: vi.fn().mockResolvedValue(undefined),+ deleteSchemaCachePrefix: vi.fn().mockResolvedValue(undefined),+ listDatabases,+ listInstalledAgents: vi.fn().mockResolvedValue([]),+ listSchemaInfos,+ loadSchemaCache: vi.fn().mockResolvedValue(null),+ saveConnections: vi.fn().mockResolvedValue(undefined),+ saveSchemaCache: vi.fn().mockResolvedValue(undefined),+ saveSidebarLayout: vi.fn().mockResolvedValue(undefined),+ }));++ const { useConnectionStore } = await import("@/stores/connectionStore");+ const store = useConnectionStore();+ const connection = postgresConnection();+ const databaseNode: TreeNode = {+ id: `${connection.id}:app`,+ label: "app",+ type: "database",+ connectionId: connection.id,+ database: "app",+ isExpanded: false,+ isLoading: false,+ children: [],+ };+ store.connections = [connection];+ store.connectedIds.add(connection.id);+ store.treeNodes = [+ {+ id: connection.id,+ label: connection.name,+ type: "connection",+ connectionId: connection.id,+ isExpanded: true,+ children: [databaseNode],+ },+ ];+ const liveDatabaseNode = store.treeNodes[0]!.children![0]!;++ const schemaLoad = store.loadSchemas(connection.id, "app");+ await vi.waitFor(() => expect(listSchemaInfos).toHaveBeenCalledTimes(1));+ expect(liveDatabaseNode.isLoading).toBe(true);++ await store.loadDatabases(connection.id, { connectedOnly: true });++ const databaseDuringRefresh = store.treeNodes[0]?.children?.find((child) => child.id === databaseNode.id);+ expect(databaseDuringRefresh).toBe(liveDatabaseNode);+ expect(databaseDuringRefresh?.isLoading).toBe(true);++ resolveSchemas([{ name: "public", comment: null }]);+ await schemaLoad;++ const loadedDatabase = store.treeNodes[0]?.children?.find((child) => child.id === databaseNode.id);+ expect(loadedDatabase).toBe(liveDatabaseNode);+ expect(loadedDatabase?.isLoading).toBe(false);+ expect(loadedDatabase?.isExpanded).toBe(true);+ expect(loadedDatabase?.children?.map((child) => child.label)).toContain("public");+ });+it("clears sticky subtree loading when health-check reconnect bumps revision", async () => {let resolveTables!: (tables: TableInfo[]) => void;const listTables = vi.fn(diff --git a/apps/desktop/src/stores/connectionStore.ts b/apps/desktop/src/stores/connectionStore.tsindex 4df558c1a8..feb006eafb 100644--- a/apps/desktop/src/stores/connectionStore.ts+++ b/apps/desktop/src/stores/connectionStore.ts@@ -1966,8 +1966,6 @@ export const useConnectionStore = defineStore("connection", () => {children = dedupeTreeNodeChildrenById(children);if (shouldClearDescendantLoadedMarkers(parent, children)) {clearDescendantLoadedChildrenMarkers(parent.id);- // Parent load may still be current; only supersede descendant generations.- treeNodeLoads.invalidateDescendants(parent.id);}if (parent.children && parent.children.length > 0) {const oldMap = new Map(parent.children.map((c) => [c.id, c] as const));