Commit Graph
6116 Commits
Author SHA1 Message Date
yetone e7fbbaab9f plugin: an author's own listing is kept, for a search to find (plugins#479)
On magpie-community/plugins#479 the owner ruled that registry.json
entries for packages published from their author's own repository
rightly leave out "community": true, and are shown under the
publisher's name, to a search alone. parseMarket dropped every entry
without the flag, so PinK (YuchenWell, plugins#617), and WispTerm,
CiteBox and Wisp Science (hoptoper) couldn't be found in magpie at
all.

What changed:
- parseMarket keeps a listing without the flag; Listing.Community
  says which it is. The new plugin.Community(l) picks the community's.
- Every reader of the market was re-derived:
  - plugins.js already browses community listings alone, matches a
    search over every listing (name, package, summary, providers, npm
    publisher), and shows a non-community card and page under its npm
    publisher, without the magpie community badge. Unchanged.
  - plugin.resolve (a short name like "river") reads the community's
    alone: an author's "pink" stays npm's own name "pink".
  - pluginAgents (/api/plugins/agents, the Agents page's suggestions)
    reads the community's alone, as Discover's Agents section does.
  - plugin.Icon's fallback by provider id reads the community's alone;
    its exact-package match reads all, so PinK's own icon shows.
  - pluginListings and pluginMarketState pass every listing on.
- Docs (en, zh, ja plugins.html) say such a package isn't browsed and
  is found by a search, under its publisher.

Tests:
- TestMarketKeepsAuthorsOwnListings parses registry.json's River and
  PinK entries as they are at plugins 486a68a5 (#617's base, lines
  126-130, PinK without the flag; testdata/registry-pink.json). PinK is
  kept, not community, with its kind, summary and icon; resolve("pink")
  is "pink" and resolve("river") the community's package.
- TestMarketSources now expects the non-community entry kept.
- plugin-authors-listing.test.cjs: PinK isn't browsed (Agents shows
  Kilo, no PinK anywhere), a search by name or publisher shows one PinK
  card under "zhouzhenzhou" with no badge, its page reads
  "zhouzhenzhou · magpie-plugin-pink" with no badge, River keeps its
  badge. en, zh, zh-TW, ja, de; 980 and 420 wide; chromium and webkit.

Broken by hand, each red, then put back:
- parseMarket's `&& l.Community` restored: TestMarketSources and
  TestMarketKeepsAuthorsOwnListings red.
- resolve without Community(): TestMarketKeepsAuthorsOwnListings red
  (pink resolved to magpie-plugin-pink).
- pluginAgents without Community(): TestPluginAgentsNotInstalled red.
- plugins.js Agents without the l.community filter, and the badge shown
  for every agent: plugin-authors-listing 0/22 each.

Run on mote at this head (rebased on a4916aec1; i18n-keys and plugin-authors-listing ran again there, both engines):
- gofmt -l: clean. GOOS=linux go vet -tags nogui and GOOS=windows go
  vet of internal/plugin and internal/gui: ok.
- go test -timeout 45m internal/plugin, internal/provider: ok.
  internal/gui: ok but TestMainWindowCorners/macOS_26_SDK (#3949,
  mote's macOS 27, nothing here touches it).
- At 3086c650b (rebased on 541102eba; the rebase since touched
  host.js, a gateway test and a provider test only): agent, agentplug,
  backup, davsync, library, middleware, usage and plugins/...: ok.
  cli: TestEveryRouteHasACommandOrIsNamed (#4826); gateway:
  TestCodexPoolSaysTheClientsVersion (#4807). Both filed, untouched
  here.
- node --test site/*.test.mjs: 80/80.
- GUI, every file that reaches the Plugins page (agent-plugin-agents,
  i18n-keys, market-*, plugin*; 1078 tests, both engines): 1074 pass,
  plugin-authors-listing 22/22. The 4 reds are plugin-move-unserved's
  "Try again takes the models unticked" (#4410, models folded behind
  "Show the other"), not reached here. The whole GUI suite wasn't run:
  mote held two other sessions' full suites for over an hour, and this
  changes no app.js, plugins.js, layout or API call. That run was at
  f5c956b84; after the rebase on a1f56720c (i18n.js and caller keys
  moved), plugin-authors-listing, i18n-keys, plugin-market and
  plugin-registry ran again: webkit's plugin-authors-listing and
  plugin-market timed out at mote load ~250 from other sessions' suites
  (#4125), and both passed 14/14 alone right after.

Not tried: a real magpie window against the live registry.json (the
listings come from a fixture and a faked API); the Icon fallback's
community-only rule has no test that goes red without it.
2026-11-02 14:12:20 +08:00
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 d577c184b3 redact: a user name's and an address's stand-ins come back in any case (yapechan on Discord)
yapechan (Discord #feedback): with masking on, a person's name sometimes
came back as letters that are no one's, with no {{…}} braces. A user name
in a home folder goes to the vendor as eight made-up lowercase letters
(standInOf). When the login name is the user's own name (yaobin), a model
takes those letters for the user's name and writes them as a name is
written, "作者:Tmhdfetm", "Hi Tmhdfetm,". restoreShapes put a stand-in
back only as written, so a capitalised or upper-case one reached the user
as garbage. An IP stand-in (public-ip-…), a host name that is the same in
any case, had the same gap.

Now a USERNAME or IP stand-in is put back in any ASCII case: in Restore,
RestoreJSON (hasShapes), a stream's held tail (shapeTail) and
outsideShapes. Matching uses an ASCII-lowered copy of the same length
(lowerASCII, which now returns s itself with no capital in it, so there
is no copy), and strings.Index runs once per stand-in as before. An IP
stand-in is still put back only as a whole name. A key's made-up form
(Options.Shape) is still put back only as written, because a key's case
is part of it.

The restart question: the placeholder-to-value map is in memory only.
But a placeholder is an HMAC of its value under a key kept on disk
(redact.key, 0600, SetKeyPath from the gateway), and an agent resends its
history with the values on every turn. So after a restart the same value
goes as the same placeholder and the reply comes back whole.
TestPlaceholdersOutliveARestart now guards that, using the reporter's
姚斌 as a user word. Nothing new is written to disk.

Not found in magpie: a homophone (姚斌 -> 姚兵). Nothing in redact, pii
or restore maps a name by sound. A value goes back only for its own
placeholder or stand-in. The test records that 姚兵 goes back as the
vendor wrote it. Most likely the vendor model wrote it from a
romanisation it saw (a login name, an address); this is not reproduced.

Run at 19e9f7a82 (rebased on 4fc34828e), on mote:
- go test ./internal/redact ./internal/masking ./plugins/redact: ok
- go test -run 'Redact|Mask|Placeholder|Restore' ./internal/gateway: ok
- before the rebase, the whole ./internal/gateway (-timeout 45m): one red,
  TestCodexPoolSaysTheClientsVersion, which is #4807 (another test's
  Codex identity reaches it in a full run). It passes alone -count=3 at
  this head, and it does not touch masking.
- GOOS=linux and GOOS=windows go vet ./internal/redact ./internal/gateway: ok
- gofmt -l: clean
Broken by hand: with the old shape.go, both InAnyCase tests are red
(Restore, RestoreJSON and the stream at every cut). With loadKey ignoring
the key file, TestPlaceholdersOutliveARestart is red (new placeholders,
reply left as {{TERM_…}}).
Not tried: a real vendor writing a capitalised stand-in. The reporter's
own session and records were not seen. The GUI was not run (no GUI
change).
2026-11-02 13:58:47 +08:00
yetone 4fc34828e5 docs: an agent's model picker sends a model in its vendor's fast mode from the bolt on its row (Phoen1xCode on Discord)
Phoen1xCode asked whether magpie can send a ChatGPT (Codex) account's
models to other agents in Codex's Fast mode, service_tier "priority". It
already does, since #954: the bolt beside a model's star in the agent's
picker (shown on the picked row and under the pointer, like the star),
and a routing group member's Fast switch. Nothing in the site docs said
so, and the bolt is hidden on the other rows, so the feature couldn't be
found without hovering the right row.

Section 2 of the start page (en, zh, ja) now says which models have the
bolt (provider.CanFast: a ChatGPT account's GPT, an OpenAI key's GPT and
o-series, Cursor's with a fast variant, Claude Opus on an Anthropic key,
a plugin's or remote magpie's that says priority), what it sends
(service_tier "priority" as Codex's /fast does, checked against
openai/codex a09812981 codex-rs/protocol/src/config_types.rs:
ServiceTier::Fast.request_value() is "priority"; Claude's speed "fast"),
the Ultrafast step, that it is per agent and leaves fallbacks as they
are, and the routing group's switch.

No code changed. The GUI's hover-only bolt is left as it is: it matches
the star beside it.

Run at this head on mote: node --test site/worker.test.mjs
site/install.test.mjs site/stable.test.mjs site/credits.test.mjs, 80/80.
Not tried: a real ChatGPT account's priority request; no test covers
docs text.

Not changed: the CLI and TUI have no way to switch an agent's fast pick
(#4860).
2026-11-02 13:57:23 +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 541102eba2 claude: a saved account's .claude.json gets the onboarding mark when it lacks it (Jaxxxxnn on X)
Jaxxxxnn on X (magpie 0.1.2669, Claude Code 2.1.316, macOS arm64): a
saved Claude account's config directory had a .claude.json without
hasCompletedOnboarding. Claude Code's interactive mode then asked for a
login method beside a sign-in that works, the run ended on it, and both
requests and the usage read failed as if signed out. Adding the mark by
hand fixed it with the same token.

magpie wrote the mark only when it made .claude.json itself, so a
directory -p ran in (before the interactive mode was the default) or one
an earlier magpie made kept a file without it. claudeOnboarded now adds
the mark to the file that is there, every other key kept (numbers read
with UseNumber), on both paths of claudeSavedDir (sign-in put in, or
there already) and in claudeTokenDir. A file that can't be read or
parsed, which Claude Code may be writing, is left as it is.

Run (mote, at this tree):
- go test -count=1 ./internal/provider ./internal/claudetui: ok
- go vet ./internal/provider, GOOS=linux and GOOS=windows: ok
- gofmt -l: clean

Broken by hand: with claude_dirs.go and claude_setup_token.go at
origin/main, TestClaudeSavedDirMarksOnboardingDone and
TestClaudeTokenDirMarksOnboardingDone are red.

Not tried: a real Claude Code 2.1.316 run in a directory without the
mark; the reporter's own fix (the same mark) is the evidence. Not the
full suite.
2026-11-02 11:48:26 +08:00
yetone a69ffd9f01 appdir: a portable data folder in a moved Downloads, Desktop or Documents stays magpie's on update (jwaitq)
jwaitq on Discord (#feedback, 11-02): updated from v0.1.2630 to v0.1.2670
with the update button, and magpie showed the setup of long ago.

9f1734645 (v0.1.2648) added the folders the system keeps Downloads,
Desktop and Documents in (Windows' known folders, moved to D:\ or OneDrive;
the XDG ones on Linux, ~/下载) to sharedFolder. A data folder beside magpie
there was then judged as one in home\Downloads: passed over whenever the
installed folder (~/.config/magpie) holds magpie's files too. Every release
before took any data folder there, so a user who kept magpie portable in
such a folder had all their files in data\, and an installed folder from
long ago with a settings.json was enough to make the updated magpie read
that one instead. On Windows the updated exe, no longer portable and in a
download folder, then also installed itself to
%LOCALAPPDATA%\Programs\magpie (update.Settle) and opened that copy.

shared() now treats a moved folder (movedFolder, the system's folder that
isn't home's own) as before v0.1.2648 for a data folder holding magpie's
files: it is taken. One holding none of them (another app's, or emptied by
an archiver, tangle778's case) is still passed over. home's own Downloads,
Desktop, Documents, the home folder and /Applications are unchanged.
userFolder is a hook so the test runs on every system.

Users already hit: on Linux the next update finds data/ again by itself.
On Windows the copy in %LOCALAPPDATA%\Programs\magpie runs from a folder
with no data beside it, so it keeps reading %USERPROFILE%\.config\magpie;
their files are untouched in <moved Downloads>\data and are brought back by
hand (copy into .config\magpie, or a .portable file beside the old exe).
Anything set up in v0.1.2648..2670 went into .config\magpie.

Run at this head (b61121503 + this):
- mote (macOS): gofmt -l clean; go vet ./internal/appdir ./internal/update,
  GOOS=windows and GOOS=linux the same; go test -count=1 ./internal/appdir
  ./internal/update ./internal/settings ok.
- wsl-run (Ubuntu 24.04): go test ./internal/appdir ok.
- win-run (Windows 11): ./internal/appdir and ./internal/update: all pass
  but TestFoldersJoinedOnce (filed #4846) and TestPackagedByDpkg (#4603),
  both red the same on an unchanged b61121503 tree run there.

Broken by hand: shared() judging a moved folder as home's (the v0.1.2648
rule): TestResolveMovedDownloadsKeepsData red ("installed has old files:
\"\", want the data folder"; Passed names it).

Not tried: a real Downloads redirected on Windows, or a real update from
v0.1.2630 on such a layout; jwaitq's OS isn't known yet, and on a Mac
nothing about where data lives changed in v0.1.2630..2670.
2026-11-02 11:47:46 +08:00
yetone b611215034 gateway: a relay's 400 "concurrency limit, retry later" says the agent can retry (#2372, zminds, ump45nose)
3d63fc9cb made an in-stream 408/429/5xx say "(<status>: you can retry
your request)", so Pi, which decides from the text alone, tries again.
zminds' other case wasn't covered: a relay answering 400
{"message":"Concurrency limit exceeded for account, please retry
later","type":"upstream_error"}. magpie's group already fails over on
it (quotaWords has "exceeded"), but when every member says it, the text
Pi got was the relay's own, which matches none of Pi's retry words, so
the run ended after one try.

What changed: saysBusy adds " (busy: you can retry your request)" to a
400, 409 or 422 whose text says the upstream is busy (concurrency limit,
too many pending/concurrent/in-flight requests, temporarily
unavailable, retry/try again later, 并发, 稍后重试), unless it also
names spent money or quota (quota, insufficient, balance, credit,
billing, budget, usage limit, 余额, 额度, 欠费, 套餐, 用量), which a retry
doesn't fix, or already says it passes, or is too long to be a short
reason. It runs on both the whole reply (writeErrorSaid) and the
stream's error event (streamError). The status sent is unchanged.

Run at the pushed head, on mote:
- TestBusyRelaySaysItPasses (new; the words, and what keeps a text as
  it is: spent quota, other statuses, already said) and
  TestGroupBusyRelaySaysItPasses (new; a two-member group, both
  answering zminds' literal 400 body, whole and stream, and the text
  the agent gets passes Pi's own retry and deny regexes): ok, beside
  TestStreamErrorSaysItPasses and TestGroupLastFailureInStreamSaysItPasses.
- Broken by hand: saysBusy a no-op, both new tests red.
- go test -tags nogui -timeout 45m ./internal/gateway/: every test ok except
  TestCodexPoolSaysTheClientsVersion, red the same in a full run at a
  clean d39358f1b (origin/main) copy and green alone there; it is
  #4807 (another test's Codex identity reaches it).
- GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gateway/:
  ok; gofmt -l clean.

Not tried: a real Pi run against a busy relay. ump45nose's Cursor batch
502 is not changed here; a 5xx already carries its status (and in a
stream, 3d63fc9cb's wording), but that wasn't watched in a real run.
2026-11-02 11:15:43 +08:00
yetone 0431793db4 provider: a key added beside others takes the models its own list has
Young on Discord: a provider of several keys, each of a relay group that
serves some of its models, had every key added or imported allow every
model, so the user narrowed each by hand, and requests went to a key
that can't serve the model.

A key added now (GUI Add key, Import keys, several keys pasted in the
provider's key field, and Import local configurations, CC Switch's
entries folded into one provider included) is asked for its own
/models, with that key alone, within the add's 8s wait and beside the
provider's own Fetch. What it answers becomes its AccountModels when it
leaves out a model the provider's other keys serve.

Only a new key with no models of its own is given a list: the keys a
provider had keep theirs (none, or the user's), and a pick the user
makes while the list is asked is kept. A key whose list can't be told
keeps every model, as before, and no empty list is written: a refused
key, an empty list, one past the wait, a base that didn't answer (its
part would be the provider's old list), a vendor with no list
(Preset.NoList, plan-only presets, Cline and Kilo's feeds), a provider
of one key, and a key that lists every model the others do (a list
would only hold back what the vendor adds later).

The CLI has no key add (`provider key` replaces the key), so it is
unchanged.

Run on mote at the pushed head (on origin/main fa6725ee7):
- go test -count=1 -timeout 45m ./internal/provider/: ok
- go test -count=1 -timeout 45m ./internal/gui/: ok but
  TestMainWindowCorners, red the same 3 of 3 on origin/main b3eb26400
  on mote's macOS 27 (#3949)
- GOOS=linux go vet -tags nogui ./internal/provider/ ./internal/gui/
  and GOOS=windows go vet ./...: clean
- gofmt -l internal/provider internal/gui: clean
Tests use a fake relay that answers per key (httptest), no network.

Broken by hand, each red:
- give existing keys a list too (drop the before check):
  TestNewKeyTakesItsOwnModels (2 keys given a list, want 1)
- take a list with a base that didn't answer:
  TestNewKeyHalfAnsweredKeepsAll
- give a list even when it has every model, and skip the Save:
  TestNewKeyTakesItsOwnModels / TestImportedKeysTakeTheirOwnModels

Not tried: a real relay account with per-group keys; the "replace key"
action (it keeps the key's slot); a model the vendor later adds to a
prefilled key's group is added by hand in the key's models, as with
any list. No GUI asset changed.
2026-11-02 11:09:11 +08:00
fa6725ee7f grok: an account with no plan says Grok, and the provider is Grok, not "Grok (SuperGrok)" (#3668, zane668, skygunner)
zane668's two Grok accounts both showed "SuperGrok", one of them on a
plan that isn't. Two places named a tier no one had told magpie:
- the account chip's Grok branch (accountPlan in app.js) fell back to
  the literal "SuperGrok" when the plugin reported no plan, and the Grok
  plugin reports none, so every account said it;
- the retired built-in's provider name (movedCards in plugin_usage.go)
  and the Add sheet's Grok tile were "Grok (SuperGrok)".
A known plan is still shown as told; with none, the chip says the
provider's own name, Grok. The provider row and the Add tile say Grok;
the tile's plans line still lists "SuperGrok · X Premium+" as the plans
it takes.

skygunner's patch (their branch fix/r25-grok-plan-absent-label, commit
7ca156c68, on #3668) is the app.js fallback and grok-plan.test.cjs, with
plugin-plan.test.cjs updated; applied as written. The provider name and
the Add tile are added here.

Not changed: the plugin's own name "Grok (SuperGrok)" in
magpie-community/plugins (packages/grok), which magpie's moved-card name
overrides, and the plugin still returns no plan, so the real tier needs
Grok's API for it, which isn't known yet.

Run at the pushed head, on mote:
- GUI (chromium + webkit, narrow widths, every language): grok-plan
  (new), plugin-plan, i18n-keys, add-sheet, deprecated-subscriptions,
  plugin-market, provider-listed-as, plugin-movable-review,
  plugin-signed-out-account: 65 pass, 0 fail.
- go test -tags nogui ./internal/provider/ ./internal/gui/: ok
  (TestMovedProviderName now expects "Grok").
- GOOS=linux and GOOS=windows go vet -tags nogui ./internal/provider/:
  ok; gofmt -l clean.
- Broken by hand: the "SuperGrok" fallback put back, grok-plan is red.

Not tried: the real Grok plugin signed in with a real account.

Co-authored-by: skygunner <84759+skygunner@users.noreply.github.com>
Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
2026-11-02 11:04:07 +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 46a13f8375 gateway: a Claude Code Message Threads turn is refused so it is sent again whole (#2480, zane668, Vincentzyx)
Claude Code's Message Threads (message-threads-2026-08-12) send
"thread": {"type":"create"} on a thread's first turn and
{"type":"continue","previous_message_id":...} after, and a continue
carries only what came after that message: the history, the system
prompt and the tools are left to the server. magpie keeps no thread and
never read the field, so a continue went on to the upstream as the
latest turn alone. Vincentzyx's case (#2480): 50,381 input tokens on one
turn, 2,034 on the next, and the model asked what the task was.

What changed: /v1/messages (and /messages) answers a request that names
a thread, create or continue, before it is routed, with Anthropic's
refusal for a thread it can't serve: 400 invalid_request_error,
error.details.error_code "thread_unsupported_request". Claude Code's
tether reads that code as "unsupported_request" and sends the same turn
again stateless, with the whole history, system and tools, and keeps
that thread stateless on that model for the rest of the session (read
from Claude Code 2.1.316's own code: "[tether] ...: resending this turn
stateless; this thread stays stateless on this model for the session").
A request with no thread, or "thread": null, is served as before.
Nothing is passed through for an upstream that might keep threads: magpie
routes each turn on its own, so a continue can't be trusted to reach the
upstream that saw its create.

Run at the pushed head, on mote:
- TestMessageThreadsSentAgainWhole (new; #2480's own synthetic bodies,
  both paths, create and continue; and the turn sent again whole is
  served with its system and tools): ok.
- Broken by hand (the check turned off): red, the create and the
  continue both reach the fake upstream with "thread" in them.
- go test -tags nogui -timeout 45m ./internal/gateway/ at the rebased
  head: every test ok except
  TestCodexPoolSaysTheClientsVersion, red the same in a full run at a
  clean d39358f1b (origin/main) copy and green alone there; it is
  #4807 (another test's Codex identity reaches it).
- GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gateway/: ok;
  gofmt -l: clean.

Not tried: a real Claude Code session through magpie on this build (no
real thread was sent here; the retry is read from the client's code, not
watched). count_tokens isn't checked for a thread; Claude Code wasn't
seen sending one there.
2026-11-02 10:58:10 +08:00
yetone 838d12d6f8 sessions: the Move sessions to Codex's provider dialog has Select all and Invert selection
Cyrus on Discord asked for a way to pick all and to invert the picks in
the "Move sessions to {to}?" dialog (the Codex sessions made with another
provider, each with a checkbox).

Over a list of more than one, a quiet row above it now says how many are
picked ("{n} selected", the core's word), with two text buttons: Select
all, which reads Deselect all once every one is picked, and Invert
selection. Each press re-ticks the boxes; the count and Move follow, and
Move is off with none picked, as it was for boxes unticked by hand. A
list of one has no row. Plain text buttons, no native select, no
coloured border. Only the sessions plugin changes (client.js, its CSS
and i18n.js); app.js and the core budget are untouched. "Select all" and
"{n} selected" are the core's keys; "Deselect all" and "Invert
selection" are new, in zh, zh-TW, ja and de.

Run on mote at this tree (base d39358f1b, rebased onto origin/main
1a864f156, which touches no sessions-plugin file; the new test, the old
codex-provider test and i18n-keys ran again at the rebased head, 18 of 18):
- new internal/gui/tests/sessions-codex-provider-pick.test.cjs: 10 of 10
  (chromium and webkit x en, zh, zh-TW, ja, de) at 420px: the row sits
  above the list inside the dialog, no sideways scroll; Deselect all,
  Select all, a box unticked by hand then Invert, Invert of all to none
  (Move off), and Move posting exactly the picked ids in order.
- every internal/gui/tests/sessions-*.test.cjs plus i18n-keys: 465 of 465.
- go test -run 'Budget|Asset|Plugin|I18n|Strings' ./internal/gui: ok.

Broken by hand: Move's disabled no longer following the picks, and
Invert only adding: each turned the new test red.

Not tried: the real app window with real Codex sessions of another
provider; the whole GUI suite (app.js is not touched).
2026-11-02 10:34:27 +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 fdfce4d986 provider: WorkBuddy's mover asks for opencode-workbuddy-auth 0.2.11, whose card shows the plan's credits apart from gifted ones (akic404)
akic404 on Discord: "workbuddy 积分总量可否分离套餐内的总量和赠送的总量?…
现在这样那个匀速用量线实际没意义的". The plugin summed every package of the
resource summary into one "Credits" window, so gifted and activity credits
used long ago put the card at most of its allowance on the first day of
the month. magpie-community/plugins 486a68a (workbuddy 0.2.11) splits it
by package code, as WorkBuddy's own client groups them: "Credits" is the
plan's packages (those the client refreshes each cycle, or the named
subscription) with the plan's cycle, "Extra credits" the ones that only
lapse. One of the two is set aside, so routing still stops the account
only when both are spent. keepMovedCurrent brings every moved user up to
it.

Run, on mote at this tree (origin/main 18c397623):
- gofmt -l internal/provider: clean; GOOS=linux and GOOS=windows go vet
  ./internal/provider: ok.
- go test -count=1 -timeout 45m ./internal/provider: ok (102.9s).
- npm view @magpie-community/opencode-workbuddy-auth version
  --prefer-online --registry https://registry.npmjs.org: 0.2.11.
- The plugin side (in 486a68a): the plugins repo's whole bun test, 4730
  tests, 0 fail; packages/workbuddy 305 pass; its new tests red on the
  old index.mjs (3 fail, "282 / 3400" where "0 / 500" is wanted).

Broken by hand: nothing on this side; the change is the min string.
Not tried: a full go test ./... (only internal/provider, which holds the
mover); a real moved user's plugin updating to 0.2.11; akic404's own
account. "Extra credits" has no GUI translation yet, so it reads in
English, as "Prepaid credits" does.
2026-11-02 09:39:12 +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 33f21bdb1f otlp: a global proxy switch drops the exporter's idle connection to the collector (#4824)
The residue ggbdpq's #4824 patch named. The OTel exporter keeps its own
long-lived transport (Proxy: netproxy.Func). An https collector gets
HTTP/2, which pools by authority alone, so after the global proxy moved,
every batch kept going through the old proxy's connection. The exporter
now holds a netproxy.Watch, and send closes the client's idle
connections when the proxy has moved since the last send. An exporter
built without one (otel_cost_test's literal) skips the check.

Run at the pushed head (on mote, base 4d55a0a02)
- TestOTelGlobalSwitchDialsThroughTheNewProxy is new. It uses an HTTPS
  HTTP/2 collector and two counting SOCKS5 proxies, and passes. The
  otlp package passes.
- The full suite, gofmt and the cross-OS vet are as recorded in the
  #4824 netproxy commit before this one. The only reds are #4826 and
  #4807, neither in otlp.

Broken by hand: with the moved check off, the test is red: "after the
switch: 2 at the collector, 1 connections through A, 0 through B".

Not tried: a real OTel collector behind a real proxy switch.
2026-11-02 09:11:30 +08:00
ggbdpqandyetone 3ed3605ba0 netproxy: a global proxy switch drops the idle connections of the sync and the icon fetch (#4824)
ggbdpq's patch (gua2100 on Discord), reviewed and landed with test
changes.

What changed
- netproxy.Watch gives the dispatch's per-request check for a moved
  global proxy (#4523) to transports magpie keeps for itself. The sync
  (davsync) uses http.DefaultTransport, so when one of its requests
  finds the proxy moved, it now drops the idle connections itself.
  Before this, only a DefaultClient request dropped them, and a backup
  kept going through the old proxy's HTTP/2 connection.
- FetchIcon now closes the pool of the client that only the fetch used.
  Nothing closed it before.
- Review changes: the davsync test restores settings.json afterwards,
  and the icon test's wait for idle is bounded at 20s, not 2s, to leave
  room under load.

Run at the pushed head (on mote, base 4d55a0a02)
- go test -race passes for netproxy, davsync and provider's touched
  tests.
- go test -tags nogui -count=1 -timeout 45m ./... passes every package
  except two reds already filed and not touched here:
  - internal/cli TestEveryRouteHasACommandOrIsNamed (#4826, red on main
    since e87140242);
  - internal/gateway TestCodexPoolSaysTheClientsVersion (#4807, another
    test's Codex identity, passes alone).
- gofmt -l is clean. go vet ./... passes for darwin, for GOOS=linux
  (-tags nogui) and for GOOS=windows, and so do the linux and windows
  builds.

Broken by hand
- With stall.go's move check off, TestGlobalSwitchDialsTheSyncThroughTheNewProxy
  is red: "1 connections through A, 0 through B".
- With FetchIcon's CloseIdleConnections removed,
  TestFetchIconLeavesNoIdleConnection is red: "the fetch's connection is
  still idle".
- With Watch never reporting a move, TestGlobalSwitchDropsTheOldProxyConnections
  and TestWatchSeesTheGlobalProxyMove are red.

Not tried: a real proxy switch with a real WebDAV/S3 target or icon
host, or Windows/Linux at run time (vet and build only).

Co-authored-by: yetone <yetoneful@gmail.com>
2026-11-02 09:11:30 +08:00
yetoneandggbdpq 4d55a0a02c provider: Cursor's mover min is 0.2.37, which starts a long step on a fresh Run and says to retry a deadline cut (#4419)
Okxdd123 (#4419): a Pi turn on cursor/grok-4.7@500k went on in a
retained native Run with 494 s of its 15-minute lifetime left, and the
deadline cut the answer with "native Run lifetime expired", words Pi
doesn't retry on. ggbdpq found the cause and wrote a gateway-side patch
and repro; the plugin owns both the deadline and the words, so the fix
is there (magpie-community/plugins#616, 3f615ea):

- a step with under 10 minutes of the lifetime left goes on a fresh Run
  from the history instead of the old Run (was: the last minute);
- a Run the deadline still cuts says "native Run lifetime expired: the
  Run timed out; retry your request", which Pi's retry list and
  magpie's passingSaid both take.

This raises the mover's min to 0.2.37, so keepMovedCurrent updates every
moved user's plugin. npm view --prefer-online shows 0.2.37.

Run (mote, temp HOME): go test ./internal/provider ok (103.9s); go vet
./internal/provider for darwin, GOOS=linux -tags nogui and GOOS=windows
clean; gofmt -l internal/provider prints nothing.

Not tried: a real Cursor account reaching the deadline, or a real moved
user's plugin update to 0.2.37.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-02 08:07:45 +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 8e884421cb library: opening the page draws it again only for a change (#3099)
Every opening of the Library (its nav clicked, while on it too, or back
from another page) read the library and drew the whole page again,
changed or not. The rows were replaced under the reader's pointer, so
the trash shown on a row's hover went away mid-click, and
library-row-remove's click measured a row already gone: red about half
the time in Chromium since 10-29 (the test opens the page at
?view=library, then clicks Library again). Opening the page now draws it
again only when the library changed, or on RTK's tab, which is asked
again each time; a language change still draws it all again.

Found by logging render()'s callers: two opens, the second drawing the
same library 10-20ms after the first.

Run on mote at this head (7e201ce20 + this): new
library-open-again.test.cjs (Chromium and WebKit, 1100/420px, en/zh)
10/10, red on the old code ("the row was drawn over again, nothing
changed"). library-row-remove alone 22/22 three runs (it was red 3 of 3
at 7e201ce20). library*, i18n* and plugin* GUI files, both engines:
1914 pass, 6 fail, the 6 in plugin-move-unserved and plugin-card-update,
red the same way on a clean 7e201ce20 copy (filed separately).
go test ./internal/gui: ok.
2026-11-02 07:51:12 +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 22f69ae443 gateway, routing: a group in a group says the group above picked its reasoning (#4358)
30c55ff5e skips a nested group's effort classifier once the group above
picked, and traced it as Classified{Error: "the group above already
picked this turn's reasoning"}. The Routing page reads an Error with no
intents as "{by} was to rate how hard turn {turn} is, but couldn't —
{err} — so it reasons as the agent asked", which is wrong: the turn
reasons at the group above's pick.

Classified gets Above, the pick of the group above, in place of that
Error (also on a classifier still asked for intents), and classWhy says
"{by} wasn't asked how hard turn {turn} is: the group above picked
{level} reasoning for it.", in zh, zh-TW, ja and de too.
TestNestedGroupClassifierNotAskedWhenTheParentPicked checks the nested trace carries
Above "high" and no Error; routing-classifier-above.test.cjs checks the
line in every language at 1100px and 390px, with no sideways scroll
and without the old "reasons as the agent asked".

Run on mote: go test -tags nogui ./internal/gateway/ -run
'Nested|Classif|Intent|Effort|Rule' ok; node --test (chromium and
webkit) routing-classifier-above, routing-classifier-said,
routing-intent-fallback, routing-smart-intent and i18n-keys: 124 of 124
pass. Broken by hand: classWhy without the Above branch, the new GUI
file 0 of 10 in chromium.
Not tried: a real nested effort=auto group.

The whole batch (101e6201c..this, gua2100's five patches and three
follow-ups) at this tree, on mote: gofmt -l clean; go vet -tags nogui
for GOOS darwin, linux, windows, and go vet (GUI) darwin, all ok;
go test -tags nogui -count=1 -timeout 45m ./...: 85 packages ok and 2
reds, neither from this batch. internal/cli
TestEveryRouteHasACommandOrIsNamed is red at origin/main ad53a23dc too
(POST /api/usage/checkin-account, from e87140242; #4826). internal/gateway
TestCodexPoolSaysTheClientsVersion passes alone 3 of 3 at the base and at
this head (#4807).
2026-11-02 07:40:21 +08:00
yetone 1ad8b20c7a library: the sweep of ~/.agents/skills leaves the user's own entries (#4379)
e938a4f13's sweepShared removes magpie's entries from the shared folder
once no agent whose folder it is gives them. Its tests cover magpie's
links only. TestKimiSweepLeavesTheUsersOwnSharedSkills puts the user's
own folder, a folder by the name of a library skill Kimi Code is given
(pdf), and the user's own link to a folder elsewhere into a sandbox
HOME's ~/.agents/skills, syncs twice, and checks each is still there with
its SKILL.md and link target unchanged. A skill given to Kimi Code and
Codex (both read the shared folder besides their own) lands in each
one's own folder, not the shared one. Test only; no code change.

Run on mote: go test -tags nogui ./internal/library/ -run
'Kimi|Shared|Skill' ok. Broken by hand: the sweep without its ours()
check deletes all three of the user's entries (the new test red);
without the sweep step TestKimiOldSharedEntrySwept is red; Kimi Code's
folder put back to ~/.agents/skills turns all three Kimi tests red.
Not tried: a real Kimi Code 2.x reading the folder.
2026-11-02 07:40:21 +08:00
yetone a130035a0d gateway: only a relay whose list draws a GPT Image takes the family (#4432)
34199952b let any keyed provider at a Responses base draw every
gpt-image-* name. Its body says "a Codex backend relay whose model list
carries any gpt-image* name", but the code read no list: a chat-only
relay ahead of one that draws took a bare gpt-image-2 and failed it at
its vendor, and a Codex turn on a chat-only relay lost the Settings pick
it drew with before. The patch changed TestCodexDrawingFallsBackToImage-
Setting's expectations (and moved its "off" checks to no turn) to fit.

drawsFamily now takes a keyed Responses relay only when its own Drawers
hold one gpt-image-* already, as the patch's description had it. Both of
the patch's tests stay green; TestCodexDrawingFallsBackToImageSetting is
back to its form before the patch, and TestRelayDrawingNoGPTImageClaims-
NoneOfTheFamily covers the chat-only relay.

Run on mote: go test -tags nogui ./internal/gateway/ -run
'Draw|Drawing|Relay' ok. Broken by hand: the case returning true for any
gpt-image-* (the patch's rule) fails the new test (plain/gpt-image-2)
and TestCodexDrawingFallsBackToImageSetting (text-only/gpt-image-2);
the case removed fails the patch's two tests and the new one.
Not tried: a real sub2api relay (loscoy's), whose list magpie_image
drew from per the report.
2026-11-02 07:40:21 +08:00
ggbdpq 7e44e57b4e fix(gateway): a Codex backend's relay draws the gpt-image family it serves (#4432)
A harness asking for its own image model by the bare name its vendor
gives it (Codex CLI asks its provider for gpt-image-2) was turned away
by magpie when the provider is a Codex backend relay (sub2api) whose
model list names another of the family, or none: drawsFamily admitted
only a ChatGPT account and a Grok subscription, so resolveDrawing
answered 404 "magpie knows no model "gpt-image-2" to draw with", and a
Codex turn's own provider lost the drawing to magpie's Settings pick,
the harness's own model overridden. The relay serves the ChatGPT
backend's images API, which draws the same for any gpt-image-* name
(#1865), as #870 had it draw its listed ones; it draws the family the
same way, the vendor refusing in its own words one it doesn't serve.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-02 07:40:21 +08:00
ggbdpq ecdcbe48a8 fix(library): give Kimi Code its own skills folder (#4379)
A skill given to the new Kimi Code (2.x) had no folder of its own to
go to: its target was ~/.agents/skills, which fourteen other agents
read as well, so it reached every one of them whatever the library
ticks, and the page locked their chips for it. Handing it over to the
library didn't isolate it either: Kimi Code's own link was written
into the shared folder all the same, and no sync took it out, since
none of the agents whose folder the shared one is had given the skill.

Kimi Code 2.x reads a folder of its own besides the shared one
($KIMI_CODE_HOME/skills, else ~/.kimi-code/skills - docs/
customization/skills.md, "Skill Locations"), so its skills go there
now, and it joins readsShared: a skill kept in ~/.agents/skills for
another agent is read where it is, with no second link in Kimi
Code's own folder. The legacy kimi-cli branch stays as it was: it
reads the first of ~/.kimi/skills, ~/.claude/skills, ~/.codex/skills,
so a folder of its own would hide Claude Code's from it.

What an older magpie put in ~/.agents/skills for Kimi Code is swept
out: an entry of the library's own stays there only while an agent
whose folder the shared one is still gives the skill. The user's own
entries stay, and so does a copy takeEdits couldn't scan.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-02 07:40:21 +08:00
ggbdpq 339ff564e6 fix(gateway): skip a nested group's effort classifier when the group above picked (#4358)
A group reached through a parent group runs its own classifier when it is
effort=auto, even after the parent's classifier already picked the turn's
reasoning: the request goes out at the parent's pick (the outermost pick
stands, gateway.go), so the group in it pays for an answer the turn throws
away. On one reporter's day the group in it answered 27 of 28 such turns,
2-8 s each, and 14 of the 28 parent picks discarded the answer.

ruleFor now takes the pick a group above it already made: with one standing,
the classifier is not asked for the effort again. The intents, when the
group's rules have them, are still asked — they are the group's own routing.
The trace says why nothing was asked. The fallback keeps working: the group
in it is asked as before whenever the group above gave no pick.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-02 07:40:21 +08:00
ggbdpq 021a75762a fix(copilot): list an Experimental vendor's model the picker offers (#4343)
What changed: copilotModels dropped every model whose vendor is
"Experimental" before looking at anything else, so mai-code-2-flash —
an Enterprise account's, vendor "Experimental", model_picker_enabled
true, served on /responses — never reached the catalog. A saved
selection of it then failed everywhere with "copilot has no model
mai-code-2-flash (magpie provider copilot lists them)" (serves() is
Available() ∪ Exposed(), both built from the fetched list).

The vendor is now only one more reason a model no picker offers stays
out: an Experimental model the picker offers (model_picker_enabled
true) is listed, as VS Code's own picker shows it. One the picker
doesn't offer (kimi-k3-base) stays out.

Run: TestCopilotSignAndModels fails on the old code (ids end
"gpt-4.1,auto"), passes now; the fixture carries both shapes.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-02 07:40:21 +08:00
ggbdpq f0b9c8af9c provider, plugin: a plugin's word on its model's inputs stands without a word of images
pluginCatalog read a plugin's word on what its model takes only where the
plugin also said whether it takes images: the InputModalities assignment
sat whole behind ImageSaid, so a model said text alone (Command Code's
plans, no word of images, #4436) came out with no input modalities at
all, though the host had passed its inputs through.

But the host's passing them through is not the plugin saying them: for a
config model nothing was said of, the host's own default capabilities
say input {"text": true} (internal/plugin/host.js), and listing that as
the model's word would claim text-only of a model nobody described,
which the readers read as no images — what the #1595 guard exists to
keep out. The first cut gated on the inputs being non-empty and did
just that; this one asks the host whose word the kinds are instead.

inputSaid keeps that default ({"text": true} alone) out: whoever says
the kinds says them each, models.dev and the config expanding them all,
a plugin's models hook giving its own. The model carries inputsSaid as
it carries outputsSaid, and pluginCatalog gates InputModalities on it:
Command Code's plans list their inputs, a model nobody described still
lists none.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-02 07:40:21 +08:00
yetone eceb815160 site: the IndexNow key, so Bing and the other IndexNow engines take our URLs
IndexNow checks that a submitter owns the site by fetching this key at
the site's root; it stays as long as we submit.

Run: nothing; it is a static file, checked live after deploy.
2026-11-02 07:34:43 +08:00
yetone 377e3ca6e8 site: the Google Search Console verification tag on the home page
Search Console verifies https://usemagpie.ai/ by this meta tag and checks
it again later, so it stays.

Run: on mote, node --test worker.test.mjs install.test.mjs from site/:
54 of 54 pass.
2026-11-02 07:32:49 +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
yetone c3048cd266 site: a sitemap, robots rules, a searchable title and canonical docs pages
usemagpie.ai had no sitemap, a robots.txt with Cloudflare's comments
only, a home page titled just "magpie" in every language, and docs
pages with no canonical or x-default.

- public/sitemap.xml lists the home page in en, zh, ja and de and every
  docs page by its clean URL. A test fails when a docs page on disk is
  missing from it, or it lists one that isn't there.
- public/robots.txt names the sitemap and keeps crawlers off /api/,
  /go/, /r/ and /download, so a crawler's fetch isn't counted as a
  download or a partner click.
- The home <title>, og:title and twitter:title name the agents
  ("magpie: one model switcher for Claude Code, Codex and Gemini CLI"),
  translated by worker.js like the rest (meta.title, meta.locale in
  i18n.js). og:type, og:site_name and og:locale are added, plus JSON-LD
  for a free, MIT-licensed SoftwareApplication and the WebSite.
- Each docs page has rel=canonical to its own clean URL and an
  x-default alternate to the English page, plus og:site_name. A test
  checks each one, and that every hreflang alternate is a listed page.

Run: on mote, node --test worker.test.mjs install.test.mjs from site/
at this tree: 54 of 54 pass. Broken by hand in a copy: a docs page
without its canonical, and the sitemap without docs/zh/docker, each
turns the sitemap test red.
Not tried: Google's Rich Results test; the live check is after deploy.
2026-11-02 07:08:49 +08:00
yetone 6247086fe9 agent: Alma's providers are decoded once per answer kept
A heap profile of the live magpie (v0.1.2646, 37 minutes, the owner's
real accounts) had almaProvidersSeen decode Alma's whole /api/providers
answer 390MB worth: the Agents page's model field (almaGet, 221MB) and
Alma's check (alma.func1, 167MB) each decoded the answer almaSend
already kept for 5s, every poll.

almaProvidersSeen keeps the slice it decoded beside the bytes it decoded
it from, and gives it again while almaSend gives the same kept bytes. A
new answer (5s on, or any change sent to Alma, which forgets the kept
ones) is decoded anew; a failed read is an error, never the last good
answer. Its three callers only read what it gives.

Run on mote (macOS 27.2):
- TestAlmaProvidersSeenDecodeOnce (new): 400 known models; 10 allocs or
  fewer a look, one ask of Alma, the new models after a PUT, an error
  with Alma gone. With the bytes check turned off by hand: "a look at the
  answer kept allocates 6833 times", red. Restored: ok.
- The owner's real Alma answer (227KB with keys blanked, 11 providers,
  539 models; probe not committed): a look 1,182,317 B / 30,690 allocs
  before, 48 B / 1 after.
- go test ./internal/agent: ok (161.6s); -race -run TestAlma: ok.
- gofmt -l clean; go vet, GOOS=windows and GOOS=linux go vet: ok.
2026-11-02 07:06:24 +08:00
yetone 78cbb711d9 agent, codexcat: a poll asks Vision once per stamp and reads Codex's cache levels once per change
A heap profile of the live magpie (v0.1.2646, 37 minutes, the owner's
real accounts) had buildModels allocate 1288MB. 553MB of it was the
gateway's seer, asked once per list build (provider.Described), and
238MB was codexEfforts -> TakesEffort -> CacheEntries, which decodes the
whole Codex models_cache.json for each model asked.

- buildModels asks describedNow(), kept per provider.StampNow() in a
  stampedLists like the lists themselves, so every agent's list of one
  stamp shares one answer, and a change (a provider saved) asks again.
- TakesEffort reads a slug's default level from cacheLevels(), a
  filememo.Read of the cache file by its stat: the decode keeps only
  each model's level, and runs again when the file changes. magpie's own
  added entries are skipped as CacheEntries skips them.

Run on mote (macOS 27.2):
- TestListsAskVisionOnce (new): pi, claude, codex, opencode, droid and
  dsh lists ask Described once; after a provider save, once more, and a
  "no" reaches the new list. With buildModels asking Described itself
  (put back by hand): red. Restored: ok.
- TestTakesEffortReadsTheCacheOnChange (new): a 300-model cache, levels
  for a slug and codex/<slug>, the default for magpie/x and an unknown
  one, 20 allocs or fewer a look, and the new level after a rewrite a
  minute later. With TakesEffort on CacheEntries again (by hand): red.
  Restored: ok.
- go test ./internal/agent ./internal/codexcat at this tree: ok (162.5s).
  ./internal/gateway and ./internal/gui at the tree before the test's
  last fix (only the new test changed since): ok but
  TestCodexPoolSaysTheClientsVersion (#4807, red in a full gateway run
  on mote, untouched here) and TestMainWindowCorners/macOS_26_SDK
  (#3949, red on macOS 27).
- gofmt -l clean; go vet, GOOS=windows and GOOS=linux go vet of both
  packages: ok.

Not tried: a heap profile of a live build with this change.
2026-11-02 06:59:17 +08:00
yetone 7e201ce20d browser: one tool, browser, whose action says what to do
magpie-browser listed 17 tools (11,483 bytes of schema in every request);
it now lists one, browser, whose action picks what to do (4,087 bytes).
The old tool names are still accepted on tools/call, and text the
extension writes about browser_X now says "the X action".

Any action takes screenshot: true and returns the page after it, as a
1024px-wide JPEG (q70), so an agent sees the page without a second call.

Run on mote at this head: go test -tags nogui -run Browser
./internal/gateway/ with a real Chromium: ok, including
TestBrowserToolActionsInARealBrowser. TestBrowserToolCallsTheExtensionsTool
went red with the name rewrite taken out by hand and with the downscale
taken out (2880x1800 stays 2880x1800). gofmt clean; go vet -tags nogui for
darwin, linux and windows ok. Not tried: Claude Code and Codex using the
one tool against a live gateway.
2026-11-02 06:40:03 +08:00
yetone da23fcb169 browser: frames from other sites are read and acted on; failures say their kind
A page's cross-site iframes (out-of-process frames) were missing from the
snapshot: Page.getFrameTree on the parent doesn't list them, so a checkout
form or a login inside such a frame couldn't be read or clicked. The
snapshot now adds each frame whose session was auto-attached under its
parent (t.frameOf), and actions on its refs go to that frame's session.

A failed action now says its kind (STALE_REF, DIALOG_OPEN, LOAD_FAILED,
PAGE_BLOCKED, WAIT_TIMEOUT, OUTCOME_UNKNOWN, BAD_ARGS ...) with what to try next, and an action
settles on the DOM going quiet before it says done. Extension 0.1.3.

Run on mote at this head: go test -tags nogui -run Browser
./internal/gateway/ ./internal/browserext/ with a real Chromium
(MAGPIE_BROWSER_CHROME, Chrome for Testing 1234): ok, including
TestBrowserFramesAndFailuresInARealBrowser. Red on the old code ("no
textbox Card"); the settle taken out by hand made it red ("doesn't say
done"). gofmt clean; go vet -tags nogui for darwin, linux and windows ok.
Not tried: a real site's payment iframe in the owner's own Chrome.
2026-11-02 06:40:03 +08:00
yetone 35c47f762f agent: the window's drift poll parses dsh's YAML once per change, not per field and per look
The window asks /api/drift every 15s. On the owner's live magpie a heap
profile showed Drift and Values allocating ~3.3 GB in 37 minutes, most
of it DeepSeek Harness: settings.yaml (80 KB) parsed again for each
field GetYAML read (465 MB of it), and each profile entry's YAML parsed
again on each of dshCheck's looks (dshHomeHas, dshOver, dshConfigIndex,
dshRoutesIn, dshConfig).

- edit.loadYAML memoizes the parsed root through filememo, keyed by the
  file's stat, and shares it with GetYAML, GetYAMLMap, GetYAMLList and
  GetYAMLText, which only read it. Writes go through their own parse as
  before. BlockList skips the decode for a text that starts as a block
  list (blockSequence), which every dsh patch list does.
- dshNodeShared parses an entry's text once and shares the node with the
  read-only lookers (dshConfig, dshConfigIndex, dshRoutesIn, dshOver's
  patch side). The writers (dshOver's base, the route and start writes)
  keep dshNode's own copy. 512 entries kept at most.

Run on mote (macOS 27.2):
- Probe on copies of the owner's real ~/.dsh (settings.yaml, config.yaml,
  the desktop and web profiles; probe not committed, copies deleted):
  a.Values() + a.Drift() per poll, 20 polls: 16381 KB / 223788 allocs
  per poll with the edit change alone -> 4355 KB / 2588 allocs.
- TestGetYAMLParsesTheFileOnce (new): a look at a 3000-entry file
  allocates under a tenth of its size; sees SetYAML, another process's
  write, a removed file and a list-topped file.
  TestBlockSequenceAgreesWithADecode (new): ~24 texts against yaml's own
  decode.
- TestDshLookParsesAnEntryOnce (new): with dshConfig and dshConfigIndex
  put back on dshNode by hand: "27388 allocations, want a few", red.
  Restored: ok. It also checks a writer's change never shows in a look.
- go test ./internal/agent ./internal/edit: ok (164.2s, 5.9s).
  go vet both: ok. gofmt -l: clean.

Not tried: the full suite (only internal/agent and internal/edit
call these); a live window poll after the release.
2026-11-02 06:30:12 +08:00
yetone f1eeeb8fd5 sessions: a Codex session's window lives an hour past its last change, not five minutes (#4369)
A Codex rollout's summary and its calls each keep an index of what they
read (the Codex window) so the next lines are read on from where the last
read ended. A window was let go five minutes after its file last changed
(revisionIdle), so the turn after any longer pause (a long think, a
meeting, a review of the diff) read the whole rollout again from its
first line, for the summary and the calls alike: on #4369's real
rollouts, 21.5 MB read twice for one line.

revisionIdle is an hour, as a working Claude window's already is
(revisionWorking). What can be held is bounded as before:
revisionFiles (8) windows within revisionEntries, and revisionActiveFiles
(2) past it up to revisionActiveEntries each, so the most held is what
working sessions held already; an idle one is held longer. A session
left over an hour is read whole once on its next turn, now in one pass
for both readers (the commit before).

Run on mote (macOS 27.2):
- TestCodexSessionReadOnAfterAPause (new): a 40-call rollout last changed
  ten minutes ago is read (calls, then List), a turn appended: no scan
  of it from 0, 41 calls. With revisionIdle back at five minutes:
  "the turn after a pause read the rollout from its first line: [0 0]".
  Restored: ok.
- go test ./internal/sessions -run
  "Pause|Revision|Settled|LongCodex|PlainRollout": ok.
- go test -timeout 45m ./internal/sessions ./internal/usage
  ./internal/gateway ./internal/gui: ok for sessions (11.3s, -race 56.2s, at this tree), usage (30.2s), gateway (575.6s); internal/gui: ok but TestMainWindowCorners/macOS_26_SDK, red on macOS 27 as #3949 records (same message), untouched here
- TestIdleWindowsYieldToRecentWork's ten-minute pause was written
  -2*revisionIdle (ten minutes at five); it is ten minutes as written,
  since at an hour it was a two-hour pause, past revisionWorking.
- gofmt -l: clean.

Not measured: RSS over an hour of real Codex use with several sessions
open; the bound is the count above, not a measurement.
2026-11-02 06:11:06 +08:00
yetone 2140f5b935 sessions: a plain Codex rollout read from its start has its calls read on the summary's pass (#4369)
A start parses every changed session file for Sessions (refresh ->
parseWith), then reads every changed file's calls for Requests
(ReadCallSource -> readCalls). callsAlong already let a packed rollout
and an unread Claude session be read once for both; a plain .jsonl
rollout was read twice. On copies of the owner's real ~/.codex and
~/.claude (1.7 GB), a cold start scanned 931 times, 3.49 GB, every large
rollout x2.

callsAlong now takes a plain rollout too, when both reads start at its
first line: the summary it goes on from has no Codex window (nothing
kept, or kept on disk, which holds none), and parseWith lets the ride go
when either read goes on from an offset (calls.st.Off as well as s.Off),
so a read on from where it was is two incremental reads, as before. A
summary that still has its window is passed in so such a file's calls
shard isn't loaded only to be let go.

keepCalls names the root when none is named yet. A ride keeps a
rollout's calls (Codex window and all) during the Sessions parse, before
any Requests read has called pruneCalls; pruneCalls took the empty root
for a moved one and dropped everything kept. The shard on disk has no
window, so the next line read the rollout whole again (in the same run,
seconds after the start). TestHistoricalClaudeFilesDoNotDisplaceActive
Windows went red on exactly that ("rebuilt active call shard" for its
Codex rollout) until this.

TestWarmReadsOnlyInItsSlots' calls phase found nothing left to read,
since the index phase now reads every file's calls along; it appends a
line to each source first, so the calls have reading of their own.

Tests' forget (in the new test, claude_ride_test.go and
codex_zst_warm_test.go) calls Reset before removing the cache file:
Reset writes a save still pending, which put back the file just removed,
and the next List then went on from disk states (no window), red 1 in
~40 under -race. TestHistoricalClaudeFilesDoNotDisplaceActiveWindows
waits for the save (saved()) before writing its marker onto a cached
state the save's goroutine was encoding (a DATA RACE under -race).

Run on mote (macOS 27.2):
- TestPlainRolloutReadOnceForSessionsAndCalls (new): 3 plain rollouts.
  Nothing kept: each scanned once, from 0. Read, kept on disk, the long
  one grown and Reset: that one scanned once, from 0. An append in the
  same run: no scan from 0 (with keepCalls' root line removed by hand:
  "an append: the long rollout read again from its first line:
  [213219 0]", and the Historical test red as above). Calls, List and StatsAt reflect.DeepEqual to
  a calls-first read without the ride in each case. With plain rollouts
  kept out of callsAlong by hand: "first read: ... scanned from [0 0],
  want once from 0" for all 3. Restored: ok. -race -count=80 with
  the Packed, ClaudeSessionReadOnce, CodexSessionReadOn, Historical and
  WarmReads tests: ok (108.8s)
- Real data (copies of 1.7 GB of the owner's sessions, probe run
  sessions.List(200), usage QueryPage Today and Week; probe not
  committed): cold 931 scans / 3.49 GB -> 718 / 2.10 GB, no rollout read
  twice; no change 0 / 0; the first line appended to the newest rollout
  after the cold read: read whole by both readers -> read whole once
  (1 scan, 10.8 MB; the before run's newest was a 21.5 MB one, read
  twice). It is read whole at all because it was last changed on 10-31,
  past any window's idle time: a session left that long is read whole
  once on its next line, now in one pass. Later lines: 2 scans, 0 MB.
- go test -timeout 45m ./internal/sessions ./internal/usage
  ./internal/gateway ./internal/gui: ok for sessions (11.3s, -race 56.2s, at this tree), usage (30.2s), gateway (575.6s); internal/gui: ok but TestMainWindowCorners/macOS_26_SDK, red on macOS 27 as #3949 records (same message), untouched here
- GOOS=windows and GOOS=linux go vet ./internal/sessions: ok. gofmt -l:
  clean.

Not tried: a packed rollout's path is unchanged (it rode before).
2026-11-02 06:11:06 +08:00