mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7581] [MERGED] fix(avatars): per-avatar frame rate, one shared drag, and shared save, picture and blink helpers #7812
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#7812
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 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)
74c6ad6fix(avatars): per-avatar frame rate, one shared drag, and one copy of each avatar helperc0347d8test(avatars): open the Agents section before Arrange in the drag e2ef91c9adtest(avatars): keep the setup page from opening itself in the saved-chat page3f0a1f0fix(avatars): count a phone's load per avatar so idle avatars stay at 15189cb41fix(avatars): keep the VRM panel's toasts when it closes mid-request1b98bc6docs(avatars): say mesh avatars keep the runtime's own blinking28ec82aMerge 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
Linked issue
Refs #7537 (epic: 2D and 3D avatar agents). This is the polish and reuse lane, branched from
stagingafter the live-faces lane (#7555) and the generation lane (#7554) merged.Why this change
SpriteOverlay.tsx, and the avatar stage had its ownusePlacementDrag. The avatars must use the sprites' drag code, and two copies drift apart.useUpdateAvatarModelinhooks/use-avatar-models.ts, the 2D lane'suse-avatar-kind-actions.tsand the VRM panel's inline mutations each refreshed the avatar queries in their own way. Kept generation results had a fourth refresh.resolveAvatarImage(stage) andresolvePngtuberImage(2D lane) did the same job. The PNGTuber renderer fetched/api/spritesagain although the stage already holds the list, and a mesh avatar's sprite fallback fetched it once more.happy_talkandhappy_blinknext to the faces, which would make a blink picture of a talk picture.What changed
avatarDrawDueinavatar-stage-logic.tsis the rule.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.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.useAvatarModelActionsinhooks/use-avatar-models.tsis 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.tsand 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 tomutate(), so a rejected import still says so after the user switches owner or leaves the page.resolveAvatarImageis the one resolver, andresolvePngtuberImageis 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.PNGTUBER_DEFAULT_MOTIONlives once in@marinara-engine/shared(4.5 s average). The client, the server's.saveimporter 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._talkand_blinkpictures (or their other spellings) as the source. The variants section reusespngtuberSpriteFamilyinstead of its own copy.e2e/avatar-setup.e2e.tsfailed 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.mdalready 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 adocs-i18nfollow-up for one sentence.spriteBuiltPngtuberinservices/avatars/generation/pngtuber-variants.tsis still a copy of the client'sbuildPngtuberLayersFromSprites(it carries aponytail:note saying so). Moving one copy into@marinara-engine/sharedis a follow-up.errorMessageexists in four files with two different contracts (the raw message, or a translated fallback), and merging them would change what some toasts say.SpriteLike(urloptional, for building faces) andAvatarSpriteRef(urlrequired, for resolving pictures) describe different inputs.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.?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.Validation
pnpm checkpasses locallyCONTRIBUTING.mdCommands run by the agent (the boxes above are for the human reviewer). Tested revision:
1b98bc630unless 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 inHomeProfessorMariChat.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:_talkand_blinksprites are never a source. Its threeresolvePngtuberImagechecks now run againstresolveAvatarImagewith the same expectations (a stored file now carries?v=<save time>), plus a full-body-only case.--filter agent-activation(2/2),--filter spatial-context(1/1),--filter open-issues(1/1): passed.PLAYWRIGHT_*_PORT5412/8012/5413/8013):e2e/avatar-2d.e2e.ts,e2e/avatar-setup.e2e.ts,e2e/avatar-preview.e2e.ts,e2e/expression-active-sprites.e2e.ts: 16/16 passed.e2e/avatar-2d.e2e.tsande2e/avatar-setup.e2e.ts: 24/24 passed.e2e/avatar-2d.e2e.tstest "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 withf91c9ad25'sVrmSetupPanel.tsxswapped in (then restored).f91c9ad25'sAvatarStage.tsxswapped in: the quiet avatar at 16-19 during the line and, in one of two runs, 19-20/19 after it.74c6ad640tof91c9ad25):avatar-setup.e2e.ts --repeat-each=816/16 on desktop Chromium. The Arrange test also passed with staging's ownSpriteOverlay.tsxandAvatarStage.tsxswapped 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.mountPanelcan 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 withoutneutral_talkandhappy_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.coderabbit review --agent --committed --base-commit 1cd98bc16) on1b98bc630: review completed, 0 findings. The earlier run onf91c9ad25also 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:
_talkpictures 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.happyandhappy_talksprites. Under Make an avatar from a sprite, neither picker listshappy talk. Press Use my sprites, change a face, import a PNGTuber Plus.save, then Remove: each change shows at once..vrm, change a face binding, add and remove a.vrma, then Remove: each shows at once with its toast. Then pick a large.vrmand switch Character or persona before it finishes: its toast still appears. In a chat, the VRM blinks every few seconds.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)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
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.