fix(api-config) error when creation of api config

This commit is contained in:
sam hoang 2025-02-01 20:07:57 +07:00
parent 3e303ea22e
commit 9406a273da
2 changed files with 15 additions and 3 deletions

View file

@ -128,7 +128,10 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
id="api-provider"
value={selectedProvider}
onChange={(value: unknown) => {
handleInputChange("apiProvider")({
handleInputChange(
"apiProvider",
true,
)({
target: {
value: (value as DropdownOption).value,
},

View file

@ -71,7 +71,7 @@ export interface ExtensionStateContextType extends ExtensionState {
setEnhancementApiConfigId: (value: string) => void
setExperimentEnabled: (id: ExperimentId, enabled: boolean) => void
setAutoApprovalEnabled: (value: boolean) => void
handleInputChange: (field: keyof ApiConfiguration) => (event: any) => void
handleInputChange: (field: keyof ApiConfiguration, softUpdate?: boolean) => (event: any) => void
customModes: ModeConfig[]
setCustomModes: (value: ModeConfig[]) => void
}
@ -142,7 +142,16 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
}, [])
const handleInputChange = useCallback(
(field: keyof ApiConfiguration) => (event: any) => {
(field: keyof ApiConfiguration, softUpdate?: boolean) => (event: any) => {
if (softUpdate === true) {
setState((currentState) => {
return {
...currentState,
apiConfiguration: { ...currentState.apiConfiguration, [field]: event.target.value },
}
})
return
}
setState((currentState) => {
vscode.postMessage({
type: "upsertApiConfiguration",