[PR #923] [MERGED] feat(comfyui): add %reference_image_name% workflow placeholder #4840

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

📋 Pull Request Information

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

Base: staging ← Head: feat/comfyui-reference-image-upload


📝 Commits (3)

  • e027196 feat(comfyui): add %reference_image_name% workflow placeholder
  • 21a591f Merge branch 'staging' into feat/comfyui-reference-image-upload
  • ba77085 Merge branch 'staging' into feat/comfyui-reference-image-upload

📊 Changes

3 files changed (+41 additions, -5 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/client/src/components/connections/ConnectionEditor.tsx (+2 -1)
📝 packages/server/src/services/image/image-generation.ts (+38 -4)

📄 Description

Linked issue

Closes #922

Why this change

LoadImage is the standard ComfyUI node for loading an image from the input/ directory by filename. Marinara's existing %reference_image% placeholder inlines the image as a base64 string, which LoadImage can't read, that path only works with custom decode nodes like ETN_LoadImageBase64. Users running vanilla ComfyUI, or authoring workflows around the built-in LoadImage, currently have no way to use a reference image. ComfyUI already exposes POST /upload/image for exactly this purpose; this PR wires it in.

A new %reference_image_name% placeholder is added. When the workflow JSON contains it, Marinara uploads the reference image to ComfyUI's input/ folder and substitutes the returned filename, so vanilla LoadImage nodes can use the reference without any custom decode node.

The existing %reference_image% placeholder is unchanged. The two are fully independent: a workflow can use either one, the other, or both in the same workflow.

What changed

  • New helper uploadComfyReferenceImage(base, reference) in packages/server/src/services/image/image-generation.ts: decodes the existing base64 reference once via decodeReferenceImage, content-hashes it for a stable filename (marinara-ref-<sha256[:16]>.<ext>), POSTs multipart with overwrite=true, and returns the name ComfyUI assigns. Content-hashed filenames mean repeat references against the same image don't accumulate in input/.
  • Substitution branch in generateComfyUI: the upload only fires when the workflow JSON contains %reference_image_name%. %reference_image% is still set unconditionally whenever a reference exists, the structural walker replaceComfyUiPlaceholders is a no-op when the placeholder isn't in the workflow, so setting it is free.
  • Connection editor: workflow help text now documents both placeholders and the node setup each implies (ETN_LoadImageBase64 vs vanilla LoadImage). %reference_image_name% is added to the workflow validator's "unused placeholder" list as its own entry, treated independently from %reference_image%.
  • CHANGELOG entry under [Unreleased] / Added.

Validation

  • pnpm check passes locally
  • 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

Manual verification notes

  • Manually verify in browser: paste a ComfyUI workflow whose LoadImage node uses "image": "%reference_image_name%". Trigger a generation that supplies a reference image (sprite sheet, avatar, or Roleplay illustrator). Confirm the image generates and a marinara-ref-<hash>.<ext> file appears in ComfyUI's input/ folder.
  • Manually verify in browser: with the workflow textarea open in the connection editor, removing %reference_image% from the workflow surfaces it under "Unused"; removing %reference_image_name% surfaces that under "Unused"; using only one of the two doesn't flag the other.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)


🔄 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/923 **Author:** [@Yasyasyasvil](https://github.com/Yasyasyasvil) **Created:** 5/16/2026 **Status:** ✅ Merged **Merged:** 5/17/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/comfyui-reference-image-upload` --- ### 📝 Commits (3) - [`e027196`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e027196745c6e3ee0a583ccd4333170da49206e8) feat(comfyui): add %reference_image_name% workflow placeholder - [`21a591f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/21a591f7dca07523f4e9ecb209c01fdab0a3f1da) Merge branch 'staging' into feat/comfyui-reference-image-upload - [`ba77085`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ba77085b363fa9762888459dcbec63d6fcc862c3) Merge branch 'staging' into feat/comfyui-reference-image-upload ### 📊 Changes **3 files changed** (+41 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/client/src/components/connections/ConnectionEditor.tsx` (+2 -1) 📝 `packages/server/src/services/image/image-generation.ts` (+38 -4) </details> ### 📄 Description ## Linked issue Closes #922 ## Why this change `LoadImage` is the standard ComfyUI node for loading an image from the `input/` directory by filename. Marinara's existing `%reference_image%` placeholder inlines the image as a base64 string, which `LoadImage` can't read, that path only works with custom decode nodes like `ETN_LoadImageBase64`. Users running vanilla ComfyUI, or authoring workflows around the built-in `LoadImage`, currently have no way to use a reference image. ComfyUI already exposes `POST /upload/image` for exactly this purpose; this PR wires it in. A new `%reference_image_name%` placeholder is added. When the workflow JSON contains it, Marinara uploads the reference image to ComfyUI's `input/` folder and substitutes the returned filename, so vanilla `LoadImage` nodes can use the reference without any custom decode node. The existing `%reference_image%` placeholder is unchanged. The two are fully independent: a workflow can use either one, the other, or both in the same workflow. ## What changed - **New helper** `uploadComfyReferenceImage(base, reference)` in `packages/server/src/services/image/image-generation.ts`: decodes the existing base64 reference once via `decodeReferenceImage`, content-hashes it for a stable filename (`marinara-ref-<sha256[:16]>.<ext>`), POSTs multipart with `overwrite=true`, and returns the name ComfyUI assigns. Content-hashed filenames mean repeat references against the same image don't accumulate in `input/`. - **Substitution branch** in `generateComfyUI`: the upload only fires when the workflow JSON contains `%reference_image_name%`. `%reference_image%` is still set unconditionally whenever a reference exists, the structural walker `replaceComfyUiPlaceholders` is a no-op when the placeholder isn't in the workflow, so setting it is free. - **Connection editor**: workflow help text now documents both placeholders and the node setup each implies (`ETN_LoadImageBase64` vs vanilla `LoadImage`). `%reference_image_name%` is added to the workflow validator's "unused placeholder" list as its own entry, treated independently from `%reference_image%`. - **CHANGELOG entry** under `[Unreleased] / Added`. ## Validation - [x] `pnpm check` passes locally - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - [x] Manually verify in browser: paste a ComfyUI workflow whose `LoadImage` node uses `"image": "%reference_image_name%"`. Trigger a generation that supplies a reference image (sprite sheet, avatar, or Roleplay illustrator). Confirm the image generates and a `marinara-ref-<hash>.<ext>` file appears in ComfyUI's `input/` folder. - [x] Manually verify in browser: with the workflow textarea open in the connection editor, removing `%reference_image%` from the workflow surfaces it under "Unused"; removing `%reference_image_name%` surfaces *that* under "Unused"; using only one of the two doesn't flag the other. ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:11:05 +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#4840
No description provided.