From e1ae7842ff600ad6434b36c6d7cbce120dc93dd9 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Tue, 30 May 2023 22:12:21 +1000 Subject: [PATCH] feat(ui): add `defaultModel` to config --- invokeai/frontend/web/src/app/types/invokeai.ts | 1 + .../src/features/parameters/store/generationSlice.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/invokeai/frontend/web/src/app/types/invokeai.ts b/invokeai/frontend/web/src/app/types/invokeai.ts index 0de1d8c84b..409a37ac36 100644 --- a/invokeai/frontend/web/src/app/types/invokeai.ts +++ b/invokeai/frontend/web/src/app/types/invokeai.ts @@ -351,6 +351,7 @@ export type AppConfig = { disabledSDFeatures: SDFeature[]; canRestoreDeletedImagesFromBin: boolean; sd: { + defaultModel?: string; iterations: { initial: number; min: number; diff --git a/invokeai/frontend/web/src/features/parameters/store/generationSlice.ts b/invokeai/frontend/web/src/features/parameters/store/generationSlice.ts index 9b2539550b..75e724ed4c 100644 --- a/invokeai/frontend/web/src/features/parameters/store/generationSlice.ts +++ b/invokeai/frontend/web/src/features/parameters/store/generationSlice.ts @@ -2,11 +2,12 @@ import type { PayloadAction } from '@reduxjs/toolkit'; import { createSlice } from '@reduxjs/toolkit'; import * as InvokeAI from 'app/types/invokeai'; import promptToString from 'common/util/promptToString'; -import { clamp, sample, sortBy } from 'lodash-es'; +import { clamp, sortBy } from 'lodash-es'; import { setAllParametersReducer } from './setAllParametersReducer'; import { receivedModels } from 'services/thunks/model'; import { Scheduler } from 'app/constants'; import { ImageDTO } from 'services/api'; +import { configChanged } from 'features/system/store/configSlice'; export interface GenerationState { cfgScale: number; @@ -231,6 +232,13 @@ export const generationSlice = createSlice({ state.model = firstModel.name; } }); + + builder.addCase(configChanged, (state, action) => { + const defaultModel = action.payload.sd?.defaultModel; + if (defaultModel && !state.model) { + state.model = defaultModel; + } + }); }, });