[PR #6968] [MERGED] fix(roleplay): keep Merged and Individual narration in sync #7410

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

📋 Pull Request Information

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

Base: staging ← Head: fix/narrator-mode-sync


📝 Commits (5)

  • 78b66f6 fix(roleplay): keep narration mode identity and context in sync
  • c8a2aad Merge remote-tracking branch 'origin/staging' into fix/narrator-mode-sync
  • f98b953 Merge remote-tracking branch 'origin/staging' into fix/narrator-mode-sync
  • 2aa373f docs(changelog): drop repeated entries
  • f0c8cf8 Merge remote-tracking branch 'origin/staging' into fix/narrator-mode-sync

📊 Changes

9 files changed (+329 additions, -21 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
➕ e2e/group-narration-mode-sync.e2e.ts (+122 -0)
📝 packages/client/src/components/chat/ChatArea.tsx (+3 -1)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+13 -9)
📝 packages/server/src/routes/chats.routes.ts (+6 -2)
📝 packages/server/src/routes/generate.routes.ts (+17 -8)
📝 packages/server/src/routes/generate/generate-route-utils.ts (+2 -1)
📝 packages/shared/src/types/chat.ts (+5 -0)
➕ scripts/regressions/group-narration-mode-sync.regression.ts (+159 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #6959

Why this change

In Roleplay group chats, switching between Merged Narrator and Individual could leave the prompt's identity ("You are X") and its context order disagreeing. I found two ways that happened:

  1. Continue ignored Merged mode. Continuing a reply made that reply's speaker the prompt target in every mode. In Merged mode the prompt became "You are Jane Doe" with only Jane's card, while the history and instructions stayed merged. Swipes got a guard for exactly this in #3850; Continue never did. The mode was also read in several places per request, sometimes from a fresh copy of the chat.
  2. The toggle's save wasn't waited on. The mode toggle saved outside the queue a new reply waits for. A message sent right after switching could be built with the old mode while the drawer already showed the new one, and quick toggles could land out of order.

What changed

  • One reading of the mode: a shared normalizeGroupChatMode, where anything other than "individual" means Merged, the documented default. It's used by generation, the metadata route, the prompt preview, ChatArea and the drawer.
  • Generation: reads the mode once per request, and that one value decides the identity, the context and Continue's speaker. Continue now follows the same rule as swipes.
  • Saving: the metadata route stores only a normalized mode, and the drawer's mode toggle now saves through the queue that a new reply waits for.
  • CHANGELOG entry.

Worth knowing: in Merged mode, {{char}} still means the first active character, by design. So "You are Joe Smith" is expected in Merged mode when Joe is listed first. If the merged prompt should name a narrator instead, that's a separate design change.

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

What I ran (not a replacement for the checklist):

  • Checks: pnpm check and pnpm regression:prompt pass, and 22 group-chat, Roleplay and memory regressions pass.

  • New group-narration-mode-sync.regression.ts:

    • It toggles the mode back and forth through the real routes, and after each toggle checks continue, swipe and send.
    • It also covers stored values of 1, "Individual", "bogus" and null, plus the reporter's exact chat data.
    • Before the fix: merged continue: Merged keeps the narrator identity — actual 'Jane Doe', expected 'Joe Smith'.
  • New e2e/group-narration-mode-sync.e2e.ts (desktop): holds the mode save, sends a message, and checks the reply waits for the save. It fails with the client change undone.

  • Local CodeRabbit: 1 finding, fixed. The CHANGELOG had repeated entries from merging staging, including one already repeated on staging, and now has one of each.

To check by hand:

  • In a Roleplay group chat with two characters, switch Merged ↔ Individual a few times. After each switch, send, swipe and continue, and check the prompt in Peek Prompt.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

CHANGELOG entry only.

UI evidence (if applicable)

No visual change; the toggle now waits for its save.

Summary by CodeRabbit

  • Bug Fixes
    • Switching between Merged (Narrator) and Individual mode now updates the full prompt used for replies, including when continuing or regenerating a response.
    • Messages sent immediately after a mode change wait until the new setting is saved, helping ensure replies use the selected mode.
    • Chat Settings now displays the mode used for replies.

🔄 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/6968 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/2/2026 **Status:** ✅ Merged **Merged:** 10/2/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/narrator-mode-sync` --- ### 📝 Commits (5) - [`78b66f6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/78b66f60c690596871dd66625ce5dcd2d0ef96a4) fix(roleplay): keep narration mode identity and context in sync - [`c8a2aad`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c8a2aad5c26b8434d5452781a3640e6257759914) Merge remote-tracking branch 'origin/staging' into fix/narrator-mode-sync - [`f98b953`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f98b9537f5516fc10cf79615a1d998bf3854746d) Merge remote-tracking branch 'origin/staging' into fix/narrator-mode-sync - [`2aa373f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2aa373fce8f9abe7972a1058990c3b8e21e6b687) docs(changelog): drop repeated entries - [`f0c8cf8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f0c8cf8377dbb28450ddb58ecd831b293676cb51) Merge remote-tracking branch 'origin/staging' into fix/narrator-mode-sync ### 📊 Changes **9 files changed** (+329 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) ➕ `e2e/group-narration-mode-sync.e2e.ts` (+122 -0) 📝 `packages/client/src/components/chat/ChatArea.tsx` (+3 -1) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+13 -9) 📝 `packages/server/src/routes/chats.routes.ts` (+6 -2) 📝 `packages/server/src/routes/generate.routes.ts` (+17 -8) 📝 `packages/server/src/routes/generate/generate-route-utils.ts` (+2 -1) 📝 `packages/shared/src/types/chat.ts` (+5 -0) ➕ `scripts/regressions/group-narration-mode-sync.regression.ts` (+159 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #6959 ## Why this change In Roleplay group chats, switching between **Merged Narrator** and **Individual** could leave the prompt's identity ("You are X") and its context order disagreeing. I found two ways that happened: 1. **Continue ignored Merged mode.** Continuing a reply made that reply's speaker the prompt target in every mode. In Merged mode the prompt became "You are Jane Doe" with only Jane's card, while the history and instructions stayed merged. Swipes got a guard for exactly this in #3850; Continue never did. The mode was also read in several places per request, sometimes from a fresh copy of the chat. 2. **The toggle's save wasn't waited on.** The mode toggle saved outside the queue a new reply waits for. A message sent right after switching could be built with the old mode while the drawer already showed the new one, and quick toggles could land out of order. ## What changed - **One reading of the mode:** a shared `normalizeGroupChatMode`, where anything other than `"individual"` means Merged, the documented default. It's used by generation, the metadata route, the prompt preview, `ChatArea` and the drawer. - **Generation:** reads the mode once per request, and that one value decides the identity, the context and Continue's speaker. Continue now follows the same rule as swipes. - **Saving:** the metadata route stores only a normalized mode, and the drawer's mode toggle now saves through the queue that a new reply waits for. - **CHANGELOG entry.** Worth knowing: in Merged mode, `{{char}}` still means the first active character, by design. So "You are Joe Smith" is expected in Merged mode when Joe is listed first. If the merged prompt should name a narrator instead, that's a separate design change. ## 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 What I ran (not a replacement for the checklist): - **Checks:** `pnpm check` and `pnpm regression:prompt` pass, and 22 group-chat, Roleplay and memory regressions pass. - **New `group-narration-mode-sync.regression.ts`:** - It toggles the mode back and forth through the real routes, and after each toggle checks continue, swipe and send. - It also covers stored values of `1`, `"Individual"`, `"bogus"` and `null`, plus the reporter's exact chat data. - Before the fix: `merged continue: Merged keeps the narrator identity — actual 'Jane Doe', expected 'Joe Smith'`. - **New `e2e/group-narration-mode-sync.e2e.ts` (desktop):** holds the mode save, sends a message, and checks the reply waits for the save. It fails with the client change undone. - **Local CodeRabbit:** 1 finding, fixed. The CHANGELOG had repeated entries from merging staging, including one already repeated on staging, and now has one of each. To check by hand: - In a Roleplay group chat with two characters, switch Merged ↔ Individual a few times. After each switch, send, swipe and continue, and check the prompt in Peek Prompt. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) CHANGELOG entry only. ## UI evidence (if applicable) No visual change; the toggle now waits for its save. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Switching between Merged (Narrator) and Individual mode now updates the full prompt used for replies, including when continuing or regenerating a response. * Messages sent immediately after a mode change wait until the new setting is saved, helping ensure replies use the selected mode. * Chat Settings now displays the mode used for replies. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:19:30 +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#7410
No description provided.