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

Commit9f625fd

Browse files
fix: improve file sync agent picker (#128)
Previously, the agent/workspace picker when creating a file sync session had the user choose between instances of the `Agent` struct. This meant the value would get unselected were the status of the agent to change. I'm not sure why I had the picker select the entire struct instead of just the hostname.
1 parentfe20801 commit9f625fd

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

‎Coder-Desktop/Coder-Desktop/Views/FileSync/FileSyncConfig.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,6 @@ struct FileSyncConfig<VPN: VPNService, FS: FileSyncDaemon>: View {
103103
// Opens the log file in Console
104104
NSWorkspace.shared.open(fileSync.logFile)
105105
}
106-
}.task{
107-
// When the Window is visible, poll for session updates every
108-
// two seconds.
109-
while !Task.isCancelled{
110-
if !fileSync.state.isFailed{
111-
await fileSync.refreshSessions()
112-
}
113-
try?awaitTask.sleep(for:.seconds(2))
114-
}
115106
}.onAppear{
116107
isVisible=true
117108
}.onDisappear{

‎Coder-Desktop/Coder-Desktop/Views/FileSync/FileSyncSessionModal.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
88
@EnvironmentObjectprivatevarfileSync:FS
99

1010
@StateprivatevarlocalPath:String=""
11-
@Stateprivatevarworkspace:Agent?
11+
@StateprivatevarremoteHostname:String?
1212
@StateprivatevarremotePath:String=""
1313

1414
@Stateprivatevarloading: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){ agentin
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(nilasAgent?)
45+
Divider().tag(nilasString?)
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{awaitsubmit()}}
5757
.keyboardShortcut(.defaultAction)
58+
.disabled(localPath.isEmpty || remotePath.isEmpty || remoteHostname==nil)
5859
}.padding(20)
5960
}.onAppear{
6061
iflet 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-
guardletworkspaceelse{
80+
guardletremoteHostnameelse{
8081
return
8182
}
8283
loading=true
@@ -87,7 +88,7 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
8788
}
8889
tryawait fileSync.createSession(
8990
localPath: localPath,
90-
agentHost:workspace.primaryHost!,
91+
agentHost:remoteHostname,
9192
remotePath: remotePath
9293
)
9394
} catch{

‎Coder-Desktop/Coder-Desktop/Views/VPN/VPNMenu.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ struct VPNMenu<VPN: VPNService, FS: FileSyncDaemon>: View {
116116
.environmentObject(vpn)
117117
.environmentObject(state)
118118
.onReceive(inspection.notice){ inspection.visit(self, $0)} // ViewInspector
119+
.task{
120+
while !Task.isCancelled{
121+
await fileSync.refreshSessions()
122+
try?awaitTask.sleep(for:.seconds(2))
123+
}
124+
}
119125
}
120126

121127
privatevarvpnDisabled:Bool{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp