File tree Expand file tree Collapse file tree 3 files changed +31
-8
lines changed
SuggestionWidget/FeatureReducers Expand file tree Collapse file tree 3 files changed +31
-8
lines changed Original file line number Diff line number Diff line change @@ -55,8 +55,8 @@ struct GUI: ReducerProtocol {
5555 case openChatPanel( forceDetach: Bool )
5656 case createChatGPTChatTabIfNeeded
5757 case sendCustomCommandToActiveChat( CustomCommand )
58- case toggleWidgets
59-
58+ case toggleWidgetsHotkeyPressed
59+
6060 case suggestionWidget( WidgetFeature . Action )
6161
6262 static func promptToCodeGroup( _ action: PromptToCodeGroup . Action ) -> Self {
@@ -194,11 +194,18 @@ struct GUI: ReducerProtocol {
194194 }
195195 }
196196
197- case . toggleWidgets:
197+ case . toggleWidgetsHotkeyPressed:
198+ let hasChat = state. chatTabGroup. selectedTabInfo != nil
199+ let hasPromptToCode = state. promptToCodeGroup. activePromptToCode != nil
200+
198201 return . run { send in
199- await send (
200- . suggestionWidget( . circularWidget( . widgetClicked) )
201- )
202+ await send ( . suggestionWidget( . circularWidget( . widgetClicked) ) )
203+
204+ if hasPromptToCode {
205+ await send ( . suggestionWidget( . updateKeyWindow( . sharedPanel) ) )
206+ } else if hasChat {
207+ await send ( . suggestionWidget( . updateKeyWindow( . chatPanel) ) )
208+ }
202209 }
203210
204211 case let . suggestionWidget( . chatPanel( . chatTab( id, . tabContentUpdated) ) ) :
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ final class GlobalShortcutManager {
3131 {
3232 guiController. viewStore. send ( . openChatPanel( forceDetach: true ) )
3333 } else {
34- guiController. viewStore. send ( . toggleWidgets )
34+ guiController. viewStore. send ( . toggleWidgetsHotkeyPressed )
3535 }
3636
3737 if !isExtensionActive {
Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ public struct WidgetFeature: ReducerProtocol {
2121 public var sharedPanelWindowState = WindowState ( )
2222 public var tabWindowState = WindowState ( )
2323 }
24+
25+ public enum WindowCanBecomeKey : Equatable {
26+ case sharedPanel
27+ case chatPanel
28+ }
2429
2530 public struct State : Equatable {
2631 var focusingDocumentURL : URL ?
@@ -112,6 +117,7 @@ public struct WidgetFeature: ReducerProtocol {
112117 case updateWindowOpacity
113118 case updateFocusingDocumentURL
114119 case updateWindowOpacityFinished
120+ case updateKeyWindow( WindowCanBecomeKey )
115121
116122 case panel( PanelFeature . Action )
117123 case chatPanel( ChatPanelFeature . Action )
@@ -578,11 +584,21 @@ public struct WidgetFeature: ReducerProtocol {
578584 await send ( . updateWindowOpacityFinished)
579585 }
580586 . cancellable ( id: DebounceKey . updateWindowOpacity, cancelInFlight: true )
581-
587+
582588 case . updateWindowOpacityFinished:
583589 state. lastUpdateWindowOpacityTime = Date ( )
584590 return . none
585591
592+ case let . updateKeyWindow( window) :
593+ return . run { _ in
594+ switch window {
595+ case . chatPanel:
596+ await windows. chatPanelWindow. makeKeyAndOrderFront ( nil )
597+ case . sharedPanel:
598+ await windows. sharedPanelWindow. makeKeyAndOrderFront ( nil )
599+ }
600+ }
601+
586602 case . circularWidget:
587603 return . none
588604
You can’t perform that action at this time.
0 commit comments