Commit Graph
8384 Commits
Author SHA1 Message Date
yetone 3f7e52bbb7 gui tests: usage-fold wheels a fold above Scroll to top's floater (#6003)
"several accounts: one in full, the others in brief" was red in WebKit
(en and zh) since d5dc8eecc (11-02) added the Scroll to top / bottom
floater: wheelTo stopped once the fold was above the 300px window's
foot, and at that height the floater, shown once the page scrolls, sat
over Codex's second fold, so the click was caught by .ve-up ("intercepts
pointer events", 11 retries). It now stops above the floater's top, as
a reader clicks what isn't under it.

Run on mica at origin/main 60ebaea03 plus this file: the "several
accounts" tests, chromium and webkit, en and zh: 4 of 4 (before: both
webkit red). The "17 subscriptions" reds of the same issue are another
cause, still open on #6003.
2026-11-15 14:55:26 +08:00
yetone 02f1cee794 plugin: a plugin installs the vendor CLI it signs in through (niuniu_8964 on X)
agy-cli signs in and serves requests through Google's agy CLI. In magpie's
Docker image there is none, so its sign-in failed with "agy CLI not found"
and the user had to get a shell in the container and install it by hand,
where it lived outside the volume. Claude's sign-in already installs
claude when it is missing ("Installing Claude Code…"); a plugin had no way
to say it needs a CLI.

A plugin now declares its CLI as auth.cli = {name, manual, installed(),
install({signal})}. The host lists it as Provider.CLI and answers two new
calls, cliInstalled and installCli (run through the provider's proxy, and
given up when magpie gives up). pluginCLI returns that CLI when it isn't
installed, so the plugin's sign-in goes through the same "installing"
state as Claude's: the Providers sheet shows "Installing Antigravity CLI…",
then the sign-in link; a failed install names its cause and the plugin's
manual command. `magpie plugin login` does the same in a terminal. An
answer magpie can't get (host down, a timeout) counts as installed, so a
plugin is never reinstalled for a failed read.

The agy-cli side (installing agy into the data folder, which is on the
container's volume, and keeping that copy current) is in
magpie-community/plugins.

Run, at this head (rebased on 60ebaea03), on mica:
- go test ./internal/cli ./internal/plugin ./internal/provider ./internal/gui: ok
- GOOS=linux (-tags nogui) and GOOS=windows go vet of plugin, provider, cli: ok; gofmt clean
- TestPluginSignInInstallsItsCLI red on the old pluginSignIn (no CLI found,
  straight to waiting), green now. TestPluginInstallsItsCLI covers the host
  calls: listing, a refused install, an install given up, a good one.

Real use, magpie's Dockerfile built on xiaomi-gpu (Docker Desktop, linux
amd64), volume on /config, agy-cli loaded from its working tree:
- `magpie plugin login agy-cli 1`: "Installing it…", agy 1.5.9 downloaded
  to /config/data/magpie-agy-cli/agy, then agy's Google sign-in link.
- restart: agy still there and runs.
- `magpie web` in the container, agy removed, POST /api/plugin-signin:
  state installing ("Antigravity CLI"), then waiting with the link.
- agy.version set back to 1.5.0 and restarted: the plugin updated its copy
  a minute later.

Not tried: finishing a Google sign-in in the container (no keyring there;
agy-cli's file sign-in is the path), a real install on macOS, Windows or a
musl Linux, and the full suite.
2026-11-15 14:52:48 +08:00
yetone 60ebaea033 claude: the newest Claude Code on the machine runs, and an old one's sign-in says it is too old (zi_xiang5806 on X)
zi_xiang5806's in-magpie Claude sign-in ended "Sign-in didn't finish":
the claude magpie ran was an npm 2.1.38 first on PATH, which has no
`auth login --claudeai` ("error: unknown option '--claudeai'"), while
`claude update` had installed 2.1.325 into another Node after it.

- proc.FindTools lists every `claude` (each PATH folder, then where
  installers put it), deduped by real path, cached like FindTool.
- claudecode.Own (behind claudecode.Find, so the sign-in, the gateway's
  bridge, bili, keep and `magpie claude-code` all get it) runs the
  newest. The first on PATH is passed over only for one whose version
  is known and newer; an unreadable version is unknown, not old.
  Versions are read first where each is installed, running nothing
  (npm package.json via proc.PackageVersion, the native installer's
  versions/<v>, Homebrew's Caskroom/claude-code/<v>); only when one is
  known that way is another asked --version (VersionOf, kept per file
  until it changes, an unknown for a minute). With one claude, or none
  known, nothing is run.
- A sign-in whose claude says "unknown option"/"unknown command" now
  says Claude Code is too old, with its version and path, and to run
  `claude update` (or npm install -g @anthropic-ai/claude-code@latest).

Tests: TestClaudeSignInRunsTheNewestClaudeCode and
TestClaudeSignInSaysClaudeCodeIsTooOld put two fake npm-layout claudes
(2.1.38 first, 2.1.325 second) on PATH in a sandbox HOME; both were red
with Find reverted to the first on PATH (the first with the reporter's
exact "unknown option '--claudeai'"). TestOwn*, TestInstalledVersion,
TestFindTools.

Run at base 96d1b93b2 (the 5 commits rebased over touch none of these
files): full `go test -count=1 -timeout 45m ./...` on mote, 101 ok,
exit 0 (internal/gateway ok 1036s; an earlier version that ran
--version on every candidate turned ~20 gateway Claude bridge tests red
through their fake claude, which is why nothing is run when no version
is known where it is installed). claudecode, proc and provider
TestClaudeSignIn also ok on wsl-run (Linux) and claudecode on win-run;
GOOS=linux and GOOS=windows go vet of proc, claudecode, provider ok;
gofmt clean.

Not tried: a real sign-in with a real old CLI and account; WSL's
too-old message; the Agents page still shows the first on PATH.
2026-11-15 14:30:16 +08:00
yetone 8f2136fab6 lessons: a "seen again" is still not work on it (#5052, #6003) 2026-11-15 14:26:32 +08:00
yetone 17d230d65f gui tests: account-eye reads an eye again when a re-render replaced its card (#5052)
The Usage card test's first read, opacity(card(ME).locator(".acct-eye")),
came back '' in Chromium under parallel runs. Instrumented on mica, every
such read was of a button no longer in the document (isConnected false,
an empty computed style): a re-render replaced the card between the
locator's resolve and the evaluate. The helper now reads again, which
resolves the locator afresh, until the element is attached (at most 21
reads; it never waits a fixed time).

Run on mica at this head (origin/main 2e1c0a377 plus this file), 8
parallel runs of account-eye.test.cjs, both engines:
- before: the Usage-card test alone, 8 runs, 32 of 40 red at line 294;
- after: 8 of 8 runs pass 30 of 30, 240 of 240.

Not changed: why the Usage page re-renders the card once more after
its first .quota-alias shows. That second render is expected (a later
poll repaints), and nothing a user sees depends on the same element
staying.
2026-11-15 14:26:16 +08:00
yetone c2c3e0c6f6 provider: Devin's mover min is 0.1.42, which keeps the picked models when Devin's list can't be read
devin 0.1.42 (magpie-community/plugins 6c6677d0, pushed as part of
b6a99647) marks the snapshot list it serves when neither Devin nor the
devin CLI names the account's models with Symbol.for("magpie.fellBack"),
so the plugin host keeps the account's last good list and the models
picked from it instead of relisting on the snapshot. The class came from
Archivemylife on X (agy-cli: "配置后报存提示成功,再打开还是全部都启用");
agy-cli 0.1.61, doubao-work 0.1.13, inkstone 0.1.6, loomy 0.1.10 and
cloudflare-workers-ai 0.0.6 have the same fix and no mover.
keepMovedCurrent brings every moved Devin user to it.

Run: go test -timeout 45m ./internal/provider/ on mote at this change
(on 2e1c0a377): ok (230s). gofmt -l clean.
npm: registry.npmjs.org's dist-tags latest for
@magpie-community/opencode-devin-auth is 0.1.42 (publish run
43684238864: "+ @magpie-community/opencode-devin-auth@0.1.42"; the run is
red only for middleware-think-tags/system-prompt, plugins#180).
The plugin's own record (red on the old code, the plugins root suite)
is in its commits.
2026-11-15 14:20:25 +08:00
yetone 2e1c0a377b usage: a single-account card folds to its figures, and folded cards are one size (PILIHU2023 on X)
PILIHU2023 asked for a fold on each Usage → Overview card that leaves
only the usage, with the cards all one height and width.

- A card with one account (or one key) and figures to show (windows or a
  balance) now has a disclosure chevron at the end of its head, before
  its ⋯. It reuses the per-account fold (usageAcctFold, usageAccts in
  localStorage), so its state is kept across restarts and its titles
  are the existing ones. Folded, the card keeps its windows' names,
  bars and figures. It drops resets, curves, history, the reading line
  and the auto-reset and credits rows. A plan-only card (OpenCode Zen
  Free) has nothing to fold and gets no chevron.
- Cards with several accounts keep their own folds: each account's
  chevron, and the All N accounts strip's.
- Folded cards are packed to one height: the tallest folded single
  card. A card of several accounts, each in brief, takes whole rows of
  that height. A fully folded page is a grid of one width and one
  height. Open cards keep their natural height, so nothing is stretched
  or clipped (jen_celeus, #860).
- app.js was at its budget with no room. The Usage packing block
  (packUsage and its helpers, about 3.8KB of code) moved from app.js to
  plugins/usage/page.js, which already holds the Usage page's card
  menus. app.js code is now about 3.2KB under its budget. No budget was
  raised.
- The chevron's turn uses --ease-out (cubic-bezier(.23, 1, .32, 1)),
  .15s.

What was run:
- New usage-card-fold.test.cjs: Chromium and WebKit × en, zh, zh-TW,
  ja, de, at 1400, 900 and 400px and after a reload. It folds every
  card and checks they are one width and one height, sit on whole rows
  and don't overlap. It then unfolds two cards and checks they are
  their own height again. Red on origin/main 96d1b93b2 (0 of 1 in
  chromium-en), 10 of 10 on this change.
- usage-fold (one-account case updated), usage-pack, usage-card-fold,
  i18n-keys and go test -run Budget ./internal/gui, on mica after the
  rebase on 45185710e. Everything passed except four usage-fold
  subtests. Those four ('17 subscriptions and 29 accounts' in
  chromium and webkit, 'several accounts…' in webkit en and zh) fail
  the same way alone at origin/main 96d1b93b2. Noted on #6003.
- The first version gave a plan-only card a chevron. That wrapped Zen's
  head at 897px and turned usage-pack's "head's height" check red,
  which is why the windows-or-balance condition was added.
- A 175-file GUI run (the usage-related files and i18n-keys) on mica,
  before the plan-only fix. Only account-eye was red: "a Usage card's
  eye" in Chromium. Eight parallel runs on mote give 1–3 reds each at
  origin/main too, all at the same line. Noted on #5052.
- go test ./internal/gui: ok, before the rebase.

Not tried: the real app (WebKitGTK on Linux, WebView2 on Windows) and
real accounts. Only test fixtures were used.
2026-11-15 14:04:13 +08:00
yetone 45185710e4 codex: Lite requests go without added instructions, and a turn's state stays with its account
legeling567 on X: three ChatGPT Pro accounts behind magpie, Codex on
Astra at high effort, saw frequent 529 "high load", quota spent faster,
and luna replies; CC Switch on the same accounts was fine. Diffed the
official Codex 0.165 against magpie through a recording proxy, both on
the owner's real account (sandbox HOMEs). Two differences:

- Responses Lite (an additional_tools input item, or reasoning.context
  all_turns): Codex sends no top-level instructions and no
  reasoning.summary. codexBody added Codex's full instructions (~21K
  chars) and summary "auto": about 4K input tokens a request more than
  the official client. codexLite now leaves both out; a request that
  isn't Lite still gets them.
- x-codex-turn-state, the backend's routing token for a turn: Codex
  over HTTP sends it back on the turn's next request. Through magpie it
  never was: the pool route didn't hand it to Codex, and Codex over its
  socket to magpie continues a turn by previous_response_id with no
  state. The gateway now keeps the state per account and turn
  (codex_turnstate.go) and sends it on that turn's next request to the
  same account only; a state Codex sends itself goes only to the account
  that issued it. The socket front keeps the last reply's state per turn
  and sends it as the header, and takes it out of client_metadata.

Red on the old code, green now: TestCodexBodyLiteGetsNoInstructions,
TestCodexPoolTurnStateStaysWithItsAccount, TestCodexSocketKeepsTurnState,
TestCodexSocketServed (state left in client_metadata).

Real run (Codex 0.165, gpt-6-astra high, one Pro account, sandbox
magpie built with CodexBase at the recording proxy): request 1 sent no
state and got one; request 2 sent it back and the backend issued no new
one, as with the official client. Neither had instructions or summary;
input tokens ~14.1K-15.5K against the official 15,466 (before: ~19.6K).

Run at this head (run rebased on 8bf9cb99d; pushed on 96d1b93b2, which touches only internal/plugin): go test -timeout 45m
./internal/gateway/ ./internal/provider/ on mote: ok (gateway 961s, provider 144s); gofmt -l
clean; go vet GOOS=darwin, linux, windows on both packages clean.

Not tried: the luna reroute itself (both sides were served gpt-6-astra),
Codex Desktop, three accounts at once, magpie to chatgpt.com over a real
WebSocket (the proxy forced HTTP). OpenAI-Beta: responses=experimental,
which 0.165 no longer sends, is left as is.
2026-11-15 13:56:58 +08:00
yetone 96d1b93b23 plugin: a dist add is judged by the copy Bun leaves, tried again over a broken one
CHENGJIAHEGOXIS on X (Windows, Bun 1.4.4, after v0.1.4229) still couldn't
install @magpie-community/tools-goanyapi from the dist branch: "Unexpected:
failed copying files from cache to destination for package
@magpie-community/tools-goanyapi ... installed ... Failed to install 1
package". 38a90a34c only let a failure over *another* package pass; this one
names GoAnyAPI itself, so the add was refused, and nothing magpie did made
the next try different.

What Bun 1.4.4 does (reproduced, sandbox HOME, its source read in
src/install/PackageInstall.rs):
- A local tarball is installed from its install-cache entry
  <cache>/@T@sha512-<32 hex>@@@1, trusted whole once there. An entry
  missing a file gives a copy missing it, "1 package installed", exit 0
  (macOS on mote and Windows on xiaomi-gpu). Before this, magpie recorded
  that plugin as installed with no index.mjs.
- A copy it can't make still prints "installed", writes the dependency and
  exits 1: a file of the old copy held open without delete sharing on
  Windows gives the reporter's lines with EBUSY; a read-only folder on
  macOS gives EACCES. The reporter's "Unexpected" is a Win32 code Bun has
  no errno for; which one wasn't reproduced (antivirus, a cloud
  placeholder or a transient hold are the candidates).

Now addDist checks node_modules/<name> against the tarball installDist
verified, file by file (.bun-tag and other extras ignored). A copy that
differs is taken out together with Bun's cache entry and its scope link,
and after 2s (distAgainAfter) the add is tried once more. A whole copy is
the package in. One still not whole is errDistPartial, which install never
hands to othersFailed, so the dependency is put back and the plugin isn't
listed. The npm add has no tarball in hand and isn't judged this way.

The fake bun now copies a dist tarball through a modelled cache entry
(.held / MAGPIE_FAKE_BUN_HELD for a copy it can't make, MAGPIE_FAKE_BUN_LOSE
for a file that never arrives); both sandboxes pass BUN_INSTALL_CACHE_DIR.

Run:
- New tests red on the old dist.go/store.go (mote): TestDistAddOverABroken-
  CacheEntry (no index.js), TestDistAddOverAHeldCopy (the reporter's
  error), TestDistAddNeverRecordsAPartialCopy (exit 0 one returned nil).
- go test ./internal/plugin/... on mote at the pushed head (rebased on
  8bf9cb99d): ok 155s. gofmt -l clean; GOOS=windows go vet and GOOS=linux
  go vet -tags nogui of internal/plugin: ok.
- win-run go test ./internal/plugin/ (before the rebase): the new tests
  pass; TestStaleMissingIsUnknownWhileDistUnread (#5351, passes alone) and
  TestPiPackage (#4115, red alone on base dd89f1255 too) red.
- Real Bun 1.4.4, real goanyapi 0.1.1 tarball served as the dist branch,
  through AddExact (throwaway test, not committed): clean add, a cache
  entry with index.mjs taken out, and on Windows a file of the old copy
  held open for 3s (EBUSY, then the second try after the pause) each
  installed, and the plugin loaded under bun (its hooks return 37/50
  tools). A hold of 20s: add fails with Bun's EBUSY lines, GoAnyAPI not in
  package.json and not listed.
- All 105 dist packages' latest tarballs added with real Bun 1.4.4 on mote:
  every copy equals its tarball byte for byte (only .bun-tag besides), so
  the check refuses none of them.

Not tried: the reporter's own machine or its "Unexpected" code; the check
on npm adds (#6736).
2026-11-15 13:41:12 +08:00
yetone 8bf9cb99d4 codex: an account with bought credits goes on on them, heard as Codex hears them
123xtv03k on X (v0.1.4233): Codex alone goes on on an account's bought
credits once its plan is used up; through magpie the account stopped.

Codex itself sends no opt-in for credits. It reads
x-codex-credits-has-credits, -unlimited and -balance from every reply,
the 429 included, and `credits` on the codex.rate_limits event
(parse_credits_snapshot; both bools required). magpie knew of credits
only from /wham/usage, read about once a minute, so the 429 that used a
window up was taken as out, and the rest lasted till the window renewed.

- heardCodexCredits reads the headers on every Codex reply (routed and
  the relay's 429), codexEventCredits the event; an image limit's are
  left out. provider.NoteCodexCredits marks the account's windows and
  allowance on credits and clears Held, so Usage doesn't call it out.
- A rest taken for a used-up window before the credits were known is
  lifted once they are, heard or read (provider.OnCredits, creditsKnown),
  only when the account's "Use credits" is on.
- The relay's hold for an account on credits refused twice is at most
  fallbackCooldown (1 minute), like the routed path's, not till reset.
- No header or flag is sent that Codex doesn't send.

Run (mote, at this head rebased on b466aa280; 79b10c5a9 since touches only LESSONS.md): go vet for darwin, linux
and windows of internal/provider and internal/gateway; go test -count=1
-timeout 45m ./internal/provider ./internal/gateway: ok (provider 137s, gateway 907s). gofmt -l
clean.
Broken by hand: without the heardCodexCredits calls, the OnCredits
registration and the hold clamp, every new gateway subtest but "says
none" goes red.
Not tried: a real account holding credits (the owner's hold none). The
Usage card's balance text still comes from /wham/usage only.
2026-11-15 13:28:34 +08:00
yetone 79b10c5a9a LESSONS: coreScriptBudget rose 29 times in 3.5 days (#2710) 2026-11-15 13:23:52 +08:00
yetone b466aa2803 update: a Daily channel, one release a day that passed its tests, for the app and Docker (fishmagic80 on X)
fishmagic80 on X: Stable is too slow (community plugins need a newer
magpie than it has), every release is too fast, and Docker users have
nothing in between. Daily sits between them.

What it is:
- site/worker.js keepDaily: at the daily cut (20:00 UTC, the quarter-hour
  cron) the newest tag whose commit has a successful Test run and whose
  release has all 17 assets is picked and kept in LEDGER "daily". A day
  with none keeps the day before's; a failed GitHub read writes nothing.
  /api/latest?channel=daily (503 until a pick exists), /download/daily/<p>,
  and an urgent release overlays it as on Stable.
- .github/workflows/docker-daily.yml reads that feed and points
  ghcr.io/yetone/magpie:daily at the picked version's image.
- App: settings.UpdateDaily ("daily"); update.Channel()/Picked() (Stable()
  kept); the feed is asked channel=daily, never falls back to GitHub's
  latest, What's new lists every change since yours. Settings > About >
  Update channel has Every version / Daily / Stable; the version row says
  "Up to date on Daily (· {v} is out on Every version)". CLI: magpie
  update channel [stable|daily|every].
- Words in en, zh, zh-TW, ja, de, on top of 7f832b2f2's 尝鲜版/搶先版/先行版
  for Every version (kept as it landed).
- The channel row wraps its switch under its name when narrow (ja at
  420px was 18px past the window with three segments).
- app.js budget +338: the segment, its line and the two Up to date on
  Daily words, packed to one t() per choice; Settings and renderUpdate
  draw on every window, nothing lazy to move them to.
- Docs: docs/reference.md, site docs (docker, privacy in en/zh/ja),
  llms-full.txt, search indexes.

Red on the old code (a daily-old worktree, then only settings allowing
"daily"): the feed was not asked channel=daily, 40 notes instead of all,
Picked false, notesKey "zh" not "zh|daily", the Daily row showed
"available"; the GUI tests had no Daily segment.

Run on mote at this commit's tree (on origin/main ec1a1a7a5; the Daily pick itself is live on the deployed worker: /api/latest?channel=daily answers 0.1.4171, /download/daily 302s to its dmg):
- go test -count=1 ./internal/settings ./internal/settingsapi
  ./internal/update ./internal/cli ./internal/gui: all ok (TestCoreScriptBudget
  included).
- GUI, chromium and webkit, every language: update-*.test.cjs (22 files),
  i18n-*.test.cjs, settings-search.test.cjs: 554 of 554 pass.
- site: node --test site/*.test.mjs, 132 of 132 (130 before the rebuild).
- gofmt -l clean; go vet darwin, windows (gui/update/cli) and
  GOOS=linux -tags nogui.

Also: site/public/search/*.json and llms-full.txt rebuilt
(search-index.mjs, llms-full.mjs); they still listed Antigravity's old
sign-in after 9cd5f3652, so the two site freshness tests were red.

Filed: #6730, engines.magpie is never read, so a plugin needing a newer
magpie installs on Stable (0.1.3078) and fails without saying why
(page-amp-usage >=0.1.3681, middleware-company-guard >=0.1.3841,
page-day-card >=0.1.3427).

Not tried: a real self-update on Daily, a real docker-daily workflow run,
the whole GUI suite, the worker's unauthenticated GitHub reads under a
rate limit.
2026-11-15 13:10:18 +08:00
yetone ec1a1a7a55 library: import the slash commands the agents already have
miantiao_me on X (after v0.1.4189): 「之前在 Pi 定义的可以导入吗?」. Library ›
Slash commands now has a "Find in agents" card at the top. It reads the
command files each agent already has, from the same places magpie writes
them (Pi prompts/*.md, Claude commands/*.md, OpenCode command/ and
commands/, Gemini and Qwen .toml, Qwen .md, Droid), and lists them to
import, the way Subagents' import does.

- Parsing: frontmatter description plus body; for TOML, description and
  prompt. Arguments go back to magpie's form: Claude's $ARGUMENTS[n] and
  $n (0-based) become $n+1, Gemini/Qwen {{args}} becomes $ARGUMENTS,
  Pi's $@ becomes $ARGUMENTS (${@:N} is left as written).
- Files magpie wrote itself are skipped. The same content in several
  agents is one command; a name with different bodies per agent shows
  "Differs by agent" and one of them is picked; a name the library has
  with other content is "Name taken" and can't be picked.
- An imported command keeps its source agents ticked, and magpie adopts
  each original file byte for byte (Command.Taken): sync writes the same
  bytes at the same path, so the file is never doubled or rewritten.
  After an edit the agent gets magpie's render at that path; a rename
  drops Taken. Taken never leaves the machine (Collect strips it, Put
  keeps the local one).
- API: POST /api/library/commands/probe, and commands/import through
  the library change route. internal/cli's parity test names the probe
  as stage 3, like subagents/probe.
- Docs: docs/subsystems/library.md has the new row.

Run at 039e25752 (on origin/main dd89f1255), on mote:
- go test ./internal/library/ ./internal/cli/: ok. ./internal/gui/: only
  TestCoreScriptBudget red (app.js 10 bytes over), red on main, #6733;
  this commit doesn't touch app.js.
- gofmt clean; GOOS=linux and GOOS=windows go vet -tags nogui ./...: ok
  (at fb01ae2bb, base 028b07b4b; the two later main commits are Windows
  hook code in internal/gui).
- GUI: library-commands-import (new: chromium + webkit, en/zh/zh-TW/ja/de,
  420 and 1100 wide, no sideways scroll, press stays in place),
  library-commands, library-subagents-import, i18n-keys, i18n-en-no-cjk:
  64 of 64.
Earlier, at 1a70f31b6 (base 6af327e2b):
- go test -timeout 45m ./...: every package ok except internal/cli's
  TestEveryRouteHasACommandOrIsNamed, which named the missing probe route;
  fixed here and green since.
- Whole GUI suite (--test-concurrency=8, mote at load 17 to 44 with
  another session's go suite and GUI runs): 26887 pass, 1005 fail in 109
  files, none of them library-commands. The 109 files run alone at
  99719df19 and at origin/main 5bd41301b: 1145/996 vs 1144/997, the
  same tests red apart from language/width variants that flip between
  runs. Recorded on #6709.
Tests use a sandbox HOME with real Pi prompt files from Pi's repo
(internal/library/testdata/pi-prompts). Broken by hand: with syncCommands'
Taken branch off, all four import tests go red ("has a slash command of
its own"); with Put's Taken keep off, TestCommandImportNotCarried goes red.
Not tried: a real Pi install on a live HOME (by rule), or Windows/Linux
runs of the Go tests.
2026-11-15 12:59:12 +08:00
yetone dd89f12556 gui: the no-activate hook's handle is swapped atomically, and the Windows exit doc says what the unhook leaves to endProcess (#6705)
On top of wizd's unhook (#6705, afe3b3ff7, kept as authored with its test): noActivateHook becomes an atomic.Uintptr
that unhookNoActivate swaps to 0, so the three places that unhook
(OnShutdown, the main-thread window's WM_DESTROY, Run's return) take it
off once without a racy read-then-clear. Nothing hooks it again:
hookNoActivate runs its SetWindowsHookEx under noActivateOnce, and
noActivateHooked stays true after the unhook.

07dfd0bb8's endProcess (TerminateProcess on itself) and awaitExit are
kept and the gui-shell doc says why: they still cover the other DLL
detaches, an os.Exit while the app runs (Wails' fatal error, which this
unhook doesn't reach), and an update from a version before the fix.

Exit paths reviewed: Quit (tray, page) runs Wails' cleanup, whose
shutdown tasks run on the main thread (InvokeSync), so OnShutdown
unhooks on the hook's thread before Run returns into endProcess. A
restart to update quits the same way. Wails' SingleInstance os.Exit in a
second instance comes in application.New, before any window exists, so
no hook is on. SIGINT/SIGTERM in the app go to Wails (ownSignals), so
through OnShutdown. The handover's quitBy exitNow is Mac/Linux only.

Run at this tree on base 72e06980e (the rebase onto 028b07b4b adds only
routing JS and docs), on xiaomi-gpu (Windows 11 26200,
Go 1.26.8) through win-run:
- TestUnhookNoActivatePreventsExitDeadlock -count=3: PASS 3/3.
- broken by hand (unhookNoActivate returning at once), at the tree before
  the rebase: unhook and destroy-main both FAIL "process hung in
  ExitProcess (stderr=fatal error: exitsyscall: syscall frame is no longer
  valid ...)".
- go test ./internal/gui: 11 reds. TestCoreScriptBudget (app.js 10 bytes
  over its budget) is red the same on macOS at 72e06980e with no script
  touched here; filed as #6733. The other 10 (TestGatewayHeldByAContainer,
  TestLodyImportHandoff, TestImportStatusUnreadableIsUnknown,
  TestAionUiImportRow, TestCherryStudioImportRow, TestProviderSaveClientCert,
  TestPageAwayLetsStatsGo, TestPluginAgentMissingSaysSo,
  TestGatewayModeStatsNameTheGatewaySessions, TestUpdateThatWontStart) fail
  the same on origin/main 9cd5f3652 run alone there, and are filed in
  #6068 (also #5324, #5928, #6059).
- In the signed-in session (scheduled task /IT, where msctf is loaded):
  TestRestartBySelfAsksNoAttention (window, tray),
  TestRestartBySelfComesBackQuietly and TestUnhookNoActivatePreventsExitDeadlock
  pass.
- A real build (go build -tags production -H windowsgui) run as `magpie
  app` in a sandbox profile (USERPROFILE/APPDATA/LOCALAPPDATA redirected,
  MAGPIE_ADDR :3461, page on :3462) in the signed-in session, quit four
  times through POST /api/window/quit?now=1: each exited in 51-62ms. The
  magpie:// handler it registered was put back afterwards.
On mica: gofmt -l clean, go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: ok.

Not tried: a restart to update of a real build on Windows (needs a staged
update); the wedge itself in a real app (07dfd0bb8's endProcess already
ends the normal quit without ExitProcess, so it can't be brought on at
will); Windows on arm64.
2026-11-15 12:39:32 +08:00
Wizard 7ce93508f0 gui: unhook noActivateHook before process exit on Windows (#6705)
Two full-memory dumps on Windows 11 (magpie.DMP on v0.1.4196 and magpie2.dmp on v0.1.4185) show why ExitProcess throws in exitsyscall and wedges with one thread left (#5922, #6678, #6705):

1. hookNoActivate installs a thread-local WH_CBT hook (noActivateCBT, Go callback #93) on Wails' main thread and never unhooks it.
2. When the process exits through runtime.exit(0) -> ExitProcess (for example from Wails' SingleInstance handover os.Exit, Wails' fatal os.Exit, or before 07dfd0bb8's endProcess), runtime.exit(0) acquires runtime.finlock and enters ExitProcess via runtime.stdcall with g1.syscallsp set.
3. Inside ExitProcess -> RtlExitUserProcess -> LdrShutdownProcess -> RtlpFlsDataCleanup -> msctf!CicFlsCallback -> msctf!SYSTHREAD::DestroyThreadMessageWindow -> win32u!NtUserDestroyWindow, Windows dispatches HCBT_DESTROYWND (nCode=4) to noActivateCBT on the main thread.
4. noActivateCBT calls w32.CallNextHookEx, whose nested Go syscall clears g1.syscallsp = 0 on return. When cgocallbackg then calls runtime.exitsyscall, gp.syscallsp < sp triggers 'fatal error: exitsyscall: syscall frame is no longer valid'.
5. runtime.fatalthrow.func1 calls runtime.exit(2) on the same thread (m0), which attempts to lock runtime.finlock a second time and self-deadlocks forever while still holding Wails' single-instance mutex and WebView2 profile handles.

Fix: unhook noActivateHook (w32.UnhookWindowsHookEx) when Wails' main-thread window receives WM_DESTROY in appWndProc, in OnShutdown, and when Run returns.

TestUnhookNoActivatePreventsExitDeadlock reproduces the exact FLS window-destruction callback on ExitProcess's last thread: without unhookNoActivate the child process throws 'exitsyscall: syscall frame is no longer valid' and wedges with 1 thread left; with unhookNoActivate (or WM_DESTROY on the main-thread window) it exits 0 cleanly.

Fixes #6705
2026-11-15 12:39:32 +08:00
yetone 028b07b4bd routing: a folded fold of accounts on one plan shows its bar in the app (Sdsi134a on X)
Sdsi134a on X: on the Routing stage, "Command Code Plan · 3 accounts" folded
said only "3 available", with no quota, though the accounts are on one plan.
foldQuota (ea1a8ae80, chen2652) was meant to show that figure and bar, but
it never could in the app: cardFor matched only cards whose kind is
"subscription", and /api/usage/quotas sends this computer's cards with no
kind (SubscriptionQuota.Kind is omitempty and set only on a remote magpie's
cards). The tests' fixtures carried kind: "subscription", so they passed.
cardFor now takes a card of this computer whose kind is subscription or
none. This also lets the accounts list's per-account windows (#1833) and
the failed-read line (dd9cd59a1) find their cards in the app.

The fold's figure now also says when its window starts again, the soonest
of the accounts' ("5 hours 40% used · renews in 2 h 10 min"), as an account
row does; no new strings. Hide plans on the groups page
(magpie.routingGroupPlans, f362d3b9a) folds the figure and bar away here
too (plansHidden). Mixed plans: nothing, as before.

Run (base 9cd5f3652; rebased onto 72e06980e, whose new commits touch no
routing or GUI file):
- routing-fold-accounts-together.test.cjs, its cards now in the API's shape
  (no kind), plus the reset and the Hide plans case: 22/22 on mote,
  chromium + webkit, en zh zh-TW ja de, 1100 and 420px. With the old
  client.js: 22/22 red (the figure never appears). With the plansHidden gate
  taken out by hand: 11/11 chromium red ("hidden plans").
- With it, on mica: routing-account-windows, -card-error, -group-plans,
  -free-seat, -groups-page, -pooled-card, -remote-windows, -read-allowances,
  -seat-windows, -wallet-lapse, -fold-all, -folder, i18n-keys,
  i18n-en-no-cjk: 306/306.
- go test -count=1 ./internal/gui/ on mote: ok.
Not tried: the real app with several real accounts on one plan (the owner
has none such); the whole GUI suite.

Reported-by: Sdsi134a
2026-11-15 12:35:22 +08:00
yetone 72e06980eb LESSONS: a new API route runs internal/cli's parity tests (#6724) 2026-11-15 12:30:43 +08:00
yetone 72418591f0 cli tests: POST /api/warm-all is named with warm-now, as stage 3 (#6724)
5bd41301b added POST /api/warm-all (All accounts warms every account in
use) and left TestEveryRouteHasACommandOrIsNamed red: the route had no
command and no name. Its sibling POST /api/warm-now waits for a command
in stage 3; warm-all goes beside it the same way.

Run (mica, at origin/main 62ced98cc): go test ./internal/cli/ ok (43s).
Broken by hand (the line taken out): TestEveryRouteHasACommandOrIsNamed
red, as on 5bd41301b. gofmt -l clean.
Not run: the full ./... suite (a one-line test-table entry).
2026-11-15 12:30:18 +08:00
yetone 62ced98ccd gateway: a Gemini 3+ on an Anthropic or Chat relay is asked a thinking level, never a budget (Mamba_asr on X)
A relay serving Gemini under a host of its own (Mamba_asr's peta-gemini)
was sent Claude Code's thinking budget_tokens as it came on Anthropic's
Messages, the translation's budget from a Chat or Responses effort, or a
Chat client's extra_body.google.thinking_config thinking_budget. Such a
relay passes it on to Gemini as thinkingBudget, which Gemini 4 turns
away ("Thinking budget is not supported for this model. Use thinking
level instead.", #2083). AI Studio, Vertex AI and the translated Gemini
routes already sent thinkingLevel; the relay routes didn't.

geminiLevelBody (gemini_level_body.go), run in passthrough and
forwardTranslated after xaiBody, acts only for a Gemini 3 or later model
id on an Anthropic or Chat upstream:
- Anthropic: thinking enabled + budget_tokens goes as thinking adaptive
  with output_config.effort, the budget bucketed by effortOfBudget
  (<=4096 low, <=12000 medium, else high) unless the request names an
  effort.
- Chat: thinking_config's budget goes as thinking_level (-1: none, 0:
  low), and reasoning_effort is fitted.
Gemini's own OpenAI-compatible API (geminiCompat: AI Studio, or a
proxy on this computer or the LAN) is left alone: it takes a budget,
and the Chat path already fits its levels and asks again on a refused
one (TestGeminiThinkingLevelRefused and
TestPassthroughGeminiMinimalRefused went red until it was left out).
geminiLevelFor fits a level to the model: the catalog's levels where it
lists them, else nothing above high, and medium as high on a Gemini 3
Pro (which takes low and high only, per Google's model docs).

Run (mote, at this head rebased on origin/main):
- TestGeminiRelayAskedALevel: a fake relay that returns Gemini's 400
  for any budget sent to a gemini-4 model. Its 7 Gemini cases are red
  with gateway.go's old body (budget_tokens / thinking_budget / xhigh
  sent as they came); the 3 other cases (claude-sonnet-4-5 budget_tokens,
  gpt-5.5 reasoning_effort xhigh with a thinking_config budget, and
  gemini-2.5-flash budget_tokens) pass on both, unchanged.
- TestGeminiLevelFor.
- gofmt -l clean; go vet ./internal/gateway on darwin, linux, windows.
- go test -count=1 -timeout 45m ./internal/gateway: ok.
  That full run was at 862660144; rebased onto 049073c97 (the
  Antigravity retirement touched internal/gateway), go vet and
  go test -run 'Gemini|Thinking|Effort|Vertex|Anthropic|Relay'
  ./internal/gateway: ok at this head.
- docs/subsystems/gateway-routing.md names the rule.

Not tried: the reporter's real relay, or any real relay. A relay that
doesn't understand thinking "adaptive" will drop it and use the model's
default thinking, which beats a 400. Not covered: a Responses upstream,
plugin routes, and a Chat body's own "thinking" budget field.
2026-11-15 12:27:05 +08:00
yetone 870f16265b gui: Antigravity's and WorkBuddy's icons are sharp in WebKit (no SVG filter)
@lexrus on X: the Antigravity icons (Antigravity, agy-cli) are blurry in
the GUI. WebKit (WKWebView, and Playwright's WebKit) draws an <img> SVG
that holds an SVG filter at one device pixel per CSS pixel and scales it
up, so on Retina the whole icon, its edges too, comes out soft. Chromium
draws it sharp. Antigravity's lobe-icons SVG was 11 feGaussianBlur blobs
under a mask; WorkBuddy's had a blurred yellow glow.

- antigravity-color.svg is rebuilt from https://antigravity.google/favicon.svg
  (same A path and blobs, base #3186FF). Each blurred blob is a circle
  under the blob's own transform, filled by a radialGradient whose stops
  follow a disk blurred by a Gaussian (15 stops, radius 1+3 sigma); the
  irregular blob is an equal-moment ellipse. The A is a vector clipPath.
  Mean difference from the official favicon in Chromium at 256px: 3.9/255
  per channel. The site's copy (site/public/icons) is the same file.
- workbuddy-color.svg: the filtered glow is the same kind of gradient
  circle, clipped to the tile as WorkBuddy.app's own icon is.
- TestIconsStaySharp fails on any <filter>/feGaussianBlur in the GUI's or
  the site's icons, and on a PNG icon under 2x the largest size the GUI
  draws (26px). Red on the old code, naming antigravity-color.svg (both
  copies) and workbuddy-color.svg.
- The tray's mono logo tests cover both icons; the old Antigravity SVG
  drew in the menu bar with a stray line, the new one as a clean A.

Siblings: no other SVG in the repo has a filter or an embedded <image>,
and every PNG icon is 64px or more.

Run (on mote):
- go test -timeout 45m ./... at 705d67efc+this: exit 0, 101 packages ok.
- gofmt -l clean; go vet ./internal/gui; GOOS=linux (nogui) and
  GOOS=windows go vet.
- After rebasing on 9cd5f3652: gofmt, go vet ./internal/gui and
  TestIconsStaySharp|TestTrayImage ok.
- GUI: 345 files (every test naming antigravity, workbuddy, agy or
  icons/, and every skill/library test), both engines: 6557 pass, 267
  fail in 22 files. Those 22 files rerun at head and at the base
  705d67efc, same load: 265 vs 268 fail, the same files and tests red
  at the base; images-codex-one passed in both. Each is filed (#6709,
  #6373, #6559, #6029, #6658, #6372, #6514, #6659, #4097, #6027, #4566,
  #6597, #6353, #6667, #6687, #6668, #5859, #6561, #6003, #5262).
- Before/after renders: the Library Skills page and the icons at 14-26px
  in WebKit and Chromium at DPR 2, light and dark; tray renders.

Not tried: WebKitGTK on Linux, the live app. The site is not deployed.
2026-11-15 12:25:47 +08:00
yetone 049073c979 gui: Settings' update check interval says it is about updates, so "更新" finds it
jen_celeus on X (tweet 2121683828754530565): the row under Automatic
updates was named "Check every" (zh 检查间隔), so Settings' search for
"更新" didn't find it. It is now "Update check interval": zh 检查更新间隔,
zh-TW 檢查更新間隔, ja アップデートの確認間隔, de Update-Prüfintervall.
The saved updateEvery and its choices are unchanged.

settings-search now types the language's word for update (update, 更新,
更新, アップデート, update) and needs the interval's row shown under
About; with the old zh label it is red ("更新" finds the update check's
interval), checked by putting 检查间隔 back. update-auto finds the row by
its new name.

Run at 658af9118 (this stack on origin/main 9cd5f3652), mica via
mica-run (mote was over its load): node --test of the 45 files
i18n-*, gui-* (zh-TW, ja, de), update-*, about-*, settings-*, Chromium
and WebKit, every language: 897 tests, 885 pass, 12 fail. The 12 are in
settings-groups (#6597), settings-hints (#6107, #6073) and
settings-lines-wrap (#6353); the same 12 fail on origin/main 4aa64500f
alone (56 tests, 44 pass). i18n-keys, update-channel,
update-stable-newest, update-auto and settings-search pass in both
engines and every language.

Not tried: the real app; the whole 1,500-file GUI suite.
2026-11-15 12:24:47 +08:00
yetone 7f832b2f2b gui: the every-release update channel is 尝鲜版 in Chinese, 搶先版 in zh-TW, 先行版 in Japanese
sufunds on X (tweet 2121637380738388348): Settings › About › Update
channel read 「每个版本 | 稳定版」, so the line under Version said
"稳定版已是最新 · 每个版本已有 0.1.4182" and the button "改为每个版本",
which reads oddly. The channel is now named as a channel beside 稳定版:

  zh     尝鲜版  "稳定版已是最新 · 尝鲜版已有 {v}"  "改用尝鲜版"
  zh-TW  搶先版  "穩定版已是最新 · 搶先版已有 {v}"  "改用搶先版"
  ja     先行版  "安定版では最新です · 先行版では {v} が出ています"  "先行版に切り替える"

Its line is "每个新版本一发布就更新" (zh-TW the same). English and German
keep "Every version" / "Jede Version", which read as a channel name there.
Only translations change: the channel ids ("" and "stable"), the saved
setting and the update feed are as they were. Those four strings are all
the GUI shows of the channel; the tray shows none of it. The site's
download switch (最新版/稳定版) is another surface and is unchanged.

update-channel and update-stable-newest hold the new words in every
language.

Run at 658af9118 (this stack on origin/main 9cd5f3652), mica via
mica-run (mote was over its load): node --test of the 45 files
i18n-*, gui-* (zh-TW, ja, de), update-*, about-*, settings-*, Chromium
and WebKit, every language: 897 tests, 885 pass, 12 fail. The 12 are in
settings-groups (#6597), settings-hints (#6107, #6073) and
settings-lines-wrap (#6353); the same 12 fail on origin/main 4aa64500f
alone (56 tests, 44 pass). i18n-keys, update-channel,
update-stable-newest, update-auto and settings-search pass in both
engines and every language.

Not tried: the real app; the whole 1,500-file GUI suite.
2026-11-15 12:24:47 +08:00
yetone e7fc1bba4c gui tests: settings-search leaves the window's in-use post out of what it calls a write (#6133)
Since 10c4dc109 any key or click posts /api/update/using, so typing in
Settings' search recorded it and "searching posts nothing" failed in every
language (#6133, the class in #5982). It writes no setting; the recorder
now skips that one path and still counts every other non-GET.

Run (mica, mica-run): settings-search.test.cjs in Chromium and WebKit,
every language, green with the next commit's change; the same file was
red on the same assertion before this.
2026-11-15 12:15:23 +08:00
yetone 9cd5f36521 antigravity: retired, the built-in and its plugin both ask Google nothing; Antigravity is served by your own agy (agy-cli)
Google bans accounts it sees on Code Assist through Antigravity's own
client. magpie offered that route twice, the built-in and
@magpie-community/opencode-antigravity-auth, and anyone who picked
Antigravity in magpie took it by default (the owner, 11-15: 全部下线,改推
agy-cli).

- retiredBuiltins has antigravity. googleLogins lists no account of a
  subscription its plugin serves, so no list, usage read, quota read or
  request goes to Google with a built-in Antigravity account (the usage
  loop in subscription_usage.go had no gate of its own). The mover reads
  googleSavedLogins, so saved accounts still move.
- The mover's min is 0.2.0 (on the plugins dist index, b8bf5a57): that
  version sends nothing, answers every request 410 ModelDeprecated
  ("model has been retired", which modelRetired reads, so a group asks its
  next member) naming Antigravity (local agy CLI) and
  `magpie plugin add @magpie-community/opencode-agy-cli-auth`, and turns
  sign-in away. It left the plugins registry (003a38ff).
- Gemini CLI's route, on the same code, is unchanged.
- The built-in's code stays for now (shared with Gemini CLI); taking it
  out is #6723. Its 123 tests serve it again for their run through
  provider.AntigravityBuiltinForTest(), a counter BuiltinRetired reads.
- README (en, zh) and site docs subscriptions (en, zh, ja) point to
  Antigravity through the user's own agy CLI. AGENTS.md and
  provider-plugins.md say why and that neither route comes back.

What users lose: Antigravity with Google accounts signed in to magpie, and
rotating several of them. agy-cli serves the one account the user's agy is
signed in to, and needs agy installed.

Tests: TestRetiredAntigravityAsksGoogleNothing saves an Antigravity
account and checks googleLogins/googleAccountOf give nothing, the mover
still carries it, usage has no Antigravity card and the fake Google was
asked nothing, and Gemini's account still lists. Broken by hand (the
PluginServes gate removed from googleLogins): red,
"googleLogins(antigravity) = 1 accounts".

Run (mote/mica, at this change on origin/main 5bd41301b): gofmt -l clean;
go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./... and go build ./... ok; go test ./internal/gateway/ (1245s),
./internal/agent/ (419s), ./internal/provider/ (253s) ok on mica;
after rebasing on origin/main f362d3b9a: go test ./internal/provider/
(160s) and ./internal/plugin/ (184s) ok on mica.
Earlier at this change minus the test opt-ins: sessions, usage, library,
gui ok (mica). internal/cli's TestEveryRouteHasACommandOrIsNamed is red at
5bd41301b itself (/api/warm-all, #6724), not from this change.
Not run: the full ./... suite (mote and mica each had another session's
full or GUI suite); the GUI suite (no app.js change); a real move of a
built-in Antigravity account onto 0.2.0.

Plugins side: magpie-community/plugins 003a38ff (antigravity 0.2.0) and
f9155256 (agy-cli 0.1.56, comments only).
2026-11-15 12:14:48 +08:00
yetone f362d3b9af routing: Hide plans folds the groups' quota lines, kept across restarts
Sdsi134a on X: each routing group listed every provider's quota line
("WorkBuddy AI, 4 accounts: …"), so with many plans and accounts the
groups page grew long. The page's toolbar has Hide plans, before
Templates: it folds those lines under every group (name, id chip and the
members' line stay) and then reads Show plans. The choice is kept in
localStorage (magpie.routingGroupPlans), as the Routing page's other view
choices are, so it holds across restarts. Shown by default, as before;
the button is only there when a group has such a line.

Run at b694f760c (this commit on origin/main c12ca5e3b), on mote:
- routing-group-plans.test.cjs (new): 22/22, chromium and webkit, en zh
  zh-TW ja de, 1280 window and 420 web. It checks the button's place,
  the fold, that it holds across a quotas redraw and a reload, and no
  button without quota lines.
- With it, group-new-head, group-template, routing-by-key,
  routing-groups-off/back/page/wide, routing-group-fold, filter-ime,
  i18n-keys, i18n-en-no-cjk, account-arrange: 257/260. Reds:
  account-arrange x2 (#6010, red alone at base 705d67efc too), and
  routing-groups-back chromium ja 420 once, a 5s wait under load 39
  (#6729); alone 30/30 twice after.
- go test -count=1 ./internal/gui/: ok. app.js untouched (no budget).
Full GUI suite on mica at a0bf997a9 (the same change on 705d67efc), at
concurrency 6 beside two other sessions' suites, load ~50 on 12 cores:
still running at push, 6916 results through library-*, 217 reds in 45
files, none in the routing plugin. group-editor-selected x2 is red alone
at base 705d67efc on mote too (#5049, commented); account-arrange is
#6010, bark #6543, agent-details-ready #6369/#6373. The rest
(checkin-now-account, agent-switch-accounts, key-switch, login-export,
editor-hints, ...) don't load the Groups page; not each rerun alone.
Not tried: the real app.
2026-11-15 12:08:51 +08:00
yetone 862660144e gui: a page's tabs in the sidebar fold from its own row, with a disclosure chevron (hkwok06 on X)
Opening Settings unrolled its tabs in the window's sidebar and nothing
said they would fold again; only opening another page (the gateway)
put them away. The open page's row now carries a quiet disclosure
chevron, as a Mac sidebar's: turned to its list while the list shows
(down for the pages above, up for Settings, whose list opens above its
row), and clicking the row or the chevron again folds the list and
unfolds it, the page staying open on its tab. A list folded stays
folded, per page, until it is opened again (localStorage
magpie.navFolded). The same holds for Usage, Library and Plugins.
The chevron is muted, turns in 200ms on the strong ease-out, and
doesn't move under prefers-reduced-motion. aria-expanded says the
state; Enter on the focused row toggles it too.

The chevron and the fold live in navicons.js (navFoldRows, navFold),
imported with the first list; app.js keeps 123 bytes (navList shared
with navMine, the two rows' clicks asking navFold first), with the
budgets raised by that and the reason in core_budget_test.go.

Run (mote):
- nav-sub-fold.test.cjs (new), chromium + webkit, en zh zh-TW ja de:
  red on the old code (12 of 12, "Settings' row shows a disclosure
  chevron"), green 12 of 12 on this change.
- After rebasing on origin/main 38a90a34c: nav-sub-fold,
  nav-sub-unroll and i18n-keys: pass 38, fail 0; TestCoreScriptBudget
  ok; go vet ./..., GOOS=windows go vet ./..., GOOS=linux go vet
  -tags nogui ./..., go build ./... ok; gofmt -l clean.
- 45 GUI files the change can reach (nav-*, sidebar/side-*,
  settings-*, menu-scroll, click-scroll, i18n, gui-*, text-size,
  plugin-panels, ...): all pass except menu-scroll's scrollable
  dropdowns (#6532), nav-timeout (#5425) and settings-groups'
  warm-ups and check-in (#6597), which fail the same 5 tests on clean
  origin/main 38a90a34c (pass 8 fail 31 on both).

Not tried: the whole GUI suite (mote and mica were both loaded by other
sessions' suites), and the real app on Linux WebKitGTK and Windows.
2026-11-15 12:05:32 +08:00
yetone 38a90a34ce plugins: a dist add failed by another package, unnamed in Bun's last lines, is done (CHENGJIAHEGOXIS on X)
On v0.1.4210 the reporter (Windows) still couldn't add
@magpie-community/tools-goanyapi from the dist branch:
"bun add ./dist/magpie-community-tools-goanyapi-0.1.1.tgz: exit status 1:
Saved lockfile installed @magpie-community/tools-goanyapi@./dist/... 1
package removed ... Failed to install 1 package". Bun had installed
goanyapi; another package failed, but the line naming it comes before
"Saved lockfile", and the error kept only the last six lines, so
othersFailed found no name and the add failed. The tgz is fine (sha512
matches the index, no dependencies); nothing changes in the plugins repo.

- bunSaid: every Bun error magpie shows (add, update, remove, the dist
  mend) keeps up to 8 failure lines from anywhere in the output before
  its last lines, ANSI and CRs stripped.
- bunFailed reads every way Bun 1.4.4's source (install/*.rs) names a
  failed package: failed to install/link <name>:, refusing to install
  dependency, extracting tarball from/for, downloading tarball <name>@,
  failed to download, Failed to open node_modules folder for, path for
  package.
- othersFailed: a failure naming no package is another's when the add's
  own package is in package.json and installed at the exact version asked
  for (the spec's exact version, or the one installDist read from the
  index; installDist now returns it). Its own package named still fails.
  This covers every plugin kind, provider plugins and tools alike, as all
  go through install().

Run:
- Old code (origin/main 5bd41301b with the new tests): all five new or
  changed tests red, TestUnnamedFailureDoesNotFailADistAdd with the
  reporter's message byte for byte.
- mote: go test -timeout 30m ./internal/plugin/... ok (174s);
  GOOS=windows go vet ./internal/plugin/ and GOOS=linux go vet -tags
  nogui ./internal/plugin/ ok; gofmt -l clean.
- xiaomi-gpu (Windows 11), real Bun 1.4.4, sandbox USERPROFILE/APPDATA/
  XDG_CONFIG_HOME, magpie.exe -tags nogui built from this tree:
  `magpie plugin add @magpie-community/tools-goanyapi` from a clean
  plugins folder installs 0.1.1 from dist with its 37 tools; with
  agency-agents installed and a file of it held open, the add drops
  agency-agents and installs goanyapi. That second shape passes on
  origin/main too (Bun's EBUSY line names agency-agents there).

Not tried: the reporter's exact hidden line, which their message cut
off; no shape I made on Windows hid the name. Publishing tools-goanyapi
to npm, which would skip the dist path, needs the owner.
2026-11-15 11:55:45 +08:00
yetone c12ca5e3b7 usage: a Mythos no catalog prices is priced as its Fable (shangyuan0818 on X)
shangyuan0818 on X (Windows, latest): Usage -> Requests shows no price
for claude-mythos-5.2, and Codex subscription requests made hours apart
are priced as cache misses.

Cause (Mythos). No catalog lists claude-mythos-5.2: models.dev's
anthropic has claude-fable-5-2 (8/40, cache 0.2/10) but no Mythos 5.2,
and its only Mythos price is azure's claude-mythos-5, at claude-fable-5's.
So ListPrice, MakerPrice and PricedName found nothing and the row was
unpriced.

Fix. mythosFable maps a Mythos id to the Fable of the same version
(claude-mythos-5.2 -> claude-fable-5.2). Anthropic's docs give Mythos 5.1
"the same ... per-token pricing" as Fable 5.1 ($10/$50, cache reads
$0.25) and Mythos 5 the same as Fable 5. ListPrice, MakerPrice and
PricedName (the row's "priced as" and the Sessions page's price) try it
last, after every price for the Mythos id itself: a catalog's, what
Anthropic told Claude Code (additionalModelCostsCache), a plugin's. A
first version put it in pricedNamesTo, ahead of Claude Code's price, and
TestClaudeAccountListsGatedModels went red in the full suite. That
ordering is what this version fixes.

Codex cache: no change. magpie prices a Codex call from the cached
tokens OpenAI reports (input_tokens_details.cached_tokens, read in
responses.go and chat.go). No time-window guess exists in usage
pricing; the only time rule is gateway routing affinity (chatGPTCold,
1h), which picks an account and prices nothing. Real records on this
Mac (usage.jsonl against ~/.codex/sessions, one account, gpt-6-sol):
- a thread resumed after 25 min: OpenAI reported 186112 of 186330 cached;
- after 748 min (12.5h): OpenAI itself reported 3456 of 30724 cached.
magpie recorded and priced exactly those numbers. A miss hours later is
OpenAI's cache having expired.

Run:
- TestMythosPricedAsItsFable (new): Mythos 5.2 written five ways
  (dots, dashes, case, [1m], anthropic/ prefix) is priced at Fable 5.2's
  through MakerPrice and ListPrice, and PricedName names claude-fable-5.2.
  A listed Mythos 5 keeps its own price, and claude-mythos-9 stays
  unpriced. With mythosFable disabled by hand, 11 of its checks go red.
  Restored, it is green, with TestClaudeAccountListsGatedModels green in
  both cases.
- Real catalog: a throwaway test (not committed) loaded this Mac's
  ~/.cache/magpie models.json and labs.json from today into a sandbox
  HOME and ran on mica. Results:
  - claude-mythos-5.2 and -5-2: 8/40/0.2/10, priced as claude-fable-5.2;
  - claude-mythos-5-1 and 5.1: 10/50/0.25/12.5;
  - claude-mythos-5: 10/50/1/12.5.
- go test -count=1 -timeout 45m ./... on mote at this commit (rebased
  on origin/main 5bd41301b): 100 packages ok. The one red is
  internal/cli TestEveryRouteHasACommandOrIsNamed ("POST /api/warm-all
  has no command"). It comes from 5bd41301b and is filed as #6724.
- Windows (xiaomi-gpu, win-run): go test ./internal/provider/ at this
  commit. TestMythosPricedAsItsFable passes. 17 reds, the same set as
  origin/main 5bd41301b run there alone (main has one more,
  TestUsageReadAndReadAgain). All are filed: #2808, #6024, #6025, #4633,
  #4115/#6068 and #4446.
- gofmt -l: nothing. go vet on mica: darwin, GOOS=linux -tags nogui and
  GOOS=windows ./... all ok before the reorder. After it, the same three
  ran on internal/provider and internal/sessions: ok.

Not tried: the reporter's own Windows usage data. Not covered: a dotted
id with a window mark (claude-mythos-5.2[1m]) is still unpriced, because
catalog.PricedBy doesn't combine the two rewrites even for Fable; that
is filed as #6725.
2026-11-15 11:50:15 +08:00
yetone 5bd41301b9 warm-up: All accounts warms every account in use at one press (CoderMaurice on X)
CoderMaurice on X: with several Claude accounts, Warm up now had to be
pressed once per account. With two or more accounts, the Warm up… menu on
the Warm up now row (a Claude Code or Codex provider's editor, the warm-up
section) now starts with All accounts. It sends POST /api/warm-all, and
provider.WarmAll sends Warm up now to every account that is in use (the
one the agent is on, or one turned on beside it) and whose windows aren't
all running already, going by the cached readings the Usage page shares.
It runs three at a time. An account that is turned off or paused, or
already in its windows, is sent nothing. An account whose sign-in lapsed
is sent nothing and is listed as failed, as Warm up now treats it. The
row's line lists the accounts warmed, the ones already in a window, and
each refusal with its reason (in red).
Accounts that are turned off aren't listed. A gateway rest is not read
(the provider package can't see it). An account rested for a used-up
window is still inside that window, so it is skipped as running.

"All accounts" moves from the usage plugin's i18n.js into core i18n.js,
since the core uses it now. It and two new strings are in zh, zh-TW, ja
and de. app.js stays inside its budget: the single-account and
all-accounts results now go through one formatter.

Run at a1968a0b5 (rebased on origin/main aecf27efb), on mica:
- go test -run 'WarmAll|WarmNow|CoreScriptBudget|Budget' ./internal/provider
  ./internal/gui: ok. New: TestWarmAllWarmsEachIdleAccountInUse,
  TestWarmAllOnlyCodexAndClaude, warm-all cases in TestWarmNowAPISaysWhy.
- Broken by hand: with the "running" skip removed from warmAll,
  TestWarmAllWarmsEachIdleAccountInUse FAILs (busy@ and spent@ warmed).
  With the All accounts item removed from the menu, warm-now.test.cjs
  FAILs ("Warm up all warms every account at one press" and the menu
  list assertion).
- GUI, Chromium and WebKit, en/zh/zh-TW/ja/de, 900px and 440px:
  warm-now, i18n-keys, i18n-en-no-cjk, usage-accounts: 54/54 pass. Before
  the rebase, plan-name-fits, provider-prefs-layout and quota-warm also
  passed (54/54 with usage-accounts).
- gofmt -l: clean. go vet, GOOS=linux go vet -tags nogui and
  GOOS=windows go vet of internal/provider and internal/gui: ok.
  go build, GOOS=linux go build -tags nogui, GOOS=windows go build: ok.

Not run: the full go test ./... and the full GUI suite. Both mote and
mica had other sessions' GUI suites running throughout, and this ships
now per the owner's ship-immediately rule. Both will run when a machine
is free. Not tried: a real Warm up all against several real Claude
accounts (the send per account is the unchanged WarmNow).
2026-11-15 11:00:37 +08:00
yetone aecf27efbc LESSONS: a quiet go test log is not a hang until a package's time says so (#5267)
The macOS Test step of run 43664046438 was cancelled at 53 minutes as a hang; its log shows go test had just finished. Packages print in order, so one slow one holds every later line back. Docs only; nothing run.
2026-11-15 10:43:43 +08:00
yetone ab3bcdb145 plugin tests: the slow-recall fixture renames its output into place (#6019)
TestGatewayHookSlowRecallUsesConfiguredBudget polls every 50ms for the
file its onResponse writes and fails on the first read that succeeds.
fs.writeFileSync creates the file empty before it writes the bytes, so a
read in between saw "" and failed with `captured ` (mote at f03ec97b8,
and macOS CI run 43664046438 at 01f307091). The fixture now writes a
.tmp beside it and renames it in, so the file appears whole or not at
all. The budgets under test were never the cause: 24.16s is the 12s
recall plus the 12s onResponse.

Run:
- Broken by hand: the fixture opening the file, waiting 300ms, then
  writing goes red the way CI did (`gateway_budget_test.go:53: captured `).
- The fix: -count=3 -run '^TestGatewayHookSlowRecallUsesConfiguredBudget$'
  ok on mote (load 26 on 18 cores at the time), and the whole
  internal/plugin package ok on mica (179s), with go vet and gofmt -l
  clean.

Not run: the full suite; this changes one test's JS fixture only.

Closes #6019.
2026-11-15 10:43:03 +08:00
yetone 705d67efc7 ci: the Test step has a 75-minute cap (#5267)
0dbdc7481's macOS Test step (run 43656468676) printed its last package
line at 00:54:42 (internal/libc) and nothing more until it was cancelled
by hand at 01:38:41: internal/library, next in order, neither finished
nor hit go test's -timeout 30m panic, so no stack came out. Main's runs
don't cancel each other, so 97e6ac36c's run waited behind it. With the
cap a hang fails the step and the queue moves.

The cap: Test took 11 minutes on ubuntu in that run and 31 on macOS in
the run before (6e6a18eda, where the gateway's 30m alarm ended it);
75 leaves room for a slow macOS runner. The hang itself is #5267's
(internal/library past its timeout in testenv's warm-up run); this
doesn't fix it.

Run: the workflow parses (python yaml.safe_load). Not run: the workflow
itself; this push's own run is its check.
2026-11-15 09:40:35 +08:00
yetone 01f307091b routing: a group's routing changed counts at a conversation's next turn (#6708)
A conversation under Stays auto keeps its member while its cache holds
cacheWorth (1024) or more. That stays: routing ranking another member
first on its own merits doesn't move a warm cache (backFromStandIn's
rule), since the ranking moves with every reading and a move pays the
whole prompt again. What was missing is the user's own act: a reorder
already counts at the next turn (reorderedSince), but changing a
group's routing (manual -> pace in #6708) did not, so the conversation
stayed on the manual pick.

Group gains RoutedAt, stamped by SaveGroup when Routing changes and
kept otherwise, so it is persisted and a change from the CLI or TUI
reaches the running gateway (unlike NoteReordered, #6265). affine's
Auto branch now also lets the conversation go when its stick predates
the group's RoutedAt. Session, Strict and a turn under way keep it, as
for a reorder. The sibling for a provider's own accounts routing is
#6718.

Tests: TestReroutedGroupTakesTheConversationAtItsNextTurn (a 2.8k
cache, the reporter's size: rerouted "a a b b", a rename-only save
"a a a a", session "a a a a") and TestGroupRoutedAtFollowsTheRouting.
Broken by hand: with reroutedSince returning false the first is red
("a a a a, want a a b b"); green with it, beside TestReorderedAccounts.

Run at e8e5b9e06 (this pair on origin/main 97e6ac36c), on mica because mote's load was over its cores: gofmt -l clean; GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... and go vet ./... ok; HOME=sandbox go test -timeout 45m ./... ok, all 101 packages (gateway 932s, agent 337s, provider 209s), no reds. No GUI change. Not tried: a real Remote magpie on a free plan, or a real conversation through a rerouted group; both are covered by the tests above only.
2026-11-15 09:38:24 +08:00
yetone 98fb140869 routing: a Remote magpie signed in to a free plan is spent first by Free quota by expiry (#6708)
weighRouted set a seat's FreePlan only from c.p.Account, so a Remote
magpie whose card is a Free plan (Kind "subscription", Plan "Free")
was weighed as paid, and "Free quota by expiry" spent a paid remote
before it. provider.RemoteSeat now also says whether the card it chose
is a free subscription plan; RemoteAllowance wraps it unchanged, and
weighRouted keeps that bit on the member's left and ORs it into
FreePlan.

Test: TestRemoteMagpieFreePlanSpentFirst (two httptest remotes, a Pro
at 20% and a Free at 60%, FreeExpiring group): the free one goes first
and is the only one in wg.free. Broken by hand: without the
`|| ...freePlan` the test is red ("mac-paid first", free map all
false); green with it, beside TestRemoteMagpiesWeighedByTheirCards and
TestRemoteAllowance.

Run at e8e5b9e06 (this pair on origin/main 97e6ac36c), on mica because mote's load was over its cores: gofmt -l clean; GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... and go vet ./... ok; HOME=sandbox go test -timeout 45m ./... ok, all 101 packages (gateway 932s, agent 337s, provider 209s), no reds. No GUI change. Not tried: a real Remote magpie on a free plan, or a real conversation through a rerouted group; both are covered by the tests above only.
2026-11-15 09:38:24 +08:00
yetone 97e6ac36c9 catalog: a provider's model list names each model once (#6582)
elis_pina (LoveEcho1145) on X: some APIs list a model more than once in
their /models, and each copy was a row of its own. A provider asked at its
base already merged copies by id (Provider.fetchOne's add), but one asked at
the URL its list is at (ModelsURL), the add form's List, and every list
fetched another way (accounts, Azure, Kilo, Cline, decision lists) kept
them, in the pickers, /v1/models and the agents' lists.

catalog.Unique keeps each id once: the first copy in its place, with what
it leaves unsaid (a name other than the id, window, output, levels, price,
APIs, tiers, magpie_via, keys) taken from the copies after it, as the
lookups by id (LiveByID's callers) already took the first copy that said
it. It runs at the parse of every upstream /models (catalog.fetchOne, all
pages), at every save (saveLive: the list and each base's part, whoever
fetched it), and at every read (readLive), so a list saved before reads
each id once without waiting for a fetch. A list with no copies comes back
as it is. Plugins' lists are keyed by id in host.js already. Keyed by id
alone, as Provider.fetchOne and fetchPerKey merge already.

Tests: TestFetchedListNamesEachModelOnce, TestSavedListNamesEachModelOnce
(saved, sides, LiveByID, and a file written before with copies),
TestUniqueLeavesAListWithoutCopies, TestProviderListsEachModelOnce (at
base and at ModelsURL: Fetch, List, Available). Broken by hand: with
Unique returning its input, the first two and the ModelsURL case of the
last are red (Fetch/List/Available listed [gpt-5.6 glm-5.3 gpt-5.6
glm-5.3]); with readLive's Unique alone taken out, the saved-before case
is red.

Run on mica: gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags
nogui ./... ok; go test -timeout 45m ./... at b552edb12 (base 6af327e2b):
100 packages ok, internal/plugin red on TestCancelledSignInSavesNothing,
#5532 (filed, same tok-late output, passes -count=10 alone at this head).
Rebased on 87a0af212 (changes only gateway test files and LESSONS
since); at the pushed head internal/catalog and
internal/provider ok, linux/windows vet of both ok. No GUI file changed
and no API shape changed, so no GUI suite was run. Not tried: a real
vendor that lists copies (the reporter named none).
2026-11-15 09:02:39 +08:00
yetone 87a0af2126 LESSONS: a change to which tests share a process checks the state they leave (#6717) 2026-11-15 08:46:47 +08:00
yetone 6e0b8113dd gateway tests: a rest one test records is let go when it ends (#6717)
restingUntil is package-global. Six tests leave a Codex usage-limit rest
behind (TestAccountProxy, TestCodexOwnModelMovesToNextAccount,
TestCodexSwitchedAccountRestsAsItself, TestCodexPausedOwnAccountPassedOver,
TestCodexPoolForwardsCodexHeaders, TestCodexSocketErrorIsItsStatus), and
TestEffortChangeKeepsTheCache, whose effortCodexAccount sets its home
without fresh(t), started held by it whenever the chunking put them in one
process: its first turn was refused in 15ms with "The usage limit has been
reached". Red in Race at 6e6a18eda and in Test at 0dbdc7481.

The class, both sides:
- fresh(t) clears the rests through noRests() and again when the test
  ends (t.Cleanup), so a test that comes through fresh leaves none.
- noRests() clears restingUntil.lifted too, not only m and note.
- The helpers that set a home without fresh (effortCodexAccount,
  leadSignIn, claudeMadeFirst, piTwoTurns) call noRests first and when
  they end, as b64Home already did.

Run on mote, at 6af327e2b plus this change:
- Broken by hand: each test of the eleven files whose fakes answer a
  usage limit, run with TestEffortChangeKeepsTheCache in one process
  (-test.run '^(T|TestEffortChangeKeepsTheCache)$'). Before: red with the
  six tests above. After: none red.
- internal/gateway plain, sharded as CI does (build/race-shards.sh, 12
  workers): 4300 tests, shards_rc=0.
- internal/gateway -race, sharded: one red, TestBurstTellsNoSpeed/
  responses_from_chat_burst (839ms burst read as 5959 tok/s), a timing
  red with its issue, #2719 (output recorded there); every other test ok.
- gofmt -l internal/gateway: clean.

Not run: the other packages (test files of internal/gateway only).

Fixes #6717
2026-11-15 08:45:42 +08:00
yetone 6af327e2b3 provider: TestWalletCapHolds holds its clock at local noon (#6474)
The test read the wallet at time.Now() plus 1 to 5 minutes. A run that
started within 5 minutes of local midnight read the later balances in the
next day, the wallet's daily spend started again, and the cap checks
failed: red on mote at 23:56 PST and on macOS CI at 00:00:12 UTC (run
43653589915, "500 of 10,000 spent, cap 4: held <nil>"). Every function on
the path (withWalletSpend, allowanceOf, CapHeld) takes its time as an
argument, so the test now starts from today's local noon, as f53c4a1a1
did for three usage tests.

Run (mica, at origin/main 0dbdc7481 + this):
- TestWallet* and TestPluginWalletCapHolds, -count=2, in TZ=UTC,
  Asia/Shanghai and America/Los_Angeles: ok
- broken by hand: held at 23:57 instead of noon, red at
  wallet_spend_test.go:123 with SpentSince the next day's 00:00, the
  same failure as CI's

Not tried: the full suite (a test-only change in one test).
2026-11-15 08:24:18 +08:00
yetone 0dbdc7481c ci: Test runs internal/gateway in chunks, one process per core, as Race does (#2191)
f1c9014cd's macOS Test run went red with internal/gateway past go test's
30m alarm while the test then running was 1s in: no test hung, the
package as a whole ran out. Its tests run one at a time (t.Setenv rules
out t.Parallel), and the package grew from 450-600s on macOS runners
(10-28, 56602426d) to 965s on the green run before, and 892s for 4286
tests on mote, none over 20s. A longer timeout would be met again the
same way; Race already runs the same tests in chunks through
build/race-shards.sh (#5361).

The Test step now runs every other package as before, and the gateway's
plain test binary through race-shards.sh. The plain run stays: it sends
the full 64 MB bodies and runs the pool tests -race skips (raceOn).

Run on mote at this change (origin/main a5e3972a7):
- go test -c ./internal/gateway/, then build/race-shards.sh with 18
  workers and -test.timeout=20m: 4300 tests in 135 chunks, 125s, exit 0
  (twice; the second run's status taken from the script, not a pipe)
- go list ./... | grep -v '/internal/gateway$': 121 packages, the
  gateway's subpackage kept
Not run: the workflow itself; this push's own Test run is its check,
on Linux (gtk3 tags) and macOS.
2026-11-15 08:05:40 +08:00
yetone a5e3972a71 agent: the Codex account the user keeps Codex on is never taken over when held, so the app shows it, not "magpie" (davezfr on X)
davezfr on X, after v0.1.4216 (369ec0418): "still shows Magpie". Account
1 has used up both its plan allowance and its credits; picked in Codex's
sign-in it shows "magpie" in the Codex app, while account 2 (room) shows
itself. When it still had credits this didn't happen.

Cause. With quota and credits both gone the account is held (codexHeld:
rate_limit.allowed false, no credits), and the agent package's out()
then makes magpie Codex's provider (codex.out takeover, #540) without
requires_openai_auth. Codex's app-server answers account/read with no
account for such a provider, so the app shows the provider's name,
"magpie", in place of the account the user picked. 369ec0418 only
ended stale holds at their window's reset; a real hold still took the
account over. The takeover is magpie's default; the account the user
keeps Codex signed in to is the user's own value, which the default
overrode (code standards: magpie's default never overrides a value the
user set).

Fix.
- provider.CodexSignInKept: Codex is on the account the user keeps it
  on (keepsLogin: KeepLoginAs names the active account, or kept on the
  first with none named). False under switch-only, keeping off, or kept
  on another account than the active one.
- agent: out() is false for such an account (codexSignInKept, a var
  for tests), so Sync leaves Codex beside its ChatGPT sign-in, a pick of
  magpie's model doesn't take it over, and a takeover made before the
  keep ends. The app shows the account and greys Send till its reset,
  as it does without magpie. Not kept, a held account is taken over as
  before (Always ChatGPT still turns the takeover off for every account).
- docs/subsystems/agent-wiring.md says so.

Users already affected: once updated, the next catalog sync puts Codex
back beside the kept account's sign-in; the Codex app shows the account
after its app-server restarts (the Agents row's Restart, or Restart the
Codex app to follow), as for the takeover's end at a reset.

Tests:
- TestCodexKeptOnAHeldAccountShowsIt (agent): held and not kept: the
  takeover; kept: beside the sign-in, no AppOut, on magpie's model and
  on Codex's own joined model; let go: taken over again.
- TestCodexSignInKept (provider): the reporter's state, two accounts,
  account 1 held (week at 100%, not allowed, no credits) and kept via
  SetKeepLoginAs: CodexUsedUpKnown true and CodexSignInKept true; kept
  on account 2 while on 1, switch-only, keeping off: false.
Broken by hand: with `&& !codexSignInKept()` taken out of out(),
TestCodexKeptOnAHeldAccountShowsIt red (model_provider = "magpie"
written); with CodexSignInKept's match turned to false,
TestCodexSignInKept red ("CodexSignInKept false").

Run: full suite `go test -count=1 -timeout 45m ./...` on mote at this
change on ca64168d3: exit 0, 101 packages ok, no FAIL (log kept whole
in magpie-wt/codex-held-account-scratch/suite.log). After rebasing on
6e6a18eda (gateway only): internal/agent ok, internal/provider ok on
mote. gofmt -l clean; on mica go vet (darwin), GOOS=linux -tags nogui
and GOOS=windows go vet ./internal/agent ./internal/provider ok.

Not tried: the real Codex app with a real held account, and the
reporter's exact setting (if account 1 was picked by a plain switch
rather than kept, magpie moves Codex off the held account to account 2
at its next look, as before, and the takeover stands meanwhile).
2026-11-15 07:39:25 +08:00
yetone 1296b2a865 provider: Antigravity's plugin min is 0.1.18 (plugins#1169)
0.1.18 asks Gemini 4 Hydrogen's xhigh variant at xhigh instead of high,
and reads a capitalised thinking level ("XHIGH") as Gemini's own
clients write it. keepMovedCurrent brings every moved user up to it.

Checked before landing: magpie-community/plugins dist index.json lists
@magpie-community/opencode-antigravity-auth 0.1.18 (the package is
dist-only, not on npm).
Run: go test ./internal/provider -run 'Mover|Moved|Antigravity|Min' on
mote: ok.
Not tried: a real update of a moved account to 0.1.18.
2026-11-15 07:37:44 +08:00
yetone 6e6a18edac gateway: a Code Assist variant at xhigh is asked at xhigh (plugins#1169)
Gemini 4 Hydrogen's xhigh variant was sent with thinkingLevel "high":
thinkingConfig's level chain had no xhigh case, so any effort at or
above high came out as high. Google lists LOW, MEDIUM, HIGH and XHIGH
for that model. A variant whose own level is xhigh is now asked at
xhigh; a model with no xhigh variant still goes at high, as before.
The same fix shipped in the antigravity plugin 0.1.18 (df7d7ae0 in
magpie-community/plugins); this is the built-in's side, which still
serves accounts not yet moved.

Run: go test ./internal/gateway -run CodeAssist on mote: ok.
Broken by hand: with the new branch off, TestCodeAssistAntigravityLevels
is red on both hydrogen-xhigh rows ("at high, want xhigh").
Not tried: a real Code Assist request at xhigh; no account here is
served Gemini 4, so Google taking "xhigh" there rests on its model list.
2026-11-15 07:30:18 +08:00
yetone ca64168d3e library: a skill beside itself folds back on read; GitHub by git address is one repo
Refeccd on X said eee217712 (v0.1.4213) didn't fix "skills from a grouped
git repository get the repository's suffix". Reproduced in a sandbox HOME
three ways the fix left open:

- Copies an earlier magpie had already suffixed (blog-team beside blog)
  were folded only by foldBeside in a change. Upgrading and opening the
  Library changed nothing; Read, CheckSkills and Read again all kept them.
  readView now folds them too, when any skill has Called and a remote
  source, saves and syncs the agents in the same read, so a folded copy's
  links don't point at a removed folder. Sync problems join the view's.
- A GitHub repository added as owner/repo and then by its git address
  (git@github.com:owner/repo.git) was two sources: sameRepo and
  fromSameSource compared Kind first, so every skill went in again as
  name-owner. Both now match github and git sources through remoteRepo.
  foldBeside folds a copy from the same folder of the same repository
  (before only one whose target was Gone and at another path).
- gitRepoOf looked at a skill's folder and three above it, while a probe
  finds skills four folders into a repository: a checkout's
  skills/team/writing/poem wasn't traced, and an edited poem went in as
  poem-sub. It now looks at the folder and four above it.

Existing suffixed copies: folded on the next read of the Library page
(or next change); the copy's files, renamed, replace the skill's, its
agents are added, and both old folders go to the backups.

Tests (skill_group_suffix_test.go), each broken by hand:
- TestSkillBesideItselfFoldsOnRead: red with the readView fold removed.
- TestGitHubRepoByGitAddressIsHad: red with sameRepo kept same-kind.
- TestGitHubCopyByGitAddressFoldsBack: red with each of the above and
  with foldBeside's old condition.
- TestCheckoutSkillFourDeepIsTraced: red with gitRepoOf at 4.

Docs: docs/subsystems/library.md's "Skills installed together" no longer
says nothing is renamed after the fact; it describes sameRepo, movedIn,
besideName, followsHere's depth and foldBeside on read.

Run on mica at 168d6fb13 (on origin/main ab7cb5537): gofmt -l internal
clean; go vet ./..., GOOS=windows go vet ./..., GOOS=linux go vet -tags
nogui ./... ok; go test -timeout 45m ./... ok, 101 packages, no FAIL
(internal/library 298s). An earlier full run at 1bfdeab52 was red in two
of these new tests only: other tests mark owner/repo tooBig for the whole
run, so the fixture now uses its own repository (refeccd/grouped-skills).
No GUI file changed and no GUI test was run: the change is Go only.

Not tried: a real GitLab or intranet repository, and the reporter's own
layout (the reply gave no detail); a real GitHub repo by SSH address
(the test maps it to a local repository through git insteadOf).
2026-11-15 07:04:53 +08:00
yetone ab7cb55371 plugin: a page-only plugin's options are set under plugins.json's lock too (#4666)
0d6162c8a put every plugins.json change under the file's lock, but
SetPageOptions writes a page-only plugin's options itself, under listMu
alone, so another magpie's save meanwhile was still lost there. It now
takes listFileMu before listMu, as SetOptions does.

Run (mote, darwin/arm64):
- go test ./internal/plugin -run Meanwhile -v: the three Meanwhile tests ok
- page.go reverted with the test kept: TestPluginPageOptionsKeepWhatAnotherMagpieSetMeanwhile
  red ("SetPageOptions went on while another magpie held plugins.json's
  lock"); restored, green
- full suite (go test -tags nogui ./... -timeout 45m, mote) with this
  stack at b566b9d3c on 0b8c4bfc3: every package ok but two reds of that
  base, both fixed on main since: internal/cli
  TestEveryRouteHasACommandOrIsNamed (4c86b0ab4) and internal/tui
  TestEveryWordHasZh "permission mode" (e9fcc6229)
- rebased on f1c9014cd: go vet (darwin, linux nogui, windows) and
  go test of internal/gateway, internal/plugin, internal/cli and
  internal/tui at the pushed head: ok (gateway 899s, plugin 158s, cli, tui)
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., darwin/linux/windows builds: ok at b566b9d3c

Refs #4666
2026-11-15 06:40:19 +08:00
ggbdpq 5aa365349a plugin: a plugins.json change one magpie makes keeps what another saved meanwhile (#4666)
What changed: every change to plugins.json (Add, Remove, SetOff, Prefer,
SetOptions — the GUI's Plugins page, a plugin page's options bridge,
`magpie plugin options/prefer/remove`, migrate and backup) is now made
under the file's lock, plugins.json.lock, the same shape the accounts'
logins and mcp-signins.json are changed under: listMu is this process
alone, so the gateway and a magpie run from a terminal read, changed and
wrote whole lists past each other, and the later write went out with
what the other had saved since its read. Under the file lock every
change reads the file afresh, so both stand. A lock held longer than
filelock.Wait goes on without it, as before there was one; a file
system with no locks likewise. Reads are unlocked, as they were.

Run (darwin/arm64, GOCACHE pinned, upstream/main 873b4987e + this):
- go test ./internal/plugin -run 'TestPluginOptionsKeepWhatAnotherMagpieSetMeanwhile|TestPluginPreferKeepsWhatAnotherMagpieSetMeanwhile' -count=1 -race: ok
  (each red before the fix: "SetOptions went on while another magpie
  held plugins.json's lock" / "Prefer went on …", deterministic)
- go test ./internal/plugin -count=1 -timeout 25m: ok except TestHostToldTheGatewayAddress
  (a port-migration flake this machine's proxy already gave: red on the
  parent commit 873b4987e too, same "told MAGPIE_ADDR=127.0.0.1:3591")
- gofmt -l internal/plugin: clean; go vet ./...: ok;
  GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: ok
- go build, GOOS=linux go build -tags nogui, GOOS=windows go build: ok

Generated-by: GLM-5.3-Flash (ZCode)

Landed by the maintainer after (mote, darwin/arm64):
- this change's file(s) reverted with its tests kept: its new tests red;
  restored, green
- full suite (go test -tags nogui ./... -timeout 45m) with the stack on
  0b8c4bfc3: every package ok but two reds of that base, fixed on main
  since (4c86b0ab4 cli route parity, e9fcc6229 tui "permission mode")
- rebased on f1c9014cd: go test of internal/gateway, internal/plugin,
  internal/cli and internal/tui ok; go vet darwin, linux nogui, windows ok
2026-11-15 06:40:19 +08:00
ggbdpq dac251b5f5 gateway: a client's own whole replay is asked once more without the ids another resource refuses
A Codex replaying its whole conversation itself (store false, no
previous_response_id) echoes ids the upstream handed out for earlier
turns. When an upstream turns one away as another of its resources' —
the prevForeign refusal — the recovery that strips such ids from a
conversation magpie gave back never ran: the store-off request hung no
ask, so the retry gate stayed shut and the 400 reached the client
(#6320). x1051445024's report; the reporter's own compat proxy stripped
whitelisted optional ids as a workaround.

The store-off request now carries a marked ask when its input reads as a
replayed conversation: more than one item, and one before the last
naming an id that may go without one, or a reasoning's. One id'd item
alone is the client's own new input and goes as it came, as
TestPreviousResponseOtherResourceWholeSentWithoutIDs already holds the
line. On the foreign refusal the same prevElsewhere run takes those ids
out of the replay — reasoning only with its encrypted_content, calls'
call_id pairing kept — and the request is asked again once, only with a
body that differs. Nothing is recorded for a store-off request, and a
known conversation's recovery is exactly as before (the mark is never
set on an ask magpie answered).

Verification on darwin/arm64, upstream/main 873b4987e + this commit:
- New TestClientWholeReplayForeignIDsAskedWithoutThem fails on the
  unmodified base with the 400 reaching the client, passes with this
  commit (2 upstream calls: the refusal, then the replay without ids);
  TestClientWholeSingleIDedItemStaysAsItCame holds the single-item line.
- The existing prev family stays green, the two boundary tests included.
- Ablation: the three hunks reverted (ask hang, prevClientWhole gate,
  prevElsewhere's client-whole treatment), tests kept, the replay test
  red again; restored, green.
- internal/gateway whole package green; gofmt/vet clean.

Fixes #6320

Generated-by: GLM-5.3-Flash (ZCode)

Landed by the maintainer after (mote, darwin/arm64):
- this change's file(s) reverted with its tests kept: its new tests red;
  restored, green
- full suite (go test -tags nogui ./... -timeout 45m) with the stack on
  0b8c4bfc3: every package ok but two reds of that base, fixed on main
  since (4c86b0ab4 cli route parity, e9fcc6229 tui "permission mode")
- rebased on f1c9014cd: go test of internal/gateway, internal/plugin,
  internal/cli and internal/tui ok; go vet darwin, linux nogui, windows ok
2026-11-15 06:40:19 +08:00
ggbdpq c747ecfa68 gateway: a sealed subagent task is never downgraded to a translation (#5198)
A subagent's task its lead sealed goes to the provider that can open it
(sealedReader, #1109), but attempt's downgrades didn't know that: a
provider marked as having turned Codex's custom tools away had the
request translated from the start, and a refusal of the custom tools met
on the sealed turn itself translated on the fallback — and a translation
reads an agent_message's text and images alone, so the NEW_TASK header
went out and the task's sealed body stayed behind, with a 200 saying the
task was there.

A sealed task now goes with who can open it as it came, as a native
compaction does (#1099): every downgrade in attempt leaves it alone, and
the refusal met on the turn is the client's answer as the upstream said
it, not a 200 with the task gone.

Generated-by: GLM-5.3-Flash (ZCode)

Landed by the maintainer after (mote, darwin/arm64):
- this change's file(s) reverted with its tests kept: its new tests red;
  restored, green
- full suite (go test -tags nogui ./... -timeout 45m) with the stack on
  0b8c4bfc3: every package ok but two reds of that base, fixed on main
  since (4c86b0ab4 cli route parity, e9fcc6229 tui "permission mode")
- rebased on f1c9014cd: go test of internal/gateway, internal/plugin,
  internal/cli and internal/tui ok; go vet darwin, linux nogui, windows ok
2026-11-15 06:40:19 +08:00
yetone 72d3692e5f codex relay: a browser extension's call while magpie is quit is told to open magpie
jipairamen on X (v0.1.4212): a Chrome translation extension pointed at
magpie's gateway address got, for every request,
  403 "magpie's Codex relay serves Codex on this computer only".

Cause: that answer is not the gateway's. When magpie quits with Codex
running, it leaves `magpie codex-relay` at the gateway's port for the
Codex threads still open (codexrelay, 4534561f6). The relay judged who
asks before what is asked: any request with an Origin was refused with
the line above, so an extension's /v1/chat/completions never reached the
"magpie isn't running ... Open magpie" answer (relayGone) that every
other non-Codex call gets, and the doc already promised. The message
read as a permission rule, not as "magpie is closed".

Now a path other than /backend-api/codex/* gets relayGone (503) from any
caller, Origin or not; it passes nothing on, so who asks doesn't matter.
On Codex's own path a page, an extension, a null frame or a rebound name
is still refused (403), with a message that says magpie isn't running
and to open it. No origin rule changed: the relay still forwards only
loopback, Origin-less Codex requests, and the running gateway's
corsGuard is untouched (an unlisted chrome-extension:// origin was
already served keyless there by design; a listed one needs a key).

Siblings: the relay's LeavePath answers only the next magpie (token);
its "forbidden" there is not seen by users. No other handler holds the
gateway's port while magpie is quit.

Tests: TestCodexRelayTellsExtensionToOpenMagpie (chrome-extension://,
moz-extension://, https page, null; four paths; with and without a
key: 503 relayGone, nothing sent to OpenAI) and
TestCodexRelayOnlyThisComputer (now with an extension origin and the
"Open magpie" text). With the old codex_relay.go both FAIL:
  --- FAIL: TestCodexRelayOnlyThisComputer
  --- FAIL: TestCodexRelayTellsExtensionToOpenMagpie
and pass with the change.

Real use: built magpie (nogui) on mote, ran `magpie codex-relay --addr
127.0.0.1:34871 --pids <sleep>` under a sandbox HOME and curled it as
the extension: POST /v1/chat/completions with Origin
chrome-extension://... -> 503 "magpie isn't running: ... Open magpie for
everything else."; POST /backend-api/codex/responses with that Origin
-> 403 with the new text.

Run on mote at a9c98d8de (base b754cb095): gofmt -l (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
rc 0; go test -tags nogui -timeout 45m ./...: 101 packages ok, no FAIL
(internal/gateway 1081s).
After rebasing onto dcb0f3dcd (gateway, provider and app.js changed
upstream), at e27f946cf: go vet ./..., GOOS=linux and GOOS=windows go vet,
go build rc 0; go test -tags nogui -timeout 45m ./internal/gateway
./internal/provider ./internal/gui ./internal/codexrelay: all ok
(gateway 1086s, provider 335s, gui 296s).
Rebased onto f1c9014cd (agent/wsl, gateway fallback, masking, provider;
none of this change's files) before the push; at abaa78247 only go
build, go vet of gateway and codexrelay, and their TestCodexRelay*,
TestLeave*, TestEnds* were run: ok. The full suite was not rerun there.

Not tried: the user's own extension in Chrome; magpie's Settings page
doesn't change.
2026-11-15 06:27:36 +08:00
yetone f1c9014cd9 wsl, masking: a hung WSL or a slow local model no longer holds requests
vsoullai on X (0.1.4190, Windows): the gateway froze. Each request waited
15s in turn on the local masking model, routing was held 30s and got a
504, and a stopped WSL distro's probe dragged everything down until
redactModel and WSL were turned off. #6167 (Codex held 30s then 504,
fixed by restarting WSL) and #4856 (masking timeouts, 504s) are the same.

WSL (internal/agent/wsl.go, wsl_links.go):
- wsl's lock was held through wsl.exe and through the stat of
  \\wsl.localhost\<distro>, which can't be cancelled. The GUI's look held
  it, and every request's Codex/Claude stand-in, wslUp, distroAt and
  Copilot's WSL folders queued behind it.
- A look (wslRefresh) now runs wsl.exe, the probes and the stat outside
  the lock. Looks take turns on wslRefreshMu, and the lock only guards
  reads and writes.
- wslRoot's stat is bounded (wslRootWait 5s); a distro whose / can't be
  opened fails its probe and is tried again later.
- What a request asks never waits on a look. "Which distros run" is
  asked single-flight in the background and waited for at most
  wslRunningWait (2s). A distro wsl.exe hasn't named as running counts
  as stopped, so nothing opens or wakes a distro on a guess.
- Copilot's WSL sign-in (internal/provider/copilot_cli.go) is read the
  same way: single-flight, waited for at most copilotWSLWait (2s), with
  the last answer kept. Before, its own mutex queued every request
  behind the first one's read.

Masking (internal/masking/masking.go):
- With redactModel on, each request waited up to strictWait (15s). In a
  burst the backlog grew and the requests waited one after another.
- Once a strict request runs out its wait with texts unread, the model
  is "behind". The next requests then wait only defaultWait (2s) until a
  request is read whole or a minute passes (behind, waitFor). The rules
  still mask everything the model hasn't read.

Docs: docs/subsystems/agent-wiring.md (WSL twins) and gateway-routing.md
(masking).

Run:
- New tests, on mote, -race -count=3: TestWSLHangHoldsNoRequest (wsl.exe
  --running, a distro's probe, the stat; each hang injected),
  TestWSLRootHangFailsProbe, TestCopilotWSLHangHoldsNoRequest and
  TestStrictModelBehindWaitsTheDefault, with the other WSL, Copilot WSL
  and masking tests. All ok.
- Broken by hand: the same tests on the old code (origin/main's files
  with only the new tests added). Each WSL hang case failed ("a Codex
  stand-in waited on a hung WSL past 2.2s", "the GUI's look didn't wait
  on the hung WSL"). The Copilot test failed ("13 requests waited on a
  hung WSL past 2.2s"). The masking test failed ("request 2 after the
  model fell behind waited 2.0s").
- Full suite on mica at f08597a58 (this change on b754cb095):
  `go test -timeout 45m ./...`, exit 0, 101 packages ok.
- Rebased on f03869520 (a gateway/provider change). At this head, on
  mica: go test -count=1 ./internal/agent ./internal/provider
  ./internal/masking ./internal/gateway all ok, go vet ./internal/... and
  GOOS=windows vet of those four ok, gofmt clean. The full suite ran at
  the base before it, not again at this head.
- Rebased again on c0cf352a8 (four commits: gateway, provider Codex
  hold, providers base URL, LESSONS). At this pushed head, on mica:
  go test -count=1 ./internal/provider ./internal/masking ok, the WSL and
  Copilot tests of internal/agent ok, go vet of agent, provider and
  gateway (darwin and GOOS=windows) ok.
- gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and
  GOOS=windows: ok.
- Windows (xiaomi-gpu, win-run), internal/agent, internal/provider and
  internal/masking. masking: ok. agent and provider: 52 reds, all in the
  53 that origin/main f03869520 has on the same box (#6068, #1827,
  #5068, #5344, #5950; this run's list is on #6068). None touch WSL,
  Copilot's WSL or masking.

Not tried: a real hung WSL. On xiaomi-gpu, wsl -l -q and -l --running
answered in ~55ms, and a terminated distro's \\wsl.localhost path failed
in 131ms, so the hang was injected in the tests, not reproduced live.

(vsoullai on X, #6167, #4856)
2026-11-15 06:20:15 +08:00
yetone c0cf352a8d gateway: a group member's reply that ends with nothing in it goes to the next member (#6712)
shawn8888's ai-studio (magpie-gemini-web 0.14.0, aistudio2api 0.3.8)
answered a streamed request with 200, a role chunk with "" content, then
finish_reason "stop" and 0 output tokens when Google's every
regeneration came back malformed_response. streamEvent read that Chat
finish chunk as content, so the hold let the stream through as an answer
and group/auto-gemini-4-hydrogen (routing order) never asked agy-cli or
google; the agent got no reply.

A reply's end in an event that says nothing itself is now eventEmptyEnd:
a Chat finish_reason other than length, error or a filter; Messages'
end_turn, stop_sequence or tool_use; a completed Responses reply; Gemini's
STOP. The hold fails the try with a 502 "empty reply: it ended with
nothing in it" only when nothing was said before it, reasoning included,
and only for a group member with another member after it and errors not
passed through (holdWriter.emptyFails). The group's existing empty-reply
branch then asks the next member and rests nobody. A reply held whole is
judged in the one parse settle already made (refusedReply is now
readWhole, which also says empty), so a passing reply is read no more
than before. The last member's empty reply, or a model asked alone, goes
to the agent as it came, so an empty answer can't loop.

Changed on purpose: a Claude member's empty end_turn inside a group with
members left now asks the next member; TestStreamEventRefusals' three
rows for an empty end now say eventEmptyEnd.

Not handled: a stream the hold already let through on its timer (a Gemini
client after 15s) before the empty end came. The plugin side is
BUKOWSKIREAL/magpie-gemini-web#61 (a 502 or error event, not 200 + stop).

Run, on mica:
- new tests red on 369ec0418's fallback.go/gateway.go (checked out over the
  new ones, the unit tables left out): TestEmptyStopFailsOverToTheNextMember
  (chat, messages, responses, gemini), TestEmptyWholeReplyFailsOverToTheNextMember,
  TestEmptyStopEndsAtTheLastMember, TestEmptyEndFromEachUpstreamFailsOver
  (Messages and Responses upstreams) all FAIL; TestReasonedThenStoppedStaysTheAnswer
  passes on both (a guard against reaching too far). All green on the new code.
- go test ./internal/gateway -count=1 (whole package): one red,
  TestStreamEventRefusals' three empty-end rows, updated here; then
  -run 'StreamEvent|Refusal|Empty|FinishReason|Overload|Overflow|ReadWhole|Reasoned|Responses' ok.
- go vet ./internal/gateway, GOOS=linux (nogui) and GOOS=windows vet ok; gofmt -l clean.
- The full go test ./... -timeout 45m runs after the push (ship-at-once);
  its result goes on #6712.
2026-11-15 06:09:25 +08:00