Skip to content

Conversation

@ysmoradi
Copy link
Member

@ysmoradi ysmoradi commented Jul 11, 2025

closes #11097

Summary by CodeRabbit

  • New Features

    • Added support for alternative text (alt text) for product primary images, including a new field for editing and displaying alt text in the product interface.
    • Integrated AI-based image analysis to automatically generate descriptive alt text for uploaded primary product images.
    • Alt text is now stored and managed as part of product data.
  • Localization

    • Added translations for the new alt text field in supported languages.

@ysmoradi ysmoradi requested a review from Copilot July 11, 2025 15:24
@coderabbitai
Copy link

coderabbitai bot commented Jul 11, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce automatic generation and management of alternative text (alt text) for product primary images during file upload. This includes AI-based analysis of uploaded images to generate descriptive alt text, model and database updates to store the alt text, UI modifications to display and edit it, and localization support for the new field.

Changes

File(s) Change Summary
.../AddOrEditProductPage.razor, .../AddOrEditProductPage.razor.cs UI updated to display and bind a new "AltText" field for product images; file upload handler now receives and assigns AI-generated alt text.
.../AttachmentController.cs AI-based image analysis integrated into file upload; parses JSON response for alt text and car detection, returns alt text in response.
.../Product.cs, .../ProductDto.cs Added nullable PrimaryImageAltText property to product model and DTO.
.../20250711145344_Initial.cs, .../20250711145344_Initial.Designer.cs, .../AppDbContextModelSnapshot.cs Database migration and model snapshot updated to add PrimaryImageAltText column to products.
.../AppStrings.resx, .../AppStrings.fa.resx Added "AltText" resource string for localization (English and Persian).

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant UI as Product Page UI
    participant Server as AttachmentController
    participant AI as AI Chat Client

    User->>UI: Uploads product primary image
    UI->>Server: POST image file
    Server->>AI: Sends image for analysis (isCar, alt text)
    AI-->>Server: Returns JSON { isCar, alt }
    alt isCar == false
        Server-->>UI: Returns error (not a car)
    else isCar == true
        Server-->>UI: Returns alt text
        UI->>User: Displays alt text in editable field
    end
    User->>UI: Edits alt text (optional)
    UI->>Server: Saves product with alt text
Loading

Assessment against linked issues

Objective Addressed Explanation
Automatic generation of alt text for product image uploads (#11097)
Storing and displaying alt text in product model, DTO, and UI (#11097)
Localization for alt text label (#11097)

Poem

A rabbit hopped in code today,
Bringing alt text in a clever way.
With AI eyes, it sees the scene—
"Is this a car, or something green?"
Now products speak with words so bright,
Accessibility hopping into sight!
🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for AI-generated alt text in the Bit Boilerplate template by extending resources, DTOs, entities, migrations, server logic, and the client UI.

  • Added AltText resource entries and Farsi translation.
  • Introduced PrimaryImageAltText property in the product DTO and entity, with corresponding database migrations and seed updates.
  • Enhanced the attachment upload controller to call an AI service for image analysis and return alt text, and updated the product page to display and bind the alt text.

Reviewed Changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/.../AppStrings.resx Closed existing <data> tag and added AltText entry
src/.../AppStrings.fa.resx Added Farsi AltText translation
src/.../ProductDto.cs Added PrimaryImageAltText with a [Display] attribute
src/.../Product.cs Introduced PrimaryImageAltText on the product entity
src/.../AppDbContextModelSnapshot.cs Updated snapshot to include PrimaryImageAltText
src/.../20250711145344_Initial.cs Added new column and updated seed data with null alt-text values
src/.../AttachmentController.cs Integrated AI image review, logging, and return of alt text
src/.../AddOrEditProductPage.razor.cs Updated upload completion handler to set PrimaryImageAltText
src/.../AddOrEditProductPage.razor Rendered AltText input field and validation message
Files not reviewed (1)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Data/Migrations/20250711145344_Initial.Designer.cs: Language not supported
Comments suppressed due to low confidence (2)

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/AttachmentController.cs:154

  • The comment indicates this variable is for 'future use' but it's already used to store and return the AI-generated alt text. Update the comment to accurately reflect its current purpose.
        string? altText = null; // For future use, e.g., AI-generated alt text.

src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Resources/AppStrings.resx:977

  • [nitpick] The newly added </data> and <data name="AltText"> entries have inconsistent indentation compared to surrounding entries. Align their indentation for better readability.
  </data>

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (3)
src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Resources/AppStrings.fa.resx (1)

972-974: Add a translator comment for context.

The new key/value pair is correct, but consider adding a <comment> element to clarify that this label refers to the primary image’s alternative-text field. It helps translators keep future variants consistent.

     <data name="AltText" xml:space="preserve">
-    <value>متن جایگزین</value>
+    <value>متن جایگزین</value>
+    <comment>Label for the product primary image alternative-text field</comment>
   </data>
src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Resources/AppStrings.resx (1)

978-980: Mirror the translator comment in the neutral resource file.

For parity with the localized file (and future automated tooling), add the same explanatory comment here.

     <data name="AltText" xml:space="preserve">
-    <value>Alt text</value>
+    <value>Alt text</value>
+    <comment>Label for the product primary image alternative-text field</comment>
   </data>
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/AttachmentController.cs (1)

154-154: Consider initializing altText with a default value.

While the null initialization is technically correct, consider adding a comment or initializing with a more descriptive default to improve code clarity.

-        string? altText = null; // For future use, e.g., AI-generated alt text.
+        string? altText = null; // Will be populated with AI-generated alt text for product images
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 50d7e36 and 5b5798d.

📒 Files selected for processing (10)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Products/AddOrEditProductPage.razor (2 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Products/AddOrEditProductPage.razor.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/AttachmentController.cs (4 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Data/Migrations/20250711145344_Initial.Designer.cs (2 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Data/Migrations/20250711145344_Initial.cs (2 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Data/Migrations/AppDbContextModelSnapshot.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Models/Products/Product.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Dtos/Products/ProductDto.cs (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Resources/AppStrings.fa.resx (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Resources/AppStrings.resx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build and test
🔇 Additional comments (8)
src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Dtos/Products/ProductDto.cs (1)

43-44: LGTM! Property implementation follows DTO best practices.

The PrimaryImageAltText property is properly implemented with appropriate nullability and localization support through the Display attribute.

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Data/Migrations/AppDbContextModelSnapshot.cs (1)

578-579: EF Core model snapshot correctly reflects the new property.

The PrimaryImageAltText property is properly configured in the model snapshot with appropriate column type and nullability settings.

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Data/Migrations/20250711145344_Initial.Designer.cs (1)

581-582: LGTM: Database schema correctly updated for alt text storage.

The addition of the nullable PrimaryImageAltText string property with TEXT column type is appropriate for storing alternative text descriptions of product images.

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Products/AddOrEditProductPage.razor.cs (1)

90-90: Method signature change is safe

Verified with rg that each HandleOnUploadComplete is defined and used only within its own Razor component.

  • AddOrEditProductPage.razor.cs uses the new (BitFileInfo fileInfo) signature
  • ProfileSection.razor.cs retains its no-argument version in its own component

There are no cross-component calls to update.

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Data/Migrations/20250711145344_Initial.cs (2)

226-227: LGTM! Column definition is appropriate.

The PrimaryImageAltText column is correctly defined as a nullable TEXT field, which is suitable for storing optional alternative text descriptions for product images.


573-625: Seed data consistency verified: all entries include PrimaryImageAltText

Verified that every product seed in
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Data/Migrations/20250711145344_Initial.cs
includes the new PrimaryImageAltText column (all set to null).

src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Products/AddOrEditProductPage.razor (1)

74-77: Approve alt text field implementation

  • Verified the AltText localization key exists in
    src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Resources/AppStrings.resx.
  • The multiline BitTextField is correctly bound to product.PrimaryImageAltText with accompanying <ValidationMessage>.
  • Placement inside the conditional block ensures it’s only rendered when a primary image is present.
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/AttachmentController.cs (1)

262-262: LGTM! Return value properly includes AI-generated alt text.

The modified return statement correctly includes the AI-generated alt text, enabling the frontend to receive and display it.

@msynk msynk merged commit fa6a028 into bitfoundation:develop Jul 12, 2025
3 checks passed
@ysmoradi ysmoradi deleted the 11097 branch July 16, 2025 22:39
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.

bit Boilerplate file upload is not generating alt text for iamges

2 participants