@@ -88,21 +88,19 @@ export class ObjectExplorerService {
8888 const result = [ ] ;
8989
9090 const rootId = this . _connectionManager . connectionStore . rootGroupId ;
91-
9291 if ( ! this . _connectionGroupNodes . has ( rootId ) ) {
9392 this . _logger . error (
9493 "Root server group is not defined. Cannot get root nodes for Object Explorer." ,
9594 ) ;
9695 return [ ] ;
9796 }
9897
99- // Only show ' User Connections' and ' Workspace Connections' as children of ROOT
98+ // Always show both User Connections and Workspace Connections as children of ROOT
10099 const rootChildren = this . _connectionGroupNodes . get ( rootId ) ?. children || [ ] ;
101- for ( const child of rootChildren ) {
102- if ( child . label === "User Connections" || child . label === "Workspace Connections" ) {
103- result . push ( child ) ;
104- }
105- }
100+ let userGroup = rootChildren . find ( ( child ) => child . label === "User Connections" ) ;
101+ let workspaceGroup = rootChildren . find ( ( child ) => child . label === "Workspace Connections" ) ;
102+ if ( userGroup ) result . push ( userGroup ) ;
103+ if ( workspaceGroup ) result . push ( workspaceGroup ) ;
106104
107105 return result ;
108106 }
@@ -394,16 +392,22 @@ export class ObjectExplorerService {
394392 ) ;
395393
396394 const rootId = this . _connectionManager . connectionStore . rootGroupId ;
397- const serverGroups =
398- await this . _connectionManager . connectionStore . readAllConnectionGroups ( ) ;
395+ // Read user and workspace groups separately
396+ const userGroups =
397+ this . _connectionManager . connectionStore . connectionConfig . getGroupsFromSettings ( ) ;
398+ // Import ConfigurationTarget from the correct module
399+ // Use VscodeWrapper.ConfigurationTarget.Workspace
400+ const { ConfigurationTarget } = require ( "../controllers/vscodeWrapper" ) ;
401+ const workspaceGroups =
402+ this . _connectionManager . connectionStore . connectionConfig . getGroupsFromSettings (
403+ ConfigurationTarget . Workspace ,
404+ ) ;
405+ // Merge root, user, and workspace groups
406+ const allGroups = [ ...userGroups , ...workspaceGroups ] ;
399407 let savedConnections = await this . _connectionManager . connectionStore . readAllConnections ( ) ;
400408
401409 // if there are no saved connections, show the add connection node
402- if (
403- savedConnections . length === 0 &&
404- serverGroups . length === 1 &&
405- serverGroups [ 0 ] . id === rootId
406- ) {
410+ if ( savedConnections . length === 0 && allGroups . length === 1 && allGroups [ 0 ] . id === rootId ) {
407411 this . _logger . verbose (
408412 "No saved connections or groups found. Showing add connection node." ,
409413 ) ;
@@ -416,34 +420,27 @@ export class ObjectExplorerService {
416420 const newConnectionGroupNodes = new Map < string , ConnectionGroupNode > ( ) ;
417421 const newConnectionNodes = new Map < string , ConnectionNode > ( ) ;
418422
419- // Add all group nodes from settings first
420- for ( const group of serverGroups ) {
423+ // Add all group nodes from merged settings
424+ for ( const group of allGroups ) {
421425 const groupNode = new ConnectionGroupNode ( group ) ;
422-
423426 if ( this . _connectionGroupNodes . has ( group . id ) ) {
424427 groupNode . id = this . _connectionGroupNodes . get ( group . id ) . id ;
425428 }
426-
427429 newConnectionGroupNodes . set ( group . id , groupNode ) ;
428430 }
429431
430432 // Populate group hierarchy - add each group as a child to its parent
431- for ( const group of serverGroups ) {
433+ for ( const group of allGroups ) {
432434 // Skip the root group as it has no parent
433435 if ( group . id === rootId ) {
434436 continue ;
435437 }
436-
437438 if ( group . parentId && newConnectionGroupNodes . has ( group . parentId ) ) {
438439 const parentNode = newConnectionGroupNodes . get ( group . parentId ) ;
439440 const childNode = newConnectionGroupNodes . get ( group . id ) ;
440-
441441 if ( parentNode && childNode ) {
442442 parentNode . addChild ( childNode ) ;
443-
444443 if ( parentNode . id !== rootId ) {
445- // set the parent node for the child group unless the parent is the root group
446- // parent property is used to
447444 childNode . parentNode = parentNode ;
448445 }
449446 } else {
@@ -462,9 +459,7 @@ export class ObjectExplorerService {
462459 for ( const connection of savedConnections ) {
463460 if ( connection . groupId && newConnectionGroupNodes . has ( connection . groupId ) ) {
464461 const groupNode = newConnectionGroupNodes . get ( connection . groupId ) ;
465-
466462 let connectionNode : ConnectionNode ;
467-
468463 if ( this . _connectionNodes . has ( connection . id ) ) {
469464 connectionNode = this . _connectionNodes . get ( connection . id ) ;
470465 connectionNode . updateConnectionProfile ( connection ) ;
@@ -475,9 +470,7 @@ export class ObjectExplorerService {
475470 groupNode . id === rootId ? undefined : groupNode ,
476471 ) ;
477472 }
478-
479473 connectionNode . parentNode = groupNode . id === rootId ? undefined : groupNode ;
480-
481474 newConnectionNodes . set ( connection . id , connectionNode ) ;
482475 groupNode . addChild ( connectionNode ) ;
483476 } else {
@@ -491,7 +484,6 @@ export class ObjectExplorerService {
491484 this . _connectionNodes = newConnectionNodes ;
492485
493486 const result = [ ...this . _rootTreeNodeArray ] ;
494-
495487 getConnectionActivity . end ( ActivityStatus . Succeeded , undefined , {
496488 nodeCount : result . length ,
497489 } ) ;
0 commit comments