[PR #5935] [MERGED] Issue Sweep: lorebook persistence and Game portraits #6997

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

📋 Pull Request Information

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

Base: staging ← Head: fix/issue-sweep-generation-sep7


📝 Commits (5)

  • b018d0a chore: claim assigned lorebook and Game avatar issues
  • bb22f70 fix: preserve selected lorebooks and Game NPC portrait identity
  • 3f1d989 Merge remote-tracking branch 'origin/staging' into fix/issue-sweep-generation-sep7
  • 92830c9 fix(game): remove unrelated speaker fallback and reuse loaded metadata
  • 63abb86 fix(game): use refreshed party scope for queued portraits

📊 Changes

14 files changed (+352 additions, -198 deletions)

View changed files

📝 CHANGELOG.md (+4 -0)
➕ e2e/game-npc-portraits.e2e.ts (+125 -0)
📝 packages/client/src/components/game/GameSurface.tsx (+20 -142)
📝 packages/server/src/routes/chats.routes.ts (+1 -0)
📝 packages/server/src/routes/game.routes.ts (+25 -54)
📝 packages/server/src/routes/generate.routes.ts (+6 -0)
📝 packages/server/src/routes/generate/agent-write-approval.ts (+2 -0)
📝 packages/server/src/routes/generate/lorebook-keeper-utils.ts (+4 -1)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+5 -0)
📝 packages/server/src/services/game/npc-avatar-utils.ts (+15 -0)
📝 packages/server/src/services/lorebook/keyword-scanner.ts (+2 -1)
➕ scripts/regressions/grouped-sticky-lorebook.regression.ts (+57 -0)
➕ scripts/regressions/lorebook-selected-target.regression.ts (+65 -0)
➕ scripts/regressions/npc-avatar-lan.regression.ts (+21 -0)

📄 Description

Linked issue

Closes #5913, #5907, #5885, #5887.

Why this change

Assigned issue sweep for @SpicyMarinara. Sticky group entries were competing with fresh matches before their lifetime expired. Model-proposed Lorebook Keeper destinations could override the selected target. Game portrait paths still searched unrelated library cards and could replace a campaign NPC's portrait; legacy loopback URLs failed on LAN clients.

What changed

  • Prefer still-sticky candidates during existing weighted group selection.
  • Carry explicit Lorebook Keeper target selection through automatic runs, retries/backfill and approval. Keep automatic routing when no target was selected, and retain locked-entry protection.
  • Reuse the existing Game character ID scope and avatar lookup. Do not search unrelated library cards or overwrite an existing NPC portrait.
  • Normalize legacy loopback Engine avatar URLs to same-origin paths, preserving queries and leaving external resources untouched.

Automated evidence

  • pnpm check passed; pnpm check:e2e-types passed after adding the browser proof.
  • pnpm regression:prompt and open-issues.regression.ts passed.
  • Focused regressions passed for grouped sticky lifetime/expiry, selected versus automatic lorebook routing and locked entries, and legacy LAN URLs.
  • Browser regression passed on desktop Chromium, mobile Chromium and mobile WebKit: same-name unrelated library card, existing portrait retained, reload, LAN-safe URL, and missing portrait stays unbound. No paid generation calls.

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

Manually verify a real Lorebook Keeper automatic run and retry with a selected target, a grouped lorebook through its sticky duration, and Game portraits on a second LAN device. Automated browser emulation is not a physical iPhone claim. No downloadable-agent prompts or packages were changed.

Docs and release impact

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

UI evidence

Existing Game portrait presentation is reused; desktop and both mobile browser projects exercise the real narration surface.

Summary by CodeRabbit

  • Bug Fixes
    • Grouped lorebook entries now remain selected for their configured sticky duration.
    • Lorebook Keeper respects explicitly selected targets during automatic runs, retries, and approvals, while retaining automatic routing when no target is selected.
    • Game NPC portraits no longer inherit unrelated same-name library portraits or replace existing portraits.
    • Legacy local avatar links now resolve correctly for LAN clients, keeping portraits visible when accessing games remotely.
    • NPC portrait data remains consistent after page reloads and metadata updates.

🔄 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/5935 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/7/2026 **Status:** ✅ Merged **Merged:** 9/7/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/issue-sweep-generation-sep7` --- ### 📝 Commits (5) - [`b018d0a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b018d0a9251f12d91276e3b0b19017a8c6543be7) chore: claim assigned lorebook and Game avatar issues - [`bb22f70`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bb22f705f60c62565c2114cf2e0350ff7fc48401) fix: preserve selected lorebooks and Game NPC portrait identity - [`3f1d989`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3f1d9895e74ee2953b1b3414c61da4f0a58488de) Merge remote-tracking branch 'origin/staging' into fix/issue-sweep-generation-sep7 - [`92830c9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/92830c911cd4d2985e51921cec608de92c249368) fix(game): remove unrelated speaker fallback and reuse loaded metadata - [`63abb86`](https://github.com/Pasta-Devs/Marinara-Engine/commit/63abb86e41b51134ba175c956f24d3a372866e90) fix(game): use refreshed party scope for queued portraits ### 📊 Changes **14 files changed** (+352 additions, -198 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+4 -0) ➕ `e2e/game-npc-portraits.e2e.ts` (+125 -0) 📝 `packages/client/src/components/game/GameSurface.tsx` (+20 -142) 📝 `packages/server/src/routes/chats.routes.ts` (+1 -0) 📝 `packages/server/src/routes/game.routes.ts` (+25 -54) 📝 `packages/server/src/routes/generate.routes.ts` (+6 -0) 📝 `packages/server/src/routes/generate/agent-write-approval.ts` (+2 -0) 📝 `packages/server/src/routes/generate/lorebook-keeper-utils.ts` (+4 -1) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+5 -0) 📝 `packages/server/src/services/game/npc-avatar-utils.ts` (+15 -0) 📝 `packages/server/src/services/lorebook/keyword-scanner.ts` (+2 -1) ➕ `scripts/regressions/grouped-sticky-lorebook.regression.ts` (+57 -0) ➕ `scripts/regressions/lorebook-selected-target.regression.ts` (+65 -0) ➕ `scripts/regressions/npc-avatar-lan.regression.ts` (+21 -0) </details> ### 📄 Description ## Linked issue Closes #5913, #5907, #5885, #5887. ## Why this change Assigned issue sweep for @SpicyMarinara. Sticky group entries were competing with fresh matches before their lifetime expired. Model-proposed Lorebook Keeper destinations could override the selected target. Game portrait paths still searched unrelated library cards and could replace a campaign NPC's portrait; legacy loopback URLs failed on LAN clients. ## What changed - Prefer still-sticky candidates during existing weighted group selection. - Carry explicit Lorebook Keeper target selection through automatic runs, retries/backfill and approval. Keep automatic routing when no target was selected, and retain locked-entry protection. - Reuse the existing Game character ID scope and avatar lookup. Do not search unrelated library cards or overwrite an existing NPC portrait. - Normalize legacy loopback Engine avatar URLs to same-origin paths, preserving queries and leaving external resources untouched. ## Automated evidence - `pnpm check` passed; `pnpm check:e2e-types` passed after adding the browser proof. - `pnpm regression:prompt` and `open-issues.regression.ts` passed. - Focused regressions passed for grouped sticky lifetime/expiry, selected versus automatic lorebook routing and locked entries, and legacy LAN URLs. - Browser regression passed on desktop Chromium, mobile Chromium and mobile WebKit: same-name unrelated library card, existing portrait retained, reload, LAN-safe URL, and missing portrait stays unbound. No paid generation calls. ## 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 Manually verify a real Lorebook Keeper automatic run and retry with a selected target, a grouped lorebook through its sticky duration, and Game portraits on a second LAN device. Automated browser emulation is not a physical iPhone claim. No downloadable-agent prompts or packages were changed. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on `docs-i18n` updated or a follow-up issue opened - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence Existing Game portrait presentation is reused; desktop and both mobile browser projects exercise the real narration surface. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Grouped lorebook entries now remain selected for their configured sticky duration. - Lorebook Keeper respects explicitly selected targets during automatic runs, retries, and approvals, while retaining automatic routing when no target is selected. - Game NPC portraits no longer inherit unrelated same-name library portraits or replace existing portraits. - Legacy local avatar links now resolve correctly for LAN clients, keeping portraits visible when accessing games remotely. - NPC portrait data remains consistent after page reloads and metadata updates. <!-- 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:15:36 +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#6997
No description provided.