@@ -10,15 +10,15 @@ const managerMocks = vi.hoisted(() => ({
1010 resolveSession : vi . fn ( ) ,
1111 closeSession : vi . fn ( ) ,
1212 initializeSession : vi . fn ( ) ,
13- updateSessionRuntimeOptions : vi . fn ( ) ,
13+ setSessionConfigOption : vi . fn ( ) ,
1414} ) ) ;
1515
1616vi . mock ( "./control-plane/manager.js" , ( ) => ( {
1717 getAcpSessionManager : ( ) => ( {
1818 resolveSession : managerMocks . resolveSession ,
1919 closeSession : managerMocks . closeSession ,
2020 initializeSession : managerMocks . initializeSession ,
21- updateSessionRuntimeOptions : managerMocks . updateSessionRuntimeOptions ,
21+ setSessionConfigOption : managerMocks . setSessionConfigOption ,
2222 } ) ,
2323} ) ) ;
2424
@@ -39,7 +39,7 @@ beforeEach(async () => {
3939 metaCleared : false ,
4040 } ) ;
4141 managerMocks . initializeSession . mockReset ( ) . mockResolvedValue ( undefined ) ;
42- managerMocks . updateSessionRuntimeOptions . mockReset ( ) . mockResolvedValue ( undefined ) ;
42+ managerMocks . setSessionConfigOption . mockReset ( ) . mockResolvedValue ( undefined ) ;
4343 ( { ensureConfiguredAcpBindingSession } = await import ( "./persistent-bindings.lifecycle.js" ) ) ;
4444} ) ;
4545
@@ -119,7 +119,7 @@ describe("ensureConfiguredAcpBindingSession", () => {
119119 expect ( ensured ) . toEqual ( { ok : true , sessionKey } ) ;
120120 expect ( managerMocks . closeSession ) . not . toHaveBeenCalled ( ) ;
121121 expect ( managerMocks . initializeSession ) . not . toHaveBeenCalled ( ) ;
122- expect ( managerMocks . updateSessionRuntimeOptions ) . not . toHaveBeenCalled ( ) ;
122+ expect ( managerMocks . setSessionConfigOption ) . not . toHaveBeenCalled ( ) ;
123123 } ) ;
124124
125125 it . each ( [
@@ -141,11 +141,11 @@ describe("ensureConfiguredAcpBindingSession", () => {
141141 } ) ;
142142
143143 expect ( ensured ) . toEqual ( { ok : true , sessionKey } ) ;
144- expect ( managerMocks . updateSessionRuntimeOptions ) . toHaveBeenCalledWith ( {
145- cfg : baseCfg ,
146- sessionKey,
147- patch : runtimeOptions ,
148- } ) ;
144+ expect ( managerMocks . setSessionConfigOption . mock . calls ) . toEqual (
145+ Object . entries ( runtimeOptions ) . map ( ( [ key , value ] ) => [
146+ { cfg : baseCfg , sessionKey, key , value } ,
147+ ] ) ,
148+ ) ;
149149 expect ( managerMocks . closeSession ) . not . toHaveBeenCalled ( ) ;
150150 expect ( managerMocks . initializeSession ) . not . toHaveBeenCalled ( ) ;
151151 } ) ;
@@ -158,7 +158,28 @@ describe("ensureConfiguredAcpBindingSession", () => {
158158 ok : true ,
159159 sessionKey,
160160 } ) ;
161- expect ( managerMocks . updateSessionRuntimeOptions ) . not . toHaveBeenCalled ( ) ;
161+ expect ( managerMocks . setSessionConfigOption ) . not . toHaveBeenCalled ( ) ;
162+ expect ( managerMocks . closeSession ) . not . toHaveBeenCalled ( ) ;
163+ expect ( managerMocks . initializeSession ) . not . toHaveBeenCalled ( ) ;
164+ } ) ;
165+
166+ it ( "reports rejected live thinking without replacing or overwriting the existing session" , async ( ) => {
167+ const spec = createPersistentSpec ( { thinking : "off" } ) ;
168+ const sessionKey = mockReadySession ( {
169+ spec,
170+ cwd : "/workspace/openclaw" ,
171+ thinking : "high" ,
172+ } ) ;
173+ managerMocks . setSessionConfigOption . mockRejectedValue ( new Error ( "Live off is unsupported" ) ) ;
174+
175+ for ( let attempt = 0 ; attempt < 2 ; attempt ++ ) {
176+ expect ( await ensureConfiguredAcpBindingSession ( { cfg : baseCfg , spec } ) ) . toEqual ( {
177+ ok : false ,
178+ sessionKey,
179+ error : "Live off is unsupported" ,
180+ } ) ;
181+ }
182+ expect ( managerMocks . setSessionConfigOption ) . toHaveBeenCalledTimes ( 2 ) ;
162183 expect ( managerMocks . closeSession ) . not . toHaveBeenCalled ( ) ;
163184 expect ( managerMocks . initializeSession ) . not . toHaveBeenCalled ( ) ;
164185 } ) ;
@@ -259,10 +280,11 @@ describe("ensureConfiguredAcpBindingSession", () => {
259280 } ) ;
260281
261282 expect ( ensured ) . toEqual ( { ok : true , sessionKey } ) ;
262- expect ( managerMocks . updateSessionRuntimeOptions ) . toHaveBeenCalledWith ( {
283+ expect ( managerMocks . setSessionConfigOption ) . toHaveBeenCalledWith ( {
263284 cfg : baseCfg ,
264285 sessionKey,
265- patch : { thinking : "off" } ,
286+ key : "thinking" ,
287+ value : "off" ,
266288 } ) ;
267289 expect ( managerMocks . closeSession ) . not . toHaveBeenCalled ( ) ;
268290 expect ( managerMocks . initializeSession ) . not . toHaveBeenCalled ( ) ;
@@ -283,7 +305,7 @@ describe("ensureConfiguredAcpBindingSession", () => {
283305 } ) ;
284306
285307 expect ( ensured ) . toEqual ( { ok : true , sessionKey } ) ;
286- expect ( managerMocks . updateSessionRuntimeOptions ) . not . toHaveBeenCalled ( ) ;
308+ expect ( managerMocks . setSessionConfigOption ) . not . toHaveBeenCalled ( ) ;
287309 expect ( managerMocks . closeSession ) . not . toHaveBeenCalled ( ) ;
288310 expect ( managerMocks . initializeSession ) . not . toHaveBeenCalled ( ) ;
289311 } ) ;
0 commit comments