[PR #7578] [MERGED] fix(avatars): one set of setup controls, and sprites show as an avatar #7809

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

📋 Pull Request Information

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

Base: staging ← Head: fix/avatars-base-integration


📝 Commits (2)

  • 030d1cf fix(avatars): one set of setup controls, and sprites show as an avatar
  • 9a44b29 test(avatars): check the saved avatar in chat and keep other workers' avatars out

📊 Changes

12 files changed (+409 additions, -587 deletions)

View changed files

📝 docs/agents/avatars.md (+6 -7)
📝 e2e/avatar-setup.e2e.ts (+66 -28)
📝 packages/client/src/features/avatars/setup/AvatarAgentSetup.tsx (+94 -310)
📝 packages/client/src/features/avatars/setup/avatar-setup-logic.ts (+3 -93)
📝 packages/client/src/features/avatars/setup/demo-avatar.ts (+2 -2)
📝 packages/client/src/features/avatars/stage/AvatarStage.tsx (+74 -30)
📝 packages/client/src/features/avatars/stage/avatar-stage-logic.ts (+36 -5)
📝 packages/client/src/hooks/use-avatar-models.ts (+4 -26)
📝 packages/client/src/localization/locales/en.json (+0 -24)
📝 packages/server/src/services/avatars/storage.ts (+13 -2)
📝 scripts/regressions/avatar-models.regression.ts (+37 -11)
📝 scripts/regressions/avatar-stage-logic.regression.ts (+74 -49)

📄 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

Refs #7537 (epic: 2D and 3D avatar agents). This follows up the base lane, #7556, which merged while these integration fixes were being made. The epic stays open for the remaining lanes.

Why this change

An integration review of the base lane against the 2D (#7549, merged), 3D (#7557), director (#7555) and generation (#7554) lanes found these problems:

  • Two sets of setup controls. The 2D Avatars and 3D Avatars pages showed base's own Use my sprites, import buttons, Remove and a Faces editor, then the kind panel's copies of the same controls below them. With both on screen there were two "Use my sprites" buttons, two "Remove" buttons and two face editors with different labels (Calm vs Neutral). The two copies also saved different data. Base's face editor offered slot names that mesh avatars ignore and never offered a VRM's own expression names. Base's Add an idle animation also lacked the 3D panel's check that keeps a .vrm picked on a phone from replacing the model.
  • Mouths never opened after base's "Use my sprites". Base's own sprite builder made happy_talk and similar sprites into separate faces instead of the open-mouth picture. It also skipped full-body-only owners. The 2D lane's builder handles both cases.
  • Sprites showed nothing in chats. The PNGTuber panel says "Shows your expression sprites until you change something here", and the guide's 2D section says such an owner "already has a PNGTuber avatar ... with nothing to set up". In practice the chat showed nothing until something was saved, and showed nothing again after Remove.
  • The classifier model downloaded with no avatar on screen. The stage created the director before checking whether any avatar shows, and the director lane's director asks for the mood model as soon as it is created.
  • A regression would fail once 3D merges. avatar-models.regression.ts checked the 3D stub's exact refusal text, and the real VRM importer answers with a different message. Each PR passed alone, but whichever merged second would break complete-node-regressions.

What changed

  • Setup page (setup/AvatarAgentSetup.tsx): base now keeps only the controls that apply to every kind: the character/persona picker, Show this avatar in chats, Avatar type with Show this one, the Movement switches and the preview. Importing, removing, sprites and faces belong to the kind panels below it. Base's sprite builder, face-editor helpers, import/remove hooks and their 24 unused avatars.setup.* strings are deleted. Show this one on a sprite-only PNGTuber saves the sprite setup along with the choice, because the schema requires the active kind to be set up.
  • Sprites are an avatar until one is saved (stage and setup): with 2D Avatars on in a chat, an owner with expression sprites and no saved PNGTuber setup shows its sprites as a PNGTuber avatar. Both the stage and the setup preview build it with the 2D lane's buildPngtuberLayersFromSprites, so one rule applies everywhere. Show this avatar in chats and Movement now also appear for such owners. Turning the avatar off hides it. Nothing shows until the saved-avatar list has loaded, so a turned-off avatar never flashes in. Sprite lists are fetched per participant only when 2D Avatars is on, the same way ChatArea already fetches them for expression avatars.
  • Storage (services/avatars/storage.ts), a behaviour change the maintainer did not request: removing the last kind still deletes the owner's folder. The exception is an avatar that is turned off or has a Movement switch changed: then avatar.json stays, with no kinds. Without this, removing the last kind would bring a turned-off avatar back through the sprite fallback. avatar-models.regression.ts pins both cases. The original "folder is gone with its last kind" check still holds once the switches are back at their defaults, and the old "folder gone" check on a turned-off avatar now expects avatar.json to stay. CodeRabbit flagged this expectation change, so it is called out here for review.
  • Director: the stage creates the director only once an avatar shows.
  • Regression: the import-dispatch check now uses a stand-in VRM importer that refuses with a known message. It still proves that a .vrm the importer does not recognise goes to that importer and that the person sees its own message, and it no longer depends on the 3D lane's text.
  • Docs: docs/agents/avatars.md "Setting up an avatar" now describes the split page and the sprite avatar. The guide's translation is already tracked in #7540.

Whether avatars should show from sprites with nothing saved is a product decision for @SpicyMarinara. This PR follows what the merged 2D panel copy and guide already promise, and what the 2D PR asked of base. If the answer is no, revert the stage and setup fallback in 030d1cf9e and change the 2D copy and guide instead.

Not changed here (other lanes, noted for whoever merges): the director lane's branch edits setup/AvatarAgentSetup.tsx to render <AvatarModelStatus />, and avatar-director.regression.ts checks for it. That file now conflicts with staging, so #7555 needs to add <AvatarModelStatus /> to the merged setup page when it resolves the conflict. The preview's Try a face menu still labels the resting face "Calm" while the 2D panel says "Neutral". I left that copy alone.

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

Commands run by the agent (results as reported; the boxes above are for the human reviewer):

  • pnpm install --frozen-lockfile --prefer-offline --store-dir <main checkout>/.pnpm-store, pnpm build:shared: done. No dependency or lockfile change.
  • pnpm check on the rebased head: passed (exit 0). The only ESLint warning is the existing one in HomeProfessorMariChat.tsx. pnpm localization:check: passed.
  • node scripts/run-regressions.mjs --filter avatar (10 files): all passed, on the rebased head too. --filter for agent-activation, spatial-context, open-issues, admin-preset-expunge, backup (4 files), character-delete-chat-membership, profile-import, sprite-list-security, capability-package-lifecycle, docs-command-search and docs-language: all passed.
  • Integrated tree: on a throwaway local merge of this fix with origin/feat/avatars-3d, --filter avatar gave 11/11 (including avatar-vrm and avatar-models). Before the fix, the integration review reported 13/14 there, with only avatar-models failing.
  • Proof the storage check bites: with the old storage.ts and the new regression, avatar-models.regression.ts fails.
  • avatar-stage-logic.regression.ts now covers the sprite fallback (a sprite-only owner shows, a VRM whose agent is off falls back to sprites, a turned-off owner stays hidden, nothing shows before the list loads, sprites need 2D Avatars). It also checks withSpriteAvatar (identity kept so nothing remounts, a saved setup wins) and that _talk sprites become open mouths. Source checks confirm the director is created only once an avatar shows and that the setup page has no file picker, removal or face editor.
  • Browser: npx playwright test e2e/avatar-setup.e2e.ts --repeat-each=3 on its own ports: 9/9 passed on desktop Chromium, Android-sized Chromium and iPhone-sized WebKit. The test proves the chat shows the sprite avatar with no avatar.json (404). It checks that the page has exactly one Use my sprites, one Import PNGTuber Plus save and no Remove before saving. It covers the preview showing the character's sprites instead of the example, the covered chat pausing on phones, the saved layers using happy_talk as happy's open mouth, a hand-picked face being saved, and the chat showing the saved avatar. The owner list is narrowed to the test's own character, because the two mobile projects share one local server and the other worker's saved avatar made the page open on that owner. e2e/avatar-preview.e2e.ts (profile-picture library, not this code) failed once on mobile Chromium in a combined run and passed when run alone.
  • Built bundle: pngtuber-layers is its own small lazy chunk shared by the stage, the setup and the renderer, and none of it is in the entry chunk.
  • Local CodeRabbit (coderabbit review --agent --committed --base-commit 2b417feaa): 2 findings. Fixed in 9a44b29db: the chat check after saving is back. Not changed: the storage expectation change, which is deliberate and explained above (no maintainer request; flagged for review). Not rerun after the test-only fix.

Manual verification notes

Install a local build of the 2D Avatars package, or add 2d-avatars to a chat's agents with a package that declares that id.

  • Desktop Chrome, Firefox and Safari: open Agents → 2D Avatars and choose a character with expression sprites (include happy and happy_talk) and nothing saved. The page shows one set of controls: the switches, Avatar type with PNGTuber marked Shown in chats, Movement, then the PNGTuber panel with one Use my sprites. The preview shows the character's sprites, not the example avatar.
  • Same page: press Use my sprites, then Talk in the preview. The happy face opens its mouth with happy_talk, and happy_talk is not offered as a separate face.
  • Open a Roleplay chat with that character and 2D Avatars added, before and after saving. The avatar shows both times. Turn Show this avatar in chats off: it disappears from the chat. Press Remove in the PNGTuber panel: it stays hidden.
  • Same character with the avatar on: press Remove. The chat goes back to showing the sprites.
  • Agents → 3D Avatars (once #7557 lands): only the VRM panel imports, removes and maps faces, and there is no second import or Faces block above it.
  • Desktop Chrome DevTools → Network: open a Roleplay chat with 2D Avatars on where no character or persona has sprites or a saved avatar. No POST /api/avatar-classify/model is sent (needs #7555).
  • Android Chrome, the Android app WebView and iOS Safari: the 2D Avatars page stacks with the preview on top. With a Roleplay chat open underneath, [data-avatar-stage] carries data-avatar-paused="true" while the agent page covers it.
  • Light and dark mode and a custom theme: nothing new uses hard-coded colours.

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 ("Setting up an avatar") changed. Its translation is tracked in #7540.

UI evidence (if applicable)

None attached. The e2e saves avatar-setup-sprites.png and avatar-setup.png per project under test-results/ when it runs.


🔄 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/7578 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/13/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/avatars-base-integration` --- ### 📝 Commits (2) - [`030d1cf`](https://github.com/Pasta-Devs/Marinara-Engine/commit/030d1cf9e5f0c868db057d18253b908cf107a9e7) fix(avatars): one set of setup controls, and sprites show as an avatar - [`9a44b29`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9a44b29dbf532e7334aaa671729e36f47d57dff4) test(avatars): check the saved avatar in chat and keep other workers' avatars out ### 📊 Changes **12 files changed** (+409 additions, -587 deletions) <details> <summary>View changed files</summary> 📝 `docs/agents/avatars.md` (+6 -7) 📝 `e2e/avatar-setup.e2e.ts` (+66 -28) 📝 `packages/client/src/features/avatars/setup/AvatarAgentSetup.tsx` (+94 -310) 📝 `packages/client/src/features/avatars/setup/avatar-setup-logic.ts` (+3 -93) 📝 `packages/client/src/features/avatars/setup/demo-avatar.ts` (+2 -2) 📝 `packages/client/src/features/avatars/stage/AvatarStage.tsx` (+74 -30) 📝 `packages/client/src/features/avatars/stage/avatar-stage-logic.ts` (+36 -5) 📝 `packages/client/src/hooks/use-avatar-models.ts` (+4 -26) 📝 `packages/client/src/localization/locales/en.json` (+0 -24) 📝 `packages/server/src/services/avatars/storage.ts` (+13 -2) 📝 `scripts/regressions/avatar-models.regression.ts` (+37 -11) 📝 `scripts/regressions/avatar-stage-logic.regression.ts` (+74 -49) </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 Refs #7537 (epic: 2D and 3D avatar agents). This follows up the base lane, #7556, which merged while these integration fixes were being made. The epic stays open for the remaining lanes. ## Why this change An integration review of the base lane against the 2D (#7549, merged), 3D (#7557), director (#7555) and generation (#7554) lanes found these problems: - **Two sets of setup controls.** The 2D Avatars and 3D Avatars pages showed base's own **Use my sprites**, import buttons, **Remove** and a **Faces** editor, then the kind panel's copies of the same controls below them. With both on screen there were two "Use my sprites" buttons, two "Remove" buttons and two face editors with different labels (Calm vs Neutral). The two copies also saved different data. Base's face editor offered slot names that mesh avatars ignore and never offered a VRM's own expression names. Base's **Add an idle animation** also lacked the 3D panel's check that keeps a `.vrm` picked on a phone from replacing the model. - **Mouths never opened after base's "Use my sprites".** Base's own sprite builder made `happy_talk` and similar sprites into separate faces instead of the open-mouth picture. It also skipped full-body-only owners. The 2D lane's builder handles both cases. - **Sprites showed nothing in chats.** The PNGTuber panel says "Shows your expression sprites until you change something here", and the guide's 2D section says such an owner "already has a PNGTuber avatar ... with nothing to set up". In practice the chat showed nothing until something was saved, and showed nothing again after **Remove**. - **The classifier model downloaded with no avatar on screen.** The stage created the director before checking whether any avatar shows, and the director lane's director asks for the mood model as soon as it is created. - **A regression would fail once 3D merges.** `avatar-models.regression.ts` checked the 3D stub's exact refusal text, and the real VRM importer answers with a different message. Each PR passed alone, but whichever merged second would break `complete-node-regressions`. ## What changed - **Setup page (`setup/AvatarAgentSetup.tsx`):** base now keeps only the controls that apply to every kind: the character/persona picker, **Show this avatar in chats**, **Avatar type** with **Show this one**, the **Movement** switches and the preview. Importing, removing, sprites and faces belong to the kind panels below it. Base's sprite builder, face-editor helpers, import/remove hooks and their 24 unused `avatars.setup.*` strings are deleted. **Show this one** on a sprite-only PNGTuber saves the sprite setup along with the choice, because the schema requires the active kind to be set up. - **Sprites are an avatar until one is saved (stage and setup):** with 2D Avatars on in a chat, an owner with expression sprites and no saved PNGTuber setup shows its sprites as a PNGTuber avatar. Both the stage and the setup preview build it with the 2D lane's `buildPngtuberLayersFromSprites`, so one rule applies everywhere. **Show this avatar in chats** and **Movement** now also appear for such owners. Turning the avatar off hides it. Nothing shows until the saved-avatar list has loaded, so a turned-off avatar never flashes in. Sprite lists are fetched per participant only when 2D Avatars is on, the same way `ChatArea` already fetches them for expression avatars. - **Storage (`services/avatars/storage.ts`), a behaviour change the maintainer did not request:** removing the last kind still deletes the owner's folder. The exception is an avatar that is turned off or has a **Movement** switch changed: then `avatar.json` stays, with no kinds. Without this, removing the last kind would bring a turned-off avatar back through the sprite fallback. `avatar-models.regression.ts` pins both cases. The original "folder is gone with its last kind" check still holds once the switches are back at their defaults, and the old "folder gone" check on a turned-off avatar now expects `avatar.json` to stay. CodeRabbit flagged this expectation change, so it is called out here for review. - **Director:** the stage creates the director only once an avatar shows. - **Regression:** the import-dispatch check now uses a stand-in VRM importer that refuses with a known message. It still proves that a `.vrm` the importer does not recognise goes to that importer and that the person sees its own message, and it no longer depends on the 3D lane's text. - **Docs:** `docs/agents/avatars.md` "Setting up an avatar" now describes the split page and the sprite avatar. The guide's translation is already tracked in #7540. Whether avatars should show from sprites with nothing saved is a product decision for @SpicyMarinara. This PR follows what the merged 2D panel copy and guide already promise, and what the 2D PR asked of base. If the answer is no, revert the stage and setup fallback in `030d1cf9e` and change the 2D copy and guide instead. Not changed here (other lanes, noted for whoever merges): the director lane's branch edits `setup/AvatarAgentSetup.tsx` to render `<AvatarModelStatus />`, and `avatar-director.regression.ts` checks for it. That file now conflicts with staging, so #7555 needs to add `<AvatarModelStatus />` to the merged setup page when it resolves the conflict. The preview's **Try a face** menu still labels the resting face "Calm" while the 2D panel says "Neutral". I left that copy alone. ## 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` Commands run by the agent (results as reported; the boxes above are for the human reviewer): - `pnpm install --frozen-lockfile --prefer-offline --store-dir <main checkout>/.pnpm-store`, `pnpm build:shared`: done. No dependency or lockfile change. - `pnpm check` on the rebased head: passed (exit 0). The only ESLint warning is the existing one in `HomeProfessorMariChat.tsx`. `pnpm localization:check`: passed. - `node scripts/run-regressions.mjs --filter avatar` (10 files): all passed, on the rebased head too. `--filter` for `agent-activation`, `spatial-context`, `open-issues`, `admin-preset-expunge`, `backup` (4 files), `character-delete-chat-membership`, `profile-import`, `sprite-list-security`, `capability-package-lifecycle`, `docs-command-search` and `docs-language`: all passed. - Integrated tree: on a throwaway local merge of this fix with `origin/feat/avatars-3d`, `--filter avatar` gave 11/11 (including `avatar-vrm` and `avatar-models`). Before the fix, the integration review reported 13/14 there, with only `avatar-models` failing. - Proof the storage check bites: with the old `storage.ts` and the new regression, `avatar-models.regression.ts` fails. - `avatar-stage-logic.regression.ts` now covers the sprite fallback (a sprite-only owner shows, a VRM whose agent is off falls back to sprites, a turned-off owner stays hidden, nothing shows before the list loads, sprites need 2D Avatars). It also checks `withSpriteAvatar` (identity kept so nothing remounts, a saved setup wins) and that `_talk` sprites become open mouths. Source checks confirm the director is created only once an avatar shows and that the setup page has no file picker, removal or face editor. - Browser: `npx playwright test e2e/avatar-setup.e2e.ts --repeat-each=3` on its own ports: 9/9 passed on desktop Chromium, Android-sized Chromium and iPhone-sized WebKit. The test proves the chat shows the sprite avatar with no `avatar.json` (404). It checks that the page has exactly one **Use my sprites**, one **Import PNGTuber Plus save** and no **Remove** before saving. It covers the preview showing the character's sprites instead of the example, the covered chat pausing on phones, the saved layers using `happy_talk` as `happy`'s open mouth, a hand-picked face being saved, and the chat showing the saved avatar. The owner list is narrowed to the test's own character, because the two mobile projects share one local server and the other worker's saved avatar made the page open on that owner. `e2e/avatar-preview.e2e.ts` (profile-picture library, not this code) failed once on mobile Chromium in a combined run and passed when run alone. - Built bundle: `pngtuber-layers` is its own small lazy chunk shared by the stage, the setup and the renderer, and none of it is in the entry chunk. - Local CodeRabbit (`coderabbit review --agent --committed --base-commit 2b417feaa`): 2 findings. Fixed in `9a44b29db`: the chat check after saving is back. Not changed: the storage expectation change, which is deliberate and explained above (no maintainer request; flagged for review). Not rerun after the test-only fix. ### Manual verification notes Install a local build of the 2D Avatars package, or add `2d-avatars` to a chat's agents with a package that declares that id. - Desktop Chrome, Firefox and Safari: open **Agents → 2D Avatars** and choose a character with expression sprites (include `happy` and `happy_talk`) and nothing saved. The page shows one set of controls: the switches, **Avatar type** with PNGTuber marked **Shown in chats**, **Movement**, then the PNGTuber panel with one **Use my sprites**. The preview shows the character's sprites, not the example avatar. - Same page: press **Use my sprites**, then **Talk** in the preview. The `happy` face opens its mouth with `happy_talk`, and `happy_talk` is not offered as a separate face. - Open a Roleplay chat with that character and 2D Avatars added, before and after saving. The avatar shows both times. Turn **Show this avatar in chats** off: it disappears from the chat. Press **Remove** in the PNGTuber panel: it stays hidden. - Same character with the avatar on: press **Remove**. The chat goes back to showing the sprites. - **Agents → 3D Avatars** (once #7557 lands): only the VRM panel imports, removes and maps faces, and there is no second import or Faces block above it. - Desktop Chrome DevTools → Network: open a Roleplay chat with 2D Avatars on where no character or persona has sprites or a saved avatar. No `POST /api/avatar-classify/model` is sent (needs #7555). - Android Chrome, the Android app WebView and iOS Safari: the 2D Avatars page stacks with the preview on top. With a Roleplay chat open underneath, `[data-avatar-stage]` carries `data-avatar-paused="true"` while the agent page covers it. - Light and dark mode and a custom theme: nothing new uses hard-coded colours. ## 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` ("Setting up an avatar") changed. Its translation is tracked in #7540. ## UI evidence (if applicable) None attached. The e2e saves `avatar-setup-sprites.png` and `avatar-setup.png` per project under `test-results/` when it runs. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:07:42 +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#7809
No description provided.