Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit419dcb2

Browse files
committed
PR fixes
1 parentb05f081 commit419dcb2

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

‎App/ViewModels/AgentViewModel.cs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public AgentViewModel Create(IAgentExpanderHost expanderHost, Uuid id, string fu
4545
string?workspaceName,bool?didP2p,string?preferredDerp,TimeSpan?latency,TimeSpan?preferredDerpLatency,
4646
DateTime?lastHandshake)
4747
{
48-
System.Diagnostics.Debug.WriteLine($"Creating agent:{didP2p}{preferredDerp}{latency}{lastHandshake}");
4948
returnnewAgentViewModel(childLogger,coderApiClientFactory,credentialManager,agentAppViewModelFactory,
5049
expanderHost,id)
5150
{
@@ -88,6 +87,19 @@ public enum AgentConnectionStatus
8887
Offline,
8988
}
9089

90+
publicstaticclassAgentConnectionStatusExtensions
91+
{
92+
publicstaticstringToDisplayString(thisAgentConnectionStatusstatus)=>
93+
statusswitch
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+
91103
publicpartialclassAgentViewModel:ObservableObject,IModelUpdateable<AgentViewModel>
92104
{
93105
privateconststringDefaultDashboardUrl="https://coder.com";
@@ -169,6 +181,7 @@ public string FullyQualifiedDomainName
169181
[ObservableProperty]
170182
[NotifyPropertyChangedFor(nameof(ShowExpandAppsMessage))]
171183
[NotifyPropertyChangedFor(nameof(ExpandAppsMessage))]
184+
[NotifyPropertyChangedFor(nameof(ConnectionTooltip))]
172185
publicrequiredpartialAgentConnectionStatusConnectionStatus{get;set;}
173186

174187
[ObservableProperty]
@@ -214,11 +227,12 @@ public string FullyQualifiedDomainName
214227
publicstringConnectionTooltip{get
215228
{
216229
vardescription=newStringBuilder();
230+
varhighLatencyWarning=ConnectionStatus==AgentConnectionStatus.Unhealthy?$"({AgentConnectionStatus.Unhealthy.ToDisplayString()})":"";
217231

218232
if(DidP2p!=null&&DidP2p.Value&&Latency!=null)
219233
{
220234
description.Append($"""
221-
You're connected peer-to-peer.
235+
You're connected peer-to-peer.{highLatencyWarning}
222236
223237
You ↔{Latency.Value.Milliseconds} ms ↔{WorkspaceName}
224238
"""
@@ -227,7 +241,7 @@ public string ConnectionTooltip { get
227241
elseif(PreferredDerpLatency!=null)
228242
{
229243
description.Append($"""
230-
You're connected through a DERP relay.
244+
You're connected through a DERP relay.{highLatencyWarning}
231245
We'll switch over to peer-to-peer when available.
232246
233247
Total latency:{PreferredDerpLatency.Value.Milliseconds} ms
@@ -247,15 +261,14 @@ public string ConnectionTooltip { get
247261
}
248262
}
249263
}
264+
else
265+
{
266+
description.Append(ConnectionStatus.ToDisplayString());
267+
}
250268
if(LastHandshake!=null)
251-
description.Append($"\n\nLast handshake:{LastHandshake?.ToString()??"Unknown"}");
252-
253-
vartooltip=description.ToString().TrimEnd('\n',' ');
254-
255-
if(string.IsNullOrEmpty(tooltip))
256-
return"No connection information available.";
269+
description.Append($"\n\nLast handshake:{LastHandshake?.ToString()}");
257270

258-
returntooltip;
271+
returndescription.ToString().TrimEnd('\n',' ');;
259272
}
260273
}
261274

‎App/ViewModels/TrayWindowViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,13 @@ private void UpdateFromRpcModel(RpcModel rpcModel)
224224
if(string.IsNullOrWhiteSpace(fqdn))
225225
continue;
226226

227-
227+
#pragma warning disableCS8602// Protobuf will always set this value, so we can safely dereference them.
228228
varlastHandshakeAgo=DateTime.UtcNow.Subtract(agent.LastHandshake.ToDateTime());
229+
#pragma warning restoreCS8602
229230

230231
// For compatibility with older deployments, we assume that if the
231232
// last ping is null, the agent is healthy.
232-
varisLatencyAcceptable=agent.LastPing!=null?agent.LastPing.Latency.ToTimeSpan()<HealthyPingThreshold:true;
233+
varisLatencyAcceptable=agent.LastPing==null||agent.LastPing.Latency.ToTimeSpan()<HealthyPingThreshold;
233234
varconnectionStatus=AgentConnectionStatus.Healthy;
234235
if(lastHandshakeAgo>TimeSpan.FromMinutes(5))
235236
{
@@ -243,7 +244,6 @@ private void UpdateFromRpcModel(RpcModel rpcModel)
243244

244245
workspacesWithAgents.Add(agent.WorkspaceId);
245246
varworkspace=rpcModel.Workspaces.FirstOrDefault(w=>w.Id==agent.WorkspaceId);
246-
System.Diagnostics.Debug.WriteLine($"Agent{uuid} LastHandshakeAgo:{lastHandshakeAgo} ConnectionStatus:{connectionStatus} FQDN:{fqdn} Last ping:{agent.LastPing} Last handshake:{agent.LastHandshake}");
247247

248248
agents.Add(_agentViewModelFactory.Create(
249249
this,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp