[codex] PR_26171_067 tts profile emotion table foundation#21
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cbedbf392f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (state.profiles.some((candidate) => candidate.id !== profile.id && candidate.name.toLowerCase() === profile.name.toLowerCase())) { | ||
| errors.push("Profile Name must be unique."); | ||
| } |
There was a problem hiding this comment.
When adding a profile whose display name normalizes to an existing slug but is not an exact case-insensitive name match (for example Man/Profile 1 alongside Man Profile 1), createTextToSpeechProfile gives both rows the same id while this validation still passes. Because edit/select/delete are keyed by profile.id, those duplicate rows become ambiguous and delete will remove every matching id, so the UI can corrupt more than the intended profile.
Useful? React with 👍 / 👎.
| function ensureDefaultProfiles() { | ||
| if (state.profiles.length) { | ||
| return; | ||
| } | ||
| state.profiles = createDefaultTextToSpeechProfiles(state.voiceOptions); |
There was a problem hiding this comment.
Rebind default profiles after voices load
In browsers where speechSynthesis.getVoices() is initially empty and voices arrive via voiceschanged, this early return leaves the default profiles permanently seeded with blank voice values and Default browser voice names. The callback later only re-renders rows, so the Message Studio profile options never pick up the available browser voices even though createDefaultTextToSpeechProfiles(state.voiceOptions) is designed to bind them.
Useful? React with 👍 / 👎.
| return createTextToSpeechProfileEmotion({ | ||
| active: editorChecked(row, "[data-tts-emotion-active]"), | ||
| emotion: editorValue(row, "[data-tts-emotion-name]"), | ||
| id: key === NEW_ROW_KEY ? "" : key, |
There was a problem hiding this comment.
Regenerate emotion ids when the emotion changes
When editing an existing emotion row to a different emotion, this preserves the old row id while changing emotion.emotion. After that, adding a new setting for the original emotion is accepted by the uniqueness check, leaving two rows with the same id; because edit/delete actions are keyed by that id, a later delete can remove more than the intended emotion setting.
Useful? React with 👍 / 👎.
| .filter((profile) => profile?.active !== false) | ||
| .map((profile) => ({ | ||
| active: true, | ||
| emotionSettings: Array.isArray(profile.emotions) | ||
| ? profile.emotions.filter((emotion) => emotion.active !== false).map((emotion) => ({ |
There was a problem hiding this comment.
Keep in-use profiles and emotions visible to Message Studio
When a row with messageStudioUsageCount or messagePartsUsageCount is edited and its Active checkbox is cleared, deletion is still blocked but this export removes the referenced profile or emotion from messageStudioOptions. For example, deactivating the default balanced profile or its neutral emotion makes existing Message Studio/Message Parts references lose their option without actually deleting the row.
Useful? React with 👍 / 👎.
Summary
Validation
node --check toolbox\text-to-speech\text2speech.jsnode --check tests\playwright\tools\TextToSpeechFunctional.spec.mjsnode --check tests\tools\Text2SpeechShell.test.mjstoolbox/text-to-speech/index.htmlnode --test tests/tools/Text2SpeechShell.test.mjsnpx playwright test tests/playwright/tools/TextToSpeechFunctional.spec.mjs --project=playwright --workers=1 --reporter=listnpx playwright test tests/playwright/tools/MessagesTool.spec.mjs --project=playwright --workers=1 --reporter=listnpm run test:workspace-v2