diff --git a/Coder-Desktop/Coder-Desktop/Views/FileSync/FileSyncConfig.swift b/Coder-Desktop/Coder-Desktop/Views/FileSync/FileSyncConfig.swift index 345928b6..dc946c83 100644 --- a/Coder-Desktop/Coder-Desktop/Views/FileSync/FileSyncConfig.swift +++ b/Coder-Desktop/Coder-Desktop/Views/FileSync/FileSyncConfig.swift @@ -103,15 +103,6 @@ struct FileSyncConfig: View { // Opens the log file in Console NSWorkspace.shared.open(fileSync.logFile) } - }.task { - // When the Window is visible, poll for session updates every - // two seconds. - while !Task.isCancelled { - if !fileSync.state.isFailed { - await fileSync.refreshSessions() - } - try? await Task.sleep(for: .seconds(2)) - } }.onAppear { isVisible = true }.onDisappear { diff --git a/Coder-Desktop/Coder-Desktop/Views/FileSync/FileSyncSessionModal.swift b/Coder-Desktop/Coder-Desktop/Views/FileSync/FileSyncSessionModal.swift index d3981723..0e42ea0c 100644 --- a/Coder-Desktop/Coder-Desktop/Views/FileSync/FileSyncSessionModal.swift +++ b/Coder-Desktop/Coder-Desktop/Views/FileSync/FileSyncSessionModal.swift @@ -8,7 +8,7 @@ struct FileSyncSessionModal: View { @EnvironmentObject private var fileSync: FS @State private var localPath: String = "" - @State private var workspace: Agent? + @State private var remoteHostname: String? @State private var remotePath: String = "" @State private var loading: Bool = false @@ -37,12 +37,12 @@ struct FileSyncSessionModal: View { } } Section { - Picker("Workspace", selection: $workspace) { + Picker("Workspace", selection: $remoteHostname) { ForEach(agents, id: \.id) { agent in - Text(agent.primaryHost!).tag(agent) + Text(agent.primaryHost!).tag(agent.primaryHost!) } // HACK: Silence error logs for no-selection. - Divider().tag(nil as Agent?) + Divider().tag(nil as String?) } } Section { @@ -55,15 +55,16 @@ struct FileSyncSessionModal: View { Button("Cancel", action: { dismiss() }).keyboardShortcut(.cancelAction) Button(existingSession == nil ? "Add" : "Save") { Task { await submit() }} .keyboardShortcut(.defaultAction) + .disabled(localPath.isEmpty || remotePath.isEmpty || remoteHostname == nil) }.padding(20) }.onAppear { if let existingSession { localPath = existingSession.alphaPath - workspace = agents.first { $0.primaryHost == existingSession.agentHost } + remoteHostname = agents.first { $0.primaryHost == existingSession.agentHost }?.primaryHost remotePath = existingSession.betaPath } else { // Set the picker to the first agent by default - workspace = agents.first + remoteHostname = agents.first?.primaryHost } }.disabled(loading) .alert("Error", isPresented: Binding( @@ -76,7 +77,7 @@ struct FileSyncSessionModal: View { func submit() async { createError = nil - guard let workspace else { + guard let remoteHostname else { return } loading = true @@ -87,7 +88,7 @@ struct FileSyncSessionModal: View { } try await fileSync.createSession( localPath: localPath, - agentHost: workspace.primaryHost!, + agentHost: remoteHostname, remotePath: remotePath ) } catch { diff --git a/Coder-Desktop/Coder-Desktop/Views/VPN/VPNMenu.swift b/Coder-Desktop/Coder-Desktop/Views/VPN/VPNMenu.swift index 207f0d96..83757efd 100644 --- a/Coder-Desktop/Coder-Desktop/Views/VPN/VPNMenu.swift +++ b/Coder-Desktop/Coder-Desktop/Views/VPN/VPNMenu.swift @@ -116,6 +116,12 @@ struct VPNMenu: View { .environmentObject(vpn) .environmentObject(state) .onReceive(inspection.notice) { inspection.visit(self, $0) } // ViewInspector + .task { + while !Task.isCancelled { + await fileSync.refreshSessions() + try? await Task.sleep(for: .seconds(2)) + } + } } private var vpnDisabled: Bool { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy