@@ -182,6 +182,9 @@ struct ChatTabBar: View {
182182 content: { tab. tabItem } ,
183183 isSelected: info. id == viewStore. state. selectedTabId
184184 )
185+ . contextMenu {
186+ tab. menu
187+ }
185188 . id ( info. id)
186189 } else {
187190 EmptyView ( )
@@ -359,62 +362,8 @@ struct CreateOtherChatTabMenuStyle: MenuStyle {
359362 }
360363}
361364
362- class FakeChatTab : ChatTab {
363- static var name : String { " Fake " }
364- static func chatBuilders( externalDependency: Void ) -> [ ChatTabBuilder ] { [ Builder ( ) ] }
365-
366- struct Builder : ChatTabBuilder {
367- var title : String = " Title "
368-
369- func build( store: StoreOf < ChatTabItem > ) async -> ( any ChatTab ) ? {
370- return FakeChatTab ( store: store)
371- }
372- }
373-
374- func buildTabItem( ) -> any View {
375- Text ( " Fake " )
376- . contextMenu {
377- Text ( " Menu Item " )
378- Text ( " Menu Item " )
379- }
380- }
381-
382- func buildView( ) -> any View {
383- ChatPanel (
384- chat: . init(
385- history: [
386- . init( id: " 1 " , role: . assistant, text: " Hello World " ) ,
387- ] ,
388- isReceivingMessage: false
389- ) ,
390- typedMessage: " Hello World! "
391- )
392- }
393-
394- func restorableState( ) async -> Data {
395- return Data ( )
396- }
397-
398- static func restore(
399- from data: Data ,
400- externalDependency: ( )
401- ) async throws -> any ChatTabBuilder {
402- return Builder ( )
403- }
404-
405- convenience init ( id: String , title: String ) {
406- self . init ( store: . init(
407- initialState: . init( id: id, title: title) ,
408- reducer: ChatTabItem ( )
409- ) )
410- }
411-
412- func start( ) { }
413- }
414-
415365struct ChatWindowView_Previews : PreviewProvider {
416366 static let pool = ChatTabPool ( [
417- " 1 " : FakeChatTab ( id: " 1 " , title: " Hello I am a chatbot " ) ,
418367 " 2 " : EmptyChatTab ( id: " 2 " ) ,
419368 " 3 " : EmptyChatTab ( id: " 3 " ) ,
420369 " 4 " : EmptyChatTab ( id: " 4 " ) ,
@@ -423,30 +372,31 @@ struct ChatWindowView_Previews: PreviewProvider {
423372 " 7 " : EmptyChatTab ( id: " 7 " ) ,
424373 ] )
425374
426- static var previews : some View {
427- ChatWindowView (
428- store: . init(
429- initialState: . init(
430- chatTabGroup: . init(
431- tabInfo: [
432- . init( id: " 1 " , title: " Fake " ) ,
433- . init( id: " 2 " , title: " Empty-2 " ) ,
434- . init( id: " 3 " , title: " Empty-3 " ) ,
435- . init( id: " 4 " , title: " Empty-4 " ) ,
436- . init( id: " 5 " , title: " Empty-5 " ) ,
437- . init( id: " 6 " , title: " Empty-6 " ) ,
438- . init( id: " 7 " , title: " Empty-7 " ) ,
439- ] ,
440- selectedTabId: " 1 "
441- ) ,
442- isPanelDisplayed: true
375+ static func createStore( ) -> StoreOf < ChatPanelFeature > {
376+ StoreOf < ChatPanelFeature > (
377+ initialState: . init(
378+ chatTabGroup: . init(
379+ tabInfo: [
380+ . init( id: " 2 " , title: " Empty-2 " ) ,
381+ . init( id: " 3 " , title: " Empty-3 " ) ,
382+ . init( id: " 4 " , title: " Empty-4 " ) ,
383+ . init( id: " 5 " , title: " Empty-5 " ) ,
384+ . init( id: " 6 " , title: " Empty-6 " ) ,
385+ . init( id: " 7 " , title: " Empty-7 " ) ,
386+ ] ,
387+ selectedTabId: " 2 "
443388 ) ,
444- reducer: ChatPanelFeature ( )
445- )
389+ isPanelDisplayed: true
390+ ) ,
391+ reducer: ChatPanelFeature ( )
446392 )
447- . xcodeStyleFrame ( )
448- . padding ( )
449- . environment ( \. chatTabPool, pool)
393+ }
394+
395+ static var previews : some View {
396+ ChatWindowView ( store: createStore ( ) )
397+ . xcodeStyleFrame ( )
398+ . padding ( )
399+ . environment ( \. chatTabPool, pool)
450400 }
451401}
452402
0 commit comments