[PR #7852] [MERGED] fix(avatars): arrange, resize and frame avatars from the Chat Settings Agents drawer #7967

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7852
Author: @SpicyMarinara
Created: 10/19/2026
Status: ✅ Merged
Merged: 10/19/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/avatars-drawer-arrange


📝 Commits (1)

  • 9cbb662 fix(avatars): arrange, resize and frame avatars from the Chat Settings Agents drawer

📊 Changes

19 files changed (+964 additions, -436 deletions)

View changed files

📝 docs/agents/avatars.md (+6 -2)
📝 e2e/avatar-placement.e2e.ts (+311 -157)
📝 e2e/avatar-setup.e2e.ts (+4 -1)
➕ packages/client/src/components/chat/AvatarLayoutSettings.tsx (+122 -0)
📝 packages/client/src/components/chat/ChatArea.tsx (+126 -4)
📝 packages/client/src/components/chat/ChatCommonOverlays.tsx (+4 -0)
📝 packages/client/src/components/chat/ChatRoleplaySurface.tsx (+7 -10)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+42 -0)
📝 packages/client/src/components/chat/local-sprite-visual-settings.ts (+17 -0)
📝 packages/client/src/components/chat/use-sprite-placement-drag.ts (+1 -2)
📝 packages/client/src/components/game/GameSurface.tsx (+8 -83)
📝 packages/client/src/features/avatars/contract.ts (+7 -0)
📝 packages/client/src/features/avatars/renderers/vrm/vrm-motion.ts (+31 -14)
📝 packages/client/src/features/avatars/renderers/vrm/vrm-renderer.ts (+27 -4)
📝 packages/client/src/features/avatars/stage/AvatarStage.tsx (+73 -119)
📝 packages/client/src/features/avatars/stage/avatar-stage-logic.ts (+18 -0)
📝 packages/client/src/localization/locales/en.json (+8 -3)
📝 scripts/regressions/avatar-placement.regression.ts (+90 -37)
📝 scripts/regressions/avatar-vrm.regression.ts (+62 -0)

📄 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

No issue: this is a maintainer request (@SpicyMarinara, 2026-10-19) following #7843 and #7850. A tracking issue should be opened if one is wanted.

Why this change

  • The "Arrange avatars" button that #7843/#7850 put on the Roleplay, Visual Novel and Game chats (with an on-stage Done button and size sliders) was a static control in the middle of the chat, and it did not really work for 3D avatars. Mari decided avatars should be arranged the way sprites are: from a drawer in Chat Settings → Agents, like the Expression Engine's.
  • 3D avatars could only be shown as a head-and-shoulders bust. People who want to see their whole avatar had no way to do that, so each 3D avatar now gets a Framing choice: Portrait, Half body or Full body.

What changed

  • No avatar controls on the chat. The stage's Arrange/Done button, its size sliders and the per-avatar Done (check) button are gone. While Arrange is off, avatars ignore clicks, so the chat gets them.
  • New Avatars drawer in Chat Settings → Agents (Roleplay, Visual Novel and Game), shown when the 2D or 3D Avatars agent is on in the chat. It reuses the Expression Engine drawer's parts: the Arrange/Done and Reset buttons, an Avatar picker listing each character or persona whose avatar shows in the chat, the size slider (same 5–200% range and steps), and help text. It also has a link in the Agents menu chips.
    • Arrange turns dragging on and off. While it is on, 2D and 3D avatars can be dragged with a mouse or a finger and moved with the arrow keys (Shift moves further), as in #7850. Clicks over a Game avatar do not move the story on.
    • Reset clears the avatars' saved positions only. Sprites keep theirs.
    • Framing (3D only, hidden for 2D): Portrait is today's framing and the default. Half body shows down to the hips. Full body fits the whole model, from the measured top of its hair or hat (no longer capped) to its measured soles, with a little floor below. frameCamera takes the framing as a mode and still changes smoothly as the box resizes. The avatar box keeps its size; a taller framing shows more of the model in it.
  • 3D canvas stays sharp. The VRM renderer redraws at once when its size or framing changes, as the 2D renderers already do, so a resized canvas never shows a stretched picture until the next frame.
  • One owner for the layout. Game kept its own copy of the per-chat layout cache, so it could not hear the drawer. ChatArea now owns it for every mode. Saves happen at the time of the edit, never inside a React state updater. Queued edits each build on the one before, and an edit from a chat that has since closed is dropped. Framing is saved per owner in the same device-local per-chat layout as size and position (avatarFramings). Nothing in packages/shared changed.
  • Removed copy that is no longer used: avatars.stage.arrange, avatars.stage.done, avatars.stage.finishPlacing. Added avatars.layout.* (title, description, framing labels, help, empty state). Existing text is reused for Arrange, Done, Reset, Avatar and the size label.
  • docs/agents/avatars.md: the Arrange section now describes the drawer and the framing choice, in plain words.

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

Agent-run checks (for the reviewer to confirm, not proof):

  • pnpm check: exit 0 (one existing lint warning in HomeProfessorMariChat.tsx, not touched here).
  • node ./scripts/run-regressions.mjs --filter avatar: the avatar regressions passed (avatar-2d-importers timed out once under parallel load, then passed on its own). avatar-placement.regression.ts now drives ChatArea's shared callbacks and keeps every assertion it had for Game's: batched moves and sizes survive, saves happen outside updaters, stale chats can't save, a new chat reads its own cache, and a full cache keeps edits visible. It adds framing and Reset. avatar-vrm.regression.ts adds the framing math: Portrait is unchanged, Half body reaches the hips, Full body keeps a tall hat and the soles in view, no jumps on resize. It also checks the immediate redraw.
  • Playwright on desktop-chromium and mobile-chromium: e2e/avatar-placement.e2e.ts (rewritten to use the drawer, per the maintainer decision), e2e/avatar-setup.e2e.ts and e2e/avatar-2d.e2e.ts: 42 passed. The placement spec now checks, in Roleplay and Game, that the stage has no Arrange, Done or size controls. It checks that the drawer's Arrange makes a 2D and a 3D avatar draggable by mouse or touch and by the arrow keys, and that the slider resizes both and the 3D canvas keeps its full pixel ratio. It checks that Full body puts the VRM fixture's head and feet inside the canvas, and that Done gives clicks back to the chat. After a reload, positions, sizes and framing are restored. The old check of the removed on-stage slider's styling is gone with the slider. avatar-setup.e2e.ts now scopes its Expression Engine Arrange click to that card, because the Avatars card has its own Arrange.
  • The real 16.5 MB VRoid Studio model (Maukie, VRM 1.0) was tested on a local instance with a temporary data folder, in Roleplay, Visual Novel and Game, desktop and phone. The stage had no Arrange button. Portrait, Half body and Full body each framed as intended, and Full body showed the hair and shoes inside the box. The size slider resized the canvas with matching pixels. Drag worked with Arrange on, and the layout came back after a reload with Arrange off. Headless Chromium's software GL could not draw this model, so this check used Chromium with Metal.

Manual verification notes

Please check these by hand. None have been done by a person yet:

  • Manually verify in a Roleplay chat with 3D Avatars on: there is no Arrange button on the chat; Chat Settings → Agents → Avatars shows your avatar; Full body shows the whole model from hair to shoes; Half body stops around the hips/thighs; Portrait looks as before.
  • Manually verify that Arrange in that drawer lets you drag the avatar anywhere in the chat with a mouse, and with a finger on a phone. Check that the arrow keys move a focused avatar, and that after Done clicks on the chat reach the messages again.
  • Manually verify the size slider in the drawer resizes 2D and 3D avatars, and the 3D one stays sharp, not blurry.
  • Manually verify Visual Novel and Game chats the same way, including that clicking a Game avatar while arranging does not advance the story.
  • Manually verify that reloading keeps each avatar's position, size and framing, and that Reset puts avatars back without moving sprites.
  • Manually verify light and dark themes in the drawer.

Docs and release impact

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

docs/agents/avatars.md changed (the Arrange paragraph, the new Framing paragraph, and one sentence in the 3D section). The translation follow-up for this file is already open as #7831; a note about this change was added there.

UI evidence (if applicable)

Before (staging, #7843/#7850): an "Arrange avatars" button sits on the chat, at the top left in Roleplay and the top right in Game. Pressing it puts a Done button and one size slider per avatar over the chat, plus a check button above each avatar.

After, from the e2e run (test-results/avatar-placement.e2e.ts-…/):

  • roleplay-before.png / game-before.png: a 3D (VRM fixture) and a 2D avatar on the chat with no controls on the stage.
  • roleplay-desktop-drawer.png, roleplay-phone-drawer.png, game-desktop-drawer.png, game-phone-drawer.png: the Avatars drawer in Chat Settings → Agents, with Arrange/Reset, the Avatar picker, the size slider and Framing; the VRM is in Full body framing.
  • *-arranging.png: both avatars marked "Drag to move" after being dragged with Arrange on.
  • *-restored.png: after a reload, the same positions, sizes and framing.

From the local check with the real Maukie model (maukie-shots/<layout>-<desktop|phone>/ in the session scratchpad): 1-portrait.png, 3-half-body.png and 3-full-body.png compare the three framings in the same box. 4-arranged.png shows the drag with Arrange on, and 5-reloaded.png shows the layout after a reload. These cover Roleplay, Visual Novel and Game, on desktop and phone.

Summary by CodeRabbit

  • New Features

    • Added avatar layout controls in chat settings to select visible avatars, resize them, arrange or reset their positions, and adjust framing for 3D avatars.
    • Added Portrait, Half body, and Full body framing options for 3D avatars.
    • Avatar layout choices are saved per chat on the device.
  • Documentation

    • Updated avatar setup and layout guidance, including how framing options affect the visible model.

🔄 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/7852 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/19/2026 **Status:** ✅ Merged **Merged:** 10/19/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/avatars-drawer-arrange` --- ### 📝 Commits (1) - [`9cbb662`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9cbb662b81dae7642f91cbdada7cc1a2600908ef) fix(avatars): arrange, resize and frame avatars from the Chat Settings Agents drawer ### 📊 Changes **19 files changed** (+964 additions, -436 deletions) <details> <summary>View changed files</summary> 📝 `docs/agents/avatars.md` (+6 -2) 📝 `e2e/avatar-placement.e2e.ts` (+311 -157) 📝 `e2e/avatar-setup.e2e.ts` (+4 -1) ➕ `packages/client/src/components/chat/AvatarLayoutSettings.tsx` (+122 -0) 📝 `packages/client/src/components/chat/ChatArea.tsx` (+126 -4) 📝 `packages/client/src/components/chat/ChatCommonOverlays.tsx` (+4 -0) 📝 `packages/client/src/components/chat/ChatRoleplaySurface.tsx` (+7 -10) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+42 -0) 📝 `packages/client/src/components/chat/local-sprite-visual-settings.ts` (+17 -0) 📝 `packages/client/src/components/chat/use-sprite-placement-drag.ts` (+1 -2) 📝 `packages/client/src/components/game/GameSurface.tsx` (+8 -83) 📝 `packages/client/src/features/avatars/contract.ts` (+7 -0) 📝 `packages/client/src/features/avatars/renderers/vrm/vrm-motion.ts` (+31 -14) 📝 `packages/client/src/features/avatars/renderers/vrm/vrm-renderer.ts` (+27 -4) 📝 `packages/client/src/features/avatars/stage/AvatarStage.tsx` (+73 -119) 📝 `packages/client/src/features/avatars/stage/avatar-stage-logic.ts` (+18 -0) 📝 `packages/client/src/localization/locales/en.json` (+8 -3) 📝 `scripts/regressions/avatar-placement.regression.ts` (+90 -37) 📝 `scripts/regressions/avatar-vrm.regression.ts` (+62 -0) </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`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue No issue: this is a maintainer request (@SpicyMarinara, 2026-10-19) following #7843 and #7850. A tracking issue should be opened if one is wanted. ## Why this change - The "Arrange avatars" button that #7843/#7850 put on the Roleplay, Visual Novel and Game chats (with an on-stage Done button and size sliders) was a static control in the middle of the chat, and it did not really work for 3D avatars. Mari decided avatars should be arranged the way sprites are: from a drawer in **Chat Settings → Agents**, like the Expression Engine's. - 3D avatars could only be shown as a head-and-shoulders bust. People who want to see their whole avatar had no way to do that, so each 3D avatar now gets a **Framing** choice: Portrait, Half body or Full body. ## What changed - **No avatar controls on the chat.** The stage's Arrange/Done button, its size sliders and the per-avatar Done (check) button are gone. While Arrange is off, avatars ignore clicks, so the chat gets them. - **New Avatars drawer** in Chat Settings → Agents (Roleplay, Visual Novel and Game), shown when the 2D or 3D Avatars agent is on in the chat. It reuses the Expression Engine drawer's parts: the Arrange/Done and Reset buttons, an **Avatar** picker listing each character or persona whose avatar shows in the chat, the size slider (same 5–200% range and steps), and help text. It also has a link in the Agents menu chips. - **Arrange** turns dragging on and off. While it is on, 2D and 3D avatars can be dragged with a mouse or a finger and moved with the arrow keys (Shift moves further), as in #7850. Clicks over a Game avatar do not move the story on. - **Reset** clears the avatars' saved positions only. Sprites keep theirs. - **Framing** (3D only, hidden for 2D): Portrait is today's framing and the default. Half body shows down to the hips. Full body fits the whole model, from the measured top of its hair or hat (no longer capped) to its measured soles, with a little floor below. `frameCamera` takes the framing as a mode and still changes smoothly as the box resizes. The avatar box keeps its size; a taller framing shows more of the model in it. - **3D canvas stays sharp.** The VRM renderer redraws at once when its size or framing changes, as the 2D renderers already do, so a resized canvas never shows a stretched picture until the next frame. - **One owner for the layout.** Game kept its own copy of the per-chat layout cache, so it could not hear the drawer. ChatArea now owns it for every mode. Saves happen at the time of the edit, never inside a React state updater. Queued edits each build on the one before, and an edit from a chat that has since closed is dropped. Framing is saved per owner in the same device-local per-chat layout as size and position (`avatarFramings`). Nothing in `packages/shared` changed. - Removed copy that is no longer used: `avatars.stage.arrange`, `avatars.stage.done`, `avatars.stage.finishPlacing`. Added `avatars.layout.*` (title, description, framing labels, help, empty state). Existing text is reused for Arrange, Done, Reset, Avatar and the size label. - `docs/agents/avatars.md`: the Arrange section now describes the drawer and the framing choice, in plain words. ## 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` Agent-run checks (for the reviewer to confirm, not proof): - `pnpm check`: exit 0 (one existing lint warning in `HomeProfessorMariChat.tsx`, not touched here). - `node ./scripts/run-regressions.mjs --filter avatar`: the avatar regressions passed (`avatar-2d-importers` timed out once under parallel load, then passed on its own). `avatar-placement.regression.ts` now drives ChatArea's shared callbacks and keeps every assertion it had for Game's: batched moves and sizes survive, saves happen outside updaters, stale chats can't save, a new chat reads its own cache, and a full cache keeps edits visible. It adds framing and Reset. `avatar-vrm.regression.ts` adds the framing math: Portrait is unchanged, Half body reaches the hips, Full body keeps a tall hat and the soles in view, no jumps on resize. It also checks the immediate redraw. - Playwright on `desktop-chromium` and `mobile-chromium`: `e2e/avatar-placement.e2e.ts` (rewritten to use the drawer, per the maintainer decision), `e2e/avatar-setup.e2e.ts` and `e2e/avatar-2d.e2e.ts`: 42 passed. The placement spec now checks, in Roleplay and Game, that the stage has no Arrange, Done or size controls. It checks that the drawer's Arrange makes a 2D and a 3D avatar draggable by mouse or touch and by the arrow keys, and that the slider resizes both and the 3D canvas keeps its full pixel ratio. It checks that Full body puts the VRM fixture's head and feet inside the canvas, and that Done gives clicks back to the chat. After a reload, positions, sizes and framing are restored. The old check of the removed on-stage slider's styling is gone with the slider. `avatar-setup.e2e.ts` now scopes its Expression Engine Arrange click to that card, because the Avatars card has its own Arrange. - The real 16.5 MB VRoid Studio model (Maukie, VRM 1.0) was tested on a local instance with a temporary data folder, in Roleplay, Visual Novel and Game, desktop and phone. The stage had no Arrange button. Portrait, Half body and Full body each framed as intended, and Full body showed the hair and shoes inside the box. The size slider resized the canvas with matching pixels. Drag worked with Arrange on, and the layout came back after a reload with Arrange off. Headless Chromium's software GL could not draw this model, so this check used Chromium with Metal. ### Manual verification notes Please check these by hand. None have been done by a person yet: - Manually verify in a Roleplay chat with 3D Avatars on: there is no Arrange button on the chat; Chat Settings → Agents → **Avatars** shows your avatar; **Full body** shows the whole model from hair to shoes; **Half body** stops around the hips/thighs; **Portrait** looks as before. - Manually verify that Arrange in that drawer lets you drag the avatar anywhere in the chat with a mouse, and with a finger on a phone. Check that the arrow keys move a focused avatar, and that after **Done** clicks on the chat reach the messages again. - Manually verify the size slider in the drawer resizes 2D and 3D avatars, and the 3D one stays sharp, not blurry. - Manually verify Visual Novel and Game chats the same way, including that clicking a Game avatar while arranging does not advance the story. - Manually verify that reloading keeps each avatar's position, size and framing, and that **Reset** puts avatars back without moving sprites. - Manually verify light and dark themes in the drawer. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) `docs/agents/avatars.md` changed (the Arrange paragraph, the new Framing paragraph, and one sentence in the 3D section). The translation follow-up for this file is already open as #7831; a note about this change was added there. ## UI evidence (if applicable) Before (staging, #7843/#7850): an "Arrange avatars" button sits on the chat, at the top left in Roleplay and the top right in Game. Pressing it puts a Done button and one size slider per avatar over the chat, plus a check button above each avatar. After, from the e2e run (`test-results/avatar-placement.e2e.ts-…/`): - `roleplay-before.png` / `game-before.png`: a 3D (VRM fixture) and a 2D avatar on the chat with no controls on the stage. - `roleplay-desktop-drawer.png`, `roleplay-phone-drawer.png`, `game-desktop-drawer.png`, `game-phone-drawer.png`: the Avatars drawer in Chat Settings → Agents, with Arrange/Reset, the Avatar picker, the size slider and Framing; the VRM is in Full body framing. - `*-arranging.png`: both avatars marked "Drag to move" after being dragged with Arrange on. - `*-restored.png`: after a reload, the same positions, sizes and framing. From the local check with the real Maukie model (`maukie-shots/<layout>-<desktop|phone>/` in the session scratchpad): `1-portrait.png`, `3-half-body.png` and `3-full-body.png` compare the three framings in the same box. `4-arranged.png` shows the drag with Arrange on, and `5-reloaded.png` shows the layout after a reload. These cover Roleplay, Visual Novel and Game, on desktop and phone. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added avatar layout controls in chat settings to select visible avatars, resize them, arrange or reset their positions, and adjust framing for 3D avatars. * Added Portrait, Half body, and Full body framing options for 3D avatars. * Avatar layout choices are saved per chat on the device. * **Documentation** * Updated avatar setup and layout guidance, including how framing options affect the visible model. <!-- 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-24 04:09:14 +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#7967
No description provided.