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

Commit99d3868

Browse files
committed
review
1 parent92eab7e commit99d3868

File tree

3 files changed

+35
-35
lines changed

3 files changed

+35
-35
lines changed

‎Coder-Desktop/Coder-Desktop/Preview Content/PreviewVPN.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ import SwiftUI
55
finalclass PreviewVPN:Coder_Desktop.VPNService{
66
@Publishedvarstate:Coder_Desktop.VPNServiceState=.connected
77
@PublishedvarmenuState:VPNMenuState=.init(agents:[
8-
UUID():Agent(id:UUID(), name:"dev", status:.error, hosts:["asdf.coder"], wsName:"dogfood2",
8+
UUID():Agent(id:UUID(), name:"dev", status:.no_recent_handshake, hosts:["asdf.coder"], wsName:"dogfood2",
99
wsID:UUID(), primaryHost:"asdf.coder"),
1010
UUID():Agent(id:UUID(), name:"dev", status:.okay, hosts:["asdf.coder"],
1111
wsName:"testing-a-very-long-name", wsID:UUID(), primaryHost:"asdf.coder"),
12-
UUID():Agent(id:UUID(), name:"dev", status:.warn, hosts:["asdf.coder"], wsName:"opensrc",
12+
UUID():Agent(id:UUID(), name:"dev", status:.high_latency, hosts:["asdf.coder"], wsName:"opensrc",
1313
wsID:UUID(), primaryHost:"asdf.coder"),
1414
UUID():Agent(id:UUID(), name:"dev", status:.off, hosts:["asdf.coder"], wsName:"gvisor",
1515
wsID:UUID(), primaryHost:"asdf.coder"),
1616
UUID():Agent(id:UUID(), name:"dev", status:.off, hosts:["asdf.coder"], wsName:"example",
1717
wsID:UUID(), primaryHost:"asdf.coder"),
18-
UUID():Agent(id:UUID(), name:"dev", status:.error, hosts:["asdf.coder"], wsName:"dogfood2",
18+
UUID():Agent(id:UUID(), name:"dev", status:.no_recent_handshake, hosts:["asdf.coder"], wsName:"dogfood2",
1919
wsID:UUID(), primaryHost:"asdf.coder"),
2020
UUID():Agent(id:UUID(), name:"dev", status:.okay, hosts:["asdf.coder"],
2121
wsName:"testing-a-very-long-name", wsID:UUID(), primaryHost:"asdf.coder"),
22-
UUID():Agent(id:UUID(), name:"dev", status:.warn, hosts:["asdf.coder"], wsName:"opensrc",
22+
UUID():Agent(id:UUID(), name:"dev", status:.high_latency, hosts:["asdf.coder"], wsName:"opensrc",
2323
wsID:UUID(), primaryHost:"asdf.coder"),
2424
UUID():Agent(id:UUID(), name:"dev", status:.off, hosts:["asdf.coder"], wsName:"gvisor",
2525
wsID:UUID(), primaryHost:"asdf.coder"),

‎Coder-Desktop/Coder-Desktop/VPN/MenuState.swift

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,32 @@ struct Agent: Identifiable, Equatable, Comparable, Hashable {
4343
}
4444

4545
varstatusString:String{
46-
if status==.error{
46+
switch status{
47+
case.okay,.high_latency:
48+
break
49+
default:
4750
return status.description
4851
}
4952

5053
guardlet lastPingelse{
51-
//either:
52-
// -old coder deployment
53-
// -we haven't received any pings yet
54+
//Either:
55+
// -Old coder deployment
56+
// -We haven't received any pings yet
5457
return status.description
5558
}
5659

60+
lethighLatencyWarning= status==.high_latency?"(High latency)":""
61+
5762
varstr:String
5863
if lastPing.didP2p{
5964
str="""
60-
You're connected peer-to-peer.
65+
You're connected peer-to-peer.\(highLatencyWarning)
6166
6267
You ↔\(lastPing.latency.prettyPrintMs)\(wsName)
6368
"""
6469
}else{
6570
str="""
66-
You're connected through a DERP relay.
71+
You're connected through a DERP relay.\(highLatencyWarning)
6772
We'll switch over to peer-to-peer when available.
6873
6974
Total latency:\(lastPing.latency.prettyPrintMs)
@@ -104,25 +109,25 @@ struct LastPing: Equatable, Hashable {
104109
enumAgentStatus:Int,Equatable,Comparable{
105110
case okay=0
106111
case connecting=1
107-
casewarn=2
108-
caseerror=3
112+
casehigh_latency=2
113+
caseno_recent_handshake=3
109114
case off=4
110115

111116
publicvardescription:String{
112117
switchself{
113118
case.okay:"Connected"
114119
case.connecting:"Connecting..."
115-
case.warn:"Connected, but with high latency" //Currently unused
116-
case.error:"Could not establish a connection to the agent. Retrying..."
120+
case.high_latency:"Connected, but with high latency" //Message currently unused
121+
case.no_recent_handshake:"Could not establish a connection to the agent. Retrying..."
117122
case.off:"Offline"
118123
}
119124
}
120125

121126
publicvarcolor:Color{
122127
switchself{
123128
case.okay:.green
124-
case.warn:.yellow
125-
case.error:.red
129+
case.high_latency:.yellow
130+
case.no_recent_handshake:.red
126131
case.off:.secondary
127132
case.connecting:.yellow
128133
}
@@ -287,26 +292,21 @@ extension Vpn_Agent {
287292
varhealthyPingMax:TimeInterval{0.15} // 150ms
288293

289294
varstatus:AgentStatus{
295+
// Initially the handshake is missing
290296
guardlet lastHandshake= lastHandshake.maybeDateelse{
291-
// Initially the handshake is missing
292297
return.connecting
293298
}
294-
295-
returnif lastHandshake< healthyLastHandshakeMin{
296-
// If last handshake was not within the last five minutes, the agent
297-
// is potentially unhealthy.
298-
.error
299-
}elseif hasLastPing, lastPing.latency.timeInterval< healthyPingMax{
300-
// If latency is less than 150ms
301-
.okay
302-
}elseif hasLastPing, lastPing.latency.timeInterval>= healthyPingMax{
303-
// if latency is greater than 150ms
304-
.warn
305-
}else{
306-
// No ping data, but we have a recent handshake.
307-
// We show green for backwards compatibility with old Coder
308-
// deployments.
309-
.okay
299+
// If last handshake was not within the last five minutes, the agent
300+
// is potentially unhealthy.
301+
guard lastHandshake>= healthyLastHandshakeMinelse{
302+
return.no_recent_handshake
303+
}
304+
// No ping data, but we have a recent handshake.
305+
// We show green for backwards compatibility with old Coder
306+
// deployments.
307+
guard hasLastPingelse{
308+
return.okay
310309
}
310+
return lastPing.latency.timeInterval< healthyPingMax?.okay:.high_latency
311311
}
312312
}

‎Coder-Desktop/Coder-DesktopTests/VPNMenuStateTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ struct VPNMenuStateTests {
9999
state.upsertAgent(agent)
100100

101101
letstoredAgent=try #require(state.agents[agentID])
102-
#expect(storedAgent.status==.warn)
102+
#expect(storedAgent.status==.high_latency)
103103
}
104104

105105
@Test
@@ -139,7 +139,7 @@ struct VPNMenuStateTests {
139139
state.upsertAgent(agent)
140140

141141
letstoredAgent=try #require(state.agents[agentID])
142-
#expect(storedAgent.status==.error)
142+
#expect(storedAgent.status==.no_recent_handshake)
143143
}
144144

145145
@Test

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp