1
1
package app
2
2
3
3
import (
4
+ "claude-squad/app/controller"
4
5
"claude-squad/config"
5
6
"claude-squad/keys"
6
7
"claude-squad/session"
@@ -47,7 +48,7 @@ type home struct {
47
48
// state is the current discrete state of the app
48
49
state tuiState
49
50
// controller manages instances and orchestrators
50
- controller * controller
51
+ controller * controller. Controller
51
52
// program is the program to use for instances and orchestrators
52
53
program string
53
54
// autoYes is whether to automatically approve actions
@@ -97,11 +98,13 @@ func newHome(ctx context.Context, program string, autoYes bool) *home {
97
98
appState : appState ,
98
99
}
99
100
100
- controller := newController (& h .spinner , h .autoYes )
101
- if err := controller .LoadExistingInstances (h ); err != nil {
101
+ // Initialize controller with spinner and autoYes setting
102
+ ctrl := controller .NewController (& h .spinner , h .autoYes )
103
+ // Pass home object which implements required interfaces
104
+ if err := ctrl .LoadExistingInstances (h ); err != nil {
102
105
fmt .Printf ("Warning: Failed to load existing instances: %v\n " , err )
103
106
}
104
- h .controller = controller
107
+ h .controller = ctrl
105
108
106
109
return h
107
110
}
@@ -127,8 +130,9 @@ func (m *home) updateHandleWindowSizeEvent(msg tea.WindowSizeMsg) {
127
130
listWidth := int (float32 (msg .Width ) * 0.4 )
128
131
previewWidth := msg .Width - listWidth
129
132
130
- m .controller .list .SetSize (listWidth , contentHeight )
131
- m .controller .tabbedWindow .SetSize (previewWidth , contentHeight )
133
+ // Access controller's UI components via exported fields or methods
134
+ m .controller .SetListSize (listWidth , contentHeight )
135
+ m .controller .SetTabbedWindowSize (previewWidth , contentHeight )
132
136
}
133
137
134
138
func (m * home ) Init () tea.Cmd {
@@ -145,14 +149,63 @@ func (m *home) Init() tea.Cmd {
145
149
}
146
150
147
151
func (m * home ) Update (msg tea.Msg ) (tea.Model , tea.Cmd ) {
148
- return m .controller .Update (m , msg )
152
+ _ , cmd := m .controller .Update (m , msg )
153
+ return m , cmd
149
154
}
150
155
151
156
func (m * home ) handleQuit () (tea.Model , tea.Cmd ) {
152
- m .controller .HandleQuit (m )
157
+ // We ignore the returned model since we're returning ourselves
158
+ _ , _ = m .controller .HandleQuit (m )
153
159
return m , tea .Quit
154
160
}
155
161
162
+ // Helper methods to support controller functionality
163
+
164
+ // GetStorage returns the storage instance
165
+ func (m * home ) GetStorage () * session.Storage {
166
+ return m .storage
167
+ }
168
+
169
+ // GetMenu returns the menu instance
170
+ func (m * home ) GetMenu () * ui.Menu {
171
+ return m .menu
172
+ }
173
+
174
+ // GetErrBox returns the error box instance
175
+ func (m * home ) GetErrBox () * ui.ErrBox {
176
+ return m .errBox
177
+ }
178
+
179
+ // GetState returns the current UI state
180
+ func (m * home ) GetState () tuiState {
181
+ return m .state
182
+ }
183
+
184
+ // SetState sets the UI state
185
+ func (m * home ) SetState (state tuiState ) {
186
+ m .state = state
187
+ }
188
+
189
+ // GetProgram returns the program name
190
+ func (m * home ) GetProgram () string {
191
+ return m .program
192
+ }
193
+
194
+ // GetAutoYes returns the autoYes flag
195
+ func (m * home ) GetAutoYes () bool {
196
+ return m .autoYes
197
+ }
198
+
199
+ // GetSpinner returns the spinner instance
200
+ func (m * home ) GetSpinner () * spinner.Model {
201
+ return & m .spinner
202
+ }
203
+
204
+ // UpdateSpinner updates the spinner model
205
+ func (m * home ) UpdateSpinner (msg spinner.TickMsg ) (spinner.Model , tea.Cmd ) {
206
+ return m .spinner .Update (msg )
207
+ }
208
+
156
209
func (m * home ) handleMenuHighlighting (msg tea.KeyMsg ) (cmd tea.Cmd , returnEarly bool ) {
157
210
// Handle menu highlighting when you press a button. We intercept it here and immediately return to
158
211
// update the ui while re-sending the keypress. Then, on the next call to this, we actually handle the keypress.
0 commit comments