Commit Graph
327 Commits
Author SHA1 Message Date
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
yetone ec104b8625 gateway: a Codex account can spend its credits before magpie moves to another account (jojonas_xyz on X)
jojonas_xyz on X: "我账号额度用完了自动给我切了别的号…找不到怎么关掉设置…你怎么知道
我不是想用 credits 呢". (Roughly: "my account ran out of quota and magpie
switched me to another account by itself; I can't find a setting to turn
that off; how do you know I didn't want to use the credits?")

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

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

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

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

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

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

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

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

Claude has no equivalent: magpie reads no extra_usage and has no Use
credits modes for Claude. Filed as #4662 (see #4241).
2026-11-01 21:19:22 +08:00
yetone 8826a15ea4 gui: a Quit while agents go through magpie asks first, naming them (Aisiverto on X)
Aisiverto on X (Windows, v0.1.2519) wired Codex to magpie and quit magpie.
Codex then retried "unexpected status 502 Bad Gateway ... url:
http://127.0.0.1:3425/backend-api/codex/responses" five times and gave up,
and it took a long search to find magpie's openai_base_url in config.toml.

A Quit the user chooses (the tray's Quit, the panel's and window's Quit,
Command-Q on the Mac) now asks first when this process serves the gateway
and agents are wired to it. The window comes up on a sheet
(quitask.js, lazy-loaded) that names each agent cut off, says closing the
window keeps magpie running (menu bar on a Mac, system tray elsewhere),
and offers Quit (focused), Disconnect and quit, and Cancel. Disconnect and
quit puts each agent back as its row's Disconnect does, then quits; a
disconnect that fails keeps magpie open, named in the status line. A
second Quit within a minute of the question quits, so a window that
can't show it traps nobody. With nothing wired, or another magpie serving
the gateway, Quit quits at once.

Not asked: a restart to update, Uninstall, a browser's page (magpie web),
logging out or shutting down, and the Dock's Quit (AppKit terminate:).

Found while checking the report:
- Closing the window on Windows hides it; magpie stays in the tray and
  the gateway keeps serving (tried for real, below). Not a bug.
- Autostart is off by default on Windows.
- The proxy / NO_PROXY in the report isn't magpie's to fix: the 502 is
  magpie's port with nothing behind it.

Strings in en, zh, zh-TW, ja and de (existing terms: Agent, 退出). No
native dialog, no <select>. TestCoreScriptBudget met without a raise:
app.js gains two lines, the sheet is outside the core, and driftFix's
comment block is cut to six lines (453 bytes back; main's core had grown
to 258 bytes over with these lines in).

Run, at this head (on origin/main 94f6f6092), on mote unless said:
- gofmt -l internal/gui: clean.
- go vet ./..., GOOS=windows go vet ./..., GOOS=linux go vet -tags
  nogui ./..., go build, GOOS=linux go build -tags nogui, GOOS=windows
  go build: ok.
- go test ./internal/gui -run 'Budget|Quit|CommandQ', and with -tags
  nogui -run 'Budget|Quit': ok (TestCommandQAsksFirst runs AppKit in a
  child process).
- quit-ask.test.cjs, old-webkit.test.cjs, i18n-keys.test.cjs in chromium
  and webkit, en/zh/zh-TW/ja/de: 60/60 ok.
- At the previous base (9d08993c8): go test ./internal/gui (whole
  package, GUI build): two reds. TestCoreScriptBudget (258 over, fixed
  above) and TestMainWindowCorners/macOS_26_SDK, red the same at
  9d08993c8 itself (#3949, macOS 27). The nogui run of the package was
  not reached.
- The whole GUI suite: started at 24fd4a250 on WSL (magpie-desktop),
  stopped about halfway (3,915 results) to rebase; 68 reds in 28 files.
  Those 28 files with quit-ask, old-webkit and i18n-keys at 9d08993c8+this
  on mote: 74 reds in 7 files, none in this change's files. The 7 alone
  at origin/main 9d08993c8: the same 6 files red (73), and
  gateway-caller-keys red at main when run alone (1 of 4). All filed:
  balance-fix #4682 #4683, key-replace #4126 #3476, agent-panel-name-width
  #4203 (red on macOS too, commented), context-map #3488, header-centre
  #3479, gateway-key-models #4616, gateway-caller-keys #3797.
- Not run: go test ./... in full (mote at load 140-160 with others' full
  suites, WSL with two GUI suites), and the GUI suite to its end.

Broken by hand, each red:
- api.go's ask skipped (false &&): TestWindowQuitAsksFirst "the window's
  Quit didn't ask (AskQuit never ran)".
- askingQuit without RemoveMenuItem: TestCommandQAsksFirst "the app menu
  still has the Quit role".
- quitNow as asked == 0 ||: TestQuitNow "connected, never asked: quitNow
  = true, want false".
- The return after a failed disconnect removed: quit-ask 5/25 chromium
  red (the failed-disconnect test in every language).
- app.js's ?ask=quit line removed: 20/25 webkit red.

Windows, for real (xiaomi-gpu, sandbox HOME/APPDATA under
C:\Users\yeton\quitask-sb, MAGPIE_ADDR 127.0.0.1:3471, MAGPIE_NO_ACCOUNTS,
a -H windowsgui build of this branch, launched in the desktop session):
`magpie codex fakeq/m1` wired the sandbox Codex to
http://127.0.0.1:3471/backend-api/codex; WM_CLOSE on the window left
the process alive with no visible window and the gateway listening.

Not tried:
- The tray's Quit and the sheet on real Windows: WebView2's CDP port
  never listened and UI Automation didn't find the tray icon, so the
  sheet was tried in Playwright only.
- A real Codex run against the sandbox gateway before and after a quit.
- The Dock's Quit (not covered by design).
2026-11-01 21:16:35 +08:00
yetone 5dfbca6274 cli: magpie settings list|get|set|reset, through the window's own save (#4745)
Stage 1 of #4745 (StringKe): every setting POST /api/settings saves can
be read and set from the terminal.

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

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

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

Not tried: a real run on Windows or Linux; the live app reacting to a
CLI write while open (#4752); the GUI node suite (no page file changed).
2026-11-01 15:57:43 +08:00
yetone 344a59f9db gui: an unchanged Sessions poll answers Same without making the rows
The Sessions tab asks for every session each 15 s. When nothing had
changed, the handler still copied the kept listing, made a row of each
session, merged the gateway's sessions, read Codex's effort and the
vias, encoded every row and hashed them, only to answer X-Magpie-Same.
Over ~17k real sessions (69 GB of Claude Code and Codex history) that
was ~140 ms of CPU and ~24 MB of garbage per poll.

Now the handler keeps, per ?limit, what the last list it sent was made
from: the sessions listing (sessions.ListUnless's number, which changes
whenever the listing is made again, and at least once a minute), the
usage log's version (usage.LogVersion), the user's usage aliases, and
the agents' names and icons with the folders. An ask whose
X-Magpie-Had is that list's tag, while all of these stand, gets
X-Magpie-Same before any row is made or the listing copied. Anything
else a row shows (a Codex thread's effort, a gateway title) follows
within the minute the kept listing stands. writeJSONRows returns the
tag it sent.

Measured on the real history (a sandbox HOME with APFS clones of
~/.claude/projects and ~/.codex/sessions, 17,140 files), 30 polls of
/api/sessions + stats + overview, the same script for both builds:
  before (d614f2172): 4.19 s CPU, /api/sessions median 64 ms, 711 MB
    allocated
  after:              2.67 s CPU, median 47 ms, 298 MB allocated
What is left is the listing's own look at every file (getattrlistbulk,
~43% of the samples) and its GC.

Tests: TestSessionsSameWithoutRows: an unchanged poll is Same without
rows, and a gateway call, an alias and a new session file each make the
rows again. Broken by hand on mote: never taking the shortcut fails it
("rows made 1 times"), and leaving the log version out of the key fails
it ("after a gateway call: same true"). go vet and go test of
internal/gui, internal/sessions and internal/usage on mote (macOS):
sessions and usage ok; gui's reds were TestMainWindowCorners (red on
origin/main b646a9127 too, #3949) and the BusyLoad guard (#4739, fixed
by b646a9127; passes after the rebase onto 403323af7). GOOS=linux go
vet of sessions and usage, GOOS=windows of all three.

Not run: the full ./... suite, a Linux vet of internal/gui (cgo), the GUI suite (the page's api() and its
X-Magpie-Had handling are unchanged), Windows and Linux.
2026-11-01 15:27:49 +08:00
yetone 01ccbd40a0 library: an MCP router says which computer it is, so an agent can pick between two (packinggoodsllc_07668 on Discord)
Two magpies, one in China and one in Los Angeles, each serve the same
tools through their MCP router (/mcp/magpie/hub). An agent connected to
both saw two identical web fetches and couldn't pick the one in Los
Angeles to reach Google.

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

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

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

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

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

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

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

Run on mote (mote-run):
- At the pre-rebase tree (base 21882a68d): go test of settings, and
  -run 'Searcher|Search' of gateway and gui: ok.
- searcher-then, searcher-pick and i18n-keys in both engines: 46 of 46.
- gofmt clean. go vet: darwin gateway, gui, settings; windows the same;
  linux gateway and settings on mote, gui with -tags gtk3 on the Linux
  box (wsl-run): ok.
- Rebased onto origin/main 1e6a27d4f, this tree: -run
  'Search|Searcher|CoreScriptBudget|SettingsSave' of gateway, gui and
  settings: gateway and settings ok; gui ok but for
  TestSettingsSaveKeepsWhatItDoesNotSend on BusyLoad, red on main
  since 8d8df0639 (#4739, not this change; SearcherThen passes its
  check). The three GUI files above: 46 of 46.
  Pushed on origin/main e62a1bc51. Its 6 commits since touch routing,
  sessions and rex files only, none of these, and weren't run here.
Not run before the tag: the whole GUI suite and the full go test of
gateway, gui and settings. They are queued behind other sessions'
suites on mote and run after the push; any red they find gets its own
commit.
Not tried: a real relay or a real searcher failing in the GUI app.
2026-11-01 14:43:18 +08:00
yetone 0516c18ca3 gui: writeJSONRows hands the encoder each row by pointer
Every Sessions poll encodes all ~17k rows for their hashes, even when
the page already has the answer. enc.Encode(rows[i]) boxed each row
into an any, a copy allocated per row per poll. &rows[i] encodes the
same bytes (no type in sessionJSON has a pointer-receiver marshaler)
without the copy.

TestJSONRowsNotCopiedEach: a 2000-row poll the page already has makes
at most 200 allocations. Broken by hand (back to rows[i]): red, "made
2022 allocations". TestWriteJSONRowsWritesWhatMarshalDid still checks
the bytes against json.Marshal per row.

Measured on mote's build against the real ~17k sessions (sandbox HOME,
APFS clones), 30 polls, heap diff alloc_space:
  writeJSONRows   201 MB -> 98 MB
  whole poll      854 MB -> 726 MB
CPU over 30 polls 4.46s -> 4.44s (no change past noise); /api/sessions
median 74ms -> 73ms.

Run on mote: go test -run JSONRows ./internal/gui ok.
Not run: the full suite (one-line change in writeJSONRows, its tests
run).
Then rebased onto 586b59fe7 (provider: Devin's plugin min); not rerun.
2026-11-01 14:26:03 +08:00
yetone 8d8df06399 plugin, gateway: a plugin reports its models' load, and busy models can go last (axelburks on Discord)
axelburks (Discord #feedback): an in-house vendor queues requests to
its busy models, and the plugin could only put the load in the model's
name, which changed only when magpie re-read the list.

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

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

Not run before the push (owner: push and tag first): go test ./...
-timeout 45m and the whole GUI suite. mote and the WSL box were each
running another session's full suite. Both run next, and any red gets
its own commit.
Not tried: a real plugin and vendor reporting load. The plugin side is
tested through the real Bun host with a plugin written in the test.
2026-11-01 13:45:40 +08:00
yetone 90c02326bb gui: an app takes the gateway over from its older copy once idle, and says any other version serving it (matrix0487)
matrix0487 on Discord: after an update, pi said 404 'magpie knows no
model "kimi/k3.1-pro" ... add a provider in magpie first'. The app had
written pi a model its older gateway didn't know, and updating the
gateway fixed it. A magpie that finds another one serving the gateway
used to log it and wait for that one to quit (watchGateway took the
port only once nothing answered). Only the Gateway page said so.

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

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

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

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

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

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

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

Not tried: the whole GUI suite (mote was running another session's
full suite), a real app with a real agent stream in flight during the
take-over (the Go test holds a stream through a fake), Windows and
Linux apps (the replace path needs handoverHost, set by the app's Run
on every OS, but it was tried on macOS only).
2026-11-01 11:43:56 +08:00
yetone 699ddf1524 gateway: a Codex account can spend its credits only after every other account, key and fallback (gokoshiki on Discord)
gokoshiki wants a Codex subscription first, then an OpenAI API key, then
the subscription's credits. Until now an account at 100% that holds
credits either kept its place and spent them there (on) or was held
(off). This adds a third way per account, "last":

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

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

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

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

Not tried: a real ChatGPT account at 100% with credits beside a real
OpenAI key; the order is shown with the gateway's fake Codex backend.
2026-11-01 09:08:07 +08:00
yetone d307aa6485 gui: /api/state is written one agent at a time, for the page and the kept sum at once
Each poll of the Agents page encoded the whole state (1.3 MB with real
accounts) into json's buffer, and the GC between polls empties the pool
that buffer comes from, so it grew to the state's size again each poll:
48 MB of what twenty rounds allocated (v0.1.2477 build, real-account
sandbox), and 68 MB at v0.1.2463.

writeStateJSON encodes the state without its agents twice (as sent, and
as keepState keeps it, without the settings), and each agent once,
straight to the response and to keepState's sha256, through one encoder.
keepState is split so the handler hands it that sum (keepStateSummed).
When the splice can't be made (no agents, or a field put before
"agents"), it writes and sums the state whole, as before.

Measured on this Mac with the real-account sandbox (abr.sh, 20 rounds of
drift + state + providers):
- v0.1.2477: writeJSON under /api/state 48 MB, 511 MB in all.
- this change: writeStateJSON 15 MB, 477 MB in all. The /api/state
  bytes are identical to v0.1.2477's (cmp).

Run on mote (mote-run, Go 1.26.8):
- gofmt clean; go vet ok, also GOOS=windows.
- TestStateWrittenAsEncoded (same bytes as Encode, same sum as keepState,
  for a large state, an empty agent list and none) and
  TestStateWriteGrowsNoBufferItsSize, with TestKeptState* and TestLast*:
  ok 3 of 3.
- Broken by hand (the whole-state path always taken): red, "writing a
  1614586-byte state allocated 4207139 bytes, want under half its size".
- Not run before this push: the full internal/gui package; it runs next.
2026-11-01 05:12:20 +08:00
yetone d9845432f7 gui: a same-tagged answer is written twice, never held whole (#2278)
writeSame wrote each answer into a buffer to hash and send it, and kept
two such buffers between polls (answerLinger). The Sessions tab's stats
answers are ~6 MB each over a full history, so 12.5 MB of a warm start's
169 MB live heap was those buffers (heap profile, bytes.growSlice under
statsAnswer). Now write is given an io.Writer and called twice: once into
the hash for the tag, and once straight to rw (32 KB bufio) when the page
hasn't got that answer. statsAnswer encodes a part at a time into a small
buffer. The stats route still answers "same" from its kept tag without
encoding at all when nothing changed, so the second encode costs only on
a changed answer. answerBuffers, answerBuffer, keepAnswer go.

Run on mote (M5 Pro), from this tree:
- go vet ./internal/gui ok; gofmt -l clean.
- go test -count=1 ./internal/gui: FAIL only TestSettingsSaveKeepsWhatItDoesNotSend
  (#4514) and TestMainWindowCorners/macOS_26_SDK (#3949), both filed, both
  untouched by this change. TestStatsAnswerWritesWhatEncodeDid (bytes are
  the whole Encoder's) and the new TestSameAnswerNotHeldWhole pass.
- Broken by hand: writeSame's bufio sized 64 MB, TestSameAnswerNotHeldWhole
  red ("allocated 67117776 bytes for a 4194304-byte answer").
- Warm start on a copy of the owner's real history (11,925 Codex .zst,
  4,696 Claude .jsonl, 5,000 listed sessions), the page's 10 reads every
  5s, interleaved, load ~25-34:
    before (bb5eb83c3): footprint peak 267, 269, 274 MB; cpu 9.6-10.1s
    after:              footprint peak 255, 257, 258 MB; cpu 9.9-10.2s

Not tried: a cold start A/B (the buffers matter once polls begin).
2026-10-31 20:31:26 +08:00
yetone bb5eb83c3e gui: the Sessions list goes out a row at a time, never held whole (#2278)
writeJSONRows built the whole answer in a buffer to hash it and send it.
Over the owner's full history (16,600 sessions, 5.8 MB list) that buffer
grew to 25 MB, was kept between polls, and was 25 MB of a warm start's
183 MB live heap. Now a first pass encodes each row into one small
buffer for its hash and the answer's tag. What is sent is encoded again,
straight to the ResponseWriter through a 32 KiB bufio.Writer, and a delta
holds only the rows the page hasn't got. The bytes and the tag are the
same as before, so the page's delta and "same" answers don't change.

Run on mote (macOS 27), real history copy (~16,600 session files):
- warm start, 75 s of poll.sh (what an open window asks every 5 s):
  - before (v0.1.2382): steady footprint 240-265 MB, live heap 183-193 MB;
  - after: steady footprint 216-233 MB, live heap 168-178 MB.
  - The phys_footprint peak is about the same (257-267 vs 264-289 MB over
    3 interleaved pairs): a poll's own spike still sets it.
- /api/sessions from each binary on the same history: the same tag
  06a661d3…, the same sha256 of 5,842,606 bytes, X-Magpie-Same on its
  tag, and the full list for an unknown tag.
- TestJSONRowsNotHeldWhole is new: red on the old writeJSONRows (9.5 MB
  allocated for a 4.2 MB answer), green now. TestWriteJSONRowsWritesWhatMarshalDid
  (bytes and delta) is green.
- go test ./internal/gui: ok except three reds that are already filed.
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners
  (#3949) are red the same way with the old api.go in the same copy.
  TestColdTurnsTaken (#4510) was red in the full run and passed 3 of 3
  alone.
Not run: the GUI (Playwright) suite. app.js isn't touched and the
answer's bytes are the same.
2026-10-31 20:15:15 +08:00
yetone a7b47d57ec accounts: removing the account Claude Code is signed in to switches it to another first (#4532)
StringKe (#4532): removing the signed-in Claude account was refused with
SignedInError, while Codex's switched away first. ForgetLogin now does
the same for Claude Code: nextOnForget picks another account (on first,
then one whose sign-in holds), SwitchLogin signs Claude Code in to it,
and only then is this one forgotten. If that switch fails, nothing is
removed and the error says why.

nextOnForget leaves out accounts Claude Code or Codex can't be signed in
to (switchable: not a setup-token account, not a Codex account held in
another folder). Claude Code is never signed out: when the account is
the only one it can be signed in to, it is kept, with
SignedInError{Only} (GUI code signed_in_only), which says to add another
account first or sign out in Claude Code. The GUI gives the signed-in
Claude row a Remove when another account it can use exists, and no
Remove or Sign out otherwise. Claude Code's own credential is never
deleted; forgetClaudeDir removes only the forgotten account's own
folder and its folder's Keychain item, and claudeHolders' check of
other records holding the same token is unchanged.

Tests: TestForgetLiveClaudeSwitchesFirst, TestForgetOnlyClaudeIsKept
(replacing TestClaudeInUseStillRefused, which held the old refusal);
codex-signout.test.cjs gets three Claude cases (Remove with another;
only + setup-token: no Remove, reason in zh/zh-TW/ja/de; the
signed_in_only refusal in en/zh).

Run (mote, sandbox HOME through the test helpers):
- go test ./internal/provider ./internal/cli, vet and gofmt at the
  stack head: in the next commit's body (one tree, same run).
- Broken by hand, each red: Claude not switched first
  (TestForgetLiveClaudeSwitchesFirst), Only left false, a setup-token
  account counted as another, nextOnForget unfiltered
  (TestForgetOnlyClaudeIsKept).
- GUI on Linux (WSL magpie-desktop), Chromium and WebKit: codex-signout,
  own-signin-remove, saved-signedout-remove, login-import, claude-signin,
  account-alias and i18n-keys all pass but i18n-keys' "a plugin's words
  are its own", red on main (#4524). On mote, codex-signout passed in
  Chromium; its WebKit launches were killed with mote at load ~25 under
  other sessions' suites (#4125), so WebKit's record is Linux's.

CLI in a sandbox HOME (WSL, file credentials): forget of the signed-in
account by its name switched Claude Code to the other (.claude.json then
says max@x.com); forget of the only one was refused with the message
above and left it signed in.

Not tried: a real Claude Code switch on removal with real accounts, or
in the CLI against a live ~/.claude (sandbox only).
2026-10-31 18:18:37 +08:00
yetone ceeb73a0f1 app: the desktop app writes its log to app.log; magpie log and Settings › About › Log find it
rayem1w on X (0.1.2330, macOS) was asked for ~/Library/Logs/magpie/serve.log
while chasing a Codex "hit a snag" through the gateway, and had no such
folder. Only the launch agent (magpie daemon install, written by launchd)
and a gateway magpie tui left running wrote a log; the app opened from the
Finder, the Dock or the Start menu logged to a stderr nobody reads, on
every system.

Now runGUI and runPanel (magpie, app, tray, panel, a window view, a
magpie: link) call applog.Start before gui.Run. It sends the standard
logger (the gateway, the plugin host, providers and Wails' error handler
all log through it) to app.log as well as stderr, and points
debug.SetCrashOutput at it so a panic's trace is there too:

  macOS    ~/Library/Logs/magpie/app.log
  Windows  %LOCALAPPDATA%\magpie\logs\app.log
  Linux    $XDG_STATE_HOME/magpie/app.log, else ~/.local/state/magpie/app.log
  portable data/logs/app.log

app.log, not serve.log: on a Mac launchd writes serve.log for the service,
another process. The file is 0600. At 5 MiB it becomes app.old.log (two
files at most); when another magpie (an update's new process) rotated it
already, it is only opened again; when it can't be moved it is emptied.
stderr goes first, through a writer that never fails, since io.MultiWriter
stops at a failed writer and an app opened from Explorer has no stderr.

Secrets: the log calls name header names and paths without queries; no
key or token was found logged (grep of log.Print* in gateway, provider,
plugin, gui, agent). scrub masks bearer/basic credentials, key/token query
parameters and sk-, AIza, gh?_ and JWT shapes anyway.

How a user finds it: Settings › About › Log, with the path, Copy and an
Open that shows its folder (POST /api/settings/log/reveal; the row is
hidden in magpie web, which writes no file). magpie log prints where every
log is (the app's, app.old.log, the service's, the tui's background
serve.log); --path the app's alone, -n N its last lines, -f follows it
across a rotation. Docs: reference.md, gui-shell.md, site start (FAQ "Where
is magpie's log?" and the CLI table) and privacy (files on your computer),
en/zh/ja.

Run:
At 227ce6074 on origin/main fbb1b36d1:
- mote: go test ./internal/applog ./internal/appdir ./internal/cli ok;
  -run TestCoreScriptBudget ./internal/gui ok; GOOS=windows go vet
  ./internal/... and GOOS=linux go vet -tags nogui ./internal/... ok;
  gofmt -l clean. GUI, chromium: about-log (5 languages x 1100/420, and
  no row without a log), about-website, i18n-keys: 24 of 25, the one red
  "a plugin's words are its own" ("Unmarked") is the same at origin/main
  fbb1b36d1 (#4524).
- WSL (magpie-desktop), webkit: about-log and about-website 21 of 21.
- Windows (win-run): applog, appdir, tui ok; cli ok but
  TestLibraryMCPHub's TempDir cleanup (#4140, mcp-npm, not this change).
- WSL full go test -tags nogui -timeout 45m ./... at the previous base
  03f609e3f: every package ok but reds that fail the same at origin/main
  03f609e3f alone: TestSettingsSaveKeepsWhatItDoesNotSend (#4514),
  TestNoCommandBypassesProc (#4491), internal/agent's install-detection
  tests (#4033, #3548), and TestCoreScriptBudget, which was this change
  (app.js 321 over): its comment is cut to one line and both budgets
  are raised by the remaining 124 bytes, with no room added.
- Broken by hand: with startLog left out of runGUI, TestTheAppWritesItsLog
  is red ("app wrote no log: open .../Library/Logs/magpie/app.log: no such
  file or directory"); with proc.UserPath taken out of openApp,
  TestGatewayStartsGetUserPath is red ("runGUI doesn't call
  proc.UserPath"). The guard now follows a start into a function or func
  var of this package, since the Wails start sits behind openApp for the
  test.
- Real use on mote: the GUI build, magpie app in a sandbox HOME, wrote
  ~/Library/Logs/magpie/app.log (0600) with its "started" line; magpie
  log and magpie log -n 3 printed it.
Not tried: the app opened from Windows Explorer or a Linux desktop
launcher for real (the paths are unit-tested per OS, the writer on
Windows and Linux); the full GUI suite (running on WSL after the push,
reds filed if they fail at origin/main too).
2026-10-31 14:45:22 +08:00
yetone b09349d179 search: magpie can search for a model whose provider searches by itself too
cybercaius on Discord: "能否强制支持联网搜索的供应商模型走代搜 API". Nothing
did this before: a provider that searches by itself (Codex, Copilot and
Grok accounts on Responses, a relay marked Searches, the search hosts) was
always sent the client's web_search, and "provider search off" and
"Search APIs first" only order magpie's own search.

Settings › Models › Web search gets one row, "Models that search by
themselves": their own (as before, the default) or magpie's. On,
settings.SearchAll makes magpieSearches true while magpie can search
(canSearchFor), so searchedForIt and translate treat the model as one that
can't search: the searcher and the search APIs answer, and the provider is
sent no search tool. With nothing magpie can search with the provider keeps
its own, and the row isn't shown. magpie's own searcher request
(searchingKey) is never turned around. The value is set on its own
(POST /api/settings/search-all) and carried by a save of the rest of the
page, so app.js is unchanged and the core budget holds. With provider
search off and this on, the searcher's note says the APIs answer every
model.

Run:
- go test -run Search ./internal/gateway ./internal/settings; ./internal/gui
  TestSettingsSearchAllSetOnItsOwn, TestSettingsSearchProviderOff,
  TestSettingsPageSave*, TestCoreScriptBudget (on mote): ok.
- TestSearchAllTakesTheSearchFromAProviderThatSearches: on with no search
  API, relayed as sent with web_search_20250305; off, native and Tavily not
  asked; on, Tavily asked and no native tool sent.
- go vet darwin, linux, windows on gateway and settings, windows on gui; gofmt.
- GUI: search-all (new), search-first, searcher-pick, search-order,
  i18n-keys in Chromium (47 pass), en zh zh-TW ja de, 1100 and 560px.
  The WebKit run was still going at the push (owner: ship at once); any
  red it shows is filed.
Broken by hand: magpieSearches returning false, and without the
canSearchFor guard, the gateway test goes red; without the merge line in
api.go TestSettingsSearchAllSetOnItsOwn goes red ("a save of the page
dropped searchAll"); the old settings.js and i18n fail 15 of 20 GUI cases.
search-first now reaches its row before clicking, since the new row moved
it below the fold.
Not tried: real Codex, Copilot or Grok accounts with it on. Codex sign-in
turns relayed as sent (codexAsSent) and sealed relays keep the native
search; the Routing page's webSearchOf still says native.
2026-10-31 10:33:50 +08:00
yetone 9345318ff7 gui: Codex's Long conversations lines fit the core budget, no raise (zgjfjfl on Discord)
5c637f17b raised the core script budget from 1,537,356 to 1,537,669 for
Long conversations' two Codex lines. Size budgets are never raised, so
this puts it back at 1,537,356 and makes the lines fit under it. The
core is 1,537,351 bytes now, 314 less than at 5c637f17b.

- The server writes the config key list as the row shows it
  ("[profiles.work] key = value, ...", codexKeysText) in
  codexCompactKeys, where the page built it from codexCompactHeld's
  objects. The window's size comes formatted too (tokensSize, "128K"),
  under the "n" slot of the row's words, so the page passes the struct
  to t() whole.
- The two lines go through one helper. Their English words are shorter:
  "Codex's config.toml sets {keys}, read before Long conversations" and
  "Codex compacts {model} at 90% of its {n} window, before Long
  conversations; set a larger one in its provider's Context window". The
  zh, zh-TW, ja and de translations keep their words under the new keys.
- The row draws the same lines, button and drop as before.

Run, at origin/main a808c31a7 plus this change:
- mote-run: node --check app.js; go vet -tags nogui ./internal/gui for
  darwin, linux and windows; go test -tags nogui -run
  'TestCodexCompactHeld|TestCodexWindowUnder|TestCodexKeysText|
  TestCoreScriptBudget|TestI18n' ./internal/agent ./internal/gui: ok.
  gofmt -l: clean.
- wsl-run (mote's Playwright WebKit launch hung earlier today):
  codex-compact-held, i18n-keys, codex-async-compact, compact-at and
  compact-one-value: 64 of 64 ok, Chromium and WebKit, every language.

Broken by hand: codexKeysText without the profile turned
TestCodexKeysTextAndSize red with the profile missing from the line.

Not tried: the real app with a real config.toml after this change; the
full GUI suite.
2026-10-31 09:17:24 +08:00
yetone 5c637f17b2 gui: Long conversations says what makes Codex compact before it (zgjfjfl on Discord)
zgjfjfl set Long conversations to "Compact at 544K", and Codex still
compacted every conversation at about 128K. The model is gpt-6-A, with no
context size set on the provider, on v0.1.2281.

Codex 0.165 compacts at min(model_auto_compact_token_limit, 90% of the
window). magpie writes the model's window into the catalog and writes
auto_compact_token_limit only when Long conversations is below that
window. Two things put Codex under 544K, and the row said neither:

- ~/.codex/config.toml's model_context_window or
  model_auto_compact_token_limit, at the top or in a profile, which
  Codex reads before magpie's catalog. The row now names each key, with
  its profile and value, and "Take it out" removes those lines
  (agent.CodexCompactHeld, DropCodexCompactHolds,
  POST /api/settings/codex-compact-held/drop). Nothing is removed unless
  the user clicks.
- The model's own window. gpt-6-A isn't in models.dev, so its window
  comes from the provider's own /models list (context_length). A relay
  that lists it at 128K makes Codex compact at ~115K, and no Long
  conversations value can raise that. The row now names the model Codex
  runs (agent.CodexModel, from config.toml's model and the picked
  profile) and the window magpie tells Codex, and says a larger one is
  set in the provider's Context window (codexWindowUnder).

Which of the two the reporter has is not known: their config.toml and
their relay's list weren't seen.

Run (worktree at origin/main a6951cc63, through mote-run):
- Real Codex 0.165 against a fake Responses server in a sandbox HOME:
  config.toml model_context_window = 128000 made it compact at ~115K
  with Long conversations at 544K; with the key taken out it didn't.
- go test -tags nogui -run 'TestCodexCompactHeld|TestCodexWindowUnder|
  TestCoreScriptBudget|TestI18n' ./internal/agent ./internal/gui: ok.
- go vet -tags nogui for darwin, GOOS=linux and GOOS=windows on
  internal/agent and internal/gui: ok. gofmt -l: clean.
- node --test codex-compact-held.test.cjs on the Linux box (wsl-run):
  20 of 20 ok, Chromium and WebKit, en/zh/zh-TW/ja/de at 900 and 420px.
  On mote Chromium was 10 of 10 ok; mote's Playwright WebKit launch hung
  at 180s for every test there, beside another session's full GUI suite.
  The first Linux WebKit run was red at 420px in en, ja and de: the test
  took scrollTop before Playwright's click scrolled the button into view.
  The button is now wheeled into view first (reader.cjs reach), and the
  check allows only the browser holding scrollTop under a shorter page.
- i18n-keys.test.cjs: 4 of 4 ok.
- A first GUI run was red in every file: the new block declared `box`
  twice in one function (a SyntaxError), so no row drew. Fixed before
  this commit. A rerun of codex-async-compact, compact-at and
  compact-one-value at this tree was cut short when mote's browsers
  stopped launching; codex-async-compact's five Chromium cases had passed
  by then. That run was stopped, not finished.

Broken by hand:
- CodexCompactHeld without the profile lookup: its test went red.
- codexWindowUnder forced to nil (`if true ||`): red at line 46.
- CodexModel without the profile lookup: red at line 52.
- The window line turned off (`if (false) hb.append`): codex-compact-held
  red in all 10 Chromium cases at the own line's waitFor.

Not tried: a real relay listing gpt-6-A, the reporter's config.toml,
WSL Codex configs, `codex --profile` on the command line, the Codex app.

Core script budget: 1,537,356 -> 1,537,669 for the two lines in Codex's
row, with the comment cut and no room added.
2026-10-31 09:03:01 +08:00
yetone 03d21ab8e1 gui: a page's read and the warm-up collect at GOGC 10, not 25 (#2278)
tightGCPercent goes from 25 to 10. This is the GOGC that underTightGC (the
warm-up's reads) and every /api/sessions* and /api/usage* answer
(held) run under; it is put back once the last read ends.

Profiled on mote (heap dumps at each 8 MB of live heap, plus a goroutine
dump). After v0.1.2280 the first start's reads already take turns, so the
peak is one build at a time over what the indexes keep. The live peak is
~280 MB, and at GOGC 25 Go let the heap grow ~70 MB past that before a
collection.

Bench: the mote sandbox HOME with the real history (13k sessions, ~720k
gateway calls), MAGPIE_NO_STATS=1, a poll of ten answers every 5 s,
75 s per run, footprint peak (phys_footprint_peak):
- cold start (no caches), 3 runs each:
  - v0.1.2280: 397/390/392 MB, 162–168 s user CPU, slowest first answer
    29.8–30.6 s
  - this change: 352/350/352 MB, 197–200 s user CPU, slowest first answer
    31.9–32.4 s
- start with caches, 2 runs each:
  - v0.1.2280: 321/304 MB, 7.6 s user CPU
  - this change: 271/275 MB, 10.3 s user CPU, mean answer 0.12 → 0.13 s

Tried and dropped:
- 10 only until the warm-up ends: cold 372–374 MB, warm 301–306 MB.
- 10 only inside usage's big builds (a holdBigBuild hook): cold
  373–395 MB, warm 304–312 MB. The peaks are not all big builds.
- Warming the heatmap as a fifth warm-up step: cold 395–401 MB, the same.
  The goroutine dump shows the page asks already take their turns.

Run on mote, first at 7f2acb9ff + this, then again after the rebase onto
a6951cc63 (which brought a GLM card fix, the WorkBuddy min and the main
window's footer):
- go vet ./...: ok, at both heads.
- go test -timeout 45m ./internal/gui/ at 7f2acb9ff + this: every test
  passed except TestCoveredWindowStaysUp (#4125).
- The same run at the rebased head: ten real-window AppKit tests were
  killed at their deadlines (dock, panel, tray, titlebar, plugin page,
  covered window). Five of them, run alone on a clean a6951cc63 checkout
  without this change, were killed the same way while another session's
  GUI suite loaded mote. They are filed: #4125, #2645, #1936 and #3178.
- gofmt -l: clean.
Not run: the Linux vet of internal/gui (Wails needs cgo to cross-compile,
and the WSL distro has no gtk4). The change is a constant and comments.
2026-10-31 07:42:25 +08:00
yetone e647a1fd54 plugins: an npm registry of the user's own is used for installs and lookups (timwangdev on X)
timwangdev asked on X for plugins to take a custom npm registry. Zero-config
first: Registry() (internal/plugin/registry.go) takes, in order, the one set
in magpie (settings npmRegistry: `magpie plugin registry <url>|default`, or
Plugins › Discover's new npm registry row), BUN_CONFIG_REGISTRY /
NPM_CONFIG_REGISTRY / npm_config_registry in magpie's environment, then the
login shell's (cached probe only, proc.LoginEnvKnown, never waits on a
shell), install.registry in the plugins folder's or the user's .bunfig.toml,
registry= in the plugins folder's or ~/.npmrc, then the 国内镜像 switch's
npmmirror, then npm's own. The switch no longer puts npmmirror over a
registry the user named: before, bun was handed BUN_CONFIG_REGISTRY=npmmirror
whenever it was on, over the user's .npmrc. bun is told the registry only
where it wouldn't find it itself (magpie's setting, the shell's, the
switch's). magpie's own npm questions (latest version for the market,
Update and the hourly check, README, search) go to the same registry, a
package's @scope:registry= to that scope's, with the .npmrc's
//host/path/:_authToken (${VAR} expanded, longest prefix) sent to that host
alone, dropped on a redirect to another host, never logged or shown.
Download counts stay npm's. Only http(s) with a host, no userinfo, query
or fragment is taken; anything else is refused and not saved, and a bad
value hand-written into settings.json is passed over. /api/plugins says
which registry is in use and where it came from.

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

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

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

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

Not tried: a real private registry (Verdaccio, GitHub Packages, Nexus) with
a real token; a real bun install through one; Windows (the login shell
probe is a no-op there, so only env, bunfig and .npmrc apply).
2026-10-31 04:24:59 +08:00
yetone f03ed8c26e agents: Open in terminal on a Mac's Agents row (coolmantou)
coolmantou on Discord asked to start an agent from magpie's Agents list.
In the Mac app's window, an agent row's menu (openRowMenu, the one the
grip and a right-click open) now has "Open in terminal". This includes a
row under Not set up. Clicking it posts POST /api/agents/open with only
{agent: id}. The server finds that exact id in agent.Detected() (not
agent.Find's prefix match) and builds the line itself: the agent's
Launch() where it has one (agy, Claude Science, Cursor local), otherwise
its program's path, single-quoted (BinPath, new in internal/agent).
openTerminal then opens that line with the user's Session terminal
choice. The command never comes from the page. Other systems, the web
build, WSL agents and desktop apps with no program are refused, and
their rows have no item (agentJSON.terminal). The tray panel's rows don't
have the item either. The label is "Open in terminal", not "Terminal",
because the user's terminal can be iTerm or Ghostty. The string is in
en, zh, zh-TW, ja and de. Windows and Linux are #4474.

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

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

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

Not tried:
- No terminal app actually opened. The scratch run recorded what
  `open` would get instead.
- iTerm, Ghostty and the other Session terminal choices were not tried.
- Launch() agents (agy, Claude Science, Cursor local) were not opened
  for real; their lines were already quoted and used by
  "Copy launch command".
- The full Go suite and the whole GUI suite were started before the
  rebase and not waited on (ship at once).
2026-10-31 01:22:28 +08:00
yetone a45a0f1c5d signin: Settings can keep sign-in pages out of the default browser (max2020)
max2020 on Discord signs in from a separate, fingerprint browser so the
vendor never sees their default one. Every waiting sign-in already shows
its link with Copy link (since 52c8e838d), but magpie still opened the
page in the default browser first.

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

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

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

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

Not tried: a real vendor sign-in from a fingerprint browser; Grok on
macOS/Windows still opens its own page; MCP server sign-ins unchanged.
2026-10-31 01:02:24 +08:00
yetone 995f84a0f9 codex: how early an expiring reset is used is a setting
A Codex reset card that would run out unused was spent 30 minutes before
it expired, a fixed resetExpiryLead. Now the lead is codexResetLead in
settings.json (minutes, 15 to 1440). Unset, out of range or unreadable
reads as 30m, never 0, and magpie never writes it unless the user does.

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

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

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

Not tried: a real Codex account spending a card at a non-default lead;
Windows and Linux runs (vet only). The whole GUI suite in Chromium on
mote has ~45 tests in 31 files crash with "browser has been closed" on
untouched origin/main c84c3e1c0 too (reducedMotion files, #4458).
2026-10-31 00:41:29 +08:00
yetone 7d4a631480 tray: pick which of a subscription's windows the menu bar shows (StrikingRaw on X)
Claude Pro's menu bar card drew its 5-hour and 7-day windows as two
small stacked numbers, and the user wanted one of them alone. Settings ›
Usage › Menu bar windows (under Allowances in the menu bar) lists a pill
per ticked subscription with two or more windows ("Claude Code · All
windows"), opening the app's menu: All windows, then each window. The
choice is settings.TrayWindows, by provider id (every account of it, the
in-use "|*" card too) and by window kind from the span ("5h", "1d", "7d",
"month", "15m", "name:<name>" when the span is unknown), so a vendor
reordering windows changes nothing. Unset shows every window as before;
a pick whose windows are all gone shows every window again, never an
empty card. Only the bar's rows and the Linux label are filtered; the
tooltip still says every window. One row draws at mpRowFont's 11pt
single-row size. Hidden on Windows (its tray shows no text). Per
computer through KeepOwn. The GUI learns kinds from trayKind on
/api/usage/quotas (withTrayKinds; model and aside windows get none). The
row's code is a lazily imported traywindows.js, so the core script
budget is not raised (app.js +4 lines for the call and the prefs keep).

Run:
- mote (macOS): go test -run 'TrayWindow|TrayUsage|WithTrayKinds|
  CoreScriptBudget|AppScript|TrayImage' ./internal/gui/ ok;
  ./internal/settings/ ok; davsync TestSync ok. TestTrayImageOneWindow
  draws through AppKit: Claude's card one line ("42%"), both windows two;
  the PNGs were looked at.
- mote: gofmt -l empty; go vet ./..., GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./... ok; go build, GOOS=linux go build
  -tags nogui, GOOS=windows go build ok.
- magpie-desktop (Linux VM), --test-concurrency=1, BROWSER=chromium and
  webkit: tray-windows (en, zh, zh-TW, ja, de; picking All; hidden on
  Windows / single-window / no cards; 360px narrow), i18n-keys,
  old-webkit, tray-usages, tray-logos, tray-cost, quota-pace: 43/43 each.
After rebasing on ec5571d6f: the focused Go run above, davsync and vet of
the touched packages ok on mote; tray-windows, i18n-keys, old-webkit,
tray-usages 27/27 in chromium and webkit on the Linux VM.
Broken by hand: the row filter in trayCardText off -> TestTrayWindowsPicked
and TestTrayImageOneWindow red; trayWindows out of prefsKeep ->
tray-windows.test.cjs red in every language. Restored, green.
Not run: the full Go suite (owner: ship each verified fix at once; mote
was at load 20-27 under another session's full GUI suite) and the whole
GUI suite. The GUI ran on the Linux VM because mote's browsers crash or
hang under that load (#4125; TestTrayCellClickReleasedPanel is red the
same way on origin/main c84c3e1c0 there).
Not tried: the live app's real menu bar with a signed-in Claude account
(the AppKit drawer was exercised in-process instead); Linux tray label
on a real desktop.
2026-10-30 23:14:08 +08:00
yetone 2ec3453647 gui: the main window opens where it was left (jorbenzhu)
jorbenzhu on Discord: after every update and restart the panel is back in
the middle of the screen. It is the main window: after an update magpie
starts again with `magpie gui <tab>`, and Wails opens a window centred
unless told otherwise. Its size and maximised state were kept; its place
never was (gui-shell.md said "The window's position is not kept"), so
nothing was lost on upgrade, there was nothing to restore. The tray's
panel opens under the tray icon on the Mac and Windows, and where the
click was on Linux, so it is not what moved.

Now settings.WindowAt keeps the window's top left corner (system
coordinates across every screen), per machine like Window (KeepOwn, and
the Settings page's save carries it over). keepAt saves it once a move or
resize has rested 500ms, unless the window is maximised, full screen,
minimised or hidden; settings.Save writes through temp and rename, and an
unreadable settings file is left alone. On the first show placeMain puts
it back (putBack): openAt picks the screen holding most of the window and
moves it fully onto that screen's work area; when no screen holds any of
it (a monitor gone) or the screens or the file can't be read, it stays
centred. Under Wayland a window can't place itself, so nothing is kept or
restored there unless GDK_BACKEND is x11 (keepsPlace).

Run:
- mote, at 3f8f1d88b (on d99e213f5): go test -timeout 45m -count=1 ./...
  80 packages ok; internal/gui red only in its 10 real-window AppKit
  tests (TestDockJoinLeadsCommandTab, TestPanelCloseHidesIt,
  TestPanelJoinsFullScreenSpaces, TestPluginPageLoadsItsFilesInTheWindow,
  TestDockReopenKeepsTheWindowsSpace, TestMainWindowCorners,
  TestMainWindowRightToLeft, TestHandoverLeavesTheMenuBarIconForTheNextMagpie,
  TestTrayCellClickReleasedPanel, TestCoveredWindowStaysUp), each killed
  at its deadline. The same 10 fail the same way on origin/main
  fa427216a: mote has no console session (#4125).
- mote, after rebasing onto 024393fbb (two gateway commits, none of
  these files): internal/gui (less the 10 above), internal/settings and
  internal/gateway: ok.
- mote: gofmt -l; go vet ./internal/gui ./internal/settings; GOOS=linux
  go vet -tags nogui ./...; GOOS=windows go vet ./...; go build, and
  GOOS=windows / GOOS=linux -tags nogui builds: clean.
- Windows (win-run) and Linux (wsl-run, -tags gtk3): TestOpenAt,
  TestSettleAt, TestKeepsPlace, TestOpenSize, TestSettle*,
  TestSettingsSaveKeeps*, TestWindowMaximisedKeptAndOwn: ok.

Broken by hand (each red, then restored):
- api.go not carrying WindowAt over a Settings save:
  TestSettingsSaveKeepsWhatItDoesNotSend red ("WindowAt: [] after a save
  of the Settings page, was [-1440 120]").
- KeepOwn not keeping WindowAt: TestWindowMaximisedKeptAndOwn red.
- openAt without the clamp and the gone-screen check: TestOpenAt red in
  7 of 12 cases.

Real app, Linux X11 (magpie-desktop, Xvfb 1920x1080 + xfwm4, sandbox
HOME/XDG dirs, MAGPIE_ADDR 127.0.0.1:3447, gtk3 build of this tree):
first start centred (630,240 in X terms); xdotool moved it to 200,150 and
settings.json got windowAt; restarted, it opened at 200,150; windowAt
[5000,4000] (a gone monitor) opened centred; [1700,900] opened at
[1260,480], flush with the bottom right (660x600 + GTK's 26px shadow).

Not tried: the real app on macOS (mote has no console session, #4125)
and on Windows (a sandbox magpie.exe rewrites HKCU\Software\Classes\magpie,
which points at another session's build there). Wayland is not restored
by design. Multi-monitor setups with mixed scaling were not tried on real
hardware; openAt's cases cover a second screen left of and right of the
main one.
2026-10-30 21:56:29 +08:00