@@ -86,19 +86,21 @@ public actor RealtimeSuggestionController {
8686 if Task . isCancelled { return }
8787 guard await Environment . isXcodeActive ( ) else { return }
8888
89+ // cancel in-flight tasks
8990 await withTaskGroup ( of: Void . self) { group in
9091 for (_, workspace) in await workspaces {
9192 group. addTask {
9293 await workspace. cancelInFlightRealtimeSuggestionRequests ( )
9394 }
9495 }
96+ group. addTask {
97+ await { @ServiceActor in
98+ inflightRealtimeSuggestionsTasks. forEach { $0. cancel ( ) }
99+ inflightRealtimeSuggestionsTasks. removeAll ( )
100+ } ( )
101+ }
95102 }
96103
97- await { @ServiceActor in
98- inflightRealtimeSuggestionsTasks. forEach { $0. cancel ( ) }
99- inflightRealtimeSuggestionsTasks. removeAll ( )
100- } ( )
101-
102104 let escape = 0x35
103105 let isEditing = await Environment . frontmostXcodeWindowIsEditor ( )
104106
@@ -109,7 +111,7 @@ public actor RealtimeSuggestionController {
109111 }
110112
111113 let shouldTrigger = {
112- // closing suggestion panel
114+ // closing auto-complete panel
113115 if isEditing, event. getIntegerValueField ( . keyboardEventKeycode) == escape {
114116 return true
115117 }
@@ -132,11 +134,10 @@ public actor RealtimeSuggestionController {
132134 . value ( forKey: SettingsKey . realtimeSuggestionDebounce) as? Int
133135 ?? 800_000_000
134136 ) )
135- if Task . isCancelled { return }
136- os_log ( . info, " Prefetch suggestions. " )
137137 guard UserDefaults . shared. bool ( forKey: SettingsKey . realtimeSuggestionToggle)
138138 else { return }
139139 if Task . isCancelled { return }
140+ os_log ( . info, " Prefetch suggestions. " )
140141 do {
141142 try await Environment . triggerAction ( " Prefetch Suggestions " )
142143 } catch {
@@ -146,13 +147,25 @@ public actor RealtimeSuggestionController {
146147 }
147148}
148149
150+ /// Present a tiny dot next to mouse cursor if real-time suggestion is enabled.
149151final class RealtimeSuggestionIndicatorController {
150152 struct IndicatorContentView : View {
153+ @State var opacity : CGFloat = 1
154+ @State var scale : CGFloat = 1
151155 var body : some View {
152156 Circle ( )
153- . trim ( from : 0.2 , to : 1 )
154- . fill ( Color . accentColor )
157+ . fill ( Color . accentColor . opacity ( opacity ) )
158+ . scaleEffect ( . init ( width : scale , height : scale ) )
155159 . frame ( width: 8 , height: 8 )
160+ . onAppear {
161+ Task {
162+ await Task . yield ( ) // to avoid unwanted translations.
163+ withAnimation ( . easeInOut( duration: 1 ) . repeatForever ( autoreverses: true ) ) {
164+ opacity = 0.5
165+ scale = 0.5
166+ }
167+ }
168+ }
156169 }
157170 }
158171
0 commit comments