@@ -33,6 +33,11 @@ public partial class TrayWindowViewModel : ObservableObject
33
33
34
34
private DispatcherQueue ? _dispatcherQueue ;
35
35
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
+
36
41
// This isn't an ObservableProperty because the property itself never
37
42
// changes. We add an event listener for the collection changing in the
38
43
// constructor.
@@ -194,9 +199,12 @@ private void UpdateFromRpcModel(RpcModel rpcModel)
194
199
{
195
200
// When an agent is expanded:
196
201
if ( args . PropertyName == nameof ( AgentViewModel . IsExpanded ) && agent . IsExpanded )
202
+ {
203
+ _hasExpandedAgent = true ;
197
204
// Collapse every other agent.
198
205
foreach ( var otherAgent in Agents . Where ( a => a . Id != agent . Id && a . IsExpanded ) )
199
206
otherAgent . IsExpanded = false ;
207
+ }
200
208
} ;
201
209
202
210
// Sort by status green, red, gray, then by hostname.
@@ -208,6 +216,15 @@ private void UpdateFromRpcModel(RpcModel rpcModel)
208
216
} ) ;
209
217
210
218
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
+ }
211
228
}
212
229
213
230
private void UpdateFromCredentialModel ( CredentialModel credentialModel )
0 commit comments