[PR #7554] [MERGED] feat(avatars): make an avatar from a sprite (PNGTuber variants and mesh avatars) #7793

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

📋 Pull Request Information

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

Base: staging ← Head: feat/avatars-generation


📝 Commits (10+)

  • a60776a feat(avatars): make PNGTuber variants and a mesh avatar from a sprite
  • a4ba56a feat(avatars): generation panel for the 2D Avatars agent page
  • 4eaef30 fix(avatars): faster layer builder, fuller eye outline, one start per click
  • 9324400 fix(avatars): keep the compiled negative prompt when a reviewed prompt leaves it out
  • a606d44 fix(avatars): refuse mesh generation before any model call when .mavatar can't be kept
  • cbe06c1 fix(avatars): show a failed retry instead of the old picture; plainer guide
  • be7d471 Merge branch 'staging' into feat/avatars-generation
  • 5e1f172 fix(avatars): keep generation responsive, lined up and from losing faces
  • 79b0e7d fix(avatars): ask GPT Image 2 for a canvas size it keeps
  • 7b1c7b6 fix(avatars): log a cancelled generation as a cancellation

📊 Changes

14 files changed (+4006 additions, -37 deletions)

View changed files

📝 docs/agents/avatars.md (+21 -1)
📝 packages/client/src/features/avatars/generation/AvatarGenerationPanel.tsx (+142 -5)
➕ packages/client/src/features/avatars/generation/MeshAvatarSection.tsx (+171 -0)
➕ packages/client/src/features/avatars/generation/PngtuberVariantsSection.tsx (+277 -0)
➕ packages/client/src/features/avatars/generation/SpritePicker.tsx (+56 -0)
➕ packages/client/src/features/avatars/generation/use-avatar-generation.ts (+286 -0)
📝 packages/client/src/localization/locales/en.json (+44 -0)
📝 packages/server/src/routes/avatar-generation.routes.ts (+133 -10)
➕ packages/server/src/services/avatars/generation/generation-context.ts (+483 -0)
➕ packages/server/src/services/avatars/generation/mesh-layer-builder.ts (+571 -0)
➕ packages/server/src/services/avatars/generation/mesh-rig-layout.ts (+412 -0)
📝 packages/server/src/services/avatars/generation/mesh-rig.ts (+298 -10)
📝 packages/server/src/services/avatars/generation/pngtuber-variants.ts (+476 -11)
➕ scripts/regressions/avatar-generation.regression.ts (+636 -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

Refs #7537 (generation lane of the avatar agents epic)

Built on the avatar contract, #7539, which is now merged into staging. This branch has staging merged in, so the diff shows only this lane. Saving and the panel itself still need the base lane (#7556, storage and the setup page). Mesh avatars also need the 2D lane (#7549, the .mavatar importer).

Why this change

  • Making a 2D avatar by hand means drawing a blink picture and a talk picture for every expression, or rigging a mesh avatar in a separate tool. Most users already have expression sprites, so the 2D Avatars agent should turn them into an avatar in one click.
  • The user has to stay in control of what gets stored: image models redraw more than they are asked to, so every result is shown first and nothing replaces the current avatar until the user keeps it.

What changed

  • On the 2D Avatars agent page, Make an avatar from a sprite (the AvatarGenerationPanel the base lane's setup mounts through AVATAR_GENERATION_PANEL; it is inert until that PR lands):
    • Blink and talk pictures
      • Pick sprites, Eyes closed and/or Mouth open, and an image connection. When portrait sprites exist, only portraits are offered, because the PNGTuber avatar never mixes portrait and full-body faces. The server refuses a full-body label before any picture is paid for.
      • Pictures are made one at a time through the existing image generation path: the same provider routing, fallback connection, style settings and payload debug logging as sprite generation.
      • The sprite is sent as the reference picture, already placed (scaled, never stretched) on a canvas of the size the model is asked for. The sprite's own area is then cut back out of the answer. An edit that keeps the picture in place therefore lines up with the sprite, even when the model only takes fixed sizes (GPT Image 1) or the request is rounded. Custom-size GPT Image models get a canvas size their size rules keep.
      • No see-through background is requested, because GPT Image 2 has none. A cut-out sprite gets its own outline back.
      • Each picture gets Keep / Try again, and Cancel stops the one being made. Pictures already made stay: Make pictures only makes the missing ones, a failed Try again keeps the old picture and shows the error under it, and a kept picture has no Try again until the user lets it go.
      • Save kept pictures stores them as PNGTuber layers, each next to a copy of its source sprite, so base and variants always line up. A sprite replaced since its pictures were made is refused (409), checked by file hash before anything is written.
      • Files are written first, and the setup is merged inside the owner's storage queue (updateAvatarConfig). A change saved in the meantime (another tab, an import) is therefore kept.
      • An avatar still showing the owner's plain sprites keeps all of them: the save starts from the same sprite-built setup the 2D renderer shows. The result becomes a generated setup, so Update from sprites can't wipe the new pictures. Existing bindings and motion stay, and a set drawn for a different base picture is replaced rather than mixed.
    • Mesh avatar
      • Pick one sprite and a chat connection that can see pictures (default: the agent's connection, then the default agent connection).
      • The vision model answers with a box-and-point face layout (head, face, eyes, brows, nose, mouth corners, neck) on a gridded copy of the sprite. The answer is parsed strictly and checked against the picture and against itself. Eyes too big for the face are refused. When an answer can't be used, the model is asked once more with the reasons.
      • A JavaScript port of mesh-avatar-studio's layer builder (MIT) on sharp, with no Python, OpenCV or GPU, cuts each eye into ball, lash, lower-lid and crease layers and fills the skin behind them.
      • The builder works in 25 ms slices, so chat streaming and other requests keep running, and Cancel stops it. Very big eyes are built from a smaller copy of the sprite, which keeps one build to a few seconds of work.
      • The avatar blinks and talks with mesh-avatar's own eyelids and mouth. No drawn sprites are written: mesh-avatar 0.1.1 treats any sprites.json as the full set (half-closed and smiling eyes, four mouth shapes) and switches its own lids and mouth off.
      • The .mavatar is checked with the 2D importer before it is offered. The user sees the sprite with the found face parts drawn on it, and Save as mesh avatar checks the archive again, like any upload, before storing it.
    • Nothing is stored until the user saves. Expose media prompts before sending is honoured for every image prompt. One generation job per avatar runs at a time (server guard plus a client guard against fast double clicks), and closing the request cancels the provider calls.
  • Prompts come from the 2D Avatars package's avatarGenerationTemplates (ids in AVATAR_PROMPT_TEMPLATE_IDS). The Engine keeps one-sentence fallbacks only for a package that ships no template. Card text (name, appearance) reaches a prompt only as one capped line inside a template variable, the vision call adds a fixed line that the description is never an instruction, and the model's answer can only become a layout that passes the checks. Every prompt is logged with logDebugOverride (debug mode or DEBUG_AGENTS), the vision messages with the picture redacted.
  • Until the 2D importer can read .mavatar files, Make mesh avatar is refused with 503 before any model call, so no paid request is wasted.
  • Lane-local API (/api/avatar-generation, documented in the route header): POST /pngtuber-variants/preview, POST /pngtuber-variants (drafts), POST /pngtuber-variants/save, POST /mesh-rig (draft), POST /mesh-rig/save. The contract request types and schemas are reused unchanged. promptOverrides, the drafts' sourceHash and the draft/save bodies are lane-local, like the sprite routes' own body types. A closed request aborts with an AbortError, so a cancelled job is logged as a cancellation. No contract file is edited.
  • UI copy under avatars.generation.* in en.json; docs/agents/avatars.md gets its "Making an avatar from a sprite" section (translation follow-up: #7540).

Design notes for reviewers

  • Generate returns drafts and save stores them, because the epic asks for per-picture approval and for the old avatar to stay until approval. Drafts live in the browser; the save routes re-validate everything they get back (pictures are decoded, re-encoded and must match the sprite's size; archives go through the 2D importer), so a draft is never trusted more than an upload.
  • The vision model gives boxes and points, not the 14-20 point eye outlines the Studio asks a person or coding agent to trace; vision models place boxes far more reliably. The eye outline is a full almond in the eye box (ponytail: comment names the ceiling: refine from eye-white pixels).
  • Skin behind the eyes is filled with a membrane solve (the Studio's fill_skin), not model inpainting: the existing image path has no edit mask. ponytail: comment names the ceiling (flat shading under the lids; upgrade: masked inpainting once the image path accepts a mask). Hands, hanging accessories, buns and hair strands are not rigged; the hair moves with the head.
  • The server copy of the 2D renderer's sprite-to-layers rule (spriteBuiltPngtuber) carries a ponytail: comment: the two must change together until one copy moves into @marinara-engine/shared with a contract PR. A second ponytail: comment covers pictures of a replaced imported set. They stay on disk until the next PNGTuber import or removal tidies the folder, because storage has no queued tidy call for generation to use.

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 on this branch (not a substitute for the boxes above):

  • pnpm check on 79b0e7d2b: passed (exit 0). The last commit, 7b1c7b698, only changes an abort reason, one docs sentence and the regression's fake server.
    • After the last commit, server tsc --noEmit, Prettier and the regression were re-run and pass.
    • The client files are unchanged since that pnpm check run.
  • node scripts/run-regressions.mjs --filter avatar-: 7/7 passed, including the reworked avatar-generation regression and the contract's avatar-contract.
  • pnpm localization:check: passed. Two avatars.generation.drawVariants* keys were removed with the mesh drawing option.
  • The new checks fail on the code they guard against: run with the old edit path (unpadded reference, stretched back), the alignment check fails (dot at x=199.5 ends up at x=174.9 on a 600x720 sprite). The old builder had no cancel signal, the old layout check accepted half-picture eyes, and the old save schema has no sourceHash.
  • Local probes (not committed). Main-thread CPU time between event-loop turns, measured with process.threadCpuUsage, because the machine was heavily loaded:
    • A 2040x2448 bust: the longest stretch went from 808 ms to 128-156 ms, with the same total CPU.
    • The reviewer's half-picture eye layout is now refused. The largest layout the check still allows builds from a 0.35x copy in 3.1 s of sliced CPU, with a longest stretch of 175 ms.
  • Local probe against the base lane's real storage.ts (swapped in, then restored):
    • A first save into a sprite-only avatar keeps neutral/happy/sad/angry, and happy_talk stays happy's mouth-open picture.
    • A motion change saved during a second save survives.
    • A replaced sprite is refused.
  • Reviews:
    • The earlier GitHub threads are all resolved (4 CodeRabbit, 2 CodeQL). Nothing new was unresolved before this push.
    • Local CodeRabbit (--committed, base 797877c54) on 79b0e7d2b raised 3 findings, all fixed in 7b1c7b698: the fake server's size came from the request, the cancel reason was a plain Error, and the fallback connection was missing from the privacy sentence.
    • A second local run on 7b1c7b698 raised 2 findings. Both were rejected with these reasons:
      • "Malformed layout JSON throws, so the retry never runs": repairJsonText returns only text that JSON.parse already accepted, so tryParseJsonRecord cannot throw. The cited {"headBox":[x0,y0,x1,y1]} comes back as strings, the strict schema refuses it, and the retry path runs.
      • "14px selects make iOS zoom": globals.css already sets font-size: 1rem on input, select, textarea under @media (pointer: coarse). That rule is outside any @layer, so it outranks Tailwind's layered text-sm.

Manual verification needed

This lane needs the base lane (storage, setup page) and the 2D lane (.mavatar importer) on staging before the panel shows up and saving works.

  1. Desktop Chrome: install 2D Avatars, open its Agent editor page, choose a character with expression sprites. Check Make an avatar from a sprite shows the sprites, the image connection (default marked), and the two sections.
  2. Blink and talk: pick two sprites with both variants and select Make 4 pictures. Check that:
    • pictures appear one at a time, and Cancel stops the current one;
    • Try again replaces one picture, and Keep marks it;
    • Save kept pictures shows a success toast;
    • the PNGTuber avatar now blinks and talks with the kept pictures, and every other expression still shows (including on a character that had no PNGTuber setup before);
    • blink and talk swaps do not jump, on a GPT Image 1 connection and on a Stable Diffusion or Draw Things connection.
  3. Keep two pictures, pick one more sprite and select Make pictures again. Check the kept pictures stay, only the new ones are made, and a kept picture shows no Try again until you select Kept to let it go.
  4. Make pictures for one sprite, replace that sprite in the character editor, then select Save kept pictures. Check the save is refused with a "make them again" message and nothing changes.
  5. With portrait and full_ sprites on one character, check only the portraits are offered for blink and talk pictures.
  6. With Expose media prompts before sending on (Settings), check the prompt review opens before any picture is made, edits are used, and cancelling the review makes nothing.
  7. Double-click Make pictures and Save kept pictures quickly: only one run and one save happen.
  8. Mesh avatar: pick a front-facing bust sprite and a chat connection whose model accepts pictures; select Make mesh avatar. Check that:
    • the preview outlines sit on the eyes, brows and mouth, and warnings read plainly;
    • Discard keeps the old avatar;
    • after Save as mesh avatar, the avatar blinks, half-closes its eyes when angry, talks with changing mouth shapes and turns its head on the stage.
  9. While a mesh avatar is being built from a large sprite, stream a reply in another chat tab and check the reply keeps streaming. Select Cancel and check the build stops right away.
  10. Error paths: no image connection (the panel offers Open Connections), a chat model without vision (a plain error after at most two tries), a persona with no sprites (the "Add sprites" hint), and an SVG-only sprite set (SVG sprites are not offered).
  11. Repeat steps 1, 2 and 8 on desktop Firefox and Safari, Android Chrome and the Android app WebView, and iOS Safari. Check the sprite grid wraps, buttons are easy to tap, and the preview fits the screen. On Android/Termux, check a mesh avatar build finishes and the server stays responsive.
  12. Light and dark mode plus a custom theme with Accent Pulse: selected sprites and kept pictures use the theme accent; the mesh error line uses the steady accent.
  13. Debug mode on: the server log shows the image prompts and the vision messages with the picture left out; a cancelled job is logged at info level, not as an error.

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 gains its "Making an avatar from a sprite" section; the translation follow-up for this guide is #7540 (it covers later edits to the section too). No CHANGELOG entry (release notes are compiled from this description).

UI evidence (if applicable)

  • No screenshot of the panel yet: it is mounted by the base lane's setup, which is not on this branch. The renders listed under Validation were checked locally and not uploaded.

Summary by CodeRabbit

  • New Features

    • Generate blink and talking PNGTuber images from existing sprites, review prompts, retry or cancel generation, and save selected results.
    • Create mesh avatars from a selected sprite, preview the result, and save or discard it.
    • Choose image and language connections for generation, with clear guidance when connections or eligible sprites aren’t available.
  • Documentation

    • Added instructions for generating and managing sprite-based pictures and mesh avatars, including connection requirements, prompt review, and mesh movement limitations.

🔄 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/7554 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/13/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/avatars-generation` --- ### 📝 Commits (10+) - [`a60776a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a60776a84f8c938efef1da606deb1c85ad2de4d2) feat(avatars): make PNGTuber variants and a mesh avatar from a sprite - [`a4ba56a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a4ba56a951fbfc666fbb1497e07331bfa1820e23) feat(avatars): generation panel for the 2D Avatars agent page - [`4eaef30`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4eaef3082aa8a3d64c28d10a9467ad1a8a4d5da2) fix(avatars): faster layer builder, fuller eye outline, one start per click - [`9324400`](https://github.com/Pasta-Devs/Marinara-Engine/commit/93244005ca3a0e1897bba360de20ba0ae7d3a06f) fix(avatars): keep the compiled negative prompt when a reviewed prompt leaves it out - [`a606d44`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a606d440c92ac181fc3f475ab22f1b5999957651) fix(avatars): refuse mesh generation before any model call when .mavatar can't be kept - [`cbe06c1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cbe06c19503dba9d93545708c79afd3b100b7516) fix(avatars): show a failed retry instead of the old picture; plainer guide - [`be7d471`](https://github.com/Pasta-Devs/Marinara-Engine/commit/be7d47116b2ab469b519ce30dd87fe348c884bd9) Merge branch 'staging' into feat/avatars-generation - [`5e1f172`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5e1f172cbba2004fbbae7c7d1487183be5aee99e) fix(avatars): keep generation responsive, lined up and from losing faces - [`79b0e7d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/79b0e7d2bc44bfa7571bdaa7d8c2b604be5805f6) fix(avatars): ask GPT Image 2 for a canvas size it keeps - [`7b1c7b6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7b1c7b698d7ba07efed78c9d801e44110dfbe9c2) fix(avatars): log a cancelled generation as a cancellation ### 📊 Changes **14 files changed** (+4006 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `docs/agents/avatars.md` (+21 -1) 📝 `packages/client/src/features/avatars/generation/AvatarGenerationPanel.tsx` (+142 -5) ➕ `packages/client/src/features/avatars/generation/MeshAvatarSection.tsx` (+171 -0) ➕ `packages/client/src/features/avatars/generation/PngtuberVariantsSection.tsx` (+277 -0) ➕ `packages/client/src/features/avatars/generation/SpritePicker.tsx` (+56 -0) ➕ `packages/client/src/features/avatars/generation/use-avatar-generation.ts` (+286 -0) 📝 `packages/client/src/localization/locales/en.json` (+44 -0) 📝 `packages/server/src/routes/avatar-generation.routes.ts` (+133 -10) ➕ `packages/server/src/services/avatars/generation/generation-context.ts` (+483 -0) ➕ `packages/server/src/services/avatars/generation/mesh-layer-builder.ts` (+571 -0) ➕ `packages/server/src/services/avatars/generation/mesh-rig-layout.ts` (+412 -0) 📝 `packages/server/src/services/avatars/generation/mesh-rig.ts` (+298 -10) 📝 `packages/server/src/services/avatars/generation/pngtuber-variants.ts` (+476 -11) ➕ `scripts/regressions/avatar-generation.regression.ts` (+636 -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 Refs #7537 (generation lane of the avatar agents epic) Built on the avatar contract, #7539, which is now merged into `staging`. This branch has `staging` merged in, so the diff shows only this lane. Saving and the panel itself still need the base lane (#7556, storage and the setup page). Mesh avatars also need the 2D lane (#7549, the `.mavatar` importer). ## Why this change - Making a 2D avatar by hand means drawing a blink picture and a talk picture for every expression, or rigging a mesh avatar in a separate tool. Most users already have expression sprites, so the 2D Avatars agent should turn them into an avatar in one click. - The user has to stay in control of what gets stored: image models redraw more than they are asked to, so every result is shown first and nothing replaces the current avatar until the user keeps it. ## What changed - On the **2D Avatars** agent page, **Make an avatar from a sprite** (the `AvatarGenerationPanel` the base lane's setup mounts through `AVATAR_GENERATION_PANEL`; it is inert until that PR lands): - **Blink and talk pictures** - Pick sprites, **Eyes closed** and/or **Mouth open**, and an image connection. When portrait sprites exist, only portraits are offered, because the PNGTuber avatar never mixes portrait and full-body faces. The server refuses a full-body label before any picture is paid for. - Pictures are made one at a time through the existing image generation path: the same provider routing, fallback connection, style settings and payload debug logging as sprite generation. - The sprite is sent as the reference picture, already placed (scaled, never stretched) on a canvas of the size the model is asked for. The sprite's own area is then cut back out of the answer. An edit that keeps the picture in place therefore lines up with the sprite, even when the model only takes fixed sizes (GPT Image 1) or the request is rounded. Custom-size GPT Image models get a canvas size their size rules keep. - No see-through background is requested, because GPT Image 2 has none. A cut-out sprite gets its own outline back. - Each picture gets **Keep** / **Try again**, and **Cancel** stops the one being made. Pictures already made stay: **Make pictures** only makes the missing ones, a failed **Try again** keeps the old picture and shows the error under it, and a kept picture has no **Try again** until the user lets it go. - **Save kept pictures** stores them as PNGTuber layers, each next to a copy of its source sprite, so base and variants always line up. A sprite replaced since its pictures were made is refused (409), checked by file hash before anything is written. - Files are written first, and the setup is merged inside the owner's storage queue (`updateAvatarConfig`). A change saved in the meantime (another tab, an import) is therefore kept. - An avatar still showing the owner's plain sprites keeps all of them: the save starts from the same sprite-built setup the 2D renderer shows. The result becomes a `generated` setup, so **Update from sprites** can't wipe the new pictures. Existing bindings and motion stay, and a set drawn for a different base picture is replaced rather than mixed. - **Mesh avatar** - Pick one sprite and a chat connection that can see pictures (default: the agent's connection, then the default agent connection). - The vision model answers with a box-and-point face layout (head, face, eyes, brows, nose, mouth corners, neck) on a gridded copy of the sprite. The answer is parsed strictly and checked against the picture and against itself. Eyes too big for the face are refused. When an answer can't be used, the model is asked once more with the reasons. - A JavaScript port of mesh-avatar-studio's layer builder (MIT) on sharp, with no Python, OpenCV or GPU, cuts each eye into ball, lash, lower-lid and crease layers and fills the skin behind them. - The builder works in 25 ms slices, so chat streaming and other requests keep running, and **Cancel** stops it. Very big eyes are built from a smaller copy of the sprite, which keeps one build to a few seconds of work. - The avatar blinks and talks with mesh-avatar's own eyelids and mouth. No drawn sprites are written: mesh-avatar 0.1.1 treats any `sprites.json` as the full set (half-closed and smiling eyes, four mouth shapes) and switches its own lids and mouth off. - The `.mavatar` is checked with the 2D importer before it is offered. The user sees the sprite with the found face parts drawn on it, and **Save as mesh avatar** checks the archive again, like any upload, before storing it. - Nothing is stored until the user saves. **Expose media prompts before sending** is honoured for every image prompt. One generation job per avatar runs at a time (server guard plus a client guard against fast double clicks), and closing the request cancels the provider calls. - Prompts come from the 2D Avatars package's `avatarGenerationTemplates` (ids in `AVATAR_PROMPT_TEMPLATE_IDS`). The Engine keeps one-sentence fallbacks only for a package that ships no template. Card text (name, appearance) reaches a prompt only as one capped line inside a template variable, the vision call adds a fixed line that the description is never an instruction, and the model's answer can only become a layout that passes the checks. Every prompt is logged with `logDebugOverride` (debug mode or `DEBUG_AGENTS`), the vision messages with the picture redacted. - Until the 2D importer can read `.mavatar` files, **Make mesh avatar** is refused with 503 before any model call, so no paid request is wasted. - Lane-local API (`/api/avatar-generation`, documented in the route header): `POST /pngtuber-variants/preview`, `POST /pngtuber-variants` (drafts), `POST /pngtuber-variants/save`, `POST /mesh-rig` (draft), `POST /mesh-rig/save`. The contract request types and schemas are reused unchanged. `promptOverrides`, the drafts' `sourceHash` and the draft/save bodies are lane-local, like the sprite routes' own body types. A closed request aborts with an `AbortError`, so a cancelled job is logged as a cancellation. No contract file is edited. - UI copy under `avatars.generation.*` in `en.json`; `docs/agents/avatars.md` gets its "Making an avatar from a sprite" section (translation follow-up: #7540). ### Design notes for reviewers - Generate returns drafts and save stores them, because the epic asks for per-picture approval and for the old avatar to stay until approval. Drafts live in the browser; the save routes re-validate everything they get back (pictures are decoded, re-encoded and must match the sprite's size; archives go through the 2D importer), so a draft is never trusted more than an upload. - The vision model gives boxes and points, not the 14-20 point eye outlines the Studio asks a person or coding agent to trace; vision models place boxes far more reliably. The eye outline is a full almond in the eye box (`ponytail:` comment names the ceiling: refine from eye-white pixels). - Skin behind the eyes is filled with a membrane solve (the Studio's `fill_skin`), not model inpainting: the existing image path has no edit mask. `ponytail:` comment names the ceiling (flat shading under the lids; upgrade: masked inpainting once the image path accepts a mask). Hands, hanging accessories, buns and hair strands are not rigged; the hair moves with the head. - The server copy of the 2D renderer's sprite-to-layers rule (`spriteBuiltPngtuber`) carries a `ponytail:` comment: the two must change together until one copy moves into `@marinara-engine/shared` with a contract PR. A second `ponytail:` comment covers pictures of a replaced imported set. They stay on disk until the next PNGTuber import or removal tidies the folder, because storage has no queued tidy call for generation to use. ## 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 on this branch (not a substitute for the boxes above): - `pnpm check` on 79b0e7d2b: passed (exit 0). The last commit, 7b1c7b698, only changes an abort reason, one docs sentence and the regression's fake server. - After the last commit, server `tsc --noEmit`, Prettier and the regression were re-run and pass. - The client files are unchanged since that `pnpm check` run. - `node scripts/run-regressions.mjs --filter avatar-`: 7/7 passed, including the reworked `avatar-generation` regression and the contract's `avatar-contract`. - `pnpm localization:check`: passed. Two `avatars.generation.drawVariants*` keys were removed with the mesh drawing option. - The new checks fail on the code they guard against: run with the old edit path (unpadded reference, stretched back), the alignment check fails (dot at x=199.5 ends up at x=174.9 on a 600x720 sprite). The old builder had no cancel signal, the old layout check accepted half-picture eyes, and the old save schema has no `sourceHash`. - Local probes (not committed). Main-thread CPU time between event-loop turns, measured with `process.threadCpuUsage`, because the machine was heavily loaded: - A 2040x2448 bust: the longest stretch went from 808 ms to 128-156 ms, with the same total CPU. - The reviewer's half-picture eye layout is now refused. The largest layout the check still allows builds from a 0.35x copy in 3.1 s of sliced CPU, with a longest stretch of 175 ms. - Local probe against the base lane's real `storage.ts` (swapped in, then restored): - A first save into a sprite-only avatar keeps neutral/happy/sad/angry, and `happy_talk` stays happy's mouth-open picture. - A motion change saved during a second save survives. - A replaced sprite is refused. - Reviews: - The earlier GitHub threads are all resolved (4 CodeRabbit, 2 CodeQL). Nothing new was unresolved before this push. - Local CodeRabbit (`--committed`, base 797877c54) on 79b0e7d2b raised 3 findings, all fixed in 7b1c7b698: the fake server's size came from the request, the cancel reason was a plain Error, and the fallback connection was missing from the privacy sentence. - A second local run on 7b1c7b698 raised 2 findings. Both were rejected with these reasons: - "Malformed layout JSON throws, so the retry never runs": `repairJsonText` returns only text that `JSON.parse` already accepted, so `tryParseJsonRecord` cannot throw. The cited `{"headBox":[x0,y0,x1,y1]}` comes back as strings, the strict schema refuses it, and the retry path runs. - "14px selects make iOS zoom": `globals.css` already sets `font-size: 1rem` on `input, select, textarea` under `@media (pointer: coarse)`. That rule is outside any `@layer`, so it outranks Tailwind's layered `text-sm`. ### Manual verification needed This lane needs the base lane (storage, setup page) and the 2D lane (`.mavatar` importer) on `staging` before the panel shows up and saving works. 1. Desktop Chrome: install **2D Avatars**, open its Agent editor page, choose a character with expression sprites. Check **Make an avatar from a sprite** shows the sprites, the image connection (default marked), and the two sections. 2. Blink and talk: pick two sprites with both variants and select **Make 4 pictures**. Check that: - pictures appear one at a time, and **Cancel** stops the current one; - **Try again** replaces one picture, and **Keep** marks it; - **Save kept pictures** shows a success toast; - the PNGTuber avatar now blinks and talks with the kept pictures, and every other expression still shows (including on a character that had no PNGTuber setup before); - blink and talk swaps do not jump, on a GPT Image 1 connection and on a Stable Diffusion or Draw Things connection. 3. Keep two pictures, pick one more sprite and select **Make pictures** again. Check the kept pictures stay, only the new ones are made, and a kept picture shows no **Try again** until you select **Kept** to let it go. 4. Make pictures for one sprite, replace that sprite in the character editor, then select **Save kept pictures**. Check the save is refused with a "make them again" message and nothing changes. 5. With portrait and `full_` sprites on one character, check only the portraits are offered for blink and talk pictures. 6. With **Expose media prompts before sending** on (Settings), check the prompt review opens before any picture is made, edits are used, and cancelling the review makes nothing. 7. Double-click **Make pictures** and **Save kept pictures** quickly: only one run and one save happen. 8. Mesh avatar: pick a front-facing bust sprite and a chat connection whose model accepts pictures; select **Make mesh avatar**. Check that: - the preview outlines sit on the eyes, brows and mouth, and warnings read plainly; - **Discard** keeps the old avatar; - after **Save as mesh avatar**, the avatar blinks, half-closes its eyes when angry, talks with changing mouth shapes and turns its head on the stage. 9. While a mesh avatar is being built from a large sprite, stream a reply in another chat tab and check the reply keeps streaming. Select **Cancel** and check the build stops right away. 10. Error paths: no image connection (the panel offers **Open Connections**), a chat model without vision (a plain error after at most two tries), a persona with no sprites (the "Add sprites" hint), and an SVG-only sprite set (SVG sprites are not offered). 11. Repeat steps 1, 2 and 8 on desktop Firefox and Safari, Android Chrome and the Android app WebView, and iOS Safari. Check the sprite grid wraps, buttons are easy to tap, and the preview fits the screen. On Android/Termux, check a mesh avatar build finishes and the server stays responsive. 12. Light and dark mode plus a custom theme with Accent Pulse: selected sprites and kept pictures use the theme accent; the mesh error line uses the steady accent. 13. Debug mode on: the server log shows the image prompts and the vision messages with the picture left out; a cancelled job is logged at info level, not as an error. ## 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` gains its "Making an avatar from a sprite" section; the translation follow-up for this guide is #7540 (it covers later edits to the section too). No CHANGELOG entry (release notes are compiled from this description). ## UI evidence (if applicable) - No screenshot of the panel yet: it is mounted by the base lane's setup, which is not on this branch. The renders listed under Validation were checked locally and not uploaded. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Generate blink and talking PNGTuber images from existing sprites, review prompts, retry or cancel generation, and save selected results. * Create mesh avatars from a selected sprite, preview the result, and save or discard it. * Choose image and language connections for generation, with clear guidance when connections or eligible sprites aren’t available. * **Documentation** * Added instructions for generating and managing sprite-based pictures and mesh avatars, including connection requirements, prompt review, and mesh movement limitations. <!-- 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:33 +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#7793
No description provided.