Skip to content

Commit 590fad8

Browse files
committed
feat: skip folder hierarchy in exclusive connection mode for chunked refresh
Update refresh_tree_chunked to match refresh_tree behavior when using -c/--connection flag, showing the connection at root level without folders.
1 parent 5095076 commit 590fad8

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

sqlit/domains/explorer/ui/tree/builder.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def _add_connection_node(
7575
is_connected: bool,
7676
is_connecting: bool,
7777
spinner: str | None,
78+
skip_folder: bool = False,
7879
) -> Any:
7980
if is_connected:
8081
label = host._format_connection_label(config, "connected")
@@ -83,8 +84,11 @@ def _add_connection_node(
8384
else:
8485
label = host._format_connection_label(config, "idle")
8586

86-
folder_parts = _split_folder_path(getattr(config, "folder_path", ""))
87-
parent = _ensure_connection_folder_path(host, folder_parts)
87+
if skip_folder:
88+
parent = host.object_tree.root
89+
else:
90+
folder_parts = _split_folder_path(getattr(config, "folder_path", ""))
91+
parent = _ensure_connection_folder_path(host, folder_parts)
8892

8993
node = parent.add(label)
9094
node.data = ConnectionNode(config=config)
@@ -232,7 +236,9 @@ def refresh_tree(host: TreeMixinHost) -> None:
232236
if connecting_config and not any(c.name == connecting_config.name for c in connections):
233237
connections = connections + [connecting_config]
234238
connections = _sort_connections_for_display(connections)
235-
_build_connection_folders(host, connections)
239+
# Skip folder structure in exclusive mode
240+
if not exclusive_active:
241+
_build_connection_folders(host, connections)
236242

237243
for conn in connections:
238244
is_connected = host.current_config is not None and conn.name == host.current_config.name
@@ -243,6 +249,7 @@ def refresh_tree(host: TreeMixinHost) -> None:
243249
is_connected=is_connected,
244250
is_connecting=is_connecting,
245251
spinner=connecting_spinner,
252+
skip_folder=exclusive_active,
246253
)
247254

248255
restore_subtree_expansion(host, host.object_tree.root)
@@ -294,7 +301,9 @@ def refresh_tree_chunked(
294301
if connecting_config and not any(c.name == connecting_config.name for c in connections):
295302
connections = connections + [connecting_config]
296303
connections = _sort_connections_for_display(connections)
297-
_build_connection_folders(host, connections)
304+
# Skip folder structure in exclusive mode
305+
if not exclusive_active:
306+
_build_connection_folders(host, connections)
298307

299308
def schedule_populate() -> None:
300309
if getattr(host, "_tree_refresh_token", None) is not token:
@@ -353,6 +362,7 @@ def populate_once() -> None:
353362
is_connected=is_connected,
354363
is_connecting=is_connecting,
355364
spinner=connecting_spinner,
365+
skip_folder=exclusive_active,
356366
)
357367

358368
def finish_sync() -> None:
@@ -379,6 +389,7 @@ def add_batch() -> None:
379389
is_connected=is_connected,
380390
is_connecting=is_connecting,
381391
spinner=connecting_spinner,
392+
skip_folder=exclusive_active,
382393
)
383394
idx = end
384395
if idx < len(connections):

0 commit comments

Comments
 (0)