[PR #671] [MERGED] feat(avatar-crop): re-apply PR #661 with chat-side propagation #4723

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

📋 Pull Request Information

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

Base: main ← Head: feat/avatar-crop-chat-propagation


📝 Commits (3)

  • 3d30f3e Revert "Merge pull request #666 from Romuromylus/revert/avatar-crop-full-image"
  • 15dac0a feat(avatar-crop): propagate new-format crop through chat surfaces
  • c612b04 Merge branch 'main' into feat/avatar-crop-chat-propagation

📊 Changes

41 files changed (+874 additions, -265 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/client/src/components/characters/CharacterEditor.tsx (+19 -141)
📝 packages/client/src/components/characters/CharacterLibraryView.tsx (+3 -3)
📝 packages/client/src/components/chat/ChatArea.tsx (+3 -1)
📝 packages/client/src/components/chat/ChatInput.tsx (+3 -3)
📝 packages/client/src/components/chat/ChatMessage.tsx (+8 -5)
📝 packages/client/src/components/chat/ChatNotificationBubbles.tsx (+2 -2)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+4 -4)
📝 packages/client/src/components/chat/ChatSetupWizard.tsx (+1 -1)
📝 packages/client/src/components/chat/ConversationInput.tsx (+3 -3)
📝 packages/client/src/components/chat/ConversationMessage.tsx (+7 -4)
📝 packages/client/src/components/chat/ConversationView.tsx (+4 -4)
📝 packages/client/src/components/chat/ExpressionPanel.tsx (+2 -2)
📝 packages/client/src/components/chat/QuickPersonaSwitcher.tsx (+21 -12)
📝 packages/client/src/components/chat/QuickSwitcherMobile.tsx (+19 -11)
📝 packages/client/src/components/chat/RecentChats.tsx (+4 -4)
📝 packages/client/src/components/chat/chat-area.types.ts (+3 -1)
📝 packages/client/src/components/game/GameCharacterSheet.tsx (+3 -3)
📝 packages/client/src/components/game/GameNarration.tsx (+4 -4)
📝 packages/client/src/components/game/GamePartyBar.tsx (+4 -4)

...and 21 more files

📄 Description

Linked issue

Closes #669

Why this change

PR #661 shipped the new full-image avatar cropper and persona crop UI but explicitly deferred chat-side propagation. With #661 live, four chat surfaces rendered broken avatars on any saved new-format crop (see #665), so PR #666 reverted it. This PR re-applies #661 and lands the deferred chat-side propagation so the cropper can ship.

Verified end-to-end on a fork deployment with the four #665 surfaces all rendering clean.

What changed

Two commits so the review can separate "re-apply" from "new work":

  1. Revert \"Merge pull request #666...\" — exact git revert -m 1 of the revert PR. Brings back PR #661 unchanged.
  2. feat(avatar-crop): propagate new-format crop through chat surfaces — the deferred scope:

Part A — data plumbing

  • Widen CharacterMap.avatarCrop to AvatarCrop | LegacyAvatarCrop | null and add PersonaInfo.avatarCrop in chat-area.types.ts.
  • Thread avatarCrop from the persona row through ChatArea.tsx's userPersonaInfo useMemo so all chat consumers receive it.
  • Snapshot avatarCrop on user messages (shared type + server/generate.routes.ts + client/use-generate.ts) so the rendered avatar matches the persona that was active when the message was sent, not the current one.
  • ChatMessage / ConversationMessage now resolve a persona crop style on user messages (msgPersona.avatarCrop → personaInfo.avatarCrop, parsed via parseAvatarCropJson) and pass it to getAvatarCropStyle.
  • QuickPersonaSwitcher and QuickSwitcherMobile apply the crop to both the picker rows and the active chip in the chat header.

Refactor

  • Move parsePersonaAvatarCrop from PersonasPanel into lib/utils.ts (renamed parseAvatarCropJson) since it's now used by both panel and chat.
  • Introduce AvatarCropValue = AvatarCrop | LegacyAvatarCrop in lib/utils.ts and replace inline narrow { zoom; offsetX; offsetY } types across 17 client files so character-side crop data can also flow in the new shape.

Part B — container clipping

The new-format crop renders the <img> with position: absolute, so each immediate parent needs position: relative (in addition to the existing overflow: hidden). Sweeps relative onto 22 parents covering:

  • Chat surfaces — ChatInput, ChatMessage (compact + RP single-avatar variants), ChatSettingsDrawer (4 sites), ChatSetupWizard, ConversationInput, ConversationMessage (chat bubble + segment-level bubble), ConversationView (2 sites), ExpressionPanel (2 sites), QuickPersonaSwitcher active chip, RecentChats.
  • Game-mode widgets — GameCharacterSheet, GamePartyBar, GamePartySidebar (3 sites), GameSetupWizard.
  • Layout — ChatSidebar.

Where the original parent had siblings needing to render outside the avatar bounds (e.g. active-indicator dots), the QuickPersonaSwitcher picker rows use the same inner-wrapper pattern PR #661 already applied to the persona panel.

No data migration; legacy crops keep rendering via the legacy CSS transform path.

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 a character with a new-format avatarCrop (e.g. a tall portrait re-cropped via the editor): RP scene top character avatar renders the chosen framing, no stripey artifacts at container edges (was #665 surface 1).
  • Manually verify a persona with a saved new-format crop, in a Conversation-mode chat: the persona avatar next to "You" message bubbles shows the full cropped face, not a vertical sliver (was #665 surface 2).
  • Manually verify a character with a saved new-format crop, in a Conversation-mode chat: the character avatar next to its message bubble shows the cropped circle, not a giant horizontal banner across the chat (was #665 surface 3).
  • Manually verify the QuickPersonaSwitcher chip in the chat header and its dropdown picker rows: active persona avatar renders centered, picker rows render correctly (was #665 surface 4).
  • Manually verify QuickSwitcherMobile (narrow viewport / mobile DPI) — same persona rows render correctly.
  • Manually verify pre-existing surfaces from PR #661 still work — Persona panel main rows + group member tiles, RP chat list sidebar, RP chat top header.
  • Manually verify legacy { zoom, offsetX, offsetY } crops still render unchanged (slider-era data on existing characters). Legacy CSS transform path is preserved.
  • Manually verify a character with no avatarCrop extension at all renders identically to before (uncropped object-cover).
  • Manually verify game-mode party widgets — GamePartyBar and GamePartySidebar member tiles, GameCharacterSheet portrait — render cropped avatars cleanly.

Docs and release impact

  • No docs changes needed (CHANGELOG entry from #661 is restored by the revert-of-revert commit)
  • 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)

Behavioral fix; the editor-side UX is unchanged from PR #661 (already screenshotted there). Chat-side surfaces now render cropped avatars cleanly instead of the four #665 failure modes.


🔄 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/671 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 5/11/2026 **Status:** ✅ Merged **Merged:** 5/11/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `main` ← **Head:** `feat/avatar-crop-chat-propagation` --- ### 📝 Commits (3) - [`3d30f3e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3d30f3e3df474ef6b47b97b205331a139dca20f7) Revert "Merge pull request #666 from Romuromylus/revert/avatar-crop-full-image" - [`15dac0a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/15dac0a06f5093e9cbd79b80ff3180e15e055fd7) feat(avatar-crop): propagate new-format crop through chat surfaces - [`c612b04`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c612b04c922d274991deed249a079cbdf7e4b960) Merge branch 'main' into feat/avatar-crop-chat-propagation ### 📊 Changes **41 files changed** (+874 additions, -265 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/client/src/components/characters/CharacterEditor.tsx` (+19 -141) 📝 `packages/client/src/components/characters/CharacterLibraryView.tsx` (+3 -3) 📝 `packages/client/src/components/chat/ChatArea.tsx` (+3 -1) 📝 `packages/client/src/components/chat/ChatInput.tsx` (+3 -3) 📝 `packages/client/src/components/chat/ChatMessage.tsx` (+8 -5) 📝 `packages/client/src/components/chat/ChatNotificationBubbles.tsx` (+2 -2) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+4 -4) 📝 `packages/client/src/components/chat/ChatSetupWizard.tsx` (+1 -1) 📝 `packages/client/src/components/chat/ConversationInput.tsx` (+3 -3) 📝 `packages/client/src/components/chat/ConversationMessage.tsx` (+7 -4) 📝 `packages/client/src/components/chat/ConversationView.tsx` (+4 -4) 📝 `packages/client/src/components/chat/ExpressionPanel.tsx` (+2 -2) 📝 `packages/client/src/components/chat/QuickPersonaSwitcher.tsx` (+21 -12) 📝 `packages/client/src/components/chat/QuickSwitcherMobile.tsx` (+19 -11) 📝 `packages/client/src/components/chat/RecentChats.tsx` (+4 -4) 📝 `packages/client/src/components/chat/chat-area.types.ts` (+3 -1) 📝 `packages/client/src/components/game/GameCharacterSheet.tsx` (+3 -3) 📝 `packages/client/src/components/game/GameNarration.tsx` (+4 -4) 📝 `packages/client/src/components/game/GamePartyBar.tsx` (+4 -4) _...and 21 more files_ </details> ### 📄 Description ## Linked issue Closes #669 ## Why this change PR #661 shipped the new full-image avatar cropper and persona crop UI but explicitly deferred chat-side propagation. With #661 live, four chat surfaces rendered broken avatars on any saved new-format crop (see #665), so PR #666 reverted it. This PR re-applies #661 and lands the deferred chat-side propagation so the cropper can ship. Verified end-to-end on a fork deployment with the four #665 surfaces all rendering clean. ## What changed Two commits so the review can separate "re-apply" from "new work": 1. **`Revert \"Merge pull request #666...\"`** — exact `git revert -m 1` of the revert PR. Brings back PR #661 unchanged. 2. **`feat(avatar-crop): propagate new-format crop through chat surfaces`** — the deferred scope: ### Part A — data plumbing - Widen `CharacterMap.avatarCrop` to `AvatarCrop | LegacyAvatarCrop | null` and add `PersonaInfo.avatarCrop` in `chat-area.types.ts`. - Thread `avatarCrop` from the persona row through `ChatArea.tsx`'s `userPersonaInfo` useMemo so all chat consumers receive it. - Snapshot `avatarCrop` on user messages (`shared` type + `server/generate.routes.ts` + `client/use-generate.ts`) so the rendered avatar matches the persona that was active when the message was sent, not the current one. - `ChatMessage` / `ConversationMessage` now resolve a persona crop style on user messages (`msgPersona.avatarCrop` → `personaInfo.avatarCrop`, parsed via `parseAvatarCropJson`) and pass it to `getAvatarCropStyle`. - `QuickPersonaSwitcher` and `QuickSwitcherMobile` apply the crop to both the picker rows and the active chip in the chat header. ### Refactor - Move `parsePersonaAvatarCrop` from `PersonasPanel` into `lib/utils.ts` (renamed `parseAvatarCropJson`) since it's now used by both panel and chat. - Introduce `AvatarCropValue = AvatarCrop | LegacyAvatarCrop` in `lib/utils.ts` and replace inline narrow `{ zoom; offsetX; offsetY }` types across 17 client files so character-side crop data can also flow in the new shape. ### Part B — container clipping The new-format crop renders the `<img>` with `position: absolute`, so each immediate parent needs `position: relative` (in addition to the existing `overflow: hidden`). Sweeps `relative` onto 22 parents covering: - Chat surfaces — `ChatInput`, `ChatMessage` (compact + RP single-avatar variants), `ChatSettingsDrawer` (4 sites), `ChatSetupWizard`, `ConversationInput`, `ConversationMessage` (chat bubble + segment-level bubble), `ConversationView` (2 sites), `ExpressionPanel` (2 sites), `QuickPersonaSwitcher` active chip, `RecentChats`. - Game-mode widgets — `GameCharacterSheet`, `GamePartyBar`, `GamePartySidebar` (3 sites), `GameSetupWizard`. - Layout — `ChatSidebar`. Where the original parent had siblings needing to render outside the avatar bounds (e.g. active-indicator dots), the `QuickPersonaSwitcher` picker rows use the same inner-wrapper pattern PR #661 already applied to the persona panel. No data migration; legacy crops keep rendering via the legacy CSS transform path. ## 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 a character with a new-format `avatarCrop` (e.g. a tall portrait re-cropped via the editor): RP scene top character avatar renders the chosen framing, no stripey artifacts at container edges (was #665 surface 1). - Manually verify a persona with a saved new-format crop, in a Conversation-mode chat: the persona avatar next to "You" message bubbles shows the full cropped face, not a vertical sliver (was #665 surface 2). - Manually verify a character with a saved new-format crop, in a Conversation-mode chat: the character avatar next to its message bubble shows the cropped circle, not a giant horizontal banner across the chat (was #665 surface 3). - Manually verify the `QuickPersonaSwitcher` chip in the chat header and its dropdown picker rows: active persona avatar renders centered, picker rows render correctly (was #665 surface 4). - Manually verify `QuickSwitcherMobile` (narrow viewport / mobile DPI) — same persona rows render correctly. - Manually verify pre-existing surfaces from PR #661 still work — Persona panel main rows + group member tiles, RP chat list sidebar, RP chat top header. - Manually verify legacy `{ zoom, offsetX, offsetY }` crops still render unchanged (slider-era data on existing characters). Legacy CSS transform path is preserved. - Manually verify a character with no `avatarCrop` extension at all renders identically to before (uncropped `object-cover`). - Manually verify game-mode party widgets — `GamePartyBar` and `GamePartySidebar` member tiles, `GameCharacterSheet` portrait — render cropped avatars cleanly. ## Docs and release impact - [x] No docs changes needed (CHANGELOG entry from #661 is restored by the revert-of-revert commit) - [ ] 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) Behavioral fix; the editor-side UX is unchanged from PR #661 (already screenshotted there). Chat-side surfaces now render cropped avatars cleanly instead of the four #665 failure modes. --- <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:07 +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#4723
No description provided.