Commit Graph
6576 Commits
Author SHA1 Message Date
ggbdpq ae3c2ec4e9 fix(netproxy): the health check pings a silent connection after 10s, not 20 (#4936)
What changed
The HTTP/2 health check is the only probe of a connection whose path has
died silently, so a turn in flight on such a connection waits for the
next one: with PingAfter at 20s a first try read EOF came ~20.5s after it
was written (Antigravity through a local proxy whose tunnel a NAT or a
relay had dropped, yetone/magpie#4936), and magpie's own retry served at
once on a new connection. PingAfter is 10s now: finding a dead path costs
at most half of what it did, and the margin a body under uploadBytes
needs on a slow uplink — the budget PingAfter+PingWait, a ping queued
behind the body and answered only after its last byte (#3909) — still
covers 64KB at about 3KB/s.

Run
go test -tags nogui -count=1 ./internal/netproxy (a new test walks a turn
onto a connection whose path dies under it and watches it fail at the
health check, then a retry serve on a connection of its own; a second
locks the sizing)
go test -tags nogui -count=1 ./internal/... — TestMothX,
TestProxyCheckSaysAProxyPassedBy and TestHostToldTheGatewayAddress are
red alone on the parent commit too; TestCodexPoolSaysTheClientsVersion is
a known full-suite flake, green alone
go vet, gofmt, GOOS=linux GOARCH=amd64 go build, GOOS=windows
GOARCH=amd64 go build, go build on darwin.

Reviewed and ported: every line read against origin/main 1b0340fdb.
Bodies of uploadBytes (64KB) and over go over HTTP/1.1, so the
PingAfter+PingWait budget, 30s down to 20s, still covers what HTTP/2
carries at ~3.2KB/s. On mote: TestPingAfterSizesTheDeadPathDiscovery is
red with netproxy.go put back to 1b0340fdb ("PingAfter 20s; want 10s"),
green with it. TestRequestOnAHoledConnectionFailsAtThePing builds its own
transport with scaled timings, so it passes on the old code too: it
documents Go's HTTP/2 health check on a dead tunnel, not this value.
On mote at this tree: go test -tags nogui -count=1 -timeout 45m
./internal/gateway/ ./internal/netproxy/: ok (gateway 1025.9s, netproxy
5.3s); go vet -tags nogui of both packages for darwin, GOOS=linux and
GOOS=windows: clean; gofmt -l: clean.
Not tried: the reporter's Clash/Mihomo route to Antigravity. This halves
the stall on a dead pooled connection (~21.5s to ~11.5s); it doesn't stop
the first try landing on it.

Generated-by: GLM-5.3-Flash (ZCode)
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-05 18:31:16 +08:00
ggbdpq f76b48ea09 gateway: a Chat finish of tool_calls with no call in the stream ends stop (#4944)
What changed: Hermes through magpie (stream=true, tools, deep
reasoning): a reply of text alone ended, on the reporter's upstream, on
a frame saying finish_reason "tool_calls" that no delta ever carried a
call for - the shape the reporter's bare call of the model ends its
real calls with ("delta":{"reasoning_content":null},
"finish_reason":"tool_calls","matched_stop":1); its text-only turns end
there too, and the client took every such turn for one whose calls were
dropped and re-prompted, three times a reply. The other gateway on the
same upstream said stop.

chatTidy's mend that ends a finish of tool_calls with no call left stop
(#1475) only ran for a choice some delta had carried a tool_calls key
for: the case "tool_calls" sat inside the t.called[choice] guard the
case "stop" needs, and a reply whose stream never carried the key
passed the misleading finish on. The switch now runs for every choice's
finish: a finish of tool_calls with no readable call ends stop whether
or not a delta carried the key, and the stop of a choice that made
calls still ends tool_calls. A legacy function_call a client may still
be reading (#4659) keeps a finish that says the turn ended in a call,
and a "function_call": null is still the contract's own nothing.

Whole replies are untouched: #1475's review narrowed chatWhole to a
finish whose call was dropped and pinned a whole reply that came with
no tool_calls at all as going as it came
(TestToolCallsFinishWithNoCallsStaysWhole); no report covers them.

Run: go test -tags nogui -count=1 ./internal/gateway: one red,
TestCodexPoolSaysTheClientsVersion, green on its own - the known
pre-existing red of this machine; the two new tests and the family
guards among the rest, ok. go test -tags nogui -count=1 -timeout 45m
./internal/...: 74 packages ok; the four failures are all red at the
parent 173b7e274 single-run too, none of this commit's own (TestMothX
in agent, TestProxyCheckSaysAProxyPassedBy in gui,
TestHostToldTheGatewayAddress in plugin, and the codex pool one above).
Red at the parent with chattidy.go from the parent and the tests kept:
TestChatNoCallToolCallsFinishEndsStop "calls map[], finish
"tool_calls"" and TestChatRelayLegacyCallFinish "finish "tool_calls"" -
the reported symptom; green again with the commit restored. gofmt -l:
clean. go vet -tags nogui ./...: clean. go build -tags nogui: darwin,
GOOS=linux, GOOS=windows: ok.

Reviewed and ported: every line read against origin/main 1b0340fdb
(chatTidy runs before textCallTidy, which sets tool_calls itself when it
makes calls from text, so a written call still ends tool_calls; a finish
line reaches the switch through needsTidy's "tool_calls" match). On mote:
TestChatNoCallToolCallsFinishEndsStop and TestChatRelayLegacyCallFinish
are red with chattidy.go put back to 1b0340fdb ('stream: calls map[]
finish "tool_calls"' and 'stream, function_call null and no call: finish
"tool_calls"'), green with it; the chattidy family (TestChatCallsEndToolCalls,
TestToolCallsFinish*, tidy/nameless/function_call tests) green.
On mote at this tree: go test -tags nogui -count=1 -timeout 45m
./internal/gateway/ ./internal/netproxy/: ok (gateway 1025.9s, netproxy
5.3s); go vet -tags nogui of both packages for darwin, GOOS=linux and
GOOS=windows: clean; gofmt -l: clean.
Not tried: a real Hermes against the reporter's upstream. Not covered:
the translated route (a Chat upstream's "tool_calls" finish with no call,
to an Anthropic or Responses client) still says tool_use; collector.finish
only mends stop to tool, not back.

Generated-by: GLM-5.3-Flash (ZCode)
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-05 18:31:16 +08:00
yetone 2f59545d29 gateway: a key not given a group listing alone is listed the members it may use (luckymanjc)
luckymanjc on Discord (#general, 11-05): on a second computer, through
Remote magpie, his three Codex accounts offered GPT-6-Luna alone, with
the key his Remote magpie uses held to "Codex 的全部模型" (codex/*),
GPT-6-Luna and the accounts. His screenshot of that key's picker, on the
host, offered GPT-6-Luna alone under Codex too.

Cause: a routing group listing alone (Group.Unlists, "the group alone")
keeps its members out of Catalog(), so out of /v1/models and the key
picker (/api/caller-keys/models), as the group stands in for them there.
Since d1cdce130 (11-03) that holds for subscription models again. But a
group of the user's own is never a key's unless the key names it
(kautism's rule, groupAllowed), so a key held to codex/* was given
neither the group nor its members: only the Codex models no such group
named were left, Luna here. The picker read the same Catalog(), so there
was nothing else to tick.

Fix: the group stands in only where it is given.
- provider.GroupStandIns: the models groups listing alone keep out, with
  the groups' ids (groupsKeeping, which unlistedByGroups now reads; a
  provider kept for routing groups alone is not among them).
- gateway keyListed: for a key that may use none of the groups standing
  in for a model and may use the model, the model is listed beside its
  provider's others; the list's own picks still leave one out. Every key
  list goes through it: catalogFor (/v1/models and what it feeds, the
  remote magpie's fetch included), /v1/models/{id}, the key's page,
  Codex's catalog and spawn choices. A key that names the group gets the
  group in place of its members, as before. Unrestricted callers are
  unchanged: the group alone, as the option says.
- The key picker offers those models after their provider's.
It is the same for every provider a group can list alone, not Codex
alone. Docs: reference.md, gateway-routing.md.

Tests (mote):
- TestKeyNotGivenTheGroupIsListedItsMembers (gateway): Free + Pro Codex
  sandbox accounts, a group listing sol/astra/terra alone. Unrestricted
  list: group, no members. The reporter's key (codex/*, codex/gpt-6-luna,
  both accounts): every Codex model, no group. A key of one member: that
  one. A key naming the group: group, no members. A Remote magpie on the
  reporter's key fetches every Codex model. Red on the old code (sol,
  astra, terra missing), green now.
- TestCallerKeyModelsOfferGroupKept (gui): the picker offers the kept
  models, beside their provider's. Red on the old code, green now.
- Broken by hand: dropping the "a group standing in is given" check
  turns the key-naming-the-group case red.
- go vet provider, gateway, gui; go test ./internal/provider ok;
  ./internal/gui all ok but TestMainWindowCorners (#3949, AppKit titlebar on
  mote's macOS, untouched here); ./internal/gateway -run
  "Key|Codex|Model|Remote|Group|Catalog|Spawn|Unlist|Caller" ok.

Not tried: the reporter's own host (his groups are inferred from the
screenshot: only Luna left under Codex in the picker); two real magpie
apps on two machines; real Codex accounts.
2026-11-05 18:28:38 +08:00
yetone 51bdc985bc provider: a cap set on a window a plugin later sets aside still holds; WorkBuddy min 0.2.24 (ferock on Discord)
WorkBuddy 0.2.24 stops an account by a new "Total credits" window (the
plan's credits and the extra ones together) and sets "Credits" and
"Extra credits" aside, so the Routing page reads every account the same,
its plan's credits spent or not. Routing skipped every window set aside,
caps included, so a cap the user had set on "Credits" would have stopped
holding the account: magpie's change overriding the user's value.

Now a window set aside, not a pool's or one model's, rides in each
limit's pool (allowanceOf), as a pool's windows do, and holds the
account at a cap set on that window itself (WindowCaps.own), never at the
account's cap or a Codex credits hold, which never reached it before.
WithCapped marks such a window Capped with OwnCap, so the GUI shows the
mark and the "at its cap" note for it, counts no account cap on it
(windowCapOf), and offers its meter as a button only while it has a cap
of its own, to change or lift it; no new cap on a window set aside.
app.js grows 48 bytes, inside the core budget (no raise).

Run (mote): go test ./internal/provider (ok) and ./internal/gui
(TestCoreScriptBudget ok); window-cap, window-cap-pool and account-cap
GUI tests, both engines, 420/1100, five languages: 136 pass.
internal/gui's TestMainWindowCorners/macOS_26_SDK (#3949) and
i18n-keys "a plugin's words are its own" (#5327, #5332) are red the same
on origin/main a9b1877cf, files this change doesn't touch.
Broken by hand: allowanceOf without the set-aside loop,
TestAsideWindowKeepsItsOwnCap red ("the user's 50% cap on Credits, at
60%, no longer held: <nil>"); app.js without the meter's ownCap guard,
window-cap 20 of 80 red (the new test in every engine, width and
language).
Not tried: a real WorkBuddy account with a cap on Credits; the whole GUI
suite (the full Go suite runs after the tag).
2026-11-05 18:22:56 +08:00
yetone a9b1877cfc routing: a session's name stays when a later poll answers without it (#5365)
refreshOtherNames deleted a name the page had whenever a poll of
/api/gateway/session-titles came back without it, so a read that failed
or ran late (ZCode's database busy or slow, Flandern1211's report) put the
card back to its folder until a later poll named it again. An answer
without a name is unknown, not a session that lost its name: the page now
only takes new names in. 226fc8ea3 makes ZCode's poll fast; this is the
"names that vanish" half of #5365, which that commit leaves alone.

Co-authored-by: Flandern1211 <163982805+Flandern1211@users.noreply.github.com>

Run (mote, via mote-run):
- node --test internal/gui/tests/routing-session-name-kept.test.cjs
  (new; Chromium and WebKit, all five languages, 1100 and 420): 20 pass.
  With client.js at origin/main: red, the card reads "Claude Code ·
  work/zc" after a poll without the name.
- go test ./internal/gui (budgets, i18n guards): ok but
  TestMainWindowCorners/macOS_26_SDK, #3949.

- node --test on the 8 GUI files that fake session-titles
  (claude-subagent-tag, routing-by-key, -credits, -moved-why,
  -request-metrics, -session-folder, -session-title, -sessions) and
  i18n-keys: 185 pass, 1 fail, i18n-keys "a plugin's words are its own"
  on two words in files untouched here (#5332, #5327).

Not tried: the whole GUI suite (one routing file changed by four lines,
no new strings, no new API call).
2026-11-05 17:53:42 +08:00
yetone 52563d1cdf sessions: a ZCode name poll reads its sessions' messages for their stamp, as the listing does (#5365)
226fc8ea3 lists ZCode's sessions for Titles from their rows alone, with
size 0 and the row's time_updated as the file's stamp. Two things followed
from that stamp:

- ZCode writes a message without touching its session's row, so a session
  still under its default title, first read before its prompt was in, was
  never named by that prompt while only the Routing page polled.
- The cache kept size 0 and the row's time, where the Sessions page's
  listing (zcodeFiles) keeps the message count and the last message's
  time, so each read the session whole again after the other.

zcodeTitleStamps gives the sessions a poll asks for (their key wanted,
subagents under it too) the same count and last activity, from a
COUNT/MAX over each one's own messages by session_id, not the join over
every session's. A session whose messages can't be read keeps its row's
stamp, as before.

Co-authored-by: Flandern1211 <163982805+Flandern1211@users.noreply.github.com>

Run (mote, via mote-run):
- go test ./internal/sessions -run TestZCode -count=1 at 226fc8ea3 alone:
  TestZCodeTitlesSeeNewMessages red (after the prompt: "") and
  TestZCodeTitlesKeepTheListingsStamp red (kept size 0 mod
  1790496000000000000, listing has size 3 mod 1790496030000000000). With
  this change both green. On origin/main 1b0340fdb both pass (the poll
  read the join), while 226fc8ea3's TestZCodeSubagentTitlesByRequestID and
  TestZCodeTitlesWithoutMessageTable are red there.
- go test -timeout 45m ./internal/sessions ./internal/gui -count=1: sessions
  ok; gui ok but TestMainWindowCorners/macOS_26_SDK, #3949 (mote is
  macOS 27), untouched here.
- GOOS=linux and GOOS=windows go vet ./internal/sessions: ok. gofmt clean.

Not tried: a real ZCode database (none on this Mac or the Windows box);
the per-session COUNT/MAX is not timed against the reporter's 1 GB one.
It filters message by session_id, as parseOpenCode's own reads do.
2026-11-05 17:53:42 +08:00
Flandern1211 24e1a21095 sessions: list ZCode's rows, not its messages, for a title poll
Titles listed every agent's files, and zcodeFiles joins the message table to give each session its size and last activity. On a ZCode database of 1,022 sessions and about 1 GB of messages that join took ~20 s, while the Routing page asks again every 15 s: its cards showed the folder for a while, and a poll that came back empty dropped a name it had.

Titles now lists ZCode's sessions from their own rows (zcodeTitleFiles: id, parent, time_updated) and names them through the same assembleListed/parseOpenCode path as before. A ZCode subagent, which ocRoots files under its parent's key, is named from its own file's cached row when the key asked for matches no group.

Run:
- go test ./internal/sessions -run 'TestZCodeTitlesByRequestID|TestZCodeSubagentTitlesByRequestID|TestZCodeTitlesWithoutMessageTable|TestZCodeDefaultTitleFallsBackToFirstPrompt|TestSessionTitles|TestZCodeCalls' -count=1: ok.
- go test ./internal/gui -run TestSessionTitlesNameOtherAgents -count=1: ok.
- Broken by hand: with zcodeFiles (the message join) in place, TestZCodeTitlesWithoutMessageTable fails with an empty title; with the subagent fallback removed, TestZCodeSubagentTitlesByRequestID fails; with the sess_ alias removed, TestZCodeTitlesByRequestID fails.
- Real ZCode database on Windows: Titles for three live sessions went from 20.4 s to 780 ms cold and 74 ms warm; a ZCode and dsh poll took 80-160 ms.
- go build ./...: ok. The full sessions package has the same three Windows-only failures as before this change (TestAgySessions, TestAgyRowOnly, TestCCListingKeepsItsNames).
2026-11-05 17:53:42 +08:00
yetone d3a0be6dda provider: Google's verify link is the one Gemini CLI opens, read whole from any body (pppuuu)
pppuuu (Discord) tested an Antigravity model, got Google's 403 "Verify your
account to continue." with a link, and opening the link gave Google's own
"400. That's an error. The server cannot process the request because it
is malformed."

What magpie showed was checked first, and it was Google's validation_url
whole: a realistic VALIDATION_REQUIRED body (ErrorInfo metadata with
validation_url, validation_error_message, validation_url_link_text, a
google.rpc.Help detail, & written raw and as &) sent through the
Antigravity model test (TestAntigravityModelTest) and through the gateway
to an agent (TestVerifyLinkWhole) shows the URL with every parameter on
the old code too. Google's own Antigravity flow gives the same 400 to
many accounts (discuss.ai.google.dev 119780: cleared google.com cookies,
Chrome, or removing Antigravity from third-party access fixed it).

What differed from Google's own client, and is fixed here:
- Gemini CLI (classifyValidationRequiredError) opens the google.rpc.Help
  detail's link first, past a "Learn more" one, then the ErrorInfo's
  validation_link, then validation_url. magpie took validation_url first
  and never read validation_link. It now takes them in Gemini CLI's order.
- Metadata was read as map[string]string, so one non-string value made the
  whole body unreadable and the link was lost; values are read one by one.
- A message magpie already put the link in, passed on again as a JSON
  error body (a Remote magpie's, the gateway's), has & as &; the raw
  read stopped at the \ and found no link. It is read from the decoded
  words now.

Tests: TestVerificationLinkWhole and TestVerificationLinkAsGeminiCLI
(provider), TestVerifyLinkWhole and a verify case in
TestAntigravityModelTest (gateway).

Run on mote: go test -run 'TestVerification|TestAPIError' ./internal/provider
ok; go test -run 'TestAntigravityModelTest|TestVerify|Restricted'
./internal/gateway ok; go vet (darwin, linux, windows) of internal/provider
and go vet internal/gateway ok; go test ./internal/provider: ok (178s).
Broken by hand: with the old test.go, TestVerificationLinkWhole (escaped
read-back) and TestVerificationLinkAsGeminiCLI (Help link) are red; the
gateway cases pass on the old code too, which is the evidence the shown
link was already whole.
Not tried: a real account Google wants verified (none here), and
pppuuu's exact body and link, which aren't known; whether Google's Help
link and validation_url ever differ is not known.
2026-11-05 17:50:33 +08:00
yetone 1b0340fdbc provider: WorkBuddy's mover min is 0.2.23, which hides DeepSeek Harness's name
plugins 4912c608 (npm 0.2.23, checked --prefer-online): a "Hide DeepSeek Harness's name" switch, on by default, takes dsh's identity lines out of what goes to WorkBuddy (NancyTom18 on X, an account banned after use from dsh). keepMovedCurrent brings moved users up to it.

Run: go test ./internal/provider on mote at this tree, ok (219s); gofmt -l clean. Not tried: a real WorkBuddy account.
2026-11-05 17:37:22 +08:00
yetone 6d9fb7ef0f routing: a dsh request names the dsh session its first prompt was read from
changqiu4890 on Discord: Routing -> Requests showed dsh's requests with no
session id. dsh 0.2.1's pi-ai routes (openai-completions, anthropic), which
magpie configures, send no session header (pi-ai's session affinity is
withheld by dsh's compat gate), so a route had only its Conv, the hash of
its first user message. The Context page already found dsh's session by
that hash (dshConvs); the Routing page grouped by header session only.

pricedRoutes now gives a dsh route with no session of its own the dsh
session whose Convs hold its Conv (convOwners, shared with the Context
page's joinConvs), from an index rebuilt at most every 2s when a conv is
missing and every minute otherwise. Grouping and titles (dsh:<id>) follow.
A route with its own session, another agent's route, and a conv two
sessions share stay as they were.

Run (mote-run, this tree):
- go test -tags nogui ./internal/gui/ ./internal/sessions/: ok, ok
- TestRoutingDshRoutesNameTheirSession and TestContext*: ok
- GUI routing-sessions, routing-session-folder, routing-by-key, ctx-route,
  routing-day-window: Chromium 160/0, WebKit 80/0
- go vet darwin, linux (nogui), windows ./internal/gui; go build all three
- gofmt -l clean
Broken by hand: `r.Session = owners[k]` -> `_ = owners[k]`; the new test's
dsh chat and messages routes went red.
Not tried: a real dsh through magpie. A brand-new session's first request
shows no session until dsh writes its session file and the index refreshes.
The in-flight list (Active, concurrency endpoint) is unchanged.
2026-11-05 17:25:26 +08:00
yetone 4f624241f7 codex: the ChatGPT app left on "hit a snag" after an app-server restart is reopened when idle (#4550)
ysm119 on Discord: each Restart of Codex in magpie left the ChatGPT
desktop app on "ChatGPT 遇到了问题 / 请重试" till it was quit and opened
again. magpie ends the app's own app-server cleanly (code 0); a
signed-in ChatGPT 26.1021 then fails "Hosted AppServerManager identity
is not ready" on the one it starts, logs fatal_error_broadcasted and
shows the page. That is the app's bug; magpie now follows it up.

- provider/codex_app_crash.go: for 60s after every end magpie makes
  (the watcher's step, RestartCodexApp, RestartSwitchedCodexApp) the
  app's logs are read for a whole fatal_error_broadcasted line stamped
  after the end. On one, with no request through magpie since or in
  flight and no Codex turn opened since, the app is quit and opened
  once. Otherwise it is left as it is and logged. Where it can't be
  reopened (Linux, an app that didn't quit) the Agents row says
  "The Codex app hit an error · quit it and open it again" (appSnag)
  until the app-servers seen then are gone or the app is closed.
  Unreadable logs reopen nothing.
- agent/codex_app_crash.go: the logs as the app's file logger writes
  them (macOS ~/Library/Logs/com.openai.codex, Windows
  %LOCALAPPDATA%\Codex\Logs and the Store package's LocalCache, Linux
  $XDG_STATE_HOME/codex/logs; YYYY/MM/DD folders, tail-read, half
  lines dropped). The relaunch is the Agents row's: on macOS
  ChatGPT.app found by its bundle id, quit as ⌘Q does and opened once
  it has ended, never forced; on Windows codexAppReopen.
- GUI line in en, zh, zh-TW, ja, de; docs/subsystems/agent-wiring.md.

Run on mote (macOS) at this head on origin/main 08982805e:
- go vet ./internal/agent ./internal/provider ./internal/gui (darwin
  and GOOS=windows), GOOS=linux go vet ./internal/agent
  ./internal/provider; go build ./...; gofmt -l clean.
- go test ./internal/provider ok; go test -run
  'TestCodexApp|Restart|Reopen' ./internal/agent ok.
- go test ./internal/gui: red only in TestMainWindowCorners (#3949) and
  TestPanelHiddenByWailsMarksPageOutOfSight (#5322), AppKit window tests
  red on mote's macOS 27 and filed before this change.
- win-run and wsl-run: go test -run TestCodexApp ./internal/agent
  ./internal/provider ok (the macOS relaunch test skips on Windows, as
  TestWorkBuddySidecarOutlivesQuitOnMac does, #4115).
- node --test codex-app-snag, codex-app-out, codex-app-back, i18n-keys,
  i18n-en-no-cjk: chromium and webkit, every language, 980 and 440px.
  i18n-keys' "a plugin's words are its own" stays red for "View routing"
  (#5327/#5332, red on main since 73c98ebc2); this change added a word
  there and took it out again.
- Core script budget: under it, not raised.

Broken by hand, each red then restored:
- codexAppCrashStep's call removed: 4 provider tests red.
- the watch not armed in RestartSwitchedCodexApp:
  TestCodexAppRestartsWatchForTheErrorPage red; in RestartCodexApp:
  TestCodexAppRowRestartWatchesForTheErrorPage red.
- the turn and request checks off: TestCodexAppInUseAfterItsErrorPageIsLeft red.
- the snag not set: TestCodexAppSnagSaidTillTheAppRestarts red.
- the stamp's >= since check dropped, or a half-written last line kept:
  TestCodexAppCrashedReadsItsOwnLogs red.
- a wrong Store package path: TestCodexAppCrashedReadsEachSystemsFolder red.

Not tried: a real signed-in ChatGPT app reaching the identity-not-ready
page, and a real quit and reopen of the user's ChatGPT.app (the relaunch
is tested with faked process listing, quit and open in a sandbox HOME).
The log line and folders are read from ChatGPT 26.1021's
file-based-logger and the reporters' logs; a later app that renames
them reopens nothing, as before this change.
2026-11-05 17:24:53 +08:00
yetone 08982805eb gui: spinners stand still under reduced motion instead of flickering
_yukirock on X (0.1.3036, macOS 27.3): spinners ran far too fast. The
reduced-motion rule cut every animation to .01ms but left endless ones
endless, so a spinner restarted every few microseconds and each frame
caught it at a random angle (seen frame by frame in the reporter's
video: the arc jumps 90-180 degrees per 60fps frame). It hits anyone
with the system's Reduce Motion, or magpie's own (Settings > General).

The rule now also sets animation-iteration-count: 1, so an endless
animation runs once, ends at once and shows its base style, as the
spinners that declare `animation: none` there already did (ag-up,
quota-refresh, saving). routing.css's busy spinner asked for a 2s turn
under reduced motion; the global !important rule always overrode it, and
it now stands still with the rest.

reduce-motion.test.cjs puts a sign-in spinner in the page and waits up to
1s for its animations to finish: they do while motion is reduced, and
never otherwise. (Counting running animations two frames on was red in
Chromium at the rebased head: a compositor animation can take longer to
start.)

Run on mote (Chromium and WebKit):
- reduce-motion plus every GUI file that reads animations under reduced
  motion (33 files, 1034 tests): 1011 pass, 23 fail. The failing four
  files (context-map, found-skill-pick-remove, mobile-web,
  tray-cell-click) fail the same on origin/main a732f3c49 run alone
  (24 vs 24, context-map's chromium 420px case flips language): filed as
  #3488, #4932, #5013, #3952, #5215.
- Broken by hand: the new test on the old app.css is red (spin 1 where 0).
- go test -tags nogui ./internal/gui: ok. gofmt -l clean.
At the pushed head: reduce-motion 6 of 6 runs green in both engines,
sync-spin green; the new test red on the old app.css (0 of 2).
Not tried: the real app with macOS Reduce Motion on.
2026-11-05 17:09:10 +08:00
yetone 965ae78e1e gateway: a routing group draws on its own image member, Codex's tool too
changqiu4890 on Discord: the group smart-split has three Codex CPA chat
models, DeepSeek-V4.1-Flash and Codex CPA's gpt-image-2.5, and dsh,
Codex and Pi are set to it. Image requests went to other providers'
image models.

Two causes in magpie:

- drawingTries tried every member of a group named for a drawing in the
  order chat routing plans them, so the chat members came first.
  group/smart-split drew on cpa/gpt-6-astra, which was asked as a chat
  for an image, before it reached the group's image member. A group
  with members that make the kind (drawsModel, or servesKind for
  video) is now tried on those members alone. The fallback between
  them stays as it was.
- Codex's image tool drew on the provider that served the turn, else
  on Settings' pick. A group's image member was never used: a turn on
  DeepSeek, or on the relay, drew with Settings' model or with the
  relay's other GPT Image. codexDrawingProvider now also returns the
  routing group the turn asked for. When that group draws (GroupDraws),
  the drawing goes to its image member through resolveDrawing, which
  keeps the member's provider.

The reporter's Routing screenshot also shows explicit requests from a
client magpie names "Mozilla": x0-15/gpt-image-2.5, codex/gpt-image-2.5,
and bare gpt-image-1 and gpt-image-1.5. magpie routes a request that
names a provider to that provider, and a bare id to the first provider
whose Drawers list it. Nothing in such a request links it to the agent's
group, so this commit leaves those requests alone.

Tests:
- TestMixedGroupDrawsOnItsImageMemberOnly (new): the reporter's group
  shape on fake upstreams, with another relay listing gpt-image-2.5
  first. Red before the fix (drew on cpa/gpt-6-astra), green after.
- TestCodexDrawingTakesItsGroupsImageMember (new): red with the group
  branch turned off by hand (drew on chat/gpt-image-2), green with it.
- TestMixedGroupMakesVideoOnItsVideoMemberOnly (new): a guard for the
  video sibling. It passes with the filter turned off as well, because
  video's mediaMembers already keeps only video members (KindGroup).

Run on mote (mote-run) at this tree:
- gofmt -l
- go vet ./internal/gateway on darwin, GOOS=linux -tags nogui and
  GOOS=windows
- go test -count=1 -run 'Group|Draw|Image|Video|Media' ./internal/gateway
- go test -count=1 -timeout 45m ./internal/gateway ./internal/provider

Not tried:
- a real Codex CPA relay or a real dsh session
- the image MCP's default for a non-Codex agent set to a group: the MCP
  call carries no link to the agent's chat route, so it still uses
  Settings' pick
- chat routing to a group's image member when the member's provider has
  no picks: the member's provider is still the pinned one, and this
  commit doesn't change it
2026-11-05 17:04:16 +08:00
yetone 331f201faf plugin: a cross-signed root copy in Windows' ROOT store no longer shadows Bun's own root (youyo.p_10001)
youyo.p_10001 (Discord #feedback, magpie 0.1.2993 windows/amd64, Bun
1.4.4, Clash Verge on 127.0.0.1:7897): every MiniMax plugin request to
agent.minimaxi.com failed "unable to get issuer certificate", while the
same chain verified outside the plugin host.

Cause: magpie hands Bun the user's Windows ROOT store as
NODE_EXTRA_CA_CERTS. Bun (BoringSSL) builds the chain up through the
first trusted certificate with the subject it wants, the extra file's
ahead of its own bundle, and stops when that one's issuer is missing.
A ROOT store holding USERTrust RSA's copy cross-signed by AAA
Certificate Services (agent.minimaxi.com's chain goes leaf, WoTrus DV,
USERTrust RSA) gave Bun that copy ahead of the self-signed root it
ships, and AAA is in neither. Node, curl and Schannel go on to the
self-signed one, so outside magpie it worked.

Fix: rootsFirst writes the self-signed roots first and keeps another
certificate only when its issuer is in the file too. Bun never ends a
chain on one that isn't self-signed (no partial chains), so one left
out could only stand in front of a root. NODE_USE_SYSTEM_CA=1 stays: the
system store Bun reads itself comes after its bundle and shadows
nothing (tried, below).

Also, for the next report like it:
- the host logs its network settings when it starts, and when the
  proxy (or the gateway's address) moves, old to new: the proxy without
  user and password (netproxy.Redact), NO_PROXY, NODE_EXTRA_CA_CERTS,
  NODE_USE_SYSTEM_CA, SSL_CERT_FILE/DIR (netLine);
- a fetch Bun refuses for the certificate keeps Bun's words and its
  code and cause, and adds "(UNABLE_TO_GET_ISSUER_CERT: the plugin
  host's TLS didn't verify agent.minimaxi.com's certificate chain
  against the roots it trusts)", so it doesn't read as the vendor's
  fault (throwTLS in host.js).

The plugin side, a China-site account call that can't reach
agent.minimaxi.com going once to agent.minimax.cn, is
opencode-minimax-auth 0.2.3 (magpie-community/plugins#757).

Run:
- Reproduced on xiaomi-gpu (Windows 11, Bun 1.4.2) with the real host
  and the real ROOT store: the real cross-signed USERTrust RSA (valid to
  2028) imported into LocalMachine\Root, then a scratch test through
  bunCommand (NODE_USE_SYSTEM_CA=1 included) fetching
  https://agent.minimaxi.com/: the file as before ->
  UNABLE_TO_GET_ISSUER_CERT, rootsFirst's -> 200. Certificate removed
  after (checked); without it both 200. Also as NODE_EXTRA_CA_CERTS
  alone: cross copy -> UNABLE_TO_GET_ISSUER_CERT; self-signed then cross
  -> 200; cross then self-signed -> UNABLE_TO_GET_ISSUER_CERT; cross with
  AAA either order -> 200. The cross copy in CurrentUser\CA with
  NODE_USE_SYSTEM_CA=1 -> 200 (no shadowing from the system store).
- New tests: TestRootsFirstPutsTheSelfSignedCopyAhead,
  TestBunGetsPastACrossSignedRootCopy (a synthetic cross chain through
  Bun), TestPluginTLSRefusalSaysWhose (through the fake plugin's fetch;
  Bun's message there is the reporter's "unable to get issuer
  certificate"), TestNetLineSaysNoSecret. Green on mote (macOS, Bun
  1.4.2) and on xiaomi-gpu via win-run, with the systemca tests beside
  them.
- Broken by hand on mote: rootsFile without rootsFirst ->
  TestBunGetsPastACrossSignedRootCopy/the_cross-signed_copy_first red;
  throwTLS rethrowing as is -> TestPluginTLSRefusalSaysWhose red
  ("err = unable to get issuer certificate").
- mote, at this tree: gofmt -l clean; go vet, GOOS=linux go vet -tags
  nogui, GOOS=windows go vet of internal/plugin ok; go test
  ./internal/plugin ok (111.7s). xiaomi-gpu: go test -run
  'Proxy|CA|TLS|Roots|NetLine|LAN|Network' ./internal/plugin ok.

Not tried: the reporter's own machine and store (what put the cross
copy in their ROOT store is a guess from the error; the host's new log
line will show NODE_EXTRA_CA_CERTS, and the file is in the cache's bun
folder); Bun 1.4.4 (the reporter's; 1.4.2 here); macOS keychain copies
(rootsFirst applies to systemRoots there too, untried with a real cross
copy); Linux takes the distribution's bundle as it is, unchanged.
2026-11-05 16:58:34 +08:00
yetone 97ccb90e88 routing: a group with no rule shows only the example rule's button, no paragraph under Rules (mr_coffee0083)
01a260af4 put a four-line paragraph under Rules in a group with no rule,
the whole setup for a thinking model and coding models spelled out. The
owner's UI rule: no secondary description the layout can carry. The
"Add an example rule" button stays, beside Add a rule and its ⓘ; the
rule it adds says what it is for in its own intent ("planning, design,
or a hard problem to think through"), to the group's last member.

- plugins/routing/client.js: rHint2 says only what holds the rules back
  (one model, routed by hand), as before 01a260af4.
- i18n.js: the paragraph's key out of zh, zh-TW, ja and de.
- routing-rule-example.test.cjs: the line under Rules is hidden while
  the button shows.

Run (wsl-run, magpie-desktop, Node 22, Playwright 1.62.0):
- routing-rule-example, i18n-keys, i18n-en-no-cjk: 27 of 28; the red is
  i18n-keys' "a plugin's words are its own" (#5327, the same on main).

Broken by hand: a "No rule yet" line put back under Rules for a group
with no rule: routing-rule-example 0 of 20, "no line under Rules".
Restored after.

Not tried: the real app window.
2026-11-05 16:35:38 +08:00
yetone a732f3c493 gateway: models of one API other than chat are grouped by id on their route (#5339)
XYenon (Discord) has the same embedding model at several providers and
asked why it isn't grouped the way chat models are. It wasn't even
listed: a fetched list dropped every embedding, rerank, speech and
transcription model, so "embed-1" on /v1/embeddings was a 404 unless a
hand-made group named it.

- catalog: a fetched list keeps those models, tagged with their API
  (Model.Serves, read from the id by ServesOf: rerank, embed/bge-,
  whisper/transcribe, tts-/-tts). Chat() and Live() leave them out, so
  agents' model lists, gateway keys and Routing's chat pickers never
  see them; LiveServing(id, kind) reads them. The live file says
  "kinded": true; a list fetched before this is fetched again once a
  run (autolist), with no schedule needed.
- provider: KindGroup(kind, ref) is made per request, never stored, so
  it is in neither Groups() nor Catalog(). Its id is
  auto-<kind>:<model> ("group/auto-embedding:embed-1"); its members are
  the providers that serve exactly that id for that API, in the order
  they were added, none off, decide-only, serving none, or with the
  model disabled.
- gateway: embeddings, rerank, speech, transcriptions and videos pick
  the group by route (mediaMembers): a bare id is a kind group when
  more than one provider serves it, the group's own id always; a
  hand-made group still works through offChatList. A group is of its
  own API: an embedding model's id on /v1/rerank is a 404.

Run at bd0f33828 + this change, on WSL magpie-desktop (mote was
running another session's full suite):
- go test -tags nogui -count=1 -timeout 45m ./internal/catalog
  ./internal/provider ./internal/gateway: ok, ok, ok (594s). The first
  run was red in three tests that held a fetched list to leaving its
  embedding model out (TestFetchArkMarksVideoModels,
  TestNvidiaModelScopeLiveList, TestTencentTokenHubList); they now hold
  it kept, tagged embedding, and out of catalog.Chat.
- 22 GUI files over the model lists and Routing pickers, both engines,
  every language (group-pick-drawers image-models-hide video-models-hide
  model-kind routing-kind agent-models agent-models-picker
  agent-model-groups agent-models-only-picked gateway-key-models
  gateway-key-groups group-from-model-add unlisted-models
  models-select-all-api provider-add-models provider-detect-models
  routing-rule-models panel-routing-pick fallback-group group-unlists
  settings-groups i18n-keys): 229 of 244 pass. The 15 reds are in six
  files that a control run of those six at bd0f33828 has red the same
  (14 of 56): #4389, #4964, #5332, #4616 and, new, #5357
  (routing-rule-models webkit 390). agent-models webkit zh's opacity
  0.998 was red here only, a fixed 250ms wait: #5358. No GUI asset is
  changed here; the GUI tests stub /api.
- on mote: TestProviderListBeforeSave (internal/gui; the add form's
  list keeps an embedding model out) and
  TestPiModelsAskedOnTheirNativeAPI (internal/agent), ok.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet of catalog,
  provider and gateway on mote at this head, ok.

Rebased then on origin/main d620ff6b5 (one commit, internal/agent and
internal/sessions only), and b63b28958 (one mover min line) after; at
d620ff6b5 + this on mote: go build ./..., go vet
of catalog, provider, gateway, agent and sessions, go test
./internal/catalog and -run 'Kind|Fetch|Nvidia|Tencent|Serving' of
provider and gateway: ok.

Red on the old code: TestKindGroupsServeEachAPIByRoute (embed-1 404)
and TestVideoKindGroupByTheModelsID (404).
Broken by hand, each red, then restored:
- the fetch dropping serves != "" again: TestFetchKeepsModelsOfOtherAPIs;
- the once-a-run refetch forced off: TestKindlessListFetchedOnce;
- KindGroup's disabled-model check removed:
  TestKindGroupHoldsTheExactModel;
- LiveServing asked with "" (any kind): the rerank-by-embedding-id
  check gets 200 instead of 404.

Known gaps, not done here:
- The Routing group editor still offers only chat and image models, so
  a new hand-made group of different ids (bge-m3 / BAAI/bge-m3) can't
  pick kind models: #5352.
- A bare id whose every member is disabled is a 404, not a 403.
- Rerank, Qwen3-Embedding and bge models that sat among a provider's
  chat models before (textModel's words missed them) leave agents'
  lists now. A hand-made group naming one keeps serving.
- /v1/models lists no kind model; the Routing live view may show the
  raw kind id.
Not tried: real vendors' lists and routes; the full ./... suite at this
head (queued on mote after another session's run; reds get issues).
2026-11-05 16:22:31 +08:00
yetone b63b289589 provider: WorkBuddy's mover min is 0.2.22, extra credits keep the account going once the plan's are spent (ferock)
ferock on Discord (2026-11-05, WorkBuddy China): once an account's base
credits were used up magpie moved to another account, though WorkBuddy
goes on serving it on its extra credits. workbuddy 0.2.22
(magpie-community/plugins 36fc59a7) sets the plan's Credits window
aside once it is spent with extra credits left, and Extra credits stops
the account, for the extra credits only the detail lists carry too, as
the summary's own split already did. keepMovedCurrent brings every moved
user up to it.

npm: `npm view --prefer-online --registry https://registry.npmjs.org
@magpie-community/opencode-workbuddy-auth version` answered 0.2.22
before this commit (the publish run is red only on think-tags 0.1.1's
E404, plugins#180).

Run at this tree on mote: go test -timeout 45m ./internal/provider/ ok
(302.7s); gofmt -l clean.
Not tried: a real move to 0.2.22, or any real account with extra credits
(the China desktop sign-in here is refused 401 by the billing meter).
2026-11-05 16:20:56 +08:00
yetone d620ff6b54 codex: an old OpenAI thread follows Codex onto magpie by its row, and back at the Disconnect (Parry_Moody, Cyrus)
Parry_Moody and Cyrus on Discord: Codex on OpenAI through an API key
before magpie, and for two days the Codex app answered every older
conversation "继续聊天未成功: This chat uses openai, but your current
provider is magpie. Switch to openai to continue."

Cause, from Codex's source (rust-v0.167.0-alpha.3.1, same in 0.166.0):
every thread Codex 0.166 starts is paginated (history_mode 'paginated'
in its state-DB row), and for those thread-store read_thread takes the
provider from the row, never the rollout ("Paginated history may contain
only a suffix, so its display metadata lives in SQLite"). The app sends
thread/resume with modelProvider null (ChatGPT.app 26.1021, Kct in
app-shared), so the row alone decides, and load_for_resume refuses a row
other than the current provider. bringOver moved threads by rewriting
files: plain ones in place, packed ones only from the last 30 days and
128 MB a sync. An older or packed OpenAI thread kept an openai row.

Now sessions.RetagPagedCodexThreads moves every paginated thread on a
provider by its row alone: any age, packed or not, an id of any length,
no file read, written or copied. Each thread is held by its writer lock
(an open one stays: its writer would write the provider back), one
written to in the last minute waits, 200 rows a transaction. It runs
after the in-place relabel in bringOver, bringBack (so a Disconnect no
longer copies a whole paginated history to the trash), bringOfficial and
bringBeside, and giveBeside by ids (RetagPagedCodexThreadIDs). Legacy
threads keep the file path. The Sessions page lists a paginated thread
on its row's provider (codexPagedProviders, memoised on the DB and WAL
stamp), so it isn't offered a Move it had.

Run:
- real codex-cli 0.166.0 (npm latest) on mote in a sandbox CODEX_HOME,
  a fake Responses server: a thread started with OpenAI (API key,
  openai_base_url) is paginated, row openai; with model_provider magpie
  `codex exec resume` failed with exactly "This chat uses openai, but
  your current provider is magpie" (modelProviderMismatch). After
  magpie's RetagPagedCodexThreads on that home (a throwaway test calling
  it, not committed) it resumed and answered; the rollout still names
  openai. Reversed (magpie -> openai) with config back on OpenAI, it
  resumed again. The first retag try moved nothing: the rollout had been
  written <1 minute before, the ActiveWindow skip, as intended.
- mote: gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
  for ./internal/sessions ./internal/agent; go test ./internal/sessions
  ./internal/agent: ok (sessions 20.1s, agent 194.4s) on mote, plus go vet on darwin, linux -tags nogui and windows

Broken by hand:
- RetagPagedCodexThreads returning nil (the old behaviour):
  TestCodexPagedThreadsFollowByRow red (250 packed 90-day-old threads
  "on openai, want magpie"), TestRetagPagedCodexThreads red.
- the writer-lock hold skipped: TestCodexPagedThreadsFollowByRow red,
  the open thread moved to magpie.

Not tried: the Codex app GUI itself (the app goes through the same
app-server thread/resume, whose modelProvider it sends null); Windows
and Linux runs (vet only). Codex rebuilds a row from its rollout when a
search listing reconciles it, which puts a retagged thread back on its
file's provider until the next sync; not seen, read from the source.
A legacy thread packed over 30 days still waits for Sessions' Move.
2026-11-05 16:11:14 +08:00
yetone bd0f338282 hermes: a Claude model goes on anthropic_messages, so cache_ttl 1h works; the user's api_mode stays (#5315)
cherish_onlyy (#5315): magpie wrote providers.magpie as chat_completions at
the gateway's /v1 for every model. On chat completions to a custom provider
Hermes sends no cache marks (anthropic_prompt_cache_policy gives
(False, False)), and the marks magpie adds for a Chat client last five
minutes, so prompt_caching.cache_ttl: 1h never reached the vendor. They set
api_mode: anthropic_messages and the gateway's root by hand and got 1h
writes; magpie's next sync or connect wrote chat_completions at /v1 back.

Hermes takes api_mode per providers entry, never per model
(_resolve_named_custom_runtime, hermes_cli/runtime_provider_custom.py;
aliases in config_providers.py's _API_MODE_ALIASES, transport read when
api_mode is absent). On anthropic_messages its adapter strips a trailing
/v1 and the SDK adds /v1/messages, and for a "claude" model on a
third-party gateway it puts its own system_and_3 marks at the configured
ttl (agent/prompt_caching.py, read at d914e233). So magpie now writes two
entries, as dsh already splits its routes:
- magpie: chat_completions at gw/v1, every model not on Messages;
- magpie-anthropic: anthropic_messages at gw (no /v1), the models whose
  native API is Anthropic's Messages and not Responses (hermesOnMessages).
model.provider follows the picked model (hermesRoute), in every profile;
a sync moves a Claude model magpie had set under "magpie" onto
magpie-anthropic, and drops that entry when no model is left for it.
Disconnect takes both out.

The user's own value: an api_mode or transport on one of magpie's entries
that isn't the one magpie writes there (by Hermes's aliases, so "openai"
is still magpie's chat) is the user's (hermesModeIn). It stays through
sync and pick, base_url follows it, and on "magpie" that entry then
serves every model and no magpie-anthropic is written, which is the
reporter's set-up exactly. magpie only ever wrote chat_completions into
providers.magpie, so nothing earlier is mistaken for the user's.

Tests:
- TestHermesClaudeGoesOnMessages: Claude on magpie-anthropic (mode, base
  without /v1, models), deepseek stays on magpie at /v1, Get/Check/Drift
  clean, a pick moves model.provider back, a bot profile too, Disconnect
  removes both entries from every profile.
- TestHermesSyncMovesClaudeOntoMessages: an existing connected config is
  moved on sync, and back when the provider goes chat-only.
- TestHermesKeepsTheUsersAPIMode: api_mode anthropic_messages at gw,
  transport: anthropic, codex_responses: each survives two syncs and
  two picks, base_url kept; api_mode: openai is still magpie's.
- internal/gateway TestHermesHourMarksReachTheVendor: a Hermes-shaped
  /v1/messages turn with 1h marks reaches the Anthropic upstream with
  every mark at 1h; the same turn on /v1/chat/completions goes at 5m.
  This one passes on the old code too: the gateway already passed the
  marks through; it guards that and records why the mode matters.

Run (mote-run, this tree):
- go test ./internal/agent/ -count=1 -timeout 45m: ok
- go test ./internal/gateway/ -run 'TestHermesHourMarksReachTheVendor|TestResponsesToClaudeMarksLastAnHour' -count=1: ok
- go vet ./internal/agent/ ./internal/gateway/, GOOS=linux and GOOS=windows: ok
- gofmt -l: clean
Broken by hand:
- hermesSplit returning (nil, false), the old one-entry behaviour:
  ClaudeGoesOnMessages, SyncMovesClaude and the openai-alias case fail.
- hermesModeIn never reporting the user's mode: all three
  KeepsTheUsersAPIMode cases fail at "sync".
Not tried:
- Hermes itself: it was not run (running it under a temp HERMES_HOME
  rewrites the live launcher); its behaviour is read from its source at
  d914e233. No real 1h cache write was measured against a vendor.
- Group models whose members are all Claude, and Claude Code sign-ins
  (no Native API), stay on chat_completions; GPT on codex_responses is
  #3080.
- Windows and Linux runs of the agent package (vet only).
2026-11-05 15:53:16 +08:00
yetone 465928bcce backup: the default backup folder says a reinstall takes it too; docs say how to keep magpie on another disk (two_2025.)
two_2025. on Discord asked to pick magpie's config folder: on Windows it
is on C:, and a system reinstall without a backup loses everything.
Two ways already exist and neither is said where the user looks:
automatic backups can go to any folder (Settings > Sync and backup >
Backup folder > Change...), but default to auto-backups inside magpie's
own folder, lost with it; and portable mode (a data folder beside
magpie.exe, internal/appdir) keeps everything on another disk. So no
new data-folder setting: moving the live folder would have to repoint
the library's links, agents' configs and a running gateway, and its
pointer would sit on C: and be lost on the same reinstall.

- AutoStatus reports inside: the backup folder is settings.Dir() or in
  it, letter case aside off Linux. The Backup folder row then says a
  reinstalled system or a lost disk takes these backups too, and to pick
  a folder on another disk or a cloud drive's (en, zh, zh-TW, ja, de).
  A folder picked elsewhere says nothing new.
- docs/start (en, zh, ja) #data-folder: pick a backup folder on another
  disk and restore from it after a reinstall, sync for the keys, or run
  portable from D:\magpie with a data folder beside magpie.exe.
- docs/subsystems/sync-backup.md names the field and the tests.

Run (mote, at this tree on origin/main 5db1b07ed):
- go test -count=1 ./internal/backup/ ./internal/gui/: backup ok; gui
  red only in TestMainWindowCorners/macOS_26_SDK (#3949, mote's macOS 27).
- node --test auto-backup, i18n-keys, i18n-en-no-cjk, sync-not-backup:
  49 of 50; the red is i18n-keys "a plugin's words are its own", red on
  main since 73c98ebc2 (#5327, #5332). auto-backup passes in Chromium and
  WebKit, 1100 and 420px, all five languages.
- node --test site/*.test.mjs: 84 of 84.
- GOOS=windows, GOOS=linux and native go vet ./internal/backup/; gofmt -l.
- Windows (win-run on xiaomi-gpu): go test ./internal/backup/ ok
  (TestAutoInsideMagpiesFolder with the upper-case path);
  ./internal/appdir/ red only in TestFoldersJoinedOnce (#4846, untouched).

Again at this commit, rebased on origin/main 435f04151 (mote): go test
./internal/backup/ ok; auto-backup.test.cjs 22 of 22 and i18n-en-no-cjk
ok.

Broken by hand: AutoStatus with inside always false makes
TestAutoInsideMagpiesFolder red ("default folder ... inside false");
the JS line dropped makes auto-backup.test.cjs red (webkit 1100px zh,
zh-TW).

Not tried: the real app on Windows with a backup folder on another
drive and a restore after a reinstall; a portable copy moved to D: from
an installed one (the docs restore a backup into a fresh portable copy
rather than copying the folder, whose library links point at the old
one). Full suite runs after the push.
2026-11-05 15:30:11 +08:00
yetone 435f041514 gateway: an account near its usage cap takes one turn at a time (dyzdyz010)
dyzdyz010 on Discord: two Claude Code accounts, each capped at 90% of its
five hours, Stop at the caps and Check usage near the cap on, and both
read 100%. Routing holds a capped account by its last reading. Turns sent
together (an agent's subagents, several agents) were each planned on the
same reading, so an account a point under its cap took every one of them,
and went as far past it as they used between them. Check usage near the
cap reads the usage again before planning, but every turn read the same
figure: each saw 89%.

- gateway (cap_near.go): within 5 points of a usage cap (carefulNear),
  an account takes one turn at a time. A turn that finds it busy goes to
  the next candidate first, the account moved behind them once; the last
  candidate waits for it. Once its turn comes capHeld judges it again, by
  what the reply before it said (codex.rate_limits, rate_limit_event), or
  by the usage read again when that reply said nothing (at most
  carefulWait). Held, it is passed over, or the agent gets the cap's 429
  when nobody is left. The cap is passed by one turn at most.
- A conversation kept on its account by Stays: Strict takes no turn there
  and goes on past the cap, as before. Neither does an account already
  held when its try begins, let in past its cap on purpose (a Codex reset
  spent for it, its credits).
- docs: gateway-routing.md's capHeld step, providers-accounts.md's cap
  sentence.

Run (wsl-run, magpie-desktop, Go 1.26.8):
- go test -tags nogui -run 'NearCap|FarFromCap' -v ./internal/gateway:
  the five new tests pass.
- go test -tags nogui -race -count=20 -run 'NearCap|FarFromCap'
  ./internal/gateway: ok.
- GOOS=linux go vet -tags nogui ./internal/gateway, GOOS=windows go vet
  ./internal/gateway: ok. gofmt -l: nothing.
- go test -tags nogui -timeout 30m -run
  'NearCap|FarFromCap|CodexNoCredits|Reset|Strict|Cap|Credits'
  ./internal/gateway: ok.
- go test -tags nogui -timeout 45m ./internal/gateway ./internal/provider,
  at this tree rebased on 248853225: ok (gateway 604.9s, provider 90.9s).
- at the pushed head, rebased on 5db1b07ed: the vets ok, and -run
  'NearCap|FarFromCap|CodexNoCredits|Reset|Strict|Cap|Credits|Group'
  ./internal/gateway ok.

Broken by hand (each restored after):
- the whole near-cap block off (`&& false`): TestNearCapTakesOneTurnAtATime
  red (acct-1 took all 4 turns), the two wait tests never saw a turn
  waiting, and TestNearCapClaudeAccountsTakeOneTurnEach red (both turns on
  the account near its cap, the spare never run).
- nearCapAgain a no-op: TestNearCapReadsAgainAfterASilentReply red
  (200, 200).
- capHeld's second look off: TestNearCapWaitsThenHolds and
  TestNearCapReadsAgainAfterASilentReply red.
- the first full run, before the strict exception, had
  TestStrictAffinityGoesPastTheCap red: the strict conversation got the
  cap's 429. The second, without the held-on-entry exception, had
  TestCodexNoCreditsSpendsAReset and
  TestCodexNoCreditsResetAfterTheLastRefusal red: the account a reset
  was just spent for was held again. Both fixed in this commit.
- An unrelated red in the first run,
  TestZCodeTrialRefusalRestsTheTrialAlone/trial_edge_block ("no plugin
  signs in to zcode"), passes alone and was green in the last run; filed
  as #5335.

Not tried: a real Claude or Codex account near its cap; plugin accounts
(their caps go through the same candidate loop, untested here). One turn
alone can still pass a cap by what it spends: an Opus turn on a Pro plan
can take several points of the five hours.
2026-11-05 15:16:13 +08:00
yetone 01a260af46 routing: a group with no rule says what a rule is for, with an example rule (mr_coffee0083)
mr_coffee0083 on Discord asked how to set up a group where one model
thinks and several others write code: the group editor's rules part
had no word on it and no example to start from.

- plugins/routing/client.js: a group of two models or more, not routed
  by hand, with no rule yet, says under Rules that every turn goes by
  the routing, and how one model thinks while others write code: the
  coding models in a group of their own added first, the thinking model
  after it, routed In order, and a rule sending planning and hard
  problems to the thinking model. "Add an example rule" beside "Add a
  rule" adds that rule, its intent filled in ("planning, design, or a
  hard problem to think through"), for the editor to finish. Neither
  shows once the group has a rule, or for one model, or routed by hand.
- i18n.js: the three strings in zh, zh-TW, ja and de, with each
  language's own word for In order.
- routing.css: the button wraps and reads in the accent colour, as the
  text buttons beside it.

Run (wsl-run, magpie-desktop, Node 22, Playwright 1.62.0):
- routing-rule-example.test.cjs (new): 20 of 20, chromium and webkit,
  en zh zh-TW ja de, at 1100 and 390 wide. The hint and button show,
  nothing is past the editor's side, pressing adds one rule to opus
  with the translated intent, Save posts it with the classifier Jev;
  after a reload a group of one model, or routed by hand, shows
  neither.
- the 16 i18n-*, routing-rule*, routing-rules-*, group-editor-* and
  routing-classifier* files: 190 of 221. The 31 reds are in
  i18n-keys (#5327, #5332), routing-rule-drag, routing-rule-models,
  routing-rule-remove and routing-rules-line (#4585, #5088, #3789,
  #4112, #4560). Those five files run alone, one at a time, at clean
  origin/main 9d143eaca: 24 reds there, 27 here, the same tests with
  different subtests each run.
- at the pushed head, rebased on 5db1b07ed (which changed
  routing/client.js): routing-rule-example 20 of 20; i18n-keys red
  only by #5327, the same as main.

Broken by hand: rTry never shown (hidden = true): the new test 0 of
20, "the example's button shows". Restored after.

Not tried: the real app window; mr_coffee0083's own groups.
2026-11-05 15:16:13 +08:00
yetone 5db1b07ed9 gui: the tray panel's Usage tab is drawn again in Settings' currency picked alone, and when its read came before the state (dLdgKyRd)
dLdgKyRd on Discord, v0.1.3025 on macOS: the menu-bar panel's Usage tab
said ≈$12.36 while the window's Usage page said ≈¥82.61 for the same day.

v0.1.2913 (2ba044aa6) made the Mac panel's page hear that it was hidden
and shown, so a reopen reads the state again. Nothing since changed that
path; its redraw never came. applyPrefs drew the panel's Usage tab again
only when the number units changed. A currency change called the Usage
page's costs hook, which redraws the page and Routing, not the panel's
tab, which keeps its own read. 2913's test picked ¥ and 万 / 亿 together,
so the units' redraw hid it. And the first applyPrefs (applyPrefs.painted
false) redrew nothing: the panel opened on its Usage tab reads its usage
beside /api/state, and when that read came first it drew $, which no
reopen, focus or quiet read of the same figures drew again.

applyPrefs now redraws the panel's Usage tab, when it has drawn, on any
change of currency, rate or units, the first settings included.

Tests: panel-units-follow.test.cjs gets "follows Settings' currency
picked alone": first open with ¥ set and /api/state answering 400ms after
the usage read; ¥ picked alone, then a reopen; $ picked again, then a
focus (Settings changed while the panel was open); and the panel opened
on Agents, ¥ picked, its Usage tab picked after. zh, en, zh-TW, ja, de, at
380px and 300px, Chromium and WebKit.

Run on mote (macOS 27.2), at this tree:
- node --test panel-units-follow (the new test 20/20 subtests, the 2913
  one 12/12), panel-usage, currency, number-units, window-visibility,
  i18n-en-no-cjk: 62/62, at the rebased head (parent a2f7ed2e8)
- go test -count=1 ./internal/gui/ (core and app.js budgets included,
  app.js 1,311,133 of 1,316,874): every test ok but
  TestMainWindowCorners/macOS_26_SDK, red alone at a2f7ed2e8 too (#3949)
- go vet ./internal/gui/, GOOS=linux go vet -tags nogui, GOOS=windows go
  vet: ok; gofmt -l: nothing
- every panel-*, usage-*, currency, number-units, window-visibility and
  i18n file before the rebase: 1462 of 1495; the 33 reds are in
  i18n-keys (#5327, #5332), usage-agents-hide and usage-fold (#2399) and
  usage-ledger (#5048), and the same four files are red alone on
  origin/main 2891ec7a7 (34 there)

Broken by hand: the new test against the old app.js (a copy of the
assets, MAGPIE_PANEL_UNITS_ASSETS): 0 of 10 in each engine, "first open,
the state after the usage" (≈$26.40); with the first-open part left out,
"reopened after ¥ was picked alone" red in zh and en. The tab part passes
on the old code too: it is a guard, not the bug.

Not tried: the real tray panel by hand on a Mac, nor on Windows or Linux;
dLdgKyRd's exact sequence (which of the paths they hit) isn't known.
2026-11-05 15:09:33 +08:00
yetone a2f7ed2e81 gateway: a hand-made group of embedding, rerank, speech, transcription or video models is served when its providers have picks
XYenon on Discord: a routing group of embedding models was a 404 on
/v1/embeddings. Picks are of chat models, so membersFound dropped every
member of a provider with picks as unpicked (#3911). 1d8658abc fixed this
for drawings with FindDrawingGroup. The sibling routes still used
FindGroup: retrieval (embeddings, rerank, speech, transcriptions and
translations, which all go through serveRetrieval) and /v1/videos.

provider.FindGroupAlso is FindGroup with an "also keep" test, and
FindDrawingGroup now wraps it. The gateway's mediaMembers keeps a member
that is not on its provider's chat list (offChatList), so a chat model the
user unticked stays out. mediaGroupFirst resolves the group's first such
member, because Resolve reads the agents' catalog and finds none of them.
The routing doc says the same.

Auto groups by kind (non-chat ids never reach autoGroups) are #5339 and
are not in this commit.

Run on mote:
- go test -count=1 -timeout 45m ./internal/gateway ./internal/provider:
  ok (gateway 823.6s, provider 180.0s)
- GOOS=linux and GOOS=windows go vet of the two packages: ok
- gofmt -l: clean
- No GUI file changed, so no GUI run.
- At the rebased head (on origin/main 2891ec7a7: 6 commits, balance_probe and
  others, none in group, retrieval or video code): go test -run
  'MediaGroup|VideoGroup|ImageGroup|Retrieval|Embedding|Speech|Transcri|Rerank|Group'
  ./internal/gateway ./internal/provider: ok; gofmt -l: clean

Red on the old code: with media_group.go removed and the three routes back
on FindGroup, TestMediaGroupOfProvidersWithChatPicks fails with 404 "magpie
knows no model "group/emb"" and TestVideoGroupOfProvidersWithChatPicks with
404 for "group/vid". In both, the members' providers have picks that don't
name the embedding/speech/video ids.

Broken by hand: offChatList made to return true lets the unticked chat
model in, and the test goes red ("a group of a chat model the user unticked
was asked: 400 ... chat-model is not an embedding model").

Not tried: a real vendor's embeddings or speech through a group (fakes
only), plugin-served embedding models, and the full suite (it runs after
the push).
2026-11-05 14:57:43 +08:00
yetone 2891ec7a7b docs: Trae / Trae CN through magpie, in the start page's FAQ (en, zh, ja)
A user (tz_188, Discord) confirmed Trae works with magpie this way:
the gateway's address in Trae's custom model settings, Share on local
network (局域网共享) turned on, and a gateway key as the API key. Trae keeps
custom models in the Trae account, server-side, so magpie can't set it up
in one click, and Trae may not reach 127.0.0.1. The FAQ entry (#trae)
says that, hedged as a user report, and links Remote magpie's #share.

Run: node --test site/*.test.mjs via mote-run at this tree, 84 of 84 ok.
(Run with -C site it is 83 of 84: the sponsors test reads ../README.md,
which -C site doesn't copy; not a red.) No Go test reads site/public/docs
(pluginrt's tree walk skips site/), so none was run.
Not tried: Trae itself; the steps are the reporter's, not reproduced here.
2026-11-05 14:55:06 +08:00
yetone 06508f2bf5 library: a stdio server that refuses home is checked again in a project folder (fff)
math_milian on Discord: fff-mcp worked in their agent, but Library → MCP
said "fff exited (1)". fff-mcp indexes the folder it starts in and
refuses a file system root or home ("Can not run certain FFF features in
a file system root or home directories"), exiting 1. magpie's check
starts every stdio server in home (#1727), where agents never start it;
they start it in their project.

When a local check exits, it now starts the server once more in an empty
project folder of its own (removed after). If it answers there:
- given to agents that start it themselves (no router, not Codex on
  magpie, or hub "direct"), the row shows its tools, and the tooltip says
  it exits in home, with what it said;
- run by magpie in home for agents (the MCP router, or Codex on magpie's
  RunPath), the row says "won't start in home" (why "home"), and its
  editor offers "Through the MCP router" to turn off, even with the router
  off, so each agent starts it in its project.
A server that exits in both places reads as before. WSL checks are
unchanged. healthKey (Go and client.js) now includes whether magpie runs
it in home, so a router change checks it again. startServer takes the
dir; the hub and the RunPath runner still pass home.

Run:
- go test -count=1 -timeout 30m ./internal/library on mote: ok (159s).
- TestCheckServerThatRefusesHome red on the old code: State error, Why
  exited, Code 1, with fff's text, the reporter's case.
- Real fff-mcp 0.11.0 (cargo-built on mote, sandbox HOME resolved through
  /private/var) via CheckServer: direct ok, 3 tools, Project; router on,
  Why home, Code 1.
- go vet ./internal/library ./internal/gui (darwin), GOOS=windows and
  GOOS=linux go vet ./internal/library on mote; gofmt -l clean.
- GUI on mote, Chromium + WebKit: mcp-home-health (new, every language,
  1100 and 390), library-mcp-health, mcp-hub-direct, library-mcp-hub,
  library-mcp-health-wsl, i18n-en-no-cjk, i18n-keys: 91 of 92 ok. The red
  is i18n-keys "a plugin's words are its own" on search_row_archive_test.go's
  "View routing", red on main since 73c98ebc2 (#5327, #5332).

Broken by hand: the new test run against the old mcp_check.go (red as
above).

Not tried: Windows and WSL runs; a real agent session through the router
or Codex's RunPath; the whole GUI suite.
2026-11-05 14:50:02 +08:00
yetone 24d315fa85 routing: the request list can be grouped By key, each gateway key's calls under its name
acezan (#help on Discord) asked to see API use on the Routing page the way
it shows each agent's, live and in the history. The list's group bar gets
a third button, By key, after By request and By session. It shows once
Settings has a gateway key (/api/caller-keys). Each head is the key's
current name (else the name the route kept, else its id), with its agents
dim beside it and the usual count, tokens, in progress and cost. Calls with
no key (from this computer, or kept before 75fb76186 named the key) go
under "No gateway key". A row's tooltip names its key too. The choice is
kept in localStorage (magpie.routingGroupBy), and the old
magpie.routingBySession still works. Text added in zh, zh-TW, ja and de.

click-scroll counted two group buttons and now counts three, with By key
hidden when there is no key. purpose-filter clicked .last() for By
session and now picks [data-by="session"].
reference.md and gateway-sessions.md describe By key and Route.CallerKey.

Run (WSL magpie-desktop: mote's disk is full, ld errno=28):
- routing-by-key.test.cjs: 20/20 in chromium and webkit, in en, zh,
  zh-TW, ja and de, at 1100 and 420. Red 20/20 with client.js and
  i18n.js at the parent (waits for By key).
- 254 Routing-related GUI files at concurrency 4. Every red was rerun
  serially, with this change and at origin/main 73c98ebc2.
  - Only purpose-filter and click-scroll were this change's; both are
    fixed above and green now.
  - The rest are red at main too, or flake there: #5045 call-headers,
    #4385 click-scroll wheel, #5049, #1745, #4689, #3402, #4623, #1937,
    #3773 idle-frame (10 frames, passes on rerun), plus routing-rule-*,
    zero-priced-free and others under #4121/#4400.
- Windows: go test ./internal/gui. Reds are #4115/#1827, plus
  TestPluginAgentMissingSaysSo and TestGatewayHeldByAContainer, red at
  main too and filed now as #5324.
Not tried: the real app, the whole GUI suite, the tray panel (no By key
there). A key renamed after a row was drawn shows its old name in that
row's tooltip until the row is drawn again.
2026-11-05 14:47:18 +08:00
yetone 5fe4c48df9 gateway: a route names the gateway key it came with, by id and name
The Routing page is to show each gateway key's requests as it shows each
agent's (acezan on Discord). A route kept the key's id only for
sessionLatest, unexported, so neither the trace nor the routing history
said it. Route.CallerKey and CallerKeyName are now in its JSON: the id and
the name the key had, never the secret. A request with no key names none,
and so does every route the history kept before this.

The trace is told to this computer alone (/v1/magpie/trace is loopback
only, /api/gateway/trace the GUI's), and /v1/magpie/route sends
sessionRouteOf's projection, which carries neither field.

Run (wsl-run, magpie-desktop; mote's disk was full, its link failed with
errno 28): go test -count=1 -run
'TestTraceNamesCallerKey|TestSessionRoute|TestCallerUsage|TestRejectedRequest'
./internal/gateway ok. Broken by hand: with trace.go, unrouted.go and
session_route.go back at c2b8814e7, TestTraceNamesCallerKey fails ("the
key's route doesn't name it").
2026-11-05 14:47:18 +08:00
yetone b95a78d43c gui: the editor says where magpie found a relay's balance, with Use
A relay added by hand with no Balance URL has its balance found by
magpie, but nothing in the window said so. A user who saw a wrong amount
couldn't tell it was a guess or where to put it right. Under the Balance
URL, in Advanced, the editor now shows "Found by magpie: <url> <field>"
with Use, which copies the query into the Balance URL and Balance field
to be changed. Check balance draws the line again from what it found,
and when it found nothing it says "No balance at /v1/usage or
/api/usage/token" instead of "No Balance URL to ask".

/api/providers carries balanceFound and balanceFoundField. The check's
reply carries looked, found and foundField. The line is in balfound.js,
loaded when the editor draws a relay's balance with no Balance URL. Its
one call and the check's text in app.js are paid for by three provider
editor comments cut down, so there is no raise: the core is 1,533,452,
350 under its budget. zh, zh-TW, ja and de are translated.

Run on mote:
- go test -count=1 -timeout 45m ./internal/gui: ok, except
  TestMainWindowCorners/macOS_26_SDK, mote's macOS 27 (#3949).
- GUI, both engines: balance-found (new, 900px and 420px, every
  language) 22/22. balance-url-first, balance-fix, balance-method,
  balance-field-default, key-balance-card and old-webkit: ok.
  i18n-keys: "a plugin's words are its own" is red (#5327), as on main.

Broken by hand: with the import taken out of app.js, balance-found is
0/11 in chromium.

Not tried: the whole GUI suite at this head (run after the push), and
the real app with a real relay.
2026-11-05 14:46:23 +08:00
yetone 464cc30f91 provider: a relay's found balance query is looked for again each day
A relay added by hand with no Balance URL has its balance found at
/v1/usage or /api/usage/token (248853225). What was found was kept until
magpie quit, so a relay that moved to other software went on being read
at a query that may now mean something else. A query found is now kept
24 hours and then looked for again. If the look finds nothing, the old
query stays when it turns the key away (401/403, so the card says the
relay refused the key instead of going) or the relay can't be reached.

BalanceFound tells the editor where the balance was found, so a wrong
amount can be put right (the GUI commit after this one).

Run on mote:
- gofmt -l: nothing.
- go vet, GOOS=linux go vet -tags nogui and GOOS=windows go vet of
  ./internal/provider and ./internal/gui: ok.
- go test -count=1 -timeout 45m ./internal/provider: ok.

Broken by hand:
- A found query kept for ever again: TestFoundBalanceLookedForAgain fails.
- The kept-on-refusal case taken out: TestFoundBalanceKeptWhenTheKeyIsRefused
  fails.

Not tried: a relay that really moved to other software.
2026-11-05 14:46:23 +08:00
yetone 2488532257 provider: a relay added by hand finds its balance where relays tell it
The same relay user had added yylx.io by hand: no Balance URL, so no
balance anywhere until they deleted it and imported it from the relay's
site, whose link names the query (小鱼 of yylx.io, WeChat, 11-05).

A provider added by hand, or from a relay's preset, with a key and no
Balance URL, at no host magpie knows a query for, is now asked at its
base's origin: /v1/usage (sub2api, $remaining), then /api/usage/token
(new-api, $data.total_available / 500000), with the key's own auth and
headers, as balanceRead asks. A 200 whose field reads is the query. It is
kept in memory per origins and key (the key hashed), and so is finding
none, for 6h (5 min when the relay can't be reached), so a poll asks once.
Nothing is written to providers.json. The card, Check balance and
`magpie provider show` (BalanceQuery) read the found URL; none found is
no card, and the editor's "No Balance URL to ask".

Never asked: a vendor's or local server's preset host (api.openai.com,
api.anthropic.com, api.deepseek.com…), this computer, opencode.ai and
api.cline.bot, a plan whose windows are its card. The subsystem page has
the row.

Run (mote, go1.26.8):
- go vet ./internal/provider; go test -count=1 ./internal/provider: ok.
- The new tests: a sub2api relay read at $10472.14 with /v1/usage asked
  3 times over the probe, a Balance and a card poll; a new-api relay found
  after /v1/usage's 404; a relay answering HTML 200 everywhere has no
  card and is asked twice in all over two polls; the hosts left alone.

Broken by hand: with the probe taken out of balanceRead, the three
HandAdded tests fail (balance "" false; a card with no balance).

Before this, TestOpenCodeZenSaysItTellsNoBalance caught the probe asking
opencode.ai for OpenCode Go and a custom inference provider; those hosts
are left out now.

Real use (mote, sandbox HOME holding only the owner's yylx.io provider,
copied with its key, removed after): `magpie provider yylx-hand` (no
preset) and `magpie provider yylx` (鱼鱼连线's preset, Global region)
both show "balance $19.97 from https://global.yylx.io/v1/usage
$remaining".

Not tried: a real new-api relay; a new-api relay that routes unknown /v1
paths to its upstream.
2026-11-05 14:19:28 +08:00
yetone e2aaf21f73 gui: a custom provider's Balance URL is asked above its balance token
A relay's user wanting their balance opened the editor and found
"Account balance" asking for a new-api System Access Token or a sub2api
JWT and user id, while the setting that worked (Balance URL
https://app.yylx.io/v1/usage, token left empty) sat at the foot of the
form under More endpoints (小鱼 of yylx.io, WeChat, 11-05).

The Balance URL and Balance field now sit right above Account balance in
Advanced (balSlot), and Advanced opens when a Balance URL is saved. The
token's hint says first to leave it empty, that most relays tell a key's
balance at the Balance URL above (sub2api's …/v1/usage, new-api's
…/api/usage/token), and only then what the token is for. zh, zh-TW, ja
and de have it. In Advanced's narrower column the method picker and URL
wrap, so the URL keeps at least 120px at 420px.

Run (mote, Playwright 1.62.0):
- balance-url-first (new), balance-fix, balance-method and the other
  balance-* files: 186/186 in Chromium and WebKit, at 900 and 420px,
  en/zh/zh-TW/ja/de.
- The whole GUI suite, cut short after 733 tests (it ran for hours
  beside other sessions): red only in account-eye chromium en/ja (#5052)
  and account-weight webkit ja 390 (#4644), both open and in files this
  change doesn't reach.
- i18n-keys: "a plugin's words are its own" red, the same on main
  (#5327).

TestCoreScriptBudget: the hint took the core 494 bytes over its budget;
five comments in the provider editor were cut (573 bytes), so it is 79
under, with no raise.
- go test ./internal/provider ./internal/gui ./internal/cli ./internal/tui
  at the rebased head: ok but internal/gui's TestMainWindowCorners on
  mote's macOS 27 (#3949, open) and the budget before the cut.

Broken by hand: balance-url-first on the old app.js fails at "a saved
Balance URL opens Advanced" (chromium).

Filed: #5336, Advanced is 46px too wide at 420px on main (the Rests
tick's label); the new test checks only the balance rows for it.

Not tried: the real app on Linux (WebKitGTK); no motion or new API here.
2026-11-05 14:19:28 +08:00
yetone 373cab2b08 provider: the Cursor mover's min is 0.2.41 (plugins#706)
cursor 0.2.41 (plugins#706, ooboqoo): a short session whose parent Run
waits on tool results no longer loses that step's usage. The later Run
of the conversation collects it, and it is counted once. Raising the
min makes keepMovedCurrent bring every moved Cursor user to it.

npm view --prefer-online @magpie-community/opencode-cursor-auth version
gave 0.2.41 before the change and again right before this commit.

Run on mote at this change on 294768599 (origin/main, unchanged at
push): go build ./... ok; GOOS=linux and GOOS=windows go vet
./internal/provider ok; go test -timeout 45m ./internal/provider ok
(139.9s). gofmt -l internal/provider is empty.
Not broken by hand: the change is a version string and its note.
Not tried: a real Cursor account through magpie on 0.2.41.
2026-11-05 14:19:12 +08:00
yetone 2947685999 claude: an interactive run's calls keep the conversation they answered when their line comes late
kay20475 on X (magpie 0.1.3005, local magpie -> shared server magpie ->
Claude subscription, interactive bridge): a Claude Code sub-agent's
requests on one account read 99%, 6%, 6%, 99% from the cache; the two 6%
requests were 169.1k each, 35s apart, about 3s long with a short reply.
That is the shape of Claude Code's AgentSummary: every ~30s it sends the
sub-agent's conversation with its last results and "Describe your most
recent action in 3-5 words", while the sub-agent's own run has already
taken those results.

Cause. Such a request finds no run waiting on its calls and should go on
in a branch of the sub-agent's run's session (branch). branch takes it
only when the conversation stored on the call's line (callLine.told)
matches the one before the reply. park stored that only on lines it
already had. The interactive mode streams a reply first and reads its
session lines from the file afterwards (118-162ms after the call). So the
run parked before noteLines had the call's line, and the line came in
with no conversation. The next park then gave it the next request's
conversation. branch returned nil, and every AgentSummary (and every
fork directive) was told the whole conversation in a new Claude Code,
pasted as one text block. A single block can't match the cache beyond
the tools and system prompt, so 6%, and the next summary missed the same
way because its tail differs.

Fix. park also keeps the conversation for each call the client was shown
(r.shown), as a line with no uuid yet. noteLines keeps it when the line
comes, and branch skips lines with no uuid.

Test: TestClaudeForkBranchesOffTheLeadsSession/interactive now has the
fake write the call's session line after the reply's stream, once the
result is handed over, so after the park, which is the real order.
Broken by hand: with this test and the old claude_subscription.go on
mote, it fails ("told it whole", want "branched at line-...").

Run on mote at this tree (base 4cb7159f1): gofmt -l clean; go vet
./internal/gateway on darwin, GOOS=linux and GOOS=windows ok; go test
-timeout 45m ./internal/gateway (679s) ./internal/claudetui
./internal/claudebridge all ok. The fork/side-question/cut tests
-count=3 ok. The full ./... suite and the GUI suite were not run (no
GUI or other-package change).
Rebased on 351844594 (GUI only since 4cb7159f1): go test -count=1 -run
'Claude|Fork|Branch|Subscription' ./internal/gateway ok (77s) on mote.

Not tried: a real Claude Code AgentSummary against a real account. The
reporter's requests are matched by shape only (size, timing, short
reply). Ruled out: the remote-magpie hop. The bridge doesn't key runs on
headers (only anthropic-beta for safeguards), so losing
x-claude-code-session-id can't move a turn off its run. Not fixed here: a
sub-agent loop with no plain reply, told anew in the interactive mode, is
still pasted as one text, so a new run for it reads only tools+system.
2026-11-05 14:05:54 +08:00
yetone 3518445947 gui: the self-remote notes are shorter, the core back under its budget
1826c4bd9 (This magpie, Use it anyway) left the core's scripts at
1,534,182 bytes once rebased over 5b9bfe407, over their 1,533,802
budget (TestCoreScriptBudget red on main). The two notes' English keys,
in app.js and as each language's key, are cut, and a comment goes; the
translations say the same. No budget raised.

Run (Linux WSL, at this tree on origin/main 4cb7159f1):
- go test -tags nogui -run 'Budget|I18n' ./internal/gui: ok.
- remote-self.test.cjs and i18n-*.test.cjs: 23 of 24; the red is
  i18n-keys "a plugin's words are its own" on plugins/usage's "View
  routing", which 73c98ebc2's search_row_archive_test.go says too, not
  this change.

Not tried: the whole GUI suite.
2026-11-05 14:01:09 +08:00
yetone 4cb7159f18 routing: a ChatGPT account whose usage can't be read is asked, not starved
peterpark8527 on Discord: 11 ChatGPT accounts under Use before expiry,
one never used. An account whose wham/usage reading fails (or names no
window, or is held by "When I ask") stayed not known for good:
Use before expiry counted it a fresh week (FreshPace, ~0.6/h), behind
every known week being spent; Smart put it after every known account.
NoteCodexLimits only updated accounts already read, so its replies'
x-codex-* headers never made it known. Its week, once started by
magpie's own turns or warm-up, lapsed unspent. A simulation of 11
accounts over 4 weeks (Pace, Poisson load 30/60/90%) had it at 141 of
~1200 used at 30% load, losing 3406, while every known account was used.

- provider: a reply that tells an unread account's week makes it known
  from that (usedCache.heard), kept over failed readings, until a good
  reading tells it; a 5h window alone still makes nothing up.
- gateway: a Codex account not known, weighed against one known, is
  Learns, like Claude's: asked first once so its reply tells its week,
  and again an hour after its last answer if that told nothing
  (codexAnswered, codexLearnAgain). Of accounts none known the order
  stands, so no week is started before it is needed.
- docs/reference.md: Smart and Use before expiry say so.

Ruled out (by design or not starving): an unstarted Codex week lasts
until its first request, so last is right for it; ties go by decayed
tokens, not a fixed order; a 5h-only account goes by its 5h pace
(ahead); rests are time-bound with probes.

Run:
- wsl-run go test -count=1 -timeout 45m ./internal/gateway
  ./internal/routes ./internal/provider ./internal/middleware: provider,
  routes, middleware ok; gateway had 3 reds (TestAccountProxy,
  TestCodexDrawMovesToNextAccount, TestWeeklyPace's five-hours case):
  accounts none known reordered by answers earlier tests left in
  codexAnswered. Fixed by the known-peer gate above; then wsl-run
  go test -count=1 -timeout 45m ./internal/gateway ./internal/routes:
  ok (809s). The none-known guard's u00 line was added after that run
  and run alone on Windows (win-run -run TestUnknownCodexAccountIsAsked
  ./internal/gateway, with the reds above: ok).
- win-run the two new tests on the old code (73c98ebc2, stand-ins for
  the new names): TestNoteCodexLimitsKnowsAnUnreadAccount and
  TestUnknownCodexAccountIsAsked red.
- win-run go vet ./internal/provider ./internal/gateway ./internal/routes:
  ok; wsl-run go vet of the same: ok. gofmt -l: clean.

Broken by hand: learns' codex case returning false turns
TestUnknownCodexAccountIsAsked red; Allowances not applying heard turns
TestNoteCodexLimitsKnowsAnUnreadAccount red ("the next failed reading
forgot what the reply told"); dropping the known-peer gate turns its
none-known case red ("u01@x.com first, not the first listed").

Not tried: real ChatGPT accounts; the reporter's actual cause is not
confirmed (asked for version, quota, status, plan). Other ways one
account goes unused (90%/98% tiers, rested, model list, group, off)
need their answers. mote was not used: its disk is full.
2026-11-05 13:27:32 +08:00
yetone 87c51cd6bb gui: a tap that comes let go before it is pressed clicks its control once (refeccd)
refeccd on Discord (magpie 0.1.3014, macOS 27.2 26B123): with Tap to click
on, a tap often does nothing, in the tray panel and the window, and almost
always inside a dialog, sheet or menu opened from the active window.

Cause: WebKit's WebViewImpl::nativeMouseEventHandler hands every mouse event
to NSTextInputContext handleEvent:completionHandler: while an editable
element has focus, and before WebKit ba0432f3f5 (2026-11-04, bug 329642,
"Dispatch mouse events to the page in the order sent to the input method",
rdar://102126328) each event was dispatched from its own completion handler.
Some input methods answer out of order, so a tap, whose down and up are a
few ms apart, reaches the page as mouseup then mousedown: no click, :active
stuck, and the next tap's mouseup pairs with the left press and clicks
where the two meet (the "second tap works" of the earlier reports). A
physical press is ~100ms long, so its order holds. Dialogs focus their
first field when they open and menus focus their search box, which is why
dialogs are almost always hit. macOS 27.2's system WebKit predates the fix.
Not proven on refeccd's machine: no real trackpad with an input method was
used; the order is reproduced, not observed there.

Change (app.js, the one capture-phase tap net every control goes through):
a press within 300ms and 12px of a release that had no press, and not let
go within 100ms, is such a tap (tapBack). Its control (the lost-click net's
selector) is clicked once after 100ms, and the trusted click the next
release pairs with it (detail > 0, so never a keyboard click) is dropped.
A release within the 100ms means the press was in order after all: nothing
is clicked by the page and the browser's click is kept. The segs press
tracker and the lost-click net ignore a tapBack press. Comments in app.js
were condensed to keep the core script budget (main was already 380 bytes
over it, #4526's test); no budget raised.

Not covered: an inverted tap on a dialog's backdrop doesn't close it
(backdropClick pairs pointerdown/up); nothing is clicked for it.

Run (mote, at this tree rebased on origin/main 9d143eaca):
- internal/gui/tests/tap-inverted.test.cjs (new): Chromium and WebKit, en,
  zh, zh-TW, ja, de, 1100 and 390 wide: 22/22 pass. Playwright's
  mouse.up then mouse.down gives the page that order with trusted events.
- The old app.js with the new test: 22/22 red at the first inverted tap
  (0 clicks).
- Broken by hand: the dropped paired click off -> red at the second tap
  (0 clicks where 1 expected; the click landed on .segs); the 100ms
  in-order cancel off -> red, a no-control press after a stray release
  lost its click.
- tap-*, click-scroll, segs-*, modal-*, menu-*, dialog-*, library-mcp-*,
  tray-cell-click, i18n-* GUI files; go test -run TestCoreScriptBudget
  ./internal/gui: 437 pass, 25 red. Every red is the same at origin/main
  9d143eaca, run there alone on mote (30 pass, 24 red in the four files;
  tray-cell-click chromium zh passed there once, red 4 of 4 in #5215):
  segs-press-redraw "clicks its new self once" (16, #4566),
  menu-input-scroll (4, #3402), tray-cell-click (4, #5215), i18n-keys
  "a plugin's words are its own" (1, filed as #5327).
  TestCoreScriptBudget ok.
- go test ./internal/gui: TestMainWindowCorners/macOS_26_SDK red, #3949
  (macOS 27, AppKit), not touched here.

Not tried: a real trackpad with Tap to click and a third-party input method
(Baidu, Sogou, WeType), the Wails app itself, the tray panel's NSPanel.
2026-11-05 13:26:17 +08:00
yetone 9d143eacab uninstall: install.sh --uninstall disconnects every agent first, a deleted magpie too
whimsical_wolf_15477 (Discord): after uninstalling magpie, Codex didn't go
back to its own config. `install.sh --uninstall` deleted the magpie command
and app and left every agent wired to a gateway that no longer runs: Codex
kept openai_base_url (or model_provider = "magpie" and model_catalog_json)
pointing at 127.0.0.1. A magpie deleted by hand undid nothing either, and
`--purge` refused with no magpie left to run.

- `magpie uninstall --keep-data` (uninstall.KeepData): every agent
  disconnected and its own values put back from stash.json, the service,
  autostart, shortcut, scheme and helpers removed, magpie's settings,
  providers and usage kept.
- install.sh --uninstall runs `magpie uninstall --yes --keep-data` (--purge:
  `--yes`) before deleting anything, and stops if it fails. With no magpie
  of its own (deleted by hand) but magpie's config left, it fetches the
  newest release into a temporary folder, checks its sha256, runs that, and
  deletes it after. An older magpie without --keep-data gets the newest one
  for this too. A magpie on PATH that the script didn't install is left to
  its own `magpie uninstall`, and said so.
- MAGPIE_UNINSTALL_SCRIPT=1: under the script magpie doesn't ask to delete
  a path that the script deletes next.
- docs (en/zh/ja start.html #uninstall) and READMEs: what the line does,
  that it works for a magpie already deleted, and Codex's lines by hand.

Run (WSL magpie-desktop; mote's disk is full, nothing run or deleted there):
- go test -tags nogui -run "Uninstall|Help|TestKeepData" ./internal/cli/
  ./internal/uninstall/: ok. node --test site/install.test.mjs: all pass.
- The new install tests against the old install.sh: 5 red. Broken by hand
  (--keep-data case removed, Data() back in KeepData): TestUninstallKeepData
  and TestKeepData red.
- Real e2e: magpie built from this tree, Codex wired in a sandbox HOME
  (not signed in, and ChatGPT signed in), magpie installed and deleted by
  hand; install.sh --uninstall with a local feed. config.toml's diff before
  wiring vs after is the [model_providers.magpie] table only (kept on
  purpose for threads started on magpie); model, effort, openai_base_url,
  model_provider and model_catalog_json are the user's again; settings kept.
- gofmt -l clean; go vet GOOS=windows/darwin/linux (nogui) for the two
  packages; sh -n and dash -n install.sh.

Not tried: macOS's zip path for a deleted magpie run for real (tests cover
it with fakes), Termux, Windows (no install.sh there; docs say download
magpie again and use Settings › Uninstall). The full internal/cli package
timed out at 10m under WSL load in providers_unreadable_cli_test (not
touched here); see the full suite record.
2026-11-05 12:52:46 +08:00
yetone 73c98ebc20 gateway: a search API's or plan service's ask is routed and archived (axelburks)
axelburks on Discord: when magpie searches for a model through a search
API, the Routing page doesn't say which API answered, and Usage →
Requests lists the row but has no request archive, so the request and
response sent to the API can't be seen.

A model's search (searchWith) was already routed and archived. A search
API's ask (askSearchAPIKeys, a plugin's search hook, a signed-in search
API) and a plan's own search service (Kimi Code, GLM Coding Plan,
WorkBuddy, Codex's searchBy, and searchBy's Kimi branch, which wrote no
row at all before) only wrote a usage row.

Now every ask that writes a row goes through keepSearch
(search_archive.go): a done web_search route, agent magpie, For the
agent searched for, the API's name as model and its host as provider,
seated on the masked key or account; a Recent call with ring-cut
bodies; and with the request archive on, archiveOwn of the exchange as
sent. The row gets RouteID and Archive, which the Requests tab already
opens. Each ask has a searchWire in its context, filled where it is sent
(tapSearch tees the answer as read; the last exchange stands, so GLM's
MCP tools/call is the one kept). A plugin's search is noted as what
magpie handed the hook (key masked) and what came back (PLUGIN method).
The key is replaced by MaskSearchKey in path, query, headers and both
bodies before anything is kept; the archive's own scrub runs on top.
Bodies are kept up to RequestArchiveMaxMB (longer marked cut); archive
off keeps nothing on disk, the route and Recent call stay.

Run (mote's disk filled mid-work, see below; the rest on WSL
magpie-desktop via wsl-run):
- mote-run: go test -run 'Search|Archive' ./internal/gateway ok; GUI
  usage-ledger-search, routing-side-calls, request-archive-usage in
  chromium+webkit, every language and width: 38 pass.
- wsl-run: go test -run 'Search|Archive' ./internal/gateway ok; go vet
  ./internal/gateway ok; GOOS=windows go vet ./internal/gateway
  ./internal/gui ok; GOOS=darwin CGO_ENABLED=0 go vet ./internal/gateway
  ok; GUI usage-ledger-search, routing-side-calls, request-archive-usage,
  search-instead, search-mcp in both engines: 68 pass, 0 fail.
- gofmt -l clean.

Broken by hand: keepSearch's call commented out turns all five new
gateway tests red; taken()'s key masking turned off turns
TestSearchAPIAskIsRoutedAndArchived and TestSearchAPIKeyInQueryNotArchived
red. TestSearchRowKeepsRouteAndArchive (internal/gui) is a guard that the
row's RouteID and Archive reach /api/usage/requests; it passed on the
old code too.

Not tried: real Tavily/Brave/Kimi/GLM/WorkBuddy/Codex accounts (httptest
stubs only); Linux go vet of internal/gui (WSL lacks gtk4/webkitgtk);
web_fetch (search_fetch.go) and a vendor's own search (search_native.go),
which magpie doesn't send, are unchanged. Full suite runs after the push.
No GUI asset, API call or i18n string changed.
2026-11-05 12:40:35 +08:00
yetone 1826c4bd99 providers: a Remote magpie that is this magpie says so and is left out, unless kept (hanslin1666)
B uses A through a Remote magpie provider, and sync carries that
provider to A, where it points at A. Each of its models was one of A's
own, listed again beside it and taken by A's found groups, and a request
through it passed through A's gateway twice.

A fetch of a Remote magpie's list now reads its models' magpie_via: when
the magpie that listed them (the last entry) is this magpie's own
catalog.Self, remote-self.json keeps the provider id and the address it
answered at (noteSelf). Another lister, or a list with no via, takes
the record away; an empty list or a failed fetch changes nothing; a
provider moved to another address is not self until a fetch there says
so. The file is this computer's own, never in a backup or sync.

Such a provider is left out (SelfLeftOut in On, SwitchedOff and
remoteMagpies): not in /v1/models, the catalog or a found group. A
request naming one of its models, an agent's pick synced from B, is
served here with the remote's id taken off (ThroughSelf in Resolve and
ResolveRoute), once through the gateway. A 404 for it says why and how
to keep it.

The Providers row shows "This magpie" (greyed while left out), with the
reason as its title; the editor has a note and a "Use it anyway" tick
(KeepSelf, POST /api/provider/keepself). KeepSelf belongs to the user
and to this computer: Mirror and Restore keep the local value (false for
a provider new here), davsync's hashes blank it, and a provider save
keeps it. Strings in en, zh, zh-TW, ja, de.

Docs: providers-accounts.md (two magpies row), sync-backup.md (what
stays on each computer).

Run at this tree on origin/main 4e85cac01:
- gofmt -l: nothing. app.js 1,309,132 bytes (budget 1,316,874).
- mote: go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet of
  provider, gateway, gui, davsync, catalog: ok.
- mote: go test catalog, davsync ok; gui red only in
  TestMainWindowCorners/macOS_26_SDK (#3949, macOS 27); provider and
  gateway did not build there (mote's disk full, "no space left on
  device"), so they were run on:
- Linux (WSL magpie-desktop): go test -tags nogui provider, gateway,
  gui, davsync: all ok.
- Windows (xiaomi-gpu): go test -run 'RemoteSelf|KeepSelf|RemoteMagpie|
  Mirror|KeepLogin' provider, gateway, davsync: ok.
- mote: remote-self.test.cjs 16 of 16 (chromium and webkit, 1100 and
  420, en zh ja de), before the rebase; the rebase touched no line of it.

Broken by hand, each red, then restored:
- noteSelf a no-op: TestRemoteSelfRecord and
  TestRemoteMagpieThatIsThisOneIsLeftOut red.
- ThroughSelf a no-op: the gateway test red (404 for rem/own/m1).
- On() without SelfLeftOut: the gateway test red (listed, 2 passes).
- davsync hashes without the KeepSelf blank: TestKeepSelfIsNoChange red.
- Mirror without keeping KeepSelf: TestMirrorKeepsKeepSelf red.
- The row's badge removed: remote-self.test.cjs red (chromium 1100 en).
- The tick's onchange a no-op: remote-self.test.cjs red (webkit 420 zh).

Not tried: two real computers syncing each other (the case is built in
one process: the gateway test's Remote magpie is its own gateway);
the Linux and Windows apps' webviews; the whole GUI suite (mote's disk is full);
remote-self.test.cjs again after the rebase.
2026-11-05 12:37:30 +08:00
yetone 583fe70751 provider: WorkBuddy's mover min is 0.2.21, whose sign-in page shows 企业微信 (shenyebuwu)
shenyebuwu on Discord signs in to WorkBuddy with 企业微信 (WeCom), and the
plugin's sign-in page had no WeCom entry. The plugin opened the login
page with version=2.0.0; WorkBuddy's China login page hides WeCom below
5.8.0. Plugin 0.2.21 (magpie-community/plugins a90b7aa4) opens it at the
desktop app's version, as WorkBuddy desktop does; keepMovedCurrent now
brings every moved user to it.

Run at this head (mote): gofmt -l internal/provider empty; go test
-timeout 45m ./internal/provider ok. npm view --prefer-online shows
@magpie-community/opencode-workbuddy-auth 0.2.21.
Not tried: a real WeCom sign-in to the end.
2026-11-05 12:32:05 +08:00
yetone 5b9bfe407c gui: the tray panel's Allowances tab folds what has nothing left behind "{n} at 0" (runking on Discord)
.runking on Discord: "额度面板那里能不能那些额度是 0 的可以隐藏掉啊 现在我一堆是 0 的".

What counts as at 0 (quotaAtZero): a fresh reading whose every window is used up (or held by another), and whose balance, if any, is 0 or below ("¥0.00", "-$1.20", "$-1.20", "0 credits"). A balance card folds on its own; a vendor's group folds only when every account in it is at 0. Never folded: a failed reading, an old one (asOf), a percent balance part, a text or unlimited window, a window used part way, a Codex account with credits on, reset credits, a check-in, and a card a menu bar cell opened.

Folded cards are not hidden silently: the foot gets "{n} at 0" (pq-more, beside Arrange); a click shows them and the button reads "Fold the ones at 0". The choice is kept in localStorage (magpie.panelZeroOpen). The click doesn't move the page and keeps the keyboard on the button. The Usage page and routing are unchanged. Strings in en, zh, zh-TW, ja, de. No new API call, no CSS.

Run on mote (mote-run):
- node --test internal/gui/tests/panel-zero-fold.test.cjs: 10/10 (chromium and webkit; en, zh, zh-TW, ja, de at 440px).
- The panel-*, quota-*, i18n-*, gui-zh-tw and click-scroll GUI files: 564 pass, 1 fail ("a plugin's words are its own": my first title said "Accounts and keys", the routing plugin's word; reworded). After that: i18n-keys, gui-zh-tw and panel-zero-fold 17/17.
- go test ./internal/gui -count=1: only TestMainWindowCorners/macOS_26_SDK is red, the macOS 27 red already filed as #3949 (AppKit, not touched here). TestCoreScriptBudget and TestAppScriptBudget pass; no budget raised.

Broken by hand:
- The test against origin/main's app.js and i18n.js: 10/10 red ("claude|a@b.c is folded").
- Dropping the asOf and creditsOn guards: chromium 5/5 red ("kimi stays in sight").

Not tried: the real tray panel on macOS, Windows or Linux with real accounts; the whole GUI suite (only the files above; no API call was added).
2026-11-05 12:13:57 +08:00
yetone c2b8814e75 gui: the tray panel keeps the latest height it asked for, its fits sent one at a time (robot_yz on X)
robot_yz on X (11-05, v0.1.3005): the menu-bar panel had become short,
and the Allowances tab's one card, Zhipu GLM (max, rings 5h 7%, 7d 18%,
MCP 1%, a curve), was cut off by the foot.

Cause: Wails v3 serves each request from the page on a goroutine of its
own (application.go, `go a.handleWebViewRequest(request)`), so two
window/fit requests sent together reach fitPanel in either order. In a
real WKWebView under Wails on mote, 69 of 400 pairs of fetches sent
together reached the handler the wrong way round. When an older, smaller
height lands last, it stays: fit.last in app.js and the panel's own
panelHeight both take the newer height as done, so nothing asks again
until the content's height changes. Since 2ba044aa6 (v0.1.2913) every
Mac panel open runs load(true), and renderAgents and renderPanelQuota
each fit in the same task. A boot asks 122, 306, 566 and 291 within
about 120ms (setPanelTab, renderAgentsLoading, the routing panel, its
poll), which is likely why it showed after the update. fit(), panelFrame,
panelRoom and fitPanel haven't changed since 10-20/10-26, and go.mod's
Wails hasn't changed either.

Fix: fit() sends through fitSend. A fit asked while one is on its way
waits for it, and only the latest of those goes next, so the panel always
ends at the height asked last.

Test: panel-fit-order.test.cjs sets up panel mode with the reporter's
case: one Zhipu GLM allowance with its 5h, 7d and MCP windows and the 5h
curve, 15 agents, and the Allowances tab. The fake panel holds the first
fit until the page has drawn the card and stopped asking. The test
asserts that the panel ends at the last height asked, that the card's
bottom is inside the view, and that the tab doesn't overflow.
Chromium and WebKit, en, zh, zh-TW, ja and de.

Rebased on 4e85cac01 and run again on mote at this head: go test ./internal/gui -run Budget ok; panel-fit-order, account-models-available and i18n-keys, 94 pass, 0 fail (on ea3d1c62e: every panel-* file too, 300 pass).

First run on mote (mote-run), at base 0e55a7593:
- panel-fit-order.test.cjs: 10 of 10 pass.
- Every panel-*.test.cjs and quota-*.test.cjs file plus i18n-keys.test.cjs
  (47 files, --test-concurrency=2): 534 tests, 534 pass, 0 fail.
- go test -timeout 45m ./internal/gui: FAIL, one red,
  TestMainWindowCorners/macOS_26_SDK ("a toolbar doesn't change the
  corners in this design, yet the main window's was taken off"). The
  same test alone on origin/main 2260390a0 (fetched just before) fails
  the same way. It is #3949 (macOS 27 on mote), and this change touches
  no Go. Every other test in the package passed.

Broken by hand: the new test run against origin/main's assets
(git archive of internal/gui/assets) is 0 of 10, each one "the panel
ended at an older height than the page asked for last (asked 122 306
566 291, applied 306 566 291 122)". The panel was left at 220 and the
card was cut off.

Not tried: the real tray panel by hand on a Mac with this build. The
reporter's own overlapping fits weren't seen either; the reorder was
measured with Wails and WKWebView on mote, not on their machine.
2026-11-05 11:59:50 +08:00
yetone 4e85cac01d agent: OpenCode installs as OpenCode 2 (@opencode/cli, opencode.ai/v2/install) (math_milian)
math_milian on Discord: magpie's npm command for OpenCode installs
OpenCode 1, and OpenCode 2 isn't installed that way. On 2026-11-05
opencode-ai's latest is 1.19.5 and it has no 2.x; OpenCode 2 is
@opencode/cli (2.2.5, anomalyco/opencode's README), and
opencode.ai/install refuses a 2.x ("not an OpenCode 1 release") and
points to opencode.ai/v2/install.

- Install: opencode.ai/v2/install on a Mac or Linux, then
  npm install -g --allow-scripts=@opencode/cli @opencode/cli. Air's
  "OpenCode isn't installed" notice says the same, in every language.
- Update: an install from either package is updated within it (npm,
  bun, pnpm by where it sits; brew's opencode or anomalyco/tap's
  opencode-v2). An installer copy in ~/.opencode/bin is offered its
  own line's newest: OpenCode 2 @opencode/cli's, OpenCode 1
  opencode-ai's, since OpenCode 1's opencode upgrade runs the v1-only
  installer. An unreadable version promises none.
- An existing opencode-ai install isn't moved to OpenCode 2: its
  config differs, and npm needs --force over the other package's bin.

Run (mote): gofmt -l, go vet ./internal/agent, GOOS=linux/windows go
vet, go test ./internal/agent -run 'Install|UpdateCLI|HowInstalled|Mend|
Npm|Bun|Pnpm|Shim|Scripts|CLI|OpenCode|Air' ok; node --test i18n-keys,
i18n-en-no-cjk, agent-air-own, agent-notice-lang, agent-cli-missing: 82
pass. Real, sandbox HOME on mote: curl -fsSL opencode.ai/v2/install |
bash gave ~/.opencode/bin/opencode and opencode2, "opencode v2.2.5";
`opencode upgrade 2.2.4` from there went to v2.2.4 (magpie's target
form); npm 10.9.4 and 11.21.2 with magpie's exact command gave v2.2.5,
opencode2 too; `opencode acp` is in 2.2.5 for Air.
Broken by hand: opencode-ai first in npm turns TestInstallCommands red;
without the line hook TestUpdateCLIOpenCodeKeepsItsLine/1.19.4 is
offered 2.2.5 and TestUpdateCLIOpenCodeTakesVersion goes red.
Not tried: Windows npm install for real, Homebrew's opencode-v2 tap,
moving a real opencode-ai user to OpenCode 2.
2026-11-05 11:50:13 +08:00
yetone 06808ad308 agent: an agent's npm package that needs its install script gets it run on npm 12, bun and pnpm
npm 12 runs a package's install script only when told to
(--allow-scripts=<pkg>), and bun (--trust) and pnpm 10 (--allow-build)
do the same. A package whose postinstall puts its binary in place then
installs a stub: @opencode/cli 2.2.5 from npm 12.2.2 or bun 1.4.2 without
the flag prints "@opencode/cli's postinstall script was not run" and
exits 1 (mote, sandbox HOME). OpenCode's own v2 updater passes the same
flags.

cliSpec.scripts marks the agents whose npm package has an install
script: `npm view <pkg> scripts` on 2026-11-05 named one for claude,
cline, crush, deveco, mothx, omo, opencode and snow, and none for the
rest. Their install command, their npm/bun/pnpm update and the mend
hint now carry the manager's flag. npm 10 and 11 run scripts anyway and
take --allow-scripts as an unknown config.

Run (mote): gofmt -l, go vet ./internal/agent, go test ./internal/agent
-run 'Install|UpdateCLI|HowInstalled|Mend|Npm|Bun|Pnpm|Shim|Scripts|CLI|
OpenCode|Air' ok, and GOOS=linux/windows go vet ok. Real: on mote, npm
10.9.4, 11.21.2 and 12.2.2 with --allow-scripts=@opencode/cli each gave
a working opencode v2.2.5; npm 12 without it and bun without --trust the
stub; bun with --trust a working one.
Broken by hand: withScripts never adding the flag turns
TestInstallLetsScriptsRun, TestUpdateLetsScriptsRun and
TestUpdateCLIChecksItRuns red.
Not tried: pnpm and yarn for real (mote has neither), the other seven
agents' packages on npm 12.
2026-11-05 11:50:13 +08:00
yetone 3587bf70e2 providers: a plugin account's Select all available ticks its own list; zcode min 0.1.51 (young02036)
young02036 on Discord: their two ZCode accounts in magpie, one with no
GLM Coding Plan whose Start Plan holds glm-5.3-flash and one subscribed
whose gift shows as glm-5.3-flash-trial, failed while the ZCode app
worked; picking each account's usable models by hand worked. They also
said ticking the available models by default didn't work.

- zcode mover min 0.1.51: the plugin now lists for a gift-only account
  only the models its Start Plan balance names, as ZCode 3.17.2 offers
  it, not every model of the Start Plan config, so routing stops sending
  GLM-5.2 or GLM-5-Turbo to an account that holds only GLM-5.3-Flash
  (plugins c96d04bb, npm 0.1.51 checked with --prefer-online).
- Select all available in an account's model picker ticked every model
  shown for a signed-in account. provider/keylisted now answers for a
  plugin's account with the models its plugin lists for that account
  (plugin.Account.Models, by the provider's listed ids), and the picker
  asks it for accounts as for keys. An account the plugin keeps no list
  for (one account has them all) or doesn't have is unknown, which still
  ticks every model shown; a non-plugin account is unchanged in effect.
  The account title says so, translated in zh, zh-TW, ja and de.

Run on mote:
- go test ./internal/provider -run 'TestKeyListed|TestPluginAccountModels':
  TestKeyListedIsAPluginAccountsOwnList red on the old code (the key
  account's list: [], want [fake-1]), green after.
- node --test account-models-available.test.cjs (chromium + webkit,
  en zh zh-TW ja de, 900 and 420px): with the old app.js the new plugin
  account case and the Codex case (now asks keylisted) are red; green
  after. i18n-keys green.
- go test ./internal/gui -run Budget, go test ./internal/provider (whole
  package), GOOS=windows go vet of both packages, GOOS=linux go vet of
  internal/provider (internal/gui's wails needs cgo for a Linux vet from
  mac), gofmt.
Not tried: a real ZCode account (none available); whether the 3012s
young02036 saw came from these requests is not proven; the whole GUI
suite (only this picker's file and i18n-keys).
2026-11-05 11:46:26 +08:00
yetone ea3d1c62e7 gateway, codexcat: Codex's image detail "original" goes as "high" to a relay's Responses API, and only DeepSeek's own API is told it takes it (qiu_eth)
qiu_eth on Discord, v0.1.2885: the Codex App on
opencode-go/deepseek-v4.1-flash got 400 "invalid image detail" / "this
feature is not yet supported by atlas" for every screenshot.

Where the values come from:
- input_modalities ["text","image"]: models.dev lists
  deepseek-v4.1-flash under opencode-go with input text and image, and
  841326709 (v0.1.2343) counts Go's media types as images. Go's own list
  says the same, so this stays.
- supports_image_detail_original true: codexcat set it on every model
  named deepseek-* on any provider (8acb0d3a7), copied from DeepSeek's
  own Codex setup for api.deepseek.com. A vendor rule had not been scoped
  to the vendor. Go serves this model on its Responses API (no npm in
  models.dev, so every API is open, 7c4a5d114), and Responses to
  Responses went as it came, so "original" reached Go and was refused.

The fix has two parts:
- codexcat sets supports_image_detail_original only for a model of
  DeepSeek's own provider (deepseek/…). The rest of DeepSeek's setup
  (shell_command, verbosity, summary, agents v2) still applies to every
  DeepSeek model.
- The gateway sends an input_image's detail "original" as "high" to any
  Responses API but OpenAI's (api.openai.com, chatgpt.com, Azure),
  DeepSeek's (api.deepseek.com) and a remote magpie, which decides for
  its own upstream. That covers the class: a Codex that already has the
  old catalog, a relay's GPT, and any other model whose catalog says
  original. Chat already did this (chatDetail). A body without "original"
  isn't parsed.

Checked against the class: other opencode-go models with images (Kimi,
GLM, MiniMax, Qwen) never had the flag, since it was DeepSeek-only, but
the gateway now covers them too. Nothing after v0.1.2885 had changed
this.

Run on mote (mote-run):
- go test ./internal/gateway ./internal/codexcat ./internal/catalog
  -count=1 -timeout 45m: all three ok (gateway 847s).
- gofmt -l: clean. GOOS=linux and GOOS=windows go vet of both packages: ok.

Broken by hand:
- With the gateway's rewrite turned off, TestOriginalDetailHighOnARelay
  is red: details ["original" "low" "original"], want ["high" "low"
  "high"].
- With codexcat back to `e.DetailOriginal = m.Images`,
  TestCodexCatalogDeepSeekAsDeepSeekSays is red:
  opencode-go/deepseek-v4.1-flash has supports_image_detail_original
  true.

Not tried: a real OpenCode Go request. The only Go key here answers 401
api_key_expired, so Go's 400 is the reporter's word, not reproduced,
and that Go takes "high" rests on the Responses spec, not on a run.
2026-11-05 11:45:44 +08:00
yetone 116f23c784 plugins: an agent plugin whose agent isn't on this computer says so, not "Adds Kimi to Agents" (zzZ)
zzZ (innerscw) on Discord: Kimi no longer shows in Agents, even with the
plugin installed. Nothing in magpie regressed. Kimi Code CLI (built-in
`kimi`, ~/.kimi-code) is found on main: installed with Kimi's own
install.sh in a sandbox HOME on mote, it is listed. The plugin is
@magpie-community/agent-kimi-desktop. Its agent's folder,
~/.config/magpie-kimi, is made by its adapter only once Kimi desktop's
Work runtime has written its config.json (bootstrap() in adapter.mjs).
Until then Detected() is false, so Agents lists no row for it. All the
while, the Plugins page said "Adds Kimi to Agents".

/api/plugins's agent now has missing, looks (where magpie looks, ~ for
home) and notice (the plugin's own notice) when the agent isn't found.
The row's line says "Kimi isn't in Agents: magpie doesn't find it in
~/.config/magpie-kimi", followed by the plugin's notice ("请先打开 Kimi…").
It wraps, in muted colour, since it is not a failure. In zh, zh-TW, ja
and de as well. A found agent's row is unchanged, as are fixtures with
no `missing`.

Run on mote (mote-run):
- go test ./internal/gui -run 'TestPluginAgent|TestCoreScriptBudget|I18n|Words': ok.
- node --test plugin-agent, i18n-keys, i18n-en-no-cjk: 30 pass, Chromium
  and WebKit, en/zh/zh-TW/ja/de, at 980 and 420.
- go test ./internal/gui ./internal/agent -count=1 -timeout 45m:
  internal/agent ok; internal/gui red only in TestMainWindowCorners
  (macOS 27, #3949).
- node --test every *plugin*.test.cjs: 1126 of 1130 pass. The 4 reds are
  plugin-move-unserved's "Try again takes the models unticked", red the
  same on origin/main 47d583939 run alone on mote (#4410).
- The core script budget: 1,530,183 + this change, under 1,533,802, with
  no raise.

Broken by hand:
- With pluginAgentOf back to the old code, TestPluginAgentMissingSaysSo is
  red ("Missing:false Looks: Notice:").
- With plugins.js back to the old code, plugin-agent is red with "Adds Kimi
  to Agents" / "把 Kimi 加到 Agent 页".

Not tried: a real Kimi desktop install. It is on neither this Mac nor mote.
2026-11-05 11:45:44 +08:00
yetone 10f1e97883 search: a GLM Coding Plan searches its own models with the plan's web search MCP
young02036 on Discord asked for the GLM Coding Plan's Web Search MCP in
magpie's web search. The plan's key is given for that server, so magpie
now asks it with the provider's own key, with nothing to set up: a
Streamable HTTP session at <host>/api/mcp/web_search_prime/mcp
(open.bigmodel.cn or api.z.ai, docs.bigmodel.cn/cn/coding-plan/mcp/
search-mcp-server and docs.z.ai/devpack/mcp/search-mcp-server), the key
as a Bearer, initialize, one tools/call of webSearchPrime with
{"search_query"}, then the session's DELETE.

- provider.ZhipuCodingSearch: only a provider or key on the plan's
  /api/coding/paas/v4 (Zhipu's or Z.ai's host, or the zhipu/zai preset).
  A pay-as-you-go key isn't served by the server and never asks it.
  ZhipuSearches reads p.Keys itself, since KeysOn is counted per list and
  searchesOwn runs on every request. ZhipuSearchKeys lists the plan's
  keys, which are asked in turn.
- searchesOwn/ownSearch: the plan's own models search there first, as
  with Kimi Code and WorkBuddy, and fall to magpie's searcher and the
  search APIs when it fails. This happens only while Settings names no
  searcher (glmSearches): a searcher the user named still searches for
  every model, which is a value the user set.
- It is not offered as a searcher for other providers' models. A plan
  with the Responses base (/api/v1) already searches natively there
  (searchHosts, #660), and making it a no-model service would change the
  searcher those users have now.
- The reply's text is read as a list of results, a list in a JSON
  string, or a list under search_result/results/items/data. isError, or
  words with no results, is an error with the key masked. The query is
  masked as Settings > Privacy says (maskedQuery). Each ask is a request
  log row (logOwnSearch).
- No GUI change: the setting has no switch, the same as WorkBuddy's.
- docs/subsystems/gateway-routing.md has a section on it, and the
  searchesOwn lists there and in plugin-runtime.md name it.

Run (mote, at this tree):
- go test -count=1 ./internal/provider ./internal/settings
- go test -count=1 -run 'Search|GLM|Zhipu|Kimi|LoopGuard|Docs|Guard|WorkBuddy'
  ./internal/gateway: ok
- GOOS=linux and GOOS=windows go vet ./internal/gateway ./internal/provider:
  ok
- gofmt -l: clean

The tests use a fake server only and never reach the network:
- TestGLMCodingPlanSearchesForItsModels: Claude Code's literal WebSearch
  request to a plan's model. The fake gives an event-stream reply with
  a progress notification before the result, and a double-stringified
  result. Then a refusal, an unnamed versus a named searcher beside a
  search API, and a pay-as-you-go key.
- TestReadGLMSearch: each reply shape, and prose.
- TestZhipuCodingSearchAddress: hosts, presets, a plan key beside a
  pay-as-you-go one, a key that's off.

Broken by hand:
- With the old searchesOwn/ownSearch, TestGLMCodingPlanSearchesForItsModels
  is red: the model had no search, 400 "no search tool".
- With glmSearches ignoring a named searcher, the test is red at the
  named-searcher step: the MCP was asked and the named searcher wasn't.

Not tried:
- No real GLM Coding Plan key was available, so nothing was sent to the
  real open.bigmodel.cn or api.z.ai server. The docs give neither the
  tool's argument names nor its reply's shape. search_query and the
  result fields come from Zhipu's Web Search API and a third-party npm
  wrapper (web-search-zaimcp 0.1.2). If the real reply differs, a search
  falls to magpie's other searcher or the search APIs and says why.
- The plan's MCP quota, and how a spent quota is worded.
- A GUI hint in Settings > Web search.
2026-11-05 11:44:31 +08:00
yetone 2260390a01 gateway: a Gemini thought signature goes back only to the provider that gave it
mimi001234 on Discord: Pi (openai-completions) on auto/gemini-4-argon, a
group of google-vertex and google-aistudio-paid. Vertex AI served turns
1 to 14 and signed its calls; on turn 15 it answered 429, the group moved
to AI Studio, and magpie replayed Vertex AI's signatures from
gemini-signatures/. AI Studio answered every try with 400 "Corrupted
thought signature." A signature is the issuing backend's, and only it
takes one.

- The provider that gave a signature is noted beside it,
  gemini-signatures/<key>.by (noteSigner, written through temp and
  rename), wherever a reply is read: decoderFor (every translated path:
  Chat, Anthropic and Responses clients, plugins, search, continuations)
  and sigTidy (a Chat relay, and a Gemini client's reply relayed as it
  came, now only read, in native mode).
- Every request is fitted to its provider: ownSignatures in
  forwardTranslated, chatCallSignatures and geminiBodySignatures in
  passthrough. Another provider's signature goes as Google's documented
  skip_thought_signature_validator on a call, and not at all on text. A
  signature of no known provider (ids from before this change, a note
  that couldn't be written) goes as before.
- A 400 "Invalid/Corrupted thought signature" (signatureRefused) is asked
  again once without signatures at any upstream Gemini's signatures
  reach (signaturesReach), relayed too, not only Vertex AI translated;
  it rests no account (restAfterMarked) and lets a group go on to its
  next member (shapeRefused).

The signer is the provider id, not the account: two accounts of one
provider share signatures as before.

Run on mote (mote-run), the targeted run and vets at this change on origin/main 0e55a7593:
- go test ./internal/gateway -run 'Signature|Signer|Vertex|Gemini|Corrupted': ok
- go test -timeout 45m ./internal/gateway: ok (876s), at this change on
  bf60ea596; the only commit since, 47d583939, touches internal/library
- gofmt -l internal/: clean; go vet ./...; GOOS=linux go vet -tags nogui
  ./...; GOOS=windows go vet ./...; go build ./...: ok

Red on the old code (origin/main 0e55a7593 with the new test file):
TestSignatureGoesOnlyToItsSigner (turn 3: 400 "AI Studio: ... Corrupted
thought signature."), TestCorruptedSignatureTriedWithout and
TestCorruptedSignatureNotTheAccount (rested "backoff" 60s).
Broken by hand on the new code:
- chatCallSignatures without the foreignSignature check:
  TestSignatureGoesOnlyToItsSigner red (AI Studio asked twice: refused,
  then the retry).
- ownSignatures in forwardTranslated commented out:
  TestSignatureGoesOnlyToItsSignerTranslated red the same way.
- the passthrough retry turned off: TestCorruptedSignatureTriedWithout
  red with the 400.

Not tried: real Vertex AI and AI Studio accounts; a Gemini client's
request relayed to Vertex AI end to end (TestGeminiBodyKeepsOnlyItsOwn
covers the body and the noting only); Code Assist relays, whose replies
are not noted, so their signatures count as of no known provider.
2026-11-05 11:42:53 +08:00