Skip to content

Commit 997e619

Browse files
feat(ui): address feedback
1 parent 4bc184f commit 997e619

File tree

5 files changed

+26
-20
lines changed

5 files changed

+26
-20
lines changed

invokeai/frontend/web/src/features/controlLayers/store/lorasSlice.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
import { createSelector, createSlice, type PayloadAction } from '@reduxjs/toolkit';
22
import type { RootState } from 'app/store/store';
33
import type { SliceConfig } from 'app/store/types';
4+
import type { NumericalParameterConfig } from 'app/types/invokeai';
45
import { paramsReset } from 'features/controlLayers/store/paramsSlice';
56
import { type LoRA, zLoRA } from 'features/controlLayers/store/types';
67
import { zModelIdentifierField } from 'features/nodes/types/common';
7-
import { DEFAULT_LORA_WEIGHT_CONFIG } from 'features/system/store/configSlice';
88
import type { LoRAModelConfig } from 'services/api/types';
99
import { v4 as uuidv4 } from 'uuid';
1010
import z from 'zod';
1111

12+
export const DEFAULT_LORA_WEIGHT_CONFIG: NumericalParameterConfig = {
13+
initial: 0.75,
14+
sliderMin: -1,
15+
sliderMax: 2,
16+
numberInputMin: -10,
17+
numberInputMax: 10,
18+
fineStep: 0.01,
19+
coarseStep: 0.05,
20+
};
21+
1222
const zLoRAsState = z.object({
1323
loras: z.array(zLoRA),
1424
});

invokeai/frontend/web/src/features/lora/components/LoRACard.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
1313
import { InformationalPopover } from 'common/components/InformationalPopover/InformationalPopover';
1414
import {
1515
buildSelectLoRA,
16+
DEFAULT_LORA_WEIGHT_CONFIG,
1617
loraDeleted,
1718
loraIsEnabledChanged,
1819
loraWeightChanged,
1920
} from 'features/controlLayers/store/lorasSlice';
2021
import type { LoRA } from 'features/controlLayers/store/types';
21-
import { DEFAULT_LORA_WEIGHT_CONFIG } from 'features/system/store/configSlice';
2222
import { memo, useCallback, useMemo } from 'react';
2323
import { PiTrashSimpleBold } from 'react-icons/pi';
2424
import { useGetModelConfigQuery } from 'services/api/endpoints/models';
2525

26+
const MARKS = [-1, 0, 1, 2];
27+
2628
export const LoRACard = memo((props: { id: string }) => {
2729
const selectLoRA = useMemo(() => buildSelectLoRA(props.id), [props.id]);
2830
const lora = useAppSelector(selectLoRA);
@@ -80,8 +82,9 @@ const LoRAContent = memo(({ lora }: { lora: LoRA }) => {
8082
onChange={handleChange}
8183
min={DEFAULT_LORA_WEIGHT_CONFIG.sliderMin}
8284
max={DEFAULT_LORA_WEIGHT_CONFIG.sliderMax}
83-
step={DEFAULT_LORA_WEIGHT_CONFIG.fineStep}
84-
marks={DEFAULT_LORA_WEIGHT_CONFIG.marks.slice()}
85+
step={DEFAULT_LORA_WEIGHT_CONFIG.coarseStep}
86+
fineStep={DEFAULT_LORA_WEIGHT_CONFIG.fineStep}
87+
marks={MARKS}
8588
defaultValue={DEFAULT_LORA_WEIGHT_CONFIG.initial}
8689
isDisabled={!lora.isEnabled}
8790
/>
@@ -90,7 +93,8 @@ const LoRAContent = memo(({ lora }: { lora: LoRA }) => {
9093
onChange={handleChange}
9194
min={DEFAULT_LORA_WEIGHT_CONFIG.numberInputMin}
9295
max={DEFAULT_LORA_WEIGHT_CONFIG.numberInputMax}
93-
step={DEFAULT_LORA_WEIGHT_CONFIG.fineStep}
96+
step={DEFAULT_LORA_WEIGHT_CONFIG.coarseStep}
97+
fineStep={DEFAULT_LORA_WEIGHT_CONFIG.fineStep}
9498
w={20}
9599
flexShrink={0}
96100
defaultValue={DEFAULT_LORA_WEIGHT_CONFIG.initial}

invokeai/frontend/web/src/features/modelManagerV2/hooks/useLoRAModelDefaultSettings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { isNil } from 'es-toolkit/compat';
2-
import { DEFAULT_LORA_WEIGHT_CONFIG } from 'features/system/store/configSlice';
2+
import { DEFAULT_LORA_WEIGHT_CONFIG } from 'features/controlLayers/store/lorasSlice';
33
import { useMemo } from 'react';
44
import type { LoRAModelConfig } from 'services/api/types';
55

invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/LoRAModelDefaultSettings/DefaultWeight.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { CompositeNumberInput, CompositeSlider, Flex, FormControl, FormLabel } from '@invoke-ai/ui-library';
22
import { InformationalPopover } from 'common/components/InformationalPopover/InformationalPopover';
3+
import { DEFAULT_LORA_WEIGHT_CONFIG } from 'features/controlLayers/store/lorasSlice';
34
import { SettingToggle } from 'features/modelManagerV2/subpanels/ModelPanel/SettingToggle';
4-
import { DEFAULT_LORA_WEIGHT_CONFIG } from 'features/system/store/configSlice';
55
import { memo, useCallback, useMemo } from 'react';
66
import type { UseControllerProps } from 'react-hook-form';
77
import { useController } from 'react-hook-form';
88
import { useTranslation } from 'react-i18next';
99

1010
import type { LoRAModelDefaultSettingsFormData } from './LoRAModelDefaultSettings';
1111

12+
const MARKS = [-1, 0, 1, 2];
13+
1214
type DefaultWeight = LoRAModelDefaultSettingsFormData['weight'];
1315

1416
export const DefaultWeight = memo((props: UseControllerProps<LoRAModelDefaultSettingsFormData, 'weight'>) => {
@@ -51,7 +53,7 @@ export const DefaultWeight = memo((props: UseControllerProps<LoRAModelDefaultSet
5153
step={DEFAULT_LORA_WEIGHT_CONFIG.coarseStep}
5254
fineStep={DEFAULT_LORA_WEIGHT_CONFIG.fineStep}
5355
onChange={onChange}
54-
marks={DEFAULT_LORA_WEIGHT_CONFIG.marks.slice()}
56+
marks={MARKS}
5557
isDisabled={isDisabled}
5658
/>
5759
<CompositeNumberInput

invokeai/frontend/web/src/features/system/store/configSlice.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,11 @@ import type { PayloadAction, Selector } from '@reduxjs/toolkit';
22
import { createSelector, createSlice } from '@reduxjs/toolkit';
33
import type { RootState } from 'app/store/store';
44
import type { SliceConfig } from 'app/store/types';
5-
import { getDefaultAppConfig, type PartialAppConfig, zAppConfig } from 'app/types/invokeai';
5+
import type { PartialAppConfig } from 'app/types/invokeai';
6+
import { getDefaultAppConfig, zAppConfig } from 'app/types/invokeai';
67
import { merge } from 'es-toolkit/compat';
78
import z from 'zod';
89

9-
export const DEFAULT_LORA_WEIGHT_CONFIG = {
10-
initial: 0.75,
11-
sliderMin: -1,
12-
sliderMax: 2,
13-
marks: [-1, 0, 1, 2],
14-
numberInputMin: -10,
15-
numberInputMax: 10,
16-
fineStep: 0.01,
17-
coarseStep: 0.05,
18-
} as const;
19-
2010
const zConfigState = z.object({
2111
...zAppConfig.shape,
2212
didLoad: z.boolean(),

0 commit comments

Comments
 (0)