[PR #7854] [MERGED] fix(avatars): blink and talk pictures change only the eyes or mouth, and are generated when the model cannot edit #7973

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

📋 Pull Request Information

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

Base: staging ← Head: fix/avatar-variant-region-composite


📝 Commits (1)

  • be9cbc3 fix(avatars): blink and talk pictures change only the eyes or mouth, and are generated when the model cannot edit

📊 Changes

15 files changed (+2056 additions, -280 deletions)

View changed files

📝 docs/agents/avatars.md (+6 -4)
📝 e2e/avatar-generation.e2e.ts (+147 -12)
📝 packages/client/src/features/avatars/generation/PngtuberVariantsSection.tsx (+27 -3)
📝 packages/client/src/features/avatars/generation/use-avatar-generation.ts (+86 -9)
📝 packages/client/src/localization/locales/en.json (+2 -0)
📝 packages/server/src/routes/avatar-generation.routes.ts (+3 -1)
📝 packages/server/src/routes/sprites.routes.ts (+189 -69)
📝 packages/server/src/services/avatars/generation/generation-context.ts (+101 -87)
📝 packages/server/src/services/avatars/generation/pngtuber-variants.ts (+156 -27)
➕ packages/server/src/services/avatars/generation/variant-composite.ts (+706 -0)
📝 scripts/regressions/avatar-backgrounds.regression.ts (+81 -56)
📝 scripts/regressions/avatar-generation-cancel.regression.ts (+5 -3)
➕ scripts/regressions/avatar-variant-composite.regression.ts (+537 -0)
📝 scripts/regressions/image-edit-reference.regression.ts (+8 -9)
📝 scripts/run-regressions.mjs (+2 -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

No issue: @SpicyMarinara's report while testing staging on 2026-10-19 (Agents → 2D Avatars → Blink and talk pictures). An issue should be opened for it if one is needed for tracking. Follow-up to #7682, #7690 and #7843; replaces the approach of the closed #7841.

Why this change

The Eyes closed and Mouth open pictures came back with a white line along the bottom and slightly wrong pixels everywhere else. The face was clean, and the image model was the same one that made the faces.

Root cause, in plain words: image models never send a picture back exactly where it went in. They pad it, move it a few pixels or zoom out a little. The Engine then pasted the model's whole picture back inside the face's outline. Wherever the model had shifted or shrunk the picture, its white padding landed inside the outline. The reported face (512×484) is a bust cut flat at the canvas bottom, so the padding showed as a white line just above the bottom. #7843 kept the bottom 13 rows as the face's own pixels, which is why the line sits a little above the edge rather than on it. Everything else was the model's redraw, scaled slightly, so pixels looked off all over.

Separately, an image connection that can't edit pictures (DALL-E, Pollinations, Together AI, Horde, a ComfyUI workflow without a picture slot) was refused outright, so those users had no way to get blink and talk pictures.

What changed

  • You can no longer keep a blink or talk picture in which nothing changed. When the model didn't close the eyes or open the mouth, or moved the picture too far to line it up, the slot now says so ("The image model didn't close the eyes in this picture. Try again.") instead of offering it. Try again draws it again, as before.
  • Blink and talk pictures change only the eyes or the mouth.
    • The model's picture is first lined up with the face, undoing padding, a shift or a small zoom. A picture that comes back at another size or shape works too.
    • Then only the region that changed is taken from it: the eyes for a blink, the mouth for talking. It is softened at its edge and laid onto the face.
    • Everything else stays the face's own pixels, byte for byte: hair, outline, clothes and the bottom edge. The face's transparency is kept everywhere, so a white bar can't appear.
  • Connections that can't edit pictures now make the pictures instead of being refused. They draw a new face with its blink and talk pictures in one picture, so the three match. This uses the same sheet drawing and plain-color background removal as Make faces from the avatar, from the character's or persona's appearance.
    • Each variant is lined up with the new face and gives only its eyes or mouth.
    • The row shows the new face as New face, with a short note. Keep keeps the face and both pictures together.
    • Saving makes the new face the face of that feeling in the PNGTuber avatar. The sprite file itself is never changed. Old pictures of the old face are dropped, because they wouldn't match.
    • With Expose media prompts before sending on, you review one prompt for the set.
    • Without an appearance or description, you get a plain message asking you to add one.
  • Edit-capable connections still edit. The decision uses the existing per-provider reference-picture table from #7685.
  • Removed the outline collar from #7843 (applyAvatarSourceOutline and its band). The region composite keeps its guarantees: the face's own alpha and edge pixels, and no stripe along a bust cut at the canvas edge.
  • The sprite-sheet cutter in routes/sprites.routes.ts is now one function that both Make faces from the avatar and the set use. Sheet behavior is unchanged.
  • Docs: the 2D Avatars guide describes lining up, the eyes/mouth-only rule and the set for connections that can't edit.

After updating, make the existing Eyes closed and Mouth open pictures again. Pictures saved before this change kept the model's whole picture, white line included. Use Try again on each, then Save kept pictures.

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

Agent-run validation (the boxes above are left for the human pass):

  • pnpm check passed on the pushed commit: localization, formatting, lint, TypeScript and production builds. The one lint warning is pre-existing, in HomeProfessorMariChat.tsx.
  • node scripts/run-regressions.mjs --filter avatar-: 20/20 passed, including the new avatar-variant-composite. The filters image-edit-reference, sprite, gpt-image-2-5, open-issues, pixelize and regeneration-context also passed.
  • New regression avatar-variant-composite:
    • A fake image model edits the face on the canvas it is sent. Simulated outputs: in place, shifted with white fill, zoomed out 7%, zoomed in 3%, a square canvas, a letterboxed portrait canvas, and a larger canvas with JPEG noise.
    • For each output, the saved picture equals the face outside the eyes or mouth, pixel for pixel. It has no added white pixels in the bottom 30 rows, keeps the face's alpha everywhere, and shows the change.
    • A picture with no change, and one turned 14°, are refused with plain messages.
    • Capability decision: GPT Image edits; DALL-E 3 and Pollinations draw a set. The set preview carries the set contract.
    • Set path, from a simulated sheet: one generation request and no edit request. Both variants share the new face and equal it outside their region. Saving stores the new face as the base and leaves the sprite file unchanged. A picture of the old face can't be mixed in, and the old _talk sprite doesn't stay. A character without an appearance gets the plain message.
    • The face is drawn from SVG with the reported sprite's shape: 512×484, bust cut flat across the bottom rows, alpha 253 inside. The reported neutral.png isn't committed. MARINARA_AVATAR_VARIANT_SOURCE=<png> runs the same edit checks on it, and it passed on the reported face.
  • Updated regressions:
    • avatar-backgrounds: the outline-collar checks now target the region composite. A cut-out keeps its alpha and edge, a bust's bottom edge survives a white stripe, a fringe and a hair highlight never come through, and small cropped faces keep their eye and mouth edits.
    • image-edit-reference: a connection that drops the picture is no longer refused; it reports canEdit: false.
    • avatar-generation-cancel: its fake model now answers with a real edit, because an unchanged picture is refused.
  • Playwright on desktop Chromium, 8/8 passed for avatar-generation, avatar-setup and gpt-image-2-5.
    • The Cancel test's fake model now closes the eyes.
    • New test: a DALL-E 3 connection makes New face with both pictures in one generation request and no edit request. Keep on one keeps both, and saving stores the face and both pictures.
  • Before and after, on the reported face, compared with the old pipeline copied from staging:
    • The zoomed-out output reproduces the report: 1,837 added white pixels in a line just above the bottom, ending where #7843's 13-row band begins. The letterboxed output gives 7,756.
    • About 75,000 to 88,000 pixels outside the face region differ from the face in every old output, even when the model kept the picture in place, because the whole redraw was pasted back. After: 0 white and 0 differing pixels outside the eyes or mouth in all 16 cases.
    • Real Codex image edits of the reported face (GPT Image, 1274×1235 returned for a 1056×1024 canvas), mouth open and eyes closed: after, clean, with only the mouth or eyes changed.
    • A real three-cell set sheet generated without a reference: the eyes and mouth were moved onto the face cell cleanly.

Manual verification notes

  • Manually verify on staging with the original image connection: in Agents → 2D Avatars → Blink and talk pictures, select Try again on the Neutral face's Eyes closed and Mouth open. Check that the pictures have no white line at the bottom, and that only the eyes or the mouth differ from the Face when switching between them.
  • Manually verify with an image connection that can't edit pictures (for example DALL-E 3 or Pollinations): Make shows New face with both pictures. Keep on one keeps all three, and after Save kept pictures the avatar shows the new face and its blink and talk pictures. The character's sprite in the sprite editor is unchanged.
  • Manually verify that a picture in which the model didn't change the eyes or mouth shows the plain "Try again" message in its slot, and that Try again works afterwards.
  • Manually verify the prompt review (Settings → Expose media prompts before sending) for both kinds of connection: two edit prompts, or one set prompt.
  • Manually verify the row on a phone-width window and in light mode.

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 changed (Blink and talk pictures). Translations: follow-up issue #7853. No release metadata changed.

UI evidence (if applicable)

Before/after pictures were made on the reported face and kept locally, not uploaded: the face, the old pipeline and the new one side by side for each simulated output, plus the real Codex edits and set. Old pipeline: a white line along the bottom (zoomed-out output), large white areas (letterboxed), and a slightly shrunken redraw inside the original outline. New pipeline: the face's own pixels everywhere except the closed eyes or open mouth.

The new New face row was screenshotted in the Playwright run: the hint line under the feeling names, then New face, Eyes closed and Mouth open with their pictures.

Summary by CodeRabbit

  • New Features
    • Avatar generation now supports image connections that cannot edit reference pictures. These connections create a new face with matching blink and talking variants, provided an appearance or description is available.
    • Generated faces can be saved with their variants, replacing the current face.
  • Improvements
    • Blink and talking variants from reference-capable connections are better aligned with the source sprite and preserve its appearance outside the requested facial change.
    • Unusable or misaligned generated variants are rejected with clearer guidance.

🔄 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/7854 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/19/2026 **Status:** ✅ Merged **Merged:** 10/19/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/avatar-variant-region-composite` --- ### 📝 Commits (1) - [`be9cbc3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/be9cbc38d77c539ae00d7438ea972ac13bebf496) fix(avatars): blink and talk pictures change only the eyes or mouth, and are generated when the model cannot edit ### 📊 Changes **15 files changed** (+2056 additions, -280 deletions) <details> <summary>View changed files</summary> 📝 `docs/agents/avatars.md` (+6 -4) 📝 `e2e/avatar-generation.e2e.ts` (+147 -12) 📝 `packages/client/src/features/avatars/generation/PngtuberVariantsSection.tsx` (+27 -3) 📝 `packages/client/src/features/avatars/generation/use-avatar-generation.ts` (+86 -9) 📝 `packages/client/src/localization/locales/en.json` (+2 -0) 📝 `packages/server/src/routes/avatar-generation.routes.ts` (+3 -1) 📝 `packages/server/src/routes/sprites.routes.ts` (+189 -69) 📝 `packages/server/src/services/avatars/generation/generation-context.ts` (+101 -87) 📝 `packages/server/src/services/avatars/generation/pngtuber-variants.ts` (+156 -27) ➕ `packages/server/src/services/avatars/generation/variant-composite.ts` (+706 -0) 📝 `scripts/regressions/avatar-backgrounds.regression.ts` (+81 -56) 📝 `scripts/regressions/avatar-generation-cancel.regression.ts` (+5 -3) ➕ `scripts/regressions/avatar-variant-composite.regression.ts` (+537 -0) 📝 `scripts/regressions/image-edit-reference.regression.ts` (+8 -9) 📝 `scripts/run-regressions.mjs` (+2 -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 No issue: @SpicyMarinara's report while testing staging on 2026-10-19 (Agents → 2D Avatars → Blink and talk pictures). An issue should be opened for it if one is needed for tracking. Follow-up to #7682, #7690 and #7843; replaces the approach of the closed #7841. ## Why this change The **Eyes closed** and **Mouth open** pictures came back with a white line along the bottom and slightly wrong pixels everywhere else. The face was clean, and the image model was the same one that made the faces. **Root cause, in plain words:** image models never send a picture back exactly where it went in. They pad it, move it a few pixels or zoom out a little. The Engine then pasted the model's *whole* picture back inside the face's outline. Wherever the model had shifted or shrunk the picture, its white padding landed inside the outline. The reported face (512×484) is a bust cut flat at the canvas bottom, so the padding showed as a white line just above the bottom. #7843 kept the bottom 13 rows as the face's own pixels, which is why the line sits a little above the edge rather than on it. Everything else was the model's redraw, scaled slightly, so pixels looked off all over. Separately, an image connection that can't edit pictures (DALL-E, Pollinations, Together AI, Horde, a ComfyUI workflow without a picture slot) was refused outright, so those users had no way to get blink and talk pictures. ## What changed - **You can no longer keep a blink or talk picture in which nothing changed.** When the model didn't close the eyes or open the mouth, or moved the picture too far to line it up, the slot now says so ("The image model didn't close the eyes in this picture. Try again.") instead of offering it. **Try again** draws it again, as before. - **Blink and talk pictures change only the eyes or the mouth.** - The model's picture is first lined up with the face, undoing padding, a shift or a small zoom. A picture that comes back at another size or shape works too. - Then only the region that changed is taken from it: the eyes for a blink, the mouth for talking. It is softened at its edge and laid onto the face. - Everything else stays the face's own pixels, byte for byte: hair, outline, clothes and the bottom edge. The face's transparency is kept everywhere, so a white bar can't appear. - **Connections that can't edit pictures now make the pictures instead of being refused.** They draw a new face with its blink and talk pictures in one picture, so the three match. This uses the same sheet drawing and plain-color background removal as **Make faces from the avatar**, from the character's or persona's appearance. - Each variant is lined up with the new face and gives only its eyes or mouth. - The row shows the new face as **New face**, with a short note. **Keep** keeps the face and both pictures together. - Saving makes the new face the face of that feeling in the PNGTuber avatar. The sprite file itself is never changed. Old pictures of the old face are dropped, because they wouldn't match. - With **Expose media prompts before sending** on, you review one prompt for the set. - Without an appearance or description, you get a plain message asking you to add one. - **Edit-capable connections still edit.** The decision uses the existing per-provider reference-picture table from #7685. - Removed the outline collar from #7843 (`applyAvatarSourceOutline` and its band). The region composite keeps its guarantees: the face's own alpha and edge pixels, and no stripe along a bust cut at the canvas edge. - The sprite-sheet cutter in `routes/sprites.routes.ts` is now one function that both **Make faces from the avatar** and the set use. Sheet behavior is unchanged. - Docs: the 2D Avatars guide describes lining up, the eyes/mouth-only rule and the set for connections that can't edit. **After updating, make the existing Eyes closed and Mouth open pictures again.** Pictures saved before this change kept the model's whole picture, white line included. Use **Try again** on each, then **Save kept pictures**. ## 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` Agent-run validation (the boxes above are left for the human pass): - `pnpm check` passed on the pushed commit: localization, formatting, lint, TypeScript and production builds. The one lint warning is pre-existing, in `HomeProfessorMariChat.tsx`. - `node scripts/run-regressions.mjs --filter avatar-`: 20/20 passed, including the new `avatar-variant-composite`. The filters `image-edit-reference`, `sprite`, `gpt-image-2-5`, `open-issues`, `pixelize` and `regeneration-context` also passed. - New regression `avatar-variant-composite`: - A fake image model edits the face on the canvas it is sent. Simulated outputs: in place, shifted with white fill, zoomed out 7%, zoomed in 3%, a square canvas, a letterboxed portrait canvas, and a larger canvas with JPEG noise. - For each output, the saved picture equals the face outside the eyes or mouth, pixel for pixel. It has no added white pixels in the bottom 30 rows, keeps the face's alpha everywhere, and shows the change. - A picture with no change, and one turned 14°, are refused with plain messages. - Capability decision: GPT Image edits; DALL-E 3 and Pollinations draw a set. The set preview carries the set contract. - Set path, from a simulated sheet: one generation request and no edit request. Both variants share the new face and equal it outside their region. Saving stores the new face as the base and leaves the sprite file unchanged. A picture of the old face can't be mixed in, and the old `_talk` sprite doesn't stay. A character without an appearance gets the plain message. - The face is drawn from SVG with the reported sprite's shape: 512×484, bust cut flat across the bottom rows, alpha 253 inside. The reported `neutral.png` isn't committed. `MARINARA_AVATAR_VARIANT_SOURCE=<png>` runs the same edit checks on it, and it passed on the reported face. - Updated regressions: - `avatar-backgrounds`: the outline-collar checks now target the region composite. A cut-out keeps its alpha and edge, a bust's bottom edge survives a white stripe, a fringe and a hair highlight never come through, and small cropped faces keep their eye and mouth edits. - `image-edit-reference`: a connection that drops the picture is no longer refused; it reports `canEdit: false`. - `avatar-generation-cancel`: its fake model now answers with a real edit, because an unchanged picture is refused. - Playwright on desktop Chromium, 8/8 passed for `avatar-generation`, `avatar-setup` and `gpt-image-2-5`. - The Cancel test's fake model now closes the eyes. - New test: a DALL-E 3 connection makes **New face** with both pictures in one generation request and no edit request. **Keep** on one keeps both, and saving stores the face and both pictures. - Before and after, on the reported face, compared with the old pipeline copied from `staging`: - The zoomed-out output reproduces the report: 1,837 added white pixels in a line just above the bottom, ending where #7843's 13-row band begins. The letterboxed output gives 7,756. - About 75,000 to 88,000 pixels outside the face region differ from the face in every old output, even when the model kept the picture in place, because the whole redraw was pasted back. After: 0 white and 0 differing pixels outside the eyes or mouth in all 16 cases. - Real Codex image edits of the reported face (GPT Image, 1274×1235 returned for a 1056×1024 canvas), mouth open and eyes closed: after, clean, with only the mouth or eyes changed. - A real three-cell set sheet generated without a reference: the eyes and mouth were moved onto the face cell cleanly. ### Manual verification notes - Manually verify on staging with the original image connection: in Agents → 2D Avatars → Blink and talk pictures, select **Try again** on the Neutral face's **Eyes closed** and **Mouth open**. Check that the pictures have no white line at the bottom, and that only the eyes or the mouth differ from the **Face** when switching between them. - Manually verify with an image connection that can't edit pictures (for example DALL-E 3 or Pollinations): **Make** shows **New face** with both pictures. **Keep** on one keeps all three, and after **Save kept pictures** the avatar shows the new face and its blink and talk pictures. The character's sprite in the sprite editor is unchanged. - Manually verify that a picture in which the model didn't change the eyes or mouth shows the plain "Try again" message in its slot, and that **Try again** works afterwards. - Manually verify the prompt review (Settings → Expose media prompts before sending) for both kinds of connection: two edit prompts, or one set prompt. - Manually verify the row on a phone-width window and in light mode. ## 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` changed (Blink and talk pictures). Translations: follow-up issue #7853. No release metadata changed. ## UI evidence (if applicable) Before/after pictures were made on the reported face and kept locally, not uploaded: the face, the old pipeline and the new one side by side for each simulated output, plus the real Codex edits and set. Old pipeline: a white line along the bottom (zoomed-out output), large white areas (letterboxed), and a slightly shrunken redraw inside the original outline. New pipeline: the face's own pixels everywhere except the closed eyes or open mouth. The new **New face** row was screenshotted in the Playwright run: the hint line under the feeling names, then **New face**, **Eyes closed** and **Mouth open** with their pictures. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Avatar generation now supports image connections that cannot edit reference pictures. These connections create a new face with matching blink and talking variants, provided an appearance or description is available. * Generated faces can be saved with their variants, replacing the current face. * **Improvements** * Blink and talking variants from reference-capable connections are better aligned with the source sprite and preserve its appearance outside the requested facial change. * Unusable or misaligned generated variants are rejected with clearer guidance. <!-- 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:09:18 +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#7973
No description provided.