File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ import XcodeInspector
1111import ProChatTabs
1212
1313enum ChatTabFactory {
14- static var chatTabBuilderCollection : [ ChatTabBuilderCollection ] {
14+ static func chatTabBuilderCollection(
15+ openTab: @escaping ( any ChatTab ) -> Void
16+ ) -> [ ChatTabBuilderCollection ] {
1517 func folderIfNeeded(
1618 _ builders: [ any ChatTabBuilder ] ,
1719 title: String
@@ -86,7 +88,8 @@ enum ChatTabFactory {
8688 try await service. modifyCode ( prompt: instruction ?? " Modify content. " )
8789 return service. code
8890 }
89- }
91+ } ,
92+ handleNewTab: openTab
9093 ) ) , title: BrowserChatTab . name) ,
9194 ] . compactMap { $0 }
9295
@@ -97,7 +100,9 @@ enum ChatTabFactory {
97100#else
98101
99102enum ChatTabFactory {
100- static var chatTabBuilderCollection : [ ChatTabBuilderCollection ] {
103+ static func chatTabBuilderCollection(
104+ openTab: @escaping ( any ChatTab ) -> Void
105+ ) -> [ ChatTabBuilderCollection ] {
101106 func folderIfNeeded(
102107 _ builders: [ any ChatTabBuilder ] ,
103108 title: String
Original file line number Diff line number Diff line change @@ -119,20 +119,29 @@ public final class GraphicalUserInterfaceController {
119119 let widgetDataSource : WidgetDataSource
120120 let viewStore : ViewStoreOf < GUI >
121121
122+ class WeakStoreHolder {
123+ weak var store : StoreOf < GUI > ?
124+ }
125+
122126 private init ( ) {
127+ let weakStoreHolder = WeakStoreHolder ( )
123128 let suggestionDependency = SuggestionWidgetControllerDependency ( )
124129 let setupDependency : ( inout DependencyValues ) -> Void = { dependencies in
125130 dependencies. suggestionWidgetControllerDependency = suggestionDependency
126131 dependencies. suggestionWidgetUserDefaultsObservers = . init( )
127132 dependencies. chatTabBuilderCollection = {
128- ChatTabFactory . chatTabBuilderCollection
133+ ChatTabFactory . chatTabBuilderCollection { tab in
134+ weakStoreHolder. store?
135+ . send ( . suggestionWidget( . chatPanel( . appendAndSelectTab( tab) ) ) )
136+ }
129137 }
130138 }
131139 let store = StoreOf < GUI > (
132140 initialState: . init( ) ,
133141 reducer: GUI ( ) ,
134142 prepareDependencies: setupDependency
135143 )
144+ weakStoreHolder. store = store
136145 self . store = store
137146 viewStore = ViewStore ( store)
138147 widgetDataSource = . init( )
You can’t perform that action at this time.
0 commit comments