@@ -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 )
@@ -206,28 +210,35 @@ def refresh_tree(host: TreeMixinHost) -> None:
206210 connecting_name = connecting_config .name if connecting_config else None
207211 connecting_spinner = host ._connect_spinner_frame () if connecting_config else None
208212
209- # Check for active direct connection or pending startup connection
213+ # Check for active direct connection, exclusive connection, or pending startup connection
210214 direct_config = getattr (host , "_direct_connection_config" , None )
211215 startup_config = getattr (host , "_startup_connect_config" , None )
216+ exclusive_connection = getattr (host , "_exclusive_connection" , False )
212217 direct_active = (
213218 direct_config is not None
214219 and host .current_config is not None
215220 and direct_config .name == host .current_config .name
216221 )
217- # Also hide saved connections when startup connection is pending (before it's connected)
222+ # Hide saved connections when startup connection is pending (before it's connected)
218223 startup_pending = startup_config is not None and not any (
219224 c .name == startup_config .name for c in host .connections
220225 )
226+ # Exclusive mode: only show the specified connection (even if it's saved)
227+ exclusive_active = exclusive_connection and startup_config is not None
221228 if direct_active and host .current_config is not None :
222229 connections = [host .current_config ]
230+ elif exclusive_active :
231+ connections = [startup_config ]
223232 elif startup_pending :
224233 connections = [startup_config ]
225234 else :
226235 connections = list (host .connections )
227236 if connecting_config and not any (c .name == connecting_config .name for c in connections ):
228237 connections = connections + [connecting_config ]
229238 connections = _sort_connections_for_display (connections )
230- _build_connection_folders (host , connections )
239+ # Skip folder structure in exclusive mode
240+ if not exclusive_active :
241+ _build_connection_folders (host , connections )
231242
232243 for conn in connections :
233244 is_connected = host .current_config is not None and conn .name == host .current_config .name
@@ -238,6 +249,7 @@ def refresh_tree(host: TreeMixinHost) -> None:
238249 is_connected = is_connected ,
239250 is_connecting = is_connecting ,
240251 spinner = connecting_spinner ,
252+ skip_folder = exclusive_active ,
241253 )
242254
243255 restore_subtree_expansion (host , host .object_tree .root )
@@ -263,28 +275,35 @@ def refresh_tree_chunked(
263275 connecting_name = connecting_config .name if connecting_config else None
264276 connecting_spinner = host ._connect_spinner_frame () if connecting_config else None
265277
266- # Check for active direct connection or pending startup connection
278+ # Check for active direct connection, exclusive connection, or pending startup connection
267279 direct_config = getattr (host , "_direct_connection_config" , None )
268280 startup_config = getattr (host , "_startup_connect_config" , None )
281+ exclusive_connection = getattr (host , "_exclusive_connection" , False )
269282 direct_active = (
270283 direct_config is not None
271284 and host .current_config is not None
272285 and direct_config .name == host .current_config .name
273286 )
274- # Also hide saved connections when startup connection is pending (before it's connected)
287+ # Hide saved connections when startup connection is pending (before it's connected)
275288 startup_pending = startup_config is not None and not any (
276289 c .name == startup_config .name for c in host .connections
277290 )
291+ # Exclusive mode: only show the specified connection (even if it's saved)
292+ exclusive_active = exclusive_connection and startup_config is not None
278293 if direct_active and host .current_config is not None :
279294 connections = [host .current_config ]
295+ elif exclusive_active :
296+ connections = [startup_config ]
280297 elif startup_pending :
281298 connections = [startup_config ]
282299 else :
283300 connections = list (host .connections )
284301 if connecting_config and not any (c .name == connecting_config .name for c in connections ):
285302 connections = connections + [connecting_config ]
286303 connections = _sort_connections_for_display (connections )
287- _build_connection_folders (host , connections )
304+ # Skip folder structure in exclusive mode
305+ if not exclusive_active :
306+ _build_connection_folders (host , connections )
288307
289308 def schedule_populate () -> None :
290309 if getattr (host , "_tree_refresh_token" , None ) is not token :
@@ -343,6 +362,7 @@ def populate_once() -> None:
343362 is_connected = is_connected ,
344363 is_connecting = is_connecting ,
345364 spinner = connecting_spinner ,
365+ skip_folder = exclusive_active ,
346366 )
347367
348368 def finish_sync () -> None :
@@ -369,6 +389,7 @@ def add_batch() -> None:
369389 is_connected = is_connected ,
370390 is_connecting = is_connecting ,
371391 spinner = connecting_spinner ,
392+ skip_folder = exclusive_active ,
372393 )
373394 idx = end
374395 if idx < len (connections ):
0 commit comments