Commit Graph
2 Commits
Author SHA1 Message Date
yetone ab7cb55371 plugin: a page-only plugin's options are set under plugins.json's lock too (#4666)
0d6162c8a put every plugins.json change under the file's lock, but
SetPageOptions writes a page-only plugin's options itself, under listMu
alone, so another magpie's save meanwhile was still lost there. It now
takes listFileMu before listMu, as SetOptions does.

Run (mote, darwin/arm64):
- go test ./internal/plugin -run Meanwhile -v: the three Meanwhile tests ok
- page.go reverted with the test kept: TestPluginPageOptionsKeepWhatAnotherMagpieSetMeanwhile
  red ("SetPageOptions went on while another magpie held plugins.json's
  lock"); restored, green
- full suite (go test -tags nogui ./... -timeout 45m, mote) with this
  stack at b566b9d3c on 0b8c4bfc3: every package ok but two reds of that
  base, both fixed on main since: internal/cli
  TestEveryRouteHasACommandOrIsNamed (4c86b0ab4) and internal/tui
  TestEveryWordHasZh "permission mode" (e9fcc6229)
- rebased on f1c9014cd: go vet (darwin, linux nogui, windows) and
  go test of internal/gateway, internal/plugin, internal/cli and
  internal/tui at the pushed head: ok (gateway 899s, plugin 158s, cli, tui)
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., darwin/linux/windows builds: ok at b566b9d3c

Refs #4666
2026-11-15 06:40:19 +08:00
ggbdpq 5aa365349a plugin: a plugins.json change one magpie makes keeps what another saved meanwhile (#4666)
What changed: every change to plugins.json (Add, Remove, SetOff, Prefer,
SetOptions — the GUI's Plugins page, a plugin page's options bridge,
`magpie plugin options/prefer/remove`, migrate and backup) is now made
under the file's lock, plugins.json.lock, the same shape the accounts'
logins and mcp-signins.json are changed under: listMu is this process
alone, so the gateway and a magpie run from a terminal read, changed and
wrote whole lists past each other, and the later write went out with
what the other had saved since its read. Under the file lock every
change reads the file afresh, so both stand. A lock held longer than
filelock.Wait goes on without it, as before there was one; a file
system with no locks likewise. Reads are unlocked, as they were.

Run (darwin/arm64, GOCACHE pinned, upstream/main 873b4987e + this):
- go test ./internal/plugin -run 'TestPluginOptionsKeepWhatAnotherMagpieSetMeanwhile|TestPluginPreferKeepsWhatAnotherMagpieSetMeanwhile' -count=1 -race: ok
  (each red before the fix: "SetOptions went on while another magpie
  held plugins.json's lock" / "Prefer went on …", deterministic)
- go test ./internal/plugin -count=1 -timeout 25m: ok except TestHostToldTheGatewayAddress
  (a port-migration flake this machine's proxy already gave: red on the
  parent commit 873b4987e too, same "told MAGPIE_ADDR=127.0.0.1:3591")
- gofmt -l internal/plugin: clean; go vet ./...: ok;
  GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: ok
- go build, GOOS=linux go build -tags nogui, GOOS=windows go build: ok

Generated-by: GLM-5.3-Flash (ZCode)

Landed by the maintainer after (mote, darwin/arm64):
- this change's file(s) reverted with its tests kept: its new tests red;
  restored, green
- full suite (go test -tags nogui ./... -timeout 45m) with the stack on
  0b8c4bfc3: every package ok but two reds of that base, fixed on main
  since (4c86b0ab4 cli route parity, e9fcc6229 tui "permission mode")
- rebased on f1c9014cd: go test of internal/gateway, internal/plugin,
  internal/cli and internal/tui ok; go vet darwin, linux nogui, windows ok
2026-11-15 06:40:19 +08:00