Skip to content

Commit 9406a27

Browse files
committed
fix(api-config) error when creation of api config
1 parent 3e303ea commit 9406a27

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ const ApiOptions = ({ apiErrorMessage, modelIdErrorMessage }: ApiOptionsProps) =
128128
id="api-provider"
129129
value={selectedProvider}
130130
onChange={(value: unknown) => {
131-
handleInputChange("apiProvider")({
131+
handleInputChange(
132+
"apiProvider",
133+
true,
134+
)({
132135
target: {
133136
value: (value as DropdownOption).value,
134137
},

webview-ui/src/context/ExtensionStateContext.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export interface ExtensionStateContextType extends ExtensionState {
7171
setEnhancementApiConfigId: (value: string) => void
7272
setExperimentEnabled: (id: ExperimentId, enabled: boolean) => void
7373
setAutoApprovalEnabled: (value: boolean) => void
74-
handleInputChange: (field: keyof ApiConfiguration) => (event: any) => void
74+
handleInputChange: (field: keyof ApiConfiguration, softUpdate?: boolean) => (event: any) => void
7575
customModes: ModeConfig[]
7676
setCustomModes: (value: ModeConfig[]) => void
7777
}
@@ -142,7 +142,16 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
142142
}, [])
143143

144144
const handleInputChange = useCallback(
145-
(field: keyof ApiConfiguration) => (event: any) => {
145+
(field: keyof ApiConfiguration, softUpdate?: boolean) => (event: any) => {
146+
if (softUpdate === true) {
147+
setState((currentState) => {
148+
return {
149+
...currentState,
150+
apiConfiguration: { ...currentState.apiConfiguration, [field]: event.target.value },
151+
}
152+
})
153+
return
154+
}
146155
setState((currentState) => {
147156
vscode.postMessage({
148157
type: "upsertApiConfiguration",

0 commit comments

Comments
 (0)