Commit Graph
352 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 059d995d56 gateway keys: the list reads the ledger once for all keys, and a proxy's web page is said by its title (aiandcloud on X)
aiandcloud (2.98B tokens, 12,654 requests a day, server mode behind a
proxy) saw Gateway keys draw a Cloudflare 524 page as raw HTML.

Slow list: every poll of /api/caller-keys read up to a month of ledger
rows once per window per key. budget.AllOf now reads each distinct window
once for all keys, and keeps the settled blocks' sums with a cursor
(usage.VisitFrom), so a poll only reads what was appended since; the
unfinished tail block is always read again. A rewritten or shorter log
resets the cursor. All(k) is AllOf of one key.
Numbers (BenchmarkAll vs BenchmarkReadEach, 8 keys x day/week/month,
31 days x 12000 rows/day = 372k rows, warm): 211-228 ms before, 23.5 ms
after.

Raw HTML: fail() now turns an error string holding a web page (a remote
magpie's or a vendor's 524/502 page inside the JSON error) into a short
said/what pair, "A proxy in front of magpie answered, not magpie ({what})"
with the page's title, translated in all 5 languages (key already in
i18n.js). The browser already handled non-JSON bodies (notJSON, #2032).

Run (Windows box, mote ssh was down earlier): go test budget, usage, gui
(AllOf, Budget, FailSays, I18n, Keys); gateway-keys-proxy-page and
gateway-key-limit GUI files in chromium and webkit, 5 languages: 24/24;
gofmt; vet windows, linux nogui, darwin (mote, only a clang deprecation
warning). Broken by hand: with the old fail() TestFailSaysAProxyPageByItsTitle
is red; with VisitFrom's reset() removed TestAllOfIsWhatEachWindowRead is red.
Not tried: a user-scale cold ledger, a server behind a real Cloudflare,
the full suite before the tag (started after).
2026-11-11 13:00:54 +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 89f66966d9 release builds: the UI's files are packed into one zip, ~5.7 MB off each binary (@ZhangXiaof48473 on X)
The Windows and Linux downloads (and the CLI builds) are the raw binary, so
what is embedded counts in full. 8.2 MB of the 12 MB under internal/gui/assets
is scripts, styles and svgs. `make assets-pack` (build/assetpack) writes them
to internal/gui/assets.zip (deflate; png/jpg/webm stored), and the release
targets and `make app` build with -tags packedassets, which embeds that zip
instead of the tree (assets_packed.go: a file is unpacked once, on first use,
and served seekable with no modification time, as an embedded one is). Plain
`go build`, `make build`, `make cli` and every test still embed the tree.
The zip is git-ignored and made before every release build.

Sizes (go build -trimpath -ldflags="-s -w", on mote, at e430e2750):
  linux/amd64 nogui   73,203,874 -> 67,502,242  (-5,701,632)
  windows/amd64 app   88,401,408 -> 82,755,584  (-5,645,824)
The macOS zip/dmg compress the binary already, so they gain nothing.

Run: assetpack, then `go test -tags packedassets -run TestPacked ./internal/gui`
(passes: every file byte for byte and no other; / and a range of the webm served;
no Last-Modified). The first try failed it with "packed has 0 files, the tree
301" (zip entries lacked the assets/ prefix), so it does go red on a bad pack.
go vet ./internal/gui on darwin, linux nogui, windows and -tags packedassets:
clean. gofmt clean.

Not run: the full suite and the GUI suite (default builds embed the tree as
before; api.go only lost the embed line), a real release through
magpie-releases (its release.yml calls these make targets), the Linux GTK
build (cgo).
2026-11-11 10:28:05 +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 e053c337aa gateway: join a shared magpie with a password (EV_John_Liu on X)
EV_John_Liu asked for quick setup on a LAN: the central magpie serves a
page behind a password where other PCs and Macs get their config and a
new key of their own.

Settings -> Network and sharing -> Join with a password sets the
password (at least 8 characters; only a salted PBKDF2-SHA256 hash is
kept, in join.json, 0600, written through temp-and-rename; a file that
can't be read or parsed means joining is closed). The row then shows the
address to give out, <shared address>/join, and Turn off joining.

/join is the key page (/me) opened to join: the visitor types a name for
the computer and the password. POST /v1/magpie/join makes a gateway key
named after that computer (or "Joined from <ip>"). The key is listed in
Gateway keys like any other, where it can be limited or removed. The
page shows the key once and then the setup for that key: Claude Code,
Codex, a new magpie tab (`magpie provider add remote-magpie '<key>'
url='<address>'`), OpenAI-compatible and curl.

Every route judged:
- lanGuard lets another machine reach GET /join and the join route
  without a key, only while magpie is shared. The route checks the
  password itself.
- A browser's POST must come from the page itself. Host must be one of
  this computer's own names (IP, localhost, MAGPIE_PUBLIC_URL's, its
  hostname), so a DNS-rebound name is refused. Origin must equal Host.
  Missing Origin and Origin "null" are refused, and so is any
  Sec-Fetch-Site but same-origin. corsGuard still refuses null, foreign
  and *.localhost Origins before this. curl and scripts, which send no
  browser marks, are judged on the password alone.
- Throttle: each try from another machine costs a token, a right
  password too. The bucket holds 10 and refills one every 10s, so a
  guesser gets about 360 tries an hour, and a flood of tries makes no
  flood of keys. Over the limit the route answers 429 with Retry-After.
- The password and key never go in a URL or a log line. The key comes
  back only in a no-store 201 body. Logs name the key's id and the
  caller's address.
- The routes are classed in the key-slot and read-only route lists.
  They carry no key.

Run on mote at this head (rebased on 065ca02c2):
- gofmt clean
- go vet: darwin, linux -tags nogui and windows, for access, gateway
  and gui
- go test: access, gui, and gateway's join, route-list, key page and
  LAN tests
- The whole gateway package ran before the rebase, and its only reds
  were the two route-list guards fixed here.
- GUI (node --test), chromium and webkit: lan-join (new), key-page,
  mtls-settings, allow-ips, i18n-keys, lan-docker, lan-lazycat,
  lan-address-height, side-gateway-lan: all ok before the rebase, and
  lan-join, key-page and i18n-keys ok again at this head.
- That GUI run caught a TDZ error: JOINING was read before its const,
  which broke /me too. It is fixed in this commit, and key-page went
  from red to green.

Broken by hand (each red, then put back):
- no throttle: TestJoinHoldsAGuesser red
- no lanGuard bypass: TestJoinMakesARevocableKey, TestJoinHoldsAGuesser
  and TestJoinClosed red
- no ownHost check: TestJoinRefusesOtherPages red
- joinRefusal returning "": rebound remote, cross-site and no-Origin
  browser POSTs each got a 201, red
- Dropping only the Origin comparison stayed green, because corsGuard
  refuses the same Origins first.

Not tried:
- a real two-machine LAN join with the built app
- a Windows or Linux run of the tests (vet only)
- the full suite, which starts after the tag
2026-11-10 22:42:11 +08:00
yetone 10c4dc109a update: a restart by itself waits while magpie's window is in use (BESTLJP0412 on X)
With Restart automatically on, magpie restarted to update as soon as the
gateway was idle, even while the user was adding a provider or changing
settings in its own window, which closed what they were doing.

The page now tells the app it is in use: any pointerdown, keydown, input
or wheel posts /api/update/using (at most every 20s, and at once when a
dialog opens or closes, with whether #modal is open). inUseAt holds a
restart for 2 minutes after the last input (usingFor), or 15 minutes
while a dialog was open at the last input (openFor). waitFor skips the
restart while the window is in use, unless the restart was asked for
(the tray's Restart to update, Settings' Restart now), which still
restarts at once. A `magpie update` from a terminal (restartBeside) waits
the same way. The route writes nothing, so held doesn't drop caches for
it. /api/update says `using`, and Settings' Version row and the Update
pill add "waiting while you use magpie" (en, zh, zh-TW, ja, de).
docs/subsystems/gui-shell.md describes it.

Run (mote, at this head):
- go test -run 'AutoRestart|Wait|Idle|Restart|Using|EveryRoute|CoreScript|Budget'
  ./internal/gui/ ./internal/cli/: ok.
- go vet darwin, GOOS=linux -tags nogui, GOOS=windows for internal/gui
  and internal/cli: ok. gofmt -l: clean.
- GUI, chromium and webkit: update-using (new), every update-*.test.cjs
  and i18n-keys.
- TestCoreScriptBudget: fits with no raise. Main had 40 bytes left, so
  the update code's comments next to this change were cut to one line
  each (no code, every issue and reporter kept): 1,533,641 of 1,533,802.
- One webkit run of update-wait.test.cjs had a red subtest while mote
  needed 10 ssh tries (its output was cut by my grep, so not filed);
  update-wait passed 3 of 3 in webkit at this change and 3 of 3 on
  origin/main 016763f23.

Broken by hand (a separate worktree): waitFor's in-use check made `if
false && …`, restartBeside's !inUseAt dropped, and the page's listeners
given no events: TestAutoRestartWaitsWhileTheWindowIsUsed and
TestTerminalUpdateWaitsWhileTheWindowIsUsed went red, and update-using's
"a restart by itself waits while magpie is used" went red in chromium.

Not tried: the real app on any OS (only Playwright's engines and the Go
tests), WebKitGTK, and a real update downloaded and applied. A dialog
left open with no more input holds the restart for 15 minutes, then it
goes ahead; the wait still gives up after an hour (waitMost) as before.
2026-11-10 21:09:39 +08:00
yetone e8fbee60ea gui: pause the gateway without quitting magpie (me2seeks on X)
Disconnect and quit was the only way to stop the gateway, and it quits
magpie too. Pause does the same without the quit, from the tray's Pause
Gateway (Resume Gateway while paused), Settings › General › Gateway
(On/Paused, the app's only) and the Gateway page's Resume gateway, all
through POST /api/gateway/pause.

- Pause disconnects each connected agent as its row's Disconnect does
  (its own settings put back), keeps their ids in gateway-paused.json in
  the config folder, and stops the listener with requests in flight
  drained. An agent that can't be disconnected keeps the gateway serving,
  those before it connected again, and is named in the status line.
- While paused, serveGatewayLocked serves nothing: not the 15s watch, a
  port change nor a handover; a magpie started again stays paused. A
  pause file that can't be read counts as paused.
- Resume serves again and connects the agents the pause disconnected.
  A port held by something else keeps the pause and says what holds it.
  The Gateway page's Start/Restart, connecting an agent and picking one
  of magpie's models for it resume too.
- quitask's wired list and the pause share wiredOf.
- Strings in en, zh, zh-TW, ja, de. gui-shell.md documents it.

Run (mote was unreachable for the later runs; the Windows box instead):
- mote, before the rebase: go vet ./internal/gui; go test -run
  'TestGatewayPause|TestGatewayResumes|TestTray|TestGatewayFix|TestQuit'
  ./internal/gui: ok.
- at this tree on b46f23ffa: win-run go vet ./internal/gui ok; wsl-run
  go vet -tags nogui ./internal/gui ok; gofmt -l clean.
- win-run go test -count=1 ./internal/gui: the pause and tray tests ok;
  8 reds, each the same on origin/main d4b4a188e run alone on Windows
  and filed (#4115 %AppData% import rows, #5928 ~\ paths, #2107/#3649
  TestGatewayHeldByAContainer).
- wsl-run GUI (chromium + webkit): gateway-pause (5 languages x 1000/420),
  settings-general, gateway-takeover, i18n-keys, i18n-en-no-cjk: 51/52.
  The red is gateway-takeover webkit en's dark-mode case, red 1 of 2 on
  untouched origin/main too: #5942.
- rebased on 401187300: win-run go test -run 'Budget|TestGatewayPause|
  TestGatewayResumes|TestTray|TestQuit' ./internal/gui ok; wsl-run go vet
  -tags nogui ./internal/gui ok; gofmt clean. darwin vet not rerun after
  the rebase (mote refused SSH).

Broken by hand: serveGatewayLocked without its pausedNow check, and the
rollback's reconnect skipped: TestGatewayPauseAndResume ("served while
paused") and TestGatewayPauseRollsBack ("codex not connected again")
went red; green again restored.

Not tried: the real app's tray on a desktop, a real agent's config
round-trip (the Go tests fake the agents; Disconnect/connect are the
rows' own code), an agent wired from the CLI while the app is paused
(it doesn't resume), the whole GUI suite, the full Go suite (started after the tag).
2026-11-10 19:36:24 +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 b358677305 gui: open a server's magpie in a window of the app (xuanwo on X)
xuanwo runs magpie on a server and wants the desktop app to show that
magpie's routing and usage. Browser access in Settings › Network and
sharing goes the other way: it serves this app's page to a browser.

Settings › Network and sharing has a new section, Another magpie. It takes
an address and a key. You can paste the whole link the server printed
(`magpie daemon install --web`, `magpie web`, or another app's Browser
access), and its k= becomes the key. The app then opens that magpie's own
web page in a window of its own. The window signs in through the server's
own webGuard with ?k=, the same way a browser does, and is traded for its
cookie. Nothing new is served here: the page in the window talks to the
server alone and gets no bound calls from this app.

- remoteAddr:
  - https:// is used when no scheme is typed.
  - Plain http is allowed only to an IP, localhost, a .local name or a
    one-word name, so the key never crosses the internet in the clear.
    This is also the rule a Mac's webview applies.
  - userinfo and other schemes are refused.
- remoteProbe: before the window opens, it asks for the link without
  following redirects. Only a 303 that sets a magpie_web_* cookie counts
  as success. A 401, a 403 (allowed addresses), an untrusted certificate,
  no answer, or any other reply is reported in Settings, translated.
- remote-magpie.json:
  - It sits beside settings.json, mode 0600, and the key is never in
    settings.json.
  - GET /api/remote returns the address and hasKey, never the key.
  - POST with no key reuses the key kept for the same address.
  - POST /api/remote/forget removes the file.
- The routes are on the app's own windows' API only (!isWeb). A host that
  can't open windows refuses.

Run (on mote, at this tree):
- go test -count=1 ./internal/gui/: ok.
- Go tests:
  - TestRemoteAddr
  - TestRemoteOpensTheOtherMagpie: real webHandler; wrong or missing key
    refused, nothing kept; the pasted link opens; 0600; the key is not
    returned; a cookie-jar client following the opened link reaches the
    page behind the key; the kept key is reused; forget.
  - TestRemoteNotMagpie
  - TestRemoteNotOnBrowserPages
- GUI test, new: another-magpie.test.cjs. Covers 5 languages, 360px,
  and a browser page with no section that never asks /api/remote.
- GUI suite: every GUI file that draws Settings › Network (18, the new one included), plus
  i18n-keys, i18n-en-no-cjk and gui-de/ja/zh-tw. Chromium and WebKit:
  307/307 pass. Also remote-magpie.test.cjs (the Remote magpie
  provider's add sheet), run with the new file at the rebased head.
- gofmt -l: clean.
- go vet: darwin, GOOS=linux -tags nogui, and GOOS=windows on
  internal/gui; ok.

Broken by hand:
- A 303 without the magpie cookie taken as signed in:
  TestRemoteNotMagpie red.
- remoteRoutes outside !isWeb: TestRemoteNotOnBrowserPages red (200).
- renderRemote drawn on a browser's page, and errors not translated:
  another-magpie.test.cjs red in zh/zh-TW/ja/de and the browser case,
  in both engines.

Not tried:
- The real Wails window on macOS, Windows or Linux.
- A real server over https.
- Links on the remote page that open a new window (target=_blank,
  window.open) inside the remote window.
- Settings › Text size does not rezoom a remote window that is already
  open.
2026-11-10 18:39:20 +08:00
yetone 40ca0c88de gui: a model's price is set from the Usage page (soilzhu80 on X)
A model an agent runs is often in no provider's list, so no provider's
Model settings could price it. A model's row on the Usage page (its "…"
or a right-click) and its bar in the Sessions tab's Models card (a
right-click) now offer "Set price…": a sheet with input, output, cache
read and cache write in $ / 1M tokens, the maker's list price greyed in
the empty boxes. It sets the model's price from any provider (*/model),
the key `magpie model price '*/model'` writes, through GET/POST
/api/model-price (modelprice.go). A provider's own price for the model
still comes first. Restore default takes the price away. Sessions' stats
are forgotten on a save, so past calls are counted at the new price too.
A Sessions bar prices the id after its last "/", the id sessions'
priceOf looks up.

Run (mote): go test -run ModelPrice ./internal/gui; node --test
usage-model-price (chromium + webkit, 420px wide, en/zh/zh-TW/ja/de),
usage-clear (its menu now has Set price… above Clear usage…),
i18n-keys; gofmt -l; go vet ./... for darwin, linux -tags nogui and
windows.
Broken by hand: SetModelPrice skipped, TestModelPriceFromAnyProvider red
("set: 200 {Price:<nil>}"); Set price… taken out of the row menu,
usage-model-price red.
Not tried: a real gateway call priced after setting it in the real app.
2026-11-10 17:45:42 +08:00
yetone 720200092e agent: turn off an agent's own telemetry from its settings (OipsAnthony on X)
An agent with a documented telemetry switch has a Telemetry row in its
Settings on the Agents page (opened row and settings sheet). Off writes
that switch into the agent's own config the way magpie writes it already:

- Codex: [analytics] enabled = false in config.toml (feedback left alone)
- Claude Code: env DISABLE_TELEMETRY and DISABLE_ERROR_REPORTING = "1"
- Gemini CLI, Qwen Code: privacy.usageStatisticsEnabled = false

Nothing is written until the user turns it off. Off writes only keys the
file lacks and records them in the stash; a key the user set on refuses
Off and names it; one they set off stays, and the row says so. On takes
out only the keys magpie wrote that still hold magpie's value. An
unreadable config is unknown: the row says so and can't be pressed.
Agent.Telemetry is not a Field, so profiles never carry it and Unwire
leaves it. Only agents on this computer (no WSL distro, #3896).
POST /api/agents/telemetry/{id}; strings in zh, zh-TW, ja, de.

The row is paid for in the core budget with sixteen Agents-page comments
cut in app.js (core 1,532,840 of 1,533,802 after the rebase), no raise.

Run (mote, at this head on origin/main 1ad9d157f; vet, the three packages and agent-telemetry, i18n-keys, agent-details-ready, click-scroll again there, 98 of 98):
- go test -run Telemetry ./internal/agent, then go test -count=1
  ./internal/agent ./internal/gui ./internal/cli: ok
- go vet ./..., GOOS=linux -tags nogui, GOOS=windows: ok; gofmt clean
- GUI, chromium and webkit: agent-telemetry (34 pass: every language at
  1100 and 640px, no scroll on click, no select, the user's own off,
  a refusal, the sheet), and 104 agent-*, i18n-*, click-scroll,
  settings-search, panel-agent and agent-settings files: reds only in
  page-width-steady and mobile-web (red the same at origin/main
  5a347ca8c, #5013, #4541) and agent-compact once under concurrency 6
  (passes alone, 8 of 8; #5607; its fixture has no telemetry)
- internal/cli failed once in the first run with its name lost to a
  tail of mine; it passed on a rerun at this head and at origin/main

Broken by hand: skipping the user-on check, dropping the "still ours"
check before a delete, and removing the WSL gate each turned
TestCodexTelemetryLeavesTheUsers, TestClaudeTelemetryChangedSince,
TestUsageStatsTelemetrySwitch and TestTelemetryOnlyHere red. The tests
don't compile on the old code (no Agent.Telemetry).

Not tried: real Codex, Claude Code, Gemini CLI or Qwen Code reading the
written keys (the keys come from their source); Crush (left for later),
OpenCode (no switch); WSL agents; the whole GUI suite (the agent-*,
i18n and agent-settings files only); the full go suite runs after the tag.
2026-11-10 17:28:15 +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 bb4dd86790 appdir: magpie's files and cache move to another disk, a link left where they were (CHENGJIAHEGOXIS and buhaodeshiyehao on X)
CHENGJIAHEGOXIS asked to keep magpie's data and cache on an external SSD
instead of the Mac's own disk. buhaodeshiyehao asked to keep magpie's
personal data on another disk. Settings › Sync now has a Data folder row.
It shows where magpie's files are, with Show, Move… and Move back.
`magpie data` does the same from a terminal.

- What moves: appdir.Config() and Cache() only, into <picked>/magpie/config
  and /cache. The agents' own folders and session histories stay where
  each agent reads them. A link is left at each old path, so every path
  the agents were given still works. On Windows, when symlinks need a
  privilege (#973), the link is a junction; library's junction code moved
  into appdir for this.
- Never under a running magpie. Move… explains first in the app's own
  dialog, then asks for the move (move-to.json). The app restarts itself
  through the update path's relaunch and quits, and the new process makes
  the move in cli.Main before it reads anything, once. A failed move is
  kept in move-result.json and shown under the row. When another magpie
  serves the gateway, or for magpie web, the app doesn't restart, and the
  row says the move waits, with Cancel.
- Refused before anything quits: a relative or missing folder, a
  magpie folder there with files in it, or a folder inside magpie's own.
- One disk: a rename. Across disks: a copy. The old folder is put aside
  until the link is made, and a failed copy leaves everything as it was.
- Disk unplugged: magpie stops with an error (and a native alert from the
  app, as #989) instead of starting empty and writing over the link.
- Usage history in auto backups is left for a follow-up: auto backups are
  plain JSON kept 7 times, and usage is large and synced separately.

Docs: sync-backup.md has a "Data folder on another disk" section, and
docs/start's #data-folder (en, zh, ja) describes Move….

Run (mote, at this tree on 0791c91c5):
- gofmt -l: clean
- go vet: darwin, linux -tags nogui and windows, for appdir, cli, gui and
  library: ok
- go test -count=1 ./internal/appdir ./internal/cli ./internal/library
  ./internal/gui: ok. cli was red first, on TestEveryRouteHasACommandOrIsNamed;
  the routes are now mapped to magpie data.
- Windows (xiaomi-gpu): appdir's Move tests, including TestMoveByJunction
  with symlink forced to fail with ERROR_PRIVILEGE_NOT_HELD, and
  TestDataFolderMoveRestarts: ok. TestFoldersJoinedOnce is red there,
  which is #4846 (appdir.go is untouched).
- GUI, chromium + webkit: data-folder (5 languages x 1100/420px),
  auto-backup, sync-*, settings-sections, segs-press-redraw, old-webkit,
  github-sync, s3-sync, skill-how, usage-computers,
  webdav-settings-refresh, i18n-keys and i18n-en-no-cjk: ok except
  phone-no-sideways de 375 (#5869) and s3-sync webkit en (#3413/#5872,
  red 3 of 3 on this tree too), both already red on main.
- Linux (WSL magpie-desktop): appdir -run Move and
  TestDataFolderMoveRestarts (nogui): ok.

Again after rebasing on 0a44c1c84 (mote): gofmt, the three vets, go test
./internal/appdir ./internal/cli ./internal/gui, and the GUI files
data-folder, i18n-keys, i18n-en-no-cjk, auto-backup and settings-sections
in both engines (60 of 60): ok. Pushed on 5426c43cc, which touches only
the gateway's dsh_compact and the routing plugin, none of these files.

Broken by hand (each went red):
- no removal of a half copy: TestMoveCopyFailsLeavesAll "a half copy
  is left on the disk"
- no Unreachable check for a gone disk: TestMovedDiskGoneIsUnreachable
- restarting with another magpie serving: TestDataFolderMoveRestarts
  "2 restarts"

Not tried: a real app restart making a real move on a real external disk
(the restart is the update path's relaunch, faked in the test); a real
unplug.
2026-11-10 13:46:13 +08:00
yetone 5e6fb27702 perf(gui): the page's mime types are added when a page is served, not at launch
gui's init called mime.AddExtensionType, and the mime package reads and
parses the system's whole type table (/etc/apache2/mime.types on macOS,
/etc/mime.types on Linux) the first time anything asks it. So every
launch, `magpie statusline` on each Claude Code message included, paid
~18,000 allocations for a table only a served page uses. Handler now
adds the types once (sync.OnceFunc) before it builds the mux.

TestAssetTypesHoldAgainstTheRegistry now sets each type wrong first and
asks Handler to set it right. The old form passed with the call removed
on both mote and the Windows box (both tables already agree), so it
guarded nothing; with the call removed the new one is red on mote
(.css, .js, .html, .svg, .png served as application/x-other).

Measured on mote, sandbox HOME, t43 (v0.1.3517) against t44 (this):
- GODEBUG=inittrace=1 sum: 4.63 MB / 46,795 allocs -> 3.94 MB / 28,742
- `magpie statusline`, 3 runs: instructions retired ~177M -> ~156M,
  peak footprint 16.4-17.0 MB -> 16.1-16.3 MB

Run: go vet ./internal/gui (darwin, GOOS=windows) ok; go test
./internal/gui ok (130s); root go vet ./... after rebase below.
2026-11-10 13:02:57 +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 0549e5301a masking: Send requests unmasked is found from Settings › Privacy and holds on every route (CrazyMouse_TT on X)
CrazyMouse_TT runs a model of their own and wanted masking off for it.
The switch already existed (the provider editor's Advanced › Send requests
unmasked, provider.Unredacted), but nothing near masking pointed to it,
and it held only on chat-shaped routes.

- Settings › Privacy has a "Sent unmasked" row: each provider set so is a
  button that opens its editor with Advanced open; with none, the row says
  where the switch is (settingsJSON.UnmaskedProviders, redact plugin's
  unmaskedRow).
- Images (draw.go), videos (video.go) and Ark's own API (native.go) go as
  written when every model they may go to is such a provider
  (unmaskedMembers); a group with one member left on stays masked, as a
  chat's route does (unredactedRoute).
- A Remote magpie may be set so too (SkipsRedaction no longer refuses
  it): it is sent the request as written with no X-Magpie-Masked-As, so
  it masks by its own Settings and switches, once, before any vendor
  (1d6d263ee's hop). Left off, it is masked here, as before. The editor
  says so for a remote magpie.
- Default stays off for every provider: nothing changes for anyone who
  hasn't ticked it.

app.js stays under TestCoreScriptBudget by a shorter unmaskRow call and
three trimmed comments (app.js -51 bytes vs base).

Run (mote, at this tree): gofmt -l clean; go vet darwin, GOOS=linux
-tags nogui, GOOS=windows clean; go test -count=1 ./internal/gateway
./internal/provider ./internal/cli ./internal/masking ./internal/gui ok.
GUI (chromium + webkit, 5 languages, 1100/440px):
provider-unmasked, unmasked-providers, i18n-keys, i18n-en-no-cjk,
redact-route: 126 pass, 0 fail. masking-records.test.cjs is red the same
on origin/main 9430c5309 (#5830).

Broken by hand: SkipsRedaction refusing a remote magpie again made
TestUnredactedRemoteMagpieMasksOnItsOwnSide red; images/videos/Ark
ignoring the switch made TestUnredactedProviderDrawsWhole,
...MakesVideosWhole and ...ArkNativeWhole red; dropping
unmaskedProviders made unmasked-providers.test.cjs red.

Not tried: Windows (win-run), and a real two-machine magpie hop; the hop
is tested with two in-process gateways and a tap between them.
2026-11-10 10:03:49 +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 e364d27fce agent, provider, profile: a state poll builds no agents per profile, keys dsh entries without joining them, and works out renames once a change
What /api/state still allocated with real accounts, forty polls on mote
(t29, 76 and 83 MB):

- profile.Details built every agent again for each profile listed
  (7 MB). DetailsIn takes the agents the page already holds for its
  request; Details keeps its signature for other callers.
- dshNodeShared joined an entry's lines into a string to key its parsed
  node (5.7 MB). It now hashes the lines with maphash and checks them
  against its own copy, so a hit allocates nothing; a caller changing
  its slice in place still gets the new text.
- dsh's Joined check read and parsed the first profile's list each poll
  (5.2 MB). It uses dshLook, the parse shared until the file changes;
  dshOver only changes a copy of the items.
- provider.UsageRenames parsed the whole providers.json for each
  profile's in-use check (5.1 MB). It is worked out through filememo
  once per change; a file that doesn't decode goes through read's own
  last-good path as before.

Measured on mote, sandbox HOME with the owner's real account data, 5
warm-up then 40 calls, paired runs:
  /api/state  t29 82.9 / 76.0 MB  ->  t30 38.1 / 47.4 MB  (-46%)
  /api/drift  t29 7.3 / 5.5 MB    ->  t30 9.7 / 7.1 MB (512 kB sampling
              noise: no dsh or renames frame in either top list)

Tests:
- TestUsageRenamesParsedOnceAChange: 60 providers, a look at unchanged
  renames allocates at most 10 times, a rename since shows at once.
  Red on the old rename.go (424 allocations).
- TestDshLookParsesAnEntryOnce now asks dshNodeShared alone for 0
  allocations and checks a slice changed in place. Red on the old
  dsh.go (1 allocation).

Run on mote at this tree: gofmt -l clean; go vet of agent, provider,
profile, gui; go test -count=1 of internal/agent (390s), provider
(256s), profile, gui (174s) and usage: all ok.
Not run: the full ./... suite and the GUI (JS) suite; no JS changed.
2026-11-10 07:36:19 +08:00
yetone 16a2dfac9c lan: a LazyCat app offers the box's LAN address, or says how to forward the port
mtoolstec on X (after v0.1.3432) runs magpie from the magpie-lzcapp
package on a LazyCat box. Settings -> Share on local network offered
https://magpie.<box>.heiyu.space/v1, which only devices with LazyCat's
client reach, and http://172.28.3.65:3425/v1, the container bridge,
named "Other containers on this host", which nothing off the box
reaches. Other devices on his LAN wanted http://192.168.0.100:3425/v1.
The package runs magpie on the app's bridge network, and LazyCat
publishes an app's ports only on heiyu.space, not on the box's LAN
address. Its env names the app's domain, never the box's LAN IP.

- On the box's own network (network_mode: host, as LazyCat's Emby, Lucky
  and LAN Sheriff run), magpie now finds the box's LAN addresses. It sees
  the box's bridges/veths, or host.lzcapp is one of its own addresses, and
  takes the IPv4 of the default route's interface, minus host.lzcapp.
  LANURLs lists them first and the app domain after. A MAGPIE_PUBLIC_URL
  of the user's own (not the domain) stays first, and a pinned
  MAGPIE_ADDR still serves only that address. The sidebar names the box
  address, not the domain.
- On a bridge network that address can't be known. The domain is listed
  alone, named "LazyCat client", and the container-bridge address is no
  longer offered under LazyCat (ContainerHostURL ""). The row under the
  address, in Settings and on the Gateway page, says to forward the port
  with LazyCat's "LAN port forwarding" app (局域网端口转发工具). The CLI
  banner (serve, web) says the same.
- New settings/gateway fields: lanLazyCat, lanLazyCatBox; lazyCat,
  lazyCatBox (and boot.js's sideGateway). Strings are in zh, zh-TW, ja
  and de.
- host.lzcapp is looked up only under LAZYCAT_APP_DOMAIN, with a 2s
  timeout and no lock held. An answer is kept; a failure is retried after
  a minute.

Package side: the magpie-lzcapp package (lazycat-contrib, czyt) needs
network_mode: host plus host.lzcapp upstreams and the net.* permissions,
or its usage needs the port-forward steps. An issue is filed there.

Run (mote, macOS, at this tree on origin/main ce6ae593c; then rebased
onto ab084fdf2; api.go, providers.go and i18n.js changed there too and
merged clean):
- gofmt -l: clean. go vet: darwin for gateway/gui/cli; CGO_ENABLED=0
  GOOS=linux -tags nogui ./... and GOOS=windows ./...: ok.
- go test -timeout 45m ./...: ok (before the string reword; after it,
  internal/cli and internal/gateway again: ok).
- wsl-run (Ubuntu 24.04): the LazyCat/default-route/LAN tests in
  internal/gateway and internal/cli: ok.
- GUI: lan-lazycat (new: 2 engines x 5 languages x 1100/420px, 20 tests),
  i18n-keys, i18n-en-no-cjk, gui-de/ja/zh-tw, lan-docker and
  side-gateway-lan: 85 pass, 0 fail. A wider set (lan-*, gateway-*, connect-*,
  key-page, sidebar, phone-*, remote-magpie and others; 835 tests) was
  run before the reword. Its reds were the i18n placeholder check
  (fixed: no <box IP> in the string), and phone-connect-menu 420 (#4706,
  #4707) and remote-magpie (#4398). Those last two are red the same alone
  on origin/main b03a37476 on mote.
- Real Linux containers (Docker on xiaomi-gpu), with a test binary
  printing what the real functions find. LAZYCAT_APP_DOMAIN was set and
  host.lzcapp added as host-gateway.
  - bridge: ifaces [lo eth0], LANURLs [https://magpie.snyht3.heiyu.space],
    ContainerHostURL "".
  - --network host: ifaces [lo services1 eth0 docker0], defaultIfaces
    [eth0], LANURLs [http://192.168.65.3:3425 https://magpie...],
    ContainerHostURL "".
- Broken by hand: LANURLs without the box branch and ContainerHostURL
  without the LazyCat check turn TestLazyCatOffersTheBoxAddress red (6
  failures). The old settings.js turns lan-lazycat red (10 of 10,
  chromium).

Not tried: no LazyCat box is at hand. Not checked on a real box: lzcos's
interface names on the host network, where host.lzcapp points in host
mode, and which interface holds the default route.

At the rebased head: gofmt clean; go vet of internal/gui, gateway and
cli; their Budget/LazyCat/LAN/Container/PublicURL/Parity tests ok; GUI
lan-lazycat, i18n-keys, i18n-en-no-cjk, lan-docker, side-gateway-lan:
76 pass, 0 fail.
2026-11-10 07:34:29 +08:00
yetone e99993fcac gui, provider: a page builds the agents once a request, and preset hosts are gathered once
The Providers page built agent.All for Detected beside the one
accountLabel looks names up in (provider.Held), and the state built it
twice (Clients, Detected). They now share the request's held list
(heldAgents; agent.DetectedIn, agent.ClientsIn), as /api/drift does.
notProbed gathered every vendor and local preset's bases for each
provider of each poll; it now asks a set made once (presetHosts).

Run on mote (darwin): go vet and go test of internal/agent, internal/gui
and internal/provider: agent and gui ok; provider red only in
TestMoveToPlugin's TempDir cleanup (#5524, passes alone).
TestNotProbedSetMatchesThePresets: broken by hand (set rebuilt per
ask) it measured 44 allocations an ask, red; 0 restored.
2026-11-10 07:18:50 +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 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 9451ad59f1 gateway: MAGPIE_PUBLIC_URL at a private address is the local network's, the Docker bridge's other containers', alike in Connect's menu
jiezhengj (Discord) runs magpie in Docker on a NAS, MAGPIE_PUBLIC_URL at
the NAS's own 192.168.31.218. The web UI's Gateway list called that
address "Public address" (公网地址), which reads as the internet's, and
Connect's Base URL menu offered 本机 / 公网地址 / 局域网, where 局域网 was
really the Docker bridge's 172.17.0.1 that other containers on the host
use, while the list above it named that one "Other containers on this
host".

The classification itself was right (gateway.PublicIP never takes
RFC 1918, CGNAT or ULA for the internet); the labels weren't: any
MAGPIE_PUBLIC_URL was "Public address", and Connect's menu had its own
three-way rule that knew nothing of the bridge or of internet addresses.

- gateway.URLKind(u): "internet" (PublicIP), "local" (any other IP
  literal) or "" (a name, not looked up). /api/settings and
  /api/providers' gateway carry it as publicKind beside publicURL.
- settings.js addrWho(g, u, others) is the one rule: this computer;
  the bridge address as other containers'; an internet address as such;
  MAGPIE_PUBLIC_URL by its kind (private: Local network; a name: Public
  address); anything else Local network. The Gateway list (each label
  said once for the lines it heads; local, then other containers, then
  internet), Connect's Base URL menu and About's MAGPIE_PUBLIC_URL row
  all use it.
- "Public address" now only names a MAGPIE_PUBLIC_URL that is a host
  name; zh 公网地址 → 对外地址, zh-TW 公開位址 → 對外位址 (ja/de already
  neutral enough: 公開アドレス, Öffentliche Adresse). No new strings.

Run, on mote (sandbox HOME, Go 1.26.8):
- go test -run 'URLKind|PublicURL|LAN|Container|DefaultGateway|HostNetwork'
  ./internal/gateway ./internal/gui: ok, at 2dac9b84e and again at this
  rebased head on 6b7ee4a98
  (then rebased onto a7113d5c9, which shares no file with this, and
  not run again).
- GUI, chromium and webkit, 18 files (allow-ips, api-key-theme,
  connect-snippet-shell, gateway-card, gateway-connect-keys,
  gateway-caller-keys, connect-address-kept, gateway-keys-off,
  lan-public, lan-docker, phone-connect-menu, public-url,
  public-url-default, side-gateway-lan, key-page, statusline-remote,
  i18n-keys, i18n-en-no-cjk): chromium 152/156, webkit 153/156. Every
  red is red at base 2dac9b84e too and filed: i18n-keys "a plugin's
  words are its own" (#5332, #5327, #5482, #5426), phone-connect-menu
  420 public / no public URL (#4706, #4707), gateway-caller-keys
  chromium en (#3797, passed at base this time).
- Again at this rebased head: lan-docker, public-url-default,
  public-url, lan-public in both engines, 86/86.
- gofmt -l clean; go vet darwin (gateway, gui, cli),
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: ok.
- Full go test -tags nogui -timeout 45m ./... through suite.lock was
  still running at push (the owner's rule: no verified commit waits on
  the queue); a red it shows gets its own issue.

Broken by hand: TestPublicURLSaysItsKind on the old source fails
"publicKind <nil>, want local" (and want internet); the new lan-docker
test with the old JS fails 'Public address' vs 'Local network' and
'公网地址' vs '局域网' (chromium en, zh).

Not tried:
- a real Docker container or NAS; the cases are fixtures.
- magpie web's and the share banner's CLI lines still say "network" for
  every address, internet ones too; left alone.
- an in-container page opened at a public IP the host derived (not in
  lanPublic, not MAGPIE_PUBLIC_URL) is still labelled Local network.
- ja/de "Public address" wording kept.

Reported-by: jiezhengj on Discord
2026-11-08 02:13:14 +08:00
yetone c8eb7b3877 search: a search API's keys are a list, each switched off, moved and removed on its own
Web search took one key per API in one field (辰林鸭~ on Discord: only one
Tavily key). Settings › Models › Web search now lists an API's keys under
it as a provider's accounts are: each masked on its own row with a tick
(off / on), Show, Copy and Remove; several pasted at once (commas,
semicolons, lines), the reply saying how many were new and how many it
had; the order changed by dragging or Alt+↑/↓. A resting key says why and
until when on its row ("asked last until 14:05: rate limited"), from the
gateway's rest (SearchKeyRest, SearchQuota.Ref); rotation on 401/403,
402/432/433 and 429 (#1477) is unchanged.

provider.SearchAPI keeps Key as the keys on, comma-joined, so the gateway
and an older magpie never ask one switched off; keyList is written only
while a key is off. A Key that differs from the list (an older magpie, a
sync) wins, its keys on in its order, the list's off keys after. The last
key on can't be switched off or removed. The GUI names a key by
SearchKeyRef (a hash): POST /api/settings/search-keys (add, ref+on,
ref+remove, arrange) and /api/settings/search-key with ref. Saving an API
with no key keeps its keys, off ones too. Backup and WebDAV sync carry
the off keys, or leave them out with the rest. `magpie search` says
"+N off". docs/subsystems/gateway-routing.md has "The keys as a list".

Run (mote, at this tree, base 3441035a2):
- go test -count=1 ./internal/gui ./internal/provider ./internal/backup
  ./internal/davsync ./internal/cli: ok but gui's
  TestPanelHiddenByWailsMarksPageOutOfSight (#5322, mote, untouched) and
  cli's TestEveryRouteHasACommandOrIsNamed, then fixed (search-keys named
  S2) and run again: ok. ./internal/gateway search tests ok earlier.
- node --test search-key-list, search-keys, search-api, search-signs-in,
  search-order: 84/84, Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and
  420px (search-api/order at their own widths). i18n-keys: only "a
  plugin's words are its own" red, as on main (#5332, #5426, #5482).
- go build ./..., go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok. gofmt -l: clean.

Broken by hand, each red then restored:
- SetSearchAPI drops KeyList: provider and gui tests red.
- backup clears Key only / davsync merges Key only: their tests red.
- off keys still put in Key: provider, gui, backup and gateway red.
- the whole key in /api/state: TestSearchKeyListFromSettings red.
- no last-key-on check: TestSearchKeyList red.
- settings.js at HEAD: search-key-list.test.cjs red.

Not tried: a real Tavily account with several keys (the vendor is faked;
no test reaches the network); the real app window (the GUI ran in
Playwright only); Windows and Linux runs of the tests (vet only). The
full Go and GUI suites run after the push, under mote's suite lock.

Reported-by: 辰林鸭~ (Discord)
2026-11-07 21:21:48 +08:00
yetone 9ed0f1fa49 agents: Claude Code's prompt cache lifetime is picked in its settings
Linka (Discord) asked to set Claude Code's prompt cache TTL from magpie.
Until now only Usage › Context's "Tuned for you" card wrote it, and that
card offers nothing when the value is already the cheapest it found.

Claude Code's opened row and settings sheet now have two rows under its
own Long conversations: "Prompt cache · main conversation" and "Prompt
cache · subagents". Each opens the app menu with Claude Code's default,
5 min and 1 hour. They write the keys the card writes, promptCacheTtl and
subagentPromptCacheTtl in Claude Code's settings.json
(agent.ClaudeCacheSet, POST /api/settings/claude-cache). Default takes
the key out. A pick is the user's own: it forgets the card's stash, so
the card's Undo leaves it. A variable that comes before the setting
(FORCE_PROMPT_CACHING_5M, CLAUDE_CODE_PROMPT_CACHE_TTL,
CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL, in settings.json's env or
magpie's own) disables the row and names the variable, and the route
refuses it, so a value the user set by hand is never written over.

The names were checked in Claude Code 2.1.316's binary. Its resolver
checks FORCE_PROMPT_CACHING_5M, then the env var, then the setting
(enum "5m"/"1h"), then an agent's experimental.cacheTtl, then
ENABLE_PROMPT_CACHING_1H. With nothing set, the main conversation gets
1h on a subscription within its limits and subagents get 5m.

Run (mote, at this tree on 2ce44dc28):
- go test -count=1 -run 'TestClaudeCache|TestTune' ./internal/agent
  ./internal/gui: ok; go test ./internal/cli: ok (route parity).
- node --test claude-cache.test.cjs: 8/8 (Chromium and WebKit, en and
  zh, 900 and 420px), with agent-compact, i18n-*, gui-ja/zh-tw/de,
  old-webkit, agent-details-ready and context-tune: ok.
- Whole GUI suite on the Linux VM (wsl-run, concurrency 4), still
  running at commit: 74 files red there, mostly WebKitGTK. Of those
  only codex-memories-settings reaches Claude Code's settings: it
  counted Claude Code's rows as Long conversations alone, and now
  leaves out the two cache rows and checks they are there (18/18 on
  mote). desktop-subagent-model, account-eye, allow-ips and builtins
  pass alone on mote. codex-auto-reset (webkit de, #4790) and
  i18n-keys (#5327, #5332, #5426, #5482) fail the same way at
  origin/main f0620db63 on mote.
- go test ./internal/gui ./internal/agent ./internal/tune: agent and
  tune ok; gui red only in TestMainWindowCorners/macOS_26_SDK (#3949).
- gofmt -l: clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build ./...: ok.

Broken by hand:
- Without forget, TestClaudeCacheSet fails ("the pick is the user's,
  not the card's").
- Without the lock check, it fails ("set under
  CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL").
- With default leaving the key, TestClaudeCacheSet and
  TestClaudeCacheRoute fail.
- Without the rows in agentcompact.js, claude-cache.test.cjs fails 8/8.
  Without the same-pick check, it fails on the extra post.
- The first GUI run was red in WebKit at 420px: Playwright's own
  scroll to an off-screen button was taken as the page scrolling. The
  test now wheels the rows into sight as a reader does, and checks they
  came into view.

Not tried: a real Claude Code session reading the picked value (only
the settings.json it reads was checked); the live ~/.claude was never
touched.

Reported-by: Linka
2026-11-07 05:16:53 +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
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
yetone 4f624241f7 codex: the ChatGPT app left on "hit a snag" after an app-server restart is reopened when idle (#4550)
ysm119 on Discord: each Restart of Codex in magpie left the ChatGPT
desktop app on "ChatGPT 遇到了问题 / 请重试" till it was quit and opened
again. magpie ends the app's own app-server cleanly (code 0); a
signed-in ChatGPT 26.1021 then fails "Hosted AppServerManager identity
is not ready" on the one it starts, logs fatal_error_broadcasted and
shows the page. That is the app's bug; magpie now follows it up.

- provider/codex_app_crash.go: for 60s after every end magpie makes
  (the watcher's step, RestartCodexApp, RestartSwitchedCodexApp) the
  app's logs are read for a whole fatal_error_broadcasted line stamped
  after the end. On one, with no request through magpie since or in
  flight and no Codex turn opened since, the app is quit and opened
  once. Otherwise it is left as it is and logged. Where it can't be
  reopened (Linux, an app that didn't quit) the Agents row says
  "The Codex app hit an error · quit it and open it again" (appSnag)
  until the app-servers seen then are gone or the app is closed.
  Unreadable logs reopen nothing.
- agent/codex_app_crash.go: the logs as the app's file logger writes
  them (macOS ~/Library/Logs/com.openai.codex, Windows
  %LOCALAPPDATA%\Codex\Logs and the Store package's LocalCache, Linux
  $XDG_STATE_HOME/codex/logs; YYYY/MM/DD folders, tail-read, half
  lines dropped). The relaunch is the Agents row's: on macOS
  ChatGPT.app found by its bundle id, quit as ⌘Q does and opened once
  it has ended, never forced; on Windows codexAppReopen.
- GUI line in en, zh, zh-TW, ja, de; docs/subsystems/agent-wiring.md.

Run on mote (macOS) at this head on origin/main 08982805e:
- go vet ./internal/agent ./internal/provider ./internal/gui (darwin
  and GOOS=windows), GOOS=linux go vet ./internal/agent
  ./internal/provider; go build ./...; gofmt -l clean.
- go test ./internal/provider ok; go test -run
  'TestCodexApp|Restart|Reopen' ./internal/agent ok.
- go test ./internal/gui: red only in TestMainWindowCorners (#3949) and
  TestPanelHiddenByWailsMarksPageOutOfSight (#5322), AppKit window tests
  red on mote's macOS 27 and filed before this change.
- win-run and wsl-run: go test -run TestCodexApp ./internal/agent
  ./internal/provider ok (the macOS relaunch test skips on Windows, as
  TestWorkBuddySidecarOutlivesQuitOnMac does, #4115).
- node --test codex-app-snag, codex-app-out, codex-app-back, i18n-keys,
  i18n-en-no-cjk: chromium and webkit, every language, 980 and 440px.
  i18n-keys' "a plugin's words are its own" stays red for "View routing"
  (#5327/#5332, red on main since 73c98ebc2); this change added a word
  there and took it out again.
- Core script budget: under it, not raised.

Broken by hand, each red then restored:
- codexAppCrashStep's call removed: 4 provider tests red.
- the watch not armed in RestartSwitchedCodexApp:
  TestCodexAppRestartsWatchForTheErrorPage red; in RestartCodexApp:
  TestCodexAppRowRestartWatchesForTheErrorPage red.
- the turn and request checks off: TestCodexAppInUseAfterItsErrorPageIsLeft red.
- the snag not set: TestCodexAppSnagSaidTillTheAppRestarts red.
- the stamp's >= since check dropped, or a half-written last line kept:
  TestCodexAppCrashedReadsItsOwnLogs red.
- a wrong Store package path: TestCodexAppCrashedReadsEachSystemsFolder red.

Not tried: a real signed-in ChatGPT app reaching the identity-not-ready
page, and a real quit and reopen of the user's ChatGPT.app (the relaunch
is tested with faked process listing, quit and open in a sandbox HOME).
The log line and folders are read from ChatGPT 26.1021's
file-based-logger and the reporters' logs; a later app that renames
them reopens nothing, as before this change.
2026-11-05 17:24:53 +08:00
yetone 099d2b4612 agents: Codex back on ChatGPT after the reset says to restart its app, with a Restart
A bug report by mail (11-04): after the ChatGPT allowance reset, Codex
was back on its account, but the Codex app still showed no account and
no usage. The app's app-server was the one it started while magpie
served Codex, and the app reads account/read only as that starts. With
"Restart the Codex app when magpie switches its account back" off (the
default, #4550), codexAppStep leaves it running, and nothing said so;
the takeover's hover even said "It all comes back on its own at the
reset". On Windows StaleCopies lists only the daemon, so no hint showed
there either.

- provider: codexAppStep remembers the app-servers it left running when
  magpie gave Codex its account back (c.out && !out, not magpie's own
  account switch, which codexAppLeft already says). CodexAppBack() is
  true till they are gone (rechecked every 30s; a failed listing keeps
  it), a route change clears it, and RestartSwitchedCodexApp clears it.
- gui: /api/state's Codex row carries appBack (not for a WSL Codex).
  The Agents row says "Back on ChatGPT · restart the Codex app to see its
  account" with a Restart, and the row opened says why, with the same
  Restart; it posts codex/daemon/restart-app, as the Providers page's
  "still signed in as" Restart does. The takeover text now says the
  account and usage come back once the app-server restarts, and that
  this row offers it.
- i18n: zh, zh-TW, ja, de for every new and changed string.

Run (on mote unless named; rebased on origin/main d892dd6a2, then 8b902e287 (checkin only; vet and CodexApp/Checkin tests ok there), the gui budget/i18n Go tests, CodexApp and i18n-keys, codex-app-back, codex-app-out ran again at this head: ok, 148 of 148):
- go test ./internal/provider -run CodexApp: ok; also ok on Windows
  (win-run) and Linux (wsl-run, with go vet ./internal/provider).
- go test ./internal/gui: one red, TestMainWindowCorners/macOS_26_SDK,
  which is #3949 (macOS 27 on mote), nothing else.
- GOOS=windows go vet ./internal/provider ./internal/gui: ok. Linux vet
  of internal/gui needs gtk4/webkitgtk dev packages the WSL distro
  lacks, so it was not run.
- gofmt -l internal/: nothing.
- GUI: every codex-*, agent*, ag-* and i18n* file (86 files), both
  engines: 1484 of 1486. The two reds are codex-auto-reset webkit de
  1100/420, red the same alone at origin/main e0ee9265e; #4790 (noted
  there that macOS has it too). The new codex-app-back.test.cjs: 20 of
  20, every language, both engines, 980 and 440 px, line and row opened.
- Broken by hand: leftBack forced false, TestCodexAppBackSaidTillItRestarts
  went red ("the app left on the takeover's app-server isn't said");
  restored.

Not tried: a real Codex app through a real reset; the state machine is
driven with stubbed app-server listings.
2026-11-05 01:45:17 +08:00
yetone 083821dc96 plugins: a search entry can use the plugin's own sign-in, with its own rests
Asked for by axelburks on Discord. A plugin's search hook entry can name
a provider its own auth hook signs in to, `auth: "<provider id>"`. It then
takes no key. The host picks an account, renews it under `fresh` (the wait
counts within the search's time), runs the hook in `inScope`, and gives it
`ctx.getAuth()`, which returns that account's sign-in. A token the hook saves
with client.auth.set goes to the same account.

The gateway (askSearchSignedIn) asks one account at a time. It takes the
accounts that are on, in the order the provider's model requests take them
(accountsOn, now shared with fallback.go), and puts an account resting from
a search refusal last. A refusal rests only that account's search
(restSearchKey "account <key>"), never its models' rest (restingUntil). Every
attempt gets its own request-log row. An entry without `auth`, or naming a
provider the plugin doesn't sign in to, is a keyed entry as before, with no
getAuth. In Settings → Search, a bound entry shows "Signs in with {name}" in
place of the key field, and the row says whether it is signed in and how
many accounts are on (every language).
Docs: reference.md (with an example), plugin-runtime, plugin-tools and
provider-plugins.

Run on mote at f44fa2ef6 + this change. After rebasing on acd789d45 (an
unrelated responses_ws change), go build ./... and -run "Search|Budget"
on plugin, gateway and provider are ok again at this tree.
- gofmt -l clean; go vet ./internal/... ok; Linux and Windows vet of
  plugin/gateway/provider/gui ok
- go test -count=1 -timeout 45m ./internal/plugin ./internal/provider
  ./internal/gateway ./internal/gui: plugin, provider and gateway
  ok; gui red only in TestMainWindowCorners/macOS_26_SDK, mote's
  macOS 27 title bar, already filed as #3949
- node --test on 15 GUI files: search-signs-in, search-api, search-keys,
  search-order, search-all, search-first, search-instead, searcher-pick,
  searcher-then, provider-search, settings-search, i18n-keys, gui-zh-tw,
  gui-ja, gui-de. 207 of 207 pass (chromium and webkit, 980/420px, en/zh).

Broken by hand. Each break made its test red:
- B1, no ctx.getAuth: plugin TestPluginSearchSignsIn "ctx.getAuth is not a
  function"
- B2, no renewal: "searched as due@seek acc-due", "the renewal never began"
- B3, gateway with no auth branch: gateway TestPluginSearchSignsIn "signed
  in: k9 undefined"
- B4, a refusal that also rests the model account: "a search's rate limit
  rested a@seek for its models"
- B5, getAuth handing out the provider's first account: "as the second
  account: a@seek acc-a"
- B6, the hook run outside inScope: "a token saved while searching as b: a
  rotated-b@seek"
- B7, getAuth given to every entry: "keyed: k9 function"
- settings.js showing the key field for a bound entry: search-signs-in red
  in every engine, width and language

Not tried: a real search vendor or Axel's own plugin; real accounts; runs
on the Windows or Linux boxes; the full GUI suite. The full go test ./...
runs after the push.
2026-11-04 20:55:42 +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 90bf96a23d search: a plugin can give a web search API (its search hook)
treeman on Discord #help asked for web search to be pluggable so users can
add search vendors. A plugin's `search` hook, {search: {<id>: {name, keysURL?,
keyOptional?, url?, execute({query, count, key, url}, ctx)}}}, adds an API to
Settings > Models > Web search as `<plugin>:<id>`. It is added, keyed, ordered,
switched off and removed like Tavily or Brave. The built-in APIs stay built in.

How: host.js collects the hook's entries (id [a-z0-9-], an execute) into
Loaded.Searches and runs one with the `search` op (timeout from ctx, an error
with a numeric status comes back as a refusal). The host notes them in
plugin-searches.json (internal/plugin/search.go); provider.AllSearchVendors
adds the noted ones of plugins that are on to SearchVendors, so Ready, check,
the CLI and the GUI list see them. askSearchAPI hands a plugin vendor to
askPluginSearch below askSearchAPIKeys, so keys, rest on 401/402/403/429,
order, the masked query and the request-log row are the built-ins' own.

Run (mote, on this tree, whose base df7c94bdf was just fetched):
- go test -timeout 45m ./internal/plugin ./internal/provider ./internal/gateway
  ./internal/cli: ok.
- go vet native; GOOS=windows go vet plugin, provider, gateway, cli: ok;
  GOOS=linux go vet plugin, provider, gateway: ok. gofmt -l: empty.
- internal/gui: TestCoreScriptBudget and TestMainWindowCorners fail in a
  full run. This change touches no script (only api.go's loop), so the
  budget red is the base's (re-checked after the rebase, below);
  TestMainWindowCorners is AppKit on mote (macOS 27).
Broken by hand: skipping off plugins in NotedSearches turns TestPluginSearch
red; the refusal mapping removed turns TestPluginSearchAPI red.
Not tried: a real plugin against a real vendor's API; the GUI JS suite (no
GUI script changed); a Linux or Windows window; site/public/docs (en, zh, ja)
do not describe the hook yet. A plugin just added is listed once the host has
loaded it; RestoreSearchAPIs drops a plugin's entry on a machine without it.
The community README has the template (magpie-community/plugins 3ec42d4).

Reported by treeman.
2026-11-04 08:37:21 +08:00
yetone 6673171595 update: the app and magpie web follow each other's update (visamzh on X)
visamzh on X: with the desktop app and magpie web both open, an update
from either side left the other still offering it ("↑ 更新") until it was
quit by hand.

Cause: the app and magpie web are two processes over one program, each
with its own updater (state, download, latest) in memory. One restarting
to update puts the new binary in; the other is told nothing. Its
replaced() (the binary on disk is no longer the one it started from) was
read only on a click of its own Update or on magpie update's gateway ask
(restartBeside), which reaches only the process serving the gateway. And
a browser's page reloaded (backAsNew) only after a restart it asked for
itself, so magpie web's tab kept the old page and its pill even once
the process under it was new.

Fix:
- followReplaced (update_beside.go): every updater stats its binary each
  5 s and, once another magpie replaced it, restarts into it through
  restartBeside, once: at once when idle, else after the gateway's
  requests (waitIdle), as for magpie update's ask. Not for what this
  process put in itself (installed, set by install, cleared by
  wontStart), not twice (followed), not for a build that isn't a release
  (make dev, go build rebuild in place). It stops with backendCtx, so a
  copy left draining after a handover doesn't look.
- waitFor (update_wait.go): a wait for the gateway restarts into what
  another magpie put in whatever the feed says now; before, a feed out
  of reach or a "latest" answer ended the wait with nothing restarted.
- boot.js names the version that served the page (bootPrefs.version);
  app.js's servedAnew reloads a browser's page (web) when /api/update's
  current names another, on the reads it already made (load, focus, back
  into view) and once a minute while shown. The app's own windows come
  back with their new process and are left alone.
- docs/subsystems/gui-shell.md describes it.

Run (mote, through mote-run, at 1e1068c86 + this change unless said):
- gofmt -l internal/gui: nothing.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., go build, GOOS=linux go build -tags nogui, GOOS=windows go
  build: all ok.
- go test -tags nogui -race -count=5 -run
  'Follow|AnotherMagpies|OwnUpdate|OwnBuild|UpdateClicked|Wait|Beside|
  Restart|Install|WhatsNew|Quiet' ./internal/gui/: ok (102.9s).
- go test -tags nogui -timeout 45m ./internal/gui/... ./internal/cli/...
  ./internal/update/... . : gui, update, update/launcher and magpie ok;
  internal/cli red in TestEveryRouteHasACommandOrIsNamed (GET
  /api/context/reply has no command), red the same on origin/main
  51fa4b7eb alone, filed as #5026 (from 0872bc2a0).
- node --test internal/gui/tests/update-served-anew.test.cjs: 34/34
  (Chromium and WebKit; en, zh, zh-TW, ja, de; 1100 and 420 wide; the
  minute poll under page.clock; the app's window not reloaded).

Broken by hand, each red, then put back:
- followReplaced never restarting: TestAnotherMagpiesUpdateRestartsThisOne
  and TestAnotherMagpiesUpdateWaitsForTheGatewayThenRestarts red.
- the installed guard dropped: TestOwnUpdateIsNotFollowedAgain and
  TestUpdateClickedOverAnothersIsNotFollowedAgain red (a second restart).
- waitFor's "in" case off: TestAnotherMagpiesUpdateWaitsForTheGateway
  ThenRestarts red (the wait ends with nothing restarted).
- boot.js without the version: TestBootNamesTheVersionThatServedThePage
  red.
- servedAnew not reloading: 15 of 16 subtests red in Chromium.
- the minute poll removed: the 5 "left on screen" subtests red in WebKit.

A first cut also refused a second install() once one was in; that made
TestRestartBySelfComesBackQuietly and TestWhatsNewQuietAfterRestartTo
Update red (they restart one updater several times), so the flag only
keeps followReplaced off.

Not tried: a real pair of the app and magpie web on two release builds
with one replacing the binary (only temp files and fakes); Windows
(InstallBinaryAside starts the staged file there, so the own-install
test is skipped and the click test covers the flag) and Linux runs;
the whole GUI suite: mote was never free (two other sessions' full GUI suites, load ~400), so it runs on the Linux box after this lands.
2026-11-04 06:59:29 +08:00
yetone 6c201095d8 gateway: in Docker, other containers on the host are shown the host's Docker bridge address
jiezhengj (Discord #feedback) runs magpie in Docker on a NAS at
192.168.31.218. The web UI's host address, http://192.168.31.218:3425,
works for other devices. Other containers on the NAS couldn't use it, and
not the container's own 172.17.0.x either. What works for them is the
host's Docker bridge address, http://172.17.0.1:3425. On Linux,
host.docker.internal is there only in a container given extra_hosts.
magpie showed no such address.

- gateway.ContainerHostURL: in a container on a bridge network, the
  gateway of /proc/net/route's default route (172.17.0.1 on the default
  bridge, a compose network's own otherwise), on the gateway's port.
  It is "" outside a container and on the host's network
  (`network_mode: host`, told by the host's
  docker0/br-*/veth*/podman* interfaces). In that case ContainerAddrs is
  false too, since the addresses are the host's own.
- The GUI gets it as /api/providers' gateway.containerHost,
  /api/settings' lanContainerHost and boot's sideGateway.containerHost.
- settings.js lanShown is fed by the new gwLAN(g) for Gateway, Connect,
  the sidebar and the key page. Each case lists:
  - Opened at the host: the host's address first, then the bridge
    address, labelled "Other containers on this host".
  - At localhost: the bridge address alone, with that label, and a line
    that the host's own is MAGPIE_PUBLIC_URL's.
  - No default route: as before.
  The container's own 172.17.0.x is no longer offered beside them. The
  sidebar line and the key page prefer an address other machines reach.
  The scheme comes from the URL, not a hard-coded http. Three new strings
  are in zh, zh-TW, ja and de.
- CLI: `magpie web` and the share banner print "other containers on this
  host <url>".
- docs/reference.md and site docs/docker (en, zh, ja): the log example and a new "Other
  containers on the same host" paragraph.

Run on mote, at this change on d8501848a:
- gofmt -l: clean. node --check: passes.
- Vet: darwin go vet, GOOS=linux go vet -tags nogui and GOOS=windows go
  vet of internal/gateway, internal/gui and internal/cli: ok.
- go test -timeout 45m: internal/gateway ok. internal/gui is red only on
  TestMainWindowCorners/macOS_26_SDK, which is red on macOS 27 at main
  (#3949). internal/cli is red only on TestEveryRouteHasACommandOrIsNamed
  for GET /api/context/reply, red at main (#5026).
- GUI, chromium and webkit: lan-docker (en, zh, zh-TW, ja, de) and the
  40 files on the caller-keys fixture or the LAN paths. 586 tests, 580
  pass. Each red is also red alone at the base d8501848a or af9ac3d25:
  - phone-connect-menu 420, 4 reds (#4706, #4707).
  - gateway-key-models webkit en (#4616, #4081; 4 of 4 at the base).
  - gateway-caller-keys chromium en (#3797; 2 of 3 at the base, 1 of 3
    here).

After the rebase onto 3f1f1882a (187f3e272, the usage page alone, came after): the commits
between touch none of these files. Linux and Windows vet ok. go test -run
'Container|HostNetwork|DefaultGateway|PublicURL|LAN|Boot|Provider' ok in
gateway, gui and cli. GUI lan-docker, i18n-keys, side-gateway-lan and
key-page: 56 of 56, in both engines.

Broken by hand, in a copy:
- defaultGateway reading big-endian: TestDefaultGateway goes red
  ("1.0.17.172").
- The old settings.js, client.js and keys.js: every lan-docker test goes
  red, in both engines and every language.
TestDefaultGateway stubs the in-container check, so it tests the
container path on mote and CI too.

Not tried:
- a real Docker container, on a NAS or anywhere;
- reaching 172.17.0.1 from a container on another compose network on the
  reporter's NAS;
- a published port that differs from the gateway's (MAGPIE_PUBLIC_URL
  sets the host's; the bridge address uses the gateway's own port);
- Podman's rootless networking (slirp4netns, pasta), where the default
  route may not be the host.
2026-11-03 19:41:02 +08:00
yetone d10f377657 providers: Names & levels is Names, prices & levels, where a model's own price at one provider is set (ferock4669)
ferock4669 asked on Discord whether magpie has a screen to price each
model, since one model can cost differently on each provider. It has:
each row in a provider's per-model list has a price box (input, output,
cache read, cache write, 1h cache write, long-context tier, $ / 1M
tokens), saved in settings' ModelPrices under pid/model. It wins over
the list price in Usage (usage.Pricer through provider.BasePriceIn) and
in a key's spend cap (usage.KeySpent through NewCoster). Nothing has to
be built; the button opening it said only "Names & levels", so nobody
finds a price there.

What changed:
- The button, its panel's heading and fold, and every note that sends
  the user there say "Names, prices & levels" (zh 名称、价格与推理档位,
  zh-TW 名稱、價格與推理檔位, ja 名前・価格・推論レベル, de "Namen,
  Preise & Stufen"); the gateway's vision and compaction notes, the
  provider package's text, the subsystem pages and the site's start
  docs (en, zh, ja) follow.
- The button's tooltip says it sets what each model costs at this
  provider; Usage's "estimated" tooltip says where a provider's own
  price is set and that it counts over the list price. Both in en, zh,
  zh-TW, ja and de.
- Not changed: the Codex model description text in internal/codexcat
  (it goes to Codex, so a vendor sees it) and core_budget_test's
  history comment.
- app.js: a comment above the price box is shortened so the core
  script stays under its budget, not raised (app.js 116 bytes under
  origin/main).

Run at the pushed head (rebased on origin/main 1af868a15), on mote:
- go test -run 'Budget|ModelPrice|ModelPref|Vision|Compaction'
  ./internal/gui ./internal/provider ./internal/gateway: ok.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows:
  ok (before the rebase, which touched no Go of this change).
- GUI, both engines, every language each file runs: the 149 files that
  name the label or open a provider's editor (before the rebase): 1191
  ok, 30 red in 7 files. Each of the 7 is red the same way alone at
  origin/main without this change: provider-fetch-again (#5057),
  provider-typed (#4673), provider-levels-scroll webkit (#4395),
  provider-picks-stay (#4397), usage-agents-hide (#3414), usage-ledger
  Requests (#5048), mobile-web (#3952, no .git in mote-run's copy).
  name-suffix-remote "chromium de" (ERR_NAME_NOT_RESOLVED once) passed
  alone at the head. After the rebase: model-price-edit, i18n-keys,
  name-suffix-remote, usage-ledger, usage-agents-hide again: go tests above ok; model-price-edit, i18n-keys and
  name-suffix-remote (all 10 cases) ok; usage-ledger Requests and
  usage-agents-hide red as at origin/main 1af868a15.
Broken by hand: model-price-edit.test.cjs at origin/main's label is red
in all 4 cases (the button "Names, prices & levels" is not found).
Not tried: the whole GUI suite (another session's full suite was on
mote, WSL at load ~100 with 31 test runners); the real app.
2026-11-03 17:00:38 +08:00
yetone 01de489de1 search: a ChatGPT account searches for another model by the backend's own search (lucy_85908)
A third-party model in Codex (DeepSeek, MiniMax, ...) had its web
searches made by asking gpt-6-luna on the Codex account to search
through /responses. A ChatGPT account now searches by the ChatGPT
backend's /alpha/search, the request Codex's web.run sends by itself
with no model turn (codex-rs ext/web-search): one search_query, the
account's small model in "model", allowed_callers ["direct"], and
external_web_access from the client's web_search tool (#5018: Codex's
"cached" sends false; live by default). The output's pages are read by
their 80-dash rule and ref_id; the private-use citation marks are dropped.

Measured on a real Plus account (2026-11-03, token not refreshed): 151
alpha/search calls left the 5h window at the same percent, ~1.5-2.2s
each; 51 searches by gpt-6-luna took 0% -> 1% of it, 7-15s each,
~9-17k tokens in (40 of them: 414,585 in, 10,313 out). The backend
answered the same for any "model" (deepseek-v4 too) and any
max_output_tokens.

- Automatic (and searchInTurn) picks the backend's search for a ChatGPT
  account; Settings > Web search offers "<id>/@search" as "its web
  search". "<id>" and "<id>/<model>" saved before still search by that
  model, so a user's pick is unchanged.
- When the backend's search fails, the account's small model searches
  (codexSearchBy).
- Codex web.run's own search for a non-ChatGPT model (alphaSearchHere)
  and a Responses request's web_search tool pass their mode on.

Run at this head (rebased on origin/main), on mote:
- go test ./internal/gateway/... ./internal/gui/ ./internal/agent/
  -timeout 45m: gateway and agent ok; gui red only on
  TestMainWindowCorners/macOS_26_SDK (#3949, macOS 27 on mote).
  After the rebase: the gateway's search tests again ok.
- searcher-pick.test.cjs: 22/22, chromium + webkit, en/zh (+ the label
  is in zh, zh-TW, ja, de).
- gofmt -l clean; GOOS=linux go vet gateway, provider; GOOS=windows go
  vet gateway, gui.
- Whole GUI suite on the Linux box (wsl-run): not finished when pushed;
  its reds so far are WebKit pages this doesn't touch (add-provider,
  API key palette, Routing headers, click-scroll, Codex resets).

Broken by hand, each red: the Automatic switch (TestCodexSearchesWith
ItsCheapModel, TestChatGPTAccountSearchesByItsWebSearch), the
responses.go mode (TestResponsesWebSearchModeKept), the body's mode,
the fallback, and the picker option (searcher-pick).

Not tried: a real search through magpie in a sandbox (the request shape
was tried by hand against the backend); an account out of its
allowance (does alpha/search still answer?); the model fallback still
searches live when Codex asked cached.

Suggested by lucy_85908 on Discord.
2026-11-03 15:59:14 +08:00
yetone 1d8658abca routing: a group's model picker offers the providers' image models, and a group of them draws (jzw690 on X)
jzw690 on X: the Routing page's group editor ("Add a model") listed no
image models, so a group of image models, to draw at
/v1/images/generations and to pick in Settings > Images, couldn't be
made.

What changed:
- /api/groups gains `drawers`: each provider's image models
  (gateway.Drawers, less ones unticked in its editor unless a group
  names them), apart from the chat `models`. The picker offers them
  after the chat models, noted "<provider> · Image model" (an existing,
  translated key); a member row says so and offers no reasoning level.
  Decision-model groups don't offer them. Image models stay out of the
  chat catalog, so agents are not offered them.
- An image member drew only when its provider had no picks: picks are
  of chat models, so membersFound dropped it as unpicked, and GroupDraws,
  resolveDrawing, the group's turns and DrawerMissing all failed.
  provider.FindDrawingGroup keeps such a member when drawsModel holds;
  the image path uses it (drawingMembers), video keeps FindGroup.
  DrawerMissing for a group ref asks GroupDraws.
- Routing card: such a member reads ready (groupsState), and Settings >
  Images lists every group that draws, not only those reached through
  Served.
- docs/subsystems/gateway-routing.md says so.

Tests:
- TestImageGroupOfUnpickedImageModelsDraws (gateway), from the
  reporter's case: two key providers whose live lists hold gpt-5.5 and
  gpt-image-2, one with gpt-5.5 picked. group/<id> draws at
  /v1/images/generations (the first member's 502 moves on to the next),
  as the Settings pick a request naming no model draws, and the model
  gone from the list makes it missing.
- TestGroupEditorOffersImageModels (gui): drawers listed, an unticked
  one not offered unless a group names it, none among chat models, the
  group's members ready, Settings offers the group.
- group-pick-drawers.test.cjs: the picker offers it with its note, adds
  it, no reasoning button, Save posts it; en and zh, Chromium and
  WebKit.

Broken by hand: drawingMembers passing nil instead of drawsModel made
the gateway test red ("group/pix-images doesn't draw"); turning off the
groups.go drawer branch made the gui test red ("group not ready").

Run at b295d1196 plus this change (mote unless said):
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- go test -count=1 -timeout 45m ./internal/provider ./internal/gateway
  ./internal/gui: provider ok. Two reds, neither on this path:
  TestCodexPoolSaysTheClientsVersion (full run only, passes alone 3/3;
  #4807) and TestMainWindowCorners (red on origin/main f49f6ba68 too,
  macOS 27; #3949). Both commented.
- GUI on the Linux VM (Playwright 1.62.0, both engines), 62 files:
  group-*, routing-group*, settings-groups, fallback-group,
  agent-model-groups, image*/images*, panel-routing*, routing-manual,
  routing-levels, i18n-keys. 698/710. i18n-keys was red on a comment of
  this change saying ", with an image" (reworded; 4/4 after). The
  WebKit reds under concurrency 4 passed on a serial run except
  group-member-info webkit zh, red 2/2 on origin/main f49f6ba68 too
  (#1745, commented).

Rebased on origin/main 809801f1f (its 8 commits change client.js and
gateway-routing.md), then again on mote: gofmt clean, go test -run
of the budgets, TestImageGroup*, TestDrawing*, TestGroupMember* and
TestGroupEditorOffersImageModels in gateway, gui and provider: ok; on
the Linux VM, both engines, group-pick-drawers, group-pick-filter,
group-decide-members, group-editor-fits, group-member-off,
routing-levels, settings-groups, image-models-hide, i18n-keys: 96/96.
Rebased last onto 03d7927a8 (search strings, i18n.js values only;
none of this change's files), not run again.

Not tried: a real provider's image model drawn through a group in the
running app; Windows and the real Linux app (WebKitGTK).
2026-11-03 11:57:11 +08:00
yetone 443e53d6b2 search: an AI Studio key that searches by googleSearch searches for other providers' models
cocoasoda on Discord: a Gemini AI Studio key provider searches natively
(googleSearch grounding, geminiKeySearches), but it never showed in the
search-for-other-providers (代搜索) list. searchRank knew only a Google
sign-in (googleAccount) at rank 5, so namedSearcherRank gave such a key
-1 and Searchers() left it out; autoSearcher never chose it.

searchRank now gives geminiKeySearches(p) rank 5 too: a saved key
provider, not a plugin, not Vertex, whose Gemini searches itself. That is
the same rank and the same googleSearch route as a Google sign-in, and
Searchers() marks it Own (it searches by its own tool, not a relay or a
search key).

Run on mote (macOS 27), at the rebased head e76db5515's tree:
- go test -count=1 ./internal/gateway -run
  'AIStudio|GeminiKey|Searcher|WebSearch': ok; ./internal/gui -run
  'Budget|Script|Search': ok; gofmt -l: clean.
- GUI: searcher-pick, searcher-then, search-instead, search-order,
  provider-search (chromium + webkit): 84/84.
- Before the rebase, at eb779ce92 + this: GOOS=linux and GOOS=windows
  go vet -tags nogui ./internal/gateway ./internal/gui: ok.
- TestAIStudioKeySearchesForOthers: a fake AI Studio endpoint
  (httptest, no network) answers the googleSearch call; the test checks
  rank 5, Own, the small model gemini-2.5-flash, autoSearcher's pick,
  and that another provider's model's web search goes there once, with
  tools [{"googleSearch":{}}] and x-goog-api-key.

Broken by hand: the new case taken out of searchRank, the test is red
("rank -1, by hand only false").

Not tried: a real AI Studio key; the whole ./internal/gateway and
./internal/gui packages at this head (a run at the old base is still
going).
2026-11-03 10:57:36 +08:00
yetone eb779ce92a gui: the tray icon's tooltip is in magpie's language (yi_time)
yi_time in #feedback: magpie set to Chinese on Windows, and the tray
icon's hover tooltip said "Today: 121K tokens (2.9K in · 180 out ·
118K cached)" and "3 requests" in English. The tray menu already
followed magpie's language (trayLang, #301); the tooltip's words were
hard-coded English in trayusage.go.

Now every tooltip is in trayLang(settings.Lang, systemLang), on
Windows, macOS and Linux alike. That covers trayIdleTip, magpie's
totals (trayTotalCard), and each subscription card (trayCardText: its
use or what is left, the pace, when it resets, until's d/h/m, "as of
…"). The words are in trayWords beside the menu's, for zh, zh-TW, ja
and de; English stays the key and the fallback. A window's name and an
error are still the card's own. A change of language in Settings now
also refreshes the tooltip (onTrayUsage); before, only the menu was
relabelled. The test-only trayUsageText and trayUsageView stay in
English, so the existing tests keep their strings.

Test: TestTrayTooltipFollowsMagpiesLanguage.
- yi_time's own numbers in zh: "magpie\n今天:121K token(输入 2.9K ·
  输出 180 · 缓存 118K)\n3 个请求".
- The same numbers in en are unchanged.
- Covers the total card and a card's used, left, reset and as-of.
- For zh, zh-TW, ja and de, no English word in the idle, totals, card
  (with pace) or combined tooltips.

Run at this head (rebased on 5573f7923):
- mote: gofmt -l clean; CGO_ENABLED=0 GOOS=linux go vet -tags nogui
  and GOOS=windows go vet of ./internal/gui ok.
- mote: go test ./internal/gui. Everything passes except
  TestMainWindowCorners/macOS_26_SDK, which is #3949 (red on mote's
  macOS 27, not touched here).
- Windows (xiaomi-gpu, win-run): go test -run Tray ./internal/gui ok.

Broken by hand: with the tooltip words taken out of trayWords, the
test goes red. Its zh output is then exactly the old English tooltip.

Not tried:
- The real tray on Windows, hovering the icon.
- The watch loop's choice of language has no test of its own. Passing
  "en" there would not go red.
2026-11-03 10:14:23 +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
yetoneanderlinerd 1cb4d43013 profiles: a saved profile renames, in its details, the TUI and magpie rename (#2721, erlinerd)
erlinerd's patch on #2721 (profile.Rename, /api/state profile/rename,
a Rename button in the details), reviewed against main and adapted:

- profile.Rename trims both names, refuses an empty, taken or missing
  name and leaves profiles.json as it was, renames by case only
  (home -> Home), and keeps what the profile holds.
- GUI: Rename turns the details' name into a field. Enter renames
  through profileAction, so the chip is renamed at once, pending, and
  rolled back with the error if magpie refuses; the details stay open
  under the new name, with In use kept. Escape or a click away puts
  the name back. The field lives in profilerename.js, imported on
  press, so the core script stays under its budget (no raise; 50 bytes
  under after comments in app.js were cut). While the field is open
  In use, Apply and Rename hide so a 360px panel's field has room.
- TUI: ctrl+e on a profile renames it on the name line.
- CLI: `magpie rename <old> <new>`; a flag is never taken for a name.
- WebDAV: a rename syncs as the old name gone and the new one in
  (davsync test).

Run on mote at 47672f11c (on 70b96126e), and again after rebasing on
52195b6b0 (backup), as 3b279fdee:
- go test ./internal/profile ./internal/cli ./internal/gui ./internal/tui
  ./internal/davsync: ok except TestEveryRouteHasACommandOrIsNamed
  (#4826) and TestMainWindowCorners (#3949), both red on origin/main
  07f4d46c5 too. gofmt clean; GOOS=linux (-tags nogui) and
  GOOS=windows go vet ok.
- GUI, chromium and webkit: profile-rename (en, zh, zh-TW, ja, de;
  900x560 window and 360x420 panel), panel-profiles, profile-confirm,
  profile-in-use, profile-details, hermes-profiles,
  view-wheel-after-click, i18n-keys, gui-de, gui-ja, gui-zh-tw,
  editor-roomy: 219 pass, 0 fail. After the rebase: profile, cli,
  gui, tui and vet again (same two reds only, core budget ok), and the
  GUI files above with auto-backup in place of editor-roomy: 161 pass.
  Then rebased over ea51526b6 (gateway, plugin, provider only; no
  file of this change, no GUI asset) without another run.

Broken by hand, each red, then restored:
- Rename comparing names with EqualFold: TestRename red (case-only).
- Dropping the CLI's "-" check: TestRenameCommand red.
- Dropping `profileOpen = to`: profile-rename 22 of 22 red, both engines.

Not tried: the real app on Linux (WebKitGTK) or Windows; a rename
synced over a real WebDAV server.

Co-authored-by: erlinerd <erlinerd@outlook.com>
2026-11-02 18:37:25 +08:00
yetone 4dfdd0cd63 provider: a provider switched off is asked for nothing, its plugin's model list included
ChangQiu on Discord switched a provider off long ago, and magpie still
reached it. Routing, fallback, usage and balance reads, warmups,
check-ins and keepalive were already held back (On(), leftAlone,
KeepListsFresh). These were not:

- The plugin host's providers listing ran every plugin's models hook,
  which asks the vendor, and its sign-in renewal (fresh), for every
  plugin provider, on or off. Go now passes the ids switched off
  (plugin.ListingOff, provider.pluginsOff: the provider's id and the
  plugin's own id, read from providers.json alone). host.js lists such
  an id without running a hook (info(..., quiet)), so its row stays and
  keepListed keeps the last list.
- Sync (POST /api/sync, `magpie sync`) fetched every ready provider's
  list. Both now go through provider.RefreshLists, which skips one
  switched off.
- Saving or switching on in the GUI fetched the list even for one left
  off; PrefillNewKeys asked one switched off too.

What still asks one switched off, by the user's own click: the TUI's
refetch, the provider Test button and `magpie provider models <id>`
refetch.

Tests: TestOffPluginProviderAskedNoModels (the fake plugin's models
endpoint counts its hits: 0 while off, the list kept, asked again once
switched on), TestPrefillAsksNoProviderSwitchedOff,
TestPluginsOffNamesThePluginsOwnIDs and
TestRefreshListsAsksNoProviderSwitchedOff.

Run on mote at this head (first at a4916aec1):
- go test -timeout 45m ./internal/provider ./internal/plugin
  ./internal/gui ./internal/cli ./internal/tui ./internal/gateway:
  provider, plugin and tui ok. Three reds, each also red on origin/main
  and filed: gui TestMainWindowCorners/macOS_26_SDK (#3949), cli
  TestEveryRouteHasACommandOrIsNamed (#4826), gateway
  TestCodexPoolSaysTheClientsVersion (#4807).
- After rebasing on ce2e81da1: provider and plugin again, plus darwin
  vet of the four packages. One provider run went red on
  TestClaudeAccountServesModelsListedSinceItsFetch (#3174, full-run
  only). It is green alone 3/3 on this head and on origin/main, and the
  next full provider run was ok on both.
- GOOS=windows go vet of plugin, provider, cli and gui: clean.
  gofmt -l: clean. Linux go vet (WSL magpie-desktop) of plugin and
  provider: clean. cli and gui can't be vetted there: the distro has no
  gtk4/webkitgtk-6.0 headers for wails' cgo.
Broken by hand: with each guard taken out, its test went red ("switched
off, the vendor was asked 2 times", "the vendor asked 2 times",
"pluginsOff = [fakeco onco openai openai-plugin]", "the provider
switched off was asked 1 times").
Not tried: a real plugin provider switched off in the app. Which
provider ChangQiu had switched off isn't known, so his exact case is
not reproduced.
2026-11-02 14:30:45 +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