Skip to content

Commit c563280

Browse files
committed
Models-modal: Wizard uses the same autocomplete pattern
1 parent f8cbb6f commit c563280

1 file changed

Lines changed: 22 additions & 30 deletions

File tree

src/modules/llms/models-modal/ModelsWizard.tsx

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import * as React from 'react';
22
import { useShallow } from 'zustand/react/shallow';
33

4-
import { Avatar, Badge, Box, Button, Chip, CircularProgress, Input, Sheet, Typography } from '@mui/joy';
4+
import { Avatar, Badge, Box, Button, Chip, CircularProgress, Sheet, Typography } from '@mui/joy';
55

6+
import { FormInputKey } from '~/common/components/forms/FormInputKey';
67
import { TooltipOutlined } from '~/common/components/TooltipOutlined';
78
import { llmsStoreActions, llmsStoreState, useModelsStore } from '~/common/stores/llms/store-llms';
89
import { useShallowStabilizer } from '~/common/util/hooks/useShallowObject';
@@ -126,12 +127,12 @@ function WizardProviderSetup(props: {
126127
const valueName = isLocal ? 'server' : 'API Key';
127128
const { name: vendorName } = providerVendor;
128129

130+
// use consistent autoCompleteId pattern: vendor-key for API keys, vendor-host for servers
131+
const autoCompleteId = isLocal ? `${providerVendor.id}-host` : `${providerVendor.id}-key`;
132+
129133

130134
// handlers
131135

132-
const handleTextChanged = React.useCallback((e: React.ChangeEvent) => {
133-
setLocalValue((e.target as HTMLInputElement).value);
134-
}, []);
135136

136137
const handleSetServiceKeyValue = React.useCallback(async () => {
137138

@@ -180,11 +181,12 @@ function WizardProviderSetup(props: {
180181
{/*</TooltipOutlined>*/}
181182
{/*<TooltipOutlined title='Confirm'>*/}
182183
<Button
183-
variant='solid' color='primary'
184+
color='primary'
185+
variant='solid'
184186
onClick={handleSetServiceKeyValue}
185187
// endDecorator={<CheckRoundedIcon />}
186188
>
187-
{!serviceKeyValue ? 'Confirm' : !localValue?.trim() ? 'Clear' : 'Update'}
189+
{!serviceKeyValue ? 'Save' : !localValue?.trim() ? 'Delete' : 'Update'}
188190
</Button>
189191
{/*</TooltipOutlined>*/}
190192
</Box>
@@ -219,30 +221,20 @@ function WizardProviderSetup(props: {
219221
</TooltipOutlined>
220222

221223
{/* Main key inputs */}
222-
<Box sx={{ flex: 1, display: 'grid' }}>
223-
224-
{/* Line 1 */}
225-
{/*{!!props.serviceLabel && (*/}
226-
{/* <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>*/}
227-
{/* /!*<props.vendorIcon />*!/*/}
228-
{/* <Box>{props.serviceLabel}</Box>*/}
229-
{/* </Box>*/}
230-
{/*)}*/}
231-
232-
{/* Line 2 */}
233-
<Input
234-
fullWidth
235-
name={`wizard-settings-value-${providerVendor.id}`}
236-
autoComplete='off'
237-
variant='outlined'
238-
value={localValue ?? ''}
239-
onChange={handleTextChanged}
240-
placeholder={`${vendorName} ${valueName}`}
241-
type={isLocal ? undefined : 'password'}
242-
// error={!isValidKey}
243-
// startDecorator={<props.vendorIcon />}
244-
endDecorator={endButtons}
245-
/>
224+
<Box sx={{ flex: 1, display: 'flex', flexDirection: 'row', gap: 0.5 }}>
225+
226+
<Box sx={{ flex: 1 }}>
227+
<FormInputKey
228+
noKey={isLocal}
229+
autoCompleteId={autoCompleteId}
230+
value={localValue ?? ''}
231+
placeholder={`${vendorName} ${valueName}`}
232+
onChange={setLocalValue}
233+
required={false}
234+
/>
235+
</Box>
236+
237+
{endButtons}
246238

247239
</Box>
248240

0 commit comments

Comments
 (0)