Skip to content

Commit c4a854d

Browse files
committed
Get active application before debounce delay
1 parent 6f2fa5d commit c4a854d

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

Core/Sources/SuggestionWidget/FeatureReducers/WidgetFeature.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -549,20 +549,22 @@ public struct WidgetFeature: ReducerProtocol {
549549
}
550550
}
551551

552+
#warning("TODO: control windows in their dedicated reducers.")
552553
case let .updateWindowOpacity(immediately):
553554
let isChatPanelDetached = state.chatPanelState.chatPanelInASeparateWindow
554555
let hasChat = !state.chatPanelState.chatTabGroup.tabInfo.isEmpty
555556
let shouldDebounce = !immediately &&
556557
Date().timeIntervalSince(state.lastUpdateWindowOpacityTime) < 1
557558
return .run { send in
559+
let activeApp = xcodeInspector.activeApplication
558560
if shouldDebounce {
559561
try await mainQueue.sleep(for: .seconds(0.2))
560562
}
561563
try Task.checkCancellation()
562564
let task = Task { @MainActor in
563-
if let app = xcodeInspector.activeApplication, app.isXcode {
565+
if let activeApp, activeApp.isXcode {
564566
let application = AXUIElementCreateApplication(
565-
app.runningApplication.processIdentifier
567+
activeApp.runningApplication.processIdentifier
566568
)
567569
/// We need this to hide the windows when Xcode is minimized.
568570
let noFocus = application.focusedWindow == nil
@@ -576,10 +578,7 @@ public struct WidgetFeature: ReducerProtocol {
576578
} else {
577579
windows.chatPanelWindow.alphaValue = noFocus ? 0 : 1
578580
}
579-
} else if
580-
let app = xcodeInspector.activeApplication,
581-
app.runningApplication.bundleIdentifier == Bundle.main.bundleIdentifier
582-
{
581+
} else if let activeApp, activeApp.isExtensionService {
583582
let noFocus = {
584583
guard let xcode = xcodeInspector.latestActiveXcode
585584
else { return true }

0 commit comments

Comments
 (0)