Skip to content

Commit 031c5b1

Browse files
committed
Add a workaround to temporarily turn on accessory mode for chat
1 parent 0eb92ef commit 031c5b1

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Core/Sources/SuggestionWidget/SuggestionPanelView.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,20 @@ final class SuggestionPanelViewModel: ObservableObject {
2323
case error(String)
2424
}
2525

26-
@Published var content: Content
26+
@Published var content: Content {
27+
didSet {
28+
#warning("""
29+
TODO: There should be a better way for that
30+
Currently, we have to make the app an accessory so that we can type things in the chat mode.
31+
But in other modes, we want to keep it prohibited so the helper app won't take over the focus.
32+
""")
33+
if case .chat = content {
34+
NSApp.setActivationPolicy(.accessory)
35+
} else {
36+
NSApp.setActivationPolicy(.prohibited)
37+
}
38+
}
39+
}
2740
@Published var isPanelDisplayed: Bool
2841
@Published var alignTopToAnchor = false
2942
@Published var colorScheme: ColorScheme

ExtensionService/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
3030
setupQuitOnUserTerminated()
3131
xpcListener = setupXPCListener()
3232
Logger.service.info("XPC Service started.")
33-
NSApp.setActivationPolicy(.accessory)
33+
NSApp.setActivationPolicy(.prohibited)
3434
buildStatusBarMenu()
3535
checkForUpdate()
3636
}

0 commit comments

Comments
 (0)