@@ -8,7 +8,7 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
8
8
@EnvironmentObject private var fileSync : FS
9
9
10
10
@State private var localPath : String = " "
11
- @State private var workspace : Agent ?
11
+ @State private var remoteHostname : String ?
12
12
@State private var remotePath : String = " "
13
13
14
14
@State private var loading : Bool = false
@@ -37,12 +37,12 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
37
37
}
38
38
}
39
39
Section {
40
- Picker ( " Workspace " , selection: $workspace ) {
40
+ Picker ( " Workspace " , selection: $remoteHostname ) {
41
41
ForEach ( agents, id: \. id) { agent in
42
- Text ( agent. primaryHost!) . tag ( agent)
42
+ Text ( agent. primaryHost!) . tag ( agent. primaryHost! )
43
43
}
44
44
// HACK: Silence error logs for no-selection.
45
- Divider ( ) . tag ( nil as Agent ? )
45
+ Divider ( ) . tag ( nil as String ? )
46
46
}
47
47
}
48
48
Section {
@@ -55,15 +55,16 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
55
55
Button ( " Cancel " , action: { dismiss ( ) } ) . keyboardShortcut ( . cancelAction)
56
56
Button ( existingSession == nil ? " Add " : " Save " ) { Task { await submit ( ) } }
57
57
. keyboardShortcut ( . defaultAction)
58
+ . disabled ( localPath. isEmpty || remotePath. isEmpty || remoteHostname == nil )
58
59
} . padding ( 20 )
59
60
} . onAppear {
60
61
if let existingSession {
61
62
localPath = existingSession. alphaPath
62
- workspace = agents. first { $0. primaryHost == existingSession. agentHost }
63
+ remoteHostname = agents. first { $0. primaryHost == existingSession. agentHost } ? . primaryHost
63
64
remotePath = existingSession. betaPath
64
65
} else {
65
66
// Set the picker to the first agent by default
66
- workspace = agents. first
67
+ remoteHostname = agents. first? . primaryHost
67
68
}
68
69
} . disabled ( loading)
69
70
. alert ( " Error " , isPresented: Binding (
@@ -76,7 +77,7 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
76
77
77
78
func submit( ) async {
78
79
createError = nil
79
- guard let workspace else {
80
+ guard let remoteHostname else {
80
81
return
81
82
}
82
83
loading = true
@@ -87,7 +88,7 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
87
88
}
88
89
try await fileSync. createSession (
89
90
localPath: localPath,
90
- agentHost: workspace . primaryHost! ,
91
+ agentHost: remoteHostname ,
91
92
remotePath: remotePath
92
93
)
93
94
} catch {
0 commit comments