Skip to content

fix(image-panel): keep freshly-generated image on screen - #152

Merged
Eslam93 merged 2 commits into
mainfrom
fix/image-panel-disappear
May 16, 2026
Merged

Eslam93 merged 2 commits into
mainfrom
fix/image-panel-disappear

Conversation

@Eslam93

@Eslam93 Eslam93 commented May 16, 2026

Copy link
Copy Markdown
Owner

Symptom

After clicking Generate, the new image flashed on screen, then disappeared. Reopening the content-detail modal made it reappear correctly.

Cause

useImageGenerateMutation called invalidateQueries on success. Invalidation queues a refetch but does not update the cache. The panel renders from list.data — during the refetch window, that snapshot still came from before the mutation, so the new image was not yet visible and the now-superseded is_current row stayed marked current.

Fix

onSuccess now writes the new image into the list cache via setQueryData and flips any prior is_current=true row to false in the same update. The panel renders the new image on the next frame with no refetch.

Also (operational, not in this diff)

Deleted 8 orphan generated_images rows whose underlying files no longer existed on disk. App Runner uses ephemeral filesystem for local-images/, so images written before today's prompt-builder redeploy returned 404. Going forward this becomes a non-issue when image storage moves to S3 (already in "What I'd add next").

Test plan

Eslam93 added 2 commits May 16, 2026 13:12
The mutation success used to call invalidateQueries, which queues a
refetch but does not update the cache. The panel renders from
list.data, so during the refetch window list.data still pointed at
the pre-mutation snapshot — the brand-new image hadn't landed yet and
the prior current row stayed marked is_current. The visible effect
was a flash where the new image rendered, then vanished, then
reappeared once the modal remounted the query.

Switching onSuccess to setQueryData closes the gap: the new image is
written into the list cache atomically, prior is_current rows are
demoted in the same update, and the panel renders the new image on
the next frame with no refetch needed.
@Eslam93
Eslam93 merged commit 52dc30b into main May 16, 2026
2 checks passed
@Eslam93
Eslam93 deleted the fix/image-panel-disappear branch May 16, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant