@@ -21,7 +21,7 @@ public struct WidgetFeature: ReducerProtocol {
2121 public var sharedPanelWindowState = WindowState ( )
2222 public var tabWindowState = WindowState ( )
2323 }
24-
24+
2525 public enum WindowCanBecomeKey : Equatable {
2626 case sharedPanel
2727 case chatPanel
@@ -153,8 +153,8 @@ public struct WidgetFeature: ReducerProtocol {
153153 }
154154
155155 case . circularWidget( . widgetClicked) :
156- let isDisplayingContent = state. _circularWidgetState. isDisplayingContent
157- if isDisplayingContent {
156+ let wasDisplayingContent = state. _circularWidgetState. isDisplayingContent
157+ if wasDisplayingContent {
158158 state. panelState. sharedPanelState. isPanelDisplayed = false
159159 state. panelState. suggestionPanelState. isPanelDisplayed = false
160160 state. chatPanelState. isPanelDisplayed = false
@@ -163,11 +163,16 @@ public struct WidgetFeature: ReducerProtocol {
163163 state. panelState. suggestionPanelState. isPanelDisplayed = true
164164 state. chatPanelState. isPanelDisplayed = true
165165 }
166+ let isDisplayingContent = state. _circularWidgetState. isDisplayingContent
166167 return . run { _ in
167- guard isDisplayingContent else { return }
168- if let app = activeApplicationMonitor. previousApp, app. isXcode {
169- try await Task . sleep ( nanoseconds: 200_000_000 )
170- app. activate ( )
168+ if isDisplayingContent, !( await NSApplication . shared. isActive) {
169+ try await Task . sleep ( nanoseconds: 50_000_000 )
170+ await NSApplication . shared. activate ( ignoringOtherApps: true )
171+ } else if !isDisplayingContent,
172+ let app = xcodeInspector. previousActiveApplication
173+ {
174+ try await Task . sleep ( nanoseconds: 20_000_000 )
175+ app. runningApplication. activate ( )
171176 }
172177 }
173178
@@ -584,7 +589,7 @@ public struct WidgetFeature: ReducerProtocol {
584589 await send ( . updateWindowOpacityFinished)
585590 }
586591 . cancellable ( id: DebounceKey . updateWindowOpacity, cancelInFlight: true )
587-
592+
588593 case . updateWindowOpacityFinished:
589594 state. lastUpdateWindowOpacityTime = Date ( )
590595 return . none
0 commit comments