@@ -3,7 +3,10 @@ import GRPC
33extension MutagenDaemon {
44 typealias PromptStream = GRPCAsyncBidirectionalStreamingCall < Prompting_HostRequest , Prompting_HostResponse >
55
6- func host( allowPrompts: Bool = true ) async throws ( DaemonError) -> ( PromptStream , identifier: String ) {
6+ func host(
7+ allowPrompts: Bool = true ,
8+ promptCallback: ( @MainActor ( String ) -> Void ) ? = nil
9+ ) async throws ( DaemonError) -> ( PromptStream , identifier: String ) {
710 let stream = 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 { @MainActor in self . lastPromptMessage = nil } }
3234 do {
3335 while let msg = try await 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 { @MainActor in self . lastPromptMessage = msg. message }
46+ Task { @MainActor in promptCallback ? ( msg. message) }
4547 }
4648 try await stream. requestStream. send ( reply)
4749 }
0 commit comments