[PR #8836] [MERGED] fix(client): show only a historical merged reply's own scene in its avatars #8831

Closed
opened 2026-11-07 17:40:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: staging ← Head: fix/merged-avatars-scene-only


📝 Commits (2)

  • 39418ee fix(client): show only a historical merged reply's own scene in its avatars
  • 2dffef2 fix(client): keep unnameable members and split-reply scenes on older merged replies

📊 Changes

5 files changed (+442 additions, -24 deletions)

View changed files

📝 e2e/narrator-macro-avatars.e2e.ts (+79 -0)
📝 packages/client/src/components/chat/ChatMessage.tsx (+17 -1)
📝 packages/client/src/components/chat/ChatRoleplaySurface.tsx (+45 -2)
📝 packages/client/src/components/chat/merged-avatar-roster.ts (+97 -15)
📝 scripts/regressions/merged-chat-historical-avatars.regression.ts (+204 -6)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.

Linked issue

Closes #8823

Why this change

Issue #8823 is a follow-up to #8762 / PR #8800. In a merged Roleplay group chat, historical replies showed avatars for every chat member. Characters who were not in a reply's scene appeared with their regular avatars next to the participants' expression portraits. #8800 kept older replies from losing avatars when the roster shrank, but its fallback also added the whole live roster. So whenever the active roster was larger than the reply's scene (auto-selection off, or members reactivated), older replies gained the absent characters. A historical reply should show only the cast of its own scene: its saved roster, or for an older reply the members its own expression result names. It should fall back to the live roster only when it carries no per-character data at all.

What changed

  • resolveMergedAvatarRoster (packages/client/src/components/chat/merged-avatar-roster.ts): a saved reply now shows only its own scene. That is mergedReplyRoster(extra, chatCharacterIds) filtered to current members: the saved roster, or for an older reply the members named by expressionSpriteIds and the spriteExpressions keys. The live roster is no longer added. A reply with no per-character data at all keeps the old live-roster behaviour; so does a reply whose saved roster has entirely left the chat. A ponytail: comment documents this, with the upgrade path of backfilling from speaker tags.
  • Unchanged: streaming and regenerating replies still follow the live roster; Continue still streams with the reply's own roster plus the live one, which is what the server saves. Server code, the shared mergedReplyRoster, ChatMessage, ChatRoleplaySurface and the outside-card avatars from referencedCharacterIds are untouched. The persona and non-members are still filtered out of the fallback.
  • scripts/regressions/merged-chat-historical-avatars.regression.ts: added a four-member chat (Ana, Ben, Cal, Dee). The server generates a reply with Cal and Dee inactive and the test asserts the saved roster is [Ana, Ben]. With everyone active again it asserts the exact avatar list for (a) the saved reply [Ana, Ben], (b) an older reply with an expression list [Ana, Ben], (b) an older reply with expression keys only [Ana, Ben], (c) an older reply with no expression data (all four), (d) a greeting created through the API as Cal's message (all four), plus a new streaming reply (all four). The header comment was updated to describe the new rule.
  • e2e/narrator-macro-avatars.e2e.ts: new desktop-only test, "historical narrator replies show only the characters of their own scene". It builds a four-member merged chat with solid-colour portraits and creates cases (a)–(d) through the API, with a user turn before each so replies don't group and hide avatars. It checks the exact rendered .mari-message-avatar img count and which portrait srcs appear for each row.
  • Older merged Roleplay replies (saved before #8800) keep the avatars of active members that no expression result could name: members without sprites the chat shows, or outside its sprite selection. Members with sprites who were absent from the scene stay hidden.
  • In older replies split at scene breaks, the first part now shows its own scene, taken from the reply's last part, instead of the whole live roster.

Validation

  • pnpm check passes locally
  • Ran the app, clicked through the changes manually

Manual verification notes

  • Manually verify in the browser: in a merged Roleplay group with four characters, open an older reply (saved before #8800) whose Expression Engine result names only two of them, with all four active. Only those two avatars should cycle, with their expression portraits, and the other two should not appear.
  • Manually verify that a reply generated after #8800 with only two of four characters active keeps showing only those two after you reactivate the other two or turn automatic selection off.
  • Manually verify that an older reply with no expression data, and a greeting, still show the current active roster and never an inactive member's avatar.
  • Manually verify that the next generated reply streams and saves with the full current active roster, and that regenerating an older reply shows the live roster while it streams and after it saves.
  • Manually verify Continue on an older reply whose expression data names two of four active characters: the stream and the saved reply should show the same avatars (its two plus the live roster), with no jump when the stream finishes.
  • Manually verify that a narrator reply with ID-macro references still shows the referenced outside character's avatar alongside its scene roster.
  • Manually verify Visual Novel mode and a mobile viewport: the active VN message and historical replies follow the same scene-only rule.

Agent-run checks (for reference):

  • node ./scripts/run-regressions.mjs --filter scripts/regressions/merged-chat-historical-avatars.regression.ts: PASSED (1/1 passed; 0 failed). Run against two mutations first: with the unnameable-member fix reverted it FAILED on the Ben-without-sprites assertion, and with the split-part fix reverted it FAILED on the older split re
  • PLAYWRIGHT_CLIENT_PORT=5801 PLAYWRIGHT_SERVER_PORT=7801 PLAYWRIGHT_MOBILE_CLIENT_PORT=5802 PLAYWRIGHT_MOBILE_SERVER_PORT=7802 PLAYWRIGHT_ONLY_PROJECT=desktop np: 7 passed (2.3m). With both fixes reverted, the scene-only test failed (expected 3 avatars, received 2); after restoring the fixes it passes again.
  • node ./scripts/pnpm-runner.mjs check: Exit 0 (impeccable, localization, format, lint, e2e types, token-estimation types, build).
  • npx tsc --noEmit -p packages/client: Exit 0, no errors.
  • node ./scripts/run-regressions.mjs --filter <each of tts-source-persistence, open-issues, roleplay-swipe-media, narrator-avatar-borders, avatar-stage-logic, tts: Each 1/1 passed; 0 failed. These are the regressions that read the touched client sources.

Independent review of 39418eea1f: changes (1 medium, 1 low), both fixed in 2dffef22ca: older replies keep active members no expression result could name (no sprites, or outside the sprite selection), and older split replies show their own scene from the reply's last part. Dottore Review: Viable, With Notes, no defects.

Known limits and risks:

  • Older replies with expression data: a member who was in the scene but had no expression entry (for example, no sprites) is no longer shown, even when currently active. Before this change the live roster brought them back.
  • Older replies with no expression data, greetings and API-created messages still show the live active roster, so they gain or lose avatars as the roster changes. Speaker tags are not stored as per-message IDs and were not parsed. Upgrade path: backfill mergedRosterCharacterIds from speaker tags.
  • Replies saved since #8800 show their saved roster, which is the active roster when they were generated. If all four characters were active then (auto-selection off), all four show even if the narrator wrote only two into the scene. The active list defines the scene; this is unchanged.
  • Continue is unchanged from #8800: it saves the reply's own roster plus the live one. Continuing an A/B reply while all four are active makes it show all four afterwards.
  • Stale spriteExpressions keys remain the limit noted in #8800. If an Expression Engine retry wrote an empty expressionSpriteIds but left the old map, the old map's members still count as the reply's scene.
  • Outside-card avatars from referencedCharacterIds (ID-macro references) still appear as before. They never include chat members.
  • Not checked by hand in a browser beyond the Playwright run. Visual Novel mode and mobile were not exercised by the new test.
  • An older merged reply without a saved roster decides which members its expression result could never name from today's sprites, sprite selection and display modes, not the ones in place when it was written. If a member gains sprites later, they disappear from that reply's avatars. If the sprite selection is narrowed later, members outside it reappear.
  • An active member who had sprites but whom the older reply's expression result left out is still hidden from that reply. The upgrade path is unchanged: backfill mergedRosterCharacterIds from speaker tags.
  • When a member's sprite list has not loaded yet, they count as nameable, so their avatar appears on older replies once the list arrives. The list is shared with the existing sprite caches and kept for 5 minutes.
  • An older split reply whose last part has not loaded yet (beyond the loaded history page) still falls back to the live roster on its first part.

🤖 Generated with Claude Code


🔄 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/8836 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 11/4/2026 **Status:** ✅ Merged **Merged:** 11/4/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/merged-avatars-scene-only` --- ### 📝 Commits (2) - [`39418ee`](https://github.com/Pasta-Devs/Marinara-Engine/commit/39418eea1fcb628768010eceb24dd3c0949cd91e) fix(client): show only a historical merged reply's own scene in its avatars - [`2dffef2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2dffef22cae2396e72f586788dfae2d8f219db04) fix(client): keep unnameable members and split-reply scenes on older merged replies ### 📊 Changes **5 files changed** (+442 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `e2e/narrator-macro-avatars.e2e.ts` (+79 -0) 📝 `packages/client/src/components/chat/ChatMessage.tsx` (+17 -1) 📝 `packages/client/src/components/chat/ChatRoleplaySurface.tsx` (+45 -2) 📝 `packages/client/src/components/chat/merged-avatar-roster.ts` (+97 -15) 📝 `scripts/regressions/merged-chat-historical-avatars.regression.ts` (+204 -6) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. ## Linked issue Closes #8823 ## Why this change Issue #8823 is a follow-up to #8762 / PR #8800. In a merged Roleplay group chat, historical replies showed avatars for every chat member. Characters who were not in a reply's scene appeared with their regular avatars next to the participants' expression portraits. #8800 kept older replies from losing avatars when the roster shrank, but its fallback also added the whole live roster. So whenever the active roster was larger than the reply's scene (auto-selection off, or members reactivated), older replies gained the absent characters. A historical reply should show only the cast of its own scene: its saved roster, or for an older reply the members its own expression result names. It should fall back to the live roster only when it carries no per-character data at all. ## What changed - `resolveMergedAvatarRoster` (packages/client/src/components/chat/merged-avatar-roster.ts): a saved reply now shows only its own scene. That is `mergedReplyRoster(extra, chatCharacterIds)` filtered to current members: the saved roster, or for an older reply the members named by `expressionSpriteIds` and the `spriteExpressions` keys. The live roster is no longer added. A reply with no per-character data at all keeps the old live-roster behaviour; so does a reply whose saved roster has entirely left the chat. A `ponytail:` comment documents this, with the upgrade path of backfilling from speaker tags. - Unchanged: streaming and regenerating replies still follow the live roster; Continue still streams with the reply's own roster plus the live one, which is what the server saves. Server code, the shared `mergedReplyRoster`, ChatMessage, ChatRoleplaySurface and the outside-card avatars from `referencedCharacterIds` are untouched. The persona and non-members are still filtered out of the fallback. - scripts/regressions/merged-chat-historical-avatars.regression.ts: added a four-member chat (Ana, Ben, Cal, Dee). The server generates a reply with Cal and Dee inactive and the test asserts the saved roster is `[Ana, Ben]`. With everyone active again it asserts the exact avatar list for (a) the saved reply `[Ana, Ben]`, (b) an older reply with an expression list `[Ana, Ben]`, (b) an older reply with expression keys only `[Ana, Ben]`, (c) an older reply with no expression data (all four), (d) a greeting created through the API as Cal's message (all four), plus a new streaming reply (all four). The header comment was updated to describe the new rule. - e2e/narrator-macro-avatars.e2e.ts: new desktop-only test, "historical narrator replies show only the characters of their own scene". It builds a four-member merged chat with solid-colour portraits and creates cases (a)–(d) through the API, with a user turn before each so replies don't group and hide avatars. It checks the exact rendered `.mari-message-avatar img` count and which portrait srcs appear for each row. - Older merged Roleplay replies (saved before #8800) keep the avatars of active members that no expression result could name: members without sprites the chat shows, or outside its sprite selection. Members with sprites who were absent from the scene stay hidden. - In older replies split at scene breaks, the first part now shows its own scene, taken from the reply's last part, instead of the whole live roster. ## Validation <!-- These are human tasks. Never tick a box for a check that was not actually performed. --> - [ ] `pnpm check` passes locally - [ ] Ran the app, clicked through the changes manually ### Manual verification notes - Manually verify in the browser: in a merged Roleplay group with four characters, open an older reply (saved before #8800) whose Expression Engine result names only two of them, with all four active. Only those two avatars should cycle, with their expression portraits, and the other two should not appear. - Manually verify that a reply generated after #8800 with only two of four characters active keeps showing only those two after you reactivate the other two or turn automatic selection off. - Manually verify that an older reply with no expression data, and a greeting, still show the current active roster and never an inactive member's avatar. - Manually verify that the next generated reply streams and saves with the full current active roster, and that regenerating an older reply shows the live roster while it streams and after it saves. - Manually verify Continue on an older reply whose expression data names two of four active characters: the stream and the saved reply should show the same avatars (its two plus the live roster), with no jump when the stream finishes. - Manually verify that a narrator reply with ID-macro references still shows the referenced outside character's avatar alongside its scene roster. - Manually verify Visual Novel mode and a mobile viewport: the active VN message and historical replies follow the same scene-only rule. Agent-run checks (for reference): - node ./scripts/run-regressions.mjs --filter scripts/regressions/merged-chat-historical-avatars.regression.ts: PASSED (1/1 passed; 0 failed). Run against two mutations first: with the unnameable-member fix reverted it FAILED on the Ben-without-sprites assertion, and with the split-part fix reverted it FAILED on the older split re - PLAYWRIGHT_CLIENT_PORT=5801 PLAYWRIGHT_SERVER_PORT=7801 PLAYWRIGHT_MOBILE_CLIENT_PORT=5802 PLAYWRIGHT_MOBILE_SERVER_PORT=7802 PLAYWRIGHT_ONLY_PROJECT=desktop np: 7 passed (2.3m). With both fixes reverted, the scene-only test failed (expected 3 avatars, received 2); after restoring the fixes it passes again. - node ./scripts/pnpm-runner.mjs check: Exit 0 (impeccable, localization, format, lint, e2e types, token-estimation types, build). - npx tsc --noEmit -p packages/client: Exit 0, no errors. - node ./scripts/run-regressions.mjs --filter <each of tts-source-persistence, open-issues, roleplay-swipe-media, narrator-avatar-borders, avatar-stage-logic, tts: Each 1/1 passed; 0 failed. These are the regressions that read the touched client sources. Independent review of 39418eea1f: changes (1 medium, 1 low), both fixed in 2dffef22ca: older replies keep active members no expression result could name (no sprites, or outside the sprite selection), and older split replies show their own scene from the reply's last part. Dottore Review: Viable, With Notes, no defects. Known limits and risks: - Older replies with expression data: a member who was in the scene but had no expression entry (for example, no sprites) is no longer shown, even when currently active. Before this change the live roster brought them back. - Older replies with no expression data, greetings and API-created messages still show the live active roster, so they gain or lose avatars as the roster changes. Speaker tags are not stored as per-message IDs and were not parsed. Upgrade path: backfill `mergedRosterCharacterIds` from speaker tags. - Replies saved since #8800 show their saved roster, which is the active roster when they were generated. If all four characters were active then (auto-selection off), all four show even if the narrator wrote only two into the scene. The active list defines the scene; this is unchanged. - Continue is unchanged from #8800: it saves the reply's own roster plus the live one. Continuing an A/B reply while all four are active makes it show all four afterwards. - Stale `spriteExpressions` keys remain the limit noted in #8800. If an Expression Engine retry wrote an empty `expressionSpriteIds` but left the old map, the old map's members still count as the reply's scene. - Outside-card avatars from `referencedCharacterIds` (ID-macro references) still appear as before. They never include chat members. - Not checked by hand in a browser beyond the Playwright run. Visual Novel mode and mobile were not exercised by the new test. - An older merged reply without a saved roster decides which members its expression result could never name from today's sprites, sprite selection and display modes, not the ones in place when it was written. If a member gains sprites later, they disappear from that reply's avatars. If the sprite selection is narrowed later, members outside it reappear. - An active member who had sprites but whom the older reply's expression result left out is still hidden from that reply. The upgrade path is unchanged: backfill `mergedRosterCharacterIds` from speaker tags. - When a member's sprite list has not loaded yet, they count as nameable, so their avatar appears on older replies once the list arrives. The list is shared with the existing sprite caches and kept for 5 minutes. - An older split reply whose last part has not loaded yet (beyond the loaded history page) still falls back to the live roster on its first part. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:40:03 +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#8831
No description provided.