[GH-ISSUE #4567] [Maintenance]: Consolidate avatar crop handling into a shared contract #2489

Closed
opened 2026-10-21 05:48:47 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Xelvanis on GitHub (Aug 4, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4567

Originally assigned to: @SpicyMarinara on GitHub.

What problem does this solve?

Avatar crop types, validation, JSON parsing, and normalization are spread across entity-specific modules and consumers. The same stored crop data is represented with Persona-specific names, explicit current/legacy unions, repeated parsing, and unsafe casts.

This makes a shared display concern harder to understand and maintain across Characters, Personas, and Noodle. Both the current source-rectangle format and the legacy zoom/offset format must remain readable.

Proposed solution

  • Move the crop shapes, schema, and normalization into neutral shared modules.
  • Use one AvatarCrop read contract covering current and legacy stored values.
  • Have editors and widgets emit the current source-rectangle shape.
  • Normalize once in shared display/parsing paths such as parseCharacterDisplayData().
  • Remove Persona-specific crop type names and repeated consumer-side JSON parsing/casts.
  • Reuse the neutral contract for Noodle while preserving its intentionally stricter request validation.
  • Return null for malformed stored crops so they remain recoverable.

Do not migrate persisted data. Legacy crops do not always have an exact source-rectangle equivalent, and imports or backups can reintroduce them. Normal editing will naturally replace legacy values with the current format.

Alternatives considered

  • Keeping compatibility aliases for the Persona-specific names: unnecessary because the shared package is private and no external imports were found.
  • Migrating all legacy values: rejected because conversion can be lossy and would not eliminate the need to support legacy imports.
  • Leaving parsing in each consumer: retains duplicated control flow and inconsistent type assertions.

Additional context

Draft implementation: #4566

This is a focused internal cleanup/consolidation, not a bug fix or persisted-data migration.

Template check

Template read and requested details provided.

Originally created by @Xelvanis on GitHub (Aug 4, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4567 Originally assigned to: @SpicyMarinara on GitHub. ## What problem does this solve? Avatar crop types, validation, JSON parsing, and normalization are spread across entity-specific modules and consumers. The same stored crop data is represented with Persona-specific names, explicit current/legacy unions, repeated parsing, and unsafe casts. This makes a shared display concern harder to understand and maintain across Characters, Personas, and Noodle. Both the current source-rectangle format and the legacy zoom/offset format must remain readable. ## Proposed solution - Move the crop shapes, schema, and normalization into neutral shared modules. - Use one `AvatarCrop` read contract covering current and legacy stored values. - Have editors and widgets emit the current source-rectangle shape. - Normalize once in shared display/parsing paths such as `parseCharacterDisplayData()`. - Remove Persona-specific crop type names and repeated consumer-side JSON parsing/casts. - Reuse the neutral contract for Noodle while preserving its intentionally stricter request validation. - Return `null` for malformed stored crops so they remain recoverable. Do not migrate persisted data. Legacy crops do not always have an exact source-rectangle equivalent, and imports or backups can reintroduce them. Normal editing will naturally replace legacy values with the current format. ## Alternatives considered - Keeping compatibility aliases for the Persona-specific names: unnecessary because the shared package is private and no external imports were found. - Migrating all legacy values: rejected because conversion can be lossy and would not eliminate the need to support legacy imports. - Leaving parsing in each consumer: retains duplicated control flow and inconsistent type assertions. ## Additional context Draft implementation: #4566 This is a focused internal cleanup/consolidation, not a bug fix or persisted-data migration. ## Template check Template read and requested details provided.
bsakaguchi 2026-10-21 05:48:47 +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#2489
No description provided.