From 47e93d1cf3d50b56016e139b0e9f6b9cab0ae037 Mon Sep 17 00:00:00 2001 From: Andrew Pareles Date: Sat, 15 Mar 2025 17:00:21 -0700 Subject: [PATCH] fix up settings --- .../void/browser/react/src/util/inputs.tsx | 2 +- .../react/src/void-settings-tsx/Settings.tsx | 88 ++++++++++--------- 2 files changed, 46 insertions(+), 44 deletions(-) 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 ed328dc4..6ac3d712 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 @@ -925,7 +925,7 @@ export const VoidCodeEditor = ({ initValue, language, maxHeight, showScrollbars export const VoidButton = ({ children, disabled, onClick }: { children: React.ReactNode; disabled?: boolean; onClick: () => void }) => { return } 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 3ab75258..7fa7d183 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 @@ -18,13 +18,12 @@ import { ModelDropdown } from './ModelDropdown.js' import { ChatMarkdownRender } from '../markdown/ChatMarkdownRender.js' import { WarningBox } from './WarningBox.js' import { os } from '../../../../common/helpers/systemInfo.js' +import { IconX } from '../sidebar-tsx/SidebarChat.js' -const SubtleButton = ({ onClick, text, icon, disabled }: { onClick: () => void, text: string, icon: React.ReactNode, disabled: boolean }) => { +const ButtonLeftTextRightOption = ({ text, leftButton }: { text: string, leftButton?: React.ReactNode }) => { return
- + {leftButton ? leftButton : null} {text} @@ -57,22 +56,28 @@ const RefreshModelButton = ({ providerName }: { providerName: RefreshableProvide const { state } = refreshModelState[providerName] const { title: providerTitle } = displayInfoOfProviderName(providerName) - return { - refreshModelService.startRefreshingModels(providerName, { enableProviderOnSuccess: false, doNotFire: false }) - metricsService.capture('Click', { providerName, action: 'Refresh Models' }) - }} - text={justFinished === 'finished' ? `${providerTitle} Models are up-to-date!` - : justFinished === 'error' ? `${providerTitle} not found!` - : `Manually refresh ${providerTitle} models.` - } - icon={justFinished === 'finished' ? - : justFinished === 'error' ? - : state === 'refreshing' ? - : + + return { + refreshModelService.startRefreshingModels(providerName, { enableProviderOnSuccess: false, doNotFire: false }) + metricsService.capture('Click', { providerName, action: 'Refresh Models' }) + }} + > + {justFinished === 'finished' ? + : justFinished === 'error' ? + : state === 'refreshing' ? + : } + } - disabled={state === 'refreshing' || justFinished !== null} + text={justFinished === 'finished' ? `${providerTitle} Models are up-to-date!` + : justFinished === 'error' ? `${providerTitle} not found!` + : `Manually refresh ${providerTitle} models.`} /> } @@ -93,7 +98,7 @@ const RefreshableModels = () => { -const AddModelMenu = ({ onSubmit }: { onSubmit: () => void }) => { +const AddModelMenu = ({ onSubmit, onClose }: { onSubmit: () => void, onClose: () => void }) => { const accessor = useAccessor() const settingsStateService = accessor.get('IVoidSettingsService') @@ -116,8 +121,8 @@ const AddModelMenu = ({ onSubmit }: { onSubmit: () => void }) => { options={providerNames} selectedOption={providerName} onChangeOption={(pn) => setProviderName(pn)} - getOptionDisplayName={(pn) => pn ? displayInfoOfProviderName(pn).title : '(null)'} - getOptionDropdownName={(pn) => pn ? displayInfoOfProviderName(pn).title : '(null)'} + getOptionDisplayName={(pn) => pn ? displayInfoOfProviderName(pn).title : 'Provider Name'} + getOptionDropdownName={(pn) => pn ? displayInfoOfProviderName(pn).title : 'Provider Name'} getOptionsEqual={(a, b) => a === b} className={`max-w-44 w-full border border-void-border-2 bg-void-bg-1 text-void-fg-3 text-root py-[4px] px-[6px] @@ -141,8 +146,8 @@ const AddModelMenu = ({ onSubmit }: { onSubmit: () => void }) => {
{/* button */} -
- { + { const modelName = modelNameRef.current?.value if (providerName === null) { @@ -161,16 +166,16 @@ const AddModelMenu = ({ onSubmit }: { onSubmit: () => void }) => { settingsStateService.addModel(providerName, modelName) onSubmit() - }} - >Add model -
+ >Add model - {!errorString ? null :
- {errorString} -
} + + {!errorString ? null :
+ {errorString} +
} + } @@ -178,9 +183,9 @@ const AddModelMenu = ({ onSubmit }: { onSubmit: () => void }) => { const AddModelMenuFull = () => { const [open, setOpen] = useState(false) - return
+ return
{open ? - { setOpen(false) }} /> + setOpen(false)} onClose={() => setOpen(false)} /> : setOpen(true)}>Add Model }
@@ -354,7 +359,7 @@ export const VoidProviderSettings = ({ providerNames }: { providerNames: Provide type TabName = 'models' | 'general' -export const AutoRefreshToggle = () => { +export const AutoDetectLocalModelsToggle = () => { const settingName: GlobalSettingName = 'autoRefreshModels' const accessor = useAccessor() @@ -366,19 +371,17 @@ export const AutoRefreshToggle = () => { // right now this is just `enabled_autoRefreshModels` const enabled = voidSettingsState.globalSettings[settingName] - return
- { voidSettingsService.setGlobalSetting(settingName, newVal) metricsService.capture('Click', { action: 'Autorefresh Toggle', settingName, enabled: newVal }) - }} /> - - - {`Automatically detect local providers and models (${refreshableProviderNames.map(providerName => displayInfoOfProviderName(providerName).title).join(', ')}).`} - -
+ }} + />} + text={`Automatically detect local providers and models (${refreshableProviderNames.map(providerName => displayInfoOfProviderName(providerName).title).join(', ')}).`} + /> } @@ -431,11 +434,10 @@ export const FeaturesTab = () => { return <>

Models

- - -
+ +