Files
magpie/internal/daemon
yetone 5e30d5b5ae autostart, gui: Open at login says when the Mac's own switch for it is off (#2120)
Anoninz on #2120: Settings said Open at login was On while System
Settings › General › Login Items › Allow in the Background had magpie
switched off, so magpie never opened at login. autostart.Enabled now
returns a State: off, on, or needs allowing.

- macOS 13+: with the plist present, Enabled asks Background Task
  Management through SMAppService statusForLegacyURL: (cgo, ServiceManagement
  weak-linked, minos stays 12.0). RequiresApproval reads as needs allowing.
  Any other answer, a failed ask (-1), macOS 12 or a build without cgo
  (the darwin CLI release) leaves the plist alone deciding, as before: a
  failed read is never "off". launchctl print-disabled did not follow
  the switch on macOS 26.2, so it isn't used.
- BTM matches the item by the plist's Label, not its path: the tests ask
  about a label of their own, and TestMain stubs the ask so no test reads
  the user's real item.
- GUI: Settings › General keeps On and adds one line, "Switched off in
  System Settings’ Login Items…", with an "Open Login Items" button that
  opens x-apple.systempreferences:com.apple.LoginItems-Settings.extension
  through /api/open (that one URL is allowed; other x-apple URLs aren't).
  The window's focus reload clears it once switched back on. The row is
  hidden in magpie web, as before. Strings in zh, zh-TW, ja, de.
- CLI `magpie autostart` says where to switch it on. The daemon counts a
  held-back record as on (it is the user's choice, held by the system).

Part B (SMAppService.mainApp) is not in this commit: it can't be verified
here without registering in the user's real login items and logging out
to see a login launch stay tray-only.

Run:
- go test ./internal/autostart (cgo and CGO_ENABLED=0), cli, daemon, gui
  after rebasing on origin/main e4ac5e871: ok except gui's
  TestSetAnswersWhileDevinAndProvidersHang, red the same alone on
  origin/main e4ac5e871 at load ~400 (1 of 2), #1375.
- set -o pipefail; go test -timeout 45m ./... (base dd70c5e6a): every
  package ok but internal/agent, past 45m at load ~300; alone: ok (1761s).
- gofmt -l clean; go vet darwin; GOOS=linux -tags nogui and GOOS=windows
  go vet ./... clean.
- Broken by hand, each red: the binding always -1
  (TestLegacyStatusAsksTheSystem), heldBack always false and heldBack
  "!= Enabled" (TestEnabledFollowsTheSystemsSwitch); renderLoginAllow not
  called, the line not removed on focus, a wrong URL opened
  (login-allow.test.cjs).
- Real use, macOS 26.2, a build with the label patched to
  com.yetone.magpie-autostart-probe and the user's own HOME: autostart on
  -> "opens at login"; its Allow in the Background switch turned off in
  System Settings -> the needs-allowing message; back on -> "opens at
  login"; autostart off -> plist gone. com.yetone.magpie.plist untouched.
- GUI (playwright 1.62.0, chromium + webkit): login-allow.test.cjs new,
  40 of 40 (5 languages, 1000/440px, app and web). The 106 GUI files that
  load Settings or open URLs, 6 wide: reds were codex-predictions (#2624),
  segs-glide (#2683), lightweight (#2638), usage-checkin (#2549) - each
  the same alone on origin/main e4ac5e871 -, mobile-web (compares to
  origin/main, which had moved; 30 of 30 after the rebase), and
  account-alias and fonts under load only (#2984, pass alone). After the
  rebase: mobile-web, login-allow, settings-general, i18n-keys all green.
  The other ~700 GUI files were not run: at load 200-400 the whole suite
  was going at ~1000 tests an hour.
2026-10-20 02:29:39 +08:00
..