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

Commitd1b2c7d

Browse files
committed
added connecting state and improved the logic on tooltip generation
1 parent419dcb2 commitd1b2c7d

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

‎App/ViewModels/AgentViewModel.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ public AgentViewModel CreateDummy(IAgentExpanderHost expanderHost, Uuid id,
8282
publicenumAgentConnectionStatus
8383
{
8484
Healthy,
85+
Connecting,
8586
Unhealthy,
8687
NoRecentHandshake,
87-
Offline,
88+
Offline
8889
}
8990

9091
publicstaticclassAgentConnectionStatusExtensions
@@ -93,6 +94,7 @@ public static string ToDisplayString(this AgentConnectionStatus status) =>
9394
statusswitch
9495
{
9596
AgentConnectionStatus.Healthy=>"Healthy",
97+
AgentConnectionStatus.Connecting=>"Connecting",
9698
AgentConnectionStatus.Unhealthy=>"High latency",
9799
AgentConnectionStatus.NoRecentHandshake=>"No recent handshake",
98100
AgentConnectionStatus.Offline=>"Offline",
@@ -224,7 +226,9 @@ public string FullyQualifiedDomainName
224226
[NotifyPropertyChangedFor(nameof(ConnectionTooltip))]
225227
publicpartialDateTime?LastHandshake{get;set;}=null;
226228

227-
publicstringConnectionTooltip{get
229+
publicstringConnectionTooltip
230+
{
231+
get
228232
{
229233
vardescription=newStringBuilder();
230234
varhighLatencyWarning=ConnectionStatus==AgentConnectionStatus.Unhealthy?$"({AgentConnectionStatus.Unhealthy.ToDisplayString()})":"";

‎App/ViewModels/TrayWindowViewModel.cs

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

227-
#pragma warning disableCS8602// Protobuf will always set this value, so we can safely dereference them.
228-
varlastHandshakeAgo=DateTime.UtcNow.Subtract(agent.LastHandshake.ToDateTime());
229-
#pragma warning restoreCS8602
230-
231-
// For compatibility with older deployments, we assume that if the
232-
// last ping is null, the agent is healthy.
233-
varisLatencyAcceptable=agent.LastPing==null||agent.LastPing.Latency.ToTimeSpan()<HealthyPingThreshold;
234227
varconnectionStatus=AgentConnectionStatus.Healthy;
235-
if(lastHandshakeAgo>TimeSpan.FromMinutes(5))
228+
229+
if(agent.LastHandshake!=null&&agent.LastHandshake.ToDateTime()!=default&&agent.LastHandshake.ToDateTime()<DateTime.UtcNow)
236230
{
237-
connectionStatus=AgentConnectionStatus.NoRecentHandshake;
231+
// For compatibility with older deployments, we assume that if the
232+
// last ping is null, the agent is healthy.
233+
varisLatencyAcceptable=agent.LastPing==null||agent.LastPing.Latency.ToTimeSpan()<HealthyPingThreshold;
234+
235+
varlastHandshakeAgo=DateTime.UtcNow.Subtract(agent.LastHandshake.ToDateTime());
236+
237+
if(lastHandshakeAgo>TimeSpan.FromMinutes(5))
238+
connectionStatus=AgentConnectionStatus.NoRecentHandshake;
239+
elseif(!isLatencyAcceptable)
240+
connectionStatus=AgentConnectionStatus.Unhealthy;
238241
}
239-
elseif(!isLatencyAcceptable)
242+
else
240243
{
241-
connectionStatus=AgentConnectionStatus.Unhealthy;
244+
// If the last handshake is not correct (null, default or in the future),
245+
// we assume the agent is connecting (yellow status icon).
246+
connectionStatus=AgentConnectionStatus.Connecting;
242247
}
243248

244-
245249
workspacesWithAgents.Add(agent.WorkspaceId);
246250
varworkspace=rpcModel.Workspaces.FirstOrDefault(w=>w.Id==agent.WorkspaceId);
247251

@@ -257,7 +261,7 @@ private void UpdateFromRpcModel(RpcModel rpcModel)
257261
agent.LastPing?.PreferredDerp,
258262
agent.LastPing?.Latency?.ToTimeSpan(),
259263
agent.LastPing?.PreferredDerpLatency?.ToTimeSpan(),
260-
agent.LastHandshake?.ToDateTime()));
264+
agent.LastHandshake!=null&&agent.LastHandshake.ToDateTime()!=default?agent.LastHandshake?.ToDateTime():null));
261265
}
262266

263267
// For every stopped workspace that doesn't have any agents, add a

‎App/Views/Pages/TrayWindowMainPage.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@
152152
<SolidColorBrushColor="#ffcc01" />
153153
</converters:StringToBrushSelectorItem.Value>
154154
</converters:StringToBrushSelectorItem>
155+
<converters:StringToBrushSelectorItemKey="Connecting">
156+
<converters:StringToBrushSelectorItem.Value>
157+
<SolidColorBrushColor="#ffcc01" />
158+
</converters:StringToBrushSelectorItem.Value>
159+
</converters:StringToBrushSelectorItem>
155160
<converters:StringToBrushSelectorItemKey="Healthy">
156161
<converters:StringToBrushSelectorItem.Value>
157162
<SolidColorBrushColor="#34c759" />

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp