[PR #5970] [MERGED] feat(roleplay): add opt-in commands, private notes, and real rolls #7003

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

📋 Pull Request Information

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

Base: staging ← Head: feat/roleplay-commands


📝 Commits (4)

  • 726ba80 feat(roleplay): add opt-in character commands
  • c96a771 test(roleplay): align agent activation proof with command turns
  • 31d60c0 fix(roleplay): isolate cancellation of shared sound requests
  • 7ff970b Merge remote-tracking branch 'origin/staging' into feat/roleplay-commands

📊 Changes

24 files changed (+2016 additions, -89 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
➕ e2e/roleplay-commands.e2e.ts (+477 -0)
📝 packages/client/src/components/chat/ChatMessage.tsx (+4 -2)
📝 packages/client/src/components/chat/ChatRoleplaySurface.tsx (+7 -1)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+28 -15)
➕ packages/client/src/components/chat/RoleplayCommandResults.tsx (+53 -0)
➕ packages/client/src/components/chat/RoleplayCommandsSettings.tsx (+151 -0)
📝 packages/client/src/hooks/use-generate.ts (+30 -1)
📝 packages/client/src/localization/locales/en.json (+33 -0)
📝 packages/server/src/routes/generate.routes.ts (+378 -61)
📝 packages/server/src/routes/generate/conversation-prompt-formatting.ts (+10 -0)
📝 packages/server/src/routes/generate/dry-run-route.ts (+46 -0)
📝 packages/server/src/routes/tts.routes.ts (+43 -0)
📝 packages/server/src/services/conversation/character-commands.ts (+1 -1)
📝 packages/server/src/services/generation/generation-parameters.ts (+1 -1)
➕ packages/server/src/services/generation/roleplay-commands.ts (+376 -0)
📝 packages/shared/src/index.ts (+1 -0)
📝 packages/shared/src/types/chat.ts (+14 -0)
➕ packages/shared/src/types/roleplay-command.ts (+43 -0)
📝 scripts/regressions/agent-activation.regression.ts (+5 -3)

...and 4 more files

📄 Description

Linked issue

Closes #5969

Why this change

Roleplay characters can forget that they lied, lose a cover story, or miss a planned follow-up when reasoning is not replayed between turns. This adds private character state and scene-appropriate commands through the familiar Conversation settings controls, with an optional narrator able to use those intentions without giving every character access.

What changed

  • Add Commands to the Roleplay Agents drawer, with a master switch and independent toggles for illustrations, documents, sound cues, soundtrack changes, personal notes, reminders, dice rolls, and DMs. New commands default off; explicit legacy DM opt-ins remain enabled. Expressions and scene-break commands are excluded.
  • Scope notes and keyed reminders to their author and an optional narrator selected from individual-group participants. Notes replace the previous notes and explicitly preserve lies, deceptions, motives, secrets, cover stories, and plans; reminders survive note rewrites. State follows selected swipes, regeneration, continuation, and branches.
  • Append private context and enabled command instructions to the final responder prompt in XML, Markdown, or None format, after tracker context. Strip hidden commands during streaming and keep private state and opaque reasoning out of shared prompt history and agent previews.
  • Resolve real dice through the existing tool executor before continuing the same visible reply. Support native tool calls and a text-command fallback that stops the upstream stream and discards invented post-roll outcomes.
  • Reuse the existing Illustrator, Music DJ, cached audio, and DM host integrations. Render in-world documents and sound attachments, and add canonical English UI copy and an Unreleased changelog entry. No downloadable agent definitions, dependencies, migrations, or version files 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

Completed automated evidence (checkboxes remain a human to-do list):

  • pnpm check and pnpm regression:prompt passed. The existing lint warning in untouched GameNarration.tsx remains.
  • Focused command parsing/privacy, Roleplay streaming, past-reasoning, Game dice, and TTS regressions passed. Tests cover all three prompt formats, default-off and legacy DM behavior, incomplete-command hiding, narrator/other-character boundaries, and cancelled sound requests. A production-function regression reproduces and fixes cross-chat cancellation: cancelling one Roleplay waiter releases only that waiter while shared generation remains available to other Roleplay and Game callers, with abort listeners cleaned up and late provider failures handled.
  • All 12 new browser cases passed across desktop Chromium, mobile Chromium, and mobile WebKit on the final code, including focused reruns. Browser tests capture actual mock-provider requests and inspect persisted message/swipe extras for notes, reminders, documents, branches, continuation, and native/textual rolls. Cached audio exercises the real attachment and browser playback-request path without paid generation.
  • Full pnpm smoke:ui: 619 passed, 228 skipped, 17 failed. All 17 failed cases passed in isolation with --last-failed --workers=1; the broad run was not a clean pass. A later sound-selector assertion collided on identical names from two mobile fixtures; it was scoped to the unique connection ID, and all three sound cases passed afterward.
  • git diff --check passed. The local Docker image built successfully; a fresh isolated container returned HTTP 200 JSON at /api/health and HTTP 200 HTML at /. The temporary container and its anonymous data volume were removed afterward.
  • On 7ff970b86, project validation, the complete Node suite, Docker build/run checks, security analysis, and nine browser shards passed CI. One mobile WebKit shard closed its page during the unchanged Game Chroma widget test; that exact test passed locally in mobile WebKit, and the failed CI shard is being rerun. The earlier internal WebKit page-reload failure on c96a77120 also passed on rerun.
  • CodeRabbit completed both the Roleplay-fix review on 31d60c042 and the final base-sync review on 7ff970b86, with no new actionable comments. All five original review threads are resolved.

Integration proof with #5970 and the merged #5972 also passed: pnpm check, the Roleplay command and GPT Image 2.5 regressions, and all 15 focused browser cases across desktop Chromium, mobile Chromium, and mobile WebKit. The final branch tree ab24b9356e47590b2dd72adfe0a9938eb8c6fe4a exactly matches that tested combined tree. The Roleplay streaming and TTS regressions also passed after the review fixes.

Manual verification notes

Desktop and mobile Commands screenshots were inspected for layout and reuse of existing theme controls. Automated browser interaction covered default-off toggles, selecting the narrator, documents, sound playback requests, and a roll result visible while the follow-up response was still streaming.

  • Manually verify live Illustrator generation and Music DJ playback through a configured external player.
  • Manually verify uncached ElevenLabs sound generation and audible playback on real devices.
  • Manually verify light/dark themes and provider-specific function calls beyond the tested native and text fallback protocols.

Privacy proof covers routing and hiding command text in the normal transcript. It does not claim that an LLM cannot disclose a secret in ordinary narration or that raw chat/debug data is encrypted from the application owner.

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.md and the canonical English UI catalog are updated. No docs/ files or version-bearing files change.

UI evidence (if applicable)

Desktop/mobile screenshots and verification report. Download the gist ZIP and open the HTML files to view the embedded, unmodified screenshots. The files need no scripts or external assets; screenshot artifacts are not committed to this repository. A pre-feature baseline screenshot was not captured.

Summary by CodeRabbit

  • New Features

    • Added opt-in Roleplay Commands for illustrations, documents, sound effects, music, notes, reminders, dice rolls, and direct messages.
    • Added per-command controls, narrator selection, and audio connection settings in the Agents drawer.
    • Displays generated documents, audio controls, and dice-roll results in roleplay messages.
  • Privacy & Reliability

    • Commands are disabled by default, with private content scoped to the appropriate characters.
    • Results persist across regenerations, swipes, branches, and continuations.
    • Dice rolls resolve before narration continues, and sound cancellation does not interrupt other chats.

🔄 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/5970 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/8/2026 **Status:** ✅ Merged **Merged:** 9/8/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/roleplay-commands` --- ### 📝 Commits (4) - [`726ba80`](https://github.com/Pasta-Devs/Marinara-Engine/commit/726ba80651b985e0c776646e23b02ce0ad079d1f) feat(roleplay): add opt-in character commands - [`c96a771`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c96a77120c415041da920d904eeef499a440480a) test(roleplay): align agent activation proof with command turns - [`31d60c0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/31d60c0424332e954d25f526a7fe6116e33e2cef) fix(roleplay): isolate cancellation of shared sound requests - [`7ff970b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7ff970b86e1115a2d83d4d64f43487b1978b82c2) Merge remote-tracking branch 'origin/staging' into feat/roleplay-commands ### 📊 Changes **24 files changed** (+2016 additions, -89 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) ➕ `e2e/roleplay-commands.e2e.ts` (+477 -0) 📝 `packages/client/src/components/chat/ChatMessage.tsx` (+4 -2) 📝 `packages/client/src/components/chat/ChatRoleplaySurface.tsx` (+7 -1) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+28 -15) ➕ `packages/client/src/components/chat/RoleplayCommandResults.tsx` (+53 -0) ➕ `packages/client/src/components/chat/RoleplayCommandsSettings.tsx` (+151 -0) 📝 `packages/client/src/hooks/use-generate.ts` (+30 -1) 📝 `packages/client/src/localization/locales/en.json` (+33 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+378 -61) 📝 `packages/server/src/routes/generate/conversation-prompt-formatting.ts` (+10 -0) 📝 `packages/server/src/routes/generate/dry-run-route.ts` (+46 -0) 📝 `packages/server/src/routes/tts.routes.ts` (+43 -0) 📝 `packages/server/src/services/conversation/character-commands.ts` (+1 -1) 📝 `packages/server/src/services/generation/generation-parameters.ts` (+1 -1) ➕ `packages/server/src/services/generation/roleplay-commands.ts` (+376 -0) 📝 `packages/shared/src/index.ts` (+1 -0) 📝 `packages/shared/src/types/chat.ts` (+14 -0) ➕ `packages/shared/src/types/roleplay-command.ts` (+43 -0) 📝 `scripts/regressions/agent-activation.regression.ts` (+5 -3) _...and 4 more files_ </details> ### 📄 Description ## Linked issue Closes #5969 ## Why this change Roleplay characters can forget that they lied, lose a cover story, or miss a planned follow-up when reasoning is not replayed between turns. This adds private character state and scene-appropriate commands through the familiar Conversation settings controls, with an optional narrator able to use those intentions without giving every character access. ## What changed - Add Commands to the Roleplay Agents drawer, with a master switch and independent toggles for illustrations, documents, sound cues, soundtrack changes, personal notes, reminders, dice rolls, and DMs. New commands default off; explicit legacy DM opt-ins remain enabled. Expressions and scene-break commands are excluded. - Scope notes and keyed reminders to their author and an optional narrator selected from individual-group participants. Notes replace the previous notes and explicitly preserve lies, deceptions, motives, secrets, cover stories, and plans; reminders survive note rewrites. State follows selected swipes, regeneration, continuation, and branches. - Append private context and enabled command instructions to the final responder prompt in XML, Markdown, or None format, after tracker context. Strip hidden commands during streaming and keep private state and opaque reasoning out of shared prompt history and agent previews. - Resolve real dice through the existing tool executor before continuing the same visible reply. Support native tool calls and a text-command fallback that stops the upstream stream and discards invented post-roll outcomes. - Reuse the existing Illustrator, Music DJ, cached audio, and DM host integrations. Render in-world documents and sound attachments, and add canonical English UI copy and an Unreleased changelog entry. No downloadable agent definitions, dependencies, migrations, or version files 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` Completed automated evidence (checkboxes remain a human to-do list): - `pnpm check` and `pnpm regression:prompt` passed. The existing lint warning in untouched `GameNarration.tsx` remains. - Focused command parsing/privacy, Roleplay streaming, past-reasoning, Game dice, and TTS regressions passed. Tests cover all three prompt formats, default-off and legacy DM behavior, incomplete-command hiding, narrator/other-character boundaries, and cancelled sound requests. A production-function regression reproduces and fixes cross-chat cancellation: cancelling one Roleplay waiter releases only that waiter while shared generation remains available to other Roleplay and Game callers, with abort listeners cleaned up and late provider failures handled. - All 12 new browser cases passed across desktop Chromium, mobile Chromium, and mobile WebKit on the final code, including focused reruns. Browser tests capture actual mock-provider requests and inspect persisted message/swipe extras for notes, reminders, documents, branches, continuation, and native/textual rolls. Cached audio exercises the real attachment and browser playback-request path without paid generation. - Full `pnpm smoke:ui`: 619 passed, 228 skipped, 17 failed. All 17 failed cases passed in isolation with `--last-failed --workers=1`; the broad run was not a clean pass. A later sound-selector assertion collided on identical names from two mobile fixtures; it was scoped to the unique connection ID, and all three sound cases passed afterward. - `git diff --check` passed. The local Docker image built successfully; a fresh isolated container returned HTTP 200 JSON at `/api/health` and HTTP 200 HTML at `/`. The temporary container and its anonymous data volume were removed afterward. - On `7ff970b86`, project validation, the complete Node suite, Docker build/run checks, security analysis, and nine browser shards passed CI. One mobile WebKit shard closed its page during the unchanged Game Chroma widget test; that exact test passed locally in mobile WebKit, and the failed CI shard is being rerun. The earlier internal WebKit page-reload failure on `c96a77120` also passed on rerun. - CodeRabbit completed both the Roleplay-fix review on `31d60c042` and the final base-sync review on `7ff970b86`, with no new actionable comments. All five original review threads are resolved. Integration proof with #5970 and the merged #5972 also passed: `pnpm check`, the Roleplay command and GPT Image 2.5 regressions, and all 15 focused browser cases across desktop Chromium, mobile Chromium, and mobile WebKit. The final branch tree `ab24b9356e47590b2dd72adfe0a9938eb8c6fe4a` exactly matches that tested combined tree. The Roleplay streaming and TTS regressions also passed after the review fixes. ### Manual verification notes Desktop and mobile Commands screenshots were inspected for layout and reuse of existing theme controls. Automated browser interaction covered default-off toggles, selecting the narrator, documents, sound playback requests, and a roll result visible while the follow-up response was still streaming. - Manually verify live Illustrator generation and Music DJ playback through a configured external player. - Manually verify uncached ElevenLabs sound generation and audible playback on real devices. - Manually verify light/dark themes and provider-specific function calls beyond the tested native and text fallback protocols. Privacy proof covers routing and hiding command text in the normal transcript. It does not claim that an LLM cannot disclose a secret in ordinary narration or that raw chat/debug data is encrypted from the application owner. ## 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.md` and the canonical English UI catalog are updated. No `docs/` files or version-bearing files change. ## UI evidence (if applicable) [Desktop/mobile screenshots and verification report](https://gist.github.com/SpicyMarinara/fc8281b921a55d076222fb725ed09003). Download the gist ZIP and open the HTML files to view the embedded, unmodified screenshots. The files need no scripts or external assets; screenshot artifacts are not committed to this repository. A pre-feature baseline screenshot was not captured. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added opt-in Roleplay Commands for illustrations, documents, sound effects, music, notes, reminders, dice rolls, and direct messages. - Added per-command controls, narrator selection, and audio connection settings in the Agents drawer. - Displays generated documents, audio controls, and dice-roll results in roleplay messages. - **Privacy & Reliability** - Commands are disabled by default, with private content scoped to the appropriate characters. - Results persist across regenerations, swipes, branches, and continuations. - Dice rolls resolve before narration continues, and sound cancellation does not interrupt other chats. <!-- 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:15:39 +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#7003
No description provided.