Commit Graph
2631 Commits
Author SHA1 Message Date
yetone ddc78405cf gateway: a magpie's /v1/models offers Ultrafast where its accounts do
OoopsHh on X: a magpie in Docker could pick Ultrafast on a model, but
another magpie that has it as its Remote magpie provider was offered
Fast alone on that model. The remote's list takes its service tiers from
provider.CodexTiers through codexcat.Entries, and CodexTiers only ever
added "priority". Ultrafast came only from Codex's own catalog, which a
magpie with no Codex beside it (Docker) does not have, and the codexcat
branches for Fast and OwnTier models dropped any tier m.Tiers added.

- CodexTiersWith adds "ultrafast" after Fast where provider.UltraOn says
  the key or account offers it (an OpenAI key's Ultrafast models, a
  provider added by its address on OpenAI's Ultrafast models, a Codex
  account whose live list has it), and on a group where a member does.
  UltraModels is read at most once a list, and only after a model
  already shows Fast.
- codexcat keeps those tiers (withTiers) and names "ultrafast"
  "Ultrafast" when Codex's own catalog doesn't.
- The asking side already sends ultrafast to a Remote magpie
  (RemoteTiers), and the remote already asks a member without it for
  priority (tierMate). Both ends need this version: the remote to list
  it, the local one to read it.

A provider added by its address serving gpt-6.1-sol now lists
Ultrafast in /v1/models, /v1/codex/models and magpie-models.json, as its
editor's CanUltra already said; TestModelsListTiersForEveryClient,
TestRemoteMagpieOffersItsTiers and TestCodexCatalogTiersReachDisk
expect it.

Tests:
- TestRemoteMagpieOffersUltrafast: a relay's gpt-6.2-sol and a group of
  it list "priority ultrafast"; a Remote magpie provider reading that
  list has CanUltra on both, and an ultrafast ask through it reaches the
  vendor as ultrafast. Red on 7d5db0f29 (tiers "priority" alone, no
  CanUltra).
- TestOpenAIKeyUltrafast: an OpenAI key's /v1/models lists ultrafast on
  gpt-6-astra and not on gpt-6-sol, and its trace's order says Ultra
  on the pick (Weighed.Ultra, previous commit).
- tui, codexcat, provider and agent, and gateway's
  'Tier|Ultra|Remote|Fast|Codex' tests: ok on mote.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./... and the three builds: ok on mica. gofmt -l clean.

Full suite (both commits; go test -count=1 -timeout 45m ./... on mica,
load ~30 on 12 cores): 99 packages ok. Reds, each filed and none in
code this touches:
- agent TestWSLAgentFolderIsALink (#7150, ~1 in 6 on main);
- dirent's five watch tests (#7031, a busy Mac);
- gateway TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117, red
  on origin/main);
- gui TestGatewayModeListsNoOwnSessions (#7064);
- sessions timed out at 45m in TestWSLAntigravityLinkedHomeOnce under
  that load (#5451). Run alone with -timeout 90m: ok in 2925s on mica,
  ok in 62s on mote (origin/main 3869aee3b: ok in 54s on mote), so the
  time is mica's, not this change's.

The full suite ran on the base 3869aee3b. After a rebase onto ef997d186
(no files in common), at this head on mote: go build ./..., the three
go vets, tui, codexcat, provider, agent, gui's Budget/Group/Fast/Ultra
tests and gateway's Tier/Ultra/Remote/Fast/Codex tests ok;
group-member-fast, routing-ultra-row, routing-service-tier, gui-de,
gui-ja, gui-zh-tw and i18n-* 50 of 51 (gui-ja's "Gets copies" string,
#7144, on main).
2026-11-19 14:02:17 +08:00
yetoneandggbdpq c1934262ab routing: a group member sent Ultrafast says Ultrafast, not fast
OoopsHh on X: with Ultrafast picked on a routing group's member, the
group list's card still said "· fast". The Routing page's summaries
(the card's member line, the member menus' notes and the route view's
tag) read Group.Fast alone. They now say Ultrafast where the group sends
the member so and an account offers it (memberJSON.Ultra), as the
editor's speed button and `magpie group` already did. The TUI's group
view did the same and now says Ultrafast too. The route trace's Weighed
gains Ultra so the route view's tag can tell the two apart (#7095).

Fixes #6881 and #7095 (paul-tian). ggbdpq took #6881 and posted a
patch on it; its TUI test and the Codex GPT-6-Astra fixture are ported
here with credit.

Siblings checked: `magpie group` (groups_cli.go) and the Agents page
(agentspeed.js) and search tags (fastTag) already said Ultrafast; the
tray has no group speed summary.

Tests:
- group-member-fast.test.cjs: a group "Astra" with an Ultrafast member;
  its card says "gpt-6.2-sol · Ultrafast" / "· 极速" (en, zh; Chromium,
  WebKit). Red on 7d5db0f29 (4 of 4: "Relay gpt-6.2-sol · fast").
  The same card now also holds #6881's Codex gpt-6-astra member
  (ggbdpq's fixture) and checks it reads Ultrafast, not fast.
- routing-ultra-row.test.cjs (new, #7095): the route view tags a member
  sent Ultrafast "Ultrafast" with its own title, and one sent fast
  "fast"; every language, Chromium and WebKit. Red on 7d5db0f29 (10 of
  10: both tagged "fast").
- TestGroupMemberUltrafastShown (tui) and ggbdpq's
  TestGroupMemberUltraShown (a Codex gpt-6-astra member; a member set
  fast alone still says fast): both red on 7d5db0f29.
- routing-service-tier.test.cjs: 20 of 20 green.
- GUI run of the group-*, routing-*, panel-routing, fast-*,
  codex-service-tier, picker-speeds, agent-speed, i18n-*, gui-de/ja/zh-tw
  and header-relang files on mote: 4295 tests, 84 red in 10 files. The
  10 files then run at this head and at origin/main 3869aee3b on mote:
  the same 84 reds on both, each filed: fast-pick/fast-ultra #6201,
  group-editor-selected #5049, gui-ja #7144, routing-pin-away #6512,
  routing-provider-off and routing-rows-fit #7016, routing-row-swap
  #3799, routing-signin #6520, routing-story-shrinks #3954.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-19 13:51:20 +08:00
yetone ef997d186c serve: a SIGTERM finishes the requests in flight, for Kubernetes rolling updates
@justforlxz on X runs magpie in Kubernetes and every update cut the
requests in flight. A SIGTERM ended the gateway like Ctrl+C: the
listener closed at once and Shutdown cut what was left after 2s, an
agent's stream included, with no unready phase for the Service to see.

Now a SIGTERM to `magpie serve`, `magpie web` or `serve --web`:
- GET / answers 503 {"draining":true} at once, so `magpie healthcheck`
  (the image's HEALTHCHECK, and the readiness probe the docs give) fails
  and the pod leaves its Service's endpoints;
- in a pod (KUBERNETES_SERVICE_HOST) it keeps accepting for 5s while
  that reaches kube-proxy and the ingress, then stops accepting;
- the requests in flight, streams included, get up to MAGPIE_DRAIN to
  finish: unset, 20s in a pod (k8s' default grace is 30s, with room to
  save after) and 7s elsewhere (docker stop and Compose kill at 10s,
  and a drain past that would lose the state saved at the end);
  seconds or a Go duration; 0 ends after 2s as before; an unreadable
  value logs and uses the default. magpie web's page port (which
  serves /v1 too) shuts down within the same grace.
Ctrl+C and SIGHUP end as before. Nothing to configure.

A request still answering at the end of any drain was logged as "cut"
but kept running, its upstream call too, until the process exited:
Shutdown doesn't close active connections. The gateway now closes them
after a failed Shutdown, so a gateway restarted in-process (the GUI's
restart, a test) leaves nothing holding the provider catalog
(holdCatalog). TestDrainEndsAtItsGrace's cut request, still in flight
after it returned, made the next test, TestGrokGetsAgentMessageAsUser,
read migrations.json through that hold and fail in a full gateway run
on WSL; the test now waits for it to end, and without the Close that
wait fails at 30s.

PID 1: the image's ENTRYPOINT is exec form, so magpie is PID 1 and gets
the SIGTERM itself (it calls signal.Notify). As PID 1 it exits 2 rather
than 143 after the drain, the same on the old code.

/config shared by two pods (a RollingUpdate overlap) is not verified
safe: files are flock'd and written by rename, but the serving magpie's
sign-in renewal, plugin sign-in renewal and check-ins would run in both.
The docs say one pod per volume with strategy: Recreate (an RWO volume
on another node also stalls a RollingUpdate). Requests sent between the
old pod's end and the new one's start are refused; the drain covers what
was in flight.

Docs: a Kubernetes section (Deployment with an exec readiness probe,
terminationGracePeriodSeconds, Recreate, the RWO note) and a
MAGPIE_DRAIN row on docker.html in en, zh and ja; docs/reference.md's
Docker section; site index regenerated.

Run:
- TestDrainedGatewayFinishesItsStream, TestDrainEndsAtItsGrace,
  TestHandedOverGatewayFinishesItsStream, TestReadOnlyKeyEveryRoute,
  TestDrainGrace, TestDrainOnSignal and the cli Signal tests: ok (mica).
- Broken by hand: without Drain's grace in drainFor,
  TestDrainedGatewayFinishesItsStream fails "the gateway ended with a
  stream in flight".
- Real binary (before the 7s default, which applies outside a pod
  only, and the Close), sandbox HOME, fake SSE upstream streaming 10s, SIGTERM
  at +2s, KUBERNETES_SERVICE_HOST set, magpie as PID 1 in its own pid
  namespace (unshare) on Linux (WSL magpie-desktop), serve and web:
  new: healthcheck fails while draining, a new request 1s after SIGTERM
  200, the stream completes at +10s, exit at +11s. origin/main: the new
  request is refused, the stream is cut at +4s after 4 chunks. Also
  serve on macOS (mica): same, exit status 143.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build: ok (mica), before the 7s default
  and the Close.
- Full suite, go test -count=1 -timeout 45m ./..., on Linux (WSL
  magpie-desktop; mote and mica were each running another session's
  suite) at the first version of this change on 2051dfc23: every
  package ok except root, internal/cli and internal/gui, which can't
  build there (no gtk4/webkitgtk-6.0 dev packages), and
  internal/gateway, red on TestGrokGetsAgentMessageAsUser (the hold
  above, fixed here). The doneHold "close of closed channel" panic in
  the log is #6339/#6505/#6690, not this change.
- After the fixes: internal/gateway and internal/provider whole on WSL
  ok (1075s, 156s); root, internal/cli, internal/gui on mote ok.
- At this head, rebased on 1c9c359f9: internal/cli whole and the drain,
  handover, Codex tool and Grok gateway tests ok (mote); go vet of
  gateway/cli/gui, GOOS=windows the same, GOOS=linux -tags nogui of
  gateway/cli ok (mote).

Not tried: the real Docker image build and a real Kubernetes cluster
(no Docker daemon on mote, mica or WSL; Docker Desktop on xiaomi-gpu is
not running).
2026-11-19 13:04:38 +08:00
yetone 1c9c359f9d gui: Usage cards keep their place as they come in (liuzhengdong99 on X)
liuzhengdong99 on X: 用量界面每张卡片取数的时间不一致,导致卡片渲染时高度一直
跳动——滑到上面看某张卡片,视图会被拽回下面. The allowance cards come in
at different times: each vendor's read (the page asks again every 1.5s
while X-Magpie-Reading says a read is under way), then the curves'
history. Every answer redraws the cards (renderQuotas), and packUsage
grows the ones above the card being read. Nothing kept that card in
place: the view's scroll guard (keepInView) only knew elements by node,
and the cards are new nodes on each draw, so the browser's anchoring was
the only thing holding them. It anchored on nodes that were being
replaced, and the reader ended up dragged down.

Fix:
- The Overview keeps the card being read in place: the highest card (or
  part of the page under the cards) that starts in sight, found again by
  its data-key after a redraw (keepInView's new `only` mode with pinnedAt),
  and followed after every packUsage (followPin). The browser's own
  anchoring stays on while nothing is kept: at the page's top, on
  another tab, and while the cards are dragged or moved by keys (unpin,
  so a dropped card lands where its slot showed).
- Placeholders from the last known height: each card's height drawn in
  full is kept by its key (localStorage magpie.usageCardTall, 1s
  debounce, 200 keys at most). A card still waiting on its read or its
  curve (usageWaiting: quotasReading, the new flag loadQuotas sets, or
  no history answer yet) is packed and held at least that tall, in the
  column count the cards were last whole in at that width. On the next
  start, no card in sight moves.
- loadQuotaHist counts its first answer even when it is empty, so a
  user with no history isn't left waiting (found by usage-pack: the
  cards held their first packing at 560px).

No new animation, nothing scrolls the page on its own (click-scroll
passes), and the layout is unchanged once the cards are in.

Run (mica, Playwright 1.62.0, Chromium + WebKit):
- usage-cards-steady.test.cjs (new): 20 tests, all 5 languages, 1100px
  and 420px. On the old assets (MAGPIE_ASSETS) it was red 8 of 8 in en
  and ja. With the hold disabled, the second visit goes red.
- At ee079814b + this change (then rebased onto 1c29e2c7d, which changes
  only app.css, redact.css and a new contrast test; script budgets
  measured again, unchanged): go test ./internal/gui/ (budgets included),
  gofmt, and usage-pack, usage-cards-steady, usage-drag, usage-arrange,
  click-scroll and i18n-keys: go ok (300s), 64 of 64 GUI tests pass.
- Every usage-*, quota-*, view-*, account-arrange, click-scroll,
  i18n-keys and gui-de/ja/zh-TW file (151 files), run before the empty-history fix and the last
  rebase, head vs origin/main.
  No red at head is new. The reds that are also on base: account-arrange
  (#6010), quota-count-wrap (#3404), quota-curve (#6789),
  quota-refresh-order (#6180), quota-credits (#6807), usage-ledger
  (#5048, #6003), routing-* (#7016), gui-ja (#7144),
  view-trackpad-coast (#4724), view-wheel-unheard (#5158), plus the
  whole-suite reds in #6975 and #6934. usage-pack and usage-drag went
  red at head along the way and are fixed here.

Not tried: the real app (WebKitGTK on Linux, WebView2 on Windows,
WKWebView on macOS) and the full GUI suite.
2026-11-19 13:01:23 +08:00
yetone 426a707a19 library: each subagent is kept in a Markdown file to edit, or one of the user's own in a git repo (JonahFu on X)
JonahFu asked on X (tweet 2123236872940073039) for each subagent's
local path in Library > Subagents, to edit it with an LLM, or to keep a
subagent in a git repository.

Each subagent of the library (not a plugin's) is now kept on this
computer in <library>/subagents/<name>.md as well, in Claude Code's
shape (name, description, model, skills, mcpServers, the prompt), or in
a file of the user's own set under the editor's Advanced (folded unless
one is set), in a repository say:

- FileHash is what the file said when magpie last wrote or took it in.
  An edit there (by hand, by an agent, a git pull) is taken in at the
  next sync and before a change made on the page, and every ticked
  agent gets it. While magpie runs, KeepLinked's loop syncs when a
  file's hash differs, once per edit.
- An edit that can't be read as a subagent (no front matter, another
  name, no prompt) is left as it is, the agents keep what it said
  before, and the editor says why. magpie writes a file only when it is
  missing, or still as magpie left it; never the user's edit.
- A file of the user's own that is there already is what the subagent
  says (a bad one refuses the save). It must be an absolute .md path,
  not a folder, not inside the library, not one another subagent uses,
  and not a file magpie writes for an agent.
- Rename and remove take the library's own file only while it is as
  magpie wrote it; the user's own file always stays.
- File and FileHash are this computer's: Collect leaves them out, Put
  keeps this computer's.

The editor shows the path (click reveals it, Copy copies it), a line
that edits there reach the agents, and the error when one wasn't taken
in. i18n in zh, zh-TW, ja and de.

docs/subsystems/library.md: a row for the subagent's own file and its
tests.

Run at the tree before 2051dfc23 (a Pi market change in
pimarket.go and plugin/market.go only) came onto origin/main:
- mote-run: gofmt -l none; GOOS=linux and GOOS=windows go vet -tags
  nogui ./... and go vet ./...: ok. go test -timeout 45m ./...: every
  package ok, internal/library 504s, except known reds not touched here:
  internal/cli TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
  TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr and
  TestUpdateFindsAMagpieThatWroteNoRecord (#6471, #6223: a real gateway
  on mote's 127.0.0.1:3425), internal/gateway
  TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117).
  mote and mica were both over their cores; the suite went to mote.
- mica-run: node --test library-subagents, library-rules,
  library-commands, i18n-keys, i18n-en-no-cjk (Chromium and WebKit,
  420 and 1100 wide, en zh zh-TW ja de): 44 of 44. Before that, every
  library-*, lib-*, nav-* and i18n* file (95 files, 2071 tests): red
  only in library-commands (its tab-order assert, fixed in the previous
  commit) and library-open-again's 1100px cases, red the same alone at
  base 14b6b9555 (#6751).
- Red on the old code: TestSubagentFileFollowed and
  TestSubagentFileUnreadable went red with the follow step skipped and
  the hash check dropped; library-subagents.test.cjs is red against the
  previous commit's client.js.
- Real use: a sandbox HOME magpie on mica (fake claude on PATH) wrote
  ~/.config/magpie/library/subagents/reviewer.md; an edit there with a
  new description and prompt reached ~/.claude/agents/reviewer.md and
  library.json on the next `library sync`; an edit with no front matter
  was left as written and Claude Code's file kept the old text.
- After rebasing on 2051dfc23, mica-run: go vet ./internal/library
  ./internal/plugin and go test -timeout 45m ./internal/library: ok.
Not tried: a real Claude Code or other agent editing the file, a real
git pull into a repository file while magpie runs (KeepLinked's loop is
covered by TestSubagentOwnFile only), Windows and Linux.
2026-11-19 12:20:02 +08:00
yetone 3132fa1cd9 library: Rules, a folder of rules given to Claude Code, Cline and Kiro CLI (JonahFu on X)
JonahFu asked on X (tweet 2123237371739316685) for Claude's rules
folder in the Library. A new Rules tab keeps rules once and gives each
to the agents ticked for it, in the folder each reads by itself:

- Claude Code: <claude dir>/rules/<name>.md. `paths` is the only
  front matter key it reads (code.claude.com/docs/en/memory). Checked
  on real 2.1.327 in a sandbox: it reads every .md under the folder,
  loads one without paths at launch, and one with paths when
  Read/Write/Edit touches a matching file.
- Cline: <cline dir>/rules (CLINE_DIR, else ~/.cline). Cline 3.0.70
  reads every rule always and has no paths key, so a rule with paths
  isn't written for it; the agent gets a problem and the editor says
  why under the paths.
- Kiro CLI: ~/.kiro/steering, `inclusion: fileMatch` +
  `fileMatchPattern` for paths, else always. A rule named "agents" is
  refused there (it would be AGENTS.md on a disk that ignores case).
- Not listed: Cursor (user rules live in its settings; .cursor/rules is
  per project), Codex (its rules are execpolicy), Droid (command
  permissions), Gemini CLI, Qwen Code and OpenCode (no rules folder).

A body starting with --- gets an empty front matter first. Files are
recorded with their hash in Applied.Rules through the same
syncOwnFiles as subagents and slash commands: a file of the user's own
by that name, or one magpie wrote that the user edited, is never
written over or taken away. Bundles (backup, WebDAV) carry rules; a
bundle from an older magpie leaves this computer's alone. The editor
lists each agent's file to reveal. No CLI yet.

docs/subsystems/library.md: a Rules row and its tests.

Run (mica-run, at this tree):
- go vet -tags nogui ./internal/library ./internal/gui ./internal/davsync
  ./internal/cli: ok. gofmt -l: none.
- go test -tags nogui -timeout 45m ./internal/library ./internal/davsync:
  ok (TestRulesEachAgentsFile, TestRulesKeptToTheirPaths,
  TestRulesLeaveTheUsersFiles, TestRuleCheck, TestRulesCarried).
- node --test library-rules, library-subagents, library-commands,
  library-hooks, library-loading, library-groups, i18n-keys,
  i18n-en-no-cjk (Chromium and WebKit, 420 and 1100 wide, en zh zh-TW
  ja de): 78 of 78.
- The full suite and cross-OS vet ran at the next commit, which this
  one is under.
- Real use: Claude Code 2.1.327 in a sandbox HOME loaded a rule without
  paths at launch and one with paths only on touching a match; a
  sandbox magpie on mica wrote ~/.claude/rules/go-style.md with
  paths: ["**/*.go"].
Not tried: Cline and Kiro CLI loading the files for real, project-level
rules (.claude/rules in a repository), Copilot and CodeBuddy (not
verified, not listed), Windows and Linux.
2026-11-19 12:20:02 +08:00
yetone 3869aee3b0 sessions: agy's calls in T3 Code are on Usage → Requests
zzzkl on X: requests from Antigravity in T3 Code weren't on Usage →
Requests, while a plain agy's were.

T3 Code (pingdotgg/t3code, read at 00c6adbd) runs agy for each
Antigravity instance as an ACP server on the instance's own Google
sign-in: `agy acp --gemini-dir <profile> --app-data-dir antigravity-acp`
(antigravityAuthSupport.ts), the profile being
<T3 Code's folder>/userdata/providers/antigravity/<sha256 of the
instance id>, the folder $T3CODE_HOME or ~/.t3 (dev for its dev
server). Those requests go to Google, never through the gateway, and
magpie's agy reader looked only in ~/.gemini/antigravity-cli, so
nothing counted them. agy writes the same transcript_full.jsonl there
as in its own folder (agy 1.5.10 run that way in a sandbox against a
fake Gemini endpoint; the fixture is its bytes).

agyCallFiles now reads every T3 Code profile's antigravity-acp too, and
Found lists agy for those folders, so the read consent covers them.
T3 Code's folder is appdir.T3Code, shared with agent's t3Base.

Siblings: `agy acp` from any other ACP client with the defaults writes
to antigravity-cli, already read (agy acp --help). T3 Code's magpie
instances (Claude, Codex) go through the gateway and are counted there.

Run: TestAgyCallsInT3Code (default folder, T3CODE_HOME, ~/ form) red
on the old calls_agy.go/access.go with 0 calls, and with Found() =
[claude codex] when only access.go is old; green with the change.
gofmt -l clean; go vet (darwin, GOOS=linux, GOOS=windows) of appdir,
agent and sessions on mote. Full suite (go test -timeout 45m ./..., mica, at 0e3d09361 plus this):
every package ok but agent, dirent, gateway, gui, library and profile;
each red was run again at the base: TestWSLAgentFolderIsALink 2 of 12
red at the base too (filed #7150), the dirent watch tests and
TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes red at the base
(#7031, #7117), TestGatewayModeListsNoOwnSessions (#7064) ok alone,
library and profile hung in testenv.warmAt (#5267) and ok alone.
After the rebase on 14b6b9555 (this commit's tree): appdir ok, agent ok
but TestWSLAgentFolderIsALink (#7150), sessions ok (2335s).
Rebased again onto 9768b384e (its three commits touch none of
sessions, agent or appdir): go build ./... and the TestAgy/T3 tests
of sessions and agent ok at this commit.
No GUI file is reached (no string, API or page change).

Not tried: a real T3 Code signed in to Google (the profile layout is
from T3's source, agy's files from a real agy acp); T3 Code in WSL;
a plain agy with its own GEMINI_HOME/--gemini-dir. The calls count as
agy (Antigravity CLI), not T3 Code, and the Sessions page doesn't list
these conversations (agy --conversation would look in agy's own folder).
T3's throwaway helper sessions delete their files, so their calls go too.
2026-11-19 11:18:11 +08:00
yetone 9768b384e4 router: find_tools finds tools for a query in Chinese, and names every tool when none matches (Passings_z on X)
Passings_z asked on X (tweet 2123227759409586219) why, with the MCP
router's tools on demand, some tools never get used. An agent given
find_tools and call_tool that asks in Chinese found none of the tools
there were:

- hubWords split only at characters that aren't letters or digits, so
  帮我截个图 was one word, and hubWordIn looked for it whole in the
  description, which an English one never has.
- hubMatch.clears needs two thirds of the query's key words, so
  截图 screenshot failed on a tool named screenshot too: 截图 counted
  against it.
- With nothing matched, the reply named 8 tools a server, so a model
  had no way to the rest.

Now:
- hubWords also cuts where a spaceless script (Han, kana, Hangul) meets
  another (截图screenshot is 截图 and screenshot). A spaceless word is
  cut at characters that say nothing of a tool (hubStopRunes: 我 帮 个
  を …), each piece a key word (帮我截个图 is 截 and 图), found in a text
  when it is one character there or at least half of its two-character
  runs are (hubPhraseIn).
- Key words are matched against the tool's router name, its server's
  own name (a server named in Chinese) and its description.
- A key word with letters not in ASCII counts only for a tool whose
  name, server or description has such letters, so 截图 screenshot is
  screenshot to an English tool. An English query matches what it did.
- No match names every tool of each server when that fits in hubSayMax
  (2000 characters), else 8 a server and that find_tools with an empty
  query names every tool. A query not in ASCII when no tool has such
  letters is told the tools are named and described in English.

Siblings: hubNear (call_tool's close names) shares hubKeyWords and
hubMatchOf, so it takes the same words. The GUI's searches are
substring filters (includes), not this tokenizer; nothing to change.
find_tools' and call_tool's descriptions and the instructions, the text
that goes to the vendor, are unchanged.

docs/subsystems/mcp-router.md: Tools on demand says the new matching
and the no-match reply.

Tests (internal/gateway/hub_find_cjk_test.go):
- TestHubFindInChinese: 截图 screenshot, 截图screenshot, 帮我截个图,
  截取屏幕, 发消息到群聊, 截屏 (a server named 截屏工具) find their tool
  first, and not each other's.
- TestHubFindNotFoundNamesEveryTool: all 12 of a server named, the
  English hint, and past the budget the empty-query hint.
- TestHubFindEnglishAsBefore: 30 English queries match exactly what
  they matched at 14b6b9555.

Run:
- Old code (14b6b9555 with the new test file, on mica):
  TestHubFindInChinese FAIL ("截图 screenshot" matched [], "帮我截个图"
  matched [], 6 of 8), TestHubFindNotFoundNamesEveryTool FAIL (not
  every tool, no English hint, no empty-query hint),
  TestHubFindEnglishAsBefore PASS (as it should).
New code, at base 14b6b9555, on mica (mote's load was over 18):
  gofmt -l prints nothing; go vet ./..., GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./..., go build, GOOS=linux go build
  -tags nogui, GOOS=windows go build: ok.
  HOME=<temp> go test -tags nogui -timeout 45m ./...: every package ok
  but agent, dirent, gateway and gui. Each red rerun on mica at the new
  code and at 14b6b9555:
  - internal/dirent watch tests: red at both (#7031).
  - TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes: red 3 of 3 at
    both (#7117).
  - gateway doneHold.serve "close of closed channel" panic
    (continuation_test.go:781): #6505, #6690; not seen on the rerun.
  - TestWSLAgentFolderIsALink (#7150) and TestGatewayModeListsNoOwnSessions
    (#7064): pass on the rerun at both.
  The new hub tests and every Hub/HubMCP/HubFind test pass.
- Rebased on origin/main 7d5db0f29 (cli plugin hosts, update hint; no
  file in common): go build, go vet ./... and
  go test ./internal/gateway -run 'Hub' run again there: build ok, vet ok, gateway Hub tests ok.
- Not tried: a real agent without its own tool search (e.g. OpenCode,
  Kimi) asking the router in Chinese end to end; the queries tested are
  my own phrasings against real servers' English descriptions plus
  invented Chinese ones, not the reporter's own tool list.
2026-11-19 10:54:42 +08:00
yetone 7d5db0f29a cli: a command that ends ends its plugin hosts, and one that doesn't serve starts none (#7146)
athemeroy (WangYeruo on X) runs `magpie serve` as a LaunchAgent with the
magpie-google-ai-studio browser plugin and 11 accounts. Each
`magpie --version`, `version`, `licenses` or `group <id>` run beside it
left a second magpie-bun host with PPID 1, holding the Chrome profiles
the gateway's host wanted ("Chrome exited before starting WebView").
Their analysis was right on each count:

- plugin.Cached starts a background list of the plugins' providers
  whenever this process hasn't listed them (provGood is in memory), so
  every short command reaching provider.Catalog (startUp's RenameLegacy,
  groups, models, ...) started a host.
- Main ended through os.Exit and never stopped it. A host whose stdin
  closes leaves only once nothing is pending, and a plugin holding a
  browser keeps Bun up meanwhile, so the host outlived magpie, adopted
  by init. SIGTERM (launchd stopping serve) orphaned serve's own host
  the same way.
- --version and licenses were answered after startUp.

Now:
- Cached asks the plugins in the background only when
  plugin.ListInBackground is on; run sets it from servesPages (app,
  web, serve, TUI). Other commands read the list on disk.
- Main ends through exit(), which runs plugin.EndHosts first, on
  success and error; die does too on SIGINT/SIGTERM/SIGHUP, bounded by
  hostsOnSignal (20s, past the 15s a renewing host gets).
- provider test returns exitError instead of os.Exit(1).
- -v/--version/version and licenses answer before any start-up work.

Audit of the os.Exit calls in internal/cli: data_cli.go:135 and the
CheckEnv exit in Main run before anything can start a host;
claudeLetGo already called EndHosts.

Tests (red on the old code, the non-test sources reverted to
14b6b9555, green with the fix):
- TestOneShotCommandsStartNoPluginHost: groups, group fakeco, models,
  providers, accounts each started a host (5 reds); version, --version,
  -v, licenses and agents start none; Cached in a serving magpie still
  lists.
- TestExitEndsPluginHosts: a real host whose stuck usage hook holds it
  up (new STUCK_USAGE_HOLD, STUCK_PID in testdata/stuck), the magpie
  ended by `version`, by an error and by SIGTERM: all three left the
  host at PPID 1 on the old code, none now. 10 of 10 on macOS, 3 of 3
  on Linux (WSL), version/error on Windows (no SIGTERM there).
- TestSessionCommandsSkipStartUp: version/--version/-v/licenses don't
  run startUp (red on the old code for version). Three tests that used
  `version` to reach startUp/makeDirs use `groups`.

Real use, sandbox HOME on mote, a plugin whose provider list takes 90s
holding a timer, signed in with a key, `magpie serve` running:
- old binary: groups, group holdco and models each left a magpie-bun
  at PPID 1; after SIGTERM to serve, serve's host was at PPID 1 too
  (4 left).
- new binary: only serve's host, and none left after SIGTERM. The
  commands take 0.02-0.15s.

Run at the pushed head:
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build: ok (mote).
- go test -count=1 -timeout 45m ./... on mote: 102 packages ok, two
  red, each red the same at the base 14b6b9555 (-count=3/5 there):
  internal/cli TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
  TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr and
  TestUpdateFindsAMagpieThatWroteNoRecord (#6471, #6223: an ssh
  session's forward holds 127.0.0.1:3425 on mote), and internal/gateway
  TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117).
- Rebased on 598bc4534 (it changes internal/cli's update code), at
  the pushed head: go test ./internal/cli ./internal/plugin on mote:
  plugin ok; cli ok but for the same three #6471 reds.

Not tried: the reporter's real Google AI Studio plugin with Chrome, and
a real LaunchAgent stop (launchctl); the repro sends serve SIGTERM as
launchd does.
2026-11-19 10:38:25 +08:00
yetone a18ed4995f memory: a memory of several lines keeps them, folded to its first line (_meouwu on X)
_meouwu on X: a memory added by hand in several lines showed as one line
with its breaks gone; it should keep its format and, folded, show the
first line and an ellipsis.

Cause: the store never lost the breaks. A memory file's body is
m.Text as written (encode/apply trim only the ends). They were lost
where it was shown: the Library row clamped the name to two lines with
white-space normal, the digest given to agents went through oneLine
(strings.Fields), and so did memory_search / memory_list in the memory
MCP.

Now:
- Library: a folded row and a suggestion show firstLine(text) (first
  line, " …" when more follow); an open row shows the whole text
  pre-wrap. The editor already kept "\n".
- Digest and memory MCP: memory.Indented keeps each line, the lines
  after the first indented two spaces so the memory stays one list
  item.
- Dream and distill listings stay one line on purpose: the model's
  reply is read line by line, and a user's memory is Fixed, never
  rewritten by them. Written in docs/subsystems/memory.md.

Memories saved before: their files already hold the breaks, so after
updating they show, edit and reach agents in their own lines. Nothing
to redo, no migration.

Run at 3fabaf8f2 (on origin/main b332ef7ef, the pushed head),
f6452d777 (on 1622484a8) and ee84e288a (on 54117164c), on the WSL VM magpie-desktop: mote and mica were over
their cores with other sessions' suites for ~2h.
- go vet -tags gtk3 ./... ok; gofmt -l clean.
- go test -tags gtk3 -count=1 -timeout 45m ./... at ee84e288a: 101 ok,
  2 FAIL, both red at origin/main 2416beed6 on the same VM:
  internal/gui TestClipboardReadBack (#7074, #7073), internal/usage
  TestRequestStateKeptAcrossACatalogFetchedAgain (#6572).
- Whole GUI suite (concurrency 8): 1355 of 29368 red in 221 files under
  load. Those 221 again at concurrency 3: 71 red; 66 of them red at
  base 54117164c too. Of the other 5, 3 pass alone;
  codex-auto-reset-settings (#6108) and copilot-ghe (#1949) are red at
  base alone too (2 of 3 and 3 of 3 rounds), commented there.
- After the rebase (f6452d777): internal/memory, internal/memdistill
  and -run "Memory|Budget|I18n" in gateway, gui, library ok. All 84
  library-*.test.cjs: 1920 of 1950 pass; each red file alone, beside
  1622484a8: commands-import, group-steady, mcp-copy-config,
  mcp-off-fold, open-again and all are red at base too (#7097; all 3 of
  3 at base); memory-suggest, mcp-json and bili pass alone.
- At 3fabaf8f2 (b332ef7ef brought flying_crp's digest header and
  memory_save note; conflicts were only both sides adding tests and
  doc text): go vet memory, gateway, memdistill; go test memory,
  memdistill, access, and -run "Memory|Budget|I18n|Digest" in gateway,
  gui, library ok; library-memory*.test.cjs 112 of 112.
- library-memory-lines.test.cjs: 5 langs x 980/420 x chromium/webkit.

Broken by hand (old code, new tests): TestMultiLineMemoryKeepsItsLines
red at the digest step only (save, edit and the file passed: the store
kept the breaks), TestIndented and TestMemorySearchKeepsTheLines red,
library-memory-lines red ("Release steps: …" expected).

Not tried: a macOS run (mote, mica busy), Windows, the real app.
2026-11-19 06:32:40 +08:00
yetone b332ef7efe memory: a project's own instruction files win over memory, and its rules go there (flying_crp on X)
flying_crp on X: with memory on, the digest in the agent's instructions
disagreed with the project's own rules, and things that belong in the
project were saved to memory instead, while the user keeps the
project's docs tidy themselves.

- The digest's header (internal/memory/digest.go) now puts the
  project's own instruction files (AGENTS.md and the like) and docs
  first: where a memory disagrees, the agent follows the files and
  says which memory is out of date. A project's rule or fact belongs in
  its files; memory keeps what holds for the user across projects.
- memory_save's description says the same, and a new save made in a
  project whose root holds AGENTS.md, CLAUDE.md, GEMINI.md,
  .github/copilot-instructions.md or .cursorrules ends with a note
  naming the files found: for a memory of the caller's project (any
  kind but profile and preference), to offer to write it there and
  forget the memory once it is; for a global rule or procedure, the
  same when it holds only in this project (projectFilesNote). The save
  itself is kept.
- Distillation's instructions leave a project's rules and conventions
  to its files, and drop what disagrees with them.
- The texts name neither magpie nor a vendor (checked in each test).
  The only filenames named are AGENTS.md "and the like" in the fixed
  text, and in the save note the files actually found on disk.
- docs/subsystems/memory.md says all three.

Tests, each red on the old code (the three source files put back to
origin/main by hand, tests kept), green with the change:
TestDigestDefersToTheProjectsFiles (internal/memory), TestWhatIsSent
(internal/memdistill), TestMemorySavePointsProjectRulesToItsFiles
(internal/gateway, -tags nogui).

Real agents, sandbox HOME and CLAUDE_CONFIG_DIR, model through the live
gateway as an endpoint only, nothing live written:
- Digest: a git project whose CLAUDE.md/AGENTS.md say "Python code here
  is indented with tabs", and a digest in the sandbox CLAUDE.md with a
  project memory "Indent Python code with 4 spaces". Asked to write
  add.py, with the old header Claude Code (haiku and sonnet) both used 4
  spaces, following memory; with the new header both used a tab and
  said the memory was out of date.
- Save: a sandbox `magpie serve` built from this tree on 127.0.0.1:3471,
  Claude Code (sonnet) with its memory server over --mcp-config, asked
  to "remember for this project: tests always run with pytest -x". The
  save came back with the note naming AGENTS.md, CLAUDE.md, and the agent
  offered to add the rule to them and then delete the memory.

Full suite (`go test -timeout 45m ./...`, mica):
- at a9696f14d: mica's disk filled during the run; reds in 17 packages
  were "no space left on device". Not counted.
- at 8647ac995 (origin/main + this): 101 ok, 3 red, each filed and not
  in code this change touches: internal/dirent watch tests (#7031),
  internal/gateway TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes
  (#7117), internal/gui TestGatewayModeListsNoOwnSessions (#7064).
- at d67beb049 (this commit's tree, on origin/main 67405d560): 101 ok,
  the same 3 filed reds (#7031, #7117, #7064), nothing else.
GOOS=linux and GOOS=windows go vet of memory, memdistill and gateway:
ok. gofmt -l: clean. No GUI or i18n change, so no GUI suite run.

Not tried: Codex or other agents (Claude Code only); a memory server
reached from another computer (the note stats the project roots that
computer named, on this one: at worst an advisory note).
2026-11-19 03:27:25 +08:00
yetone 06428541ac agent: Dim's Magpie provider names each model with its provider, so two vendors' DeepSeek are told apart (T_t__biu on X)
T_t__biu on X: in Dim alpha, models of its built-in Magpie provider
can't be told apart by the magpie provider behind them; two vendors'
DeepSeek read the same.

Cause: Dim names a listed model by the display_name (or displayName,
name) of the endpoint's /v1/models (crates/dim-app-server
provider/remote.rs), shown in its Models page, `dima models` and the
picker's search. magpie's /v1/models gives display_name the name alone
(PlainName) to every client but Cindy and Claude Code's discovery.

- /v1/models asked with Dim's key gives display_name the name the
  agents' lists give the model (provider.LabelsFor("dim"): its
  provider's after it, as the Provider in model names setting says),
  as Cindy's already is.
- Dim takes names only when it lists the models again
  (provider.refresh). dim.json now keeps dimListed (a hash of the ids
  and names) of the last listing, and Sync, while Dim's daemon runs,
  lists the provider again when it changed: a provider renamed or
  added, the setting changed, and a Dim connected by v0.1.4497, which
  kept none, on its first Sync.
- A name the user gave a model in Dim (provider.models.edit) is a
  descriptor override, which Dim's refresh keeps. No other provider of
  Dim's is touched; disconnect is as before.

Run at this commit's tree (rebased on origin/main c4bae0724):
- Red on the old gateway.go/dim.go (a Listed field stubbed in):
  TestCindyDiscoveryNamesModelsApart/dim (Dim told "GLM-5.3-Flash"
  for all three providers) and TestDimListsAgainWhenNamesChange (no
  refresh on Sync). Green on the new code.
- Real Dim 0.1.0-alpha.24 (npm dimcode-alpha) in a sandbox HOME on
  mote, a sandbox `magpie serve` on 38741 with two custom providers
  (SiliconFlow, DeepSeek Official) each serving deepseek-v3: after
  `magpie dim sf/deepseek-v3`, `dima models magpie` and the daemon's
  provider.management list "DeepSeek V3 · SiliconFlow" and "DeepSeek
  V3 · DeepSeek Official". After renaming ds/deepseek-v3 to "My DS"
  in Dim (provider.models.edit) and `magpie provider set sf
  name="SiliconFlow CN"`, Dim lists "DeepSeek-V3 · SiliconFlow CN" and
  "My DS" (listed hash moved). `magpie dim default` turned the provider
  off, key cleared, 3425/v1.
- At 4938d8527 (on origin/main c4bae0724): gofmt -l clean; go vet -tags nogui
  internal/agent and internal/gateway, GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./... ok (mote). go test -count=1 -timeout 45m:
  internal/agent ok (265.9s, mote); internal/gateway (mica) ok except
  TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes, red on origin/main and
  filed and taken as #7117 (OpenCode Go/Zen, not Dim). The full ./... suite
  was not run.
- Rebased onto 4e24994a6 (gateway Memory access): gofmt, vet (darwin,
  linux, windows) of both packages and -run 'TestDim|TestCindyDiscovery|
  TestListModels|Memory' ok again at 65cd98fca's tree (mica).

Not tried: Dim's desktop app (CLI and daemon only); Windows and Linux
with a real Dim (the change is in the gateway's list and a refresh call
the Windows pipe already carries); upgrading a real v0.1.4497 connect
(the unit test clears the listing to stand for one).

Not changed: a model the gateway knows no limits of, which magpie gives
them at its pick (provider.models.edit), holds a Dim descriptor
override with the whole entry, its name as listed then (Dim's
merge_visible_edit); a later rename doesn't reach that one model until
it is reset in Dim. One picked under v0.1.4497 keeps its plain name so.
2026-11-19 02:47:38 +08:00
yetone 4e24994a6e gateway: a key let use Magpie Memory reaches it from another computer
Niapyaya on X reaches their own MCP servers through the MCP hub from a
remote machine, but not magpie-memory: memory answered the agents on
this computer alone, on /mcp/magpie/memory (547585cd9) and in the hub
(HereOnly), whatever key came. That was on purpose: a friend's key
could read every memory or plant a global rule the digest writes into
every agent's instructions here.

So it stays off for every key, and the user can let one key of their
own use it:

- access.Key.Memory, set by "memory-key" (`magpie gateway-key memory
  <id> on|off`, or the key's ... > Advanced > Magpie Memory). As Admin,
  only a key the user made can have it (memoryOf): never the sharing
  key, a read-only or Browser key, nor an issued or expiring one.
  Read-only takes it away; the management API can't set it.
- memoryMCP lets a caller from elsewhere in only while magpie is
  shared, by such a key, and never from a page by hubFromPage (Origin,
  Sec-Fetch-Site, a Mozilla/ agent; Node's fetch sends Sec-Fetch-Mode,
  #5522). This computer's check is unchanged.
- The hub gives magpie-memory (HubServer.Memory, from isMemory) to an
  Away visitor only by such a key (HubVisitor.Memory), listed and run,
  in the gateway and again in the library's Call.
- Advanced in the key's menu now opens Management API and Magpie
  Memory, each its own pick; a key with it says so in its row. Strings
  in zh, zh-TW, ja, de. Docs: memory.md, mcp-router.md, and the site's
  remote page (en, zh, ja) with its index rebuilt.

Image already answers a key directly (/mcp/magpie/image, held to the
key); sessions stays this computer's. There is no skills MCP server.

Tests: TestMemoryMCPToAKeyGivenIt, TestHubGivesMemoryToAKeyLetUseIt,
TestMemoryKey, the hubServerOf Memory column, and gateway-key-admin's
GUI file now goes through Advanced > Management API and covers Memory.

Run (mote unless said; base d01e0a465, rebased onto c4bae0724, which
only touches the Settings keep guard):
- Red on the old code (mica): TestMemoryMCPToAKeyGivenIt (403 to the
  key) and TestHubGivesMemoryToAKeyLetUseIt (hub listed [docs] only).
- go test -count=1 -timeout 45m ./internal/access ./internal/gateway
  ./internal/library ./internal/cli ./internal/gui: access, library ok.
  Reds, each the same at a clean origin/main c4bae0724 and filed:
  gateway TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117) and
  the doneHold panic log (#6505); cli TestHealthcheck…/TestUpdate…
  WithoutMagpieAddr, TestUpdateFindsAMagpieThatWroteNoRecord (#6471,
  #6223); gui TestSettingsSaveKeepsWhatItDoesNotSend (fixed by
  c4bae0724).
- GUI, both engines, every language, at this head: 64 files (every
  caller-keys / gateway-plugin file and i18n-*): 1008 of 1024 pass;
  api-key-theme (#6444) and connect-address-kept (#6755) fail the same
  at clean origin/main c4bae0724.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... ok; builds for all three OSes ok.
- Broken by hand: drop !hubFromPage -> the Sec-Fetch-Site case gets 200,
  red; drop the key's Memory check -> another key gets 200, red. Drop
  sharedWith -> still green: serveMCP's share guard refuses first, so
  memoryReaches' check is a second line, not the only one.

Not tried: a real remote agent against a real shared magpie (tests use
httptest with 192.0.2.7 as the remote address); the full suite runs
after the push.
2026-11-19 02:31:18 +08:00
yetone d01e0a465a agent: Dim's built-in Magpie provider is filled in, so a plain dima runs on magpie (T_t__biu on X)
T_t__biu on X: Dim alpha has a provider named Magpie built in, and
magpie's one-click connect left it empty, relying on DIM_* variables a
shell function set for each run. Dim launched any other way (its app, a
terminal opened before, an IDE) was not on magpie.

Dim keeps providers in a database only its daemon writes, so magpie now
talks to the daemon the way Dim's own clients do (JSON-RPC 2.0 after a
hello of protocol 4, on <home>/rust/daemon.sock, or on Windows through
Dim's pipe bridge `dimcode-server app-server --connect-pipe`; read from
Dim's crates/dim-app-server and dim-client source). Picking a magpie
model:
- writes the gateway's /v1 (the port magpie is on), magpie's key and
  enabled onto the `magpie` provider only, each against the record's
  version (provider.update);
- refreshes it, gives a model its token limits when the gateway doesn't
  know them (provider.models.edit), and makes it Dim's pick
  (provider.select against the pick's version);
- records first, in magpie's own dim.json (temp+rename), what was there
  and the pick to give back.
A key or address the user set on that entry themselves is kept: magpie
writes nothing to the provider and only picks the model. Sync writes the
port and key again when they change. Disconnect (`magpie dim default`
or the switch) turns the entry off with the key cleared (Dim clears a
key only on a provider turned off), puts the address back, and puts
back the model Dim was on. No other provider is read or written. The
per-run env and shell function stay only as the fallback when Dim's
daemon can't be reached or started.

Run at this commit's tree (on origin/main d048939da, then rebased over
3 commits that touch neither internal/agent nor the docs here):
- go test -run TestDim ./internal/agent on mica: 8 ok. Red on the old
  dim.go (with a stub for the new test helpers): FillsItsMagpieProvider
  (key empty), MagpieProviderPort, MagpieProviderUsersOwn/key (not
  picked), SyncMovesToProvider.
- Real Dim 0.1.0-alpha.24 (npm dimcode-alpha) in a sandbox HOME on
  mote, with a sandbox `magpie serve` on 38725 and a fake upstream:
  the user's own deepseek provider set and picked first. `magpie dim
  up/m1` left deepseek at v3 untouched, set magpie to on, 38725/v1, a
  key, and picked magpie/up/m1; a plain `dima exec -p` with no DIM_*
  set answered PONG-FROM-UPSTREAM through the gateway. `magpie dim
  default` turned magpie off, no key, 3425/v1, pick back to
  deepseek/fake/known. With a key and address set on the Magpie entry
  by hand first, connect wrote nothing to it (wrote:false) and only
  picked; disconnect gave the pick back and left the entry as set.
- Windows (xiaomi-gpu, real Dim alpha.24 in a sandbox DIMCODE_HOME):
  dimConnect through the pipe bridge did the hello and read the magpie
  provider and selection (a throwaway probe test, not committed).
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... on mote: clean.
- go test -tags nogui -count=1 -timeout 45m ./... on mote (suite.lock):
  every package ok (internal/agent 372 s) except 6 reds, each red the
  same on a clean origin/main d048939da copy and already filed:
  internal/cli TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
  TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr,
  TestUpdateFindsAMagpieThatWroteNoRecord (#6223); internal/gateway
  TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117),
  TestLaneLimitRoutes (#5150); internal/gui
  TestSettingsSaveKeepsWhatItDoesNotSend (#7127).

Not tried: a full connect/disconnect on Windows or Linux with a real
magpie serve (only the Windows pipe read); Dim's desktop app (the CLI
and daemon only); a UNC or symlinked DIMCODE_HOME on Windows.
2026-11-19 01:38:23 +08:00
yetone de58a3879b sessions: a cold read packs idle Claude sessions' calls into one file
shangyuan0818 on X: on Windows, Usage -> Sessions took 18 to 25 s with
long Claude Code sessions. The cause: a cold read wrote a calls-v15 .gob
shard and a .rev for every Claude session, about 21k files for 12k
sessions, and Windows Defender scans each file as it is closed.

Sessions not changed within the hour are now written into one
calls-v15/*.pack per pass (MPCALLS1 magic, the frames, a gob index of
path/offset/count, length, CRC32, magic). It is written to a temp file
and renamed, and flushed at the end of a pass, at checkpoints, in Saved
and every 32 MB. A session's own shard is read before the pack, so a
session that grows gets its own shard and its lines are appended there
as before. A bad pack means the source is read again. The hourly prune
sweeps packs no session points at. Working sessions keep a shard and a
.rev as before.

Measured on xiaomi-gpu (Windows 11, Defender on), fixture of 12,016
Claude session files, no magpie cache, first /api/sessions reply, the
runs alternating old and new:
  origin/main build: 31.67 s, 25.26 s, 20.74 s
  this change:        5.92 s,  5.85 s,  5.65 s
  restart with the pack written: 1.97 s and 2.16 s; then 0.25 to 0.31 s.
  The cache held 1 .pack and 4 .gob.

Tests (call_pack_test.go): TestColdSessionsReadWritesOnePack,
TestPackedCallsServeRequests, TestPackedSessionGrows. With the pack
branch turned off by hand the first fails (.gob:63 .rev:62) and the
second finds 0 packs.

Run at 4ace48feb (this change on origin/main 2ab2f6913):
- gofmt -l: clean.
- go test ./... -timeout 45m -count=1 on mote: 101 packages ok
  (internal/sessions 154 s), 3 red, none in code this touches, each
  filed: internal/cli TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
  TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr and
  TestUpdateFindsAMagpieThatWroteNoRecord (#6223: another session's ssh
  forward listened on mote's 127.0.0.1:3425); internal/gateway
  TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117) and
  TestLaneLimitRoutes (#5150); internal/gui
  TestAppReplacesItsOlderGatewayOnceIdle (#6297) and
  TestSettingsSaveKeepsWhatItDoesNotSend (#7127, red since f6a538ece).
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./..., go build, GOOS=linux go build -tags nogui, GOOS=windows go
  build: clean.
- internal/gui/tests/sessions-*.test.cjs (46 files): 322 of 322 in
  chromium, 322 of 322 in webkit.
- wsl-run go test ./internal/sessions: ok (25.3 s), at the base before
  the rebase.
- win-run go test ./internal/sessions: 4 reds, the same on origin/main
  07d19510f and filed as #6071 (TestAgySessions, TestAgyRowOnly,
  TestAntigravityAppFolder, TestCCListingKeepsItsNames). go vet clean.

Rebased onto fcbc1a2d0 (three gateway commits, none in
internal/sessions or its doc). At the pushed head: go test
./internal/sessions ok (209 s); go vet of it on darwin, linux (nogui)
and windows clean; go build clean.

Not tried: a real user's profile; the timings use a generated fixture
the size of the report.
2026-11-19 01:22:40 +08:00
yetone fcbc1a2d02 gateway: Claude Code's deferred tools are declared in full where a load would lose the cache
Seapawn1 on X: GPT in Claude Code loses its prompt cache with tool search
on. A tool ToolSearch loads joined the top-level tools on the next request
on every route but Anthropic's and a Responses upstream that loads in
place (LoadedInPlace, #2660). An OpenAI-style cache is a prefix with the
tools before the messages, so each load (2.1.327 defers WebFetch,
WebSearch, Monitor and the other built-ins too) read the whole
conversation again uncached. A sandboxed Claude Code 2.1.327 through a
fake upstream showed it: on Chat and on a Responses relay the tools
changed at req1 and req3; in place they held.

On such a route a Claude Code request carrying DeferredToolPlaceholder is
answered 400 invalid_request_error naming tools.defer_loading, locally.
The real Claude Code 2.1.327 answers that (after its beta-strip retries,
3 refused requests) by declaring every tool in full for the rest of that
conversation, --continue included; a new conversation, on a Claude model,
tries tool search again. The message doesn't name the beta header, which
Claude Code would remember everywhere. Only while the reminder names 50
deferred tools or fewer: an MCP router's hundreds keep tool search, and a
request whose reminder can't be read keeps it too. Anthropic routes and
in-place Responses upstreams are unchanged. The refusal is not a member's
fault (retryable/shapeRefused false), so a group doesn't fall over or
rest.

Not handled: a user who set ENABLE_TOOL_SEARCH themselves can't be told
apart on the wire; additional-tools=on keeps search on a relay that takes
the item.

Run:
- mica: go test -run 'TestDeferred|TestLoadedTools|TestKimiIsSent|TestToolSearch|TestDeferredToolBlocks' ./internal/gateway ok.
- Broken by hand (the check in translate made false): TestDeferredToolsTurnedAwayWhereTheyLoseTheCache and TestDeferredToolsKeptWhereLoadedInPlace red (status 200, upstream called).
- mica: GOOS=linux and GOOS=windows go vet ./internal/gateway ./internal/agent ok; gofmt -l clean.
- wsl-run (magpie-desktop): go test -timeout 45m ./internal/gateway ./internal/agent started before push; result with the full suite.
- Real Claude Code 2.1.327 in a sandbox HOME against a fake 400 naming defer_loading: retried with every tool declared, kept for the conversation and --continue, new conversation searched again.

Full suite: run after push.
2026-11-19 01:13:33 +08:00
yetone 91e8146727 gateway: words written after a call go before it, so DeepSeek takes the call as answered
wizcheu on X (Claude Code 2.1.327, deepseek-flash at max effort on
DeepSeek's own API) still saw "400 due to tool use concurrency issues"
after v0.1.4478: "DeepSeek: messages.422.2: `tool_use` ids were found
without `tool_result` blocks immediately after:
call_00_wIys8uRO8314ixexw3r35173", and earlier messages.71.2.

The block index is the clue. Checked against api.deepseek.com/anthropic
today: an assistant message with a text block after a tool_use is
refused with messages.N.K, K the text block, even when the next message
answers the call ([T, tu, X] -> messages.1.2; [X, tu, T, X] ->
messages.1.3; [tu, X, tu] -> .2; an empty text after the call too),
while [T, tu, T, tu] and [T, X, tu] pass. A system message between a
call and its result (d74754970) gives messages.N with no block index,
so the reported .2 was this other shape all along.

toolBlocksPaired (passthrough and count_tokens) now moves the blocks an
assistant message wrote after its first call to before that call
(callsLast), thinking kept where it was and empty text dropped; a
message without that shape keeps its bytes. pairToolBlocks does the same
for a translated build (blocksCallsLast): a Responses turn's message
item after its function_call. Applied for every Messages upstream:
Claude writes no words after a call, and the order of the words relative
to the call is the only thing that changes.

Run (mote, at this tree on origin/main 2ab2f6913):
- go test ./internal/gateway -run 'TestWordsAfterACallGoBeforeIt|
  TestCallsLast|TestSystemMessage|TestChatSystemMessage|Pair' ok;
  -run 'Tool|Pair|Anthropic|Steer|Thinking|Messages' ok (91s)
- GOOS=linux go vet -tags nogui and GOOS=windows go vet of the package
  ok; gofmt -l clean
Broken by hand: with both source files at origin/main, all four
TestWordsAfterACallGoBeforeIt cases are red with the reporter's message
(messages.1.2 / 1.3) and TestCallsLast red; with only pairToolBlocks'
reorder taken out, TestCallsLast is red on the built message.
Live: api.deepseek.com/anthropic, deepseek-flash: the old shapes 400,
the mended ones ([T, X, tu], [X, X, tu, T]) 200.
Not tried: wizcheu's own conversation (the trailing text's source isn't
confirmed; four live max-effort replies gave [thinking, tool_use] only),
the full suite (to follow), a Claude relay with [tu, X] (the openrouter,
yylx and aihubmix keys have no balance).
2026-11-19 00:57:11 +08:00
yetone 2ab2f69132 agent: Codex's status line shows the account's quota or the relay's balance (opt-in)
lyj1115 on X asked for the current account's quota, or the relay key's
balance, under Codex's chat box, off by default. Codex's TUI draws its
footer from a status line provider from 0.171.0-alpha.12 on: a stdio
MCP server whose tool advertises a statusline entrypoint, picked in
[tui] status_line_provider behind [features] tui_extensions_statusline.
Codex reads it about once a second with the thread's id. Nothing is put
into the prompt or the model's reply.

- `magpie statusline --codex` is that server. Each read asks the local
  gateway for the thread's latest route and the kept quotas (no vendor
  read). It answers `→ provider/model` and that provider's account that
  answered last, with its windows or a key's balance. A gateway that is
  down gives a null tree, never an error, because an error stops Codex's
  reads. The tool's name and words name neither magpie nor a vendor,
  since the tool is listed to the model.
- A status line square on Codex's row (`magpie codex statusline on`)
  writes the flag, [mcp_servers.quota_line] (this magpie by full path,
  args statusline --codex, env_vars = ["MAGPIE_ADDR"]) and the
  provider. Every write is read back, and the file is restored on a
  mismatch. Off and Disconnect take out only magpie's keys, and the flag
  only when the stash says magpie wrote it.
- Nothing of the user's is written over. A provider of their own, a
  quota_line of theirs, the flag turned off or an unreadable file keeps
  the square away and refuses on.
- The switch is offered only when a Codex CLI here is 0.171.0-alpha.12
  or newer (0.170.0 reads the keys and draws nothing), and only on this
  computer, not in a WSL distro.
- In the GUI, the status line square's title takes the note of its
  field's on option, which Claude Code's field already sent with the
  same words TOGGLES kept, so Codex's says its own words in en, zh,
  zh-TW, ja and de. TOGGLES' copy of Claude's note went, and app.js
  stays under its budget (30 bytes of room) without a raise.

The Codex desktop app has no such footer. cockpit-tools reaches it
through a debug port, and magpie doesn't.

Run (WSL magpie-desktop, since mote's load was over 18):
- go vet -tags nogui ./...; GOOS=windows go vet of agent, cli, provider
  and gui; gofmt -l clean.
- go test -tags nogui of ./internal/cli and ./internal/provider: ok.
- ./internal/agent -run "CodexStatus|Statusline|StatusLine|TestCodex|
  TestWSLCodex": ok.
- ./internal/gui -run "CoreScript|Budget|I18n|Keys" and node --test of
  codex-statusline, claude-statusline and i18n-keys (both engines, every
  language, window and panel), with vet (and GOOS=linux and windows
  vet) of agent, cli, provider and gui, on mote at the rebased head
  (on 1bd1a08a3): all ok, 64 of 64 GUI cases.

Broken by hand:
- free() reduced to `readable`: TestCodexStatusLineLeavesTheUsers is red
  on their provider, their server and flag off.
- The field not appended: TestCodexStatusLineSwitch is red ("no
  statusline field").
- The first build checked `at.base == nil` after codexIn had set base.
  Every agent test went red, which is how that bug was found.

Real Codex, in a sandbox HOME on WSL with a fake gateway:
- 0.171.0-alpha.13, with `magpie codex statusline on` writing config.toml,
  draws `→ relay/glm-5  relay $4.20` under the prompt, and the server is
  read about once a second.
- Without env_vars, Codex starts the server without MAGPIE_ADDR: nothing
  was asked and nothing was drawn. That is why env_vars is written.
- On a second time leaves the file byte for byte. Off brings it back to
  what it was, apart from Codex's own NUX counter.
- 0.170.0 lists quota_line from the same file and runs fine.

Not tried: macOS and Windows Codex; a real gateway with real accounts
(the server was fed through MAGPIE_ADDR); whether an open Codex session
picks the footer up without a restart.

Full suite: run after push.
2026-11-19 00:44:40 +08:00
yetone f6a538ece9 images: a resolution tier, 1K, 2K or 4K, in Settings and the image MCP (skingstyle48487 on X)
Asking the image MCP for 4K through a relay came back at 2K: nothing
told the model how large to draw. Settings › Models › Images now has
Image resolution (Automatic, 1K, 2K, 4K; an app menu, saved as
imageResolution), and generate_image takes a resolution argument. The
agent's own resolution or WIDTHxHEIGHT size wins over the setting.

The images API takes `resolution` (or a tier given as size, "4K"), and
each vendor gets it in its own field:
- Gemini: imageConfig.imageSize (3.x image models; 2.x draws at 1K);
- chat image models (Gemini's): image_config.image_size;
- OpenRouter /images: resolution;
- Grok Imagine: resolution 1k or 2k (its largest);
- Seedream (Ark): the size tier the model has, or its pixels for a ratio;
- MiniMax H3: area;
- GPT Image 2 and other WxH images APIs: pixels at the ratio, within
  GPT Image 2's limits (edge 3840, 655,360 to 8,294,400 pixels, /16);
- gpt-image-1, DALL·E and SenseNova keep their own sizes.
A vendor that answers 400 or 422 to a tier is asked once more without
it. An unknown resolution is a 400. Both MCPs now say what size each
image came back at, and when that is under the tier asked.

The row is drawn by videogen.js, after Video generation's, so app.js
keeps its budget (it was at 1,088,641 to the byte); the server keeps
imageResolution when a save doesn't send it (TestSettingsImageResolution),
so prefsKeep doesn't carry it. The menu has no notes: "The model's own"
was a plugin's key already.

Run (magpie-desktop WSL on xiaomi-gpu; mote was over load 18 all day):
- gofmt -l: clean; go vet -tags nogui ./... and GOOS=windows go vet
  ./...: ok.
- go test ./internal/gateway -count=1 (1995s), ./internal/imagemcp,
  ./internal/settings, ./internal/settingsapi: ok; at this head go vet
  -tags nogui of gui, gateway and settingsapi, and gateway -run
  "Tier|ImagesAPIResolution|ImageMCP|Draw|Image", settingsapi and
  imagemcp: ok.
- New: draw_tier_test.go (each protocol's field, a fake upstream for
  the images API and the image MCP, the 400 retry, the precedence).
- At this head (on 88b65d758): go test -tags nogui ./internal/gui -run
  "Budget|I18n|SettingsImage": ok; node --test i18n-keys,
  image-resolution (22 of 22: chromium and webkit, en zh zh-TW ja de,
  1100 and 420 wide), video-gen-pick and old-webkit: 62 of 64. The 2 reds are
  old-webkit's "compat.js is the first..." (guideback.js) and "the
  styles hold up in Safari 15.0" (app.css :has()), the same on a clean
  copy of origin/main 88b65d758: #6570.
- Broken by hand: imagesAPISize returning the size as given, the retry
  off, chat image_size and OpenRouter resolution dropped, the image MCP
  ignoring the setting, the server's keep of imageResolution removed,
  a zh string removed: each turned its test red.

Not run yet: the full go test ./... and the whole GUI suite (WSL's one
suite slot was taken by another session); they run after this push.
Not tried against a real vendor.
2026-11-19 00:27:58 +08:00
yetone 88b65d7584 library: the skills sheet says why an agent gets copies (4kT1FohCTP97031 on X)
The report (X, tweet 2123056163587780891): "Claude Code can only copy
skills, never link them; every other agent can use paths." Claude Code
already takes links: real claude 2.1.327 in a sandbox HOME and
CLAUDE_CONFIG_DIR loads a symlinked skill folder and a symlinked
SKILL.md, and reads the files beside it. The row that said 只能用副本
with no reason and no switch was Claude Desktop's (Cowork), which
really does skip a linked skill (Claude Desktop 2.7032; see
desktop_skills.go), so it keeps copies.

- AgentView gains CopyWhy and CopyWith (copyWhy in skill_how.go):
  desktop, liveagent, wsl (a WSL agent on a Windows drive), junction
  (agy/antigravity/crush on Windows), and shared, for an agent that reads
  the same folder as one given copies. A shared agent was shown as
  "Gets links" while syncSkills gave it copies (l.copies with sharers);
  its How is now copy and the row names whose copies they are.
- The How sheet's row says the reason ("Only ever takes copies: Cowork
  skips a linked skill"), in en, zh, zh-TW, ja and de. Without a known
  reason it still says "Only ever takes copies".
- docs/subsystems/library.md says so.

Not changed: agy/crush on Windows take copies even where a symlink
could be made (#5107, #6610 decided that); not part of this report.

Tests:
- TestSkillHowSaysWhyCopies: Claude Code link, Claude Desktop
  desktop, Codex reading Claude Code's folder as copies -> Claude Code
  how copy, shared, ["Codex"], a copy on disk, and links again after.
  Red on the old behaviour (fields kept, copyWhy and the How override
  dropped): "Claude Desktop: why """ and "Claude Code: how "link"".
- skill-how.test.cjs: the desktop row's reason, a shared row, a bare
  must-copy row, and a new all-languages test (en zh zh-TW ja de) at a
  phone width. Red on origin/main's plugins/library client.js and
  i18n.js in every language (expected the reason, got the bare words).

Run:
- gofmt -l clean. go vet internal/library and (-tags nogui)
  internal/gui on Linux, GOOS=windows, GOOS=darwin (wsl-run): ok.
- go test ./internal/library -count=1 at this head (rebased on
  origin/main 1e2287758, on mote): ok.
  go test -tags nogui -run 'Budget|I18n|Doc' ./internal/gui: ok.
- GUI at this head on mote, chromium and webkit: library-wsl-asleep +
  skill-how 53/53 each. On magpie-desktop at load ~78 (another session's
  full suite and GUI suite) many files timed out together; skill-how and
  skill-name-many-agents alone there: 15/15.
- Before the rebase on magpie-desktop, both engines: skill-how,
  library-wsl-asleep, i18n-keys, i18n-en-no-cjk, library-desktop-skills,
  library-desktop-twin, skill-router, library-items pass. click-scroll,
  library-all and skill-where (webkit) red, and the same red on a clean
  origin/main 454f9d023 alone: #4385, #4967, #5154 (commented).

Not run before the push: the full go test ./... and the whole GUI
suite (the coordinator asked to ship on the targeted runs); they run
after on a free machine.
2026-11-19 00:13:47 +08:00
yetone 68f6385155 library: a skill the router lists stays a $name of Codex's, a /skill:name of Pi's and a /name of Droid's
yuushabu_buyinn on X: with the skill router on, / in the agent no
longer picks a skill. afabb7f90 gave Claude Code a command per listed
skill; Codex, Pi and Droid still had nothing to type, since a listed
skill has no entry of its own in their skills folders.

For each skill the router lists there, placeStubs links <skills>/<name>
to a stub in routerDir+"-slash": a SKILL.md with the skill's name,
description and argument-hint, disable-model-invocation: true, and a
body that sends the agent to the skill's SKILL.md at the router's path;
agents/openai.yaml sets Codex's policy.allow_implicit_invocation false.
Each agent's loader was read for both halves, a picker entry and none
in the model's prompt: Codex 0.165 (allow_implicit_invocation), Pi 1.4.0
(formatSkillsForPrompt), Droid 0.231 (the model's list filters
disableModelInvocation, the slash list only userInvocable). slashFor
gives none where another agent reads the folder and neither flag (Alma
reads Codex's, as Crush reads Claude Code's: that is why Claude Code's
are commands), and none for user-invocable: false. dropStubs takes them
out before the links are written, so router off or kept direct puts the
skill's link where its stub was. routerOurs knows a stub, so it is never
"found" as an agent's own skill. Gemini CLI, OpenCode, Alma, Crush and
the rest have no such flag and get no stub; a skill typed there is kept
direct (doc says so).

Run at this tree:
- Full go test -tags nogui ./... not yet at this head: it is queued
  on magpie-desktop after the push. At the earlier base 2957d16e5 on
  mica it was ok but for internal/dirent's watch tests (#7031, red
  alone too under mica's load) and TestWSLKimiCode (#7054, ok 5 of 5
  alone), neither of them reaching internal/library.
- mica, at this tree (rebased over 454f9d023's internal/library
  change): go test -tags nogui ./internal/library -count=1 ok;
  GOOS=linux, GOOS=windows and darwin go vet ./internal/library ok.
- magpie-desktop (WSL2 Ubuntu 24.04 on xiaomi-gpu), one base before:
  go test -tags
  nogui ./internal/library -count=1 ok; GOOS=linux and GOOS=windows
  go vet -tags nogui ./... ok; gofmt -l clean; node --test
  internal/gui/tests/skill-router.test.cjs 22 pass, 0 fail (chromium
  and webkit).
- mica, at the base before: the same GUI file 22 pass;
  GOOS=linux/windows go vet ./internal/library ok.
- Broken by hand, on mica: slashAgent false for all (the old behaviour) turns
  TestSkillRouterSlash ("codex: no stub of pdf to type it by") and
  TestSkillRouterSlashNotWhereAlmaReads red; dropping the readers check
  turns the Alma test red ("with Alma reading Codex's folder, codex has
  a stub of pdf").
- Real Codex 0.165.0 on this Mac (macOS 26), in a sandbox HOME, magpie's library built from
  this tree with two skills for claude and codex and the router on:
  the old tree's "$pdf" says "no matches"; this tree lists
  "pdf-reader [Skill] Read and summarise PDF files." and "$magpie"
  still lists the router. Claude Code's folder there has magpie-skills
  alone, with afabb7f90's commands beside it.
- Real Claude Code 2.1.325 on this Mac, in a sandbox HOME with an earlier cut that
  also stubbed Claude Code's skills folder: "/pdf" listed /pdf-reader,
  it read the skill's SKILL.md and answered its codeword, and the
  model's Skill list named magpie-skills alone. That cut was dropped
  for afabb7f90's commands (Crush, DevEco Code and Kimi Code read that
  folder), so Claude Code's skills folder gets no stub.

Not tried: a real Pi or Droid (neither installed here; their loaders
were read in Pi 1.4.0's dist and Droid 0.231's binary); a real Codex
turn checking the stub's description stays out of the request; a real
agent on Windows or Linux (the paths are filepath.Join and dirLink, as
the router's); the full suite on macOS (mote overloaded, mica's disk
full).
No GUI change, so no GUI run beyond skill-router.test.cjs.
2026-11-18 23:46:29 +08:00
yetone cb96fcc3a0 claude: a gated model goes to the account whose Claude Code offers it (ZacharyZhang on X)
With several Claude accounts and only one with Claude Mythos 5.2, the
model was asked of the first account, which answered Anthropic's 404
"There's an issue with the selected model (claude-mythos-5-2). It may
not exist or you may not have access to it." That 404 wasn't read as
the model's, so the account rested for every model, with a backoff
that grew, and was asked Mythos again each time the rest ended.

- claudeLists: Claude Code names only the gated models an account has
  (additionalModelOptionsCache), never the ones it lacks. A model
  models.dev doesn't list that another account's Claude Code offers is
  now out of an account whose own file doesn't offer it. AccountsFor
  then tries it only after the accounts that have it. A model no
  account offers, nor models.dev lists, is still taken to be in, so an
  account is never left out when nothing is known.
- ModelUnserved: Claude Code's "may not exist or you may not have
  access" and the API's not_found_error "model: …" rest only that
  model on that account (restID). Its other models stay on it.

Run on mote at 3438b7bd9 plus this change (rebased since on cd25b3735,
which touches internal/update only):
- go test -run 'TestClaudeGatedModel|TestClaudeModelNoAccess|
  TestAnthropicModelNoAccess|TestClaudeMadeFirst|TestEscapedWords|
  TestClaude.*Account|TestPool' ./internal/gateway: ok
- go test -run 'Claude|Unserved|ModelOnly|Plugin401' ./internal/provider: ok
- GOOS=linux and GOOS=windows go vet of both packages: ok; gofmt -l clean.

Broken by hand:
- With the old claude_code_models.go, TestClaudeGatedModelGoesToTheAccountThatHasIt
  is red: "A ... was asked it 1 times".
- With the old ModelUnserved, TestClaudeModelNoAccessRestsTheModelOnly
  is red: Sonnet went to B. TestAnthropicModelNoAccessIsTheModels is
  red for both bodies.

The first try read an account with a Claude Code file as lacking every
model when models.dev's list was empty. TestClaudeMadeFirstSpentGoesToTheOther
caught it, and it is fixed before this commit.

The fixture bytes are Claude Code's real 404 lines for a model the
account can't call.

Not tried: a real account with Mythos 5.2 beside one without it. There
is no such pair here.

Full suite: run after push.
2026-11-18 23:39:19 +08:00
yetone 3438b7bd9c codex: a kept ChatGPT account that runs out is taken over on magpie's models, so the Codex app sends them (Yuzhou__Zhang on X)
Yuzhou__Zhang on X, after updating from Stable (v0.1.3960) to v0.1.4477:
once the ChatGPT account ran out, the Codex app (ChatGPT app) sent
nothing, on "Claude Opus 5.5 · routing group" too, whose Claude accounts
had room. The screenshot shows the app's own banner, "Codex 和工作使用额度
已用完 … 11月20日 16:25 重置", and Send greyed: no request reached magpie.

Cause. The Codex app greys Send for every model while its authMethod is
chatgpt and the account's rate limit says not allowed. magpie gets past
that by becoming Codex's provider while the account is held (codex.out,
#540). a5e3972a7 (v0.1.4224, davezfr on X) left the account the user
keeps Codex on (Switch account automatically off: KeepLogin, or a pick in
the account menu, KeepLoginAs) out of the takeover on every model, so the
app showed the account rather than "magpie". On a model of magpie's that
meant a grey Send till the account's reset, the takeover's whole purpose
undone. Keeping the sign-in says which account; whether magpie's models
wait for it is Always ChatGPT's to say.

Fix. agent/codex.go: out becomes outOn(model). The kept account is still
left beside its sign-in on one of Codex's own models (davezfr's case,
including the takeover's own-model stand-ins, codex.out_own /
codex.out_stand), and taken over on a model of magpie's as any held
account is: by Sync, by a pick (set checks the model picked), and kept
through later Syncs till the reset. Always ChatGPT still keeps it beside
the sign-in. Doc comment in provider/keep_login_as.go and
docs/subsystems/agent-wiring.md say so.

Users already affected: on the next catalog sync after updating, a held
kept account on a magpie model is taken over and the app-server restarted
(AppOut), so Send works without anything to do.

Tests:
- TestCodexKeptOnAHeldAccountSendsMagpiesModel (new): magpie's model
  picked with room, then the kept account held: taken over (magpie the
  provider, AppOut), stays through another Sync and a pick, back beside
  the sign-in at room, and Always ChatGPT keeps it beside. Red on
  origin/main's codex.go ("held, kept: magpie's model left on the held
  account").
- TestCodexKeptOnAHeldAccountShowsIt: now Codex's own model only (the
  magpie's-model half was the behaviour this reverses).
Broken by hand: without the out_own/out_stand check in outOn,
TestCodexKeptOnAHeldAccountShowsIt/Codex's_own_model is red (codex/gpt-a
kept on magpie).

Run (wsl-run in magpie-desktop; mote's load was over 18): go test -count=1 -timeout 45m ./internal/agent ok (642s); go vet ./internal/agent, GOOS=windows go vet, GOOS=linux go vet -tags nogui: ok; gofmt -l clean. Base: origin/main 454f9d023 (rebased onto f1e2ada0f before push, which touches none of these files).

Full suite: run after push.

Not tried: the real Codex app with a real held account.
2026-11-18 23:21:28 +08:00
yetone f1e2ada0f7 usage: GPT-6.2's Ultrafast is priced at OpenAI's 3x, then 6x from March 1st (mu33410 on X)
mu33410 on X asked whether the cost magpie shows is adjusted for GPT's
fast modes. Mostly it was: a call is priced at the tier its reply named
(else the one sent, which is what a Codex/ChatGPT row has) from
models.dev's experimental.modes, on every route (Responses, Chat
Completions, the Responses WebSocket, which goes through the same
handler, and Codex's backend), in the Usage page, a key's spend limit
and a subscription window's API value. Checked against OpenAI's pricing
page: Fast (priority) is 2x on every model that lists it, Flex 0.5x,
Ultrafast 6x on GPT-6 Astra and GPT-6.1 Sol, all matching.

The gap: OpenAI prices GPT-6.2 Astra's and Sol's Ultrafast at "3 times
the Standard rate through February 28, 2027" and "6 times the Standard
rate starting March 1, 2027 (Pacific time)", and models.dev lists their
ultrafast mode with no cost. TierPrice skipped it, so every GPT-6.2
Ultrafast call, on an OpenAI key or a Codex subscription, was priced at
the standard rate, below Fast.

catalog.TierTimes holds that dated multiple; TierPrice takes the call's
time and gives the standard price times the multiple of its day, every
part and the long-context rate with it (Price.Times). The price caches in
Pricer and apiPricer key on the day's rate (Record.tierKey), and the
request-index ask names it, so calls either side of March 1st price
apart. Scoped to the openai maker entry and those two models; Claude's
fast mode reads its own mode as before.

Run (WSL magpie-desktop, Linux, Go 1.26.8; mote overloaded by another
session's full suite, mica's disk full):
- TestDatedUltrafastPricedAtItsDay (new; Claude fast and standard
  unchanged among its cases): red on origin/main 78b6d47cc (Ultrafast
  0.11 for 0.33 and 0.66), green with the fix, also with TZ=UTC and
  TZ=Asia/Tokyo. TestFastCallsPricedAtTheirTier green.
- Broken by hand: tierKey without the day's rate -> red (the March call
  priced at the promotion's 3x through the cache).
- go test ./internal/catalog ./internal/usage: catalog ok; usage ok but
  TestRequestStateKeptAcrossACatalogFetchedAgain, red the same (-count=10)
  on untouched origin/main 78b6d47cc on Linux, filed as #6572.
- gofmt -l clean; go vet for linux, windows and darwin on both packages.
Not run before the push: the full ./... suite (runs after, on mote).
2026-11-18 23:18:27 +08:00
yetoneandrecih 171475905f plugin: a reply's head that arrives with its completion is read, not dropped (#7017)
headRead checked the queue, found it empty, and then found the call's
result: a head the plugin queued between those two checks was lost, and
the reply was read as headless ("the vendor ended early"). The result
branch now takes a head queued meanwhile, as the c.done branch already
did. body.Read is not affected: it loops back to the queue after taking
the result.

From recih's branch (68bdf17e6), ported as its own commit.

Run: TestHostHeadArrivesWithCompletion passes on origin/main without
help (the window is narrow); with a 2ms sleep injected between the pop
and the result check it is red on origin/main ("completed reply's head
= {...}, the vendor ended early") and green with this change.
The full stack's run, on mote at e4506887c (this stack on origin/main 7300be4d0):
go test -timeout 45m ./...: 101 packages ok, 2 FAIL, both open issues
that fail the same at 7300be4d0 on mote, where an ssh session forwards
127.0.0.1:3425 to a real magpie: internal/cli's
TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr and
TestUpdateFindsAMagpieThatWroteNoRecord (#6223), internal/gui's
TestLaneLimitRoutes (#5150). On mica: gofmt -l clean; go vet ./...,
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., go
build, GOOS=linux go build -tags nogui, GOOS=windows go build all ok.
go test -race -count=2 of the new and touched tests in internal/gateway,
gui, plugin, tui ok on mote.

Rebased since. At dc507aefd on mote: go vet (darwin, GOOS=linux
-tags nogui, windows) ok; go test of internal/cli, tui, plugin,
gateway, gui, claudebridge ok but for the same #6223 and #5150 reds.
At 939fe31b6 (on origin/main 78b6d47cc) on mote: gofmt -l clean, the
three vets ok, the stack's tests with TestClaude* and
TestCoreScriptBudget ok in all six packages. Pushed on b400566f9 after
a clean rebase; the commits between touch no Go file this stack does.

Co-authored-by: recih <240406+recih@users.noreply.github.com>
2026-11-18 23:06:38 +08:00
yetoneandrecih e8e05b68e3 gateway: a stalled upload's retry waits for its connection to close (#7017)
stallGuard dropped the connection of an upload that stalled past
bodyStall and retried through GetBody at once, so the retry could start
while the stalled connection was still closing. The retry now waits for
that close (dropped, closed once inside onStall, the only place
errUploadStalled is set).

From recih's branch (fix/web-restart-session-persistence, 04bac6196),
ported as its own commit.

Run: TestStalledBodyRetryWaitsForConnectionClose red on origin/main
48fffb60c ("retry began before the stalled connection finished
closing"), green here.
The full stack's run, on mote at e4506887c (this stack on origin/main 7300be4d0):
go test -timeout 45m ./...: 101 packages ok, 2 FAIL, both open issues
that fail the same at 7300be4d0 on mote, where an ssh session forwards
127.0.0.1:3425 to a real magpie: internal/cli's
TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr and
TestUpdateFindsAMagpieThatWroteNoRecord (#6223), internal/gui's
TestLaneLimitRoutes (#5150). On mica: gofmt -l clean; go vet ./...,
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., go
build, GOOS=linux go build -tags nogui, GOOS=windows go build all ok.
go test -race -count=2 of the new and touched tests in internal/gateway,
gui, plugin, tui ok on mote.

Rebased since. At dc507aefd on mote: go vet (darwin, GOOS=linux
-tags nogui, windows) ok; go test of internal/cli, tui, plugin,
gateway, gui, claudebridge ok but for the same #6223 and #5150 reds.
At 939fe31b6 (on origin/main 78b6d47cc) on mote: gofmt -l clean, the
three vets ok, the stack's tests with TestClaude* and
TestCoreScriptBudget ok in all six packages. Pushed on b400566f9 after
a clean rebase; the commits between touch no Go file this stack does.

Co-authored-by: recih <240406+recih@users.noreply.github.com>
2026-11-18 23:06:38 +08:00
yetoneandrecih bfbc22e190 claude: an idle session is saved whenever the gateway ends or hands over (#7017)
recih: after magpie web restarted (an update's re-exec, or Quit and
start again) the next Claude turn replayed the whole conversation
instead of resuming its session. Web.Wait closed the page server and
never drained the gateway, so abortAll never ran and claude-shelf.json
was never written.

- Web.Wait drains the gateway (Close: page server, then stopServing)
  before the plugin hosts end and before update.Reexec.
- Desktop quit: OnShutdown calls stopServing.
- Signals: web, serve, the TUI and the app register their gateway with
  the signal handler (stopGatewayOnSignal). SIGINT, SIGTERM and SIGHUP
  drain it, sessions saved, before magpie dies of the signal. The return
  path waits for a drain the signal already started. The TUI and the
  app take SIGINT/SIGTERM themselves, but SIGHUP (the terminal closing)
  stays with magpie. runTUI, runGUI and runPanel now register
  tui.StopGateway and gui.StopServing for it (added in review).
- Handover: the successor answered a Claude turn before the predecessor
  had saved its shelf. The predecessor now serves
  GET /_magpie/claude-ready on its callback socket, answered once
  abortAll has run. A Claude turn on the successor waits for it.
  - The predecessor saves only after every request it holds has ended,
    of any provider, which can take up to handedOffDrain (15m).
  - Added in review: the wait is bounded by predecessorWait (90s, inside
    Claude Code's ten minutes for a reply). Past that, the turn goes on
    as before, as a replay, and no later turn waits
    (errPredecessorSlow).
  - loadShelf still reads a shelf written later, at the next turn with
    no session found.
  - A predecessor without the endpoint (404) keeps the old race.
- Sweep: sweepSessions removed session files older than idleLongest.
  That included a session kept for hours past a quota 429
  (keepForReset) and one moving from the shelf to a run.
  - Those are now protected: the shelf file, the in-memory shelf, the
    resuming set and active runs.
  - An unreadable shelf skips the sweep.
  - loadShelf and the sweep's snapshot are serialised by shelfFileMu.
    The bridge lock is held only for the shelf maps, never across the
    file's reads (added in review: the branch read the file under b.mu,
    which every Claude turn takes).

From recih's branch fix/web-restart-session-persistence (7a0261cc1,
fab0ea651), with the review's follow-ups. Not taken from the branch:
the .github/workflows/test.yml change (contributors.md: .github/ stops
for the maintainer), and the test-flake commits in other packages,
which are separate goals.

Red on origin/main 48fffb60c (the branch's tests, trimmed to what
compiles there), on mica:
- TestWebShutdownKeepsClaudeSession quit and restart: no
  claude-shelf.json ("Web.Wait did not keep the idle Claude session").
  Restart is a real Unix re-exec of the test binary with a fake claude.
- TestDesktopShutdownDrainsGateway.
- TestClaudeHandoverWaitsForSavedSession: "the successor answered
  before the predecessor saved its session".
- TestClaudeSweepKeepsQuotaSessions: 5 of 5 subtests swept the kept
  session.

Broken by hand: with runTUI's, runGUI's and runPanel's
stopGatewayOnSignal defer removed, TestHangupDrainsTheGatewayFirst
fails tui, app and panel ("SIGHUP never drained the gateway"), on
mote.
Run on mote at e4506887c (this stack on origin/main 7300be4d0):
go test -timeout 45m ./...: 101 packages ok, 2 FAIL, both open issues
that fail the same at 7300be4d0 on mote, where an ssh session forwards
127.0.0.1:3425 to a real magpie: internal/cli's
TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr and
TestUpdateFindsAMagpieThatWroteNoRecord (#6223), internal/gui's
TestLaneLimitRoutes (#5150). On mica: gofmt -l clean; go vet ./...,
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., go
build, GOOS=linux go build -tags nogui, GOOS=windows go build all ok.
go test -race -count=2 of the new and touched tests in internal/gateway,
gui, plugin, tui ok on mote.
Not tried: a real desktop app quit or update with a real Claude
account; SIGHUP from a real terminal closing.

Rebased since. At dc507aefd on mote: go vet (darwin, GOOS=linux
-tags nogui, windows) ok; go test of internal/cli, tui, plugin,
gateway, gui, claudebridge ok but for the same #6223 and #5150 reds.
At 939fe31b6 (on origin/main 78b6d47cc) on mote: gofmt -l clean, the
three vets ok, the stack's tests with TestClaude* and
TestCoreScriptBudget ok in all six packages. Pushed on b400566f9 after
a clean rebase; the commits between touch no Go file this stack does.

Co-authored-by: recih <240406+recih@users.noreply.github.com>
2026-11-18 23:06:38 +08:00
yetone b400566f96 library: a resize no longer works out every agent chip's style again (lexrus on X)
lexrus's Skills page (196 skills, By source, about 24 agent chips a row,
dark) crawled while the window was resized. Each row's chip strip was a
size container, and the chips' gap used cqw. Chromium invalidates every
style with container units on each change of the viewport width
(ViewportUnits), so every chip was recalculated on each resize step.

Now handGap works the gap out in whole pixels from each row's
content-box width, which a ResizeObserver on the .lib-row hands over, so
there is no forced layout and no container query. The CSS clamps
--lib-gap as before, and the gap is set only when it changes. While the
window is resized, .lib-resizing (held 600ms after the last step) turns
the chips' translate transitions off, which WebKit was paying to start
on every step.

Measured with a Playwright probe at the reporter's scale (259 rows,
6425 chips, every group open), 30 resize steps between 1200px and up,
CDP Performance.getMetrics and tracing, on mote:
- Chromium: resize wall 24.4-29.3s -> 2.7s; style recalc 18.2-22.1s ->
  1.3s; layout 0.47-0.71s -> 0.17s; long tasks 53-65 (6.8-8.0s) -> 15
  (1.7s).
- WebKit: resize wall 25.9-31.6s -> 9.2s; average frame 235-277ms ->
  48ms (hiding every chip gives 1.8s, the floor).
- Scroll is unchanged (about 31ms frames in Chromium, 20ms in WebKit).
  content-visibility was tried and dropped: it made scroll worse.

skill-name-many-agents.test.cjs now resizes 866px -> 560px and checks the
strips match a fresh 560px render, and a guard fails if library.css uses
container units again. Broken by hand (handGap run only once): 3 pass, 3
fail. Restored: green.

Run on mote at this head (rebased on 1b360f08c):
- The 180 library GUI files, Chromium and WebKit, --test-concurrency=4:
  1870/47 and 1872/45. Every red file run again alone on origin/main
  1b360f08c and on this head, both engines: the same reds on both, none
  new here (main 95/46 and 98/43, this head 99/43 and 99/43). They are
  filed: #5982 (update/using in strict recorders: skill-fold-all,
  skill-manual), #6667, #6751 (library-open-again), #3403/#6570
  (old-webkit), #3952/#5013 (mobile-web, found-skill-pick-remove),
  #5859 (skill-where), #6687 (skill-group-shared), #4620 (market-have),
  #7097 (win-caption, text-size, search-mcp-library).
- go test ./internal/gui/ ./internal/library/ (they read these assets):
  library ok; gui red once in TestLaneLimitRoutes, which read a running
  gateway's real volcengine lane (#5150); -count=3 of it alone is ok at
  this head and on origin/main.
- Rebased on 454f9d023, which changed client.js's MCP router row: at that
  head skill-name-many-agents, library-mcp-router-tools and i18n-keys
  pass 21/0 in Chromium and in WebKit, and go test ./internal/gui/ is ok.
Not run before the push: the full Go suite (mote at load 34-50, mica's
disk full); it runs after the tag. No Go file changed.
2026-11-18 23:00:33 +08:00
yetone 454f9d023a library: the Tools on demand row names the agents the gateway gives every tool
The row under the MCP router said "Claude Code, Claude Desktop, Codex and
Pi find tools themselves and are given every one", but hubOnDemand gives
every tool to Droid and omp too (hubSearchesItself). The words now come
from the code: gateway.HubFindsItself (the ordered list hubSearchesItself
is built from) and gateway.HubOnDemandOver reach the library's view as
hubFindsItself (each agent by its name, its id when none is found) and
hubOnDemandOver, and the row joins them with the language's list
separator. Two keys replace the old sentence in zh, zh-TW, ja and de; the
CJK sentences follow each other with no space.

Tests:
- TestHubFindsItselfIsWhoGetsEveryTool: every named agent (and its WSL
  id) is given every tool, every agent given every tool is named, and
  other agents get theirs on demand.
- TestHubFindsItselfInTheView: /api/library carries the gateway's list
  and threshold, each agent by its name.
- library-mcp-router-tools.test.cjs: the row's text is built from the
  view's list and count (fixture: 12, six agents), names each one, never
  says 10, and has no "。 ".

Run (wsl-run, magpie-desktop; mote was at load 46-49 of 18, mica's disk
full), at this tree on 35a03fee0:
- gofmt -l internal/gateway internal/library internal/gui: clean
- go vet -tags nogui, and GOOS=windows go vet -tags nogui, of
  ./internal/gateway ./internal/library ./internal/gui: ok
- go test -count=1 ./internal/gateway -run 'Hub|MCP': ok
- go test -count=1 ./internal/gui ./internal/testenv: ok (134s)
- go test -count=1 ./internal/library: ok (183s)
- node --test i18n-keys, library-mcp-router-tools,
  library-mcp-router-note, library-mcp-hub (chromium and webkit; 1100
  and 420 wide; en, zh, zh-TW, ja, de): 70 of 70 ok

Broken by hand (a copy of this tree): dropping omp from the list while
omp still gets every tool, TestHubFindsItselfIsWhoGetsEveryTool fails
"omp is given every tool but not named"; putting the old hardcoded "10"
and four names back into the row, library-mcp-router-tools fails in
every language. That run also showed "。 " in zh, fixed here.

Not run: the full go test ./... and the whole GUI suite; the real app.
2026-11-18 22:39:19 +08:00
yetone 35e5989f17 provider: OpenCode Go's own free models are asked as the client asked them, without OpenCode's environment block (withtee on X)
withtee (X, 2123032184043024704) saw models on OpenCode Go answer with
"Prefer /tmp/opencode over generic system temporary directories such as
/tmp". That line is magpie's: OpenCodeFree counted Go's own -free models
(beam-free, cat-jam-free, which models.dev's opencode-go lists) as Zen's
free tier, so the Zen mimicry went with them: OpenCode's <env> block and
the core-tool stubs were added to every request from Claude Code and other
clients, and the model said the block back. Paid Go models never got it.

OpenCodeFree now leaves out a model opencode-go lists when the provider is
at Go's gateway (openCodeGoLists). It is asked as the client asked it and
is not asked again at Zen when Go refuses it. A Zen free model Go doesn't
list (glm-5-free) keeps the block when RetryOpenCodeFreeOnZen asks it at
Zen, which answers 429 without it. The opencode-zen preset is unchanged.

Tests: TestOpenCodeGoOwnFreeModelsAreNotZens (provider) and
TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (gateway, checks the
request body has no /tmp, <env> or stub; Zen's retry of glm-5-free still
carries both). TestOpenCodeGoUnavailableSaysWhere moved to glm-5-free,
since Go now lists cat-jam-free itself.

Run (all on magpie-desktop, WSL2 on xiaomi-gpu, via wsl-run; mote over
its load limit, mica's disk full):
- gofmt -l: clean.
- go vet -tags nogui ./... (Linux): ok. GOOS=windows go vet ./...: ok.
- go test -tags nogui -count=1 -run 'OpenCode|Zen' ./internal/provider
  ./internal/gateway: ok, before the rebase and again at 32c5d297a on
  origin/main 1b360f08c.
- Broken by hand: OpenCodeFree returning true for Go's listed models
  turns both new tests red (provider and gateway); restored, green.
Full suite: queued, run after push (magpie-desktop busy with another
session's GUI suite).

Not tried: a real OpenCode Go request; the live Go key answers
api_key_expired.
2026-11-18 22:37:50 +08:00
yetone 1b360f08c2 gui: the Version row's Restart is named Restart only (realfxw on X)
With automatic updates off, Settings › About's Version row shows Check
and a bare Restart. realfxw restarted again and again, reading Restart
as "install the update", while his build was newer than Daily's and no
update was on offer.

Why the button is there: 74bba1fa6 added it for yansheng1003 on X, to
start magpie again as it is so start-only settings apply (LAN set by
hand in settings.json, environment variables). It does something, so
it stays, named for what it does: "Restart only" (仅重启, 僅重啟,
再起動のみ, Nur neu starten). It still shows only while no update is on
offer; the paths that install an update keep their own buttons. No
description text is added. The plain "Restart" key stays for the
agent dialogs that use it.

A longer "Restart without updating" was tried first: at 420 wide it
squeezed en's "Automatic updates are off" onto two lines, the row grew
and update-auto's "a view at its top stays at its top" went red (top
25, 2 of 2 runs, both engines). "Restart only" keeps that line on one.

TestCoreScriptBudget: app and core budgets +5, the longer word alone;
renderUpdate draws it on every window, so there is no page to move it
to.

Tests: version-restart.test.cjs gains "automatic updates off, the button
beside Check says it doesn't update", every language at 900 and 400
wide (buttons on one line, no sideways scroll, no page errors).

Run, on mote:
- Red on old: the new case against origin/main's assets, chromium, 31
  failures (['Check','Restart'] where the new label is expected).
- At this head (rebased on 35a03fee0):
  - gofmt -l internal/gui empty;
  - go vet ./internal/gui for darwin, linux -tags nogui and windows;
  - go build ./... for darwin, linux -tags nogui and windows;
  - go test -run 'TestCoreScriptBudget|TestI18n|TestRestart|TestUpdate'
    ./internal/gui ok.
- GUI, the 32 files it can reach (update-*, version-*, i18n-*,
  gui-zh-tw, gui-ja, gui-de, settings-search*, old-webkit, refresh-page,
  settings-update-source), chromium and webkit: 356 of 358 in each engine; the two reds are old-webkit's, below.
  - Before the rebase: update-auto, version-restart, update-check,
    i18n-keys, gui-de, gui-ja and gui-zh-tw passed 70 of 70 in each
    engine.
- old-webkit's two reds (guideback.js from cb1fe6d5d isn't in its
  list) fail the same on a fresh origin/main 35a03fee0, alone, in both
  engines; recorded on #6570.

Not run: the full Go suite (mote at load ~50, mica's disk full).
Not tried: the real app's About page with automatic updates off.
2026-11-18 22:32:44 +08:00
yetone 78b6d47ccc update: a version newer than its channel's says nothing comes until the channel passes it (realfxw on X)
realfxw on X (tweet 2123033167170814171): "升级无效,重启了无数次,一直卡在这个版本",
on 0.1.4445. Every release around it has its 17 assets, so nothing was
missing to download. Their Update channel is Daily, and Daily's pick
(the 11-17 20:00 UTC cut) is 0.1.4395, older than what they run. The app
keeps the newer version and installs nothing until Daily passes it, which
is right, but the version row said "Up to date on Daily" (每日版已是最新)
and, before a check, Automatic updates are off with a bare Restart. They
restarted again and again waiting for an update that couldn't come.

- update.go: the update JSON says ahead when the state is latest and
  this version is newer than the channel's.
- app.js: the row says "Newer than Daily's 0.1.4395; it updates once
  Daily passes it", the newest on Every version after it, and Switch to
  Every version as before; one t() for both channels and the Every
  version tail shared with Up to date. Translated in zh, zh-TW, ja, de.
- update_cli.go: `magpie update check` says the same, with
  `magpie update channel every` to get it now.
- core_budget_test.go: +68 bytes of code on app.js and the core scripts,
  packed to the shortest form; renderUpdate draws on every window, so
  there is no page to move it to.
- docs/reference.md: the channel section names Daily and the line.

Red on the old code (upd-ahead-red, origin/main b855cfee9):
TestUpdateAheadOfChannel FAIL (no ahead key in the JSON),
TestUpdateAheadOfChannelSaysSo FAIL ("up to date"), and
update-stable-newest.test.cjs timed out on the ahead line in every
language.

Run at this head (253547908's tree, rebased on 4d79bebfa), on mote:
- gofmt -l clean; go vet ./internal/gui ./internal/cli ./internal/update
  for darwin, GOOS=linux -tags nogui and GOOS=windows; go build . for all
  three.
- go test -count=1 ./internal/gui ./internal/cli ./internal/update
  ./internal/settings: update and settings ok; the new tests pass; gui
  and cli red only on TestLaneLimitRoutes (#5150),
  TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
  TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr (#6471) and
  TestUpdateFindsAMagpieThatWroteNoRecord (#6223), the same on
  origin/main b855cfee9 on mote, where an ssh forward holds
  127.0.0.1:3425.
- GUI, BROWSER=chromium and webkit: update-*, i18n-*, gui-zh-tw/ja/de,
  settings-search(-reach), 28 files, 296/296 each, before the rebase;
  update-stable-newest and i18n-keys 15/15 each after it, with
  TestCoreScriptBudget ok.

Not run: the full go test ./... suite. mote and mica each had another
session's full suite running, and mica's disk is full; CI runs it.
Not tried: a real Daily install moving past it.
2026-11-18 21:44:37 +08:00
yetone 4d79bebfa7 usage: speed counts all output, reasoning and tool calls too, from the first output (Archivemylife on X)
Archivemylife on X: speed should be the upstream's usage over the local
time, with no split into reasoning, tools and answer, since reasoning and
tool calls are tokens too.

Speed is now every output token the vendor's usage counts (reasoning and
tool-call arguments included) over the time from the first output of any
kind to the end of the reply. The first output is the earlier of the first
content (TTFT) and the first sign of reasoning, firstToken.reasoningMs in
ttft.go, which works the same in every protocol:
- a Responses reasoning item's start;
- an Anthropic thinking or redacted_thinking block's start;
- sealed (hidden) thinking;
- reasoning deltas spread over 100 ms or more. Deltas that came at once
  are a buffered burst and tell none.

A summary is no sign (summaryPart: a Responses reasoning summary, a Gemini
thought, or a summary translated from another protocol via
firstToken.summarized), because it is written after some of the reasoning
it sums up (#1463). A reply that reasoned with no sign of when it began
counts only its answer, its output less the reasoning, from its first text,
and none with no text. Before this, a reply that reasoned always counted
only its answer, and a reply that wrote tool calls after reasoning told no
speed. Burst and held-content checks judge the answer's part.

The same definition holds everywhere:
- gateway: speed.go, trace.go, codex_backend.go;
- usage.DecodeOf, for the Usage cards, rows and `magpie usage`;
- the Usage page's ledDecode;
- the Routing page's decodeOf and its ranking (fast routing reads
  noteTrySpeed, which uses DecodeOf).

settledCountVersion goes to 8, so settled heat totals are counted again.
The rule text is in en, zh, zh-TW, ja and de. Docs: reference.md, and
gui-shell.md under "Streamed output speed".

Red on the old code (scratch worktree at 589e4ba6d):
- TestCodexPreambleThenReasoningTellsSpeed: "reasoning seen from 0 ms;
  want 3166".
- TestVisibleReasoningSpeed: 100/1000 and 0/0 where 1500/14000 was
  wanted.

Run at this head (rebased on dc507aefd), on mote:
- go test -tags nogui -count=1 -timeout 45m ./...
  - gateway ok (1132s), usage ok, routes ok.
  - Red, filed, and caused by mote's own gateway on 127.0.0.1:3425:
    internal/cli TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
    TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr and
    TestUpdateFindsAMagpieThatWroteNoRecord (#6223, #6471); internal/gui
    TestLaneLimitRoutes (#5150).
- go vet for gateway and usage on darwin, GOOS=linux -tags nogui and
  GOOS=windows: ok. gofmt -l: clean.
- GUI, 18 files in Chromium and WebKit (reasoning-speed, usage-speed-*,
  usage-ledger, routing and the i18n files): 242 of 270 pass. The rest are
  usage-ledger "newest live route needs no return-to-live button" (#6003)
  and usage-speed-all-models "asked for 7d" (#5834). Both are red the same
  way on origin/main dc507aefd, in a run of its own.

Rebased again on 70ad7cf30, which touches gateway.go and usage/page.js.
At that head, on mote: go vet for gateway and usage; go test -run
"Reasoning|Speed|Decode|Ultra|Uncounted" for gateway and usage, ok;
reasoning-speed, usage-reads-note, usage-speed-every-row and i18n-keys in
both engines, 66 of 66.

Not tried: a real account per vendor. The timing is taken from recorded
stream shapes in the tests: Responses, Anthropic, Chat and Gemini, native
and translated.
2026-11-18 21:30:25 +08:00
yetone 1c0ecec0f6 library: a magpie in Docker keeps skills and prompts for its clients
fenglian980510 on X: in the Docker gateway the Library had MCP and no
Skills. Since f285426ac a page that shows no agent (no agents found, as
in a container, or gateway mode) drew the MCP tab alone. 5a9b5720d then
let another computer's magpie take a remote's skills and prompts (Use its
skills and prompts, GET /v1/magpie/library), but a Docker magpie had no
way to hold any, and anything it held was ticked for no agent, so Borrow
gave it to none on the client. The borrow change didn't re-derive the
agentless page.

- client.js: with no agent shown, the Library has Instructions, MCP
  servers and Skills (AGENTLESS_TABS), with nothing of agents (no chips,
  agents' own skills, projects or Agents list) and a line saying a
  magpie that adds this one as a provider takes them. It opens on MCP
  unless the reader picked one of the three. Strings in zh, zh-TW, ja, de.
- library: Shared says NoAgents when the page shows none (NoAgentsShown,
  set by gui.gatewayMode). Borrow gives such a new skill or set ticked
  for none to the agents here that take skills or instructions and
  aren't hidden (givenHere); one ticked for agents keeps them.
- docs: docker.html en/zh/ja (zh and ja still said there is no Library
  at all), reference.md, library, gui-shell and mcp-router pages; the
  search index rebuilt.

Rebased on origin/main 5cf1d3846 (runs below at 589e4ba6d; the five
commits since touch none of these files but gui-shell.md, which
rebased clean, and docs-index.mjs writeAll left the index unchanged).
The search index was rebuilt through
docs-index.mjs's writeAll after the rebase). What was run:
- At this head, on Linux (WSL magpie-desktop): gofmt -l (0 files),
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: ok
  (mote and mica were over their load bars).
- At this head, on WSL: go test -tags nogui ./internal/library
  ./internal/gui ./internal/gateway ./internal/provider
  ./internal/testenv -count=1 -timeout 45m: all ok.
- At this head, on WSL: library-agentless-skills, library-mcp-agentless,
  i18n-keys, gateway-mode*, library-* and i18n-* (both engines, every
  language the files run): 1975 of 2010 ok. The 35 reds are in 11
  tests, all red on main too: library-all, library-commands-import,
  library-group-steady, library-mcp-copy-config, library-mcp-off-fold,
  library-open-again (#7097), library-bili (#6015: 82/2 alone, with and
  without this change), gateway-model-chip-height (#7108: red 2 of 3
  alone at main). library-bili-settings and library-mcp-json pass alone
  at both (22/22, 32/32).
- At 998e40c85 (the same change on origin/main 48fffb60c), on mica
  (load 25-35 on 12 cores): go test ./... -timeout 45m, 100 packages ok
  and 3 red, each also red or passing alone at the base 534b85bf9:
  internal/dirent (4 tests, red alone at both, #7031), internal/gui
  TestGatewayModeListsNoOwnSessions (passes alone 3/3, #7064),
  internal/sessions TestWSLStoppedDistroKept (passes alone, #7071).
  gofmt and darwin/linux/windows vet ok there too.
- At 998e40c85, on WSL: 239 GUI files that reach the Library (library-*,
  i18n-*, gateway-mode*, web-page*, any file naming the Library):
  4530 of 4688 ok. The 24 red files rerun at concurrency 2: 151 red at
  998e40c85, 155 at 48fffb60c, the same files (#7097, with #6990,
  #4566, #3922, #6570, #4716 for segs-press-redraw, old-webkit and
  title-bar-tools).
- Not on macOS this round: mote and mica each had another session's full
  GUI suite running all the while.

Broken by hand:
- Borrow's two NoAgents branches set to false:
  TestBorrowFromAMagpieWithNoAgents red ("a skill ticked for none there
  went to [] here, not [claude gemini]").
- origin/main's client.js and i18n.js: library-agentless-skills and
  library-mcp-agentless red at "the tabs", 44 of 44.

Not tried: a real Docker magpie with a second magpie borrowing from it
across two machines. site/search-index.mjs run as a script hangs on its
circular import of docs-index.mjs (as on main); the index was written
through docs-index.mjs's writeAll.
2026-11-18 21:29:39 +08:00
yetone 70ad7cf30f provider: an OpenAI key's GPT-6 Astra and Sol can go Ultrafast, on its Responses (OoopsHh on X)
OoopsHh on X: in Docker, an OpenAI API provider's GPT-6 Astra offered
Standard and Fast only, in the model's speed, in routing groups and in
the Agents settings. Every Ultrafast offer came from a Codex account's or
Codex CLI's list, which a Docker magpie with an API key has none of, and
buildResponses sent "ultrafast" to chatgpt.com alone.

OpenAI's Ultrafast mode guide
(developers.openai.com/api/docs/guides/ultrafast-mode) names GPT-6.2
Astra, GPT-6.2 Sol, GPT-6 Astra and GPT-6.1 Sol, with service_tier
"ultrafast" on the Responses API. provider.OpenAIUltra holds those four
(a dated snapshot too). UltraOn offers Ultrafast for them on an OpenAI
key's Responses, and on a provider added by its address (OwnFast) with no
Codex cache; the GUI's three speed controls read UltraOn
(providers.go canUltra, groups.go ultraOK, agent route UltraOK), so no
GUI asset changed. buildResponses sends the tier to api.openai.com for
those models only (any other goes priority, as before). OpenAI's Chat
Completions turns the tier away on every model, so a Chat request to
api.openai.com that would carry it, a client's own ask too, goes priority
(chatNoUltra, in the tierMate check). Another vendor's model is untouched.

The Codex subscription half (Docker asked the ChatGPT list as 0.159.0,
below the 0.166.0 that lists GPT-6.2 and Ultrafast) was fixed meanwhile
on main by e1c186cfe (0.169.1 and npm's latest);
TestCodexFallbackListsUltrafast keeps the fallback at or above 0.166.0.

Real requests (11-18, magpie's own keys, nothing printed):
- api.openai.com /v1/responses, service_tier ultrafast: gpt-6-astra,
  gpt-6.1-sol, gpt-6.2-astra, gpt-6.2-sol passed validation and stopped
  at 429 billing_not_active (the key's billing is off, so a served
  ultrafast reply was not seen); gpt-6-sol and gpt-6.1-terra answered 400
  "Invalid service_tier argument".
- /v1/chat/completions with ultrafast: 400 "Invalid service_tier
  argument" on every model; with priority, accepted up to billing.
- ChatGPT backend (a real Codex account), service_tier ultrafast:
  gpt-6.2-sol and gpt-6-astra as 0.170.0 answered 200 (the reply said
  service_tier default); as 0.159.0, gpt-6.2-sol was refused as not
  supported. Its models list as 0.166.0+ lists gpt-6.2-sol with
  priority and ultrafast; as 0.165.0 and before, no ultrafast anywhere.

Tests: TestOpenAIKeyUltrafast (Responses and Claude's API to an OpenAI
key's gpt-6-astra send ultrafast on /v1/responses; Chat goes priority;
gpt-6-sol can't be picked Ultrafast; another agent goes standard; an
Anthropic key's Claude has no Ultrafast and keeps speed "fast"),
TestCanUltraOwnProvider (OpenAI key and relay with no cache; gpt-6-sol,
gpt-6.1-mini, Claude false; OpenAIUltra's prefix, case and dated forms).

Broken by hand, each red: buildResponses without the api.openai.com
case (TestOpenAIKeyUltrafast sent priority); without chatNoUltra (Chat
sent ultrafast); UltraOn without the OpenAI branches
(TestCanUltraOwnProvider false for oa/gpt-6.1-sol).

Run on mica at 888847666 (this change on origin/main dc507aefd, after
e08dc0fe5 put api.openai.com's Responses on the WebSocket; pushed on
5cf1d3846, a sessions/GUI change after it, not run with this):
go test -count=1 -timeout 45m ./...: 101 packages ok, internal/gateway
included; red were internal/dirent's watch tests (#7031; dirent imports
only testenv, red alone on mica too) and TestGatewayModeListsNoOwnSessions
(#7064, ok run alone); the same at c7060224b. An earlier run at 2d1545833 (on d74754970) had
those plus TestImageMCPKeepsDrawingsOffTheHeap (#6890, ok alone).
Targeted internal/provider and internal/gateway Ultra/Fast/Tier runs on
mote: ok.
go vet on darwin, GOOS=linux and GOOS=windows for internal/provider and
internal/gateway: ok. gofmt -l: clean.

Not tried: a served ultrafast reply from api.openai.com (no key with
active billing), the Docker image itself, and the GUI suite (no asset
changed; the controls read the same canUltra/ultraOK fields their GUI
tests cover).
2026-11-18 21:20:35 +08:00
yetone 5cf1d3846a sessions: an agent left off in the first "allow selected" is asked about once more, on Sessions and Usage › Requests
baysonfox on X: with magpie installed after Antigravity 2.0, the app's
sessions and calls made without magpie never showed in Usage, while agy
CLI's did. The first consent named the app off beside agy, and a named
agent was never "new" again, so nothing asked about it and nothing on
Usage said why. The reader is fine: the app's calls come from its own
SQLite steps (antigravityRead), read once allowed.

Nothing is turned on by magpie: the gate is the user's privacy choice.
Instead:
- settings.SessionReads gets Kept: agents turned off on their own (a
  sessions/reads post without `all`: Keep off, a Settings › Privacy row,
  `magpie sessions read off <agent>`). A post setting it on takes it out.
- readsNow's New: off, found here and not Kept (was: never named). So an
  agent left off in the first choice's list is asked about once more,
  as one found later already was.
- Usage › Requests shows a line above its rows for those agents
  (readsLater in the usage plugin): Count {names} / Don't count, the
  same {agents} posts as the Sessions page's laterCard. Gone after
  either answer; sessions/reads read at most once a minute.
- Old data: an agent turned off in Settings before Kept existed has no
  entry and is asked once more, for every user with such an agent.

Tests:
- TestSessionReadsUncheckedAgentAskedAgain (count, keep off): sandbox
  HOME with testdata/agy-sessions and the real Antigravity 2.30
  conversation (antigravity-2.30-tools); after the first choice the app
  is off and New, has no rows in /api/usage/requests; Count brings its
  rows in, Keep off keeps none, and neither is asked again. Red on the
  old code (New false after the first choice).
- TestSessionReadsTurnedOffNotAskedAgain: off on its own, under all true
  and all false, is neither on nor New.
- usage-reads-note.test.cjs: the Requests line in Chromium and WebKit,
  en/zh/zh-TW/ja/de at 900/420/390px, both answers, buttons inside the
  line, no sideways scroll; red on the old code (no #ledReads).

Run on mica (mote was full: load 40+, another GUI suite on it), rebased
on 389169f76:
- gofmt -l clean
- go vet on gui, sessions, settings, cli and tui; GOOS=linux -tags nogui
  and GOOS=windows vet on gui, sessions, settings and cli; go build ./...
- go test -count=1 -timeout 45m on internal/gui, sessions, settings, cli
  and tui: all ok except gui's TestGatewayModeListsNoOwnSessions, red
  the same on an untouched 389169f76 copy (#7064)
- GUI, both engines: usage-reads-note, sessions-reads, i18n-keys,
  i18n-en-no-cjk, usage-ledger, usage-request-page, usage-no-reading,
  usage-ledger-fit, ledger-hscroll, usage-phone-head, sessions-usage-off.
  Only usage-ledger's "newest live route needs no return-to-live button"
  was red (en, zh, both engines), red the same on the untouched
  389169f76 copy (#3104). i18n-keys first caught "Leave off" as otel's
  word; renamed to "Don't count".
- After rebasing on dc507aefd: gofmt, vet, the TestSessionReads tests
  and usage-reads-note, i18n-keys, i18n-en-no-cjk and sessions-reads
  again: all ok, 98 of 98 GUI tests.

Broken by hand: recording Kept on every off post (all sent too) turns
TestSessionReadsNewAgent, ...UncheckedAgentAskedAgain and
...TurnedOffNotAskedAgain red.

Not tried: the whole GUI suite (both machines had another GUI suite
running), the full go test ./..., and a real Antigravity 2.0 install
in the GUI; the live Antigravity data was not touched.
2026-11-18 20:59:55 +08:00
yetone dc507aefd3 gateway: Automatic image recognition and web search stay with the provider that served them
hxy920830 on X added a Claude account only for account switching, and
every agent's image recognition and web search moved onto it: with
Settings › Models › Image recognition and Web search on Automatic, magpie
ranked the picks again on each call, and a Claude account ranks first in
both (seersRanked tier 0, searchRank 0). Adding a provider reassigned
what another provider already served.

- auto_picks.go holds each Automatic slot (Image recognition, Web search,
  Image generation, Video generation) to the provider magpie first picked,
  in auto-picks.json beside providers.json. seersRankedHeld and
  autoSearcherReady put the held provider before every other of its
  readiness; AutoDrawer and AutoVideomaker pick among its models while it
  has one. A default fills only a slot nothing serves: nothing held, or
  the held provider removed, off, or left with no model for it.
- Allowance still comes first for the moment (#1801); the hold stays.
- A model picked in Settings is untouched. The picker already shows the
  pick as "Automatic · <model>", where it can be changed.
- A file that can't be read holds nothing and is not written over.

Users already switched: holds begin once, when the gateway first serves
(seedAutoPicks). It reads the last 30 days of the ledger's Image
description calls (kind vision) and the searcher's Web search calls
(kind web_search, not search API / native rows). A slot a later provider
took over is given back to the provider that served the call just before
the current pick's first, while it can still serve it. A switch older
than 30 days, or one whose earlier provider is gone, is not restored: the
current pick is held and the user picks in Settings › Models. Image and
video generation have no Automatic call in the ledger and are held to
the pick at the seed, nothing restored.

Docs: docs/subsystems/gateway-routing.md, "Automatic picks are held to
the provider that serves them".

Run:
- go test ./internal/gateway -run 'TestAddedProviderTakesNoAutomaticPick|TestAutoPicksSeededFromTheLedger|TestClaudeAccountAddedTakesNoImages' -v: ok (mica)
- GOOS=linux go vet ./internal/gateway, GOOS=windows go vet ./internal/gateway: ok (mica)
- go test -count=1 -timeout 45m ./... (mote, at 589e4ba6d + this change):
  every package ok (internal/gateway 1080s) except seven reds, each
  already filed and each passing alone at this tree on mica:
  capre TestCappedIsSmall (#5975); cli TestHealthcheckFindsTheRunning-
  GatewayWithoutMagpieAddr, TestUpdateRestartsTheGatewayItFindsWithout-
  MagpieAddr, TestUpdateFindsAMagpieThatWroteNoRecord (#6223, #6471:
  something serves on mote's 127.0.0.1:3425); gui TestAppReplacesIts-
  OlderGatewayOnceIdle (#6297), TestLaneLimitRoutes (#5150). The four
  cli and capre tests pass on origin/main 9314999a4 too.
- After the rebase onto origin/main e08dc0fe5 (mica): go test ./internal/gateway -run 'the three|Vision|Searcher|Drawer|Videomaker' ok, GOOS=windows go vet ok.

Broken by hand: heldPick returning "" (the old ranking) turns all three
tests red: AutoVision = "anth/eye" after a provider was added, and
"claude/claude-haiku-5-5" after the Claude account was signed in.
Not tried: the real app with a real Claude account; no GUI file changed,
so the GUI suite was not run.
2026-11-18 20:27:20 +08:00
yetone e08dc0fe58 provider: OpenAI's own API sends Responses turns over the WebSocket by default, only the new input each turn (KawaiiZapic on X)
KawaiiZapic's screenshot showed 6.4 GB up for 799 MB down: every turn
went out whole. What each leg sends, checked in the code:

- Codex on a ChatGPT subscription: the kept upstream socket already
  sends previous_response_id and only the new input (codex_socket*.go).
- A Responses provider with socket=auto/on: the same, but socket was
  off unless someone ticked it, so an OpenAI API key provider sent the
  whole conversation each turn over HTTP.
- A client's own previous_response_id is kept for api.openai.com,
  Azure and Ark (prevKeeps); other relays get the expanded whole turn,
  since they can't be trusted to hold the chain.
- Claude Messages, Chat Completions and Gemini have no incremental
  protocol; those always send whole (prompt caching is what saves there).
- The ↑ counter (upbytes.go) counts each upstream write once; no double
  count found.

Change: a Responses provider at https://api.openai.com with no socket
set now goes over the WebSocket (provider.SocketByDefault, mirroring
codex-rs's create_openai_provider supports_websockets: true). socket=off
is now stored, so unticking it there sticks; elsewhere unticked is still
"". The CLI shows "auto (default)" and takes socket=off|default. The
editor's WebSocket row moved into socketrow.js (imported as the editor
draws), so app.js and the core shrink by 165 bytes and their budgets
drop with them. Caveat: an OpenAI provider saved unticked before this
(socket "") now goes over the socket until it is unticked again; the
docs say so.

Measured (fake api.openai.com over TLS, sandbox HOME, 20 turns of a 4KB
user message each): socket off 20 HTTP posts, 876,345 bytes up;
default 0 posts, 20 socket turns on one handshake, 84,928 bytes up
(Traffic().Up equal to the socket bytes, so no double count).

Run (mica). At this head, rebased on origin/main 589e4ba6d: the go
test -run line below ok (budgets included), gofmt clean,
provider-socket.test.cjs 80/80 and old-webkit's same 2 reds. The rest
ran at the tree rebased on 1bfa8d5a1 (main since touched only plugin
assets and docs outside these files):
- go test -run 'Socket|Budget|OpenAI' ./internal/gui ./internal/provider
  ./internal/cli ./internal/gateway: ok.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
  for provider, cli, gateway, gui: ok.
- GUI: provider-socket.test.cjs 80/80 (chromium + webkit, 5 languages,
  2 widths). Every provider-*, i18n-* and old-webkit file in one
  run: 1793 pass, 76 red. Each red file run alone at this tree and at
  origin/main 1bfa8d5a1 is red the same or green at both:
  provider-fetch-again (#5057, #5232), provider-many-keys and
  provider-max-output (#6209), provider-models-rest, provider-picks-stay
  and provider-typed (#6532), provider-proxy (#7100), provider-remove
  (#7101); provider-advanced-fold 50/50, provider-env-paste,
  provider-add-gemini, -gemini, -at-once, -auth-header and -mask pass
  alone (load).
- Full suite, go test -count=1 -timeout 45m ./...: 99 packages ok, 4 red.
  Alone: TestSearchQueueKeepsCodexAlive (gateway) and
  TestWSLStoppedDistroKept (sessions) pass; TestGatewayModeListsNoOwnSessions
  (gui, #7064) and the dirent watch tests (#7031) are red at
  1bfa8d5a1 too.
- old-webkit.test.cjs: 2 reds (guideback.js not in the lazy list,
  Safari 15.0 styles), the same on origin/main 1bfa8d5a1 run alone;
  noted on #6570.

Broken by hand: SocketByDefault returning false turns
TestSocketByDefaultOnOpenAI and TestOpenAIProviderTurnsGoOverWebSocketByDefault
red ("2 HTTP posts, 0 socket turns on 0 handshakes").

Not tried: a real OpenAI API key, and a real Codex binary against an
API-key provider; the fake follows the Responses WebSocket protocol the
existing socket tests use.

Reported-by: KawaiiZapic on X
2026-11-18 20:22:30 +08:00
yetone 9314999a4a ccswitchlink: a ccswitch:// link that still reaches magpie goes to CC Switch, and so does the scheme (asombrado_a on X)
@asombrado_a (X, 2122995130097713493) has CC Switch and magpie both
installed, and a ccswitch://v1/import link opened magpie. magpie claims
magpie:// only since 03314b25a (v0.1.4455), but v0.1.3981 to v0.1.4454
claimed CC Switch's scheme too, and what they registered stays:
- macOS: Launch Services keeps the old Info.plist's ccswitch claim after
  the bundle is rewritten in place (seen on mote below);
- Windows: HKCU\Software\Classes\ccswitch running magpie.exe;
- Linux: magpie-ccswitch.desktop as the x-scheme-handler/ccswitch default.

The owner's call in 03314b25a stands: magpie doesn't read CC Switch's
links. A ccswitch:// link that reaches magpie anyway is now handed on:
- cli.run, before anything is read, moved or started (Windows, Linux:
  `magpie ccswitch://…`), and the Mac's URL event in gui.Run call
  ccswitchlink.Forward;
- macOS: `open -b com.ccswitch.desktop <link>`, then `lsregister -f` on
  magpie's own bundle, which reads its current Info.plist and drops the
  claim;
- Windows: the handler's program when it isn't this magpie, else
  %LOCALAPPDATA%\Programs\CC Switch\cc-switch.exe (where CC Switch's
  per-user MSI installs it); when the handler ran this magpie the key is
  rewritten as that MSI writes it ("URL:com.ccswitch.desktop protocol",
  URL Protocol, DefaultIcon, shell\open\command "exe" "%1");
- Linux: CC Switch's .desktop entry in the XDG data dirs (its first
  start's cc-switch-handler.desktop with %u first, else the package's
  "CC Switch.desktop", whose Exec has no %u, so the link is appended) is
  run, and a default that is magpie-ccswitch.desktop moves to it; magpie's
  entry is removed while it runs this magpie or a gone binary. Any other
  default is left alone.
- No CC Switch: ErrNotInstalled, nothing opened, the claim kept, so
  magpie opens such a link as it does now (it says it reads magpie://
  links only).

Existing users: nothing changes until a ccswitch:// link reaches magpie.
The first one is opened in CC Switch and the claim goes back, so later
links go to CC Switch directly.

CC Switch's facts come from farion1231/cc-switch (tauri.conf.json's
deep-link schemes ["ccswitch"], wix per-user-main.wxs, lib.rs's
register_all) and its v4.0.35 assets: macOS.zip's Info.plist
(com.ccswitch.desktop, CFBundleURLSchemes ccswitch), the portable zip's
cc-switch.exe, the .deb's "CC Switch.desktop" and /usr/bin/cc-switch.

Run (this tree on d74754970, then again where named after a rebase on
589e4ba6d, which touches none of these files):
- mote: go test -count=1 ./internal/ccswitchlink ./internal/cli
  ./internal/gui ok; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build ok; gofmt -l empty.
- wsl-run (magpie-desktop) and win-run (xiaomi-gpu): go test -count=1
  -v ./internal/ccswitchlink ok (Windows writes a test key of its own,
  Software\Classes\magpie-test-ccswitch-<pid>, removed after).
- Full suite on mica (go test -count=1 -timeout 45m ./..., on
  d74754970): 101 packages ok; reds, all filed and none in a package this
  touches: internal/dirent's watch tests (#7031; red alone on a fresh
  origin/main 589e4ba6d too), TestGatewayModeListsNoOwnSessions (#7064)
  and TestWSLStoppedDistroKept (#7071), both ok alone on mica.
- After the rebase on 589e4ba6d: go vet ./..., GOOS=linux go vet -tags
  nogui ./..., GOOS=windows go vet ./..., go build, gofmt -l on mote ok;
  ./internal/ccswitchlink and ./internal/gui ok on mote; ./internal/cli
  ok on mica. On mote three cli tests reach the 127.0.0.1:3425 an ssh
  port forward holds there (#6223).
- Real, macOS (mote, in ~/runs, cleaned up with lsregister -u): a test
  bundle registered with the old ccswitch claim kept it 5s after its
  Info.plist was rewritten without it; the built Forward then opened
  the real CC Switch v4.0.35 app and the dump showed the claim gone.
  Without CC Switch registered it returned ErrNotInstalled.
- Real, Linux (magpie-desktop, sandbox HOME and XDG dirs): with
  magpie-ccswitch.desktop as the real xdg-mime default, Forward ran
  cc-switch-handler.desktop's Exec with the link and the default was
  cc-switch-handler.desktop after.
- Broken by hand: no lsregister call (darwin), no xdg-mime default
  (linux) and no handBack (windows) each turned their test red.
- GUI suite: not run; no page, app.js or i18n change.

Not tried: a real CC Switch install on Windows (the box's real HKCU
ccswitch key is left alone; the test uses its own key), and a real
CC Switch .deb or AppImage on Linux (its entry was faked with the
package's own bytes).
2026-11-18 20:07:09 +08:00
yetone 389169f761 gateway: a Qwen Token Plan's TTS, ASR and video models are served on OpenAI's routes
gaubeebangeel on X (tweet 2122991088017477954) asked for every kind of
model Alibaba's Token Plan sells, each on its own DashScope endpoint.
Before this, magpie served the plan's text (Anthropic and chat
completions), its realtime voice (/v1/realtime, realtime.go) and its
Qwen-Image drawing (draw_dashscope.go). The plan's text list lacked
deepseek-v4.1-flash-1017, and nothing served its TTS, ASR or video
models.

- presets: alibabaPlanModels as the four plans' overviews list them on
  11-18 (qwen4-max, qwen4-max-preview, deepseek-v4.1-flash-1017 added).
  PresetDef gains Drawers, Videos, Speakers and Transcribers, Region
  gains Speakers and Transcribers, and the four Token Plans
  (qwen-token-plan, bailian-token-plan, alibaba-token-plan,
  qwencloud-token-plan) name qwen-image-3.0-pro and wan2.7-image(-pro),
  wan3.0-video and happyhorse-1.1-t2v/-i2v/-r2v, qwen-audio-3.0-tts-plus
  and qwen-audio-3.0-asr-flash. PlanSpeakers and PlanTranscribers feed
  PlanRetrieval, so the router knows which provider speaks and
  transcribes.
- /v1/audio/speech (speech_dashscope.go): a plan key's qwen-audio TTS
  model is asked on <root>/api/v1/services/audio/tts/SpeechSynthesizer,
  every field under input as the docs have them. An OpenAI voice name
  becomes the model's own first voice (longanlingxin for -plus,
  longanhuan_v3.6 for -flash), speed goes as rate (0.5 to 2), and
  instructions as instruction. mp3, wav, pcm and opus are served; aac,
  flac and stream_format sse are 400s before DashScope is asked. The
  answer's output.audio.url is fetched (or data decoded) and served with
  the format's type.
- /v1/audio/transcriptions: a plan key's qwen-audio ASR model goes to
  multimodal-generation with the file as an input_audio data URI, its
  format from the file's name or type, and language as language_hints.
  The answer is given back as OpenAI's json, text or verbose_json; srt,
  vtt and translations are 400s. The form's file is read only on this
  path (audioForm.file), so a form passed on as sent is never copied.
- /v1/videos (video_dashscope.go): Wan 3.0 and HappyHorse start at
  video-synthesis with X-DashScope-Async: enable and are polled at
  /api/v1/tasks/<id>. The id carries the model and the key's mark, as
  MiniMax's does. vendorAsk.answer now takes the request's context, so
  the TTS answer's audio URL is fetched under it.

Hosts, paths, fields and voices were checked against Alibaba's docs
(help.aliyun.com model-studio qwen-audio-tts/asr HTTP API and Wan 3.0
video reference, docs.qwencloud.com Token Plan multimodal pages,
platform.qianwenai.com token-plan), not against the tweet. Not tried
against the real API: the owner's magpie has no Token Plan provider.
The tests use a fake DashScope serving the docs' shapes.

Run (on mote via mote-run, tree at 8634c4ad0 plus this diff):
- gofmt -l internal/: nothing.
- go test -count=1 -run 'TokenPlan|DashScope|Speech|Transcri|Video|Plan|Qwen|Qianwen|Alibaba'
  ./internal/gateway ./internal/provider ./internal/gui: ok, ok, ok.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., go build, GOOS=linux go build -tags nogui, GOOS=windows go
  build: all ok.
- go test -count=1 -timeout 45m ./...: 101 packages ok; internal/cli and
  internal/gui red on TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
  TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr,
  TestUpdateFindsAMagpieThatWroteNoRecord (#6223, #6471) and
  TestLaneLimitRoutes (#5150). mote has an ssh forward listening on
  127.0.0.1:3425, which those tests read. All four are red the same way,
  run alone on mote, at a just-fetched origin/main 589e4ba6d.
- Broken by hand: with the X-DashScope-Async header dropped,
  TestTokenPlanMakesVideos goes red (403 "does not support synchronous
  calls"); with -plus's default voice changed to alloy,
  TestTokenPlanSpeaks goes red.
- GUI: no asset changed, and the .cjs files run app.js on fixtures, so
  none can be reached. The Go GUI API that lists the plans' models ran
  in ./internal/gui above.
- Rebased on origin/main 589e4ba6d (6 commits, none touching these
  files) and run again at this head on mote: gofmt -l nothing; the
  targeted run above ok, ok, ok; vet (darwin, linux nogui, windows) of
  ./internal/gateway ./internal/provider and the three builds ok.
2026-11-18 19:59:27 +08:00
yetone 589e4ba6da agent: OpenCode finds magpie's models itself; opencode.json no longer lists them
chawyehsu on X asked for dynamic model discovery, as
yuhp/opencode-models-discovery does. magpie wrote its whole catalog into
opencode.json's magpie provider. For an OpenCode that loads plugins of
today's shape (1.4.0 and later, 2.0.5 and later; openCodeDiscovers),
the provider now has no "models". magpie writes plugins/magpie-models.js
beside the file (opencode_models.js, marked by its first line). It fills
the provider's models as OpenCode starts, from the gateway's new
/v1/models?format=opencode (opencode2 for OpenCode 2;
gateway/opencode_models.go). That endpoint gives the same entries a sync
would have listed, in magpie's order, never cached, and only the
models of OpenCode's catalog the key asking may use (keyListed).

- OpenCode 1: through its config hook, which runs before it reads
  providers. The user's entries under magpie's provider are laid over
  magpie's, and an id magpie doesn't list stays.
- OpenCode 2: through ctx.model.transform. The config's own entries are
  laid on afterwards by OpenCode. Every entry says variants ([] for
  none), so OpenCode makes up none.
- Gateway not answering (3s timeout): the plugin lists the models magpie
  had when it last wrote it.

Existing users: the first sync on such an OpenCode takes magpie's list
out of the file (modelsLeft). Of each model, only what the user said
differently stays: their own variant, or a limit.output they typed. A
limit or cost they changed stays whole, since OpenCode 1.19.6 refuses
one without its context ("Missing key ...limit.context"). An id magpie
no longer lists goes that once (stash opencode-discover:<path>), as it
did on every sync before; one added after that is the user's and stays.
The user's other keys and providers are untouched. These keep the list
in the file as before: an OpenCode older than those versions, of no
known version, and the forks (mimocode, DevEco, Air). Going back to
such an OpenCode writes the list again and removes the plugin, and so
does taking magpie out. A file at the plugin's path without magpie's
first line is the user's and is never touched.

Run:
- mote-run go vet ./internal/agent ./internal/gateway, also with
  GOOS=linux and GOOS=windows: clean. gofmt -l: clean.
- mote-run go test ./internal/agent -run
  'OpenCode|OpenChamber|Air|DevEco|Mimo': ok (TestOpenCodePluginRuns runs
  the plugin in node against a stubbed gateway, up and down, v1 and v2).
- mote-run go test ./internal/gateway -run 'TestOpenCodeModelsList|Models': ok.
- Broken by hand, each red: no key filter (TestOpenCodeModelsList),
  openCodeDiscovers always false (Finds/ListMoves/DiscoversFrom), the
  delta keeping whole models (ListMoves), and the plugin letting magpie's
  fields win over the user's (PluginRuns).
- Three opencode_v2 tests that check the listed words now pin 2.0.4 and
  1.3.9, which still list.
- Real OpenCode on mote in a sandbox HOME, opencode-ai 1.19.6 and
  @opencode/cli 2.3.2. Config and plugin written by magpie's own code, a
  fake /v1/models serving one extra model:
  - `opencode models` lists the served model with the gateway up, and
    the cached list with it down. Both versions, Bearer key sent.
  - A file moved from 1.3.9/2.0.4 with a user limit.output and a user
    model: `opencode models magpie --verbose` (1.19.6) and
    `opencode api --standalone GET /api/model` (2.3.2) resolve magpie's
    models the same as the old full-list file did. Names, limits,
    variants and the user's edits are identical; 2.3.2 orders a model
    the file names first.
- Full suite: mote-run go test ./... -timeout 45m -count=1 on this change over base 1bfa8d5a1: 103 packages ok, no FAIL.
- Rebased on 7300be4d0 (main touched agents.go and gateway.go): go vet
  darwin/linux/windows of internal/agent and internal/gateway clean;
  go test ./internal/agent ok; ./internal/gateway red only in
  TestSearchQueueKeepsCodexAlive/comments and /cancel at load ~37, the
  idle-bar class of #7090 (commented), 5/5 ok alone at this head.
- Not changed: the forks mimocode, DevEco and Air keep the list; filed as #7055.
Not tried: a WSL distro's OpenCode, and OpenChamber's own UI over the
plugin-filled provider.
2026-11-18 19:47:19 +08:00
yetone 7300be4d01 gateway: find_tools says no tool was found instead of handing over near names
sahuaja3669 on X (tweet 2122928458355319211), on the on-demand router:
it shouldn't pad its answer with tools of a near name that do something
else, and it should say plainly when nothing was found.

Before, find_tools counted any query word found as a substring of a
tool's name or description, stop words and single letters included. "a"
is in nearly every name, so "send an email" against GitHub, filesystem,
Linear, magpie-image and magpie-browser gave five tools in full
(search_code, read_file, write_file, ...) as matches, with nothing saying
they were weak; a query nothing matched did say so.

Now find_tools matches on the query's key words (stop words such as a,
the, to, my left out), each a whole word of the name or description or
the start of one at four letters or more (open/opens, issue/issues; a
non-ASCII word anywhere, as before). A tool is a match only when the
query is its name, or it has two thirds of the key words, one in its
name unless it has them all. When none clears that, the answer says no
tool was found and not to call one that only sounds close, and names
each server with its tool count and up to 8 of its tool names, as what
there is rather than as matches. call_tool's "close to it" for an
unknown name keeps a looser rule (a key word shared with the name,
hubNear), so create_isue still points to create_issue. Cheap and
deterministic: word lists, no model, no index.

The cost: a query in other words than the tool's ("draw an image of a
cat" for generate_image) now finds nothing, and the model reads
generate_image from the server list in the answer, and from find_tools'
description, which already names each server's tools.

Test: TestHubFindNothingClose, on real descriptions from
github-mcp-server, the reference filesystem server, Linear's, and
magpie-image's and magpie-browser's own. Red on the old
hub_ondemand.go: "send an email" matched eight tools or more, five in full.
docs/subsystems/mcp-router.md updated.

Run:
- full go test ./... -count=1 -timeout 45m on mote at 5c32b285d (on
  48fffb60c): every package ok, internal/gateway 1392s.
- full go test ./... -count=1 -timeout 45m on mica at 1acbfcc23 (on
  3e66d25d8), mote over its load: 100 packages ok, three red, none in
  code this touches: internal/dirent's watch tests (red on mica at
  3e66d25d8 alone too, ok on mote; #7031), internal/sessions
  TestWSLStoppedSinceNotOpened (internal/sessions doesn't import
  gateway; red 1 of 4 on mica at 3e66d25d8 alone, ok on mote; filed
  #7089), internal/gateway TestSearchQueueKeepsCodexAlive/progress (ok
  3 of 3 alone; filed #7090).
- at the pushed head 22647c27f (on e199eb9c7): go test ./internal/gateway
  -count=1 -timeout 45m on mica ok (1306s); go vet ./internal/gateway
  for darwin, linux and windows ok; gofmt -l clean.
- rebased onto d2fa7d8d7 to push (four commits: sessions, library, and
  d74754970's system-message placement in gateway, none in the hub);
  there go test ./internal/gateway -run 'Hub|MCP|Search|Message|System'
  ok on mica, go vet ok. 65c9a2e41 there addresses #7089's WSL wait.
Not tried: a real agent driving find_tools against a live router.
2026-11-18 18:58:55 +08:00
yetone d2fa7d8d79 sessions: an Antigravity app conversation shows what was said, not only its title
@yansheng1003 on X: the Sessions page showed an Antigravity 2.0
conversation's title and preview only. HasTranscript left "antigravity"
out, since conversations/<id>.db's step text is encrypted at rest, so
the row had no Show conversation and /api/sessions/transcript said
"this agent's conversations can't be shown".

The app also writes every step in plain text beside the database:
brain/<id>/.system_generated/logs/transcript_full.jsonl in the same
store, in agy CLI's format (user input, planner responses with their
tool_calls, tool results). Antigravity 2.30's language server writes it
in the stable store and in Insiders' (both checked: run in a sandbox
HOME on Windows against a fake model that called read_file).

- transcript.go: antigravity has a transcript; readTranscriptOf reads
  it through agyTranscript (antigravityTranscriptOf), so the viewer,
  TranscriptAt, search, the said index and the Markdown export all get
  it. A conversation with no transcript file is ErrNoTranscript, as
  before.
- antigravity_app.go: antigravityTranscript derives the path from the
  database's (stable, Insiders, a WSL distro's); its size and time are
  folded into the session file's with the -wal's, so a step it adds
  reads the session and the said index again.
- search.go: linesFile is false for antigravity, so the encrypted .db is
  never pre-scanned for the words.
- testdata/antigravity-2.30-tools: that real conversation (db with the
  WAL checkpointed, summary row, brain/ logs).

Tests: TestAntigravityAppTranscript (stable, Insiders, WSL: parts, search
hit and miss, Markdown), TestAntigravityAppNoTranscript,
internal/gui TestSessionAntigravityConversation (/api/sessions marks it,
/api/sessions/transcript gives the five parts).

Run: on mica (mica-run) at base de5fc6700:
- gofmt -l internal/sessions internal/gui: clean.
- go vet ./internal/sessions ./internal/gui, GOOS=linux go vet -tags
  nogui and GOOS=windows go vet on the same, go build .: ok.
- go test -count=1 -timeout 45m ./internal/sessions: ok but for
  TestWSLAgentsGoneListingDrops (load ~48; fixed at its cause in the
  commit before this one); go test ./internal/gui: ok (299s).
- After that fix: go test -run 'WSL|Antigravity|Agy|Gone'
  ./internal/sessions ok; GUI files sessions-talk, -talk-sheet,
  -talk-model, -export, -said, -subagents, -reads, -search, -convert:
  168 of 168 in Chromium and WebKit.
- Old code (de5fc6700 with only the new tests and testdata):
  TestAntigravityAppTranscript red in stable, insiders and wsl ("the
  session isn't marked readable"), TestSessionAntigravityConversation
  red ("listed with no conversation to show ... Transcript:false").
- Windows (win-run on xiaomi-gpu): TestAntigravityAppTranscript (3
  subtests) and TestAntigravityAppNoTranscript pass.
  TestAntigravityAppFolder is red there at the base as well (#5957).
Rebased onto bfddc9cfb, on mote (mote-run) at this tree: gofmt clean,
the three vets and go build ok, go test -count=1 ./internal/sessions
./internal/gui ok (56s, 157s).
Not tried: the real GUI window opening this conversation; the API and
page are covered by the tests above.
2026-11-18 18:55:46 +08:00
yetone bfddc9cfba routing: DimCode's requests read as DimCode, with its mark, by key too
Yayoi_no_yume on X, a Docker magpie (v0.1.4350): DimCode (dimcode.dev)
on another computer, calling with a gateway key named "Magpie", drew
the Routing page's client node as the cube and "Magpie", and the
request's story said "DimAgent asked for the routing group Step 5
Preview".

Two causes:
- DimCode was no client magpie knew, so usage.AgentOf named it by its
  product name: npm's dimagent 0.5.29 sends "DimAgent/<version>" to a
  provider set to send its identity (resolveDimOAuthIdentityHeaders)
  and "DimCode/<version>" otherwise (read from the published binary).
  A client "dimcode" (DimCode, UA dimagent/dimcode) now names it,
  apart from the Dim alpha magpie starts ("dima"/"dimcode-alpha" stay
  Dim's, by name first). Its icon is dim-color: dimcode.dev's favicon
  (dimagent-favicon.svg, "Official DimAgent mark") is the same artwork.
  Routes and ledger records kept before are named again through
  AgentOf (Route.routedAgain), so old "DimAgent" rows read as DimCode.
- A keyed request's node read the key's name alone (eadc6cdb9, for a
  script's key behind "Python-urllib"). An agent magpie knows now
  reads "agent · key", as Usage's ledger rows already do; a script's
  key keeps the key's name alone. The tooltip names the agent once.
  The tray panel's stage and rows share callerName and read the same.

The icon comes from the embedded assets, which the web (Docker) build
serves the same way; the GUI test checks the image loads.

Run on mote:
- go vet ./internal/agent, GOOS=linux -tags nogui and GOOS=windows:
  ok. go test -count=1 ./internal/agent ./internal/usage: ok (agent 463s, usage 124s)
- TestDimCodeByUserAgent is red with the dimcode entry taken out
  (AgentOf("DimAgent/0.5.29") = "DimAgent").
- GUI, chromium and webkit, every language, 1100 and 420:
  routing-agent-with-key.test.cjs (new), i18n-keys, i18n-en-no-cjk:
  30 of 30 pass. Earlier, on mica, with the same client.js: the 28 other
  files that read callerKey, .rt-src, .ps-name/.ps-ag or .pr-who pass
  but api-key-usage (#7083) and usage-ledger's return-to-live case
  (#5048), both red on origin/main 2416beed6 too.
  routing-agent-with-key is red on the old client.js ('Magpie' for
  'DimCode · Magpie').

Not tried: a real DimCode against a real Docker magpie; the
User-Agents come from the published binary and the reporter's log.
2026-11-18 18:03:16 +08:00
yetone 71b8ab46c1 gateway: Codex's compaction on Open Design goes without empty tools, and its upstream_error is asked again (Mugenrikka on X)
Codex compacting on any Open Design model got 400 "[code=upstream_error]
Provider returned error" from amr-link, while other providers compacted.
Codex's compaction is its one request with "tools": [], and the summary
ask adds tool_choice and parallel_tool_calls beside them (#292). Since
plugins 0.1.13 / 48f976402 the Responses body is relayed to amr-link as
written, and an OpenAI-style validator refuses empty tools and a lone
tool_choice.

- passthrough: a Responses request to Open Design (its plugin, or a
  provider at amr-link.open-design.ai) goes without an empty tools list
  and the tool_choice/parallel_tool_calls beside it (withoutEmptyTools).
  A body that declares a tool is unchanged; every other upstream is sent
  Codex's shape as before.
- codexCompact: amr-link's "[code=upstream_error]" counts as
  upstreamFailed, so a summary still refused is asked as sent, then as
  text, then made locally, never handed to Codex as the 400.
  upstreamFailed is only used by the compaction ladder.

Run (mote; the suite at 54117164c, then rebased on 1bfa8d5a1 and
-run 'OpenDesign|Compact' ./internal/gateway run again there: ok):
- TestOpenDesignCompactionSendsNoEmptyTools and
  TestOpenDesignCompactionRefusedAsksAsText, built from Codex Desktop
  26.1007's real compaction (testdata/codex-26.1007-compaction.json)
  through the fake plugin as opendesign: both red on the old
  gateway.go/codex_backend.go with the reporter's 400, green with them.
- go test -run 'OpenDesign|Compact|LoneToolChoice|ToolsOff' ./internal/gateway ok.
- go test -timeout 45m ./...: every package ok.
- go vet (darwin), GOOS=linux -tags nogui and GOOS=windows vet of
  internal/gateway ok; gofmt -l clean.

Not tried: a real Open Design account (none here). Which of the empty
tools, the lone choices or the history's calls amr-link refuses is not
confirmed; the second change covers whichever it is.
2026-11-18 17:58:02 +08:00
yetone 54117164cd gateway: a Claude account Anthropic turned off moves on and rests as restricted
When Anthropic turns a Claude subscription account off, the request now
goes on to the routing group's next member and the provider's other
accounts, and the account rests as restricted (2h) instead of a short
failure rest. Before, a disabled organization's 400 ended the group at
that account and its next members were never asked (Ramon317317 on X),
and Claude Code's "account is on hold" came back from the bridge as a
502 that rested the account a minute and asked it again.

The words (claudeOffWords, routing.go): "This organization has been
disabled." (400 invalid_request_error or 403), "account is on hold and
can't use Claude Code" (the bridge now answers it as a 403),
"organization has disabled Claude subscription access", "OAuth
authentication is currently not allowed for this organization", and
"account can't receive replies from Claude" (either apostrophe, or
"cannot"). claudeAccountOff scopes them to a Claude subscription account
or a key on api.anthropic.com. A relay's same words are about the
relay's own account behind it, so they stay ordinary failures there, as
on Codex. The extra-usage and Usage Policy refusals are not account
faults and are unchanged. riskRefused keeps the provider's other
accounts in, as for Google's suspension.

Docs: claude-subscription-bridge.md and gateway-routing.md updated.

Run at f357a5e25 (this commit on origin/main f7e0f68ca), on mote:
- new tests (TestClaudeAccountOffMovesToNextAccount,
  TestClaudeOrgDisabledGroupMovesOn, TestClaudeAccountOffScoped):
  51 PASS lines, 0 FAIL.
- Broken by hand: routing.go, fallback.go and claude_subscription.go put
  back to the parent's, with a claudeAccountOff stub returning false so
  the test compiles: all 3 tests fail, 35 FAIL lines (32 subtests), 16
  pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- go test ./... -timeout 45m: every package ok (103 ok lines), rc 0.

Then rebased on origin/main a2d402afe (six commits, internal/gui, site/
and docs/ only) and run again at the pushed head, on mote: gofmt -l
nothing; go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
go vet ./... ok; go test -count=1 ./internal/gateway ./internal/gui ok.
Rebased again on 1318864d1 (internal/agent, internal/provider,
internal/sessions; none touched here) and run at this head: gofmt and
the three vets as above ok; go test -count=1 ./internal/gateway
./internal/provider ok.
main moved once more (3e66d25d8, 03314b25a: internal/agent, catalog,
gui import links, provider's CC Switch import; none touched here), and
this pushed head was run with gofmt, the three vets ok and the new tests
(51 PASS, 0 FAIL); the gateway package as a whole last ran at 1318864d1.

Not counted: an earlier full run on mica at an older base was voided
because mica's disk filled mid-run (253 "no space left on device"
failures). Its three internal/dirent reds (TestWatchesFromOneMarkProbeOnce,
TestWatchedFolderReadOnlyWhenChanged, TestFileHeldOpenStillSeen) did not
come back in the mote run above. mote's 1-minute load was ~39 on 18 cores
during the run, with no other full suite there.

Not tried: a real disabled or on-hold Claude account; the bodies are
from Claude Code's errors page and users' reports.
2026-11-18 17:09:18 +08:00
yetone 3ec89c5224 codex: the takeover's end waits for the chats on magpie the Codex app has open (milianxinqi on X)
milianxinqi on X, the Codex app: "Model provider mismatch. This chat uses
magpie, but your current provider is OpenAI. Switch to magpie to
continue." ("用的好好的,codex 突然就弹这个了"), with nothing disconnected.

Cause. With the ChatGPT account Codex is signed in to held (out of its
allowance and credits), magpie is Codex's provider (the codex.out
takeover, #540) and new chats start on magpie. When the account has room
again (its window's reset, a switch to another account, or the account
the user keeps Codex on, a5e3972a7), Sync ended the takeover at once:
model_provider out of config.toml, Codex back on OpenAI. The Codex app
keeps the app-server the takeover started (codexAppStep leaves it
running unless Restart the Codex app to follow is on, off by default,
#4550), with its chats loaded and each one's writer lock held, so
bringBack could move none of them and codexRetagOpenThreads never ran
(it runs only before magpie ends the app-server). Every send in an open
chat then met the mismatch, with no step of the user's.

Fix. outStays (agent/codex.go): the takeover's end in Sync, both the
out_own way back and #540's, waits while a Codex holds a chat on magpie
open or wrote to one in the last minute (codexHeldOnMagpie:
sessions.CodexThreadsBusyOnBut, T3 Code's own threads left out, as
codexRetagOpenThreads leaves them), and codexThreadsLater asks for the
Sync that ends it once they are let go; bringBack then moves them onto
OpenAI. Meanwhile magpie serves them on the account, which has room, and
the app on the takeover's app-server shows no account either way. Nothing
waits when the app-server is restarted for the change (Restart the Codex
app to follow on, provider.CodexRestartsApp) or the user turned the
takeover off (Always ChatGPT): that restart moves the open chats first.
The [model_providers.magpie] table already stays after a Disconnect, so
an old thread still opens; a deliberate Disconnect restarts the
app-server (byHand) and retags its chats.

Other paths looked at and left: Disconnect, Unwire, Join and Codex's
account switch go through the same bringBack/retag; RestoreOnQuit (off by
default) runs at quit only; the update restart hands the gateway over on
macOS and Linux and skips it. On Windows a restart runs RestoreOnQuit
when it is on: filed separately.

Tests:
- TestCodexTakeoverWaitsForTheOpenChat (new): takeover, a chat on magpie
  quiet but its lock held, account back: still magpie's provider, the
  chat on magpie, no Sync asked; lock let go: a Sync asked, which ends
  the takeover and moves the chat to openai.
- TestCodexTakeoverEndsAtOnceWhenTheAppFollows (new): with the app
  restarted for the change, nothing waits.
- TestCodexTakeoverThreadComesBackOnceQuiet (nb5p): now the takeover
  stays while the thread is written to, and ends at the later Sync.
Broken by hand: outStays' gate taken out of Sync: the new test and nb5p's
red ("Codex was put on OpenAI under it"), green with it.

Run (mica, mote over its load, at this tree on origin/main 48fffb60c):
- go test -count=1 -timeout 45m ./internal/agent ./internal/sessions
  ./internal/provider: ok (426s, 1917s, 237s).
- go vet of those on darwin, GOOS=windows, GOOS=linux: ok. gofmt -l clean.
- Rebased onto origin/main a2d402afe (provider and sessions changes
  elsewhere): go build ./..., go vet of the three, and the takeover,
  thread-move and retag tests of internal/agent and internal/sessions
  again: ok.

Not tried: the real Codex app through a real reset (needs an account
held then given room); a full ./... run (mica had another session's full
suite and GUI suite running).
2026-11-18 16:33:04 +08:00
yetone c5cb1c0588 gui: the tray's logo is 16pt, as large as other apps' menu bar icons
qingnianxiaozhe on X: magpie's A\ in the menu bar looked a size smaller
than another app's A\ beside it. magpie fitted each logo to a 14pt box,
so the A\ (about 1.37:1) drew 14x10pt. Claude.app's menu bar template
(TrayIconTemplate@2x.png, 48x48 px) has 32x32 px of ink, a 16pt glyph,
and in the reporter's screenshot the other A\ is 32x22 px against
magpie's 28x20 px at 2x. mpLogo is now 16; the letter in a ring (a logo
that can't be read) grows with it. The two 10pt rows of percentages are
unchanged and still fit the 22pt bar.

Tests: the logo boxes in the tray tests follow the 16pt box (offsets 28
-> 32, 34 -> 38 px at 2x); TestTrayImageLogoSizes now wants 27-33 px of
a 32 px box.

Run on mote (macOS 27.2):
- go test ./internal/gui -run Tray -count=1 -v: ok.
- Broken by hand (mpLogo back to 14): TestTrayImageLogoSizes FAILs
  ("alma spans 24 px of a 32 px box", codex/zcode/workbuddy 26 px) and
  TestTrayImagePlain FAILs ("238 px with logos, 182 without").
- Rendered by the real drawing code (trayImagePNG, 22pt bar at 2x)
  next to Claude.app's own template icon: the A\ is 28 px wide before
  and 32x24 px of ink after, as wide as Claude's 32 px spark; the
  percentages are the same text at the same size. The before/after
  strips are kept outside the repo (tray-toolbar-scratch/before and
  after/strip-{light,dark}.png).
Suite and checks, on mote at aa31e737c8d271455865615fafdf512e09073663 (this commit and its pair, the
tray logo size / the toolbar menu):
- go test -count=1 -timeout 45m ./... in a sandbox HOME, caches pinned:
  exit 0, 103 packages ok, none FAIL (internal/gateway 1633s,
  internal/agent 949s, internal/provider 470s, internal/gui 295s).
- gofmt -l internal/gui: nothing. go vet ./..., GOOS=linux go vet -tags
  nogui ./..., GOOS=windows go vet ./..., go build, GOOS=linux go build
  -tags nogui, GOOS=windows go build: all ok.
- No GUI asset changed, so the Playwright suite wasn't run.
After a rebase onto 42c43c002 (Antigravity sessions, internal/gui
sessions reads; no file in common), at the pushed head:
go vet, GOOS=windows and GOOS=linux -tags nogui go vet of ./internal/gui/...
and go test -count=1 ./internal/gui/...: ok.
Then rebased onto f7e0f68ca (Codex instructions, internal/provider
only), not run again.

Not tried: a screen screenshot of the real menu bar (no Screen
Recording permission over ssh on mote; the image is the one the app
hands NSStatusItem); the reporter's notch Mac, where the bar is 24pt.
2026-11-18 16:08:15 +08:00
yetone add1e75ee3 gui: no Icon and Text menu on a right-click by the traffic lights
AlanWang1027713 on X: a right-click on the main window's title bar, by
the lights, offered "Icon and Text / Icon Only / Text Only". It comes
from the empty NSToolbar that MacTitleBarHiddenInset puts there to
inset the lights; NSThemeFrame's menuForEvent: lists its display modes.
insetLights takes the toolbar away only in the macOS 26 design, so on
macOS 27, with an older SDK and in a right-to-left layout the toolbar,
and its menu, stayed.

quietToolbar turns the menu off where the toolbar stays:
allowsDisplayModeCustomization = NO (macOS 15+), and AppKit's own
_setWantsToolbarContextMenu: NO for macOS 12-14, each looked up with
respondsToSelector, since the SDK that builds magpie may be older than
the system it runs on. Nothing about the title bar's shape changes.

windowshape.Of now reads the menu a right-click 20pt below the top,
120pt in, gets from the window frame (TitlebarMenu), and
TestMainWindowCorners and TestMainWindowRightToLeft fail when the main
window gets one, or when the reference toolbar window doesn't (so the
probe is proven to see it).

Run on mote (macOS 27.2), real makeMain window:
- go test ./internal/gui -run 'TestMainWindowCorners|TestMainWindowRightToLeft'
  -count=1 -v: ok. Each stage logs "title bar menu []" next to the
  reference toolbar window's ["Icon and Text" "Icon Only" "Text Only" "-"]
  (macOS 26 SDK) and ["-"] (macOS 15 SDK). Lights [[26 26] [49 26] [72 26]],
  66pt title bar and 16pt corners with the 26 SDK, [[19 19] [39 19]
  [59 19]] and 38pt with the 15 SDK: the same as without the change.
- Broken by hand (quietToolbar call taken out): both FAIL, "a right-click
  on the title bar gets a menu: ["Icon and Text" "Icon Only" "Text Only"
  "-"]" (26 SDK) and ["-"] (15 SDK).
- A probe app on mote: either switch alone empties the frame's menu.
Suite and checks, on mote at aa31e737c8d271455865615fafdf512e09073663 (this commit and its pair, the
tray logo size / the toolbar menu):
- go test -count=1 -timeout 45m ./... in a sandbox HOME, caches pinned:
  exit 0, 103 packages ok, none FAIL (internal/gateway 1633s,
  internal/agent 949s, internal/provider 470s, internal/gui 295s).
- gofmt -l internal/gui: nothing. go vet ./..., GOOS=linux go vet -tags
  nogui ./..., GOOS=windows go vet ./..., go build, GOOS=linux go build
  -tags nogui, GOOS=windows go build: all ok.
- No GUI asset changed, so the Playwright suite wasn't run.
After a rebase onto 42c43c002 (Antigravity sessions, internal/gui
sessions reads; no file in common), at the pushed head:
go vet, GOOS=windows and GOOS=linux -tags nogui go vet of ./internal/gui/...
and go test -count=1 ./internal/gui/...: ok.
Then rebased onto f7e0f68ca (Codex instructions, internal/provider
only), not run again.

Not tried: a screen screenshot (screencapture over ssh has no Screen
Recording permission on mote; the menu is read from AppKit instead);
macOS 12-14, where only the private selector applies.
2026-11-18 16:08:15 +08:00
yetone 42c43c0020 sessions: an agent found after Allow selected is asked about once (Antigravity 2.0)
baysonfox on X: Antigravity 2.0 desktop sessions showed on the Sessions
page only while the app was connected to magpie; agy CLI's always showed.

Cause: not the file reader. Real Antigravity 2.30 (signed out, no model,
sandbox HOME on the Windows box) writes ~/.gemini/antigravity/
conversations/<id>.db, conversation_summaries.db and brain/, and
internal/sessions parses them. The gate is settings.SessionReads:
"Allow selected" (and the Usage readsNote's "Count …") saves all:false,
so an agent installed after that choice is never read and never asked
about again. Gateway-recorded sessions skip the gate, hence "only when
connected".

Fix: /api/sessions/reads marks a found agent `new` when the choice was
made, it isn't read, isn't named in Agents and is on disk (Found(), which
checks every OS's path). The Sessions page shows one quiet card for those
(laterCard): "Show their sessions" names each on, "Keep off" names each
off, so it isn't asked again. No new endpoint; the card posts the
existing sessions/reads.

Tests: TestSessionReadsNewAgent copies the real 2.30 files
(internal/sessions/testdata/antigravity-2.30, sandbox paths only, no
tokens) beside agy-sessions, with agy allowed by name: antigravity is
off and new, nothing listed; after the answer it is not new, settings
keep all:false/agy:true, and its one session is listed only when shown.
TestSessionReadsNewOnlyWhenNamed: not asked, allow all, all with agy off
mark nothing new. sessions-reads.test.cjs: the card, both answers, posts
and no card after reload, Chromium and WebKit, 5 languages, 900/390px.

Run at d7d62d889, on mote, then rebased onto 48fffb60c (app.js and
settings-groups only, no file in common):
- gofmt -l, node --check client.js/i18n.js: clean
- go vet ./internal/gui ./internal/sessions; GOOS=linux -tags nogui and
  GOOS=windows go vet of the same: ok; go build .: ok
- go test -count=1 ./internal/sessions: ok (282s)
- go test -run 'TestSessionReads|TestCoreScript|TestI18n|TestCSS'
  ./internal/gui: ok
- GUI: sessions*.test.cjs (45 files), usage-reads-note,
  gateway-mode-sessions, i18n-keys, window-back-once: 711/711 pass
Broken by hand: New forced false, TestSessionReadsNewAgent red in both
subtests ("want off and new"). An earlier "Allow" button label was red
in i18n-keys (core word, internal/agent/reach.go), hence the label.
Not run: the whole GUI suite and the full go test ./... (mote and mica
were overloaded, mica's disk full). Not tried: a real Antigravity 2.0
on macOS/Linux; Found() paths for those come from the existing reader.
Not changed: the Usage page's readsNote still shows only before the
choice; Found() doesn't look into WSL distros.
2026-11-18 16:04:10 +08:00