Skip to content

Commit a51c53c

Browse files
committed
comments
1 parent f669c09 commit a51c53c

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

App/Converters/VpnLifecycleToBoolConverter.cs

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Coder.Desktop.App.Converters;
88

9+
[DependencyProperty<bool>("Unknown", DefaultValue = false)]
910
[DependencyProperty<bool>("Starting", DefaultValue = false)]
1011
[DependencyProperty<bool>("Started", DefaultValue = false)]
1112
[DependencyProperty<bool>("Stopping", DefaultValue = false)]
@@ -18,6 +19,7 @@ public object Convert(object value, Type targetType, object parameter, string la
1819

1920
return lifecycle switch
2021
{
22+
VpnLifecycle.Unknown => Unknown,
2123
VpnLifecycle.Starting => Starting,
2224
VpnLifecycle.Started => Started,
2325
VpnLifecycle.Stopping => Stopping,

App/Models/RpcModel.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public enum RpcLifecycle
1313

1414
public enum VpnLifecycle
1515
{
16+
Unknown,
1617
Stopped,
1718
Starting,
1819
Started,
@@ -23,7 +24,7 @@ public class RpcModel
2324
{
2425
public RpcLifecycle RpcLifecycle { get; set; } = RpcLifecycle.Disconnected;
2526

26-
public VpnLifecycle VpnLifecycle { get; set; } = VpnLifecycle.Stopped;
27+
public VpnLifecycle VpnLifecycle { get; set; } = VpnLifecycle.Unknown;
2728

2829
public List<Workspace> Workspaces { get; set; } = [];
2930

App/Services/RpcController.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public async Task Reconnect(CancellationToken ct = default)
126126
MutateState(state =>
127127
{
128128
state.RpcLifecycle = RpcLifecycle.Disconnected;
129-
state.VpnLifecycle = VpnLifecycle.Stopped;
129+
state.VpnLifecycle = VpnLifecycle.Unknown;
130130
state.Workspaces.Clear();
131131
state.Agents.Clear();
132132
});
@@ -136,7 +136,7 @@ public async Task Reconnect(CancellationToken ct = default)
136136
MutateState(state =>
137137
{
138138
state.RpcLifecycle = RpcLifecycle.Connected;
139-
state.VpnLifecycle = VpnLifecycle.Stopping; // prevents clicking the toggle
139+
state.VpnLifecycle = VpnLifecycle.Unknown;
140140
state.Workspaces.Clear();
141141
state.Agents.Clear();
142142
});
@@ -250,7 +250,7 @@ private void ApplyStatusUpdate(Status status)
250250
{
251251
state.VpnLifecycle = status.Lifecycle switch
252252
{
253-
Status.Types.Lifecycle.Unknown => VpnLifecycle.Stopping, // disables the switch
253+
Status.Types.Lifecycle.Unknown => VpnLifecycle.Unknown,
254254
Status.Types.Lifecycle.Starting => VpnLifecycle.Starting,
255255
Status.Types.Lifecycle.Started => VpnLifecycle.Started,
256256
Status.Types.Lifecycle.Stopping => VpnLifecycle.Stopping,

App/ViewModels/TrayWindowViewModel.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ public partial class TrayWindowViewModel : ObservableObject
2222
private DispatcherQueue? _dispatcherQueue;
2323

2424
[ObservableProperty]
25-
public partial VpnLifecycle VpnLifecycle { get; set; } =
26-
VpnLifecycle.Stopping; // to prevent interaction until we get the real state
25+
public partial VpnLifecycle VpnLifecycle { get; set; } = VpnLifecycle.Unknown;
2726

2827
// VpnSwitchOn needs to be its own property as it is a two-way binding
2928
[ObservableProperty]
@@ -82,7 +81,7 @@ private void UpdateFromRpcModel(RpcModel rpcModel)
8281
// Window should not show the current Page if the RPC is disconnected.
8382
if (rpcModel.RpcLifecycle is RpcLifecycle.Disconnected)
8483
{
85-
VpnLifecycle = VpnLifecycle.Stopping;
84+
VpnLifecycle = VpnLifecycle.Unknown;
8685
VpnSwitchOn = false;
8786
Agents = [];
8887
return;

Vpn.Proto/vpn.proto

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ message ClientMessage {
5050
oneof msg {
5151
StartRequest start = 2;
5252
StopRequest stop = 3;
53-
StatusRequest status = 4;
53+
StatusRequest status = 4;
5454
}
5555
}
5656

@@ -60,7 +60,7 @@ message ServiceMessage {
6060
oneof msg {
6161
StartResponse start = 2;
6262
StopResponse stop = 3;
63-
Status status = 4; // either in reply to a StatusRequest or broadcasted
63+
Status status = 4; // either in reply to a StatusRequest or broadcasted
6464
}
6565
}
6666

0 commit comments

Comments
 (0)