[PR #8687] [MERGED] fix(chat): impersonated turns keep their reasoning and regenerate in Individual groups #8749

Closed
opened 2026-11-07 17:39:25 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: staging ← Head: fix/impersonation-reasoning-regen-8682


📝 Commits (1)

  • a13fa31 fix(chat): impersonated turns keep their reasoning and regenerate in Individual groups (#8682)

📊 Changes

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

View changed files

➕ e2e/impersonation-reasoning.e2e.ts (+106 -0)
📝 packages/client/src/components/chat/ChatMessage.tsx (+3 -2)
📝 packages/server/src/routes/generate.routes.ts (+4 -1)
➕ scripts/regressions/impersonation-group-regeneration.regression.ts (+195 -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 #8682

Why this change

A user who relies on guided impersonation in roleplay reported two recurring problems:

  • The reasoning disappears. While an impersonated turn streams, its reasoning shows. Once it's saved, it can't be opened at all. The server does save it, as extra.thinking on the persona's message. But ChatMessage.tsx showed reasoning only on non-user rows: both the inline disclosure and the "View model thoughts" button were gated on !isUser.
  • Regenerating fails in group chats. Regenerating an impersonated message in a group chat fails with "Regenerated message is missing character". In an Individual-mode group, every regeneration took the character-swipe branch, which needs a characterId. A persona's message has none, so the request ended with that error. Single-character and Merged chats never took that branch.

What changed

  • packages/client/src/components/chat/ChatMessage.tsx: a user message with saved reasoning shows it the way a reply does:
    • by default, the "View model thoughts" button;
    • with Show Thinking In Messages on, the collapsed inline disclosure, which respects Don't Collapse Thinking.
    • A typed message has no saved reasoning, so it shows nothing new. A typed message the model rewrote through Regenerate shows that rewrite's reasoning.
  • packages/server/src/routes/generate.routes.ts: in an Individual group, only a character's message now regenerates as that character. Every persona message takes the path single-character and Merged chats already use:
    • a message with its stored impersonation replay re-impersonates with the original direction;
    • one without a replay gets the normal user rewrite. That covers a typed message, an impersonation saved before replays existed, and a copy in a branched chat (branching drops generationReplay).
    • Regenerating a character's reply is unchanged.
  • Proofs:
    • scripts/regressions/impersonation-group-regeneration.regression.ts covers single-character, Merged and Individual chats.
    • e2e/impersonation-reasoning.e2e.ts covers the reasoning button and the inline disclosure after an impersonation.

No strings, docs, CHANGELOG or version files changed.

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

What the agent ran locally:

  • node ./scripts/pnpm-runner.mjs check: exit 0. It covers localization, format, lint, the e2e and token-estimation types, and the build.
  • Server regression (node ./scripts/run-regressions.mjs --filter impersonation-group-regeneration). Before the fix, only the Individual group fails, with the reported error. With only an !input.impersonate condition, the persona-rewrite steps (typed message, replay removed) still fail. It passes with this change. It checks that:
    • each regeneration saves a new swipe on the same persona message, with its own reasoning;
    • no character instruction is sent;
    • no message is added.
  • e2e (e2e/impersonation-reasoning.e2e.ts): it fails on desktop-chromium and mobile-chromium before the client change and passes after it. mobile-webkit was run only with the fix.
  • Independent reviews: two review agents checked the change against the code. One drove the real /api/generate path through a streaming stub in an Individual group, on desktop and phone, in light and dark, with Show Thinking off and on. Their one finding, branched chats and typed messages, is fixed here.
  • Related regressions: gemini-user-regeneration, roleplay-regeneration-context, generation-replay-copy, group-mention-routing, expression-group-generation, generate-save-generated-reply and others all pass.

For a human to verify:

  • With a reasoning model in a Roleplay chat, run guided impersonation. Manually verify that after the stream ends, the persona's message still has the brain "View model thoughts" button (on hover on desktop, on tap on a phone), and that it opens the reasoning.
  • Turn on Settings → Appearance → Roleplay → Show Thinking In Messages. Manually verify the impersonated message shows the "Thought for N seconds" disclosure collapsed, and with Don't Collapse Thinking on it stays open.
  • In an Individual-mode group Roleplay chat, regenerate an impersonated message. Manually verify a new swipe appears on that same persona message, steered by the original direction, with no "Regenerated message is missing character" error.
  • In the same group, manually verify that regenerating a typed message rewrites it, and that regenerating a character's reply still makes a new swipe for that character.
  • Branch that group chat and regenerate the copied impersonated message. Manually verify it rewrites with no error.

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)

The e2e proof checks that the "View model thoughts" button and the inline disclosure appear on the persona's message after an impersonation. No screenshots 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/8687 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/impersonation-reasoning-regen-8682` --- ### 📝 Commits (1) - [`a13fa31`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a13fa31fc4ddff6cf5daa0041606a0baba8fd42b) fix(chat): impersonated turns keep their reasoning and regenerate in Individual groups (#8682) ### 📊 Changes **4 files changed** (+308 additions, -3 deletions) <details> <summary>View changed files</summary> ➕ `e2e/impersonation-reasoning.e2e.ts` (+106 -0) 📝 `packages/client/src/components/chat/ChatMessage.tsx` (+3 -2) 📝 `packages/server/src/routes/generate.routes.ts` (+4 -1) ➕ `scripts/regressions/impersonation-group-regeneration.regression.ts` (+195 -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 #8682 ## Why this change A user who relies on guided impersonation in roleplay reported two recurring problems: - **The reasoning disappears.** While an impersonated turn streams, its reasoning shows. Once it's saved, it can't be opened at all. The server does save it, as `extra.thinking` on the persona's message. But `ChatMessage.tsx` showed reasoning only on non-user rows: both the inline disclosure and the "View model thoughts" button were gated on `!isUser`. - **Regenerating fails in group chats.** Regenerating an impersonated message in a group chat fails with "Regenerated message is missing character". In an Individual-mode group, every regeneration took the character-swipe branch, which needs a `characterId`. A persona's message has none, so the request ended with that error. Single-character and Merged chats never took that branch. ## What changed - **`packages/client/src/components/chat/ChatMessage.tsx`:** a user message with saved reasoning shows it the way a reply does: - by default, the "View model thoughts" button; - with **Show Thinking In Messages** on, the collapsed inline disclosure, which respects **Don't Collapse Thinking**. - A typed message has no saved reasoning, so it shows nothing new. A typed message the model rewrote through Regenerate shows that rewrite's reasoning. - **`packages/server/src/routes/generate.routes.ts`:** in an Individual group, only a character's message now regenerates as that character. Every persona message takes the path single-character and Merged chats already use: - a message with its stored impersonation replay re-impersonates with the original direction; - one without a replay gets the normal user rewrite. That covers a typed message, an impersonation saved before replays existed, and a copy in a branched chat (branching drops `generationReplay`). - Regenerating a character's reply is unchanged. - **Proofs:** - `scripts/regressions/impersonation-group-regeneration.regression.ts` covers single-character, Merged and Individual chats. - `e2e/impersonation-reasoning.e2e.ts` covers the reasoning button and the inline disclosure after an impersonation. No strings, docs, CHANGELOG or version files changed. ## 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 What the agent ran locally: - **`node ./scripts/pnpm-runner.mjs check`:** exit 0. It covers localization, format, lint, the e2e and token-estimation types, and the build. - **Server regression** (`node ./scripts/run-regressions.mjs --filter impersonation-group-regeneration`). Before the fix, only the Individual group fails, with the reported error. With only an `!input.impersonate` condition, the persona-rewrite steps (typed message, replay removed) still fail. It passes with this change. It checks that: - each regeneration saves a new swipe on the same persona message, with its own reasoning; - no character instruction is sent; - no message is added. - **e2e** (`e2e/impersonation-reasoning.e2e.ts`): it fails on desktop-chromium and mobile-chromium before the client change and passes after it. mobile-webkit was run only with the fix. - **Independent reviews:** two review agents checked the change against the code. One drove the real `/api/generate` path through a streaming stub in an Individual group, on desktop and phone, in light and dark, with Show Thinking off and on. Their one finding, branched chats and typed messages, is fixed here. - **Related regressions:** gemini-user-regeneration, roleplay-regeneration-context, generation-replay-copy, group-mention-routing, expression-group-generation, generate-save-generated-reply and others all pass. For a human to verify: - With a reasoning model in a Roleplay chat, run guided impersonation. Manually verify that after the stream ends, the persona's message still has the brain "View model thoughts" button (on hover on desktop, on tap on a phone), and that it opens the reasoning. - Turn on Settings → Appearance → Roleplay → **Show Thinking In Messages**. Manually verify the impersonated message shows the "Thought for N seconds" disclosure collapsed, and with **Don't Collapse Thinking** on it stays open. - In an Individual-mode group Roleplay chat, regenerate an impersonated message. Manually verify a new swipe appears on that same persona message, steered by the original direction, with no "Regenerated message is missing character" error. - In the same group, manually verify that regenerating a typed message rewrites it, and that regenerating a character's reply still makes a new swipe for that character. - Branch that group chat and regenerate the copied impersonated message. Manually verify it rewrites with no error. ## 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) The e2e proof checks that the "View model thoughts" button and the inline disclosure appear on the persona's message after an impersonation. No screenshots 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 17:39:25 +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#8749
No description provided.