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#5944
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/3451
Author: @kolacheee
Created: 7/10/2026
Status: ✅ Merged
Merged: 7/10/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/3449-followup-relocation-if📝 Commits (1)
9be2011fix(macros): resolve #3449 relocation-{{#if}} regressions📊 Changes
2 files changed (+75 additions, -30 deletions)
View changed files
📝
packages/server/src/routes/generate.routes.ts(+41 -27)📝
packages/shared/src/utils/macro-engine.ts(+34 -3)📄 Description
Linked issue
Closes #3450 (fast-follow to the merged #3449 / #3448)
Why this change
A post-merge adversarial review of #3449 (relocation macros in
{{#if}}) found three regressions that shipped tostaging:{{context}}only inside a deferred conditional leaves no literal{{context}}after deferral. The context tail-fallback keyed onreplaceConversationContextMacro's return — which isfalsefor a deferred token — so it pushed the context block as a trailing user message and the decode pass inlined it. The current-context block (latest user message, status, activity, timestamp, mentions) was sent twice, every turn.{{#if …}}bodies.{{#if topic == "memories"}}(string literal) or{{#if user.status == "x"}}(dotted operand) matched the alias word and flipped the slot true, while the parser-based defer predicate correctly declined. With the slot wrongly set, the code took the "macro placed" branch (replacing a bare{{memories}}that isn't there) instead of the normal recall injection — silently dropping memory recall / react rules / commands / lorebook.trimDeferredStandaloneBranchestrimmed the leading newline only for branch 0, so a selected{{else}}/{{else if}}branch kept a stray blank line the evaluate-now path strips.What changed
Root cause of #1 and #2 is a slot-detection path that disagreed with the parser-based defer decision. Fix makes them share one parser:
packages/shared/src/utils/macro-engine.ts:collectDeferredRelocationConditionOperands(text)— reads the actual deferred tokens and returns their condition operands (sameparseConditionExpressionthe deferral uses).trimDeferredStandaloneBranches: trim the leading newline of whichever branch is selected, not just branch 0.packages/server/src/routes/generate.routes.ts:conversationContextMacroConditionPatternregex with token-driven slot detection: after the conversation macro pass, map each deferred-token operand back to its key viarelocationKeyForOperand(now shared with the defer predicate) and OR into the slots. Slot detection and deferral can no longer disagree — fixing both the over-match (dropped retrieval) and the inverse braced-operand miss.relocationKeyForOperandstays scoped toCONVERSATION_RELOCATION_MACRO_KEYS, preserving the About-me exclusion and coveringreplyRules.conversationContextMacroSlots.contextinstead of thereplace()return, so a deferred{{#if context}}no longer double-injects.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Automated checks I ran locally (green):
pnpm --filter @marinara-engine/shared build+pnpm --filter @marinara-engine/server lint(tsc) — cleanpnpm regression:prompt— full suite passes (61 checks, incl. the deferred-relocation cases added with #3449){{#if topic == "memories"}}and{{#if user.status …}}do not defer and yield no relocation operand (so retrieval is unaffected);{{#if char_about}}(about-me field) is not deferred; real bare / braced-mixed /{{#if replyRules}}references defer and collect their key operand.Still to verify manually in the app (please tick above once done):
{{#if context != ""}}…{{context}}…{{/if}}and no bare{{context}}→ context block appears once.{{#if topic == "memories"}}…{{/if}}and no bare{{memories}}→ memory recall still injected.{{#if memories != ""}}…{{else}}…{{/if}}with empty memories → else branch renders with no leading blank line.Docs and release impact
No docs/version changes; behavior-only bug fixes.
UI evidence (if applicable)
N/A (prompt-assembly logic).
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.