@@ -14,7 +14,7 @@ final class RealtimeSuggestionIndicatorController {
1414 @Published var isPrefetching = false
1515 @Published var progress : Double = 1
1616 private var prefetchTask : Task < Void , Error > ?
17-
17+
1818 @MainActor
1919 func prefetch( ) {
2020 prefetchTask? . cancel ( )
@@ -28,12 +28,11 @@ final class RealtimeSuggestionIndicatorController {
2828 }
2929 }
3030 }
31-
31+
3232 @MainActor
3333 func endPrefetch( ) {
3434 withAnimation ( . easeOut( duration: 0.2 ) ) {
3535 isPrefetching = false
36- progress = 1
3736 }
3837 }
3938 }
@@ -68,6 +67,10 @@ final class RealtimeSuggestionIndicatorController {
6867 viewModel. progress = 0
6968 }
7069 }
70+ } . onDisappear {
71+ withAnimation ( . default) {
72+ viewModel. progress = 1
73+ }
7174 }
7275 }
7376 }
@@ -202,6 +205,9 @@ final class RealtimeSuggestionIndicatorController {
202205 let application = AXUIElementCreateApplication ( activeXcode. processIdentifier)
203206 if let focusElement: AXUIElement = try ? application
204207 . copyValue ( key: kAXFocusedUIElementAttribute) ,
208+ let focusElementType: String = try ? focusElement
209+ . copyValue ( key: kAXDescriptionAttribute) ,
210+ focusElementType == " Source Editor " ,
205211 let selectedRange: AXValue = try ? focusElement
206212 . copyValue ( key: kAXSelectedTextRangeAttribute) ,
207213 let rect: AXValue = try ? focusElement. copyParameterizedValue (
@@ -231,7 +237,7 @@ final class RealtimeSuggestionIndicatorController {
231237 func triggerPrefetchAnimation( ) {
232238 viewModel. prefetch ( )
233239 }
234-
240+
235241 func endPrefetchAnimation( ) {
236242 viewModel. endPrefetch ( )
237243 }
0 commit comments