From 08161fbc6fdb56e8308cde6c32154225d867d0ee Mon Sep 17 00:00:00 2001 From: abose Date: Fri, 28 Aug 2026 09:55:07 +0530 Subject: [PATCH] refactor: drop the Trusted Web Activity branch from the sunset dialog Installed app users were shown "Update the app" pointing at the Play Store instead of the new site, on the strength of a document.referrer check. That check cannot be relied on. The android-app referrer only survives the first navigation of a launch, and this app reloads itself for cache upgrades and after a migration, so from the second boot onward a TWA user is indistinguishable from a browser user and silently falls back to the browser path anyway. The alternatives do not help. display-mode standalone survives reloads but cannot separate a TWA from an installed PWA, and telling a PWA user to update an app they do not have is worse than saying nothing. The user agent carries no marker at all, since a TWA runs on Custom Tabs rather than a WebView. So everyone now gets the same button and a plain navigation. The shipped APK points at web.phcode.dev and lists both origins in its asset statements, so that navigation stays chrome-less for app users. Until that build reaches a device the old one shows a URL bar there, which is cosmetic and self correcting once Play updates the app. Removes the referrer check, the package and store URL constants, the update button and its handler, the twa metrics variant and three strings. The reasoning is left as a comment so the next reader does not reintroduce a check that does not work. --- .../MigrateAssist/constants.js | 19 ---------- .../MigrateAssist/sunset-dialog.js | 35 ++++++------------- src/nls/root/strings.js | 3 -- 3 files changed, 10 insertions(+), 47 deletions(-) diff --git a/src/extensionsIntegrated/MigrateAssist/constants.js b/src/extensionsIntegrated/MigrateAssist/constants.js index 5b3073eef3..606bbc2329 100644 --- a/src/extensionsIntegrated/MigrateAssist/constants.js +++ b/src/extensionsIntegrated/MigrateAssist/constants.js @@ -57,14 +57,6 @@ define(function (require, exports, module) { */ const SUNSET_DATE = Date.UTC(2026, 8, 1); - /** - * Android/ChromeOS Trusted Web Activity that wraps the legacy origin. Users launched from this - * package need an app update rather than a browser navigation, see sunset-dialog.js. - */ - const TWA_PACKAGE_ID = "prod.phcode.twa"; - const TWA_REFERRER_PREFIX = `android-app://${TWA_PACKAGE_ID}`; - const TWA_STORE_URL = `https://play.google.com/store/apps/details?id=${TWA_PACKAGE_ID}`; - /** * PhStore key recording that the migration already ran. Once set, the automatic path never runs * again and the user has to ask for it from the Help menu. @@ -182,15 +174,6 @@ define(function (require, exports, module) { return !(Phoenix.browser.desktop.isSafari || Phoenix.browser.mobile.isIos); } - /** - * True when the app was launched from our own Trusted Web Activity. document.referrer only - * reflects the initial navigation, so callers should read this once at boot and cache it. - * @return {boolean} - */ - function isTWALaunch() { - return (document.referrer || "").startsWith(TWA_REFERRER_PREFIX); - } - /** * Whole days left before the legacy origin is retired, floored at 0. * @param {number} [now] current time in ms, for tests @@ -215,7 +198,6 @@ define(function (require, exports, module) { exports.NEW_DOMAIN_NAME = NEW_DOMAIN_NAME; exports.SUNSET_DATE = SUNSET_DATE; - exports.TWA_STORE_URL = TWA_STORE_URL; exports.MIGRATION_DONE_KEY = MIGRATION_DONE_KEY; exports.MIGRATION_ATTEMPTS_KEY = MIGRATION_ATTEMPTS_KEY; exports.MAX_AUTO_ATTEMPTS = MAX_AUTO_ATTEMPTS; @@ -226,7 +208,6 @@ define(function (require, exports, module) { exports.isLegacyOrigin = isLegacyOrigin; exports.isNewOrigin = isNewOrigin; exports.isMigrationSupportedBrowser = isMigrationSupportedBrowser; - exports.isTWALaunch = isTWALaunch; exports.daysToSunset = daysToSunset; exports.isPastSunset = isPastSunset; }); diff --git a/src/extensionsIntegrated/MigrateAssist/sunset-dialog.js b/src/extensionsIntegrated/MigrateAssist/sunset-dialog.js index 7baf156d7a..d599cd61f4 100644 --- a/src/extensionsIntegrated/MigrateAssist/sunset-dialog.js +++ b/src/extensionsIntegrated/MigrateAssist/sunset-dialog.js @@ -40,12 +40,15 @@ define(function (require, exports, module) { Constants = require("./constants"); const BTN_GO_NEW_SITE = "goNewSite", - BTN_UPDATE_APP = "updateApp", BTN_STAY = "stay"; - // document.referrer only reflects the navigation that opened this document, so read it once - // before anything can navigate and hold on to the answer. - const isTWA = Constants.isTWALaunch(); + // There is deliberately no Trusted Web Activity branch. document.referrer is the documented way + // to spot a TWA launch, but it only survives the first navigation, and this app reloads itself + // for cache upgrades and after a migration, so a TWA user looks like a browser user from the + // second boot onward. display-mode: standalone survives but cannot tell a TWA from an installed + // PWA, and telling a PWA user to update an app they do not have is worse than saying nothing. + // Installed app users are therefore sent to the new site like everyone else; the shipped APK + // points at web.phcode.dev and trusts it, so that navigation stays chrome-less. function _buildMessage() { const paragraphs = []; @@ -62,10 +65,6 @@ define(function (require, exports, module) { if (!Constants.isMigrationSupportedBrowser()) { paragraphs.push(Strings.MIGRATE_MANUAL_DOWNLOAD_NOTE); - } else if (isTWA) { - paragraphs.push(Strings.MIGRATE_TWA_UPDATE_NOTE); - paragraphs.push(StringUtils.format(Strings.MIGRATE_TWA_BROWSER_LINK, - Constants.getNewOrigin(), Constants.NEW_DOMAIN_NAME)); } else { paragraphs.push(StringUtils.format(Strings.MIGRATE_DATA_SAFE_NOTE, Constants.NEW_DOMAIN_NAME)); } @@ -74,24 +73,13 @@ define(function (require, exports, module) { } function _buildButtons() { - // "Stay here" is a real choice, not a nag dismiss. On managed ChromeOS fleets the Play Store - // can be blocked outright, so the update button may be a dead end through no fault of the - // user, and the app has to keep working for them. + // "Stay here" is a real choice rather than a nag dismiss. Some installs, managed ChromeOS + // fleets in particular, may not be able to move on the user's own schedule. const stayButton = { className: Dialogs.DIALOG_BTN_CLASS_NORMAL, id: BTN_STAY, text: Strings.MIGRATE_STAY_HERE }; - if (isTWA) { - return [ - stayButton, - { - className: Dialogs.DIALOG_BTN_CLASS_PRIMARY, - id: BTN_UPDATE_APP, - text: Strings.MIGRATE_UPDATE_APP - } - ]; - } return [ stayButton, { @@ -107,7 +95,7 @@ define(function (require, exports, module) { * so the user is reminded again next time rather than being able to silence it permanently. */ function show() { - const variant = !Constants.isMigrationSupportedBrowser() ? "safari" : (isTWA ? "twa" : "web"); + const variant = Constants.isMigrationSupportedBrowser() ? "web" : "safari"; Metrics.countEvent(Metrics.EVENT_TYPE.PLATFORM, "migrateAssist", `sunsetShown.${variant}`); Dialogs.showModalDialog( @@ -119,9 +107,6 @@ define(function (require, exports, module) { if (buttonId === BTN_GO_NEW_SITE) { Metrics.countEvent(Metrics.EVENT_TYPE.PLATFORM, "migrateAssist", "sunsetGoNewSite"); window.location = Constants.getNewOrigin(); - } else if (buttonId === BTN_UPDATE_APP) { - Metrics.countEvent(Metrics.EVENT_TYPE.PLATFORM, "migrateAssist", "sunsetUpdateApp"); - window.open(Constants.TWA_STORE_URL, "_blank", "noopener"); } else { Metrics.countEvent(Metrics.EVENT_TYPE.PLATFORM, "migrateAssist", `sunsetStay.${variant}`); } diff --git a/src/nls/root/strings.js b/src/nls/root/strings.js index 53c37dc222..29df45b94f 100644 --- a/src/nls/root/strings.js +++ b/src/nls/root/strings.js @@ -2929,10 +2929,7 @@ define({ "MIGRATE_SUNSET_COUNTDOWN_ONE": "You have {0} day left before {1} stops working.", "MIGRATE_DATA_SAFE_NOTE": "Your projects, settings and extensions will be copied over for you the first time you open {0}. Nothing is deleted from this site.", "MIGRATE_MANUAL_DOWNLOAD_NOTE": "Automatic transfer is not available in this browser. If you have projects saved here, please download them before the date above so you can open them again on the new site.", - "MIGRATE_TWA_UPDATE_NOTE": "Please update the app when you can. Nothing stops working today, and you can keep using this version in the meantime.", - "MIGRATE_TWA_BROWSER_LINK": "If you cannot update right now, you can also continue in a browser at {1}.", "MIGRATE_GO_TO_NEW_SITE": "Take me to the new site", - "MIGRATE_UPDATE_APP": "Update the app", "MIGRATE_STAY_HERE": "Stay here", "MIGRATE_PROGRESS_TITLE": "Bringing your data over", "MIGRATE_PROGRESS_STATUS": "{0} of {1} files copied",