Commit Graph
248 Commits
Author SHA1 Message Date
yetone f5e1b10913 settings: longest context can hold a model's own window too (WJaunita45604 on X)
v0.1.3681's Longest context left a window the user set for a model, or "*"
on its provider, alone even when longer. Settings > Models > Routing now has
a menu beside the field: "Models without their own" (the default, as before)
or "Every model". In both modes the shorter of the cap and the user's own
window is told; they differ only when the user's own is longer (own keeps it,
every model brings it down). Settings.ContextCapAll, Settings.CappedOwn,
POST /api/settings/context-cap-mode {all}, magpie model context-cap all|own.
Applied in provider.windowIn (so /v1/models, catalogs, compaction), Codex's
CodexNativeWindow/CodexWindow (the list's ETag tag carries the mode) and the
gateway fallback window. i18n in zh, zh-TW, ja, de.

Run (wsl-run, mote's disk was full): provider (full), settings, settingsapi,
codexcat packages; cli -run ContextCap; gateway -run ContextCap|ModelsList;
GUI context-cap, i18n-keys, model-load, settings-places, settings-general in
chromium and webkit; TestCoreScriptBudget; gofmt; go vet nogui and
GOOS=windows vet. Broken by hand: windowIn's CappedOwn removed turns
TestContextCapAllHoldsTheUsersOwnWindowsToo red.
Not tried: the whole Go and GUI suites, a real Codex reading the list, macOS
or Windows runs, GUI in zh-TW/ja/de beyond the i18n-keys check.
2026-11-11 14:28:17 +08:00
yetone 58fb070953 settings: named proxies, chosen as inherit, direct or a saved one anywhere a proxy is (@tsingchao on X)
Settings > Network keeps named proxies (name, address, optional login)
with a Test that says reachable and the latency. Everywhere a proxy can be
chosen (global, plugin downloads, a provider, a key, a Claude account) now
has a Saved mode beside the others; the value is "@<id>". Addresses typed
before are read exactly as before, nothing is migrated or overridden.
netproxy.Parse/Resolve/Redact/EnvWith/Dispatch resolve a reference at the
lowest layer, so a proxy edited once reaches the gateway, usage reads,
sign-ins and the plugin host at the next request; Claude Code's
settings.json env (a snapshot) is rewritten by provider.ProxyEdited.
A reference this computer lacks fails closed (DeadProxy), says the proxy's
name in the request error and as "Proxy missing: {name}" on the provider
row, and never goes direct. The password lives in settings.json (0600), is
never read back by the page, logged, or put in Settings sync. The list
rides with the providers part of a sync (Bundle.Proxies, MergeProxies by
id, passwords only with keys). A proxy in use can't be deleted (409).
The saved list's page code is in proxies.js, loaded when Settings draws it;
app.js grew by Saved-mode helpers only, paid for by 16 long comments cut
(core budget unchanged, no raise).

Run (mote refused ssh all session, so Go and GUI went through win-run on
xiaomi-gpu, Windows 11; gofmt and darwin/linux-nogui/windows go vet were
clean on mote before it went down, at the pre-sync tree):
- go test settings, netproxy, backup, settingsapi, davsync: ok on Windows
  (earlier on mote: also gui, provider, plugin with real Bun, gateway).
- saved-proxies.test.cjs 20 of 20 (chromium+webkit, en zh zh-TW ja de,
  420px) twice more on Windows; provider-proxy-missing.test.cjs 20 of 20.
  One webkit de 420px run of saved-proxies failed once under 4-way
  concurrency and passed 3 of 3 alone; not reproduced.
- TestCoreScriptBudget ok after the move (it was 3.4KB over before).
Red on this tree and on origin/main alike (Windows run, not mine):
settings TestSharedCheckedReadsOnceAndKnowsUnknown; provider
Codex keychain/Git tests; plugin TestHostRunsAsMagpieBun, TestPiPackage;
gui TestGatewayHeldByAContainer and others; old-webkit "compat.js is the
first" (headerpresets.js) and ":has() (Safari 15.4)" on origin/main 245f07b19.
Broken by hand: restore skipping Proxies (TestSavedProxiesTravelWithProviders
red), Parse returning nil for a dangling ref (netproxy tests red), the
Proxy-missing badge disabled (provider-proxy-missing 0 of 20), and the Claude
env snapshot failing open (found by reading, test added).
Not tried: real vendors, the real Claude Code, a real two-computer sync, the
macOS suite and the whole GUI suite on this final tree (mote down; the whole
suite ran to test ~3700 on the earlier tree with reds owned by others).
A proxy missing whose sender never had it is named by its id.
2026-11-11 12:26:43 +08:00
yetone 7476328901 settings: one longest context for every model (WJaunita45604 on X)
Settings > Models > Routing has a Longest context field (magpie model
context-cap [<size>|off], POST /api/settings/context-cap). It lowers every
model's window to it, so a user need not set each model. A window the user
set on a model, or on its provider with "*", wins and is not capped; a model
whose window is unknown stays unknown.

It is applied where the window is derived, provider.windowIn, so /v1/models,
every agent's catalog, group windows and the compaction thresholds that
follow the window all agree. Codex's own models take it through
CodexNativeWindow, CodexWindow and codexcat.Cap on the list the gateway
serves; the list's ETag carries the cap so Codex asks again. The provider
editor's Listed value stays the vendor's.

Run (mote): provider, codexcat, cli, settings, settingsapi, gateway tests;
GUI context-cap, model-load, settings-places, i18n-keys, settings-general in
chromium and webkit (en, zh); TestCoreScriptBudget; gofmt; vet on darwin,
linux nogui and windows. Broken by hand: windowIn without the cap turns
TestContextCapHoldsEveryModelButTheOnesTheUserSet and TestModelsListContextCap
red.
Not tried: the whole GUI suite (one row added to an existing list, no new API
read on page load), a real Codex reading the capped list, Windows run.
Not covered: Claude Code's own [1m] choice (claudeRunName) and agent/claude.go's
fallback when a ref has no window.
2026-11-11 11:07:57 +08:00
yetone 71c4ef2d07 gui: Bark push target for every alert, and a daily spend summary (EV_John_Liu on X)
Settings > Usage has a Bark row: a server (default https://api.day.app, or
a self-hosted one) and the device key, then Test and Remove. Every alert
that goes through notifier.sendAs (allowance, balance, reset reminder, task
done, masking, sign-in) is also pushed to Bark when a key is set, whether or
not the system lets this computer notify. A second row, once a key is set,
turns on a daily summary at a time of day: today's cost and request count,
and each window or balance near its cap (the Allowance alert's share, else
80%), capped at 8 lines. It is pushed once a day (a restart does not resend;
a failed push is retried every 15 minutes; one more than 6 hours late is
left), in the page's language (en, zh, zh-TW, ja, de).

The device key is a key: the page only gets barkKeySet, never the key; it has
its own route (POST /api/settings/bark, key omitted keeps it, "" removes it),
a Settings save carries it (settingsapi.Merge), and a backup or sync without
keys leaves it out and keeps this machine's. No log line or error names it
(the Bark client replaces it with "..." in what the server or client says).
bark.js is a lazy module so app.js (budget) gains one line.

Run (mote, at the pushed tree before the rebase onto 6d7862769):
- go test ./internal/bark ./internal/settings ./internal/settingsapi
  ./internal/backup ./internal/davsync ./internal/provider: ok.
- go test -run 'Bark|AlertsGoTo|GitHubToken' ./internal/gui: ok. go vet
  darwin, GOOS=linux -tags nogui and GOOS=windows over gui, bark, settings:
  clean. gofmt -l: clean.
- GUI: bark.test.cjs (5 languages x 900/380px x chromium/webkit), i18n-keys,
  i18n-en-no-cjk, usage-alert: pass. Whole GUI suite started; reds so far are
  in account/agent/checkin tests that do not touch Settings or Bark, filed
  separately after this tag; old-webkit's Safari 15.0 :has() is #5919.
- All against fake servers; nothing reaches the network.
Broken by hand, each went red: no barkPush in sendAs
(TestAlertsGoToBark), BarkKeySet forced true / key shown (TestBarkSettingAndTest),
no same-day check in the daily step (TestBarkDailyStep).
Not tried: a real Bark device or the real api.day.app; win-run and wsl-run
(vet only for those OSes); a self-hosted Bark server.
2026-11-11 03:41:37 +08:00
yetone 1d41799f2a agent: turn off every agent's telemetry from Settings › Privacy (OipsAnthony on X)
OipsAnthony on X: "magpie 设置 - 隐私,支持统一关闭所有 Agent 的遥测功能,
这个统一管理的地方优先级最高". v0.1.3562 gave Codex, Claude Code, Gemini
CLI and Qwen Code a Telemetry row each; there was no one switch for all.

Settings › Privacy now has "Turn off telemetry for all agents"
(settings.AgentTelemetryOff, POST /api/settings/agent-telemetry,
agent.SetTelemetryAll in internal/agent/telemetry_all.go):

- On: every agent found here with a telemetry switch is turned off through
  its own switch and that switch's rules (only keys the file lacks are
  written; a value of the user's own that keeps telemetry on is never
  written over: the agent stays on and the reply's "refused" names it
  and why). Each agent the switch turned off gets a stash marker,
  <id>.telemetry.all. An agent found later is turned off on the next
  state the window reads and by a one-minute gateway loop
  (KeepTelemetryAllOff, in WhileServing).
- While on, each agent's own Telemetry row shows off, says "Off for all
  agents in Settings › Privacy" and its buttons are disabled; the API
  refuses it too (ErrTelemetryAllOff).
- Off: only the marked agents are turned back on, which takes out only
  magpie's keys. An agent off by its own row or the user's own config
  before stays off.
- An unreadable settings.json is unknown: nothing is written.
- The setting is per computer (KeepOwn) and the generic settings POST
  can't change it (settingsapi.Merge carries it).

app.js pays for its ~650 bytes with ten Privacy-section comments cut
(core 1,533,550, under its 1,533,802 budget, no raise).

Run (mote, first on 10bef5fe0):
- go test -count=1 ./internal/agent ./internal/gui ./internal/cli
  ./internal/settings ./internal/settingsapi: ok, except gui's
  TestSettingsSaveKeepsWhatItDoesNotSend, red as it should be for a new
  field; with AgentTelemetryOff in its fixture it and the budget and
  parity tests pass (-run).
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./...: clean. gofmt -l: clean.
- GUI, chromium and webkit: privacy-*.test.cjs (new
  privacy-agent-telemetry: 5 languages x 1100/640px plus a refused case
  in each engine, no scroll on click, no native select), i18n-*,
  agent-telemetry, settings-search, click-scroll: 218 of 218 pass.
- The whole GUI suite (1,367 files) was started under ~/suite.lock and
  never got it: lockf gave up after 4h with the lock held by other runs.

- Rebased on 6a81a3c62 (this commit's parent), again: go vet
  ./internal/... (darwin) and GOOS=windows vet of agent, gui, cli; the
  Telemetry, budget, settings-keep, CLI parity and route tests; GUI
  privacy-agent-telemetry, agent-telemetry, i18n-keys and
  privacy-usage-stats in both engines: 64 of 64.

Broken by hand:
- no stash marker in keepTelemetryOff: TestTelemetryAllOff red, "Gemini
  CLI not back on".
- SetTelemetry without the ErrTelemetryAllOff check: TestTelemetryAllOff
  red, "Gemini CLI's row turned on under the switch".

Not tried: a real agent's config on this computer (sandbox HOME only);
Windows runs of the new Go tests (they skip there, a #! stand-in isn't a
command on Windows; the switch's code has no OS-specific path).
2026-11-11 02:38:58 +08:00
yetone 4623f54190 gateway: HTTPS for other computers, from magpie's CA or an imported certificate (zhangly1 on X)
zhangly1 on X: Claude on another computer on the LAN needed magpie at
https://. Settings → Network and sharing → HTTPS (magpie https on)
serves other computers TLS on the gateway's own port, with a
certificate magpie's CA (the mTLS one, in ~/.config/magpie/mtls) signs
for this computer's names and addresses; this computer keeps plain
http://. The switch is read per connection, so no restart.

- Certificate row: Import… takes the user's own PEM certificate (with
  chain) and unencrypted key, in any files and order; a pair that can't
  be served (no key, no cert, a stranger key, a passphrase, run out,
  nothing PEM) is refused with the reason in the page's language and
  leaves nothing behind. Remove goes back to magpie's CA. --tls-cert
  still comes first.
- magpie's CA row: SHA-256 shown, Save puts magpie-ca.crt in Downloads;
  the gateway serves it without a key at /magpie-ca.crt to any address
  the share lets in. Rows under it give curl -kO, macOS, Windows, Linux
  and NODE_EXTRA_CA_CERTS steps with Copy.
- A page open from another computer can't turn HTTPS on or off under
  itself (it would lose its own address).
- magpie https status|on|off|import|remove|ca --out; the serve banner
  names magpie's CA or the imported file instead of "(mTLS)".
- docs/reference.md and gateway-routing.md say all of it, and that
  Windows' curl.exe needs --ssl-no-revoke for any private CA.

Run:
- gofmt -l clean; go vet linux -tags nogui ./internal/..., GOOS=windows
  and GOOS=darwin -tags nogui vet of the touched packages (WSL, mote
  refused ssh all evening).
- WSL: go test -tags nogui gateway -run HTTPS|MTLS|ClientCert|CAFile|TLS|LAN
  ok; gui -run HTTPS|MTLS|Keep ok; settings, settingsapi, mtls ok;
  cli -run Help|HTTPS|TLS|Serve|Banner|Flag|Unknown ok. The whole cli
  package hit its 40m timeout in TestEveryAgentFieldNameWritesNothing
  (#5234, #4247, not this change).
- GUI (WSL Playwright, chromium + webkit): https-settings (en, zh, 390px,
  strings in all four languages) ok, plus mtls-settings, allow-ips,
  browser-access, cors-origins, gui-de/ja/zh-tw, i18n-keys,
  i18n-en-no-cjk, lan-*, public-url*, api-key-theme,
  connect-address-kept, gateway-connect-keys, gateway-caller-keys,
  side-gateway-lan, menu-scroll. Reds at load ~130: api-key-theme
  (#5044), connect-address-kept (#5972), gateway-caller-keys (#2572),
  gui-ja (#5943), lan-docker (#4692), all red the same at base
  10bef5fe0 run beside it; allow-ips and gateway-connect-keys went red
  once under that load and pass 18/18 at concurrency 1, base and this
  change side by side.
- Real: a sandbox HOME gateway built from this tree on WSL
  (MAGPIE_ADDR=0.0.0.0:3593, a gateway key, magpie https on, magpie
  serve). From the Windows host: curl -k /magpie-ca.crt 200 without a
  key; Node fetch with NODE_EXTRA_CA_CERTS=magpie-ca.crt 200 on
  /v1/models, 401 without the key, SELF_SIGNED_CERT_IN_CHAIN without
  the CA; plain http:// 400; curl.exe --cacert needs --ssl-no-revoke
  (schannel), then 200. Cert SANs: localhost, the hostname, .local,
  127.0.0.1, ::1 and every address. magpie https import of an openssl
  CA's leaf on the running gateway: Node trusting that CA 200, magpie's
  CA alone refused. remove + off on the running gateway: plain http://
  from Windows 200. This computer's plain http:// 200 throughout.
- At the pushed tree (on origin/main ee818e8bc), WSL:
  gofmt -l clean; go vet -tags nogui linux, GOOS=windows, GOOS=darwin
  nogui of gateway, gui, cli ok; go test -run 'HTTPS|CAFile|MTLS|LAN'
  gateway, gui ok. GUI https-settings, mtls-settings, i18n-keys,
  gui-de/ja/zh-tw, allow-ips, lan-* (both engines): 147/155; reds are
  gui-ja (#5943), lan-docker (#4692), allow-ips webkit under load, and
  gui-zh-tw chromium under load (2 of 3 green alone, filed #5983).

Broken by hand:
- TLSOn without HTTPSOn: TestHTTPSOtherComputer red.
- lanGuard without the caFileOpen exemption: TestHTTPSCAFile red.
- mtls config without GetCertificate = settingsCert: all three
  serving tests red.
- app.js without renderHTTPS(s): https-settings red in both engines.

Not tried: the macOS, Windows and Linux system trust commands on a real
store (they change the box's trust); Claude Desktop itself; a darwin
GUI run (mote unreachable); the full suite before the tag (started
after it).
2026-11-10 23:05:47 +08:00
yetone 71075af726 codex: "subagents on any model" tells Codex V1 for a relay of the ChatGPT backend too (brethhbbm on X)
brethhbbm on X: lead on relay/gpt-6-astra, subagent model set to
relay/gpt-6.1-terra, "Codex subagents on any model" on. A new session's
subagents still ran on Astra, and Routing said the task was sealed and
only a ChatGPT account could read it. The model's catalog entry still
said multi_agent_version "v2".

Cause: the setting (settings.CodexAgentsV1) stamped V1 only on the
ChatGPT account's own models (codex/) and the groups one is in (Fast).
The relay lists Codex's own entry for gpt-6-astra (a sub2api asked with
Codex's client_version), "v2" included, and a relay offering Ultra is
given "v2" (AgentsV2) besides. In V2 Codex hands the lead the
collaboration namespace (spawn_agent etc.), whose arguments a relay of
the ChatGPT backend seals as the backend does (#1109), so
codexSubagentPick kept the subagent on the lead's model (sealedKept).

Fix: catalog.Model.Seals (provider.CodexSeals) marks a model whose
provider is of no sign-in on the Responses API, as the gateway's
canSeal, or a group with such a member. With the setting on, its entry
says V1 like the ChatGPT account's, listed by its relay or made by
magpie, so the task goes as text and the model set for subagents takes
it. Seals is in the list's tag, so Codex asks for the list again. A
model of an account that seals nothing (Copilot's Ultra, #656) keeps
V2, and with the setting off every entry is as before. No prompt text
or instructions change.

Real Codex (0.165.0, sandbox HOME/CODEX_HOME, fake Responses server,
model_catalog_json with the user's gpt-6-astra entry as
relay/gpt-6-astra): with "v2" the first request carries the
collaboration namespace (spawn_agent, send_message, followup_task,
wait_agent, ...); with "v1" it has none.

Run (Linux box via wsl-run; mote refused SSH for the whole session):
- go vet -tags nogui (linux), GOOS=windows go vet, GOOS=darwin
  CGO_ENABLED=0 go vet -tags nogui on codexcat, provider, agent,
  catalog, settings: ok; gofmt -l clean
- go test -tags nogui -count=1 ./internal/codexcat ./internal/catalog
  ./internal/settings ./internal/provider: ok
- ./internal/agent, and -run 'Codex|Ultra|Subagent|Sealed|Collab|AgentsV1'
  ./internal/gateway, were still running when this was pushed; their
  results go on the release's issue thread if red
- at the pushed head (rebased on c2c2c82ca), Windows box: go vet on the
  five packages, and -run 'CodexSeals|CodexAgentsV1|Ultra' codexcat and
  provider: ok
- earlier on mote: -run 'CodexSeals|CodexAgentsV1|Ultra|CodexListed|Listed'
  ./internal/codexcat ./internal/provider: ok

Broken by hand: dropping m.Seals from both V1 conditions in codexcat
makes TestCodexAgentsV1SealingRelay red ("on: map[... relay/gpt-6-astra:v2]");
CodexSeals setting false makes TestCodexSeals red ("relay/gpt-6-astra:
Seals false, want true").

Tests: TestCodexAgentsV1SealingRelay (a relay's listed v2 entry and a
made Ultra entry say v1 with the setting, Copilot's keeps v2, all as
before with it off), TestCodexSeals.

Not tried: a real relay of the ChatGPT backend end to end with a real
subagent spawn; Codex 0.165 exec showed no V1 spawn tools in its first
request (they are deferred), so the V1 side was checked by the
collaboration namespace being gone. No GUI is reachable from this
change. A thread started before keeps the version it started with; a
new session is needed.
2026-11-10 21:05:34 +08:00
yetone 99b080e2ee agents: an agent can have its own Provider in model names (KillTry27355 on X)
"希望 可以在不同的 agent中选择是否显示供应商名字,现在只能统一开关":
Provider in model names was one switch for every agent. An agent's
Details on the Agents page now has a Provider in model names row: As in
Settings · <mode> (the default, kept for everyone), On, Not on names I
set, or Off, for that agent alone. The CLI has the same thing:
`magpie model suffix <agent> [on|own|off|every]`.

- settings.AgentSuffix keeps the agent's own mode by the id its lists are
  kept by (Agent.ListsFor, lower-cased, without @wsl: or #profile). An
  agent with none follows PlainNames/PlainOwnNames as before, so nothing
  a user already set changes.
- provider.LabelsFor(agent, es) reads that agent's mode. Every place
  that named models with Labels for an agent now passes the agent: Codex's
  catalog, the agents' written lists (route.go, Pi's extension), the
  gateway's /v1/models (by agentOf(r)), Muse, Antigravity, Ollama, Claude
  Desktop's catalog and descriptions, Claude Science. Labels is
  LabelsFor("").
- POST /api/settings/agent-suffix sets it and rewrites the agents'
  configs (catalog.Touched), as Settings' switch does.
- docs/subsystems/agent-wiring.md says where the mode is kept and read.
- The picker is in agentsuffix.js, imported when an agent's Details open,
  so the core grows by the one line that loads it (1,529,335 of its
  1,533,802 budget, after the previous commit's move). An agent whose
  list takes no names of magpie's (noNames) has no row.

Tests, each red on the old code: TestAgentSuffix (provider: modes, keys
with @wsl and #profile, reset, bad input), TestAgentSuffixReachesItsFileAlone
(agent: Pi's file follows its own mode while Codex's follows Settings'),
TestModelsListFollowsAgentSuffix (gateway /v1/models per agent),
TestModelSuffixAgentCmd (cli), settings_keep (AgentSuffix survives a
Settings save), agent-suffix.test.cjs (5 languages x 1180/390 x chromium
and webkit, and a noNames agent has no row).

Broken by hand (a copy with LabelsFor ignoring the agent and the picker
reading no own mode): TestAgentSuffix, TestAgentSuffixReachesItsFileAlone,
TestModelsListFollowsAgentSuffix and every agent-suffix GUI case went red.
TestModelSuffixAgentCmd stayed green; it checks what is saved, not the
names.

Run on mote at this change on top of 720200092: gofmt -l clean; go vet darwin, GOOS=linux
-tags nogui and GOOS=windows clean; go test -count=1 of internal/provider,
cli, gui, settings, settingsapi and agent: ok; internal/gateway in an earlier
run of this change at 3b261932e: ok (1044s), and at this head -run
'Desktop|Models|Suffix|Science|Muse|Ollama|Antigravity|Codex.*Catalog': ok.
node --test of every agent-*, i18n-* and gui-* file plus old-webkit, both
engines: 1026 of 1049. The reds are all on main or under load:
agent-switch-accounts' 20 not-connected cases (red at origin/main 7c41060c2
too, filed as #5925), old-webkit's Safari 15 styles (#5919), and one case
each of agent-compact (#5607) and agent-stale-copies (#1949), which pass
44/44 when run alone. panel-fold's 'keeps what was clicked' is red on main
too (#5796).

Rebased on 0f94acc99 and run again at this change (9d82986ea): gofmt
clean, go vet clean for darwin, linux (nogui) and windows; provider,
gui, settings, settingsapi and agent ok, the gateway's suffix and
agentOf tests ok; GUI agent-suffix, old-webkit, agent-bulk-visibility,
visibility-saving, i18n-keys and i18n-en-no-cjk in chromium and webkit,
57 of 58, the one red Safari 15's styles (#5919). internal/cli was red
only on /api/model-price having no command, from main's 40ca0c88d;
the next commit names it. Rebased again on ccc96b4a7 before the push
(proc, codex, claudetui, a remote window, routing rules, redact;
no conflict), core budget test ok there.

Not tried: a real agent with a real account picking its own mode; WSL and
Windows agents (the @wsl: key is covered by a unit test only).
2026-11-10 18:57:16 +08:00
yetone add0dadd4f codex: a service tier set in Codex's settings goes on every request of Codex's (JackyFill on X)
JackyFill asked for a choice in Codex's agent settings that rewrites
service_tier: follow the request, force Fast, force Ultra Fast. Codex's
settings on the Agents page now have "Codex service tier", picked from
the app menu: As Codex asks (the default, nothing changes), Standard,
Fast or Ultrafast.

The values are Codex's own request values (codex-rs protocol
config_types.rs ServiceTier, tui service_tier_resolution.rs): Fast is
"priority", Ultra Fast is "ultrafast", and Standard sends no
service_tier. Flex isn't offered: the ChatGPT backend's requests drop
it (codex_request.go).

settings.CodexServiceTier ("", "default", "priority", "ultrafast";
anything else refused) is set through POST
/api/settings/codex-service-tier. codexTiered rewrites the body where
Codex's requests come in, on both ways: codexBackend (Codex signed in,
/backend-api/codex) and the main handler's Codex-on-Responses block,
which a websocket turn goes through too. It applies only when the
request is Codex's (fromCodex or agentOf == codex). Everything after
treats it as Codex's own ask: an account whose list lacks Ultrafast is
put after a mate that has it or sent priority. A bare model (Codex's own
sign-in, whose plan magpie doesn't know) gets ultrafast only where one
of magpie's Codex accounts lists it on the model (UltraModels), else
priority. The body is edited with topMember/withoutTopMember, no full
decode. Fast picks still apply after, unchanged.

Run (mote):
- TestCodexServiceTierSet, TestWithServiceTier: ok. The test signs in a
  Plus and a Pro ChatGPT account against a fake backend whose lists offer
  gpt-6-luna's Ultrafast to Pro only, and checks the tier sent for each
  setting x what Codex asked, through /v1/responses (account:tier tried)
  and on /backend-api/codex for a model with Ultrafast and one without;
  OpenCode's own priority is left alone; "flex" is refused.
- go test -count=1 -timeout 45m ./internal/settings ./internal/provider
  ./internal/gui ./internal/gateway: ok but internal/gui, which was red
  twice: TestCoreScriptBudget (1,535,075 > 1,533,802) and
  TestSettingsSaveKeepsWhatItDoesNotSend (a save of the Settings page
  dropped the tier). Paid for by eight Codex-row comments cut in app.js
  (now 1,533,416), no raise; settingsapi.Apply keeps CodexServiceTier
  as it keeps the other Codex rows. At the pushed head: go test
  ./internal/settingsapi ./internal/settings ./internal/gui ok, the two
  gateway tier tests ok.
- go vet darwin; GOOS=linux -tags nogui; GOOS=windows (gateway,
  provider, settings, gui): clean. gofmt -l: clean.
- GUI, chromium + webkit: codex-service-tier (new, en/zh/zh-TW/ja/de at
  900 and 400px: 20/20), agent-prefs (56/56, Codex's row list updated),
  i18n-keys, i18n-en-no-cjk, settings-search, codex-titles,
  codex-subagent-model, settings-general, codex-sheet-providers,
  click-scroll: all pass; at the pushed head codex-service-tier,
  agent-prefs, i18n-keys, settings-search, codex-titles,
  codex-subagent-model, settings-general, click-scroll: 166/166.

Broken by hand:
- codexTiered returning the body as it came: TestCodexServiceTierSet red
  (17 lines).
- the Ultrafast-to-Fast downgrade for a bare model removed: red on
  gpt-6-sol (sent ultrafast, want priority).
- the GUI posting to the wrong path, and the row left out of Codex's
  AGENT_PREFS: codex-service-tier red in chromium and webkit.
- settingsapi without the CodexServiceTier keep:
  TestSettingsSaveKeepsWhatItDoesNotSend red.

Not tried: a real ChatGPT account's Ultrafast or Fast request with the
setting on (only the fake backend), a real Codex websocket session, and
Windows/Linux runs of the GUI.
2026-11-10 15:24:40 +08:00
yetone efb75ad1f0 gateway: client certificates (mTLS), and Remote Magpie can show one (hhdaxia on X, #5596)
hhdaxia on X asked for mTLS so a shared magpie isn't open to the internet
on a key alone; clxsh's #5596 asks Remote Magpie to send a client
certificate and key (PEM) to an Nginx doing mTLS, the server still
verified, the Gateway Key still sent, for models, the test and streaming.

Server side (magpie's own CA, internal/mtls):
- Settings -> Network and sharing -> Require a client certificate, or
  `magpie mtls on|off|issue <device>|list|revoke`. Issue saves
  client.pem, client-key.pem and ca.pem to ~/Downloads/magpie-<device>;
  the key is kept nowhere else.
- With it on, a peer that isn't this computer or a WSL distro must finish
  the TLS handshake with a certificate the CA issued and hasn't revoked
  (RequireAndVerifyClientCert + VerifyConnection -> Admits). The TLS
  config is chosen per connection, so the switch needs no relisten;
  without --tls-cert the server certificate is made by the CA in memory.
- lanGuard and ClientCertGuard (magpie web's page) refuse 403 what still
  arrives without a verified one: plain HTTP, a proxy or tunnel on
  loopback (unless MAGPIE_TRUST_PROXY=1), the page port, a connection
  from before the switch, a certificate revoked since its handshake.
- Loopback, this computer's own address and a WSL agent with its key are
  answered as before.
- A page open from another computer can't shut itself out: without a
  certificate it can't turn mTLS on, and it can't revoke or reissue the
  certificate it came with.

Client side: a provider with a base URL of the user's own (Remote
Magpie included) takes ClientCert, ClientKey and ServerCA paths (editor:
Advanced -> Client certificate). netproxy.WithClientCert shows them to
that provider's own hosts only, on a transport per identity keyed on the
files' mtimes; through an https:// proxy such a request is refused. Save
refuses half a pair, a pair that doesn't match and a CA that isn't one.

Run (on mote, at 4024df0f9, this commit before its rebase):
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- go test -count=1 ./internal/mtls ./internal/netproxy ./internal/provider
  ./internal/settings ./internal/settingsapi ./internal/cli ./internal/gui
  ./internal/gateway: ok (gateway 893s). The first run had three reds of
  this change, each green at base and fixed here:
  TestEveryRouteHasACommandOrIsNamed (the mtls routes now name `magpie
  mtls`), TestSettingsSaveKeepsWhatItDoesNotSend (MTLS kept), and
  TestGoroutineDumpAnswersWhileRequestsWait (mtlsRefuses asks whether the
  peer is remote before reading settings, so a local request never waits
  on the settings lock). TestHandedOffGatewayAnswersAConnectionNotedLate
  was reset because ServeTLS now always wraps the listener: tlsListener
  hands a connection it took as Close came to the server instead of
  dropping it. -count=3 of these and every TLS/MTLS/Handover/Relisten test
  ok.
- Every route without a certificate, with a foreign one, a revoked one
  and a good one: TestMTLSOtherComputerHandshake, TestMTLSGuardEveryRoute,
  TestMTLSThisComputerAndProxies, TestMTLSToggleWithoutRelisten,
  TestMTLSRevokeMidConnection, TestClientCertGuardPage. Remote Magpie
  against an httptest server asking RequireAndVerifyClientCert: models
  and the connection test fail without the certificate and pass with it
  (TestRemoteMagpieClientCert).
- GUI: the 92 files near the change (settings-*, provider-*, editor-*,
  lan-*, i18n*, allow-ips, remote-*, mtls-settings new) in Chromium and
  WebKit: 2904 pass, 74 fail, all in nine files red the same way at base
  0791c91c5 and listed in #5872 (editor-thumbs-batched also #5886;
  provider-fetch-again #5057 #5232; provider-many-keys, -models-rest,
  -picks-stay, -typed #5475 #4396 #5233 #4673; remote-magpie #4398;
  settings-hints, settings-lines-wrap run alone at base and here: the
  same 8 reds). The whole GUI suite and the whole Go suite were not run:
  mote's suite lock had about 15 runs queued at load 31-40.

Rebased on 031938ca9 (one conflict, internal/gui/api.go's route list,
both kept) and run again there: gofmt clean, vet on three systems, go
test ./internal/{gui,cli,mtls,netproxy,provider,settings,settingsapi} ok
(cli with the next commit's line), the gateway's TLS, MTLS, Handover,
Relisten, HandedOff, GoroutineDump, ClientCert and RemoteMagpie tests ok,
TestCoreScriptBudget ok, and mtls-settings, i18n-keys, allow-ips and
provider-insecure-tls in Chromium and WebKit: 143 pass, 0 fail.

Broken by hand, each red:
- lanGuard without refuseWithoutClientCert: TestMTLSGuardEveryRoute,
  TestMTLSThisComputerAndProxies, TestMTLSRevokeMidConnection.
- VerifyClientCertIfGiven and no Admits: TestMTLSOtherComputerHandshake.
- netproxy.With keeping another provider's certificate:
  TestClientCertOnlyItsHost.
- The page-lockout and own-serial guards in internal/gui/mtls.go:
  TestSettingsMTLSPageLockout.

Not tried: a real Nginx doing mTLS; a Windows or Linux run (vet only);
installing the certificate in a browser (there is no .p12 yet); a
proxy that checks certificates itself with MAGPIE_TRUST_PROXY=1.
2026-11-10 14:27:21 +08:00
yetone e4197144a8 perf: every package's package-level regexps compile on first use
v0.1.3516 made gateway's and redact's patterns lazy. The other 299
package-level regexp.MustCompile calls, in 148 files across agent,
provider, gui, library, codexcat, sessions, usage, plugin and the rest,
now go through lazyre.New too, so a launch that never reaches them
(`magpie statusline`, run by Claude Code on every message) doesn't
compile them. Fields, maps and params that held them are *lazyre.RE.

Measured on mote (M5 Pro), sandbox HOME, v0.1.3516-equivalent build
(t42) against this one (t43):
- GODEBUG=inittrace=1 sum: 7.39 MB / 69,837 allocs -> 4.62 MB / 46,765
- `magpie statusline`, 3 runs each: instructions retired ~212M -> ~176M,
  peak memory footprint 19.2-19.4 MB -> 16.8-17.0 MB

Run: go vet ./... (darwin) ok; GOOS=windows go vet on each of the 30
changed packages ok; GOOS=linux go vet ok except ., internal/cli and
internal/gui, which stop in wails v3's cgo files when cross-compiled
(the same at main). New TestAllLazyPatternsCompile at the root compiles
all 574 registered patterns (ok), so a bad pattern fails a test rather
than a first use.
Not run before push: the changed packages' own test suites; they run
on mote after it.
2026-11-10 12:54:39 +08:00
yetone 4bfac12683 plugins: downloads take a proxy of their own, apart from the vendors' (JonahFu on X)
JonahFu on X: GitHub is unreachable without a proxy, while API requests
may go direct, so plugin downloads' proxy should be set apart from the
one model requests take.

Before: plugin downloads already followed the global proxy (fetches
through http.DefaultClient and netproxy.Func, bun add and git through
netproxy.Env), so nothing ignored it; there was only no way to give
them a different one.

Now Settings › Network has a Plugin downloads row under Proxy: Same as
above (the default, unset: downloads follow the global proxy as
before), Direct, or Custom with its login, remembered as
pluginProxyCustom as Proxy's Custom is. The CLI takes it as
`magpie settings set pluginProxy <url|direct|"">`. It covers the plugins
list and Discover's lists (fetchJSONFrom), a user's own npm registry
(fetchRegistry), Bun's download (getURLFrom), bun add/update/remove and
the git commands of GitHub-installed plugins (dlEnv). The plugin host
(bun run) keeps the global proxy: its requests are the vendors'. Both
fields belong to this computer (KeepOwn) and are left out of
auto-backups, since a proxy URL may hold a password. Settings' Proxy
row and the new one are drawn by one helper (proxyRow); the core's
script budget is met by cutting the proxy rows' comments, no raise.

Run (mote, through mote-run): gofmt -l clean; go vet of the touched
packages (darwin), GOOS=linux -tags nogui ./..., GOOS=windows of the
touched packages; go test -count=1 internal/settings, settingsapi,
backup, netproxy, plugin, gui, cli all ok (gui after the comment cut;
its first run had TestCoreScriptBudget 1,352 bytes over). GUI, chromium
and webkit: settings-plugin-proxy (new, 5 languages x 2 widths),
settings-proxy-remember, settings-proxy-auth, proxy-test,
settings-sections, proxy-login-fields and the i18n files: 102 pass, 0
fail. plugin-proxy-page, proxy-own-wording, account-proxy,
provider-proxy, routing-proxy, provider-many-keys-proxy and
signin-proxy: 104 pass, 2 fail, both signin-proxy's "a subscription
with no proxy offers the global one" at 380px in Chromium, red the same
way on origin/main b596da773 (filed #5866).

Again at this commit, rebased on b596da773: gofmt, the three go vets,
the seven packages' go test (all ok, TestCoreScriptBudget included) and
settings-plugin-proxy, -remember and -auth (50 pass, 0 fail).

Broken by hand: fetchJSONFrom without netproxy.Downloads ->
TestPluginDownloadsTakeTheirOwnProxy red (the list went direct and hit
testenv's offline guard); bunCommand always taking env() -> red (bun
add's HTTPS_PROXY ""); the GUI row saving key "proxy" ->
settings-plugin-proxy 10 of 10 red in chromium.

Not tried: a real install behind a real proxy with GitHub blocked; the
Library's (skills, MCP) downloads and plugin icons (loaded by the
webview through usemagpie.ai) still follow the global proxy; Windows.
2026-11-10 11:44:17 +08:00
yetone 6ce663c0ce check-in: a time of day every daily check-in waits for (times_ang on X)
times_ang asked on X: 可以调整自动签到的时间吗. Before this, the daily
check-in had no time to choose. The loop first looks 2 minutes after start,
asks every 30 minutes, and asks as the Beijing day (UTC+8) turns. So an
account was checked in at the first look after 00:00 Beijing, on whatever
clock the computer kept.

settings.CheckinAt ("15:04", local time) is one time for every check-in:
the built-in WorkBuddy, Trae, MiniMax and Qoder ones and the plugins'
auth.checkin.
- checkinGate puts it on the Beijing day the account is checked in for:
  the first HH:MM on the computer's clock at or after that day's start.
- The loop holds each account's first ask of a Beijing day until then,
  and wakes at it.
- Within the day nothing changes: a vendor's own turn (a plugin's until),
  retries and the before-noon recheck. So a vendor day is never skipped.
- Unset keeps today's behaviour.
- A press (Check in now, `magpie accounts checkin`) is never held.

Where to set it:
- The editor's check-in groups get a Check-in time row (Off/On and a time
  box, as the warm-ups do), drawn by checkinnow.js so the core stays in
  its budget.
- The Usage card's not-yet line says "checks in from 09:00".
- From the CLI: `magpie settings set checkinAt 09:00`.

Run (on mote unless named):
- go test ./internal/provider ./internal/gui ./internal/tui; settings,
  settingsapi and cli.
- The check-in tests again with TZ=UTC and TZ=Pacific/Kiritimati.
- TestCheckinAt*/TestCheckinGate on Windows (win-run).
- TestCoreScriptBudget at the rebased head: 1,533,673 of 1,533,802.
- gofmt; go vet for darwin, linux (nogui) and windows.
- GUI: checkin-at.test.cjs (chromium and webkit, 1100 and 420 wide, en,
  zh, zh-TW, ja, de) plus 27 more files the change reaches (check-in,
  warm-at, provider-prefs, settings, i18n, gui-de/ja/zh-tw).

New tests, with the zone held in UTC+8 and in UTC-5:
- One ask per Beijing day, at the set time, with no day skipped.
- A press goes ahead of the time.
- A vendor whose day turns at 10:00 gets one ask a day at 20:00.
- Save refuses 25:00.

Broken by hand:
- The gate off: the Beijing 09:00, New York 23:30, press and vendor-day
  cases went red.
- The row not drawn: checkin-at 0 of 40.

Not tried:
- Real vendor accounts.
- The real Linux app.
- The whole GUI suite; the full Go suite runs after the tag.
2026-11-10 11:17:07 +08:00
yetone 60f0433d1b dsh: a model of its own for DeepSeek Harness's compaction (Musikrv77852 on X, #5395)
DSH compacts on the session's latest model (compaction-basic with no
summarizationModel). A session on magpie/workbuddy/deepseek-v4.1-flash
switched to another model compacted on WorkBuddy first, got 429, and the
switch failed.

DeepSeek Harness's opened row on the Agents page now has a "compaction
model" square (compact_model), offered once dsh is on magpie's route. It
is magpie's own Live setting (settings.DshCompactModel), so nothing is
written into dsh's profiles and no restart is needed. The gateway moves a
dsh compaction to it (dshCompactTo, Route.Moved why "dsh-compact") when
the model is enabled, served by its exact id and allowed to the key; else
the compaction stays as asked with a log line. The Routing page says why.

On magpie's llm-pi-ai routes DSH sends no x-deepseek-harness-compact mark,
so its compaction is now known by compaction-basic's own ask
(@deepseek-ai/dsh-compaction-basic 0.0.1-rc.3, the latest) in
compactAsks. As a result DSH compactions show as Compaction in Usage and
Routing, and a group's Compact rule reaches them too.

The options are spelt magpie/<id> like the model field's, so
`magpie dsh deepseek/flash` still sets the model (fieldForValue gives a
bare value to the first field offering it). CLI: `magpie dsh
compact_model magpie/deepseek/flash`; API: /api/set. zh, zh-TW, ja and
de strings added.

Run (mote): go test -count=1 -timeout 45m on internal/gateway,
provider: ok at the base before the rebase on 0842bc517; agent, gui,
settings, settingsapi, and the gateway's TestDsh/TestCompacting/
TestRuleCompact: ok at this head. The first agent run caught the square
reading dsh's profiles at a stopped WSL distro (TestWSLColdPlaceOpensNothing,
#3896); its options now look at nothing at a cold place. go vet on darwin,
GOOS=linux -tags nogui and GOOS=windows: clean. gofmt clean. GUI in
chromium and webkit: dsh-compact-model (new, 5 languages x 2 widths),
desktop-subagent-model, codex-subagent-model, routing-moved-why,
i18n-keys, i18n-en-no-cjk, claude-subagent-effort-row,
codex-start-model-field, model-test-why and agent-connect-no-models: 140
of 140 pass; after the rebase (i18n.js changed upstream) i18n-keys,
i18n-en-no-cjk, dsh-compact-model and routing-moved-why 48 of 48.

Broken by hand, each red: dropping the compactAsks line (TestCompacting,
TestDshCompactMoved on all three protocols), skipping the move in serve
(TestDshCompactMoved), dropping the agent check (TestDshCompactLeft's
other agent), taking the square out of extra() and dropping the routing
story's case (dsh-compact-model.test.cjs).

Not tried: a real DeepSeek Harness desktop app (none on this Mac or on
mote); the compaction text was checked against the npm package's source.
DS Bot's requests can't be told from dsh's, so its compactions follow
the same setting, though it has no square of its own.
2026-11-10 11:05:59 +08:00
yetone 47f70a077f perf: the allow list and state read settings without a copy of their own
Every request served by the GUI and the gateway goes through AllowGuard,
and AllowGuard read the allow list through settings.LoadChecked. That
call reflect-copies the whole Settings each time. /api/state did the same
through Load, then only encoded the result.

Changes:
- New settings.SharedChecked(). It is Shared plus LoadChecked's error.
  While settings.json parses whole it returns the settings parse already
  keeps, with no copy. Otherwise, or while a write is in progress, it
  falls back to loadChecked, so an unreadable file is still unknown,
  never an empty list.
- allowList reads AllowIPs through SharedChecked.
- state() reads settings through Shared. Nothing in gui writes into
  stateJSON.Settings (grepped for field, map and append writes).

Measured on mote with the real-account sandbox, allocations under
Settings.clone/deepCopy over 40 /api/state polls:
- before: 1.5 MB and 1 MB
- after: 0 and 0
The totals vary run to run (t32 34.6-35.1 MB, t33 24.8-30.8 MB).

Run on mote:
- go vet on settings, gateway and gui.
- go test, all of internal/settings.
- go test, internal/gateway -run "Allow|Remote|LAN|Lan|Origin|Guard".
- go test, internal/gui -run "State|Settings|Allow".
All ok.

New test: TestSharedCheckedReadsOnceAndKnowsUnknown checks that a change
is read and that a file that doesn't parse is an error. With the shared
path broken by hand (made to fall through to loadChecked), it goes red:
24 allocations against LoadChecked's 24.

Not tried: the full gateway and gui suites.
2026-11-10 08:50:13 +08:00
yetone ab084fdf25 gateway: a model's own system prompt, added after the agent's on every route (liucl on X)
liucl asked for a system prompt per model rather than per agent. A
provider's editor now has a System prompt box in each model's Model
settings row (Providers > a provider > Model settings). The gateway adds
the text after the agent's own system prompt on every request for that
model, whatever agent sends it. Empty, the default, sends the body byte
for byte as before.

It is only ever appended. Codex's base_instructions, Claude Code's
identity block and any agent's prompt stay first and unchanged
(withModelSystem in internal/gateway/model_system.go), in the agent's
protocol, in serve's candidate loop after triedOn, so before translation
and before a plugin's fetch:
- Anthropic: string system + "\n\n" + text; a block array gets one more
  text block; none gets system.
- Chat: the last leading system/developer message gets it after a blank
  line (or one more text part); none gets a system message first.
- Responses: a developer message after the leading system/developer
  items, instructions untouched; a string input becomes that message plus
  the user's; none when previous_response_id is set (the turn it follows
  had it).
- Gemini: systemInstruction / system_instruction gets one more part.
count_tokens counts it (countOn). magpie's own asks (search and vision
side calls, Codex titles, the router's classifier) get none. A fallback
to another model gets that model's own, or none.

Stored as settings.modelSystemPrompts["pid/model"] (SetModelSystemPrompt:
trimmed, at most 64KB, no NUL, a model the provider serves), saved through
modelPrefs[id].system; renames carry it (perModelFields). The Restore
default title now says it takes the system prompt away too; the four
tests that pin that title follow it. app.js stays in its budget with one
comment cut, no raise.

Run, on mote at this head:
- TestModelSystem* (every wire format with exact bytes, empty unchanged,
  own asks skipped, messages/chat/responses/gemini/count_tokens routes,
  another model sent byte for byte as before, a plugin's model),
  TestProviderSaveModelPrefs, settings keep test.
- Broken by hand, each red then restored: no call in serve, no call in
  countOn, prepend in Anthropic, empty not guarded, own asks included, any
  model of the provider; SetModelPrefs ignoring system; the GUI not
  staging it.
- GUI: model-system-prompt.test.cjs (Chromium and WebKit, en zh zh-TW ja
  de, 1200 and 420px), model-limits, model-headers, provider-same-as,
  provider-detect, provider-listed-as, i18n-keys.
- Real run: Claude Code 2.1.321 -p in a sandbox HOME and
  CLAUDE_CONFIG_DIR, through a sandbox `magpie serve` built from this
  tree, to a fake Anthropic upstream recording bodies. Its /v1/messages
  system had 3 blocks, Claude Code's own first, the prompt once, at the
  end of the last block; count_tokens sent "Be terse.\n\nAlways answer in
  Chinese."
- gofmt; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...: clean.
- The full go test -timeout 45m ./... and the whole GUI suite were
  queued on mote at this head and run after the tag (the owner's ship-now
  rule); what they find goes in follow-up commits.

Not tried: Codex or any agent other than Claude Code for real; a real
vendor upstream; the Responses, chat and Gemini shapes only through the
gateway tests' fake upstreams.
2026-11-10 07:25:54 +08:00
yetone 39569d5604 claude desktop: an optional Claude Magpie app beside your own Claude (#5671)
baranwang on X asked to keep Claude Desktop's own (1P, Anthropic) sign-in
while using magpie. Turning on "Separate app" in Claude Desktop's row on
the Agents page (or `magpie claude-desktop launcher add`) moves magpie's
3P wiring into ~/Library/Application Support/Claude-Magpie-3p and adds
~/Applications/Claude Magpie.app. That launcher opens Claude.app with
--user-data-dir on that folder, so it runs side by side with the user's
own Claude.app. Its icon is Claude's icon with a magpie badge. Off is the
default, and turning it off (`launcher remove`) moves the wiring back
and removes the app. It is macOS only: Desktop's packaged app strips
CLAUDE_USER_DATA_DIR, and on Windows it hardcodes LOCALAPPDATA\Claude-3p.
The folder ends in -3p because Desktop adds -3p to any other name.
Restarting the isolated app ends only its own process (pkill on its
--user-data-dir) and opens the launcher again.

Run at 1b25cda26 (this change on origin/main be9dbce02); rebased onto
fdabddeb4 (catalog only), then go build ./..., vet and the budget and
launcher tests again: ok. All
on mote:
- gofmt -l clean; go vet ./internal/...; GOOS=linux go vet -tags nogui
  and GOOS=windows go vet on agent, cli, desktopiso, desktopdir, gui.
- go test (whole packages) desktopiso, desktopdir, settings, settingsapi,
  proc: ok. -run Isolated|TestDesktopInstance|TestAddStartsDesktopOnTheFolder|
  TestScript|TestAddLeavesTheirs|ClaudeDesktop|Restart in agent;
  TestClaudeDesktopLauncher|TestEveryRouteHasACommandOrIsNamed|Help in cli;
  TestCoreScriptBudget|TestSettingsSaveKeepsWhatItDoesNotSend|Budget|Desktop
  in gui and gateway: ok.
- An earlier full `go test ./...` at fef23255f had four reds, all from
  this change and fixed here: the route without a command (now in
  notYet), settings_keep's DesktopIsolated, os/exec instead of proc, and
  the core script budget (paid by sharing the switch helper with the
  largest-window line and cutting comments; no raise). A second full run
  of the touched packages queued ~7h on mote's suite lock behind other
  sessions and was stopped; the targeted runs above replace it.
- GUI on mote, both engines: desktop-isolated (new; en, zh, zh-TW, ja,
  de; 1100 and 640; aria-checked, posts, status text, no scroll, no
  select, absent without `isolated`), desktop-longest, click-scroll,
  plain-names, i18n-keys: ok. page-width-steady, panel-fold and
  zero-priced-free are red, the same 33 tests at origin/main be9dbce02
  (diffed): #4541/#5013, #5796, #5262. i18n-keys' "a plugin's words are
  its own" is red on main too (#5332).
- Whole GUI suite on WSL at an older head: 400 of 22778 red across
  ~100 files of other pages, in line with #5559 (478 of 21666 on main
  there). Not rerun on mote.

Real use, on mote in a sandbox HOME with Claude.app 4.23118 linked in:
`claude-desktop magpie`, then `launcher add`, moved the wiring to
Claude-Magpie-3p (deploymentMode 3p, mcpServers and locale carried).
Opening Claude Magpie.app started Claude with
--user-data-dir=.../Claude-Magpie-3p; it wrote configLibrary and
model-catalog there (3P mode) and no -3p-3p folder. A second, 1P Claude
ran beside it on its own sandbox folder. Opening the launcher again
kept one instance; the pkill pattern matched only the isolated pid; both
quit on SIGTERM. `launcher remove` put the wiring back and removed the
app.

Broken by hand: a folder without -3p (Desktop made -3p-3p), the
CLAUDE_USER_DATA_DIR env route (ignored by the packaged app), os/exec in
the quit (TestNoCommandBypassesProc red).

Not tried: a screenshot of the running app (screencapture fails over
ssh); a model request through a gateway from the isolated app; Windows
and Linux (not offered there). Known: the Dock shows Claude's own icon
for the running isolated app, and Chrome pairing is off in a moved
userData folder.
2026-11-09 22:31:16 +08:00
yetone dae104bfac capre: a length check, not an unrolled repeat, holds nine patterns
Go's regexp unrolls a bounded repeat into that many copies of its
class: [A-Za-z0-9.-]{0,254} (the session terminal's bundle id) was
89kB of program, kept from start to exit, and Codex's item-id refusal
`.{0,1000}?` 88kB. Measured one by one over magpie's 540 package-level
patterns (1.5MB in all), the nine largest bounded ones were ~440kB.

capre.MustCompile(expr, max) is the pattern with * or +, matching only
a string of max characters at most (rune count, so the (?i) Kelvin
sign and invalid bytes count as the regexp counted them). The nine:
settings' bundle id, library's name and agent id (now name@wsl:distro
cut in two), Anthropic tool names, the trace page's name and find,
access's MCP server, OpenClaw's profile and Codex's provider id. The
item-id refusal is a function: the tail within 1000 characters of a
head.

Run on mote (go1.26.8):
- go test ./internal/capre ./internal/access ./internal/settings
  ./internal/library ./internal/sessions ./internal/agent ./internal/gui
  . : ok; ./internal/gateway -run 'ItemID|Undeclared|ToolName|Refus': ok
- TestCappedMatchesBounded holds each old pattern against its new one
  over 14 units x 19 lengths (0..300, at each bound +-1); with the
  length check taken out it is red (1586 mismatches).
  TestItemIDRefusalAsTheRegexp holds the function against the old
  regexp at 998..1002 characters of x, é, 日, \xff, \n; with 1001 it is
  red. TestCappedIsSmall: 1304 bytes held, 49680 bounded.
- go vet native, GOOS=linux and GOOS=windows over the touched packages
  (gui natively: its Linux build needs cgo); gofmt -l clean.
- Real build, GODEBUG=inittrace=1: magpie's own inits allocate
  11.93MB -> 10.61MB.
- Idle on the real-account copy, 180s heap: regexp programs (sampled)
  4.54MB -> 3.01MB.

Not tried: the full ./... suite; the gateway package beyond the run
above.
2026-11-09 21:47:24 +08:00
yetone c7ebb6f8d9 settings: Video generation picks the model Magpie Image makes videos with
The same Discord (#feedback) user: a custom provider's video model still
couldn't be chosen. A custom provider's video model was already found
(seedance, kling, veo, wan, hailuo ids by name, or marked by hand with
right-click › Makes › Video model, #1399), but generate_video always used
AutoVideomaker's pick, the first video model of the first provider, with
nowhere to choose another, as Settings › Images does for images.

settings.VideoGen (provider/model or a routing group) is now the model a
request that names none makes its video with, while it resolves; else
AutoVideomaker's, as before. Image generation turned off turns video off
with it, as before. Settings › Models › Images gets a Video generation
row under Image generation: Automatic (naming the automatic pick) and
every model Magpie Image can make videos with. A pick that no longer
makes videos (provider gone or off, model unmarked) says so and the
automatic one is used in its place; the settings API refuses a model
that makes none, and keeps the pick when a save doesn't send it.

The row is drawn by videogen.js, imported when Settings draws Image
generation, with one call in app.js: drawn in app.js it put the core
scripts 616 bytes over TestCoreScriptBudget (1,534,418 > 1,533,802, found
by the first full run), and the budget is not raised.

Run on mote:
- At this change on bceeabd93 (rebased onto c630d9a29, which changes
  only the gateway key page): gofmt -l clean; GOOS=windows go vet and
  GOOS=linux go vet -tags nogui of the changed packages: ok. go test -run
  'Budget|VideoGen|Videomaker|TestSettingsSave|TestKeysAreWhatTheSaveWrites'
  in settings, settingsapi, gateway, gui: ok. GUI: video-gen-pick
  (32 subtests: chromium and webkit; en, zh, zh-TW, ja, de at 1100px, en
  and zh at 400px), old-webkit, i18n-en-no-cjk and the six image/Settings
  files (image-timeout-setting, images-codex-one, images-library-way,
  images-missing, image-models-hide, image-mcp): 220 of 220 ok.
- At 95a3fa3e0 (the change before the videogen.js move and the rebase):
  go test -timeout 45m ./internal/settings ./internal/settingsapi
  ./internal/gateway ./internal/gui: ok except TestCoreScriptBudget
  (fixed above). i18n-keys at 4394ea1b9: only the known plugin-words red
  (#5332).
- Not run at this head: the whole of those four packages and the 183 GUI
  files a Settings change reaches; the suite lock on mote was an hour
  deep in other sessions' suites.

Broken by hand, each red:
- videomaker ignoring VideoGen: TestVideoGenPicksAMarkedModel.
- settingsapi not keeping a pick a save doesn't send:
  TestVideoGenCheckedAndKept.
- No Video generation row: video-gen-pick.test.cjs, 30 of 32.
- videoGen left out of the Settings page's prefsKeep:
  TestSettingsSaveKeepsWhatItDoesNotSend ("VideoGen: not sent by the
  Settings page"), found before it was added.

Not tried: a real video generation with a custom provider's model (the
gateway tests hold the vendor's replies).
2026-11-09 14:25:55 +08:00
yetone 7a6211d047 providers: a model's own headers, in Model settings
axelburks on Discord: a vendor routes one model by a header of its own.
A key's provider (built-in or custom) can give each model headers
(settings.ModelHeaders["pid/model"]). They go on that provider's
requests for that model alone, after the provider's headers and after
auth: a name both have is sent once, as the model's, so a user's value
is never overridden by the provider's or magpie's key header. The
gateway names the model (provider.WithModel) on every route that asks
one: chat on each API, translated and streamed, count_tokens, System
One's decision, embeddings, images, videos and the model test. A
fallback provider serving the same model id gets its own headers only.
Accounts and plugins carry their sign-in's headers and take none.

The editor's "Name, price and reasoning level" panel is now "Model
settings" (every language), with + Add header per model, staged and
made with the Save; Restore default takes them away.
The rows being typed are kept out of the draft's
compare, so an untouched editor still closes without asking.

Broken by hand: dropping WithModel from gateway.go turns
TestModelHeadersReachTheirModelOnEveryRoute red; dropping the provider
id check in modelOf turns TestModelHeadersStayWithTheirProvider red.

Run, on this stack over origin/main 0fc3455e2 (mote's suite lock had
hours of queue, so the suites ran on WSL magpie-desktop under flock):
- go test -timeout 45m ./internal/{provider,gateway,gui,cli,settings,fx}
  on WSL, ok; ./internal/codexcat on mote, ok; gofmt -l clean;
  go vet on mac, GOOS=linux -tags nogui and GOOS=windows on mote, ok;
  TestCoreScriptBudget ok (paid by cutting comments, no raise).
- GUI, both engines, every language, on WSL at the pushed head and at
  0fc3455e2: every touched test file plus the provider-editor files a
  first run found red. No red at head that isn't red at 0fc3455e2. The
  shared reds have issues: i18n-keys #5332, model-chip-steady #4388,
  model-copy-id #4621, models-works-only #4391, plugin-move-unserved
  #4392, provider-fetch-again #5232, provider-levels-save #4394,
  provider-levels-scroll #4395, provider-models-rest #4396,
  provider-picks-stay #4397, provider-typed #4673, remote-magpie #4398,
  zero-priced-free #5262, model-reasonless (webkit de) #4100,
  name-suffix-no-names #1937.
- Rebased on origin/main 4ab1191bc (gateway.go moved under it) and run
  again at the pushed head: gateway and provider ok on WSL, gofmt,
  vet (mac, linux nogui, windows) and the budget ok, i18n-keys,
  model-headers and routing-groups-back with only #5332's red.
Not run at push: the whole GUI suite (1277 files).

Not tried: a real vendor that routes by header (Ark); fake vendors only.

Reported-by: axelburks (Discord)
2026-11-08 11:28:54 +08:00
yetone 6b7ee4a984 routing: every group follows a default for rate limits, slow starts and busy members unless it sets its own
jiezhengj on Discord asked to set the per-group policies once instead of
in each group. The Routing groups page's Settings card, under the list,
now has three rows: Rate limited (keeps its place / goes to the back),
Slow to start (wait / 30 s ... 4 min) and Every member busy (off / 1 min
... 4 min). They are saved in settings.json as groupSink, groupFirstToken
and groupPatience (settings.SetGroupDefaults, POST /api/groups/defaults).

A group follows the default for each value it leaves unset, and its own
value always wins:
- Sinks() is the group's Sink, or else the default unless NoSink, a new
  field for an explicit "Keeps its place".
- FirstTokenOr() is the group's own FirstToken (-1, FirstTokenWait, is an
  explicit Wait), or else the default. The gateway reads it where it
  reads a group's first-token time.
- Waits() reads the default when Patience is 0. 60 is an explicit 1 min.
Groups saved before have 0 and no NoSink, so they follow the default,
which starts at magpie's own (keep its place, wait, 60s). Nothing a user
set changes. The group editor's three rows gain a Default option, on for
a group that sets none, and its hint names the value it follows. Segments
only, with no native select.

Run on mote, at 06b2daeff rebased on origin/main 2dac9b84e:
- go test on the new tests TestGroupDefaultsUnlessItsOwn,
  TestGroupFirstTokenFollowsTheDefault, TestGroupSinkFollowsTheDefault
  and TestGroupDefaultsSaved, plus TestKeysAreWhatTheSaveWrites and the
  existing first-token and sink tests: ok.
- Broken by hand (Waits, FirstTokenOr and Sinks ignoring settings): the
  three provider/gateway tests went red.
- GUI: group-defaults (new), group-patience, group-first-token,
  group-found-off and rate-limited-sink, in Chromium and WebKit, in en,
  zh, zh-TW, ja and de, at 1100 and 420: 56/56 pass. With the old
  client.js and routing.css, group-defaults, group-patience and
  group-first-token fail 44 of 44.
- GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...:
  clean. gofmt -l: clean.

Still running when this was pushed (owner: never hold a verified commit
behind the suite): go test -timeout 45m on internal/provider,
internal/gateway, internal/gui, internal/settings and
internal/settingsapi, then the whole GUI suite under suite.lock. Any red
they show gets its own issue.

Not tried: the real app with real groups under real rate limits. Only
the gateway tests' fakes exercise the default sink and first-token paths.

Reported-by: jiezhengj on Discord
2026-11-08 02:08:30 +08:00
yetone da548b4548 codex: a reset about to expire can be used from 3 minutes before, or after any minutes typed (Custom…)
shangyuan0818 asked again, and the coordinator agreed: magpie runs the
whole time, a reset's expiry is known to the second, and a user who is
worried can pick a long lead. So the menu ends with Custom…, and the
floor is now what the gateway needs, not 15 or 5 minutes.

- settings: CodexResetLeadLeast 5 -> 3; the presets start at 3. The CLI
  (magpie quota reset-lead) and settings/codex-reset-lead check the same
  constant. Saved values stay valid: everything from 5 to 1440 still is.
- Why 3: since v0.1.3204 the loop wakes at the lead's start (timer, at
  most 1s late), a try is bounded by the pass's 2 minutes, and a failure
  in the last 15 minutes is tried again a minute after it began, at once
  when that has passed. At 3 minutes a try hung to its bound ends at
  T-0:57 and a retry starts at T-0:56. At 2 minutes a hung try leaves no
  retry before expiry.
- GUI (autoresetown.js): Custom…, the menu's last item, puts a field of
  minutes where the button was, at the button's size, so the row doesn't
  rewrap. Enter or leaving it saves. Escape keeps the lead. A number
  outside 3 to 1440 is shown as an error and not written. A redraw
  leaves the field alone while it is open. It uses the app menu and no
  native select. There is one new string, in all five languages.

Tests:
- TestShortLeadSpentInTime: at the least lead, for four phases, the
  reset is spent at T-3:00, and after a 2-minute hung try plus a 30s
  retry it is spent before expiry.
- TestQuotaResetLeadCmd: 3m is taken and 2m is refused.
- codex-reset-lead.test.cjs: 12 items, picking 3 min, and Custom… in
  every language at 1100 and 420. Typing 7 and pressing Enter posts 7.
  Typing 2 is said and not posted. Escape posts nothing, and leaving the
  field posts 12. Opening the field moves no page.

Run on mote at this tree:
- go test of the reset-lead, short-lead, reset-loop, expiring and
  quota-reset tests in provider, cli and settings: ok.
- go vet: darwin, linux -tags nogui and windows on provider, settings
  and cli, plus darwin on gui: ok.
- go test ./internal/gui: TestCoreScriptBudget ok with no raise (the
  field lives in the lazy autoresetown.js). TestMainWindowCorners is red,
  as in #3949.
- GUI codex-reset-lead, codex-auto-reset-settings and i18n-keys in
  Chromium and WebKit: 49/50. The red is i18n-keys "a plugin's words are
  its own", filed as #5327, #5332, #5426 and #5482. Before the last
  comment trims, codex-reset-lead, codex-auto-reset-settings and
  providers-reset-use passed 86/86.

Broken by hand, each red:
- Floor at 2: the least-lead hung case goes red (one try, no retry), and
  so does the CLI (2m taken).
- Floor at 5: the CLI refuses 3m.
- The GUI range check removed: "2 isn't posted".
- Escape saving: "Escape posts nothing".
- The field at its own size (76x27) instead of the button's: WebKit ja
  and de at 1100 move the page 1px.

Not tried: a real ChatGPT reset spent at 3 minutes, since none of my
accounts has a reset about to expire. The redraw guard has no test of
its own, because a click elsewhere blurs the field and saves first.

Reported-by: shangyuan0818 (Discord)
2026-11-07 06:39:39 +08:00
yetone d4a221f79c codex: a reset about to expire can be used 5 or 10 minutes before it does
shangyuan0818 on Discord asked for leads under 15 minutes (1, 3, 5, 10, or
free seconds) for Codex's auto-use of the reset about to expire, to use
more of the windows first. The shortest was 15m because the gateway only
looked every 5 minutes after a pass ended (a pass is bounded at 2
minutes), so the gap between looks could reach ~7 minutes. With a 5-minute
lead, the reset could run out before any look landed inside it.

- provider: a look lands on the lead's start (nextResetLook takes the
  sooner of +5m and until-lead), and the loop sleeps until the soonest look
  due among the accounts its pass went over (expiringResets.wake: 5m at
  most, 1s at least; an account the pass skipped wakes nothing). A read or
  spend that fails inside the lead in the last 15 minutes is tried again
  in 1 minute (retryResetLook), not 5; a long lead failing earlier keeps
  the 5-minute cadence. A retry that came due while a hung pass ran is
  made at once.
- settings: CodexResetLeadLeast 15 -> 5; choices 5m, 10m, 15m, 30m (default),
  1h ... 24h. Saved values from 15 to 1440 stay valid; the default is
  unchanged.
- GUI (app.js RESET_LEADS, resetLeadMinutes) and CLI (magpie quota
  auto-reset lead) follow the same range. No new strings ("{n} min"
  already exists). Still the app menu, no seconds field.

Why 5 and not 3 or 1: in the worst case a try hangs to the pass's 2-minute
bound. At 5m: try at T-5:00, hung until T-2:57, retried at T-2:56, so two
tries before expiry (four when ChatGPT refuses at once). At 3m a hung try
leaves no retry. At 1m one try cannot even run to its own bound, and
local-vs-server clock skew eats the rest.

Run (mote, via mote-run, at base 49f207c78):
- go test -run 'Reset|Expir|Lead' ./internal/provider ./internal/settings
  ./internal/cli: ok. New: TestShortLeadSpentInTime (5m lead at four loop
  phases: spent at T-5 within 5s; a 2-minute hung try then a retry before
  T-1m; four quick failures, all before expiry; a 7m CLI lead lands on
  T-7; a 6h lead failing all along makes 70 to 90 tries, not ~360),
  TestResetLoopWakesForTheSoonestLook.
- go vet: darwin (provider, settings, cli, gui), GOOS=linux -tags nogui,
  GOOS=windows. go test ./internal/settings ./internal/settingsapi: ok.
  ./internal/gui: ok but TestMainWindowCorners/macOS_26_SDK (#3949) and
  TestPanelHiddenByWailsMarksPageOutOfSight (#5322), AppKit window tests
  red on mote's macOS 27, both filed; the size budgets pass.
- GUI: codex-reset-lead.test.cjs (now also picks 5 min and checks the
  10-item menu), codex-auto-reset-settings, i18n-keys; Chromium and
  WebKit, en/zh/zh-TW/ja/de, 1100 and 420 px: 49/50. The one red is
  i18n-keys "a plugin's words are its own", red on main and filed
  (#5327, #5332, #5426, #5482); nothing here touches those files.

Broken by hand, each went red:
- the look not landing on the lead's start: TestShortLeadSpentInTime's
  7m case (spent 4m59s before).
- wake fixed at 5m: TestShortLeadSpentInTime, TestResetLoopWakes...
- the 1-minute retry turned into nextResetLook: the hung-try case.
- CodexResetLeadLeast back at 15: TestShortLeadSpentInTime,
  TestQuotaResetLeadCmd.

Not tried: a real Codex account spending a card at a 5m lead; a Mac
asleep across the lead (no lead can help there, same as before); the
3-minute delay after start is unchanged, so a magpie started within the
lead spends at its first pass; Windows and Linux runs (vet only).

Reported-by: shangyuan0818 (Discord)
2026-11-07 06:07:03 +08:00
yetoneandmdwsk88 4e0e8e7933 gateway, settings, gui, cli: the results a search is answered with can be set, 1 to 20 (#5545)
Claude Code's WebSearch and Codex's web_search never name a count, so
magpie answered every such search with searchHits, 6 pages (#5545,
mdwsk88: more pages for research-heavy work, fewer to save context).

settings.SearchCount holds the count. 0 means the default, 6
(SearchCountDefault), and the most is 20 (SearchCountMost), the most
Brave and Tavily return. Save refuses a value out of range, so nothing
is written. Settings.SearchPages reads it. The gateway's searchCount
falls back to it when a search names no count. The web_search MCP tool
still answers a named count with that count, and its schema's default
says the count set. It reaches every search API (Brave, Tavily, Exa,
You, the plugins' searchers), as a named count already did.

- Settings › Models › Web search: "Results per search", segments 3, 6,
  10, 15 and 20, plus a count set by hand in settings.json.
  POST /api/settings/search-count sets it alone. settingsapi.Apply
  keeps it as it keeps search-all, so a save of the Settings form
  doesn't put it back.
- CLI: magpie search count says the count; magpie search count <n>
  sets it; magpie search count default puts 6 back. A bad value is
  refused and nothing is written.
- docs/subsystems/gateway-routing.md says it.
- New strings are in zh, zh-TW, ja and de.

Run at this tree (mote-run, macOS):
- go test -count=1: internal/settings, settingsapi, cli, gateway
  (TestSearchMCPCount, TestSearchCountReachesEveryAPI,
  TestSearchCountSetting), and gui (TestSettingsSearchCountSetOnItsOwn, and
  TestSettingsSaveKeepsWhatItDoesNotSend with SearchCount set): ok.
  internal/gateway whole: ok with -timeout 45m (847s). internal/gui
  whole: ok but TestMainWindowCorners/macOS_26_SDK (#3949, mote is on
  macOS 27).
  The first cli run was red on TestEveryRouteHasACommandOrIsNamed:
  the new route had no CLI entry. cliForRoute maps it to search count
  now.
- Broken by hand: searchCount returning searchHits again makes
  TestSearchCountSetting fail ("set 11: a search naming no count asks
  for 6, want 11"). Restored, it passes.
- GUI: node --test --test-concurrency=4 over routing-*, usage-*,
  ledger-*, panel-*, call-*, search-*, searcher-*, settings-*, i18n-*
  and gui-* (Chromium and WebKit; the files cover en, zh, zh-TW, ja
  and de), with #2398 and #5545 in one tree: 4961 of 5016 ok. The 55
  reds are in 12 files. i18n-keys' "a plugin's words are its own"
  names other files' strings (#5327, #5426, #5482). The other 11 files
  were run alone at dc49feca9 (this tree without either change) and at
  this tree: 52 and 51 reds, the same tests. The one apart is
  usage-focus-steady, which flakes (#3501). Each is filed: #5392,
  #3414, #5048, #3799, #3415, #3954, #4627, #4628, #5223, #1529.
  routing-canceled-row.test.cjs: 10 of 10. With the .rt-req.gone rule
  taken out, its dot is the answered green rgb(24, 154, 88) and it
  fails. Restored, it passes.
- Not tried: a real Claude Code WebSearch through this tree with a live
  search API key. The tests use fake search APIs.

Co-authored-by: mdwsk88 <11055210+mdwsk88@users.noreply.github.com>
Reported-by: mdwsk88 (dawei on Discord)
2026-11-07 04:03:01 +08:00
yetoneandmdwsk88 6ac1e04244 provider: a Claude model on Copilot has its 1-hour cache write priced as Copilot bills it, at the 5-minute write (#3435)
Copilot bills a cache write at one price however long it is kept. Its
copilot_usage counts a 1-hour write as the cache_write a 5-minute one
is, and GitHub's "Models and pricing for GitHub Copilot"
(docs.github.com/en/copilot/reference/copilot-billing/models-and-pricing)
lists one "Cache write" price per Claude model, no 1-hour tier (Opus
5.5: input $4, cached input $0.20, cache write $5, output $20). magpie
gave every Claude model's list price Anthropic's 1-hour write, 2x input
(catalog.OneHourFor), so copilot/claude-opus-5.5 was priced at $8 per
million for an hour's write where Copilot bills $5: on the reporter's
request, $0.125456 against Copilot's own $0.078443.

A Copilot price (tariffOf, cacheWritesAlike) now has no 1-hour write of
its own, so an hour's write is billed as a 5-minute one
(catalog.Price.OneHour), its tiers alike, copied as they may be the
catalog's. This holds for a call read after Copilot was signed out too
(tariffOf's unknown-provider path, MakerPrice), which the reporter's
patch left at 2x. A price the user gave for a Copilot model keeps the
1-hour write they gave, and one they left out isn't filled with 2x input
(userPrice, so UserBasePriceIn reads it alike). Every other provider is
as before: Anthropic, Bedrock, Vertex and relays bill the hour at 2x, so
the rule is scoped to Copilot's id, not taken off every non-Anthropic
provider. Usage rows are priced as they are read (Record.CostAt), so
calls already recorded read at the new price too. docs/reference.md and
ModelPrice's comment say so.

Run on mote (go1.26.8, macOS) at 400b66ec3 plus this commit and the
next:
- go test -tags nogui ./internal/provider ./internal/tune
  ./internal/catalog: ok.
- TestCopilotOneHourCacheWriteAtItsWritePrice is red with models.go at
  400b66ec3 ("copilot/claude-opus-5.5 = {... CacheWrite1h:8 ...}").
  With the unknown-provider strip taken out by hand, its two new checks
  are red ("signed-out copilot/claude-opus-5.5 = {... CacheWrite1h:8
  ...}" and "BasePriceIn(copilot, claude-opus-5.5) with no Copilot ...").
Not tried: a live Copilot request; the figures are Copilot's own
copilot_usage for the reporter's request. A plugin that serves Copilot
(OpenCode's github-copilot auth) is priced as before; how it is billed
wasn't checked.

Reported-by: mdwsk88 (dawei on Discord)
Co-authored-by: mdwsk88 <11055210+mdwsk88@users.noreply.github.com>
2026-11-07 04:03:00 +08:00
yetone ead0bf0059 agents, sessions: open in a terminal on Windows and Linux too, and copy any CLI agent's launch line
lileo0668 on Discord: clicking an agent should start it in a terminal,
and a history session should resume there. Opening a terminal was the
Mac app's only (Open in terminal on an Agents row, and Sessions' Open in
the selected terminal and Continue with another agent), and Copy launch
command was only for agy, Cursor (local) and Claude Science.

- terminal_open.go: openTerminal off a Mac.
  - Windows: Windows PowerShell (the system default), PowerShell 7 and
    Windows Terminal. The line, PowerShell's as Sessions already copies
    it, goes as -EncodedCommand: no script file, so no execution policy,
    no file encoding and no quoting in between. A shell gets its own
    console through cmd's start (magpie's children are CREATE_NO_WINDOW);
    wt is started directly, on pwsh or else powershell.
  - Linux: $TERMINAL, then xdg-terminal-exec, then x-terminal-emulator,
    then the first of GNOME Terminal, Konsole, Xfce Terminal, kitty,
    Alacritty, Ghostty, foot, WezTerm, Terminator and XTerm, each with its
    own words before the command. The line runs from a script of its own
    in sh, then the user's shell, as the Mac's .command file does.
  - A terminal that quits failing within a second says so, with what it
    printed ("cannot open display").
- Settings' Session terminal row lists the terminals found on Windows and
  Linux too; no row when none is found.
- Every agent row with a program now carries `command`, the line the
  server builds (Launch, or the program quoted for this system's shell;
  an agent in a WSL distro is started through wsl.exe on Windows). The
  row menu (right-click or the grip) has Copy launch command after Open in
  terminal, on the web build and in the panel too.

Run:
- mote (macOS 27, go1.26.8): go vet of internal/gui and internal/settings
  for darwin, for linux with -tags nogui, and for windows; GOOS=windows
  and GOOS=linux (nogui) builds of the binary; go test ./internal/gui
  ./internal/settings ./internal/agent. Everything passes except
  TestMainWindowCorners/macOS_26_SDK, which is #3949.
- Windows (win-run, xiaomi-gpu): go test ./internal/gui ./internal/settings.
  The new tests pass, among them TestAgentLineWindows, where real
  PowerShell runs the encoded line on a claude.cmd in a folder named
  `it's a $(New-Item made1) & New-Item made2 #` and runs nothing else.
  The six reds are filed: TestLodyImportHandoff,
  TestImportStatusUnreadableIsUnknown and TestAionUiImportRow (#4115),
  TestUpdateThatWontStart (#1827), and TestPluginAgentMissingSaysSo and
  TestGatewayHeldByAContainer (#5324).
- Linux (wsl-run, magpie-desktop): go test -tags nogui -timeout 45m
  ./internal/gui ./internal/settings: both ok (internal/gui 630s; at
  the default 10m it timed out with nothing hung)
- Real use. A throwaway test called openTerminal, not committed.
  - On xiaomi-gpu's console desktop (schtasks /IT): system default and
    wt each opened a window and ran a line with ' and 中文. pwsh isn't
    installed there and was refused by name.
  - On magpie-desktop under Xvfb: the system default
    (x-terminal-emulator, the xfce4-terminal wrapper) and xfce4-terminal
    each ran it (TERM=xterm-256color, set by the terminal). xterm isn't
    installed there and was refused. Without a display, xfce4-terminal's
    "cannot open display" came back as the error.
- GUI (mote, Playwright Chromium and WebKit): agent-open-terminal (five
  languages, 980px and 420px; Copy sends the server's line to /api/copy
  unchanged), session-terminal (Win32 and Linux platforms at 420px, and
  no row when nothing is found), settings-general, and the agent-*,
  sessions-*, session-*, gui-de, gui-ja and gui-zh-tw files with
  fold-show-grip, grip-inset, tap-click, menu-input-scroll and
  click-scroll (102 files): 1689 pass, 5 fail. The fails:
  menu-input-scroll, 4 of 4 red alone on origin/main 152c3852f too
  (#3402), and i18n-keys' "a plugin's words are its own" is
  red on origin/main too (#5332, #5327, #5426, #5482).
- gofmt -l is clean. TestCoreScriptBudget passes; no budget was raised.

Broken by hand:
- PowerShell quoting turned into POSIX quoting: TestAgentLineWindows red.
- cmd's start dropped: TestWinTerminalArgv red.
- A terminal's failure ignored: TestOpenLinuxTerminalRuns red.
- app.js and settings.js put back as they were: 32 GUI tests red
  (agent-open-terminal, session-terminal).

Not tried:
- A real GNOME, KDE, kitty, Alacritty, Ghostty, foot or WezTerm. Their
  words come from their docs.
- Omarchy's xdg-terminal-exec.
- PowerShell 7 on a real desktop (not installed on the box).
- The packaged GUI app on Windows or Linux; the real runs called
  openTerminal from a test binary.

Refs #4474.

Reported-by: lileo0668 (Discord)
2026-11-06 16:02:04 +08:00
yetoneandggbdpq bd18b7e280 gateway: Settings' Longest wait an agent is told bounds every Retry-After it hears (#5371)
tlerbao (#5371): an Antigravity quota ran out, magpie rested the account
until the plan's reset hours away, and that horizon went to OpenCode as
Retry-After. OpenCode clamps one wait at 900s and asks the same model a
few times, so it sat ~45 minutes before its own fallback chain moved on.

RetryAfterCap (seconds, unset by default) bounds the Retry-After an
agent is told. Accounts rest exactly as long either way: restAfter and
the held try read the header before it leaves.

Changed from ggbdpq's patch:
- The cap is one wrapper in Server.Handler (retryCapped), on every
  answer of 400 and up, not capAfter at four call sites. The patch
  missed the vendor's own Retry-After passed on by keepRetry (19821s and
  an HTTP date went out uncapped) and any other site that writes one.
  The wrapper has Flush and Unwrap, so ResponseController and the
  websocket's Hijack still reach the connection.
- settings.Shared() per answer, not settings.Load() from disk.
- The setting is reachable: settingsapi Keys and Merge (kept when not
  sent), a Settings › Models › Replies row (1/5/15 min, No limit) with
  zh, zh-TW, ja and de text, and prefsKeep. The patch failed
  TestKeysAreWhatTheSaveWrites ("only saved: [retryAfterCap]").
- Stays opt-in: a default cap makes a backing-off client ask again
  sooner, and each ask can spend a confirm probe on an exhausted account.
- Core script budget not raised; three app.js comments were shortened.

Run on mote at this head (rebased on 1493acb46):
- go test -tags nogui ./internal/gateway -run 'TestRetryAfter|
  TestQuotaRestsUntilTheTimeOfDaySet|TestAllRestingAnswersFromRest': ok
  (GoesOutWholeByDefault, CapBoundsTheAgentWait, CapLeavesTheRestWhole,
  CapBoundsTheVendorsOwn, ALimitIsAsked, Rests).
- settingsapi/cli TestKeysAreWhatTheSaveWrites,
  TestSettingsCLISetsWhatTheWindowSaves, TestBodySetsOneKeyOnly: ok.
- internal/gui Budget|I18n: ok.
- GUI, chromium + webkit: retry-after-cap-setting (new, 5 languages,
  1100 and 420), refusal-retries-setting, settings-hints, i18n-keys,
  i18n-en-no-cjk, reply-model-setting: 91 of 92. The one red is
  i18n-keys "a plugin's words are its own", already filed as #5332 and
  #5426 (strings outside this change).
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on
  gateway, settings, settingsapi: clean.

Broken by hand: with retryCapped taken out of Handler,
CapBoundsTheAgentWait fails (Retry-After "19252", want at most 60s) and
CapBoundsTheVendorsOwn fails (Retry-After "19821", want "60", and the
HTTP-date case). With the patch's own code, CapBoundsTheVendorsOwn fails
the same way.

Not tried: a real Antigravity account running out with a real OpenCode
fallback chain; the full suite.

Rebased onto 766d2a9f5's descendants: TestCoreScriptBudget was 1 byte
over (1533803 > 1533802) after ce2a59daa's app.js change; the new
row's comment lost a word. At the pushed head on mote:
TestCoreScriptBudget ok, -run RetryAfter ./internal/gateway ok.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 10:08:35 +08:00
yetone d00e41604c settings: the image model error's example is gpt-image-2, not the shut-down gpt-image-1
OpenAI shut gpt-image-1 down on 2026-10-23. Run: go test ./internal/settings on mote: ok.
2026-11-05 19:57:29 +08:00
yetone 93d5c76c0d router: an agent with many tools is given them on demand
ArvinCharl on X: the MCP router's tools fill the context. An agent that
doesn't search its MCP tools itself (all but Claude Code, Claude
Desktop, Codex and Pi) sends every tool's whole schema on every
request. Given more than 10 router tools, such an agent now lists two in
their place: find_tools (matches by name and description, the first 5
with their inputSchema, 15 more by name) and call_tool (runs one by
<server>__<tool>, its bare name, or arguments sent as a string; an
unknown name is told the close ones). The instructions still name every
server and its tools, and a tool called by its own name still runs. The
request log names the tool call_tool ran. The address for any other app
lists every tool, since which app connects isn't known.

Library → MCP gains a "Tools on demand" toggle (settings
routerAllTools, kept by KeepOwn and the settings API); turned off,
every agent gets every tool whole as before.

Run on mote (after the rebase onto 083821dc9: gateway vet, -run
'Hub|MCP|Settings|Search' and the four GUI files again, ok, 70 of 70):
- gofmt -l: empty. go vet, GOOS=linux go vet -tags nogui, GOOS=windows
  go vet of gateway, settings, settingsapi, gui, library: ok.
- go test -tags nogui -count=1 -timeout 45m ./internal/settings
  ./internal/settingsapi ./internal/gui ./internal/library: ok;
  ./internal/gateway -run 'Hub|MCP|Settings': ok.
- GUI (Chromium + WebKit, every language): library-mcp-router-tools,
  library-mcp-router-note, library-mcp-hub, i18n-keys: 70 of 70.
Broken by hand: hubOnDemand forced false turns TestHubMCPToolsOnDemand
red.
Not tried: a real OpenCode or Gemini CLI session against the router;
the full gateway package and full GUI suite.
2026-11-04 21:00:51 +08:00
yetone 3eb2bda4f2 settings: Codex, Claude Code and Grok Build each take a Long conversations of their own (molianyin4227 on Discord)
molianyin4227 (Discord #help): models differ, so one compaction size
for every agent fits none; they asked for Codex, Claude Code and Grok
Build to each have their own, falling back to the shared one.

- settings.AgentCompacts[agent] {At, Full} for the agents that write a
  compaction window (CompactAgents: codex, claude, grok); Settings.
  ForAgent(agent) lays it over CompactAt/FullContext for that agent's
  readers only: codexcat.entriesAt, provider codexListed, Claude Code's
  writeCompact and desktopPlan, grokModelTables, the route list's
  buildModels, Codex's window line (api.go) and Tuned for you
  (gui/tune.go, agent/tune.go). A model's or provider's own Compact at
  still comes first. An agent with none follows the shared value, so
  nothing new is written for it, and an agent outside the three has no
  such key and is refused (provider.SetAgentCompact).
- POST /api/settings/agent-compact {agent, own, full, at}; own false
  takes the agent's value away. settingsapi.Merge keeps the map.
- GUI: a row "Long conversations in <agent>" under Long conversations,
  in the agent's opened row and its sheet: Every agent / Compact at N /
  Full window (segs, no select), a size box when Compact at. It lives in
  agentcompact.js, imported when the agent's settings hold Long
  conversations, then put in synchronously (an async put-in after a
  redraw moved the page in chromium: codex-memories-settings' scroll
  check). It draws again only when its own values change. i18n in
  zh, zh-TW, ja, de.
- Tuned for you's Use on an agent with its own value changes that one,
  stashed under tune.long.compact.<agent>; Undo puts it back.
- codex-memories-settings' "no Codex" check counts Long conversations
  alone again (:not(.agent-compact)) and waits for the new row.
- docs/subsystems/agent-wiring.md: a row for it.

Core size: app.js 1,311,919 bytes, 109 under origin/main 0ee424e3e
(1,312,028): the two calls are paid for by four comments cut. The core
total is 1,534,045, still over its budget as on main (#5139), 109 less
than main's 1,534,154. No budget raised.

Run at this tree (based on origin/main 0ee424e3e, fetched just before
the commit), all on mote via mote-run:
- go test settings, settingsapi, codexcat; provider/agent/gui with
  -run "Compact|Tune|Grok|SettingsSave|CodexWindow|Long": ok.
- New tests broken by hand, each red: ForAgent taken out of codexcat
  (TestCodexCatalogCompactAt), grok.go (TestGrokWindowFollowsLong
  Conversations), claude.go (TestClaudeCompactAt); tune's per-agent key
  turned off (TestTuneAgentOwnLong: "after apply: codex {At:0
  Full:true}"); the row's import call taken out of app.js
  (agent-compact.test.cjs 4 of 4 red in chromium).
- GUI, chromium + webkit (en/zh/zh-TW/ja/de as each file has, narrow
  and wide): agent-compact, agent-prefs, compact-at, compact-one-value,
  settings-general, codex-async-compact, codex-compact-held,
  codex-memories-settings, context-tune, segs-glide, i18n-keys,
  old-webkit: 432 of 432 ok.
- gofmt -l clean; go vet darwin and GOOS=windows on mote, linux with
  -tags gtk3 on magpie-desktop (wsl-run): ok.
- TestCoreScriptBudget: red, 1,534,045 > 1,533,802, as on main (#5139),
  109 bytes lower than main.

Not tried: real Codex, Claude Code or Grok Build reading the values
(the config writers are unit-tested); the full go test ./... (after
the push). `magpie model compact` has no per-agent flag, and t3code's
route list reads the shared value.
2026-11-04 16:17:47 +08:00
yetone 1e1068c86c codex: "Same as the lead" holds every subagent to the lead's model (cleverpigo on X)
cleverpigo (Windows, Codex App 26.1027.6604.0) had Codex's lead on
WorkBuddy's DeepSeek-V4.1-Flash, the subagent model on what the GUI called
"Same as the lead", and the Routing page still showed a subagent on
gpt-5.6-sol through Codex's own sign-in.

Cause: that setting, unset, never held a subagent to anything. Since
67c8f562c (mengxiao) a subagent keeps the model its lead names in
spawn_agent (codexFollowTo leaves subagents alone; codexSubagentPick
returns nil with nothing set), and Codex lists its own models first under
spawn_agent's model overrides, so the DeepSeek lead named gpt-5.6-sol.
Codex's side calls use luna, terra or codex-auto-review, not sol, so it
was the subagent, not a side call.

Now:
- "lead" (settings.CodexSubagentLead / provider.CodexSubagentLead) is a
  value of CodexSubagentModel: every Codex subagent goes on the model the
  lead's own turns last went on (codexLeads.lookup), whatever it names.
  The trace says so (SubagentPick.Lead) and Routing tells it as "the
  model its lead is on".
- A lead on one of Codex's own models is followed on the ChatGPT backend
  route only; in serve such a lead leaves the request as asked. With no
  lead turn seen, a subagent goes as asked.
- The GUI's picker offers "Lead's pick" (unset, mengxiao's case, as
  before) and "Same as the lead" (the new value); the texts say which one
  holds the subagents. en, zh, zh-TW, ja and de.
- No prompt text sent to a vendor changes.

Users who had it unset stay on Lead's pick; the label now says what it
does, and they pick Same as the lead to hold their subagents.

Docs: agent-wiring.md (subagent model field), gateway-routing.md
(CodexSubagentModel paragraph).

Ran, on mote through mote-run at this tree (base origin/main 50265256b):
- go test -tags nogui ./internal/gateway (whole package, -timeout 45m): ok
- go test -tags nogui ./internal/provider ./internal/settings
  ./internal/settingsapi: ok; -run Codex ./internal/agent ./internal/gui:
  ok; -run Budget ./internal/gui (TestCoreScriptBudget): ok
- go vet ./..., GOOS=windows go vet ./..., GOOS=linux go vet -tags nogui
  ./... (and -tags nogui darwin/windows): clean; gofmt -l: nothing
- node --test, both engines: codex-subagent-model (now picks Same as the
  lead and back, sheet row, Routing story of a lead-moved subagent, five
  languages), codex-subagents-lead, i18n-keys, routing-request-model,
  routing-sealed-task: pass. routing-story-shrinks is red in WebKit (4
  subtests, "held while under way"), the same alone at origin/main
  50265256b: #3954.

Broken by hand (in mote's copy only):
- lead lookup turned off in codexSubagentPick: both new tests red
  (TestCodexSubagentFollowsTheLeadWhenSet: "ChatGPT was asked for
  [gpt-5.6-sol]", the reporter's case).
- codexBackend's gate back to bare models only:
  TestCodexSubagentFollowsALeadOnCodexsOwnModel red.
- On the old code the tests don't build (no "lead" value), and
  SetCodexSubagentModel refused "lead".

Not tried: a real Codex App/CLI with a DeepSeek lead spawning a subagent,
and nothing on Windows (the change has no OS-specific path). The whole GUI
suite wasn't run: mote had two other sessions' full GUI suites going.
2026-11-03 23:12:33 +08:00
yetone 3c2dceb340 gateway: "member" in Model name in replies names the member to Claude Code and Codex too (ZoeCats)
ZoeCats (Discord #feedback, after v0.1.2760): with Settings › Models ›
Replies › Model name in replies on "vendor" the name is no longer written
over, but on "member" (作答的成员) a reply still didn't name the routing
group's member that answered.

Cause: replyNamingOf turned the "member" setting into the model asked for
whenever the agent was Claude Code, Claude Desktop or Codex (vendorNamed,
kept from #822's memberModel). ZoeCats's agent is Claude Code, so the
setting did nothing for them, while "vendor" was already for every agent.
The setting was saved and read as it should be (the vendor choice worked
through the same path), and an absent X-Magpie-Response-Model falls
through to the setting.

Fix: the user's pick is for every agent. Those three already take a
provider/model id back under the default (the group or provider/model
they asked for), so the member's provider/model id is no new shape for
them. vendorNamed, replyNamingOf's unused agent argument and the dead
namesMember are gone. The menu's note for "member" says "for every agent,
groups included" in en, zh, zh-TW, ja and de; settings.go's comment and
gateway-routing.md say the same.

Tests (fake upstreams, no network):
- TestReplyNamesMember: "on, codex", "on, claude code", "old file on,
  codex" now want the member, plus "on, claude desktop" and "on, codex,
  name asked" (the header still wins), on 6 paths x streamed or not, each
  after a failover in a group.
- TestPluginReplyNamesMember (new): a group served by the fake plugin,
  Chat and Messages, streamed and whole, with no token and Claude Code's,
  member and default.
- TestGeminiReplyNamesAskedModel: also with replyModel member and vendor.
- reply-model-setting.test.cjs: the member note says every agent and
  names no Claude Code.
Red on origin/main db7c57670 with only the tests changed: every
codex/claude code/claude desktop member case of TestReplyNamesMember
and the four Claude Code member cases of TestPluginReplyNamesMember
(the reply named group/chat, group/claude). Gemini and plugin member
cases without a vendorNamed token were already green.

Run on mote at this tree (on origin/main db7c57670, the pushed base):
- gofmt -l internal/ clean; GOOS=linux go vet -tags nogui and
  GOOS=windows go vet of ./internal/gateway ./internal/settings clean.
- go test -tags nogui -count=1 -timeout 45m ./internal/settings
  ./internal/settingsapi ./internal/gui ./internal/cli ./internal/gateway:
  settings, settingsapi, gui, cli ok; gateway ok except
  TestCodexPoolSaysTheClientsVersion, the open #4807 (another test's
  Codex identity; red in the full package, green alone), untouched here.
  TestReplyNamesMember, TestPluginReplyNamesMember and
  TestGeminiReplyNamesAskedModel pass.
- node --test reply-model-setting + i18n-keys (chromium + webkit, 5
  languages, 1100 and 420 wide): 26 pass, 0 fail.
Broken by hand: the tests alone on the old member.go (above) were red.

Not tried: a real Claude Code or Codex session reading the member's id
back (the default already gives them a provider/model or group id); a
real vendor account through a real group.
2026-11-03 07:15:52 +08:00
yetone 91379b9339 settings: a reply's model can be the vendor's own name again, the member, or the model asked for (ZoeCats)
ZoeCats (Discord #general): since v0.1.2473 a reply's model says the name
the client asked for (a group or provider/model id), groups that aren't
aggregates included, and the only way back to the vendor's own text was the
X-Magpie-Response-Model header, which their client can't send.

Settings › Models › Replies › Model name in replies (replyModel), picked
from the app's menu, in en, zh, zh-TW, ja and de:
- "" the model asked for (the default, as now);
- member: magpie's provider/model that answered (what memberModel did;
  Claude Code, Claude Desktop and Codex still get the name asked for);
- vendor: the vendor's own text, for every agent, the vendorNamed three
  included, as every agent got before v0.1.2473 and as the header's
  "vendor" already gave them.
X-Magpie-Response-Model (asked, member or vendor) still picks for its
request; an unknown value falls through to the setting, as before.

memberModel is folded in without changing anyone's choice: a file with
memberModel on reads as replyModel member, an explicit replyModel wins, and
memberModel is written beside it as a mirror so an older magpie reads the
same. An older page sending only memberModel changes the setting only when
its switch moved (a vendor choice survives its saves). The CLI's set/reset
goes through Keys/Choices (replyModel in place of memberModel).

app.js's row is paid for by five comments in Settings' code cut down:
app.js is 145 bytes under its base, no budget raise.

Run on mote at this head (rebased on origin/main b328a7790):
- gofmt -l clean; GOOS=linux go vet -tags nogui ./... and GOOS=windows
  go vet ./... clean.
- go test -tags nogui -count=1 -timeout 45m ./internal/settings
  ./internal/settingsapi ./internal/gui ./internal/cli ./internal/gateway:
  settings, settingsapi, gui, cli ok; gateway ok but
  TestCodexPoolSaysTheClientsVersion, red in the full package and green
  alone (#4807, another test's Codex identity; passed alone at the
  previous head).
- GUI (node --test, chromium + webkit): reply-model-setting (5 languages x
  1100/420, plus default-to-member), loop-guard-setting, i18n-keys,
  account-discovery, disabled-models, masking-records,
  refusal-retries-setting: 222 pass, 0 fail.
- Whole GUI suite earlier at d73b208ac's tree: reds in account-eye (#4244)
  and segs-press-redraw's "every Settings option" (#4566, searchAllRow;
  red the same at origin/main b328a7790, run alone), plus load reds in
  unrelated pages; none in Settings' Replies.

Rebased again onto f3681b90c (Agents page, usage, claude /usage) and
run there: internal/gui and settingsapi -run Budget|SettingsSave|Keys ok,
settings TestReplyModel ok, i18n-keys + reply-model-setting 26/26.

Broken by hand (each red, then put back):
- replyNamingOf ignoring the vendor setting: TestReplyNamesMember's
  vendor, vendor+codex, vendor+claude code cases red on every protocol.
- normal() without the memberModel fold: TestReplyModelFoldsMemberModel
  and TestReplyNamesMember's "old file on" red.
- Merge without the old page's memberModel rule: TestReplyModelSaves'
  old page turns it on / off red.
- settings_keep_test.go went red at the earlier head (MemberModel not sent),
  fixed by setting replyModel member there.

Not tried: a real vendor account through a real group; the GUI test was not
run against the old app.js (the row doesn't exist there).
2026-11-03 05:38:18 +08:00
yetone 2ab9235711 agents: an agent's picks can be kept to this computer, as an MCP server can
chenxiang0010 on Discord: 「agent当前选择的模型可不可以像mcp那样 只对当前设备生效」.
Sync carries every agent's picks (model, effort...) between computers;
an MCP server has an opt-in "This computer only" that sync and backup
files never carry. Agents now have the same: the row's menu (right-click
or ...) has This computer only, off by default, so an upgrade changes no
pick on any computer.

- settings: AgentsHere, this computer's own (KeepOwn), and kept by a save
  of the Settings page (settingsapi.Apply), which doesn't send it.
- davsync: each kept agent adds "<id>.*" to the own set (withHere, isOwn),
  so a sync neither pushes its fields nor brings the server's; a Restore
  from the server leaves them. sync-state.json records the list as of the
  last sync (Here): hashes before a sync use it and after use the current
  list, so turning it on or off is no change on either side, and a changed
  list forces the sync past its early returns. Turned off, the next pick
  goes up again. Other agents still sync both ways; the implicit own
  fields (hayden4608) are unchanged.
- backup.Restore skips a kept agent in a backup file.
- gui: POST /api/agents/here; the row says "This computer only" beside
  the version (hidden in the tray panel and in a narrow row), menu ticks.
  Core words moved from the library plugin's i18n into core i18n
  (zh/zh-TW/ja/de). Comments in renderAgents cut to pay for it under the
  core budget (no raise).
- cli: the route is named under stage 3 (no command yet).
- docs/subsystems/sync-backup.md describes it.

Run on mote, at the base eb8b840dd (Go and the GUI files below) and again
at this head's base for internal/gui (core budget) and agent-here,
i18n-keys, agent-menu-label:
- go test -tags nogui ./internal/davsync ./internal/settings
  ./internal/backup ./internal/gui ./internal/settingsapi: ok
- go test ./internal/cli: ok but TestEveryRouteHasACommandOrIsNamed,
  red on main for POST /api/usage/checkin-account alone (#4826)
- GOOS=linux and GOOS=windows go vet ./...: ok; gofmt -l: clean
- GUI, chromium + webkit: agent-here (en/zh/zh-TW/ja/de x 1100/640/360),
  i18n-keys, sync-own-fields, mcp-local-server, agent-menu-label:
  90/90 ok
- the whole GUI suite: cut off at test 3783 by a session restart; the
  rest (key-* on) is still running at push. Reds seen so far, under
  three GUI suites at once on mote, none in an agent file: account-eye,
  balance-fix (Sub2API, /api/user/self), codex-auto-reset, context-map,
  editor-advanced-align; being checked at main and filed there.

Broken by hand, each red then restored:
- hereOf returns nil: TestAgentHereThroughSync "B's kept picks went up"
- backup.Restore's kept skip off: "B after a backup file"
- KeepOwn line dropped: TestAgentsHereIsThisComputers "another
  computer's kept agents came in"
- TestSettingsSaveKeepsWhatItDoesNotSend went red on this change before
  settingsapi kept AgentsHere (a Settings save would have dropped it).

Not tried: a real two-computer sync with real accounts; no CLI/TUI
command for the flag; Settings -> Sync doesn't list kept agents; WSL
agent ids (codex@wsl:...) only through the key format.
2026-11-03 02:27:20 +08:00
yetone ed978e560f gui: the Quit question's Don't ask again, and Settings › General › Ask before quitting (zhujiu on Discord)
zhujiu (Discord #feedback) asked for a 不再提示 on the question a tray
Quit asks while agents go through magpie (8826a15ea), and a switch in
Settings to turn it on and off again.

- The question (quitask.js, an in-app sheet) has a "Don't ask again"
  checkbox above its buttons, unticked each time. It goes with the Quit
  chosen: Quit and Disconnect and quit post window/quit?now=1&noAsk=1,
  which saves settings.quitNoAsk (settings.SetQuitNoAsk, under the file
  lock) before quitting; a failed save keeps magpie open. Cancel saves
  nothing.
- AskQuit quits at once when quitNoAsk is set (quitAtOnce); otherwise as
  before. The default is unchanged: it asks.
- Settings › General has "Ask before quitting" On/Off (segs, app-only),
  after Open at login. settingsapi.Keys lists quitNoAsk, and Merge carries
  it when a save doesn't send it, so the tray panel or an older page
  can't turn the question back on.
- zh, zh-TW, ja, de strings. Five app.js comments shortened to stay in
  the core script budget (no raise).

Run at the pushed head (on origin/main f95bacdfb), on mote:
- gofmt clean; go vet darwin, linux, windows (nogui too).
- go test internal/settings, internal/settingsapi ok; internal/gui
  -run "Budget|Quit" ok.
- internal/cli: TestEveryRouteHasACommandOrIsNamed red for
  POST /api/usage/checkin-account, from e87140242, filed as #4826; this
  change adds no route.
- GUI, chromium and webkit: quit-ask-setting (25: en, zh, zh-TW, ja, de
  at 1100 and 420), quit-ask (35), settings-general, settings-sections,
  settings-search, settings-tabs-stick, wsl-agents-setting, agent-prefs,
  i18n-keys, old-webkit, auto-backup, all pass.

Broken by hand, each red:
- api.go's noAsk ignored: TestQuitDontAskAgain "wasn't saved".
- quitAtOnce not reading the setting: TestQuitDontAskAgain "still asks".
- Merge carry dropped: TestQuitNoAskKeptUnlessSent.
- SetQuitNoAsk saving false: TestSetQuitNoAsk.
- quitask.js without &noAsk=1: quit-ask's two Don't ask again tests.

Not tried: a real tray Quit with the box ticked in the built app on
macOS, Windows or Linux; only the sheet in Playwright and the handler
in Go. Not the whole GUI suite.
2026-11-02 18:53:07 +08:00
yetone da275848b6 tray: Windows shows a card's number in its icon (Benjaminliang_1 on X)
Windows' notification area shows no text beside an icon, so with a card
in the tray the icon itself is now the first card's figure: the first
row of the first card whose first row is a percentage, used or left as
Allowance display has it, its digits alone (trayIconFigure). It is drawn
in Segoe UI Semibold (Go's bold if the font can't be read) at
SM_CXSMICON, white on a dark taskbar, near black on a light one, as tall
as fits, centred by its ink, three digits narrowed into the square
(trayNumberIcon). It is drawn again when the figure, the icon size or
the taskbar theme changes (SystemThemeChanged wakes the loop); the
tooltip still lists every card. A balance or magpie's totals are
skipped; with no such card, or no cards at all, the icon is the bird as
before. Settings > Usage > Tray icon number (settings.TrayNoNumber,
Windows only, on by default, kept per computer) keeps the bird when off;
Menu bar windows is now shown on Windows too, since it picks the row
the number comes from. The number row sits after Menu bar cost, so the
bird > pace > cost order the other tests pin holds. Linux and the Mac
are unchanged. New words in zh, zh-TW, ja and de. app.js stays in the
core budget with one comment shortened, no raise.

Run at this commit on origin/main ec104b862 (traywindows.js merged with
94f6f6092's trayExtra pills; its "not on Windows" note dropped), mote:
gofmt -l empty; go vet and GOOS=windows go vet of gui and settings ok;
go test -count=1 -timeout 45m ./internal/settings ./internal/davsync
ok; ./internal/gui red only on TestMainWindowCorners (#3949),
TestCoreScriptBudget ok. GUI tray-windows, tray-cost, quota-pace,
i18n-keys, tray-bird, tray-logos, tray-usages, quit-ask: 140 pass,
0 fail. win-run on xiaomi-gpu: TestTrayNumberIcon and
TestTrayIconFigure ok. At c0477aa72 the same GUI set once had
quota-pace webkit "On moved the page" (439 !== 120), a late wheel
(#4784); green twice after, and quota-pace alone 3 of 3 green there
and on c0477aa72 itself.

Run before on the same change over origin/main 9d08993c8, mote:
- gofmt -l on gui/settings/davsync: empty; go vet ./internal/gui
  ./internal/settings and GOOS=windows go vet: ok.
- go test -count=1 -timeout 45m ./internal/gui ./internal/settings
  ./internal/davsync: settings ok, davsync ok; gui red only on
  TestMainWindowCorners/macOS_26_SDK (#3949) and TestCoreScriptBudget
  (5 bytes over after the rebase), which is green after the comment
  trim, rerun with TestTrayNumberIcon and TestTrayIconFigure: ok.
- GUI (both engines): tray-windows, tray-cost, quota-pace: 56 pass,
  0 fail. Earlier at this tree: tray-bird, tray-logos, tray-usages,
  i18n-keys green; quota-pace webkit de 420 red once, from a late wheel
  scroll (#4784), green on the rerun; segs-press-redraw red on
  searchAllRow, the same on a clean origin/main 9d08993c8 copy (#4566).
- A 184-file GUI run (the files touching Settings, the tray or i18n,
  before the rebase) under mote load 40-90: 3095 pass, 224 fail. My
  files' reds there (tray-cost: the number row was between pace and
  cost) are fixed above. The rest are in files this change doesn't
  reach (account-alias, model chips, menu-input-scroll, mobile-web,
  omarchy, plugin-github, key-replace, context-map and others; #4600
  lists several). Each was not compared on main one by one.
Windows (win-run on xiaomi-gpu, real Segoe UI): TestTrayNumberIcon and
TestTrayIconFigure ok.
Real Windows 11 run: a production build in a portable sandbox (own
data\, USERPROFILE/APPDATA/LOCALAPPDATA redirected, gateway on a free
port, a fake remote magpie serving one Claude card). The dark taskbar
showed a white "42", then a narrowed "100" when the card read 100%,
and the bird with trayNoNumber set. Only my processes, tasks and
NotifyIconSettings entry were removed afterwards.

Broken by hand: trayIconFigure always "" turns TestTrayIconFigure red
(6 cases); the dark and light colours swapped turn TestTrayNumberIcon
red; the old advance-width centring turns it red too.

Not tried: a light taskbar on the real box (it would change the user's
theme; covered by the test only), hovering the tooltip (screen locked),
other DPIs on real hardware, Windows on ARM64. Linux's code is
unchanged and was not run.
2026-11-01 21:31:55 +08:00
yetone ec104b8625 gateway: a Codex account can spend its credits before magpie moves to another account (jojonas_xyz on X)
jojonas_xyz on X: "我账号额度用完了自动给我切了别的号…找不到怎么关掉设置…你怎么知道
我不是想用 credits 呢". (Roughly: "my account ran out of quota and magpie
switched me to another account by itself; I can't find a setting to turn
that off; how do you know I didn't want to use the credits?")

Cause. At 90% or 98% of a window, smart routing's tier put the account
behind every account that still had room, whether or not it had ChatGPT
credits. Codex's own sign-in (NextLogin / SwitchWhenSpent) moved at the
spent share in the same way. The account's credits were spent only once
every other account was used up, and the switch was a log line. The Use
credits switches that existed (on, and "Only after other accounts" from
699ddf152) were only on the Usage page and the panel. None of them meant
"stay on this account and spend its credits".

Change.
- A fourth credits mode, first: settings.CodexCreditsFirst. on, first,
  last and off are exclusive; one mode replaces another.
- routes.Seat.First: a first seat's tier is 0, so routing keeps it in
  front past its windows while it has credits. The trace records
  Weighed.CreditsFirst.
- NextLogin keeps Codex's own sign-in on such an account (spendsFirst).
- The POST /api/codex-credits handler takes "first". The general
  settings save keeps the stored value.
- The CLI: `magpie quota credits <account> first`.
- GUI. No new page and no new component, only the Use credits row that
  already exists:
  - 供应商 → Codex → 账号 ⋯ → 使用积分 → 「先用完积分再换账号」. The
    Providers ⋯ tools now carry the credits row too, which is where the
    reporter looked.
  - 用量 → Codex 账号卡 → 使用积分 → 「先用完积分再换账号」.
  - The menu-bar panel's folded line reads 「开,先于其他账号」.
  - The "First again once it has room" tag on a moved-off account now
    points to the switch in its title.
  - Strings are in en, zh, zh-TW, ja and de.
- "Only after other accounts" (gokoshiki, 699ddf152) is unchanged.
  Its off title now says what off means.
- Docs: docs/reference.md and docs/subsystems/gateway-routing.md.

Budgets: at this head app.js is 1,312,105 of 1,316,874 bytes, and
TestCoreScriptBudget passes (231 bytes under before the rebase). Comments
were condensed; no budget was raised.

Run on mote, at this tree (rebased on origin/main 9d08993c8; the rebase
moved the settings save into internal/settingsapi, which now carries
CodexCreditsFirst beside CodexCreditsLast):
- go test -count=1 -timeout 45m ./internal/gateway ./internal/provider
  ./internal/routes ./internal/settings ./internal/settingsapi
  ./internal/gui ./internal/cli at 9d08993c8+1: gateway, provider,
  routes, settings and settingsapi ok. Two reds, both filed:
  - internal/gui TestMainWindowCorners/macOS_26_SDK: #3949.
  - internal/cli TestLibraryMCPHub, TempDir cleanup not empty: #4140.
  At the pre-rebase tree (da0005df8+1) internal/gui also had
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestColdTurnsTaken
  (#4510), red the same at da0005df8; both pass at this head.
- New tests:
  - internal/provider/codex_credits_first_test.go
  - internal/gateway/codex_credits_first_test.go (routing and the trace)
  - internal/gui/codex_credits_first_test.go (POST sequence, sandbox HOME)
  - internal/gui/tests/codex-credits-first.test.cjs: the Usage page and
    Providers ⋯ at 900 and 440px, and the panel at 360px; chromium and
    webkit, en zh zh-TW ja de. It also checks for no select, no stripe,
    the i18n keys, and that a click does not move the page.
- The whole GUI suite (make test-ui), at da0005df8+1 on mote at load
  66 to 213, in two parts (a wiped scratchpad cut the first log; its red
  titles were kept): 59 files with a red. 45 of them are red at
  origin/main da0005df8 too, each under an open issue: #4304 (mote
  umbrella), #4600, #4471, #4120, #4119, #4621, and per file balance-fix
  #4682/#4683, gui-ja #4580, page-width-steady #4541, phone-connect-menu
  #4706/#4707, quota-curve #4768, segs-press-redraw #4566, signin-proxy
  #4643/#1814, zhipu-team #4728, model-copy-id #4621 (red 4 of 4 on main).
- The 14 green at da0005df8 were run again at this tree. One was this
  change's: usage-curve-zoom-back. The Codex card's fourth credits line
  (366px, was 344) held the DeepSeek card beside it to 261px, so the
  "card grows" check at 1100px had no room. Its fixture now turns the
  Codex account's credits off, since the count of credits lines isn't
  what it tests; 20 of 20 pass.
- At this head (9d08993c8+1), on mote at load 75 to 84: codex-credits-first,
  codex-credits-last, codex-credits, routing-codex-credits-again,
  panel-options-fold, usage-curve-zoom-back, i18n-keys and the 13 files
  above: 232 tests, 227 pass. Each red has an open issue:
  - models-fold webkit en/zh, "ebody holds" after the click: #4071; red
    the same at 9d08993c8 (run there).
  - account-weight webkit, same "ebody holds": #4644 (red at
    da0005df8+1, green in this run).
  - routing-many-keys chromium de "2 keys in sight at the foot": #4082
    (under load; red again alone here, green at 9d08993c8 in one run).
  - signin-closes-sheet chromium en/zh: #2628 (green alone at this head
    in a second run).
  - signin-again and signin-port-blocked, red once at da0005df8+1 under
    load, pass at this head and at 9d08993c8.

- Rebased last onto 94f6f6092 (three commits; c0477aa72 changes the
  Codex Providers row): go test -run 'Budget|CodexCredits|SettingsSave'
  ./internal/gui ok, and codex-credits-first, codex-credits,
  codex-credits-last, providers-reset-use, i18n-keys and
  usage-curve-zoom-back: 92 of 92 pass.

Broken by hand, each red, then restored:
- spendsFirst forced false: the provider test is red.
- The gateway's l.first forced false: both gateway tests are red.
- codex-credits-first.test.cjs against origin/main's assets: red
  (TimeoutError on the switch).

Not tried:
- No real ChatGPT account with credits went past its window. The routing
  order and NextLogin are tested on fakes only.
- The Linux and Windows apps were not run.

go vet -tags nogui ./... with GOOS darwin, linux and windows on mote:
clean (cgo enum warnings only). gofmt -l on the changed Go files: clean.

Claude has no equivalent: magpie reads no extra_usage and has no Use
credits modes for Claude. Filed as #4662 (see #4241).
2026-11-01 21:19:22 +08:00
yetone e5f66f8a61 claude: with the interactive mode on, nothing ever runs as -p; the editor switches TUI and claude -p
The owner (11-01): the interactive mode falling back to -p is dangerous,
for the account (a -p request counts as another client's) and for the
cache (a -p run starts without the interactive mode's), so it goes
entirely. With Settings › Models › Replies' interactive mode on:

- a request it can't take (safeguards, client cache marks, a JSON
  schema, an image by URL, words over 400KB, a branch of a -p session,
  a WSL Claude Code whose home or transcripts magpie can't reach) is
  refused before any Claude Code starts, saying why and naming the
  setting (claudeTUIErr), never run as -p;
- a helper that can't start the interactive mode (sign-in asked,
  first-run notes, an untrusted folder, no prompt within ReadyWait)
  ends saying why (claudetui fail); printMode, OnlyEnv and the
  claude-tui-broken mark that sent every run to -p for a day are gone;
- a helper that never answers initialize fails the turn
  (tuiNoStart), and the next turn tries again.

Off still runs every request as -p. The "Interactive only" choice of
v0.1.2448 (claudeTUIOnly) is what On is now; the setting is no longer
read or sent.

The Claude Code provider editor's "Claude Code runs as" row is a
switch between Interactive mode (TUI) and claude -p (owner, 11-01),
saving claudePrintMode and reading /api/claude/mode again; disabled in
magpie web. It reads the settings first when the Settings page was
never opened (prefs null crashed the switch; found by the GUI test).
Chromium has no onfocusin property, so the card on keyboard focus
listens for focusin/focusout. Words in en, zh, zh-TW, ja and de.
Docs: claude-subscription-bridge.md describes refusal, not fallback.

Not covered yet, now refused under On rather than run as -p (follow-
ups, each to be done inside the interactive mode): an image by URL, a
JSON schema, safeguards, client cache marks, over 400KB, a -p
session's branch, WSL transcripts Windows can't read. /usage reads
the allowance with claude -p /usage (no model request) either way.

Run (worktree at df0320156 + this):
- mote: gofmt -l clean; go vet darwin/windows/linux of claudetui,
  gateway (gui for windows); go test claudetui, settings, settingsapi
  ok; gateway -run "TUI|Warm|Claude|AskClaude|Cache|Mode" ok (110s);
  gui -run "Budget|I18n|Settings|Claude" ok.
- mote GUI: claude-mode, claude-tui-setting, i18n-keys: 64/64 pass in
  Chromium and WebKit, 900 and 420 wide, en zh zh-TW ja de.
- wsl-run go vet -tags nogui ./internal/gui ./internal/claudetui ok;
  win-run go test ./internal/claudetui ok.
- Real Claude Code 2.1.316 on macOS through this build's
  claude-tui-helper, sandbox HOME, CLAUDE_CODE_OAUTH_TOKEN: trusted
  folder -> interactive run, streamed (message_start, 4 deltas,
  message_stop), result success in 5.2s; untrusted folder -> exit 1
  "Claude Code's interactive mode didn't run: Claude Code asks whether
  to trust the folder", no -p run; config without onboarding -> exit
  1 naming the first-run notes, no -p run.
Seen red: claude-mode's save test with prefs null before the fix, and
its focus test in Chromium before the listeners; TestClaudeModeLast
while it still read a helper's "this run is -p" line.
Not tried: a real gateway request refused in the GUI (covered by the
Go tests with the fake Claude Code); the new gateway tests run
against the old fallback code; Windows and WSL real runs of this
build; no full suite.
2026-11-01 17:43:17 +08:00
yetone 5dfbca6274 cli: magpie settings list|get|set|reset, through the window's own save (#4745)
Stage 1 of #4745 (StringKe): every setting POST /api/settings saves can
be read and set from the terminal.

- internal/settingsapi holds the save the handler made: Merge (the
  carry of keys a page leaves out, moved verbatim from api.go, plus
  upstream's RouterNote line), the vision/imageGen/searcher checks,
  settings.Save's own checks, catalog.Touched. POST /api/settings and
  `magpie settings` both call settingsapi.Apply, so a value is checked
  and saved one way. It sits outside internal/gui so the nogui build
  has it.
- `magpie settings` (list, the default, with value, default and
  choices; get; set; reset to settings.Defaults()), --json on list and
  get. Body sends the whole file with one key changed, so a key the
  save keeps when absent (noBird, refusalRetries, ...) is set even to
  off. A flag where a key or value goes, an unknown key (with near
  matches named) or a refused value writes nothing and exits 1;
  --help prints usage.
- Parity guards: TestKeysAreWhatTheSaveWrites (each Settings field sent
  changed on its own; what the save takes must equal Keys),
  TestSettingsCLISetsWhatTheWindowSaves (every key the page's prefsKeep
  and savePrefs send is a key), TestEveryRouteHasACommandOrIsNamed
  (each /api route has a command or a reason in notYet, which later
  stages shrink; 36 have one now).
- Item 3 of the stage (per-provider CLI-only fields in the window) is
  left for stage 2.
- The open app's in-process follow-ups (fonts, Dock, tray menu, alerts,
  language, update re-check) run only from the window's save: #4752.

Run (mote, at the pushed head 1c3591b5d + this):
- gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; GOOS=linux go build -tags nogui;
  GOOS=windows go build: clean (before rebase, the vets again after).
- go test internal/settingsapi, internal/settings, internal/cli: ok.
  internal/gui -run Settings|Prefs|Keep after the rebase: ok. The full
  internal/gui run before the rebase had three reds:
  TestSettingsSaveKeepsWhatItDoesNotSend (BusyLoad, fixed on main in
  b646a9127), TestColdTurnsTaken (fixed on main in 647323409) and
  TestMainWindowCorners/macOS_26_SDK (#3949, mote is macOS 27).
- Real run in a sandbox HOME on mote with a magpie built from this:
  settings --help / help, list, get, set theme dark, noBird on,
  redactWords "acme, globex", usageAlert 85; refused theme neon, `them`
  (names theme), usageAlert lots, trayUsageEvery 4, vision
  nobody/nothing, each exit 1 with settings.json unchanged; set
  usageAlert --help printed usage and wrote nothing. Then `magpie web`
  with MAGPIE_WEB_KEY: GET /api/settings read back each value the CLI
  set; POST /api/settings lang ja, then `settings get lang` said ja;
  reset theme gave system.

Broken by hand, each red, then put back: noBird dropped from Keys
(TestKeys, TestBodySetsOneKeyOnly, the CLI set test and the GUI parity
test red); Body dropping false values (TestBodySetsOneKeyOnly and the
CLI "noBird off" check red); a route taken out of notYet and another
renamed (TestEveryRouteHasACommandOrIsNamed red, 3 errors). On the old
code the new tests don't compile (no settingsapi, no command).

Not tried: a real run on Windows or Linux; the live app reacting to a
CLI write while open (#4752); the GUI node suite (no page file changed).
2026-11-01 15:57:43 +08:00
yetone 01ccbd40a0 library: an MCP router says which computer it is, so an agent can pick between two (packinggoodsllc_07668 on Discord)
Two magpies, one in China and one in Los Angeles, each serve the same
tools through their MCP router (/mcp/magpie/hub). An agent connected to
both saw two identical web fetches and couldn't pick the one in Los
Angeles to reach Google.

Each router now says where it is:
- initialize's instructions end "This router: <name>. Each of its
  tools' descriptions starts with [<name>]; ...", and serverInfo.title
  is "Magpie MCP hub · <name>";
- each tool's description in tools/list starts "[<name>] " (once: a
  description that starts so already, another magpie's router behind
  this one, isn't given it twice).
<name> is the user's words (settings.RouterNote, one line, 80
characters at most) to every caller. With none it is this computer's
name, to callers on other computers only: an agent on this computer
has one router at hand, and its prompts stay as they were.

RouterNote is this computer's own (KeepOwn): library.json is synced,
settings.json isn't, so a sync never brings the other machine's name.
It is set in the Library's MCP tab, in a Router name row under the
router's address (shown while the router is on): a plain field with the
computer's name as placeholder, saved on Enter or leaving it, Escape
puts the saved words back, an input method's Enter is its own. POST
/api/settings keeps it. Translated in zh, zh-TW, ja, de.
docs/subsystems/mcp-router.md has the rule.

Run (mote, at a5a9cdf7b + this change): go vet ./... for darwin, linux
and windows ok; go test -tags nogui ./... -timeout 45m: every package
ok except internal/gui's TestSettingsSaveKeepsWhatItDoesNotSend on
BusyLoad, red on main since 8d8df0639 (#4739, fixed in the next
commit). After rebasing on 9feb1024c: internal/gui, settings, library
and gateway again, and node --test library-mcp-router-note (new),
library-mcp-hub, mcp-hub-direct and i18n-keys, chromium and webkit,
en/zh/zh-TW/ja/de, at 1100 and 420 wide.

Broken by hand: hubWhere returning "" turns TestHubMCPSaysWhere red;
dropping RouterNote from KeepOwn turns TestRouterNote red; dropping it
from POST /api/settings' carry list turns TestHubNoteSaved and
TestSettingsSaveKeepsWhatItDoesNotSend red. i18n-keys caught a test
comment saying "Router name", reworded.

Not tried: two real magpies on two computers with a real Claude Code
or Codex connected to both, and whether a model actually picks by the
prefix; the Linux and Windows apps' Library tab.
2026-11-01 15:23:15 +08:00
yetone 4c815ac2a5 search: searchers picked to follow the one named, tried in their order when it fails (axelburks on Discord)
axelburks asked for more than one searcher, so that when one fails
another provider searches. A searcher named in Settings gave way to no
other provider before, only to the Search APIs. Automatic already fell
back to up to three.

- settings: SearcherThen, the searchers after the one named. Entries
  are trimmed. Blanks, "off", the named one and repeats are dropped.
- gateway: when the named searcher fails (the context still live),
  modelSearch asks each of SearcherThen in order and skips one that
  can't search now or is the same model. The first that searches
  answers, and the call is marked searchingInstead, so the Routing row
  says why the named one didn't search. If all of them fail, their
  errors go back together, saying "the searchers picked ..., in their
  order", and webSearch goes on to the Search APIs as before.
  SearchFailure.Instead names the one that searched in its place.
- gui api: searchFailed.instead. A save takes only searchers that
  Searchers() offers. A save without searcherThen keeps the list, since
  the page's prefsKeep doesn't send it, and [] clears it.
- Settings › Web search (plugins/search/settings.js, outside app.js's
  budget): an "If it fails" row under a named searcher, with numbered
  chips and Add. A chip's picker changes the chip or removes it. The
  row is hidden for Automatic and Off. The failure line names who
  searched instead, or says the ones after it failed too. The help
  text says the same in en, zh, zh-TW, ja and de.
- docs: gateway-routing's failing searcher, and gui-shell.

Tests:
- TestPickedSearchersInTheirOrder (gateway): one test where the named
  searcher answers without searching and one where it fails. A gone
  entry and one that can't search are skipped, and the third searches
  once. With no working entry, the error says so and Instead is empty.
- TestSearcherThenSaved (settings) and TestSearcherThenFromSettings
  (gui): what is saved, kept and cleared; refusing an entry that can't
  search. settings_keep_test sets SearcherThen.
- searcher-then.test.cjs: chromium and webkit, en, zh, zh-TW, ja, de,
  at 560 and 1000 wide. Checks the row's place and words, what Add
  offers, the posted lists, that the chips fit with no horizontal
  scroll, that no click moves the page, and both failure lines.
Broken by hand: running no fallback turned TestPickedSearchersInTheirOrder
red (both subtests: "ds2 searched []"). Not keeping the list on save
turned TestSearcherThenFromSettings and the keep test red.

Run on mote (mote-run):
- At the pre-rebase tree (base 21882a68d): go test of settings, and
  -run 'Searcher|Search' of gateway and gui: ok.
- searcher-then, searcher-pick and i18n-keys in both engines: 46 of 46.
- gofmt clean. go vet: darwin gateway, gui, settings; windows the same;
  linux gateway and settings on mote, gui with -tags gtk3 on the Linux
  box (wsl-run): ok.
- Rebased onto origin/main 1e6a27d4f, this tree: -run
  'Search|Searcher|CoreScriptBudget|SettingsSave' of gateway, gui and
  settings: gateway and settings ok; gui ok but for
  TestSettingsSaveKeepsWhatItDoesNotSend on BusyLoad, red on main
  since 8d8df0639 (#4739, not this change; SearcherThen passes its
  check). The three GUI files above: 46 of 46.
  Pushed on origin/main e62a1bc51. Its 6 commits since touch routing,
  sessions and rex files only, none of these, and weren't run here.
Not run before the tag: the whole GUI suite and the full go test of
gateway, gui and settings. They are queued behind other sessions'
suites on mote and run after the push; any red they find gets its own
commit.
Not tried: a real relay or a real searcher failing in the GUI app.
2026-11-01 14:43:18 +08:00
yetone 7503beee72 plugin, settings: a model's load goes past 100% for a vendor that queues (axelburks on Discord)
axelburks, on v0.1.2547: their vendor queues, so a model's load can be
past 100%, even 200%. magpie clamped every load to 100, and Busy models
last allowed 1-99 only.

- host.js reportLoad and plugin.noteLoads keep a load from 0 up. The
  floor is still 0, null still clears it, and a sanity cap of 10000
  (LOAD_MOST, plugin.LoadMost) keeps an absurd value from reaching the
  UI or the trace.
- settings.BusyLoad takes 1 to 9999 (BusyLoadMost-1). The segment
  choices stay Off/50/70/80/90, and a value set in settings.json (150)
  shows as its own choice, as before.
- The editor's badge reads "180%". It is a badge, not a bar, so nothing
  assumed 100 wide; the test checks it stays on one line.
- Docs: site plugins page (en, zh, ja) Values and Routing bullets, and
  provider-plugins.md and gateway-routing.md.

Run on mote via mote-run, on origin/main 8d8df0639+ rebased:
- go test ./internal/plugin ./internal/gateway ./internal/settings -run
  'ModelLoad|TestBusy' -v: all pass. TestPluginReportsModelLoad has
  over:250 kept and huge:1e9 at 10000. TestBusyModelGoesBehind has 180
  behind 120 at a threshold of 150, and 10000 refused.
- Broken by hand in a copy, with the old 100 clamps and the 99 limit:
  TestPluginReportsModelLoad red ("ModelLoad(over) = 100; want 250"),
  TestBusyModelGoesBehind red (150 refused).
- node --test model-load (with Queued 180% in every language, Chromium
  and WebKit, 420 and 900, plus Over 150% picked at 420) and i18n-keys:
  46/46 pass. go test ./internal/gui -run Budget: ok.
- gofmt -l: empty. GOOS=linux go vet -tags nogui and GOOS=windows go
  vet on plugin, settings and gateway: ok.

Not run before the push (owner: push and tag first): go test ./... and
the whole GUI suite. They are queued on mote behind another session's
suite.
2026-11-01 14:28:25 +08:00
yetone 8d8df06399 plugin, gateway: a plugin reports its models' load, and busy models can go last (axelburks on Discord)
axelburks (Discord #feedback): an in-house vendor queues requests to
its busy models, and the plugin could only put the load in the model's
name, which changed only when magpie re-read the list.

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

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

Not run before the push (owner: push and tag first): go test ./...
-timeout 45m and the whole GUI suite. mote and the WSL box were each
running another session's full suite. Both run next, and any red gets
its own commit.
Not tried: a real plugin and vendor reporting load. The plugin side is
tested through the real Bun host with a plugin written in the test.
2026-11-01 13:45:40 +08:00
yetone 699ddf1524 gateway: a Codex account can spend its credits only after every other account, key and fallback (gokoshiki on Discord)
gokoshiki wants a Codex subscription first, then an OpenAI API key, then
the subscription's credits. Until now an account at 100% that holds
credits either kept its place and spent them there (on) or was held
(off). This adds a third way per account, "last":

- settings: CodexCreditsLast []string, empty by default, so a setting
  saved before it keeps its order. provider.CodexCreditsLast,
  CodexCreditsMode and SetCodexCreditsMode(user, on|last|off);
  SetCodexCredits(on) still means "in its place" and clears last.
- gateway: candidate.creditsLast is true for such an account once a
  window for the model is used up and it is going on its credits (a
  call ChatGPT counts in no window stays in its place). restLast orders
  ready, then resting, then those, and marks Weighed.CreditsLast.
  restLast runs over the asides too, so such an account goes behind a
  provider's reserves (Accounts at once, 2c6b7c063) as well.
  lastBehind keeps In turn's next turn (after), a new conversation's
  spread (leastHeld) and a subagent's lead (readyForNew) from bringing
  it forward, and a kept conversation moves off it to one not on its
  credits (Affinity.Why "credits").
- CLI: magpie quota credits <account> [on|last|off]; alone it lists
  accounts set off and last.
- API: POST /api/settings/codex-credits takes {user, on, last?}.
- GUI: under a Codex account's Use credits, while on, a second switch
  "Only after every other account, key and fallback", in the Usage
  page's card and the tray panel's (both wrap it to its own line at 360
  to 900px), and the panel's folded brief says "On, after everything
  else". The Routing page's trace says why such an account is behind
  (aside, the kept conversation's why, the row tag). zh, zh-TW, ja, de.
  creditsButton and the new switch share creditsSwitch, and the Codex
  options' comments in app.js were cut, so the core budget holds with
  no raise (1,532,664 of 1,533,105).
- docs: reference.md (quota credits) and gateway-routing.md.

Tests:
- gateway: TestCodexCreditsLastAfterTheOthers (two accounts, In order:
  the one at 100% on its credits goes behind, the trace says so, and
  back in place when turned on), TestCodexCreditsLastAfterTheFallback
  (both accounts at 100% and set last: the API key the provider falls
  back to answers before either one's credits; with the credits in
  their place an account answers on them, as before),
  TestCodexCreditsLastNotKept (a kept conversation moves off it).
  All three red with creditsLast and lastBehind forced false.
- provider: TestCodexCreditsLastMode.
- gui: settings_keep_test carries CodexCreditsLast;
  tests/codex-credits-last.test.cjs (Chromium and WebKit, en zh zh-TW
  ja de; Usage at 900 and 440, the panel at 440 and 360, the folded
  brief, the Routing page's aside and why, every key in I18N). Red on
  the old assets (no .ar-credits-last).

Run at this change on origin/main c76bcaea7, on mote (pushed on fd70def82, whose
one commit since, fd70def82, changes only the Providers poll's Go
files in internal/gui):
gofmt clean; go vet of gateway, provider, gui, cli and settings ok;
their tests ok but internal/gui's #4514 and #3949, both on main. The
8 commits between d6aa9cdf6 and c76bcaea7 touch none of this
change's files.

Run at this change on origin/main d6aa9cdf6, Go 1.26.8:
- mote: gofmt -l clean; go vet ./..., and GOOS=linux and GOOS=windows
  go vet -tags nogui ./...: ok. go test -count=1 -timeout 45m ./...:
  85 packages ok; internal/gui red only on TestSettingsSaveKeepsWhatIt
  DoesNotSend's SearchAll (#4514), TestMainWindowCorners (#3949) and
  TestColdTurnsTaken (#4510), all three on main. TestCoreScriptBudget
  passes.
- WSL magpie-desktop, Playwright 1.62.0, both engines: codex-credits*,
  i18n-keys, gui-ja, gui-zh-tw, panel-options-fold, provider-at-once and
  every routing-* file: 2127 tests, 2064 pass. Every codex-credits and
  codex-credits-last test passed (26). The red files (gui-ja, 19 routing
  files) run again at this tree and at d6aa9cdf6, alike: 200 tests, 61
  and 57 red. gui-ja is #4580; the routing reds are timeouts and
  waits, on both. The one file red at this tree only,
  routing-request-model (WebKit 420px "the model is cut"), is 5 of 5
  green alone at both, and with six copies at once red at both (29 and
  27 of 30 here, 28 and 27 of 30 at d6aa9cdf6): a fixed 150ms wait
  after a resize, filed as #4650. Nothing this change adds to Routing
  draws unless an account is set last (fixtures don't).
- Earlier, at 3564eb04b (this change on 7428f3229), WSL: the whole GUI
  suite beside two other sessions' suites, 16944 tests, 16496 pass;
  its 102 red files again at that head and at 7428f3229, 444 and 425
  red. The files red at the head only, run alone: view-open-wheel,
  usage-accounts, add-button, usage-ledger-open-settled 0 red;
  view-wheel-after-click, view-wheel-unheard and context-map (#3488)
  red alone at 7428f3229 too. mote, the credits and i18n files: 172 of
  174, the two #4580 and a click timeout in quota-curve at load 148
  (alone 30 of 30).

Not tried: a real ChatGPT account at 100% with credits beside a real
OpenAI key; the order is shown with the gateway's fake Codex backend.
2026-11-01 09:08:07 +08:00
yetone 9bb1efdde3 gateway: a reply names the model the agent asked for when it went out under another name (issennknight)
issennknight on Discord (#general): an agent asked for deepseek-v4.1-flash,
which goes out as deepseek-v4.1-flash-1017 (settings' ModelIDs). The vendor's
reply said -1017, magpie passed it back, and the agent warned that the model
didn't match.

Before, only MemberModel (#822) or X-Magpie-Response-Model: member rewrote a
reply's model, and only to the group member's id. Now the default is
nameAsked. When magpie sent the request under another name than the agent
asked for (a model's own id, a routing group, a provider/model id), the
reply names the asked model. That covers Chat and Anthropic `model`,
Responses `response.model` (created, in_progress, completed), Anthropic
`message.model` (message_start) and Gemini `modelVersion`, streamed and
whole, translated paths and plugins included: it all goes through serve's
one memberWriter. A vendor that sent back the wire name as asked keeps its
own name, a dated -20261017 too. Usage rows, recent calls and the Routing
page still record served = the vendor's name: the writer sits outside
captureResponseWriter. Claude Code, Claude Desktop and Codex get the asked
name (or the vendor's), never the member's id, as before.

Streams are rewritten one complete line at a time (memberLines). A run
with no "model" in it is written through as the same slice. Only a JSON
reply that has a target at decide time is held whole, which is what
MemberModel already did.

A JSON body that doesn't parse (a reply cut short) goes on as it came.
A request to a remote magpie now sends X-Magpie-Response-Model: vendor
(passOnCaller). That magpie names the vendor's model, as before, so this
one still records what served the call (TestRemoteMagpieGroupNotSwapped
went red without it).

Existing tests that held a native reply byte for byte now expect only
its model renamed to the asked id (namedAs in member_test.go):
passthrough_severed, stream_accounting, refusal, refusal_thinking,
thinking_signature and vertex. The archive keeps the reply as the
vendor sent it, under the vendor's name (archive_test).

Also dropped: the openai-model header code. serve never relays that header,
so the test for it could not pass.

Run (mote, at this head rebased on origin/main 15066f84f):
- go test -tags nogui -count=1 -timeout 45m ./...: every package ok
  except internal/gui: TestSettingsSaveKeepsWhatItDoesNotSend (#4514,
  SearchAll from b09349d17) and TestColdTurnsTaken (#4510). Both are filed,
  and neither touches this change. Three other sessions' suites ran on
  mote at the same time.
  The first full run (base 80bcef18f) had internal/gateway red in 10
  tests: the byte-for-byte tests above, the remote-magpie served test and
  the truncated JSON body. Each one was fixed as described.
- Rebased on 544b91ca8 (no gateway files changed in between): go build ./...,
  go vet, then go test ./internal/gateway ./internal/settings
  ./internal/provider: all ok.
- go vet -tags nogui ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean (cgo warnings only); gofmt -l clean.
- go test -race -count=3 on the member and served tests: ok (122s).
- the 10 formerly red tests with TestReplyNames, TestGeminiReplyNames,
  TestMemberLine, TestMemberWriter and Masked, after the rebase: ok.

Red on the old code (the new tests over a git archive of the base):
- TestReplyNamesAskedModel: 36 subtests fail (own id, group and provider
  id, x 6 protocol paths, x streamed or not), e.g. `the reply names
  "deepseek-v4.1-flash-1017", want "deepseek-v4.1-flash"`.
- TestGeminiReplyNamesAskedModel: both subtests fail (modelVersion -1017).

Broken by hand: dropping `|| m.wire == m.asked` from target() fails
"as asked, dated" in 12 subtests.

Real use: Codex 0.165.0 (codex exec --json) under a sandbox HOME and
CODEX_HOME on mote. A fake Responses vendor always answered
deepseek-v4.1-flash-1017, and a tee between Codex and `magpie serve` logged
what Codex got. providers.json had d with deepseek-v4.1-flash and group
fast; settings.json had modelIDs d/deepseek-v4.1-flash ->
deepseek-v4.1-flash-1017.
- old build: the vendor was asked for -1017; Codex got "model":
  "deepseek-v4.1-flash-1017" in response.created, in_progress and completed,
  both for -m deepseek-v4.1-flash and for -m group/fast.
- new build: the vendor was still asked for -1017; Codex got
  "deepseek-v4.1-flash" and "group/fast"; the usage rows still say served
  deepseek-v4.1-flash-1017. Codex answered "pong" both times. Codex 0.165
  itself shows no warning for a body model either way (its "model
  rerouted" reads the openai-model header), so the agent behind the
  report's warning was not the one run.

Not tried: the reporter's own agent (not named) and Claude Code; the
Responses WebSocket path (responses_ws.go's own frames); a compressed
reply, which still goes through as it is; Antigravity's effort-variant
wire, where the wire differs from the asked name on purpose.
2026-11-01 04:51:17 +08:00
yetone 05f6ca39b3 provider, gui: settings only read go through the shared copy
settings.Load clones the whole Settings, every provider's model prefs
included. CompactsOf, OutputsOf, ModelNames, ModelEfforts,
settings.SavedAddr and the GUI's providerInfoWith only read it, and
providerInfoWith took a copy for each provider: 16 MB of what twenty
window polls allocated in a real-account sandbox, more with each
model a user has set prefs for.

They read settings.Shared() now. ModelEfforts hands back a clone of
the slice it finds, so a caller's change never reaches the shared
settings.

TestModelPrefsReadTheSharedSettings: 3000 other models' prefs; the
values are right, a caller's change to ModelEfforts' list doesn't
reach the settings, and each look allocates at most a tenth of
Load's. Red on the old code: ~6058 allocations a look against 6056
for a Load.

Run at this head on mote: go vet (darwin, GOOS=windows, GOOS=linux
without the gui package) ok; go test ./internal/settings and
./internal/provider ok; ./internal/gui red only in
TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
TestMainWindowCorners (#3949), both red on main.
2026-11-01 04:05:38 +08:00
yetone 15066f84f6 appdir: a folder and file name are joined once, not on every read
appdir.Config and Cache, catalog.CachePath and LivePath, settings.Path,
provider.Path and the logins path each ran filepath.Join on every call,
and they are called on every read of a cached file, many times a request.
Those joins were 70 MB of the 1.4 GB twenty window polls allocated.
appdir.Join and JoinFile keep each (dir, name, ext) they joined, up to
4096 of them, so a path named again is the same string. A changed HOME
or folder is a different key, so a test's sandbox still gets its own
path.

TestFoldersJoinedOnce and TestLivePathNamedOnce: 0 allocations a call.
Broken by hand on mote (the files before this change) they are red at 1
allocation a call, and 3 for LivePath.

Run on mote at this tree (on d714c4216): gofmt clean; vet ok on darwin,
windows and linux (appdir, catalog, settings, provider); go build ok;
appdir, catalog, settings (49s), provider (187s), agent (324s) and
gateway (1244s) ok.

At the pushed head (on 019bfc951, which adds provider.Held): vet of
appdir, catalog, settings, provider and gui ok, go build ok, appdir,
catalog and gui's TestAccountLabelsBuildTheAgentsOnce ok.
2026-11-01 03:52:46 +08:00
yetone e6b595e1ab claude: Interactive only, a setting under which a model request never runs as claude -p (_yuchanns_ on X)
_yuchanns_ on X, on the interactive mode falling back to -p: for people
who stayed off magpie's Claude subscriptions because of -p, a fallback
is a time bomb. Settings › Models › Replies › Claude Code's interactive
mode now has three choices: Off (always -p), On (the default, falling
back to -p as before) and Interactive only.

With Interactive only (settings.ClaudeTUIOnly; ClaudePrintMode set too
wins):
- a run claudeTUI would make -p is not started; the request fails with
  the reason and the setting (claudeOnlyErr, claudeNotTUIWhy);
- the helper is handed MAGPIE_CLAUDE_TUI_ONLY=1 (claudetui.OnlyEnv,
  claudeCLI.tuiEnv). Where it would exec -p (no start, sign-in, first-run
  notes, untrusted folder, 45s timeout) it exits with the reason
  (fallBack in Run), and it ignores the broken mark;
- a helper that never answers initialize ends the turn with an error,
  not a -p retry, and `broken` isn't counted (claudeMachineWhy), so the
  next run tries the interactive mode again;
- the model test's and warm-up's "hi" (askClaude) runs through the
  helper (askClaudeTUI) in stream-json, its stdin closed at the first
  result. The helper command and env are built in one place now
  (tuiCommand, tuiEnv) for both.
Reading the plan's allowance (/usage) asks no model and stays -p; the
setting's text says so. Docs: claude-subscription-bridge.md.

Provider editor, on e8347401f's "Claude Code runs as" pill
(ClaudeMode.Only): with the interactive mode in use and no last
request, it says a request it can't take fails, and the card's foot says
nothing runs as -p. Where the interactive mode can't run, the pill names
Interactive only, never claude -p, the line says "Claude requests fail:
<why>", and Change in Settings goes to the row. A request refused this
way never ran, so it isn't noted as the last request (noteClaudeRun
comes after the refusal).

app.js: the Replies rows share one helper (segRow, which waitRow uses
too), so app.js is 530 bytes under main's with the third choice; no
budget raise.

Tests: TestClaudeTUIOnlyRefusesPrint, TestClaudeTUIOnlyHungHelperNoPrint,
TestClaudeTUIOnlyTellsHelper, TestAskClaudeTUIOnly (gateway);
TestShimOnlyNeverPrints (claudetui: fake fail/trust/login/notes each
exit with an error and no -p, a marked-broken run still interactive);
claude-tui-setting.test.cjs (three choices, Only saves claudeTUIOnly with
claudePrintMode false) and claude-mode.test.cjs (Only in use, and Only where it can't run).

Broken by hand, each red, then put back: the startRun gate off
(RefusesPrint 200); start()'s Only check off (HungHelper 502 without the
Only reason); tuiEnv's OnlyEnv off (TellsHelper); askClaude's branch off
(AskClaudeTUIOnly); the helper's fallBack ignoring only (4 subtests);
BrokenSince's `&& !only` gone ("marked broken"); the save without
claudeTUIOnly (16 of 16 setting tests) and claudemode.js's m.only
branches gone, rebuilt on e8347401f's file (10 of 10 Only tests,
Chromium).

Run on mote at e8347401f + this commit:
- at f1d6f4137 (main, after #4571's claude_cache.go) + this commit: go
  vet of gateway and gui ok, CoreScriptBudget|I18n ok, the gateway's
  TUI|Warm|Claude|AskClaude|Cache tests ok; the rest below at e8347401f
- gofmt -l clean; go vet and GOOS=windows go vet of claudetui, gateway,
  settings and gui ok; Linux vet (wsl-run, -tags nogui) ok
- go test ./internal/claudetui ./internal/settings ok; the gateway's
  TUI|Warm|Claude|AskClaude tests ok
- internal/gui CoreScriptBudget|I18n|Settings: ok but
  TestSettingsSaveKeepsWhatItDoesNotSend, SearchAll, red on main since
  b09349d17 (#4514)
- GUI (Chromium + WebKit, every language): claude-mode, claude-tui-setting
  and i18n-keys 94 of 94 at e8347401f; with the other Replies rows'
  files (claude-lean-prompt, member-model, loop-guard, refusal-retries,
  classify-timeout, image-timeout) 180 of 180 at 2e9df9b1b. Earlier
  segs-press-redraw's searchAllRow red is #4566, not this change.
Not tried: a real account under Interactive only (the fallback paths
are forced by the fake Claude Code); the full GUI suite (mote had
another session's full GUI suite and an agent+gateway suite going).
2026-11-01 02:53:08 +08:00
yetone 33a284497e plugin options: a switch a provider plugin declares is saved where the plugin reads it (plugins#550)
`magpie plugin options cursor '{"wire_trace": true}'` wrote the entry's
options in plugins.json (a middleware's ctx.options), while a provider
plugin's switches (auth.options, the editor's Plugin options) are read
from settings' PluginOptions (input.magpie.option). The command said
"options set" and Wire trace stayed off.

Now a key that the plugin declares as a switch for one of its providers
(from the providers last listed, else asked of the plugin host) goes to
PluginOptions for that provider, through settings.EditPluginOptions, and
a running host is handed it (SetProviderOptions, 5s, best effort). Only
true or false is taken for a switch. The other keys go to plugins.json
as before; set with switches only, a middleware's options stay, less a
switch written there before. `off` puts every switch back to the
plugin's default and clears plugins.json's options. Shown with no value,
each switch is listed with its value. docs/reference.md and the plugins
page (en, zh, ja) say so.

Run at this head on mote: go test ./internal/cli ./internal/settings
./internal/plugin ok; gofmt -l clean; go vet darwin and GOOS=windows ok;
Linux go vet -tags gtk3 in WSL (magpie-desktop) ok.
Broken by hand: no key read as declared, and both new tests went red
(PluginOptions empty, the old switch left in plugins.json).
Not tried: the real CLI against a running magpie with the Cursor plugin
installed; a plugin not listed yet (the host path) is not in a test.
2026-10-31 16:46:14 +08:00
yetone 7b09d2c951 provider: a model can be listed by an id of the user's at its provider, asked for by its own
zeewell on X (tweet 2116404121930432888): relays serve one model under
ids of their own (deepseek-v4.1-flash-1017, grok-4.6@500k). They want to
give each one their own id at the provider layer. magpie then lists,
routes, groups and finds groups by that id, and the upstream request
still carries the vendor's id.

Choice: a new per-model map, settings' ModelIDs
("<pid>/<local>": "<own id>"), served through the wire names that
already exist. ModelSameAs was not widened. It means "same as another
vendor's model": it lends specs and joins found groups. Making it rename
models everywhere would change every existing user's ids and refs.
ModelWires was not reinterpreted either, for the same reason. ModelIDs is
ModelWires turned round: a wire keeps magpie's id and changes the one
sent, and this keeps the one sent and changes magpie's. Settings.Wires()
merges each entry in as a wire name (wrapped by a "<pid>/*" wire). Every
place that sent a ModelWires name (gateway, usage ledger, request page,
UpstreamName, UpstreamNameAs) reads Wires(), so the upstream id needs no
new path. An explicit ModelWires entry for the same id wins.

- Listed by the local id: Available, liveIDs/liveByID, Serving and
  ListPrice translate through OwnModelID. /v1/models, agents' lists,
  Resolve, routing groups and found groups (auto/<local>, merged with
  every other provider serving that id) all see the local id.
- Only a provider of the user's own (Account == nil) takes one. An
  account's or a plugin's request is built from its list's id, which no
  wire reaches.
- Two variants of one provider given one id: the latest given it wins,
  and the earlier one is listed by its own id again. The CLI names it.
  The editor refuses two rows given one id in one save. A model of the
  provider's own id that a variant is listed by (plain grok-4.6 beside
  grok-4.6@500k) is not listed while the variant has it.
- The user's values are never overridden. SetModelID moves picks,
  contexts, fallbacks, groups' members/rules/fast/placed/off/weights/
  classifier/pick, the pickers' lists, every per-model setting
  (Settings.MoveModel) and gateway keys' models (provider.ModelMoved,
  set by access) to the new id, but only where nothing is under the new
  id yet. Agents' own files are not rewritten: an old provider/<own id>
  still resolves and is sent as it is. Group match patterns and key
  patterns stay as written.
- Key limits: a key held to either id passes for both (modelAllowed:
  the ref, OwnModelID, ListedModelID). Group members use the same check.
- Usage: model = the listed id, served = the vendor's id from its reply.
  The price is the own id's first.

CLI: magpie model id <provider/model> [<id>|--reset], magpie model ids.
GUI: Providers > a provider's editor > Names & levels > "Listed as",
beside Same as. It is staged with the editor's Save and taken back by
Restore default, in zh, zh-TW, ja and de. Accounts have no box.
Docs: providers-accounts.md, gateway-routing.md, and site start.html in
en, zh and ja.

Run (mote-run, at this tree rebased on 841326709):
- go test -tags nogui of internal/gateway, provider, settings, access,
  usage and cli: ok. internal/gui: ok but for
  TestSettingsSaveKeepsWhatItDoesNotSend's SearchAll, red on main since
  b09349d17 (#4514, yiqiui's patch); its ModelIDs case passes.
- TestAutoVisionDoesNotBuildListsAgain: 457 allocations with 4 models,
  458 with 400 (main 459), searcherModel within its 50. Reading
  Shared() per list cost 3041; SharedModelIDs parses only modelIDs once
  per file change, the settings path is built again only when what it is
  built from changes, and Serving looks up the own id only when a key is
  listed to some model.
- TestCoreScriptBudget: raised by 1,178 bytes for the Listed as box,
  with a note.
- gofmt -l clean; go vet, GOOS=linux and GOOS=windows go vet ok.
- GUI: provider-listed-as (en, zh, zh-TW, ja, de), provider-same-as,
  provider-detect in Chromium on mote and WebKit on the Linux box (mote's
  WebKit launch hangs, #4125): 9 of 9.
Broken by hand, each red: the wire name (wires), the list (list), a key
held to the own id (keyown), the key move hook (hook), liveIDs, liveByID,
moving refs (moverefs) and moving per-model settings (movemodel).
Not tried: a red for ListPrice's or Serving's own-id lookup; a real relay
with variant ids; Match patterns are not rewritten to the new id. The
full Go suite and the whole GUI suite are still running and their reds
get their own issues.
2026-10-31 15:04:44 +08:00