File tree Expand file tree Collapse file tree 3 files changed +9
-3
lines changed
Expand file tree Collapse file tree 3 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ public actor AITerminalChatPlugin: ChatPlugin {
3131 history. append ( . init( role: . user, content: content) )
3232 }
3333 delegate? . pluginDidStartResponding ( self )
34+ if isCancelled { return }
3435 if try await checkConfirmation ( content: content) {
3536 delegate? . pluginDidEndResponding ( self )
3637 delegate? . pluginDidEnd ( self )
@@ -52,6 +53,7 @@ public actor AITerminalChatPlugin: ChatPlugin {
5253 delegate? . pluginDidStartResponding ( self )
5354 let result = try await generateCommand ( task: content)
5455 command = result
56+ if isCancelled { return }
5557 await chatGPTService. mutateHistory { history in
5658 history. append ( . init( role: . assistant, content: """
5759 Confirm to run?
@@ -73,6 +75,8 @@ public actor AITerminalChatPlugin: ChatPlugin {
7375
7476 public func cancel( ) async {
7577 isCancelled = true
78+ delegate? . pluginDidEndResponding ( self )
79+ delegate? . pluginDidEnd ( self )
7680 }
7781
7882 public func stopResponding( ) async { }
Original file line number Diff line number Diff line change 11import Foundation
22import OpenAIService
33
4- public protocol ChatPlugin {
4+ public protocol ChatPlugin : AnyObject {
55 /// Should be [a-zA-Z0-9]+
66 static var command : String { get }
77 var name : String { get }
Original file line number Diff line number Diff line change @@ -112,8 +112,10 @@ extension ChatService: ChatPluginDelegate {
112112 runningPlugin = plugin
113113 }
114114
115- public func pluginDidEnd( _: ChatPlugin ) {
116- runningPlugin = nil
115+ public func pluginDidEnd( _ plugin: ChatPlugin ) {
116+ if runningPlugin === plugin {
117+ runningPlugin = nil
118+ }
117119 }
118120
119121 public func shouldStartAnotherPlugin( _ type: ChatPlugin . Type , withContent content: String ) {
You can’t perform that action at this time.
0 commit comments