@@ -19,7 +19,8 @@ public class XPCService: NSObject, XPCServiceProtocol {
1919 public func getXPCServiceVersion( withReply reply: @escaping ( String , String ) -> Void ) {
2020 reply (
2121 Bundle . main. infoDictionary ? [ " CFBundleShortVersionString " ] as? String ?? " N/A " ,
22- Bundle . main. infoDictionary ? [ " CFBundleVersion " ] as? String ?? " N/A " )
22+ Bundle . main. infoDictionary ? [ " CFBundleVersion " ] as? String ?? " N/A "
23+ )
2324 }
2425
2526 @ServiceActor
@@ -88,6 +89,7 @@ public class XPCService: NSObject, XPCServiceProtocol {
8889 withReply reply: @escaping ( Data ? , Error ? ) -> Void
8990 ) {
9091 Task { @ServiceActor in
92+ await RealtimeSuggestionController . shared. cancelInFlightTasksAndIgnoreTriggerForAWhile ( )
9193 do {
9294 let editor = try JSONDecoder ( ) . decode ( EditorContent . self, from: editorContent)
9395 let fileURL = try await Environment . fetchCurrentFileURL ( )
@@ -118,6 +120,7 @@ public class XPCService: NSObject, XPCServiceProtocol {
118120 withReply reply: @escaping ( Data ? , Error ? ) -> Void
119121 ) {
120122 Task { @ServiceActor in
123+ await RealtimeSuggestionController . shared. cancelInFlightTasksAndIgnoreTriggerForAWhile ( )
121124 do {
122125 let editor = try JSONDecoder ( ) . decode ( EditorContent . self, from: editorContent)
123126 let fileURL = try await Environment . fetchCurrentFileURL ( )
@@ -145,6 +148,7 @@ public class XPCService: NSObject, XPCServiceProtocol {
145148 withReply reply: @escaping ( Data ? , Error ? ) -> Void
146149 ) {
147150 Task { @ServiceActor in
151+ await RealtimeSuggestionController . shared. cancelInFlightTasksAndIgnoreTriggerForAWhile ( )
148152 do {
149153 let editor = try JSONDecoder ( ) . decode ( EditorContent . self, from: editorContent)
150154 let fileURL = try await Environment . fetchCurrentFileURL ( )
@@ -172,6 +176,7 @@ public class XPCService: NSObject, XPCServiceProtocol {
172176 withReply reply: @escaping ( Data ? , Error ? ) -> Void
173177 ) {
174178 Task { @ServiceActor in
179+ await RealtimeSuggestionController . shared. cancelInFlightTasksAndIgnoreTriggerForAWhile ( )
175180 do {
176181 let editor = try JSONDecoder ( ) . decode ( EditorContent . self, from: editorContent)
177182 let fileURL = try await Environment . fetchCurrentFileURL ( )
@@ -196,6 +201,7 @@ public class XPCService: NSObject, XPCServiceProtocol {
196201 withReply reply: @escaping ( Data ? , Error ? ) -> Void
197202 ) {
198203 Task { @ServiceActor in
204+ await RealtimeSuggestionController . shared. cancelInFlightTasksAndIgnoreTriggerForAWhile ( )
199205 do {
200206 let editor = try JSONDecoder ( ) . decode ( EditorContent . self, from: editorContent)
201207 let fileURL = try await Environment . fetchCurrentFileURL ( )
@@ -250,7 +256,7 @@ public class XPCService: NSObject, XPCServiceProtocol {
250256 reply ( nil , NSError . from ( error) )
251257 }
252258 }
253-
259+
254260 Task { @ServiceActor in inflightRealtimeSuggestionsTasks. insert ( task) }
255261 }
256262
@@ -260,6 +266,7 @@ public class XPCService: NSObject, XPCServiceProtocol {
260266 return
261267 }
262268 Task { @ServiceActor in
269+ await RealtimeSuggestionController . shared. cancelInFlightTasksAndIgnoreTriggerForAWhile ( )
263270 UserDefaults . shared. set (
264271 !UserDefaults. shared. bool ( forKey: SettingsKey . realtimeSuggestionToggle) ,
265272 forKey: SettingsKey . realtimeSuggestionToggle
@@ -293,7 +300,7 @@ public class XPCService: NSObject, XPCServiceProtocol {
293300 reply ( )
294301 }
295302 }
296-
303+
297304 Task { @ServiceActor in inflightRealtimeSuggestionsTasks. insert ( task) }
298305 }
299306}
0 commit comments