[PR #7677] [MERGED] refactor(generate): move the roleplay roll handling into roleplay-rolls helpers (#7573, slice 6) #7875

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7677
Author: @Gunterlie
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @Gunterlie

Base: staging ← Head: chore/7573-roleplay-roll-helpers


📝 Commits (2)

  • 4ad4539 refactor(generate): move the roleplay roll handling into roleplay-rolls helpers
  • e47ef60 Merge remote-tracking branch 'origin/staging' into chore/7573-roleplay-roll-helpers

📊 Changes

4 files changed (+313 additions, -95 deletions)

View changed files

📝 packages/server/src/routes/generate.routes.ts (+16 -38)
📝 packages/server/src/routes/generate/tool-rounds.ts (+25 -56)
📝 packages/server/src/services/generation/roleplay-rolls.ts (+136 -1)
➕ scripts/regressions/roleplay-roll-helpers.regression.ts (+136 -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

Part of #7573 (sixth slice). Stacked on #7676: merge it first; GitHub retargets this PR to staging when its base branch is deleted.

Why this change

The roleplay roll handling was spread over the route and the tool-call loop: when rolls are on, how the roll tool gets the participant list, how a [roll: …] written as text becomes a roll tool call, what the roll activity entry holds, the text the model gets after a roll, and how a roll in the last round is cut. These rules were inline code between stream and message handling. As pure helpers next to prepareRoleplayRoll, each rule has a direct test, and the loop reads as a sequence of named steps.

No behaviour change.

What changed

  • packages/server/src/services/generation/roleplay-rolls.ts gets six pure helpers: isRoleplayRollEnabled, withRoleplayRollSchema, textualRollToolCall, rollActivityFromToolResult, rollResultFollowUp and cutPendingRoll.
  • generate.routes.ts and generate/tool-rounds.ts call them. The stream abort on a roll request, the SSE events, the message shapes (a textual roll has no tool_calls and its result goes back as a user message) and their order stay in the loop.
  • New scripts/regressions/roleplay-roll-helpers.regression.ts: the enable conditions (game mode, impersonate, narrator-only audience, the tool fallback), the schema (enum, attribute, required, other tools untouched, no mutation of shared tool definitions), the textual roll (cuts, call arguments, no id drawn without a roll), the activity entry, the follow-up text on the last round only, and the pending-roll cut (including a cut to an empty string).

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

Agent-run results (not a substitute for the boxes above):

  • pnpm check: passed.
  • Regressions: a sweep of 109 passed, run one at a time: the new one, every regression that reads generate.routes.ts or tool-rounds.ts, and every one that covers rolls. No source pin needed a change.
  • Local CodeRabbit: 0 findings. A separate review compared each helper with the old expressions and found no change.

Manual verification notes

  • Manually verify a roleplay chat with Rolls on: a [roll: …] stops the stream, the roll card shows, and the reply continues with the result.
  • Manually verify a group roleplay: the roll tool offers the participants' names.
  • Manually verify that a roll the model asks for in the last tool round is cut and the roll-limit notice shows.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) 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)

Summary by CodeRabbit

  • Roleplay
    • Dice rolls are now handled in eligible roleplay chats, including roll requests written in conversation text.
    • Roll results are added to the conversation, with a notice when no further rolls are available in the final round.

🔄 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/7677 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `chore/7573-roleplay-roll-helpers` --- ### 📝 Commits (2) - [`4ad4539`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4ad4539f54c81aa1d53c0065f4218de2fb4e35ea) refactor(generate): move the roleplay roll handling into roleplay-rolls helpers - [`e47ef60`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e47ef60414617826285d8afa7d00877f2f719e72) Merge remote-tracking branch 'origin/staging' into chore/7573-roleplay-roll-helpers ### 📊 Changes **4 files changed** (+313 additions, -95 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/generate.routes.ts` (+16 -38) 📝 `packages/server/src/routes/generate/tool-rounds.ts` (+25 -56) 📝 `packages/server/src/services/generation/roleplay-rolls.ts` (+136 -1) ➕ `scripts/regressions/roleplay-roll-helpers.regression.ts` (+136 -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 Part of #7573 (sixth slice). Stacked on #7676: merge it first; GitHub retargets this PR to `staging` when its base branch is deleted. ## Why this change The roleplay roll handling was spread over the route and the tool-call loop: when rolls are on, how the roll tool gets the participant list, how a `[roll: …]` written as text becomes a roll tool call, what the roll activity entry holds, the text the model gets after a roll, and how a roll in the last round is cut. These rules were inline code between stream and message handling. As pure helpers next to `prepareRoleplayRoll`, each rule has a direct test, and the loop reads as a sequence of named steps. No behaviour change. ## What changed - `packages/server/src/services/generation/roleplay-rolls.ts` gets six pure helpers: `isRoleplayRollEnabled`, `withRoleplayRollSchema`, `textualRollToolCall`, `rollActivityFromToolResult`, `rollResultFollowUp` and `cutPendingRoll`. - `generate.routes.ts` and `generate/tool-rounds.ts` call them. The stream abort on a roll request, the SSE events, the message shapes (a textual roll has no `tool_calls` and its result goes back as a user message) and their order stay in the loop. - New `scripts/regressions/roleplay-roll-helpers.regression.ts`: the enable conditions (game mode, impersonate, narrator-only audience, the tool fallback), the schema (enum, `attribute`, `required`, other tools untouched, no mutation of shared tool definitions), the textual roll (cuts, call arguments, no id drawn without a roll), the activity entry, the follow-up text on the last round only, and the pending-roll cut (including a cut to an empty string). ## 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` Agent-run results (not a substitute for the boxes above): - `pnpm check`: passed. - Regressions: a sweep of 109 passed, run one at a time: the new one, every regression that reads `generate.routes.ts` or `tool-rounds.ts`, and every one that covers rolls. No source pin needed a change. - Local CodeRabbit: 0 findings. A separate review compared each helper with the old expressions and found no change. ### Manual verification notes - Manually verify a roleplay chat with Rolls on: a `[roll: …]` stops the stream, the roll card shows, and the reply continues with the result. - Manually verify a group roleplay: the roll tool offers the participants' names. - Manually verify that a roll the model asks for in the last tool round is cut and the roll-limit notice shows. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) 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) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Roleplay** * Dice rolls are now handled in eligible roleplay chats, including roll requests written in conversation text. * Roll results are added to the conversation, with a notice when no further rolls are available in the final round. <!-- 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:08:23 +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#7875
No description provided.