[PR #5220] [MERGED] Fix Game portrait recovery replacing library avatars #6676

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5220
Author: @SpicyMarinara
Created: 8/18/2026
Status: ✅ Merged
Merged: 8/18/2026
Merged by: @SpicyMarinara

Base: staging ← Head: agent/4746-preserve-existing-game-portraits


📝 Commits (1)

  • 00124b4 Preserve library portraits during game asset recovery

📊 Changes

3 files changed (+85 additions, -2 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/client/src/components/game/game-asset-generation-payload.ts (+15 -2)
➕ scripts/regressions/game-portrait-recovery.regression.ts (+69 -0)

📄 Description

Linked issue

Closes #4746

Why this change

Game Mode's automatic asset recovery treated every existing portrait as a game-owned generated NPC file. When a saved scene background was missing or an avatar emitted a load error, the client sent the character name in forceNpcAvatarNames. The server then intentionally bypassed both its existing-avatar check and its Character-library lookup, generating and persisting a replacement for a matching Character portrait.

What changed

  • Restrict automatic forced portrait recovery to files owned by the current game under /api/avatars/npc/<chatId>/....
  • Keep matching Character-library avatars authoritative during missing-background and portrait-load recovery.
  • Preserve explicit manual Generate portrait behavior.
  • Add a focused regression for both recovery triggers and both avatar ownership classes.
  • Add the user-facing fix under CHANGELOG.md [Unreleased].

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 evidence

  • node scripts/run-regressions.mjs --filter scripts/regressions/game-portrait-recovery.regression.ts
  • pnpm localization:check
  • pnpm check

Manual verification notes

  • Manual browser verification remains requested for a Game Mode chat where a Character-library portrait encounters an image load error.
  • Checklist boxes remain intentionally unchecked for human verification.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened
  • Version/release files updated (only if this PR includes a version bump)

No user-facing documentation or release metadata changed. CHANGELOG.md is updated under [Unreleased].

UI evidence (if applicable)

No visual UI changes.

Summary by CodeRabbit

  • Bug Fixes

    • Prevented Game Mode from overwriting matching Character Library portraits when restoring missing scene backgrounds or retrying failed portrait loads.
    • Ensured NPC portrait recovery only uses avatars belonging to the active chat.
    • Improved recovery for generated NPC avatars while preserving existing library portraits.
  • Tests

    • Added regression coverage for portrait recovery scenarios.

🔄 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/5220 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 8/18/2026 **Status:** ✅ Merged **Merged:** 8/18/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `agent/4746-preserve-existing-game-portraits` --- ### 📝 Commits (1) - [`00124b4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/00124b40a5e3faee6c9f56010e0a9c6b4b850104) Preserve library portraits during game asset recovery ### 📊 Changes **3 files changed** (+85 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/client/src/components/game/game-asset-generation-payload.ts` (+15 -2) ➕ `scripts/regressions/game-portrait-recovery.regression.ts` (+69 -0) </details> ### 📄 Description ## Linked issue Closes #4746 ## Why this change Game Mode's automatic asset recovery treated every existing portrait as a game-owned generated NPC file. When a saved scene background was missing or an avatar emitted a load error, the client sent the character name in `forceNpcAvatarNames`. The server then intentionally bypassed both its existing-avatar check and its Character-library lookup, generating and persisting a replacement for a matching Character portrait. ## What changed - Restrict automatic forced portrait recovery to files owned by the current game under `/api/avatars/npc/<chatId>/...`. - Keep matching Character-library avatars authoritative during missing-background and portrait-load recovery. - Preserve explicit manual **Generate portrait** behavior. - Add a focused regression for both recovery triggers and both avatar ownership classes. - Add the user-facing fix under `CHANGELOG.md` `[Unreleased]`. ## 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 evidence - `node scripts/run-regressions.mjs --filter scripts/regressions/game-portrait-recovery.regression.ts` - `pnpm localization:check` - `pnpm check` ### Manual verification notes - Manual browser verification remains requested for a Game Mode chat where a Character-library portrait encounters an image load error. - Checklist boxes remain intentionally unchecked for human verification. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened - [ ] Version/release files updated (only if this PR includes a version bump) No user-facing documentation or release metadata changed. `CHANGELOG.md` is updated under `[Unreleased]`. ## UI evidence (if applicable) No visual UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Prevented Game Mode from overwriting matching Character Library portraits when restoring missing scene backgrounds or retrying failed portrait loads. - Ensured NPC portrait recovery only uses avatars belonging to the active chat. - Improved recovery for generated NPC avatars while preserving existing library portraits. - **Tests** - Added regression coverage for portrait recovery scenarios. <!-- 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:12:39 +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#6676
No description provided.