- {'Models'}
- {models.length === 0 ?
- {'Please add a provider!'}
- :
+ const wasEmpty = models.length === 0
+ if (wasEmpty) {
+ models.push(['Provider', 'Model'])
+ }
+
+ return <>
+ {featureName}
+ {
s.join(' - '))}
- onChangeSelection={(newVal) => { /*voidConfigService.setFeatureState(providerName, 'model', newVal)*/ }}
+ initVal={models[0]}
+ options={wasEmpty ? [{ text: 'Please add a Provider!', value: models[0] }] : models.map(s => ({ text: s.join(' - '), value: s }))}
+ onChangeSelection={(newVal) => { voidConfigService.setModelSelectionOfFeature(featureName, { providerName: newVal[0] as ProviderName, modelName: newVal[1] }) }}
selectBoxRef={{ current: null }}
/>}
{/* Settings - {featureName}
*/}
{/* {models.map(([providerName, model], i) => {providerName} - {model}
)} */}
- >
+ >
}
export const SidebarModelSettings = () => {
diff --git a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarProviderSettings.tsx b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarProviderSettings.tsx
index b9435a56..d1bd2afb 100644
--- a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarProviderSettings.tsx
+++ b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarProviderSettings.tsx
@@ -20,19 +20,24 @@ const Setting = ({ providerName, settingName }: { providerName: ProviderName, se
useEffect(() => {
// this is really just to sync the state on initial mount, when init value hasn't been set yet
- const syncState = () => {
+ let synced = false
+ const syncStateOnMount = () => {
if (!instanceRef.current) return
+ if (synced) return
+ synced = true
const settingsAtProvider = voidConfigService.state.settingsOfProvider[providerName];
// @ts-ignore
const stateVal = settingsAtProvider[settingName]
- if (instanceRef.current.value !== stateVal)
- instanceRef.current.value = stateVal
+ if (instanceRef.current.value !== stateVal) {
+ instanceRef.current.value = stateVal // triggers onDidChangeState
+ }
}
- syncState()
- const disposable = voidConfigService.onDidChangeState(syncState)
+ syncStateOnMount()
+ synced = false // sync the next time state changes (but not after that - the "current.value = ..." triggers a state change, causing an infinite loop!)
+ const disposable = voidConfigService.onDidChangeState(syncStateOnMount)
return () => disposable.dispose()
}, [instanceRef, voidConfigService])
diff --git a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/inputs.tsx b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/inputs.tsx
index ae0646bb..d8174ea8 100644
--- a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/inputs.tsx
+++ b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/inputs.tsx
@@ -91,11 +91,11 @@ export const VoidInputBox = ({ onChangeText, onCreateInstance, placeholder, mult
-export const VoidSelectBox = ({ onChangeSelection, initVal, selectBoxRef, options }: {
- onChangeSelection: (value: string) => void;
- initVal: string;
+export const VoidSelectBox =