mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7556] [MERGED] feat(avatars): storage, import, setup and chat stage for the avatar agents #7795
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#7795
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/7556
Author: @SpicyMarinara
Created: 10/13/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @SpicyMarinara
Base:
staging← Head:feat/avatars-base📝 Commits (9)
82c6bbafeat(avatars): storage, import, serving, setup and stage for the avatar agentsd2eba01fix(avatars): keep a dragged avatar steady and mount PNGTuber avatars when sprites fail to load5fe461atest(avatars): browser check of the avatar setup and the chat stageb082633fix(avatars): show code scanning the model file containment and the routes' rate limit43427acMerge remote-tracking branch 'origin/feat/avatars-contract' into feat/avatars-base298d994fix(avatars): open the import picker in the same tap and free a renderer that fails to mountb94c3bafix(avatars): keep stored avatars intact on refused saves and pause covered chats701afe7fix(avatars): clear the import picker when it returns without a file2b417feMerge branch 'staging' into avatar lane📊 Changes
31 files changed (+3412 additions, -66 deletions)
View changed files
📝
docs/agents/avatars.md(+25 -2)➕
e2e/avatar-setup.e2e.ts(+156 -0)➕
packages/client/public/sprites/avatar-demo/README.md(+8 -0)➕
packages/client/public/sprites/avatar-demo/base.png(+0 -0)➕
packages/client/public/sprites/avatar-demo/eyes-closed-mouth-open.png(+0 -0)➕
packages/client/public/sprites/avatar-demo/eyes-closed.png(+0 -0)➕
packages/client/public/sprites/avatar-demo/mouth-open.png(+0 -0)📝
packages/client/src/components/agents/AgentEditor.tsx(+25 -1)📝
packages/client/src/components/chat/ChatRoleplaySurface.tsx(+32 -0)📝
packages/client/src/components/game/GameSurface.tsx(+27 -0)📝
packages/client/src/features/avatars/setup/AvatarAgentSetup.tsx(+527 -5)➕
packages/client/src/features/avatars/setup/AvatarSetupPreview.tsx(+149 -0)➕
packages/client/src/features/avatars/setup/avatar-setup-logic.ts(+101 -0)➕
packages/client/src/features/avatars/setup/demo-avatar.ts(+57 -0)📝
packages/client/src/features/avatars/stage/AvatarStage.tsx(+440 -8)➕
packages/client/src/features/avatars/stage/avatar-stage-logic.ts(+148 -0)➕
packages/client/src/features/avatars/stage/use-avatar-pause.ts(+54 -0)➕
packages/client/src/features/avatars/stage/use-avatar-renderer.ts(+109 -0)➕
packages/client/src/features/avatars/stage/use-chat-avatar-agents.ts(+21 -0)➕
packages/client/src/hooks/use-avatar-models.ts(+73 -0)...and 11 more files
📄 Description
Linked issue
Refs #7537 (epic: 2D and 3D avatar agents). This is the base lane; the epic stays open for the other lanes.
Depends on https://github.com/Pasta-Devs/Marinara-Engine/pull/7539 (opened ready, base staging, "feat(avatars): shared contract for the 2D and 3D avatar agents", Refs #7537). All 4 GitHub CodeRabbit threads on
15af58f10got replies and are resolved. Two were fixed indf538660f: Windows device names in stored paths, and the code comments now point at the developer notes. Two were answered: the docs-i18n issue is #7540, and the 1.73 bump stays, with a publish-order rule added to the developer notes. CI ondf538660fwas still running at hand-off, so mergeStateStatus was BLOCKED; on15af58f10every check had passed except complete-node-regressions, which was still pending. Not merged; no checkboxes ticked. (its commits show in this diff until it merges)Update: #7539 has merged into
staging, so the diff againststagingnow shows only this lane.Why this change
staging. Until the renderer lanes land, set-up avatars draw nothing (the renderer stubs are inert).What changed
.save, a mesh avatar.mavatar, a VRM model.vrmand a.vrmaidle animation. Faces shows which face each feeling (and, for models, each mouth shape and the blink) uses, marked Found, Your choice or Missing, with a menu to change it. Movement has the lip sync, blinking and idle-motion switches. Preview draws the avatar through its lazily loaded renderer with Try a face and Talk; before anything is set up it shows an example PNGTuber. Remove deletes one avatar type. The kind panels and the generation panel of the other lanes load below it. The section loads only on these two pages.DATA_DIR/avatar-models/<character|persona>/<id>/holdsavatar.json(validated against the shared schema on every write and read back only when valid) and each kind's files. Writes go through one queue per owner, and every path is checked to stay inside the owner's folder. A save is checked before any file is written, and all of its files are written before any stored file is replaced, so a refused import leaves the saved avatar as it was. Only files a write newly names must exist, so a file lost since it was saved (a skipped restore, a hand deletion) never blocks turning the avatar off, saving another kind or removing the broken kind; removing a kind writes the config before deleting that kind's files. Saving an import removes files of that kind the new data no longer names. Removing the last kind removes the folder./api/avatar-models: list, get,PUT(a partial update; files it names must exist), import (multipart; the file goes to the importer that recognises it, or to the importer of its extension so the person gets that importer's plain message, such as "VRM files can't be imported yet." while the stubs are in place), file serving (PNGTuber layers only as raster images;.mavataronly with ZIP bytes asapplication/zip;.vrm/.vrmaonly with glTF bytes asmodel/gltf-binary; symlinks may not leave the folder; ranges work), and removal of a kind or a whole avatar. Imports add no size limit below the global upload cap (256 MiB).avatar-models, and restored PNGTuber layers must be real images. Clearing Media & Assets in the Danger Zone empties the folder. Character card exports don't include avatars.docs/agents/avatars.md: "Setting up an avatar" (including where files live and backups) and "Performance and devices".packages/client/public/sprites/avatar-demo/(generated with Codex image generation; provenance in its README), fetched only by the setup preview and skipped by the service worker.scripts/regressions/avatar-contract.regression.tsasserted thatGET /api/avatar-modelsanswers 404 ("not served yet"). This lane serves it, so that one URL now asserts 200; the classify and generation routes keep their 404 check.AvatarStagePropsis unchanged: the stage takes its sprite-layout props through its ownAvatarStageLayoutinterface instage/AvatarStage.tsx.packages/client/vite.config.ts. WorkboxglobIgnoresnow also skips{pngtuber,mesh-avatar,vrm}-renderer-*.js,vendor-three*.jsandvendor-mesh-avatar*.js, so the service worker no longer downloads avatar renderer code for every PWA install; it loads only when an avatar is shown. The smallAvatarStage/AvatarAgentSetupchunks stay precached.Validation
pnpm checkpasses locallyCONTRIBUTING.mdCommands run by the agent (results as reported; boxes above are for the human reviewer):
pnpm install --frozen-lockfile --prefer-offline --store-dir <main checkout>/.pnpm-storeandpnpm build:shared: done (no dependency or lockfile change in this lane).pnpm checkon the final head: passed (impeccable, localization, Prettier, ESLint with the one existing warning inHomeProfessorMariChat.tsx, e2e and token-estimation types, full build).pnpm localization:checkon its own: passed.packages/client/dist(static-import walk from the entry inindex.html):AvatarAgentSetup15.7 KiB,AvatarStage8.1 KiB,avatar-stage-logic2.9 KiB,use-avatar-renderer2.8 KiB,use-chat-avatar-agents0.3 KiB and the renderer stubs are all lazy; none is reachable from the entry. No three, three-vrm or mesh-avatar chunk exists yet (the renderers are stubs).scripts/regressions/avatar-models.regression.ts(storage, routes, import dispatch with the stubs and with a working importer and a 12 MB upload, file serving and refusals, kind/owner removal, character and persona delete cascade, backup/restore coverage) andscripts/regressions/avatar-stage-logic.regression.ts(kind fallback, the 2/4 budget, fps and pixel-ratio caps, feature switches and reduced motion, PNGTuber picture lookup, "Use my sprites", participants and agent gating, lazy mounts). Both pass.node scripts/run-regressions.mjs --filterforavatar-(7 files incl. the contract regression),agent-activation,spatial-context,open-issues,admin-preset-expunge,automatic-backup,backup-download,backup-folder,capability-package-lifecycle,character-delete-chat-membership,profile-import,profile-apply,sprite-list-security,sprite-background,zip-reader: all passed.node scripts/run-regressions.mjslocally: 618/624. Not passed:termux-sharp(the known local-only store issue from #7539: offline install against this worktree's empty store) and five timing-sensitive files that timed out or missed a 1-second bound while the machine ran at load average ~30 with other lanes (advanced-memory-core,code-scanning-content-parsing,multiplayer-peer-server-security,native-export-memory,ruleset-combat-director); two of those passed on rerun, none touches code in this PR. CIcomplete-node-regressionspassed on the first push (82c6bba9f).npx playwright test e2e/avatar-setup.e2e.ts(own ports) passed on desktop Chromium (3 repeats), Android-sized Chromium and iPhone-sized WebKit. It mocks only the installed package and the sprite list; the avatar routes, storage and character delete are real.coderabbit review --agent --committed --base-commit df538660f, Pasta-Devs org): 0 findings.43427acf8: 4 threads, all replied to and resolved. Fixed in298d994da: the import picker now opens in the same tap (no frame callback; Safari keeps the click in the gesture), and a renderer whosemount()fails is disposed at once. Answered: personas do keep their sprites under the shared/api/sprites/:idroute (the persona editor uses it), so Use my sprites stays available for them. Thecharacters/personasexpunge scopes first stayed as they were, matching sprite folders; that changed inb94c3ba20(see the review round below), since those scopes already remove the deleted owners' profile pictures and an avatar folder can't be reached from the UI once its owner is gone. After the fixes: client typecheck, ESLint and Prettier clean; the e2e passed again on desktop Chromium and iPhone-sized WebKit.82c6bba9f: two alerts inavatar-models.routes.ts, both fixed inb082633d4.js/path-injection: the model file path was already contained byresolveAvatarFile; the route now repeats it as prefix checks CodeQL recognises, before and after resolving symlinks.js/missing-rate-limiting: every avatar-model route now declares the global default bucket (600 per minute, the limit that already applied).298d994da(b94c3ba20,701afe79e):characters/personasexpunge scopes remove their avatar folders (Professor Mari's stays); on phones the chat's avatars pause while a panel or editor covers the chat (it stays mounted underneath, so the setup preview no longer draws beside two hidden avatars); the setup preview idles at the budget rate (20 fps on phones); the Faces list links each menu to its Found / Your choice / Missing text (aria-describedby); the service worker skips avatar renderer chunks (contract file, above).config.featureswhen they mount (pngtuberblink, VRM copies the flags, mesh-avataridleMotion), re-imports keep their file names, andconfig.updatedAtis the?v=cache-buster for stored files, so the config object is the only signal that files changed. Avoiding the reload needs a contract addition (a renderer config update or a per-kind file revision); suggested as a follow-up on #7537.ChatSettingsDrawer/ExpressionSpriteSettings, outside this lane's files; Game chats can't arrange full-body sprites either (no placements are passed there). Avatars without it stand where the full-body sprite's default place is. Suggested as a follow-up on #7537.node scripts/run-regressions.mjs --filter scripts/regressions/avatar-models.regression.ts: passed. It now also covers a refused save keeping the stored bytes and leaving no temporary file, a deleted layer file not blockingPUT {enabled:false}, another kind's save and removal of both kinds, a character deleted during an import (404, no folder), and thecharacters+personasexpunge (folders gone, Professor Mari's kept). Against the previous server code it fails on the import race (200 instead of 404) and, with only the route fix applied, on the refused save changing the stored bytes.node scripts/run-regressions.mjs --filter avatar(7 files) and--filterforadmin-preset-expunge,admin-server-restart,request-timeouts,speech-to-text-server,shutdown-deadline,termux-postmortem,termux-client-build,backup(4 files): all passed.pnpm check: passed (exit 0; the one existing ESLint warning inHomeProfessorMariChat.tsx).pnpm localization:check: passed, no new keys.npx playwright test e2e/avatar-setup.e2e.ts e2e/avatar-preview.e2e.ts(own ports) on desktop Chromium, Android-sized Chromium and iPhone-sized WebKit:avatar-setuppassed on all three. It now opens the setup page over the active chat; on the phone projects it asserts the covered chat's stage is paused (data-avatar-paused="true"), and on every project that the uncovered chat's stage is not, plus the Faces descriptions. With the covered check disabled it fails on mobile Chromium as expected.avatar-preview's library-portraits test failed in that combined run but passed when run alone on desktop Chromium; it doesn't touch this lane's code.packages/client/dist/sw.js: the precache list no longer haspngtuber-renderer,mesh-avatar-rendererorvrm-renderer;AvatarStage(8 KB),AvatarAgentSetup(16 KB) anduse-avatar-renderer(3 KB) stay.coderabbit review --agent --committed --base-commit 1e9e58776, the merge base withorigin/staging): 2 findings. Fixed in701afe79e: the import input is cleared when the picker returns without a file. Not changed: the "Try a face" menu'stext-xscan't cause iOS focus zoom, becauseglobals.csssetsinput, select, textarea { font-size: 1rem }under@media (pointer: coarse)outside any cascade layer, which overrides Tailwind's layered utilities (the same rule covers every menu in the app). Not rerun after the one-line fix.Manual verification notes
The renderers are stubs until the 2D and 3D lanes land, so avatars and the preview draw nothing yet except where noted. To test before the packages are published, install a local build of the 2D Avatars or 3D Avatars package (or add
2d-avatarsto a chat's agents with a package that declares that id)..vrm: the message "VRM files can't be imported yet." appears (until the 3D lane lands). Pick a.txtrenamed to.saveon the 2D page: "PNGTuber Plus files can't be imported yet."data/avatar-models/character/<id>/.AvatarStage,vendor-three*orvendor-mesh-avatarfile is requested. Add 2D Avatars to the chat's agents: only theAvatarStagechunk (and, once a renderer lane lands, that renderer's chunk) loads.[data-avatar-stage]). Turn on Arrange in the Expression Engine's sprite settings: each avatar shows a check button and can be dragged; the place stays after reload.data/avatar-models/character/<id>/folder is gone. Download a backup: the zip containsavatar-models/.pngtuber/*.pngby hand, then toggle Show this avatar in chats, remove the VRM type and remove the PNGTuber type: each works, and the folder is gone at the end.data/avatar-models/character/*(except Professor Mari's) anddata/avatar-models/persona/*folders are gone; Media & Assets still empties the whole folder.[data-avatar-stage]under the covered chat carriesdata-avatar-paused="true"and only the setup preview animates; closing the panel resumes the chat avatars.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)docs/agents/avatars.mdchanged; its translation is tracked in #7540, which already covers this guide.docs/data/where-data-is-stored.mddoes not listavatar-modelsyet (outside this lane's files); a follow-up can add the row.UI evidence (if applicable)
None yet: the renderers are stubs, so there is nothing to capture beyond the setup form.
🤖 Generated with Claude Code
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.