diff --git a/packages/types/src/providers/bedrock.ts b/packages/types/src/providers/bedrock.ts index 58e860dd94a..470902fc920 100644 --- a/packages/types/src/providers/bedrock.ts +++ b/packages/types/src/providers/bedrock.ts @@ -405,4 +405,10 @@ export const BEDROCK_REGIONS = [ { value: "sa-east-1", label: "sa-east-1" }, { value: "us-gov-east-1", label: "us-gov-east-1" }, { value: "us-gov-west-1", label: "us-gov-west-1" }, -].sort((a, b) => a.value.localeCompare(b.value)) + { value: "custom", label: "Custom region..." }, +].sort((a, b) => { + // Keep 'custom' option at the end + if (a.value === "custom") return 1; + if (b.value === "custom") return -1; + return a.value.localeCompare(b.value); +}) diff --git a/webview-ui/src/components/settings/providers/Bedrock.tsx b/webview-ui/src/components/settings/providers/Bedrock.tsx index 1839298f9b6..611d20b159b 100644 --- a/webview-ui/src/components/settings/providers/Bedrock.tsx +++ b/webview-ui/src/components/settings/providers/Bedrock.tsx @@ -18,12 +18,27 @@ type BedrockProps = { export const Bedrock = ({ apiConfiguration, setApiConfigurationField, selectedModelInfo }: BedrockProps) => { const { t } = useAppTranslation() const [awsEndpointSelected, setAwsEndpointSelected] = useState(!!apiConfiguration?.awsBedrockEndpointEnabled) + const [isCustomRegion, setIsCustomRegion] = useState( + apiConfiguration?.awsRegion && !BEDROCK_REGIONS.some((region) => region.value === apiConfiguration.awsRegion), + ) // Update the endpoint enabled state when the configuration changes useEffect(() => { setAwsEndpointSelected(!!apiConfiguration?.awsBedrockEndpointEnabled) }, [apiConfiguration?.awsBedrockEndpointEnabled]) + // Initialize custom region state on component mount + useEffect(() => { + if (apiConfiguration?.awsRegion) { + const isStandardRegion = BEDROCK_REGIONS.some( + (region: { value: string; label: string }) => + region.value === apiConfiguration.awsRegion && region.value !== "custom", + ) + setIsCustomRegion(!isStandardRegion) + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []) // Only run on mount - deliberately ignoring apiConfiguration dependency to avoid conflicts + const handleInputChange = useCallback( ( field: K, @@ -88,8 +103,16 @@ export const Bedrock = ({ apiConfiguration, setApiConfigurationField, selectedMo
+ {isCustomRegion && ( +
+ + + +
+ )}