Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(webv2): open prompt action popovers when a model is missing

joshistoast14c52a5f3ac6
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index d71f18ce0a..0083bc379c 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -936,6 +936,7 @@
"enableNegativePrompt": "Enable negative prompt",
"enableReferenceImage": "Enable reference image",
"enabled": "Enabled",
+ "enterPromptToExpand": "Enter a prompt to expand.",
"expand": "Expand",
"expandPrompt": "Expand prompt",
"expandReferenceImage": "Expand reference image",
@@ -986,6 +987,7 @@
"noVisionModelInstalled": "No vision model installed",
"offCount_one": "{{count}} off",
"offCount_other": "{{count}} off",
+ "openModelManager": "Open Model Manager",
"override": "Override",
"positivePrompt": "Positive prompt",
"promptHistory": "Prompt history",
diff --git a/invokeai/frontend/webv2/src/app/GenerationUiAdapter.tsx b/invokeai/frontend/webv2/src/app/GenerationUiAdapter.tsx
index 454867f3c1..a2bf040ccf 100644
--- a/invokeai/frontend/webv2/src/app/GenerationUiAdapter.tsx
+++ b/invokeai/frontend/webv2/src/app/GenerationUiAdapter.tsx
@@ -48,7 +48,6 @@ export const GenerationUiAdapterProvider = ({ children }: { children: ReactNode
const session = useAuthSession();
const queryClient = useQueryClient();
const notify = useNotify();
-
const galleryGroup = useMemo<GenerationUiAdapter['gallery']>(
() => ({
selectedImage: selectedGalleryImage,
@@ -64,9 +63,16 @@ export const GenerationUiAdapterProvider = ({ children }: { children: ReactNode
error: modelsError,
getBaseColorPalette: getModelBaseColorPalette,
getBaseLabel: getModelBaseLabel,
+ // Hash navigation, matching the app.selectModelsTab command. Going through
+ // useNavigate or the models UI store would pull either the router hooks or
+ // the store into the editor/launchpad initial bundles (architecture budget).
+ // The manager opens on Add Models by default, which is where this link wants to land.
+ openManager: () => {
+ window.location.hash = `#/models?project=${encodeURIComponent(project.activeProjectId)}`;
+ },
status: modelsStatus,
}),
- [modelsCatalog, modelsError, modelsStatus]
+ [modelsCatalog, modelsError, modelsStatus, project.activeProjectId]
);
const notificationsGroup = useMemo<GenerationUiAdapter['notifications']>(
() => ({ error: notify.error, info: notify.info, reportError: notifications.reportError }),
diff --git a/invokeai/frontend/webv2/src/features/generation/ui/GenerationUiContext.tsx b/invokeai/frontend/webv2/src/features/generation/ui/GenerationUiContext.tsx
index c30be6b8cf..c1ec29b8d4 100644
--- a/invokeai/frontend/webv2/src/features/generation/ui/GenerationUiContext.tsx
+++ b/invokeai/frontend/webv2/src/features/generation/ui/GenerationUiContext.tsx
@@ -52,6 +52,8 @@ export interface GenerationUiAdapter {
error: string | null;
getBaseColorPalette(base: string): string;
getBaseLabel(base: string): string;
+ /** Navigates to the model manager, which opens on Add Models by default. */
+ openManager(): void;
status: 'error' | 'idle' | 'loaded' | 'loading';
};
notifications: {
diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PositivePromptActions.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PositivePromptActions.tsx
index fbbc8addc2..420de9d72b 100644
--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PositivePromptActions.tsx
+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PositivePromptActions.tsx
@@ -41,6 +41,21 @@ import { useTranslation } from 'react-i18next';
const POPOVER_POSITIONING_BOTTOM_END = { placement: 'bottom-end' } as const;
const TEXT_LLM_MODEL_TYPES = ['text_llm'];
const LLAVA_MODEL_TYPES = ['llava_onevision'];
+/**
+ * The way out of an empty state that needs a model installed. Availability is
+ * explained inside the popover rather than by disabling the trigger, so the
+ * dead end always has a door.
+ */
+const OpenModelManagerButton = () => {
+ const { t } = useTranslation();
+ const { openManager } = useGenerationUi().models;
+
+ return (
+ <Button alignSelf="start" px="0" size="xs" variant="plain" onClick={openManager}>
+ {t('widgets.generate.openModelManager')}
+ </Button>
+ );
+};
/**
* Everything the prompt actions know about the applied template, in one prop.
@@ -277,7 +292,10 @@ export const PromptTriggerPopover = ({
<Separator />
<Scrollable flex="1" label={t('widgets.generate.promptTriggerOptions')} minH="0">
{options.length === 0 ? (
- <PromptHistoryEmptyText>{t('widgets.generate.noPromptTriggersAvailable')}</PromptHistoryEmptyText>
+ <Stack align="start" gap="1" px="2">
+ <PromptHistoryEmptyText>{t('widgets.generate.noPromptTriggersAvailable')}</PromptHistoryEmptyText>
+ <OpenModelManagerButton />
+ </Stack>
) : filteredOptions.length === 0 ? (
<PromptHistoryEmptyText>{t('widgets.generate.noMatchingTriggers')}</PromptHistoryEmptyText>
) : (
@@ -427,7 +445,7 @@ const ExpandPromptButton = ({
<Popover.Trigger asChild>
<IconButton
aria-label={t('widgets.generate.expandPrompt')}
- disabled={isDisabled || isLoading || !positivePrompt.trim()}
+ disabled={isDisabled || isLoading}
size="2xs"
variant="ghost"
>
@@ -444,9 +462,12 @@ const ExpandPromptButton = ({
{t('widgets.generate.expandPrompt')}
</Text>
{textLlmModels.length === 0 ? (
- <Text color="fg.subtle" fontSize="xs">
- {t('widgets.generate.installTextLlmToExpandPrompts')}
- </Text>
+ <>
+ <Text color="fg.subtle" fontSize="xs">
+ {t('widgets.generate.installTextLlmToExpandPrompts')}
+ </Text>
+ <OpenModelManagerButton />
+ </>
) : (
<>
<ModelSelect
@@ -462,6 +483,11 @@ const ExpandPromptButton = ({
selectedId={effectiveSystemPromptId}
onSelect={setSelectedSystemPromptId}
/>
+ {positivePrompt.trim() ? null : (
+ <Text color="fg.subtle" fontSize="xs">
+ {t('widgets.generate.enterPromptToExpand')}
+ </Text>
+ )}
<Button
disabled={!selectedModel || !positivePrompt.trim()}
loading={isLoading}
@@ -577,9 +603,12 @@ const ImageToPromptButton = ({
{t('widgets.generate.imageToPrompt')}
</Text>
{llavaModels.length === 0 ? (
- <Text color="fg.subtle" fontSize="xs">
- {t('widgets.generate.installVisionModelToGeneratePrompts')}
- </Text>
+ <>
+ <Text color="fg.subtle" fontSize="xs">
+ {t('widgets.generate.installVisionModelToGeneratePrompts')}
+ </Text>
+ <OpenModelManagerButton />
+ </>
) : (
<>
<ModelSelect