Commit Graph
2204 Commits
Author SHA1 Message Date
yetone c51b0ca9fa sessions: the Antigravity app connected to WSL has its usage read from the distro (@guyng35955 on X)
@guyng35955 on X: on Windows, with the Antigravity app connected to a
WSL Ubuntu, magpie showed no Antigravity usage.

Why. Antigravity 2.x (dist/wsl.js and languageServer.js in its
app.asar) runs a Linux language server in the distro when it is
connected to WSL ($HOME/.antigravity-server/bin/<version>/
language_server, started through wsl.exe with --app_data_dir
antigravity), so the conversations go to the distro's
~/.gemini/antigravity, not %USERPROFILE%\.gemini\antigravity. magpie
read Antigravity's conversations only from this computer's folder:
- sessions.wslAgents had no antigravity (nor agy, whose
  ~/.gemini/antigravity-cli in a distro wasn't read either);
- internal/agent kept a distro for the Sessions page only when one of
  wslKinds or the Copilot CLI's folder was there, so a distro with only
  the app's data never reached sessions.WSLHomes;
- and, found on the Windows box: no SQLite database under
  \\wsl.localhost opens in place. Every form (file: URI, plain path,
  mode=ro, provider.OpenReadOnly) answers SQLITE_BUSY after its 3s
  busy_timeout, since the share doesn't take the locks a WAL database
  needs. So listing the files alone would have shown nothing still.

What changed.
- agent: wslKept keeps a distro with ~/.gemini/antigravity(-insiders),
  and the probe looks for them (no agent row for them).
- sessions: wslAgents reads the app's conversations (insiders under
  their own key) and agy's in a distro; their summary rows name the
  distro's folders as Linux does (agyFolder with goos "linux", so
  /home/me/site, not a Windows path). The distro's calls count in
  Calls (wslFiles("antigravity"), wslCallFiles("agy")). The listing
  kept on disk (sessions-wsl.json) carries each file's row, rev and
  read-only, so a stopped distro keeps its titles and folders. A
  distro's ~/.gemini that is this computer's own (a link) is read once,
  as this computer's (sameDir).
- sessions: openAppStore opens agy's and the app's databases read only
  in place, or, under \\wsl.localhost or \\wsl$, as OpenUntouched does
  (immutable with no -wal, else from a copy of the db and its -wal).
- docs/subsystems/agent-wiring.md says which distros are kept for reads
  only.

Not changed: session-read consent ("allow selected" names agents found
on this computer) doesn't look in WSL, as before for every WSL agent.
OpenCode's and ZCode's SQLite readers aren't used for a distro (not in
wslAgents), so they keep provider.OpenReadOnly.

Run (at the tree rebased on dc85a7ca5; then rebased on c8290df25, which
changes nothing under internal/sessions or internal/agent):
- mote: gofmt -l internal (clean); GOOS=linux go vet -tags nogui ./...
  and GOOS=windows go vet ./... ok; go test -tags nogui -count=1
  -timeout 45m ./internal/sessions/ ./internal/agent/: ok (sessions 104s,
  agent 223s).
- Windows 11 (xiaomi-gpu, win-run): go test -run TestWSL
  ./internal/sessions/ ok.
- Real \\wsl.localhost read on xiaomi-gpu: a fixture conversation
  (WAL) and conversation_summaries.db, and agy's conversations, written
  in the WSL distro magpie-desktop's real ~/.gemini from inside Linux;
  a throwaway test on Windows with WSLHomes at
  \\wsl.localhost\magpie-desktop\home\yeton. Before openAppStore: agy
  listed with no folders, the app's conversation missing, 0
  antigravity calls, listing 6.4s (each open waits 3s for BUSY).
  After: the conversation listed with the distro, its title, folder
  /home/me/site, tokens and 4 calls; agy's folders read; listing
  0.21s. With a writer in the distro holding a title only in the -wal
  (wal_autocheckpoint=0, db held open), Windows read the -wal's title.
  The fixture and binaries were removed after.

Broken by hand:
- the three wslAgents entries and the Calls line out:
  TestWSLAntigravityApp red (no antigravity session from the distro);
- sameDir check out: TestWSLAntigravityLinkedHomeOnce red (listed as
  the distro's);
- the listing's row (m.agy, m.rev) not carried: TestWSLAntigravityApp
  red (no title or folder);
- wslKept without the Antigravity dirs: TestWSLAntigravityHome red
  (no homes).

Not tried: a real Antigravity sign-in connected to WSL (the box's app
isn't signed in, and the connection needs its GUI), so the language
server's own files are this fixture, laid out as its source writes
them; the full suite (five full suites were queued on mote's
suite.lock and two on mica's).
2026-11-14 12:27:25 +08:00
yetone c8290df259 provider: Devin's Adaptive and Fusion picks are no longer served
The live gateway's /v1/models listed devin/Adaptive and devin/adaptive,
and Devin answered both with 502 "no API providers are available".
They came from magpie, not the plugin: the plugin's list (and its cached
copy in plugin-providers.json) has neither, since parseFamilies and
parseConfigFamilies skip Adaptive and Fusion. The owner's providers.json
keeps "Adaptive" and "adaptive" in the devin entry's picks (models), saved
when the built-in still listed Devin's router families, before ce8d0e065
served Devin's chat API. A pick only leaves Models when a list that had it
stops having it (dropGonePicks), and no list fetched since ever had these,
so after the move to the plugin they were served as picks of the user's
own (Exposed's unlisted picks) and offered to every agent.

normalize now reads a devin provider's Models and Delisted without
Adaptive and Fusion, in any case (devinRouter, withoutDevinRouters, which
devinModelsFlatten now uses too). Every reader that goes through All
(the gateway's /v1/models, the agents' lists, the editor's Picks) sees
them gone, so old files are fixed for every user on read; the next Save
writes the file without them, and a save that sends one back drops it.
Scoped to provider id devin: another provider's "adaptive" is its own.

Not changed: AccountModels (an account's own list only narrows what it
serves; dropping a lone "adaptive" there would widen it to every model),
Fallback ("devin/adaptive" as another provider's fallback is still tried
and refused) and settings.json's hiddenModels/picked lists (they hide or
pick, never add a model). PickedFrom keeps them, which only means "listed
then". The plugin needs no change.

Run:
- TestDevinRouterPicksNotServed (new): a sandbox HOME with the owner's
  devin entry as written, the plugin moved and its list cached. Red on
  the old provider.go: "served [Adaptive adaptive swe-2 claude-opus-5-5
  Fusion fusion], want [swe-2 claude-opus-5-5]"; green with the change.
- Real data: magpie built at a83fe2325 and at this change (-tags nogui,
  on mica), `magpie models` under a sandbox HOME holding copies of the
  owner's devin entry from providers.json, plugins.json, plugin-auth.json,
  migrations.json and plugin-providers.json. Old: devin/Adaptive and
  devin/adaptive first under Devin, as the live gateway lists them. New:
  the list starts at devin/swe-2, the rest unchanged.
- Full suite on mica through suite.lock at 3b164fafb (this change on
  a83fe2325): gofmt -l empty, go vet ./..., GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./..., go build for darwin, linux (nogui) and
  windows, go test -tags nogui -count=1 -timeout 45m ./...: suite exit 0,
  99 packages ok, no FAIL.
- Rebased onto dc85a7ca5 (56 files changed upstream, b76016676 in
  internal/provider): gofmt, vet (darwin, linux, windows) and
  internal/provider's tests again there: vet-ok, ok internal/provider 156s.
  Then rebased once more onto 74c94b5db and e36541ddf (internal/gui
  appearance and site/ only, not re-run).

Not tried: a request through a real gateway, since the requests that
still go (devin/swe-2 and the rest) take no path this change touches.
2026-11-14 12:25:28 +08:00
yetone 74c94b5db0 gui: a picked accent tints the theme's grounds (CHENGJIAHEGOXIS on X)
CHENGJIAHEGOXIS asked, on 0.1.4112 and again on 0.1.4116 ("依然没变,是不是
出bug了"), for the dark theme to follow the colour they picked. v0.1.4114
(a83fe2325) tinted only the chosen thumbs (--mark-fill). Their 0.1.4116
screenshot shows those thumbs purple, but the page, sidebar and cards are
still neutral grey: bg (25,25,27), card (32,32,34). Nothing tinted the
grounds.

lookCSS now also sets the theme's grounds from the picked colour.
- Window, light: --bg, --card-2, --pill, --pill-hover, --seg-track, --line,
  --line-2. Cards stay white.
- Window, dark: --bg, --card, --card-2, --pill, --pill-hover, --line,
  --line-2, plus the menus' --pop-bg.
- Tray panel: the body.panel grounds, in light and dark. tintPanel and the
  Windows title bar read --bg, so they follow.
Each ground takes 5% (light) or 8% (dark) of the colour's offset from its
own grey (base + k*(c - mean(c))). Lightness is kept, so a grey pick changes
nothing. With no accent, or under Omarchy, nothing is drawn.
accentOn and --mark are checked against the tinted grounds too.

Tests:
- TestAccentTintsGrounds covers:
  - every block is tinted;
  - lightness is kept (contrast to the base <= 1.1);
  - a grey pick changes nothing;
  - text is >= 7:1 and the accent >= 4.4:1 on the tinted --bg and --card,
    for many picks;
  - no accent gives no CSS.
- TestTintBasesAreAppCSS holds the Go bases to app.css.
- TestLookFixture holds tests/fixtures/look-accents.json to lookCSS
  (UPDATE=1 rewrites it).
- appearance-look.test.cjs now reads the real CSS from the fixture. A new
  case, in each engine and theme, picks a colour on Settings › General with
  and without a wallpaper, and checks:
  - the list, the sidebar and the body are tinted;
  - Default turns them grey again;
  - the panel's --bg is tinted.

Run on mote, at this commit rebased on origin/main 7b002b6be:
- gofmt -l internal/gui: clean.
- go vet -tags nogui ./internal/gui, the same with GOOS=linux, and
  GOOS=windows go vet ./internal/gui: ok.
- go test -tags nogui ./internal/gui: ok (126s).
- node --test, in both engines, of: appearance-look, omarchy,
  api-key-theme, checkbox-look, sidebar, settings-sections,
  settings-groups, i18n-keys, panel-options-fold and the seg-/theme files.
  Result: 120 of 138 pass. The 18 reds are api-key-theme (6, #6444),
  omarchy (#6027) and settings-groups' warm-ups case (#6597). On a fresh
  origin/main b005d1a47 the same three files give the same 18 reds.
- Screenshots in both engines: Settings › General, dark, zh, the reporter's
  purple #66258d. With no accent the ground is (26,26,30) and the card
  (35,35,39). Before this change the purple pick gives the same values.
  After it, the ground is (27,21,34) and the card (36,30,43).

Rebased on origin/main dc85a7ca5 (then e36541ddf, site/ only; 4 commits, none in appearance, app.css
or boot.js) and run again on mote at this head:
- go test -tags nogui -run 'TestAccent|TestLook|TestTint|TestWallpaper|Budget'
  ./internal/gui: ok.
- appearance-look and i18n-keys: 44 of 44.

Broken by hand: with both tints at 0.0 and the fixture regenerated,
TestAccentTintsGrounds fails and the four new GUI cases are red. Both pass
again with the change restored.

Not tried:
- the real macOS app, WebView2 and WebKitGTK;
- the full Go and GUI suites.
2026-11-14 12:24:31 +08:00
yetone 7b002b6be8 library: an MCP command's %USERPROFILE%, $USERPROFILE and ~\ are the home on every system (0xBCD18E on X)
0xBCD18E's Library server ran
"%USERPROFILE%\AppData\Local\Programs\Pinky\pinky.exe", and the check
said it couldn't find "%USERPROFILE%\A…": magpie read $NAME, ${NAME}
and ~ in a command but not cmd.exe's %NAME%, so the only way to share
one server across computers with different user names was a per-device
command.

Now HOME and USERPROFILE are both the home, on every system, as $NAME,
${NAME} or %NAME% (either case), and a leading ~ or ~\ too:
- library.json (and so sync and backups) keeps them as written;
- an agent that reads references in a command (Claude Code, CodeBuddy,
  WorkBuddy, Grok, Gemini, omp/Qoder/AtomCode, OpenCode, Cursor) is
  given the home's own variable where it runs: ${USERPROFILE} on
  Windows, where an agent seldom has HOME, ${HOME} on a Mac, Linux and
  in WSL, where nothing has USERPROFILE. Before this, $HOME went to
  Claude Code on Windows as ${HOME}, which it usually hasn't;
- every other agent (Codex, Kiro, Droid, Copilot, Crush, Goose, Pi, ...)
  and magpie's own start (the check, the router, Codex through the
  gateway) get the home's path;
- any other %NAME% (%APPDATA%) is a variable on Windows only, and is
  left as written elsewhere, so 100% or %Y% in an arg stays as it is;
- a command's environment: a leading ~ and %USERPROFILE% / %HOME% in a
  value are put in as the home for every agent and for magpie's start
  (homeEnv); ${NAME} there stays envref's.
No cwd: a Library server has none.

Tests: TestCmdVarsUserProfile forces cmdOS to windows, darwin and linux
for Codex, Claude, Cursor, OpenCode and Claude in WSL, command, args
and env; TestCmdVarsUserProfileLaunch starts a real server by
%USERPROFILE%<sep>prog, %HOME%/prog and $USERPROFILE/prog.
TestCmdVarsPerAgent pins the Unix variable; TestCmdVarsSync expects
${USERPROFILE} in .claude.json on Windows.

Run: the red was checked on origin/main e0889719c's cmdvars.go,
mcp_check.go and mcp_run.go with these tests: all 8 subtests of
TestCmdVarsUserProfile and TestCmdVarsUserProfileLaunch FAIL; with the
change, ok on mote (darwin), on xiaomi-gpu (Windows 11, win-run: the
real check starts the server by %USERPROFILE%\prog, and Claude Code's
.claude.json gets ${USERPROFILE}/bin/x) and in WSL magpie-desktop
(wsl-run). Full suite at b84b6dc3c (this change on e0889719c) on mica
under suite.lock: gofmt -l clean, go vet, GOOS=linux go vet -tags
nogui, GOOS=windows go vet, the three builds, and go test -tags nogui
-count=1 -timeout 45m ./...: 99 packages ok, suite exit 0. Rebased onto
8df4239a8; internal/library run again there.
Not tried: a real agent (Claude Code, Codex) launching the server on
Windows from its written config; no GUI change.
2026-11-14 12:04:38 +08:00
yetone 90932ed1fa gateway: Claude Code's model discovery is shown every model by an id it keeps
Claude Code's Gateway Model Discovery (CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY)
puts in /model only the ids matching /(claude|anthropic)/i: Tvi in the
2.1.316 bundle, te.data.data.filter((se)=>/(claude|anthropic)/i.test(se.id)),
on GET <ANTHROPIC_BASE_URL>/v1/models?limit=1000 with User-Agent
claude-code/<version> (Xs(), not claude-cli/) and anthropic-version:
2023-06-01. A remote magpie's Kimi, GLM and DeepSeek never showed (zent00
on X, tweet 2121440002244747428).

That request alone (claudeCodeDiscovers: the User-Agent and the header,
never another magpie) is now shown a chat model whose id says neither by
Claude Desktop's alias anthropic/magpie-<n> (aliasFor), which unprefixed
already serves as the model for every client, before any provider's
model of that spelling; no Claude id is spelled so. Its display_name is
the agents' list name, which /model shows. Ids Claude Code keeps, names a
gateway key gives models, and every other client's list are unchanged; a
bare-id row it wouldn't keep is left out (its full id's row is there).
"anthropic/<magpie id>" was not used: a provider named anthropic (the
Anthropic preset's id) serves any model asked by that spelling. Zero
config, so no switch.

Run:
- TestClaudeCodeDiscoveryKeepsEveryModel, on mote: red on the old
  gateway.go ("not shown anthropic/magpie-9301644634 for auto/kimi-k3"),
  green with the change; with the anthropic-version check broken by hand
  it fails on the claude-cli/ client. TestCindyDiscovery and the Desktop
  tests green.
- Real Claude Code 2.1.316 binary on mote, sandbox HOME, against the
  gateway with a fake Anthropic upstream: its cache gateway-models.json
  held {"id":"anthropic/magpie-4484984192","display_name":"DeepSeek V4 ·
  DeepSeek"}; `claude -p --model anthropic/magpie-4484984192` answered
  PONG and the upstream was asked model deepseek-v4. Claude Code warns it
  assumes a 200k window for an id it doesn't know, as for any non-Claude
  id.
- gofmt -l: clean. Package vets/builds and go test ./internal/gateway
  started on mote; the full suite (go vet, GOOS=linux/windows vet,
  builds, go test -tags nogui -timeout 45m ./...) is queued under
  mote's suite.lock and runs after the push, per the ship-at-once rule;
  its reds get their own commits.
Not tried: interactive /model screen (the rows come from that cache
file), a real remote magpie over LAN with a gateway key.
2026-11-14 11:43:27 +08:00
yetone c5b40bf898 claude-desktop: after Use Claude Magpie the lit row is Claude Magpie, and its Code tab's row says it is on magpie (xMopf7RF on X)
xMopf7RF on X, 0.1.4111: clicking Use Claude Magpie seemed to connect
their own Claude Desktop, and left "Claude Code · Claude Magpie" saying
"Not connected · uses its own settings" with its switch off.

The wiring was right: with the Separate app on, connecting claude-desktop
writes only Claude-Magpie-3p's config (desktopSets), and the user's own
Desktop is left alone. The page said otherwise twice:
- the row that turned on was still named Claude Desktop. While the
  Separate app is on, state() now names the claude-desktop row Claude
  Magpie (desktopiso.Name), since that is the only config it wires.
- the claude#magpie-desktop row is not wired itself, and need not be:
  Desktop's Code tab runs Claude Code with
  CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST, so its requests go through
  Claude Magpie whatever that folder's settings.json says. While Claude
  Magpie is on magpie, the row carries twinCode (agent.DesktopTwinCode)
  and its line, lit, says "On magpie through Claude Magpie" (en, zh,
  zh-TW, ja, de).

The core script budget goes up 67 for that one connectLine line, cut to
the shortest words that say it; the Agents rows draw it, so there is no
page to move it to. docs/subsystems/agent-wiring.md says both.

Tests:
- TestClaudeMagpieCodeTabRowIsOnThroughIt (agent): DesktopTwinCode only
  for claude#magpie-desktop, only while Claude Magpie is on magpie.
- TestClaudeMagpieRowsAfterUseClaudeMagpie (gui): sandbox HOME, POST
  connect after turning the Separate app on: the wired row is named
  Claude Magpie, the Code tab row has twinCode, the user's own Desktop
  config is unchanged and no Claude-3p folder is made.
- desktop-twin-code.test.cjs: clicks Use Claude Magpie; no lit row is
  named Claude Desktop, the Code tab row's line is lit and fits, the
  click doesn't scroll; en/zh/zh-TW/ja/de, 1100 and 640 wide, Chromium
  and WebKit.

Run (mica; mote's load was over its cores), at e0889719c + this change
(the one later main commit, a83fe2325, is CSS and Go appearance only):
- gofmt -l clean; go vet -tags nogui ./internal/agent ./internal/gui on
  darwin, GOOS=linux and GOOS=windows: ok.
- go test -tags nogui -count=1 ./internal/gui (whole package, budget
  included): ok; ./internal/agent -run 'Claude|Desktop': ok.
- node --test, both engines, every agent-*, desktop-*, library-desktop-*
  and i18n-* file (78 files, 1358 tests): 1303 pass, 55 red in 4 files,
  each red the same at origin/main e0889719c and filed:
  agent-details-ready (#6373, #6369), agent-switch-accounts (#5925),
  agent-menu-label (#6371), desktop-tiers (#6475). desktop-twin-code 20
  of 20, desktop-twin, desktop-isolated, desktop-isolated-claude,
  library-desktop-twin, i18n-keys, i18n-en-no-cjk ok.

Broken by hand: at origin/main e0889719c (api.go given only the
TwinCode field, DesktopTwinCode stubbed false), both Go tests are red
("Claude Magpie on: \"Claude Desktop\" wired false"; the code row not
on), and desktop-twin-code is 20 of 20 red ("Not connected · Claude
Code · Claude Magpie uses its own settings").

Not tried: a real Claude Magpie.app in a sandbox HOME on this change
(005178104 did one for the button itself); this change only names rows
and reads the same wiring.
2026-11-14 11:42:50 +08:00
yetone b325718f0a antigravity: turned-away lines go reworded, not broken up; Antigravity min 0.1.12 (#1118)
Since 11-14 Google's check reads past invisible characters. A system
prompt with Claude Code's billing line and Agent SDK line, broken up
with two U+200B in every word as the cloak sent them, was turned away
5 of 5 with the bare 429 "Resource has been exhausted". Claude Desktop's
Code tab through magpie to Antigravity failed every turn (hc295971796
on X, tweet 2121429628019781849), and on v0.1.4110 with the Antigravity
Cloak plugin Antigravity hit 429 very often (daoche_wuzui, tweet
2121432333769433178).

The built-in cloak (codeassist.go) now rewords each line Google turns
away, in plain words:
- the x-anthropic-billing-header line is left out to its line's end; a
  system part or message holding only it is dropped;
- "built on Anthropic's Claude Agent SDK" -> "built on the Claude Agent
  SDK by Anthropic";
- Codex's "based on GPT-5" -> "built on GPT-5";
- Hermes' "created by Nous Research" -> "built by Nous Research";
- omp's RFC "keywords" -> "key words".
A copy an older magpie or middleware broke up (U+200B, U+2060, soft
hyphen, inside or between words) is matched and reworded as the line.
The Code tab's main line passes as written and is kept.

The plugins repo's packages carry the same rewording (plugins 5bb41941:
opencode-antigravity-auth 0.1.12, opencode-agy-cli-auth 0.1.41,
middleware-antigravity-cloak 0.1.7 on the dist branch). The Antigravity
mover's min goes to 0.1.12, the version dist has (these packages are
not on npm); the cloak middleware is Official and updates itself.

Run:
- real Antigravity account, sandbox HOME, gemini-3.8-flash, 10
  sequential requests each through the new plugin: Code tab main prompt
  as Claude Desktop sends it 10/10 200, Agent SDK subagent line 10/10,
  an old two-U+200B copy 10/10, Codex GPT-5 10/10, Hermes' earlier
  persona 10/10, omp's RFC line 10/10. The zero-width break went 0/5.
- mote-run: gofmt -l; go vet, GOOS=linux go vet -tags nogui and
  GOOS=windows go vet of internal/gateway, provider, cli;
  go test -count=1 -timeout 45m ./internal/gateway/ ./internal/provider/
  ./internal/cli/ ./internal/middleware/: all ok (gateway 926s);
  vet clean, gofmt clean.
Broken by hand: codeassist.go from origin/main with these tests: 6 fail
(TestAntigravityCloakClaudeCode2316, ...RewordsEveryLineItTurnsAway,
...AnswersHermesAndCodexByDefault, TestOnlyAntigravityIsSentThePrompt
Reworded, ...LineWrappedOrWidened, ...TurnsCodexsGPT5ThreadAwayOnce).
Not tried: models other than gemini-3.8-flash; the whole go test ./...
(only the four packages this touches); Claude Desktop itself (its Code
tab's system prompt was captured and replayed instead).
2026-11-14 11:42:32 +08:00
yetone 71a806749d sessions: a paginated Codex rollout moves to a longer provider id by its row (@xMopf7RF on X)
@xMopf7RF on X (tweet 2121441393424113800): the Sessions page's Move
refused an old Codex session with "rollout-2026-03-09T09-25-….jsonl.zst
keeps its history by byte, and "magpie" is longer than the provider it
names: Codex couldn't open it moved", and offered nothing else.

Since 67b12956a a paginated rollout's session_meta is only rewritten at
its own length (Codex keeps places in it by byte), and MoveCodexProvider
refused a longer id outright. But Codex reads a paginated thread's
provider from its row in the state database, never from its file
(codex-rs read_thread; RetagPagedCodexThreads already moves such threads
by the row alone, tried with the real codex 0.166). So now
rewriteCodexProvider leaves such a line as it was and says so (kept),
and moveCodexPaths moves the thread by its row. Every caller gets it:
the Sessions page's Move, Resume's move first, and the sync's
MoveCodexThreads/MoveRecentCodexThreads, which met the same refusal for
a provider shorter than magpie.

With no row to move it by, it can't move at all: it is refused as
sessions.StuckError, every file put back and no trash copy left, and the
API says stuck with the provider it stays on. The page then says why,
that the session stays on that provider unchanged and shows in Codex when
Codex uses it again, and that Delete clears it into magpie's trash, where
it can be restored. New string in zh, zh-TW, ja and de.

Run, at 7951989c6 (on origin/main e0889719c):
- go test -count=1 -run 'TestMoveCodexProvider|TestRetagPaged|TestPortCodex'
  ./internal/sessions/ on mote: ok.
- Old code back (codex_provider.go from e0889719c, StuckError stubbed):
  TestMoveCodexProviderPagedByRow and TestMoveCodexProviderPagedNoRow
  FAIL with the reporter's exact error text; green with the change.
- node --test sessions-codex-provider-stuck, sessions-codex-provider,
  sessions-codex-provider-pick, i18n-keys, i18n-en-no-cjk on mote,
  Chromium and WebKit, five languages, 900px and 420px: 42 of 42 pass.
  The new GUI file with the old client.js: 0 of 20 pass.
- gofmt -l on the changed packages: nothing.
- Full suite (vet x3, builds x3, go test -tags nogui ./... -timeout 45m)
  queued on mote's suite lock; pushed before it ran, per the owner's
  ship-at-once rule. Its result goes in a follow-up.

Not tried: a real Codex resuming a thread moved this way. The row-only
move is the one RetagPagedCodexThreads makes, which was tried with codex
0.166.0 exec resume (docs/subsystems/agent-wiring.md). Not reproduced:
the no-row case with real Codex, where Codex 0.166 keeps a row for every
paginated thread; it is covered by a fixture only.
2026-11-14 11:42:17 +08:00
yetone e0889719c8 gateway: a Responses WebSocket turn streams without the HTTP stream field (#5291)
OpenAI's WebSocket mode doesn't use the HTTP stream field: a
response.create leaves it out and is streamed all the same. magpie made
each frame into the HTTP body its route would have had and kept the
field as the frame said it, so a client that left it out (M4n5ter on X,
AnacondaKC's Niko in #5291) got the provider's reply unstreamed and
every frame of it at the end. Codex sends stream:true itself, so it
never showed there.

turn now sets stream:true on every generating turn, whatever the frame
says (left out or false). It is the one place the three socket routes
(/v1/responses, /responses and Codex's backend route) make their body,
so all three are covered; a warmup (generate false) still answers
locally before it, and HTTP POSTs are unchanged.

Ported from AnacondaKC's patch in #5291 (62e3fd1ad), with these
differences: the test runs on /v1/responses and /responses, with stream
left out and with stream:false, checks the body sent upstream, and
TestCodexSocketStreamsWithoutStreamField covers Codex's route.

Tests: TestResponsesSocketStreamsWithoutStreamField and
TestCodexSocketStreamsWithoutStreamField, both red with responses_ws.go
at origin/main 8ed2ae030 ("no text delta before the upstream
completed"; "sent to ChatGPT unstreamed"), green with the change (on
mica). go vet ./internal/gateway for darwin, linux (nogui) and windows
on mote; gofmt -l clean.

Full suite (go test -tags nogui -count=1 -timeout 45m ./...) runs on
mica after the push; its result goes on #5291.

Not tried: a real client (Niko or the reporter's) against a real
provider.
2026-11-14 11:05:49 +08:00
yetone 8ed2ae030c claudetui: an image goes into the interactive mode on Windows 10 as a long paste, not -p (ok123now on X, #5061)
ok123now (magpie v0.1.3901, Windows 10 LTSC 21H2, Claude Code 2.1.316,
Claude Desktop): text worked, one 64x64 PNG was a 502 every try, and the
client asked again without end.

Cause: the helper pastes an image as its file's path in bracketed-paste
marks. Windows 10's conhost (10.0.19041) drops the marks on the way in
(the reporter's lead; #5061 and #5205 measured it on 19044 and 19045),
so Claude Code got the path as typed words, the helper waited out
pasteWait and exited 1, and the gateway answered 502.

Fix:
- claudetui: Claude Code reads its console as VT input (mode 0x208, read
  from a real claude.exe 2.1.316) and takes one read of over 800
  characters as a paste with or without the marks ($X=800 in 2.1.316,
  q6=800 in 2.1.281), a path with spaces after it as the image alone. On
  Windows the path is sent padded with spaces to 900 characters, no
  marks: over 800, and under the 1024-byte blocks the same conhost loses
  of a longer write (#5205). Elsewhere it stays bracketed.
- If the interactive mode still doesn't take a message (an image, or a
  block it can't paste), the helper ends the turn with an error result
  beginning claudetui.Unpastable instead of exiting, the gateway asks it
  once as claude -p with the image itself, and remembers that for 12
  hours. A redo that can't run is a 400, not a 502, so no client loops.
- The reporter asked to keep images interactive: -p counts at about
  twice the plan quota and has none of the interactive run's cache. The
  -p reason (Routing chip, all four locales, and the log line) says so.

Run, at this head (rebased on 925bc7188):
- win-run (Windows 11 26200): ./internal/claudetui; every test passes
  but TestShimFirstMessageWaitsForTools, red on the old code too (#4810).
  TestShimPaddedImageTakenWithoutMarks 3 of 3, TestImagePasteWindowsLength.
- The helper on a real claude.exe 2.1.316 in a ConPTY (sandbox
  CLAUDE_CONFIG_DIR, ANTHROPIC_BASE_URL to a closed port): padded and
  bracketed, the image reached the transcript as an image. A direct
  probe: bracketed and padded paths shown as [Image #1], a bare path
  stays words.
- wsl-run: ./internal/claudetui ok; go vet of claudetui and gateway on
  Linux and Windows.
- GUI: routing-entry, routing-intent-entry, claude-mode,
  claude-tui-setting, i18n-keys, i18n-en-no-cjk in Chromium and WebKit
  (Linux), 112/112.
- Full suite, wsl-run (Linux), go test -tags nogui -timeout 45m ./...:
  every package ok (gateway 883s, claudetui 164s) but internal/usage's
  TestRequestStateKeptAcrossACatalogFetchedAgain, a catalog CacheKey red
  already filed as #6572 and untouched here. The mote suite stayed queued
  behind other sessions' runs, so the suite ran on Linux.

Broken by hand: TestShimPaddedImageTakenWithoutMarks on the old code
(bracketed paste, fake console dropping the marks) is red: the shim
wrote 1 line of 3 in 30s. Its bracketed half is the old behaviour and
ends in an Unpastable error result, not an exit.

Not tried: a real Windows 10 21H2 console (no such box here); the -p
redo with a real Claude subscription. Long pasted text on Windows 10
still loses 1 KB blocks (#5205); this doesn't change that.
2026-11-14 10:48:55 +08:00
yetone 925bc7188b usage: the Requests card's up arrow opens what the bytes sent upstream were made of
theforeveriris (X, 2121408745616162998) saw 8169 requests send 8.6 GB
up and 1.0 GB down and wanted to know why. About 1 MB a request is
normal: every request sends the whole conversation again, with the
system prompt and the tools' definitions. This shows it.

Gateway: promptOf, which already parses the body off the request path,
now also counts the bytes of the system prompt, the tool definitions
and images in the body it read. upParts scales those to the wire bytes
and puts them on Record.UpParts. Nothing new runs on the request path,
and a body that isn't parsed stays "Not measured".

Usage: a packed row keeps the mix in 255ths under flag rowUpParts
(32768); the row stays 152 bytes. Totals gain up_calls, up_measured,
up_system, up_tools and up_images, and Shares carry up_bytes and
up_calls by agent and by model. settledCountVersion goes 4 -> 5, so
settled days are counted again once on the next start.

GUI (Usage -> Requests): the "↑ 8.6 GB" on the Requests card is a
button that opens a "Sent upstream" card: the average per request, one
sentence on why, a bar and legend for Conversation / Tool definitions /
System prompt / Images / Not measured, and the top 8 agents and models
with bytes sent and per request. The open state is kept; × closes it.
A request's details get a "Made of" line. zh, zh-TW, ja, de strings.
Entrance is 200ms ease-out, no movement under reduced motion.

Run (mote, at this head on 27e43ed26):
- go test ./internal/usage ./internal/usageapi: ok
- go test -run 'Prompt|UpParts|UpBytes|DownBytes|Traffic|Ledger|
  CodexOwnTurn' ./internal/gateway: ok
- go test -run Budget ./internal/gui: ok (after the rebase)
- go vet -tags nogui for darwin, linux, windows on usage, gateway,
  usageapi, gui: ok; gofmt -l clean
- GUI: usage-upload.test.cjs 32/32 (chromium + webkit, 1180 and 420,
  en zh zh-TW ja de); with i18n-keys, i18n-en-no-cjk,
  usage-ledger-bytes, usage-traffic, usage-ledger-detail: 144 pass,
  0 fail
- GUI subset i18n*, usage*, ledger* at f1f34d624: the only reds are
  usage-agents-hide, usage-cards-hide, usage-fold,
  usage-hidden-way-back, usage-ledger, usage-range-times and
  usage-speed-all-models. They are red the same way on origin/main
  f1f34d624 without this change and are already filed (#3414, #3415,
  #6003, #6294, #6295, #6499, #5834).
- Screenshots of the card: chromium en 1180 light, webkit zh 1180
  dark, chromium zh 420 light.
- Benchmark: promptOf on a 1.17 MB body, 2.8-3.9 ms/op with counting
  vs 3.2-3.7 without, same allocations (noise).
- Broken by hand: without the b.again guard,
  TestPromptKnowsWhatItsBytesWere goes red.

Not run: the full go test ./... and the full GUI suite. mote and mica
were loaded, with a suite already queued under suite.lock.
2026-11-14 10:22:25 +08:00
yetone ed63a5be5e gui: a picked accent colours what is chosen (CHENGJIAHEGOXIS on X)
「选中任意强调色没反应」: picking an accent in Settings › General seemed
to do nothing. The token did apply. With the real server, in Chromium
and WebKit, under light, dark and system, with and without a background
image, --accent was set by lookCSS and kept. Neither the theme nor the
wallpaper overrode it. But nothing on Settings, the sidebar, the header
tabs or the panel's tabs used --accent: every chosen option is graphite,
var(--fg), by design. So the colour only showed in a few buttons
elsewhere.

The fix is a --mark token, the ink of what is chosen.
- It is var(--fg) by default, so magpie's own look is unchanged, like a
  Mac's Graphite.
- accentVars sets it once the user picks an accent. It is moved toward
  black (light) or white (dark) until it reads at 4.5:1 on the surfaces a
  chosen option sits on: --pill-hover #e9e9ee, and the dark switch thumb
  #4c4c52.
- It is used by .seg/.opt/.ptabs/.warm-tabs/.am-seg/.klf-tab/.day-chip/
  .apptab .on, the header nav's chosen tab, the side-nav's open-page icon
  and Settings icon, and Library's switches and radios. Each is the same
  "chosen" role, so all of them follow the accent, not just one.

Tests:
- appearance_test.go's TestAccentReadable checks --mark's contrast on
  each surface, in both themes.
- appearance-look.test.cjs adds 8 tests, in Chromium and WebKit, light
  and dark:
  - Settings' theme and bird options and the side-nav icon at 1200 with a
    wallpaper set: graphite by default, the mark for #0d9488 and #db2777,
    and back to graphite on Default.
  - The header tabs at 900 and the panel's tabs at 380.

Run:
- gofmt clean. go vet ok on darwin, GOOS=linux -tags nogui and
  GOOS=windows (at 75bdc85fe, the same change on an older main).
- At 6f5549b1f (this change on 08f77528f), on Linux (WSL magpie-desktop),
  since mote's suite queue was hours deep:
  - The whole GUI suite, Chromium and WebKit, every language and the
    panel widths: 27231 tests, 1258 red in 183 files. The same 183 files
    at the parent were 1226 red. The 70 tests red only with the change
    were rerun with their 43 files at concurrency 2: 80 red with it, 89
    at the parent 783b69b8c. Every one left has a language or width
    sibling red at the parent too. None is about colour. They are the
    Linux reds #5559 and #4388 track.
  - go test -tags nogui ./... -timeout 45m: every package ok except
    internal/usage's TestRequestStateKeptAcrossACatalogFetchedAgain,
    red the same at the parent (#6572).
- At the pushed head, on mote (macOS):
  - TestAccent*, TestWallpaper*, TestLook* ok.
  - appearance-look 36/36, i18n-keys 4/4, library-all 26/26.
  - segs-press-redraw 16 red and api-key-theme 6/6 red, the same counts
    at the parent 6c88d61f0 (#4566, #3922, #6444).
  - TestCoreScriptBudget is red (1269382 > 1268961), the same at the
    parent. 92e760f3d took it over (#6518, taken). This change adds no
    script.
- Broken by hand:
  - With the old app.css and library.css, the 8 new GUI tests are red,
    8 of 8.
  - accentVars without --mark: TestAccentReadable fails ("…;--sel:#efefef",
    no mark).

Not tried:
- The whole GUI suite and the Go suite on macOS at the pushed head. mote's
  suite.lock queue was hours deep, so they ran on Linux instead.
- The real macOS app.
- Windows WebView2, and Linux WebKitGTK.
- Charts' --c1 series colour still does not follow the accent; that is
  left as it was.
2026-11-14 09:58:38 +08:00
yetone 4e770f733a library: subagents imported from a repository
CHENGJIAHEGOXIS on X asked for an easy way to install a repository of
subagents such as msitarzewski/agency-agents. Library → Subagents now
has a find line. It takes what the skill installer takes: owner/repo, a
GitHub or GitLab link to a repository, folder or file, any git address,
or a folder on this computer. It lists the subagents found, lets the
user tick all or some, and imports them as Library subagents for the
agents ticked.

- Fetching is the skill importer's: resolvePluginRoot's source handling
  moved into fetchSourceRoot, which both use. tooBig still refuses a
  whole repository that is too big and asks for the folder's link.
- A subagent is a Markdown file whose front matter has a description.
  - Its name is the slug of `name`. In an `agents` or `droids` folder
    with no `name`, it is the file's own name.
  - The description is folded to one line of at most 1000 characters.
  - The body is the prompt.
- Dropped: every other front-matter key (agency-agents' color, emoji
  and vibe, and tools, model, author or anything else). A Codex TOML
  role is not read. A skill's folder (one with SKILL.md) and .git,
  .github and node_modules are skipped.
- Two files with one name: the shallower is taken, and the other is
  listed as left out, with why. So is a file Subagent.check refuses.
- An imported subagent records its source and file (From) and a hash
  of its description and prompt as imported (FromHash). Imported again,
  a subagent from the same file is:
  - have, when it is unchanged;
  - update, when upstream changed and the library's copy still matches
    FromHash (description and prompt replaced; agents, skills, servers
    and model kept);
  - edited, when the user changed it in magpie (left as it is).
- A name the library already uses for another subagent is never written
  over: the import takes the next free name-N.
- A carried library carries From.
- The page has Select all, a filter past eight, a tag per state, the
  files left out, and a summary of what was imported and updated.
  i18n: zh, zh-TW, ja, de.
- The fixture is agency-agents' own files in
  internal/library/testdata/agency-agents. No test reaches the network.

Run on 80ae5ba24, which is this change on e730a14dc:
- gofmt -l is clean. GOOS=linux and GOOS=windows go vet -tags nogui
  ./... are clean (mote).
- go test -tags nogui -count=1 -timeout 45m ./... on mica: 98 packages
  ok. internal/cli's TestEveryRouteHasACommandOrIsNamed was red because
  the new POST /api/library/subagents/probe wasn't named. It is now in
  notYet beside skills/probe and plugins/probe, and the test passes.
- GUI files run in chromium and webkit, in every language:
  - The new library-subagents-import.test.cjs and the doc's Library
    list: 117 of 118 passed. The red was i18n-keys: "{n} subagents" is
    the sessions plugin's key. The keys now use {count}.
  - A second run of the doc's Library list, i18n*, project-subagents,
    skill-install-* and plugin-*: 1652 of 1768 passed. The 116 reds are
    in 7 files that fail the same way alone on a fresh origin/main
    (e730a14dc): 116 there, 114 at this head. Each has an open issue:
    - found-skill-pick-remove: #4097 and #5013
    - plugin-option-placement: #6559
    - plugin-signin-no-url: #5938
    - plugin-signed-out-account: #5998
    - plugin-move-unserved: #4392 and #4410
    - plugin-page-foreign-error: #6117
    - plugin-card-update: #3079

Run at the pushed head, rebased on eb1b83000, on mica:
- gofmt -l is clean.
- go test ./internal/library ./internal/gui ./internal/cli: ok.
- library-subagents-import, library-subagents and i18n-keys: 38 of 38
  passed.

Broken by hand, each red, then reverted:
- Clash renaming off (`false && taken[name]`):
  TestSubagentImportLeavesTheUsersOwn red.
- The edited check made `case true:`: TestSubagentImportAgainUpdates
  red (paid-media-auditor read as update).

Real import, in a sandbox HOME magpie web on mote (built from this
change), with Claude Code and
Codex detected:
- The probe of https://github.com/msitarzewski/agency-agents found 283
  subagents. One was left out: the mcp-memory copy of
  backend-architect.
- Importing all 283 wrote 283 files to ~/.claude/agents (only name and
  description in the front matter) and 283 TOML roles to ~/.codex/agents.
- A probe of .../tree/main/engineering then showed 66, all have.

Not tried: the Windows and Linux runtime, GitLab and plain git sources
against real repositories, an agent in WSL, a repository over tooBig's
limit.
2026-11-14 09:11:31 +08:00
yetone eb1b830004 gateway: Cindy is told each model by its name with its provider's (cdredfox on X)
Cindy's picker listed magpie's GLM-5.3-Flash three times, 千问 3.8-Flash
and DeepSeek-Flash twice each, with nothing to tell them apart. Cindy
0.1.94's model discovery (parseModelsListResponse in its app bundle)
names a row by display_name before name, and magpie's display_name is
the bare model name. /v1/models asked with Cindy's key (magpie-cindy, as
its import link gives it) now gives display_name the name the agents'
lists use, provider.LabelsFor("cindy", ...): "GLM-5.3-Flash · Zhipu",
"... · routing group" for auto/, following Cindy's Provider in model
names (the picker the Agents page already showed for Cindy, which
changed nothing there before), a name the user gave a model kept as
they wrote it. Every other client's display_name is unchanged. In Cindy
a discovered model's shown name follows discoveredMetadata.name, which
its 刷新模型列表 updates for existing models; a name the user typed in
Cindy (nameExplicit) still wins there.

Run:
- TestCindyDiscoveryNamesModelsApart (new): on, own and off, three
  providers' GLM-5.3-Flash apart, a user's own name kept, another client
  plain. Red on the old gateway.go ("on: Cindy told
  map[... or/glm-5.3-flash:GLM-5.3-Flash zp/glm-5.3-flash:GLM-5.3-Flash]").
- Real use: this tree's magpie built and served in a sandbox HOME on
  mica with two custom providers serving glm-5.3-flash; its /v1/models
  with magpie-cindy fed to Cindy 0.1.94's own parseModelsListResponse
  (extracted from /Applications/Cindy.app's app.asar): "GLM-5.3-Flash ·
  OpenRouterX", "GLM-5.3-Flash · ZhipuX", "GLM-5.3-Flash · routing
  group"; with magpie-pi's key all three still "GLM-5.3-Flash".
- Full suite on mica at base e730a14dc (go test -count=1 -timeout 45m ./...): 99 packages ok, no FAIL. go vet ./... (darwin), GOOS=windows go vet ./... and GOOS=linux go vet -tags nogui ./... clean; gofmt -l clean.

Not tried: Cindy's own window. Adding magpie there writes into the live
CindyGlobal folder, which has no account database on this Mac.

- After the rebase onto 9a3f95f3f's parent (two gateway commits): internal/gateway, internal/provider and internal/agent ok on mica.
2026-11-14 08:39:31 +08:00
yetone ab4b1cf38f sessions: a long Codex rollout is read on after a restart, not read again whole
shangyuan0818 on X: on Windows, Usage > Sessions took over ten seconds to
open with one very long session (tens to 100 MB), though there were only
a few sessions.

Cause: a Codex rollout's summary window (state.Codex) and its calls'
window (cxRun) lived in memory only. After a restart, or once the window
had been dropped, the first line a live rollout gained made parseRead,
prepareCalls and readsWhole read the rollout again from its first line:
once for the summary and once for the calls. Claude Code sessions were
already read on through their kept windows (#3493).

Fix: the window of a rollout being written (changed within the hour, the
same files memory keeps windows for) is now kept on disk with the parser
version, a window version, and the size, offset and content hash of the
read that made it. The summary's goes in codex-windows/<hash>.gob next
to sessions.json. It is written with sessions.json, and it is removed
once the cache drops that window. The calls' window goes in the shard's
.rev file next to Claude's. Each is used only when all of those match,
so a window from another read, or from an older layout, is never used;
the file is read whole instead, as before.

Measured (100 MB rollout built from testdata/codex-native-paginated.jsonl,
plus a 100 MB Claude Code session, GET /api/sessions in a sandbox HOME):
  mote (M5), before: after one line appended following a restart, 2.51 s
    (Codex alone 2.25 s). After: 9.7 ms (Codex alone 6.3 ms).
  Windows (xiaomi-gpu), before: 2.61 s. After: 22.8 ms.
  The first read with nothing kept is unchanged: 2.6 s on mote, 2.8 s on
    Windows. Warm and plain-restart opens were already 10 to 30 ms. stats
    and overview stayed at a few ms throughout.
  A real 32 MB rollout: 24 ms after an append, with 2 KB and 4 KB windows.
    A 100 MB rollout with a unique response id per turn: 11 ms, with
    623 KB and 834 KB windows.

Tests: TestCodexSessionReadOnAfterRestart reads a rollout, restarts, then
appends a replayed token_count and a new turn. It checks that neither
reader starts at offset 0, and that calls and the session's tokens,
models and cost match a read from scratch. TestCodexWindowLeavesWithItsSession
covers writing, reading back, refusing another read's window and
removal. TestPlainRolloutReadOnceForSessionsAndCalls (#4369) expected
both readers to start from 0 after a restart; it now expects them to
read on.

Broken by hand, each red: the summary window not read (starts [319830 0]);
the calls window not read ([0 319830]); a summary window emptied of what
it had seen (it panicked in codexUsageState.count, which is why the
version guard was added); a calls window emptied (62 calls vs 61).

Run: gofmt -l clean. GOOS=linux and GOOS=windows go vet -tags nogui ./...
on mote. Full go test -tags nogui -timeout 45m ./... on Linux (wsl-run,
magpie-desktop) at this change on 70bd270ae: every package ok but
internal/usage, whose TestRequestStateKeptAcrossACatalogFetchedAgain is
red the same way alone on origin/main 7b50e1f2c (11 of 20; a same-size
catalog write in one mtime tick, filed as #6572). mote's suite.lock had
five runs queued ahead, so its run of this change is still waiting.
Rebased onto 7b50e1f2c (7 files in internal/provider and internal/usage,
none under internal/sessions); provider, usage and sessions run again
there on Linux: all ok (#6572 passed this time). win-run ./internal/sessions/: only TestAgySessions,
TestAgyRowOnly, TestAntigravityAppFolder and TestCCListingKeepsItsNames
fail, and they fail the same way on origin/main ea9f2639b (#6071).
win-run -run 'Session|Usage|Calls' ./internal/gui/: only
TestGatewayModeStatsNameTheGatewaySessions fails, the same on ea9f2639b
(#6068).

Old data: right after updating, every user's live rollout is read whole
once more on its next change, since no window has been kept yet. From
then on it is read on. Nothing else changes for files not written within
the hour.

Not changed: WorkBuddy, WorkBuddy AI and CodeBuddy calls are still read
whole on every line (556 ms per 100 MB on mote), filed as #6565. Not
tried: the reporter's own machine and files.
2026-11-14 03:28:08 +08:00
yetone 7b50e1f2c6 provider: Claude Code's version-2 model catalog lists an account's models too (#6418)
Claude Code 2.1.323+ keeps an account's models in
<config dir>/cache/model-catalog/<organizationUuid>-<sha256(accountUuid)[:12]>-cc.json
(version 2, catalog.config.models), and magpie read only .claude.json's
additionalModelOptionsCache / modelAccessCache. A model only that catalog
has, and models.dev's anthropic list lacks, was missing from the Claude
provider, `magpie models` and Claude Code's own picker (pwn2ooown).

readClaudeCodeModels, which every reader of those caches goes through
(claudeModels, claudeModelsOf/claudeLists, ClaudeCodeModels,
claudeCodePrice), now adds the catalog of the account its .claude.json
names, from that config directory or Claude Code's own (~/.claude keeps
every account's that signed in there), the one fetched last. A model
models.dev doesn't describe takes the catalog's window, reply limit,
effort levels and mm_images. The legacy caches are read as before.
Another account's catalog is never read; a file of another version or
surface is unknown; a .claude.json or catalog that doesn't parse
(halfway through a write) is what it said last (readKeepingGood), a file
gone is gone.

The name and shape come from this Mac's Claude Code, read only: 7 files
in ~/.claude/cache/model-catalog and 2 in saved account dirs; the name's
first part is organizationUuid and its second sha256(accountUuid)[:12]
for every account whose .claude.json is here.

Run (mote):
- go test -tags nogui ./internal/provider ./internal/agent ./internal/cli
  ./internal/catalog ./internal/filememo ./internal/proc: all ok (provider 166s, agent 357s, cli 67s)
- go vet ./...; GOOS=linux go vet -tags nogui and GOOS=windows go vet of
  internal/provider and internal/agent; gofmt -l clean
- built magpie, `magpie models` in sandbox HOMEs (the issue's repro
  adapted): baseline, other account's catalog, half-written catalog: no
  Fable 5.2; the issue's catalog: listed; legacy cache: listed; a copy of
  a real Claude Code catalog's bytes under synthetic ids: all 13 models
  listed.
- after rebasing on 58629a0f8 (no change in these packages): provider
  and usage ok again at the pushed head.

Broken by hand (TestClaudeCodeCatalogV2Models red each time):
- catalog not read: "Fable 5.2 from the version-2 catalog not listed"
- last good dropped: "a half-written catalog dropped Fable 5.2"
- name keyed on org only: "another account's catalog listed"

Not tried: Claude Code on Linux/Windows (same path under the config dir
assumed); a real account whose catalog has a model models.dev lacks
(every model in this Mac's catalogs is in models.dev); the full ./...
suite. The issue's repro names its file <org>-<accountUuid>-cc.json,
which Claude Code doesn't write, so that literal name is not read.
2026-11-14 03:17:11 +08:00
yetone 70bd270ae2 agents: Antigravity says how its own sign-in's models come back on magpie (T_t__biu on X)
T_t__biu on X: once magpie wires the Antigravity app, the Gemini models of
their own signed-in Google account leave the app's model list. Cause: magpie
connects the app through Google's Enterprise Gateway (gateway block in
~/.gemini/config/config.json and ~/.antigravity/settings.json). On a gateway
the app's language server runs in AUTH_MODE_ENTERPRISE_GATEWAY and drops the
Google sign-in (Google's docs: the two can't be used at once), so Code
Assist's fetchAvailableModels, which listed the account's models, is never
asked. No key in the file keeps both.

What does keep them: the same Google account signed in under magpie's
Antigravity subscription (the antigravity-auth plugin). The gateway's
antigravity catalog then lists that account's own models beside magpie's,
on that account's quota, pooled with any other Google account added there.
The notice shown on connecting now says so while magpie has no Antigravity
account (provider.Logins("antigravity") empty); with one, it reads as
before. Translated in zh, zh-TW, ja, de; the site's Antigravity page (en,
zh, ja), llms-full.txt and docs/subsystems/agent-wiring.md say the same,
and the subsystem page names what is not built: keeping the app's own
sign-in and adding magpie's models beside it would need the backend's
Code Assist endpoint (--cloud_code_endpoint / CLOUD_CODE_URL) pointed at
magpie.

Run at this head (base 331057743 = origin/main, fetched), on mote:
- go test -count=1 -timeout 45m ./internal/agent ./internal/gui ./internal/cli: ok
- go test -run 'Subsystem|Doc|Loop' ./internal/gateway: ok
- node --test i18n-keys, i18n-en-no-cjk, agent-notice-lang, about-notices
  (GUI): 50/50 pass
- site: node --test worker.test.mjs files.test.mjs: 52/52 (after
  regenerating llms-full.txt, which the first run caught stale)
- GOOS=linux and GOOS=windows go vet ./internal/agent: ok; gofmt -l clean
Real use, sandbox HOME on mote with one real Antigravity account (copied
plugin:antigravity entry only, @magpie-community/opencode-antigravity-auth):
- magpie antigravity magpie/up/g3 wrote the gateway block; GET
  /v1/models?format=antigravity with the app's key listed the account's
  models (Gemini 3.8 Flash, Gemini 3 Flash, Claude Sonnet/Opus 4.6, GPT-OSS
  120B, ...) beside up/g3; a chat on antigravity/gemini-3-flash:low through
  /v1/chat/completions answered "pong" on that account.
- the built binary prints the old notice in that HOME, and the old notice
  plus the new sentence in an empty sandbox HOME.
Broken by hand: Notice's account check forced off, TestAntigravityGateway
red ("no word of the app's own models with no Antigravity account").
Not tried: a real signed-in Antigravity app (none here; the app keeps its
token in the keyring); the whole GUI suite (app.js untouched, only i18n.js
keys added); Windows/Linux runs of the package (no OS-specific code).
2026-11-14 02:44:12 +08:00
yetone 48f9764027 plugins: a model served on more APIs keeps the client's (gaubeebangeel on X)
gaubeebangeel on X: OpenDesign's Anthropic requests to an Open Design
Cloud account were all sent upstream as chat completions. The Open
Design plugin declares each model on one AI SDK package (chat
completions for most, Responses for deepseek-v4-pro and claude-haiku-5.5,
plugins#141), and pluginAPIs gave a plugin model that one API alone, so
attempt never relayed a /v1/messages request and translated it, though
amr-link serves every model on all three (plugins#888). A DeepSeek
API-key provider, the case first suspected, relays to /anthropic/v1/messages
as sent: tried with OpenCode's, node's and no User-Agent, bare and
prefixed ids, and web search.

A plugin model can now list the other APIs its vendor serves it on, as
their AI SDK packages (m.also; plugin.Model.Also through host.js, config
model and models hook). pluginProtocols gives the model's own API first,
then those; ListedAPIs, the catalog's APIs and the provider's bases come
from it, so a client's request on any of them is relayed as sent. usable
puts a plugin model's own API first, so a request on an API it isn't
served on is still translated to the declared one. A model with no also
is unchanged. opendesign 0.1.13 (plugins 397da020) sets also on every model.

Test: TestPluginModelServedOnMoreAPIsKeepsTheClientAPI (fake plugin,
FAKE_ALSO): Anthropic, Responses and Chat requests to the also model
reach the upstream on their own path; fake-1 (no also) is still
translated to /chat/completions. Red on HEAD's plugins.go: Anthropic and
Responses reached /v1/chat/completions, ListedAPIs and usable were [chat].

Run (mote unless said): go test ./internal/provider ./internal/plugin
./internal/catalog ok; go test ./internal/gateway ok (972s);
GOOS=linux/windows go vet of the three packages ok; gofmt clean.
Not run: the full ./... suite (mote and mica each had full suites
queued under suite.lock); not tried against a real amr-link account
(keyblues's plugins#888 measurements are the evidence it serves
/v1/messages for every model).
2026-11-14 02:14:31 +08:00
yetone 6112dd37c1 agents: Use Claude Magpie shows with Claude Magpie made too, and the row names it (xMopf7RF on X)
xMopf7RF on 0.1.4076: "没看到按钮". The Use Claude Magpie button beside
Claude Desktop's switch showed only while Desktop wasn't on magpie and
Claude Magpie was off (`!a.isolated.on`). The reporter had tried Claude
Magpie since 0.1.4064, so it was on while Desktop wasn't on magpie, the
one state where the button hid. The row then still read "on magpie,
Claude Desktop opens a separate profile…", though connecting there wires
only Claude-Magpie-3p (desktopSets), never their own Desktop.

States where Desktop isn't on magpie, before → now:
- Claude Magpie off: button shown (unchanged).
- Claude Magpie on, app there: no button, wrong line → button, and the
  line says connecting puts Claude Magpie on magpie and their own Desktop
  stays signed in with Anthropic.
- Claude Magpie on, app deleted from ~/Applications (launcher ""): no
  button, so nothing made it again → the button, whose
  settings/desktop-isolated on:true remakes the app (desktopiso.Add over
  nothing), then connects.
- isolated missing (not a Mac, WSL): no button (unchanged).

Run (mica, mote over its 18 cores):
- desktop-twin.test.cjs, new cases: Claude Magpie made with and without
  its app, every language, 1100 and 640px, Chromium and WebKit: 62/62 ok.
  Broken by hand: the same file on origin/main's app.js: 40 red (every new
  case), 22 ok.
- TestCoreScriptBudget ok (within the room app.js had).
- Every GUI file naming claude-desktop or isolated (31) with i18n-keys and
  i18n-en-no-cjk, both engines: 760/762; the two reds are
  desktop-tiers' Chromium cases, red the same on origin/main 65f745dd4
  with this change taken out (#6475).

Not tried: the real app on a Mac with a deleted Claude Magpie.app; the
switch alone (not the button) in that state still wires the folders
without making the app again.
2026-11-14 00:51:23 +08:00
yetone a82bae2bd3 routing: a request's row says the service tier it went at (Anotiaww on X)
Anotiaww on X: with Codex's fast mode on, the Routing page's request log
didn't show that a request went in fast mode.

Two gaps. Codex on its own ChatGPT sign-in (codexUpstreamOn) set only the
route's tier, never its tries', and the Routing row drew only a group
member's fast flag, never a tier.

- codex_backend.go: the try (first and askAgain) carries the body's tier
  (bodyTier), and its end notes tier_served through servedTierAt. The
  handed-on usage record has tier_asked/tier_sent too.
- plugins/routing/client.js: the row shows a quiet tag beside the model
  (fast for priority, Ultrafast, flex) from the try's tier, or the
  route's asked tier while in flight. Its title says the tier and, when
  the reply said another, what it said. No new column. rowSays' sig
  takes the tier, so the row is drawn again when it changes.
- "flex" is a core word in i18n.js (i18n-keys: a plugin can't own a
  word other code says); its title strings are the routing plugin's.
- docs/subsystems/gateway-routing.md says the Codex relay's tries carry
  the tier and what the row shows.

Price: a priority turn is still priced at the standard rate. Pricer and
catalog.Price don't read the tier. That is #1784's open work, in
hhh2210's fork PR (hhh2210/magpie#1, catalog.ServicePrice), so nothing
is duplicated here. No Flags bits added or changed.

Run on mica (mote and mica both over their core count; mica the lower),
at 74b5f2420 on origin/main 1730c75b9:
- gofmt -l clean; go vet darwin, GOOS=linux and GOOS=windows -tags
  nogui ./internal/gateway ./internal/gui: ok
- go test ./internal/gateway -run 'Tier|ChatGPTBackend|OpenAIAPI|
  CodexOwn|CodexRelay|FastPick|SessionRoute': ok
- go test ./internal/gui -run 'Budget|I18n|Routing' (core script
  budget): ok
- node --test routing-service-tier, i18n-keys, i18n-en-no-cjk,
  routing-entry, group-member-fast: 52 of 52
Before the last rebase, at the same change on 817d35ffa: every GUI file
that loads the routing page plus i18n-keys and i18n-en-no-cjk, 3672
tests, 38 red. i18n-keys' "flex" was mine and is fixed above. The other
reds were in six files, with the same 25 red when those files ran alone
at 817d35ffa itself. Each is filed: ctx-session-line #5801,
routing-context-fold #5586, routing-pin-away #6512, routing-row-swap
#3799, routing-story-shrinks #3954, and mobile-web #3952/#5013 (its
"desktop matches origin/main" needs .git, which a mica-run copy lacks).
The rest (codex-subagent-model, desktop-subagent-model, provider-mask,
routing-many-keys, usage-compact-counts) passed on a rerun at
concurrency 3.

Broken by hand: client.js from HEAD~ makes routing-service-tier 0 of 20;
the first Try's Tier dropped makes TestCodexRelayRouteSaysTier red.
Dropping servedTierAt in end leaves it green: uu.Tier is filtered before
end runs. Kept as a guard.

Not tried: a real ChatGPT account's /fast turn, the full Go suite, the
Windows and Linux runtime.
2026-11-14 00:14:26 +08:00
yetone 1730c75b97 library: Claude Magpie is an agent of its own (xMopf7RF on X)
xMopf7RF asked for Claude Magpie, the separate Claude Desktop, to show
on its own in the Library's instructions, skills and MCP, like an
independent agent. Before, Claude Desktop's target wrote its servers
(DesktopConfigs3p) and Cowork skills (desktopdir.Everywhere) into
Claude-Magpie-3p too, and the twin's Code tab folder
~/.claude-magpie-desktop (a claude# row) got nothing from the Library.

- agent.DesktopTwinApp: claude-desktop#magpie, "Claude Magpie", an app
  target while the Separate app is on and its folder is there (macOS).
  MCP to Claude-Magpie-3p's claude_desktop_config.json, Cowork skills to
  its skills-plugin. No instructions file: noPlace points to its Code
  tab's row.
- Claude Desktop's target leaves Claude-Magpie-3p out (DesktopConfigs3p,
  desktopSkillRoots).
- Every claude#<name> row takes CLAUDE.md, skills/ and .claude.json in
  its folder (~/.claude.json for ~/.claude itself). settings.json
  features (hooks, env, tools off) stay keyed on claude.
- Old data: carryTwin, on load and only while nothing is recorded for
  the twin, ticks for Claude Magpie each server and skill magpie gave
  Claude Desktop that is in Claude-Magpie-3p already, so an update takes
  nothing away. library.json syncs, so another Mac's twin sees the same
  ticks. Unticked later, it stays unticked.
- Not changed: desktopCarryMCP still copies the user's own Desktop
  servers into the twin when it is wired.

Run (mote, sandbox HOME in the tests):
- go test -tags nogui ./internal/library ./internal/agent
  ./internal/desktopiso ./internal/desktopdir: ok (167s, 251s).
  GOOS=linux and GOOS=windows go vet of library and agent ok; gofmt clean.
- TestClaudeMagpieIsItsOwnLibraryAgent: InstallSkills, SaveServer and
  SaveInstructions write only Claude-Magpie-3p and
  ~/.claude-magpie-desktop; Claude Desktop's config and manifest,
  ~/.claude/settings.json unchanged; ~/.claude.json, ~/.claude/CLAUDE.md
  and ~/.claude/skills/pdf not written. TestClaudeMagpieKeepsWhatDesktopWasGiven.
- GUI, both engines: library-*.test.cjs (76 files), by-agent,
  every-skill, group-skill-chips, pick-skills, project-*, skill-*,
  i18n-keys and the new library-desktop-twin.test.cjs (separate chips
  for Claude Magpie and Claude Code · Claude Magpie, lit only for what
  they were given, a click on Claude Desktop's asks for it alone; en,
  zh, zh-TW, ja, de at 980 and 420px). 1850 of 1878 the first run, with
  a library.css hand change since dropped; the 28 reds were all in
  library-new-skill, library-subagents, library-wsl-asleep and
  skill-where, and those four files plus the twin test, run again
  without it: 174 of 174.

Broken by hand, each red then restored: carryTwin off (fs/pdf not
ticked, nothing recorded); Desktop's skill roots with the twin's folder
(target reaches Claude Magpie's folder); the claude# branch off (Code
tab target nil); DesktopConfigs3p with the isolated config again
(library and agent tests red).

Filed: #6558, a row's chips reach past its edge at 420px (ja with four
agents, before this too with six); the twin test skips that check for ja
at 420px until it is fixed.
Not tried: a real Claude Magpie.app on a desktop reading the new files.
2026-11-14 00:01:24 +08:00
yetone d0fb3c0084 provider: Claude accounts can be set not to spend extra usage (baksili_ on X)
baksili_ on X asked for a way to keep magpie off Anthropic's paid extra
usage on Claude subscription accounts. magpie can't flip Anthropic's own
switch, so it holds the account itself.

Providers -> Claude -> Advanced has a new "Spend extra usage" row: On,
as before, by default (nothing changes for anyone who doesn't touch it).
Off saves claudeNoExtraUsage. While it is off, HoldCaps holds every
Claude account at 100% of any plan window with no cap of its own (the
same Credits hold a Codex account set not to spend its credits gets),
so a Claude account whose 5-hour or weekly window is used up gets no
requests until it renews and the other accounts take them. What its
plan has left is still used; a cap the user set lower still holds first.

A cap on an account's "Usage credits" window (its extra-usage spend,
set as an amount or a share on the usage card) now holds the account
the same way once that much extra usage is spent (Allowance.extraCapped,
called from CapHeld and NearCap). Before, aside windows carried no
amount, so an amount cap on one never held anything; allowanceOf now
gives aside limits their Amount, Of and Unit.

Every route that picks an account goes through capHeld, so the gateway,
groups and fallback obey it alike. Claude Code switching (NextLogin)
already moves off an account on overages. The warm-up sends a held,
used-up account nothing (codexWarmer.held / spentPast; claudeHeldFull
for Claude), since that request would be billed as extra usage. With
every account held, the client is told "has used up a usage window and
is set not to spend extra usage" and how to turn it back on, and the
call's record says "set not to spend extra usage" (Weighed.ExtraUsage).

Not done: Claude Code's hidden /limit-reset. It resets or buys limits
through endpoints Anthropic hasn't published, and calling them would be
mimicking Claude Code's client, which magpie doesn't do. A Claude Code
signed in on its own, not through magpie, still spends extra usage.

Run on mote at 5b0572ae3 + this change; rebased since on ce2ce86ab
(two gui commits on WebView2 and a GC read, no file in common), where
the gui budget tests passed again:
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./...: ok
- go test -timeout 45m ./internal/provider ./internal/gateway
  ./internal/settings ./internal/settingsapi ./internal/gui: all ok
  (gateway 939s; the core script budget passes)
- GUI (node --test, Chromium and WebKit): claude-extra-usage-setting
  (en, zh, zh-TW, ja, de at 1100 and 420), provider-prefs,
  claude-lean-prompt-setting, i18n-keys, account-cap, claude-overages,
  quota-credits: 114 of 114
- gofmt -l: clean

Broken by hand (at the 7eecbcc56 base), each red, then restored:
- HoldCaps' claude case -> TestClaudeNoExtraUsageHoldsAtThePlan,
  TestClaudeNoExtraUsageHoldsTheAccount (gateway)
- extraCapped in CapHeld -> TestClaudeExtraUsageCapHoldsAtThePlan
- aside Amount/Of in allowanceOf -> TestAsideWindowAmountCapHolds,
  TestClaudeExtraUsageCapHoldsAtThePlan, TestClaudeHeldFull
- spentPast in warmNow -> TestWarmUpSendsAHeldAccountNothing
- capHeld's extra flag -> TestClaudeNoExtraUsageHoldsTheAccount
- the row left out of #claudeRunList -> claude-extra-usage-setting
  20 of 20 red

Not tried: a real Claude account on extra usage; the hold was checked
with /usage reads built from the CLI's shape, not a live account past
its plan. The full ./... suite was not run (mote and mica over their
load limits, two full suites queued on mote's suite.lock).
2026-11-13 23:42:57 +08:00
yetone 5b0572ae3b agents: Use Claude Magpie is its own button beside Claude Desktop's switch (xMopf7RF on X)
xMopf7RF read Claude Desktop's row as "connect Desktop first", and
connecting is what changes their own Desktop. They asked for one button
beside Claude Desktop that makes the clone and touches neither their
Desktop nor ~/.claude. The button that does this has been in the row
since v0.1.4029, but it was a quiet link at the end of a long status
line that warns about connecting. Their screenshot has no button at all,
so it was easy to miss or they were on an older version.

Now it is a real button (ag-add) beside the switch, where Claude Code's
model picker stands. The status line no longer holds it. What it does
is unchanged: Separate app on, then connect, which wires only
Claude-Magpie-3p (v0.1.4064 keeps ~/.claude out of it for a new twin).
It shows only while Desktop isn't on magpie and the twin isn't made yet,
on a Mac.

Run:
- At the pushed head, after the rebase: desktop-twin, desktop-isolated, desktop-isolated-claude and i18n-keys
  in Chromium and WebKit, every language, at 1100 and 640px: 38/38 per
  engine. desktop-twin now checks that the button isn't in .ag-st, sits
  level with the switch 8 to 28px left of it, and that the status ends
  before it. It waits for the fold's animations first.
- Every GUI file whose fixture has claude-desktop or isolated (38
  files), both engines: WebKit 345/345. Chromium 343/345: the two reds are
  desktop-tiers ("no tiers square"), red the same at origin/main
  6e03b746b and filed as #6475. Its fixture is wired with no isolated, so
  the button never draws there.
- TestCoreScriptBudget: ok.
- Sandbox HOME on mote with the real Claude.app, at this tree: CLI
  launcher add, then connect, then launcher remove. The original
  Desktop's config.json and claude_desktop_config.json, ~/.claude and
  ~/.claude.json were byte-identical after each step. The twin's script
  exports CLAUDE_CONFIG_DIR=~/.claude-magpie-desktop.

Broken by hand: with the button put back in the status line,
desktop-twin goes red ("in the status line").

Not tried: a click in the real GUI app. The backend calls are the same as
v0.1.4064's, which the sandbox covers.
2026-11-13 23:21:56 +08:00
yetone 6e03b746be gui: plugin pages load on Windows again, their sandboxed frame kept in the window's process (Mute06162 on X)
Mute06162 on X (0.1.4066, Windows): every plugin page (用量速览, 对话,
模型指纹, GPT号池) showed "This page stopped working / <page> didn't
answer", and Codex found "Worker request cancellation setup: The
parameter is incorrect" and "Resuming Windows asset request: The
parameter is incorrect" in the log. Both are Wails' own lines
(request_cancellation_windows.go, v3.0.0-beta.24).

Cause, reproduced on xiaomi-gpu (WebView2 157.0.4341.46): WebView2 runs
the plugin page's frame (sandbox="allow-scripts") in a process of its
own (Chromium's IsolateSandboxedIframes; CDP lists it as an "iframe"
target). Wails registers its WebResourceRequested filter with
AddWebResourceRequestedFilter, and that isn't raised for this process's
requests: the frame got its index.html (a navigation), but bridge.js,
app.js and style.css went to the network as http://wails.localhost/...
and failed with net::ERR_CONNECTION_REFUSED. The bridge never said
hello, so after 10s the page was broken. Wails' request cancellation
auto-attaches the frame's target, takes it for a worker, and its setup
on that session fails with E_INVALIDARG: that is the log line.

Fix: windowsOptions starts WebView2 with IsolateSandboxedIframes
disabled (sharedFrameProcess), merged into the one --disable-features
with the user's own, unless the user enables it in
WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS. This is app-wide, so it covers
every sandboxed frame magpie makes: plugin pages and plugin panels
(pluginpages.js, the only two), in the main window and the tray panel.
The frame keeps its sandbox: an opaque origin (its context's origin is
"://"), its CSP, messages only.

Run:
- Real repro on xiaomi-gpu, sandbox HOME (C:\Users\yeton\magpie-wvf),
  testdata/page-plugin (magpie-usage-glance, the reporter's 用量速览),
  `magpie app` started in the console session by a one-shot scheduled
  task, driven over CDP:
  - origin/main 077421733: the page shows "This page stopped working /
    Usage glance 的页面没有响应"; the frame target's three subresources
    fail ERR_CONNECTION_REFUSED; err.log has "Worker request
    cancellation setup: The parameter is incorrect." on every open.
  - origin/main with --disable-features=IsolateSandboxedIframes set by
    hand in WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS: the frame stays.
  - this change: the card draws (screenshot: "Today, 0 calls, 0 tokens,
    $0.00, Hide cost", so the bridge and usage:summary read work), and
    no Wails line is logged.
- TestWebView2KeepsPluginFramesInTheWindowProcess (new): win-run
  `go test -run WebView2 ./internal/gui` ok on xiaomi-gpu. Broken by
  hand (sharedFrameProcess not called): red on Windows, "disabled 0
  times". TestWebView2ArgsMergeTheUsers and
  TestWebView2ArgsSurviveWailsInit updated for the new default.
- mote: go test ./internal/gui ok (158s).
- mica: go vet ./internal/gui for GOOS=windows, GOOS=linux -tags nogui
  and darwin ok; gofmt -l clean.

Not tried: an older WebView2 runtime (when the runtime turned the
isolation on is not proven; 157 has it), the reporter's other three
plugins (they are frames like this one), Wails' own fix (registering the
filter for every request source kind), and the whole internal/gui
package on Windows.
2026-11-13 23:17:31 +08:00
yetone 817d35ffa9 usage: a window's whole follows the tokens pick's With cache (Anotiaww on X)
@Anotiaww asked (X 2121248031983194214) that the account cards' "Whole ≈ N
tokens" on Usage → Overview follow the page's tokens pick. With cache, it
now adds the window's routed cache read and written, scaled by the same
share used as the input and output; the line reads "Whole ≈ N tokens with
cache" and its tooltip says cache is included. Without cache nothing
changes. Changing the pick redraws the cards. The tray panel shows no
holds line, so it has nothing to follow.

holdsLine and holdsUnknownLine move from app.js into the Usage plugin's
page.js, beside usageWithCache, so the core script budget stays as it is
(it had 14 bytes left). quotaWindows still calls them as globals. New
words are said in zh, zh-TW, ja and de.

Run (mica, both engines, every language):
- quota-holds, i18n-keys, i18n-en-no-cjk: 16/16 ok. The new quota-holds
  test (pick With cache at 360 and 1000px, reload keeps it, pick back)
  went red in both engines with the cache left out and the old words, and
  again with no redraw on pick.
- 185 GUI files that reach Usage or quotas, plus mobile-web, idle-ticks,
  old-webkit and every i18n file, concurrency 3. Reds: account-eye,
  account-mask, account-refresh-holds, claude-quota-onboarding,
  codex-auto-reset (de), key-balance-card (de), menu-scroll, mobile-web,
  old-webkit, quota-count-wrap. The same files are red at the base
  ac0b5c287 without this change (quota-count-wrap 1100px cut, alone), and
  each is filed (#5052, #3951, #5814, #6179, #4790, #6414, #6532, #3952,
  #6467, #3404).
Run (mote): go vet, GOOS=linux vet -tags nogui, GOOS=windows vet, builds;
go test -tags nogui ./internal/gui (TestCoreScriptBudget), ./internal/provider,
./internal/usage ok.
Rebased on 077421733, where 5211fd3ba gave holdsLine a provider's
currency (prov); page.js carries it. At this head (mica): quota-holds,
quota-curve, currency-provider, currency, i18n-keys, i18n-en-no-cjk,
quota-count-wrap 80/83; the reds are quota-count-wrap (#3404, red at
077421733 too) and quota-curve chromium en/zh (#4768), which passes 31/31
alone here and at 077421733. go test -tags nogui ./internal/gui (budgets) ok.
Not run: the full go test ./... and the full GUI suite (both machines were
loaded); the only Go change is a comment.
2026-11-13 23:12:48 +08:00
yetone a97c8191bc workbuddy: with the provider left out of the names, a model's id is its name (elis_pina on X)
WorkBuddy's model list read "GLM-5.3:workbuddy/glm-5.3" with Provider in
model names Off. WorkBuddy (5.5.6 renderer, getModelDisplayName) shows
every custom model as "name:id" unless the name is empty or equal to
the id, and magpie wrote the catalog id (provider/model) as the id. So
the provider came back after the colon whatever the names said.

- agent (buddyIDs): for WorkBuddy and WorkBuddy AI under Off or Own,
  each magpie entry in models.json gets the name as its id too, so the
  list shows "GLM-5.3" alone. The catalog id stays when two models
  share a name, when the name is another model's id, when the entries
  point at a magpie on another machine or in WSL, and in On mode.
  A model turned off in WorkBuddy, its default effort and a reply limit
  typed in carry across the change of id: an old id is mapped back
  through every label form (Label, PlainName, the list's name).
- provider.AgentNamed: the catalog id of the one model an agent's list
  names so.
- gateway (namedFor): a request with WorkBuddy's or WorkBuddy AI's key
  for such a name goes to that model before any other resolution, so a
  bare id that another provider serves first is not asked instead. The
  reply keeps the name that was asked for. Other agents' keys are not
  mapped.

Siblings: CodeBuddy Code shares the writer and keeps catalog ids. Its
settings.json names the model by the catalog id (codebuddy.go), and its
CLI picker shows the name alone (no name:id template in its bundle).

What users meet: a change of mode, or of a model's name, changes the
id. WorkBuddy then picks another model for a session that had the old
one, as it does for any model that leaves its list.

Run:
- Unit tests: TestWorkBuddyNamesAreIDsWithoutProvider covers Off, Own,
  back to On, WorkBuddy AI and CodeBuddy. TestWorkBuddyAsksByName uses
  the real handler: a name equal to a bare id that a provider listed
  first serves (hidden from WorkBuddy) reaches the named model, and
  OpenCode's key for the same name does not.
- Broken by hand (on mica), each red:
  - buddyIDs always returning the catalog id: the test sees
    id deepseek/pro under Off.
  - namedFor's mapping skipped: the request went to provider "first".
  - The old-id mapping skipped: Own lost disabled.
- Sandbox HOME, built binary:
  - magpie provider add zai (fake upstream) and magpie workbuddy
    provider magpie wrote "zai/glm-5.3 | GLM-5.3 · Z.ai".
  - magpie model suffix workbuddy off rewrote the file to
    "GLM-5.3 | GLM-5.3".
  - magpie serve on a spare port, then a curl with magpie-workbuddy for
    "GLM-5.2" reached upstream as glm-5.2 (reply model GLM-5.2).
  - WorkBuddy 5.5.6's own CLI (app.asar.unpacked/cli/bin/codebuddy -p
    --model GLM-5.3), with HOME set to the sandbox, answered "pong", and
    upstream saw glm-5.3, streamed.
- Full suite on mote at this tree (go test -count=1 -timeout 45m ./...):
  every package ok (agent 369s, gateway 1062s, provider 230s,
  sessions 254s), log kept whole. The doc line in agent-wiring.md was
  added after the run; no test reads that file. gofmt -l is empty,
  and go vet ./... passes. On mica, GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./..., and the linux nogui and windows
  builds pass.
- That suite ran at base ac0b5c287. The change was then rebased onto
  5211fd3ba (usage currency; no file in common). At the pushed head,
  on mica: go build, go vet of agent, gateway and provider, and
  -run "WorkBuddy|CodeBuddy|AgentSuffix|Labels" in those three
  packages all pass.

Not tried: WorkBuddy's window itself (the name:id rule is read from
its renderer source, not seen on screen), and WorkBuddy AI's app.
2026-11-13 22:49:39 +08:00
yetone 5211fd3ba2 usage: a currency "By provider" shows each provider's costs in what it sells in
onkashiko on X: DeepSeek, Kimi (China), Zhipu and other domestic vendors
price in yuan, the rest in dollars, and one currency for every cost made
the Usage page read wrong for half of them.

Settings > Usage > Currency gains a third choice, By provider. With it,
a figure of one provider's calls (a model's, an account's, a key's row,
a request, a routing try, a quota card's whole) shows in the currency
that provider sells in, and every sum across providers (the total,
agents, sessions, charts, the tray, Bark's daily, the day page) in the
currency a "Totals in" row picks, a row shown only while By provider is
chosen. GUI, TUI and CLI agree. Costs stay stored in dollars; only the
display converts, at the live rate (internal/fx).

Which providers sell in yuan (provider.PricesInYuan): a .cn host; a
preset at its own site that is a yuan preset (deepseek, zhipu,
volcengine, tencent-cloud, bailian, siliconflow…), ends in -cn, or is in
its China region; a plugin id ending in -cn; a provider of one's own
with a yuan models.dev catalog served at that catalog's site. A relay
made from DeepSeek's preset, Z.ai, Kimi's and MiniMax's international
endpoints stay in dollars: they share a catalog with their Chinese
twins, so the catalog alone can't tell.

Known limit: models.dev has only dollar prices (converted from the
vendors' yuan at ~6.7-7.0), so a yuan figure is that dollar price at
today's rate and can differ a few percent from the vendor's own list.

A second ask from onkashiko: set the currency of the menu bar and of
the totals apart, sums converted by themselves.

So Settings > Usage also gains an Advanced fold (closed by default, open while
set) with one row, Menu bar currency: Same as totals (the default), $ or
¥ (settings.TrayCurrency, TrayCostIn). It sets the menu bar's totals
cards and the tray tooltip's cost; the Usage page, the panel, the TUI,
the CLI and Bark's daily message stay in the totals' currency
(totalsCurrency). Like the other menu bar settings it stays on this
computer (KeepOwn). Every sum is still made in dollars and converted
once, at the live rate, so a mixed-currency total is never added up
from yuan and dollars.

Settings' currency rows (Currency, Totals in, Menu bar currency and the
rate in the tooltip) moved out of app.js into currencyprefs.js, imported
when Settings draws its usage prefs, and costInYuan is packed: the core
is 3 bytes under coreScriptBudget, with no raise.

Run:
- go test -count=1 at this tree on mote: internal/settings,
  settingsapi, tui, cli, catalog, provider, fx and gui all ok
  (TestCoreScriptBudget included). The full go test ./... and the whole
  GUI suite are queued behind other sessions' suites on suite.lock
  (mote and mica, load 35 and 60) and had not started at push.
- GUI files at this tree (mica): currency-provider, currency, i18n-keys,
  i18n-en-no-cjk, tray-cost, tray-totals, every settings-*, old-webkit:
  362 pass, 28 red. Every red is red the same at origin/main ac0b5c287
  on mote, and filed: settings-search (#6133, #6353), settings-hints
  (#6107, #6353), settings-lines-wrap de 440px (#6353), old-webkit
  appearance.js (#6467) and :has() (#5919). The one red of this change,
  settings-groups' list of Usage's parts (now with the Advanced fold),
  is fixed here: 14 of 14.
- currency-provider.test.cjs (new): en, zh, zh-TW, ja, de at 900 and
  420px, both engines; By provider, Totals in ¥, then Advanced: $ for
  the menu bar with totals in ¥, totals stay ¥21.60, the fold opens
  itself after a reload. Plus currency.test.cjs (3 choices now),
  i18n-keys, i18n-en-no-cjk, tray-cost: green in both engines.
- TestTrayCostIn (values, refused eur/provider, KeepOwn),
  TestFXByProvider (trayCurrency vs totalsCurrency), TestCoreScriptBudget.
- gofmt -l clean; GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., GOOS=linux go build -tags nogui,
  GOOS=windows go build on mote at this tree: ok.
- Broken by hand, each red: costInYuan ignoring the provider (GUI
  test: deepseek showed $1.00 for ¥7.20), PricesInYuan without the
  preset's site check (a relay made from DeepSeek's preset read as
  yuan), CostIn without its By provider branch (settings test),
  TrayCostIn ignoring TrayCurrency (TestTrayCostIn, TestFXByProvider),
  the fold not opening while set (webkit), the row saving into
  totalCurrency (chromium).
- Real app in a sandbox HOME on mote (dev build, magpie web and magpie
  usage) with DeepSeek, OpenAI and Z.ai presets and one call each: the
  window and the CLI both show deepseek-v4-pro ≈¥15.44, gpt-4.1 ≈$1.00,
  glm-4.6 ≈$0.290 and the total ≈¥24.07 at 6.685; /api/settings' fx
  carries yuan ["deepseek"].
Not tried: Windows and Linux windows and trays, the real menu bar with
Menu bar currency changed (drawn natively; covered through trayCurrency
in Go), a real Kimi CN or Zhipu account.
2026-11-13 22:46:00 +08:00
yetone ac0b5c287f pii: a strict request goes once only what an earlier one sent unread is left (gaubeebangeel on X)
gaubeebangeel on X: with masking on, first tokens on a cloud server
came at 30-40s, 10-15s with it off.

Where the time goes, measured on a 60-turn Claude Code Messages body
(367-414 KB, a 4 KB tool result a turn; TestRealLatencyOfALongSession,
gated on GUARD_REAL_DIR, run in WSL on a Ryzen AI MAX+ 395):
- The rules are not it: 89ms for the body cold, 13ms warm (the rule
  memo); 7-11ms on mote's M5 Pro (BenchmarkMaskLongSession,
  BenchmarkScrubCodexTurn).
- AstrLink Guard on the CPU is: ~7 KB/s on its 4 cores (GOMAXPROCS=32),
  ~3 KB/s on one (GOMAXPROCS=2). A turn whose new text the model reads
  waits for it: 16 KB of new tool output is 3.0-3.5s on 4 cores and
  7.8-8.2s on one. That part is the model's reading and stays.
- With the model turned on (strict, 15s), a resumed or never-read
  history was read on every request, until the 15s ran out, though the
  vendor had that text already and it goes as it went on the same route
  (redact's sentSpans): its finds only feed learnLate. 4 cores: 15.1,
  15.0, 15.0, 7.8s, then 0.85s. 1 core: 15s on eight requests in a row,
  then 7.9s, then 1.9s.

Now a request with a bound that waits for every text (masking's strict
wait) marks what it goes without, as a Bounded one does (backend.sent),
and once all that is left is what an earlier request sent unread, it is
answered with a *Partial (afterSent): what it adds was read, the rest
has the rules' masking, as on the same route it had. The model reads on
into the backlog after the request, to the request's own bound, and
keeps what it finds for the next one. While it waits, a strict request
counts only what it adds for the queue, so it goes before a backlog
read on by an earlier request. A strict request with no bound still
reads everything; Bounded (the default) is unchanged.

After, same body, same box: 4 cores 15.1s (the first request: all new
text), then 0.97, 1.3, 1.4, 2.3, 3.0, 3.1, 3.1, 3.1, 2.9s; 1 core 15.1s,
then 2.1, 4.6, 4.5, 4.8, 4.7, 4.6, 5.7, 4.5, 4.9s. Those later turns
come back to back, so each shares the CPU with the backlog read on
after the one before; with an agent's think time between them it is
read meanwhile.

What changes in what is masked: on the same route, nothing in what a
text goes as. A value the model would find late in a backlog text masks
new text from the request after the read, not from the one it went
with. On another route (the user picked another provider), a backlog
text has the model's finds of now, none until it is read, and goes with
the rules' masking alone; before, it was read for up to 15s, newest
first.

Run (WSL magpie-desktop, at this commit rebased on 005178104):
go test ./internal/pii ./internal/masking ./internal/redact,
go test -run "Mask|Redact|Privacy|Model|Partial" ./internal/gateway,
go test -race -count=5 on TestStrictRequestGoesBeforeTheBacklog,
TestBounded* and TestNewestTextReadFirst, go vet (linux, windows,
darwin) on pii and masking, and the latency runs above with the real
AstrLink Guard files.
Broken by hand: with early forced false,
TestStrictRequestGoesBeforeTheBacklog goes red ("the request waited for
the history an earlier one sent unread", 20s).
Not run: the full suite (mote and mica each had suites queued on
suite.lock); Privacy Filter (pf-serve) on a CPU, which shares
backend.find; the queue-order change has no unit test of its own (a
fair one races the turn's hand-over), only the latency runs.
2026-11-13 22:03:56 +08:00
yetone 533f351085 library: billion-context.json syncs, its settings change from its tab, running bilis reload
@Luxzinw on X asked for three things: sync billion-context's config,
edit its settings in the Library's billion-context tab, and have running
bili proxies reload after a change.

Sync. billion-context.json goes in the library part (library.Bundle.Bili),
by sync and backup file alike. magpie finds it the way bili's
src/paths.ts does: BILI_CONFIG_FILE, else $XDG_CONFIG_HOME (or
~/.config, %USERPROFILE%\.config on Windows), then
billion-context/billion-context.json.
- The text is carried as written, comments kept.
- magpie's summary recipe is carried at the canonical gateway address
  and localized to this computer's gateway when written, so two
  computers on different ports don't trade it back and forth.
- A newer local file is never blindly overwritten. Before a carried file
  replaces a different one here, this computer's copy is kept with the
  backups.
- An unreadable file, or one over 1 MiB, counts as unknown and is never
  carried as empty. A bundle without the file leaves this computer's
  alone.
- A file naming a DSN is left out of keyless backups.
- The credential store (<config>.summary-credentials.json) never
  travels.
- A library with no such file hashes as before.
- The new sync preview names the file when it would be added, changed
  or removed.

Settings. GET/POST /api/library/bili/settings, and a Settings section
under the agents in the tab:
- In front: "Summarize with a fast model" (externalSummary), picked from
  the app's menu, never a <select>. It offers magpie's served models and
  the file's own recipes. "Fold only when nudged" (requireNudge) and
  "Nudge every N tokens" (nudgeGrowthTokens).
- Under Advanced, collapsed: the compression philosophy
  (prompts.compressPhilosophy with acknowledgePromptsRisk, which bili
  needs before it reads a prompt override).
Writes go through edit.PatchJSON and temp+rename, so unknown keys,
comments and the BOM are kept. bili disables its whole compress section
on one bad value, so magpie writes only values bili accepts. A magpie
model becomes a providers.magpie recipe whose key is saved in bili's own
credential store, the way bili writes it (0600, O_EXCL .lock,
temp+rename). A user's own providers.magpie is never taken over. A file
bili can't read is said so and left alone.

Reload. After a change, and after sync writes the file, every running
bili on loopback is sent POST /__bili/config/reload. bili reloads routes
and compress there. The status line says whether it did, or that the
agent needs a restart.

Also: agentenv.Vars clears BILI_CONFIG_FILE in sandboxes, and the
settings-parity list names the two routes for stage 3, as the other bili
routes are.

Run (mica, macOS):
- At abcbc632e, this change on origin/main 9a8219237. The three commits
  main gained before the push (e8001f73a, 7af7a3aba, 005178104) touch
  none of these files:
  - go test -count=1 -timeout 45m ./internal/agentenv ./internal/agent
    ./internal/cli ./internal/library ./internal/gui ./internal/davsync:
    all ok;
  - go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
    ./..., go build: ok;
  - gofmt -l: nothing;
  - library-bili-settings, library-bili, i18n-keys and sync-scope
    .test.cjs, Chromium and WebKit, every language, 1100 and 420 wide:
    ok;
  - library-bili-settings was red in WebKit 1 run in 4: the tab was
    clicked by its index in a list read before the sidebar drew its own
    list, in another order, so the click reached another tab. A dump of
    the page at the miss showed Instructions still open. Both files now
    click the tab by its name. library-bili.test.cjs did the same twice
    and is changed with it. After the change: WebKit 6 runs in a row and
    both files in both engines, all green.
- Full go test ./... at an earlier base, 7eecbcc56: only
  TestFolderVarsAreListed and TestEveryRouteHasACommandOrIsNamed went
  red, both guard tests for this change. They are fixed here and pass in
  the run above.
- Whole GUI suite at that base: 71 reds, none in the Library, i18n or
  sync. Each also fails without this change on origin/main 459d668b3
  (68 there, and the rest pass at this head):
  - agent-details-ready: #6369, #6373
  - api-key-theme: #6444
  - account-arrange: #6010
  - agent-switch-accounts: #5925
  - aside-native: #6212
  - agent-menu-label: #6371
  - account-refresh-holds: #5814
  - bark: filed as #6543

Broken by hand:
- Collect not carrying the file: TestBiliFileCarried red.
- The model pick without summary, or Advanced not kept open: the GUI test
  red (22 of 32).
- On the old code the new Go tests don't compile, and the route test
  gets 404.

Not tried: a real bili proxy reloading. The reload is tested against a
fake /__bili/config/reload, and bili's source was read, not run. Not
tried with a real WebDAV/S3/GitHub server between two computers either:
the davsync tests use the fake server. When a running bili doesn't reload, the status
line says to restart the agent.
2026-11-13 22:02:05 +08:00
yetone 0051781044 claude-desktop: a new Claude Magpie leaves the original alone, its own Claude Code folder included (xMopf7RF on X)
xMopf7RF asked for Claude Magpie to be a full clone, like an Android
app twin: making it from magpie must not wire their own Claude Desktop
or touch its config. In a sandbox HOME on mote with the real Claude.app
(`launcher add`, then `claude-desktop magpie`, as "Use Claude Magpie"
does), origin/main f798b4eb7 left Claude's and Claude-3p's files
byte-identical, but:

- ~/.claude/settings.json got Desktop's Explore flag (and, with models
  on magpie, Desktop's windows and caps): the twin's Code tab ran on the
  user's own Claude Code folder, since its own folder (#6459) was
  opt-in;
- `launcher remove` then put the user's own Desktop on magpie
  (deploymentMode 3p in Claude/claude_desktop_config.json, Claude-3p's
  configLibrary): turning the Separate app off always moved the wiring
  back to the usual folders, even when it never came from them.

Decided (product calls are delegated):

- A Claude Magpie made new gets ~/.claude-magpie-desktop
  (desktopIsoClaudeDefault in SetDesktopIsolated). Made new is the app
  off and no Claude-Magpie-3p folder yet, and the user never set the
  option: settings.DesktopIsolatedClaudeChosen, set by the Advanced fold
  and `launcher claude-dir`. A clone made before (chats in
  Claude-Magpie-3p, Code tab on ~/.claude) and a user's off are kept.
  The option itself stays where it was; no new UI.
- Off moves the wiring back only when it came from the user's own
  Desktop (stash claude-desktop.isolated-from-own, set when the on path
  moves it). A twin made beside a Desktop not on magpie leaves that
  Desktop off magpie. A Separate app turned on before this mark (since
  11-09) also leaves it off when turned off; connecting it again is one
  click, while wiring a signed-in Desktop the user didn't ask for is the
  harm reported.

Run (mote, at this change on f798b4eb7; after the rebase onto 7af7a3aba,
which changed internal/agent, agent and settingsapi tests and vet ran
again: ok):
- Sandbox HOME, real Claude.app, the same three steps as above: Claude,
  Claude-3p, ~/.claude and ~/.claude.json byte-identical after add and
  connect and after remove; the twin's app script exports
  CLAUDE_CONFIG_DIR=~/.claude-magpie-desktop and Desktop's Explore flag
  went into that folder. Second sandbox: own Desktop wired, `claude-dir
  off`, `launcher add` moved it into the clone (Code tab on ~/.claude,
  as chosen), `launcher remove` moved it back. Sandboxes removed.
- go test -tags nogui agent, cli, settings, settingsapi, desktopiso,
  desktopdir: all ok. gui TestSettingsSaveKeeps*, TestCoreScriptBudget
  ok.
- gofmt -l clean; go vet ./... (darwin), GOOS=linux -tags nogui and
  GOOS=windows go vet ./..., linux and windows builds: ok.
- GUI, Chromium and WebKit: desktop-twin, desktop-isolated-claude,
  desktop-isolated, i18n-keys: 72 of 72 (no GUI file changed).

Broken by hand:
- Off always moving back (no mark check): TestClaudeMagpieTwinLeaves
  TheOriginal red ("the user's own on magpie true").
- No desktopIsoClaudeDefault call: the same test red ("its own folder
  false").
- The default not asking whether the user chose: TestClaudeMagpieOwn
  FolderKeepsWhatWasSet/chosen_off red ("its own folder turned on").

Not run at push: the full go test -tags nogui ./... (on the
f798b4eb7-based tree) was queued on mica behind another session's
suite (mote and mica both over their core count), not finished. Not tried:
a Code-tab session in the real twin's UI (#6459 saw one write into the
folder).
2026-11-13 21:55:13 +08:00
yetone 9a82192375 agents: Pi's row picks the protocol magpie's models are asked on (xiaomanweiman on X)
magpie writes Pi's ~/.pi/agent/models.json with api "openai-completions".
xiaomanweiman found that T3 Code's pi plugin then puts all 71 tools in the
context, while on "openai-responses" only 3 core tools load and the rest
come lazily. v0.1.4039 kept an api set by hand; this adds a choice so no
one has to edit the file.

Pi's opened row in Agents has a Protocol row, picked in the app's menu
(no native select): Each model's own (today's default, unchanged),
OpenAI Chat Completions, OpenAI Responses, Anthropic Messages. These are
the KnownApi names in pi-ai 1.4.0 (/opt/homebrew/bin/pi) that magpie's
gateway serves (dshAPIs). The choice is stashed as pi.protocol and written
into the magpie provider block (piProviderOn/piModelOn). Anthropic
Messages also gives each model the gateway root as its baseUrl, since
Anthropic's SDK adds /v1 itself. Effort levels and prompt caching follow
the api actually written. An api typed in models.json by hand still wins
(piAPIsKept) and shows as the picked value. The CLI has
`magpie pi protocol <api|default>`. It is Pi only: not its forks (OmO,
Prime Agent, ...) or Aside. It is hidden while the pi-magpie extension
serves the models, and it reads nothing at a stopped WSL distro (#3896).

Tests:
- internal/agent/pi_protocol_test.go: TestPiProtocolPicked.
- internal/gui/tests/pi-protocol.test.cjs: Chromium and WebKit, en, zh,
  zh-TW, ja, de. It checks the row, the menu (4 items, no select, the
  current one ticked) and what /api/set gets.
- Strings in i18n.js in every language.

Broken by hand: with the protocol not written, TestPiProtocolPicked goes
red. With the menu label left untranslated, pi-protocol.test.cjs goes
16 of 20 red.

Real use: a nogui build ran in a sandbox HOME on 127.0.0.1:3562, against
a fake OpenAI Chat upstream, with the real pi 1.4.0 `-p "say pong"` and a
logging tap:
- completions: POST /v1/chat/completions
- responses: POST /v1/responses
- anthropic-messages: POST /v1/messages?beta=true
- default: /v1/chat/completions
Each answered PONG-FROM-FAKE. An api typed by hand (openai-responses)
survived `magpie sync`, and `magpie pi protocol` showed it.

Run at this head (rebased on origin/main 459d668b3):
- mote: gofmt -l clean; go vet of internal/agent, internal/gui and
  internal/cli ok; go test -count=1 of those three packages ok (an
  earlier run there found TestWSLColdPlaceOpensNothing and
  TestCoreScriptBudget red, both fixed here; the budget is met by
  trimming this change's code, not by raising it).
- mote at the pre-rebase tree: GOOS=linux go vet -tags nogui ./..., a
  windows vet, and go build, all ok.
- mica: pi-protocol.test.cjs 20/20, and the 65 agent-*, pi-*, i18n-* and
  connect-* GUI files. Their only reds are 55 in agent-details-ready,
  agent-switch-accounts and agent-menu-label. The same 55 fail on
  origin/main 459d668b3 alone, and are filed as #6373, #6369, #5925,
  #6029 and #6371.

Not run: the full `go test ./...` and the whole GUI suite. Both machines'
suite locks were queued behind other sessions' suites for hours. Not
tried: Pi forks, or a real vendor upstream behind each protocol (the
upstream was a fake).
2026-11-13 21:41:05 +08:00
yetone 459d668b35 sync: pick what syncs, preview a sync, undo the last one (#6428)
jinpwng (#6428, on X) syncs two computers and wants only Library and
memory to go between them: each keeps its own providers, settings and
models. They also want to see what a sync would change before it
applies, and to roll the last one back.

What syncs: providers, settings and profiles now have switches like
agents' models, library and memory (Config.Providers/Settings/Profiles,
*bool, nil = synced as before, so an existing setup syncs exactly what
it did). The sync form shows Providers (and its API keys), Settings and
Agents' models up front; Profiles, usage and sign-ins sit under
Advanced, closed unless one is set away from its default. The form
sends a part's choice only when it is or was off. A part left out
stays as it is here and on the server; turning it back on joins it
like a first sync (st.Off, rejoin). The sync's line says which parts
each computer keeps ("Stays as it is on each computer: ..."). The
setup text and the CLI carry it: magpie <webdav|s3|github> set
providers=no settings=no profiles=no.

Preview: davsync.Preview (plan.go) says, per part, what syncing now
would bring in, send up, or leave; library items and memory files by
name, sign-ins and plugins gone. Preview... in Settings > Sync shows it,
and Sync now from there runs SyncPreviewed(token): if the server or
this computer changed since, it says so and shows the new plan instead
of syncing something else. CLI: magpie <kind> preview.

Undo: a sync that brings parts in records them (st.Applied) and keeps
a sealed copy of this computer first (keepSealed, as Restore does).
Undo the last sync puts those parts back from that copy, on this
computer only (st.Local, so the next sync sends it up rather than
fetching the server's again). If one of them changed here since, it
asks first (409 changed, Undo anyway). CLI: magpie <kind> undo-sync
[anyway]. Restore's own Undo is unchanged.

docs/subsystems/sync-backup.md and the site's sync docs (en, zh, ja)
have a section on it. i18n: zh, zh-TW, ja, de.

Run (worktree at base 48e394146):
- go test -count=1 . ./internal/davsync ./internal/cli: ok (mote).
  Broken by hand, each went red: syncs() forced true (scope tests),
  rejoin's again forced false, UndoSync without the st.Local update.
- go test -count=1 ./internal/gui: TestCoreScriptBudget was over by
  85 bytes; the sync-left line moved into syncfiles.js, now ok.
- go vet ./internal/gui, GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok. gofmt -l: nothing.
- node --check app.js, syncfiles.js, sync-scope.test.cjs: ok.
- GUI (mica), every test file that opens Settings > Sync or calls
  davsync (22 files) plus i18n-keys, Chromium and WebKit, 1100 and
  420px, en/zh/zh-TW/ja/de: 453 of 454 pass. The red is s3-sync webkit
  en "picking S3 must not scroll the page" (0 !== 98), the same on
  origin/main 52c9880cb (#3413, #2448). An earlier run also had
  library-new-skill chromium en 420 red, the same on main (#6539).
  sync-scope.test.cjs is new: on the old code there is no Providers
  switch, Preview or Undo, so it fails at once.
- Rebased on origin/main 7eecbcc56 (app.js and i18n.js changed there):
  TestCoreScriptBudget, go test . ./internal/davsync, node --check, and
  i18n-keys, sync-scope, webdav-settings-refresh (both engines): ok.
- The full go test ./... was started through mote's suite lock when
  this was pushed; its result goes on #6428.

Not tried: a real WebDAV, S3 or GitHub server (the tests use fakes);
the real app on Linux WebKitGTK. "Save and sync" from the form, after a
preview, syncs without the preview's token check.
2026-11-13 21:09:44 +08:00
yetone 36c5ee1e6c claude: a run that ends during a turn keeps its session for the answer, retry or summary after (#6528)
When the Claude Code bridge ended a run in a turn the client still goes
on with (runTimeout on an AskUserQuestion, or letGo when the client went
away mid-reply), removeRun deleted its session file. The late answer,
the tunnel-drop retry and the delayed AgentSummary then found no run and
were told whole to a new Claude Code (recih: 118K and 305K written to
the cache again).

removeRun now keeps such a run (keepEnded, claude_ended.go) in the same
b.mu section that takes it out of runs, so no request in between finds
neither. The bounds: at most endedMost (16), each for endedLongest
(idleLongest, the cache hour), the oldest let go first, with its files
removed. Not kept: shelved, rewound, client cache marks, a handed-over
account, or anything at gateway stop (abortAll drops them all, and
sweepSessions takes what a crash leaves). branch and retryBranch look at
kept runs after live ones, latest first. Each branch cuts its own copy,
so the kept file is never written and the AgentSummary that comes after
a recovery still branches.

Real Claude Code 2.1.316 (mock Anthropic plus an MCP tool that never
answers, both -p and interactive): the text and tool_use lines are in
the jsonl ~30-60ms after the reply streams, and on SIGTERM only
cost-state lines are added, with no result and no interrupt marker. So
a cut after the call line is sound.

Run:
- New tests: TestClaudeAnswerAfterTheRunEndedBranchesOffItsKeptSession,
  TestClaudeEndedRunsSessionsAreBounded (time, count, stop, unkept),
  TestClaudeTurnSentAgainAfterItsRunEndedBranchesOffItsSession (real
  letGo through the interactive harness, -count=10).
- Broken by hand on mote: with keepable() returning false, the answer,
  count and retry tests went red; with (gone || !run.closed) put back to
  !run.closed, the answer and retry tests went red.
- gofmt -l clean. go vet -tags nogui ./... with GOOS=linux, GOOS=windows
  and darwin on mote: ok.
- Full suite, go test -tags nogui ./... -timeout 45m on mica at
  07ed85f97 (origin/main d21cb563e + this change): every package ok
  except the root package's TestNoEagerPackageRegexps
  (internal/davsync/setuptext.go:73). That red was on main and is
  fixed by 48e394146 (#6534). After rebasing onto it (this head): ., internal/davsync,
  internal/gui and internal/gateway ok.

Not tried: a real AskUserQuestion answer through a live magpie with a
real Claude account; the reporter's case is reproduced in tests with an
injected end (abortFor and a cancelled client).
2026-11-13 20:04:42 +08:00
yetone f5553d7103 sessions: a Pi subagent's calls are its lead session's, on its own model (nzvzbmz78932 on X)
nzvzbmz78932 on X: "在pi子代理中使用了deepseek 但是不显示用量". pi-subagents
(npm 0.88.1) runs each subagent as a Pi of its own, its session in
<lead file's folder>/<run id>/run-<n>/session.jsonl (async and parallel
runs a level deeper), or under extensions/subagent/config.json's
defaultSessionDir, its header's parentSession naming the lead's file.
magpie read only sessions/*/*.jsonl, so those files were never read. The
lead's `subagent` tool result carries the subagents' usage summed, and
piParse counted it on the lead's model and provider: a lead on magpie's
entry made it the gateway's (piGateway), so DeepSeek's calls were on no
page, Usage or Sessions.

- piFilesIn reads every session file under a lead's folder as the
  lead's (non-main, like omp's), and the defaultSessionDir ones through
  their headers' parentSession, up to 8 levels.
- piSubagentsRead: a tool result whose every sessionFile is one of those
  counts nothing, in piParse and piCall; one naming a file not read
  still counts as before.
- The scout's header id is in Session.Subs (pi is idInFile), so a
  subagent on magpie's entry is the lead's row to the gateway too.
- state.codexPath is parsePath, the file read, for piLeadID: a new field
  took state past its 416-byte class (TestStateFitsItsSizeClass).
- parseVersions and callParseVersions pi/raft/cindy raised.

The fixture is a real run: Pi 1.4.0 with pi-subagents 0.88.1 in a
sandbox PI_CODING_AGENT_DIR, a lead and one scout on a relay's
deepseek/deepseek-flash; system prompts dropped, paths rewritten.

Run (mica, at this head):
- go test ./internal/sessions: ok (119s)
- GOOS=linux and GOOS=windows go vet ./internal/sessions: ok; gofmt clean.
- Linux (wsl-run, magpie-desktop): TestPi*, TestOmp*, TestCodex*,
  TestStateFits*: ok
TestPiSubagentCalls: beside the lead and in defaultSessionDir, each with
the lead on the relay and on magpie's entry (the reporter's case).
Broken by hand: without the walk, 3 of 5 calls and 0 of 2 with the lead
on magpie (red); without the tool-result skip, 6 calls, the sum counted
again (red); the Subs check was red while it named the run id.
Not tried: the reporter's own files; a subagent nesting subagents; a
subagent run on magpie's entry against a live gateway.

With f0fb22c6b and 5bc816c1a below it, at this head (mica): go test
./internal/sessions ./internal/agent ./internal/claudecode ok,
./internal/gateway -run TestClaude ok, GOOS=linux and windows go vet of
the four ok, gofmt clean.
2026-11-13 19:07:34 +08:00
yetone 9205ee109c agent: the Claude Code magpie downloaded keeps ~/.claude from reading as "CLI not found"
Wing8Aqua on X runs magpie as a systemd service on Ubuntu, where the
Claude subscription runs the Claude Code magpie downloaded
(claudecode.Install, in its cache folder, off PATH). Magpie's own runs
make ~/.claude, and the Agents page took that folder, with no `claude`
on PATH, for an uninstall's leftover: Claude showed "CLI not found"
while that Claude Code answered every request, and `magpie claude`
starts it. cliHeld now counts claudecode.Downloaded() for Claude Code.

Run: TestCLIMissing* in internal/agent on Linux (wsl-run): ok, with a
case for a download and one for a version folder without its binary.
Broken by hand (the download not counted): case 5 red.
2026-11-13 19:07:34 +08:00
yetone 6fad0d0465 gateway: a run waiting a minute on its subagents gives its Claude Code place to one that needs it
Wing8Aqua on X (0.1.4026, Ubuntu, magpie.service with memory.high 768M):
"4 Claude Code processes are running, as many as may run at once (768 MiB
of memory (cgroup /system.slice/magpie.service/memory.high) holds 4);
none ended within 2m0s". An ask that finds the room full lets go of an
idle run, else of a run parked on tool results, but only one parked
parkLongest (5 minutes), while it waits claudeRoomWait (2 minutes). A
lead conversation waits on its parallel subagents' Task calls for as
long as they work, and every subagent is a conversation needing its own
Claude Code: the lead held a place, doing nothing, while a subagent
waited the 2 minutes and was answered 503.

letGoForRoom now takes a parked run once it has waited roomParkLongest
(1 minute), well inside claudeRoomWait. Its results go to a new run told
the whole conversation, as past parkLongest; a tool answered within the
minute keeps its run, and busy runs are never let go.

Run: TestClaudeRoomLetsALeadWaitingOnSubagentsGo, with the room tests
(TestClaudeRoom*, TestClaudeRunsHeld*, TestClaudeOneOffs*,
TestClaudeParked*, TestClaudeNoRoom*, TestClaudeMem*) on Linux
(wsl-run, magpie-desktop): ok. Broken by hand (parkMost back to
parkLongest): the subagent got the 503 after 30s, red.
Not tried: the reporter's machine; whether their 4 were busy rather than
parked is not known (their `magpie claude-code runs` would say).
2026-11-13 19:07:33 +08:00
yetone 880da8c17e agent: ZCode is told a model takes video, so a video it attaches reaches it (Flandern1211 on X, #5098)
A model whose source lists video input (antigravity/gemini-4-argon, say)
reached ZCode as text and image only, in config.json's modalities.input
and in provider_config.json's inputFormat, so ZCode never attached a
video to it. buildModels left the catalog's kinds out of the agent
model, and zcode.go rebuilt the list from m.Images.

- buildModels carries Entry.Modalities() into InputModalities and
  OutputModalities.
- zcodeInputs adds "video" when the model lists it and the provider's
  format is Messages or Chat. ZCode's own built-in rules (3.14.3's
  zcode-builtin.json) use inputFormat.supportsVideo, so the key is one
  its strict schema takes; it is written only when true.

Ported from Flandern1211's fork branch (fix/zcode-video-input,
e955d3c24), with these differences after review:
- Its gateway half (Messages video block and Chat video_url as a file
  part) is on main already, since b4fc29a6e (#6135), so it is not
  taken; TestZCodeVideoReachesCodeAssist keeps their captured ZCode
  shapes as a guard.
- PDF is not offered (no supportsPdf, no "pdf" input), and Messages'
  document block is not read as a file: a translated request still
  loses a PDF (#5452), so ZCode would be told of a kind that doesn't
  arrive.

Test: TestZCodeToldOfVideoInput, red on origin/main e4ea31321
("config.json's media/gemini takes [text image], want [text image
video]"), and red with the Responses gate taken out by hand.

Not tried: a real ZCode with a video against a real Gemini model here;
the reporter captured ZCode 0.17.1's video block and video_url on
Windows 11.

Co-authored-by: Flandern1211 <163982805+Flandern1211@users.noreply.github.com>

Ran (mica, at this tree on e4ea31321): gofmt -l internal (nothing),
go vet ./..., GOOS=windows go vet ./..., GOOS=linux go vet -tags nogui
./..., go test -tags nogui -timeout 45m ./internal/agent
./internal/gateway ./internal/catalog ./internal/provider: ok agent
(297s), gateway (1080s), catalog; provider red on TestHostBuildsNoList
only ("Host allocated 5 times"), #6479, red on main and untouched here
(baffcb65d on main since). Rebased on origin/main ea3edd4b1 (no change
to these files): the new tests and TestZCode/TestCrush again, ok.
2026-11-13 18:57:10 +08:00
yetone 7758da0770 agent: Crush is told which models take images (Novello42 on X, #6515)
Crush's view tool answered "This model (…) does not support image data",
its file picker (ctrl+f) was hidden and a pasted image was left out, for
every model through magpie. magpie wrote Crush's providers.magpie.models
without catwalk's supports_attachments, so each model decoded with
SupportsImages false (capabilities.vision false once Crush 0.99 migrates
the file: migrateCatwalkV2Model, internal/config/load.go). Each model now
carries supports_attachments from m.Images, as OpenCode's modalities do.

Checked against catwalk and Crush main: Crush's load.go moves
supports_attachments to capabilities.vision; catwalk v3 reads vision.
Report and root cause: #6515 by DaVinci42.

Not changed: magpie still writes Catwalk v2 keys, which Crush 0.99+
rewrites to v3 on load; filed as #6521.

Test: TestCrushModelsSayTheyTakeImages, red on origin/main e4ea31321
("see/looks has no supports_attachments").

Ran (mica, at this tree on e4ea31321): gofmt -l internal (nothing),
go vet ./..., GOOS=windows go vet ./..., GOOS=linux go vet -tags nogui
./..., go test -tags nogui -timeout 45m ./internal/agent
./internal/gateway ./internal/catalog ./internal/provider: ok agent
(297s), gateway (1080s), catalog; provider red on TestHostBuildsNoList
only ("Host allocated 5 times"), #6479, red on main and untouched here
(baffcb65d on main since). Rebased on origin/main ea3edd4b1 (no change
to these files): the new tests and TestZCode/TestCrush again, ok.
2026-11-13 18:57:10 +08:00
yetone 456b5c6c74 alibaba: a RAM user's NotAuthorised names the grants Token Plan needs (#6506)
hkxhkxhkx on X (#6506, v0.1.4026, gateway on OpenCloudOS): the Token
Plan personal edition's usage, read with a RAM user's AccessKey, fails
with BailianGateway.Team.NotAuthorised. The RAM user had the
AliyunBailian* and AliyunModelStudio* policies.

magpie calls the right API: GenerateCLIAccessToken, then the console
gateway's zeldaHttp.apikeyMgr./tokenplan/personal/api/v2/usage, the same
call Alibaba's own CLI (modelstudioai/cli, `bl usage token-plan`) makes;
its only other parameter, switchAgent, is for delegated access, not RAM
users. Alibaba's Token Plan docs (personal FAQ; permissions and usage)
list what a RAM user needs, and none of it is a Bailian/ModelStudio
policy:
- the AliyunTokenPlanReadOnlyAccess (or FullAccess) system policy,
- AliyunBSSReadOnlyAccess for the personal edition,
- the Administrator or Subscribe Plan permission for the RAM user on
  Model Studio's Account Management page.
The NotAuthorised error now says those three and where, or to use the
main account's AccessKey. Any other refusal now carries the console's
errorMsg (read as raw JSON, so an odd type doesn't hide the code).

Tests: TestAliGatewayRAMNotAuthorised answers the call with the
console's NotAuthorised envelope and checks each grant is named, and
that another code shows its errorMsg. Broken by hand: the old message
makes it red on five checks.

Run on mica (and again after the rebase onto 49d7adef7): gofmt -l clean; go test ./internal/provider
-run TestAliGateway ok; vet as in the parent commit; go test ./internal/provider red only on
TestHostBuildsNoList (#6479). The editor's alibaba hint is unchanged:
the core script budget is red at base (#6518), and the error on the
Usage page carries the whole list. Not run: a real RAM
user's key (none here); the full suite.
2026-11-13 18:41:28 +08:00
yetone 80c22eecba agents: Codex leaves a model unchecked in its provider's list (JNDliuliuM on X)
JNDliuliuM: after picking new models for a provider, Codex CLI didn't
change, and after a restart it was still on the old model. magpie wrote
the new list, but Codex's `model` (config.toml, or magpie.config.toml for
`codex -p magpie`) stayed on the model the user had unchecked. Resolve
still takes any provider/model, so Codex kept starting on it and asking
the vendor for it.

Tried with the real codex-cli 0.165.0 in a sandbox CODEX_HOME, profile
wiring: the list was swapped from sub/old-a, sub/old-b to sub/new-x,
sub/new-y. After a restart, /model listed only the new ones, but the
status line still read sub/old-a, as the profile named it.

What changed:
- provider.Unpicked(id) reports a model the user has since unchecked:
  the provider has picks, its served models lack the model, and it isn't
  a decision model. This is the same rule ResolveRoute already applies
  to routing groups (#3911).
- agent.pickedInstead moves such a model to the first model of that
  provider that magpie lists for the agent now.
- Codex's Sync calls it before its other model branches, through set, as
  picking the model does. The profile's Sync calls it through put. The
  Codex app reads the same config.toml, so it follows too.
- Left alone:
  - a provider with no picks, whose list is the vendor's and may lack
    the model (#2642);
  - a provider with none of its models listed any more.

Run on mote:
- TestCodexLeavesAModelUncheckedInItsProvider (as provider, beside a
  ChatGPT sign-in, profile) and TestCodexKeepsAModelOfAProviderWithNoPicks;
- go test ./internal/agent/ ./internal/provider/;
- go vet for darwin, linux and windows on both packages;
- gofmt.
Result: internal/agent ok (470s). internal/provider is red only on
TestHostBuildsNoList (a Gemini provider's Host allocates 5 times), which
is #6479 and was already red on main.

Broken by hand: with the Codex Sync call disabled, the "as its provider"
and "beside the sign-in" subtests are red ("model = sub/old after sub/old
was unchecked"). With the profile call disabled, the "by its profile"
subtest is red.

Not tried:
- the fixed magpie with a real Codex;
- the Codex app.

Not changed, filed as #6504: other agents' model fields, and Codex's
subagent and compaction models.
2026-11-13 17:37:48 +08:00
yetone f4a73672ef routing: a ChatGPT API account is weighed by its Codex twin's reading, and its story lines wear its own logo
tmr11235 on X (v0.1.3924): a routing group of two ChatGPT accounts, each
added both as Codex and as ChatGPT API (chatgpt-api). The Codex rows read
their week and reset; the story below said "剩余额度未知,排在已知的之后"
next to the Codex logo, so it read as the Codex rows being unknown.

Two causes, both still on main:

- The story's lines were about the ChatGPT API accounts, but a line
  named only an account's name, and logoed() put the logo of the first
  member of that name in the order: the Codex twin. asides() now says
  which member each line is about (by its place, as two lines may say
  the same words), and renderSteps hands it to logoed(), as it did for
  a skipped member's line only.
- OpenAI tells a ChatGPT API account's plan usage nowhere magpie can
  ask, so Smart weighed it as unknown and put it after every known
  account, though it spends the same plan as its Codex twin.
  Allowances("chatgpt-api") now gives such an account the Codex
  account's allowance (samePlanAllowances), matched as
  SamePlanAccounts matches them: both tokens' chatgpt_account_id and
  chatgpt_user_id, never the name, so two Team seats of one email stay
  apart. One with no Codex twin stays unknown. The Routing card reads
  the same figure, as it reads the gateway's.

What was run (GUI on the Linux box through wsl-run, mote over its load
then; Go on mote):
- go test ./internal/provider -run 'TestChatGPTAPIAllowanceIsTheSameAccountsCodexReading|TestRenewedAccountForgetsItsAllowance|SamePlan': ok
- node --test routing-twin-logo (new; chromium and webkit; en, zh,
  zh-TW, ja, de; 1100 and 420): 20 of 20 ok.
- Every GUI file that opens the Routing page (199) plus i18n-keys and
  i18n-en-no-cjk: 3533 ok, 61 red in 13 files (click-scroll,
  ctx-head-narrow, ctx-route-align, ctx-session-line,
  inner-scroll-contain, mobile-web, routing-ctx-sessions,
  routing-many-keys, routing-pin-away, routing-pulse-composited,
  routing-row-swap, routing-sky-under, routing-story-shrinks). The same
  13 files at origin/main daaa11cb5 on the same Linux box: 57 red in
  the same tests; on mote the 13 files give 23 red at both
  origin/main and this change, test for test (ctx-session-line,
  mobile-web, routing-pin-away, routing-row-swap,
  routing-story-shrinks).
- go vet ./internal/provider ./internal/gateway (darwin), GOOS=linux
  and GOOS=windows go vet ./internal/provider: ok; gofmt -l: none.

Broken by hand:
- samePlanAllowances not applied: the new provider test is red ("the
  chatgpt-api account reads [] (known false)").
- asides' member dropped (about[i] -> undefined): routing-twin-logo is
  red in all 20 cases, the unknown lines lead with codex-color.

Not tried: a real ChatGPT API + Codex pair in a sandbox HOME (the
match is SamePlanAccounts', run for real since 2df5d40ee); the full
suite before the push (started after it).
2026-11-13 17:36:40 +08:00
yetone cc42ec1d7e agent: an api set by hand in Pi's models.json stays (xiaomanweiman on X)
T3 Code's Pi puts all 71 of its tools into the context on
openai-completions and only 3 on openai-responses, loading the rest when
asked. The reporter set providers.magpie.api to openai-responses in
~/.pi/agent/models.json, and the next catalog sync wrote
openai-completions back.

piAPIsKept (pi_api_kept.go), called from piBlockKept (Pi, its forks and
Aside), keeps an api the user set for magpie's provider or for one of its
models. As with a maxTokens typed by hand (output_kept.go), the stash
records the APIs magpie wanted per file (api:<path>:wanted), and an api in
the file that is none of them is the user's. A model's keeps its baseUrl
and compat with it. With no record yet, the provider's is taken as
openai-completions, the only value magpie ever wrote there, so a file
edited before this release keeps the user's value on its first sync. An
api the file lacks is magpie's. A Chat model left on a provider the user
put on Responses gets compat.supportsStrictMode, as magpie's own
Responses models have it (#3055).

magpie's default is unchanged: a model whose provider speaks Chat stays
on Chat, relayed as Pi sent it, and no setting was added.

Run (mote): go test -count=1 ./internal/agent/ ok (322s); go vet
./internal/agent/ for darwin, GOOS=linux and GOOS=windows; gofmt -l clean.
TestPiKeepsAnAPISetByHand covers a value set before any record, set back
by hand, a model's api with its baseUrl, and one taken out.
Broken by hand: with the piAPIsKept call commented out the test goes red
("provider api = openai-completions, want the user's openai-responses").
Not tried: a real Pi or T3 Code (neither is installed here); the full
suite runs after the push.
2026-11-13 17:14:57 +08:00
yetone 5d54a990d4 usage: switched-off providers' accounts can be checked in, and Check in all (wxkwxk666 on X)
wxkwxk666 asked for two things on the Usage page. First, a provider
switched off should still show its accounts, at the bottom and folded,
so they can still be checked in each day. Second, one button should check
in every account at once.

- provider.OffCheckins (off_checkins.go) lists every account a
  checkiner reaches whose provider is switched off (Off, not Hidden).
  Each is a card with no windows. Nothing is read or asked for it. Its
  check-in result is matched by its own key, not by its name, since two
  sign-ins can share a name (plugins#254).
  GET /api/usage/checkins/off serves the list.
- The Usage page (plugins/usage) adds a "Switched off · n" line after
  the cards and the hidden line. It is folded until clicked. Each
  account shows today's check-in, and a Check in button when it isn't
  checked in yet. The button uses checkinnow.js's ciNowSend, which
  POSTs /api/usage/checkin-account.
- Check in all, at the head of the allowances, presses every account
  not checked in today, from the cards and from the switched-off line.
  It sends one checkin-account request per account, three at a time,
  shows "Checking in i/n…", then gives the counts (checkinPressSaid).
  When no account is due, it says so and sends nothing.
- Nothing switches a provider back on. The new strings are in zh,
  zh-TW, ja and de. Plugin files only: app.js is unchanged.
- docs/subsystems/provider-plugins.md says all of this.

Run, on mote:
- TestOffCheckinsListsSwitchedOffAccounts, in the fakeco plugin
  sandbox:
  - nothing is listed before the switch-off;
  - after it, two cards with distinct keys;
  - a press on one checks in exactly that account;
  - the provider stays off;
  - only the pressed card carries a result;
  - nothing is listed once the provider is switched on.
- go test ./internal/provider ./internal/gui, at this commit on
  origin/main 0fda3a1c1: gui ok; provider ok but for
  TestHostBuildsNoList, red on main already (#6479)
- gofmt
- go vet for darwin, linux (-tags nogui, ./...) and windows
- usage-checkin-all.test.cjs, in Chromium and WebKit, at 900 and
  420px, in en, zh, zh-TW, ja and de (20 of 20). It covers:
  - the line is folded, at the end, with its count;
  - opening it doesn't scroll;
  - a row's own press asks for that account only;
  - Check in all shows 0/2 while held, presses only the two due
    accounts, and POSTs nothing else (no provider switched on);
  - a second press asks nothing and says every account is in.
- 187 GUI files (the Usage page, panel, tray, settings and their
  neighbours), at the rebased head on mote: 3080 cases, 104 red in 16
  files. Those 16 run again on mote at origin/main 5a2d0ff47 and at
  this commit, under the same load: the same 12 files are red on both
  (checkin-now-account #6029, codex-auto-reset #4790, key-balance-card
  #6414, menu-scroll #5982, mobile-web #3952, old-webkit #6030,
  quota-refresh-order #6180, tray-cell-click #5215, usage-cards-hide
  #6294, usage-fold #4790, usage-hidden-way-back #6295,
  usage-range-times #6499, filed now). account-eye, i18n-keys,
  last-page and quota-warm pass on both in that rerun.
- That wide run found account-alias and account-eye red on an earlier
  draft: a fixture answering {} for the new endpoint made the page
  spread a non-array. The page now takes only an array.

Broken by hand:
- Without checkinAll's not-due skip, all 20 GUI cases go red.
- Without OffCheckins' check-in result (q.Checkin), the Go test goes
  red at off_checkins_test.go:56.
- Matching results by name (WithCheckins), as an earlier draft did,
  also went red.

Not tried: checking in a real switched-off vendor account through the
real app. The press is the existing CheckInAccount path, the same one
Settings' per-account Check in now already uses.
2026-11-13 16:56:19 +08:00
yetone a4cd61f77f claude: a turn refused for the account's limit keeps its session till the reset (#6292)
A Claude subscription turn refused for the 5-hour limit before any reply
(429) ended its run through relay's abort, and the conversation's native
session went with it. After the reset the turn was told whole to a new
Claude Code: 354,900 tokens written to the cache again (recih).

Now relay's abort is told the status and words (relayFailing); on a 429
keepForReset shelves a copy of the session cut before the refused turn
(no user line, no synthetic error line), under the turn's key. Cut at
backLine/backMsg for a resumed idle run, or at fromLen (the saved file's
length at start) for a run started from a saved session that has answered
nothing, so a turn refused again while still limited is kept again.

It waits until the reset the refusal names, else the account's used-up
window's reset from the rate_limit_event (KeptClaudeLimits), else 5h; plus
1h, at least idleLongest, at most longestQuota (8d). until goes into
claude-shelf.json, so the entry survives a restart. Shelf still capped at
shelfMost.

Run (on mica; mote was over its cores):
- go test -tags nogui ./internal/gateway/ -run 'Claude|Shelf|Relay|Bridge|Subscription': ok 93s
- new TestClaudeTurnRefusedForTheLimitKeepsItsSessionTillTheReset (print and
  interactive: two refusals, restart, then --resume of the cut session told
  the turn alone) and TestQuotaShelfFor: ok
- GOOS=linux and GOOS=windows go vet ./internal/gateway/: ok; gofmt clean

Broken by hand, each red:
- keepForReset call removed: "try 1: no session kept"
- fromLen forced to 0: "try 2: no session kept"
- fromLen cut at the file's end (refused turn kept): "try 2: the kept
  session isn't the conversation before the refused turn"

Not tried: a real account hitting its real 5-hour limit; Claude's
"resets 9pm" text is still not parsed by resetsAt (the rate_limit_event's
resetsAt covers it). The full suite runs after the push.
2026-11-13 16:36:09 +08:00
yetone a95a7a1cd8 providers: each API key can bill at a price rate of its own (tnt12231 on X)
A relay sells keys in groups that bill at different rates against the
official price (0.5x on one, 1.2x on another) under one endpoint, and
magpie had only the provider's price rate. Now a key can have its own:

- provider.KeyPriceRates, keyed by key id like KeySpendCaps: cloned,
  normalized on save, carried when a key is replaced. A key without one
  bills at the provider's PriceRate. A price the user set for a model
  stands as set, as it does under the provider's rate.
- Usage prices each call at its key's rate (usage.Pricer memoizes per
  key id, BaseKeyPriceIn), so the Usage page, a key's spend cap and its
  typed balance follow it. PriceAt, used to route by price, takes the
  rate of the key the provider holds.
- GUI: the provider editor's Advanced has "Price rate per key" under
  Price rate, shown only with two or more keys, folded past 8 keys like
  the per-key proxies. An empty line shows the provider's rate as its
  placeholder. Save sends keyPriceRates ({} clears, left out keeps).
  The lines, the check and the placeholder live in keyrates.js,
  imported when a provider with two or more keys opens. The core's
  budget goes up 397 for what is left in app.js (the import, the
  draft's copy, Advanced opening for it, the save's line, proxyLines
  drawing another kind of line); app.js stays under its own.
- CLI: magpie provider key-rate <id> [key [rate|default]].
- docs/subsystems/providers-accounts.md: a Key price rates row.

Run, at this head (rebased on 287a1ffa2) through mote-run:
- go test ./internal/usage ./internal/cli ./internal/gui: ok.
  ./internal/provider: ok but TestHostBuildsNoList, red the same on
  origin/main 51b98b1a8 (3 of 3), filed as #6479 (likely 16b8c300f).
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build: ok.
- GUI: key-price-rate.test.cjs (chromium and webkit x en, zh, zh-TW,
  ja, de: own rates saved, provider rate as placeholder, bad values
  refused, comma decimals, {} on clear, a folded key keeps its rate,
  one key shows no lines and posts none), i18n-keys and
  provider-many-keys-proxy (it shares proxyLines): ok. old-webkit:
  keyrates.js added to its on-demand list; its two reds (compat.js
  first, Safari 15.0 styles) fail the same on origin/main 51b98b1a8
  (#5919 and the on-demand list's #6467 family).
- Earlier, at 92bce5c72: the GUI files that reach the provider editor
  (134 tests). The 6 provider-many-keys reds fail the same on that base
  (#6209); proxy-login-fields' chromium zh timeout passes 12/12 alone on
  base and branch (#6374).

Broken by hand: atKeyRate leaving PriceRate as the provider's made
TestKeyPriceRatePrices and TestPricerKeyPriceRates red; the save not
sending keyPriceRates made 20 of 30 key-price-rate GUI tests red, and
keyrates.js dropping each parsed rate made them red again after the
move.

Not tried: a real relay with several keys at different rates; the real
Linux WebKitGTK app. The budget estimate and the Sessions page's costs
still use the provider's rate.
2026-11-13 16:31:24 +08:00
yetone 287a1ffa26 gui: Hermes's other profiles are picked on the one Hermes row again (Norethcy on X)
Norethcy on X, v0.1.4022: "Hermes 其他 profile 的配置消失了,只有默认的
Hermes Agent". 1d60b165c (v0.1.3743) took the connected row's Other profiles
lines out because each profile had a row of its own (hermes#<name>, from
7050da0a4, Norethcy). c96f33d65 (v0.1.3912, geekbb on X) then took those rows
out of the Agents list (Agent.Nested) to keep Hermes one entry, but left the
section out, so from v0.1.3912 a profile's model could be picked nowhere and
the profiles looked gone. The profile:<name> fields were in /api/state all
along (hermesProfileFields, TestHermesProfileModels), the Library still gives
each profile its skills and MCP servers (hermes#<name> through agent.All),
and nothing in any profile's config.yaml was touched.

The opened Hermes row has its Other profiles section again: one line per
profile, its name (a Chinese one as its name), its model picker (the app's
model picker, Default noted as putting back what it had before magpie) and
`hermes -p <id>`. Hermes stays one row, as geekbb asked. The picker note's
hermes# branch is gone: no hermes# row is drawn since c96f33d65.
The "Other profiles" key is back in zh, zh-TW, ja and de.
docs/subsystems/agent-wiring.md says so.

Core script budget +225 (TestCoreScriptBudget): the section was in the core
before 1d60b165c took it out; the Agents rows draw it, so there is no lazy
page to move it to, and it is packed to the shortest form.

Run on mote (the GUI files at the tree before the rebase onto
origin/main 51b98b1a8; at the pushed head again where named):
- hermes-profiles.test.cjs (restored from before 1d60b165c, plus a profile
  named in Chinese whose hint is its id): chromium + webkit, en/zh/zh-TW/ja/
  de, 1100 and 560px, 20 of 20 green.
- Broken by hand: origin/main's app.js with this test: 20 of 20 red.
- go test ./internal/gui at the pushed head: ok (TestCoreScriptBudget was
  red before the pack and the raise). hermes-profiles, hermes-profile-row
  and i18n-keys at the pushed head: green. go test ./internal/agent -run Hermes: ok.
- GUI files hermes-*, agent-*, i18n-*, click-scroll in both engines
  (64 files, 1082 cases): 1027 pass, 55 red, all in agent-details-ready
  (#6373, #6369), agent-switch-accounts (#5925) and agent-menu-label
  (#6371); the same 55 are red on origin/main 51b98b1a8 run alone.
Not tried: a real Hermes install with several profiles in the real app;
Linux WebKitGTK; Windows. No Go code changed outside the budget constant.
2026-11-13 16:22:51 +08:00
yetone 5a2d0ff478 claude-desktop: Use Claude Magpie, a twin on magpie in one click (xMopf7RF on X)
xMopf7RF asked for the Separate app to be reached like a phone's app
twin: one button that makes a second Claude Desktop on magpie and leaves
their own Claude Desktop as it is. Claude Desktop's row, while it isn't
on magpie and Desktop can run so (macOS), now has "Use Claude Magpie":
it turns the Separate app on (settings/desktop-isolated) and then
connects Desktop, so only Claude-Magpie-3p is wired, and says to open
Claude Magpie from Applications. The order matters: connecting first
would wire the user's own Desktop.

The button is drawn by claudemagpie.js with the fold; app.js keeps the
one line that places it, so the core budget goes up by 81.

Run, at this commit:
- TestCoreScriptBudget; gofmt clean.
- GUI on mote, Chromium and WebKit: desktop-twin (five languages, 1100
  and 640px: the posts in order, the status, the button gone after, no
  scroll, no native select; no button without the Separate app),
  desktop-isolated-claude, desktop-isolated, i18n-keys, i18n-en-no-cjk,
  old-webkit (its two reds are on origin/main, #6467, #5919), and every
  agent*/desktop*/claude* GUI file; its reds are all on origin/main
  (#6467, #5919, #6373, #5925, #6179, #6371, #6475).

Broken by hand: connecting before turning the Separate app on turns
desktop-twin red (the post order).

Not tried: clicking the button in a real Desktop; the two calls it makes
are the ones the commit before ran for real (launcher add, then claude-
desktop magpie, in a sandbox HOME on mote).
2026-11-13 16:02:12 +08:00
yetone 6bc0d1e203 claude-desktop: Claude Magpie's Code tab on a Claude Code folder of its own (#6459)
The Separate app (Claude Magpie.app, #5671) kept its own Desktop
userData, but its Code tab's bundled Claude Code still read and wrote
the user's ~/.claude: their CLAUDE.md, skills, plugins and history went
into the twin, and the twin's sessions into theirs (xMopf7RF on X).

An opt-in, macOS-only switch under the Separate app's Advanced fold
(settings.DesktopIsolatedClaude, POST /api/settings/desktop-isolated-
claude, `magpie claude-desktop launcher claude-dir on|off`) gives it
~/.claude-magpie-desktop:

- desktopiso.Script exports CLAUDE_CONFIG_DIR in the app's launch
  script; turning the option on or off remakes the app, and the hint
  says to quit and reopen Claude Magpie, since a running one keeps its
  environment.
- desktopOn writes Desktop's model windows, caps and explore entries
  into that folder's settings.json instead of ~/.claude's while it is on
  (desktopCodeDir, desktopClaudeSync); off moves them back. The folder
  is kept when it is turned off, and shows as the claude# row "Claude
  Code · Claude Magpie".
- The fold is drawn by claudemagpie.js, imported the first time it
  shows; what stays in app.js is the import (isoLazy) and the fold's
  place, 216 bytes, so the core budget goes up by 180 (the 36 of room
  there was taken first).

Run:
- gofmt -l clean; go vet ./internal/... on darwin, GOOS=windows and
  GOOS=linux -tags nogui vet of agent, cli, desktopiso, gui, settings,
  settingsapi (mote).
- go test agent, cli, desktopiso, desktopdir, settings, settingsapi,
  gui, library on mote: all ok except cli's three healthcheck/update
  tests, which ask the gateway mote's own magpie serves on :3425
  (#6223, the same with or without this change).
- TestCoreScriptBudget and TestSettingsSaveKeepsWhatItDoesNotSend at
  this commit and the next.
- GUI on mote, Chromium and WebKit: desktop-isolated-claude (five
  languages, 1100 and 640px), desktop-isolated, i18n-keys,
  i18n-en-no-cjk, old-webkit, and every agent*/desktop*/claude* file
  (98 files, 1,595 of 1,662 pass). Every red is the same on origin/main
  92bce5c72 run alone: old-webkit (#6467, #5919), agent-details-ready
  (#6373), agent-switch-accounts (#5925), claude-quota-onboarding
  (#6179), agent-menu-label (#6371), desktop-tiers Chromium (#6475).
- A real Claude Desktop on mote in a sandbox HOME (~/sb6459, removed
  after): `claude-desktop magpie`, `launcher add`, `launcher claude-dir
  on`. The window and caps moved into .claude-magpie-desktop/
  settings.json, ~/.claude kept only its theme, the script exported
  CLAUDE_CONFIG_DIR, and the launched Desktop's main process and
  children had it in their environment. `claude-dir off` moved them
  back and dropped the export; `launcher remove` removed the app.
  mote's real ~/.claude was listed before and after: unchanged.

Broken by hand:
- desktopOn without the clone-folder branch: TestClaudeDesktopIsolated
  ClaudeDir red (the window stays in ~/.claude).
- The fold without its ontoggle: desktop-isolated-claude red ("shut by
  the redraw").
- settingsapi not keeping the field: TestSettingsSaveKeepsWhatItDoes
  NotSend red.

Not tried: a Code-tab session driven in the real Desktop's UI, so
bundled Claude Code writing into the folder was not seen in this run
(an earlier look at #6459 saw it). Library has no targets for the
clone's folder yet (#6469). The whole GUI suite (1,484 files) was not
run; the files on the Agents page and every i18n file were.
2026-11-13 16:02:12 +08:00
yetone 1c6dc247ed codex: the Codex app restarts once for magpie's list named after it started (not_4O4 on X)
not_4O4 (X, magpie 0.1.4012, Windows): the ChatGPT app's Work tab
listed GPT alone, in a new window and in a new project on D: too.

The app-server reads model_catalog_json only as it starts. codex-rs
app-server model_catalog.rs reloads only when needs_reload is set,
which happens on an account change alone. The app keeps one
app-server for all its windows, and on Windows it runs from login
(StartupTask). So a list magpie named after the app-server started
never reached the picker. That happens when the list first becomes
known (the backend answering, or the models_cache stand-in from
327da691a) or when Codex moves from WSL to the Windows config.
magpie's restart follows only the route (codexAppRoute), and the list
is kept out of the route on purpose (#4550). On Windows StaleCopies
reports no app copy, so no Restart was offered either.

Now deskList stashes when it names the key (codex.desk_at, Agent.DeskAt,
provider.CodexAppDesk). codexAppDeskStep marks the app's app-servers
that started before that time as stale, once for each naming, and they
are ended at idle like a Connect's, with RestartApp off too. The time
is kept while the key is taken out and named again in one change (a
model picked in magpie, a reset), and dropped once deskList takes the
list out as not wanted. Left alone:
- an app-server whose start can't be read;
- the takeover's, where the reset names the list again as it ends, in
  the same look or a later one (c.back) (#4550);
- a new list written into a file already named.

Run:
- Real Windows app-server (OpenAI.Codex 26.1106, codex-cli
  0.167.0-alpha.4.1, sandbox CODEX_HOME, cwd D:\cxproj): model/list,
  then model_catalog_json written, config/read, model/list on the same
  process: still the 12 GPT models. A fresh process listed magpie's.
- win-run: TestCodexDesktopList* in internal/agent ok. A temporary
  test started the Store package's codex.exe app-server: codexAppServersOn
  listed it, and codexServerStart read its start; the test file was not
  committed. TestCodexAppRestartedForTheListNamed ok.
- mote (load 25-33 over 18 cores; mica's disk full):
  TestCodexAppRestartedForTheListNamed, TestCodexAppLeftRunning*,
  TestCodexAppServer*, TestCodexAppSwitch*, TestCodexAppCrash*,
  TestCodexDesktopList* ok. go vet for darwin, windows and linux on
  internal/agent and internal/provider: ok.
  go test ./internal/agent ./internal/provider: internal/agent ok;
  internal/provider red at TestWalletCapHolds only, a midnight
  boundary on mote's clock unrelated to this change, filed as #6474.

Broken by hand, each red:
- the desk step marks nothing stale: ended [], want [60];
- no takeover guard: ended [102] at the reset;
- no c.back guard: ended [103] a look after the reset;
- a new time at each naming: TestCodexDesktopListNamedAt red at the
  magpie model pick.

Not tried:
- the real ChatGPT app's window on Windows: ending its app-server and
  watching the picker list magpie's models. ssh sees no interactive app.
- A key named by a magpie before this one has no time, and nothing is
  restarted for it. Restarting then would restart every running Codex
  app once at the update, the ones that work too. Such a user quits
  the app once.
2026-11-13 16:01:06 +08:00
yetone 16b8c300fe provider: a Gemini compatible URL saved as a bare host is asked at its /v1beta (equinox0253 on X)
cc0d9c8b0 kept a relay's root typed under "Gemini 兼容" as typed, where it
was saved as …/v1beta before, and requests went to the saved base as it
was. So WandAPI's https://api.wandapi.ai was asked
/models/gemini-3.8-flash:streamGenerateContent?alt=sse with no version, and
the relay refused it (the tweet's second screenshot: Claude Code's
/v1/messages → Gemini, 503).

The saved base stays as typed, and the version is added where a request
goes: provider.GeminiAsked gives a bare host /v1beta, as Google's SDKs add
it to a base_url with no path, and keeps a base with a path of its own
(/v1beta, a relay's /gemini, /proxy/v1) as typed. Base(Gemini) returns it,
so the gateway's requests, the native route and the model list
(catalog.FetchGemini at Base) all take it; a model's test (provider/test.go)
read p.Gemini directly and now reads Base(Gemini) too. The Google preset's
bases already carry /v1beta and are unchanged. docs/subsystems/
providers-accounts.md said GeminiBase adds /v1beta to any bare host, true
before cc0d9c8b0; it now says where the version is added.

Run (mote, -tags nogui, on 5a3f055d7 at origin/main 92bce5c72): the new
TestGeminiBareHostAskedAtV1beta (a fake upstream that answers only at the
expected path; bare host, bare host with a slash, /v1beta, /gemini) red on
the old code (asked /models/gemini-3.8-flash:…, 404), green after; the new
TestGeminiAsked; go test ./internal/gateway ./internal/provider -run
'Gemini|Vertex|OpenCode' ok; go vet darwin, linux, windows on provider,
gateway, catalog; gofmt clean.
Broken by hand: Base(Gemini) and the model test back to p.Gemini: both new
tests red.
Rebased on origin/main 0b38eb21c and run again there (mote, -tags nogui):
go test ./internal/gateway ./internal/provider ./internal/catalog -run
'TestWrongEndpoint$|TestNoChannel|Gemini' ok.
Not tried: a real WandAPI account; the full suite runs after the tag.
2026-11-13 15:59:26 +08:00