Skip to content

Commit 4f97f50

Browse files
committed
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.
1 parent 57fbdb7 commit 4f97f50

3 files changed

Lines changed: 10 additions & 47 deletions

File tree

src/extensionsIntegrated/MigrateAssist/constants.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@ define(function (require, exports, module) {
5757
*/
5858
const SUNSET_DATE = Date.UTC(2026, 8, 1);
5959

60-
/**
61-
* Android/ChromeOS Trusted Web Activity that wraps the legacy origin. Users launched from this
62-
* package need an app update rather than a browser navigation, see sunset-dialog.js.
63-
*/
64-
const TWA_PACKAGE_ID = "prod.phcode.twa";
65-
const TWA_REFERRER_PREFIX = `android-app://${TWA_PACKAGE_ID}`;
66-
const TWA_STORE_URL = `https://play.google.com/store/apps/details?id=${TWA_PACKAGE_ID}`;
67-
6860
/**
6961
* PhStore key recording that the migration already ran. Once set, the automatic path never runs
7062
* again and the user has to ask for it from the Help menu.
@@ -182,15 +174,6 @@ define(function (require, exports, module) {
182174
return !(Phoenix.browser.desktop.isSafari || Phoenix.browser.mobile.isIos);
183175
}
184176

185-
/**
186-
* True when the app was launched from our own Trusted Web Activity. document.referrer only
187-
* reflects the initial navigation, so callers should read this once at boot and cache it.
188-
* @return {boolean}
189-
*/
190-
function isTWALaunch() {
191-
return (document.referrer || "").startsWith(TWA_REFERRER_PREFIX);
192-
}
193-
194177
/**
195178
* Whole days left before the legacy origin is retired, floored at 0.
196179
* @param {number} [now] current time in ms, for tests
@@ -215,7 +198,6 @@ define(function (require, exports, module) {
215198

216199
exports.NEW_DOMAIN_NAME = NEW_DOMAIN_NAME;
217200
exports.SUNSET_DATE = SUNSET_DATE;
218-
exports.TWA_STORE_URL = TWA_STORE_URL;
219201
exports.MIGRATION_DONE_KEY = MIGRATION_DONE_KEY;
220202
exports.MIGRATION_ATTEMPTS_KEY = MIGRATION_ATTEMPTS_KEY;
221203
exports.MAX_AUTO_ATTEMPTS = MAX_AUTO_ATTEMPTS;
@@ -226,7 +208,6 @@ define(function (require, exports, module) {
226208
exports.isLegacyOrigin = isLegacyOrigin;
227209
exports.isNewOrigin = isNewOrigin;
228210
exports.isMigrationSupportedBrowser = isMigrationSupportedBrowser;
229-
exports.isTWALaunch = isTWALaunch;
230211
exports.daysToSunset = daysToSunset;
231212
exports.isPastSunset = isPastSunset;
232213
});

src/extensionsIntegrated/MigrateAssist/sunset-dialog.js

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ define(function (require, exports, module) {
4040
Constants = require("./constants");
4141

4242
const BTN_GO_NEW_SITE = "goNewSite",
43-
BTN_UPDATE_APP = "updateApp",
4443
BTN_STAY = "stay";
4544

46-
// document.referrer only reflects the navigation that opened this document, so read it once
47-
// before anything can navigate and hold on to the answer.
48-
const isTWA = Constants.isTWALaunch();
45+
// There is deliberately no Trusted Web Activity branch. document.referrer is the documented way
46+
// to spot a TWA launch, but it only survives the first navigation, and this app reloads itself
47+
// for cache upgrades and after a migration, so a TWA user looks like a browser user from the
48+
// second boot onward. display-mode: standalone survives but cannot tell a TWA from an installed
49+
// PWA, and telling a PWA user to update an app they do not have is worse than saying nothing.
50+
// Installed app users are therefore sent to the new site like everyone else; the shipped APK
51+
// points at web.phcode.dev and trusts it, so that navigation stays chrome-less.
4952

5053
function _buildMessage() {
5154
const paragraphs = [];
@@ -62,10 +65,6 @@ define(function (require, exports, module) {
6265

6366
if (!Constants.isMigrationSupportedBrowser()) {
6467
paragraphs.push(Strings.MIGRATE_MANUAL_DOWNLOAD_NOTE);
65-
} else if (isTWA) {
66-
paragraphs.push(Strings.MIGRATE_TWA_UPDATE_NOTE);
67-
paragraphs.push(StringUtils.format(Strings.MIGRATE_TWA_BROWSER_LINK,
68-
Constants.getNewOrigin(), Constants.NEW_DOMAIN_NAME));
6968
} else {
7069
paragraphs.push(StringUtils.format(Strings.MIGRATE_DATA_SAFE_NOTE, Constants.NEW_DOMAIN_NAME));
7170
}
@@ -74,24 +73,13 @@ define(function (require, exports, module) {
7473
}
7574

7675
function _buildButtons() {
77-
// "Stay here" is a real choice, not a nag dismiss. On managed ChromeOS fleets the Play Store
78-
// can be blocked outright, so the update button may be a dead end through no fault of the
79-
// user, and the app has to keep working for them.
76+
// "Stay here" is a real choice rather than a nag dismiss. Some installs, managed ChromeOS
77+
// fleets in particular, may not be able to move on the user's own schedule.
8078
const stayButton = {
8179
className: Dialogs.DIALOG_BTN_CLASS_NORMAL,
8280
id: BTN_STAY,
8381
text: Strings.MIGRATE_STAY_HERE
8482
};
85-
if (isTWA) {
86-
return [
87-
stayButton,
88-
{
89-
className: Dialogs.DIALOG_BTN_CLASS_PRIMARY,
90-
id: BTN_UPDATE_APP,
91-
text: Strings.MIGRATE_UPDATE_APP
92-
}
93-
];
94-
}
9583
return [
9684
stayButton,
9785
{
@@ -107,7 +95,7 @@ define(function (require, exports, module) {
10795
* so the user is reminded again next time rather than being able to silence it permanently.
10896
*/
10997
function show() {
110-
const variant = !Constants.isMigrationSupportedBrowser() ? "safari" : (isTWA ? "twa" : "web");
98+
const variant = Constants.isMigrationSupportedBrowser() ? "web" : "safari";
11199
Metrics.countEvent(Metrics.EVENT_TYPE.PLATFORM, "migrateAssist", `sunsetShown.${variant}`);
112100

113101
Dialogs.showModalDialog(
@@ -119,9 +107,6 @@ define(function (require, exports, module) {
119107
if (buttonId === BTN_GO_NEW_SITE) {
120108
Metrics.countEvent(Metrics.EVENT_TYPE.PLATFORM, "migrateAssist", "sunsetGoNewSite");
121109
window.location = Constants.getNewOrigin();
122-
} else if (buttonId === BTN_UPDATE_APP) {
123-
Metrics.countEvent(Metrics.EVENT_TYPE.PLATFORM, "migrateAssist", "sunsetUpdateApp");
124-
window.open(Constants.TWA_STORE_URL, "_blank", "noopener");
125110
} else {
126111
Metrics.countEvent(Metrics.EVENT_TYPE.PLATFORM, "migrateAssist", `sunsetStay.${variant}`);
127112
}

src/nls/root/strings.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2929,10 +2929,7 @@ define({
29292929
"MIGRATE_SUNSET_COUNTDOWN_ONE": "You have <strong>{0} day</strong> left before {1} stops working.",
29302930
"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.",
29312931
"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.",
2932-
"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.",
2933-
"MIGRATE_TWA_BROWSER_LINK": "If you cannot update right now, you can also <a href=\'{0}\'>continue in a browser at {1}</a>.",
29342932
"MIGRATE_GO_TO_NEW_SITE": "Take me to the new site",
2935-
"MIGRATE_UPDATE_APP": "Update the app",
29362933
"MIGRATE_STAY_HERE": "Stay here",
29372934
"MIGRATE_PROGRESS_TITLE": "Bringing your data over",
29382935
"MIGRATE_PROGRESS_STATUS": "{0} of {1} files copied",

0 commit comments

Comments
 (0)