[PR #5329] [MERGED] fix: isolate Roleplay swipe agent lifecycle #6730

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

📋 Pull Request Information

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

Base: staging ← Head: fix/roleplay-swipe-illustrator-image


📝 Commits (2)

  • 5472a1b fix: isolate roleplay swipe agent lifecycle
  • 20846ae fix: keep agent aborts scoped to detached runs

📊 Changes

6 files changed (+124 additions, -14 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/client/src/lib/message-cache-reconciliation.ts (+5 -3)
📝 packages/server/src/routes/generate.routes.ts (+36 -4)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+14 -2)
📝 scripts/regressions/open-issues.regression.ts (+1 -5)
📝 scripts/regressions/roleplay-streaming.regression.ts (+67 -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 #5328

Why this change

  • A discarded Roleplay swipe could keep running post-processing agents. Their media could leak into the selected swipe through cache reconciliation, and the overlapping work could occupy generation capacity while Stop Agents failed to reach work still registered as the active request.

What changed

  • Keep generated-message extras only when the persisted snapshot still represents the same active swipe.
  • Anchor detached and retried agent runs to their exact message and swipe.
  • Cancel only abandoned-swipe agent work when the user commits the next Roleplay turn.
  • Let Stop Agents fall back to agent work still inside the active request when no detached tail exists, without sending a backend-wide abort.
  • Add regression coverage and an Unreleased changelog entry.

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 validation completed: pnpm check.
  • Focused regressions completed: scripts/regressions/roleplay-streaming.regression.ts and scripts/regressions/open-issues.regression.ts.
  • Manual browser reproduction was not performed; verify regenerating a Roleplay swipe with Illustrator, selecting the prior swipe before agents finish, sending the next turn, and using Stop Agents.

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)

  • Not applicable: this changes runtime ownership and cache reconciliation without changing the interface.

Summary by CodeRabbit

  • Bug Fixes

    • Improved cancellation of Roleplay generations and active agent requests.
    • Prevented abandoned swipe illustrations and attachments from reappearing after selecting a different swipe.
    • Preserved relevant post-processing attachments when refreshing the same swipe.
    • Improved stopping behavior for both attached and detached agent runs.
    • Maintained the correct swipe context while generation transitions between processing stages.
  • Tests

    • Added regression coverage for cancellation, swipe selection, attachment handling, and agent stopping.

🔄 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/5329 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 8/20/2026 **Status:** ✅ Merged **Merged:** 8/20/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/roleplay-swipe-illustrator-image` --- ### 📝 Commits (2) - [`5472a1b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5472a1bfafb61d568ebc2f4a8805aea6e0d1c1f7) fix: isolate roleplay swipe agent lifecycle - [`20846ae`](https://github.com/Pasta-Devs/Marinara-Engine/commit/20846ae205673e8c6a2725151fe0eb934b998adc) fix: keep agent aborts scoped to detached runs ### 📊 Changes **6 files changed** (+124 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/client/src/lib/message-cache-reconciliation.ts` (+5 -3) 📝 `packages/server/src/routes/generate.routes.ts` (+36 -4) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+14 -2) 📝 `scripts/regressions/open-issues.regression.ts` (+1 -5) 📝 `scripts/regressions/roleplay-streaming.regression.ts` (+67 -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`. ## Linked issue Closes #5328 ## Why this change - A discarded Roleplay swipe could keep running post-processing agents. Their media could leak into the selected swipe through cache reconciliation, and the overlapping work could occupy generation capacity while Stop Agents failed to reach work still registered as the active request. ## What changed - Keep generated-message extras only when the persisted snapshot still represents the same active swipe. - Anchor detached and retried agent runs to their exact message and swipe. - Cancel only abandoned-swipe agent work when the user commits the next Roleplay turn. - Let Stop Agents fall back to agent work still inside the active request when no detached tail exists, without sending a backend-wide abort. - Add regression coverage and an Unreleased changelog entry. ## 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 validation completed: `pnpm check`. - Focused regressions completed: `scripts/regressions/roleplay-streaming.regression.ts` and `scripts/regressions/open-issues.regression.ts`. - Manual browser reproduction was not performed; verify regenerating a Roleplay swipe with Illustrator, selecting the prior swipe before agents finish, sending the next turn, and using Stop Agents. ## 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) - Not applicable: this changes runtime ownership and cache reconciliation without changing the interface. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved cancellation of Roleplay generations and active agent requests. - Prevented abandoned swipe illustrations and attachments from reappearing after selecting a different swipe. - Preserved relevant post-processing attachments when refreshing the same swipe. - Improved stopping behavior for both attached and detached agent runs. - Maintained the correct swipe context while generation transitions between processing stages. - **Tests** - Added regression coverage for cancellation, swipe selection, attachment handling, and agent stopping. <!-- 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:13:08 +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#6730
No description provided.