Commit Graph
3181 Commits
Author SHA1 Message Date
yetone a0c4dba97d gui: the tray icon closes an open panel on the Mac under a window over the whole screen too, not only when the panel can be seen (#1661)
TestTrayCellClickReleasedPanel went red with "initial quota click did not
open the panel". The cause: Wails' WebviewWindow.IsVisible on the Mac is
the window's occlusion state, not [NSWindow isVisible]. This Mac runs
UURemoteServer, whose privacy curtain is an opaque window over the whole
screen at layer 2147483631, above every app's. Under it, every window is
"occluded", so the panel the click had just opened read as closed.

The same check is a product bug too. togglePanelNow went through Wails'
SystemTray.ToggleWindow, which chooses hide or show by IsVisible. Under
such a cover, a click on the tray icon showed the already open panel
again and never closed it. With only the test's check changed, the test
failed on "second quota click did not close the panel".

Fix: on the Mac, togglePanelNow decides by windowOpen (shown and not
miniaturised, the check #1381 brought in for lightweight mode). It hides
the panel, or places it and shows it, itself. fitPanel, zoomWindows and
trayCellClick use windowOpen in place of IsVisible as well. Linux and
Windows still go through ToggleWindow, unchanged. The Hyprland branch's
IsVisible checks are left alone, since they are Wayland only. Both
AppKit tests (TestTrayCellClickReleasedPanel, TestPanelCloseHidesIt) now
read the panel's state through windowOpen. gui-shell.md item 5 says so.

Run, on darwin/arm64:
- Under an injected cover (scratchpad cover.swift: opaque, max level,
  sharingType none, the whole screen):
  - origin/main: TestTrayCellClickReleasedPanel 0/8, and
    TestPanelCloseHidesIt 0/4 ("timed out waiting until the panel shows").
  - Test-only change: 0/8 ("second quota click did not close the panel").
  - This commit: TestTrayCellClickReleasedPanel 25/25, and
    TestPanelCloseHidesIt 20/20.
- Under UU's own curtain:
  - origin/main: 30/30 red.
  - This commit: 10/10 green.
- Before the curtain was up, origin/main passed 75/75. Under an activator
  load, it was 5/40 red.
- go test ./internal/gui (GUI build) passes. go test -tags nogui
  ./internal/gui passes. gofmt is clean.
- go vet with -tags nogui passes for linux and windows; go vet passes
  on darwin.

Not tried: clicking the real status item by hand under a remote session.
The test drives trayCellClick and togglePanel's path through the host.
2026-10-12 01:45:14 +08:00
yetone 94fd332c35 agent, gui, tui: an agent's own models can be left out of its model picker (#1642, MizuIro-H)
DeepSeek Harness offers its own DeepSeek models beside magpie's in its
model picker, and nothing in magpie could leave them out: `magpie visible`
and the model list only cover magpie's catalog. An agent's model list now
has a switch at the top, "Show {agent}'s own models", for an agent that
has models of its own. Off, its picker offers magpie's alone.

- settings.OwnModelsHidden lists the agents whose own models are left
  out. provider.OwnModelsHidden / SetOwnModelsHidden read and write it.
  POST /api/settings keeps it: the Settings page doesn't send it.
- agent.Picks(f, cur) is a field's options without the agent's own
  (no Ref, a value). It leaves them in when the field has no magpie
  option at all, and always keeps the value the agent is set to now, so
  the user's own choice isn't dropped or rewritten. The GUI's agent
  fields and the TUI picker read it. The CLI still sets an own model by
  name.
- GET /api/agent-models/{id} says `own` and `ownHidden`. POST
  {ownHidden} sets it. The GUI's switch rolls back if the save fails,
  and closing the list filters the picker at once, before the state is
  read again. The order view (magpie's models alone) hides the switch.
- Strings in zh, zh-TW, ja, de.

Run: go test ./internal/agent ./internal/provider ./internal/settings
./internal/tui, all green. go test ./internal/gui is green apart from
TestTrayCellClickReleasedPanel, which fails the same alone on
origin/main ee20a1511 (#1661). The new TestAgentOwnModelsHidden goes red
with Picks returning every option. The GUI suites agent-*, gui-*, i18n-*
and settings-* pass 424/424. The new agent-models-own.test.cjs runs in
Chromium and WebKit, en/zh/de/ja, at 420 and 1100 wide, and goes red with
the close-time filter taken out. gofmt is clean, and linux and windows
vet are clean (gui on windows only).

Not tried: the real dsh in the live GUI.
2026-10-12 01:29:57 +08:00
yetone 781cb386cc gui tests: quota-curve measures the tray's spark in one go once it is drawn, so it no longer reads a card that was just redrawn as having no box
quota-curve.test.cjs could fail with "TypeError: Cannot read properties of
null (reading 'height')". It looked up the tray's spark and its card in one
call each, then measured them. When the tab opens, the allowances it reads
come back and the cards are drawn again (#1588). Under load, the card found
first could be taken out before it was measured, so boundingBox() gave null.

Now one waitForFunction finds the card and the spark, and measures both, in
a single pass in the page, once the spark has a width.

What was run, with one busy-looping node per CPU:
- origin/main 5dfcf4346, chromium only, 3 runs: red in 1 of 6 tests.
- This branch before this change, same load: red in 4 of 6.
- After this change, same load: 6 of 6 pass.
- Without load: quota-curve, balance-curve and panel-balance-order pass in
  both engines.
2026-10-12 01:19:37 +08:00
yetone 7c23ecea9d gui: the tray's quota spark no longer has a dotted now line, and clicking into the panel's list no longer rings the whole list (#1601, MizuIro-H)
The reporter uses the Linux GTK/WebKit tray panel. Two of their points
reproduce in both engines:

- The 16px spark under a card drew the large curve's dotted upright now
  line. In that size it reads as a stray mark under the curve. The spark's
  solid line already ends at now. drawQuotaPlot now leaves the now line out
  when it draws thin; the large curves keep theirs.
- A view takes focus (tabIndex -1) so the arrow keys scroll it after a
  click. A click and then a key made it :focus-visible, and the browser drew
  its own ring round the whole list: 3px in WebKit, 1px in Chromium.
  `.view:focus { outline: none }`. The view can't be reached by Tab, and
  every control inside it keeps its own ring.

The content cut off at the bottom in their screenshot is the list before it
is scrolled. Scrolled to its end at 440x560, the last card ends 44px above
the footer at both 1x and 1.75x, in both engines.

What was run:
- quota-curve.test.cjs now checks that there is no now line in the spark,
  and that a click and then a key leave the view with no outline.
- Breaking each fix by hand turns the test red in chromium and webkit, en
  and zh.
- quota-curve, balance-curve, readable-focus, click-scroll and
  panel-balance-order pass in both engines, twice in a row after the rebase.
  In one earlier run of this set, click-scroll's late-wheel subtest went red
  once in Chromium under load. It is filed as #1660; this change touches no
  scrolling.
- The new focus check runs after the spark is measured. A click focuses the
  window, the window's focus reloads the cards, and a card measured during
  that redraw had no box.
- A probe of the reporter's cards (Codex with credits, Command Code, and
  SudoCode and DeepSeek balances) at 440x560, 1x and 1.75x, light and dark.

Not tried: real Linux, WebKitGTK or Wayland. The lightweight panel that
never maps (Gdk-CRITICAL) is not looked at here.
2026-10-12 01:19:37 +08:00
yetone 9ce12eec71 gateway: a tool_use turn sent to DeepSeek's Anthropic endpoint carries a thinking block, so DeepSeek no longer refuses the request with 400, or with 422 over Claude's redacted thinking (#1611)
What changed: in thinking mode, DeepSeek's Anthropic endpoint
(api.deepseek.com/anthropic) refuses a request when an assistant turn has a
tool_use and no thinking block: 400 "The `content[].thinking` in the
thinking mode must be passed back to the API". It also refuses
redacted_thinking anywhere in the request with 422 "unknown variant
`redacted_thinking`". A Claude Code routing group whose Claude turns fall
over to DeepSeek met both refusals. This is the Anthropic-endpoint sibling of
#1592 (Responses) and #1462 (Chat).

- anthropicReplaysThinking(host, model): DeepSeek only, by host or model id.
  It is never api.anthropic.com or a Claude model.
- withThinkingOnToolTurns: a tool_use turn with no thinking gets a
  {"type":"thinking","thinking":" "} block first. Redacted thinking becomes
  that block, or is dropped when the turn already has thinking. The body is
  returned byte for byte when nothing changes.
- The passthrough and the translated build (a Chat/Responses client to an
  Anthropic-only DeepSeek) both use it. The translated build also replays
  the turn's own reasoning text, where it has one.
- docs/subsystems/gateway-routing.md describes it.

Checked live on 2026-10-11 against api.deepseek.com/anthropic with
deepseek-flash and deepseek-v4-pro:
- Thinking on (no field, enabled or adaptive) with a bare tool_use: 400.
- Thinking disabled with a bare tool_use: 200.
- redacted_thinking, even in a text-only turn: 422.
- Thinking " ", thinking "", unsigned thinking and thinking after text: all
  200.

What was run:
- New tests in deepseek_anthropic_thinking_test.go:
  - direct and through group/cc;
  - glm-5.2 and claude-sonnet-4-6 on the same upstream are sent unchanged;
  - the translated path;
  - the body is returned byte for byte when nothing changes.
- Breaking each call site by hand turns its test red.
- go test ./internal/gateway passed (410s). gofmt -l is clean, and go vet
  passes for linux, windows and darwin.
- End to end, with a built binary on port 3611 and a sandbox HOME holding
  the owner's real DeepSeek key:
  - before this change: 422 with redacted thinking, and 400 with thinking
    adaptive;
  - after it: 200 with a complete reply in all 8 cases (direct and
    group/cc, streamed and whole, adaptive and no thinking field).
2026-10-12 01:19:37 +08:00
yetone ee20a1511b gateway: the package's tests wait ~42s less for queues and OTel exports (#1654)
internal/gateway hit go test's default 10m timeout under a full ./... on
a loaded Mac. go test -json timed its 1583 top-level tests at ~306s
summed (they run one after another); the slowest few waited on real
clocks for things the tests don't check.

- TestQueuedStreamFailureIsTheStreamsError (27s -> 0.3s): it queued for
  room in a 3s minute (MaxRPM 1), and each of the vendor's two retries
  waited a minute more, 9s a protocol. It now queues for a slot
  (MaxConcurrency 1, freed once the agent has heard a keepalive), which
  goes through the same keepQueued, queuedAlive and watch around the
  attempt, so its retries go at once. The assertions are unchanged.
- TestQueuedStreamKeptAliveOnceSentToItsVendor (15s -> 7.6s): the same
  slot instead of a 4s minute; keepHeldAfter 1.5s, keepalive 100ms and
  the vendor's 1s quiet stay. With the h.alive.sent clause in
  holdWriter.watch removed by hand it goes red on all three protocols
  ("wrote nothing ... between the vendor being asked and its answer").
- TestQueuedStreamKeptAliveForTheMinute keeps the MaxRPM queue.
- A shared holdSlot helper holds the slot; it frees itself after 5s and
  in cleanup, so a test that hears nothing fails instead of hanging.
- usage.OTelEvery / OTelSessionsEvery (5s / 2s, read once when StartOTel
  starts an exporter) replace the hard-coded tickers; the gateway's OTel
  tests set them to 200ms / 50ms through fastOTel.
  TestOTelClaudeMainAndChildDedupRetainsHelper 10s -> 4.5s (the rest is
  sessions' 2s settle before a Claude transcript counts as finished),
  TestOTelSessionDedupOnlyUnkeyedLoopback 2.25s -> 0.4s. Production
  intervals are unchanged.

Not cut: TestPluginStreamLargeReplies (22s, 24MB throttled at 3MB/s),
TestPluginStreamLongActiveReader (16s, sized to outlast a 10s stall
window the plugin host dropped in c38728145), TestLargeRequestEndpoints
(16s, a 64MB body the gateway parses many times over - product speed,
not test waits), and the many 1-3s tests.

Run: go test -count=3 -run 'TestQueued|TestOTel' ./internal/gateway (ok),
-race -count=2 of the same (ok), go test ./internal/usage (ok);
go test -count=1 -json ./internal/gateway: tests summed 305.9s before,
the changed ones ~41.6s less after; the whole run took 330.6s at load
average ~125 against 306.7s for the baseline, other tests slowing under
that load (e.g. TestWarmClaudeSaysWhyNot 0.26s -> 5.3s). gofmt -l clean;
GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gateway
./internal/usage clean.
2026-10-12 01:16:36 +08:00
yetone 3f6db48f50 provider: moving Cursor onto its plugin no longer fails "unserved" on the built-in's model ids the plugin still runs (#1656, delete-cloud)
The Cursor plugin lists Cursor's picker since 0.2.0 (plugins #51): a model
once per context size (grok-4.7@256k), effort and fast as the request's
parameters. The built-in ticks 0.1.x-style ids (grok-4.7-fast,
claude-opus-5-thinking, cursor-grok-4.5, a stale grok-4.7-low), which the
plugin's named() runs as the variants they stood for, but move() only
counted an id served when the plugin's list had it literally, and the
cursor mover had no served hook. A move failed for most ticked models.

The cursor mover now has served (cursorServed): an id is served when its
family, taken apart by splitCursorID and without -thinking/-fast, is a
model the plugin lists (its id before "@"), with or without Cursor's
"cursor-" prefix; default/auto when the plugin lists Auto. A family the
picker hasn't got (claude-fable-5-thinking-no-zdr, codex-5.3-fast) is
still refused. Known limit, as the report says: the list is flat, so a
-fast id of a listed family counts as served though the account may lack
fast; the plugin runs it as the nearest variant.

Siblings checked: Devin already has served, ZCode builtin; Grok's plugin
keeps the plain id for the default window (grok-4.7, grok-4.7@500k
beside it); the other plugins list the vendor's ids as the built-in did.

Run:
- TestCursorMoverServesBuiltinIDs, with the ids plugin 0.2.7 lists for
  its own context.test.mjs PICKER (got by running the plugin under bun;
  request() resolves each id the test calls served to a Cursor variant).
  Failed with the hook removed ("the Cursor mover has no served hook")
  and with the "@" cut removed (claude-opus-5-5 ... not served).
- go test -tags nogui ./internal/provider/ in a sandbox HOME: ok.
- gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/provider/: clean.
Not run: a real move with a real Cursor account (the reporter ran the same
approach end to end on their account: 17 unserved down to the 2 above).
2026-10-12 01:15:46 +08:00
yetone 5dfcf43465 gui tests: the masking-rules tests act on Settings' rows once the page has drawn its last read of the settings, not the first (#1653)
redact-rule-row failed in WebKit zh on a loaded machine with
"locator.scrollIntoViewIfNeeded: Element is not attached to the DOM".

Cause: opening Settings reads the settings twice, the page's own read
(showView) and the window's load() once the state is in, and each read
redraws every row (renderRedact replaces #redactList's children). The
test found the row after the first draw and scrolled it; when the second
read landed during Playwright's stability check, the element it held was
gone. Locator clicks retry on a detached element, but
scrollIntoViewIfNeeded and boundingBox act on the element they found.
A probe wrapping #redactList's replaceChildren showed the two draws
(renderSettings < loadSettings, then the same < async load).

Fix: reader.cjs gains watchSettingsReads (an init script counting the
page's GET /api/settings reads, each counted drawn a task after its body
is read, after loadSettings has drawn from it) and settingsDrawn (waits
for load.done, which load() sets in the same run that then asks for the
settings, and for every read asked to be drawn). redact-rule-row and its
two siblings on the same rows, redact-rule-edit and redact-kinds, wait
for it after finding their first row. The page is unchanged: its second
draw is how Settings catches up with the state.

Run (injected: the test's route holds the page's second settings read
until the row is found, and lets it go as the test acts on it):
- Injected, without the wait: 8 of 8 red in Chromium and WebKit, en and
  zh, 1100 and 640px, the issue's exact error. With the wait: 8 of 8
  green.
- redact-rule-row WebKit, 25 runs: 100 of 100 cases green at load ~115.
- redact-rule-row, redact-rule-edit and redact-kinds in both engines:
  50 of 50, and again 50 of 50 (injected 8 of 8) after rebasing
  onto 18e82adc6.

Not done here: 37 other Settings tests use boundingBox or
scrollIntoViewIfNeeded after finding a row and can meet the same second
draw; #1659 lists them, to move onto settingsDrawn.
2026-10-12 00:57:27 +08:00
yetone 751ebe8f5a gui: magpie leads Command-Tab's order after opening its window on a busy Mac too, not only when the main thread keeps up (#1651)
TestDockJoinLeadsCommandTab failed under a full local go test ./...: the
test app was LaunchServices' front app, yet last in Command-Tab's order
(lsappinfo visibleProcessList), kitty first.

Cause: setDock decided whether to activate magpie again by way of the
Dock (#1381's fix) from [NSApp isActive]. The Mac makes an activated app
the front app at once, but NSApp says it is active only once its main
thread has taken the activation in. On a loaded machine the join came
first, isActive read NO, dockStep chose a plain activate (a no-op for
the front app), and magpie stayed last. A temporary print in setDock
showed active=false in every failing run (3 of 5 at load ~120) and true
in the passing ones. The same can happen to a user when the panel's
focus and Open come close together on a busy Mac.

Fix: joining the Dock to the front always goes by way of the Dock
(activateAgain), whatever NSApp says. When magpie truly isn't active
(the tray's Open), the Dock's turn in front changes nothing: magpie is
activated after it either way. dockStep loses its active argument and
appActive is gone. docs/subsystems/gui-shell.md item 7 says so.

The test now activates magpie, waits for LaunchServices to call it the
front app, and joins, all in one turn of the main thread, so the join
always comes before NSApp knows: the busy-machine order, made certain.

Run:
- New test on the old dockStep: 5 of 5 red (magpie not first, kitty first).
  With the fix: 25 of 25 green at load ~120-135.
- The old test (no injected order) with the fix: 10 of 10 green at load
  ~180; before the fix 3 of 5 red at load ~120.
- TestDockStep (table without active). go test ./internal/gui (GUI
  build, darwin) 5 runs green. One run before them failed and its
  output wasn't kept, so which test failed is unknown. After rebasing
  onto 18e82adc6, one package run failed TestTrayCellClickReleasedPanel
  (its own AppKit child, no setDock on its path); it passed alone and in
  3 package runs after. Filed as #1661, cause not found.
  go test -tags nogui ./internal/gui green. gofmt -l clean; go vet
  ./internal/gui (darwin), GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/gui clean.

Not tried: a real magpie build with osascript Command-Tabs (as 15872d977
did) after this change; the full-screen join (dockOnFullscreen), which
still reads isActive at NSWindowWillEnterFullScreen, long after any
activation, and is unchanged.
2026-10-12 00:57:27 +08:00
yetone d4eae3618f gateway: reasoning off goes to an Anthropic API as thinking off, and the log says the level a translated request went at (#1636, jswysnemc)
jswysnemc saw a custom provider think at another level than the one the
agent asked. This commit fixes two places where magpie's own translation
did that.

- A Chat or Responses client turning reasoning off (effort none),
  translated to an Anthropic endpoint, was sent thinking enabled at a
  4096-token budget (buildAnthropic read Effort "none" as a level). It
  now goes as thinking disabled. A model that refuses disabled
  (alwaysThinks / mandatoryReasoning / thinkingOffRefused, e.g. GLM) is
  asked again at its least (thinkingBackOn), and markUnfit(offRefused)
  sends it that way at once until restart.
- none/minimal go as low to Chat/Responses for a model whose levels
  aren't known (effortOf). The route, the try and the usage log all
  said none/minimal. The route still keeps the level asked; the try and
  the usage log now say the level built (noteWireEffort/wireEffort via
  a context slot filled in forwardTranslated). Routing already draws
  asked -> went from the two.

The passthrough path (a client on the provider's own API, e.g. Claude
Code to an Anthropic relay) is unchanged: it sends the client's level
as it came.

Run: go test ./internal/gateway/ (full package, 304s, green);
TestTranslatedEffortLoggedAsSent (8 cases) and
TestTranslatedThinkingOffRefused fail with 11 assertions when the
gateway.go/anthropic.go changes are reverted. gofmt; GOOS=linux and
GOOS=windows go vet.
Not tried: a real vendor's Anthropic API with thinking disabled.
2026-10-12 00:53:48 +08:00
yetone 4b1b5dd822 agent: CC Switch's unified-history mirror waits for the proxy check and drops failover on quit too, tested on its own bytes (xuxing0727 on X)
CC Switch with "unify Codex session history" runs the official sign-in
as model_provider = "custom" (name OpenAI, requires_openai_auth,
supports_websockets), so failover goes on that table's base_url, not
openai_base_url. f156d9046 already gates and ends both; this pins it with
CC Switch's literal config. Run: the test, red with the proxy gate removed
and with dropMirrorFailover left out of EndFailover; CCSwitch tests green.
2026-10-12 00:50:18 +08:00
yetone cec9647a2a access: a default gateway key the user removed isn't made again when sharing is turned off and on (#1655, GradientLive)
Turning on Settings -> Share on local network makes a default gateway key
named "Magpie". A user who wants only their own, stronger key could remove
it from Gateway -> Gateway keys, but configureLAN looked for the default key
by LANKeyID, found none, and made a fresh enabled "Magpie" key the next time
sharing was turned on. That reads as a default key that is always there.

configureLAN now leaves a removed default key removed: when its id is
recorded (LANKeyID), or an older magpie dropped the id and kept only the
revoked mirror, sharing is turned on with the keys there are. Asking for a
new sharing key (newKey / rotate) still makes one, as
TestLANSettingSharesCallerKeyStore expects. A disabled default key already
stayed disabled; the test now holds that too. First-time sharing is
unchanged. docs/reference.md says so.

Run: go test ./internal/access ./internal/gui ./internal/agent (ok);
TestRemovedDefaultKeyStaysRemovedOnReshare goes red with the new check
disabled by hand (a second "Magpie" key appears). gofmt -l clean; GOOS=linux
and GOOS=windows go vet ./internal/access clean. Not tried in the real GUI.
2026-10-12 00:47:10 +08:00
yetone df49305e22 agent: TestOmo and TestJcodeHome no longer fail where omo or jcode is installed (#1646, ggbdpq)
Both tests check that the agent is not detected before its folder exists.
Detected also looks for the agent's command on PATH, so an omo or jcode
installed on the host made the tests fail. Both tests now run with an
empty temp dir as PATH. The TestOmo line is the reporter's.

To find every test with this problem, the whole agent package was run
with a fake executable on PATH for each agent id and Bin (145 names):
- TestOmo and TestJcodeHome failed.
- TestInstallWithoutNodeStopsWhenTheDownloadFails also failed, but only
  because the fake curl stood in for the real one. That is not an agent
  detection.

With this change, both tests pass with the fakes on PATH. go test -tags
nogui ./internal/agent/ is green, and gofmt -l and go vet are clean on
darwin, linux and windows.
2026-10-12 00:44:47 +08:00
yetone 11d1d5d208 usage: a model asked for at a window (grok-4.7@500k) and answered under its plain name is no longer marked swapped (#1645, ggbdpq)
magpie offers some models at a window beside their default, spelled as
<model>@<size>: grok-4.7@500k, and Cursor's grok-4.7@256k. The vendor
answers under the plain name. bareModel left the @500k in place, so
Swapped marked every such request as answered by another model.

What changed: bareModel now drops a trailing @<digits>[k|m], right after
the [1m] tail Claude Code writes, using the reporter's regexp. Another
version or variant answered for a windowed id is still a swap.

What was run:
- TestSwappedGrokWindowID uses the reporter's cases.
- It is red with the new line commented out (all five same-model cases
  fail) and green with it.
- go test -tags nogui ./internal/usage/ is green.
- gofmt -l and go vet are clean on darwin, linux and windows.

Not tried against real SuperGrok traffic.
2026-10-12 00:44:47 +08:00
yetone bc320e249f agent: T3 Code, Air, OpenChamber and the rest send the LAN key to a gateway pinned beyond loopback (#1647, ggbdpq)
The gateway takes gateway.Token, and the keys that name an agent
(gateway.TokenFor), only from loopback. When MAGPIE_ADDR pins the
gateway to an address beyond loopback and sharing is on, keyAt gives the
LAN sharing key, and most writers use it. T3 Code's instance still wrote
gateway.Token, so every call it made got 401. Air's and OpenChamber's
Checks compared against gateway.Token, so they said the wiring Sync had
just written was off.

The same mistake was in every writer that pairs gateway.URL() or
gatewayV1() with a fixed token:
- agy, Alma, Cindy, Claude Desktop, Copilot for JetBrains, Cursor's
  local agent, OpenHanako, Pencil, VS Code / Insiders / VSCodium,
  WorkBuddy-family models.json, ZCode (both files), Zed's credential,
  Aside's provider, and the legacy Claude token rename.
- Fix: these now take agentKey(agent) or hereKey(), which are keyAt and
  agentKeyAt for gateway.URL(). On loopback they are unchanged.
- Alma re-keys a provider that holds any of magpie's keys other than the
  one it should have now.
- WorkBuddy and Aside also count the new key as theirs.
- ZCode treats a saved address equal to the pinned gateway as this
  machine's, not another magpie's.

What was run:
- New tests: TestT3CodeKeyBeyondLoopback and
  TestAirAndOpenChamberChecksTakeTheKeyForTheGateway (from the
  reporter's patch), and TestPinnedGatewayKeyForEveryWriter, which covers
  the other writers.
- With the product files reverted, all three are red. The T3 token reads
  "magpie", and each of the 11 writers shows its old key. They are green
  with the fix.
- go test -tags nogui ./internal/agent/ is green.
- gofmt -l and go vet are clean on darwin, linux and windows.

Not tried with a real T3 Code, Air, OpenChamber or a real pinned
MAGPIE_ADDR on a second machine.
2026-10-12 00:44:47 +08:00
yetone 18e82adc62 gui: the window's pages down a sidebar in groups, the open page's tabs under it, and a button to have the header's tabs instead
From 1024 points wide (SIDE_AT) the window lays its pages down the left
as a Mac app's sidebar: Work (Agents, Sessions, Library), Models
(Providers, Routing, Gateway), Insights (Usage), Extend (Plugins), with
Settings and the gateway's address at the foot. The open page's own tabs
(Usage, Library, Plugins, Settings) are listed under it, opening and
folding on an iOS-like spring, and the page's strip is hidden. The header
becomes a breadcrumb, and pages whose head held only tools have them in
the title bar. Graphite: the open page is in the text's ink, not purple.
A pressed row darkens and never shrinks. The selection under the tabs
sets off as the row is pressed, on a 0.3s curve (it felt behind the
finger), and is the list's only shape: a sub-row hovered or pressed has
no ground of its own, which showed a block under the finger before the
selection slid there. The page's tab is clicked at once, so what is
typed next goes to it.

The title bar's button (or ⌃⌘S, Ctrl+Shift+S), there at every width,
picks the sidebar or the header's tabs. The choice is kept in
localStorage magpie.navLayout (side or top) at every width, so it is laid
out from the first frame; picked in a narrow window the sidebar is 184
points under 860. The two trade places in
a view transition: the sidebar slides, each tab flies to its place, and
the page slides as one. Without view transitions or under reduced
motion, the change is at once.

With nothing picked, narrower than 1024 the page beside a sidebar would
be narrower than Usage's requests table needs, so the header's tabs come
back. A resize
drops what a click held (heldWidth). Usage's KPI strip goes two to a line
by the room the page gives it (a container query), and Japanese counts
wrap there. Tests whose window is 1024+ were updated for the sidebar,
and docs/subsystems/gui-shell.md says how it works.

Run: sidebar.test.cjs and side-toggle.test.cjs 16/16 in chromium and
webkit, in en, zh, zh-TW, ja and de. Each was broken by hand (press
shrink, address cut, press glide, sub-row ground, view transition, kept
choice) and went red. Every page at 560 points with the sidebar picked,
zh and de, both engines: nothing scrolls sideways. session-identity's
ledger row sits under the footer beside the sidebar; WebKit's click
doesn't scroll to it, so the test wheels it up first. Animation frames were checked from a recorded video. The 105
affected GUI files in both engines; their reds were rerun alone and fixed
(filter-ime: the sub-row's click now at once; session-identity, above) or
fail the same on main (tray-logos). The full GUI suite in chromium, on
the rebase onto d5cae267a, was cut short at 352 tests on the owner's
"ship": 6 reds (account-alias, account-models, codex-auto-review,
codex-credits, context-text) each pass alone, here and on main d5cae267a,
so they are timing under the full run's load and are to be filed. After
rebasing onto e4e22b23e: sidebar, side-toggle, session-identity,
filter-ime, library-instr-busy, usage-speed-count and view-scrollbar,
50/50 in chromium and webkit. go build ./... passes.
2026-10-12 00:41:34 +08:00
yetone f11fdd854c provider: oMLX's Clef, Clef-Flash and OpenJev classify routing groups through System One, and agents no longer see them as chat models (#1641, ObsidianArch02)
oMLX 0.7.1.dev1 (jundot/omlx#4315) serves decision models at POST
/v1/systemone. Its /v1/models lists them among the chat models with
nothing to mark them, by the alias the user gave one. Its
/v1/models/status (same key) gives each model's model_type, which is
"decision" for these. oMLX finds that from the checkpoint's files, so
the folder's name needn't say "clef" or "openjev". A name rule would
miss an aliased OpenJev, so magpie reads the status list instead.

- The omlx preset has a decision base, http://localhost:8000/v1. An oMLX
  provider saved before this gets its chat base as one, at whatever port
  it was given (the same backfill Zen and OpenRouter got).
- omlxDecides joins listsDecisions. fetchDecide reads
  /v1/models/status and keeps the decision models under <id>.decisions,
  each by its alias where it has one. It leaves out the ones the user hid
  in oMLX and keeps the window oMLX serves. Clef and OpenJev both read
  images, so ImageInput is set.
- DecidesModel then takes them out of the agents' lists and offers them
  as deciders. Jev() is the first of them. A server with none (or an
  older oMLX) lists none, and no Jev alias is made up for it.

Run:
- TestOMLXDecisionModels: the fake answers with get_status's real fields.
  Clef-Flash by name and OpenJev under the alias "router" are deciders,
  the hidden Clef isn't, the chat model alone reaches agents, and
  RouteDecider plus AskSystemOne post "router" to /v1/systemone. Red
  with omlxDecides taken out of listsDecisions.
- TestOMLXWithoutDecisionModels: no decision model means none, not Jev.
- go test ./internal/provider, gofmt, linux and windows vet.

Not tried: a real oMLX 0.7.1.dev1 with a Clef checkpoint (no Apple-silicon
oMLX install here). The fixture follows the server's source at the
v0.7.1.dev1 tag, not captured bytes.
2026-10-12 00:37:27 +08:00
yetone 1d67f79ca3 gateway: a Claude subscription's next turn goes on in the Claude Code that had the conversation, whatever the client's billing line says (#1638, chicring)
The bridge finds the run a conversation went on in by turnKey, and a
rewritten turn's by newLooseTurn. Both hashed the request's system prompt
raw, with the client Claude Code's x-anthropic-billing-header line in it.
renderClaudePrompt already leaves that line out of what a run is told,
but its fields change from turn to turn on the clients that send them:
cch (#1600, 2.1.114), and cc_prev_req, cc_prompt_id, cc_prompt_index and
cc_turn_index (2.1.296's binary, when it counts itself first party). So
no next user turn found its idle run or its shelved session. Each turn
started a new Claude Code that was told the whole conversation in one
message, which wrote it to the prompt cache again: the reporter's
cache_read stayed fixed (~18k, system + tools) while cache_write grew
with the conversation (~368k). Tool rounds inside one turn still went on
(follows doesn't look at the system), which is why it showed only when a
turn ended.

Both keys now hash withoutBillingHeader(req.System). The rest of the
system prompt stays in, so a real change to it still starts a new run.

Run:
- TestClaudeBillingLineKeepsTheRun: two turns whose billing lines differ
  only in cch, cc_prev_req and cc_prompt_id go on in one run, and the run
  is told "b2" alone, never the billing line. Red on the old turnKey
  (2 runs; the second told the whole conversation).
- TestClaudeRunKeysLeaveOutTheBillingLine: both keys ignore the line and
  still change with the rest of the system. Red with only newLooseTurn
  reverted.
- go test ./internal/gateway (434s), gofmt, linux and windows vet.
- Real Claude Code 2.1.296 under a fake upstream: --resume sent bytes
  identical to an in-process run, with and without an MCP tool round, so
  the resume itself doesn't move the prefix.

Not tried: the reporter's own client version and setup. A 2.1.296 client
pointed at a plain base URL sent a constant billing line, so I couldn't
see the per-turn fields from the client side here. If a miss remains, it
is logged as "a new Claude Code is told the whole conversation".
2026-10-12 00:37:27 +08:00
yetone e4e22b23ec gateway: a relayed Gemini stream the upstream cut short ends in Gemini's own error (#1644, ggbdpq)
What: a Gemini client's stream relayed as it comes (a custom provider's
Gemini URL, Vertex AI) that the upstream stopped cleanly before a
candidate's finishReason was delivered as if whole: the relay's cut check
(#370) only knew Anthropic's message_stop and Responses'
response.completed. Now the usage sniffer marks a Gemini SSE stream ended
on geminiEnds (the #1643 rule: a candidate's finishReason, or a chunk with
no candidate), the tail switch counts Gemini, and streamFailure writes
Gemini's own mid-stream error, the shape geminiEncoder already uses:
data: {"error":{"code":502,"message":...,"status":"UNAVAILABLE"}} with no
event line (Google's SDK reads none).

Sibling: before this, a read that failed mid-reply on a Gemini relay
(cutMidReply) also went through streamFailure's default and wrote
Anthropic's "event: error" shape to a Gemini client; it now gets Gemini's.

usageMetadata is not taken as an end, as the reporter suggested: Vertex AI
sends it on every chunk (the captured vertexThought bytes).

Run:
- New TestGeminiRelayEndedShort: the captured Vertex reply cut mid-answer
  ends in the Gemini error and no event: line; the whole reply and a
  usage-only reply go as they came.
- Broken by hand three ways, each red: Gemini dropped from the tail switch
  (the cut ended silently); streamFailure's Gemini case removed (Anthropic's
  event: error was written); the sniffer's geminiEnds removed (the whole
  and usage-only replies wrongly got the error).
- go test -tags nogui ./internal/gateway -run 'GeminiRelay|Sniff|Passthrough|CustomGemini|Vertex': ok.
- go test -tags nogui -count=1 -timeout 40m ./internal/gateway after rebase on origin/main: ok (505s).
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gateway clean.

Not run: no real Gemini CLI or Vertex relay cut mid-reply; httptest
serving captured Vertex bytes cut by hand.
2026-10-12 00:36:49 +08:00
yetone 17c56ed245 gateway: a Gemini reply the upstream cut short ends in an error, not as if whole (#1643, ggbdpq)
What: a translated reply from a Gemini upstream (a custom provider's
Gemini URL, Vertex AI, Factory's generate route) or Code Assist
(Antigravity) whose stream stopped cleanly before the last chunk was
delivered to the client as a whole reply: finish_reason "stop" to a Chat
client, end_turn to Claude Code, 200 to a client that asked for no stream.
The cut check from #1562/#1563 (errEndedShort) only ran for Anthropic and
Responses, since Gemini chunks have no type and there is no [DONE].

Why this way: geminiEnds reads a candidate's finishReason (Code Assist's
inside "response"). The reporter's patch also counted usageMetadata as an
end, but Vertex AI sends usageMetadata on every chunk
({"trafficType":"ON_DEMAND"} until the last; the captured vertexThought
bytes), so a real Vertex stream cut after any chunk would still read as
whole. A chunk with no candidate at all (usage alone, a blocked prompt)
does end the stream: the reply said nothing, and #667's empty-reply path
still handles it (TestGeminiEmptyReplyIsAnError's "no candidate"). An
error chunk still reaches the client as the vendor's own error, because
failed is set and the cut check needs failed == "".

Run:
- New TestGeminiUpstreamEndedShort (Chat and Anthropic clients) and
  TestGeminiNonStreamEndedShort use the captured Vertex AI reply cut
  after "No, 391 is not prime because it is". Broken by hand (geminiKin
  dropped from the two cut checks), both fail: the Chat stream ended
  "stop", the Anthropic one end_turn, and the non-streamed one came back
  200 whole. With the fix, the Chat and Anthropic streams carry the
  error, the non-streamed request gets a 502, and the whole reply is
  served as it came.
- TestGeminiEnds: the Vertex usage-only chunk is no end; finishReason,
  Code Assist's wrapped one, and no-candidate chunks are.
- go test -tags nogui -count=1 -timeout 40m ./internal/gateway: ok (425s).
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/gateway: clean.

Not run: no real Gemini/Vertex/Antigravity stream cut mid-reply. There is
no reporter's live case; the fixture is a captured Vertex reply cut by
hand. Code Assist is covered by the geminiEnds unit test only, not an
end-to-end Antigravity request. A relay that strips finishReason from
whole Gemini streams would now get the error; none is known.
2026-10-12 00:27:55 +08:00
yetone 53abc8e283 gateway: a script Claude Code starts, naming a Claude id magpie doesn't serve, goes to Claude Code's tier (tbxark on X)
tbxark's request log: Claude Code's own requests went to its tier, while
Python-urllib asked /v1/messages for claude-sonnet-4-6 and claude-opus-5-5
and got 404 "unknown model" in 5 ms. A hook, the statusline or a plugin's
script that Claude Code starts inherits its ANTHROPIC_BASE_URL and token, so
it reaches magpie with the plain gateway token and its own User-Agent.
claudeTierStandIn mapped a Claude id to Claude Code's tier only for a
request magpie took for Claude Code, by its User-Agent, so the script's
ids went nowhere.

Now a request that came with the plain token (not a magpie-<agent> token
magpie gave an agent), whose User-Agent names no agent magpie knows
(usage.IsAgent; claude-desktop and cursor-local are known too), and that
names a Claude-family id magpie doesn't serve, gets Claude Code's stand-in
for it, on /v1/messages and on count_tokens (the one choke point both
use). Nothing changes when:
- the id is served (a Claude subscription or an Anthropic key in the
  catalog lists it): it goes where it is served, as before;
- the caller is an agent magpie knows, or uses an agent's own token;
- Claude Code isn't routed through this gateway (StandIn says nothing),
  so the 404 stays.

Run:
- TestClaudeTierForAScriptClaudeCodeStarted (new) fails on the old
  gateway.go (404 for urllib, "", anthropic-python; count_tokens counted 0
  without reaching the tier). Breaking the token check by hand or the
  served-id check by hand turns it red too. TestIsAgentByUserAgent (new,
  internal/agent) covers IsAgent with the real agent list.
- Sandbox HOME, a fake Anthropic upstream, `magpie serve` on 127.0.0.1:3561
  with Claude Code's settings.json routed there (sonnet/opus tiers set):
  python3 urllib POST /v1/messages claude-sonnet-4-6 with x-api-key magpie:
  old binary 404 "magpie knows no model", new binary 200, upstream got
  m-sonnet-tier; claude-opus-5-5 -> m-opus-tier; count_tokens reached the
  upstream on m-sonnet-tier. A codex_cli_rs User-Agent still gets 404.
- gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; go test of every package (gateway with
  -timeout 25m).

A full ./... run on the loaded Mac timed the gateway package out at 10m
(#1654); run alone it passed in 330s.
2026-10-12 00:22:49 +08:00
yetone f57dc9610b library, gui: an instruction set made, saved or removed writes only the instructions, and the page holds its buttons while it does (#1624, Hipple)
On Windows 11 the Library's Instructions tab took 30s+ to show, and each
instruction made, saved or removed took about a minute with nothing on
the page to say so; a second click made a second set or removed twice.

What an instruction change cost:
- SaveInstructions and ImportInstructions went through change(), which
  gives every agent its MCP servers and skills again too (takeEdits and
  syncSkills look through every skill folder, and the projects), and
  the API then answered with a whole library.Read, which reads every
  agent's skill folders through again (foundSkills, behind: minutes on
  a machine with many skills, #541).
- Every read of the library found the agents (Targets: every agent's
  folders, WSL too) three times: ReadInstructions, readView, and
  foundServers.

Now:
- library: changeInstructions writes only the instructions into the
  agents (with backups as before); readView finds the agents once and
  passes them to instructionsView and foundServersOf. ReadInstructions
  stays for the TUI.
- gui: an instructions/* action answers {part: "instructions",
  instructions, result, problems}; the problems the last change had with
  servers and skills stay, those with the instructions are the new
  change's.
- library.js change(): one change at a time; while one is out the
  page's (and the Library dialog's) buttons are disabled, the page is
  aria-busy, the button pressed says "Saving…" and so does the status.
  An answer with part "instructions" is merged into the page's library.

Timed on the Windows test box (sandbox profile, 1 agent, 80 skills, copy
mode): an instruction create was ~170ms + a ~460ms Read, now ~80ms + a
~70ms instructions read; Glance 350 -> 200ms, Read 480 -> 320ms. The
30s/1min the reporter sees wasn't reproduced there.

Tests (each fails on the old code):
- TestInstructionChangeWritesOnlyInstructions: a server taken out of
  codex's config by hand stays out through instruction create, switch,
  save and remove, and comes back with a server change.
- TestInstructionChangeAnswersInstructions: the instructions answer and
  the problems kept.
- library-instr-busy.test.cjs: a double click on Add sends one create,
  every page button is disabled and the pressed one says Saving… while
  the answer is held, the page keeps the rest of the library after an
  instructions-only answer; the sure Remove double-clicked sends one.
  Chromium and WebKit, en/zh/zh-TW/ja/de.

Also run: go test ./internal/library ./internal/gui ./internal/tui;
gofmt; GOOS=linux and windows go vet; every library*.test.cjs plus the
30 other GUI tests that reach the Library, Chromium and WebKit: all pass
but library-mcp-tool-switch in WebKit, which fails the same alone on
origin/main (#1609), and mobile-web's desktop-vs-main check, which needs
a git checkout the scratch copy it ran in hadn't.
2026-10-12 00:10:59 +08:00
yetone 47ccb7165b gui: Usage's Output speed card keeps its number inside it, and a page's bar across its foot is as thin as at its side on mac (#1623, fanbuz)
At ~983px on Usage › Requests the Output speed figure with its reply
count ("48 token/秒(781 次)", since 3964ea65) ran past its card, as
.led-strip .v is nowrap, in zh, zh-TW and ja. The page then scrolled
sideways, and the mac page scrollbar rule set only width: 8px, so that
bar across the foot was drawn at the engine's default thickness.

- ledGroupSpeed also gives the figure in parts (the speed, then the
  count), and renderLedgerDash draws an array value as parts: each kept
  whole (ellipsised only if one alone is wider than the card), the count
  going under the speed in a card too narrow for both.
- body.mac's page/dialog scrollbar gets height: 8px beside width: 8px.
- usage-speed-count.test.cjs: widths 1400, 983, 789 (guzi171's window,
  #1634, the same overflow), 700, 560; the "read whole"
  check measured an element box that never overflows, now it measures
  every visible .led-strip .v's text (Range rects) against its card,
  which also covers the sibling cards and #ledVia's .led-strip; the
  sideways check reads #view-usage, the real scroller, not
  documentElement.
- view-scrollbar.test.cjs: a 3000px-wide page's bar across its foot is
  8px, as at its side.

Run: on the old code usage-speed-count fails in WebKit (zh, zh-TW, ja:
'75 token/秒(3 次)' outside its card) and view-scrollbar fails (foot
17px WebKit, 16px Chromium); with the change both pass in Chromium and
WebKit, en/zh/zh-TW/ja/de. Whole GUI suite (concurrency 4, load average
70-180): Chromium 3138 pass / 8 fail, WebKit 3135 / 9. None in Usage
but usage-stale-answer, red on main alone (#1632). The others pass alone
or fail the same alone on origin/main 756fef492: market-have (#1631),
routing-side-calls (#1640), redact-rule-row (#1653), privacy-hides-
accounts WebKit (#1632), segs-press-redraw (b0e25696e on main since),
routing-save/routing-flood (pass alone); library-instr-busy is #1624's
test, run here before its change.
2026-10-12 00:10:59 +08:00
yetone d5cae267a7 gateway: image recognition and web search pick only models the user enabled (JonahFu on X)
On a provider with a long list, AutoVision and the searcher picked their
small model from everything the vendor lists (Available), not from what
the user enabled. A Trae CN user's text-only model had its image sent to
OpenRouter's anthropic/claude-haiku-5.5, which they never enabled and
which OpenRouter refused for their region (403).

smallModel, and so AutoVision, searcherModel and the searcher's
first-model fallback, now chooses from Exposed: the user's picks, else
what agents are offered. With no enabled model that sees, a request
turned away says so ("none of the models enabled in magpie can see
images ... enable one that can, or pick one in Settings → Models → Image
recognition"); Vision off says it is off; a describer magpie picked
itself that fails is named as magpie's pick.

Not done: no fallback to another describer on a refusal. With the pick
limited to enabled models, a refusal is of a model the user chose, and
the error now names it and where to change it. Image generation's
AutoDrawer still picks from image models a provider lists: image models
aren't in the chat pickers, so limiting it to picks would turn drawing
off for nearly everyone.

Run: the two new tests fail on the old code (AutoVision =
router/google/gemini-3-flash, searcherModel = google/gemini-3-flash) and
pass now; go test ./... green except internal/gui's
TestDockJoinLeadsCommandTab, which reads the live desktop's Command-Tab
order and passes run alone; gofmt; GOOS=linux and windows go vet
./internal/gateway.
2026-10-12 00:01:28 +08:00
yetone 221e24a3c7 agents, gateway: Codex's subagent model offers every provider's models, not only ChatGPT's (#1633, laacmilan)
The Agents page's Codex "subagent model" field (settings.CodexSubagentModel,
which the gateway puts x-openai-subagent collab_spawn requests on) listed
only the ChatGPT accounts' models, and its setter refused any other
provider's. A user whose lead runs on a chat provider (Token中心, 智谱Plan)
couldn't put its subagents there.

- provider: CodexSubagentModels is Codex's shown catalog
  (CatalogFor("codex"), so hidden or unpicked models stay out), ChatGPT
  accounts first, routing groups included. SetCodexSubagentModel takes any
  provider/model or group id, refuses a bare Codex name.
  CodexSubagentUnserved says "magpie doesn't serve it now" for a non-ChatGPT
  id that isn't served. CodexAccountModel exported.
- gateway: codexSubagentPick gets the body. When the lead ran on the
  ChatGPT backend the task arrives sealed (encrypted_content), and only a
  ChatGPT account can open it: set to another provider, such a subagent
  stays on the model asked for, with Kept = sealedKept in the route trace
  (#1613's constraint; the reverse, a chat lead with a subagent on ChatGPT,
  was already handled by 149ab950e). A plain task moves, and sealed
  MESSAGE items are stripped as before.
- gui: i18n for both new reasons (zh, zh-TW, ja, de); the GUI test lists a
  chat provider's model and shows the sealed reason in every language.
- docs: agent-wiring and gateway-routing say the same.

Run:
- go test ./internal/gateway/ ./internal/agent/ ./internal/provider/
  ./internal/gui/ (ok), gofmt -l clean, GOOS=linux and windows go vet
  -tags nogui on the four packages.
- GUI node tests (codex-subagent-model, routing-kind, i18n-keys,
  codex-start-model-field, gui-ja, gui-de, gui-zh-tw) in Chromium and
  WebKit: 38/38.
- Broken by hand: without the sealed check,
  TestCodexSubagentSealedTaskStaysOffAChatProvider fails with a 400;
  options limited to ChatGPT entries, TestCodexSubagentModelTakesAnyProvider
  fails; options from Served() instead of Codex's shown catalog,
  TestAgentModelLineAllHidden and TestAgentModelsOnlyPicked fail.
- Sandbox HOME e2e with the built binary and a fake chat upstream:
  `magpie codex subagent_model token/gpt-6.1-sol` set, a bare gpt-5.5
  refused; a collab_spawn plain-task request on gpt-6-astra to
  /backend-api/codex/responses was answered by token/gpt-6.1-sol and the
  upstream got the task text.

Not tried: a real Codex CLI or ChatGPT account; the sealed case only in
unit tests.
2026-10-11 23:43:37 +08:00
yetone 0b0bd38b3f release: each tagged release is copied onto yetone/magpie with its notes and all 16 assets (PapainTea on X)
The main repo's Releases page was empty: the installers live only on
yetone/magpie-releases, which is bad for finding magpie and confusing to
people who look here first. A new mirror-release job, after the dispatch,
waits (up to an hour, every 30s) until the magpie-releases release for the
tag has 16 assets, downloads them, and creates the same release here with
GITHUB_TOKEN (contents: write): title "magpie vX", the same notes plus a link
to the magpie-releases page. A rerun edits the notes and replaces the assets.
It fails when fewer than 16 land here.

Nothing reads this repo's releases: self-update (internal/update),
install.sh and the site's /api/latest still read magpie-releases, unchanged.
A release made with GITHUB_TOKEN triggers no workflow, and none here listens
for release events.

Run: YAML parses; the wait and download half by hand against v0.1.1191
(16 assets, 554M, title "magpie v0.1.1191"). The create half runs for the
first time on the next tag.
2026-10-11 23:38:35 +08:00
yetone 639826a89d gateway: a routing group's compaction rule takes Minis's compactions (#1635, jueda12)
Minis (OpenMinis, iOS and Android) compacts with one request and no
tools: its own system prompt ("You are a context compaction engine. Your
summary will REPLACE the original messages in the conversation context
window. ...") and the conversation wrapped in one user message ending
"END OF CONVERSATION TO COMPACT.". Neither was in compactSystems or
compactAsks, so a group's Compact rule never matched it and Minis's
compactions went to the group's ordinary model.

Both are added, keyed on Minis's own text, not its User-Agent (which
Android lets the user change). The prompts were read from OpenMinis at
b4c0661 (Android ChatViewModel.kt compactSummarySystemPrompt and its user
message; iOS AIChatViewModel+Compaction.swift, whose line continuations
render the first paragraph to the same bytes), and the test's fixture is
those literal bytes.

A general signal (no tools plus a summarize request) was considered and
not taken: an ordinary tool-less chat asking for a summary would be sent
to the compaction model too.

Run: go test -tags nogui ./internal/gateway, gofmt -l, GOOS=linux and
GOOS=windows go vet. With the two entries removed, TestCompactingMinis
fails for all four compaction cases.
2026-10-11 23:37:34 +08:00
yetoneandhhh2210 957aa79aa3 provider, gateway: refreshing a saved Claude account's card reads its allowance through Claude Code, without switching to it (#1630, hhh2210)
A saved (not signed-in) Claude account's Usage card read nothing on
Refresh: claudeWindows only ever ran /usage for the account Claude Code
itself is signed in to, so the button did nothing for the rest.

Now the card's own refresh (RefreshUsage for that account, savedRefresh)
runs the real Claude Code's /usage with CLAUDE_CONFIG_DIR set to the
account's claudeSavedDir (readSavedClaudeUsage). magpie still never calls
Anthropic with the token itself, and Claude Code's own account is not
switched. The 30-second per-account floor holds, background reads keep
the last reading, and asks for every card (the Usage page opened, magpie
quota, magpie accounts) start no Claude Code per saved account: they keep
the last reading, or the "not read yet: refresh this account's card"
note.

Claude Code may refresh the account's token in that directory while it
runs, spending the old refresh token. So:
- inSavedClaudeDir holds a per-account RWMutex (claudeDirRun) for the run,
  and switchSavedLogin takes it for writing first, so a switch never hands
  Claude Code a copy the run has just spent;
- syncSavedClaude copies a rotated sign-in from the directory back into
  logins.json right after the run, under savedTokenMu and loginsMu.
Two Claude Codes in one directory are kept from refreshing at once by
Claude Code's own lock file (2.1.296's refresh lock in its config dir).
A saved account's warm-up, which already ran in that directory, now goes
through inSavedClaudeDir too.

The plumbing (configDir through UsageClaudeVia, readClaudeUsage and the
gateway's claudeUsage, and TestClaudeUsageRunsInSavedAccountDirectory)
is from hhh2210's patch 043ee7d7, reviewed line by line. Its gate (any
explicit read reads every saved account) was narrowed to the card's own
refresh, and the lock and sync back are new.

Run: go test -tags nogui ./internal/provider ./internal/gateway . (sandbox
HOME, fake claude via UsageClaudeVia, no real token), gofmt -l, GOOS=linux
and GOOS=windows go vet on the three packages. Broken by hand, each red:
saved never read (all three new tests), any ask reads saved
(TestRefreshSavedClaudeUsage), switch not held and no sync back
(TestSavedClaudeUsageKeepsRotatedSignIn / SavesRotatedSignIn), run in ""
instead of the account's directory. Not tried with a real Claude Code
binary against a real saved account.

Co-authored-by: hhh2210 <hzy2210@gmail.com>
2026-10-11 23:37:34 +08:00
yetone 756fef4921 gui: an update out, downloading or failed offers its release page in the browser (PapainTea on X)
Where GitHub is slow to magpie, the built-in download can take ages. The
About row's update now has "Open the release page" while an update is
available (desktop; on web Download already opens it), while it downloads,
and after a download error. The browser can then fetch the installer through
the user's own proxy or accelerator. The mirror setting is unchanged. The
button is kept across the 700ms download redraws, so a click on it isn't
lost, and it goes away once the row is back to up to date. The string was
already translated (en, zh, zh-TW, ja, de).

Run: new update-release-page.test.cjs (5 languages, 560/900px, chromium and
webkit: 22 pass, twice). Broken by hand three ways: the button made again
on every redraw, no button while downloading, and the button never removed.
Each one went red. All update-*.test.cjs pass (auto, blocked, check,
download-percent, hide, mirror, notes-ask, stuck, wait).
2026-10-11 23:36:47 +08:00
yetone 396a6a3d4f gateway: a flood of wrong remote keys is capped to 429, so a weak caller key can't be guessed unthrottled and each try stops being a valid/invalid oracle (akic404 on Discord)
A pentest of a publicly-exposed magpie gateway found the auth entry had no
rate limit: a remote client could try keys as fast as it liked. The system
key (sk-magpie-key-<48 hex>) is infeasible to guess, but a weak user-set key
(8+ ASCII) is not, and every try returned a distinct 401 that told the
caller whether the key was valid/well-formed.

tooManyAuthFails is one token bucket (50 wrong keys, then ~1/s) shared across
all remote callers. identifyCaller spends a token only on the !ok && !local
branch; once empty, later wrong keys get 429 + Retry-After instead of the
401 message, closing the oracle and bounding the work. A request carrying a
valid key, and any loopback request, never touch the bucket, so flooding
wrong keys can only clamp later wrong keys -- it can never lock out a real
caller (no self-DoS, which is why the bucket is global, not per-IP: behind a
reverse proxy every caller shares the proxy's address anyway).

Left unchanged, by design: the last-4 echo for a long key (#545, it names
only the caller's own submitted key, for debugging), and MAGPIE_WEB_KEY
(already forced >=16 chars + a charset in internal/gui/web.go).

Run (macOS): go test ./internal/gateway/ ./internal/access/ (both ok);
gofmt -l clean; GOOS=linux and GOOS=windows go vet ./internal/gateway/ clean.
Broke tooManyAuthFails to always return false and watched
TestAuthThrottleSparesValidAndLocal go red ("never clamped to 429").
2026-10-11 23:14:44 +08:00
yetone b0e25696eb gui: a segmented control's thumb glides once, one way, and no other thumb moves when a save redraws the page
Settings' Off/On (Lightweight mode in the report) shook back and forth when
clicked, and the first click on the page replayed every thumb's animation.

Why, in the old slide():
- Every save's answer runs renderSettings(), which draws a new control and
  a new thumb for each one. The new thumb took its place from what was
  remembered: within 300ms of the click it started from the position
  before the click, so a redraw mid-glide sent the thumb back to Off and
  slid it again.
- Settings is drawn while hidden (at start, or from another tab), so every
  control was remembered 0 wide. thumbsUnderPicks put the DOM right when
  the tab was shown but never the memory, so the first save's redraw grew
  every thumb on the page in from the left.

#1211 (700315dff) only kept a press made across a redraw (pointerdown on
one button, pointerup on its replacement); it never touched how the thumb
moves across a redraw, which is why the shake stayed.

Now:
- A redrawn control takes over the old thumb element itself, with its
  running animation, so a glide in flight just goes on. No clock math.
- slide() glides only when the target changes, from where the thumb is
  drawn now (computed transform), with a WAAPI animation; the CSS
  transform/width transition is gone so nothing else starts one.
- One shared ResizeObserver puts a thumb under its option, without motion,
  when its control is shown or resized. A control drawn hidden is never
  measured. thumbsUnderPicks and the two per-bar ResizeObservers go.

Run:
- segs-glide.test.cjs (new): records every thumb on General per frame and
  between frames, for an answer mid-glide, an answer at once with two more
  redraws on the way, and a refused save; Chromium and WebKit, en zh zh-TW
  ja de, 900 and 440px. 80/80 over two runs; on the old code 20/20 fail
  (thumb jumps back to 0).
- Full GUI suite, concurrency 6: 6157 tests, 10 fail. Each fails the same
  alone on origin/main 96de5cac2 (library-mcp-tool-switch #1609,
  privacy-hides-accounts and usage-stale-answer #1632) or passes alone on
  both (purpose-filter, routing-signin, filed in #1632). tencent-cloud's
  WebKit flake also happens on the old code (#1620).
- Checked by hand against a sandbox magpie web (real server, sandbox
  HOME): the clicked thumb moves one way, no other thumb moves, including
  Settings opened from Usage first.
- gofmt, go vet (darwin, linux nogui, windows), go test ./internal/gui.

Not tried: the Wails app itself, Windows and Linux webviews.
2026-10-11 23:04:12 +08:00
yetone f156d90460 agent, gui: Codex isn't handed to a magpie it can't reach, through a proxy or after magpie quits (Muma102kMichael, Leon920717, thisisvainxx on X)
Muma102kMichael (Windows): after magpie took Codex over, every project
and every new chat got 502. Codex's reqwest sends its requests for
http://127.0.0.1:3425 through HTTP_PROXY/ALL_PROXY or the system's
proxy, and only an exact IP or a CIDR in NO_PROXY (on Windows, with no
NO_PROXY, the bypass list with "*." removed) keeps 127.0.0.1 off it:
"127.*" and "localhost" don't, and macOS' exceptions aren't read. A
proxy in global mode answers 502 for every request. With [features]
respect_system_proxy Codex asks the system alone and goes direct with
no proxy set there. Account failover, which magpie writes uninvited
when 2+ ChatGPT accounts are on, put all of Codex's traffic, its own
models included, behind that proxy.

- codex_proxy.go works out Codex's proxy the way Codex does and probes
  GET / through it (must answer as magpie). Failover waits for that
  probe and isn't written while the proxy doesn't pass Codex on; one
  written before goes again.
- New drift kind "proxied": the Agents pill says Codex reaches magpie
  through a proxy that doesn't pass its requests on, How to fix names
  the fix (DIRECT rule for 127.0.0.0/8, NO_PROXY=127.0.0.1, or
  127.0.0.1 in Windows' bypass list), and the dialog has a one-click
  Disconnect from magpie (also on unreachable drift).
- Leon920717: after quitting magpie Codex kept retrying. The app that
  serves the gateway now takes failover out in OnShutdown
  (EndCodexFailover); the next start's Sync writes it again. A
  connected Codex is kept (its model is magpie's; Disconnect restores).
  A kill or crash still leaves failover in place.
- thisisvainxx: "several restarts". Codex's app-server keeps the base
  URL it started with, and KeepCodexDaemonCurrent ends with magpie, so
  EndCodexFailover restarts it when no codex session is on it.

Run:
- real codex-cli 0.162.1 in a sandbox CODEX_HOME against a fake 502
  proxy and a fake gateway: NO_PROXY=localhost,127.* -> 30 POSTs to the
  proxy; NO_PROXY=localhost -> proxy; NO_PROXY=127.0.0.1 -> gateway;
  respect_system_proxy with HTTP_PROXY set -> gateway directly.
- go test -tags nogui ./internal/agent/ (full package, 465s, ok) and
  the new tests after the daemon change; each new test went red with
  its guarantee broken by hand (failover gate, drift, EndFailover,
  daemon restart on quit).
- node --test agent-proxied/agent-unreachable/agent-failover/
  agent-disconnect-preview: 104 passed, chromium + webkit, en zh zh-TW
  ja de, window and panel.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui clean.
Not tried: the quit path in the real app, on the Windows box, or
whether computer use / remote connection broke for this same reason.
2026-10-11 23:00:00 +08:00
yetone 8029d98b7e gateway: a large Codex request ChatGPT closes on is asked again, not told 413 (#1628, ScarfQian)
ScarfQian (#1628, v0.1.1184, Codex desktop computer use on a ChatGPT
subscription): a 1.1 MiB turn answered with ChatGPT's 503 "upstream
connect error or disconnect/reset before headers. reset reason: remote
connection failure" came back as a2b96139c's 413 "dropped this 1.1 MiB
request ... magpie didn't retry it". Codex doesn't retry a 4xx, and every
later turn carries the same screenshots, so each one got one try and the
same 413 and the conversation was stuck.

a2b96139c took that 503 as deterministic for bodies of 1 MiB or more from
one report (ylorn: every turn past ~1 MiB, also without magpie). The
evidence says it isn't the request's: from here a Pro account answered
bodies of 0.5 to 20 MiB (a2b96139c's own body); Codex's own client sends
>1 MiB computer-use turns to the same endpoint; ScarfQian's other tool got
a 200 on the 9th try after 8 of these 503s; and "remote connection
failure" is Envoy failing to reach the backend, not a size check. So it is
transient, on some networks/times more than others. Nothing was remembered
per session or size: the "session keeps failing" was the history carrying
the images into every next turn, each refused 413 at once.

Now codexDropped leaves the 503 a 503, with a message that says the
backend closed the connection on this N MiB request, that magpie asked
again without resting the account, and, if it keeps happening, /compact or
shrink the images. In the accounts loop a large request's reset moves to
the next account without resting this one (ylorn's acct-1 rest stays
fixed); the last one left is asked again as for any 503 (lastRetries). On
the passthrough (Codex's own sign-in alone) it is asked again up to
lastRetries times after retryPause<<n. Codex then asks again itself for
the 503. A small request's reset is unchanged.

Tests (codex_dropped_test.go, a backend answering the literal 503 to
bodies over 1 MiB the first N times):
- TestCodexResetBigBodyAskedAgain: two accounts, closed on twice then
  served: 200, asked acct-1,acct-2,acct-2, nobody rests. Old code: 413
  after one try.
- TestCodexResetBigBodyStays503: closed on always: 503 with the advice,
  asked acct-1 then acct-2 3x, nobody rests; the next turn as large goes to
  acct-1 and is answered once the backend takes it. Old code: 413.
- TestCodexResetBigBodyRelayed: sign-in alone, closed once: 200 on the
  2nd try; always: 503 after 3 tries. Old code: 413 after one.
Broken by hand: old code -> all three red; the no-rest branch off -> acct-1
rests (and the next turn goes to acct-2); the passthrough retry off ->
Relayed red.

Run: go test -tags nogui ./internal/gateway, gofmt -l, go vet -tags nogui
with GOOS=linux and windows on ./internal/gateway. Not tried: the
reporter's network or a real ChatGPT reset (none reproduces on demand);
what Codex desktop shows after its own retries of the 503.
2026-10-11 22:54:49 +08:00
yetone cfa280a6c2 provider, gateway, gui: You.com can be added as a search API, with no key for its free search or with a key (#1626, brainsparker)
A model's web search, when no provider can search, goes to the search
APIs the user added; each of them needed a key except a SearXNG of the
user's own. You.com answers with no key too, so it is one a user can
add in one step.

- provider: SearchVendor has KeyOptional (You.com, SearXNG); Ready and
  check let a vendor that has it go with no key. You.com is listed
  between Firecrawl and SearXNG, its keys at you.com/platform.
- gateway: with no key, GET https://api.you.com/v1/agents/search?query=
  &count=6 (YouFreeSearch); with a key, POST https://ydc-index.io/v1/search
  {"query","count"} with X-API-Key, as its API reference says; with a
  base URL of the user's own and no key, GET <url>/v1/agents/search.
  Both replies are read from results.web then results.news: the
  snippets, else the description, and page_age. You.com's errors are a
  code beside a message, so the message is what the user is told (a
  402 "prepaid credit balance has been depleted" is a refused key, the
  next key or API is asked). Its requests carry the User-Agent tag You.com
  asked for, "youdotcom-integration/yetone-magpie", after magpie's own.
- gui: Settings › Web search lets You.com be added with the key empty,
  its placeholder saying so (zh, zh-TW, ja, de).
- cli: magpie search add you [<key>]; the help lists it.

New network addresses: api.you.com (keyless) and ydc-index.io (keyed),
asked only when the user adds You.com, with the search query only.

Checked against the real service on 10-11: a keyless GET to
api.you.com/v1/agents/search answered 200 (testdata/you/free_search.json
is that reply, cut to 3 hits), and a real run through askSearchAPIKeys
returned 6 pages. ydc-index.io/v1/search answered 402 with no key
(testdata/you/keyed_402.json, real bytes) and 403 to a made-up key. The
keyless endpoint isn't in the API reference; You.com's own docs pages for
third-party tools describe it (free, 100 a day per address, no account),
as LiteLLM, ragflow and AnythingLLM use it. you.com/terms bars automated
use of its website and apps, not the API. The keyed request shape is
from its API reference only: no key with credit was tried.

Run: go test -tags nogui . ./internal/gui/ ./internal/provider/
./internal/backup/ green; ./internal/gateway/ green but
TestTurnDoneSaidAtTheTurnsEnd (#1629, fixed in its own commit);
search-api.test.cjs in Chromium and WebKit, en/zh, 980/420px green;
gui-ja, gui-de and i18n-keys green; gofmt -l; go vet -tags nogui for
linux, windows and darwin. The tests make no network request (a stub
RoundTripper). Without the change, TestYouSearch, TestYouKeyOutOfCredit,
TestYouNeedsNoKey and TestSearchCLIYouWithoutKey fail, and with the GUI's
keyOptional check taken out search-api.test.cjs fails in all four
Chromium runs (Add sends nothing).
2026-10-11 22:45:11 +08:00
yetone 09136a6bf1 gateway tests: TestTurnDoneSaidAtTheTurnsEnd starts its clock at the turn's first request, as Took does (#1629)
Took runs from the turn's first request, but the bound took its start
just before the third, so the first two sends and the two noEnd waits were
outside it. A slow first request on a busy machine pushed Took past
Since(start)+20*quiet ("took 1.488977083s", a full gateway run). start is
now taken before the first send, so Took can never be over it, and the
slack is gone.

Reproduced by injecting a 1.5s sleep in the fake's tool-calling reply:
the old bound fails both subtests (took 1.99s, 2.40s), the new one
passes; the lower bound (8*quiet) still catches a Took measured from the
last request. Run: go test -tags nogui -run TestTurnDone ./internal/gateway/.
2026-10-11 22:45:10 +08:00
yetone 56bc93e9fa gateway: a 400 saying the user's location isn't supported goes to the next member or the fallback, and isn't told as too long (#1621, WardLu)
Antigravity (and Gemini, Code Assist) answer a request from an address
Google doesn't serve with HTTP 400 FAILED_PRECONDITION "User location is
not supported for the API use." retryable() only let a 400/422 through
for model, quota and credit wording, so a routing group stopped at the
member and the backup provider was never asked; Claude Code's turn just
ended. tooLongUnsaid could also read the bare 400 on a long request as a
context overflow.

regionWords now names the refusal: Google's sentence, OpenAI's
unsupported_country_region_territory code and its "Country, region, or
territory not supported" message. A 400/422 matching it is retryable, and
tooLongUnsaid leaves it alone. It is about the address the request went
out from (the machine, or the account's own proxy), not the request, so
the member is rested as failOther: the default 1 min backoff doubling to
10 min, never the 30 min credit rest or days. As WardLu set out, not every
400 is retryable: "location field is not supported", "Invalid value for
location parameter" and "messages: field required" stay where they were,
and a 200 whose text has the sentence switches nothing.

Run: go test -tags nogui ./internal/gateway/ (TestTurnDoneSaidAtTheTurnsEnd
red under load, the cause in #1629 and fixed in its own commit; everything
else green), -run 'Region|Shape|NoFallback|PayloadTooLarge|Fallback'
green; gofmt -l; go vet -tags nogui for linux, windows and darwin.
Without the change in fallback.go, TestRegionRefusalIsRetryable,
TestRegionRefusalIsNotTooLong, TestGroupFailsOverARegionRefusal and
TestFallbackOnRegionRefusal all fail.
2026-10-11 22:45:09 +08:00
yetone 863af7abc8 provider: a provider's Extra body adds JSON fields to every request's body, ${sessionId} as the session (#1604, Luc-xz)
What: a provider has an Extra body (extraBody in providers.json, a JSON
object, beside Headers; an "Extra body" box in the editor under Headers).
Its fields are added at the top level of every JSON body sent to that
provider, in the gateway's forwardOnce: Messages, Chat, Responses and
Gemini, relayed as they came or translated from another API. Test models
and Detect send them too (provider.tested), so a relay that
refuses a request without them can be tested before a Save.

- A field the request already has is kept; "!name" replaces it.
- ${sessionId}, in any string at any depth, becomes the session id: the
  agent's session header (sessionOf), else the id conversationID derives
  from the first user message (magpie-<hash>), stable through one
  conversation. Test and Detect send magpie-test-<12 random letters>.
- model, stream and the conversation (messages, input, contents, system,
  systemInstruction, system_instruction, instructions, tools) are never
  set from it: Save refuses them (ExtraBodyOK), the editor says why as
  they are typed and holds the Save, and one written by hand into
  providers.json is dropped on read (cleanExtraBody).
- Not sent: count_tokens, embeddings, images, video, the decision model,
  and signed-in accounts' requests. One object goes to every API;
  per-API sections aren't done.
- A save that leaves extraBody out keeps the saved one; {} clears it.

Why: Luc-xz's relay turns Responses requests away without a
prompt_cache_key, and headers alone couldn't add one.

Docs: providers-accounts.md has an Extra body row and its tests.

Run:
- go test -tags nogui ./internal/provider ./internal/gateway ./internal/gui
  -run ExtraBody: pass. The tests are TestExtraBodyResponsesRelayed,
  ChatDerivedSession, Translated (messages→chat, chat→responses),
  Anthropic (count_tokens left alone), Gemini (relayed and from chat),
  TestExtraBodyTested/OK/ReadByHand, TestWithExtraBody and
  TestProviderExtraBodySaved.
- Broken by hand, each FAIL recorded, then restored:
  - WithExtraBody removed from forwardOnce: all 5 gateway tests FAIL.
  - the countsTokens guard dropped: TestExtraBodyAnthropic FAIL.
  - tested() without the extra body: TestExtraBodyTested FAIL.
  - Save's ExtraBodyOK skipped: TestProviderExtraBodySaved FAIL.
  - keep-when-omitted skipped: TestProviderExtraBodySaved FAIL.
- internal/gui/tests/extra-body.test.cjs: en, zh, ja and de, in Chromium
  and WebKit, 8/8 pass. It covers live errors, Save held and focused, Test
  sending the typed object, the 420px fit, Save as an object, and empty
  saving {}.
- Also run: gui-de, gui-ja, gui-zh-tw, i18n-keys, provider-*, providers-*,
  balance-fix, duplicate-pause, editor-short-window, ux-safety and
  vertex-editor.
- gofmt -l clean; go vet -tags nogui for darwin, linux and windows on
  provider, gateway and gui; the full go test ./... after the rebase.

Not tried: a real relay that needs prompt_cache_key; the fixtures are
httptest upstreams.
2026-10-11 22:41:11 +08:00
yetone a2afc18282 gateway: a turn's end reads its length and hook as the reply ends, not in its timer (race in 7cba316b9's tests)
CI's -race run (38146011985, ubuntu and macOS) caught TestTurnDoneSaidAtTheTurnsEnd and TestTurnDoneWaitsForEveryRequest: the quiet timer read turnAfter and TurnDone on its own goroutine while a test put them back or changed the length. end() now reads both as the reply ends and hands them to the timer; the tests change the length through an atomic and wait out a timer still going before restoring the hooks.

Run: go test -race -count=5 ./internal/gateway -run 'TestTurnDone|TestToolScan' (ok, 37s); gofmt -l clean.
2026-10-11 22:34:41 +08:00
yetone 234b2399c4 library: an MCP server an agent has of its own can be removed from it, its files backed up first (#1618, sxwedo)
A server listed under Library > MCP servers > "In your agents" could
only be brought into the library. As a found skill can (#1303), it can
now be taken out of every agent that has it, without bringing it in.

- library.RemoveFoundServer(name): every agent the server was found in
  has it deleted from its MCP settings by the same per-format code the
  library writes with (JSON/JSONC paths, Codex and Grok TOML, Goose and
  Hermes YAML, dsh profiles, the Also files and the Extra files an agent
  still reads, Pi's old mcp-adapter.json among them). The user's other
  keys, comments and servers stay.
- Every file it touches is copied to magpie's backups (res.Backup)
  before it is written; a file that doesn't hold the server isn't.
- Every file is read before any is written: one that doesn't parse stops
  the removal with nothing changed (a failed read is unknown, not
  empty). The file is read back after, and a server still there is an
  error, not "removed".
- A server the agent's app puts there itself (Own, e.g. Codex's
  node_repl) is refused: taking it out wouldn't last. The GUI doesn't
  list those, and the TUI says so.
- An agent with a different server by that name (Others) is left alone.
- GUI: a trash beside Bring in asks first, naming the agents, that each
  file goes to the backups and that the other server by that name stays;
  posts servers/remove-found. Strings in zh, zh-TW, ja, de.
- TUI: d twice on a found-mcp row, as on a found skill.

What was run:
- go test ./internal/library ./internal/tui ./internal/gui (sandbox
  HOME). New tests: TestRemoveFoundServer (Claude/Codex/OpenCode files
  with user keys, comments and other servers that must survive; Gemini
  with a different one and an unparseable Cursor file left
  byte-identical), ...Unreadable, ...Own, ...EveryAgent (claude, codex,
  gemini, opencode, mimocode, pi, goose, cursor, copilot, crush, dsh),
  TestRemoveFoundEntryEveryFormat (every format, with backups),
  TestRemoveFoundEntryPiExtra; tui's d-twice found-mcp case keeps the
  rest of .claude.json.
- Broken by hand, each went red: no backup, Extra file skipped, Extra
  unreadable read as empty (mcp.json must stay unwritten), no delete,
  Own allowed; GUI trash posting without the confirm. The main file
  unreadable read as empty stays green on purpose: nothing is written
  and the read-back still refuses.
- GUI: remove-found-server.test.cjs (new), remove-found-skill,
  i18n-keys, every library-*.test.cjs, view-no-sideways, mobile-web,
  by-agent in Chromium and WebKit. library-mcp-tool-switch fails in
  WebKit with or without this change, and also when run alone (#1609);
  it has no found servers.
- gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui on the three
  packages.
Not tried against a real agent's live config.
2026-10-11 22:23:45 +08:00
yetone 8902ec2179 library: a server that admits only the apps it lists says so at Sign in, and leaves the sign-in to each agent (#1619, Xichun123)
Figma's remote MCP server (mcp.figma.com/mcp) allow-lists clients by the
client_name they register with: its registration endpoint
(api.figma.com/v1/oauth/mcp/register) answered a plain registration
named Magpie 403 with the bare body "Forbidden" (tried once, by hand).
The Library's Sign in then showed "registering magpie with the server's
sign-in failed (403): Forbidden", which reads as a fault to retry.

magpie doesn't register under another client's name. A 401 or 403 from
registration is now mcpauth.ErrClientRefused: the server's sign-in admits
only the apps it lists and turned magpie away; the agents given it still
have the server's own address, so each signs in itself (in Claude Code,
/mcp). That address is what they already get while magpie isn't signed
in (library.through), so Claude Code, a client Figma lists, signs in
there with its own registration. The message is translated into zh,
zh-TW, ja and de. Other registration failures keep their status and body.
docs/subsystems/library.md says it.

Run: TestSignInRefusedByAnAllowListLeavesItToTheAgents (new, through
library.SignInServer against mcpauthtest serving Figma's 403 bytes)
fails without the change with the reporter's exact "registering magpie
with the server's sign-in failed (403): Forbidden", passes with it, and
checks claude, codex and cursor keep the server's own URL.
mcp-signin.test.cjs (Figma case added) passes in Chromium and WebKit, en
and zh; gui-ja, gui-de, gui-zh-tw and i18n-keys pass. go test -tags nogui
./internal/mcpauth/... ./internal/library/ ./internal/gui/ ok under a temp
HOME; gofmt -l clean; GOOS=linux and GOOS=windows go vet ok. Not tried:
Claude Code's own /mcp sign-in to Figma (no Figma account here).
2026-10-11 22:06:36 +08:00
yetone eed5a6a829 provider, gateway, gui: a GPT model on a provider you added can be switched fast in Routing and the picker (#1615, iomect)
iomect: "目前只有官key可以开启快速模式, 希望在路由设置中 支持给供应商也开启快速模式".
Fast mode (OpenAI's service_tier "priority") was offered only on a
ChatGPT account, an OpenAI key, Cursor and an Anthropic key's Opus. A
relay or sub2api the user added themselves had no toggle, though Codex's
own Fast already reaches such a provider as asked (OwnTier, #1234).

What changed
- provider.OwnFast: a GPT/o-series model (by its slug, openai/GPT-x
  too) on a provider the user added by its address (no preset, no
  account, no plugin, not a cloud), served on an OpenAI API (Chat or
  Responses), not OpenAI's own host. CanFast now includes it, so the
  Routing group member toggle and the agent picker's bolt offer it.
  Nothing is on by default: it is sent fast only when the user switches
  it.
- gateway: such a member or pick is asked for service_tier "priority"
  on the provider's Chat/Responses API whatever API the agent spoke. An
  Anthropic-speaking agent gets it through the translated request
  (forwardTranslated, via a ctx mark), and Claude's speed "fast" or its
  beta is never sent to the user's provider (a relay may turn it away).
  A provider that turns service_tier away is asked again without it and
  not sent it again (the existing optional-field refusal path, keyed per
  provider and protocol).
- gui: canFast members/models carry ownFast; the toggle's and the bolt's
  titles say fast is asked of the provider, "where your provider serves
  it", in en/zh/zh-TW/ja/de.

Not done: a provider's Claude model is not sent Claude's fast mode (no
way to know a relay serves speed "fast"), and no relay is special-cased.

What was run
- go test -tags nogui ./internal/provider ./internal/agent ./internal/gui
  ./internal/gateway (gateway -timeout 40m): ok.
- New: TestOwnFast, TestFastMemberOwnProvider (chat/responses/anthropic
  asks, plus a relay with an Anthropic URL too: no speed),
  TestFastMemberOwnProviderRefusing (refused once in 3 calls per API),
  TestFastPickOwnProvider; TestCanFast checks OwnFast is false for every
  vendor-official case.
- Broken by hand: without the forwardTranslated tier line the anthropic
  cases go red (no tier sent, refused 0 in 2); with withFast ungated the
  both-APIs relay case goes red (speed:fast sent to /v1/messages); with
  the ownFast titles off, fast-pick and group-member-fast go red in every
  language.
- GUI: group-member-fast, fast-pick in Chromium and WebKit; gui-ja,
  gui-de, i18n-keys in Chromium.
- gofmt -l clean; go vet -tags nogui GOOS=linux and GOOS=windows clean.
- Not tried against a real relay's priority tier.
2026-10-11 22:04:46 +08:00
yetone 49caff3caf provider tests: a no-wait return is asserted by holding the slow thing, not a wall-clock bound (#1617)
The siblings of #1586 that 7b151cf54 left alone. Each said "comes back
without waiting" by measuring time.Since(start) against a bound (50ms,
500ms, 1s, 2s, 3s) that a loaded runner can pass and so make red without
the guarantee breaking. Each now holds the slow thing until it has its
answer, so a call that comes back at all came back without waiting for it.
A deadline is kept only so a call that did wait fails as a FAIL rather
than a hang, and each is short of the slow thing's own timeout, so a call
that waited cannot come back in time by having it time out:

- cli_identity_test TestCLIIdentityFirstAskBounded: both looks run while
  the ask is held (it was already). The second look is run with firstAsk
  set to an hour, so a second look that waited again (not only waited the
  whole ask) is caught; 10s guard.
- claude_status_test TestClaudeIdentityServedWhileAsked: the stand-in CLI
  now waits for a file instead of `sleep 1`, and writes another when
  reached. The stale look must come back while it is held, with the ask
  still in flight (claudeStatusBusy), and the CLI must have been asked
  again. The guard is 4s, short of askClaudeStatus' own 5s kill. Its
  cleanup lets the CLI go and waits for the ask to end.
- partners_test TestPartnersDoesNotWait: the five Partners() calls run
  while the site is held; 10s guard (the fetch's own is 20s).
- partners_test TestPartnersNow and plugin_icon_test
  TestRepoIconsWaitForFirstFetch had a floor and a ceiling. The floor is
  the guarantee that the call waited for its bound, and a busy machine only
  lengthens it, so it stays (100ms, and 250ms for a 300ms wait as before).
  The ceiling was the "doesn't wait past its bound" half: it is now that
  the call comes back while the site/fetch is held; 10s guard (the fetch's
  own are 20s and 30s).
- sub2api_usage_test TestKeyAllowanceNeverWaits: the ten looks run while
  sub2api is held and report back over a channel, not t.Errorf from a
  goroutine that could outlive a failed test; 10s guard (the read's own is
  30s).

What was run (temp HOME, caches pinned):
  go test -tags nogui -race -count=10 -run '<the six tests>' ./internal/provider  ok
  go test -tags nogui -count=1 ./internal/provider                                ok 395.6s
  gofmt -l; go vet, GOOS=linux and GOOS=windows go vet -tags nogui ./internal/provider  clean

Broken by hand, each red at the new assertion:
  cli_identity.go, drop c.waited = true (every look waits):
    :124 a second look waited
  cli_identity.go, drop the firstAsk case (the first look waits the ask):
    :116 the first look waited for the held ask
  account.go, askClaudeStatus() in the stale case under the lock:
    claude_status_test.go:111 a stale look waited for the held CLI
  partners.go, Partners runs refreshPartners in line:
    :246 Partners waited for the held site
  partners.go, PartnersNow without its time.After(wait):
    :316 PartnersNow waited past its bound for the held site
  key_allowance.go, KeyAllowance reads in line (lock let go around it):
    sub2api_usage_test.go:279 a look waited for the held read
  plugin_icon.go, RepoIcons without its timer case:
    :168 RepoIcons waited past its 300ms for the held fetch
2026-10-11 22:02:50 +08:00
yetone 7cba316b90 gateway, gui: a notification when an agent's long task is done, opt-in in Settings › Usage (itieniu on X)
itieniu asked for a "ding" when a long Claude Code or OpenCode task
finishes. magpie sees every request an agent sends through it, so the
gateway now follows each agent session's turn and the app notifies at
its end.

Gateway (turndone.go): a request is of the turn unless it is one the
agent makes on the side (Kind) or a Claude Code subagent's. Its reply is
scanned on the way to the agent for a tool call in every wire format
(Anthropic tool_use, Chat tool_calls/function_call, Responses
function_call/custom_tool_call/local_shell_call/..., Gemini
functionCall), as a JSON value, never a key ("tool_calls":[]) or text.
The turn is done when no request of it is going, the last reply was
whole, under 400 and called no tool, and nothing more came for 4s; a
session idle past 30m starts over. The ChatGPT backend path is followed
too. Only a turn at least Settings' TurnDoneAlert seconds long is told,
and only when the app set gateway.TurnDone: magpie serve follows nothing.

Settings: turnDoneAlert (seconds, 0 = off, the default, at most a day).
GUI: Settings › Usage "Task done alert": Off / 1 / 3 / 10 min; the
notification says "Codex is done", "Took 1m 8s · folder", in en, zh,
zh-TW, ja and de. A click on it doesn't open the Usage page.

Tests: TestTurnDoneSaidAtTheTurnsEnd (chat and anthropic through the
gateway: a tool reply, a subagent's last reply and a short turn don't
fire; a final reply fires once with session and folder),
TestTurnDoneCodexBackend, TestTurnDoneWaitsForEveryRequest,
TestTurnDoneOff, TestToolScan (every split point), TestTurnDoneText,
settings' range. Broken by hand: without the capture's scan, without the
subagent exclusion, or without the codex backend's scan, they go red.
turn-done.test.cjs: every language, 900 and 380px, chromium and webkit.
The new row moved the Usage tab's geometry: usage-alert and currency
now wheel their row clear of the header before clicking it, as a reader
would (both green 5/5 here; on base they were green as before).

Run: gofmt -l; go vet darwin, GOOS=windows ./..., GOOS=linux gateway and
settings; go test ./... (gateway alone: ok, 863s under a GUI suite's
load); the full GUI suite in both engines. codex-credits and
gateway-key-models fail now and then here on base 398f8469b too
(codex-credits filed as #1622).

Real use: a sandbox HOME, the app's dev build on 3486/3487, "1 min"
clicked in its Settings › Usage (settings.json got turnDoneAlert 60);
then the gateway in that HOME with a TurnDone that logs, and real Codex (codex exec, ChatGPT sign-in, openai_base_url at the
sandbox gateway) running `sleep 62` then answering: the turn's end came
once, agent codex (Codex), its session, folder turnproj, took 1m8s; a
short "reply hi" turn after it didn't fire. The macOS notification
itself wasn't seen: an unbundled dev binary can't post one ("require a
valid bundle identifier"); the notifier is the one usage alerts use.
Claude Code and OpenCode weren't run live; their wire formats are in
the tests.
2026-10-11 21:59:10 +08:00
yetone 0370048f2a agent: Claude Code's /model lists a model a tier runs at an effort once, not again beside the tier (#1616, iTanX)
With Codex's Luna on Haiku at Max, the tier's model is written as
codex/gpt-6-luna:max. Claude Code's /model drops a modelPicker row that
names a tier's model, but compares the ids whole, so Sol's and Astra's
rows (Opus/Sonnet/Fable, no effort) were folded into their tiers while
Luna's bare row stayed as a sixth entry "GPT-6-Luna · <account> · via
magpie" under "codex/gpt-6-luna:max  Custom Haiku model".

writePicker now leaves out the row of a model that a tier runs at an
effort of its own, compared by model (claudeSameModel: effort and [1m]
mark aside). Tiers at no effort are left to Claude Code's own matching,
as before, so the #1575 routing-group row stays. The rule sits in
writePicker, which every path that writes Claude Code's tiers goes
through (writeTiers, Sync's refresh; WSL's Claude Code via claudeIn).
No other agent writes a model id with an effort suffix into a list.

Run: TestClaudePickerLeavesOutATiersModelAtItsEffort (new) fails without
the change ("picker [cx/gpt-6.1-sol cx/gpt-6-astra cx/gpt-6-luna
cx/gpt-6-terra]: want Luna, on Haiku at max, left out ..."), passes with
it; go test -tags nogui ./internal/agent/ ok under a temp HOME; gofmt -l
clean; GOOS=linux and GOOS=windows go vet ok. Not tried in a real Claude
Code /model: the dedupe rule is the one the reporter's screenshot shows.
2026-10-11 21:55:31 +08:00
yetone c763d4fe1d provider: a moved ZCode or Command Code account is brought to plugin 0.1.15 / 0.1.10, which say the agent's folder (plugins #86, Hipple)
Raises the movers' min so keepMovedCurrent updates every moved user:
- @magpie-community/opencode-zcode-auth 0.1.15 (plugins baa788b): the
  Start Plan's environment section says the folder and git repository
  magpie tells it, never magpie's own folder, and leaves out what it
  isn't told and the shell.
- @magpie-community/opencode-commandcode-auth 0.1.10 (plugins 7e67b98): a
  Go request's workingDir and isGitRepo are the agent's.
Both were published by the plugins repo's publish workflow and are the
registry's latest. Run: go test internal/provider.
2026-10-11 21:51:34 +08:00
yetone 93c93a80c4 provider: built-in ZCode's Start Plan and Command Code's Go request say the agent's git repository as it is, not a home or shell they don't know (plugins #86)
The siblings of plugins #86 in the built-ins, for accounts not moved onto
the plugins.

ZCode (zcode_client.go): the Start Plan's environment section already took
the agent's folder from its prompt, but fell back to the user's home when
the prompt named none, said "Is a git repository: no" whatever the folder,
and said magpie's $SHELL/%ComSpec% as the shell. zcodePlace now gives the
folder and the git state: the agent's word, else this disk's
(GitSaid/GitOnDisk). Each line is left out when unknown, and the Shell line
is gone, as in plugin 0.1.15.

Command Code (gateway/commandcode.go): a Go request's config said
workingDir: home and isGitRepo: false always. It now says the agent's
folder (workPlace) and its git state the same way. A request with no
folder keeps the CLI's config in the home, as plugin 0.1.10 does.

Run: TestZCodeEnvironmentSaysOnlyWhatIsKnown and
TestCommandCodeGoSaysTheAgentsFolder (new), TestZCodeStartSentAsTheApp
updated (its /work/proj isn't on this disk, so no git line, and no
shell). Broken by hand: with git always "no" both ZCode tests fail; with
the old commandcode.go 5 of the 6 cases fail. go test internal/gateway,
internal/provider; gofmt -l; go vet darwin/linux/windows.
2026-10-11 21:51:34 +08:00
yetone 1075991f90 gateway: a plugin's fetch is told the folder the agent works in and whether it is a git repository, never seeing magpie's own (plugins #86, Hipple)
A plugin runs in magpie's plugin host, so its process.cwd() is magpie's
folder. The ZCode plugin's Start Plan request said that folder
(C:\Users\<user>\.config\magpie) as the agent's "Primary working
directory", with "Is a git repository: no", and the model looked there.

forwardOnce now calls tellWorkPlace on every request to a plugin's
provider. It reads the request as sent to the plugin with workPlace (the
same reading rules by folder use) and sets two headers on the plugin's
fetch:
- x-magpie-work-dir (provider.WorkDirHeader): the folder, percent-encoded
  (url.PathEscape; decodeURIComponent reads it);
- x-magpie-work-git (provider.WorkGitHeader): yes/no. The agent's own word
  beside the folder (Claude Code's "Is a git repository: true/false",
  OpenCode's "Is directory a git repo: yes/no") wins. Otherwise it is a
  .git in the folder or above it, when the folder is on this computer
  (provider.GitSaid, provider.GitOnDisk in the new workplace.go).
Each is left off when unknown; a folder that isn't on this computer and
that the agent didn't call a repository has no git value, never "no".
host.js's fetch (unsaid) takes both headers off every request a plugin
sends, so a plugin that forwards the headers it was given sends them to
no vendor. Documented in docs/subsystems/provider-plugins.md.

Run: TestPluginToldWhereTheAgentWorks (new) sends the captured Claude Code
and Codex requests, and Pi-style ones from a temp repo subfolder and a
plain folder, through the fake plugin to fake-claude and fake-1. It checks
what the plugin read and that the vendor got neither header. Broken by
hand: without the tellWorkPlace call every case fails; without unsaid in
host.js it fails with "the vendor got X-Magpie-Work-Dir". go test
internal/gateway (-timeout 40m), internal/provider, internal/plugin;
gofmt -l; go vet on darwin, GOOS=linux and GOOS=windows for the three
packages.
2026-10-11 21:51:34 +08:00
yetone 96de5cac29 gui: Providers has a search box, and a provider's right-click moves it to the top or the bottom (#1614, ququdu)
ququdu has many providers and kept scrolling to find one, and moving one
far up the list meant a long drag. The Providers page had neither a search
nor a quick move; its rows moved only by dragging the logo or Alt+↑/↓ one
step at a time.

- A search box over the list, at its right edge as Settings' is (full width
  in a narrow window). The words typed keep the rows, on and off, whose
  text or data say them all: name, id, preset, addresses, every model's id
  and name, the account's user and plan and each login's, account names
  and key names. The Turned off fold stays open while searching; nothing
  found says so; Escape or clearing the box shows every row and the fold
  as it was (findProviders).
- A row that is on has a right-click menu, as an agent row has: Move to
  top, Move up, Move down, Move to bottom (openProviderMenu), with their
  keys. Alt+Shift+↑/↓ on the logo go to the top or the bottom.
- While searching, a row still moves, among the rows shown: Alt+↑/↓ and a
  drop put it where the shown row it passes was, and the hidden rows keep
  their order (stepProvider, shownToOn). Move to top and Move to bottom go
  to the ends of the whole list. Every move saves the whole order through
  /api/providers/arrange as before.
- After a save, the keyboard stays on the handle it is on, also when it
  was another row's taken up while the save was out (it was lost before).
- The logo's tooltip says right-click moves it to the top or the bottom.
- Drag already scrolls the page near its edges (dragRows); unchanged.

Strings in zh, zh-TW, ja and de. docs/subsystems/gui-shell.md says how it
works.

Run:
- provider-find.test.cjs (new), en, zh, zh-TW, ja, de at 420x560, Chromium
  and WebKit: matches by name, model id, account user, key name and two
  words; the off row found with its fold open; nothing-found text; Alt+↑ and
  a drag while filtered, with the posted order checked; Escape; the menu's
  four items, which are off at each end; Alt+Shift+↑/↓; nothing scrolled,
  nothing but the order posted, no overflow. Fails on the old assets ("no
  search box on the Providers page"), and goes red with each of five breaks
  by hand: steps over the full list while filtered, no right-click menu,
  drop index taken as a full-list index, no Alt+Shift, the off fold
  honoured while searching.
- provider-order.test.cjs updated for the tooltip.
- Every GUI test that opens the Providers page (150 files): WebKit 754/754;
  Chromium 748/752 under load ~100, the 4 in azure-endpoint and
  routing-save (30s waits on the add sheet and routing) pass alone in both
  engines, with provider-search, provider-order and settings-search
  (31/31). gui-zh-tw, gui-ja, gui-de pass in both.
- go test -tags nogui ./internal/gui/... (sandbox HOME), go vet darwin,
  GOOS=linux and GOOS=windows -tags nogui.
- Screenshots looked at: zh narrow with a search, zh wide with the menu.
2026-10-11 21:42:30 +08:00
yetone 0fcf563e61 routing: a pause rule can hold by folder, in some or outside them (#1606, Ti800)
Ti800 keeps a subscription's quota for one long task in one folder and
wants every other request kept off it (their option A). A pause rule
held by hours, days and agents only; it now holds by folder too.

What changed
- provider.Rule gains ExceptFolders (json exceptFolders, CLI
  except-folders=, aliases except-folder/not-in/outside): the folder the
  agent works in is in none of them. An agent that says no folder isn't
  known to be in one, so except-folders holds for it; folders= still
  never matches an unknown folder. Both conditions are allowed on send-to
  and pause rules (Rule.ByFolder, inFolders); cleanRules cleans and
  dedupes both and lets a pause hold by time, days, agents and folders.
- PausedOut takes the request's folder. The gateway reads it (workDir)
  only when a pause by folder is on the way (PausesByFolder); embeddings
  and System One's decision calls pass none. Paused carries Folder and
  ByFolder for the trace. ruleFor reads the folder for except-folders
  rules too.
- Group sharing drops every rule by folder, except-folders included.
- CLI usage, TUI hint, ParseRule/Line round-trip except-folders.
- GUI: the rule editor has a "not in folder" condition beside "in
  folder", both shown on a pause and kept when a rule turns into one; a
  folder that isn't a whole path and a pause with no condition are
  refused; the group's rule and the trace say "not in …", and a paused
  reason says the folder read or that the agent said none. Strings in
  zh, zh-TW, ja, de.
- Docs: gateway-routing.md, site start.html (en, zh, ja).

What was run
- go test -tags nogui ./internal/provider ./internal/gateway (folder,
  pause, share, rule tests); full go test ./... before pushing.
- Broke it by hand: with the gateway's folder read replaced by nothing,
  TestPauseByFolder fails (in-task requests went to the other member).
- GUI: routing-pause-folder.test.cjs (new), routing-pause,
  routing-folder, i18n-keys and 10 other rule-editor tests in Chromium
  and WebKit, en/zh/zh-TW/ja/de, at 1100px and 390px.
- gofmt -l; GOOS=linux and GOOS=windows go vet of the touched packages.

Not tried: a real Claude Code subagent's request against a live group;
by the documented rule a request without a folder is paused off the
kept member, which is what the reporter asked for.
2026-10-11 21:24:10 +08:00
nrenvo 7b151cf549 provider tests: the stale copy's prompt return is asserted by a held refresh, not a 40ms bound (#1586)
TestSubscriptionUsageServesStale said "a stale copy comes back at once while it
refreshes" by timing the call: a 50ms ctx and a 40ms bound on time.Since(start).
On a loaded machine the bound is what fails -- the report has "waited
311.332917ms for a stale copy" -- so the test said nothing either way about the
guarantee it guards. Which step of the call took those 311ms I did not
establish; the assertion no longer needs to know, because nothing is timed.

The refresh is now held at the vendor instead: CopilotUserURL points at an
httptest server whose handler blocks until released, so the refresh cannot
finish. The copy is asserted to come back while SubscriptionUsageReading still
reports a refresh in flight, which is the guarantee itself rather than a proxy
for it, and <-reached proves a refresh really went out, so the test cannot pass
by never starting one.

The test also resets c.asked, the one field of the cache it primes that it had
left alone. It is not set when this test runs -- AskUsage is the only setter and
quota_asked_test.go's own restart clears it -- so this is not the reported
failure's cause; it completes what the test already does to c.data, c.at and
c.pending, so the test does not depend on another file's cleanup.

What was run:
  gofmt -l internal/provider/subscription_usage_test.go   (no output)
  go test -tags nogui -count=1 -run TestSubscriptionUsageServesStale ./internal/provider
  go test -race -count=20 -run TestSubscriptionUsageServesStale ./internal/provider
  go test -tags nogui -count=1 ./internal/provider        (whole package)
  go vet ./... ; GOOS=linux go vet -tags nogui ./... ; GOOS=windows go vet ./...
  go build ; GOOS=linux go build -tags nogui ; GOOS=windows go build
  go test -tags nogui ./... (53 of 54 packages ok; internal/gateway reds only in
    the parallel run, which this change cannot reach -- it does not compile this
    file -- and which is filed already as #1543/#1544)

Without the change: with SubscriptionUsage's "if !have && pending != nil" broken
to "if have && pending != nil" -- a copy that has data waiting for the pending
refresh -- the new test fails with

  subscription_usage_test.go:97: got [], want only claude: a copy that waited
  for the held refresh comes back with nothing
  --- FAIL: TestSubscriptionUsageServesStale (12.51s)

Reviewed and landed from nrenvo/magpie fix/1586-stale-copy-test (b5bda612),
posted on #1586 because PRs are collaborators-only. Run at the cherry-pick on
origin/main 398f8469b, temp HOME, caches pinned, load average ~120-135:
  go test -tags nogui -race -count=50 -run 'TestSubscriptionUsageServesStale$' ./internal/provider   ok
  go test -tags nogui -race -count=20 -cpu 1,2 -run TestSubscriptionUsage ./internal/provider        ok
  go test -tags nogui -count=1 ./internal/provider                                                   ok 149.7s
  go vet, GOOS=linux and GOOS=windows go vet -tags nogui ./internal/provider; gofmt -l               clean
Broken by hand in SubscriptionUsage, two ways, each red:
  "if !have && pending != nil" -> "if pending != nil" (a stale read waits for
    the refresh, up to ctx): FAIL at :96, got [] (11.6s)
  an unbounded <-pending for every read: FAIL at :96, got the Copilot card read
    after the held refresh gave up (21s)
2026-10-11 21:22:18 +08:00