From 8fd93427124eee84feefad76de6105a5f918f6d5 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Thu, 7 Mar 2024 15:36:58 +1100 Subject: [PATCH] fix(ui): typing issues related to trigger phrase changes --- .../subpanels/ModelPanel/Metadata/TriggerPhrases.tsx | 6 +++++- .../web/src/features/prompt/PromptTriggerSelect.tsx | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Metadata/TriggerPhrases.tsx b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Metadata/TriggerPhrases.tsx index 3e7adb7ed4..c3cfa7a59a 100644 --- a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Metadata/TriggerPhrases.tsx +++ b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/Metadata/TriggerPhrases.tsx @@ -15,6 +15,7 @@ import type { ChangeEvent } from 'react'; import { useCallback, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useGetModelConfigQuery, useUpdateModelMutation } from 'services/api/endpoints/models'; +import { isNonRefinerMainModelConfig } from 'services/api/types'; export const TriggerPhrases = () => { const { t } = useTranslation(); @@ -29,8 +30,11 @@ export const TriggerPhrases = () => { }, []); const triggerPhrases = useMemo(() => { + if (!modelConfig || !isNonRefinerMainModelConfig(modelConfig)) { + return []; + } return modelConfig?.trigger_phrases || []; - }, [modelConfig?.trigger_phrases]); + }, [modelConfig]); const errors = useMemo(() => { const errors = []; diff --git a/invokeai/frontend/web/src/features/prompt/PromptTriggerSelect.tsx b/invokeai/frontend/web/src/features/prompt/PromptTriggerSelect.tsx index 06055af9bd..9da7876e52 100644 --- a/invokeai/frontend/web/src/features/prompt/PromptTriggerSelect.tsx +++ b/invokeai/frontend/web/src/features/prompt/PromptTriggerSelect.tsx @@ -18,6 +18,7 @@ import { useGetModelConfigQuery, useGetTextualInversionModelsQuery, } from 'services/api/endpoints/models'; +import { isNonRefinerMainModelConfig } from 'services/api/types'; const noOptionsMessage = () => t('prompt.noMatchingTriggers'); @@ -84,7 +85,7 @@ export const PromptTriggerSelect = memo(({ onSelect, onClose }: PromptTriggerSel } } - if (mainModelConfig && mainModelConfig.trigger_phrases?.length) { + if (mainModelConfig && isNonRefinerMainModelConfig(mainModelConfig) && mainModelConfig.trigger_phrases?.length) { _options.push({ label: t('modelManager.mainModelTriggerPhrases'), options: mainModelConfig.trigger_phrases.map((triggerPhrase) => ({