Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Account matrix: cover the gallery move and add-to-project routes (#11767)

Daniel Hanc90a5ca2b025
diff --git a/studio/backend/tests/multi_account/factories_media.py b/studio/backend/tests/multi_account/factories_media.py
index aa9143f9c23..2007406d5ee 100644
--- a/studio/backend/tests/multi_account/factories_media.py
+++ b/studio/backend/tests/multi_account/factories_media.py
@@ -45,6 +45,41 @@ def seed_image(account) -> dict[str, str]:
return {"image_id": record["id"]}
+# The chat project a gallery item is copied into. Seeded in the item's account AND in the calling
+# account, so the caller always has a project by that id and the only thing that can refuse it is
+# the item lookup. With the project only beside the item, a route that found another account's item
+# would still 404 on the missing project, and the matrix could not tell that from isolation.
+MEDIA_PROJECT_ID = "media-project"
+
+
+def _calling_account(actor: str):
+ """The account the matrix sends this actor's request as, when it has one of its own."""
+ from auth import storage
+ from utils.account_context import OWNER
+
+ return {"owner": OWNER, "wrong": storage.get_account("bob")}.get(actor)
+
+
+def _seed_media_project(account) -> None:
+ from storage import studio_db
+ from utils.account_context import run_as
+ run_as(
+ account,
+ studio_db.upsert_chat_project,
+ {"id": MEDIA_PROJECT_ID, "name": SENTINEL, "createdAt": 1000, "updatedAt": 1000},
+ )
+
+
+@seeder("media-image-project")
+def seed_image_and_project(account, actor: str = "right") -> dict[str, str]:
+ params = seed_image(account)
+ _seed_media_project(account)
+ caller = _calling_account(actor)
+ if caller is not None:
+ _seed_media_project(caller)
+ return params
+
+
def _wav_bytes() -> bytes:
import io
import wave
@@ -135,6 +170,16 @@ def seed_video(account) -> dict[str, str]:
return {"video_id": VIDEO_ID}
+@seeder("media-video-project")
+def seed_video_and_project(account, actor: str = "right") -> dict[str, str]:
+ params = seed_video(account)
+ _seed_media_project(account)
+ caller = _calling_account(actor)
+ if caller is not None:
+ _seed_media_project(caller)
+ return params
+
+
@seeder("media-search-image")
def seed_search_image(account) -> dict[str, str]:
import io
@@ -228,6 +273,13 @@ FACTORIES = {
"media-image", {"archived": True}, fragment = SENTINEL
),
"routes.inference:DELETE:/images/gallery/{image_id}": Factory("media-image"),
+ # An empty move (to the front) still has to find the item in the caller's own gallery.
+ "routes.inference:POST:/images/gallery/{image_id}/move": Factory(
+ "media-image", {"after_id": None}, fragment = SENTINEL
+ ),
+ "routes.inference:POST:/images/gallery/{image_id}/project": Factory(
+ "media-image-project", {"project_id": MEDIA_PROJECT_ID}, fragment = "sandbox"
+ ),
"routes.inference:GET:/audio/gallery/{audio_id}/file": Factory("media-audio"),
"routes.inference:PATCH:/audio/gallery/{audio_id}": Factory(
"media-audio", {"archived": True}, fragment = SENTINEL
@@ -254,6 +306,12 @@ FACTORIES = {
"media-video", {"archived": True}, fragment = SENTINEL
),
"routes.video:DELETE:/video/gallery/{video_id}": Factory("media-video"),
+ "routes.video:POST:/video/gallery/{video_id}/move": Factory(
+ "media-video", {"after_id": None}, fragment = SENTINEL
+ ),
+ "routes.video:POST:/video/gallery/{video_id}/project": Factory(
+ "media-video-project", {"project_id": MEDIA_PROJECT_ID}, fragment = "sandbox"
+ ),
"routes.video:GET:/videos/{video_id}": Factory("media-video", fragment = SENTINEL),
"routes.video:GET:/videos/{video_id}/content": Factory("media-video"),
"routes.video:DELETE:/videos/{video_id}": Factory("media-video", fragment = VIDEO_ID),