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

Commit1063155

Browse files
committed
fixup tests
1 parent5f3122c commit1063155

File tree

8 files changed

+39
-17
lines changed

8 files changed

+39
-17
lines changed

‎Coder-Desktop/Coder-Desktop/Preview Content/PreviewFileSync.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import VPNLib
33
@MainActor
44
finalclassPreviewFileSync:FileSyncDaemon{
55
varlogFile:URL=.init(filePath:"~/log.txt")!
6-
varlastPromptMessage:String?
76

87
varsessionState:[VPNLib.FileSyncSession]=[]
98

@@ -21,7 +20,12 @@ final class PreviewFileSync: FileSyncDaemon {
2120
state=.stopped
2221
}
2322

24-
func createSession(arg _:CreateSyncSessionRequest)asyncthrows(DaemonError){}
23+
func createSession(
24+
arg _:CreateSyncSessionRequest,
25+
promptCallback _:(
26+
@MainActor(String)->Void
27+
)?
28+
)asyncthrows(DaemonError){}
2529

2630
func deleteSessions(ids _:[String])asyncthrows(VPNLib.DaemonError){}
2731

‎Coder-Desktop/Coder-Desktop/VPN/MenuState.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ struct VPNMenuState {
8787
wsName: workspace.name,
8888
wsID: wsID,
8989
// Hosts arrive sorted by length, the shortest looks best in the UI.
90-
primaryHost: nonEmptyHosts.first!,
90+
primaryHost: nonEmptyHosts.first!
9191
)
9292
}
9393

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
1515
@StateprivatevarcreateError:DaemonError?
1616
@StateprivatevarpickingRemote:Bool=false
1717

18+
@StateprivatevarlastPromptMessage:String?
19+
1820
varbody:someView{
1921
letagents= vpn.menuState.onlineAgents
2022
VStack(spacing:0){
@@ -62,8 +64,11 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
6264
Divider()
6365
HStack{
6466
Spacer()
65-
iflet lastMessage= fileSync.lastPromptMessage{
66-
Text(lastMessage).foregroundStyle(.secondary)
67+
iflet msg= lastPromptMessage{
68+
Text(msg).foregroundStyle(.secondary)
69+
}
70+
if loading{
71+
ProgressView().controlSize(.small)
6772
}
6873
Button("Cancel", action:{dismiss()}).keyboardShortcut(.cancelAction)
6974
Button(existingSession==nil?"Add":"Save"){Task{awaitsubmit()}}
@@ -106,8 +111,10 @@ struct FileSyncSessionModal<VPN: VPNService, FS: FileSyncDaemon>: View {
106111
arg:.init(
107112
alpha:.init(path: localPath, protocolKind:.local),
108113
beta:.init(path: remotePath, protocolKind:.ssh(host: remoteHostname))
109-
)
114+
),
115+
promptCallback:{ lastPromptMessage= $0},
110116
)
117+
lastPromptMessage=nil
111118
} catch{
112119
createError= error
113120
return

‎Coder-Desktop/Coder-DesktopTests/AgentsTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ struct AgentsTests {
2727
status: status,
2828
hosts:["a\($0).coder"],
2929
wsName:"ws\($0)",
30-
wsID:UUID()
30+
wsID:UUID(),
31+
primaryHost:"a\($0).coder",
3132
)
3233
return(agent.id, agent)
3334
})

‎Coder-Desktop/Coder-DesktopTests/Util.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class MockVPNService: VPNService, ObservableObject {
3131
classMockFileSyncDaemon:FileSyncDaemon{
3232
varlogFile:URL=.init(filePath:"~/log.txt")
3333

34+
varlastPromptMessage:String?
35+
3436
varsessionState:[VPNLib.FileSyncSession]=[]
3537

3638
func refreshSessions()async{}
@@ -47,7 +49,10 @@ class MockFileSyncDaemon: FileSyncDaemon {
4749
[]
4850
}
4951

50-
func createSession(arg _:CreateSyncSessionRequest)asyncthrows(DaemonError){}
52+
func createSession(
53+
arg _:CreateSyncSessionRequest,
54+
promptCallback _:(@MainActor(String)->Void)?
55+
)asyncthrows(DaemonError){}
5156

5257
func pauseSessions(ids _:[String])asyncthrows(VPNLib.DaemonError){}
5358

‎Coder-Desktop/VPNLib/FileSync/FileSyncDaemon.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ public protocol FileSyncDaemon: ObservableObject {
1111
varstate:DaemonState{get}
1212
varsessionState:[FileSyncSession]{get}
1313
varlogFile:URL{get}
14-
varlastPromptMessage:String?{get}
1514
func tryStart()async
1615
func stop()async
1716
func refreshSessions()async
18-
func createSession(arg:CreateSyncSessionRequest)asyncthrows(DaemonError)
17+
func createSession(
18+
arg:CreateSyncSessionRequest,
19+
promptCallback:(@MainActor(String)->Void)?
20+
)asyncthrows(DaemonError)
1921
func deleteSessions(ids:[String])asyncthrows(DaemonError)
2022
func pauseSessions(ids:[String])asyncthrows(DaemonError)
2123
func resumeSessions(ids:[String])asyncthrows(DaemonError)
@@ -48,8 +50,6 @@ public class MutagenDaemon: FileSyncDaemon {
4850

4951
publicletlogFile:URL
5052

51-
@PublishedpublicvarlastPromptMessage:String?
52-
5353
// Managing sync sessions could take a while, especially with prompting
5454
letsessionMgmtReqTimeout:TimeAmount=.seconds(15)
5555

‎Coder-Desktop/VPNLib/FileSync/FileSyncManagement.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ public extension MutagenDaemon {
1717
sessionState= sessions.sessionStates.map{FileSyncSession(state: $0)}
1818
}
1919

20-
func createSession(arg:CreateSyncSessionRequest)asyncthrows(DaemonError){
20+
func createSession(
21+
arg:CreateSyncSessionRequest,
22+
promptCallback:(@MainActor(String)->Void)?=nil
23+
)asyncthrows(DaemonError){
2124
if case.stopped= state{
2225
dothrows(DaemonError){
2326
tryawaitstart()
@@ -26,7 +29,7 @@ public extension MutagenDaemon {
2629
throw error
2730
}
2831
}
29-
let(stream, promptID)=tryawaithost()
32+
let(stream, promptID)=tryawaithost(promptCallback: promptCallback)
3033
defer{ stream.cancel()}
3134
letreq=Synchronization_CreateRequest.with{ reqin
3235
req.prompter= promptID

‎Coder-Desktop/VPNLib/FileSync/FileSyncPrompting.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import GRPC
33
extensionMutagenDaemon{
44
typealiasPromptStream=GRPCAsyncBidirectionalStreamingCall<Prompting_HostRequest,Prompting_HostResponse>
55

6-
func host(allowPrompts:Bool=true)asyncthrows(DaemonError)->(PromptStream, identifier:String){
6+
func host(
7+
allowPrompts:Bool=true,
8+
promptCallback:(@MainActor(String)->Void)?=nil
9+
)asyncthrows(DaemonError)->(PromptStream, identifier:String){
710
letstream= client!.prompt.makeHostCall()
811

912
do{
@@ -28,7 +31,6 @@ extension MutagenDaemon {
2831
try initResp.ensureValid(first:true, allowPrompts: allowPrompts)
2932

3033
Task.detached(priority:.background){
31-
defer{Task{@MainActorinself.lastPromptMessage=nil}}
3234
do{
3335
whilelet msg=tryawait iter.next(){
3436
try msg.ensureValid(first:false, allowPrompts: allowPrompts)
@@ -41,7 +43,7 @@ extension MutagenDaemon {
4143
// Any other messages that require a non-empty response will
4244
// cause the create op to fail, showing an error. This is ok for now.
4345
}else{
44-
Task{@MainActorinself.lastPromptMessage=msg.message}
46+
Task{@MainActorinpromptCallback?(msg.message)}
4547
}
4648
tryawait stream.requestStream.send(reply)
4749
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp