@@ -142,13 +142,14 @@ private extension WidgetWindowsController {
142
142
await updateWidgetsAndNotifyChangeOfEditor ( immediately: false )
143
143
case . mainWindowChanged:
144
144
await updateWidgetsAndNotifyChangeOfEditor ( immediately: false )
145
- case . moved,
146
- . resized,
147
- . windowMoved,
148
- . windowResized,
149
- . windowMiniaturized,
150
- . windowDeminiaturized:
145
+ case . windowMiniaturized, . windowDeminiaturized:
151
146
await updateWidgets ( immediately: false )
147
+ case . resized,
148
+ . moved,
149
+ . windowMoved,
150
+ . windowResized:
151
+ await updateWidgets ( immediately: false )
152
+ await updateChatWindowLocation ( )
152
153
case . created, . uiElementDestroyed, . xcodeCompletionPanelChanged,
153
154
. applicationDeactivated:
154
155
continue
@@ -339,8 +340,7 @@ extension WidgetWindowsController {
339
340
340
341
// Generate a default location when no workspace is opened
341
342
private func generateDefaultLocation( ) -> WidgetLocation {
342
- let mainScreen = NSScreen . main ?? NSScreen . screens. first!
343
- let chatPanelFrame = UpdateLocationStrategy . getChatPanelFrame ( mainScreen)
343
+ let chatPanelFrame = UpdateLocationStrategy . getChatPanelFrame ( isAttachedToXcodeEnabled: false )
344
344
345
345
return WidgetLocation (
346
346
widgetFrame: . zero,
@@ -444,6 +444,18 @@ extension WidgetWindowsController {
444
444
445
445
updateWindowOpacityTask = task
446
446
}
447
+
448
+ @MainActor
449
+ func updateChatWindowLocation( ) {
450
+ let state = store. withState { $0 }
451
+ let isAttachedToXcodeEnabled = UserDefaults . shared. value ( for: \. autoAttachChatToXcode)
452
+ if isAttachedToXcodeEnabled {
453
+ if state. chatPanelState. isPanelDisplayed && !windows. chatPanelWindow. isWindowHidden {
454
+ let frame = UpdateLocationStrategy . getChatPanelFrame ( isAttachedToXcodeEnabled: isAttachedToXcodeEnabled)
455
+ windows. chatPanelWindow. setFrame ( frame, display: true , animate: true )
456
+ }
457
+ }
458
+ }
447
459
448
460
func updateWindowLocation(
449
461
animated: Bool ,
@@ -481,8 +493,11 @@ extension WidgetWindowsController {
481
493
animate: animated
482
494
)
483
495
}
484
-
485
- if isChatPanelDetached {
496
+
497
+ let isAttachedToXcodeEnabled = UserDefaults . shared. value ( for: \. autoAttachChatToXcode)
498
+ if isAttachedToXcodeEnabled {
499
+ // update in `updateChatWindowLocation`
500
+ } else if isChatPanelDetached {
486
501
// don't update it!
487
502
} else {
488
503
windows. chatPanelWindow. setFrame (
@@ -523,10 +538,10 @@ extension WidgetWindowsController {
523
538
524
539
@MainActor
525
540
func adjustChatPanelWindowLevel( ) async {
541
+ let window = windows. chatPanelWindow
542
+
526
543
let disableFloatOnTopWhenTheChatPanelIsDetached = UserDefaults . shared
527
544
. value ( for: \. disableFloatOnTopWhenTheChatPanelIsDetached)
528
-
529
- let window = windows. chatPanelWindow
530
545
guard disableFloatOnTopWhenTheChatPanelIsDetached else {
531
546
window. setFloatOnTop ( true )
532
547
return
@@ -549,7 +564,7 @@ extension WidgetWindowsController {
549
564
} else {
550
565
false
551
566
}
552
-
567
+
553
568
if !floatOnTopWhenOverlapsXcode || !latestAppIsXcodeOrExtension {
554
569
window. setFloatOnTop ( false )
555
570
} else {
0 commit comments