Commit Graph
3391 Commits
Author SHA1 Message Date
yetone f5083e8041 gui: a gateway key's account menu says a provider none of whose accounts is picked is used, and how to keep the key off it (#2077, KKKKKKKEM)
A key held to some accounts (#905) is held to the accounts of the
providers its list names; a provider it names none of is used on every
account. The menu showed that provider's accounts unticked like any
other, so the reporter unticked every Codex account, ticked the rest,
and was surprised that the key's remote magpie still listed and served
Codex's models.

The rule stays as #905 set it (a key held to one Codex seat keeps its
other providers). The menu now notes each account of such a provider
"Used: no <provider> account is picked", and the badge's tooltip says a
key is kept off a provider by picking only other providers' models.
en, zh, zh-TW, ja, de.

Verified:
- gateway-key-accounts.test.cjs (chromium + webkit, en + zh) checks the
  note on OpenAI's key under a key held to a Relay account, Relay's
  unpicked account still noting its provider, the tooltip, and a key
  held to no account showing neither. With the old keys.js it fails:
  expected 'Used: no OpenAI account is picked', actual 'OpenAI' (and
  the zh equivalent).
- gateway-key-*, gateway-keys-off, i18n-keys, gui-zh-tw, gui-ja, gui-de
  in chromium and webkit: 62/62.
- The menu at 420px in German (chromium) and Chinese (webkit): no
  horizontal overflow, the note wraps inside the menu.

Not run: the whole GUI suite.
2026-10-14 15:33:27 +08:00
yetone d53a51cdfe gateway: the key's own limit on a remote magpie still rests the whole remote, and #2077's case is tested across two gateways (#2077, KKKKKKKEM)
#2077: server B used server A's magpie as a Remote magpie provider. A's
Claude Code hit its session limit and answered 429; B rested its one
key to A until the reset, so a request for A's Qoder model was refused
on B with Claude Code's 429 ("... (out of its allowance: not asked
again before 10:55)") and never asked of A.

caa536733 (bigsteven on Discord) landed the same fix while this was
being written: remoteModelRest rests only the model on a remote's
quota, credit or rate refusal. This adds what it left:

- A's refusal of the key itself (keyLimited's 429 for the gateway key's
  own budget) refuses every model alike, so it still rests the whole
  remote. keyLimited now marks it with X-Magpie-Limit-Reset
  (remoteKeyLimitHeader), and remoteModelRest takes the response header.
- TestRemoteMagpieRestsTheModel: the reporter's case end to end, a
  real gateway handler as A over HTTP with a Claude Code provider
  answering the reporter's 429 and a Qoder one answering 200, a Remote
  magpie on B fetched from it. Qoder answers after Claude Code's 429,
  and Claude Code is then held on B without asking A. On the code
  before caa536733 it failed with the reporter's exact text.
- TestRemoteMagpieKeyLimitRestsTheKey: goes red with the header check
  taken out (checked by hand).

Run:
- gofmt -l clean; go vet ./internal/gateway on darwin (nogui),
  GOOS=linux -tags nogui, GOOS=windows.
- go test -tags nogui ./internal/gateway -run
  'Rest|Rate|Quota|Remote|KeyLimit|Fallback|Held' on the rebased tree:
  ok. The whole package (go test -tags nogui ./internal/gateway, 1939s
  under load) was green on this change before rebasing onto
  caa536733; not rerun whole after.

Not tried: two built magpie binaries on two machines, or a real Claude
Code account out of its limit.
2026-10-14 15:33:27 +08:00
Ha1baraA1 c8b4ac7755 fix(catalog): honor models.dev reasoning toggles (#1294)
* catalog: honor reasoning toggles as off effort

Include none when models.dev reports both a reasoning toggle and effort levels. Keep toggle-only entries level-less, and leave effort-only entries unchanged.

Validation: go test ./... with GOFLAGS=-tags=nogui; all packages pass. The new catalog regression failed before the fix and passes after it. No vendor API request was made locally.

* catalog: limit reasoning off to DeepSeek

* catalog: include verified Kimi reasoning toggles

* fix(catalog): keep off effort provider scoped
2026-10-14 15:30:43 +08:00
july_lu b6e82c6c5c gateway tests: a Chat client's reply translated from Anthropic's Messages streams as the vendor sends it — the first chunk when its first event comes, each word as it is written, never the whole reply held to the stream's end — and now a test holds it to that. A reporter's OpenAI-format client on Z.ai's GLM saw the opposite for a while (every event of a reply in one burst once the stream ended, while the same provider's Messages replies streamed fine), and it measured out to be the vendor's doing, not the gateway's: the reporter's own request bodies, replayed at full size against the vendor's chat and Messages endpoints through the gateway's build and beside it, streamed both ways on the day. Nothing locked the translation's pacing, though, so a future hold would read as the vendor's again. TestChatFromAnthropicStreamsAsItComes paces a Messages upstream at 200ms a word — glm-5.3 at an Anthropic-only provider, and a Claude model where Chat and Anthropic URLs both sit, which the Messages redirect takes there anyway — and wants the client's first chunk before the upstream has written its last word (relative to the upstream, not the wall clock, so a loaded runner's setup time is not held against it), at least two of the five pauses reaching it, and one ask on /v1/messages; holding every event of the chat encoder until finish (as the report read) fails it on both branches with the first chunk at the stream's end. And the keepalive table that walks every protocol's quiet stream (TestQuietStreamsKeptAliveEveryProtocol) had responses, anthropic, chat and anthropic from chat; chat from anthropic, the path a chat client on a Messages-only provider takes, was the row missing, and it keeps alive the same as the rest. go test -race -count=2 on the two tests, go vet and the nogui build pass. (#1310) 2026-10-14 15:28:27 +08:00
Zhu Wang dae2618ade gui: make the Routing context lazy and align wide cards (#1354)
* gui: make the Routing context lazy and align wide cards (#1354)

Rebuild the context and wide-layout change on main e1b70c13 following
the Oct 13 review. Keep the complete request story, original heading,
visible stage caption and main's unchanged line/logo retention.

Use one context header, construct its body only while open, migrate the
existing fold choice and retain live card updates and the text viewer.
Align the stage/story and overview/contents splits within the page's
existing width cap. Keep the narrow stage sizing and prevent flex shrink
from moving the header when context contents appear.

Three-platform vet and builds and the sandboxed nogui suite passed.
Base assets fail the new context test because a closed card constructs
the detail grid (1 instead of 0). Focused disclosure checks passed;
the complete GUI suite is still running and is tracked in the PR body.

* gui tests: exercise the new Routing layout with user scrolling

Open the lazy context explicitly for its retained-animation check and wait for page entrance animations as well as cells. Reach the group Cancel button and history day with user wheel input rather than relying on forbidden click scrolling. Until the baseline contains the new Routing wrapper, keep its intentional desktop layout out of the unchanged-page pixel comparison; the focused layout matrix covers it and mobile fit still checks Routing.

Validation: group-fold and held-animations passed all 8 cases; phone-rows passed all 10 cases across five languages and both engines; mobile-web passed all 30 cases. git diff --check and JavaScript syntax passed. The complete GUI suite is still being recorded on unchanged d6d5738a assets. Library switch failures are independently reproduced on e1b70c13 assets and tracked by upstream #1609; they are not claimed as passing.

* gui tests: scroll to narrow Routing history before selecting it

The visible full request story can leave a historical request below a narrow window. Reach the day and request row with wheel input before selecting them, while retaining the app scroll guard and all cancellation and failure-colour assertions.

Validation: all 37 checks in routing-agent-gone and routing-agent-hue-not-red pass across both engines, four/five languages and 420/1100px widths. The whole GUI run had exposed the two WebKit German 420px click-scroll failures. git diff --check and JavaScript syntax passed.

* gui: keep context disclosure usable while the next prompt is read

Keep the last available live prompt separately from the render key. Opening or closing the unified header can redraw that carried context while a new request has no prompt yet; clearing a render key for a disclosure no longer removes the entire card. Explicitly picked requests still start fresh, and unavailable or completed requests clear the carried data.

Validation: before the fix, the new pending-prompt disclosure regression fails because the carried context becomes invisible. After the fix, all 134 context disclosure, saved-choice, Usage-link, live patch, every-frame and provider-logo checks pass in Chromium and WebKit across five languages and desktop/phone widths. Native macOS, Linux nogui and Windows builds, syntax and git diff --check pass. The complete GUI run is recorded separately with unresolved existing failures linked in the PR description.
2026-10-14 15:27:59 +08:00
yetoneandfchengyan 62378c5f84 cli, usage: magpie usage takes --last <dur> and --days <n>, a window ending now, with or without --csv and --account (#2075, tinysnake, fcy222fcy)
today, 7d and 30d begin at a local midnight, so a caller wanting "the
last few hours" just after midnight had to take 7d's CSV, seven days of
rows for one. `magpie usage [--csv [--account <name>]] --last 24h` (any
Go duration, 90m) or `--days 1.5` now reads a window that began that
long ago; the presets are unchanged.

From fcy222fcy's branch (usage-rolling-window, 60472c661): a rolling
window is a period "last:<dur>" (usage.LastOf / Period.Last) that Since,
Known, shown and the chart's timeline answer for, so the ledger, Direct
and the summary read the same window.

Review fixes on top:
- a summary of a rolling window is worked out each time, like a picked
  range: kept, its start didn't move with the clock while the log
  stayed the same (reachable through the web API's ?period=last:24h);
- the CSV export's file name has no colon from "last:24h0m0s", which
  Windows refuses;
- `--last 24h 7d` is refused rather than silently taking --last;
- --days refuses NaN, Inf and over a century;
- the help line and docs/reference.md name the flags.

Run: new TestRollingWindowIsNotKeptStale fails with the cache fix taken
out ("an hour later: 1 calls, want 0"); TestCSVStamp fails without the
colon fix ("magpie-requests-last:24h0m0s-2026-09-30");
TestUsageRollingWindowRejectsJunk fails without the preset/--days
checks; TestUsageRollingWindow and the new ...WithAccount fail (3 rows,
want 2) with Since moved back. go test -tags nogui ./internal/usage/...
./internal/cli/... ./internal/usageapi/... ./internal/gui/... in a
sandbox HOME: ok. gofmt -l clean; go vet darwin, GOOS=linux -tags nogui,
GOOS=windows; go build darwin, linux nogui, windows.
Real use: the built binary on a sandbox HOME with a generated 50,000-call
7-day usage.jsonl: --csv 7d 47,233 rows / 6.97 MB; today 4,376; --last
24h 7,140 / 1.05 MB; --last 90m 444; --days 1.5 10,712; --account me@x
--last 24h 3,570 (that account's half); oldest row of each at the
window's start.
Not tried: the full go test ./... suite; the process still parses the
whole usage.jsonl into its in-memory index on each run (as every period
does), so the cut is in rows decoded and written, not bytes read.

Co-authored-by: fchengyan <3181088318@qq.com>
2026-10-14 15:26:28 +08:00
yetone 0ad9661b60 agent: a Max output the user set reaches VS Code, Copilot JetBrains, ZCode, WorkBuddy and CodeBuddy as set (#2064)
DeepSeek V4.1 Flash with Max output 384k set in magpie reached VS Code
as 250000 (its context/4 trim) and WorkBuddy, CodeBuddy and ZCode as
128000 (zcodeOutput), so the number typed in magpie looked ignored.
Those trims are for a vendor's figure; a value the user set
(settings ModelOutputs, per model or per provider) is now carried as
provider.Entry.OutputSet -> catalog.Model.OutputSet, and outputOr hands
it on as it is (still within the window, as maxTokens keeps it). A
model nothing was set on gets the same numbers as before.

buddyModel no longer trims inside: the trim moved to its caller with
the others, so TestWorkBuddyEfforts' direct call now sees 500000.

Run: gofmt -l (clean); go vet for darwin, GOOS=linux -tags nogui and
GOOS=windows ./... (clean); go test -tags nogui ./internal/agent/
(-timeout 40m under load 200+; the first run hit the default 10m),
./internal/provider/ ./internal/catalog/ ./internal/gui/
./internal/codexcat/, all ok. New TestAgentsTakeTheUsersMaxOutput
checks every agent's written file with nothing set (old numbers) and
with 384000 set on the provider; with outputOr reverted it fails
("384k set, vscode-oai-in: 750000").

Not tried: real VS Code, CodeBuddy, WorkBuddy and ZCode reading the
files; whether Command Code's API serves max_tokens over 200000 (the
probe key was refused, UNAUTHORIZED).
2026-10-14 15:23:05 +08:00
yetone 9f8ad6edb8 gateway: the model's text between a batch's tool calls goes ahead of the batch's first call, so OpenCode Go stops answering "No tool output found" (#2100, eugene1003)
What: joinToolRuns (responses.go), which mends a relayed Responses
request's tool runs in attempt before every destination, now moves an
assistant message the model wrote between its own calls, before the run's
first result, to just ahead of the run's first call, together with the
reasoning items right before it (so a reasoning item keeps the item that
followed it). The reporter's Codex rollout was
[text, call_A, text, call_B, out_A, out_B]; it reaches the upstream as
[text, text, call_A, call_B, out_A, out_B]. Reasoning alone between calls,
hosted calls and anything carrying a call_id stay where they were (#1752's
review note), and V2 (text after out_A, between whole exchanges) and V3
(calls together) go byte for byte.

Why: magpie relays deepseek-v4.1-flash at OpenCode Go to its /responses
(models.dev names no SDK for it, so every API may be tried, and #1822's
turn shows Go's DeepSeek answering there). Go builds a chat form in which
an assistant message after a call opens a new assistant message, so the
first one's tool_calls were followed by no tool message: 400 "No tool
output found for tool call call_aaaa1111" - the same text joinToolRuns'
comment already lists for Go. The translation to a Chat upstream was
already right on main (joinSplitCalls + mergeTurns join the step into one
assistant message); TestTextBetweenABatchsCallsStaysInItsStep now guards
it with the reporter's shape. Native ChatGPT sign-ins don't go through
joinToolRuns. Moved plugins get the relayed body after attempt, so they
get the change too; no plugin translator was touched.

Run:
- TestRelayedTextBetweenABatchsCallsIsAnswered (V1-V4, fake upstream that
  checks the exchange as Go does) and the new TestJoinToolRunsOnlyMoves...
  cases fail on origin/main 2fbbd1694 with the fix stashed: V1 and V4
  "status 400: Fake: No tool output found for tool call call_aaaa1111",
  and got [function_call:a function_call:b message: ...] want
  [message: function_call:a ...]; pass with it.
- gofmt -l clean; go vet ./internal/gateway (darwin), GOOS=linux -tags
  nogui, GOOS=windows: clean.
- go test -tags nogui ./internal/gateway/... under a scratch HOME with
  pinned caches: ok (2011s at load ~230; a first run with the default
  10m -timeout was killed by the timeout under that load, not a failure).
Not tried: the real OpenCode Go. The key on this machine answers "This Go
model requires Global regions" / "An active OpenCode Go subscription is
required" for every Go model, and Zen's free tier refuses non-OpenCode
clients, so the fix rests on the reporter's V1-V4 table and the fake.
2026-10-14 15:20:24 +08:00
yetone fbb7e2cbd4 gui, update: Settings' Restart automatically restarts into a downloaded update once no agent request is in flight (#2096, xiaozhu1337)
#2096 asks for a setting that installs and restarts whenever an update is
there. Settings > About gets "Restart automatically" (Off/On), off by
default: a restart ends the window, and whatever an agent sends during it
waits for the gateway to come back.

When on, and Automatic updates is on, the updater's minute loop sees a
"ready" update and starts the same idle wait the Install-when-idle button
uses (waitIdle: 10s with nothing in flight, at most 1h). Cancelling that
wait from the GUI skips that version, so the next one is restarted into
again. The app (window or tray) and `magpie web` are covered; serve and
daemon have no in-process updater and are not. On the Mac, a restart the
app made by itself reopens to the menu bar icon only (`open … --args tray`)
when no window was shown, rather than popping a window up unasked
(update.Relaunch takes a window flag; relaunchOpen builds the command).
With Automatic updates off the row is dimmed and reads "While automatic
updates are on", like Check every.

Run:
- go test: internal/gui (-tags nogui, full package, 273s), internal/update,
  internal/settings, internal/cli — ok, with set -o pipefail.
- New: TestAutoRestartWaitsForIdle, TestAutoRestartNeedsAReadyUpdate,
  TestAutoRestartCalledOff, TestRelaunchOpen.
- Broken by hand: without autoTick, WaitsForIdle and CalledOff fail;
  without the autoSkip assignment, CalledOff fails; restarting without
  the idle wait fails WaitsForIdle and CalledOff; without prefsKeep's
  autoRestart, update-restart.test.cjs fails 11 of 11.
- gofmt -l clean; go vet and go build for darwin, GOOS=linux -tags nogui
  and GOOS=windows on internal/gui, update, settings, cli.
- GUI: new update-restart.test.cjs, chromium and webkit, 1100 and 420,
  en/zh/zh-TW/ja/de (22 pass, twice); update-*, i18n-keys and settings*
  in both engines: 253 pass, 0 fail.
- Found on the way, filed as #2134: in WebKit at 420, turning Automatic
  updates off scrolls a view at its top by ~2px (the Version row's sub
  grows). The test checks the clicked control holds still instead.

Not tried: a real update or relaunch (no real install was touched), the
tray-only reopen on a real bundle, Windows/Linux restarts by hand.
2026-10-14 15:19:14 +08:00
yetone 114509426f provider: a moved Factory updates to plugin 0.1.26, Gemini's route and a 413 said as Factory's byte limit (#2080, #2082)
@magpie-community/opencode-factory-auth 0.1.26 (published, npm latest):
- Gemini 4 Argon and Gemini 3.x on Factory's /api/llm/g/v1/generate,
  as the built-in sends them (#2080; plugins 60c9054).
- on a 413 from Factory, the request asked once more with every image
  and file but the newest left out, tool results kept beside their
  calls; failing that, an error saying it is Factory's limit on the
  body's bytes, not the context, with the gateway's 413 hint
  (#2082; plugins 1bd6d17).

Unmoved users: the gateway already adds the same byte-limit hint to any
413 and fails a routing group over to the next member.

Run: npm view @magpie-community/opencode-factory-auth@0.1.26 version
(0.1.26); go test ./internal/provider ./internal/gateway -count=1 (ok);
vet on darwin, linux (nogui) and windows. Not tried: a real Factory
account.
2026-10-14 15:17:06 +08:00
yetone d5b1c95c4f provider: the built-in Factory offers Gemini 4 Argon, as droid 0.241.1 does (#2080)
droid 0.241.1's picker has Gemini 4 Argon (provider google, 1M total
context, 65536 output, low/medium/high, images); the built-in's table
stopped at Gemini 3.1 Pro. It goes to /api/llm/g like the other Gemini
models. In droid it is behind a Factory feature flag (Gemini4Argon,
unreleased), so an account it isn't on for may be refused it.

TestFactoryDroid0241Gemini reads droid 0.241.1's picker and Gemini
entries (testdata, byte for byte from @factory/cli-darwin-arm64@0.241.1
bin/droid, the same fixture as the plugin's) and checks every Gemini
model there is offered with droid's name, limits, efforts and images,
on Gemini, in standard's pool.

Moved users get it from plugin 0.1.26 (the next commit raises the
mover's min).

Run: gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on
internal/provider and internal/gateway; go test ./internal/provider
./internal/gateway -count=1 (ok, under load average ~260). Broken by
hand: without the row the new test fails. Not tried: a real Factory
account (none here).
2026-10-14 15:17:06 +08:00
yetone c19a8d13a9 gui: an import's results offer Import more… beside Done, so the next batch needs no Done first (#2131, ump45nose)
After an import (Antigravity's, ChatGPT's or any importable
subscription's), the results box only offered Done, and the
"Import accounts from a file…" row stayed hidden until it was clicked.
The box now has Import more… (primary) beside Done; it opens an empty
import box for the next batch. Done still closes the results.
renderLoginImport is the one place every importable subscription's
results are drawn, so this covers all of them.

Verified:
- login-import.test.cjs, chromium + webkit, en + zh: new check that the
  results box has the button, it opens an empty box with no old
  results, a second import posts again, and Done closes it. With the
  app.js change reverted it fails in webkit en and zh with "no way to
  import again beside the results, only Done".
- The same test run ad hoc in zh-TW, ja and de at 420px (no sideways
  scroll), chromium + webkit: pass.
- i18n-keys.test.cjs: pass.
- The machine was at load ~280: chromium runs with the test's 5s click
  timeout timed out on clicks both new and old (the Cancel click at
  line 121, unchanged code) in 2 of 4 runs; with a 30s timeout both
  languages pass. Not filed as a test bug: it is the host's load.
- Not tried: the real app with a real Antigravity export.
2026-10-14 15:16:10 +08:00
yetone 258b4ff1ff gui: Settings › Images says where the Magpie Image tool comes from, turns the Library on, or opens its sheet (#2091, nailuoGG)
Under the Essentials preset the Library is switched off and leaves the
window, but Image generation's row still sent people to "Library → MCP
servers → Discover → Magpie Image", a page that wasn't there.

- The row's words follow the state: with the Library off it says the
  Library is turned off in Plugins › Built-in and offers "Turn on the
  Library", which flips the same built-in switch (plugins/builtin) and
  brings the page back; with it on, "Give agents Magpie Image…" opens the
  Library on MCP servers with Magpie Image's sheet up, to pick agents.
  One already in the library opens the tab with nothing over it.
- Gateway mode (no Library) and Image generation Off offer no button.
- The Library plugin page gets a `server(name)` hook (magpie.call), which
  waits for the read its open started before looking the item up.
- The row's sub wraps instead of ellipsizing; strings in zh, zh-TW, ja, de.

Run: new images-library-way.test.cjs (en, zh, zh-TW, ja, de; 1100 and
420; Chromium 31/31, WebKit 31/31), red against the old app.js. Related
suites in both engines (i18n-keys, builtins, images-*, library-*,
market-*, settings-search, settings-sections, gateway-mode, click-scroll):
345/345 each. go test ./internal/gui: all pass but TestMainWindowCorners,
killed at its 40s deadline (load average ~270); it fails the same on
origin/main caa536733 run alone, filed as #1936.
Not tried: a real build with the Essentials preset; the API is faked.
2026-10-14 15:10:32 +08:00
yetone 11b1fb1db7 cli: magpie quota refresh <provider> [<account>] reads that card again, as its refresh button does (#2104)
magpie quota refresh <provider> [<account>] [--json] runs the Usage card's
refresh (RefreshUsage's path) from a terminal and prints that card alone;
no other vendor is asked. provider.RefreshReport returns the read's own
cards (refreshCards, shared with RefreshUsage), since a fresh process's
caches don't hold a partial read's subscription and plan cards. A second
refresh of the same card within 30s asks nobody and prints the kept
reading, saying so on stderr; the times live in the cache dir's
quota-refresh.json, so the gap holds across processes. --json prints
magpie quota --json's shape, with readAt and error. The account may be a
login, an alias or <provider>/<account>.

Run:
- go test -tags nogui ./internal/cli ./internal/provider ./internal/tui:
  ok (provider 591s under load ~200; an earlier run hit the 600s default
  timeout, the rerun with -timeout 25m passed)
- TestQuotaRefreshReadsOneCard / TestQuotaRefreshGapPerCard; with the gap
  check disabled by hand the first goes red ("asked a 2 times")
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on the
  three packages
- the built binary in a sandbox HOME (MAGPIE_ADDR=127.0.0.1:47614) against
  a local fake balance endpoint: refresh free-relay showed 12.50; a second
  run at once didn't hit the endpoint and said so; after 31s it read 11.00;
  "Free Relay" resolved by name; --json carried readAt, and a 404 gave
  "error": "404 Not Found"; an unknown provider exits 1.

Not tried: a real subscription (Codex, Claude) or a remote magpie's cards.
Reading from the caches instead of RefreshReport doesn't turn the test red
for a key balance (its cache holds the read in-process); the subscription
path that needs it is covered by reading only, not by a test.
2026-10-14 15:02:15 +08:00
yetone d593e80f36 tui: a provider's models view fetches its list again with ctrl+r, and shows what came (#2113, huadi)
Over SSH the TUI is where magpie is set up, and OpenCode Zen's or Kilo's
free models change often. m on the providers list already asked the
vendor again, but the models view the reporter looks at (providers ›
<provider> › models) had no way to: its keys go to the filter. ctrl+r
there now runs the same refetch (refetchCmd, the app editor's Fetch
models), the footer names it, and the list open is drawn again from what
came (a flash now relists an open models picker, modelsChanged). The
view doesn't fetch by itself on entry: a fetch can drop picks gone from
the vendor's list, which looking at the list shouldn't do.

Run:
- go test -tags nogui ./internal/tui: ok. TestTUIFetchesAProvidersModels
  now opens the models view, grows the fake vendor's list, presses ctrl+r
  and checks the new model is listed and a typed key still filters.
  Fails without the change: with pages.go reverted, "the models view
  doesn't offer ctrl+r"; with the flash not relisting, "the models view
  doesn't list what ctrl+r fetched".
- gofmt -l, go vet (darwin), GOOS=linux go vet -tags nogui, GOOS=windows
  go vet on ./internal/tui: clean.
- Real use: the built nogui binary under a sandbox HOME, a custom
  provider at a local fake /v1/models, magpie tui in tmux: Enter on the
  provider, the list grown on the fake, ctrl+r: "Free Relay: 3 models
  from its list · 3 for agents" and the third model listed.
Not tried: OpenCode Zen or Kilo themselves (the refetch path is the
existing m key's, unchanged).
2026-10-14 15:02:14 +08:00
yetoneandNeuroPaw 5654c8187c agent: while Claude Desktop is on magpie, Explore inherits Desktop's mythos-magpie model instead of being capped to Opus (#2087, NeuroPaw)
Claude Desktop lists models with effort levels as mythos-magpie-* so its
effort picker shows. Claude Code 2.1.295's built-in Explore (model:
"inherit") caps its inherited model at Opus when the session model's family
ranks above Opus (pge/BHn: {inheritCap:"opus"}), so an Explore with no model
of its own went to Desktop's Opus default, a different route. Claude Code
skips that cap when CLAUDE_CODE_DISABLE_EXPLORE_INHERIT_CAP is set.

magpie now writes CLAUDE_CODE_DISABLE_EXPLORE_INHERIT_CAP="1" into Claude
Code's settings env while this machine's Desktop is on magpie (writeExplore
in claudeIn: Desktop alone, model picks and Sync), and removes it when
Desktop is taken off, only if it is still magpie's own "1". A value the user
had (an empty one too) or changed later stays. The stash key
claude.explore_inherit_cap marks magpie's value. WSL twins don't get it.

Checked in the installed Claude Code 2.1.295 binary (read only): the env is
read in pge() before the cap, and it is not in the set host-managed sessions
(CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST, Desktop's Code tab) drop from settings
env (eu: oV, N$, F$, hdt model list, ... none hold it), so Desktop's Code
tab honours it. Renaming the alias was not chosen: Desktop's effort picker
needs it. The settings file is shared, so a terminal Claude Code session on
a real Fable model also inherits without the cap while Desktop is on.

Patch by NeuroPaw (1b480ef3), applied unchanged.

Run (sandbox HOME, pinned GOMODCACHE, private GOCACHE):
- TestClaudeDesktopExploreInheritCap, TestClaudeDesktopExploreKeepsUserValue
  pass. Broken by hand four ways, each a real FAIL: no write ("value "",
  present false; want "1", true"), overwriting the user's value ("user's
  Explore value "0" lost: "1""), never removing ("value "1" ... want "",
  false"), removing a value that isn't magpie's ("user's Explore value "0"
  lost: """).
- go test -tags nogui ./internal/agent (1337s, load ~260) and
  ./internal/agentenv: ok. An earlier run of internal/agent hit the default
  10m timeout under that load; with -timeout 45m it passed.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on
  internal/agent; GOOS=linux -tags nogui and GOOS=windows go build.
Not tried: a real Claude Desktop Code session with the built magpie; the
full go test ./... suite.

Co-authored-by: NeuroPaw <link_xin@163.com>
2026-10-14 14:59:00 +08:00
yetone 96aca14a9b agent: Claude Desktop on magpie starts from the user's own gateway profile that points at magpie, so their settings carry over (#2035, capiton0)
capiton0's settings were in a Desktop profile they made themselves (key
"magpie", static credential) pointing at magpie's gateway. c76842482 only
keeps edits made inside magpie's own profile, so turning magpie on started
magpie's profile empty and their settings looked lost.

Now, when magpie's profile has nothing stashed, desktopOn seeds it from the
profile Desktop has applied (or the one magpie stashed as applied) when that
profile is the user's own, inferenceProvider "gateway", and its base URL is
magpie's gateway (same port; same host, localhost or a loopback IP). Only the
gateway URL, key and auth scheme are magpie's. The user's file is not
touched, and turning magpie off applies it again. A profile for another
gateway, Bedrock or Vertex is not carried over.

Run:
- go test -tags nogui ./internal/agent -count=1 (sandbox HOME): ok, 1219s.
- TestClaudeDesktopOnKeepsTheUsersOwnGatewayProfile uses the reporter's
  literal config; it fails without the change. Making desktopIsOurGateway
  always true turns TestClaudeDesktopOnLeavesOtherProfilesOut red.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
Not tried: a real Claude Desktop.
2026-10-14 14:49:25 +08:00
yetone caa5367336 gateway: a remote magpie's quota, credit or rate refusal rests only that model, not the whole remote (bigsteven on Discord)
A Remote magpie provider (LAN share) serves every model through one
key. When it answered 429 "usage limit … resets in 3 hours" for one
model, the key rested whole for those 3 hours. A group then never
moved on to the remote's other models that still had quota, and the
user had to ask again by hand. The remote magpie rests its own
providers' models itself, so one model out of quota there says nothing
of its others.

remoteModelRest: on a Remote magpie provider, failQuota, failCredit
and failRate rest c.restID() (the model) in restAfterMarked and
rateRest. A refused key or an unreachable computer still rests the
whole remote.

Run:
- TestRemoteMagpieQuotaRestsTheModel, against a fake remote whose codex
  model answers 429 quota, glm 429 rate, and kimi OK. A direct request,
  then two groups. It fails with remoteModelRest taken out.
- go test -tags nogui -count=1 -timeout 30m ./internal/gateway: ok.
- gofmt -l is clean. go vet passes on darwin, GOOS=linux -tags nogui
  and GOOS=windows.

Not tried: two real computers on a LAN share.
2026-10-14 14:47:37 +08:00
yetone c77d198a81 gateway: a Google account's Code Assist 404 for a model rests that model, not the account (Packing1 on Discord)
Google's fetchAvailableModels lists models the account's plan doesn't
serve (Argon on Google AI Pro). Asked for one, Code Assist answers 404
NOT_FOUND "Requested entity was not found." Its endpoint is the same
for every model, so what is missing is the model, but the 404 counted
as failOther and rested the whole Antigravity / Gemini CLI account,
taking its other models down with it.

codeAssistModelMissing (built-in antigravity/gemini accounts only, not
a plugin) makes that 404 "unserved": only that model rests on that
account, and the request moves on to the next candidate.

Run:
- TestCodeAssistMissingModelRestsTheModel. It fails with the check
  taken out, because the account rests.
- go test -tags nogui -count=1 -timeout 30m ./internal/gateway: ok.
- gofmt -l is clean. go vet passes on darwin, GOOS=linux -tags nogui
  and GOOS=windows.

Not tried: a real Google AI Pro account, or the real 404 body. The
fixture's body follows Google's documented NOT_FOUND error shape.
2026-10-14 14:47:36 +08:00
yetone 79f64f028e gateway: Claude Code's advisor goes to a relayed Claude upstream under the upstream's own model name, or is left out (JackChou on Discord)
Claude Code (2.1.299, seen against a fake server in a sandbox HOME) declares
the advisor as Anthropic's server tool {"type":"advisor_20260301",
"name":"advisor","model":"claude/claude-opus-5-5"} with the beta
advisor-tool-2026-03-01. The model is magpie's id, which no vendor knows,
so a relayed Messages request carrying it was refused whole.

passthrough now runs advisorTools on Anthropic upstreams. An advisor model
that is one of the same provider's Claude models goes as that upstream's
own name for it (the wires, as the request's own model). So does a bare
Claude id that names no provider, and the [1m] mark is dropped. An advisor
the upstream can't run (another provider's model, a group, a model that
isn't Claude), and every advisor when the request's own model isn't
Claude, is left out. If no tools are left, tools and tool_choice go too.
Translated routes already drop server tools (anthropic.go). The Claude
subscription's bridge declares only magpie's tools, so it never has an
advisor. Nothing is sent to Anthropic with a user's token.

Claude Code's own gate: without CLAUDE_CODE_ENABLE_EXPERIMENTAL_ADVISOR_TOOL=1
it sends no advisor for a model with no advisor rank in its catalog ("Switch
to a public model alias (opus, sonnet, fable)"). That is unchanged here.

Run: TestAdvisorModelAsTheUpstreamNamesIt (same provider, [1m], bare
Claude id kept, another provider left out, vendor model left out, other
tools kept). It fails with advisorTools taken out of passthrough.
gofmt -l clean. go vet for darwin, GOOS=linux -tags nogui and GOOS=windows
on ./internal/gateway. go test -tags nogui ./... under a sandbox HOME at
load ~90: every package passed except agent and gateway, which hit the
10m timeout, and TestCopilotSecretToolUsername (its two 5s secret-tool
waits ran out under that load). Rerun with -timeout 30m, gateway, agent
and provider all pass.

Not tried: a real Anthropic or relay upstream, and a running magpie with
real Claude Code end to end.
2026-10-14 14:47:36 +08:00
yetone 88ce2cdd4c gateway: a web search's query is masked before it goes to a search API, Kimi Code's or WorkBuddy's search (lc on Discord)
lc on Discord: "mcp 搜索出去的脱敏了吗?"

A searcher model is asked through serve, which masks its request, and the
image and vision MCPs go through the masked routes too. But the search
APIs (Tavily, Brave, Exa, Firecrawl, SearXNG, ...), a Kimi Code plan's
search service and WorkBuddy's search were sent the query as it came. A
model's own web_search writes its query from a request already masked, but
an agent's call to the search MCP carries the query as the agent's model
wrote it, with the values put back, so a secret or phone number in it went
out as written.

maskedQuery masks the query, as Settings say, where it leaves magpie for
each of those three (a plan the user set to go unmasked, SkipsRedaction,
keeps it), and searchMCPRun puts the values back in what it returns to
the agent. Scoped by where the value goes (the query field of a search
service's request), not by a key's name.

Run: TestSearchQueryMasked; each of the four changes removed alone turns it
red (search API, Kimi, WorkBuddy asked the phone number; the agent got the
placeholder back). -run 'Search|Redact|Kimi|WorkBuddy|MCP' over
internal/gateway (sandbox HOME); gofmt -l; go vet darwin, GOOS=linux
-tags nogui, GOOS=windows. docs/subsystems/gateway-routing.md says it.
Not tried: a real search API or a real agent's MCP call.
2026-10-14 14:47:36 +08:00
yetone 88b4c00ea1 provider: a Codex token refresh, once sent, is waited for even when its caller gives up
willz on Discord: a Codex account that isn't the current one stops showing
its quota after a day or two and asks to be signed in again, while
requests on it still work; moving it to the top "fixes" it.

codexRefresh sent the refresh on the caller's context. OpenAI rotates the
refresh token as it answers, so a refresh whose caller went away mid-flight
(an agent's cancelled request, a usage read's deadline, the keep-alive's
2-minute run) dropped the answer and left magpie holding the spent refresh
token. The next refresh (the keep-alive forces one each day) is refused as
refresh_token_reused, the account is marked lapsed and its row says to sign
in, while the access token it still holds keeps serving requests. Moving it
to the top makes it the active account, whose lapse isn't shown.

Like siwcFresh (the ChatGPT API's refresh) already does, a refresh that has
been sent now runs on context.WithoutCancel with its own 30 s; a caller
already gone sends nothing.

The cause can't be confirmed without willz's log; this is the one path
found where a working account's refresh token is lost.

Run: TestCodexRefreshOutlivesItsCaller fails without the change
("context canceled") and passes with it; -race -count=10; the whole
internal/provider package (sandbox HOME); gofmt -l; go vet darwin,
GOOS=linux -tags nogui, GOOS=windows.
Not tried: a real Codex account.
2026-10-14 14:47:35 +08:00
yetone c8c3ce9a9a usage, sessions: Antigravity CLI's (agy's) own calls are counted, read from its transcripts, and a step it sent through magpie once (#2097, parkavenue9639)
agy wrote its calls nowhere magpie read. Each conversation's
brain/<id>/.system_generated/logs/transcript_full.jsonl has a line per step,
and a model step carries its own input_tokens, cache_read_tokens and
output_tokens. readAgyCalls reads those as agent agy, provider unknown
(session-unknown) and no model: the step names none, and settings.json's is
only the one picked now. A transcript an older agy wrote has the lines with
no token fields; they are left out, not counted as zero.

agy sends the gateway no session header, so its gateway records name no
session and the matcher, which pairs by session, would have counted a step
sent through magpie twice. matchedBlocks now pairs an agy step with a
session-less agy gateway record by tokens alone, and lets the record end up
to 30 minutes after the step's created_at, which is when the step began (to
the second), not when its call ended.

Tried for real: agy 1.2.16 under a sandbox HOME, with GEMINI_API_KEY and
GOOGLE_GEMINI_BASE_URL on a fake Gemini endpoint, three turns of one
conversation. It sent User-Agent google-genai-sdk/1.72.0, X-Goog-Api-Key and
no session header; its transcript's input_tokens is the prompt less the
cached tokens and output_tokens includes thoughtsTokenCount (8 + 40 = 48),
as the gateway counts a Gemini reply. A turn that failed to connect wrote
ERROR_MESSAGE steps with no tokens. That transcript is the fixture beside
the issue's quoted lines and an old one without tokens; the built binary's
`magpie usage --csv all` in that HOME lists the three steps as agy, log.

Run: TestAgyCalls and TestAgyStepThroughMagpieCountedOnce fail without the
change (0 agy calls; "the step the gateway logged is counted again"); gofmt
-l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on sessions and
usage; go build darwin, linux nogui, windows; go test -tags nogui of
internal/sessions, internal/usage, internal/usageapi, internal/cli in a
sandbox HOME, all ok.

Not tried: a step through a real magpie gateway and a real Google account
(the matcher's pairing is covered by the unit test with the gateway's
numbers from the fake run); agy on Windows or Linux; the full go test ./...
2026-10-14 14:35:23 +08:00
yetone 407595b2ab sessions: a Kimi Code session whose state.json names no folder takes it from session_index.jsonl (#2103, infinitr0us)
Early protocol 1.4 sessions and those migrated from the Python kimi-cli
(ses_* folders) have neither cwd nor workDir in state.json, so they were
listed under "No folder" and resumed with a bare `kimi --session <id>`.
Kimi Code's session_index.jsonl, at the root of its home beside sessions/,
has {sessionId, sessionDir, workDir} for every session (Kimi's
docs/en/configuration/data-locations.md). parseKimi now falls back to the
workDir of the index line whose sessionId is the session folder's name;
a folder state.json names still wins. The index is read again only when
its size or mtime changes. parseKimi is the only place a Kimi session's
folder is derived (the resume command is built from it).

Run:
- TestKimiCodeSessionFolderFromIndex (new): the reporter's 1.4 and
  migrated sessions get the index's folder and a `cd '<folder>' &&`
  resume; state.json's cwd beats a different index line; a session with
  no folder anywhere stays without one. With kimi.go put back it fails:
  `june folder ""`.
- go test -tags nogui ./internal/sessions/... under a sandbox HOME with
  pinned caches: ok.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean.

Not tried: a real Kimi Code home with an index (this machine's
~/.kimi-code has no sessions); the format is from Kimi's docs, the
reporter's line on the issue and Coffee-CLI's reader of the same file.
Not run: the full go test ./... suite.
2026-10-14 14:19:23 +08:00
yetone 2fbbd16945 gateway, gui: routing history keeps the last two levels of the folder an agent works in, and By session, the stage and the panel name it (#1068, emo172)
Routes now carry Folder: the last two levels of the working directory the
agent states (Claude Code's "Primary working directory", Codex's <cwd>,
Pi, OpenCode), cut by shortFolder before the route is stored, so no full
path reaches the routing history, /api, or the GUI. It is kept in the
routing history for as long as the history itself (30 days / 200 MB).
A request that states no folder (title, side calls) takes the folder its
session (or parent session) last stated; the per-session map is capped
at 512 entries.

GUI: By session headings read "Agent · folder · title", their tooltip
and every request row's tooltip (page and tray panel) name the folder,
the stage's agent subtitle lists the last level of each folder when an
agent works in more than one, and the panel's agent node tooltip lists
them.

Run:
- TestShortFolder (unix, trailing slash, C:\, D:\, UNC, CJK with spaces)
  and TestRouteKeepsItsFolderShort (real Handler, fake upstream: session
  inheritance, a moved Windows path, nothing of the full path in the
  marshalled routes, saveRoute -> History round trip), TestTurnDone.
  Broke it by hand: without the session lookup the title request has no
  folder; with the folder unshortened the full path shows. Both go red.
- routing-session-folder.test.cjs: chromium + webkit x en, zh, zh-TW,
  ja, de x 1100 and 420 px, 20/20. Red on the old routing.js and with
  the stage's live routes left out.
- GUI suites routing-*, panel-routing*, purpose-filter, reasoning-speed,
  gui-de/ja/zh-tw, click-scroll, number-units: 951/951.
- gofmt -l clean; go vet darwin, linux (nogui), windows; builds for all
  three. go test -tags nogui ./...: all ok except internal/gateway, which
  hit go test's default 10m timeout at 611s on a loaded machine (#2108);
  alone with -timeout 30m it passes in 356s.
- Real use: nogui build in a sandbox HOME, fake upstream, real Claude Code
  2.1.299 (claude -p) run from .../workspace/magpie and .../src/dial: the
  day's routing jsonl has folder "workspace/magpie" and "src/dial" and no
  part of the sandbox path above them.

Not tried: title/side requests' inheritance end to end with a real agent
(claude -p made none), Codex, OpenCode and Pi with real binaries, Windows.
2026-10-14 14:03:38 +08:00
yetone d9ca84a2f4 gateway: built-in TLS, magpie serve/web/daemon install --tls-cert --tls-key, reloaded on renewal (RoderickZH)
magpie serve, magpie web and magpie daemon install take --tls-cert <file>
--tls-key <file> (or MAGPIE_TLS_CERT / MAGPIE_TLS_KEY). The gateway and the
web UI on its listener then serve HTTPS to other computers. Without them
nothing changes.

- Half a pair, a file that doesn't parse, or a flag with no value is
  refused at start with a message naming the missing flag.
- The pair is re-read when either file's mtime or size changes (certbot
  renewal), with no restart. A renewal that doesn't parse keeps the
  certificate already served and is logged once.
- Other computers get HTTPS only. Plain HTTP from them gets net/http's
  400 "Client sent an HTTP request to an HTTPS server".
- This computer (loopback, or a peer address equal to the local one) may
  still use plain http on the same port. Its connections are sniffed on
  their own goroutine (a first byte of 0x16 is TLS) for up to 10s, so a
  silent client holds nobody else up. gateway.URL() stays
  http://127.0.0.1:<port>, which agents, MCP servers, ServedBy, the
  healthcheck and daemon status all use, and no certificate covers
  loopback.
- WSL NAT and containers count as other computers.
- ALPN is http/1.1 only (hijacked connections and websockets need it), with
  TLS 1.2 as the minimum.
- Printed links, LAN addresses, publicURL, the serve/web banners and
  daemon install show https:// for other computers' addresses.
- The DNS-rebinding Host checks (foreignPage, rebound, the MCP
  loopbackHost) don't depend on the scheme and are unchanged.
- daemon install carries MAGPIE_TLS_* into the unit or plist. A reinstall
  or `daemon web on` that names no certificate keeps the installed pair,
  and --no-tls removes it.
- Docs: reference.md gets an HTTPS section that names Caddy as the
  alternative, gateway-routing.md gets a TLS row, and docker.html (en,
  zh, ja) gets the env rows.

What was run:
- New tests: internal/gateway/tls_test.go (others HTTPS-only, this
  computer both, a silent local client holds no other, renewed
  certificate served, CheckTLS, addresses, Relisten keeps TLS),
  internal/cli/tls_cli_test.go and daemon TestInstallCarriesTLS (linux
  and darwin, paths with space, %, & and ").
- Each was broken by hand and went red: no wrap in listen, no reload, a
  synchronous sniff, a bad renewal dropping the certificate, http in
  publicURL or the pinned LANURLs, the carried entries removed, and
  keepTLS as a no-op.
- Real use under a sandbox HOME, with a self-signed pair, on
  0.0.0.0:3461:
  - Half a pair, a garbage certificate, a flag with no value, and the
    env set to half a pair each exit 1 with the message.
  - curl -k https://127.0.0.1 and https://<LAN IP>/v1/models with a key:
    200. Plain http on loopback: 200.
  - The cert files were swapped for a second pair while it ran.
    openssl s_client then showed the new CN and serial, and curl
    --cacert with the new pair got 200. A junk key file then kept the
    second pair, logged once.
  - From the Windows box over the LAN: plain http got 400; https with
    the key got 200, and without it 401.
  - magpie web --addr 0.0.0.0:3462: https network links. From Windows,
    http got 400 and https with the key got 303.
- gofmt -l clean. go vet passed on darwin, GOOS=linux -tags nogui and
  GOOS=windows.
- go test -tags nogui for ./internal/cli, ./internal/daemon, and the TLS
  tests of ./internal/gateway and ./internal/gui: all pass at the rebased
  head.
- Two reds in the full suite (`go test -tags nogui ./...`) are the same
  on origin/main f074996d9; both are filed:
  - TestGatewayHeldByAContainer failed 2 of 5 there (#2107).
  - The gateway package runs past go test's default 10m under load:
    1208s on main and 1221s here, both passing with -timeout 40m
    (#2108).
2026-10-14 13:36:03 +08:00
yetone 579de3baa0 agent: enabledModels lose a deselected model's entries after the catalog sync (#2055)
misaka9981: models deselected in a provider's editor left magpie's
provider in Pi's models.json, but their magpie/<provider>/<model>
entries stayed in settings.json's enabledModels, and Pi warned "No
models match pattern" for each at every start. Pi's resolver
(model-resolver.js resolveModelScope, 1.1.0) only warns, never prunes.

After the sync writes magpie's provider block, an enabledModels entry
that names one of magpie's models outright (no glob; a thinking level
read off) whose model the block no longer has is taken out. As the
entry may be the user's own, it is remembered in stash.json
(<agent>.scope.gone) and goes back on the list's end once the model is
offered again; a provider rename moves the remembered entries too and a
disconnect forgets them. Globs, entries on other providers and on
models still offered stay, in order, comments kept. A list left with
nothing is removed (never written []) and made again when its entries
come back, with the model picked meanwhile; a list the user removed
isn't made again. When the agent's model list can't be read, nothing
is taken out.

The same holds for the siblings with such a list: OmO and Prime Agent
(piLike), StepCode (config.toml; its wiring state's last scope follows,
so a disconnect still puts the user's list back) and omp (config.yml's
plain entries; folder-scoped entries are left alone).

Run:
- TestPiEnabledModelsLoseDeselected (pi, omo, prime-agent) with the
  reporter's provider and four models, beside the user's own entries
  (another provider at a level, a magpie glob, a model still offered
  at a level): deselect, select again, rename.
  TestPiEnabledModelsEmptiedAndBack: emptied and back; removed by the
  user stays removed; other providers' and globs' file byte for byte;
  an unreadable models.json prunes nothing.
  TestStepCodeAndOmpEnabledModelsLoseDeselected, StepCode's disconnect
  putting the original list back included.
- TestPiEnabledModelsFollowRename and TestStepCodeEnabledModelsFollowRename
  keep a magpie/deepseekx/flash entry to show a rename leaves a name
  sharing a prefix alone; deepseekx is now a real provider there, as the
  sync would otherwise (rightly) take an entry naming nothing out.
- Broken by hand, each red: Pi's, StepCode's and omp's Sync hook off;
  the put-back off; the rename of remembered entries off.
- Real Pi 1.1.0 (@earendil-works/pi-coding-agent) under a sandbox
  HOME, `pi -p`: the stale exact entries gave the reporter's warnings;
  the list as pruned gave none.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows;
  go test -tags nogui ./... green on origin/main 7d15df78a. Rebased again
  over 2eee900dc (omp's Sync now keeps the user's keys, ompProvider(models);
  the conflict is that one line), then vets and ./internal/agent/ and
  ./internal/cli/ again: green but for TestReasonixCLI*, whose fixture
  build read a go1.26.8 toolchain another session was unpacking into the
  shared module cache ("internal/oserror is not in std"); both pass run
  alone right after.

Not tried: the GUI's provider editor end to end with a real Pi session,
real omp and StepCode binaries, WSL. A magpie glob that matches nothing
still gets Pi's warning: it is the user's pattern and stays.
2026-10-14 13:33:28 +08:00
yetone 06c3370b74 gui: Fetch models' "{p}: {n} models" counts the models the editor lists, not the vendor's ids (#2069)
liangxyz's Antigravity refetch said "Antigravity: 23 个模型" over 17 chips.
The toast counted the ids the vendor listed, while the editor shows a
model Antigravity lists once per thinking level (gemini-3.7-flash-high,
-low, -medium) as one model with those levels, as Cursor's and Devin's
lists are folded too. Two numbers for one list read as models gone.

The count is now the models the provider offers after the refetch
(Provider.Available, what the editor's chips are drawn from), the ids
only when it offers none.

TestFetchedCountIsTheEditorsModels saves an Antigravity list of six ids,
three models, and fails on the old count (6, want 3).

Run (macOS): the test red with fetchedCount returning the ids, green with
it; TestProviderTypedKey still counts a relay's two; go test -tags nogui
./internal/gui: one run of the whole package failed in a 208s run whose
output I didn't keep, while a fork was running other suites on this
machine; three runs after it passed, so its cause is not known. gofmt
clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean. No GUI
change (app.js shows r.count as before), so the GUI suite wasn't run. Not
tried against a real Antigravity account.
2026-10-14 13:31:10 +08:00
yetone 9829d2f553 gui: a hook's description is shown whole, wrapped, and written in a box that wraps (#2085, emo172)
Library › Hooks cut a hook's description to one line with an ellipsis and
no tooltip, and the editor's Description was a one-line input, so an
80–150 character Chinese description could neither be read nor seen while
written.

- The list wraps the description (at most 200 characters, the user's own
  words). The row's text block takes a 240px basis, so the long text no
  longer pushes the name under the glyph at narrow widths.
- The editor's Description is a textarea that wraps and grows to fit. It
  stays one paragraph (library.SaveHook joins its lines), so Enter still
  saves, an IME's Enter still doesn't, as in every other field there.
- Siblings left as they are on purpose: skills, subagents and market rows
  hold one line with the whole text in a tooltip, because their lists are
  windowed to a fixed row height and their descriptions are authors'
  paragraphs, not the user's 200 characters.

Verified:
- library-hooks.test.cjs now gives a hook a 90-character Chinese
  description and checks it is not clipped and wraps at 440 and 1100 (1100
  in a window of its own: resizing one window across the page's breakpoint
  raises a WebKit ResizeObserver-loop error under load), that the name
  stays beside its glyph, and that the editor's box is a textarea showing
  all of it. On the old code it fails 12/12 ("the description is cut off
  at 440"); without the 240px basis, "the name is 38px off its glyph at
  440".
- All 484 library*.test.cjs pass in Chromium and WebKit, en/zh/zh-TW/ja/de;
  the hooks test 4x concurrently in both engines, 48/48.
- Screenshots at 440 and 1100, both engines, looked at.
Not run: Go checks (no Go changed); not tried in the built app.
2026-10-14 13:30:06 +08:00
yetone 353464f161 gateway: a translated Anthropic or Responses reply that said nothing and counted no token is asked again, then fails, not completed (#2086, tensornull)
tensornull's Codex turn on an Anthropic-compatible proxy (baseAPI
anthropic, claude-opus-5-5) ended as response.completed after 21s with
no output: the route had status 200, no usage, no served model, no
ttft. Codex took it as its turn's end (last_agent_message null) and
didn't ask again. No usage and no served model mean the proxy never sent
a message_start Claude would have (it counts the prompt and names the
model), yet the stream said it ended (message_stop or a stop_reason), so
320af9858's replyEnds read it as whole and errEndedShort didn't apply.

Now a reply from an Anthropic or Responses upstream (repliesCounted) that
said nothing (no text, call, search or image) and counted no token at all
(uncounted) is the empty reply #667 already handles for Gemini: asked
again in place, then failed with "an empty reply (the model answered
nothing; try again)", which Codex retries. Same in streamTranslated and
the unstreamed translate path, for Responses, Messages and Chat clients.
Claude's own empty end_turn (after a tool's result) counts its prompt and
still completes, as does a Responses reply with usage and no output.

Not changed: a reply passed through in its own protocol (Codex asking a
Responses provider, Claude Code an Anthropic one) isn't read for this;
the passthrough has no empty-reply rule at all, Gemini's included.

Verified:
- New stream_uncounted_test.go. TestUncountedEmptyReplyFails (message_stop
  only; pings then message_stop; message_start with no usage then a
  stop_reason; zero usage), TestUncountedResponsesReplyFails and
  TestUncountedEmptyReplyFailsEveryClient (Chat streamed, Responses and
  Chat unstreamed) all FAIL on the old code ("ended response.completed
  \"completed\", want response.failed", "status 200, want the empty
  reply's failure") and pass with the change. TestCountedEmptyReplyStillCompletes
  and the #1933 tests (TestWellFormedStreamsStillComplete, TestMalformed*)
  pass.
- The full go test -tags nogui ./internal/gateway run failed only
  TestCodexHeadersReachKeyedRelay and TestStandaloneNativeAccounts, whose
  fake Codex backends answered response.completed with output [] and no
  usage, which the real backend never sends; their fakes now count
  tokens, and both pass. Run in a sandbox HOME with pinned
  caches; gofmt -l; go vet ./internal/gateway for darwin,
  GOOS=linux -tags nogui and GOOS=windows; GOOS=linux go build -tags
  nogui and GOOS=windows go build.
- Not tried: the reporter's proxy or its real bytes (the report has none);
  the fixtures are the shapes its route record allows. Not run: the full
  go test ./... (only internal/gateway changed).
2026-10-14 13:26:18 +08:00
yetone 6e9930e374 provider: the Kiro mover asks for opencode-kiro-auth 0.1.10, which passes the caller's prompt-cache marks to Kiro (magpie-community/plugins#110)
kiro 0.1.10 (plugins 386a2ba) turns each cache_control in the Anthropic
body magpie hands the plugin (system, messages, tools) into Kiro's
cachePoint, at most 4 with the last kept; up to 0.1.9 it dropped them, so
a moved Kiro never asked Kiro to cache. This raises the mover's min, so
keepMovedCurrent updates every moved user.

Run: npm view @magpie-community/opencode-kiro-auth version on
registry.npmjs.org shows 0.1.10 (the publish run is red only for
zed-auth and zen-free-auth, refused by npm's trusted publishing); the
plugin's bun test (1191 pass) and scripts/check.mjs kiro, with its
cache-points.test.mjs failing 3 of 4 with the fix broken by hand; gofmt
-l; go vet darwin, linux -tags nogui, windows on internal/provider; go
test -count=1 ./internal/provider (ok).
Not tried: a real Kiro account.
2026-10-14 13:20:36 +08:00
yetone e710c5accd gateway: the built-in Kiro tells Kiro where to cache the prompt (magpie-community/plugins#110)
plugins#110 ("kiro cli cache 率为 0"): a Kiro subscription read nothing
from its prompt cache. Kiro's generateAssistantResponse takes Bedrock's
cachePoint {"type":"default"} on a userInputMessage (the CodeWhisperer
streaming model in aws/amazon-q-developer-cli; Kiro CLI 2.27's model list
carries PromptCaching with up to 4 checkpoints), but neither the plugin
nor the built-in ever sent one. The plugin's fix is kiro 0.1.10
(plugins 386a2ba); this is the same for users who haven't moved.

buildKiro now marks the first message when there is a system prompt
(which it folds into that message) and the current message, the two
places buildAnthropic marks for Anthropic. gateway-routing.md says how
each Kiro path places them.

Run: gofmt -l (clean); go vet on darwin, GOOS=linux GOARCH=amd64 -tags
nogui and GOOS=windows for internal/gateway and internal/provider; go
test -count=1 ./internal/gateway ./internal/provider (ok; both isolate
HOME in TestMain). TestBuildKiroMarksTheCache fails with the current
message's mark taken out by hand, and passes with it back.
Not tried: a real Kiro account (none signed in here), so whether Kiro
then reports cache reads is for the reporter to confirm; kirocc#83 notes
Kiro often sends a metadataEvent with no token counts.
2026-10-14 13:20:36 +08:00
yetone 33da86c71a provider: removing a plugin sets its providers' model picks in providers.json aside, and adding it again puts them back (#2057, dawn1095)
A plugin's provider leaves a record in providers.json once the user
picks its models: its id and nothing of its own (OnlyPicks). Removing
the plugin left those records behind. Nothing listed them, `magpie
provider rm` couldn't reach them, and a sync or backup asked for a
sign-in to them on every run.

RemovePlugin now finds the ids the plugin's providers are stored under
(PluginID of each provider plugin.Listed gives for its spec), and moves
the records with those ids that hold only picks into providers.json's
new pluginLeft, under the plugin's package name. Left alone:
- any record with an endpoint or a key (the user's own provider,
  whatever its id);
- a built-in's ids (accountIDs) and "magpie";
- an id another installed plugin serves too;
- everything, when the plugins' listing isn't known (no cache and no
  plugin-providers.json): unknown is not "none is the user's".
provider.AddPlugin (CLI, GUI, backup restore) puts the set-aside
records back, each one whose id has no record now; one the user has
given to a provider since stays aside. plugin.Listed is new: the cached
listing, or plugin-providers.json.

Run:
- plugin_left_test.go, four tests with user-owned records beside the
  plugin's (a user "zap" with an endpoint next to the plugin's
  zap-plugin, a hand-made "mine", a built-in's picks, another plugin's
  and a shared id). Each guarantee broken by hand turned its test red:
  no set-aside, no OnlyPicks check, no other-plugin exclusion, no
  unknown-listing guard, take-back over the user's record, no take-back.
- go test ./... in a sandbox HOME; gofmt -l; go vet darwin, linux
  (-tags nogui), windows.
Not done: records left by plugins removed before this change stay where
they are; turning a plugin off (not removing it) sets nothing aside;
`magpie provider rm` still can't name such a leftover. The move flow
(installPlugin) still adds through plugin.Add, since its own
migration owns those records. Not tried with a real plugin removal in
the GUI.
2026-10-14 13:20:13 +08:00
yetone 2a6354f09f gui: a quota curve closed again takes its card back to its height (#2059)
mengyianx on the Linux CLI's web settings page: with the remaining-quota
trend (剩余额度走势) opened and closed again, the allowance's box stayed
as tall as when it was open, blank under the curve.

The Usage page packs its cards into columns on 1px grid rows. Each card
is stretched to the rows it was given, and the last card in a column is
held down to the tallest column. A ResizeObserver on the list and the
cards repacks. A curve that grows pushes its card's box, so it repacked.
A curve that shrinks leaves the card's box where the packing put it, so
the observer never fired and nothing packed again. packUsageNow now also
observes each card's children, so a shrinking curve or balance trend
repacks too.

New test usage-curve-zoom-back.test.cjs opens and closes Codex's
allowance curve and DeepSeek's balance curve. It checks that every card
and the list come back to their heights, that the clicks don't scroll,
and that there are no page errors. It runs in Chromium and WebKit, en, zh,
zh-TW, ja and de, at 1100 and 420 (WebKit at 420 wheels to the balance
card with reader.cjs's reach).

Run:
- The new test: 20/20 pass. Against origin/main 8a4cfe0e4's assets
  (MAGPIE_ZOOM_ASSETS), all 20 fail with "codex: closed again, every
  card and the list are as tall as before it opened". On the old assets
  in Chromium en 1100, Codex stays 400 (was 297), DeepSeek 295 (was 192).
- The Usage-page GUI files (usage-*, quota-*, balance-*, panel-usage,
  tray-usage*, allowance*, routing-quota*, claude-usage*, api-key-usage*)
  in both engines at --test-concurrency=3: 807/808 pass. The one red,
  webkit de usage-sum-whole at 860px (page 4px wide), serves no quota
  cards, so this change can't reach it. Alone it passed 3/3. It is the
  known load flake #1864/#2023; this run was added to #1864.

Not tried: the rest of the GUI suite, and the real Linux CLI's web page
(the fake API serves the same assets).
2026-10-14 13:20:13 +08:00
yetone 3a7d0314a9 usage: a window's Pace as a number on its card, and in the menu bar when asked (fflake33)
fflake33 on Discord asked for the pace as a figure, "+12%" or "−8%"
against an even pace through the window, on the Usage cards and in the
menu bar.

- provider: QuotaWindow.Pace(readAt, now) is the share used (0-100) less
  the share of the window gone by, from Bounds (reset less span; a
  month's window a calendar month); none for an unlimited window, one
  whose span or reset isn't known, or outside it. WithWindowStarts sets
  startsAt on copies of the cards for the GUI (the caches' cards are
  left alone); /api/usage/quotas and its refresh send it.
- Usage page: "Pace +20%" on the reset line after the wait (quotaPace,
  paceLine), its sign turned with the meter in Left mode, amber while
  more is used than an even pace would have, what it means in its
  tooltip. Past cycles and windows with no known start show none.
- Menu bar: Settings > Menu bar pace (settings.TrayPace, off by default;
  hidden on Windows, whose tray shows no text) puts " +12%" beside each
  figure ("42% −14%", at most 10 runes, trayRowMax) and "pace −14%" in
  the tooltip. KeepOwn keeps it device-local like the other tray
  settings; the Settings save keeps it (prefsKeep).
- Strings in en, zh, zh-TW, ja, de. gui-shell.md says it.

Run:
- go test -tags nogui ./internal/provider ./internal/gui ./internal/settings
  ./internal/usage: ok; ./internal/davsync: ok (now covers TrayPace;
  red with TrayPace taken out of KeepOwn). go test ./internal/gui -run
  Tray (darwin, with the tray image tests): ok.
- New TestWindowPace, TestWithWindowStarts (input not mutated),
  TestTrayUsagePace (off unchanged, used and left, rows, tooltip).
- quota-pace.test.cjs, chromium and webkit: 4 pass; cards in en, zh,
  zh-TW, ja, de at 1100 and 420px, used and left, amber, tooltips, no
  sideways scroll, a click moves nothing; the Settings row in all five
  at both widths, On posts trayPace, a currency save keeps it, no
  scroll; hidden with no card and on Windows, shown on Linux. Red with
  paceLine not called, with trayPace out of prefsKeep, and with the
  Left-mode sign not turned.
- gui-de, gui-ja, gui-zh-tw, i18n-keys: 12 pass; tray-bird 6, quota-holds
  2, quota-read-at 4 pass.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean.
Not tried: the real menu bar on a Mac or Linux tray.
2026-10-14 13:02:48 +08:00
ggbdpq eb0d5750f8 catalog: a relay's Nano Banana is a drawer, whatever its spelling (#2071)
ll905518294's relay serves Gemini's image models under the name they are
called, "Nano Banana 2.1", and both it and a video model landed in the
chat model list: a base-URL provider's list is classified by the id
alone, and "banana" is no word of Google's own ids, which all say
"image".

- DrawsID knows "banana": the Nano Banana family (gemini-2.5-flash-image,
  gemini-3-pro-image), which relays id "nano-banana", "Nano Banana 2.1",
  "NanoBanana2". A model it catches leaves the chat list for the
  editor's image models and Settings -> Images, as an id saying "image"
  does.
- The video model is not touched: a list that says nothing of what a
  model makes stays a chat model, for the user to mark in the editor
  (#1399, "Makes: Video model"). No word of "omni_flash-10s" says video,
  and none is guessed.

TestFetchRelayDrawerNames (a relay list with the three spellings, a
"gemini-3-pro-image-preview" that drew already, and the two that must
stay chat) fails on the old DrawsID: "Nano Banana 2.1: not a drawer",
"nano-banana-pro: not a drawer", "NanoBanana2: not a drawer". With the
word it passes.

Run (branch hunt19-b2 on origin/main f074996d): gofmt clean (CRLF false
positives judged on LF copies); go vet -tags nogui and GOOS=linux go vet
-tags nogui and GOOS=windows go vet of ./internal/catalog
./internal/gateway ./internal/provider, clean; go build -tags nogui
./... ok; go test -tags nogui -count=1 ./internal/catalog ok, and -run
'Draw|Film|Video|Image' of ./internal/gateway and ./internal/provider
ok. Not tried against the reporter's relay (no account here): the
classification is the live-list path's own, tried on a fixture of the
ids the report's screenshot shows.

Re-run on landing (macOS, origin/main 722abfbb0): the new test red with
catalog.go reverted, green with it; ./internal/catalog, and -run
'Draw|Film|Video|Image' of gateway and provider, ok; gofmt clean; go vet
darwin, GOOS=linux -tags nogui, GOOS=windows clean. No other copy of the
word list exists (grep hidream).

Fixes #2071

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-14 13:01:07 +08:00
yetone 722abfbb0a usage, gui: a window whose whole can't be estimated says "not enough data", and why in its tooltip (#2045)
The Usage page's account cards told a window's whole ("Whole ≈ N tokens
· ≈ $X") only where it could be reckoned honestly, and said nothing
elsewhere, so a reader couldn't tell a window magpie can't reckon from
a fault (#2045 asked for "数据不足" there).

The server now says why on each window of an account's own card that
isn't reckoned (QuotaWindow.HoldsWhy):
- low: under 5% used (HoldsFloor);
- clock: no reset clock, so no known start;
- log: the window began before magpie's request log;
- none: magpie routed nothing the window counts in it;
- credits: a call in it may have been paid from credits or extra usage
  (#2010's dry runs).
Windows whose whole is never told (a pool, a family, money aside, an
error card, another magpie's) carry no reason and say nothing, as
before. WithWindowHolds now also fills reasons when no window at all can
be reckoned; the caller's cards are still left unwritten.

The GUI shows a muted "Whole: not enough data" on the reset's line, with
the reason in its tooltip, in all five languages. A reason it doesn't
know says nothing. History cards are unchanged.

Run:
- go test ./internal/usage ./internal/gui: pass. The window-holds tests
  check each reason, that reckoned windows carry none, and that the
  caller's cards stay unwritten. Not writing HoldsWhy turns 3 tests red.
- quota-holds.test.cjs in Chromium and WebKit, en/zh/zh-TW/ja/de, at
  360, 420, 440, 1000 and 1100: the line, its reason, muted, not cut,
  inside its card. Removing the GUI branch turns it red. Screenshots at
  420 in zh and de looked at.
- i18n-keys, quota-curve, keep-login, quota-name-translated in both
  engines: pass.
- gofmt -l clean; go vet darwin, linux (-tags nogui), windows; linux and
  windows builds.
Not tried: a real account's card in the running app.
2026-10-14 12:53:09 +08:00
yetone f074996d93 provider, gateway, gui: a model with none of its levels ticked is sent no reasoning field, on every route and in a routing group (yuexian7)
yuexian7 on Discord: models.dev lists their model as reasoning, and the
vendor answers any reasoning parameter with 422 while the same request
without it works. In a routing group they couldn't set an effort per
model, and the model editor refused to untick the last level ("Keep at
least one level"). The learned refusals (bed306ae, #1062) don't cover
this: they learn a refusal of reasoning *off* and of Gemini levels, and
optionalFields holds thinking/enable_thinking, not reasoning_effort.

- settings.ModelReasonless, set by provider.SetModelReasonless (the
  provider editor's Names & levels with every level unticked, saved as
  modelPrefs {reasonless: true}; `magpie model efforts <ref> off`).
  Ticking levels again or Restore default clears it (setModelEfforts);
  setting it drops the model's kept levels.
- entryFor and Efforts/Thinks/Levelless: the model offers no levels and
  is Quiet, so agents are given none for it.
- Gateway: the candidate loop strips the body with withoutAnyReasoning
  in the agent's protocol (Chat/Responses reasoning_effort, reasoning,
  thinking, enable_thinking, include's reasoning.encrypted_content;
  Anthropic thinking of any type and output_config.effort; Gemini
  thinkingConfig). The Anthropic relay doesn't add
  thinking:{type:disabled} for it, and forwardTranslated clears Effort,
  ThinkOff and Thinking for its other callers (continuation, search).
- A routing group with it as a member keeps the other members' levels
  (it `continue`s like a member whose levels are unknown, #597), and the
  member that reasons is still sent the effort asked.
- GUI: none ticked shows "No reasoning field sent" beside the levels, in
  zh, zh-TW, ja and de too; a model with one known level now shows its
  picker so it can be unticked. A model whose levels aren't known
  (m.given) keeps none ticked meaning no levels known.

Run (worktree on origin/main 82f3befd2, sandbox HOME, private GOCACHE):
gofmt -l clean; with set -o pipefail go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./... all clean; node --check
app.js. go test -count=1 ./internal/provider ./internal/gateway
./internal/settings ./internal/cli: ok. ./internal/gui: ok except
TestMainWindowCorners/macOS_15_SDK killed at its 40s deadline under
load (AppKit window measurement, untouched here; #1936, noted there).
The run caught TestSettingsSaveKeepsWhatItDoesNotSend (ModelReasonless
added to it) and the CLI usage alignment tests (fixed).
New tests and what breaking the change does: TestReasonlessModelSentNoReasoning
(Chat, Chat+enable_thinking, Responses with include, Anthropic->Chat
translated; by name and through group/mix) and TestReasonlessAnthropicRelay
fail with gateway.go/quiet.go reverted; TestGroupReasonlessMemberKeepsLevels
fails with group.go's reasonless branch disabled; TestModelReasonless
needs the new API. model-reasonless.test.cjs in chromium and webkit, at
1100 and 420, in en, zh, zh-TW, ja, de: 20/20; on the old assets all
fail. Related GUI tests 418/418 (one model-copy-id failure on a first
run under load, passed alone; #2066).
Not tried against the reporter's real vendor: the 422 is taken from
their report.
2026-10-14 09:38:12 +08:00
yetone 2971e1518f gui: the Context window field offers 400K and 512K beside 128K, 200K, 256K and 1M (yuexian7)
yuexian7 on Discord asked for 400K and 512K among the context-length
quick picks; until now they had to be typed. contextPicks gains the
two, in order.

Run: context-picks.test.cjs (new) in chromium and webkit, at 1100 and
420 wide, in en, zh, zh-TW, ja and de: 20/20 pass; on the old app.js
all 20 fail. node --check app.js. Related GUI tests (provider-levels-*,
model-*, gateway-model-info, context-*, routing-levels, compact-at,
name-suffix-*, names-*): 418/418 on a second run; the first run had one
failure in model-copy-id (chromium zh, right-click copies a chip's id)
that passed 3/3 alone, filed as #2066.
2026-10-14 09:38:12 +08:00
yetone c4f4aaaa97 gateway: Claude's bridge no longer passes hook notices and token counts on as the user's message (#2060)
Through the Claude subscription bridge, the inner Claude Code kept saying
"The user sent a new message while you were working:" followed by a hook's
additional context, a bare <total_tokens>... line or nothing at all. The
outer agent sends these after a tool result, and saidWithResults took every
text block after a result as words the user typed mid-turn and queued them
into the inner session.

Captured from a real Claude Code 2.1.296 with PreToolUse/PostToolUse hooks
against a local mock: after a tool_result it sends a {role:"system"}
message whose one text block joins "PreToolUse:Bash hook additional
context: ...", "PostToolUse:Bash hook additional context: ...", optionally
"The user sent a new message while you were working:\n<words>\n\nThis is how
Claude Code surfaces messages ...", and "<total_tokens>N tokens left
</total_tokens>". Older clients put the same in <system-reminder> blocks;
the reporter's had an empty reminder too, which is why some of their
"messages" were empty.

- saidWithResults takes only the user's words out of a mid-turn block
  (midTurnSaid, up to the client's own tail, a reminder's end, the token
  count or the next hook notice), skips the rest of a system or developer
  message, and drops a text that is an agent notice (agentNotice: empty
  once reminder tags are stripped, a hook notice of the known kinds, a
  token count, or one of the injected leads prompt.go already knows).
- renderParts, the sibling that labels text after a result as
  [user message] in the prompt for a fresh run, closes the result instead
  for an agent notice.
- docs/subsystems/claude-subscription-bridge.md says so.

Run:
- Fixtures are the literal 2.1.296 bytes and the reporter's
  (claude_hook_notice_test.go): nothing queued for hooks and token counts;
  only "also tell me the date" queued when the user did write; the
  rendered prompt has no [user message]. A "Stop hook is broken: fix it"
  typed by the user still goes on.
- With the old condition put back and the renderParts change off, the
  three new tests fail; restored, they pass.
- gofmt -l internal/: clean. go vet ./internal/gateway on darwin,
  GOOS=linux -tags nogui, GOOS=windows (set -o pipefail): clean.
- go test -count=1 -timeout 30m ./internal/gateway: ok (667s).
- Not tried end to end through the bridge with a real Claude subscription.
2026-10-14 09:32:21 +08:00
yetone aa6a0d6b20 library: one skill over 200 MB is left out, not the whole repository (#2062)
mikubaka88/CCFA-Skills couldn't be installed at all: "the skills in ... are
too big to install (over 200 MB)". The repository is over the 200 MB
tarball cap, so fetchSkillFiles fetched it file by file, and that refused
the whole repository once the files summed past 200 MB. One skill,
ccf-paper-writer, is 297 MB on its own (exemplar paper PDFs, llava-4d.pdf
alone 46.8 MB); the other 16 are small.

The 200 MB limit per skill stays: a skill is copied into every agent that
gets one as a copy, and treeOf stops comparing at 256 MB, so a 297 MB skill
can't be told current or edited. What changes is that one such skill no
longer blocks the rest:
- fetchSkillFiles sums each skill's files (the deepest skill folder a file
  is under) and leaves out a skill over maxFetch; its files are never
  asked for. Only when every skill is over it does it fail as before.
- The left-out skills reach ProbeSkills as Probe.Left (path, size), kept
  per temp folder and taken once (tookLeftOut).
- The GUI's probe names each under the list ("{name} is too big to
  install: 283 MB, over the 200 MB a skill may be"), or in place of "No
  skills there" when nothing else is left; zh, zh-TW, ja, de. The TUI says
  it in its flash.
- docs/subsystems/library.md says how a big repository is fetched.

Run:
- Real: probe of mikubaka88/CCFA-Skills under a sandbox HOME lists 16
  skills and leaves out ccf-paper-writer (296736735 bytes). Not installed
  into a real agent.
- gofmt -l internal/: clean. go vet ./internal/gateway ./internal/library
  ./internal/tui on darwin, GOOS=linux -tags nogui, GOOS=windows (set -o
  pipefail): clean.
- go test -count=1 ./internal/library ./internal/tui: ok.
- TestOneSkillTooBigLeavesTheOthers (new): fails with the per-skill
  leave-out turned off by hand, passes with it.
  TestTooBigRepositoryChecksWhatArrives now makes every skill too big.
- skill-too-big.test.cjs (new), chromium and webkit, en 980 and zh,
  zh-TW, ja 440, de 420, plus every-skill-too-big: 14/14; red (0/7 in
  chromium) with client.js at origin/main. skill-*.test.cjs 190/190 and
  library-*.test.cjs 484/484 in both engines.
2026-10-14 09:32:21 +08:00
yetone e855272cf0 gui: a refused allow list names the address magpie sees the page from, with Add <addr> (Mathresearcher)
Settings > Share on local network > Allowed addresses refused a list that
would shut out the page itself with a fixed sentence and no address
(Mathresearcher on Discord). The server already names it (KeepsOut in
gateway/allow.go, "that allow list would shut out <addr>, the address
this page is open from"); allowSays now carries it into the message in
every language, and a one-click "Add <addr>" button saves the list with
it added.

The address is the connection's own (peerAddr: RemoteAddr, unmapped, zone
dropped); X-Forwarded-For and the like are never trusted, and loopback and
the machine's own addresses always pass. Behind Docker Desktop or rootless
Docker every client shows as Docker's own address (192.168.65.x), the host
reaching a container shows as the bridge gateway (172.17.0.1), and a proxy
in another container shows as that container. So the button's tooltip
says that behind Docker or a reverse proxy this is the proxy's address,
and adding it lets in everyone who comes through that proxy.

Run:
- allow-ips.test.cjs, chromium and webkit: 14 pass. The subtest checks
  the refusal names 203.0.113.50, the button's text and tooltip fit,
  a click posts ["172.16.0.0/12","203.0.113.50"], lists the rows, takes
  the button away and doesn't scroll. With the old app.js put back it
  fails (TimeoutError; chromium 5 pass, 2 fail).
- gui-de, gui-ja, gui-zh-tw, i18n-keys: 12 pass.
- gofmt -l (clean), go vet darwin, GOOS=linux -tags nogui, GOOS=windows:
  clean. go test -tags nogui ./internal/gui -run Allow: ok.
Not tried: a real Docker or reverse-proxy setup.
2026-10-14 09:31:01 +08:00
yetone 6fc0e93176 gui: the tray panel's Routing rows tell how fast a finished request wrote (#2050)
A finished request that didn't fail now shows its speed after its tokens
and time, "12.4k tokens · 1.5 s · 1667 tok/s", from the same speedOf the
Routing page's rows use, so it is left out where that page leaves it out
(no first token, a burst at the end, a failure). The string "{n} tok/s" is
already translated in every language.

With the speed the totals no longer fit beside where a request went in
the 440px panel: the "served …" mark was cut to "served gpt-…", and when
the totals were let shrink, the speed was cut instead. Where it went and
its totals now share a wrapping line (.pr-line), and the totals go under
it, at the right, when both don't fit. A row whose provider and account
alone are too long now has its totals under them rather than beside.

Not done: a live rate on a request still being answered (part 2). The
trace has no token count until the reply ends, so there is nothing to
show a rate from.

Run:
- panel-routing, panel-routing-providers, routing-reroute-title and
  number-units in Chromium and WebKit: 13/13 each.
- panel-routing now checks the speed is on the finished row only and no
  row's totals are cut. Dropping the speed line turns it red; dropping
  flex-wrap turns it red (the served mark is cut).
- Looked at the panel's screenshot at 440 in both engines.
Not run: other languages than en and zh in this test (the string itself
is translated in all five).
2026-10-14 09:29:59 +08:00
yetone 54a003d48d provider tests: the device sign-ins' fakes poll every 10ms, not the 1s floor a vendor's 0 interval got (#2051)
Copilot, Factory and ZCode's device sign-ins wait at least a second
between polls, whatever interval the vendor gives. The tests' fakes give
0, so each poll in a test cost a full second, and these tests were 56.5s
of the provider package's 399s of test time.

The floor is now devicePollFloor, read through devicePoll(seconds) at the
three call sites, and the provider package's TestMain lowers it to 10ms.
Real sign-ins still wait max(vendor's interval, 1s), as before.
TestDevicePollKeepsItsFloor checks 0, -1 and 1 give 1s and 5 gives 5s.

Run:
- go test ./internal/provider (full, -count=1, load avg ~100): pass,
  403s -> 316s of package time; the Copilot/Factory/ZCode tests 56.5s
  -> 22.5s.
- A/B on -run 'Copilot|Factory|ZCode', base vs this: 45-58s vs 15-16s
  (32s once, under load).
- Removing the floor from devicePoll turns TestDevicePollKeepsItsFloor red.
- gofmt -l clean; go vet darwin, linux (-tags nogui), windows; linux and
  windows builds.

One A/B round failed on both base and this change at load over 200; the
cause wasn't captured, and the next 4 rounds passed on both.

Not done: the other slow causes in the package. The 1.2s sleeps waiting
for the callback port to be let go (signin_test.go:137,
signin_proxy_test.go:92, signin_usage_afresh_test.go:70), Cursor's
linkWait, MoveToPlugin (7-9s) and WarmAtSeveralTimes (6-10s).
2026-10-14 09:29:59 +08:00
yetone a125d5c9ea gui tests: group-fold's window is 1700 tall, for the editor's Custom wait that 195a1009b added
195a1009b put Custom (minutes of your own) beside Wait, 30 s, 1 min and
2 min in a routing group's Slow to start, which made the editor 8px
taller. At 1600 the editor's Cancel sat half under the window's footer,
and WebKit en clicked the footer (Chromium's text metrics kept the
centre just above it). Red in WebKit on origin/main 2eee900dc, 2 of 2
runs; at 1700 WebKit and Chromium pass, en and zh.
2026-10-14 09:25:02 +08:00
yetone 2eee900dc9 agent: eight more syncs keep what the user set on magpie's block (#2030's siblings)
1e654d8ce fixed T3 Code's sync, which rewrote magpie's provider instance
whole. The same shape lost user-set keys in eight more agents. On every
Sync and every pick, each one rewrote magpie's own block in the agent's
config whole. Each app's schema was taken from its own source, never
guessed:

- Qoder 1.1.70 (@qoder-ai/qodercli bundle): providers.magpie lost routing
  (the compact and subagent models), firstPayloadTimeoutMs,
  streamIdleTimeoutMs, type, authType, anthropic and a displayName.
- fx (vercel-labs/fx configured_provider.zig): reviewer_model was lost,
  and a tool_choice_mode of "omit" went back to "send". auth stays
  magpie's whole, since fx refuses an env beside type none.
- Hermes (hermes_cli/config_providers.py): `hermes model` itself writes
  default_model into providers.magpie. That was lost, as were key_cmd,
  the timeouts, extra_body, a name and extra headers. This held in every
  profile spread() writes.
- omp (models-config-schema-bundle.ts): modelOverrides, discovery,
  disableStrictTools, headers and compat flags were lost. auth and
  apiKey stay magpie's, or go, so a loopback's auth: none never sits
  beside a WSL key.
- Kimi Code (configSection.ts ProviderConfig): SetTOMLTable replaced
  [providers.magpie], losing inline custom_headers, env and
  default_model. Its three keys are now set in place.
- Cline (local-provider-registry.ts): models.json lost the provider's
  other keys, and the per-model overrides that the VS Code model editor
  writes. A model magpie no longer lists still goes.
- Goose (declarative.rs): the custom provider file was rewritten whole,
  losing display_name, timeout_seconds, toolshim, other headers and the
  like. Goose's own editor carries those keys over.
- ZCode (provider-data-schema.ts, strict): the provider rule lost
  providerName, logo, visibility, api.headers and
  access.apiKeyManagementUrl. Only keys already in the file, which ZCode
  accepted, are kept.

Each merge lays magpie's block over what is there. magpie's parts (the
address, the key, the format and the model list) are named, and a key
magpie stops writing goes with them. The JSON ones use theirsKept or
mergeKept. A new yamlKept does the same for Hermes and omp.
agent-wiring.md lists what each one keeps.

Tests: Test{Qoder,Fx,Hermes,Omp,Kimi,Cline,Goose,ZCode}KeepsTheUsersSettings.
Each one:
- connects;
- sets the user's keys the way the app writes them, plus a stale
  address and a stale model;
- adds a provider, then syncs 3 times and picks again;
- checks that the user's keys stay, that magpie's parts are rewritten,
  and that the stale model is gone.

All eight fail on origin/main's agent code (each reports "the user's
settings not kept") and pass with this change.

Run, in a sandbox HOME, with GOCACHE in the scratchpad and Go 1.26.8:
- gofmt -l on the changed files: clean.
- go vet ./... (darwin), GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: clean.
- go test -tags nogui -timeout 45m ./internal/agent: ok, 805s.
- go test -tags nogui -timeout 45m ./...: all ok.

Not tried: none of these apps was run against a real config written by
this change. Their schemas come from their source (Qoder's npm bundle,
fx, Hermes, oh-my-pi, kimi-code, cline, goose and ZCode at their current
heads), not from a live install.
2026-10-14 09:21:18 +08:00
yetone ccffdadb8a gateway: /v1/audio/transcriptions passes speech-to-text through to the provider (#2053, niyoh120)
niyoh120 asked for an OpenAI-style speech-to-text endpoint so a client's
voice input can go through magpie like its chat does. magpie had no
/v1/audio route, so the request 404ed.

What changed:
- POST /v1/audio/transcriptions and /v1/audio/translations (and the
  /audio/... spellings) route through the same core as embeddings and
  rerank. embeddings.go's routing is pulled out into serveRetrieval, so
  disabled models, key access, groups, pause rules, account holds,
  failover, redaction and usage records are shared rather than copied.
- transcribe.go reads the multipart form only to find `model` (as
  provider/model) and `prompt`. The form goes to the provider byte for
  byte; it is rebuilt part by part, under the same boundary, only when
  the model name is rewritten or the prompt was masked. The audio part
  is always copied as sent.
- Only providers with an OpenAI-style base are tried; an Anthropic-only
  provider gets a 400 saying so. A body that isn't multipart, a form with
  no model, or one that doesn't parse gets a 400 and nothing is sent.
- The vendor's answer type passes through (response_format text/srt/vtt
  stays text/plain). Usage records output tokens from usage.output_tokens.
- The 404 message, the info api list, remote magpie's suffix list, the
  CORS and LAN tests, docs/reference.md, gateway-routing.md and the
  remote docs (en, zh, ja) name the new paths.

What was run, at 9c36c3a0 (this change rebased on 10f38770):
- gofmt -l internal/gateway internal/provider: empty
- go vet (darwin); GOOS=linux and GOOS=windows go vet -tags nogui on
  ./internal/gateway ./internal/provider: clean
- go test -tags nogui -timeout 45m ./internal/gateway ./internal/provider:
  ok (1367s, 339s); also green on two earlier bases (b4fe6663, 06fbfd95)
- Rebased again on a0ebe003 (main had moved 5 commits, none in these
  files; routing.go's Factory rest is the nearest): gofmt, vet on darwin,
  linux (nogui) and windows (nogui) clean, and
  go test -tags nogui -run 'Transcri|Embed|Rerank|CORS|LAN|Lan|Factory|
  Retriev|NotFound|Info' ./internal/gateway ok. The full packages were not
  rerun on this last base.

Break-checks, each turned red and restored:
- routes removed (the old code): all 5 new tests fail
- model never rewritten: TestTranscriptionGoesToTheModelsProvider and
  TestTranscriptionPromptRedacted fail
- answer always labelled JSON: TestTranscriptAsTextKeepsItsType fails
- rebuild truncates the audio part: Goes + PromptRedacted fail
- prompt not masked: TestTranscriptionPromptRedacted fails
- output tokens ignored: TestTranscriptionGoesToTheModelsProvider fails

Real use: through magpie's real handler against aihubmix
(https://aihubmix.com/v1) with a `say`-made m4a: whisper-1 json 200
{"text":"Hello from the Magpie Gateway."}, response_format=text 200,
srt 200 text/plain with SRT cues, translations 200.

Not tried: OpenAI direct (the key answers 429 "account is not active"),
Groq, a local vLLM/whisper server, and any real client's voice input.
2026-10-14 09:19:16 +08:00
yetone a0ebe0032d plugin: a listed plugin whose package is gone is installed again, and bun's installs run one at a time (#2002)
anganing (Windows 11, v0.1.1229): after an auto-update, every switched-on
plugin said "no such plugin: …\node_modules\@magpie-community\opencode-grok-auth"
at each start. For the github: plugins the path was the spec itself
(node_modules\github:owner\repo), so package.json no longer listed them.
Removing a plugin and adding it again was the only way out.

- InstallMissing installs again each listed plugin (switched off or not)
  whose package isn't in plugins/, from its own spec. KeepUpdated runs
  it 30s after start and then hourly, before CheckUpdates. Nothing did
  this before: CheckUpdates skips a plugin with no installed version.
- installMu serialises every bun command that changes plugins/: install
  (including the first package.json it writes), reinstall's bun update,
  and Remove's and add's bun remove. At start KeepUpdated (30s) and
  keepMovedCurrent (20s) each run bun add with no lock. On the Windows
  box, three concurrent bun add runs (Bun 1.4.3) in one folder kept only
  one writer's package.json change. A git plugin's dependency dropped
  that way leaves Name() unresolved, which is the reporter's github rows.

The exact sequence that emptied the reporter's node_modules wasn't
reproduced. Bun 1.4.2 -> 1.4.3, magpie v0.1.1205 -> v0.1.1227 with the
same plugins, and a package.json reset all left the folders in place.
So this repairs the state and closes the one race found. It isn't
proven to be the trigger.

Run:
- go test ./internal/plugin ./internal/provider -count=1: ok.
- The new tests -count=3 on macOS, and on the Windows box as a
  cross-built test binary: ok.
- Broke each fix by hand (lock a no-op; InstallMissing returns early):
  TestBunCommandsOneAtATime fails with "another bun is running here",
  and TestMissingPluginsInstalledAgain gets 0, want 2.
- Real use on the Windows box, sandbox HOME, port 3561, real Bun 1.4.3:
  deleted opencode-grok-auth and opencode-qoder-auth from node_modules
  and started serve built from this commit. The host logged the
  reporter's exact "no such plugin" for both. At +30s it logged
  "installed 1 missing plugins again" and both folders were back.
  After the restart, no plugin failed to load.
- gofmt -l internal/: clean. go vet for darwin, linux -tags nogui and
  windows (plugin, provider, gateway), and GOOS=windows go build ./...:
  ok.
2026-10-14 09:17:47 +08:00
yetone 8cb0946fbe gateway: a Factory usage-limit 402 that arrives before the account's windows are read rests only that model once they are (#2036, Ziqi-Cui)
#1979 rests only the model when Factory answers 402 "You've reached your
weekly standard usage limit" and the account's windows say Standard's
pool is the one used up. Before the windows are read (just after a
start, or after a reading failed) nothing tells the pool from the
account, so the whole account rested, Droid Core's models with it,
until the reset the refusal named, often days.

Such a rest now starts narrowWhenRead in the background: it waits for a
reading (provider.AwaitAllowance, up to a minute), and if the reading
says the model's pool is the one used up, moves the rest to the model
alone (restID) with the same end. No reading in time, a reading that
says the whole account, or a rest lifted or made again meanwhile leaves
the account's rest as it is.

CodeAlex52's patch (c623610) waited for the reading inside the request
for up to 10s. That holds the failover the client is waiting on, so the
wait is off the request instead: the request has failed over already,
and the rest's scope only matters to later ones. The gateway's TestMain
turns the wait off so no test's goroutine asks a fake upstream after
the test ends; the tests that need it swap it in and wait on
narrowing.

Run: TestFactoryStandardOutLeavesCore's new unread case (built-in and
plugin windows) and TestResetsInWords' no-reading case; the unread case
fails with the narrowing removed; -race -count=3 on both; full
go test -tags nogui ./internal/gateway in a sandbox HOME; gofmt -l
clean; go vet darwin, linux nogui, windows nogui.
docs/subsystems/gateway-routing.md's 402 paragraph says so.
2026-10-14 09:15:21 +08:00
yetone c76842482f agent: Claude Desktop keeps the user's own 3p settings when magpie is turned off and on again (#2035, capiton0)
Settings the user changes in Claude Desktop's third-party window (models
list, allowed hosts, Claude Code for Desktop, the mode chooser and
whatever Desktop adds later) live in the profile magpie made. Switching
Desktop off magpie deleted that profile, so switching on again started
from "{}" and every such setting was gone.

Off now stashes the profile as it was (a non-empty JSON object, under
claude-desktop.profile + the package key) before removing it, and on
writes it back when the profile is missing or empty; the gateway's
address, key and auth scheme are then set over it as before, so only
magpie's own fields are replaced. A stash that isn't a JSON object is
ignored and on starts from "{}" as before.

Run: TestClaudeDesktopOffOnKeepsTheUsersSettings (new) fails on
origin/main (the user's coworkEgressAllowedHosts, inferenceModels and
isClaudeCodeForDesktopEnabled lost) and passes here; go test -tags nogui
./internal/agent in a sandbox HOME; gofmt -l clean; go vet darwin,
darwin nogui, linux nogui, windows nogui.
Not tried: a real Claude Desktop.
2026-10-14 09:15:21 +08:00