@@ -139,6 +139,44 @@ test("OpenCode TUI changes the default model and persists on q", async () => {
139139 assert . match ( output . writes . join ( "" ) , / L o a d i n g m o d e l s / ) ;
140140} ) ;
141141
142+ test ( "OpenCode TUI changes the focused agent model" , async ( ) => {
143+ const input = createTuiInput ( ) ;
144+ const output = { isTTY : true , rows : 30 , writes : [ ] , write ( chunk ) { this . writes . push ( String ( chunk ) ) ; } } ;
145+ const saved = [ ] ;
146+ const state = {
147+ schemaVersion : 1 ,
148+ defaultModel : "nan/model-a" ,
149+ smallModel : "nan/model-a" ,
150+ agents : Object . fromEntries ( AGENT_IDS . map ( ( agent ) => [ agent , "nan/model-a" ] ) ) ,
151+ } ;
152+ const running = runTerminalOcSwitcher ( {
153+ input,
154+ output,
155+ initialState : state ,
156+ initialModels : [ "nan/model-a" , "openai/model-b" ] ,
157+ refreshModels : async ( ) => [ "nan/model-a" , "openai/model-b" ] ,
158+ saveState : async ( nextState ) => {
159+ saved . push ( nextState ) ;
160+ return nextState ;
161+ } ,
162+ } ) ;
163+
164+ await nextTick ( ) ;
165+ emitKey ( input , "down" ) ;
166+ emitKey ( input , "down" ) ;
167+ emitKey ( input , "return" , "\r" ) ;
168+ await nextTick ( ) ;
169+ emitKey ( input , "down" ) ;
170+ emitKey ( input , "return" , "\r" ) ;
171+ await nextTick ( ) ;
172+ emitKey ( input , "q" ) ;
173+ const result = await running ;
174+
175+ assert . equal ( result . status , "saved" ) ;
176+ assert . equal ( saved . length , 1 ) ;
177+ assert . equal ( saved [ 0 ] . agents . lead , "openai/model-b" ) ;
178+ } ) ;
179+
142180test ( "OpenCode search treats shortcut letters as query text" , async ( ) => {
143181 const input = createTuiInput ( ) ;
144182 const output = { isTTY : true , rows : 30 , writes : [ ] , write ( chunk ) { this . writes . push ( String ( chunk ) ) ; } } ;
0 commit comments