[WOOMOB-3229] Cache edit and view context variation images separately#16272
[WOOMOB-3229] Cache edit and view context variation images separately#16272irfano wants to merge 11 commits into
Conversation
Generated by 🚫 Danger |
|
|
There was a problem hiding this comment.
AI Code Review - Found 2 potential issues
The core approach (splitting the variation's own image into editContextImage and keeping the display image separate, merging by fetch context) is sound and well tested. One issue below is in a file outside this PR's diff, so it is described here rather than inline.
[fix here] The variation detail screen still reads variation.image and will now show the wrong image. VariationDetailFragment.showVariationDetails() (lines 340 and 350, an unchanged file) still branches on variation.image to decide between the "Add image" placeholder and rendering the image. But the variation detail screen fetches with edit context (VariationDetailRepository.fetchVariation -> fetchSingleVariation(context = "edit")), and mergeEditContextResponse moves the response image into editContextImage while setting image to the stored display image (empty when none was previously fetched via view context). As a result, for a variation that has its own image, variation.image is null and the screen shows the "Add image" placeholder instead of the image; likewise a freshly uploaded image (now written to editContextImage, VariationDetailViewModel.kt:456) will not render. The list adapter and ViewModel were switched to editContextImage, but this Fragment was missed. Please update showVariationDetails() to use editContextImage.
Automatic review · claude-opus-4-8 · Workflow run
How to reply to a finding
Reply on this review (or inline at the line the finding refers to) with one of:
@claude addressed- I made the change. Bot verifies against the next diff before marking resolved.@claude rejected: <reason>- Will not fix; reason gets quoted on the next review.@claude not-applicable- Finding does not apply (wrong file, already covered elsewhere, etc.).
The bot honours these on the next review pass.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## issue/WOOMOB-3229-variation-image-removal #16272 +/- ##
===============================================================================
- Coverage 41.16% 41.16% -0.01%
- Complexity 13509 13522 +13
===============================================================================
Files 2503 2503
Lines 146464 146517 +53
Branches 21760 21773 +13
===============================================================================
+ Hits 60295 60310 +15
- Misses 80044 80085 +41
+ Partials 6125 6122 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@samiuelson, can you please test the POS case in the test steps and confirm that the code changes don’t affect POS screens? |
Hi, @irfano, I verified POS displays variation images as expected 👍 |

Description
This PR restores the variation images that #16245 unintentionally changed in the order creation picker and POS back to the trunk behavior, fixes the issues #16245 introduced, and fixes a variation image bug that exists on trunk.
WooCommerce renders a variation image in two contexts: edit context returns only the variation's own image, while view context returns the variation's own image, falling back to the parent product's image when the variation has none. #16245 switched the product screens to edit context but kept a single cached image, so the cache carried whichever context last wrote it. This PR stores the two values separately:
imagekeeps the view value for the display surfaces, and the neweditContextImagecolumn keeps the variation's own image for the editing screens and the update request.#16245 fixed the image removal, gave the editing screens their placeholder, and stopped the details screen from copying the image on save. This PR fixes what remained on that branch. In the examples below, a T-shirt product has a product image showing the white T-shirt, and its Blue variation has no image of its own, so the store shows the white T-shirt image for Blue.
Outside the product editing flows everything keeps fetching with view context and showing the same images as trunk. No POS code is touched in this PR.
Test Steps
Saving no longer copies the parent image onto the variation
Placeholder on the editing screens
Order creation picker keeps the product image after visiting the variations screen
Opening the variations screen first is what used to break the picker, so the first steps set that condition up.
POS shows the product image as before
POS reads the view context image, so it looks the same as trunk even after the variations screen writes the edit data. The first steps set that condition up.
Images/gif
N/A
RELEASE-NOTES.txtif necessary. Use the "[Internal]" label for non-user-facing changes.