[PR #1319] [MERGED] Fix ComfyUI indexed reference placeholders #5036

Closed
opened 2026-10-22 04:12:41 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1319
Author: @cha1latte
Created: 5/26/2026
Status: ✅ Merged
Merged: 5/26/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/refactor-issue-1275-comfyui-references


📝 Commits (2)

  • eace3b0 Fix ComfyUI indexed reference placeholders
  • 23d8054 Merge remote-tracking branch 'upstream/refactor' into fix/refactor-issue-1275-comfyui-references

📊 Changes

1 file changed (+153 additions, -14 deletions)

View changed files

📝 src-tauri/src/commands/storage/images/providers.rs (+153 -14)

📄 Description

Linked issue

Closes #1275

Why this change

  • ComfyUI workflows that use multiple reference image filename placeholders, such as %reference_image_name_01% and %reference_image_name_02%, currently only get the first/default placeholder substituted. Indexed placeholders leak into the prompt payload as raw text and ComfyUI rejects the workflow input.

What changed

  • Added ComfyUI reference filename token discovery for %reference_image_name% and one-based indexed placeholders like %reference_image_name_01%.
  • Uploads each referenced slot once, reuses slot 1 for both the default alias and _01, and uses the existing 1x1 placeholder image for missing indexed slots.
  • Added Rust regression coverage for alias/indexed token collection, embedded-token replacement, missing-slot fallback, and invalid-token negative controls.

Refactor impact

Primary owner:

Rust storage / runtime image generation integrations.

Impact areas reviewed:

  • Local ComfyUI workflow placeholder replacement.
  • Illustrator/chat image generation requests that provide multiple referenceImages.
  • Missing reference-image slot fallback behavior for ComfyUI filename placeholders.

Boundary notes:

  • The change stays inside the Rust ComfyUI provider path and does not change shared API request contracts, connection storage, prompt assembly, or client UI.

Pressure points touched:

  • src-tauri/src/commands/storage/images/providers.rs ComfyUI generation path.

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

  • Codex reproduced the pre-fix placeholder leak with node scratch\issue-1275-comfyui-repro.mjs; the current refactor replacement map left %reference_image_name_01% and %reference_image_name_02% raw.
  • Codex ran cargo test --manifest-path src-tauri\Cargo.toml comfy_reference_name; it passed and covered alias, _01, _02, embedded strings, missing-slot fallback, and invalid _00 / _abc negative controls.
  • Codex ran pnpm check; it passed after installing locked dependencies in the clean refactor worktree with pnpm install --frozen-lockfile.
  • Codex ran node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json; it passed.
  • No live ComfyUI server was configured in the Codex environment, so provider-network smoke testing against a real ComfyUI instance was not run.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

No docs or release metadata changes are needed; this is a narrow provider bugfix.

UI evidence

N/A - backend/provider workflow substitution bug with no visible UI state.

Summary by CodeRabbit

  • New Features

    • Enhanced reference image handling in ComfyUI workflows to support multiple indexed placeholders (e.g., _01, _02)
    • Reference images are now efficiently scanned, uploaded once per unique index with automatic deduplication
    • Added fallback placeholder support for cases where requested reference images are unavailable
  • Tests

    • Added comprehensive unit tests covering placeholder detection and workflow resolution

Review Change Stack


🔄 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/1319 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/26/2026 **Status:** ✅ Merged **Merged:** 5/26/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/refactor-issue-1275-comfyui-references` --- ### 📝 Commits (2) - [`eace3b0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/eace3b0d63502d8486063be53f74c4e45d8ca56c) Fix ComfyUI indexed reference placeholders - [`23d8054`](https://github.com/Pasta-Devs/Marinara-Engine/commit/23d8054d2eb9b4abf70eeee250586ef03bb96a98) Merge remote-tracking branch 'upstream/refactor' into fix/refactor-issue-1275-comfyui-references ### 📊 Changes **1 file changed** (+153 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/images/providers.rs` (+153 -14) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue <!-- Every user-facing PR should reference a feature request or issue report when practical. --> Closes #1275 ## Why this change <!-- What user problem, bug, refactor goal, or maintenance need does this solve? --> - ComfyUI workflows that use multiple reference image filename placeholders, such as `%reference_image_name_01%` and `%reference_image_name_02%`, currently only get the first/default placeholder substituted. Indexed placeholders leak into the prompt payload as raw text and ComfyUI rejects the workflow input. ## What changed <!-- List the key changes in this PR. --> - Added ComfyUI reference filename token discovery for `%reference_image_name%` and one-based indexed placeholders like `%reference_image_name_01%`. - Uploads each referenced slot once, reuses slot 1 for both the default alias and `_01`, and uses the existing 1x1 placeholder image for missing indexed slots. - Added Rust regression coverage for alias/indexed token collection, embedded-token replacement, missing-slot fallback, and invalid-token negative controls. ## Refactor impact Primary owner: <!-- Examples: app shell, catalog, chat mode, roleplay mode, game mode, runtime generation, world-state, shared API, engine generation, Rust storage, imports, remote runtime. --> Rust storage / runtime image generation integrations. Impact areas reviewed: - Local ComfyUI workflow placeholder replacement. - Illustrator/chat image generation requests that provide multiple `referenceImages`. - Missing reference-image slot fallback behavior for ComfyUI filename placeholders. Boundary notes: <!-- Note engine/shared-api/feature/Rust/remote-runtime boundaries. Say "none" only if you checked. --> - The change stays inside the Rust ComfyUI provider path and does not change shared API request contracts, connection storage, prompt assembly, or client UI. Pressure points touched: <!-- Mention ModeSurface, GameSurface, shared mode UI, src-tauri/src/lib.rs command registration, or import modules if touched. --> - `src-tauri/src/commands/storage/images/providers.rs` ComfyUI generation path. ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> - [ ] `pnpm check` passes locally - [ ] `pnpm typecheck` passes locally - [ ] `pnpm build` passes locally - [ ] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [ ] Remote runtime smoke checked when relevant ### Manual verification notes <!-- Describe exactly what you tested in a real browser/app/runtime, step by step. If an AI agent filled this out, verify it yourself before ticking boxes. --> - Codex reproduced the pre-fix placeholder leak with `node scratch\issue-1275-comfyui-repro.mjs`; the current refactor replacement map left `%reference_image_name_01%` and `%reference_image_name_02%` raw. - Codex ran `cargo test --manifest-path src-tauri\Cargo.toml comfy_reference_name`; it passed and covered alias, `_01`, `_02`, embedded strings, missing-slot fallback, and invalid `_00` / `_abc` negative controls. - Codex ran `pnpm check`; it passed after installing locked dependencies in the clean refactor worktree with `pnpm install --frozen-lockfile`. - Codex ran `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json`; it passed. - No live ComfyUI server was configured in the Codex environment, so provider-network smoke testing against a real ComfyUI instance was not run. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims No docs or release metadata changes are needed; this is a narrow provider bugfix. ## UI evidence <!-- Add before/after screenshots or recordings for visible UI changes. --> N/A - backend/provider workflow substitution bug with no visible UI state. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Enhanced reference image handling in ComfyUI workflows to support multiple indexed placeholders (e.g., `_01`, `_02`) * Reference images are now efficiently scanned, uploaded once per unique index with automatic deduplication * Added fallback placeholder support for cases where requested reference images are unavailable * **Tests** * Added comprehensive unit tests covering placeholder detection and workflow resolution <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/1319?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- 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-22 04:12:41 +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#5036
No description provided.