fix: Updates for text-context updation after regenerating image#726
Merged
Avijit-Microsoft merged 3 commits intomicrosoft:devfrom Feb 20, 2026
Merged
Conversation
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
approved these changes
Feb 20, 2026
Contributor
|
🎉 This PR is included in version 2.2.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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?
Golden Path Validation
Deployment Validation
What to Check
Verify that the following are valid
Other Information