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(webv2): show loading feedback on image map retries

joshistoast9de97824393f
diff --git a/invokeai/frontend/webv2/src/workbench/image-map/imageMap.test.ts b/invokeai/frontend/webv2/src/workbench/image-map/imageMap.test.ts
index 7695a9b66c..595c23084a 100644
--- a/invokeai/frontend/webv2/src/workbench/image-map/imageMap.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-map/imageMap.test.ts
@@ -217,6 +217,33 @@ describe('image map store', () => {
expect(snapshot.error).toBe('Failed to load the image map');
expect(snapshot.data?.points).toHaveLength(2);
});
+
+ it('enters loading while retrying a failed points request', async () => {
+ const response = {
+ model_name: null,
+ point_count: 0,
+ points: [],
+ stale: false,
+ state: 'disabled',
+ updated_at: null,
+ };
+ let resolveRequest: (value: typeof response) => void = () => {};
+ const request = new Promise<typeof response>((resolve) => {
+ resolveRequest = resolve;
+ });
+
+ imageMapStore.patchSnapshot({ error: 'previous failure', loadState: 'error' });
+ mocks.apiFetchJson.mockReturnValueOnce(request);
+
+ const refresh = refreshImageMapPoints();
+
+ try {
+ expect(imageMapStore.getSnapshot().loadState).toBe('loading');
+ } finally {
+ resolveRequest(response);
+ await refresh;
+ }
+ });
});
describe('cluster palette', () => {
diff --git a/invokeai/frontend/webv2/src/workbench/image-map/imageMapStore.ts b/invokeai/frontend/webv2/src/workbench/image-map/imageMapStore.ts
index 738b43fdfd..5bdb97f730 100644
--- a/invokeai/frontend/webv2/src/workbench/image-map/imageMapStore.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-map/imageMapStore.ts
@@ -89,10 +89,7 @@ export const refreshImageMapPoints = (): Promise<void> => {
}
const owner = captureAccountScope();
-
- if (imageMapStore.getSnapshot().loadState === 'idle') {
- imageMapStore.patchSnapshot({ loadState: 'loading' });
- }
+ imageMapStore.patchSnapshot({ loadState: 'loading' });
const refresh = fetchImageMapPoints()
.then((data) => {