fix(sidebar): locate grouped connections after restart

Closes #6840
This commit is contained in:
t8y2 committed 2026-08-22 05:46:37 +00:00
1 parent a6f4cebd18
commit 11179676ed
3 files changed
+88 -3

No files matched your search

@@ -86,6 +86,22 @@ export type ActiveTabSidebarTarget =
savedSqlId: string;
};
/**
* Resolve a connection root without walking its potentially large object tree.
* Grouped connections live below connection-group nodes, while a connection
* id can also appear on descendants, so only group children are traversed.
*/
export function findSidebarConnectionNode(nodes: readonly TreeNode[], connectionId: string): TreeNode | null {
for (const node of nodes) {
if (node.type === "connection" && node.id === connectionId) return node;
if (node.type === "connection-group" && node.children) {
const found = findSidebarConnectionNode(node.children, connectionId);
if (found) return found;
}
}
return null;
}
export function activeTabSidebarTarget(tab: QueryTab | undefined | null): ActiveTabSidebarTarget | null {
if (!tab) return null;