Skip to content
This repository was archived by the owner on Jun 18, 2025. It is now read-only.

Commit 3905f1a

Browse files
committed
Adjust always on top behavior
1 parent 8b12291 commit 3905f1a

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +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
28+
@AppStorage(\.chatPanelFloatOnTopOption) var chatPanelFloatOnTopOption
2929
@AppStorage(
3030
\.keepFloatOnTopIfChatPanelAndXcodeOverlaps
3131
) var keepFloatOnTopIfChatPanelAndXcodeOverlaps
@@ -299,20 +299,23 @@ struct ChatSettingsGeneralSectionView: View {
299299

300300
CodeHighlightThemePicker(scenario: .chat)
301301

302-
Toggle(isOn: $settings.alwaysDisableFloatOnTopForChatPanel) {
303-
Text("Always disable always-on-top.")
302+
Picker("Always-on-top behavior", selection: $settings.chatPanelFloatOnTopOption) {
303+
Text("Always").tag(UserDefaultPreferenceKeys.ChatPanelFloatOnTopOption.alwaysOnTop)
304+
Text("When Xcode is active")
305+
.tag(UserDefaultPreferenceKeys.ChatPanelFloatOnTopOption.onTopWhenXcodeIsActive)
306+
Text("Never").tag(UserDefaultPreferenceKeys.ChatPanelFloatOnTopOption.never)
304307
}
305308

306309
Toggle(isOn: $settings.disableFloatOnTopWhenTheChatPanelIsDetached) {
307310
Text("Disable always-on-top when the chat panel is detached")
308-
}.disabled(settings.alwaysDisableFloatOnTopForChatPanel)
311+
}.disabled(settings.chatPanelFloatOnTopOption == .never)
309312

310313
Toggle(isOn: $settings.keepFloatOnTopIfChatPanelAndXcodeOverlaps) {
311314
Text("Keep always-on-top if the chat panel and Xcode overlaps and Xcode is active")
312315
}
313316
.disabled(
314317
!settings.disableFloatOnTopWhenTheChatPanelIsDetached
315-
|| settings.alwaysDisableFloatOnTopForChatPanel
318+
|| settings.chatPanelFloatOnTopOption == .never
316319
)
317320
}
318321
}

Core/Sources/SuggestionWidget/WidgetWindowsController.swift

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,14 +540,14 @@ extension WidgetWindowsController {
540540

541541
@MainActor
542542
func adjustChatPanelWindowLevel() async {
543-
let alwaysDisableChatPanelFlowOnTop = UserDefaults.shared
544-
.value(for: \.alwaysDisableFloatOnTopForChatPanel)
543+
let flowOnTopOption = UserDefaults.shared
544+
.value(for: \.chatPanelFloatOnTopOption)
545545
let disableFloatOnTopWhenTheChatPanelIsDetached = UserDefaults.shared
546546
.value(for: \.disableFloatOnTopWhenTheChatPanelIsDetached)
547547

548548
let window = windows.chatPanelWindow
549549

550-
if alwaysDisableChatPanelFlowOnTop {
550+
if flowOnTopOption == .never {
551551
window.setFloatOnTop(false)
552552
return
553553
}
@@ -599,7 +599,14 @@ extension WidgetWindowsController {
599599
let overlap = await overlap
600600
window.setFloatOnTop(overlap)
601601
} else {
602-
window.setFloatOnTop(false)
602+
switch flowOnTopOption {
603+
case .onTopWhenXcodeIsActive:
604+
window.setFloatOnTop(false)
605+
case .alwaysOnTop:
606+
window.setFloatOnTop(true)
607+
case .never:
608+
window.setFloatOnTop(false)
609+
}
603610
}
604611
}
605612
}

Tool/Sources/Preferences/Keys.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,15 @@ public extension UserDefaultPreferenceKeys {
486486
var preferredChatModelIdForUtilities: PreferenceKey<String> {
487487
.init(defaultValue: "", key: "PreferredChatModelIdForUtilities")
488488
}
489+
490+
enum ChatPanelFloatOnTopOption: Int, Codable, Equatable {
491+
case alwaysOnTop
492+
case onTopWhenXcodeIsActive
493+
case never
494+
}
489495

490-
var alwaysDisableFloatOnTopForChatPanel: PreferenceKey<Bool> {
491-
.init(defaultValue: false, key: "AlwaysDisableFloatOnTopForChatPanel")
496+
var chatPanelFloatOnTopOption: PreferenceKey<ChatPanelFloatOnTopOption> {
497+
.init(defaultValue: .onTopWhenXcodeIsActive, key: "ChatPanelFloatOnTopOption")
492498
}
493499

494500
var disableFloatOnTopWhenTheChatPanelIsDetached: PreferenceKey<Bool> {

Version.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
APP_VERSION = 0.35.8
2-
APP_BUILD = 456
2+
APP_BUILD = 458
33
RELEASE_CHANNEL =
44
RELEASE_NUMBER = 1

0 commit comments

Comments
 (0)