Skip to content

feat: regenerate AI post images with brand palette#57

Merged
paulocastellano merged 12 commits into
mainfrom
feat/ai-image-regenerate
May 21, 2026
Merged

feat: regenerate AI post images with brand palette#57
paulocastellano merged 12 commits into
mainfrom
feat/ai-image-regenerate

Conversation

@paulocastellano
Copy link
Copy Markdown
Contributor

Summary

  • Add Adjust flow in the post editor to regenerate AI media in place (async job + Echo + toast), replacing the slide without changing carousel length.
  • Apply workspace brand, background, and text colors to AI image prompts across all image styles.
  • Swap autofill background ↔ text when populating workspace brand colors (site body text → image background, site page background → in-image text).

Hardening

  • Block regeneration on finalized posts (published, publishing, etc.)
  • Transactional media swap with rendered file cleanup on failure
  • Record text AI usage for the image copy rewriter
  • Dialog UX: loading state, timeout, no dismiss while processing; Adjust button moved to bottom-left

Test plan

  • php artisan test on PostAiRegenerateMedia, RegeneratePostMediaImageJob, BrandImagePalette, AiImageClient, UpdatePostRequest
  • Edit a draft post with AI carousel → Adjust → instruction → image replaces in same position + success toast
  • Autofill brand from a light website → background dark / text light in form
  • Published post → Adjust not shown / regenerate API returns 422
  • Regenerate non-AI media → 422

Made with Cursor

paulocastellano and others added 12 commits May 21, 2026 16:27
Let users adjust AI-generated slides in place via async job and Echo, while applying workspace brand, background, and text colors to image prompts. Autofill swaps site text/background colors for the image palette, and regeneration is blocked on finalized posts with safer job cleanup.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Added guidelines for AI agents to avoid embedding prompts in PHP and to store them in Blade files under `resources/views/prompts/`.
- Updated `PostImageRegenerator` to render prompts using Blade instead of heredocs, improving maintainability and consistency with project standards.
- Enhanced documentation in `CLAUDE.md` and `.cursor/rules` files to reflect these changes.
…nitions

- Refactored the media item interface by moving it to a dedicated type file, enhancing code organization and reusability across components.
- Updated various components to import the new MediaItem type, ensuring consistency and reducing redundancy in type definitions.
- Improved the RegeneratePostMediaImage job by optimizing the media regeneration process and enhancing error handling for better reliability.
- Improved type definitions for regeneration status and event handling, increasing clarity and maintainability.
- Streamlined the regeneration result handling by introducing a dedicated function to manage success and error states.
- Added computed properties to optimize form submission logic, ensuring better user experience and validation.
- Refactored the subscription logic to improve readability and error handling during media regeneration.
…sGuard

- Replaced direct status checks in multiple controllers and actions with the PostStatusGuard utility, improving code readability and maintainability.
- Updated error messages to utilize a centralized method for consistency across the application.
- Removed the BrandImagePalette class, consolidating color resolution logic into the AiImageClient for better organization and type safety.
…ting and deletion checks

- Removed the PostStatusGuard class and replaced its usage with the new PostStatusRules utility across multiple controllers and actions, enhancing code organization and maintainability.
- Updated error message handling to utilize the centralized method in PostStatusRules, ensuring consistency in user feedback.
- Deleted associated tests for PostStatusGuard, reflecting the removal of the class.
…ype safety

- Replaced custom regeneration logic with a composable for improved organization and reusability.
- Streamlined state management and error handling, enhancing clarity and maintainability.
- Removed unused imports and interfaces, reducing code complexity and improving readability.
- Updated computed properties for better form submission validation and user experience.
- Introduced a new `regenerate_image` boolean parameter in the PostImageRegenerator schema to control background image regeneration.
- Updated relevant methods in RegeneratePostMediaImage and TemplateImageGenerator to utilize the new parameter for reusing existing backgrounds when appropriate.
- Enhanced documentation and comments to clarify the usage of the `regenerate_image` option.
- Added tests to ensure correct behavior when reusing background images.
…ration

- Replaced the `regenerate_image` boolean with a `change_mode` string parameter in the PostImageRegenerator schema, allowing for more granular control over regeneration options.
- Updated methods in RegeneratePostMediaImage to handle the new `change_mode` values: `image_only`, `text_only`, and `both`.
- Enhanced documentation and comments to clarify the new regeneration logic.
- Added tests to verify correct behavior for different regeneration modes, ensuring that text and image changes are handled appropriately.
- Added consistent imports of the MediaItem type across various components, including FacebookSettings, InstagramSettings, LinkedInSettings, PinterestSettings, PreviewTab, InstagramPreview, and PlatformPreview.
- This change enhances code organization and ensures uniformity in type definitions throughout the project.
@paulocastellano paulocastellano merged commit 7a59861 into main May 21, 2026
2 checks passed
@paulocastellano paulocastellano deleted the feat/ai-image-regenerate branch May 21, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant