@@ -114,6 +114,7 @@ private extension WidgetWindowsController {
114114 await hideSuggestionPanelWindow()
115115 }
116116 await adjustChatPanelWindowLevel()
117+ await adjustModificationPanelLevel()
117118 }
118119 guard currentApplicationProcessIdentifier != app.processIdentifier else { return }
119120 currentApplicationProcessIdentifier = app.processIdentifier
@@ -395,7 +396,7 @@ extension WidgetWindowsController {
395396 let application = activeApp. appElement
396397 /// We need this to hide the windows when Xcode is minimized.
397398 let noFocus = application. focusedWindow == nil
398- windows. sharedPanelWindow. alphaValue = noFocus ? 0 : 1
399+ windows. sharedPanelWindow. alphaValue = 1
399400 windows. suggestionPanelWindow. alphaValue = noFocus ? 0 : 1
400401 windows. widgetWindow. alphaValue = noFocus ? 0 : 1
401402 windows. toastWindow. alphaValue = noFocus ? 0 : 1
@@ -418,7 +419,7 @@ extension WidgetWindowsController {
418419
419420 let previousAppIsXcode = previousActiveApplication? . isXcode ?? false
420421
421- windows. sharedPanelWindow. alphaValue = noFocus ? 0 : 1
422+ windows. sharedPanelWindow. alphaValue = 1
422423 windows. suggestionPanelWindow. alphaValue = noFocus ? 0 : 1
423424 windows. widgetWindow. alphaValue = if noFocus {
424425 0
@@ -441,7 +442,7 @@ extension WidgetWindowsController {
441442 . chatPanelWindow. isKeyWindow
442443 }
443444 } else {
444- windows. sharedPanelWindow. alphaValue = 0
445+ windows. sharedPanelWindow. alphaValue = 1
445446 windows. suggestionPanelWindow. alphaValue = 0
446447 windows. widgetWindow. alphaValue = 0
447448 windows. toastWindow. alphaValue = 0
@@ -503,6 +504,7 @@ extension WidgetWindowsController {
503504 }
504505
505506 await adjustChatPanelWindowLevel ( )
507+ await adjustModificationPanelLevel ( )
506508 }
507509
508510 let now = Date ( )
@@ -531,6 +533,20 @@ extension WidgetWindowsController {
531533 lastUpdateWindowLocationTime = Date ( )
532534 }
533535
536+ @MainActor
537+ func adjustModificationPanelLevel( ) async {
538+ let window = windows. sharedPanelWindow
539+
540+ let latestApp = await xcodeInspector. safe. activeApplication
541+ let latestAppIsXcodeOrExtension = if let latestApp {
542+ latestApp. isXcode || latestApp. isExtensionService
543+ } else {
544+ false
545+ }
546+
547+ window. setFloatOnTop ( latestAppIsXcodeOrExtension)
548+ }
549+
534550 @MainActor
535551 func adjustChatPanelWindowLevel( ) async {
536552 let alwaysDisableChatPanelFlowOnTop = UserDefaults . shared
@@ -539,12 +555,12 @@ extension WidgetWindowsController {
539555 . value ( for: \. disableFloatOnTopWhenTheChatPanelIsDetached)
540556
541557 let window = windows. chatPanelWindow
542-
558+
543559 if alwaysDisableChatPanelFlowOnTop {
544560 window. setFloatOnTop ( false )
545561 return
546562 }
547-
563+
548564 guard disableFloatOnTopWhenTheChatPanelIsDetached else {
549565 window. setFloatOnTop ( true )
550566 return
@@ -884,6 +900,16 @@ class WidgetWindow: CanBecomeKeyWindow {
884900 self . state = previousState
885901 }
886902 }
903+
904+ func setFloatOnTop( _ isFloatOnTop: Bool ) {
905+ let targetLevel : NSWindow . Level = isFloatOnTop
906+ ? . init( NSWindow . Level. floating. rawValue + 1 )
907+ : . normal
908+
909+ if targetLevel != level {
910+ level = targetLevel
911+ }
912+ }
887913}
888914
889915func widgetLevel( _ addition: Int ) -> NSWindow . Level {
0 commit comments