mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #661] [MERGED] feat(avatar-crop): full-image mode + persona crop UI #4718
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#4718
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/661
Author: @Romuromylus
Created: 5/10/2026
Status: ✅ Merged
Merged: 5/11/2026
Merged by: @Romuromylus
Base:
main← Head:feat/avatar-crop-full-image📝 Commits (10+)
4c132f0feat(avatar-crop): support full-image mode (zoom < 1, pan-anywhere)7633c25feat(persona): add avatarCrop column end-to-end (schema, storage, routes, hooks, importer)ce78aacfeat(persona): surface avatar crop widget in PersonaEditor + PersonasPanelf36426bfeat(avatar-crop): replace zoom+pan widget with square-region crop selector93ff857fix(persona-panel): clip oversized cropped with inner overflow-hidden wrapper3485e6dfix(cropper): force remount on src change so cached images still init the overlay2c5ac21fix(cropper): defensively run handleImgLoad for cached imagesfb075fbdocs(changelog): note avatar crop tool rework under [Unreleased] Added1769e84fix(avatar-crop): address CodeRabbit review on PR #6618dc39bbMerge branch 'main' into feat/avatar-crop-full-image📊 Changes
15 files changed (+744 additions, -159 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/client/src/components/characters/CharacterEditor.tsx(+19 -129)📝
packages/client/src/components/game/GameNarration.tsx(+4 -4)📝
packages/client/src/components/game/GameSurface.tsx(+2 -2)📝
packages/client/src/components/panels/PersonasPanel.tsx(+79 -13)📝
packages/client/src/components/personas/PersonaEditor.tsx(+100 -5)➕
packages/client/src/components/ui/AvatarCropWidget.tsx(+424 -0)📝
packages/client/src/hooks/use-characters.ts(+2 -0)📝
packages/client/src/lib/utils.ts(+66 -6)📝
packages/server/src/db/migrate.ts(+6 -0)📝
packages/server/src/db/schema/characters.ts(+2 -0)📝
packages/server/src/routes/characters.routes.ts(+1 -0)📝
packages/server/src/services/import/marinara.importer.ts(+8 -0)📝
packages/server/src/services/storage/characters.storage.ts(+5 -0)📝
packages/shared/src/types/persona.ts(+25 -0)📄 Description
Linked issue
Closes #658
Why this change
The avatar crop tool was a slider + drag-to-pan over a circular preview — a soft visual nudge, not a real crop selector. Users with tall portraits couldn't reach face-centered crops without fighting the controls, and Personas had no crop UI at all. This PR replaces the inline widget with a proper square-region cropper, brings the same widget to Personas, and makes both crops non-destructive so the original avatar file (used by the Roleplay glued side panel) is never overwritten.
What changed
Cropper UX (the headline)
AvatarCropWidgetshows the source image at full size with a draggable square overlay: 4 corner handles + interior pan, dark mask outside the selection, live circle preview next to it.Data model
AvatarCropis now{ srcX, srcY, srcWidth, srcHeight }normalized to source image dimensions. The editor enforces a square crop in source pixels (srcWidth * sourceW === srcHeight * sourceH).LegacyAvatarCrop(the prior{ zoom, offsetX, offsetY, fullImage }shape) is preserved as a render-only path. Existing crops keep rendering unchanged via the historical CSS transform until the user re-edits them with the new cropper, at which point the widget writes the current shape. No automatic migration — backward compatible by construction.getAvatarCropStylediscriminates on shape: legacy crops keep returning the transform; current crops return absolute-position styles that map the crop rectangle onto the container's full area without distortion at any source aspect ratio.Server / persistence
personas.avatar_cropTEXT column added (CREATE TABLE + idempotent ADD COLUMN migration), wired throughcreatePersona/updatePersona/duplicatePersona. POST /personas accepts it; PATCH already forwards arbitrary fields. Marinara importer round-trips it (handles object or stringified shapes).PersonaAvatarCroptype lives inpackages/shared/src/types/persona.ts.extensions.avatarCropvia the existing storage path.UI integration
CharacterEditorMetadataTab andPersonaEditorDescription tab both host the newAvatarCropWidget.PersonasPanel(main row + group member list) renders the crop on persona avatar tiles via a smallparsePersonaAvatarCrophelper that defensively validates either shape.PersonasPanelmain row's avatar<button>got an innerrelative overflow-hidden rounded-xlwrapper for the<img>so an oversized cropped image is clipped to the rounded tile — needed because the button itself can't haveoverflow:hidden(would clip the active-indicator star and camera-hover overlay).PersonasPanelgroup-member tile gotrelative overflow-hiddenadded for the same reason.Cropper init for cached images
loadevent so quickly that React'sonLoadlistener can miss it for the new src. Two complementary defenses:key={src}on the<img>forces a remount when the source changes.useEffectchecksimg.completeafter every render and runshandleImgLoadifimgRectis still null. The null-guard makes it a no-op once initialized.Out of scope (deliberate deferral)
AvatarCropthroughChatArea.tsxinto chat-side render sites — chat bubbles,QuickPersonaSwitcher,QuickSwitcherMobile,ChatSetupWizard/GameSetupWizard, andChatSettingsDrawer's persona chooser. Those keep rendering personas the way they did before. The follow-up will adduserPersonaInfo.avatarCrop, sweepposition: relative+overflow-hiddenacross those parents (same pattern as the persona panel fix here), and verify in chat.relative overflow-hiddentreatment. None reported breaking yet but worth verifying during review.Docs
CHANGELOG.md— entry under[Unreleased] / Addedsummarizing the user-facing change.Validation
Manual verification notes
Docs and release impact
UI evidence (if applicable)
To be added — the editor flow: persona row → editor opens → cropper widget with image canvas + draggable square overlay + live preview circle → save → tile reflects the new crop in the persona panel.
Summary by CodeRabbit
Release Notes
New Features
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.