[PR #918] [MERGED] Fix NPC avatar matching for professor names #4837

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

📋 Pull Request Information

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

Base: staging ← Head: fix/prof-oak-sprite


📝 Commits (1)

  • a910293 Fix NPC avatar matching for professor names

📊 Changes

4 files changed (+91 additions, -10 deletions)

View changed files

📝 packages/server/src/routes/chats.routes.ts (+23 -4)
📝 packages/server/src/routes/game.routes.ts (+26 -5)
📝 packages/server/src/routes/generate.routes.ts (+6 -1)
➕ packages/server/src/services/game/npc-avatar-utils.ts (+36 -0)

📄 Description

Linked issue

No linked GitHub issue. Bug was reported directly in Codex; an issue should be opened before non-draft submission if the team wants one.

Why this change

  • Professor Oak could render with Professor Mari's built-in portrait in Game mode because the NPC avatar matcher treated the shared title word professor as a fuzzy avatar alias.

What changed

  • Treat professor as a title/honorific for NPC avatar aliases, so Professor Mari can still match Mari without matching every professor NPC.
  • Added a shared NPC avatar sanitizer that strips Mari's built-in avatar from non-Mari game NPCs.
  • Applied the sanitizer when reading chat metadata, hydrating Game mode metadata, upserting NPC avatar entries, and reusing stored NPC avatars during character-tracker updates.

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

Manual verification notes

  • Codex reproduced the bad state on the Pi app via http://100.64.240.39:7860/api/chats: chat KmSLNSsePLyUwHOuwZUb7 had gameNpcs[0].name as Professor Oak with avatarUrl set to /sprites/mari/Mari_profile.png.
  • Codex ran pnpm --dir packages/server exec tsx ../../scratch/prof-oak-avatar-repro.ts; the focused repro showed Oak no longer resolves from Mari-only aliases, exact Oak/title aliases still work, and stale Mari avatars are stripped from Professor Oak while preserved for Professor Mari.
  • Codex ran pnpm check; it passed.
  • Bunny review pass: passed for the current diff.
  • Recommended after deploy: visually confirm on the Pi Docker app that Professor Oak no longer renders Professor Mari's portrait in the active game chat.

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 docs, release metadata, schema, or dependency changes.

UI evidence (if applicable)

Original UI evidence was supplied in the bug report screenshot. The changed server path was verified with a focused repro script; a post-deploy visual check on the Pi Docker app is still recommended.


🔄 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/918 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/16/2026 **Status:** ✅ Merged **Merged:** 5/16/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `staging` ← **Head:** `fix/prof-oak-sprite` --- ### 📝 Commits (1) - [`a910293`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a910293cce656a65c093daa91975c977935ba4a6) Fix NPC avatar matching for professor names ### 📊 Changes **4 files changed** (+91 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/chats.routes.ts` (+23 -4) 📝 `packages/server/src/routes/game.routes.ts` (+26 -5) 📝 `packages/server/src/routes/generate.routes.ts` (+6 -1) ➕ `packages/server/src/services/game/npc-avatar-utils.ts` (+36 -0) </details> ### 📄 Description <!-- Target branch: `staging`. The default base in this UI is `main` (release branch). --> <!-- Change the base to `staging` before submitting unless this is a maintainer-approved mainline change. --> <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue <!-- Every PR should reference a feature request or issue report. If there isn't one yet, open one first to gather opinions: --> <!-- https://github.com/Pasta-Devs/Marinara-Engine/issues/new/choose --> No linked GitHub issue. Bug was reported directly in Codex; an issue should be opened before non-draft submission if the team wants one. ## Why this change <!-- What user problem, bug, or goal does this solve? --> - Professor Oak could render with Professor Mari's built-in portrait in Game mode because the NPC avatar matcher treated the shared title word `professor` as a fuzzy avatar alias. ## What changed <!-- List the key changes in this PR --> - Treat `professor` as a title/honorific for NPC avatar aliases, so `Professor Mari` can still match `Mari` without matching every professor NPC. - Added a shared NPC avatar sanitizer that strips Mari's built-in avatar from non-Mari game NPCs. - Applied the sanitizer when reading chat metadata, hydrating Game mode metadata, upserting NPC avatar entries, and reusing stored NPC avatars during character-tracker updates. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [ ] `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` ### Manual verification notes <!-- Describe exactly what you tested in a real browser/app, step by step. --> <!-- ⚠️ If an AI agent filled out or ticked these boxes for you, treat them --> <!-- as a TO-DO LIST, not as proof the work is done. Verify each item yourself --> <!-- before submitting. If you haven't verified it, untick the box. --> - Codex reproduced the bad state on the Pi app via `http://100.64.240.39:7860/api/chats`: chat `KmSLNSsePLyUwHOuwZUb7` had `gameNpcs[0].name` as `Professor Oak` with `avatarUrl` set to `/sprites/mari/Mari_profile.png`. - Codex ran `pnpm --dir packages/server exec tsx ../../scratch/prof-oak-avatar-repro.ts`; the focused repro showed Oak no longer resolves from Mari-only aliases, exact Oak/title aliases still work, and stale Mari avatars are stripped from Professor Oak while preserved for Professor Mari. - Codex ran `pnpm check`; it passed. - Bunny review pass: passed for the current diff. - Recommended after deploy: visually confirm on the Pi Docker app that Professor Oak no longer renders Professor Mari's portrait in the active game chat. ## 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 docs, release metadata, schema, or dependency changes. ## UI evidence (if applicable) Original UI evidence was supplied in the bug report screenshot. The changed server path was verified with a focused repro script; a post-deploy visual check on the Pi Docker app is still recommended. --- <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:04 +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#4837
No description provided.