[PR #7581] [MERGED] fix(avatars): per-avatar frame rate, one shared drag, and shared save, picture and blink helpers #7812

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

📋 Pull Request Information

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

Base: staging ← Head: fix/avatars-reuse-polish


📝 Commits (7)

  • 74c6ad6 fix(avatars): per-avatar frame rate, one shared drag, and one copy of each avatar helper
  • c0347d8 test(avatars): open the Agents section before Arrange in the drag e2e
  • f91c9ad test(avatars): keep the setup page from opening itself in the saved-chat page
  • 3f0a1f0 fix(avatars): count a phone's load per avatar so idle avatars stay at 15
  • 189cb41 fix(avatars): keep the VRM panel's toasts when it closes mid-request
  • 1b98bc6 docs(avatars): say mesh avatars keep the runtime's own blinking
  • 28ec82a Merge remote-tracking branch 'origin/staging' into HEAD

📊 Changes

26 files changed (+646 additions, -424 deletions)

View changed files

📝 e2e/avatar-2d.e2e.ts (+73 -14)
📝 e2e/avatar-setup.e2e.ts (+123 -2)
📝 packages/client/src/components/chat/SpriteOverlay.tsx (+8 -76)
➕ packages/client/src/components/chat/use-sprite-placement-drag.ts (+92 -0)
📝 packages/client/src/features/avatars/generation/AvatarGenerationPanel.tsx (+4 -1)
📝 packages/client/src/features/avatars/generation/PngtuberVariantsSection.tsx (+2 -5)
📝 packages/client/src/features/avatars/generation/use-avatar-generation.ts (+6 -15)
📝 packages/client/src/features/avatars/renderers/mesh-avatar/MeshAvatarSetupPanel.tsx (+12 -9)
📝 packages/client/src/features/avatars/renderers/pngtuber/PngtuberSetupPanel.tsx (+16 -11)
📝 packages/client/src/features/avatars/renderers/pngtuber/pngtuber-layers.ts (+7 -24)
📝 packages/client/src/features/avatars/renderers/pngtuber/pngtuber-renderer.ts (+11 -30)
➖ packages/client/src/features/avatars/renderers/pngtuber/use-avatar-kind-actions.ts (+0 -39)
📝 packages/client/src/features/avatars/renderers/vrm/VrmSetupPanel.tsx (+33 -51)
📝 packages/client/src/features/avatars/renderers/vrm/vrm-motion.ts (+10 -4)
📝 packages/client/src/features/avatars/setup/AvatarAgentSetup.tsx (+3 -3)
📝 packages/client/src/features/avatars/setup/AvatarSetupPreview.tsx (+8 -5)
📝 packages/client/src/features/avatars/setup/demo-avatar.ts (+1 -1)
📝 packages/client/src/features/avatars/stage/AvatarStage.tsx (+29 -111)
📝 packages/client/src/features/avatars/stage/avatar-stage-logic.ts (+39 -0)
📝 packages/client/src/hooks/use-avatar-models.ts (+58 -6)

...and 6 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

Refs #7537 (epic: 2D and 3D avatar agents). This is the polish and reuse lane, branched from staging after the live-faces lane (#7555) and the generation lane (#7554) merged.

Why this change

  • Phones spent the talking frame rate on every avatar. The stage's one loop picked a single rate for all avatars. While any avatar talked, the quiet one next to it also drew at 30 fps instead of the idle 20 (15 under load). The budget says only the speaking avatar draws at the talking rate.
  • Two copies of the Arrange drag. The sprites' drag was inline in SpriteOverlay.tsx, and the avatar stage had its own usePlacementDrag. The avatars must use the sprites' drag code, and two copies drift apart.
  • Three copies of save, import and remove. useUpdateAvatarModel in hooks/use-avatar-models.ts, the 2D lane's use-avatar-kind-actions.ts and the VRM panel's inline mutations each refreshed the avatar queries in their own way. Kept generation results had a fourth refresh.
  • Two picture resolvers, and a sprite list fetched twice. resolveAvatarImage (stage) and resolvePngtuberImage (2D lane) did the same job. The PNGTuber renderer fetched /api/sprites again although the stage already holds the list, and a mesh avatar's sprite fallback fetched it once more.
  • Two default blink rates. PNGTuber blinks every 4.5 s on average (3 to 6 s), defined three times (client, server import, server generation). VRM blinked every 2 to 6 s (4 s on average).
  • Generation offered talk and blink pictures as sources. Make an avatar from a sprite listed happy_talk and happy_blink next to the faces, which would make a blink picture of a talk picture.

What changed

  • Frame rate: the stage keeps one frame loop and gives each avatar its own clock. The speaking avatar draws at the talking rate (30). Every other avatar draws at the idle rate (phones 20, or 15 under load; desktops 30). Hidden, off-screen, covered and paused stages still draw nothing, and reduced motion is unchanged. avatarDrawDue in avatar-stage-logic.ts is the rule.
  • Phone load: each avatar keeps its own average draw time, and a phone is under load when one draw of every avatar takes more than 12 ms (avatarsUnderLoad). The first version averaged the cost per drawing tick. Once a speaker's clock drifted out of phase with the quiet one, each tick held only one avatar, so a loaded phone stopped counting as loaded after the first line and went back to 20 fps. The stage and the setup preview also share one phone query (AVATAR_PHONE_QUERY) instead of two copies.
  • Arrange mode: one drag hook, components/chat/use-sprite-placement-drag.ts, extracted from the sprite's inline code. Full-body sprites and avatars both use it. The gesture is unchanged: drag in percentages of the stage, Release to Save, the check button saves and ends Arrange mode, and leaving Arrange mode mid-drag drops the drag.
  • Save, import and remove: useAvatarModelActions in hooks/use-avatar-models.ts is the one place. The owner switches, the PNGTuber, mesh and VRM panels all use it, and kept generation results refresh through the same helper (useAvatarModelChanged). use-avatar-kind-actions.ts and the VRM panel's inline copies are deleted. After a save, an import or a removal, the setup page now shows the server's reply at once and then refreshes. Before, the 2D panels and the owner switches waited for a refetch. The VRM panel gives its toasts to the hook (as it did on staging), not to mutate(), so a rejected import still says so after the user switches owner or leaves the page.
  • Pictures: resolveAvatarImage is the one resolver, and resolvePngtuberImage is deleted. The PNGTuber renderer no longer fetches /api/sprites. The stage and the setup preview hand it the setup and the sprite list they already have, including to mesh avatars for their sprite fallback. A mesh avatar now waits for that list before it mounts, instead of mounting and then mounting again when the list arrives. Face thumbnails in the PNGTuber panel now load stored pictures with the save time attached, so a replaced picture shows fresh.
  • Blinking: PNGTUBER_DEFAULT_MOTION lives once in @marinara-engine/shared (4.5 s average). The client, the server's .save importer and the server's generation use it. VRM models now blink at the same rate: every 3 to 6 seconds instead of every 2 to 6. Mesh avatars still use the mesh-avatar runtime's own blinking (about every 2 to 6 seconds, sometimes twice), and the comments now say so.
  • Generation: Make an avatar from a sprite no longer offers _talk and _blink pictures (or their other spellings) as the source. The variants section reuses pngtuberSpriteFamily instead of its own copy.
  • Tests: e2e/avatar-setup.e2e.ts failed about one run in six on staging too (1 of 6 repeats there). The 2D Avatars page, still open in the same browser context, kept saving its UI state (the open agent page) to the shared local storage while the saved-chat page started, so that page sometimes opened the agent editor instead of the chat. The agent page now leaves first, and each page answers the synced UI settings itself.

Not changed, for the maintainer:

  • docs/agents/avatars.md already lists the talking and idle rates per avatar, so I left the guide alone. Step 1 of Blink and talk pictures could say that talk and blink sprites are not offered; I did not add that, to avoid a docs-i18n follow-up for one sentence.
  • The server's spriteBuiltPngtuber in services/avatars/generation/pngtuber-variants.ts is still a copy of the client's buildPngtuberLayersFromSprites (it carries a ponytail: note saying so). Moving one copy into @marinara-engine/shared is a follow-up.
  • Some near-copies remain, on purpose: errorMessage exists in four files with two different contracts (the raw message, or a translated fallback), and merging them would change what some toasts say. SpriteLike (url optional, for building faces) and AvatarSpriteRef (url required, for resolving pictures) describe different inputs.
  • The PNGTuber and mesh panels still pass their toasts to mutate(), as they already did on staging, so their toasts can be lost the same way if the panel closes mid-request. The hook now takes hook-level feedback, so moving them is a small follow-up.
  • Face thumbnails in the PNGTuber panel carry the save time (?v=), so they refetch after each save. That is what lets a regenerated picture at the same path show fresh, and the browser keeps the old picture until the new one has loaded.
  • The open questions already with Mari are untouched: the "Calm" vs "Neutral" label, whether a persona's mouth moves for the user's own messages, and the chat-chrome 64% accent text.

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 (the boxes above are for the human reviewer). Tested revision: 1b98bc630 unless noted.

  • pnpm install --frozen-lockfile --prefer-offline --store-dir <main checkout>/.pnpm-store, pnpm build:shared: done. No dependency or lockfile change.
  • pnpm check: passed (exit 0). The only ESLint warning is the existing one in HomeProfessorMariChat.tsx. pnpm localization:check (part of it): passed; no English key changed.
  • node scripts/run-regressions.mjs --filter avatar: 14/14 passed. Checks this PR adds:
    • avatar-stage-logic: one simulated 60 Hz loop with a speaking and a quiet avatar draws 30/20 per second on a phone, 30/15 under load and 30/30 on a desktop, and the stage's loop asks each avatar's own clock. A second simulation runs two avatars that take 8 ms each to draw on a phone through a 3 s line: both idle at 15 before, the quiet one stays at 15 during the line, and both stay at 15 for 6 s after it; avatars that take 5 ms idle at 20. With the earlier per-tick average swapped into the same simulation, both avatars went back to 20 after the line, so this check catches it.
    • avatar-vrm: VRM blinks are 3, 4.5 and 6 s apart for the lowest, middle and highest random draw.
    • avatar-2d-renderers: _talk and _blink sprites are never a source. Its three resolvePngtuberImage checks now run against resolveAvatarImage with the same expectations (a stored file now carries ?v=<save time>), plus a full-body-only case.
  • Guards: --filter agent-activation (2/2), --filter spatial-context (1/1), --filter open-issues (1/1): passed.
  • Browser, on ports of its own (PLAYWRIGHT_*_PORT 5412/8012/5413/8013):
    • Desktop Chromium: e2e/avatar-2d.e2e.ts, e2e/avatar-setup.e2e.ts, e2e/avatar-preview.e2e.ts, e2e/expression-active-sprites.e2e.ts: 16/16 passed.
    • Mobile Chromium and mobile WebKit: e2e/avatar-2d.e2e.ts and e2e/avatar-setup.e2e.ts: 24/24 passed.
    • New e2e/avatar-2d.e2e.ts test "the VRM setup still reports a rejected import after the panel closes": picks a .vrm, closes the panel while the upload waits, then the server rejects it; the error toast must show. It passed 3/3, and failed with f91c9ad25's VrmSetupPanel.tsx swapped in (then restored).
    • Phone load, temporary Playwright probe (deleted afterwards), mobile Chromium: two PNGTuber avatars in a Roleplay chat, each draw slowed by 8 ms, a quoted line streamed for one of them through the chat store. With this branch, 4 of 4 runs: 15/15 before the line, the quiet avatar at 15 during it, and both at 14-15 in the two 3 s windows from 3 to 9 s after it. With f91c9ad25's AvatarStage.tsx swapped in: the quiet avatar at 16-19 during the line and, in one of two runs, 19-20/19 after it.
  • Earlier commits (74c6ad640 to f91c9ad25): avatar-setup.e2e.ts --repeat-each=8 16/16 on desktop Chromium. The Arrange test also passed with staging's own SpriteOverlay.tsx and AvatarStage.tsx swapped in (then restored), so it describes the drag as it already worked.
  • e2e/avatar-2d.e2e.ts: the harness does what the stage does, handing the renderer the sprite setup and resolving pictures from the sprite list, because the renderer no longer fetches sprites. mountPanel can now close a panel. No assertion changed.
  • e2e/avatar-setup.e2e.ts: the 2D setup test also checks that both generation pickers list the faces without neutral_talk and happy_talk. The Arrange test drags a full-body sprite and an avatar. It checks Release to Save while dragging, the drop position in stage percentages, the sprite's check button ending Arrange mode for both, and both positions after a reload.
  • Local CodeRabbit (coderabbit review --agent --committed --base-commit 1cd98bc16) on 1b98bc630: review completed, 0 findings. The earlier run on f91c9ad25 also had 0 findings; the review findings fixed here came from a separate code review.

Manual verification notes

On staging, with the 2D Avatars and 3D Avatars agents installed through Download Agents:

  • Frame rate (phone or a narrow window): open a Roleplay group chat with two characters whose sprites include _talk pictures and add 2D Avatars. While one character's reply streams, only that avatar moves at full smoothness; the other keeps breathing and blinking. The speaking avatar looks as smooth as before. After several replies, the quiet avatars look the same as before the first one.
  • Arrange mode: open Chat Settings → Agents → Expression Engine → Sprite Layout → Arrange. Drag a full-body sprite and an avatar. Each shows Release to Save while dragging and stays where it was dropped. Press the check button above either one: Arrange mode ends. Reload: both keep their places.
  • 2D setup page: on Agents → 2D Avatars, pick a character with happy and happy_talk sprites. Under Make an avatar from a sprite, neither picker lists happy talk. Press Use my sprites, change a face, import a PNGTuber Plus .save, then Remove: each change shows at once.
  • 3D setup page: import a .vrm, change a face binding, add and remove a .vrma, then Remove: each shows at once with its toast. Then pick a large .vrm and switch Character or persona before it finishes: its toast still appears. In a chat, the VRM blinks every few seconds.
  • Mesh avatar fallback: with a mesh avatar that cannot draw (for example a browser without WebGL2), the chat shows the character's sprites instead.

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)

UI evidence (if applicable)

No visual change: the Arrange controls, setup panels and pickers look as before, minus the talk and blink sprites in the generation pickers.

Summary by CodeRabbit

  • Improvements
    • Avatar and sprite placement can be adjusted together in Arrange mode, and their positions persist after reload.
    • Sprite choices exclude talk and blink variants where they aren’t applicable.
    • Avatar rendering is paced per avatar, with adjustments for phone performance.
    • VRM avatars blink at consistent 3–6 second intervals.
    • Mesh and sprite-backed avatars render across more setups, with fallback sprites when WebGL2 is unavailable.
  • Bug Fixes
    • Closing avatar setup during an import no longer hides a subsequent import error.

🔄 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/7581 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/avatars-reuse-polish` --- ### 📝 Commits (7) - [`74c6ad6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/74c6ad6401877f706cd37b57277c1b838eac8c26) fix(avatars): per-avatar frame rate, one shared drag, and one copy of each avatar helper - [`c0347d8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c0347d823f97c0757f31205aac119c501e687a40) test(avatars): open the Agents section before Arrange in the drag e2e - [`f91c9ad`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f91c9ad2580229dcda9cbc0f3223a72cec003573) test(avatars): keep the setup page from opening itself in the saved-chat page - [`3f0a1f0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3f0a1f092126103751fa5960b405ddae31a166e4) fix(avatars): count a phone's load per avatar so idle avatars stay at 15 - [`189cb41`](https://github.com/Pasta-Devs/Marinara-Engine/commit/189cb414ebd4f8c4c2062ec2956ddd13543600bf) fix(avatars): keep the VRM panel's toasts when it closes mid-request - [`1b98bc6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1b98bc630cede0a50361c02f40d3bbfc0bdadf5b) docs(avatars): say mesh avatars keep the runtime's own blinking - [`28ec82a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/28ec82afd35292f7de4eb7a5160a0bcef3cf5b00) Merge remote-tracking branch 'origin/staging' into HEAD ### 📊 Changes **26 files changed** (+646 additions, -424 deletions) <details> <summary>View changed files</summary> 📝 `e2e/avatar-2d.e2e.ts` (+73 -14) 📝 `e2e/avatar-setup.e2e.ts` (+123 -2) 📝 `packages/client/src/components/chat/SpriteOverlay.tsx` (+8 -76) ➕ `packages/client/src/components/chat/use-sprite-placement-drag.ts` (+92 -0) 📝 `packages/client/src/features/avatars/generation/AvatarGenerationPanel.tsx` (+4 -1) 📝 `packages/client/src/features/avatars/generation/PngtuberVariantsSection.tsx` (+2 -5) 📝 `packages/client/src/features/avatars/generation/use-avatar-generation.ts` (+6 -15) 📝 `packages/client/src/features/avatars/renderers/mesh-avatar/MeshAvatarSetupPanel.tsx` (+12 -9) 📝 `packages/client/src/features/avatars/renderers/pngtuber/PngtuberSetupPanel.tsx` (+16 -11) 📝 `packages/client/src/features/avatars/renderers/pngtuber/pngtuber-layers.ts` (+7 -24) 📝 `packages/client/src/features/avatars/renderers/pngtuber/pngtuber-renderer.ts` (+11 -30) ➖ `packages/client/src/features/avatars/renderers/pngtuber/use-avatar-kind-actions.ts` (+0 -39) 📝 `packages/client/src/features/avatars/renderers/vrm/VrmSetupPanel.tsx` (+33 -51) 📝 `packages/client/src/features/avatars/renderers/vrm/vrm-motion.ts` (+10 -4) 📝 `packages/client/src/features/avatars/setup/AvatarAgentSetup.tsx` (+3 -3) 📝 `packages/client/src/features/avatars/setup/AvatarSetupPreview.tsx` (+8 -5) 📝 `packages/client/src/features/avatars/setup/demo-avatar.ts` (+1 -1) 📝 `packages/client/src/features/avatars/stage/AvatarStage.tsx` (+29 -111) 📝 `packages/client/src/features/avatars/stage/avatar-stage-logic.ts` (+39 -0) 📝 `packages/client/src/hooks/use-avatar-models.ts` (+58 -6) _...and 6 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`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Refs #7537 (epic: 2D and 3D avatar agents). This is the polish and reuse lane, branched from `staging` after the live-faces lane (#7555) and the generation lane (#7554) merged. ## Why this change - **Phones spent the talking frame rate on every avatar.** The stage's one loop picked a single rate for all avatars. While any avatar talked, the quiet one next to it also drew at 30 fps instead of the idle 20 (15 under load). The budget says only the speaking avatar draws at the talking rate. - **Two copies of the Arrange drag.** The sprites' drag was inline in `SpriteOverlay.tsx`, and the avatar stage had its own `usePlacementDrag`. The avatars must use the sprites' drag code, and two copies drift apart. - **Three copies of save, import and remove.** `useUpdateAvatarModel` in `hooks/use-avatar-models.ts`, the 2D lane's `use-avatar-kind-actions.ts` and the VRM panel's inline mutations each refreshed the avatar queries in their own way. Kept generation results had a fourth refresh. - **Two picture resolvers, and a sprite list fetched twice.** `resolveAvatarImage` (stage) and `resolvePngtuberImage` (2D lane) did the same job. The PNGTuber renderer fetched `/api/sprites` again although the stage already holds the list, and a mesh avatar's sprite fallback fetched it once more. - **Two default blink rates.** PNGTuber blinks every 4.5 s on average (3 to 6 s), defined three times (client, server import, server generation). VRM blinked every 2 to 6 s (4 s on average). - **Generation offered talk and blink pictures as sources.** **Make an avatar from a sprite** listed `happy_talk` and `happy_blink` next to the faces, which would make a blink picture of a talk picture. ## What changed - **Frame rate:** the stage keeps one frame loop and gives each avatar its own clock. The speaking avatar draws at the talking rate (30). Every other avatar draws at the idle rate (phones 20, or 15 under load; desktops 30). Hidden, off-screen, covered and paused stages still draw nothing, and reduced motion is unchanged. `avatarDrawDue` in `avatar-stage-logic.ts` is the rule. - **Phone load:** each avatar keeps its own average draw time, and a phone is under load when one draw of every avatar takes more than 12 ms (`avatarsUnderLoad`). The first version averaged the cost per drawing tick. Once a speaker's clock drifted out of phase with the quiet one, each tick held only one avatar, so a loaded phone stopped counting as loaded after the first line and went back to 20 fps. The stage and the setup preview also share one phone query (`AVATAR_PHONE_QUERY`) instead of two copies. - **Arrange mode:** one drag hook, `components/chat/use-sprite-placement-drag.ts`, extracted from the sprite's inline code. Full-body sprites and avatars both use it. The gesture is unchanged: drag in percentages of the stage, **Release to Save**, the check button saves and ends Arrange mode, and leaving Arrange mode mid-drag drops the drag. - **Save, import and remove:** `useAvatarModelActions` in `hooks/use-avatar-models.ts` is the one place. The owner switches, the PNGTuber, mesh and VRM panels all use it, and kept generation results refresh through the same helper (`useAvatarModelChanged`). `use-avatar-kind-actions.ts` and the VRM panel's inline copies are deleted. After a save, an import or a removal, the setup page now shows the server's reply at once and then refreshes. Before, the 2D panels and the owner switches waited for a refetch. The VRM panel gives its toasts to the hook (as it did on staging), not to `mutate()`, so a rejected import still says so after the user switches owner or leaves the page. - **Pictures:** `resolveAvatarImage` is the one resolver, and `resolvePngtuberImage` is deleted. The PNGTuber renderer no longer fetches `/api/sprites`. The stage and the setup preview hand it the setup and the sprite list they already have, including to mesh avatars for their sprite fallback. A mesh avatar now waits for that list before it mounts, instead of mounting and then mounting again when the list arrives. Face thumbnails in the PNGTuber panel now load stored pictures with the save time attached, so a replaced picture shows fresh. - **Blinking:** `PNGTUBER_DEFAULT_MOTION` lives once in `@marinara-engine/shared` (4.5 s average). The client, the server's `.save` importer and the server's generation use it. VRM models now blink at the same rate: every 3 to 6 seconds instead of every 2 to 6. Mesh avatars still use the mesh-avatar runtime's own blinking (about every 2 to 6 seconds, sometimes twice), and the comments now say so. - **Generation:** **Make an avatar from a sprite** no longer offers `_talk` and `_blink` pictures (or their other spellings) as the source. The variants section reuses `pngtuberSpriteFamily` instead of its own copy. - **Tests:** `e2e/avatar-setup.e2e.ts` failed about one run in six on staging too (1 of 6 repeats there). The 2D Avatars page, still open in the same browser context, kept saving its UI state (the open agent page) to the shared local storage while the saved-chat page started, so that page sometimes opened the agent editor instead of the chat. The agent page now leaves first, and each page answers the synced UI settings itself. Not changed, for the maintainer: - `docs/agents/avatars.md` already lists the talking and idle rates per avatar, so I left the guide alone. Step 1 of **Blink and talk pictures** could say that talk and blink sprites are not offered; I did not add that, to avoid a `docs-i18n` follow-up for one sentence. - The server's `spriteBuiltPngtuber` in `services/avatars/generation/pngtuber-variants.ts` is still a copy of the client's `buildPngtuberLayersFromSprites` (it carries a `ponytail:` note saying so). Moving one copy into `@marinara-engine/shared` is a follow-up. - Some near-copies remain, on purpose: `errorMessage` exists in four files with two different contracts (the raw message, or a translated fallback), and merging them would change what some toasts say. `SpriteLike` (`url` optional, for building faces) and `AvatarSpriteRef` (`url` required, for resolving pictures) describe different inputs. - The PNGTuber and mesh panels still pass their toasts to `mutate()`, as they already did on staging, so their toasts can be lost the same way if the panel closes mid-request. The hook now takes hook-level feedback, so moving them is a small follow-up. - Face thumbnails in the PNGTuber panel carry the save time (`?v=`), so they refetch after each save. That is what lets a regenerated picture at the same path show fresh, and the browser keeps the old picture until the new one has loaded. - The open questions already with Mari are untouched: the "Calm" vs "Neutral" label, whether a persona's mouth moves for the user's own messages, and the chat-chrome 64% accent text. ## 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 (the boxes above are for the human reviewer). Tested revision: `1b98bc630` unless noted. - `pnpm install --frozen-lockfile --prefer-offline --store-dir <main checkout>/.pnpm-store`, `pnpm build:shared`: done. No dependency or lockfile change. - `pnpm check`: passed (exit 0). The only ESLint warning is the existing one in `HomeProfessorMariChat.tsx`. `pnpm localization:check` (part of it): passed; no English key changed. - `node scripts/run-regressions.mjs --filter avatar`: 14/14 passed. Checks this PR adds: - `avatar-stage-logic`: one simulated 60 Hz loop with a speaking and a quiet avatar draws 30/20 per second on a phone, 30/15 under load and 30/30 on a desktop, and the stage's loop asks each avatar's own clock. A second simulation runs two avatars that take 8 ms each to draw on a phone through a 3 s line: both idle at 15 before, the quiet one stays at 15 during the line, and both stay at 15 for 6 s after it; avatars that take 5 ms idle at 20. With the earlier per-tick average swapped into the same simulation, both avatars went back to 20 after the line, so this check catches it. - `avatar-vrm`: VRM blinks are 3, 4.5 and 6 s apart for the lowest, middle and highest random draw. - `avatar-2d-renderers`: `_talk` and `_blink` sprites are never a source. Its three `resolvePngtuberImage` checks now run against `resolveAvatarImage` with the same expectations (a stored file now carries `?v=<save time>`), plus a full-body-only case. - Guards: `--filter agent-activation` (2/2), `--filter spatial-context` (1/1), `--filter open-issues` (1/1): passed. - Browser, on ports of its own (`PLAYWRIGHT_*_PORT` 5412/8012/5413/8013): - Desktop Chromium: `e2e/avatar-2d.e2e.ts`, `e2e/avatar-setup.e2e.ts`, `e2e/avatar-preview.e2e.ts`, `e2e/expression-active-sprites.e2e.ts`: 16/16 passed. - Mobile Chromium and mobile WebKit: `e2e/avatar-2d.e2e.ts` and `e2e/avatar-setup.e2e.ts`: 24/24 passed. - New `e2e/avatar-2d.e2e.ts` test "the VRM setup still reports a rejected import after the panel closes": picks a `.vrm`, closes the panel while the upload waits, then the server rejects it; the error toast must show. It passed 3/3, and failed with `f91c9ad25`'s `VrmSetupPanel.tsx` swapped in (then restored). - Phone load, temporary Playwright probe (deleted afterwards), mobile Chromium: two PNGTuber avatars in a Roleplay chat, each draw slowed by 8 ms, a quoted line streamed for one of them through the chat store. With this branch, 4 of 4 runs: 15/15 before the line, the quiet avatar at 15 during it, and both at 14-15 in the two 3 s windows from 3 to 9 s after it. With `f91c9ad25`'s `AvatarStage.tsx` swapped in: the quiet avatar at 16-19 during the line and, in one of two runs, 19-20/19 after it. - Earlier commits (`74c6ad640` to `f91c9ad25`): `avatar-setup.e2e.ts --repeat-each=8` 16/16 on desktop Chromium. The Arrange test also passed with staging's own `SpriteOverlay.tsx` and `AvatarStage.tsx` swapped in (then restored), so it describes the drag as it already worked. - `e2e/avatar-2d.e2e.ts`: the harness does what the stage does, handing the renderer the sprite setup and resolving pictures from the sprite list, because the renderer no longer fetches sprites. `mountPanel` can now close a panel. No assertion changed. - `e2e/avatar-setup.e2e.ts`: the 2D setup test also checks that both generation pickers list the faces without `neutral_talk` and `happy_talk`. The Arrange test drags a full-body sprite and an avatar. It checks **Release to Save** while dragging, the drop position in stage percentages, the sprite's check button ending Arrange mode for both, and both positions after a reload. - Local CodeRabbit (`coderabbit review --agent --committed --base-commit 1cd98bc16`) on `1b98bc630`: review completed, 0 findings. The earlier run on `f91c9ad25` also had 0 findings; the review findings fixed here came from a separate code review. ### Manual verification notes On staging, with the 2D Avatars and 3D Avatars agents installed through **Download Agents**: - **Frame rate (phone or a narrow window):** open a Roleplay group chat with two characters whose sprites include `_talk` pictures and add 2D Avatars. While one character's reply streams, only that avatar moves at full smoothness; the other keeps breathing and blinking. The speaking avatar looks as smooth as before. After several replies, the quiet avatars look the same as before the first one. - **Arrange mode:** open **Chat Settings → Agents → Expression Engine → Sprite Layout → Arrange**. Drag a full-body sprite and an avatar. Each shows **Release to Save** while dragging and stays where it was dropped. Press the check button above either one: Arrange mode ends. Reload: both keep their places. - **2D setup page:** on **Agents → 2D Avatars**, pick a character with `happy` and `happy_talk` sprites. Under **Make an avatar from a sprite**, neither picker lists `happy talk`. Press **Use my sprites**, change a face, import a PNGTuber Plus `.save`, then **Remove**: each change shows at once. - **3D setup page:** import a `.vrm`, change a face binding, add and remove a `.vrma`, then **Remove**: each shows at once with its toast. Then pick a large `.vrm` and switch **Character or persona** before it finishes: its toast still appears. In a chat, the VRM blinks every few seconds. - **Mesh avatar fallback:** with a mesh avatar that cannot draw (for example a browser without WebGL2), the chat shows the character's sprites instead. ## 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) ## UI evidence (if applicable) No visual change: the Arrange controls, setup panels and pickers look as before, minus the talk and blink sprites in the generation pickers. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Improvements** * Avatar and sprite placement can be adjusted together in Arrange mode, and their positions persist after reload. * Sprite choices exclude talk and blink variants where they aren’t applicable. * Avatar rendering is paced per avatar, with adjustments for phone performance. * VRM avatars blink at consistent 3–6 second intervals. * Mesh and sprite-backed avatars render across more setups, with fallback sprites when WebGL2 is unavailable. * **Bug Fixes** * Closing avatar setup during an import no longer hides a subsequent import error. <!-- 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:07:43 +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#7812
No description provided.