Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

update: a feed a release behind keeps the version downloaded (Restart to update stayed on v0.1.2037)

yetone1a85394329e9
diff --git a/internal/gui/update.go b/internal/gui/update.go
index 59ef127f1..44fb6ec7b 100644
--- a/internal/gui/update.go
+++ b/internal/gui/update.go
@@ -41,7 +41,9 @@ type updater struct {
mirror string // error: the mirror the failed download came through (#893)
network bool // error: the network broke the download off (update.Network)
staged string
- aside string // Windows: where install moved the running exe, to put back
+ // stable: latest was found on Settings' Stable channel
+ stable bool
+ aside string // Windows: where install moved the running exe, to put back
// a version this computer wouldn't start (Smart App Control, #894),
// which the clock's checks don't download again; byClock, the check
// under way is the clock's
@@ -356,15 +358,29 @@ func (u *updater) run() {
if lang == "" {
lang = notesLang(trayLang(s.Lang, systemLang))
}
+ stable := s.UpdateChannel == settings.UpdateStable
rel, err := update.LatestIn(ctx, lang)
u.mu.Lock()
defer u.mu.Unlock()
- // the feed names an older version than the one found before: Settings'
- // Update channel went to Stable since (ssharpcc on X). What was
- // downloaded from every version isn't put in, and the version found
- // is the feed's again, as if never found.
if err == nil && u.latest != nil && update.Newer(u.latest.Version, rel.Version) {
- u.staged, u.latest = "", nil
+ if stable != u.stable {
+ // an older version than the one found before, on another
+ // channel: Settings' Update channel went to Stable since
+ // (ssharpcc on X). What was downloaded from every version
+ // isn't put in, and the version found is the feed's again, as
+ // if never found.
+ u.staged, u.latest = "", nil
+ } else {
+ // on the same channel it is the feed behind: the site, short
+ // of GitHub's API, answers from GitHub's latest redirect or
+ // the last answer it kept, which can be a release or more
+ // old. Restart to update asks the feed first (recheck), and
+ // such an answer dropped the download it was about to put
+ // in: no restart, and the app stayed on the version it was
+ // (littleHong on Discord, v0.1.2037 offered v0.1.2038). The
+ // version found stands, and so does its download.
+ rel, lang = u.latest, u.notesIn
+ }
}
// a version downloaded on a click stays the one restarted into while
// downloads wait for a click: a newer one out since isn't fetched
@@ -385,7 +401,7 @@ func (u *updater) run() {
u.state, u.err = "error", err.Error()
return
}
- u.latest, u.notesIn = rel, lang
+ u.latest, u.notesIn, u.stable = rel, lang, stable
switch {
case !update.Released(Version):
u.state = "source"
diff --git a/internal/gui/update_channel_test.go b/internal/gui/update_channel_test.go
index 3d5089d63..d3ebc8960 100644
--- a/internal/gui/update_channel_test.go
+++ b/internal/gui/update_channel_test.go
@@ -158,3 +158,73 @@ func TestWhatsNewKeyedByChannel(t *testing.T) {
t.Fatalf("every version keeps %d", len(got))
}
}
+
+// The feed behind on the same channel (littleHong on Discord). Short of
+// GitHub's API the site answers from GitHub's latest redirect or the
+// last answer it kept, which can be older than the version the app found
+// and downloaded. Restart to update asks the feed first; such an answer
+// dropped 0.1.12's download, so nothing was restarted into and the app
+// stayed on 0.1.10. The version found stands, download and all.
+func TestUpdateFeedBehindKeepsDownload(t *testing.T) {
+ sandboxHome(t)
+ body := []byte("new magpie")
+ sum := sha256.Sum256(body)
+ var downloads atomic.Int32
+ var behind atomic.Bool
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.URL.Path == "/asset" {
+ downloads.Add(1)
+ w.Write(body)
+ return
+ }
+ v := "0.1.12"
+ if behind.Load() {
+ v = "0.1.11"
+ }
+ json.NewEncoder(w).Encode(update.Release{Version: v, Assets: map[string]update.Asset{
+ update.BinaryAsset(): {URL: "http://" + r.Host + "/asset", Size: int64(len(body)), SHA256: hex.EncodeToString(sum[:])},
+ }})
+ }))
+ defer srv.Close()
+ t.Setenv("MAGPIE_UPDATE_FEED", srv.URL)
+ oldV := Version
+ Version = "0.1.10"
+ defer func() { Version = oldV }()
+ exe, err := update.Executable()
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.Remove(exe + ".new")
+
+ o := updates
+ u := &updater{exe: exe}
+ u.self, _ = os.Stat(exe)
+ updates = u
+ defer func() { updates = o }()
+ settle := func() updateJSON {
+ t.Helper()
+ for range 1000 {
+ if j := u.json(); j.State != "checking" && j.State != "downloading" {
+ return j
+ }
+ time.Sleep(10 * time.Millisecond)
+ }
+ t.Fatalf("still %s", u.json().State)
+ return updateJSON{}
+ }
+
+ u.check()
+ if j := settle(); j.State != "ready" || j.Latest != "0.1.12" || downloads.Load() != 1 {
+ t.Fatalf("found: %+v, %d downloads", j, downloads.Load())
+ }
+ // Restart to update asks the feed again, and it is a release behind
+ behind.Store(true)
+ u.recheck(true)
+ j := settle()
+ u.mu.Lock()
+ staged := u.staged
+ u.mu.Unlock()
+ if j.State != "ready" || j.Latest != "0.1.12" || staged == "" || downloads.Load() != 1 {
+ t.Fatalf("feed behind: %+v, staged %q, %d downloads", j, staged, downloads.Load())
+ }
+}