[PR #4566] [MERGED] Refactor avatar crop contract #6428

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4566
Author: @Xelvanis
Created: 8/4/2026
Status: ✅ Merged
Merged: 8/4/2026
Merged by: @SpicyMarinara

Base: staging ← Head: avatar-crop-contract


📝 Commits (3)

  • 6f9c6ca refactor avatar crop contract
  • 3eb7a87 address avatar crop review findings
  • 991d882 normalize game persona crops at adapter

📊 Changes

47 files changed (+752 additions, -495 deletions)

View changed files

📝 package.json (+1 -0)
📝 packages/client/src/components/characters/CharacterEditor.tsx (+5 -11)
📝 packages/client/src/components/characters/CharacterLibraryView.tsx (+6 -11)
📝 packages/client/src/components/chat/CharacterScheduleEditorModal.tsx (+3 -2)
📝 packages/client/src/components/chat/ChatArea.tsx (+7 -7)
📝 packages/client/src/components/chat/ChatInput.tsx (+3 -2)
📝 packages/client/src/components/chat/ChatMessage.tsx (+9 -15)
📝 packages/client/src/components/chat/ChatNotificationBubbles.tsx (+3 -2)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+41 -67)
📝 packages/client/src/components/chat/ChatSetupWizard.tsx (+24 -29)
📝 packages/client/src/components/chat/ConversationInput.tsx (+3 -2)
📝 packages/client/src/components/chat/ConversationMessage.tsx (+3 -2)
📝 packages/client/src/components/chat/ExpressionSpriteSettings.tsx (+2 -1)
📝 packages/client/src/components/chat/QuickPersonaSwitcher.tsx (+5 -4)
📝 packages/client/src/components/chat/QuickSwitcherMobile.tsx (+4 -3)
📝 packages/client/src/components/chat/RecentChats.tsx (+5 -5)
📝 packages/client/src/components/chat/chat-area.types.ts (+3 -4)
📝 packages/client/src/components/game/GameCharacterSheet.tsx (+3 -2)
📝 packages/client/src/components/game/GameNarration.tsx (+4 -3)
📝 packages/client/src/components/game/GamePartyBar.tsx (+5 -4)

...and 27 more files

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #4567

Why this change

Avatar crops are shared by Characters, Personas, and Noodle, but their contract and parsing were split across entity-specific names and consumers. Centralizing the read contract keeps legacy stored data and imported backups supported without a persisted-data migration; normal editing naturally writes the current source-rectangle format.

What changed

  • Move avatar crop types, schema, and normalization into neutral shared modules.
  • Accept current source-rectangle and legacy zoom/offset crops on reads while editors emit source rectangles.
  • Normalize character display data once and remove repeated crop JSON parsing and unsafe consumer casts.
  • Reuse the neutral crop contract for Noodle while preserving its stricter request validation and recoverable stored-data reads.
  • Route Persona crop rendering in the New Chat wizard and Chat Settings through the shared normalized crop path.
  • Add a focused TypeScript regression for current, legacy, malformed, character-display, and Noodle crop behavior.

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

Additional automated validation:

  • pnpm regression:avatar-crop-contract passed locally.
  • A one-off desktop Chromium check covered Persona crop rendering in the New Chat wizard and Chat Settings.

Manual verification notes

User verified Persona and Character avatar crops displayed properly in their respective editors and sidebar locations, New Chat wizard setup, Chat Settings, and Noodle.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

No permanent Playwright test or screenshot artifact was added. The focused browser verification was run as a one-off check.

Summary by CodeRabbit

  • Bug Fixes

    • Improved avatar cropping consistency across character, persona, chat, game, and profile views.
    • Added safer handling for malformed or legacy crop data to prevent display issues.
    • Preserved compatibility with existing crop formats while standardizing newly saved crops.
    • Editors now produce consistent crop data for more reliable avatar positioning.
    • Added stricter validation to prevent invalid crop settings from being saved.
  • Tests

    • Added regression coverage for crop validation, normalization, rendering, and editor behavior.

🔄 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/4566 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 8/4/2026 **Status:** ✅ Merged **Merged:** 8/4/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `avatar-crop-contract` --- ### 📝 Commits (3) - [`6f9c6ca`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6f9c6ca5e9a869e72f6b86df2d111d0dcba85944) refactor avatar crop contract - [`3eb7a87`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3eb7a8732c0dba29c48de1fec63d1de098bb2019) address avatar crop review findings - [`991d882`](https://github.com/Pasta-Devs/Marinara-Engine/commit/991d88232195aad4280cacd5ec52e88f0e366411) normalize game persona crops at adapter ### 📊 Changes **47 files changed** (+752 additions, -495 deletions) <details> <summary>View changed files</summary> 📝 `package.json` (+1 -0) 📝 `packages/client/src/components/characters/CharacterEditor.tsx` (+5 -11) 📝 `packages/client/src/components/characters/CharacterLibraryView.tsx` (+6 -11) 📝 `packages/client/src/components/chat/CharacterScheduleEditorModal.tsx` (+3 -2) 📝 `packages/client/src/components/chat/ChatArea.tsx` (+7 -7) 📝 `packages/client/src/components/chat/ChatInput.tsx` (+3 -2) 📝 `packages/client/src/components/chat/ChatMessage.tsx` (+9 -15) 📝 `packages/client/src/components/chat/ChatNotificationBubbles.tsx` (+3 -2) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+41 -67) 📝 `packages/client/src/components/chat/ChatSetupWizard.tsx` (+24 -29) 📝 `packages/client/src/components/chat/ConversationInput.tsx` (+3 -2) 📝 `packages/client/src/components/chat/ConversationMessage.tsx` (+3 -2) 📝 `packages/client/src/components/chat/ExpressionSpriteSettings.tsx` (+2 -1) 📝 `packages/client/src/components/chat/QuickPersonaSwitcher.tsx` (+5 -4) 📝 `packages/client/src/components/chat/QuickSwitcherMobile.tsx` (+4 -3) 📝 `packages/client/src/components/chat/RecentChats.tsx` (+5 -5) 📝 `packages/client/src/components/chat/chat-area.types.ts` (+3 -4) 📝 `packages/client/src/components/game/GameCharacterSheet.tsx` (+3 -2) 📝 `packages/client/src/components/game/GameNarration.tsx` (+4 -3) 📝 `packages/client/src/components/game/GamePartyBar.tsx` (+5 -4) _...and 27 more files_ </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #4567 ## Why this change Avatar crops are shared by Characters, Personas, and Noodle, but their contract and parsing were split across entity-specific names and consumers. Centralizing the read contract keeps legacy stored data and imported backups supported without a persisted-data migration; normal editing naturally writes the current source-rectangle format. ## What changed - Move avatar crop types, schema, and normalization into neutral shared modules. - Accept current source-rectangle and legacy zoom/offset crops on reads while editors emit source rectangles. - Normalize character display data once and remove repeated crop JSON parsing and unsafe consumer casts. - Reuse the neutral crop contract for Noodle while preserving its stricter request validation and recoverable stored-data reads. - Route Persona crop rendering in the New Chat wizard and Chat Settings through the shared normalized crop path. - Add a focused TypeScript regression for current, legacy, malformed, character-display, and Noodle crop behavior. ## Validation - [x] `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) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` Additional automated validation: - `pnpm regression:avatar-crop-contract` passed locally. - A one-off desktop Chromium check covered Persona crop rendering in the New Chat wizard and Chat Settings. ### Manual verification notes User verified Persona and Character avatar crops displayed properly in their respective editors and sidebar locations, New Chat wizard setup, Chat Settings, and Noodle. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) No permanent Playwright test or screenshot artifact was added. The focused browser verification was run as a one-off check. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved avatar cropping consistency across character, persona, chat, game, and profile views. * Added safer handling for malformed or legacy crop data to prevent display issues. * Preserved compatibility with existing crop formats while standardizing newly saved crops. * Editors now produce consistent crop data for more reliable avatar positioning. * Added stricter validation to prevent invalid crop settings from being saved. * **Tests** * Added regression coverage for crop validation, normalization, rendering, and editor behavior. <!-- 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-23 04:10:19 +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#6428
No description provided.