Repository navigation
fix(image-panel): keep freshly-generated image on screen - #152
Merged
Merged
Conversation
… + specificity checklist
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
After clicking Generate, the new image flashed on screen, then disappeared. Reopening the content-detail modal made it reappear correctly.
Cause
useImageGenerateMutationcalledinvalidateQuerieson success. Invalidation queues a refetch but does not update the cache. The panel renders fromlist.data— during the refetch window, that snapshot still came from before the mutation, so the new image was not yet visible and the now-supersededis_currentrow stayed marked current.Fix
onSuccessnow writes the new image into the list cache viasetQueryDataand flips any prioris_current=truerow tofalsein 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_imagesrows whose underlying files no longer existed on disk. App Runner uses ephemeral filesystem forlocal-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
NEXT_OUTPUT=export pnpm buildsucceeds