11import { useCallback } from "react"
22import { VSCodeLink , VSCodeTextField } from "@vscode/webview-ui-toolkit/react"
33
4- import { type ProviderSettings , VERTEX_REGIONS } from "@roo-code/types"
4+ import { type ProviderSettings , type ModelInfo , VERTEX_REGIONS } from "@roo-code/types"
55
66import { useAppTranslation } from "@src/i18n/TranslationContext"
77import { Select , SelectContent , SelectItem , SelectTrigger , SelectValue } from "@src/components/ui"
8+ import { ContextWindow } from "@src/components/common/ContextWindow"
89
910import { inputEventTransform } from "../transforms"
1011
@@ -27,6 +28,42 @@ export const Vertex = ({ apiConfiguration, setApiConfigurationField }: VertexPro
2728 [ setApiConfigurationField ] ,
2829 )
2930
31+ const handleContextWindowChange = useCallback (
32+ ( contextWindow : number | undefined ) => {
33+ const currentModelInfo = apiConfiguration ?. vertexCustomModelInfo
34+ const updatedModelInfo : ModelInfo | undefined = contextWindow
35+ ? {
36+ maxTokens : currentModelInfo ?. maxTokens ?? null ,
37+ contextWindow,
38+ supportsPromptCache : currentModelInfo ?. supportsPromptCache ?? false ,
39+ // Preserve other fields if they exist
40+ ...( currentModelInfo && {
41+ maxThinkingTokens : currentModelInfo . maxThinkingTokens ,
42+ supportsImages : currentModelInfo . supportsImages ,
43+ supportsComputerUse : currentModelInfo . supportsComputerUse ,
44+ supportsVerbosity : currentModelInfo . supportsVerbosity ,
45+ supportsReasoningBudget : currentModelInfo . supportsReasoningBudget ,
46+ requiredReasoningBudget : currentModelInfo . requiredReasoningBudget ,
47+ supportsReasoningEffort : currentModelInfo . supportsReasoningEffort ,
48+ supportedParameters : currentModelInfo . supportedParameters ,
49+ inputPrice : currentModelInfo . inputPrice ,
50+ outputPrice : currentModelInfo . outputPrice ,
51+ cacheWritesPrice : currentModelInfo . cacheWritesPrice ,
52+ cacheReadsPrice : currentModelInfo . cacheReadsPrice ,
53+ description : currentModelInfo . description ,
54+ reasoningEffort : currentModelInfo . reasoningEffort ,
55+ minTokensPerCachePoint : currentModelInfo . minTokensPerCachePoint ,
56+ maxCachePoints : currentModelInfo . maxCachePoints ,
57+ cachableFields : currentModelInfo . cachableFields ,
58+ tiers : currentModelInfo . tiers ,
59+ } ) ,
60+ }
61+ : undefined
62+ setApiConfigurationField ( "vertexCustomModelInfo" , updatedModelInfo )
63+ } ,
64+ [ apiConfiguration ?. vertexCustomModelInfo , setApiConfigurationField ] ,
65+ )
66+
3067 return (
3168 < >
3269 < div className = "text-sm text-vscode-descriptionForeground" >
@@ -91,6 +128,11 @@ export const Vertex = ({ apiConfiguration, setApiConfigurationField }: VertexPro
91128 </ SelectContent >
92129 </ Select >
93130 </ div >
131+ < ContextWindow
132+ customModelInfo = { apiConfiguration ?. vertexCustomModelInfo }
133+ defaultContextWindow = { 128000 }
134+ onContextWindowChange = { handleContextWindowChange }
135+ />
94136 </ >
95137 )
96138}
0 commit comments