[PR #3445] [MERGED] feat(conversation): add {{replyRules}} macro to relocate custom emoji/sticker reply rules #5940

Closed
opened 2026-10-23 04:05:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3445
Author: @kolacheee
Created: 7/10/2026
Status: ✅ Merged
Merged: 7/10/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/3438-reply-rules-macro


📝 Commits (2)

  • 6d39a80 feat(conversation): add {{replyRules}} macro to relocate custom emoji/sticker reply rules
  • 8578a3f Merge branch 'staging' into feat/3438-reply-rules-macro

📊 Changes

2 files changed (+34 additions, -5 deletions)

View changed files

📝 packages/server/src/routes/generate.routes.ts (+12 -1)
📝 packages/server/src/routes/generate/conversation-custom-assets.ts (+22 -4)

📄 Description

Linked issue

Refs #3438

Why this change

#3438 points out a clear parity gap: a preset can relocate the react-rules block with {{reactRules}}, but the parallel custom-emoji/sticker reply advertisement — the "you can use custom emojis in your reply by writing :name:…" text, and the sticker equivalent — has no macro and is always force-appended to the first system message. So a preset author can move the react rules but not the emoji/sticker reply rules.

What changed

Adds a {{replyRules}} relocation macro that mirrors {{reactRules}}:

  • packages/server/src/routes/generate.routes.ts: added a replyRules key (alias {{replyRules}}) to ConversationContextMacroSlots, and wired a placement callback into appendConversationCustomAssetAdvertisements when the slot is present.
  • packages/server/src/routes/generate/conversation-custom-assets.ts: the emoji and sticker reply advertisements are now built into function-scope locals; at the end the helper either (a) renders the combined block at the {{replyRules}} macro (suppressing the auto append) via the callback, or (b) falls back to the historical behavior — append emoji then sticker to the first system message. When there are no advertisements the macro token is still stripped.

Single macro covering both emoji and sticker reply rules; no emoji-only/sticker-only aliases, since every alias of a slot renders the same block (avoids accidental duplication).

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Automated checks I ran locally (green):

  • pnpm --filter @marinara-engine/server lint (tsc -b ../shared && tsc --noEmit) — clean
  • pnpm regression:prompt — full prompt/macro regression suite passes

Still to verify manually in the app (please tick above once done):

  1. Conversation chat with custom emojis/stickers configured, no {{replyRules}} in the preset → confirm the reply advertisement(s) still append to the system message exactly as before (emoji then sticker).
  2. Add {{replyRules}} somewhere in the preset → confirm the reply advertisement(s) render at that spot and are not also appended at the top.
  3. {{replyRules}} present but the chat has no custom emojis/stickers → confirm the {{replyRules}} token is removed (no literal {{replyRules}} leaks into the prompt).
  4. Confirm {{reactRules}} (react rules) still behaves independently.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

Macro-reference docs for the conversation relocation macros are tracked in #3437 and will cover {{replyRules}} alongside the others; no version bump here.

UI evidence (if applicable)

N/A (prompt-assembly logic; no UI surface changed).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/3445 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 7/10/2026 **Status:** ✅ Merged **Merged:** 7/10/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/3438-reply-rules-macro` --- ### 📝 Commits (2) - [`6d39a80`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6d39a80706f0ed67d834fcd7557110f2af41ad71) feat(conversation): add {{replyRules}} macro to relocate custom emoji/sticker reply rules - [`8578a3f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8578a3f93d39b350c9f03ea017563d4756db6e9c) Merge branch 'staging' into feat/3438-reply-rules-macro ### 📊 Changes **2 files changed** (+34 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/generate.routes.ts` (+12 -1) 📝 `packages/server/src/routes/generate/conversation-custom-assets.ts` (+22 -4) </details> ### 📄 Description <!-- Target branch: `staging`. --> ## Linked issue Refs #3438 <!-- This PR implements the one concrete, low-effort parity fix from #3438 (the {{replyRules}} macro). The broader placement macros requested there — conversation history and lorebook before/after — are larger and intentionally left for follow-up. --> ## Why this change #3438 points out a clear parity gap: a preset can relocate the react-rules block with `{{reactRules}}`, but the parallel custom-emoji/sticker **reply** advertisement — the "you can use custom emojis in your reply by writing `:name:`…" text, and the sticker equivalent — has **no macro** and is always force-appended to the first system message. So a preset author can move the react rules but not the emoji/sticker reply rules. ## What changed Adds a `{{replyRules}}` relocation macro that mirrors `{{reactRules}}`: - `packages/server/src/routes/generate.routes.ts`: added a `replyRules` key (alias `{{replyRules}}`) to `ConversationContextMacroSlots`, and wired a placement callback into `appendConversationCustomAssetAdvertisements` when the slot is present. - `packages/server/src/routes/generate/conversation-custom-assets.ts`: the emoji and sticker reply advertisements are now built into function-scope locals; at the end the helper either (a) renders the combined block at the `{{replyRules}}` macro (suppressing the auto append) via the callback, or (b) falls back to the historical behavior — append emoji then sticker to the first system message. When there are no advertisements the macro token is still stripped. Single macro covering both emoji and sticker reply rules; no emoji-only/sticker-only aliases, since every alias of a slot renders the same block (avoids accidental duplication). ## Validation <!-- Required: include commands run and/or manual checks performed --> - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes Automated checks I ran locally (green): - `pnpm --filter @marinara-engine/server lint` (`tsc -b ../shared && tsc --noEmit`) — clean - `pnpm regression:prompt` — full prompt/macro regression suite passes Still to verify manually in the app (please tick above once done): 1. Conversation chat with custom emojis/stickers configured, **no** `{{replyRules}}` in the preset → confirm the reply advertisement(s) still append to the system message exactly as before (emoji then sticker). 2. Add `{{replyRules}}` somewhere in the preset → confirm the reply advertisement(s) render at that spot and are **not** also appended at the top. 3. `{{replyRules}}` present but the chat has no custom emojis/stickers → confirm the `{{replyRules}}` token is removed (no literal `{{replyRules}}` leaks into the prompt). 4. Confirm `{{reactRules}}` (react rules) still behaves independently. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) Macro-reference docs for the conversation relocation macros are tracked in #3437 and will cover `{{replyRules}}` alongside the others; no version bump here. ## UI evidence (if applicable) N/A (prompt-assembly logic; no UI surface changed). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:05:23 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5940
No description provided.