Commit Graph
7089 Commits
Author SHA1 Message Date
yetone 97f825d560 gui: spinners turn round their own centre: the drawing turns inside the svg, round the viewBox's centre, since WebKit turned a whole svg on a pixel-snapped layer and its ring circled a point ~1.3px off (Agents' "Updating…", Sync, Save, the quota and usage refreshes, the agent fix) (yetone)
Measured on the real screen (headed WebKit + screencapture, 30 frames,
circle fit): the ring's centre wandered 2.7 device px before, 0.2 after.
Playwright screenshots repaint and never showed it. The CSS ring
spinners (sign-in, plugins) measured 0.2 already and are unchanged.
#sync's stop-on-a-whole-turn reads the svg's subtree animations.
Run: cli-update (fails on the old CSS), agent-update-all, sync-spin,
provider-save-busy, agent-app-version, agent-unreachable, aside-native,
usage-card-refresh, usage-remote-cards, usage-stale-answer: all pass,
Chromium + WebKit.
2026-10-09 01:46:48 +08:00
yetone 05b5965872 providers, gui: a partner listed since the add sheet last showed the partners puts a small dot on the "+ Add provider" button, its name in the title, until the sheet shows it (yetone: 有了新的合作伙伴的时候,这里能否有个小小的精致优雅的提醒吸引用户点击查看)
Ran: go test ./internal/provider ./internal/gui ./internal/tui .;
partners.test.cjs (chromium + webkit, en/zh at 900 and 440), i18n-keys,
gui-ja, gui-de; GOOS=linux -tags nogui and GOOS=windows builds.
2026-10-09 01:45:43 +08:00
yetone 7d663a2769 providers, stats: count how often each partner is shown, opened, has its key page opened and is added, per day and capped, and send the days that have ended with the daily stats as "magpie partner" events; off with the stats or with what magpie is used with (yetone: 能否统计每个合作伙伴的展示数和点击数)
Ran: go test ./internal/provider ./internal/stats ./internal/gui ./internal/tui .;
partners.test.cjs (chromium + webkit), privacy-usage-stats, i18n-keys,
gui-ja, gui-de; GOOS=linux -tags nogui and GOOS=windows builds.
2026-10-09 01:40:02 +08:00
yetone af798bd1bf routing, gui: the context window's card folds to its head, with how full it is beside the title ("114K / 272K · 42%"), and stays folded for the next request and after the page comes back, so the request list under it has the room (0xBCD18E on X: 这个"上下文窗口"的板块非常占"上下"高度,还不能折叠,下面只能展示三行)
ctxCard takes opts.foldable (Routing passes it; the Usage page's cards
don't): its title becomes a button with a chevron, aria-expanded, and a
click toggles .shut on the card, which hides all but the head. The choice
is kept in localStorage (magpie.ctxShut). The head is morphed in place, so
the click reads the button from the event, and the card that is there
keeps .shut across live patches; a new card takes it from the saved choice.

Verified: routing-ctx-fold.test.cjs (new), at 420 and 1100 wide in
Chromium and WebKit, 3/3 each: open, then folded to one line (<60px) with
the figure, the list under it up by >200px, nothing runs over at 420px;
another request picked is still folded; after a reload still folded;
opened again, 400 cells and the same height as before. It fails on the old
code (no .ctx-fold). routing-*, context-*, usage*, group-context,
click-scroll, panel-routing, old-webkit, gui-ja/de/zh-tw: WebKit 371/371;
Chromium 370/371 once at --test-concurrency=4, routing-blocked's "picking
the request moved the page", which passes 3/3 alone and in two more
routing-* runs at the same concurrency (196/196 each). Not filed as caused
by this change; seen once under load.
2026-10-09 01:40:02 +08:00
yetone 0d20aaba45 gateway: under In turn routing, new conversations sent at once spread over the accounts instead of all going to the one least held, which held one Antigravity account busy while the others sat idle (#1342, handong66)
leastHeld counted only conversations already answered, so every new
conversation in a burst saw the same counts and picked the same account.
A conversation that is opening now counts until it is answered or its
request ends.

Run: go test -tags nogui ./internal/gateway (ok); -race -count=5 on the
rotate/affinity tests (ok); go vet darwin, linux, windows (ok).
TestRotateSpreadsABurstOfNewConversations fails without the fix
("k1 got none of 6 new conversations sent at once ...: map[k2:4 k3:2]",
3 of 3 runs).
Not tried: a real burst on Antigravity accounts. The default (smart)
routing keeps using the first account while it has quota, by design.
2026-10-09 01:29:46 +08:00
yetone b2c97659fb gateway: a model picked for Responses is asked on Responses again after the relay once answers it there with "use /v1/chat/completions", not sent as chat from then on (01huadalang on Discord: 为什么会转成 chat,我都设置的 response)
A wrong-endpoint answer marks the model unfit on that API until magpie
restarts. With the user's per-model API (Names & levels, ModelAPI) the
only API usable gives, one such answer left usable empty, and every later
request fell back to p.Speaks(): chat first. Now the fallback is the
picked API; without a pick it is Speaks() as before.

TestModelAPIPickHoldsAfterWrongEndpoint (a relay with chat and Responses
URLs, the model picked for Responses, its first Responses answer a 400
"not supported in /v1/responses, use /v1/chat/completions"; a Responses
and a chat client each send twice) fails on the old code (the second
request goes to /v1/chat/completions, upstream [/v1/responses
/v1/chat/completions ...]) and passes with the change. go test -tags
nogui -count=1 ./internal/gateway under a temp HOME passes; go vet
(darwin, GOOS=linux, GOOS=windows) on ./internal/gateway passes. Not
confirmed that this is the reporter's case: their provider and request
weren't seen.
2026-10-09 01:24:47 +08:00
yetone cde2a351e2 library, gui: the Skills and MCP tabs' strip has a Discover button that goes to the market under the list, many screens down with dozens of skills (#1348, ttmouse)
The strip that stays at the top of the Library page gets a Discover button on
the MCP and Skills tabs. It scrolls the market's heading to just under the
strip (through scrollOnPurpose, so the click-scroll guard lets it) and puts the
cursor in the market's search box. The strip's buttons now keep together at its
end and wrap onto a line of their own when the window is too narrow, so the
window's 560px minimum doesn't scroll sideways.

New test library-discover-jump.test.cjs (Chromium and WebKit, en and zh, web
and window, 1000px and 560px; 60 skills, 40 servers): the market starts more
than 700px below the view, the button fits without sideways scroll, and after
the click the market is in sight under the strip with its search box focused,
and still is 500ms later. It fails without the library.js change (12 failures
waiting for the button).

Ran: library-discover-jump 64/64; library-*, market-*, click-scroll, gui-ja,
gui-de, gui-zh-tw, i18n-keys, skill-*, mobile-web, phone-web, project-* and
others in both engines, 520/524. The 4 failures: library-servers-bulk in
Chromium fails the same without this change (#1322), and mobile-web's 900px
desktop compare timed out / differed by 338px on Providers under
--test-concurrency=6; run alone it passed 30/30 twice.
2026-10-09 01:20:22 +08:00
yetone b3330ea82d gateway: a Responses request relayed with a tool call no result answers sends the call a synthetic result, instead of Volcengine coding plan's 400 "An assistant message with 'tool_calls' must be followed by tool messages" (#1341, XcodeFish)
The reporter's own experiment through magpie to the same upstream: a
function_call with no function_call_output was turned away with exactly
the reported 400, and the same request with the output went through.
Volcengine checks the exchange on the chat form it turns /responses into.
The Chat path has mended this shape since #1275 (pairToolMessages); the
Responses relay had only orphanedToolOutputs, which handles the opposite
case (a result with no call).

pairToolItems runs beside orphanedToolOutputs for every Responses request
not going to a ChatGPT account. A function_call or custom_tool_call that
no result in the input answers gets "[The result of this tool call is
unavailable: the turn was interrupted.]". As in the Chat path, that result
goes at the end of the run of calls and results the call is in, so no
result lands between two parallel calls. A result with no call is still
left to orphanedToolOutputs. A result naming a call from an earlier request
(previous_response_id) stays as it is. Based on ggbdpq's patch on the
issue, which put the result right after the call.

TestResponsesRelayAnswersALoneCall (through the whole gateway) fails
without the change ("the lone call went unanswered") and passes with it.
TestPairToolItemsAnswersALoneCall covers parallel calls, custom calls,
byte-for-byte pass-through of paired, out-of-order and
previous_response_id requests, and that the caller's buffer is left
alone. go test -tags nogui ./internal/gateway under a temp HOME passes, as
do go vet (darwin, linux, windows) and gofmt. Not tried against the real
Volcengine coding plan: the only Volcengine key here is a pay-as-you-go
Ark key with no DeepSeek model enabled. The reporter's Codex rollout shows
every call paired, so which call went unanswered in their request is not
known. They are asked whether it still happens.
2026-10-09 01:19:25 +08:00
yetone 23d9e5def8 gui tests: ledger-hscroll checks the Requests table's sideways scroll in a 600px window, where the table is wider by a margin no machine's fonts take away (#1340, wizzy-yang)
Since fdcdb5af (#860) the table fits a narrow window much more closely,
and at the test's 700px the Chinese table was 76px wider than the window
on this Mac but 33px on the reporter's machine (689 vs 656), whose
narrower fonts failed the test's "wider than the window by 50px" premise
in Chromium and WebKit. The product is right; the test's window was a
premise #860 took away. At 600px the Chinese table is 176px wider here.

Verified: ledger-hscroll passes 6/6 (Chromium and WebKit, en and zh).
With the reporter's narrower fonts stood in for by letter-spacing
-0.06em / -0.08em on .led (zh 696 vs 658), the old test fails zh in both
engines (2 pass, 4 fail) and the new one passes 6/6. No product code
changed.
2026-10-09 01:12:10 +08:00
yetone 844b9ca3ac provider, gateway, gui: a custom provider's Base URL can be a Gemini API (generateContent): …/v1beta, its models listed from it, the key sent in x-goog-api-key (#1346, NagaseMinato)
The custom provider editor's Base URL has a fifth API, "Gemini compatible"
(Gemini 兼容 / Gemini 互換 / Gemini-kompatibel), beside OpenAI, Anthropic and
Responses; More endpoints has a Gemini URL; the CLI takes gemini=. A
Gemini URL is kept as its base (…/v1beta, a relay's path prefix kept, a
pasted models/…:generateContent cut off). Every client's request, Chat,
Messages, Responses or Gemini, streamed or not, goes upstream to
models/{model}:streamGenerateContent?alt=sse under it, with no model in
the body and the key in x-goog-api-key; models are listed from its
/models, a page at a time, keeping those that serve generateContent.
Detect doesn't ask a Gemini API and is hidden while it is picked.
Factory's Gemini route and Bearer token are unchanged.

With five APIs the pick no longer fits a 900px editor in English and
German, so it wraps to a second row, and its thumb now follows the
picked option onto that row.

Verified against fake httptest upstreams only; no real Gemini key or
relay was tried:
- TestCustomGeminiUpstream (gateway): chat, chat stream, messages, a
  Gemini client's stream and non-stream, behind /proxy/v1beta. Fails with
  "chat: 404" without the gateway.go change.
- TestCustomGeminiProvider, TestGeminiBase, TestFactoryGeminiUnchanged
  (provider).
- go vet, HOME=$(mktemp -d) go test -tags nogui ./... (44 packages ok),
  GOOS=linux and GOOS=windows go vet on the touched packages.
- provider-gemini.test.cjs (new, en/zh/ja/de, Chromium + WebKit, 8 pass;
  fails with "900px: the thumb is 22px off" without the slide() fix),
  and in both engines: provider-base-api, provider-detect,
  provider-detect-models, provider-add-models, provider-output-picks,
  provider-search, provider-url-each-api, seg-contrast, settings-groups,
  menu-scroll, click-scroll, ledger-hscroll, strip-scrollbar,
  view-scrollbar, usage-ledger-chart, system-one, gui-ja, gui-de,
  gui-zh-tw: all pass.
2026-10-09 01:10:25 +08:00
yetone 88f2eb8aa5 gui tests: signin-paste-codex, signin-again and signin-closes-sheet give the sign-in window they open an empty page instead of the real vendor's (#1307's siblings)
Found by logging every off-host request in a full Chromium GUI run:
signin-paste-codex opened the real auth.openai.com (Cloudflare's
challenge, the page that hung login-import's clicks), signin-again
loaded www.codebuddy.cn with its downloads and trackers, and
signin-closes-sheet example.com. Each routed only its page. Now the
context answers anything off magpie.test with an empty page; a rerun
logged only the three window URLs, no subresources. Chromium and
WebKit, all three files: 9/9 pass each.
2026-10-09 01:07:41 +08:00
yetone f9a1ca0355 docs: a Privacy section in the READMEs and a "What does magpie send about me?" FAQ on the site's Get started (en, zh, ja): the daily event's id, version and system, and the agents, providers and models by magpie's own ids (a provider of the user's own only "custom"), what is never sent, and the Settings → Privacy switches; node --test site/*.test.mjs passes 2026-10-09 01:07:16 +08:00
yetone 9f0831b239 gui tests: copilot-ghe gives the device-sign-in window it opens an empty page instead of the real github.com and acme.ghe.com (#1307's sibling)
Like login-import's ChatGPT window, only the page was routed, so the
window GitHub's device sign-in opens loaded the real site (304 requests
to github.githubassets.com in one full Chromium run). It wasn't red here
(10 at once in Chromium: 0/20 failed), but its outcome rested on pages
the test doesn't control. Chromium and WebKit, en and zh: pass, and no
request went past the two window URLs, which the route answers.
2026-10-09 01:02:51 +08:00
yetone 9755201b44 gui tests: login-import gives the sign-in window it opens an empty page instead of ChatGPT's real one, whose Cloudflare challenge hung this page's clicks in Chromium (#1307)
The browser sign-in calls window.open on auth.openai.com, and only the
page was routed, so the new window loaded the real site: Cloudflare's
challenge. While it runs, Playwright's clicks on the opener in Chromium
stall at "performing click action" past their 5s.

Shown with a page that opens the same window and then clicks a button
30 times, 8 at once: real window, every run had 1-2 clicks time out
(max 5.0-5.5s), twice over; window routed to an empty page, 0 timeouts
(max 1.2-4.0s at load ~100-117). The test itself, 10 at once in
Chromium (load 150-190): before 20/20 and 19/20 subtests failed (click
or fill timeouts at lines 111-117, after the window opened); after
0/20 twice. WebKit, 8 at once: 0/16. en and zh both run.
2026-10-09 01:02:51 +08:00
yetone 7ddea2c2e0 plugin tests: TestHostRunsAsMagpieBun puts the Bun on PATH at the old name as a hard link, not a fresh copy, so macOS's first-run check of a new program no longer comes out of the host's one-minute start under a full go test run (#1306)
A copy is a new program, which macOS checks before its first exec; the
host's init ran it inside the test's minute. Timed here with load ~130
and syspolicyd not pegged: a fresh copy's first `--version` took
0.9-1.6s, a hard link of the same bun 0.04-0.3s; with syspolicyd busy
the same check took 26-55s a program in #1284. Where no link can be
made (another filesystem), the copy is run once before the minute starts.

Run in Docker (golang:1.26.8, linux/arm64, bun 1.4.2): -count=3 of the
test with bun on a bind mount (copy path) and beside HOME (link path),
all PASS; go test -tags nogui ./internal/plugin ok; go vet for linux,
windows and darwin clean. Not run: the test on macOS itself (Go tests
are kept off this Mac while syspolicyd is overloaded), so the red under
a slow first-run check is shown by the timings above, not by a failing run.
2026-10-09 01:02:51 +08:00
yetone 1e405be3fc gui tests: routing-sessions' suggestion groups answer the names ask with the titles their trace carries, as the gateway does; the Claude Code row has the page ask 300ms after it draws, and the empty answer took the titles away under load (#1307) 2026-10-09 01:02:51 +08:00
yetone 8576e3cc33 gui tests: routing-sessions leaves the held live trace for a reload to cancel; letting it go just before the reload had the page ask again while going away, which WebKit turned away "due to access control checks" as a page error (#1307) 2026-10-09 01:02:51 +08:00
Charan Rathore 023f5aaad2 provider: a background reading of an account writes its quota history too (#1318)
* provider: a background reading of an account writes its quota history too

GET /v1/magpie/quotas/history was written only by the Usage page's
reads, so a magpie only ever serving other magpies - nobody opens its
Usage page - kept an empty history while its routing read each account
every few minutes.

When a login's fresh reading is kept, it is now noted in the history as
a page reading is, named for its account (a login's reading itself
carries no user); a read that failed is skipped, not told again. The
test is the reporter's story: a background LoginUsage, then the
history, no Usage page involved; it fails on main. Keys' background
readings (KeyAllowance) are not noted here - the page names a key's
history line by its key name, which routing's reading does not have.

Invited by yetone on #1317 after 137ebee8 closed the cards half of

Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>
#1313.

* provider: a LoginUsage batch notes its quota history once, off the request path

Per review on #1318: a kept reading per account meant N full
read/parse/write cycles of quota-history.json for N accounts, and the
write ran before close(r.done), so routing's waiters on a reading
waited on the disk, the writes serialized under quotaHistMu.

loginUsageAt now notes the batch once after wg.Wait(), each reading
named for its account, through noteHistory, whose write runs in its own
goroutine; a cached reading notes nothing new (its ReadAt is no newer)
and a failed one is skipped. Tests: several accounts cost one write
(TestBackgroundReadsNoteHistoryOnce) and a held write holds no waiter
(TestHistoryWriteHoldsNoWaiter).

Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>

* provider: note the batch's quota history synchronously

The detached write goroutine outlived its caller: it read Path() and
wrote quota-history.json after a test had returned, racing t.TempDir
removal and leaking into the next test's HOME (go test
./internal/provider red with the PR, green on main). Note synchronously
in loginUsageAt after wg.Wait(): every reading has completed and
released its in-flight marker by then, so no routing waiter is held.
Only the LoginUsage caller pays for one write per batch, and Allowances
already calls it from its own background goroutine.

TestHistoryWriteHoldsNoWaiter now holds the write during the first
LoginUsage and asserts a second caller on the same account answers from
the completed readings, with a timeout on the write-start wait.

Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>

---------

Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>
2026-10-09 00:39:40 +08:00
yetone 84c3eb0362 provider: moved Cursor users get plugin 0.2.1: an id 0.1.x listed, at an effort only its other branch has, goes as that branch's nearest effort, not as the default's id with parameters that contradict it (magpie-community/plugins#54, geoqiao)
On 0.2.0, cursor/claude-opus-5 at xhigh went as claude-opus-5-thinking-high
with thinking=false, effort=xhigh, because Opus 5 without thinking stops at
high. 0.2.1 sends claude-opus-5-high with effort=high, as 0.1.11 did. The
cursor mover's min goes from 0.2.0 to 0.2.1, so keepMovedCurrent updates
every moved Cursor user.

0.2.1 on npm (registry.npmjs.org) has an index.mjs byte-identical to plugins
main cf0de01e. The plugin PR was reviewed at ea00bd9 and merged:
- bun test in packages/cursor: 49 pass, 0 fail
- whole repo: 987 pass, 0 fail
- bun scripts/check.mjs passes for all 15 packages
- the new test fails on 0.2.0's index.mjs
- not tried with a real Cursor account on the review side (the stored token
  answers 401)
The case where the default's own branch stops short is still open:
magpie-community/plugins#55.

go test -tags nogui ./internal/provider passes (temp HOME, pinned caches).
go vet -tags nogui ./internal/provider passes for darwin, linux and windows.
gofmt -l is clean.
2026-10-09 00:36:27 +08:00
yetone b91569d311 readme: feedback goes to Discord, and the repository takes no pull requests (only collaborators can open one) 2026-10-09 00:31:48 +08:00
yetoneandClaude 55209c5529 plugin tests: TestHostStreamCreditBoundsTheQueue waits for the given-up call to leave the host, which it does once its abort's write is known, after the child may already have read it (red on ubuntu CI at 2b5f19fc; a 50ms pause before the write is known fails the old check every time)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-09 00:23:17 +08:00
yetone ed31293c0e usage, gui: a reply its vendor let go in a burst over a couple of hundred milliseconds tells no speed, not 2,237 tok/s (John on Discord)
John's Kimi Code rows after v0.1.1119 (OpenCode, group/k3-glm, api.kimi.ai,
Chat, k3-256k): 550 tokens, 22 of them reasoning, in 16 s with the first
content at 5.2 s read 2,237 tok/s, and 395 tokens in 19 s 2,012. 528 answer
tokens at 2,237 tok/s is 236 ms: the burst the vendor let go at the end.
de5455b8 measured how long the content took to come (flow) and took the
window as no longer than it, so a burst sent in one write (flow ~1 ms) fell
under the 100 ms floor and told none, but a burst let go over 236 ms of
many events read its tokens over those 236 ms, under the 10,000 tok/s
ceiling. The time a burst takes to come is not the time it took to write.

usage.DecodeOf now tells no speed for a reply held back and let go at its
end, both ways the burst can show:
- its content came in under a quarter of its window (flow*4 < window):
  the text came early, the tool call it wrote over the rest of the time
  came at the end (window 10.6 s, flow 236 ms);
- it reasoned, and its answer came over 20 times faster than its
  reasoning came between its first content and its first text: the text
  came with the burst, so the window from it is the burst itself (22
  reasoning tokens over 10.5 s, then 528 in 236 ms). Hidden reasoning
  (OpenAI's, Claude's omitted) comes before the first content and leaves
  that time short; streamed reasoning comes at its answer's pace.
Between the two the window is the whole window again, not the flow.
routing.js's decodeOf and app.js's ledDecode do the same; docs/reference.md
says it.

Tests: TestKimiHeldBurstTellsNoSpeed, a fake Kimi Code (Chat: four
reasoning_content deltas, then text and a tool call whose arguments come
as 40 writes 6 ms apart over the last 236 ms; usage 538/550/22), through
the real gateway for a Chat, a Responses and an Anthropic agent, with the
wait shortened (first content 1.3 s, end 4 s): the held call and the held
answer tell none (before: 2,112 to 2,237 tok/s on all three), a steady
50 tok/s answer after the same reasoning keeps ~50. TestKimiHeldBurstAtJohnsTimes
feeds firstToken the same streams at John's times (5.2 s, 16 s): before,
2,138 and 2,237 tok/s. TestJohnsRowsTellNoSpeed: his rows as records
(before: 2,237, 2,237, 2,015). routing-burst-speed and usage-speed gain
his rows and a steady 50 tok/s one; they fail on the old routing.js and
app.js ("2237 tok/s", "2,237 tok/s") and pass now in Chromium and WebKit,
en and zh, with reasoning-speed, routing-request-metrics,
usage-ledger-detail, click-scroll, gui-ja, gui-de and i18n-keys.

Run: go test -tags nogui ./internal/... (golang:1.26.8 in Docker, as a
non-root user: as root, internal/agent's TestAside* write-refusal tests
fail because root ignores the file modes they rely on, unrelated to this);
-race -count=5 of the new and the burst tests; go vet (linux, windows,
nogui) on internal/gateway and internal/usage. Not tried against the real
Kimi Code API: the owner's Kimi Code key answers 403 (subscription has no
access), so how Kimi Code lets the reply go is inferred from John's
numbers; which of the two shapes his rows were is not known, and both are
covered.
2026-10-09 00:10:23 +08:00
yetone 3d34c2d747 routing: live, the next request is patched into the context window that is there, so its cells don't come in again and the card no longer goes and comes back, moving the request list under it (Zhenzhen on Discord)
Each new request in a session emptied the card while the gateway read its
prompt (the box collapsed to 0, everything under it jumped up), then drew a
new card whose 400 cells scaled in again, then a third card when it was
done; a request under way had no Prompt cache stat, so the grid moved
again when it came. Now ctxCard returns a card with ctxUpdate: the grid's
cells are made once and only their classes change, the head, stats,
legend, contents rows and foot are morphed in place, and an under-way
request keeps the cache stat's place with "—". Routing patches the live
card, keeps it in place while a live request has no prompt yet, and still
draws a request the reader picks afresh.

Verified: routing-live-patch.test.cjs (new) feeds two requests in three
steps each, at 420 and 1100 wide, in Chromium and WebKit: the old rows,
card, grid, cells, legend and contents rows stay the same nodes, the grid
and card keep their height on every ResizeObserver frame, the view never
scrolls. Without the change it fails: the card reads '' while the request
is under way, the card/grid are new nodes, the box goes 884 -> 0 -> 789
-> 884. routing-*, context-*, click-scroll, panel-routing, old-webkit,
gui-ja/de/zh-tw, usage* pass in both engines; go test ./internal/gui and
GOOS=linux/windows go vet pass.
2026-10-09 00:08:21 +08:00
yetone ae24bcfcfb agent, gui: Codex's row on the Agents page shows its desktop app's version beside its CLI's ("CLI 0.130.0", "App 26.930.31730"), and the app's alone where no CLI is on PATH (#1334, laacmilan)
The app's version is read from /Applications or ~/Applications
ChatGPT.app (or Codex.app) Contents/Info.plist, taken only when its bundle
id is com.openai.codex, so the ChatGPT chat app (com.openai.chat) isn't
taken for it. macOS only: the Windows Store package isn't read yet. The
app chip's tooltip says it reads the same settings as the CLI, so
connecting Codex connects both. At narrow widths the chip ellipsizes, and
below 250px it gives way so the name keeps its room.

Verified: TestCodexAppVersion fails without the CLI() change ("the app
alone, no CLI"); agent-app-version.test.cjs fails 12/16 without the app.js
change and passes 16/16 with it, Chromium and WebKit, en/zh/ja/de, at 980,
560 and 440px. agent-cli-missing, agent-connect, agent-field-names,
agent-layout, agent-update-all, cli-update, click-scroll, gui-ja, gui-de,
i18n-keys pass in both engines. internal/agent passes in Linux Docker
(non-root); full ./... on macOS; vet darwin/linux/windows. Read
26.930.51102 from the real /Applications/ChatGPT.app on this Mac. Not
tried on the reporter's machine.
2026-10-09 00:02:40 +08:00
yetone 2b5f19fc73 gateway: a request whose tool results another request already answered (Claude Code's fork sub-agents and their lead, a turn sent again) gets a Claude Code run of its own instead of a 409 "the agent's turn is already being resumed" (ylorn on Discord)
A Claude Code fork sub-agent's first request is its lead's conversation
with a result for each of the lead's in-flight calls ("Fork started —
processing in background") and its directive after. The lead's own resume
and every fork it started therefore match the same run at once; the first
to claim it won and the rest got a terminal 409 that Claude Code does not
retry, so the forks died. The 409 dates from e8cd4bac (#794); nothing
between v0.1.1108 and main changed it. A request that loses the claim now
gets a run of its own, told the conversation whole.

Verified: TestClaudeForksAnsweringTheLeadsCallsEachGetAnAnswer drives the
real server stack (httptest Handler, fake claude whose MCP calls go back
through /_magpie/claude-mcp) with a lead and 8 forks resuming at once.
Before the change it failed 7/20 plain and 5/10 under -race (409 for forks
and the lead); after, -count=30, -race -count=20 (macOS) and -race
-count=10 (Linux Docker) pass. TestClaudeBridgeSafeguardConcurrentHandoff
now expects the second caller to get its own run. go test -race
./internal/gateway is green on macOS and in Linux Docker; go vet for
darwin/linux/windows and gofmt clean. Not tried with a real Claude
subscription.
2026-10-08 23:59:50 +08:00
yetoneandClaude 325b2a67fb gui: Settings says the GitHub token also installs skills from private repositories it can read, and needs no scopes for public ones (37FlowAI on X)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-08 23:59:31 +08:00
yetoneandClaude 3bf88948b5 library: a skill in a private GitHub repository installs with the GitHub token set in Settings → Network and sharing (or GITHUB_TOKEN/GH_TOKEN), asked of GitHub's API, which alone gets the token; without one the error says where it is set (37FlowAI on X)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-08 23:58:22 +08:00
小七 172f45a5e6 agent: dsh's check stays quiet when its key store holds a caller key of this gateway's (#1332) (#1339)
The drift check asked only whether refs.MAGPIE_GATEWAY_KEY equals the key
magpie writes into .env, so a caller key the gateway itself issued — which
dsh's store prefers and the gateway authenticates — was named as "another
MAGPIE_GATEWAY_KEY" and the user was told to remove it there, while
delete → disconnect → re-apply wrote the very same state back. The check
now asks the gateway's own Authenticate first: a key it takes means dsh is
going through magpie, and only a key it would refuse (a foreign one, a
switched-off one) is drift. The .env side needs nothing: the serving round
rewrites .env to magpie's key, so a stray value there heals itself.

TestDshStoreHoldingAGatewayCallerKey (a key from access.Update add-key in
the store's refs) failed without the change with the "holds another
MAGPIE_GATEWAY_KEY" drift; with it the check is quiet, and a key the
gateway doesn't take still reports.

Verified: go test -tags nogui ./internal/agent -count=1; the three dsh
store tests under -race -count=10; gofmt -l clean; go vet -tags nogui
./internal/agent; go build and GOOS=linux/GOOS=windows go build -tags
nogui.

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-08 23:51:34 +08:00
Charan Rathore 8df15fd437 sessions: the page's limit counts nonempty sessions only (#1324)
List sorted the session keys by file mtime and truncated them to the
limit before assemble dropped empty sessions, so a newest empty file
ate the page: List(1) answered no session at all though List(0) found
two, and on an mtime tie an empty one could win the key tie-break.

The limit now falls on the assembled sessions: keys are walked newest
first and a nonempty one takes an empty one's place until limit are
collected; the most-recently-active-first order is kept.

Reproducer by @Ethereal49 in #1320, red before (limit=1 returned 0
nonempty sessions, want 1) and green after; the TestList flake they
saw under -race -count=20 does not repeat with it. Fixes #1320.

Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>
2026-10-08 23:43:20 +08:00
yetone 920aab3326 provider: the Claude sign-in without Claude Code says it needs the claude command line, not the Claude desktop app, which a reporter had installed and took for it (xlz on Discord)
Ran: go test -tags nogui ./internal/provider -run 'Claude|SignIn' (Docker, linux).
2026-10-08 23:40:46 +08:00
yetone 238f0d927b gateway tests: the fake Cursor servers close their connection after a reply, so their log has no "http: panic serving …: invalid concurrent Body.Read call" (CI Test run 37791950740 at 8db24fd6, macOS, and green runs since 85fd35ab)
The five fakes answer a Run in full duplex (EnableFullDuplex) and return
while magpie's request body is still open, as Cursor does. Go's server
then reads the rest of that body in finishRequest's Close, after it has
stopped the connection's background read; the read's EOF starts another
background read, and the kept-alive connection's next request reads
beside it and panics. net/http recovers it and the tests pass, so it
was only noise in the log, beside the run's real failure
(TestBurstTellsNoSpeed, fixed in 5e17a183). magpie's own server never
uses full duplex: the panic is the fakes' alone. cursorDuplex enables
full duplex and sends Connection: close, so there is no next request on
that connection.

Red before: the cursor tests -count=10 -cpu 1,2,4 log the panic 11
times (a standalone full-duplex server returning before the body ends
logs it on every other request; 0 with Connection: close); after, 0.
go test -race -tags nogui ./internal/gateway (temp HOME), go vet
-tags nogui ./internal/gateway for darwin, linux and windows, and
gofmt -l pass at this head.
2026-10-08 23:33:44 +08:00
yetone 24bef0f9be gateway: a streamed request waiting for its key's slot (Concurrency) or for room in its minute (Requests per minute) has its agent sent the stream's 200 and SSE keepalives after 15s, as a held try's stream is, instead of nothing until it is sent (coeo91 on Discord: WorkBuddy, Trae and Qoder said it timed out)
serve's try took its lane slot and waited for the minute (04704111)
before holdWriter.watch started, so for up to 2 minutes (or QueueWait,
unbounded by default) the agent got no status, no headers, no byte.
keepQueued runs beside lanes.take and rpms.wait: past keepHeldAfter it
sends the stream's 200 and ": keepalive" comments every keepaliveEvery
(keepAlive, the mechanism held tries already use; none for Gemini, #934).
Once they are out the try is held, so the vendor's error, or the queue
turning it away, reaches the agent as its protocol's stream error
(failTo: Chat's error chunk, Responses' response.failed, Messages'
event: error), and the next candidate still answers in the same stream.
A wait shorter than keepHeldAfter sends nothing: its 429 keeps its
Retry-After. Non-streamed requests are unchanged.

What the agents do with it (read from their app bundles, not tried live):
- WorkBuddy 5.5.6 / WorkBuddy AI 5.6.2 (codebuddy-headless.js): no
  header timeout, first-token timer 20 min, so a 2-minute queue alone
  doesn't time it out there.
- Qoder 0.4.3: 60s to headers, then 60s more after them; its SSE parser
  drops comment lines, so keepalives don't extend that. Headers at 15s
  give it 75s instead of 60s; longer waits need firstPayloadTimeoutMs.
- Trae: its agent is downloaded at runtime and wasn't read.

Verified (Linux, golang:1.26.8 in Docker):
- queue_keepalive_test.go through lanGuard(New().Handler()), with an
  agent whose connection gives up after 400ms of silence: a request
  queued 1.2s for the minute (chat, responses, messages) and one queued
  for a Concurrency slot get 200, keepalives, then the reply; a vendor
  500 after keepalives is each protocol's stream error; a QueueWait
  waited out is the stream's error naming the limit; a short wait is
  still a plain 429. With keepQueued taken out, every one but the 429
  test fails with "i/o timeout". TestQueuedUnheldTryHeldOnceKeptAlive
  fails without the hold (": keepalive\n{\"error\":...}" in the stream).
- go test -tags nogui ./internal/gateway: ok (122s).
- go test -race on internal/gateway the way CI runs it (go test -race -c,
  build/race-shards.sh over 14 processes, -test.timeout=20m): 1258 tests,
  every shard ok. A single serial -race process passes 10m's default
  timeout, which is why CI shards it (#923).
- go vet -tags nogui ./internal/gateway for linux, windows and darwin;
  gofmt -l clean. After rebasing on 5e17a183: TestQueued, TestBurst,
  RPM, TestQuiet and TestSilentHeld under -race, and linux vet, pass.
2026-10-08 23:13:12 +08:00
yetone 5e17a1835f gateway tests: the burst tests' burst is 5,000 tokens, so the time magpie takes to pass it on reads faster than any stream (TestBurstTellsNoSpeed red on macOS CI at 8db24fd6: 1000 tokens in 138 ms read 7246 tok/s)
A burst tells no speed when its window is under MinDecodeMs or its speed
over MaxDecodeSpeed. de5455b8's burst was 1,000 tokens: on a busy macOS
runner magpie took 138 ms to relay it, which is over 100 ms and under
10,000 tok/s, so it read a speed. A real burst of a few thousand tokens
reads over the cap; at 5,000 the relay would need over 500 ms to read a
speed. TestCodexBackendBurstTellsNoSpeed had the same 1,000; both change.

Red before: with the fake upstream taking 150 ms over the burst (two
writes), all three burst cases fail with CI's message ("1000 tokens in
192 ms … read 5208 tok/s"); with 5,000 they pass 3 of 3 with the same
delay. Still guards de5455b8: with DecodeOf's flow clamp off, all three
fail ("5000 tokens in 608 ms (flow 1) … read 8223 tok/s").

Run in docker golang:1.26.8 as uid 1000: go vet -tags nogui
./internal/gateway; go test -race -count=15 -cpu 1,4 on both tests pass.
2026-10-08 23:10:46 +08:00
yetoneandClaude cdf325f178 plugins: a package that is only a command (an MCP server like magpie-x-search) isn't listed under Unreviewed, isn't added as a plugin, and one added before says what it is instead of a host stack (#1327, congee949)
A repository tagged magpie-plugin whose npm copy (from that repository)
names no file to load (no main, no exports) was listed and installed from
npm without the entry check the GitHub route has; it then failed every
host start with "has no entry" and a stack. Now:

- the Unreviewed list checks npm's copy the same way: one that names no
  file needs the index.js the repository's own route needs (askTagged);
- `magpie plugin add` / the Plugins page refuse a package that names no
  file, has no index file and is neither pi's nor a middleware, take the
  package just installed for it out again, and say it isn't an OpenCode
  or magpie plugin, and, for one with a bin, to add an MCP server under
  Library → MCP servers (notPlugin);
- the host says the same, without a stack, for one already on the list.

Run: TestCommandOnlyPackageIsNoPlugin (magpie-x-search 1.2.0's real
package.json) fails without the change (Add = <nil>; with only host.js
reverted, the stack message), TestTaggedRepos with the real GitHub
package.json and npm latest of cyberElar/magpie-x-search fails without it
(listed), both pass with it; TestNotPluginKeepsPlugins (index.mjs, main,
exports, middleware, pi, a file stay plugins). go test -tags nogui
./internal/plugin under a temp HOME ok; go vet -tags nogui for darwin,
linux, windows. The built binary in a sandbox HOME: `magpie plugin add
magpie-x-search@latest` from real npm prints the new error, and
plugins/package.json no longer lists it.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-08 23:09:25 +08:00
yetoneandClaude 0feffaa7f9 agent: TestFolderVarsAreListed knows MAGPIE_PARTNERS is magpie's own partner-list source, not an agent's folder (red on main since 10578ce6)
Run: go test -tags nogui ./internal/agent under a temp HOME: FAIL before
("MAGPIE_PARTNERS, read by ../provider/partners.go, is not in
agentenv.Vars"), ok after.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-08 23:03:19 +08:00
yetoneandClaude d9caa3dd13 library: Hermes Agent in a WSL distro takes skills and MCP servers there, and so does every other WSL agent that keeps them in its own folder (omp, OpenCode, MiMo Code, Droid, Grok Build, Command Code, AtomCode, Qoder, MiniMax Code, fx, dsh) (#1323, Kevinzz224)
wslTargetOf knew only Claude Code, Codex, Pi and OmO, so hermes@wsl:Ubuntu
was never a Library target and a skill meant for it could only go to
Windows' ~/.hermes. An agent whose places are all its own folder (a.Dir,
or beside a.Path) now gets the target targetOf makes on this machine, at
the distro's home the agent was found with: copies for skills, its MCP
file marked as WSL's (a Windows program is refused, magpie's own image
server goes by its WSL path), and the skills it reads besides its own are
the same distro's agents'. Agents whose places depend on this machine's
variables or home (Kimi Code, Crush, Cline, CodeBuddy, Goose) stay out.

Run: TestWSLOwnFolderTargets fails without the change (hermes@wsl,
omp@wsl, droid@wsl, opencode@wsl aren't targets; no copy of the skill),
passes with it. go test -tags nogui ./internal/library ./internal/agent
under a temp HOME on macOS (library ok; agent's TestFolderVarsAreListed is
red on main since 10578ce6, fixed in its own commit next), and
./internal/library in golang:1.26.8 Docker (Linux) ok; go vet -tags nogui
for darwin, linux and windows. Not run: a real Windows box with Hermes in
WSL.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-08 23:03:19 +08:00
yetone 9a4b25aa60 gui: Usage's request sources round their end cells as their bar does, so a hovered, focused or filtered-by first or last source no longer lays a square corner over the bar's rounded one, in a row or stacked (yetone)
Run: usage-ledger-chart (Chromium + WebKit; new corner checks fail on the
old CSS, pass now; hover screenshots wide and 560px, dark), usage-ledger,
usage-ledger-fit, -detail, -content, ledger-hscroll, ledger-protocol,
mobile-web, number-units: all pass in both engines.
2026-10-08 23:01:28 +08:00
yetone 10578ce683 providers: the add sheet lists Partners first, above Subscriptions, under a heading that says they sponsor magpie; who they are comes from usemagpie.ai/api/partners (site/partners.js), so a paid listing changes with a deploy, not a release (yetone)
The app fetches the list behind the call every 6 hours (10 minutes after a
failure), never waiting, and keeps it in the cache folder. Each entry is
checked: its own id, never a built-in preset's; a name and an endpoint;
https only; at most 12; no decision API, no-key or user endpoint. Its logo
goes through FetchIcon. A partner is a preset to the rest of magpie, and
one that has left still is to the providers added from it, unsponsored.
The window lists a partner in the languages it names only, with its tagline
in the page's language; `magpie presets` and the TUI list them first too.
MAGPIE_PARTNERS moves the list, off lists none.

Run: go test -tags nogui -race ./internal/provider ./internal/gui
./internal/tui . (ok); TestPartners* -race -count=3; node --test
internal/gui/tests/partners.test.cjs add-sheet gui-ja gui-de i18n-keys in
Chromium and WebKit (en/zh/ja/de, 900 and 440px); node --test
site/worker.test.mjs site/install.test.mjs; the built binary in a sandbox
HOME against a local feed: listed, an http entry left out, listed from the
cache with the site down, `provider add` from it.
2026-10-08 22:52:30 +08:00
yetoneandClaude 5ba0601fda gateway: Codex's Ultrafast goes first to a ChatGPT account whose own model list offers it, and one whose plan doesn't is asked for Fast instead of being sent a tier it may refuse (yxinyu715 on X)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-08 22:51:58 +08:00
yetone 8db24fd62f gui: Routing folds three or more of a provider's keys for one model into one row that shows the count and their state, and opens in place to each key (#1319, tkhs101)
53 agnes-3.0-flash keys were 53 near-identical stage rows and 53 rows
under Accounts and keys. Now three or more keys of one provider standing
together for one model (same fixed effort, fallback and group-in-group
heading) fold into one stage row: "Agnes 53 keys agnes-3.0-flash", then
the lit key and what it does, "51 available · 2 resting". A request on a
folded key flies to the fold; a key failing and the next answering show
there (its 429 tag too). A click, Enter or Space opens it in place: each
key keeps its own row, state and wire, drawn from the fold. Accounts and
keys folds the provider's keys into one row with their summed tally and
models, and opens the same way. Open folds are kept per reader in
localStorage magpie.routingKeysOpen. Two keys stay two rows; one key is
as before. Display only: the gateway's order and choice don't change.
New strings in zh, zh-TW, ja and de. docs/subsystems/gui-shell.md says how.

routing-account-order's relay has three keys, so it now opens their fold
to read their order.

Run: routing-keys-fold.test.cjs (32: folded, open/persist/Enter, live
updates folded and open, Accounts and keys, 440px; Chromium and WebKit;
en, zh, ja, de) — fails on main (no fold). All routing-*.test.cjs,
panel-routing, click-scroll, fold-show-grip, gui-ja, gui-de, gui-zh-tw,
i18n-keys: 409 pass. Every other test that opens Routing (29 files, 152
tests) passes but purpose-filter's WebKit "returning focus does not scroll
the page", which fails the same alone on origin/main (off by 1px).
go vet -tags nogui ./internal/gui (darwin, GOOS=linux, GOOS=windows).
2026-10-08 22:20:22 +08:00
yetone dfd881231e usage: a DeepSeek balance in CNY and USD at once reads in one order every read ("$11.12 · ¥-0.05", the currency with money left first), and its trend is that currency's own line in its own sign, not ¥-0.05 and $11.12 joined into one alternating line (gakki on Discord)
DeepSeek's /user/balance lists balance_infos in an order that changes from
read to read. readDeepSeek wrote them as they came, and the balance history
kept the first number of the string, so the chart alternated between the two
currencies. readDeepSeek now sorts them (money left first, then by code). The
history keeps each currency of such a balance under a key of its own
(balanceCurrencies), the card's trend is the first one's with
BalanceTrend.currency set, and the card's old line (which can't be split
again) is dropped on the first such read. app.js says the curve's legend,
readings and pace in that sign alone ("$11.12", not "$11.12 · ¥-0.05" after
every amount). The usage alert reads the first amount too, so it no longer
flips between the two currencies either.

Red before: TestBalanceHistoryTwoCurrencies (reporter's shape: CNY -0.05 and
USD 11.12, order swapped each read) fails with 'card says "¥-0.05 · $11.12",
want "$11.12 · ¥-0.05"' on the old readDeepSeek, and with the old history
alone the trend holds 11.2, -0.05, 11.15, …; TestBalanceReaders' two new
cases fail the same way. balance-currencies.test.cjs fails on the old app.js
with 'Balance$11.12 · ¥-0.05' and 'about $0.44 · ¥-0.05 a day'.

Run (Docker golang:1.26, temp HOME): go test -tags nogui ./... (only
internal/agent's TestAside* write-failure tests fail, as root in the
container; they pass as uid 501), go vet ./internal/provider ./internal/gui,
GOOS=linux/windows/darwin go vet ./internal/provider, gofmt -l. GUI:
balance-currencies, balance-curve, balance-parts, balance-fix in Chromium
and WebKit (110 pass; en/zh, light/dark, 900 and 440px). No new t() strings.
Not tried with a real DeepSeek account holding both currencies.
2026-10-08 22:13:09 +08:00
yetone 0d8f85e47b gui: Providers, Library and Plugins no longer scroll 12-16px sideways in macOS 15 with scroll bars shown (#1236, pineog)
Library's and Plugins' sticky tab strip (.lib-head) and Providers' sticky
Add bar (#view-providers .after-list) reached over the view's side padding
by a negative margin (-12px, -16px in the window, the view's padding in
the narrow browser page), so their boxes ran 12-16px past the view's
content end edge. macOS 15's WebKit (Safari 18) takes a flex scroller's
scrollable width as the furthest in-flow child's right edge plus
max(0, margin-end), then adds the padding-end (RenderBlock::computeOverflow's
includePaddingEnd, before WebKit 290159@main / bug 218579, which shipped in
macOS 26): the negative margin is left out, the page is 12px (Providers) or
16px (Library, Plugins) wider than the view, and with classic scrollbars a
draggable horizontal bar shows. That is the reporter's three pages and only
those, at every text size and width. Chromium and macOS 26's WebKit count
the margin, so neither scrolls.

The strips' boxes now keep to the content box; a ::before paints the
frosted strip / the fade over the padding (--bleed-l/-r), the hairline
moves to it, and the pre-color-mix fallback too. Looks the same
(before/after screenshots, light, window and browser page).

New internal/gui/tests/view-no-sideways.test.cjs visits every page, en/zh/
ja/de, the window (body.mac) at 560 (windowMinW) and 1000px and the browser
page at 360/440/1000px, Chromium with its scrollbars shown and WebKit, and
checks both macOS 15 WebKit's sum, worked out from the layout, and the
engine's own scrollWidth. Red before: 40 of 40 cases in each engine, on
providers (12px, div.after-list), library and plugins (12/16px,
div.lib-head) and no other page. Green after, 42/42.

Also run, BROWSER=chromium and BROWSER=webkit (712 of 714 pass; the 2 are
library-servers-bulk in Chromium, the same 2px flake on the old assets, #1322):
click-scroll, gui-ja,
gui-de, add-button, deprecated-subscriptions, plugin-market,
provider-discovery, every library-*, plugin-* and provider(s)-* test.
GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gui pass.
Not tried in a real macOS 15 WKWebView: this Mac runs macOS 26, whose
WebKit has the fix; the rule was read from WebKit's source at 2025-01.
2026-10-08 22:11:26 +08:00
yetone 3856a9a6d8 provider: moved Cursor users get plugin 0.2.0: the list is Cursor's model picker, a model once per context size with that window (claude-opus-5-5@300k, @1m), effort and fast sent as the variant's parameters, and an id 0.1.x listed still runs as the variant it stood for (magpie-community/plugins#51, geoqiao)
The cursor mover's min goes from 0.1.11 to 0.2.0, so keepMovedCurrent updates every moved Cursor user. The ids picks were saved under before (claude-opus-5-5, claude-opus-5-5-fast, cursor-grok-4.6, a variant's own slug) keep working. magpie still sends an id the plugin no longer lists to the plugin unchanged: provider.Resolve accepts any cursor/<model> while the provider is on, and pluginFetch builds a stub model. The plugin's named() then resolves the id to its variant.

0.2.0 on npm was checked against registry.npmjs.org: its index.mjs is byte-identical to plugins main 8cd5a0f. The plugin PR was reviewed at c64bc3d and merged onto main:
- bun test in packages/cursor: 48 pass, 0 fail
- bun scripts/check.mjs cursor passes
- seven deliberate breaks, each caught
- not tried with a real Cursor account on the review side

go test -tags nogui ./internal/provider passes in Docker (golang:1.26.8, temp HOME, module cache read-only). go vet -tags nogui ./internal/provider passes for linux, windows and darwin. gofmt -l is clean.
2026-10-08 22:07:41 +08:00
yetone ddb6f806ac gui: the sessions warm-up hands its garbage back to the system when it ends, so a magpie just started doesn't read ~470 MB at rest for its first two minutes (H20 on Discord)
The warm-up reads every session file for the Sessions page and Usage › Requests. On a 13.5k-session history it allocates ~830 MB (QueryPage ~570, StatsFor ~260) to keep ~80 MB of indexes, and Go's scavenger returns the freed pages only over the next minutes. warmUp now calls debug.FreeOSMemory once its reads are done: one forced GC and scavenge, once, at start.

RSS of a linux nogui `magpie web` in Docker on a copy of a real config with those sessions mounted read-only, sampled every 15 s from start (with the dsh round change before it): 15 s 472 -> 197 MB, 30 s 475 -> 285, 60 s 417 -> 281, 2 min 337 -> 281, 3.5 min 266 -> 218, 12 min ~250 -> ~204. TestWarmUpReturnsItsGarbage fails without the FreeOSMemory call (10 of 10: 46-334 MB of freed heap still held, or the heap not yet collected) and passes 10 of 10 with it. go test -tags nogui ./internal/gui ./internal/sessions (Docker golang:1.26.8, temp HOME), go vet -tags nogui ./internal/gui for linux, windows and darwin, and gofmt -l pass. Not measured on macOS: a fresh build there hangs at exec behind syspolicyd today.
2026-10-08 21:21:01 +08:00
yetone 1d1c9e07d2 agent: without dsh, the dsh round every 30 s doesn't build magpie's whole catalog for no patch list (H20 on Discord: magpie idles near 500 MB)
dshWiredOnce built magpieModels("dsh") before looking for a profile, so every magpie, dsh or not, built the catalog every 30 s and threw it away: 93% of what a magpie at rest allocated (pprof heap?gc=1 delta over 120 s, a linux nogui `magpie web` in Docker on a copy of a real config with 13.5k Codex and Claude Code sessions mounted read-only). That garbage kept the heap at its GC goal, about twice what it keeps. It now returns before the catalog when there is no profile; with one, nothing changes.

Same measurement, this commit and the warm-up one together: idle allocation 73 MB per 2 min -> 6.8 MB (3.8 MB of it the profile read itself); RSS at rest after the first minutes ~250 MB -> ~203 MB, the heap no longer climbing 125 -> 192 MB between GCs. TestDshRoundWithoutDshBuildsNoCatalog fails without the change (475 allocations a round) and passes with it. go test -tags nogui ./internal/agent (Docker golang:1.26.8, non-root, temp HOME), go vet -tags nogui ./internal/agent for linux, windows and darwin, and gofmt -l pass. Not measured on macOS: a fresh build there hangs at exec behind syspolicyd today.
2026-10-08 21:21:01 +08:00
yetone 8d6e9bad49 gateway tests: the burst tests allow the moment a first word takes to reach magpie (TestCodexBackendBurstTellsNoSpeed red on macOS CI at 58f45d05: Millis 612, TTFT 13)
de5455b8's tests asserted that the time from the first word to the end
was at least the upstream's 600 ms wait. The fake upstream starts that
wait once it has sent the first word, and magpie stamps TTFT when the
word arrives, so the span is the gap less the delivery time: 599 ms on a
busy macOS runner. TestBurstTellsNoSpeed had the same `span < gap`
check; both now want 90% of the gap. The speed assertions they guard
(a burst tells no speed, a steady stream keeps it) are unchanged.

Run in docker golang:1.26.8 as uid 1000: go vet -tags nogui
./internal/gateway; go test -race -count=15 -cpu 1,4 -run
'TestCodexBackendBurstTellsNoSpeed|TestBurstTellsNoSpeed' pass. Not
reproduced locally with an injected delay; the CI log above is the red.
2026-10-08 21:20:46 +08:00
yetone 4ed6df801c provider: moved Factory users get plugin 0.1.21, whose pi compaction summary no longer opens with the sentence Factory refuses (#1316, Eriice)
After pi compacted a session, every turn on factory/claude-opus-5-5 was 403
"Factory: Forbidden". The reporter's replays found the refused part: pi's
fixed opening of its summary message, "The conversation history before
this point was compacted into the following summary:"
(COMPACTION_SUMMARY_PREFIX in pi-coding-agent dist/core/messages.js), whole.
Plugin 0.1.21 (magpie-community/plugins f4c0d96, on npm) rewords that
sentence, and pi's branch summary opening, when a user text is pi's whole
summary, on Messages, chat completions and Responses; the mover's min is
raised so keepMovedCurrent updates moved users. The built-in, which has
none of the plugin's pi or Claude Code adaptations (#952, #1132), is
unchanged.

Plugin: its new pi.test.mjs tests fail on 0.1.20 and pass on 0.1.21; bun
test (114 pass) and check.mjs factory pass; the npm tarball's index.mjs is
the committed one. Here: go test -tags nogui -count=1 ./internal/provider/
in Docker (golang:1.26.8; on the Mac new test binaries hung in dyld while
syspolicyd was at 100%), go vet -tags nogui for darwin, linux and windows,
gofmt -l pass. Not tried against Factory itself (no Factory account here).
2026-10-08 21:15:25 +08:00
yetone 8514750426 gui: focusing the window no longer blanks the Usage chart: the window coming back (focus, visibilitychange) reads the Usage tab shown as its timer does, drawn again only on a change and with no skeleton between; the tray panel's Usage tab isn't dimmed or redrawn by its 10 s timer or a focus when nothing changed; Routing's groups aren't redrawn on focus when the same (Zhenzhen on Discord: omarchy/Hyprland, focus follows mouse, the bar chart flashed each time the pointer crossed into magpie)
Cause: window focus and visibilitychange called load(), which on the Usage
page called loadUsage(): renderUsageLoading() hid #chart, put the KPI
skeletons up, and renderUsage() drew every bar again. Under focus-follows-
mouse every pointer crossing is a focus. load(true) now goes through
refreshUsage() when the tab's figures are drawn (usageDrawn), and loadUsage()
as before on a first draw or when the language changed.

Test: internal/gui/tests/usage-focus-steady.test.cjs fires focus and
visibilitychange and watches the Overview bars, the Requests columns, the
tray panel's columns and Routing's group card. With the old app.js it fails
in all 4 runs ("nothing changed: the chart isn't blanked": skeleton, chart
hidden); with only the panel change reverted ("dimmed", "bars removed");
with only the Requests path reverted ("bars removed"); with the old
routing.js ("the same group card stays": 0 vs 1). Passes in Chromium and
WebKit, en and zh. 998/998 pass across the usage*, panel*, tray*,
sessions*, context*, group*, routing* and focus/visibility-firing GUI
tests in both engines. No strings or Go changed (no gui-ja/gui-de, go vet
needed). Not tried on real Hyprland.
2026-10-08 20:59:07 +08:00
yetone de3b1c646a usage: a subscription card's window says what the whole window holds, "Whole ≈ N tokens · ≈ $X", reckoned from what magpie routed through the account since the window began over the share used, at API list prices (Chiao on Discord)
usage.WithWindowHolds fills QuotaWindow.Holds on GET /api/usage/quotas and its refresh, from usage.jsonl: the card's provider (by its id now, so a moved plugin's card and a renamed provider count), its account (ProviderAccount, or an older record's Host), calls to the models the window counts (Claude's Opus-only or Fable week), not turned away, from the window's start up to when the share was read. Priced by catalog.Price.CostSplit at the maker's list price, else the provider's own list, never the user's own subscription price: Anthropic's 5-minute and 1-hour cache writes at 1.25x and 2x input, OpenAI's cached input and no cache write price. A call with no API price leaves the window tokens-only. The caller's cards are not written to.

Not told where it wouldn't be honest: under 5% used, nothing routed in the window, magpie's log starting after the window did, no reset or no span (credits with no reset, Copilot's premium requests), Antigravity's per-model family and pool windows, Aside windows, a card with an error, a balance, or one read from another computer. The tooltip says how it was reckoned and that use of the account outside magpie makes it read low (the request said 偏高; such use raises the share without adding to what magpie saw, so the estimate is lower than the truth). en, zh, zh-TW, ja, de.

Run: go test -tags nogui ./... in Docker (golang:1.26.8): all pass but internal/agent's Aside* chmod tests, which fail only as root and pass with --user 1000. The new tests fail with the log-start check removed, the model scope removed, the caller's windows not cloned, and 1-hour cache writes at the 5-minute price. Against a read-only copy of the owner's usage.jsonl, quotas.json and models.json: Claude's week (71%) ≈ 46K tokens / $14.16 from 165 calls, its Fable week and 5 hours (12%) nothing, every other card nothing (under 5%, or no reset). New quota-holds.test.cjs passes in Chromium and WebKit at 360, 440 and 1000px in en, zh (万), zh-TW (萬), ja, de, and fails with the new CSS removed; click-scroll, gui-ja, gui-de, i18n-keys, quota-* and usage-* pass (304/304). go vet -tags nogui (darwin, GOOS=linux, GOOS=windows) and gofmt -l on the touched packages pass.
2026-10-08 20:53:03 +08:00
yetone 137ebee82f provider: a remote magpie's cards carry what was read behind the requests — the account switching's, the Codex warm-up's and routing's readings of each account (LoginUsage), routing's of each key (KeyAllowance) — and after a restart the readings kept in quotas.json, not only what the Usage page last read (#1313, jorben)
A magpie serving only other magpies (`magpie serve` in a container) has nobody on its Usage page, so GET /v1/magpie/quotas/cards, answered by CachedCards from the page's caches (subscriptionUsageCache, planQuotaCache, keyBalanceCache), said "nothing read on that magpie yet" while its Codex account's usage was read every few minutes behind the requests: those readings land in loginUsageCache (and a key's in keyAllowances), which CachedCards never looked at; after a restart even a page-read card was gone until the page was opened, though quotas.json held it.

CachedCards still asks nobody. It now lays each account's latest LoginUsage reading over its card when it is newer by readSeq (perLogin's cards are that same reading, so the page's own later read stands), adds a card for an account read that way and never on the page, named and drawn as the page names it (accountCard: perLogin now takes that face), and falls back to the reading kept on disk, dated (AsOf). Keys the same way: routing's KeyAllowance reading now keeps what was read with the windows (plan, balance, parts, readSeq) and is laid over the key's plan or balance card, or makes one; with no card read since start, the plan and balance cards kept in quotas.json are told. Cursor (known by asking its CLI), Grok (read by home) and a Kiro key keep the page's cards only. The local Usage page is unchanged.

Not fixed here: the quota history (/v1/magpie/quotas/history) is still written only by the page's reads.

Red before: with CachedCards as on origin/main and everything else in place, TestRemoteMagpieShowsBackgroundReadings (gateway, through lanGuard(New().Handler()) and a remote-magpie provider: CodexUsedUp, then RemoteCards) fails with the reporter's card ("nothing read on that magpie yet; refresh to have it read"), and TestCachedCardsTellBackgroundReadings, TestCachedCardsKeepALaterPageRead and TestCachedCardsTellKeyReadings fail; all pass with it. ForgetKeptCardsForTest is called from the gateway's fresh() so TestRemoteMagpieQuotas's "nothing read" holds under -count.

Run (Docker golang:1.26.8, the Mac's syspolicyd pegged): go test -tags nogui ./internal/... (internal/agent as uid 1000), go test -race ./internal/provider ./internal/gateway, go test -count=2 -run TestRemoteMagpie ./internal/gateway; go vet -tags nogui for darwin, linux and windows on internal/provider and internal/gateway; gofmt -l. No app.js change.
2026-10-08 20:48:49 +08:00