Commit f9d26b8
fix(core): Refresh MediaPicker3 thumbnails after AI-driven value changes
The MediaPicker3 thumbnail subcomponent fetches the rendered media on
mount and doesn't re-fetch when its mediaKey prop changes within an
existing picker entry. So when an LLM swaps an image via set_value, the
underlying value is correct (right mediaKey, right entry shape) but the
visible thumbnail keeps showing the previous image until the user saves
and reloads.
Lit re-mounts a subcomponent only when its surrounding entry key
changes, so to force a fresh fetch we re-mint the entry's `key`
(distinct from `mediaKey`) when its content actually changed. The prior
hand-rolled `[0].key = uuidv4()` only fired on string-parsed input and
only touched the first entry; the new path:
- Compares each incoming entry to the same-keyed entry in the current
staged value.
- Regenerates the key only when the entry exists in the old value AND
its non-key content differs. This forces re-mount for replaced
entries.
- Leaves keys alone when content is identical (no churn for entries the
LLM didn't touch — focal points, crops, etc. stay stable).
- Leaves keys alone for entries whose key isn't in the old value at all
— those are genuinely new (e.g. minted by `add_item`'s handler) and
the LLM may reference them via `remove_item({ blockKey })` later, so
we must not change them.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 297cbe4 commit f9d26b8
1 file changed
Lines changed: 39 additions & 3 deletions
File tree
- Umbraco.AI/src/Umbraco.AI.Web.StaticAssets/Client/src/entity-adapter/adapters
Umbraco.AI/src/Umbraco.AI.Web.StaticAssets/Client/src/entity-adapter/adapters/value-preparation.ts
Lines changed: 39 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | 48 | | |
52 | 49 | | |
53 | 50 | | |
54 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
55 | 86 | | |
56 | 87 | | |
57 | 88 | | |
| |||
63 | 94 | | |
64 | 95 | | |
65 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
0 commit comments