fix: Auto-translate not enabled for users who join rooms before setting a language preference#40992
fix: Auto-translate not enabled for users who join rooms before setting a language preference#40992juliajforesti wants to merge 5 commits into
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
🦋 Changeset detectedLatest commit: ad50ea4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #40992 +/- ##
===========================================
- Coverage 70.14% 70.11% -0.03%
===========================================
Files 3358 3358
Lines 129569 129574 +5
Branches 22457 22472 +15
===========================================
- Hits 90883 90851 -32
- Misses 35380 35408 +28
- Partials 3306 3315 +9
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
| } | ||
|
|
||
| const workspaceLanguage = rcSettings.get('Language'); | ||
| if (language !== 'default' && language !== workspaceLanguage) { |
There was a problem hiding this comment.
what happens if the user change the language back to default or to the workspace's default language? will they get the wrong translation? like:
- user join channel
- user set language to pt-br
- update subscription:
{ autotranslate: true, language: 'pt-br' }
- update subscription:
- user set language back to 'default'
- nothing happens, subscription keeps 'pt-br'
There was a problem hiding this comment.
As discussed, this is yet another gap in the behavior and I'll include this case here
CORE-2297
Proposed changes (including videos or screenshots)
When
AutoTranslate_AutoEnableOnJoinRoomis enabled, auto-translate is supposed to be automatically configured for users whose language preference differs from the workspace default. However, this only worked at room join time — users who joined rooms before setting a language preference (including users with the default "Default" setting) ended up with subscriptions that never had auto-translate enabled.Later, when those users set a language preference, the existing sync logic (updateAllAutoTranslateLanguagesByUserId) only updated the autoTranslateLanguage field on subscriptions that already had autoTranslate: true. Since their subscriptions were created without it, nothing changed and auto-translate never activated.
This affects virtually every new user on workspaces with
AutoTranslate_AutoEnableOnJoinRoomenabled, since "Default" is the out-of-the-box language setting.Solution:
Added a new
enableAutoTranslateByUserIdmethod on the Subscriptions model that targets subscriptions where autoTranslate is not yet set, and calls it insaveUserPreferenceswhen a user sets a valid non-default language that differs from the workspace default — mirroring the same conditions used ingetSubscriptionAutotranslateDefaultConfig.The existing
updateAllAutoTranslateLanguagesByUserIdcall is preserved to handle users who already have auto-translate enabled and are just changing their language.Issue(s)
Root Cause
Two separate features introduced in different PRs left a gap:
#30370 introduced
getSubscriptionAutotranslateDefaultConfig— auto-enables auto-translate at room join time for users with a non-default language#31417 introduced the language preference sync in saveUserPreferences — but only updated the language on subscriptions that already had
autoTranslate: true, never enabling it on subscriptions that were created before the user had a language setSteps to test or reproduce
AutoTranslate_AutoEnableOnJoinRoomin admin settingsExpected: messages appear translated to Spanish
Actual: messages appear in original language — auto-translate was never enabled on the subscription
Further comments
Users who change their language preference from Default (or any previous value) to a specific language will have auto-translate immediately enabled across all their existing room subscriptions, without needing to leave and rejoin rooms.
If user sets their language to Default, they're saying "use the workspace/browser default" — auto-translate shouldn't be forced on for them.
Note: A migration is recommended to retroactively fix existing users already in the broken state — users who currently have a language preference set but joined rooms before setting it. The fix alone only applies going forward (on the next language preference change), and for users who change the language preference from now on.