[PR #7020] [MERGED] fix(tts): save a Character Editor voice without undoing newer settings #7433

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7020
Author: @SpicyMarinara
Created: 10/3/2026
Status: ✅ Merged
Merged: 10/3/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/tts-voice-assignment-save


📝 Commits (4)

  • 7a655a1 fix(tts): save a Character Editor voice without undoing newer settings
  • a880ea4 fix(tts): keep unreadable TTS settings and cover failed voice saves
  • 4329bb8 Merge remote-tracking branch 'origin/staging' into fix/tts-voice-assignment-save
  • 4ffd8ab fix(tts): switch to per-character voices without undoing newer settings

📊 Changes

9 files changed (+445 additions, -65 deletions)

View changed files

📝 CHANGELOG.md (+1 -1)
📝 e2e/ux-feedback-sweep.e2e.ts (+70 -6)
📝 packages/client/src/components/characters/CharacterVoicePicker.tsx (+20 -24)
📝 packages/client/src/hooks/use-tts.ts (+34 -7)
📝 packages/client/src/lib/tts-dialogue.ts (+6 -17)
📝 packages/server/src/routes/tts.routes.ts (+69 -8)
📝 packages/shared/src/types/tts.ts (+32 -0)
📝 scripts/regressions/tts-source-persistence.regression.ts (+1 -2)
➕ scripts/regressions/tts-voice-assignment-route.regression.ts (+212 -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 #7008

Follow-up to #6998 (found by CodeRabbit there).

Why this change

The Character Editor's new Voice section saved a pick by sending the whole Text to Speech configuration as the page last saw it. If another save landed meanwhile, the pick put the old values back. That other save could come from Connections → Text to Speech, another tab or another device, and could change the speed, the source or another character's voice. Its Use a voice per character button had the same problem. The Voice section hasn't shipped yet, so this fixes it before the release.

What changed

  • Server (tts.routes.ts):
    • PUT /api/tts/config/voice-assignment changes only one character's voice row.
    • PUT /api/tts/config/voice-mode changes only the voice mode.
    • Both apply the change to the stored settings and leave everything else as stored, including the encrypted keys. The active source profile mirrors the change, as PUT /config does.
    • They share one in-process write lock with PUT /config, so no save can read old settings and overwrite a newer one.
    • If the stored settings can't be read (for example a newer version's provider), they answer 409 and write nothing, instead of replacing the settings with defaults.
  • Shared: setCharacterVoiceAssignment moved to packages/shared, with input schemas for both routes. A voice name is capped at 200 characters, the most POST /speak accepts.
  • Client:
    • The Voice section saves through the new routes.
    • Picks are sent in the order they were made.
    • A failed save shows "Could not save the voice." and doesn't block later saves.
    • Typing during a slow save is still kept.
  • CHANGELOG: the Voice section entry now covers this (#6997, #7008).

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

Run by the agent (CI runs neither the route regression nor these e2e tests):

  • pnpm check, pnpm localization:check, tts-source-persistence and the new tts-voice-assignment-route regression pass.

  • The new regression covers:

    • only the character's row changes, and a newer speed survives;
    • stored keys stay byte for byte;
    • a blank voice drops the row;
    • invalid input gets 400;
    • a save racing PUT /config loses neither change;
    • a failed write doesn't jam later saves;
    • unreadable settings get 409;
    • the voice-mode route changes only the mode.

    Reverting each piece of the fix makes it fail. It passed 9/9 runs in a row.

  • On desktop Chromium, two ux-feedback-sweep e2e tests pass: "Character Voice …" (held saves, a failed save, then a new pick) and "Use a voice per character keeps Text to Speech settings saved elsewhere". Each fails on the old picker.

  • Two reviews ran. All confirmed findings are fixed, and the rejected ones have code-based reasons.

Still to verify by hand:

  • With Connections → Text to Speech open in a second tab, change the speed there, then type a voice in a character's Voice section in the first tab. After reloading, both changes are kept.
  • With one shared voice, press Use a voice per character in the Voice section. Voices switch to per character, and the other TTS settings stay as they were.

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)

CHANGELOG updated; no user docs change.

Summary by CodeRabbit

  • Bug Fixes
    • Saving or changing a character’s voice now preserves other Text to Speech settings, including speed changes made elsewhere.
    • Voice selections are saved in order. If a save fails, the last saved voice is restored and an error is shown; a later selection can still be saved.
  • Documentation
    • Clarified that enabling Use a voice per character changes only the character’s voice choice and leaves other Text to Speech settings unchanged.

🔄 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/7020 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/3/2026 **Status:** ✅ Merged **Merged:** 10/3/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/tts-voice-assignment-save` --- ### 📝 Commits (4) - [`7a655a1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7a655a1752d8d5d1ce359859e500e6faef725f90) fix(tts): save a Character Editor voice without undoing newer settings - [`a880ea4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a880ea4244803590f7823390cd179df4a3f71a8f) fix(tts): keep unreadable TTS settings and cover failed voice saves - [`4329bb8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4329bb8952bcd8bb46775d44161802715a7f8e45) Merge remote-tracking branch 'origin/staging' into fix/tts-voice-assignment-save - [`4ffd8ab`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4ffd8ab7bf8a17693981d9eaa09b3ec296cac983) fix(tts): switch to per-character voices without undoing newer settings ### 📊 Changes **9 files changed** (+445 additions, -65 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -1) 📝 `e2e/ux-feedback-sweep.e2e.ts` (+70 -6) 📝 `packages/client/src/components/characters/CharacterVoicePicker.tsx` (+20 -24) 📝 `packages/client/src/hooks/use-tts.ts` (+34 -7) 📝 `packages/client/src/lib/tts-dialogue.ts` (+6 -17) 📝 `packages/server/src/routes/tts.routes.ts` (+69 -8) 📝 `packages/shared/src/types/tts.ts` (+32 -0) 📝 `scripts/regressions/tts-source-persistence.regression.ts` (+1 -2) ➕ `scripts/regressions/tts-voice-assignment-route.regression.ts` (+212 -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 #7008 Follow-up to #6998 (found by CodeRabbit there). ## Why this change The Character Editor's new **Voice** section saved a pick by sending the whole Text to Speech configuration as the page last saw it. If another save landed meanwhile, the pick put the old values back. That other save could come from **Connections → Text to Speech**, another tab or another device, and could change the speed, the source or another character's voice. Its **Use a voice per character** button had the same problem. The Voice section hasn't shipped yet, so this fixes it before the release. ## What changed - **Server** (`tts.routes.ts`): - `PUT /api/tts/config/voice-assignment` changes only one character's voice row. - `PUT /api/tts/config/voice-mode` changes only the voice mode. - Both apply the change to the stored settings and leave everything else as stored, including the encrypted keys. The active source profile mirrors the change, as `PUT /config` does. - They share one in-process write lock with `PUT /config`, so no save can read old settings and overwrite a newer one. - If the stored settings can't be read (for example a newer version's provider), they answer 409 and write nothing, instead of replacing the settings with defaults. - **Shared:** `setCharacterVoiceAssignment` moved to `packages/shared`, with input schemas for both routes. A voice name is capped at 200 characters, the most `POST /speak` accepts. - **Client:** - The Voice section saves through the new routes. - Picks are sent in the order they were made. - A failed save shows "Could not save the voice." and doesn't block later saves. - Typing during a slow save is still kept. - **CHANGELOG:** the Voice section entry now covers this (#6997, #7008). ## 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 Run by the agent (CI runs neither the route regression nor these e2e tests): - `pnpm check`, `pnpm localization:check`, `tts-source-persistence` and the new `tts-voice-assignment-route` regression pass. - The new regression covers: - only the character's row changes, and a newer speed survives; - stored keys stay byte for byte; - a blank voice drops the row; - invalid input gets 400; - a save racing `PUT /config` loses neither change; - a failed write doesn't jam later saves; - unreadable settings get 409; - the voice-mode route changes only the mode. Reverting each piece of the fix makes it fail. It passed 9/9 runs in a row. - On desktop Chromium, two `ux-feedback-sweep` e2e tests pass: "Character Voice …" (held saves, a failed save, then a new pick) and "Use a voice per character keeps Text to Speech settings saved elsewhere". Each fails on the old picker. - Two reviews ran. All confirmed findings are fixed, and the rejected ones have code-based reasons. Still to verify by hand: - With **Connections → Text to Speech** open in a second tab, change the speed there, then type a voice in a character's **Voice** section in the first tab. After reloading, both changes are kept. - With one shared voice, press **Use a voice per character** in the Voice section. Voices switch to per character, and the other TTS settings stay as they were. ## 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) CHANGELOG updated; no user docs change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Saving or changing a character’s voice now preserves other Text to Speech settings, including speed changes made elsewhere. * Voice selections are saved in order. If a save fails, the last saved voice is restored and an error is shown; a later selection can still be saved. * **Documentation** * Clarified that enabling **Use a voice per character** changes only the character’s voice choice and leaves other Text to Speech settings unchanged. <!-- 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:19:44 +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#7433
No description provided.