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

fix: improve file sync agent picker#128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ethanndickson merged 4 commits intomainfromethan/rework-agent-picker
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -103,15 +103,6 @@ struct FileSyncConfig<VPN: VPNService, FS: FileSyncDaemon>: 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 {
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is already checked inrefreshSessions.

await fileSync.refreshSessions()
}
try? await Task.sleep(for: .seconds(2))
}
}.onAppear {
isVisible = true
}.onDisappear {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
@EnvironmentObject private var fileSync: FS

@State private var localPath: String = ""
@State private varworkspace: Agent?
@State private varremoteHostname: String?
@State private var remotePath: String = ""

@State private var loading: Bool = false
Expand DownExpand Up@@ -37,12 +37,12 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: 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 asAgent?)
Divider().tag(nil asString?)
}
}
Section {
Expand All@@ -55,15 +55,16 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: 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(
Expand All@@ -76,7 +77,7 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {

func submit() async {
createError = nil
guard letworkspace else {
guard letremoteHostname else {
return
}
loading = true
Expand All@@ -87,7 +88,7 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
}
try await fileSync.createSession(
localPath: localPath,
agentHost:workspace.primaryHost!,
agentHost:remoteHostname,
remotePath: remotePath
)
} catch {
Expand Down
6 changes: 6 additions & 0 deletionsCoder-Desktop/Coder-Desktop/Views/VPN/VPNMenu.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -116,6 +116,12 @@ struct VPNMenu<VPN: VPNService, FS: FileSyncDaemon>: 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 {
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp