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: address adversarial review of the image-map reveal branch
Lincoln Stein871a831149a2
diff --git a/invokeai/frontend/webv2/patches/react-hook-tanstack-virtual.patch b/invokeai/frontend/webv2/patches/react-hook-tanstack-virtual.patchindex 4114ca0b07..31b3710594 100644--- a/invokeai/frontend/webv2/patches/react-hook-tanstack-virtual.patch+++ b/invokeai/frontend/webv2/patches/react-hook-tanstack-virtual.patch@@ -1,26 +1,26 @@diff --git a/dist/useVirtualizerBase-C3OWQGkj.js b/dist/useVirtualizerBase-C3OWQGkj.js-index 6e8df8ec5304bea75001914bccd115c745a96a44..77c4e2aa1eeccf222a9515d27afa4e64c123bf31 100644+index 6e8df8ec5304bea75001914bccd115c745a96a44..2cdf2ca421952ab4be1a36cf755fac792833cd20 100644--- a/dist/useVirtualizerBase-C3OWQGkj.js+++ b/dist/useVirtualizerBase-C3OWQGkj.js@@ -1,2 +1,2 @@-import{Virtualizer as e}from"@tanstack/virtual-core";import*as t from"react";import{useCallback as n,useInsertionEffect as r,useMemo as i,useRef as a,useState as o,useSyncExternalStore as s}from"react";import{flushSync as c}from"react-dom";const l=(e,...t)=>e,u=(e,t)=>{if(e.size!==t.size)return!1;for(let[n,r]of e){let e=t.get(n);if(r!==e||!Object.is(r,e))return!1}return!0},d=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0},f=(e,t)=>{if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map)return u(e,t);if(e instanceof Set&&t instanceof Set)return d(e,t);let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.hasOwn(t,r))return!1;let{[r]:n}=e,{[r]:i}=t;if(n!==i||!Object.is(n,i))return!1}return!0},p=typeof document<`u`?t.useLayoutEffect:()=>{},m=e=>{let[t,n]=o(e);return f(t,e)||n(e),t};let h=1,g=!1;const _=new Map,v=({callback:e,args:t})=>e.apply(void 0,t),y=e=>{if(g){x(y,e);return}let t=_.get(e);if(t){g=!0;try{v(t)}finally{S(e),g=!1}}},b=`scheduler`in globalThis?{setImmediate:(e,...t)=>{let n=h++;return _.set(n,{callback:e,args:t}),scheduler.postTask(()=>y(n),{priority:`user-blocking`}),n},clearImmediate:e=>{_.delete(e)}}:(()=>{let e=new MessageChannel;e.port1.onmessage=function(e){let t=e.data;y(t)};let t=e.port2;return{setImmediate:(e,...n)=>{let r=h++;return _.set(r,{callback:e,args:n}),t.postMessage(r),r},clearImmediate:e=>{_.delete(e)}}})(),x=b.setImmediate,S=b.clearImmediate;let C=1;const w=new Map,T=({callback:e,args:t})=>e.apply(void 0,t),E=e=>{let t=w.get(e);if(t)try{T(t)}finally{O(e)}},D=(e,...t)=>{let n=C++;return w.set(n,{callback:e,args:t}),requestAnimationFrame(()=>x(()=>E(n))),n},O=e=>{w.delete(e)};function k(e){let[t,r]=o(e);return[t,n(e=>(r(e),()=>{r(null)}),[])]}const A=({getVirtualItems:e,getVirtualIndexes:t,getTotalSize:n,...r})=>({...r,virtualItems:e(),virtualIndexes:t(),totalSize:n()}),j=({options:e,virtualIndexes:t,virtualItems:n,...r},{options:i,virtualIndexes:a,virtualItems:o,...s})=>f(e,i)&&f(t,a)&&f(n,o)&&f(r,s),M=({useFlushSync:t=!0,directDomUpdates:u=!1,directDomUpdatesMode:d=`transform`,...h},g=l,_=f)=>{"use no memo";let v=m(h),{horizontal:y=!1,scrollMargin:b=0}=v,x=y?`width`:`height`,S=d===`transform`,[C,w]=o(null),[T,E]=k(null),[M]=o(()=>new WeakMap),[N]=o(()=>new WeakMap),[P]=o(()=>new e(v)),F=i(()=>Object.assign(P,{containerRef:E}),[P,E]);p(()=>{if(!u||!T||C==null)return;let e=``,t=D(()=>{e=T.style.getPropertyValue(x),t=requestAnimationFrame(()=>{T.style.setProperty(x,`${C}px`)})});return()=>{w(null),cancelAnimationFrame(t),O(t),requestAnimationFrame(()=>{T?.style.setProperty(x,e)})}},[x,T,u,C]),p(()=>{if(!(!u||!T))return()=>{requestAnimationFrame(()=>{let e=F.getVirtualItems();for(let t of e){let e=F.elementsCache.get(t.key);if(!e)continue;M.delete(e);let n=N.get(e);n!=null&&(N.delete(e),S?e.style.setProperty(`transform`,n):e.style.setProperty(x,n))}})}},[x,T,u,F,M,N,S]);let I=a({hasValue:!1,value:null}),[L]=o(()=>new Set),R=n(e=>(L.add(e),()=>{L.delete(e)}),[L]),z=i(()=>{let e=!1,t,n;return()=>{let r=A(F);if(!e){e=!0,t=r;let i=g(r,F);if(I.current.hasValue){let e=I.current.value;if(_(e,i))return n=e,e}return n=i,i}let i=t,a=n;if(j(i,r))return a;let o=g(r,F);return _!==void 0&&_(a,o)?(t=r,a):(t=r,n=o,o)}},[g,_,F]),B=n(e=>{if(!u||!T)return;w(e.getTotalSize());let t=e.getVirtualItems();for(let n of t){let t=n.start-b,r=e.elementsCache.get(n.key);r&&M.get(r)!==t&&(N.has(r)||(S?N.set(r,r.style.getPropertyValue(`transform`)):N.set(r,r.style.getPropertyValue(x))),M.set(r,t),S?r.style.setProperty(`transform`,y?`translate3d(${t}px, 0, 0)`:`translate3d(0, ${t}px, 0)`):r.style.setProperty(x,`${t}px`))}},[x,T,u,y,M,N,b,S]),V=n((e,n)=>{if(B(e),t&&n)c(()=>{for(let e of L)e()});else for(let e of L)e();v.onChange?.call(void 0,e,n)},[B,L,v.onChange,t]),H=i(()=>({...v,onChange:V}),[V,v]);p(()=>{F.setOptions(H)},[F,H]),p(()=>F._didMount(),[F]),p(()=>F._willUpdate()),p(()=>{B(F)});let U=s(R,z);return r(()=>{I.current.hasValue=!0,I.current.value=U},[U]),U};export{M as t};-+import{Virtualizer as e}from"@tanstack/virtual-core";import*as t from"react";import{useCallback as n,useInsertionEffect as r,useMemo as i,useRef as a,useState as o,useSyncExternalStore as s}from"react";import{flushSync as c}from"react-dom";const l=(e,...t)=>e,u=(e,t)=>{if(e.size!==t.size)return!1;for(let[n,r]of e){let e=t.get(n);if(r!==e||!Object.is(r,e))return!1}return!0},d=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0},f=(e,t)=>{if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map)return u(e,t);if(e instanceof Set&&t instanceof Set)return d(e,t);let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.hasOwn(t,r))return!1;let{[r]:n}=e,{[r]:i}=t;if(n!==i||!Object.is(n,i))return!1}return!0},p=typeof document<`u`?t.useLayoutEffect:()=>{},m=e=>{let[t,n]=o(e);return f(t,e)||n(e),t};let h=1,g=!1;const _=new Map,v=({callback:e,args:t})=>e.apply(void 0,t),y=e=>{if(g){x(y,e);return}let t=_.get(e);if(t){g=!0;try{v(t)}finally{S(e),g=!1}}},b=`scheduler`in globalThis?{setImmediate:(e,...t)=>{let n=h++;return _.set(n,{callback:e,args:t}),scheduler.postTask(()=>y(n),{priority:`user-blocking`}),n},clearImmediate:e=>{_.delete(e)}}:(()=>{let e=new MessageChannel;e.port1.onmessage=function(e){let t=e.data;y(t)};let t=e.port2;return{setImmediate:(e,...n)=>{let r=h++;return _.set(r,{callback:e,args:n}),t.postMessage(r),r},clearImmediate:e=>{_.delete(e)}}})(),x=b.setImmediate,S=b.clearImmediate;let C=1;const w=new Map,T=({callback:e,args:t})=>e.apply(void 0,t),E=e=>{let t=w.get(e);if(t)try{T(t)}finally{O(e)}},D=(e,...t)=>{let n=C++;return w.set(n,{callback:e,args:t}),requestAnimationFrame(()=>x(()=>E(n))),n},O=e=>{w.delete(e)};function k(e){let[t,r]=o(e);return[t,n(e=>(r(e),()=>{r(null)}),[])]}const A=({getVirtualItems:e,getVirtualIndexes:t,getTotalSize:n,...r})=>({...r,virtualItems:e(),virtualIndexes:t(),totalSize:n()}),j=({options:e,virtualIndexes:t,virtualItems:n,...r},{options:i,virtualIndexes:a,virtualItems:o,...s})=>f(e,i)&&f(t,a)&&f(n,o)&&f(r,s),M=({useFlushSync:t=!0,directDomUpdates:u=!1,directDomUpdatesMode:d=`transform`,...h},g=l,_=f)=>{"use no memo";let v=m(h),{horizontal:y=!1,scrollMargin:b=0}=v,x=y?`width`:`height`,S=d===`transform`,[C,w]=o(null),[T,E]=k(null),[M]=o(()=>new WeakMap),[N]=o(()=>new WeakMap),[P]=o(()=>new e(v)),F=i(()=>Object.assign(P,{containerRef:E}),[P,E]);p(()=>{if(!u||!T||C==null)return;let e=``,t=D(()=>{e=T.style.getPropertyValue(x),t=requestAnimationFrame(()=>{T.style.setProperty(x,`${C}px`)})});return()=>{w(null),cancelAnimationFrame(t),O(t),requestAnimationFrame(()=>{T?.style.setProperty(x,e)})}},[x,T,u,C]),p(()=>{if(!(!u||!T))return()=>{requestAnimationFrame(()=>{let e=F.getVirtualItems();for(let t of e){let e=F.elementsCache.get(t.key);if(!e)continue;M.delete(e);let n=N.get(e);n!=null&&(N.delete(e),S?e.style.setProperty(`transform`,n):e.style.setProperty(x,n))}})}},[x,T,u,F,M,N,S]);let I=a({hasValue:!1,value:null}),[L]=o(()=>new Set),R=n(e=>(L.add(e),()=>{L.delete(e)}),[L]),z=i(()=>{let e=!1,t,n;return()=>{let r=A(F);if(!e){e=!0,t=r;let i=g(r,F);if(I.current.hasValue){let e=I.current.value;if(_(e,i))return n=e,e}return n=i,i}let i=t,a=n;if(j(i,r))return a;let o=g(r,F);return _!==void 0&&_(a,o)?(t=r,a):(t=r,n=o,o)}},[g,_,F]),B=n(e=>{if(!u||!T)return;w(e.getTotalSize());let t=e.getVirtualItems();for(let n of t){let t=n.start-b,r=e.elementsCache.get(n.key);r&&M.get(r)!==t&&(N.has(r)||(S?N.set(r,r.style.getPropertyValue(`transform`)):N.set(r,r.style.getPropertyValue(x))),M.set(r,t),S?r.style.setProperty(`transform`,y?`translate3d(${t}px, 0, 0)`:`translate3d(0, ${t}px, 0)`):r.style.setProperty(x,`${t}px`))}},[x,T,u,y,M,N,b,S]),V=n((e,n)=>{if(B(e),t&&n)c(()=>{for(let e of L)e()});else for(let e of L)e();v.onChange?.call(void 0,e,n)},[B,L,v.onChange,t]),H=i(()=>({...v,onChange:V}),[V,v]);p(()=>{F.setOptions(H),F.maybeNotify()},[F,H]),p(()=>F._didMount(),[F]),p(()=>{const e=F._willUpdate(),t=F.scrollElement;if(t&&`scrollTop`in t&&!F.isScrolling){const e=F.options.horizontal?t.scrollLeft*(F.options.isRtl?-1:1):t.scrollTop;F.scrollOffset!==null&&Math.abs(F.scrollOffset-e)>1&&(F.scrollOffset=e,F._intendedScrollOffset=null,F.scrollAdjustments=0,F.maybeNotify())}return e}),p(()=>{B(F)});let U=s(R,z);return r(()=>{I.current.hasValue=!0,I.current.value=U},[U]),U};export{M as t};++import{Virtualizer as e}from"@tanstack/virtual-core";import*as t from"react";import{useCallback as n,useInsertionEffect as r,useMemo as i,useRef as a,useState as o,useSyncExternalStore as s}from"react";import{flushSync as c}from"react-dom";const l=(e,...t)=>e,u=(e,t)=>{if(e.size!==t.size)return!1;for(let[n,r]of e){let e=t.get(n);if(r!==e||!Object.is(r,e))return!1}return!0},d=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0},f=(e,t)=>{if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map)return u(e,t);if(e instanceof Set&&t instanceof Set)return d(e,t);let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.hasOwn(t,r))return!1;let{[r]:n}=e,{[r]:i}=t;if(n!==i||!Object.is(n,i))return!1}return!0},p=typeof document<`u`?t.useLayoutEffect:()=>{},m=e=>{let[t,n]=o(e);return f(t,e)||n(e),t};let h=1,g=!1;const _=new Map,v=({callback:e,args:t})=>e.apply(void 0,t),y=e=>{if(g){x(y,e);return}let t=_.get(e);if(t){g=!0;try{v(t)}finally{S(e),g=!1}}},b=`scheduler`in globalThis?{setImmediate:(e,...t)=>{let n=h++;return _.set(n,{callback:e,args:t}),scheduler.postTask(()=>y(n),{priority:`user-blocking`}),n},clearImmediate:e=>{_.delete(e)}}:(()=>{let e=new MessageChannel;e.port1.onmessage=function(e){let t=e.data;y(t)};let t=e.port2;return{setImmediate:(e,...n)=>{let r=h++;return _.set(r,{callback:e,args:n}),t.postMessage(r),r},clearImmediate:e=>{_.delete(e)}}})(),x=b.setImmediate,S=b.clearImmediate;let C=1;const w=new Map,T=({callback:e,args:t})=>e.apply(void 0,t),E=e=>{let t=w.get(e);if(t)try{T(t)}finally{O(e)}},D=(e,...t)=>{let n=C++;return w.set(n,{callback:e,args:t}),requestAnimationFrame(()=>x(()=>E(n))),n},O=e=>{w.delete(e)};function k(e){let[t,r]=o(e);return[t,n(e=>(r(e),()=>{r(null)}),[])]}const A=({getVirtualItems:e,getVirtualIndexes:t,getTotalSize:n,...r})=>({...r,virtualItems:e(),virtualIndexes:t(),totalSize:n()}),j=({options:e,virtualIndexes:t,virtualItems:n,...r},{options:i,virtualIndexes:a,virtualItems:o,...s})=>f(e,i)&&f(t,a)&&f(n,o)&&f(r,s),M=({useFlushSync:t=!0,directDomUpdates:u=!1,directDomUpdatesMode:d=`transform`,...h},g=l,_=f)=>{"use no memo";let v=m(h),{horizontal:y=!1,scrollMargin:b=0}=v,x=y?`width`:`height`,S=d===`transform`,[C,w]=o(null),[T,E]=k(null),[M]=o(()=>new WeakMap),[N]=o(()=>new WeakMap),[P]=o(()=>new e(v)),F=i(()=>Object.assign(P,{containerRef:E}),[P,E]);p(()=>{if(!u||!T||C==null)return;let e=``,t=D(()=>{e=T.style.getPropertyValue(x),t=requestAnimationFrame(()=>{T.style.setProperty(x,`${C}px`)})});return()=>{w(null),cancelAnimationFrame(t),O(t),requestAnimationFrame(()=>{T?.style.setProperty(x,e)})}},[x,T,u,C]),p(()=>{if(!(!u||!T))return()=>{requestAnimationFrame(()=>{let e=F.getVirtualItems();for(let t of e){let e=F.elementsCache.get(t.key);if(!e)continue;M.delete(e);let n=N.get(e);n!=null&&(N.delete(e),S?e.style.setProperty(`transform`,n):e.style.setProperty(x,n))}})}},[x,T,u,F,M,N,S]);let I=a({hasValue:!1,value:null}),[L]=o(()=>new Set),R=n(e=>(L.add(e),()=>{L.delete(e)}),[L]),z=i(()=>{let e=!1,t,n;return()=>{let r=A(F);if(!e){e=!0,t=r;let i=g(r,F);if(I.current.hasValue){let e=I.current.value;if(_(e,i))return n=e,e}return n=i,i}let i=t,a=n;if(j(i,r))return a;let o=g(r,F);return _!==void 0&&_(a,o)?(t=r,a):(t=r,n=o,o)}},[g,_,F]),B=n(e=>{if(!u||!T)return;w(e.getTotalSize());let t=e.getVirtualItems();for(let n of t){let t=n.start-b,r=e.elementsCache.get(n.key);r&&M.get(r)!==t&&(N.has(r)||(S?N.set(r,r.style.getPropertyValue(`transform`)):N.set(r,r.style.getPropertyValue(x))),M.set(r,t),S?r.style.setProperty(`transform`,y?`translate3d(${t}px, 0, 0)`:`translate3d(0, ${t}px, 0)`):r.style.setProperty(x,`${t}px`))}},[x,T,u,y,M,N,b,S]),V=n((e,n)=>{if(B(e),t&&n)c(()=>{for(let e of L)e()});else for(let e of L)e();v.onChange?.call(void 0,e,n)},[B,L,v.onChange,t]),H=i(()=>({...v,onChange:V}),[V,v]);p(()=>{F.setOptions(H),F.maybeNotify()},[F,H]),p(()=>F._didMount(),[F]),p(()=>{const e=F._willUpdate(),t=F.scrollElement;if(t&&`scrollTop`in t&&!F.isScrolling){const e=F.options.horizontal?t.scrollLeft*(F.options.isRtl?-1:1):t.scrollTop;F.scrollOffset!==null&&Math.abs(F.scrollOffset-e)>1&&(F.scrollOffset=e,F.scrollAdjustments=0,F.maybeNotify())}return e}),p(()=>{B(F)});let U=s(R,z);return r(()=>{I.current.hasValue=!0,I.current.value=U},[U]),U};export{M as t};//# sourceMappingURL=useVirtualizerBase-C3OWQGkj.js.map\ No newline at end of filediff --git a/dist/useVirtualizerBase-K4A1fZan.cjs b/dist/useVirtualizerBase-K4A1fZan.cjs-index 69494e5c083f991a4b7417cd2b6a216be3bf00e6..0b9882d4260992a32056fa07de41a6da9d9ab863 100644+index 69494e5c083f991a4b7417cd2b6a216be3bf00e6..df02f4d2032b807b6b2c2fc3881051254a55fb71 100644--- a/dist/useVirtualizerBase-K4A1fZan.cjs+++ b/dist/useVirtualizerBase-K4A1fZan.cjs@@ -1 +1 @@-var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("@tanstack/virtual-core"),l=require("react");l=s(l,1);let u=require("react-dom");const d=(e,...t)=>e,f=(e,t)=>{if(e.size!==t.size)return!1;for(let[n,r]of e){let e=t.get(n);if(r!==e||!Object.is(r,e))return!1}return!0},p=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0},m=(e,t)=>{if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map)return f(e,t);if(e instanceof Set&&t instanceof Set)return p(e,t);let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.hasOwn(t,r))return!1;let{[r]:n}=e,{[r]:i}=t;if(n!==i||!Object.is(n,i))return!1}return!0},h=typeof document<`u`?l.useLayoutEffect:()=>{},g=e=>{let[t,n]=(0,l.useState)(e);return m(t,e)||n(e),t};let _=1,v=!1;const y=new Map,b=({callback:e,args:t})=>e.apply(void 0,t),x=e=>{if(v){C(x,e);return}let t=y.get(e);if(t){v=!0;try{b(t)}finally{w(e),v=!1}}},S=`scheduler`in globalThis?{setImmediate:(e,...t)=>{let n=_++;return y.set(n,{callback:e,args:t}),scheduler.postTask(()=>x(n),{priority:`user-blocking`}),n},clearImmediate:e=>{y.delete(e)}}:(()=>{let e=new MessageChannel;e.port1.onmessage=function(e){let t=e.data;x(t)};let t=e.port2;return{setImmediate:(e,...n)=>{let r=_++;return y.set(r,{callback:e,args:n}),t.postMessage(r),r},clearImmediate:e=>{y.delete(e)}}})(),C=S.setImmediate,w=S.clearImmediate;let T=1;const E=new Map,D=({callback:e,args:t})=>e.apply(void 0,t),O=e=>{let t=E.get(e);if(t)try{D(t)}finally{A(e)}},k=(e,...t)=>{let n=T++;return E.set(n,{callback:e,args:t}),requestAnimationFrame(()=>C(()=>O(n))),n},A=e=>{E.delete(e)};function j(e){let[t,n]=(0,l.useState)(e);return[t,(0,l.useCallback)(e=>(n(e),()=>{n(null)}),[])]}const M=({getVirtualItems:e,getVirtualIndexes:t,getTotalSize:n,...r})=>({...r,virtualItems:e(),virtualIndexes:t(),totalSize:n()}),N=({options:e,virtualIndexes:t,virtualItems:n,...r},{options:i,virtualIndexes:a,virtualItems:o,...s})=>m(e,i)&&m(t,a)&&m(n,o)&&m(r,s),P=({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r},i=d,a=m)=>{"use no memo";let o=g(r),{horizontal:s=!1,scrollMargin:f=0}=o,p=s?`width`:`height`,_=n===`transform`,[v,y]=(0,l.useState)(null),[b,x]=j(null),[S]=(0,l.useState)(()=>new WeakMap),[C]=(0,l.useState)(()=>new WeakMap),[w]=(0,l.useState)(()=>new c.Virtualizer(o)),T=(0,l.useMemo)(()=>Object.assign(w,{containerRef:x}),[w,x]);h(()=>{if(!t||!b||v==null)return;let e=``,n=k(()=>{e=b.style.getPropertyValue(p),n=requestAnimationFrame(()=>{b.style.setProperty(p,`${v}px`)})});return()=>{y(null),cancelAnimationFrame(n),A(n),requestAnimationFrame(()=>{b?.style.setProperty(p,e)})}},[p,b,t,v]),h(()=>{if(!(!t||!b))return()=>{requestAnimationFrame(()=>{let e=T.getVirtualItems();for(let t of e){let e=T.elementsCache.get(t.key);if(!e)continue;S.delete(e);let n=C.get(e);n!=null&&(C.delete(e),_?e.style.setProperty(`transform`,n):e.style.setProperty(p,n))}})}},[p,b,t,T,S,C,_]);let E=(0,l.useRef)({hasValue:!1,value:null}),[D]=(0,l.useState)(()=>new Set),O=(0,l.useCallback)(e=>(D.add(e),()=>{D.delete(e)}),[D]),P=(0,l.useMemo)(()=>{let e=!1,t,n;return()=>{let r=M(T);if(!e){e=!0,t=r;let o=i(r,T);if(E.current.hasValue){let e=E.current.value;if(a(e,o))return n=e,e}return n=o,o}let o=t,s=n;if(N(o,r))return s;let c=i(r,T);return a!==void 0&&a(s,c)?(t=r,s):(t=r,n=c,c)}},[i,a,T]),F=(0,l.useCallback)(e=>{if(!t||!b)return;y(e.getTotalSize());let n=e.getVirtualItems();for(let t of n){let n=t.start-f,r=e.elementsCache.get(t.key);r&&S.get(r)!==n&&(C.has(r)||(_?C.set(r,r.style.getPropertyValue(`transform`)):C.set(r,r.style.getPropertyValue(p))),S.set(r,n),_?r.style.setProperty(`transform`,s?`translate3d(${n}px, 0, 0)`:`translate3d(0, ${n}px, 0)`):r.style.setProperty(p,`${n}px`))}},[p,b,t,s,S,C,f,_]),I=(0,l.useCallback)((t,n)=>{if(F(t),e&&n)(0,u.flushSync)(()=>{for(let e of D)e()});else for(let e of D)e();o.onChange?.call(void 0,t,n)},[F,D,o.onChange,e]),L=(0,l.useMemo)(()=>({...o,onChange:I}),[I,o]);h(()=>{T.setOptions(L)},[T,L]),h(()=>T._didMount(),[T]),h(()=>T._willUpdate()),h(()=>{F(T)});let R=(0,l.useSyncExternalStore)(O,P);return(0,l.useInsertionEffect)(()=>{E.current.hasValue=!0,E.current.value=R},[R]),R};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return P}});\ No newline at end of file-+var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("@tanstack/virtual-core"),l=require("react");l=s(l,1);let u=require("react-dom");const d=(e,...t)=>e,f=(e,t)=>{if(e.size!==t.size)return!1;for(let[n,r]of e){let e=t.get(n);if(r!==e||!Object.is(r,e))return!1}return!0},p=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0},m=(e,t)=>{if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map)return f(e,t);if(e instanceof Set&&t instanceof Set)return p(e,t);let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.hasOwn(t,r))return!1;let{[r]:n}=e,{[r]:i}=t;if(n!==i||!Object.is(n,i))return!1}return!0},h=typeof document<`u`?l.useLayoutEffect:()=>{},g=e=>{let[t,n]=(0,l.useState)(e);return m(t,e)||n(e),t};let _=1,v=!1;const y=new Map,b=({callback:e,args:t})=>e.apply(void 0,t),x=e=>{if(v){C(x,e);return}let t=y.get(e);if(t){v=!0;try{b(t)}finally{w(e),v=!1}}},S=`scheduler`in globalThis?{setImmediate:(e,...t)=>{let n=_++;return y.set(n,{callback:e,args:t}),scheduler.postTask(()=>x(n),{priority:`user-blocking`}),n},clearImmediate:e=>{y.delete(e)}}:(()=>{let e=new MessageChannel;e.port1.onmessage=function(e){let t=e.data;x(t)};let t=e.port2;return{setImmediate:(e,...n)=>{let r=_++;return y.set(r,{callback:e,args:n}),t.postMessage(r),r},clearImmediate:e=>{y.delete(e)}}})(),C=S.setImmediate,w=S.clearImmediate;let T=1;const E=new Map,D=({callback:e,args:t})=>e.apply(void 0,t),O=e=>{let t=E.get(e);if(t)try{D(t)}finally{A(e)}},k=(e,...t)=>{let n=T++;return E.set(n,{callback:e,args:t}),requestAnimationFrame(()=>C(()=>O(n))),n},A=e=>{E.delete(e)};function j(e){let[t,n]=(0,l.useState)(e);return[t,(0,l.useCallback)(e=>(n(e),()=>{n(null)}),[])]}const M=({getVirtualItems:e,getVirtualIndexes:t,getTotalSize:n,...r})=>({...r,virtualItems:e(),virtualIndexes:t(),totalSize:n()}),N=({options:e,virtualIndexes:t,virtualItems:n,...r},{options:i,virtualIndexes:a,virtualItems:o,...s})=>m(e,i)&&m(t,a)&&m(n,o)&&m(r,s),P=({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r},i=d,a=m)=>{"use no memo";let o=g(r),{horizontal:s=!1,scrollMargin:f=0}=o,p=s?`width`:`height`,_=n===`transform`,[v,y]=(0,l.useState)(null),[b,x]=j(null),[S]=(0,l.useState)(()=>new WeakMap),[C]=(0,l.useState)(()=>new WeakMap),[w]=(0,l.useState)(()=>new c.Virtualizer(o)),T=(0,l.useMemo)(()=>Object.assign(w,{containerRef:x}),[w,x]);h(()=>{if(!t||!b||v==null)return;let e=``,n=k(()=>{e=b.style.getPropertyValue(p),n=requestAnimationFrame(()=>{b.style.setProperty(p,`${v}px`)})});return()=>{y(null),cancelAnimationFrame(n),A(n),requestAnimationFrame(()=>{b?.style.setProperty(p,e)})}},[p,b,t,v]),h(()=>{if(!(!t||!b))return()=>{requestAnimationFrame(()=>{let e=T.getVirtualItems();for(let t of e){let e=T.elementsCache.get(t.key);if(!e)continue;S.delete(e);let n=C.get(e);n!=null&&(C.delete(e),_?e.style.setProperty(`transform`,n):e.style.setProperty(p,n))}})}},[p,b,t,T,S,C,_]);let E=(0,l.useRef)({hasValue:!1,value:null}),[D]=(0,l.useState)(()=>new Set),O=(0,l.useCallback)(e=>(D.add(e),()=>{D.delete(e)}),[D]),P=(0,l.useMemo)(()=>{let e=!1,t,n;return()=>{let r=M(T);if(!e){e=!0,t=r;let o=i(r,T);if(E.current.hasValue){let e=E.current.value;if(a(e,o))return n=e,e}return n=o,o}let o=t,s=n;if(N(o,r))return s;let c=i(r,T);return a!==void 0&&a(s,c)?(t=r,s):(t=r,n=c,c)}},[i,a,T]),F=(0,l.useCallback)(e=>{if(!t||!b)return;y(e.getTotalSize());let n=e.getVirtualItems();for(let t of n){let n=t.start-f,r=e.elementsCache.get(t.key);r&&S.get(r)!==n&&(C.has(r)||(_?C.set(r,r.style.getPropertyValue(`transform`)):C.set(r,r.style.getPropertyValue(p))),S.set(r,n),_?r.style.setProperty(`transform`,s?`translate3d(${n}px, 0, 0)`:`translate3d(0, ${n}px, 0)`):r.style.setProperty(p,`${n}px`))}},[p,b,t,s,S,C,f,_]),I=(0,l.useCallback)((t,n)=>{if(F(t),e&&n)(0,u.flushSync)(()=>{for(let e of D)e()});else for(let e of D)e();o.onChange?.call(void 0,t,n)},[F,D,o.onChange,e]),L=(0,l.useMemo)(()=>({...o,onChange:I}),[I,o]);h(()=>{T.setOptions(L),T.maybeNotify()},[T,L]),h(()=>T._didMount(),[T]),h(()=>{const e=T._willUpdate(),t=T.scrollElement;if(t&&`scrollTop`in t&&!T.isScrolling){const e=T.options.horizontal?t.scrollLeft*(T.options.isRtl?-1:1):t.scrollTop;T.scrollOffset!==null&&Math.abs(T.scrollOffset-e)>1&&(T.scrollOffset=e,T._intendedScrollOffset=null,T.scrollAdjustments=0,T.maybeNotify())}return e}),h(()=>{F(T)});let R=(0,l.useSyncExternalStore)(O,P);return(0,l.useInsertionEffect)(()=>{E.current.hasValue=!0,E.current.value=R},[R]),R};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return P}});++var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("@tanstack/virtual-core"),l=require("react");l=s(l,1);let u=require("react-dom");const d=(e,...t)=>e,f=(e,t)=>{if(e.size!==t.size)return!1;for(let[n,r]of e){let e=t.get(n);if(r!==e||!Object.is(r,e))return!1}return!0},p=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0},m=(e,t)=>{if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map)return f(e,t);if(e instanceof Set&&t instanceof Set)return p(e,t);let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.hasOwn(t,r))return!1;let{[r]:n}=e,{[r]:i}=t;if(n!==i||!Object.is(n,i))return!1}return!0},h=typeof document<`u`?l.useLayoutEffect:()=>{},g=e=>{let[t,n]=(0,l.useState)(e);return m(t,e)||n(e),t};let _=1,v=!1;const y=new Map,b=({callback:e,args:t})=>e.apply(void 0,t),x=e=>{if(v){C(x,e);return}let t=y.get(e);if(t){v=!0;try{b(t)}finally{w(e),v=!1}}},S=`scheduler`in globalThis?{setImmediate:(e,...t)=>{let n=_++;return y.set(n,{callback:e,args:t}),scheduler.postTask(()=>x(n),{priority:`user-blocking`}),n},clearImmediate:e=>{y.delete(e)}}:(()=>{let e=new MessageChannel;e.port1.onmessage=function(e){let t=e.data;x(t)};let t=e.port2;return{setImmediate:(e,...n)=>{let r=_++;return y.set(r,{callback:e,args:n}),t.postMessage(r),r},clearImmediate:e=>{y.delete(e)}}})(),C=S.setImmediate,w=S.clearImmediate;let T=1;const E=new Map,D=({callback:e,args:t})=>e.apply(void 0,t),O=e=>{let t=E.get(e);if(t)try{D(t)}finally{A(e)}},k=(e,...t)=>{let n=T++;return E.set(n,{callback:e,args:t}),requestAnimationFrame(()=>C(()=>O(n))),n},A=e=>{E.delete(e)};function j(e){let[t,n]=(0,l.useState)(e);return[t,(0,l.useCallback)(e=>(n(e),()=>{n(null)}),[])]}const M=({getVirtualItems:e,getVirtualIndexes:t,getTotalSize:n,...r})=>({...r,virtualItems:e(),virtualIndexes:t(),totalSize:n()}),N=({options:e,virtualIndexes:t,virtualItems:n,...r},{options:i,virtualIndexes:a,virtualItems:o,...s})=>m(e,i)&&m(t,a)&&m(n,o)&&m(r,s),P=({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r},i=d,a=m)=>{"use no memo";let o=g(r),{horizontal:s=!1,scrollMargin:f=0}=o,p=s?`width`:`height`,_=n===`transform`,[v,y]=(0,l.useState)(null),[b,x]=j(null),[S]=(0,l.useState)(()=>new WeakMap),[C]=(0,l.useState)(()=>new WeakMap),[w]=(0,l.useState)(()=>new c.Virtualizer(o)),T=(0,l.useMemo)(()=>Object.assign(w,{containerRef:x}),[w,x]);h(()=>{if(!t||!b||v==null)return;let e=``,n=k(()=>{e=b.style.getPropertyValue(p),n=requestAnimationFrame(()=>{b.style.setProperty(p,`${v}px`)})});return()=>{y(null),cancelAnimationFrame(n),A(n),requestAnimationFrame(()=>{b?.style.setProperty(p,e)})}},[p,b,t,v]),h(()=>{if(!(!t||!b))return()=>{requestAnimationFrame(()=>{let e=T.getVirtualItems();for(let t of e){let e=T.elementsCache.get(t.key);if(!e)continue;S.delete(e);let n=C.get(e);n!=null&&(C.delete(e),_?e.style.setProperty(`transform`,n):e.style.setProperty(p,n))}})}},[p,b,t,T,S,C,_]);let E=(0,l.useRef)({hasValue:!1,value:null}),[D]=(0,l.useState)(()=>new Set),O=(0,l.useCallback)(e=>(D.add(e),()=>{D.delete(e)}),[D]),P=(0,l.useMemo)(()=>{let e=!1,t,n;return()=>{let r=M(T);if(!e){e=!0,t=r;let o=i(r,T);if(E.current.hasValue){let e=E.current.value;if(a(e,o))return n=e,e}return n=o,o}let o=t,s=n;if(N(o,r))return s;let c=i(r,T);return a!==void 0&&a(s,c)?(t=r,s):(t=r,n=c,c)}},[i,a,T]),F=(0,l.useCallback)(e=>{if(!t||!b)return;y(e.getTotalSize());let n=e.getVirtualItems();for(let t of n){let n=t.start-f,r=e.elementsCache.get(t.key);r&&S.get(r)!==n&&(C.has(r)||(_?C.set(r,r.style.getPropertyValue(`transform`)):C.set(r,r.style.getPropertyValue(p))),S.set(r,n),_?r.style.setProperty(`transform`,s?`translate3d(${n}px, 0, 0)`:`translate3d(0, ${n}px, 0)`):r.style.setProperty(p,`${n}px`))}},[p,b,t,s,S,C,f,_]),I=(0,l.useCallback)((t,n)=>{if(F(t),e&&n)(0,u.flushSync)(()=>{for(let e of D)e()});else for(let e of D)e();o.onChange?.call(void 0,t,n)},[F,D,o.onChange,e]),L=(0,l.useMemo)(()=>({...o,onChange:I}),[I,o]);h(()=>{T.setOptions(L),T.maybeNotify()},[T,L]),h(()=>T._didMount(),[T]),h(()=>{const e=T._willUpdate(),t=T.scrollElement;if(t&&`scrollTop`in t&&!T.isScrolling){const e=T.options.horizontal?t.scrollLeft*(T.options.isRtl?-1:1):t.scrollTop;T.scrollOffset!==null&&Math.abs(T.scrollOffset-e)>1&&(T.scrollOffset=e,T.scrollAdjustments=0,T.maybeNotify())}return e}),h(()=>{F(T)});let R=(0,l.useSyncExternalStore)(O,P);return(0,l.useInsertionEffect)(()=>{E.current.hasValue=!0,E.current.value=R},[R]),R};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return P}});\ No newline at end of filediff --git a/src/lib/useVirtualizerBase.ts b/src/lib/useVirtualizerBase.ts-index 59f46c47fe9bf8c09b482e110a623fbff5e65da3..813e95ed8046124e5e882152479bdfa33806d32a 100644+index 59f46c47fe9bf8c09b482e110a623fbff5e65da3..1cb263dbc0c5f39c30f380886b4a7c19d6cee1b5 100644--- a/src/lib/useVirtualizerBase.ts+++ b/src/lib/useVirtualizerBase.ts-@@ -364,14 +364,54 @@ export const useVirtualizerBase = <+@@ -364,14 +364,61 @@ export const useVirtualizerBase = <useLayoutEffect(() => {instance.setOptions(resolvedOptions)@@ -62,14 +62,21 @@ index 59f46c47fe9bf8c09b482e110a623fbff5e65da3..813e95ed8046124e5e882152479bdfa3+ && Math.abs(instance.scrollOffset - actualOffset) > 1+ ) {+ const mutable = instance as unknown as {-+ _intendedScrollOffset: number | null+ maybeNotify: () => void+ scrollAdjustments: number+ }+ instance.scrollOffset = actualOffset-+ mutable._intendedScrollOffset = null+ mutable.scrollAdjustments = 0+ mutable.maybeNotify()++ // `_intendedScrollOffset` is deliberately LEFT ALONE. virtual-core's++ // offset observer ignores an incoming scroll event when++ // `isScrolling && _intendedScrollOffset === null && offset ===++ // scrollOffset` — a guard whose whole purpose is to let a++ // programmatic scroll's own event through. Clearing it here while++ // also writing scrollOffset satisfies all three conditions, so every++ // scrollToIndex would swallow its own event and leave `isScrolling`++ // false and `scrollDirection` stale, which in turn misdirects dynamic++ // re-measurement. Left set, the next real event clears it itself.+ }+ }+ return resultdiff --git a/invokeai/frontend/webv2/pnpm-lock.yaml b/invokeai/frontend/webv2/pnpm-lock.yamlindex a7cec1cb28..5b26dc45fe 100644--- a/invokeai/frontend/webv2/pnpm-lock.yaml+++ b/invokeai/frontend/webv2/pnpm-lock.yaml@@ -6,7 +6,7 @@ settings:patchedDependencies:react-hook-tanstack-virtual:- hash: 6477499df111179c5116abd9739a07ef50ad182a8c3cec3811e7094a64b1f36a+ hash: b6a17ea8d00a392cd605ab76cfed12fb181d6230d3187ad063c9053e0da05b79path: patches/react-hook-tanstack-virtual.patchimporters:@@ -78,7 +78,7 @@ importers:version: 19.2.8([email protected])react-hook-tanstack-virtual:specifier: ^0.0.4- version: 0.0.4(patch_hash=6477499df111179c5116abd9739a07ef50ad182a8c3cec3811e7094a64b1f36a)(@tanstack/[email protected]([email protected]([email protected]))([email protected]))(@tanstack/[email protected])([email protected]([email protected]))([email protected])+ version: 0.0.4(patch_hash=b6a17ea8d00a392cd605ab76cfed12fb181d6230d3187ad063c9053e0da05b79)(@tanstack/[email protected]([email protected]([email protected]))([email protected]))(@tanstack/[email protected])([email protected]([email protected]))([email protected])react-i18next:specifier: ^17.0.11version: 17.0.11([email protected]([email protected]))([email protected]([email protected]))([email protected])([email protected])@@ -3880,7 +3880,7 @@ snapshots:react: 19.2.8scheduler: 0.27.0- [email protected](patch_hash=6477499df111179c5116abd9739a07ef50ad182a8c3cec3811e7094a64b1f36a)(@tanstack/[email protected]([email protected]([email protected]))([email protected]))(@tanstack/[email protected])([email protected]([email protected]))([email protected]):+ [email protected](patch_hash=b6a17ea8d00a392cd605ab76cfed12fb181d6230d3187ad063c9053e0da05b79)(@tanstack/[email protected]([email protected]([email protected]))([email protected]))(@tanstack/[email protected])([email protected]([email protected]))([email protected]):dependencies:'@tanstack/virtual-core': 3.17.7diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 811377124e..1684cf006b 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -3022,7 +3022,10 @@"uploadUnsupported": "No supported media files to upload (PNG, JPEG, WebP, or MP4).","videoCount_one": "{{count}} video","videoCount_other": "{{count}} videos",- "windowLimit": "Showing the first {{count}} items. Narrow the search or switch to Pages to reach the rest."+ "windowAnchored": "Showing this board from item {{index}}.",+ "backToBoardTop": "Back to top",+ "windowLimit": "Showing the first {{count}} items. Narrow the search or switch to Pages to reach the rest.",+ "windowLimitFrom": "Showing {{count}} items from item {{index}}. Narrow the search or switch to Pages to reach the rest."},"queueStatus": {"idle": "Queue idle",diff --git a/invokeai/frontend/webv2/src/features/gallery/core/semanticImageQuery.test.ts b/invokeai/frontend/webv2/src/features/gallery/core/semanticImageQuery.test.tsindex 15cc789ec3..81fedc88e2 100644--- a/invokeai/frontend/webv2/src/features/gallery/core/semanticImageQuery.test.ts+++ b/invokeai/frontend/webv2/src/features/gallery/core/semanticImageQuery.test.ts@@ -49,6 +49,22 @@ describe('image cluster registry', () => {expect(getImageCluster(clusterId)?.imageNames).toEqual(['a.png', 'b.png', 'c.png']);});+ it('rolls back only its own removals when another prune interleaves', () => {+ // Two deletions overlap: the first fails and rolls back while the second+ // has already pruned. Restoring the captured list wholesale would+ // resurrect the second deletion's image; an identity guard would skip the+ // restore entirely and strand the failed deletion's image outside the+ // cluster for good.+ const clusterId = registerImageCluster(['a.png', 'b.png', 'c.png'], 'beaches');+ const rollbackFirst = pruneImageClusterMembers(['a.png']);++ pruneImageClusterMembers(['b.png']);+ expect(getImageCluster(clusterId)?.imageNames).toEqual(['c.png']);++ rollbackFirst();+ expect(getImageCluster(clusterId)?.imageNames).toEqual(['a.png', 'c.png']);+ });+it('makes pruning a no-op when nothing matches, and rollback a no-op once superseded', () => {const clusterId = registerImageCluster(['a.png'], 'beaches');diff --git a/invokeai/frontend/webv2/src/features/gallery/core/semanticImageQuery.ts b/invokeai/frontend/webv2/src/features/gallery/core/semanticImageQuery.tsindex 958c8ccb1a..e2bbde928f 100644--- a/invokeai/frontend/webv2/src/features/gallery/core/semanticImageQuery.ts+++ b/invokeai/frontend/webv2/src/features/gallery/core/semanticImageQuery.ts@@ -121,9 +121,8 @@ export const getImageCluster = (clusterId: string): { imageNames: string[]; labe* Drops deleted images from the registered cluster, in step with the gallery's* optimistic cache patch: the member list is client-owned, so without this the* cluster view's total (and its trailing page) would keep counting images that- * no longer exist. Returns a rollback that restores the previous member list —- * unless a different registration has since replaced the entry, in which case- * the rollback is a no-op (the newer cluster owns the slot).+ * no longer exist. Returns a rollback that puts back exactly the names THIS+ * call removed — a no-op once a different registration owns the slot.*/export const pruneImageClusterMembers = (imageNames: readonly string[]): (() => void) => {const entry = [...clusters.entries()].at(0);@@ -133,21 +132,40 @@ export const pruneImageClusterMembers = (imageNames: readonly string[]): (() =>}const [clusterId, cluster] = entry;- const removed = new Set(imageNames);- const prunedNames = cluster.imageNames.filter((name) => !removed.has(name));+ const requested = new Set(imageNames);+ const originalNames = cluster.imageNames;+ const removedNames = originalNames.filter((name) => requested.has(name));- if (prunedNames.length === cluster.imageNames.length) {+ if (removedNames.length === 0) {return () => undefined;}- clusters.set(clusterId, { imageNames: prunedNames, label: cluster.label });+ const removed = new Set(removedNames);++ clusters.set(clusterId, {+ imageNames: originalNames.filter((name) => !removed.has(name)),+ label: cluster.label,+ });return () => {const current = clusters.get(clusterId);- if (current && current.imageNames === prunedNames) {- clusters.set(clusterId, { imageNames: cluster.imageNames, label: current.label });+ if (!current) {+ return;}++ // Rebuilt from the pre-prune order rather than swapped back wholesale, so+ // that a concurrent deletion's prune (or its rollback) landing in between+ // survives: whatever this call did not remove keeps whatever state the+ // other call left it in. Restoring the captured array instead would either+ // resurrect that deletion's images or — guarded on identity — skip the+ // restore entirely and strand a failed deletion's image outside the list.+ const restored = new Set([...current.imageNames, ...removedNames]);++ clusters.set(clusterId, {+ imageNames: originalNames.filter((name) => restored.has(name)),+ label: current.label,+ });};};diff --git a/invokeai/frontend/webv2/src/features/gallery/data/queries.test.ts b/invokeai/frontend/webv2/src/features/gallery/data/queries.test.tsindex f948726f0c..a987efa350 100644--- a/invokeai/frontend/webv2/src/features/gallery/data/queries.test.ts+++ b/invokeai/frontend/webv2/src/features/gallery/data/queries.test.ts@@ -273,6 +273,25 @@ describe('Gallery item query read model', () => {}});+ it('never grows an anchored infinite window above its anchor, but still lets paginated anchors', () => {+ // The grid shares the anchored entry and cannot request earlier pages+ // itself, so a prepend would splice 60 items in above its viewport and+ // shift the content under the user. Paginated consumers slice out the one+ // page they want by pageParam, so prepending is invisible there — and+ // Preview walks backwards through exactly that mechanism.+ const page: GalleryItemsPage = { items: [], total: 20_000 };+ const onePage = [page];+ const anchored = galleryItemsInfiniteOptions(baseFilter, { kind: 'infinite', offset: 6000 });+ const base = galleryItemsInfiniteOptions(baseFilter);+ const paginated = galleryItemsInfiniteOptions(baseFilter, { kind: 'anchor', offset: 6000 });++ expect(anchored.getPreviousPageParam?.(page, onePage, 6000, [6000])).toBeUndefined();+ expect(anchored.getPreviousPageParam?.(page, onePage, 6060, [6060])).toBe(6000);+ expect(base.getPreviousPageParam?.(page, onePage, 0, [0])).toBeUndefined();+ expect(base.getPreviousPageParam?.(page, onePage, GALLERY_PAGE_SIZE, [GALLERY_PAGE_SIZE])).toBe(0);+ expect(paginated.getPreviousPageParam?.(page, onePage, 6000, [6000])).toBe(6000 - GALLERY_PAGE_SIZE);+ });+it('does not create item-list cache entries for repeated invalidation events', async () => {const queryClient = createQueryClient();backend.listGalleryItems.mockResolvedValue(createPage({ count: 1, offset: 0, total: 1 }));diff --git a/invokeai/frontend/webv2/src/features/gallery/data/queries.ts b/invokeai/frontend/webv2/src/features/gallery/data/queries.tsindex 67690a2fda..430cf423e8 100644--- a/invokeai/frontend/webv2/src/features/gallery/data/queries.ts+++ b/invokeai/frontend/webv2/src/features/gallery/data/queries.ts@@ -353,10 +353,20 @@ export const galleryItemsInfiniteOptions = (allPages.length >= GALLERY_MAX_INFINITE_PAGES? undefined: getNextPageParam(normalizedWindow, lastPage, lastPageParam),- getPreviousPageParam: (_firstPage, allPages, firstPageParam) =>- allPages.length < GALLERY_MAX_INFINITE_PAGES && firstPageParam >= GALLERY_PAGE_SIZE+ getPreviousPageParam: (_firstPage, allPages, firstPageParam) => {+ // An anchored INFINITE window must not grow upward past its anchor: its+ // cache key names that start offset, and the grid — which shares the+ // entry and cannot request earlier pages itself — would have 60 items+ // spliced in above its viewport, shifting the content under the user.+ // Paginated anchors keep growing freely: their consumer slices out the+ // one page it wants by pageParam, so a prepend is invisible there, and+ // Preview walks backwards through exactly this mechanism.+ const lowestPageParam = normalizedWindow.kind === 'infinite' ? normalizedWindow.offset : 0;++ return allPages.length < GALLERY_MAX_INFINITE_PAGES && firstPageParam - GALLERY_PAGE_SIZE >= lowestPageParam? firstPageParam - GALLERY_PAGE_SIZE- : undefined,+ : undefined;+ },initialPageParam,maxPages: GALLERY_MAX_INFINITE_PAGES,queryFn: async ({ client, pageParam, signal }) => {diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.browser.test.tsxindex 773d252963..2d52cd930c 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.browser.test.tsx@@ -69,6 +69,7 @@ const boards = [const createGallery = (settings: Partial<GallerySettings> = {}): GalleryStateView =>({+ anchoredWindowPage: 0,boards,compareImageKey: null,currentItem: null,diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsxindex 40c9ff2111..c468f5026e 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx@@ -208,6 +208,7 @@ const createGallery = (overrides: Partial<GalleryStateView> = {}): GalleryStateV];return {+ anchoredWindowPage: 0,boards: [board],compareImageKey: null,currentItem: { itemKey: 'image:first.png', kind: 'item' },@@ -450,6 +451,11 @@ const pointer = (type: string, target: EventTarget, clientX: number, clientY: nu};beforeEach(() => {+ // The reveal channel is a module singleton, so a request from a previous+ // test would otherwise be adopted by the next mount (grids deliberately+ // honor a request that predates them). Drain it with one that can never+ // match an item here.+ requestGalleryItemReveal('image:__drained__');accountLifecycle.activate('grid-user');vi.clearAllMocks();registeredCommands.clear();@@ -1020,6 +1026,46 @@ describe('GalleryImageGrid reveal requests', () => {expect(mocks.scrollToIndex).toHaveBeenCalledTimes(1);});+ it('honors a reveal requested before this grid mounted, while its item is still selected', async () => {+ // The gallery is frequently opened (or swapped between its stacked and+ // wide layouts, which remounts the grid) in response to the very reveal+ // that is outstanding, so a grid must not ignore a request just because+ // it arrived before the mount.+ await interact(() => requestGalleryItemReveal('image:last.png'));+ expect(mocks.scrollToIndex).not.toHaveBeenCalled();++ await renderGallery(createGallery({ selectedItemKey: 'image:last.png', selectedItemKeys: ['image:last.png'] }));++ expect(mocks.scrollToIndex).toHaveBeenCalledTimes(1);+ });++ it('ignores a reveal requested before mount once the selection has moved on', async () => {+ // Age is not what makes a request stale — a superseding selection is.+ await interact(() => requestGalleryItemReveal('image:last.png'));+ await renderGallery(createGallery({ selectedItemKey: 'image:first.png', selectedItemKeys: ['image:first.png'] }));++ expect(mocks.scrollToIndex).not.toHaveBeenCalled();+ });++ it('keeps a reveal pending while its item has no row, then scrolls when one appears', async () => {+ // A starred item under a collapsed Starred section is loaded but has no+ // row to scroll to; consuming the reveal there would silently drop it.+ const starred = createItem('image', 'starred.png', { starred: true });+ const gallery = createGallery({+ items: [starred, createItem('image', 'regular.png')],+ selectedItemKey: 'image:starred.png',+ selectedItemKeys: ['image:starred.png'],+ });++ await renderGallery(gallery);+ await click(getButton('Collapse starred items'));+ await interact(() => requestGalleryItemReveal('image:starred.png'));+ expect(mocks.scrollToIndex).not.toHaveBeenCalled();++ await click(getButton('Expand starred items'));+ expect(mocks.scrollToIndex).toHaveBeenCalledTimes(1);+ });+it('retires a pending reveal once a different selection lands', async () => {const items = [createItem('image', 'first.png')];const gallery = createGallery({ items, selectedItemKey: null, selectedItemKeys: [] });diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsxindex bf111781ae..8b76434cd0 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx@@ -7,7 +7,8 @@ import {type GalleryRevealRequest,} from '@features/gallery/core/revealRequest';import { isDateBoardId } from '@features/gallery/data/backend';-import { DropZone } from '@platform/ui';+import { GALLERY_PAGE_SIZE } from '@features/gallery/data/queries';+import { Button, DropZone } from '@platform/ui';import { ChevronRightIcon, StarIcon, UploadIcon } from 'lucide-react';import {useCallback,@@ -128,7 +129,7 @@ const GalleryStarredSectionHeader = ({export const GalleryImageGrid = () => {const { t } = useTranslation();const { actions, gallery, isWindowTruncated, itemActions, region } = useGalleryWidget();- const { account, antialiasProgressImages, ImageContextMenu } = useGalleryUi();+ const { account, antialiasProgressImages, gallery: galleryCommands, ImageContextMenu } = useGalleryUi();const [isDropActive, setIsDropActive] = useState(false);const [isStarredOpen, setIsStarredOpen] = useState(true);const [viewportWidth, setViewportWidth] = useState(() => viewportWidthCache.get(region) ?? 0);@@ -204,12 +205,16 @@ export const GalleryImageGrid = () => {// an effect event, which always sees the latest render's closure, so a stable// identity would buy nothing and pinning the mutable virtualizer into a// dependency array defeats the compiler's own memoization.- const scrollToItemIndex = (itemIndex: number) => {+ /** Returns whether the item had a row to scroll to — a collapsed section has none. */+ const scrollToItemIndex = (itemIndex: number): boolean => {const rowIndex = getGalleryGridRowIndexForItem(rows, itemIndex);- if (rowIndex >= 0) {- virtualizer.scrollToIndex(rowIndex);+ if (rowIndex < 0) {+ return false;}++ virtualizer.scrollToIndex(rowIndex);+ return true;};useGalleryGridHotkeys({ actionSelectionRefs, columnCount, scrollToItemIndex });@@ -224,7 +229,13 @@ export const GalleryImageGrid = () => {// retries), and is dropped as soon as some other selection supersedes it.const revealRequest = useSyncExternalStore(subscribeGalleryRevealRequests, getGalleryRevealRequest);const pendingRevealRef = useRef<GalleryRevealRequest | null>(null);- const consumedRevealTokenRef = useRef(revealRequest?.token ?? 0);+ // Seeded below any real token so a grid that mounts AFTER the request still+ // honors it: the gallery is often opened (or swapped between its stacked and+ // wide layouts, which remounts this component) in response to the very+ // reveal that is outstanding. Staleness is judged by the selection guard+ // below rather than by age — a request whose item is no longer the selection+ // retires without scrolling.+ const consumedRevealTokenRef = useRef(0);const settlePendingReveal = useEffectEvent(() => {const pending = pendingRevealRef.current;@@ -243,9 +254,12 @@ export const GalleryImageGrid = () => {const itemIndex = gallery.items.findIndex((item) => toGalleryItemKey(item) === pending.itemKey);- if (itemIndex >= 0) {+ // Consumed only once it actually scrolled: the item can be loaded and+ // still have no row — a starred item under a collapsed Starred section —+ // and clearing on the attempt alone would silently drop the reveal+ // instead of honoring it when the section is expanded again.+ if (itemIndex >= 0 && scrollToItemIndex(itemIndex)) {pendingRevealRef.current = null;- scrollToItemIndex(itemIndex);}});@@ -376,6 +390,11 @@ export const GalleryImageGrid = () => {[itemActions]);+ // Releasing the anchor puts the window back over the top of the listing.+ const handleReturnToBoardTop = useCallback(() => galleryCommands.setPage(0), [galleryCommands]);++ const anchoredWindowFirstItem = gallery.anchoredWindowPage * GALLERY_PAGE_SIZE + 1;+return (<Boxref={syncRangeInteractionContext}@@ -391,6 +410,16 @@ export const GalleryImageGrid = () => {onDragOver={handleDragOver}onDrop={handleDrop}>+ {gallery.anchoredWindowPage > 0 ? (+ <Flex align="center" bg="bg.panel" gap="2" justify="space-between" px="2" py="1">+ <Text color="fg.muted" fontSize="2xs" truncate>+ {t('widgets.gallery.windowAnchored', { index: anchoredWindowFirstItem })}+ </Text>+ <Button flexShrink={0} size="2xs" variant="ghost" onClick={handleReturnToBoardTop}>+ {t('widgets.gallery.backToBoardTop')}+ </Button>+ </Flex>+ ) : null}{isEmpty ? (gallery.isLoading || hasActiveSearch || isVirtualBoard ? (<Flex align="center" color="fg.muted" h="full" justify="center" minH="8rem">@@ -517,7 +546,12 @@ export const GalleryImageGrid = () => {{paginationMode === 'infinite' && !gallery.isLoading && isWindowTruncated && (<Flex align="center" justify="center" py="3"><Text color="fg.subtle" fontSize="xs" textAlign="center">- {t('widgets.gallery.windowLimit', { count: gallery.items.length })}+ {gallery.anchoredWindowPage > 0+ ? t('widgets.gallery.windowLimitFrom', {+ count: gallery.items.length,+ index: anchoredWindowFirstItem,+ })+ : t('widgets.gallery.windowLimit', { count: gallery.items.length })}</Text></Flex>)}diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsxindex a7606e266d..e1597454b5 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx@@ -188,8 +188,14 @@ export const GalleryWidgetView = ({ presentation, region, runtime }: GalleryWidgpublishGalleryTotal(total);}, [total]);+ // Runs in BOTH modes: `page` is the paginated page number and also the+ // infinite window's anchor, so either way a page past the end of a shrunken+ // listing renders an empty grid — which, with no search active, reads as an+ // empty board (the upload dropzone) rather than as a stale position.+ // Clamping to the last real page keeps the user near where they were and+ // always shows something that exists.useEffect(() => {- if (settings.paginationMode !== 'paginated' || total === null) {+ if (total === null) {return;}@@ -198,7 +204,7 @@ export const GalleryWidgetView = ({ presentation, region, runtime }: GalleryWidgif (page > maxPage) {galleryCommands.setPage(maxPage);}- }, [galleryCommands, page, settings.paginationMode, total]);+ }, [galleryCommands, page, total]);if (region === 'bottom' && presentation !== 'expanded') {return <GalleryStatusChip count={total ?? gallery.items.length} />;diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.tsindex fbcb2d8a4c..048d538ccc 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryStateView.ts@@ -72,6 +72,13 @@ export type GalleryCurrentItem =| null;export interface GalleryStateView {+ /**+ * Page the infinite window starts at, when a reveal has anchored it+ * mid-board; 0 whenever the window covers the top of the listing (always so+ * in paginated mode). Non-zero means the grid cannot scroll above its first+ * row, so the surface owes the user both an explanation and a way back.+ */+ anchoredWindowPage: number;boards: GalleryBoard[];compareImageKey: GalleryItemKey | null;currentItem: GalleryCurrentItem;@@ -436,6 +443,7 @@ export const getGalleryStateView = (});return {+ anchoredWindowPage: isAnchoredInfiniteWindow ? getGalleryPage(values) : 0,boards,compareImageKey,currentItem,diff --git a/invokeai/frontend/webv2/src/platform/react/virtualizerScrollElementRemount.browser.test.tsx b/invokeai/frontend/webv2/src/platform/react/virtualizerScrollElementRemount.browser.test.tsxindex 7ea702c331..4d4a2fc89f 100644--- a/invokeai/frontend/webv2/src/platform/react/virtualizerScrollElementRemount.browser.test.tsx+++ b/invokeai/frontend/webv2/src/platform/react/virtualizerScrollElementRemount.browser.test.tsx@@ -20,14 +20,28 @@ import { afterEach, describe, expect, it, vi } from 'vitest';const ROW_HEIGHT = 50;+/** The live virtualizer instance, so a test can assert its internal scroll bookkeeping. */+let instance: {+ isScrolling: boolean;+ scrollDirection: string | null;+ scrollToIndex: (index: number) => void;+} | null = null;+const VirtualList = ({ count, isListMounted }: { count: number; isListMounted: boolean }) => {const scrollRef = useRef<HTMLDivElement | null>(null);- const virtualizer = useVirtualizer({- count,- estimateSize: () => ROW_HEIGHT,- getScrollElement: () => scrollRef.current,- overscan: 0,- });+ const virtualizer = useVirtualizer(+ {+ count,+ estimateSize: () => ROW_HEIGHT,+ getScrollElement: () => scrollRef.current,+ overscan: 0,+ },+ (snapshot, virtualizerInstance) => {+ instance = virtualizerInstance as unknown as typeof instance;++ return snapshot;+ }+ );if (!isListMounted) {return <p>loading</p>;@@ -78,10 +92,50 @@ afterEach(async () => {await act(() => root?.unmount());host?.remove();host = null;+ instance = null;root = null;});describe('useVirtualizer scroll element remount', () => {+ it('does not consume a programmatic scroll\u2019s pending intent while reconciling', async () => {+ // virtual-core ignores an incoming scroll event when `isScrolling &&+ // _intendedScrollOffset === null && offset === scrollOffset`. That guard+ // exists so a PROGRAMMATIC scroll's own event still gets through, and it+ // is armed by `_intendedScrollOffset` being non-null. If the+ // reconciliation writes scrollOffset AND clears the intent, all three+ // conditions hold, so every scrollToIndex swallows its own event and+ // leaves `isScrolling` false and `scrollDirection` stale — which is what+ // virtual-core steers dynamic re-measurement by.+ host = document.createElement('div');+ document.body.append(host);+ root = createRoot(host);++ await render(1000, true);+ const scroller = host.querySelector<HTMLElement>('[data-testid="scroller"]');+ const internals = instance as unknown as {+ _intendedScrollOffset: number | null;+ scrollOffset: number | null;+ };++ // The state a programmatic scroll leaves behind: the element has moved,+ // the intent is recorded, and the cached offset is still stale because no+ // scroll event has been delivered yet. Staged and committed in one+ // synchronous block so the commit — and with it the reconciliation — runs+ // before the browser can deliver that event, which is the ordering every+ // scrollToIndex call site in this app produces.+ await act(() => {+ scroller!.scrollTop = 400 * ROW_HEIGHT;+ internals.scrollOffset = 0;+ internals._intendedScrollOffset = 400 * ROW_HEIGHT;+ root?.render(<VirtualList count={1000} isListMounted />);+ });++ // The reconciliation ran: the cached offset now matches the element...+ expect(internals.scrollOffset).toBe(400 * ROW_HEIGHT);+ // ...and it left the pending intent alone, so the guard stays armed.+ expect(internals._intendedScrollOffset).toBe(400 * ROW_HEIGHT);+ });+it('recovers when the restored offset is clamped by shorter remounted content', async () => {host = document.createElement('div');document.body.append(host);diff --git a/invokeai/frontend/webv2/src/workbench/persistence.ts b/invokeai/frontend/webv2/src/workbench/persistence.tsindex 31f2e4ff52..8cfec4c489 100644--- a/invokeai/frontend/webv2/src/workbench/persistence.ts+++ b/invokeai/frontend/webv2/src/workbench/persistence.ts@@ -1,5 +1,7 @@import type { HydratedWorkbenchSnapshot, PersistedWorkbenchSnapshotV1 } from '@workbench/persistenceContracts';-import type { WorkbenchState } from '@workbench/projectContracts';+import type { Project, WorkbenchState } from '@workbench/projectContracts';++import { getGalleryPage, getGallerySettings } from '@features/gallery/contracts';import { timeWorkbenchPerf } from './performanceMarks';@@ -14,6 +16,37 @@ export interface WorkbenchPersistenceService {const isBrowser = (): boolean => typeof window !== 'undefined' && typeof window.localStorage !== 'undefined';+/**+ * In infinite mode the gallery's `galleryPage` is not a page number but the+ * anchor of a mid-board window, set by a reveal from the image map. That is a+ * "you are here" position for the current session: restored a day later it+ * would open the gallery stranded in the middle of a board, with no page+ * control (the footer's is paginated-only) and no way back to the top short of+ * switching boards. Paginated pages stay persisted — there the value really is+ * the page the user was reading.+ */+const stripInfiniteWindowAnchor = (project: Project): Project => {+ let didChange = false;+ const widgetInstances = Object.fromEntries(+ Object.entries(project.widgetInstances).map(([instanceId, instance]) => {+ const values = instance.state.values;++ if (+ instance.typeId !== 'gallery' ||+ getGallerySettings(values).paginationMode !== 'infinite' ||+ getGalleryPage(values) === 0+ ) {+ return [instanceId, instance];+ }++ didChange = true;+ return [instanceId, { ...instance, state: { ...instance.state, values: { ...values, galleryPage: 0 } } }];+ })+ );++ return didChange ? { ...project, widgetInstances } : project;+};+export const stripTransientWorkbenchState = (state: WorkbenchState): WorkbenchState => {const { errorLog: _legacyErrorLog, ...nextState } = state as WorkbenchState & { errorLog?: string[] };@@ -24,7 +57,7 @@ export const stripTransientWorkbenchState = (state: WorkbenchState): WorkbenchSt// snapshots immediately and never let full-project undo entries consume// localStorage quota or grow across browser sessions.projects: nextState.projects.map((project) => ({- ...project,+ ...stripInfiniteWindowAnchor(project),undoRedo: { future: [], past: [] },})),};diff --git a/invokeai/frontend/webv2/src/workbench/projects/projectAssets.ts b/invokeai/frontend/webv2/src/workbench/projects/projectAssets.tsindex 3d0e3dd9db..65b33f444c 100644--- a/invokeai/frontend/webv2/src/workbench/projects/projectAssets.ts+++ b/invokeai/frontend/webv2/src/workbench/projects/projectAssets.ts@@ -57,7 +57,20 @@ export const GALLERY_SELECTION_KEYS: ReadonlySet<string> = new Set([*/export const GALLERY_INSTALLATION_KEYS: ReadonlySet<string> = new Set(['projectBoardId', 'selectedBoardId']);-const INSTALLATION_STATE_KEYS: ReadonlySet<string> = new Set([...GALLERY_SELECTION_KEYS, ...GALLERY_INSTALLATION_KEYS]);+/**+ * Where the gallery was scrolled to. Meaningless in another install: the board+ * ids above are stripped, so an imported project lands on a different (usually+ * near-empty) board, where a page number — or, in infinite mode, the mid-board+ * window anchor it doubles as — describes a position that does not exist and+ * renders as an empty board.+ */+export const GALLERY_POSITION_KEYS: ReadonlySet<string> = new Set(['galleryPage']);++const INSTALLATION_STATE_KEYS: ReadonlySet<string> = new Set([+ ...GALLERY_SELECTION_KEYS,+ ...GALLERY_INSTALLATION_KEYS,+ ...GALLERY_POSITION_KEYS,+]);/*** URLs the document caches beside a media name, naming *this* install's copy.diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.tsindex c352bb9af3..a5dcb2d3b6 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts@@ -2969,6 +2969,57 @@ describe('workbenchReducer Phase 5 generation flow', () => {expect(galleryValues.selectedImageName).toBe('image:gallery-image.png');});+ it('releases a mid-board infinite window anchor when a result lands on the viewed board', () => {+ // A deep reveal from the image map anchors the infinite window mid-board.+ // New images land at the TOP of that listing, which the anchored window+ // never covers — and an anchored window also suppresses the recents+ // overlay and the queue placeholders, so without releasing the anchor the+ // user would never see their own generation appear.+ let state = primeGenerate();++ state = workbenchReducer(state, { destination: 'gallery', type: 'setInvocationDestination' });+ state = workbenchReducer(state, { page: 11, type: 'setGalleryPage' });+ state = submitGenerate(state);++ const project = getActiveProject(state);+ const queueItem = project.queue.items[0];++ expect(getProjectWidgetValues(project, 'gallery').galleryPage).toBe(11);++ state = workbenchReducer(state, {+ images: [createImage('fresh.png', queueItem.id)],+ projectId: project.id,+ queueItemId: queueItem.id,+ type: 'routeQueueItemResults',+ });++ expect(getProjectWidgetValues(getActiveProject(state), 'gallery').galleryPage).toBe(0);+ });++ it('leaves the window anchor alone when the result lands on a board that is not being viewed', () => {+ // The anchor describes the viewed board's listing; a result arriving in+ // some other board says nothing about where the user is looking.+ let state = primeGenerate();++ state = workbenchReducer(state, { destination: 'gallery', type: 'setInvocationDestination' });+ state = workbenchReducer(state, { boardId: 'board-elsewhere', type: 'selectGalleryBoard' });+ state = submitGenerate(state);++ const project = getActiveProject(state);+ const queueItem = project.queue.items[0];++ state = workbenchReducer(state, { boardId: 'board-viewed', type: 'selectGalleryBoard' });+ state = workbenchReducer(state, { page: 11, type: 'setGalleryPage' });+ state = workbenchReducer(state, {+ images: [createImage('elsewhere.png', queueItem.id)],+ projectId: project.id,+ queueItemId: queueItem.id,+ type: 'routeQueueItemResults',+ });++ expect(getProjectWidgetValues(getActiveProject(state), 'gallery').galleryPage).toBe(11);+ });+it('preserves the destination board on freshly routed Gallery results', () => {let state = primeGenerate();diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.tsindex 2689c6548d..5bfcc2ab03 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts@@ -52,6 +52,7 @@ import type {import {getBoundedRecentImages,+ getGalleryPage,getPersistedSelectedGalleryItemKeys,getGallerySettings,getSelectedGalleryItemFromValues,@@ -2792,9 +2793,22 @@ const updateGalleryWithResultImages = (project: Project, images: GeneratedImageCconst nextSelectedItem = nextSelectedImage ? legacyGeneratedImageToGalleryItem(nextSelectedImage) : undefined;const nextSelectedItemKey = nextSelectedItem ? toGalleryItemKey(nextSelectedItem) : undefined;const gallerySettings = getGallerySettings(galleryValues);+ // A deep reveal from the image map anchors the infinite window mid-board.+ // New images land at the TOP of that board's listing, which such a window+ // never covers — and an anchored window also suppresses the recents overlay+ // and the queue placeholders. Release the anchor when an incoming image+ // belongs to the board being viewed, or the user would never see their own+ // generation appear. Scoped to that board: an anchor on some other board's+ // listing has nothing to do with this result.+ const viewedBoardId = typeof galleryValues.selectedBoardId === 'string' ? galleryValues.selectedBoardId : 'none';+ const releasesWindowAnchor =+ gallerySettings.paginationMode === 'infinite' &&+ getGalleryPage(galleryValues) > 0 &&+ newImages.some((image) => image.boardId === viewedBoardId);return updateProjectWidgetValues(project, 'gallery', () => ({...galleryValues,+ ...(releasesWindowAnchor ? { galleryPage: 0 } : {}),recentImages: getBoundedRecentImages([...newImages, ...previousImages]),selectedImage: nextSelectedItem ?? galleryValues.selectedImage,selectedImageName: nextSelectedItemKey ?? galleryValues.selectedImageName,