Commit Graph
3 Commits
Author SHA1 Message Date
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 0361189f9e test: every package's tests pass on Windows, and none writes outside its sandbox (the user: 把 Windows 上那几个失败的测试修掉) — on a Windows box the suite failed in most packages, and the root package hung for 25 minutes. Tests set HOME, which os.UserHomeDir ignores on Windows (it reads USERPROFILE), so they read and wrote the runner's own home; each now sets USERPROFILE beside HOME, and Devin's, Goose's, Crush's and Claude Desktop's tests set APPDATA/LOCALAPPDATA, where those keep their files there. said() read the command's output only once it returned, and a pipe holds a few KB on Windows, so magpie model --help blocked forever; it reads while the command writes. Unix permission bits (the gateway key store's 0600 too), exec bits and symlinks Windows lacks are checked only off Windows; TOML strings hold Windows paths as literal strings, JSON as marshalled ones; a URL's path is compared as one. The provider and usage packages run in a home of their own (TestMain, as the gateway's already does), since a CLI's identity kept by a refresh still going when its test ended landed in the runner's ~/.config/magpie — and on a Mac in the user's own. Two product fixes came out of it: imagemcp took a file:///C:/… root or image for the path /C:/…, which doesn't exist on Windows, and now makes a Windows path of it (a host for a UNC share); and session discovery could keep a new Cowork session hidden on Linux, where a folder's mtime is a kernel tick and its size doesn't change, so an entry added within the tick of the last listing left both as they were — a listing made within 2s of its folder's last change is read again, as git does for racy files. TestFilePath and TestRacyDirectoryListedAgain fail without the change. On Windows 11 every package passes (32 of 32) and a run of each package in a fresh home leaves nothing in home, APPDATA or LOCALAPPDATA; on Linux (WSL) and macOS go test -tags nogui ./... passes. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build pass. 2026-10-01 23:15:07 +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