11import ActiveApplicationMonitor
22import AppKit
3+ import AsyncAlgorithms
34import AXNotificationStream
45import DisplayLink
56import Environment
67import QuartzCore
78import SwiftUI
89import XPCShared
9- import AsyncAlgorithms
1010
1111/// Present a tiny dot next to mouse cursor if real-time suggestion is enabled.
1212@MainActor
@@ -97,7 +97,6 @@ final class RealtimeSuggestionIndicatorController {
9797 private var windowChangeObservationTask : Task < Void , Error > ?
9898 private var activeApplicationMonitorTask : Task < Void , Error > ?
9999 private var editorObservationTask : Task < Void , Error > ?
100- private var xcode : NSRunningApplication ?
101100 var isObserving = false {
102101 didSet {
103102 Task {
@@ -166,7 +165,6 @@ final class RealtimeSuggestionIndicatorController {
166165 }
167166
168167 private func observeXcodeWindowChangeIfNeeded( _ app: NSRunningApplication ) {
169- xcode = app
170168 guard windowChangeObservationTask == nil else { return }
171169 windowChangeObservationTask = Task { [ weak self] in
172170 let notifications = AXNotificationStream (
@@ -177,6 +175,7 @@ final class RealtimeSuggestionIndicatorController {
177175 kAXFocusedWindowChangedNotification,
178176 kAXFocusedUIElementChangedNotification
179177 )
178+ self ? . observeEditorChangeIfNeeded ( )
180179 for await notification in notifications {
181180 guard let self else { return }
182181 try Task . checkCancellation ( )
@@ -210,6 +209,7 @@ final class RealtimeSuggestionIndicatorController {
210209 . copyValue ( key: kAXVerticalScrollBarAttribute)
211210 else { return }
212211
212+ updateIndicatorLocation ( )
213213 editorObservationTask = Task { [ weak self] in
214214 let notificationsFromEditor = AXNotificationStream (
215215 app: activeXcode,
@@ -220,13 +220,13 @@ final class RealtimeSuggestionIndicatorController {
220220 kAXLayoutChangedNotification,
221221 kAXSelectedTextChangedNotification
222222 )
223-
223+
224224 let notificationsFromScrollBar = AXNotificationStream (
225225 app: activeXcode,
226226 element: scrollBar,
227227 notificationNames: kAXValueChangedNotification
228228 )
229-
229+
230230 for await _ in merge ( notificationsFromEditor, notificationsFromScrollBar) {
231231 guard let self else { return }
232232 try Task . checkCancellation ( )
0 commit comments