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", "noControlImageForControlAdapter": "Control Adapter #{{number}} has no control image",
"noInitialImageSelected": "No initial image selected", "noInitialImageSelected": "No initial image selected",
"noModelForControlAdapter": "Control Adapter #{{number}} has no model 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", "noModelSelected": "No model selected",
"noPrompts": "No prompts generated", "noPrompts": "No prompts generated",
"noNodesInGraph": "No nodes in graph", "noNodesInGraph": "No nodes in graph",

View File

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