Skip to content

Commit 9b8af1f

Browse files
committed
Force delete broken TTS profiles
1 parent 87db3eb commit 9b8af1f

6 files changed

Lines changed: 392 additions & 332 deletions

File tree

assets/toolbox/text-to-speech/js/index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ const NEW_ROW_KEY = "__new__";
8080
const DEFAULT_TTS_PROFILE_ID = "tts-profile";
8181
const DEFAULT_TTS_EMOTION_ID = "calm";
8282
const SIGN_IN_ROUTE = "account/sign-in.html";
83+
const RETIRED_TTS_PROFILE_PARENT_NAMES = Object.freeze([
84+
"Default Balanced Profile",
85+
"Hero",
86+
"Merchant",
87+
"Neutral",
88+
"Robot",
89+
]);
8390

8491
const TTS_PROFILE_GENDER_OPTIONS = Object.freeze([
8592
Object.freeze({ label: "Neutral", value: "neutral" }),
@@ -170,6 +177,11 @@ function labelForOption(options, value, fallback = "") {
170177
return options.find((option) => String(option.value) === String(value))?.label || fallback || String(value || "");
171178
}
172179

180+
function isRetiredTextToSpeechProfileName(value) {
181+
const normalized = String(value || "").trim().toLowerCase();
182+
return RETIRED_TTS_PROFILE_PARENT_NAMES.some((name) => name.toLowerCase() === normalized);
183+
}
184+
173185
function createTextToSpeechProfileEmotion({
174186
active = true,
175187
displayOrder = 0,
@@ -879,7 +891,9 @@ function initializeTextToSpeechTool(root = document, { engine = new TextToSpeech
879891

880892
function loadProfilesFromApi() {
881893
const payload = listTtsProfiles();
882-
state.profiles = (payload.ttsProfiles || []).map((profile) => createTextToSpeechProfileFromApi(profile));
894+
state.profiles = (payload.ttsProfiles || [])
895+
.filter((profile) => !isRetiredTextToSpeechProfileName(profile?.name))
896+
.map((profile) => createTextToSpeechProfileFromApi(profile));
883897
if (state.selectedProfileId && !state.profiles.some((profile) => profile.id === state.selectedProfileId)) {
884898
state.selectedProfileId = "";
885899
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# PR_26177_BRAVO_009-force-delete-broken-tts-profiles
2+
3+
## Branch Validation
4+
- PASS: Initial branch was `bravo/26177-text-to-speech`.
5+
- PASS: Work stayed on the active Bravo branch; main was not checked out.
6+
- PASS: No `start_of_day` folders were modified.
7+
8+
## Scope Summary
9+
- Strengthened server-side setup cleanup for hard-deleted broken TTS parent profiles.
10+
- Added a setup/API validation guard that fails if any retired parent profile name survives cleanup.
11+
- Forced API profile reads to rerun retired-name cleanup before returning TTS Profiles.
12+
- Rejected creator/API saves that attempt to recreate retired TTS Profile names.
13+
- Added a TTS page display guard so retired profile names are filtered from UI rendering if a bad payload ever reaches the browser.
14+
- Preserved guest save redirect behavior to `account/sign-in.html`.
15+
16+
## Required Name Absence
17+
- PASS: `Default Balanced Profile` is deleted from persisted TTS profiles and absent from API output after setup.
18+
- PASS: `Hero` is deleted from persisted TTS profiles and absent from API output after setup.
19+
- PASS: `Merchant` is deleted from persisted TTS profiles and absent from API output after setup.
20+
- PASS: `Neutral` is deleted from persisted TTS profiles and absent from API output after setup.
21+
- PASS: `Robot` is deleted from persisted TTS profiles and absent from API output after setup.
22+
23+
## Requirement Checklist
24+
- PASS: Existing Local DB TTS profile records are deleted by exact retired name during Messages service setup/read cleanup.
25+
- PASS: Child TTS profile emotion settings for those parent profiles are deleted.
26+
- PASS: Message, sentence, and event-action references pointing at those parent profiles are deleted with the broken profile data.
27+
- PASS: API list responses cannot return those names; cleanup reruns before list output and validation throws if any remain.
28+
- PASS: TTS UI filters those names before rendering profile rows.
29+
- PASS: Validation fails if a retired name remains after setup cleanup.
30+
- PASS: Tests assert the names are absent from API output and TTS page rendering.
31+
- PASS: No fallback profiles or placeholder child rows were added.
32+
- PASS: Guest save redirect behavior is unchanged.
33+
- PASS: No governance changes or unrelated cleanup.
34+
35+
## File Inventory
36+
- `assets/toolbox/text-to-speech/js/index.js`
37+
- `src/dev-runtime/messages/messages-postgres-service.mjs`
38+
- `tests/dev-runtime/MessagesPublishValidation.test.mjs`
39+
- `docs_build/dev/reports/PR_26177_BRAVO_009-force-delete-broken-tts-profiles.md`
40+
- `docs_build/dev/reports/codex_changed_files.txt`
41+
- `docs_build/dev/reports/codex_review.diff`
42+
43+
## DB/API Inventory
44+
- `messages_tts_profiles`: retired parent rows are force-deleted by name.
45+
- `messages_tts_profile_emotion_settings`: child settings for retired parents and orphaned settings are deleted.
46+
- `messages_records`, `messages_segments`, `messages_event_actions`: stale references to deleted retired profiles are deleted to avoid orphaned DB references.
47+
- `GET /api/messages/tts-profiles`: reruns cleanup and validation before returning profile output.
48+
- `POST/PATCH /api/messages/tts-profiles`: rejects retired profile names instead of recreating them.
49+
50+
## Test Inventory
51+
- Updated `Messages seed cleanup deletes retired parent TTS profiles and orphaned settings` to assert each retired name is absent from persisted records and API output.
52+
- Added `Messages seed setup fails if retired TTS profile validation still finds broken names`.
53+
- Updated empty-save coverage to assert retired names cannot be recreated through `createTtsProfile`.
54+
- Existing TTS Playwright spec contains page-rendering absence assertions for the retired names.
55+
56+
## Validation Lane Report
57+
- PASS: Explicit search ran for `Default Balanced Profile|Hero|Merchant|Neutral|Robot`; remaining hits are cleanup constants, seed notes, negative assertions, and voice-gender terminology only.
58+
- PASS: `node --check src/dev-runtime/messages/messages-postgres-service.mjs`
59+
- PASS: `node --check assets/toolbox/text-to-speech/js/index.js`
60+
- PASS: `node --check tests/dev-runtime/MessagesPublishValidation.test.mjs`
61+
- PASS: `node --check tests/playwright/tools/TextToSpeechFunctional.spec.mjs`
62+
- PASS: `node --test tests/dev-runtime/MessagesPublishValidation.test.mjs` (9/9)
63+
- PASS: `node --test --test-name-pattern "Messages Local API seeds" tests/dev-runtime/DbSeedIntegrity.test.mjs` (1/1)
64+
- PASS: `node --test tests/tools/Text2SpeechShell.test.mjs` (6/6)
65+
- BLOCKED: `npx playwright test tests/playwright/tools/TextToSpeechFunctional.spec.mjs tests/playwright/tools/MessagesTool.spec.mjs tests/playwright/tools/EventsTool.spec.mjs --project=playwright`
66+
- Browser launch failed before page code ran because Chromium is missing at `C:\Users\davidq\AppData\Local\ms-playwright\chromium-1217\chrome-win64\chrome.exe`.
67+
68+
## Manual Validation Notes
69+
- Reviewed server setup/read cleanup paths and TTS page profile loading.
70+
- Confirmed no fallback profile or placeholder child-emotion creation was added.
71+
- Browser/manual UI validation remains blocked by the missing local Playwright Chromium install.
72+
73+
## Known Issues
74+
- Playwright browser validation cannot complete in this environment until the matching Chromium browser is installed.
75+
76+
## Repo-Structured ZIP
77+
- `tmp/PR_26177_BRAVO_009-force-delete-broken-tts-profiles_delta.zip`
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
assets/toolbox/text-to-speech/js/index.js
2-
docs_build/database/seed/messages.json
32
docs_build/dev/reports/codex_changed_files.txt
43
docs_build/dev/reports/codex_review.diff
5-
docs_build/dev/reports/PR_26177_BRAVO_008-delete-empty-tts-profile-parents.md
4+
docs_build/dev/reports/PR_26177_BRAVO_009-force-delete-broken-tts-profiles.md
65
src/dev-runtime/messages/messages-postgres-service.mjs
76
tests/dev-runtime/MessagesPublishValidation.test.mjs
8-
tests/playwright/tools/MessagesTool.spec.mjs
9-
tests/playwright/tools/TextToSpeechFunctional.spec.mjs

0 commit comments

Comments
 (0)