diff --git a/src/vs/workbench/contrib/void/browser/react/src/util/inputs.tsx b/src/vs/workbench/contrib/void/browser/react/src/util/inputs.tsx index ec2b2e94..a1c573ac 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/util/inputs.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/util/inputs.tsx @@ -152,6 +152,37 @@ export const VoidInputBox2 = forwardRef(fun }) + +export const VoidSimpleInputBox = ({ value, onChangeValue, placeholder, className, disabled, ...inputProps }: { + value: string; + onChangeValue: (value: string) => void; + placeholder: string; + className?: string; + disabled?: boolean; +} & React.InputHTMLAttributes) => { + const inputRef = useRef(null); + + return ( + onChangeValue(e.target.value)} + placeholder={placeholder} + disabled={disabled} + className={`w-full resize-none text-void-fg-1 placeholder:text-void-fg-3 px-2 py-1 rounded-sm + ${disabled ? 'opacity-50 cursor-not-allowed' : ''} + ${className}`} + style={{ + background: asCssVariable(inputBackground), + color: asCssVariable(inputForeground) + }} + {...inputProps} + /> + ); +}; + + export const VoidInputBox = ({ onChangeText, onCreateInstance, inputBoxRef, placeholder, isPasswordField, multiline }: { onChangeText: (value: string) => void; styles?: Partial, diff --git a/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx b/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx index 375e5086..3c6d2245 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx @@ -7,7 +7,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { InputBox } from '../../../../../../../base/browser/ui/inputbox/inputBox.js' import { ProviderName, SettingName, displayInfoOfSettingName, providerNames, VoidModelInfo, globalSettingNames, customSettingNamesOfProvider, RefreshableProviderName, refreshableProviderNames, displayInfoOfProviderName, defaultProviderSettings, nonlocalProviderNames, localProviderNames, GlobalSettingName, featureNames, displayInfoOfFeatureName, isProviderNameDisabled, FeatureName } from '../../../../common/voidSettingsTypes.js' import ErrorBoundary from '../sidebar-tsx/ErrorBoundary.js' -import { VoidButton, VoidCheckBox, VoidCustomDropdownBox, VoidInputBox, VoidInputBox2, VoidSwitch } from '../util/inputs.js' +import { VoidButton, VoidCheckBox, VoidCustomDropdownBox, VoidInputBox, VoidInputBox2, VoidSimpleInputBox, VoidSwitch } from '../util/inputs.js' import { useAccessor, useIsDark, useRefreshModelListener, useRefreshModelState, useSettingsState } from '../util/services.js' import { X, RefreshCw, Loader2, Check, MoveRight } from 'lucide-react' import { useScrollbarStyles } from '../util/useScrollbarStyles.js' @@ -255,45 +255,30 @@ export const ModelDump = () => { const ProviderSetting = ({ providerName, settingName }: { providerName: ProviderName, settingName: SettingName }) => { - - // const { title: providerTitle, } = displayInfoOfProviderName(providerName) - const { title: settingTitle, placeholder, isPasswordField, subTextMd } = displayInfoOfSettingName(providerName, settingName) const accessor = useAccessor() const voidSettingsService = accessor.get('IVoidSettingsService') + const settingsState = useSettingsState() - let weChangedTextRef = false + const settingValue = settingsState.settingsOfProvider[providerName][settingName] as string // this should always be a string in this component + if (typeof settingValue !== 'string') { + console.log('Error: Provider setting had a non-string value.') + return + } return
- { - if (weChangedTextRef) return + { voidSettingsService.setSettingOfProvider(providerName, settingName, newVal) }, [voidSettingsService, providerName, settingName])} - // we are responsible for setting the initial value. always sync the instance whenever there's a change to state. - onCreateInstance={useCallback((instance: InputBox) => { - const syncInstance = () => { - const settingsAtProvider = voidSettingsService.state.settingsOfProvider[providerName]; - const stateVal = settingsAtProvider[settingName as SettingName] + // placeholder={`${providerTitle} ${settingTitle} (${placeholder})`} + placeholder={`${settingTitle} (${placeholder})`} - // console.log('SYNCING TO', providerName, settingName, stateVal) - weChangedTextRef = true - instance.value = stateVal as string - weChangedTextRef = false - } - - syncInstance() - const disposable = voidSettingsService.onDidChangeState(syncInstance) - return [disposable] - }, [voidSettingsService, providerName, settingName])} - multiline={false} - isPasswordField={isPasswordField} + type={isPasswordField ? 'password' : 'text'} /> {subTextMd === undefined ? null :