feat(extension): report the channel beside the version (step 7)
CI / lint (push) Successful in 4s
CI / extension-version (push) Successful in 5s
CI / frontend-build (push) Successful in 20s
CI / backend-lint-and-test (push) Successful in 32s
extension / lint (push) Successful in 28s
CI / integration (push) Successful in 3m52s
Build images / sign-extension (push) Successful in 4s
Build images / build-ml (push) Failing after 5s
Build images / build-agent (push) Successful in 13s
Build images / build-web (push) Successful in 2m4s
CI / lint (push) Successful in 4s
CI / extension-version (push) Successful in 5s
CI / frontend-build (push) Successful in 20s
CI / backend-lint-and-test (push) Successful in 32s
extension / lint (push) Successful in 28s
CI / integration (push) Successful in 3m52s
Build images / sign-extension (push) Successful in 4s
Build images / build-ml (push) Failing after 5s
Build images / build-agent (push) Successful in 13s
Build images / build-web (push) Successful in 2m4s
Closes the half of the ask the signing work didn't: a way to tell a dev
build from a main one. FC_CHANNEL is baked into the web image at build
time and /api/extension/manifest reports it as its own key, next to
version — the popup banner, the toolbar tooltip and the Settings card all
name it.
Beside the version, never inside it. A `1.0.3499884-dev` suffix is the
obvious shortcut and it is the exact failure this design comes from:
versionIsNewer parses each dotted segment with parseInt, so a suffixed
segment reads as 0, every dev build compares equal to every other, and
"no update available" stops being distinguishable from "I cannot read this
version". The comparator already degrades rather than discarding (rule
150), which is a reason not to NEED the suffix, not a licence to add one.
Two tests hold the line — one backend, asserting version and channel are
separate keys; one frontend, asserting the rendered version text stays the
bare derived number.
Optional on the read side, and absent rather than defaulted. An image
built before this field says nothing by not having the key; an image built
without a channel now says nothing the same way, so there is one absence
to handle instead of a second spelling of "unknown". Every reader drops
the label entirely when it is missing and reads exactly as it did before.
Reported verbatim rather than validated against {dev, main}: if an image
declares something else, showing what it claims helps whoever is debugging
more than dropping it would.
FC_CHANNEL is declared LAST in the Dockerfile. An ARG invalidates every
layer below it, and this is the one value that differs between the dev and
main builds of identical source — earlier, and the two channels could
never share a cached pip install. A tag push counts as main: a vYY.MM.DD
tag is cut from main, so that image is a main-channel artifact wearing an
immutable name.
No channel switcher, deliberately. background.js:34 already records that
Firefox's static update_url cannot apply, because every FC instance is a
different host — so the extension asks its configured backend, and the
channel IS the instance it points at. Switching is repointing apiUrl and
reinstalling from that host. A separate setting would contradict each
server build shipping its own extension.
This commit touches packaged extension files, so it moves the derived
version and will sign a new one via AMO — the first push to exercise the
extension-changed path from dev end to end.
This commit is contained in:
@@ -66,6 +66,25 @@ Commit time gives both branches the same number for the same source — which is
|
||||
exactly what lets one AMO signature serve both channels (family rule 149, FC
|
||||
issue #3092).
|
||||
|
||||
## Channels
|
||||
|
||||
`dev` and `main` each build and sign their own extension, and an install is
|
||||
tied to whichever FC instance it points at — Firefox's static `update_url`
|
||||
cannot apply here, since every FC install is a different host, so the extension
|
||||
asks its configured backend. **The channel therefore IS the instance.**
|
||||
Switching channel means repointing the FC URL in options and reinstalling from
|
||||
that host; there is no separate channel setting, and adding one would
|
||||
contradict each server build shipping its own extension.
|
||||
|
||||
The channel is reported *beside* the version, never inside it:
|
||||
`/api/extension/manifest` answers `{"version": "...", "channel": "dev"}`. It is
|
||||
optional — an instance that declares none simply omits the key, and the popup,
|
||||
the toolbar tooltip and the Settings card all read exactly as they did before
|
||||
the field existed. Do not be tempted to make it a `-dev` version suffix: the
|
||||
comparator parses each dotted segment with `parseInt`, so a suffixed segment
|
||||
reads as 0 and every dev build compares equal to every other, collapsing "no
|
||||
update available" and "I cannot read this version" into one answer.
|
||||
|
||||
## Release
|
||||
|
||||
Nothing to do by hand. Push to `dev`: `build.yml` signs the extension if this
|
||||
|
||||
@@ -37,7 +37,16 @@ ensureInitialized().catch(e => console.error('init failed:', e));
|
||||
// configured backend for the latest published version and nudge the operator to
|
||||
// reinstall the freshly-signed XPI — surfaced as a popup banner (on demand) and
|
||||
// a toolbar badge (daily). /api/extension/manifest is public and returns
|
||||
// {version, latest_url, sha256}; the XPI is served from the web root (not /api).
|
||||
// {version, latest_url, sha256} plus an OPTIONAL {channel} naming which channel
|
||||
// that instance serves ("dev"/"main", #3113); the XPI is served from the web
|
||||
// root (not /api).
|
||||
//
|
||||
// The channel IS the instance: Firefox's static update_url cannot apply here
|
||||
// because every FC install is a different host, so the extension asks its
|
||||
// configured backend — which means switching channel is repointing apiUrl in
|
||||
// options and reinstalling from that host. There is no separate channel
|
||||
// setting to build, and building one would contradict each server build
|
||||
// shipping its own extension.
|
||||
|
||||
function versionIsNewer(candidate, current) {
|
||||
// Dotted numeric compare so 1.0.10 > 1.0.9 (a plain string compare wouldn't).
|
||||
@@ -60,12 +69,22 @@ async function checkForUpdateInfo() {
|
||||
}
|
||||
const currentVersion = browser.runtime.getManifest().version;
|
||||
const latestVersion = info && info.version ? info.version : null;
|
||||
// Which channel the configured instance serves — reported ALONGSIDE the
|
||||
// version, never folded into it. A `-dev` suffix would have to survive
|
||||
// versionIsNewer's parseInt above, and it wouldn't: the segment would read
|
||||
// as 0 and every dev build would compare equal to every other.
|
||||
//
|
||||
// null is a normal answer, not a failure — an instance built before the
|
||||
// field existed, or one built locally with no channel declared. Nothing
|
||||
// below branches on it except the label.
|
||||
const channel = info && info.channel ? info.channel : null;
|
||||
// latest_url is served from the web root, not the JSON API.
|
||||
const base = api.webRoot();
|
||||
return {
|
||||
updateAvailable: !!latestVersion && versionIsNewer(latestVersion, currentVersion),
|
||||
currentVersion,
|
||||
latestVersion,
|
||||
channel,
|
||||
xpiUrl: info && info.latest_url ? `${base}${info.latest_url}` : null,
|
||||
};
|
||||
}
|
||||
@@ -77,7 +96,11 @@ async function refreshUpdateBadge() {
|
||||
await browser.action.setBadgeText({ text: r.updateAvailable ? '↑' : '' });
|
||||
if (r.updateAvailable) {
|
||||
await browser.action.setBadgeBackgroundColor({ color: '#F4BA7A' });
|
||||
await browser.action.setTitle({ title: `FabledCurator — update available (v${r.latestVersion})` });
|
||||
// Channel first, version second, and the channel dropped entirely when
|
||||
// the instance doesn't report one — so the tooltip reads exactly as it
|
||||
// did before the field existed rather than saying "(unknown ...)".
|
||||
const label = r.channel ? `${r.channel} v${r.latestVersion}` : `v${r.latestVersion}`;
|
||||
await browser.action.setTitle({ title: `FabledCurator — update available (${label})` });
|
||||
} else {
|
||||
await browser.action.setTitle({ title: 'FabledCurator' });
|
||||
}
|
||||
|
||||
@@ -81,8 +81,12 @@ async function checkForUpdate() {
|
||||
}
|
||||
|
||||
function showUpdateBanner(r) {
|
||||
// The channel names itself beside the version, never inside it (#3113).
|
||||
// Absent when the instance doesn't report one, and the banner then reads
|
||||
// exactly as it did before the field existed.
|
||||
const channel = r.channel ? ` (${r.channel})` : '';
|
||||
document.getElementById('update-text').textContent =
|
||||
`Update available — v${r.latestVersion} (installed v${r.currentVersion})`;
|
||||
`Update available${channel} — v${r.latestVersion} (installed v${r.currentVersion})`;
|
||||
// Opening the signed XPI triggers Firefox's native install prompt.
|
||||
document.getElementById('update-btn').addEventListener('click', () => {
|
||||
browser.tabs.create({ url: r.xpiUrl });
|
||||
|
||||
Reference in New Issue
Block a user