@@ -115,7 +115,7 @@ public struct WidgetFeature: ReducerProtocol {
115115 case updateColorScheme
116116
117117 case updateWindowLocation( animated: Bool )
118- case updateWindowOpacity
118+ case updateWindowOpacity( immediately : Bool )
119119 case updateFocusingDocumentURL
120120 case updateWindowOpacityFinished
121121 case updateKeyWindow( WindowCanBecomeKey )
@@ -206,7 +206,7 @@ public struct WidgetFeature: ReducerProtocol {
206206 let isDetached = state. chatPanelState. chatPanelInASeparateWindow
207207 return . run { send in
208208 await send ( . updateWindowLocation( animated: false ) )
209- await send ( . updateWindowOpacity)
209+ await send ( . updateWindowOpacity( immediately : false ) )
210210 if isDetached {
211211 Task { @MainActor in
212212 windows. chatPanelWindow. alphaValue = 1
@@ -217,7 +217,7 @@ public struct WidgetFeature: ReducerProtocol {
217217 let isDetached = state. chatPanelState. chatPanelInASeparateWindow
218218 return . run { send in
219219 await send ( . updateWindowLocation( animated: !isDetached) )
220- await send ( . updateWindowOpacity)
220+ await send ( . updateWindowOpacity( immediately : false ) )
221221 }
222222 default : return . none
223223 }
@@ -278,7 +278,7 @@ public struct WidgetFeature: ReducerProtocol {
278278 for await _ in stream {
279279 try Task . checkCancellation ( )
280280 await send ( . updateWindowLocation( animated: false ) )
281- await send ( . updateWindowOpacity)
281+ await send ( . updateWindowOpacity( immediately : false ) )
282282 }
283283 } . cancellable ( id: CancelID . observeCompletionPanelChange, cancelInFlight: true )
284284
@@ -392,12 +392,12 @@ public struct WidgetFeature: ReducerProtocol {
392392 kAXFocusedWindowChangedNotification,
393393 ] . contains ( notification. name) {
394394 await send ( . updateWindowLocation( animated: false ) )
395- await send ( . updateWindowOpacity)
395+ await send ( . updateWindowOpacity( immediately : false ) )
396396 await send ( . observeEditorChange)
397397 await send ( . panel( . switchToAnotherEditorAndUpdateContent) )
398398 } else {
399399 await send ( . updateWindowLocation( animated: false ) )
400- await send ( . updateWindowOpacity)
400+ await send ( . updateWindowOpacity( immediately : false ) )
401401 }
402402 }
403403 } . cancellable ( id: CancelID . observeWindowChange, cancelInFlight: true )
@@ -433,14 +433,14 @@ public struct WidgetFeature: ReducerProtocol {
433433 guard xcodeInspector. latestActiveXcode != nil else { return }
434434 try Task . checkCancellation ( )
435435 await send ( . updateWindowLocation( animated: false ) )
436- await send ( . updateWindowOpacity)
436+ await send ( . updateWindowOpacity( immediately : false ) )
437437 }
438438 } else {
439439 for await _ in merge ( selectionRangeChange, scroll) {
440440 guard xcodeInspector. latestActiveXcode != nil else { return }
441441 try Task . checkCancellation ( )
442442 await send ( . updateWindowLocation( animated: false ) )
443- await send ( . updateWindowOpacity)
443+ await send ( . updateWindowOpacity( immediately : false ) )
444444 }
445445 }
446446
@@ -451,14 +451,14 @@ public struct WidgetFeature: ReducerProtocol {
451451 return . run { send in
452452 await send ( . panel( . switchToAnotherEditorAndUpdateContent) )
453453 await send ( . updateWindowLocation( animated: false ) )
454- await send ( . updateWindowOpacity)
454+ await send ( . updateWindowOpacity( immediately : true ) )
455455 await windows. orderFront ( )
456456 await send ( . observeWindowChange)
457457 }
458458 }
459459 return . run { send in
460460 await send ( . updateWindowLocation( animated: false ) )
461- await send ( . updateWindowOpacity)
461+ await send ( . updateWindowOpacity( immediately : true ) )
462462 }
463463
464464 case . updateColorScheme:
@@ -549,10 +549,11 @@ public struct WidgetFeature: ReducerProtocol {
549549 }
550550 }
551551
552- case . updateWindowOpacity:
552+ case let . updateWindowOpacity( immediately ) :
553553 let isChatPanelDetached = state. chatPanelState. chatPanelInASeparateWindow
554554 let hasChat = !state. chatPanelState. chatTabGroup. tabInfo. isEmpty
555- let shouldDebounce = Date ( ) . timeIntervalSince ( state. lastUpdateWindowOpacityTime) < 1
555+ let shouldDebounce = !immediately &&
556+ Date ( ) . timeIntervalSince ( state. lastUpdateWindowOpacityTime) < 1
556557 return . run { send in
557558 if shouldDebounce {
558559 try await mainQueue. sleep ( for: . seconds( 0.2 ) )
0 commit comments