Skip to content

fix: Updates for text-context updation after regenerating image#726

Merged
Avijit-Microsoft merged 3 commits intomicrosoft:devfrom
NirajC-Microsoft:fix-text-context
Feb 20, 2026
Merged

fix: Updates for text-context updation after regenerating image#726
Avijit-Microsoft merged 3 commits intomicrosoft:devfrom
NirajC-Microsoft:fix-text-context

Conversation

@NirajC-Microsoft
Copy link
Contributor

Purpose

Fix descriptive text (body, tagline, headline) not updating to reflect the new color/product name after image regeneration.

When a user regenerates an image with a different color (e.g., switching from "Porcelain Mist" to "Pine Shadow"), the image and product name updated correctly, but the marketing copy still displayed the old color name. Additionally, navigating away and returning to the conversation reverted the text to the original color because the persisted text_content in Cosmos DB was never updated.

Root Cause

Frontend (App.tsx): The regeneration handler spread the old generatedContent.text_content unchanged into the new state — only image_content was replaced.

Backend (app.py): The /api/regenerate persistence logic saved updated image fields and selected_products but never touched text_content. The orchestrator stores text_content as either a string or dict, but the replacement code only handled the dict case, so it silently skipped most updates.

Fix

App.tsx: Added a swapName helper in the regeneration success handler that performs a case-insensitive find-and-replace of the old product name with the new one across all text_content fields (headline, body, tagline, cta_text) before setting state.

app.py: Added the same name replacement in the Cosmos DB persistence block, handling both dict and str formats of text_content, so the updated copy survives conversation reloads.

Does this introduce a breaking change?

  • Yes
  • No

Golden Path Validation

  • I have tested the primary workflows (the "golden path") to ensure they function correctly without errors.

Deployment Validation

  • I have validated the deployment process successfully and all services are running as expected with this change.

What to Check

Verify that the following are valid

  • ...

Other Information

This comment was marked as resolved.

NirajC-Microsoft and others added 2 commits February 20, 2026 09:05
Accepting Copilot PR reviewer suggestion to use lambda functions

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Accepted the Suggestion by Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Avijit-Microsoft Avijit-Microsoft merged commit e6ce244 into microsoft:dev Feb 20, 2026
4 checks passed
@github-actions
Copy link
Contributor

🎉 This PR is included in version 2.2.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants