fix(sidebar): collapse the Queries node by default

This commit is contained in:
Allen authored and GitHub committed 2026-09-03 01:13:05 +08:00
1 parent 6848e78855
commit 2f4a72c4e9
2 files changed
+8 -1

No files matched your search

@@ -65,6 +65,11 @@ describe("database saved SQL tree", () => {
expect(root).toMatchObject({ id: "conn-1:app:__queries", label: "tree.queries", type: "saved-sql-root", children: [] });
});
it("collapses the Queries node by default when opening a connection", () => {
expect(buildDatabaseSavedSqlRootNode(database, files)?.isExpanded).toBe(false);
expect(buildDatabaseSavedSqlRootNode(database, [])?.isExpanded).toBe(false);
});
it("adds Queries after database metadata and preserves its expansion state", () => {
const existingRoot = { ...buildDatabaseSavedSqlRootNode(database, files)!, isExpanded: false };
const decorated = decorateDatabaseSavedSqlTreeNodes(
@@ -71,7 +71,9 @@ export function buildDatabaseSavedSqlRootNode(databaseNode: Pick<TreeNode, "id"
connectionId: databaseNode.connectionId,
catalog: databaseNode.catalog,
database: databaseNode.database,
isExpanded: existingRoot?.isExpanded ?? true,
// Default collapsed: opening a connection should not expand the Queries
// node until the user asks for it; an existing node's state is preserved.
isExpanded: existingRoot?.isExpanded ?? false,
children: savedSqlFilesForDatabase(source, {
connectionId: databaseNode.connectionId,
catalog: databaseNode.catalog,