[PR #3837] [MERGED] fix: smooth Roleplay interactions and TTS pauses #6123

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

📋 Pull Request Information

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

Base: staging ← Head: fix/roleplay-composer-stream-smoothing


📝 Commits (7)

  • 25c9a36 chore: start roleplay responsiveness fix
  • dcf8a4f fix: smooth roleplay typing and streaming
  • fe07582 fix: keep roleplay backgrounds stable during panel resize
  • bd306da Revert "fix: keep roleplay backgrounds stable during panel resize"
  • 3634be5 fix: stabilize roleplay backgrounds and TTS pauses
  • 746a9a3 fix: resize roleplay backgrounds with sidebars
  • 1e4052b fix: address roleplay smoothing review

📊 Changes

14 files changed (+273 additions, -56 deletions)

View changed files

📝 CHANGELOG.md (+3 -0)
📝 docs/chats/sending-and-streaming.md (+1 -1)
📝 e2e/core-flows.e2e.ts (+49 -2)
📝 packages/client/src/components/chat/ChatInput.tsx (+31 -8)
📝 packages/client/src/components/chat/ChatRoleplaySurface.tsx (+10 -6)
📝 packages/client/src/components/panels/settings/TTSConfigCard.tsx (+24 -14)
📝 packages/client/src/hooks/use-generate.ts (+21 -1)
📝 packages/client/src/lib/generation-stream-policy.ts (+24 -0)
📝 packages/client/src/styles/globals.css (+28 -10)
📝 packages/client/src/styles/themes/sillytavern.css (+3 -2)
📝 packages/client/src/workers/weather-effects.worker.ts (+6 -2)
📝 packages/shared/src/types/tts.ts (+18 -1)
📝 scripts/regressions/roleplay-streaming.regression.ts (+32 -0)
📝 scripts/regressions/tts-source-persistence.regression.ts (+23 -9)

📄 Description

Closes #3836

Why

Roleplay typing published the full draft to shared state synchronously for every key. Streamed replies also drained each provider burst faster than the next chunk arrived, and the Roleplay streaming glow continuously repainted a box shadow. Together these made both composing and reading feel less fluid.

Firefox could also briefly flash Roleplay's visual layers while the desktop shell changed width around opening or closing sidebars. The first workaround kept the background viewport-sized, but that caused sidebars to crop it instead of resizing the whole composition into the remaining chat area. The weather OffscreenCanvas also cleared itself on resize and waited until its next 30 FPS tick to repaint. Separately, the TTS dialogue-pause control exposed milliseconds, allowed no pause, and topped out at only 1.5 seconds instead of presenting a useful human-scale range.

Changes

  • Batch Roleplay draft publication to one update per animation frame and avoid rescanning quote formatting for unrelated input events.
  • Measure visible token delivery and keep the open Typewriter queue slightly behind that cadence, then return to the selected speed as soon as transport completes.
  • Replace the animated box shadow with a compositor-friendly opacity pulse and disable the loop for reduced-motion users.
  • Render Roleplay crossfade backgrounds as persistent image layers that resize with the chat pane and preserve the whole composition as sidebars change the available width.
  • Repaint the weather OffscreenCanvas immediately after initialization and resize so the browser never presents its cleared intermediate state.
  • Keep the instant desktop sidebar fallback in Firefox; other browsers retain the existing panel animation.
  • Present the TTS dialogue pause as whole seconds from 1 through 60 while retaining millisecond storage compatibility and migrating legacy sub-second or no-pause values to one second.
  • Document the changes and extend Roleplay, TTS persistence, and Connections UI regression coverage.

Automated validation

  • pnpm check
  • pnpm --filter @marinara-engine/client lint
  • pnpm --filter @marinara-engine/client build
  • pnpm regression:roleplay
  • pnpm regression:tts
  • pnpm smoke:ui (72 passed, 46 viewport-specific skips)
  • Targeted PocketTTS Connections UI test in desktop Chromium
  • Repeated selected-background open/close cycles for both sidebars in desktop Chromium and Firefox
  • git diff --check

Manual verification

  • Manually verify fast typing in a long Roleplay draft on desktop.
  • Manually verify the composer on a mobile viewport.
  • Manually verify a bursty streamed Roleplay response at low, default, and high Streaming Speed settings.
  • Manually verify stream completion, regeneration, rewrite, and group-turn transitions.
  • Manually verify the complete selected Roleplay background resizes with the chat area when opening and closing both desktop sidebars.
  • Manually verify weather effects remain visually stable while opening and closing both desktop sidebars in Firefox.
  • Manually verify reduced-motion behavior.
  • Manually verify the TTS dialogue pause shows and persists whole seconds from 1 through 60 in Settings → Connections → TTS.

Summary by CodeRabbit

  • Bug Fixes

    • Improved streaming text pacing for smoother, more responsive generation.
    • Reduced Roleplay background flashes during layout changes, especially in Firefox.
    • Refined Roleplay streaming visuals with a smoother opacity-based pulse.
  • Improvements

    • TTS dialogue pauses now use whole seconds from 1–60, with older values automatically adjusted.
    • Updated streaming-speed guidance to clarify how bursty generation is smoothed and rendered.
  • Documentation

    • Clarified the behavior of the streaming speed setting.

🔄 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/3837 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 7/19/2026 **Status:** ✅ Merged **Merged:** 7/20/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/roleplay-composer-stream-smoothing` --- ### 📝 Commits (7) - [`25c9a36`](https://github.com/Pasta-Devs/Marinara-Engine/commit/25c9a366cd939804ae925ab42f90e867b9cdfb69) chore: start roleplay responsiveness fix - [`dcf8a4f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/dcf8a4f0db70f8a3abbd44b12b95730c4d7ef75e) fix: smooth roleplay typing and streaming - [`fe07582`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fe07582eb77c2c00e83d5201aa36003e56ee1e5b) fix: keep roleplay backgrounds stable during panel resize - [`bd306da`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bd306da6479a7874933b95a1b302d8a883839030) Revert "fix: keep roleplay backgrounds stable during panel resize" - [`3634be5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3634be5a2429f196c7cd3e14d2178264664eece0) fix: stabilize roleplay backgrounds and TTS pauses - [`746a9a3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/746a9a38456a7b019cf9aa2f297dbed8796a9a40) fix: resize roleplay backgrounds with sidebars - [`1e4052b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1e4052bf49d43cc2bfe8703aa1898fcd8ec93821) fix: address roleplay smoothing review ### 📊 Changes **14 files changed** (+273 additions, -56 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -0) 📝 `docs/chats/sending-and-streaming.md` (+1 -1) 📝 `e2e/core-flows.e2e.ts` (+49 -2) 📝 `packages/client/src/components/chat/ChatInput.tsx` (+31 -8) 📝 `packages/client/src/components/chat/ChatRoleplaySurface.tsx` (+10 -6) 📝 `packages/client/src/components/panels/settings/TTSConfigCard.tsx` (+24 -14) 📝 `packages/client/src/hooks/use-generate.ts` (+21 -1) 📝 `packages/client/src/lib/generation-stream-policy.ts` (+24 -0) 📝 `packages/client/src/styles/globals.css` (+28 -10) 📝 `packages/client/src/styles/themes/sillytavern.css` (+3 -2) 📝 `packages/client/src/workers/weather-effects.worker.ts` (+6 -2) 📝 `packages/shared/src/types/tts.ts` (+18 -1) 📝 `scripts/regressions/roleplay-streaming.regression.ts` (+32 -0) 📝 `scripts/regressions/tts-source-persistence.regression.ts` (+23 -9) </details> ### 📄 Description Closes #3836 ## Why Roleplay typing published the full draft to shared state synchronously for every key. Streamed replies also drained each provider burst faster than the next chunk arrived, and the Roleplay streaming glow continuously repainted a box shadow. Together these made both composing and reading feel less fluid. Firefox could also briefly flash Roleplay's visual layers while the desktop shell changed width around opening or closing sidebars. The first workaround kept the background viewport-sized, but that caused sidebars to crop it instead of resizing the whole composition into the remaining chat area. The weather OffscreenCanvas also cleared itself on resize and waited until its next 30 FPS tick to repaint. Separately, the TTS dialogue-pause control exposed milliseconds, allowed no pause, and topped out at only 1.5 seconds instead of presenting a useful human-scale range. ## Changes - Batch Roleplay draft publication to one update per animation frame and avoid rescanning quote formatting for unrelated input events. - Measure visible token delivery and keep the open Typewriter queue slightly behind that cadence, then return to the selected speed as soon as transport completes. - Replace the animated box shadow with a compositor-friendly opacity pulse and disable the loop for reduced-motion users. - Render Roleplay crossfade backgrounds as persistent image layers that resize with the chat pane and preserve the whole composition as sidebars change the available width. - Repaint the weather OffscreenCanvas immediately after initialization and resize so the browser never presents its cleared intermediate state. - Keep the instant desktop sidebar fallback in Firefox; other browsers retain the existing panel animation. - Present the TTS dialogue pause as whole seconds from 1 through 60 while retaining millisecond storage compatibility and migrating legacy sub-second or no-pause values to one second. - Document the changes and extend Roleplay, TTS persistence, and Connections UI regression coverage. ## Automated validation - `pnpm check` - `pnpm --filter @marinara-engine/client lint` - `pnpm --filter @marinara-engine/client build` - `pnpm regression:roleplay` - `pnpm regression:tts` - `pnpm smoke:ui` (72 passed, 46 viewport-specific skips) - Targeted PocketTTS Connections UI test in desktop Chromium - Repeated selected-background open/close cycles for both sidebars in desktop Chromium and Firefox - `git diff --check` ## Manual verification - [ ] Manually verify fast typing in a long Roleplay draft on desktop. - [ ] Manually verify the composer on a mobile viewport. - [ ] Manually verify a bursty streamed Roleplay response at low, default, and high Streaming Speed settings. - [ ] Manually verify stream completion, regeneration, rewrite, and group-turn transitions. - [ ] Manually verify the complete selected Roleplay background resizes with the chat area when opening and closing both desktop sidebars. - [ ] Manually verify weather effects remain visually stable while opening and closing both desktop sidebars in Firefox. - [ ] Manually verify reduced-motion behavior. - [ ] Manually verify the TTS dialogue pause shows and persists whole seconds from 1 through 60 in Settings → Connections → TTS. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved streaming text pacing for smoother, more responsive generation. - Reduced Roleplay background flashes during layout changes, especially in Firefox. - Refined Roleplay streaming visuals with a smoother opacity-based pulse. - **Improvements** - TTS dialogue pauses now use whole seconds from 1–60, with older values automatically adjusted. - Updated streaming-speed guidance to clarify how bursty generation is smoothed and rendered. - **Documentation** - Clarified the behavior of the streaming speed setting. <!-- 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:18 +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#6123
No description provided.