@@ -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 ()
@@ -236,6 +237,28 @@ describe('opencode.core', function()
236237 assert .equal (' sess-new' , new .id )
237238 state .api_client .create_session = orig_session
238239 end )
240+
241+ it (' persist options in state when sending message' , function ()
242+ local orig = state .api_client .create_message
243+ state .windows = { mock = ' windows' }
244+ state .active_session = { id = ' sess1' }
245+
246+ state .api_client .create_message = function (_ , sid , params )
247+ create_called = true
248+ assert .equal (' sess1' , sid )
249+ assert .truthy (params .parts )
250+ return Promise .new ():resolve ({ id = ' m1' })
251+ end
252+
253+ core .send_message (
254+ ' hello world' ,
255+ { context = { current_file = { enabled = false } }, agent = ' plan' , model = ' test/model' }
256+ )
257+ assert .same (state .current_context_config , { current_file = { enabled = false } })
258+ assert .equal (state .current_mode , ' plan' )
259+ assert .equal (state .current_model , ' test/model' )
260+ state .api_client .create_message = orig
261+ end )
239262 end )
240263
241264 describe (' opencode_ok (version checks)' , function ()
0 commit comments