[PR #760] [MERGED] Fix hidden message regeneration crash #4764

Closed
opened 2026-10-22 04:10:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/760
Author: @cha1latte
Created: 5/12/2026
Status: ✅ Merged
Merged: 5/12/2026
Merged by: @cha1latte

Base: main ← Head: fix/issue-744-hidden-regen-crash


📝 Commits (1)

  • 4370714 Fix hidden message regeneration crash

📊 Changes

2 files changed (+168 additions, -6 deletions)

View changed files

📝 packages/server/src/routes/generate.routes.ts (+13 -6)
➕ packages/server/test/generate-hidden-regenerate.test.ts (+155 -0)

📄 Description

Linked issue

Closes #744

Why this change

  • Regenerating a roleplay assistant message that was hidden from AI could treat the target as missing after SSE had already started, which could surface Fastify's Reply was already sent failure and crash the server.

What changed

  • Look up regenerate targets from the scoped transcript before hidden-from-AI filtering, while still removing hidden messages from the model-visible context.
  • Send late regenerate validation failures as SSE error events instead of normal Fastify replies after the stream has started.
  • Added a server regression test covering a hidden regenerate target with several recent hidden messages.

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

  • Codex proof: scratch route repro failed before the fix because hidden regenerate targets were treated as missing, then passed after the fix without Regenerated message not found or Reply was already sent.
  • Codex proof: pnpm --dir packages/server exec tsx --import ./test/setup-env.ts --test C:/tmp/Marinara-Engine-issue-744/scratch/issue-744-hidden-regen-repro.ts passed.
  • Codex proof: pnpm --dir packages/server exec tsx --import ./test/setup-env.ts --test test/generate-hidden-regenerate.test.ts passed.
  • Codex proof: pnpm --filter @marinara-engine/server test passed 291 tests.
  • Codex proof: pnpm check passed.
  • Codex proof after fast-forwarding to current upstream/main: focused scratch repro and permanent regression test both still passed.
  • No human-only verification blocker identified for the core server-crash claim.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

No docs or release metadata changes are needed for this narrow server bug fix.

UI evidence (if applicable)

N/A - backend/server crash fix. The repro is covered by the server route harness and regression test above.

Summary by CodeRabbit

  • Bug Fixes
    • Improved message regeneration to correctly locate target messages in conversation context
    • Enhanced error handling during failed regeneration attempts to provide reliable streaming responses instead of HTTP errors

Review Change Stack


🔄 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/760 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/12/2026 **Status:** ✅ Merged **Merged:** 5/12/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `main` ← **Head:** `fix/issue-744-hidden-regen-crash` --- ### 📝 Commits (1) - [`4370714`](https://github.com/Pasta-Devs/Marinara-Engine/commit/43707146a181836af77125fcf4bbce9ccce4a7a0) Fix hidden message regeneration crash ### 📊 Changes **2 files changed** (+168 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/generate.routes.ts` (+13 -6) ➕ `packages/server/test/generate-hidden-regenerate.test.ts` (+155 -0) </details> ### 📄 Description ## Linked issue <!-- Every PR should reference a feature request or issue report. If there isn't one yet, open one first to gather opinions: --> <!-- https://github.com/Pasta-Devs/Marinara-Engine/issues/new/choose --> Closes #744 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - Regenerating a roleplay assistant message that was hidden from AI could treat the target as missing after SSE had already started, which could surface Fastify's `Reply was already sent` failure and crash the server. ## What changed <!-- List the key changes in this PR --> - Look up regenerate targets from the scoped transcript before hidden-from-AI filtering, while still removing hidden messages from the model-visible context. - Send late regenerate validation failures as SSE error events instead of normal Fastify replies after the stream has started. - Added a server regression test covering a hidden regenerate target with several recent hidden messages. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [ ] `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 <!-- Describe exactly what you tested in a real browser/app, step by step. --> <!-- ⚠️ If an AI agent filled out or ticked these boxes for you, treat them --> <!-- as a TO-DO LIST, not as proof the work is done. Verify each item yourself --> <!-- before submitting. If you haven't verified it, untick the box. --> - Codex proof: scratch route repro failed before the fix because hidden regenerate targets were treated as missing, then passed after the fix without `Regenerated message not found` or `Reply was already sent`. - Codex proof: `pnpm --dir packages/server exec tsx --import ./test/setup-env.ts --test C:/tmp/Marinara-Engine-issue-744/scratch/issue-744-hidden-regen-repro.ts` passed. - Codex proof: `pnpm --dir packages/server exec tsx --import ./test/setup-env.ts --test test/generate-hidden-regenerate.test.ts` passed. - Codex proof: `pnpm --filter @marinara-engine/server test` passed 291 tests. - Codex proof: `pnpm check` passed. - Codex proof after fast-forwarding to current `upstream/main`: focused scratch repro and permanent regression test both still passed. - No human-only verification blocker identified for the core server-crash claim. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) No docs or release metadata changes are needed for this narrow server bug fix. ## UI evidence (if applicable) N/A - backend/server crash fix. The repro is covered by the server route harness and regression test above. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved message regeneration to correctly locate target messages in conversation context * Enhanced error handling during failed regeneration attempts to provide reliable streaming responses instead of HTTP errors [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/760) <!-- 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-22 04:10:27 +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#4764
No description provided.