Skip to content

Commit 87cae85

Browse files
committed
Support disabling chat panel always on top
1 parent 519cce1 commit 87cae85

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

Core/Sources/HostApp/FeatureSettings/Chat/ChatSettingsGeneralSectionView.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct ChatSettingsGeneralSectionView: View {
2525
@AppStorage(\.chatModels) var chatModels
2626
@AppStorage(\.embeddingModels) var embeddingModels
2727
@AppStorage(\.wrapCodeInChatCodeBlock) var wrapCodeInCodeBlock
28+
@AppStorage(\.alwaysDisableFloatOnTopForChatPanel) var alwaysDisableFloatOnTopForChatPanel
2829
@AppStorage(
2930
\.keepFloatOnTopIfChatPanelAndXcodeOverlaps
3031
) var keepFloatOnTopIfChatPanelAndXcodeOverlaps
@@ -298,13 +299,21 @@ struct ChatSettingsGeneralSectionView: View {
298299

299300
CodeHighlightThemePicker(scenario: .chat)
300301

302+
Toggle(isOn: $settings.alwaysDisableFloatOnTopForChatPanel) {
303+
Text("Always disable always-on-top.")
304+
}
305+
301306
Toggle(isOn: $settings.disableFloatOnTopWhenTheChatPanelIsDetached) {
302307
Text("Disable always-on-top when the chat panel is detached")
303-
}
308+
}.disabled(settings.alwaysDisableFloatOnTopForChatPanel)
304309

305310
Toggle(isOn: $settings.keepFloatOnTopIfChatPanelAndXcodeOverlaps) {
306311
Text("Keep always-on-top if the chat panel and Xcode overlaps and Xcode is active")
307-
}.disabled(!settings.disableFloatOnTopWhenTheChatPanelIsDetached)
312+
}
313+
.disabled(
314+
!settings.disableFloatOnTopWhenTheChatPanelIsDetached
315+
|| settings.alwaysDisableFloatOnTopForChatPanel
316+
)
308317
}
309318
}
310319

Core/Sources/SuggestionWidget/ChatPanelWindow.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ final class ChatPanelWindow: WidgetWindow {
2020
override var defaultCollectionBehavior: NSWindow.CollectionBehavior {
2121
[
2222
.fullScreenAuxiliary,
23-
.transient,
2423
.fullScreenPrimary,
2524
.fullScreenAllowsTiling,
25+
.participatesInCycle
2626
]
2727
}
2828

Core/Sources/SuggestionWidget/WidgetWindowsController.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,18 @@ extension WidgetWindowsController {
533533

534534
@MainActor
535535
func adjustChatPanelWindowLevel() async {
536+
let alwaysDisableChatPanelFlowOnTop = UserDefaults.shared
537+
.value(for: \.alwaysDisableFloatOnTopForChatPanel)
536538
let disableFloatOnTopWhenTheChatPanelIsDetached = UserDefaults.shared
537539
.value(for: \.disableFloatOnTopWhenTheChatPanelIsDetached)
538540

539541
let window = windows.chatPanelWindow
542+
543+
if alwaysDisableChatPanelFlowOnTop {
544+
window.setFloatOnTop(false)
545+
return
546+
}
547+
540548
guard disableFloatOnTopWhenTheChatPanelIsDetached else {
541549
window.setFloatOnTop(true)
542550
return
@@ -587,7 +595,7 @@ extension WidgetWindowsController {
587595
let activeXcode = await XcodeInspector.shared.safe.activeXcode
588596

589597
let xcode = activeXcode?.appElement
590-
598+
591599
let isXcodeActive = xcode?.isFrontmost ?? false
592600

593601
[
@@ -600,7 +608,7 @@ extension WidgetWindowsController {
600608
$0.moveToActiveSpace()
601609
}
602610
}
603-
611+
604612
if isXcodeActive, !windows.chatPanelWindow.isDetached {
605613
windows.chatPanelWindow.moveToActiveSpace()
606614
}
@@ -867,7 +875,7 @@ class WidgetWindow: CanBecomeKeyWindow {
867875
}
868876
}
869877
}
870-
878+
871879
func moveToActiveSpace() {
872880
let previousState = state
873881
state = .switchingSpace

Tool/Sources/Preferences/Keys.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,11 @@ public extension UserDefaultPreferenceKeys {
195195
var gitHubCopilotPretendIDEToBeVSCode: PreferenceKey<Bool> {
196196
.init(defaultValue: false, key: "GitHubCopilotPretendIDEToBeVSCode")
197197
}
198-
198+
199199
var gitHubCopilotModelId: PreferenceKey<String> {
200200
.init(defaultValue: "", key: "GitHubCopilotModelId")
201201
}
202-
202+
203203
var gitHubCopilotModelFamily: PreferenceKey<String> {
204204
.init(defaultValue: "", key: "GitHubCopilotModelFamily")
205205
}
@@ -478,11 +478,15 @@ public extension UserDefaultPreferenceKeys {
478478
var preferredChatModelIdForWebScope: PreferenceKey<String> {
479479
.init(defaultValue: "", key: "PreferredChatModelIdForWebScope")
480480
}
481-
481+
482482
var preferredChatModelIdForUtilities: PreferenceKey<String> {
483483
.init(defaultValue: "", key: "PreferredChatModelIdForUtilities")
484484
}
485485

486+
var alwaysDisableFloatOnTopForChatPanel: PreferenceKey<Bool> {
487+
.init(defaultValue: false, key: "AlwaysDisableFloatOnTopForChatPanel")
488+
}
489+
486490
var disableFloatOnTopWhenTheChatPanelIsDetached: PreferenceKey<Bool> {
487491
.init(defaultValue: true, key: "DisableFloatOnTopWhenTheChatPanelIsDetached")
488492
}
@@ -494,7 +498,7 @@ public extension UserDefaultPreferenceKeys {
494498
var openChatMode: PreferenceKey<UserDefaultsStorageBox<OpenChatMode>> {
495499
.init(defaultValue: .init(.chatPanel), key: "DefaultOpenChatMode")
496500
}
497-
501+
498502
var legacyOpenChatMode: DeprecatedPreferenceKey<OpenChatMode.LegacyOpenChatMode> {
499503
.init(defaultValue: .chatPanel, key: "OpenChatMode")
500504
}
@@ -731,7 +735,7 @@ public extension UserDefaultPreferenceKeys {
731735
var useCloudflareDomainNameForLicenseCheck: FeatureFlag {
732736
.init(defaultValue: false, key: "FeatureFlag-UseCloudflareDomainNameForLicenseCheck")
733737
}
734-
738+
735739
var doNotInstallLaunchAgentAutomatically: FeatureFlag {
736740
.init(defaultValue: false, key: "FeatureFlag-DoNotInstallLaunchAgentAutomatically")
737741
}

0 commit comments

Comments
 (0)