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.

Merge upstream/main into integration/upstream-main-2026-08-03

joshistoasta91ae3787bbb
diff --cc invokeai/app/api/routers/utilities.py
index 073e6837ff,023f653df6..40115e324b
--- a/invokeai/app/api/routers/utilities.py
+++ b/invokeai/app/api/routers/utilities.py
@@@ -14,13 -16,13 +14,14 @@@ from invokeai.app.api.auth_dependencie
from invokeai.app.api.dependencies import ApiDependencies
from invokeai.app.api.routers._access import assert_image_read_access
from invokeai.app.api.routers.image_move_maintenance import assert_image_move_maintenance_inactive
+ from invokeai.app.services.events.events_base import EventServiceBase
from invokeai.app.services.image_files.image_files_common import ImageFileNotFoundException
from invokeai.app.services.model_records.model_records_base import UnknownModelException
-from invokeai.app.util.dynamicprompts import find_missing_wildcards
+from invokeai.app.services.wildcard_records.wildcard_records_common import build_wildcard_manager
+from invokeai.app.util.dynamicprompts import expand_dynamic_prompt
from invokeai.backend.llava_onevision_pipeline import LlavaOnevisionPipeline
from invokeai.backend.model_manager.taxonomy import ModelType
- from invokeai.backend.text_llm_pipeline import DEFAULT_SYSTEM_PROMPT, TextLLMPipeline
+ from invokeai.backend.text_llm_pipeline import DEFAULT_SYSTEM_PROMPT, ProgressCallback, TextLLMPipeline
from invokeai.backend.util.devices import TorchDevice
logger = logging.getLogger(__name__)
diff --cc invokeai/app/api/sockets.py
index 4f3e625f7b,c1cc753c88..ca5667d59a
--- a/invokeai/app/api/sockets.py
+++ b/invokeai/app/api/sockets.py
@@@ -101,16 -103,8 +105,18 @@@ MODEL_EVENTS =
BULK_DOWNLOAD_EVENTS = {BulkDownloadStartedEvent, BulkDownloadCompleteEvent, BulkDownloadErrorEvent}
WORKFLOW_EVENTS = {WorkflowCreatedEvent, WorkflowUpdatedEvent, WorkflowDeletedEvent}
+MODEL_INSTALL_EVENTS = (
+ ModelInstallDownloadStartedEvent,
+ ModelInstallDownloadProgressEvent,
+ ModelInstallDownloadsCompleteEvent,
+ ModelInstallStartedEvent,
+ ModelInstallCompleteEvent,
+ ModelInstallCancelledEvent,
+ ModelInstallErrorEvent,
+)
+
+ LLM_TASK_EVENTS = {LLMTaskProgressEvent, LLMTaskCompleteEvent, LLMTaskErrorEvent}
+
class SocketIO:
_sub_queue = "subscribe_queue"
@@@ -612,15 -607,22 +619,26 @@@
)
return
- # Model install / download events remain broadcast to all connected sockets - they feed
- # the model manager UI, which is not per-user.
+ # Model install events feed an admin-only UI and may expose details about privileged
+ # operations, so keep the fork's admin-only routing. Other download events retain their
+ # existing broadcast behavior.
+ if isinstance(event_data, MODEL_INSTALL_EVENTS):
+ await self._sio.emit(event=event_name, data=event_data.model_dump(mode="json"), room="admin")
+ return
+
await self._sio.emit(event=event_name, data=event_data.model_dump(mode="json"))
+ async def _handle_llm_task_event(self, event: FastAPIEvent[LLMTaskEventBase]) -> None:
+ """Route LLM utility task events privately to the originating user + admins.
+
+ These events carry partial prompt content (via the task_id correlation) and
+ must not be broadcast to other users.
+ """
+ event_name, event_data = event
+ user_room = f"user:{event_data.user_id}"
+ payload = event_data.model_dump(mode="json")
- await self._sio.emit(event=event_name, data=payload, room=user_room)
- await self._sio.emit(event=event_name, data=payload, room="admin")
++ await self._sio.emit(event=event_name, data=payload, room=[user_room, "admin"])
+
async def _handle_bulk_image_download_event(self, event: FastAPIEvent[BulkDownloadEventBase]) -> None:
event_name, event_data = event
# Route to user-specific + admin rooms so that other authenticated
diff --cc tests/app/test_invocation_event_socketio.py
index 23e2d80d8c,33c71f0cda..d6d06c4de8
--- a/tests/app/test_invocation_event_socketio.py
+++ b/tests/app/test_invocation_event_socketio.py
@@@ -175,7 -161,9 +175,33 @@@ async def test_generic_download_events_
from types import SimpleNamespace
event = SimpleNamespace(model_dump=lambda mode="json": {"id": 1})
- # Not a load event, so it takes the broadcast path (no room argument).
- assert not isinstance(event, ModelInstallStartedEvent)
- await socketio._handle_model_event(("model_install_started", event))
+ await socketio._handle_model_event(("download_started", event))
+
+ socketio._sio.emit.assert_awaited_once_with(event="download_started", data={"id": 1})
+
- socketio._sio.emit.assert_awaited_once_with(event="model_install_started", data={"id": 1})
++
++async def test_llm_task_progress_is_emitted_once_to_owner_and_admin_rooms() -> None:
++ from invokeai.app.services.events.events_common import LLMTaskProgressEvent
++
++ socketio = SocketIO(FastAPI())
++ socketio._sio.emit = AsyncMock()
++
++ event = LLMTaskProgressEvent(
++ task_id="task-1",
++ user_id="owner-1",
++ phase="generating",
++ message="Generating",
++ percentage=0.5,
++ current_tokens=10,
++ total_tokens=20,
++ )
++
++ await socketio._handle_llm_task_event(("llm_task_progress", event))
++
++ socketio._sio.emit.assert_awaited_once_with(
++ event="llm_task_progress",
++ data=event.model_dump(mode="json"),
++ room=["user:owner-1", "admin"],
++ )