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(ui): run the install runtime app-wide

joshistoast02e28a032422
diff --git a/invokeai/frontend/webv2/src/app/router.tsx b/invokeai/frontend/webv2/src/app/router.tsx
index ac8b302e40..85d22b99be 100644
--- a/invokeai/frontend/webv2/src/app/router.tsx
+++ b/invokeai/frontend/webv2/src/app/router.tsx
@@ -8,6 +8,7 @@ import {
useAuthSession,
type Capabilities,
} from '@features/identity';
+import { ModelInstallRuntime } from '@features/models';
import {
createHashHistory,
createRootRoute,
@@ -64,9 +65,11 @@ const RouterError = ({ error }: ErrorComponentProps) => {
const rootRoute = createRootRoute({ component: Outlet, errorComponent: RouterError });
/**
- * Wraps every authenticated route with the shared backend socket transport.
- * Feature runtimes attach their own listeners only where needed, keeping the
- * light Launchpad bundle free of editor/model-manager code.
+ * Wraps every authenticated route with the shared backend socket transport
+ * and the model-install runtime — installs must progress and toast no matter
+ * which surface started them. Heavier feature runtimes still attach their own
+ * listeners only where needed, keeping the light Launchpad bundle free of
+ * editor/model-manager view code.
*/
const AuthenticatedLayout = () => {
const session = useAuthSession();
@@ -82,6 +85,7 @@ const AuthenticatedLayout = () => {
return (
<Fragment key={session.accountEpoch}>
<SocketHubRuntime />
+ <ModelInstallRuntime />
<Outlet />
</Fragment>
);
diff --git a/invokeai/frontend/webv2/src/features/models/index.ts b/invokeai/frontend/webv2/src/features/models/index.ts
index 12911f7b07..4699d02aa9 100644
--- a/invokeai/frontend/webv2/src/features/models/index.ts
+++ b/invokeai/frontend/webv2/src/features/models/index.ts
@@ -22,5 +22,6 @@ export {
type ModelLoadActivitySink,
type ModelLoadInfo,
} from './data/modelLoadStore';
+export { ModelInstallRuntime } from './ui/ModelInstallRuntime';
export { ModelsPage } from './ui/ModelsPage';
export { ModelsUiProvider, type ModelsUiAdapter } from './ui/ModelsUiContext';
diff --git a/invokeai/frontend/webv2/src/features/models/ui/ModelInstallRuntime.tsx b/invokeai/frontend/webv2/src/features/models/ui/ModelInstallRuntime.tsx
index 24a7a79400..0c708351e8 100644
--- a/invokeai/frontend/webv2/src/features/models/ui/ModelInstallRuntime.tsx
+++ b/invokeai/frontend/webv2/src/features/models/ui/ModelInstallRuntime.tsx
@@ -1,9 +1,10 @@
import {
+ getInstallsSnapshot,
handleModelInstallSocketEvent,
MODEL_INSTALL_SOCKET_EVENTS,
refreshInstalls,
} from '@features/models/data/installsStore';
-import { refreshModels } from '@features/models/data/modelsStore';
+import { getModelsSnapshot, refreshModels } from '@features/models/data/modelsStore';
import { useMountEffect } from '@platform/react/useMountEffect';
import { captureAccountScope, isAccountScopeCurrent } from '@platform/state/accountLifecycle';
import { getConnectionStatus, subscribeConnection } from '@platform/transport/connectionStore';
@@ -11,7 +12,13 @@ import { socketHub } from '@platform/transport/socketHub';
import { useInstallOutcomeToasts } from './useInstallOutcomeToasts';
-/** Admin model-manager runtime: install socket events, reconnect refresh, and outcome toasts. */
+/**
+ * App-wide install runtime: install socket events, reconnect refresh, and
+ * outcome toasts. Mounted once in the authenticated layout so installs
+ * progress, refresh the library, and announce completion no matter which
+ * surface queued them. Exactly one instance may exist — the outcome toasts
+ * keep per-instance seen state.
+ */
export const ModelInstallRuntime = () => {
useMountEffect(() => {
const owner = captureAccountScope();
@@ -29,8 +36,19 @@ export const ModelInstallRuntime = () => {
useMountEffect(() => {
const owner = captureAccountScope();
const refreshOnConnect = () => {
- if (isAccountScopeCurrent(owner) && getConnectionStatus().status === 'connected') {
+ if (!isAccountScopeCurrent(owner) || getConnectionStatus().status !== 'connected') {
+ return;
+ }
+
+ // Only revalidate stores something already read — an app-wide mount
+ // must not fetch model data for sessions that never open a models
+ // surface. An install finishing while a store is idle still lands via
+ // the socket handler's scheduled refresh.
+ if (getModelsSnapshot().status !== 'idle') {
void refreshModels();
+ }
+
+ if (getInstallsSnapshot().status !== 'idle') {
void refreshInstalls();
}
};
diff --git a/invokeai/frontend/webv2/src/features/models/ui/ModelManagerView.tsx b/invokeai/frontend/webv2/src/features/models/ui/ModelManagerView.tsx
index 8b16c08027..7bae18ca2a 100644
--- a/invokeai/frontend/webv2/src/features/models/ui/ModelManagerView.tsx
+++ b/invokeai/frontend/webv2/src/features/models/ui/ModelManagerView.tsx
@@ -1,6 +1,5 @@
import { Flex } from '@chakra-ui/react';
import { ensureModelsLoaded } from '@features/models/data/modelsStore';
-import { ModelInstallRuntime } from '@features/models/ui/ModelInstallRuntime';
import { useMountEffect } from '@platform/react/useMountEffect';
import { DetailPane } from './manager/DetailPane';
@@ -14,7 +13,6 @@ export const ModelManagerView = () => {
return (
<Flex direction="column" h="full" minH="0" w="full">
- <ModelInstallRuntime />
<Flex flex="1" minH="0" w="full">
<LibraryColumn />
<DetailPane />
diff --git a/invokeai/frontend/webv2/src/features/models/ui/launchpad/ModelsNotice.tsx b/invokeai/frontend/webv2/src/features/models/ui/launchpad/ModelsNotice.tsx
index 1ff7234f3f..a177f2b5f2 100644
--- a/invokeai/frontend/webv2/src/features/models/ui/launchpad/ModelsNotice.tsx
+++ b/invokeai/frontend/webv2/src/features/models/ui/launchpad/ModelsNotice.tsx
@@ -1,21 +1,15 @@
import type { StarterModelBundle } from '@features/models/core/types';
import { Flex, Icon, Spinner, Stack, Text, Wrap } from '@chakra-ui/react';
-import {
- ensureInstallsLoaded,
- isActiveInstallStatus,
- refreshInstalls,
- useInstallsSelector,
-} from '@features/models/data/installsStore';
-import { ensureModelsLoaded, refreshModels, useModelsSelector } from '@features/models/data/modelsStore';
+import { ensureInstallsLoaded, isActiveInstallStatus, useInstallsSelector } from '@features/models/data/installsStore';
+import { ensureModelsLoaded, useModelsSelector } from '@features/models/data/modelsStore';
import { ensureStartersLoaded, useStartersSelector } from '@features/models/data/startersStore';
import { getStarterBundleInstallSources } from '@features/models/ui/add-models/starterModelInstallSources';
import { useInstallActions } from '@features/models/ui/add-models/useInstallActions';
import { useMountEffect } from '@platform/react/useMountEffect';
-import { captureAccountScope, isAccountScopeCurrent } from '@platform/state/accountLifecycle';
import { Button } from '@platform/ui/Button';
import { BoxIcon } from 'lucide-react';
-import { useCallback, useEffect, useMemo } from 'react';
+import { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
/**
@@ -28,8 +22,6 @@ import { useTranslation } from 'react-i18next';
* has something in it.
*/
-const INSTALL_POLL_INTERVAL_MS = 2_500;
-
const EMPTY_BUNDLES: Record<string, StarterModelBundle> = {};
const PANEL_STYLE = {
@@ -56,37 +48,6 @@ export const ModelsNotice = () => {
ensureInstallsLoaded();
});
- /**
- * Installs started here would otherwise sit on "Installing…" forever: the
- * socket handling, reconnect refresh, and completion toasts all live in
- * `ModelInstallRuntime`, which only the model manager mounts. Mounting a
- * second copy of that runtime is not an option — its outcome toasts keep
- * per-instance state, so Home and an already-visited Models section would
- * each announce every install.
- *
- * Polling only while something is actually installing keeps this to the
- * window where it matters, and both refreshes de-duplicate in flight.
- */
- useEffect(() => {
- if (activeInstallCount === 0) {
- return;
- }
-
- const owner = captureAccountScope();
- const interval = setInterval(() => {
- if (!isAccountScopeCurrent(owner)) {
- return;
- }
-
- void refreshInstalls(owner);
- void refreshModels(owner);
- }, INSTALL_POLL_INTERVAL_MS);
-
- return () => {
- clearInterval(interval);
- };
- }, [activeInstallCount]);
-
// Nothing to say until the library has actually been read; guessing "you
// have no models" during the first fetch would be a lie half the time.
if (modelsStatus !== 'loaded' || modelCount > 0) {