Skip to content

Commit 7b9f419

Browse files
committed
Update the switch activationPolicy logic
1 parent 1643f92 commit 7b9f419

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Core/Sources/SuggestionWidget/SuggestionWidgetController.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,19 +219,22 @@ public final class SuggestionWidgetController {
219219
}
220220

221221
Task { @MainActor in
222-
suggestionPanelViewModel.onActiveTabChanged = { [weak self] activeTab in
222+
suggestionPanelViewModel.onActiveTabChanged = { activeTab in
223223
#warning("""
224224
TODO: There should be a better way for that
225225
Currently, we have to make the app an accessory so that we can type things in the chat mode.
226226
But in other modes, we want to keep it prohibited so the helper app won't take over the focus.
227227
""")
228-
if case .chat = activeTab, NSApp.activationPolicy() != .accessory {
229-
NSApp.setActivationPolicy(.accessory)
230-
} else if NSApp.activationPolicy() != .prohibited {
228+
switch activeTab {
229+
case .suggestion:
230+
guard NSApp.activationPolicy() != .prohibited else { return }
231231
Task {
232232
try await Environment.makeXcodeActive()
233233
NSApp.setActivationPolicy(.prohibited)
234234
}
235+
case .chat:
236+
guard NSApp.activationPolicy() != .accessory else { return }
237+
NSApp.setActivationPolicy(.accessory)
235238
}
236239
}
237240
}

0 commit comments

Comments
 (0)