[PR #3876] [MERGED] fix: preserve Persona names in Name Prefix History #6139

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

📋 Pull Request Information

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

Base: staging ← Head: fix/name-prefix-history-persona-snapshots


📝 Commits (1)

  • fdd831d fix: preserve Persona names in prefixed history

📊 Changes

6 files changed (+55 additions, -1 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/routes/generate.routes.ts (+3 -0)
📝 packages/server/src/routes/generate/dry-run-route.ts (+4 -0)
📝 packages/server/src/routes/generate/generate-route-utils.ts (+9 -1)
📝 packages/server/src/services/generation/prompt-message-scope.ts (+1 -0)
📝 scripts/regressions/prompt.regression.ts (+37 -0)

📄 Description

Linked issue

No GitHub issue has been filed yet. This draft tracks a regression reported directly by the maintainer; an issue should be opened and linked before the PR is marked ready.

Why this change

When Name Prefix History is enabled, switching Personas relabels every historical user turn with the currently selected Persona. Messages originally sent as Powers That Be therefore reach the model as if Mari had sent them.

What changed

  • Read the Persona snapshot already stored on each historical user message.
  • Carry that snapshot name through prompt shaping and prefer it when prefixing user history.
  • Preserve the current-Persona fallback for unsnapshotted legacy messages and new dry-run input.
  • Apply identical behavior to real generation and Peek Prompt.
  • Add regression coverage for mixed historical/current Personas and update the changelog.

Root cause

The history prefixer accepted one generation-wide personaName and applied it to every user message. Although messages already persisted their send-time personaSnapshot, prompt mapping discarded that name before Name Prefix History ran.

Validation

Automated commands run successfully:

  • pnpm regression:prompt

  • pnpm check

  • pnpm version:check

  • git diff --check

  • 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

  • Manually send Roleplay group messages as Persona A with Name Prefix History enabled.
  • Switch to Persona B, inspect Peek Prompt, and generate another response.
  • Confirm Persona A remains the prefix on its historical turns while the current turn uses Persona B.

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)

UI evidence (if applicable)

No UI changes.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed Name Prefix History so historical user messages retain the persona name that originally sent them, rather than being relabeled under the currently selected persona.
    • Applied the corrected persona names consistently in chat generation and dry-run previews.
  • Tests
    • Added regression coverage for persona-prefixed historical messages, including names with extra whitespace.

🔄 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/3876 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 7/20/2026 **Status:** ✅ Merged **Merged:** 7/20/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/name-prefix-history-persona-snapshots` --- ### 📝 Commits (1) - [`fdd831d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fdd831d3b62b6577a2732ff06857a5bebdafe196) fix: preserve Persona names in prefixed history ### 📊 Changes **6 files changed** (+55 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+3 -0) 📝 `packages/server/src/routes/generate/dry-run-route.ts` (+4 -0) 📝 `packages/server/src/routes/generate/generate-route-utils.ts` (+9 -1) 📝 `packages/server/src/services/generation/prompt-message-scope.ts` (+1 -0) 📝 `scripts/regressions/prompt.regression.ts` (+37 -0) </details> ### 📄 Description ## Linked issue No GitHub issue has been filed yet. This draft tracks a regression reported directly by the maintainer; an issue should be opened and linked before the PR is marked ready. ## Why this change When **Name Prefix History** is enabled, switching Personas relabels every historical user turn with the currently selected Persona. Messages originally sent as Powers That Be therefore reach the model as if Mari had sent them. ## What changed - Read the Persona snapshot already stored on each historical user message. - Carry that snapshot name through prompt shaping and prefer it when prefixing user history. - Preserve the current-Persona fallback for unsnapshotted legacy messages and new dry-run input. - Apply identical behavior to real generation and Peek Prompt. - Add regression coverage for mixed historical/current Personas and update the changelog. ## Root cause The history prefixer accepted one generation-wide `personaName` and applied it to every user message. Although messages already persisted their send-time `personaSnapshot`, prompt mapping discarded that name before Name Prefix History ran. ## Validation Automated commands run successfully: - `pnpm regression:prompt` - `pnpm check` - `pnpm version:check` - `git diff --check` - [ ] `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 - Manually send Roleplay group messages as Persona A with Name Prefix History enabled. - Switch to Persona B, inspect Peek Prompt, and generate another response. - Confirm Persona A remains the prefix on its historical turns while the current turn uses Persona B. ## 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) ## UI evidence (if applicable) No UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed Name Prefix History so historical user messages retain the persona name that originally sent them, rather than being relabeled under the currently selected persona. * Applied the corrected persona names consistently in chat generation and dry-run previews. * **Tests** * Added regression coverage for persona-prefixed historical messages, including names with extra whitespace. <!-- 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:07:26 +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#6139
No description provided.