The terminal and `magpie serve` never called provider.FetchNew, which the
window calls at start: a signed-in Cursor account's list exists only at
Cursor, so the TUI's Routing pickers (and a headless gateway's /v1/models)
offered the fallback cursor/auto alone until the list was fetched by hand
with m on the Providers page.
- tui: Init fetches the new lists (fetchModelsCmd, alongside the catalog
sync). A model picker open when they arrive (Routing members, the
classifier, a provider's models, an agent's model field) is filled in
place through its relist, keeping its filter and the model under the
cursor. A list left missing (no network) is asked for again a minute
later (modelsRetry). Built on reyoung's branch and test.
- serve: FetchNew at start, again each minute while a list is missing.
- provider: FetchNew reports whether a list is missing, and waits for a
CLI asked who is signed in for the first time (awaitIdentities), then
lists the accounts again. With the real Cursor account in a fresh
sandbox, `cursor-agent about` answered after a look's 3s firstAsk, so
FetchNew saw no Cursor account and `magpie serve` still listed 1 model
with the TUI fix alone. The window's startBackend gets the same wait.
- docs: providers-accounts.md says who fetches the lists and when.
Run:
- internal/tui TestTUIFetchesSubscriptionModels (6 views) and
TestTUIAsksAgainForAMissingList, -race x3; red with the Init fetch,
the relist, the cursor restore or the retry tick each removed by hand.
A first `about` slowed to 12s injected: passes (the test re-asks).
- internal/provider TestFetchNewWaitsForASlowSignIn: red without
awaitIdentities (no provider "cursor"); TestFetchNewAccount covers the
missing result.
- Real Cursor account, sandbox HOME with a keychain holding only Cursor's
two items: TUI on main showed cursor/auto only in Routing; the fix shows
the full list and "24 models" on Providers. `magpie serve`: main 1
Cursor model at /v1/models, the fix 24 within 5s.
- gofmt -l, go vet (darwin, GOOS=linux, GOOS=windows), go test ./... in a
sandbox HOME.
Not tried: Linux and Windows real Cursor CLIs (the fake CLI tests skip on
Windows); Devin's CLI identity goes through the same wait but wasn't
tried with a real account.
What changed: Settings → Privacy → Subscription accounts (On/Off),
`magpie accounts discovery [on|off]` and MAGPIE_NO_ACCOUNTS=1 turn off
account discovery. It stays on by default. While it is off, magpie reads
none of the agents' sign-ins: ~/.claude/.credentials.json, .claude.json's
account, ~/.codex/auth.json, Copilot's, Cursor's, Devin's, Kiro's,
Gemini's, ZCode's, Command Code's and OpenCode's files. It runs no
`security` / `secret-tool` for the Keychain or Secret Service, and asks no
agent CLI who is signed in. It serves no subscription. API-key providers,
middleware plugins and Pi extensions work as before.
Why: the reporter runs magpie on machines where reading other tools'
credentials isn't wanted. The owner delegated the call.
How: settings.NoAccountDiscovery (kept per computer by KeepOwn) and
settings.AccountDiscoveryOff(). The variable only ever turns discovery
off. The gates sit at every reader (readAccountFile, discoveryOff) and at
every route that reads or writes a sign-in, so a route that skips
Accounts still reads nothing:
- Accounts, All, Logins, usage, renewal, warm-up, session identities,
check-ins;
- switching, forgetting, SetLoginOn, StartSignIn, the imports;
- moves onto plugins.
The ones that write refuse with an error that names how to turn it back
on. On the agent side, Agent.Source and OpenCode's auth.json are gated,
and Codex wiring goes by magpie's stash instead of auth.json, so a
toggle never rewires Codex. logins.json and plugin-auth.json are left
untouched and serve again when discovery is turned back on. A change
applies at once (ForgetAccounts).
Docs: providers-accounts.md, README (en, zh-CN), and the site's CLI table
(en, zh, ja).
Run:
- TestAccountDiscoveryOffReadsNoSignIn (provider) and
TestAccountDiscoveryOffAgentsReadNoSignIn (agent). Every credential
path is a FIFO that records each open, and security, secret-tool,
claude, codex, cursor-agent, devin, kiro-cli, copilot and grok are fakes
on PATH. Both fail with the gate removed: they show the opens and
`security find-generic-password -s Claude Code-credentials`, among
others. Both pass with the gate in place.
- TestAccountDiscoverySetting and TestAccountsDiscoveryCmd.
- account-discovery.test.cjs: chromium and webkit, 900 and 360 wide,
en/zh/zh-TW/ja/de, 32/32. The neighbouring privacy, redact,
settings-sections and i18n-keys GUI tests: 49/49.
- The full `go test -tags nogui ./...`, gofmt -l, and go vet for darwin,
linux and windows on the touched packages.
Not tried: a real machine under fs_usage, and Linux and Windows at
runtime. The FIFO tests are !windows.
TestDshHomePickSurvivesSyncAndEffort failed under full-suite load and
passed alone. The cause is cliIdentity: a look starts an ask of the CLI
(a failing testenv stand-in) and, once the answer is a minute old, a
refresh in a goroutine. keep() writes cli-identity.json under the
XDG_CONFIG_HOME current when it finishes, so an ask slow under load,
still going when its test ended, wrote into the config folder of the
test running then while t.TempDir's cleanup was removing it:
"TempDir RemoveAll cleanup: ... directory not empty".
4ee3a76b fixed this for internal/gateway alone (KeepCLIIdentities=false
in its TestMain). internal/agent, and every other package whose tests
read the accounts (., access, backup, davsync, gui, profile, sessions,
stats, tui, usage), still could. keep() now skips in any binary testenv
isolated (MAGPIE_TEST_SANDBOX, as internal/proc's sandboxVar reads it),
and the provider tests of the file itself turn keeping back on with
keepIdentities(t). The gateway's own switch and its test are gone;
TestCLIIdentityNotKeptInATestBinary covers every package.
Ran:
- Reproduced by injection (get refreshes on every look, 15ms sleep after
c.ask()), agent Dsh tests -count=3: old code red 2 of 6 runs with the
exact TempDir cleanup error; new code 0 of 6.
- Broke by hand (keepsIdentities() returns true):
TestCLIIdentityNotKeptInATestBinary red, "written in a test binary".
- go test -count=1 ./internal/provider ./internal/agent ./internal/gateway: ok
- gofmt -l clean; go vet provider, agent, gateway on darwin,
GOOS=linux -tags nogui, GOOS=windows: clean.
TestEncodedBodyInflatedPastLimit failed under load at its TempDir cleanup
("unlinkat .../001/magpie: directory not empty"). The server wasn't the
writer: New() starts no goroutine, and httptest's Close waits for the
handlers. The writer is provider's cliIdentity. Reading the accounts
reads Cursor's and Devin's identity. In the gateway's tests, testenv's
stand-in cursor-agent and devin are on PATH, so their CLIs count as
installed. After the first answer, a look older than a minute asks the
CLI again in a goroutine and doesn't wait for it. When the stand-in
answers signed out, keep() writes cli-identity.json (MkdirAll, then a
temp file renamed in) under the XDG_CONFIG_HOME of whatever test is
running then. Under load the stand-in takes seconds, so the write lands
as that test's TempDir is removed.
Found by injecting a delay, not by rerunning. With get() refreshing at
every look and a 15ms sleep after the ask, a -count=3 run of
TestEncodedBodyInflatedPastLimit failed 3 subtests with the exact error
from the issue (/v1/responses/zstd, /v1/chat/completions/zstd,
/v1/videos/gzip). With this change and the same injection,
-count=5 of TestEncodedBody*, TestUnknownBodyEncodingRefused and
TestKeyLimitReservesDecodedBody passed.
provider.KeepCLIIdentities (default true) now decides whether the
answers are kept on disk. The gateway's TestMain turns it off, as it
already turns off keepRoutes for the same reason. Production doesn't
change. TestNoCLIIdentityKeptInTests goes red if TestMain leaves it on.
TestCLIIdentityNotKeptWhenOff checks that an answer is still served and
nothing is written.
The same pattern: every gateway test that calls New() and never stops it
was a suspect. Server has no Stop and New() starts nothing, so the pattern
itself is harmless; the background write was the cause wherever a
request looks at the accounts. provider's own tests still keep
identities on, since several of them test the file; they haven't failed
this way.
Run: go test -tags nogui -count=1 -timeout 40m ./internal/gateway
./internal/provider (ok); gofmt -l; GOOS=linux and GOOS=windows go vet
-tags nogui ./internal/gateway ./internal/provider.
Cursor's and Devin's sign-in is read from their CLIs (cliIdentity), asked
again behind what is served once the last answer is a minute old. A
cursor-agent that calls itself (an old ~/.local/bin wrapper running
`cursor agent`) never answers: each ask ran its 10s timeout and started
hundreds of processes, every minute magpie's pages or gateway read the
accounts. With no Cursor token kept, it still counted as an answer (nobody
signed in), so a "failed asks back off" rule alone would not have reached
JJ-Lin's case: an ask that takes slowAsk (5s) or longer backs off too. A
quick answer, or a sign-in or out (forget), has the CLI asked every minute
again. What is served is unchanged: a failed ask keeps it, a slow answer is
taken as before.
Verified:
- red without the change: TestCLIIdentityFailingAskedLessOften/fails and
/slow both fail with "asked again a minute after the second"; pass with
it (-race -count=3 with the other TestCLIIdentity tests).
- go test -tags nogui ./internal/provider/ in a sandbox HOME; go vet -tags
nogui of provider for darwin, linux and windows.