Skip to content

fix: Auto-translate not enabled for users who join rooms before setting a language preference#40992

Draft
juliajforesti wants to merge 5 commits into
developfrom
fix/auto-translate
Draft

fix: Auto-translate not enabled for users who join rooms before setting a language preference#40992
juliajforesti wants to merge 5 commits into
developfrom
fix/auto-translate

Conversation

@juliajforesti

@juliajforesti juliajforesti commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

CORE-2297

Proposed changes (including videos or screenshots)

When AutoTranslate_AutoEnableOnJoinRoom is 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_AutoEnableOnJoinRoom enabled, since "Default" is the out-of-the-box language setting.

Solution:
Added a new enableAutoTranslateByUserId method on the Subscriptions model that targets subscriptions where autoTranslate is not yet set, and calls it in saveUserPreferences when a user sets a valid non-default language that differs from the workspace default — mirroring the same conditions used in getSubscriptionAutotranslateDefaultConfig.

The existing updateAllAutoTranslateLanguagesByUserId call 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 set

Steps to test or reproduce

  1. Enable AutoTranslate_AutoEnableOnJoinRoom in admin settings
  2. Create a user with language set to Default
  3. Add the user to a channel
  4. Change the user's language preference to Spanish
  5. Have another user send a message in the channel

Expected: 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.

Review in cubic

@juliajforesti juliajforesti added this to the 8.6.0 milestone Jun 17, 2026
@dionisio-bot

dionisio-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ad50ea4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@rocket.chat/model-typings Patch
@rocket.chat/models Patch
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch

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

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cb8007ab-f9f6-46cd-8d5e-f18f831d898c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.11%. Comparing base (236eef2) to head (dab2370).

Additional details and impacted files

Impacted file tree graph

@@             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     
Flag Coverage Δ
e2e 59.35% <ø> (+0.04%) ⬆️
e2e-api 46.21% <100.00%> (-0.86%) ⬇️
unit 70.03% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

}

const workspaceLanguage = rcSettings.get('Language');
if (language !== 'default' && language !== workspaceLanguage) {

@sampaiodiego sampaiodiego Jun 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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' }
  • user set language back to 'default'
    • nothing happens, subscription keeps 'pt-br'

@juliajforesti juliajforesti Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, this is yet another gap in the behavior and I'll include this case here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants