Commit Graph
3 Commits
Author SHA1 Message Date
yetone c3b2e6109b provider: signing in to a plugin again takes the lapsed mark off when the providers' list is empty too (#2748)
clearPluginLapse cleared an account's "sign in again" mark only through
plugin.Cached(): it looked for the plugin's provider in the list and
cleared nothing when it wasn't there. The list is empty while
checkList reads another magpie's change to plugins.json again
(provCache = nil, before the providers file is written), so a sign-in
finished then left the account lapsed until a request or usage read
went through. TestPluginLoginTakesTheLapseOff (internal/cli) went red
that way on ubuntu CI twice (runs 39216129687 and 39234604936: "signed
in again, but still lapsed").

The mark now goes by the account's agent and key alone
(notePluginLapseOf), with the same sign-in count ordering as before;
only the stale usage reading still needs the provider, and is still
dropped when it is listed.

TestPluginSignInClearsLapseWithoutTheList saves two lapsed plugin
accounts with no plugin listed, signs one in again, and checks its mark
went and the other's stayed. On the old plugin_accounts.go it fails:
  plugin_fetch_lapse_test.go:83: signed in again, but still lapsed:
  "gone@fake's FakeCo sign-in has expired — sign in again"
and passes with the change.

Whether CI's two reds were this empty list and not another path is
inferred from the code, not captured; #2748 stays open until CI has
gone a while without it.

Run on origin/main 9fd80b212 + this change, macOS, load ~170-230:
- gofmt -l internal/provider: clean; go vet ./internal/provider/;
  GOOS=linux and GOOS=windows go vet -tags nogui on internal/provider and
  internal/cli: ok
- go test -timeout 45m -count=1 ./internal/provider/ ./internal/cli/:
  ok provider 552.7s, ok cli 324.7s
- -run 'TestPluginLogin|TestPluginSignIn|Lapse' on both packages, 5
  times: ok every time
- not the full ./... suite: the change is internal/provider's lapse
  clearing, and the two packages that sign plugins in were run whole.
2026-10-19 18:58:42 +08:00
yetone 2da8fbe488 tests: every test that runs plugins on the bun on PATH runs it once first, through testenv.Bun, so a bun that has never run here doesn't time out internal/provider's and internal/plugin's plugin tests (#1306)
65dcc573 (ggbdpq's patch 1) warmed the bun on PATH before the root
package's one-minute plugin contexts. The same lookup of the bun on PATH
is in 40 more places in internal/provider (28), internal/gateway (8),
internal/plugin (3) and internal/gui (1), and in the root package's
TestPluginListSaysClash. Many of them then open a one- or two-minute
context (internal/provider's sign-in, fetch and move tests,
internal/plugin's sandbox), and there macOS's first-exec check of a
just-installed or upgraded bun landed inside the deadline. The rest
are covered the same way, so no test has to remember which is which.

testenv.Bun now does what the root package's pathBun did: it finds the
bun on PATH (skipping the test when there is none) and runs
`bun --version` before the test opens its context, once per bun per test
binary. pathBun is gone; every `exec.LookPath("bun")` + skip block in
the tests uses testenv.Bun instead. Three tests reach for the bun some
other way and are left as they were: TestHostRunsAsMagpieBun (7ddea2c2
covers its copy), the plugin_git test's realBun and netproxy's
TestBunThroughBridge, none of which runs the plugin host under a
deadline on the PATH bun. migrate_test.go needed two `err` declarations
that the removed block used to provide.

What was run (macOS arm64, bun 1.4.2), with a wrapper bun first on PATH
whose first exec sleeps 61s (marker-gated, then execs the real bun):
- Red, old code:
  - internal/provider TestPluginSignInTakesAPastedCallback: FAIL at
    61.1s, "pluginsignin_paste_test.go:36: starting plugins: context
    deadline exceeded".
  - internal/plugin TestFakePlugin: FAIL at 62.0s, "plugin_test.go:66:
    Plugins = [], starting plugins: context deadline exceeded".
  - internal/gateway TestPluginFailover passed on the old code too (its
    calls have no deadline that short), so the gateway is not shown red.
- Green, this change, same cold wrapper: the three tests passed (61.1s,
  62.9s, 61.2s).
- go test -tags nogui -count=1 for the root package and for
  internal/testenv, gateway, gui, plugin and provider, under a temp HOME
  with GOMODCACHE, GOCACHE and GOPATH pinned: all ok.
- gofmt -l on the changed files: clean. go vet of those packages for
  darwin (-tags nogui), GOOS=linux and GOOS=windows (-tags nogui), and
  GOOS=windows without the tag: clean.

Not run: a really cold bun on a loaded machine; the sleep stands in for
the check. Not run on Linux or Windows, where the warm-up is one extra
`bun --version` per test binary.
2026-10-10 10:22:59 +08:00
yetone 4f9dcb39e5 plugins: a plugin subscription goes through every path a built-in one does (the user: 要保证插件订阅 provider 跟内置的订阅 provider所有逻辑都要一模一样) — a SOCKS5 proxy on a plugin provider or account now carries its requests: Bun speaks http(s) proxies only, so magpie stands a loopback http proxy in front of the SOCKS one, and a proxy that refuses says so as Go's transport does. A plugin's model list and its loader are asked through the account's own proxy, as a built-in's list is fetched through it. The Grok plugin draws and makes videos at Grok's Imagine API through the plugin, and keeps Codex's namespaced tools, as the built-in does; an official plugin beside its built-in (kiro-plugin, zcode-plugin) counts tokens by estimate as the built-in and the moved plugin do. FetchNew no longer re-lists plugin providers every ten minutes, their list being told by the plugin host; a plugin account's usage is cached under one name whichever way it is asked for; and a fetch hook that throws on its sign-in (a refused refresh) marks the account lapsed, as a built-in's refused refresh does. TestPluginSOCKSProxy, TestPluginModelListThroughAccountProxy, TestGrokPluginDraws, TestPluginBesideBuiltinCountsByEstimate, TestFetchNewLeavesListedPlugins, TestPluginUsageReadOnceWhicheverName and TestPluginFetchSignInExpiredLapses fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass (the known load flakes pass alone); internal/plugin, netproxy and the plugin/proxy tests of provider and gateway pass on Linux and Windows. 2026-10-01 19:07:12 +08:00