From 0674a0ab01ed0c88312a472c23957f39fb9c7219 Mon Sep 17 00:00:00 2001 From: Lucas Motta Date: Mon, 29 Sep 2025 19:11:46 +0200 Subject: [PATCH 1/3] Fix code completion window visibility issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves intermittent visibility problems where the code completion window would not appear visually despite functioning correctly for keyboard navigation. Changes: - Replace problematic window style masks (.nonactivatingPanel, .utilityWindow) with .borderless - Set hidesOnDeactivate to false to prevent unexpected hiding - Add canHide = false and acceptsMouseMovedEvents = true for better window behavior - Improve window showing sequence in showWindow(attachedTo:) - Add proper cleanup of notification observers in close() The .nonactivatingPanel style was preventing the window from becoming key, causing the "canBecomeKeyWindow returned NO" warning and inconsistent visibility. Using .borderless provides the clean appearance needed for code completion while ensuring reliable display. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../Window/SuggestionController+Window.swift | 6 ++++-- .../CodeSuggestion/Window/SuggestionController.swift | 11 +++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Sources/CodeEditSourceEditor/CodeSuggestion/Window/SuggestionController+Window.swift b/Sources/CodeEditSourceEditor/CodeSuggestion/Window/SuggestionController+Window.swift index 48edf993c..0609ac4b3 100644 --- a/Sources/CodeEditSourceEditor/CodeSuggestion/Window/SuggestionController+Window.swift +++ b/Sources/CodeEditSourceEditor/CodeSuggestion/Window/SuggestionController+Window.swift @@ -84,7 +84,7 @@ extension SuggestionController { static func makeWindow() -> NSWindow { let window = NSWindow( contentRect: .zero, - styleMask: [.resizable, .fullSizeContentView, .nonactivatingPanel, .utilityWindow], + styleMask: [.borderless], backing: .buffered, defer: false ) @@ -97,8 +97,10 @@ extension SuggestionController { window.hasShadow = true window.isOpaque = false window.tabbingMode = .disallowed - window.hidesOnDeactivate = true + window.hidesOnDeactivate = false window.backgroundColor = .clear + window.canHide = false + window.acceptsMouseMovedEvents = true return window } diff --git a/Sources/CodeEditSourceEditor/CodeSuggestion/Window/SuggestionController.swift b/Sources/CodeEditSourceEditor/CodeSuggestion/Window/SuggestionController.swift index d8c32a51b..d5a8f2fdd 100644 --- a/Sources/CodeEditSourceEditor/CodeSuggestion/Window/SuggestionController.swift +++ b/Sources/CodeEditSourceEditor/CodeSuggestion/Window/SuggestionController.swift @@ -103,7 +103,10 @@ public final class SuggestionController: NSWindowController { /// Opens the window as a child of another window. public func showWindow(attachedTo parentWindow: NSWindow) { guard let window = window else { return } + + super.showWindow(nil) parentWindow.addChildWindow(window, ordered: .above) + window.orderFront(nil) // Close on window switch observer // Initialized outside of `setupEventMonitors` in order to grab the parent window @@ -118,8 +121,6 @@ public final class SuggestionController: NSWindowController { self?.close() } - super.showWindow(nil) - window.orderFront(nil) window.contentViewController?.viewWillAppear() } @@ -134,6 +135,12 @@ public final class SuggestionController: NSWindowController { contentViewController?.viewWillDisappear() } + // Clean up window observers + if let observer = windowResignObserver { + NotificationCenter.default.removeObserver(observer) + windowResignObserver = nil + } + super.close() } From 515b7a14979d3bf75322f5aa968341eb807c69db Mon Sep 17 00:00:00 2001 From: Lucas Motta Date: Mon, 29 Sep 2025 19:20:07 +0200 Subject: [PATCH 2/3] Fix remaining canBecomeKeyWindow warnings in BezelNotification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removes .nonactivatingPanel from BezelNotification window style mask to eliminate console warnings while maintaining non-activating behavior through .hudWindow style. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../SupportingViews/BezelNotification.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/CodeEditSourceEditor/SupportingViews/BezelNotification.swift b/Sources/CodeEditSourceEditor/SupportingViews/BezelNotification.swift index cf71c2fbd..5a8a742f6 100644 --- a/Sources/CodeEditSourceEditor/SupportingViews/BezelNotification.swift +++ b/Sources/CodeEditSourceEditor/SupportingViews/BezelNotification.swift @@ -51,7 +51,7 @@ final class BezelNotification { let window = NSPanel( contentRect: .zero, - styleMask: [.borderless, .nonactivatingPanel, .hudWindow], + styleMask: [.borderless, .hudWindow], backing: .buffered, defer: true ) From 9332e064cf0681ae9549eb876638b3b4b11a77b2 Mon Sep 17 00:00:00 2001 From: Lucas Motta Date: Mon, 29 Sep 2025 19:22:44 +0200 Subject: [PATCH 3/3] Revert "Fix remaining canBecomeKeyWindow warnings in BezelNotification" This reverts commit 515b7a14979d3bf75322f5aa968341eb807c69db. --- .../SupportingViews/BezelNotification.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/CodeEditSourceEditor/SupportingViews/BezelNotification.swift b/Sources/CodeEditSourceEditor/SupportingViews/BezelNotification.swift index 5a8a742f6..cf71c2fbd 100644 --- a/Sources/CodeEditSourceEditor/SupportingViews/BezelNotification.swift +++ b/Sources/CodeEditSourceEditor/SupportingViews/BezelNotification.swift @@ -51,7 +51,7 @@ final class BezelNotification { let window = NSPanel( contentRect: .zero, - styleMask: [.borderless, .hudWindow], + styleMask: [.borderless, .nonactivatingPanel, .hudWindow], backing: .buffered, defer: true )