mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7593] [MERGED] fix(summary): hidden {{#if}} sections leave no blank lines #7821
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#7821
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/7593
Author: @SpicyMarinara
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/summary-if-blank-lines📝 Commits (3)
9a05b11fix(summary): hidden {{#if}} sections leave no blank lines96dc3aafix(summary): carry a section's line break before it, and cover review gaps2b35aebfix(summary): collapse the blank line back-to-back hidden sections leave in Advanced Memory📊 Changes
6 files changed (+446 additions, -31 deletions)
View changed files
📝
packages/server/src/services/advanced-memory.ts(+28 -15)📝
packages/server/src/services/prompt/macro-context.ts(+3 -0)📝
packages/shared/src/utils/macro-engine.ts(+182 -0)📝
scripts/regressions/advanced-memory-audience.regression.ts(+57 -0)📝
scripts/regressions/merged-chat-summary.regression.ts(+29 -14)📝
scripts/regressions/prompt.regression.ts(+147 -2)📄 Description
Linked issue
No linked issue: reported by the maintainer on 2026-10-14.
Why this change
{{#if char == "Cyno"}}…{{/if}}. When Cyno wasn't the one replying, the text disappeared from the prompt but left empty lines where it had been.What changed
What is different for you:
[Known only to …]notes, and the narrator, who reads every section. In a merged reply, a summary that ends with a hidden section no longer leaves extra empty lines before the next summary.{{// comments}}, and summaries with a[…]group block get the same cleanup. A group block keeps its[and]lines.{{else}}), each character's version is on its own line, also at the end of the summary. Before, the versions could be glued together on one line.#heading there and the XML format still indents it. The section's own lines start at the margin of<chat_summary>, as before.#heading on that line is not escaped in Markdown and the line is not indented in XML.Technical summary:
packages/shared/src/utils/macro-engine.ts: new exportedattachConditionalLineBreaks(summary). It normalizes line endings to\n, strips{{// }}comments (reading drops them anyway), and rewrites each{{#if}}block that fills whole lines (only spaces or tabs before the{{#if}}and after the{{/if}}on their lines).{{else}}/{{/if}}on its own line; text on an inline{{#if}}'s line keeps that line's indentation.{{/if}}stays in the text. A block that is a paragraph of its own also takes the blank lines before it.[and]lines are boundaries: the text between them is rewritten apart, and a block alone between them stays as written for the existing per-character trim.{{noop}}keeps a rewritten block off a line of its own and guards a branch that starts with a line break, so the standalone-tag trim (#3435) does not drop a carried line break a second time, also when a merged reply reads a block apart from the text before it.[ \t]*regexes CodeQL flagged, and leaves text outside blocks untouched.packages/server/src/services/prompt/macro-context.ts:resolveChatSummaryMacrosapplies the helper first, now also to summaries with a group block (which still keep the single reading). Every Chat Summary placement goes through it: thechat_summarymarker (marker-expander.tsexpandChatSummary), the preset-less fallback (assembler.tsappendFallbackChatSummaryToSystemPrompt), generation (generate.routes.ts), Peek Prompt's dry run (dry-run-route.ts) and its live preview (chats.routes.ts).packages/server/src/services/advanced-memory.ts:renderEntryapplies the helper before narrator flattening and per-reader scoping.trimResult: false, as the Chat Summary's parts already are, and the merged result is trimmed, as a single reader's is.preparationPolicyRevisionmoves fromscene-timeframe-constants-v24to-v25. Peek Prompt and the live request then agree.preparationPolicyRevisionis the only Advanced Memory cache key that covers rendered summaries.resolveMacros/resolveConditionalBlocks, deferred-token decoding, stored summaries, and agent context.flattenAgentConditionalMacros), so no section is hidden there.promptPartspath wraps the raw summary without resolving macros.scripts/regressions/merged-chat-summary.regression.ts. These pinned the empty lines this PR removes, so please confirm.{{else}}versions in the merged expectation are on separate lines.{{noop}}guard) inside each token.scripts/regressions/prompt.regression.ts, case "Chat Summary sections for someone who is not replying leave no empty line":[Known only to …].{{else if}}/{{else}}chains and an empty first branch; nested sections, including one at the top of a section that is not a paragraph and one that fills its section; indentation; a section starting with a blank line; a comment line; a group block; a section sharing a line with text (left unchanged).{{else}}chain; Windows line endings, now and deferred; the Markdown heading guard and the XML indent after a section in Individual mode.resolveMacroson the original text.scripts/regressions/advanced-memory-audience.regression.ts: merged, each individual reader, a reader with no section, and the narrator, throughprepare; and a merged reply where one summary ends with a hidden section and another is only sections.Validation
pnpm checkpasses locallyCONTRIBUTING.mdCommands run by the agent, on the final commit:
pnpm build:shared: passed.node ./scripts/run-regressions.mjs --filter scripts/regressions/prompt.regression.ts: 1/1 passed, including the extended case.merged-chat-summary, and all 16advanced-memory*files, each run on its own: all passed.pnpm regression:prompt: 3/3 passed.pnpm check: passed.9a05b11b6), with this branch's tests and that commit's source:prompt.regression.tsfails on the case "Hidden at the start and at the end", which kept trailing line breaks.merged-chat-summaryfails at "Individual mode".advanced-memory-audiencefails on the merged reply whose first summary ends with a hidden section.advanced-memory-audiencefails, for merged readers and for a single reader, without the collapse inrenderEntry.{{else}}chains and blank lines, in six runs:[/]lines and Windows line endings, in four runs: no text changed, no lines glued that staging kept apart, no new disagreement between the immediate and deferred readings, and the rewrite is always idempotent.coderabbit review --agent --committed): review completed, 0 findings on the 6 changed files.pnpm regressionand browser smoke tests were not run locally. CI runs them.Manual verification notes
{{#if char == "…"}}paragraph per character, and one section as the summary's last paragraph.[Known only to …]lines, with no empty lines between them and the surrounding text.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)UI evidence (if applicable)
Not applicable: prompt text only, no UI change.
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.