[PR #6639] [MERGED] fix: apply User Input regex to other Roleplay group characters #7264

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

📋 Pull Request Information

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

Base: staging ← Head: codex/group-user-input-regex


📝 Commits (4)

  • a01e933 docs: track Individual group regex fix (#6637)
  • 8cb251c fix: apply group prompt regexes from the responding character perspective
  • 432b110 fix: preserve regex anchors and inactive character regeneration
  • 872ee9a fix: preserve attachments and scope the regex fix to Roleplay

📊 Changes

9 files changed (+481 additions, -37 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/extending/regex-scripts.md (+2 -0)
📝 packages/server/src/routes/generate.routes.ts (+55 -19)
📝 packages/server/src/routes/generate/dry-run-route.ts (+50 -7)
📝 packages/server/src/routes/generate/generate-route-utils.ts (+7 -1)
📝 packages/server/src/services/generation/prompt-message-scope.ts (+19 -8)
📝 packages/server/src/services/generation/runtime-agent-sections.ts (+4 -2)
➕ scripts/regressions/group-prompt-regex.regression.ts (+319 -0)
📝 scripts/regressions/prompt.regression.ts (+23 -0)

📄 Description

Linked issue

Closes #6637

Why this change

In a Roleplay chat using Individual group mode, Pantalone's replies become User Input for Maukie. Prompt regexes were applied before that role change when a character was explicitly selected, so a User Input thought-hiding script could leave Pantalone's thoughts visible. Rewriting shared history early also carried one responder's filtering into later responders.

What changed

  • Defer Roleplay Individual group prompt regexes until history is scoped to its recipient, including replies added in the same turn. Apply global and character-scoped scripts together once, in their existing order.
  • Reuse the group history scoping helper in generation and Peek Prompt. Apply regexes before restoring history wrappers and optional speaker prefixes, so anchors and history depth remain meaningful.
  • Preserve narrator exclusions, preset restrictions, saved messages, and the existing merged/single-character/impersonation paths. Regenerating an inactive character still runs regexes, and removing all text preserves image/file payloads. Conversation keeps its existing history-formatting flow.
  • Add an isolated regression using the real generation and dry-run routes with a local fixture provider; clarify the regex guide and changelog.

Validation

Automated proof completed for 872ee9ae4:

  • pnpm check passed (existing unrelated GameNarration hook-dependency warning; no errors).

  • pnpm regression:prompt passed.

  • node scripts/run-regressions.mjs --filter group-prompt-regex passed. Before the fix, it failed because Maukie's request contained Pantalone's thoughts.

  • Group mention routing and Roleplay whisper generation regressions passed.

  • The new proof checks explicit recipients, sequential replies, narrator handoffs/exclusions, global and character-scoped scripts, AI Output placement, preset/display exclusions, depth zero, anchored patterns, one application per rule, saved-text preservation, preset-less preview, merged groups, impersonation and single-character controls. Added coverage for optional speaker prefixes, inactive-character regeneration and attachment-only history after regex removal.

  • Local CodeRabbit reviews completed. Fixed the valid speaker-prefix, inactive-recipient, attachment and fixture-order findings; the latest local rerun returned no findings. An additional focused review of the final wrapper-cleanup guard hit the CLI quota; that guard is covered by the passing attachment regression and remains subject to the final GitHub review. Hosted CI/review is in progress.

  • Rejected the suggestion to disable deferral in Manual mode: no selected character intentionally means no provider call (verified with a temporary route proof), while applying regexes early for an explicit manual recipient reproduces #6637. The retained regression covers explicit Manual replies and a handoff to an excluded narrator.

  • 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 the original Hide thoughts regex in an Individual group with Pantalone, Maukie and an excluded narrator; inspect each character's Peek Prompt and generated request. The automated fixture uses asterisk-delimited thoughts; the reporter's private chat and exact saved regex were not inspected. No interactive browser verification was performed. Local container validation is limited by roughly 2 GiB free disk space; hosted container checks are running.

Prompt claim boundary

The change selects regex placement and recipient scope for live history. It does not reconstruct older generated summaries or change display-side regex behavior. No storage format or provider protocol changes are included.

Docs and release impact

Updated the English regex guide and CHANGELOG. Translation follow-up: #6640. No version bump.

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

UI evidence (if applicable)

No UI changes.

Summary by CodeRabbit

  • Bug Fixes
    • In Individual group chats, User Input prompt regexes apply to other characters’ messages, while each responding character’s replies follow AI Output rules. Character-specific exclusions remain in effect.
    • Regex placement follows the character receiving the prompt, including earlier replies in the same group turn.
  • Documentation
    • Clarified prompt regex placement in Individual group chats and noted that Only Prompt mode keeps saved chat text intact.

🔄 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/6639 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/24/2026 **Status:** ✅ Merged **Merged:** 9/24/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `codex/group-user-input-regex` --- ### 📝 Commits (4) - [`a01e933`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a01e933667f2d8a46121a154fcd279e952148f7d) docs: track Individual group regex fix (#6637) - [`8cb251c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8cb251c67ab5f0f103c28ee5a7389ab4fb4dfe8b) fix: apply group prompt regexes from the responding character perspective - [`432b110`](https://github.com/Pasta-Devs/Marinara-Engine/commit/432b110bc2b324f03015633cebed0df4281be588) fix: preserve regex anchors and inactive character regeneration - [`872ee9a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/872ee9ae4767bd22b916ed6ce746df66354eb30d) fix: preserve attachments and scope the regex fix to Roleplay ### 📊 Changes **9 files changed** (+481 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/extending/regex-scripts.md` (+2 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+55 -19) 📝 `packages/server/src/routes/generate/dry-run-route.ts` (+50 -7) 📝 `packages/server/src/routes/generate/generate-route-utils.ts` (+7 -1) 📝 `packages/server/src/services/generation/prompt-message-scope.ts` (+19 -8) 📝 `packages/server/src/services/generation/runtime-agent-sections.ts` (+4 -2) ➕ `scripts/regressions/group-prompt-regex.regression.ts` (+319 -0) 📝 `scripts/regressions/prompt.regression.ts` (+23 -0) </details> ### 📄 Description ## Linked issue Closes #6637 ## Why this change In a Roleplay chat using Individual group mode, Pantalone's replies become User Input for Maukie. Prompt regexes were applied before that role change when a character was explicitly selected, so a User Input thought-hiding script could leave Pantalone's thoughts visible. Rewriting shared history early also carried one responder's filtering into later responders. ## What changed - Defer Roleplay Individual group prompt regexes until history is scoped to its recipient, including replies added in the same turn. Apply global and character-scoped scripts together once, in their existing order. - Reuse the group history scoping helper in generation and Peek Prompt. Apply regexes before restoring history wrappers and optional speaker prefixes, so anchors and history depth remain meaningful. - Preserve narrator exclusions, preset restrictions, saved messages, and the existing merged/single-character/impersonation paths. Regenerating an inactive character still runs regexes, and removing all text preserves image/file payloads. Conversation keeps its existing history-formatting flow. - Add an isolated regression using the real generation and dry-run routes with a local fixture provider; clarify the regex guide and changelog. ## Validation Automated proof completed for `872ee9ae4`: - `pnpm check` passed (existing unrelated GameNarration hook-dependency warning; no errors). - `pnpm regression:prompt` passed. - `node scripts/run-regressions.mjs --filter group-prompt-regex` passed. Before the fix, it failed because Maukie's request contained Pantalone's thoughts. - Group mention routing and Roleplay whisper generation regressions passed. - The new proof checks explicit recipients, sequential replies, narrator handoffs/exclusions, global and character-scoped scripts, AI Output placement, preset/display exclusions, depth zero, anchored patterns, one application per rule, saved-text preservation, preset-less preview, merged groups, impersonation and single-character controls. Added coverage for optional speaker prefixes, inactive-character regeneration and attachment-only history after regex removal. - Local CodeRabbit reviews completed. Fixed the valid speaker-prefix, inactive-recipient, attachment and fixture-order findings; the latest local rerun returned no findings. An additional focused review of the final wrapper-cleanup guard hit the CLI quota; that guard is covered by the passing attachment regression and remains subject to the final GitHub review. Hosted CI/review is in progress. - Rejected the suggestion to disable deferral in Manual mode: no selected character intentionally means no provider call (verified with a temporary route proof), while applying regexes early for an explicit manual recipient reproduces #6637. The retained regression covers explicit Manual replies and a handoff to an excluded narrator. - [ ] `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 the original Hide thoughts regex in an Individual group with Pantalone, Maukie and an excluded narrator; inspect each character's Peek Prompt and generated request. The automated fixture uses asterisk-delimited thoughts; the reporter's private chat and exact saved regex were not inspected. No interactive browser verification was performed. Local container validation is limited by roughly 2 GiB free disk space; hosted container checks are running. ### Prompt claim boundary The change selects regex placement and recipient scope for live history. It does not reconstruct older generated summaries or change display-side regex behavior. No storage format or provider protocol changes are included. ## Docs and release impact Updated the English regex guide and CHANGELOG. Translation follow-up: #6640. No version bump. - [ ] 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 - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) No UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * In Individual group chats, User Input prompt regexes apply to other characters’ messages, while each responding character’s replies follow AI Output rules. Character-specific exclusions remain in effect. * Regex placement follows the character receiving the prompt, including earlier replies in the same group turn. * **Documentation** * Clarified prompt regex placement in Individual group chats and noted that Only Prompt mode keeps saved chat text intact. <!-- 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:18: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#7264
No description provided.