[PR #770] [MERGED] fix(library): use square aspect for character card image to undistort saved crops #4767

Closed
opened 2026-10-22 04:10:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/770
Author: @Romuromylus
Created: 5/12/2026
Status: ✅ Merged
Merged: 5/12/2026
Merged by: @Romuromylus

Base: main ← Head: fix/character-library-aspect


📝 Commits (2)

  • 4f5f6ea fix(library): use square aspect for character card image to undistort saved crops
  • 633656e fix(library): match shimmer placeholder to new square card image

📊 Changes

1 file changed (+3 additions, -3 deletions)

View changed files

📝 packages/client/src/components/characters/CharacterLibraryView.tsx (+3 -3)

📄 Description

Linked issue

Closes #769

Why this change

  • Saved avatar crops in the current source-rectangle format are stored as a square in source pixels (see AvatarCropWidget). The Character Library card thumbnail and the detail-panel hero rendered them in an aspect-[4/3] container, and getAvatarCropStyle produces an <img> sized to (cw/srcWidth × ch/srcHeight) with object-fit: fill — so the square crop was stretched horizontally by exactly the container's aspect ratio (4/3). Faces looked compressed vertically / wide. A Discord user reported the bug and verified that overriding the container aspect to 1/1 via custom-theme CSS fixed the visual.

What changed

  • packages/client/src/components/characters/CharacterLibraryView.tsx: switched the detail-panel hero image container and the grid card image container from aspect-[4/3] / sm:aspect-[4/3] to aspect-square / sm:aspect-square so the saved square crop renders undistorted. Cards become slightly taller; uncropped portrait avatars now show more of the source than before, less cropped top/bottom.
  • A related bypass (rectangleSafeCropStyle in ChatMessage.tsx) is left untouched — fixing the root math in getAvatarCropStyle would touch ~30 consumers and is out of scope for this report.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Manually verify the Character Library grid: each card's image area is now a square; previously-cropped characters render with correct face proportions, not horizontally stretched.
  • Manually verify the Character Library detail panel: clicking a card opens a detail view whose hero image is also square and shows the saved crop undistorted.
  • Manually verify the mobile / narrow viewport: the small h-24 w-24 thumbnail variant (below the sm: breakpoint) is unchanged — only the sm:-and-up rendering switches to sm:aspect-square.
  • Manually verify a character with no saved crop still renders sanely (image fills the square via existing object-cover on the <img>).

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Reproduced and verified on a live deploy of this branch. JS inspection confirms every Character Library image container computes at exactly 1:1 (282×282 in the grid) and aspect-[4/3] is absent from the rendered tree. No console errors introduced.

Summary by CodeRabbit

  • Style
    • Updated character avatar and thumbnail display aspect ratios to square format throughout the character library interface. Visual styling adjustments have been applied to the character detail card image containers, character loading state placeholder backgrounds, and character grid card avatars, ensuring a more uniform and consistent visual presentation across all sections.

Review Change Stack


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/770 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 5/12/2026 **Status:** ✅ Merged **Merged:** 5/12/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `main` ← **Head:** `fix/character-library-aspect` --- ### 📝 Commits (2) - [`4f5f6ea`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4f5f6ea2e69c846809ea7ed2c2c74d1a735a8f5c) fix(library): use square aspect for character card image to undistort saved crops - [`633656e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/633656e3a46a90b6425a3869d58de8976330bd14) fix(library): match shimmer placeholder to new square card image ### 📊 Changes **1 file changed** (+3 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/characters/CharacterLibraryView.tsx` (+3 -3) </details> ### 📄 Description ## Linked issue Closes #769 ## Why this change - Saved avatar crops in the current source-rectangle format are stored as a square in source pixels (see `AvatarCropWidget`). The Character Library card thumbnail and the detail-panel hero rendered them in an `aspect-[4/3]` container, and `getAvatarCropStyle` produces an `<img>` sized to `(cw/srcWidth × ch/srcHeight)` with `object-fit: fill` — so the square crop was stretched horizontally by exactly the container's aspect ratio (4/3). Faces looked compressed vertically / wide. A Discord user reported the bug and verified that overriding the container aspect to `1/1` via custom-theme CSS fixed the visual. ## What changed - `packages/client/src/components/characters/CharacterLibraryView.tsx`: switched the detail-panel hero image container and the grid card image container from `aspect-[4/3]` / `sm:aspect-[4/3]` to `aspect-square` / `sm:aspect-square` so the saved square crop renders undistorted. Cards become slightly taller; uncropped portrait avatars now show more of the source than before, less cropped top/bottom. - A related bypass (`rectangleSafeCropStyle` in `ChatMessage.tsx`) is left untouched — fixing the root math in `getAvatarCropStyle` would touch ~30 consumers and is out of scope for this report. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Manually verify the Character Library grid: each card's image area is now a square; previously-cropped characters render with correct face proportions, not horizontally stretched. - Manually verify the Character Library detail panel: clicking a card opens a detail view whose hero image is also square and shows the saved crop undistorted. - Manually verify the mobile / narrow viewport: the small `h-24 w-24` thumbnail variant (below the `sm:` breakpoint) is unchanged — only the `sm:`-and-up rendering switches to `sm:aspect-square`. - Manually verify a character with **no** saved crop still renders sanely (image fills the square via existing `object-cover` on the `<img>`). ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) Reproduced and verified on a live deploy of this branch. JS inspection confirms every Character Library image container computes at exactly 1:1 (282×282 in the grid) and `aspect-[4/3]` is absent from the rendered tree. No console errors introduced. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Style** * Updated character avatar and thumbnail display aspect ratios to square format throughout the character library interface. Visual styling adjustments have been applied to the character detail card image containers, character loading state placeholder backgrounds, and character grid card avatars, ensuring a more uniform and consistent visual presentation across all sections. [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/770) <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:10:29 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4767
No description provided.