4794de398ea8337d223a91e207181c56fcf4ad76
9
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e1b70c13de |
fix(autostart): a launch agent left half-written reads as Open at log… (#1079)
* fix(autostart): a launch agent left half-written reads as Open at login off, not on The Mac's launch agent, the Linux .desktop and the Android boot script were written with a plain write, which empties the file before it fills it, so a crash or a full disk part way through left a record that is empty or half there. launchd refuses a job that names neither its own label nor a program, and the desktop starts no entry with no Exec, so magpie simply never opened at login. Enabled() on the Mac and on Linux asked only whether the file was there, so Settings kept showing the switch on; and Refresh(), which the app runs at every start, rewrites only a record its ProgramArguments regexp can still find a program in, which a half-written one does not have. Nothing repaired it and nothing said so, so the user was left believing a switch that did nothing. The four writes of these records now go through edit.WriteAtomic, which writes a temp file beside the record and renames it over: a write lands whole or not at all, and one cut short leaves the previous record, still loadable, where it was. No import cycle: internal/edit brings in only internal/steady and internal/filememo. enabled() on the Mac and on Linux now asks whether the record is one that starts magpie — the launch agent names both its label and its program, the desktop entry has both its Type and its Exec — instead of whether the file is there. A record a write cut short now reads as off, so the switch stops saying magpie opens at login when it does not, and the user sees the off that Refresh() cannot repair. A record magpie did not write is still left alone by Refresh() (TestRefreshOlderLaunchAgent), which is unchanged: refresh() rewrites what it can parse, and enabled() reports off for what it cannot. Windows' Run key is not touched here. TestSetThenTruncatedRecordReadsAsOff is new, once for the Mac (autostart_darwin_test.go) and once for Linux (autostart_other_test.go), where the record is written whole and then left as a write cut short leaves it: the head, stopping before the program it names, and the same record emptied. Against the old code, whose check was os.Stat, the Mac one fails with "a launch agent with no ProgramArguments reads as on" and the Linux one with "a desktop entry with no Exec reads as on", each on both records. With the change both pass, and TestSet, TestRefreshOlderLaunchAgent and TestLaunchAgentLetsTheRelaunchLive are unchanged. go vet, the windows, darwin and linux builds and test compiles, and gofmt on the seven files (LF-normalized first, since the worktree is CRLF) pass. Not run on a Mac or with plutil: this is a Windows box, so the darwin and linux behaviour is checked by GOOS=darwin and GOOS=linux builds plus their test compiles, and the two new predicates were run here against the bytes those platforms write from a scratch harness, which showed the old os.Stat check reading all three records as on. That harness is not committed. * fix(autostart): a record that names nothing to run reads as off The Linux and Mac checks the last commit added ask for the Exec key and the ProgramArguments array, not for anything in them, so a record whose Exec is present and empty still read as on. A desktop starts no entry that names nothing to run and launchd refuses a job whose program is an empty string, so that is the same lie the truncated record told, in the one shape the truncation could leave that the check didn't cover. entryExec now wants a non-space after the key, and program wants something other than the closing tag in the first string. Android's check needs nothing here: it reads the file's exec bit, which a write cut short does not leave on it. Each of the two tests now writes the empty-valued record beside the truncated one and the empty one, so all three shapes are covered. * fix(autostart): the darwin check's new block sits inside the function The block added to TestSetThenTruncatedRecordReadsAsOff landed after the closing brace, so the darwin and linux jobs answered "autostart_darwin_test.go:134:2: expected declaration, found empty" at the gofmt step and nothing of the package was ever compiled there. Windows never compiled the file, so the branch was green on the one platform that could not see it. The block now sits before the closing brace with the rest of the check. Verified on Windows with go1.27.2: go vet ./internal/autostart passes for windows/amd64, darwin/arm64 and linux/amd64, and the package's tests pass. --------- Co-authored-by: TryWorld <TryWorld2026@users.noreply.github.com> Co-authored-by: yetone <yetoneful@gmail.com> |
||
|
|
c31dcb8824 |
fix(autostart): turning Open at login off says so when the Run key refuses it (#1081)
* autostart: the Run key is reached through one variable disable and enabled open HKCU\...\CurrentVersion\Run themselves, so a test can only reach whatever the real user's key answers — and this machine's own Run key opens with SET_VALUE, which is exactly the case that hides the bug. One variable holds the open, so a test can hand back a key the user's ACL refuses, as the probe key this change was checked against did. No behaviour changes: the variable is registry.OpenKey, and the two call sites answer as they did. * fix(autostart): turning Open at login off says so when the Run key refuses it magpie autostart off returned success for every error from opening HKCU\...\CurrentVersion\Run, and the Settings switch did the same, when the Run key's ACL denies the user SET_VALUE: the magpie value was left where it was, Windows started it again at the next sign-in, and the switch showed off. Confirmed on this machine with a probe key under HKCU whose ACL denies SET_VALUE but allows QUERY_VALUE: OpenKey with QUERY_VALUE reads the value fine while OpenKey with SET_VALUE returns Access is denied, which is not registry.ErrNotExist, so the old disable() read it as "nothing to turn off". The probe key was removed afterwards; the real magpie Run value was never opened for writing. disable() now returns an error that isn't a missing key, as the three file-backed platforms already do: they ignore only "the record isn't there" and report the rest. The other OpenKey calls in the file are classified the same way, each through its own variable so a test can refuse it: enabled() told the two apart already; switchedOff() now returns errors.Is(err, registry.ErrNotExist), because a marker that cannot be read is not "switched off" either — the Run value is what starts magpie, and reporting off would hide that; and what enable() did to the marker unchecked is now clearApprovedMarker(), which returns every error that isn't a missing marker, so Set(true) no longer answers success while Task Manager's Startup apps marker still tells Windows to leave magpie switched off. The Run value is written before the marker is cleared either way, so that is the one step left that can leave the switch on and Windows starting nothing. TestDisableReportsAKeyItCannotReach checks that Set(false) returns an error for Access is denied and none for ErrNotExist. TestEnabledUnreadableKeyIsNotOff checks that a Run key that cannot be read is not read as off while a missing one is. TestClearApprovedMarkerReportsOneItCannotReach checks the same pair for clearApprovedMarker, and TestSwitchedOffUnreadableMarkerIsNotOff that a marker which cannot be read is not read as switched off while a missing one is. Run here against disable() as it answers every error with nil, TestDisableReportsAKeyItCannotReach fails with "a Run key that refuses SET_VALUE was reported as turned off"; against clearApprovedMarker() as it returns nil for an OpenKey error and drops DeleteValue's, it fails with "a Startup apps marker that cannot be cleared was reported as on"; and with switchedOff() still folding its OpenKey error into false, TestSwitchedOffUnreadableMarkerIsNotOff fails with "no marker reads as not switched off". All four pass with the change. TestSet still skips on Windows, where the Run key is the real user's; none of the new tests opens it. go vet, gofmt (on LF-normalized copies, since the worktree is CRLF), the windows, darwin and linux builds and test compiles, and go test -race ./internal/autostart pass. The real Run key on this machine still opens with SET_VALUE, so the ordinary path is unchanged; only a key the ACL does refuse is reported. The StartupApproved\Run key itself was not probed — this machine has no marker for Task Manager to have switched off — so that half rests on the four tests and on OpenKey answering a key with the refusing ACL the way it answered the Run key above. * fix(autostart): no Startup apps marker at all is not switched off switchedOff answered errors.Is(err, registry.ErrNotExist) for a Startup Approved\Run key it could not open, so a machine with no such key at all read as switched off. Windows writes that key the first time Startup apps lists an entry: a user who never opened Task Manager's Startup apps has no key, while every Run value the machine has is on. enabled() ends in !switchedOff(), so Settings showed "login: off" and the tray said magpie doesn't open at login for a magpie that does start at every sign-in. Only a marker that says so is switched off now: one that is missing, or that cannot be read, is not. The comment above the function said as much already, which is what gave the wrong answer away. TestSwitchedOffUnreadableMarkerIsNotOff had pinned the wrong half of this: its last pair asserted that no marker reads as switched off. It is now TestSwitchedOffUnreadableOrAbsentMarkerIsNotOff, asserting neither case is. TestEnabledWithNoMarkerIsOn covers the real machine the first one could not: the Run value there, the marker key not, which is what a user who has never opened Startup apps has. The Run value's read goes through readRunValue beside openRunKey and openApprovedKey, so a test can hand back a value with no Run key of its own: the package's other tests skip on Windows because the Run key is the real user's, and these read it. --------- Co-authored-by: TryWorld <TryWorld2026@users.noreply.github.com> |
||
|
|
40e9df4e70 |
autostart: Open at login is listed as magpie in Login Items, not under the developer's name on its signature (#1512, ysicing)
System Settings > General > Login Items ("Allow in the Background")
listed magpie's launch agent as "Xipeng Guan" with a blank icon: a plain
LaunchAgent is attributed to the name on its program's signature unless
the plist names the app it belongs to. The launch agent now carries
AssociatedBundleIdentifiers with the bundle id read from the app's own
Info.plist (com.yetone.magpie for a release), Apple's supported way for
an app's legacy launch agent (macOS 13+; older systems ignore the key).
A program outside an .app names none. Refresh already rewrites an older
magpie's plist at start, so users who turned it on before get the key
without toggling; an Info.plist that fails to read never drops a key
written before.
SMAppService was not taken: it needs a plist inside the signed bundle and
a cgo/ObjC bridge, and changes how Enabled is read, a bigger move for a
display-name fix.
Run: TestLaunchAgentNamesItsApp fails on the old code (no
AssociatedBundleIdentifiers) and with the unread-Info.plist guard
removed; passes now, plutil -lint and plutil -extract read the key.
A plist written for /Applications/magpie.app into a sandbox HOME lints
OK and names com.yetone.magpie. go test -tags nogui ./internal/autostart,
gofmt -l, go vet, GOOS=linux/windows go vet -tags nogui pass.
Not tried: the Login Items pane itself with a real login item
(~/Library/LaunchAgents is off-limits here); the reporter confirms.
|
||
|
|
21702d01ff |
Add German translation; harden paths against unset env vars (#770)
* Add German translation and harden paths against unset env vars Add a German locale to the GUI, tray menu, usage alerts and website home page, and refuse to start when the home folder is unset or relative so nothing is written under the working folder; the pi plugin no longer adopts the user's PI_CODING_AGENT_DIR, and an inherited APPIMAGE no longer selects portable mode. Scripts refuse to run from the wrong folder or empty a shared out folder, and a new internal/testenv sandboxes every test package from the user's real files, which also fixes the Claude picker and Termux installer tests on Windows. * Makefile: know magpie's folder by its go.mod, so paths with spaces work The check compared $(CURDIR) with $(dir $(abspath …)), which make splits on spaces, so a checkout under 'My Projects' or 'John Doe' refused every target. It now reads go.mod relative to the working folder and wants magpie's module there: make -C and a symlinked Makefile work, make -f from another folder still stops before any recipe runs. * i18n: German for the strings main added since, with a parity test 75 strings main added (group order, patterns, slow-start wait, usage caps, RTK savings …) get their German, and two that main dropped go. gui-de.test.cjs checks, as gui-ja does, that de has every zh string with its placeholders and tags, and that the window reads in German when picked or on a German system. * appdir: ignore relative folder variables when reading, keep them for children CheckEnv no longer unsets anything. magpie reads the XDG folders, APPDATA/LOCALAPPDATA and every agent's folder variable through appdir.Getenv/LookupEnv, which pass over a relative value; the environment stays as it is, so the agents magpie starts get the variable as the user set it. That covers what proc.UserPath lends from the login shell too, which is set after main's check and reached the desktop app unchecked. On Windows a path rooted on the current drive (\Users\x, Git Bash's /c/x) counts as usable, and magpie version and help answer without a home, before run makes any folder. * Sandbox the tests main added since internal/wslrun gets testenv's TestMain, and four tests main added that set HOME alone set their home with testenv.SetHome, so on Windows they don't read the runner's profile through USERPROFILE. * agentenv: PI_CONFIG_DIR and OPENCODE_DB take relative names on purpose omp puts $PI_CONFIG_DIR under the home and OpenCode a relative $OPENCODE_DB in its data folder, so neither depends on the working folder: appdir no longer passes them over. * i18n: German for the Library's multi-select and System One's decision API The 19 strings main added since (#791's skill multi-select, the decision API snippets) get their German; the one main replaced (four APIs → five APIs) goes. * appdir: tidy the import into magpie's group; say what Go makes of /c/x The appdir import joins the group of magpie's own imports where a file has one. rooted's comment now says that Go takes a Git Bash path like /c/x as \c\x on the current drive, not C:\x. |
||
|
|
69368007b0 |
termux: support Android builds and installation (#644)
* termux: build natively and run plugins on Bun 1.4.2 Select nogui for Android builds, open browser and OAuth links with termux-open-url, and write an executable Termux:Boot script that starts the gateway with shell-quoted paths. Bun 1.3 has no official Android build. Upgrade the default plugin runtime to 1.4.2, add the official Android arm64 and amd64 download targets, and update SHA-256 checksums for every supported platform. Document Termux installation, startup and source updates. Validation on Termux arm64: - Native build and go vet pass. - A fresh config downloads and verifies Android Bun 1.4.2 and loads a test plugin. - Boot startup can be enabled and disabled. - The Web page, authenticated state API, unauthenticated API rejection, gateway healthcheck and Web quit action work. - Browser argument preservation, boot path quoting and permissions, and plugin tests pass. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a10014-56c1-73d3-b3ee-2ea569713989 * site: install Android builds in Termux Detect Termux through TERMUX_VERSION or its PREFIX and select the Android CLI asset instead of a Linux binary. Install into PREFIX/bin by default, keep MAGPIE_BIN_DIR overrides, and suggest the Web or terminal interface without Linux desktop setup instructions. When the release has no Android asset, explain how to build from source. Add android/arm64 to release-cli and stop the build loop on failure. Document the installer and its release-asset requirement. Shell syntax and all 11 site tests pass, covering platform selection, custom paths, missing assets, checksum rejection and existing Linux installation paths. The Android arm64 release build succeeds on Termux; with a simulated release feed, the installer verifies and installs that binary into PREFIX/bin and the installed command runs successfully. Amp-Thread-ID: https://ampcode.com/threads/T-01a10014-56c1-73d3-b3ee-2ea569713989 Co-authored-by: Amp <amp@ampcode.com> * ci: check Android releases and the installer Build both linux/amd64 and android/arm64 through make release-cli in the CLI test matrix. Run the site and installer tests in the Linux job with Node 22, and check the installer's shell syntax. The release workflow in yetone/magpie-releases already calls the source Makefile's release-cli target, uploads dist/magpie-cli-*, and generates checksums for every artifact. The Android target added to TARGETS is therefore included without changing that workflow. Replace the full Termux README section with a short platform note beside the Linux and Windows installation requirements, removing duplicate commands, the fork URL and temporary release availability details. Both CLI release builds, all 11 site tests, shell syntax checks and actionlint validation pass locally. Amp-Thread-ID: https://ampcode.com/threads/T-01a10014-56c1-73d3-b3ee-2ea569713989 Co-authored-by: Amp <amp@ampcode.com> --------- Co-authored-by: Amp <amp@ampcode.com> |
||
|
|
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. | ||
|
|
ee16c6576d | autostart: a magpie opened at login comes back from "update and restart" on the Mac (悠悠哥 on Discord: 更新后开机自启动没了) — open at login was never lost: the Mac's launch agent runs magpie as a launchd job, and launchd ends whatever a job started once the job exits, so the shell update.Relaunch leaves to open the new version was killed as magpie quit and magpie never came back. The launch agent now carries AbandonProcessGroup, and the desktop app rewrites one an older magpie wrote in the current form at start, keeping the program path it names; with none it stays off, and a launch agent magpie didn't write is left alone. Two throwaway launchd jobs showed children, detached ones too, killed on the job's exit without the key and living with it. TestLaunchAgentLetsTheRelaunchLive and TestRefreshOlderLaunchAgent fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. | ||
|
|
532325f7a6 | autostart: on Windows, Open at login switched off in Task Manager's Startup apps reads as off, and switching it on in magpie switches it on there again | ||
|
|
0669c450e3 | settings: Open at login starts magpie in the tray when you log in, so agents find the gateway from the start — a launch agent on the Mac, the user's Run value on Windows, an autostart entry on Linux, which is where whether it's on is read from too (magpie autostart [on|off] in the terminal) |