[PR #3729] [MERGED] fix(image): prevent duplicate prompt inputs #6074

Closed
opened 2026-10-23 04:06:51 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3729
Author: @JurijPietrowicz
Created: 7/17/2026
Status: ✅ Merged
Merged: 7/17/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/image-prompt-generation-issues


📝 Commits (2)

  • 8be882d fix(image): prevent duplicate prompt inputs
  • a09d48f fix(image): protect compacted appearance inputs

📊 Changes

3 files changed (+326 additions, -28 deletions)

View changed files

📝 packages/server/src/services/game/game-asset-generation.ts (+22 -11)
📝 packages/shared/src/utils/image-prompt-compiler.ts (+109 -17)
📝 scripts/regressions/prompt.regression.ts (+195 -0)

📄 Description

Linked issue

Closes #3728

Why this change

  • Image builders can embed an explicit art style or appearance in the source prompt while also passing the same value separately to the shared compiler, causing duplicated provider-visible prompt content.
  • Deduplicating too early can also remove the dedicated style before compact-token or storyboard-character limits discard the source copy, silently losing the configured style.

What changed

  • Detect complete normalized duplicates using the effective prompt grammar so negative clauses are not mistaken for positive style copies.
  • Recheck the transformed provider-visible prompt and protect the explicit style when compaction would otherwise remove its only positive copy.
  • Limit preserved-storyboard deduplication to source text guaranteed to survive final 7,000-character assembly.
  • Add regressions across built-in profiles, image kinds, compact-token limits, semicolon and embedded negative clauses, appearance cues, and storyboard truncation.

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

Automated validation performed:

  • pnpm regression:prompt
  • pnpm check

Manual verification notes

  • The reporter manually confirmed that the original Z-Image portrait duplication was removed before the compact/truncation hardening.
  • The reporter manually confirmed a Z-Image portrait with an explicit art style shows the style exactly once in the provider prompt.
  • The reporter manually confirmed other styles retain their art styles.
  • The reporter manually confirmed a long preserved storyboard prompt retains the configured art style after final truncation.

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)

No documentation or release metadata changes are expected because this is an internal prompt-assembly correction.

UI evidence (if applicable)

Not applicable; no UI changes.

Summary by CodeRabbit

  • Improvements
    • Improved image prompt compilation to preserve important style and scene details when prompts approach length limits.
    • Reduced repeated style and appearance instructions in generated image prompts for cleaner, more consistent results.
    • Improved handling of preserved scenes, portraits, backgrounds, illustrations, and storyboard prompts during truncation.
    • Ensured configured styles remain represented once, including compact prompts and prompts containing negated or embedded variations.

🔄 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/3729 **Author:** [@JurijPietrowicz](https://github.com/JurijPietrowicz) **Created:** 7/17/2026 **Status:** ✅ Merged **Merged:** 7/17/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/image-prompt-generation-issues` --- ### 📝 Commits (2) - [`8be882d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8be882d3b06884b62c10e722f4deb59a50652eaf) fix(image): prevent duplicate prompt inputs - [`a09d48f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a09d48f33949acaa098a75b62d5b72ad67afaacd) fix(image): protect compacted appearance inputs ### 📊 Changes **3 files changed** (+326 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/game/game-asset-generation.ts` (+22 -11) 📝 `packages/shared/src/utils/image-prompt-compiler.ts` (+109 -17) 📝 `scripts/regressions/prompt.regression.ts` (+195 -0) </details> ### 📄 Description ## Linked issue Closes #3728 ## Why this change - Image builders can embed an explicit art style or appearance in the source prompt while also passing the same value separately to the shared compiler, causing duplicated provider-visible prompt content. - Deduplicating too early can also remove the dedicated style before compact-token or storyboard-character limits discard the source copy, silently losing the configured style. ## What changed - Detect complete normalized duplicates using the effective prompt grammar so negative clauses are not mistaken for positive style copies. - Recheck the transformed provider-visible prompt and protect the explicit style when compaction would otherwise remove its only positive copy. - Limit preserved-storyboard deduplication to source text guaranteed to survive final 7,000-character assembly. - Add regressions across built-in profiles, image kinds, compact-token limits, semicolon and embedded negative clauses, appearance cues, and storyboard truncation. ## Validation - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] 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) - [x] Read and followed `CONTRIBUTING.md` Automated validation performed: - `pnpm regression:prompt` - `pnpm check` ### Manual verification notes - The reporter manually confirmed that the original Z-Image portrait duplication was removed before the compact/truncation hardening. - The reporter manually confirmed a Z-Image portrait with an explicit art style shows the style exactly once in the provider prompt. - The reporter manually confirmed other styles retain their art styles. - The reporter manually confirmed a long preserved storyboard prompt retains the configured art style after final truncation. ## 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) No documentation or release metadata changes are expected because this is an internal prompt-assembly correction. ## UI evidence (if applicable) Not applicable; no UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Improvements** * Improved image prompt compilation to preserve important style and scene details when prompts approach length limits. * Reduced repeated style and appearance instructions in generated image prompts for cleaner, more consistent results. * Improved handling of preserved scenes, portraits, backgrounds, illustrations, and storyboard prompts during truncation. * Ensured configured styles remain represented once, including compact prompts and prompts containing negated or embedded variations. <!-- 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-23 04:06:51 +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#6074
No description provided.