@@ -45,7 +45,6 @@ public AgentViewModel Create(IAgentExpanderHost expanderHost, Uuid id, string fu
45
45
string ? workspaceName , bool ? didP2p , string ? preferredDerp , TimeSpan ? latency , TimeSpan ? preferredDerpLatency ,
46
46
DateTime ? lastHandshake )
47
47
{
48
- System . Diagnostics . Debug . WriteLine ( $ "Creating agent: { didP2p } { preferredDerp } { latency } { lastHandshake } ") ;
49
48
return new AgentViewModel ( childLogger , coderApiClientFactory , credentialManager , agentAppViewModelFactory ,
50
49
expanderHost , id )
51
50
{
@@ -88,6 +87,19 @@ public enum AgentConnectionStatus
88
87
Offline ,
89
88
}
90
89
90
+ public static class AgentConnectionStatusExtensions
91
+ {
92
+ public static string ToDisplayString ( this AgentConnectionStatus status ) =>
93
+ status switch
94
+ {
95
+ AgentConnectionStatus . Healthy => "Healthy" ,
96
+ AgentConnectionStatus . Unhealthy => "High latency" ,
97
+ AgentConnectionStatus . NoRecentHandshake => "No recent handshake" ,
98
+ AgentConnectionStatus . Offline => "Offline" ,
99
+ _ => status . ToString ( )
100
+ } ;
101
+ }
102
+
91
103
public partial class AgentViewModel : ObservableObject , IModelUpdateable < AgentViewModel >
92
104
{
93
105
private const string DefaultDashboardUrl = "https://coder.com" ;
@@ -169,6 +181,7 @@ public string FullyQualifiedDomainName
169
181
[ ObservableProperty ]
170
182
[ NotifyPropertyChangedFor ( nameof ( ShowExpandAppsMessage ) ) ]
171
183
[ NotifyPropertyChangedFor ( nameof ( ExpandAppsMessage ) ) ]
184
+ [ NotifyPropertyChangedFor ( nameof ( ConnectionTooltip ) ) ]
172
185
public required partial AgentConnectionStatus ConnectionStatus { get ; set ; }
173
186
174
187
[ ObservableProperty ]
@@ -214,11 +227,12 @@ public string FullyQualifiedDomainName
214
227
public string ConnectionTooltip { get
215
228
{
216
229
var description = new StringBuilder ( ) ;
230
+ var highLatencyWarning = ConnectionStatus == AgentConnectionStatus . Unhealthy ? $ "({ AgentConnectionStatus . Unhealthy . ToDisplayString ( ) } )" : "" ;
217
231
218
232
if ( DidP2p != null && DidP2p . Value && Latency != null )
219
233
{
220
234
description . Append ( $ """
221
- You're connected peer-to-peer.
235
+ You're connected peer-to-peer. { highLatencyWarning }
222
236
223
237
You ↔ { Latency . Value . Milliseconds } ms ↔ { WorkspaceName }
224
238
"""
@@ -227,7 +241,7 @@ public string ConnectionTooltip { get
227
241
else if ( PreferredDerpLatency != null )
228
242
{
229
243
description . Append ( $ """
230
- You're connected through a DERP relay.
244
+ You're connected through a DERP relay. { highLatencyWarning }
231
245
We'll switch over to peer-to-peer when available.
232
246
233
247
Total latency: { PreferredDerpLatency . Value . Milliseconds } ms
@@ -247,15 +261,14 @@ public string ConnectionTooltip { get
247
261
}
248
262
}
249
263
}
264
+ else
265
+ {
266
+ description . Append ( ConnectionStatus . ToDisplayString ( ) ) ;
267
+ }
250
268
if ( LastHandshake != null )
251
- description . Append ( $ "\n \n Last handshake: { LastHandshake ? . ToString ( ) ?? "Unknown" } ") ;
252
-
253
- var tooltip = description . ToString ( ) . TrimEnd ( '\n ' , ' ' ) ;
254
-
255
- if ( string . IsNullOrEmpty ( tooltip ) )
256
- return "No connection information available." ;
269
+ description . Append ( $ "\n \n Last handshake: { LastHandshake ? . ToString ( ) } ") ;
257
270
258
- return tooltip ;
271
+ return description . ToString ( ) . TrimEnd ( ' \n ' , ' ' ) ; ;
259
272
}
260
273
}
261
274
0 commit comments