@@ -8,7 +8,7 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
88 @EnvironmentObject private var fileSync : FS
99
1010 @State private var localPath : String = " "
11- @State private var workspace : Agent ?
11+ @State private var remoteHostname : String ?
1212 @State private var remotePath : String = " "
1313
1414 @State private var loading : Bool = false
@@ -37,12 +37,12 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
3737 }
3838 }
3939 Section {
40- Picker ( " Workspace " , selection: $workspace ) {
40+ Picker ( " Workspace " , selection: $remoteHostname ) {
4141 ForEach ( agents, id: \. id) { agent in
42- Text ( agent. primaryHost!) . tag ( agent)
42+ Text ( agent. primaryHost!) . tag ( agent. primaryHost! )
4343 }
4444 // HACK: Silence error logs for no-selection.
45- Divider ( ) . tag ( nil as Agent ? )
45+ Divider ( ) . tag ( nil as String ? )
4646 }
4747 }
4848 Section {
@@ -55,15 +55,16 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
5555 Button ( " Cancel " , action: { dismiss ( ) } ) . keyboardShortcut ( . cancelAction)
5656 Button ( existingSession == nil ? " Add " : " Save " ) { Task { await submit ( ) } }
5757 . keyboardShortcut ( . defaultAction)
58+ . disabled ( localPath. isEmpty || remotePath. isEmpty || remoteHostname == nil )
5859 } . padding ( 20 )
5960 } . onAppear {
6061 if let existingSession {
6162 localPath = existingSession. alphaPath
62- workspace = agents. first { $0. primaryHost == existingSession. agentHost }
63+ remoteHostname = agents. first { $0. primaryHost == existingSession. agentHost } ? . primaryHost
6364 remotePath = existingSession. betaPath
6465 } else {
6566 // Set the picker to the first agent by default
66- workspace = agents. first
67+ remoteHostname = agents. first? . primaryHost
6768 }
6869 } . disabled ( loading)
6970 . alert ( " Error " , isPresented: Binding (
@@ -76,7 +77,7 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
7677
7778 func submit( ) async {
7879 createError = nil
79- guard let workspace else {
80+ guard let remoteHostname else {
8081 return
8182 }
8283 loading = true
@@ -87,7 +88,7 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
8788 }
8889 try await fileSync. createSession (
8990 localPath: localPath,
90- agentHost: workspace . primaryHost! ,
91+ agentHost: remoteHostname ,
9192 remotePath: remotePath
9293 )
9394 } catch {
0 commit comments