[PR #8462] [MERGED] feat(roleplay): automate active characters in Merged Roleplay groups #8617

Closed
opened 2026-11-07 16:46:01 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8462
Author: @ylli-selmani
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @ylli-selmani

Base: staging ← Head: feat/auto-active-characters


📝 Commits (10+)

  • 605bb86 feat(roleplay): add the rules for automated active characters
  • a6a1ad4 feat(roleplay): keep Merged Roleplay cast in sync with the scene
  • fe83092 feat(roleplay): add the Automate active characters control
  • ea9a0e3 fix(roleplay): address the local review of automated active characters
  • 3f9a3f2 fix(roleplay): put the pin left of the eye toggle
  • 44315a3 fix(roleplay): address Dottore's review of automated active characters
  • fff9385 fix(roleplay): keep the pin on every row while automation runs
  • 5c1a20a fix(roleplay): keep the cast when the tracker names no attached character
  • de937d0 fix(roleplay): find tracked characters by name and alias, not id alone
  • 1929833 refactor(roleplay): read cast ids with the tracker's own parser

📊 Changes

8 files changed (+945 additions, -1 deletions)

View changed files

📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+111 -1)
📝 packages/client/src/localization/locales/en.json (+12 -0)
📝 packages/server/src/routes/generate.routes.ts (+99 -0)
➕ packages/server/src/services/generation/scene-presence-decision.ts (+176 -0)
➕ packages/server/src/services/generation/scene-presence.service.ts (+109 -0)
📝 packages/shared/src/types/chat-preset.ts (+2 -0)
📝 packages/shared/src/types/chat.ts (+6 -0)
➕ scripts/regressions/scene-presence-decision.regression.ts (+430 -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

Closes #8461

Why this change

  • In a Merged (Narrator) Roleplay group chat, every active character card is in the narrator's context on every turn, and nothing triggers cards in or out the way lorebook entries are. With a large cast you either pay for every card on every reply or flip the eye toggles by hand as characters enter and leave. Individual mode avoids that but splits the reply per character.
  • This adds Automate active characters to the Group Chat box under Merged (Narrator), Roleplay only. It has three settings: Off, Decision model, or Character Tracker. The Decision model works like Smart response order but asks "is this character in the scene?" before each reply. Character Tracker reads the tracker's present characters from the last reply, so it updates one turn late.

What changed

  • Rules (605bb8632): adds the autoActiveCharacters and autoActiveCharacterPins chat metadata, plus pure rules in scene-presence-decision.ts. Pinned characters keep their state and the Commands narrator stays active. If there's no answer, nothing changed, or the choice would leave nobody active, the chat is left as it is. The setting travels with settings profiles; the pins are the chat's own state.
  • Server (a6a1ad4fa, ea9a0e338, 5c1a20add, de937d035): before a Merged Roleplay reply, Decision mode asks the Decision model one presence question per character, like Smart response order. Tracker mode reads the Character Tracker's last present list, matching each entry to a card by its id, a cast id's card, its name, or the card's name aliases (the tracker model writes the ids and often makes one up for a card that walks in while inactive). A list that names no attached card is treated as no data, and Decision mode falls back to that list when the model can't answer or defers. The result goes to inactiveCharacterIds with a live metadata_patch. Both modes run before generation, so swipes and regenerates see the right scene. A chat with a custom "Choose active chat characters" agent skips this entirely. Continue and impersonate turns are skipped too, and any failure keeps the current list.
  • UI (fe83092a8, ea9a0e338, fff938533): an Off / Decision model / Character Tracker control in the Group Chat box under Merged (Narrator), Roleplay only. It copies the Mode selector's segmented buttons in ChatSettingsDrawer.tsx. The hint below it says what's missing: a Decision model, the Character Tracker, or a tracker that only runs manually. While automation is on, every row has a pin left of the eye: muted like the closed eye, the accent colour once pinned. Clicking it pins the character's current state, on or off, and a hand eye-toggle pins too. Turning automation off clears every pin.

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

Manual verification notes

  • Regression: node scripts/run-regressions.mjs --filter scene-presence-decision
  • node scripts/run-regressions.mjs --filter character-activity-agent and --filter chat-profile-followers still pass.
  • The regression drives the real generate route with a fake System One server. It covers Decision mode setting the cast, a pin surviving, the tracker fallback when the decision fails (with the card listed under a made-up id and its alias), the narrator naming in the transcript, and no decision call when the setting is off or the chat is in Individual mode.
  • Phone size on a dev build: the control and its "no Decision model" hint show in Group Chat, and every row shows the pin, grey when unpinned and the accent colour when pinned, including an active pinned character.
  • Not yet tried: a live turn against a real Decision model.

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)

UI evidence (if applicable)

Phone-size screenshot of the character list with a pinned character: to be attached.

🤖 Generated with Claude Code


🔄 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/8462 **Author:** [@ylli-selmani](https://github.com/ylli-selmani) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ylli-selmani](https://github.com/ylli-selmani) **Base:** `staging` ← **Head:** `feat/auto-active-characters` --- ### 📝 Commits (10+) - [`605bb86`](https://github.com/Pasta-Devs/Marinara-Engine/commit/605bb863270527c3bb74019df48300d861e05a8c) feat(roleplay): add the rules for automated active characters - [`a6a1ad4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a6a1ad4facc79ebca742850d8d51dfd5f6cafdd6) feat(roleplay): keep Merged Roleplay cast in sync with the scene - [`fe83092`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fe83092a8f5bd9541a6dceee778ad84fb6fdc491) feat(roleplay): add the Automate active characters control - [`ea9a0e3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ea9a0e338f16ca99983485d80295552a365c9ae0) fix(roleplay): address the local review of automated active characters - [`3f9a3f2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3f9a3f2713bd8599b738fdc7016ce4d8de8bd13f) fix(roleplay): put the pin left of the eye toggle - [`44315a3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/44315a33488c29b2d6937af09876cb14877e918b) fix(roleplay): address Dottore's review of automated active characters - [`fff9385`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fff93853312cc02c69f1a9630a3f09abc78d2e96) fix(roleplay): keep the pin on every row while automation runs - [`5c1a20a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5c1a20adda89098f868baa7edf4223f5dd662f33) fix(roleplay): keep the cast when the tracker names no attached character - [`de937d0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/de937d0351f03785802568d7e0dbe29b0fd00011) fix(roleplay): find tracked characters by name and alias, not id alone - [`1929833`](https://github.com/Pasta-Devs/Marinara-Engine/commit/19298331e91112d6e9274d1ed68a12f104d3a04b) refactor(roleplay): read cast ids with the tracker's own parser ### 📊 Changes **8 files changed** (+945 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+111 -1) 📝 `packages/client/src/localization/locales/en.json` (+12 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+99 -0) ➕ `packages/server/src/services/generation/scene-presence-decision.ts` (+176 -0) ➕ `packages/server/src/services/generation/scene-presence.service.ts` (+109 -0) 📝 `packages/shared/src/types/chat-preset.ts` (+2 -0) 📝 `packages/shared/src/types/chat.ts` (+6 -0) ➕ `scripts/regressions/scene-presence-decision.regression.ts` (+430 -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`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #8461 ## Why this change - In a Merged (Narrator) Roleplay group chat, every active character card is in the narrator's context on every turn, and nothing triggers cards in or out the way lorebook entries are. With a large cast you either pay for every card on every reply or flip the eye toggles by hand as characters enter and leave. Individual mode avoids that but splits the reply per character. - This adds **Automate active characters** to the Group Chat box under Merged (Narrator), Roleplay only. It has three settings: Off, Decision model, or Character Tracker. The Decision model works like Smart response order but asks "is this character in the scene?" before each reply. Character Tracker reads the tracker's present characters from the last reply, so it updates one turn late. ## What changed - **Rules** (`605bb8632`): adds the `autoActiveCharacters` and `autoActiveCharacterPins` chat metadata, plus pure rules in `scene-presence-decision.ts`. Pinned characters keep their state and the Commands narrator stays active. If there's no answer, nothing changed, or the choice would leave nobody active, the chat is left as it is. The setting travels with settings profiles; the pins are the chat's own state. - **Server** (`a6a1ad4fa`, `ea9a0e338`, `5c1a20add`, `de937d035`): before a Merged Roleplay reply, Decision mode asks the Decision model one presence question per character, like Smart response order. Tracker mode reads the Character Tracker's last present list, matching each entry to a card by its id, a cast id's card, its name, or the card's name aliases (the tracker model writes the ids and often makes one up for a card that walks in while inactive). A list that names no attached card is treated as no data, and Decision mode falls back to that list when the model can't answer or defers. The result goes to `inactiveCharacterIds` with a live `metadata_patch`. Both modes run before generation, so swipes and regenerates see the right scene. A chat with a custom "Choose active chat characters" agent skips this entirely. Continue and impersonate turns are skipped too, and any failure keeps the current list. - **UI** (`fe83092a8`, `ea9a0e338`, `fff938533`): an Off / Decision model / Character Tracker control in the Group Chat box under Merged (Narrator), Roleplay only. It copies the Mode selector's segmented buttons in `ChatSettingsDrawer.tsx`. The hint below it says what's missing: a Decision model, the Character Tracker, or a tracker that only runs manually. While automation is on, every row has a pin left of the eye: muted like the closed eye, the accent colour once pinned. Clicking it pins the character's current state, on or off, and a hand eye-toggle pins too. Turning automation off clears every pin. ## 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` ### Manual verification notes - Regression: `node scripts/run-regressions.mjs --filter scene-presence-decision` - `node scripts/run-regressions.mjs --filter character-activity-agent` and `--filter chat-profile-followers` still pass. - The regression drives the real generate route with a fake System One server. It covers Decision mode setting the cast, a pin surviving, the tracker fallback when the decision fails (with the card listed under a made-up id and its alias), the narrator naming in the transcript, and no decision call when the setting is off or the chat is in Individual mode. - Phone size on a dev build: the control and its "no Decision model" hint show in Group Chat, and every row shows the pin, grey when unpinned and the accent colour when pinned, including an active pinned character. - Not yet tried: a live turn against a real Decision model. ## 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) ## UI evidence (if applicable) Phone-size screenshot of the character list with a pinned character: to be attached. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:46:01 +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#8617
No description provided.