[PR #6515] [MERGED] feat(tts): allow clearing cached audio for specific message #7207

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

📋 Pull Request Information

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

Base: staging ← Head: feature/tts-cache-clear


📝 Commits (10+)

  • 8a62ecb feat(tts): allow clearing cached audio for specific message
  • 76108e3 Merge branch 'staging' into feature/tts-cache-clear
  • 3687815 fix(tts): prevent late persistent read from restoring purged audio
  • c7dacee Merge branch 'staging' into feature/tts-cache-clear
  • a00990a Merge branch 'staging' into feature/tts-cache-clear
  • 1aba299 fix(i18n): sort clearCachedVoice key alphabetically
  • 9265b37 Merge branch 'staging' into feature/tts-cache-clear
  • 039ee7f style: format ChatMessage.tsx with prettier
  • 539e2c6 Merge branch 'staging' into feature/tts-cache-clear
  • 30545cc feat(help): add eraser icon to legend and clean up unused variable

📊 Changes

10 files changed (+308 additions, -76 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 e2e/chat-sweep.e2e.ts (+4 -4)
📝 e2e/roleplay-vn.e2e.ts (+1 -0)
📝 e2e/tts-mobile-playback.e2e.ts (+15 -6)
📝 packages/client/src/components/chat/ChatHelpOverlay.tsx (+4 -5)
📝 packages/client/src/components/chat/ChatMessage.tsx (+129 -49)
📝 packages/client/src/lib/tts-audio-cache.ts (+56 -11)
📝 packages/client/src/lib/tts-service.ts (+18 -1)
📝 packages/client/src/localization/locales/en.json (+3 -0)
➕ scripts/regressions/tts-cache-clear.regression.ts (+76 -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 #6514

Why this change

  • Currently, dialogue TTS audio is aggressively cached in browser IndexedDB.
  • If audio has generation glitches/artifacts, or if the user updates/fine-tunes their local TTS backend, voice models, or launch scripts (e.g. adding pre-translation), there is no way to invalidate the voiceover for a single message.
  • Users are forced to wipe the entire browser database (marinara-tts-audio-cache), deleting cached voice lines across all other chats and characters.

What changed

  • packages/client/src/lib/tts-audio-cache.ts:
    • Exported deleteCachedTTSAudioKeys to drop cache entries from memory and IndexedDB (both message keys and text-hash aliases).
    • Track invalidation per cache key so in-flight synthesis cannot restore a cleared clip or invalidate unrelated messages.
  • packages/client/src/lib/tts-service.ts:
    • Added clearCachedAudio helper method to extract cache keys and trigger eviction.
  • packages/client/src/components/chat/ChatMessage.tsx:
    • Added an Eraser action button to message toolbars (both standard and alternate layouts) to purge cache for that specific message.
    • The audio menu groups playback, volume and cache clearing. Clearing stops current playback and removes cached audio without starting synthesis.
  • packages/client/src/localization/locales/en.json:
    • Added "ui.chat.chatmessage.clearCachedVoice": "Clear cached voice".

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

  • Rebuilt the app locally via pnpm build on Windows.
  • Verified that clicking the eraser button drops the cached audio for that specific message without launching autoplay or freezing the action spinner.
  • Verified that pressing the standard Speak button immediately afterwards triggers a fresh synthesis request to the TTS provider with the new output.
  • Checked both action button toolbar layouts in chat.

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
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

image

Summary by CodeRabbit

  • New Features

    • Added a Clear cached voice action for chat messages with text-to-speech audio.
    • Clearing stops active playback and removes cached voice audio for that message.
    • Voice audio is regenerated the next time it is played.
    • Added loading feedback and consolidated voice controls for playback and volume.
    • Added the action to chat help legends.
  • Bug Fixes

    • Prevented cleared voice audio from reappearing due to in-progress generation or stale cache operations.

Maintainer integration verification

Reconciled with staging and restored the visual-novel dialogue layout, portraits and image lightbox. Kept the contributor's compact audio menu, updated its Help Overlay entry, added error feedback, and prevented late cache operations from restoring cleared audio.

  • pnpm check passed, including localization, types, lint and production build.
  • TTS cache-clear and Safari playback regression scripts passed.
  • 15 focused browser checks passed across desktop Chromium, mobile Chromium and mobile WebKit: playback, clearing without autoplay, on-screen volume controls, and visual-novel manual/automatic speech.
  • Updated browser evidence, using synthetic chats and mocked audio. Physical iPhone and Docker execution were not repeated locally.
  • Local CodeRabbit review completed. The Help Overlay placement finding was fixed. Shared text aliases are deliberately cleared so the target cannot replay stale audio; other primary message entries are retained and covered by the regression. The final initial local review reported no further findings. Hosted follow-up findings were fixed and reviewed: clearing one message leaves unrelated in-flight clips cacheable, and an older request cannot replace a fresh request after a purge during its initial cache lookup.

Manual follow-up: verify your real TTS provider from the audio menu. The contributor's existing human checklist is preserved above.


🔄 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/6515 **Author:** [@menemorofaan](https://github.com/menemorofaan) **Created:** 9/22/2026 **Status:** ✅ Merged **Merged:** 9/23/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feature/tts-cache-clear` --- ### 📝 Commits (10+) - [`8a62ecb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8a62ecbc7d1333f0c34b0e58b35cc622e180a350) feat(tts): allow clearing cached audio for specific message - [`76108e3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/76108e32dcc2975b2fbe5599800e997d599e8174) Merge branch 'staging' into feature/tts-cache-clear - [`3687815`](https://github.com/Pasta-Devs/Marinara-Engine/commit/36878156b6c385bffe7f88aebd537c57458e11d9) fix(tts): prevent late persistent read from restoring purged audio - [`c7dacee`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c7dacee25af78319e09550775a3746b0b4060b54) Merge branch 'staging' into feature/tts-cache-clear - [`a00990a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a00990a8660c63f8639ed0ca5789259898ac9e62) Merge branch 'staging' into feature/tts-cache-clear - [`1aba299`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1aba2991a5cca7f9f6cc83e1e31c46e5832bf4c3) fix(i18n): sort clearCachedVoice key alphabetically - [`9265b37`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9265b3749db06f33a3fc0c8cb5cc12c4ce79870a) Merge branch 'staging' into feature/tts-cache-clear - [`039ee7f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/039ee7f9cd3394daea3ca85d3a3a00879ca00a93) style: format ChatMessage.tsx with prettier - [`539e2c6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/539e2c6e28437703b6235bba64dd3eeeb0848cb4) Merge branch 'staging' into feature/tts-cache-clear - [`30545cc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/30545cc035c50e8747a730c3a2e2fd2500d653c9) feat(help): add eraser icon to legend and clean up unused variable ### 📊 Changes **10 files changed** (+308 additions, -76 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `e2e/chat-sweep.e2e.ts` (+4 -4) 📝 `e2e/roleplay-vn.e2e.ts` (+1 -0) 📝 `e2e/tts-mobile-playback.e2e.ts` (+15 -6) 📝 `packages/client/src/components/chat/ChatHelpOverlay.tsx` (+4 -5) 📝 `packages/client/src/components/chat/ChatMessage.tsx` (+129 -49) 📝 `packages/client/src/lib/tts-audio-cache.ts` (+56 -11) 📝 `packages/client/src/lib/tts-service.ts` (+18 -1) 📝 `packages/client/src/localization/locales/en.json` (+3 -0) ➕ `scripts/regressions/tts-cache-clear.regression.ts` (+76 -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 #6514 ## Why this change - Currently, dialogue TTS audio is aggressively cached in browser IndexedDB. - If audio has generation glitches/artifacts, or if the user updates/fine-tunes their local TTS backend, voice models, or launch scripts (e.g. adding pre-translation), there is no way to invalidate the voiceover for a single message. - Users are forced to wipe the entire browser database (`marinara-tts-audio-cache`), deleting cached voice lines across all other chats and characters. ## What changed - **`packages/client/src/lib/tts-audio-cache.ts`**: - Exported `deleteCachedTTSAudioKeys` to drop cache entries from memory and IndexedDB (both message keys and text-hash aliases). - Track invalidation per cache key so in-flight synthesis cannot restore a cleared clip or invalidate unrelated messages. - **`packages/client/src/lib/tts-service.ts`**: - Added `clearCachedAudio` helper method to extract cache keys and trigger eviction. - **`packages/client/src/components/chat/ChatMessage.tsx`**: - Added an `Eraser` action button to message toolbars (both standard and alternate layouts) to purge cache for that specific message. - The audio menu groups playback, volume and cache clearing. Clearing stops current playback and removes cached audio without starting synthesis. - **`packages/client/src/localization/locales/en.json`**: - Added `"ui.chat.chatmessage.clearCachedVoice": "Clear cached voice"`. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Rebuilt the app locally via `pnpm build` on Windows. - Verified that clicking the eraser button drops the cached audio for that specific message without launching autoplay or freezing the action spinner. - Verified that pressing the standard Speak button immediately afterwards triggers a fresh synthesis request to the TTS provider with the new output. - Checked both action button toolbar layouts in chat. ## Docs and release impact - [x] 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 - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) <!-- Paste a screenshot of the new eraser button in the message toolbar below --> <img width="600" height="135" alt="image" src="https://github.com/user-attachments/assets/2cca0222-ced4-4724-9936-725236da5dac" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added a **Clear cached voice** action for chat messages with text-to-speech audio. - Clearing stops active playback and removes cached voice audio for that message. - Voice audio is regenerated the next time it is played. - Added loading feedback and consolidated voice controls for playback and volume. - Added the action to chat help legends. - **Bug Fixes** - Prevented cleared voice audio from reappearing due to in-progress generation or stale cache operations. <!-- end of auto-generated comment: release notes by coderabbit.ai --> ## Maintainer integration verification Reconciled with staging and restored the visual-novel dialogue layout, portraits and image lightbox. Kept the contributor's compact audio menu, updated its Help Overlay entry, added error feedback, and prevented late cache operations from restoring cleared audio. - `pnpm check` passed, including localization, types, lint and production build. - TTS cache-clear and Safari playback regression scripts passed. - 15 focused browser checks passed across desktop Chromium, mobile Chromium and mobile WebKit: playback, clearing without autoplay, on-screen volume controls, and visual-novel manual/automatic speech. - [Updated browser evidence](https://gist.github.com/SpicyMarinara/2b1412992359c0d99be921b6b4b828ff), using synthetic chats and mocked audio. Physical iPhone and Docker execution were not repeated locally. - Local CodeRabbit review completed. The Help Overlay placement finding was fixed. Shared text aliases are deliberately cleared so the target cannot replay stale audio; other primary message entries are retained and covered by the regression. The final initial local review reported no further findings. Hosted follow-up findings were fixed and reviewed: clearing one message leaves unrelated in-flight clips cacheable, and an older request cannot replace a fresh request after a purge during its initial cache lookup. Manual follow-up: verify your real TTS provider from the audio menu. The contributor's existing human checklist is preserved above. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:17:31 +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#7207
No description provided.