Closed Bug 2010993 Opened 2 months ago Closed 2 months ago

Make Translations UI States Reactive to Changes in Feature Enabledness

Categories

(Firefox :: Translations, task, P1)

task

Tracking

()

VERIFIED FIXED
148 Branch
Tracking Status
firefox148 + verified
firefox149 --- verified

People

(Reporter: nordzilla, Assigned: nordzilla)

References

(Blocks 1 open bug)

Details

Attachments

(20 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Description

Prior to now, there was no official way in the UI to disable or enable the Translations feature. It was only available in about:config, which is not an officially user-facing API.

Now that we are going to support this, we need to ensure that we always react correctly to the feature becoming enabled or disabled.

This includes:

  • Ensuring all open instances of the about:translations page react accordingly, either enabling or disabling.
  • When the feature is disabled, we will need to hide the Translations button on any open tabs that have it present, and possibly ensure that restorePage is called when the tab becomes active again, if Translations was active on the page.
  • When the feature is enabled, we need to ensure that already-open tabs may need to run through the translations-offer logic.

This work needs to be completed before the AI Killswitch release, but is not critical to unblock progress on the Settings UI.

Depends on: 2009269
Blocks: 2005605
Target Milestone: --- → 148 Branch

This commit ensures that disabling the Translations feature will ensure
that the Translations Engine is destroyed. It also ensures that the engine
actor is fetched every time, rather than relying on the cached value, which
may no longer be valid when re-enabling the feature.

This commit ensures that the about:translations page reacts to the Translations
feature becoming disabled and enabled. When disabled, the page content should
hide itself. When re-enabled, the page content should re-show and continue to
work as normal.

This commit ensures that the Translate QuickAction is reactive to the
enabled state of the Translations feature, which may now become disabled
or re-enabled via the Settings UI.

This commit ensures that the SelectTranslations context menu item is reactive
to the Translations feature becoming disabled or re-enabled, which may now
occur in the Firefox Settings.

This commit ensures that the "Translate page..." Application Menu Item correctly
reacts to the Translations feature becoming enabled or disabled, which may now
occur from the main Settings UI.

Adding tracking flags for 148

This commit reworks our cached state from being per top chrome window
to being truly per tab. Now that the feature can be disabled and enabled
at runtime with multiple tabs open, there is more than just the current
context that we may need to store in order to behave correctly if the
feature becomes re-enabled with multiple tabs still open.

This commit ensures that the FullPage Translations functionality is able
to react to the Translations feature becoming enabled and disabled, including
managing the state of the Translations URL bar button across tabs, and handling
context from tabs that may have been disabled mid translation.

This commit adds 3 new telemetry metrics so that we can tell how frequently
the Translatiosn feature is being enabled, disabled, or reset from the settings,
especially compared to how often the global AI switch is being flipped.

Pushed by enordin@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/60b926db4079 https://hg.mozilla.org/integration/autoland/rev/7a80e16ce9ce Ensure TranslationsEngine is destroyed when disabling Translations r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/7dbe5906dfdb https://hg.mozilla.org/integration/autoland/rev/b366ef118d69 Make about:translations react to feature enabledness r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/d0e01653aba7 https://hg.mozilla.org/integration/autoland/rev/f6f4b5dc5f0c Make Translate QuickAction react to feature enabledness r=daleharvey,translations-reviewers,urlbar-reviewers,gregtatum,mak https://github.com/mozilla-firefox/firefox/commit/b1369094877a https://hg.mozilla.org/integration/autoland/rev/2b8df146544e Make SelectTranslations react to feature enabledness r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/28c1a0fa597a https://hg.mozilla.org/integration/autoland/rev/e6968aa3e79b Make AppMenu react to Translations feature enabledness r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/4276ace5a173 https://hg.mozilla.org/integration/autoland/rev/81b8e6689732 Rework StatePerTopChromeWindow to StatePerTab r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/c12ab13d7d25 https://hg.mozilla.org/integration/autoland/rev/6c09712822cf Make FullPage Translations react to feature enabledness r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/5ea4fa9b40c0 https://hg.mozilla.org/integration/autoland/rev/7b5cdf9bdc75 Add TranslationsFeature Telemetry r=translations-reviewers,gregtatum
Pushed by amarc@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/f3081be7b6d3 https://hg.mozilla.org/integration/autoland/rev/759dff34f2a0 Revert "Bug 2010993 - Add TranslationsFeature Telemetry r=translations-reviewers,gregtatum" for causing multiple bc failures
Flags: needinfo?(enordin)

re: Failure log -> ui-test

Translate extension doesn't seem to be offered at all looking at the android videos in the matrix associated with the run

This commit ensures that the test expectations on Android
reflect the new flow of the FullPage Translations language
state and detection logic.

Status: NEW → ASSIGNED

I believe that I've addressed all of the issues.

Try runs are looking green for the 3 failures mentioned in comment 12.

Queuing for relanding.

Flags: needinfo?(enordin)
Pushed by enordin@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/97239f8ed9c3 https://hg.mozilla.org/integration/autoland/rev/e89f154cdd54 Ensure TranslationsEngine is destroyed when disabling Translations r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/f78f5e861274 https://hg.mozilla.org/integration/autoland/rev/b76c96846ed3 Make about:translations react to feature enabledness r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/e97e9bb23240 https://hg.mozilla.org/integration/autoland/rev/e703fa6f5541 Make Translate QuickAction react to feature enabledness r=daleharvey,translations-reviewers,urlbar-reviewers,gregtatum,mak https://github.com/mozilla-firefox/firefox/commit/accc09b6ed83 https://hg.mozilla.org/integration/autoland/rev/c128c380c618 Make SelectTranslations react to feature enabledness r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/63d9a87bfefc https://hg.mozilla.org/integration/autoland/rev/ee946f7958a5 Make AppMenu react to Translations feature enabledness r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/cceadb3a8154 https://hg.mozilla.org/integration/autoland/rev/4e654220d7cf Rework StatePerTopChromeWindow to StatePerTab r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/1288d8c4183d https://hg.mozilla.org/integration/autoland/rev/0dced6f77beb Make FullPage Translations react to feature enabledness r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/45bd6451cfec https://hg.mozilla.org/integration/autoland/rev/2228c46fc529 Add TranslationsFeature Telemetry r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/fe1114298a60 https://hg.mozilla.org/integration/autoland/rev/5b25cb295eec Update Android Test Expectations r=ohall,geckoview-reviewers,translations-reviewers
Pushed by chorotan@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/726344b075e2 https://hg.mozilla.org/integration/autoland/rev/4fdfd1c2e093 Revert "Bug 2010993 - Update Android Test Expectations r=ohall,geckoview-reviewers,translations-reviewers" for causing bc failures on browser_preferences_usage.js

Backed out for causing bc failures on browser_preferences_usage.js
Backout link
Push with failures
Failure log(s)

Flags: needinfo?(enordin)

I requested that this be backed out (though it may have been regardless).

Opening new tabs is checking the Translations pref too many times.

I need to fix this before landing.

Flags: needinfo?(enordin)

This patch ensures that all access to the TranslationsParent
browsing context are guarded against the context being dead
at the time of access.

Attachment #9541007 - Attachment description: WIP: Bug 2010993 - Guard against dead context in TranslationsParent r=ohall! → Bug 2010993 - Guard against dead context in TranslationsParent r=ohall!
Pushed by enordin@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/6b36243e9701 https://hg.mozilla.org/integration/autoland/rev/c601cd62ea35 Ensure TranslationsEngine is destroyed when disabling Translations r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/674c7991f558 https://hg.mozilla.org/integration/autoland/rev/2d2f194c1de6 Make about:translations react to feature enabledness r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/dc03210a5536 https://hg.mozilla.org/integration/autoland/rev/ddab8d82789c Make Translate QuickAction react to feature enabledness r=daleharvey,translations-reviewers,urlbar-reviewers,gregtatum,mak https://github.com/mozilla-firefox/firefox/commit/f3f92ec1ce36 https://hg.mozilla.org/integration/autoland/rev/54a01d9519ba Make SelectTranslations react to feature enabledness r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/a428fda6c5dc https://hg.mozilla.org/integration/autoland/rev/a7239f47a85b Make AppMenu react to Translations feature enabledness r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/a2cfab1f1c49 https://hg.mozilla.org/integration/autoland/rev/9bb5351f7299 Rework StatePerTopChromeWindow to StatePerTab r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/4c2629d08c7f https://hg.mozilla.org/integration/autoland/rev/35b7db4fbcac Make FullPage Translations react to feature enabledness r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/602d222604be https://hg.mozilla.org/integration/autoland/rev/94866222a000 Add TranslationsFeature Telemetry r=translations-reviewers,gregtatum https://github.com/mozilla-firefox/firefox/commit/fdd2fcb75110 https://hg.mozilla.org/integration/autoland/rev/faff99735317 Update Android Test Expectations r=ohall,geckoview-reviewers,translations-reviewers https://github.com/mozilla-firefox/firefox/commit/609b4c5a07b4 https://hg.mozilla.org/integration/autoland/rev/b55ddd5197de Guard against dead context in TranslationsParent r=ohall,translations-reviewers

Third time's a charm. Queuing it up!

Verified as fixed in our latest Nightly 149.0a1 (2026-01-30).

QA Whiteboard: [qa-ver-needed-c149/b148]
QA Contact: rdoghi
Duplicate of this bug: 2012707

This commit ensures that disabling the Translations feature will ensure
that the Translations Engine is destroyed. It also ensures that the engine
actor is fetched every time, rather than relying on the cached value, which
may no longer be valid when re-enabling the feature.

Original Revision: https://phabricator.services.mozilla.com/D280367

Attachment #9541277 - Flags: approval-mozilla-beta?

This commit ensures that the about:translations page reacts to the Translations
feature becoming disabled and enabled. When disabled, the page content should
hide itself. When re-enabled, the page content should re-show and continue to
work as normal.

Original Revision: https://phabricator.services.mozilla.com/D280368

Attachment #9541278 - Flags: approval-mozilla-beta?

This commit ensures that the Translate QuickAction is reactive to the
enabled state of the Translations feature, which may now become disabled
or re-enabled via the Settings UI.

Original Revision: https://phabricator.services.mozilla.com/D280369

Attachment #9541279 - Flags: approval-mozilla-beta?

This commit ensures that the SelectTranslations context menu item is reactive
to the Translations feature becoming disabled or re-enabled, which may now
occur in the Firefox Settings.

Original Revision: https://phabricator.services.mozilla.com/D280370

Attachment #9541280 - Flags: approval-mozilla-beta?

This commit ensures that the "Translate page..." Application Menu Item correctly
reacts to the Translations feature becoming enabled or disabled, which may now
occur from the main Settings UI.

Original Revision: https://phabricator.services.mozilla.com/D280371

Attachment #9541281 - Flags: approval-mozilla-beta?

This commit reworks our cached state from being per top chrome window
to being truly per tab. Now that the feature can be disabled and enabled
at runtime with multiple tabs open, there is more than just the current
context that we may need to store in order to behave correctly if the
feature becomes re-enabled with multiple tabs still open.

Original Revision: https://phabricator.services.mozilla.com/D280387

Attachment #9541283 - Flags: approval-mozilla-beta?

This commit ensures that the FullPage Translations functionality is able
to react to the Translations feature becoming enabled and disabled, including
managing the state of the Translations URL bar button across tabs, and handling
context from tabs that may have been disabled mid translation.

Original Revision: https://phabricator.services.mozilla.com/D280388

Attachment #9541284 - Flags: approval-mozilla-beta?

This commit adds 3 new telemetry metrics so that we can tell how frequently
the Translatiosn feature is being enabled, disabled, or reset from the settings,
especially compared to how often the global AI switch is being flipped.

Original Revision: https://phabricator.services.mozilla.com/D280542

Attachment #9541285 - Flags: approval-mozilla-beta?

This commit ensures that the test expectations on Android
reflect the new flow of the FullPage Translations language
state and detection logic.

Original Revision: https://phabricator.services.mozilla.com/D280872

Attachment #9541286 - Flags: approval-mozilla-beta?

firefox-beta Uplift Approval Request

  • User impact if declined: This patch stack is required in order for the Translations UI surfaces to be compatible with the AI Killswitch.
  • Code covered by automated testing: yes
  • Fix verified in Nightly: yes
  • Needs manual QE test: yes
  • Steps to reproduce for manual QE testing: The QE representative for this project is aware of the steps and is already testing.
  • Risk associated with taking this patch: medium
  • Explanation of risk level: I'm marking this as medium risk because it affects the entire set of Translations features from the about:translations page, to selected-text translation, to full-page translation.

However, I've added 22 new automated test cases to CI, in addition to doing a lot of manual testing myself.

That being said, it's still risky to uplift these kinds of changes in functionality. I feel strongly that there are no major issues.

My biggest fear is regressing something on Android, which is not the target of this work, but shares infrastructure with this code.

However, I've asked for review and testing from Android developers, in addition to testing it myself. I will continue to test even more aggressively once these changes hit the Google Play Store.

I feel confident that anything minor that may come up can be fixed within the next 24 days to release.

  • String changes made/needed: None
  • Is Android affected?: yes
Attachment #9541287 - Flags: approval-mozilla-beta?
Flags: qe-verify+

This patch ensures that all access to the TranslationsParent
browsing context are guarded against the context being dead
at the time of access.

Original Revision: https://phabricator.services.mozilla.com/D281029

Attachment #9541287 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9541286 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9541285 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9541284 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9541283 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9541281 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9541280 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9541279 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9541278 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9541277 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

This issue is Verified as fixed in our latest Beta 148.0b10 ID: 20260130190749

Disabling this feature from the AI controls page will remove this feature from the Following scenarios:

The URL button will disappear while translating a page or after the page is already translated.
The URL button will disappear from any tab where it was displayed even on multiple tabs or windows.
The Translate Quick Action is also hidden when we type "translate" in the URL bar (first we have to enabled it in Beta from browser.translations.quickAction.enabled - true)
The about:translations page is blank.
The "Translate Page..." option from the Hamburger menu is no longer displayed.
The "Translate selection to .." from the context menu is no longer displayed.

As far as Telemetry goes, Ive only found these 3 besides the ones that trigger when we actually use the feature:
translations.feature.disable
translations.feature.reset
aiControlTranslationsSelect

but I'm not sure which ones have been added with this patch.

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-ver-needed-c149/b148] → [qa-ver-done-c149/b148][uplift]
Flags: qe-verify+

(In reply to Rares Doghi, Desktop QA from comment #38)

As far as Telemetry goes, Ive only found these 3 besides the ones that trigger when we actually use the feature:
translations.feature.disable
translations.feature.reset
aiControlTranslationsSelect

The new telemetry events added by this patch are the following:

  • translations.feature.reset
  • translations.feature.disable
  • translations.feature.enable

Due to the way the settings are implemented for Translations, I don't think enable can ever be called in the current state of the code, since Translations only has "Available" and "Blocked" in its menu list.

aiControlTranslationSelect existed prior to this patch.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: