[PR #4685] [MERGED] Persist the first edit after stopping Roleplay generation #6469

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4685
Author: @SpicyMarinara
Created: 8/6/2026
Status: ✅ Merged
Merged: 8/6/2026
Merged by: @SpicyMarinara

Base: staging ← Head: agent/4678-reconcile-optimistic-edit


📝 Commits (3)

📊 Changes

4 files changed (+90 additions, -21 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 e2e/core-flows.e2e.ts (+55 -15)
📝 packages/client/src/hooks/use-generate.ts (+24 -4)
📝 packages/server/src/routes/generate.routes.ts (+10 -2)

📄 Description

Linked issue

Closes #4678

Why this change

  • A user message is persisted before generation starts, but the Roleplay UI continued rendering its temporary optimistic ID until a later message refresh. If generation was stopped and the message was edited immediately, the first PATCH targeted that temporary ID and the edit was discarded.

What changed

  • Emit the saved user message when the generation stream opens.
  • Reconcile the optimistic row with its durable server row through their existing submission ID, while preventing duplicate cache rows.
  • Extend the Roleplay regression to stop generation and save the first edit before the stopped-generation refresh can resolve.
  • Add the user-facing fix to the Unreleased changelog.

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

  • Automated Playwright: exact stopped-generation first-edit regression passes on desktop Chromium.
  • Automated Playwright: the same regression passes on mobile Chromium.
  • The test also retains coverage for a delayed save with one forced transient 503 retry and for provider refusal cleanup.
  • Before the fix, the exact regression failed because the edited text never reached the durable user message.
  • Manual verification by Mari is intentionally pending while this PR remains a draft.

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)

UI evidence (if applicable)

  • Behavioral fix only; no visual changes.

Summary by CodeRabbit

  • Bug Fixes
    • Improved message synchronization after generation so newly sent messages receive their saved identifiers promptly.
    • Fixed the first edit to a newly generated message not being persisted reliably.
    • Improved handling of repeated edits, including save retries when an earlier save fails.
    • Prevented duplicate messages when temporary and saved message records are reconciled.
    • Improved message persistence during interrupted or refused generation flows.
    • Ensured edits continue to apply correctly after message metadata is updated.

🔄 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/4685 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 8/6/2026 **Status:** ✅ Merged **Merged:** 8/6/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `agent/4678-reconcile-optimistic-edit` --- ### 📝 Commits (3) - [`6455369`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6455369e9fb563126d4c3f9c23e236c3fff1c082) chore: restart #4678 fix - [`f4dd93f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f4dd93fd129192182b398ed709dc0e77963f2356) fix: reconcile optimistic Roleplay edits - [`11c6126`](https://github.com/Pasta-Devs/Marinara-Engine/commit/11c6126acd7dc953a980b64aa601f1f15f1da72c) test: require Roleplay stop control ### 📊 Changes **4 files changed** (+90 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `e2e/core-flows.e2e.ts` (+55 -15) 📝 `packages/client/src/hooks/use-generate.ts` (+24 -4) 📝 `packages/server/src/routes/generate.routes.ts` (+10 -2) </details> ### 📄 Description ## Linked issue Closes #4678 ## Why this change - A user message is persisted before generation starts, but the Roleplay UI continued rendering its temporary optimistic ID until a later message refresh. If generation was stopped and the message was edited immediately, the first PATCH targeted that temporary ID and the edit was discarded. ## What changed - Emit the saved user message when the generation stream opens. - Reconcile the optimistic row with its durable server row through their existing submission ID, while preventing duplicate cache rows. - Extend the Roleplay regression to stop generation and save the first edit before the stopped-generation refresh can resolve. - Add the user-facing fix to the Unreleased changelog. ## 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 - Automated Playwright: exact stopped-generation first-edit regression passes on desktop Chromium. - Automated Playwright: the same regression passes on mobile Chromium. - The test also retains coverage for a delayed save with one forced transient 503 retry and for provider refusal cleanup. - Before the fix, the exact regression failed because the edited text never reached the durable user message. - Manual verification by Mari is intentionally pending while this PR remains a draft. ## 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) ## UI evidence (if applicable) - Behavioral fix only; no visual changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved message synchronization after generation so newly sent messages receive their saved identifiers promptly. * Fixed the first edit to a newly generated message not being persisted reliably. * Improved handling of repeated edits, including save retries when an earlier save fails. * Prevented duplicate messages when temporary and saved message records are reconciled. * Improved message persistence during interrupted or refused generation flows. * Ensured edits continue to apply correctly after message metadata is updated. <!-- 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:10:43 +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#6469
No description provided.