Commit Graph
4133 Commits
Author SHA1 Message Date
yetone d3db461bbb redact: the local model's secrets leave UUIDs, digests and paths, and client_metadata goes as written
The owner's masking records showed Codex's turn metadata with every id as
{{SECRET_…}}: installation_id, session_id, turn_id, window_id,
context_window_id, root_turn_id, and a skill's file path in the
instructions. The local model (OpenAI's Privacy Filter) labels a UUID a
secret: run on Codex's x-codex-turn-metadata it took each id, and on a
log it took a request id and "sha256 9b74…". The vendor and magpie's own
sessions match a turn by those ids, so masking them can break what
depends on them, and hides nothing worth hiding.

- modelTakes: a secret the model finds is not taken when it names a
  thing (namesThing): a UUID, with window_id's ":0" after it too; a
  digest with its algorithm's name; a file's path. A password or a key
  it finds is still masked, and the rules' secrets (sk-…, password=…,
  API_KEY: …) are unchanged.
- client_metadata is in defKeys: the client's ids, which no model
  reads, go as written, as tools and stream_options do.

docs/subsystems/gateway-routing.md says both.

TestModelSecretIsNoID uses what the real model labelled "secret" on these
texts (pf-serve with the q8 model, run here): the UUIDs, the request id,
the sha256 digest, plus the reporter's path; the password and the
32-hex key beside them are still masked. Broken by hand: without
namesThing 5 values are masked, without client_metadata in defKeys a
user word in it is.

Run:
- At 3fff6c011 (on origin/main e65688886): gofmt -l clean; go vet clean
  on macOS, GOOS=linux -tags nogui and GOOS=windows; go test ./...
  -timeout 100m: 66 packages ok, and internal/agent and internal/library
  printed PASS but were marked FAIL when the disk briefly filled ("can't
  write testlog.txt: no space left on device"); run again alone, both ok
  (993s, 596s).
- Rebased on origin/main 141470515 (its 12 commits touch agent, cli,
  gateway, gui, provider, sessions, settings, tui, not redact): at this
  head gofmt and vet three ways clean, go test ./internal/redact
  ./internal/gwmw ./plugins/redact ok. The rest runs on CI before the
  tag.
2026-10-21 19:13:49 +08:00
yetone 1414705159 gui: the warm-up's read of the whole usage history runs under GOGC 25, so a cold start peaks ~130 MB lower
The warm-up's last big read, the Usage page's QueryPage over all time,
holds every row of the history unpacked at once (129 MB of rows, 271 MB
live at that moment for this history), and at Go's default GOGC the heap
grows to twice what is live before collecting: Activity Monitor's
footprint peaked at 555-587 MB there, on a magpie that rests at ~200 MB
once it is done. underTightGC lets the heap grow by a quarter during that
read and puts back what was set; a GOGC the user set lower, or off, is
kept. Holding fewer rows at once needs the page built in passes over
packed chunks (rowRef points into unpacked ones), which is the next step.

The whole warm-up under GOGC 25 gave the same peak for ~11 s more CPU, so
only that read is.

Measured with startheap-runs/fp.sh: cold start (calls and sessions caches
deleted) of a 6,437-file history, phys_footprint sampled every 2 s and
footprint's own phys_footprint_peak at the end, run until the caches stop
growing for 30 s; every run wrote the same 6,437 files / 70,069,451 bytes.
Machine at load ~85-140 from other sessions.

  before (e68a0b1db)        peak 555, 587 MB   cpu 2:01 (one run)
  whole warm-up at 25       peak 438, 410 MB   cpu 2:12, 2:14
  this commit               peak 421, 456 MB   cpu 2:05, 2:01
  at rest after, all        183-215 MB

(ps RSS reads 500-720 MB at rest in every build: macOS counts the pages Go
already gave back with MADV_FREE until it takes them; heapReleased was
438-678 MB of that.)

Run:
- TestUnderTightGC (new): the read runs under 25 from GOGC 100 and 200,
  under 10 from 10, and with GC off from off; each is put back after.
  TestWarmUpTightensOnlyTheUsageRead: other warm-up steps run at 100.
- go test -run 'TestWarmUp|TestUnderTightGC' ./internal/gui ok.
- gofmt -l clean.
- go test -tags nogui -count=1 ./internal/gui (the whole package) ok
  77.2s; GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gui
  ok. No other test sets or reads GOGC (grep SetGCPercent/FreeOSMemory
  in *_test.go). The full suite's last run (e58108c3b, the commit before)
  had every package ok but internal/agent at the 45m deadline under load
  ~120; alone it passed in 2213s (noted on #2544).
2026-10-21 19:12:19 +08:00
yetone 1bd99194ea provider: Claude Code stays listed, signed out, when every saved account's sign-in is gone
LeeHom on Discord: two Claude Pro accounts vanished from Providers, and
signing one in again showed the other as "needs sign in again". While
Claude Code is signed out, the claude provider is built on
claudeStandIn's account. claudeStandIn skips an account whose sign-in
Claude Code let go of (claudeLoggedOut's claudeLogoutLapse) or that is
still Held. With every saved account like that, it returned "", no claude
provider was made, and the subscription and both accounts left the GUI,
the TUI and `magpie providers` at once.

claudeStandInAccount and Logins now ask claudeListed: the stand-in, else
the signed-out account seen last. A Held account is never listed this way,
because the sign-in Claude Code left on disk would then be served
(TestClaudeSignedOut still holds). The listed account's token still fails
with the lapse reason (claudeSavedDir), so nothing is served on it.
claudeStandIn itself is unchanged, since addLogin and logins_on rely on
it.

The app's row already said "{user} is signed out" when every login in use
had lapsed. Provider.SignedOut is that rule in Go. With it, `magpie
providers` says "○ <user> is signed out · sign in again" and the TUI says
"○ <user> is signed out", instead of a green "signed in". The CLI's key
column moved into keyColumn so it can be tested. The providers-accounts
doc row says this.

Tests:
- TestClaudeAllSignedOutStaysListed: signed in, a second account
  logout-lapsed, then Claude Code signed out. It fails on the old code
  ("Claude Code left the Providers list with every account signed out:
  false") and with SignedOut returning false (both broken by hand).
- TestProvidersSaySignedOut, in cli and tui: a signed-out account reads
  as signed out and a signed-in one still reads as signed in.

Run: gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags
nogui ./..., GOOS=windows go vet ./...; go build for all three.

Then go test -timeout 45m ./... under a sandbox HOME at base ba319a758
(load ~25). Every package was ok except two:
- internal/agent timed out with a 2s-old test running (rerun alone: ok
  1866s).
- internal/gateway failed TestRateLimitIsWaitedOut, "an hour away: passed
  on after 1.32s" against its 1s bound. That is #1971, open, a wall-clock
  bound under load and not this change; rerun alone: ok 1433s.

Rebased on d771138c4 (13 commits, including c79400556 in
agent/provider.go). At the pushed head: gofmt clean, go build for darwin,
linux nogui and windows, go vet of provider/cli/tui, and go test
./internal/provider ./internal/cli ./internal/tui all ok. No GUI file
changed, so the GUI suite was not run.

Not tried: a real Claude account signed out in Claude Code. The sandbox
test drives the same files (.credentials.json, .claude.json, logins.json).
2026-10-21 19:00:33 +08:00
yetone d771138c41 provider: WorkBuddy's mover min is 0.1.29, which sends a refused system prompt again as the user's instructions
Wing on Discord (10-21) got 400 11128 "Illegal API invocation from an
unapproved channel" from WorkBuddy with an agent whose lines the plugin
didn't reword. WorkBuddy checks only system and assistant messages, against
lines it knows. Since 0.1.29 (magpie-community/plugins af360a5), a chat it
refuses that way is sent once more with its system prompt moved into the
first user message, inside <instructions> tags, and WorkBuddy's default
system prompt in its place. The refusal still rests no account, as since
2033df0f. The comment also records 0.1.28, which wasn't noted when it was
published.

npm view @magpie-community/opencode-workbuddy-auth version --prefer-online
--registry https://registry.npmjs.org: 0.1.29 (dist-tags latest 0.1.29).
publish.yml run 39584806291 published it ("+ ...workbuddy-auth@0.1.29").
The run is red only for think-tags' known E404 (plugins#180).

Run at e68a0b1db plus this change:
- gofmt -l internal/provider: empty. go vet ./internal/provider on darwin,
  GOOS=linux -tags nogui and GOOS=windows: ok. go build ./...: ok.
- go test -timeout 45m -count=1 ./internal/provider: ok (207s). The first
  try failed on "no space left on device" while another session's
  `go test ./...` and four other suites ran at load ~145. After space came
  back (42G), it passed.
- The full suite wasn't run: another session's `go test ./... -timeout
  100m` was running, and only one suite runs on a machine at a time. The
  change is the min string and its comment.

The plugin's real runs (both builds, OpenCode 2.0.25 and omp 18.9.1 with
tool calls) are in af360a5's body.
2026-10-21 18:47:24 +08:00
yetone c627652e9a settings: lightweight mode is off for a user who never chose
The owner, 10-21: "要默认关闭「轻量模式」,不然太卡了". With it on, the window
is made again and its page loaded again on every opening, which is slow.
28bec1507 had made it on for a user who never chose, against a hidden
webview growing ~20 MB a minute on Windows (#2515); that user now gets
the kept window again. A user who turned it on or off keeps their choice:
only an unset value changes meaning (LightweightOn, Settings › General's
row).

Run on origin/main b855cfee9 + this commit, macOS, playwright 1.62.0:
- go test ./internal/settings/ -run Lightweight ok; red with the old
  LightweightOn.
- lightweight.test.cjs, segs-glide, segs-press-redraw, settings-general:
  89/90 in chromium and webkit, every language; the red was
  segs-press-redraw chromium en 440px while a full GUI suite ran beside
  it, and the file passes 42/42 alone. lightweight.test.cjs goes 4 of 8
  red with app.js's old `!== false`.
- gofmt -l clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet
  of internal/settings and internal/gui.

Shipped at the owner's word (10-21, "赶紧上线") before the full GUI suite
finished: it was stopped at ~2,040 passing tests (about a quarter of the
files, on b855cfee9 + the dialog change), with two reds,
desktop-longest chromium zh 640px and gateway-key-groups chromium en,
both under load at ~100. On origin/main c79400556 + both commits (rebased after onto
e68a0b1db, which adds only internal/sessions):
desktop-longest, gateway-key-groups, modal-morph, lightweight,
segs-glide, segs-press-redraw and settings-general 108/108 in chromium
and webkit; go test ./internal/settings/ ok; go test ./internal/gui/
-run 'Budget|Lightweight' ok; gofmt -l clean; GOOS=linux go vet -tags
nogui and GOOS=windows go vet of internal/settings and internal/gui.
Not run: the rest of the GUI suite.
2026-10-21 18:45:23 +08:00
yetone 1b9b97f8db gui: a provider's dialog grows out of its icon and name, as an add sheet tile's does
The owner, 10-21: the provider editor's opening was stiff ("太生硬"), and
the add sheet's, opening a vendor's tile, is the one to follow. Both run
through openModal's morph, but a tile is narrower than the dialog, so the
dialog starts shrunk to it (scale ~.4) and zooms out; a provider row is
wider than the dialog, so the scale stayed 1 and the dialog opened as a
full-size strip widening over the row, its text at full size from the
first frame.

A provider row is now measured as a tile: from its left edge to where
its name and host line's words end (rowOwnRect, the text nodes' extents;
a range over the block spans its whole width), the row's height. The
dialog grows out of that and folds back into it, as a tile's does.

Run on origin/main b855cfee9 + this commit, macOS, playwright 1.62.0:
- modal-morph.test.cjs: 6/6 chromium and webkit, 1240 and 420px. Its new
  checks (starts at the row's left, ends before the words do, scale < .8;
  closes into the same) are red on the old app.js: chromium 1240 and 420
  fail.
- frames held at 8/16/30/50% of the opening and closing, row beside the
  add sheet's Custom provider tile, looked at side by side.
- go test ./internal/gui/ -run Budget ok; gofmt -l clean.

Shipped at the owner's word (10-21, "赶紧上线") before the full GUI suite
finished: it was stopped at ~2,040 passing tests (about a quarter of the
files, on b855cfee9 + the dialog change), with two reds,
desktop-longest chromium zh 640px and gateway-key-groups chromium en,
both under load at ~100. On origin/main c79400556 + both commits (rebased after onto
e68a0b1db, which adds only internal/sessions):
desktop-longest, gateway-key-groups, modal-morph, lightweight,
segs-glide, segs-press-redraw and settings-general 108/108 in chromium
and webkit; go test ./internal/settings/ ok; go test ./internal/gui/
-run 'Budget|Lightweight' ok; gofmt -l clean; GOOS=linux go vet -tags
nogui and GOOS=windows go vet of internal/settings and internal/gui.
Not run: the rest of the GUI suite.
2026-10-21 18:45:23 +08:00
yetone 3c38fe5c99 agent: Zoo Code (VS Code) through its autoImportSettingsPath (wani on Discord)
wani on Discord (#feedback) asked for Zoo Code (zoocode.dev), a fork of Roo
Code for VS Code and JetBrains.

Route: Zoo Code keeps its provider profiles in VS Code's SecretStorage,
which magpie can't write. The one file it reads is the one its
zoo-code.autoImportSettingsPath setting names. On every activation
(src/utils/autoImportSettings.ts, Zoo Code 3.90.0) it imports that file as
Settings → Import does (importSettingsFromPath). magpie writes
<User>/globalStorage/zoocodeorganization.zoo-code/settings/magpie-import.json
with one profile, "magpie": apiProvider openai on the gateway's
/v1 Chat Completions, key magpie-zoo-code, the chosen model, and an
openAiCustomModelInfo built from the catalog (contextWindow, else Zoo's own
128000 default; maxTokens only when an output limit is known). It points
the setting at that file in the default settings.json and in each VS Code
profile's. A value the user set themselves is stashed and restored by
Disconnect. The file sits outside magpie's folder so that a sync keeps an
address the user moved (kept.away skips magpie's own folder). Requests say
"ZooCode/<version>", and usage names them zoo-code.

Limits (also in docs/reference.md → Zoo Code):
- Zoo reads the file only at start: the notice asks for Developer: Reload
  Window.
- While connected, each start switches Zoo back to the magpie profile.
- Disconnect stops the import but can't delete the imported profile
  from SecretStorage. The user switches away from it or deletes it in Zoo.
- VS Code Stable only.

JetBrains is not wired. Zoo Code for JetBrains runs the extension in its own
extension host, which is handed an empty configuration on every start
(RPCManager.startInitialize in Zoo-Code-JetBrains), so the setting never
reaches it. Its secrets sit in ~/.zoo-code/secrets.json, an internal store
with no lock and no documented format. Neither is a clean route.

Tests (internal/agent/zoocode_test.go):
- TestZooCode: connect, model switch, a stale key that Check reports and
  Sync fixes, and disconnect putting the user's own import path back byte
  for byte with the file removed.
- TestZooCodeFresh and TestZooCodeProfiles: VS Code profiles, including one
  made after connecting.
- TestZooCodeDetectAndUA: Roo alone is not detected; ZooCode/3.90.0 maps to
  zoo-code.
Broken by hand (the restore disabled): TestZooCode and TestZooCodeProfiles
went red.
The generated file was checked with bun against Zoo's own zod schemas
(providerSettingsWithIdSchema, isProviderName; zod 4.6.7 from its repo):
valid, every field kept, current profile in apiConfigs.

Run, set -o pipefail, GOMODCACHE pinned, sandbox HOME:
- First full run, with this change on ba319a758 at 49bec8c4f:
  - gofmt -l clean.
  - go vet darwin, GOOS=linux -tags nogui and GOOS=windows: clean.
  - go test -timeout 45m ./...: 67 packages ok, including gateway 2543s,
    gui 509s and library 2326s.
  - internal/agent was red: TestSyncKeepsAnAddressOnAnotherMachine. The
    import file was then in magpie's folder, which kept.away skips, so a
    NAS address was lost. The file was moved into Zoo's globalStorage
    folder. The package also hit the 45m deadline under load (#2544).
- After the fix: -run 'ZooCode|TestSyncKeepsAnAddressOnAnotherMachine|
  TestReverseProxyIsStillMagpie' ./internal/agent was ok in 112.9s.
- At 0aa9c53ce: gofmt -l clean, internal/agent vet clean three ways, and
  go test -timeout 90m ./internal/agent ./internal/library ./internal/gui
  ok (agent 1912s, library 1299s, gui 420s).
- GUI suite in both engines: 283/283 in chromium and 283/283 in webkit
  (playwright 1.62.0). It covers the 44 files the change can reach:
  gui-de, gui-ja, gui-zh-tw, i18n-keys, agent-notice-lang,
  models-add-and-icons, mono-icon-redraw and every agent-*.

After rebasing onto origin/main 049040283 (which changed internal/agent/claude.go):
- go vet ./internal/agent clean three ways; linux nogui and windows
  builds ok.
- -run 'ZooCode|Compact|TestSyncKeepsAnAddressOnAnotherMachine|UserAgent|AgentOf'
  ./internal/agent ok in 35.9s.
- The darwin go build of the binary hit a full disk at link (this
  machine's, 369M free), not a code error.

Not tried: real VS Code (not installed on this machine), Windows and Linux.
2026-10-21 18:43:06 +08:00
yetone 049040283e codex: a searched conversation under Codex's web.run isn't sent the hosted web_search beside it (Savin on Discord)
Savin (#help, magpie 0.1.1296, Codex 0.163.0-alpha.10.2, signed in with
ChatGPT): the turn failed with the ChatGPT backend's "a single request
can't contain both a client-declared function web.run and the hosted tool
web_search".

Who adds which:
- web.run is Codex's own. codex-rs/ext/web-search (tool.rs) declares it
  as a function "run" in the "web" namespace, and spec_plan.rs's
  hosted_model_tool_specs leaves the hosted web_search out whenever
  web.run is registered: on a Responses Lite model (whose requests take
  no hosted tools at all), or with the standalone_web_search feature on.
  Codex never sends both itself.
- The hosted web_search was magpie's. provider.DeclareSearch (#1270)
  adds the cached-only {"type":"web_search","external_web_access":false}
  to any ChatGPT-bound request whose input replays a web_search_call
  without declaring search. declaresSearch looked only for a web_search*
  type, so a conversation that had searched with the hosted tool and
  went on under web.run (a Lite model, a newer Codex, or magpie's own
  searcher's web_search_call items) got web_search added beside web.run,
  in the additional_tools item for Lite or in the tools. The backend then
  refused the turn.

What changed: declaresSearch counts web.run as the conversation's search.
It matches the namespace "web" holding a function "run", and a function
named "web.run". DeclareSearch then leaves the body as Codex sent it.
This covers both routes that call it: codexBody (a ChatGPT account in
magpie) and codexUpstreamOn (Codex's own sign-in relayed). Nothing the
client declared is dropped. web.run is the tool the backend serves this
client (through /alpha/search), so magpie no longer adds the tool that
conflicts with it. A namespace other than "web" with a "run" function
still gets web_search declared.

Not verified: whether the ChatGPT backend accepts a replayed
web_search_call under web.run with no hosted tool. That is the request
the official Codex client sends to it directly. It was not probed on a
real account, and the test fake assumes it is accepted.

Tests:
- TestDeclareSearch: new cases cover web.run in Lite's additional_tools,
  web.run among the tools, the flat "web.run" function, and another
  namespace's run.
- TestSearchedConversationUnderWebRun: protectedSearch now refuses a
  request that carries both tools, with Savin's error. The test covers
  Lite on Codex's sign-in (relayed byte for byte) and two turns on a
  ChatGPT account (Lite and tools).
- On ba319a758 without the codex_request.go change, both tests fail.
  The gateway test gets the 400 with Savin's error. With the change,
  both pass, along with TestSearchedConversation* and
  TestUnsearchedConversationUnchanged.

docs/subsystems/gateway-routing.md says it next to #1270.

Run:
- gofmt -l: clean. go vet ./... passes on darwin, GOOS=linux -tags nogui
  and GOOS=windows -tags nogui.
- `set -o pipefail; go test -timeout 45m ./...` at base ba319a758: every
  package ok except internal/agent and internal/gateway. Both hit the 45m
  package timeout with no test failing. The tests in flight at the panic
  had run 5s and 0s, and four suites from other sessions were running on
  the machine.
- Rerun of those two at -timeout 90m: gateway ok (2057s), agent ok
  (2418s).
- Rebased onto c79400556, whose 4 new commits touch agent, library,
  redact and provider. Rerun there: gofmt, vet on all three OSes,
  ./internal/provider ok, ./internal/redact ok, and
  ./internal/gateway -run 'Search|Codex|WebRun|Protect' ok.
- Rebased again onto e68a0b1db (4 commits in internal/sessions only).
  go vet on sessions, provider and gateway passes there.
2026-10-21 18:40:51 +08:00
yetone e68a0b1db5 sessions: a prompt's title reads only as far as it keeps, not through a regexp and runes of the whole prompt
title collapsed white space with regexp's \s+ over the whole prompt and
then made runes of all of it to cut at 160. A pasted file as the prompt
went through both whole: sessions.title was 0.45 GB of a cold start's
first 2 minutes (cxPrompt 334 MB, ccPrompt 112 MB). It now collapses and
counts in one pass and stops at 160 characters, then looks only for
whether anything but space follows. The result is the same: each run of
\t \n \f \r and space one space, Unicode space trimmed at both ends, a
byte not UTF-8 kept as it was in a short title and U+FFFD in a cut one.
The regexp `space` had no other user and is gone.

Run:
- TestTitleAsBefore (new): equal to the old code on the edge cases
  (159/160/161 characters, \v and NBSP and U+0085 at the ends, invalid
  bytes, CJK) and on 20,000 random strings of those runes.
- TestTitleOfALongPromptAllocatesItsTitle (new, a ~900 KB prompt): red
  with title pointed back at the old code ("50 allocations"); green now,
  at most 8 allocations and 4 KB.
- go test ./internal/sessions/ ok, and with -race ok.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui ok.
2026-10-21 18:19:48 +08:00
yetone 4c0afc26d7 sessions: scan buffers and zstd decoders are kept on a small shelf across garbage collections, let go after 10 s unused
The line readers, long-line buffers and zstd decoders scans use were kept
only in sync.Pools, and a pool lets what it holds go at every second
collection. A cold start collects about once a second (155 GCs in its
first 2 minutes), so the pools were mostly empty when asked. A probe
build counted, in those 2 minutes: 611 new 1 MiB line readers, 205
long-line buffers taken from an empty pool (114 more from one too small,
833 MB in all) and 281 new zstd decoders (~3 MiB each).

A shelf keeps up to 4 of each (per line-reader size class; long lines up
to 4 MiB, longer ones still go to the pool), takes before the pool and
gives back before it, and lets everything go once nothing was taken or
given back for 10 s, so an idle magpie holds none of it. A full long-line
shelf keeps the larger buffer.

Run:
- TestLineReaderKeptAcrossCollections, TestLongLineKeptAcrossCollections
  (new): with the shelves' takes removed both are red ("a 1 MiB line
  reader was made again after three collections", "a 2 MiB long-line
  buffer ..."); green now. TestShelfFullKeepsTheLarger,
  TestShelfLetsGoWhenIdle (new, waits for the state, 10 s bar).
- go test ./internal/sessions/ ok; -race ok (the first try raced on a
  test writing the idle time as a global under a live timer; it is a
  field of the shelf now); -race -count=20 on the new tests ok.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui ok.
- Cold start in a sandbox HOME (startheap-home, calls and sessions
  caches removed), serve --web, run until the caches stop growing; both
  wrote the same 6,437 files, 70,069,451 bytes. With this and the two
  commits before (objectEnd, prefixHash), two runs each, alternating:
    old:  12.57 / 11.92 GB allocated, 145 / 149 GCs, CPU 2:01 / 1:55,
          settled at 213 / 192 s
    new:   7.38 /  7.23 GB allocated,  85 /  87 GCs, CPU 1:52 / 1:50,
          settled at 191 / 161 s
  RSS at the end is unchanged (714-748 MB): the peak is the warm-up
  listing holding every row, not these buffers.
2026-10-21 18:19:48 +08:00
yetone 002b4eb080 sessions: prefixHash reads into one pooled buffer instead of io.CopyN's
io.CopyN made a new buffer for every call, and for each of the 16
samples of a long file (64 KB a call). Every session and call log is
hashed this way on a cold start: io.copyBuffer via prefixHash was 0.78 GB
of 11.57 GB allocated in the first 2 minutes. It now reads into a pooled
64 KB array: ReadFull for a short prefix, ReadAt for each sample. A
sample short of its window is still unknown (""), as CopyN's error was.
The hash is byte-for-byte the same, so stored sample-v1 hashes still
match.

Run:
- TestPrefixHashUnchangedAndUnbuffered (new): equal to the old
  CopyN code at 0, 1, 4095, 4096, 65535, 65536, 65537, 1 MiB and 3 MiB,
  and "" past the end as before; with prefixHash pointed back at the old
  code it is red, "hashing a long log allocated 65 KB"; green now (under
  -race the pool drops some puts, 13 KB, so the bar is 24 KB).
- go test ./internal/sessions/ with -race ok; -race -count=5 on the new
  test ok.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui ok.
2026-10-21 18:19:47 +08:00
yetone a0f3b33b1f sessions: a Claude reply's tool blocks and usage are decoded from their object, not by a decoder copying the rest of the line
ccTools and ccReply's usage each opened a json.Decoder over the rest of
the line, and the decoder copies what it reads ahead into its own buffer.
A long tool input was copied once per tool block and once for usage. In a
cold-start heap profile (11.57 GB allocated in the first 2 minutes) this
was the largest site: Decoder.refill, 1.6 GB, via ccReply/ccTools.
objectEnd now finds the end of the object (brackets outside strings) and
json.Unmarshal decodes only those bytes, which still checks them.

Run:
- TestClaudeReplyDecodesWithoutCopyingTheLine (new; a 1 MiB tool input
  plus a Skill tool through claudeLine): red on the old decoder path,
  "a 1024 KB reply allocated 4100 KB to read"; green now, under 256 KB.
- TestObjectEnd (new): nesting, braces and escapes in strings,
  unterminated, a leading space, empty.
- go test ./internal/sessions/ ok, and with -race ok (79s);
  -race -count=5 on the new tests ok.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui ok.
2026-10-21 18:19:47 +08:00
yetone c79400556c agent: a Claude model on Bedrock runs to its own window in Claude Code, not 272K
划船不靠桨 on Discord (0.1.1306) asked why magpie sets
CLAUDE_CODE_AUTO_COMPACT_WINDOW=272000 for a 1M model. writeCompact already
skips the working window for Anthropic's Claude models and for routing
groups made only of them (provider.ClaudeGroup). But the agent package's
claudeModel only knew a name that starts with "claude", so a 1M Claude
model listed under Amazon Bedrock's name (us.anthropic.claude-opus-…[1m])
was held to 272K, while a group of the same model ran to 1M. claudeModel
now asks provider.ClaudeModel, which takes the vendor prefix off first.

The reporter's own setup (a deepseek-v4-flash auto routing group of
WorkBuddy, Qoder and a newapi relay) is not this bug. A probe in a sandbox
HOME showed 272000 for group/auto-deepseek-v4-flash, its [1m] form and
auto/deepseek-v4-flash, the group listed at its largest member's 1048576.
That is settings.WorkingWindow, the default for any non-Claude model or
mixed group over 272K (e950eb08). Settings -> Long conversations -> Full
window, Compact at (global, per provider or per model), or a window typed
on the group lift it. tune's compaction advice covers Claude models only,
so it isn't the source.

Test: TestClaudeCompactWindowBedrockClaude. A 1M Bedrock Claude model with
[1m] leaves the env unset, after Sync too, and a 1M Nova model on the same
provider still gets 272000. On the old claudeModel it fails with "a 1M
Claude model on Bedrock is compacted at \"272000\"".

Run at this head: gofmt -l clean; go vet ./... (darwin), GOOS=linux go
vet -tags nogui ./..., GOOS=windows go vet ./...; go build for all three.
Then go test -timeout 45m ./... under a sandbox HOME: every package ok
except internal/agent, internal/gateway and internal/library, which timed
out at 45m at load average ~25 (other sessions' suites), each with a
test 1-3s old running, so no hang. Rerun alone (-timeout 60m): agent ok 2660s, gateway ok 2238s,
library ok 2151s. That suite ran at base ba319a758. Rebased on e65688886
(three commits, in library and redact only): go build ./... and
go test ./internal/agent -run Compact pass at the pushed head.

Not changed: the 272K default for non-Claude models and mixed groups.
Also not changed: a Claude [1m] model picked mid-session in /model while
the main model is not Claude still runs under the main model's env
until the next session.
2026-10-21 18:13:59 +08:00
yetone e656888867 library: Library → Instructions gives Devin its global AGENTS.md (#3151, eqe365 on Discord)
eqe365 on Discord (#3151): Devin CLI reads AGENTS.md, but Library →
Instructions listed Devin as keeping no user-wide instructions file.
Devin's target had Skills and MCP and no Instructions.

Source: the docs Devin CLI 3000.11.92 ships with it,
share/devin/docs/extensibility/rules.mdx ("Rules & AGENTS.md" → Global
Rules). It reads global rules from ~/.config/devin/AGENTS.md
(%APPDATA%\devin\AGENTS.md on Windows) at the start of every session, and
the singular AGENT.md there too. Devin's folder (a.Dir) is already that
folder, so Instructions is AGENTS.md there, or AGENT.md when only that
one exists (firstThere). The GUI is data-driven and needs no change.

Test: TestDevinInstructions (internal/library/agent_skills_test.go)
checks:
- the target is AGENTS.md before the file exists;
- Save writes the shared block after the user's own text;
- with only AGENT.md present, that file is the target.
With targets.go reverted it fails: "Devin's instructions: "", want
.../.config/devin/AGENTS.md before the file is there".

Run with this change on origin/main ba319a758 (before the rebase),
set -o pipefail, GOMODCACHE pinned:
- gofmt -l: clean.
- go vet ./..., GOOS=linux go vet -tags nogui ./... and GOOS=windows
  go vet ./...: all clean. darwin, linux nogui and windows builds: ok.
- go test -timeout 45m ./...: 66 packages ok. Two timed out at 45m
  while the machine's load average was 24 to 60 (other sessions'
  suites):
  - internal/library (2724s; TestCheckSkills had been running 6s at the
    deadline). Alone at -timeout 90m it is ok in 2204s. This is #2853.
  - internal/agent (2714s). It doesn't import internal/library, so it
    runs the same code as origin/main. This is #2544.
- Packages that import library are ok: backup, cli, davsync, gui,
  profile, tui.
- No GUI files touched.

Not tried: a real Devin session reading the file; the claim rests on
Devin's own shipped docs.
2026-10-21 18:05:03 +08:00
yetone b855cfee9e redact: a file named like an address (…@2x.jpg) is not masked as an email (#3029)
vdxz on Pi with personal data masked: /Users/…/Pictures/261020_14-16-11@2x.jpg
went to the model as /Users/…/Pictures/{{EMAIL_…}}, and Pi could no longer
read the file. A Mac saves an image at twice its size with @2x before its
extension, which the EMAIL rule reads as user@2x.jpg.

realEmail leaves an address whose last label is a file extension no
top-level domain has (fileExt: jpg, png, gif, webp, svg, heic, pdf and
the like; py, md, sh, zip and mov are domains and stay out of it). The
local model's EMAIL spans pass the same check now (modelTakes), so it
can't mask the name the rule leaves. An address beside the file's name
is still masked.

TestFileNameIsNoEmail uses the reporter's path. Broken by hand: with
redact.go as on main the rule's half fails, with model.go as on main the
model's half fails.

Run at this head (on the #3143/#3144 commit, origin/main ba319a758):
- gofmt -l clean; go vet clean on macOS, GOOS=linux -tags nogui and
  GOOS=windows.
- go test ./internal/redact ./internal/masking ./internal/gateway
  -timeout 100m: ok (gateway 2742s at load ~25).
- The commit below this one ran go test ./... -timeout 100m: 68
  packages ok; this one touches internal/redact and its doc only.
2026-10-21 17:20:42 +08:00
yetone 88119d4f67 redact: Codex's tool server names, stream_options and snake_case words go as written (#3143, #3144)
Two reports from hibaliqya-yonma (v0.1.1306, Codex Desktop through
/backend-api/codex), each a 400 on every request until masking was
turned down:

- #3143: a user's word that is part of an MCP server's name went into a
  Responses function_call's namespace as mcp__{{TERM_…}}. Codex checks a
  namespace against ^[a-zA-Z0-9_-]+$, and the call is replayed every
  turn. namespace is kept as name is, and so are the server's name in
  its siblings: a Responses mcp_call's server_label, Anthropic's
  mcp_tool_use server_name.
- #3144: the local model took stream_options.reasoning_summary_delivery,
  "sequential_cutoff", for a name. stream_options is a request setting
  now (defKeys, with reasoning and text), and the model's name is never
  a snake_case word (snakeWord), wherever it is, so an enum or an
  identifier in a tool's arguments or in code is not taken either.

The same word in the user's own message is still masked, and a name
beside it still is. docs/subsystems/gateway-routing.md says both.

Tests from the reporter's bodies: TestMaskJSONKeepsReasoningSummaryDelivery,
TestMaskJSONKeepsToolServerNames (namespace, server_label, server_name),
TestModelTakesNoSnakeWord. Broken by hand: with json.go and model.go as
on main, all three fail; with the change they pass.

Run at this head (origin/main ba319a758):
- gofmt -l clean; go vet clean on macOS, GOOS=linux -tags nogui and
  GOOS=windows.
- go test ./... -timeout 100m: 68 packages ok, exit 0.
- With #3029's commit stacked on it: go test ./internal/redact
  ./internal/gateway ok (gateway 2742s at load ~25), vet the three ways
  clean.
2026-10-21 17:20:37 +08:00
yetone ba319a7587 gateway: the lone tool_choice none goes to the Grok plugin only (#3110)
19527ca8d sent a lone tool_choice "none" (tools turned off, none
declared) to every provider plugin on Responses. No other plugin's
vendor had been tried with one. commandcode, factory, opendesign and
zed don't touch tool_choice in their fetch/rewrite (git grep on
magpie-community/plugins origin/main), so it would have reached their
vendors as is, and a 400 there would be a regression. Only the Grok
plugin reads it, and grok 0.1.18 drops it before Grok.

keepsLoneNone now keeps it for the Grok plugin alone (still not when
the plugin points at xAI or Copilot, #378); forwardTranslated strips it
for every other upstream, as before 19527ca8d.

Run at this commit (on 19527ca8d):
- gofmt -l: clean
- go vet ./...: darwin, GOOS=linux -tags nogui, GOOS=windows: clean
- set -o pipefail; go test -timeout 45m ./...: exit 0, 68 packages ok
  (gateway 475.6s, provider 173.9s), no FAIL
- broken by hand: keepsLoneNone back to "any plugin" turns the new
  TestToolsOffWithoutToolsNotSentToOtherPlugins red; returning false
  turns TestToolsOffWithoutToolsReachesPlugin red; both green restored

Not tried: no vendor was sent a real request; with this change none
but Grok's plugin path can receive the lone "none", and that plugin
drops it.
2026-10-21 10:25:31 +08:00
yetone 19527ca8dd gateway: tools turned off with none declared reach a plugin as tool_choice none (#3110)
Cause: buildResponses wrote tool_choice only inside its tools block, so a
Chat "none", Anthropic {"type":"none"} or Gemini NONE with no tools was
dropped on the way to Responses. A provider plugin that adds a
server-side tool (Grok's x_search, plugins PR #263) couldn't tell
"tools off" from "no choice". The other builders (Chat, Anthropic,
Gemini, Code Assist) send no tool choice without tools, which is what
their vendors accept (OpenAI Chat refuses a lone tool_choice), so they
are unchanged.

Fix:
- buildResponses keeps a lone "none" (only "none"; "" and "auto"
  still go unsaid).
- forwardTranslated strips it again for every non-plugin upstream, and
  for a plugin on api.x.ai or Copilot (refusesLoneToolChoice, the #378
  rule now shared with passthrough). A vendor never sees it.
- The grok plugin's body shaping (grokPluginBody) keeps a lone "none";
  the built-in's grokBody still drops it. grok plugin 0.1.18
  (magpie-community/plugins aee6b9d, on npm) drops any lone tool_choice
  itself before Grok, so the mover's min goes 0.1.17 -> 0.1.18.

Run at this commit (worktree on efd1b697e):
- gofmt -l: clean
- go vet ./...: darwin, GOOS=linux -tags nogui, GOOS=windows: clean
- set -o pipefail; go test -timeout 45m ./...: exit 0, 68 packages ok
  (gateway 660.6s, provider 270.9s), no FAIL
- broken by hand, each went red then green on restore: removing the
  "none" emit (ReachesPlugin, PerBuilder/responses); grokPluginBody with
  keepNone=false (TestGrokPluginBodyKeepsLoneNone, ReachesPlugin);
  dropping the !p.IsPlugin() check (NotSentToVendor)
- plugins: bun test 2018 pass, 0 fail; the new tool-choice test is red
  against the old index.mjs

Not tried: live Grok, xAI or OpenAI with a lone "none". Other Responses
plugins (commandcode, factory, opendesign, zed) now get a lone "none" in
this case; their vendors take Codex's lone "auto", but this is untested.
2026-10-21 10:14:07 +08:00
yetone efd1b697e4 sessions: a cached file's calls are read into a slice made for them
loadCalls appended each decoded patch to a nil slice, so every cached
file's calls grew through append's steps. In a warm start's 30s
alloc_space profile (sandbox HOME, ~380k calls) that append was 509 MB,
the largest single site. Each frame now grows the slice once by its
patch count (slices.Grow), which a frame of new calls fills exactly.

TestLoadedCallsAreSizedOnce: 3000 cached calls came back in a slice of
3246 on the old code (red, run with the change stashed); 3006 now, the
allocator's size class. It also reads back a second appended frame.
go test -tags nogui ./internal/sessions/ ./internal/usage/: ok.

At 8b48dc5d6 (this commit and the two beside it, on 5c557c793):
gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui ./...
clean; go test -race -tags nogui ./internal/usage/ ./internal/sessions/
ok; go test -tags nogui -timeout 45m ./... with pipefail: 68 packages
ok, no FAIL.
Warm start in a sandbox HOME, magpie serve --web (ps RSS / footprint /
heapSys at 30s): origin/main 650 / 213 / 649 MB, all three 606 / 208 /
598 MB. Allocated in the first 30s: 2557 MB before, 1878 MB after.
2026-10-21 09:41:29 +08:00
yetone 80d32fd609 usage: a Claude Code call skips the desktop-root path arithmetic
sessionResolver.desktopIdentity ran filepath.Rel and strings.Split
against every desktop root for every claude call, though only a file
under a root's local-agent-mode-sessions can name a desktop identity.
In a warm start's heap profile (sandbox HOME, ~380k calls) that was
178 MB from Rel and 98 MB from Split in the first 30s, about a fifth
of what gui.warmUp's first Requests read allocated. A path without the
folder name can't produce a Rel whose first segment is that name, so
the guard is exact.

TestDesktopIdentityOfCLICallAllocatesNothing: 6 allocs per call on the
old code (red, run with the change stashed), 0 now.
go test -tags nogui ./internal/usage/: ok, TestDesktopSessionAccountMetadata
unchanged.

At 8b48dc5d6 (this commit and the two beside it, on 5c557c793):
gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui ./...
clean; go test -race -tags nogui ./internal/usage/ ./internal/sessions/
ok; go test -tags nogui -timeout 45m ./... with pipefail: 68 packages
ok, no FAIL.
Warm start in a sandbox HOME, magpie serve --web (ps RSS / footprint /
heapSys at 30s): origin/main 650 / 213 / 649 MB, all three 606 / 208 /
598 MB. Allocated in the first 30s: 2557 MB before, 1878 MB after.
2026-10-21 09:41:29 +08:00
yetone 16d20c0b3d usage: a packed block keeps its compressed bytes, not S2's worst-case buffer
s2.Encode makes its output MaxEncodedLen(len(src)) long, more than the
rows' own bytes, and pack kept the archive as a slice of it
(slices.Clip trims the capacity, not the allocation). Every cached
session block and every gateway log block (log_index.go) so held its
whole uncompressed size plus S2's slack, while Bytes counted only the
compressed length, so the cache budget undercounted it too. pack now
encodes into pooled scratch (the rows' bytes and S2's output) and
copies the archive out at its own length.

Measured on a sandbox HOME (a clone of a 23 GB Codex + Claude Code
history, ~380k calls), magpie serve --web, warm call caches, heap
profile from /v1/magpie/heap:
- at rest (2 min): s2.Encode's archives 17.2 MB -> 9.2 MB (slices.Clone)
- at the warm-up's peak (6 s): archives 45.3 MB -> 30.6 MB
- liveHeap at 30 s 96.1 MB -> 90.3 MB, footprint 213 MB -> 203 MB

TestPackedArchiveHoldsOnlyItsBytes packs 100 blocks of 2000 rows and
measures what stays reachable after a collection. On the old pack it
fails: "100 packed blocks hold 16035 KB for 3887 KB of archives"
(3 of 3 runs); with the change it passes, and blocks packed through
the same scratch read back their own rows.

At 8b48dc5d6 (this commit and the two beside it, on 5c557c793):
gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui ./...
clean; go test -race -tags nogui ./internal/usage/ ./internal/sessions/
ok; go test -tags nogui -timeout 45m ./... with pipefail: 68 packages
ok, no FAIL.
Warm start in a sandbox HOME, magpie serve --web (ps RSS / footprint /
heapSys at 30s): origin/main 650 / 213 / 649 MB, all three 606 / 208 /
598 MB. Allocated in the first 30s: 2557 MB before, 1878 MB after.
2026-10-21 09:41:29 +08:00
yetone a00900d642 provider: ZCode's mover installs plugin 0.1.20, a team's plan beside the account's own (plugins #285)
An account with a GLM Coding Plan of its own and a seat on a team's could
only reach its own plan through the plugin. zcode 0.1.20 (plugins
d87dd8f, on npm) adds "ZCode: a team's GLM Coding Plan", which signs in
to the team seat as an account of its own, "<email> (team)". Raising the
min lets keepMovedCurrent bring every moved user to it.

Run at the parent 5fadf6ace: gofmt -l (clean); go vet ./... on darwin,
GOOS=linux -tags nogui and GOOS=windows (ok); set -o pipefail;
GOMODCACHE=/Users/yetone/go/pkg/mod go test -timeout 45m ./... (exit 0).
npm view @magpie-community/opencode-zcode-auth version --prefer-online:
0.1.20.
2026-10-21 09:35:44 +08:00
yetone 5fadf6aceb gui: Settings' gateway row is titled an address, and says only its port is typed here (Chicring on Discord)
Chicring: Settings showed "网关端口" (gateway port), but the row showed
MAGPIE_ADDR's host:port.

What the field takes, from the code: renderPort posts to
/api/settings/port, and setPort (internal/gui/port.go) accepts only a port
from 1024 to 65535 (settings.CheckPort). The gateway listens on that port,
on 127.0.0.1, or on 0.0.0.0 while shared on the LAN. When MAGPIE_ADDR is
set, it is the whole host:port and comes first. The row then shows its
value and is disabled. So the row is the gateway's address, but only its
port is typed here; it isn't a second way to write MAGPIE_ADDR.

The row is renamed in every language: Gateway address / 网关地址 / 閘道位址 /
ゲートウェイのアドレス / Adresse des Zugangspunkts. The new hint says "Only
the port is set here, 1024 to 65535; MAGPIE_ADDR=host:port sets the whole
address instead. Agents magpie connected move with it. Now {url}". With
MAGPIE_ADDR set, the hint says "MAGPIE_ADDR={addr} sets the gateway's whole
address, host:port: unset it to set the port here". The CLI help (cpu,
healthcheck, heap, quota, statusline) and setPort's comment named
"Settings' Gateway port". They now say "the port in Settings' Gateway
address".

Test: gateway-port.test.cjs pins the new name and hints in en and zh. With
MAGPIE_ADDR set, it now also checks that the field shows 127.0.0.1:3426
and that the row's name and aria-label say the address. gui-zh-tw, gui-ja,
gui-de and i18n-keys cover the other languages. Broken by hand: on the old
app.js it is red, "not ok 1 - en expected: 'Gateway address' actual:
'Gateway port'", and zh red against '网关地址'.

What was run. The whole suites ran at dcf7eeae3, which was these two commits
on origin/main 592899467. They were rebased cleanly onto 5c557c793 and
re-checked there.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: ok, at both heads.
- GOMODCACHE=... go test -timeout 45m ./... in a sandbox HOME: 63 ok.
  internal/agent, internal/gateway and internal/library hit the 45m package
  timeout while other sessions' full suites ran (load ~27-40). Their stacks
  were in short tests (TestDisconnectStaysThroughSync 21s,
  TestSub2APIThinkingOffRefused 0s, TestSkillHow 10s), so nothing hung.
  Each passed when run alone:
  "ok internal/agent 1127.439s", "ok internal/gateway 1044.808s",
  "ok internal/library 1029.999s".
- The whole GUI suite, node --test --test-concurrency=2
  internal/gui/tests/*.test.cjs, with playwright 1.62.0:
  - BROWSER=chromium: "# tests 5862 # pass 5844 # fail 18".
  - BROWSER=webkit: "# tests 5854 # pass 5835 # fail 19".
  Every red file was rerun alone on a freshly fetched origin/main
  (a3ebed202 / 5c557c793) and is red there too:
  - library-row-remove (chromium, 4 of 8 runs on main): filed #3099.
  - quota-count-wrap and quota-name-translated (webkit): #2228.
  - usage-agents-hide (both engines): #2276.
  - usage-fold (chromium): #2163.
  - plugin-card-update (webkit, 2 of 4 runs on 5c557c793): #3079.
  - s3-sync (webkit): #2448.
  - usage-checkin's Qoder tab (webkit): #2549.
  - tray-usages and routing-rule-remove: passed alone on both trees.
  None of these files touch the provider editor or the gateway address row.
- At 5c557c793 + these commits: decide-endpoint-label, gateway-port,
  system-one, remote-magpie, i18n-keys, gui-zh-tw, gui-ja, gui-de and
  lan-docker in both engines: "# tests 54 # pass 54 # fail 0".
  go test ./internal/gui ./internal/cli: ok.
2026-10-21 09:13:30 +08:00
yetone 4bea86d0a3 gui: a provider that asks its own decision models (OpenRouter, Ollama …) shows System One's endpoint, not Jev's (Outvi V on Discord)
Outvi V added OpenRouter and its editor named the decision address field
"Jev 端点". The hint gave Cloudflare's …/accounts/<account id>/ai/run as the
example.

Cause: the title was "System One endpoint" only for a decide-only preset
whose name had no "jev". Every preset that also serves conversations got
"Jev endpoint". The hint gave Cloudflare's address to any preset without a
workspace ID. The placeholder was already the provider's own Decide URL.

Fix: only Jev's own decide-only presets (TypeSafe Jev, Jev · Vercel AI
Gateway, Cloudflare Workers AI · Jev) keep the Jev title and the
Cloudflare hint. Every other provider shows "System One endpoint" with a
hint of its own: "The address its decision models are asked at, POST
…/systemone under it". Every preset that reaches this path is covered:
openrouter, opencode-zen, ollama-cloud, bailian-token-plan, ollama, omlx
and mlx-serve, plus the decide-only bailian-decision and qwen-decision,
which already had the right title. The new string is in zh, zh-TW, ja
and de.

Test: decide-endpoint-label.test.cjs opens each of the ten presets with a
Decide URL from the add sheet, and edits a saved OpenRouter, in en, zh,
zh-TW, ja and de. The three Jev presets must show Jev's title and the
Cloudflare hint. The rest must show System One's title and their own
hint, with no Cloudflare or Jev in it. The saved OpenRouter's placeholder
must be https://openrouter.ai/api/v1.

Broken by hand:
- The old app.js line: red in every language, for example "expected:
  'System One endpoint' actual: 'Jev endpoint'" and zh "'System One 端点'
  vs 'Jev 端点'".
- Cloudflare's hint forced onto every provider: red, "expected: 'The
  address its decision models are asked at …' actual: \"The address Jev
  is asked at; …Cloudflare's…\"".
At this commit alone, decide-endpoint-label, system-one, remote-magpie,
i18n-keys, gui-zh-tw, gui-ja and gui-de passed in both engines: "# tests
42 # pass 42 # fail 0".

What was run. The whole suites ran at dcf7eeae3, which was these two commits
on origin/main 592899467. They were rebased cleanly onto 5c557c793 and
re-checked there.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: ok, at both heads.
- GOMODCACHE=... go test -timeout 45m ./... in a sandbox HOME: 63 ok.
  internal/agent, internal/gateway and internal/library hit the 45m package
  timeout while other sessions' full suites ran (load ~27-40). Their stacks
  were in short tests (TestDisconnectStaysThroughSync 21s,
  TestSub2APIThinkingOffRefused 0s, TestSkillHow 10s), so nothing hung.
  Each passed when run alone:
  "ok internal/agent 1127.439s", "ok internal/gateway 1044.808s",
  "ok internal/library 1029.999s".
- The whole GUI suite, node --test --test-concurrency=2
  internal/gui/tests/*.test.cjs, with playwright 1.62.0:
  - BROWSER=chromium: "# tests 5862 # pass 5844 # fail 18".
  - BROWSER=webkit: "# tests 5854 # pass 5835 # fail 19".
  Every red file was rerun alone on a freshly fetched origin/main
  (a3ebed202 / 5c557c793) and is red there too:
  - library-row-remove (chromium, 4 of 8 runs on main): filed #3099.
  - quota-count-wrap and quota-name-translated (webkit): #2228.
  - usage-agents-hide (both engines): #2276.
  - usage-fold (chromium): #2163.
  - plugin-card-update (webkit, 2 of 4 runs on 5c557c793): #3079.
  - s3-sync (webkit): #2448.
  - usage-checkin's Qoder tab (webkit): #2549.
  - tray-usages and routing-rule-remove: passed alone on both trees.
  None of these files touch the provider editor or the gateway address row.
- At 5c557c793 + these commits: decide-endpoint-label, gateway-port,
  system-one, remote-magpie, i18n-keys, gui-zh-tw, gui-ja, gui-de and
  lan-docker in both engines: "# tests 54 # pass 54 # fail 0".
  go test ./internal/gui ./internal/cli: ok.
2026-10-21 09:13:30 +08:00
yetone 5c557c793c usage: the allowance cards come in the Providers page's order (Zhenbao TONG on Discord)
Reported: Zhenbao TONG moved a provider on the Providers page, and the
tray panel's Allowances tab kept the old order.

Changed: provider.InProviderOrder(qs) (internal/provider/quotas.go) sorts
a copy of the quota cards, stably, by the provider's place in All().
Providers it doesn't know go last. Used by /api/quotas's two routes
(internal/gui/usage.go) and the TUI (internal/tui/pages.go). The app.js
comment says the order now comes from the server.

Test: TestQuotaCardsInProviderOrder (quotas_order_test.go). Broken by
hand:
  - InProviderOrder as the identity: "as added: [a/a1 remote:x/r c/c1
    b/pro a/a2 c/$1]".
  - sorting without the clone: "Quotas' list was sorted in place".
Not covered: the /api/quotas wiring has no test beyond the function's
unit test.

Run, go1.26.8 darwin/arm64, sandbox HOME, private GOCACHE:
  At this stack on origin/main df6bd3efe (head 48522d851):
    gofmt -l: nothing
    go vet ./... (darwin), GOOS=linux go vet -tags nogui ./...,
      GOOS=windows go vet ./...: ok
    set -o pipefail; go test -timeout 45m ./...: ok, EXIT=0
      (68 ok, 19 with no test files; agent 528s, gateway 628s,
      library 482s)
    GUI, playwright 1.62.0, chromium and webkit, concurrency 3: the
      171 files near this change (routing*, panel-routing*,
      window-mask, privacy*, usage*, quota*, providers*): 2217 tests,
      2183 pass, 34 fail. Every red is also red alone on origin/main:
      quota-count-wrap and quota-name-translated (#2228),
      usage-agents-hide (#2276), usage-checkin (#3091), usage-fold
      (#2163), usage-ledger (#3104, red since df6bd3efe, green at its
      parent). window-mask: 20 of 20.
  At this stack on origin/main c922225f1 (head 91baa7adb), before
  df6bd3efe's routing trace change:
    set -o pipefail; go test -timeout 45m ./...: ok, EXIT=0
      (66 ok, 20 with no test files)
    the whole GUI suite (823 files, both engines, concurrency 3):
      11589 tests, 11554 pass, 35 fail. The 9 files red were run again
      alone at --test-concurrency=1 on the head and on origin/main
      a8ecf4020. The same 7 files were red on both: the five issues
      above plus s3-sync (#2448) and library-row-remove (#3099).
      nav-sub-unroll (#1950) and plugin-updates (#3103) were red only
      under the full run. codex-predictions (#2624) was 20 of 20.
2026-10-21 08:40:49 +08:00
yetone 0084291888 gui: Hide accounts hides them in the whole window, Providers and its editor too (Zhenbao TONG on Discord)
Reported: Zhenbao TONG turned on Hide accounts to take a screenshot. The
Providers page and its editor still showed account emails, because the
mask covered only the Routing and Usage views.

Changed (internal/gui/assets/app.js): the mask's root is body in every
mode, so every page and sheet of the window is masked. It is turned on
from #rtMask and #usageMask as before, and the panel has none. mask(root)
takes a root, and the MutationObserver masks again only the roots that
changed, not the whole body.

Test: internal/gui/tests/window-mask.test.cjs, with Hide accounts on,
on Providers, its editor and the other pages. 5 languages x widths 1000
and 420 x chromium and webkit. Broken by hand (the old app.js mask):
chromium en and zh at 1000 red, waitForFunction timed out on
`#view-providers .pii`.

Run, go1.26.8 darwin/arm64, sandbox HOME, private GOCACHE:
  At this stack on origin/main df6bd3efe (head 48522d851):
    gofmt -l: nothing
    go vet ./... (darwin), GOOS=linux go vet -tags nogui ./...,
      GOOS=windows go vet ./...: ok
    set -o pipefail; go test -timeout 45m ./...: ok, EXIT=0
      (68 ok, 19 with no test files; agent 528s, gateway 628s,
      library 482s)
    GUI, playwright 1.62.0, chromium and webkit, concurrency 3: the
      171 files near this change (routing*, panel-routing*,
      window-mask, privacy*, usage*, quota*, providers*): 2217 tests,
      2183 pass, 34 fail. Every red is also red alone on origin/main:
      quota-count-wrap and quota-name-translated (#2228),
      usage-agents-hide (#2276), usage-checkin (#3091), usage-fold
      (#2163), usage-ledger (#3104, red since df6bd3efe, green at its
      parent). window-mask: 20 of 20.
  At this stack on origin/main c922225f1 (head 91baa7adb), before
  df6bd3efe's routing trace change:
    set -o pipefail; go test -timeout 45m ./...: ok, EXIT=0
      (66 ok, 20 with no test files)
    the whole GUI suite (823 files, both engines, concurrency 3):
      11589 tests, 11554 pass, 35 fail. The 9 files red were run again
      alone at --test-concurrency=1 on the head and on origin/main
      a8ecf4020. The same 7 files were red on both: the five issues
      above plus s3-sync (#2448) and library-row-remove (#3099).
      nav-sub-unroll (#1950) and plugin-updates (#3103) were red only
      under the full run. codex-predictions (#2624) was 20 of 20.
2026-10-21 08:40:49 +08:00
yetone 0eb5cbe81a routing: the live view and Usage's Requested name a found group auto/<model>, not group/auto-<model> (未寒 on Discord)
Reported: 未寒 picked auto/claude-opus-5-5, and the Routing live view and
Usage's Requested column named it group/auto-claude-opus-5-5, an internal
id that agents never see.

Changed:
  - internal/gateway/trace.go: GroupRef and SubGroup carry Ref
    (Group.Ref(), the id agents pick the group by).
  - internal/gui/trace.go: publicRoute rewrites a route's Model,
    For.Model, Subagent.Asked/To and the group's and subs' Ref through
    provider.PublicRef (memoised per answer). It copies the pointers
    before writing, so the gateway's trace is left as it was.
  - internal/gui/context.go: the Context page's model too.
  - internal/usageapi/usageapi.go: the ledger page's Requested.
  - routing/client.js: useName falls back to a sub's ref.

Test: TestRoutesNameFoundGroupsByTheirPublicID
(internal/gui/trace_publicref_test.go). Broken by hand, each one red:
  - publicRoute made a no-op: red on model, group, subagent, For, Subs
    and route.
  - usageapi mapping removed: `the ledger's Requested:
    ["group/auto-claude-opus-5-5" "group/mine"]`.
  - contextRoutes mapping removed: `the Context page's model:
    "group/auto-claude-opus-5-5:high"`.
  - Ref dropped from gateway/trace.go alone stays green, as expected:
    publicRoute fills an empty Ref.
Not covered: the ledger's text search (usage.Filter.Query) still matches
the stored group/auto-… form, not the shown auto/… (package usage can't
import provider). client.js's ref fallback has no GUI test of its own.

Run, go1.26.8 darwin/arm64, sandbox HOME, private GOCACHE:
  At this stack on origin/main df6bd3efe (head 48522d851):
    gofmt -l: nothing
    go vet ./... (darwin), GOOS=linux go vet -tags nogui ./...,
      GOOS=windows go vet ./...: ok
    set -o pipefail; go test -timeout 45m ./...: ok, EXIT=0
      (68 ok, 19 with no test files; agent 528s, gateway 628s,
      library 482s)
    GUI, playwright 1.62.0, chromium and webkit, concurrency 3: the
      171 files near this change (routing*, panel-routing*,
      window-mask, privacy*, usage*, quota*, providers*): 2217 tests,
      2183 pass, 34 fail. Every red is also red alone on origin/main:
      quota-count-wrap and quota-name-translated (#2228),
      usage-agents-hide (#2276), usage-checkin (#3091), usage-fold
      (#2163), usage-ledger (#3104, red since df6bd3efe, green at its
      parent). window-mask: 20 of 20.
  At this stack on origin/main c922225f1 (head 91baa7adb), before
  df6bd3efe's routing trace change:
    set -o pipefail; go test -timeout 45m ./...: ok, EXIT=0
      (66 ok, 20 with no test files)
    the whole GUI suite (823 files, both engines, concurrency 3):
      11589 tests, 11554 pass, 35 fail. The 9 files red were run again
      alone at --test-concurrency=1 on the head and on origin/main
      a8ecf4020. The same 7 files were red on both: the five issues
      above plus s3-sync (#2448) and library-row-remove (#3099).
      nav-sub-unroll (#1950) and plugin-updates (#3103) were red only
      under the full run. codex-predictions (#2624) was 20 of 20.
2026-10-21 08:40:49 +08:00
yetone 55b5eca055 gateway: a provider that searches for some of its models is offered as a searcher, with those models only (01huadalang on Discord)
Reported: 01huadalang has a Command Code plan, but web search offered no
searcher for it, although some of its models (gpt-6-luna) search on
their own. The picker counted a provider only when every model searched,
or when its host was a self-searching API.

Changed (internal/gateway/search.go, search_remote.go):
  - partSearcher(p) holds for a provider with no Account and no
    self-searching API host whose preset is in searchModels or whose base
    host is in searchModelsHosts. modelSearchesAny(p, model) says whether
    that model is one that searches.
  - searchRank ranks such a provider 4 when one of its available models
    searches. searcherReady keeps it. searchableModel offers only the
    models that search, never e.g. claude-opus-5-5.
  - docs/subsystems/gateway-routing.md says so.

Test: TestCommandCodeSearchesForOtherModels (search_models_test.go).
Broken by hand, each one red, then green when put back:
  - search.go and search_remote.go reverted: "the picker offers [],
    want Command Code's gpt-6-luna alone".
  - partSearcher dropped from searcherReady's keep, and the
    searchableModel case dropped: `Command Code searches with
    "claude-opus-5-5"`.

Run, go1.26.8 darwin/arm64, sandbox HOME, private GOCACHE:
  At this stack on origin/main df6bd3efe (head 48522d851):
    gofmt -l: nothing
    go vet ./... (darwin), GOOS=linux go vet -tags nogui ./...,
      GOOS=windows go vet ./...: ok
    set -o pipefail; go test -timeout 45m ./...: ok, EXIT=0
      (68 ok, 19 with no test files; agent 528s, gateway 628s,
      library 482s)
    GUI, playwright 1.62.0, chromium and webkit, concurrency 3: the
      171 files near this change (routing*, panel-routing*,
      window-mask, privacy*, usage*, quota*, providers*): 2217 tests,
      2183 pass, 34 fail. Every red is also red alone on origin/main:
      quota-count-wrap and quota-name-translated (#2228),
      usage-agents-hide (#2276), usage-checkin (#3091), usage-fold
      (#2163), usage-ledger (#3104, red since df6bd3efe, green at its
      parent). window-mask: 20 of 20.
  At this stack on origin/main c922225f1 (head 91baa7adb), before
  df6bd3efe's routing trace change:
    set -o pipefail; go test -timeout 45m ./...: ok, EXIT=0
      (66 ok, 20 with no test files)
    the whole GUI suite (823 files, both engines, concurrency 3):
      11589 tests, 11554 pass, 35 fail. The 9 files red were run again
      alone at --test-concurrency=1 on the head and on origin/main
      a8ecf4020. The same 7 files were red on both: the five issues
      above plus s3-sync (#2448) and library-row-remove (#3099).
      nav-sub-unroll (#1950) and plugin-updates (#3103) were red only
      under the full run. codex-predictions (#2624) was 20 of 20.
2026-10-21 08:40:49 +08:00
yetone df6bd3efec routing: out of sight the page stops asking for the trace, and a waiting trace read gathers a burst of changes into one answer
The Routing page (and the tray panel's Routing tab) read
/api/gateway/trace in a loop for as long as magpie ran, in sight or not.
The read was already a long-poll, but each change woke it: a request's
way is told in a burst (begun, a try sent, answered, its usage), so
under traffic every open page was answered 4-8 times a second, hidden
pages included, for nothing they drew.

Server (internal/gateway/trace.go): once a change wakes a waiting
Trace, it gathers for traceGather (250ms) before answering, so a burst
is one answer; a read with nothing new still blocks until a change or
the 25s wait. Every answer now also lists the ids of all the routes
the trace keeps (TraceState.IDs, "ids"), changed or not; OwnerTrace
passes them through from another magpie serving the gateway.

Client (plugins/routing/client.js): after its first answer, poll()
asks only while the page or the panel's Routing tab is in sight
(document not hidden, and the view shown or the panel's tab picked).
Out of sight it parks; start() (visibilitychange, focus, the view's
hidden attribute) and panelRoutingShown resume it. The first answer
after a resume is a catch-up: what came meanwhile is listed, and only
the requests still under way fly (stage and panel), as #302 asks. A
route last heard of as under way that is missing from "ids" (it ended
and was trimmed while the page was away) is dropped, so it can't show
as live forever. An answer with no "ids" (an older magpie) leaves the
routes as before.

Measured:
  - Hidden page, 2s with a request every 80ms (routing-hidden-stage,
    panel-routing-hidden): before, the trace was read 24-25 times in
    2s by each of the main window (another page picked, or the window
    hidden) and the hidden tray panel; after, 0 times.
  - A burst of 4 changes 20ms apart (TestTraceWaitHearsABurstOnce):
    before, read in 4 answers; after, 1.

Tests:
  - TestTraceWaitHearsABurstOnce (gateway, new): a waiting read
    answers a burst once, with all of it and the route's id in IDs.
    Broken by hand: no gather -> "a burst of 4 changes was read in 4
    answers, want 1"; no ids -> "ids [], want [<id>]".
  - routing-hidden-stage and panel-routing-hidden now assert the page
    reads the trace at most once out of sight (was: at least 20), and
    shows the newest request once back. The mock is a clock-driven
    gateway (every change since `after`, at once). With the old
    client.js all 12 went red: "the trace was read 24/25 times out of
    sight", "... while hidden".
  - routing-busy and routing-flood's mocks answered one route per
    read; the gateway answers every change since `after`, so they do
    too now. routing-purpose-state sent one update while another page
    was shown and required a new read to start out there; that send
    no longer waits for one.

Run at this commit's tree (go1.26.8 darwin/arm64, sandbox HOME):
  gofmt -l .: nothing
  GOOS=linux go vet -tags nogui ./...: ok
  GOOS=windows go vet -tags nogui ./...: ok
  go test -tags nogui ./internal/gateway ./internal/gui: ok
  go test -tags nogui -race -timeout 45m ./internal/gateway
    ./internal/gui: ok (gateway 1598s, gui 348s)
  set -o pipefail; go test -tags nogui -timeout 45m ./...: ok, every
    package (66 ok, 20 with no test files)
  GUI, playwright 1.62.0, chromium and webkit, every routing*.test.cjs
    and panel-routing*.test.cjs (97 files, 1204 tests, concurrency 4):
    1203 pass, 1 red: routing-rule-remove "chromium en 390: a rule's
    ... is there to remove it" (routing-rule-remove.test.cjs:158,
    "1 !== 0", the rule count read right after a keyboard Enter). Its
    trace mock never answers a wait, so its polling is the same before
    and after this change; alone it passed 3 runs of 3 (60/60).
  The whole GUI suite (822 files) was still running when this was
  written.
2026-10-21 07:32:11 +08:00
yetone 6a050eebe6 provider: the catalog a request built is kept for the next requests while nothing it is built from moved
heldEntries held the providers' catalog for heldFor (1s) after a request,
so an agent's requests a few seconds apart each built it again from
every provider's models and accounts (buildEntries via Resolve and
Served, ~725 MB of allocations in 300s of a gateway in use), and with it
the switched-off providers' models (heldOffEntries, entriesOf again), the
groups and the groups' entries (heldFrom). They are now kept across
requests (kept, hold.go) while provider.StampNow stays the same and for
at most keptFor (a minute), as the gateway's stamped does for model
lists: a provider, account or setting saved, a plugin's change, the
providers', settings' or catalog's file written by another process, or
another environment moves the stamp and the next request builds them
again. What moves no stamp (an account another program signed in to, a
model retired by its date) is seen within the minute. Only a request
that holds the catalog uses what is kept; a look outside one builds its
own, as before.

Measured with a gateway probe (5 providers, ~9.9KB settings.json; at the
parent commit -> this one), 40 requests 1.1s apart:
  messages   675 KB/request, allProviders 1.02/request -> 285 KB, 0.00
  chat       614 KB, 1.00                              -> 245 KB, 0.00
  responses  676 KB, 1.00                              -> 297 KB, 0.00
and 200 back to back: messages 259 -> 234 KB, chat 211 -> 184 KB,
responses 253 -> 251 KB.

TestCatalogKeptAcrossRequests (heldFor 0, so each request is past the
last one's hold) counts builds. Broken by hand, it went red each way:
  - kept never used: "20 requests with nothing changed built the catalog
    20 times, want 0"
  - groups not kept (heldFrom): "20 requests with nothing changed built
    the groups 20 times, want 0"
  - the stamp not checked: "relay2/m3 not in the served catalog after
    the save"
  - no time bound: "past keptFor: built 0 times in 2 requests, want one
    each at least"

Run at this commit's tree (go1.26.8 darwin/arm64, sandbox HOME):
  gofmt -l .: nothing
  GOOS=linux go vet -tags nogui ./...: ok
  GOOS=windows go vet -tags nogui ./...: ok
  go test -tags nogui -race -timeout 45m ./internal/provider
    ./internal/gateway: gateway ok (2072s); provider red once on
    TestSignInDoneOnceTheAccountIsBack, a data race between the test's
    write of catalog.Changed (signin_removed_test.go:112) and a plugin
    refresh goroutine left running by an earlier test reading it in
    catalog.Touched (live.go:202, from plugin.tell). Neither side is
    code this commit touches. It reproduces on origin/main 2201b6628
    (go test -race -run TestSignInDoneOnceTheAccountIsBack -count=30
    ./internal/provider: 1 race in 30). Provider -race run again at
    this tree: ok (171s).
  set -o pipefail; go test -tags nogui -timeout 45m ./...: ok, every
    package (66 ok, 20 with no test files)
2026-10-21 07:32:11 +08:00
yetone 9329c89c95 settings: an unchanged settings.json is parsed once, and a gateway request reads the shared settings
settings.parse ran json.Unmarshal on every Load, and one gateway request
called Load six or seven times (Provider.Efforts, ImageOverride,
masking.options, withWires, redactionWanted, recordConversation,
namesMember). parse now keeps the last parsed value keyed by the file's
bytes, and hands Load a deep clone (internal/settings/clone.go), so every
caller still owns what it gets. settings.Shared() returns one read-only
value for the request path, its slices held at len==cap so an append
reallocates instead of reaching the shared array; the seven callers above
moved to it after checking none writes what it reads. A file that doesn't
parse is not memoized: it falls back as before (lastgood), and Shared
then returns that result, never the last good parse, so a failed read
can't keep a looser list. LoadChecked callers (allow list, image fetch
guard, disabled) stay on Load.

Measured with a 200-request probe through the gateway (5 providers, a
~9.9KB settings.json), before (origin/main 2201b6628) -> after:
  chat       7.1 parses/request, 570-571 KB/request -> 0.0, 216-242 KB
  messages   6.1-6.2 parses,      537-556 KB         -> 0.0, 255-261 KB
  responses  6.2-6.3 parses,      569-574 KB         -> 0.0, 268-277 KB

Tests: TestRequestsParseUnchangedSettingsOnce (gateway, 30 requests must
parse fewer than 30 times), TestUnchangedSettingsParsedOnce,
TestLoadIsTheCallersOwn, TestSharedAppendReallocates,
TestUnreadableSettingsNotTheLastParsed, TestCloneSharesNothing. Broken by
hand, each went red:
  - old code: "settings.json parsed 226 times for 30 requests with the
    file unchanged"
  - memo hit off: "an unchanged settings.json was parsed 200 more times
    in 300 reads"
  - shallow clone: TestLoadIsTheCallersOwn, TestSharedAppendReallocates,
    TestCloneSharesNothing ("Settings.RedactKinds is shared", ...)
  - Shared keeping the last parse on a bad file: "Shared kept the last
    file's list: [10.0.0.1]"
  - no len==cap clone: "appends reached the shared list"

Run at this commit's tree (go1.26.8 darwin/arm64, sandbox HOME):
  gofmt -l .: nothing
  GOOS=linux go vet -tags nogui ./...: ok
  GOOS=windows go vet -tags nogui ./...: ok
  go test -tags nogui -race -timeout 45m ./internal/settings
    ./internal/masking ./internal/provider ./internal/gateway: ok
    (settings 388s, provider 836s, gateway 2081s)
  set -o pipefail; go test -tags nogui -timeout 45m ./...: ok, every
    package (66 ok, 20 with no test files)
2026-10-21 07:32:11 +08:00
yetone a8ecf4020e provider: a check-in file that can't be read or parsed stops the check-in
readCheckins, the reader every daily check-in shares (WorkBuddy, Trae CN,
MiniMax Code, Qoder and the plugins' own), took a file it couldn't read
or parse as empty. The next check-in then asked the vendor again for
every account and wrote its answers over the file: an account could be
checked in twice in one day, and the entries it couldn't read were lost.

readCheckins now returns an error for a file that is there but can't be
read, or doesn't parse into entries (cut short, zeroed, empty, `[]`,
`null`). A file not there is still empty. On the error:
- checkiner.checkinNow asks nothing and writes nothing. Each account it
  would look at is `failed` with the reason (the path and why), so the
  loop tries again after 30 minutes and a press (GUI, TUI, `magpie
  accounts checkin`) says why. The error is logged once while it stays
  the same.
- The readers that only show results (WithCheckins, *Checkins(),
  PluginCheckins) go through shownCheckins, which gives what last read
  from the file in this process, so a card keeps its last good data.
- adoptLegacyPluginCheckins' own strict copy of the read now uses
  readCheckins too.
Docs: providers-accounts.md no longer lists check-in marks among the
caches written over; provider-plugins.md says the plugin file's case.

Test: TestCheckinUnreadableFileLeftAlone writes a cut-short, zeroed,
empty, `[]` and `null` workbuddy-checkin.json, runs the loop and a press
against a fake WorkBuddy, and checks no status or claim request went out,
the file is byte for byte unchanged, and the result says the path; a
folder in place of plugin-checkin.json does the same through a plugin
checkiner. TestCheckinMissingFileIsEmpty and
TestCheckinUnreadableKeepsLastGood cover the other two sides.
Broken by hand (checkinNow taking the error as an empty map again): the
test went red, every case claimed (Asked true), and green once restored.

Run in a worktree at origin/main 62a1df801, sandbox HOME (testenv):
- gofmt -l . : clean
- go vet ./... (darwin), GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... : all exit 0
- set -o pipefail; go test -timeout 45m ./... : exit 0, 68 packages ok,
  none failed (internal/gateway 613s, internal/agent 529s,
  internal/provider 262s)
No red seen, so no issue filed.
2026-10-21 07:23:23 +08:00
yetone 62a1df8010 provider: a plugin's daily check-in reaches every sign-in, also two that share a display name (plugins#254)
AutoClaw's plugin can hold several sign-ins under one default display name,
which AutoClaw doesn't let the user change. plugin_checkin.go keyed each
account's check-in on "<provider>|<AccountID>", the display name, so
checkinNow's per-key dedupe asked only the first sign-in of each name, by
the loop and by Check in now alike; the others stayed 今日未签 for good,
and Settings showed one row, and one Off switch, per name.

Each sign-in is now keyed on the key plugin-auth.json keeps it under
(pluginCheckinKey: "autoclaw|autoclaw", "autoclaw|autoclaw#x1y2z3").
Two sign-ins never share it; a refresh writes the same key, and signing
in to an account already signed in goes back to its key (host.js
settle). The display name is shown only. Cards, Settings rows,
CheckinOff and Check in now all read the same key, so app.js is
unchanged. An account without an AccountID already had this key.

Upgrade (adoptLegacyPluginCheckins, run when the plugin's accounts are
listed): an entry kept as "<provider>|<display name>" goes
- in plugin-checkin.json, to the first sign-in in use of that name (the
  one the old key's check-in asked) and only to it, and the old entry
  is dropped: it isn't asked again today, and its namesakes, never asked,
  are;
- in settings.CheckinOff, to every sign-in of that name: the user turned
  that name off and none of its sign-ins was checked in since, so the
  upgrade switches none on (settings.EditCheckinOff edits that field
  alone from what the file holds).
A plugin-checkin.json that can't be read or parsed is left as it is and
carried over once it reads; writes go through writePrivate
(temp-and-rename). Known gap: a sign-in made the same day after another
was signed out can take the freed key and that day's result.

The fake plugin's check-in now records a signed-in account as
name@fake/uid so two of one name tell apart in the presses.

Tests:
- TestPluginCheckinTellsSignInsOfOneNameApart: four sign-ins, A/u1, A/u2,
  B/u3, B/u4 (the reporter's case). All four pressed once, none again
  that day, four entries kept, four Settings rows, every card marked;
  with A/u2 off, Check in now the next day presses the other three.
- TestPluginCheckinCarriesOverDisplayNameEntries: a plugin-checkin.json
  with fakeco|A@fake and fakeco|B@fake claimed today plus another
  plugin's entry, and CheckinOff ["workbuddy|123", "fakeco|B@fake"].
  A's check-in goes to its first sign-in only, the old entries go, the
  other plugin's stays, both B sign-ins are off and workbuddy|123 is
  kept; the loop then presses only A's namesake, and a second look
  presses nothing.
- TestPluginCheckinCarriesNothingOverAnUnreadableFile.

Broken by hand, each red:
1. key back on the display name: TellsApart pressed only A@fake/u1 and
   B@fake/u3; CarriesOver kept the old entries.
2. adoption not called: CarriesOver ("A's check-in went to ... ok false").
3. record to every heir: CarriesOver ("carried to both") and Unreadable.
4. Off to the first heir only: CarriesOver (CheckinOff lacks one B).
5. old entry kept: CarriesOver and Unreadable.
6. parse error ignored: Unreadable.

Run at 0f044e944 (origin/main) plus this change, macOS arm64, sandbox
HOMEs from testenv, shared GOCACHE:
- go test -race -count=20 -run TestPluginCheckin ./internal/provider: ok
- gofmt -l on the changed files: prints nothing
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
  go vet ./...: clean
- go build, GOOS=linux go build -tags nogui, GOOS=windows go build: ok
- go test -timeout 45m ./...: exit 0, 68 packages ok, no FAIL
- after a comment-only rewrap: go test ./internal/provider
  ./internal/settings: ok
No GUI suite: internal/gui/assets is unchanged.
Not tried with real AutoClaw accounts or a real plugin-checkin.json from
the reporter.
2026-10-21 07:04:19 +08:00
yetone fb371eaa1b provider: the Qoder mover's min is 0.2.25, where the international sign-in sends no redirect_uri (plugins #276)
qoder 0.2.25 (plugins f5548bd5) stops sending redirect_uri=qoder-app:// on
the international sign-in. Only Qoder's desktop app handles that link, so on
a Mac with Qoder.app installed the end of sign-in was handed to the app
instead of finishing in the browser tab. The plugin polls for the token and
needs no redirect, as Qoder's own CLI and the CN site already do. Raising
the min lets keepMovedCurrent bring every moved user onto it.

npm view --prefer-online --registry https://registry.npmjs.org
@magpie-community/opencode-qoder-auth@0.2.25 version -> 0.2.25.

Run at 0f044e944 + this change: gofmt -l clean; go vet for darwin, linux
(-tags nogui) and windows clean; set -o pipefail; go test -timeout 45m ./...
exit 0, every package ok. Not tried with a real Qoder account here; the
reporter signed in three accounts with the same one-line change on 0.2.21.
2026-10-21 06:59:55 +08:00
yetone 0f044e9447 plugins: a GITHUB_TOKEN GitHub refuses is dropped for anonymous requests, not shown as an error (till on Discord)
till's Plugins page said "无法连接 GitHub: GitHub refused GITHUB_TOKEN
(no GitHub token is set in Settings → Network and sharing)". ghtoken.Token
falls back to the environment's GITHUB_TOKEN / GH_TOKEN, and a stale one
there made every GitHub read fail, though GitHub serves the same reads
without a token.

ghtoken.Do now sends a GitHub API request with the token. When the token
came from the environment and GitHub answers 401, it remembers that token
as refused for the rest of the process (Token() skips it, so GH_TOKEN is
still tried after a refused GITHUB_TOKEN, and Settings no longer shows it)
and asks once more without Authorization, returning that answer. A token
set in Settings is never dropped: its 401 is still Refused()'s error. An
anonymous rate limit after the drop is said by LimitedBy as before.

Every caller goes through it: plugin fetchJSONFrom (tagged-repo search,
git plugin checks, githubHead) and getURLFrom (Bun), and library apiGet,
skills fetch, skilltree fetchBlob and latestRTK via doGitHub.
internal/davsync/github.go stays strict: its token is the one the user gave
sync to write a private repo, outside ghtoken, and an anonymous retry can't
write there, so it would only hide why sync failed.

Tests (httptest only): ghtoken_test covers an env token refused then asked
again without, not sent again (and GH_TOKEN tried next), a Settings token
refused stays an error, an env token refused then an anonymous rate limit
is reported, and another host untouched. plugin TestTaggedReposStaleEnvTokenDropped
is till's case: TaggedRepos with GITHUB_TOKEN=stale-till lists 7 repos, no
error. github_token_test and library TestGitHubRateLimitSaid now expect the
env token dropped and the Settings token still refused.

Broken by hand, each red: (a) no anonymous retry: every new env test, the
plugin and library tests red, and TestTaggedReposStaleEnvTokenDropped shows
till's exact error; (b) no memory of the refusal: NotSentAgain, the plugin
and library tests red; (c) a Settings token also retried:
SettingsTokenRefusedStaysAnError, the plugin and library tests red.

Run on the commit before the rebase (base 9b04c4e20):
- gofmt -l: clean. go vet ./... on darwin, GOOS=linux -tags nogui, GOOS=windows: clean.
- set -o pipefail; go test -timeout 45m ./... at load ~30: 62 packages ok.
  agent, gateway and library ran past 45m while still progressing; gui
  failed TestSetAnswersWhileDevinAndProvidersHang (set took 10.26s, #1375)
  and TestMainWindowCorners (measuring killed, #1936/#2645); provider failed
  TestPluginPicksComeBackWithTheirList (#3051, fixed on main in c922225f1).
- Each rerun alone at load 21-56: library ok 809.7s, provider ok 308.8s,
  gui ok 159.5s, agent ok 1673.3s, gateway ok 780.4s.

After rebasing onto a3ebed202 (main moved 8 commits): gofmt -l clean; go vet
darwin, linux -tags nogui, windows clean; go test -count=1 at load ~57:
ghtoken ok 2.9s, plugin ok 277.6s, library ok 144.2s.
2026-10-21 06:16:31 +08:00
yetone f21dd99f5a privacy: every masking is recorded, and Settings › Privacy shows it
What was masked is now kept, so the user can see it. Settings › Privacy
opens on a summary card: how many values were kept from vendors over 1,
7 or 30 days, by kind, by finder (rules, your words, the local model,
known values) and by where they went, with a day strip. The page is
grouped into What to mask, How it's found (rules and the local model are
layers, not a toggle: the model adds names and addresses rules can't
see) and Sharing. A records view lists each masked request: its kinds,
finders, placeholders and, while magpie runs, the line around each
value. Gateway › Recent calls and the Routing log carry a masked-N badge
that opens the record.

Originals never go to disk. internal/maskrec writes day files under
~/.config/magpie/masking (0600, 30 days, 100MB at most) holding kinds,
finders, placeholders, a first character or key prefix and a length.
The lines around values are kept in memory for the last 400 records
only, and /api/masking/value answers only while the masker remembers a
placeholder. Nothing is written under MAGPIE_TEST_SANDBOX.

A masker says what it masked through gwmw.Teller (JSONHits, TextHits,
Value); a plugin masker that doesn't is counted only, so older redact
plugins keep working. Every route that masks notes it: chat, Responses,
Codex backend and search, embeddings, images, video, transcription,
decide and the search MCP query. Masking still fails closed: a masker
that panics on any path refuses the request (TestMaskingOnAndOff's fake
now panics on JSONHits and TextHits too, since the gateway asks a Teller
through those).

app.js grows to 1,314,432 bytes, so its budget rises to 1,335,000 and
the core's to 1,528,800 (+1.5%): Settings is the core's own page.

Run at this head (rebased on origin/main a3ebed202):
- go vet clean on macOS, GOOS=linux -tags nogui and GOOS=windows;
  go test ./internal/gateway ok (561s).
- On origin/main c922225f1 (one commit back, the packages either side
  touches): agent, gateway, gui, gwmw, maskrec, provider, redact ok.
- On origin/main 592899467: go test ./... -timeout 45m, 65 packages ok;
  agent and gateway hit the 45m timeout under load ~26 (each mid-way
  through a short test, not a hang) and pass alone with -timeout 100m
  (1133s, 890s).
- GUI, on 592899467, the 42 files this change or main's new commits reach (privacy-*,
  redact-*, masking-records, settings-*, gateway-*, routing-bodies,
  routing-request-metrics, routing-log-icons, account-discovery,
  click-scroll, i18n-keys, old-webkit), both engines, every language:
  475 tests, 475 pass. routing-bodies is green here since 2543fb2c1.

Run on the previous base, origin/main c84864ffc (the whole suites):
- go test ./... -timeout 45m: every package ok (66), exit 0. An earlier
  run found TestMaskingOnAndOff/panics (its fake, above) and
  TestCoreScriptBudget (the budget, above); both fixed.
- gofmt -l clean; go vet on macOS, GOOS=linux -tags nogui and
  GOOS=windows clean; node --check on the changed scripts.
- GUI suite, both engines, every language, --test-concurrency=6:
  11533 tests, 11483 pass, 50 fail. Each failing file rerun alone here
  and on origin/main:
  - red the same on main, filed: codex-predictions (#2624),
    usage-checkin (#2549), usage-agents-hide (#2276), usage-fold
    (#2163), s3-sync (#2448), quota-count-wrap and
    quota-name-translated (#2228), routing-request-metrics (#2571),
    routing-bodies (#2559: red at its "second request pressed" step;
    this change's badge checks before and after it pass),
    routing-rule-remove (#3096, filed now: 0 2 1 alone here, 0 0 2 on
    c84864ffc).
  - load, pass alone: group-member-weight (#2387), routing-model-rest,
    context-tune (Chromium didn't launch in 180s at load average ~45;
    0 0 0 alone on both). An earlier whole run's library-chip-fan red is
    #3072 (filed), plugin-card-update #3079, lightweight #2638,
    segs-glide #2683.
  - mine, fixed: old-webkit, three ":hover, :focus-visible" lists
    Safari before 15.4 drops; split, 6/6.
- Broken by hand, each went red: masked values kept on disk
  (TestNoValueOnDisk), a snip that runs past an escaped quote
  (TestSnipStaysInItsString), the shared-line dedup in the records view
  (masking-records, 10 of 12).
- Real app in a sandbox HOME with the local model on: the summary card,
  flow, chips and records view in light and dark; persons and
  addresses, Chinese names among them, recorded by=model; a grep of the
  masking folder and the sandbox config for the masked values found
  none.
2026-10-21 06:12:37 +08:00
yetone a3ebed202e gateway: Codex's compaction back on its own model goes without another vendor's reasoning text, so the turn after DeepSeek isn't refused over input[n].content (jue on Discord)
jue (Codex app, GPT-6.1 Sol) set a DeepSeek model for Codex on the
Agents page, went back to GPT, and the next turn sometimes failed with
"[ArrayParam] [input[8].content] [array_above_max_length] Invalid
'input[8].content': array too long. Expected an array with maximum
length 0, but got an array with length 1 instead."

Cause: when the model changes (or the thread passes its auto-compact
limit) Codex compacts the thread before the turn, and shows a failed
compaction as the turn's error. Codex's /responses/compact for one of
its own models went to the ChatGPT backend (Codex's sign-in, its sk-
key, or a magpie Codex account through compactOn) with its input as
sent. A reasoning item from DeepSeek's Responses API carries its
reasoning_text in content, which OpenAI accepts only empty, so the
whole compaction was refused. A turn on the same routes already went
through codexInput(body, false), which drops such items; the
compaction didn't. "Sometimes" is when Codex compacts first.

Fix: codexBackend's own-model branch runs codexInput(body, false) on
/responses/compact too, before any of the three routes. OpenAI's own
sealed reasoning (encrypted_content, no text) stays; a summary magpie
made goes as its text, as from a turn. DeepSeek still gets its
reasoning text (withReasoningText). Siblings read: the translated
Responses path sends back only sealed reasoning (sealedReasoning);
passthrough strips reasoning text for openai.com, Azure and Codex
accounts and retries on the refusal elsewhere (#1411). Not covered: a
full restore that drops openai_base_url leaves magpie off Codex's path.
Codex's base_instructions and prompts are untouched.

Test: TestForeignReasoningNeverReachesOpenAI sends the reported thread
(input[8] a DeepSeek reasoning item with one reasoning_text, input[3]
OpenAI's sealed reasoning) on seven routes: turn and compaction on
Codex's sign-in, its API key and a magpie account, and /v1/responses
with codex/gpt-6.1-sol. The fake OpenAI refuses a reasoning item with
text with the reported 400 byte for byte. On the old code the three
compaction routes are red with that 400 and the four turns green;
with the fix all seven are green. Broken by hand a second way
(codexInput(body, true) on the compact branch): the same three red.

Run at 592899467 + this change, GOMODCACHE=/Users/yetone/go/pkg/mod,
sandbox HOME and GOCACHE in the worktree:
- gofmt -l on the changed Go files: empty.
- go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...: all clean.
- set -o pipefail; go test -timeout 45m ./...: exit 1 at load from
  other sessions' suites. 61 packages ok. internal/agent, gateway and
  library hit the 45m timeout (#2869's kind).
  TestSetAnswersWhileDevinAndProvidersHang (internal/gui, 10.6s set,
  #1375) and TestTaggedReposSlowRead (internal/plugin, #1889) failed
  their timing bars.
- Rerun alone, go test -timeout 45m -p 2 ./internal/gateway
  ./internal/agent ./internal/library ./internal/gui ./internal/plugin:
  all five ok (gateway 1011s, agent 1235s, library 632s, gui 184s,
  plugin 452s).
- Rebased on c922225f1 (5 commits, gateway.go among them): go vet
  ./internal/gateway for darwin, linux -tags nogui and windows clean;
  go test -timeout 45m ./internal/gateway ok (1253s).
2026-10-21 05:57:34 +08:00
yetone c922225f13 provider: TestPluginPicksComeBackWithTheirList waits for the full list to be taken, not a fixed 200ms (#3051)
After sending the full list, the test waited 200ms for "not asked
again" and then read the picks. Under load KeepPluginsListed hadn't
taken the list yet, so the picks still read [pool-a pool-b], set aside
[qoder/claude-x kiro/claude-y]: red in the v0.1.1303 full suite and at
load ~400 before. It now polls Find until the picks are back (10s
bar), failing if the loop asks again meanwhile, then checks for 100ms
that it isn't asked again soon. Waiting for the state is ggbdpq's
idea on #3051.

Run: a 300ms sleep injected into the fake relist before it caches the
answer: the old test red 3 of 3 with the same message
(plugin_delisted_test.go:130), the new one green (2.74s). Without it:
go test -race -count=20 -run TestPluginPicksComeBackWithTheirList ok;
gofmt -l clean.
2026-10-21 04:16:29 +08:00
yetone 5daea73c6e gateway: whether a model is served is answered from catalog names kept while the catalog stays the same
unserved() built provider.Catalog() on every request to see whether the
asked id is a catalog name. In a 10-minute profile of a sandbox instance
(fake upstream, ~1,000 gateway requests plus the GUI's polls) that was
2.26GB of 9.8GB allocated. The id and model names are now kept in a
stamped set (provider.StampNow, at most a minute), so a saved provider is
seen at once.

Measured, gateway-only load for 300s on the same sandbox data (fixed
build also carries 0afeebd01's pooled zstd body decoders):
  before: 3.9GB allocated for 434 requests (unserved 1.22GB, Catalog
          1.26GB, zstd 863MB), numGC +52
  after:  2.96GB for 443 requests (unserved 25MB, Catalog 57MB, zstd
          body decode gone from the top), numGC +29

TestUnservedKeptWhileCatalogStays (a provider of 1,000 models) counts
two answers already given against one catalog build in the same run,
since the package's other tests leave background work allocating beside
it (an absolute bar of 2000 read 2733 in the full suite, 682 alone):
67985 allocations against a build of 33262 before (fails, needs under a
third), 1486 after; a provider saved afterwards is served.

Run: gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui
./internal/gateway/; go test -race -run
'Unserved|Desktop|StandIn|Science|ClaudeTier|Zstd' ./internal/gateway/ ok.
Full suite (go test -tags nogui -timeout 45m ./..., sandbox HOME, on
this commit's first test): 62 packages ok; gateway and agent hit the
45m timeout under machine load (no hung test: TestCachePartialUpdateMatrix
and TestSyncKeepsAnAddressOnAnotherMachine were at 0s), provider red in
TestPluginPicksComeBackWithTheirList (#3051, passes alone 3/3), and this
test's absolute bar read 2733, fixed above. Rerun at this head:
gateway ok 885s, agent ok 899s, provider ok 226s.
2026-10-21 04:16:28 +08:00
yetone f962cfa75b agent: whether a model value is magpie's is kept while the catalog stays the same
isMagpie asked provider.Resolve, which outside a request holding the
catalog built every provider's entries again. The window's drift poll
(/api/drift, every 15s while the window is up) asks it for every
detected agent's field values, and each poll built the catalog again:
in the procmem profile (a sandbox `magpie web` on main with 17
providers, the GUI cycling its pages for 10 minutes) Drift's isMagpie
was 235 MB of the 1.37 GB allocated, ~6 MB a poll, with nothing changed.

Now isMagpie's answers are kept by value while provider.StampNow stays
the same, for a minute at most and 4096 values at most, as the gateway's
stamped lists are: a provider, account or setting saved, a plugin's
change, a catalog sync, another process rewriting providers.json or
settings.json, or a changed environment moves the stamp and they are
asked again. A value with no "/" is no catalog reference and isn't asked
at all, as before.

Tested with TestIsMagpieKeptWhileCatalogStays: two answers already given
take 1924 allocations before (fails), under 200 after; a provider saved
since is magpie's at once. go test -tags nogui ./internal/agent passes
(849s); -race on IsMagpie|Drift|GoProgram|GoMagic|Goose passes; gofmt -l
clean; GOOS=linux and GOOS=windows go vet -tags nogui ./internal/agent
pass. The full suite is run before the push of this batch.
2026-10-21 04:16:26 +08:00
yetone 077c472053 gateway: a zstd request body is decoded by a decoder kept between requests
Codex sends every turn's body zstd. decodedBody made a new zstd decoder
for each one, with the package's default concurrency: it started a
stream goroutine and allocated its window and block buffers on every
request. In the procmem profile (a sandbox `magpie web` on main, three
Codex-style sessions sending zstd /v1/responses every 2-4s plus Chat and
Messages traffic, ~1,000 requests in 10 minutes) that was 1.74 GB of the
9.8 GB allocated, all under zstd.(*Decoder).startStreamDecoder.

Now a sync.Pool keeps decoders (concurrency 1, the same 512 MB memory
bound), as sessions' packed reads do since 21c2ab6fa. A decoder decodes
in step with the body's reader, which reads it through to its end
anyway, and goes back to the pool at Close; a read after Close gets
net.ErrClosed. A body that isn't zstd fails at Reset with the same 400
as before.

Measured with TestZstdBodyDecoderKept (a 304 KB body, 20 reads): 1719 KB
allocated a read before (fails), 678 KB after, which is io.ReadAll
growing to the body's size. The test is skipped under -race, where
sync.Pool drops a quarter of what is put in it (raceOn, as in sessions).

Run: go test -tags nogui -run 'Zstd|Encod|Codex.*Backend|BodyLimit|
Title|Bound|Gzip' ./internal/gateway (ok), the same with -race (ok),
gofmt -l clean, GOOS=linux and GOOS=windows go vet -tags nogui
./internal/gateway pass. The full suite is run before the push of this
batch.
2026-10-21 04:16:25 +08:00
yetone 7e340036a7 agent: a goose on PATH is told apart from a Go program without parsing its symbol table
Telling Block's goose from pressly's Go migration tool (goProgram) called
buildinfo.ReadFile, which parses a binary's whole symbol and string tables
before it looks for Go's build info. For Block's goose, a 260 MB Rust
program, that was ~210 MB allocated on the first state the window asked
for (the procmem heap profile: 200 MB under debug/buildinfo, gooseIn,
goProgram, in the first 10 minutes of GUI use). It is kept per file
afterwards, but the heap had grown by it and kept the room.

Now the file is read through a 256 KB buffer for Go's build-info magic
("\xff Go buildinf:") first. A file without it is no Go program; one with
it is still asked of buildinfo, so the answer is the same as before.

Measured on the real ~/.local/bin/goose (260 MB, Rust): 214468 KB
allocated and 460 ms before, 256 KB and 244 ms after.

Tested with TestGoProgramReadsNoSymbolTable (a 40 MB Mach-O whose
LC_SYMTAB names 32 MB of strings: 186 MB allocated before, fails; under
4 MB after) and TestHasGoMagicAcrossReads (the magic across a buffer
boundary, zeros, this Go test binary). TestGooseDetectSkipsGoGoose (a
real Go goose is skipped, a script goose detected) passes. gofmt -l
clean; GOOS=linux and GOOS=windows go vet -tags nogui ./internal/agent
pass. The full suite is run before the push of this batch.
2026-10-21 04:16:24 +08:00
yetone 592899467b gateway: Gemini's reasoning streams as it comes on the last candidate, so Codex isn't left with nothing for the whole of its thinking (LuckymanJC on Discord)
LuckymanJC and kkgg: through magpie the first turn of a Codex session on
a Gemini model was very slow or seemed stalled. Measured with fake
upstreams through the gateway (Codex Responses -> Chat DeepSeek, Gemini;
OpenCode Chat; Anthropic passthrough), first content came within 1-50ms
on every path but one: a Gemini model's reasoning was held even on the
last candidate (`|| last && modelFamily(c.model) != ""` left Gemini out),
so Codex got nothing at all, not even response.created, until the text
began, while Claude's and GPT's has gone as it comes there since
iTianbao's report.

It was held there for #667, a reply that only reasoned being asked
again. That re-ask happens in place in streamTranslated, keeping the
reasoning the agent has, so it doesn't need the hold. But with the try
passing, emptyRetries counted it as past the request's own re-asks and
asked only streamRetries (2) times, and TestGeminiEmptyRepliesAskedAgain
(three empty replies running) went red. A held try that went through on
its reasoning alone (holdWriter.thoughtThrough) is now asked once more in
place (streamRetries+1); a never-answering model still makes at most 4
calls (the test's bound is 6).

Tests: TestThinkingStreamsWithNoOneElse gets "gemini" (Gemini upstream)
and "chat gemini" cases, to Claude Code and Codex. With the old line
restored they go red ("thinking held: first thought only 1.75us before
the text"). With emptyRetries' new branch broken by hand
(streamRetries+0), TestGeminiEmptyRepliesAskedAgain goes red with
"an empty reply"; green with both.
Run: go test -run 'TestGeminiEmpty|TestThinkingStreams|TestThinkingHeld|TestUncountedEmpty|TestReasoningLoop' ./internal/gateway: ok.
Break check repeated at push: the old `|| last && modelFamily(c.model)
!= ""` turns
TestThinkingStreamsWithNoOneElse/{gemini,chat_gemini}/v1/{messages,responses} red ("thinking held: first thought only 1.458µs before the text").
Full suite (go1.26.8 darwin-arm64, rebased on 0fe039f14): go test
-timeout 45m ./... gave 63 packages ok; internal/agent and
internal/gateway timed out at 45m with no test failed (load ~110 from
other sessions; deadline in TestJcode and TestVertexGeminiClients,
#2544 and #2870 seen again) and passed alone at that head: ok
internal/agent 1644.560s, ok internal/gateway 1397.712s. Rebased on
origin/main 4ae6c06dc, every package its new commits touch run in full
there: ok internal/agent 465.353s, internal/gateway 648.172s,
internal/sessions, internal/gui, internal/cli, internal/codexsummary;
gofmt -l on the changed files empty; go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./... clean; go build for
darwin, linux (nogui) and windows ok (at 0fe039f14).
Then rebased on origin/main 2201b6628 (one line in
internal/provider/migrate_qoder.go): ok internal/provider 608.249s; go
vet of internal/provider, internal/agent and internal/gateway clean.
2026-10-21 03:40:27 +08:00
yetone 5206177704 agent: a 1M model Desktop lists by its [1m] id is told by its 1M, not a 272K GPT's beside it (dumplings on Discord)
dumplings (magpie 0.1.1295, Settings > 长对话 "完整窗口"): the provider
model showed 1M and its 1M variant was picked in Claude Desktop, but
Desktop's Code tab still showed 272K. With Desktop on magpie, claudePlan
tells Claude Code the largest window of every model it can run there
(CLAUDE_CODE_MAX_CONTEXT_TOKENS) and holds the smaller ones to their own
with modelSettings.<id>.autoCompactWindow. A model handed by a "[1m]" id
counted toward that largest only when it was Claude Code's main model,
so a 1M model Desktop lists by its 1M id (DesktopLongest) beside a 272K
GPT left 272K the value told, and with it alone nothing at all.

Now every [1m] model counts by its window (1M when unknown), and the GPT
beside it gets its own 272K entry. The `main` field it needed is gone.

Tests: TestClaudeDesktopContextWindow1M (rewritten: glm listed by its 1M
id alone tells 1M; beside a 272K GPT, 1M told and GPT held to 272000),
TestClaudePlan's [1m]-beside-272K case and its 500K->1M expectations.
Broken by hand (`case m.long && false:`): both go red
(TestClaudePlan "magpie's default: 500000", TestClaudeDesktopContextWindow1M
"glm listed by its 1M id alone: \"\""); green with the fix.
Run: go test -run 'TestClaudePlan|TestClaudeDesktop|TestClaudeContextWindow|TestBudget' ./internal/agent: ok.
Break check repeated at push: `case m.long && false:` turns
TestClaudePlan ("magpie's default: 500000") and
TestClaudeDesktopContextWindow1M ("glm listed by its 1M id alone:
\"\"") red.
Full suite (go1.26.8 darwin-arm64, rebased on 0fe039f14): go test
-timeout 45m ./... gave 63 packages ok; internal/agent and
internal/gateway timed out at 45m with no test failed (load ~110 from
other sessions; deadline in TestJcode and TestVertexGeminiClients,
#2544 and #2870 seen again) and passed alone at that head: ok
internal/agent 1644.560s, ok internal/gateway 1397.712s. Rebased on
origin/main 4ae6c06dc, every package its new commits touch run in full
there: ok internal/agent 465.353s, internal/gateway 648.172s,
internal/sessions, internal/gui, internal/cli, internal/codexsummary;
gofmt -l on the changed files empty; go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./... clean; go build for
darwin, linux (nogui) and windows ok (at 0fe039f14).
Then rebased on origin/main 2201b6628 (one line in
internal/provider/migrate_qoder.go): ok internal/provider 608.249s; go
vet of internal/provider, internal/agent and internal/gateway clean.
2026-10-21 03:40:26 +08:00
yetone 2201b66285 provider: the Qoder mover's min is 0.2.24, where Qoder's 400 "Error in upstream response" is a 502 (SlouchyQuill507 on Discord)
SlouchyQuill507 (Discord, qoder-cn) found Qoder's failures of the model's
own vendor, "Error in upstream response", reaching magpie as a 400: the
client's fault, never asked again or of another account. That runs in
the plugin for moved users, so the fix is
@magpie-community/opencode-qoder-auth 0.2.24 (plugins 4af310c,
"qoder 0.2.24"), which answers it as a 502 and keeps genuine 400s (Qoder's
request codes, other invalid requests) as 400. Raising the mover's min
makes keepMovedCurrent update every moved user to it. tooLongUnsaid still
tells an overflow that fails this way apart by its size, at 502 as at 400.
npm view @magpie-community/opencode-qoder-auth@0.2.24 version
--prefer-online: 0.2.24.

The same plugins push has cline 0.1.10 (the plugin's side of d2c434b5a:
glm-5.3-flash pinned by OpenRouter's provider.only ["z-ai"]); Cline has no
mover, so nothing here names its version.

Run at 0fe039f14 plus this change: gofmt -l (none); go vet ./... on darwin,
GOOS=linux -tags nogui and GOOS=windows: clean.
set -o pipefail; GOMODCACHE=/Users/yetone/go/pkg/mod go test -timeout 45m ./...:
62 packages ok; internal/agent, internal/gateway and internal/library hit
the 45m timeout with load average near 100 from other sessions' suites
(the tests running at the timeout had run 0-7s, no hang in the stacks).
Rerun of those three alone at load ~30: ok (agent 1345s, gateway 1130s,
library 914s), exit 0.
Rebased onto 4ae6c06dc (Codex compaction, routing, GUI tests; nothing in
internal/provider/migrate_qoder.go): gofmt -l (none), the three vets of
internal/provider and go test ./internal/provider/ ok (216s).
2026-10-21 03:18:24 +08:00
yetone 4ae6c06dc3 docs: gateway-routing says how magpie's Codex compaction is made portable
The magpie1: item, the message codexInputAs sends for it, and
sessions.PortCodexRollouts: what it changes, the writer-lock protocol, when
it runs, what was tried (Codex 0.162.1 resume against an upstream that
refuses magpie1: as OpenAI does) and what wasn't (a Codex in WSL).
2026-10-21 03:05:24 +08:00
yetone 19901812e7 gateway: a ported Codex rollout reads the same through magpie as magpie's compaction item did
TestPortedCompactionReadsTheSame: codexInputAs sends the same input for
magpie's item and for the message sessions.PortCodexRollouts writes in its
place, for a magpie model (native or not) and for Codex's own.

Run: go test ./internal/gateway -run TestPortedCompactionReadsTheSame.
2026-10-21 03:05:24 +08:00
yetone 4896fc3ba1 codex: a thread magpie compacted goes on after magpie is quit or disconnected (LukeMa on X)
When magpie answers Codex's compaction itself (a magpie model, Codex's
own models through magpie's accounts, a CC Switch table), the item it
returns carries encrypted_content "magpie1:"+base64(summary). Codex keeps
it in the rollout (a response_item, and the compacted checkpoint's
replacement_history) and replays it with every later turn. Sent to the
ChatGPT backend directly, it is refused: "The encrypted content for item
cmp_magpie_1 could not be verified ... invalid_encrypted_content"
(probed with a real request on gpt-5.6-luna; the same summary as a user
message was answered).

Codex's remote compaction v2 keeps exactly one Compaction item, so magpie
can't answer with a plain message instead. sessions.PortCodexRollouts
writes each of magpie's items in a rollout as the message it stands for
(codexsummary.Message: Codex's summary prefix, a newline and the summary,
as a user message), which is what Codex's own local compaction stores and
what the gateway already sends in its place, so it reads the same through
magpie and goes on without it.

- Only magpie's compaction items change; other lines keep their bytes,
  the file its line count, mode and time. An unreadable one is left out
  of a list with its replacement_history_metadata entry, as Codex's own
  ghost-snapshot strip does.
- Published as Codex publishes a compressed rollout: temp file and
  rename, under thread-writer-locks/.coordination.lock and only with the
  thread's lock free. A thread a Codex has open is left for a later pass.
  A Codex home without thread-writer-locks is left alone.
- .jsonl.zst rollouts are read and written packed.
- Passes: 2 minutes after the GUI or magpie serve starts and every 10
  minutes; on Codex Disconnect (3s); as the GUI quits (3s). The first
  pass reads rollouts written since 2026-09-24; later ones only what
  changed since the last whole pass, plus what was left held
  (codex-portable.json in magpie's folder).

Run at this series' head (on origin/main 0fe039f14):
- Real codex 0.162.1, sandbox HOME/CODEX_HOME, exec </dev/null, against a
  fake upstream. In magpie mode it auto-compacted and the rollout's
  compacted line held magpie1:. In OpenAI mode, `exec resume --last`
  failed with "Error running remote compact task: ...
  invalid_encrypted_content". After PortCodexRollouts on that home, only
  that line changed (42 lines before and after). The same resume exited
  0, and the upstream saw the summary message.
- Broken by hand. With the thread-lock TryLock check off,
  TestPortCodexRolloutsLeavesAnOpenThread went red. With the replacement
  off, TestPortCodexRollouts went red. Both green with the fix restored.
- gofmt -l clean. go vet ./... (darwin) clean, GOOS=windows go vet
  ./internal/... clean, and GOOS=linux go vet -tags nogui ./... clean.
- go test ./... -count=1 -timeout 45m: 64 packages ok, two reds.
  - internal/agent ran out of time at 2706s (load average 25 to 57), the
    known #2723/#2544. Alone, go test ./internal/agent -count=1 is ok in
    901s.
  - internal/provider TestHoldReadsMigrationsOnce: "migrations.json read
    again while held" at 2.70s. It passes alone 5 of 5. I didn't touch
    that package. Filed #3095: heldFor (1s) can run out between the
    test's two reads.

Not tried:
- api.openai.com itself after a port. The refusal was probed on the
  ChatGPT backend, and the resume ran against a fake.
- A Codex in a WSL distro. Disconnect skips it, because its locks can't
  be taken from Windows.
- The Codex app still holding a thread when magpie quits. Its lock is
  held, so the file is left for the next pass, and the thread in that
  app's memory keeps the magpie1 item until it is loaded again.
2026-10-21 03:05:24 +08:00
yetone 694674cf0d codexsummary: one owner for magpie's Codex compaction item and the message it stands for
The "magpie1:" mark, Codex's summary prefix and the reading of a magpie
compaction as Codex's own local-compaction summary message move from the
gateway into internal/codexsummary, so the rollout rewrite that comes next
(internal/sessions, which the gateway imports) reads it the same way. The
gateway's behaviour is unchanged.

Run: go build ./internal/...; go vet ./internal/gateway ./internal/codexsummary;
go test ./internal/codexsummary; go test ./internal/gateway
-run 'Compact|CodexInput|Rewrite|Native|CallItem|Protection' (ok, 57s).
2026-10-21 03:05:23 +08:00
yetone 4bb93b3255 gui tests: routing-wb-restricted waits for the posted lift instead of a fixed 300ms (#2658)
The test pressed Try now, paused 300ms and then read what its fake
/api/gateway/unrest had received. On a busy machine the POST reached the
fake after the pause and the list was still empty. It now waits up to 5s
for the lift to arrive and then checks it.

Red before: with a 600ms delay injected into the fake, the old test is 2
of 2 red (chromium en, 1100 and 420), the new one 2 of 2 green.

Run (macOS, Playwright 1.62.0, chromium and webkit, every language and
width the file runs): 20 of 20 green alone, and green in the
--test-concurrency=6 run of the 37 reach/wheelTo files (590 of 590).
2026-10-21 02:44:28 +08:00