@@ -167,6 +167,8 @@ public final class XcodeAppInstanceInspector: AppInstanceInspector {
167167 @Published public var documentURL : URL = . init( fileURLWithPath: " / " )
168168 @Published public var projectURL : URL = . init( fileURLWithPath: " / " )
169169 @Published public var workspaces = [ WorkspaceIdentifier: WorkspaceInfo] ( )
170+ @Published public private( set) var completionPanel : AXUIElement ?
171+
170172 var _version : String ?
171173 public var version : String ? {
172174 if let _version { return _version }
@@ -232,6 +234,41 @@ public final class XcodeAppInstanceInspector: AppInstanceInspector {
232234 }
233235
234236 longRunningTasks. insert ( updateTabsTask)
237+
238+ completionPanel = appElement. firstChild { element in
239+ element. identifier == " _XC_COMPLETION_TABLE_ "
240+ } ? . parent
241+
242+ let completionPanelTask = Task {
243+ let stream = AXNotificationStream (
244+ app: runningApplication,
245+ element: appElement,
246+ notificationNames: kAXCreatedNotification, kAXUIElementDestroyedNotification
247+ )
248+
249+ for await event in stream {
250+ let isCompletionPanel = {
251+ event. element. firstChild { element in
252+ element. identifier == " _XC_COMPLETION_TABLE_ "
253+ } != nil
254+ }
255+ switch event. name {
256+ case kAXCreatedNotification:
257+ if isCompletionPanel ( ) {
258+ completionPanel = event. element
259+ }
260+ case kAXUIElementDestroyedNotification:
261+ if isCompletionPanel ( ) {
262+ completionPanel = nil
263+ }
264+ default : break
265+ }
266+
267+ try Task . checkCancellation ( )
268+ }
269+ }
270+
271+ longRunningTasks. insert ( completionPanelTask)
235272 }
236273
237274 func observeFocusedWindow( ) {
0 commit comments