Skip to content

Conversation

@DankerMu
Copy link

Summary

Adds an image aspect ratio setting to the Settings UI and validates it server-side.

Changes

  • Settings UI: add image_aspect_ratio selector
  • Backend: validate/normalize aspect ratio (e.g. 1920:1080 → 16:9)
  • Tests: settings API coverage

Testing

  • npm run test:backend
  • npm run test:frontend

Closes #167

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @DankerMu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the application's settings by introducing a user-configurable image aspect ratio. This feature provides greater control over image generation, supported by robust backend logic for validation and normalization. The changes also include an update to the HTTP client used in integration tests, moving from requests to httpx for better performance and maintainability.

Highlights

  • Image Aspect Ratio Setting: Introduced a new setting for image aspect ratio in the frontend UI, allowing users to select from common aspect ratios for image generation.
  • Backend Validation and Normalization: Implemented server-side validation and normalization for the image aspect ratio setting. This includes reducing ratios to their simplest form (e.g., 1920:1080 to 16:9) and rejecting invalid or extreme values.
  • Updated Integration Tests: Refactored backend integration tests to use the httpx library instead of requests for making HTTP requests, improving modern async capabilities and error handling.
  • New Unit Tests for Settings API: Added dedicated unit tests for the settings API to cover the new image aspect ratio functionality, ensuring correct behavior for getting, updating, normalizing, and rejecting invalid aspect ratio inputs.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces an image aspect ratio setting, including UI integration, server-side validation, and normalization. The backend logic correctly handles various aspect ratio inputs, reducing them to their simplest form and validating against a predefined range and common ratios. Integration tests have been updated to use httpx instead of requests, and new unit tests cover the aspect ratio functionality. However, there's an unnecessary dependency on requests added to pyproject.toml and uv.lock, and an arbitrary length check for normalized aspect ratios that could lead to unexpected rejections.

)

normalized = f"{width}:{height}"
if len(normalized) > 10:
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The check len(normalized) > 10 seems arbitrary and could lead to valid, simplified aspect ratios being rejected. For example, a ratio like 10000:1 would simplify to 10000:1 (length 7) but 100000:1 would simplify to 100000:1 (length 8). If a user inputs 1000000000:1, it would simplify to 1000000000:1 (length 10), which is fine. However, if a ratio like 1234567890:1 is simplified to 1234567890:1 (length 11), it would be rejected. Given that custom ratios are allowed, this length check might be too restrictive and not directly related to the validity or extremity of the ratio itself. Consider removing this check or basing it on a more logical constraint if there's a specific reason for it.

"python-pptx>=1.0.0",
"python-dotenv>=1.0.1",
"reportlab>=4.1.0",
"requests>=2.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The integration tests (backend/tests/integration/test_api_full_flow.py) have been updated to use httpx instead of requests. If requests is no longer used anywhere else in the backend, it should be removed from the dependencies list to keep the project dependencies lean and avoid unnecessary packages.

{ name = "python-dotenv" },
{ name = "python-pptx" },
{ name = "reportlab" },
{ name = "requests" },
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the pyproject.toml comment, if requests is no longer a direct dependency after migrating to httpx in the integration tests, this entry should be removed from uv.lock to reflect the actual project dependencies.

{ name = "python-dotenv", specifier = ">=1.0.1" },
{ name = "python-pptx", specifier = ">=1.0.0" },
{ name = "reportlab", specifier = ">=4.1.0" },
{ name = "requests", specifier = ">=2.0.0" },
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This requires-dist entry for requests should also be removed if the library is no longer a dependency, aligning with the removal from pyproject.toml.

@DankerMu
Copy link
Author

Review summary (local)

  • Settings UI now exposes common aspect ratios and persists via Settings API.
  • Backend validates/normalizes ratios (e.g. 1920:1080 → 16:9) and guards extreme values.
  • Service-only integration tests are gated by SKIP_SERVICE_TESTS (CI can run them with SKIP_SERVICE_TESTS=false).

LGTM (waiting for CI).

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