@@ -33,6 +33,11 @@ public partial class TrayWindowViewModel : ObservableObject
3333
3434 private DispatcherQueue ? _dispatcherQueue ;
3535
36+ // When we transition from 0 online workspaces to >0 online workspaces, the
37+ // first agent will be expanded. This bool tracks whether this has occurred
38+ // yet (or if the user has expanded something themselves).
39+ private bool _hasExpandedAgent ;
40+
3641 // This isn't an ObservableProperty because the property itself never
3742 // changes. We add an event listener for the collection changing in the
3843 // constructor.
@@ -194,9 +199,12 @@ private void UpdateFromRpcModel(RpcModel rpcModel)
194199 {
195200 // When an agent is expanded:
196201 if ( args . PropertyName == nameof ( AgentViewModel . IsExpanded ) && agent . IsExpanded )
202+ {
203+ _hasExpandedAgent = true ;
197204 // Collapse every other agent.
198205 foreach ( var otherAgent in Agents . Where ( a => a . Id != agent . Id && a . IsExpanded ) )
199206 otherAgent . IsExpanded = false ;
207+ }
200208 } ;
201209
202210 // Sort by status green, red, gray, then by hostname.
@@ -208,6 +216,15 @@ private void UpdateFromRpcModel(RpcModel rpcModel)
208216 } ) ;
209217
210218 if ( Agents . Count < MaxAgents ) ShowAllAgents = false ;
219+
220+ var firstOnlineAgent = agents . FirstOrDefault ( a => a . ConnectionStatus != AgentConnectionStatus . Gray ) ;
221+ if ( firstOnlineAgent is null )
222+ _hasExpandedAgent = false ;
223+ if ( ! _hasExpandedAgent && firstOnlineAgent is not null )
224+ {
225+ firstOnlineAgent . SetExpanded ( true ) ;
226+ _hasExpandedAgent = true ;
227+ }
211228 }
212229
213230 private void UpdateFromCredentialModel ( CredentialModel credentialModel )
0 commit comments