[PR #156] [MERGED] Fix {{user}} / {{char}} macro substitution in Game Mode #4485

Closed
opened 2026-10-22 04:08:01 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/156
Author: @Romuromylus
Created: 4/21/2026
Status: ✅ Merged
Merged: 4/21/2026
Merged by: @SpicyMarinara

Base: main ← Head: fix-game-mode-user-macro


📝 Commits (2)

  • 21d0798 Fix {{user}} / {{char}} macro substitution in Game Mode
  • 29487bc Merge branch 'main' into fix-game-mode-user-macro

📊 Changes

1 file changed (+28 additions, -3 deletions)

View changed files

📝 packages/client/src/components/game/GameNarration.tsx (+28 -3)

📄 Description

Summary

In Game Mode, {{user}} and {{char}} macros appear literally in the rendered narration instead of resolving to the active persona/character.

Root cause

GameNarration.tsx is the rendering chokepoint for Game Mode narration and player-action segments, but it never runs display-time macro replacement. The chat path handles this in ChatMessage.tsx (around line 650, text.replaceAll(\"{{user}}\", userName)), and GameNarration.tsx does not call into that path. The server-side resolveMacros engine doesn't catch it either, since Game Mode replaces the system prompt entirely with buildGmSystemPrompt(gmCtx) (in generate.routes.ts), whose output never goes through resolveMacros. Net effect: {{user}} / {{char}} survive end-to-end and render verbatim in the UI.

This is a missing feature, not a regression — Game Mode shipped without macro display-substitution from v1.5.0 onward.

Fix

Apply the substitution at segment-build time inside the segments and sideLineMap useMemos in GameNarration.tsx. Doing it there (rather than inside formatNarration) means every downstream render path — formatNarration, animateTextHtml, side-line overlays — receives already-resolved text without changing the renderer's signature.

  • {{user}} → personaInfo.name (fallback "You"), matching ChatMessage.tsx.
  • {{char}} → seg.speaker when present, otherwise the first character in characterMap. Left literal if neither is available.

🔄 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/156 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 4/21/2026 **Status:** ✅ Merged **Merged:** 4/21/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `main` ← **Head:** `fix-game-mode-user-macro` --- ### 📝 Commits (2) - [`21d0798`](https://github.com/Pasta-Devs/Marinara-Engine/commit/21d07982cb5d30d4152fcf1947cce9bd7293c0c6) Fix {{user}} / {{char}} macro substitution in Game Mode - [`29487bc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/29487bc31aeed9c5b3297140671c5197cb86ce9c) Merge branch 'main' into fix-game-mode-user-macro ### 📊 Changes **1 file changed** (+28 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/game/GameNarration.tsx` (+28 -3) </details> ### 📄 Description ## Summary In Game Mode, `{{user}}` and `{{char}}` macros appear literally in the rendered narration instead of resolving to the active persona/character. ## Root cause `GameNarration.tsx` is the rendering chokepoint for Game Mode narration and player-action segments, but it never runs display-time macro replacement. The chat path handles this in `ChatMessage.tsx` (around line 650, `text.replaceAll(\"{{user}}\", userName)`), and `GameNarration.tsx` does not call into that path. The server-side `resolveMacros` engine doesn't catch it either, since Game Mode replaces the system prompt entirely with `buildGmSystemPrompt(gmCtx)` (in `generate.routes.ts`), whose output never goes through `resolveMacros`. Net effect: `{{user}}` / `{{char}}` survive end-to-end and render verbatim in the UI. This is a missing feature, not a regression — Game Mode shipped without macro display-substitution from v1.5.0 onward. ## Fix Apply the substitution at segment-build time inside the `segments` and `sideLineMap` useMemos in `GameNarration.tsx`. Doing it there (rather than inside `formatNarration`) means every downstream render path — `formatNarration`, `animateTextHtml`, side-line overlays — receives already-resolved text without changing the renderer's signature. - `{{user}}` → `personaInfo.name` (fallback `"You"`), matching `ChatMessage.tsx`. - `{{char}}` → `seg.speaker` when present, otherwise the first character in `characterMap`. Left literal if neither is available. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:08:01 +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#4485
No description provided.