Commit Graph
4659 Commits
Author SHA1 Message Date
yetone 31da93ccdc gui: pick the local model from the app's menu (#3578)
Settings → Privacy's "Find with a local model" row gets a picker
beside its switch, the app's own menu (openProtoMenu), not a select:
AstrLink Guard ("Chinese and English, few false alarms in code") and
Privacy Filter ("OpenAI's, masks more ordinary values in code"), each
with its size and whether it is downloaded. It shows only when there
is more than one model. Progress and Cancel follow whichever model is
downloading. Words in zh, zh-TW, ja and de.

privacy-model.test.cjs's new test opens the menu in chromium and
webkit, every language, at 1100 and 640px: both names, the note
translated, the one in use ticked, the menu inside the window, the
pick posted as pick astrlink-guard, and nothing scrolled.

Run at the pushed head: privacy-model and i18n-keys (48/48); mask-*,
masking-records, privacy-*, redact-*, text-size and click-scroll
GUI files in both engines (248/248); TestCoreScriptBudget and the app.js budget
pass without a raise.
2026-10-27 02:01:16 +08:00
yetone a019f4ffc0 masking, settings, gui: the local model the user picks (#3578)
settings.RedactModelName holds the pick ("" for none, read by
pii.Choose), this computer's own like RedactModel, kept by KeepOwn and
by the GUI's settings save. /api/privacy-model returns the chosen
model's status and every model's, and takes {do: pick, model}: picked
while off it is saved for the next On; picked while on it is
downloaded, and once on disk it is saved and the other model stopped.
Remove deletes both. masking runs the picked model.

TestPrivacyModelPick and TestMaskingUsesThePickedModel fail on the old
code (no pick; Privacy Filter always).

Run: go test ./internal/settings ./internal/gui ./internal/masking
./internal/gateway -run 'Mask|Redact|Privacy|PII|Unmasked'
./internal/gwmw at the pushed head.
2026-10-27 02:01:16 +08:00
yetone 0db804999e pii: AstrLink Guard as a second local model (#3578)
pii.Model is a local model (ID, Supported, Installed, Size, Find, Now,
Download, Cancel, Warm, Stop, Remove); pii.Models lists Privacy Filter
and AstrLink Guard, pii.Of finds one by id. pii.Choose decides which
one runs: the user's pick; else Privacy Filter for a user who has it on
or downloaded, so no one's model changes under them; else AstrLink
Guard, the default for everyone who turns the model on from now on.

Why AstrLink Guard as the default. On 234 segments of real code and
config (131 KB: Go, TS, lockfiles, go.sum, CI and agent configs),
Privacy Filter found 100 spans in 26 segments, 39 after redact's checks
(38 go.sum hashes and "Zed"); AstrLink Guard found 2, 1 after the
checks. On the masking eval (42 values to mask, 113 to keep), the
model alone: Privacy Filter 40/42 and 47/113 wrongly, AstrLink Guard
38/42 and 3/113; with the rules and checks both are 41/42 and 1/113.
It is 39 MB, not 1.6 GB, runs on any CPU in magpie's process, and
needs no native helper.

Its three files come from Hugging Face at revision 7216b6a3 (v0.1.3),
each checked against the sha256 in the publisher's SHA256SUMS:
int8/model_int8.onnx 0a070d31…, int8/model_int8.onnx_data 0ba34216…,
int8/tokenizer.json 0cf3b235…; from hf-mirror first in China, as
Privacy Filter's are. It is loaded on the first request and let go
after 10 minutes with none; a failure holds requests back with the
same backoff as Privacy Filter's. Its labels are named as Privacy
Filter's, so redact's checks read both alike.

TestGuardFilesAreThePublishers holds each pinned path and sha256 to
the publisher's SHA256SUMS lines (testdata); it is red with the
tokenizer at the repo root, which is a 404 (found by a real download).

Run: go test -race -count=2 ./internal/pii ./internal/source; a real
download from huggingface.co into a sandbox HOME through
Of(Choose("", false)).Download (8.7s), then Find: 张伟, 13800138000,
zhangwei@example.cn, 北京市朝阳区建国路88号 and an sk-proj key found,
nothing in a go.sum line or "gpt-5.1-codex, go 1.26.8, README.md";
load 104 ms, three texts in 177 ms. All at the pushed head.
Not tried: a real download on Windows or Linux.
2026-10-27 02:01:16 +08:00
yetone 27b4f41264 pii: a model's find, cache and download as a backend of its own
No change in behaviour: Privacy Filter's turn, waiting count, answer
cache, on-disk found file and download state move into a backend and
a dlState, so a second model can have its own of each.

Run: go test -race -count=3 ./internal/pii at the pushed head.
2026-10-27 02:01:16 +08:00
yetone 6e9820a3a4 pii/guard: run AstrLink Guard's int8 model in Go (#3578)
AstrLink Guard (QuantumNous/astrlink-guard, Apache-2.0, on Microsoft's
MIT Multilingual-MiniLM-L12-H384) is a 36.9M-parameter BERT token
classifier for Chinese and English: 21 BIO labels (email, phone,
account, payment_card, ip_address, url, common_secret, private_address,
private_date, private_person), 512-token windows overlapping by 128,
a 0.8 score floor. Its int8 ONNX is 37 MB.

This package runs it with no new dependency and nothing native: an ONNX
protobuf reader for the graph and its external data (onnx.go), the
XLM-R Unigram tokenizer from tokenizer.json (tokenizer.go), and the
encoder with int8 x int8 matmuls (bert.go) on NEON/SDOT kernels on
arm64, SSE2 on amd64 and Go elsewhere (kernel*). Word embeddings stay
quantized (15 MB in memory, not 61 MB). uax29 moves from an indirect to
a direct requirement for the tokenizer's pre-split.

Checked against onnxruntime on the publisher's files: the same spans
on 69 of 71 eval texts, 232 of 234 real code segments and 24 of 25
positive samples; the rest differ by a span edge at the score floor.
One 512-token window takes ~0.5s CPU on arm64 and ~1.2s under Rosetta
on amd64, on a box at load ~100.

Run: go test ./internal/pii/guard (kernels against the Go reference,
tokenizer against the publisher's tokenizer on testdata/tokens.json),
gofmt -l, go vet, GOOS=linux go vet -tags nogui and GOOS=windows go
vet on amd64 and arm64, at the pushed head.
2026-10-27 02:01:16 +08:00
yetone e1709ab42e usage: Append makes the log's folder only when it is missing (#3725)
Every request appends one line to usage.jsonl, and Append ran
os.MkdirAll on the folder first each time: a stat, and on its error
path a walk up the tree. Now the file is opened first, and the folder is
made (then the open tried again) only when that open says it doesn't
exist.

Measured with a scratch benchmark (not committed) at 1360689ef, Append into an
existing folder, -count 5: 3070 B and 25 allocs per call before, 2445 B
and 20 allocs after. Wall time is the write itself, ~45-60µs, and at
machine load ~160 the run-to-run noise was bigger than the saved stat,
so no time saving is claimed. A scratch test with XDG_CONFIG_HOME under
two missing folders checked the first Append still creates them and the
file.

Run at 1360689ef plus this change: gofmt -l clean; GOOS=linux and GOOS=windows
go vet -tags nogui ./internal/usage ok; go test -count=1 -timeout 45m
./internal/usage ok.
2026-10-27 01:58:09 +08:00
yetone 1360689ef2 provider: Served is shared while a request holds the catalog, not copied for each look (#3725)
Served built a fresh copy of the whole catalog on every call: the
unlisted groups' entries plus every provider entry. An Entry is ~1.3KB,
and a request looks at Served from outputLimit, userOutput, askedOutput
and windowIn, so with 12 providers of 20 models each look copied ~380KB
and a request ~800KB, all garbage by the reply.

Served now goes through heldFrom like providerEntries: one slice, built
once while a request holds the catalog and kept across requests until a
file it is built from changes. It is clipped, so a caller's append makes
its own copy and never reaches the next caller. The four gateway loops
take each entry by pointer instead of copying 1.3KB a step. Every
caller of Served (gateway, gui, cli, tui, agent, provider) was read for
writes into the slice or its entries; all only read.

Measured on BenchmarkZZIO (12 providers x 20 models, an 8KB request,
not committed): 1.57MB allocated per request before, 640KB after.

TestServedSharedWhileHeld: under Hold two calls give the same backing
entry, and an append to one doesn't show in the next. Red on the old
code (a new copy each call), green now.

Run at f2aa7fe34 (origin/main plus this change): gofmt -l clean on
internal/gateway and internal/provider; GOOS=linux and GOOS=windows go
vet -tags nogui ./internal/gateway ./internal/provider ok; go test
-count=1 -timeout 45m ./internal/provider (skipping
TestUnreadLoginsWriteErrorsKeepCredentials, #3632) ./internal/gateway
./internal/gui ./internal/cli ./internal/gwmw all ok.
2026-10-27 01:55:25 +08:00
yetone b3b0e1649f gui tests: routing-live-patch's folded bar counts the skills part
83234fe92 put a skills part between tools and memory (PARTS has seven
kinds now), so the folded context window's thin bar draws one more
segment. routing-live-patch's folded case still expected six widths and
was red in both engines on main.

Run at f2aa7fe34: node --test tests/routing-live-patch.test.cjs
tests/routing-context-fold.test.cjs, red 2 of 2 folded cases before
(chromium and webkit, the extra 0%), 34 of 34 after.
2026-10-27 01:51:46 +08:00
yetone f2aa7fe346 plugin: HasGateway looks at the plugins once a second, not on every request (#3725)
Every agent request asks plugin.HasGateway (gatewayHooks, and
GatewayBegin again when on). It read plugins.json through lastgood and
steady, cloned the list, and stat'ed and read every enabled plugin's
package.json. With 12 plugins installed and none with hooks:

  Windows (Ryzen AI MAX+ 395, Defender on): 457µs, 51KB, 360 allocs
  macOS (M4 Pro):                           251-286µs, 36KB, 260 allocs

per call. It now keeps its answer for a second, keyed on plugins.json's
path and filememo.Gen, as middleware.current does: magpie's own writes
(plugin add/remove/on/off all go through save, which calls
filememo.Forget) are seen at once, another program's within a second.
Now 0.5µs/640B on Windows and 0.3-0.85µs/208B on macOS.

Run at b9ab17231 plus this change:
- go test -count=1 -timeout 45m ./internal/plugin ./internal/middleware
  ./internal/gwmw ./internal/gateway: all ok (gateway 541s).
- TestHasGatewayLooksOnceASecond (new) is red with the cache turned off
  by hand ("the plugins were read again within the second"), green with
  it. It also checks filememo.Forget and an expired look see a change.
- The numbers come from a throwaway benchmark (12 plugin dirs with
  package.json, plugins.json with options) run on this Mac and as a
  windows/amd64 test binary on the Windows box, old and new code.
- GOOS=linux and GOOS=windows go vet -tags nogui on the three packages,
  gofmt.

Not tried: a hooks plugin edited by hand outside magpie in the real app
(the test covers the one-second look).

Rebased onto origin/main 3fd7e1698 (no plugin or filememo change between); go build ./... and go test -count=1 ./internal/plugin ok at the pushed head. Before that, at b5d17b26e: go build ./..., linux and windows go vet -tags nogui ./internal/plugin, and go test -count=1 ./internal/plugin ./internal/middleware ./internal/gwmw all ok.
2026-10-27 01:44:57 +08:00
yetone 3fd7e16983 agent: PenguinHarness is installed from the Agents page and served by magpie with nothing to set up
rankyurky asked on Discord #feedback for PenguinHarness (npm
@prismshadow/penguin-cli, command penguin). Every value comes from
Penguin's own source (0.2.17):

- Config: $PENGUIN_HOME (else ~/.penguin/data, every OS) /
  $PENGUIN_PROJECT_ID (else default_project) /.project_config.toml.
  magpie writes [providers.magpie] (base_url, client_type, api_key),
  one [[models]] entry per magpie model (context_window, vision,
  max_tokens, [models.pricing] in usd_per_mtok) and default_model in
  Penguin's own inline spelling. Penguin's server reads the file again
  when its mtime changes, so no restart; a default naming no entry is
  refused by Penguin, so Check fails when one is missing.
- A file magpie creates is 0600 in a 0700 folder, as Penguin keeps it.
  Disconnect restores the user's own default_model (or none), drops a
  magpie vision model, and removes the file when magpie made it.
  Penguin's own entries, providers and command_policy rules are kept.
- A sync that changes nothing writes nothing (bytes and mtime kept), so
  Penguin's watcher isn't woken.
- Install: curl -fsSL https://penguin.ooo/install.sh | sh, or
  irm https://penguin.ooo/install.ps1 | iex on Windows; update: npm, or
  penguin update --yes for the tarball, except on Windows where
  update.ts refuses it.
- WSL: a penguin kind with no restart notice; the WSL test now expects
  an empty Notice for a kind with no restart.
- agentenv: PENGUIN_HOME, PENGUIN_PROJECT_ID; the project id is in
  NotPaths, or appdir dropped a value like "work" as a relative path.
- edit.SetTOMLArrayTables: replaces every [[name]] entry with key =
  value (with child tables) by blocks, or removes them; blank lines
  between replaced entries go with them, and an unchanged result isn't
  written.
- GUI: penguin-color.svg icon; README (en, zh-CN), docs/reference.md
  and docs/subsystems/agent-wiring.md.

Run (worktree at ca9b5048e, GOMODCACHE/GOCACHE pinned):
- go test -tags nogui -timeout 45m ./internal/agent ./internal/edit
  ./internal/agentenv ./internal/appdir ./internal/usage: all ok but
  TestWSLMoreAgentsPick (penguin has no restart notice), fixed in the
  test; rerun -run 'TestWSL|TestPenguin|TestEveryAgent|TestFolderVars|
  TestEveryNotice' ok.
- internal/gui: TestCoreScriptBudget, TestAssetTypesHoldAgainstTheRegistry,
  icon and i18n guards ok; no budget raised.
- GUI Playwright, chromium and webkit: i18n-keys, getting-started,
  agent-cli-missing, agent-update-all, gui-ja, gui-de, gui-zh-tw:
  123 tests, 123 pass. The icon renders in colour in both engines.
- gofmt -l internal/ clean; go vet -tags nogui ./... with GOOS linux,
  windows and darwin clean.
- Real Penguin 0.2.17 (npm, Node 25) in a sandbox HOME against a sandbox
  magpie serve and a fake upstream: penguin run -m "Say PONG" answered
  "PONG from fake" through magpie (usage agent "penguin",
  /v1/responses -> /v1/chat/completions); switching the model in magpie
  took effect with no Penguin restart; a no-op sync kept bytes and
  mtime; magpie penguin default restored the user's custom/my-own and
  left no magpie line; with no prior file it was created 0600 and
  removed on disconnect. The fixture is the file Penguin itself wrote.

- Rebased on origin/main d9a8148d7 and run again there: internal/agent -run
  'TestPenguin|TestWSL|TestEveryAgent|TestFolderVars|TestEveryNotice|
  TestSync', internal/edit, internal/agentenv and the internal/gui
  guards ok; gofmt clean.

Broken by hand, each went red: the no-op skip (mtime test), the 0600
create, the inline default_model spelling, the own-default restore,
removing magpie's file, dropping the vision model, the NotPaths entry,
and both SetTOMLArrayTables fixes (blank-line growth, unchanged write).

Not tried: the full ./... suite (machine load ~190-200, as asked); a
Windows or WSL real binary; Penguin's desktop app; a real vendor key
through Penguin. Penguin sends the openai SDK's User-Agent, so the
agent is named from its key, not its UA.
2026-10-27 01:38:45 +08:00
yetone d9a8148d7c routing: Speed first sends a request to the provider or key that answered the model fastest lately
joeliu96872540 on X: when one model is reachable through several API
channels, they want an option that sends each request to whichever has
been answering fastest, because they compare channel speeds by hand
today. Speed first (`fast`; `fastest` and `speed` also work) is a new
routing beside Free first. It applies to a provider's keys and accounts
(provider editor › Routing) and to a group of one model on several
providers (Routing page › group › Routing).

How it decides. When a streamed answer ends, gateway/speed.go records two
numbers for that account or key and model (restID): the time to first
token and the output tokens per second, as usage.DecodeOf computes them
for the Requests page. Each is a decayed average with a 20m half-life.
After an hour with no answer the record goes stale, and the store holds
at most 4096 records. This is O(1) at the answer choke point, beside
servedCandidate. For a pool routed by BySpeed, weighRouted reads one map
entry per candidate, and only for that pool. The usage history is never
read on a request.

routes.Fastest ranks each awake seat by its estimated time to a
200-token reply: TTFT + 200/TPS. A seat that reported no TPS gets the
median TPS of the others. Seats within 10% of the fastest in their band
keep their listed order, so near-ties don't swap on every request.
Seats with no recent measurement go after the measured ones. One request
in five, counted per pool, goes first to an unmeasured seat, rotating
among them, so each gets measured again. Resting seats go behind the
awake ones, and used-up seats behind those. Rests and failover are the
same as for every other routing.

The request trace gets lateTtft and lateTps, and the row-story sentence
says "answered m fastest lately: first token in 0.8s, 60 tokens a
second". It has a variant for a probe turn and one for when no seat has
been measured yet. i18n covers zh, zh-TW, ja and de. Also updated: the
CLI (`magpie group|provider set <id> routing=fast`, plus a new
`routing=` pair on provider set that refuses manual), the TUI name, the
rotation plugin's Sub, docs/subsystems/gateway-routing.md,
plugin-runtime.md, docs/reference.md and site start.html (en, zh, ja).
There is no new layout: it is one more item in the existing pickers.
app.js stays under its budget with no raise.

Tests:
- routes/fastest_test.go:
  - ordering: fastest first, slow writer loses, alike keep order,
    resting and used-up, median pace, none measured;
  - the probe turn at 5, 10, 15 and 20, rotating between seats;
  - a resting seat never gets a probe turn.
- gateway/speed_test.go:
  - decay, staleness and per-model records, with an injected clock;
  - a group of slowv and fastv routed fast: after the speeds are
    measured and seeded, the request goes to fastv with lateTtft set;
  - the same group routed in order still goes to slowv.
- cli: parseRouting and the provider routing= pair.
- GUI routing-speed-first.test.cjs: the row story for measured,
  no-pace, probe and none, in en, zh, zh-TW, ja and de, in chromium and
  webkit: 40/40.

Broken by hand:
- Fastest returning the listed order: the routes tests and the gateway
  group test go red.
- noteTrySpeed removed: "the streamed answer wasn't measured".
- The client.js case renamed: routing-speed-first 0/20 in chromium.

Run at b5a5caff2 (base 5b4dec58e):
- `go test ./... -count=1 -timeout 45m`, alone on the machine, at load
  130-230. Every package is ok except:
  - internal/provider: TestUnreadLoginsWriteErrorsKeepCredentials
    crashes with "close of synctest channel from outside bubble"
    (#3632, open);
  - internal/gui: TestMainWindowCorners and
    TestTrayCellClickReleasedPanel are killed at their deadline under
    load (#1936, #2645).
- gofmt -l is empty. go vet is ok on darwin, on GOOS=linux with -tags
  nogui, and on GOOS=windows for ./internal/....
- GUI files the change reaches, both engines, every language they test,
  all ok: i18n-keys, gui-de, gui-ja, gui-zh-tw, routing-save,
  routing-save-keeps-the-row, builtins, panel-routing,
  panel-routing-pick, panel-routing-providers, panel-routing-hidden,
  routing-key-windows, key-weight, key-weight-fit, group-member-weight,
  routing-weight-chip, account-arrange and routing-speed-first (40/40).
- routing-group-strategy was 4/18: the menu now has 9 items and the test
  still counted 8. Fixed in this commit; rerun, it is 18/18.
- routing-save-blank (a webkit click timeout) and routing-columns (zh
  "side by side") each failed one subtest at load ~200. Rerun alone,
  they are 4/4 each. Both are already filed (#1924, #1612).

Rebased on 8f023b511, where upstream changed gateway.go, app.js, client.js,
the routing plugin's i18n.js and gateway-routing.md; the rebase was clean.
At this head I reran gofmt, go build ./... and go vet (darwin, linux
nogui, windows) on routes, gateway and cli, and go test for routes, cli,
provider and gateway (the routing and speed tests) and for gui -run
Budget: all ok. The GUI files i18n-keys (4/4), routing-speed-first
(40/40) and routing-group-strategy (18/18) also passed.

Not tried:
- A real run against several channels of one model. Speeds come from
  real answers, so the first minutes after a start are in listed order
  plus probes.
- A non-streamed reply is not measured, a sub-millisecond TTFT is not
  counted, and a restart forgets every speed.
- The Windows runtime: only go vet ran for it.
2026-10-27 01:37:38 +08:00
yetone 78a0dbdd29 gui: a download the network broke off says so, not the signed address
AIMetaPhD on X: Settings › About read "0.1.1618 下载失败 · https://github.com/
…/magpie-windows-amd64.exe: Get \"https://release-assets.githubusercontent.com/
…?sig=…&jwt=…\": EOF". The text was hundreds of characters of signature and
token, and it said nothing about what to do.

/api/update now carries network: true when update.Network(err) is true
(the previous commit's NetError, after its own tries). The Version row
then says "{v}'s download broke off, a network problem. Click Check to
try again, or download it from the release page", translated into zh,
zh-TW, ja and de. The raw error stays in the tooltip. The release page
button the row already had stays. A mirror's failure keeps its own text
(#893). begin() clears the flag along with the mirror.

Run: GUI tests (Playwright 1.62.0, Chromium and WebKit):
update-*.test.cjs (16 files, the new update-network among them) and
i18n-keys, 266 of 266 pass. go test ./internal/gui (ok, 224s); go
test ./internal/update ./internal/cli (ok, previous commit); gofmt -l
clean; go vet; GOOS=windows go vet; GOOS=linux go vet -tags nogui
(./internal/gui ./internal/update).

After rebasing both commits onto origin/main b5d17b26e (its i18n.js
changed), these were run again at this tree: go test ./internal/update
(ok), go test ./internal/gui -run 'Budget|I18n|Update|Asset' (ok), and
i18n-keys, update-network and update-mirror in both engines (36 of 36).

Broken by hand: with the row's new line turned off, update-network
is red, 11 of 11 in Chromium. TestUpdateMirrorSetting now also checks
that a mirror's 404 isn't flagged as a network failure.

Not tried: the real app on Windows, or a real dropped connection, and
the gui-*.test.cjs language suites beyond i18n-keys.
2026-10-27 01:37:04 +08:00
yetone 6335625a60 update: a download that breaks off is tried five more times, from where it stopped
AIMetaPhD on X: on Windows, 0.1.1615 couldn't download 0.1.1618;
GitHub's asset host dropped the connection ("EOF"). The download was
tried three times, two and four seconds apart, each time from byte zero,
and then it gave up. The error also carried the full signed redirect
URL, which the GUI showed.

Now a try the network breaks off (the connect, or the body part way) is
tried again after 2, 4, 8, 16 and 30 seconds. Each later try asks with
Range for the bytes still missing. A host that sends 200 instead has the
file written again from the start, and a 206 whose Content-Range doesn't
start where the file ends is refused. The SHA-256 from the feed is
checked over the whole file read back from disk, so the bytes from
earlier tries are covered. A failure that isn't the network's (a 404, a
checksum mismatch, a write that fails) is not tried again, and the file
is removed. The error is a NetError that names the file and the cause
("the download of magpie.exe.new broke off (EOF)"), never the address.

Release timing was checked and is not the cause. v0.1.1618's
magpie-releases release was created at 16:32:48Z, its assets were
uploaded from 16:36:13Z to 16:36:17Z, and it was published at
16:36:18Z. The feed reads only releases/latest, which skips drafts, and
needs SHA256SUMS, so it couldn't name 1618 before its files were there.
The URL in the screenshot is the asset host's redirect, which exists
only for an uploaded asset.

Run: go test ./internal/update ./internal/cli (ok); gofmt -l clean;
GOOS=linux and GOOS=windows go vet ./internal/update. New tests run on
httptest servers: a body cut mid-stream twice (resumed with
bytes=102400- and bytes=307200-, file and progress whole), a resume
with the wrong bytes (checksum fails, nothing kept), a connection hung
up before any answer behind a redirect to a ?sig=&jwt= URL (six tries,
and the error holds no URL), and a 404 (one try).

Broken by hand: without the Range header the resume test is red
(ranges "" "" ""); with the NetError keeping the url.Error the address
test is red (the signed URL in the text); with three tries it is red
(tries = 3, want 6).

Not tried: a real self-update on this machine or the Windows box, or a
real cut connection to GitHub. The China mirror and the user's
UpdateMirror get the same Range header; a mirror that ignores it sends
200 and the file is written again from the start.
2026-10-27 01:34:26 +08:00
yetone b5d17b26e0 gateway: Antigravity's 429 to Codex's GPT-5 prompt says why and rests nothing, on the web-search path too (Jodiezzzzzz on X)
From Codex, every call to antigravity/claude-opus-5-5 failed with
"exceeded retry limit, last status: 429" while dsh worked on the same
account. The call was an agent_created_thread, and the vendor said
"Resource has been exhausted (e.g. check quota)".

Cause: a Codex thread begun on a GPT-5.x model keeps "You are Codex, an
agent based on GPT-5..." as its first developer message after /model,
resume -m or a fork, and magpie lifts it into systemInstruction.
Antigravity answers that line with a fake 429, whatever quota is left,
as it does Claude Code's (#666). Codex also sends a web_search tool every
turn, so for an Antigravity model magpie serves search itself (translate
-> searchReply -> askTranslated), and that path passed the bare 429 back:
no hint, no 400, so Codex retried to its limit.

- antigravityTurnsCodexAway: the two Codex GPT-5 opening lines count as
  a turned-away prompt; antigravityHint picks the Codex hint for them.
- antigravityRound wraps the search path's ask, so its 429 and an
  in-stream refusal get the same 400, hint and no rest as translate's.
- antigravityForeseen returns the hint, so a group skips Antigravity for
  the next 6h saying which prompt.
- The Routing page shows the new hint (routing/client.js HINTS) in en,
  zh, zh-TW, ja and de.
- Rest: none. The refusal is about the prompt, not the account (Fail
  "prompt"); a second account answers the same.

Plugins: middleware-antigravity-cloak 0.1.1 (plugins a52d1b3) breaks
the two Codex lines with U+200B. Its body says "npm had 0.1.0": wrong,
the package is not on npm; dist had 0.1.0 and now has 0.1.1 (6fd1438).
No mover applies.

Real account (owner's Antigravity, sandbox HOME copy, gateway built from
this branch) and real Codex 0.162.1:
- codex exec resume <a gpt-5.5 thread> -m antigravity/gemini-3-flash:
  before, 429 retried to "exceeded retry limit"; after, one request and a
  400 with the Codex hint; route try (429, prompt), no rest.
- A new Codex chat on the same model: 200.
- The two lines with U+200B after the first letter: 200; whole: 400.

Broken by hand:
- antigravityTurnsCodexAway returning false: the Codex tests go red
  (Codex got 429; the group's skip doesn't say why).
- The antigravityRound wrap removed: the search=true subtests go red
  ("Codex got 429").

Run:
- go test -count=1 -timeout 45m ./internal/gateway/: ok (476s, at
  865df2472; main's next three commits touch only GUI files).
- go test -count=1 -timeout 45m ./internal/gui/: ok (230s, at the pushed tree on a6d7e02c7).
- gofmt -l: clean; go vet ./internal/gateway/ for darwin, linux, windows.
- GUI, chromium and webkit: routing-ag-turned-away, i18n-keys, gui-ja,
  gui-de, gui-zh-tw, routing-wb-refused, routing-blocked 41/41; at the
  pushed tree routing-ag-turned-away, i18n-keys, routing-steps-cap and routing-js 34/34.
- Rebased on b9ab17231 (routing client.js): routing-ag-turned-away,
  i18n-keys, routing-free-seat 45/46, the red webkit zh-TW `.rt-day`
  click timeout at load 163 (#3781's class); routing-ag-turned-away
  alone 20/20 after. go test -run 'Budget|I18n|Hint|Routing' on
  internal/gui and internal/gateway: ok.
- Rebased again on 68ee4117a (gateway: gemini_schema, unrouted,
  masking wait): gofmt, vet x3, and go test -run
  'Antigravity|CodeAssist|Search|Gemini|Unrouted|Masking|Translate|Continu'
  ./internal/gateway/ ok; the whole package was not run again at this
  tree.
- Under load 89-150: TestTrayCellClickReleasedPanel killed at 20s
  (#2645), routing-js webkit zh (#3774), panel-routing and
  routing-zcode-blocked webkit zh click timeouts (#3781). All pass alone.

Not tried: Claude Opus itself (the sandbox account's free-tier Claude
quota was spent while probing, so gemini-3-flash stood in; the prompt
check is model-blind); the cloak installed in a running magpie; the
Windows box; the full GUI suite.
2026-10-27 01:33:53 +08:00
yetone 68ee4117af gateway: a Gemini model's untyped tool schemas go typed (Vertex refused cua-driver's drag)
kthink on Discord: dsh with cua-driver's MCP tools on Command Code's
google/gemini-3.8-flash (the commandcode plugin), every request 400
INVALID_REQUEST from Vertex: "`mcp__cua-driver__drag` functionDeclaration
`parameters.target` schema didn't specify the schema type field."
cua-driver's drag schema before cua's #4888 has target as an anyOf of an
untyped oneOf and null, and scope a const with no type. Command Code's
gateway turns JSON Schema into Vertex's Schema object, whose type is
required, and an untyped node stays untyped.

geminiToolTypes (forwardOnce, so plugin requests too) is keyed on the
model id (last '/' segment starts with "gemini"), not the provider:
each untyped schema under tools' function.parameters / parameters /
input_schema gets the type its enum/const, keywords or branches say,
null left out; {} or a description alone is a string, a tool root an
object. Mixed-type unions, unresolved $ref/unions and anything under
not/if are left as they came. Written in place after the brace, so the
rest of the body is unchanged. withTypes no longer writes a trailing
comma into an empty {} (it produced invalid JSON there).
Google's own Gemini API / Code Assist (parametersJsonSchema) and
Antigravity (plainSchema) bodies have no such tools and are not walked.

Run at this tree, rebased on origin/main 8f023b511 (tests and vet run again there; GOMODCACHE/GOCACHE pinned):
- go test ./internal/gateway/ -run 'Gemini|Kimi|Grok|OneOf|PlainSchema|Tool|LoopGuard|Doc' -count=1: ok
- gofmt -l internal/gateway/: clean
- go vet ./internal/gateway/ (darwin), GOOS=linux go vet -tags nogui,
  GOOS=windows go vet: ok; go build ./... for darwin, linux (nogui), windows: ok
- Not run: the full ./... suite (machine load ~200, other sessions' suites).

Broken by hand:
- geminiToolTypes call commented out of forwardOnce:
  TestGeminiToolTypesCuaDriverDrag red on chat, messages and responses.
- emptyObjectAt check replaced by true: TestGeminiToolTypes red, invalid JSON.

Tests: TestGeminiToolTypesCuaDriverDrag uses cua-driver's literal old drag
schema (testdata/cua_driver_drag_untyped.json) through the server on
/v1/chat/completions, /v1/messages and /v1/responses; a GPT model on the
same provider gets the tools byte for byte. TestGeminiToolTypes covers the
type rules, and that claude/gpt/gemma/kimi ids get the body bytes.Equal.

Not tried: a real Command Code account or a real Vertex request; the
schema's acceptance by Vertex is from its documented Schema object and
cua's own Vertex lint (cua-driver-testkit vertex.rs), not a live call.
2026-10-27 01:28:39 +08:00
yetone 8f023b5119 pii: a long text goes to the masking model in overlapping pieces, a piece at a time, each kept (#3682)
A text over 12 KB was sent to pf-serve whole. On a weak GPU one such
text could take longer than classifyTimeout, so the request failed and
nothing was kept, and every other request waited behind it.

Now find.go cuts a long text into pieces of at most 12 KB (pieceSize).
Each piece overlaps the one before by up to 1 KB, cut after a line's
end where there is one, else after a space, else at a rune's start.
- Each piece is cached on its own, so a request stopped part way and
  sent again asks only about the pieces not done yet.
- Spans are shifted to the text's offsets and merged: overlapping
  spans become one with the longer one's label, and same-label spans
  that touch are joined.
- pf-serve gets one chunk per call. The turn is given up between
  chunks, so a short request waiting for the model goes next instead
  of after the whole long one.

Run:
- go test -count=1 ./internal/pii/: ok.
- gofmt -l and GOOS=linux/windows go vet ./internal/pii/: clean.
- go test -count=1 -timeout 45m ./internal/pii/... ./internal/gateway/...
  at f8b58fb48 (this change on origin/main 865df2472): pii ok 31s,
  gateway ok 571s. GOOS=linux/windows go vet of every package without
  Wails (88), and GOOS=windows go vet ./...: clean.
- Real model (pf-serve v2 Metal, q8 model from ~/.cache, M4 Pro) on a
  96 KB generated text with names, emails, phones and keys, sent whole
  and in its 9 pieces: 2208 spans either way, 2206 the same. 2 were
  found only whole and 2 only in pieces, none at a cut (model context,
  not the split). Pieces took 1.23s against 2.06s whole.

Broken by hand:
- No yield between pieces: TestShortRequestGoesBetweenPieces red.
- No cache put per piece: TestLongTextKeepsPiecesWhenStopped red.
- merge as a no-op: TestMergeAcrossPieces and
  TestLongTextFoundAcrossPieces red.
- pieceOverlap = 0: TestLongTextFoundAcrossPieces red (the name cut
  in two was not found).

Not tried: a real weak GPU (Vulkan) with a long text, and span quality
on a real PII corpus. The comparison above uses generated text.
2026-10-27 01:14:23 +08:00
yetone 16f6e568f4 gateway: masking's time no longer counts toward the 2 minutes before routing (#3682)
yunwang2442-creator: a 480 KB request the local masking model takes 90s
over on an RX 470/580 (more on its CPU, and more behind the requests
ahead of it in the model's one turn) was answered 504 at unroutedMost,
2 minutes from its arrival, its masking cut off, and the same again
each time it was sent.

unroutedMost now counts the request's time other than masking: a
masking (noteMasking), its wait for the model's turn with it, is
tracked like the known waits, and most's timer (checkMost) looks again
when the last masking ends, with what is left. unroutedUnknown is as
before.

Reconciled with 5a94eec3a, not taken as the report wrote it: the report
asked for unroutedMost to count only unknown waits. Next to the 30s
unknown bound that is dead code (unknown fires first), and a known wait
that hangs (a plugin's gateway hook, an image description never ending)
would be held for good, the heyusaku6 case. So only masking is left out.
Masking stays bounded inside internal/pii: classifyTimeout per request
to pf-serve, gpuLoadTimeout/loadTimeout per load, and a model that keeps
failing holds requests back at once (heldBack, retryAfter); a client
that leaves lets go of the turn's queue (FindContext).

The masking 504 message no longer says "what the model has already
read is kept, so it goes quicker": a request cut off mid-read had
nothing kept. It is reached now only by a masking begun as the rest of
the wait ran out.

TestHeldForTheMaskingModelSaysSo, which held a request at the model
past unroutedMost and expected the 504, is now
TestMaskingModelWaitNotCutOffAtMost (no answer past 5x unroutedMost;
the model's wait lets go when the client leaves) and
TestUnroutedMsgSaysTheMaskingModel (the message's words).
TestUnroutedMostLeavesOutMasking: masked 3x unroutedMost, not answered;
then held by an image description that never ends, answered 504.

Run: go test -count=1 -run 'Unrouted|Masking|Held|Mask'
./internal/gateway/ ok; go test ./internal/pii/ ok; gofmt -l clean;
GOOS=linux and GOOS=windows go vet of both ok. Full gateway and pii
run before the push, recorded in the last commit of this set.
Broken by hand: checkMost counting from arrival again
(TestMaskingModelWaitNotCutOffAtMost and TestUnroutedMostLeavesOutMasking
red, 504 while masked); checkMost never giving up
(TestUnroutedMostLeavesOutMasking and TestUnroutedRequestShownThenAnswered
red).
Not tried: a real long request through a real pf-serve on a weak GPU.
2026-10-27 01:14:23 +08:00
yetone dd5b0ab311 pii: a GPU too slow for one request is tried again, and a lost GPU comes back without a restart (#3682)
yunwang2442-creator's RX 470/580 (Vulkan): a 480 KB request ran past
classifyTimeout, magpie ended pf-serve, and classifyTurn set srv.cpu on
any GPU error. Nothing cleared it short of a restart of magpie, so every
request after it ran on a CPU about 3x slower. A slow request is not a
lost GPU.

Now:
- ended for taking too long on the GPU (h.slow), the try again is on
  the GPU; a second one in a row is a lost GPU, and the CPU is tried;
- a GPU that dies answering, or whose load hangs (cebd0d4c3, kept), is
  lost at once, as before;
- a lost GPU is tried again after gpuRetryAfter: 10 minutes, doubling to
  2 hours while it keeps failing. The CPU's pf-serve makes way for the
  GPU's at that request; one that fails moves back to the CPU, for
  longer;
- a GPU that answers clears cpu, gpuLost and the count.

Tests (fake pf-serve modes gpuhang, gpuhangonce, gpudiesonce):
TestGPUTimeoutStaysOnGPU, TestGPUHungTwiceMovesToCPU,
TestLostGPUTriedAgain, TestGPURetryAfter; they use gpuInstall, so the
GPU is Vulkan's off macOS.

Run: go test -count=1 ./internal/pii/ ok; the four with gpuInstall's
Linux branch forced on macOS, ok; gofmt -l clean; GOOS=linux and
GOOS=windows go vet ./internal/pii/ ok.
Broken by hand: the slow request's GPU retry removed (TestGPUTimeout-
StaysOnGPU and TestGPUHungTwiceMovesToCPU red); the gpuAgain retry
turned off (TestLostGPUTriedAgain red); a GPU's answer not clearing
the state (TestLostGPUTriedAgain red).
Not tried: a real Vulkan GPU, or a real GPU hang; the GPU's reload on a
retry is a fake's here.
2026-10-27 01:14:23 +08:00
yetone c84f859dd0 pii: the GPU tests start pf-serve-vulkan off macOS, so they pass on Linux (#3741)
TestFindJoinsTextsAndMapsBack, TestGPUDeathMovesToCPU,
TestServeStartsWithoutResidencyHeartbeat and TestWarm were red on
ubuntu CI (run 40351272355 at 80857a66c, and earlier). The cause:
cebd0d4c3 made candidates() put a GPU pf-serve first only where there is
one, pf-serve-vulkan or macOS's Metal pf-serve. The tests installed
pf-serve alone and expected it on the GPU ("start pf-serve MTL0"), which
holds on macOS only; on Linux it is the CPU's alone.

gpuInstall installs macOS's pf-serve there and pf-serve-vulkan elsewhere,
and says the GPU's start line; the four tests use it. The code isn't
changed.

Run: go test ./internal/pii/ (ok, macOS). The Linux branch forced on
macOS (gpuInstall's darwin check made false, so pf-serve-vulkan is
installed as on Linux): the four tests pass. GOOS=linux and
GOOS=windows go vet ./internal/pii/ ok.
Not tried: a Linux machine itself (no Docker daemon here); the next CI
run is the check.
2026-10-27 01:14:22 +08:00
yetone 7279bdc28b pii: pf-serve-vulkan runs its MoE in 2048-token chunks unless the user set PF_MOE_CHUNK (#3682)
yunwang2442-creator (#3682, Windows, RX 470/580-class 8 GB GPU through
Vulkan, q8 model): with privacy-filter.cpp's default PF_MOE_CHUNK (4096)
a 480 KB text took 159s and was killed at classifyTimeout's 150s; with
2048 it took 90s, and 2048 was 1.77x faster at every size from 24 KB to
480 KB and the fastest of 1024/1536/2048/2560/3072 on 48 KB.

What PF_MOE_CHUNK is (privacy-filter.cpp at the pinned 735a6c286,
src/model.cpp and docs/cpu-perf.md): the MoE FFN runs over the window's
tokens in chunks of this many; per-token, so exact (no halo). Its default
is the forward window (4096), where it is inert. So 2048 changes speed
only, not what is found.

Measured here, M4 Pro, Metal, the real pf-v2 pf-serve and q8 model run
directly (not through magpie, ~/.config/magpie untouched), interleaved
A/B, two rounds of two runs, at load ~250 from other sessions:
  24 KB: 4096 0.40-0.43s, 2048 0.44-0.45s, 1024 0.49-0.66s
  96 KB: 4096 1.86-1.92s, 2048 1.98-2.15s, 1024 2.22-2.27s
  spans the same (5) at every setting.
So 2048 is ~6% slower on Metal: magpie sets it for pf-serve-vulkan only.
macOS's Metal pf-serve and the CPU's keep the engine's default. A
PF_MOE_CHUNK in magpie's environment (set, even empty) is the user's and
is inherited by every pf-serve, never overridden (moeChunk).

Run: go test ./internal/pii/ -run 'TestVulkanServeGetsMoEChunk|
TestServeStartsWithoutResidency' (ok). The full ./internal/pii/...
./internal/gateway/... run is recorded on the last commit of this stack.
Broken by hand: moeChunk ignoring the user's value -> the "user's own"
case red (2048 where 3072 was set); moeChunk never matching Vulkan ->
the "vulkan" case red.
Not tried: a real Vulkan GPU (none here; the 1.77x is the reporter's
measurement), an NVIDIA or Intel GPU through Vulkan, where 2048 may be
slightly slower as on Metal.
2026-10-27 01:14:22 +08:00
yetoneandMYCF711 b9ab172318 routing: a seat whose model costs nothing says free, not "100% used" (#3763)
On the Routing page a seat serving a model its vendor gives away
(Weighed.free, OpenCode Zen's *-free models under Free first) read
"100% used" with a full bar: the account's windows are what the rest
of it costs, not this model, so the one seat that can always answer
looked spent. Its row now says "free · costs nothing" (zh, zh-TW, ja,
de too) and draws no bar. A resting free seat still says its rest
first, and a paid seat beside it still says its share.

MYCF711's patch (pr/free-seat) built the case on free seats with no
routing, which the gateway never sends: .free is set only where
weighRouted weighs by it, so a real free seat always carries its
routing and read "100% used", not "all but used up". The test is
built on that real shape. Not taken from the patch: the green status
colour (UI restraint; the word says it) and the `low` change, which
no real free seat reaches. Their German string would have failed
their own test's /verbraucht/ check; this one is "kostenlos · zählt
nicht zum Kontingent".

Run: tests/routing-free-seat.test.cjs (new), chromium and webkit,
en/zh/zh-TW/ja/de at 1100px and 420px, 22/22. go test ./internal/gui
-run 'CoreScriptBudget|I18n|Strings|Plugin' ok. The routing,
panel-routing and i18n GUI files ran at concurrency 6 under load
280-300 from other sessions: 49 timeouts in 12 files, none of whose
fixtures has a free seat, and the run was stopped there. Those 12
files again, one at a time: 50 ok, 5 red in two
files: routing-intent-entry's "Add a rule makes a rule by intent" at
1100px (red the same alone on origin/main ca9b5048e, 2 of 8; #3408)
and routing-keys-fold's "flies to the fold" in chromium ja and de
(red alone on origin/main ca9b5048e too, 5 of 32; #1612, #2658).
i18n-keys 4/4. Again at the pushed head, on a6d7e02c7: routing-free-seat
and i18n-keys 26/26, the gui Go budget/i18n tests ok.
Broken by hand: old client.js, the test is red ("100% used"); with
the status line kept and only the bar check removed, 11/11 red in
chromium.
Not tried: a real OpenCode Zen account in the GUI.

Co-authored-by: MYCF711 <MYCF711@users.noreply.github.com>
2026-10-27 01:04:53 +08:00
yetone a6d7e02c77 gui: a page wheeled right after a click scrolls on macOS 13's WebKit too (issennknight on Discord)
issennknight (macOS, trackpad): every page scrolled again, but a saved
profile opened on the Agents page and then scrolled through often stayed
where it was. macOS 13's WebKit scrolls a view under wheels it never
dispatches, so the view guard puts each such scroll back and takes three
put back the same way within a second as the reader's run (30d3001a0).
That rule skipped every put-back while a click held what it clicked, and
a click holds for 4s: a profile opened and wheeled through at once was put
back on every scroll and the page stood still ("sometimes" = within 4s of
a click). A wheel the page hears was fine.

Now a held view's put-back is the hold's only when the page was redrawn
since the hold last held it (the view's height, or where the first held
parts sit, moved from what hold() left in h.lay). A scroll with the page
laid out as the hold left it counts as at rest, so the reader's run is
given back a click before it too. One scroll by code after a click is
still put back: view-wheel-unheard's last case now checks that (its old
per-frame code scroll is a run, given back by design).

Other inner scrollers checked: the panel's Profiles popover (overflow
auto, overscroll-behavior contain) is outside any .view and the guard;
the provider editor's .mchips keeps contain except under 640px tall, an
earlier deliberate call, left alone.

Tests:
- New view-wheel-after-click.test.cjs: wheels (unheard and heard) over
  the long profile's details right after the click, to the foot, past it
  and back up; the short one's too; nothing but the view scrolls. en, zh,
  zh-TW, ja, de at 420 and 1000 wide, Chromium and WebKit. Red on
  origin/main's assets (MAGPIE_AFTER_CLICK_ASSETS) in 20 of 24 subtests,
  "ten wheels of 30px right after the click scroll the page: from 153 to
  153"; the heard cases pass there. Green with the change.
- Before the rebase, 59 GUI files the change can reach (every scroll/wheel/view-/click/
  hold/held/keep/profile/unroll/jump/stay/still file, old-webkit,
  text-size, sidebar*, last-page, routing-days-fit, routing-failed-open,
  update-auto, i18n-keys, gui-de/ja/zh-tw), both engines, at
  --test-concurrency=4 on a box at load 130-160: 810 of 816 pass. Reds,
  each red alone on origin/main 865df2472 too: menu-input-scroll (#3402),
  old-webkit Safari 15.0 (#3403), quota-holds WebKit (#3777, new);
  routing-scroll-end 440x620 "stage's columns 3 !== 2" under load, 22/22
  alone on both (#3778, new). The whole GUI suite was not run: other
  sessions' GUI suites held the machine.
- go test -tags nogui ./internal/gui ok before the rebase.

At the pushed head (rebased on ca9b5048e, which touched app.js): the budget
tests ok (app.js 1,314,407 bytes of 1,321,319, not raised), and
view-wheel-after-click, view-wheel-unheard and click-scroll pass 54/54 in
both engines. The 59-file run above was at the base de54b4ff9.

Broken by hand: putting back the old gate (any put-back under a hold
skipped) turns the new test red as above. Removing the new redraw gate
(h = false) is not caught by a test: in both engines a redraw under a
click is held by heldSizes before the guard hears a scroll (logged: no
put-back during a 30-frame shrink at the foot), and the synthetic
redraw fixtures I tried passed with the hold removed too, so none is
shipped.

Not tried: real macOS 13 / WebKit 16.6 and a real trackpad; the unheard
wheel is a capture listener stopping the wheel event.
2026-10-27 00:54:18 +08:00
jayswu ca9b5048e3 routing: a request tried on many keys keeps its steps in a box of 200px, so the list below stays where it was (#3764)
A trace tried on 40 keys says a line or two a key, so .rt-steps grew
to ~2500px and pushed the request list a screen down; clicking between
it and a one-key request moved the list by that much each time
(hheei's analysis in #3764). The list now holds at most 200px (eight
or so steps) and scrolls in itself; short stories start at its top as
before.

jayswu's patch (their branch gui/cap-routing-steps-height, ported here
since the repo takes no outside PRs). One change to it: a different
request's story starts scrolled to the top, and that reset now runs
before renderSteps' "nothing changed" return. In the patch it ran
after, so two requests whose stories read alike (the same keys
refused the same way) kept the first one's scroll.

Run at base 479de8900 plus this change, then rebased on 865df2472
(nothing under routing/ or app.js changed between them):
- new tests/routing-steps-cap.test.cjs, chromium and webkit: 2 of 2
  ok, again at the pushed head. Broken by hand: without the CSS cap, red ("the story's box grew
  to 2518px"); with the reset where the patch had it, red ("another
  request's story opened scrolled down", 400 !== 0).
- go test -tags nogui ./internal/gui/: ok (71s).
- every routing-*.test.cjs plus i18n-keys, --test-concurrency=4 at
  load ~100: 531 ok and 5 red when this was written (the run goes on).
  Of the reds, routing-intent-entry is #3408; routing-affinity-cache-
  write, routing-idle-frame and routing-js each pass whole when run
  alone and are filed as #3772, #3773 and #3774.

Not tried: the real app with a real 40-key provider; the steps box is
CSS only and the test draws the real page.
2026-10-27 00:46:24 +08:00
yetone 7395b7b77e gui: magpie's "API key" and "Signed in" labels aren't hidden as accounts
outloudvi on Discord: with Hide accounts on, the Plugins page blurred
"API key" in Kiro's summary ("…or an API key"). A plugin's account with
no name is labelled "API key" or "Signed in" by pluginLabels (with
" (2)" for a second one), and every account name was hidden wherever it
appeared, so any sentence with those words was blurred too. They are now
in NOT_ACCOUNTS, the " (n)" slot suffix stripped before the check. A
key's tail ("API key …abcd") is still hidden.

Run:
- account-mask.test.cjs, with Kiro accounts "API key" and
  "Signed in (2)" and a sentence holding both words: 4/4 (chromium,
  webkit, en, zh). On the old app.js it is red 4/4.
- privacy-hides-accounts, account-eye, window-mask, mask-emails and
  account-alias: 68/70 at load ~200. The reds were different webkit
  subtests each run (5s timeouts in account-alias and account-eye), so I
  counted them as load and didn't file them.
- i18n-keys 4/4; go test ./internal/gui -run Budget ok.
Not run: the whole GUI suite, and the change in the real app.
2026-10-27 00:45:09 +08:00
yetone 865df24727 gateway: a Chat stream's tool calls sent by turns are read by index, one call each
mysterious_dove (Discord, on 098ac9696): a Chat upstream that streams two
tool calls' fragments by turns (index 0, 1, 0, 1, 0, 1, the first of each
with id and name, the rest only arguments) reached Codex as six
function_call items: the first two with their names and `{}`-ish partial
arguments, four with no name, half the arguments and fresh ids.
chatDecoder started a new call at every change of index.

chatDecoder now reads fragments by tool_calls[].index (toolCall). The open
call streams as it comes; a call that starts while the open one's
arguments aren't yet whole JSON is held by its index and given whole, in
index order, at finish_reason or [DONE]. A sequential stream streams as
before; a repeated id still continues its call, a new id at the same
index still starts the next one.

Siblings: every Chat-to-X translation (Responses, Anthropic Messages,
Gemini, a whole reply via collector) reads through chatDecoder, so all
are fixed here. Checked and unchanged: chattidy's streamCallIndexes,
chat_call_ids, grok_integral, whole_stream and textcalls already key by
index or build no calls from fragments.

Tests (translate_stream_test.go): TestInterleavedToolCallsToResponses
(the exact interleaved stream: 2 function_call items, whole JSON args,
index order, one output_index and item id per item across added/delta/
done), TestInterleavedToolCallsToAnthropic (2 tool_use blocks),
TestInterleavedToolCallsWhole (2 calls), TestToolCallsNamedFirstThenArgued
(names first, then args, [DONE] with no finish_reason).

Broken by hand: with origin/main's chat.go put back, all four fail
("6 function_call items, want 2"; 6 tool_use blocks; 6 calls of fragments).

Run at this head (rebased on d157700a0): go test ./internal/gateway/ -run
'TestInterleaved|NamedFirst|ToolCall|Parallel|ChatTranslation|RepeatedToolCall'
ok; gofmt -l internal/gateway/ empty; go vet, GOOS=linux go vet -tags
nogui, GOOS=windows go vet ./internal/gateway/ ok.

Not tried: the full `go test ./internal/gateway/... -timeout 45m` before
the push: other sessions' gateway suites held the machine for 2h (load
150-200) and a second suite at once would only time out; it runs after
the push. Not tried against the reporter's real upstream; the fixture is
built from the report's description, not captured bytes.
2026-10-27 00:28:06 +08:00
yetone d157700a0a gateway: a request naming no reply limit asks DeepSeek, and a translated one any vendor, for the model's own
xuanwo on X (tweet 2114748847167815951): Codex on DeepSeek kept ending
"stream disconnected before completion: Incomplete response returned,
reason: max_output_tokens". Codex names no max_output_tokens, magpie
relayed its turn to DeepSeek's /v1/responses as it came, and DeepSeek
reads no limit as 8K without thinking and 64K with it (its
create-chat-completion docs: "When not set, the default is 8K in
non-thinking mode, 64K in thinking mode"), where deepseek-flash and
deepseek-v4-pro give 384K (393216, its /v1/models and pricing page).
Reproduced on api.deepseek.com with the owner's key: deepseek-flash,
effort none, no limit: status incomplete, reason max_output_tokens, at
8192 output tokens; with max_output_tokens 393216: completed at 17602.

- Relayed or translated, a request naming no reply limit, to DeepSeek's
  own API (api.deepseek.com, shortByDefault), is sent the model's own
  limit (askedOutput: the user's Max output, else the vendor's list or
  models.dev, within the window), in the client's words: Responses
  max_output_tokens, Chat max_tokens, Gemini generationConfig.
  maxOutputTokens. A relay serving DeepSeek's models elsewhere goes as
  it came: its default isn't DeepSeek's.
- Translated onto a vendor's Chat or Responses (fillsOutput), a request
  naming none is sent the model's own, as on Anthropic's since #1792:
  the client's API reads none as the model's whole, a vendor's needn't.
  Not for an account's own backend (the ChatGPT one turns
  max_output_tokens away) or another magpie (it fills its own). A
  vendor that turns the filled figure away ("max_tokens" in a 400/422
  that isn't the window) is asked again naming none, and from then on
  (outputFillRefused).
- The window: DeepSeek counts the reply asked for in its 1M window. The
  existing room retry (replyLeft) asks again for what the window left;
  withReplyCap now also adds the field to a Gemini body, which it
  couldn't before, so a Gemini client's long conversation isn't
  refused where DeepSeek's default fitted.
- A limit the client named goes as it is, everywhere. A reply DeepSeek
  cuts on length still reaches Codex as incomplete / max_output_tokens
  (relayed as DeepSeek says it; translated by responses.go's length
  stop), unchanged.

Tests: TestShortDefaultAsksTheModelsOutput (DeepSeek relayed on
Responses and Chat, the client's own limit kept, a Gemini client
translated, and a relay's Responses and Chat with the same model sent
no limit), TestTranslatedAsksTheModelsOutput (Codex onto a Chat-only
vendor: the catalog's 65536; the client's 700 kept; a vendor refusing
past 32768 is asked again naming none, and not filled again).
Broken by hand: withOwnOutput returning the body as it came turns the
two DeepSeek relayed cases red; fillsOutput false for Chat/Responses
turns the translated case red; the refusal retry off turns the refusal
case red (400 to the client).

Real run (sandbox HOME, only the owner's DeepSeek provider copied, this
build serving on 127.0.0.1:3481): a streamed Codex-shaped Responses turn
to deepseek/deepseek-flash naming no limit, asking for ~17K tokens:
response.completed, 17602 output tokens (8192 and incomplete before, as
above). A 699015-token Codex turn: DeepSeek refused 393216 against its
1M window, magpie asked again with max_output_tokens 349561 (the window
left), response.completed.

Run: gofmt -l clean; go vet ./internal/gateway on darwin, linux and
windows; go test ./internal/gateway (whole package) -count=1
-timeout 45m: ok (465s) at base 479de8900.

Not tried: deepseek-v4-pro with thinking on (64K default) in a real
run, only flash with effort none; a plugin provider for real (its path
is forwardTranslated's, covered by the translated test with an API-key
vendor); other vendors whose Chat default is small (Kimi, GLM, MiniMax)
on their relayed path, which this leaves as it was: only DeepSeek's
default was checked against its docs and its API. The full ./... suite
(only internal/gateway changed).
2026-10-27 00:25:18 +08:00
yetone 479de89001 gateway: Codex's model list is asked of the backend once for every app-server, and kept, so it comes within Codex's 5 s (#3734)
#3734: with ~20 Codex app-servers starting together, Codex logged
"failed to refresh available models: request timed out" 1,906 times a
day, fell back to its default metadata for magpie's groups (no
supports_search_tool), and inlined ~1,075 Apps tools: ~500K input tokens
a turn.

Each /backend-api/codex/models asked the ChatGPT backend on its own, and
gave its ask up at codexModelsWait (3 s). Measured with a minimal
gateway (gateway.New().Handler() alone, sandbox HOME, no providers), 20
lists at once with a real ChatGPT sign-in's headers, as app-servers ask:
- 4a33cf0a9: mean 2.24 s, max 3.01 s; the one at 3.01 s was handed an
  empty list (16 bytes), the backend asked 20 times. Again right after:
  mean 1.04 s, max 1.72 s, 20 asks again.
- this change: mean 1.72 s, max 1.74 s, all 20 the full list (568,401
  bytes) from one ask; again right after: max 0.01 s.

Now the backend's list is kept for each sign-in (account id, the
backend, Codex's version): within codexListFor (a minute) it is handed
out again; past it, handed out at once while one ask goes; with none,
the callers wait on the one ask for up to codexModelsWait as before,
and the ask goes on, up to 30 s, for the callers after, where a backend
slower than the wait had never got a list through. A 401 or 403 is
still Codex's to see, and no list from before is handed out in its
place. Each caller reads its own copy, since the windows, picks, V1
stamp and auto-review are written into the entries.

What changes for users: the account's own models (not magpie's, whose
part is built per call) are up to a minute behind the backend.

Not changed: Codex's own 300 s cache and the build of magpie's part
under provider.Hold (#746); no model_catalog_json floor is written.

Tests (codex_models_shared_test.go):
- 20 lists at once, the backend held: each answered with magpie's
  models and Codex's last list, the backend asked once; let go, its
  list reaches the next caller; fresh, five more ask it no more. On
  4a33cf0a9: asked 20 times, then 5 times more.
- a backend always 600 ms against a 200 ms wait gets its list through:
  red on 4a33cf0a9 (none in 10 s), green here.
- stale: three answers at once while the backend holds its second ask.
- a refused sign-in after a list: the 401 is passed on.
TestCodexModelListOnlyPicked and TestCodexNativeModelsTakeSetWindows
change the backend's list between calls, so they forget the kept one
there (forgetCodexLists, which also waits for every ask a test began).

Run at this head (cm3734 worktree, base 834935149):
- go test -race -count=10 on the five list tests (the four new, BackendSlow): ok.
- GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gateway/: ok;
  gofmt -l clean.
- go test -timeout 45m ./internal/gateway/: ok (429s), run before
  TestCodexModelListBackendAlwaysSlow was added; that test then run
  alone and in the -race run above: ok.
- Rebased onto 80857a66c (13cca8109 touched codexcat and Codex's
  models since): go test -run 'Codex|Fast' ./internal/gateway/: ok (42s).
2026-10-26 23:41:35 +08:00
yetoneandMYCF711 80857a66c9 provider: a window's runsOutAt reaches /v1/magpie/quotas and magpie quota --json (#3762)
QuotaWindow has carried RunsOutAt/RunsOut (when the soonest of what is
left is lost apart from the reset, and how much) since WorkBuddy's
credit packages, but quotaReport builds each QuotaSpan field by field
and had no such fields, so the report /v1/magpie/quotas and `magpie
quota --json` tell dropped them. A free WorkBuddy account, whose credits
have no reset at all, said nothing there of when they end.

The issue also says the Usage page and tray miss it. They don't: the
GUI reads /api/usage/quotas, which sends SubscriptionQuota/QuotaWindow
as they are, so its card already had runsOutAt. The affected surfaces
are the quotas API and the CLI's JSON. The CLI's text table still shows
no run-out column; not changed here.

TestQuotaSpanCarriesEveryWindowField walks QuotaWindow's JSON fields:
each is on QuotaSpan or named as left out on purpose (resetSecs,
family, credits, capped, capsSome, capId, startsAt, each with why), and
a window with every field set comes out with every QuotaSpan key set.
A field added to QuotaWindow can't be dropped again without a decision.

Run: go test ./internal/provider/... (ok, with
TestUnreadLoginsWriteErrorsKeepCredentials skipped: known synctest
crash #3632, crashed the same way unskipped); go test -run Quota
./internal/gateway/ ok; gofmt -l clean; GOOS=linux go vet -tags nogui
and GOOS=windows go vet ./internal/provider/ clean.
Broken by hand: quotas.go at origin/main: both new tests FAIL (field
missing). Fields on QuotaSpan but not copied in quotaReport: both FAIL
("quotaReport leaves it empty").
Not tried: a real WorkBuddy account; the fixture is the plugin's window
shape from the issue (workbuddy 0.1.35, free plan).

Co-authored-by: MYCF711 <MYCF711@users.noreply.github.com>
2026-10-26 23:38:09 +08:00
yetone 5b4dec58e4 providers: a vendor's keys saved a provider each are one provider with those keys
yuluo_yx on X: "NVIDIA #595"…"#600" at integrate.api.nvidia.com and
"Mistral #0001"… at api.mistral.ai were a provider each on the
Providers page and a row each on Routing, and with thousands of keys
magpie started slowly. They came from an app that keeps an entry a key
(CC Switch) imported in one batch: ImportFromApps only offered "add as
another key" against providers that existed before the batch, so each
entry became a provider of its own (nvidia, nvidia-2…).

Fold (internal/provider/fold.go):
- FoldCopies runs in startUp, before anything lists the providers, so
  every user who has such copies already finds them folded. Automatic,
  not a one-click offer: they are the same account's keys at the same
  address, what the user wanted is one provider (zero-config rule), and
  nothing is lost: each copy's id goes in the provider's Was, so its
  calls count with it by key (ProviderKeyID is the key's fingerprint,
  unchanged) and a model picked by the old id still resolves.
- Only copies by name fold at start-up: a base name and that name with a
  number after it (" #12", or freeName's " 2"), at least one numbered.
  They must also be alike in all but the key: the provider with id,
  name, keys and on/off left out, their per-model settings, and every
  place that names them (Visible, picked/hidden/ordered models, groups,
  fallbacks). A copy shown to one agent alone, given its own models or
  settings, or named by the user ("Home relay" / "Work relay") stays
  apart. Subscriptions, hidden ones, Vertex and StepFun-signed ones are
  never folded.
- The first copy that is on takes the rest; it is named the base name
  ("NVIDIA") and its key keeps its old name. Others become keys in the
  providers' order, named as they were, off if they were off.
- Group members, weights, rules, classifier, pick and fallbacks name the
  provider once; per-model settings and fetched lists of the folded ids
  go; balance and window history kept by their id moves to their key's
  name, where a provider with several keys reads it.
- A providers.json that doesn't parse is left alone (read() would have
  given its .bak, and a fold would write that over it).
- ImportFromApps folds what one import added by shape alone, whatever
  the entries are called.

Routing needed no change: a provider's keys for one model already fold
into one row ("2400 keys"), opened on click (FOLD_AT, #1319).

Numbers, sandbox HOME with 2400 NVIDIA + 600 Mistral copies (gen.py,
NVIDIA preset + 2 models, Mistral 15 models), `magpie web`, every
outgoing request through a dead proxy:
- before (origin/main 9809a8ac9): first /api/state 200 after 6.38s
  (4.9s on a second try), /api/state 2.6-4.5s and 86,475,466 bytes,
  /api/providers 6.4-8.4s and 11.7 MB, RSS ~1 GB.
- after, first start (folding): first /api/state after 1.73s; later
  starts 0.52s. /api/state 5-13 ms and 100,833 bytes, /api/providers
  25-80 ms and 315 KB, RSS 69 MB. The file ends with 2 providers,
  nvidia with 2400 keys and mistral with 600.
With 3000 keys in one provider nothing else scaled badly enough to
show (#3164 and @NetRozee's thousand-key work already made the key
paths once-per-list), so nothing more was changed.

Tests: TestFoldCopies, TestFoldCopiesIntoOneOn, TestFoldCopiesUnreadable,
TestImportFoldsAKeyAnEntry. Broken by hand, each went red: refs left
out of the shape (a copy shown to Codex alone folded), per-model
settings left out, Off not carried, Was not appended (usage of the
folded id stayed its own), the first-on rule, the history move, the
settings move, the unparseable-file guard, and the import's fold.

Run: gofmt -l (clean); go vet ./..., GOOS=linux go vet -tags nogui
./..., GOOS=windows go vet ./... (clean); go test -tags nogui
./internal/provider ./internal/cli ./internal/settings
-skip TestUnreadLoginsWriteErrorsKeepCredentials: all ok (provider
121s). That test crashes alone on origin/main 834935149 too ("close of
synctest channel from outside bubble", filememo.Forget), filed as #3632.

Not tried: the GUI suite (no asset changed; the pages read the same
APIs), a real CC Switch database with hundreds of entries (the fixture
is CC Switch's schema with four), a user whose copies have different
per-key settings (they stay apart by design), and the full ./... suite
before the push (other sessions' suites were running at load ~110).
2026-10-26 23:27:55 +08:00
yetone 13cca81099 codex: /fast reaches a group or model whose fast mode isn't a ChatGPT account's
cute_lynx_36404 (Discord #feedback): turning on GPT fast mode (/fast, 加速)
inside Codex did nothing through magpie; only the Routing page's fast
default worked.

Cause: Codex sends service_tier only on a model whose catalog entry lists
it (codex-rs ModelInfo::service_tier_for_request drops any other).
provider.CodexTiers listed Fast on a routing group only when a member was
a ChatGPT account's gpt- model, and on a model of its own only for
codex/gpt, a relay's GPT (OwnTier), another magpie and plugin tiers. A
group whose fast members are an OpenAI or Anthropic key, Cursor, a
plugin's priority model or a relay's GPT, and an Anthropic key's Opus on
its own, were offered no tier, so Codex never sent one. The gateway
already takes the client's service_tier per request and says it in each
member's words (priority on OpenAI/ChatGPT/relays, speed fast for Opus on
api.anthropic.com, Cursor's fast variant, a plugin's tier) or drops it
where the member has no fast mode; the Routing default went another way
(the member's own fast), which is why only it worked.

Now a group with any provider.CanFast member is offered Fast through
m.Tiers ("priority"; m.Fast still means a ChatGPT member, which also
drives MultiAgent v1), and so is a model of its own that CanFast and no
tier above names. codexcat uses the named tiers for a provider added by
address when Codex's own entry has none for it (Opus behind an address
on api.anthropic.com). The served tier is recorded as before
(TierAsked/TierSent/TierServed); magpie prices no tier differently, by
the Routing default or by the client, which this doesn't change.

Run:
- TestCodexFastOfferedWhereAMemberHasIt (new, internal/gateway): red with
  CodexTiers reverted (group/hard and an/claude-opus-5-5 list no tier),
  red with only the codexcat line reverted (an/claude-opus-5-5); green
  now.
- go test ./internal/codexcat; -run 'Tier|Fast|Codex.*Catalog|CodexList'
  in internal/provider, internal/agent, internal/gateway: ok.
- Real codex-cli 0.162.1 in a sandbox HOME/CODEX_HOME, model_provider
  magpie on a fake Responses upstream, catalog from codexcat.Catalog:
  group/hard (Fast listed) with service_tier="fast" sent
  service_tier "priority"; without it, none; group/cheap (no fast
  member) with fast on sent none.
- go test ./internal/gateway/... ./internal/agent/... ./internal/provider/...
  ./internal/codexcat/... -timeout 45m at this tree, on origin/main
  834935149: gateway ok (513s), agent ok (310s), codexcat ok; provider
  FAIL twice on TestUnreadLoginsWriteErrorsKeepCredentials, "close of
  synctest channel from outside bubble" in filememo.Forget, red on main
  and filed as #3632; provider with that test skipped: ok (109s).
- gofmt -l clean; GOOS=linux go vet -tags nogui ./... and GOOS=windows
  go vet ./... clean.

Not tried: the Codex desktop app's /fast toggle itself, and a real
Anthropic or OpenAI key upstream at priority.
2026-10-26 23:25:36 +08:00
yetone 834935149a routing: a request still going is patched in its row, not made again, so the page holds still under traffic (#3731)
gpboyer2 (#3731, v0.1.1579): with requests coming, the Routing page kept
redrawing, its stage, caption and request list jumping so nothing could
be read; idle it was still.

Measured on main 4a33cf0a9 with a probe (MutationObserver on
#view-routing, plus animationstart), 12 requests listed, then one still
going answered by the trace every 150ms, as under traffic:
- idle, 5s: 25 nodes put in and 25 taken out, 30 attribute writes. The
  countdown's second ran rebuild(), and header() replaced the head's
  nodes and wrote the mode line and each agent's name, sub and title
  whatever they said.
- one live request, 5s (41 answers): 217 nodes in, 219 out, 824
  attribute writes (nearly all the same value), and the row's rtlive
  pulse started over 62 times. rowOf made the request's row again
  whenever its signature changed, and a request still going changes it
  on each answer (its tokens), so the row and its pulse came in afresh
  4 to 8 times a second: the flashing.

Now rowOf patches the row it has (morphRow, as context.js's morph does
for the Context card), and the head, the agents' nodes, the wires'
viewBox, the list head's titles and aria (setAttr), the hub's title and
the packet's cx/cy are written only when they change. Same probe after:
idle 0 writes of any kind; one live request 0 nodes made again (2 taken
out: the packet's flight ending), 177 attribute writes, 0 pulse
restarts, in Chromium and WebKit.

Not changed: the stage still follows the newest request, so with
several agents at once it shows each in turn (by design; pinning a
request holds it), and the issue's "Pause live" switch and fixed stage
height (#2598) are not added here.

Test: tests/routing-live-calm.test.cjs. Idle three seconds the page
gets no write; with the live request answered again and again the row
is the same element, says the new tokens, its pulse never restarts and
no node is put in afresh. Green in chromium and webkit; with
client.js reverted to 4a33cf0a9 both red (rows made again, pulse
restarted).

Run (rt3731 worktree):
- At 4a33cf0a9 with this change: go test -timeout 45m ./internal/gui/
  ok (176s). Rebased onto e9c1066c4 (no routing file changed between):
  the same run red on TestRestartHandsTheGatewayOver only ("1 of 2
  requests during the restart answered", #3451, the update handover);
  run again with the budgets, -count=3: ok 3 of 3, TestCoreScriptBudget
  ok. routing-live-calm.test.cjs at e9c1066c4: 2 of 2 ok.
- GUI tests/routing-*.test.cjs, whole, at this change and at 4a33cf0a9,
  both cut at 1500s under load 100+: head 509 ok 4 red, base 462 ok 4
  red; every red at head is routing-intent-entry's "Add a rule makes a
  rule by intent" (#3408), red alone at both, different subtests each
  time.
- 30 row, stage and head files alone at this change: 458 ok, 9 red:
  routing-live-patch's folded subtests (an extra 0% context part, red
  the same alone at 4a33cf0a9: 4 ok 6 red, #3637) and routing-keys-fold
  "flies to the fold" in webkit zh/ja/de (#1612, #2658).
2026-10-26 23:21:30 +08:00
yetone e9c1066c4b gui test: the README bird's leave is measured at the swap
TestPluginReadmeBird read the leaving box and the README's top after
"Paragraph 11." showed. By then the dialog had moved some frames on
its spring (holdModal) while the box stays where it was, so the two
were 4.5 to 5.5px apart in webkit, over the 4px bar: 1 of 6 alone on
origin/main 9809a8ac9 and on this branch. A MutationObserver now takes
both at the swap itself, which is what "leaves from where it was"
means.

Run: the file alone, both engines, 6 times: 12 of 12 ok.
Broken by hand: the box placed 20px lower in fill() fails it in both
engines (boxTop 481 vs mdTop 461).
2026-10-26 23:10:09 +08:00
yetone 2bde657591 gui test: a gateway key's narrow check waits for the header to fit
TestGatewayKeyLimit read scrollWidth right after setViewportSize. The
header's tabs are fitted by fitTop from a ResizeObserver, a moment
later, so the read could still see the 1100px layout's nav.seg
(right edge 597 in a 560px window). webkit en was red 3 of 3 alone on
origin/main a6c808b68 at load ~170; chromium lost the same race when
the page had more to do. It now waits for scrollWidth <= innerWidth
(3s), as import-row.test.cjs does, and names the width when it fails.

Run: the test alone, both engines, 3 times: 12 of 12 ok.
Broken by hand: a 900px div appended after the resize fails it with
"sideways scroll at 560px: 900" (chromium en and zh).
Not tried: the other eight scrollWidth checks in tests/ that read at
once; none of them was red in the runs above.
2026-10-26 23:10:09 +08:00
yetone ed5cc959a7 gui: every slow page's skeletons get magpie's bird hopping bar to bar
The owner, after the Plugins page's README bird (722483c08): every
skeleton loader should have it, the slow pages most of all (Sessions,
Usage, Masking, Library).

app.js keeps one bird for the window (skelBird). Every 250ms it looks
for .skeleton and the Plugins page's ghost cards' .sk bars. When some
have stayed 450ms or more and at least one can be seen (in the
viewport, elementFromPoint at the bar landing on it or a box it sits
in, since ghost bars let clicks through), the bird drops onto one. The
bar dips under it, and it hops to the next bar it can see, in page
order. When the bars are gone it flaps off up and to the right and is
removed. It is position: fixed with pointer-events none, so nothing
under it moves or stops taking clicks. A quick load (under 450ms)
never shows it. A hidden window and reduced motion skip it.

The README's bird (plugins.js bounceLoader) now draws from the same
markup (BIRD) and styles (.sk-bird, sk-flap in app.css). plugins.css
loses its .pm-bird copy.

Budgets: app.js 1,321,319 -> 1,325,845, core 1,537,645 -> 1,541,967,
the exact bytes, no room added.

Run at origin/main 9809a8ac9 (load 100-150):
- skeleton-bird.test.cjs (new), both engines: a held market read
  shows the bird within 3s, over 30 places and dips, and gone 2s after
  the reply. A 150ms reply shows none. Reduced motion: no bird, no dip.
- plugin-readme-bird, i18n-keys, gateway-key-limit, the Budget tests:
  ok (the README bird's one webkit red is main's too, fixed in the
  next commit but one).
- Probe with every /api read but state held, per page: the bird shows
  on Sessions (4 bars), Library (31), Providers (20), Gateway (39),
  Usage (15), Masking (2) and Plugins (48). Screenshots looked at for
  Library, Usage and Sessions.
- The whole GUI suite at a6c808b68 (concurrency 6, load ~170): 128
  reds on this branch, 130 on main, over the same 36 files. Run alone
  twice per tree, the only test red on this branch and not on main was
  gateway-key-limit's chromium narrow check, a ResizeObserver race,
  fixed in the next commit.
Broken by hand: with the bird never spawned, the slow test is red.
Not tried: the Routing window page, which draws its stage at once and
has no skeleton (the tray panel's routing tab does); the tray panel
itself; the real app (only Playwright's engines).
2026-10-26 23:10:08 +08:00
yetone 9809a8ac9a gateway: Codex side calls go at an effort the model takes, and a refusal for no effort is asked again at low
cybercaius on Discord: Codex's side calls are meant to go at low effort,
but some went with none or no effort, and the upstream answered 400 as
the model needs one.

Cause, from Codex's source: a title asks low only on Codex's own title
model (gpt-5.6-luna, thread_title.rs `(model == THREAD_TITLE_MODEL)
.then_some(Low)`); on any other model, a magpie one included, it sends no
effort. The auto-review (guardian select_review_model) asks low only when
the model's preset lists low, else the preset's default, and codexcat
writes no levels and no default for a magpie model whose levels aren't
known, so it too goes with none. magpie fitted an effort asked to the
model's levels but never added one that was absent, and its off-effort
retry fired only for none/minimal refusals that list levels.

Fix:
- codexSideEffort: a title, description, summary, prediction, auto-review
  or memory call on one of magpie's models whose levels are known, asking
  no effort or an off one the model hasn't, is asked at its lowest on
  level (onEffort: low where it has it). Groups, other efforts and models
  with unknown levels go as asked.
- serve, forwarded and translated (Chat and Responses, not Anthropic):
  a 400 whose body says an effort is required (effortRequired: "reasoning
  effort is required", "missing required parameter: reasoning.effort",
  "requires a reasoning effort", "reasoning cannot be disabled") to a
  request that asked no effort or none is asked again once at onEffort.
  Any other 400 goes back as it came, asked once; a none that was refused
  is remembered (offRefused) as before. A no-effort refusal isn't
  remembered, so a model with unknown levels pays the 400 each time.

Ran (at this head, rebased on origin/main):
- go test -count=1 -timeout 45m ./internal/gateway/... ./internal/agent/...: ok (gateway 521s, agent 316s), at the pushed tree (2ca0da8e5 before this body was written), base 51202cd43
- go test -race -count=5 on the new tests: ok
- gofmt -l internal/gateway: clean; GOOS=linux and GOOS=windows go vet
  -tags nogui ./internal/gateway: clean

Broken by hand:
- codexSideEffort returning the body as it came:
  TestCodexSideCallAskedAtAnEffortTheModelTakes red (asked at ["" "low"])
- the backend's guardian/memory normalisation off: the same test red at
  the auto-review (["low" "" "low"])
- the forwarded retry off: TestEffortRequiredRefusalAskedAgainAtLow red
  (chat false: 400 "Reasoning effort is required")
- the translated retry off: the same test red (chat true)

Not tried: cybercaius's own upstream; its exact 400 text wasn't in the
report, so effortRequired is built from the wordings above, and
TestEffortRequiredWords holds that a level or field refusal isn't read
as one.
2026-10-26 22:55:29 +08:00
yetone 81a73c1c01 gateway: a Codex title that comes before its conversation's first turn follows the model just switched to
cybercaius on Discord: after switching Codex to another model, the first
new conversation's title was still written by the model before.

Cause: Codex writes a title on a temporary thread of its own
(tui/src/app/thread_title.rs, thread_source "thread_title"), with no
parent link to the conversation, started as the first message is sent and
so racing that conversation's first turn. codexLeads.of found neither a
parent nor its own thread and took the key's last turn, which, when the
title came first, was the previous conversation's, on the old model.
Composer predictions run on a fork and named it (forked_from_thread_id),
which of() never read, so they too took the key's last turn rather than
their conversation's.

Fix: of() reads the forked-from thread. The app's side turns (titles,
descriptions, summaries, predictions) read through codexLeads.sideOf: a
call tied to no thread magpie has seen, whose key's last turn is older
than 3s, waits for the next own turn (a channel saw() closes), up to 5s
or the request's cancellation, and takes that turn's model. Subagents and
memories keep codexSessionOf with no wait: they carry their lead's
thread. The auto-review follows the session only through codexcat's
per-entry override, and compaction goes on the conversation's own turn
model, so neither reads codexLeads.

Ran (at this head, rebased on origin/main):
- go test -count=1 -timeout 45m ./internal/gateway/... ./internal/agent/...: ok (gateway 521s, agent 316s), at the pushed tree (2ca0da8e5 before this body was written), base 51202cd43
- go test -race -count=5 on the new and neighbouring Codex side tests: ok
- TZ=UTC go test -run TestCodexTitle ./internal/gateway: ok
- gofmt -l internal/gateway: clean; GOOS=linux and GOOS=windows go vet
  -tags nogui ./internal/gateway: clean

Broken by hand:
- the backend's session reader put back to codexSessionOf:
  TestCodexTitleBeforeTheFirstTurnFollowsTheSwitch red ("the model
  switched from got 2 requests, the title among them")
- meta.Forked taken out of lookup: TestCodexPredictionFollowsTheThreadItForks
  red ("the forked conversation's model got 1 requests")

Not tried: a real Codex TUI or app switching models against a live
magpie (the race is reproduced in the test, ordering forced by waiting on
the state). A rename suggestion asked later, with no turn beside it, now
waits the 5s before going on the last turn's model.
2026-10-26 22:55:29 +08:00
yetone e52a5e50ba redact: a request opens by its key again; the key goes to the GUI as a string
The owner opened the newest masked request and got "This request's
record is gone: records are kept for 30 days", and a request opened from
the list said its whole text was no longer in memory. A record's key is
its time in nanoseconds (~1.79e18), past 2^53, so JSON.parse rounded it
to 256ns: /api/masking/record?key= and /api/masking/sent?key= looked up
a key no record has. A list row worked only because it carried its
record. Every way in by key failed: the Gateway page's and tray panel's
masked badge, ?key= in the address, and each request's sent text; the
list's before= paging was off by the rounding too.

gateway.Masked's key and /api/masking/record(s)' key now go as JSON
strings (",string"); records on disk keep their number. The page keeps
the key a string (no unary +), and a refresh compares keys as BigInt.

Tests: TestMaskedRequestIsRecorded and TestMaskingRecordsAPI check the
key is a string, and masking-records' fake API uses 19-digit string keys
in place of 1001-1005, which no rounding touched.
Broken by hand: with the Go change out, both Go tests fail ("key not a
string"); with the page.js/client.js change out, "chromium: a masked call
on the Gateway page, and a key in the address, open its request" fails.

Run: go test ./internal/gui (twice ok; a first run under load ~180 went
red with its log cut by tail, so the test is unnamed; two reruns with
the whole log were ok), ./internal/gateway ok, ./internal/maskrec ok;
GOOS=linux/windows go vet ./internal/gateway ok; GUI masking-records,
routing-bodies, i18n-keys: 96 of 96 ok, both engines.
Not tried: the real app with a real masked request.
2026-10-26 22:50:37 +08:00
yetone 29f1a5a717 redact: a request's steps are joined number to number, not by a dash before each
The owner's screenshot of a masked request showed a short dash left of
steps 2 to 5. The connector (li + li::before) was 10px wide at left
-10px, so it covered only the grid gap, and read as a stray dash beside
each number. It now runs from the number before to this one, 6px clear
of each (columns are equal, 10px apart, numbers 20px).

masking-records' request test measures each line's ends against the two
numbers: 6px from each.

Run: masking-records.test.cjs whole (both engines, every language, 1100
and 640px), 82 of 82 ok. At 640px (container under 760px) the lines stay
hidden, as before.
2026-10-26 22:50:37 +08:00
yetoneandskygunner 51202cd431 plugin: a check-in outcome magpie doesn't know names what the plugin said
A plugin check-in that answered an outcome not in the list, with a
message, became failed with the plugin's message alone, so "the daily
credits were refreshed" read as magpie's own failure reason. The reason
now names the answer first: the plugin answered "yes": <message>. With
no message it stays "the plugin answered no outcome" or the answer.

Split out of skygunner's fix/usage-absent-used branch (#3650), which
carried it beside the usage fix.

Run: go test ./internal/provider -run TestPluginCheckinRunsAsTheBuiltinsDo
ok. Broken by hand: host.js's old line makes it red (Msg was the message
alone). Not tried: a real plugin answering an unknown outcome.

Co-authored-by: skygunner <skygunner@users.noreply.github.com>
2026-10-26 22:42:59 +08:00
yetoneandskygunner 9733ed1b4a usage: a plugin window that doesn't say used is no reading (#3650)
A plugin usage window that leaves out `used` was read as 0 in host.js
usageOf. The card then showed "100% left" (or NaN% once the GUI saw a
missing value), and allowanceOf ranked the account as the one with all
of its allowance left, so smart routing put spent accounts first.

Now a left-out used is null from the host, plugin.UsageWindow.Used is a
*float64, and quotaOfPlugin makes such a window Text and Aside: the card
shows its display (else "No allowance reported"), with no percentage and
no meter, and routing leaves it out. An account whose windows all tell no
share has no allowance and is not known to routing (routedAllowance), as
one never read: not preferred and not rested. A window that says used:0
is a reading at 0, as before.

Ported from skygunner's fix/usage-absent-used (6791aa99). Changed from
the branch:
- lastAllowances (the reading kept on disk) built an empty allowance for
  such an account, which routing read as known with all of it left. Both
  it and Allowances now go through routedAllowance.
- quotaText shows "No allowance reported" for a no-share window with no
  display, rather than a blank.
- A host-level test (the bun host with the fake plugin) and the GUI test
  widened to both engines, every language, 900 and 390px, used and left.
- The branch's check-in wording change is its own commit.
Note: an account whose windows are all aside or text was known with 0%
used before; it is now not known, so loginRoom won't pick it as the
next account with room.

Run at this tree (base 9298d2a7c):
- go test ./internal/provider -run 'Absent|NoShare|PluginUsage|PluginText|
  AllowancePooled|PluginPool|GLMPlan|WorkBuddyCredits|QuotasDedupe'  ok
- go test ./internal/plugin ok; gofmt -l empty; go vet ./...,
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok
- GUI: usage-no-reading.test.cjs chromium+webkit ok; i18n-keys ok;
  TestCoreScriptBudget ok (budget not raised)
Broken by hand, each red, then restored:
- quotaOfPlugin without the Text/Aside branch: 3 absent tests red
- routedAllowance always ok and allowanceOf not skipping Text:
  TestRoutingKnowsNoAccountThatSaidNoShare red
- host.js's old used line: TestPluginHostPassesAnAbsentUsedOn red
- usage-no-reading on origin/main's assets: red in both engines
  ("12 / 300 · NaN% used")
Not tried: a real Loomy account, a live routed request.

Co-authored-by: skygunner <skygunner@users.noreply.github.com>
2026-10-26 22:42:59 +08:00
yetone 43001be863 gateway: a relayed Chat body's unpaired tool calls are paired before Kimi sees them
Paidaixinbao on X: Qoder through magpie on Kimi Code, a conversation
forked at an earlier turn fails on every prompt while a new one works.
A Chat client's body to a Chat upstream was relayed as-is, and only
translated requests had their tool exchanges mended (pairToolMessages).
A forked or stopped history can hold a call with no tool answer, calls
split over two assistant messages, a user turn between a call and its
answer, or an answer to no call. Kimi turns the whole request away with
400 "an assistant message with 'tool_calls' must be followed by tool
messages responding to each 'tool_call_id'..." or "tool_call_id  is not
found". toolPairsOut now pairs such a body on the Chat relay (joining
split calls, answering the unanswered, turning an orphan answer into
user text); a paired body goes out byte for byte.

Run:
- Real Kimi Code API (kimi.com/coding/v1, 2026-10-26; the account's
  plan has lapsed, so a body past validation answers 403 and a refused
  one 400): unanswered call, split calls, user between call and answer,
  one of two answered and an orphan answer are each 400; every one of
  them after toolPairsOut is 403, past validation. A tool turn without
  reasoning_content, null content, repeated ids, out-of-order and
  double answers, prefill and a reasoning field all pass as-is, so
  they are not the cause and are left alone.
- gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and
  GOOS=windows.
- go test -timeout 45m ./internal/gateway: ok, at this commit.
- Two fixtures held an unpaired body only by accident and are paired
  now: image_input's chat-tool case (a lone tool message) and the
  large-chat upstream golden (its last call left unanswered); the new
  large-chat hash is the same on the old code.

Broken by hand: without the toolPairsOut call all six subtests of
TestChatRelayPairsToolsForKimi go red against a fake Kimi with Kimi's
own wording; without joinSplitChatCalls the split case goes red;
reading only string content in toolAsUser turns the parts case red.

Not tried: the real Qoder app and the reporter's own forked history,
so which shape their fork holds is not proven; Qoder's "unsupported
request" text is not magpie's wording. A real Kimi model answer (the
plan has lapsed, only validation was seen). A non-Kimi Chat upstream,
though the rule is OpenAI's too and runs for every Chat relay.
2026-10-26 22:40:48 +08:00
yetone de54b4ff99 codex: threads started on OpenAI are listed while magpie is Codex's provider
notnico64 on Discord (Linux, magpie desktop): with Codex connected to
magpie, `codex resume` said "No sessions yet". Codex's resume picker
(tui/src/resume_picker.rs picker_provider_filter) lists only threads
whose model_provider is the one Codex is on now, with no opt-out, and
the filesystem scan checks each rollout's session_meta, not just the
state DB row. With no ChatGPT sign-in (also an API key, magpie API, an
account out of allowance, another machine/WSL) magpie writes
model_provider = "magpie", so every thread started on "openai" vanished
from the list. Nothing in it is Linux-only; macOS does the same.

Now, when magpie becomes Codex's provider and Codex was on OpenAI
before (not on a provider of the user's), the threads on "openai" move
to "magpie": the state DB row and the rollout's session_meta, rewritten
in place (both ids are 6 bytes), the file's mtime kept so the picker's
order holds, with no trash copy. At the Disconnect bringBack relabels
them back the same way before its usual mover. Threads Codex has
already packed (.zst, a week after the last turn) are left alone:
rewriting gigabytes of history at a switch isn't worth it (the owner's
~/.codex/sessions is 51GB, 11,591 of 12,255 rollouts packed). Files
written within ActiveWindow, outside this Codex home, or without their
id in the name are skipped too.

Run:
- Real Codex 0.162.1 in a sandbox HOME/CODEX_HOME (never ~/.codex):
  without model_provider the picker listed only the openai thread;
  with model_provider = "magpie" only the magpie one (the report).
  After RelabelCodexThreads(home, "openai", "magpie") the same picker
  listed both threads.
- TestCodexThreadsFollowMagpieIn (new) is red on the old code:
  "connected: thread ...c1 on "openai", want "magpie"".
- go test -tags nogui -timeout 45m ./internal/agent ./internal/sessions
  at this head: ok agent 480s, ok sessions 41s (rebased on 9298d2a7c)
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on
  both packages clean.

Broken by hand: dropping the prior-provider guard turns the
"provider of the user's" subtest red; dropping the Chtimes turns the
mtime check red.

Not tried: the reporter's own machine and why magpie became their
provider; Linux itself; the Codex desktop app's thread list; a full
`go test ./...`. Packed threads stay out of the list while magpie is
the provider.
2026-10-26 22:38:57 +08:00
yetone 9298d2a7c3 cli: prompts read the stdin Windows' console init reopens, not the one package init saw
tom047784 (Discord, Windows desktop build): `magpie plugin login` in a
terminal failed with "read /dev/stdin: The handle is invalid". The
desktop build is a GUI-subsystem binary; console_windows.go's init
attaches the parent console and reopens CONIN$/CONOUT$ into os.Stdin,
os.Stdout and os.Stderr. But `var stdin = bufio.NewReader(os.Stdin)` in
backup_cmd.go is a package variable, set before any init runs, so it
kept the invalid handle.

That one reader serves every CLI prompt, so all of them broke the same
way: plugin login (askPrompt, askNumber, the code and pasted callback
lines), backup/WebDAV passphrases and passwords piped in (secret), the
library and quota confirmations. stdin is now a func that makes the
reader over os.Stdin as it is when read, and remakes it if os.Stdin
changed; one reader still serves a run, so a second piped secret is
still the second line.

Sibling of the same class: lipgloss's default renderer (termenv's
default output) is made over os.Stdout at its package init, before the
reattach, so the desktop build's CLI printed every style without colour.
The init now points that renderer at CONOUT$ in place; the styles made
at package init hold it. A grep for package-level os.Stdin/os.Stdout/
os.Stderr found no other one in the repo (writers like fmt.Println and
json.NewEncoder(os.Stdout) inside functions resolve at use time).

webdav_cli_test's piped() swapped both os.Stdin and the reader, which is
why no test caught this; it now swaps os.Stdin only.

Run (at this tree, worktree off origin/main 4e3078ee4):
- go test -count=1 -timeout 45m ./internal/cli/: ok (52s)
- go test -race -count=3 TestPromptsReadStdinSetAfterInit|TestAskPrompt|TestWebdav: ok
- gofmt -l internal/cli: empty; go vet ./internal/cli, GOOS=linux go vet
  -tags nogui ./internal/cli, GOOS=windows go vet ./internal/cli: ok
Broken by hand: TestPromptsReadStdinSetAfterInit on the old backup_cmd,
plugins_cli, library_cli and quota_cli (new test file only) is red:
"askPrompt = "", EOF; want blue from the stdin set after init".
Not tried on Windows: the Windows box (10.0.0.132) timed out on ssh, so
the real desktop build's `magpie plugin login` and the lipgloss colour
change were not run there. Not run: go test ./... (only internal/cli
changed).
2026-10-26 22:22:27 +08:00
yetone b3729b8d56 redact: a model's or a toolchain's name the local model takes for a secret goes as written
The owner's 脱敏 page showed groqAPIModel = "llama3-70b-8192" masked as
a secret by the local model. The real model, asked again, also takes
claude-3-5-sonnet-20241022 beside it for one. namesThing now holds
modelName: lower-case words joined by dashes with a size part (70b,
8x7b, 32k), an eight-digit date part (20241022) or a yyyy-mm-dd date
(nightly-2026-09-01). A diceware passphrase (correct-horse-battery-
staple) or maple-4-river-77 has neither and is still masked.

The page's other value, nightly-2026-09-01 as a name, was recorded by
the running v0.1.1370 (10-24). The model labels it private_person, and
main already drops it (a name with a digit, a word in lower case, since
611b9e173); the new rust-toolchain eval case holds that.

Run:
- MAGPIE_EVAL_CACHE=$HOME/.cache go test -run TestMaskEval ./internal/redact
  with the real model: re-recorded, both new cases ok in "both", the
  model's column WRONG for all three values.
- go test ./internal/redact ./internal/pii: ok. gofmt clean; go vet for
  darwin, linux and windows.
- Broken by hand: modelName taken out of namesThing → settings-model red
  (both values) and the four new TestModelMisreadsNotMasked cases. The
  digit check in personFits alone taken out stays green on
  rust-toolchain, since the lower-case-word check also drops it.

Not run: the packages that import redact (gateway and others) before
the push; the change only narrows what the model's secrets mask.
2026-10-26 22:16:02 +08:00
yetone 4e3078ee47 agents: a Codex thread started on any provider table goes through magpie when reopened, not only CC Switch's
A report the owner relayed from WeChat (10-26): in Codex, with apikeyfan's
gpt-6.1-sol on, an old thread failed every turn with "unexpected status 404
Not Found: Model "apikeyfan/gpt-6.1-sol" is not supported by any configured
account in this group, url: https://slb.apikey.fan/responses". A new thread
worked, and updating magpie didn't help. The url is Codex's own call: Codex
reopens a thread on the provider it was started on, and that thread's table
pointed straight at the relay (no /v1, so not a table magpie wrote), so the
magpie model id went to the relay. 6c5ed2acf pointed only CC Switch's
"custom"/"cc-switch-N" tables at magpie; a table of the user's own, or one
named after a CC Switch card, kept going to the relay.

Now any [model_providers.<id>] table a Codex thread was started on (the
state database's threads) goes through magpie while a magpie model is on,
the same way: base_url to magpie's /v1, the old URL kept in the stash and
given back with Codex's own model or a reset, the table's other keys as they
were. Left alone: tables no thread names, tables a profile names, magpie's,
Codex's built-ins and CC Switch's OpenAI mirror. The state database is read
only when a table outside CC Switch's ids has a base_url, once per check.

Run at this head (4a33cf0a9 + this):
- TestCodexTakesThreadTables (new) is red on the old codex.go: "thread's
  table not through magpie". TestCodexWritesTablesThreadsName, changed to
  expect the user's thread table through magpie, is red on the old code too.
- go test -tags nogui ./internal/agent -run Codex: ok.
- gofmt -l, go vet (darwin, GOOS=windows), go build (darwin, GOOS=linux): ok.

Not tried: the reporter's own config.toml (its table's id isn't known, so a
quoted header or a profile-named table would still be left alone), the full
suite, and a real Codex app reopening a thread.
2026-10-26 22:02:03 +08:00
yetone 4a33cf0a98 update: a Stable channel in Settings → About, and magpie update channel
ssharpcc on X reads every changelog before updating, for fear of a ban
when behind, and with many releases a day that is a lot of reading.
Settings → About → Update channel (zh: 更新渠道, 稳定版 / 每个版本) picks
Every version, the default and today's behaviour, or Stable: one version
a week, the newest that had been out three days as the week began
(Monday 00:00 UTC), and an urgent release at once. usemagpie.ai chooses
it from the release list (the previous commit); a release is urgent when
a line of its notes starts with "**Urgent release:**", which
magpie-releases' release run writes from an `Urgent: <why>` trailer
(magpie-releases 73f6cff).

- settings: updateChannel, "" or "stable"; anything else is refused.
- update: on Stable the feed is asked with channel=stable; What's new
  shows every release since the installed one (up to 1500) instead of
  the newest 40, so a week's notes read as one list.
- gui: the row is segs, never a <select>; a save that doesn't send the
  channel keeps it; switching asks the feed again at once, and a
  download from every version newer than Stable's pick is dropped,
  never restarted into. What's new's notes are kept per channel.
- cli: magpie update channel [stable|every] ("all" too), and it says
  which with nothing after it.
- docs: reference.md's Update channel (the rule and the marker); the
  privacy pages (en, zh, ja) name ?channel=stable on /api/latest.

The full Go and GUI suites were not run: the disk was at 3 GB free and
other sessions had GUI suites and a 45-minute gateway run going the
whole time.

Run, at this tree before the rebase:
- gofmt -l (clean); go vet on darwin, GOOS=linux -tags nogui and
  GOOS=windows for ./internal/update/... ./internal/cli/...
  ./internal/settings/... ./internal/gui/.
- go test -count=1 ./internal/update/... ./internal/cli/...
  ./internal/settings/...: ok. ./internal/gui -run
  'TestUpdateChannelSwitch|TestWhatsNewKeyedByChannel|TestCoreScriptBudget':
  ok (the app.js budget passes).
- GUI, chromium and webkit: update-channel (22: en, zh, zh-TW, ja, de at
  900 and 420 wide: default lit, Stable saved, kept by another save,
  kept over a reload, Every saved back, no click scrolls, no sideways
  scroll at 420), i18n-keys, gui-ja, gui-de, gui-zh-tw and every
  update-*.test.cjs: 253 of 253 pass.
- The live feed: /api/latest?channel=stable answers 0.1.1327 (out
  2026-10-22 21:55 UTC, the last before Friday 10-23 00:00) with 15
  assets after the first real cron run filled the ledger (400 releases
  back to 10-10); /api/notes 0.1.1200..0.1.1327 gives 124 notes, none
  empty (1213 and 1218 were never published).

After rebasing on afc99490f: TestCoreScriptBudget, the channel Go tests
(update, cli, gui) and GUI i18n-keys + update-channel (both engines,
26 of 26) pass again.

Broken by hand, each red: the feed asked without channel=stable
(TestLatestAsksTheChannel); Stable capped at 40 (TestStableNotesAreAll);
any channel saved (TestUpdateChannelSaved); "all" dropped
(TestUpdateChannelCmd); a save without the field clearing it, no new ask
on a switch, the newer download kept (TestUpdateChannelSwitch); one
notes key for both channels, What's new capped at 40 on Stable
(TestWhatsNewKeyedByChannel); app.js's other saves dropping the channel,
Stable's click saving "" (update-channel 11 of 11 red); the zh label or
a de subtitle taken out (update-channel and i18n-keys red).

Not tried: the full go test ./... and the whole GUI suite (above); a
real app switching channel against the live feed; Windows and Linux
runs (vet only); a real urgent release.

Requested by ssharpcc on X.
2026-10-26 21:09:44 +08:00
yetone 8f4469954e site: a Stable update feed, a release a week and an urgent one at once
ssharpcc on X reads every changelog before updating, for fear of a ban
when behind, and with many releases a day that is a lot of reading. This
is the feed side of Settings' Update channel: /api/latest?channel=stable.

How Stable is chosen (stableOf, from the release list, never by hand):
- as each week begins (Monday 00:00 UTC), the newest release that had
  been out three days by then (published <= Monday - 3 days);
- an urgent release is Stable as soon as it is out, until a weekly pick
  passes it.
A release is urgent when a line of its notes starts with
"**Urgent release:** <why>" (quoted or not). GitHub releases are not
marked pre-release for any of this.

GitHub's newest 100 releases are about a day of magpie, so a KV ledger
(LEDGER, usemagpie-ledger) keeps 45 days of {version, published, urgent}
and each day's notes, filled by a cron every 15 minutes: the API's first
page (the releases feed when the API says no, keeping the ledger's dates
and API notes), the pages after it while there is a hole, and on back to
21 days, at most four API asks a run, writing only what changed. A
ledger that can't be read is never written over. /api/notes reads a
range older than the newest 100 on from the ledger, so a Stable app's
week of notes comes as one list. Without a ledger reaching the week's
cut, the stable feed answers 503 (no-store) rather than guess. The
default feed, and any other channel value, is unchanged.

Run: node --test site/*.test.mjs (stable.test.mjs 14 new, every clock
held: weekStart, the cut to the second, a week held and moved on, urgent
before/after its time, unknown, the ledger's paging, hole, ask cap,
broken KV, API-limited feed fallback, notes past the 100 newest; the
existing worker and install tests 31 pass). wrangler deploy --dry-run
shows the LEDGER binding.
Broken by hand, each red: no soak, a rolling 3 days instead of the week,
urgent ignored, no ledger notes, a broken read taken as empty, the
feed's date or notes over the API's, notes bucketed by the feed's date,
no hole mending, no ask cap, the index always rewritten, the marker
matched mid-line.
Not tried: a real cron run before this deploy; the anonymous API's
60/hour limit under the cron's asks beyond reasoning (one ask a run once
the ledger is deep).

Requested by ssharpcc on X.
2026-10-26 21:08:00 +08:00
yetone afc99490f2 plugin: a fetch's body goes to the host in one line made for it (#3472)
Each plugin request was copied several times before it reached the
plugin:
- pluginFetch read the body with io.ReadAll, which grows from 512
  bytes, so a 1 MB body was some 3 MB read. It now reads into a buffer
  of the request's Content-Length.
- Fetch marshalled a map holding the FetchRequest and the body as
  []byte, so encoding/json base64'd the body into its own buffer and
  then copied it into the line, and enqueueOwned appended the newline
  in another copy. fetchLine now marshals the request without the body
  (FetchRequest.Body is json:"-") and appends the base64 body and
  window into one slice sized for the whole line; enqueueLine sends it
  as is.

The frame is byte for byte what it was: TestFetchBodyWireIsUnchanged
compares it with the old json.Marshal of the map, field order
included (request fields, body, window).

BenchmarkFetchBodyProd B/op, before -> after:
  1 MiB   1,516,234 -> 1,411,609
  8 MiB   14.4 MB   -> 11.2 MB
  16 MiB  29.7 MB   -> 22.4 MB
Through the gateway with the previous commit (probe, 60 requests of
~938 KB, per request including the test's client and fake vendor):
  /v1/chat/completions 21.2 MB -> 17.3 MB (24.4 MB before both, -29%)
  /v1/messages         33.7 MB -> 29.3 MB (39.8 MB before both, -26%)
Server.serve's own share on /v1/messages: 29.1 -> 19.0 MB (-35%).
What is left on top is buildChat's json.Marshal of the outgoing body,
which the upstream byte fixtures pin; not changed here.

Run at this head (base origin/main 1bb8143b3):
- go test ./internal/plugin ./internal/provider -skip
  '^TestUnreadLoginsWriteErrorsKeepCredentials$' (#3632) -count=1
  -timeout 45m: ok (plugin 109s, provider 105s)
- go test ./internal/gateway -skip '^TestZZ' -count=1 -timeout 45m: ok
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui for
  internal/plugin, internal/provider, internal/gateway: clean
- Real account in a sandbox HOME: the Command Code plugin
  (commandcode-plan/claude-haiku-5-5) answered /v1/messages and
  /v1/chat/completions with a ~54 KB history, a tool call and a UTF-8
  tool result: 200 both, the tool's text quoted back exactly.
Not tried: an OAuth plugin (their tokens rotate; not copied into a
sandbox), Windows.

Rebased onto origin/main 6e6aba51c (a providers key change) and run again at the pushed head: go build -tags nogui ./... ok; go test ./internal/provider (same skip) ok 115s, ./internal/plugin ok 110s, ./internal/gateway -run 'Facts|Parse|Plugin|WorkPlace|Fetch' ok 50s. The full gateway run above was at 1bb8143b3.
2026-10-26 21:04:48 +08:00
yetone 9a888323a2 gateway: a Chat or Messages request is read for its folder and turn without its history (#3472)
A plugin's request is read for its work folder on every try
(tellWorkPlace -> readFacts -> parseIn(proto, body, true)). Only the
Responses reader had a facts mode (#3394); Chat and Messages parsed the
whole conversation, copying every assistant turn, tool call and tool
output, to learn a folder and whether the last turn was a tool's answer.
On a long conversation that history was most of what each try allocated.

readChat and readAnthropic now take facts, as readResponses does: they
decode with decodeJSONView, keep an assistant message as its role alone
and a tool result as its kind and call id, and keep the system and user
text that workPlace reads. parseChat and parseAnthropicRequest are
readChat/readAnthropic with facts off, unchanged.

Numbers (1.3 MB body, least of 3 runs, TotalAlloc):
  Chat facts 980 KB, whole parse 4.5 MB
  Messages facts 1.08 MB, whole parse 5.3 MB
Through the gateway on the plugin path (probe, 60 requests of ~938 KB,
counting the test client and fake vendor), per request:
  /v1/chat/completions 24.4 MB -> 21.2 MB
  /v1/messages         39.8 MB -> 33.7 MB
Retained heap is unchanged (~15-19 MB); this is churn, which is what the
reporter's heapSys grows from.

Tests:
- TestChatAndMessagesFactsAsTheWholeParse: facts give the same folder,
  turn and tool-answer facts as the whole parse, over the real fixtures
  (workdir/pi-1.1.0, claude-code-2.1.296, context/claude-code, the
  upstream_bodies chat/anthropic families), a large conversation and
  hand cases (model and tool both spoke; answered then a tool; answered
  then nothing; a tool's result alone).
- TestChatAndMessagesFactsLeaveTheHistory: facts allocate under a third
  of the whole parse.
- TestReadersOfAHeldBodyParseItOnce's last check now counts readFacts
  calls through the factsParsed hook instead of allocation, which the
  cheaper facts no longer show.
Broken by hand, each red then green: dropping the assistant message in
Chat facts; keeping only role-less messages in Messages facts; facts off
in parseIn (the allocation test); a held-facts lookup matching any entry.

Run at this head (base origin/main 1bb8143b3):
- go test ./internal/gateway -skip '^TestZZ' -count=1 -timeout 45m: ok
  (401s)
- go test ./internal/plugin ./internal/provider (provider with
  -skip TestUnreadLoginsWriteErrorsKeepCredentials, #3632): ok, run
  with the next commit in the tree
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui for
  internal/gateway, internal/plugin, internal/provider: clean
- Real accounts in a sandbox HOME (only the deepseek provider and the
  Command Code plugin copied): /v1/messages and /v1/chat/completions
  multi-turn requests with a working-directory line, a tool call and a
  tool result, to deepseek/deepseek-flash and
  commandcode-plan/claude-haiku-5-5: all 200, answers right (the plugin
  quoted the tool's "file a: 你好" back exactly).
Not tried: a real Claude Code or Codex session against this build.

Rebased onto origin/main 6e6aba51c (a providers key change) and run again at the pushed head: go build -tags nogui ./... ok; go test ./internal/provider (same skip) ok 115s, ./internal/plugin ok 110s, ./internal/gateway -run 'Facts|Parse|Plugin|WorkPlace|Fetch' ok 50s. The full gateway run above was at 1bb8143b3.
2026-10-26 21:04:48 +08:00
yetone 6e6aba51c8 providers: a key may be for another plan of its vendor, sent to that plan's endpoints
yckonnnn on X uses Volcengine's pay as you go and its Agent Plan, and
wants a key of each in one provider. Each plan takes its own keys at its
own endpoints (/api/v3, /api/plan/v3, /api/coding/v3), and every key of
a provider went to the provider's one plan, so only one kind worked.

A key now may say which of its preset's Regions it is for
(KeyAccount.Plan; Provider.KeyPlan for the first key, as KeyProtocol).
None, or the provider's own plan, is the provider's plan, stored as
none: old configs read and write as before. Presets whose plans take
keys of their own (PresetDef.KeyPlans): zhipu, zai, stepfun,
stepfun-cn, xiaomi, baidu-qianfan, tencent-cloud, huaweicloud,
volcengine, siliconflow. Not: yylx (one key everywhere),
bailian-decision (decide only), bedrock and bedrock-mantle (regions of
one account).

Every reader of the region or a base URL, and what it does now:
- WithKey (keys.go): moves the key's copy to its plan (atKeyPlan:
  Chat, Responses, Anthropic, Decide, KeysURL, Website, Catalog via
  atRegionOf; a provider at a host of its own keeps that host) and marks
  it keyView. Every gateway key path goes through it: chat, Responses,
  Messages, count_tokens, failover, embeddings (serveRetrieval via
  onKeys), drawing (drawOnAccounts via perKeyBarred), key tests
  (test.go), key_models.go, gui/groups.go, markedKey.
- perKeyBarred (gateway/fallback.go): a key whose plan's list lacks the
  model (PlanServing) is not asked; only when no key's plan has it.
- fetch / fetchPerKey / planOnly (models.go): a mixed provider lists
  each key's plan, a NoList plan from its preset list with no request,
  pay as you go from /api/v3/models with its own key.
- planMedia (PlanEmbeddings, PlanDrawers, PlanVideos): every plan's.
- PlanQuotas (planquota.go): each key read at its own plan's source.
- volcPlanQuotas, tencentPlanQuotas: one view per plan (planViews).
- KeyBalances (balance.go): each key at its plan's host (SiliconFlow).
- startVideo / videoMaker (gateway/video.go): a mixed provider starts on
  a key whose plan makes the model (onKeys) and names it in the id
  (keyMark), so the poll goes to that key's plan.
- GUI: POST /api/keys/plan (SetKeyPlan, then the lists are read again);
  the editor keeps KeyPlan with an unchanged first key, typed() clears
  it with a new one; KeepSecrets, AddCopy, backup's withoutKeys carry it.
- app.js: planPicker, a plan chip in each key row (the app's own menu,
  openProtoMenu, through pickPill, which protoPicker now shares), shown
  for a KeyPlans preset while the provider has several keys or the key
  has a plan; i18n zh, zh-TW, ja, de.

A key's plan is not guessed from the key: Volcengine's keys carry
nothing that says their plan. Xiaomi's tp-, Tencent's sk-tp-, MiniMax's
sk-cp- and Bailian's sk-sp- are noted in code but not used.

Not done: a gateway key held to some keys (videoAsker) on a mixed
provider's video may pick another key; a mixed provider whose own plan
has no balance source while a key's plan has one is not read; keys left
out for their plan don't show in the Routing trace; StepFun's plan
windows are a sign-in per site, unchanged.

Credit: yckonnnn on X (tweet 2114657701305487483).

Run at this commit on origin/main 1bb8143b3 (macOS, go1.26.8):
- gofmt -l internal: clean. go vet ./..., GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...: clean.
- go test -count=1 -skip TestUnreadLoginsWriteErrorsKeepCredentials
  ./internal/provider/ ./internal/gateway/: ok (103s, 421s). The skipped
  test crashes the whole provider package on main (#3632, from 091153bf).
- TestCoreScriptBudget: ok, budgets not raised (app.js 1,307,430 bytes).
- GUI, chromium and webkit: key-*, provider*-*, add-sheet, i18n-keys,
  gui-de, gui-ja, gui-zh-tw (58 files): 956 of 956 pass. key-plan.test.cjs
  covers en, zh, zh-TW, ja and de at 420 and 1000px.
Earlier, at the same change on origin/main 9120acaff:
- go test -timeout 45m ./...: 71 packages ok, internal/gateway and
  internal/gui among them. internal/provider crashed on #3632 only; run
  again with that one test skipped, it passed.
- The whole GUI suite (node --test tests/*.test.cjs) did not finish: the
  disk ran out at about 319 tests and the run was stopped. Up to then the
  only reds were account-discovery in both engines, #3497, red on main.
Broken by hand: without atKeyPlan in WithKey, TestKeyPlanEndpoints,
TestKeyPlanModelList and TestKeyPlansEachToItsOwnEndpoint go red; without
the planless filter in perKeyBarred the gateway test goes red; without
the plan chip key-plan.test.cjs goes red.
Not tried: real Volcengine (or any other vendor's) keys of two plans in
one provider; the video path (startVideo with mixed plans) has no test of
its own; Windows and Linux were vetted, not run.
2026-10-26 20:37:07 +08:00