File tree Expand file tree Collapse file tree 4 files changed +38
-31
lines changed
Expand file tree Collapse file tree 4 files changed +38
-31
lines changed Original file line number Diff line number Diff line change @@ -7,15 +7,21 @@ struct ChatContextMenu: View {
77 @AppStorage ( \. customCommands) var customCommands
88
99 var body : some View {
10- Group {
11- currentSystemPrompt
12- currentExtraSystemPrompt
13- resetPrompt
10+ Text ( chat. title)
11+ . contextMenu {
12+ menu
13+ }
14+ }
15+
16+ @ViewBuilder
17+ var menu : some View {
18+ currentSystemPrompt
19+ currentExtraSystemPrompt
20+ resetPrompt
1421
15- Divider ( )
22+ Divider ( )
1623
17- customCommandMenu
18- }
24+ customCommandMenu
1925 }
2026
2127 @ViewBuilder
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ public class ChatGPTChatTab: ChatTab {
4141 ChatPanel ( chat: provider)
4242 }
4343
44- public func buildMenu ( ) -> any View {
44+ public func buildTabItem ( ) -> any View {
4545 ChatContextMenu ( chat: provider)
4646 }
4747
Original file line number Diff line number Diff line change @@ -175,18 +175,16 @@ struct ChatTabBar: View {
175175 ScrollView ( . horizontal) {
176176 HStack ( spacing: 0 ) {
177177 ForEach ( viewStore. state. tabInfo, id: \. id) { info in
178- ChatTabBarButton (
179- store: store,
180- info: info,
181- isSelected: info. id == viewStore. state. selectedTabId
182- )
183- . id ( info. id)
184- . contextMenu {
185- if let tab = chatTabPool. getTab ( of: info. id) {
186- tab. menu
187- } else {
188- EmptyView ( )
189- }
178+ if let tab = chatTabPool. getTab ( of: info. id) {
179+ ChatTabBarButton (
180+ store: store,
181+ info: info,
182+ content: { tab. tabItem } ,
183+ isSelected: info. id == viewStore. state. selectedTabId
184+ )
185+ . id ( info. id)
186+ } else {
187+ EmptyView ( )
190188 }
191189 }
192190 }
@@ -263,9 +261,10 @@ struct ChatTabBar: View {
263261 }
264262}
265263
266- struct ChatTabBarButton : View {
264+ struct ChatTabBarButton < Content : View > : View {
267265 let store : StoreOf < ChatPanelFeature >
268266 let info : ChatTabInfo
267+ let content : ( ) -> Content
269268 let isSelected : Bool
270269 @State var isHovered : Bool = false
271270
@@ -274,7 +273,7 @@ struct ChatTabBarButton: View {
274273 Button ( action: {
275274 store. send ( . tabClicked( id: info. id) )
276275 } ) {
277- Text ( info . title )
276+ content ( )
278277 . font ( . callout)
279278 . lineLimit ( 1 )
280279 . frame ( maxWidth: 120 )
@@ -372,10 +371,12 @@ class FakeChatTab: ChatTab {
372371 }
373372 }
374373
375- func buildMenu( ) -> any View {
376- Text ( " Menu Item " )
377- Text ( " Menu Item " )
378- Text ( " Menu Item " )
374+ func buildTabItem( ) -> any View {
375+ Text ( " Fake " )
376+ . contextMenu {
377+ Text ( " Menu Item " )
378+ Text ( " Menu Item " )
379+ }
379380 }
380381
381382 func buildView( ) -> any View {
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ public protocol ChatTabType {
2525 func buildView( ) -> any View
2626 /// Build the menu for this chat tab.
2727 @ViewBuilder
28- func buildMenu ( ) -> any View
28+ func buildTabItem ( ) -> any View
2929 /// The name of this chat tab type.
3030 static var name : String { get }
3131 /// Available builders for this chat tab.
@@ -84,10 +84,10 @@ open class BaseChatTab {
8484
8585 /// The menu for this chat tab.
8686 @ViewBuilder
87- public var menu : some View {
87+ public var tabItem : some View {
8888 let id = " ChatTabMenu \( id) "
8989 if let tab = self as? ( any ChatTabType ) {
90- ContentView ( buildView: tab. buildMenu ) . id ( id)
90+ ContentView ( buildView: tab. buildTabItem ) . id ( id)
9191 . onAppear {
9292 Task { @MainActor in self . startIfNotStarted ( ) }
9393 }
@@ -162,8 +162,8 @@ public class EmptyChatTab: ChatTab {
162162 . background ( Color . blue)
163163 }
164164
165- public func buildMenu ( ) -> any View {
166- EmptyView ( )
165+ public func buildTabItem ( ) -> any View {
166+ Text ( " Empty- \( id ) " )
167167 }
168168
169169 public func restorableState( ) async -> Data {
You can’t perform that action at this time.
0 commit comments