mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3435] [Issue]: New conversation macros don't resolve inside {{#if}} conditions (block always renders); removed blocks leave blank lines #1858
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#1858
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?
Originally created by @kolacheee on GitHub (Jul 10, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3435
Originally assigned to: @kolacheee on GitHub.
Summary
Two problems when using the new Conversation preset macros inside
{{#if}}blocks:{{#if char_about != ""}}is always true — the block renders even when the macro's value is empty — because the{{#if}}condition evaluator doesn't resolve the new conversation macros.{{#if}}block is removed, it leaves an extra blank line.Expected behavior
{{#if char_about != ""}}evaluates the actual value of{{char_about}}— so the block is hidden when the about-me is empty.{{#if}}block leaves no blank line.Actual behavior
This template:
resolves to (note
- Locutus:renders with an empty about, and the spacing has extra blank lines):Steps to reproduce
{{#if char_about != ""}}- {{char}}: {{char_about}}{{/if}}.Environment
Logs, screenshots, or video
See the before/after template above.
Additional context
Bug 1 root cause (verified on staging): the
{{#if}}condition evaluator and the flat{{...}}substitution use two different, non-shared resolution paths, and the new conversation macros were only added to the flat pass.char_about != ""is resolved byresolveConditionalOperand(packages/shared/src/utils/macro-engine.ts:634-701), whoseswitchhas cases forchar/user/persona/description/… but none forchar_about/persona_about(norreactRules/commands/status/context). It falls through to the defaultreturn ctx.variables[token] ?? token(~:698), returning the unresolved literal string"char_about"."char_about" !== ""→ true, so the block always renders.{{char_about}}/{{persona_about}}are only resolved to their real values in the flat replace pass (macro-engine.ts:1298-1299, fromctx.convoFields), which runs on the block body — after the condition has already (wrongly) passed → hence- Locutus:with an empty about.{{char_about}} != ""with braces happens to work today, because a pre-pass expands braced macros before the condition is parsed. But bare tokens are the intended{{#if}}convention.)Suggested fix: make the condition evaluator resolve the same macro set as the flat pass — ideally route unknown bare operands through the full macro resolver (so any macro valid in
{{...}}is also valid inside{{#if}}), instead of thectx.variables[token] ?? tokenfallback. Mirror inisCharacterConditionalOperand/conditionDependsOnCharacterif those gate per-character re-evaluation.Bug 2 (the extra blank lines) root cause (verified): the macro engine never "chomps" the newline of a standalone block tag. When an
{{#if}}block is false,resolveConditionalBlocks(macro-engine.ts:950-990) keeps the newline before the tag, replaces the block with an empty string, then resumes right after the{{/if}}keeping the newline after it — so the two bracketing newlines merge into a blank line. There is no standalone-tag newline trim anywhere (only a whole-output trim at:1403-1405, which doesn't touch interior blank lines). This affects all{{#if}}blocks, not just conversation macros. Fix: chomp the trailing newline + leading indent of a standalone block tag (Handlebarstrim_blocks/ Jinja style), guarding inline conditionals. Cosmetic / low priority.Template check