mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
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#7836
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/7615
Author: @SpicyMarinara
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/7607-include-macro-user-message📝 Commits (2)
8c7b5f4fix(macros): fill in lorebook includes when a user message is sent (#7607)1ed6491fix(macros): give include expansion a deadline and keep includes without a chat (#7607)📊 Changes
3 files changed (+222 additions, -3 deletions)
View changed files
📝
packages/client/src/lib/chat-macros.ts(+35 -3)📝
packages/server/src/routes/lorebooks.routes.ts(+15 -0)➕
scripts/regressions/user-message-include-macro.regression.ts(+172 -0)📄 Description
Linked issue
Closes #7607
Why this change
{{random}}is rolled once and the chat shows the same text the model reads.{{include::Entry}}was skipped: it reads lorebook entries, and only the server has those. The message was saved as typed, the chat showed{{include::Test}}, and every new prompt filled it in again. A{{random}}inside the entry rolled differently on every turn, and editing the entry changed old messages.What changed
POST /api/lorebooks/expand-includes({ text, chatId }→{ text }). It only puts in the included entries. It reusesloadLorebookIncludesForandexpandLorebookIncludes, so it reads the same lorebooks as an include in a prompt: a plain name is looked up in the lorebooks the chat uses,BOOK::ENTRYand entry IDs reach any lorebook, nested includes work, and an include that loops back becomes empty. A missing entry also becomes empty, as it does in a prompt. Macro comments are removed first, the same orderresolveMacrosuses.prepareUserInputMessage(packages/client/src/lib/chat-macros.ts) calls that route through the newexpandMessageIncludesjust before its final macro pass, and only when the message uses{{include::. The final pass then fills in the entry's own macros ({{random}},{{user}}, …) together with the rest of the message. Plain messages make no extra request.console.warn.expandMessageIncludesis exported so Game turns can use it (see Notes for reviewers).scripts/regressions/user-message-include-macro.regression.ts. It runsprepareUserInputMessageagainst the real route and a real database. It also covers the 10-second limit and a send without a chat.Validation
pnpm checkpasses locallyCONTRIBUTING.mdCommands the agent ran locally (for reference, not ticked):
node ./scripts/run-regressions.mjs --filter scripts/regressions/user-message-include-macro.regression.ts: failed on unfixedstaging(a8481ca6d) with'Respond with: {{include::Test}}'instead of'Respond with: Random Number: 42 for Pat', and passes with the fix. The two later checks also failed before their own fixes: the no-chat send came back as'[]'instead of'[{{include::Test}}]', and the hanging-server check failed with "the request has a deadline".--filter macro(5/5),--filter lorebook(22/22),--filter include(2/2),--filter send-command-macros,--filter chat-persona-macros,--filter character-identity,--filter conversation-game-slash: all passed on the final head.pnpm regression:prompt: passed (3/3 files) on the final head.pnpm check: passed on the final head. The one ESLint warning (react-hooks/exhaustive-deps,serverRun) is already onstaging.coderabbit review --agent --committed --base-commit a8481ca6d): review completed with 0 findings, on both the first commit and the final head.Manual verification notes
Testwhose content isRandom Number: {{random:0:100}}. SendRespond with: {{include::Test}}. The chat should showRespond with: Random Number: N, not the raw macro.Nin that message and in Peek Prompt. Then edit the entry and check that the old message stays the same./send Respond with: {{include::Test}}store the same kind of filled-in text.{{include::Other lorebook::Entry}}with a lorebook that is not added to the chat. It should be filled in. A plain{{include::Entry}}for that entry should come out empty, as in a prompt.{{include::Test}}should still send, with the include as typed, and log one warning in the browser console.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)No docs were edited.
docs/prompts/macros.mdalready says macros typed in the chat message box are filled in before the message is sent, and includes now do that too.Notes for reviewers:
staging, a Game turn fills in no macros when it is sent. All of them,{{random}}too, are saved as typed and filled in at prompt time, so this PR has no Game send step to add includes to. The in-progressfix/send-followupschange adds that step inGameSurface.tsx, usingcreateInputMacroResolverForChatwithoutprepareUserInputMessage. It should calluserMessage = await expandMessageIncludes(userMessage, useChatStore.getState().activeChat?.id)before its resolver; otherwise a Game turn will save{{random}}filled in but{{include::…}}as typed. Its/remindusesprepareUserMessage, so it gets includes already. The two branches change different files.{{getvar::x}},{{model}},{{chatId}}and{{outlet::x}}inside an included entry are saved empty,{{lorebooksize::id}}is saved as0, and a{{setvar}}in the entry doesn't change the chat's variable. Before this PR, these got real values each time a prompt was built. Typed directly into the message, they have been saved empty since #7600. A later fix could give the client the chat'smacroVariables, or leave these macros as typed for the prompt. Either would change typed macros too, so it is left out of this PR.UI evidence (if applicable)
Not applicable. The change affects what is stored, and no UI was changed.
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.