@@ -476,25 +476,37 @@ extension SuggestionWidgetController {
476476 editor: focusElement
477477 )
478478 }
479- } else if let window = application. focusedWindow,
480- ![ " open_quickly " ] . contains ( window. identifier) ,
479+ } else if var window = application. focusedWindow,
481480 var frame = application. focusedWindow? . rect,
482481 frame. size. height > 200 ,
483482 let screen = NSScreen . screens. first ( where: { $0. frame. origin == . zero } ) ,
484483 let firstScreen = NSScreen . main
485484 {
485+ if [ " open_quickly " ] . contains ( window. identifier) {
486+ // fallback to use workspace window
487+ guard let workspaceWindow = application. windows
488+ . first ( where: { $0. identifier == " Xcode.WorkspaceWindow " } ) ,
489+ let rect = workspaceWindow. rect
490+ else { return ( . zero, . zero, . zero, false ) }
491+
492+ window = workspaceWindow
493+ frame = rect
494+ }
495+
486496 if [ " Xcode.WorkspaceWindow " ] . contains ( window. identifier) {
497+ // extra padding to bottom so buttons won't be covered
487498 frame. size. height -= 40
488499 } else {
500+ // move a bit away from the window so buttons won't be covered
489501 frame. origin. x -= Style . widgetPadding + Style. widgetWidth / 2
490502 frame. size. width += Style . widgetPadding * 2 + Style. widgetWidth
491503 }
492-
504+
493505 return UpdateLocationStrategy . FixedToBottom ( ) . framesForWindows (
494506 editorFrame: frame,
495507 mainScreen: screen,
496508 activeScreen: firstScreen,
497- preferredInsideEditorMinWidth: 9_999_999_999
509+ preferredInsideEditorMinWidth: 9_999_999_999 // never
498510 )
499511 }
500512 }
@@ -506,10 +518,10 @@ extension SuggestionWidgetController {
506518 suggestionPanelViewModel. alignTopToAnchor = widgetFrames. alignPanelTopToAnchor
507519 if detachChat {
508520 if chatWindow. alphaValue == 0 {
509- chatWindow. setFrame ( panelWindow. frame, display: false , animate: false )
521+ chatWindow. setFrame ( panelWindow. frame, display: false , animate: animated )
510522 }
511523 } else {
512- chatWindow. setFrame ( panelWindow. frame, display: false , animate: false )
524+ chatWindow. setFrame ( panelWindow. frame, display: false , animate: animated )
513525 }
514526 }
515527
@@ -525,6 +537,24 @@ extension SuggestionWidgetController {
525537 } else {
526538 chatWindow. alphaValue = noFocus ? 0 : 1
527539 }
540+ } else if let app = ActiveApplicationMonitor . activeApplication,
541+ app. bundleIdentifier == Bundle . main. bundleIdentifier
542+ {
543+ let noFocus = {
544+ guard let xcode = ActiveApplicationMonitor . latestXcode else { return true }
545+ let application = AXUIElementCreateApplication ( app. processIdentifier)
546+ return application
547+ . focusedWindow == nil || ( application. focusedWindow? . role == " AXWindow " )
548+ } ( )
549+
550+ panelWindow. alphaValue = noFocus ? 0 : 1
551+ widgetWindow. alphaValue = noFocus ? 0 : 1
552+ tabWindow. alphaValue = noFocus ? 0 : 1
553+ if detachChat {
554+ chatWindow. alphaValue = chatWindowViewModel. chat != nil ? 1 : 0
555+ } else {
556+ chatWindow. alphaValue = noFocus && !chatWindow. isKeyWindow ? 0 : 1
557+ }
528558 } else {
529559 panelWindow. alphaValue = 0
530560 widgetWindow. alphaValue = 0
0 commit comments