mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #845] [MERGED] feat(lorebooks): add keyword-test panel to lorebook editor #4804
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#4804
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/845
Author: @Romuromylus
Created: 5/14/2026
Status: ✅ Merged
Merged: 5/14/2026
Merged by: @Romuromylus
Base:
main← Head:feat/lorebook-keyword-test-panel📝 Commits (3)
7c7d5ecfeat(lorebooks): add keyword-test panel to lorebook editor (#816)52ebd4dMerge branch 'main' into feat/lorebook-keyword-test-panelab42137Merge branch 'main' into feat/lorebook-keyword-test-panel📊 Changes
5 files changed (+241 additions, -81 deletions)
View changed files
📝
packages/client/src/components/lorebooks/LorebookEditor.tsx(+119 -0)📝
packages/client/src/components/lorebooks/LorebookEntryRow.tsx(+41 -1)📝
packages/server/src/services/lorebook/keyword-scanner.ts(+1 -80)📝
packages/shared/src/index.ts(+1 -0)➕
packages/shared/src/utils/lorebook-keyword-matching.ts(+79 -0)📄 Description
Linked issue
Closes #816
Why this change
Lorebook authors — especially newcomers to World Info — don't have a good way to sanity-check which entries would actually be triggered by a given paragraph of chat text. Today the only ways to find out are (a) load the lorebook into a chat and roleplay until you happen to hit the keys, or (b) read every entry's keys list and mentally simulate the matcher (which gets unwieldy with regex / whole-word / case-sensitive / selective + secondary-keys / selectiveLogic in the mix). The result is keys that fire too eagerly or not at all, and bloated entries that the author has no fast feedback loop to tune.
This adds a focused authoring aid right where the entries are edited: paste sample text, see which entries that text would activate.
Per maintainer triage on #816 (cha1latte's
normal-scopelabel and "least risky next step is to keep it scoped to keyword-trigger preview behavior"), this PR deliberately covers only the keyword-trigger preview surface. Context-budget, memory-aware, and runtime-state simulation are not included.What changed
New collapsible "Keyword test" panel at the top of the Entries tab (
packages/client/src/components/lorebooks/LorebookEditor.tsx). Collapsed by default so it doesn't crowd the editor for users who don't need it. When expanded:N matches).N of M enabled entries would activate.Per-row match indicator (
packages/client/src/components/lorebooks/LorebookEntryRow.tsx). When the preview is active, matched entries get:Shared keyword-matching helpers (
packages/shared/src/utils/lorebook-keyword-matching.ts). The three pure functions that decide whether a key matches text —testKeyword,testPrimaryKeys,testSecondaryKeys— were previously inline inpackages/server/src/services/lorebook/keyword-scanner.ts. Moved them to a new shared util module so the editor preview and the real server scanner use the same code path. This is the load-bearing piece of the PR: it prevents the preview from drifting from real activation behavior over time.Server scanner now imports the shared helpers. No behavior change on the server — the deleted local copies were byte-identical to the new shared versions.
Explicit scope
In scope (preview honors these):
keys(primary)secondaryKeys+selective+selectiveLogicuseRegex,matchWholeWords,caseSensitiveenabled(disabled entries are skipped)constant(flagged separately as "Always active")Out of scope (deliberately not simulated):
sticky/cooldown/delay(no chat history → no runtime state)probability(preview should be deterministic)characterFilterMode/characterTagFilterMode/generationTriggerFilterMode(depend on a live chat context)groupWeight(out of scope per triage)These can land in follow-up PRs if the keyword-only preview proves useful.
Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
N matches, and the summary line showsN of M enabled entries would activate.enabled: falseshort-circuits before constant).^Mr\.\s+\w+) and confirm the preview honors the regex flag.caseSensitiveandmatchWholeWordson an entry and confirm preview matches change accordingly.I tested most of these on my fork deployment with a real lorebook (23 entries, Selective mode mix); leaving the boxes unchecked per repo CLAUDE.md so the maintainer can re-verify on their own setup.
Docs and release impact
UI evidence (if applicable)
The panel's collapsed state shows only the flask icon and the
Keyword testlabel inline with the search/sort row. Expanded shows the scope blurb, textarea, and (when text is present) the summary line. Per-row indicators are a 3px emerald (or amber for constant) left-edge stripe + an emerald (or amber)sparkles + Would activate(orAlways active) chip placed immediately after the status dot.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.