Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: invalidate an in-flight gallery-picker upload on unmount too (#4127)
[._.]/ Adam Eivya65ffe02bc60
diff --git a/client/src/components/imageGen/GalleryImagePicker.jsx b/client/src/components/imageGen/GalleryImagePicker.jsxindex 237b02d5ec..114a61fdd2 100644--- a/client/src/components/imageGen/GalleryImagePicker.jsx+++ b/client/src/components/imageGen/GalleryImagePicker.jsx@@ -67,10 +67,14 @@ export default function GalleryImagePicker({// '' = All. Otherwise `uni:<id>` or `col:<id>`.const [scope, setScope] = useState('');const [type, setType] = useState('');- // Bumped on every open/close transition, so an async upload can tell whether- // the picker session it started in is still the current one.+ // Bumped on every open/close transition — and on unmount, for a host that+ // tears the picker down instead of toggling `open` — so an async upload can+ // tell whether the picker session it started in is still the current one.const sessionRef = useRef(0);- useEffect(() => { sessionRef.current += 1; }, [open]);+ useEffect(() => {+ sessionRef.current += 1;+ return () => { sessionRef.current += 1; };+ }, [open]);// Fetch the gallery each time the picker opens so newly generated images show// up without a page reload. Reset the search on close so a re-open starts clean.diff --git a/client/src/components/imageGen/GalleryImagePicker.test.jsx b/client/src/components/imageGen/GalleryImagePicker.test.jsxindex 604fed028c..ed0eebb677 100644--- a/client/src/components/imageGen/GalleryImagePicker.test.jsx+++ b/client/src/components/imageGen/GalleryImagePicker.test.jsx@@ -181,6 +181,22 @@ describe('GalleryImagePicker', () => {expect(onClose).not.toHaveBeenCalled();});+ // Same guarantee for a host that tears the picker down (route change, or a+ // parent that conditionally renders it) rather than toggling `open`.+ it('drops an upload that lands after the picker unmounted', async () => {+ let settleUpload;+ uploadGalleryImage.mockReturnValue(new Promise((resolve) => { settleUpload = resolve; }));+ const onSelect = vi.fn();+ const { unmount } = render(<GalleryImagePicker open allowUpload onSelect={onSelect} onClose={vi.fn()} />);+ await pickFile(new File(['x'], 'photo.png', { type: 'image/png' }));+ await waitFor(() => expect(uploadGalleryImage).toHaveBeenCalledTimes(1));++ unmount();+ await act(async () => { settleUpload({ filename: 'late.png', path: '/data/images/late.png' }); });++ expect(onSelect).not.toHaveBeenCalled();+ });+it('allows a large file when no host cap narrows the wire limit', async () => {uploadGalleryImage.mockResolvedValue({ filename: 'big.png', path: '/data/images/big.png' });render(<GalleryImagePicker open allowUpload onSelect={vi.fn()} onClose={vi.fn()} />);