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(projects): un-archive a board when a project claims it

Josh Corbett838bd72db7ee
diff --git a/invokeai/app/services/project_records/project_records_sqlite.py b/invokeai/app/services/project_records/project_records_sqlite.py
index 698f84c722..2350474756 100644
--- a/invokeai/app/services/project_records/project_records_sqlite.py
+++ b/invokeai/app/services/project_records/project_records_sqlite.py
@@ -302,9 +302,12 @@ class ProjectRecordsSqlite(ProjectRecordsStorageBase):
if row[1] != BoardVisibility.Private.value or row[2] or row[3]:
raise ProjectBoardUnavailableError(board_id)
+ # Un-archived as well as renamed. A project's board takes its archived state from the
+ # project, and `PATCH /boards/{id}` refuses to set it on a claimed board — so a board that
+ # arrived archived would be invisible in every listing with no API left to fix it.
cursor.execute(
"""--sql
- UPDATE boards SET board_name = ? WHERE board_id = ?;
+ UPDATE boards SET board_name = ?, archived = FALSE WHERE board_id = ?;
""",
(name[:BOARD_NAME_MAX_LENGTH], board_id),
)
diff --git a/invokeai/app/services/shared/sqlite_migrator/migrations/migration_2026_08_06_add_project_boards.py b/invokeai/app/services/shared/sqlite_migrator/migrations/migration_2026_08_06_add_project_boards.py
index f13a434247..5b54209278 100644
--- a/invokeai/app/services/shared/sqlite_migrator/migrations/migration_2026_08_06_add_project_boards.py
+++ b/invokeai/app/services/shared/sqlite_migrator/migrations/migration_2026_08_06_add_project_boards.py
@@ -66,9 +66,14 @@ class AddProjectBoardsMigrationCallback:
if board_id is None:
board_id = self._insert_board(cursor, user_id=user_id, name=name)
else:
+ # Un-archived as well as renamed, and for the same reason the claim path does it:
+ # a project's board follows the project, and the generic board API refuses to
+ # change `archived` on a claimed board. Someone who had archived their project's
+ # gallery board before upgrading would otherwise end up with a project whose board
+ # is invisible in every listing and unreachable by any route.
cursor.execute(
"""--sql
- UPDATE boards SET board_name = ? WHERE board_id = ?;
+ UPDATE boards SET board_name = ?, archived = FALSE WHERE board_id = ?;
""",
(name[:BOARD_NAME_MAX_LENGTH], board_id),
)
@@ -78,9 +83,7 @@ class AddProjectBoardsMigrationCallback:
return assignments
- def _adopt_board(
- self, cursor: sqlite3.Cursor, *, user_id: str, data: str, claimed: set[str]
- ) -> Optional[str]:
+ def _adopt_board(self, cursor: sqlite3.Cursor, *, user_id: str, data: str, claimed: set[str]) -> Optional[str]:
"""Return the project's existing board if exactly one candidate is safe to adopt."""
candidates = _collect_board_candidates(data)
diff --git a/tests/app/services/project_records/test_project_records.py b/tests/app/services/project_records/test_project_records.py
index 31e7ee3b95..38aacefce8 100644
--- a/tests/app/services/project_records/test_project_records.py
+++ b/tests/app/services/project_records/test_project_records.py
@@ -151,15 +151,23 @@ def _insert_board(
user_id: str = SYSTEM_USER_ID,
name: str = "Loose board",
visibility: str = "private",
+ archived: bool = False,
) -> str:
with db.transaction() as cursor:
cursor.execute(
- "INSERT INTO boards (board_id, board_name, user_id, board_visibility) VALUES (?, ?, ?, ?);",
- (board_id, name, user_id, visibility),
+ "INSERT INTO boards (board_id, board_name, user_id, board_visibility, archived) VALUES (?, ?, ?, ?, ?);",
+ (board_id, name, user_id, visibility, archived),
)
return board_id
+def _board_is_archived(db: SqliteDatabase, board_id: str) -> bool:
+ with db.transaction() as cursor:
+ cursor.execute("SELECT archived FROM boards WHERE board_id = ?;", (board_id,))
+ row = cursor.fetchone()
+ return bool(row[0])
+
+
def _board_name(db: SqliteDatabase, board_id: str) -> str | None:
with db.transaction() as cursor:
cursor.execute("SELECT board_name FROM boards WHERE board_id = ?;", (board_id,))
@@ -210,6 +218,24 @@ def test_create_claims_a_supplied_board_and_renames_it(
assert _board_count(db) == before
+def test_claiming_a_board_un_archives_it(project_records: ProjectRecordsSqlite, db: SqliteDatabase) -> None:
+ """A project's board follows the project, and `PATCH /boards/{id}` refuses `archived` on a
+ claimed board — so a board claimed while archived would be invisible in every listing with no
+ route left to bring it back."""
+ _insert_board(db, "staging-board", name="Untitled", archived=True)
+
+ created = project_records.create(SYSTEM_USER_ID, "Imported", {}, board_id="staging-board")
+
+ assert created.board_id == "staging-board"
+ assert _board_is_archived(db, "staging-board") is False
+
+
+def test_a_project_creates_its_board_un_archived(project_records: ProjectRecordsSqlite, db: SqliteDatabase) -> None:
+ created = project_records.create(SYSTEM_USER_ID, "My Project", {})
+
+ assert _board_is_archived(db, created.board_id) is False
+
+
def test_claiming_a_missing_or_foreign_board_reports_it_as_missing(
project_records: ProjectRecordsSqlite, db: SqliteDatabase, other_user_id: str
) -> None:
@@ -395,9 +421,7 @@ def test_the_snapshot_excludes_what_the_gallery_does_not_show(
assert [item.name for item in snapshot.items] == ["shown.png", "shown.mp4"]
-def test_the_snapshot_excludes_media_on_other_boards(
- project_records: ProjectRecordsSqlite, db: SqliteDatabase
-) -> None:
+def test_the_snapshot_excludes_media_on_other_boards(project_records: ProjectRecordsSqlite, db: SqliteDatabase) -> None:
mine = project_records.create(SYSTEM_USER_ID, "Mine", {})
theirs = project_records.create(SYSTEM_USER_ID, "Other", {})
_put_image(db, "mine.png", mine.board_id)
diff --git a/tests/app/services/shared/sqlite_migrator/migrations/test_migration_2026_08_06_add_project_boards.py b/tests/app/services/shared/sqlite_migrator/migrations/test_migration_2026_08_06_add_project_boards.py
index 924bca8675..759c16515c 100644
--- a/tests/app/services/shared/sqlite_migrator/migrations/test_migration_2026_08_06_add_project_boards.py
+++ b/tests/app/services/shared/sqlite_migrator/migrations/test_migration_2026_08_06_add_project_boards.py
@@ -101,10 +101,11 @@ def _add_board(
user_id: str = "u1",
name: str = "Board",
visibility: str = "private",
+ archived: bool = False,
) -> None:
db.execute(
- "INSERT INTO boards (board_id, board_name, user_id, board_visibility) VALUES (?, ?, ?, ?);",
- (board_id, name, user_id, visibility),
+ "INSERT INTO boards (board_id, board_name, user_id, board_visibility, archived) VALUES (?, ?, ?, ?, ?);",
+ (board_id, name, user_id, visibility, archived),
)
@@ -138,9 +139,7 @@ def _add_project(
def _board_of(db: sqlite3.Connection, project_id: str, user_id: str = "u1") -> str:
- cursor = db.execute(
- "SELECT board_id FROM projects WHERE user_id = ? AND project_id = ?;", (user_id, project_id)
- )
+ cursor = db.execute("SELECT board_id FROM projects WHERE user_id = ? AND project_id = ?;", (user_id, project_id))
row = cursor.fetchone()
assert row is not None
return row[0]
@@ -288,6 +287,22 @@ def test_a_created_board_is_private_unarchived_and_owned_by_the_project_owner()
assert row == ("Fresh project", "u1", "private", 0)
+def test_an_adopted_board_is_un_archived() -> None:
+ """Someone who archived their project's gallery board before upgrading would otherwise end up
+ with a project whose board is hidden from every listing, and no route left to unhide it: the
+ generic board API refuses `archived` on a claimed board, and there is no project archive API."""
+ db = _make_db()
+ _add_user(db, "u1")
+ _add_board(db, "b1", name="Archived board", archived=True)
+ _add_project(db, "p1", name="Project", data=_gallery_document("b1"))
+
+ _run(db)
+
+ assert _board_of(db, "p1") == "b1"
+ archived = db.execute("SELECT archived FROM boards WHERE board_id = 'b1';").fetchone()[0]
+ assert archived == 0
+
+
def test_a_long_project_name_is_truncated_to_what_the_board_api_accepts() -> None:
db = _make_db()
_add_user(db, "u1")