Skip to content

Show refined/edited/restyled images in candidates panel#2174

Open
SajalChaplot wants to merge 3 commits into
mainfrom
ai_main_e5f966ce7f2e4fe8a37d
Open

Show refined/edited/restyled images in candidates panel#2174
SajalChaplot wants to merge 3 commits into
mainfrom
ai_main_e5f966ce7f2e4fe8a37d

Conversation

@SajalChaplot

@SajalChaplot SajalChaplot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Refine, edit, and restyle actions now pass an appendVariant flag through to generate-image so 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 appendVariant flag from edit-image, refine-image, and restyle-image through to generate-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 forward ActionRunContext and set appendVariant: true when delegating to generate-image.run.
  • generate-image.ts: adds an appendVariant boolean arg (default false) and threads it through pending/ready/failed variant slot upserts.
  • variant-slots.ts: upsertVariantSlot now appends to the previous state when appendVariant is true and the library matches, instead of resetting the candidate scope; cross-library appends are still rejected.
  • Updated specs for edit-image, restyle-image, and variant-slots to cover context passing, appendVariant forwarding, and append/reset behavior including cross-library isolation.
  • Added changelog entry noting refined images now appear in the Generated candidates panel, newest first.

Edit in Builder  Preview


To clone this PR locally use the Github CLI with command gh pr checkout 2174

You can tag me at @BuilderIO for anything you want me to fix or change

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@builder-io-integration builder-io-integration Bot changed the title Update from the Builder.io agent Show refined/edited/restyled images in candidates panel Jul 16, 2026
@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Here's a visual recap of what changed:

Visual recap

Open the full interactive recap

@builder-io-integration builder-io-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment on lines +104 to +109
const appendToPrevious =
previous != null &&
input.appendVariant === true &&
previous.libraryId === input.libraryId;
const state =
previous && isSameVariantScope(previous, input)
previous && (isSameVariantScope(previous, input) || appendToPrevious)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Fix in Builder

@builder-io-integration builder-io-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment on lines +104 to +109
const appendToPrevious =
previous != null &&
input.appendVariant === true &&
previous.libraryId === input.libraryId;
const state =
previous && isSameVariantScope(previous, input)
previous && (isSameVariantScope(previous, input) || appendToPrevious)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Fix in Builder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants