update: a version newer than its channel's says nothing comes until the channel passes it (realfxw on X)
realfxw on X (tweet 2123033167170814171): "升级无效,重启了无数次,一直卡在这个版本", on 0.1.4445. Every release around it has its 17 assets, so nothing was missing to download. Their Update channel is Daily, and Daily's pick (the 11-17 20:00 UTC cut) is 0.1.4395, older than what they run. The app keeps the newer version and installs nothing until Daily passes it, which is right, but the version row said "Up to date on Daily" (每日版已是最新) and, before a check, Automatic updates are off with a bare Restart. They restarted again and again waiting for an update that couldn't come. - update.go: the update JSON says ahead when the state is latest and this version is newer than the channel's. - app.js: the row says "Newer than Daily's 0.1.4395; it updates once Daily passes it", the newest on Every version after it, and Switch to Every version as before; one t() for both channels and the Every version tail shared with Up to date. Translated in zh, zh-TW, ja, de. - update_cli.go: `magpie update check` says the same, with `magpie update channel every` to get it now. - core_budget_test.go: +68 bytes of code on app.js and the core scripts, packed to the shortest form; renderUpdate draws on every window, so there is no page to move it to. - docs/reference.md: the channel section names Daily and the line. Red on the old code (upd-ahead-red, origin/mainb855cfee9): TestUpdateAheadOfChannel FAIL (no ahead key in the JSON), TestUpdateAheadOfChannelSaysSo FAIL ("up to date"), and update-stable-newest.test.cjs timed out on the ahead line in every language. Run at this head (253547908's tree, rebased on4d79bebfa), on mote: - gofmt -l clean; go vet ./internal/gui ./internal/cli ./internal/update for darwin, GOOS=linux -tags nogui and GOOS=windows; go build . for all three. - go test -count=1 ./internal/gui ./internal/cli ./internal/update ./internal/settings: update and settings ok; the new tests pass; gui and cli red only on TestLaneLimitRoutes (#5150), TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr, TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr (#6471) and TestUpdateFindsAMagpieThatWroteNoRecord (#6223), the same on origin/mainb855cfee9on mote, where an ssh forward holds 127.0.0.1:3425. - GUI, BROWSER=chromium and webkit: update-*, i18n-*, gui-zh-tw/ja/de, settings-search(-reach), 28 files, 296/296 each, before the rebase; update-stable-newest and i18n-keys 15/15 each after it, with TestCoreScriptBudget ok. Not run: the full go test ./... suite. mote and mica each had another session's full suite running, and mica's disk is full; CI runs it. Not tried: a real Daily install moving past it.
This commit is contained in:
+6
-4
@@ -3590,10 +3590,12 @@ version channel first. A release marked urgent goes to Stable at once.
|
||||
When Stable moves past several versions, What's new lists the notes of
|
||||
every version since yours as one list.
|
||||
|
||||
A version installed from the site can be newer than Stable's; the app
|
||||
keeps it and waits until Stable passes it. While it waits, the Version
|
||||
row says *Up to date on Stable*, names the newest version out on Every
|
||||
version, and offers to switch to Every version.
|
||||
A version installed from the site, or kept from Every version when the
|
||||
channel changed, can be newer than Stable's or Daily's; the app keeps it
|
||||
and waits until the channel passes it. While it waits, the Version row
|
||||
says so (*Newer than Daily's 0.1.4395; it updates once Daily passes it*),
|
||||
names the newest version out on Every version, and offers to switch to
|
||||
Every version; `magpie update` says the same.
|
||||
|
||||
The site's downloads offer Stable's version beside the newest
|
||||
(`usemagpie.ai/download/stable/<platform>`). A fresh install of it (no
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
"github.com/yetone/magpie/internal/update"
|
||||
)
|
||||
|
||||
// `magpie update` on a version newer than its channel's (realfxw on X:
|
||||
// 0.1.4445 on Daily, whose pick was 0.1.4395) said it was up to date, and
|
||||
// nothing came until Daily passed it. It now says it is newer than the
|
||||
// channel's, and how to update now. On the channel's own version it is up
|
||||
// to date as before.
|
||||
func TestUpdateAheadOfChannelSaysSo(t *testing.T) {
|
||||
groupsHome(t)
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
v := "0.1.4472"
|
||||
if r.URL.Query().Get("channel") == "daily" {
|
||||
v = "0.1.4395"
|
||||
}
|
||||
json.NewEncoder(w).Encode(update.Release{Version: v})
|
||||
}))
|
||||
defer srv.Close()
|
||||
t.Setenv("MAGPIE_UPDATE_FEED", srv.URL)
|
||||
if err := settings.Save(settings.Settings{UpdateChannel: settings.UpdateDaily}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
was := version
|
||||
t.Cleanup(func() { version = was })
|
||||
|
||||
version = "0.1.4445"
|
||||
out, err := stdoutOf(t, func() error { return updateCmd([]string{"update", "check"}) })
|
||||
if err != nil || !strings.Contains(out, "is newer than the daily channel's 0.1.4395") || !strings.Contains(out, "magpie update channel every") || strings.Contains(out, "up to date") {
|
||||
t.Fatalf("ahead of daily: %v %q", err, out)
|
||||
}
|
||||
version = "0.1.4395"
|
||||
out, err = stdoutOf(t, func() error { return updateCmd([]string{"update", "check"}) })
|
||||
if err != nil || !strings.Contains(out, "is up to date on the daily channel") {
|
||||
t.Fatalf("daily's own version: %v %q", err, out)
|
||||
}
|
||||
}
|
||||
@@ -227,7 +227,11 @@ func updateCmd(args []string) error {
|
||||
}
|
||||
if !update.Newer(rel.Version, version) {
|
||||
if update.Released(version) {
|
||||
if ch := update.Channel(); ch != "" {
|
||||
if ch := update.Channel(); ch != "" && update.Newer(version, rel.Version) {
|
||||
// newer than the channel's: nothing is installed until the
|
||||
// channel passes it (realfxw on X), which "up to date" hid
|
||||
fmt.Println("magpie", version, "is newer than the "+ch+" channel's "+rel.Version+muted.Render("; it updates once "+ch+" passes it, or now with `magpie update channel every`"))
|
||||
} else if ch != "" {
|
||||
fmt.Println(green.Render("✓"), "magpie", version, muted.Render("is up to date on the "+ch+" channel ("+ch+" is "+rel.Version+")"))
|
||||
} else {
|
||||
fmt.Println(green.Render("✓"), "magpie", version, muted.Render("is the latest"))
|
||||
|
||||
@@ -22719,10 +22719,10 @@ async function renderUpdate(r, u) {
|
||||
again(1000);
|
||||
break;
|
||||
case "latest":
|
||||
// Stable's and Daily's say the newest out (ylspcm on X)
|
||||
sub.textContent = u.channel === "daily"
|
||||
? t(u.newest ? "Up to date on Daily · {v} is out on Every version" : "Up to date on Daily", { v: u.newest })
|
||||
: u.newest ? t("Up to date on Stable · {v} is out on Every version", { v: u.newest }) : t(u.channel ? "Up to date on Stable" : "Up to date");
|
||||
// Stable's and Daily's say the newest out (ylspcm on X); newer than
|
||||
// the channel's, that nothing comes until it passes (realfxw on X)
|
||||
sub.textContent = t(u.ahead ? "Newer than {c}'s {d}; it updates once {c} passes it" : u.channel == "daily" ? "Up to date on Daily" : u.channel ? "Up to date on Stable" : "Up to date", { c: t(u.channel == "daily" ? "Daily" : "Stable"), d: u.latest }) + (u.newest ? " · " + t("{v} is out on Every version", { v: u.newest }) : "");
|
||||
if (u.ahead) sub.classList.add("wraps");
|
||||
if (u.newest) btn(t("Switch to Every version"), () => savePrefs({ ...prefsKeep(prefs), updateChannel: "" }));
|
||||
btn(t("Check"), check);
|
||||
break;
|
||||
|
||||
@@ -4253,10 +4253,10 @@ const I18N = {
|
||||
"Downloading {v}…": "正在下载 {v}…",
|
||||
"Up to date": "已是最新",
|
||||
"Up to date on Stable": "稳定版已是最新",
|
||||
"Up to date on Stable · {v} is out on Every version": "稳定版已是最新 · 尝鲜版已有 {v}",
|
||||
"Daily": "每日版",
|
||||
"Up to date on Daily": "每日版已是最新",
|
||||
"Up to date on Daily · {v} is out on Every version": "每日版已是最新 · 尝鲜版已有 {v}",
|
||||
"Newer than {c}'s {d}; it updates once {c} passes it": "比{c}的 {d} 新,{c}超过它后才会更新",
|
||||
"{v} is out on Every version": "尝鲜版已有 {v}",
|
||||
"One version a day, the newest that passed its tests, and urgent fixes at once. What's new lists every change since yours": "每天一个版本,选通过测试的最新版;紧急修复立即推送。「更新内容」会列出你当前版本以来的全部改动",
|
||||
"Switch to Every version": "改用尝鲜版",
|
||||
"What's new": "更新内容",
|
||||
@@ -9714,10 +9714,10 @@ const I18N = {
|
||||
"Downloading {v}…": "正在下載 {v}…",
|
||||
"Up to date": "已是最新",
|
||||
"Up to date on Stable": "穩定版已是最新",
|
||||
"Up to date on Stable · {v} is out on Every version": "穩定版已是最新 · 搶先版已有 {v}",
|
||||
"Daily": "每日版",
|
||||
"Up to date on Daily": "每日版已是最新",
|
||||
"Up to date on Daily · {v} is out on Every version": "每日版已是最新 · 搶先版已有 {v}",
|
||||
"Newer than {c}'s {d}; it updates once {c} passes it": "比{c}的 {d} 新,{c}超過它後才會更新",
|
||||
"{v} is out on Every version": "搶先版已有 {v}",
|
||||
"One version a day, the newest that passed its tests, and urgent fixes at once. What's new lists every change since yours": "每天一個版本,選通過測試的最新版;緊急修正立即推送。「更新內容」會列出你目前版本以來的全部變更",
|
||||
"Switch to Every version": "改用搶先版",
|
||||
"What's new": "更新內容",
|
||||
@@ -15184,10 +15184,10 @@ const I18N = {
|
||||
"Downloading {v}…": "{v} をダウンロード中…",
|
||||
"Up to date": "最新です",
|
||||
"Up to date on Stable": "安定版では最新です",
|
||||
"Up to date on Stable · {v} is out on Every version": "安定版では最新です · 先行版では {v} が出ています",
|
||||
"Daily": "デイリー版",
|
||||
"Up to date on Daily": "デイリー版では最新です",
|
||||
"Up to date on Daily · {v} is out on Every version": "デイリー版では最新です · 先行版では {v} が出ています",
|
||||
"Newer than {c}'s {d}; it updates once {c} passes it": "{c}の {d} より新しいため、{c}が追い越すまで更新されません",
|
||||
"{v} is out on Every version": "先行版では {v} が出ています",
|
||||
"One version a day, the newest that passed its tests, and urgent fixes at once. What's new lists every change since yours": "テストに通った最新のバージョンを 1 日 1 回、緊急の修正はすぐに届けます。新機能には今のバージョン以降のすべての変更がまとめて表示されます",
|
||||
"Switch to Every version": "先行版に切り替える",
|
||||
"What's new": "新機能",
|
||||
@@ -20675,10 +20675,10 @@ const I18N = {
|
||||
"Downloading {v}…": "Lade {v} herunter…",
|
||||
"Up to date": "Aktuell",
|
||||
"Up to date on Stable": "Aktuell auf Stabil",
|
||||
"Up to date on Stable · {v} is out on Every version": "Aktuell auf Stabil · Unter Jede Version ist {v} erschienen",
|
||||
"Daily": "Täglich",
|
||||
"Up to date on Daily": "Aktuell auf Täglich",
|
||||
"Up to date on Daily · {v} is out on Every version": "Aktuell auf Täglich · Unter Jede Version ist {v} erschienen",
|
||||
"Newer than {c}'s {d}; it updates once {c} passes it": "Neuer als {d} auf {c}; Updates kommen, sobald {c} diese Version überholt",
|
||||
"{v} is out on Every version": "Unter Jede Version ist {v} erschienen",
|
||||
"One version a day, the newest that passed its tests, and urgent fixes at once. What's new lists every change since yours": "Eine Version pro Tag, die neueste mit bestandenen Tests, dringende Korrekturen sofort. Neuigkeiten listet alle Änderungen seit Ihrer Version",
|
||||
"Switch to Every version": "Zu Jede Version wechseln",
|
||||
"What's new": "Neuigkeiten",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -34,6 +34,17 @@ const dailyWords = {
|
||||
de: { newest: "Aktuell auf Täglich · Unter Jede Version ist 0.1.410 erschienen", daily: "Aktuell auf Täglich" },
|
||||
};
|
||||
|
||||
// newer than the channel's pick (realfxw on X: 0.1.4445 on Daily's
|
||||
// 0.1.4395): the row says nothing comes until the channel passes it,
|
||||
// not that it is up to date, and still offers the newest
|
||||
const aheadWords = {
|
||||
en: { daily: "Newer than Daily's 0.1.390; it updates once Daily passes it · 0.1.410 is out on Every version", stable: "Newer than Stable's 0.1.390; it updates once Stable passes it" },
|
||||
zh: { daily: "比每日版的 0.1.390 新,每日版超过它后才会更新 · 尝鲜版已有 0.1.410", stable: "比稳定版的 0.1.390 新,稳定版超过它后才会更新" },
|
||||
"zh-TW": { daily: "比每日版的 0.1.390 新,每日版超過它後才會更新 · 搶先版已有 0.1.410", stable: "比穩定版的 0.1.390 新,穩定版超過它後才會更新" },
|
||||
ja: { daily: "デイリー版の 0.1.390 より新しいため、デイリー版が追い越すまで更新されません · 先行版では 0.1.410 が出ています", stable: "安定版の 0.1.390 より新しいため、安定版が追い越すまで更新されません" },
|
||||
de: { daily: "Neuer als 0.1.390 auf Täglich; Updates kommen, sobald Täglich diese Version überholt · Unter Jede Version ist 0.1.410 erschienen", stable: "Neuer als 0.1.390 auf Stabil; Updates kommen, sobald Stabil diese Version überholt" },
|
||||
};
|
||||
|
||||
function settingsPayload(lang, ctl) {
|
||||
const s = {
|
||||
theme: "light", lang, tray: "panel", quotaLeft: false, currency: "usd",
|
||||
@@ -69,7 +80,7 @@ function server(lang, ctl) {
|
||||
}
|
||||
if (url.pathname === "/api/update") {
|
||||
if (ctl.channel !== "stable" && ctl.channel !== "daily") return json({ state: "latest", current: "0.1.400", latest: "0.1.410" });
|
||||
return json({ state: "latest", current: "0.1.400", latest: "0.1.390", channel: ctl.channel, ...(ctl.newest ? { newest: ctl.newest } : {}) });
|
||||
return json({ state: "latest", current: "0.1.400", latest: "0.1.390", channel: ctl.channel, ...(ctl.newest ? { newest: ctl.newest } : {}), ...(ctl.ahead ? { ahead: true } : {}) });
|
||||
}
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||||
@@ -159,6 +170,29 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await openPart(page, "about");
|
||||
await page.waitForFunction((s) => document.querySelector("#about .row.pref .sub.say")?.textContent === s, dailyWords[lang].daily);
|
||||
assert.equal(await row.locator("button", { hasText: w.go }).count(), 0);
|
||||
|
||||
// ahead of Daily, the newest out: said, the switch offered, and
|
||||
// the row fits at 420 without a sideways scroll
|
||||
ctl.ahead = true;
|
||||
ctl.newest = "0.1.410";
|
||||
await page.reload();
|
||||
await settingsDrawn(page);
|
||||
await openPart(page, "about");
|
||||
await page.waitForFunction((s) => document.querySelector("#about .row.pref .sub.say")?.textContent === s, aheadWords[lang].daily);
|
||||
await row.locator("button", { hasText: w.go }).waitFor();
|
||||
await showRow(page, row);
|
||||
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth), true, "no sideways scroll ahead of Daily");
|
||||
const aheadRight = await row.locator("button", { hasText: w.go }).evaluate((b) => b.getBoundingClientRect().right);
|
||||
assert.ok(aheadRight <= width, `the button ends at ${aheadRight}, past ${width}`);
|
||||
// ahead of Stable, nothing newer
|
||||
ctl.channel = "stable";
|
||||
ctl.newest = "";
|
||||
await page.reload();
|
||||
await settingsDrawn(page);
|
||||
await openPart(page, "about");
|
||||
await page.waitForFunction((s) => document.querySelector("#about .row.pref .sub.say")?.textContent === s, aheadWords[lang].stable);
|
||||
assert.equal(await row.locator("button", { hasText: w.go }).count(), 0);
|
||||
ctl.ahead = false;
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -152,7 +152,13 @@ type updateJSON struct {
|
||||
// isn't the newest
|
||||
Channel string `json:"channel,omitempty"`
|
||||
Newest string `json:"newest,omitempty"`
|
||||
Done int64 `json:"done,omitempty"` // downloading: bytes so far
|
||||
// Ahead: latest on Stable or Daily, this version is newer than the
|
||||
// channel's (Latest). Nothing is installed until the channel passes
|
||||
// it, and "up to date on Daily" read as an update that never came
|
||||
// (realfxw on X: 0.1.4445 on Daily, whose pick was 0.1.4395, restarted
|
||||
// again and again)
|
||||
Ahead bool `json:"ahead,omitempty"`
|
||||
Done int64 `json:"done,omitempty"` // downloading: bytes so far
|
||||
// downloading: the step under way, "" before the first
|
||||
// (update.StepDownload, StepRetry, StepVerify, StepUnpack,
|
||||
// StepSignature), and how fast the bytes came over the last seconds,
|
||||
@@ -808,6 +814,7 @@ func (u *updater) jsonIn(lang string) updateJSON {
|
||||
j.Channel = u.channel
|
||||
if u.state == "latest" {
|
||||
j.Newest = u.newest
|
||||
j.Ahead = update.Newer(Version, u.latest.Version)
|
||||
}
|
||||
}
|
||||
if u.latestStale() {
|
||||
|
||||
@@ -314,3 +314,67 @@ func TestStableUpToDateNamesNewest(t *testing.T) {
|
||||
t.Fatalf("every version: %v, asked %d times", j, asked.Load()-before)
|
||||
}
|
||||
}
|
||||
|
||||
// A version newer than its channel's (realfxw on X): 0.1.4445 on Daily,
|
||||
// whose pick was 0.1.4395, with 0.1.4472 out on every version. The row
|
||||
// said "up to date on Daily", nothing was installed until Daily passed
|
||||
// 0.1.4445, and the user restarted again and again for an update that
|
||||
// wasn't coming. The answer now says it is ahead (the row: newer than
|
||||
// Daily's, it updates once Daily passes it), and still names the newest.
|
||||
// The same version as the channel's, or every version, isn't ahead.
|
||||
func TestUpdateAheadOfChannel(t *testing.T) {
|
||||
sandboxHome(t)
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
v := "0.1.4472"
|
||||
if r.URL.Query().Get("channel") == "daily" {
|
||||
v = "0.1.4395"
|
||||
}
|
||||
json.NewEncoder(w).Encode(update.Release{Version: v, Notes: "- x"})
|
||||
}))
|
||||
defer srv.Close()
|
||||
t.Setenv("MAGPIE_UPDATE_FEED", srv.URL)
|
||||
oldV := Version
|
||||
defer func() { Version = oldV }()
|
||||
exe, err := update.Executable()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
o := updates
|
||||
defer func() { updates = o }()
|
||||
// as the page reads it
|
||||
check := func(channel, v string) map[string]any {
|
||||
t.Helper()
|
||||
s := settings.Load()
|
||||
s.UpdateChannel, s.NoAutoUpdate = channel, true
|
||||
if err := settings.Save(s); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
Version = v
|
||||
u := &updater{exe: exe}
|
||||
u.self, _ = os.Stat(exe)
|
||||
updates = u
|
||||
u.check()
|
||||
for range 1000 {
|
||||
if j := u.json(); j.State != "checking" && j.State != "downloading" {
|
||||
var m map[string]any
|
||||
b, _ := json.Marshal(j)
|
||||
if err := json.Unmarshal(b, &m); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
t.Fatalf("still %s", u.json().State)
|
||||
return nil
|
||||
}
|
||||
if j := check(settings.UpdateDaily, "0.1.4445"); j["state"] != "latest" || j["ahead"] != true || j["channel"] != "daily" || j["latest"] != "0.1.4395" || j["newest"] != "0.1.4472" {
|
||||
t.Fatalf("ahead of Daily: %v", j)
|
||||
}
|
||||
if j := check(settings.UpdateDaily, "0.1.4395"); j["state"] != "latest" || j["ahead"] != nil || j["newest"] != "0.1.4472" {
|
||||
t.Fatalf("Daily's own version: %v", j)
|
||||
}
|
||||
if j := check("", "0.1.4472"); j["state"] != "latest" || j["ahead"] != nil || j["channel"] != nil {
|
||||
t.Fatalf("every version: %v", j)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user