01aaa8e9258b34ff4e11794f3a6fd1587f60e2df
2114
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
01aaa8e925 | plugins: the built-in market lists OpenCode Zen Free (@magpie-community/opencode-zen-free-auth), OpenCode Zen's free models, with the bundled opencode icon | ||
|
|
d40fee800d |
library: Pi's mcp.json is backed up to ~/.config/magpie/backups before magpie moves it whole to mcp-adapter.json, as it already was before a merge (#1097, heliar-k)
piMove renamed mcp.json to mcp-adapter.json when the adapter's file wasn't
there yet, with no copy kept. The user's file is now copied aside first;
one that can't be copied isn't moved.
Verified: TestPiMCPWholeMoveKeepsABackup (the reporter's layout: adapter
only in npm/node_modules, packages: [], a user-owned mcp.json) fails
without the change ("backups of mcp.json: []") and passes with it.
go test -race ./internal/library green under a temp HOME.
|
||
|
|
c83c0d5fef |
gateway: sharing keeps the host MAGPIE_ADDR names (127.0.0.1 behind Tailscale Serve, one interface's address) instead of listening on every interface, and still asks what reaches it from elsewhere for a gateway key (#1112)
listenAddr turned sharing into 0.0.0.0:<port> and dropped the host of an
explicit MAGPIE_ADDR, so requiring gateway keys from remote callers also
widened the listener. A host MAGPIE_ADDR names is now kept while shared;
0.0.0.0, :: or no host still means every interface, and an unset
MAGPIE_ADDR still shares on every interface. LANURLs offers the pinned
address alone, or none on loopback (MAGPIE_PUBLIC_URL says the proxy's).
Verified: TestSharedKeepsPinnedAddr fails without the lan.go change
("shared, MAGPIE_ADDR on loopback, listens on 0.0.0.0:4555") and passes
with it, -race -count=20. go test -race ./internal/gateway ./internal/gui
green under a temp HOME.
|
||
|
|
6b6113aa7a |
gateway keys: a key can be created with a value of the user's own, one their clients already send, so moving from another gateway (CLIProxyAPI's api-keys) doesn't mean re-keying every client (love1sbug on X)
Gateway → Gateway keys → Add gateway key has a second field, "Your own key
(optional)"; `magpie gateway-key add <name> --key <value>` (or `--key -`
from stdin) does the same. Left empty, magpie makes a sk-magpie-key- as
before. A value is 8–256 printable ASCII characters with no spaces, can't
start with sk-magpie-, and can't be another key's. The list shows only its
last four characters ("…0042"); rotating it gives a magpie-made key.
From another computer any enabled key was already checked, so an own value
works there as is. From this computer the gateway only identified a request
whose key looked like sk-magpie-…, so an own value would have been let in
unidentified: not counted as the key, nor held to its limit, models or
accounts. managedKey now asks access.Named, which also knows the store's
own values (cached by the file's size and time).
Tested: go test -race . ./internal/access ./internal/gateway ./internal/gui;
-count=20 on the new and LAN guard tests; TestOwnKeyValueIsTheKey fails with
managedKey back on access.Managed. gateway-own-key.test.cjs passes 16/16
(chromium and webkit, en/zh/ja/de, 1000 and 440px), and the gateway-key
suites, i18n-keys, gui-ja and gui-de pass. A built binary in a sandbox HOME
with sharing on: own key from the LAN address 200, a wrong or no key 401,
from 127.0.0.1 200, the old value after rotate 401. GOOS=linux and windows
builds pass.
|
||
|
|
290c60a31e | docs: Plugins says a GitHub repository tagged magpie-plugin is listed under Discover as unofficial (en, zh, ja) | ||
|
|
f6f960e42c |
plugins: a GitHub repository tagged magpie-plugin shows on the Plugins page under Discover, as an unofficial plugin nobody at magpie has reviewed
GitHub's search for topic:magpie-plugin (not archived, not a fork, not magpie-community's own, which the market lists) is asked at most every six hours and kept on disk, so a restart or GitHub being down shows what it said last. Each repository is read from its package.json on the default branch. When npm has that package published from the same repository, it is installed from npm, because a repository often builds its dist only to publish and Bun runs no build for a git install. Otherwise it is installed as github:owner/repo, and only if the file it loads (exports, main or magpie.middleware) is in the repository. Its page warns that it is unofficial, says whether npm or the repository is what gets installed, and shows the repository's README until it is installed. MAGPIE_PLUGIN_MARKET=off asks GitHub nothing. Checked against real GitHub with the topic set to opencode-plugin in a sandbox: 43 repositories came back, and 32 were kept (30 from npm, 2 from git). github:ndom91/open-plan-annotator, one of the git ones, really installed and loaded. alfaoz/opencode-see-image, whose dist isn't in its repository, failed to load before the entry check and is now left out. The test fixtures are GitHub's and npm's real answers. Ran: go test -race -count=3 ./internal/plugin, go test ./internal/gui, go vet, and plugin-github.test.cjs (Chromium and WebKit, 980/440, en/zh/ja/de, 18/18). The full GUI suite passed 3343 of 3348. The 5 failures were WebKit number-units, purpose-filter and routing-failed-open, which pass 3/3 on their own and don't touch the Plugins page. |
||
|
|
f1821f4869 |
gui: Settings' Web pages help says a page from another site is refused, not that it only gets no CORS headers
Since
|
||
|
|
e8a2b50703 |
gateway: a Claude subscription run started on a long conversation is told its past tool calls as mcp__magpie__<Name>, the names it can call, so the model no longer calls a bare Bash and gives up on "Bash is disabled for this session" (#958, Cyb3rN8)
The run's Claude Code has the caller's tools only through the MCP helper
(--tools "" turns its built-ins off). A run started anew (after an idle gap,
or magpie quitting for an update) was told the conversation in text with
every past call as [tool call Bash …]: hundreds of bare names and none of
the run's own. The model wrote Bash, Claude Code itself answered "Bash is
disabled for this session, in subagents as well as here.", nothing reached
magpie, and the turn ended without a call. renderClaudePrompt and
renderClaudeTurn now write a call of a tool the caller offers under
bridgeName (mcp__magpie__<Name>), and a forced tool_choice names it so too.
A call of a tool the caller doesn't offer (its framework's own) keeps its
name.
Verified: TestClaudePromptTellsPastCallsByTheRunsNames fails without the
change ("started anew: a call of the caller's Bash isn't told as the run's
mcp__magpie__Bash", the same for the next turn, and "You must call the Read
tool.") and passes with it. go vet, go test -tags nogui ./internal/gateway
(temp HOME, pinned caches), GOOS=linux go build -tags nogui and GOOS=windows
go build pass. Not tried against a real Claude subscription: the bare-name
call could not be brought about on demand (18 real runs called the right
name before this change).
|
||
|
|
3e38bd76dc |
gateway tests: TestRestingKeyReadAgainInAnOrderedGroup lets the key be back already once the relay has answered with its limit raised (red on ubuntu CI at fb9d1a4c, run 37540375720: "resting: ko first, its rest <nil>") — since ee2588c2 a reading of the key's windows still out as it refused for quota is followed by another at once. When that second reading reaches the relay after the test raises the limit, it lifts the rest before the test plans again, which is right; the test asked for the rest to still stand there. It now accepts ko first and not resting when a reading saw the raised limit, and still wants kx first and ko resting otherwise. With the first reading held 100 ms and 200 ms between raising the limit and planning (a loaded CI runner), the old test fails as CI did and the new one passes. With ee2588c2's re-read taken out and the second reading held 300 ms, the new test still fails 2 of 2 ("still rests by window"). go test -race -count=40 -cpu 1,2,4 -run 'TestRestingKey|TestKey|Lone|Allowance' ./internal/gateway and go vet pass.
|
||
|
|
d688a8b43c |
providers, gui: a Copilot account on the individual_max plan reads "Max", not "Individual_max", and individual_edu reads "Education"
copilotPlans had no name for two copilot_plan values that GitHub sends,
so label() capitalised the raw id. GitHub's own clients name them:
- VS Code's chatEntitlementService maps individual_pro to ProPlus
("Copilot Pro+"), individual_max to Max ("Copilot Max") and
individual_edu to EDU.
- CopilotForXcode's planDisplayName gives "Copilot Pro+ Plan" for
individual_pro and "Copilot Max Plan" for individual_max.
So individual_max is Max, not Pro+. The real individual_max response in
copilot_usage_test.go has a premium allowance of 20000, above Pro+'s.
That test and its comments called it Pro+ and now say Max. VS Code also
gives individual_edu the EDU entitlement, which magpie already labels
"Education" through the free_educational_quota SKU, so the plan id gets
the same name. The full list of ids that GitHub's clients handle (free,
individual, individual_pro, individual_max, individual_edu, business,
enterprise) is now named. The Copilot tile's plan list in the Add sheet
includes Max.
Verified: TestCopilotEntitlementLabels fails without the map change
("{Plan:individual_max AccessSKU:free_github_star_quota}: "Individual_max",
want "Max""; individual_edu the same), and passes with it under -race
-count=20. deprecated-subscriptions and signin-closes-sheet GUI tests pass
in Chromium and WebKit (5/5 each). No new t() string.
|
||
|
|
1ef6c92670 |
tests: a fake that a test runs under a fixed wait is a file macOS has already let run, so the first-run check no longer kills it on a loaded Mac (WSL omp probe, Reasonix CLI, Grok install)
TestWSLProbeFindsBunOmp, TestReasonixCLIRequiresSupportedNativeVersion,
TestReasonixCLIRecoversAfterProbeTimeout and TestGrokInstallsWithoutShell
failed in loaded full runs and passed alone. None of the causes was a
serialized probe, a lock held across the exec or CPU starving the fake.
Each test exec'd a newly written file under a fixed wait. On macOS a new
executable waits for the system's first-run check before its first
exec. That check is a queue shared with every other new program starting
(each package's test binary and its fakes), so under a go test ./... it
outlasts the wait:
- WSL omp: the fake `omp` was written with os.WriteFile (its `bun` was
already a testenv.Program). The probe script's own `timeout 10 "$p"
--version` killed it, so the version came back empty. It is a
testenv.Program now.
- Reasonix: warmReasonixCLIFixture gave the freshly built Go binary's
first launch 10s ("start native CLI fixture: signal: killed"). It now
waits as long as the test runs (t.Context()), which is what the warm-up
is for. The probe assertions after it still run under reasonixCLI's 2s.
- Grok: the installer runs the downloaded file with `--version` under its
own 30s, and that file was always new. The test puts an already-run
file at the download's temp path. The installer writes over it in place
(O_TRUNC) and renames it, which keeps the pass.
- quota_served_cli_test's inert stand-ins (`exit 1`, each asked under a
3s wait) are testenv.Programs too. They gave the same answer when killed,
so this one cost time (5s at load), not a failure.
Production timeouts are unchanged. The WSL probe's 10s runs inside a
Linux distro, which has no such check. Grok's 30s verify and Reasonix's
2s probe of a binary that has already run passed in every loaded run
here. Reasonix doesn't cache a failed probe, so a first run that is slow
after an update is tried again on the next scan.
Evidence (macOS, load2.sh = the hjc load.sh recipe with N fresh-exec
loops, tests under `taskpolicy -c background`):
- A fresh 2-line script's first exec took 2.1-7.0s at 8 loops and
10.7-14.2s at 32. Its second exec took 0.02s. A file written over in
place and renamed ran in 0.02s.
- An instrumented copy of the omp test at 8 loops: a fresh omp hit
`timeout 10` in 6 of 6 runs (version empty). The same test with omp as
a testenv.Program took 0-1s in 6 of 6.
- TestWSLProbeFindsBunOmp at 32 loops: before 21.0s FAIL (version empty),
9.3s, 9.6s. After 0.63s and 0.75s, plus 21.6s for the first run, which
is the pool's one-time warm-up and has no timeout on it.
- TestGrokInstallsWithoutShell at 32 loops, before: "the downloaded Grok
Build 1.2.3 doesn't run here: signal: killed" after 78s.
- TestReasonixCLIRequiresSupportedNativeVersion at 8 loops, before:
"reasonix_test.go:178: start native CLI fixture: signal: killed" (12.0s).
- After the change, the four tests passed in every loaded A/B round
(8/24/32 loops).
|
||
|
|
fb9d1a4cc6 |
provider, plugins: a sign-in reads as done only once its account is listed again, and the command line's plugin sign-in brings the account back and takes its lapsed mark off (#1061)
* provider: a sign-in reads as done only once the account it brings back is listed again, so the window opens it rather than saying magpie can't list it (TestClaudeTeamSeatBesidePersonal failed so on macOS in #1046's CI) Signing in brings back an account removed from magpie (ShowAccount clears its Hidden mark). Since |
||
|
|
395c4bc51e |
tests: a test that sets time.Local does it through testenv.Zone, which first waits out the stand-ins' first runs — their os.Stat reads time.Local, and TestDsh -race alone raced it every run
testenv.StandIns (
|
||
|
|
2c2137beb7 |
sessions: a DeepSeek Harness session can be deleted — its folder, its subagents' and their cached listing rows go to magpie's trash, and Restore puts them back (lc on Discord: deepseek harness无法删除会话)
Deletable left dsh out, so the Sessions page said magpie could list dsh's
sessions but not delete them. dsh keeps each session as files of its own
(dsh-session-persistence-jsonl, root $DSH_HOME/sessions from dsh-base's
cordis.patch.yml): <sessions>/--<cwd>--/<id escaped by encodeSegment>/ with
every format generation and session.lock; a subagent's session is a folder
of its own whose header names its parent. dsh's listing caches a row per
session at storages/session_projcache/sessions/<id>.json (per-record
dsh-storage-json); dsh itself deletes nothing ("Nothing deletes session
files"), so there is no index to keep in step.
The delete moves each of the group's session folders and its cached row.
A folder is taken only when its name is the session id as dsh escapes it
and it sits two levels under the sessions root; when any file of the
group isn't in such a folder nothing is moved, so another session's files
never go with it.
Tested: TestDshDeleteRestore on dsh 0.2.0-rc.2's real layout (zstd frames,
session.v4 plus a v3 left behind, session.lock, a subagent, a second
session in the same project folder that stays untouched, ErrActive while
written), TestDshDeleteOnlyItsOwnFolder, TestDshSegment (checked against
dsh's own encodeSegment run in node). Fails with dsh out of Deletable.
With the real dsh 0.2.0-rc.2 in a sandbox DSH_HOME: two `dsh headless`
sessions, magpie deleted one (folder + cached row), restore gave a tree
identical to the original (diff -r), deleted again: `dsh headless
--session-id` on the other still resumes it, and on the deleted one says
it does not exist. go test -race -count=5 of the delete tests, go vet,
gofmt, go test -tags nogui ./... pass. No GUI change: the page already
offers delete when the API says deletable.
Siblings checked: Cline keeps sessions.db as its session list (its own
deleteSession removes the rows, checkpoint refs and files), so moving files
alone would leave it listing them; Grok Build keeps session_search.sqlite;
Droid's layout is only known from a closed binary. They stay list-only.
|
||
|
|
11ec99de71 |
providers: a provider whose id isn't one magpie would make (b.ai, put in providers.json by hand) saves, and its editor's ID renames it, where every Save said "provider id must be lowercase letters, digits and dashes"
01huadalang on Discord (screenshot): 我不管改成什么都显示不能用 b.ai,我没用 b.ai 做名字和 id. The provider was stored under the id "b.ai". The editor's Save first saves the rest under the id the provider has, then renames it, and provider.Save refused any id that isn't a slug, stored or not, so the provider could be neither changed nor renamed to one that is right. An id providers.json has already is now saved as it is; a new provider still can't be given one (Add, imports, backups and the rename's target are checked as before). Verified: TestStoredOddIDSavedAndRenamed (stored b.ai saved, renamed to bai with key and URL kept, a new c.ai refused) fails without the change. In a sandbox HOME with the built binary and the real GUI: a provider stored as "b.ai", ID typed as "bai" and Save showed the reporter's exact error on a build without this change (Save as on origin/main); with it the editor closes and providers.json has id bai, was ["b.ai"]. |
||
|
|
40ece3a0d1 |
gui: a provider's Save keeps the tag, website and key page set from the CLI or TUI, and on a preset's provider its Balance and Models URLs, which the editor doesn't show
Found while tracing 01huadalang's report (Discord, a Responses pick reopening as OpenAI compatible): POST /api/provider/save replaces the whole provider with what the editor sent, and the editor never sends family, website or keysUrl (nor balance, balancePath and modelsUrl for a preset's provider, whose editor has no field for them). So `magpie provider set x family=…` or the TUI's "f" was undone by the next Save in the GUI. A field the request leaves empty now keeps its saved value. Verified: TestProviderSaveKeepsWhatTheEditorDoesntShow (preset and custom cases) fails without the providers.go change and passes with it. In a sandbox HOME with the built binary: `provider set relay-a family=relays website=… keys=…`, then renamed and saved Relay A in the real GUI; providers.json kept all three and baseAPI "responses". |
||
|
|
54b4e36dcf |
providers, gui: a custom provider saved as OpenAI Responses opens as OpenAI Responses, not OpenAI compatible (01huadalang on Discord: 我选 response 保存了然后再打开一会就变成 openai 兼容了)
The editor never saved which API the Base URL was picked as; reopening showed the first API with a URL, chat first. A provider added as OpenAI compatible keeps its chat URL when Responses is picked (#105), so after Responses was picked, its URL typed and saved, it opened as OpenAI compatible again. Picked with no URL of its own, the Save sent nothing for it and the pick was gone without a word. Now the pick is saved with the provider (baseAPI), sent back to the editor and shown while it has a URL; a save that doesn't say keeps it, and one whose URL is cleared elsewhere drops it. A Save with the picked API's URL empty while another has one says so in the form. Requests are unchanged: they go by which URLs are set. Verified: reproduced on origin/main in a sandbox HOME with the built binary (magpie web, real GUI via Playwright, fake Responses-only upstream): a provider added as OpenAI compatible, then saved as Responses with and without its URL typed, reopened as OpenAI compatible. With the change it reopens as OpenAI Responses after a reload, a 65s wait and an app restart, and the empty Save shows the message. A provider added as Responses from the start was already kept and still is. TestProviderBaseAPIKept fails without the change ("added as OpenAI compatible, shown as \"\""); provider-base-api.test.cjs fails on the old app.js (actual 'OpenAI compatible', expected 'OpenAI Responses') and passes in Chromium and WebKit, en and zh. gui-ja, gui-de, i18n-keys and the provider*/system-one/azure/add-sheet/menu-scroll GUI tests pass in both engines. go vet, GOOS=linux/windows builds, go test -tags nogui ./... pass under a temp HOME. |
||
|
|
e13f151302 |
gateway tests: TestConcurrentRedactedCountTokens' children run the stand-in CLIs their parent already ran, and stop at the parent's deadline rather than a fixed 20s
The test re-executes its own binary once per mode so the redaction key cache is cold. Each child went through TestMain again, which wrote all eight stand-in CLIs (security, claude, codex, cursor-agent, devin, ...) into a new temp home. On macOS a newly written program waits for the system's first-run check before it runs. The child's fixture, provider.Save, calls Accounts(), which runs those stand-ins (cursor and devin identity asks, each waited for up to 3s, and `security` for the Claude credential). So the child spent its budget on account discovery it doesn't test. The masked count_tokens work under test takes ~6ms. Evidence (stacks from the child's own timeout panic): every timed-out child sat in provider.Save -> Accounts -> cliIdentity.get / askDevinStatus / askCursorStatus / readClaudeCredential, waiting on a stand-in's exec. None was in redact or count_tokens. Timing provider.Save in the child under scratchpad load.sh (CPU burners plus new-script exec loops), 6 interleaved runs each: 5.7-9.4s before, 3.9-5.1s after (one 8.1s). Idle: 4-6s before, 1.7-2.2s after. Under `taskpolicy -c background` the old children timed out at 20s in 2 of 4 runs and in 2 of 6 earlier ones. What remains after that is CPU starvation. Under background QoS at load average ~150, children still went past 20s. Their stacks were runnable in json encoding, or in `security` exec'd from a stand-in that had already run, with nothing blocked. So the child's -test.timeout is now 90% of the parent's remaining deadline instead of a fixed 20s. A child that really hangs still prints its stacks before the parent's run ends. Children now take the parent's stand-in folder from MAGPIE_GATEWAY_TEST_STAND_INS. A child still gets its own temp HOME and XDG folders. Verified: -race -count=10 of the test; go test -race ./internal/gateway (ok, 739s on a loaded machine; TestLargeRequestEndpoints alone took 272s under -race, so the default 10m -timeout is too short there); go vet ./...; full go test -tags nogui ./... has gateway ok (298s). |
||
|
|
ee7ab461c5 |
gateway tests: a Claude Code run a test keeps for the next turn ends with the test, so -count no longer gathers 11 fake Claude Code processes a round (#1060)
Six tests have their server keep a Claude Code run for a conversation's
next turn, which the bridge holds for idleLongest (an hour):
TestClaudeRunKeptForTheNextTurn, TestClaudeOneOffAskNotKept,
TestClaudeRunLetGoWhenTheConversationMovedOn and
TestClaudeRunKeptAcrossEffort (claude_subscription_test.go),
TestClaudeRunKeptAfterTheClientsOwnToolCall and
TestCodexThreadKeepsItsClaudeRunAcrossAMemoryCall. Nothing ended those
runs, so each test's fake Claude Code ran on until the test binary
exited, 11 more each round: under -race -count=50, gateway.test had 77
of them after about 8 rounds.
Each now ends its server's runs as the gateway does when it stops,
t.Cleanup(s.subscription.abortAll), like the tests that already keep
runs. fakeClaude, and TestClaudeRunKeptAcrossEffort's own fake, register
runsEndWithTest before New(), so it runs after the test's cleanups: it
fails the test when a run of that fake is still in its server's bridge
and not ended, and ends it. Like the park sweep, it counts a run killed
or exited, on its way out of the bridge, as ended.
Without the six abortAll cleanups the six tests fail:
claude_subscription_foreign_test.go:19: Claude Code runs the test started, still going after it: 3
--- FAIL: TestClaudeRunKeptAfterTheClientsOwnToolCall
claude_subscription_test.go:148: Claude Code runs the test started, still going after it: 3
--- FAIL: TestClaudeRunKeptForTheNextTurn
claude_subscription_test.go:192: Claude Code runs the test started, still going after it: 1
--- FAIL: TestClaudeOneOffAskNotKept
claude_subscription_test.go:349: Claude Code runs the test started, still going after it: 2
--- FAIL: TestClaudeRunLetGoWhenTheConversationMovedOn
claude_subscription_test.go:571: Claude Code runs the test started, still going after it: 1
--- FAIL: TestClaudeRunKeptAcrossEffort
codex_developer_cache_test.go:73: Claude Code runs the test started, still going after it: 1
--- FAIL: TestCodexThreadKeepsItsClaudeRunAcrossAMemoryCall
With them they pass.
The test binary's processes after each round of -count=3, each test run
alone with a probe that lists gateway.test's descendants after it: before,
3, 6, 9 (TestClaudeRunKeptForTheNextTurn,
TestClaudeRunKeptAfterTheClientsOwnToolCall), 2, 4, 6
(TestClaudeRunLetGoWhenTheConversationMovedOn) and 1, 2, 3 (the other
three); the six in one run 11, 22, 33. After, none for each. The
package's other tests, run the same way one by one, left none running
into their next round: in a first round the probe saw only the stand-ins
TestMain runs once (testenv.StandIns), and once a fake of
TestClaudeBridgeSafeguardContextUpdates that abortAll had just killed.
The 21 that need bun, which end their plugin host with plugin.Settle, and
the live Codex test were skipped here.
-race -count=20 of the six passes. gofmt -l, go vet ./..., go build ./...,
GOOS=linux go build -tags nogui ./..., GOOS=windows go build ./... and
go test -tags nogui ./... pass under a temp HOME with Go's caches pinned.
Tests only.
|
||
|
|
a24458ca4b |
providers: a Copilot Business seat that has used up its premium requests reads as used up, not unlimited (#1063, n1majne3: Github copilot Bussiness额度用尽时显示为无限)
magpie counted a quota_snapshots entry only when has_quota was true. GitHub
sends has_quota false for an allowance that is used up, and under
token-based billing for every snapshot, so an exhausted seat's
premium_interactions was dropped and the card showed only Chat and
Completions, both unlimited. The snapshot is now read as VS Code's
chatEntitlementService (parseQuotas, getQuotaUsage, isChatQuotaExceeded)
reads it:
- an entitlement of 0 on a limited snapshot is no allowance (left out);
otherwise used = entitlement - quota_remaining, or 100 - percent_remaining
when quota_remaining is absent; neither known is unknown and left out,
never unlimited;
- entitlement, quota_remaining and quota_reset_at come as numbers or as
strings ("3900"); a string used to fail the whole reading;
- an organization's pooled premium allowance (unlimited true, has_quota
false) is used up, not unlimited; chat and completions keep reading
unlimited, as VS Code reads them;
- quota_reset_at, when set, is the snapshot's own reset;
- premium past its allowance with overage_permitted no longer stops a Pro
account (Aside), while a Business or Enterprise seat stops whatever it
says, as VS Code pauses it ("Contact your administrator").
GUI card, tray, TUI and CLI all render these windows, so none of them
changes. TestCopilotUsageReadsEverySeat (a real Pro+ response from
api.github.com, Business left / used up as numbers and as strings, Business
with overage, Enterprise pool spent / left, routing over each),
TestCopilotUsageFreeUnderTokenBilling and TestCopilotUsageUnknownIsNotUnlimited
fail on the old code (no Premium requests window; "cannot unmarshal string
into ... entitlement of type float64"). Not tried with a real Business seat:
its shapes are VS Code's test fixtures and the Pro+ account's live bytes.
|
||
|
|
d2aa2e1f4e | gui: Settings' "Codex's own pick" chips draw their OpenAI mark at the chip's 14px, not the row's 18–22px (duanckham on X) | ||
|
|
6f65ffb5ff |
agent: CodeBuddy Code, Cline, Gemini CLI, AtomCode, Goose and Reasonix installed in a WSL distro are found and wired there (lgtm on Discord: magpie 现在无法检测到安装在wsl中的codebuddy呀?)
wslKinds had none of these CLIs, so each was set up only on Windows. Each now has a place-aware constructor (codebuddyIn, clineIn, geminiIn, atomcodeIn, gooseIn, reasonixIn). It writes the distro's own config with the gateway as the distro reaches it (mirrored or NAT) and the key it takes from there. A distro reads none of Windows' variables (CODEBUDDY_CONFIG_DIR, CLINE_DIR, APPDATA...). Kinds are found by their folder or their command. Gemini CLI is found by its command alone, because Antigravity keeps ~/.gemini too. Goose is found by its folder alone, because a goose command can be pressly's. Reasonix also needs a native version (new wslKind.accept). Gemini CLI also counts a .env that names an old address with magpie's key as magpie's own. Before this, a WSL restart that moved the distro's address made it read "custom", and picking the model again stashed magpie's old address as the user's. Verified: - On the Windows test box (WSL2 magpie-desktop, NAT), with a sandboxed nogui magpie.exe (own USERPROFILE/APPDATA, port 3441), real CodeBuddy Code 2.161.4, Gemini CLI 0.63.0 and Cline CLI 3.0.68 were installed in the distro. `magpie ls` listed each as "· WSL magpie-desktop". Picking relay/glm-4.6 wrote ~/.codebuddy/models.json, ~/.gemini/.env + settings.json and ~/.cline/data/settings/providers.json in the distro at http://172.17.32.1:3441, and wrote nothing in the sandbox home's agent folders. The installs were removed afterwards. - Not tried for real: AtomCode, Goose and Reasonix in a distro, and a chat request from a WSL CLI through the gateway. - Tests: gofmt; go vet ./...; -race on internal/agent; the full `go test -tags nogui ./...`; GOOS=windows and GOOS=linux builds. TestWSLProbeFindsMoreAgents and the rest of TestWSLMore* panic with "no WSL agent codebuddy" on the old wsl.go. TestWSLGeminiAddressMoved fails ("auth custom") without the gemini routed change. |
||
|
|
51626258d1 |
gui tests: text-size zooms the page out only after the 100% post and the click's frame, as the webview does (scrolled from 120 to 61, max 78, since bd33e575's font rows made Settings run past the window's foot)
The test resized the page in the same frame as the click, while the Mac header still drew at 150%'s 33px: the view was 17px taller for a moment and the browser clamped its scroll to it. In magpie the webview zooms only once Go has the post (textsize.go), frames later. Before
|
||
|
|
61838f7c94 |
gui tests: codex-auto-reset clicks its account group's Show more, not the panel's Arrange, which 490d2ea3 made a .pq-more too (strict-mode violation on .pq-more since the panel's Allowances tab got Arrange at its foot)
Passes in Chromium and WebKit. |
||
|
|
134d388ba0 |
gui: a call's JSON tree keeps its keyboard focus styles in Safari before 15.4 — :focus-visible goes in rules of its own (old-webkit failed on 5b9b9c9b's .jt-fold and .jt-copy selector lists, which those Safaris drop whole, hover included)
old-webkit passes; json-tree passes in Chromium and WebKit. |
||
|
|
479865bcfd |
gui: a Providers row with a vendor's outage badge is laid out by a class, not :has(), which Safari 15.0 doesn't parse (old-webkit failed on 2a990175's .provider .name:has(> .badge.upstream) since #971)
The Providers row's name gets with-upstream while it holds the badge, and loses it when the badge goes. old-webkit's style check passes this rule again; upstream-status passes in Chromium and WebKit. |
||
|
|
d9b2cdc593 |
plugin tests: TestHostJSCancellation's ready-wait cancels 1,000 bootstrap waits rather than 30,000, so it finishes inside its 10 s under a full suite's load
ready-wait failed twice on 10-07 in full `go test -tags nogui ./...` runs on
main ("signal: killed" at 10.00s) and passed alone. The cause is the test's
size, not the host's cancellation. The case runs 30,000 fetch+abort rounds,
each waiting at least one setImmediate turn. That takes ~4s alone, 4.4-8.5s
beside a full go test ./... plus CPU and fresh-script load loops, and more
than 10s when starved (taskpolicy -c background with every core busy: killed
3 of 3). The cost per round stays flat from 5,000 to 120,000 rounds (no growth,
so no leak), and the counts at the end are exact: retainedWaiters 0, one
reaction on the shared ready promise, one drain listener.
Those counts are what catches a leak, and they catch it at any size. With
1,000 rounds, leaving the waiter in readyWaiters fails with retainedWaiters
1000, and a reaction per request on the shared ready promise fails with
retainedReadyReactions 1000.
Before: starved, 3 of 3 runs killed at 10.04-10.26s; -race -count=20 79.9s.
After: starved, 5 of 5 pass (ready-wait 0.6-5.6s, mostly node startup);
-race -count=20 9.9s.
No production code changed.
|
||
|
|
d5468283bb |
gateway: a web page that isn't listed in Settings, on this computer or the gateway's own address is refused 403 on every route
On loopback a call needs no key and the body's Content-Type isn't checked, so any page the user visited could send a "simple" text/plain POST to 127.0.0.1:3425 and spend their subscriptions without reading the reply. corsGuard now refuses a request whose Origin is an http(s) origin that is not on Settings → Network and sharing → Web pages, not loopback (localhost, *.localhost, 127.0.0.0/8, [::1], any port) and not the request's own (host:port equal to Host). usemagpie.ai still reads /v1/magpie/omarchy. No Origin (agents), "null" and non-http schemes (app://, file://, tauri://, vscode-webview://, chrome-extension://) pass as before: those clients could only call before by not enforcing CORS, and no web page can send those origins. Such a page never read a reply before (no CORS headers), so nothing that worked is refused. Verified: TestForeignPagesRefused (text/plain POSTs from https://evil.example and other foreign origins on every route family: /v1/chat/completions, /v1/responses, /v1/messages, count_tokens, /v1/systemone, /v1beta, /v1/embeddings, /v1/rerank, images, videos, the Codex backend path, /mcp, /_magpie/claude-mcp, /v1/magpie/*, /v1/models, the GET /v1/responses upgrade, OPTIONS; loopback, *.localhost, listed with a key, same-origin on a LAN address through lanGuard, no Origin, null, app://, file://, tauri://, vscode-webview://, chrome-extension:// answered) fails without the change (120 routes answered, the fake vendor reached 139 times). go test -tags nogui ./... green; -race -count=10 on the CORS tests; darwin, linux nogui and windows builds. The built binary served from a sandbox HOME on 127.0.0.1:3591: curl from the foreign origins got 403 on every route with the vendor untouched; the allowed origins got 200. |
||
|
|
7837f90d00 |
gateway: a listed web page's call with a gateway key is answered by the running gateway, not refused 401
On the real server lanGuard sits in front of Handler and, for a gateway key sent from this computer, records the caller and puts magpie's own token in the key's place, so corsGuard never saw the key and refused every listed page's call with "a web page calls magpie with a gateway key". corsGuard now also takes the caller lanGuard recorded. Verified: TestCORSKeyThroughTheServer (lanGuard(Handler), a listed origin with and without a key) fails without the change (401 for the keyed call) and passes with it; TestCORSOrigins passes. |
||
|
|
82a36a35c7 |
click-scroll test: Live and a day, and the room kept for a click, are checked where the accounts sit beside the requests (1440px) — red on main since 5d871723 (#860)
|
||
|
|
780b3fa3da | docs: the FAQ says how to let an agent reach magpie through Surge, Clash or mihomo: rules that send 127.0.0.0/8 and ::1 direct (amor90s, baksili_ on X: Codex got 502 from the proxy and magpie saw nothing) | ||
|
|
90960edcb7 |
gateway: the Routing view keeps a day's routes when a request that began before midnight is done after the day was gzipped, and lists the day once (waitingsnow) (#1057)
saveRoute writes a done route to the file of the day it began, and
pruneHistory, at most once an hour, gzips every day before today. gzipFile
wrote <day>.jsonl.gz whole from <day>.jsonl and removed the file, so a
request that began before midnight and was done after the first prune past
it (a long streamed reply, say) went into a new <day>.jsonl, and the next
prune gzipped that over the day's .gz: every other route of the day was
lost, and only the late ones were left. While both files were there,
History listed the day twice.
* gzipFile keeps a day's .gz and adds the file's routes after it as a
gzip member of their own, which the gzip reader reads back as one
stream. The new .gz is written to <day>.jsonl.gz.tmp and renamed over
the old one (steady.Rename), and the file is removed only once that is
done.
* A route the .gz has already is not added again: a file added and left
behind (magpie stopped before removing it) adds only what was written
to it since, however many times that happens. The .gz is read a route
at a time and matched against a set made from the file's lines, never
held whole unzipped.
* A .gz that doesn't read to its end, or ends in a route cut short (an
older magpie stopped, or the disk filled, while it or its file was
written), is written anew from its whole routes and the file's when the
file has a route to add. Added after the break, the file's routes could
never be read, and after a route cut short the first of them would join
it. A last route whole but for its newline is kept. The old gzipFile
mended a .gz cut short by writing it over from its file, and this keeps
that.
* A .gz that can't be read, other than for not being there, is unknown,
not empty: it and the file are left as they are for a later prune.
* pruneHistory removes a <day>.jsonl.gz.tmp once it is an hour old, left
by a magpie stopped between the write and the rename. A younger one
may be another magpie's, still being written.
* History counts a day's .jsonl beside its .gz into one entry of its day
list.
A day with only its .jsonl, the usual case, is gzipped to the same lines
as before at the same cost: 6.3 MB allocated for a real 4.5 MB day, here
and upstream. A late route beside a real day's .gz (569 KB, 5,481 routes)
allocates 14.7 MB and takes about 16 ms; upstream allocated 1.1 MB in under
a millisecond, writing over the day. While a file added and left behind is
there, until the next prune, History counts its routes twice, as it did
before.
Tests, with what upstream's history.go gives:
* TestHistoryKeepsALateRouteWithItsDay: a route done after its day's
prune, the file it went to left behind once with nothing written since
and twice with a late route written to it, and an older day beside it.
Upstream lists the day twice before the second prune ([{2026-09-29 1}
{2026-09-29 1} {2026-09-28 1}]), and after it returns routes [2] and
"route 1 not found".
* TestHistoryKeepsADayCutShort: a .gz cut short while written in place,
its whole file still there, comes back [1 2 3]; a .gz gzipped from a
file whose last route was cut short, a late route written since, comes
back [1 3]; one whose last route had no newline comes back [1 2 3].
Upstream returns [3] for the last two (the late file written over the
day), and passes the first, which it mends the same way.
* TestHistoryLeavesADayItCantRead: a .gz that can't be read keeps the
file beside it, and both read back [1 2] once it can be. Upstream
returns [2]. It skips where a file at mode 0 still reads: as root, on
Windows, or on a file system without Unix permissions.
* TestHistoryDropsALeftGzTmp: a .gz.tmp an hour and a minute old goes,
one written just now stays. Upstream leaves both.
Each part was also broken on its own, and each break fails a test:
History's old day list (the day twice), matching a file left behind by the
.gz's last member instead of by line ([1 2 2 3 3 4]), no check for a route
the .gz has ([1 2 2]), adding after a .gz cut short ([1] and "flate:
corrupt input before offset 41"), a mend that drops the .gz's routes ([2
3]), no check of the .gz's last newline ([1]), dropping a whole last route
without its newline ([1 3]), keeping a route cut short (4 routes counted
for 3), reading an unreadable .gz as empty ([2]), no sweep of the .gz.tmp,
and a sweep with no hour's grace. Writing the .gz in place instead of
through the .tmp passes them all: the atomic replace isn't covered by a
test.
Verified on
|
||
|
|
443f1cbc2d |
gateway: a held stream's first keepalive reads only magpie's notes until the vendor's reply has its status, so it never races the try writing the reply's headers
go test -race ./internal/gateway failed in TestQuietStreamsKeptAliveEveryProtocol (chat held) with six data races: keepAlive, on watch's goroutine, sent the held stream's 200 with the try's headers by iterating holdWriter.header, while the try's goroutine wrote that map with no lock: noteMember (#822's X-Magpie-Provider/Model) and passthrough copying the vendor's headers in. In production, a vendor that answers only after keepHeldAfter does the same, and outside -race that can end the process with "concurrent map iteration and map write". Before the try has its status (WriteHeader, under mu), keepAlive now sends only magpie's own notes, which noteMember sets under mu (holdWriter.note); the vendor has said nothing yet, so nothing of its is lost. It also clones what it copies, so the agent's header shares no slice with the try's. TestKeepAliveBeforeTheVendorsHeaders (a try writing its headers while the first comment goes out) reports the race on the old code (2 of 3 runs); -race -count=20 passes, and so does the whole package under -race. |
||
|
|
b234507842 |
gateway, settings, gui: web pages the user lists in Settings › Network may call the gateway from a browser, each request with a gateway key (SkyAerope, #1051)
A page on http://localhost:3000 asking /v1/models got a 404 to its preflight and no Access-Control-Allow-Origin, so the browser hid every answer. Settings › Network › Web pages now takes origins (cleaned to scheme://host[:port]; "*" and anything that isn't an origin are refused, said in the page's language). For a listed origin corsGuard answers the preflight (204, the asked header names, Private Network Access) and adds Access-Control-Allow-Origin; every other request from it needs an enabled gateway key, even from loopback, or gets a readable 401. Default: none listed, and a request with any other Origin or none (every agent's) is unchanged. A save of the rest of the Settings page keeps the list. Verified: TestCORSOrigins (gateway, loopback requests: preflight, keyed calls, keyless/managed-token/turned-off key refused, unlisted origins incl. "null" and port/scheme variants get nothing, agents untouched) fails without corsGuard in Handler (preflight 404); TestCleanOrigins; TestCORSOriginsSetting fails without keeping CORSOrigins in POST /api/settings; TestSettingsSaveKeepsWhatItDoesNotSend. GUI cors-origins.test.cjs (en/zh, 440px, add by button and Enter, refusals, remove, no scroll, no left border) in Chromium and WebKit fails without renderCORS; gui-ja, gui-de, i18n-keys, gateway-port, lan-docker, redact-rule-row, settings-* pass in both. go test -tags nogui ./... green; -race -count=5 on the new tests; darwin, linux nogui, windows builds. click-scroll's two Requests-page subtests fail the same on origin/main. |
||
|
|
76d82528e6 |
agents, gui: every agent's model list has Order, not only Codex's (cjyrainbow, #1052)
The model list under an agent (Pick on its row) had a third view, Order, for Codex alone (#855): the API said only Codex's list was orderable and refused an order for any other. The order itself was never Codex's only: provider.CatalogFor puts every agent's catalog in its order (InOrder), and the gateway's /models, the files magpie writes for each agent and Claude Code's modelPicker are all built from it. So the view is now on every agent's list, the API takes any agent's order, and one agent's order leaves the others' alone. Codex's note still says it is the order Codex lists them in; another agent's says it is the order magpie hands them to it, since an agent that sorts its own menu may sort them again. zh, ja, de. Verified: TestAgentModelOrderAPI fails on the old code (opencode: 400, the order refused); codex-model-order.test.cjs's new Claude Code case (en, zh, 440px wide: three views uncut and inside the box, Order lists the shown, Alt+Down posts the order, Default order posts none, nothing scrolls) fails on the old app.js (no Order). TestModelOrderReachesEveryAgent checks Claude Code's picker and opencode's written models follow their own order. Chromium and WebKit: codex-model-order, agent-models, agent-models-all- hidden, agent-models-loading, agent-model-groups, agent-models-picker, gui-ja, gui-de, i18n-keys pass. click-scroll's "Live and a day" and "room kept for a click" (Requests page) fail the same on origin/main, untouched here. go vet, builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. |
||
|
|
35485f2d93 | providers: Cursor's mover asks for opencode-cursor-auth 0.1.10, which far from Cursor counts a tool step whose usage event shows late in the conversation's next steps instead of guessing it uncached (#1053, plugins#33) | ||
|
|
0bf9d77d3f |
agent tests: TestDriftBypassed's request reaching the gateway is kept to its run, so -count=2 passes
The test stood for a request with usage.Saw("codex"). Saw's record lasts
the process, which the gateway relies on (LastSeen answers from it before
a request is written to the log), so a second run started with a request
seconds old, newer than its prompt five minutes back, and found nothing
bypassed ("bypassed: <nil>", also on origin/main).
Drift reads LastSeen through a package variable the test replaces with its
own clock; production still reads usage.LastSeen. That Saw is LastSeen's
answer at once moves to usage's own TestSawIsLastSeen, which removes its
record afterwards.
-run 'TestDrift|TestSawIsLastSeen' -race -count=5 passes; before, -count=2
failed.
|
||
|
|
06420a7121 |
tests: a fake program is a file macOS has already let run (testenv.Program), so a fake's first start no longer eats a test's wait under load
macOS checks a newly written executable before its first exec: 0.27s alone, 2-5s while other new programs start (a go test ./... starting its test binaries). The same file again takes 0.009s, and the pass is kept across a rename and an in-place rewrite. |
||
|
|
0c08b1d5bb |
agent: Claude Code's tier and subagent models the user set for their own endpoint come back with it when magpie steps out (#1050)
They were stashed nowhere: Connect took ANTHROPIC_DEFAULT_*_MODEL, ANTHROPIC_SMALL_FAST_MODEL and CLAUDE_CODE_SUBAGENT_MODEL over and Disconnect or Claude Code's own model deleted them, giving back only the base URL and token. |
||
|
|
c44698bdaa |
agent: a model given to one of Claude Code's tiers or its subagents stays theirs when the main model moves onto it and on again (#1050)
#1050's sonnet tier and subagents were given Sonnet 5.5 with the main model on Opus 5.5. Moving the main model to Sonnet 5.5 made the two read as following it, so its next move took them along: back on Opus 5.5, ANTHROPIC_DEFAULT_SONNET_MODEL said Opus and CLAUDE_CODE_SUBAGENT_MODEL was gone, the pick lost without a word. set now marks a tier or the subagents whose own model the new main model is (ownKey, the mark a tier already got when the main model was picked for it where it would follow another), in magpie and through /model's Follow alike. While marked they read as that model, not "same as model"; "same as model" picked for them takes the mark away and they follow again. TestReseatOff expected the sonnet tier given ds/gpt-5 to read empty after the main model was reseated onto ds/gpt-5; it now keeps ds/gpt-5. The #1050 drift tests leave the marks out, as a magpie before this left the state. TestClaudeOwnTierStaysThroughTheMainModel (magpie and /model) fails without the change ("on the main model, the tier and subagents read as their own": sonnet and subagent empty), as does TestReseatOff with the old expectation flipped. go test -race ./internal/agent ./internal/profile pass; -race -count=20 on the Claude, WSL and reseat tests passes. |
||
|
|
99f07249e8 |
agent: Claude Code's tiers and subagents following a main model moved onto the model magpie gave them aren't "changed outside magpie" (#1050, cjyrainbow: Claude Code · WSL Ubuntu 已在 magpie 之外换掉 claude/claude-sonnet-5-5[1m])
With the sonnet tier and the subagents on Sonnet 5.5 and the main model on Opus 5.5, moving the main model to Sonnet 5.5 in Claude Code's own /model left the two following it: they read as empty, and Drift took that for the agent's default replacing the Sonnet 5.5 in applied.json. Drift now reads an empty field that follows another (Follows) as on that field's model, so the usual rules apply: a move between magpie's models isn't drift, the main model taken off magpie still is. The subagents field now says it follows the main model, and a stopped WSL distro's agent keeps Follows too. TestClaudeFollowerOnTheMainModelIsNoDrift and TestWSLClaudeFollowerOnTheMainModelIsNoDrift (running and stopped distro) build #1050's record through Apply and the switch through /model + Follow. Without the change both fail with "replaced Field:sonnet Now: Want:anth/claude-sonnet-5-5[1m]"; without the wsl.go line the stopped distro still does. go test -race ./internal/agent ./internal/profile pass. |
||
|
|
89b3a20f5d |
gui tests: a test run leaves no gui.test folder in the real ~/Library/WebKit or ~/Library/Caches (waitingsnow) (#1047)
TestTrayCellClickReleasedPanel shows its panel in the test binary run
again as a child. The package's TestMain gives the tests testenv's HOME,
but WebKit takes the home from the account's record, so every run wrote
the child's WebKit data to ~/Library/WebKit/gui.test and its caches to
~/Library/Caches/gui.test in the real home.
The child now starts through runAppKit (appkit_darwin_test.go). It sets
CFFIXED_USER_HOME, which CoreFoundation reads before the account's
record, to a temporary folder, so WebKit's data and caches go there. It
runs the binary under a name of its own, through a hard link: WebKit
names its folders after the process, whose name comes from the file, not
argv[0]. The test fails when a folder of that name is left in the real
~/Library/WebKit or ~/Library/Caches. The empty folders WebKit makes
under the name in the account's temporary folder (NSTemporaryDirectory,
which TMPDIR doesn't move) are removed. Wails v3 beta.24 offers no
non-persistent WKWebsiteDataStore: its windowNew makes a plain
WKWebViewConfiguration, which uses WebKit's default store.
CFFIXED_USER_HOME doesn't move the account's settings: cfprefsd still
serves the global domain and com.apple.universalaccess, where dark mode
and Increase Contrast are kept. A probe window read the same appearance,
Increase Contrast, Reduce Transparency, layout direction, languages and
non-default values (AppleShowScrollBars, AppleReduceDesktopTinting, the
zoom factor) with and without it, on macOS 26.7.1. Nothing is written
to the temporary home after the child exits.
Without CFFIXED_USER_HOME the test fails:
trayusage_panel_darwin_test.go:20: the windows' process left /Users/wei/Library/WebKit/gui.test-1791307161567260000 in the account's real home
trayusage_panel_darwin_test.go:20: the windows' process left /Users/wei/Library/Caches/gui.test-1791307161567260000 in the account's real home
--- FAIL: TestTrayCellClickReleasedPanel (0.45s)
With it, it passes, and nothing new appears in the real ~/Library or in
the temporary folder.
PR #1042's TestMainWindowCorners and TestMainWindowRightToLeft, moved
onto runAppKit at its head f89991b1, pass and print the same with and
without CFFIXED_USER_HOME: corners 16.00pt (plain 16.00, toolbar
26.00), lights [[26 26] [49 26] [72 26]], title bar 66pt, a sheet 66pt
below the top, right to left lights [[874 26] [851 26] [828 26]].
Without it, both fail the same way.
go vet ./..., go build ./..., GOOS=linux go build -tags nogui ./...,
GOOS=windows go build ./..., go test -tags nogui ./..., go test
-count=1 ./internal/gui/... and gofmt -l pass under a temp HOME with
Go's caches pinned. docs/subsystems/gui-shell.md says it. Tests only.
|
||
|
|
c06a550b73 |
provider tests: the hold tests pass on any -count, each starting from a config folder of its own instead of the files the last round left
TestHoldReadsSettingsOnce and TestHoldReadsMigrationsOnce failed on every
-count>=2, without any load ("a visibility before any was set", "moved
before any move"): they wrote settings.json and migrations.json into the
package's one test HOME, so the second round found held-agent's visibility
and held-sub's move already there. The leftover was only those files, not a
package global production relies on: Hold's cache is dropped at the last
release, and filememo re-reads a file that changed. Each of the four hold
tests that writes a magpie file now sets XDG_CONFIG_HOME to a TempDir, as
the rest of the package's tests do.
Before: go test -run TestHoldReads -count=2 fails both. After: -run TestHold
-count=20 -race -shuffle=on passes.
|
||
|
|
108852b4e1 |
provider tests: the CLI sign-in tests run their fake login as /bin/sh -c, not a script written for the test, so macOS's first-run check of a new executable no longer eats linkWait (TestCursorSignInJoinsAWrappedLink failed once in a full go test ./... with "login gave no link to open") — macOS assesses a newly written executable before its first exec: ~0.3s alone (a fresh #!/bin/sh script runs in 0.25–0.35s, the same file again in 0.00s), and seconds while other new executables start, as a go test ./... starts its test binaries. runCLISignIn's linkWait counts from Start, so the "never whole, and nothing more" case, which sets linkWait to 3s, got no line at all before the wait was over. Before: with a loop starting 8 fresh scripts at a time beside it, the test failed 2 of 3 at cursor_signin_test.go:70 with "login gave no link to open", 39s a run. After, under the same load: 5 of 5 pass, 3.9s a run; -race -count=50 -cpu 1,2,4 of TestCursorSignIn|TestCLISignIn pass; -shuffle=on -count=5 of the package beside go test ./internal/gateway and that loop never fails them. TestCLISignInSaysWhyNoLink starts its fake the same way. No fake outlives its test: stop() kills the shell, which has exec'd its sleep.
|
||
|
|
e961836fb0 |
usage, gateway, gui, provider, cli: the tests pass when a run crosses midnight, and a usage answer reads the clock once (#1046)
* usage: the usage tests pass at any time of day, midnight included The usage tests stamped their calls with the machine's time and then asked for today, 7 or 30 days, or a cached answer, which the code worked out from its own time.Now a moment later. A minute after midnight a call made "a minute ago" was yesterday's, and when midnight fell between the test's read and the code's, the call and the period were of two days. magpie usage, the TUI's Usage page, the two Codex cache-write tests and the computers' shared days failed in the first minutes after midnight (the TUI's after midnight UTC, the zone its package's tests run in since |
||
|
|
e277f5c5ef |
usage: four tests pass when run alone and in any order — one saves no account copy mid-test, three price with the catalogue they write (#1045)
* usage: TestQueryPageSourceAndIdentityInvalidation passes when run alone
Run alone, the test failed at any time of day:
request_page_test.go:224: unchanged source rebuilt
In a package run it passed only because an earlier test had looked at
the accounts less than 30 seconds before it. QueryPage calls
provider.All, whose rememberLogins saves a copy of the account Codex is
signed in to into logins.json, at most once every 30s (loginsSeenAt, a
package variable in provider). Alone, the test's first QueryPage made
that save. SessionIdentities then listed "one" twice (auth.json and the
saved copy), the request cache's key changed and every chunk was
rebuilt, so the pointer check failed. The test also expects only
auth.json's identity later on: with a saved "one" sharing a/u with
"two", the "two" step resolves to "" (two members of one workspace).
With the first check let through, it failed at request_page_test.go:237
"identity {... SessionAccount: ...}". The same failure hits a package
run whenever more than 30s pass between the last earlier look and this
test.
The test now calls provider.ForgetAccounts and provider.Accounts before
it signs Codex in, as an earlier test in a package run does, so no copy
is saved while it runs and the result no longer depends on test order.
This holds while the test runs within rememberLogins' 30s of that look;
it takes well under a second, -race and at.sh included. No other usage
test fails run alone: each test in the package was run alone, each
under a fresh HOME, and only this one failed.
Verified (go test -tags nogui under a temp HOME, Go caches pinned):
- before: -count=1 -run '^TestQueryPageSourceAndIdentityInvalidation$'
./internal/usage: --- FAIL ... request_page_test.go:224: unchanged
source rebuilt; -race -count=20: 1 of 20 failed (the first; the
later ones ran inside the 30s window); the same at local 12:00:00.
With its neighbours (-run '^(TestQueryPage|TestRequestPage)') it
passed, and failed again at :224 with a scratch 31s sleep at the
test's start.
- after: alone -count=1 ok, -count=20 ok, -race -count=20 ok; at local
12:00:00 and 00:00:30 PASS; with neighbours plus the scratch 31s
sleep ok; go test ./internal/usage ok; go vet ok; gofmt clean.
Without the change the run-alone command fails with the FAIL line above.
* usage: tests that write their own catalogue price with it, in any order
TestDirectCountsOnlySessionFileCalls and TestLedgerWithSessionLogCalls
write a catalogue to catalog.CachePath() and expect calls priced from
it, but never called catalog.Reset. The catalog package reads the cache
once and keeps what it read until Reset, so each test priced with
whatever catalogue an earlier test had left loaded. In file order they
passed only because no earlier test had. In another order the calls
came out unpriced. Run as
go test -run '^(TestDirectCountsOnlySessionFileCalls|TestLedgerUsesTheStatedPrice|TestLedgerWithSessionLogCalls)$' ./internal/usage
TestDirectCountsOnlySessionFileCalls ran first and left its gpt-6
catalogue loaded, and TestLedgerWithSessionLogCalls failed:
ledger_test.go:228: logged call {... Provider:session-unknown ...
Cost:0 Priced:false ... Source:log}
With -shuffle=1, TestLedgerWithSessionLogCalls ran first and left its
claude-sonnet-5 catalogue loaded, and the other one failed:
direct_test.go:55: not priced: {Calls:2 ... Cost:0 Unpriced:2 ...}
Each passes alone, so running every test alone doesn't find this. It
was found in review with go test -shuffle=on ./internal/usage, which
failed 5 runs of 6.
Both tests now call catalog.Reset after writing the cache, and again
on cleanup, as TestLedger and TestSummaryByAccount do. So does
TestLedgerUsesTheStatedPrice, the only other test that writes the
cache with no Reset there. It passes in any order, since its stated
prices win, but it checks that no tier is counted at the catalogue's
price, which needs its own catalogue. Every other test in the
repository that writes catalog.CachePath() already resets the
catalogue there.
Verified (go test -tags nogui under a temp HOME, Go caches pinned):
- before, on main: the run above fails as shown. All six orders of the
three tests (-shuffle=1, 2, 5, 7, 13 and 16) fail: at
ledger_test.go:228 when TestDirectCountsOnlySessionFileCalls runs
before TestLedgerWithSessionLogCalls, at direct_test.go:55 when it
runs after. go test -shuffle=N ./internal/usage fails for the
review's seeds 1791276105858112000, 1791276117280881000,
1791276129005822000, 1791276140549291000 and 1791276151835143000,
and for 101, 202, 505, 808 and 1010 of the seeds 101, 202, ... 1010;
each failure is in one or both of these two tests.
- after: the run above ok; all six orders ok; -race -count=20 on the
three tests ok; at local 12:00:00 PASS; go test ./internal/usage ok,
and ok with each of those 15 seeds; each test in the package
passes run alone; go vet ./internal/usage ok; gofmt clean.
Without the change the run above fails with the ledger_test.go:228
line, and with -shuffle=1 it fails with the direct_test.go:55 line.
|
||
|
|
8a7f600cb0 |
provider: the Requests page keeps its cache when magpie first saves a signed-in account (#1049)
SessionIdentities lists the identity in Codex's auth.json (and Claude's profile), then one per saved login. Once rememberLogins had saved a copy of the account signed in now, that account was listed twice. QueryPage keys the request cache on this list, so the save that added the copy changed the key, and the next Requests page query dropped every cached chunk and read and priced every session log again, though no identity had changed. Users could see that as one more slow Requests page after magpie saved its first copy of an account: one an agent was signed in to outside magpie (codex login, Claude Code's /login), or the one already signed in when magpie first ran. Switching between saved accounts and signing in through magpie never caused it: rememberLogins replaces a saved account in place, and magpie's own sign-in (addLogin) writes logins.json together with auth.json. The resolver gets nothing from the duplicate: an identical entry never changes which email or login a session resolves to. SessionIdentities now leaves out a saved identity equal to one already in the list. One that differs in any field is still listed, such as another member of the same workspace (the same account id, another email): sessionResolver.codexUser names no member when two identities share a workspace and user id but not the email. TestSessionIdentitiesListTheSavedCurrentAccountOnce saves the account Codex is signed in to with rememberLogins(true), checks that it was saved and that the identities are unchanged, then saves a second member of the same workspace and checks that it is listed. A scratch test on main ( |
||
|
|
9db5753ba3 |
providers: a provider's model list reads the settings once, not three times per model (lml on Discord, Windows: 每次至少都得等五六秒…供应商或者额度列表还在加载) — each model's row asked for its image answer twice (ApplyImage, ImageOverride) and its reply limit once (ReplyLimit), and each ask parsed settings.json again, even inside a GET's hold, since filememo keeps its bytes, not the parse. providerInfo now reads the settings once and uses provider.ImageOverrideIn and Provider.ReplyLimitIn. This removes redundant work found while measuring lml's report; it does not explain the whole 5-6s, which needs their setup (see below).
Measured with a copy of the owner's config (23 providers, ~1500 models) under a sandbox HOME and the real server (magpie web, dead proxy): GET /api/providers on the Windows box 497-558ms → 148-214ms, on the Mac 442-525ms → 174-191ms; the JSON answer is byte-for-byte the same apart from the gateway port. Everything else the window waits on at open answered locally in under 0.6s on Windows, so the rest of a 5-6s wait is network (the usage cards wait for every vendor on a cold start, and on Usage's own open), not this. TestProviderListReadsSettingsOnce (300 models, a big settings file, held as a GET is) takes 5.3s without the change and 41ms with it, and checks an image answer and a reply limit the user set are still said. go vet, GOOS=windows go build, GOOS=linux go build -tags nogui and go test -tags nogui ./... under a temp HOME pass. |
||
|
|
54c3cb06fc |
agent: the default thinking effort set on one of magpie's models in WorkBuddy stays through a sync, as it does in CodeBuddy Code, ZCode, Kimi Code and MiniMax Code (悠悠哥 on Discord: 供应商能设置模型默认的思考强度吗,我的workbuddy每次手动设置了思考强度,还是会被更新覆盖掉)
WorkBuddy's Settings > Models saves an edited custom model whole into ~/.workbuddy/models.json: reasoning.defaultEffort (absent for its Auto), and the vendor of the provider it matches, which for magpie's entries is the "Custom" provider's (WorkBuddy 5.x app.asar: inferProviderIdFromLocalCustomModel, the form's save in ui-docs-viewer). buddyWrite knew its entries by vendor "magpie" only, so a sync kept the edited entry as the user's and added magpie's own with the same id and magpie's default effort; one set by hand under vendor magpie was simply rewritten. buddyWrite (WorkBuddy and CodeBuddy Code) now also knows magpie's entries by their key (magpie-<agent>, or a NAS magpie's key already on its entries), and keeps each model's defaultEffort (or the older reasoning.effort) while the model still offers that level; WorkBuddy's Auto stays Auto. A new model gets magpie's default; a model magpie no longer has is taken out, the edited one included. The same rule (keptEffort) keeps a hand-set default in ZCode's config.json (defaultVariant), Kimi Code's config.toml (default_effort) and MiniMax Code's config.yaml (thinking.defaultEffort), which a sync rewrote too. The composer's own effort pick is WorkBuddy's localStorage (cb-effort:by-model), which magpie never touched. Verified: kept_effort_test.go (TestWorkBuddy/CodeBuddy/ZCode/Kimi/MiniMax KeepsTheUsersDefault*) fail on the old writers, WorkBuddy's with "think/wide twice" and the rest with magpie's default back; pass with this, -race -count=3. go test -tags nogui ./... green under a temp HOME; go vet, GOOS=linux and GOOS=windows builds. Not tried in the real WorkBuddy app: the fixture follows its save code, not a file it wrote. |
||
|
|
05683637d5 |
plugins: the Bun the plugin host runs on is kept as magpie-bun, so a proxy app's PROCESS-NAME rule can route the requests plugins (Cursor and the other moved subscriptions) make (#1048)
magpie downloads its own Bun into ~/.cache/magpie/bun/<version>/. It is now written there as magpie-bun (magpie-bun.exe on Windows), and a Bun downloaded before is renamed in place the first time it is looked for, so nothing is downloaded again and no second copy takes disk. The host, bun add and bun update all run it, so all of their traffic carries the one name. A $MAGPIE_BUN the user set is run as it is. Verified: TestBunDownloadedAsMagpieBun, TestBunDownloadedBeforeTakesTheName and TestHostRunsAsMagpieBun fail without the change (the Bun is .../bun, the host runs .../bun). TestHostRunsAsMagpieBun starts the real host on a copy of Bun 1.4.2 and `ps -o comm=` names it magpie-bun on macOS. On the Windows box the three tests pass with the Windows build of Bun 1.4.2, a running bun.exe renames to magpie-bun.exe, and Get-Process/Win32_Process name it magpie-bun. Linux not run here (CI's ubuntu job runs the test with Bun on PATH). go test -tags nogui ./... green; -race -count=10 on the new tests green. |