Show refined/edited/restyled images in candidates panel#2174
Show refined/edited/restyled images in candidates panel#2174SajalChaplot wants to merge 3 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Here's a visual recap of what changed: Open the full interactive recap |
There was a problem hiding this comment.
Builder reviewed your changes and found 1 potential issue 🟡
Review Details
Code Review Summary
PR #2174 updates the Assets image-generation flow so edit, refine, and restyle actions preserve their action run context and append newly generated candidates to the live asset-variants tray. The implementation adds an opt-in appendVariant flag to generate-image, protects against cross-library merges, and includes focused unit coverage for delegation and slot behavior. The overall approach is sound, and the serialized variant-state lock is a good safeguard for concurrent slot updates.
Key Findings
Medium: Appending a refinement changes the retained tray’s run/batch identity. If a user refines a ready candidate while sibling slots from the original batch are still pending, a later sibling completion no longer matches the stored scope and can reset the tray, dropping the refinement and other candidates. The retained original batch boundary should be preserved, or late sibling updates should merge by their original slot/run identity.
Verification
Focused variant-slots tests passed (10 tests). This is a standard-risk state-management change. Browser verification was attempted for the affected Assets flows, but the executor environment exposed no browser automation tools, so the flows could not be exercised.
🧪 Browser testing: Will run after this review (PR touches UI code)
| const appendToPrevious = | ||
| previous != null && | ||
| input.appendVariant === true && | ||
| previous.libraryId === input.libraryId; | ||
| const state = | ||
| previous && isSameVariantScope(previous, input) | ||
| previous && (isSameVariantScope(previous, input) || appendToPrevious) |
There was a problem hiding this comment.
🟡 Appending a refinement lets in-flight batch completions reset the tray
appendToPrevious retains the prior batch's slots, but the unconditional assignments above replace that retained state's runId/batchId with the refinement's run, whose batch ID is null. If a user refines an already-ready candidate while siblings from the original generate-image-batch are still pending, a sibling's later ready/failed upsert has appendVariant: false and its original batch ID; it no longer matches the state and takes the reset branch, dropping the refinement and other candidates. Preserve the original batch identity for append-only writes or merge late in-flight sibling updates by their original slot/run identity.
Additional Info
Confirmed by independent code-review agent; focused variant-slots tests passed but do not cover refinement during an in-flight batch.
There was a problem hiding this comment.
Builder reviewed your changes and found 1 potential issue 🟡
Review Details
Incremental Code Review Summary
The latest commit adds integration coverage around generate-image and broadens append behavior so source-asset-driven calls automatically append to the current candidate tray. The new tests exercise real application-state read/modify/write behavior, fresh-generation resets, direct sourceAssetId calls, and action context forwarding. The implementation is generally sound, and the added integration coverage is valuable.
The previously reported concurrency issue at variant-slots.ts:104-109 remains unresolved and was intentionally not reposted. This incremental review found one additional user-visible issue: when an append reuses the existing tray state, the unconditional metadata assignments replace the tray's original prompt with the refinement prompt. Since the tray displays variants.prompt as its subtitle, the candidate panel loses the original generation context after a refinement.
Key Findings
Medium: Preserve the original tray prompt when appending a refinement, or store refinement context separately. Metadata should only be replaced for a genuinely new generation scope or same-scope batch update.
Focused tests and typechecking reported by the review agents passed (17 focused tests and typecheck). This remains a standard-risk state-management/UI behavior change.
🧪 Browser testing: Will run after this review (PR touches UI code)
| const appendToPrevious = | ||
| previous != null && | ||
| input.appendVariant === true && | ||
| previous.libraryId === input.libraryId; | ||
| const state = | ||
| previous && isSameVariantScope(previous, input) | ||
| previous && (isSameVariantScope(previous, input) || appendToPrevious) |
There was a problem hiding this comment.
🟡 Appending a refinement overwrites the tray prompt
When this branch reuses the existing tray state for appendToPrevious, the unconditional metadata assignments immediately below replace its prompt with the refinement prompt. GenerationResults displays this field as the candidate-panel subtitle, so after refining a candidate the tray loses the original batch prompt and shows the longer feedback text instead. Preserve the original tray prompt for append operations, or track refinement context separately while only replacing metadata for a new generation scope.
Additional Info
Found by an independent incremental review agent; the added integration test verifies slot preservation but not the prompt shown after append.

Summary
Refine, edit, and restyle actions now pass an
appendVariantflag through togenerate-imageso their results are added to the existing candidate tray instead of resetting it, with newest results shown first.Problem
When a user sent a prompt to refine (or edit/restyle) a generated asset, the resulting image was not surfaced in the Generated candidates UI alongside the original candidates, making it hard to compare the refined result with prior options.
Solution
Propagate the action's run context and a new
appendVariantflag fromedit-image,refine-image, andrestyle-imagethrough togenerate-image, which forwards it to the variant slot state so the refined candidate is appended to the existing live tray for the same library/scope rather than starting a fresh candidate set.Key Changes
edit-image.ts,refine-image.ts,restyle-image.ts: accept and forwardActionRunContextand setappendVariant: truewhen delegating togenerate-image.run.generate-image.ts: adds anappendVariantboolean arg (defaultfalse) and threads it through pending/ready/failed variant slot upserts.variant-slots.ts:upsertVariantSlotnow appends to the previous state whenappendVariantis true and the library matches, instead of resetting the candidate scope; cross-library appends are still rejected.edit-image,restyle-image, andvariant-slotsto cover context passing,appendVariantforwarding, and append/reset behavior including cross-library isolation.To clone this PR locally use the Github CLI with command
gh pr checkout 2174You can tag me at @BuilderIO for anything you want me to fix or change