@@ -4,7 +4,7 @@ import React from "react"
44
55import { render , screen , fireEvent } from "@/utils/test-utils"
66
7- import type { ModelInfo } from "@roo-code/types"
7+ import type { ModelInfo , ProviderSettings } from "@roo-code/types"
88
99import { ThinkingBudget } from "../ThinkingBudget"
1010
@@ -352,6 +352,81 @@ describe("ThinkingBudget", () => {
352352 expect ( setApiConfigurationField ) . toHaveBeenCalledWith ( "reasoningEffort" , "max" , false )
353353 } )
354354
355+ it ( "should use the first supported effort when required reasoning has no advertised default" , ( ) => {
356+ const setApiConfigurationField = vi . fn ( )
357+ render (
358+ < ThinkingBudget
359+ { ...defaultProps }
360+ apiConfiguration = { { } }
361+ setApiConfigurationField = { setApiConfigurationField }
362+ modelInfo = { {
363+ ...reasoningEffortModelInfo ,
364+ supportsReasoningEffort : [ "low" , "high" ] ,
365+ requiredReasoningEffort : true ,
366+ } }
367+ /> ,
368+ )
369+
370+ expect ( screen . getByTestId ( "select" ) ) . toHaveAttribute ( "data-value" , "low" )
371+ expect ( setApiConfigurationField ) . toHaveBeenCalledWith ( "reasoningEffort" , "low" , false )
372+ expect ( setApiConfigurationField ) . toHaveBeenCalledWith ( "enableReasoningEffort" , true , false )
373+ } )
374+
375+ it . each < {
376+ name : string
377+ apiConfiguration : ProviderSettings
378+ modelInfo : ModelInfo
379+ expected : string
380+ expectedWrite ?: string
381+ } > ( [
382+ {
383+ name : "keeps a supported stored effort over the model default" ,
384+ apiConfiguration : { reasoningEffort : "low" , enableReasoningEffort : true } ,
385+ modelInfo : {
386+ ...reasoningEffortModelInfo ,
387+ supportsReasoningEffort : [ "disable" , "low" , "high" ] ,
388+ reasoningEffort : "high" ,
389+ } ,
390+ expected : "low" ,
391+ expectedWrite : undefined ,
392+ } ,
393+ {
394+ name : "normalizes an unsupported stored effort to the model default" ,
395+ apiConfiguration : { reasoningEffort : "max" , enableReasoningEffort : true } ,
396+ modelInfo : {
397+ ...reasoningEffortModelInfo ,
398+ supportsReasoningEffort : [ "disable" , "low" , "high" ] ,
399+ reasoningEffort : "high" ,
400+ } ,
401+ expected : "high" ,
402+ expectedWrite : "high" ,
403+ } ,
404+ {
405+ name : "defaults optional boolean reasoning support to disabled" ,
406+ apiConfiguration : { } ,
407+ modelInfo : reasoningEffortModelInfo ,
408+ expected : "disable" ,
409+ expectedWrite : undefined ,
410+ } ,
411+ ] ) ( "$name" , ( { apiConfiguration, modelInfo, expected, expectedWrite } ) => {
412+ const setApiConfigurationField = vi . fn ( )
413+ render (
414+ < ThinkingBudget
415+ { ...defaultProps }
416+ apiConfiguration = { apiConfiguration }
417+ setApiConfigurationField = { setApiConfigurationField }
418+ modelInfo = { modelInfo }
419+ /> ,
420+ )
421+
422+ expect ( screen . getByTestId ( "select" ) ) . toHaveAttribute ( "data-value" , expected )
423+ if ( expectedWrite ) {
424+ expect ( setApiConfigurationField ) . toHaveBeenCalledWith ( "reasoningEffort" , expectedWrite , false )
425+ } else {
426+ expect ( setApiConfigurationField ) . not . toHaveBeenCalledWith ( "reasoningEffort" , expect . anything ( ) , false )
427+ }
428+ } )
429+
355430 it ( "should fall back to rawReasoningEffort when availableOptions is empty" , ( ) => {
356431 // Covers the ?? rawReasoningEffort branch when availableOptions[0] is undefined
357432 render (
0 commit comments