feat(ui): sort model select options with compatible base model first

This commit is contained in:
psychedelicious 2023-12-29 09:13:43 +11:00 committed by Kent Keirsey
parent e32eb2a649
commit 77f2aabda4
2 changed files with 7 additions and 2 deletions

View File

@ -1124,7 +1124,7 @@
"noControlImageForControlAdapter": "Control Adapter #{{number}} has no control image",
"noInitialImageSelected": "No initial image selected",
"noModelForControlAdapter": "Control Adapter #{{number}} has no model selected.",
"incompatibleBaseModelForControlAdapter": "Control Adapter #{{number}} model is invalid with main model.",
"incompatibleBaseModelForControlAdapter": "Control Adapter #{{number}} model is incompatible with main model.",
"noModelSelected": "No model selected",
"noPrompts": "No prompts generated",
"noNodesInGraph": "No nodes in graph",

View File

@ -1,4 +1,5 @@
import type { EntityState } from '@reduxjs/toolkit';
import { useAppSelector } from 'app/store/storeHooks';
import type { GroupBase } from 'chakra-react-select';
import { groupBy, map, reduce } from 'lodash-es';
import { useCallback, useMemo } from 'react';
@ -28,6 +29,9 @@ export const useGroupedModelInvSelect = <T extends AnyModelConfigEntity>(
arg: UseGroupedModelInvSelectArg<T>
): UseGroupedModelInvSelectReturn => {
const { t } = useTranslation();
const base_model = useAppSelector(
(state) => state.generation.model?.base_model ?? 'sdxl'
);
const { modelEntities, selectedModel, getIsDisabled, onChange, isLoading } =
arg;
const options = useMemo(() => {
@ -51,8 +55,9 @@ export const useGroupedModelInvSelect = <T extends AnyModelConfigEntity>(
},
[] as GroupBase<InvSelectOption>[]
);
_options.sort((a) => (a.label === base_model ? -1 : 1));
return _options;
}, [getIsDisabled, modelEntities]);
}, [getIsDisabled, modelEntities, base_model]);
const value = useMemo(
() =>