@@ -68,15 +68,17 @@ const ApiOptions = ({
6868 const [ lmStudioModels , setLmStudioModels ] = useState < string [ ] > ( [ ] )
6969 const [ vsCodeLmModels , setVsCodeLmModels ] = useState < vscodemodels . LanguageModelChatSelector [ ] > ( [ ] )
7070 const [ anthropicBaseUrlSelected , setAnthropicBaseUrlSelected ] = useState ( ! ! apiConfiguration ?. anthropicBaseUrl )
71- const [ anthropicThinkingBudget , setAnthropicThinkingBudget ] = useState ( apiConfiguration ?. anthropicThinking )
7271 const [ azureApiVersionSelected , setAzureApiVersionSelected ] = useState ( ! ! apiConfiguration ?. azureApiVersion )
7372 const [ openRouterBaseUrlSelected , setOpenRouterBaseUrlSelected ] = useState ( ! ! apiConfiguration ?. openRouterBaseUrl )
7473 const [ isDescriptionExpanded , setIsDescriptionExpanded ] = useState ( false )
7574
76- const inputEventTransform = < E , > ( event : E ) => ( event as { target : HTMLInputElement } ) ?. target ?. value as any
75+ const anthropicThinkingBudget = apiConfiguration ?. anthropicThinking
76+
7777 const noTransform = < T , > ( value : T ) => value
78+ const inputEventTransform = < E , > ( event : E ) => ( event as { target : HTMLInputElement } ) ?. target ?. value as any
7879 const dropdownEventTransform = < T , > ( event : DropdownOption | string | undefined ) =>
7980 ( typeof event == "string" ? event : event ?. value ) as T
81+
8082 const handleInputChange = useCallback (
8183 < K extends keyof ApiConfiguration , E > (
8284 field : K ,
@@ -107,8 +109,10 @@ const ApiOptions = ({
107109 250 ,
108110 [ selectedProvider , apiConfiguration ?. ollamaBaseUrl , apiConfiguration ?. lmStudioBaseUrl ] ,
109111 )
112+
110113 const handleMessage = useCallback ( ( event : MessageEvent ) => {
111114 const message : ExtensionMessage = event . data
115+
112116 if ( message . type === "ollamaModels" && Array . isArray ( message . ollamaModels ) ) {
113117 const newModels = message . ollamaModels
114118 setOllamaModels ( newModels )
@@ -120,6 +124,7 @@ const ApiOptions = ({
120124 setVsCodeLmModels ( newModels )
121125 }
122126 } , [ ] )
127+
123128 useEvent ( "message" , handleMessage )
124129
125130 const createDropdown = ( models : Record < string , ModelInfo > ) => {
@@ -130,6 +135,7 @@ const ApiOptions = ({
130135 label : modelId ,
131136 } ) ) ,
132137 ]
138+
133139 return (
134140 < Dropdown
135141 id = "model-id"
@@ -1268,11 +1274,9 @@ const ApiOptions = ({
12681274 < div className = "flex flex-col gap-2 mt-2" >
12691275 < Checkbox
12701276 checked = { ! ! anthropicThinkingBudget }
1271- onChange = { ( checked ) => {
1272- const budget = checked ? 16_384 : undefined
1273- setAnthropicThinkingBudget ( budget )
1274- setApiConfigurationField ( "anthropicThinking" , budget )
1275- } } >
1277+ onChange = { ( checked ) =>
1278+ setApiConfigurationField ( "anthropicThinking" , checked ? 16_384 : undefined )
1279+ } >
12761280 Thinking?
12771281 </ Checkbox >
12781282 { anthropicThinkingBudget && (
@@ -1286,11 +1290,7 @@ const ApiOptions = ({
12861290 max = { anthropicModels [ "claude-3-7-sonnet-20250219" ] . maxTokens - 1 }
12871291 step = { 1024 }
12881292 value = { [ anthropicThinkingBudget ] }
1289- onValueChange = { ( value ) => {
1290- const budget = value [ 0 ]
1291- setAnthropicThinkingBudget ( budget )
1292- setApiConfigurationField ( "anthropicThinking" , budget )
1293- } }
1293+ onValueChange = { ( value ) => setApiConfigurationField ( "anthropicThinking" , value [ 0 ] ) }
12941294 />
12951295 < div className = "w-10" > { anthropicThinkingBudget } </ div >
12961296 </ div >
0 commit comments