@@ -3,7 +3,10 @@ import GRPC
3
3
extension MutagenDaemon {
4
4
typealias PromptStream = GRPCAsyncBidirectionalStreamingCall < Prompting_HostRequest , Prompting_HostResponse >
5
5
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 ) {
7
10
let stream = client!. prompt. makeHostCall ( )
8
11
9
12
do {
@@ -28,7 +31,6 @@ extension MutagenDaemon {
28
31
try initResp. ensureValid ( first: true , allowPrompts: allowPrompts)
29
32
30
33
Task . detached ( priority: . background) {
31
- defer { Task { @MainActor in self . lastPromptMessage = nil } }
32
34
do {
33
35
while let msg = try await iter. next ( ) {
34
36
try msg. ensureValid ( first: false , allowPrompts: allowPrompts)
@@ -41,7 +43,7 @@ extension MutagenDaemon {
41
43
// Any other messages that require a non-empty response will
42
44
// cause the create op to fail, showing an error. This is ok for now.
43
45
} else {
44
- Task { @MainActor in self . lastPromptMessage = msg. message }
46
+ Task { @MainActor in promptCallback ? ( msg. message) }
45
47
}
46
48
try await stream. requestStream. send ( reply)
47
49
}
0 commit comments