Commit Graph
3467 Commits
Author SHA1 Message Date
yetone 2c18c697c2 provider: moved WorkBuddy users get plugin 0.1.22, so an MCP server's tools reach Kimi, not 400 11133 (magpie-community/plugins#122, clearmann)
The mover's min, so keepMovedCurrent updates every moved user's plugin.
workbuddy 0.1.22 (plugins a6bed5e): Kimi (kimi-k3-1, kimi-k2.7) and
DeepSeek turn away tool schemas MCP servers commonly send (an enum with
no type or of several types, an empty enum, true/false where a schema
goes, a required that isn't a list, an unknown type) with 400 11133 /
11129. It is the request's content, not the account. The plugin now
gives each the shape these models take, meaning the same. Tried on the
owner's real account: each refused shape 400 before, 200 after.

On npm: npm view @magpie-community/opencode-workbuddy-auth version is
0.1.22 (tarball holds fitShape).

Run: gofmt -l, go vet ./internal/provider for darwin, GOOS=linux -tags
nogui and GOOS=windows, go test ./internal/provider (ok, 439s). Not
tried: a moved user's update in a running magpie.
2026-10-14 21:47:24 +08:00
yetone e5cd125f06 provider: OpenCode Go's and Zen's Gemini models are asked on Gemini's generateContent, not chat (#2168, @bugyaluwang on X)
OpenCode Go's gemini-4-argon-contributor went to
/zen/go/v1/chat/completions, then Responses and Messages, and Go turns
each away with "Model does not support this protocol". OpenCode serves
each model on the API of the AI SDK package models.dev names in its
per-model provider.npm. catalog.APIOf knew @ai-sdk/openai (Responses)
and @ai-sdk/anthropic (Messages) but not @ai-sdk/google, and an OpenCode
provider had no Gemini URL. So a Gemini model had no API it is served
on. Zen's nine Gemini models (gemini-3-flash, 3.1-pro, 4-argon, ...)
failed the same way: the sibling.

- catalog.APIOf: @ai-sdk/google is "gemini".
- openCodeEndpoints fills in the Gemini base:
  - Zen's /zen/v1. OpenCode's proxy relays models/X:streamGenerateContent
    there to Google's route and reads the key from x-goog-api-key.
  - Go's /inference/go/v1. /zen/go/v1 has no Gemini route (404).
  openCodeRoot also takes /inference and /inference/go URLs.
- The gateway's existing Gemini translator does the rest:
  - models/<id>:streamGenerateContent?alt=sse, the key in x-goog-api-key;
  - OpenCode's x-opencode-session and its variants, as for every API;
  - the client is answered in its own API;
  - reasoning effort low/medium/high becomes thinkingConfig.thinkingLevel.
- Provider.NamedOnlyOn(Gemini) for OpenCode: a model the list names no
  API for (GLM, Kimi...) is never tried on Gemini's, in usable() and in
  the Test probe's model choice. Without it, a model turned away on all
  three falls through to Gemini's and answers with a bare 404.
- The model list isn't fetched at OpenCode's Gemini base: its models
  come from the chat list.
- Existing saved providers get the URL through normalize, as #1215's
  did. The GUI's per-model API picker already offers Gemini once
  p.gemini is set.

Run:
- New TestOpenCodeGoGeminiModelOnGeminiAPI. The fake answers with Zen's
  real SSE bytes. It checks:
  - the URL, x-goog-api-key, no Authorization, and a stable
    x-opencode-session across two turns;
  - chat, chat stream, messages, responses and a Gemini client are each
    answered;
  - thinkingLevel for low, medium and high.
- New TestOpenCodeZenGeminiAndOtherModelsUnchanged: Zen's gemini-3-flash
  goes on /zen/v1/models/...; GLM on Zen and Go stays on chat with
  Bearer; a model with no API named and turned away everywhere is never
  sent to Gemini's.
- TestOpenCodeEndpointsFilledIn now has a gemini column and /inference
  cases.
- Broken by hand, each went red:
  - APIOf's google case: the reporter's error, Go and Zen;
  - the Gemini URL fill;
  - NamedOnlyOn in usable (kimi-k3 sent to Gemini's API).
- gofmt -l; go vet on darwin, linux (nogui) and windows for catalog,
  provider and gateway.
- go test -tags nogui ./internal/catalog ./internal/provider
  ./internal/gateway ./internal/agent: all ok (gateway 1260s, agent
  1170s on a loaded machine).
- Real use, the owner's OpenCode key through the gateway in a sandbox
  HOME (in-process, fresh(t), real network, the live models.dev catalog):
  - Zen gemini-3-flash before the fix: 400 "OpenCode Zen: Model does not
    support this protocol" on chat and messages.
  - Zen gemini-3-flash after:
    - chat: 200 "Hi" (reasoning_effort low);
    - chat stream: 200 "Hi.", [DONE];
    - messages: 200 "Hi.".
  - Go gemini-4-argon-contributor at /inference/go/v1: 400 "This Go model
    trains on request data. Allow paid endpoints that train on request
    data in your workspace's Privacy settings to use it." Not consented
    to, as the issue asks.

Not run:
- A successful Go Gemini answer. The owner's workspace hasn't given that
  consent and has no active Go subscription (glm-5.3 on chat: 403). With
  the fix broken, Go gives this account the same consent 400 on chat,
  so Go's before/after rests on the reporter's error and the fakes.
- The full go test ./...
- The GUI.
2026-10-14 21:23:15 +08:00
yetone b9c589ebb1 gateway: the user's own Max output lowers a plain provider's max_tokens, not only a group's (YaCo on Discord)
Claude Code asks claude-opus-5-5 for max_tokens 128000. A relay that
holds back max_tokens x price from a key's quota answered 403 "token
quota is not enough ... need $2.59" for every turn (128000 x $20/M plus
~8K input x $4/M). Setting the provider's Max output didn't help: the
gateway lowered max_tokens with withMaxOutput only inside a group
(outputLimit), so a request routed straight to a provider went out as
the agent asked.

userOutput finds the Max output the user set for the provider's model
(provider > model or the provider's "*", Entry.OutputSet) and lowers a
larger request to it on any route. Only the user's own value does this
outside a group: a vendor's catalog figure may be stale. Group routing
is unchanged.

Run:
- TestUserMaxOutputLowersAPlainProvidersRequest (new): 128000 -> 32000
  with Max output 32k on the model, 8000 kept, a sibling model with no
  Max output kept at 128000. Red without the gateway.go change ("went
  as 128000").
- go test ./internal/gateway -count=1 (whole package, -timeout 45m):
  ok, 1200s, before rebasing onto 4e9335c96; after the rebase the
  Output/MaxTokens tests again: ok.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: clean.
- A real Claude Code 2.1.29x against a fake server with the reporter's
  env: it sends max_tokens 128000 for claude-opus-5-5 with or without
  magpie. Not tried against the reporter's relay.
2026-10-14 21:11:42 +08:00
yetone 7f968b95dd gateway: auto affinity keeps a conversation on the cache its last reply wrote, not only one it read (vilicvane on Discord)
Affinity's auto mode kept a conversation on its last answerer across turns
only while that reply had read at least cacheWorth (1024) tokens from the
vendor's cache. A first turn reads nothing and writes the whole prompt
(Anthropic's cache_creation_input_tokens), so the second turn was moved as
"no-cache" and the cache just built was thrown away (vilicvane on Discord,
「会话保持 → 自动」: 「新的 cache 都建好了,再切走不可惜吗?」).

answered() is now given the usage's CacheWrite beside CacheRead (both
already parsed at that call site for every route: Anthropic, Chat's
cache_write_tokens / cache_creation_input_tokens, Cursor, Command Code,
plugins), and affine counts read + written against cacheWorth. The stick
keeps cacheWrite in memory and in affinity.json (`cacheWrite`, omitempty);
a file from before has no such field and reads as 0, so an old stick is
judged by its read alone, as before. The trace's Affinity carries
CacheWrite, and the Routing page's "cache" and "no-cache" explanations say
what was read and what was written (en, zh, zh-TW, ja, de).

Not covered: a vendor that caches without reporting a write (OpenAI's
automatic prefix cache, Gemini) still reports CacheWrite 0 on a first turn,
so its second turn may still move. Noted in gateway-routing.md.

Docs: docs/subsystems/gateway-routing.md (affinity bullet), docs/reference.md
(step 6 of how magpie picks an account).

Run:
- TestAffinityKeepsACacheJustWritten (new): an Anthropic Messages upstream
  streaming cache_creation_input_tokens 3000 / read 0; the second turn is
  kept as "cache", also across a restart (affinity.json reloaded); 600+600
  is kept, 300+300 moves as "no-cache". Broken by hand twice and watched
  red: the old `st.cacheRead < cacheWorth` (written: why no-cache), and
  stickOf not reading CacheWrite from the file (restarted: no-cache).
- routing-affinity-cache-write.test.cjs (new): chromium and webkit, 1100
  and 420 wide, en/zh/zh-TW/ja/de, 20/20 pass; red on the old routing.js
  and i18n.js. i18n-keys.test.cjs and routing-account-identity.test.cjs
  pass.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows for
  internal/gateway.
- go test ./internal/gateway/...: all pass except
  TestAgentGoneInTheRetryPause/group_replan, which failed in two full runs
  at load average 150-380 and passes alone (-count=3); its fixed 100ms
  sleep before cancelling assumes the pause has begun. Filed as #2175; it
  never reaches the affinity path this changes (a first request).
- go test -timeout 40m ./... at load ~300-377: 50 packages ok; agent and
  gateway hit the 40m package timeout (no test failed before it); gui's
  TestSetAnswersWhileDevinAndProvidersHang (#1375) and
  TestMainWindowCorners (#1936) failed, both filed load reds.
  internal/agent rerun alone: ok (1008s at load ~200).
- Not tried against a real Anthropic account.
2026-10-14 21:05:26 +08:00
yetone 4e9335c96c plugin: Windows on ARM downloads Bun's native windows-aarch64 build and runs plugins, not "Bun has no build for windows/arm64" (#2183, EdwinDigital)
bunTargetFor turned windows/arm64 away, so magpie-windows-arm64.exe
listed a plugin as on while its host never started, and its providers
never showed. Bun publishes bun-windows-aarch64.zip (1.4.2 and later),
so windows/arm64 now maps to it, with no baseline suffix (arm64 has no
baseline build). Its SHA-256 a7a16b87…0cfd is added to bunSums, taken
from Bun 1.4.2's SHASUMS256.txt, so the download is still checked and
can come through a mirror. The provider-plugins page says so.

What was run (macOS arm64, sandbox HOME, private GOCACHE):
- TestWindowsOnArmGetsNativeBun (new): with windows/arm64 stubbed,
  Bun() downloads bun-windows-aarch64.zip from an httptest release and
  runs it; the checksum is the official one. Old bun.go: FAIL
  "bunTarget = "", Bun has no build for windows/arm64".
- TestBunTargetForMusl gains windows/arm64 and now checks every
  target has a checksum; TestBunDefaultSums and TestBunTarget list
  bun-windows-aarch64. Both FAIL on the old code.
- go test ./internal/plugin/ ok; gofmt -l clean; go vet darwin,
  GOOS=linux -tags nogui, GOOS=windows clean;
  GOOS=windows GOARCH=arm64 go build ok.
- Downloaded the real bun-v1.4.2/bun-windows-aarch64.zip: SHA-256
  matches, it holds bun-windows-aarch64/bun.exe, a PE32+ Aarch64 binary.
Not tried: a real Windows ARM64 machine (the Windows box is x64), so
the plugin host starting on that bun is not verified.
2026-10-14 20:56:18 +08:00
yetone 35230ba1fb gui: a plugin sign-in with no page to open waits with its proxy link, not "[object HTMLButtonElement]" (#2181, guanwenpeng2001-bot)
A plugin whose authorize gives url "" (it drives a desktop app and the
host waits on its callback) reaches the sign-in box's "waiting" branch,
which wrapped signInProxyLink's button in el("span", "acts", button).
el() wrote its third argument into textContent, so the box showed the
string "[object HTMLButtonElement]" and no proxy link. el() now puts a
Node inside the element as it is and keeps textContent for everything
else, so this caller and any other that hands it a node are fixed at
the one helper; that was the only static call passing one
(grep of el(..., <call>) across internal/gui/assets).

What was run (macOS, playwright 1.62.0):
- new internal/gui/tests/plugin-signin-no-url.test.cjs, en/zh/zh-TW/
  ja/de at 1100 and 420: chromium 11/11, webkit 11/11 pass. With el()
  put back it fails 11/11 in webkit and chromium with
  "a node written out as text".
- plugin-signin, signin-proxy, signin-link, plugin-moved-signin,
  signin-callback, signin-paste-plugin, add-sheet in both engines:
  67 pass, 0 fail.
- go vet (darwin, linux nogui, windows) clean.
Not run: the whole GUI suite (machine load ~200); el()'s output for a
non-Node argument is unchanged. Not tried with the reporter's own plugin.
At 420px in WebKit the method button sits under the sheet's footer
after Playwright scrolls it, so the test presses it with Enter.
2026-10-14 20:56:18 +08:00
yetone d1c485f7e9 agent: a model at max without xhigh tells Claude Code it has xhigh, so Ultracode shows on GLM, DeepSeek and Kimi in Claude Desktop
leesunrise2364 on Discord: Claude Desktop on magpie has no Ultracode effort,
which cc-switch had, and Ultracode is what turns on dynamic workflows.

Desktop 2.7032.0 shows Ultracode only when the model's effort options
include xhigh and Claude Code takes it. magpie lists a model with known
levels to Desktop as mythos-magpie-<n>, whose options include xhigh, and
tells Claude Code what each model can do in CLAUDE_CODE_MODEL_CAPABILITIES.
That value said only the levels magpie knows the model has. GLM-5.3
(low/high/max), DeepSeek V4 (high/max), Kimi K3 and the like reach max
without xhigh, so they were written as "effort,max_effort", and Claude Code
refuses Ultracode there: "Ultracode isn't available on <model>". cc-switch
names its models as real Claude ids, which Claude Code already knows have
xhigh.

A model Claude Code doesn't know whose levels reach max now also gets
xhigh_effort. The gateway already runs xhigh at max for such a model
(fitEffort: a tie goes up), so no level the model doesn't take is sent.
Claude models Claude Code knows are unchanged: Opus and Sonnet 4.6 still
get no xhigh, as Claude Code's own table has it. Models that top out at
high, or have no known levels, are unchanged too.

Tests: TestClaudeModelCapabilities gets v/glm (low/high/max) and v/top
(high/max), both now "effort,xhigh_effort,max_effort", while
v/claude-opus-4-6 stays "effort,max_effort". TestClaudeCapabilitiesSync's
w/b (low/max) now has xhigh_effort. TestFitEffort covers xhigh to
[high,max] going out as max. With the change turned off by hand, both
agent tests go red on exactly those values.

Run:
- Real Claude Code 2.1.299 in a sandbox HOME, gateway mode
  (CLAUDE_CODE_USE_GATEWAY=1), `-p '/effort ultracode'`, with the value
  magpie's own code wrote for v/glm-5.3 at low/high/max
  ("v/glm-5.3=effort,xhigh_effort,max_effort") printed "Ultracode on (this
  session only): dynamic workflows on every task". The old value
  "effort,max_effort" printed "Ultracode isn't available on v/glm-5.3".
  The same pair was run for Desktop's id mythos-magpie-7, with the same
  two results.
- gofmt -l is clean. go vet passes for darwin, GOOS=linux -tags nogui and
  GOOS=windows.
- go test ./internal/agent passes when run alone (1110s at load ~250),
  and so do the caps and fitEffort tests.
- The full go test ./... ran twice at load average ~300.
  - The first run hit internal/provider's 10m timeout (#2051).
  - The second run (-timeout 30m) had these reds:
    - internal/agent and internal/gateway passed 30m as whole packages;
    - TestAgentGoneInTheRetryPause/last_one_left (#2175's sibling);
    - TestMainWindowCorners was killed at its deadline (#1936).
  - None of these is in code this commit touches.

Not tried: a live Claude Desktop. The packaged app won't start on a
sandbox user-data dir, and the live Desktop config is not to be touched.
So Desktop's effort menu showing Ultracode was not seen. It rests on
Desktop's renderer code (the Ultracode gate needs xhigh among the options
and the claude_code_workflows capability) and on the Claude Code probe
above.
2026-10-14 20:51:01 +08:00
yetone 22512cde53 provider, gateway: rest-cap off never rests a provider's keys after an unknown failure (Kismet Alan on Discord)
A relay or account pool fails now and then with errors that say nothing
of why (a 5xx, a dropped connection), and the next request often goes
through. Every such failure rested the key or account a minute, doubling
up to 10, and `rest-cap` could only move that cap (1 minute at least;
`off` read as `default`).

`magpie provider rest-cap <id> off` (provider.RestCapOff, restCap: -1 in
providers.json) now has a failure that says nothing of why (failOther)
rest nobody and not count toward the backoff: restAfterMarked returns a
Rest by "off" with no time left. What says why still rests as before: a
401 or 403, a model not served (restID), an account's window full, a
rate limit (magpie's own 30-minute cap; RestCapOr treats off as unset),
quota, credit, a restriction. `rest-cap <id> 30s` is turned away and names
1m and off (the first rest is a minute already). The Routing page tells a
try rested by "off" as not resting (one new string, zh/zh-TW/ja/de).
No "fail N times before switching" counter: a failed try already moves
the same request on to the next key or member, so a count would only
keep requests on a failing upstream longer.

Run:
- TestRestCapOff (gateway), TestRestCapCmd (cli), TestOwnRestCap: pass;
  each goes red with the change taken out by hand (the early return
  disabled: "#1 500: rests 59.99s by backoff"; restMinutes in place of
  restCapMinutes: "off: <nil> 0").
- routing-rest-off.test.cjs: 20/20 (chromium, webkit; 1100, 420; en zh
  zh-TW ja de); red 10/10 with the "off" case renamed.
  routing-wb-restricted 20/20. rest-try-now and routing-model-rest fail
  a varying few under load average 200-420 here, and fail more on
  origin/main 331c27703 run at the same time; neither reads "off".
- gofmt -l clean; go vet darwin (provider, gateway, cli, gui), GOOS=linux
  -tags nogui and GOOS=windows (provider, gateway, cli).
- go test ./... with pipefail, sandbox HOME: every package ok except
  agent, gateway and library, which hit the 10m timeout under load
  average ~200 (no test hung: each stack shows a different test seconds
  in). Rerun with a longer -timeout: library ok (603s), gateway ok
  (1572s) and agent ok (1457s).
Not tried: a real relay; the change is in the rest bookkeeping only.
2026-10-14 20:49:20 +08:00
yetone d692b25481 tests: routing-burst-speed scrolls to a row with a wheel over a point in sight, not hover()
The row pick was red on a loaded machine ("picking the request moved the
page", zh in Chromium, 2 of 4 on origin/main 331c27703 at load ~250).
hover() on .rt-reqs scrolled the list's bottom into view by script; the
day's click still held the view at its top and put that scroll back, and
only a wheel made within 50 ms of the put-back gives it back (givesBack).
When the wheel came ~150 ms later the view stayed 18px short, and the
click then scrolled the row into view itself. Traced with a scroll-write
probe: the put-back at hold(), and givesBack's SET18 only on the green
runs.

The test now wheels over the part of the list in sight while the row is
below the list's end, and over the view's head while the list ends below
the window, so every scroll is the reader's.

Run: routing-burst-speed, both engines, en and zh, 3 of 3 green at load
~300. Broken by hand (hold() returning at once, and a pick scrolling the
view 30px) it goes red in en and zh; with only the pick's scroll it stays
green, as the hold puts that back.
2026-10-14 20:41:06 +08:00
yetone 6855218884 gateway tests: TestCanceledRequestRestsNobody cancels once a is asked, not 50ms after the request began (#2175)
The sibling of #2175 (fixed for TestAgentGoneInTheRetryPause in
b8070cc6c): this test canceled 50ms after the request began and let a
answer 50ms later, assuming a was being asked by then. On a busy
machine the cancel could land before a was asked, or a's 200 race the
cancel, and the test no longer covers an agent leaving mid-request.
The scripted fake now closes `hanging` as its first request starts to
wait; the test cancels then, and a answers only once the gateway is
done with the request (or after 10s, so nothing outlives the test).

Run (rebased on origin/main 5ccc05afe):
- broken by hand: a 150ms delay before ServeHTTP (the request reaching
  a late) still passes with the new wait. Before the rebase, with my
  own version of the TestAgentGoneInTheRetryPause wait: a 300ms delay
  in its fake upstream turned the old test red with the issue's shape
  (Millis 110/131, Again 0, Fail:canceled).
- go test -race -run 'TestCanceledRequestRestsNobody$|TestAgentGoneInTheRetryPause$'
  -count=20: ok (360s, before rebase); -count=5 after rebase: ok
- go test ./internal/gateway/ -count=1: ok (1419s, load average ~395,
  before rebase; the rebase changed only agent_gone_pause_test.go,
  taken as origin/main has it)
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: clean

Looked at and left alone: the 100-200ms sleeps before cancel in the
claude_subscription rewind/takeback/park tests and in
TestVertexMintWaitCancelled come after the state they need is already
seen (the fake holds its reply forever), so a late cancel changes
nothing.
2026-10-14 20:33:22 +08:00
yetone 5ccc05afe7 gateway: a plugin's non-streaming Responses request is relayed streamed and given back whole, so Grok's x_search runs (plugins#112, Watchyourback)
Plugin accounts only stream (Account.Stream), so a stream:false request
was translated: parsed to the IR and rebuilt. The Responses parser keeps
only function and web_search tools, so x_search never reached the Grok
plugin, and Grok answered "let me look that up" without searching. The
rendered reply also hardcoded "tools": [], dropped
usage.server_side_tool_usage_details, and dropped web_search's open_page
item. Watchyourback's capture of the plugin's fetch showed this (no tools
field, input wrapped into message[], store:false); CodeAlex52's code read
agreed.

Now a plugin's request on Responses that asked for one body is relayed
like a streamed one (gathers, used by serve's relay decision and by
passthrough):
- It is asked with stream:true, and the stream goes through the relay's
  usual tidies.
- The client gets the `response` of the stream's response.completed (or
  response.incomplete) as one application/json body. Its output is
  filled from response.output_item.done items, or else the streamed
  text, when that event's output is empty (gathered.go).
- A non-200 goes back as before.
- A whole reply goes back as it came.
- A stream that fails, or ends without its last event, is a 502, as a
  translated one is, never an empty 200.
- Usage is counted from the stream, as for a streamed relay.

Left as it was:
- Messages: its stream has no event holding the whole reply, so
  gathering it means assembling the message from deltas. That is not a
  simple sibling.
- Subscriptions magpie signs in to itself (ChatGPT backend, Qoder,
  MiMo...): their own code fits their requests, and their fakes end in a
  response.completed with no output. A first version that covered every
  stream-only account broke 7 Codex/ChatGPT-API tests, so it was
  narrowed to plugins.

TestGrokPluginGetsNamespacedTools now expects the namespace's freeform
custom tool to be left out (grokBody), as the built-in and the streamed
plugin already did. The translation had offered it as a function.

Tests (fake grok plugin through the plugin host):
- TestGrokPluginNonStreamKeepsHostedTools: upstream SSE with a
  custom_tool_call, tools [x_search] and server_side_tool_usage_details.
  Asserts the plugin was asked stream:true with tools [x_search]; the
  client gets application/json with the custom_tool_call, message,
  tools and details; usage is recorded at 50/7.
- TestGrokPluginNonStreamEndedShort: no response.completed gives 502.
- TestGatheredTextOnlyStream: deltas only.
Each was broken by hand and went red:
- the relay condition reverted: "the plugin was offered null";
- the missing-completed check removed: 200;
- the text fallback removed.

Run: gofmt -l; go vet ./internal/gateway on darwin, GOOS=linux -tags
nogui and GOOS=windows; go test ./internal/gateway -count=1 (ok, 1400s,
load ~200).
Not tried: a real Grok account or the real grok plugin; the reporter's
allowed_x_handles case.
2026-10-14 20:25:21 +08:00
yetone f3ea4bd69e gui: an agent's model picker lists magpie's models before the ones it asks for itself (abledo on Discord)
abledo: "为什么claudecode的magpie模型选不了?其他的agent可以选". Claude Code
pointed at a relay through its own ANTHROPIC_BASE_URL showed that relay's
Claude models first ("Claude Code · <host>", a dozen-plus rows), and with
the current model lifted to the top every magpie model sat below the fold.
The server always sent them; only the order hid them.

openPicker now orders: the picker's own choices (Automatic, Off), routing
groups, each provider's models, then the agent's own direct rows. This
covers every agent with direct rows (Claude Code, Codex, dsh), not only
Claude Code. The current model is still lifted to the top.

Run:
- new claude-picker-magpie-first.test.cjs: chromium + webkit, widths 1100
  and 420, en/zh/zh-TW/ja/de, wired false and true: 22/22. Fails on the
  old app.js (own group before Zhipu).
- claude-picker-fold.test.cjs updated for the new order (own group and
  its fold row last): 22/22.
- the 67 GUI tests that touch direct rows or #pop, with the change: green
  except claude-picker-fold before its update. searcher-pick chromium zh
  failed twice under load at its scrollIntoViewIfNeeded after reload
  (#1745); it passes alone 2/2 and in the later batch.
- go test -tags nogui ./internal/gui: ok.
Not tried: the real desktop app with a real relay-configured Claude Code.
2026-10-14 20:21:25 +08:00
yetone 07e95265af gui: a picker on a phone keeps to the room it was placed in, never off the window's top
On magpie web at phone width the pop may grow to the window's height
(body.web .pop { max-height: calc(100% - 16px) }), more than the 420 the
model picker is placed by. Opened upward from a row low in the page, its
top went above the window (y = -241 at 420x760 in zh): the filter and the
first rows were out of reach. placePop now holds the pop to the room it
chose, above the button or below it (holdPop), and the list scrolls.
Found while testing abledo's Claude Code picker at 420.

Run:
- pop-phone-room.test.cjs (new): chromium + webkit, 1100 and 420,
  en/zh/zh-TW/ja/de, 22/22. On main's app.js all five languages at 420
  fail with the pop at y -223/-241. Run 4 at once in webkit, 4/4 green.
- The 45 GUI tests that open #pop, both engines: green but
  claude-picker-magpie-first (the next commit's, red until it) and
  searcher-pick, which failed chromium zh twice at line 304
  (scrollIntoViewIfNeeded after page.reload: element not attached),
  passed 2 of 2 alone with this change and 1 of 1 on main's app.js; no
  pop is open at that step.
Not tried: a real phone; the desktop app (its picker's max-height already
equals the h it is placed by, so nothing changes there).
2026-10-14 20:21:24 +08:00
yetone 2c2155c452 gateway: Claude Code through magpie on any model lets a relay be tested as Claude Code
neiko on Discord: Claude Code connected to magpie, and "Test as Claude
Code" stayed grey. The test asks with the headers Claude Code last sent
(client-shapes.json), and those were noted only where they were passed
on: a request forwarded on Anthropic Messages to a keyed provider. A
Claude Code on a subscription, a Chat provider's model or any translated
one never got there, so the test kept saying no Claude Code request had
come. They are now noted as the request arrives on /v1/messages, after
the caller guard, whatever serves it; the forward still passes them on
only to a keyed provider on Messages, as before.

Run:
- TestClaudeCodeSeenOnAnyRoute (new): Claude Code on a Chat-only
  provider, then a relay's model tested as Claude Code with its headers.
  Fails on main ("no Claude Code request has come through magpie yet").
- TestModelTestAsClient still green.
- gofmt; go vet darwin, GOOS=linux -tags nogui, GOOS=windows for
  internal/gateway and internal/provider.
- go test -tags nogui ./internal/gateway ./internal/provider (-timeout
  60m; the machine was at load ~300): gateway ok; provider red only on
  TestCopilotSecretToolUsername's 10s bound under load (#1627), green
  3 of 3 alone. The full ./... ran twice and timed out package by
  package at load ~270-300 (10m default, then build failures in the
  second), so it is not a pass.
Not tried: a real Claude Code against a real Claude Code-only relay.
2026-10-14 20:21:12 +08:00
yetone 2c5db1c6ea gui: a template picked from Routing's Templates menu opens filled in, in the editor and in view
Owner, 10-14: picking a template from the menu added a group somewhere
below the fold, with nothing to show what happened. Now a pick opens the
new-group editor with the template in it (as the cards' Edit first does),
scrolls the editor's top into view and focuses its name. Nothing is saved
until the user saves. The cards' Add still adds in a click, since the
group then shows in place of the cards.

- openRowMenu passes its click to run(e), so an item can scroll through
  scrollOnPurpose; every run is an arrow function, the others ignore it.
- block "start" with scroll-margin-top 12px, not "center": the editor
  is taller than the window, and centred it opened halfway down the form
  (ja/de/zh-TW failed the new test that way).

Run: group-template.test.cjs + click-scroll.test.cjs, chromium and
webkit, en/zh/zh-TW/ja/de at 420px: 52/52. The new test (12 groups of
the user's, so the editor opens below the window) goes red with the
scroll removed by hand. Load average was ~300 during the runs.
2026-10-14 20:18:40 +08:00
yetone e1dcd1e1d7 tune: a compaction window advised never makes you wait longer on compactions, and says the wait (HirotaNagai on X)
Tuned for you advised the compaction window by tokens alone, so a smaller
window that compacts far more often could be advised however long each
compaction keeps the user waiting.

What changed
- sessions: a call now carries how long a compaction took (Call.Compact).
  Claude Code's compact_boundary line gives compactMetadata.durationMs,
  which goes on the first call after it that isn't an error. Codex compacts
  by a call of its own (the token_usage_record a compacted line names), and
  that call's own time is the compaction's. Older rollouts with no such
  record stay untimed. callCacheVersion is now calls-v13.
- tune: with 3 or more compactions timed for a model (minTimed), Facts.took
  is their median in seconds, and each window's Point.wait is its
  compactions x took. When compactions are timed, the advice never takes a
  window that compacts more often than the current one. Of the windows that
  don't, it takes the cheapest, and of those within 3% of that (sameCost)
  the one that compacts least. Tokens and seconds share no unit the files
  measure, so magpie doesn't trade one for the other at a guessed rate. The
  token-cheapest window is reported (cheapest, wait_cheapest) so the user
  can pick it. A model with fewer than 3 timed compactions is advised as
  before, with no wait shown.
- GUI (Usage > Context): when timed, the advice is labelled
  "Tokens + wait". The explanation says what a compaction took, the wait at
  the advice against the window now, and the cheaper window that would wait
  longer (if it saves 3% or more). The caveat says tokens and waiting only.
  The picker shows each window's wait, with "Fewest tokens" on the
  cheapest. Untimed rows are unchanged. The new strings are in zh, zh-TW,
  ja and de.
- docs/subsystems/agent-wiring.md describes the timing sources and the
  rule.

What was run
- go test -tags nogui ./internal/sessions ./internal/tune ./internal/gui
  ./internal/agent pass.
  - internal/agent ran before the rebase. It took 1416s under a load
    average of 120-300 and passed with -timeout 40m (the default 10m timed
    out mid-suite). Its Tune/Compact/CacheTTL tests pass on their own.
  - sessions, tune and gui ran again after rebasing on origin/main
    331c27703. fcd6f3519, the head this was pushed onto, touches none of
    these files.
  - internal/gui's TestProviderListReadsSettingsOnce failed 1 of 3 runs
    under load (7.0s against its 2s bar). It passed 6 of 6 on this branch
    and 9 of 9 on origin/main 4048ead7f, and it doesn't touch this code.
    Filed as #2185.
  - TestCallsClaudeCompactTook and TestCallsCodexCompactTook check the
    timings, also after Reset.
  - TestCompactTimedWaitsLeast checks the advice from 1M, 600K and 150K.
    With the timed rule disabled it fails ("advised 260000 makes 36
    compactions, more than 4 now").
  - TestCompactUntimedUnchanged checks that 2 timed compactions give the
    same advice as none, with no wait.
- GUI: context-tune, i18n-keys and context-window pass, 97/97 in Chromium
  and WebKit, in en/zh/zh-TW/ja/de at 360 and 1100 px. The new timed test
  fails against the old assets ("Fewest tokens" where "Tokens + wait" is
  expected).
- gofmt -l is clean. go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./... are clean.
- Real data, from copies of the owner's 4 Codex rollouts and 8 Claude
  transcripts in a sandbox HOME:
  - Compactions took 28-46s (opus-5-5), 85-139s (fable-5-1) and 52-121s
    (Codex gpt-5.6-sol).
  - gpt-5.6-sol keeps 230K. Before this change it was advised 70K: 44%
    fewer tokens, but about 3.5h of waiting against 30m.
  - opus-5 moves 200K to 190K, with 6% fewer tokens and the same wait.
  - Untimed models are unchanged.

Not tried: the live app with real accounts. The replay assumes a
compaction takes the same time at every window, since the files only time
compactions near the window the user ran with.
2026-10-14 20:03:53 +08:00
yetone b7a2e73761 agent: connecting an app that gets magpie's models as its provider, with none listed for it, says why instead of reporting success (Lumens on Discord)
Lumens (v0.1.1233) connected WorkBuddy from the Agents page. The toast
said it was connected, but the toggle flipped straight back and
WorkBuddy had no magpie models. For agents that take magpie itself as
the provider (WorkBuddy, WorkBuddy AI, ZCode, Pencil, T3 Code, Copilot
JetBrains), Agent.connect() went down the "magpie" branch and called
Apply without checking whether any model was listed for the agent. With
none listed (no provider or subscription yet, or "only picked" with
every pick gone), Apply wrote nothing, connect still answered 200, and
the next read found nothing wired.

The fix applies, then, if the agent still doesn't read as wired, returns
the same NoModelsError or AllHiddenError the field-less path already
used. The GUI already maps both to no_models and all_hidden, in all five
languages. The check comes after Apply because Cursor Private Inference
is wired through its environment with no models at all, and
TestCursorLocalConnects keeps that connecting. The noModelLeft helper is
shared with the existing field-less path.

Tests:
- TestConnectMagpieAsProviderWithNoModelLeft (agent): WorkBuddy with no
  provider gives NoModelsError. With its only picked provider switched
  off it gives AllHiddenError and stays unwired. Switched back on, it
  connects and is wired.
- TestAgentConnectNoModelsMagpieAsProvider (gui): POST
  /api/agents/connect/workbuddy with nothing in magpie gives 400
  no_models. The old code gave 200.
Both fail on the old code.

Run:
- gofmt -l is clean.
- go vet passes on darwin, on GOOS=linux -tags nogui and on GOOS=windows,
  for internal/agent and internal/gui.
- go test -tags nogui passes for ./internal/agent and ./internal/gui under
  a sandbox HOME (load ~250 from sibling sessions).
- An earlier full ./... run: gateway, library and provider passed on a
  rerun with a longer -timeout. Their first run hit the 10m timeout under
  load, with no assertion failures.

Not tried: the real WorkBuddy app, and Lumens' own settings, which
haven't been seen. Left for its own change: workbuddyWired counts only
vendor "magpie" entries, while buddyWrite also treats an entry under
magpie's key that WorkBuddy re-saved as vendor "Custom" as magpie's.
2026-10-14 20:01:06 +08:00
yetone 62e012b3e2 gui tests: Settings tabs are opened with Enter, not a click that waits on frames a loaded WebKit doesn't draw (#2150)
Cause: quota-reads (webkit de 360) timed out on
`:is(#setTab-usage, .nav-s[data-of=setTab-usage]):visible").click()`. Its
call log ends at "waiting for element to be visible, enabled and stable",
with no "element is not stable" retries, so the tab wasn't moving.
Playwright's stability check compares the box over two
requestAnimationFrame callbacks. WebKit's frames are driven by its UI
process, and on a loaded machine they stall for seconds while the page's
ordinary tasks run on, so the click sat out the whole 5s page timeout over
a still tab.

Reproduced by injecting a delay: SIGSTOP/SIGCONT duty-cycling of WebKit's
UI process (10ms on / 990ms off) around the tab step in a copy of
quota-reads. click() took 3-4s and timed out in 4 of 6 runs.
press("Enter") on the same locator took 2-3s and passed 6 of 6.

Fix: reader.cjs gets openPart(page, id), which presses Enter on the tab or
its sidebar strip entry. Both are <button>s, so Enter clicks them with no
frame to wait for. All 49 call sites of that locator shape across 35 test
files use it now. The other shapes (getAttribute, focus, boundingBox, the
.nav-s strip's own pointer tests) are left as they are, since they test
the tab itself.

Run (playwright 1.62.0, chromium + webkit, each file's own languages and
widths): all 35 changed files, four at a time, at load average ~400 from
other sessions. 450 tests passed. sync-not-backup (#prefs not there yet)
and tray-inuse (a 180s browser launch timeout) failed one test each
before the tab step; alone they pass 20/20 and 4/4.

Not tried: the other rAF-polled waits across the suite (waitForFunction
defaults to rAF polling, and settingsDrawn is one of them). They starve
the same way under this load, but none is named in #2150 or #2151.
2026-10-14 20:00:55 +08:00
yetone fcd6f35198 gateway: a decision model's intent counts by its option probabilities, not its own confidence field (@VersunPan on X)
Cause: readJev took an intent (and kept a level over the turn before's)
only when the answer's `confidence` was at least jevSure (0.4). That
scale is System One's: 0 for an even spread, 1 for one option certain
(provider.Confidence, (top - 1/n) / (1 - 1/n)). Other decision models
fill the field their own way. Cloudflare's @cf/cloudflare/clef-flash
compresses it: "提醒我明天下午三点给 Dora 打电话" came back light at
0.2866 while its top probability was about 0.68, so everyday requests
matched no rule and fell through to the group's default (Opus).
MLX-Serve's clef-flash-4bit says its top probability (0.68-0.95) and
passed. Both picked the same choice 15 of 15.

Fix: sureOf reads sureness from the answer's `probabilities` when it
gives two or more numbers, on System One's scale. Cloudflare's
clef-flash output schema makes probabilities (summing to 1) and
confidence required for a choice answer, and calls confidence only
"derived from the probabilities". Jev's own confidence is that same
formula, so Jev's decisions don't change. An answer without
probabilities is read by its confidence as before. A near-even spread
still comes out near 0 and matches nothing. The threshold stays 0.4.
The level path, which falls back to the turn before's level when
unsure, uses sureOf too. Verdict.Sure, which the Routing page shows, is
now the value the decision used. The effort pick reads only `score`, so
it is unchanged. The GUI line "An intent it isn't sure of matches no
rule" stays accurate.

Tests (decide_sure_test.go):
- TestClefFlashSureByProbabilities runs end to end through Workers AI's
  envelope at /ai/run/@cf/cloudflare/clef-flash, with answers shaped as
  that schema has them. Light at 0.68/0.14/0.10/0.08 with confidence
  0.2866 now routes to its rule (Sure 0.573). A 0.28/0.25/0.24/0.23
  spread matches none.
- TestJevLevelSureByProbabilities: a clear level is taken over the turn
  before's, a torn one keeps it, and an answer with no probabilities
  falls back to its confidence.

Run: gofmt -l (clean). go vet ./internal/gateway on darwin, GOOS=linux
and GOOS=windows. go test ./internal/gateway -count=1 -timeout 40m: ok
(2086s at load ~250. A first run hit go test's default 10m package
timeout under that load).

Broken by hand:
- readJev back on a.Confidence: both tests red. The CF case went to
  "from ka" with Sure 0.2866, the reporter's miss.
- sureOf floored at 0.5: the near-even spread and the torn level went
  red.

Not tried: a real Workers AI call. The fixture's spread is built from
the reporter's numbers (sure 0.2866, MLX top 0.68, MAE 1.6%), not from
saved bytes of that request.
2026-10-14 19:54:31 +08:00
yetone 430871d632 provider: SiliconFlow offers its international site as a region beside China
SiliconFlow asked (by mail) for its international site, api.siliconflow.com,
in magpie. It is a separate account with its own keys page and a $ balance,
so the siliconflow preset now has two regions: China (the default, so every
saved provider and link reads as before) and Global, with
cloud.siliconflow.com's key page and console. The balance read already knew
the .com host. Import links take region=intl; the import docs (en, zh, ja)
list it. "Global" reuses the GUI's existing translations.

Run: go test ./internal/provider/ (ok, 541s), incl. the new
TestSiliconFlowInternational: an intl link gets the .com endpoint, key
page, console and $ balance source; FromPreset stays on .cn; a saved .cn
provider sits at region cn and an intl one at intl. gofmt, go vet clean.
Not tried with a real international-site key (no account).
2026-10-14 19:52:21 +08:00
yetone 4048ead7fa provider: a balance query's header takes the key as {token} too, and the key pasted as its token goes as a Bearer (lx_78654 on Discord)
A key usage query that takes only "Authorization: Bearer <key>"
answered magpie's Check balance with {"code":"INVALID_AUTH_HEADER",
"message":"Authorization header format must be 'Bearer {token}'"}. Two
ways got there:
- a header written as the vendor's own error names it, "Authorization:
  Bearer {token}", went with "{token}" in it as written: only {key},
  {apiKey} and {api_key} were put in;
- the key pasted into the Account balance (token) field went bare in
  Authorization, the way a new-api access token goes.

The key is now put in for {token} as well, for any case of key, apikey,
api_key, api-key and token, and in {{…}} or ${…}. A balance token that
is the provider's own key (with or without "Bearer ") is taken as no
token, so the query is asked as a chat request is, with the key as a
Bearer. A token of the account's own still goes as it is. Without a
header or a token the key already went as a Bearer.

Run:
- TestBalanceKeyAsBearer: an httptest server that answers only
  "Bearer <key>"; no header, Bearer {token}/{key}/{API_KEY}/{{apikey}}/
  ${API_KEY}, the key and "Bearer <key>" as the token all read $8.50;
  {TOKEN} in the URL is escaped; an access token still goes bare. On the
  old code it fails with the reporter's INVALID_AUTH_HEADER for {token},
  {API_KEY}, {{apikey}}, ${API_KEY} and the key as token.
- go test -tags nogui ./internal/provider/ ./internal/cli/.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.

Not tried: the vendor's real endpoint (a relay, not contacted). Chat
requests still send Headers exactly as typed (provider.go's Headers
doc); only the balance query puts the key in.
2026-10-14 19:47:17 +08:00
yetone 8ea4fec90a tui: w changes a custom provider's base URLs (luluxiu_1_4392 on Discord)
On Linux, with no window, the TUI had no way to change an API-key
provider's base URL: w only moved a local server's address or a preset
with an endpoint, and for a provider of the user's own it only pointed
to `magpie provider set <id> url=…`.

w on a provider with no preset now asks each base URL it has (Chat,
Responses, Anthropic, Gemini) in turn, prefilled with the one there now;
Enter alone keeps one. Only http(s) addresses with a host are taken, a
trailing / is dropped, and only the URLs that changed are saved, the
balance cache forgotten. A vendor preset is still asked at its own
address, and the footer already said "w address".

TestTUIAddsARemoteMagpieWithItsAddress asserted w asks nothing on the
custom provider "a"; its vendor case now uses a DeepSeek preset.

Run:
- TestTUIEditsACustomProvidersBaseURL: one URL changed and saved
  without the trailing slash, a bad URL refused, a two-URL provider with
  one kept and one changed, Enter Enter = unchanged. With the new branch
  disabled it fails ("w opened "" (mode 0)").
- go test -tags nogui ./internal/tui/ (the full run caught the old
  assertion above, now updated).
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.

Not tried: the TUI by hand in a real terminal on Linux.
2026-10-14 19:47:16 +08:00
yetone ef0c515eb0 provider: a sub2api or new-api account query left without its token asks the key's query instead (lx_78654 on Discord)
The editor's "Use …/api/v1/user/profile" sets the Balance URL to the
sub2api panel's account query, which only the login JWT can ask. Its
Remove button clears the token but not the URL, so the profile query was
then asked with the key, refused with 401, and the Usage card said
"Allowance unavailable" for good.

keyQueryOf now asks the same panel's key query when the Balance URL is
an account query (sub2api /api/v1/user/profile, new-api /api/user/self)
and no token is set: /v1/usage and /api/usage/token, with the key, their
own default field unless the user wrote another. The saved URL is left
as set, so pasting a token again asks the account query again. A
provider whose Headers carry its own Authorization or Cookie is asked as
set. It covers every reader: the Usage page and `magpie quota`
(KeyBalances), the editor's Check balance, routing's key windows
(sub2APIKeyLimits), and `magpie provider <id>`, whose "from" line now
says the query actually asked (BalanceQuery).

Run:
- TestAccountQueryWithoutTokenAsksTheKey (httptest sub2api + new-api):
  JWT, removed, JWT again; new-api without token; custom field kept;
  account query never asked with the key; own Authorization kept.
  With keyQueryOf a no-op it fails with the reporter's 401 card.
- Sandbox CLI (scratch HOME, fake sub2api on 127.0.0.1): old binary,
  after `provider set sub2 balance.token=`, `magpie quota` shows
  "401 Unauthorized…"; new binary shows "$7.25 left", from /v1/usage.
- go test -tags nogui ./internal/provider/ ./internal/cli/ ./internal/tui/,
  and internal/gateway's balance, allowance, quota and key-limit tests.
  The full `go test -tags nogui ./...` passed every other package;
  internal/gateway and internal/agent ran out of time (10m, then 40m)
  with the machine at a load average of ~300-370, the tests running at
  the deadline seconds old, so not a hang; neither run finished.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.

Not tried: a real sub2api or new-api account; the GUI not clicked
through (no asset changed, it reads the same KeyBalances).
2026-10-14 19:47:16 +08:00
yetone b8070cc6c8 tests: TestAgentGoneInTheRetryPause cancels once the last try is in its pause, not 100ms after the upstream counted it
CI on b75e21be3 (ubuntu, run 38549121391) failed group_replan: the last
try ended 499 "canceled" after 112ms with Again 0, so the agent had left
while the try was still in flight, not in the pause the test is about.
The test counted the upstream's request and then slept a fixed 100ms
before cancelling; on a loaded runner the gateway hadn't read the 503 by
then. It now polls the trace until the last route has its tries and the
last one carries Again (written just before the pause starts), then
cancels.

Run (worktree on origin/main 331c27703):
- Injected a 150ms sleep in the fake upstream between counting and
  answering: the old test fails both subtests with CI's exact shape
  (Millis ~110, Again 0); the new one passes, -count=3.
- Break check: with try.Gone = true taken out of both pause paths in
  gateway.go, the new test fails both subtests.
- go test -race -run TestAgentGoneInTheRetryPause -count=8: ok (116s,
  load average ~300).
- gofmt -l clean, go vet -tags nogui ./internal/gateway ok.
Not run: the whole gateway package (only this test file changed).
2026-10-14 19:46:29 +08:00
yetone 331c27703a gateway, provider: send no prompt_cache_options to Codex, and ask again without it when an upstream refuses it (#2154)
pi-ai sends {"prompt_cache_options":{"mode":"explicit"}} on the Responses
API. The ChatGPT backend behind a Codex subscription answers 400:

  {"error":{"message":"prompt_cache_options is not supported on this
  model","type":"invalid_request_error","param":"prompt_cache_options",
  "code":"invalid_parameter"}}

Probed on 2026-10-14 with a read-only use of the owner's Codex token
(never refreshed or written): gpt-5.5, gpt-6-sol, gpt-6-astra,
gpt-6-luna and gpt-5.6-sol all refuse it, and the same requests without
the field return 200.

- codexBody drops prompt_cache_options with the other fields the backend
  turns away. prompt_cache_key stays; the backend follows it (#1473).
- prompt_cache_options joins the gateway's optional fields. Its refusal
  names the field bare, at the start of the message, which none of the
  existing patterns read, so unsupportedOptionalField also takes
  "<field> is not supported/unsupported" when the message starts with
  it. Only at the start, so a field named inside an echo of the input is
  not taken for it. As for the other optional fields, the refusal is
  remembered per provider, though OpenAI's wording says "on this model";
  the cost of that is a cache hint left off, never a failed request.

Run: go test -tags nogui for internal/gateway (40m timeout; load ~380
from other sessions), provider, catalog, codexcat and agent; gofmt -l;
go vet darwin, GOOS=linux -tags nogui, GOOS=windows. With each fix taken
out by hand, TestRefusedOptionalNamesOnlyUnsupportedFields,
TestPromptCacheOptionsRefusedRetried and
TestCodexBodyDropsPromptCacheOptions go red.
Not tried: pi-ai itself against a Codex subscription.
2026-10-14 19:06:51 +08:00
yetone f51863b3da catalog: a relay channel's word before a known model is that model, so Codex lets it see images (#2157)
The reporter's relay lists nyro-gpt-5.5, nyro-gemini-3.8-flash and
nyro-deepseek-v4.1-flash. None of those ids is in models.dev, so magpie
knew nothing about them: magpie-models.json gave each one
input_modalities ["text"], no context window and no reasoning levels, and
Codex refused every image. The bare ids are known (gpt-5.5: images, a context
window and reasoning levels).

renamed now also takes a leading channel word off an unknown id: 2 to 24
lowercase letters and a dash, when what is left has a digit and is a
known model. models.dev's own data backs it: 147 of its listed ids have
the form word-<another listed id> (openai-, databricks-, anthropic-,
doubao-, zai-, ...), and each is the same model. A listed id is never
renamed, so a vendor's own chan-gpt-5.5 keeps its entry; nyro-auto,
ny2-gpt-5.5 and nyro-gpt-5.5x stay unknown. NameOf keeps the word, so the
shown name is still the relay's own.

TestRenameNeverTakesAModelForAnother (#1383) had
anthropic-deepseek-v4.1-flash as a near miss. By the evidence above, that
id is DeepSeek's model under a vendor word, so the guard row is now
anthropic2-deepseek-v4.1-flash, which the rule still leaves alone.

A model magpie still can't place stays text-only: telling Codex a
text-only model sees images makes it offer view_image and fails the turn
upstream. For those the per-model "sees images" switch already writes
image into the catalog, which TestChannelModelsReachCodexWithImages
covers along with the renamed ids.

Run: go test -tags nogui for internal/catalog, codexcat, provider,
gateway (40m timeout; load ~380 from other sessions) and agent; gofmt -l;
go vet darwin, GOOS=linux -tags nogui, GOOS=windows. With the channel rule
turned off by hand both new tests go red (nyro-gpt-5.5 images false,
window 0; input_modalities [text]).
Not tried: a real Codex image turn through the reporter's relay.
2026-10-14 19:06:50 +08:00
yetone bab1b30009 routing: the hub's mode chip is written only when it changes, so a press held over the once-a-second redraw still clicks in WebKit (#2151)
Cause: the routing view redraws every second (setInterval → render →
header). header() set chip.textContent and goTo() re-set data-go, tabindex,
role and title each time, even when nothing changed. Setting textContent
swaps the chip's text node. In WebKit, a press whose mousedown and mouseup
straddle that swap gets no click, so goRouting never ran and
routing-mode-goes timed out waiting for .rt-found (webkit zh 420 on CI).
A reader pressing the chip for a moment could miss it the same way.

Reproduced by injecting a delay: SIGSTOP/SIGCONT duty-cycling of WebKit's
UI process. At 10ms on / 490ms off, a MutationObserver on .rt-hub plus
pointer logging showed pointerdown at 2407ms, the hub's childList swap at
2869ms, pointerup at 2904ms, and no click. At 50/450, 1 of 30 runs timed
out at the rt-found wait on the old code; 0 of 30 do with this change.

Fix: header() and hubText() go through setText (write only if different),
and goTo() sets each attribute only when it differs. The activity list's
heading chips already keep equal nodes through patch().

Test: routing-mode-goes now holds a press over one redraw. It counts the
routing interval's ticks through a wrapped setInterval, then does
mouse.down, waits for a tick, does mouse.up and expects .rt-found. On the
old routing.js this fails in all 10 WebKit cases at that wait (chromium
passes, since it clicks the common ancestor); with the fix it passes.

Run (playwright 1.62.0, chromium + webkit):
- routing-mode-goes: 40/40, en zh zh-TW ja de at 1100 and 420.
- group-switch-add-many, group-share, routing-key-windows,
  routing-weight-chip, view-scrollbar-drag, routing-steady,
  routing-idle-frame and routing-shape all pass.
- routing-live-patch failed one folded subtest only with 9 files run at
  once. It passes 2/2 alone with and without this change: a fixed 400ms
  sample, filed as #2174.

Not tried: the desktop app's WKWebView by hand. At 2% CPU (10/490) the
chip now clicks, but the view's scroll guard can still refuse or put back
the scroll when the click is handled more than 1s late. I left that
alone; it doesn't appear at 10%.
2026-10-14 18:59:50 +08:00
yetone 0506f011d7 agent: a Codex reaching the gateway from another machine is never joined beside its ChatGPT sign-in (#2145, lazydao)
A Codex in a WSL distro under NAT (or with MAGPIE_ADDR pinned beyond
loopback) signed in to ChatGPT was joined beside its sign-in: it sent
its ChatGPT token to <gw>/backend-api/codex, and from another machine
the gateway takes a named key alone, so every request was a 401.

chatGPT() is now false when onAnotherMachine(at.gw()): such a Codex is
wired as one with no ChatGPT sign-in, magpie as its provider with gwKey()
(the LAN sharing key). One of its own models picked still goes straight
to OpenAI on its sign-in, as it does for a Codex with no sign-in.

Run: TestCodexBeyondLoopbackNotJoined (new; fails on the old code with
the joined config), go test -tags nogui -count=1 ./internal/agent (975s,
ok), gofmt -l, go vet darwin / GOOS=linux -tags nogui / GOOS=windows.
A first version forced magpie API under NAT and broke
TestWSLCodexProvider (own model refused); this one keeps that path.
Not tried: a real WSL distro under NAT with a ChatGPT-signed-in Codex.
A NAT Codex already joined is rewired on the next connect or model pick.
2026-10-14 18:44:45 +08:00
yetone a4d580fa24 gateway: a group skips Antigravity for the system prompt it just turned away (#2156)
Antigravity answers Claude Code's and the Agent SDK's system prompt (the
x-anthropic-billing-header line, "built on Anthropic's Claude Agent SDK")
with 429 "Resource has been exhausted" whatever quota is left (#666).
magpie already tells it as prompt_turned_away, rests nobody and hands it
on, but each Claude Desktop turn in a group waited on the same refusal
first (#2156: 429 in 1073ms, then cursor/composer-2.5 200).

Now, once Antigravity has turned such a request away (any of the three
paths that set holdWriter.turnedAway), for agForeseeing (6h) after, the
candidate loop skips an Antigravity candidate for a request that carries
the line, when someone is left after it (antigravityForeseen). The skip
goes in Fallback with the hint, sets `other` as the asked path does, and
changes no account state. The last one left is still asked and told the
400 with the hint. A request without the line (titles, Codex) still goes.
An old refusal foresees nothing, so a block Google lifts is noticed. The
lines are still neither rewritten nor hidden (#666). The stamp is per
Server, in memory.

TestAntigravityTurnedAwayRestsNobody's "asked first again" half now
checks it with a turn without the line, since one with it is foreseen.

Run:
- TestAntigravityTurnedAwayIsForeseen: fails with the skip turned off
  ("Antigravity was asked again for the prompt it just turned away"),
  passes with it; TestAntigravity* -count=3 green.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ok.
- go test -tags nogui ./... in a sandbox HOME at load average 140-220:
  everything green except 10m timeouts in agent, cli, gateway, library,
  provider and TestSetAnswersWhileDevinAndProvidersHang (#1375, noted
  there); those six packages rerun with -timeout 45m: all ok.
Not tried: the skip against the real Antigravity account (the refusal
itself was reproduced with a real account before: 400 with the line,
200 without), nor Windows/Claude Desktop as the reporter uses. No GUI
change.
2026-10-14 18:41:56 +08:00
yetone 9bc9a6e5e1 tests: TestRefreshInvalidationCancelsStaleCall gives the second ask 10s, not 1s, so a loaded runner doesn't read it as a stale listing left running
Seen red during a full run at load average 200-360 ("stale listing was not
cancelled and followed by the new state", 1.73s). The test's fake first ask
waits on its context alone, so a listing that invalidation fails to cancel
never ends; a 1s bound only measured how fast the second ask and the commit
ran. 10s keeps that apart with room on both sides.

Run: a 1.5s sleep injected into the second ask fails the old 1s bound with
the same message and passes the 10s one; with provCancel() taken out of
forgetProviders the test still fails (Fatal at 10s, then the package times
out on Settle, as before). go test -race -count=20 -run the test, go test
-tags nogui ./internal/plugin (179s), gofmt -l, go vet darwin, GOOS=linux
-tags nogui and GOOS=windows on ./internal/plugin pass. Test-only change;
./... not run. TestRefreshDeadlineBoundsRealProviderCall in the same file
still bounds a 100ms deadline against a 1.5s plugin call with a 1s wait
(900ms/500ms of room); not changed here.
2026-10-14 18:41:45 +08:00
yetone bc2d351337 gui: a routing group's member held at its cap, or used up and set not to spend credits, stays on the Routing stage (#2129, wyq0x55)
A member whose accounts were all held — Codex used up with "spend
credits" off, or an account past the usage cap set on it — went to the
route's left list, and the stage draws r.order only, so the member
vanished from the group on the stage (d-task's gpt-sol-6.1), while a
used-up Claude, resting, stayed there faded. The stage now seats left
entries held at a cap or for credits (not those a gateway key may not
use, nor those whose plan doesn't list the model, which 01cee5a26 kept
off on purpose) in their place among the group's members, faded with
the existing "held" wording. A fold of a provider's accounts counts them
apart: "1 available · 2 held" ({n} held in zh, zh-TW, ja, de).

Run: routing-held-member.test.cjs (new) in chromium and webkit, en zh
zh-TW ja de, 1100 and 420 wide: 20/20; with routing.js reverted it fails
10/10 in chromium. All routing-*, codex-credits, account-cap, window-cap
and i18n* GUI tests, 4-wide, both engines: 1032 pass, 13 fail, all in
routing-keys-fold and routing-model-rest, which fail the same alone on
origin/main bda271999 (9/52 there, load ~300; #1612, #2115), and use no
left entries. Not tried against a live gateway with a used-up Codex.
2026-10-14 18:40:39 +08:00
yetone 845b5c4ddd gui: Settings › General's Codex model rows and Open at login say what they do in their tooltip, and Lightweight mode that the gateway keeps running (#2120)
Anoninz asked on #2120 what the Codex model rows do, why Open at login
shows under App Background Activity on macOS, and what Lightweight mode
gives up. These rows were made to say their name alone in f36e744c3
(1ooogle's mockup, approved by the owner), so this adds no line under
them. The explanation goes into the row's tooltip, the way the text size
keys went in that same commit.
- Codex thread titles, descriptions, composer predictions, auto-review
  and memories model rows: what Codex uses the model for and when, and
  what "Codex's own" means. The facts are from settings.go and
  codexcat.go.
- Open at login: opens in the menu bar (tray) with no window. On a Mac
  it is a launch agent, which System Settings › General › Login Items
  lists under App Background Activity, not Open at Login. The section
  names are from macOS 26's LoginItems loctables.
- Lightweight mode keeps its one line. It now says the gateway and tasks
  keep running and only the page reloads (lightweight_rule.go: only a
  closed window's webview is let go). It still fits on one line at 1000px
  in every language. In de, "only the page reloads" didn't fit, so de
  says that the gateway and tasks keep running.
All five languages are covered: en, zh, zh-TW, ja and de.

Run: NODE_PATH playwright 1.62.0, chromium and webkit, all green:
- i18n-keys, bare-ids, gui-de, gui-ja, gui-zh-tw, search-keys
- lightweight, settings-general, settings-groups, settings-sections,
  settings-search, keep-login
- codex-titles, codex-descriptions, codex-predictions,
  codex-auto-review, codex-auto-reset-settings, codex-memories,
  codex-memories-settings, codex-subagent-model
A scratch check (not committed) loaded Settings › General in both
engines, at 1100 and 420, in all five languages, with Mac and non-Mac
platforms. It found each tooltip set and translated, the Mac/other
login text picked right, no sideways scroll, no row overflow and no
page errors (40/40).

Not tried: the tooltips weren't hovered in the real Wails window. No
Go code changed, so no go vet or go test was run.
2026-10-14 18:36:42 +08:00
Edward4226 52b5d9f83f gui: an allowance curve says when it runs out, so its 52px shape need not be read (#2079, #2146, Edward4226)
A window's curve is asked one question — will this run out before its reset,
and when — and answers it with the angle between two lines in a 52px box. In
the issue's card (a monthly window 13 days into 30, 28% used, under even
burn) the curve's own slope is 4.9° on the Usage page and 1.5° in the tray's
spark, against even burns at 7.8° and 2.4°: the two differ by 2.9° and 0.9°,
and in the panel their right-hand ends sit about 2px apart. 65a8365 has since
drawn that spark 30px tall and shaded which side of the burn it is on, which
answers "which side" at a glance; the hour is the half a shape still cannot
give. An axis fitted to the readings does not give it either: the dashes are
the cycle's even burn, a full-height diagonal from a window's start to its
reset, so fitting the axis pulls the burn out of the readings' own range and
inverts the reading. That change is right for a balance and wrong here (the
commit before this one).

So the answer is said, in the reader's own clock. Main grew a quotaPace of
its own — 3a7d031, "Pace +20%" on the reset line, the meter's share less the
share of the window gone by. That is where a window stands, which the eye
still has to turn into a rate; the hour is the missing half. The helpers here
are named quotaEta / quotaEtaText / quotaEtaSpan so as not to shadow that
quotaPace, and the two are meant to sit on one card: "Pace +9%" above
"Runs out Oct 26 13:22 at this pace".

- quotaEta: a window's recent run — the readings since it last refilled,
  within the week, walked back while each older one is the higher, as
  balance_history.go fits a balance's over balanceFitSpan — fitted to a line
  and carried to where it meets zero. {out} is that hour; {lasts} is whether
  it falls after the reset. Nothing is said with fewer than three readings,
  less than an hour of them, nothing left, a line that is not falling, or one
  already past zero.
- quotaCurve: the head carries the sentence, for the window whose deadline
  is furthest off, beside the range it already names; the title holds the
  full stamp. The plot itself is untouched, behind it.
- panelQuotaCard: the same sentence on the card whose deadline line it
  belongs to, for the window the thin spark draws. quotaWindowLine is the
  reading quotaSpark draws from, now shared by both, so the words cannot
  drift from the line they are about.
- "Runs out {when} at this pace" joins the existing "{in}" string, which the
  balance curve keeps, in all five languages: the hour is named (10月26日
  13:22) rather than counted to, since a counted-to run-out is the reader's
  arithmetic to do. "Lasts past the reset at this pace" is the other answer,
  and the one most windows should be giving.

Run (Node v22.20.0, Playwright 1.64, Chromium and WebKit, no backend, the
API faked), rebased onto 3b6ca05, whose own tray-spark-gap test still passes
underneath:

- node --test internal/gui/tests/quota-curve.test.cjs — 15 pass, both
  engines. Run against an LF copy of the assets: the file's quotaCycleBreak
  case slices app.js on indexOf("\n}\n"), so a checkout with
  core.autocrlf=true reads that function back as undefined and is red there
  whatever this patch does.
- node --test internal/gui/tests/quota-pace.test.cjs — 4 pass (the shipped
  Pace is unchanged by the rename and by the span beside it).
- node --test internal/gui/tests/balance-curve.test.cjs — 4 pass (the other
  commit).
- node --test internal/gui/tests/tray-spark-gap.test.cjs — 65a8365's 30px
  spark and its shading, unchanged, with the window line now coming from
  quotaWindowLine.
- With main's own app.js, app.css and i18n.js put back in place, both
  engines fail the new assertions by name: waiting for
  locator('.subscription-card').filter({ hasText: 'Codex' })
  .locator('.quota-curve').first().locator('.qc-pace').

Not tried: no real DeepSeek or Codex key, so the numbers behind the sentence
are only ever the fixtures'; a card whose window is read once every few hours
has three readings within the week and speaks, and nothing here decides
whether a run of one reading an hour is representative. The rate itself is
not shown (the balance curve's "about {amount} a day" is the precedent, and
a "%/day" unit for a 5-hour window reads oddly). No dark-theme-specific,
multi-account or pool treatment beyond what the shared card already does.

Review changes on merge (#2146), by the maintainer side:

- Rebased onto bda271999: main has dropped the box.title line beside the
  head, so the conflict there keeps main's (quotaCurveTitle draws it now).
- quotaEta says nothing for a cycle that is already over, and quotaCurve
  asks it only for the current cycle: a past cycle picked from the cycle
  menu has no pace left to tell. A unit case runs quotaEta in a vm (a
  falling run, one past its reset, too few readings, half an hour, nothing
  left, a flat run, and a past cycle flat and falling); with the guard
  removed it goes red.
- The tray card adds the sentence only when its reset line names the first
  window's deadline alone. With both Codex windows begun the line reads
  "↻ 14:26 · Weekly Oct 31", and the sentence (about the 5-hour window)
  after it read as the week's. The existing tray case now wants no sentence
  there, and a second fixture with only the 5-hour window begun wants it;
  with the old gate the first goes red in both languages. It is also left
  out while the curves are off, like the spark it speaks for.
- The Usage head keeps "Left over time" on one line and cuts the sentence
  short rather than wrapping it; its tooltip names the window (when the
  card has more than one) and the full stamp. German was cut at 420px
  ("Bei diesem Tempo leer um 15. Okt. 17:…"), so the German strings are
  shorter: "Leer ca. {when}" and "Reicht so bis zum Reset".
- Not taken: 25a2886 (the balance curve's axis fitted to its readings).
  The balance curve already says its run-out in words ("Runs out {in} at
  this pace", "about {amount} a day"), so the slope no longer has to carry
  it; a value axis that doesn't start at zero makes a cents-a-day drift
  look like a fall to empty; and valueBand only takes the floor in when the
  padded band already reaches below it, so when the dashes do reach zero
  inside the window they are drawn past the plot's foot instead of meeting
  it, the case its own comment promises.

Run on this tree (Playwright 1.62, Chromium and WebKit, load avg ~300):
quota-curve 28/28, quota-pace 4/4, balance-curve 6/6, tray-spark-gap
22/22, panel-usage 4/4, i18n-keys 3/3, usage-quota-head 4/4, quota-reads
22/22, quota-read-at 4/4, tray-usages 16/16, tray-usage-redraw 4/4,
quota-families 4/4, quota-pools 4/4, panel-balance-order 16/16,
quota-count-wrap 2/2, quota-name-translated 10/10, quota-credits 8/8,
quota-holds 2/2. An ad-hoc check (not committed) loaded the Usage page and
the tray in en, zh, zh-TW, ja and de at 1100 and 420 in both engines with a
falling week and a lone 5-hour window: the sentence is one line, nothing is
cut, no card or page overflows. gofmt, go vet (darwin, linux nogui,
windows) on internal/gui. go test ./internal/gui failed only
TestSetAnswersWhileDevinAndProvidersHang (#1375) and
TestMainWindowCorners/macOS_26_SDK killed at its deadline (#1936), both
already filed as load reds and neither touching these assets.

Not tried: real Codex or DeepSeek readings; dark theme beyond the shared
card; the full GUI suite.
2026-10-14 18:34:27 +08:00
yetone cf455ebd5f gui: a view at its top when a control is clicked stays at its top, what came in above moving the control down (#2134)
The click guard's own rule says "A view at its top stays at its top:
what comes in above the control there moves it down instead of
scrolling itself out of sight", but hold() only kept that rule for the
room at the foot. Anything that grew above the held control scrolled
the view to follow it. At 420 wide, Settings › About turning Automatic
updates Off gave the Version row its "are off" line ~2.3px tall once the
save answered, and the view slid from 0 to 2. hold() now keeps a view
that was at its top (h.top) at 0, so the switch moves down by those
pixels instead.

Tests:
- update-auto: a new case at 420x640 clicks Off with Settings at its top
  and checks scrollTop after the save's redraw (600ms), not only right
  after the click. On origin/main's app.js it is red in both engines
  (2 !== 0); with the change green.
- update-restart (#2096) held the switch to within 1px, which is the
  old behaviour at the top. It now checks the at-top rule when the view
  is at its top (scrollTop 0, switch down by at most 4px), and the old
  1px hold otherwise.

Run (load avg 200-340 from other sessions):
- update-auto + update-restart, chromium and webkit, widths 1100 and
  420, en/zh/zh-TW/ja/de: 32/32.
- 71 scroll-guard files (click-scroll, *scroll*, *steady*, *pin*,
  *profile*, settings*, stays-strict, held-animations, and every file
  checking "must not scroll the page"), both engines, 4 wide: 921 pass,
  11 fail. The fails are nav-sub-unroll, removed-groups-menu-scroll,
  settings-proxy-auth and text-size. Alone, settings-proxy-auth passes
  10/10 and nav-sub-unroll chromium 2 of 2; nav-sub-unroll webkit,
  removed-groups-menu-scroll and text-size are red alone on origin/main
  bda271999's app.js too (#1950, #1866, filed #2172).
Not tried: the real app window; only the Playwright engines.
2026-10-14 18:25:52 +08:00
yetone b75e21be31 agent: the Qoder app counts as Qoder again, found by the status file it writes to ~/.qoder (#2138, xiaozicoder)
xiaozicoder's Windows 11 has the Qoder app and the Qoder CN app
(Qoder-win-x64-user.exe, Qoder-CN-win-x64-user.exe from qoder.com and
qoder.cn) and no qodercli, and since v0.1.1220 magpie's Agents page lists
no Qoder at all. Qoder-win-x64-user.exe is the Qoder app (com.qoder.app,
qoder-app/releases/latest.yml at 0.4.7), not the Qoder IDE. Its app.asar
runs Qoder's CLI as its agent (qodercli 1.1.64's worker runtime, config dir
.qoder / .qoder-cn, QODER_CONFIG_DIR, with BYOK config management), so
~/.qoder/settings.json's providers.magpie reaches it. It writes the
enabledPlugins of its bundled qoder-context plugin to settings.json, which
alone stopped counting in the same change, so the app's Qoder was lost.

The app also writes .qoder-app-status.json (-canary-, -dev- for its other
channels) into ~/.qoder, or ~/.qoder-cn for the China product (the map is
in its app.asar; this Mac's Qoder.app 0.4.3 wrote one). Agent gets sign, one
more sign the agent is here for a dirShared folder, and Qoder's (both
builds) is that file. The JetBrains plugin's folder of #1495 has none, so it
still isn't Qoder.

Run: TestQoderAppIsQoder (both builds: plugin-only settings.json not
detected; each of the three status files detected; the status file with no
settings.json detected; a folder of that name not) red on the old code
(Qoder CN subtests fail), green now; TestQoderSettingsFromAnIDEPluginIsNotTheCLI
still green; go test ./internal/agent -count=1 -timeout 45m ok (1576s, the
machine at load ~350; a first run hit the default 10m package timeout mid
TestCodexAgentsV1WarnsWhenCodexOwnV2IsOn at 1s, not a hang). gofmt -l
clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean. A
nogui build's `magpie ls` in a sandbox HOME (PATH=/usr/bin:/bin) with
~/.qoder holding the plugin-only settings.json and a copy of this Mac's real
.qoder-app-status.json, and ~/.qoder-cn the same with a qoder-cn status,
lists Qoder and Qoder CN.
Not tried: the Qoder app on Windows itself, and whether its agent takes
magpie's provider from settings.json in practice (would need a live
~/.qoder changed).
2026-10-14 18:21:44 +08:00
yetone 6d19988416 usage: a provider the log names but that isn't set up now goes by its name, "Claude Code", not "claude" (@ByronVon1 on X)
The Requests page's Provider filter listed "claude" between named
providers. The usage log keeps the id of every provider a call went to,
and usageapi named those only from provider.All(). The Claude Code
subscription is in that list only while its account is discovered, so
after a sign-out, with account discovery off, or for a preset provider
removed since, the bare id showed. This happened in the filter, each
row's Provider column, the split-by-provider and model-at-provider
legends, the Account filter's provider notes, and the summary's model
and account subtitles (stateOf had its own copy of the same lookup).

- provider.KnownFace(id): the name and icon magpie knows an id by while
  it isn't set up. It covers the built-in subscriptions' card faces
  (accountCard: Claude Code, Codex, Copilot, Gemini, Antigravity, moved
  ones) and then the presets. A custom provider removed since stays its
  id, since nothing else knows its name.
- usageapi.providerFaces: one lookup for LedgerPage and stateOf, in
  order: the provider set up, "Local session" for session-unknown, then
  KnownFace, then the id.

Run:
- TestProvidersNotSetUpAreNamed (new, internal/usageapi). Fails on the
  old code with 13 errors across the filter, rows, both splits, the
  Account filter and the summary; passes with the fix.
- gofmt -l: clean. go vet for usageapi, provider, gateway, gui on darwin,
  and usageapi, provider on GOOS=linux and windows: clean.
- go test ./internal/usageapi ./internal/usage: ok.
- go test ./internal/provider ./internal/gateway ran at load average
  ~300 with other sessions' suites. Three timing tests went red, and each
  passes 3/3 alone (-count=3 -run): TestCopilotSecretToolUsername
  (#1627, commented), TestOTelFastRequestTranscriptDiscovery (#1811),
  and TestTranslatedStreamKeepsClientAlive (filed as #2169).
  TestUsageOverGateway and the gateway's TestUsage* pass.
- GUI: usage-ledger.test.cjs and usage-ledger-chart.test.cjs in chromium
  and webkit, 52/52 (playwright 1.62.0). app.js is unchanged, since the
  page already shows the name the API sends.

Not tried: the real GUI with a signed-out Claude account.
2026-10-14 18:19:16 +08:00
yetone bd4cb7a260 provider: moved Kiro, WorkBuddy and Factory users get plugins 0.1.11, 0.1.21 and 0.1.27 (magpie-community/plugins#120, #121, #119)
The movers' min, so keepMovedCurrent updates every moved user's plugin:
- kiro 0.1.11: a thinking model offers xhigh as its own level (50k
  budget), so Claude Code's xhigh isn't routed as max (plugins#120).
- workbuddy 0.1.21: a model free only at night (Hy4 preview, 23:00-08:00)
  is never said free, and a whole-day discount shows the price before it,
  from WorkBuddy's modelPromotions (plugins#121).
- factory 0.1.27: droid's Fast Mode models (Opus 5.5/5/4.8, GPT-5.5/5.4/
  5.3-Codex), and fast asked of a base model sent to its Fast Mode model
  (plugins#119).

All three are on npm (npm view: 0.1.11, 0.1.21, 0.1.27).

Run: gofmt -l, go vet ./internal/provider for darwin, GOOS=linux -tags
nogui and GOOS=windows, go test ./internal/provider (ok, 449s under load
~280). Not tried: a moved user's update in a running magpie.
2026-10-14 18:18:57 +08:00
yetone 1a33d22cca agent: an omp outside magpie's PATH (bun's ~/.bun/bin) is still found and asked its version on Linux and macOS, so its models offer max (whqtian on Discord)
whqtian: "ubuntu 24 版本的 omp 最大推理级别,还是xhigh,win版和 wsl版好了". omp
gets max in models.yml only when its version is known to be 16.4.0 or
later (ompTakesMax). The version comes from cliBin → binAt, which looks in
the user's tool folders (proc.FindTool: ~/.bun/bin, npm prefixes, every nvm
Node, mise, fnm ...) only on Windows. Elsewhere it uses the PATH magpie
was started with, and only the GUI and `daemon install` widen that. Under
`magpie serve`, web, tui, the CLI or a service, an omp installed by bun in
~/.bun/bin read as no version, so max was turned into xhigh. 31626c154
fixed only WSL's probe script, and Windows already had the fallback, which
is why only native Linux stayed on xhigh. cliBin now falls back to FindTool
on every system. proc.Version reads the npm package.json first, so it
doesn't need bun on PATH.

Verified:
- TestOmpVersionOffPath (a bun-layout omp 18.9.1 in a temp HOME, with
  PATH set to an empty dir) fails without the change (version "") and
  passes with it.
- Reproduced in Docker ubuntu:24.04 with real bun and omp 18.10.4, PATH
  without ~/.bun/bin, provider a/sol with efforts low..max, then
  `magpie omp a/sol`. The old linux/arm64 nogui build wrote efforts up to
  xhigh; the new one writes max. Control: the old build with ~/.bun/bin
  on PATH also wrote max.

Checks: gofmt -l is empty. go vet passes for darwin, GOOS=linux -tags
nogui and GOOS=windows. The GOOS=windows build passes. go test -tags nogui
-count=1 ./... was run under a sandbox HOME.
- The machine's load average was 200-360, so agent, gateway, library,
  plugin and provider ran out of the 10m timeout. Rerun with -timeout
  45m -p 2, all five pass.
- TestRefreshInvalidationCancelsStaleCall (plugin) and
  TestCopilotSecretToolUsername (provider) failed once under that load
  and passed on the rerun. Neither package depends on this change.

docs/subsystems/agent-wiring.md says where an off-PATH CLI is looked
for.

Not tried: the .deb GUI on a real Ubuntu desktop, or the reporter's exact
install.
2026-10-14 18:17:38 +08:00
yetone 8c5190a203 provider: a routing group keeps its thinking members' levels beside a member known not to think, so Codex shows its effort control (#2127, cnlove7777777-art)
#2127: with a routing group as its model, Codex showed an effort but no
control to change it, and new sessions and subagents ran at medium. A
group offers agents the levels its members have in common
(groupEntries), and a member magpie knows doesn't think (Entry.Quiet: its
vendor's list says no reasoning) counted as having none, so the
intersection came out empty. The group still reasons when one member
does, so Codex got its entry with reasoning but no
supported_reasoning_levels and no default_reasoning_level: no slider,
and Codex's own medium.

Since #950 the gateway sends such a member no reasoning ask at all
(withoutReasoningAsk, quiet.go), as it does a reasonless one (f074996d9)
and as it handles a member whose levels nothing knows (#597), so its
having no levels is no reason to take the others' away. groupEntries now
skips it like those two. The group's levels are those of its members
that think; Group.Levels and fixed-effort members are unchanged.

Tests: TestGroupQuietMemberKeepsCodexEffortControl builds the Codex
catalog (codexcat.Catalog(CodexListed())) for a group of a models.dev
reasoning:false model and one with levels, and wants the levels and
default (high, and max when config.toml asks max); TestGroupReasoningLevels
gains "quiet between". Both fail on the old group.go (levels [], default
""). TestGroupLevelsWithUnknownMember's "plain" group and
TestModelsListReasoning's group/auto-mixed encoded the old rule and now
want the thinking member's levels. docs/reference.md and
gateway-routing.md say the new rule.

Run (worktree on origin/main bda271999, private GOCACHE): gofmt -l clean;
go vet (darwin), GOOS=linux -tags nogui and GOOS=windows go vet of
internal/provider clean; go test -count=1 ./internal/provider
./internal/gateway ./internal/agent ./internal/codexcat ok.
Not tried: a real Codex session against the reporter's groups (their
config isn't known; a group with a non-thinking member is the case that
produces exactly what they describe).
2026-10-14 18:14:17 +08:00
yetone 778000326a gui: the sidebar sets off from rest and settles in a third of a second, as a Mac's does (wangye1644294 on X)
wangye1644294 (Windows, zh-CN, sidebar layout) found collapsing and
expanding the sidebar stiff. The morph ran .5s on cubic-bezier(.32,.72,0,1),
the spring the sidebar's lists open on. That curve leaves at speed: 8% of
the travel in the first frame, 92% by 184ms, then a 300ms creep. The frames
a webview drops as the view transition's pictures start to move (WebView2's
most) landed where the page moves most, and read as a jerk, followed by a
long tail.

The view-transition group, side-out and side-in animations now share
--morph-t (.32s) and --morph-ease (cubic-bezier(.42,0,.58,1), the Mac's
ease-in-ease-out). Largest per-frame step drops from 13.7% to 9% of the
travel, and the start, where frames drop, barely moves. End states,
reduced motion (no transition), Linux (no transition) and the 1500ms stuck
cut-off are unchanged. The other .32,.72,0,1 uses in app.js (lists, iOS
sheet, nav) are other animations and are left alone.

side-toggle.test.cjs now reads the running animations' computed timing:
the page, nav-usage group and side-out each last 250-350ms and their curve
starts from rest (x1>0, y1=0).

Measured (page card edge, 188px travel):
- Real WebView2 on the Windows box (Edge 155.0.4283.45, 125Hz, 1349x1128,
  DPR 1.1), 12 toggles each over CDP, a temporary build with
  AdditionalBrowserArgs (not committed):
  old: 63-67 frames over ~503ms, first step 7-8px, max step 14px, one 39px
       jump from frames dropped at the start
  new: 42-44 frames over 320-328ms, first step 0px, max step 9px, no long
       frames
- Mac, headed Chromium, ffmpeg avfoundation 60fps + mpdecimate, 3 rounds
  alternating:
  old: 25-27 changed frames over ~500ms, 4-7 gaps per toggle, first
       visible step 19-54px
  new: 14-20 changed frames over ~333ms, 0-5 gaps, first visible step
       4-18px (a busy shared desktop makes the gap counts noisy)

Run: side-toggle, side-width, header-centre in Chromium and WebKit, 44/44
pass (five languages; widths 1023 and 640 included). Broken by hand, each
red in the new test: the old .5s timing ("group(nav-usage) lasts 500ms"),
the old curve at .32s ("sets off from rest: cubic-bezier(0.32, 0.72, 0,
1)"), and side-out alone at .5s ("old(side) lasts 500ms").
No Go changed, so no gofmt/vet/go test. Not tried: the top-tab-bar layout
on Windows (it has no sidebar morph; covered by the existing tests), and
the reporter's own machine.
2026-10-14 18:10:48 +08:00
yetone bfef5d51b5 gui: Routing is back to v0.1.1231's layout; reverts dae2618ad (#1354)
v0.1.1233 shipped community PR #1354 (dae2618ad), which put "How the
last request was routed" in a right column beside the stage on wide
windows, split the context card into overview/contents columns, and
replaced the context card's own head with one lazily built disclosure
header. Two users on Discord asked for the old page back: wongxy
("这是哪个人才要改成这样的,丑死了", "UI方面的需求响应要克制一点", with a
screenshot of the new page) and molvqingtai ("v0.1.1231 没有这个问题").
The owner delegated the call: Routing goes back to v0.1.1231's look.

Only the lazy construction of the context body was a candidate to keep,
as it is invisible. It doesn't separate cleanly: it is built on the new
unified header (ctxSummary in the closed state, ctx-body/ctx-overview in
the open one), which is itself the visible change. So this reverts
dae2618ad whole: assets, its doc section, its README entry, the new
routing-context-layout test, and the test edits that existed only for
the new layout (wheel-scrolling to rows the right column pushed down,
mobile-web's skip of Routing in the pixel comparison). No later commit
on main is a follow-up of it.

Later commits touching the same files are kept: 20350dafa's subagent
reason in routing.js and README entry, a7a38193f/5fc2f87d1's gui-shell.md
lines, 00afcf97a's README entry. routing.css and context.js are now
byte-identical to v0.1.1231; routing.js differs only by later features
(#1068 folders, subagent reasons).

Run (worktree on origin/main 3ec45e715 + this revert):
- Routing page screenshots against v0.1.1231's assets with one counted
  request (the .rt card): Chromium and WebKit, en/zh/zh-TW/ja/de, 1100
  and 420 wide, plus 1440/1800 in en/zh: 0 pixels differ in all 28.
  origin/main differs in all of them (the folded header, the columns).
- node --test routing-*, panel-routing*, group-fold, held-animations,
  phone-rows, context-*: 1025 of 1034 pass. The 9 reds are
  routing-keys-fold's "a request that comes flies to the fold" (WebKit,
  and Chromium de) and routing-model-rest's "Try now" reach. Both files
  run alone fail the same way on origin/main bda271999 (12 fails there,
  11 here, different cases of model-rest each run), at load average
  ~350 from other sessions; filed as #1612 and #2115.
- mobile-web (pixel baseline) with BASE_REF=dae2618ad^: every phone
  case and Routing's desktop compare pass; the 8 reds are all Settings,
  changed since by #2073's colorblind switch, not by this.
- gofmt -l, go vet (darwin, linux nogui, windows) and
  go test -tags nogui ./internal/gui pass.
Not tried: the native Wails window; the complete GUI suite.
2026-10-14 18:07:59 +08:00
yetone 60fa582c80 gateway: a try is queued only for the time it stood in its lane's queue or waited for its minute, so a provider with no limit never reads as queued (#2153)
TestSentTellsMagpieFromEarlierTries failed on a loaded Mac with
"queued 1" for a provider with no MaxConcurrency and no MaxRPM. queued
was time.Since(waited) around the whole block: keepQueued's goroutine
starting, lanes.take, rpms.wait, and queuedAlive() waiting for that
goroutine to end. With no limit take returns at once, but starting and
stopping the keepalive goroutine on a busy machine took a millisecond,
and that read as a wait for a slot. Users saw the same: a 1ms "queued"
in a request's detail on a provider with no limit, taken out of
"In magpie".

lanes.take now answers how long it stood in the queue (0 on the fast
path, with no limit or a slot free), rpms.wait already answers how long
it waited for its minute, and queued is their sum. A lane wait that ends
in errQueueWait or the agent leaving still counts its time, which
laneMessage's "waited %.1fs" uses.

Reproduced by injecting a 3ms sleep at the end of keepQueued's stop
func: on the old code the test failed ("queued 7"); with the change it
passes with the sleep still in. The sleep is not committed.

Run: go test -tags nogui -count=1 ./internal/gateway/ (full package,
ok, 1833s on a machine at load ~220); gofmt; go vet darwin,
GOOS=linux -tags nogui, GOOS=windows. Not tried: -race on the full
package.
2026-10-14 17:58:41 +08:00
yetone 4faa931325 provider: Vertex AI's preset offers Gemini 4 Argon at global, and its test asks it at low (#2155, TomXPRIME)
Gemini 4 Argon went live on Vertex AI's global location on 2026-10-13
(gemini-4-argon), and the preset's fixed list (Vertex has no list to ask)
didn't have it, so a fetch never showed it. It is added to the preset's
models, which are global's; us, eu and the regions are left as they
answered on 2026-10-06, since nothing says Argon is served there (typed
in by hand it still goes).

Its metadata (1,048,576 context, 65,536 output, low/medium/high, $2/$10)
comes from models.dev's google-vertex entry, which lists it as of today,
so nothing is hard-coded here. The gateway already tells Gemini 4 a
thinking level at the level asked (52be997b3, #2083), medium as medium.

The model test (vertexTest) only told gemini-3* a thinking level; Argon
got none, so it would think at its default medium against a 16-token
budget. It is now told low like every Gemini 3 and later
(vertexGeneration), and an id naming no generation (gemini-flash-latest)
still gets none.

Run: go test -tags nogui ./internal/provider/ (full package, ok);
TestVertexTestRequest goes red on the old gemini-3 prefix check with the
new argon row; gofmt; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
Not tried: a real Vertex AI project (no Google Cloud credentials here).
2026-10-14 17:44:03 +08:00
yetone 50929661fe provider: a moved Devin gets plugin 0.1.16, where SWE-2 isn't held by a used-up quota
太陽と向日葵 on magpie's Discord: SWE-2 is free, but with the Devin
account's quota used up magpie said so and didn't route SWE-2 to it,
while a model test worked. The plugin's "1 day" and "7 days" windows
named no models, so a full window held the account for every model.
@magpie-community/opencode-devin-auth 0.1.16 (plugins cff78b3) reads
Devin's model_cost_tier from GetCliModelConfigs: SWE-2's variants are its
Free tier, the only ones of 262. It gives the day and week windows
notModels with their ids (quotaOfPlugin's idSet then leaves them out) and
lists them free: true (catalog Free, so PaidBesideFree rests only a paid
model on a quota refusal). Raising the mover's min updates moved users.

Run: gofmt -l; go vet for darwin, GOOS=linux -tags nogui and
GOOS=windows on internal/provider; go test -timeout 30m ./internal/provider
in a sandbox HOME, ok in 691s (the default 10m timed out at load average
~300, other sessions' test binaries running). npm view
@magpie-community/opencode-devin-auth@0.1.16 --registry
https://registry.npmjs.org --prefer-online returns 0.1.16. Not tried: an
account with its quota really used up, nor the moved plugin end to end
through a gateway.
2026-10-14 17:40:07 +08:00
yetone 7d4ad7c628 gui: the menu bar's total is every token, cache too, marked Σ, as the Requests tab sums it (NextCommit)
NextCommit on Discord: the menu bar's usage showed only input tokens, and
more input than the Usage page. It showed input + output, unlabelled, so
it read as the input and came out above the page's input. And it was summed
as the Overview sums (usage.SummarizeTop: the gateway's calls only, cache
aside), while a click opens the panel's Usage tab, which sums the ledger
(the agents' own session-file calls too) and counts the cache's tokens
in its Tokens. Two numbers under one name.

- trayTotalSum is the ledger's cached sum, usage.QueryPage(p, {}, 0, 1).Sum,
  the one the panel's Usage tab and the window's Requests tab show.
- The cell's top row is every token (in + out + cache read + write, as
  allTokens) prefixed Σ; the cost stays under it. The tooltip spells out
  "N tokens (a in · b out · c cached)".
- With the window as the tray's, a click opens the Requests tab at the
  period (quotaView), not the Overview, which sums differently.
- docs/reference.md and gui-shell.md say so.

Run:
- TestTrayTotalIsTheLedgers (new): a Codex session-file call of 1000 in,
  200 out, 8000 cache read; the menu bar's sum equals ledgerPage's and the
  cell reads Σ9.2K. With trayTotalSum put back to SummarizeTop it fails
  (menu bar all zeros, ledger 1 call).
- TestTrayTotals/BesideCards updated for Σ, the cache and tab=requests.
- go test -tags nogui ./internal/gui (sandbox HOME via the package): ok.
- tray-totals, tray-usages, tray-cell-click .test.cjs, chromium and
  webkit, five languages, 1100 and 420: 70 pass.
- The Mac cell rendered with trayImagePNG and looked at: "Σ6.3M" over
  "$3.40", "Σ47M" alone, both inside the row width.
- gofmt -l, go vet darwin, GOOS=linux -tags nogui, GOOS=windows; builds.
Not tried: the real menu bar on the reporter's data.
2026-10-14 17:29:43 +08:00
yetone bda271999f gui: the desktop window saving an allow list is this computer, not 192.0.2.1 (Mathresearcher)
Settings › Allowed addresses in the desktop app refused a list with "that
allow list would shut out 192.0.2.1, the address this page is open from"
(Mathresearcher on Discord). The window's requests reach the API through
Wails' asset server, which has no peer address and fills in
192.0.2.1:1234 (TEST-NET-1; assetserver_webview.go in wails v3
beta.24). KeepsOut took that for the page's address. The asset handler
handed to Wails is now wrapped in ownWindow, which marks its requests as
loopback: only the webview reaches it, never the network. magpie web
(web.go, AllowGuard) is unchanged and still judges the real peer.

Run:
- TestAllowIPsFromTheAppWindow (new): posts ["10.0.0.0/8"] with
  RemoteAddr 192.0.2.1:1234 through ownWindow(Handler). With ownWindow's
  rewrite taken out it fails (refused, saved []); with it, passes.
- go test -tags nogui -run TestAllowIPs ./internal/gui: ok.
- gofmt -l, go vet (darwin), GOOS=linux -tags nogui and GOOS=windows vet
  of internal/gui and internal/gateway; go build for all three.
Not tried: saving the list in a real desktop window (not launched).
2026-10-14 17:00:34 +08:00
yetone 3ec45e7155 gateway: a json_schema an upstream turns away is asked for as a JSON object, the schema in the system prompt, before the format is told in words alone (#2126)
klarkxy's Codex on Xiaomi MiMo's Token Plan got back "text.format type
'json_schema' is not supported, only 'text' and 'json_object' are
supported" and the turn ended there. Codex's /responses reaches the
upstream by passthrough when the protocols match, and passthrough never
looked at a format refusal; the translated path did, but only by moving
the whole format into the system prompt, which drops the object
requirement the vendor would have kept.

Now, on either path, a json_schema the upstream turns away is asked
again as {"type":"json_object"} with the schema appended to the system
prompt (Responses instructions, Chat's first system/developer message,
Anthropic system). If json_object is turned away too, the format field
goes and only the words stay. Each step is remembered per provider,
model and protocol once a request with it is taken, so later turns go
out already rewritten. Anthropic's output_config.format has no object
mode, so it goes straight to words. DeepSeek, which takes json_object
only, gains the same middle step on the translated path.

Run:
- format_refused_test.go, new:
  - TestPassthroughSchemaRefusedAskedAsObject replays the reporter's
    exact error and probe body through /backend-api/codex/responses.
    It covers object taken (2 asks, then json_object) and object refused
    too (3 asks, then no format). Turn 2 is checked to take 1 ask, the
    instructions to keep "You are Codex." first, and the input to be
    unchanged.
  - TestPassthroughFormatRefusedChatAndAnthropic.
- TestRefusedFormatToldInWords was rewritten for both outcomes on the
  translated path.
- Break check: with the old gateway.go, the passthrough test gets back
  the reporter's exact error.
- gofmt -l is clean. go vet passes for darwin, GOOS=linux -tags nogui
  and GOOS=windows. go test ./internal/gateway/ -count=1 is ok (1017s).

Not tried: a real Xiaomi MiMo key (none here; the error envelope is
assumed to be OpenAI's), and Gemini passthrough, which has no rewrite.
2026-10-14 16:42:56 +08:00
yetone 3e812ebde4 gateway: a provider that refuses a tool_result holding only tool_reference blocks gets them said as text too (#2124)
OpenDesign's Anthropic-compatible endpoint answers 422 "messages[4]:
missing field `content`" when a ToolSearch result carries only
tool_reference blocks, so every Claude Code turn after a deferred tool
loaded failed there.

The fix is a learned shape, scoped to the provider that refuses it, like
the deferred-tools one: refuseShapes marks shapeRefsOnly when a 400/422
says "missing field `content`" and the request held such a result, and
withoutRefusedShapes then puts a text block ("Tool X is loaded and can be
called now.") before the references in each refs-only tool_result,
keeping the references. Every Anthropic upstream route goes through
forward/forwardOnce, so /v1/messages, count_tokens and a group's member
all get it; a provider that takes the references unchanged never sees the
text. Requests translated to another API already rendered a reference as
text in stringOrText; it now uses the same sentence (toolLoadedText).

Run:
- TestRefsOnlyToolResultRefusedGetsText (fake vendor answering the
  reporter's 422 bytes, body from the reporter's repro.json): first ask
  refused, retried with the text; group member and count_tokens get it at
  once afterwards; a provider that takes them sees bare references.
- TestRefsSaidLeavesOtherResults: other results unchanged, two refs.
- Break checks: with the mark off, and with the mend off, the test fails
  with "status 422 ... missing field `content`".
- go test -tags nogui ./internal/gateway/ -count=1: ok (1069s, loaded
  machine; a first run with the default 10m timeout timed out under load).
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.

Not tried: the real OpenDesign endpoint (no key); the fake follows the
reporter's own curl evidence.
2026-10-14 16:42:47 +08:00
yetone 54a2b0d05f gui: a provider kept for its usage alone is one click, Usage only, and its card says so (#2068, keleus)
keleus wanted a subscription's quota in the status bar without anything
routed to it. That has existed since #1818 (noModels), but getting there
took Picked only, then Select none, then Save, and the card then just said
"no models exposed". The models' serves control now has a third option,
Usage only: no picks, noModels on, nothing routed, balance and usage still
read, models the vendor lists later not added. The card's line says
"usage only" for such a provider. Picked only with none picked used to be
the same state under another name; it now starts from the models the
vendor's list serves (the dashed ones), so each of the three options is a
state of its own. Unpicking the last pick still leaves none (#1831),
which now reads as Usage only. Strings in en, zh, zh-TW, ja, de; the old
Picked only tooltip's second half moved to Usage only's.

Decision (owner delegated product calls): name the state rather than
document the path; the backend, CLI (`magpie provider models <id> none`)
and saved files are unchanged.

Run: provider-none-picked.test.cjs and i18n-keys.test.cjs, Chromium and
WebKit, 5 languages, 1100 and 420 wide: 33/33. With app.js put back,
provider-none-picked fails ("+ 'Picked only' - 'Usage only'"). The test's
saved-as-none fixture now has its models off, as /api/providers sends them
(Exposed is empty for it). No Go changed. Not run: the whole GUI suite
(no shared selector or API added).
2026-10-14 16:42:39 +08:00
yetone 1a5128747b cli: magpie provider refresh-every and auto-include set a list's schedule and rules (#2135)
`magpie provider refresh-every <id> 6h|1d|off` and
`magpie provider auto-include <id> 'gpt-*' 're:claude-.*'|none` set the
fields the previous commit added; `magpie provider <id>` shows them, and
`magpie provider refresh` prints the models its rules took.

TestRefreshEveryAndAutoIncludeCmds: a too-short or unreadable time and
a plain id as a rule are refused, the rule takes the current matches,
and none/off clear both while keeping the picks. Run with the go test
in the previous commit's body.
2026-10-14 16:40:24 +08:00