Commit Graph
5504 Commits
Author SHA1 Message Date
yetone fdf5e2c65f cli: claude-tui-helper ends on a signal its own way, not of magpie's handler
magpie's process-wide handler (endProbesOnSignal) re-raises SIGTERM. In
claude-tui-helper it killed the helper (exit -15) before the shim's own
handler could stop its Claude Code and remove what it wrote, so a run the
gateway aborted left them behind. The helper's command now lets go of
those signals (leaveSignals) before claudetui.Run.

Run: go test ./internal/claudetui ./internal/cli on mote (macOS) and in
WSL magpie-desktop (-tags nogui), ok; go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./..., go build on mote, ok.
Broken by hand: without leaveSignals, SIGTERM to a real helper in the
sandbox gateway exited -15 and left its temp folder; with it, exit 1 and
the folder removed (termimg.py).
Not tried: SIGHUP from a closed terminal.
2026-10-31 05:00:39 +08:00
yetone cac606be1a provider: Cursor's mover min is 0.2.33, free credit on the card (CryptoSarom on X)
CryptoSarom on X: magpie didn't read Cursor's bonus credit or the limits
on spending it. The plugin (magpie-community/plugins 00de68a,
@magpie-community/opencode-cursor-auth 0.2.33, on npm) now shows two
things on the Usage card, both aside so they never stop routing:
- the plan's bonus, from GetCurrentPeriodUsage planUsage.bonusSpend and
  remainingBonus, as "+$X on us" (the IDE's "free usage on us" line);
- each active credit grant, from DashboardService/
  GetUsageLimitStatusAndActiveGrants activeGrants: spent / total, its
  expiry, and the models (allowed_model_ids, tags, selections) or
  clients (allowed_client_types) it covers.
A pool spent while a grant that cursor-agent ("cli") can use still has
money left no longer stops the models that grant covers. The field
names come from Cursor's own schemas, in the IDE's workbench bundle and
cursor-agent 2026.10.01, and from real replies on the owner's account.
This commit raises keepMovedCurrent's min so moved users get it.

Run:
- plugins: bun test packages/cursor on mote, 79 pass 0 fail
  (credit/usage/included-only), and the full suite before that;
  bun scripts/check.mjs cursor.
- the real account's card through 0.2.33, in a sandbox HOME, read only.
- here: gofmt -l internal/provider (clean), and
  mote-run go test ./internal/provider/ -timeout 45m: ok (98.5s) at base 9d4a4bfd3.

Broken by hand: credit.test.mjs is red 9 of 9 on the old index.mjs.

Not tried: a real account that has a grant or remainingBonus true (the
owner's has neither: activeGrants is empty and remainingBonus is false),
so the grant fixtures come from the schema, not from real bytes. Also
not tried: whether Cursor really serves past a spent pool on a grant.
GetCreditGrantsBalance and GetClientVisibleCreditGrants (both {} here)
are not read.
2026-10-31 04:54:20 +08:00
yetone 9d4a4bfd3f gateway: a late Claude Code call tells the client after 500ms, not 1s
In Claude Code's interactive mode a call of a client's tool waits callFirst
for its message in the transcript before the call tells the client itself.
Measured on a real account (a probe build logging the time from the MCP call
to the transcript's tool_use), a message written before its call was read
118 to 162ms after the call came in, 8 calls of 8. 500ms leaves it room and
halves what a late message costs.

Run: go test -race -count=3 -run 'TestClaudeTUI|TestSubscription'
./internal/gateway on mote, ok. Real account (claude-haiku-5-5, sandbox
HOME, interactive TUI): 9 runs of the one/two/text scenarios, all ok, every
call told once with its own id; 1 took the late path, none fell back to -p.
Not tried: sonnet/opus, Linux.
2026-10-31 04:35:16 +08:00
yetone e647a1fd54 plugins: an npm registry of the user's own is used for installs and lookups (timwangdev on X)
timwangdev asked on X for plugins to take a custom npm registry. Zero-config
first: Registry() (internal/plugin/registry.go) takes, in order, the one set
in magpie (settings npmRegistry: `magpie plugin registry <url>|default`, or
Plugins › Discover's new npm registry row), BUN_CONFIG_REGISTRY /
NPM_CONFIG_REGISTRY / npm_config_registry in magpie's environment, then the
login shell's (cached probe only, proc.LoginEnvKnown, never waits on a
shell), install.registry in the plugins folder's or the user's .bunfig.toml,
registry= in the plugins folder's or ~/.npmrc, then the 国内镜像 switch's
npmmirror, then npm's own. The switch no longer puts npmmirror over a
registry the user named: before, bun was handed BUN_CONFIG_REGISTRY=npmmirror
whenever it was on, over the user's .npmrc. bun is told the registry only
where it wouldn't find it itself (magpie's setting, the shell's, the
switch's). magpie's own npm questions (latest version for the market,
Update and the hourly check, README, search) go to the same registry, a
package's @scope:registry= to that scope's, with the .npmrc's
//host/path/:_authToken (${VAR} expanded, longest prefix) sent to that host
alone, dropped on a redirect to another host, never logged or shown.
Download counts stay npm's. Only http(s) with a host, no userinfo, query
or fragment is taken; anything else is refused and not saved, and a bad
value hand-written into settings.json is passed over. /api/plugins says
which registry is in use and where it came from.

The GUI row is in registry.js, imported when Discover draws it, so the
core script budget isn't raised (plugins.js is 292 bytes smaller than
before, one long comment there condensed).

Left out: bunfig [install.scopes] for magpie's own lookups (bun reads them
for installs), .npmrc _auth and username/password, NPM_CONFIG_USERCONFIG
and npm's global npmrc, and internal/agent/cliupdate.go's agent CLI update
lookups, which still ask npm's own.

Run (mote and wsl-run). First at this change on 2ac423f4f:
- go test ./internal/plugin/ ./internal/source/ ./internal/gui/
  ./internal/proc/ ./internal/cli/ ./internal/settings/ -timeout 45m:
  plugin, source, cli, settings ok. gui: only the real-window AppKit tests
  killed at their deadline on mote (dock, panel, titlebar, tray; #2645,
  #4125), TestCoreScriptBudget and TestSettingsSaveKeepsWhatItDoesNotSend
  green after the fixes in this commit. proc: TestNoCommandBypassesProc red
  on origin/main itself (internal/claudetui/tui.go:183), filed as #4491.
- gofmt -l internal: clean. GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: ok.
- GUI (wsl-run, magpie-desktop): plugin-registry.test.cjs in Chromium and
  WebKit, 5 languages each, 980px and 380px; i18n-keys, old-webkit and
  plugin-market (WebKit): 19/19 pass. On mote the browser runs timed out
  launching (#4125).
Again at this tree rebased on fa5e86cf2 (upstream changed app.js and
i18n.js): go build ./...; go test ./internal/gui/ ./internal/cli/
./internal/plugin/ ./internal/settings/: cli, plugin, settings ok, gui only
the same ten AppKit window tests killed on mote (#2645, #4125), the core
budget green; gofmt clean; plugin-registry (Chromium, WebKit), i18n-keys
and old-webkit on WSL: 22/22 pass.
Rebased once more on 45de2ddb9 (app.js and i18n.js again): gofmt clean,
go vet of gui and plugin ok, TestCoreScriptBudget and
TestSettingsSaveKeepsWhatItDoesNotSend ok, i18n-keys 4/4.

Broken by hand, each red, then restored:
- A: old registryEnv (npmmirror whenever the switch is on):
  TestBunTakesTheUsersRegistry red.
- B: lookups always to npm's own: TestLookupsAskTheUsersRegistry red.
- C: no URL check: TestSetRegistryRefusesWhatIsntOne red.
- D: the switch before the user's registry: Precedence, BunTakes and
  Lookups red.
- E: no token sent: Lookups red.
- F: scopes ignored: Lookups red.

Not tried: a real private registry (Verdaccio, GitHub Packages, Nexus) with
a real token; a real bun install through one; Windows (the login shell
probe is a no-op there, so only env, bunfig and .npmrc apply).
2026-10-31 04:24:59 +08:00
yetone 45de2ddb96 provider: a provider the user counts free goes first under Free first (jiabubu on Discord)
jiabubu asked on Discord #help for a way to mark a provider, model or key
as free, so that Free first routing spends it first. Their example is
ModelScope, which has a free daily quota. Until now routes.Seat.Free
came only from the vendor catalog's Free flag, and there was no way for
the user to set it.

Provider.CountFree ("Free for me" in the provider editor's Advanced fold,
`magpie provider set <id> free=yes|no` in the CLI) makes FreeModel true
for every model of that provider. Routing therefore treats it like a
vendor's free model: Free first uses it before paid ones, and Cheapest
first weighs it at nothing, because PriceAt, which only routing reads,
returns 0 for a free model. Prices shown (ListPrice and the model list)
and the costs Usage counts (EffectivePrice) are unchanged. The mark says
what to spend first, not what a call cost, and a quota that runs out
still bills at the listed price. Key and account (subscription)
providers both carry it, through withPicks, the account literal and the
copy merge.

Tests:
- internal/gateway TestFreeFirstSpendsTheProviderTheUserCountsFree:
  - a Free first group [paidv/m, mine/m] sends its first call to mine
    once mine is marked, and the trace row says Free;
  - EffectivePrice is still the listed 3/15;
  - Cheapest picks mine first;
  - unmarked, paidv goes first again.
- internal/gui TestProviderSaveKeepsCountFree: the preset and typed-in
  providers save the mark and clear it, and /api/providers reports it.
- internal/cli TestProviderSetFree: free=yes and free=no work; the value
  shows in `provider <id>`; free=maybe, an empty value and --help are
  refused and change nothing.
- GUI internal/gui/tests/provider-count-free.test.cjs covers the
  ModelScope preset, a custom provider saved with the mark, and a Codex
  account. It runs chromium and webkit, in en, zh, zh-TW, ja and de, at
  widths 900 and 440. It checks the Advanced fold, the check and save
  POST bodies, that the row fits with no sideways scroll, and that each
  string has a translation in I18N.

Core script budget: rebased on fa5e86cf2, the core's scripts came to
1,538,236 bytes, 880 over coreScriptBudget, which TestCoreScriptBudget
caught. The budget is not raised. countFreeField's comment and five
long comments on the editor's helpers (proxyPicker, concurrencyField,
priceRateField, pluginOptionsField) are cut down, so app.js ends 212
bytes smaller than before this change.

Run (mote via mote-run, at this change's tree on base 8ee75adbf):
- go test of internal/gateway (-run FreeFirst|InOrder), internal/gui,
  internal/cli and internal/provider: ok.
- GUI test: chromium 30/30 on mote. WebKit could not launch on mote at
  all at the time (a bare webkit.launch probe timed out at 60s, and
  other sessions' WebKit launches were stuck there too). WebKit was run
  on Linux instead (wsl-run, magpie-desktop): 30/30.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./... ok; go build for darwin, linux (nogui) and
  windows ok.
- At the pushed head (rebased on fa5e86cf2, comments cut): go test of
  internal/gui, internal/cli, internal/provider and internal/gateway
  -run FreeFirst|CountFree ok (internal/gui was red only on
  TestCoreScriptBudget before the cut); node --check app.js ok; the GUI
  test in chromium 30/30.
- The full Go suite (go test -tags nogui -timeout 45m ./...) is still
  running on mote at ship time, per the owner's ship-at-once rule. Any
  red it finds gets a follow-up commit. The whole GUI suite was not run:
  mote's WebKit cannot launch and the Linux box was running other
  sessions' GUI suites.

Broken by hand:
- With the CountFree line taken out of FreeModel, all three Go tests
  went red, e.g. 'Free first went to "paidv" (free false) first'.
- With `pr.CountFree = in.CountFree` taken out of the preset save
  branch, TestProviderSaveKeepsCountFree went red ("the preset's mark
  wasn't kept").

Not tried:
- A real ModelScope account; the tests use fake upstreams.
- A per-model mark (optional in the request); the mark is
  provider-wide.
- The TUI editor (the CLI setter covers the terminal).
2026-10-31 04:21:21 +08:00
yetone c799934e1b claude: the gateway logs why a run is -p
Finding why the real-account runs went -p (the previous two commits'
end-to-end) took reading a run's stderr by hand: the bridge keeps Claude
Code's stderr for an error only, and claudeTUI said nothing of why it
chose -p.

claudeTUI's conditions move into claudePrintWhy, which names the one
that held ("Claude Code in WSL", "a JSON schema", "the interactive mode
is turned off", ...), and claudeTUI logs "claude: this run is -p: <why>"
(not in the tests' binary, claudeTUIRuns off). lockedWriter logs the
helper's "claude-tui: ...; this run is -p" line (a failed start, an
untrusted folder, the 30-minute mark) as "claude: ...". The rest of
Claude Code's stderr is kept as before and not logged.

Run:
- mote: go test -count=1 -run TestClaudeTUI ./internal/gateway ok:
  TestClaudeTUIChosen now checks each case's reason,
  TestClaudeTUIFallbackLogged the helper's line logged and nothing else.
  go vet ./internal/gateway on darwin, linux, windows; gofmt -l clean.
- Real account, sandbox HOME, a gateway on this build: before the trust
  fix, the helper's line is what named the cause ("Claude Code ended
  before it showed its prompt (exit status 1): B").

Broken by hand: the log in lockedWriter taken out:
TestClaudeTUIFallbackLogged red (logged "").

Not tried: the log on Linux.
2026-10-31 04:20:10 +08:00
yetone 123d72be68 claude: a call Claude Code makes before writing its message is the reply
In the interactive mode the bridge learns of a call from the session's
transcript. Claude Code sometimes writes the message holding a client's
tool_use only after that MCP call returns (4 of 8 real runs before this).
The call waits on the client, and the client waits for the call it was
never told of: a deadlock until the run's timeout.

mcpCall now hands each call to run.onCall, which readOutput sets for a
TUI run. If callFirst (1s) after the call it isn't in the transcript yet
and still waits, the call itself becomes the reply: a message with one
tool_use and stop tool_use, with the MCP helper's id, name and arguments
(the id is the transcript's, from _meta "claudecode/toolUseId"). The
message written after such calls is the late one: its rows aren't told
again (lateID), a call in it not yet told is told by its own turn
(written), and its usage is counted in the next reply. Such a reply has
no words or thinking; the model's text before its call is lost to the
client. -p runs don't set onCall and are unchanged.

docs/subsystems/claude-subscription-bridge.md has the paragraph.

Run:
- mote: go test -count=1 -race -run TestClaudeTUI ./internal/gateway ok
  at this tree; earlier, -race -count=5 of the new tests ok.
- TestClaudeTUICallBeforeItsMessage (output 47 = late 40 + answer 7),
  TestClaudeTUICallAfterItsMessage (told once, output 7),
  TestClaudeTUIParallelCallsBeforeTheirMessage (written after both, and
  between).
- mote: go vet ./internal/gateway on darwin, linux, windows; gofmt -l
  clean. go test -timeout 45m ./internal/gateway ./internal/claudetui
  ./internal/claudebridge ok before the previous commit's rebase
  (gateway 522s); a run with all three commits is going.
- Real account, sandbox HOME, a gateway running this build, haiku: "two
  calls in one message" logged "Claude Code called get_secret before
  writing its message; the call is the reply" for both calls, and the
  client got red then blue as two replies and the answer naming both
  secrets. One call, and words then a call: answered from the
  transcript. Every row "entrypoint":"cli".

Broken by hand: onCall never called: the three tests red ("deadlock").
lateID never set: the late message told again, red.

Not tried: sonnet or opus in the real run (haiku only); a call whose
client takes longer than the run's timeout.
2026-10-31 04:20:10 +08:00
yetone faaba45236 claudetui: the folder-trust question is answered Yes only once Yes is drawn
The real-account end-to-end through a running gateway found every
interactive run going to -p. The gateway's working folder
(magpie-claude-work-<uid>) wasn't yet trusted under the account's config
dir, so Claude Code 2.1.314 asked whether to trust it, with "No, exit"
chosen. The helper pressed down and then, 300ms later, Enter without
looking. Its down was lost when sent as the question was first drawn
(the question is drawn again on No), Enter chose "No, exit", and Claude
Code ended with status 1 (screen: "B"). The start failure marked the
interactive mode broken for 30 minutes and every run went to -p, so
v0.1.2266's default did nothing on a fresh account.

ready() now reads the choice as the last of "❯ No, exit" / "❯ Yes, I
trust" drawn, presses down (at most once a second) while No is chosen,
and Enter only on a Yes that stayed drawn for 300ms (trustSettle). The
test's fake asks as the real one does: words placed by cursor moves, No
chosen first, keys in its first 150ms lost, and drawn again on No; Enter
on No exits 1.

Run:
- By hand: real Claude Code 2.1.314 in a PTY in the gateway's folder,
  sandbox HOME with a real account's config dir: the question opens on
  No; a down sent at once is undone by the redraw, one sent 0.3s or 1.5s
  in moves to Yes.
- mote: go test -count=3 -run TestShim ./internal/claudetui ok; go test
  ./internal/claudetui ok; go vet ./internal/claudetui on darwin, linux,
  windows; gofmt -l clean.
- Real account, sandbox HOME, a gateway running this build (and the next
  commit's), haiku: a tool call, two calls in one message, words then a
  call: all answered, every transcript row "entrypoint":"cli", no broken
  mark.

Broken by hand: the old ready() with the new fake:
TestShimTrustsWhenTold red, "Claude Code ended before it showed its
prompt (exit status 1)", the real failure.

Not tried: Linux with a real Claude Code; a Claude Code version whose
question words differ (it then waits out 45s and goes -p, marked).
2026-10-31 04:20:10 +08:00
yetone fa5e86cf2b agents: Kimi Code and Kimi Code Desktop requests show their own name and icon, not the raw id and the cube (jiabubu)
jiabubu on Discord (magpie 0.1.2245, Windows, Kimi Code 2.4.1, Kimi Code
Desktop 1.2.1.0): the Routing page's request list drew Kimi Code's
requests as the grey cube and "kimi-code-cli", and Kimi Code Desktop's as
the cube and "kimi-code-desktop".

The request list, Usage and Sessions already take a client's name and
icon from one table, /api/state's clients (agent.Clients). The drift was
in usage.AgentOf: Kimi Code 2.x sends "kimi-code-cli/…", which matched
neither the kimi agent's "kimicli" prefix nor its "kimi-code" alias, and
Kimi Code Desktop ("kimi-code-desktop/…", its bundle's clientName) had
no entry at all, so both kept their raw product names.

- kimi's UA list takes kimi-code-cli.
- Kimi Code Desktop is a client of its own (agents.go's others). It runs
  Kimi Code's engine on ~/.kimi-code, so it is set up through Kimi
  Code's row. Its icon is the app's own: the 128px entry of build/icon.ico
  in KimiCode-1.2.1-win-x64.exe, the installer winget's
  MoonshotAI.KimiCodeDesktop 1.2.1 points to on code.kimi.com (sha256
  75111cb6…c312, as the manifest says). Nothing was drawn by hand.
- app.js's pngIcons names it (comment shortened, app.js 5 bytes smaller,
  budget untouched); app.css's tile rule names it, as icon-tile measures
  it solid to its edges.
- Old records re-resolve through AgentOf, so earlier kimi-code-cli
  requests read as Kimi Code too.

Guard: TestEveryClientHasNameAndIcon checks that every client has a
name and an icon file app.js's icon() really loads (a PNG only if
pngIcons names it), and that the ids the gateway records by more than a
User-Agent (claude-desktop, claude-science, cursor-local, codex, magpie)
and kimi / kimi-code-desktop are all clients. The cube is allowed only
for the six clients with no logo yet (ante, pencil, openpencil, newmax,
kirocrew, raft), filed as #4487. routing-client-icons.test.cjs draws the
request list from a history fixture and checks names, data-icon, and that
the desktop PNG loads.

Run (mote unless said):
- Red on the old code: TestAgentOf (got "kimi-code-cli" want "kimi"),
  TestEveryClientHasNameAndIcon (kimi-code-desktop not among the
  clients); routing-client-icons in Chromium on the old app.js
  (0/2, the desktop row is the cube).
- Broken by hand: pngIcons without the entry makes the guard fail ("a PNG
  app.js's pngIcons doesn't name, so it is drawn as the cube").
- go test ./internal/agent ./internal/usage ./internal/usageapi: ok.
  ./internal/gui: ok except the ten real-window AppKit tests killed at
  their deadline on mote (#4125, #2645). ok with those skipped, after
  the rebase.
- go vet (darwin), GOOS=linux -tags nogui and GOOS=windows vet of
  internal/agent and internal/gui: ok. gofmt -l: nothing.
- routing-client-icons: Chromium 2/2 on mote, WebKit 2/2 on Linux
  (wsl-run; WebKit launch hangs on mote, #4125).
- routing-*, i18n-keys, icon-tile, mono-icon-redraw and
  models-add-and-icons in Chromium on mote and WebKit on Linux: i18n-keys
  green. icon-tile caught the missing tile entry (fixed here). The other
  Routing reds are still being compared against a fresh origin/main copy
  in both engines (running at push time). Any that turns out to be ours
  gets a follow-up commit.

Not tried: a real Kimi Code 2.4.1 or Kimi Code Desktop 1.2.1 against
magpie (the UA strings come from their bundles: appName kimi-code-cli,
clientName kimi-code-desktop). Only the Windows installer's icon was
read; the macOS app's wasn't compared. Full Go suite to follow the tag.
2026-10-31 04:12:17 +08:00
yetone 8ee75adbfe gui: the Gateway card's state sits centred on its title's line
The owner, on the Gateway page's status card: "这里没有水平对齐". The
state ("运行中", 11px) sat on the 15px title's baseline. A smaller run of
CJK text on a shared baseline reads as dropped below it: the title's ink
ran rows 40-61 of the screenshot and the state's 42-61, so the state's
middle was about a pixel low. .gw .name is now a flex row with
align-items: center and an 8px gap (as .mask-act .name already is). The
state keeps its ellipsis for long text (min-width: 0).

gateway-card.test.cjs now measures the title text's middle against the
state's and allows 0.25px.

Run:
- gateway-card.test.cjs, chromium on mote: 10 of 10 ok. WebKit on mote
  hangs at browserType.launch right now (a bare webkit.launch timed out
  at 60s, load ~30), so it ran on the Linux box (magpie-desktop): 10 of
  10 ok.
- Broken by hand: the old app.css with the new test, both engines, 5
  languages, 2 widths: 20 of 20 red, "the state's middle is 0.5px off
  the title's".
- All 30 gateway GUI files at once on the Linux box, both engines: 299
  ok, 1 red. The red was gateway-caller-keys webkit en:138, the
  sideways-scroll read right after setViewportSize. That is #3797, now
  commented on. It passed 3 of 3 alone on this branch and on origin/main
  74f812eaf.

At the pushed head (rebased on 333e7f573): gateway-card and gateway-older
on the Linux box, 24 of 24 ok; go test ./internal/gui -run Budget|CSS|Asset
on mote ok.

Not tried: the whole GUI suite, and macOS WebKit (launch hangs on mote).
The change is two CSS rules scoped to .gw .name.
2026-10-31 03:52:26 +08:00
yetone 333e7f573b gateway: gateway keys are dragged into the order you want, kept with the keys (alextjy on Discord)
alextjy asked on Discord whether gateway keys can be reordered. They
could not: the Gateway page listed them in the order caller-keys.json
held them, and nothing changed that order.

- access: a "move-key" action puts one key at a place in the list,
  under the same file lock as every other key change. Nothing else
  about the key changes, and the sharing key's mirror in settings is
  left alone (its pointer would otherwise land on another key).
- GUI: the Gateway page's key rows are dragged the way search APIs'
  rows are (shared dragRows, a grip shown on hover only, Alt+Up/Down,
  the existing "Drag to reorder" title). A refused move puts the list
  back from the server. New strings in zh, zh-TW, ja and de.
- CLI: `magpie gateway-key move <id> <place>` (from 1); list already
  prints the stored order.
- Usage > Requests: the key filter lists keys in the user's order,
  removed keys after. The Overview stays a ranking by use.

Run (worktree at 14b451c11, then rebased on origin/main):
- gofmt -l clean; go vet (darwin) on access, cli, usageapi, gui;
  GOOS=linux -tags nogui and GOOS=windows go vet on access, cli,
  usageapi (mote).
- go test access, cli, usageapi: ok (mote). internal/gui: every test
  ok except the real-window AppKit tests #4125 lists
  (TestCoveredWindowStaysUp, TestPanelCloseHidesIt and 7 more), killed
  at their deadlines with pboard not running on mote.
- Broken by hand: with move-key removed, TestMoveKeyKeepsOrder,
  TestGatewayKeyCLIMove and TestLedgerKeyFilterInKeyOrder go red; with
  the mirror exclusion removed and the filter left unsorted,
  TestMoveKeyKeepsOrder ("the sharing key's mirror moved") and
  TestLedgerKeyFilterInKeyOrder go red.
- GUI (WSL): gateway-key-arrange 20/20 (chromium and webkit; en, zh,
  zh-TW, ja, de; 1100 and 420px). Red by hand: no arrange (20 red),
  grip always shown (chromium 10/10 red), drop commits nothing (webkit
  10/10 red).
- GUI (WSL), the 68 files the change can reach (every caller-keys
  fixture user, gateway-*, search-*, usage-ledger*, i18n-keys, gui-ja,
  gui-de, gui-zh-tw, key-page, phone-rows, api-key-*): 900/923. The
  reds were run again at origin/main 43966a53f and fail the same there
  (api-key-theme webkit, gateway-key-limit webkit, gateway-key-models
  webkit, search-first, usage-ledger-open-settled, usage-ledger-ttft,
  usage-ledger), each filed: #3307, #3523, #4081, #3795, #4262,
  #3104/#1876, and #4489 (usage-ledger-ttft, new). phone-rows,
  search-keys and connect-snippet-shell reds of the first run passed
  when run again at the head. usage-ledger's "zh: request routing
  links" went red once at the head (Usage view position on return) and
  passed in the first run.

At the rebased head (on 2ac423f4f): TestCoreScriptBudget and the
other Budget/I18n/Asset tests in internal/gui ok (mote);
gateway-key-arrange, i18n-keys and gateway-caller-keys 27/28 in WSL.
The red is gateway-caller-keys webkit en "wider than 560 right after
the resize" (#3797, red alone on main). A probe of that file, printing
the page width and any element past it, read 560/560 with nothing
wider in both engines, in two runs beside the arrange file.

Not tried: dragging in the real app (WebKitGTK, WKWebView, WebView2),
the full Go suite (started after the push).
2026-10-31 03:48:27 +08:00
yetone 74f812eaf0 release: the mirror waits up to five hours for magpie-releases, not one (#4488)
On 10-30, magpie-releases' macOS jobs waited about an hour for a
hosted runner while several tags queued. v0.1.2262's build published
all 16 assets at 19:36:52, 62 minutes after its tag. mirror-release
had given up at 19:35:35 ("never published v0.1.2262 with 16 assets"),
so v0.1.2261 and v0.1.2262 never reached this repo's Releases page
until their failed jobs were rerun by hand.

The wait now runs 600 tries 30 s apart (300 min), and the job's
timeout is 330 minutes, under GitHub's 360. A build that really failed
still ends in the same error, only later. Following the magpie-releases
run's own state would end such a wait sooner; #4488 stays open for it.

Run: actionlint .github/workflows/release.yml ok. Not run: a real
release through it (the next tag runs it).
2026-10-31 03:42:11 +08:00
yetone 2ac423f4f2 kimi: a Kimi Code plan model is told always_thinking, dynamically_loaded_tools and its default effort, as Kimi's list says (jiabubu)
jiabubu on Discord (Kimi Code 2.2.0, Windows): Kimi Code's own provider
gives K2.8 Preview and K3.1 Pro the capabilities thinking,
always_thinking, image_in, video_in, tool_use and
dynamically_loaded_tools; through magpie they had thinking, image_in and
tool_use, so Kimi Code offered a thinking switch the models refuse to
turn off, and started K2.8 on high where Kimi's own starts it on max.

Kimi Code 2.4.1's managed provider (packages/oauth managed-kimi-code.ts,
capabilitiesForModel) derives them from /coding/v1/models:
supports_thinking_type "only" -> thinking + always_thinking,
supports_dynamic_tools -> dynamically_loaded_tools, supports_video_in ->
video_in, think_efforts.default_effort -> the default. magpie now reads
the same fields (flat, or nested reasoning.type, tools.dynamic_load,
reasoning.effort.default) into catalog.Model (AlwaysThinks,
DynamicTools, DefaultEffort; kimiFacts), carries them through
provider.Entry and the agent's model list, and the new Kimi Code's table
gets always_thinking, dynamically_loaded_tools and default_effort at the
vendor's default (else high, as before). Only Kimi's list sends these
fields, so another vendor's model is written as before; kimi-cli, which
refuses unknown words, gets none. A routing group has none of them.

default_effort is now recorded in the stash as magpie's (kimiOwn), so a
level the user picked stays while the model has it. A table with high
and no record is read as the high magpie wrote before it kept one, and
becomes the vendor's default (max on K2.8, high on K3/K3.1).

Left out:
- video_in: with type="kimi" Kimi Code uploads a video to
  {base_url}/files (purpose=video) and sends the ms:// id. The gateway
  has no /files route, and the id belongs to the account that stored it.
  Filed as #4485.
- dynamically_loaded_tools works (Kimi Code's tool select is behind
  KIMI_CODE_EXPERIMENTAL_TOOL_SELECT): the loaded tools' system message
  is lifted into the request's tools (liftMessageTools, #2322), so they
  stay callable (TestKimiCodeLoadedToolsReachKimi), but each load
  restarts Kimi's prompt cache. Filed as #4486.
- max_output_size: Kimi's own provider writes none; magpie keeps writing
  the model's known reply cap (32768 on K2.8 per models.dev), unchanged.

This also covers #3399 (K3.1 offered thinking off): Kimi's list says
"only" for both K3.1 models.

Real list: tests read Kimi's /coding/v1/models reply of 2026-10-31
(internal/catalog/testdata/kimi-code-cn-models-2026-10-31.json, read
with the owner's kimi-code-cn key, no key in the file).

Run (mote, at this commit on origin/main b62fa332f; the agent-wiring.md
line was added after the run, docs only):
- go test -tags nogui -count=1 -timeout 45m ./... : 79 packages ok;
  internal/proc (TestNoCommandBypassesProc) and internal/sqlitedb
  (TestOnlyThisPackageReachesSQLite) red on a Go module cache my e2e
  sandbox had left inside the run folder (vendor files under
  e2e-kimi/sb/home/go/pkg/mod); with it removed both ok.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./... ok; gofmt -l clean.
- Real Kimi Code 2.4.1 (npm) in a sandbox HOME/KIMI_CODE_HOME on mote,
  with a sandbox magpie serve (MAGPIE_ADDR 127.0.0.1:34652), the
  kimi-code-cn preset pointed at a fake upstream that serves the real
  list: magpie wrote the six tables (K2.8: thinking, always_thinking,
  image_in, tool_use, dynamically_loaded_tools, support_efforts low/high/
  max, default_effort max; K2.7 Highspeed without
  dynamically_loaded_tools), Kimi Code took the config, and `kimi -p`
  reached the upstream with thinking enabled and reasoning_effort max
  (K2.8) and high (K3.1 Pro).
- Rebased onto 43966a53f..f2eb56c6b (claude, GUI budget, usage; none of
  them touch these files) as f5a82f215, then again at this head:
  internal/agent, internal/catalog, internal/provider ok, internal/gateway
  -run 'Kimi|MessageTools|Lift' ok. The full suite was not rerun there.

Broken by hand, each red then green:
- kimiFacts not called: TestFetchKimiCodeFacts and
  TestKimiCodePlanCapabilities red.
- fields not carried in route.go / entryFor: TestKimiCodePlanCapabilities
  red.
- the unrecorded-high rule off: TestKimiCodeOldHighBecomesTheVendorsDefault
  red.
- always_thinking without the !legacy guard: the kimi-cli case red.

Not tried: the TUI picker by eye (that the thinking switch is gone);
tool select with a real MCP server and the experimental flag; Windows
(the reporter's system; nothing here is OS-specific); a real Kimi
upstream through magpie (the list was real, the chat was a fake).
2026-10-31 03:27:34 +08:00
yetone 43966a53fb claude: a subscription's run is Claude Code's interactive mode, -p only as the fallback
The owner (10-31): a Claude subscription ran `claude -p`, whose
requests Anthropic labels sdk-cli and counts at about twice the
interactive mode's cli (anthropics/claude-code#97074). Running the real
interactive Claude Code is what its terms describe and uses the plan as
a person does. Wanted inside magpie, on by default, with a way off.

`magpie claude-tui-helper <claude> <-p args>` (internal/claudetui)
stands where `claude -p` stood and speaks the same stream-json. It
turns the -p arguments into the interactive mode's (no -p, no
--dangerously-skip-permissions: --permission-mode default with only
mcp__magpie, and the WebSearch -p was given, allowed; --no-chrome;
--session-id or the --resume given), starts Claude Code in a
pseudo-terminal of its own (no tmux), pastes each message into its
prompt and presses Enter, and tells the session's transcript back as
-p's lines: whole assistant messages, an API error as the turn's error
result with its rate_limit_info, turn_duration as the result. Nothing
sets CLAUDE_CODE_ENTRYPOINT, and the user's ~/.claude and
~/.claude.json are never written. The folder-trust question is
answered only for magpie's own folder or a saved account's config
directory (MAGPIE_CLAUDE_TUI_TRUST).

A Claude Code that doesn't start or show its prompt in 45s becomes
`claude -p` on the same pid, its input still unread, so the turn is
answered all the same; that is remembered for 30 minutes
(<cache>/magpie/claude-tui-broken). An untrusted folder goes to -p
without the mark.

claudeTUI keeps -p for Windows and WSL, Settings › Models › Replies ›
Claude Code's interactive mode Off (claudePrintMode), safeguards,
client cache marks, a JSON schema, images and a first message over
400KB. A TUI run ends instead of taking an image turn, a rewind or an
effort change, and letGo doesn't take one back. The gateway's tests
run with claudeTUIRuns off: their binary has no claude-tui-helper.
docs/subsystems/claude-subscription-bridge.md has the section.

The core's scripts grow 725 bytes with the setting's row;
coreScriptBudget is raised to the exact size, 1,537,356, with no room
added.

Run (rebased on f2eb56c6b and its budget fix):
- mote: go vet of claudetui, gateway, cli, settings on darwin;
  GOOS=windows of claudetui, gateway, cli; GOOS=linux of claudetui,
  gateway; gofmt -l clean.
- mote: go test ./internal/claudetui: TestShimTurnsInteractive (a fake
  interactive Claude Code in the PTY: two turns, a /help pasted as
  words, the arguments it was given), TestShimFallsBackToPrint (failed
  start marks broken; untrusted folder doesn't), TestShimTrustsWhenTold,
  TestPasteable, TestTranslatorAPIError.
- mote: go test ./internal/gateway -run TestClaudeTUIChosen (plain,
  off, WSL, safeguards, cache marks, schema, image, long prompt),
  TestClaudeLean*, TestCleanClaudeEnv.
- mote: go test -timeout 45m ./internal/claudetui ./internal/cli
  ./internal/settings ./internal/gateway: all ok (gateway 524s).
  go test -run Budget ./internal/gui: ok after the raise below.
- Linux (magpie-desktop): go test ./internal/claudetui ok natively,
  the PTY's Linux ioctls among it. GOOS=linux go vet -tags nogui of
  cli, gateway, claudetui, settings ok.
- Linux box, Playwright 1.62, chromium and webkit: claude-tui-setting
  16/16, claude-lean-prompt-setting 16/16, i18n-keys 4/4, mobile-web
  30/30 against 74f1df869's tree. mote's WebKit didn't launch (other
  sessions' GUI suites, running 11-16h, held ~108 WebKit processes),
  so the GUI ran there instead.
- Real Claude Code 2.1.314 on a real Claude account's magpie config dir,
  haiku, through the built helper with the bridge's exact -p arguments
  (an MCP server named magpie with one tool, --tools "",
  --system-prompt-file, --thinking disabled, --effort low,
  --thinking-display): the tool was called without a permission prompt
  and its answer used; the system prompt's end token in every reply;
  a second turn on the same run; a later run with --resume remembered
  the first. All 18 transcript rows say "entrypoint":"cli". Startup to
  init 0.7–1.5s, a haiku turn 1.4–4s. Two messages sent at once are
  one turn, as Claude Code queues them.

Broken by hand:
- each claudeTUI condition taken out in turn (WSL, safeguards, cache
  marks, schema, images, the setting, the 400KB bound): its case red.
  The WSL case first passed with the check gone (its claudeCLI had no
  path); given one, it is red without it.
- the trust check taken out of ready(): TestShimTrustsWhenTold red
  (the run went to -p).

Not tried: a turn through a running gateway into the helper on a real
account (a sandbox HOME would copy the sign-in into a new keychain item
and refresh it apart from the live one); a ~400KB paste; Linux with a
real Claude Code; an API error from the real service (the translator
is tested on its rows). The full go test ./... did not run (mote was held by those suites);
the four packages this touches ran whole.
2026-10-31 03:20:45 +08:00
yetone 1850fa3402 gui: the core's budget takes the 45 bytes b62fa332f added to app.js
b62fa332f (Send requests unmasked for subscriptions and plugin providers
too) added 45 bytes to app.js without raising coreScriptBudget, so
TestCoreScriptBudget is red on main at f2eb56c6b: 1,536,631 against
1,536,586. The budget is raised to the exact size, with no room added.

Run: mote, go test -count=1 -run Budget ./internal/gui at f2eb56c6b:
red before (1536631 > 1536586), ok after.
2026-10-31 03:20:33 +08:00
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