[PR #6110] [MERGED] feat: add reversible Roleplay interruption #7064

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

📋 Pull Request Information

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

Base: staging ← Head: feat/roleplay-interrupt


📝 Commits (3)

  • bc00354 chore: track roleplay interrupt implementation
  • 3e8cb6b feat: add reversible Roleplay interruption command
  • 51dfc8d fix: refresh restored interruption swipes and gate prompt availability

📊 Changes

20 files changed (+1875 additions, -50 deletions)

View changed files

📝 CHANGELOG.md (+3 -0)
📝 docs/roleplay/getting-started.md (+8 -0)
📝 e2e/roleplay-commands.e2e.ts (+214 -0)
📝 packages/client/src/components/chat/RoleplayCommandResults.tsx (+43 -3)
📝 packages/client/src/hooks/use-chats.ts (+17 -0)
📝 packages/client/src/hooks/use-generate.ts (+16 -0)
➕ packages/client/src/hooks/use-roleplay-commands.ts (+48 -0)
📝 packages/client/src/localization/locales/en.json (+5 -0)
📝 packages/server/src/routes/chats.routes.ts (+100 -32)
📝 packages/server/src/routes/generate.routes.ts (+134 -7)
📝 packages/server/src/routes/index.ts (+2 -0)
📝 packages/server/src/services/generation/roleplay-commands.ts (+9 -0)
➕ packages/server/src/services/generation/roleplay-interrupt-context.ts (+46 -0)
➕ packages/server/src/services/generation/roleplay-interrupt.ts (+63 -0)
📝 packages/server/src/services/import/st-chat.importer.ts (+1 -0)
📝 packages/server/src/services/storage/chats.storage.ts (+375 -7)
📝 packages/shared/src/types/roleplay-command.ts (+12 -1)
📝 scripts/regressions/roleplay-commands.regression.ts (+81 -0)
➕ scripts/regressions/roleplay-interrupt-generation.regression.ts (+317 -0)
➕ scripts/regressions/roleplay-interrupt-storage.regression.ts (+381 -0)

📄 Description

Linked issue

Closes #6109

Why this change

Roleplay characters need a reversible way to interrupt the latest dialogue or action before the rest happens. The original message must remain recoverable, and rerolls must receive its full content.

What changed

  • Add the opt-in Interruptions toggle to the existing Roleplay Commands settings. The short prompt permits a plausible verbal or physical intervention in the latest user or other-character message.
  • Match a unique, literal phrase of at least three words, keep text through that phrase, and finish it with an interruption dash and any dialogue closing quote. Invalid or ambiguous commands leave the message unchanged.
  • Keep the original text in the response's existing command activity. Restore original message, rerolls, and swipe changes recover or apply the appropriate version without overwriting later manual edits. The cut and recovery record are saved together.
  • Update live messages and subsequent group prompts immediately. Preserve recovery records through branches and JSONL copies; reuse existing memory invalidation, message queues, parser, streaming filter, and themed command disclosure. No new dependency or database table.
  • Keep command details readable in light themes by using the existing Chroma panel text color instead of inheriting custom message color/stroke.

Validation

  • pnpm install --frozen-lockfile completed.

  • pnpm check and pnpm regression:prompt passed, including localization, TypeScript, lint, and builds.

  • Focused command, interruption storage, and real generation-route regressions passed. They cover literal/ambiguous matching, escaped regex punctuation, dialogue/actions, opt-out and visibility gates, full original reroll prompts, failed/cancelled rerolls, cancellation during saving and queued commits, active-generation Restore conflicts, and consecutive user/character cuts in a three-character group with Advanced Memory enabled.

  • Storage proof also covers later edits, swipe renumbering, deletion, transaction rollback, branch/JSONL recovery, and bounded ordinary bulk-deletion reads. Existing message-mutation-race and branch-lineage regressions passed.

  • Focused pnpm smoke:ui e2e/roleplay-commands.e2e.ts --grep 'Roleplay interruptions' passed: desktop Chromium 1/1, mobile Chromium + WebKit 2/2. It exercises the default-off toggle, real generation/SSE cut, keyboard disclosure, themed text, pending Restore, reload persistence, and later manual-edit conflict.

  • 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 verify dialogue and action interruption, Restore, and rerolls with a real model.
  • Manually verify the command controls on a physical phone.

Docs and release impact

Updated CHANGELOG.md and docs/roleplay/getting-started.md. Translated documentation follow-up: #6111. No new dependency, schema migration, or version bump.

The automated model fixture verifies Engine behavior; a live model's decision to interrupt and physical-phone interaction remain manual verification items above.

UI evidence (if applicable)

Synthetic browser screenshots: settings before/after enabling Interruptions and the cut dialogue with Restore, in light/dark themes on all three browsers. These use isolated fixture data and viewport emulation.

Summary by CodeRabbit

  • New Features

    • Added an opt-in Roleplay interruption command that can cut off the latest dialogue or action at a specified point.
    • Interruptions preserve the complete original context for rerolls and support restoring the original message.
    • Added safeguards for manual edits and active generations.
  • Bug Fixes

    • Improved Roleplay command readability in light themes when custom message text colors are used.
  • Documentation

    • Added guidance for enabling and using character interruptions, including restoration, rerolls, swipes, and manual edits.

🔄 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/6110 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/12/2026 **Status:** ✅ Merged **Merged:** 9/12/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/roleplay-interrupt` --- ### 📝 Commits (3) - [`bc00354`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bc003548f13792c3a64d0cf6ff50ad51a492994d) chore: track roleplay interrupt implementation - [`3e8cb6b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3e8cb6b358bd87b113a7fccacb84c67c523d1cfa) feat: add reversible Roleplay interruption command - [`51dfc8d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/51dfc8d4a4f9cd9d36b6e3bce2ad305c0852f3d0) fix: refresh restored interruption swipes and gate prompt availability ### 📊 Changes **20 files changed** (+1875 additions, -50 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -0) 📝 `docs/roleplay/getting-started.md` (+8 -0) 📝 `e2e/roleplay-commands.e2e.ts` (+214 -0) 📝 `packages/client/src/components/chat/RoleplayCommandResults.tsx` (+43 -3) 📝 `packages/client/src/hooks/use-chats.ts` (+17 -0) 📝 `packages/client/src/hooks/use-generate.ts` (+16 -0) ➕ `packages/client/src/hooks/use-roleplay-commands.ts` (+48 -0) 📝 `packages/client/src/localization/locales/en.json` (+5 -0) 📝 `packages/server/src/routes/chats.routes.ts` (+100 -32) 📝 `packages/server/src/routes/generate.routes.ts` (+134 -7) 📝 `packages/server/src/routes/index.ts` (+2 -0) 📝 `packages/server/src/services/generation/roleplay-commands.ts` (+9 -0) ➕ `packages/server/src/services/generation/roleplay-interrupt-context.ts` (+46 -0) ➕ `packages/server/src/services/generation/roleplay-interrupt.ts` (+63 -0) 📝 `packages/server/src/services/import/st-chat.importer.ts` (+1 -0) 📝 `packages/server/src/services/storage/chats.storage.ts` (+375 -7) 📝 `packages/shared/src/types/roleplay-command.ts` (+12 -1) 📝 `scripts/regressions/roleplay-commands.regression.ts` (+81 -0) ➕ `scripts/regressions/roleplay-interrupt-generation.regression.ts` (+317 -0) ➕ `scripts/regressions/roleplay-interrupt-storage.regression.ts` (+381 -0) </details> ### 📄 Description ## Linked issue Closes #6109 ## Why this change Roleplay characters need a reversible way to interrupt the latest dialogue or action before the rest happens. The original message must remain recoverable, and rerolls must receive its full content. ## What changed - Add the opt-in **Interruptions** toggle to the existing Roleplay Commands settings. The short prompt permits a plausible verbal or physical intervention in the latest user or other-character message. - Match a unique, literal phrase of at least three words, keep text through that phrase, and finish it with an interruption dash and any dialogue closing quote. Invalid or ambiguous commands leave the message unchanged. - Keep the original text in the response's existing command activity. **Restore original message**, rerolls, and swipe changes recover or apply the appropriate version without overwriting later manual edits. The cut and recovery record are saved together. - Update live messages and subsequent group prompts immediately. Preserve recovery records through branches and JSONL copies; reuse existing memory invalidation, message queues, parser, streaming filter, and themed command disclosure. No new dependency or database table. - Keep command details readable in light themes by using the existing Chroma panel text color instead of inheriting custom message color/stroke. ## Validation - `pnpm install --frozen-lockfile` completed. - `pnpm check` and `pnpm regression:prompt` passed, including localization, TypeScript, lint, and builds. - Focused command, interruption storage, and real generation-route regressions passed. They cover literal/ambiguous matching, escaped regex punctuation, dialogue/actions, opt-out and visibility gates, full original reroll prompts, failed/cancelled rerolls, cancellation during saving and queued commits, active-generation Restore conflicts, and consecutive user/character cuts in a three-character group with Advanced Memory enabled. - Storage proof also covers later edits, swipe renumbering, deletion, transaction rollback, branch/JSONL recovery, and bounded ordinary bulk-deletion reads. Existing message-mutation-race and branch-lineage regressions passed. - Focused `pnpm smoke:ui e2e/roleplay-commands.e2e.ts --grep 'Roleplay interruptions'` passed: desktop Chromium **1/1**, mobile Chromium + WebKit **2/2**. It exercises the default-off toggle, real generation/SSE cut, keyboard disclosure, themed text, pending Restore, reload persistence, and later manual-edit conflict. - [ ] `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 verify dialogue and action interruption, Restore, and rerolls with a real model. - Manually verify the command controls on a physical phone. ## Docs and release impact Updated `CHANGELOG.md` and `docs/roleplay/getting-started.md`. Translated documentation follow-up: #6111. No new dependency, schema migration, or version bump. The automated model fixture verifies Engine behavior; a live model's decision to interrupt and physical-phone interaction remain manual verification items above. ## UI evidence (if applicable) [Synthetic browser screenshots](https://gist.github.com/SpicyMarinara/59bffc64ced90ba9e24a1808b41032fb): settings before/after enabling Interruptions and the cut dialogue with Restore, in light/dark themes on all three browsers. These use isolated fixture data and viewport emulation. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added an opt-in Roleplay interruption command that can cut off the latest dialogue or action at a specified point. - Interruptions preserve the complete original context for rerolls and support restoring the original message. - Added safeguards for manual edits and active generations. - **Bug Fixes** - Improved Roleplay command readability in light themes when custom message text colors are used. - **Documentation** - Added guidance for enabling and using character interruptions, including restoration, rerolls, swipes, and manual edits. <!-- 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:16:12 +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#7064
No description provided.