@@ -71,6 +71,8 @@ public struct ChatPanelFeature: ReducerProtocol {
7171 case createNewTapButtonClicked( kind: ChatTabKind ? )
7272 case tabClicked( id: String )
7373 case appendAndSelectTab( BaseChatTab )
74+ case switchToNextTab
75+ case switchToPreviousTab
7476 }
7577
7678 @Dependency ( \. suggestionWidgetControllerDependency) var suggestionWidgetControllerDependency
@@ -146,7 +148,7 @@ public struct ChatPanelFeature: ReducerProtocol {
146148 state. isPanelDisplayed = false
147149 }
148150 return . none
149-
151+
150152 case . createNewTapButtonHovered:
151153 state. chatTapGroup. tabCollection = chatTabBuilderCollection ( )
152154 return . none
@@ -168,6 +170,32 @@ public struct ChatPanelFeature: ReducerProtocol {
168170 state. chatTapGroup. tabs. append ( tab)
169171 state. chatTapGroup. selectedTabId = tab. id
170172 return . none
173+
174+ case . switchToNextTab:
175+ let selectedId = state. chatTapGroup. selectedTabId
176+ guard let index = state. chatTapGroup. tabInfo
177+ . firstIndex ( where: { $0. id == selectedId } )
178+ else { return . none }
179+ let nextIndex = index + 1
180+ if nextIndex >= state. chatTapGroup. tabInfo. endIndex {
181+ return . none
182+ }
183+ let targetId = state. chatTapGroup. tabInfo [ nextIndex] . id
184+ state. chatTapGroup. selectedTabId = targetId
185+ return . none
186+
187+ case . switchToPreviousTab:
188+ let selectedId = state. chatTapGroup. selectedTabId
189+ guard let index = state. chatTapGroup. tabInfo
190+ . firstIndex ( where: { $0. id == selectedId } )
191+ else { return . none }
192+ let previousIndex = index - 1
193+ if previousIndex < 0 || previousIndex >= state. chatTapGroup. tabInfo. endIndex {
194+ return . none
195+ }
196+ let targetId = state. chatTapGroup. tabInfo [ previousIndex] . id
197+ state. chatTapGroup. selectedTabId = targetId
198+ return . none
171199 }
172200 }
173201 }
0 commit comments