mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #668] [MERGED] fix(avatar-crop): defensively skip non-legacy crops in editor and renderer #4720
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#4720
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/668
Author: @Romuromylus
Created: 5/11/2026
Status: ✅ Merged
Merged: 5/11/2026
Merged by: @Romuromylus
Base:
main← Head:fix/avatar-crop-post-revert-defensive📝 Commits (1)
bdb2b0cfix(avatar-crop): defensively skip non-legacy crops after revert📊 Changes
2 files changed (+22 additions, -7 deletions)
View changed files
📝
packages/client/src/components/characters/CharacterEditor.tsx(+17 -5)📝
packages/client/src/lib/utils.ts(+5 -2)📄 Description
Linked issue
Closes #667
Why this change
After PR #666 reverted PR #661, any character whose
extensions.avatarCropwas saved with the new `{srcX, srcY, srcWidth, srcHeight}` cropper (during the brief PR #661 window) now crashes the CharacterEditor on open:The reverted editor and renderer both assume the legacy zoom/offset shape and read
.zoomdirectly. With foreign data present, the editor renders a blank screen and the avatar transform produces invalid CSS.The repro is narrow (only users who beta-tested PR #661 and pulled the revert), but it's a hard crash that locks them out of the editor entirely.
What changed
packages/client/src/components/characters/CharacterEditor.tsx— replaces the unchecked cast onformData.extensions.avatarCropwith a runtime shape check. Only treats the saved value as a legacy crop when all three ofzoom,offsetX,offsetYare numbers; anything else falls back to{ zoom: 1, offsetX: 0, offsetY: 0 }so the slider starts fresh and the editor opens.packages/client/src/lib/utils.ts—getAvatarCropStylenow guards ontypeof crop.zoom === \"number\"before returning a transform. Foreign shapes render uncropped instead of producingscale(undefined) translate(undefined%, undefined%).No data is rewritten. The user can re-edit the crop (which saves in the legacy shape, overwriting the foreign value) or just leave it — both editor and renderer are now tolerant.
Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Docs and release impact
UI evidence (if applicable)
Defensive change; behavior matches the pre-#661 baseline except that foreign-shape data is now tolerated instead of crashing. No new screenshots vs the legacy editor flow.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.