[PR #7379] [MERGED] fix(expressions): show the persona only on turns the player wrote #7707

Closed
opened 2026-10-24 04:06:42 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: staging ← Head: fix/persona-expression-only-when-present


📝 Commits (4)

  • f189e05 fix(expressions): show the persona only on turns the player wrote
  • cdd011a fix(expressions): keep the persona for the whole turn the player wrote
  • 9635ea1 Merge branch 'staging' into fix/persona-expression-only-when-present
  • ffc38a3 fix(expressions): offer the persona's sprite when a short-context retry needs it

📊 Changes

5 files changed (+128 additions, -7 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/routes/generate.routes.ts (+9 -0)
📝 packages/server/src/routes/generate/expression-agent-utils.ts (+18 -0)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+17 -7)
📝 scripts/regressions/expression-group-generation.regression.ts (+83 -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

Fixes #7378

Why this change

With Only show active sprites on, the persona's sprite stayed visible after the persona had left the scene. The maintainer's chat shows the cause. From message #1244 onward, the Expression Engine's own result (spriteExpressions) correctly left Mari out: a Tighnari reply records only {Tighnari: determined}. But every reply's expressionSpriteIds, which drives the display, still listed her, even narrator replies with no expression result.

The Engine itself added the persona to the required expression targets whenever any user message was still in the recent context:

  • on generation, through getLatestUserExpressionSource();
  • on agent retry, through recentMessages.some(role === "user").

completeRequiredSpriteExpressionEntries then filled in an expression from the player's old message on every reply.

What changed

  • generate.routes.ts: the persona is a required expression target only when this request carries the player's message (currentTurnUserMessageId). Impersonation already adds it on its own.
  • retry-agents-route.ts: the persona is required only when the retried reply directly answered a player message.
  • Other replies leave the persona to the Expression Engine, as for every other character.
  • CHANGELOG entry.

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

Automated evidence (the boxes above are for a human):

  • pnpm check passed locally.
  • expression-group-generation regression: two replies with no new player message, where the Expression Engine leaves the persona out, no longer list the persona. Retrying the Expression Engine on such a reply doesn't add it either. Each assertion fails without its fix: I reverted the generation and retry changes separately to check. The existing "the active persona keeps its existing expression request" case (a turn the player wrote, and impersonation) still passes.
  • manual-agent-retry-resolution, agent-runtime, roleplay-streaming, sprite-background and expression-tool-retirement pass.

Manual verification notes

  • Manually verify in a Roleplay group chat with the Expression Engine and Only show active sprites: write one message, then let characters reply several times. The persona's sprite should disappear once the Expression Engine stops including the persona.
  • Manually verify that writing a new message shows the persona's sprite again on that turn.

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)

One CHANGELOG entry, and no docs changes.

Summary by CodeRabbit

  • Bug Fixes
    • Persona sprites now appear on turns they wrote or when included by the Expression Engine. Replies awaiting expression for a player message retain the relevant persona, including when older persona messages remain in context; unrelated conversation history alone no longer causes them to appear.
    • Retrying expression generation on a reply to a persona’s message continues to include that persona.
  • Tests
    • Added regression coverage for expression targeting across replies, retries, and swipes.

🔄 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/7379 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/persona-expression-only-when-present` --- ### 📝 Commits (4) - [`f189e05`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f189e05358fe5946c45272b4e9fc2c2ed1f8961d) fix(expressions): show the persona only on turns the player wrote - [`cdd011a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cdd011a6f0b72f7a9cc78f7332e6c2ed80fb0941) fix(expressions): keep the persona for the whole turn the player wrote - [`9635ea1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9635ea14ae75b3a36cb941e6dbd6c312d64430ae) Merge branch 'staging' into fix/persona-expression-only-when-present - [`ffc38a3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ffc38a30bdcb479f079adb5e2938283eaf61f547) fix(expressions): offer the persona's sprite when a short-context retry needs it ### 📊 Changes **5 files changed** (+128 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+9 -0) 📝 `packages/server/src/routes/generate/expression-agent-utils.ts` (+18 -0) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+17 -7) 📝 `scripts/regressions/expression-group-generation.regression.ts` (+83 -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 Fixes #7378 ## Why this change With **Only show active sprites** on, the persona's sprite stayed visible after the persona had left the scene. The maintainer's chat shows the cause. From message #1244 onward, the Expression Engine's own result (`spriteExpressions`) correctly left Mari out: a Tighnari reply records only `{Tighnari: determined}`. But every reply's `expressionSpriteIds`, which drives the display, still listed her, even narrator replies with no expression result. The Engine itself added the persona to the **required** expression targets whenever *any* user message was still in the recent context: - on generation, through `getLatestUserExpressionSource()`; - on agent retry, through `recentMessages.some(role === "user")`. `completeRequiredSpriteExpressionEntries` then filled in an expression from the player's old message on every reply. ## What changed - `generate.routes.ts`: the persona is a required expression target only when this request carries the player's message (`currentTurnUserMessageId`). Impersonation already adds it on its own. - `retry-agents-route.ts`: the persona is required only when the retried reply directly answered a player message. - Other replies leave the persona to the Expression Engine, as for every other character. - CHANGELOG entry. ## 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` Automated evidence (the boxes above are for a human): - `pnpm check` passed locally. - `expression-group-generation` regression: two replies with no new player message, where the Expression Engine leaves the persona out, no longer list the persona. Retrying the Expression Engine on such a reply doesn't add it either. Each assertion fails without its fix: I reverted the generation and retry changes separately to check. The existing "the active persona keeps its existing expression request" case (a turn the player wrote, and impersonation) still passes. - `manual-agent-retry-resolution`, `agent-runtime`, `roleplay-streaming`, `sprite-background` and `expression-tool-retirement` pass. ### Manual verification notes - Manually verify in a Roleplay group chat with the Expression Engine and **Only show active sprites**: write one message, then let characters reply several times. The persona's sprite should disappear once the Expression Engine stops including the persona. - Manually verify that writing a new message shows the persona's sprite again on that turn. ## 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) One CHANGELOG entry, and no docs changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Persona sprites now appear on turns they wrote or when included by the Expression Engine. Replies awaiting expression for a player message retain the relevant persona, including when older persona messages remain in context; unrelated conversation history alone no longer causes them to appear. * Retrying expression generation on a reply to a persona’s message continues to include that persona. * **Tests** * Added regression coverage for expression targeting across replies, retries, and swipes. <!-- 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-24 04:06:42 +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#7707
No description provided.