@@ -37,7 +37,7 @@ public final class XcodeInspector: ObservableObject {
3737 if let activeXcode {
3838 setActiveXcode ( activeXcode)
3939 }
40-
40+
4141 let sequence = NSWorkspace . shared. notificationCenter
4242 . notifications ( named: NSWorkspace . didActivateApplicationNotification)
4343 for await notification in sequence {
@@ -90,7 +90,7 @@ public final class XcodeInspector: ObservableObject {
9090 @MainActor
9191 func setActiveXcode( _ xcode: XcodeAppInstanceInspector ) {
9292 xcode. refresh ( )
93-
93+
9494 for task in activeXcodeObservations { task. cancel ( ) }
9595 for cancellable in activeXcodeCancellable { cancellable. cancel ( ) }
9696 activeXcodeObservations. removeAll ( )
@@ -178,6 +178,10 @@ public final class XcodeAppInstanceInspector: AppInstanceInspector {
178178 @Published public var documentURL : URL = . init( fileURLWithPath: " / " )
179179 @Published public var projectURL : URL = . init( fileURLWithPath: " / " )
180180 @Published public var workspaces = [ WorkspaceIdentifier: WorkspaceInfo] ( )
181+ public var realtimeWorkspaces : [ WorkspaceIdentifier : WorkspaceInfo ] {
182+ Self . fetchWorkspaceInfo ( runningApplication)
183+ }
184+
181185 @Published public private( set) var completionPanel : AXUIElement ?
182186
183187 var _version : String ?
@@ -212,7 +216,7 @@ public final class XcodeAppInstanceInspector: AppInstanceInspector {
212216
213217 observeFocusedWindow ( )
214218 observeAXNotifications ( )
215-
219+
216220 Task {
217221 try await Task . sleep ( nanoseconds: 3_000_000_000 )
218222 // Sometimes the focused window may not be ready on app launch.
@@ -254,19 +258,19 @@ public final class XcodeAppInstanceInspector: AppInstanceInspector {
254258 focusedWindow = nil
255259 }
256260 }
257-
261+
258262 func refresh( ) {
259263 if let focusedWindow = focusedWindow as? WorkspaceXcodeWindowInspector {
260264 focusedWindow. refresh ( )
261265 } else {
262266 observeFocusedWindow ( )
263267 }
264268 }
265-
269+
266270 func observeAXNotifications( ) {
267271 longRunningTasks. forEach { $0. cancel ( ) }
268272 longRunningTasks = [ ]
269-
273+
270274 let focusedWindowChanged = Task {
271275 let notification = AXNotificationStream (
272276 app: runningApplication,
@@ -288,7 +292,7 @@ public final class XcodeAppInstanceInspector: AppInstanceInspector {
288292 kAXApplicationDeactivatedNotification
289293 )
290294 if #available( macOS 13 . 0 , * ) {
291- for await _ in notification. debounce ( for: . seconds( 5 ) ) {
295+ for await _ in notification. debounce ( for: . seconds( 2 ) ) {
292296 try Task . checkCancellation ( )
293297 workspaces = Self . fetchWorkspaceInfo ( runningApplication)
294298 }
0 commit comments