Commit Graph
45 Commits
Author SHA1 Message Date
yetone e4197144a8 perf: every package's package-level regexps compile on first use
v0.1.3516 made gateway's and redact's patterns lazy. The other 299
package-level regexp.MustCompile calls, in 148 files across agent,
provider, gui, library, codexcat, sessions, usage, plugin and the rest,
now go through lazyre.New too, so a launch that never reaches them
(`magpie statusline`, run by Claude Code on every message) doesn't
compile them. Fields, maps and params that held them are *lazyre.RE.

Measured on mote (M5 Pro), sandbox HOME, v0.1.3516-equivalent build
(t42) against this one (t43):
- GODEBUG=inittrace=1 sum: 7.39 MB / 69,837 allocs -> 4.62 MB / 46,765
- `magpie statusline`, 3 runs each: instructions retired ~212M -> ~176M,
  peak memory footprint 19.2-19.4 MB -> 16.8-17.0 MB

Run: go vet ./... (darwin) ok; GOOS=windows go vet on each of the 30
changed packages ok; GOOS=linux go vet ok except ., internal/cli and
internal/gui, which stop in wails v3's cgo files when cross-compiled
(the same at main). New TestAllLazyPatternsCompile at the root compiles
all 574 registered patterns (ok), so a bad pattern fails a test rather
than a first use.
Not run before push: the changed packages' own test suites; they run
on mote after it.
2026-11-10 12:54:39 +08:00
yetone 62a9ab743f update: Stable's "Up to date" names the newest version out (ylspcm on X)
ylspcm (macOS) on X: Check for updates always says up to date, but the
installed version is behind, so they reinstall from the site each time.
On Settings' Stable channel the feed answers Stable's weekly version.
An app installed from the site is newer than that, so every check
answered "Up to date" while newer releases were out on Every version,
and the Version row never named the channel. `magpie update` already
said "up to date on the stable channel"; the app didn't.

Now, on Stable with nothing newer there, the check also asks the feed
on every version (update.LatestEvery, before u.mu is taken).
/api/update says channel "stable" and, when it is newer than this one,
newest. The Version row reads "Up to date on Stable · {v} is out on
Every version" with Switch to Every version, which saves the channel
and the existing channel-change path checks again. With nothing newer
it says "Up to date on Stable". On every version nothing changes, and
there is no second request. en, zh, zh-TW, ja, de. reference.md's
Update channel section says so. The row's code fits in the core
script budget with four of renderUpdate's comments cut, no raise
(1,533,753 of 1,533,802).

The cause is inferred, not confirmed: the tweet gives no channel or
version. The live feed has every version at 0.1.3476 and Stable at
0.1.3078. The rest of the check (semver compare, bundle, mirrors, the
worker's 5-minute cache) gave "Up to date" only for a feed answering a
version at or below the running one.

Run on mote at this change on 216ac6f85. Its parent is now 3cfbc19b0,
which only touches app.css and adds a GUI test, so nothing was run again
(the core script budget, measured again, is the same):
- TestStableUpToDateNamesNewest red with internal/gui/update.go and
  internal/update/update.go put back (old code: map[current:0.1.12
  latest:0.1.11 state:latest], no channel or newest), green with them.
- go test -count=1 ./internal/gui ./internal/update: ok (a run at the
  earlier base passed; after the rebase TestCoreScriptBudget was 440
  bytes over, fixed by the comment cuts above, then run again).
- gofmt -l clean. go vet darwin and windows of both packages: ok.
  GOOS=linux go vet -tags nogui: ok. Without nogui, wails needs cgo
  and fails on mote and in WSL (no gtk4), as it does on main.
- GUI (Chromium + WebKit): update-stable-newest (new: every language,
  900 and 420 wide, the switch saves "", no scroll on click),
  update-channel, update-check, update-row-steady, update-auto,
  update-release-page, update-mirror, i18n-keys and i18n-en-no-cjk:
  pass 130, fail 0.

Not tried: the real app on Stable against the live feed, and a full
suite (after the tag).
2026-11-10 07:53:53 +08:00
yetone 9d366f15b9 update: a file the feed names off GitHub goes on to its github.com address, then the API
The feed is about to name usemagpie.ai's copy of each release file on
Cloudflare R2, with the file's github.com address beside it (`github`).
The app, `magpie update` and install.sh now try, in order: the feed's
url; github.com's address (Asset.GitHub), through the user's mirror when
one is set (a mirror is still only put before a github.com address); then
GitHub's API route, looked up from the github.com address, never through
a mirror. A route is left once it answers busy, or for the last tries
after connections that broke. The error names each route that failed.
Every file is checked against the feed's SHA-256 as before.

Run:
- mote: go test -count=1 ./internal/update ok; gofmt -l clean; go vet,
  GOOS=linux go vet -tags nogui, GOOS=windows go vet of ./internal/update ok.
- wsl (magpie-desktop): go test ./internal/update ok; node --test
  site/install.test.mjs ok.
- mote: node --test site/*.test.mjs 104/104.
- win-run: go test ./internal/update has one red, TestPackagedByDpkg,
  the same on origin/main 82ca554be (#4603).

Broken by hand: toGitHub forced false, five new Go tests red
(TestDownloadGoesToGitHubWhenTheSiteIsBusy and the four beside it);
install.sh's github.com step skipped, two new install tests red.

Not tried: a real update against R2 (the site change is the next commit).
2026-11-09 05:48:23 +08:00
yetone c66cdbea97 update: a release file github.com won't serve comes through GitHub's API
On 2026-11-08 github.com answered 504 for every file of
yetone/magpie-releases (…/releases/download/<tag>/<file>) for hours, while
api.github.com/repos/yetone/magpie-releases/releases/assets/<id>, asked
with Accept: application/octet-stream, redirected to the same bytes.
Every self-update and the install script failed (kurutodenzeru, wjbdx,
isee1_1 on Discord). Retrying the same address (a46190e1f) can't help.
The site's feed was stuck at 0.1.3318 too: its SHA256SUMS read went to
the same address.

- internal/update: download() goes to the API route at the first busy
  status (5xx/429), or for the last try after connection errors. The
  feed's new per-asset `api` is used as it is; without it the address is
  looked up from the release's tag (apiroute.go). The file is checked
  exactly as before: the feed's SHA-256, and Stage's signing-team check on
  the Mac. A mirror the user set keeps precedence: through one, no API
  route is tried (its whole point is that GitHub isn't reachable). This is
  the one download every caller uses: the app's update, the CLI's
  `magpie update` and serve's auto-update.
- site/public/install.sh: when the feed's github.com URL fails and no
  mirror is set, it downloads through the feed's `api` (else looks it up
  with curl+sed, no jq), and checks the same SHA-256.
- site/worker.js: the feed lists `api` per asset. SHA256SUMS is read
  through the API when github.com fails. While it does, each file's `url`
  is usemagpie.ai/dl/<tag>/<file>, which 302s to the address GitHub's API
  gives (only *.githubusercontent.com or github.com, https), so an older
  magpie, which follows `url` only, updates too, still checked against the
  feed's SHA-256. That feed is cached 60s instead of 300s, so it goes
  back to github.com's URLs soon after github.com recovers.
- docs/reference.md: the API route, and that a mirror keeps precedence.

Run:
- mote: go test -tags nogui -count=1 ./internal/update (ok 20.3s).
- mote: node --test site/install.test.mjs site/worker.test.mjs
  site/stable.test.mjs: 76 pass.
- gofmt -l internal/update: clean. mote: GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet -tags nogui ./..., GOOS=windows go vet
  ./internal/update ./internal/cli ./internal/gui: clean.
- Real, on the Linux box (wsl-run, magpie-desktop) at 10:50Z: a nogui
  build stamped 0.1.3000, `magpie update` in a sandbox HOME
  (MAGPIE_ADDR=127.0.0.1:9). MAGPIE_UPDATE_FEED was a local feed whose
  magpie-cli-linux-amd64 url answered 504, with the real `api` of
  v0.1.3319 and the sha256 from the real SHA256SUMS. The download address
  was asked once and got 504. The file came through api.github.com, and
  the binary was replaced with exactly 89fff184… and reports 0.1.3319.
- Real: install.sh's apiroute sed against api.github.com's full
  v0.1.3319 description found the right asset id for 5 files
  (723602745 for magpie-cli-linux-amd64, the same as Go's lookup).
- Full suite: not run at push; it runs after.

Broken by hand:
- No switch to the API route in download(): 3 of the 4 new Go tests red
  ("504 Gateway Timeout, on every try").
- Mirror check and the octet-stream Accept removed:
  TestMirrorKeepsPrecedenceOverTheAPIRoute red, and
  TestDownloadGoesThroughTheAPIWhenGitHubIsBusy red (checksum: GitHub's
  JSON description instead of the file).
- worker: no API read of SHA256SUMS, no /dl location cache, and no check
  of the redirect's host: each red.
- install.sh: no API fallback, then no mirror guard: each new install
  test red.

Not tried:
- The real outage itself: github.com had recovered (302, slowly) by the
  real run, so the 504 was a local server's and the API route was real.
- An old magpie through the deployed /dl route against a failing
  github.com; it is covered by the worker test only.
- install.sh end to end against the real API (only its lookup); the Mac
  app's Stage through the API route (only the fake tests, which keep the
  signing-team check unchanged).
2026-11-08 18:52:32 +08:00
yetone a46190e1f5 update: a busy download host (502, 503, 504, 500, 429) is tried again
The owner's About page: "0.1.3316 下载失败 · download
magpie-darwin-arm64.zip: 504 Gateway Timeout". Only a connection that
broke was tried again; any status but 200/206 failed the download at
once, though a 504 from GitHub's asset host (or a mirror's) is its edge
timing out, and the next ask usually goes through. Such a reply is now
a NetError: download asks again after each of retryWaits (2s to 30s),
over HTTP/1.1 and keeping what came, as for a dropped connection. When
every try is busy it says "download <file>: 504 Gateway Timeout, on
every try", and the About row says the download broke off, a network
problem, with Check to try again. A 404 or 403 is still asked once.

Run (mote): go test ./internal/update ok; -run Update|Download|Mirror
in internal/gui and internal/cli ok; GOOS=linux and windows go vet
./internal/update ok; gofmt clean.
Broken by hand: with the busy case off, TestDownloadRetriesABusyHost
fails at the first 504 and TestDownloadBusyEveryTryAndMissingOnce sees
1 try of 6.
Not tried: a real 504 from GitHub; the host's answer is faked.
2026-11-08 17:54:36 +08:00
yetone e484b4ff26 update: a slow download still moving is never ended by a total time; Bun, Claude Code and pf-serve too
#5572: since 80a47abba a silent download is broken off after 30s and
tried again, but the update's download still had a 10-minute total
(the update client's Timeout, the GUI run's ctx, `magpie update`'s ctx).
A download under ~140 KB/s, still receiving bytes, failed the 83 MB
Windows exe at 10 minutes part way. The stall timer is what ends a dead
one now; nothing ends one that is still moving.

- internal/update: fetch downloads through fileClient, the client without
  its Timeout. The feed and notes keep the 10-minute client. fetch's stall
  timer runs from the ask to the last byte, so a server that never answers
  still ends at stallAfter (30s), and download's retries stay bounded
  (len(retryWaits)+1 = 6 tries), so a connection that keeps going silent
  ends in about 4 minutes.
- internal/gui (Mac Stage, Windows/Linux StageBinary): run's 10 minutes
  (checkWait, a var for tests) bound only LatestIn; the download runs
  under a ctx with no deadline.
- internal/cli `magpie update` (Mac Stage, Windows/Linux ReplaceBinary):
  the same split.
- Siblings with the same fixed cap:
  - new internal/stall: Start(ctx, after) gives a ctx that ends with
    ErrStalled once `after` goes by with no byte read through w.Reader.
  - Bun (internal/plugin getURLOnce): watched with a 60s stall;
    KeepBunUpdated's 10-minute ctx around CheckBun is gone.
  - Claude Code (internal/claudecode downloadOnce, ~200 MB): watched with
    a 60s stall; keepOnce's 30-minute ctx around install is gone.
  - pf-serve (internal/pii upgrade): its 10-minute ctx is gone; get
    already had a 60s stall and the client a 60s header timeout, as the
    model's download (no total) does.
- Left as they are: plugin installs and npm updates (KeepUpdated's 10
  minutes) run `bun install`, whose network is Bun's own, small tarballs;
  rtk (5 min client), skills (2 min client), skilltree and market reads
  are small files; Grok CLI install has no cap of its own (its caller's
  ctx). None of them carries a large download behind a wall-clock total.

Run on mote (mote-run), at 49f207c78 + this change; the targeted
set again after rebasing on d4a221f79 (ok):
- go test ./internal/stall ./internal/update ./internal/claudecode
  ./internal/pii -run 'Stall|Slow|Silen|TestDownload|TestInstall|TestKeep';
  go test ./internal/plugin -run Bun; go test ./internal/gui -run
  TestUpdate: ok
- new: TestSlowButMovingIsReadWhole, TestSilenceIsAStall (no answer, part
  way), TestDownloadSlowButMovingOutlastsTheClientTimeout (client Timeout
  300ms, body ~1.2s: one try, no retry), TestUpdateSlowDownloadOutlastsTheCheckBound
  (checkWait 200ms, body ~600ms: ready), TestDownloadThatGoesSilentIsAStall
  (claudecode), TestBunDownloadThatGoesSilentIsAStall. The silent server
  after its retries stays covered by TestDownloadStallEveryTimeSaysSo
  (6 tries, errStalled).
- go test -race -count=3 ./internal/stall ./internal/update -run
  'Stall|Slow|Silen': ok
- win-run (Windows 11): ./internal/stall ./internal/update
  ./internal/claudecode ./internal/plugin with the same -run, and
  ./internal/gui -run 'TestUpdateSlowDownload|TestUpdateDownloadSaysStepAndSpeed': ok
- wsl-run (Ubuntu 24.04), -tags nogui: the same packages and ./internal/gui
  -run TestUpdate: ok
- gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; go build; GOOS=linux go build -tags nogui;
  GOOS=windows go build: clean
- Full suite: run after the push under the suite lock.

Broken by hand: fetch back on `client` fails
TestDownloadSlowButMovingOutlastsTheClientTimeout ("broke off ...
Client.Timeout or context cancellation while reading body"); the GUI's
download back under the check's ctx fails
TestUpdateSlowDownloadOutlastsTheCheckBound (state error, "context
deadline exceeded"); stall's reader not putting the timer off fails
TestSlowButMovingIsReadWhole (50 of 120 bytes); Bun's and Claude Code's
downloads unwatched fail their silent tests at the 20s bound ("context
deadline exceeded").

Not tried: a real update over a slow or throttled link, on any OS; a real
Bun or Claude Code download over one. The Mac's unpack and signature
check now run with no deadline (they had the 10 minutes before).

Fixes #5572
2026-11-07 06:09:42 +08:00
yetone 80a47abba8 update: a download says its speed and each step after it, and a silent connection is tried again (esir_tech)
esir_tech on Discord: after clicking Update the progress sat on 17% and
looked stuck. Cause: nothing watched a download that stopped sending. A
connection GitHub's asset host keeps open but silent (seen from some
networks) held the percent still until the client's 10-minute timeout,
then failed. The waits between retries showed the same still percent, and
after the bytes the Mac's unpack and codesign check showed a stale 100%.

- internal/update: fetch cancels a body that sends nothing for 30s
  (stallAfter) as a network error, so download's existing retry resumes it
  with Range. A step callback (update.WithStep) names download, retry,
  verify, unpack and signature.
- internal/gui: /api/update's downloading answer carries step, and speed
  (bytes/s over the last ~5s; it falls to 0 when bytes stop).
- app.js: the pill says "Downloading… 50% · 1.5 MB/s", "Reconnecting…",
  then "Verifying…", "Unpacking…", "Checking signature…"; its tooltip
  carries the text where the tight header hides it. Settings' Version row
  says the same after its MB count. i18n in zh, zh-TW, ja, de. Comments
  cut to stay under the core script budget (not raised).

Run on mote (mote-run):
- go test ./internal/update ./internal/gui -run 'TestDownload|TestUpdate|TestStage|Budget': ok
- new: TestDownloadStallIsTriedAgain, TestDownloadStallEveryTimeSaysSo,
  TestUpdateDownloadSaysStepAndSpeed, TestUpdateSpeedFallsWhenStalled
- GUI, chromium and webkit: update-download-steps (new: en, zh, zh-TW, ja,
  de at 900 and 420px), update-download-percent, update-download,
  update-row-steady, update-stuck, update-network, update-mirror: 178 pass
- i18n-en-no-cjk, header-relang: pass. i18n-keys "a plugin's words are
  its own" is red on origin/main 0d70f335e too (plugins/library,
  routing, usage i18n.js vs Go strings), untouched here.
- gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...: clean

Broken by hand: with the idle timer a no-op, TestDownloadStallIsTriedAgain
and TestDownloadStallEveryTimeSaysSo fail at their 20s bound (context
deadline exceeded); with speed left out of the answer
TestUpdateDownloadSaysStepAndSpeed fails ("never said how fast"); on the
old app.js/i18n.js update-download-steps fails in every case.

Not tried: a real update on a stalling network, a real Mac unpack and
codesign step (tests cover download/verify only), Windows/Linux runs.
The 10-minute total cap (client Timeout, GUI run ctx, CLI update) is
unchanged, so a moving download slower than ~140KB/s for the 83MB
Windows exe still fails at 10 minutes.

Reported-by: esir_tech
2026-11-07 05:02:02 +08:00
yetone 1fd0bb9670 update: a download whose HTTP/2 transfer broke off tries again over HTTP/1.1
biubiu8802 on X (tweet 2118719081872540038): behind their proxy every
update failed with "download broke off, a network problem", while the
same proxy carried ordinary downloads. Confirmed in the code: download()
retried up to 5 times with Range, but each try went through
netproxy.Dispatch over HTTP/2 again; Dispatch moves a host to HTTP/1.1
only on a TLS record error (recordError: bad record MAC and kin), and
"unexpected EOF" or a stream reset is not one. So a proxy that cuts
HTTP/2 streams part way cut every try the same way.

- netproxy: OverHTTP1(ctx) sends every request under ctx through
  Dispatch's HTTP/1.1 copy (route.h1), kept through With.
  BrokeOff(err) says a transfer broke off (net.Error, unexpected EOF,
  HTTP/2 stream error / GOAWAY / lost connection, a reset; not a
  context that ended). AgainOverHTTP1 runs a download once more over
  HTTP/1.1 after such a failure.
- update: the tries after a broken one go over HTTP/1.1, and still
  resume with Range from the bytes kept.
- Siblings, the other big downloads through Dispatch's client: the
  masking model and pf-serve (pii.fetch, one more try over HTTP/1.1
  from what is on the .part file), Bun's zip (plugin getURLFrom),
  Claude Code's binary (claudecode.download) and the Grok CLI
  (grokDownload) each try once more over HTTP/1.1.
- docs/subsystems/providers-accounts.md names it.

Run (mote, Go 1.26.8, at this tree, base 80ae904c2 = origin/main fetched
just before push):
- TestDownloadBrokenOverHTTP2TriesHTTP1 (httptest TLS HTTP/2 server
  that resets each HTTP/2 stream after 100KB, serves HTTP/1.1 whole):
  red with the update.go line taken out, all six tries over HTTP/2
  ("stream error: ... INTERNAL_ERROR"); green after, asked
  ["HTTP/2.0 ", "HTTP/1.1 bytes=102400-"].
- TestOverHTTP1EveryHost, TestAgainOverHTTP1, TestBrokeOff: green.
- go test ./internal/netproxy ./internal/update ./internal/pii
  ./internal/claudecode ./internal/plugin ./internal/provider: ok.
- go test ./... -count=1 -timeout 45m: 86 ok, gateway 795s and agent
  303s ok; internal/gui red only on two AppKit tests already filed for
  mote's macOS 27: TestMainWindowCorners/macOS_26_SDK (#3949) and
  TestPanelHiddenByWailsMarksPageOutOfSight (#5322). Nothing in gui is
  touched here.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet of the touched
  packages clean.

Not tried: a real proxy that cuts HTTP/2 (the reporter's); the retry of
pii, Bun, Claude Code and Grok against a real host (unit-covered by
AgainOverHTTP1 only); Windows/Linux test runs.
2026-11-06 23:44:58 +08:00
yetone 6abacd46c3 update: an Intel magpie under Rosetta updates to the Apple silicon build
cdredfox on Discord saw magpie at 150% of a core. Their goroutine dump
shows AstrLink Guard running in Go (guard.geluRow) in a darwin/amd64
build on an 8-core Mac. That is the Intel build under Rosetta: no
CoreML, and Go's kernels are translated, several times slower than
Apple silicon's build. AppAsset and BinaryAsset named runtime.GOARCH,
so every update fetched the Intel build again, with no way off it.

- internal/rosetta: Translated (sysctl.proc_translated), moved out of
  pii so the updater reads the same thing. pii's translated is now that
  var; its tests still replace it.
- update: arch() is arm64 for darwin/amd64 under Rosetta. AppAsset and
  BinaryAsset (the darwin CLI) use it. goos/goarch/translated are vars
  that tests set.
  Checked before switching: Stage downloads the zip, ditto unpacks it,
  sameSigner wants the same team, and Install renames it over the
  bundle. Nothing there reads the architecture, and the CLI's
  InstallBinary is a rename too. An arm64 build runs natively on every
  Mac that runs Rosetta.
- pii: Status.Rosetta, set on AstrLink Guard's Now() only. Privacy
  Filter's pf-serve is already Apple silicon's there (target).
- GUI: Settings > Privacy's local model line, while AstrLink Guard runs
  under Rosetta, says "On, slowly under Rosetta: the next update
  installs magpie for Apple silicon" in place of "On, on the CPU". It
  is the same one sub-line, with no new element. en/zh/zh-TW/ja/de.

Not done, as decided: skipping tool outputs for the model, or capping
its cores.

Run (on mote unless named):
- go test -count=1 ./internal/update ./internal/rosetta ./internal/pii:
  ok. On WSL magpie-desktop: the same three, plus go vet of them, ok.
  On Windows (xiaomi-gpu): -run "Rosetta|Asset|GuardNow" on update and
  pii, ok.
- go vet ./... (darwin) and CGO_ENABLED=0 GOOS=windows go vet ./...: ok.
  A Linux cross vet needs cgo for Wails, and WSL has no gtk4, so Linux
  vet covered the changed packages only. gofmt -l: clean.
- node --test privacy-model, i18n-keys, i18n-en-no-cjk (chromium +
  webkit, 5 languages, 1100/640px): 91 of 92. The new rosetta case
  passed in every engine, language and width. The one red is "a
  download is cancelled" (chromium). It passes alone, 1/1 at origin/main
  8eb219354 and 2/2 with this change. Filed as #5292 (wheelTo/viewOf
  return "" after a reload).
- go test -run "Budget|I18n|Lang" ./internal/gui: ok. Core scripts are
  1,530,017, under 1,533,802; no raise.

Broken by hand:
- arch() always the build's: TestRosettaUpdatesToAppleSilicon red (4
  cases), and TestRosettaStagesAppleSiliconsApp red, with Intel's
  2.0-amd64 app installed.
- No Rosetta in guardModel.Now(): TestGuardNowSaysRosetta red.
- The app.js line off: privacy-model's rosetta case red ("On, on the
  CPU").

Not tried:
- A real Rosetta process. mote has no Rosetta (no oahd); an x86_64 test
  binary built there didn't start. The translated check is the sysctl
  pii has used since the pf-serve fix, but this commit never saw it
  return 1.
- A real update from an Intel release to an arm64 one. The stage test
  swaps ad-hoc signed fake bundles through the real
  Stage/sameSigner/Install.
2026-11-05 08:25:53 +08:00
yetone a9a8f11e7f plugin, proc: a plugin host is waited for when it ends, not when its stdout does
acezan on Discord (v0.1.2819, Linux x86_64, a systemd service): after
47 hours, 57 <defunct> magpie-bun children of magpie, growing toward the
unit's TasksMax until a restart.

One cause: the plugin host's only cmd.Wait ran in host.read after its
stdout reached EOF. A program a plugin started that kept a copy of the
host's stdout (Bun.spawn given Bun.stdout, which host.js's spawn guard
doesn't catch, #5063; a daemon left behind) held that pipe open past the
host's end, so EOF never came, Wait never ran, the host was never marked
dead, and every host stopped (Restart, a moved proxy, hostStale) stayed a
zombie until magpie quit. Reproduced on Linux (WSL magpie-desktop,
Bun 1.4.2): one more Z-state bun under the test process per Restart,
1, 2, 3, 4 over four rounds. The other cause, magpie web's restart to
update leaving the running host behind its exec (#3285), is the next
commit.

- proc.Output (new, internal/proc/output.go) gives a command's stdout and
  stderr pipes of magpie's own and waits for the command the moment it
  ends. Its readers then have OutputGrace (2s) to read the last lines;
  the pipes are closed after that, which ends a read held up by a
  grandchild. startOn uses it, and a reap goroutine fails the host when
  its child ends. host.read no longer calls Wait. The tests' fake hosts
  (no child) keep cmd.Wait.
- Every other start that wasn't waited for now goes through
  proc.StartReaped (Start, then go cmd.Wait()). Process.Release doesn't
  reap on Unix: codexrelay.Start (a relay that can end while magpie
  runs), tui serveInBackground, uninstall's startAfter, update's
  runAfterExit and OpenBeside (no Wait at all), and Windows' Reexec.
- TestEveryStartedCommandIsWaited (internal/proc) parses every non-test
  .go file. In each function, an x.Start() on a command needs an
  x.Wait(), or x handed on (a call's argument, a struct field), and
  .Process.Release() is refused. It found exactly the sites above.
- docs/subsystems/provider-plugins.md says how the host is reaped.

Checked and left as they are (each waits): the StartTree callers
(provider/install, library mcp_run and mcp_check, gateway claude_warmup
and claude_subscription), pii/serve, provider grok and claude_signin,
claudetui child_unix and wslread, awake, every other bun start (bun.go,
bunupdate, store, dist use Output/CombinedOutput).

Run at 82460a2f9 (on origin/main 40a287b21):
- mote (macOS): gofmt -l clean; go vet on the touched packages,
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: ok.
  go test -count=1 -timeout 45m ./internal/plugin ./internal/proc
  ./internal/codexrelay ./internal/tui ./internal/uninstall
  ./internal/update: all ok. -race -count=3 of the new proc tests: ok.
- WSL magpie-desktop (Linux): the same six packages ok, including
  TestHostReapedWhileItsChildHoldsStdout with a real Bun host; -race
  -count=3 of it and the Output tests: ok.
- Windows (xiaomi-gpu), at the tree before the rebase (base 5ee5274bd):
  proc and codexrelay ok. plugin and update had TestPiPackage,
  TestLoadConcurrentWithSavesAndEdits and TestPackagedByDpkg red; each
  fails the same at untouched origin/main 40a287b21 on that box, 3 of 3,
  and is filed (#4115, #1827, #4603).

Broken by hand, each red:
- host.go back to StdoutPipe with Wait only after EOF:
  TestHostReapedWhileItsChildHoldsStdout fails on Linux ("the host isn't
  marked ended 15s after Restart").
- Output.Start waiting for the readers before Wait:
  TestOutputWaitsPastWhatHoldsIt fails (not waited for in 10s).
- codexrelay back to Process.Release: TestEveryStartedCommandIsWaited
  names relay.go:89 and :92.

Not tried: a full go test ./... (mote and WSL were each running other
sessions' package runs, load 39 and 110); a real magpie serve or web
running for hours on Linux; the host test on macOS (no /proc; the
Output test runs there). Not changed: killing what a host left behind
(its process group) when it is stopped; an orphan like the sleep above
stays in the service's cgroup until it ends on its own.

Reported by acezan on Discord.
2026-11-03 17:58:31 +08:00
yetone b81956189a update: a Windows update held by a scanner recovers instead of failing 416 on every try (mycf_711 on Discord)
mycf_711 (Win11 26200, 0.1.2364 -> 0.1.2404): the first try failed at the
trial start with "fork/exec ...\magpie.exe.new: The process cannot access
the file because it is being used by another process", and every try
after it failed at once with 416. Both confirmed on xiaomi-gpu with the
old code and a real handle held on the download.

Cause: something (often an antivirus) holds the staged magpie.exe.new.
CreateProcess fails with a sharing violation and that was reported as a
BlockedError (a policy block, which stops the clock checks). download()
dropped os.Remove's error, so the held, complete file stayed, and fetch
resumed it with "Range: bytes=<size>-", which no host can satisfy.

Changes in internal/update:
- download clears the earlier file through clearFile; a held file gives a
  clear error ("another program has it open...") instead of being ignored,
  and every other Remove error is returned, not dropped.
- fetch: a leftover that is already whole and matches the hash is used with
  no request; one that is whole but of other bytes starts over; a 416 starts
  over from zero once.
- binaryStage takes a fresh name (magpie.exe.new-*) when the usual one is
  held, and stagedFiles/RemoveStaleNew find and clear those too.
- the trial start waits while the download is held (waitHeld, as the aside
  moves do); still held after the wait is an ordinary error that keeps the
  download, not a BlockedError.
These run on macOS and Linux too (the held case can't happen there, the 416
and whole-leftover cases can).

Run at 003e55115 (on origin/main 7428f3229):
- mote: gofmt -l clean; go vet ./... for darwin, linux and windows; builds;
  go test -tags nogui -count=1 -timeout 45m ./...: every package ok except
  internal/gui, red on TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestColdTurnsTaken (#4510), both filed and in files this change doesn't
  touch.
- xiaomi-gpu (win-run go test ./internal/update/...): 88 PASS, -count=3 of
  the new tests ok; TestPackagedByDpkg red, the same on main (#4603: the
  fixture name magpie:amd64.list is an NTFS stream).
- xiaomi-gpu internal/gui update tests: TestUpdateThatWontStart red, the
  same on main (#4115).
- wsl-run (magpie-desktop) go test -tags nogui ./internal/update/...: ok.

Rebased on origin/main e40675cc1 (9 commits, none in internal/update) and
rerun there: mote vet (darwin, windows) and go test ./internal/update/... ok;
xiaomi-gpu the same, red only on TestPackagedByDpkg (#4603).

Broken by hand: origin/main's update.go with only the removeFile shim added
(scratchpad oldcode copy). mote: 5 red (WholeFileAsksNoRangePastTheEnd,
WholeFileOfOtherBytesStartsOver, 416StartsOverOnce, SaysAHeldLeftover,
StageStepsRoundAHeldLeftover). Windows: 8 red, those 5 plus
StageStepsRoundAFileHeldOpen ("416 ... asked [bytes=19-]") and both Trial
tests, with the reporter's own fork/exec message as a BlockedError.

Not tried: a real release update end to end on the reporter's machine, or
with a real antivirus holding the file; which program held it isn't known.
macOS Stage shares only the fetch changes.

Users already on 0.1.2364-0.1.2421 run the old updater: after a reboot (the
hold ends) Check for updates usually gets through; otherwise download
magpie from https://usemagpie.ai and open it.
2026-11-01 02:21:55 +08:00
yetone 244cf49371 update: a restart magpie makes by itself comes back as it was, without taking focus
xyxyxy_15591 (Discord #feedback) asked for a silent auto-update: once an
update is in, the window shouldn't pop up. With "Restart automatically"
(Settings, beside Version) on, the window state was already kept (a
closed window came back as the tray icon only), and What's New stays
quiet after an in-app restart. What did show was magpie taking focus:

- macOS relaunched with `open -n` and no `-g`, so LaunchServices brought
  magpie to the front even when only the menu-bar icon came back;
- with the window open, showHere's Focus() activated the app (every OS);
- joining the Dock activated magpie, and with Dock on Wails' Regular
  policy activated it at launch.

Now a restart magpie makes by itself (AutoRestart, `magpie update` from
a terminal) writes a one-shot restart-quiet mark (read once, good for
10 minutes). The next start reads it: `open -n -g`, no Focus(), the Dock
joined without activating, Accessory policy at launch and the Dock set
afterwards. A restart the user clicks removes any mark and comes to the
front as before. `open` gets -g also whenever no window is wanted. No
new setting: zero-config, the existing switch is the one asked for.

Run (base 841326709, rebased on ced880ef0, no upstream change to
these files):
- mote: gofmt -l clean; go vet ./internal/gui ./internal/update
  ./internal/cli; GOOS=linux go vet -tags nogui ./...; GOOS=windows go
  vet on gui/update/cli: clean. internal/update ok;
  TestRestartBySelfComesBackQuietly, TestUpdateThatWontStart,
  TestWhatsNew*, *Handover* ok, except
  TestHandoverLeavesTheMenuBarIconForTheNextMagpie, killed at 30s the
  same at origin/main 7b09d2c95 (AppKit on mote, #4125).
- Windows (win-run, CGO_ENABLED=0): internal/update ok; internal/gui
  reds the same set as origin/main 7b09d2c95 (#4115, #1827, #2958,
  #4514).
- WSL (wsl-run): full `go test -tags nogui -timeout 45m ./...`, 80 ok;
  reds TestInstalledVersion, TestGrokInstalled, TestOmpDetectedWithPiDir
  (#4033, #3548), TestNoCommandBypassesProc (#4491),
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514) all red the same at
  origin/main 7b09d2c95; TestColdTurnsTaken (#4510) passed there alone.
  internal/gui + internal/update rerun at this head: internal/update ok; internal/gui red only TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestColdTurnsTaken (#4510).

Broken by hand: without -g, TestRelaunchOpen and
TestRelaunchOpenTriedAgain fail; without markQuietRestart,
TestRestartBySelfComesBackQuietly fails "window true: the start after a
restart by itself isn't quiet"; without the unmark on a clicked restart,
it fails "a restart the user asked for is marked quiet".

Not tried: a real update restart on any OS (`open` of a GUI app over
ssh on mote fails, RBSRequestErrorDomain 5), so -g and no-focus weren't
seen in a real session. Windows' ShowWindow inside Wails may still
bring the window forward when it was open; Linux window managers were
not tried. No GUI assets changed, so no Playwright run.
2026-10-31 15:56:40 +08:00
yetone 482e883142 update: a Windows magpie on the Desktop leaves no magpie.exe.new or magpie.com there
nianshou5 on Discord (#help, Windows): magpie.com and magpie.exe.new
showed on the Desktop and came back after being deleted. Both were
written beside magpie.exe:

- magpie.exe.new is the update the GUI downloads as soon as it is out
  and swaps in at the next restart. StageBinary put it beside the
  program whenever that folder was writable, so it sat on the Desktop
  until a restart, and a deleted one was downloaded again by the next
  check.
- magpie.com (#3737) is written at every start while the app's folder
  is on PATH, and Settings > Command line's Add puts that folder on
  PATH, so deleting it on the Desktop lasted until the next start.

Now:

- StageBinary downloads into magpie's cache, in a folder of this
  program's own (update/<hash of the exe path>), when a rename from
  there reaches the program's folder (renamesInto, a real probe: the
  swap must stay one rename on one volume). With the cache on another
  volume it goes into a hidden .magpie-update folder beside the program
  (FILE_ATTRIBUTE_HIDDEN on Windows). A folder magpie may not write is
  unchanged (cache, moved in as administrator). The stage folder is
  removed after the swap or a failed download.
- At start RemoveStaleNew looks in every place a download may be,
  magpie.exe.new beside the program included, and removes one no newer
  than the running version (same bytes, or an older file version); a
  newer one stays, as before.
- Settled (the installed copy opened from a Desktop/Downloads one)
  also removes the update downloaded for that one, which nothing will
  put in now.
- In a download folder (Desktop, Downloads, a temp folder, as
  isDownloadFolder already says) a start only keeps an existing
  magpie.com up to date and never writes a missing one; Add still
  writes it. Any other folder on PATH is as before. A Desktop
  magpie.exe that opens the installed one (Settle) already wrote none.

Run:
- Windows (win-run, xiaomi-gpu, sandbox HOME from testenv), a repro
  test with the running test binary standing for magpie.exe on a
  Desktop on PATH: at origin/main 72ed121fd StageBinary staged
  test.test.exe.new beside it, and magpie.com came back after delete +
  start; with this change the download was in
  AppData\Local\magpie\update\<hash>\ and magpie.com stayed gone.
- Windows: a real program (whoami.exe) staged into the cache passed the
  real trial start (canStart) and was swapped in for a Desktop
  magpie.exe with the real moveAside/moveIn; the stage folder was gone
  after.
- At the pushed head (rebased on d6beb9975): go test ./internal/update
  on mote and on Windows: ok. Before the rebase also on Linux (wsl-run). gofmt, go vet ./internal/update (darwin, linux, windows),
  GOOS=windows go vet ./internal/gui ./internal/cli: clean.
- go test ./internal/gui ./internal/cli on Windows: TestUpdateThatWontStart,
  TestLodyImportHandoff, TestImportStatusUnreadableIsUnknown,
  TestAionUiImportRow (#4115), TestGatewayHeldByAContainer (#2107,
  #3649) and TestLibraryMCPHub (#4140) red, the same 6 when run at
  origin/main 72ed121fd.
- Full suite on mote (-timeout 45m): started at the pre-rebase tree
  (same update changes, base 72ed121fd) and still running at push; its
  result and any red go in a follow-up.

Broken by hand: staging back beside the exe, the download-folder rule
in EnsureCompanion off, removeStaged out of Settled: the new tests
(TestUpdateStagedOutOfTheProgramsFolder, TestUpdateStagedHiddenWithoutTheCache,
TestStartClearsAnOlderDownloadBeside, TestNoCompanionPutBackOnTheDesktop,
TestSettledClearsOnlyMagpiesFiles, TestNoCompanionBesideAForwardingDownload)
went red.

Not tried: a real GUI self-update of a release build on the Windows
desktop, a cache and Desktop on separate real volumes (the hidden
fallback was tested with no cache), the reporter's own machine, and a
real terminal's `magpie` (unchanged code outside download folders).
2026-10-31 00:21:26 +08:00
yetone eed140c4d9 update: a Mac update no longer leaves a second magpie in Spotlight (#3965)
Stage unpacked the new app to /Applications/.magpie-update/app/magpie.app
and Install moved the old one to .magpie-update/old.app. LaunchServices
registers a folder ending in .app in /Applications within seconds, and
Install only deleted the folder, so Spotlight kept listing the gone path
as another magpie.

- Stage ditto's the zip (one top folder, magpie.app, checked against the
  real v0.1.2119 zip: no FinderInfo bundle bit, no __MACOSX) into
  .magpie-update/unzip and renames magpie.app to .magpie-update/payload
  at once, then has lsregister -u forget the unzip path in case it was
  seen in that moment. codesign verifies a bundle named payload the same
  (checked on the real zip: verify ok, a tampered copy fails).
- Install and InstallAsAdmin move the old app to <stage>/old, and remove
  filepath.Dir(staged), which is still .magpie-update (or the cache's
  update folder on the admin path); renames stay on one volume.
- ForgetOldStaging runs once from the GUI's updater start, in a
  goroutine: lsregister -u on .magpie-update/app/magpie.app and
  .magpie-update/old.app beside the app and in ~/Library/Caches/magpie/
  update. lsregister is /System/Library/Frameworks/CoreServices.framework/
  Frameworks/LaunchServices.framework/Support/lsregister (present on
  macOS 27.2); failures are ignored, a 10s cap, marker in magpie's cache.
  /Volumes/magpie (an old DMG) is left alone.

Run at this head (base ffa07395e):
- mote (macOS 27.2): gofmt -l clean; go build, GOOS=windows go build,
  GOOS=linux go build -tags nogui; go vet, GOOS=windows go vet and
  GOOS=linux go vet -tags nogui on internal/update, internal/gui,
  internal/cli; go test internal/update internal/gui internal/proc
  internal/appdir: build and vet ok;
  update, proc, appdir ok; gui FAIL only in TestMainWindowCorners/
  macOS_26_SDK (the titlebar toolbar on macOS 27), already filed as
  #3949 and not in code this touches
- win-run (xiaomi-gpu, Windows 11): go test ./internal/update ok.
- wsl-run (magpie-desktop): go test ./internal/update ok.
- Real LaunchServices on mote, a fake bundle id (com.example...) in
  /Applications/lstest-3965, not magpie.app: the old flow by hand
  registered .magpie-update/app/magpie.app within 30s and kept it after
  the folder was deleted. A throwaway test running this Stage + Install
  with the real lsregister: after 45s staged and 15s installed,
  lsregister -dump shows only lstest-3965/magpie.app; with stagedName
  set back to magpie.app the same run shows .magpie-update/magpie.app
  registered (red). ForgetOldStaging with the real lsregister removed
  both registered .magpie-update paths after their folders were deleted.
  Everything registered was unregistered and the folder removed.

Broken by hand, each red: asideName "old.app" (TestInstallAsAdminAside-
IsNoApp), stagedName "magpie.app" (TestInstallStagesNoApp, TestStage-
UnpacksNoApp), RemoveAll two folders up as before (TestInstallStagesNoApp:
the Applications folder went with it), no unregister of the unzip path
(TestStageUnpacksNoApp), no marker (TestForgetOldStaging).

Not tried: a real magpie update of the installed /Applications/magpie.app
with Spotlight's UI (the fake bundle stood in), the administrator-password
path for real, the full go test ./... suite.
2026-10-30 09:23:35 +08:00
yetone 6335625a60 update: a download that breaks off is tried five more times, from where it stopped
AIMetaPhD on X: on Windows, 0.1.1615 couldn't download 0.1.1618;
GitHub's asset host dropped the connection ("EOF"). The download was
tried three times, two and four seconds apart, each time from byte zero,
and then it gave up. The error also carried the full signed redirect
URL, which the GUI showed.

Now a try the network breaks off (the connect, or the body part way) is
tried again after 2, 4, 8, 16 and 30 seconds. Each later try asks with
Range for the bytes still missing. A host that sends 200 instead has the
file written again from the start, and a 206 whose Content-Range doesn't
start where the file ends is refused. The SHA-256 from the feed is
checked over the whole file read back from disk, so the bytes from
earlier tries are covered. A failure that isn't the network's (a 404, a
checksum mismatch, a write that fails) is not tried again, and the file
is removed. The error is a NetError that names the file and the cause
("the download of magpie.exe.new broke off (EOF)"), never the address.

Release timing was checked and is not the cause. v0.1.1618's
magpie-releases release was created at 16:32:48Z, its assets were
uploaded from 16:36:13Z to 16:36:17Z, and it was published at
16:36:18Z. The feed reads only releases/latest, which skips drafts, and
needs SHA256SUMS, so it couldn't name 1618 before its files were there.
The URL in the screenshot is the asset host's redirect, which exists
only for an uploaded asset.

Run: go test ./internal/update ./internal/cli (ok); gofmt -l clean;
GOOS=linux and GOOS=windows go vet ./internal/update. New tests run on
httptest servers: a body cut mid-stream twice (resumed with
bytes=102400- and bytes=307200-, file and progress whole), a resume
with the wrong bytes (checksum fails, nothing kept), a connection hung
up before any answer behind a redirect to a ?sig=&jwt= URL (six tries,
and the error holds no URL), and a 404 (one try).

Broken by hand: without the Range header the resume test is red
(ranges "" "" ""); with the NetError keeping the url.Error the address
test is red (the signed URL in the text); with three tries it is red
(tries = 3, want 6).

Not tried: a real self-update on this machine or the Windows box, or a
real cut connection to GitHub. The China mirror and the user's
UpdateMirror get the same Range header; a mirror that ignores it sends
200 and the file is written again from the start.
2026-10-27 01:34:26 +08:00
yetone 4a33cf0a98 update: a Stable channel in Settings → About, and magpie update channel
ssharpcc on X reads every changelog before updating, for fear of a ban
when behind, and with many releases a day that is a lot of reading.
Settings → About → Update channel (zh: 更新渠道, 稳定版 / 每个版本) picks
Every version, the default and today's behaviour, or Stable: one version
a week, the newest that had been out three days as the week began
(Monday 00:00 UTC), and an urgent release at once. usemagpie.ai chooses
it from the release list (the previous commit); a release is urgent when
a line of its notes starts with "**Urgent release:**", which
magpie-releases' release run writes from an `Urgent: <why>` trailer
(magpie-releases 73f6cff).

- settings: updateChannel, "" or "stable"; anything else is refused.
- update: on Stable the feed is asked with channel=stable; What's new
  shows every release since the installed one (up to 1500) instead of
  the newest 40, so a week's notes read as one list.
- gui: the row is segs, never a <select>; a save that doesn't send the
  channel keeps it; switching asks the feed again at once, and a
  download from every version newer than Stable's pick is dropped,
  never restarted into. What's new's notes are kept per channel.
- cli: magpie update channel [stable|every] ("all" too), and it says
  which with nothing after it.
- docs: reference.md's Update channel (the rule and the marker); the
  privacy pages (en, zh, ja) name ?channel=stable on /api/latest.

The full Go and GUI suites were not run: the disk was at 3 GB free and
other sessions had GUI suites and a 45-minute gateway run going the
whole time.

Run, at this tree before the rebase:
- gofmt -l (clean); go vet on darwin, GOOS=linux -tags nogui and
  GOOS=windows for ./internal/update/... ./internal/cli/...
  ./internal/settings/... ./internal/gui/.
- go test -count=1 ./internal/update/... ./internal/cli/...
  ./internal/settings/...: ok. ./internal/gui -run
  'TestUpdateChannelSwitch|TestWhatsNewKeyedByChannel|TestCoreScriptBudget':
  ok (the app.js budget passes).
- GUI, chromium and webkit: update-channel (22: en, zh, zh-TW, ja, de at
  900 and 420 wide: default lit, Stable saved, kept by another save,
  kept over a reload, Every saved back, no click scrolls, no sideways
  scroll at 420), i18n-keys, gui-ja, gui-de, gui-zh-tw and every
  update-*.test.cjs: 253 of 253 pass.
- The live feed: /api/latest?channel=stable answers 0.1.1327 (out
  2026-10-22 21:55 UTC, the last before Friday 10-23 00:00) with 15
  assets after the first real cron run filled the ledger (400 releases
  back to 10-10); /api/notes 0.1.1200..0.1.1327 gives 124 notes, none
  empty (1213 and 1218 were never published).

After rebasing on afc99490f: TestCoreScriptBudget, the channel Go tests
(update, cli, gui) and GUI i18n-keys + update-channel (both engines,
26 of 26) pass again.

Broken by hand, each red: the feed asked without channel=stable
(TestLatestAsksTheChannel); Stable capped at 40 (TestStableNotesAreAll);
any channel saved (TestUpdateChannelSaved); "all" dropped
(TestUpdateChannelCmd); a save without the field clearing it, no new ask
on a switch, the newer download kept (TestUpdateChannelSwitch); one
notes key for both channels, What's new capped at 40 on Stable
(TestWhatsNewKeyedByChannel); app.js's other saves dropping the channel,
Stable's click saving "" (update-channel 11 of 11 red); the zh label or
a de subtitle taken out (update-channel and i18n-keys red).

Not tried: the full go test ./... and the whole GUI suite (above); a
real app switching channel against the live feed; Windows and Linux
runs (vet only); a real urgent release.

Requested by ssharpcc on X.
2026-10-26 21:09:44 +08:00
yetone 27a8255fd7 update: the Mac relaunch opens a new instance (open -n), not a reopen of the gone one (Linka on Discord)
Linka's log (Discord, macOS 27.0.1, v0.1.1308) shows the cause of the
"magpie stays closed after updating itself" report that molvqingtai also
hit with the screen locked. After the old process's "Termination
complete", open found LaunchServices still holding the gone app as
running ("Specified target process 41267 does not exist"), so it sent
that process a reopen Apple event (aevt/rapp) instead of launching the
bundle, and failed with -600 procNotFound ("LAUNCH: Launch failed in
CSUI"). The retries from fb23bca5c asked for the same reopen each time.

Fix (internal/update/update.go): relaunchOpen is `open -n <bundle>`,
with `--args tray` when no window was up. -n asks LaunchServices for a
new instance, so it launches the bundle rather than look for a running
one. The retries and f3eb92924's direct start of the bundle's program
stay as the backup, with relaunch.log.

A magpie that really is up still has one instance: the new process
takes internal/gui's instance lock (a flock on app-<hash>.lock, keyed by
the program's path), finds it held and hands over (runningAlready): a
tray start ends, a window start asks the running one to show its window.

Other opens, checked: OpenBeside (a95f0b83f, the handover restart) uses
open -n already, and when it never starts the new version the handover
falls back to Relaunch after helloWait. The Codex app restart
(673651e8d, internal/agent/codex_app.go) opens another app and is
unchanged, as are the link and `open -b` handovers in instance_darwin.go.

Tests: TestRelaunchOpen wants -n in both commands, and
TestRelaunchOpenTriedAgain's fake open records its arguments and wants
"-n <bundle> --args tray". fakeOpen names the .app argument in its -600
text rather than $1. Red by hand: with -n dropped from relaunchOpen,
TestRelaunchOpen failed for both commands and TestRelaunchOpenTriedAgain
failed with opened "<bundle> --args tray"; green with it.

Real run: a scratch Lock.app (LSUIElement, ad-hoc signed) whose program
takes the same flock as holdInstance and logs its args. Real
`open -n Lock.app --args tray` twice, 1.5s apart: the first got
args=[tray] and held the lock, the second got args=[tray], found the
lock held and handed over. With one instance up, a plain
`open Lock.app --args tray` exited 0 and started nothing (routed to
the running one), the shape of Linka's reopen. The scratch app was
unregistered from LaunchServices afterwards.

Run at 17a2b00ef plus this change: gofmt -l internal/ (clean);
go vet ./... (darwin); GOOS=linux go vet -tags nogui ./...;
GOOS=windows go vet ./...; go test -count=1 ./internal/update (ok).
Rebased onto f4640c0ae (sessions GUI only); go test -count=1
./internal/update ok again at the pushed tree.

Not tried: a real update with LaunchServices holding a stale
registration (Linka's case) or with the screen locked; the real magpie
binary under open -n (the handover's OpenBeside has run that way since
a95f0b83f).
2026-10-24 02:32:29 +08:00
yetone a95f0b83ff gui: a restart to update hands the gateway to the new version (xuanwo on X)
Before, a restart to update ended the gateway, so it waited until no
agent request was in flight (#577). An agent busy for hours held the
update back, and Restart now cut its replies off. On a Mac and on Linux
the restart now starts the new version beside the old one and hands it
the gateway's listening socket. The new version takes every new
connection at once. The old one stops accepting, finishes the requests
it has (up to 15 minutes, as `make dev` already gave), then quits.
Nothing an agent sends is refused or cut short.

How (docs/subsystems/gui-shell.md, "A restart to update hands the
gateway over"):
- internal/handoff, new, darwin and linux. The old magpie opens a unix
  socket in a 0700 temporary folder and writes handover.json (fresh for
  2 minutes) in its config folder. The new one finds it, says Hello, and
  gets the listening socket by SCM_RIGHTS with the address, its pid and
  a callbacks socket. Only the same program (same path, same uid) is
  given it. When TMPDIR is too long for a socket path (sun_path is 104
  bytes on a Mac), the folder goes in /tmp (sockDir).
- gateway: Inherit/Listen serve on the socket given, and acknowledge
  once serving. HandOff gives the old one handedOffDrain (15m) instead
  of the 2s an ordinary end gives. A Claude Code run of the old magpie
  whose helper calls its tools on the port gets those calls passed back
  to the old one over the callbacks socket (forwardCallback, mcpCall,
  ownCallback). The bridge's turns are counted on their own
  (Busy.Bridge, BridgeLast).
- gui: restartInto calls beginHandover (OpenBeside `open -n` on a Mac,
  StartBeside for the binary on Linux). On the new version's ack, the
  old one hides its menu bar icon, panel, window and Dock icon (Mac),
  ends its backend, waits for its requests, and quits. OnShutdown
  leaves Codex's failover, the thread port and the install to the new
  one, which serves the gateway they point at.
- Never two on screen. Mac: the old one lets go of its instance lock
  just before giving the socket and takes it back if the handover
  fails, then hides on the ack. Linux: Wails holds the D-Bus name until
  exit, so the new one serves the gateway at once but puts its tray up
  only once the old pid has exited (awaitExit, 16m at most). Until
  then the old tray stays.
- What a handover can't carry: the subscription bridge's Claude Code
  turns live in the old process, so the restart still waits for those
  (restartBusy = blocking(Busy, true)), along with turns parked on
  tools. Every other request is not waited for. The update badge, the
  Updates page and Settings' "Restart automatically" say so, in every
  language in i18n.js.
- A handover that isn't made restarts as before: socket not opened,
  new version not started, no hello in 60s, no ack in 90s. Because the
  restart didn't wait for the requests in flight, it now waits for
  gatewayBusy to be idle (fallbackWait, 15m at most) before it quits
  and relaunches, so a failed handover never cuts a request.
- The overlap. The instance lock is handled as above. Both processes
  write: the sticky routing is flushed before the hand (FlushSticks),
  and files go through the existing locked or atomic writes. Counters
  (RPM, concurrency) are per process for the overlap (gateway-routing
  Constraints). OAuth refresh: the previous commit locks Codex's and
  the ChatGPT API's refreshes across processes. The rest were already
  locked or don't rotate (providers-accounts Constraints).
- Not changed: Windows (no SCM_RIGHTS; it restarts as before and still
  waits for idle, #577), `magpie web` (re-execs in place), and
  `make dev` (its own Handover). MAGPIE_NO_HANDOVER=1 turns it off.

Found by the sandbox run, fixed here: in run 2 the sandbox's long TMPDIR
made the socket bind fail ("bind: invalid argument"). The restart fell
back at once, cut the stream at chunk 6 (curl exit 18), and 4 of 381
requests got no answer over ~2s. Two fixes: sockDir (/tmp fallback), and
the fallback that waits for idle.

Tests (each red when broken by hand or on the old code):
- gateway/handover_test.go: TestHandedOverGatewayFinishesItsStream
  (drainFor without handedOff: "the old one ended with a stream in
  flight"; takeAck off: "the new one never said it serves").
  TestToolCallOfTheMagpieBeforeGoesToIt (mcpCall forward off: 404;
  ownCallback forwarding off: 401). TestInheritedForAnotherAddressIsLetGo,
  TestCallbacksSocketServesOnlyToolCalls, TestBridgeTurnsCount,
  TestSameAddr.
- handoff/handoff_test.go: TestHandOverListener, TestNoAckKeepsTheSocket,
  TestTakeOnlyAFreshOfferForThisProgram, TestCloseRemovesOnlyItsPointer,
  and TestOpenWithALongTemporaryFolder (red on the old Open: "bind:
  invalid argument").
- gui/handover_unix_test.go: TestRestartHandsTheGatewayOver, cross-
  process. The test binary re-execs as the new magpie. A stream through
  the old one finishes whole, requests during the restart are all
  answered, the next ones reach the new pid, and the old one quits only
  after its stream. On the old restart it is red: "quit with a reply
  streaming". TestHandoverNotMadeRestartsAsBeforeOnceIdle ("never says
  hello", "doesn't start") is red on the code before the fallback
  drain: "quit with a reply streaming" / "the restart didn't try to
  hand over".
- gui/handover_test.go: TestRestartWaitsForWhatAHandoverCantCarry,
  TestHandsOverOnlyWhereItCan.
- update/relaunch_open_test.go: TestOpenBeside,
  TestStartBesideWaitsForNothing.
- GUI: update-wait.test.cjs (the handover wording on the badge and
  page), update-restart.test.cjs (Settings' description).

Real run, Mac, sandbox (env -i, HOME and XDG_CONFIG_HOME in a scratch
folder, a long TMPDIR, MAGPIE_ADDR 127.0.0.1:63249, MAGPIE_UPDATE_FEED
pointed at a fake feed). The app is -tags production, ad-hoc signed,
bundle id com.yetone.magpie.sbhandover, built as 0.1.9001 and 0.1.9002.
autoRestart is on. A fake upstream streams 100 one-second chunks. The
real app found the update, downloaded and staged it, and restarted with
the stream in flight (run 3, at this change's tree before the rebase):
- 18:31:43, pid 59833 serves. 18:31:51, the new pid 60477 serves; v1
  logged "magpie 0.1.9002 (pid 60477) serves the gateway now".
- Requests: 375, failed 0. 19 were answered by 59833, then 356 by 60477.
- The stream got all 100 chunks, END and [DONE] at 18:33:24, curl exit
  0, 92s after the hand. 59833 exited within 3s of the stream's end.

Run at the pushed head (7a5bca443's tree, on origin/main f3eb92924),
one suite at a time, each log tee'd:
- gofmt -l internal/ cmd/: none. go vet ./... (darwin), GOOS=linux go
  vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -count=1 -timeout 45m: internal/handoff ok, internal/update
  ok, internal/gui ok (95s), internal/provider ok, internal/gateway ok
  (367s).
- TestCoreScriptBudget: app.js is 1,338,901 of its 1,338,929. My
  additions first went 372 bytes over after the rebase; the badge's two
  wordings now share one args object and the comments I added were cut,
  with no budget raised.
- GUI (NODE_PATH playwright 1.62.0, both engines): i18n-keys, every
  update-*.test.cjs (update-wait 22/22, update-restart 22/22, update-stuck
  40/40 among them), gui-de, gui-ja, gui-zh-tw: all pass.
- f3eb92924 (the Mac relaunch's exec fallback) landed under this. A
  handover that never gets its hello falls back to update.Relaunch, which
  now carries that fallback; OpenBeside keeps open's tries only, since
  the old one is still running then and the fallback follows.
- Linux, Docker golang:1.26.8 with -tags gtk3 (before the rebase): the
  handoff package, the gui handover tests including the cross-process
  TestRestartHandsTheGatewayOver, and the gateway handover tests pass.
- Full GUI suite at f09e9a066 (before the rebases, load ~250 from other
  sessions): 11958 tests, 61 failed in 22 files. 13 pass alone (fonts,
  plugin-updates, rail-tip, routing-keys-fold, routing-mode-goes,
  routing-model-rest, routing-rule-remove, routing-went-on, search-keys,
  segment-press-dialog, sidebar-overlay-scrollbar, usage-overview-fold,
  usage-pack); load reds of this kind are #3393. 9 fail the same on
  origin/main 843417957, each filed: library-mcp-health-wsl #3350,
  quota-count-wrap and quota-name-translated #2228, quota-reads #2150,
  s3-sync #2448, usage-agents-hide #2276, usage-checkin #2549/#3091,
  usage-fold #2163, usage-ledger #3104.

Not tried:
- Windows: unchanged by design, nothing to run there beyond vet.
- A real Linux desktop app. The tests ran in Docker (above); the D-Bus
  wait (awaitExit) was not seen in a real tray.
- Whether the menu bar showed two birds for a moment on the Mac. B's
  tray goes up as it starts, and A hides on the ack, which follows B's
  first listen. They are close, but not ordered, and I didn't capture
  the screen.
- The Mac's real bundle id and LaunchServices registration
  (com.yetone.magpie), the real signed and notarised update, and real
  accounts (the run used a fake upstream).
2026-10-24 02:20:38 +08:00
yetone f3eb92924e update: the Mac relaunch starts the bundle's program when open never works (molvqingtai on Discord)
molvqingtai (Discord, 10-24): on macOS, magpie's restart after a
self-update still leaves it closed on versions after fb23bca5c, and only
while the screen is locked. Their 10-22 log (v0.1.1314) had the old
process exit 0 and `open` of the bundle fail ~160ms later with -600
(procNotFound), LaunchServices still sending to the gone process.
fb23bca5c tried that open again for ~13.5s (8 tries), and the report
says that isn't enough: LaunchServices can go on refusing for as long as
the session is locked, and the relaunch had nothing but LaunchServices
to start magpie with. With magpie closed, Prevent sleep is off too: the
Mac sleeps and the agents lose their connection.

Cause, as far as it could be checked: every route back went through
LaunchServices. A locked session was not reproduced here (the screen was
never locked), so "refuses for as long as it is locked" is the report's
shape, not something observed.

Fix (internal/update/update.go): relaunchCommand is now relaunchScript
over openWaits. The same open with the same pauses runs first; once the
last try has failed, the bundle's own program (Contents/MacOS/<the
CFBundleExecutable its Info.plist names, else this one's name, else
magpie>) is exec'd by the helper shell with RelaunchArgs: `tray` when no
window was up, `gui` when one was. That is what the Open at login launch
agent runs (ProgramArguments: Contents/MacOS/magpie tray), so it needs
nothing from LaunchServices. The shell is runAfterExit's, in a session of
its own (#2362); `exec` makes it the new magpie, so there is no shell
left to exit and take it with it. The instance lock is a flock on a file
keyed by the program's path, the same for open and for this start, so a
late open from LaunchServices hands over to the one already running.

Each try is written to relaunch.log in magpie's own folder
(appdir.Config(), ~/.config/magpie on the Mac): "magpie has exited;
opening <bundle>", then per try "open try N: exit S <open's stderr on
one line>", then "open gave up after N tries; starting <program> <args>"
or "no executable at <path>". The file is moved to relaunch.log.old past
64KB. A missing log folder writes nothing and changes nothing else.

Tests (internal/update/relaunch_fallback_test.go), with fakeOpen from
relaunch_retry_test.go first on PATH answering with the -600 text and a
fake bundle whose program writes the arguments it got:
- TestRelaunchStartsTheBundleWhenOpenNeverWorks: through runAfterExit
  after a gone pid, open refused every time; the program runs with tray
  (no window) and gui (window), after len(waits)+1 opens.
- TestRelaunchLogsEachTry: the log has the opening line, each try's exit
  status with open's -600 text, and the fallback's program and args.
- TestRelaunchOpenedStartsNothingElse: open working on try 2 is the
  whole relaunch; the program isn't also run; the log says exit 0.
- TestRelaunchNoProgramIsLogged: a bundle without its program is
  logged and the shell exits non-zero.
- TestRelaunchRunsTheProgramInfoPlistNames: "magpie dev" from
  Info.plist, in a bundle path with a quote in it.
- TestRelaunchLogInMagpiesFolder: the log is under XDG_CONFIG_HOME's
  magpie, and is moved to .old past 64KB.
Red by hand: with the fallback replaced by the old `|| exit 1`,
StartsTheBundle timed out at 30s ("the new version starting never
happened"), and LogsEachTry, NoProgramIsLogged and
RunsTheProgramInfoPlistNames failed; with note() a no-op, LogsEachTry, OpenedStartsNothingElse
and NoProgramIsLogged failed. All green with the fix.

Real run: a relauncher built from this tree calling update.Relaunch on
a scratch Scratch.app (CFBundleExecutable scratch, a script writing a
marker), under env -i with a sandbox HOME and an `open` first on PATH
that always fails with the -600 text. The relauncher exited at once;
relaunch.log under the sandbox's ~/.config/magpie had 8 tries 02:02:45
to 02:02:59, each "exit 1 _LSOpenURLsWithCompletionHandler() ... -600.",
then "open gave up after 8 tries; starting '.../scratch' 'tray'". The
marker: args=tray ppid=1 pgid=pid (own group), no tty, and still alive
3s later, after the relauncher and its shell were gone.

Run at 843417957 plus this change: gofmt -l internal/ (clean);
go vet ./... (darwin); GOOS=linux go vet -tags nogui ./...;
GOOS=windows go vet ./...; go test -count=1 ./internal/update (ok).
The full suite (-timeout 45m) was started on this tree before the push
and had not finished; per the owner's ship-at-once rule this didn't wait
for it.

Not tried: a real update with the screen locked (the screen here was
never locked), so whether the program started by path comes up under a
locked session is not seen, only that the login agent starts it the
same way. Not tried with the real magpie binary in the scratch bundle
(it would read the Keychain): the tray and the instance lock under this
start are the login agent's path, not observed here. An open that exits
0 while magpie doesn't come up isn't covered; relaunch.log will show it.
2026-10-24 02:05:05 +08:00
yetone fb23bca5c9 update: the Mac relaunch tries open again while it fails
molvqingtai's system log (Discord): v0.1.1314 updated itself at 00:43:49,
the old process exited 0, and ~160ms later `open` of the bundle failed
with -600 (procNotFound): LaunchServices still sent to the process that
had exited (the screen was locked). runAfterExit ran open once, nothing
looked at its status, and magpie stayed closed until a manual launch at
09:45.

Relaunch now runs relaunchCommand: the same open, tried again after
pauses of 0.5 1 1 2 2 3 4 seconds (13.5s, 8 tries) while it exits
non-zero, and not again once it succeeds. The detached own-session
shell (#2362) is unchanged. The new instance is not confirmed running
beyond open's exit 0.

Sibling, not changed: RelaunchBinary (Windows, Linux) starts the new
binary itself while this one is still up, with no open after exit; on
Windows with the old binary moved aside, startChecked already waits 20s
for the new one to say it is up and puts the old back otherwise. ayu's
"restart to update needs several clicks" is not this shape (candidates:
the install held by another program, or the busy-gateway wait) and needs
its own look.

Tests (internal/update/relaunch_retry_test.go): a fake `open` first on
PATH refuses its first tries with the -600 text.
- TestRelaunchOpenTriedAgain: relaunchCommand after a gone pid opens on
  the third try. Old code: FAIL "open was tried 1 times and the new
  version never opened" (30.04s).
- TestRelaunchOpenGivesUp: a refusing open ends after len(waits)+1 tries;
  one that works on the second is not run again. Broken by hand (no
  `&& exit 0`): FAIL "open tried 4 times, want 2".
- TestOpenWaitsTotal: waits add to 10-15s. Broken (0.5 1): FAIL "waits
  add to 1.5s".
Real open: the same loop with /usr/bin/open on a scratch .app that
appeared after 2s failed 3 times ("does not exist", exit 1) and opened
it on the 4th, the app got --args tray.

Record for this push: 13 commits on origin/main ca4a1cde0, head tree
539c84e92. Go 1.26.8, sandbox HOME, GOMODCACHE/GOCACHE pinned. The full Go
run and vet were at tree d6393dfc8, the same Go code as this head: only
app.js comments (cut under the core script budget) and one ja string
changed after it.
- gofmt -l: nothing. go build ./...; go vet ./... (darwin), GOOS=linux
  go vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -timeout 45m ./..., through tee, one suite on the machine:
  68 packages ok. The one red was internal/gui's
  TestCoreScriptBudget: app.js 1,335,314 > 1,335,000, since main grew
  app.js under the stack. The autoscroll commit's own comments were cut
  (to 1,334,629) rather than the budget raised, and go test -count=1
  ./internal/gui is ok at this head (113s). Packages the run took from
  Go's test cache had the same inputs.
- GUI: the 18 files this stack touches or names, both engines,
  202 of 204 pass (tree 068acf128, this push less the last commit). The
  two reds: gui-ja, red on main since c2636b7b5 and fixed by this push's
  last commit (gui-ja and i18n-keys 6 of 6 there), and usage-fold's
  chromium "several accounts" (#2163, red on main the same way).
- internal/update ok, with TestRelaunchOpenTriedAgain, TestRelaunchOpenGivesUp
  and TestOpenWaitsTotal. GOOS=linux and windows builds are covered by vet.
  The whole GUI suite ran at 1c1fc7183 (this stack's first 12 commits on
  0ddcf28a1): 11713 of 11769 pass. Each of the 21 red files was then run
  alone at the stack and at origin/main 8278fd9b0. Eight are red the same
  way on main: plugin-card-update (#3079), quota-count-wrap and
  quota-name-translated (#2228), s3-sync (#2448), usage-agents-hide
  (#2276), usage-checkin (#3091), usage-fold's chromium "several
  accounts" (#2163), usage-ledger (#3104). The other 13 pass alone on both
  and were red only under that run's load (50 to 335): currency #3101,
  plugin-github #3218, provider-fetch-again #3292, rest-try-now #2564,
  routing-auto-reset #3293, routing-keys-fold #1612, routing-steady #1804,
  routing-wb-restricted #1905, sessions-folder-delete #2218,
  sessions-manage #3294, switch-only #3295, text-size #1866, usage-pack
  #3296.

Not tried: a real update on a real Mac, or a real -600 from
LaunchServices; nothing on Windows.
2026-10-23 01:58:00 +08:00
yetone 40dee51751 update: on Windows a download an antivirus holds is waited for up to 30s, and a restart tried again doesn't trial-start it again (白菜 on Discord)
白菜 (Discord #general, 10-19): with magpie on the Desktop, every click
on Update says it is restarting and then offers the update again;
clicking again never gets it in, only a fresh download from the site
does.

Cause, as far as could be shown: the install starts the download
suspended first (canStart, #894). An antivirus that checks a program as
it starts holds the file a while after, and the move into place gave up
after asideWaits' ~3s (#2272's fix). The swap failed, the old exe was
put back, the state stayed ready and the pill said 更新失败, with the
reason only in its tooltip. A click again ran the trial start again, so
the antivirus held the same file again and it failed the same way every
time.

Change:
- moveIn and moveAside go on trying, at the last pause (1.5s), while
  Windows says the file is held open (errors 32/33), up to heldFor (30s)
  from the first try. Other errors still stop after the short pauses.
- InstallBinaryAside trial-starts a download once: the same path, size
  and mtime that passed isn't started again on a retry. A new download
  is.
- A download still held after that says so ("another program still has
  the download open (often an antivirus checking it): let magpie through
  it…"), without the paths, in the version row and the pill's tooltip.
  It still unwraps to the *os.LinkError and the sharing violation.

Tests:
- TestMoveAsideWaitsOutALongHold (all OSes): 10 held tries then success.
  A permission error still stops at 4.
- TestInstallBinaryWaitsOutALongHold (Windows): a real handle holds the
  download for 600ms against 2 short pauses.
- TestInstallBinaryTrialsADownloadOnce (Windows): one trial for a retried
  download, a second for a new one, and the new error text.
- Existing tests that hold a file for good set heldFor to 0.

What was run:
- Broken by hand (no wait past asideWaits, trial on every try): all
  three new tests red on the Windows box. TestMoveAsideWaitsOutALongHold
  is red on macOS too. Restored: green.
- Windows box (10.0.26200, Defender on), cross-compiled update.test.exe
  in a sandbox USERPROFILE/APPDATA/TEMP: the whole internal/update
  package PASS (41 tests).
- Real GUI on the box: a production build (v0.1.9000) at
  C:\Users\yeton\Desktop\magpie-windows-amd64.exe, a sandbox home, a
  local feed offering v0.1.9001. The .new was held open from PowerShell
  (FileShare Read) for 12s, then POST /api/update/install {when:now}:
  - origin/main's build: install failed, "rename … being used by another
    process", state ready, old process ran on;
  - this build: the new version started 1s after the hold was let go,
    and the Desktop exe's hash is 9001's.
- The same setup without a hold, origin/main's build, worked: plain
  Desktop, and a Desktop folder named 白菜 测试 with "(1)" in the exe
  name. A non-ASCII path or the Desktop alone is not the cause.
- gofmt clean. go vet ./... clean for darwin, linux -tags nogui and
  windows.
- HOME=<sandbox> go test -timeout 45m ./... at load ~260-290: every
  package ok except these.
  - internal/agent and internal/gateway timed out at 45m. Already filed
    as #2544 and #2870.
  - internal/gui's TestSetAnswersWhileDevinAndProvidersHang (19.8s set
    under load) is filed as #1375. Rerun alone with the update, restart,
    install and relaunch tests: ok.
  - internal/update was rerun separately, because its source was swapped
    to origin/main's for ~1 min mid-run to build the comparison exe: ok.

Not tried:
- A real third-party antivirus (360, Huorong). The hold is injected. The
  user's version, antivirus and exact error are still unknown, and were
  asked for on Discord.
- A OneDrive-redirected Desktop.
2026-10-20 01:16:38 +08:00
yetone c68270dae7 update: a Mac opened from the Dock or Finder comes back after "Update and Restart", not quits for good (#2362, danbo610)
update.Relaunch left the shell that waits for magpie to exit and then
runs `open` in magpie's own process group. launchd ends a job's process
group when its process exits, so the shell died with magpie and the new
version never opened. ee16c657 fixed this for the Open at login agent
only (AbandonProcessGroup in the plist magpie writes). The job
LaunchServices makes for an app opened from the Dock or Finder carries
no such key, and on the reporter's macOS 13 (Intel, 0.1.1250) the
restart quit and nothing came back until a manual launch. The shell now
starts in a session of its own (detach, as RelaunchBinary's helper on
Windows and Linux already does). That holds for both job kinds, however
the previous version was started.

Tried on this Mac (macOS 26.2) with throwaway jobs, all removed after:
- A LaunchAgent without AbandonProcessGroup (a Go parent starting the
  same wait-then-run shell, then exiting): the shell in the parent's
  group never ran; one with Setsid did.
- A Cocoa .app opened with `open`, relaunching itself through the same
  shell: macOS 26 didn't kill the group, and both inherit and setsid
  relaunched. The application-job half is the reporter's macOS 13
  observation (their isolated A/B matches the agent case above). It
  was not reproduced on this OS.
- A setsid shell's `open` relaunched the .app fine (open rc 0, new pid).
Not tried: a real magpie update on macOS 13. No such machine here.

Siblings: RelaunchBinary (Windows, Linux) already detaches its child
through launch. Reexec (magpie web) runs in place. No other code
waits for magpie's pid and then opens it.

Tested: TestRelaunchOutlivesItsJobsGroup. A child of the test leads a
process group as a job's process does, starts the helper through
runAfterExit and exits. The test then kills the group as launchd does,
and the helper must still run its command. With detach(cmd) removed it
fails: "the relaunch helper died with the job's process group: the new
version was never opened" (15s). Restored, it passes (1.06s, 3 of 3).
go test -tags nogui -p 1 ./internal/update ok. gofmt -l clean. go vet
-tags nogui (darwin, GOOS=linux) and GOOS=windows go vet on
./internal/update ok.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone c644d9f1d2 update: the downloaded binary is moved into place again while something still holds it after the trial start, not failed at once (#2272, JasonBuildAI)
InstallBinaryAside starts the download suspended (trialStart), ends
it, sets the running exe aside and renames the download over it. A
program that checks an executable as its process starts (an antivirus)
can hold the file a moment after the process has ended, and the rename
then fails with a sharing violation; the report says the first install
of every update failed this way. The rename (and the put-back of the
old exe on failure) now goes through moveIn, which tries again over
asideWaits (100 ms to 1.5 s) while Windows says the file is held
(errors 32/33), as moveAside already does for the running exe. Any
other failure is returned at once. The Windows CI step now runs the
trial tests too (TestTrialStart and the new ones).

What was run:
- Windows box (Windows 10.0.26200 x64, Defender real-time on, a
  cross-compiled update.test.exe in a temp dir with a sandbox
  USERPROFILE/APPDATA/LOCALAPPDATA/TEMP):
  - TestInstallBinaryWaitsForHeldDownload (new; the download held open
    for 150 ms): old update.go FAIL "rename ...magpie.exe.new
    ...magpie.exe: The process cannot access the file because it is
    being used by another process."; new PASS (0.31 s).
  - TestInstallBinaryRightAfterTheTrial (new; real trialStart, then the
    install) and TestTrialStart pass on old and new code there.
  - The whole update package passes; the CI pattern
    ^(TestInstallBinary|TestMoveAside|TestTrialStart) passes.
  - Rollback tests now use 1 ms waits so a file held for good fails
    fast.
- The real update, in a sandbox: v0.1.1243's magpie-windows-amd64.exe
  run as `magpie update` twice in separate sandbox homes: both updated
  to 0.1.1244, exit 0.
- macOS: gofmt -l clean; go vet darwin, GOOS=linux -tags nogui,
  GOOS=windows clean; go test -p 4 ./... (see the last commit of this
  push for the result).
Not reproduced: the hold itself. On this box the real trial-then-
install path succeeded every time (10/10 with a 12 MB exe, 10/10 with
a 74 MB magpie.exe, 2/2 real updates), and origin/main's TestTrialStart
passed 3/3. The fix is verified with an injected hold, not a real
antivirus one.
2026-10-15 10:10:18 +08:00
yetone fbb7e2cbd4 gui, update: Settings' Restart automatically restarts into a downloaded update once no agent request is in flight (#2096, xiaozhu1337)
#2096 asks for a setting that installs and restarts whenever an update is
there. Settings > About gets "Restart automatically" (Off/On), off by
default: a restart ends the window, and whatever an agent sends during it
waits for the gateway to come back.

When on, and Automatic updates is on, the updater's minute loop sees a
"ready" update and starts the same idle wait the Install-when-idle button
uses (waitIdle: 10s with nothing in flight, at most 1h). Cancelling that
wait from the GUI skips that version, so the next one is restarted into
again. The app (window or tray) and `magpie web` are covered; serve and
daemon have no in-process updater and are not. On the Mac, a restart the
app made by itself reopens to the menu bar icon only (`open … --args tray`)
when no window was shown, rather than popping a window up unasked
(update.Relaunch takes a window flag; relaunchOpen builds the command).
With Automatic updates off the row is dimmed and reads "While automatic
updates are on", like Check every.

Run:
- go test: internal/gui (-tags nogui, full package, 273s), internal/update,
  internal/settings, internal/cli — ok, with set -o pipefail.
- New: TestAutoRestartWaitsForIdle, TestAutoRestartNeedsAReadyUpdate,
  TestAutoRestartCalledOff, TestRelaunchOpen.
- Broken by hand: without autoTick, WaitsForIdle and CalledOff fail;
  without the autoSkip assignment, CalledOff fails; restarting without
  the idle wait fails WaitsForIdle and CalledOff; without prefsKeep's
  autoRestart, update-restart.test.cjs fails 11 of 11.
- gofmt -l clean; go vet and go build for darwin, GOOS=linux -tags nogui
  and GOOS=windows on internal/gui, update, settings, cli.
- GUI: new update-restart.test.cjs, chromium and webkit, 1100 and 420,
  en/zh/zh-TW/ja/de (22 pass, twice); update-*, i18n-keys and settings*
  in both engines: 253 pass, 0 fail.
- Found on the way, filed as #2134: in WebKit at 420, turning Automatic
  updates off scrolls a view at its top by ~2px (the Version row's sub
  grows). The test checks the clicked control holds still instead.

Not tried: a real update or relaunch (no real install was touched), the
tray-only reopen on a real bundle, Windows/Linux restarts by hand.
2026-10-14 15:19:14 +08:00
yetone e5f04f38e8 plugin: a plugin on a pre-release whose release is out shows the update on its row, as the Plugins dot already did; versions are ordered as semver orders pre-releases, in Go and in the page
The Plugins dot comes from update.Newer, and the Installed rows (chip,
Update, Update all) from plugins.js's own newer(). They disagreed:

- newer() read only x.y.z, so 2.0.0-beta.1 with 2.0.0 out had the dot
  and no row to update it from. Real case: opencode-antigravity-auth,
  whose latest is 1.6.0 after 1.6.0-beta.0..2.
- update.Newer compared pre-releases as strings, so 1.0.0-beta.10 came
  before 1.0.0-beta.9 (and 1.6.0-10 before 1.6.0-9): a missed update,
  and the other way round, an "update" to an older beta.
- update.Newer didn't parse build metadata, so 1.0.1+build.1 was never
  newer than anything.

Both now order as semver §11: no pre-release comes after any;
identifiers compared one by one, numbers as numbers, a number before a
word, and a shorter list before a longer one it starts. Build metadata
is ignored. A version that isn't x.y.z is never newer, as before.

Tests:
- internal/update TestNewer gains the pairs. On the old Newer 4 fail
  (beta.10/beta.9 both ways, 1.6.0-10/-9, +build).
- internal/gui/tests/plugin-prerelease.test.cjs: seven installed
  plugins, the dot's waiting list as update.Newer gives it, and each
  row's chip and Update button, plus the Update all count, must match.
  On the old plugins.js it fails at "v2.0.0 out" in both engines. No
  strings change, so it's English only.

Reproduced in a sandbox HOME with the real package:
`magpie plugin add opencode-antigravity-auth@1.6.0-beta.2`, then Check
for updates. Before: /api/plugins/updates listed it, and the Plugins
nav had the dot, but the row had no chip and no Update, and there was no
Update all. After: the row shows "v1.6.0 out", Update, and Update all (1).
Update all then installed 1.6.0 and the waiting list emptied.

Run: gofmt; go vet -tags nogui for darwin, linux and windows on
internal/update, internal/plugin, internal/gui and the root package; go
test -tags nogui of the root package, internal/{gui,plugin,provider,
stats,update} under a temp HOME; GUI tests plugin-prerelease,
plugin-updates, plugin-card-update, plugin-check-updates, plugin-market,
plugin-release, plugin-git and plugin-local in Chromium and WebKit.
2026-10-10 10:28:49 +08:00
yetone 9ca64d104f update, gui: a new version Windows won't start is never left in place — tried before it goes in, and a restart into one that doesn't say it is up puts the running one back; that version isn't downloaded again by the clock, and Settings › About › Version says why (#894, hisiling) — on Windows 11 with Smart App Control on, the update put the new unsigned exe in place of the running one and restarted into it; CodeIntegrity (3033/3077) refused it, magpie never started again and the working version sat in .old. Now, on Windows, the downloaded exe is first started suspended with no window and ended at once (Windows checks a program when its process is created), and one refused stays out: the running exe isn't moved. At the restart the new process is given MAGPIE_STARTED, a file it writes first thing (AwaitPredecessor); the old one waits up to 20s for it and, if the start fails (ERROR_SYSTEM_INTEGRITY_POLICY_VIOLATION 4551, 1260 or any other), the new process quits before saying so, or it says nothing in time (then it is ended), puts the running exe back over the new one (the new one renamed .blocked if it can't go) and keeps running instead of quitting; nothing notes it as updated in the app. The version is noted in the config folder (update-blocked.json, this machine's only, never synced; gone once a version at least as new runs); the clock's checks leave it alone and show why, a Check clicked downloads and tries it once more. Settings › About › Version: for an application control policy, "0.1.x didn't start on this computer: Windows' Smart App Control (or another app control policy) blocked the new version, which isn't signed. magpie stays on 0.1.y. Download it and run it yourself, or turn Smart App Control off and check again", else the reason, with Download and Check; the error in full on hover. en/zh/ja/de. A user who double-clicks the refused exe is refused by Windows before magpie runs; only signing helps there. TestRelaunchRefusedPutsBack (4551 at the start), TestRelaunchSilentPutsBack (no word in time, killed; quit at once), TestRelaunchReportedStays, TestReportStarted, TestBlockedNote and TestUpdateThatWontStart (the restart doesn't quit, the note, the clock not downloading it again, a Check that does) are new and fail without the change; on Windows TestInstallBinaryRefusedStaysOut, TestTrialStart and TestStartCheckedPutsBackForReal (real processes: not a program, quits at once, runs on silent) pass on the Windows 11 test box with the whole internal/update package (Smart App Control itself isn't on there, so the refusal is simulated). update-blocked.test.cjs (Chromium and WebKit, en and zh: the reason and both versions, full error on hover, Download opens the release, Check downloads, the other reason, no select, no scroll, no left border) fails without the change; update-check, update-mirror, update-auto, update-wait and update-download-percent pass in WebKit; click-scroll's request-list case fails now and then the same on main. go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass. 2026-10-05 19:43:31 +08:00
yetone dab887db57 update, gui: Settings › About › Download source sets the update mirror, and a download that failed through it offers GitHub (#893, M3chD09) — the mirror updates could come through was only magpie update mirror in a terminal, and the GUI never said where updates came from or that a failed download was the mirror's. About now has a Download source row: GitHub, or the mirror set (the same UpdateMirror setting the CLI writes); Use a mirror… takes a full https:// address (http, a bare host or a malformed one refused, with the reason in the row and the draft kept), Change edits it, Use GitHub takes it away in one click; Enter saves, Esc cancels, no click scrolls. POST /api/settings/update-mirror sets it; the Settings page's own save keeps it. A download through the mirror that doesn't answer, answers other than 200, or sends a file whose SHA-256 isn't usemagpie.ai's feed's is an update.MirrorError (never installed, the file removed, as before); /api/update's error carries the mirror, and the Version row says the download failed through that mirror and offers Download from GitHub, which takes the mirror away and downloads again. magpie names no mirror or CDN of its own. en/zh/ja/de. TestMirrorFailuresAreTheMirrors (tampered, 404 and closed mirrors each the mirror's, no file kept; a direct failure no mirror's; CheckMirrorURL) and TestUpdateMirrorSetting (set trimmed, http/bare/ftp/empty-host refused, Settings save keeps it, off, an updater failing through a 404 mirror reports it with retry, a new check clears it) are new; update-mirror.test.cjs (WebKit, en and zh: GitHub shown, http refused with the reason, https saved with Enter, Use GitHub posts "", a failed download through the mirror offers GitHub, which posts "" then update/install; no select, no left border, no scroll) fails without the change; update-auto, cli-path, cli-behind, settings-sections and click-scroll pass in WebKit. go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass. 2026-10-05 18:49:04 +08:00
yetone bc141ad834 update: install.sh and magpie update take --proxy and --mirror, and magpie update mirror keeps one for the app's updates too (akic404 on Discord: 安装和update如果没有梯子也是麻烦事,能否在install.sh和magpie update后加子选项?--proxy等可自定义或默认ghproxy) — install.sh had no options and fetched with curl alone, and magpie update took none; without a way out to GitHub both failed. Now both take --proxy <url> (http, https, socks5, socks5h; install.sh also MAGPIE_PROXY=) for the feed and the download, and --mirror <prefix> (or MAGPIE_MIRROR=), a GitHub download mirror the release file is fetched from as <prefix>https://github.com/…; only github.com / githubusercontent.com URLs are put through it. No mirror is used unless one is given: magpie names none and has none by default. The feed with each file's SHA-256 is always fetched from usemagpie.ai, never through the mirror, so a file the mirror changed is refused and deleted ("… from the mirror X does not match its checksum from https://usemagpie.ai; not installed"); macOS still checks the app's signing team. magpie update mirror <prefix>|off saves Settings' updateMirror (http(s) only), which the app's own background update follows too; magpie update --mirror off skips it once; the Settings page's save keeps it. The app's update already followed Settings → Proxy (#294); magpie update --proxy overrides it for one run. The environment's ALL_PROXY / all_proxy is now honoured when HTTPS_PROXY / HTTP_PROXY are unset (Go's ProxyFromEnvironment ignores it), with NO_PROXY as curl reads it. magpie update takes --flag value or --flag=value, and an unknown word is an error instead of an update. The help, README and the docs' FAQ (en/zh/ja) say how. install.test.mjs's proxy, mirror and tampered-mirror tests, TestAllProxyFromTheEnvironment, TestUpdateThroughAMirror, TestUpdateThroughAProxyGiven and TestUpdateFlags fail on the old code and pass; TestSettingsSaveKeepsWhatItDoesNotSend covers updateMirror. A dry run of install.sh as Linux amd64 into a temp HOME installed the real 0.1.773 with its SHA-256 checked, refused a local mirror serving a wrong file, and with --proxy to a closed port failed reaching the site through it. go vet, builds (darwin, GOOS=linux, GOOS=windows), sh -n, node --test site/install.test.mjs and go test -tags nogui -count=1 ./... under a temp HOME pass but TestClaudeIdentityServedWhileAsked, a timing test that passes alone. Not tried through a real proxy server or a real public mirror; no install.ps1 exists for Windows, and the app has no field for the mirror. 2026-10-04 00:19:47 +08:00
TryWorld 1ca56a9ad8 fix(update): roll back failed Windows binary installs (#632) 2026-10-03 12:51:51 +08:00
YAYOI27 cb82822f3d source: add opt-in China mirror fallback (#566) 2026-10-03 09:50:59 +08:00
yetone 88cccc184e update: on Windows, an exe something holds open for a moment still goes aside for the new version, and one held for good says why in full, with the release page a click away (freecss on Discord: "0.1.628 已下载 · couldn't move magpie-windows-amd64.exe aside to put the new version in: rename C:\Us…") — InstallBinary renamed the running exe to .old once and gave up on the first error, which Go prints as "rename <exe> <exe>.old: <reason>", two full paths ahead of the reason, and the version row cut it off on one line, so what failed couldn't be read. A leftover .old was already handled (RemoveOld, then .old-2…, TestInstallBinaryBesideARunningOld), and Windows renames a running image (it is mapped with FILE_SHARE_DELETE), so the likely cause is another program holding the exe open without delete sharing — an antivirus scan, OneDrive or a similar sync client — or a folder that refuses the change (access denied); which one isn't known until the full message is read. moveAside now tries again for about 3 s (0.1, 0.2, 0.4, 0.8, 1.5 s apart), clearing a read-only attribute after the first failure, with a fresh .old name each try; a missing exe isn't retried. When it still can't, the message is the reason without the paths and what to do: ERROR_SHARING_VIOLATION/ERROR_LOCK_VIOLATION says another program has it open (often an antivirus or OneDrive), access denied names the folder Windows won't let magpie change, anything else says to download the new version; the download is kept for another try, as before. The version row wraps a failed install's or download's reason (.sub.wraps) with the whole text as its tooltip, and a ready-but-failed install offers Download, which opens the release page. The Windows test box wasn't reachable from this session (ssh key refused), so nothing ran on Windows; TestInstallBinaryHeldOpen (windows-only: an exe held open without FILE_SHARE_DELETE for 0.5 s still installs; held for good, the error says another program has it open and the download is kept) was cross-compiled with GOOS=windows go test -c but not run. TestMoveAsideTriesAgain and TestMoveAsideSaysWhy (portable, with a fake rename) and the new update-check.test.cjs case (webkit, en and zh: the reason is not cut off, its tooltip is the full text, Download opens the release page, a later state is one line again) fail without the change; Chromium couldn't launch here (its Playwright cache has no ICU data). go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build and vet, go test -tags nogui ./... pass (TestFXInState failed once on a TempDir cleanup race, passes on the rerun; untouched). 2026-10-02 13:26:54 +08:00
yetone 65f3a6417a settings: portable mode — a data folder beside magpie keeps everything magpie keeps (#508, suixinex) — like VS Code's portable mode, a folder named "data" (or a file named ".portable", the data folder then made beside it) next to magpie makes it keep all its own files there instead of the user's profile. Where magpie keeps its files is now decided in one place, internal/appdir: Config() (~/.config/magpie, $XDG_CONFIG_HOME/magpie; portable: data/), Cache() (~/.cache/magpie, $XDG_CACHE_HOME/magpie; portable: data/cache) and SystemCache() (the OS's cache folder, which the library's market lists and an update staged where magpie may not write used; portable: data/cache). settings.Dir()/Path(), provider.Path(), profile.Path(), the models.dev catalog, the exchange rate and the plugin market cache go through it, and everything built on them follows: providers, logins and saved accounts' folders, usage ledger, routing history and request archive, plugins, library, backups, sync state and lock, caller keys, redact key, stats. "Beside magpie" is the folder holding the executable with links followed; for a Mac app the folder holding Magpie.app (inside the bundle would break its signature), and for an AppImage the folder holding the .AppImage, not where it is mounted. The decision is made once, at start: an update moves the running copy aside (into .magpie-update on a Mac, to magpie.exe.old on Windows) and its files must not move with it; the updated copy replaces the executable or bundle only, so the data folder beside it is left alone. A portable magpie doesn't copy an old dial install's folders in. Not moved, as they aren't magpie's own: the agents' configs (~/.claude, ~/.codex…), the sign-ins agents keep in the system keychain (a saved Claude account's Claude Code keychain item is named after its folder's path on a Mac, so a portable folder moved elsewhere or to another Mac signs that account in again), autostart and link-handler registrations, and temporary folders. The single-instance id already covers the config folder, so a portable and an installed magpie run side by side, but the gateway port is one. Settings shows the config folder as portable. TestResolve (data folder, .portable, a file named data, a Mac bundle), TestResolveSymlinkedExe, TestResolveAppImage (Linux), TestFolders and TestPortableSettings (Path() lands in the data folder, Save writes there, ~/.config/magpie untouched); TestPortableSettings fails without the change (Path() is ~/.config/magpie/settings.json), TestResolveSymlinkedExe without following links. A nogui build run from a folder with data/ under a sandbox HOME wrote profiles.json, cli-identity.json and cache/models.json into data/ and nothing of magpie's into HOME. go vet ./internal/..., go build -tags nogui ./... (darwin, GOOS=linux), GOOS=windows go build ./..., go test -tags nogui ./... pass. 2026-10-02 13:00:22 +08:00
yetone aa42142ea5 update: What's new and the waiting update's notes follow the app's language (freecss on Discord: 更新后的公告的语言是不是应该设置里面的走) — the release notes were English alone. A release's notes are to carry a Simplified Chinese translation below a <!-- lang:zh --> marker (the magpie-releases workflow, changed separately); usemagpie.ai's /api/latest and /api/notes take ?lang=zh for the Chinese where a release has it, and give anything else, an app from before included, the English alone, everything above the marker. The page asks /api/whatsnew, /api/update and /api/update/check in its own language (?lang=); magpie asks the site in it, keeps What's new's notes per language, and asks again for the waiting update's notes when a page's language isn't the one they are held in (at most once a minute); a check by itself asks in the pages' last language, else the app's, as the tray menu has it. Notes that come back whole (a site not yet deployed) are cut in the app too; notes without the marker (every release so far) are English, in either language. The worker must be deployed (npx wrangler deploy in site/) before the workflow change ships, or apps would get both languages. TestInLang, TestFeedsAskInLang, TestAskedLang, TestWhatsNewInPageLang, TestUpdateNotesInPageLang, site/worker.test.mjs (node --test site/worker.test.mjs), whats-new.test.cjs's language check (Chromium and WebKit, en and zh); update-check, update-hide, update-auto, sync-update pass in WebKit. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass (TestClaudeRunEndsWhenTheClientLeaves flaked once under the full run, passes alone; gateway untouched). 2026-10-02 11:31:11 +08:00
yetone bd529a555e netproxy: a host whose IPv6 takes the connection and drops it is reached over IPv4 (tony on Discord: models.dev sync and the update check failed with a bare EOF, direct or auto, while curl got through) — behind a TUN (xray) without IPv6 out, a connection to a site's IPv6 address is accepted, so the dialer's own fallback to IPv4 never starts, and closed once TLS begins. A connection to an IPv6 address that ends before a byte comes back now marks its host:port to be dialed over IPv4 for 30 minutes, and the request that met it is sent once more over IPv4 when nothing of it can have reached the site (HTTPS, or an idempotent method) and its body can be had again; proxied requests and IPv4 connections are left as they are, and TLS, ALPN/HTTP/2, headers and bodies are unchanged. Every transport made with Dispatch (http.DefaultClient, the gateway's) and the update client get it. TestIPv4Fallback fails without the change (Get "https://example.com/": EOF). go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass (TestFXInState flaked on TempDir cleanup under load, passes alone). 2026-10-01 23:20:58 +08:00
yetone 30236bf035 migrate: moving Kiro back with an API key no longer hangs magpie, a move's lock left by a killed magpie frees itself, and plugins changed in a terminal reach the running app (要保证插件订阅 provider 跟内置的订阅 provider所有逻辑都要一模一样) — Kiro's back put the plugin's API key onto the Kiro provider while holding logins.json's lock; saving the provider syncs the agents, which read the accounts and waited on that same lock, so the move back never returned and every request after it hung. The key is now put back once the lock is let go (a mover's settle). A move killed while hung left migrations.json.lock, refusing every move for 15 minutes as "another magpie is moving"; the lock now holds its magpie's pid and one whose magpie is gone is taken. And magpie plugin add, remove or move in a terminal left a running app with the plugins it had loaded (a moved Kiro gone until restart, "magpie knows no model kiro/auto"): a plugins.json changed by another magpie now restarts the host and takes the providers that magpie was told meanwhile. Found walking Qoder, Kiro and Cursor through sandbox moves. TestKiroMover (hangs), TestMoveLockOfDeadMagpie and TestPluginsChangedElsewhere fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. 2026-10-01 06:53:29 +08:00
yetone ee8a371cf4 gui, update: saving the Settings page keeps the models hidden from each agent, and update checks go through magpie's proxy and say so (#294: 设置代理之后只有模型代理生效了,代理没有用于检查 magpie 是否有更新) — POST /api/settings carried over the models' names, levels and images but not HiddenModels, which the page never sends, so changing the theme, the language or anything else there showed every model hidden one by one on the Agents page again; it is carried over with the others. The update feed and the release came through http.DefaultTransport, proxied only because main installs netproxy first; the update client now takes netproxy.Func on a transport of its own (Settings' Proxy, else *_PROXY, else the system's). A check that failed at start-up, before a proxy was set, stayed failed for six hours: saving a new proxy now checks again through it. And the Settings row read "requests to vendors go through {proxy}", which says update checks don't: it now names both. TestSettingsSaveKeepsWhatItDoesNotSend (every field prefsKeep doesn't send survives a save of the theme alone; fails on main with HiddenModels emptied), TestUpdateGoesThroughTheProxy (feed and asset at hosts only a local proxy answers; fails without the transport), TestSettingsProxyRechecksAFailedUpdate (fails without the re-check). account-proxy, provider-proxy and click-scroll GUI tests pass; go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass (TestUserPath, TestClaudeSignedOut, TestClaudeAccountNamedAsItsLogin, known flakes under load, pass alone). 2026-09-30 16:03:52 +08:00
yetone 831df8579e update: a restart to update from the open window (Windows, Linux) opens the window again, on the tab it was asked from, instead of the tray icon alone (#275 Aimer779: 设置页更新重启后主窗口消失,只剩托盘) — RelaunchBinary always started magpie tray, autostart's argument, so the new version came up as a tray icon however the update was asked for; the Mac reopens its .app and was fine. The window's Update pill and Settings' "Restart to update" send the tab they're on, the new process starts as magpie gui <tab>; the tray menu's Restart to Update brings the window back if it was open and keeps to the tray if not; autostart stays tray. magpie gui <tab> / magpie app <tab> open the window on that tab, and hand it to a magpie already running. The MAGPIE_REPLACES handover is unchanged: the new process waits for the old one before its single-instance lock. Tested with TestRelaunchArgs and TestRelaunchBinaryArgs (a script in magpie's place is started with gui settings <pid> / tray <pid>); go vet, go build (GUI and -tags nogui, GOOS=linux, GOOS=windows), go test -tags nogui ./... pass. Not tried: a real restart to update on Windows or Linux. 2026-09-30 12:33:36 +08:00
yetone 06dddf7f68 update: magpie update in a Homebrew install (brew install magpie, from the new tap in magpie-releases) says to brew upgrade magpie instead of replacing the binary in brew's Cellar, which would leave brew thinking the old version is there 2026-09-26 20:50:26 +08:00
yetone cb609d2cb4 update: after an update on Windows one magpie is left, not two — a magpie running when another updated the binary (it runs on from magpie.exe.old) no longer downloads the update again to magpie.exe.new and swaps it in when it quits; it says a restart is all that is left. A magpie.exe.new that is magpie.exe over again is removed at start. The tray that found the gateway taken serves it once the magpie that had it is gone, checked every 15 s 2026-09-26 14:30:16 +08:00
yetone 7c3fa7d19e update: on Windows an update goes in while what the last one moved aside still runs — a magpie serve started before an update runs from magpie.exe.old, which then can't be removed, and moving the running exe onto it failed with "Access is denied"; it now goes beside it (magpie.exe.old-2…), the leftovers are removed once free, the download is kept for another try, and the Update button says Update failed (the error in its tooltip) instead of seeming to do nothing. Reproduced on Windows 11 with a running .old: the old swap fails, the new one passes 2026-09-26 01:38:37 +08:00
yetone e8b3be572c windows: the desktop app no longer opens a console window for every command it runs (#54) — it is linked as a GUI program and has no console, so each console CLI it started (devin auth status and models list, devin acp for every Devin turn, claude, codex, cursor-agent and grok probes and runs, grok login) was given a new console by Windows, and a Windows Terminal window with it, some every few seconds while the app sat idle. Every command magpie runs is now made through internal/proc, which starts it with CREATE_NO_WINDOW when magpie has no console of its own: the child gets a console without a window, and its output, which magpie always pipes back, arrives as before. A magpie run in a terminal (magpie serve, the TUI, the desktop app started from one with a command) has one, and its children share it as they did, so Ctrl+C there still reaches them. The relaunch after an update keeps its DETACHED_PROCESS, added to rather than replacing the flags it was made with, and a test fails on any command made with os/exec directly, so a new one can't bring the windows back 2026-09-25 14:04:44 +08:00
yetone 90580ca7e1 update: Update updates magpie in place — a click downloads the new version and restarts into it, asking for the password when magpie can't replace itself, instead of opening the release page; only a magpie running from its disk image or a temporary copy is sent to the download page, with why 2026-09-25 01:35:24 +08:00
yetone 65fdcb1a14 update: the download shows how far along it is — percent and megabytes in Settings — a dropped connection is tried twice more, and a failure says why instead of only that it failed (#21) 2026-09-24 15:07:35 +08:00
yetone 75cb192647 Desktop app for Windows and Linux
The Windows app cross-compiles (WebView2, no cgo) as a GUI program with an
icon, version info and a DPI-aware manifest; run from a terminal with a
command it borrows the console. The Linux app links GTK 3 and WebKitGTK
4.1. Off the Mac the app updates its own binary from its own build:
downloaded in the background, swapped in on restart or quit, and the
relaunched process waits for the old one before taking the gateway. The
window leaves room for traffic lights only on a Mac.
2026-09-24 03:22:02 +08:00
yetone 73ef0e5276 usemagpie.ai, and a magpie that updates itself
site/ is the website: a static page plus a worker that turns the newest
release of yetone/magpie-releases into an update feed (/api/latest, with
every file's SHA-256), stable download links and an install script.

The app asks the feed at start-up and every six hours, downloads a newer
version in the background, and installs it on Restart to Update or on
quit. A download must match its checksum and be signed by the same team
as the app it replaces. `magpie update` does the same from a terminal and
replaces a bare binary in place.
2026-09-24 01:57:50 +08:00