@@ -5,6 +5,7 @@ local ui = require('opencode.ui.ui')
55local session = require (' opencode.session' )
66local Promise = require (' opencode.promise' )
77local stub = require (' luassert.stub' )
8+ local assert = require (' luassert' )
89
910-- Provide a mock api_client for tests that need it
1011local function mock_api_client ()
@@ -233,6 +234,28 @@ describe('opencode.core', function()
233234 assert .equal (' sess-new' , new .id )
234235 state .api_client .create_session = orig_session
235236 end )
237+
238+ it (' persist options in state when sending message' , function ()
239+ local orig = state .api_client .create_message
240+ state .windows = { mock = ' windows' }
241+ state .active_session = { id = ' sess1' }
242+
243+ state .api_client .create_message = function (_ , sid , params )
244+ create_called = true
245+ assert .equal (' sess1' , sid )
246+ assert .truthy (params .parts )
247+ return Promise .new ():resolve ({ id = ' m1' })
248+ end
249+
250+ core .send_message (
251+ ' hello world' ,
252+ { context = { current_file = { enabled = false } }, agent = ' plan' , model = ' test/model' }
253+ )
254+ assert .same (state .current_context_config , { current_file = { enabled = false } })
255+ assert .equal (state .current_mode , ' plan' )
256+ assert .equal (state .current_model , ' test/model' )
257+ state .api_client .create_message = orig
258+ end )
236259 end )
237260
238261 describe (' opencode_ok (version checks)' , function ()
0 commit comments