[GH-ISSUE #594] [Issue]: Game Mode combat shows broken-image placeholders for enemies, no enemy portrait pipeline wired #275

Closed
opened 2026-10-20 17:27:03 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Romuromylus on GitHub (May 9, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/594

Originally assigned to: @Romuromylus on GitHub.

Summary

In Game Mode combat, enemy combatants render as broken-image icons. Two related defects: (1) the renderer treats enemy.sprite as a URL when the LLM is told to emit an emoji or short description, and (2) the enemyImagePrompts portrait-prompt array the encounter LLM is asked to produce is never consumed — there is no client code path that turns those into real portraits.

Expected behavior

  • When sprite generation is enabled, each unique enemy in a combat encounter should get a generated portrait via the same npcsNeedingAvatars pipeline used for in-scene NPCs. Identical-named enemies (e.g. three Goblins) reuse one portrait.
  • When generation is disabled or fails, the combat UI should still render something coherent — the LLM-suggested emoji glyph, or initials — never a broken-image placeholder.

Actual behavior

Each enemy renders as a broken <img> with the enemy name as alt text. Player party avatars on the same row render fine because they come from the character sheet's avatarUrl (a real URL). Two distinct root causes:

Defect 1 — renderer mismatch:

  • Encounter prompt at packages/server/src/routes/encounter.routes.ts:340 instructs the LLM to populate enemy.sprite with "emoji or brief visual description" — never a URL.
  • packages/client/src/components/game/GameSurface.tsx:492 (generatedEnemyToCombatant) forwards that string straight into Combatant.sprite.
  • packages/client/src/components/game/GameCombatUI.tsx renders <img src={combatant.sprite} /> at four sites (lines ~1336, ~1846, ~2345, ~2487). When sprite is an emoji or free-text description the <img> 404s.
  • packages/client/src/components/chat/EncounterModal.tsx:98 already renders enemy.sprite correctly as text content (<div className="text-2xl">{enemy.sprite || "👹"}</div>), confirming the original intent is "this is a glyph/emoji label, not a URL".

Defect 2 — pipeline never wired:

  • The encounter init prompt at packages/server/src/routes/encounter.routes.ts:359 asks the LLM to also emit visuals.enemyImagePrompts: [{name, prompt}], but no code reads that array.
  • The combat-init handler at packages/client/src/components/game/GameSurface.tsx:4830 only consumes visuals.backgroundPrompt and visuals.illustrationPrompt, gated on visuals.isBossFight && chatMeta.enableSpriteGeneration. Per-enemy portraits are never requested.
  • Meanwhile a fully-working npcsNeedingAvatars → generatedNpcAvatars pipeline already exists at packages/server/src/routes/game.routes.ts:6220 (caches by name, reuses character-library matches, persists to chat metadata). Combat just doesn't call it.

Steps to reproduce

  1. Open a Game Mode chat with sprite generation enabled and a working image-gen connection.
  2. Trigger an encounter (e.g. against a Tideborn Alpha + Tideborn Drone A + Tideborn Drone B party).
  3. Observe: enemy row shows broken-image placeholders. Player party at the bottom shows real avatars.

Environment

  • Marinara Engine version: 1.5.8 (fork main, post-#593 merge)
  • Install type: docker (EasyPanel autodeploy from fork)
  • OS + version: server-side container; browser any
  • Browser or app shell: web

Logs, screenshots, or video

Screenshot: enemies "Tideborn Alpha", "Tideborn Drone A", "Tideborn Drone B" all show as broken-image icons with the name leaking through as alt text, while "Sasuke Uchiha", "Emilia", "Barbara" show real portraits underneath.

Additional context

Suggested two-part fix (single PR):

  1. Renderer: add a resolveSpriteKind helper in GameCombatUI.tsx that classifies combatant.sprite as URL / emoji glyph / unrenderable, then route to <img> / span / initials accordingly. Apply to all four sprite sites.
  2. Pipeline: in the combat-init .then(...) handler in GameSurface.tsx, after hydrating combatants and before setCombatEnemies, build npcsNeedingAvatars from the deduped enemy list (using visuals.enemyImagePrompts[i].prompt if present, else enemy.description, else the name), call runGameAssetGeneration({ chatId, npcsNeedingAvatars }), and overwrite each combatant.sprite with the matching generatedNpcAvatars[i].avatarUrl. Block combat start until done; on any failure (timeout, gen disabled, no image connection) fall through silently and the renderer fix above keeps the UI coherent. No retries.

Respects the existing enableSpriteGeneration gate. Names dedupe so identical-named enemies share one portrait. Capped at the server's npcsNeedingAvatars.max(10) limit.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (May 9, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/594 Originally assigned to: @Romuromylus on GitHub. ## Summary In Game Mode combat, enemy combatants render as broken-image icons. Two related defects: (1) the renderer treats `enemy.sprite` as a URL when the LLM is told to emit an emoji or short description, and (2) the `enemyImagePrompts` portrait-prompt array the encounter LLM is asked to produce is never consumed — there is no client code path that turns those into real portraits. ## Expected behavior - When sprite generation is enabled, each unique enemy in a combat encounter should get a generated portrait via the same `npcsNeedingAvatars` pipeline used for in-scene NPCs. Identical-named enemies (e.g. three Goblins) reuse one portrait. - When generation is disabled or fails, the combat UI should still render something coherent — the LLM-suggested emoji glyph, or initials — never a broken-image placeholder. ## Actual behavior Each enemy renders as a broken `<img>` with the enemy name as alt text. Player party avatars on the same row render fine because they come from the character sheet's `avatarUrl` (a real URL). Two distinct root causes: **Defect 1 — renderer mismatch:** - Encounter prompt at `packages/server/src/routes/encounter.routes.ts:340` instructs the LLM to populate `enemy.sprite` with `"emoji or brief visual description"` — never a URL. - `packages/client/src/components/game/GameSurface.tsx:492` (`generatedEnemyToCombatant`) forwards that string straight into `Combatant.sprite`. - `packages/client/src/components/game/GameCombatUI.tsx` renders `<img src={combatant.sprite} />` at four sites (lines ~1336, ~1846, ~2345, ~2487). When `sprite` is an emoji or free-text description the `<img>` 404s. - `packages/client/src/components/chat/EncounterModal.tsx:98` already renders `enemy.sprite` correctly as text content (`<div className="text-2xl">{enemy.sprite || "👹"}</div>`), confirming the original intent is "this is a glyph/emoji label, not a URL". **Defect 2 — pipeline never wired:** - The encounter init prompt at `packages/server/src/routes/encounter.routes.ts:359` asks the LLM to also emit `visuals.enemyImagePrompts: [{name, prompt}]`, but no code reads that array. - The combat-init handler at `packages/client/src/components/game/GameSurface.tsx:4830` only consumes `visuals.backgroundPrompt` and `visuals.illustrationPrompt`, gated on `visuals.isBossFight && chatMeta.enableSpriteGeneration`. Per-enemy portraits are never requested. - Meanwhile a fully-working `npcsNeedingAvatars` → `generatedNpcAvatars` pipeline already exists at `packages/server/src/routes/game.routes.ts:6220` (caches by name, reuses character-library matches, persists to chat metadata). Combat just doesn't call it. ## Steps to reproduce 1. Open a Game Mode chat with sprite generation enabled and a working image-gen connection. 2. Trigger an encounter (e.g. against a `Tideborn Alpha + Tideborn Drone A + Tideborn Drone B` party). 3. Observe: enemy row shows broken-image placeholders. Player party at the bottom shows real avatars. ## Environment - Marinara Engine version: 1.5.8 (fork main, post-#593 merge) - Install type: docker (EasyPanel autodeploy from fork) - OS + version: server-side container; browser any - Browser or app shell: web ## Logs, screenshots, or video Screenshot: enemies "Tideborn Alpha", "Tideborn Drone A", "Tideborn Drone B" all show as broken-image icons with the name leaking through as alt text, while "Sasuke Uchiha", "Emilia", "Barbara" show real portraits underneath. ## Additional context Suggested two-part fix (single PR): 1. **Renderer:** add a `resolveSpriteKind` helper in `GameCombatUI.tsx` that classifies `combatant.sprite` as URL / emoji glyph / unrenderable, then route to `<img>` / span / initials accordingly. Apply to all four sprite sites. 2. **Pipeline:** in the combat-init `.then(...)` handler in `GameSurface.tsx`, after hydrating combatants and before `setCombatEnemies`, build `npcsNeedingAvatars` from the deduped enemy list (using `visuals.enemyImagePrompts[i].prompt` if present, else `enemy.description`, else the name), call `runGameAssetGeneration({ chatId, npcsNeedingAvatars })`, and overwrite each `combatant.sprite` with the matching `generatedNpcAvatars[i].avatarUrl`. Block combat start until done; on any failure (timeout, gen disabled, no image connection) fall through silently and the renderer fix above keeps the UI coherent. No retries. Respects the existing `enableSpriteGeneration` gate. Names dedupe so identical-named enemies share one portrait. Capped at the server's `npcsNeedingAvatars.max(10)` limit. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:27:03 +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#275
No description provided.