[PR #6980] [MERGED] fix(chat): make a group reply go to the character being replied to #7416

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6980
Author: @SpicyMarinara
Created: 10/2/2026
Status: ✅ Merged
Merged: 10/2/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/reply-target-responds-first


📝 Commits (3)

  • 1399fc7 fix(chat): make a group reply go to the character being replied to
  • 231245d fix(chat): find the replied-to message in the whole chat
  • b0790bc test(chat): cover a reply in a Conversation merged group

📊 Changes

3 files changed (+89 additions, -4 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 packages/server/src/routes/generate.routes.ts (+14 -2)
📝 scripts/regressions/smart-group-decision.regression.ts (+73 -2)

📄 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 #6978

Why this change

In a group chat, using Reply on a character's message almost always got an answer from a different character. The reply is stored on the user message (extra.replyTo) and quoted into the responder's prompt, but choosing who speaks next never looked at it:

  • getExplicitlyMentionedCharacterIds() only counts @Name mentions and mentionedCharacterNames.
  • The transcript that the Decision model and the chat-model selector read (conversationPromptHistoryContent) leaves the quote out, so neither can tell a reply happened.
  • All three smart-order paths steer away from the last speaker: the Decision model drops them whenever anyone else qualifies (smart-group-decision.ts), the selector prompt says "Avoid making the same character speak twice in a row", and the fallback picks the first character who is not the last speaker. You usually reply to the message a character just sent, so the character being replied to is exactly the one all three avoid.

What changed

  • generate.routes.ts: for the user's turn, getExplicitlyMentionedCharacterIds() now counts the author of the quoted message as addressed, like an @mention. That covers every path that already honours mentions: smart order (it answers without a Decision or selector call), explicit directives, and Conversation merged groups. A reply to the user's own message addresses no one. The quoted message is looked up in the whole chat (allChatMessages), so a reply to a message hidden from the AI or past the context message limit still finds its author; there is no name matching. Mentions found in a character's reply (the assistant-text path) are unchanged.
  • scripts/regressions/smart-group-decision.regression.ts: real generate runs. Bram has just spoken and the Decision model favours Cole, yet replying to Bram's message makes Bram answer with no Decision or selector call. A reply to the user's own message still goes through smart order. A reply to an older Aya message past a contextMessageLimit of 2 makes Aya answer. Without the fix the first case fails (Cole answers); with a loaded-history-only lookup the last one fails (Cole instead of Aya).
  • CHANGELOG.md entry.

Unavailable characters are still skipped, exactly as for an @mention.

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

Run by the agent:

  • pnpm check passes.
  • node ./scripts/run-regressions.mjs --filter scripts/regressions/smart-group-decision.regression.ts passes. With the new line removed it fails with actual: ['Cole'], expected: ['Bram'], and with the lookup limited to the loaded history it fails with actual: ['Cole'], expected: ['Aya'].
  • Local CodeRabbit: 0 findings. GitHub CodeRabbit's one finding (resolve the quoted message from the whole chat) is fixed in 231245d33.

Still to verify by hand:

  • In a Conversation group chat with smart response order, let character A speak, then use Reply on A's message: A should answer.
  • Reply to an older message from a different character B: B should answer.
  • Reply to one of your own messages: the usual smart order should pick who answers.
  • Reply to a character who can't respond right now in Conversation mode: it should behave like an @mention of that character does today.

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 updated; no user docs describe how responders are chosen for replies.

Summary by CodeRabbit

  • New Features
    • In group chats, replying to a character’s message selects that character to speak next, even when the message is outside the loaded chat context or belongs to a merged conversation.
    • Replies to your own messages continue to use the usual speaker-selection process.
  • Bug Fixes
    • Fixed group chats overlooking replies when deciding who should speak next.

🔄 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/6980 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/2/2026 **Status:** ✅ Merged **Merged:** 10/2/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/reply-target-responds-first` --- ### 📝 Commits (3) - [`1399fc7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1399fc77c503b5bf49c43a6bc4ce91e28cabe168) fix(chat): make a group reply go to the character being replied to - [`231245d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/231245d33ece61223dd4a07aae1a0567936dd85b) fix(chat): find the replied-to message in the whole chat - [`b0790bc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b0790bc65b495cc0b4aab4f88b3c6cef1dce88c0) test(chat): cover a reply in a Conversation merged group ### 📊 Changes **3 files changed** (+89 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+14 -2) 📝 `scripts/regressions/smart-group-decision.regression.ts` (+73 -2) </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 Closes #6978 ## Why this change In a group chat, using **Reply** on a character's message almost always got an answer from a different character. The reply is stored on the user message (`extra.replyTo`) and quoted into the responder's prompt, but choosing who speaks next never looked at it: - `getExplicitlyMentionedCharacterIds()` only counts `@Name` mentions and `mentionedCharacterNames`. - The transcript that the Decision model and the chat-model selector read (`conversationPromptHistoryContent`) leaves the quote out, so neither can tell a reply happened. - All three smart-order paths steer away from the last speaker: the Decision model drops them whenever anyone else qualifies (`smart-group-decision.ts`), the selector prompt says "Avoid making the same character speak twice in a row", and the fallback picks the first character who is not the last speaker. You usually reply to the message a character just sent, so the character being replied to is exactly the one all three avoid. ## What changed - `generate.routes.ts`: for the user's turn, `getExplicitlyMentionedCharacterIds()` now counts the author of the quoted message as addressed, like an `@mention`. That covers every path that already honours mentions: smart order (it answers without a Decision or selector call), explicit directives, and Conversation merged groups. A reply to the user's own message addresses no one. The quoted message is looked up in the whole chat (`allChatMessages`), so a reply to a message hidden from the AI or past the context message limit still finds its author; there is no name matching. Mentions found in a character's reply (the assistant-text path) are unchanged. - `scripts/regressions/smart-group-decision.regression.ts`: real generate runs. Bram has just spoken and the Decision model favours Cole, yet replying to Bram's message makes Bram answer with no Decision or selector call. A reply to the user's own message still goes through smart order. A reply to an older Aya message past a `contextMessageLimit` of 2 makes Aya answer. Without the fix the first case fails (Cole answers); with a loaded-history-only lookup the last one fails (Cole instead of Aya). - `CHANGELOG.md` entry. Unavailable characters are still skipped, exactly as for an `@mention`. ## 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 Run by the agent: - `pnpm check` passes. - `node ./scripts/run-regressions.mjs --filter scripts/regressions/smart-group-decision.regression.ts` passes. With the new line removed it fails with `actual: ['Cole'], expected: ['Bram']`, and with the lookup limited to the loaded history it fails with `actual: ['Cole'], expected: ['Aya']`. - Local CodeRabbit: 0 findings. GitHub CodeRabbit's one finding (resolve the quoted message from the whole chat) is fixed in 231245d33. Still to verify by hand: - In a Conversation group chat with smart response order, let character A speak, then use **Reply** on A's message: A should answer. - Reply to an older message from a different character B: B should answer. - Reply to one of your own messages: the usual smart order should pick who answers. - Reply to a character who can't respond right now in Conversation mode: it should behave like an `@mention` of that character does today. ## 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 updated; no user docs describe how responders are chosen for replies. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * In group chats, replying to a character’s message selects that character to speak next, even when the message is outside the loaded chat context or belongs to a merged conversation. * Replies to your own messages continue to use the usual speaker-selection process. * **Bug Fixes** * Fixed group chats overlooking replies when deciding who should speak next. <!-- 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:19:34 +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#7416
No description provided.