[PR #3920] [MERGED] Prevent duplicate generated posts and replies #6158

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3920
Author: @Xelvanis
Created: 7/21/2026
Status: ✅ Merged
Merged: 7/21/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/prevent-duplicate-posts


📝 Commits (7)

  • 130028c Prevent duplicate generated posts and replies
  • d75ff9e fix: handle duplicate discard edge cases
  • 7870cc6 Merge branch 'staging' into fix/prevent-duplicate-posts
  • e96f31b Merge branch 'staging' into fix/prevent-duplicate-posts
  • 359d43b Address CodeRabbit review feedback
  • c832a96 Merge remote-tracking branch 'origin/staging' into codex/review-3920
  • 31ddd1d Merge remote-tracking branch 'origin/pr-3920-live' into codex/review-3920

📊 Changes

12 files changed (+356 additions, -52 deletions)

View changed files

📝 packages/client/src/hooks/use-background-autonomous.ts (+3 -1)
📝 packages/client/src/hooks/use-generate.ts (+142 -44)
📝 packages/server/src/routes/generate.routes.ts (+48 -0)
📝 packages/server/src/routes/generate/conversation-prompt-formatting.ts (+2 -0)
📝 packages/server/src/routes/generate/dry-run-route.ts (+8 -1)
📝 packages/server/src/services/conversation/server-autonomous-scheduler.service.ts (+9 -2)
📝 packages/server/src/services/conversation/transcript-sanitize.ts (+37 -1)
📝 packages/server/src/services/noodle/noodle-generated-refresh.ts (+65 -0)
📝 packages/server/src/services/noodle/noodle-prompt.ts (+3 -0)
📝 packages/server/src/services/noodle/noodle-public-generation.service.ts (+15 -3)
📝 packages/server/src/services/noodle/noodle-public-prompt.service.ts (+4 -0)
📝 scripts/regressions/open-issues.regression.ts (+20 -0)

📄 Description

Linked issue

Closes #3918

Why this change

Model output could be persisted more than once in two user-visible paths. Noodle could copy a new post verbatim into a reply from the same account, while Conversation mode could repeat a prior substantial message during either a normal reply or an Autonomous check-in.

Conversation also had a separate interrupted-stream recovery race: after an authoritative refetch found the server-saved response, the client could still POST its streamed partial as a second message.

What changed

  • Added explicit no-repeat instructions to Noodle and Conversation prompts, including Conversation prompt previews.
  • Removed normalized duplicate Noodle posts/replies before media preparation or persistence.
  • Rejected substantial exact repeats of the same character's latest Conversation response before saving, while preserving short natural repeats and regeneration/continuation behavior.
  • Added an SSE discard signal so active, background, and server Autonomous flows do not display or notify for rejected copies.
  • Prevented passive stream recovery from performing a second durable partial-message write after its authoritative refetch.

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

Command results:

  • pnpm check — passed, including workspace lint/type checks and production builds.
  • pnpm regression:roleplay — passed.
  • pnpm regression:noodle — passed.
  • Disposable duplicate-boundary regression — passed, then removed per repository policy.
  • pnpm regression:prompt — relevant Conversation assertions passed before the suite stopped on an unrelated existing assertion that the public agent reference is missing Prose Guardian.

Manual verification notes

  • Not performed. This change has no visual layout impact; the reported duplicate-generation scenarios require model/runtime reproduction.

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 installation, configuration, or release behavior changed. No documentation or version files were modified.

UI evidence (if applicable)

Not applicable; no visual UI changes.

Summary by CodeRabbit

  • Bug Fixes

    • Prevented duplicate Conversation responses from being saved or displayed.
    • Improved recovery after interrupted background generation.
    • Correctly handles discarded generations without leaving stale streamed text.
    • Prevented duplicate generated posts and replies in Noodle timelines.
  • Improvements

    • Enhanced generation completion, notifications, and retry handling after stream interruptions.
    • Added safeguards to encourage unique Conversation and Noodle content.

🔄 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/3920 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 7/21/2026 **Status:** ✅ Merged **Merged:** 7/21/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/prevent-duplicate-posts` --- ### 📝 Commits (7) - [`130028c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/130028cc4d54763660c01214df29a6e6114f34f0) Prevent duplicate generated posts and replies - [`d75ff9e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d75ff9ef1c38301d6e3dbe2ad466133cd874629b) fix: handle duplicate discard edge cases - [`7870cc6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7870cc63c076b9e117643ab644bf9dfe87b04738) Merge branch 'staging' into fix/prevent-duplicate-posts - [`e96f31b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e96f31b8638c2ddf2fda1f7f136b8b46155e00ce) Merge branch 'staging' into fix/prevent-duplicate-posts - [`359d43b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/359d43b5a06b0686e7337f53197d6b68807bf81a) Address CodeRabbit review feedback - [`c832a96`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c832a9619e85ddee51055d5de12b40bcf8b0418e) Merge remote-tracking branch 'origin/staging' into codex/review-3920 - [`31ddd1d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/31ddd1ddd86820c8a03e5aef1960adabf98a665f) Merge remote-tracking branch 'origin/pr-3920-live' into codex/review-3920 ### 📊 Changes **12 files changed** (+356 additions, -52 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/hooks/use-background-autonomous.ts` (+3 -1) 📝 `packages/client/src/hooks/use-generate.ts` (+142 -44) 📝 `packages/server/src/routes/generate.routes.ts` (+48 -0) 📝 `packages/server/src/routes/generate/conversation-prompt-formatting.ts` (+2 -0) 📝 `packages/server/src/routes/generate/dry-run-route.ts` (+8 -1) 📝 `packages/server/src/services/conversation/server-autonomous-scheduler.service.ts` (+9 -2) 📝 `packages/server/src/services/conversation/transcript-sanitize.ts` (+37 -1) 📝 `packages/server/src/services/noodle/noodle-generated-refresh.ts` (+65 -0) 📝 `packages/server/src/services/noodle/noodle-prompt.ts` (+3 -0) 📝 `packages/server/src/services/noodle/noodle-public-generation.service.ts` (+15 -3) 📝 `packages/server/src/services/noodle/noodle-public-prompt.service.ts` (+4 -0) 📝 `scripts/regressions/open-issues.regression.ts` (+20 -0) </details> ### 📄 Description ## Linked issue Closes #3918 ## Why this change Model output could be persisted more than once in two user-visible paths. Noodle could copy a new post verbatim into a reply from the same account, while Conversation mode could repeat a prior substantial message during either a normal reply or an Autonomous check-in. Conversation also had a separate interrupted-stream recovery race: after an authoritative refetch found the server-saved response, the client could still POST its streamed partial as a second message. ## What changed - Added explicit no-repeat instructions to Noodle and Conversation prompts, including Conversation prompt previews. - Removed normalized duplicate Noodle posts/replies before media preparation or persistence. - Rejected substantial exact repeats of the same character's latest Conversation response before saving, while preserving short natural repeats and regeneration/continuation behavior. - Added an SSE discard signal so active, background, and server Autonomous flows do not display or notify for rejected copies. - Prevented passive stream recovery from performing a second durable partial-message write after its authoritative refetch. ## Validation - [x] `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) - [x] Read and followed `CONTRIBUTING.md` Command results: - `pnpm check` — passed, including workspace lint/type checks and production builds. - `pnpm regression:roleplay` — passed. - `pnpm regression:noodle` — passed. - Disposable duplicate-boundary regression — passed, then removed per repository policy. - `pnpm regression:prompt` — relevant Conversation assertions passed before the suite stopped on an unrelated existing assertion that the public agent reference is missing Prose Guardian. ### Manual verification notes - Not performed. This change has no visual layout impact; the reported duplicate-generation scenarios require model/runtime reproduction. ## 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 installation, configuration, or release behavior changed. No documentation or version files were modified. ## UI evidence (if applicable) Not applicable; no visual UI changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Prevented duplicate Conversation responses from being saved or displayed. * Improved recovery after interrupted background generation. * Correctly handles discarded generations without leaving stale streamed text. * Prevented duplicate generated posts and replies in Noodle timelines. * **Improvements** * Enhanced generation completion, notifications, and retry handling after stream interruptions. * Added safeguards to encourage unique Conversation and Noodle content. <!-- 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:07:38 +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#6158
No description provided.