Skip to content

Commit 2bb0a70

Browse files
committed
Do not hide modification panel, instead change the level
1 parent 87cae85 commit 2bb0a70

2 files changed

Lines changed: 31 additions & 15 deletions

File tree

Core/Sources/SuggestionWidget/ChatPanelWindow.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,6 @@ final class ChatPanelWindow: WidgetWindow {
9090
center()
9191
}
9292

93-
func setFloatOnTop(_ isFloatOnTop: Bool) {
94-
let targetLevel: NSWindow.Level = isFloatOnTop
95-
? .init(NSWindow.Level.floating.rawValue + 1)
96-
: .normal
97-
98-
if targetLevel != level {
99-
level = targetLevel
100-
}
101-
}
102-
10393
var isWindowHidden: Bool = false {
10494
didSet {
10595
alphaValue = isPanelDisplayed && !isWindowHidden ? 1 : 0

Core/Sources/SuggestionWidget/WidgetWindowsController.swift

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

889915
func widgetLevel(_ addition: Int) -> NSWindow.Level {

0 commit comments

Comments
 (0)