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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(api): prevent stale gallery star state
joshistoast2297e19faafe
diff --git a/invokeai/app/api/routers/gallery.py b/invokeai/app/api/routers/gallery.pyindex 0cecd05615..92a5c6795c 100644--- a/invokeai/app/api/routers/gallery.py+++ b/invokeai/app/api/routers/gallery.py@@ -1,7 +1,7 @@from datetime import datefrom typing import Optional-from fastapi import HTTPException, Query+from fastapi import HTTPException, Query, Responsefrom fastapi.routing import APIRouterfrom invokeai.app.api.auth_dependencies import CurrentUserOrDefault@@ -13,6 +13,7 @@ from invokeai.app.services.shared.pagination import MAX_PAGE_SIZE, OffsetPaginatfrom invokeai.app.services.shared.sqlite.sqlite_common import SQLiteDirectiongallery_router = APIRouter(prefix="/v1/gallery", tags=["gallery"])+GALLERY_CACHE_CONTROL = "private, no-store"@gallery_router.get(@@ -22,6 +23,7 @@ gallery_router = APIRouter(prefix="/v1/gallery", tags=["gallery"]))async def list_gallery_items(current_user: CurrentUserOrDefault,+ response: Response,origin: Optional[ResourceOrigin] = Query(default=None, description="The origin of items to list."),categories: Optional[list[ImageCategory]] = Query(default=None,@@ -47,6 +49,8 @@ async def list_gallery_items(),) -> OffsetPaginatedResults[GalleryItem]:"""Returns a paginated, time-sorted stream of polymorphic gallery items (images + videos)."""+ response.headers["Cache-Control"] = GALLERY_CACHE_CONTROL+if board_id is not None and board_id != "none":_assert_board_read_access(board_id, current_user)@@ -74,6 +78,7 @@ async def list_gallery_items()async def get_gallery_item_names(current_user: CurrentUserOrDefault,+ response: Response,origin: Optional[ResourceOrigin] = Query(default=None, description="The origin of items to list."),categories: Optional[list[ImageCategory]] = Query(default=None,@@ -95,6 +100,8 @@ async def get_gallery_item_names(),) -> GalleryItemNamesResult:"""Returns an ordered (kind, name) list — used to drive virtualized gallery selection."""+ response.headers["Cache-Control"] = GALLERY_CACHE_CONTROL+if board_id is not None and board_id != "none":_assert_board_read_access(board_id, current_user)diff --git a/tests/app/routers/test_gallery.py b/tests/app/routers/test_gallery.pyindex ae1219fcd7..31057bf467 100644--- a/tests/app/routers/test_gallery.py+++ b/tests/app/routers/test_gallery.py@@ -48,6 +48,18 @@ def test_gallery_list_endpoints_parse_and_forward_created_ranges(assert kwargs["created_to"] == "2026-07-15"[email protected]("path", ["/api/v1/gallery/items/", "/api/v1/gallery/items/names"])+def test_gallery_list_endpoints_disable_browser_caching(+ monkeypatch: Any, mock_invoker: Invoker, client: TestClient, path: str+) -> None:+ _prepare_gallery_router_test(monkeypatch, mock_invoker)++ response = client.get(path)++ assert response.status_code == 200+ assert response.headers["cache-control"] == "private, no-store"++@pytest.mark.parametrize("path", ["/api/v1/gallery/items/", "/api/v1/gallery/items/names"])@pytest.mark.parametrize("param", ["created_from", "created_to"])def test_gallery_list_endpoints_reject_invalid_created_range_dates(