diff --git a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/controlAdapterAutoProcessorUpdateListener.ts b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/controlAdapterAutoProcessorUpdateListener.ts index 3c8d87e4f7..c78fddd87e 100644 --- a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/controlAdapterAutoProcessorUpdateListener.ts +++ b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/controlAdapterAutoProcessorUpdateListener.ts @@ -1,9 +1,9 @@ import { isAnyOf } from '@reduxjs/toolkit'; import type { AppStartListening } from 'app/store/middleware/listenerMiddleware'; -import { controlAdapterModelChanged } from 'features/controlAdapters/store/actions'; import { CONTROLNET_MODEL_DEFAULT_PROCESSORS } from 'features/controlAdapters/store/constants'; import { controlAdapterAutoConfigToggled, + controlAdapterModelChanged, controlAdapterProcessortTypeChanged, selectControlAdapterById, } from 'features/controlAdapters/store/controlAdaptersSlice'; diff --git a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/controlNetAutoProcess.ts b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/controlNetAutoProcess.ts index 88cb72dd86..e52df30681 100644 --- a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/controlNetAutoProcess.ts +++ b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/controlNetAutoProcess.ts @@ -2,10 +2,11 @@ import type { AnyListenerPredicate } from '@reduxjs/toolkit'; import { logger } from 'app/logging/logger'; import type { AppStartListening } from 'app/store/middleware/listenerMiddleware'; import type { RootState } from 'app/store/store'; -import { controlAdapterImageProcessed, controlAdapterModelChanged } from 'features/controlAdapters/store/actions'; +import { controlAdapterImageProcessed } from 'features/controlAdapters/store/actions'; import { controlAdapterAutoConfigToggled, controlAdapterImageChanged, + controlAdapterModelChanged, controlAdapterProcessorParamsChanged, controlAdapterProcessortTypeChanged, selectControlAdapterById, diff --git a/invokeai/frontend/web/src/features/controlAdapters/components/parameters/ParamControlAdapterModel.tsx b/invokeai/frontend/web/src/features/controlAdapters/components/parameters/ParamControlAdapterModel.tsx index b0ebaf1985..c475a01047 100644 --- a/invokeai/frontend/web/src/features/controlAdapters/components/parameters/ParamControlAdapterModel.tsx +++ b/invokeai/frontend/web/src/features/controlAdapters/components/parameters/ParamControlAdapterModel.tsx @@ -5,10 +5,10 @@ import { useControlAdapterIsEnabled } from 'features/controlAdapters/hooks/useCo import { useControlAdapterModel } from 'features/controlAdapters/hooks/useControlAdapterModel'; import { useControlAdapterModelQuery } from 'features/controlAdapters/hooks/useControlAdapterModelQuery'; import { useControlAdapterType } from 'features/controlAdapters/hooks/useControlAdapterType'; -import { controlAdapterModelChanged } from 'features/controlAdapters/store/actions'; import { getModelKeyAndBase } from 'features/metadata/util/modelFetchingHelpers'; import { memo, useCallback, useMemo } from 'react'; import type { ControlNetModelConfig, IPAdapterModelConfig, T2IAdapterModelConfig } from 'services/api/types'; +import { controlAdapterModelChanged } from '../../store/controlAdaptersSlice'; type ParamControlAdapterModelProps = { id: string; @@ -25,7 +25,6 @@ const ParamControlAdapterModel = ({ id }: ParamControlAdapterModelProps) => { const _onChange = useCallback( (model: ControlNetModelConfig | IPAdapterModelConfig | T2IAdapterModelConfig | null) => { - console.log('on change'); if (!model) { return; } diff --git a/invokeai/frontend/web/src/features/controlAdapters/store/actions.ts b/invokeai/frontend/web/src/features/controlAdapters/store/actions.ts index 979a980572..319ba3efe1 100644 --- a/invokeai/frontend/web/src/features/controlAdapters/store/actions.ts +++ b/invokeai/frontend/web/src/features/controlAdapters/store/actions.ts @@ -1,15 +1,5 @@ import { createAction } from '@reduxjs/toolkit'; -import type { - ParameterControlNetModel, - ParameterIPAdapterModel, - ParameterT2IAdapterModel, -} from 'features/parameters/types/parameterSchemas'; export const controlAdapterImageProcessed = createAction<{ id: string; -}>('controlAdapters/imageProcessed'); - -export const controlAdapterModelChanged = createAction<{ - id: string; - model: ParameterControlNetModel | ParameterT2IAdapterModel | ParameterIPAdapterModel; -}>('controlAdapters/controlAdapterModelChanged'); +}>('controlAdapters/imageProcessed'); \ No newline at end of file diff --git a/invokeai/frontend/web/src/features/controlAdapters/store/controlAdaptersSlice.ts b/invokeai/frontend/web/src/features/controlAdapters/store/controlAdaptersSlice.ts index edf3beba32..fe143dd447 100644 --- a/invokeai/frontend/web/src/features/controlAdapters/store/controlAdaptersSlice.ts +++ b/invokeai/frontend/web/src/features/controlAdapters/store/controlAdaptersSlice.ts @@ -21,6 +21,7 @@ import type { T2IAdapterConfig, } from './types'; import { isControlNet, isControlNetOrT2IAdapter, isIPAdapter, isT2IAdapter } from './types'; +import { ParameterControlNetModel, ParameterT2IAdapterModel, ParameterIPAdapterModel } from '../../parameters/types/parameterSchemas'; const caAdapter = createEntityAdapter({ selectId: (ca) => ca.id, @@ -182,6 +183,33 @@ export const controlAdaptersSlice = createSlice({ changes: { model: null }, }); }, + controlAdapterModelChanged: ( + state, + action: PayloadAction<{ + id: string; + model: ParameterControlNetModel | ParameterT2IAdapterModel | ParameterIPAdapterModel; + }> + ) => { + const { id, model } = action.payload; + const cn = selectControlAdapterById(state, id); + if (!cn) { + return; + } + + if (!isControlNetOrT2IAdapter(cn)) { + caAdapter.updateOne(state, { id, changes: { model } }); + return; + } + + const update: Update = { + id, + changes: { model, shouldAutoConfig: true }, + }; + + update.changes.processedControlImage = null; + + caAdapter.updateOne(state, update); + }, controlAdapterWeightChanged: (state, action: PayloadAction<{ id: string; weight: number }>) => { const { id, weight } = action.payload; caAdapter.updateOne(state, { id, changes: { weight } }); @@ -319,6 +347,7 @@ export const { controlAdapterImageChanged, controlAdapterProcessedImageChanged, controlAdapterIsEnabledChanged, + controlAdapterModelChanged, controlAdapterWeightChanged, controlAdapterBeginStepPctChanged, controlAdapterEndStepPctChanged,