diff --git a/features/conversation-assistant/macos/Sources/ConversationAssistantApp.swift b/features/conversation-assistant/macos/Sources/ConversationAssistantApp.swift index 06fc87980..972b355b9 100644 --- a/features/conversation-assistant/macos/Sources/ConversationAssistantApp.swift +++ b/features/conversation-assistant/macos/Sources/ConversationAssistantApp.swift @@ -1,5 +1,5 @@ -import SwiftUI import AppKit +import SwiftUI @main struct ConversationAssistantApp: App { @@ -95,4 +95,8 @@ class AppDelegate: NSObject, NSApplicationDelegate { } } } + + func closePopover() { + popover?.close() + } } diff --git a/features/conversation-assistant/macos/Sources/Views/MenuBarViewModel.swift b/features/conversation-assistant/macos/Sources/Views/MenuBarViewModel.swift index 12c467cd3..3d76b516e 100644 --- a/features/conversation-assistant/macos/Sources/Views/MenuBarViewModel.swift +++ b/features/conversation-assistant/macos/Sources/Views/MenuBarViewModel.swift @@ -1,5 +1,5 @@ -import SwiftUI import Combine +import SwiftUI @MainActor class MenuBarViewModel: ObservableObject { @@ -133,7 +133,18 @@ class MenuBarViewModel: ObservableObject { } func openSettings() { - NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil) + // Close the popover first + if let appDelegate = NSApp.delegate as? AppDelegate { + appDelegate.closePopover() + } + // Activate the app (required for menu bar apps to show settings) + NSApp.activate(ignoringOtherApps: true) + // Open settings window - use the modern selector + if #available(macOS 14, *) { + NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil) + } else if #available(macOS 13, *) { + NSApp.sendAction(Selector(("showPreferencesWindow:")), to: nil, from: nil) + } } private func updateLastSyncText(_ date: Date?) {