Commit Graph
7089 Commits
Author SHA1 Message Date
yetone 1576ccdbbc davsync: the sync setup is read once a request, not on every Providers poll
/api/providers asks archiveState, which asks davsync.S3Bucket and so
Load, on every poll, and Load opened sync.json each time, most often a
file that isn't there. In a profile of 200 lists against a copy of the
owner's real config it was 0.19s of 4.07s.

Load now reads the file's bytes through filememo (once until it
changes, remembered missing while a request holds it) and unmarshals a
Config of its own for each caller. Configure and Restore write through
edit.WriteAtomic, which forgets already; Off removes the file and now
calls filememo.Forget too, so sync turned off in a request is off for
the next Load in it.

Run (on mote unless named):
- go test -count=1 ./internal/davsync ok (36.9s); ./internal/gui red on
  TestMainWindowCorners only (macOS 27 on mote, #3949); GOOS=linux and
  windows go vet ./internal/davsync ok; gofmt clean (here).
- New TestLoadReadOnceARequest, -count=3 ok: 20 loads in one held
  request read once, a caller's change stays its own, and Off is seen
  at once. Broken by hand: Load reading the file each time -> "read 20
  times, want 1"; no Forget in Off -> "still on after Off".
- Here, 200 GET /api/providers on the sandbox with the real config
  copy (offline, proxy :9): davsync.Load 0.19s -> gone from the
  profile; total CPU within this machine's noise (4.53s -> 4.62s).
- Then rebased onto 8d8df0639 (nothing in internal/davsync or filememo); not rerun.

Not run: the full ./... suite; a real WebDAV or S3 sync (the write
paths are unchanged).
2026-11-01 13:46:44 +08:00
yetone 8d8df06399 plugin, gateway: a plugin reports its models' load, and busy models can go last (axelburks on Discord)
axelburks (Discord #feedback): an in-house vendor queues requests to
its busy models, and the plugin could only put the load in the model's
name, which changed only when magpie re-read the list.

- A provider plugin calls input.magpie.load(provider, {"<model id>":
  0-100 | null}) whenever it likes, from its own timer. host.js
  (reportLoad) clamps each number to 0-100, null clears a model, every
  other value is dropped, at most 1000 a call, and it returns the count
  taken. A provider that isn't a string or loads that isn't an object
  throws a TypeError. It goes to Go as an unasked {event:"load"}.
- internal/plugin/load.go keeps each by provider and lowercased model
  id. ModelLoad answers unknown once a load is older than LoadFresh
  (5 minutes), never idle. model@size falls back to its model.
- The provider editor shows it by the model as a grey ctx badge
  ("87%", titled "87% busy now, as its plugin says").
- Settings > Network and sharing > Busy models last (settings.BusyLoad,
  POST /api/settings/busy-load, Off by default, over 50/70/80/90% or
  1-99 by hand): restLast puts a model reported over it behind the
  ready candidates, ahead of the resting. The trace row has busy:<load>.
  At a new turn affine moves a conversation off it (Why "busy",
  busyBehind); within a turn it stays. after, readyForNew and leastHeld
  skip it. Unknown load, a lone candidate, or all busy: nothing moves.
- Docs: site plugins page (en, zh, ja) "Model load" section and input
  table; docs/subsystems provider-plugins.md and gateway-routing.md.

Run, all on mote via mote-run at a42736807's tree rebased on
origin/main b683f1c0e:
- go test ./internal/plugin ./internal/gateway -run
  'ModelLoad|TestBusy' -v: TestPluginReportsModelLoad,
  TestModelLoadGoesStale, TestBusyModelGoesBehind,
  TestBusyModelNotKeptAtNewTurn pass.
- Broken by hand, each red: host.js not sending the event
  (TestPluginReportsModelLoad "the plugin's loads never arrived"), the
  busy case off in restLast (TestBusyModelGoesBehind order), the affine
  "busy" case off (TestBusyModelNotKeptAtNewTurn "kept true, why
  session").
- go test ./internal/gui -run Budget: ok. No budget raised. app.js
  +86 bytes, two comments trimmed to fit. The settings row lives in
  plugins/gateway/settings.js.
- node --test model-load, i18n-keys, bare-ids, model-rate: 69/69 pass.
  model-load is Chromium and WebKit, 420 and 900 wide, en zh zh-TW ja
  de.
- gofmt -l: empty. go vet ./... (darwin), GOOS=linux go vet -tags
  nogui ./..., GOOS=windows go vet ./..., go build: ok.

Not run before the push (owner: push and tag first): go test ./...
-timeout 45m and the whole GUI suite. mote and the WSL box were each
running another session's full suite. Both run next, and any red gets
its own commit.
Not tried: a real plugin and vendor reporting load. The plugin side is
tested through the real Bun host with a plugin written in the test.
2026-11-01 13:45:40 +08:00
yetone b683f1c0e1 gateway: a search on Volcengine Ark asks for no include value Ark refuses
axelburks on Discord #feedback (1566310723922042991): every web search
on an Ark model (ark.cn-beijing.volces.com) failed with 400 "The
parameter `include` specified in the request are not valid: unknown
type: web_search_call.action.sources". buildResponses adds that value
to every Responses request offering web_search on any host but
api.x.ai (#315, c4ae3ca77); Ark became a host that searches by itself
later (a0cb8b646), and forArkSearch fitted the tool but not include.

Ark's 创建 Response page (docs.volcengine.com/docs/82379/1569618) names
`include` but lists no values, so they were asked of the real API with
the owner's key (deepseek-v4-1-flash-260910): reasoning.encrypted_content
is taken; web_search_call.action.sources, web_search_call.results,
file_search_call.results, message.input_image.image_url,
computer_call_output.output.image_url, code_interpreter_call.outputs and
message.output_text.logprobs are each refused with the reporter's 400.

- search_ark.go: arkIncludes (reasoning.encrypted_content alone) and
  includeTaken(host, v), Ark's host only.
- buildResponses (every translated request, Claude Code's
  web_search_20250305 and Settings' searcher on an Ark model included):
  a value Ark refuses is left out of the client's include, and the
  sources value isn't added for Ark. Every other host is as it was.
- forArkSearch (a Responses client relayed to Ark): include keeps what
  Ark takes, and goes when nothing is left. The AI SDK's OpenAI
  provider (OpenCode) adds web_search_call.action.sources itself
  whenever it offers web_search (@ai-sdk/openai 3.0.27, index.mjs
  addInclude), so that route failed the same way.

Siblings in searchHosts[Responses]: api.openai.com takes the value
(OpenAI's own), api.x.ai already gets none, and api.deepseek.com took
it with web_search on the real API (200, completed). open.bigmodel.cn
and api.z.ai: no key here, not tried; no report of a refusal.

Tests: TestArkSearchSendsNoIncludeItRefuses (a fake Ark on the real
host through a redirected dialer that answers the reporter's 400 for
any include value Ark refuses: Claude Code's search translated,
OpenCode's relayed with sealed reasoning kept, and Settings' searcher
on the Ark model), TestArkIncludeScope (OpenAI's and a relay's include
unchanged, sources still added; Ark's keeps only what it takes).

Broken by hand: includeTaken returning true and forArkSearch's include
filter off: all three subtests red with the reporter's exact 400
(searcher: "...unknown type: web_search_call.action.sources ... (the
searcher picked in Settings › Web search ...)"), and TestArkIncludeScope
red.

Real use: the bodies the fixed gateway sends Ark on all three routes
(captured from the test) sent to the real Ark API: each is accepted and
streams; the old shape (with the sources value) is refused with the
reporter's 400. This account hasn't activated Ark's web search, so the
search itself ends ToolNotOpen; a search returning pages wasn't seen.

Run (mote, mote-run, at e84870f17 + this change):
- gofmt -l internal/gateway: nothing.
- go vet ./internal/gateway, GOOS=linux go vet -tags nogui
  ./internal/gateway, GOOS=windows go vet ./internal/gateway: ok.
- go test -count=1 -timeout 45m ./internal/gateway: ok (572.5s).

Not run: the other packages' suites (only internal/gateway changed).

Rebased onto 6874b892b, which changes no internal/gateway file; gofmt, vet x3 and the Ark/include/search tests ran again there: ok.
2026-11-01 13:43:35 +08:00
yetone 6874b892bb providers: a StepFun sign-in is read once a request, not once a row
/api/providers asks StepFunSignedIn for each StepFun provider on every
poll, and each ask opened stepfun-auth.json under stepfunMu, most often
a file that isn't there. In a profile of 200 lists against a copy of
the owner's real config (2 StepFun providers) it was 0.28s of 4.07s.

StepFunSignedIn now reads the file through filememo, which parses it
once until it changes and remembers it missing while a request holds
it. A file with a site's session from before #2384 ("ai", "com") still
goes through loadStepFun under the lock, which moves it. saveStepFun
calls filememo.Forget, so a sign-in saved during a request is seen by
the next ask in it.

Run (on mote unless named):
- go test -count=1 -timeout 45m ./internal/provider ok (115s);
  -run TestStepFun -count=3 ok; GOOS=linux and windows go vet
  ./internal/provider ok; gofmt clean (here).
- New TestStepFunSignedInReadOnce: 40 asks in one held request parse
  once, and a save inside it is seen. Broken by hand: each ask reading
  the file -> "parsed 0 times, want 1"; no Forget in saveStepFun -> "a
  sign-in saved in the request wasn't seen".
- Here, 200 GET /api/providers on the sandbox with the real config
  copy (offline, proxy :9): StepFunSignedIn 0.28s -> gone from the
  profile, syscalls 1.54s -> 1.08s; total CPU 4.49s -> 4.53s, within
  this machine's noise.

Not run: the full ./... suite; GUI tests (no page change); a real
StepFun sign-in (the save path is unchanged apart from Forget).
2026-11-01 13:40:29 +08:00
yetone 3ee6c2d948 providers: a provider list looks at the stamps, plugin logins, client shapes and accounts once a request
/api/providers took ~25ms of CPU a call with the owner's real config (25
providers, plugins signed in), polled by every open window. Its profile
had file system calls at about half, each repeated for every provider
the list shows:

- StampNow stat'ed providers.json, settings.json and the catalog for every
  provider (KeptListing); under a request's Hold it is looked at once.
- plugin.ListedAt was asked for every plugin provider's Listed(); once a
  request (heldOf "plugin-listed").
- pluginLogins took logins.json's lock, a file opened across magpies,
  for every plugin even with nothing to change. It now settles the list
  as read first, and takes the lock and settles again from a fresh read
  only when something changes.
- clientShape read and parsed client-shapes.json for every relay a list
  shows (TestsAs); parsed once until the file changes (filememo), a copy
  given out.
- Logins(agent) took the same lock for every provider, twice with its
  account models; listed once an agent a request, a copy each, listed
  anew after a write (writePrivate's filememo.Forget).

Run (on mote unless named):
- go test ./internal/provider ./internal/gui -timeout 45m: provider ok
  (102s) with the new tests; gui red on TestMainWindowCorners (macOS 27,
  #3949) and on TestSettingsSaveKeepsWhatItDoesNotSend, red on main since
  b09349d17, fixed by #4514's commit before this one.
- At the pushed head (rebased on e84870f17): go test ./internal/provider
  ok (100.7s), ./internal/plugin ok (102.7s), TestLoginsListedOnceARequest
  -count=5 ok (it now clears the 30s look another test left), gui
  TestSettingsSaveKeepsWhatItDoesNotSend and TestCoreScriptBudget ok;
  GOOS=linux and windows go vet ./internal/provider ok.
  Then rebased onto 3defaf662 (internal/agent dsh.go only); not rerun.
- New tests: TestStampLooksOnceARequest, TestClientShapeParsedOnceUntilWritten,
  TestLoginsListedOnceARequest, and TestAccountListsCopyNoLoginsUnchanged
  now counts the lock. Broken by hand, each goes red: "51 stamps in one
  request looked 51 times, want 1", "30 asks parsed the file 30 times",
  "20 plugin lists with nothing to change took the lock 20 times",
  "20 lists in one request listed 20 times".
- GOOS=linux and windows go vet ./internal/provider: ok. gofmt clean.
- Real config, on this Mac: a copy of the owner's ~/.config/magpie in an
  offline sandbox HOME (proxy :9), 200 GET /api/providers each:
  v0.1.2541 5.04s CPU (25.2ms a call, median 22.5ms wall), this change
  4.55s (22.8ms, median 20.3ms). The profile's stats under StampNow fell
  from 2.17s to 0.34s.

Not run: the full ./... suite; GUI (browser) tests, as nothing the page
gets changed. What is left in the profile: StepFun's sign-in file,
sync.json, plugin icons and agent detection, each read once a request.
2026-11-01 13:32:30 +08:00
yiqiui 9fdef3ea22 gui: keep SearchAll through a save of the Settings page (#4514)
TestSettingsSaveKeepsWhatItDoesNotSend is red since SearchAll came in
with b09349d: the field is never sent by the Settings page, but the
test neither set it nor kept it through POST /api/settings. Set it in
the test; the handler keeps it (api.go, search-all below).
2026-11-01 13:32:30 +08:00
yetone 3defaf6622 dsh: a new desktop profile gets magpie's routes when the start is the user's (zyh6036 on X)
DeepSeek Harness Desktop 0.2.1-rc.5's picker listed only "DeepSeek 账号".
The app reads $DSH_HOME/profiles/desktop (apps/desktop/src/paths.ts) and
makes it from an empty template on its first start. dshFillNewProfiles
gave such a profile magpie's routes only when a wired profile started on
one of magpie's models; with the web profile wired but started on one of
dsh's own, it returned early and the desktop profile stayed bare. Now a
bare profile gets the routes alone in that case (no start written, the
user's pick stays theirs), and nothing is filled when no profile is wired.

Run:
- go test ./internal/agent -run TestDshFillNewProfiles on mote at
  ed5872d18: the new TestDshFillNewProfilesWhenTheStartIsTheUsers red on
  the old code (desktop profile left as the template), green after.
- go vet ./internal/agent (darwin, GOOS=linux, GOOS=windows) and
  go test -count=1 -timeout 45m ./internal/agent on mote: ok (183s).
- Real DeepSeek Harness Desktop 0.2.1-rc.5 (official zip, sha512 checked
  against nightly-mac.yml) on mote, sandbox DSH_HOME, not signed in:
  first start wrote profiles/desktop/cordis.patch.yml as the empty
  template; with a route-only patch (no agent-default-model), as this
  change writes, the picker listed the Magpie group (35 models).

Broken by hand: the no-profile-wired guard taken out, the test's last
check goes red (web and desktop templates filled).

Not tried: the reporter's own patch (not sent yet); a signed-in DeepSeek
account in the desktop app; the full go test ./... suite; Windows.

At the pushed head (rebased on e84870f17): go test -count=1 -run Dsh
./internal/agent on mote ok, gofmt -l clean.
2026-11-01 13:29:19 +08:00
yetone e84870f173 plugins: an option's words in the window's language, and a filtered model list says so (plugins#590)
anewuser6937 (Discord, plugins#590) saw one model in WorkBuddy's editor
and took the plugin for broken. They had turned on "Free models only"
themselves, but its label and description read in English in the Chinese
window, and nothing by the models said the list was filtered.

A plugin option (auth.options, magpie's own field; OpenCode's AuthHook is
provider/loader/methods and never reads it) may now give `labels`,
`descriptions` and `confirms`, each keyed by the window's language
("zh", "zh-TW", "ja", "de"), beside the plain strings, as a page's
`titles` do. The host keeps only non-empty strings under language names
of 16 or less, 16 languages at most, each capped as the plain one is
(60/300/300). The editor shows the exact language, then its first part
(zh-TW reads zh), else the plain words, in the row, the hint, and the
confirm dialog and its title. `filtersModels: true` says the plugin's
model list leaves models out while the switch is on; while one is on, as
saved, the Models field says under the chips "Only some models are
listed: the plugin option “…” is on." (zh 只列出部分模型:插件选项「…」已开启。,
zh-TW, ja, de too). An older plugin shows what it showed before, and an
older magpie shows a new plugin's plain words with no note.

WorkBuddy 0.2.10 gives "Free models only" in all four languages with
filtersModels (magpie-community/plugins aec58ae, on npm: `npm view
@magpie-community/opencode-workbuddy-auth@0.2.10 --prefer-online` on mote
says 0.2.10, latest), and the mover's min is raised to it so every moved
user gets it. The CLI's `magpie plugin options` stays English, as the CLI is.

The core scripts would have gone 608 bytes over their budget; three of the
provider editor's comments in app.js are cut down instead, no raise
(1,532,865 of 1,533,105).

Run, on mote (mote-run), at this tree:
- node --test plugin-option-words.test.cjs (new): Chromium and WebKit,
  1100 and 420 wide, en/zh/zh-TW/ja/de, switch on and off: each
  language's label and description, zh-TW falling back to zh and ja/de to
  the plain words for a zh-only option, the note exactly once under the
  chips in a .hint inside the editor with no sideways scroll, none while
  off, the confirm in the language. With app.js put back: 19 of 21 red
  in Chromium (only "en off" passes, both widths).
- With plugin-options.test.cjs and i18n-keys.test.cjs, both engines:
  68 pass, 0 fail.
- go test ./internal/plugin ./internal/provider ./internal/cli: ok.
  TestPluginOptions with host.js put back: red (empty maps, FiltersModels
  false). The real WorkBuddy 0.2.10 index.mjs loaded into this host
  (a temporary test, not kept): plugin.Providers lists free_only for
  workbuddy and workbuddy-ai with all four languages and filtersModels true.
- go test ./internal/gui: TestCoreScriptBudget ok after the cut. Red,
  and red the same at origin/main ed5872d18 (run there too):
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514), TestMainWindowCorners
  /macOS_26_SDK on macOS 27 (#3949); TestColdTurnsTaken red once in the
  package run and passed at origin/main (#4510, the same 0.00s red).
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- plugins: HOME=$(mktemp -d) bun test packages/workbuddy 303 pass 0
  fail; the new freeonly test red 2 of 2 with index.mjs put back.

Not run: the whole GUI suite. mote and the WSL box were each running
another session's full GUI suite (hours left on both), and one runs per
machine; it runs on mote once that one ends. Not tried: a real WorkBuddy
account in the real app window. go test ./... was not run.
2026-11-01 13:24:50 +08:00
yetone ed5872d186 gateway: a kept previous response holds its input, not the body it came in
previousResponse kept each turn's input items as views into the request
body, so every response kept for previous_response_id held its whole
body: tools, instructions and anything else the client sent. own counted
only the items, so prevCap's 256 MB bounded far less than was held. The
input is now copied out (ownItems, as the Codex socket does since
ec0a11d47) and own counts the bytes copied.

Run:
- Real zcode account (plugin), sandbox HOME with no network to anything
  else: 30 HTTP /v1/responses turns, store true, chained by
  previous_response_id, ~600 KB per body. Live heap before -> after:
  old (ec0a11d47) 23.9 -> 101.1 MB; this change 24.0 -> 42.9 MB, and 30
  more turns 41.6 -> 43.9 MB.
- mote: go test -run 'Prev|Previous|KeptTurn|HeldTurn|Socket'
  ./internal/gateway ok. TestKeptTurnOwnsItsInput is red with the copy
  taken out by hand ("kept after the body was written over").
- GOOS=linux and GOOS=windows go vet ./internal/gateway ok; gofmt clean.

Not run: the full suite before the push (the gateway package runs right
after it).
2026-11-01 12:58:45 +08:00
yetone ef8bd98fba gui: a scroll down to a view's end with a wheel the page never hears stands
On macOS 13's WebKit the page never hears the wheel, so a scroll at rest
waits for a second one the same way before it counts as the reader's,
and is put back after 120ms if none comes. A view with less room than
one wheel step reaches its end on the first step, and no second scroll
can follow, so the reader's step was put back. A scroll down that stops
at the end, with the content still the same height, is now the
reader's. Code's put-backs this guards against come from a redraw: up,
or with the height changed.

Found by view-open-wheel at 420px in zh and zh-TW, Chromium: the phone
head left Usage's skeleton 23px of room, less than the test's 30px
step, and it was red 3 of 3 on this branch.

Broken by hand: without this change the case is red 3 of 3 alone
(MAGPIE_OPEN_WHEEL_HEARD=unheard, Chromium); with it, green in the run
below, and main at 8ac1c7a56 is green 3 of 3 alone. The comment above it
was shortened so the core scripts stay under their budget, not raised.

Run (mote, at this branch's head after the rebase onto 8ac1c7a56, beside
8ac1c7a56 itself): go test ./internal/gui/, and 116 GUI files (every
usage-*, view-*, *scroll*, phone-* and thumb file, Routing's rules and
the sign-in files) in both engines, concurrency 4. 1903 tests, 64 red on
the head; 1891, 64 red on main. The branch's own tests pass:
usage-phone-head in all 5 languages and both engines, usage-range,
credit-days, routing-held-dot, routing-rule-columns, segs-glide.
Red on both, each with an issue: TestSettingsSaveKeepsWhatItDoesNotSend
(#4514), TestMainWindowCorners/macOS_26_SDK (#3949), provider-typed
(#4673, filed now), tencent-cloud (#4321), usage-agents-hide (#3414),
usage-ledger Requests (#3104), mobile-web (#3952), phone-connect-menu
(#3524), menu-input-scroll (#3402), provider-levels-scroll (#4395),
view-open-wheel in WebKit under load (#4132); alone, its WebKit
unheard case passes 2 of 2 on both. signin-closes-sheet (#2628) is red
alone 3 of 3 on main and 1 of 3 here. signin-paste-import's paste
subtests were red once each (en here, zh on main), on the click #4035
names.
Before the last three commits and the rebase, the whole GUI suite ran on
this branch: 17076 tests; the reds it alone had were routing-held-dot and
routing-rule-columns (fixed by the thumb commit), credit-days and
usage-range (the two test commits).
At the pushed head, rebased onto 90c02326b (which left the core scripts
1 byte of room; this branch's app.js lines were cut by 179 bytes to
24 under main's, no raise): go test ./internal/gui/ on both. Head:
TestCoreScriptBudget passes; red are TestSettingsSaveKeepsWhatItDoesNotSend
(#4514) and TestMainWindowCorners/macOS_26_SDK (#3949), as on main, which
also has TestColdTurnsTaken red (#4510). And 110 GUI files at the head
(every file naming thumb or segs, usage-phone-head, usage-range,
credit-days, view-open-wheel, gateway-skew, i18n-keys), both engines:
2080 tests, 28 red, all in omarchy (#4624), s3-sync (#2448),
segs-press-redraw (#4566, #3922) and tencent-cloud (#4321); those four
files are 28 of 72 red on 90c02326b too.
Then rebased onto 8f5f2a294 (Library, Plugins and search pages, none of
this branch's files): the core scripts are 1,533,079 against 1,533,105,
and go test ./internal/gui/ at the pushed head has only the two reds
above.
Not tried: a real phone; Playwright at 390 and 420px stands in for one.
2026-11-01 12:55:38 +08:00
yetone febef9741f gui: a thumb is put under its option on the window's resize, before the ResizeObserver
A phone draws its options at 13px with 11px padding (the first commit of this branch), and desktop at 12px and 10px. When the window crossed the phone width, a thumb kept its old size until thumbFit ran. In Routing at 560 to 1100 in WebKit, the group-names strip's thumb ran 4px past the view, and the view got a sideways scrollbar 10px tall. thumbFit then moved the thumb back, which changed the view's height inside its own callback, and WebKit reported a ResizeObserver loop (routing-held-dot, routing-rule-columns).

Found by tagging each ResizeObserver with its creation stack. Then, on the first frame after the resize, I hid the view's descendants one at a time to see which one widened it.
Broken by hand: without this change routing-held-dot is red 5 of 5 in WebKit at 560px, and with the phone's option size back at 44px it passes.
Run: routing-held-dot, routing-rule-columns and the 14 GUI files that mention the thumb, on mote, both engines: 189 of 189 pass.
Budget: the code and its comment were made shorter so the core scripts
stay under TestCoreScriptBudget's 1,533,105, which isn't raised.
After the rebase, in the 116-file run below: routing-held-dot,
routing-rule-columns and segs-glide pass in both engines.
2026-11-01 12:53:13 +08:00
yetone 32bedd44f7 gui tests: usage-range picks its days from the phone's menu, where the strip is hidden
At 390px the head hides #period behind #usageRangeMenu (the phone head commit before this). The test opens the menu and picks the range opt (its last item) or a preset (its first), and checks the menu names the days picked.

Run: usage-range on mote, both engines, en and zh: 4 of 4 pass.
2026-11-01 12:53:13 +08:00
yetone 4c46141dfe gui: a phone's choice of options in Settings shares its row's middle, as in Usage's filters
The 32px strip (the first commit of this branch) sat at the top of a .prefs .val row of 44px fields, 6px above their middle (redact-rule-edit, redact-rule-row). The sess-tools rule now covers .prefs .val too.

Run: redact-rule-edit and redact-rule-row on mote, both engines, every language: pass.
2026-11-01 12:53:13 +08:00
yetone b791973354 gui tests: credit-days reads Today from the phone's days menu, where the strip is hidden
The phone head commit (usage: a phone's head is the tabs over one line
of days, sum and refresh) put a phone's days behind a menu over a hidden #period, so the
360px test's click on Today waited 5s on a hidden button in every engine
and language (10 of 10 red in the whole suite). It now checks that the menu
says Today there; a wide window still clicks the strip. On mote: 10 of 10
green.
2026-11-01 12:53:13 +08:00
yetone 6c29beba1e gui: on a phone a picker is drawn as tall as the choice beside it, and search shares a line with Export CSV
Requests' "All models" picker was 44px beside a 26px status strip, aligned
at the top, and Export CSV sat alone on its own line. A .sess-pick on a
phone is now drawn 32px and taken at 44 by its own ::after, like .segs;
the strip in the sess-tools row is 32px (28px options) and centred, and
the search field and Export CSV share the last line.

Run (mote, at this branch's head after the rebase onto 8ac1c7a56, beside
8ac1c7a56 itself): go test ./internal/gui/, and 116 GUI files (every
usage-*, view-*, *scroll*, phone-* and thumb file, Routing's rules and
the sign-in files) in both engines, concurrency 4. 1903 tests, 64 red on
the head; 1891, 64 red on main. The branch's own tests pass:
usage-phone-head in all 5 languages and both engines, usage-range,
credit-days, routing-held-dot, routing-rule-columns, segs-glide.
Red on both, each with an issue: TestSettingsSaveKeepsWhatItDoesNotSend
(#4514), TestMainWindowCorners/macOS_26_SDK (#3949), provider-typed
(#4673, filed now), tencent-cloud (#4321), usage-agents-hide (#3414),
usage-ledger Requests (#3104), mobile-web (#3952), phone-connect-menu
(#3524), menu-input-scroll (#3402), provider-levels-scroll (#4395),
view-open-wheel in WebKit under load (#4132).
Before the last three commits and the rebase, the whole GUI suite ran on
this branch: 17076 tests; the reds it alone had were routing-held-dot and
routing-rule-columns (fixed by the thumb commit), credit-days and
usage-range (the two test commits).
Not tried: a real phone; Playwright at 390 and 420px stands in for one.
2026-11-01 12:53:13 +08:00
yetone 457cfd7c63 usage: a phone's head is the tabs over one line of days, sum and refresh
The owner's pick of three phone designs (B): Usage's tabs run across the
head, and under them one line holds the days as a menu ("7 days ⌄", the
app's own menu, never a <select>), the sum, and the refresh as a dot and
its figure ("● 5s", green while live). The days strips (#period,
#sessRange, #ctxRange) are hidden behind the menu. It follows whichever
the open tab shows, and a pick clicks that strip's option, so each choice
keeps its one handler; Custom opens the range menu from the head. Each
control is drawn about 30px and tapped at 44. A desktop window keeps its
strips. The refresh keeps its own menu and
its reload icon, unlike the mock-up, which had neither.
usage-phone-head.test.cjs checks the layout, the menu and the taps in
every language and both engines at 390 and 320px, and a desktop
window at 1100px.

Run (mote, at this branch's head after the rebase onto 8ac1c7a56, beside
8ac1c7a56 itself): go test ./internal/gui/, and 116 GUI files (every
usage-*, view-*, *scroll*, phone-* and thumb file, Routing's rules and
the sign-in files) in both engines, concurrency 4. 1903 tests, 64 red on
the head; 1891, 64 red on main. The branch's own tests pass:
usage-phone-head in all 5 languages and both engines, usage-range,
credit-days, routing-held-dot, routing-rule-columns, segs-glide.
Red on both, each with an issue: TestSettingsSaveKeepsWhatItDoesNotSend
(#4514), TestMainWindowCorners/macOS_26_SDK (#3949), provider-typed
(#4673, filed now), tencent-cloud (#4321), usage-agents-hide (#3414),
usage-ledger Requests (#3104), mobile-web (#3952), phone-connect-menu
(#3524), menu-input-scroll (#3402), provider-levels-scroll (#4395),
view-open-wheel in WebKit under load (#4132).
Before the last three commits and the rebase, the whole GUI suite ran on
this branch: 17076 tests; the reds it alone had were routing-held-dot and
routing-rule-columns (fixed by the thumb commit), credit-days and
usage-range (the two test commits).
Not tried: a real phone; Playwright at 390 and 420px stands in for one.
2026-11-01 12:53:13 +08:00
yetone f00a849019 gui: a phone draws a choice of options 32px tall and takes it at 44
On a phone (body.web at 760px or less, or a coarse pointer to 1024px) a
.segs strip was 44px of fat buttons. Its options are now drawn 28px
tall in a 32px strip, 13px text with 11px padding, and each takes a tap
44px tall through a transparent ::after, so what is drawn is small and
what a finger hits is not.

Run (mote, at this branch's head after the rebase onto 8ac1c7a56, beside
8ac1c7a56 itself): go test ./internal/gui/, and 116 GUI files (every
usage-*, view-*, *scroll*, phone-* and thumb file, Routing's rules and
the sign-in files) in both engines, concurrency 4. 1903 tests, 64 red on
the head; 1891, 64 red on main. The branch's own tests pass:
usage-phone-head in all 5 languages and both engines, usage-range,
credit-days, routing-held-dot, routing-rule-columns, segs-glide.
Red on both, each with an issue: TestSettingsSaveKeepsWhatItDoesNotSend
(#4514), TestMainWindowCorners/macOS_26_SDK (#3949), provider-typed
(#4673, filed now), tencent-cloud (#4321), usage-agents-hide (#3414),
usage-ledger Requests (#3104), mobile-web (#3952), phone-connect-menu
(#3524), menu-input-scroll (#3402), provider-levels-scroll (#4395),
view-open-wheel in WebKit under load (#4132).
Before the last three commits and the rebase, the whole GUI suite ran on
this branch: 17076 tests; the reds it alone had were routing-held-dot and
routing-rule-columns (fixed by the thumb commit), credit-days and
usage-range (the two test commits).
Not tried: a real phone; Playwright at 390 and 420px stands in for one.
2026-11-01 12:53:13 +08:00
yetone 8f5f2a2941 provider: Qoder's mover min is 0.2.52, which renews a job token whose model list is only the free models
star21321321124_93024 (Discord #general, 2026-11-01): a Qoder CN account
with all its credits left listed one model, the free Flash ("Qoder CN: 1
model"), and its agents saw only that one. Qoder CN's model list answers
a caller it doesn't take for the account with every paid model
enable:false and the free one on (captured from gateway.qoder.com.cn,
kept in the plugin's testdata). Up to 0.2.51 the plugin renewed the job
token for such a miss on a chat (plugins#484) but read the list magpie
shows as it came. 0.2.52 renews once from the list too, and doesn't
renew again for a renewed token that still lists only the free models.
keepMovedCurrent brings every moved user up to it.

TestQoderMoverHasTheFreeViewRenewal checks both the qoder and qoder-cn
movers; it fails at 0.2.51 (run).

npm: `npm view @magpie-community/opencode-qoder-auth version
--prefer-online` = 0.2.52 at this commit (registry.npmjs.org, from mote;
this machine's npmmirror still said 0.2.51).

Run at this tree (origin/main b1fc43540 + this change), on mote:
`go test -count=1 -timeout 45m ./internal/provider`: ok (103s).
`gofmt -l internal/provider`: nothing.

Not tried: a real Qoder CN account (none here); whether a renewal gives
the reporter's account its full list back is not confirmed.
2026-11-01 12:52:19 +08:00
yetone b1fc435407 library: Magpie Web Search, magpie's search MCP server in Library › MCP (lutra_fs)
lutra_fs on Discord: magpie's search MCP shows in Settings › Models but
not in Library › MCP servers. They were right. The gateway's web search
MCP (/mcp/magpie/web-search) was only an address to copy in Settings ›
Models › Web search. It was never a Library server, so no agent could be
given it from the Library, and the Library didn't list it.

Change:
- `magpie mcp search`: a stdio relay to the gateway's search MCP, made by
  widening browsermcp's Magpie Browser relay into a bridge with its own
  path, title and an optional session (search sends none, and has a 5
  minute client). It takes no arguments. When magpie isn't running, it
  says "Magpie Web Search can't be reached: start magpie".
- library: Magpie Web Search (magpie-web-search) is a featured,
  opt-in server beside Magpie Image and Magpie Browser. It is installed
  with no agents, so the user picks them in its sheet, and it switches
  per agent like any other row. Its command is the full binary path, and
  serverKey treats any binary's `mcp search` as the same server. Each
  agent's tool timeout is at least 120s.
- Settings › Models › Web search › MCP server: under the address there is
  a "Give agents Magpie Web Search…" link that opens its Library sheet,
  or "Turn on the Library" while the Library is off, as Images does for
  Magpie Image. Gateway mode has no link.
- The sheet's hint says where each search goes and what it costs. All
  strings are in en, zh, zh-TW, ja and de.
- docs/subsystems/library.md names magpie's own servers and the new one.
- An agent in WSL gets it through the MCP router, as Magpie Browser
  does. The image-only WSL side() is unchanged.
- The sibling, Image recognition's MCP server, is still in Settings only.
  That is filed as #4653.

Run, at this head (rebased on origin/main a6217e83d), on mote: gofmt -l
is empty. go vet passes for darwin, linux (nogui) and windows.
internal/library, browsermcp, cli and imagemcp pass. The internal/gui Go
package and the GUI files search-mcp-library, search-mcp,
images-library-way, i18n-keys, gui-ja/de/zh-tw, searcher-pick and
search-keys: 197 passed, 2 failed. The 2 reds are both known. gui-ja is
the {agent} ja string, #4580. searcher-pick's chromium en case reads a
null box: red 1 of 3 here and 2 of 3 at a6217e83d, filed as #4274.
internal/gui's three reds are red at base and filed:
TestSettingsSaveKeepsWhatItDoesNotSend #4514,
TestMainWindowCorners/macOS_26_SDK #3949 and TestColdTurnsTaken #4510.

New test: search-mcp-library.test.cjs covers Chromium and WebKit, 5
languages, at 1100 and 420px. On the old code it is red, 52 failed and
10 passed; the passes are its gateway-mode cases, which expect no link.
TestMagpieWebSearchIsOptIn and TestSearchBridgePassesLines are new too.

Broken by hand: with "search" taken out of serverKey,
TestMagpieWebSearchIsOptIn goes red (Have empty).

Real use: on mote, in a sandbox HOME, with a nogui build and the
gateway on 127.0.0.1:3611. `magpie mcp search` answered initialize with
serverInfo magpie-web-search and listed web_search in tools/list.
web_fetch https://example.com returned "Example Domain". With the
gateway killed it gave -32603 "magpie isn't running, so Magpie Web
Search can't be reached…". With an extra argument it exited 1 with
"takes no arguments".

Whole GUI suite on WSL magpie-desktop (load 120 to 180), at the
pre-rebase tree 73595f737: 17260 tests, 16684 passed, 574 failed. The
base, origin/main da0005df8, ran on the same machine: 516 failed, and
324 top-level tests were red. Each of the 161 files with a red was then
run alone on mote at head:
- At head, 118 of them pass alone. They aren't caused by this change.
- 43 fail alone at head, and every one of those also fails alone at
  base. Two pass at base once: login-import is flaky at both (#1307),
  and usage-curve-zoom-back went red once of two at base and passed 2 of
  2 at head.
  view-open-wheel was red 1 of 2 at both, filed as #4723.
- segs-press-redraw ("searchAllRow option 1") fails the same way at
  base, filed as #4566. gui-ja's {agent} string is #4580, and
  usage-ledger is #4078.
- Reds with no issue are now filed one per test: #4680 to #4728.
  Already filed: #4638 claude-mode, #4650 routing-request-model, #4176
  skeleton-bird and #1937 name-suffix-no-names.
Not tried: web_search with a real search API key (mote has none). An
agent in WSL using it directly. A run on the Windows box.
2026-11-01 12:38:01 +08:00
yetone a6217e83d3 plugins: a plugin npm said nothing of offers Install, not Coming soon (zhudabao8433 on Discord)
zhudabao8433 on Discord (#general, 11-01): PowerContext
(@magpie-community/gateway-powercontext) could be installed yesterday and
today reads 即将上线 again.

Cause: PowerContext was never pulled. It is in registry.json since
plugins 1e4c8a2 (10-29) and on the dist branch (0.2.0, every dist commit
since), and not on npm (E404), so magpie learns its version from the
dist branch's ~1.7MB index.json. Coming soon is drawn whenever a listing
has an npm answer with no version, and three paths gave one without
anything confirming the package is missing:
- builds before v0.1.2413 kept a dist read cut off at npmEach (6s) as
  "not on npm" in plugin-npm.json (ferock, e0eb74987). After an update,
  InfoCached (the listings) and Info ("what it said last") still served
  that empty answer while a new ask couldn't read the branch;
- the page turned every listing /api/plugins/npm said nothing of
  (unknown: npm or the branch not read in time) into { weekly: 0 }, i.e.
  Coming soon, and never asked again;
- /api/plugins/market gave every listing &NPM{} even when Info had no
  answer for it.

Fix:
- market.go: a cached "not on npm" over an hour old is unknown
  (npmEntry.missingStale): left out of InfoCached and of Info's seed.
  One said within the hour stands, as before.
- plugins.js: a listing npm said nothing of is marked unknown ({ u: 1 }), which
  offers Install (installDist waits for the branch with its own read);
  the page asks again up to 4 times, 15s apart, and the answer replaces
  it. A listing npm answered with no version still reads Coming soon.
- plugins.go: pluginMarketState leaves NPM nil when Info has no answer.

Old data: an old "not on npm" is unknown once an hour old, for every
user, with nothing to do on their side.

Tests:
- TestStaleMissingIsUnknownWhileDistUnread (internal/plugin): an
  hours-old "not on npm" with the dist branch 503 is in neither
  InfoCached nor Info; a minute-old one stands; once the branch answers,
  Info has 0.2.0.
- plugin-npm-unknown.test.cjs: PowerContext with no npm answer shows
  Install (enabled), Qoder answered without a version shows Coming soon,
  and after the 15s re-ask (page.clock) PowerContext shows v0.2.0. en,
  zh, zh-TW, ja, de; 980 and 420px; Chromium and WebKit.

Run (mote, at this commit rebased on origin/main 36af588e2):
- gofmt -l clean; go vet darwin, GOOS=windows, GOOS=linux -tags nogui on
  ./internal/plugin/... ./internal/gui/...: ok.
- go test -count=1 -timeout 45m ./internal/plugin/...: ok.
  ./internal/gui/...: TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestMainWindowCorners/macOS_26_SDK (#3949) red, the same on an
  origin/main 36af588e2 copy; TestCoreScriptBudget green (plugins.js is
  1 byte under main's, a comment cut, no raise).
- node --test plugin-npm-unknown (22/22), plugin-market, i18n-keys: ok.
  plugin-market webkit "the Plugins tab" was red once in the run after
  the Go suite, its output lost; 3 of 3 green after, alone.
- Broken by hand: the Go test is red on origin/main's market.go (an
  hours-old "not on npm" served; want it unknown); plugin-npm-unknown is
  red (waits for Install) on origin/main's plugins.js.
- Earlier GUI batch (70 files: plugin*, market*, i18n*,
  deprecation-notice, list-sort), before the rebase: 968/974; the reds
  are plugin-move-unserved (#4410, #4392, red the same on main) and
  plugin-github-filter chromium en 420px, batch only (#4679).

Not tried: a real slow network from China; zhudabao8433's version is not
known.
2026-11-01 12:12:05 +08:00
yetone ec0a11d47f gateway: a Codex socket's held reply keeps its input, not the frame it came in
A held turn's fresh input items were views into the response.create frame
they were decoded from, so each held reply kept that whole frame alive:
Codex's tools and instructions with it, for as long as the socket held
the reply (~39 MB of a long session's live heap). keep now copies the
fresh items into one buffer of their own; the conversation held before
is already owned, and the reply's items were already copied.

Run on mote: go vet ./internal/gateway; go test -run
'TestHeldTurnOwnsItsInput|TestResponsesSocket|TestCodexSocket'
./internal/gateway ok. Broken by hand (keep appends fresh as views):
TestHeldTurnOwnsItsInput fails, held items read back as the overwritten
frame.
Not run: the full gateway package before the push, and a real Codex
session over the socket.
2026-11-01 12:11:05 +08:00
yetone 36af588e2c gateway: "Context window is full" is a conversation too long for the model
ergou0954_54426 on Discord (#feedback, 11-01) routes by intent across
several models, one a "kiro opus" of an API-key relay (not magpie's Kiro
plugin). On long conversations the relay answered 400 "Context window is
full. Reduce conversation history, system prompt, or tools. (request id:
…)". That is the wording kiro.rs (src/anthropic/handlers.rs) and
kiro2claude (error-mapper.ts) give Kiro's CONTENT_LENGTH_EXCEEDS_THRESHOLD,
always as a 400 invalid_request_error, with new-api's request id after
it. tooLongRe had no words for it, so the 400 was an ordinary request
error: the group never asked the next member, and the agent got the
relay's 400 as a plain error, with no context_length_exceeded to compact
on. In a stream's error event it stood for a 502 (streamStatus), a
passing vendor fault that rests the account and is asked again.

tooLongRe now takes "context (window )?(is )?full", so overflowed,
failure, retryable, streamStatus, lateRests and writeErrorSaid all read
it the same way: on 400, 413 or 422, or in a stream's error event, the
member is passed for one with room (failOverflow, no rest), and alone
the agent is told context_length_exceeded. Not changed: a 5xx carrying
the words is still the vendor's fault (tooLong is 4xx only, as
TestContextOverflowSaidTheClientsWay holds for a 502), and
tooLongUnsaid still covers a 5xx only where the window is known.

Routing could not have skipped the member up front: a custom relay's
model has a window only from its own /v1/models list, models.dev by id
(catalog.ContextOf, with its spellings), or the user's Context setting.
A relay id such as "kiro-opus" matches none, so the window is unknown
(0), roomy keeps it and withRoom counts it as having room. A probe in a
fresh HOME gave windowOf 0 for claude-opus-4-6, kiro-claude-opus-4.6 and
kiro-opus on a custom provider.

TestContextWindowFullIsAnOverflow and
TestContextWindowFullGoesToAMemberWithRoom are built from the literal
text, with and without the request id, Anthropic- and OpenAI-shaped,
plus kiro.rs's sibling "Input is too long. Reduce the size of your
messages."; ordinary 400s (invalid model, model not found, messages
required) stay non-overflows.

Found and filed, not fixed: the last candidate's stream error event that
says too long reaches the agent as the vendor wrote it (#4675).

Run on mote, on this change at base 6f3dfc282: gofmt -l internal/gateway
clean; go vet ./internal/gateway, GOOS=linux go vet -tags nogui,
GOOS=windows go vet: ok; go test -timeout 45m -count=1 ./internal/gateway:
ok (730s). At the pushed head (rebased on 445891cf7, which changed
internal/gateway and internal/provider): gofmt and go vet
./internal/gateway clean, and go test -run of the two new tests,
TestContextOverflowSaidTheClientsWay, TestEveryVendorsOverflow,
TestChineseNotTooLong, TestKiroPluginOverflowGoesToAMemberWithRoom and
TestOverflowGoesToAMemberWithRoom: ok.
Broken by hand: the two new tests at origin/main 6f3dfc282 (without the
regex change) fail: every status reads as not an overflow, the stream
error stands for 502 and rests, and the group answers the relay's 400
with the second member never asked.
Not run: the whole gateway package at the pushed head, the full ./... suite (another session's suite held mote), the
GUI suite (no GUI change), a real Kiro-backed relay pushed past its
window.
2026-11-01 12:02:09 +08:00
yetone 445891cf74 gui: Insights › Masking keeps to the window's page width, centred, like every other page
refeccd on Discord (#feedback, 11-01): with the window maximised every
page sits in the middle at a fixed width, but Masking (脱敏) runs edge to
edge. The width cap is one rule in app.css that lists the pages by id
(body.window :is(#view-agents, …) { padding: max(16px, 50% - 600px) }).
Masking became a page of the redact plugin (#view-masking, kernel.js)
after that list was written and never joined it. Now it does. The cap
itself is unchanged.

Siblings: every page the sidebar opens (agents, sessions, library,
providers, routing, gateway, usage, masking, plugins) and Settings was
checked against the list; Masking was the only one missing. A community
plugin's page (.view.plugin-page) is a frame the plugin draws and is
left as it is.

The test: page-width.test.cjs no longer keeps its own list of pages. It
reads every page from the sidebar (#nav button[data-view], not a
community plugin's), plus Settings, and requires Masking among them, so
a page added later is held to the same width without the test knowing
it. It now also runs every language at 420px besides en/zh-TW/de at
1920, zh/ja at 2560 and en at 900.

Run (mote, macOS 27, Playwright 1.62.0, Chromium and WebKit):
- page-width.test.cjs on origin/main 6f3dfc282's CSS: red, "masking:
  1676 wide at 1920" and "masking: 2316 wide at 2560" in every language,
  both engines (12 pass, 12 fail). With the fix: 24 of 24 pass.
- Together, with the fix: page-width, page-width-steady, i18n-keys,
  click-scroll and every mask*/masking*/redact*/window-mask/
  routing-masking/provider-mask/provider-unmasked/account-mask/
  plugin-name-unmasked file: 602 tests, 591 pass, 11 fail. The 11 are
  page-width-steady's "opening an agent's details past the window moves
  nothing sideways", which fail the same 11 with the file run alone on a
  clean origin/main 6f3dfc282 copy on mote (#4541, filed for Linux; a
  comment now says it is red on macOS too, in both engines).

Not run: the whole GUI suite and go test ./... (a CSS rule for one
page's padding; no Go, no JS, no shared class or breakpoint changed),
the real app on a maximised screen.
2026-11-01 11:57:54 +08:00
yetoneandFake Trader 0cabaaf243 agent: a portable VS Code on a Mac is wired in its code-portable-data folder (#4151)
faketrader runs VS Code portable on a Mac: /usr/local/bin/code links into
/Applications/Code/Visual Studio Code.app, and the build reads
/Applications/Code/code-portable-data/user-data/User. magpie detected it
but wrote ~/Library/Application Support/Code/User, which that build never
reads. Their patch on #4151 is the base; this takes its rule and makes it
VS Code's own (configurePortable in src/bootstrap-node.ts), on every OS:

- A build is portable when its product.json has no `target` (an
  installer's build has one) and its data folder exists: on a Mac
  product.json's `portable`, else `<applicationName>-portable-data`,
  beside the .app; on Windows and Linux `data` beside the install, also
  for a build that updates into `<install>/<version>/resources/app`.
- The build is the one the launcher on PATH is, through a Scoop shim and
  every symlink. A launcher whose product.json names another editor (a
  fork's `code`) isn't the build's. With no launcher of its own, a Mac
  reads the app folders and Spotlight and takes a portable bundle only
  when every bundle found is that one; beside an installed bundle, which
  one runs is unknown and nothing moves.
- VS Code, Insiders and VSCodium each go by their own bundle and launcher.
- User and extensions come from one place (vscodeDirs): connect, Sync,
  profiles and Disconnect use the portable User folder, and Zoo Code is
  found by its extension in <data>/extensions and writes its import file
  there. Windows' Zoo Code under Scoop looked in ~/.vscode/extensions.
- Disconnect's preview is refused for a file in a portable data folder:
  the preview's child keeps PATH, and its launcher would reach the build's
  real files, not the copy. That also covers Scoop under home on Windows,
  which main previewed.
- An installed build with no portable folder keeps the OS's folder and
  ~/.vscode/extensions, unchanged.

#3260 and #4009 (Windows): 509d8e7d1 (ggbdpq) already moved Scoop's
`current\data`; this adds the target check, the versioned layout, the
Windows Zoo Code folder and the preview refusal above.

Tests (fixtures under t.TempDir, never /Applications or ~/Library; app
folders and Spotlight stubbed): TestVSCodeMacPortableDirs (stable,
Insiders, product's `portable`, no data folder, Windows' `data` name,
another editor, another channel's folder, unreadable product, installer
target), TestVSCodeMacPortableLinkChain (three links, folders with
spaces), TestVSCodeMacPortableWiring, TestVSCodeMacPortableWithoutLauncher,
TestVSCodeMacPortableLauncherPicks, TestVSCodeMacPortableForkLauncher,
TestVSCodePortableProduct (Windows/Linux: target, fork product, versioned
install, Zoo Code, Scoop preview).

Broken by hand, each went red and was restored: main's rule on darwin
(6 Mac tests FAIL, standard folder used), target ignored (Dirs, Product),
no preview refusal (Wiring, Product), first bundle wins
(WithoutLauncher), fork launcher decides (ForkLauncher), Zoo Code on
home's extensions (3 FAIL). On origin/main the new tests don't compile
(vscodeDirs is new); break #1 is main's Mac behaviour.

Run:
- mote (macOS 27), full suite at this change on 479476784:
  go test -tags nogui -timeout 45m -count=1 ./... : 85 packages ok
  (internal/agent 405s, gateway 832s, provider 251s), internal/gui red on
  two filed tests this change doesn't reach: TestSettingsSaveKeepsWhat-
  ItDoesNotSend (SearchAll, #4514) and TestColdTurnsTaken (#4510).
  Rebased onto 90c02326b (gui takeover, sessions save, kiro min; nothing
  in internal/agent): go build, go vet of agent/gui/sessions/provider and
  go test of internal/agent, internal/sessions, internal/provider again
  at the pushed head: ok (agent 352s, sessions 110s, provider 228s).
- mote (macOS 27): go test -tags nogui ./internal/agent -run
  'TestVSCode|TestZooCode' ok; gofmt -l clean; go vet ./...,
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., GOOS=linux
  go build -tags nogui, GOOS=windows go build ok.
- win-run (Windows 11) and wsl-run (Ubuntu 24.04): the agent tests above
  plus Preview, ok.
- Real use on mote, sandbox HOME, PATH=$SB/bin:/usr/bin:/bin: VS Code
  1.144.0 darwin-arm64 from update.code.visualstudio.com unpacked to
  "$SB/Apps With Space/Code/Visual Studio Code.app", `code` linked
  bin/code -> "link one/code" -> the bundle's bin/code. Without
  code-portable-data, `magpie agents` lists ~/Library/Application
  Support/Code/User/settings.json; with it, ".../code-portable-data/
  user-data/User/settings.json". The real `code --install-extension
  zoocodeorganization.zoo-code` put Zoo Code 3.94.0 in
  code-portable-data/extensions (no ~/.vscode made), and magpie then
  listed Zoo Code at the portable User folder. `magpie vscode
  deepseek/deepseek-chat` wrote settings.json and chatLanguageModels.json
  there, `magpie vscode default` took magpie out of both, and Zoo Code's
  connect wrote its import file under the portable globalStorage and its
  disconnect removed the setting; ~/Library/Application Support/Code was
  never made.
- Real use on xiaomi-gpu (Windows 11), sandbox USERPROFILE/APPDATA,
  PATH=<install>\bin;System32: VS Code's win32-x64 ZIP (its versioned
  layout, <install>\2c33b50b16\resources\app) unpacked to "Apps With
  Space\VSCode". Without data, `magpie agents` lists ~\AppData\Roaming\
  Code\User\settings.json; with data, <install>\data\user-data\User\
  settings.json. The real code.cmd --install-extension put Zoo Code in
  data\extensions (no ~\.vscode), magpie then listed Zoo Code there,
  and connect/disconnect wrote and cleaned that User folder; %APPDATA%\Code
  was never made.

Not tried / not handled: VS Code's window wasn't opened to see the model
picker (headless ssh). VSCODE_PORTABLE isn't read: it is the editor's
environment, not magpie's. A Windows or Linux portable build with no
launcher on PATH isn't found (there is no standard place to look). A group
an older magpie wrote in the OS's folder for a portable build stays there;
connecting again writes the portable one. A Claude Code or Codex extension
in a portable build doesn't keep that CLI from showing as gone: #4672.

Co-authored-by: Fake Trader <9635792+faketrader@users.noreply.github.com>
2026-11-01 11:55:33 +08:00
yetone 6d23a4282f provider: whether a model sees images doesn't wait for usage readings; start ~9 s → <3 s
magpie's gateway listened ~9 s after start. A goroutine dump 3 s in had
main in provider.Allowances' first-ask wait: the start's migrations
(agent.RenameLegacy) read Pi's effort field, which builds Pi's model list,
which asks provider.Described (does any model see images), which ranks
the vision models by spent accounts, which asks each agent's allowances.
Each agent's first ask waits firstWait (3 s) for its accounts' usage over
the network. Every agent's model list asks Described, so the GUI's first
lists waited the same way.

Described only asks whether a model is there, not which account a request
goes to, so it now runs under provider.Unwaited: Allowances answers from
what is last known (the readings kept on disk) and starts the reading
behind it, as after firstWait. A request routed by the gateway still waits
as before.

Real history in a sandbox HOME (17,140 session files, every account
copied from this Mac's), the network blocked by a dead proxy, `magpie web`
started twice each:
- before (v0.1.2528 tree): gateway up at 9.8 s and 8.8 s.
- this change: 2.8 s and 0.6 s; first /api/sessions answered at 4.5 s and
  2.1 s, against 12.2 s and 10.7 s.

Tests, on mote: TestUnwaitedAllowancesDontWait is new. Broken by hand
(Allowances waiting under Unwaited too) it fails: "took 20.0s".
go test ./internal/provider/ ./internal/gateway/ ./internal/agent/ ok
(gateway 740 s). gofmt -l clean; go vet (darwin), GOOS=windows go vet,
GOOS=linux go vet -tags nogui of provider and gateway ok.

Not run: the full suite; a start with the network up (the wait there
was the vendor's answer time, up to 3 s an agent); Windows and Linux.

Picked onto 2be5d206e (origin/main at push); not run again there.
2026-11-01 11:53:58 +08:00
yetone 2be5d206e1 gateway: a Codex summary request too large for the vendor is asked again as text, then compacted locally (celestial_eagle_99230 on Discord)
celestial_eagle_99230 (Discord #general, v0.1.2403) runs Codex on official
DeepSeek (DeepSeek-V4.1-Flash, 1M window) and gets "413 Request Entity Too
Large: Failed to buffer the request body: length limit exceeded". The turn
path was fixed by 2cca11176 (v0.1.2419): Codex gets context_length_exceeded
and compacts. But the compaction is the problem. Codex (openai/codex main,
compact_remote_v2.rs) sends its summary request through the same /responses
route, trims only by its token estimate against the catalog's 1M window, and
on ContextWindowExceeded does not trim and retry. A conversation that is
over DeepSeek's byte cap (base64 images and long tool outputs sent each
turn) is under 1M tokens, so the summary request was the same oversize
body. magpie passed the 413 (or overflow) back, compaction failed each
time, compactFails held later tries, and the session could neither compact
nor go on.

codexCompact now counts a 413 or an overflow on the summary request
(summaryTooLarge) with the failures it already asks again as text
(plainCompact: images left out, tool outputs over 4000 chars cut, at most
400K chars), then compacts without a model (localSummary) when that is
refused too. This is keyed on the status and overflow words, not on
DeepSeek: a summary request refused for its size means the same thing for
every vendor, and the old result (a session stuck) is never better. Any
other refusal goes back unchanged (TestCodexCompactOtherRefusalStays,
TestCodexCompactOtherFailuresStay), and a non-Codex client still gets the
413 as request_too_large (TestDeepSeekByteCapTurn's opencode case,
TestByteCapBeforeStreamStaysStatusForOthers).

DeepSeek probed without a key (no tokens): bodies of 1 to 40MB to
api.deepseek.com/chat/completions get 401 "Authentication Fails"; 80MB and
120MB get openresty's text/html 413 page. The reporter's text is axum's
body-limit error, which sits behind auth, so its value is unknown. DeepSeek's
docs list no 413 and no byte limit.

Run, mote (mote-run):
- Red at origin/main fb3942ee6 with only the new test file:
  TestCodexCompactTooLargeAsksSmaller (all 4: Chat/Responses x byte
  cap/overflow) got 413 "compaction: ... answered the summary request 413"
  or 400 context_length_exceeded; TestCodexCompactTooLargeCompactsLocally
  got 413. TestDeepSeekByteCapTurn passed (2cca11176's turn path).
- Green with the fix; broken by hand (summaryTooLarge returning false):
  all 4 AsksSmaller subtests and CompactsLocally red again.
- At the pushed head (rebased on 90c02326b): go test -count=1 -run
  'Codex|Compact|Overflow|ByteCap|TooLarge|DeepSeek|StreamError'
  ./internal/gateway ok (90s). go vet ./internal/gateway on darwin,
  GOOS=linux -tags nogui and GOOS=windows ok. gofmt -l clean.

Not tried: the whole internal/gateway package and ./... (mote was running
another session's 45m multi-package suite at load ~210, and one suite runs
at a time); a real Codex binary end to end (its compaction was read from
source); a real signed-in DeepSeek request (the cap's value is unknown).
2026-11-01 11:52:46 +08:00
yetone 90c02326bb gui: an app takes the gateway over from its older copy once idle, and says any other version serving it (matrix0487)
matrix0487 on Discord: after an update, pi said 404 'magpie knows no
model "kimi/k3.1-pro" ... add a provider in magpie first'. The app had
written pi a model its older gateway didn't know, and updating the
gateway fixed it. A magpie that finds another one serving the gateway
used to log it and wait for that one to quit (watchGateway took the
port only once nothing answered). Only the Gateway page said so.

Now (otherServes, gateway_older.go):
- An older released copy of the app (it says serves app or tray, and a
  pid) is this app's predecessor. Once its /v1/magpie/concurrency says
  nothing is in flight (gateway.ServedBusy; unknown is never idle),
  the app quits it the way the Gateway page's button does
  (quitMagpieOnPort: a magpie only, by its program) and serves the
  gateway. A stream through it runs to its end first. watchGateway
  looks again every 15s while another serves. At most three times a
  run; a quit that fails is left to the button.
- Any other one (magpie serve or the service, magpie web, a TUI, a
  newer magpie, a build of its own) is left running. /api/state
  carries it as gatewayOther, and the Agents page says it above the
  list with what to do, plus the take-over button for an older one
  (gatewaySkewLine, in plugins/gateway/client.js so app.js stays under
  its budget). A dev build of this magpie says nothing. New strings in
  zh, zh-TW, ja and de.

How the reporter's older gateway outlived the update isn't known: they
never said whether one ran separately. A failed handover leaves the
old app serving for up to 15m, and a magpie serve left running is
another source. Both are covered now: the first is replaced, and the
second is said.

Known gap: a request that starts between the idle read and the quit
gets the older app's short drain. A socket handover between two
running apps (no gap) is not built.

Run on mote at 0f8ea30bb (this change on 2b067434d):
- go vet for internal/gui and internal/gateway, also GOOS=linux
  -tags nogui and GOOS=windows; gofmt -l clean.
- go test -count=1 -timeout 45m ./internal/gui ./internal/gateway:
  gateway ok. gui has two reds, the same on origin/main 0c3163804:
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestMainWindowCorners/macOS_26_SDK (#3949).
- GUI subset, Chromium and WebKit: gateway-*, agent-layout, agents-*,
  getting-started, i18n-keys, gui-ja/de/zh, panel-arrange, panel-fold:
  411 pass. Two reds, the same on origin/main 0c3163804:
  gateway-caller-keys chromium en (#3797) and gui-ja (#4580). Passing: the new gateway-skew.test.cjs (en and zh at 380px, the
  button POSTs take-over and the line goes).
- Real app on mote, sandbox HOMEs, port 3591, update feed pointed
  nowhere:
  - origin/main built as 0.1.2400 ran `magpie app`, and this head
    built as 0.1.2500 ran `magpie app` beside it. The new one logged
    "an older copy of this app ... with nothing in flight; quitting
    it" and served 0.1.2500 on the port 2s later. The old process was
    gone.
  - The same with the old one as `magpie serve`: it was left running,
    and the new one logged that it serves, older.

Red on origin/main: TestAppReplacesItsOlderGatewayOnceIdle ("the
older copy of the app still serves the gateway", 17s).

Again at the pushed head (this change on 6f3dfc282, mote): vet darwin, linux
nogui and windows; TestCoreScriptBudget (the core is 1,533,104 of
1,533,105: main's #4652 took the room, so app.js's hook line lost its
comment, no raise), TestAppReplacesItsOlderGatewayOnceIdle,
TestGatewaySkew*, TestGatewayFixQuitsOnlyAMagpie,
TestGatewayServedByAnOlderMagpie: ok. gateway-skew, i18n-keys, gui-zh,
gui-de: 11 of 11 pass.

Broken by hand, each red:
- quit without waiting for idle: "quit with a request in flight"
- replaceable() false: "still serves the gateway"
- any serves replaceable: TestGatewaySkewOfAnotherIsSaidNotQuit, the
  serve holder quit
- the Agents hook removed: gateway-skew.test.cjs red in both langs

Not tried: the whole GUI suite (mote was running another session's
full suite), a real app with a real agent stream in flight during the
take-over (the Go test holds a stream through a fake), Windows and
Linux apps (the replace path needs handoverHost, set by the app's Run
on every OS, but it was tried on macOS only).
2026-11-01 11:43:56 +08:00
yetone 6f3dfc282f sessions: a scan's index is written at its end and on SIGTERM, not a minute later
A refresh's saves waited out saveGap (1 min) after the last one written,
the scan's checkpoints and its end too: the first checkpoint was written,
the rest waited. A magpie ended in that minute (quit, updated, `web` or
`serve` stopped by SIGTERM, whose handler died without sessions.Saved())
kept a few hundred of the files it read, and the next start read every
rollout again.

- A refresh that reads scanFiles (32) files or more is a scan: its
  checkpoints wait scanSaveGap (15 s) and its last save waits for nothing.
  A poll's few changed files still wait out saveGap. Saves folded into one
  take the shortest gap asked, and a shorter one wakes a waiting save.
- The signal handler writes the index before dying, bounded by
  saveOnSignal (5 s).

Real history in a sandbox HOME (11,994 Codex rollouts, 52.5 GB, plus
Claude projects; 17,140 files), index removed, `magpie web` killed by
SIGTERM ~44 s in (right after the first /api/sessions answered):
- v0.1.2521 tree: 1,200 entries kept (1,415 on a second try). Restart:
  /api/sessions 23.63 s, 1:38 of CPU.
- this change: 17,140 kept. Restart: /api/sessions 1.30 s, 3.4 s of CPU.

Tests, on mote: TestScanSavedWithoutTheGap and
TestSignalSavesTheSessionIndex are new. Broken by hand: with the scan's
gaps left at saveGap the first fails ("a scan's last save waited out
saveGap"); with the save call taken out of the handler the second fails
("died without the session index saved"). go test ./internal/sessions/
./internal/cli/ ok. gofmt -l clean; go vet (darwin), GOOS=windows go vet,
GOOS=linux go vet -tags nogui of both packages ok.

Not run: the full suite; the GUI app's own quit and update paths (they
return to main, which already called Saved); Windows and Linux runs.

Picked onto 0c3163804 (origin/main at push); not run again there.
2026-11-01 11:34:13 +08:00
yetone 0c31638045 kiro: the mover installs 0.1.24, which says a too-long conversation as one
ergou0954_54426 on Discord routes by intent across Kiro's Claude and GPT
models and DeepSeek, and sometimes a turn failed with Kiro saying the
context was exceeded. Kiro says a conversation is past the model's window
in three ways, and the plugin up to 0.1.23 turned only the HTTP 400 into
the "input is too long for the model's context" that the gateway reads as
an overflow (tooLong). The same ValidationException as an exception in
Kiro's event stream came out as a 502, so the gateway took it for a
passing vendor fault: it rested the account, asked Kiro again (15 asks
for a lone provider in a probe), and never told the agent
context_length_exceeded, so the agent never compacted. A reply Kiro
stopped with MODEL_CONTEXT_WINDOW_EXCEEDED came out as finished.
plugins e8050e8 (kiro 0.1.24, on npm) answers both as the 400 that says
too long. Routing was already right: roomy skips a member whose known
window the request is past, and withRoom moves an overflow to a member
with room.

The min goes to 0.1.24 so keepMovedCurrent updates every moved user.
TestKiroMoverHasTheTooLongFix holds it there.
TestKiroPluginOverflowGoesToAMemberWithRoom pins what the gateway does with
0.1.24's two wordings: in a group the other member answers, the try is
failOverflow with no rest, and alone the agent gets context_length_exceeded
after a single ask.

Run on mote: go vet ./internal/provider ./internal/gateway; go test
-timeout 45m -count=1 ./internal/provider (ok 150s) ./internal/gateway
(ok 712s). gofmt -l clean. Broken by hand: at origin/main's min 0.1.23,
TestKiroMoverHasTheTooLongFix fails. A probe with 0.1.23's 502 body
showed Fail other, a rest, and a vendor 502 for the lone provider.
Not run: the full ./... suite (another session's full suite held mote),
and a real Kiro account pushed past its window.
2026-11-01 11:30:12 +08:00
yetone 4794767846 routing: back on Routing from another page, the page isn't laid out and drawn again whole (#4652)
xisdumpling (dumplings04605 on Discord), Windows, 0.1.2507: with a
history day of 180 to 298 requests picked, coming back to Routing
stalls the page and the sidebar's highlight. Measured first, with
routing-return-cost.test.cjs (250 rows, a picked day, a request's story
open), which counts what the return does, not how long it takes.

Causes found, each fixed and each red by hand when put back:
- The request list was windowed only from 300 rows, so a day of 180 to
  298 had every row in the page. Now from 100 (WIN_MIN); the live list
  keeps 60, so it is never windowed.
- Out of sight a view is 0 wide. The ResizeObservers in the routing
  client (byWidth, the meta width) and context.js's card sizes took that
  as narrow, flipped the narrow layouts while away and flipped them back
  on return. A 0 width now keeps the layout it had.
- A hidden list re-windowed itself for a 0-high view, so the return
  placed rows and ran metaFit again. It keeps its window while hidden.
- resume rebuilt the whole stage on return. sync("back") rebuilds only
  when what the stage was built from (route, pin, day, purpose, lang,
  the requests and their accounts) changed, and records it after the
  rebuild.
- The visibility observer's group reload was not quiet and redrew the
  groups. It is quiet now.
- A providers refresh while on Routing redrew the hidden Providers page.
  It is read and drawn when Providers opens (providersBehind).
Not a cause: the nav highlight's rAF reading offsetTop only waited on
the busy main thread; it is one small layout now.

Before and after, the "back on Routing" step (Chromium layout metrics
from CDP; class flips and redraws from MutationObservers, both engines):
- mote, macOS: 25 layouts / 34.9ms of layout, 24 class flips, Providers
  redrawn 13 nodes, groups 4, stage kept 0 of 3, 250 rows, 7818 nodes
  -> 9 layouts / 3.2ms, 0 flips, 0, 0, 3 of 3, 11 rows, 1367 nodes.
- Windows (xiaomi-gpu, win-run): 25 layouts / 146.4ms, 24 flips
  -> 9 layouts / 7.1ms, every check passes. WebKit's counts match.
The test asserts no flips, no redraws, the stage kept, under half the
rows in the page and at most 12 layouts; wall time is logged, not
judged. The page looks the same: no CSS or markup change.

Run:
- routing-return-cost: red on origin/main 8ac1c7a56 in both engines,
  green with this on mote and on Windows (win-run), both engines.
- Broken by hand, each red: the byWidth 0 guard, the meta width guard,
  the hidden drawList return, sync("back"), the quiet group reload, the
  Providers deferral, WIN_MIN back at 300, and context.js's cardSizes
  guard (seen through the ctx-card).
- go test ./internal/gui -run Budget on mote: ok, no budget raised.
  Rebased on 2b067434d the core was 278 bytes over its 1,533,105; this
  change's comments and renderProviders' scroll comment were cut to
  1,533,072, app.js 1,311,935 of 1,316,874.
- All 142 routing*.test.cjs files on mote, both engines, every
  language, concurrency 3, at load 40 to 70 from other sessions: 2052
  tests, 29 red in 9 files. Each of those files run serially at origin/main
  and with this shows the same reds (rule-drag, rule-remove, row-swap,
  order-unknown: #3789, #3096, #3094, #3799, #4585, #4494), and so do
  steady, steps-cap and story-shrinks (#3412, #4585); rules-line's
  webkit de 1100 went red once with this only (#4585, #4560).
- purpose-filter (108 rows, windowed now): 14 of 14.
Not run: the whole GUI suite. mote had another session's full suite and
several more runs at load 60 to 75 the whole time; it runs after the
push and its result goes on #4652.
Not tried: the real Windows app; only Playwright on the Windows box.
2026-11-01 11:24:02 +08:00
hlyx1 2b067434d7 provider: a Kimi Code membership's k3.1-pro and k3.1-pro-highspeed are priced at the Kimi API's (#4635)
hlyx1's fix (#4635, branch hlyx1/magpie kimi-code-k31-pro-price), asked
to be expedited by matrix0487 on Discord. Kimi Code's plans serve
k3.1-pro and k3.1-pro-highspeed, which models.dev's kimi-code-plan-*
catalogs list at the membership's $0. Neither id was in kimiCodeAPI, so
a membership's call on either was unpriced on Usage. They now map to
kimi-k3.1-pro and kimi-k3.1-pro-highspeed, like k3 to kimi-k3, and the
Requests list names that model (PricedNameFor).

Checked: Kimi Code's own /models answer (internal/catalog/testdata/
kimi-code-cn-models-2026-10-31.json) lists k3.1-pro "K3.1 Pro" and
k3.1-pro-highspeed "K3.1 Pro Highspeed". Kimi's pricing page
(platform.kimi.ai/docs/pricing/chat, read 2026-11-01) and models.dev's
live moonshotai entry both give kimi-k3.1-pro $2 in / $10 out / $0.20
cached / $2 5m write, and kimi-k3.1-pro-highspeed $4 / $20 / $0.20 / $4.
The fixture's new entries match models.dev's api.json in id, name, cost
and canonical_model_id.

The alias stays Kimi Code's (kimiCodePlans): the test's relay catalog
now lists a k3.1-pro of its own at $0.50/$1, which keeps that price, and
PricedNameFor(relay, k3.1-pro) stays k3.1-pro.

Docs: docs/reference.md, docs/subsystems/providers-accounts.md.

Run on mote (Go 1.26.8), at this change rebased on fb3942ee6 (the
pushed head adds only 784b66366, app.js and a GUI test): gofmt -l
clean; go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
go vet ./... ok; go test -count=1 -timeout 45m for internal/provider,
usage, gateway, agent, cli, routes, sessions, usageapi: all ok.
TestKimiCodeListPrice and TestKimiCodeCost red with models.go at
origin/main (k3.1-pro {0 0 0 0} false; kimi-code-cn/k3.1-pro
priced=false cost=0, want true 3.264), green with it. Taking the
kimiCodeMember() check out by hand turns PricedNameFor(relay, k3.1-pro)
into kimi-k3.1-pro and the test red.
Full go test ./... at base da0005df8: every package ok but internal/gui,
red on TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
TestMainWindowCorners/macOS_26_SDK (#3949), both open on main and not
touched here.
Not tried: a real Kimi Code membership's k3.1-pro call through the GUI.
2026-11-01 11:19:26 +08:00
yetone 784b66366f gui: Settings opens after Codex's row on the Agents page was opened and shut (ysm119)
ysm119 on Discord (v0.1.2519, macOS): opening Settings showed
"null is not an object (evaluating '$(row + ".who").title = t(en)')".

Cause: an opened agent row borrows its settings rows (AGENT_PREFS,
f1e4516da) from #agentPrefRows. Shutting the row, or any redraw that
leaves no row open, drew the list again with replaceChildren(), and
the borrowed rows went out of the page with the old row. Nothing put
them back until something called homeAgentPrefRows, so renderSettings'
tooltip loop found no #codexTitlesRow, and translateStatic (a language
change) missed their text too.

Fix: renderAgents and renderAgentsLoading put the rows home right after
clearing the list, so they are never out of the page; a row opened
again takes them as before. Codex's rows' tooltips are set in
renderAgentPrefs, which homes them first and owns them; Settings sets
only Open at login's. Siblings checked: every other reader of these
rows (renderAgentPrefs, renderAgentPrefLinks, renderCodexMemories,
renderCodexSubagentModel, agentPrefsButton, connectPanel,
openAgentPrefs and its MutationObserver) already homes first.

Test: agent-prefs.test.cjs "Settings opens after Codex's row was opened
and shut", Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and 440: open
Codex's row, shut it, the rows are in the page, Settings opens from its
button with no error and the titles row's tooltip in the language.

Run (mote):
- On origin/main da0005df8 without the fix: 20/20 red, "codexAgentsV1Row
  in the page once shut"; with that check off, WebKit fails with the
  reporter's exact text and Chromium with "Cannot set properties of
  null (setting 'title')".
- Broken by hand (renderAgents' homing taken out): red again, same
  message, both engines.
- Before rebase, 89 files (agent-*, codex-*, settings-*, i18n-keys,
  gui-de/ja/zh-tw, menu-scroll, text-size), concurrency 4: 1465 tests,
  1432 pass, 33 fail: agent-panel-name-width's 32 (red on pristine
  origin/main f435aadbf too, 0/32; #4203, commented) and gui-ja's
  ja-has-every-zh-string (red on main, #4580).
- At the pushed head (rebased on fb3942ee6): agent-prefs, codex-titles,
  codex-memories-settings, settings-general, settings-search,
  i18n-keys, gui-zh-tw/de/ja: 125 tests, 124 pass, 1 fail (#4580).
  go test -run TestCoreScriptBudget ./internal/gui: ok (app.js
  1,311,806, core 1,532,895, no budget raised; comments kept short).

Not run: the whole GUI suite and go test ./... (JS-only change;
another session's full GUI suite was on mote); the real app.
2026-11-01 11:14:22 +08:00
yetone fb3942ee67 windows: the app's icon fills its square in the taskbar, the tray and Start (dzxx0496)
On Windows 10 magpie's icon looked a size smaller than its neighbours
in the taskbar, the tray overflow and Start's "Recently added"
(dzxx0496 on Discord, #general). Every Windows icon was the Mac's tile:
build/windows/icon-*.png (75cb19264, the exe's icon group #3, which
the window, the taskbar and the Start shortcut's IconLocation exe,0
all use) and internal/gui/icon.png (the tray) were build/icon/gen.go's
app(), on macOS's grid, the tile 80% of the canvas with 10% clear on
each side. Windows draws an app to the edges of its square.

- gen.go: app() and the new win() share tile(). win() is the same
  white tile, shading and bird (.8 of the tile), a 32nd of the side
  clear from 32px up (1px at 32 and 48, 8px at 256) so the rounded
  corners' soft edge stays inside, and to the edge under 32px, where
  that pixel would only blur it; corner radius .2 of the side (.225 on
  the Mac). No new colour.
- build/windows: icon-16 to icon-256 drawn by win(), plus 20, 24 and
  40 px, which Windows asks for at 125% to 250%; winres.json lists
  them.
- The tray takes internal/gui/icon-windows.ico (16, 20, 24, 32, 40,
  48, 64); Wails picks the SM_CXSMICON entry, where the 64px PNG was
  scaled down by the system. icon.png, only the tray's, is gone.
- Makefile's icons target draws all of these.

Not changed: macOS (app() is byte for byte the same at 64, 256 and
1024: cmp against the committed icon-256.png and icon-1024.png; the
.icns, Assets.car and tray.png untouched). Linux: its tray is the
glyph with no tile, and its desktop icon (icon-256.png) keeps the
margin GNOME's and the hicolor theme's app icons have too.

What was run:
- mote: go test ./internal/gui: TestWindowsIconsFillTheirSquare (new),
  TestTrayIconPerOS and TestTrayIconSize ok. Red, each filed and none
  about icons: TestSettingsSaveKeepsWhatItDoesNotSend (#4514, red 3 of
  3 at a fresh origin/main 733fac48f), TestMainWindowCorners/macOS_26_SDK
  (#3949, macOS 27) and TestColdTurnsTaken once in the package run,
  ok when run again (#4510). go vet ./..., GOOS=linux go vet -tags
  nogui ./..., GOOS=windows go vet ./..., go build and GOOS=windows
  go build: ok. gofmt -l prints nothing.
- Broken by hand: the old PNGs, winres.json and the old 64px picture
  as the tray's .ico: TestWindowsIconsFillTheirSquare red, "tile
  (25,25)-(231,231) in (0,0)-(256,256), want at least 15/16 of the
  side, centred" and the same for each size, "icon-windows.ico has no
  16px picture".
- make release-windows on mote at origin/main and at this change, both
  exes on the Windows 11 box (xiaomi-gpu). Its console was locked at
  the PIN screen, so no desktop screenshot: instead Windows itself
  drew each exe and a .lnk to it through IShellItemImageFactory (what
  Explorer, the taskbar and Start use) at 16/24/32/48/256, beside
  Docker Desktop, Claude, Explorer, Edge and Notepad, and the tray
  icon through CreateIconFromResourceEx at 16 to 40 as Wails makes it.
  Before: the tile 80% of the square, the tray blurred. After: the
  tile fills it as Docker's, Claude's and Edge's do; the tray is
  crisp at each size.

Not run: go test -tags nogui ./... (the change is internal/gui's
embeds, which nogui leaves out, and build/).
Not tried: Windows 10 itself, and the real taskbar, tray and Start
with the desktop unlocked. Windows keeps an exe's icon in its icon
cache by path, so a user may see the old one until the cache renews.
2026-11-01 11:02:56 +08:00
yetone 733fac48fb qwenpaw: each model says how its thinking is set, and the editor sets the level (Pkh)
Pkh (Discord, 0.1.2509 on Linux, QwenPaw 2.2.2.post1): QwenPaw's
thinking strength did nothing on magpie's models.

Cause, from QwenPaw 2.2.2.post1's own source:
- providers/provider.py thinking_control() takes a model's
  thinking_control, else its thinking_param_style; with neither it is
  ThinkingControl() of kind "unknown".
- providers/thinking.py resolve_thinking drops an unknown control to
  inherit, so agent.json's thinking_level was never sent.
- magpie wrote neither key in magpie.json's models, so every magpie
  model was "unknown".

Change:
- qwenpawModelJSON writes thinking_param_style "effort" and
  reasoning_effort_options for a model whose catalog efforts include
  levels QwenPaw names (minimal, low, medium, high, xhigh, max), in
  QwenPaw's order. "none" is left out: QwenPaw's off sends
  enable_thinking / thinking extra_body, which the gateway strips for
  some upstreams.
- Both keys are magpie-owned. A model whose efforts go away has them
  taken back. A null magpie writes where it never wrote is dropped,
  so a user's own config_overrides are kept.
- The QwenPaw agent editor gets an effort field over agent.json's
  thinking_level. "" writes inherit. Setting a level drops
  thinking_budget, which QwenPaw's validator requires. A budget or
  off level the user set is shown and kept.
- Docs: agent-wiring.md and reference.md.

Run:
- gofmt -l: clean.
- go vet darwin, windows, and linux (-tags nogui): clean (mote).
- go test -timeout 45m ./internal/agent/...: ok (mote).
- go test ./internal/gui: 3 reds, also red on origin/main 8ac1c7a56
  and already filed (#4514, #3949, #4510).
- Real QwenPaw 2.2.2.post1 in a sandbox HOME, in WSL magpie-desktop:
  - Loaded magpie's generated magpie.json and agent.json with
    QwenPaw's own ProviderManager and AgentProfileConfig.
  - kimi/k2 resolves to {kind: effort, efforts: [low, medium, high,
    max]}.
  - A real request to a local capture server carries
    reasoning_effort "high" at level high, and none at inherit.
  - The old file's model resolves to kind unknown, and sends nothing
    at any level.

Broken by hand:
- With the origin qwenpaw.go, both new tests are red.
- Without the thinking_budget delete, TestQwenPawEffortField is red.
- Without the new owned keys, the take-back assertion is red.

Not tried:
- QwenPaw's full app UI against a running magpie gateway.
2026-11-01 10:54:38 +08:00
yetone f435aadbf3 gateway: an image is described once, whatever model describes it, and a canceled request stops its descriptions
Pkh on Discord (0.1.2509, Linux, QwenPaw, Auto routing): with images in
the conversation, the Routing view filled with "Image description" rows,
one request asking for 63 in ~60ms, and the request they were for had no
row of its own.

Causes, each red on origin/main b2145eac1 (the new tests run there):
- A description was kept under the describing model and its level
  (sha256(model, effort, src)): AutoVision's pick changing between turns
  (opencode-go/deepseek-v4.1-flash, auto/qwen3.8-flash) read every image
  again. It is now kept under sightKey: a base64 data URL's decoded bytes
  (strict base64), else the URL, with the level picked in Settings, so
  the same picture on another protocol or media type is described once
  too, and seenBody dedupes by the key.
- describe ran on the first asker's context. Its agent canceling it failed
  the description for every request waiting on it ("context canceled",
  a 502 to a request nobody canceled) and took it out of the cache. The
  work now runs on its own context (WithoutCancel + cancel); a request
  that goes stops waiting, and only the last to go stops it and forgets
  it. A reply that came whole is kept though its asker ended.
- seenBody's queued images took a slot without looking at the context,
  so after a cancel each went on to serve with a dead context and put an
  instant 499 row on the Routing page. One waiting for a slot when its
  request ends is now asked of no one.
- The descriptions' routes are noted on the request's inflight (they run
  on its context), which dropped its "routing" placeholder; a cancel
  then left it no route at all. It now gets one (notDescribed), 499 when
  its agent canceled and 502 else, and the usage record names it. A
  group's request ends 499 on a cancel too.

Not as reported: a failure never threw away good descriptions (only the
failed one went), and seenBody already deduped and shared in-flight work
within the cache; it was the cancel, the model in the key, and the
queued work that made it read everything again.

Run on mote at this tree (rebased on da0005df8):
- gofmt -l internal: clean. go vet ./... on darwin, and GOOS=linux /
  GOOS=windows -tags nogui go vet ./...: ok.
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway: ok
  (806s); also ok on the earlier bases 8ac1c7a56 (with ./internal/catalog)
  and ccb75030a.
- -race -count=10 on the four new tests, TestUnrouted* and
  TestTextOnlyModelIsGivenTheImagesDescription: ok.

Broken by hand, each red with the named test:
- the model back in the key, and the key by src string:
  TestSameImageDescribedOnceWhateverDescribesIt;
- the work on the first asker's context:
  TestOneRequestGoneLeavesTheDescriptionToAnother (502 context canceled);
- the slot taken without the context: TestCanceledRequestAsksNoMoreDescriptions
  (9 rows, want 4); on origin/main 10;
- no notDescribed: TestCanceledWhileDescribingKeepsItsRoute (no route).

Not tried: Pkh's own QwenPaw conversation and providers; the fix is
tested with a fake describer only. heldSight (unrouted_test.go) now seeds
the cache under sightKey.
2026-11-01 10:50:31 +08:00
yetone da0005df81 agent: /api/state lists running agents once in 3s, not with a pgrep each call
/api/state asks StaleCopies for every wired agent, and each pattern
started `pgrep -lf`, which walks every process's arguments. On a Mac
with ~1000 processes that was most of a state call: 45ms each, on every
page switch, save and GUI poll, with a pgrep child seen in 25 of 40
samples.

StaleCopies now reads runningLately: a pattern's listing is kept for
3s, with each process's start (not its age), so an age read later is
still right. A fresh listing (a restart waiting for its app to end)
replaces what was kept, so the look that finds the app gone is what the
next poll sees. A test that fakes running is asked each time. The
waits in apprestart still list now.

Run (mote, this tree):
- go vet ./internal/agent ./internal/gui; GOOS=linux and GOOS=windows
  go vet ./internal/agent: ok.
- TestRunningListedOnceInAWhile, TestRunningNeedsNoPs: ok.
  Broken by hand (every call lists): red, "listed 6 times in a row,
  want 1".
- go test ./internal/agent ./internal/provider: ok. ./internal/gui:
  only TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestMainWindowCorners/macOS_26_SDK (#3949), both red on main too.

Real accounts (sandbox HOME from a copy of the live accounts, on this
Mac with its real Codex app, daemons and CLI running):
- /api/state, 10 calls after 200: v0.1.2519 43-60ms, this 8.4-21ms
  (twice each, alternating). pgrep children in 40 samples: 26 and 24
  before, 1 and 1 after.
- Each wired agent's stale copies (Codex: app, two daemons, cli, each
  with its start) are the same from both binaries, read twice 4s apart.

Not run: the full ./... suite; Linux and Windows runs of the agent
package (vet only).

Picked onto 9be72c948 (origin/main at push); not run again there.
2026-11-01 10:32:21 +08:00
yetone 9be72c9480 zcode: a level's thinking carries its budget, and the user's own level options stay (#3852)
Review of d7e1e284f, two things it changed beyond its case:

- Every level that thinks was written as {"thinking":{"type":"enabled"}}
  with no budget_tokens. ZCode puts a level's options in the request, so
  a Claude before 4.6 (Sonnet 4.5, Haiku 4.5, a relay's) asked through
  magpie at any level would be sent "enabled" without the budget
  Anthropic's Messages API requires with it, a 400 it didn't get before.
  Each level now carries the budget the gateway reads that effort as
  (gateway.ThinkingBudget, budgetOf: low 4096 ... max 32000). The
  gateway already makes it adaptive for Claude 4.6 and later
  (adaptiveThinking; ZCode's output_config.effort wins over the budget)
  and fits it under max_tokens (maxoutput.go).
- providerOptionsByLevel was written over on every sync. A user who put
  their own there (the workaround for this very bug) lost it. A level's
  options already in config.json now stay; no magpie before #3852
  wrote any, so whatever is there is the user's.

Tests: TestZCodeOutputAndReasoning expects the budgets;
TestZCodeKeepsTheUsersLevelOptions keeps a hand-written high level and
fills the others.

Run on mote: go test -run TestZCode ./internal/agent, ok. Broken by
hand: the kept options ignored and the budget left out, and those two
tests fail.
Not tried: a real ZCode 3.x (this Mac has Z Code 0.9.1, a different
app; mote has none), so ZCode putting the options in the body is the
reporter's and the author's reading of zcode.cjs, not seen here.

Batch record (gua's #2833 #3052 #3205 #3867 #4107 #4247 #4245 #4113
#3852 and the three review follow-ups; #4106 left out, its test isn't
red without its fix, see the issue):
- Full run on mote before the rebase (base fa4704f06): gofmt -l clean;
  go vet on darwin, GOOS=linux -tags nogui and GOOS=windows clean;
  go test -count=1 -timeout 45m ./...: 85 packages ok, internal/gui red
  in TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestMainWindowCorners/macOS_26_SDK (#3949), both already filed, and
  neither in a file this batch touches.
- Rebased on origin/main 9162277b9, at this tree, on mote: gofmt clean;
  go test -count=1 -timeout 45m ./internal/gateway/... ./internal/agent
  ./internal/library ./internal/handoff ./internal/routes, all ok
  (and ./internal/redact ok at the base before, b2145eac1). Then
  rebased again on ccb75030a (#4371, fastjson.go only) and
  ./internal/gateway/... run again at that tree: ok (636s). Pushed on 8ac1c7a56 (internal/catalog
  only), where catalog, handoff and library ran whole and the batch's
  gateway (Bili, TestRuleCompact, Kimi, TestClaudeMem, the two stall
  tests) and agent (TestZCode) tests ran: all ok. The whole gateway
  package was not run again on top of 8ac1c7a56.
- Windows (win-run): -run TestClaudeMem ./internal/gateway ok; with
  claude_room.go put back, TestClaudeMemRunsFromTheCgroup hangs in
  readLimit to the 5m timeout.
- Linux (wsl-run): ./internal/handoff ./internal/library ok; with the
  fixes put back, TestGiveKeepsTheListenerNonblocking,
  TestSaveDropsEmptyApplied and TestSyncAloneLeavesNoEmptyApplied fail.
Not tried: real Kimi, ZCode 3.x, Alma or bili accounts; #4245 is a
test-only change and was not reproduced red.
2026-11-01 10:26:42 +08:00
yetone 15ffd3b681 gateway: a compaction rule sees Alma's first compaction too (#2833)
Review of e72e97ef9: it knew Alma's compaction only by the ask of a
later one, "Merge the previous summary with the new conversation.".
Alma 0.4.335 (its app.asar, read on this Mac) has two: the first
compaction asks "Here is the full conversation to compact." under the
system prompt "You are compacting a long conversation so it can
continue WITHOUT losing context.", and a merge sends "You are UPDATING
an existing conversation summary ..." as its system prompt. The ask and
both system prompts are now known.

TestRuleCompactAlma also posts the first ask, and each system prompt
with an unrelated user message.

Run on mote: go test -run TestRuleCompactAlma ./internal/gateway, ok.
Broken by hand: the three new entries taken out, and the three new
cases go to the other rule (b/big).
Not tried: a real Alma compaction through magpie.
2026-11-01 10:22:57 +08:00
yetone 73528a9a03 gateway: x-bili- headers go only to a /bili/ URL of the user's own provider (#3052)
Review of 5d5a148ab: it sent every x-bili- header the agent sent to every
provider, Claude and Codex accounts and every vendor included. They are
the billion-context proxy's own headers, so they now go on only when the
request's URL is in bili's prefix form (http://host:8787/bili/<upstream>,
the form its README gives for putting it in front of a gateway and the
one the report uses), and never for a signed-in account.

TestForwardOnceKeepsBiliHeadersFromOthers: a plain URL, a URL with
/bili/ deeper in its path, and an account on a /bili/ URL get none.
TestForwardOnceCarriesBiliHeaders now posts to a /bili/ URL.

Run on mote: go test -run 'TestForwardOnce(Carries|Keeps)BiliHeaders'
./internal/gateway, ok. Broken by hand: the condition set to true, and
the new test fails for all three requests.
Not tried: a real bili proxy.
2026-11-01 10:22:57 +08:00
ggbdpq bc7d833916 zcode: the reasoning keys ZCode reads, not OpenCode's (#3852)
magpie's ZCode takeover wrote a model's reasoning as
{"enabled":true,"variants":[…],"defaultVariant":…} — OpenCode's
shape, which ZCode's config.json provider entry is loosely modeled
on. ZCode's own schema for it is
{enabled?, levels?, defaultLevel?, providerOptionsByLevel?}
(resources/glm/zcode.cjs, same in the 3.12.3 the issue reports and
in the 3.16.3 checked on this machine; "defaultVariant" has no
occurrence in the 3.16.3 runtime at all). Its .passthrough() keeps
the unknown keys and ignores them, so ZCode picked a level, sent
output_config.effort and never a thinking field — and an
always-thinking upstream model (Kimi Code's kimi/k3.1-pro, for one)
refused every request with 400.

magpie now writes the keys ZCode reads: levels and defaultLevel it
had all along, plus providerOptionsByLevel with thinking on for
every level and off for the one named "disabled". The kept default
a sync reads back now looks for defaultLevel, falling back to the
defaultVariant an older magpie wrote (a key ZCode never read, only
magpie) so a user's choice survives the first sync after the
upgrade. The provider_config.json rule side is untouched: its
optionSpecs.reasoningLevel.values is already a key ZCode reads.

The OpenCode family keeps variants/defaultVariant: there those are
the keys the app reads.

Fixes #3852

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 10:22:57 +08:00
ggbdpq 9a951eb038 gateway: end the cgroup memory walk at "/" on every host (#4113)
What: the cgroup v2 walk read the path from /proc/self/cgroup with
filepath, whose separators and root are the host's. On Windows the
root is "\", so filepath.Clean("/"+dir) was
"\system.slice\magpie.service" and filepath.Dir stops at "\", which
is never "/": the loop read \memory.max and \memory.high until the
suite's timeout, holding internal/gateway with no result on Windows
(TestClaudeMemRunsFromTheCgroup, 45m). The cgroup path is a "/" path
whatever the host reads it on, so the walk is path's now (Clean, Dir,
and the label's Join); filepath.Join stays only for the limit file
under the cgroup root, which is a host path. On Linux and darwin,
where filepath's file is path's own code, nothing changes: the walk
reads the same files and the limits, and the "cgroup ..." label, are
byte for byte what they were.

Run: TestClaudeMemWalkEndsAtRoot is new: it runs memLimit("linux", a
fixture whose cgroup path is /system.slice/magpie.service) under a
one-minute watch and fails if the walk never ends at "/". On this
macOS machine it is green before the change too — filepath is path's
code there, so old and new cannot disagree on unix; on Windows it is
red before the change by construction (filepath.Dir of "\" is "\"),
and Windows is the reported host: the reporter's 45m stack at main is
the red this test gives there. With the change it passes, and
go test -count=1 -timeout 45m ./internal/gateway is green (461s),
-tags nogui green (464s); gofmt -l clean; go vet ./... on darwin,
GOOS=linux -tags nogui and GOOS=windows clean (the internal/gui cgo
warnings are main's); go build on the three.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 10:22:57 +08:00
ggbdpq 0d76d16ec6 test(gateway): let only the gateway's deadline end a stall's fake answer
What changed: the fake relays in TestStalledAnswerSaysUrlOrB64 and
TestVendorThatStopsMidAnswerIsSaid waited on r.Context().Done() with a
time.After(5 * time.Second) fallback of their own. Under load the fake's
5s could end its answer before the gateway's 500ms stall deadline
(drawUnit = 100ms) was acted on, so the gateway read a cut body and said
502 "isn't an images API's: unexpected end of JSON input" instead of the
stall's 504 (#4245). The fakes now wait on the context alone: the
deadline's cancel is what ends them, so the order can't flip. No product
behavior changes; both tests still assert the same 504 wording.

Run: go test ./internal/gateway -run
'TestStalledAnswerSaysUrlOrB64|TestVendorThatStopsMidAnswerIsSaid'
-count=5 - ok.
go test -tags nogui -timeout 45m ./internal/gateway/... - ok (500s).
go vet ./... and GOOS=windows go vet ./... - ok; GOOS=linux go vet ./...
fails in wails (undefined: pointer) at the base commit too.
CGO_ENABLED=0 GOOS=linux|windows|darwin go build -tags nogui . - ok.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 10:22:57 +08:00
ggbdpq 71f26a600f library: a save drops an empty applied entry (#4247)
What changed: a sync that only looked at an agent — its hooks, its
subagents, its MCP file, with nothing of the library's to give it —
still took an empty applied entry into library.json, one per agent,
growing at every start ({"claude":{}}, then {"claude":{},"codex":{}}).
The syncs make the entry the moment they look (l.applied(id)), and the
step's save wrote it out. A save now drops an entry with nothing in it,
and keeps every entry that holds something. A file otherwise unchanged
is left alone by the write under it (edit.WriteAtomic), so a sync with
nothing to give anyone no longer writes library.json at all — the
single write a field-showing command of the CLI's was seen to bring
into the HOME a test held, red once on Linux (TestEveryAgentFieldName
WritesNothing).

Run:
- go test -tags nogui ./internal/library -run 'TestSaveDropsEmptyApplied|TestSyncAloneLeavesNoEmptyApplied' -count=1
- go test -tags nogui -count=1 -timeout 45m ./internal/cli ./internal/agent ./internal/library
- go vet ./... and GOOS=linux/windows go vet -tags nogui ./...; builds for the three
  systems (linux and windows with -tags nogui)

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 10:22:56 +08:00
ggbdpq c313a906f4 handoff: Give no longer leaves the handed socket's listener blocking (#4107)
A restart that hands the gateway over reads the copy of its listening
socket (ListenerFile) to send it along (Give). The copy shares the
listener's open file description (TCPListener.File dups the fd), and
os.File.Fd puts such a description in blocking mode: a socket's File
hands out expecting its Fd to be read, and SetBlocking then takes the
O_NONBLOCK flag off the description the copy and the listener share.
The gateway's own listener went blocking with it: its accept slept in
the syscall once nothing came queued, where Close cannot reach it —
the pollDesc evict wakes I/O waiting in the netpoller, not a syscall,
and the listener's own FD still counted as non-blocking, so Close
waited on its condition variable for that accept to return.
stopAccepting waited there, ListenAndServe never returned, and the
ending magpie hung: under a full-suite load TestRestartHandsTheGatewayOver
sat 43 minutes with the handover goroutine in semacquire inside
gateway.(*Server).stopAccepting (the 2701s timeout, #4107). Alone it
passed, as the accept only sleeps there when it comes around with no
connection queued, which a quiet machine rarely gives.

Give now takes the number to send from SyscallConn, which reads it
without the blocking switch.

Red before, green after: TestGiveKeepsTheListenerNonblocking — a
listener handed over with Give keeps its O_NONBLOCK (sub-second,
deterministic; on the old Give it fails "Give left the listener in
blocking mode (os.File.Fd on the copy)").

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 10:22:56 +08:00
ggbdpq 837ea5f565 gateway: a Kimi tool schema with items is an array, not its enum's string, as Gemini's is now (#3867)
yetone, #3867: kimiSchemaType and collectUntypedEnums read an untyped
schema's enum or const before its keywords, so a tool's
{"items":{"type":"string"},"enum":["a","b"]} reached Kimi typed "string"
with items beside it — the shape its Gemini sibling went out in until
d71362af made geminiSchemaType read an object's or array's keywords
(properties, items, keywordType) before its values, and Antigravity
turned that turn away over them.

- collectUntypedEnums: of an untyped node typed from its enum or const,
  its properties or items (keywordType, object or array) say the type
  first; a pattern's or minimum's string or number still loses to the
  values, as before (an integer enum beside a minimum stays integer).
- kimiSchemaType: the same keywords before the enum or const, a $ref's
  target included; the one its branches say unchanged.
- Whether Kimi refuses items on a string is not known (no report of it,
  no real Kimi request tried; #3867 leaves that to a real account); the
  two are kept apart either way, as Gemini's are.

Tests (kimi_schema_test.go): TestKimiToolEnumTypesItemsBeforeEnum, the
issue's shape through kimiToolEnumTypes and a $defs target with items
and a string enum through kimiToolRefTypes, an enum without items or
properties still typed from its values.

Run, in a worktree at upstream/main e056779a:
- go test -tags nogui ./internal/gateway -run
  'TestKimiToolEnumTypesItemsBeforeEnum' -count=1, before the change:
  FAIL (display typed "string" with items beside it, filter "string"
  with properties, the $ref's target "string"); after: ok, and
  TestKimiToolEnumTypes, TestKimiToolRefTypes and TestKimiLockedSampling
  pass as they were.

Fixes #3867

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 10:22:56 +08:00
ggbdpq 7bdf08f18d gateway: no type beside the $ref a Kimi schema's target is
kimiToolRefTypes wrote a type into each schema a tool's $refs reach that
has none. When the target was itself a $ref — zod writes one beside what
it changed of a reused schema, a format and a description among them, as
Codex's automation_update's targetThreadId reaches {"format":"uuid",
"description":"tt","$ref":"#/$defs/__schema1"} — the type went beside
that inner $ref, and Moonshot refuses one there, 400 "At path
'$defs.__schema14': when using $ref, type should be defined in the
referenced schema instead of the parent schema" (#3205), so every turn
failed though the tool is never called. The plugin side had the same bug
and fixed it in kimi-work 0.1.5.

The chain a $ref names is now followed to the schema it ends at, and it
is there the type goes, or nowhere when the chain ends at a ref to
nowhere or never ends: schemaTypes already resolved chains to say what
the type is, so only the place it is written moves. Codex's own
automation_update schema (the fixture its tests and magpie's root-union
tests share) goes as it was sent: its defs are notes beside a $ref to a
typed target, which Kimi takes.

Fixes #3205

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 10:22:56 +08:00
ggbdpq ee031e9539 gateway: a billion-context proxy in front of the provider gets the client's x-bili- headers (#3052)
What changed: forwardOnce copies the client's x-bili-* headers on to the
request it builds for the provider, by a biliHeader predicate beside
claudeCodeHeader and codexClientHeader — an x-bili- prefix, in the shape
of the anthropic-, x-stainless-, x-claude-code-, x-openai- and x-codex-
families already on the allowlist. The headers carry the cooperative
plugin's name, conversation and context window, never a key; a header no
family allowlists, and the client's own key, still stay off.

Why: forwardOnce builds the upstream request from nothing and copies only
allowlisted headers, so a client talking to a billion-context (bili)
proxy put in front of its provider lost the x-bili- ones that name its
cooperative session — bili then saw an anonymous session and injected a
duplicate set of compression tools beside the plugin's own (#3052).
Whether to generalize this into a per-provider "pass-through client
headers" setting, beside PassUserAgent (#1851) and a provider's own
Headers, is the maintainer's call; this change only admits the family
the issue reports.

Run: go test -run TestForwardOnceCarriesBiliHeaders ./internal/gateway
fails on the baseline with the three headers empty and passes with the
change (httptest, no network); ablation (product file back at baseline,
test kept) fails again. gofmt -l clean; go vet ./..., GOOS=linux and
GOOS=windows go vet -tags nogui ./... clean; native, GOOS=linux -tags
nogui and GOOS=windows builds clean; go test -tags nogui
./internal/gateway green.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 10:22:56 +08:00
ggbdpq f0ff905167 gateway: a compaction rule sees Alma's compaction ask (#2833)
What changed: compactAsks in internal/gateway/compacting.go gains Alma's
compaction ask, "Merge the previous summary with the new conversation.",
which opens the last user message of Alma's compaction request. A group's
compact rule now matches it. No compactSystems entry was added: neither the
repository nor the report carries the opening of Alma's compaction system
prompt, so none is invented.

Why: compacting.go matched the compaction prompts of Claude Code, Codex,
OpenCode, Pi, Gemini CLI, Qwen Code, Minis and Kimi Code literally. Alma was
not in the table, so its compaction fell through to the intent classifier and
was routed by another rule's model, making every compaction cost more than
the group's compact rule intended. The ask sits at byte 0 of the user message,
well inside compactLead (2048), so one table entry recognises it.

Test: TestRuleCompactAlma drives a group whose rule 1 is compact and rule 2 is
tokens >= 1 through the gateway. With the fix the Alma request is answered by
rule 1's member and X-Magpie-Model says a/small; without it the request goes
to b/big. The same test asserts a long message that only quotes the ask past
compactLead is not a compaction; raising compactLead makes that assertion
fail, so the bound is what keeps notes from matching.

Run: go test -tags nogui -count=1 -run 'TestCompact|TestCompacting|TestRule'
./internal/gateway/ (ok, 2.839s); go test -tags nogui -count=1
./internal/gateway/ (ok, 344.144s); go test -race -tags nogui -count=1 -run
'TestCompact|TestCompacting' ./internal/gateway/ (ok, 2.172s); gofmt -l
internal/gateway/ (empty); go vet -tags nogui ./internal/gateway/ and with
GOOS=linux and GOOS=windows (all ok); go build -tags nogui ./..., GOOS=linux
go build -tags nogui ./..., and GOOS=windows go build -tags nogui -o /dev/null .
(all ok). Not tried against a real Alma client: the wording is quoted from
the report.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 10:22:56 +08:00
yetone 8ac1c7a563 catalog: a model's list price is looked for once a catalog load
The GUI's provider list prices every model of every provider on each
request of /api/providers: ListPrice asks catalog.PricedBy and
MakerPriced by every spelling of the id across every maker's catalog,
and a model none of them lists (most of a relay's) went through all of
them each time. In a CPU profile of the GUI's polls (drift, state,
providers, 40 rounds, a real-account sandbox) ListPrice was 14% of the
process's CPU, PricedBy and makerListPrice most of it.

What PricedBy and MakerPriced find depends on the loaded catalog, the
providers asked and the id, and nothing else, so pricedOnce keeps it by
those for the load's Reset count (gen), as priceIndexOf and AtEndpoint
keep what they build. A Reset (a new catalog synced) starts it again; it
holds at most 32,768 answers and starts again past that. find runs
without the memo's lock, as PricedBy calls itself for a renamed id.

Run on mote (macOS 27, Go 1.26.8) at this tree:
- gofmt clean; go vet ./internal/catalog on darwin, GOOS=windows and
  GOOS=linux ok.
- TestPricedOnceALoad 3 of 3 alone, and with -race beside
  TestPricedBy*/TestMakerPriced*: ok.
- Broken by hand: the memo never answering, TestPricedOnceALoad red
  ("looked for 20 times again at one load"); the memo not keyed by gen,
  red (the old catalog's 0.15 after a new one's 0.2).
- go test ./internal/catalog ./internal/provider ./internal/usage ok.
  ./internal/gui: TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestMainWindowCorners/macOS_26_SDK (#3949) red, the same two red with
  the same output at origin/main ccb75030a on mote.

Real use, this machine, a copy of the real accounts in a sandbox HOME
(proxy blocked, MAGPIE_NO_STATS=1), v0.1.2518's tree (old) against this:
- /api/providers: 1506 models, 938 with a list price; every model's
  list and price the same in both. The rest of the reply differs only
  in fetched times and one login's lapsed time.
- 40 rounds of drift + state + providers, twice each, alternated:
  providers 28.4/27.6ms old, 24.4/24.6ms new; process CPU 2.09/2.03s
  old, 1.95/1.94s new.

Not run: the whole suite; Windows and Linux runs (nothing here is by OS).
2026-11-01 10:11:48 +08:00
yetone ccb75030aa gateway: a held request body is known by where it is, not summed again (#4371)
Each of the dozen decodes, topMember reads and validity checks a request
body goes through summed all its bytes with maphash to find what
validMemo knew of it: about 5% of the gateway's CPU on long Codex
requests (#4371). A body being served (holdBody) is not written while
held, so longBody and jsonValid now know it by its address and length,
check and split it once, and keep that in heldBodies.long until it is
released, as factsOf keeps its facts. Any other long body is summed as
before.

Run on mote at this tree:
- gofmt, go vet (darwin, GOOS=windows, GOOS=linux): ok
- TestHeldBodyIsNotSummed, TestHeldBodyNotJSON, TestDecodeJSON*,
  TestRequestBodyRawValuesShareIt, TestTopMember*, TestWithoutTopMember*:
  ok 3 of 3 alone, ok under -race
- go test -timeout 45m ./internal/gateway: ok (609s)
- Broken by hand: held lookup skipped -> "a held 84077-byte body was
  summed 18 times"; release left the finds kept -> "a released body's
  finds were kept".
- BenchmarkHeldBodyDecodes (1.8MB Responses body held, 12 decodes plus 12
  topMember reads an op): 3.31ms/op before, 7.9us/op after, allocations
  the same (24/op).

Real use: sandbox HOME copied from the owner's, real DeepSeek account,
deepseek-flash, four turns of a 115-123KB history through
/v1/chat/completions with masking on: every reply HTTP 200 (three "ok",
one empty at finish_reason length, the model's reasoning using
max_tokens, as on the old binary).

Not run: the full ./... suite; a real Codex account; Windows and Linux
runs of the tests.

Picked onto 9162277b9 (3 commits, none in internal/gateway/fastjson.go); not run again there.
2026-11-01 09:59:21 +08:00