fix(image): preserve resolution when changing aspect ratio#13324
Conversation
|
@BillionClaw is attempting to deploy a commit to the LobeHub OSS Team on Vercel. A member of the Team first needs to authorize it. |
|
@tjx666 - This is an image generation fix (preserve resolution when changing aspect ratio). Please take a look. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6ea05a4c0f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // Preserve resolution if it exists in current parameters (models like nanoBanana2 use resolution enum) | ||
| // This ensures 4K/2K resolution is maintained when changing aspect ratios | ||
| if ('resolution' in parameters && parameters.resolution !== undefined) { | ||
| newParams.resolution = parameters.resolution; | ||
| } |
There was a problem hiding this comment.
Add regression coverage for resolution preservation
This change updates setAspectRatio to keep parameters.resolution, but the commit does not add a matching test case in src/store/image/slices/generationConfig/action.test.ts; .agents/skills/code-review/SKILL.md explicitly requires bug fixes to include tests for the fixed scenario. Without a regression test for models that expose both aspectRatio and resolution (for example Nano Banana / Grok image models), this behavior can regress again without any CI failure.
Useful? React with 👍 / 👎.
|
@BillionClaw plz check codex review |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## canary #13324 +/- ##
========================================
Coverage 66.76% 66.76%
========================================
Files 1889 1888 -1
Lines 151446 151439 -7
Branches 14506 15220 +714
========================================
+ Hits 101112 101115 +3
+ Misses 50222 50212 -10
Partials 112 112
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
When using models like nanoBanana2 that support resolution (1K/2K/4K), selecting a different aspect ratio would cause the resolution to be lost. This ensures the resolution parameter is preserved when calling setAspectRatio, fixing the issue where 4K resolution would be reset to 1K when changing aspect ratios.
6ea05a4 to
554d3f1
Compare
|
When can it be processed? Version 2.1.48 is still not functioning properly. @tjx666 @BillionClaw |
|
Hi @BillionClaw, two things to address before merge:
|
Addressed Review FeedbackThanks for the review @tjx666. I've addressed both comments: 1. Added Regression Test ✅Added 3 new test cases in
2. Added Enum Validation ✅Updated // Preserve resolution if it exists in current parameters (models like nanoBanana2 use resolution enum)
// Only preserve if the new schema's resolution enum contains the current value
if (
'resolution' in parameters &&
parameters.resolution !== undefined &&
parametersSchema?.resolution?.enum &&
parametersSchema.resolution.enum.includes(parameters.resolution)
) {
newParams.resolution = parameters.resolution;
} else if (
'resolution' in parameters &&
parameters.resolution !== undefined &&
( !parametersSchema?.resolution?.enum ||
!parametersSchema.resolution.enum.includes(parameters.resolution))
) {
// Resolution value is not valid for new schema - strip it
delete newParams.resolution;
}The implementation now:
I've pushed the changes to my fork at Mati0kez/lobehub:canary and created a new PR to supersede this one since I don't have write access to the original branch. |
|
Test comment from API |
|
The fix has been implemented with regression tests. It's currently waiting for Vercel deployment authorization from a LobeHub OSS Team member. |
|
I'll get the CLA signed — will follow up once it's done. |
|
❤️ Great PR @BillionClaw ❤️ The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world. |
…3324) Co-authored-by: BillionClaw <267901332+BillionClaw@users.noreply.github.com> Co-authored-by: YuTengjing <ytj2713151713@gmail.com>
…3324) Co-authored-by: BillionClaw <267901332+BillionClaw@users.noreply.github.com> Co-authored-by: YuTengjing <ytj2713151713@gmail.com>
When using models that support resolution enum (1K/2K/4K), selecting a different aspect ratio would cause the resolution to be lost. The setAspectRatio action now preserves the resolution parameter if it exists in the current parameters. Fixes #13283