[PR #7718] [MERGED] fix(images): refuse avatar edits on connections that drop the reference picture #7894

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

📋 Pull Request Information

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

Base: staging ← Head: fix/7685-reference-image-providers


📝 Commits (5)

  • 57d285a fix(images): refuse avatar edits on connections that drop the reference picture
  • 8d90d0d fix(images): SwarmUI workflows take the picture only through %reference_image%
  • f1a90fa fix(images): an edit counts only the first workflow slot; avatar docs say non-edit connections are refused
  • 977bcf0 fix(images): a picture too large for SpicyAPI says so instead of "can't edit"
  • 06a623d fix(images): reject mixed workflows and schema-less picture edits

📊 Changes

6 files changed (+525 additions, -40 deletions)

View changed files

📝 docs/agents/avatars.md (+3 -3)
📝 packages/server/src/services/avatars/generation/generation-context.ts (+40 -24)
📝 packages/server/src/services/image/comfyui-reference-placeholders.ts (+14 -0)
📝 packages/server/src/services/image/image-generation.ts (+117 -12)
📝 packages/server/src/services/media/atlas-cloud.ts (+6 -1)
➕ scripts/regressions/image-edit-reference.regression.ts (+345 -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

Closes #7685

Why this change

  • 2D Avatars blink and talk pictures are edits of a sprite: the sprite goes to the image model as the picture to change. Some image services ignore that picture. Pollinations, for example, sends only the prompt and size. The "edit" then came back as a new picture: a full-body or redrawn result like the one #7681 fixed for GPT Image. The provider was still paid for it.
  • The same happened when the primary connection failed and the fallback image connection was one of those services.
  • Now Marinara refuses before paying for anything and tells the user what to pick: "This image connection can't edit pictures. Choose one that accepts a reference picture."

What changed

  • A table of which image services take a reference picture (imageConnectionTakesReferencePicture in image-generation.ts). I read each provider's adapter. Where the model, base URL or workflow decides, the table entry is a check:
    • Drop it: Pollinations, Together AI, Horde, Venice, Z.AI and fal.ai.
    • Depends on the model, URL or workflow:
      • OpenAI: GPT Image models only. DALL-E and other models get a new-picture request.
      • Stability: not on the v1 API.
      • NovelAI's own host: V4.5 only. A NovelAI proxy gets the picture through chat completions.
      • Atlas Cloud: edit models only. This reuses the adapter's own check.
      • ComfyUI and RunPod: only when the workflow has a reference placeholder. ComfyUI's built-in workflow is text-to-image.
      • SwarmUI: without a custom workflow, or with a %reference_image% placeholder in it. Its adapter refuses file-name slots.
    • Take it: ChatGPT plan, Arli, NanoGPT, OpenRouter, xAI, AUTOMATIC1111/Draw Things, Gemini image and SpicyAPI.
  • Avatar edits are refused on such a connection in resolveAvatarImageConnection. That runs for the prompt review and for generation, before any picture is paid for. The check and the request use the same connection fields (avatarImageService), so they can't disagree.
  • A fallback that would drop the picture is skipped for an edit (referenceIsCanvas) in generateImage. The primary's error is reported and the skip is logged. A fallback that takes the picture is still used.
  • SpicyAPI checks the model when the picture is requested. Whether a SpicyAPI model takes a picture depends on its input schema, which is only read at that point. All three built-in SpicyAPI models are text-to-image. generateSpicyApi now refuses a canvas edit after the free model lookup and before the paid task is created.
  • No conflict with #7664. That PR (provider media queue) is already merged. This change sits on top of its lane code without touching it.
  • Review fixes: SwarmUI rejects workflows containing a file-name slot even alongside a supported picture slot. SpicyAPI checks picture support from the model schema before adding custom parameters, so a custom image_url cannot make a text-only model start a paid edit. The guide describes unsupported ComfyUI workflows without implying only one literal placeholder works.
  • Regression: scripts/regressions/image-edit-reference.regression.ts, including mixed-workflow and custom-field negative cases.

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 checks:

  • After the review fixes: pnpm check passes (one existing React hook warning in HomeProfessorMariChat.tsx); focused image-edit-reference, spicyapi-image, and image-custom-parameters regressions pass.
  • Local CodeRabbit rerun after these fixes: 1 finding, dismissed because translation follow-up #7732 is already linked below and remains open. Its wording was updated to match the final guide. No remaining substantive local findings.
  • tsc --noEmit for shared, server, client and root: pass.
  • prettier --check on the changed files: pass.
  • New regression image-edit-reference: pass. It fails on staging (the helper is missing). I also undid each part of the fix by itself, and each time it fails at the matching check:
    • without the avatar refusal: "Missing expected rejection";
    • without the fallback skip: the fallback is asked;
    • without the SpicyAPI check: a task is created;
    • with Stability v1 counted as taking references: "Stability v1 is text-to-image".
  • Local CodeRabbit review: 1 finding, fixed in the second commit. A SwarmUI workflow that has only %reference_image_name% slots was counted as taking the picture. buildSwarmUiGenerationBody refuses those slots, so such a workflow is now refused too. The new table check fails without that commit.
  • Related regressions pass: avatar-generation, avatar-generation-cancel, avatar-backgrounds, avatar-vrm-generation, spicyapi-image, atlas-cloud-video-schema, codex-chatgpt-image, media-provider-lane, media-generation-cap, image-generation-timeout, image-custom-parameters, image-dimension-limit, image-response-limit, image-result-url-security, image-appearance-game, illustrator-character-prompts, illustrator-manual-cadence, swarmui-native-parameters, swarmui-timeout, openrouter-image-endpoint, novelai-character-caption-cap, novelai-zip-security, fal-image, gpt-image-2-5, provider-compat, regeneration-context and open-issues.

Manual verification notes

  • Manually verify that 2D Avatars → make blink/talk pictures with a Pollinations image connection shows "This image connection can't edit pictures. Choose one that accepts a reference picture." in the prompt review, before anything is generated.
  • Manually verify that the same flow with a GPT Image (or another editing) connection still makes the blink/talk pictures as before.
  • Manually verify that with a primary editing connection that fails (for example a wrong API key) and a Pollinations fallback image connection, the variant shows the primary's error and no Pollinations picture is made. The server log should show the "skipped fallback connection" line.
  • Manually verify that a SpicyAPI connection with a text-to-image model is refused for blink/talk pictures and that no SpicyAPI task is billed.

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] <paths> 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 (Blink and talk pictures) now says the image connection must accept a reference picture, that others are refused before anything is drawn, and that a fallback that can't take the picture is skipped. Translations: follow-up #7732. The new message is a server error that the avatar dialog already shows, so no UI copy or locale keys changed.

UI evidence (if applicable)

None: this changes the server only.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Avatar image generation now checks whether a connection supports reference pictures before starting, and reports a clear error when it does not.
    • Canvas edits no longer retry through a fallback that cannot accept reference pictures, preserving the original error instead.
    • Image edits now distinguish unsupported reference pictures from references that are too large, helping explain why an edit could not proceed.
    • Reference pictures are sent only to image models and workflows that support them.

🔄 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/7718 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/7685-reference-image-providers` --- ### 📝 Commits (5) - [`57d285a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/57d285a91505646668e4458e0780bc496d1a21ee) fix(images): refuse avatar edits on connections that drop the reference picture - [`8d90d0d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8d90d0d57d7691eba5115d6f87f6bae59fbef2ba) fix(images): SwarmUI workflows take the picture only through %reference_image% - [`f1a90fa`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f1a90faea5bf691c5c3551d6446b08ee89c9266c) fix(images): an edit counts only the first workflow slot; avatar docs say non-edit connections are refused - [`977bcf0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/977bcf0bd51bdb88459b2514ed2dafa60cc78c4a) fix(images): a picture too large for SpicyAPI says so instead of "can't edit" - [`06a623d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/06a623d1f76bef4f9d5eeb99e8aa626be09772a1) fix(images): reject mixed workflows and schema-less picture edits ### 📊 Changes **6 files changed** (+525 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `docs/agents/avatars.md` (+3 -3) 📝 `packages/server/src/services/avatars/generation/generation-context.ts` (+40 -24) 📝 `packages/server/src/services/image/comfyui-reference-placeholders.ts` (+14 -0) 📝 `packages/server/src/services/image/image-generation.ts` (+117 -12) 📝 `packages/server/src/services/media/atlas-cloud.ts` (+6 -1) ➕ `scripts/regressions/image-edit-reference.regression.ts` (+345 -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 Closes #7685 ## Why this change - 2D Avatars blink and talk pictures are edits of a sprite: the sprite goes to the image model as the picture to change. Some image services ignore that picture. Pollinations, for example, sends only the prompt and size. The "edit" then came back as a new picture: a full-body or redrawn result like the one #7681 fixed for GPT Image. The provider was still paid for it. - The same happened when the primary connection failed and the fallback image connection was one of those services. - Now Marinara refuses before paying for anything and tells the user what to pick: "This image connection can't edit pictures. Choose one that accepts a reference picture." ## What changed - **A table of which image services take a reference picture** (`imageConnectionTakesReferencePicture` in `image-generation.ts`). I read each provider's adapter. Where the model, base URL or workflow decides, the table entry is a check: - **Drop it:** Pollinations, Together AI, Horde, Venice, Z.AI and fal.ai. - **Depends on the model, URL or workflow:** - OpenAI: GPT Image models only. DALL-E and other models get a new-picture request. - Stability: not on the v1 API. - NovelAI's own host: V4.5 only. A NovelAI proxy gets the picture through chat completions. - Atlas Cloud: edit models only. This reuses the adapter's own check. - ComfyUI and RunPod: only when the workflow has a reference placeholder. ComfyUI's built-in workflow is text-to-image. - SwarmUI: without a custom workflow, or with a `%reference_image%` placeholder in it. Its adapter refuses file-name slots. - **Take it:** ChatGPT plan, Arli, NanoGPT, OpenRouter, xAI, AUTOMATIC1111/Draw Things, Gemini image and SpicyAPI. - **Avatar edits are refused on such a connection** in `resolveAvatarImageConnection`. That runs for the prompt review and for generation, before any picture is paid for. The check and the request use the same connection fields (`avatarImageService`), so they can't disagree. - **A fallback that would drop the picture is skipped for an edit** (`referenceIsCanvas`) in `generateImage`. The primary's error is reported and the skip is logged. A fallback that takes the picture is still used. - **SpicyAPI checks the model when the picture is requested.** Whether a SpicyAPI model takes a picture depends on its input schema, which is only read at that point. All three built-in SpicyAPI models are text-to-image. `generateSpicyApi` now refuses a canvas edit after the free model lookup and before the paid task is created. - **No conflict with #7664.** That PR (provider media queue) is already merged. This change sits on top of its lane code without touching it. - **Review fixes:** SwarmUI rejects workflows containing a file-name slot even alongside a supported picture slot. SpicyAPI checks picture support from the model schema before adding custom parameters, so a custom `image_url` cannot make a text-only model start a paid edit. The guide describes unsupported ComfyUI workflows without implying only one literal placeholder works. - Regression: `scripts/regressions/image-edit-reference.regression.ts`, including mixed-workflow and custom-field negative cases. ## 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 checks: - After the review fixes: `pnpm check` passes (one existing React hook warning in `HomeProfessorMariChat.tsx`); focused `image-edit-reference`, `spicyapi-image`, and `image-custom-parameters` regressions pass. - Local CodeRabbit rerun after these fixes: 1 finding, dismissed because translation follow-up #7732 is already linked below and remains open. Its wording was updated to match the final guide. No remaining substantive local findings. - `tsc --noEmit` for shared, server, client and root: pass. - `prettier --check` on the changed files: pass. - New regression `image-edit-reference`: pass. It **fails on staging** (the helper is missing). I also undid each part of the fix by itself, and each time it fails at the matching check: - without the avatar refusal: "Missing expected rejection"; - without the fallback skip: the fallback is asked; - without the SpicyAPI check: a task is created; - with Stability v1 counted as taking references: "Stability v1 is text-to-image". - Local CodeRabbit review: 1 finding, fixed in the second commit. A SwarmUI workflow that has only `%reference_image_name%` slots was counted as taking the picture. `buildSwarmUiGenerationBody` refuses those slots, so such a workflow is now refused too. The new table check fails without that commit. - Related regressions pass: avatar-generation, avatar-generation-cancel, avatar-backgrounds, avatar-vrm-generation, spicyapi-image, atlas-cloud-video-schema, codex-chatgpt-image, media-provider-lane, media-generation-cap, image-generation-timeout, image-custom-parameters, image-dimension-limit, image-response-limit, image-result-url-security, image-appearance-game, illustrator-character-prompts, illustrator-manual-cadence, swarmui-native-parameters, swarmui-timeout, openrouter-image-endpoint, novelai-character-caption-cap, novelai-zip-security, fal-image, gpt-image-2-5, provider-compat, regeneration-context and open-issues. ### Manual verification notes - Manually verify that 2D Avatars → make blink/talk pictures with a Pollinations image connection shows "This image connection can't edit pictures. Choose one that accepts a reference picture." in the prompt review, before anything is generated. - Manually verify that the same flow with a GPT Image (or another editing) connection still makes the blink/talk pictures as before. - Manually verify that with a primary editing connection that fails (for example a wrong API key) and a Pollinations fallback image connection, the variant shows the primary's error and no Pollinations picture is made. The server log should show the "skipped fallback connection" line. - Manually verify that a SpicyAPI connection with a text-to-image model is refused for blink/talk pictures and that no SpicyAPI task is billed. ## 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] <paths>` 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` (Blink and talk pictures) now says the image connection must accept a reference picture, that others are refused before anything is drawn, and that a fallback that can't take the picture is skipped. Translations: follow-up #7732. The new message is a server error that the avatar dialog already shows, so no UI copy or locale keys changed. ## UI evidence (if applicable) None: this changes the server only. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Avatar image generation now checks whether a connection supports reference pictures before starting, and reports a clear error when it does not. * Canvas edits no longer retry through a fallback that cannot accept reference pictures, preserving the original error instead. * Image edits now distinguish unsupported reference pictures from references that are too large, helping explain why an edit could not proceed. * Reference pictures are sent only to image models and workflows that support them. <!-- 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:08:36 +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#7894
No description provided.