[PR #245] [MERGED] fix(server): scan endpoint shouldn't skip empty chats — CONST entries activate regardless #4527

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/245
Author: @Trade-Mottoes
Created: 4/26/2026
Status: ✅ Merged
Merged: 4/27/2026
Merged by: @LukaTheHero

Base: main ← Head: fix/lorebook-scan-skips-empty-chats


📝 Commits (1)

  • da64de8 fix(server): scan endpoint shouldn't skip empty chats — CONST entries activate regardless

📊 Changes

1 file changed (+2 additions, -1 deletions)

View changed files

📝 packages/server/src/routes/lorebooks.routes.ts (+2 -1)

📄 Description

The bug

Open a fresh chat that has a lorebook with CONST entries attached.
Open the Active World Info panel. It says "No active entries for
this chat" — but CONST entries activate unconditionally by definition,
they should be there. Send any message at all and they appear.

Repro:

  1. Create a lorebook with one entry, mark it Constant: true.
  2. Attach the lorebook to a character.
  3. Start a fresh chat with that character.
  4. Before sending anything, open the World Info panel — empty.
  5. Send any message — entries appear.

Root cause

/lorebooks/scan/:chatId had an early return that bailed out with
an empty result when chatMessages.length === 0. The intent was
probably "no messages → nothing can have triggered" — but that
ignores CONST, which doesn't need a trigger.

Fix

Drop the early return. processLorebooks() already handles the
empty-message case correctly: keyword-triggered entries don't fire
(nothing to match), and CONST entries activate as expected.

User-visible result

CONST entries appear in the Active World Info panel from the moment
a chat is created, matching their "always on" semantic.

Testing

  • pnpm lint && pnpm build pass.
  • Manual: fresh chat with a CONST-entry lorebook attached now shows
    the entry on first panel open, before any message is sent.

Summary by CodeRabbit

  • Bug Fixes
    • The scan endpoint now properly processes empty chats by applying consistent processing instead of returning a default response for chats with no messages.

🔄 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/245 **Author:** [@Trade-Mottoes](https://github.com/Trade-Mottoes) **Created:** 4/26/2026 **Status:** ✅ Merged **Merged:** 4/27/2026 **Merged by:** [@LukaTheHero](https://github.com/LukaTheHero) **Base:** `main` ← **Head:** `fix/lorebook-scan-skips-empty-chats` --- ### 📝 Commits (1) - [`da64de8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/da64de82119e859080299ffb317edfd02d2c3c95) fix(server): scan endpoint shouldn't skip empty chats — CONST entries activate regardless ### 📊 Changes **1 file changed** (+2 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/lorebooks.routes.ts` (+2 -1) </details> ### 📄 Description ## The bug Open a fresh chat that has a lorebook with CONST entries attached. Open the Active World Info panel. It says "No active entries for this chat" — but CONST entries activate unconditionally by definition, they should be there. Send any message at all and they appear. **Repro:** 1. Create a lorebook with one entry, mark it `Constant: true`. 2. Attach the lorebook to a character. 3. Start a fresh chat with that character. 4. Before sending anything, open the World Info panel — empty. 5. Send any message — entries appear. ## Root cause `/lorebooks/scan/:chatId` had an early return that bailed out with an empty result when `chatMessages.length === 0`. The intent was probably "no messages → nothing can have triggered" — but that ignores CONST, which doesn't need a trigger. ## Fix Drop the early return. `processLorebooks()` already handles the empty-message case correctly: keyword-triggered entries don't fire (nothing to match), and CONST entries activate as expected. ## User-visible result CONST entries appear in the Active World Info panel from the moment a chat is created, matching their "always on" semantic. ## Testing - `pnpm lint && pnpm build` pass. - Manual: fresh chat with a CONST-entry lorebook attached now shows the entry on first panel open, before any message is sent. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * The scan endpoint now properly processes empty chats by applying consistent processing instead of returning a default response for chats with no messages. <!-- 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:08:26 +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#4527
No description provided.