@@ -49,6 +49,7 @@ public struct ChatPanelFeature: ReducerProtocol {
4949 var colorScheme : ColorScheme = . light
5050 public internal( set) var isPanelDisplayed = false
5151 var chatPanelInASeparateWindow = false
52+ var isFullScreen = false
5253 }
5354
5455 public enum Action : Equatable {
@@ -58,6 +59,8 @@ public struct ChatPanelFeature: ReducerProtocol {
5859 case toggleChatPanelDetachedButtonClicked
5960 case detachChatPanel
6061 case attachChatPanel
62+ case enterFullScreen
63+ case exitFullScreen
6164 case presentChatPanel( forceDetach: Bool )
6265
6366 // Tabs
@@ -81,12 +84,25 @@ public struct ChatPanelFeature: ReducerProtocol {
8184 @Dependency ( \. activateThisApp) var activateExtensionService
8285 @Dependency ( \. chatTabBuilderCollection) var chatTabBuilderCollection
8386
87+ @MainActor func toggleFullScreen( ) {
88+ let window = suggestionWidgetControllerDependency. windows
89+ . chatPanelWindow
90+ window? . toggleFullScreen ( nil )
91+ }
92+
8493 public var body : some ReducerProtocol < State , Action > {
8594 Reduce { state, action in
8695 switch action {
8796 case . hideButtonClicked:
8897 state. isPanelDisplayed = false
8998
99+ if state. isFullScreen {
100+ return . run { _ in
101+ await MainActor . run { toggleFullScreen ( ) }
102+ activatePreviouslyActiveXcode ( )
103+ }
104+ }
105+
90106 return . run { _ in
91107 activatePreviouslyActiveXcode ( )
92108 }
@@ -102,17 +118,42 @@ public struct ChatPanelFeature: ReducerProtocol {
102118 return . none
103119
104120 case . toggleChatPanelDetachedButtonClicked:
105- state. chatPanelInASeparateWindow. toggle ( )
106- return . none
121+ if state. chatPanelInASeparateWindow {
122+ return . run { send in
123+ await send ( . attachChatPanel)
124+ }
125+ } else {
126+ return . run { send in
127+ await send ( . detachChatPanel)
128+ }
129+ }
107130
108131 case . detachChatPanel:
109132 state. chatPanelInASeparateWindow = true
110133 return . none
111134
112135 case . attachChatPanel:
136+ if state. isFullScreen {
137+ return . run { send in
138+ await MainActor . run { toggleFullScreen ( ) }
139+ try await Task . sleep ( nanoseconds: 1_000_000_000 )
140+ await send ( . attachChatPanel)
141+ }
142+ }
143+
113144 state. chatPanelInASeparateWindow = false
114145 return . none
115146
147+ case . enterFullScreen:
148+ state. isFullScreen = true
149+ return . run { send in
150+ await send ( . detachChatPanel)
151+ }
152+
153+ case . exitFullScreen:
154+ state. isFullScreen = false
155+ return . none
156+
116157 case let . presentChatPanel( forceDetach) :
117158 if forceDetach {
118159 state. chatPanelInASeparateWindow = true
@@ -227,7 +268,7 @@ public struct ChatPanelFeature: ReducerProtocol {
227268 state. chatTabGroup. tabInfo. remove ( at: from)
228269 state. chatTabGroup. tabInfo. insert ( tab, at: to)
229270 return . none
230-
271+
231272 case . focusActiveChatTab:
232273 let id = state. chatTabGroup. selectedTabInfo? . id
233274 guard let id else { return . none }
@@ -239,7 +280,7 @@ public struct ChatPanelFeature: ReducerProtocol {
239280 return . run { send in
240281 await send ( . closeTabButtonClicked( id: id) )
241282 }
242-
283+
243284 case . chatTab:
244285 return . none
245286 }
0 commit comments