[PR #6174] [MERGED] fix: stop queued Roleplay text when generation is cancelled #7076

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6174
Author: @SpicyMarinara
Created: 9/13/2026
Status: ✅ Merged
Merged: 9/13/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/roleplay-generation-stop


📝 Commits (7)

  • 7f99815 docs: track Roleplay stop-generation regression
  • 86c7ed0 fix: release Roleplay text drains when generation stops
  • 5c46b18 Merge remote-tracking branch 'origin/staging' into fix/roleplay-generation-stop
  • 3ff5596 fix: stop superseded Roleplay typewriter frames
  • 3fac0df fix: retain replacement generation through stopped reply cleanup
  • 7021864 Merge remote-tracking branch 'origin/staging' into fix/roleplay-generation-stop
  • dd96271 test: retain notes replacement and Game cleanup regression contracts

📊 Changes

6 files changed (+416 additions, -51 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 e2e/generation-recovery.e2e.ts (+237 -0)
📝 e2e/illustration-arrival.e2e.ts (+128 -0)
📝 packages/client/src/hooks/use-generate.ts (+48 -46)
📝 scripts/regressions/roleplay-commands.regression.ts (+1 -4)
📝 scripts/regressions/roleplay-streaming.regression.ts (+1 -1)

📄 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 #6173

Why this change

Pressing Stop in Roleplay could leave the Pause button visible while queued text continued appearing, even after the server had finished the reply. The client was waiting for its typewriter animation to drain without observing cancellation. Stop now releases that wait promptly and returns the composer to Send; already-completed saved replies remain intact.

What changed

  • Reuse the existing abort signal and buffer flush to resolve pending text-reveal waits. Aborted or superseded generations stop their animation frames and resolve their local queue; the listener is removed during existing cleanup.
  • Publish buffered text only while the request still owns the chat. After partial-message persistence and history refresh, recheck ownership before resetting the composer or buffers so a replacement reply keeps its live state.
  • Add four parameterized Stop cases to the existing generation-recovery browser suite and an overlapping-reply case to the illustration suite; update the changelog. Reuse existing cancellation, persistence, and refresh helpers without new dependencies or settings.

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

Automated validation

  • Reproduced both buffered-response failures before the fix: the real Stop endpoint succeeded but Pause remained beyond the explicit two-second limit.
  • Nine Stop checks pass across desktop Chromium, mobile Chromium, and mobile WebKit: assistant-message-ready wait, completed transport, and a held live provider. Pause, controller ownership, and the stream buffer clear promptly; completed replies remain unchanged in storage, and the active provider connection closes.
  • Six illustration handoff controls pass on the same production source: saved illustrations remain visible while the agent stream is open, and an older un-aborted request releases its text queue without overwriting or cancelling a replacement.
  • Three delayed-save checks pass, one per browser: hold the stopped reply's actual partial-message save response, navigate away and back, start a replacement, then finish the old cleanup. The replacement keeps its controller, Pause control, and already-visible text. Before the fix, the old cleanup reset streaming to false and emptied the replacement buffer. These fixtures establish preservation of visible text, not full reveal timing while a response is deliberately held.
  • Updated two existing regression assertions for the reviewed notes wording and consolidated Game refresh guard; both targeted regressions pass. The final follow-up changes tests only.
  • All 18 focused cases pass on the final client source. E2E typechecking, formatting, diff checks, and independent review pass. Existing server cancellation and real-route interruption regressions pass.
  • pnpm check passes on final commit dd962716a6834b2babde5f7c46b74feff4793420, including staging's separate notes update. Required build/static checks and the complete Node regression suite pass on the merged head. CodeRabbit completed its production-code review with no actionable findings on 702186468; its final test-only review was rate-limited when the maintainer merged this PR.

Browser tests use a local synthetic provider and isolated data; physical iPhone verification is still needed. The previous hosted head had an unexplained WebKit page loss in a Game-log test; its trace did not show an app error or connect it to this change. The broader hosted browser matrix is still running and includes that unchanged case. The earlier Node run had two stale-assertion failures; both were corrected and the complete final Node suite passes.

Manual verification needed

Manually verify Stop during a Roleplay reply on desktop and the iPhone Home Screen app: text stops appearing and the send control becomes available promptly.

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)

Mobile WebKit interaction screenshots show before and after pressing Stop with this fix. The full saved reply remains visible and Send is available afterward. Synthetic fixture content only; the automated two-second assertions establish prompt cancellation.

Summary by CodeRabbit

  • Bug Fixes
    • Stopping a Roleplay reply now immediately reveals and saves remaining buffered text.
    • Stopping generation promptly releases generation controls and re-enables the composer.
    • Superseded or aborted generations no longer update visible response streams.
    • Overlapping illustration generations now preserve the latest response and processing state.
  • Tests
    • Added end-to-end coverage for stopping generation across multiple streaming stages, including partial saves.
    • Added coverage for overlapping illustration-generation streams.

🔄 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/6174 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 9/13/2026 **Status:** ✅ Merged **Merged:** 9/13/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/roleplay-generation-stop` --- ### 📝 Commits (7) - [`7f99815`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7f99815f933cd45d9aaa25a06363c0f5177092d3) docs: track Roleplay stop-generation regression - [`86c7ed0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/86c7ed0ae6a408f39d3fefd4664f494c8dcaf8ff) fix: release Roleplay text drains when generation stops - [`5c46b18`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5c46b1808bc88cd9159c4e3bd2d7bf0ba4ec2265) Merge remote-tracking branch 'origin/staging' into fix/roleplay-generation-stop - [`3ff5596`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3ff559683e1806ba389dabdf41c5e3abe77bc0f5) fix: stop superseded Roleplay typewriter frames - [`3fac0df`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3fac0df2ce8c1eacfbce16bad67d4dc1eec6dc85) fix: retain replacement generation through stopped reply cleanup - [`7021864`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7021864687e8715ae19a0b33ca49d89a4dafd47f) Merge remote-tracking branch 'origin/staging' into fix/roleplay-generation-stop - [`dd96271`](https://github.com/Pasta-Devs/Marinara-Engine/commit/dd962716a6834b2babde5f7c46b74feff4793420) test: retain notes replacement and Game cleanup regression contracts ### 📊 Changes **6 files changed** (+416 additions, -51 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `e2e/generation-recovery.e2e.ts` (+237 -0) 📝 `e2e/illustration-arrival.e2e.ts` (+128 -0) 📝 `packages/client/src/hooks/use-generate.ts` (+48 -46) 📝 `scripts/regressions/roleplay-commands.regression.ts` (+1 -4) 📝 `scripts/regressions/roleplay-streaming.regression.ts` (+1 -1) </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 <!-- 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 #6173 ## Why this change Pressing Stop in Roleplay could leave the Pause button visible while queued text continued appearing, even after the server had finished the reply. The client was waiting for its typewriter animation to drain without observing cancellation. Stop now releases that wait promptly and returns the composer to Send; already-completed saved replies remain intact. ## What changed - Reuse the existing abort signal and buffer flush to resolve pending text-reveal waits. Aborted or superseded generations stop their animation frames and resolve their local queue; the listener is removed during existing cleanup. - Publish buffered text only while the request still owns the chat. After partial-message persistence and history refresh, recheck ownership before resetting the composer or buffers so a replacement reply keeps its live state. - Add four parameterized Stop cases to the existing generation-recovery browser suite and an overlapping-reply case to the illustration suite; update the changelog. Reuse existing cancellation, persistence, and refresh helpers without new dependencies or settings. ## 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` ### Automated validation - Reproduced both buffered-response failures before the fix: the real Stop endpoint succeeded but Pause remained beyond the explicit two-second limit. - Nine Stop checks pass across desktop Chromium, mobile Chromium, and mobile WebKit: assistant-message-ready wait, completed transport, and a held live provider. Pause, controller ownership, and the stream buffer clear promptly; completed replies remain unchanged in storage, and the active provider connection closes. - Six illustration handoff controls pass on the same production source: saved illustrations remain visible while the agent stream is open, and an older un-aborted request releases its text queue without overwriting or cancelling a replacement. - Three delayed-save checks pass, one per browser: hold the stopped reply's actual partial-message save response, navigate away and back, start a replacement, then finish the old cleanup. The replacement keeps its controller, Pause control, and already-visible text. Before the fix, the old cleanup reset streaming to false and emptied the replacement buffer. These fixtures establish preservation of visible text, not full reveal timing while a response is deliberately held. - Updated two existing regression assertions for the reviewed notes wording and consolidated Game refresh guard; both targeted regressions pass. The final follow-up changes tests only. - All 18 focused cases pass on the final client source. E2E typechecking, formatting, diff checks, and independent review pass. Existing server cancellation and real-route interruption regressions pass. - `pnpm check` passes on final commit `dd962716a6834b2babde5f7c46b74feff4793420`, including staging's separate notes update. Required build/static checks and the complete Node regression suite pass on the merged head. CodeRabbit completed its production-code review with no actionable findings on `702186468`; its final test-only review was rate-limited when the maintainer merged this PR. Browser tests use a local synthetic provider and isolated data; physical iPhone verification is still needed. The previous hosted head had an unexplained WebKit page loss in a Game-log test; its trace did not show an app error or connect it to this change. The broader hosted browser matrix is still running and includes that unchanged case. The earlier Node run had two stale-assertion failures; both were corrected and the complete final Node suite passes. ### Manual verification needed Manually verify Stop during a Roleplay reply on desktop and the iPhone Home Screen app: text stops appearing and the send control becomes available promptly. <!-- ⚠️ 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. --> ## 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) [Mobile WebKit interaction screenshots](https://gist.github.com/SpicyMarinara/55193d7ea43d62361ddd2e3dec48c408) show before and after pressing Stop with this fix. The full saved reply remains visible and Send is available afterward. Synthetic fixture content only; the automated two-second assertions establish prompt cancellation. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Stopping a Roleplay reply now immediately reveals and saves remaining buffered text. - Stopping generation promptly releases generation controls and re-enables the composer. - Superseded or aborted generations no longer update visible response streams. - Overlapping illustration generations now preserve the latest response and processing state. - **Tests** - Added end-to-end coverage for stopping generation across multiple streaming stages, including partial saves. - Added coverage for overlapping illustration-generation streams. <!-- 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:16:20 +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#7076
No description provided.