mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7494] [MERGED] feat(chat): Lorebook Reader chat tool #7761
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#7761
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/7494
Author: @SpicyMarinara
Created: 10/12/2026
Status: ✅ Merged
Merged: 10/12/2026
Merged by: @SpicyMarinara
Base:
staging← Head:feat/lorebook-reader-7464📝 Commits (4)
c334c5afeat(chat): add a Lorebook Reader chat tool (#7464)cdb7784test(chat): cover the Lorebook Reader end to end and document it (#7464)343171dfix(chat): mark folder-gated Reader entries off and keep variable macros per entry (#7464)df7a0c7fix(chat): Lorebook Reader review fixes📊 Changes
23 files changed (+1041 additions, -49 deletions)
View changed files
📝
docs/chats/chat-settings.md(+1 -1)📝
docs/lorebooks/overview.md(+13 -0)➕
e2e/lorebook-reader.e2e.ts(+157 -0)📝
packages/client/src/components/chat/ChatControlWindow.tsx(+3 -2)📝
packages/client/src/components/chat/ChatConversationSurface.tsx(+15 -2)📝
packages/client/src/components/chat/ChatRoleplaySurface.tsx(+25 -2)📝
packages/client/src/components/chat/ConversationView.tsx(+9 -4)➕
packages/client/src/components/chat/LorebookReaderWindow.tsx(+439 -0)📝
packages/client/src/components/chat/RoleplayHUD.tsx(+1 -15)📝
packages/client/src/components/chat/RoleplayTrackerWindow.tsx(+1 -1)📝
packages/client/src/features/tracker-panel/components/TrackerDataSidebar.tsx(+2 -1)📝
packages/client/src/hooks/use-capability-packages.ts(+14 -0)📝
packages/client/src/hooks/use-chats.ts(+4 -5)📝
packages/client/src/hooks/use-lorebooks.ts(+48 -10)📝
packages/client/src/lib/chat-help-targets.ts(+5 -1)➕
packages/client/src/lib/lorebook-reader.ts(+123 -0)📝
packages/client/src/localization/locales/en.json(+17 -0)📝
packages/server/src/routes/chats.routes.ts(+13 -5)📝
packages/shared/src/types/chat-preset.ts(+2 -0)📝
packages/shared/src/types/chat.ts(+2 -0)...and 3 more files
📄 Description
Linked issue
Closes #7464
Why this change
What changed
Nothing that worked before stops working.
{{user}},{{char}}and other macros are replaced with the chat's names in entry names and content, using the same resolver, preset variables and fallback names ("You", "Assistant") as chat messages. Each text resolves on its own, so a{{setvar}}in one entry never shows up in another and{{incvar}}does not count up on redraw. This is display only: entries are never changed.lorebookPinnedEntryIds), so they follow the chat across devices and into backups. The server stores them as a deduplicated list of strings and rejects anything else.selectRoleplayTrackerPackagesmoved fromRoleplayHUD.tsxtohooks/use-capability-packages.ts(next topartitionTrackerCapabilityPackages) so the roleplay surface can count them without loading the HUD; its callers import it from there.useEntriesAcrossLorebooksnow combines its queries with TanStack'scombine, so itsentriesarray keeps its identity between renders. Its other callers (Knowledge Router coverage, Agent Suite, Game setup) get the same values as before.docs/lorebooks/overview.mdgains a "Reading entries while you chat" section anddocs/chats/chat-settings.mdlists the Reader among the control windows. Translations: #7496.Validation
pnpm checkpasses locallyCONTRIBUTING.mdAgent-run checks on head
df7a0c7f2(review fixes on top of343171d40):pnpm check: passed. One existingreact-hooks/exhaustive-depswarning inHomeProfessorMariChat.tsx, which this PR does not touch.node ./scripts/run-regressions.mjs --filter scripts/regressions/lorebook-reader.regression.ts: passed. It covers grouping and order, OFF marking (entry, folder, per-chat), macros shown as names, variable macros kept to their own text, search on the displayed text, pin order and toggling, the view-only key and the profile exclusion. New in this round: rebuilding the list with the same display after an override change resolves an entry's text once, not again.--filter:chat-window-layout-persistence,open-issues,chat-window-icons,floating-window,chat-lorebook-entry-scope,chat-persona-macros,chat-window-defaults. Passed withnode:mobile-tracker-help-layout.regression.mjsandtracker-gallery-ui.regression.mjs, afterselectRoleplayTrackerPackagesmoved.pnpm exec playwright test e2e/lorebook-reader.e2e.ts --project=desktop-chromium --project=mobile-chromium: 4 passed. The e2e gained two checks. First, a quick double click on the pin button cancels out after both saves. Second, after pinning an entry from the bottom of a long list, Back shows it in Pinned, focused and in view. Both checks failed on343171d40. Not run onmobile-webkitlocally.343171d40, a pin click caused long tasks of 150, 279, 146 and 275 ms. Typing "mill" caused long tasks of 111, 54, 55 and 55 ms, and a double click on the pin button lost the pin. Ondf7a0c7f2, the pin click and the typing caused no long tasks, and the double click kept the pin. Opening the Reader still renders every row: about 2 s of long tasks in the dev build. The rows are not virtualized.343171d40(full-diff review plus CodeRabbit on GitHub). Fixed: Back brings a pinned or unpinned entry into view; macros resolve once per entry while the names and variables stay the same; search uses a deferred value and memoized rows; the fallback names match chat messages ("You", "Assistant"); a pin builds on the newest pins in the query cache; a folder load failure shows the load error; the Reader's bubble slot counts only the Beholder windows that render. Not changed: a lorebook turned off as a whole, or switched off for this chat, stays out of the Reader. That is the scope this PR set, and showing it is a product decision for the maintainer. The docs now say so. The suggested folder-data cache in the hook was not added. Its module-levelcombineholds no state, and a new folder set now reruns only the cheap OFF pass.coderabbit review --agent --committed, base9fd6e0900): 1 finding. It asked for a docs-i18n follow-up, which already exists as #7496 (linked above). The CLI cannot see the PR body. #7496 now also includes the docs sentence added in this round.c334c5aebandcdb7784b9: a full-diff review raised 10 points, and the CodeRabbit CLI was rate limited then. Fixed in343171d40: folder-gated entries show OFF; variable macros resolve per text;entrieskeeps its identity between renders; Beholder's slot is no longer reserved when the chat does not run it; the phone slot is passed. Not changed, with reasons:{{include::…}}and card-asset links render as they do in the editor preview, which also leaves them as written. Chat{{getvar}}values follow chat messages, which use preset variables. Stale pins are not pruned, so pins come back when a lorebook is switched back on for the chat.chat-window-default-upgrade,chat-window-migration,chat-settings-hint,chat-profile-followers,lorebook-test-scanande2e/chat-lorebook-entry-scope.e2e.ts, all passing on343171d40. This round does not touch their code paths.Manual verification notes
{{user}}/{{char}}shown as names.{{user}}shows as "You" in the Reader, as it does in chat messages.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)No CHANGELOG entry, per the 2026-10-12 policy: release notes come from "What changed" above.
UI evidence (if applicable)
Mockups from the issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7464
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
mari characters update --jsonpatches #7916