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): keep off-page table group members visible
Zzzc39dd897c7c4
diff --git a/apps/desktop/src/lib/table/__tests__/tableVGroup.spec.ts b/apps/desktop/src/lib/table/__tests__/tableVGroup.spec.tsindex 351a12f77e..0d63e5e545 100644--- a/apps/desktop/src/lib/table/__tests__/tableVGroup.spec.ts+++ b/apps/desktop/src/lib/table/__tests__/tableVGroup.spec.ts@@ -12,6 +12,7 @@ import {hasTableTreeLoadMore,isTableVGroupContainerNode,isTableVGroupGroupableRowType,+ missingTableVGroupMemberNames,moveTableToVGroup,normalizeTableVGroupLayout,pruneTableVGroupMembers,@@ -42,6 +43,43 @@ function groupIds(nodes: TreeNode[]): string[] {return nodes.filter((node) => node.type === "table-vgroup").map((node) => node.id);}+describe("off-page table group members", () => {+ const names = ["orders_2026", "ordersX2026", "orders%2026", "orders\\2026", "订单😀", "archived_orders"];+ const layout: TableVGroupLayout = {+ groups: [+ { id: "parent", name: "Business", collapsed: true },+ { id: "nested", name: "Nested", collapsed: false },+ ],+ order: [+ { type: "table", name: "ungrouped" },+ {+ type: "group",+ id: "parent",+ children: [+ { type: "table", name: "already_loaded" },+ { type: "table", name: "a_view", rowType: "view" },+ { type: "group", id: "nested", children: names.map((name) => ({ type: "table", name })) },+ ],+ },+ ],+ };++ it("includes collapsed and nested members while skipping loaded tables and ungrouped entries", () => {+ expect(missingTableVGroupMemberNames(layout, new Set(["already_loaded"]))).toEqual(names);+ expect(missingTableVGroupMemberNames({ ...layout, enabled: false }, new Set())).toEqual([]);+ });++ it.each([+ { includePatterns: [" ORDERS\\_2026 "], excludePatterns: [], expected: ["orders_2026"] },+ { includePatterns: ["orders_2026"], excludePatterns: ["orders\\%2026", "orders\\\\2026"], expected: ["orders_2026", "ordersX2026"] },+ { includePatterns: ["订单_"], excludePatterns: [], expected: ["订单😀"] },+ { includePatterns: ["orders%"], excludePatterns: ["%X2026"], expected: ["orders_2026", "orders%2026", "orders\\2026"] },+ { includePatterns: [" "], excludePatterns: ["archived%", "ORDERS%"], expected: ["订单😀"] },+ ])("respects LIKE include $includePatterns and exclude $excludePatterns", ({ includePatterns, excludePatterns, expected }) => {+ expect(missingTableVGroupMemberNames(layout, new Set(["already_loaded"]), { includePatterns, excludePatterns })).toEqual(expected);+ });+});+describe("tableVGroup layout ops", () => {it("moves a table into a group and back to the ungrouped root", () => {const created = createTableVGroup(emptyTableVGroupLayout(), "订单域");diff --git a/apps/desktop/src/lib/table/tableVGroup.ts b/apps/desktop/src/lib/table/tableVGroup.tsindex 5a798f5969..a1839bf4a0 100644--- a/apps/desktop/src/lib/table/tableVGroup.ts+++ b/apps/desktop/src/lib/table/tableVGroup.ts@@ -1,4 +1,4 @@-import type { ConnectionGroup, TableVGroupLayout, TableVGroupOrderEntry, TreeNode } from "@/types/database";+import type { ConnectionGroup, TableNameFilter, TableVGroupLayout, TableVGroupOrderEntry, TreeNode } from "@/types/database";import { uuid } from "@/lib/common/utils";export type { TableVGroupLayout, TableVGroupOrderEntry };@@ -45,6 +45,48 @@ export function tableVGroupsEnabled(layout: TableVGroupLayout | null | undefinedreturn hasTableVGroupEntries(layout) && layout.enabled !== false;}+// Match the backend's SQL LIKE name filters, including escaped wildcards.+// Dynamic programming keeps repeated '%' patterns from causing regex backtracking.+function matchesTableNamePattern(name: string, pattern: string): boolean {+ const value = [...name.toLowerCase()];+ const tokens = [...pattern.trim().toLowerCase()];+ let previous = Array.from({ length: value.length + 1 }, () => false);+ previous[0] = true;+ for (let index = 0; index < tokens.length; index++) {+ let token = tokens[index]!;+ const escaped = token === "\\";+ if (escaped) token = tokens[++index] ?? "\\";+ const current = Array.from({ length: value.length + 1 }, () => false);+ if (!escaped && token === "%") current[0] = previous[0]!;+ for (let offset = 1; offset <= value.length; offset++) {+ current[offset] = !escaped && token === "%" ? previous[offset]! || current[offset - 1]! : previous[offset - 1]! && ((!escaped && token === "_") || value[offset - 1] === token);+ }+ previous = current;+ }+ return previous[value.length]!;+}++/** Only real group members need supplementary metadata, never ungrouped order entries. */+export function missingTableVGroupMemberNames(layout: TableVGroupLayout | null | undefined, loadedNames: ReadonlySet<string>, filter?: TableNameFilter): string[] {+ if (!layout || !tableVGroupsEnabled(layout)) return [];+ const include = filter?.includePatterns.filter((pattern) => pattern.trim()) ?? [];+ const exclude = filter?.excludePatterns.filter((pattern) => pattern.trim()) ?? [];+ const names = new Set<string>();+ const visit = (entries: TableVGroupOrderEntry[], inGroup: boolean) => {+ for (const entry of entries) {+ if (entry.type === "group") {+ visit(entry.children ?? [], true);+ } else if (inGroup && (!entry.rowType || entry.rowType === "table") && !loadedNames.has(entry.name)) {+ if (include.length && !include.some((pattern) => matchesTableNamePattern(entry.name, pattern))) continue;+ if (exclude.some((pattern) => matchesTableNamePattern(entry.name, pattern))) continue;+ names.add(entry.name);+ }+ }+ };+ visit(layout.order, false);+ return [...names];+}+export function tableVGroupScopeKey(scope: TableVGroupScope): string | null {if (!scope.connectionId || !scope.database) return null;const parts = [scope.connectionId, scope.linkedServer ?? "", scope.catalog ?? "", scope.database, scope.schema ?? ""];diff --git a/apps/desktop/src/stores/__tests__/connectionStore.tableVGroups.spec.ts b/apps/desktop/src/stores/__tests__/connectionStore.tableVGroups.spec.tsindex c4d40c5ec4..ef4a777d2b 100644--- a/apps/desktop/src/stores/__tests__/connectionStore.tableVGroups.spec.ts+++ b/apps/desktop/src/stores/__tests__/connectionStore.tableVGroups.spec.ts@@ -1,6 +1,6 @@import { createPinia, setActivePinia } from "pinia";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";-import type { ConnectionConfig, TreeNode } from "@/types/database";+import type { ConnectionConfig, TableInfo, TreeNode } from "@/types/database";describe("connectionStore table virtual groups during disk reload", () => {beforeEach(() => {@@ -22,6 +22,7 @@ describe("connectionStore table virtual groups during disk reload", () => {loadPinnedTreeNodeIds: vi.fn().mockResolvedValue([]),loadSidebarLayout: vi.fn().mockResolvedValue(null),loadTableVGroups: vi.fn().mockResolvedValue({}),+ saveTableVGroups: vi.fn().mockResolvedValue(undefined),loadTunnelProfiles: vi.fn().mockResolvedValue([]),listObjects: vi.fn().mockResolvedValue([]),loadSchemaCache: vi.fn().mockResolvedValue(null),@@ -39,6 +40,261 @@ describe("connectionStore table virtual groups during disk reload", () => {vi.restoreAllMocks();});+ async function paginatedGroupFixture(display: "simple" | "grouped", schema?: string) {+ const api = await import("@/lib/backend/api");+ const { useSettingsStore } = await import("@/stores/settingsStore");+ const { useConnectionStore } = await import("@/stores/connectionStore");+ const { tableVGroupScopeKey } = await import("@/lib/table/tableVGroup");+ const config: ConnectionConfig = { id: "mysql-13285", name: "Test database", db_type: schema ? "postgres" : "mysql", host: "127.0.0.1", port: schema ? 5432 : 3306, username: "root", password: "", database: "app" };+ const scope = { connectionId: config.id, database: "app", schema };+ const member: TableInfo = { name: "z_orders", table_type: "TABLE", comment: "Order records" };+ const tables: TableInfo[] = [{ name: "a_first", table_type: "TABLE" }, { name: "b_next", table_type: "TABLE" }, member];+ const layout = {+ version: 1,+ enabled: true,+ groups: [{ id: "business", name: "Business", collapsed: false }],+ order: [{ type: "group" as const, id: "business", children: [{ type: "table" as const, name: member.name }] }],+ };+ vi.mocked(api.loadConnections).mockResolvedValue([config]);+ vi.mocked(api.loadTableVGroups).mockResolvedValue({ [tableVGroupScopeKey(scope)!]: layout });+ vi.mocked(api.listTables).mockImplementation(async (_connection, _database, _schema, filter, limit, offset, _types, _catalog, nameFilter) => {+ if (nameFilter?.includePatterns.length) return [member];+ if (filter) return filter === member.name ? [member] : [];+ return tables.slice(offset ?? 0, limit === undefined ? undefined : (offset ?? 0) + limit);+ });+ const store = useConnectionStore();+ await store.initFromDisk();+ const settings = useSettingsStore();+ settings.editorSettings.sidebarObjectDisplay = display;+ settings.desktopSettings.sidebar_table_page_size = 1;+ store.connectedIds = new Set([config.id]);+ const database: TreeNode = { id: `${config.id}:app`, label: "app", type: "database", connectionId: config.id, database: "app", isExpanded: true, children: [] };+ if (schema) database.children!.push({ id: `${database.id}:${schema}`, label: schema, type: "schema", ...scope, isExpanded: true, children: [] });+ store.treeNodes[0]!.children!.push(database);+ await store.loadTables(config.id, "app", schema, { force: true });+ const liveDatabase = store.treeNodes[0]!.children!.find((node) => node.id === database.id)!;+ const parent = schema ? liveDatabase.children!.find((node) => node.schema === schema)! : liveDatabase;+ const container = display === "simple" ? parent : parent.children!.find((node) => node.type === "group-tables")!;+ if (display === "grouped") await store.loadObjectGroupChildren(container, { force: true });+ return { api, store, container, member, scope };+ }++ it.each(["simple", "grouped"] as const)("keeps off-page group members after clearing table search in %s display", async (display) => {+ const { store, container, member, api } = await paginatedGroupFixture(display);+ const groupMembers = () => container.children?.find((node) => node.type === "table-vgroup")?.children ?? [];+ expect(groupMembers().map((node) => node.label)).toEqual([member.name]);+ store.setSidebarTableSearchQuery(container.id, "no_match");+ await store.refreshSidebarTableSearch(container.id);+ expect(groupMembers()).toEqual([]);+ store.setSidebarTableSearchQuery(container.id, member.name);+ await store.refreshSidebarTableSearch(container.id);+ expect(groupMembers().map((node) => node.label)).toEqual([member.name]);++ store.setSidebarTableSearchQuery(container.id, "");+ await store.refreshSidebarTableSearch(container.id);+ expect(groupMembers().map((node) => [node.label, node.comment])).toEqual([[member.name, member.comment]]);+ expect(container.children?.filter((node) => node.type === "table").map((node) => node.label)).toEqual(["a_first"]);+ expect(container.children?.find((node) => node.type === "load-more")?.loadMore?.offset).toBe(1);++ for (let page = 0; page < 2; page++) {+ await store.loadMoreObjectGroupChildren(container.children!.find((node) => node.type === "load-more")!);+ }+ expect(groupMembers().map((node) => node.label)).toEqual([member.name]);+ expect(container.children?.filter((node) => node.type === "table").map((node) => node.label)).toEqual(["a_first", "b_next"]);+ expect(container.children?.some((node) => node.type === "load-more")).toBe(false);+ expect(+ vi+ .mocked(api.listTables)+ .mock.calls.filter((call) => call[5] === 1 || call[5] === 2)+ .map((call) => call[5]),+ ).toEqual([1, 2]);+ });++ it.each(["simple", "grouped"] as const)("keeps schema member identities stable between search and pagination in %s display", async (display) => {+ const { store, container, member } = await paginatedGroupFixture(display, "public");+ const groupMember = () => container.children!.find((node) => node.type === "table-vgroup")!.children![0]!;+ store.setSidebarTableSearchQuery(container.id, member.name);+ await store.refreshSidebarTableSearch(container.id);+ const searchId = groupMember().id;+ expect(groupMember().schema).toBe("public");++ store.setSidebarTableSearchQuery(container.id, "");+ await store.refreshSidebarTableSearch(container.id);+ expect(groupMember().id).toBe(searchId);+ for (let page = 0; page < 2; page++) await store.loadMoreObjectGroupChildren(container.children!.find((node) => node.type === "load-more")!);+ expect(groupMember().id).toBe(searchId);+ });++ it("keeps first-page tables when a grouped member name contains the schema prefix", async () => {+ const { store, container, member } = await paginatedGroupFixture("grouped", "public");+ member.name = "public:a_first";+ store.tableVGroupLayoutFor(container)!.order = [{ type: "group", id: "business", children: [{ type: "table", name: member.name }] }];+ await store.refreshSidebarTableSearch(container.id);+ const firstPageTable = container.children!.find((node) => node.type === "table" && node.label === "a_first");+ const groupedTable = container.children!.find((node) => node.type === "table-vgroup")!.children![0]!;+ expect(firstPageTable).toBeDefined();+ expect(groupedTable.label).toBe(member.name);+ expect(groupedTable.id).not.toBe(firstPageTable!.id);+ });++ it("counts each exact member once when case-insensitive batch responses overlap", async () => {+ const { store, container, api } = await paginatedGroupFixture("grouped");+ const names = Array.from({ length: 60 }, (_, index) => `z${index}${"x".repeat(60)}`);+ names.push(names[0]!.toUpperCase());+ store.tableVGroupLayoutFor(container)!.order = [{ type: "group", id: "business", children: names.map((name) => ({ type: "table", name })) }];+ vi.mocked(api.listTables)+ .mockClear()+ .mockImplementation(async (_connection, _database, _schema, _filter, _limit, _offset, _types, _catalog, nameFilter) => {+ if (nameFilter) return names.filter((name) => nameFilter.includePatterns.some((pattern) => pattern.toLowerCase() === name.toLowerCase())).map((name) => ({ name, table_type: "TABLE" }));+ return [+ { name: "a_first", table_type: "TABLE" },+ { name: "b_next", table_type: "TABLE" },+ ];+ });+ await store.refreshSidebarTableSearch(container.id);+ expect(vi.mocked(api.listTables).mock.calls.filter((call) => call[8]).length).toBeGreaterThan(1);+ const members = container.children!.find((node) => node.type === "table-vgroup")!.children!;+ expect(members.map((node) => node.label)).toEqual(names);+ expect(container.objectCount).toBe(names.length + 1);+ });++ it("does not restore group members over a newer search while their metadata is loading", async () => {+ const { store, container, member, api } = await paginatedGroupFixture("simple");+ let finishMembers: ((tables: TableInfo[]) => void) | undefined;+ vi.mocked(api.listTables).mockImplementation(async (_connection, _database, _schema, filter, _limit, _offset, _types, _catalog, nameFilter) => {+ if (nameFilter)+ return new Promise<TableInfo[]>((resolve) => {+ finishMembers = resolve;+ });+ if (filter) return [{ name: "a_first", table_type: "TABLE" }];+ return [+ { name: "a_first", table_type: "TABLE" },+ { name: "b_next", table_type: "TABLE" },+ ];+ });+ const olderLoad = store.refreshSidebarTableSearch(container.id);+ await vi.waitFor(() => expect(finishMembers).toBeDefined());+ store.setSidebarTableSearchQuery(container.id, "a_first");+ await store.refreshSidebarTableSearch(container.id);+ finishMembers!([member]);+ await olderLoad;+ expect(container.children?.find((node) => node.type === "table-vgroup")?.children).toEqual([]);+ expect(container.children?.filter((node) => node.type === "table").map((node) => node.label)).toEqual(["a_first"]);+ });++ it("discards a member response when its group was deleted during the load", async () => {+ const { store, container, member, api } = await paginatedGroupFixture("simple");+ let finishMembers: ((tables: TableInfo[]) => void) | undefined;+ vi.mocked(api.listTables).mockImplementation(async (_connection, _database, _schema, _filter, _limit, _offset, _types, _catalog, nameFilter) => {+ if (nameFilter)+ return new Promise<TableInfo[]>((resolve) => {+ finishMembers = resolve;+ });+ return [+ { name: "a_first", table_type: "TABLE" },+ { name: "b_next", table_type: "TABLE" },+ ];+ });+ const pending = store.refreshSidebarTableSearch(container.id);+ await vi.waitFor(() => expect(finishMembers).toBeDefined());+ store.deleteTableVGroups(container, ["business"]);+ finishMembers!([member]);+ await pending;+ expect(container.children?.some((node) => node.type === "table-vgroup")).toBe(false);+ expect(container.children?.filter((node) => node.type === "table").map((node) => node.label)).toEqual(["a_first"]);+ });++ it("reports member metadata errors without replacing the previous tree or deleting membership", async () => {+ const { store, container, member, api } = await paginatedGroupFixture("simple");+ const previousChildren = container.children;+ vi.mocked(api.listTables).mockImplementation(async (_connection, _database, _schema, _filter, _limit, _offset, _types, _catalog, nameFilter) => {+ if (nameFilter) throw new Error("metadata unavailable");+ return [+ { name: "a_first", table_type: "TABLE" },+ { name: "b_next", table_type: "TABLE" },+ ];+ });+ await expect(store.refreshSidebarTableSearch(container.id)).rejects.toThrow("metadata unavailable");+ expect(container.children).toBe(previousChildren);+ expect(store.tableVGroupPathForTable(container, member.name)).toEqual(["business"]);+ });++ it.each(["simple", "grouped"] as const)("removes a deleted table from a complete %s reload without synthesizing a row", async (display) => {+ const { store, container, member, api, scope } = await paginatedGroupFixture(display);+ vi.mocked(api.listTables)+ .mockClear()+ .mockResolvedValue([{ name: "a_first", table_type: "TABLE" }]);+ if (display === "simple") await store.loadTables(scope.connectionId, scope.database, undefined, { force: true });+ else await store.loadObjectGroupChildren(container, { force: true });+ expect(container.children?.find((node) => node.type === "table-vgroup")?.children).toEqual([]);+ expect(store.tableVGroupPathForTable(container, member.name)).toEqual([]);+ expect(api.listTables).toHaveBeenCalledTimes(1);+ });++ it.each(["simple", "grouped"] as const)("keeps name-filtered group members hidden in %s display", async (display) => {+ const { store, container, api, scope } = await paginatedGroupFixture(display);+ const scopeKey = store.tableNameFilterScopeKey({ ...scope, schema: display === "simple" ? "app" : undefined, nodeKind: display === "simple" ? "simple-tables" : "group-tables" });+ for (const filter of [+ { includePatterns: ["a_%"], excludePatterns: [] },+ { includePatterns: [], excludePatterns: ["z_%"] },+ ]) {+ vi.mocked(api.listTables)+ .mockClear()+ .mockResolvedValue([+ { name: "a_first", table_type: "TABLE" },+ { name: "a_next", table_type: "TABLE" },+ ]);+ const revision = store.setSidebarTableNameFilter(scopeKey, filter);+ await store.refreshTreeNodeForTableNameFilter(container, scopeKey, revision);+ expect(container.children?.find((node) => node.type === "table-vgroup")?.children).toEqual([]);+ expect(api.listTables).toHaveBeenCalledTimes(1);+ }+ });++ it("batches long member names and stops requesting batches after the tree is disconnected", async () => {+ const { store, container, api } = await paginatedGroupFixture("simple");+ const names = Array.from({ length: 60 }, (_, index) => `z${index}${"x".repeat(60)}`);+ const layout = store.tableVGroupLayoutFor(container)!;+ layout.order = [{ type: "group", id: "business", children: names.map((name) => ({ type: "table", name })) }];+ vi.mocked(api.listTables)+ .mockClear()+ .mockImplementation(async (_connection, _database, _schema, _filter, _limit, _offset, _types, _catalog, nameFilter) => {+ if (nameFilter) return nameFilter.includePatterns.map((name) => ({ name, table_type: "TABLE" }));+ return [+ { name: "a_first", table_type: "TABLE" },+ { name: "b_next", table_type: "TABLE" },+ ];+ });+ await store.refreshSidebarTableSearch(container.id);+ expect(container.children?.find((node) => node.type === "table-vgroup")?.children?.map((node) => node.label)).toEqual(names);+ const batches = vi.mocked(api.listTables).mock.calls.filter((call) => call[8]);+ expect(batches.length).toBeGreaterThan(1);+ for (const call of batches) expect(encodeURIComponent(JSON.stringify(call[8])).length).toBeLessThan(2500);+ expect(container.children?.find((node) => node.type === "load-more")?.loadMore?.offset).toBe(1);++ let finishBatch: ((tables: TableInfo[]) => void) | undefined;+ vi.mocked(api.listTables)+ .mockClear()+ .mockImplementation(async (_connection, _database, _schema, _filter, _limit, _offset, _types, _catalog, nameFilter) => {+ if (nameFilter)+ return new Promise<TableInfo[]>((resolve) => {+ finishBatch = resolve;+ });+ return [+ { name: "a_first", table_type: "TABLE" },+ { name: "b_next", table_type: "TABLE" },+ ];+ });+ const pending = store.refreshSidebarTableSearch(container.id);+ await vi.waitFor(() => expect(finishBatch).toBeDefined());+ store.connectedIds = new Set();+ store.treeNodes = [];+ finishBatch!([]);+ await pending;+ expect(api.listTables).toHaveBeenCalledTimes(2);+ expect(store.treeNodes).toEqual([]);+ });+it.each(["simple", "grouped"])("preserves group layout through repeated disk reloads in %s display", async (display) => {const api = await import("@/lib/backend/api");const { applyTableVGroupsToChildren, tableVGroupScopeKey } = await import("@/lib/table/tableVGroup");diff --git a/apps/desktop/src/stores/connectionStore.ts b/apps/desktop/src/stores/connectionStore.tsindex 2fa03463bc..f5e8eb04eb 100644--- a/apps/desktop/src/stores/connectionStore.ts+++ b/apps/desktop/src/stores/connectionStore.ts@@ -84,6 +84,7 @@ import {hasTableTreeLoadMore,hasTableVGroupEntries,isTableVGroupContainerNode,+ missingTableVGroupMemberNames,moveTableToVGroup as moveTableToVGroupOp,normalizeTableVGroupLayout as normalizeTableVGroupLayoutOp,pruneTableVGroupMembers as pruneTableVGroupMembersOp,@@ -7043,6 +7044,7 @@ export const useConnectionStore = defineStore("connection", () => {if (hasMore && !searchFilter) {children = [...children, buildLoadMoreNode(node, pageSize, pageSize)];}+ children = await loadMissingTableVGroupMembers(node, children, load, "", undefined, searchFilter, tableNameFilter);if (isTreeLoadSearchChanged(searchFilter, options)) return;if (!tableNameFilterRevisionMatches(options)) return;const targetNode = treeNodeLoadTarget(load);@@ -7132,7 +7134,7 @@ export const useConnectionStore = defineStore("connection", () => {const tableNameFilter = activeTableNameFilterForScope({connectionId,database,- schema,+ schema: simpleObjectDisplay ? (effectiveSchema ?? querySchema) : schema,nodeKind: simpleObjectDisplay ? "simple-tables" : "group-tables",});const isSidebarTableSearch = !!options?.sidebarTableSearchParentId;@@ -7188,6 +7190,9 @@ export const useConnectionStore = defineStore("connection", () => {children.push(buildEventTriggersNode(connectionId, database));}}+ const childCountBeforeMembers = children.length;+ children = await loadMissingTableVGroupMembers(node, children, load, querySchema, effectiveSchema, searchFilter, tableNameFilter);+ if (nextObjectCount !== undefined) nextObjectCount += children.length - childCountBeforeMembers;if (isTreeLoadSearchChanged(searchFilter, options)) return;if (!tableNameFilterRevisionMatches(options)) return;const targetNode = treeNodeLoadTarget(load);@@ -7350,6 +7355,9 @@ export const useConnectionStore = defineStore("connection", () => {children = page.hasMore && (!searchFilter || globalPageSearch !== undefined) ? [...page.children, buildLoadMoreNode(node, page.nextOffset, pageSize, page.nextAnchor, globalPageSearch)] : page.children;nextObjectCount = page.objectCount;}+ const childCountBeforeMembers = children.length;+ children = await loadMissingTableVGroupMembers(node, children, load, querySchema, effectiveSchema, searchFilter, effectiveTableNameFilterForNode(node, tableNameFilter));+ nextObjectCount += children.length - childCountBeforeMembers;if (isTdengineTableGroup(node) && cacheRevision !== tdengineTreeCacheRevision(node)) return;if (isTreeLoadSearchChanged(searchFilter, options)) return;if (!tableNameFilterRevisionMatches(options)) return;@@ -10463,6 +10471,52 @@ export const useConnectionStore = defineStore("connection", () => {container.children = applyTableVGroupsToChildren(stripTableVGroupsFromChildren(container.children), tableVGroupLayouts.value[scopeKey], scope);}+ async function loadMissingTableVGroupMembers(node: TreeNode, children: TreeNode[], load: TreeNodeLoadHandle, querySchema: string, effectiveSchema?: string, searchFilter?: string, tableNameFilter?: TableNameFilter): Promise<TreeNode[]> {+ // Search remains a filtered projection. A complete listing already establishes+ // which members exist; only a partial unfiltered list needs supplementation.+ if (!node.connectionId || node.database == null || searchFilter || tableVGroupKindOfContainerNode(node) !== "tables" || !hasTableTreeLoadMore(children)) return children;+ const resolved = resolveTableVGroupScope(node);+ if (!resolved) return children;+ const loadedNames = collectTableTreeNames(children);+ const memberNames = () => missingTableVGroupMemberNames(tableVGroupLayouts.value[resolved.scopeKey], loadedNames, tableNameFilter);+ const missing = memberNames();+ if (!missing.length) return children;++ // HTTP list requests encode filters in the URL. Bound each batch by encoded+ // length so long/non-ASCII identifiers do not exceed proxy request limits.+ const batches: string[][] = [];+ let batch: string[] = [];+ let encodedLength = 0;+ for (const name of missing) {+ const pattern = name.replace(/[\\%_]/g, "\\$&");+ const length = encodeURIComponent(JSON.stringify(pattern)).length + 3;+ if (batch.length && encodedLength + length > 2000) {+ batches.push(batch);+ batch = [];+ encodedLength = 0;+ }+ batch.push(pattern);+ encodedLength += length;+ }+ if (batch.length) batches.push(batch);+ const tables: TableInfo[] = [];+ for (const includePatterns of batches) {+ if (!treeNodeLoadTarget(load)) return children;+ tables.push(...(await withMetadataLoadTimeout(node.connectionId, api.listTables(node.connectionId, node.database, querySchema, undefined, undefined, undefined, ["TABLE"], node.catalog, { includePatterns, excludePatterns: tableNameFilter?.excludePatterns ?? [] }), "tables")));+ }+ // A group may have been deleted/moved while metadata was loading. Only+ // publish members that still belong to the current layout, by exact name.+ const wanted = new Set(memberNames());+ // Case-insensitive name filters can return the same table across batches.+ // Keep distinct case-sensitive names, but count each real table only once.+ const uniqueTables = [...new Map(tables.filter((table) => wanted.has(table.name)).map((table) => [table.name, table])).values()];+ const members =+ node.type === "group-tables"+ ? objectGroupChildrenFromObjects({ node, parentNodeId: objectGroupRefreshParentId(node) ?? node.id, effectiveSchema, objectTypes: ["TABLE"], objects: mergeTableInfosIntoObjects([], uniqueTables, effectiveSchema) })+ : buildTableTreeNodes({ nodeId: node.id, connectionId: node.connectionId, database: node.database, schema: effectiveSchema, catalog: node.catalog, tables: uniqueTables });+ return [...children, ...members.filter((child) => child.type === "table")];+ }+/** 分组成员回收:只有「本 scope 的完整列表」才能判定成员存亡。* 同一连接下并存多种列表:各分组容器(tables/views/procedures/triggers 各自的* 完整列表)、非分组容器列表、以及分页中间态。非本容器类别的列表或分页结果作为