Commit Graph
5489 Commits
Author SHA1 Message Date
yetone f2eb56c6bb usage: a first start pairs the history a few weeks at a time, not at once (#2278)
With no sums on disk (a first install, or a version that counts rows
otherwise), the page's cells, the heatmap's days and Codex's effort
before the cut were built from one pairing of the whole history. Every
gateway block was priced, every session row's message id went into one
set, and every call into one match map. On the owner's history that
was ~212 MB of the warm-up's 341 MB in use and the cold start's peak.

coldSpans builds them as a day's start advances them (pageAdvance),
14 days at a time. A span pairs the chunks with a row from heatReach
before it to heatReach after. Each chunk's oldest row is kept by its
serial. A gateway block not priced yet is priced by a pricer of the
span alone, and its rows go back to the pool after the span. The
recent days are then paired as on any kept start.

The page's cells come out in another order (by span, then chunk), so
TestSettledCountedAsVersioned now sorts them before it hashes. The
sorted hash is the same for a pairing at once and in spans, so
settledCountVersion stays. Tests that count a pairing of every chunk
use pairAtOnce (coldSpan 0).

Run on mote at the pushed head (rebased on b62fa332f): gofmt -l
clean; go vet ./internal/usage for darwin, linux and windows ok;
go test -count=1 ./internal/usage ok (20.0s); go build . ok.
Broken by hand: TestFirstBuildPairsSpans goes red when a span pairs
only its own days (lo, hi := from, to): the effort differs.
Bench, real history (a year), cold first start, against v0.1.2256,
two rounds each, on mote at load ~22:
  no GUI polls:  footprint peak 451, 407 MB (2256: 493, 484);
                 live heap max 318, 289 MB (2256: 367, 362)
  GUI polls:     footprint peak 483, 410 MB (2256: 534, 532);
                 live heap max 316, 290 MB (2256: 395, 406)
The heatmap's answers are byte-equal to 2256's. The request page's
differ only in float digits from the summation order (232 floats,
largest relative difference 6.5e-14); every other value is equal.
Not tried: a start on Windows or Linux.
2026-10-31 03:13:28 +08:00
yetone b62fa332f3 provider: Send requests unmasked for subscriptions and plugin providers too (isee1_1)
isee1_1 on Discord uses a community translation plugin as a provider and
asked why "Send requests unmasked" (请求不脱敏) isn't offered for it.
698da36f3 (lc) left a signed-in account, a plugin's provider and another
magpie out because the switch was then for local addresses only, and none
of those is local. 380032cda (AcMilan) made it the user's word at any
address, with a caution while on for one not local, but kept the
exclusion. Nothing still stands behind it for a subscription or a plugin:
the setting lives with the account's model picks, and every route reads
SkipsRedaction. Another magpie stays excluded, as it masks on its own side.

- provider.SkipsRedaction: an account (subscription or plugin) skips when
  set; another magpie never. Save keeps Unredacted in the picks record,
  withPicks applies it (AlsoOn accounts too).
- gateway: serve, count_tokens, embeddings, Jev and the plugin's fetch
  already go by unredactedRoute (every fallback and group member must be
  set too). The Codex relay on a ChatGPT sign-in masked always: it now
  sends the turn whole when the Codex subscription is set
  (codexRouteUnmasked; only for the ChatGPT backend, not the Codex API
  key route), codexMaskRoute stands aside then, and ChatGPT web search
  (alphaSearchOn) goes unmasked only when every provider it is on is set.
  Speech and video stay masked whatever the switch (maskTextHits), as
  before, for every provider.
- GUI: the editor's Redaction row is shared (unmaskRow); a subscription
  or plugin provider has it too, its caution naming the provider while
  on, since its vendor is never local; saved with the account's body.
  Another magpie has none. No new strings; app.js stays in its budget.
- CLI help/show text, gateway-routing.md and the masking docs (en, zh,
  ja) say so.

Run (mote, through mote-run):
- go test ./internal/provider ./internal/cli: ok
- go test -timeout 45m ./internal/gateway: ok (676s)
- go test -run 'Budget|Redact|Unmask|I18n' ./internal/gui: ok
  (TestCoreScriptBudget at +45 bytes)
- GOOS=linux go vet ./internal/gateway ./internal/provider, GOOS=windows
  go vet ./internal/gateway ./internal/provider ./internal/cli: clean
  (GOOS=linux vet of internal/cli fails in wails without cgo, as on main)
- node --test provider-unmasked (chromium): 36/36; i18n-keys: 4/4.
  WebKit on mote can't launch (#4125); WebKit ran through wsl-run:
  the whole file in chromium and webkit, 72/72. At 440 in Linux WebKit
  the list's sticky foot covers the last row (another magpie's), so the
  test clicks that row as an event (#4484).
- gofmt -l: clean

Broken by hand:
- SkipsRedaction's account branch back to false: TestSkipsRedaction
  (an account, a plugin's provider), TestPluginProviderUnmaskedSwitch/set
  and TestCodexSignInUnmaskedSwitch/set go red.
- Unredacted dropped from Save's account whitelist: the plugin test's
  "saved as" goes red.
- codexRouteUnmasked forced off: TestCodexSignInUnmaskedSwitch/set red.
The unset and falls-back-to-a-vendor cases stay masked in each.

Not tried: a real plugin provider or a real Codex/Claude account with
the switch on (fakes only: the fake bun plugin and a fake ChatGPT
backend); the Claude bridge path; the full Go and GUI suites run after
the push.
2026-10-31 02:56:49 +08:00
yetone 14b451c117 site: the MCP hub's docs are the MCP router's, and the old links redirect
The feature is called the MCP router now (the commit before). The docs
pages move to mcp-router.html in en, zh and ja, their wording follows
(MCP router / MCP 路由 / MCP ルーター, `magpie library mcp router on|off`),
and every docs page's link and canonical/hreflang URL points at the new
path. The worker answers /docs/mcp-hub, /docs/zh/mcp-hub and
/docs/ja/mcp-hub (with or without .html or a trailing slash) with a 301
to the new page, keeping the query, so links already shared still open.

The plugins pages' link to the router page (Search1API's tools,
from the rebase) follows too.

Run at e2583df31 (this stack on 86fef947e), on mote: gofmt -l clean;
go vet for darwin, linux (-tags nogui) and windows; go build ./...;
go test -tags nogui ./... -timeout 45m, 81 packages ok, 0 FAIL;
library, gateway, imagemcp, sessions, cli and gui again alone, ok;
site's node --test, 49 of 49. GUI on xiaomi-gpu (Windows; mote's
browsers crashed under other sessions' suites): library-*, image*,
mcp-hub-direct, i18n-keys, list-sort and plugin-tools, both engines and
every language, 1055 of 1056: i18n-keys found "{name} is given to each
agent directly" dropped from the library's strings in the rebase. Put
back in the first commit; at the pushed head i18n-keys, mcp-hub-direct
and library-mcp-hub are 48 of 48. That is the only difference from
e2583df31.
Broken by hand at e2583df31: imagemcp ignoring magpie/roots fails
TestHubCallSavesInTheCallersProject; the router asking anything but
roots/list fails TestHubAsksTheAgentItsRoots and TestHubRootsUnasked;
inHub leaving magpie-image out fails TestHubGivesMagpieImage.
Checked: no 聚合, ハブ or mcp-hub left under site/ except the redirect.
The worker's redirect test fails without the redirect line (not ok 7).
Rebased once more onto 2570efb5f, which changed library-mcp-hub,
list-sort, mcp-hub-direct and gateway-routing.md. Run at the pushed
head: go build; gateway, library, cli and imagemcp tests ok; the GUI
budget tests ok; on xiaomi-gpu i18n-keys, mcp-hub-direct,
library-mcp-hub and list-sort, 51 of 54. The three reds were WebKit
420px library-mcp-hub cases with no Connect sheet after a reload.
origin/main d77da5bff goes red the same way (de 420px, 9 of 11). In a
second run of library-mcp-hub on WebKit at this head, 11 of 11 passed.
Filed as #4483.
2026-10-31 02:49:08 +08:00
yetone 7bc602236b library: the MCP hub is called the MCP router
The owner asked why it was a "hub". Composio calls the same thing a Tool
Router; "router" says what it does (one server that routes each call to
the right one), and "gateway" is taken by magpie's LLM gateway. Only
the words change: MCP router / MCP 路由 / MCP 路由 / MCP ルーター /
MCP-Router, "Router address", and the CLI's `magpie library mcp router
on|off`, where `hub` still works. The URL /mcp/magpie/hub, the mcpHub
setting, the servers/hub API and the Go names stay, so nothing a user
or an agent config holds changes. docs/subsystems/mcp-hub.md moves to
mcp-router.md and the pages that link it follow.

#4382's new words follow too: "Through the MCP router", "Not through
the router" and their hints in every language, and the CLI's
`magpie library mcp router <name> shared|direct` (`hub` works there
too; library_hub_test.go says router for direct, hub for shared).

Run at e2583df31 (this stack on 86fef947e), on mote: gofmt -l clean;
go vet for darwin, linux (-tags nogui) and windows; go build ./...;
go test -tags nogui ./... -timeout 45m, 81 packages ok, 0 FAIL;
library, gateway, imagemcp, sessions, cli and gui again alone, ok;
site's node --test, 49 of 49. GUI on xiaomi-gpu (Windows; mote's
browsers crashed under other sessions' suites): library-*, image*,
mcp-hub-direct, i18n-keys, list-sort and plugin-tools, both engines and
every language, 1055 of 1056: i18n-keys found "{name} is given to each
agent directly" dropped from the library's strings in the rebase. Put
back in the first commit; at the pushed head i18n-keys, mcp-hub-direct
and library-mcp-hub are 48 of 48. That is the only difference from
e2583df31.
Broken by hand at e2583df31: imagemcp ignoring magpie/roots fails
TestHubCallSavesInTheCallersProject; the router asking anything but
roots/list fails TestHubAsksTheAgentItsRoots and TestHubRootsUnasked;
inHub leaving magpie-image out fails TestHubGivesMagpieImage.
The CLI's TestProviderAddressMovesALocalServer red at -count=3 was
the same on origin/main 380032cda and is fixed in 65c792410.
Rebased once more onto 2570efb5f, which changed library-mcp-hub,
list-sort, mcp-hub-direct and gateway-routing.md. Run at the pushed
head: go build; gateway, library, cli and imagemcp tests ok; the GUI
budget tests ok; on xiaomi-gpu i18n-keys, mcp-hub-direct,
library-mcp-hub and list-sort, 51 of 54. The three reds were WebKit
420px library-mcp-hub cases with no Connect sheet after a reload.
origin/main d77da5bff goes red the same way (de 420px, 9 of 11). In a
second run of library-mcp-hub on WebKit at this head, 11 of 11 passed.
Filed as #4483.
2026-10-31 02:49:08 +08:00
yetone b78b1de003 library: magpie-image is behind the MCP hub, saving into the calling agent's project
magpie-image was the one MCP server the hub left out, because it saves
what it makes on disk and needs to know whose project that is. The hub
now serves its tools like any other server's and tells it where the
caller works:

1. the hub answers a tools/call as SSE and asks the agent roots/list on
   that stream (3s), as Claude Code answers;
2. else Codex's _meta x-codex-turn-metadata.workspaces (git repos only);
3. else the Codex thread's cwd from its session file
   (sessions.CodexThreadCwd), only with session consent;
4. else none, and the image goes to ~/Pictures/Magpie as before.

The hub passes `magpie/roots` and `magpie/client` in the call's _meta;
imagemcp saves into the first root and names the agent on its usage
row. Its result carries `magpie/model`, which the hub's own usage row
takes, so the row says which image model drew it. A WSL agent keeps
magpie-image as its own entry (the hub can't reach a path inside the
distro). docs/subsystems/mcp-hub.md (mcp-router.md after the next commit), gateway-routing.md and
gateway-sessions.md say so.

It is rebased on #4382 (b889ffe81), which lets the user keep a server
out of the hub (Server.Hub = direct). inHub now asks both: a server
kept direct is out, and magpie-image is in unless the agent is in WSL,
so the user can keep magpie-image direct too; the editor's switch
shows for it like any server, and the hub's line counts it with the
others (mcp-hub-direct.test.cjs follows).

Run at e2583df31 (this stack on 86fef947e), on mote: gofmt -l clean;
go vet for darwin, linux (-tags nogui) and windows; go build ./...;
go test -tags nogui ./... -timeout 45m, 81 packages ok, 0 FAIL;
library, gateway, imagemcp, sessions, cli and gui again alone, ok;
site's node --test, 49 of 49. GUI on xiaomi-gpu (Windows; mote's
browsers crashed under other sessions' suites): library-*, image*,
mcp-hub-direct, i18n-keys, list-sort and plugin-tools, both engines and
every language, 1055 of 1056: i18n-keys found "{name} is given to each
agent directly" dropped from the library's strings in the rebase. Put
back in the first commit; at the pushed head i18n-keys, mcp-hub-direct
and library-mcp-hub are 48 of 48. That is the only difference from
e2583df31.
Broken by hand at e2583df31: imagemcp ignoring magpie/roots fails
TestHubCallSavesInTheCallersProject; the router asking anything but
roots/list fails TestHubAsksTheAgentItsRoots and TestHubRootsUnasked;
inHub leaving magpie-image out fails TestHubGivesMagpieImage.
Real use, sandbox HOME and gateway, at 62421e570 (before the rebase): Claude Code saved into its project
via roots/list; Codex in a git repo via its workspaces _meta; Codex
outside a repo with session consent via the thread's cwd.
At 62421e570 the whole GUI suite ran on WSL magpie-desktop at load 116 to 135 from other
runs: 504 of 15757 red in 118 files, WebKit timeouts, none in a file
this change touches; filed as #4471 with the list.

Rebased once more onto 2570efb5f, which changed library-mcp-hub,
list-sort, mcp-hub-direct and gateway-routing.md. Run at the pushed
head: go build; gateway, library, cli and imagemcp tests ok; the GUI
budget tests ok; on xiaomi-gpu i18n-keys, mcp-hub-direct,
library-mcp-hub and list-sort, 51 of 54. The three reds were WebKit
420px library-mcp-hub cases with no Connect sheet after a reload.
origin/main d77da5bff goes red the same way (de 420px, 9 of 11). In a
second run of library-mcp-hub on WebKit at this head, 11 of 11 passed.
Filed as #4483.
Not tried: Codex outside a git repo without consent (it saves to
~/Pictures/Magpie, #4435); agents on Windows and in WSL with real use.
2026-10-31 02:49:08 +08:00
yetone d77da5bff3 claude bridge: a caller elsewhere whose environment is a message is told the last one given is where tools run
packinggoods on Discord, again after v0.1.2093: a Mac Claude Code
through a Windows magpie's Claude subscription still has its commands
wrapped in PowerShell. The bridge's run is the real Claude Code on the
Windows box, and it puts its own environment (Platform: win32, its
shell, a temp folder) in a <system-reminder> at the start of the run's
first message. 1f03d7546 and 13f9c7fca follow the caller's instructions
with envElsewhereNote: "the environment these instructions describe ...
is the one every tool runs in". But Claude Code 2.1.296 and later, as a
client, don't put their environment in the system prompt: captured from
the real claude 2.1.314 (sandbox HOME, fake key, capture server), it is
a {role: "system"} message after the user's first. So the note pointed at
instructions that describe no environment, and the caller's darwin/zsh
environment came after it as a "Human:" turn, with the gateway's win32
one first.

Now clientNamedWorkPlace says whether the caller's folder was named in a
message (Request.envInTurns). Such a caller gets envTurnsNote, in the
first message's instructions or a lean run's system prompt: of the
environments the conversation gives, the last one is where every tool
runs. The run's own is always first, so the last is the caller's. A
caller naming its folder in its instructions, a run in the caller's own
folder, and a caller naming none are told what they were before. The
note names no app and no vendor.

Test: TestClaudeCallerEnvironmentInAMessageIsTheLastGiven, with the
2.1.314 request shape from a remote address, lean off and on, and a
caller naming its folder in its instructions for the old note. With the
envInTurns case taken out of envNote by hand it is red (told the note 0
times; the old note pointed at the instructions).

Run (mote-run): go test ./internal/gateway -run
'TestClaudeCallerEnvironmentInAMessageIsTheLastGiven|TestClaudeLeanPrompt|WorkDir|RemoteCaller'
ok; go vet ./internal/gateway for darwin, linux (-tags nogui) and
windows ok; gofmt -l clean. go test -timeout 45m ./... was started on
mote and shipped before it finished (owner's ship-at-once rule); its
result goes on an issue if anything is red.
Not tried: a real model turn from a Mac client through a Windows
gateway (no Claude sign-in on xiaomi-gpu), so whether the model now
stops writing PowerShell is not measured; packinggoods's magpie version
is not known.
2026-10-31 02:34:00 +08:00
yetone 2570efb5f7 gateway: an image the picked model can't describe is described by the next model that sees (kelvinjason11 on X)
kelvinjason11 on X: "图片识别好像只支持一个模型识别 没有fallback". When
the describer (Settings' Image recognition model, or AutoVision's pick)
failed, the turn failed with it, though other models that see were there.

Now describeWith asks the pick first, always. When it fails for any reason
but the client's own cancel, magpie asks the next model that sees: the
first ready one of seersRanked, AutoVision's own order (ready, then
Claude account, Codex, API key, other, then cost), leaving out each model
already tried and each one that turned an image away (sightRefused). At
most 3 models (visionTries), and all of them within visionWaitMost
together: each try gets what is left of it, not a fresh visionTimeout.

- The text header names the model that described the image
  ("as other/bigeye describes it"), not the pick.
- The Routing row of the stand-in carries Instead, Why and Picked
  (describingInstead, the same fields web search's searchingInstead
  sets), and the Routing page says in every language that the pick
  couldn't describe it, why, and which model did instead.
- When none answers, the error is the first failure as before, then
  "nor could X, asked in its place: why" for each other model tried.
- Spent/allowance: each try goes through serve as before, so autoSpent
  and spentModel judge every stand-in the same as they judged the pick.
- vision_mcp's describe_image tool gets the same fallback.

Cache (s.sights): a description is kept under the pick and the image,
whichever model described it, with the describer's name beside it. The
same image sent again asks no one, the stand-in's text is reused, and
its header still names the stand-in. A new image asks the pick first
again, so a pick that comes back is used at once. Failures are not kept.

Settings' text ("When the model in use can't see images, this one
describes them to it") is left as it is: the pick is still asked first
for every image.

Tests (internal/gateway/vision_fallback_test.go):
- TestPickedDescriberThatFailsGivesWayToTheNextThatSees
- TestAutoDescriberThatFailsGivesWayToTheNext
- TestNoDescriberAnswersNamesEach
- TestPickedDescriberThatAnswersIsTheOnlyOneAsked
- TestCanceledDescriptionAsksNoOther
TestDescriberThatCantSeeIsntAskedToDescribe now expects the next model
that sees to describe in place of a text-only pick, not a 502.
GUI: internal/gui/tests/vision-instead.test.cjs (every language, 1100
and 520 wide).

Run on mote at 45739f15b (this tree, on origin/main 74f1df869):
- go test -tags nogui ./internal/gateway/ -count=1 -timeout 45m: ok
  (542.988s). An earlier run while mote was at load ~26 failed four
  Antigravity turned-away tests and TestCodexSpentGrokFailingIsTold.
  None of them touches vision, and all passed in this run.
- gofmt -l: nothing.
- GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: ok.
- GUI, Chromium: vision-instead, search-instead, routing-vision-why,
  vision-mcp, routing-kind and i18n-keys (4/4) pass.

Broken by hand (in a worktree at 0fcb3acb3):
- The old code with the new tests: Picked, Auto and NoDescriberAnswers
  go red. PickedThatAnswers and Canceled pass, as they should on code
  that never falls back.
- The ctx.Err() check removed from describeWith: Canceled goes red (a
  vision row for other/bigeye appears).
- describeWith made to ask the next model after a success:
  PickedThatAnswers goes red ("eye asked 1 times, bigeye 1").

Not tried:
- The GUI files in WebKit. Playwright's WebKit launch timed out at 180s
  while mote was at load ~25 from other suites. To be rerun.
- vision-instead against the old Routing client, to watch it go red.
- No real account: the fallback was run only against fake upstreams.
2026-10-31 02:28:18 +08:00
yetone 74f1df8694 gui tests: agent-open-terminal's first load gets a minute too (#4470)
agent-open-terminal (f03ed8c26) landed while ce8b67de3 was being made,
with a 30s navigation bar; nav-timeout.test.cjs asks every page for a
minute, so it would be red at the pushed head. Raised to 60000.

Run on WSL magpie-desktop at this tree: nav-timeout.test.cjs green;
agent-open-terminal.test.cjs 14 of 14 in Chromium and WebKit.
2026-10-31 02:12:19 +08:00
yetone 62c8d21ee5 gui tests: account-arrange acts once the allowances are drawn (#4468)
account-arrange's "account dragging uses the routing order in every mode"
was red alone in WebKit at 31728e29a: line 169's first Antigravity row
had no box. The app is right and the test was wrong. A signed-in
provider's editor is drawn at once and drawn again when its accounts'
allowances come in (loginUsageOf: "loads on its own and fills the rows
in when it's there"), and that redraw replaces every row. The test took
a row from the first draw; when /api/login/usage answered after it (a
busy machine, WebKit), the row it held was gone.

open() and the reload now wait for drawn(page): the first row (with a
load's minute, #4470), then the editing provider's allowance answer in
and not loading, so every action works on the rows that stay. The README
paragraph says so.

What was run (WSL magpie-desktop, Playwright 1.62.0):
- By hand: /api/login/usage answered 1.5s late, a marker set on the name
  first selected. origin/main's file: red in Chromium and WebKit, "the
  name selected is the one drawn last"; this file green in both.
- account-arrange.test.cjs, Chromium, at load ~230-258: green (the first
  run, before the first row got its load's minute; WebKit then went red
  at that 5s first wait, which this file now gives a minute).
- Both engines at load 205-245 (other sessions' suites): this file and
  origin/main's own file both run past the test's 90s budget, Chromium
  and WebKit alike (origin/main's Chromium once red at 14s instead). That
  budget under load is #2200, the same on origin/main, not changed here.

Not tried: the whole GUI suite; mote (#4125) or Windows.
2026-10-31 02:09:18 +08:00
yetone c124f87e2e gui tests: Settings rows are held once the last settings read is drawn (#4469)
images-library-way opened Settings › Models and waited for the Image
generation row, then screenshotted it. A page opened on Settings reads
/api/settings twice (go('settings')'s own read and load()'s), and each
answer draws the tab again, so when the second answer came late the row
it had waited on was replaced while Playwright held it: "element was
detached from the DOM" / a screenshot of a redrawn element (zh-TW 1100
in Chromium). The app's double draw is by design; the test was wrong to
hold the first one. It now waits with reader.cjs's watchSettingsReads and
settingsDrawn, as the other Settings files do, before taking the row.
proxy-test opens Settings › Network the same way and presses its Test
button after the first draw: it gets the same wait at both gotos.

What was run (WSL magpie-desktop, Playwright 1.62.0):
- By hand: the second /api/settings answer held 1.5s and a marker set on
  the row first waited on. origin/main's images-library-way: zh-TW 1100
  and 420 red, "the row held for the screenshot is the one drawn last";
  this file 6 of 6 green, Chromium.
- images-library-way.test.cjs and proxy-test.test.cjs, Chromium and
  WebKit, every language each file covers: images-library-way 62 of 62, proxy-test 22 of 22 green at load ~210 (nav-timeout green on this tree).

Not tried: the whole GUI suite; mote (#4125) or Windows.
2026-10-31 02:09:18 +08:00
yetone ce8b67de37 gui tests: a page's first load gets a minute, not a click's 5s (#4470)
claude-switch-only set page.setDefaultTimeout(5000) and then called
page.goto with no timeout of its own, so Playwright held the first load
of app.js, i18n.js and the plugins to the 5s bar meant for clicks. On a
busy box (a whole-suite run at load 130-160) that load took longer and
goto timed out. The same pattern is in 988 GUI test files (1174 pages):
every one of them now also sets setDefaultNavigationTimeout(60000) on
the same page, right after its default, so goto, reload and waitForURL
wait on the load itself with room, while clicks and waits keep their
short bar. group-from-model-add's own 20s navigation bar is raised to the
same minute. claude-switch-only also gives its first provider row (drawn
from the page's first reads) a minute before clicking it.

nav-timeout.test.cjs (no browser) reads every GUI test file and names
each page given a default under a minute without a navigation timeout of
at least a minute, so a new file can't bring the pattern back.

What was run (WSL magpie-desktop, Playwright 1.62.0, load 70-260 from
other sessions):
- node --check on every file in internal/gui/tests: all parse.
- nav-timeout.test.cjs against origin/main's test files: red (names the
  1174 pages); against this tree: its only reds were my own probe copies
  of the old files, since removed.
- By hand: claude-switch-only with app.js served 7s late (a busy box's
  first load), --test-name-pattern "1100 en": origin/main's file 4 of 4
  red with "page.goto: Timeout 5000ms exceeded"; this file 4 of 4 green.
- claude-switch-only.test.cjs, both engines, en/zh/ja/de, 1100 and 420:
  32 of 32. group-from-model-add, usage-access-key-card and i18n-keys:
  green. agent-plugin-agents: Chromium green; WebKit's de 420 subtest red
  on a 5s waitForFunction at line 115 (a wait after load, not the
  navigation), at load ~230.

Not tried: the whole GUI suite (about 1000 files; the change is one
mechanical line per page), Windows or mote (mote's browsers, #4125).
2026-10-31 02:09:18 +08:00
yetone ef0a5c673a gateway: a web search is left out of a request relayed to a provider that runs none (mxmllln)
mxmllln (Discord #feedback, magpie 0.1.2219, Codex Desktop 0.166.0-alpha.5.1
with remote_compaction_v2): a thread on commandcode/deepseek/deepseek-v4-
flash-vision-exp with 52 function calls and 8 web searches (magpie ran them
for the model through gpt-6.1-sol) failed compaction with Command Code's
400 "An assistant message with 'tool_calls' must be followed by tool
messages responding to each 'tool_call_id'", and every later message too.

Cause: a Responses turn that offers web_search to a provider that runs no
search is translated for magpie's search, and the translation leaves the
web_search_call items out (searchedForIt, searchRoundsBack). A request
that offers no web_search is relayed as Codex sent it, items and all:
magpie's summary request for a compaction_trigger (tools: []), the summary
request Codex makes itself (#1270), a turn with search off. Command Code's
Provider API turns the Responses request into chat for DeepSeek, a
web_search_call becomes an assistant tool call nothing answers, and
DeepSeek refuses it. pairToolItems pairs function and custom calls only.

Fix: the relay of a Responses request leaves the web_search_call items out
when the provider doesn't search for that model (searchesModel), as the
translation does. Kept as they were: a provider that searches itself
(Codex and Copilot accounts, OpenAI, Command Code's gpt-6-luna etc. on
Responses), a relay Codex's turns go to as sent (codexAsSent), and a
native compaction (keepsCompaction). The item holds only the query and the
page URLs, never what the pages said, so there is no result text to pair
it with; the reply after it says what was found.

Other routes checked: the Responses -> Chat and -> Messages translations
already drop the item (or, for Claude's signed thinking, pair it with a
result through searchRoundsBack); Chat and Anthropic clients send no
web_search_call; magpie's plain-text summary retry (plainCompact) reads
no web_search_call. count_tokens is Anthropic-only.

Tests: search_relay_history_test.go. A fake Command Code that refuses a
deepseek request holding a web_search_call with DeepSeek's message, the
history built from searchedHistory (a real ChatGPT backend web_search_call,
2026-10-09) plus a function call and its output: compaction_trigger,
Codex's own summary request and a turn with search off each answer 200,
nothing sent holds a web_search_call, the call and output stay. gpt-6-luna
on the same provider still gets its search. Unit test for
withoutSearchCalls.

Run (mote-run, at this tree):
- go test ./internal/gateway -run 'TestSearchedThread|TestWithoutSearchCalls' -v: ok
- go test ./internal/gateway -run 'Search|Compact|Compaction|Pair|ToolRun|WithoutSearch': ok
- gofmt -l internal/gateway: clean
Broken by hand: with the withoutSearchCalls call taken out of attempt, all
three TestSearchedThreadCompactsOnARelayThatDoesntSearch subtests fail.
Not tried: a real Command Code account (none here), Codex Desktop on
Windows, the reporter's thread. Full suite and Linux/Windows vet run after
the push.
2026-10-31 02:04:22 +08:00
ggbdpq 86fef947e8 gateway: a 200 stream ended with finish_reason "error" fails over (#2471)
What changed: a vendor that ends its 200 stream with finish_reason
"error" - WorkBuddy's and a DeepSeek harness's word for a turn it failed
rather than finished - had the chunk taken for content: the held stream
went to the agent, the try stood as a 200 success, and the group's next
member was never asked. streamEvent now reads the word as the failure it
says, held for the next candidate as an error event before content is;
in the candidate walk the try fails as an empty reply's or a cut-short
summary's does (#1221, #2274): the next is asked, and nobody rests, as
the reply's shape failed, not the account. Content already passed to the
agent can't be taken back, and is not touched.

Run: TestFinishReasonErrorFailsOver (new) red on a15e5765 before the fix
(the reporter's shape: one try, status 200, Fail empty, the second member
never asked), green after; red again with fallback.go and gateway.go
stashed, tests kept. TestStreamErrorBeforeContentFailsOver, the
streamEvent tables, and the stream families (Stream/Finish/Refusal/
Overload/LastOneLeft/GroupFail/Retry, Loop/Hold/Pass/Queue/Patience/
Incomplete/EndedShort/Grok) green. gofmt -l clean; vet on darwin, linux
(nogui) and windows clean; build ok on all three.

Review (magpie): the maintainer's call this waited on is made: the
literal "error" is a failure from any vendor, no vendor sends it for a
finished turn, so it is not keyed per vendor. Alone (no group), the
failure is the last one left's, tried again as a 502 is (15 asks in
the test's clock, the same count a plain 502 gets), then the vendor's
stream goes to the agent as it came. Content already shown is not taken
back. Not covered, still open on #2471: an empty response.completed
and a Chat stream with no finish_reason at all. Run on the Mac mini:
go test ./internal/gateway -count=1 ok. Broken by hand: fallback.go and
gateway.go at the base - TestFinishReasonErrorFailsOver (200, b never
asked) and the streamEvent table red. Not tried: a real WorkBuddy
reply ending so.

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-31 02:00:10 +08:00
ggbdpq d965a239f5 gateway: a litellm relay's "'priority' is not supported for 'service_tier'" is asked again without the tier (#3978)
What changed: refusedOptional's recognizer (unsupportedOptionalField) gains
valueRejectedForField, for a vendor that names the field after the value it
turned away: litellm's "'priority' is not supported for 'service_tier' on
this model", handed to the agent as a plain 400 today, on both shapes the
relay sends — the bare prose (0.1.1330) and the backend's JSON embedded in
litellm's message (0.1.1829, unwrapped by the existing structure-first
walk). The name after "for" is what separates the field's refusal from a
value's ("... is not supported with this model"), which still reaches the
client as it came.

Both readers of refusedOptional take it, so the tier is dropped, the
request is asked again, and the provider isn't sent it again: a relayed
Chat or Responses request that carries the field (#393's path), and the
agent's own request on a provider the user added by its address (OwnTier),
which forwards the tier on purpose (chat.go, responses.go) and asks again
without one that turns the field away.

Run: TestRefusedOptionalNamesOnlyUnsupportedFields gains two rows (the
prose and the JSON-embedded shape, each under the direct, litellm and
openrouter wrappers) and TestServiceTierRefusedForTheValueRetried (a fake
upstream answering the issue's body) fails without the change — turn 1:
400 after 1 calls, want 2 — and passes with it: two tries, the second
without the tier, and the provider marked unfit for it. The value rows
(unsupported-value, tier-value) stay nil/pass. gofmt -l clean; go vet,
GOOS=linux go vet -tags nogui, GOOS=windows go vet ./... pass; go build,
GOOS=linux go build -tags nogui, GOOS=windows go build pass. In
go test -tags nogui ./... every package passes but three tests that fail
the same way on the unmodified base (ba3a7384f) — TestMothX,
TestProxyCheckSaysAProxyPassedBy and TestHostToldTheGatewayAddress, which
are Bun-, proxy- and port-timing-sensitive on this machine; internal/
gateway passes, targeted and in the suite.

Review (magpie): the regex needs a field name after "for", so "is
not supported with this model" still reaches the client as it came
(the table's unsupported-value rows). The tier is remembered unfit for
the provider, every model of it. Run on the Mac mini: go test
./internal/gateway -count=1 ok. Broken by hand: gateway.go at the base
- both litellm rows of TestRefusedOptionalNamesOnlyUnsupportedFields
and TestServiceTierRefusedForTheValueRetried ("400 after 1 calls")
red. Not tried: a real litellm relay.

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-31 02:00:10 +08:00
ggbdpq 460687ff57 gateway: Azure's "invalid encrypted summary" reads as foreign reasoning (#3994)
What changed: a Codex thread the ChatGPT backend served, resumed on a
relay in front of an Azure OpenAI deployment, is refused there with
{"error":{"message":"invalid encrypted summary",...}} - wording the
foreignReasoning table didn't read, so withoutReasoning was never tried
and the 400 reached Codex on every turn of the thread. The refusal is
spelled with spaces, says summary instead of content, and names no item,
so none of the table's branches took it. An alternative
invalid[ _]encrypted[ _](summary|content) now sits beside
invalid_encrypted_content; the named-item reader (unreadableItem) is
untouched, as this refusal names none, which withoutReasoning already
covers by leaving out the whole reasoning set. The ChatGPT-backend
reader (withoutUnreadable) shares the table and takes the same turn.

Run (base f982e46f2, worktree /tmp/magpie-w1d-3994):
- RED (tests kept, internal/gateway/affinity.go reverted to base):
  TestForeignReasoningWords "not matched: {\"error\":{\"message\":
  \"invalid encrypted summary\"...}}"; TestForeignSealAzureSummary
  "first: 400 {\"error\":{\"code\":\"validation_error\",\"message\":
  \"Azure: invalid encrypted summary\"...}}"
- GREEN: go test ./internal/gateway/ -tags nogui -run
  'TestForeignSealAzureSummary|TestForeignReasoningWords|TestForeignSealAcrossGroupMembers|TestForeignSealGrokToCodexAccount'
  -count=1 -> ok (4 tests)
- gofmt -l internal/gateway -> clean; go vet -> ok

Refs #3994

Review (magpie): TestForeignSealAzureSummary now also checks what the
fake deployment was sent - the seal once, then none, and the next turn
one request without it - so "left out up front" is tested, not only
the 200. Run on the Mac mini: go test ./internal/gateway -count=1 ok.
Broken by hand: affinity.go at the base - TestForeignReasoningWords
("not matched") and TestForeignSealAzureSummary ("first: 400") red.
Not tried: a real Azure deployment behind litellm.

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-31 02:00:10 +08:00
ggbdpq 7da972969b provider, gui: a listing's budgets add up, and one provider's fetch models no longer re-lists past them (#4065)
What changed

The budgets a listing of the plugins' providers is made of added up past
the budgets its callers set: the host let one provider spend listWait
(20s) on its models hook plus the wait for a due renewal (RENEW_WAIT,
15s) before it, and a provider with two accounts spent them back to
back. One provider could be allowed 35s (40s with a second account) —
past the 30s refreshDeadline the background refresh asks under and past
the editor's own 20s — so pressing Fetch models, or a refresh, died with
a bare "context deadline exceeded" while no vendor had failed: every
provider is asked side by side, and the sum of the budgets was the only
thing over.

Now the host's own bounds hold by construction:

- host.js info(): the wait for a due renewal (fresh) spends the models
  hook's own budget — the hook is given what is left of listWait, and
  the renewal wait can no longer be added on top of it.
- host.js providers(): a provider's accounts are listed side by side
  (the first no longer waited for before the rest), so one provider
  costs one listWait, not one per account.
- gui/providers.go, case "models": the editor's budget is 30s, the same
  the host bounds one providers RPC with, instead of 20s — shorter than
  even one provider's worst case under the old arithmetic.

A provider whose renewal is slow then lists late (its hook given up on
alone, said so in listError as any other stuck listing) instead of
taking the whole listing past the caller's deadline (#4065).

Run

- TestProviderListCoversAccountsSideBySide, two accounts whose hooks
  each take 3s under a 4.5s caller budget: with the product files at
  the base (68b31ce23) and the tests kept, the listing dies with
  "context deadline exceeded"; with the fix it stands and both accounts
  are listed.
- TestRenewalWaitSpendsTheListBudget, a renewal that never finishes
  waited 15s before a 10s hook given 11s of its own, under a 20s
  refreshDeadline: with the product files at the base the listing goes
  past refreshDeadline and nothing is kept; with the fix the listing
  stands and the provider fell back, its listError saying so.
- internal/plugin full suite (go test ./internal/plugin -tags nogui):
  ok, and gofmt/vet clean.

Review (magpie): the two tests' timings were widened from gua's 1.5s
hooks under 2.5s and a 5s hook under 17s, which left ~1s and ~2s of
room, to the numbers above, so a busy CI box can't turn them red
either way. Run at this head on the Mac mini: go test ./internal/plugin
-count=1 ok (254s); go vet ./internal/gui ./internal/plugin clean.
Broken by hand: host.js put back at the base, tests kept - both tests
red (context deadline exceeded at 6.1s; past refreshDeadline at 35s).
Not tried: the reporter's Windows box with 35 real providers. Left
open: /api/sync, the CLI's refresh and the editor's other Fetch calls
still give a plugin provider's fetch 8s while it lists every plugin
provider; one provider's fetch still re-lists them all.

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-31 02:00:10 +08:00
ggbdpq 50816ce024 library: turning RTK off matches the hook Claude's settings actually holds (#2879)
What changed: taking RTK out of Claude Code now drops its hook entries
from hooks.PostToolUse and hooks.SessionStart in ~/.claude/settings.json
beside hooks.PreToolUse, matching the same "rtk hook claude" mark.

Why: magpie says Claude Code has RTK by searching the settings file
whole for "rtk hook claude", but its remover only looked under
hooks.PreToolUse. rtk 1.0.1's installer writes that command under
hooks.PostToolUse too, when the user's rtk pipeline has after_tool rules
(rtk:posthook; src/hooks/init/claude.rs), and rtk's own uninstaller
sweeps PreToolUse, PostToolUse and SessionStart alike. With an entry
under another event, switching RTK off in the Library removed the
PreToolUse entry, found the command still in the file, and failed with
"rtk's hook is still in Claude" — the reported bug: the row stayed on
and the hook had to be taken out by hand. The user's own hooks under
those events are kept, as the PreToolUse ones already were.

Run: go test ./internal/library/ (ok, 75.6s); the new
TestRTKRemoveClaudeOtherEvents fails on the base with "rtk's hook is
still in Claude Code" and passes with the fix; gofmt -l clean; go vet
clean on darwin, linux and windows; the package builds on all three.

Review (magpie): checked against rtk v1.0.1's own claude.rs, which
writes and sweeps PreToolUse, PostToolUse and SessionStart; the other
agents' single key is unchanged. Run on the Mac mini: go test
./internal/library -count=1 ok; TestRTK* on the Windows box ok. Broken
by hand: rtk.go at the base - TestRTKRemoveClaudeOtherEvents red
("rtk's hook is still in Claude Code"). Not tried: the reporter's ask
to roll the switch back in the UI when a removal fails.

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-31 02:00:10 +08:00
ggbdpq a5ccf3f23f plugins: an update of an unfixed git source re-resolves the branch, not the lock's old commit (#2954)
What changed
- Before Bun resolves a git plugin's spec, the branches and tags of its
  repository are fetched into the bare clone Bun keeps in its install
  cache (refreshGitCache in gitrev.go): best-effort before install's
  bun add (a remote that can't be reached leaves the install to what the
  cache has), an error before reinstall's bun update (an update that
  didn't happen is not reported as done).
- When bun update exits 0 but the plugin is still behind the commit the
  update checks saw the repository at, reinstall says so instead of
  claiming the update.
- A spec that names a commit (#<sha>) is left alone: nothing is resolved
  for one, and its pin stands.
- docs/subsystems/provider-plugins.md: this git update path.

Why
A plugin added from an unfixed git+https://... URL could not be updated
(#2954): plugins/package.json named no commit, but Bun resolves a git
spec through its own bare clone of the repository in the install cache,
whose refs stay at the first install - a fetch there moves FETCH_HEAD,
not the clone's refs/heads. Every resolve after the first, bun update as
much as a bun add after a remove, therefore named the old commit again,
bun.lock re-recorded it (name@git+...#bb961b2...), and the update said it
had installed while node_modules kept 0.1.3. The lock is the record of
that resolution, not its cause. Verified with Bun 1.4.2 (the version
magpie runs) against a local git+file:// repository: after the branch
moved, bun update my-plugin answered "no changes" and exited 0, and so
did bun install with the lock entry dropped, bun update --force and bun
install --force; with the clone's refs fetched, the same bun update
installed the branch's commit now.

Run
go test ./internal/plugin/ -count=1 (ok; new: TestGitUpdateInstallsTheBran
chsCommitNow and TestGitUpdateKeepsACommitPin on the bun on PATH against
a local git+file:// repository, TestGitUpdateSaysWhenItDidnt with the
fake bun keeping the lock's commit, TestRefFixed,
TestSameRepoAndCloneOrigin)
go test ./internal/cli/ ./internal/provider/ -count=1 (ok)
gofmt -l (clean); go vet ./internal/plugin/ on darwin, linux and windows
(ok); builds of darwin and of windows (CGO_ENABLED=0 -tags production,
as the Makefile cross-compiles it) and of the 79 Linux packages that
don't need Linux GTK cgo (the GUI and cli are built natively per machine,
as the Makefile says).

Review (magpie): patch sha256 checked against the issue; read whole.
Run at the batch head on the Mac mini: go test ./internal/plugin
-count=1 ok, the real-Bun git e2e among them (not skipped); on the
Windows box TestGitUpdate* pass. Broken by hand: store.go at the base -
TestGitUpdateInstallsTheBranchsCommitNow ("still at 1.0.0, want
2.0.0") and TestGitUpdateSaysWhenItDidnt red; only install()'s refresh
removed - "installed again: 2.0.0, want 3.0.0". Not tried: a real
plugin from a real GitHub branch.

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-31 02:00:10 +08:00
yetone 0fcb3acb3f gateway: the 24MB CR test reads a mended line (#4256)
TestCRTidyTwentyFourMBLine's "one call mended" case never mended
anything. Its line ended its output array with a trailing comma, so the
JSON could not be read and crTidy passed it as it came. Its want was
strings.Replace(line, `x\ry`, `xy`), but on the wire the escape is
`x\\ry`, so the Replace changed nothing either. Both sides equalled the
input, and the subtest passed while timing a failed parse.

The fixture now joins its items without the trailing comma. The mended
case reads the output back: the line is still one data line, fc_1's
arguments are {"a":"xy"}, and every text item is there. The healthy case
is still compared byte for byte.

Run on mote (macOS), go test -tags nogui -count=1 -v -run
TestCRTidyTwentyFourMBLine ./internal/gateway/:
- the healthy 24MB line ~25ms, the mended one ~280ms (a whole decode and
  marshal, only on glm-5.3-flash* lines that carry a \r escape);
- with crTidy.responses' item mend turned off by hand, the mended case
  is red ("arguments ... want {"a":"xy"}"); it was green on the old
  fixture.
2026-10-31 01:53:21 +08:00
ggbdpq dd279e9314 gateway: the CR a glm-5.3-flash* replica stitches into tool-call arguments
Yetone's review of the two earlier rounds (#4256): the cure changed
healthy replies and cost the relay hot path. This one keeps to the routes
the defect was seen on, and holds a cut escape the way the encoders do:

- The cure runs only on glm-5.3-flash* routes (glmFlash, the way
  grokModel scopes its rule): a relay installs crTidy for those models
  alone, translate sets Request.CR the way it sets Request.Grok, and the
  encoder wrapper crEncoder and the whole-reply pass crResult hang off
  that flag. Another model's reply goes as it came, healthy or not.
- The relay's mends wait per call (crTidy.calls, by Chat's tool_calls
  index, Messages' block index, Responses' item id), so a \r\n cut
  across two fragments arrives as the pair it is; a \r the next
  fragment does not answer with \n is the defect, and goes. A line's
  end is looked for in the new bytes of a read alone, and a region
  without the escape is said from where it lies: a 24MB line in 32KB
  reads costs a scan (23ms here; the round-2 way took 2.45s).
- The events whose delta is an argument are read from the event's own
  type or shape: a text delta that only mentions the arguments' event
  names stands, \r and all.
- A custom tool's raw input (Codex's apply_patch) is read as bytes: the
  CRLF pair is the line ending it says, a lone CR goes.
- The encoders' dropper is said at a call's end: a lone \r goes, a bare
  \ is said as it came (crEncoder.say).

Refs #4256 (kept open for the reporter)

Run: go test -tags nogui ./internal/gateway/... (ok). The healthy
split-CRLF relays of all three protocols, the custom input's, the text
delta's and the scope's tests fail on the round-2 branch and pass here;
unwiring the flag reds the cure tests again.

Landed by yetone on origin/main e2d7d1f54 with the next commit, run on
mote (macOS) at that tree: go test -tags nogui -count=1 -timeout 45m
./internal/gateway/... ok (506s); GOOS=linux and GOOS=windows go vet
./internal/gateway ok. Rebased onto f45c3c96b (usage and site only)
before the push; there go vet and the 25 CR tests pass again. Broken by hand: glmFlash returning false reds the 13 cure tests
and TestGLMFlashScope; a per-fragment dropCR in place of the per-call
seam reds exactly the four healthy-split tests. Timed on a valid 24MB
response.completed line in 32KB reads: healthy 25ms, text with \r\n
161ms, a call mended 281ms. A model outside glm-5.3-flash* gets no
crTidy and no Request.CR (TestForeignModelStitchedStreamGoesAsItCame).
The 24MB test's mended case was vacuous; the next commit fixes it.

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-31 01:53:21 +08:00
yetone f45c3c96b6 usage: a day's first start advances the kept sums from the last cut, not a pairing of all history (#2278)
The page's cells, the heatmap's days and Codex's effort before the last
days are kept on disk (page-v1.json, heat-v1.json, effort-v1.json) under
a key that names the cut, today minus two days at midnight. The cut moves
each midnight, so each user's first start of a day found none of them,
and paired the whole history again three times. On the 240k-row bench
history that peak was 506-538 MB, against 235-325 MB for a start of the
same day.

Each file now also holds the cut and since its sums were counted at.
When the current key misses, the file's sums still stand if the key at
their own cut is the same: the chunks are split again at that cut, named
as heatSettledKey names them, and compared with the file's key. Then
only the chunks of the days since that cut are paired. The rows between
the two cuts are added to the kept sums, and the sum is written under
the current key. The heatmap also drops days before a since that moved
forward a week. A full pairing is left for a first install, a raised
version, or a settled chunk that changed.

settled_version_test blanks a page's cut and since, as it blanks its key
and at. They say when the cells were counted, not how, so
settledCountVersion stays at 1. Files written before this commit have no
cut, so the first day change after the upgrade still pairs everything
once.

Run at 9cd9cfed0 (rebased on cfb06e11c), on mote:
- go test -count=1 ./internal/usage: ok (16.8s)
- GOOS=linux and GOOS=windows go vet ./internal/usage: ok
- gofmt -l internal/usage: clean

New tests (cut_advance_test.go): TestHeatmapDaysAdvanceACut,
TestPageCellsAdvanceACut and TestCodexEffortAdvancesACut. Each holds the
clock at Sunday 2026-10-04, then at Monday, and checks that every
pairing on Monday is below all chunks and that the result equals a cold
pairing. The heatmap test includes a call 368 days back that leaves the
window when the week turns.

Broken by hand:
- With the days between the cuts left out (all three), all three tests
  are red.
- With the advance turned off (all three), all three tests are red on
  the pairing count.

Real history (mote, ~/r2278: 240k gateway rows and the full session
history, window endpoints polled every 5s, clock moved one day by a
temporary build-only env that is not in this commit, caches restored
with cp -Rp each run):
- day change, advance off: peak 506, 518 MB
- day change, this commit: peak 418, 398 MB
- the same day: peak 325 MB
- /api/usage/heatmap and /api/usage/requests were byte-identical with
  the advance on and off.

Not tried: a real overnight day change on a user's machine. The cold
first-install peak (~480-538 MB) is unchanged by this commit.
2026-10-31 01:48:43 +08:00
yetone cfb06e11c3 site: PostHog goes through usemagpie.ai/r/, and downloads are counted
A blocker that knows posthog.com dropped every count of the pages, so the
snippet's api_host is now this site's /r/: relay passes the library and
its config on to PostHog's assets host and the rest to its ingestion
host, with the visitor's address as X-Forwarded-For (PostHog's country)
and without the site's cookies. ui_host stays PostHog's.

Downloads weren't in PostHog at all: /download/* and install.sh are now
counted server-side, as "magpie site download" (link, file, country,
browser or command) and "magpie site install script", each under an id
of its own like the partner counts. A HEAD, or a file the release
doesn't have, isn't counted. The privacy pages (en, zh, ja) say both.

Run: node --test site/worker.test.mjs site/install.test.mjs
site/stable.test.mjs on mote, 48 pass. Broken by hand (no
X-Forwarded-For, the Cookie passed on, the download count off): the
relay and download tests went red. A Playwright page with the snippet
and every posthog.com request aborted (a blocker): Chromium on mote and
WebKit on xiaomi-gpu (mote's WebKit wouldn't launch at load 28) sent
$pageview, $autocapture, $snapshot, $$heatmap and $web_vitals through
/r/ alone, nothing blocked; under GPC nothing was fetched.
2026-10-31 01:46:34 +08:00
yetone e2d7d1f54a gateway: a body still arriving at the 2m cut-off is answered 408, and its read ends
heatonz on Discord (Hermes Agent to magpie v0.1.2237 in Docker): about
half the requests to a nested group were stopped after 2m0s "without
routing it to any provider". The held report's one wait was "body 2m0s
(under way)", and 7 handler goroutines sat in net/http body.Read under
waitedBody, idleBody and readSized.

The body read has its own idle limit: 60s with no byte, renewed on each
byte (idleBody), which answers 408. That limit never fired, so bytes were
still coming in gaps under 60s, and the time added up to unroutedMost
in the "body" wait. The watch then answered 504 and blamed routing, and the
handler kept reading the body after the answer until the body ended or
went idle.

Now, when the cut-off lands while the body is being read:
- the answer is 408, saying the body was still arriving from the client,
  how much of it had come and when the last byte did; OpenAI's and
  Anthropic's SDKs send a 408 again at once;
- the read ends with the answer (deadline now, waitedBody refuses further
  reads), so the connection closes with it;
- the held report says "stopped it with 408" and has a "body read: X of
  Y, the last Ns ago" line, which tells a trickle from a stall.

Not changed: the 60s idle limit. The report shows it never fired, so a
shorter one would not have been sure to catch this case, and an
upload that keeps progressing is the client's, not magpie's. The 2m bound stays,
so a trickling client can't hold a handler forever.

Run (mote, at this head on 505d9f6a2):
- go test ./internal/gateway -count=1 -timeout 45m: ok (870s)
- go vet ./internal/gateway for darwin, linux and windows: ok
- TestUnroutedTrickledBodyAnswered408 -count=5: ok
- gofmt -l: clean
Broken by hand:
- the case u.inBody() turned off (the old code): red, 504 "without
  routing it to any provider";
- the read deadline and bodyStopped taken out: red, the connection ended
  10.2s after the 408.
Also probed, through s.Front() on a real socket with a 500ms idle limit,
each answered 408 at the idle limit, never held to the cut-off:
- headers then a stalled body;
- Expect: 100-continue and no body (magpie sends the 100, then 408);
- a Content-Length 50 bytes past the body sent;
- a second request on a kept-alive connection, stalled or with Expect.
heatonz says it happens with Hermes and magpie on one machine too, so no
network hop is involved. None of those three shapes holds a read for
2m, so the bytes were trickling from the client.
Not tried: Hermes Agent itself; why it sends its body that slowly is
unknown. The next held report's "body read" line will show it.
2026-10-31 01:32:57 +08:00
yetone f03ed8c26e agents: Open in terminal on a Mac's Agents row (coolmantou)
coolmantou on Discord asked to start an agent from magpie's Agents list.
In the Mac app's window, an agent row's menu (openRowMenu, the one the
grip and a right-click open) now has "Open in terminal". This includes a
row under Not set up. Clicking it posts POST /api/agents/open with only
{agent: id}. The server finds that exact id in agent.Detected() (not
agent.Find's prefix match) and builds the line itself: the agent's
Launch() where it has one (agy, Claude Science, Cursor local), otherwise
its program's path, single-quoted (BinPath, new in internal/agent).
openTerminal then opens that line with the user's Session terminal
choice. The command never comes from the page. Other systems, the web
build, WSL agents and desktop apps with no program are refused, and
their rows have no item (agentJSON.terminal). The tray panel's rows don't
have the item either. The label is "Open in terminal", not "Terminal",
because the user's terminal can be iTerm or Ghostty. The string is in
en, zh, zh-TW, ja and de. Windows and Linux are #4474.

The core budget had 39 bytes left on main, so no budget was raised.
Instead:
- the item says nothing on success; the terminal opening is the answer,
  and a failure goes to statusErr;
- the omp roles' comment above OMP_UNSET was cut to what OMP_UNSET's
  values don't already say.
app.js is now 22 bytes under main's size.

Run:
- go test ./internal/gui ./internal/agent on mote (macOS) and in
  magpie-desktop (Linux, -tags nogui), both ok.
  - TestAgentOpenRunsOnlyTheAgent puts claude in a folder named
    "it's a' $(touch made1) `touch made2`; touch made3 #". It posts the
    ids "claude; touch made4", "claude'$(touch made5)'" and "cl"; none
    of them opens anything. It then runs the line made for claude
    through /bin/sh and checks that only the program ran.
  - After the rebase onto origin/main 2604d68db, the core budget
    first went red (1,536,904 > 1,536,586). It passed again after the
    trims above, along with TestAgentOpen* and TestAgentCommand*.
- gofmt -l clean. go vet on darwin, GOOS=linux -tags nogui and
  GOOS=windows for internal/gui and internal/agent: ok.
- GUI, both engines (wsl-run): agent-open-terminal.test.cjs is new,
  14/14 at the pushed tree. It covers every language, a row under Not set up, no item for
  the desktop app, the web build or the tray panel, and checks that the
  post body is the id only. Its goto has 30s, since a goto while
  another suite ran on the box took 5s once. i18n-keys and agent-disconnect pass.
- Real run on mote in a sandbox HOME: the endpoint was called through
  the real openTerminal with an `open` on PATH that records instead of
  opening. It returned 204, and the open args were -a
  /System/Applications/Utilities/Terminal.app <file>. The file was
  -rwx------ and read: #!/bin/sh / '<sandbox>/.local/bin/claude' /
  exec "${SHELL:-/bin/zsh}" -l.

Broken by hand:
- agentCommand returning the path unquoted: the Go test went red with
  "ran more than the agent: [made1 made2 made3]".
- The term item dropped from openRowMenu: the 10 row tests went red.
- The panel and web gates dropped: the 4 gate tests went red.

Not tried:
- No terminal app actually opened. The scratch run recorded what
  `open` would get instead.
- iTerm, Ghostty and the other Session terminal choices were not tried.
- Launch() agents (agy, Claude Science, Cursor local) were not opened
  for real; their lines were already quoted and used by
  "Copy launch command".
- The full Go suite and the whole GUI suite were started before the
  rebase and not waited on (ship at once).
2026-10-31 01:22:28 +08:00
yetone 505d9f6a21 provider: Kiro's mover min is 0.1.22 (plugins#538)
opencode-kiro-auth 0.1.22 sends xhigh and max as Kiro's own effort
levels on a model whose catalog lists them with adaptive thinking
(additionalModelRequestFields, as Kiro IDE sends them), and puts a
trailing system message (Claude Code's environment context) in a turn
before the question instead of into it. npm view --prefer-online gives
0.1.22.

Run (on mote): gofmt -l internal/provider clean; go vet ./internal/provider
for darwin, linux and windows; go test ./internal/provider -count=1: ok.
Not run: the full suite. Two other sessions' full suites were running on
mote, and this change is the min string alone.
2026-10-31 01:21:41 +08:00
yetone 261117363e plugin host: a sign-in again joins its account when an older plugin named it another way (#4473)
officeace-auth 0.1.14 to 0.1.17 kept an account as accountId = the masked
phone ("189****8051") and uid = the Huawei domain id. The CodeArts
plugin's OfficeAce card (plugins#522) names a new sign-in by the domain
id, uid the same. settle joined a new sign-in to an old record only on an
equal account id, so signing in again added a second row (fakeco#xxxxxx)
and left the old one "Sign-in required", holding the user's name, proxy
and gateway keys.

settle now also joins two records with the same uid when one of them is
named by that uid (renamedBy): then the uid is the account's own id. The
joined record keeps the old record's accountId, since the user's name,
proxy and gateway keys are kept by it (#4416), as the CodeArts plugin's
renewals already keep a stored accountId.

The issue suggested joining on any equal uid. That is not safe: Kiro
keeps how an account was signed in to as its uid ("google"), so two
different Google sign-ins share one. The test signs in two such accounts
and checks they stay apart; with a uid-only rule they were joined.

Not covered: a re-sign-in where neither record is named by its uid (a
WorkBuddy nickname changed at the vendor) still adds a row; nothing in
the records proves those are one account.

Run:
- Reproduced first on origin/main's host.js: TestPluginReSignInJoinsAnOldIDShape,
  with the old record as officeace-auth 0.1.14's callback and
  credential.mjs write it (read from the npm tarball), was red: the
  sign-in again went to "fakeco#9oncv2" beside the old record.
- Broken by hand: renamedBy on uid alone -> red (two Google accounts of
  uid "google" joined); joined without keeping the old accountId -> red
  (accountId became the domain id). Green with the fix, and
  TestPluginSameNameOtherUID (#413) still green.
- Full go test ./... -timeout 45m on mote was still running at push
  (pushed without waiting, per the owner's rule); a red it shows that
  isn't on origin/main gets its own issue.

Not tried: a real Huawei Cloud sign-in in a running magpie; the CodeArts
plugin with the OfficeAce card is not on npm yet (plugins#522 is open).
2026-10-31 01:11:31 +08:00
yetone 06d36d4142 gateway: Stays: Session spreads new sessions over the accounts (connor_yang)
connor_yang on Discord: three sessions on one provider's three accounts,
Stays: Session (整个会话), ended up on two accounts. Under Smart routing a
conversation nobody had answered yet went wherever routing put first,
whatever other sessions were on; only In turn counted the sessions each
account holds (leastHeld, #946).

Kept for the whole session (Stays: Session or Strict) under a routing that
picks by what is left (Smart, Least used first, Weekly pace;
spreadsSessions), a new conversation now goes to the key, account or
group member the fewest other conversations of the last 30 minutes are on.
It passes over one routing keeps new conversations off (readyForNew:
resting, an aside key, a fallback while the provider's own model leads,
one used past lowShare), counts leads only, and keeps routing's order on a
tie. A Claude Code subagent's first request goes to its lead's account
(withLead), not to another as a session of its own. An answered
conversation is kept as before, and resting, spent and the rest/quota
fallback are unchanged. In order, By weight, Free first, Speed first,
Cheapest, Manual and plugin routings keep their order. Docs: reference,
gateway-routing, site start.html (en, zh, ja).

Run (mote, at this head on 2604d68db): go test ./internal/gateway -run
'TestWholeSession|TestInOrderKeepsNew|TestSpreadsSessionsOnly|
TestRotateSpreads|Affinity|Strict|Subagent|Lone|LoginSwitch|ChatGPT' ok;
GOOS=linux and GOOS=windows go vet ./internal/gateway ok; gofmt clean.
The full Go suite (-timeout 45m) was started at this head after the push.

Broken by hand: spreadsSessions always false (the old code's behaviour):
TestWholeSessionSpreadsNewSessions red, "s2 went to k1, which s1 is on"
for session and strict. Subagent sent through leastHeld instead of
withLead: red, "s2's subagent went to k1, not s2's k2". readyForNew
without the fallback and lowShare checks: TestWholeSessionSpreadLeaves
TheNearlyUsedAndFallbacks red.

Not tried: real subscription accounts (the tests use three API keys on one
provider, the same candidate path); a group of different providers end to
end (leastHeld's group path is the one In turn has used); the reporter's
exact provider and agent; sessions idle more than 30 minutes no longer
count as holding their account.
2026-10-31 01:05:44 +08:00
yetone 2604d68db0 routing: the live card stays on the request it tells of while others come at once
qiang2040 on Discord ("狂闪", a screen recording): with Codex
conversations sending at once on group/glm-5.3-flash-free and
group/deepseek-v4.1-flash, the Routing page's top card (head, story,
context window) jumped to the newest request on every trace update,
and to "magpie hasn't routed this request yet" for each new one.

told() picks the request the card tells of: it stays on the one it
shows until that one is done, then goes to the newest, and a newer
request routing hasn't picked for yet doesn't take it from one that
was routed. play(), resume(), the live poll and rebuild() use it;
requests that come meanwhile still fly on the stage, without a caption
of their own. Pinned, replay and day views are unchanged.

Run:
- routing-concurrent-hold.test.cjs (new; two conversations interleaved,
  every frame's head watched; en, zh, zh-TW, ja, de): red on the old
  code in Chromium (mote); green on this code in Chromium (mote and
  WSL) and WebKit (WSL).
- Broken by hand: told() returning newest() -> 6 of 6 red in Chromium
  and WebKit (WSL), "the card stays on 101 while it is under way".
- routing-* and panel-routing* in both engines on WSL, against a base
  worktree at origin/main: the reds are the same on base. row-swap is
  red 3/3 on base too (#3799); live-patch's folded sample caught a
  count-up mid-way once (129K vs 130K, the right request; #2174); the
  rest are WSL WebKit reds under #4121.
- go test ./... -timeout 45m on mote: 80 packages ok; internal/gui's
  10 real-window AppKit tests were killed at their deadlines (mote's
  pboard/launchd state, #4125; also #2645, #1936). This change is
  JavaScript only.
- The whole GUI suite (node --test, both engines) is still running on
  WSL at push time; reds it shows that aren't on file get issues.

- At the pushed head (rebased on 59bdd4dbc): the new test 12/12 green in
  both engines on WSL.

Not tried: the real app with several real Codex conversations sending
at once (the test drives a mocked trace). WebKit on the old code
(WebKit can't launch on mote now).
2026-10-31 01:04:08 +08:00
yetone 59bdd4dbc3 routing: a group's pattern members can be put in order by hand (usrname1833)
In a routing group, members a pattern added followed the catalog's
order. The editor gave them no grip or Up/Down, and the gateway tried
them in that order. Now every row gets the same grip, Alt+arrow and
Up/Down that named members have. Matched rows still have no Remove,
since the pattern decides those.

The order is stored as Group.Placed, keyed by provider/model as Members
spells them. It is nil while the order equals the default (named, then
matched in catalog order), so existing groups.json files don't change.
Read (withMatches -> placedIn): members follow Placed. A model matched
since goes after them, and one no longer matched drops out. The gateway
tries members in the order the group is read, so it follows the editor.
Saved (SaveGroup -> placedOver): Members orders the named members, and
Placed (sent, or the stored one when a save doesn't send it) places the
matched ones. A save that doesn't know Placed (card routing, the CLI's
models+=, TUI, import) keeps the matched where they were, and a model it
names newly goes after the last named one. A provider rename, fold,
group rename and RenameMember carry Placed along.

Run:
- go test -timeout 45m -count=1 ./... on mote: 80 packages ok.
  internal/gui fails 10 AppKit window tests at 30s (TestDockJoinLeadsCommandTab,
  TestPanelCloseHidesIt, TestMainWindowCorners, ...). On a fresh origin/main
  cf9ea977c the five I reran fail the same way. That is mote's #4125 (open).
- TestGroupPatternMembersKeepTheirPlace is red on the old code
  (read [zen/y or/a:free or/c:free]).
- Broken by hand, each red at its own step: no stored-Placed fallback
  ("after a named-only save"), a newly named model put last instead of
  after the last named one ("after an add"). On the earlier draft, no
  rename mapping ("after a rename").
- GUI: group-member-drag and group-patterns in chromium and webkit on
  Linux (wsl-run), 8/8 at this head. group-member-drag was red on the old
  client.js. The whole GUI suite ran at the draft before the save
  payload's `placed` field. It was still running when this was pushed,
  and its reds will be filed once it ends.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet of provider and
  gateway on mote.

Not tried: a real account or the real app's window; WebKit on macOS
(mote's browser launches hang, #4125), so WebKit only on Linux. The TUI
has no way to reorder matched members; it keeps the stored order.
2026-10-31 01:02:35 +08:00
yetone a45a0f1c5d signin: Settings can keep sign-in pages out of the default browser (max2020)
max2020 on Discord signs in from a separate, fingerprint browser so the
vendor never sees their default one. Every waiting sign-in already shows
its link with Copy link (since 52c8e838d), but magpie still opened the
page in the default browser first.

Settings › Privacy › Sign-in pages › "Open sign-in pages in the browser",
On by default, so nothing changes unless it is turned off. Off
(settings.SignInLinkOnly) opens nothing: /api/signin and
/api/plugin-signin go through openSignIn, which skips the open and
answers linkOnly; a web tab skips window.open on linkOnly, after an
install step too; the box says the page wasn't opened and its button
reads Open, not Open again. `magpie accounts add` and a plugin's
command-line login print the link without opening it. A plugin whose own
CLI opens the page (Grok Build on macOS and Windows, opened) still does.

Callbacks, by flow: Claude Code's login, Codex (localhost:1455), ChatGPT
API, Gemini/Antigravity and localhost plugins come back to this machine,
so another browser on it finishes them, and the pasted final address
covers one whose proxy keeps it off loopback. Copilot, Grok and other
device-code flows work from any browser.

Run:
- TestSignInLinkOnlyOpensNothing (new; built-in and plugin sign-in, the
  setting on and off) with TestPluginSignIn*, TestSettingsSave*,
  TestCoreScriptBudget and TestI18n* on mote: ok. Budget holds with no
  raise (app.js 1,313,244 of 1,315,316).
- signin-link-only.test.cjs (new; every language, Chromium and WebKit,
  900 and 360px), signin-link and account-discovery on WSL: 42/42 and
  the neighbours green.
- Full Go suite on WSL (go test -timeout 45m ./...): every package ok
  except internal/agent's TestInstalledVersion, TestGrokInstalled,
  TestOmpDetectedWithPiDir and TestZedAppPath, red the same on
  origin/main 387e8572a there (#4033, #3548); root, internal/cli and
  internal/gui need gtk4 there and were run with -tags nogui: ok.
- gofmt; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: clean.
- The whole GUI suite (both engines) is still running on mote at push
  time; reds it shows that aren't on file get issues.

Broken by hand: openSignIn ignoring the setting made the Go test red
("built-in: kept to its link, its page was opened 1 times"); dropping
startSignIn's linkOnly check made the GUI test red ("no page opened",
12 of 42).

Not tried: a real vendor sign-in from a fingerprint browser; Grok on
macOS/Windows still opens its own page; MCP server sign-ins unchanged.
2026-10-31 01:02:24 +08:00
yetone 3b5dccd527 accounts: a plugin account goes by its usage's name, not its id (#4416)
A Huawei Cloud CodeArts account is kept by its accountId, an IAM id
(iam::<domain>:user:<name>), and every list showed that id while its
quota card showed the masked phone the plugin's usage() names it by.
Display only: an account now reads as the name the user gave it, else
the `user` its plugin's last usage read gave (PluginUserOf: the
in-memory read, else quotas.json), else its id. The id stays the key
everything is kept by; nothing stored changes or migrates. A read that
fails keeps the last good name; nothing read yet is the id, never blank.

One rule in provider (AccountShown, AccountShownOf, AccountLabelOf),
used by every list: cards' Alias (Usage page, tray panel,
/v1/magpie/quotas, magpie quota), magpie accounts, magpie providers,
the TUI's Providers rows and quota titles, usageapi's Account filter,
the quota alert. The GUI gets it as /api/providers' accountUsers
(accountShownOf in app.js): the editor's account rows (the id in the
tooltip), the per-account proxy lines, Routing's userShown, the
Providers search, Hide accounts. app.js's account lookups share one
helper, so the core stays in its budget (1,536,561 of 1,536,586), with
no room added.

Run:
- go test ./... -timeout 45m on mote at 2f5a3f1c0 + this change: all ok
  but internal/agent TestPiModelsAskedOnTheirNativeAPI (fixed on main
  by 7474a86f1, green there; this is rebased onto it),
  internal/update TestRelaunchOpenTriedAgain (#3881, green alone x3),
  and internal/gui's real-window AppKit tests (TestPanelCloseHidesIt,
  TestMainWindowCorners, TestTrayCellClickReleasedPanel red the same
  on origin/main 99ad38b7c; #2645, #4125, #1936).
- go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet of the
  touched packages; gofmt -l clean.
- TestPluginAccountShownByItsUsageUser (new, real plugin host and fake
  plugin): id before a read, phone after, phone after a restart from
  quotas.json, phone kept over a failed read, own name wins, id when
  nothing is known. Red on the old code.
- GUI on the Linux box (mote's Chromium segfaults on these pages on
  origin/main too, #4125): account-plugin-user (new),
  routing-account-name (extended) and account-alias, Chromium and
  WebKit, every language, 34/34; the new checks red on the old code;
  the whole suite (make test-ui on the Linux box) was still running at
  push: 417 files in, 5 reds, none on a page this changes
  (account-models' row-moved check in WebKit, 81 vs 79px, and
  agent-models-all-hidden), not yet compared with origin/main; any
  that are new get an issue once it ends.
- At the rebased head (3bce283df): go test of provider, cli, tui,
  usageapi, plugin, agent -run TestPi, gui -run
  Budget|Provider|Quota|Account: all ok. Core scripts 1,535,513 of
  1,536,586.

Broken by hand: dropping the quotas.json fallback turns the test red
at "after a restart".

Not tried: a real Huawei CodeArts account (none here). A plugin whose
windows are all model pools isn't kept in quotas.json, so after a
restart it shows its id until its first read.
2026-10-31 01:01:49 +08:00
yetone 0621e70fb9 routing: leave a provider out of the groups magpie finds
chenxiang0010 on Discord asked to keep a provider or a model out of the
auto-created routing groups. A model could already be kept out (remove
its found group; magpie keeps it removed), but a provider could only be
turned off per group or everywhere. Now Routing -> Groups, under "Find
groups on their own", has "Leave out a provider..." (app menu, saved
when it closes) and `magpie group auto skip <provider>...|none`. The
providers chosen (providers.json autoGroupSkip) join no found group; a
group the user made or changed keeps them, a found group left with one
provider goes away, and a request for it is served by AutoStandIn from
a provider still in, and agents on it are reseated (agent.Reseat). A
rename carries the id along. en, zh, zh-TW, ja, de.

Run at 383947fce (this change on origin/main 2ff75161d):
- go test -timeout 45m ./... on mote: 80 packages ok; internal/gui red
  only in its real-window AppKit tests (TestDockJoinLeadsCommandTab,
  TestPanelCloseHidesIt, TestMainWindowCorners, ...), which fail the same
  on fresh origin/main 2f65a33aa on mote (#4125, #2645).
- gofmt -l clean; go vet ./... on Windows (win-run) clean; on Linux
  (wsl-run) clean with -tags nogui (the WSL distro has no gtk4).
- GUI: group-found-skip (new) and group-found-off, all five languages,
  1100px and 390px, Chromium and WebKit on Linux (wsl-run): 24/24. On
  mote every WebKit launch times out (#4125), Chromium 12/12 there.
- The routing files the full run flagged (concurrency 6) rerun alone on
  wsl-run, here and at fresh origin/main 380032cda: click-scroll's
  WebKit case and group-morph's WebKit 420px cases fail the same on
  origin/main. group-duplicate's de case was mine: the found groups'
  new "Anbieter ausnehmen..." line made German taller than the test's
  420x1200 window, which it assumes needs no scroll; it now uses 1400
  and passes 10/10 in both engines.
- Whole GUI suite on wsl-run, concurrency 6: still running at push time
  (5092 ok, 170 not ok so far, mostly in files this change doesn't load:
  account-*, agent-*, connect-*, gui-de/gui-ja's "{agent}" placeholder
  string). They are compared against origin/main after the push.

Broken by hand: foundGroups without unskipped -> TestAutoGroupSkip and
TestGroupsSkip red. Test calls before the fix to groupCmd's args ->
TestGroupAutoSkip red.

Not tried: the real app with real providers; a model-level skip (a
model is kept out by removing its found group, as before).
2026-10-31 00:57:21 +08:00
yetone 31728e29a8 routing: the German connection-check note names {agent} as often as the English one
The sibling of ec5571d6f's ja fix: da3c5e0c0's de string for "{agent}
checked that magpie answers ..." had a third {agent} too, so gui-de's "de
has every zh string, with its placeholders and tags" was red on main. "Das
Modell dieser Prüfung wählt {agent} selbst" now reads "wählt es selbst";
the sentence opens with {agent} already. zh and zh-TW had two.

Run: wsl-run gui-de, gui-ja, gui-zh-tw, i18n-keys: 13/13; gui-de alone
before this change: red, this test. Found in the whole GUI suite run
after v0.1.2228 (ec5571d6f was checked with gui-ja only, and missed it).
Not tried: a German speaker's read of the wording.
2026-10-31 00:54:52 +08:00
yetone 65c7924108 cli: TestProviderAddressMovesALocalServer adds LM Studio in a folder of its own
The test added lmstudio in the package's shared config folder, so a
second run (-count=2 and up) found it there, added "LM Studio 2"
instead, and read the old provider back at localhost🔢 red on
origin/main 380032cda at -count=3, runs 2 and 3. It now gets its own
HOME, USERPROFILE, XDG_CONFIG_HOME and XDG_CACHE_HOME, as the other
provider tests in the package do. HOME alone was tried first and stays
red: the config folder comes from XDG_CONFIG_HOME, which testenv sets
for the whole package.

Run at this head, on mote: go test ./internal/cli -count=2 ok (53.8s);
-run TestProviderAddressMovesALocalServer -count=5 ok; gofmt -l clean.
2026-10-31 00:53:27 +08:00
yetone 380032cda1 providers: Send requests unmasked is the user's switch at any address, with a caution while on for one not local (AcMilan)
AcMilan (Discord) runs a vLLM at http://llm.corp.lan:8000, and the
editor never offered "Send requests unmasked": the switch showed only
for a localhost, *.local or private-IP address. Asked, he said the
choice should be the user's for each provider.

provider.SkipsRedaction is now: Unredacted, no signed-in account, not
another magpie, and at least one address. Nothing is looked up on the
request path. The editor shows the row for every provider but an
account or remote magpie. While it is ticked, an amber caution under it
names an address not on this computer or the local network (awayHost).
A name of the user's own DNS is asked about, only while ticked, through
POST /api/local-hosts (provider.LocalHost -> netproxy.LocalName: every
address loopback, private or link-local, 400ms lookup, kept 1 minute).
That answer only words the caution. CLI help and `provider show` say
the same. The 'away' i18n line is in zh, zh-TW, ja and de. To stay
inside the core script budget, a few nearby editor comments were cut
down (no raise).

Run (logs in the worktree's logs/):
- Full Go suite on mote at base 024393fbb (go test ./... -timeout 45m).
  Every package is ok except internal/gui. Its reds are the AppKit
  window tests (#4125, #2645, #1936, #3949, #3178) and
  TestRestartHandsTheGatewayOver (#4167), plus TestCoreScriptBudget,
  which was mine and is fixed. At the pushed head (rebased on
  995f84a0f): the gui, provider, netproxy, gateway and cli tests for
  this area, with TestCoreScriptBudget and TestI18n: ok.
- GOOS=linux go vet -tags nogui ./internal/... and GOOS=windows go vet
  on the touched packages: ok. gofmt -l is clean.
- provider-unmasked.test.cjs and decide-endpoint-label.test.cjs: 34/34
  in Chromium and 34/34 in WebKit (Linux, wsl-run), on the final app.js.
- The 155 GUI files that open a provider editor, both engines (WebKit
  on Linux, Chromium on mote). Each file red there was rerun on Linux
  beside the base 024393fbb. The one red this change caused was
  decide-endpoint-label: a /api/local-hosts fetch cut off by navigation
  showed as a console error. That is why names are now asked only while
  the switch is on. The rest are red on the base too and have issues
  (#4431 and others). mote's browsers were crashing (#4125), so
  Chromium was compared on Linux.

Broken by hand:
- The old local-only gate put back in SkipsRedaction: TestSkipsRedaction
  (lan name, vendor, public IP, own proxy) and
  TestLANNameUnredactedProvider went red.
- awayHost returning "": 12 caution tests went red.
- The "only while on" guard removed: 4 "nothing is asked while the
  switch is off" tests went red.

Not tried: a real LAN DNS server, or AcMilan's own setup; WebKit on
macOS (mote's WebKit can't launch, #4125); the Windows app; the whole
GUI suite beyond the provider-editor files.
2026-10-31 00:44:59 +08:00
yetone 995f84a0f9 codex: how early an expiring reset is used is a setting
A Codex reset card that would run out unused was spent 30 minutes before
it expired, a fixed resetExpiryLead. Now the lead is codexResetLead in
settings.json (minutes, 15 to 1440). Unset, out of range or unreadable
reads as 30m, never 0, and magpie never writes it unless the user does.

- settings: CodexResetLead and Settings.ResetLead(); the menu's values
  are 15m, 30m (default), 1h, 2h, 3h, 6h, 12h, 24h.
- provider: the spend (expiringResetSpent) and routing
  (Allowance.Restarts, through nextResetLook) read the same resetLead(),
  so they still agree (#717, #718). The "near" look cadence follows it:
  lead + 30m, at least 1h, so a look lands inside a long lead.
- GUI: Settings > Usage, under the Codex auto-use rows, a row "Codex:
  how early before one expires" with an app menu (no <select>), and the
  sub text says spending earlier loses what the windows have left. The
  four "before it expires" strings say the chosen lead. POST
  /api/settings/codex-reset-lead; the general save keeps the field.
  en, zh, zh-TW, ja, de.
- CLI: magpie quota auto-reset lead [30m|3h|<minutes>|default].
- app.js budget: the auto-use rows moved out to lazy autoresetown.js
  (painted in the same draw once loaded), so app.js and the core script
  stay under their budgets with no raise. The button sizes to its widest
  label (a grid of every label), so picking one never rewraps the row.

Run (all on mote through mote-run):
- go vet: darwin, GOOS=linux -tags nogui, GOOS=windows; nogui build.
- go test -tags nogui -timeout 45m ./... at 3955adccf (this change
  before the paint and sizer fixes, which touch only GUI assets): 81 ok.
  go test ./internal/gui at this head: ok.
- GUI, Chromium: codex-reset-lead, codex-auto-reset,
  codex-auto-reset-settings, segs-press-redraw, i18n-keys: 62/62.
  WebKit: every case of those files failed at browserType.launch
  (180s timeout) before a page loaded, both runs; mote's browser
  launches hang under #4125 (load ~26), so WebKit is not run.
- Rebased onto f7f2d75f2 (old-webkit's lazy list now has traywindows.js
  too): go build ./..., go vet -tags nogui ./internal/..., go test
  internal/gui (budgets included), cli, settings, gateway: ok. provider:
  ok but TestQuotaSpanCarriesEveryWindowField, red on main since
  7d4a63148 (#4457, fixed in ccbefe2a2). GUI old-webkit, i18n-keys,
  codex-reset-lead in Chromium: pass.
- Rebased again onto 62a1dcdd7 (clean): go test internal/gui (budgets)
  and internal/provider: ok; i18n-keys and Chromium codex-reset-lead
  12/12 pass; old-webkit 9/10, its Safari 15.0 case a WebKit launch
  timeout (#4125).

Broken by hand, each went red:
- resetLead() pinned to 30m: all 3 provider tests.
- resetExpiryNear pinned to 1h: the long-lead look test.
- ResetLead's range check turned into m == 0: TestResetLeadUnreadIsDefault.
- GUI resetLeadMinutes returning 30: codex-reset-lead in every language.
- The button without the sizer: de at 420px, "no click moved the page".

Not tried: a real Codex account spending a card at a non-default lead;
Windows and Linux runs (vet only). The whole GUI suite in Chromium on
mote has ~45 tests in 31 files crash with "browser has been closed" on
untouched origin/main c84c3e1c0 too (reducedMotion files, #4458).
2026-10-31 00:41:29 +08:00
yetone b889ffe813 library: a server can stay each agent's own entry with the MCP hub on (#4382)
cuipengcx90's #4382, Option A's first step (nifengfanpan asked on
Discord): with the MCP hub on, every Library server went behind magpie's
one entry, so a server that reads its project from the folder it starts
in, or keeps a session's state, resolved the wrong repository or shared
state across agents. A server now has a hub policy, Server.Hub ("hub" in
library.json): "" (shared, the default, so nothing changes for existing
users; "shared" is saved as "") or "direct". A direct server is left out
of the hub through inHub, the test that already keeps magpie's own image
server out, so each agent given it keeps its own entry written as with
the hub off, beside the hub's entry for the rest. An agent whose every
server is direct gets no hub entry. The hub neither lists nor runs a
direct server, at /mcp/magpie/hub either, and hubPrune ends one it held.
Switching goes through change(), so the agents are written again at once
and the entry from the other policy is removed. An unknown policy is an
error.

- GUI: with the hub on, the server editor has a "Through the MCP hub"
  switch (role=switch, not a <select>; not shown with the hub off or for
  the image server), a direct server's row has a "Not through the hub"
  tag, and the hub's line and the Connect sheet name the direct servers
  with the image server as given directly. Strings are in zh, zh-TW, ja
  and de ("MCP 聚合" as the core uses it).
- CLI: magpie library mcp hub <name> shared|direct (ServerHub), and
  magpie library marks a direct server.
- TUI: an edit keeps the policy.
- Not done: Option B (per-roots/project backends behind the hub, keying
  hubPool by roots). It is left for later; #4382 stays open for it.

Run:
- TestHubDirectServer (internal/library) and the extended
  TestLibraryMCPHub (internal/cli) on mote. Broken by hand: inHub back to
  !isSelf(s) makes TestHubDirectServer red ("codex with the hub on:
  [magpie], want [index magpie]").
- Real configs in a sandbox HOME on mote (fake claude on PATH, the real
  binary built from this tree): mcp add index + web for claude and codex,
  hub on, hub index direct, shared, then both direct. The direct index
  entry was in .claude.json and .codex/config.toml beside magpie's; with
  every server direct both files were byte-for-byte as with the hub off
  (json.tool diff and diff); shared again removed the index entry.
- Full Go suite (-tags nogui -timeout 45m ./...) on mote at this tree
  rebased on origin/main 72ed121fd: 81 packages ok. Before the rebase
  the only red was TestQuotaSpanCarriesEveryWindowField (#4457, fixed by
  ccbefe2a2). GOOS=linux and GOOS=windows go vet clean, gofmt clean.
- GUI on WSL (magpie-desktop; mote's GUI is broken, #4125), both engines,
  every language: the new mcp-hub-direct.test.cjs (1100 and 390 wide,
  hub on and off), library-mcp-hub, mcp-local-server, i18n-keys: 88 pass.
  Broken by hand: not sending hub in the save makes mcp-hub-direct red
  (11 of 11 in chromium).
- The 54 library/mcp/i18n GUI files at --test-concurrency=4 on WSL at load
  ~160: 978 of 988 pass. Red: library-chip-fan (webkit, fan positions),
  library-mcp-tools (chromium ja 420, "the click scrolled the page") and
  mcp-oauth-app (chromium de 390). None of them touch the hub switch or
  the editor's new field. They are being rerun alone, here and on
  origin/main, after this push; a red that only this change has is fixed
  next, and a red on main too is filed.

Not tried: the whole GUI suite (1028 files); a real cwd-sensitive
server in a real agent session; the live app window.
2026-10-31 00:34:45 +08:00
yetone 62a1dcdd79 usage: a start's log blocks are of log-v1.bin's pages, not the heap (#2278)
logDiskRead read log-v1.bin whole with os.ReadFile, and the kept blocks'
Archives were slices of that copy, so a 240k-call history held ~7 MB of
file bytes in the heap for good. GOGC then let the heap grow by about as
much again. Where the system maps the file, the blocks are now of its
pages, the same way requests-v1.bin's blocks already are (diskMapping,
readMapped, m.read()). Elsewhere it is read into the heap as before.

Run at the pushed head, on mote, through mote-run:
- go vet ./internal/usage: ok. GOOS=linux and GOOS=windows go vet
  ./internal/usage: ok.
- go test ./internal/usage: ok. go test ./internal/usageapi: ok.
- New TestLogDiskBlocksMapped: 2 full blocks plus a tail are written,
  the log is restarted and read again, and each full block's Archive
  must be inside the mapping. Broken by hand (c.mapped = m dropped): red,
  "block 0: read from the file into the heap". Green again restored.
- go test ./internal/gui: FAIL on the AppKit window tests only
  (TestDockJoinLeadsCommandTab, TestPanelCloseHidesIt,
  TestMainWindowCorners and 7 others), killed at their deadline on mote
  under load ~24. These are #4125 and #2645, and the same tests fail
  without this change.

Bench on mote, with the real 240k-row history: a warm restart while
the Sessions tab polls, and the heap profiled at 200 s.
- In use: 174.1 and 175.0 MB with this change, 187.6 MB without.
- Footprint at 200 s: 290 and 297 MB with it, 297 MB without. mote's
  load (~24) makes this ±20 MB, so the footprint gain is not resolved.

Not tried: Windows, where the file is still read into the heap.
2026-10-31 00:28:43 +08:00
yetone 4a440560b9 gateway: an image server file link opens without a header, by its own signed token
dhanyqaz on Discord (gateway in Docker on a VPS behind a tunnel, one
gateway key per client): the Image MCP server's file URL
/mcp/magpie/image/files/<name> opened only with the key that made it, so
a link a model relayed to a person was always refused in a browser (no
key 401, another key 404).

The URL handed out now carries ?t=<exp>.<sig> (imageFileToken):
HMAC-SHA256 of the file's name, its expiry (the same hour) and the making
key's id, under a secret made at the first file and kept only in memory,
so a restart, which loses the files, loses the links. It names neither
the key nor its id. lanGuard lets a keyless GET or HEAD of a file path
with a t through (imageTokenAsked), after the allow list and sharing are
judged; imageMCPFile serves it only when the token is that file's,
unexpired, and its key still on (access.On, read outside the store lock).
Anything else is the 401 a keyless request gets; a wrong key with a
token is still 401, a web page's Origin still 403, POST still refused,
the header-key path as before. Rotating a key keeps its id, so its links
stay good for the rest of their hour (they never held the secret);
turning it off or removing it ends them at once. The URL's base is
imageMCPBase as before (MAGPIE_PUBLIC_URL, else the request's host).
Docs: gateway-routing.md's image server section.

Not changed: generate_video's /v1/videos/<id>/content still needs the
key; same class, filed as #4462.

Run at fe3ad3917 on mote: gofmt -l clean; GOOS=linux and GOOS=windows
go vet -tags nogui ./... ok; go test -tags nogui -count=1 ./internal/gateway/
./internal/access/ ok (497s, 2s). New TestImageMCPFileLinkOpensWithoutKey;
TestImageMCPGuarded and the draws test now check the bare URL keeps the
old rules.

Broken by hand (red each): no lanGuard pass-through (no header -> the
reporter's 401); no expiry check (an expired token opened it); no
key-on check (a turned-off key's link opened); key id left out of the
HMAC (another key's token opened it). Dropping the handler's own
sharing check stays green: lanGuard refuses unshared first, so it is
defence in depth only.

Real run (before the rebase, same change) on mote: sandbox HOME, fake
upstream on 3561, magpie serve on 0.0.0.0:3562 with MAGPIE_PUBLIC_URL,
an image made through the MCP generate_image call. The tool gave
https://<public>/mcp/magpie/image/files/<name>.png?t=…, no key in it.
curl to the LAN address and with a tunnel header: link, no header 200
(bytes = upstream's PNG), HEAD 200, another key + link 200; bare URL:
own key 200, no header 401, other key 404; tampered sig, moved expiry,
token on another name, POST, wrong key + link 401; foreign Origin 403;
after `gateway-key remove` 401.

Full suite not run at this head; runs after push.
Not tried: a real browser click, and the reporter's Docker + tunnel
setup itself (the tunnel was a forwarding header).
2026-10-31 00:27:25 +08:00
yetone 482e883142 update: a Windows magpie on the Desktop leaves no magpie.exe.new or magpie.com there
nianshou5 on Discord (#help, Windows): magpie.com and magpie.exe.new
showed on the Desktop and came back after being deleted. Both were
written beside magpie.exe:

- magpie.exe.new is the update the GUI downloads as soon as it is out
  and swaps in at the next restart. StageBinary put it beside the
  program whenever that folder was writable, so it sat on the Desktop
  until a restart, and a deleted one was downloaded again by the next
  check.
- magpie.com (#3737) is written at every start while the app's folder
  is on PATH, and Settings > Command line's Add puts that folder on
  PATH, so deleting it on the Desktop lasted until the next start.

Now:

- StageBinary downloads into magpie's cache, in a folder of this
  program's own (update/<hash of the exe path>), when a rename from
  there reaches the program's folder (renamesInto, a real probe: the
  swap must stay one rename on one volume). With the cache on another
  volume it goes into a hidden .magpie-update folder beside the program
  (FILE_ATTRIBUTE_HIDDEN on Windows). A folder magpie may not write is
  unchanged (cache, moved in as administrator). The stage folder is
  removed after the swap or a failed download.
- At start RemoveStaleNew looks in every place a download may be,
  magpie.exe.new beside the program included, and removes one no newer
  than the running version (same bytes, or an older file version); a
  newer one stays, as before.
- Settled (the installed copy opened from a Desktop/Downloads one)
  also removes the update downloaded for that one, which nothing will
  put in now.
- In a download folder (Desktop, Downloads, a temp folder, as
  isDownloadFolder already says) a start only keeps an existing
  magpie.com up to date and never writes a missing one; Add still
  writes it. Any other folder on PATH is as before. A Desktop
  magpie.exe that opens the installed one (Settle) already wrote none.

Run:
- Windows (win-run, xiaomi-gpu, sandbox HOME from testenv), a repro
  test with the running test binary standing for magpie.exe on a
  Desktop on PATH: at origin/main 72ed121fd StageBinary staged
  test.test.exe.new beside it, and magpie.com came back after delete +
  start; with this change the download was in
  AppData\Local\magpie\update\<hash>\ and magpie.com stayed gone.
- Windows: a real program (whoami.exe) staged into the cache passed the
  real trial start (canStart) and was swapped in for a Desktop
  magpie.exe with the real moveAside/moveIn; the stage folder was gone
  after.
- At the pushed head (rebased on d6beb9975): go test ./internal/update
  on mote and on Windows: ok. Before the rebase also on Linux (wsl-run). gofmt, go vet ./internal/update (darwin, linux, windows),
  GOOS=windows go vet ./internal/gui ./internal/cli: clean.
- go test ./internal/gui ./internal/cli on Windows: TestUpdateThatWontStart,
  TestLodyImportHandoff, TestImportStatusUnreadableIsUnknown,
  TestAionUiImportRow (#4115), TestGatewayHeldByAContainer (#2107,
  #3649) and TestLibraryMCPHub (#4140) red, the same 6 when run at
  origin/main 72ed121fd.
- Full suite on mote (-timeout 45m): started at the pre-rebase tree
  (same update changes, base 72ed121fd) and still running at push; its
  result and any red go in a follow-up.

Broken by hand: staging back beside the exe, the download-folder rule
in EnsureCompanion off, removeStaged out of Settled: the new tests
(TestUpdateStagedOutOfTheProgramsFolder, TestUpdateStagedHiddenWithoutTheCache,
TestStartClearsAnOlderDownloadBeside, TestNoCompanionPutBackOnTheDesktop,
TestSettledClearsOnlyMagpiesFiles, TestNoCompanionBesideAForwardingDownload)
went red.

Not tried: a real GUI self-update of a release build on the Windows
desktop, a cache and Desktop on separate real volumes (the hidden
fallback was tested with no cache), the reporter's own machine, and a
real terminal's `magpie` (unchanged code outside download folders).
2026-10-31 00:21:26 +08:00
yetone d6beb9975a agent: T3 Code gets magpie on Codex too, picked in T3's model picker
karissasel_ on X: T3 Code through magpie could only run Claude Code; the
harness couldn't be chosen. T3 runs a thread on the driver of the provider
instance its model is picked under, and magpie wrote only a claudeAgent
instance. It now also writes `magpie-codex` ("magpie · Codex", driver
codex) in ~/.t3/userdata/settings.json. Its config.launchArgs (T3's
CodexSettings key, passed to `codex app-server`, and its -c pairs to
`codex exec`) are Codex's own -c overrides: model_provider=magpie, the
same model_providers.magpie table codex.go writes, and model_catalog_json
pointing at magpie-codex-models.json beside settings.json. Values are
quoted for T3's tokenizeCliArgs. ~/.codex/config.toml is not written. A
binaryPath/homePath the user gave T3's own codex instance is carried over.

The user's name, on/off and unknown keys are kept; launch args and catalog
are magpie's, and Check says when they no longer reach the gateway
(the base_url read back through T3's tokenizer; a reverse proxy to magpie
the user put there counts, reachesMagpie, as for every agent). An
older Claude-only wiring gets the instance once on Sync; one the user
removed stays removed (stash t3code.codex) until magpie is turned on for
T3 again. Turning magpie off removes both instances and the catalog. The
option's note says where to pick (4 languages); reference.md and
agent-wiring.md describe it.

Run (on mote, the tree as committed):
- real end to end, sandbox HOME (~/t3e2e/home): settings written by this
  code, magpie serve on 127.0.0.1:47811 with a fake Responses upstream,
  T3 Code server 0.1.5 (npm t3) and @openai/codex 0.165.0.
  `t3 thread start . "Reply with the word pong." --provider magpie-codex
  --model fake/fake-model --wait` answered PONG-T3-CODEX; the upstream saw
  POST /v1/responses, model fake-model, stream true, with the provider's
  own key (sent by magpie's gateway).
- go test -tags nogui ./internal/agent -count=1 -timeout 45m: ok
- gofmt -l; go vet (darwin, GOOS=linux, GOOS=windows) ./internal/agent
- node --test internal/gui/tests/i18n-keys.test.cjs: ok

Broken by hand, each red then restored: no escaping in t3Arg
(TestT3CodeCodexInstance red); Sync without t3CodexSync (both new tests
red); no stash check (TestT3CodeCodexInstanceAddedOnce red); t3CodexOff
never reporting (TestT3CodeCodexInstance red). The first full run
was red in TestReverseProxyIsStillMagpie, Check comparing the launch
args by string; that red is the break for the proxy rule.

Not tried: T3's desktop app window (the server CLI is what it runs); the
Windows quoting on a Windows box; a real vendor upstream (fake one only);
T3's other drivers (cursor, opencode, pi, grok, ...), which are off by
default in T3 and not wired.
2026-10-31 00:11:10 +08:00
yetone b5aa56e42d providers: a model test fails fast on an unreachable host and can be stopped (RIck)
RIck (Discord #feedback): after pressing 测试模型, the error took too long
to show, and the test couldn't be cancelled.

Fail fast. Each probe now has 10s (connectWait) to get a connection,
traced through httptrace's GotConn. If it doesn't get one, the error says
"couldn't connect to <host> in 10s". In the past a refused, unresolved or
silent host waited out the whole 20s probe, or TLS's own timeout, once for
every model. TestModels keeps the hosts it couldn't reach for the run
(withUnreached). Once one model on a host fails to connect, the rest of
that host's models fail at once with the same error, so they don't each
wait 10s in turn, four at a time. The 20s per-probe bound and the GUI's
3m/25s bounds are unchanged. A stream that breaks off before the model
answers is now a failure ("the stream broke off before the model
answered"), not a long wait. Plugin and account transports don't get the
connect bound, since they dial for themselves.

Stop. While a provider has a test running, its Test models button (the
model editor), its endpoints' Test, and a chip's own right-click test all
read Stop (停止 / 停止 / 停止 / Stoppen). Pressing Stop aborts the fetch
and posts provider/teststop with the run's token. The handler keeps each
run's cancel in testRuns, so the vendor's request ends on the server too.
This matters on WebView2, where a fetch abort never reaches the request's
context. The status line then reads "Test stopped". Every entry point goes
through one helper (provTest, testButton), so they behave the same.

app.js fits its budget with no raise. The helpers are compact, and three
comments in the editor's Fetch models were cut down.

Tests:
- TestTestModelsUnreachedHostFailsOnce: a listener that accepts and never
  speaks TLS, connectWait set to 200ms and 8 models. Every model's error
  must be "couldn't connect", and the listener may get at most 4
  connections.
- TestStreamAnswerBrokenOff.
- TestProviderTestStops (models and endpoints): a fake vendor holds the
  request until its context ends. The test waits for the request to
  arrive, posts teststop, and waits for the reply to say canceled and for
  the vendor's request to end. It waits on that state, not on a duration.
- model-test-stop.test.cjs: all three buttons read Stop, teststop is
  posted with the run, the labels come back, the status reads Test
  stopped, there is no left-border accent, and nothing overflows at
  560px. It runs in Chromium and WebKit, in en, zh, zh-TW, ja and de.

Broken by hand (each one went red, then the fix was restored):
- the GUI test against origin/main's app.js;
- teststop's post removed ("Stop posted no teststop");
- teststop not cancelling ("the test went on after Stop");
- dead.Store removed (8 connections);
- the connecting wrap removed (TLS handshake timeout after 10s).

Run:
- At the pushed head:
  - mote: TestCoreScriptBudget, TestProviderTestStops, the i18n Go tests,
    TestTestModelsUnreachedHostFailsOnce and TestStreamAnswerBrokenOff:
    ok.
  - wsl-run (load 179): model-test-stop 10/10 and i18n-keys 4/4.
  - model-test-one: webkit zh was red, "model-c moved on its right-click",
    445.37 vs 444.89. origin/main's app.js was red the same way 3 of 6
    times, in en and zh. That file is on #4218.
  - provider-typed: 4 red (locator.fill 5s); see #4461.
- On the change before its last rebase:
  - gofmt clean. GOOS=windows go vet and GOOS=linux -tags nogui go vet:
    ok.
  - Full Go suite on mote (-timeout 45m, tee'd): 79 packages ok.
    internal/gui failed only on the ten AppKit window tests #4125 names.
  - Whole GUI suite on Linux WSL (both engines, every language): 15,767
    tests, 502 red across about 125 files, at load 160 to 175. The 8
    provider-editor files gave the same pass and fail set at fresh
    origin/main ccbefe2a2. The reds are on the WSL issues; the 12 files
    no issue named are filed as #4461.

Not tried:
- Stop in the real Windows app (WebView2).
- A real vendor, or a real unreachable host outside the tests.
- Plugin and account transports (no connect bound for them).
- The Fetch models step inside the endpoints' test.
- The CLI's test path and Detect, which get the connect bound through
  probeOnce but weren't exercised.
- The macOS GUI suite, since mote's WebKit is broken (#4125).
2026-10-31 00:08:29 +08:00
yetone 72ed121fd2 agent: the Codex row asks for a reopen only when Codex's models change
Qyburn3 on X ("为什么我每天好多次要重启"): the Agents row of a Codex
app already connected said 已接入 · 退出并重开 Codex 应用后生效 several
times a day.

Cause: StaleCopies counts a running copy as behind when a digest of
what magpie writes for Codex changed after it started. That digest took
magpie-desktop-models.json byte for byte. Beside the ChatGPT sign-in
(since add927e60) that file holds the ChatGPT backend's entries as
sent (base_instructions, comp_hash, available_in_plans...), asked for
again each hour, and each entry's details follow magpie's version and
models.dev, so a rewrite with the same models moved the digest and the
row asked for a reopen. The same digest drives KeepCodexDaemonCurrent,
so the CLI's app-server daemon was restarted for it too.

Fix: of Codex's two lists (magpie-models.json, magpie-desktop-models.json)
the digest takes which models they hold, slug and visibility in no
order (listedModels), beside the wiring keys and magpie's table as
before. A list that doesn't parse is still taken whole. A digest an older
magpie stashed is kept at its time when it matches the files as they are
(readsBefore), so the update itself doesn't ask every user to reopen
once more. Claude Desktop's reads already hash model ids only. The file
is still written only when its bytes differ (deskList); a running Codex
keeps working on its startup copy, and new details reach it on its next
start.

Run at this head (ccbefe2a2 + this), through mote-run:
- go vet ./internal/agent, GOOS=linux and GOOS=windows: ok
- go test ./internal/agent -count=1 -timeout 45m: ok (147.6s)
- wsl-run go test ./internal/agent -run 'TestCodexStale|TestChangedAt': ok
- the real ~/.codex/magpie-desktop-models.json (35 models) through
  listedModels in a throwaway test, with every base_instructions,
  priority and comp_hash changed and two entries swapped: same part.

Broken by hand: with the old byte-for-byte reads,
TestCodexStaleNotForAListsDetails is red at "the same models, other
details: 1 stale, want 0"; with the readsBefore carry-over off, red at
"an older magpie's stash, nothing changed since: 1 stale, want 0".

Not tried: a real Codex app beside a real ChatGPT sign-in watched over a
day; whether a list that flips between two model sets (a plugin's
listing failing and coming back) still asks for a reopen each flip (it
does: only the last digest is kept). No GUI change, so no GUI run.
2026-10-31 00:00:11 +08:00
yetone 4f2d5fc7e0 routing: a group can put its cheapest member first, by each one's price at that hour
liyuanzheng (#general) and lam_em (#feedback) both asked for the same
thing. Off-peak, DeepSeek's own API should come first for deepseek-flash.
At DeepSeek's peak (weekdays 01-04 and 06-10 UTC, billed 2x since
v0.1.2173), another provider should come first, Ollama say. A schedule
editor would make the user copy DeepSeek's hours into magpie. Instead,
a group gets one more routing, "Cheapest first" (`cheap`). Each request
sorts the members by what they cost right then: input + output price per
million, at the peak rate when it is peak hours. A tie goes to the lower
cache-read price. Free models count as 0. A member with no known price
keeps its listed place after the priced ones. Prices come from the same
priceOf the usage ledger bills with, so the user's own ModelPrices,
list prices and maker prices all count, and so does a provider's rate
windows.

- routes: Seat carries Priced/Cost/CacheCost; Strategy.ByPrice; Cheapest
  is a stable sort, so equal prices keep the user's order.
- gateway: weighRouted prices each seat at priceClock() (time.Now; a test
  holds it) through the new provider.PriceAt. The trace's Weighed row
  gets a price (input/output/cacheRead/peak) so Routing can say why.
- It is a group's alone, like Manual. A provider saved with it drops it,
  and `magpie provider set … routing=cheap` refuses it. Groups take it in
  the GUI menu (one more item, no new controls), the TUI and
  `magpie group set <id> routing=cheap` (aliases cheapest, price, cost).
- Routing's mode line says why the first one is first, e.g. "Cheapest
  first: deepseek-v4-flash costs least on ollama-cloud now — $0.150 in,
  $0.600 out a million tokens.", with peak and unpriced variants.
  en/zh/zh-TW/ja/de.
- Docs: gateway-routing, plugin-runtime, reference (it also points at
  Time window and Pause rules for a fixed schedule) and the site's start
  pages (en/zh/ja).

Run, at f7f2d75f2 (this change rebased onto it):
- Red on the old code: TestCheapestFirstGroupFollowsPeakHours (deepseek
  vs ollama with ModelPrices, priceClock held at 14:00 UTC off-peak and
  02:00 UTC peak) and TestCheapestOrdersByPriceNow did not compile
  without Cheapest. TestCheapestFirstIsAGroupsOnly checks that a provider
  drops it and a group keeps it.
- Broken by hand: without `pr = pr.In(at)` the gateway test is red ("at
  DeepSeek's peak ... went to deepseek"). With Cheapest returning the
  order unchanged, both the routes test and the gateway test are red.
  Both were restored.
- Full Go suite on mote (-count=1 -timeout 45m ./..., log kept): every
  package ok except two. internal/provider had
  TestQuotaSpanCarriesEveryWindowField, which is red on origin/main (#4457,
  fixed since in ccbefe2a2). internal/gui had ten AppKit window tests
  killed at their 20-40s deadlines (TestPanelCloseHidesIt,
  TestMainWindowCorners and others). Three of them are red the same way
  on a fresh origin/main f7f2d75f2 copy, under #2645/#4125 (mote has
  several GUI suites running). After the rebase, go vet and the Cheapest,
  SpeedFirstGroup, ParseRouting, ApplyGroupPairs and ProviderRouting tests
  are ok. go vet darwin, GOOS=linux -tags nogui and GOOS=windows are ok,
  and gofmt is clean.
- GUI on WSL (Linux, chromium + webkit): routing-cheapest-first (new,
  3 scenes x en/zh/zh-TW/ja/de x 2 engines), routing-group-strategy,
  builtins, i18n-keys and routing-speed-first gave 95 of 96. The one red,
  routing-group-strategy "webkit en light ... the pick moved nothing", is
  a wheel-scroll timing red. It fails 3 of 3 on origin/main and 1 of 3 here
  (#4459). Core-script budget ok (app.js +9 bytes).
- The whole GUI suite (1025 files) was started on WSL at this tree and
  was still running when this was pushed, at load ~160.

Not tried: real DeepSeek or Ollama accounts, and a real request during
DeepSeek's peak hours. Ollama Cloud's price here is the catalog's, not
checked against a bill.
2026-10-30 23:59:31 +08:00
yetone ccbefe2a28 provider: trayKind is named as the GUI's own in the quota span guard (#4457)
7d4a63148 added QuotaWindow.TrayKind, which only gui.withTrayKinds sets,
for Settings' menu bar picker on /api/usage/quotas. quotaReport never sees
it set, and /v1/magpie/quotas has no use for it, so it belongs beside the
other GUI-only fields (capped, startsAt) in
TestQuotaSpanCarriesEveryWindowField's left-out list rather than on
QuotaSpan.

Run on mote at origin/main 59109044c + this change (rebased on f7f2d75f2,
a gateway-only change; go test ./internal/provider/ ok again there):
- go test -run QuotaSpan ./internal/provider/: red without the line
  ("trayKind" isn't on QuotaSpan), green with it.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... ok.
- go test -timeout 45m ./...: every package ok except internal/gui's ten
  real-window AppKit tests killed at their deadline under load
  (TestPanelCloseHidesIt, TestMainWindowCorners, ...), the same set
  59109044c recorded, filed as #2645 / #4125.
Not tried: Windows/Linux test runs (test-only change).
2026-10-30 23:44:03 +08:00
yetone f7f2d75f2c gateway: nested routing groups share one classifier wait, not one each (heatonz)
heatonz on Discord (v0.1.2215): requests through nested routing groups
often failed after 120s with 504 "magpie held this request for 2m0s
without routing it to any provider". The 2m is the unrouted watch's
bar for known waits, and the wait was the decision model: the top
group's ruleFor and each ruled nested group's (nestedRules) asked its
classifier with a whole classifyTimeout() of its own, one after
another, before the route was begun. With classifiers that don't
answer, N ruled levels held a request N waits (60s x 2 is exactly the
2m). Jason's fix shared one wait across a decision model's key
failover (askDecideTries); the levels were the sibling it missed.

Now a request has one classifier wait, from the first classifier
asked (Server.askWaited), shared by every group it goes through:
- a level asked with time left gets only what's left (askClassifierIn,
  askChat, askDecider/askDecisionGroup/askDecideTries take the wait);
- a level asked once it is spent isn't asked: it goes by its group's
  order at once, as for a classifier that didn't answer, and its
  Classified.Error says "spent by the routing group above";
- a classifier or decision key cut short by the shared wait (waitSpent,
  cutShort) is not rested (classifyRest, decideFailed): it had less
  than its own wait, and nothing says it is down.
docs/subsystems/gateway-routing.md says so.

Nothing from v0.1.2215 to origin/main 2df46e3c8 touched this path.

Tests (new, internal/gateway/nested_classify_wait_test.go):
- TestNestedGroupsShareTheClassifierWait: outer > mid > inner, each
  ruled on intent with its own classifier that never answers,
  classifyUnit 60ms (8s -> 480ms), unrouted most 1.1s. Red on
  origin/main 2df46e3c8: 504 "held this request for 1s without routing
  it" after 1.45s. Green: 200 from a/m, nested levels say "spent",
  only cls1 rests. -count=5 green.
- TestDecisionKeyCutShortIsNotRested: a decision provider's key cut off
  at 50ms of a 200ms wait is asked first again.

Broken by hand, each red then put back:
- askWaited giving each level a whole classifyTimeout(): the 504 again;
- classify resting waitSpent errors: cls2 and cls3 rest;
- askDecideTries without the cut-short case: the key's error is the
  plain "no answer in 50ms", and it is rested.

Run on mote (mote-run), at this tree except a comment moved back onto
askClassifier afterwards:
- go test -timeout 45m ./... : every package ok but internal/gui, whose
  10 real-window AppKit tests (TestMainWindowCorners,
  TestPanelCloseHidesIt, TestDockJoinLeadsCommandTab, ...) were killed
  at their deadlines: mote's AppKit hang, #4125 / #2645. internal/gui
  is not touched here. internal/gateway ok (745s).
- at the final tree: GOOS=linux, GOOS=windows and darwin go vet
  ./internal/gateway, and the Classif|Decide|Decision|Rule|Unrouted
  tests plus the two new ones: ok. gofmt -l clean.

Rebased onto origin/main 59109044c (no internal/gateway change between):
go vet ./internal/gateway and the same targeted tests ok there.

Not tried: heatonz's own groups and settings (their Classifier timeout
and classifiers aren't known; 60s with two ruled levels fits the 2m0s,
and the 30s between rows matches classifyRest), and a real slow
decision model; only fake upstreams. GUI not touched, GUI suite not run.
2026-10-30 23:28:16 +08:00
yetone 59109044c6 provider: the ZCode mover's min is 0.1.39, gift plans are also claimed from the ZCode app's banner feed (plugins#503)
Plugin 0.1.39 (magpie-community/plugins 2e580cf) reads the ZCode app's
claim banners from GET /api/v1/marketing/touch as well as
billing/preview. A banner plan (ZCODE WEEKEND BUILD, 10-30) is in
neither billing list while the app shows it, so the daily check-in said
there was nothing to claim (kongbai01203's capture on plugins#503). The
claim itself is the same POST /billing/claim; a list that doesn't read
is a failed check-in, asked again later. keepMovedCurrent brings every
moved ZCode user to it.

Run on mote, worktree at origin/main ec5571d6f + this change:
gofmt -l clean; `go vet`, GOOS=linux and GOOS=windows `go vet` of
./internal/provider/ ok; `go test -timeout 45m ./...`: every package ok
except internal/gui, whose ten real-window AppKit tests (TestPanelCloseHidesIt,
TestDockJoinLeadsCommandTab, TestMainWindowCorners, ...) were killed at
their 20-80s deadlines on mote, filed as #4125 and #2645; this change
touches only a string in internal/provider. Rebased onto 5bb252c8f
before the push; `go test ./internal/provider/` at the pushed tree: one
red, TestQuotaSpanCarriesEveryWindowField ("trayKind" isn't on
QuotaSpan), from 7d4a63148 on main, filed as #4457. `npm view
@magpie-community/opencode-zcode-auth version --prefer-online
--registry=https://registry.npmjs.org/` says 0.1.39. The plugin's own
record (zcode 178 pass, 3 red on the old code, dedupe and unread-list
returns broken by hand) is in 2e580cf.

Not tried: a real banner claim through the plugin; its feed fixture is
built from the capture's description of the fields.
2026-10-30 23:25:48 +08:00
yetone 5bb252c8f3 usage: a poll's small pairing lets a whole history's scratch go (#2278)
The matcher, the response picks and visibleLocal's set of ids seen are
kept for the next pairing, and each pairing that puts one back holds it
scratchLinger more. A poll's pairing of its last few days put back the
scratch the cold start's pairing of the whole history made, sized for
every call, so ~140 MB of maps and slabs stayed while the window polled:
the heap profiles at 44, 50, 56, 62 and 68 s were alike to the MB, all
of it under codexEffortOfIndex, with no pairing of the history running.

Each scratch now records the rows of the largest call it served, and a
call over a quarter of that or less (and over 4096 rows' floor) makes its
own; the large one goes with the collection. A call alike in size takes
what is kept, as before, so the polls while an agent works still reuse
it. holdBigBuild counts its rows through the same rowsOfAll.

Run on mote at this head (parent 7d4a63148, rebased; usage ok 21.4s, usageapi ok 1.6s there):
- go vet ./internal/usage: ok
- go test ./internal/usage ./internal/usageapi: ok 18.0s, ok 0.8s
- TestSmallPairingLetsLargeScratchGo with scratchFits always true: red
  ("a small pairing kept the match scratch of a large one"); green with
  it back, beside TestPairScratchGoesWhenUnused, -KeepsNothingBetweenCalls
  and TestVisibleLocalSeenKeptEmpty.
- gofmt -l clean.

Real history (the owner's full ledger and session files, sandbox HOME,
caches deleted, the GUI's polls for 120 s), footprint every 5 s:
- this head: peak 532 and 539 MB; after the peak 367–374 MB while it
  polled; CPU 3:29 both.
- e31ccf230 in the same session: peak 556 MB (548–566 before); after the
  peak 416–419 MB; CPU 3:38.

The peak itself is the pairing of the whole history while it runs, beside
the Month page and the session stats; this change doesn't cut that.
Not tried: Windows and Linux runs.
2026-10-30 23:20:35 +08:00
yetone 7d4a631480 tray: pick which of a subscription's windows the menu bar shows (StrikingRaw on X)
Claude Pro's menu bar card drew its 5-hour and 7-day windows as two
small stacked numbers, and the user wanted one of them alone. Settings ›
Usage › Menu bar windows (under Allowances in the menu bar) lists a pill
per ticked subscription with two or more windows ("Claude Code · All
windows"), opening the app's menu: All windows, then each window. The
choice is settings.TrayWindows, by provider id (every account of it, the
in-use "|*" card too) and by window kind from the span ("5h", "1d", "7d",
"month", "15m", "name:<name>" when the span is unknown), so a vendor
reordering windows changes nothing. Unset shows every window as before;
a pick whose windows are all gone shows every window again, never an
empty card. Only the bar's rows and the Linux label are filtered; the
tooltip still says every window. One row draws at mpRowFont's 11pt
single-row size. Hidden on Windows (its tray shows no text). Per
computer through KeepOwn. The GUI learns kinds from trayKind on
/api/usage/quotas (withTrayKinds; model and aside windows get none). The
row's code is a lazily imported traywindows.js, so the core script
budget is not raised (app.js +4 lines for the call and the prefs keep).

Run:
- mote (macOS): go test -run 'TrayWindow|TrayUsage|WithTrayKinds|
  CoreScriptBudget|AppScript|TrayImage' ./internal/gui/ ok;
  ./internal/settings/ ok; davsync TestSync ok. TestTrayImageOneWindow
  draws through AppKit: Claude's card one line ("42%"), both windows two;
  the PNGs were looked at.
- mote: gofmt -l empty; go vet ./..., GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./... ok; go build, GOOS=linux go build
  -tags nogui, GOOS=windows go build ok.
- magpie-desktop (Linux VM), --test-concurrency=1, BROWSER=chromium and
  webkit: tray-windows (en, zh, zh-TW, ja, de; picking All; hidden on
  Windows / single-window / no cards; 360px narrow), i18n-keys,
  old-webkit, tray-usages, tray-logos, tray-cost, quota-pace: 43/43 each.
After rebasing on ec5571d6f: the focused Go run above, davsync and vet of
the touched packages ok on mote; tray-windows, i18n-keys, old-webkit,
tray-usages 27/27 in chromium and webkit on the Linux VM.
Broken by hand: the row filter in trayCardText off -> TestTrayWindowsPicked
and TestTrayImageOneWindow red; trayWindows out of prefsKeep ->
tray-windows.test.cjs red in every language. Restored, green.
Not run: the full Go suite (owner: ship each verified fix at once; mote
was at load 20-27 under another session's full GUI suite) and the whole
GUI suite. The GUI ran on the Linux VM because mote's browsers crash or
hang under that load (#4125; TestTrayCellClickReleasedPanel is red the
same way on origin/main c84c3e1c0 there).
Not tried: the live app's real menu bar with a signed-in Claude account
(the AppKit drawer was exercised in-process instead); Linux tray label
on a real desktop.
2026-10-30 23:14:08 +08:00
yetone ec5571d6f2 routing: the Japanese connection-check note names {agent} as often as the English one
da3c5e0c0's ja string for "{agent} checked that magpie answers ..." had a
third {agent}, so gui-ja's "ja has every zh string, with its placeholders
and tags" was red on origin/main (a0cb8b646), in Chromium and WebKit.
"このチェックのモデルは {agent} がモデル一覧の名前から自分で選んだもの"
now reads "このチェックのモデルはモデル一覧の名前から自分で選んだもの"; the
sentence already says the agent picks it.

Run: wsl-run node --test gui-ja.test.cjs i18n-keys.test.cjs: 7/7 (red
before: 1 fail, the same test, in both engines).
Not tried: a Japanese speaker's read of the new wording.
2026-10-30 23:00:01 +08:00