[PR #6551] [MERGED] Fix Roleplay dice styling, memory cutoffs, and POV summaries #7223

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

📋 Pull Request Information

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

Base: staging ← Head: codex/sept22-roleplay-dice-memory-regressions


📝 Commits (3)

  • 73e823e docs: track roleplay dice and token display fixes
  • 9116bae fix: roleplay dice, measured memory cutoffs and POV summaries
  • d9e1d26 test: align Game Peek assertion with reported usage label

📊 Changes

18 files changed (+498 additions, -44 deletions)

View changed files

📝 CHANGELOG.md (+4 -0)
📝 e2e/roleplay-commands.e2e.ts (+44 -1)
📝 e2e/scene-tts-preferences.e2e.ts (+1 -1)
📝 packages/client/src/components/chat/ChatMessage.tsx (+10 -2)
📝 packages/client/src/components/chat/PeekPromptModal.tsx (+18 -1)
📝 packages/client/src/components/chat/chat-area.types.ts (+2 -0)
📝 packages/client/src/components/dice/dice.css (+2 -2)
📝 packages/client/src/hooks/use-chats.ts (+2 -0)
📝 packages/client/src/localization/locales/en.json (+5 -1)
📝 packages/server/src/routes/generate.routes.ts (+10 -0)
📝 packages/server/src/services/advanced-memory.ts (+108 -34)
📝 packages/server/src/services/generation/generation-text-utils.ts (+13 -0)
📝 packages/shared/src/types/chat.ts (+2 -0)
📝 scripts/regressions/advanced-memory-post-generation.regression.ts (+123 -2)
📝 scripts/regressions/advanced-memory-summary.regression.ts (+96 -0)
📝 scripts/regressions/game-tool-controls.regression.ts (+3 -0)
📝 scripts/regressions/game-tool-outcomes.regression.ts (+11 -0)
➕ scripts/regressions/generation-usage.regression.ts (+44 -0)

📄 Description

Linked issue

Closes #6550

Why this change

Roleplay dice outcomes were lavender with a blue accent. Peek Prompt also presented summed tool-request usage as one actual prompt: three requests near 45k input can bill roughly 133k without any one prompt crossing a 65k limit. Advanced Memory only checked its estimate, so genuinely underestimated input could exceed that limit without resetting the live history.

Switching POVs also needs more than a scene participant list: the summary helper must preserve which character knows each fact, using the existing character conditions.

What changed

  • Reuse the dice accent for outcome breakdowns and totals. Label cumulative request usage, and show the last request's input separately in Peek Prompt.
  • After a new main Roleplay reply, compare the largest individual provider-reported input with the configured limit. Include native Claude cache reads/writes; exclude output, summed tool usage, agents and regenerations. When a newer closed scene boundary exists, reuse the shared, reversible start flag and existing Chat Summaries flow. Keep the existing estimate-based guard.
  • Prepend character-name {{#if char == "Name"}} instructions to Advanced Memory summary/compaction prompts in individual-character group chats. Preserve conditions in constants and resolve them before recalled summaries reach the responding character. Include the configured narrator in each knowledge section.
  • For scenes containing character conditions, withhold raw excerpts from non-narrators because excerpts currently have scene-level access only. Plain scene summaries retain their excerpts. Existing summaries are not automatically regenerated.

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/local evidence (checkboxes intentionally left for human verification):

  • pnpm check: passed, including localization, formatting, lint, types and production builds.
  • pnpm regression:prompt: passed.
  • All ten Advanced Memory regression suites passed; the summary suite was rerun after the final POV guards and passed.
  • Generation-usage, game-tool-controls and game-tool-outcomes regressions passed: native Claude cache accounting, cache-inclusive compatible providers, tool totals, swipe metadata and missing final usage.
  • Focused Playwright Roleplay command suite: 12/12 passed across desktop Chromium, mobile Chromium and iPhone-sized WebKit, covering native/textual dice, character/persona targets, light/dark themes and Peek Prompt usage. The full browser suite was not completed locally. CI exposed one older Game Peek assertion still expecting “actual prompt tokens”; it now expects “reported prompt tokens,” and its full Game recovery/Peek test passed locally on all three browser projects (3/3).
  • Red/green reproductions: dice breakdown used lavender before the fix; a 65,001-token input failed to reset before the fix; matching a narrator's summary text could previously permit a raw private excerpt. All now pass. Negative controls cover two 45k requests, large output, exactly 65k input, regenerations, merged/single-character chats and private POV sections. The actual-input reset test also checks the shared flag event and the archived range in Chat Summaries.
  • Local CodeRabbit: completed after two fixes (only request POV markup in separated group chats; require narrator identity for private-scene excerpts). Two final suggestions were reviewed without code changes: singular request wording is unreachable because both labels require requestCount > 1; moving the cutoff into finally would move live history past a newly closed scene even if initializeImpl(...closedOnly: true) failed to archive it. Scene-preparation errors deliberately leave the shared cutoff unchanged. The hosted review finding proposes the same error-path reset; it was reviewed and declined for this reason. commitSceneCheckImpl can persist a closed boundary before initializeImpl finishes its summary, while resetContextForActualInput selects those closed structural records. Running it after a preparation failure could cut history whose recap is not yet available. The existing error reporting and retry path is preserved.

Manual verification notes

Inspected the captured desktop/mobile, light/dark screenshots. Browser and provider tests used synthetic chats and mocked responses, not the maintainer's archive or paid provider calls.

Manually verify native Anthropic Opus 5.5 usage on a real reply crossing the configured input limit, confirm the shared start flag can be cleared, and review the helper's factual POV assignments in a real story. Physical iPhone and Docker build/run were not tested locally.

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)
  • Version/release files updated (only if this PR includes a version bump)

Added user-facing Unreleased notes. No storage migration, release metadata or user-facing documentation changes.

UI evidence (if applicable)

Before/after screenshots and mobile Peek Prompt evidence — standalone HTML containing only synthetic screenshots and explanatory text; no scripts.

Summary by CodeRabbit

  • New Features

    • Token usage distinguishes totals across tool requests from the latest request’s input size.
    • Peek Prompt shows request counts, per-turn prompt usage, latest-request input, and tool-request guidance.
    • Advanced Memory responds to provider-reported input limits and preserves the latest scene recap.
    • Character-specific summaries and Recall results separate private knowledge across points of view.
  • Bug Fixes

    • Roleplay dice breakdowns and totals follow the selected accent color.
    • Hidden scene sections are excluded from exposed excerpts, while narrator recaps retain complete context.

🔄 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/6551 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/22/2026 **Status:** ✅ Merged **Merged:** 9/22/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `codex/sept22-roleplay-dice-memory-regressions` --- ### 📝 Commits (3) - [`73e823e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/73e823ee093069cb895eefacefd4fceb05fdebf7) docs: track roleplay dice and token display fixes - [`9116bae`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9116bae05ca55776ee6a9eae4fffbb5c6c77195e) fix: roleplay dice, measured memory cutoffs and POV summaries - [`d9e1d26`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d9e1d26f9066f436479cb0f691323357f7e5859d) test: align Game Peek assertion with reported usage label ### 📊 Changes **18 files changed** (+498 additions, -44 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+4 -0) 📝 `e2e/roleplay-commands.e2e.ts` (+44 -1) 📝 `e2e/scene-tts-preferences.e2e.ts` (+1 -1) 📝 `packages/client/src/components/chat/ChatMessage.tsx` (+10 -2) 📝 `packages/client/src/components/chat/PeekPromptModal.tsx` (+18 -1) 📝 `packages/client/src/components/chat/chat-area.types.ts` (+2 -0) 📝 `packages/client/src/components/dice/dice.css` (+2 -2) 📝 `packages/client/src/hooks/use-chats.ts` (+2 -0) 📝 `packages/client/src/localization/locales/en.json` (+5 -1) 📝 `packages/server/src/routes/generate.routes.ts` (+10 -0) 📝 `packages/server/src/services/advanced-memory.ts` (+108 -34) 📝 `packages/server/src/services/generation/generation-text-utils.ts` (+13 -0) 📝 `packages/shared/src/types/chat.ts` (+2 -0) 📝 `scripts/regressions/advanced-memory-post-generation.regression.ts` (+123 -2) 📝 `scripts/regressions/advanced-memory-summary.regression.ts` (+96 -0) 📝 `scripts/regressions/game-tool-controls.regression.ts` (+3 -0) 📝 `scripts/regressions/game-tool-outcomes.regression.ts` (+11 -0) ➕ `scripts/regressions/generation-usage.regression.ts` (+44 -0) </details> ### 📄 Description ## Linked issue Closes #6550 ## Why this change Roleplay dice outcomes were lavender with a blue accent. Peek Prompt also presented summed tool-request usage as one actual prompt: three requests near 45k input can bill roughly 133k without any one prompt crossing a 65k limit. Advanced Memory only checked its estimate, so genuinely underestimated input could exceed that limit without resetting the live history. Switching POVs also needs more than a scene participant list: the summary helper must preserve which character knows each fact, using the existing character conditions. ## What changed - Reuse the dice accent for outcome breakdowns and totals. Label cumulative request usage, and show the last request's input separately in Peek Prompt. - After a new main Roleplay reply, compare the largest individual provider-reported input with the configured limit. Include native Claude cache reads/writes; exclude output, summed tool usage, agents and regenerations. When a newer closed scene boundary exists, reuse the shared, reversible start flag and existing Chat Summaries flow. Keep the existing estimate-based guard. - Prepend character-name `{{#if char == "Name"}}` instructions to Advanced Memory summary/compaction prompts in individual-character group chats. Preserve conditions in constants and resolve them before recalled summaries reach the responding character. Include the configured narrator in each knowledge section. - For scenes containing character conditions, withhold raw excerpts from non-narrators because excerpts currently have scene-level access only. Plain scene summaries retain their excerpts. Existing summaries are not automatically regenerated. ## 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/local evidence (checkboxes intentionally left for human verification): - `pnpm check`: passed, including localization, formatting, lint, types and production builds. - `pnpm regression:prompt`: passed. - All ten Advanced Memory regression suites passed; the summary suite was rerun after the final POV guards and passed. - Generation-usage, game-tool-controls and game-tool-outcomes regressions passed: native Claude cache accounting, cache-inclusive compatible providers, tool totals, swipe metadata and missing final usage. - Focused Playwright Roleplay command suite: 12/12 passed across desktop Chromium, mobile Chromium and iPhone-sized WebKit, covering native/textual dice, character/persona targets, light/dark themes and Peek Prompt usage. The full browser suite was not completed locally. CI exposed one older Game Peek assertion still expecting “actual prompt tokens”; it now expects “reported prompt tokens,” and its full Game recovery/Peek test passed locally on all three browser projects (3/3). - Red/green reproductions: dice breakdown used lavender before the fix; a 65,001-token input failed to reset before the fix; matching a narrator's summary text could previously permit a raw private excerpt. All now pass. Negative controls cover two 45k requests, large output, exactly 65k input, regenerations, merged/single-character chats and private POV sections. The actual-input reset test also checks the shared flag event and the archived range in Chat Summaries. - Local CodeRabbit: completed after two fixes (only request POV markup in separated group chats; require narrator identity for private-scene excerpts). Two final suggestions were reviewed without code changes: singular request wording is unreachable because both labels require `requestCount > 1`; moving the cutoff into `finally` would move live history past a newly closed scene even if `initializeImpl(...closedOnly: true)` failed to archive it. Scene-preparation errors deliberately leave the shared cutoff unchanged. The hosted [review finding](https://github.com/Pasta-Devs/Marinara-Engine/pull/6551#discussion_r4076721140) proposes the same error-path reset; it was reviewed and declined for this reason. `commitSceneCheckImpl` can persist a closed boundary before `initializeImpl` finishes its summary, while `resetContextForActualInput` selects those closed structural records. Running it after a preparation failure could cut history whose recap is not yet available. The existing error reporting and retry path is preserved. ### Manual verification notes Inspected the captured desktop/mobile, light/dark screenshots. Browser and provider tests used synthetic chats and mocked responses, not the maintainer's archive or paid provider calls. Manually verify native Anthropic Opus 5.5 usage on a real reply crossing the configured input limit, confirm the shared start flag can be cleared, and review the helper's factual POV assignments in a real story. Physical iPhone and Docker build/run were not tested locally. ## 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`) - [ ] Version/release files updated (only if this PR includes a version bump) Added user-facing Unreleased notes. No storage migration, release metadata or user-facing documentation changes. ## UI evidence (if applicable) [Before/after screenshots and mobile Peek Prompt evidence](https://gist.github.com/SpicyMarinara/a28241d58e22b9629e6d4193e511cf13) — standalone HTML containing only synthetic screenshots and explanatory text; no scripts. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Token usage distinguishes totals across tool requests from the latest request’s input size. - Peek Prompt shows request counts, per-turn prompt usage, latest-request input, and tool-request guidance. - Advanced Memory responds to provider-reported input limits and preserves the latest scene recap. - Character-specific summaries and Recall results separate private knowledge across points of view. - **Bug Fixes** - Roleplay dice breakdowns and totals follow the selected accent color. - Hidden scene sections are excluded from exposed excerpts, while narrator recaps retain complete context. <!-- 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:17:40 +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#7223
No description provided.