[PR #542] [MERGED] Fix lorebook triggers in prompt preview #4664

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

📋 Pull Request Information

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

Base: main ← Head: fix/issue-518-lorebook-context


📝 Commits (3)

  • bdbe5c5 Fix lorebook triggers in prompt preview
  • cd5be62 Clarify prompt preview runtime comment
  • 7d1d351 Guard prompt preview entry overrides

📊 Changes

2 files changed (+41 additions, -1 deletions)

View changed files

➕ docs/pr-evidence/issue-518/repro-output.txt (+13 -0)
📝 packages/server/src/routes/chats.routes.ts (+28 -1)

📄 Description

Linked issue

Closes #518

Why this change

  • Active World Info could report roleplay-triggered lorebook entries as active while the live assembled prompt preview omitted them. The preview assembled lorebook markers with only the default chat trigger context, while the scan/generation paths include the chat mode trigger such as roleplay or game.

What changed

  • Added mode-aware lorebook generation triggers to the live /api/chats/:id/peek-prompt assembler path.
  • Passed per-chat lorebook entry state overrides into that same preview assembly path so preview remains aligned with generation when entries are disabled or ephemeral in one chat.
  • Added committed command-output evidence for the issue repro.

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

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)

UI evidence (if applicable)

N/A. This is a server-side prompt preview assembly fix; the committed command evidence above captures the assembled prompt inclusion/exclusion behavior directly.

Summary by CodeRabbit

  • Improvements

    • Enhanced the prompt preview endpoint with refined trigger resolution logic based on chat mode, ensuring more consistent behavior across different chat configurations.
  • Tests

    • Added reproduction output documentation for issue validation.

🔄 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/542 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/8/2026 **Status:** ✅ Merged **Merged:** 5/8/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `main` ← **Head:** `fix/issue-518-lorebook-context` --- ### 📝 Commits (3) - [`bdbe5c5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bdbe5c5ed4f9da5a5d5c5a19e067b8e80b0d27ef) Fix lorebook triggers in prompt preview - [`cd5be62`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cd5be624e900bc0e76c6f8949ffbaa1d1e7a8816) Clarify prompt preview runtime comment - [`7d1d351`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7d1d351372ef7abee2dcf96e3478365af6f08cbd) Guard prompt preview entry overrides ### 📊 Changes **2 files changed** (+41 additions, -1 deletions) <details> <summary>View changed files</summary> ➕ `docs/pr-evidence/issue-518/repro-output.txt` (+13 -0) 📝 `packages/server/src/routes/chats.routes.ts` (+28 -1) </details> ### 📄 Description ## 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 --> Closes #518 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - Active World Info could report roleplay-triggered lorebook entries as active while the live assembled prompt preview omitted them. The preview assembled lorebook markers with only the default `chat` trigger context, while the scan/generation paths include the chat mode trigger such as `roleplay` or `game`. ## What changed <!-- List the key changes in this PR --> - Added mode-aware lorebook generation triggers to the live `/api/chats/:id/peek-prompt` assembler path. - Passed per-chat lorebook entry state overrides into that same preview assembly path so preview remains aligned with generation when entries are disabled or ephemeral in one chat. - Added committed command-output evidence for the issue repro. ## 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. --> - Machine repro: `pnpm --dir packages/server exec tsx ../../scratch/issue-518-repro.ts` - Repro proof: Active World Info-equivalent scan includes `constant-entry` and `roleplay-entry`; old preview-equivalent `chat`-only trigger context excludes the roleplay entry; fixed route-equivalent roleplay trigger context includes it. - Edge case: the same repro verifies a per-chat disabled `entryStateOverrides` entry remains excluded from preview. - Baseline: `pnpm check` passed locally. - Evidence: https://raw.githubusercontent.com/cha1latte/Marinara-Engine/bdbe5c5ed4f9da5a5d5c5a19e067b8e80b0d27ef/docs/pr-evidence/issue-518/repro-output.txt ## 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) ## UI evidence (if applicable) N/A. This is a server-side prompt preview assembly fix; the committed command evidence above captures the assembled prompt inclusion/exclusion behavior directly. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Improvements** * Enhanced the prompt preview endpoint with refined trigger resolution logic based on chat mode, ensuring more consistent behavior across different chat configurations. * **Tests** * Added reproduction output documentation for issue validation. <!-- 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-22 04:09: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#4664
No description provided.