Commit Graph
1596 Commits
Author SHA1 Message Date
yetone a4916aec10 gateway: a Codex websocket turn sent to a Responses relay leaves Lite's client_metadata marker behind (#4853)
A Codex title request through a Responses relay (CPA) failed with
"X-OpenAI-Internal-Codex-Responses-Lite requires reasoning.context to be
all_turns". fromLite took Lite's shape off for a backend that isn't
OpenAI's: it lifted additional_tools, left reasoning.context out and
didn't send the Lite header on. But over a websocket Codex says it is
Lite a second way, in client_metadata
(ws_request_header_x_openai_internal_codex_responses_lite: "true",
codex-rs client.rs build_ws_client_metadata). magpie left that marker
in, so the relay still read the request as Lite and passed it to the
ChatGPT backend without the context it had been told to expect.

fromLite now also drops that one client_metadata key
(withoutLiteMetadata). Every other client_metadata entry, the
instructions and the identity line go as Codex sent them.

Reported by ChangQiu on Discord and filed as #4853 by ZyphrZero. The
withoutLiteMetadata patch and its two tests are ported from
ZyphrZero's fork commit 7f67c732. TestCodexSocketLiteTurnLeavesLiteForARelay
is new: it sends #4853's title request through passthrough to a fake
relay and checks that the marker, the context and the header are all gone.

Run on mote at this head:
- the three new tests plus TestLiteSubagentLeavesLite and the
  additional_tools tests: ok
- go test -timeout 45m ./internal/gateway: one red,
  TestCodexPoolSaysTheClientsVersion (#4807). It passes 3/3 alone here
  and on origin/main.
- go vet ./internal/gateway with GOOS=linux, windows and darwin: clean.
  gofmt -l: clean.
Broken by hand: with withoutLiteMetadata stubbed to return its input,
all three new tests went red.
Not tried: a real CPA, or a real Codex websocket session through magpie.
2026-11-02 14:06:01 +08:00
yetone 225d521cde minimax: Desktop keeps its own model pick, so magpie says to pick once in its menu
教父 on Discord (MiniMax Code 3.1.10, magpie v0.1.2629 and v0.1.2679):
MiniMax Code turned on in magpie's Agents page with a model picked, and
MiniMax Code went on with the user's own MiniMax-M3.1-Flash; Sessions
showed nothing.

3.1.10 is MiniMax Code Desktop (Electron, MiniMax Code.app). It runs the
mcode runtime on the same ~/.minimax/config.yaml magpie writes, and that
write is right: defaultModel is custom_provider:magpie/<model>. But
Desktop's window keeps the global model last picked in it in Chromium
localStorage ("mavis:model-selection", read from 3.1.10's renderer chunk
56321) and, when the model list loads, marks that one selected while it
is still in the runtime's list, ignoring the runtime's own default.
Only a session.model_updated from the runtime's own select API moves it,
and the runtime reads config.yaml at start-up and doesn't watch it. A
release build has no local HTTP API (local-runtime's server listens only
with the diagnostic sidecar env set), so magpie can't move the pick, and
writing the app's leveldb would risk the user's app data. Nothing changed
here between v0.1.2629 and main (only 35c47f762's dsh YAML speed-up).

What changed:
- desktopApps knows MiniMax Code Desktop: MiniMax Code.app with bundle id
  com.minimax.agent.cn (filecdn.minimax.chat) or com.minimax.agent
  (file.cdn.minimax.io), and on Windows electron-builder's per-user
  default %LOCALAPPDATA%\Programs\MiniMax Code\MiniMax Code.exe. So its
  version shows beside the CLI's, and ~/.minimax isn't a leftover there.
- With the app installed, MiniMax Code's notice says to restart the app
  and pick a magpie model once in its model menu (under magpie); mcode
  sessions still need a restart. Translated in zh, zh-TW, ja and de.
- agent-wiring.md says why.

Run (on mote) at the first base d24be3c25: go test -count=1 ./internal/agent
./internal/sessions . ok; ./internal/gui red only in TestMainWindowCorners/macOS_26_SDK, which
is #3949 (macOS 27, AppKit, unrelated). go vet ./internal/agent for
darwin, linux and windows ok; gofmt -l clean; node --test of
i18n-keys, agent-notice-lang and about-notices all pass.

Broken by hand: with the desktopApps entry renamed away,
TestMiniMaxDesktopSaysPickInTheApp goes red (no notice, no version) for
both bundle ids.

At the rebased tree (on d577c184b): go test -count=1 ./internal/agent ok,
the three node GUI files pass, linux and windows go vet ok.

Not tried: the Desktop app itself (an Electron GUI with sign-in; read
from its 3.1.10 zip, whose SHA-512 matches latest-mac.yml, never run).
The Windows install folder is electron-builder's default, not read from
an install. A data folder moved in Desktop's settings (desktop_custom)
is still not followed: magpie writes ~/.minimax or $MINIMAX_DATA_DIR.

Reported by 教父 on Discord.
2026-11-02 14:05:34 +08:00
yetone a1f56720cd gateway: Claude Desktop's catalog-named rows say their provider in the description (4 v5)
4 v5 on Discord: with Provider in model names on, Claude Desktop's picker
listed four relays' Opus 5.5 (老林夕, 新林夕, 百德, chatflowsai) all as
"Opus 5.5 (…7922287072.anthropic.claude-opus-5-5)", told apart only by
the id's tail.

Cause: a Claude model with reasoning levels is listed as
magpie-<n>.anthropic.<model> so Desktop gives it the effort picker
(claudeLooking). Desktop 4.4212 labels a picker row by labelOverride,
then its signed catalog's name, then display_name (ngn in
index.chunk-m4oMImJ-.js), so our display_name "Opus 5.5 · 老林夕" is
never shown for those ids; Qhn then appends the differing id tail to rows
of one name. labelOverride comes only from an admin inferenceModels list
in Desktop's profile (static, read at start, sealed at rest in 4.4212,
and it can't say DesktopLongest's "[1m] only"), so magpie doesn't write
it. Turning the catalog off would lose the effort picker for opus/sonnet
5.5 (Kfn lacks them).

Change: Desktop shows the gateway's description under the name, before
the catalog's (which has none for these models). desktopModels now puts
the provider there for a catalog-named row (DesktopNumber != "") when the
Provider in model names setting puts it after the name (desktopSaidBy):
on, every one; own, every vendor-named one; off, only two of one name. A
DesktopLongest 1M row says "1M context window · <provider>". Ids are
unchanged, so saved sessions and picks still resolve. Rows Desktop names
by display_name are unchanged. agent-wiring.md updated.

Run on mote. At base d24be3c25 with this change: go test -count=1
-timeout 45m ./internal/gateway ./internal/gui ./internal/agent: agent
ok; gateway red on TestCompactionOverByteCapEveryTime (new, filed #4862)
and TestCodexPoolSaysTheClientsVersion (#4807), both ok alone at
origin/main 4fc34828e and at this head; gui red on
TestMainWindowCorners/macOS_26_SDK (#3949), red the same alone at
origin/main 4fc34828e. At the pushed head (rebased on 4fc34828e): gofmt
-l clean; go vet ./internal/gateway ./internal/gui darwin and windows ok,
GOOS=linux ./internal/gateway ok (./internal/gui doesn't cross-vet for
linux: wails needs cgo, the same at origin/main); -run
'Desktop|Science|KeyModels|Decider|CallerKey' over ./internal/gateway
./internal/gui ok, plus the two gateway reds above ok.

Broken by hand: desktopSaidBy always "" made
TestClaudeDesktopCatalogNamedSaysProvider red (14 rows undescribed and
the 1M row "1M context window" alone); dropping the label check made it
red under Off (the lone Sonnet 5.5 said "chatflowsai").

Not tried: the real Claude Desktop picker. Desktop 4.4212 on mote in a
sandbox HOME refused --remote-debugging-port, stalled at start before
asking /v1/models (likely a Keychain prompt), and screencapture fails
over ssh, so the row text under the name is read from its bundle, not
seen. Desktop's own added 1M variant of a row can't take a description
from the gateway (it always gets "1M context window"); it keeps the id
tail Desktop gives it.

Reported by 4 v5 on Discord.
2026-11-02 14:04:56 +08:00
yetone 2b938b170d gateway keys: the key editor offers decision models (Jev, Clef) beside the groups
Kautism on Discord: a gateway key held to a few routing groups couldn't
use Clef or Jev, and they showed nowhere for it. A decision model is a
model: /v1/systemone and the decision list another magpie asks for
(DecidersHeader) hold a key to it as to any model, which stays so (the
restriction covers both routes). But GET /api/caller-keys/models listed
only provider.Catalog, which has no decision models, so the only way to
let a held key ask one was All models.

- caller_keys.go: the picker's list now has OfferedDeciders, each after
  its provider's chat models, marked decides.
- keys.js: such a model's note says it is a decision model that a
  routing group asks whatever the key may use, and that picking it lets
  the key ask it itself; en, zh, zh-TW, ja, de.
- A group the key names still asks its own Jev for every turn with no key
  check (askJev); TestGatewayKeyHeldToAGroupKeepsItsDecider holds that,
  and that the key is refused Jev at /v1/systemone and not listed it
  until it names it, then allowed and listed.
- docs/reference.md and gateway-routing.md say so.

Run on mote at the pre-rebase head; at the pushed head (rebased on
066ece93b, which touches no gui, gateway or access file) TestCallerKey*
and TestGatewayKey* in internal/gui and internal/gateway ran again: ok.
- go test ./internal/gui/: ok except TestMainWindowCorners/macOS_26_SDK,
  the AppKit test red on macOS 27 (#3949), unrelated.
- go test -run 'Key|Decide|Jev|SystemOne|Decider' ./internal/gateway/: ok.
- go vet darwin, GOOS=linux -tags nogui, GOOS=windows for internal/gui
  and internal/gateway: ok. gofmt -l clean.
- GUI: gateway-key-*.test.cjs and i18n*.test.cjs, chromium and webkit:
  136 of 138 ok; the 2 reds are gateway-key-models "en ... wider than
  560" (#4081), red 2 of 3 webkit runs on untouched origin/main
  d24be3c25 too. The new gateway-key-deciders.test.cjs: chromium and
  webkit, 1000px and 400px, all five languages, ok.

Broken by hand: OfferedDeciders(nil)[:0] in the handler, and
TestCallerKeyModelsOfferDeciders went red ("ts/jev-latest not offered");
the key check in serveSystemOne turned off, and
TestGatewayKeyHeldToAGroupKeepsItsDecider went red (200 for Jev).

Not tried: a real Cloudflare Clef or TypeSafe Jev account, another
magpie connected with a held key in a real app, and the whole GUI suite
(mote was at load ~150 with other sessions' suites).
2026-11-02 13:53:19 +08:00
yetone 066ece93bb provider: LongCat is a vendor preset, Meituan's LongCat API platform with chat completions, Responses and Anthropic messages (hoobnn on Discord)
LongCat makes its own models (LongCat-2.5, launched 11-02) and serves them
at api.longcat.chat. magpie had LongCat's icon but no preset for it.

The new preset is longcat ("LongCat", KindVendor, icon longcat, catalog
models.dev's longcat). It uses:
- chat completions and Responses at https://api.longcat.chat/openai/v1;
- Anthropic messages at https://api.longcat.chat/anthropic;
- docs at longcat.chat/platform/docs/zh/api-docs, keys at
  longcat.chat/platform/api_keys.
The key goes as a Bearer. magpie sends both headers, and the docs ask for
Bearer on both endpoints; x-api-key alone gets "missing_api_key". The model
list is /openai/v1/models. longcat.chat's and longcat.ai's accounts use the
same API host (both sites' api-docs pages name api.longcat.chat).

An entry at those endpoints imports as the preset, for example CC Switch's
Claude Code and Codex entries from LongCat's cc-switch page. OpenCode's
auth.json "longcat" (models.dev's id) maps to the preset too. The README
(en, zh), docs/reference.md and the site's import pages (en, zh, ja, and
import.html, with the icon) list it.

Sources, read 11-02: api-docs, api/models, api/model, api/model-params,
api/chat, api/messages, image-video-understanding, cc-switch, pricing/
longcat-2.5, change-log, faq.

Probed without a key, from this machine: /openai/v1/models and
/anthropic/v1/models answer 401 authentication_error "missing_api_key".
/openai/v1/chat/completions, /openai/v1/responses and
/anthropic/v1/messages with a bad Bearer answer 401 "incorrect api key".

Run at this head (base d24be3c25, origin/main at push), on mote:
- TestLongCatPreset and TestLongCatList (the docs' literal /models
  example) pass. TestLongCatPreset goes red with the OpenCode mapping taken
  out ("OpenCode import: … Skip:it has no base URL").
- gofmt -l and GOOS=linux / GOOS=windows go vet ./internal/provider are
  clean.
- go test -tags nogui -timeout 45m ./... is ok except three tests that
  have issues already:
  - TestEveryRouteHasACommandOrIsNamed (#4826) is red on a clean
    d24be3c25 too.
  - TestKeepOffWaitsForTheSetting (#3687) is red on a clean d24be3c25 too.
  - TestCodexPoolSaysTheClientsVersion (#4807) is red in the full package
    run and passes 3 of 3 alone on d24be3c25.
- GUI add-sheet and add-button pass in Chromium and WebKit (12/12). No GUI
  file changed: the add sheet draws presets from /api.

Not tried:
- a real LongCat key or a real request (none available).
- LongCat-2.5's window (1M), output cap (256K) and image input. These come
  from models.dev, which so far lists only LongCat-2.0 and
  LongCat-2.5-Preview, and LongCat's /models gives no facts. Until
  models.dev adds LongCat-2.5, magpie doesn't know them for it.
- LongCat's thinking switch ({"type":"enabled"|"disabled"}).
2026-11-02 13:44:11 +08:00
yetone d24be3c251 gateway: a request over a provider's byte cap is asked again with its oldest images left out (EDwinpzy)
EDwinpzy on Discord (v0.1.2605, Windows, Codex Desktop, compaction on
auto/deepseek-v4.1-flash through Command Code): a long session full of
screenshots could not compact. Command Code refused the summary request
with 400 "Request body is 40.1 MB, over the 32 MB limit for one request
(33554432 bytes)". That is not a 413, so summaryTooLarge never sent it to
the text-only ask, and Codex's compaction failed three times. The
compaction guard then held it for five minutes, and after that the same
40 MB body was sent again. Agent turns of the same session hit the cap
the same way.

What changed (internal/gateway/body_cap.go, wired in forward and
forwardOnce):
- byteCapRefusal: a 413, or a refusal of any other status whose words
  say the body is over a size limit. A 401, 403, 429 or a context
  overflow (tooLong) never counts.
- refitOverCap (forward): the cap is taken from the refusal (the
  smallest size it names below what was sent, else 3/4 of what was
  sent) and kept per provider id. The request is then asked again,
  fitted to 3/4 of the cap, at most three times.
- To fit a request, the oldest history images are replaced one by one,
  each with a text part: "[An earlier image was left out here to keep
  this request under its size limit.]" (it names neither magpie nor the
  vendor). The latest user message's images, and every text including
  tool output, are kept. Every other byte of the body stays as it was.
  Covers Responses, Chat, Anthropic and Gemini.
- withinCap (forwardOnce): once a cap is known, a later request near it
  is fitted before it goes, so each turn doesn't pay a refusal first.
- When leaving out every earlier image still doesn't fit, or every size
  is refused, the agent gets a 413 request_too_large naming the size,
  the cap and what was kept. Codex reads that as context_length_exceeded,
  and its compaction goes on to plainCompact and localSummary instead of
  sending the same body into the guard's hold.
Every route that calls serve goes through forward, including magpie's
own: compaction, titles, the classifier, search, vision and the Codex
fallback turn. So all of them are fitted.

Not changed: magpie's own requests still run no gateway hooks, so a
plugin's onRequest doesn't see compaction (EDwinpzy's other ask). Running
them there changes the plugin contract: a recall plugin's context would
land in summaries and titles, and onResponse would see calls the user
never sent. Filed as #4847, and written in gateway-request-hooks.md.
gateway-routing.md describes the byte-cap fitting.

Tests (body_cap_test.go), built from the reporter's shape: a ~40 MB
Codex session of 20 ~2 MB screenshots, from view_image tool outputs and
pasted user images, and a latest user message with its own screenshot.
The fake upstream refuses anything over 32 MiB with the reporter's
literal 400 body. No network.
- TestCompactionOverByteCapLeavesOutOldImages (Responses and Chat
  upstreams): Codex gets the model's SUMMARY. The second ask is under
  24 MiB, the oldest screenshot is replaced by the marker,
  SHOT19 (the latest user message's image) is kept, and every user
  text and tool output text is kept.
- TestTurnOverByteCapLeavesOutOldImages: a turn is fitted the same way,
  and the next turn goes fitted with one upstream call.
- TestOverByteCapNothingToLeaveOut: every image is in the latest
  message. The body is sent once, and Codex gets context_length_exceeded
  with "over the 32.0 MB 1017dp takes in one request ... no earlier
  image".
- TestCompactionOverByteCapEveryTime: refused at every size. Asks get
  smaller, there are at most 6 calls, and it ends in a local summary
  with no image in it.
- TestByteCapRefusal and TestWithoutOldImagesEachProtocol: the
  classifier (TPM 429, context overflow, 401 and an invalid-schema 400
  are not caps), statedCap, and the Chat, Anthropic and Gemini splices.

Run on mote (Go 1.26.8, macOS) at this change on b61121503:
- go test -count=1 -timeout 45m ./internal/gateway: every test passes
  except TestCodexPoolSaysTheClientsVersion, which is #4807 (red in a
  full package run on mote, passes alone; this change doesn't touch
  Codex's identity).
- the targeted -run of ByteCap, CodexCompactTooLarge, DeepSeekByteCap
  and CodexCompactOther: ok.
- GOOS=linux and GOOS=windows go vet -tags nogui ./...: ok. gofmt -l
  internal/: clean.

After the rebase onto f5c956b84 (three commits, none in
internal/gateway): Linux and Windows vet of gateway and provider, and the
byte-cap, compaction and DeepSeek tests above again: ok.

Broken by hand on mote:
- without refitOverCap, withinCap and the post-loop 413, the compaction,
  turn and nothing-to-leave-out tests fail with the reporter's 400;
- without withinCap alone, the next turn is asked twice;
- without the 413 after the loop, TestCompactionOverByteCapEveryTime
  fails with Codex's compaction answered 400.

Not tried: a real Command Code account (or any vendor's real cap), a
real Codex Desktop session, and a Windows run (nothing here is
OS-specific). The cap is kept in memory only, so after a restart the
first oversized request is refused once more before it is fitted.

Reported-by: EDwinpzy (Discord #feedback)
2026-11-02 12:20:12 +08:00
yetone f5c956b848 plugin: a 401 on an access token its refresh token renews makes it due, not the sign-in gone (plugins#618)
jinpy666 (magpie-community/plugins#618): with Copilot plugin 0.1.0, the
two Copilot slots that carried no traffic said "sign-in has expired —
sign in again" within a day or two, while their GitHub OAuth token still
traded at /copilot_internal/v2/token. A plugin's bare 401 (no
X-Magpie-Sign-In) marked the account whatever the cause, and a mark is
cleared only by a success or a usage read that says so, which an idle
slot never gets.

The host now judges such a 401 against the sign-in as the request found
it (staleAccess in host.js). For an OAuth sign-in with a refresh token
whose access token is still the stored one and not due yet, it makes the
token due (expires 1, under the auth lock, only while the access token is
unchanged), drops the account's loader and says "kept": the gateway
fails the request over as before, and the next request renews the token
through the plugin's loader (or magpie's auth.refresh) and goes through.
Still marked: an access token renewed for this request and turned away,
one that was due already and not renewed, an account with no refresh
token, and a plugin saying "expired" (a refused refresh). A sign-in that
can't be read when the 401 comes is unknown: kept, not marked. A marked
account stays routable (pluginAlsoOn doesn't filter marks), so a slot
marked before this is renewed on its next request and the success clears
it. Copilot isn't a mover; its plugin 0.1.1 (plugins 53d4813, on the dist
branch; never on npm) says "expired" for the exchange's own 401 and
"renewed" for a quota read GitHub answers, which clears old marks.

TestPluginStaleAccessRenewsNotLapses (new, fake plugin + local vendor,
no network): idle account kept and due after the 401, renewed and 200
on the next request; a renewed token refused is marked; a refused
refresh (signIn "expired") is marked; plugin-auth.json unreadable at the
401 marks nothing; a marked account is still routed. TestPluginFailover's
"gone" case asserted one 401 marks; it now asserts no mark after that
401 and the mark once the account's renewed token is refused too.
docs/subsystems/provider-plugins.md has the rule.

Run at this commit's tree (mote, rebased on 541102eba):
- go test -count=1 -timeout 45m ./internal/plugin/ ./internal/provider/
  ./internal/gateway/: plugin ok, provider ok; gateway red on
  TestCodexPoolSaysTheClientsVersion (#4807) and
  TestUnroutedHeldReportSaved (#4300), both filed, full-run-only; both
  pass alone here and at 541102eba.
- GOOS=linux and GOOS=windows go vet of the three packages: ok.
- gofmt -l: clean.
Broken by hand: host.js at the old code, the new test is red ("idle@fake
was marked for a dropped access token its refresh token renews"); the
unknown branch returning "", red on unknown@fake.
Not tried: a real Copilot account (or any real vendor's dropped access
token); which 401 marked the reporter's slots first isn't confirmed (a
request failed over to them, most likely); a plugin that keeps a future
expires but never renews (it is marked on its second 401, not its
first); GUI unchanged, no GUI run.
2026-11-02 12:03:24 +08:00
yetone b3eb26400c library: a ${NAME} only the login shell exports reaches the MCP server magpie starts or calls
Cyrus on Discord: once a Library MCP server's token was written as
${NAME}, the Library listed no tools for it. magpie expanded the
reference from its own environment only, and a magpie opened from the
Finder or the Dock has none of the profile's variables, so a token
exported in .zshrc was "not set" for the tool-list check, and the
router (dialHub) and Codex's run through the gateway (specOf) didn't
start the server either.

expandAll, the one place all three expand a reference, now takes a
variable magpie's environment hasn't from proc.LoginVars: what the
login shell (and fish or nushell, as shellEnv asks them) exports, read
through /bin/sh as the existing PATH probe is, each answer kept a
minute. On Windows it reads the registry's user then machine variables
(one set with setx after magpie started). The value is only in memory
at call time: never set in magpie's environment, never written to
library.json or an agent's file, never logged. A variable set nowhere
is still novar, naming it ("NAME not set" on the page, unchanged). The
library only documents ${NAME} (no ${NAME:-default}), so nothing else
is parsed.

Run at this head (90d554db1 rebased on 46a13f837), on mote:
- go test -tags nogui ./internal/proc ./internal/library: ok
- GOOS=linux and GOOS=windows go vet ./internal/proc ./internal/library: ok
- gofmt -l: clean
- wsl-run (magpie-desktop): TestLoginVars, TestEnvRefs*, TestCheckStdio,
  TestCheckHTTP, TestShellEnv*, TestLoginEnv*: ok
- ./internal/cli before the rebase: only TestEveryRouteHasACommandOrIsNamed
  red, POST /api/usage/checkin-account, already filed as #4826.
- By hand on mote: LoginVars with the real /bin/zsh (.zshrc) and
  /bin/bash (.bash_profile) in a temp HOME read the exported token and
  left an unset name unset.

TestEnvRefsFromLoginShell: a fake login shell exports CYRUS_TOKEN,
magpie's environment hasn't it; a fake stdio server that exits without
the right token and an http one that answers 401 without it are each
checked (ok, with tools) and dialled by the router, Codex's run spec has
the value, a variable set nowhere is novar, and after SaveServer, a
check and a Sync no file in the sandbox HOME holds the token.
TestLoginVars: exported, exported-empty, unexported and unset names, bad
names never asked, the minute's cache and a new SHELL asked again.

Broken by hand: loginVars returning nothing made TestEnvRefsFromLoginShell
red (command and url both novar CYRUS_TOKEN, the reporter's case);
parseNamed ignoring the set flag made TestLoginVars red.

Not tried: the Windows registry read (compiled by vet only, no run on
xiaomi-gpu); a real Finder-launched magpie.app with a real token; the
GUI suite (no GUI file changed).
2026-11-02 11:01:51 +08:00
yetone 1a864f156e usage: a hidden card a menu bar cell showed offers Show in Overview, not Hide again
Found while fixing yuu003348's report (dee1afa40). A card hidden from
Usage › Overview still shows when a menu bar cell asks for it (usagePeek),
and the "{n} hidden" line leaves it out while it shows. Its menu offered
only "Hide from Overview" again, so from that card there was no way back.
Now its menu has "Show in Overview" (unhides what of it is hidden) and no
Hide items. Translated in zh, zh-TW, ja, de; gui-shell.md says it.

Run (mote, node --test, chromium and webkit):
- usage-hidden-way-back (now with the peek case, every language and
  width), usage-cards-hide, usage-count-client, i18n-keys: ok.
- usage-agents-hide and tray-cell-click: red as at origin/main fdfce4d98
  (#2276/#3414, #4790), same messages.

Broken by hand: the new test on dee1afa40's page.js is 32 of 32 red,
the peek card's menu reads ['Hide from Overview'], not ['Show in Overview'].

Not tried: a real menu bar cell click in the real app.

At the pushed head (rebased on d39358f1b, both commits): usage-hidden-way-
back, usage-cards-hide, usage-count-client, i18n-keys and
claude-quota-onboarding, 100 of 100 ok.
2026-11-02 10:32:37 +08:00
yetone dee1afa400 usage: what is hidden from the Overview can be found again (yuu003348 on Discord)
yuu003348 on Discord: "观测/用量/概览 从概览中隐藏 后 无法取消隐藏". The way
back was there: a "{n} hidden" line under the cards (#quotaHid), each row with
Unhide, Show all from two. But it was drawn in --faint (#b9b9c2 on #f4f4f6,
1.77:1, 11.5px), so it couldn't be found; the Agents list's line (ikunbots on
X) is the same class.

- app.css: .us-hid .us-hidline is --muted (3:1 or more in light; ~5:1 in
  dark by the tokens), for both lines.
- plugins/usage/page.js: while any are hidden, a card's menu and an Agents
  row's menu end with "Show {n} Hidden". It opens the line under its list,
  puts the keyboard on it and brings it into sight on the menu's click
  (openHidden, scrollOnPurpose). hiddenQuotas() is the one count both the
  line and the menu read.
- i18n: "Show {n} Hidden" in zh, zh-TW, ja, de.
- docs/subsystems/gui-shell.md says both.
- usage-cards-hide / usage-agents-hide now expect the new item when
  something is hidden already.

Run (mote, node --test):
- usage-hidden-way-back.test.cjs (new): chromium and webkit, en/zh/zh-TW/ja/
  de, 1200, 560 and 390 (touch long-press): 2 of 2 ok (32 cases).
- 130 Usage/menu/tray GUI files: the only reds the change made were
  usage-cards-hide and usage-agents-hide's exact menu lists, now updated.
  Every other red there is red at origin/main fdfce4d98 too, run alone side
  by side (216 tests at base, 248 at head, the same 72 fail by name):
  balance-fix (#4683), menu-input-scroll (#3402), tray-cell-click and
  usage-fold "most on one screen" (#4790, #3415), usage-ledger "newest
  live route" (#3104, #4078), usage-agents-hide "unhiding a row leaves the
  hidden line where it was" (#2276, #3414; it fails after the menu checks).
  usage-cards-hide is ok at head.
- go test ./internal/gui: ok but TestMainWindowCorners/macOS_26_SDK (#3949).
  No Go changed, so no gofmt or vet.

Broken by hand: on the old assets the new test is red on contrast
("#quotaHid .us-hidline reads rgb(185, 185, 194) on rgb(244, 244, 246):
1.77:1"); with the new CSS and the old page.js it is red on the menu (no
"Show 1 Hidden").

Not tried: the real app or a real account; dark mode's contrast is from
the tokens, not measured in a test; Windows and Linux webviews; the whole
GUI suite (the change is a menu item and a colour, no new API call or
layout).
2026-11-02 10:29:13 +08:00
yetone d39358f1bb claude: /usage and "hi" reads run in magpie's work folder and say why they ended (#4830)
mydosu's Claude Code quota reads on Windows failed for both accounts
with "exit status 1" alone. Two things were behind it:

- Each one-off interactive run (claudeUsageTUI, askClaudeTUI) started in
  a new magpie-claude-<n> temp folder, which the helper trusted, so each
  read wrote one more trusted projects entry into the config's state file.
  The reporter had 67 in ~/.claude.json.
- The caller's budget (subscriptionTimeout, 20s) is shorter than the
  helper's own waits (45s for the prompt, 20s for a panel). The context's
  kill came first, and that is TerminateProcess on Windows, so Wait said
  "exit status 1" with an empty stderr. On Unix the same kill says
  "signal: killed".

What changed:

- One-off TUI runs work in claudeWorkDir (oneOffDir). That is the
  owner-checked folder the bridge's own runs already use, so each config
  directory holds one trusted entry instead of one per read. A temp
  folder is made only when that folder can't be.
- The run's session file there is removed by the session_id the helper's
  init line names (dropOneOff). It is not removed under WSL.
- The helper is told its caller's deadline (claudetui.DeadlineEnv, the
  context's deadline less min(3s, a quarter of what is left)). At that
  time it ends on its own, saying what Claude Code hadn't done and its
  last screen, e.g. "Claude Code hadn't drawn /usage's panel in the
  2.9s its caller waits for it: ...".
- A run that still says nothing reads "Claude Code's interactive mode
  said nothing before magpie stopped waiting for it (...)" (oneOffErr),
  not an exit code.
- quotaError says these reasons on the card as "Allowance unavailable:
  {why}" (an existing key in every language). The full text stays in
  the tooltip. Nearby comments were cut so the core script budget holds
  without a raise.
- No -p fallback was added. The -p asks keep their own temp folder,
  since -p asks nothing about trust.
- The entries older magpies left in ~/.claude.json are left alone:
  magpie never writes that file.

Run at this head (after the rebase on c875e66c2), on mote:

- go test -count=1 ./internal/claudetui: ok.
- go test -count=1 -run 'Claude|TUI|Usage|Warm|Ask' ./internal/gateway: ok.
- go test ./internal/gui -run 'Budget|I18n|Script': ok.
- node --test claude-quota-onboarding (chromium and webkit, en, zh,
  zh-TW, ja and de, 440px) and i18n-keys: 14 of 14.
- GOOS=linux and GOOS=windows go vet of claudetui and gateway: clean.
- gofmt -l: clean.

On xiaomi-gpu (Windows 11, win-run):

- TestShimEndsAtItsCallersDeadline passes through ConPTY.
- TestShimFirstMessageWaitsForTools and TestShimReadsUsage are red the
  same way on origin/main c875e66c2. They are filed as #4810 and #4820.
- The real Claude Code 2.1.316 ran under a sandbox HOME and
  CLAUDE_CONFIG_DIR, with fake credentials and a rebuilt magpie.exe.
  Before the change, each run left a new trusted temp entry. With
  MAGPIE_CLAUDE_TUI_BY 3s out, the helper now exits saying "Claude Code
  hadn't drawn /usage's panel in the 2.9s its caller waits for it: <its
  screen>". Untrusted, it says the trust reason.

Broken by hand (each went red):

- The helper ignores DeadlineEnv: claudetui's deadline test.
- oneOffDir never uses claudeWorkDir: two different pwds and sessions
  left.
- removeSession dropped: "session was left".
- oneOffErr's context branch removed: got "signal: killed".
- helperDeadline not passed: "helper was told by:" empty.
- quotaError's new lines removed: the onboarding GUI test shows
  "Allowance unavailable" alone.

Not tried:

- A real signed-in Claude account on Windows. So which step is slow on
  the reporter's machine (start-up, the prompt or the panel) is not
  known. The card now names it.
- Unrelated, seen while breaking it: with no deadline, a /usage whose
  panel is never drawn ends after 20s as a success with an empty result.

Reported by mydosu (myduso_27930 on Discord).
2026-11-02 10:14:49 +08:00
yetone c875e66c24 gateway: reasoning a Chat, Messages or Gemini client's calls carry, refused by another Responses upstream, is asked again without (#4798)
Since 9da9bfabd a Chat, Messages or Gemini client keeps a Responses
upstream's sealed reasoning in its calls' ids (<id>__rk16__<key>), and
unreasonCalls puts it back before the assistant turn on every later
request. After a fallback or an account switch (zane668: Pi's Chat on
Grok, a 402, then Codex; ZanderH-code: Claude Desktop's Messages to
Codex) the other upstream answered "The encrypted content ... could not
be verified" / "Could not decrypt the provided encrypted_content", and
serve's foreign-reasoning retry ran only for a Responses client, so the
try was `fail: other`, the turn a final 400, and every later turn
carried the same item and failed the same way.

Now that refusal is asked again for a client of any API: refuseCarried
remembers what the request's calls carried as refused by that key or
account in the conversation (refusedSeals, as a Responses client's
items are), and translate leaves those items out of this request and
every later one to it (withoutRefusedCarry, scoped to the try's
provider through withSealScope). The try is `fail: foreign`. Calls,
their arguments and results, and text go as the client wrote them,
under the calls' own ids; the one that sealed an item, and every other
account, is still given it. As with a Responses client (withoutReasoning)
all the reasoning the request carried goes on the retry, the upstream's
own earlier items too; what it seals next goes along.

Not changed: an Anthropic upstream's refused thinking signature
(thinking_bound.go) and Vertex's thought signature already retry on
every client API; a Responses client's path is as it was.

Run at this head (base fdfce4d98, origin/main unchanged since) on mote:
- go test ./internal/gateway -timeout 45m -count=1: every test ok but
  TestCodexPoolSaysTheClientsVersion, the known full-run red #4807; it
  passes alone at this head with TestForeign*, TestGrokReasoning*,
  TestSealedReasoning*, TestReasonedID*, TestBoundThinking*.
- GOOS=linux and GOOS=windows go vet ./internal/gateway: ok. gofmt -l: clean.

Broken by hand: with the new retry gate off, the new
TestForeignCarriedReasoningAskedAgainWithout is red on every client
(Chat and Messages, whole and streamed, Gemini) with Codex's 400 after
the switch; with withoutRefusedCarry's call taken out of translate, red
the same way. Fixtures use the reporters' literal refusal texts.

Not tried: a real cross-vendor switch with real Grok and Codex
accounts; a Gemini streamed client; Pi itself.
2026-11-02 10:05:07 +08:00
yetone 18c3976234 gateway: DSML calls Alma relays from a group's DeepSeek are guarded on the Responses route
wishSeikouudoku on X (tweet 2117056042001719807, 11-02 08:47 +0800): Alma,
through a magpie group to DeepSeek, got <||DSML|| calls>, invoke
name="…" and parameter as its reply's text, and no tool ran.

Cause, already fixed on main: Alma's magpie provider is of type openai,
which the AI SDK sends to /v1/responses (the owner's usage log: 4365
Alma rows with ep /v1/responses). DeepSeek's preset speaks Responses
too, so the reply was relayed as it came, and before 20f27f514 (#4743,
first in v0.1.2652, published 11-01 22:36Z, about 2h before the tweet)
a relayed Responses reply's text was never read for calls. The DSML
parser itself already read these exact bytes (observedPipes, #2623).
No code change here: this commit adds the reporter's route to the tests
and fixes the subsystem doc, which still said a relayed Responses reply
"is not read for calls yet".

- textcalls_alma_test.go: TestDSMLAlmaResponsesThroughGroup sends
  Alma's AI-SDK-shaped request (streamed and whole) to a group of two
  Responses members, the first answering or refusing with a 500. The
  reply is DeepSeek-shaped: a reasoning item, then a message whose text
  is "我先搜一下。\n\n" + observedPipes, one character to a delta.
  TestDSMLAlmaResponsesPlugin does the same to a plugin's model, alone
  and as a group's only member (the plugin is asked Chat, so the
  translation reads it).
- gateway-routing.md: the text-calls paragraph names responsesTextCalls
  and this report.

Run (mote; the full package at 4d55a0a02 + this change, then the DSML,
TestTextWritten and Responses passthrough tests again at ca1fc43fc +
this change, which touched no gateway file: ok):
- go test -timeout 45m ./internal/gateway/ ./ : root ok; gateway red on
  TestCodexPoolSaysTheClientsVersion only, a file this change doesn't
  touch, which is #4807 (red in a full package run on mote, passes
  alone); alone with TestDSMLAlma it is ok. A full ./... run wasn't
  made: this change is a test file and a doc.
- -run 'TestDSMLAlma|TestDSMLThroughGroup|TestInvokeReportedResponsesPassthrough': ok

Broken by hand:
- the responsesTextCalls branch in passthrough turned off (as before
  v0.1.2652): TestDSMLAlmaResponsesThroughGroup red, the DSML in
  output_text and in response.completed's output, no function_call.
- textCallSee turned off in both translated paths (gateway.go written,
  continuation.go): TestDSMLAlmaResponsesPlugin red. With only
  gateway.go's off it stayed green: the plugin's reply goes through
  continuation.go's.

Real request: an Alma-shaped streamed /v1/responses request through a
sandboxed magpie (sandbox HOME on mote, port 3591) to a group of
deepseek/deepseek-flash, opencode-go/deepseek-v4.1-flash and
volcengine-2/deepseek-v4-1-flash-260910. DeepSeek's own API answered
Insufficient Balance and OpenCode Go's key has expired, so Volcengine's
DeepSeek V4.1 Flash served it: a native web_search function_call, no
DSML. The model didn't write its call as text on that try.

Not tried: DeepSeek's own Responses stream (no balance), so the
reasoning-then-message shape in the fixture is modelled on OpenAI's
events, not DeepSeek's bytes; the reporter's magpie version is not
known.
2026-11-02 09:12:14 +08:00
ggbdpqandyetone ca1fc43fc9 provider: quota history draws no line for a plugin's aside window that says no share (#4825)
ggbdpq's patch (gua2100 on Discord), reviewed and landed with an
end-to-end test and a doc line.

What changed
- quotaOfPlugin marks an aside window that leaves `used` out, with no
  count to reckon one from, as noShare. pointOf refuses such a window,
  so the history no longer draws a flat 100%-left line for it. The card
  still shows the row as before.
- noShare is unexported and so lost on JSON. Cards restored from the
  cache have AsOf set, and noteQuotaHistory skips them, so this never
  matters.
- Review changes: TestAsideWindowWithoutUsedDrawsNoLine now also runs
  the windows through noteQuotaHistory and QuotaHistories in a sandbox
  HOME, and wants lines [Bonus Weekly] only.
  docs/subsystems/providers-accounts.md says such a window isn't kept.

Run at the pushed head (on mote, base 4d55a0a02)
- go test -race ./internal/provider passes for the touched tests, and
  the provider package passes.
- The full suite, gofmt and the cross-OS vet are as recorded in the
  #4824 netproxy commit. The only reds are #4826 and #4807, neither in
  provider.

Broken by hand: with noShare removed from pointOf, the test is red:
"On-demand/Points: history point true, want false" and "history lines
[Bonus On-demand Points Weekly], want [Bonus Weekly]".

Not tried: a real plugin reporting such a row, or the chart in a
browser. A wallet Balance window draws the same flat line; that is
#4831, not this commit.

Co-authored-by: yetone <yetoneful@gmail.com>
2026-11-02 09:11:30 +08:00
yetone 679bc412cb library: Magpie Browser's row asks which agents may use it, once connected
Magpie Browser is added with no agents (opt-in), so the router offers it
to none until one is ticked, and an agent asked to use the browser
reached for AppleScript instead. While its extension is connected
(GET /api/library/browser, read again every 3s while the row is shown,
so connecting it needs no reload) and no agent has it, its row asks
"Which agents may use it? They act in your tabs, signed in as you are.",
a button per agent that clicks that agent's chip (servers/agents, as a
chip's click). Once one has it, the row asks nothing more. Not
connected, or given to an agent already, it asks nothing.

Run on mote at this head (8e884421c + this): library-browser-ask (every
language, Chromium and WebKit, 1100/420px) with library-row-remove,
library-open-again, library-mcp* and i18n*: 200/200. Red with the row's
ask taken out by hand (2 pass, 22 fail). An earlier run of every
library* and i18n* file on this change had only library-row-remove red,
the #3099 flake fixed in 8e884421c. Not tried: the real extension
connecting in the owner's Chrome with the window open.
2026-11-02 08:01:47 +08:00
yetone e44ad72cfd gui: a failed status dot is an x, not a red dot alone
coolmantou on Discord (#feedback), who is red-green colour-weak, could
barely tell the green status dot from the red one. Under a deuteranopia
or protanopia simulation the two are one olive colour, in light and dark.
Making the green lighter would not help a greyscale or protan reader, so
the failed state now says it by shape (Apple HIG: never colour alone).

What changed
- app.css: a --x-mark token (an SVG x, used as a mask). Each failed dot
  keeps its red and its 6-7px box, is drawn through the mask and scaled
  1.5 so it reads as heavy as the round dot. Layout is unchanged.
  Dots: Test models (.tdot.bad), an agent's status (.ag-st.bad .ag-dot),
  the check-in (.ci-dot.bad), the request ledger (.led tr.bad .st .dot).
- routing.css: a try or probe (.rt-req/.rt-probe.bad .to i), a step
  (.rt-steps li.bad::before), the preview (.ps-dst.bad > i).
- library.css: a server that failed (.lib-health.err::before). A ring
  was not used because "not checked" is already a ring there (#2308).
- Not changed: green-only dots with no red pair (gateway, keys, tiles,
  live), chart markers, routing's animated packets, redact's categorical
  facet dots. The tray has no status dots of its own.
- docs/subsystems/gui-shell.md says it beside "State is shown with a dot".

Tests
- status-dot-shape.test.cjs (new): for all 9 pairs with the real
  stylesheets, in chromium and webkit, light and dark, 980 and 420 wide:
  the good dot has no mask, the failed one has the x mask and the good
  one's box, and its pixels have ink on the arms and centre and none
  above the centre.
- library-mcp-health.test.cjs: its "a dot, not a stripe" check now
  expects the x for a failed server and a round dot for the rest.

Run at the pushed head (mote, via mote-run)
- status-dot-shape + library-mcp-health: 16 pass, 0 fail (chromium and
  webkit).
- go test -run 'Asset|CSS|Budget|Compress|Revalidate' ./internal/gui: ok.
- At 377e3ca6e + this change (rebase since added only site/ files):
  the 232 GUI files that touch these dots, Test models, Routing, Library,
  check-in or the ledger, in both engines and every language they run:
  3588 tests, 3526 pass, 62 fail. library-mcp-health (2) was this
  change's and is fixed above. The other reds (import-row, models-works-only,
  provider-typed, rest-try-now, routing-order-unknown, routing-row-swap,
  routing-steady) fail the same on a clean origin/main 377e3ca6e copy and
  are filed: #4619, #4391, #4673, #2564/#4127, #4627, #3799/#4585, #3412.
- go test ./internal/gui: TestMainWindowCorners/macOS_26_SDK red on mote's
  macOS 27, #3949; nothing else.

Broken by hand
- The three stylesheets put back to main's: status-dot-shape 10 of 10 red
  ("the failed dot is drawn through the x").
- The x token swapped for a filled circle: red ("the failed dot isn't a
  round dot").

Checked by eye: screenshots of every pair and of the real Usage ledger,
before and after, normal, deuteranopia, protanopia and greyscale
(Machado 2009 feColorMatrix), light and dark. Before, the pair is one
colour in both simulations; after, dot vs x in all of them.

Not tried: the real app in Linux WebKitGTK, Windows WebView2 and
Omarchy's square-corner theme (the mask doesn't depend on border-radius,
so it should hold there); the Playwright engines only.
2026-11-02 07:41:23 +08:00
yetone ad53a23dc8 gateway: X-Magpie-Account takes a percent-encoded name (plugins#615)
StockRabbit (magpie-community/plugins#615, Magpie 0.1.2587, Windows):
pinning the Fingerprint page to the WorkBuddy account 北冥 failed every
sample with "Header 'X-Magpie-Account' has invalid value". A header value
is ASCII on the wire and fetch refuses any other, and the gateway matched
the header only against the account's user (北冥) or its trace id
(workbuddy@北冥/…), so no ASCII form could name that account.

pinTo now matches the value as written or percent-decoded (pinnedName:
url.PathUnescape, kept only when it decodes to valid UTF-8). The trace's
Pinned, the call's error and the 404's "no account %q" name it decoded.
gateway.go:2701 is the one place that reads the value; codex_backend.go,
codex_relay.go and gateway.go:2523 test only that it is present, so they
need nothing. docs/reference.md and the gateway-routing page say how to
send such a name.

Run at this head (rebased on c3048cd26, which changed no gateway file):
- mote: go vet ./internal/gateway for darwin, GOOS=linux, GOOS=windows: ok.
- mote: go test -run 'TestAccountPinned|TestCodexPoolSaysTheClientsVersion|Pin'
  ./internal/gateway: ok. gofmt -l: clean.
- mote, at the pre-rebase head: go test -timeout 45m ./internal/gateway:
  one red, TestCodexPoolSaysTheClientsVersion (User-Agent 0.165.0 where
  0.161.0 was sent), which is #4807 (red in a full package run on mote,
  passes alone); it passes alone at this head and at origin/main c3048cd26.

Broken by hand: pinnedName returning the raw value turns
TestAccountPinnedPercentEncoded red (404 no account "%E5%8C%97%E5%86%A5").

Not tried: a real WorkBuddy account named 北冥 (the test uses a Codex
account of that name through the same pinTo); Windows.
2026-11-02 07:20:01 +08:00
ggbdpq 49c99e18d1 provider: quota history draws measured windows set aside for routing (#4612)
chowyuan1314: the Cursor plugin marks its Weekly window aside when
on-demand or free credit can pay, and Grok Bot always — using them up
doesn't stop the account, so routing sets them behind — and both carry a
real percentage. pointOf refused every window set aside that wasn't a
pool's, so quota-history.json took no point for them and the card had no
curve, while the same account's Codex windows drew theirs. The aside
check predates the pools' (#651); the pools' own exception (14e4d8040)
freed only the row the card shows, not every measured window.

Aside is for routing, not history: what a window says is drawn
independently of whether using it up stops the account. pointOf now
refuses only what has no share to tell — a window whose text alone is
told (Text), an unlimited one, a family's, an unnamed one, a NaN — so a
pool's window needs no exception of its own and every measured aside
window keeps its line: the Cursor plugin's Weekly and Grok Bot, Copilot's
completions, a Factory account's windows read while it may spend extra.

Factory's "Extra usage" row, a balance in cents, told no share either and
stayed out only because it was aside; it is Text now, its display alone —
as Claude's row of the same name already is (claudeOveragesWindow).
Without it, the new condition would have drawn it as a fictitious 100%
left.

Routing reads Aside where it did; nothing is set aside that wasn't.

Run (at d1a94f579 + this change, macOS arm64):
- TestQuotaHistoryKeepsAsideReadings and TestFactoryExtraUsageIsTextAlone
  (new) fail before and pass after; TestQuotaHistoryKeepsAntigravityPools
  now also expects the aside "Extra" window's line, the new rule's own
  doing.
- go test ./internal/provider -tags nogui -count=1: ok.
- gofmt -l clean; go vet ./internal/provider, GOOS=linux and
  GOOS=windows (nogui) clean; builds darwin, linux, windows ok.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-02 05:38:10 +08:00
yetone 611ce90d15 agent: OpenBot, magpie's models in its model picker (jiezhengj)
OpenBot (nightly-labs/openbot, openbot.run, v0.58.0) is a new row on the
Agents page. jiezhengj on Discord asked for it: today they type magpie's
address into OpenBot by hand and add each model one at a time.

OpenBot lists the user's own OpenAI-compatible endpoints from
openbot-custom-providers-v1.json in its userData folder:
~/Library/Application Support/OpenBot, %APPDATA%\OpenBot, or
~/.config/OpenBot. Connecting adds an entry with id "magpie" pointing at
the gateway's /v1 and holding the models picked for OpenBot, with
secret null. OpenBot seals an entry's key in safeStorage, which magpie
doesn't open, so the entry has no key. OpenBot hands it to OpenCode
keyless, and the gateway accepts it as a request from this computer.

What the entry keeps to:
- OpenBot's decoders drop the whole list over one bad entry. So the entry
  has at most 64 models, only ids OpenBot accepts as magpie/<id>, and a
  context window only inside 1,024 to 100,000,000.
- The user's other entries stay. The name, harness and secret they give
  magpie's entry in OpenBot stay too.
- A sync with nothing to change doesn't write.
- A file whose version isn't the number 1, or whose providers isn't a
  list, is one OpenBot refuses itself, so magpie leaves it alone.
- Disconnect takes out magpie's entry, and the file too when only the
  version and an empty list are left.

OpenBot reads the file at start, so while it runs, a notice says to
restart it. The notice is in every language.

OpenBot is detected by its userData folder, OpenBot.app
(app.openbot.desktop), or OpenBot.exe under %LOCALAPPDATA%\Programs or
%ProgramFiles%. Docs updated: agent-wiring.md, reference.md, and both
READMEs.

Run at the pushed head, on mote:
- gofmt -l: clean.
- go vet -tags nogui for internal/agent and internal/gui, and for ./...
  with GOOS=linux and GOOS=windows: ok.
- go test -tags nogui -count=1 -timeout 45m on internal/agent and every
  package that imports it (., backup, cli, davsync, gui, library,
  profile, stats, tui, uninstall, plugins/...): ok.
- GUI: agent-notice-lang, i18n-keys, header-relang and about-notices in
  Chromium and WebKit: 58 of 58 pass.

After rebasing on d20caffae (appdir, i18n.js and gui changed on main), these were run again: gofmt; linux and windows vet of agent, gui and appdir; go test of the same three: ok. The four GUI files plus checkin-now-account: 80 of 80 pass.

Real OpenBot 0.58.0: the arm64 zip, sha512 checked against
latest-mac.yml, notarized by Akudama GmbH. It ran on mote under a
sandbox HOME with --user-data-dir and --use-mock-keychain, on a file
that magpie's own openBotWire wrote.
- OpenBot started without setting the file aside.
- Asked over CDP, window.openbot.customProviders.list() returned magpie's
  entry with all three models and harness opencode.
- Saving another endpoint in OpenBot wrote magpie's entry back unchanged.
- The notice's pgrep pattern matched the running OpenBot.

Broken by hand, each red:
- the 64 cap
- the id filter
- the version check
- keeping the user's name, secret and harness
- writing version 1 into a new file
- the notice's Running check

One break stayed green: dropping openBotWire's own no-change check.
edit.SetJSON already skips a write that changes nothing, so the test
holds at that layer.

Not tried:
- a chat through OpenBot to the gateway. OpenBot's onboarding and its
  OpenCode download were not gone through, so no request reached magpie.
- OpenBot's MCP servers. They live in its SQLite database, which magpie
  doesn't write; magpie's /mcp/magpie/... servers are added by hand.
- Windows. Its install folder is read from electron-builder's defaults,
  not from a real install.
- Linux and the AppImage.
- A request from OpenBot is counted under OpenCode's name, since
  OpenCode sends it.
2026-11-02 05:37:32 +08:00
yetone e87140242b settings: Check in now for one account, its switch left as it is (xiaowu_95660)
xiaowu_95660 (Discord #general) asked for a way to check in one account
right now where its daily check-in switch is, without turning the switch.

- provider: a checkiner can be held to one account (`only`), and
  CheckInAccount(ctx, by, key) runs the same claim path once for it, for
  WorkBuddy, Trae, MiniMax, Qoder and every plugin with a check-in.
  CheckinOff is not read or written.
- gui: POST /api/usage/checkin-account {By, Key}. Settings' daily check-in
  group (built-ins and plugins) gets a "Check in now" row under its
  accounts. One account checks in at once; several open the app menu to
  pick one. The line says done, already checked in, not eligible,
  inactive, captcha, own-app or the failure. Only quotas reload, so
  Settings isn't redrawn under the button.
- The row and press live in the lazy checkinnow.js (core budget unchanged,
  three check-in comments cut). Once loaded it draws at once, so a redraw
  by the switch doesn't shorten the page for a moment.
- Strings in zh, zh-TW, ja, de. provider-plugins.md says how it works.

Run at befdfa72b (on origin/main d89f03aa9; 4ffd5b96d, the Cursor min line, landed after), on mote:
- gofmt -l clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet of
  internal/provider and internal/gui ok.
- go test ./internal/provider ok. go test ./internal/gui: only
  TestMainWindowCorners/macOS_26_SDK red, the same at base de7953e3b
  (#3949, macOS 27 box).
- GUI, chromium and webkit, every language, narrow widths: checkin-now-
  account (new), checkin-account, plugin-checkin, checkin-reason,
  checkin-reason-once, checkin-early-done, usage-checkin,
  qoder-checkin-recheck, settings-groups, settings-lines-wrap,
  click-scroll, old-webkit, i18n-keys: 252 of 252 ok.
- Earlier at the pre-rebase head: warm-now webkit 440 en/ja/de click
  timeouts (#4322) and segs-press-redraw (#4566) red, both the same at the
  base.

Broken by hand: without the `only` branch in reaches(),
TestCheckinOneAccountNow goes red (every account is claimed). Loading
checkinnow.js after every redraw made checkin-account's "the switch moved
the page" red on webkit 420 zh/zh-TW/ja; fixed as above.

Not tried: the whole GUI suite (another session's full suite was running
on mote); a press against a real account (no real claim was made).
2026-11-02 05:22:12 +08:00
yetone 3f393a4fae redact: a user name is not masked where code has the same word as a name (Tomyu_2034 on X)
Tomyu_2034 on X: "magpie 里面的 masking 很容易把参数变量名当成 user name
给 mask 掉". No sample was given, so the class was measured: with "User
name in home folders" and "User and computer names" on, two finders took
names in code for the user's.

- Known values (known.go). A user name the home rule found once
  (/Users/developer/…) is known from then on when it is 8 bytes or more,
  and standsAlone's default bound is a letter or a digit only, so it was
  masked wherever the word stood between anything else: def
  run(developer, developer_dir), developer_mode = True, const developer
  = 1, {"developer": true}, -    developer_count := 0 in a diff, a tool
  call's old_string. A user name such as developer or workspace1 is a
  word code has too.
- The "User:" line rule (more.go). Its unquoted value was any
  login-shaped word, so user = current_user, user: UserInfo, login =
  loginName, username = target_name, a Go struct's "\tUser  UserProfile"
  and a TS interface's "user: CurrentUser" went as made-up names.

nameAlone now decides a known USERNAME: it is the user's name as a word
of its own in text (a path's part, name@host, --author=name, ls -l's
owner, uid=501(name), prose, a quoted string, chown name:staff), and
code's where it is joined to another part (_ $ a letter or digit beside
it, or a . or - with one past it), declared (const/let/var/def/func/
class/return/import…), assigned or called (name =, name(, name[,
name :=, x = name), a JSON key ("name":), or a parameter ((name, ,name)
name: str, name string), but for id's 501(name)). Nothing is exempted
by a key's name: a tool call's arguments are read by the same rule as
any text, and a quoted value in them is masked as before. The "User:"
rule leaves an unquoted value made of two or more words (split at _ .
and camel humps) one of which says it holds a user (identParts: user,
name, login, current, target, info, obj, id…); a quoted one, and a
login of words of its own (deploy_bot, john_doe), are masked still.

The boundary costs this: prose that puts the name alone in a list
"(developer, alice)" or before "=" now goes as written; such text reads
as code to this rule. A name under 8 bytes was never matched as known,
so for those only the "User:" half changes anything.

Tests (identname_test.go), with "developer" (a common word) and
"rinakato" (a handle), known from a working directory first:
- TestUserNameInCodeIsNoUserName: a Python and a JS file read, a JSON
  file, Go code, a diff and an edit tool call's arguments go as written;
  a home path, --author=, ls -l, uid=501(), prose, a quoted string, a
  JSON value, chown and a bash tool call's ~name go as the made-up name.
- TestUserLineInCodeIsNoUserName: seven code lines unmasked; User:
  deploy_bot, USER=rinak, user: "current_user", ssh config's User and
  user = john_doe masked.

Broken by hand: with more.go and known.go as on main both tests are red
(12 and 7 failures); with standsAlone's USERNAME case returning true,
TestUserNameInCodeIsNoUserName alone is red.

Run at this head (on origin/main 89ffc58f5; nothing since touches
internal/redact or the doc), on mote:
- gofmt -l clean; go vet ./internal/redact ./internal/masking, and
  GOOS=linux -tags nogui and GOOS=windows go vet ./internal/redact: clean.
- go test ./internal/redact ./internal/masking ./internal/otlp
  ./internal/pii ./internal/sessions ./internal/settings: ok.
- go test ./internal/gateway -run '(?i)mask|redact|privacy|personal|
  standin|restore': ok.
- go test ./internal/gui: TestMainWindowCorners/macOS_26_SDK red, the
  AppKit title bar on mote's macOS 27 (#3949, open); nothing else.

Not tried: the full internal/gateway package and go test ./... (the
gateway takes ~45 min; pushed at once per the owner's ship rule); the
local model's PERSON finds, which already leave snake_case and
lower-case words (modelTakes, programWords); the home rule's
"/home/<segment>" in a web route ('/home/dashboard'), which reads as a
home folder and is unchanged; a real request with the reporter's code.
2026-11-02 04:49:42 +08:00
yetone a8e98e1abb gateway: a Claude Code run that exits mid-reply is a failure, not a 200 (#4822)
A Claude subscription run whose Claude Code exited after its reply began,
with no message_stop nor a result (only the message_start, or part of the
text), closed its segment as if the reply had ended. The client was
answered 200 with nothing or the words so far, and the agent took it as a
finished turn.

- readOutput: at the end of Claude Code's output, a reply begun on the
  open segment (KStart, tracked in emit as unended until a KStop or
  KError) ends with a KError, 502, "Claude Code exited before it ended
  its reply" and the end of its stderr. -p and the interactive mode share
  this path.
- relay, not streamed: any error is a status, words said before it too
  (was: a 200 with the partial reply), as a translated reply cut short is
  (errEndedShort). The try's usage is kept as before (d2a83de61).
- Streamed with nothing sent yet: the head's KError is a status, as
  before, so the spare answers by the existing failover rules, and the
  cut try keeps its handed_on usage row. Streamed after text: the
  protocol's error event (Anthropic `error`, chat's error chunk with no
  [DONE], Responses' response.failed), no end event, no other run.
- A reply that ended with message_stop, or whose stop was told, is
  unchanged.
- The tests' fake Claude Code (claudeSubscriptionFirstSays) answers
  control requests, so it runs in the interactive mode too.

TestClaudeSubscriptionRunExitedMidReplyFails: message_start then exit and
text then exit, on /v1/messages, /v1/chat/completions and /v1/responses,
streamed and not, -p and interactive (24 cases): the spare's answer and
the cut try's handed_on row (900 cache write) where nothing was sent, the
error event and no end where text was streamed.

Run, at this tree on origin/main 89ffc58f5:
- mote: go test -run TestClaudeSubscriptionRunExitedMidReplyFails
  ./internal/gateway ok (24/24); go vet -tags nogui ./internal/gateway
  for darwin, linux and windows ok; gofmt -l clean.
- mote: go test -tags nogui -timeout 45m ./internal/gateway
  ./internal/claudetui: claudetui ok; gateway red on
  TestCodexPoolSaysTheClientsVersion alone (#4807, another test's Codex
  identity, open and passes alone; this change doesn't touch Codex).
- Full suite (go test -tags nogui -timeout 45m ./..., Linux, wsl-run)
  was still running at push time; internal/agent's install-detection
  reds there are #4033. Its result goes on #4822.
Broken by hand: with claude_subscription.go at origin/main, all 24 cases
red (200, runs "own", partial or empty reply). With the relay change
alone reverted, the 6 text/not-streamed cases red (200 partial).
Not tried: a real Claude Code whose upstream cuts the stream and exits
mid-reply. A non-streamed reply cut after text now goes on to the spare
account, which is billed for the conversation again (the client gets a
whole answer instead of a cut one, as for translated providers).
2026-11-02 04:38:57 +08:00
yetoneand胡峻果 89ffc58f5b gui: a card's Refresh says the read's failure, and Claude Code's first-run screens say what to do (#4817, uiuing)
From uiuing's branch (1eeb8928b, 66818dbf6), adapted. A usage card's
Refresh showed nothing when the read came back as a card with an
error: only a thrown request reached status. quotaRefresh now says the
refreshed card's error through quotaError, for a single account and
for a provider whose cards were replaced (the one kept in quotas).
quotaError reads the helper's new "stays on its first-run screens" and
an older magpie's "shows its first-run notes" as "Finish Claude Code's
first-run setup, then refresh", in en, zh, zh-TW, ja and de. Comments in
quotaError and quotaRefresh were cut so the core scripts stay in their
budget (1,533,732 of 1,533,802; main was at 1,533,780), with no raise.

Run at the pushed head, on mote: node --test of claude-quota-onboarding,
quota-refresh-order, usage-card-refresh, usage-refresh,
usage-refresh-flight, account-refresh, editor-quota-quiet,
usage-no-reading, usage-remote-cards, tray-usages, glm-quota-error,
claude-usage-asked, allowance-open-read, api-key-usage,
key-balance-card, copilot-signed-out-account, signin-again, plugin-git
and i18n-keys (chromium and webkit, every language each file runs, 440px
where it sets it): 287 of 287.
go test -run 'Budget|I18n|Lang' ./internal/gui ok.
go test -run "Claude|TUI" ./internal/gateway ok. The full
./internal/gateway (-timeout 45m, before the rebase onto 6b3a6d42c) is ok but for
TestCodexPoolSaysTheClientsVersion, #4807 (another test's Codex
identity reaches it in a full run); nothing Claude or GUI.

Broken by hand: without the new status line, 13 of the 31 tests in
claude-quota-onboarding and quota-refresh-order go red (all ten
engine/language cases and three VM ones).

Not tried: the real app's card against a real signed-in Claude Code
that stays on its notes.

Co-authored-by: 胡峻果 <uiuing@foxmail.com>
2026-11-02 04:19:23 +08:00
yetone af4ff747bc claudetui: Claude Code's first-run screens are gone through as a person would, not the run's end (#4817, steven_4422 on Discord)
With "runs as" Interactive, a Claude Code whose onboarding was never
finished (no hasCompletedOnboarding in the state file: steven_4422's
every request 502'd, uiuing's /usage read in #4817) stopped on the
"Security notes" screen, and 88a0262bf ended the run there. A person
presses Enter. The helper now does the same:

- "Choose the text style": Enter (as before, now after the settle);
- "Security notes: ... Press Enter to continue": Enter;
- "Use Claude Code's terminal setup? ... Esc to skip" (shown for
  TERM_PROGRAM Apple_Terminal or vscode): Esc, so no one's terminal
  settings are changed.

Each key waits until its screen has stayed drawn trustSettle (300ms),
as the trust dialog's does, and each screen gets onboardTries (3)
presses; one that is still shown after that ends the run with "stays on
its first-run screens, its onboarding not done; run Claude Code once in
a terminal and go through them", plus the screen. Claude Code then
records the onboarding done itself (hasCompletedOnboarding,
lastOnboardingVersion); magpie writes nothing in the user's
.claude.json. There is no -p fallback: with On nothing runs as -p (the
owner's 11-01 call, e5f66f8a6).

Run at the pushed head, on mote: go test ./internal/claudetui ok;
gofmt -l clean; go vet darwin, linux, windows ok. wsl-run claudetui ok
(at the pre-rebase base). win-run claudetui: TestShimGoesThroughOnboarding
and TestShimNeverPrints pass; TestShimFirstMessageWaitsForTools (#4810)
and TestShimReadsUsage (#4820, filed for this) fail the same at
origin/main eb3b9376e on Windows. go test -run "Claude|TUI" ./internal/gateway ok;
the full package ok but for #4807's TestCodexPoolSaysTheClientsVersion.

Real Claude Code 2.1.316 (npm darwin-arm64) on mote, through a built
magpie's claude-tui-helper, in fresh sandbox HOMEs with a fake
CLAUDE_CODE_OAUTH_TOKEN and ANTHROPIC_BASE_URL at a closed port, for
TERM_PROGRAM unset, Apple_Terminal and vscode: the first run got
through theme, notes (and terminal setup) and trust to init in 5-6s,
the second in 2s; .claude.json then had hasCompletedOnboarding true and
lastOnboardingVersion 2.1.316, settings.json theme dark.

Broken by hand: no Enter on the notes, both TestShimGoesThroughOnboarding
subtests red; Enter instead of Esc on terminal setup, "the user's
terminal was set up" red. Taking the settle out still passes (the fake
redraws and is answered again), so the settle is not guarded.

Not tried: a real signed-in account (no token was provided), so no
request past init; real Claude Code on Windows or WSL; iTerm or other
TERM_PROGRAMs whose onboarding may show other screens.
2026-11-02 04:19:23 +08:00
yetone 62ffc40169 gateway: a waiting request goes to an account back from rest (01huadalang)
01huadalang on Discord (11-01): three ZCode accounts, three requests at
once each. The first two got a 405 and rested, so every request went to
the third, and those over its three waited in its lane. Once the first two
were back, the waiting ones stayed on the third, behind its long turns,
until its requests were cut by hand. Same under Smart, In turn and Stays
off.

Cause: a request that queued in a lane (lanes.take) waited only for that
lane's turn. Nothing looked again when another lane gave a slot back or a
rest ended. With ZCode's maxAccounts 2, the third took a seat while the
first two rested and was a reserve again once they were back, but the
requests already waiting for it stayed. laneMate also gave way to a mate
resting, because ready() checks only lane and RPM room.

Change:
- lanes.take takes a move func. While waiting (lanes.await), it looks
  again when any lane gives a slot back, when a rest is lifted (Unrest,
  UnrestAll signal lanes.freed), when the soonest rest among the others
  ends, and at least every 5s (laneRecheck). waitMate finds the first
  candidate after it in the planned order (then those probeOne left out
  for resting) of the same provider, or any member of a group, that has
  a free slot with no queue (tryTake), minute room, isn't resting, didn't
  give way, and isn't a reserve as keepAtOnce stands now. The request
  then leaves its queue (errMoved) and serve runs that candidate with the
  slot already taken for it. A fallback provider is never one. Strict
  stays leave no other candidate, so nothing changes there.
- laneMate skips resting mates.
- docs/subsystems/gateway-routing.md Limits row says so.

Tests:
- TestWaitingRequestGoesToAccountBackFromRest: 3 keys, cap 3, MaxAccounts
  2, k1 and k2 resting (405), 9 requests. 3 go to k3, 6 wait for it, and
  none reach the resting two. Then the rests are lifted (Unrest) or run
  out (300ms), and the six go to k1 and k2 while k3's three are still
  out (9 at once). Run under Smart and Rotate, with Stays default and
  off.
- TestWaitingRequestTakesSlotGivenBackElsewhere: 2 keys, cap 1. A third
  request waiting for one key goes to the other when that one's request
  ends, under default, order, rotate and usage routing.
- TestFullMemberGivesWay updated. c, waiting for first, now goes to second
  once second's b ends. d (first's fallback is second) still waits for
  first.

Run on mote (mote-run), rebased on e65bc8473:
- go test -count=1 -timeout 45m ./internal/gateway: every test ok
  except TestCodexPoolSaysTheClientsVersion (608s; #4807, below)
- go vet ./internal/gateway, GOOS=linux (-tags nogui), GOOS=windows: ok
- gofmt -l: clean
- go test -race -count=10 on the three tests above: ok
- That red is #4807, also the only red in an earlier full run (it passes alone,
  here and on origin/main e65bc8473; another test's Codex version reaches
  it).

Rebased again on 6b3a6d42c (VS Code agent host, gateway.go): at this
head, vet for darwin, linux and windows ok, gofmt clean, and go test -run
'Lane|Waiting|FullMember|AtOnce|VSCode|Vscode|AgentHost|Concurrency|
Queue|Rest|Probe|Affinity' ./internal/gateway ok (44s).

Broken by hand:
- On origin/main's code, the new tests and the updated
  TestFullMemberGivesWay are red. The rest test fails at "six waiting for
  k3" because laneMate handed requests to the resting keys.
- With waitMate's move ignored (if ok && false), every case is red at
  "the waiting ones at k1 and k2", and so is TestWaitingRequestTakesSlot-
  GivenBackElsewhere.
- With the rest's end ignored for the recheck timer (only laneRecheck),
  the four "ran out" cases are red.
- Two test races were found under -race and fixed in the test: the rest
  was timed from before the nine were sent, and the concurrency count was
  read before the ninth reached the fake vendor.

Not tried: real ZCode accounts or the ZCode plugin. The plugin's own 405
handling and maxAccounts are as before. Not run on Windows or Linux
machines; vet only.
2026-11-02 04:17:24 +08:00
yetone 6b3a6d42c0 agent: VS Code's Agents window (vscode_agent_host) counts as VS Code, its turns as Codex's
justruman on Discord (#general, 11-01): VS Code's Agents window showed
in Usage as a raw "vscode_agent_host" row, 23 calls, 7 failed, beside
the "VS Code" row.

Why: VS Code's agent host runs `codex app-server` with clientInfo
{name: "vscode_agent_host"} (microsoft/vscode main at 8fb6054,
src/vs/platform/agentHost/node/codex/codexAgent.ts CLIENT_INFO; it
bundles @openai/codex 0.163.0). Codex sends that name as its
originator and at the head of its User-Agent, and it reads the user's
~/.codex config, so with Codex connected to magpie its turns come here
under VS Code's name. No agent's UA list had it.

- Usage: vscode_agent_host is in VS Code's UA list
  (vscodeAgentHostUA), so those calls are VS Code's. Records are named
  again at read time (ReportedAs -> AgentOf), so calls already logged
  under the raw name fold into VS Code too. Insiders' and VSCodium's
  agent host send the same name and are counted as VS Code (Stable):
  nothing in the request tells them apart.
- Routing: fromCodex also takes vscode_agent_host (hostedCodex), so
  every Codex rule holds for those turns. The one that fails without
  it: one of Codex's own models asked there, which no account in
  magpie serves, was answered 404 "magpie knows no model" instead of
  going on Codex's sign-in (codexOwnOffMagpie). Also now applied:
  spawn_agent's model list, compaction told in the stream on a byte
  cap/overflow, Codex's headers to a keyed Codex-only relay.
- A test asked as Codex keeps only Codex's own names (codexNamed) as
  Codex's shape: the agent host's headers never become it.
- VS Code's Copilot-proxied names (vscode_codex, vscode_claude_code) go
  to GitHub, not magpie, and are not matched.
- docs/subsystems/gateway-routing.md says so.

Run on mote at this change rebased on origin/main 16ce5ed23; the
one commit since, e65bc8473 (#4802), changes internal/plugin and GUI
files only: gofmt -l empty; go vet ./internal/agent ./internal/gateway
./internal/usage for darwin, GOOS=linux -tags nogui and GOOS=windows
ok; go test -count=1 -timeout 45m on the three packages: agent ok,
usage ok, gateway ok except TestCodexPoolSaysTheClientsVersion
(#4807, filed at origin/main 79f83798f before this change; it sends
codex_cli_rs, which this change leaves as it was, and passes alone
at this head and at its base).

Broken by hand, each red: without hostedCodex in fromCodex,
TestVSCodeAgentHostIsCodex, TestVSCodeAgentHostOwnModelGoesOnSignIn
(404 "magpie knows no model \"gpt-6.1-sol\"") and
TestVSCodeAgentHostNotCodexTestShape (relay sent magpie/dev); with
SawClient ungated, TestVSCodeAgentHostNotCodexTestShape (as Codex sent
vscode_agent_host, 403); without the UA list entry, TestVSCodeAgentHostUA.

Not tried: a real VS Code Agents window against magpie (no VS Code on
this machine or mote). The UA and originator are from VS Code's and
Codex's source, not captured bytes, and the terminal part of the UA is
a guess (it isn't matched). The reporter's 7 failures weren't seen:
the 404 above is the failure class the source shows, not one confirmed
in their log. Other checks keyed on agent == "codex" (Codex memory
calls, image drawing on Codex's own models, title links, CodexBusy)
don't apply to these turns, since they are counted as VS Code.
2026-11-02 04:04:47 +08:00
yetone 16ce5ed232 usage: an account whose longer window is used up adds no headroom to the all-accounts sum (#4791)
hayden4608 (Discord) and handong66 (#4791) have four Codex accounts. Three
show 5 hours 100% left with 7 days 0% left, and one shows 5 hours 0% left
with 7 days 22% left. The All accounts strip read "5 hours 75% left", but
none of those three can spend its 5 hours until its week starts again.
The right figure is 0%.

mergeQuotas (quotaall.js) is the one place that sums windows across
accounts. It feeds the Usage page's strip, the tray panel's strip and the
Routing groups' line. The native menu-bar tray, the TUI, the CLI and
/v1/magpie/quotas show one account at a time and are unchanged. The GUI's
JSON doesn't carry Aside, Model or the matches, so the call is made in Go.
provider.WithHeldWindows marks a window heldBy another window of the same
account when that other window:
- stops the account for every model, by routing's rule: not aside, no
  model, no matches, used >= 100, reset not passed, and not Codex credits
  that go on; and
- starts again after this one (by reset times, else by span).
So 7 days used up holds 5 hours, but 5 hours used up doesn't hold a week
with 22% left. /api/usage/quotas and its refresh apply it. mergeQuotas
counts a held share window as 100 used and a held counted one as its
limit, and the strip's tooltip says how many were counted that way
(en/zh/zh-TW/ja/de). The account cards still show the vendor's own figure.

Run on mote (macOS) at this head's parent tree:
- go vet for darwin, linux (nogui) and windows: ok; gofmt -l: none.
- go test -count=1 ./internal/provider ./internal/gui, before the
  quota_span leftOut line and an i18n comment fix. The provider package's
  only red was TestQuotaSpanCarriesEveryWindowField, which wanted heldBy
  named, and it is now named. internal/gui's only red was
  TestMainWindowCorners/macOS_26_SDK, which is #3949.
- GUI, chromium and webkit, every language, 440px and 360px: quota-*,
  usage-* (all-accounts, merge, accounts, fold, refresh and more),
  panel-usage/quota/switch-accounts/balance-order, routing-quota-left,
  routing-group, tray-usage, i18n-keys, gui-de/ja/zh-tw, old-webkit:
  704 of 707. The reds were i18n-keys (a quoted "All accounts" in
  window_held.go's comment, fixed here) and usage-fold's "17
  subscriptions and 29 accounts" in both engines, which is #4790 and is
  red at origin/main too (see below).
At the pushed head, rebased on eb3b9376e, on mote: gofmt none, vet ok.
internal/provider ok. internal/gui is red only on TestMainWindowCorners
(#3949). GUI usage-merge, usage-all-accounts, i18n-keys and usage-fold,
both engines: 44 of 46. The 2 reds are usage-fold's 29 accounts, which
fail the same at origin/main eb3b9376e on mote (noted on #4790).

Broken by hand, each red, then restored (cmp):
- Go, no HeldBy set: both TestHeldWindows tests red (a, b, c not held).
- Go, outlasts always true: red on d and on "a week that starts again
  first".
- JS, held forced false: usage-merge plus all 5 languages of
  usage-all-accounts red in chromium, showing the reporter's
  "5 hours · 75% left".

Not tried: real accounts. The issue names no provider; Codex is assumed
from the cards' 5 hours / 7 days. Not done: marking a card as held by its
week, the reporter's optional second ask. Not written: a handler-level
test that /api/usage/quotas carries heldBy. Not run on Linux or Windows.
2026-11-02 03:46:01 +08:00
yetone eb3b9376ea plugin load: a model listed by another id gets its plugin's load (axelburks)
axelburks on Discord: a plugin reports a model's load through
input.magpie.load by its own model id. A model the user lists in magpie
under another id (Listed as, settings' ModelIDs) showed no load on the
Providers page, and with Busy models last on it was never judged busy;
models whose id wasn't changed worked. The reporter's reading was right:
plugin.ModelLoad keeps the load by the plugin's id and both callers asked
it by the listed one.

Both call sites of plugin.ModelLoad (grep: there are only two) now map the
listed id back through Provider.OwnModelID first:
- internal/gui/providers.go providerInfoWith (models[].load), which
  already computed OwnModelID for models[].vendor; it is now read once
  and used for both.
- internal/gateway/fallback.go busyOf (restLast's busy ordering and the
  trace's busy).
A listed id whose own id is a model@size (grok -> grok-4.7@256k) still
falls back to the model's load inside ModelLoad. The provider-plugins
subsystem page says the lookup is by the plugin's own id.

Tests:
- internal/gui TestModelLoadListedAsAnotherID: a plugin provider with
  fast -> big and grok -> grok-4.7@256k listed, loads noted for big,
  grok-4.7 and small; models[].load must be 87.4 / 60 / 12 for fast /
  grok / small and absent for quiet.
- internal/gateway TestBusyModelListedAsAnotherID: busyOf at 80 judges
  fast, grok and big busy, and an unreported model not.

Run at the pushed head on mote (mote-run):
- at base de7953e3b with this change: gofmt -l clean; go vet of
  internal/gui, gateway, plugin for darwin, GOOS=linux (-tags nogui) and
  GOOS=windows: ok. go test -count=1 -timeout 45m ./internal/gui
  ./internal/gateway ./internal/plugin: plugin ok; gui red only on
  TestMainWindowCorners/macOS_26_SDK (#3949, macOS 27 corners) and
  gateway red only on TestCodexPoolSaysTheClientsVersion (#4807, another
  test's Codex identity in a full package run); both filed, neither
  touches loads. internal/gui/tests/model-load.test.cjs (Chromium and
  WebKit, every language, narrow and wide): 82 of 82 pass.
- at the pushed head 7a804cf03 (rebased; the rebase changed none of the
  touched files): vet for the three OSes ok, and go test -run
  "Load|Busy|ListedAs" of internal/gui, gateway and plugin: ok.

Broken by hand: with both call sites put back to m.ID / c.model, both new
tests fail ("fast: no load, want 87.4", "grok: no load, want 60";
"fast: load 0 busy false", "grok: load 0 busy false"); restored, both pass.

Not tried: a real plugin reporting loads in the running app with a
renamed model (the reporter's in-house vendor plugin isn't available
here); model-load.test.cjs fakes the API, so it checks the badge's
drawing, not this lookup. No full go test ./... (another session's full
suite was running on mote).
2026-11-02 03:40:03 +08:00
yetone d2a83de612 gateway: a try billed before it failed and handed on keeps its usage row
A Claude subscription run that fails after Anthropic's message_start
(an overload, a dropped connection, a cut stream Claude Code gave up on)
is a 502 so another account can take over. That account is a new Claude
Code told the whole conversation, and writes it to its own cache again.
The first try's usage was dropped twice over: relay threw away the reply
start's usage on that path, and serve wrote a usage row only for the
request's last try (and for refusals). The Usage page counted the second
account's tokens alone, with "2 tries" on the row as the only sign that
the conversation went out twice (hhxk233 and Kayrainforest on X).

- relay keeps the usage of the head's KStart/KUsage events on a failure
  before content (streamed), and the collector's usage (not streamed).
- serve writes a handed_on row for any failed try that billed something
  and handed the request on, to another account or member or the same
  one again. The row is written when the next try begins. The refusal
  and turned-away paths keep their own row, and a failure that billed
  nothing still has none. Totals count a handed_on row's tokens, not a
  request, as for refusals. The Usage page already shows such a row as
  "<status> · handed on" with its tooltip in every language.

No same-account double send was found: a fake Claude Code breaking its
stream in nine ways (error before or after message_start, a 529 or 500
result, a cut then an error or an exit, text then an error or an exit),
streamed and not, starts one run per account at most. A failure before
content goes on to the spare once. A failure after text ends the
request with no other run.

Run, at this tree on origin/main de7953e3b:
- mote: go test ./internal/gateway -run 'TestClaudeSubscriptionFailedTryKeepsItsTokens|TestClaudeSubscriptionRefusal|TestClaudeSubscriptionBigRefusal' ok;
  -run 'Retried|SearchInstead|HandedOn|Refus|Loop' ok (25.5s); gofmt -l clean.
- The full suite (go test -tags nogui -timeout 45m ./..., Linux, wsl-run)
  was still running at push time. mote had other sessions' suites the
  whole hour. Its result goes in a follow-up if it shows a red.
Broken by hand: with the failedRow() call commented out, the new test is
red ("handed-on rows: []", both stream modes). With relay's change alone
missing, it was red the same way.
Not tried: real Claude Code against a mock Anthropic that cuts the
stream. Claude Code's own stream-to-non-stream fallback (strings in
2.1.316) resends inside one run. magpie's ledger can't see that, and it
happens the same without magpie.
2026-11-02 03:38:42 +08:00
yetone ccd746e039 claude: /usage is read in the interactive mode, typed in it, not through -p
With the interactive mode on, the plan's allowance (the Claude account's
usage card) was still read by `claude -p /usage`, the one -p run left
beside a request. Claude Code 2.1.316's -p /usage also tells only the
session's cost, no window. Now claudeUsage, with claudeTUIOn, runs the
interactive mode's helper (claudeUsageTUI) and gives it a line
{"type":"command","command":"/usage"}. The helper types /usage, waits for
the panel to settle (a "N% used" and a second without change, or three
seconds of anything else, 20s at most), closes it with Esc, and tells
what was drawn as -p's lines say it (usageText: "Current session: 0% used
· resets 5am (Asia/Shanghai)"), so parseClaudeUsage reads it unchanged.
No model is asked. The helper types no other command. The machine
reasons a request is refused for (no shim, OS, missing, off) refuse the
read the same way. Turned off, -p runs it as before.

Run (mote, at this tree on origin/main a25d3d081):
- gofmt clean; go vet internal/gateway and internal/claudetui for darwin,
  windows, and linux with -tags nogui: ok.
- go test -run 'Usage|Claude|Command' ./internal/gateway
  ./internal/claudetui ./internal/provider: ok (59.9s, 4.1s, 25.2s).
- New tests: TestShimReadsUsage, which uses the bytes Claude Code 2.1.316
  drew for the panel (testdata/usage-2.1.316.bin), TestShimRunsNoOtherCommand,
  TestUsageText and TestClaudeUsageTUIOn.

Real run (this Mac, sandbox HOME, Claude Code 2.1.316, the test account):
the built helper with claudeTUIUsageArgs and the /usage line answered in
6.1s with local_command "usage" and "Current session: 0% used · resets
5am (Asia/Shanghai)" / "Current week (all models): 98% used · resets Nov
4 at 6am (Asia/Shanghai)". Exit 0.

Broken by hand: with claudeUsage's claudeTUIOn branch off,
TestClaudeUsageTUIOn read "Total cost: $0.0000" from -p and went red.
With usageText's reset dropped, TestShimReadsUsage and TestUsageText went
red.

Not tried: a plan with overages on, or a Team/Enterprise plan's panel;
both are read through the overages line and the "no window" fallback
only. Not run on Windows or in WSL. No GUI file changed. Not run: the
full gateway suite.
2026-11-02 00:39:54 +08:00
yetone a25d3d0815 claude: a JSON schema is answered in the interactive mode, through an answer tool
With the interactive mode on, a request with a JSON schema was refused
with a 400 since v0.1.2592: interactive Claude Code takes --json-schema and does nothing
with it, its StructuredOutput tool being -p's alone. It now runs in the
interactive mode like any other request.

- serveClaudeSubscription compiles the schema (santhosh-tekuri/jsonschema
  v6.0.3, draft-07 unless it says otherwise, as -p reads one; a $ref
  outside the schema is refused, never fetched) and adds an answer tool,
  StructuredOutput or a numbered name apart from the client's tools, with
  the schema as its input schema, through the bridge's MCP server. A
  schema that can't be compiled is a 400 before any run.
- mcpCall checks each call against the schema: one that doesn't fit is
  told why (isError) to be made again, as -p's is; one that fits is kept.
- At the turn's result the kept input is the reply's structured output.
  A turn that ended with no call is told once to call the tool, and
  fails "no answer fitting the schema" if it still doesn't. Neither the
  call nor the words around it reach the client.
- claudePrint no longer lists the schema. The two refusal tests
  (TestClaudeTUIOnRefusesPrint, TestClaudeTUIRefusalIsNoAccountsFault)
  now use the case that is still refused before any run: an image by
  its URL that can't be downloaded (127.0.0.1, which magpie never
  fetches).
- The provider editor's card no longer says -p takes "a JSON schema"
  the interactive mode can't (en, zh-CN, zh-TW, ja, de).
- docs/subsystems/claude-subscription-bridge.md: the refusal list, and
  how a schema is answered.

Run:
- A real run, haiku, the test account in a sandbox HOME, real Claude
  Code 2.1.316 through the helper with --json-schema and a stdio MCP
  server named magpie serving the answer tool and its description: the
  result's structured_output was null (the premise), and the model
  called mcp__magpie__StructuredOutput at once with
  {"color":"Sky blue","hex":"#87CEEB"}, which fits the schema's
  pattern. 7.2s, one turn. Not run: the whole gateway path with a real
  account (the unit tests drive it with Claude Code's real transcript
  rows).
- mote, at this tree (base 14e351378, origin/main just fetched): gofmt,
  go vet (darwin, windows, linux -tags nogui), go mod verify ok;
  go test ./internal/gateway ./internal/claudetui: claudetui ok, gateway
  red in TestCodexPoolSaysTheClientsVersion only, which is #4807 (red in
  a full package run on mote, another test's Codex identity reaches it);
  alone at this tree -count=3 ok. claude-mode 44/44 and i18n-keys 4/4 in
  chromium and webkit.
- Broken by hand: answer() taking every call without checking it made
  TestClaudeTUISchemaAnswer red ("a call that doesn't fit was told
  Answer received.").
2026-11-02 00:35:21 +08:00
yetone 14e3513780 claude: Claude Code in WSL runs interactively when Windows can't read its transcripts
With the interactive mode on, Claude Code in WSL was refused with a 502
in two cases: the distro user's own folder unreadable from Windows
(\\wsl$ needs the 9P redirector, which a session over ssh hasn't;
"wslread") and a distro whose home the probe didn't find ("wsl-home").
Both now run interactively: the helper reads the transcript inside the
distro.

- claudetui/wslread.go: before Claude Code starts, a shell run through
  wsl.exe notes how much of $HOME/.claude/projects/*/<sid>.jsonl is
  there (a resumed session's earlier turns), says "ready", then tail -F's
  the rest; the helper copies it to a file of its own and tails that as
  any transcript. When Claude Code ends it waits for the copy to stop
  growing (settle), then closes the shell's stdin, which ends it.
- claudetui.WSL gets Distro (Projects omitempty); the gateway's tuiWSL
  sets it when Windows can't read the folder or the home is unknown.
- the wslread and wsl-home refusals are gone (claudeTUI, claudeWhy,
  claudeNotTUIWhy); the GUI's "wsl-home" reason and its 4 strings too.
- docs/subsystems/claude-subscription-bridge.md says how it is read.

Run, at origin/main ff65ebd14 plus this change (the reader through real
wsl.exe and the break-by-hand at 546cdbde6):
- WSL (magpie-desktop, go1.26.8): go vet -tags nogui, GOOS=windows vet,
  GOOS=darwin CGO_ENABLED=0 vet of claudetui ok; go test ./internal/claudetui
  ok; go test -run 'Claude|WSL' ./internal/gateway ok (51s);
  claude-mode.test.cjs chromium + webkit 44/44; i18n-keys 4/4.
- Windows 11 (xiaomi-gpu): go vet ok; go test ./internal/claudetui ok
  but TestShimFirstMessageWaitsForTools, red the same at main 2739626c3
  (bee3ea675's test, #4810);
  go test -run 'Claude|WSL' ./internal/gateway ok with
  TestClaudeAsRootEnv skipped: it is red the same at main 546cdbde6 on
  Windows (#2425, a root test where magpie is never root), at 546cdbde6.
- the reader through the real wsl.exe into magpie-desktop (a temporary
  test, not committed): ready in 93ms, the line already in the file left
  out, two lines written after copied, stopped in 9ms, no tail left in
  the distro.

Broken by hand: tuiWSL not setting Distro: TestClaudeTUIWSL red ("its
own folder, unread": Distro empty).

Not tried: a real Claude Code turn in WSL over ssh (real runs stay on
this Mac); mote (its disk is full); the full go test ./... .
2026-11-02 00:12:40 +08:00
yetone 59fdab0af7 gateway: a caller's folder the user hasn't trusted runs in magpie's, not a 502 (lwjef on X)
lwjef (X, 2116867007799030000): a cwd Claude Code hasn't trusted hangs
the interactive-mode bridge (paseo chat).

Cause: in the user's own account the helper leaves the trust question
to the user (no MAGPIE_CLAUDE_TUI_TRUST) and ends at once saying so. Up
to 11-01 that run became -p; since e5f66f8a6 nothing runs as -p, so the
turn got a 502 (endedBefore, "Claude Code asks whether to trust the
folder"). A Claude Code client such as paseo's asks again with backoff
on a 5xx, so the chat looked hung. The real Claude Code 2.1.309 in an
untrusted folder (sandbox HOME, copied account) ends the helper in 1.3s
with that line.

Fix: startTrusted runs startRun, and when the helper ended over the
trust question (its stderr read to the end, saidOnEnd) in the caller's
folder under the user's own account, remembers that folder for 10
minutes (passedOver) and starts the run once more in magpie's own folder,
told the caller's (envElsewhere), as a caller on another computer is.
Only one retry: a second refusal is returned as before. The saved-session
retry in start goes through startTrusted too.

Run (mote, at this tree):
- go test -run 'Claude|MCP|Bridge' ./internal/gateway: ok
- TestClaudeTUIUntrustedFolderAnswered: ok

Broken by hand: saidOnEnd returning false made the new test red (502
"exited before it answered magpie's initialize request ... trust the
folder"); passedOver turned off made it red with the same 502 after one
retry. An earlier draft that retried through start itself looped forever
with passedOver off; the retry is bounded to one since.

Not tried: a real gateway turn from paseo; the real helper and Claude
Code were run on each side of the retry (untrusted folder ends at once;
a trusted magpie folder answers), not through a live gateway. A user who
trusts the folder within 10 minutes still runs in magpie's folder until
then.

At the pushed head's tree, on origin/main 79f83798f (which has 2b52302dc,
crosscn's 400KB fix), on mote: gofmt -l is clean, and go vet
./internal/... is ok for darwin, windows and linux. go test -timeout 45m
./internal/claudetui ./internal/claudebridge is ok. ./internal/gateway is
ok except TestCodexPoolSaysTheClientsVersion, which fails the same way in
a gateway run at origin/main 79f83798f itself and passes alone at both
(#4807, filed here). The conflict with main's tuiRefusal and replay change
in start() was resolved by keeping main's req.told and calling
startTrusted. Before the rebase, the three packages were ok on
magpie-desktop (Linux) too.
2026-11-01 23:47:47 +08:00
yetone bee3ea6753 claudetui: the first message waits for Claude Code to list magpie's tools (MinhuWang on X)
MinhuWang (X, 2116836405548916907): in the interactive mode the first
message can go before MCP has loaded, and then has none of pi's tools.

Cause: the helper's ready() took the drawn "❯ " prompt as ready. Claude
Code connects its MCP servers beside the prompt, so a message pasted at
once was answered with no mcp__magpie__ tools. Reproduced with the real
Claude Code 2.1.309 (sandbox HOME, a copy of the owner's account): an MCP
server held 8s before answering initialize got "NOTOOL" for "what is the
secret word, use your tool".

Fix: startRun gives claude-mcp-helper a third argument, a `listed` file in
the run's temp folder, which RunMCP writes after it has answered
tools/list. The helper finds that path in the run's --mcp-config
(mcpListed) and ready() waits for it as well as the prompt, inside the
same ReadyWait (45s); past it the run ends saying the tools weren't
listed. Runs without that server (warm-up, model test) don't wait.

Run (mote, at this tree):
- go test ./internal/claudetui ./internal/claudebridge: ok
- go test -run 'Claude|MCP|Bridge' ./internal/gateway: ok
- real Claude Code 2.1.309 here, a sandbox HOME with a copy of the
  account's credentials, the new helper and the real claude-mcp-helper
  behind an 8s sleep: initialize answered at 12.7s, the first turn called
  mcp__magpie__pi_secret and answered "The secret word is PELICAN".
  Without the sleep: answered at 2.1s, same answer. 2.1.309 sends
  server/discover before initialize; the helper's method-not-found answer
  is taken and initialize follows.

Broken by hand: toolsListed returning true made
TestShimFirstMessageWaitsForTools red ("echo: hello (without magpie's
tools)"); RunMCP not writing the file made TestToolsListedFileWritten
red.

Not tried: Claude Code in WSL (the path is the gateway's Windows temp
path, handed to magpie.exe as the callback path is); a Claude Code that
lists tools only on its first request (2.1.309 lists them at start),
which would now wait 45s and fail saying so instead of answering
without tools; the full gateway suite (run after the next commits).
2026-11-01 23:26:57 +08:00
yetone 8569f39f6c agent: Claude Code's /model hides its own lineup while magpie's list is narrowed
yyhhyyyyyy on Discord picked only a routing group's models for Claude Code
on the Agents page, and Claude Code's /model still listed a model they had
not picked. Real Claude Code 2.1.316 in a sandbox HOME, with the settings
magpie writes, lists: Default, the group (as Custom Opus), Claude Code's
built-in "Fable 5.1" row, then the group as Sonnet and Haiku, then
magpie's modelPicker rows. The Fable row is Claude Code's own lineup.
magpie leaves ANTHROPIC_DEFAULT_FABLE_MODEL unset for a main model that
isn't a Fable (#2090), so Claude Code shows its own Fable there. The
gateway's /v1/models already follows the picks (CatalogFor), and Claude
Code's gateway discovery is off unless
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY is set. Neither of those is
where the row comes from.

Claude Code's documented modelPicker.replaceBuiltInOptions hides the
lineup and leaves Default and magpie's rows. In the same sandbox, the
same settings with the flag set list exactly those rows. magpie already
set the flag while "Show Claude Code's own models" is off (#4548). It now
also sets it while Claude Code's list leaves out some of magpie's
catalog: only the picked models, some taken out one by one, or a
visibility of families (claudeNarrowed, CatalogFor's hidden list). A
change to the picks already rewrites settings.json through
catalog.Touched and Sync.

The user's own values:
- A user's ANTHROPIC_CUSTOM_MODEL_OPTION, in the settings env or the
  shell, keeps the lineup. The flag would hide that row too.
- availableModels was not used. It also hid the Fable row in the
  sandbox, but it is the user's key, it blocks --model, and it is meant
  for enforcement.

Run at this head (rebased on origin/main 2503520f8), on mote:
- gofmt -l: clean.
- go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: ok.
- go test -tags nogui -timeout 45m ./...: internal/agent ok, along with
  84 packages. Three packages are red, all on main and filed:
  - internal/settingsapi TestKeysAreWhatTheSaveWrites and
    internal/cli TestSettingsCLISetsWhatTheWindowSaves (trayNoNumber,
    #4793);
  - internal/cli TestEveryRouteHasACommandOrIsNamed (/api/quit, #4794);
  - internal/gui TestRestartHandsTheGatewayOver (#4167, #4107).

Broken by hand:
- On the old claude.go, TestClaudePickerNarrowedListReplacesLineup fails:
  "glm-5 taken out: ... replaceBuiltInOptions=false".
- With the custom-option guard forced off, it fails on the user's
  ANTHROPIC_CUSTOM_MODEL_OPTION step.

Not tried:
- A real magpie writing settings.json for the real Claude Code. The
  sandbox used hand-written settings of the same shape, with the base URL
  on an unused port and no sign-in.
- Claude Code in WSL. claude@wsl takes the same writePicker path.

No GUI file is touched, so no GUI run.
2026-11-01 23:00:10 +08:00
yetone 37d7913c20 claude: the interactive mode is given an earlier conversation as a transcript
A conversation no run has (a run lost to an update, a client's own
history) was told to a new Claude Code in its interactive mode as one
first message, pasted. #4778's 229 messages and 3 images that way were
refused; #4780's 56 messages and 25 images were pasted one by one until
the paste timed out, and the request got a 502 or an empty reply.

Now, when the conversation has a reply that calls no tool,
replaySession writes it as Claude Code's own transcript: a session file
in the project folder Claude Code reads, a user line holding the
conversation before that reply (as renderClaudePrompt tells it, images
as image blocks, client cache marks out) and an assistant line holding
the reply's words. The run starts with --resume on it, as a saved
session's run does, and is typed only the turns after the reply. If
Claude Code can't go on from it, start tries once more told whole
(req.told). -p (interactive mode off), WSL (no session folder) and a
conversation with no such reply are told whole as before. The file goes
in the folder of the work path with its links followed: the first try
wrote it beside the unresolved /var/folders path on a Mac, and the
replay test was red on mote for it.

Real run (this Mac, sandbox HOME and CLAUDE_CONFIG_DIR, one of the
owner's real Claude accounts by CLAUDE_CODE_OAUTH_TOKEN, real Claude Code
2.1.316 through magpie claude-tui-helper, -p stream-json in, the
interactive mode under it, --model haiku): the transcript was made by
replaySession itself (a throwaway test on mote, not committed) from 6
earlier messages with 3 images (red, blue, green 64x64 PNGs) and a
455KB file whose line 004321 names a fruit, 464,798 bytes; the work
folder was reached through a symlink. Typed only "Name the colours of
images A, B and C, and the secret fruit named in line 004321 of the
file. One line." Answer in 8.4s: "A: red, B: blue, C: green; secret
fruit in line 004321: PAPAYA." Claude Code appended to the same session
file (504,788 bytes after).

Run (mote, at this tree, rebased on 85e37162e): go vet ./internal/gateway, GOOS=windows and
GOOS=linux -tags nogui go vet; go test -run
"TUI|Claude|Resume|Interactive|Refusal|Replay|Fallback|Branch"
./internal/gateway ok. gofmt -l clean.

Broken by hand: with replaySession returning nil,
TestClaudeTUIReplayGoesInATranscript is red ("the run wasn't given a
transcript to go on from"). TestClaudeTUISafeguardsInEnv now expects the
new run of changed safeguards to be given the whole conversation
through the transcript, not typed it, and
TestClaudeTUIBranchOfPrintRunIsToldWhole (049848c5e) accepts a branch of
a -p run's session given the whole conversation as a transcript of its
own, never the -p session (it was red at the rebased head before).

Not tried: the full gateway path (a real magpie serve with the
subscription) end to end; the request was driven at the helper with the
transcript replaySession wrote. Not changed: #4780's ask that an empty
200 not count as an answer and that the specific reason reach the
client; WSL still tells the conversation whole. Part of #4778 and #4780.
2026-11-01 22:43:52 +08:00
yetone 949000a36a claude: a request the interactive mode refuses is a 400 no account rests for
A request Claude Code's interactive mode can't take (a JSON schema, a
branch of a -p run's session, WSL Claude Code whose home wasn't found)
was refused with a 502. The fallback asked every account of the
subscription in turn and rested some for it: #4778 saw 15 tries across 3
accounts. The refusal is the same on every account, so it is now a 400
(tuiRefusal), which the fallback neither retries nor rests an account
for.

The message is reworded so that "Models" no longer stands just before
the error's "invalid_request_error": "Settings › Models › Replies
runs every request as -p\",\"type\":\"invalid_request_error" matched
provider.ModelUnserved, which made the 400 retryable again.

Run (mote, at this tree): go vet ./internal/gateway, GOOS=windows and
GOOS=linux -tags nogui go vet; go test -run
"TUI|Claude|Resume|Interactive|Refusal|Fallback" ./internal/gateway ok.
gofmt -l clean.

Broken by hand: with the 400 mapping taken out,
TestClaudeTUIRefusalIsNoAccountsFault is red (502); with the old wording
it was red on WSL (retryable true through ModelUnserved).

Not tried: a refusal against real accounts. Not changed: a run that
starts and fails (tuiNoStart) is still a 502, retried on the next
account. Part of #4778.
2026-11-01 22:43:52 +08:00
yetone 2503520f82 codexcat: each Codex model takes official Codex's own instructions for it (#3759, #4008, #4783)
Every magpie model in Codex's catalog (model_catalog_json) carried
gpt-5.2-codex_prompt.md ("You are Codex, based on GPT-5"), so a magpie
GPT-6 model, the auto group's included, ran on a GPT-5.2-era prompt while
official Codex sends GPT-6's own template. magpie still writes no words of
its own into the prompt and leaves the identity line alone: each entry now
takes the text official Codex sends that model, word for word.

- A model's slug (the id's last segment) is matched as Codex 0.166
  matches one (longest prefix of an official slug): first in the entries
  the user's ChatGPT account handed this Codex (models_cache.json), whose
  base_instructions and model_messages go over as sent; then in Codex
  rust-v0.166.0's bundled models.json (instructions_template only, as an
  older Codex may not read 0.166's model_messages), embedded as
  codex_instructions.json.
- Any other model, and a routing group, takes Codex's prompt for a model
  it doesn't know (models-manager/prompt.md, model_info_from_slug), which
  replaces codex_prompt.md: that is what official Codex sends it.
- ownEntry with no base_instructions, and internal/provider's
  codexInstructions fallback, take the same official text.
- testdata holds Codex's models.json and prompt.md at rust-v0.166.0;
  TestBundledIsCodexOwn fails when the embedded copies drift from them.
- GET /v1/codex/models (a remote Codex's model_catalog_url): entries are
  now ~21 KB, so Codex before 0.166's 1 MiB cap holds about 48 of them
  (was ~125). Codex 0.166 reads the catalog whole (models_endpoint.rs
  passes no body limit), and it sends ?client_version=, so the cap now
  applies only to a Codex below 0.166 or one that doesn't say
  (codexReadsWholeCatalog). docs/reference.md says so.
- docs/subsystems/agent-wiring.md: a "Codex instructions" row. The
  Antigravity cloak's comment no longer calls the GPT-5 prompt magpie's.

Run (mote's disk is full, 100% with other sessions' runs, so on WSL
magpie-desktop through wsl-run):
- go test ./internal/codexcat/: ok. go vet -tags nogui ./... and
  GOOS=windows go vet ./...: ok. gofmt -l: clean.
- go test -tags nogui -count=1 -timeout 45m codexcat, provider, agent,
  gui, gateway (every package that imports codexcat): codexcat, provider,
  gui ok. agent: TestGrokInstalled and TestOmpDetectedWithPiDir red, the
  same at origin/main 276c806db on the same box (#3548, #4033: WSL binfmt
  and install detection). gateway: TestCodexCatalogFitsCodexsLimit and
  TestCodexCatalogKeepsTheKeysUsedModelsFirst red from this change (the
  1 MiB cap, fixed above; both ok after, with every TestCodexCatalog*,
  TestCodexListed*, TestCodexApp*), and TestUnroutedHeldReportSaved, red
  only in the full run, ok alone here and at origin/main (#4300).
- Real Codex 0.166.0 (npm) in a sandbox HOME/CODEX_HOME, model_catalog_json
  from this codexcat, against a fake Responses gateway on 127.0.0.1:38611
  capturing each request: 0.166 sends the instructions as the first
  developer message (no top-level instructions). For magpie/gpt-6-astra it
  equals gpt-6-astra's instructions_template in Codex's models.json, byte
  for byte; for magpie/deepseek-v4-pro it equals prompt.md.

- After rebasing on origin/main 9da9bfabd: go vet (linux, windows) of
  codexcat, gateway, provider ok; codexcat ok; -run
  "Codex|Antigravity|Grok" in gateway and provider ok. Then rebased
  onto 546cdbde6 (7 commits in redact, gateway translation and a GUI
  test, none in codexcat or the Codex catalog) and not run again.

Broken by hand:
- The cap held for every client_version: both catalog tests FAIL (47
  listed for 0.166.0, 0.167.0-alpha.1 and 1.0.0).
- Old codex_prompt.md and Prompt everywhere: TestBundledIsCodexOwn,
  TestThirdPartyModelsTakeCodexOwnInstructions (all 7 slugs started "You
  are Codex, based on GPT-5"), TestThirdPartyModelsTakeCachedEntry,
  TestOwnEntryInstructions and TestCodexCatalogKeepsOwnEntries FAIL.
- The same real Codex run on origin/main's codexcat: both models' first
  developer message is the 7.5K GPT-5 prompt, differing from the official
  text at byte 15 (astra) and 8 (deepseek).

Not tried:
- GOOS=darwin go vet (needs mote, full).
- Reading the bundled catalog from the user's installed Codex binary;
  the snapshot is 0.166's, and a Codex release with new templates needs
  testdata and codex_instructions.json refreshed.
- An Antigravity account with Codex's unknown-model prompt ("You are a
  coding agent running in the Codex CLI"): the cloak breaks only the
  GPT-5 identity lines tried before.
- A remote Codex below 0.166 with many models through a gateway key: it
  lists fewer than before; the used ones FitOwn moves into the first 100
  can fall past the 48 that fit.
- A real ChatGPT account's models_cache.json entries (tested with a
  fixture cache).
2026-11-01 22:30:51 +08:00
yetone 276c806db2 plugins: a plugin's own requests are counted; a provider plugin's options get the editor (plugins#592)
zelong77 asked for two things once Devin 0.1.30's cache keep-alive
worked: its pings were invisible in magpie, and the interval and ping
count could only be edited in plugins.json. The owner decided pings are
shown as counted usage and the two numbers are edited in the GUI.

- host.js gives plugins input.magpie.usage(provider, call) and
  input.magpie.account(provider). usage validates the call (kind
  [a-z0-9_-]{1,40}, a model id, whole-number tokens from 0, status at
  most 999, error clipped to 500) and sends an unasked "usage" event;
  host.go hands it to plugin.OnUsage in the background.
- internal/usage/plugin_calls.go writes each one as a row of agent
  magpie on the plugin's provider (provider.PluginID) and account
  (provider.PluginAccountUser), with its kind. It is counted, priced
  and in every total, not a probe. Kind cache_keepalive is in the
  purpose catalog as "Cache keep-alive" (five languages), so the
  request log names and filters it. The ping itself still goes straight
  to Devin, never through the gateway, which would break the cache.
- /api/plugins reads every plugin's package options example, not only a
  middleware's or request hook's, and the Installed row offers the same
  Options JSON editor for a provider or agent plugin that suggests or
  has options (not while it is off). Clear's confirm no longer calls
  them a middleware's options.
- The Devin mover's min is 0.1.31, which reports each ping and gives
  its two settings' defaults (285 s, 6) to the editor. npm has 0.1.31
  (published 10:03Z); the plugins publish run is red only for
  think-tags' known E404 (plugins#180).
- docs: provider-plugins.md (the API, the options editor),
  gateway-sessions.md (the counted row beside probes).

Run at this tree (rebased on origin/main 85e37162e):
- mote (mote-run): go test -count=1 -timeout 45m ./internal/plugin
  ./internal/usage ./internal/gui ./internal/provider: plugin, usage,
  provider ok; gui red only in TestMainWindowCorners/macOS_26_SDK, the
  macOS 27 red already filed as #3949 (not this change's code).
- mote: GOOS=linux and GOOS=windows go vet of plugin, usage, provider ok;
  gofmt -l clean.
- mote: plugin-provider-options.test.cjs (new, 5 languages, 980/420px,
  Chromium + WebKit), plugin-gateway.test.cjs and i18n-keys.test.cjs:
  28 of 28 pass.
- The whole GUI suite (make test-ui) on WSL magpie-desktop (mote was at
  load ~100 with other sessions' suites, #4125), at the 8f804396f base:
  cut off after 498 test entries, when the session's background jobs
  were killed; 495 ok, 3 red, none on a page this change touches. Run
  again alone at origin/main 85e37162e, the same files are red there
  too: account-eye webkit (#4244), agent-expand-steady webkit 980px
  (#2935), add-button zh's 3000ms waitForFunction (filed #4792). The
  rest of the suite was not run.
Broken by hand (each red, then put back):
- host.go dropping the "usage" event: TestPluginReportsOwnUsage fails.
- plugins.go reading optionsExample for middleware/hooks only:
  TestProviderPluginOptionsExample fails.
- purpose.go without the Cache keep-alive kind:
  TestPluginKeepaliveIsCounted fails (purpose {}).
- plugins.js without ownOpts: plugin-provider-options.test.cjs times
  out waiting for the Options button in every language.
Not tried: a real Devin account's keep-alive ping reported into a real
magpie (needs a live Devin conversation idle for 285 s); a plugin can
report a row for any provider id, as magpie.load can.
2026-11-01 22:14:19 +08:00
yetone 85e37162e9 routing: a route group can be held to chosen accounts (duanckham on X)
duanckham has a personal and a company GPT account, one tool and one
gateway, and wants a group's GPT models to spend only the company
account (or only his own). A second gateway key doesn't fit: his tool
talks to one gateway, and a local agent needs no key at all.

Group.Accounts holds a group to some accounts or keys of the providers
it names, in a gateway key's form and by the key's rule (#905,
Identity.AllowsAccount). The asked group narrows the request's
identity (access.Identity.HeldToGroup: the strict intersection with
the key's own list; "<provider>/\x00" when they share none), so every
gate a key's accounts go through holds the group's too: chat,
responses, messages, count_tokens, embeddings, images and video,
streamed or not. A group reached inside another, as a member or a
fallback, is held in planLevel (hold, Member.Via): its candidates on
an excluded account are Held rows with Weighed.HeldBy, which the
Routing trace tells. Fallback stays within the group's entries; with
every allowed account resting or out the group's usual error comes
back, and a key and a group that share no account get a 403 naming
the group, nothing asked upstream. SaveGroup resolves each entry
(ResolveAccount, shared with the key's CleanAccounts); share and
import drop them. A group without accounts is as before.

GUI: the group editor's Accounts section, a row per member provider
with two or more accounts, "Any of its accounts" until some are ticked
in the app menu (openPicker multi). Every save sends accounts, since a
save replaces the group. Strings in all five languages.

Gateway keys stay as they are: Gateway › "Gateway keys are for other
computers … added here once Share on local network is on" already says
where, and this case needs none.

Run (mote, through mote-run), at cafed0067 on origin/main 9d08993c8:
- gofmt -l internal/: clean. go vet of access, gateway, provider,
  gui; GOOS=linux -tags nogui and GOOS=windows go vet ./internal/...:
  ok.
- go test -count=1 ./internal/access ./internal/provider
  ./internal/gateway ./internal/gui: access, provider, gateway ok; gui
  red only on TestMainWindowCorners/macOS_26_SDK, red on main too
  (#3949, mote's macOS 27).
- node --test group-*.test.cjs routing-group-*.test.cjs
  routing-save*.test.cjs i18n-keys.test.cjs: 433/434. The one red is
  group-found-skip "webkit de 390px: a provider left out of found
  groups" (the clicks moved the page), filed as #4617 from main; the
  file alone passes 20/20 here and on main 94f6f6092.
  group-accounts.test.cjs is 30/30 (Chromium and WebKit; en, zh,
  zh-TW, ja, de; 1100 and 420px; no scroll on the clicks, no sideways
  scroll, the save carries accounts).
- Earlier, at base 5a0c79ed9: go test -timeout 45m ./... all ok but
  TestVisionBridgePassesLines and TestSettingsSaveKeepsWhatItDoesNot-
  Send (fixed on main by 0b783b1dd and b646a9127; both pass after the
  rebase) and TestMainWindowCorners (#3949).
- The whole GUI suite was cut short twice (a wiped scratchpad, then a
  mote reboot). Its runs at load ~140-220 had about 35 reds, none in a
  file this change touches (account-mask, balance-fix, lan-*, the
  #4617 test among them); not chased here.
- Sandbox HOME on mote, the built binary (`magpie serve`, MAGPIE_ADDR
  on a free port) with a fake upstream answering with the key it got:
  group/work and Work -> sk-work (3 of 3), group/mine and relay/m ->
  sk-mine.

- Rebased again onto 8826a15ea (no file in common): go vet of gui,
  provider, gateway; go test -run 'TestGroupAccounts|TestHeldToGroup|
  TestCleanAccounts|Budget|TestGroup' of gateway, access, provider,
  gui: ok; group-accounts and i18n-keys GUI files: 34/34.

- Rebased onto ec104b862 (trace.go and gateway-routing.md in common,
  merged clean): gofmt clean; go vet of gateway for darwin, windows,
  linux nogui; go test -count=1 ./internal/gateway: ok (640s).

- Rebased onto 2b52302dc, then da275848b (no file in common): go vet ./internal/...,
  the TestGroupAccounts/TestHeldToGroup/Budget tests, group-accounts
  and i18n-keys GUI files: ok, 34/34.

Broken by hand, each red, then restored:
- serve's heldByGroup: three TestGroupAccounts* tests red (sk-mine spent).
- count_tokens' heldByGroupAt: the count_tokens route red.
- planLevel's hold: the nested "outer" group red.
- the editor save without accounts: group-accounts.test.cjs red.

Not tried: a real Codex or OpenAI account (the fake upstream stands
in); a CLI `magpie group set accounts=` (no CLI for it yet); a
provider's own fallback naming a held group has no test of its own
(planFallbackGroup passes the group as hold, the same path as nested).
2026-11-01 21:36:32 +08:00
yetone 049848c5ed claude: a branch of a -p run's session goes to the interactive mode, told whole
With the interactive mode on, tool results another request answered
first for a run made as claude -p (before the mode was turned on) were
refused with a 502 (claudePrint's "branch"): the branch would have gone
on as -p. It now starts a new interactive Claude Code told the whole
conversation (startRun): -p's prompt isn't the interactive mode's, so
the cache has nothing of the -p session to read either way, and nothing
runs as -p while the mode is on. This is the second refusal behind
@crosscn's 502 on an old conversation (X, 11-01); the first, words over
400KB, went in v0.1.2614.

- startRun drops such a branch (from and req.branch nil) and logs it;
- the "branch" entry in claudePrint is gone;
- docs/subsystems/claude-subscription-bridge.md says so.

Test: TestClaudeTUIBranchOfPrintRunIsToldWhole (a -p run's saved
session given as the branch: the run is interactive, has no --resume,
and is told the first words too; req.branch is cleared).

Run on mote (go1.26.8), at origin/main da275848b plus this change:
gofmt, vet (darwin, windows, linux -tags nogui) ./internal/gateway ok;
go test -run Claude ./internal/gateway ok (61s); the fork, branch and
cut tests (-run 'Fork|Branch|Cut') ok before the rebase.

Broken by hand: the new block turned off: the test red, the run resumed
the -p session with -p's arguments.

Not tried: a real -p branch with real Claude Code (it needs a -p run's
lead parked on calls when the mode is switched); whether @crosscn's
conversation reached this path rather than the 400KB one; the full go
test ./... (the gateway's Claude tests ran).
2026-11-01 21:36:20 +08:00
yetone da275848b6 tray: Windows shows a card's number in its icon (Benjaminliang_1 on X)
Windows' notification area shows no text beside an icon, so with a card
in the tray the icon itself is now the first card's figure: the first
row of the first card whose first row is a percentage, used or left as
Allowance display has it, its digits alone (trayIconFigure). It is drawn
in Segoe UI Semibold (Go's bold if the font can't be read) at
SM_CXSMICON, white on a dark taskbar, near black on a light one, as tall
as fits, centred by its ink, three digits narrowed into the square
(trayNumberIcon). It is drawn again when the figure, the icon size or
the taskbar theme changes (SystemThemeChanged wakes the loop); the
tooltip still lists every card. A balance or magpie's totals are
skipped; with no such card, or no cards at all, the icon is the bird as
before. Settings > Usage > Tray icon number (settings.TrayNoNumber,
Windows only, on by default, kept per computer) keeps the bird when off;
Menu bar windows is now shown on Windows too, since it picks the row
the number comes from. The number row sits after Menu bar cost, so the
bird > pace > cost order the other tests pin holds. Linux and the Mac
are unchanged. New words in zh, zh-TW, ja and de. app.js stays in the
core budget with one comment shortened, no raise.

Run at this commit on origin/main ec104b862 (traywindows.js merged with
94f6f6092's trayExtra pills; its "not on Windows" note dropped), mote:
gofmt -l empty; go vet and GOOS=windows go vet of gui and settings ok;
go test -count=1 -timeout 45m ./internal/settings ./internal/davsync
ok; ./internal/gui red only on TestMainWindowCorners (#3949),
TestCoreScriptBudget ok. GUI tray-windows, tray-cost, quota-pace,
i18n-keys, tray-bird, tray-logos, tray-usages, quit-ask: 140 pass,
0 fail. win-run on xiaomi-gpu: TestTrayNumberIcon and
TestTrayIconFigure ok. At c0477aa72 the same GUI set once had
quota-pace webkit "On moved the page" (439 !== 120), a late wheel
(#4784); green twice after, and quota-pace alone 3 of 3 green there
and on c0477aa72 itself.

Run before on the same change over origin/main 9d08993c8, mote:
- gofmt -l on gui/settings/davsync: empty; go vet ./internal/gui
  ./internal/settings and GOOS=windows go vet: ok.
- go test -count=1 -timeout 45m ./internal/gui ./internal/settings
  ./internal/davsync: settings ok, davsync ok; gui red only on
  TestMainWindowCorners/macOS_26_SDK (#3949) and TestCoreScriptBudget
  (5 bytes over after the rebase), which is green after the comment
  trim, rerun with TestTrayNumberIcon and TestTrayIconFigure: ok.
- GUI (both engines): tray-windows, tray-cost, quota-pace: 56 pass,
  0 fail. Earlier at this tree: tray-bird, tray-logos, tray-usages,
  i18n-keys green; quota-pace webkit de 420 red once, from a late wheel
  scroll (#4784), green on the rerun; segs-press-redraw red on
  searchAllRow, the same on a clean origin/main 9d08993c8 copy (#4566).
- A 184-file GUI run (the files touching Settings, the tray or i18n,
  before the rebase) under mote load 40-90: 3095 pass, 224 fail. My
  files' reds there (tray-cost: the number row was between pace and
  cost) are fixed above. The rest are in files this change doesn't
  reach (account-alias, model chips, menu-input-scroll, mobile-web,
  omarchy, plugin-github, key-replace, context-map and others; #4600
  lists several). Each was not compared on main one by one.
Windows (win-run on xiaomi-gpu, real Segoe UI): TestTrayNumberIcon and
TestTrayIconFigure ok.
Real Windows 11 run: a production build in a portable sandbox (own
data\, USERPROFILE/APPDATA/LOCALAPPDATA redirected, gateway on a free
port, a fake remote magpie serving one Claude card). The dark taskbar
showed a white "42", then a narrowed "100" when the card read 100%,
and the bird with trayNoNumber set. Only my processes, tasks and
NotifyIconSettings entry were removed afterwards.

Broken by hand: trayIconFigure always "" turns TestTrayIconFigure red
(6 cases); the dark and light colours swapped turn TestTrayNumberIcon
red; the old advance-width centring turns it red too.

Not tried: a light taskbar on the real box (it would change the user's
theme; covered by the test only), hovering the tooltip (screen locked),
other DPIs on real hardware, Windows on ARM64. Linux's code is
unchanged and was not run.
2026-11-01 21:31:55 +08:00
yetone 2b52302dcb claude: the interactive mode takes a first message of any length
@crosscn on X (11-01): after the upgrade made the interactive mode the
default, a week-old conversation (a DeepSeek harness on a Claude model)
got a 502, and worked again only with -p turned back on. A conversation
told whole to a new interactive Claude Code is its first message, and
words over 400KB were refused (claudePrint's "big", tuiPromptMost). The
bound was never tried: the commit that set it lists "a ~400KB paste"
under Not tried.

Tried on real Claude Code 2.1.316 in a sandbox HOME, haiku: a 3MB
bracketed paste showed "[Pasted text #1 +46154 lines]" after 35s; a
500KB one was sent, its transcript holds every line and the question,
and the model answered it (184,168 tokens written to the cache).

- tuiPromptMost and the "big" refusal are gone; claudeTUI, claudePrint,
  claudePrintWhy and claudeNotTUIWhy no longer take the prompt, which
  only that bound read.
- the helper waits for a paste to show a second per 64KB longer than
  pasteWait (shownWait): 10s alone would press Enter while a 3MB paste
  was still being taken in.
- the editor's tooltip says -p takes what the interactive mode can't
  "yet": a JSON schema (en, zh, zh-TW, ja, de).
- docs/subsystems/claude-subscription-bridge.md says so.

Tests: TestClaudeTUIBigFirstMessage (a ~1.1MB first message runs through
the helper, 200), TestShownWaitGrowsWithThePaste; TestClaudeTUIOnRefusesPrint
refuses a JSON schema now; TestClaudeTUIChosen's long-message row runs
interactively.

Run on mote (go1.26.8):
- full go test ./internal/gateway ./internal/claudetui (-timeout 45m) at
  15b035eef plus this change: claudetui ok, gateway red only on
  TestClaudeTUIOnRefusesPrint's -p half (the fake's "ok" fits no schema,
  502); that half now checks that -p ran it, not a 200. gofmt, vet
  (darwin, windows) ok; claude-mode and i18n-keys GUI files 44/44 and
  4/4 in chromium and webkit.
- rebased on origin/main ec104b862, at the pushed tree: gofmt, vet (darwin,
  windows, linux -tags nogui) ok; go test -run 'Claude|Budget'
  ./internal/gateway ./internal/gui ok; ./internal/claudetui ok;
  claude-mode 44/44, i18n-keys 4/4 in both engines.
- a real run through the helper (magpie built from this tree, real
  Claude Code 2.1.316, sandbox HOME, haiku): a 600KB first message as
  stream-json, answered "MANGO" in 12.5s, its transcript holding all of
  it.

Broken by hand: the 400KB refusal put back: TestClaudeTUIBigFirstMessage
red with the reporter's 502; shownWait returning pasteWait alone:
TestShownWaitGrowsWithThePaste red.

Not tried: the reporter's own conversation or a DeepSeek harness; a
first message past the model's context (Claude Code's own error then,
as with -p); a paste over 3MB; Windows or WSL with a large paste; the
whole go test ./... (the gateway and claudetui packages ran whole
before the rebase).
2026-11-01 21:30:04 +08:00
yetone 8f804396fd mcp router: the hub says what its servers are for, and Pi's first prompt hears it
Asked "can you drive a browser?", Pi said no until nudged. Two causes:

- The hub's initialize instructions were one generic sentence ("The tools
  of the MCP servers ticked for this agent…"), so nothing said that
  playwright drives a browser or deepwiki answers about GitHub repos.
  They now start with one line, "Tools of context7 (…), deepwiki (…),
  playwright (Drive a real browser), …", at most 250 characters (names
  first, "and N more" past room, abouts shared out short-first), then a
  "- name: about" line per server. An about comes from the market entry
  the server was added from (by key, then by name), else none.
- Pi 1.4.0 lists a codemode server in its system prompt by its config
  description, else its instructions' first line, but writes the first
  prompt without waiting for codemode servers. In -p runs the first
  prompt had "- mcp__magpie (codemode)" and nothing after it. The hub
  entry in Pi's mcp.json now carries that line as its description,
  kept in step with the servers ticked; a description on another entry
  is the user's and is left alone. Pi only: other formats are unchanged.

Sync runs under the library lock, so the hub's servers are read from the
library already loaded ((*Library).hubServers), not through hubServers().

Run (mote, at origin/main ee7b8b072 + this change):
- go test ./internal/library ./internal/gateway -run 'TestHub|TestPi'
- TestHubMCPNamesItsServers: 10 failures without the change, green with it.
- TestHubPiDescription: red with the description assignment removed by
  hand ("the hub entry's description \"\""), green with it.
- gofmt -l, go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet,
  the three builds, go test -tags nogui -timeout 45m ./...: all ok (87 packages).

Real use: a sandbox HOME with context7, deepwiki, fetch, playwright and
time ticked for Pi 1.4.0 (deepseek through the sandbox gateway). After
`magpie library sync`, Pi's mcp.json hub entry carries the line. Five
everyday questions, none naming MCP, two runs without the description
and three with it:
- "can you drive a browser": playwright used every time.
- the H1 of usemagpie.ai: fetch + playwright every time.
- "is it OK to call a colleague in San Francisco now": bash `date`
  without the description (2 of 2), the time server with it (3 of 3).
- Hono timing middleware docs: context7 in 1 of 2 without, 2 of 3 with.
- how the Next.js App Router client cache works: deepwiki in 1 of 2
  without, 1 of 3 with; Pi mostly clones the repo instead. Not fixed here.

Not tried: other agents' first prompts (they get the new instructions
text, not a description), Pi versions other than 1.4.0.
2026-11-01 21:22:58 +08:00
yetone ec104b8625 gateway: a Codex account can spend its credits before magpie moves to another account (jojonas_xyz on X)
jojonas_xyz on X: "我账号额度用完了自动给我切了别的号…找不到怎么关掉设置…你怎么知道
我不是想用 credits 呢". (Roughly: "my account ran out of quota and magpie
switched me to another account by itself; I can't find a setting to turn
that off; how do you know I didn't want to use the credits?")

Cause. At 90% or 98% of a window, smart routing's tier put the account
behind every account that still had room, whether or not it had ChatGPT
credits. Codex's own sign-in (NextLogin / SwitchWhenSpent) moved at the
spent share in the same way. The account's credits were spent only once
every other account was used up, and the switch was a log line. The Use
credits switches that existed (on, and "Only after other accounts" from
699ddf152) were only on the Usage page and the panel. None of them meant
"stay on this account and spend its credits".

Change.
- A fourth credits mode, first: settings.CodexCreditsFirst. on, first,
  last and off are exclusive; one mode replaces another.
- routes.Seat.First: a first seat's tier is 0, so routing keeps it in
  front past its windows while it has credits. The trace records
  Weighed.CreditsFirst.
- NextLogin keeps Codex's own sign-in on such an account (spendsFirst).
- The POST /api/codex-credits handler takes "first". The general
  settings save keeps the stored value.
- The CLI: `magpie quota credits <account> first`.
- GUI. No new page and no new component, only the Use credits row that
  already exists:
  - 供应商 → Codex → 账号 ⋯ → 使用积分 → 「先用完积分再换账号」. The
    Providers ⋯ tools now carry the credits row too, which is where the
    reporter looked.
  - 用量 → Codex 账号卡 → 使用积分 → 「先用完积分再换账号」.
  - The menu-bar panel's folded line reads 「开,先于其他账号」.
  - The "First again once it has room" tag on a moved-off account now
    points to the switch in its title.
  - Strings are in en, zh, zh-TW, ja and de.
- "Only after other accounts" (gokoshiki, 699ddf152) is unchanged.
  Its off title now says what off means.
- Docs: docs/reference.md and docs/subsystems/gateway-routing.md.

Budgets: at this head app.js is 1,312,105 of 1,316,874 bytes, and
TestCoreScriptBudget passes (231 bytes under before the rebase). Comments
were condensed; no budget was raised.

Run on mote, at this tree (rebased on origin/main 9d08993c8; the rebase
moved the settings save into internal/settingsapi, which now carries
CodexCreditsFirst beside CodexCreditsLast):
- go test -count=1 -timeout 45m ./internal/gateway ./internal/provider
  ./internal/routes ./internal/settings ./internal/settingsapi
  ./internal/gui ./internal/cli at 9d08993c8+1: gateway, provider,
  routes, settings and settingsapi ok. Two reds, both filed:
  - internal/gui TestMainWindowCorners/macOS_26_SDK: #3949.
  - internal/cli TestLibraryMCPHub, TempDir cleanup not empty: #4140.
  At the pre-rebase tree (da0005df8+1) internal/gui also had
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestColdTurnsTaken
  (#4510), red the same at da0005df8; both pass at this head.
- New tests:
  - internal/provider/codex_credits_first_test.go
  - internal/gateway/codex_credits_first_test.go (routing and the trace)
  - internal/gui/codex_credits_first_test.go (POST sequence, sandbox HOME)
  - internal/gui/tests/codex-credits-first.test.cjs: the Usage page and
    Providers ⋯ at 900 and 440px, and the panel at 360px; chromium and
    webkit, en zh zh-TW ja de. It also checks for no select, no stripe,
    the i18n keys, and that a click does not move the page.
- The whole GUI suite (make test-ui), at da0005df8+1 on mote at load
  66 to 213, in two parts (a wiped scratchpad cut the first log; its red
  titles were kept): 59 files with a red. 45 of them are red at
  origin/main da0005df8 too, each under an open issue: #4304 (mote
  umbrella), #4600, #4471, #4120, #4119, #4621, and per file balance-fix
  #4682/#4683, gui-ja #4580, page-width-steady #4541, phone-connect-menu
  #4706/#4707, quota-curve #4768, segs-press-redraw #4566, signin-proxy
  #4643/#1814, zhipu-team #4728, model-copy-id #4621 (red 4 of 4 on main).
- The 14 green at da0005df8 were run again at this tree. One was this
  change's: usage-curve-zoom-back. The Codex card's fourth credits line
  (366px, was 344) held the DeepSeek card beside it to 261px, so the
  "card grows" check at 1100px had no room. Its fixture now turns the
  Codex account's credits off, since the count of credits lines isn't
  what it tests; 20 of 20 pass.
- At this head (9d08993c8+1), on mote at load 75 to 84: codex-credits-first,
  codex-credits-last, codex-credits, routing-codex-credits-again,
  panel-options-fold, usage-curve-zoom-back, i18n-keys and the 13 files
  above: 232 tests, 227 pass. Each red has an open issue:
  - models-fold webkit en/zh, "ebody holds" after the click: #4071; red
    the same at 9d08993c8 (run there).
  - account-weight webkit, same "ebody holds": #4644 (red at
    da0005df8+1, green in this run).
  - routing-many-keys chromium de "2 keys in sight at the foot": #4082
    (under load; red again alone here, green at 9d08993c8 in one run).
  - signin-closes-sheet chromium en/zh: #2628 (green alone at this head
    in a second run).
  - signin-again and signin-port-blocked, red once at da0005df8+1 under
    load, pass at this head and at 9d08993c8.

- Rebased last onto 94f6f6092 (three commits; c0477aa72 changes the
  Codex Providers row): go test -run 'Budget|CodexCredits|SettingsSave'
  ./internal/gui ok, and codex-credits-first, codex-credits,
  codex-credits-last, providers-reset-use, i18n-keys and
  usage-curve-zoom-back: 92 of 92 pass.

Broken by hand, each red, then restored:
- spendsFirst forced false: the provider test is red.
- The gateway's l.first forced false: both gateway tests are red.
- codex-credits-first.test.cjs against origin/main's assets: red
  (TimeoutError on the switch).

Not tried:
- No real ChatGPT account with credits went past its window. The routing
  order and NextLogin are tested on fakes only.
- The Linux and Windows apps were not run.

go vet -tags nogui ./... with GOOS darwin, linux and windows on mote:
clean (cgo enum warnings only). gofmt -l on the changed Go files: clean.

Claude has no equivalent: magpie reads no extra_usage and has no Use
credits modes for Claude. Filed as #4662 (see #4241).
2026-11-01 21:19:22 +08:00
yetone 8826a15ea4 gui: a Quit while agents go through magpie asks first, naming them (Aisiverto on X)
Aisiverto on X (Windows, v0.1.2519) wired Codex to magpie and quit magpie.
Codex then retried "unexpected status 502 Bad Gateway ... url:
http://127.0.0.1:3425/backend-api/codex/responses" five times and gave up,
and it took a long search to find magpie's openai_base_url in config.toml.

A Quit the user chooses (the tray's Quit, the panel's and window's Quit,
Command-Q on the Mac) now asks first when this process serves the gateway
and agents are wired to it. The window comes up on a sheet
(quitask.js, lazy-loaded) that names each agent cut off, says closing the
window keeps magpie running (menu bar on a Mac, system tray elsewhere),
and offers Quit (focused), Disconnect and quit, and Cancel. Disconnect and
quit puts each agent back as its row's Disconnect does, then quits; a
disconnect that fails keeps magpie open, named in the status line. A
second Quit within a minute of the question quits, so a window that
can't show it traps nobody. With nothing wired, or another magpie serving
the gateway, Quit quits at once.

Not asked: a restart to update, Uninstall, a browser's page (magpie web),
logging out or shutting down, and the Dock's Quit (AppKit terminate:).

Found while checking the report:
- Closing the window on Windows hides it; magpie stays in the tray and
  the gateway keeps serving (tried for real, below). Not a bug.
- Autostart is off by default on Windows.
- The proxy / NO_PROXY in the report isn't magpie's to fix: the 502 is
  magpie's port with nothing behind it.

Strings in en, zh, zh-TW, ja and de (existing terms: Agent, 退出). No
native dialog, no <select>. TestCoreScriptBudget met without a raise:
app.js gains two lines, the sheet is outside the core, and driftFix's
comment block is cut to six lines (453 bytes back; main's core had grown
to 258 bytes over with these lines in).

Run, at this head (on origin/main 94f6f6092), on mote unless said:
- gofmt -l internal/gui: clean.
- go vet ./..., GOOS=windows go vet ./..., GOOS=linux go vet -tags
  nogui ./..., go build, GOOS=linux go build -tags nogui, GOOS=windows
  go build: ok.
- go test ./internal/gui -run 'Budget|Quit|CommandQ', and with -tags
  nogui -run 'Budget|Quit': ok (TestCommandQAsksFirst runs AppKit in a
  child process).
- quit-ask.test.cjs, old-webkit.test.cjs, i18n-keys.test.cjs in chromium
  and webkit, en/zh/zh-TW/ja/de: 60/60 ok.
- At the previous base (9d08993c8): go test ./internal/gui (whole
  package, GUI build): two reds. TestCoreScriptBudget (258 over, fixed
  above) and TestMainWindowCorners/macOS_26_SDK, red the same at
  9d08993c8 itself (#3949, macOS 27). The nogui run of the package was
  not reached.
- The whole GUI suite: started at 24fd4a250 on WSL (magpie-desktop),
  stopped about halfway (3,915 results) to rebase; 68 reds in 28 files.
  Those 28 files with quit-ask, old-webkit and i18n-keys at 9d08993c8+this
  on mote: 74 reds in 7 files, none in this change's files. The 7 alone
  at origin/main 9d08993c8: the same 6 files red (73), and
  gateway-caller-keys red at main when run alone (1 of 4). All filed:
  balance-fix #4682 #4683, key-replace #4126 #3476, agent-panel-name-width
  #4203 (red on macOS too, commented), context-map #3488, header-centre
  #3479, gateway-key-models #4616, gateway-caller-keys #3797.
- Not run: go test ./... in full (mote at load 140-160 with others' full
  suites, WSL with two GUI suites), and the GUI suite to its end.

Broken by hand, each red:
- api.go's ask skipped (false &&): TestWindowQuitAsksFirst "the window's
  Quit didn't ask (AskQuit never ran)".
- askingQuit without RemoveMenuItem: TestCommandQAsksFirst "the app menu
  still has the Quit role".
- quitNow as asked == 0 ||: TestQuitNow "connected, never asked: quitNow
  = true, want false".
- The return after a failed disconnect removed: quit-ask 5/25 chromium
  red (the failed-disconnect test in every language).
- app.js's ?ask=quit line removed: 20/25 webkit red.

Windows, for real (xiaomi-gpu, sandbox HOME/APPDATA under
C:\Users\yeton\quitask-sb, MAGPIE_ADDR 127.0.0.1:3471, MAGPIE_NO_ACCOUNTS,
a -H windowsgui build of this branch, launched in the desktop session):
`magpie codex fakeq/m1` wired the sandbox Codex to
http://127.0.0.1:3471/backend-api/codex; WM_CLOSE on the window left
the process alive with no visible window and the gateway listening.

Not tried:
- The tray's Quit and the sheet on real Windows: WebView2's CDP port
  never listened and UI Automation didn't find the tray icon, so the
  sheet was tried in Playwright only.
- A real Codex run against the sandbox gateway before and after a quit.
- The Dock's Quit (not covered by design).
2026-11-01 21:16:35 +08:00
yetone 15b035eef0 claude: the interactive mode takes an image known by its URL
The interactive mode is pasted files, so an image a client names by its
URL alone made the run fall to the refusal list ("image"), which with
the TUI on means a 502. Now serveSubscription downloads each such image
first (fetchURLImages): from public addresses only (publicClient, the
same fetch the other providers use), checked to be an image by its
bytes, and kept by URL (32 of them) so a conversation that hands the
same URLs over each turn downloads each once. One that can't be had
fails the request with a 400 naming the URL and why; nothing of a
non-image's content is echoed. claudePrint's "image" entry stays as a
backstop, unreachable with the mode on.

The provider editor's tooltip for claude -p no longer lists the image
among what the interactive mode can't take (en, zh, zh-TW, ja, de), and
the bridge's subsystem page says how the image is fetched.

Run (mote, at this tree on 9f17ad4c1): gofmt -l clean; go vet
./internal/gateway, also GOOS=windows; go test -count=1 -timeout 45m
./internal/gateway: ok (760s), with ./internal/claudetui ok; GUI claude-mode, claude-tui-setting and
i18n-keys in chromium and webkit: 44, 16 and 4 pass in each engine, 0 fail.

Rebased on 9d08993c8 (main touched claude_subscription.go's tool names), then
at the pushed tree: go vet ./internal/gateway; go test -run Claude
./internal/gateway ok (68s); i18n-keys and claude-mode 48 pass, 0 fail
in each engine.

Broken by hand: with the fetchURLImages call taken out,
TestClaudeTUIImageByURL is red (502 "an image known by its URL"); green
with it back.

Not tried: a real image by URL through a real interactive Claude Code
(the plan's quota is kept for the long-conversation runs that come
next); the download itself is
FetchImage's, which the other providers' image paths already use.
2026-11-01 20:54:37 +08:00
yetone 9d08993c8b routing: Cheapest first prices Ollama Cloud's DeepSeek models at double from 12:00 to 18:00 UTC on weekdays (hayden4608)
hayden4608 on Discord asked that time-of-day routing use the gap
between peak and off-peak prices, citing https://ollama.com/pricing.
That page (read live on 11-01) gives Off-Peak rows for two models
only, deepseek-v4.1-flash ($0.30/$1.20 peak, $0.15/$0.60 off-peak) and
deepseek-v4-pro ($1.32/$3.96 peak, $0.66/$1.98), and says off-peak is
"outside 12:00 and 18:00 UTC on weekdays and all day on weekends".
models.dev's ollama-cloud catalog lists the off-peak prices, so magpie
priced Ollama Cloud's peak hours at half.

- catalog: a new Peak kind, PeakOllama. Its hours are 12:00 to 18:00
  UTC, Monday to Friday, with no holidays. PeakFactor (2) matches the
  page for both models, cache reads included.
- provider: a peakBill for ollama.com (preset/catalog ollama-cloud)
  that names the two models. Dated tags (deepseek-v4-pro:1017) count
  as their model; the bare name before ':' is compared without
  allocating. Every other model there (glm-5.3, gpt-oss...) and every
  other vendor stays flat. A local Ollama, a relay that names itself
  ollama-cloud, and an ollama.com.evil host are not matched.
- GUI: a model's price tooltip names Ollama's hours for peak "ollama".
  The Cheapest first and rate-window texts no longer say that only
  DeepSeek's hours count, in en, zh, zh-TW, ja and de.
- docs/reference.md, site docs (en, zh, ja) and the gateway-routing
  and providers-accounts subsystem pages say the same.

Run (on mote through mote-run, at this tree rebased on ef3e74a07):
- go test for ./internal/catalog ./internal/provider ./internal/gateway
  for the new and changed tests, under TZ=UTC, Pacific/Kiritimati,
  Pacific/Pago_Pago and Asia/Kathmandu: ok. The tests check 11:59,
  12:00, 17:59, 18:00, 00:00 and 23:59 on weekdays, a Chinese holiday
  Monday, Saturday and Sunday, at +14, -11 and +0545 instants.
- gofmt -l internal: empty. go vet ./..., GOOS=linux go vet -tags
  nogui ./... and GOOS=windows go vet ./...: ok.
- GUI (Chromium and WebKit): model-price-edit, provider-rate-windows,
  routing-cheapest-first, i18n-keys, gui-de, gui-ja, gui-zh-tw.
- go test -count=1 -timeout 45m ./... (one suite on mote): every
  package ok except internal/gui. TestCoreScriptBudget was 7 bytes
  over, so this commit drops a comment from the app.js change rather
  than raise the budget; it passes now. TestMainWindowCorners/
  macOS_26_SDK (the window's toolbar taken off) is red on mote and
  touches nothing here: it is red
  the same way at origin/main ef3e74a07 alone, and is #3949 (macOS 27).

Broken by hand (each red, then restored):
- the peak hours ending at 17:00: TestOllamaPeakHours red.
- the Ollama bill removed: TestPeakOf, TestOllamaCloudOffPeakPrice red.
- tagged false: the dated-tag rows red.
- Ollama's hours used for every Peak kind: TestPeakHours,
  TestPriceOfPeak and TestCheapestFirstGroupFollowsPeakHours red.

Not tried: a real Ollama Cloud account or bill; a local Ollama's
":cloud" models (sent through the local server, so not priced here);
other vendors' off-peak schedules; the site is not deployed.
2026-11-01 19:02:59 +08:00
yetone 7d1f2ecba3 claudecode: magpie keeps the Claude Code it downloaded at the newest release
alextjy on Discord runs magpie in Docker with Claude Code from
`magpie claude-code install`, and asked whether a magpie update touches
it and how it updates. The download lives in <cache>/claude-code
(/config/cache, on the volume), so a new image keeps it. But nothing
ever updated it: every run magpie starts sets DISABLE_AUTOUPDATER, so it
stayed at the version first installed until the user ran install again.

claudecode.KeepCurrent now runs while magpie serves (a WhileServing
loop): a minute after start and every six hours it asks
downloads.claude.ai for the latest release and downloads a newer one,
checked against the manifest's SHA-256 and size as install does. The
version it replaced is removed on the next look rather than at once,
since a run being started may hold its path (Install, the CLI's, still
removes it at once; a folder with a .part download in it is left
alone). It does nothing when magpie downloaded none, when the machine
has its own `claude` (that one is run and updates itself), or when
DISABLE_AUTOUPDATER is set for magpie, Claude Code's own way to hold a
version. A failed look keeps the download and is logged. It never
downgrades.

The status line of `magpie claude-code`, the Docker docs (en, zh, ja)
and the bridge's subsystem page say so.

Run:
- wsl-run (Ubuntu 24.04, Go 1.26.8): go vet, then go test -race -v
  ./internal/claudecode/ -run 'Keep|Install|Find': all pass.
- Broken by hand on WSL, each red: no newer() check
  (UpdatesMagpiesDownload, LeavesWhatIsntMagpiesToUpdate), no own()
  check (the_machine's_own), pruning at install (UpdatesMagpiesDownload),
  no prune on the next look (UpdatesMagpiesDownload).
- Real use on WSL, sandbox HOME and XDG_CACHE_HOME: a throwaway program
  with a fake 2.1.1 download ran KeepCurrent against the real
  downloads.claude.ai. After 1m34s it logged "updated from 2.1.1 to
  2.1.316", the kept binary's --version said "2.1.316 (Claude Code)",
  2.1.1 was still there for the next look, and the loop ended with its
  context.
- mote, at this tree: GOOS=windows and GOOS=linux go vet -tags nogui of
  both packages, go vet ./internal/claudecode/, go build ., then
  go test -tags nogui ./internal/claudecode/ ./internal/cli/ -timeout 45m:
  VET-OK; claudecode ok 0.680s, cli ok 56.673s.
- gofmt -l clean.

Not tried: the Docker image itself (no docker on the test boxes), and a
Windows run whose replaced binary is still in use (prune leaves what it
can't remove for the next look). Full suite not run: the change is the
claudecode package, one WhileServing line and one CLI status line. A
WSL run of ./internal/cli/ at the default 10m timeout timed out while
the box ran other sessions' full suites; the 45m run above replaces it.
2026-11-01 19:00:51 +08:00
yetone 9f17ad4c12 claude: the interactive mode takes safeguards and a client's cache marks
With the interactive mode on, nothing runs as -p any more (e5f66f8a6),
so a request carrying safeguards or a client's own cache marks was
refused. The owner (11-01) asked for every such request to work in the
interactive mode.

Safeguards: interactive Claude Code reads CLAUDE_CODE_EXTRA_BODY only
as it starts, so startRun puts them in the run's environment
(claudeEnvVars now cleans it and DISABLE_PROMPT_CACHING from what is
inherited). A turn whose safeguards changed ends the run, and the next
starts anew, told the whole conversation (setSafeguards).

Client cache marks: the helper pastes the words without their marks, so
the run keeps Claude Code's own prompt caching (no
DISABLE_PROMPT_CACHING, no client tail), and X-Magpie-Cache-Marks-Dropped
names every mark the client placed (clientCache.pasted, systemMarks).

The provider editor's tooltip, in every language, no longer lists them
as what only -p takes. The bridge doc says how each is handled.

Run:
- mote, at this tree: go test -count=1 -timeout 45m ./internal/gateway
  ./internal/claudetui: ok (gateway 897s, claudetui 10s)
- mote: node --test claude-mode, claude-tui-setting, i18n-keys: ok, all three
- New TestClaudeTUISafeguardsInEnv and TestClaudeTUIClientCacheKeepsItsOwn
  (a stand-in helper running the script Claude Code). With each change
  broken by hand, its test went red.
- Windows (GOOS=windows on mote) and Linux (wsl-run -tags nogui) go vet
  of the gateway: ok, on the tree with the image change on top.
- Real Claude Code 2.1.316, interactive, sandbox HOME: an extra body
  given in its environment reaches Anthropic (it answered 400
  "safeguards.0.dangerous_tool_use.classifier_context: Input should be
  an object" to a made-up shape).

Not tried: a real run with a valid safeguards shape (the test account
is at its 5-hour limit).
2026-11-01 18:52:44 +08:00