💄 small updates to model selection / deletion

This commit is contained in:
Nate Sesti 2023-12-15 19:18:07 -08:00
parent 6884af69f9
commit dde1139b61
3 changed files with 17 additions and 28 deletions

View file

@ -371,6 +371,7 @@ export function getSidebarContent(
)
);
ideProtocolClient.configUpdate(configJson);
ideProtocolClient.openFile(getConfigJsonPath());
break;
}
case "deleteModel": {

View file

@ -136,7 +136,15 @@ const StyledListboxOption = styled(Listbox.Option)<{ selected: boolean }>`
}
`;
function ListBoxOption({ option, idx }: { option: Option; idx: number }) {
function ListBoxOption({
option,
idx,
showDelete,
}: {
option: Option;
idx: number;
showDelete?: boolean;
}) {
const [hovered, setHovered] = useState(false);
return (
@ -159,7 +167,7 @@ function ListBoxOption({ option, idx }: { option: Option; idx: number }) {
>
<div className="flex items-center justify-between gap-3 h-5 relative">
<span>{option.title}</span>
{hovered && (
{hovered && showDelete && (
<HeaderButtonWithText
text="Delete"
onClick={(e) => {
@ -270,7 +278,12 @@ function ModelSelect(props: {}) {
>
<StyledListboxOptions>
{options.map((option, idx) => (
<ListBoxOption option={option} idx={idx} key={idx} />
<ListBoxOption
option={option}
idx={idx}
key={idx}
showDelete={options.length > 1}
/>
))}
<i className="text-xs ml-2" style={{ color: lightGray }}>
{getMetaKeyLabel()}' to toggle

View file

@ -250,31 +250,6 @@ function ModelConfig() {
/>
);
})}
<CustomModelButton
disabled={disableModelCards()}
onClick={(e) => {
if (!modelInfo || disableModelCards()) return;
const formParams: any = {};
for (const d of modelInfo.collectInputFor || []) {
formParams[d.key] =
d.inputType === "text"
? formMethods.watch(d.key)
: parseFloat(formMethods.watch(d.key));
}
const model = {
...modelInfo.packages[0]?.params,
...modelInfo.params,
...formParams,
};
addModel(model);
dispatch(setDefaultModel(model.title));
navigate("/");
}}
>
<h3 className="text-center my-2">Configure Model in config.json</h3>
</CustomModelButton>
</GridDiv>
</div>
</FormProvider>