@@ -74,4 +74,35 @@ describe("InputController thinking visibility", () => {
7474 expect ( resetDisplay ) . not . toHaveBeenCalled ( ) ;
7575 expect ( showStatus ) . toHaveBeenCalledWith ( "Thinking is off — enable thinking to show blocks" ) ;
7676 } ) ;
77+ it ( "refuses to toggle when thinking is off even if hideThinkingBlock is already true" , ( ) => {
78+ // The persisted preference may already be true from a prior session
79+ // where thinking was on. With thinking off, effectiveHideThinkingBlock
80+ // is true regardless, so any toggle is a no-op — guard it rather than
81+ // flipping the persisted preference back to false.
82+ const assistant = new AssistantMessageComponent ( ) ;
83+ const setHideThinkingBlock = vi . spyOn ( assistant , "setHideThinkingBlock" ) ;
84+ const set = vi . fn ( ) ;
85+ const showStatus = vi . fn ( ) ;
86+ const resetDisplay = vi . fn ( ) ;
87+ const ctx = {
88+ hideThinkingBlock : true ,
89+ effectiveHideThinkingBlock : true , // thinking is off → effective is true
90+ settings : { set } ,
91+ session : { agent : { hideThinkingSummary : false } } ,
92+ chatContainer : { children : [ assistant ] , clear : vi . fn ( ) , addChild : vi . fn ( ) } ,
93+ streamingComponent : undefined ,
94+ streamingMessage : undefined ,
95+ showStatus,
96+ ui : { resetDisplay } ,
97+ } as unknown as InteractiveModeContext ;
98+
99+ new InputController ( ctx ) . toggleThinkingBlockVisibility ( ) ;
100+
101+ // Persisted preference unchanged, no component updates, no reset.
102+ expect ( ctx . hideThinkingBlock ) . toBe ( true ) ;
103+ expect ( set ) . not . toHaveBeenCalled ( ) ;
104+ expect ( setHideThinkingBlock ) . not . toHaveBeenCalled ( ) ;
105+ expect ( resetDisplay ) . not . toHaveBeenCalled ( ) ;
106+ expect ( showStatus ) . toHaveBeenCalledWith ( "Thinking is off — enable thinking to show blocks" ) ;
107+ } ) ;
77108} ) ;
0 commit comments