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(webv2): exclude the compare selection from .invk archives
joshistoast4f74ea903168
diff --git a/docs/src/content/docs/development/Front End/project-files.mdx b/docs/src/content/docs/development/Front End/project-files.mdxindex e6e81ccc74..4ea3807f25 100644--- a/docs/src/content/docs/development/Front End/project-files.mdx+++ b/docs/src/content/docs/development/Front End/project-files.mdx@@ -30,7 +30,9 @@ Which ones is decided by `collectLiveAssetRefs()` in `projects/projectAssets.ts``video_name` reaches a document through an imported workflow whose node value was authored elsewhere (`VideoField` in the backend's `fields.py`, consumed by `video_frame_extract` and friends). webv2 cannot author one yet — `VideoField` is absent from `STATEFUL_FIELD_TYPE_NAMES` — but it round-trips one verbatim, so a project file has to carry it.-**The gallery selection is excluded, of either kind.** `selectedImage`, `selectedImageName` and `selectedImageNames` are pointers into per-install gallery content, not things the document renders; a project arriving on another machine should open with nothing selected rather than drag a stranger's gallery in behind it. The skip is by key on purpose: `GalleryItem` happens to spell its name field `name`, which no collector key matches, so these would be missed anyway — but that is an accident of naming, and the explicit skip is what stops a future rename from silently changing what a project file contains.+**The gallery selection is excluded, of either kind.** `selectedImage`, `selectedImageName`, `selectedImageNames` and `compareImage` are pointers into per-install gallery content, not things the document renders; a project arriving on another machine should open with nothing selected rather than drag a stranger's gallery in behind it.++The skip is by key on purpose, because the members got there differently. `selectedImage` and the name keys were already missed — `GalleryItem` spells its name field `name`, which no collector key matches — but that is an accident of naming that a rename would have undone. `compareImage` is a `GeneratedImageContract` carrying `imageName`, so it was genuinely being bundled until the exclusion became explicit.**History is excluded.** The walker skips the `queue`, `graphHistory` and `events` roots, and the `snapshot`, `snapshots` and `recentImages` keys at any depth. Every queue entry embeds a full canvas snapshot and the gallery widget keeps up to sixty recent results, so bundling all of it would turn a working project into a multi-gigabyte archive. References into history survive in the document and resolve on any install that still has those images.diff --git a/invokeai/frontend/webv2/src/workbench/projects/projectAssets.test.ts b/invokeai/frontend/webv2/src/workbench/projects/projectAssets.test.tsindex 6b9c089bfc..f97eb1acf9 100644--- a/invokeai/frontend/webv2/src/workbench/projects/projectAssets.test.ts+++ b/invokeai/frontend/webv2/src/workbench/projects/projectAssets.test.ts@@ -167,6 +167,25 @@ describe('collectLiveAssetRefs', () => {expect(refs.images.has('selected.mp4')).toBe(false);});+ /**+ * `compareImage` is a `GeneratedImageContract`, so it carries `imageName` and+ * would otherwise be collected. A comparison left open is not project content.+ */+ it('excludes the compare selection', () => {+ const { images } = collectLiveAssetRefs(+ projectDocument({+ widgetInstances: {+ 'gallery-1': {+ state: { values: { compareImage: { ...imageRef('compare.png'), imageUrl: '' } } },+ typeId: 'gallery',+ },+ },+ })+ );++ expect(images.has('compare.png')).toBe(false);+ });+it('keeps excluding the gallery selection even if it starts spelling its name `imageName`', () => {const { images } = collectLiveAssetRefs(projectDocument({diff --git a/invokeai/frontend/webv2/src/workbench/projects/projectAssets.ts b/invokeai/frontend/webv2/src/workbench/projects/projectAssets.tsindex 22ac148273..e7d12b8514 100644--- a/invokeai/frontend/webv2/src/workbench/projects/projectAssets.ts+++ b/invokeai/frontend/webv2/src/workbench/projects/projectAssets.ts@@ -60,20 +60,25 @@ export const PROJECT_HISTORY_ROOT_KEYS: ReadonlySet<string> = new Set(['events',export const PROJECT_HISTORY_KEYS: ReadonlySet<string> = new Set(['recentImages', 'snapshot', 'snapshots']);/**- * The gallery widget's selection, which is a pointer into gallery content rather- * than anything the document renders. `selectedImage` holds a whole polymorphic- * `GalleryItem` (image or video), and the two name keys hold `"<kind>:<name>"`.+ * The gallery widget's selection: pointers into gallery content rather than+ * anything the document renders. `selectedImage` holds a whole polymorphic+ * `GalleryItem` (image or video), the two name keys hold `"<kind>:<name>"`, and+ * `compareImage` holds the image the Preview widget is comparing against.*- * These are skipped deliberately. The gallery is per-install content: a project+ * All are skipped deliberately. The gallery is per-install content: a project* that arrives on another machine should open with nothing selected, not drag a* stranger's gallery in behind it.*- * The skip is by key rather than incidental. `GalleryItem` happens to spell its- * name field `name`, which no collector key matches, so today these would be- * missed anyway — but that is an accident of naming, and renaming that field- * would otherwise change what a project file silently contains.+ * The two halves got here differently, which is why the skip is by key rather+ * than left to chance. `selectedImage` and the name keys were already missed,+ * but only because `GalleryItem` spells its name field `name` and no collector+ * key matches it — an accident that renaming the field would have undone.+ * `compareImage` is a `GeneratedImageContract`, so it carries `imageName` and+ * was genuinely being bundled: excluding it is a real change, and the right one,+ * since a comparison someone happened to leave open is not part of the project.*/export const GALLERY_SELECTION_KEYS: ReadonlySet<string> = new Set([+ 'compareImage','selectedImage','selectedImageName','selectedImageNames',