Commit Graph
3225 Commits
Author SHA1 Message Date
yetone 88b4c00ea1 provider: a Codex token refresh, once sent, is waited for even when its caller gives up
willz on Discord: a Codex account that isn't the current one stops showing
its quota after a day or two and asks to be signed in again, while
requests on it still work; moving it to the top "fixes" it.

codexRefresh sent the refresh on the caller's context. OpenAI rotates the
refresh token as it answers, so a refresh whose caller went away mid-flight
(an agent's cancelled request, a usage read's deadline, the keep-alive's
2-minute run) dropped the answer and left magpie holding the spent refresh
token. The next refresh (the keep-alive forces one each day) is refused as
refresh_token_reused, the account is marked lapsed and its row says to sign
in, while the access token it still holds keeps serving requests. Moving it
to the top makes it the active account, whose lapse isn't shown.

Like siwcFresh (the ChatGPT API's refresh) already does, a refresh that has
been sent now runs on context.WithoutCancel with its own 30 s; a caller
already gone sends nothing.

The cause can't be confirmed without willz's log; this is the one path
found where a working account's refresh token is lost.

Run: TestCodexRefreshOutlivesItsCaller fails without the change
("context canceled") and passes with it; -race -count=10; the whole
internal/provider package (sandbox HOME); gofmt -l; go vet darwin,
GOOS=linux -tags nogui, GOOS=windows.
Not tried: a real Codex account.
2026-10-14 14:47:35 +08:00
yetone c8c3ce9a9a usage, sessions: Antigravity CLI's (agy's) own calls are counted, read from its transcripts, and a step it sent through magpie once (#2097, parkavenue9639)
agy wrote its calls nowhere magpie read. Each conversation's
brain/<id>/.system_generated/logs/transcript_full.jsonl has a line per step,
and a model step carries its own input_tokens, cache_read_tokens and
output_tokens. readAgyCalls reads those as agent agy, provider unknown
(session-unknown) and no model: the step names none, and settings.json's is
only the one picked now. A transcript an older agy wrote has the lines with
no token fields; they are left out, not counted as zero.

agy sends the gateway no session header, so its gateway records name no
session and the matcher, which pairs by session, would have counted a step
sent through magpie twice. matchedBlocks now pairs an agy step with a
session-less agy gateway record by tokens alone, and lets the record end up
to 30 minutes after the step's created_at, which is when the step began (to
the second), not when its call ended.

Tried for real: agy 1.2.16 under a sandbox HOME, with GEMINI_API_KEY and
GOOGLE_GEMINI_BASE_URL on a fake Gemini endpoint, three turns of one
conversation. It sent User-Agent google-genai-sdk/1.72.0, X-Goog-Api-Key and
no session header; its transcript's input_tokens is the prompt less the
cached tokens and output_tokens includes thoughtsTokenCount (8 + 40 = 48),
as the gateway counts a Gemini reply. A turn that failed to connect wrote
ERROR_MESSAGE steps with no tokens. That transcript is the fixture beside
the issue's quoted lines and an old one without tokens; the built binary's
`magpie usage --csv all` in that HOME lists the three steps as agy, log.

Run: TestAgyCalls and TestAgyStepThroughMagpieCountedOnce fail without the
change (0 agy calls; "the step the gateway logged is counted again"); gofmt
-l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on sessions and
usage; go build darwin, linux nogui, windows; go test -tags nogui of
internal/sessions, internal/usage, internal/usageapi, internal/cli in a
sandbox HOME, all ok.

Not tried: a step through a real magpie gateway and a real Google account
(the matcher's pairing is covered by the unit test with the gateway's
numbers from the fake run); agy on Windows or Linux; the full go test ./...
2026-10-14 14:35:23 +08:00
yetone 407595b2ab sessions: a Kimi Code session whose state.json names no folder takes it from session_index.jsonl (#2103, infinitr0us)
Early protocol 1.4 sessions and those migrated from the Python kimi-cli
(ses_* folders) have neither cwd nor workDir in state.json, so they were
listed under "No folder" and resumed with a bare `kimi --session <id>`.
Kimi Code's session_index.jsonl, at the root of its home beside sessions/,
has {sessionId, sessionDir, workDir} for every session (Kimi's
docs/en/configuration/data-locations.md). parseKimi now falls back to the
workDir of the index line whose sessionId is the session folder's name;
a folder state.json names still wins. The index is read again only when
its size or mtime changes. parseKimi is the only place a Kimi session's
folder is derived (the resume command is built from it).

Run:
- TestKimiCodeSessionFolderFromIndex (new): the reporter's 1.4 and
  migrated sessions get the index's folder and a `cd '<folder>' &&`
  resume; state.json's cwd beats a different index line; a session with
  no folder anywhere stays without one. With kimi.go put back it fails:
  `june folder ""`.
- go test -tags nogui ./internal/sessions/... under a sandbox HOME with
  pinned caches: ok.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean.

Not tried: a real Kimi Code home with an index (this machine's
~/.kimi-code has no sessions); the format is from Kimi's docs, the
reporter's line on the issue and Coffee-CLI's reader of the same file.
Not run: the full go test ./... suite.
2026-10-14 14:19:23 +08:00
yetone 2fbbd16945 gateway, gui: routing history keeps the last two levels of the folder an agent works in, and By session, the stage and the panel name it (#1068, emo172)
Routes now carry Folder: the last two levels of the working directory the
agent states (Claude Code's "Primary working directory", Codex's <cwd>,
Pi, OpenCode), cut by shortFolder before the route is stored, so no full
path reaches the routing history, /api, or the GUI. It is kept in the
routing history for as long as the history itself (30 days / 200 MB).
A request that states no folder (title, side calls) takes the folder its
session (or parent session) last stated; the per-session map is capped
at 512 entries.

GUI: By session headings read "Agent · folder · title", their tooltip
and every request row's tooltip (page and tray panel) name the folder,
the stage's agent subtitle lists the last level of each folder when an
agent works in more than one, and the panel's agent node tooltip lists
them.

Run:
- TestShortFolder (unix, trailing slash, C:\, D:\, UNC, CJK with spaces)
  and TestRouteKeepsItsFolderShort (real Handler, fake upstream: session
  inheritance, a moved Windows path, nothing of the full path in the
  marshalled routes, saveRoute -> History round trip), TestTurnDone.
  Broke it by hand: without the session lookup the title request has no
  folder; with the folder unshortened the full path shows. Both go red.
- routing-session-folder.test.cjs: chromium + webkit x en, zh, zh-TW,
  ja, de x 1100 and 420 px, 20/20. Red on the old routing.js and with
  the stage's live routes left out.
- GUI suites routing-*, panel-routing*, purpose-filter, reasoning-speed,
  gui-de/ja/zh-tw, click-scroll, number-units: 951/951.
- gofmt -l clean; go vet darwin, linux (nogui), windows; builds for all
  three. go test -tags nogui ./...: all ok except internal/gateway, which
  hit go test's default 10m timeout at 611s on a loaded machine (#2108);
  alone with -timeout 30m it passes in 356s.
- Real use: nogui build in a sandbox HOME, fake upstream, real Claude Code
  2.1.299 (claude -p) run from .../workspace/magpie and .../src/dial: the
  day's routing jsonl has folder "workspace/magpie" and "src/dial" and no
  part of the sandbox path above them.

Not tried: title/side requests' inheritance end to end with a real agent
(claude -p made none), Codex, OpenCode and Pi with real binaries, Windows.
2026-10-14 14:03:38 +08:00
yetone d9ca84a2f4 gateway: built-in TLS, magpie serve/web/daemon install --tls-cert --tls-key, reloaded on renewal (RoderickZH)
magpie serve, magpie web and magpie daemon install take --tls-cert <file>
--tls-key <file> (or MAGPIE_TLS_CERT / MAGPIE_TLS_KEY). The gateway and the
web UI on its listener then serve HTTPS to other computers. Without them
nothing changes.

- Half a pair, a file that doesn't parse, or a flag with no value is
  refused at start with a message naming the missing flag.
- The pair is re-read when either file's mtime or size changes (certbot
  renewal), with no restart. A renewal that doesn't parse keeps the
  certificate already served and is logged once.
- Other computers get HTTPS only. Plain HTTP from them gets net/http's
  400 "Client sent an HTTP request to an HTTPS server".
- This computer (loopback, or a peer address equal to the local one) may
  still use plain http on the same port. Its connections are sniffed on
  their own goroutine (a first byte of 0x16 is TLS) for up to 10s, so a
  silent client holds nobody else up. gateway.URL() stays
  http://127.0.0.1:<port>, which agents, MCP servers, ServedBy, the
  healthcheck and daemon status all use, and no certificate covers
  loopback.
- WSL NAT and containers count as other computers.
- ALPN is http/1.1 only (hijacked connections and websockets need it), with
  TLS 1.2 as the minimum.
- Printed links, LAN addresses, publicURL, the serve/web banners and
  daemon install show https:// for other computers' addresses.
- The DNS-rebinding Host checks (foreignPage, rebound, the MCP
  loopbackHost) don't depend on the scheme and are unchanged.
- daemon install carries MAGPIE_TLS_* into the unit or plist. A reinstall
  or `daemon web on` that names no certificate keeps the installed pair,
  and --no-tls removes it.
- Docs: reference.md gets an HTTPS section that names Caddy as the
  alternative, gateway-routing.md gets a TLS row, and docker.html (en,
  zh, ja) gets the env rows.

What was run:
- New tests: internal/gateway/tls_test.go (others HTTPS-only, this
  computer both, a silent local client holds no other, renewed
  certificate served, CheckTLS, addresses, Relisten keeps TLS),
  internal/cli/tls_cli_test.go and daemon TestInstallCarriesTLS (linux
  and darwin, paths with space, %, & and ").
- Each was broken by hand and went red: no wrap in listen, no reload, a
  synchronous sniff, a bad renewal dropping the certificate, http in
  publicURL or the pinned LANURLs, the carried entries removed, and
  keepTLS as a no-op.
- Real use under a sandbox HOME, with a self-signed pair, on
  0.0.0.0:3461:
  - Half a pair, a garbage certificate, a flag with no value, and the
    env set to half a pair each exit 1 with the message.
  - curl -k https://127.0.0.1 and https://<LAN IP>/v1/models with a key:
    200. Plain http on loopback: 200.
  - The cert files were swapped for a second pair while it ran.
    openssl s_client then showed the new CN and serial, and curl
    --cacert with the new pair got 200. A junk key file then kept the
    second pair, logged once.
  - From the Windows box over the LAN: plain http got 400; https with
    the key got 200, and without it 401.
  - magpie web --addr 0.0.0.0:3462: https network links. From Windows,
    http got 400 and https with the key got 303.
- gofmt -l clean. go vet passed on darwin, GOOS=linux -tags nogui and
  GOOS=windows.
- go test -tags nogui for ./internal/cli, ./internal/daemon, and the TLS
  tests of ./internal/gateway and ./internal/gui: all pass at the rebased
  head.
- Two reds in the full suite (`go test -tags nogui ./...`) are the same
  on origin/main f074996d9; both are filed:
  - TestGatewayHeldByAContainer failed 2 of 5 there (#2107).
  - The gateway package runs past go test's default 10m under load:
    1208s on main and 1221s here, both passing with -timeout 40m
    (#2108).
2026-10-14 13:36:03 +08:00
yetone 579de3baa0 agent: enabledModels lose a deselected model's entries after the catalog sync (#2055)
misaka9981: models deselected in a provider's editor left magpie's
provider in Pi's models.json, but their magpie/<provider>/<model>
entries stayed in settings.json's enabledModels, and Pi warned "No
models match pattern" for each at every start. Pi's resolver
(model-resolver.js resolveModelScope, 1.1.0) only warns, never prunes.

After the sync writes magpie's provider block, an enabledModels entry
that names one of magpie's models outright (no glob; a thinking level
read off) whose model the block no longer has is taken out. As the
entry may be the user's own, it is remembered in stash.json
(<agent>.scope.gone) and goes back on the list's end once the model is
offered again; a provider rename moves the remembered entries too and a
disconnect forgets them. Globs, entries on other providers and on
models still offered stay, in order, comments kept. A list left with
nothing is removed (never written []) and made again when its entries
come back, with the model picked meanwhile; a list the user removed
isn't made again. When the agent's model list can't be read, nothing
is taken out.

The same holds for the siblings with such a list: OmO and Prime Agent
(piLike), StepCode (config.toml; its wiring state's last scope follows,
so a disconnect still puts the user's list back) and omp (config.yml's
plain entries; folder-scoped entries are left alone).

Run:
- TestPiEnabledModelsLoseDeselected (pi, omo, prime-agent) with the
  reporter's provider and four models, beside the user's own entries
  (another provider at a level, a magpie glob, a model still offered
  at a level): deselect, select again, rename.
  TestPiEnabledModelsEmptiedAndBack: emptied and back; removed by the
  user stays removed; other providers' and globs' file byte for byte;
  an unreadable models.json prunes nothing.
  TestStepCodeAndOmpEnabledModelsLoseDeselected, StepCode's disconnect
  putting the original list back included.
- TestPiEnabledModelsFollowRename and TestStepCodeEnabledModelsFollowRename
  keep a magpie/deepseekx/flash entry to show a rename leaves a name
  sharing a prefix alone; deepseekx is now a real provider there, as the
  sync would otherwise (rightly) take an entry naming nothing out.
- Broken by hand, each red: Pi's, StepCode's and omp's Sync hook off;
  the put-back off; the rename of remembered entries off.
- Real Pi 1.1.0 (@earendil-works/pi-coding-agent) under a sandbox
  HOME, `pi -p`: the stale exact entries gave the reporter's warnings;
  the list as pruned gave none.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows;
  go test -tags nogui ./... green on origin/main 7d15df78a. Rebased again
  over 2eee900dc (omp's Sync now keeps the user's keys, ompProvider(models);
  the conflict is that one line), then vets and ./internal/agent/ and
  ./internal/cli/ again: green but for TestReasonixCLI*, whose fixture
  build read a go1.26.8 toolchain another session was unpacking into the
  shared module cache ("internal/oserror is not in std"); both pass run
  alone right after.

Not tried: the GUI's provider editor end to end with a real Pi session,
real omp and StepCode binaries, WSL. A magpie glob that matches nothing
still gets Pi's warning: it is the user's pattern and stays.
2026-10-14 13:33:28 +08:00
yetone 06c3370b74 gui: Fetch models' "{p}: {n} models" counts the models the editor lists, not the vendor's ids (#2069)
liangxyz's Antigravity refetch said "Antigravity: 23 个模型" over 17 chips.
The toast counted the ids the vendor listed, while the editor shows a
model Antigravity lists once per thinking level (gemini-3.7-flash-high,
-low, -medium) as one model with those levels, as Cursor's and Devin's
lists are folded too. Two numbers for one list read as models gone.

The count is now the models the provider offers after the refetch
(Provider.Available, what the editor's chips are drawn from), the ids
only when it offers none.

TestFetchedCountIsTheEditorsModels saves an Antigravity list of six ids,
three models, and fails on the old count (6, want 3).

Run (macOS): the test red with fetchedCount returning the ids, green with
it; TestProviderTypedKey still counts a relay's two; go test -tags nogui
./internal/gui: one run of the whole package failed in a 208s run whose
output I didn't keep, while a fork was running other suites on this
machine; three runs after it passed, so its cause is not known. gofmt
clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean. No GUI
change (app.js shows r.count as before), so the GUI suite wasn't run. Not
tried against a real Antigravity account.
2026-10-14 13:31:10 +08:00
yetone 9829d2f553 gui: a hook's description is shown whole, wrapped, and written in a box that wraps (#2085, emo172)
Library › Hooks cut a hook's description to one line with an ellipsis and
no tooltip, and the editor's Description was a one-line input, so an
80–150 character Chinese description could neither be read nor seen while
written.

- The list wraps the description (at most 200 characters, the user's own
  words). The row's text block takes a 240px basis, so the long text no
  longer pushes the name under the glyph at narrow widths.
- The editor's Description is a textarea that wraps and grows to fit. It
  stays one paragraph (library.SaveHook joins its lines), so Enter still
  saves, an IME's Enter still doesn't, as in every other field there.
- Siblings left as they are on purpose: skills, subagents and market rows
  hold one line with the whole text in a tooltip, because their lists are
  windowed to a fixed row height and their descriptions are authors'
  paragraphs, not the user's 200 characters.

Verified:
- library-hooks.test.cjs now gives a hook a 90-character Chinese
  description and checks it is not clipped and wraps at 440 and 1100 (1100
  in a window of its own: resizing one window across the page's breakpoint
  raises a WebKit ResizeObserver-loop error under load), that the name
  stays beside its glyph, and that the editor's box is a textarea showing
  all of it. On the old code it fails 12/12 ("the description is cut off
  at 440"); without the 240px basis, "the name is 38px off its glyph at
  440".
- All 484 library*.test.cjs pass in Chromium and WebKit, en/zh/zh-TW/ja/de;
  the hooks test 4x concurrently in both engines, 48/48.
- Screenshots at 440 and 1100, both engines, looked at.
Not run: Go checks (no Go changed); not tried in the built app.
2026-10-14 13:30:06 +08:00
yetone 353464f161 gateway: a translated Anthropic or Responses reply that said nothing and counted no token is asked again, then fails, not completed (#2086, tensornull)
tensornull's Codex turn on an Anthropic-compatible proxy (baseAPI
anthropic, claude-opus-5-5) ended as response.completed after 21s with
no output: the route had status 200, no usage, no served model, no
ttft. Codex took it as its turn's end (last_agent_message null) and
didn't ask again. No usage and no served model mean the proxy never sent
a message_start Claude would have (it counts the prompt and names the
model), yet the stream said it ended (message_stop or a stop_reason), so
320af9858's replyEnds read it as whole and errEndedShort didn't apply.

Now a reply from an Anthropic or Responses upstream (repliesCounted) that
said nothing (no text, call, search or image) and counted no token at all
(uncounted) is the empty reply #667 already handles for Gemini: asked
again in place, then failed with "an empty reply (the model answered
nothing; try again)", which Codex retries. Same in streamTranslated and
the unstreamed translate path, for Responses, Messages and Chat clients.
Claude's own empty end_turn (after a tool's result) counts its prompt and
still completes, as does a Responses reply with usage and no output.

Not changed: a reply passed through in its own protocol (Codex asking a
Responses provider, Claude Code an Anthropic one) isn't read for this;
the passthrough has no empty-reply rule at all, Gemini's included.

Verified:
- New stream_uncounted_test.go. TestUncountedEmptyReplyFails (message_stop
  only; pings then message_stop; message_start with no usage then a
  stop_reason; zero usage), TestUncountedResponsesReplyFails and
  TestUncountedEmptyReplyFailsEveryClient (Chat streamed, Responses and
  Chat unstreamed) all FAIL on the old code ("ended response.completed
  \"completed\", want response.failed", "status 200, want the empty
  reply's failure") and pass with the change. TestCountedEmptyReplyStillCompletes
  and the #1933 tests (TestWellFormedStreamsStillComplete, TestMalformed*)
  pass.
- The full go test -tags nogui ./internal/gateway run failed only
  TestCodexHeadersReachKeyedRelay and TestStandaloneNativeAccounts, whose
  fake Codex backends answered response.completed with output [] and no
  usage, which the real backend never sends; their fakes now count
  tokens, and both pass. Run in a sandbox HOME with pinned
  caches; gofmt -l; go vet ./internal/gateway for darwin,
  GOOS=linux -tags nogui and GOOS=windows; GOOS=linux go build -tags
  nogui and GOOS=windows go build.
- Not tried: the reporter's proxy or its real bytes (the report has none);
  the fixtures are the shapes its route record allows. Not run: the full
  go test ./... (only internal/gateway changed).
2026-10-14 13:26:18 +08:00
yetone 6e9930e374 provider: the Kiro mover asks for opencode-kiro-auth 0.1.10, which passes the caller's prompt-cache marks to Kiro (magpie-community/plugins#110)
kiro 0.1.10 (plugins 386a2ba) turns each cache_control in the Anthropic
body magpie hands the plugin (system, messages, tools) into Kiro's
cachePoint, at most 4 with the last kept; up to 0.1.9 it dropped them, so
a moved Kiro never asked Kiro to cache. This raises the mover's min, so
keepMovedCurrent updates every moved user.

Run: npm view @magpie-community/opencode-kiro-auth version on
registry.npmjs.org shows 0.1.10 (the publish run is red only for
zed-auth and zen-free-auth, refused by npm's trusted publishing); the
plugin's bun test (1191 pass) and scripts/check.mjs kiro, with its
cache-points.test.mjs failing 3 of 4 with the fix broken by hand; gofmt
-l; go vet darwin, linux -tags nogui, windows on internal/provider; go
test -count=1 ./internal/provider (ok).
Not tried: a real Kiro account.
2026-10-14 13:20:36 +08:00
yetone e710c5accd gateway: the built-in Kiro tells Kiro where to cache the prompt (magpie-community/plugins#110)
plugins#110 ("kiro cli cache 率为 0"): a Kiro subscription read nothing
from its prompt cache. Kiro's generateAssistantResponse takes Bedrock's
cachePoint {"type":"default"} on a userInputMessage (the CodeWhisperer
streaming model in aws/amazon-q-developer-cli; Kiro CLI 2.27's model list
carries PromptCaching with up to 4 checkpoints), but neither the plugin
nor the built-in ever sent one. The plugin's fix is kiro 0.1.10
(plugins 386a2ba); this is the same for users who haven't moved.

buildKiro now marks the first message when there is a system prompt
(which it folds into that message) and the current message, the two
places buildAnthropic marks for Anthropic. gateway-routing.md says how
each Kiro path places them.

Run: gofmt -l (clean); go vet on darwin, GOOS=linux GOARCH=amd64 -tags
nogui and GOOS=windows for internal/gateway and internal/provider; go
test -count=1 ./internal/gateway ./internal/provider (ok; both isolate
HOME in TestMain). TestBuildKiroMarksTheCache fails with the current
message's mark taken out by hand, and passes with it back.
Not tried: a real Kiro account (none signed in here), so whether Kiro
then reports cache reads is for the reporter to confirm; kirocc#83 notes
Kiro often sends a metadataEvent with no token counts.
2026-10-14 13:20:36 +08:00
yetone 33da86c71a provider: removing a plugin sets its providers' model picks in providers.json aside, and adding it again puts them back (#2057, dawn1095)
A plugin's provider leaves a record in providers.json once the user
picks its models: its id and nothing of its own (OnlyPicks). Removing
the plugin left those records behind. Nothing listed them, `magpie
provider rm` couldn't reach them, and a sync or backup asked for a
sign-in to them on every run.

RemovePlugin now finds the ids the plugin's providers are stored under
(PluginID of each provider plugin.Listed gives for its spec), and moves
the records with those ids that hold only picks into providers.json's
new pluginLeft, under the plugin's package name. Left alone:
- any record with an endpoint or a key (the user's own provider,
  whatever its id);
- a built-in's ids (accountIDs) and "magpie";
- an id another installed plugin serves too;
- everything, when the plugins' listing isn't known (no cache and no
  plugin-providers.json): unknown is not "none is the user's".
provider.AddPlugin (CLI, GUI, backup restore) puts the set-aside
records back, each one whose id has no record now; one the user has
given to a provider since stays aside. plugin.Listed is new: the cached
listing, or plugin-providers.json.

Run:
- plugin_left_test.go, four tests with user-owned records beside the
  plugin's (a user "zap" with an endpoint next to the plugin's
  zap-plugin, a hand-made "mine", a built-in's picks, another plugin's
  and a shared id). Each guarantee broken by hand turned its test red:
  no set-aside, no OnlyPicks check, no other-plugin exclusion, no
  unknown-listing guard, take-back over the user's record, no take-back.
- go test ./... in a sandbox HOME; gofmt -l; go vet darwin, linux
  (-tags nogui), windows.
Not done: records left by plugins removed before this change stay where
they are; turning a plugin off (not removing it) sets nothing aside;
`magpie provider rm` still can't name such a leftover. The move flow
(installPlugin) still adds through plugin.Add, since its own
migration owns those records. Not tried with a real plugin removal in
the GUI.
2026-10-14 13:20:13 +08:00
yetone 2a6354f09f gui: a quota curve closed again takes its card back to its height (#2059)
mengyianx on the Linux CLI's web settings page: with the remaining-quota
trend (剩余额度走势) opened and closed again, the allowance's box stayed
as tall as when it was open, blank under the curve.

The Usage page packs its cards into columns on 1px grid rows. Each card
is stretched to the rows it was given, and the last card in a column is
held down to the tallest column. A ResizeObserver on the list and the
cards repacks. A curve that grows pushes its card's box, so it repacked.
A curve that shrinks leaves the card's box where the packing put it, so
the observer never fired and nothing packed again. packUsageNow now also
observes each card's children, so a shrinking curve or balance trend
repacks too.

New test usage-curve-zoom-back.test.cjs opens and closes Codex's
allowance curve and DeepSeek's balance curve. It checks that every card
and the list come back to their heights, that the clicks don't scroll,
and that there are no page errors. It runs in Chromium and WebKit, en, zh,
zh-TW, ja and de, at 1100 and 420 (WebKit at 420 wheels to the balance
card with reader.cjs's reach).

Run:
- The new test: 20/20 pass. Against origin/main 8a4cfe0e4's assets
  (MAGPIE_ZOOM_ASSETS), all 20 fail with "codex: closed again, every
  card and the list are as tall as before it opened". On the old assets
  in Chromium en 1100, Codex stays 400 (was 297), DeepSeek 295 (was 192).
- The Usage-page GUI files (usage-*, quota-*, balance-*, panel-usage,
  tray-usage*, allowance*, routing-quota*, claude-usage*, api-key-usage*)
  in both engines at --test-concurrency=3: 807/808 pass. The one red,
  webkit de usage-sum-whole at 860px (page 4px wide), serves no quota
  cards, so this change can't reach it. Alone it passed 3/3. It is the
  known load flake #1864/#2023; this run was added to #1864.

Not tried: the rest of the GUI suite, and the real Linux CLI's web page
(the fake API serves the same assets).
2026-10-14 13:20:13 +08:00
yetone 3a7d0314a9 usage: a window's Pace as a number on its card, and in the menu bar when asked (fflake33)
fflake33 on Discord asked for the pace as a figure, "+12%" or "−8%"
against an even pace through the window, on the Usage cards and in the
menu bar.

- provider: QuotaWindow.Pace(readAt, now) is the share used (0-100) less
  the share of the window gone by, from Bounds (reset less span; a
  month's window a calendar month); none for an unlimited window, one
  whose span or reset isn't known, or outside it. WithWindowStarts sets
  startsAt on copies of the cards for the GUI (the caches' cards are
  left alone); /api/usage/quotas and its refresh send it.
- Usage page: "Pace +20%" on the reset line after the wait (quotaPace,
  paceLine), its sign turned with the meter in Left mode, amber while
  more is used than an even pace would have, what it means in its
  tooltip. Past cycles and windows with no known start show none.
- Menu bar: Settings > Menu bar pace (settings.TrayPace, off by default;
  hidden on Windows, whose tray shows no text) puts " +12%" beside each
  figure ("42% −14%", at most 10 runes, trayRowMax) and "pace −14%" in
  the tooltip. KeepOwn keeps it device-local like the other tray
  settings; the Settings save keeps it (prefsKeep).
- Strings in en, zh, zh-TW, ja, de. gui-shell.md says it.

Run:
- go test -tags nogui ./internal/provider ./internal/gui ./internal/settings
  ./internal/usage: ok; ./internal/davsync: ok (now covers TrayPace;
  red with TrayPace taken out of KeepOwn). go test ./internal/gui -run
  Tray (darwin, with the tray image tests): ok.
- New TestWindowPace, TestWithWindowStarts (input not mutated),
  TestTrayUsagePace (off unchanged, used and left, rows, tooltip).
- quota-pace.test.cjs, chromium and webkit: 4 pass; cards in en, zh,
  zh-TW, ja, de at 1100 and 420px, used and left, amber, tooltips, no
  sideways scroll, a click moves nothing; the Settings row in all five
  at both widths, On posts trayPace, a currency save keeps it, no
  scroll; hidden with no card and on Windows, shown on Linux. Red with
  paceLine not called, with trayPace out of prefsKeep, and with the
  Left-mode sign not turned.
- gui-de, gui-ja, gui-zh-tw, i18n-keys: 12 pass; tray-bird 6, quota-holds
  2, quota-read-at 4 pass.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean.
Not tried: the real menu bar on a Mac or Linux tray.
2026-10-14 13:02:48 +08:00
ggbdpq eb0d5750f8 catalog: a relay's Nano Banana is a drawer, whatever its spelling (#2071)
ll905518294's relay serves Gemini's image models under the name they are
called, "Nano Banana 2.1", and both it and a video model landed in the
chat model list: a base-URL provider's list is classified by the id
alone, and "banana" is no word of Google's own ids, which all say
"image".

- DrawsID knows "banana": the Nano Banana family (gemini-2.5-flash-image,
  gemini-3-pro-image), which relays id "nano-banana", "Nano Banana 2.1",
  "NanoBanana2". A model it catches leaves the chat list for the
  editor's image models and Settings -> Images, as an id saying "image"
  does.
- The video model is not touched: a list that says nothing of what a
  model makes stays a chat model, for the user to mark in the editor
  (#1399, "Makes: Video model"). No word of "omni_flash-10s" says video,
  and none is guessed.

TestFetchRelayDrawerNames (a relay list with the three spellings, a
"gemini-3-pro-image-preview" that drew already, and the two that must
stay chat) fails on the old DrawsID: "Nano Banana 2.1: not a drawer",
"nano-banana-pro: not a drawer", "NanoBanana2: not a drawer". With the
word it passes.

Run (branch hunt19-b2 on origin/main f074996d): gofmt clean (CRLF false
positives judged on LF copies); go vet -tags nogui and GOOS=linux go vet
-tags nogui and GOOS=windows go vet of ./internal/catalog
./internal/gateway ./internal/provider, clean; go build -tags nogui
./... ok; go test -tags nogui -count=1 ./internal/catalog ok, and -run
'Draw|Film|Video|Image' of ./internal/gateway and ./internal/provider
ok. Not tried against the reporter's relay (no account here): the
classification is the live-list path's own, tried on a fixture of the
ids the report's screenshot shows.

Re-run on landing (macOS, origin/main 722abfbb0): the new test red with
catalog.go reverted, green with it; ./internal/catalog, and -run
'Draw|Film|Video|Image' of gateway and provider, ok; gofmt clean; go vet
darwin, GOOS=linux -tags nogui, GOOS=windows clean. No other copy of the
word list exists (grep hidream).

Fixes #2071

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-14 13:01:07 +08:00
yetone 722abfbb0a usage, gui: a window whose whole can't be estimated says "not enough data", and why in its tooltip (#2045)
The Usage page's account cards told a window's whole ("Whole ≈ N tokens
· ≈ $X") only where it could be reckoned honestly, and said nothing
elsewhere, so a reader couldn't tell a window magpie can't reckon from
a fault (#2045 asked for "数据不足" there).

The server now says why on each window of an account's own card that
isn't reckoned (QuotaWindow.HoldsWhy):
- low: under 5% used (HoldsFloor);
- clock: no reset clock, so no known start;
- log: the window began before magpie's request log;
- none: magpie routed nothing the window counts in it;
- credits: a call in it may have been paid from credits or extra usage
  (#2010's dry runs).
Windows whose whole is never told (a pool, a family, money aside, an
error card, another magpie's) carry no reason and say nothing, as
before. WithWindowHolds now also fills reasons when no window at all can
be reckoned; the caller's cards are still left unwritten.

The GUI shows a muted "Whole: not enough data" on the reset's line, with
the reason in its tooltip, in all five languages. A reason it doesn't
know says nothing. History cards are unchanged.

Run:
- go test ./internal/usage ./internal/gui: pass. The window-holds tests
  check each reason, that reckoned windows carry none, and that the
  caller's cards stay unwritten. Not writing HoldsWhy turns 3 tests red.
- quota-holds.test.cjs in Chromium and WebKit, en/zh/zh-TW/ja/de, at
  360, 420, 440, 1000 and 1100: the line, its reason, muted, not cut,
  inside its card. Removing the GUI branch turns it red. Screenshots at
  420 in zh and de looked at.
- i18n-keys, quota-curve, keep-login, quota-name-translated in both
  engines: pass.
- gofmt -l clean; go vet darwin, linux (-tags nogui), windows; linux and
  windows builds.
Not tried: a real account's card in the running app.
2026-10-14 12:53:09 +08:00
yetone f074996d93 provider, gateway, gui: a model with none of its levels ticked is sent no reasoning field, on every route and in a routing group (yuexian7)
yuexian7 on Discord: models.dev lists their model as reasoning, and the
vendor answers any reasoning parameter with 422 while the same request
without it works. In a routing group they couldn't set an effort per
model, and the model editor refused to untick the last level ("Keep at
least one level"). The learned refusals (bed306ae, #1062) don't cover
this: they learn a refusal of reasoning *off* and of Gemini levels, and
optionalFields holds thinking/enable_thinking, not reasoning_effort.

- settings.ModelReasonless, set by provider.SetModelReasonless (the
  provider editor's Names & levels with every level unticked, saved as
  modelPrefs {reasonless: true}; `magpie model efforts <ref> off`).
  Ticking levels again or Restore default clears it (setModelEfforts);
  setting it drops the model's kept levels.
- entryFor and Efforts/Thinks/Levelless: the model offers no levels and
  is Quiet, so agents are given none for it.
- Gateway: the candidate loop strips the body with withoutAnyReasoning
  in the agent's protocol (Chat/Responses reasoning_effort, reasoning,
  thinking, enable_thinking, include's reasoning.encrypted_content;
  Anthropic thinking of any type and output_config.effort; Gemini
  thinkingConfig). The Anthropic relay doesn't add
  thinking:{type:disabled} for it, and forwardTranslated clears Effort,
  ThinkOff and Thinking for its other callers (continuation, search).
- A routing group with it as a member keeps the other members' levels
  (it `continue`s like a member whose levels are unknown, #597), and the
  member that reasons is still sent the effort asked.
- GUI: none ticked shows "No reasoning field sent" beside the levels, in
  zh, zh-TW, ja and de too; a model with one known level now shows its
  picker so it can be unticked. A model whose levels aren't known
  (m.given) keeps none ticked meaning no levels known.

Run (worktree on origin/main 82f3befd2, sandbox HOME, private GOCACHE):
gofmt -l clean; with set -o pipefail go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./... all clean; node --check
app.js. go test -count=1 ./internal/provider ./internal/gateway
./internal/settings ./internal/cli: ok. ./internal/gui: ok except
TestMainWindowCorners/macOS_15_SDK killed at its 40s deadline under
load (AppKit window measurement, untouched here; #1936, noted there).
The run caught TestSettingsSaveKeepsWhatItDoesNotSend (ModelReasonless
added to it) and the CLI usage alignment tests (fixed).
New tests and what breaking the change does: TestReasonlessModelSentNoReasoning
(Chat, Chat+enable_thinking, Responses with include, Anthropic->Chat
translated; by name and through group/mix) and TestReasonlessAnthropicRelay
fail with gateway.go/quiet.go reverted; TestGroupReasonlessMemberKeepsLevels
fails with group.go's reasonless branch disabled; TestModelReasonless
needs the new API. model-reasonless.test.cjs in chromium and webkit, at
1100 and 420, in en, zh, zh-TW, ja, de: 20/20; on the old assets all
fail. Related GUI tests 418/418 (one model-copy-id failure on a first
run under load, passed alone; #2066).
Not tried against the reporter's real vendor: the 422 is taken from
their report.
2026-10-14 09:38:12 +08:00
yetone 2971e1518f gui: the Context window field offers 400K and 512K beside 128K, 200K, 256K and 1M (yuexian7)
yuexian7 on Discord asked for 400K and 512K among the context-length
quick picks; until now they had to be typed. contextPicks gains the
two, in order.

Run: context-picks.test.cjs (new) in chromium and webkit, at 1100 and
420 wide, in en, zh, zh-TW, ja and de: 20/20 pass; on the old app.js
all 20 fail. node --check app.js. Related GUI tests (provider-levels-*,
model-*, gateway-model-info, context-*, routing-levels, compact-at,
name-suffix-*, names-*): 418/418 on a second run; the first run had one
failure in model-copy-id (chromium zh, right-click copies a chip's id)
that passed 3/3 alone, filed as #2066.
2026-10-14 09:38:12 +08:00
yetone c4f4aaaa97 gateway: Claude's bridge no longer passes hook notices and token counts on as the user's message (#2060)
Through the Claude subscription bridge, the inner Claude Code kept saying
"The user sent a new message while you were working:" followed by a hook's
additional context, a bare <total_tokens>... line or nothing at all. The
outer agent sends these after a tool result, and saidWithResults took every
text block after a result as words the user typed mid-turn and queued them
into the inner session.

Captured from a real Claude Code 2.1.296 with PreToolUse/PostToolUse hooks
against a local mock: after a tool_result it sends a {role:"system"}
message whose one text block joins "PreToolUse:Bash hook additional
context: ...", "PostToolUse:Bash hook additional context: ...", optionally
"The user sent a new message while you were working:\n<words>\n\nThis is how
Claude Code surfaces messages ...", and "<total_tokens>N tokens left
</total_tokens>". Older clients put the same in <system-reminder> blocks;
the reporter's had an empty reminder too, which is why some of their
"messages" were empty.

- saidWithResults takes only the user's words out of a mid-turn block
  (midTurnSaid, up to the client's own tail, a reminder's end, the token
  count or the next hook notice), skips the rest of a system or developer
  message, and drops a text that is an agent notice (agentNotice: empty
  once reminder tags are stripped, a hook notice of the known kinds, a
  token count, or one of the injected leads prompt.go already knows).
- renderParts, the sibling that labels text after a result as
  [user message] in the prompt for a fresh run, closes the result instead
  for an agent notice.
- docs/subsystems/claude-subscription-bridge.md says so.

Run:
- Fixtures are the literal 2.1.296 bytes and the reporter's
  (claude_hook_notice_test.go): nothing queued for hooks and token counts;
  only "also tell me the date" queued when the user did write; the
  rendered prompt has no [user message]. A "Stop hook is broken: fix it"
  typed by the user still goes on.
- With the old condition put back and the renderParts change off, the
  three new tests fail; restored, they pass.
- gofmt -l internal/: clean. go vet ./internal/gateway on darwin,
  GOOS=linux -tags nogui, GOOS=windows (set -o pipefail): clean.
- go test -count=1 -timeout 30m ./internal/gateway: ok (667s).
- Not tried end to end through the bridge with a real Claude subscription.
2026-10-14 09:32:21 +08:00
yetone aa6a0d6b20 library: one skill over 200 MB is left out, not the whole repository (#2062)
mikubaka88/CCFA-Skills couldn't be installed at all: "the skills in ... are
too big to install (over 200 MB)". The repository is over the 200 MB
tarball cap, so fetchSkillFiles fetched it file by file, and that refused
the whole repository once the files summed past 200 MB. One skill,
ccf-paper-writer, is 297 MB on its own (exemplar paper PDFs, llava-4d.pdf
alone 46.8 MB); the other 16 are small.

The 200 MB limit per skill stays: a skill is copied into every agent that
gets one as a copy, and treeOf stops comparing at 256 MB, so a 297 MB skill
can't be told current or edited. What changes is that one such skill no
longer blocks the rest:
- fetchSkillFiles sums each skill's files (the deepest skill folder a file
  is under) and leaves out a skill over maxFetch; its files are never
  asked for. Only when every skill is over it does it fail as before.
- The left-out skills reach ProbeSkills as Probe.Left (path, size), kept
  per temp folder and taken once (tookLeftOut).
- The GUI's probe names each under the list ("{name} is too big to
  install: 283 MB, over the 200 MB a skill may be"), or in place of "No
  skills there" when nothing else is left; zh, zh-TW, ja, de. The TUI says
  it in its flash.
- docs/subsystems/library.md says how a big repository is fetched.

Run:
- Real: probe of mikubaka88/CCFA-Skills under a sandbox HOME lists 16
  skills and leaves out ccf-paper-writer (296736735 bytes). Not installed
  into a real agent.
- gofmt -l internal/: clean. go vet ./internal/gateway ./internal/library
  ./internal/tui on darwin, GOOS=linux -tags nogui, GOOS=windows (set -o
  pipefail): clean.
- go test -count=1 ./internal/library ./internal/tui: ok.
- TestOneSkillTooBigLeavesTheOthers (new): fails with the per-skill
  leave-out turned off by hand, passes with it.
  TestTooBigRepositoryChecksWhatArrives now makes every skill too big.
- skill-too-big.test.cjs (new), chromium and webkit, en 980 and zh,
  zh-TW, ja 440, de 420, plus every-skill-too-big: 14/14; red (0/7 in
  chromium) with client.js at origin/main. skill-*.test.cjs 190/190 and
  library-*.test.cjs 484/484 in both engines.
2026-10-14 09:32:21 +08:00
yetone e855272cf0 gui: a refused allow list names the address magpie sees the page from, with Add <addr> (Mathresearcher)
Settings > Share on local network > Allowed addresses refused a list that
would shut out the page itself with a fixed sentence and no address
(Mathresearcher on Discord). The server already names it (KeepsOut in
gateway/allow.go, "that allow list would shut out <addr>, the address
this page is open from"); allowSays now carries it into the message in
every language, and a one-click "Add <addr>" button saves the list with
it added.

The address is the connection's own (peerAddr: RemoteAddr, unmapped, zone
dropped); X-Forwarded-For and the like are never trusted, and loopback and
the machine's own addresses always pass. Behind Docker Desktop or rootless
Docker every client shows as Docker's own address (192.168.65.x), the host
reaching a container shows as the bridge gateway (172.17.0.1), and a proxy
in another container shows as that container. So the button's tooltip
says that behind Docker or a reverse proxy this is the proxy's address,
and adding it lets in everyone who comes through that proxy.

Run:
- allow-ips.test.cjs, chromium and webkit: 14 pass. The subtest checks
  the refusal names 203.0.113.50, the button's text and tooltip fit,
  a click posts ["172.16.0.0/12","203.0.113.50"], lists the rows, takes
  the button away and doesn't scroll. With the old app.js put back it
  fails (TimeoutError; chromium 5 pass, 2 fail).
- gui-de, gui-ja, gui-zh-tw, i18n-keys: 12 pass.
- gofmt -l (clean), go vet darwin, GOOS=linux -tags nogui, GOOS=windows:
  clean. go test -tags nogui ./internal/gui -run Allow: ok.
Not tried: a real Docker or reverse-proxy setup.
2026-10-14 09:31:01 +08:00
yetone 6fc0e93176 gui: the tray panel's Routing rows tell how fast a finished request wrote (#2050)
A finished request that didn't fail now shows its speed after its tokens
and time, "12.4k tokens · 1.5 s · 1667 tok/s", from the same speedOf the
Routing page's rows use, so it is left out where that page leaves it out
(no first token, a burst at the end, a failure). The string "{n} tok/s" is
already translated in every language.

With the speed the totals no longer fit beside where a request went in
the 440px panel: the "served …" mark was cut to "served gpt-…", and when
the totals were let shrink, the speed was cut instead. Where it went and
its totals now share a wrapping line (.pr-line), and the totals go under
it, at the right, when both don't fit. A row whose provider and account
alone are too long now has its totals under them rather than beside.

Not done: a live rate on a request still being answered (part 2). The
trace has no token count until the reply ends, so there is nothing to
show a rate from.

Run:
- panel-routing, panel-routing-providers, routing-reroute-title and
  number-units in Chromium and WebKit: 13/13 each.
- panel-routing now checks the speed is on the finished row only and no
  row's totals are cut. Dropping the speed line turns it red; dropping
  flex-wrap turns it red (the served mark is cut).
- Looked at the panel's screenshot at 440 in both engines.
Not run: other languages than en and zh in this test (the string itself
is translated in all five).
2026-10-14 09:29:59 +08:00
yetone 54a003d48d provider tests: the device sign-ins' fakes poll every 10ms, not the 1s floor a vendor's 0 interval got (#2051)
Copilot, Factory and ZCode's device sign-ins wait at least a second
between polls, whatever interval the vendor gives. The tests' fakes give
0, so each poll in a test cost a full second, and these tests were 56.5s
of the provider package's 399s of test time.

The floor is now devicePollFloor, read through devicePoll(seconds) at the
three call sites, and the provider package's TestMain lowers it to 10ms.
Real sign-ins still wait max(vendor's interval, 1s), as before.
TestDevicePollKeepsItsFloor checks 0, -1 and 1 give 1s and 5 gives 5s.

Run:
- go test ./internal/provider (full, -count=1, load avg ~100): pass,
  403s -> 316s of package time; the Copilot/Factory/ZCode tests 56.5s
  -> 22.5s.
- A/B on -run 'Copilot|Factory|ZCode', base vs this: 45-58s vs 15-16s
  (32s once, under load).
- Removing the floor from devicePoll turns TestDevicePollKeepsItsFloor red.
- gofmt -l clean; go vet darwin, linux (-tags nogui), windows; linux and
  windows builds.

One A/B round failed on both base and this change at load over 200; the
cause wasn't captured, and the next 4 rounds passed on both.

Not done: the other slow causes in the package. The 1.2s sleeps waiting
for the callback port to be let go (signin_test.go:137,
signin_proxy_test.go:92, signin_usage_afresh_test.go:70), Cursor's
linkWait, MoveToPlugin (7-9s) and WarmAtSeveralTimes (6-10s).
2026-10-14 09:29:59 +08:00
yetone a125d5c9ea gui tests: group-fold's window is 1700 tall, for the editor's Custom wait that 195a1009b added
195a1009b put Custom (minutes of your own) beside Wait, 30 s, 1 min and
2 min in a routing group's Slow to start, which made the editor 8px
taller. At 1600 the editor's Cancel sat half under the window's footer,
and WebKit en clicked the footer (Chromium's text metrics kept the
centre just above it). Red in WebKit on origin/main 2eee900dc, 2 of 2
runs; at 1700 WebKit and Chromium pass, en and zh.
2026-10-14 09:25:02 +08:00
yetone 2eee900dc9 agent: eight more syncs keep what the user set on magpie's block (#2030's siblings)
1e654d8ce fixed T3 Code's sync, which rewrote magpie's provider instance
whole. The same shape lost user-set keys in eight more agents. On every
Sync and every pick, each one rewrote magpie's own block in the agent's
config whole. Each app's schema was taken from its own source, never
guessed:

- Qoder 1.1.70 (@qoder-ai/qodercli bundle): providers.magpie lost routing
  (the compact and subagent models), firstPayloadTimeoutMs,
  streamIdleTimeoutMs, type, authType, anthropic and a displayName.
- fx (vercel-labs/fx configured_provider.zig): reviewer_model was lost,
  and a tool_choice_mode of "omit" went back to "send". auth stays
  magpie's whole, since fx refuses an env beside type none.
- Hermes (hermes_cli/config_providers.py): `hermes model` itself writes
  default_model into providers.magpie. That was lost, as were key_cmd,
  the timeouts, extra_body, a name and extra headers. This held in every
  profile spread() writes.
- omp (models-config-schema-bundle.ts): modelOverrides, discovery,
  disableStrictTools, headers and compat flags were lost. auth and
  apiKey stay magpie's, or go, so a loopback's auth: none never sits
  beside a WSL key.
- Kimi Code (configSection.ts ProviderConfig): SetTOMLTable replaced
  [providers.magpie], losing inline custom_headers, env and
  default_model. Its three keys are now set in place.
- Cline (local-provider-registry.ts): models.json lost the provider's
  other keys, and the per-model overrides that the VS Code model editor
  writes. A model magpie no longer lists still goes.
- Goose (declarative.rs): the custom provider file was rewritten whole,
  losing display_name, timeout_seconds, toolshim, other headers and the
  like. Goose's own editor carries those keys over.
- ZCode (provider-data-schema.ts, strict): the provider rule lost
  providerName, logo, visibility, api.headers and
  access.apiKeyManagementUrl. Only keys already in the file, which ZCode
  accepted, are kept.

Each merge lays magpie's block over what is there. magpie's parts (the
address, the key, the format and the model list) are named, and a key
magpie stops writing goes with them. The JSON ones use theirsKept or
mergeKept. A new yamlKept does the same for Hermes and omp.
agent-wiring.md lists what each one keeps.

Tests: Test{Qoder,Fx,Hermes,Omp,Kimi,Cline,Goose,ZCode}KeepsTheUsersSettings.
Each one:
- connects;
- sets the user's keys the way the app writes them, plus a stale
  address and a stale model;
- adds a provider, then syncs 3 times and picks again;
- checks that the user's keys stay, that magpie's parts are rewritten,
  and that the stale model is gone.

All eight fail on origin/main's agent code (each reports "the user's
settings not kept") and pass with this change.

Run, in a sandbox HOME, with GOCACHE in the scratchpad and Go 1.26.8:
- gofmt -l on the changed files: clean.
- go vet ./... (darwin), GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: clean.
- go test -tags nogui -timeout 45m ./internal/agent: ok, 805s.
- go test -tags nogui -timeout 45m ./...: all ok.

Not tried: none of these apps was run against a real config written by
this change. Their schemas come from their source (Qoder's npm bundle,
fx, Hermes, oh-my-pi, kimi-code, cline, goose and ZCode at their current
heads), not from a live install.
2026-10-14 09:21:18 +08:00
yetone ccffdadb8a gateway: /v1/audio/transcriptions passes speech-to-text through to the provider (#2053, niyoh120)
niyoh120 asked for an OpenAI-style speech-to-text endpoint so a client's
voice input can go through magpie like its chat does. magpie had no
/v1/audio route, so the request 404ed.

What changed:
- POST /v1/audio/transcriptions and /v1/audio/translations (and the
  /audio/... spellings) route through the same core as embeddings and
  rerank. embeddings.go's routing is pulled out into serveRetrieval, so
  disabled models, key access, groups, pause rules, account holds,
  failover, redaction and usage records are shared rather than copied.
- transcribe.go reads the multipart form only to find `model` (as
  provider/model) and `prompt`. The form goes to the provider byte for
  byte; it is rebuilt part by part, under the same boundary, only when
  the model name is rewritten or the prompt was masked. The audio part
  is always copied as sent.
- Only providers with an OpenAI-style base are tried; an Anthropic-only
  provider gets a 400 saying so. A body that isn't multipart, a form with
  no model, or one that doesn't parse gets a 400 and nothing is sent.
- The vendor's answer type passes through (response_format text/srt/vtt
  stays text/plain). Usage records output tokens from usage.output_tokens.
- The 404 message, the info api list, remote magpie's suffix list, the
  CORS and LAN tests, docs/reference.md, gateway-routing.md and the
  remote docs (en, zh, ja) name the new paths.

What was run, at 9c36c3a0 (this change rebased on 10f38770):
- gofmt -l internal/gateway internal/provider: empty
- go vet (darwin); GOOS=linux and GOOS=windows go vet -tags nogui on
  ./internal/gateway ./internal/provider: clean
- go test -tags nogui -timeout 45m ./internal/gateway ./internal/provider:
  ok (1367s, 339s); also green on two earlier bases (b4fe6663, 06fbfd95)
- Rebased again on a0ebe003 (main had moved 5 commits, none in these
  files; routing.go's Factory rest is the nearest): gofmt, vet on darwin,
  linux (nogui) and windows (nogui) clean, and
  go test -tags nogui -run 'Transcri|Embed|Rerank|CORS|LAN|Lan|Factory|
  Retriev|NotFound|Info' ./internal/gateway ok. The full packages were not
  rerun on this last base.

Break-checks, each turned red and restored:
- routes removed (the old code): all 5 new tests fail
- model never rewritten: TestTranscriptionGoesToTheModelsProvider and
  TestTranscriptionPromptRedacted fail
- answer always labelled JSON: TestTranscriptAsTextKeepsItsType fails
- rebuild truncates the audio part: Goes + PromptRedacted fail
- prompt not masked: TestTranscriptionPromptRedacted fails
- output tokens ignored: TestTranscriptionGoesToTheModelsProvider fails

Real use: through magpie's real handler against aihubmix
(https://aihubmix.com/v1) with a `say`-made m4a: whisper-1 json 200
{"text":"Hello from the Magpie Gateway."}, response_format=text 200,
srt 200 text/plain with SRT cues, translations 200.

Not tried: OpenAI direct (the key answers 429 "account is not active"),
Groq, a local vLLM/whisper server, and any real client's voice input.
2026-10-14 09:19:16 +08:00
yetone a0ebe0032d plugin: a listed plugin whose package is gone is installed again, and bun's installs run one at a time (#2002)
anganing (Windows 11, v0.1.1229): after an auto-update, every switched-on
plugin said "no such plugin: …\node_modules\@magpie-community\opencode-grok-auth"
at each start. For the github: plugins the path was the spec itself
(node_modules\github:owner\repo), so package.json no longer listed them.
Removing a plugin and adding it again was the only way out.

- InstallMissing installs again each listed plugin (switched off or not)
  whose package isn't in plugins/, from its own spec. KeepUpdated runs
  it 30s after start and then hourly, before CheckUpdates. Nothing did
  this before: CheckUpdates skips a plugin with no installed version.
- installMu serialises every bun command that changes plugins/: install
  (including the first package.json it writes), reinstall's bun update,
  and Remove's and add's bun remove. At start KeepUpdated (30s) and
  keepMovedCurrent (20s) each run bun add with no lock. On the Windows
  box, three concurrent bun add runs (Bun 1.4.3) in one folder kept only
  one writer's package.json change. A git plugin's dependency dropped
  that way leaves Name() unresolved, which is the reporter's github rows.

The exact sequence that emptied the reporter's node_modules wasn't
reproduced. Bun 1.4.2 -> 1.4.3, magpie v0.1.1205 -> v0.1.1227 with the
same plugins, and a package.json reset all left the folders in place.
So this repairs the state and closes the one race found. It isn't
proven to be the trigger.

Run:
- go test ./internal/plugin ./internal/provider -count=1: ok.
- The new tests -count=3 on macOS, and on the Windows box as a
  cross-built test binary: ok.
- Broke each fix by hand (lock a no-op; InstallMissing returns early):
  TestBunCommandsOneAtATime fails with "another bun is running here",
  and TestMissingPluginsInstalledAgain gets 0, want 2.
- Real use on the Windows box, sandbox HOME, port 3561, real Bun 1.4.3:
  deleted opencode-grok-auth and opencode-qoder-auth from node_modules
  and started serve built from this commit. The host logged the
  reporter's exact "no such plugin" for both. At +30s it logged
  "installed 1 missing plugins again" and both folders were back.
  After the restart, no plugin failed to load.
- gofmt -l internal/: clean. go vet for darwin, linux -tags nogui and
  windows (plugin, provider, gateway), and GOOS=windows go build ./...:
  ok.
2026-10-14 09:17:47 +08:00
yetone 8cb0946fbe gateway: a Factory usage-limit 402 that arrives before the account's windows are read rests only that model once they are (#2036, Ziqi-Cui)
#1979 rests only the model when Factory answers 402 "You've reached your
weekly standard usage limit" and the account's windows say Standard's
pool is the one used up. Before the windows are read (just after a
start, or after a reading failed) nothing tells the pool from the
account, so the whole account rested, Droid Core's models with it,
until the reset the refusal named, often days.

Such a rest now starts narrowWhenRead in the background: it waits for a
reading (provider.AwaitAllowance, up to a minute), and if the reading
says the model's pool is the one used up, moves the rest to the model
alone (restID) with the same end. No reading in time, a reading that
says the whole account, or a rest lifted or made again meanwhile leaves
the account's rest as it is.

CodeAlex52's patch (c623610) waited for the reading inside the request
for up to 10s. That holds the failover the client is waiting on, so the
wait is off the request instead: the request has failed over already,
and the rest's scope only matters to later ones. The gateway's TestMain
turns the wait off so no test's goroutine asks a fake upstream after
the test ends; the tests that need it swap it in and wait on
narrowing.

Run: TestFactoryStandardOutLeavesCore's new unread case (built-in and
plugin windows) and TestResetsInWords' no-reading case; the unread case
fails with the narrowing removed; -race -count=3 on both; full
go test -tags nogui ./internal/gateway in a sandbox HOME; gofmt -l
clean; go vet darwin, linux nogui, windows nogui.
docs/subsystems/gateway-routing.md's 402 paragraph says so.
2026-10-14 09:15:21 +08:00
yetone c76842482f agent: Claude Desktop keeps the user's own 3p settings when magpie is turned off and on again (#2035, capiton0)
Settings the user changes in Claude Desktop's third-party window (models
list, allowed hosts, Claude Code for Desktop, the mode chooser and
whatever Desktop adds later) live in the profile magpie made. Switching
Desktop off magpie deleted that profile, so switching on again started
from "{}" and every such setting was gone.

Off now stashes the profile as it was (a non-empty JSON object, under
claude-desktop.profile + the package key) before removing it, and on
writes it back when the profile is missing or empty; the gateway's
address, key and auth scheme are then set over it as before, so only
magpie's own fields are replaced. A stash that isn't a JSON object is
ignored and on starts from "{}" as before.

Run: TestClaudeDesktopOffOnKeepsTheUsersSettings (new) fails on
origin/main (the user's coworkEgressAllowedHosts, inferenceModels and
isClaudeCodeForDesktopEnabled lost) and passes here; go test -tags nogui
./internal/agent in a sandbox HOME; gofmt -l clean; go vet darwin,
darwin nogui, linux nogui, windows nogui.
Not tried: a real Claude Desktop.
2026-10-14 09:15:21 +08:00
yetone 64487d458e gui: copying on KDE Wayland no longer breaks the connection to the compositor and quits magpie (#2039, dannisun0412)
dannisun0412 runs magpie on KDE Plasma 6.6.6 (kwin_wayland, libwayland
1.24) and it quit three times in twelve minutes with "Error 22 (Invalid
argument) dispatching to Wayland display" / "Error reading events from
display: Invalid argument".

The cause is the clipboard read-back probe (clipboard_gtk3.h). It made
its own wl_data_device and, when done, called wl_data_device_destroy,
which only frees the client side. The compositor still thinks the
device is live and keeps sending it a fresh wl_data_offer on every
later copy. libwayland drops those events for the dead proxy without
reserving their new ids, so the client's id map falls behind the
server's; the next server-created object whose id lands past the gap
makes wl_map_reserve_new return EINVAL and GDK exits.

The probe now binds the data device manager at version 3 at most and
releases the device with wl_data_device_release (version 2+), so the
compositor stops sending to it. On a version-1 manager it doesn't read
back at all (returns -2, which the Go side takes as "copy held").

The probe test (testdata/clipboard_probe.c) gets an "again" mode: copy
and read back eight times, then make the compositor hand out four
offers at once (the "burst" that needs ids past the leak), then check
the process is still alive.

Run:
- Fedora 44 container with kwin_wayland --virtual (SYS_NICE),
  gtk3/webkit2gtk-4.1, go 1.26.9: with origin/main's header the probe
  died with EINVAL 6 of 6 times (primary selection on and off) and
  TestClipboardReadBack failed 3 of 3 with "Error reading events from
  display: Invalid argument"; with this change the probe stayed alive
  6 of 6 and TestClipboardReadBack passed 3 of 3. GOOS=linux go vet
  with the gtk3 build in the container was clean.
- macOS: gofmt -l clean; go vet darwin, linux nogui, windows nogui;
  go test -tags nogui ./internal/gui passed.
Not tried: a real Plasma desktop or the full app over Selkies.
2026-10-14 09:15:21 +08:00
yetone 2076943915 plugin: a plugin declares its own switches, shown in its provider's editor and read by the plugin (#2038, Vocllum)
Vocllum asked that a plugin can offer the user generic on/off options
without magpie knowing what each one is for. A plugin now declares them
on its auth hook, beside checkin:

  auth.options: [{ key, label, description?, default?, confirm? }]

and reads the user's values through input.magpie.option(provider, key)
or input.magpie.options(provider). Each call reads the current values,
so a change reaches the plugin without a restart. magpie only keeps the
value and hands it over: nothing is scheduled or run when an option
changes. The check-in switch (settings.pluginCheckins) and the check-in
plugins are unchanged.

- host.js: optionsOf keeps a key matching [a-z0-9_-]{1,40} with a
  non-empty label, drops repeats, caps the label at 60 characters and
  the description and confirm at 300, takes default only when it is
  true, and keeps at most 16. The values come at init and through
  setProviderOptions.
- Go: plugin.Option, Provider.Options, OptionOn and SetProviderOptions
  (sent only to a host that is running). settings.PluginOptions is kept
  by the plugin's provider id, then the key. POST
  /api/settings/plugin-option {provider, key, on} checks the key the same
  way and hands the values to the host. The generic settings save keeps
  them, as it keeps PluginCheckins. /api/providers' plugins[].options
  carry each option's resolved `on`.
- GUI: a "Plugin options" field in a plugin provider's editor. Each
  option is a segs Off/On beside the plugin's label and description, put
  in with textContent. A confirm text is asked through confirmAction
  before turning an option on. Changes wait for Save, which posts each
  one before the provider. Strings are added for zh, zh-TW, ja and de.
- Docs: provider-plugins.md (a new section), reference.md, gui-shell.md
  and the tests README.

Run:
- TestPluginOptions (a real host with testdata/options). Red with the
  old host.js (no options listed) and red with setProviderOptions turned
  into a no-op (the plugin still reads the old value).
- TestPluginOptionSetting and TestSettingsSaveKeepsWhatItDoesNotSend.
  Both red with the generic save's PluginOptions line removed.
- plugin-options.test.cjs: 22/22 in Chromium and WebKit, at 1100 and 420
  wide, in en, zh, zh-TW, ja and de. Red on the old app.js (no field).
  The screenshots were looked at: long text wraps and the page has no
  sideways scroll at 420.
- provider-concurrency, plugin-signin, plugin-checkin, provider-price-rate
  and plugin-move-unserved: 68/68.
- go test ./internal/plugin/... ./internal/settings/... ./internal/gui/...
  ./internal/provider/..., gofmt -l, and go vet on darwin, linux
  (-tags nogui) and windows.

Not tried with a real community plugin, since none declares options yet.
The check-in row doesn't take a plugin-declared label or hint; it is
left as it was.
2026-10-14 08:50:41 +08:00
yetone 10f3877071 gateway tests: TestCodexHeardWithinItsIdleTimeout leaves over a second of room on both sides, where a busy machine's lag carried member a's failure past Codex's quiet limit (#1800)
#1800 has the test failing two ways on busy machines. The body check:
member a failed at 0.7s and Codex's quiet limit was 1s, so 300ms of the
gateway's lag put a's failure past the limit, and it went to Codex as
it was. The bound on the second half: 3s, against 1.2s expected and
3.2s for the pause waited.

Now the quiet limit is 2s (a fails 1.3s before it), b's reply comes at
4.7s with the first event bounded at 3.5s, and the second half's pause
is 10s with a 6s bound (1.2s expected, 11.2s waited).

Run:
- Reproduced the body failure on origin/main 7d15df78a by injecting
  350ms into a's wait (1050ms): overload_test.go:269 got a's
  server_is_overloaded, as in #1800's comments.
- With the change: passes 3/3; with 1s injected into a's wait (1.7s);
  with 1.3s injected into each member's wait in the second half; 8/8
  under 24 busy loops on top of other sessions' load (load average
  38 to 69).
- Broken by hand: tooQuiet returning false fails the first bound
  (4.72s); the replan and passing pauses no longer skipped when too
  quiet fails the second (21.8s, a 2, b 1).
- gofmt -l clean; go vet darwin, linux -tags nogui, windows.

Not tried: the whole gateway package after the change (only this
test); CI's machines. The test takes about 6.3s, up from 4.5s.
2026-10-14 08:47:30 +08:00
yetone 40df6dbd38 provider: a subscription sign-in canceled while its token is fetched adds no account (#2054)
A sign-in checked canceled/finished only when its callback was claimed.
The token exchange after that went on to addLogin / addGoogleLogin /
addSideLogin and only then called finish, a no-op after CancelSignIn, so
a sign-in the user canceled while its token was in flight still added
the account, or replaced an existing account's tokens. Sibling of #1750
(mcpauth's flow.keep, 1a7aa76b4).

Every built-in sign-in's write of its account now goes through one gate:
keepLogin(ctx, store), which finds the flow s.via put on the sign-in's
context and runs store under the flow's lock only while the flow is
live (signInFlow.keep). The CLI-run sign-ins (Claude, Grok, Cursor),
whose context isn't the flow's, call s.keep directly. Cancel takes the
same lock in finish, so either it comes first and nothing is written
(the flow stays "canceled"), or the account is kept and a cancel after
that is too late (kept): the flow then goes on to "done", matching the
account list.

Routed through it: Codex and Devin callbacks (Devin's own credentials
file and its side home), Gemini/Antigravity, ChatGPT API, Claude Code,
Copilot, Command Code (callback and pasted key), Factory, Kiro, MiMo,
Qoder, WorkBuddy, Zed, ZCode, and runCLISignIn's identity (Grok's second
account). Plugin sign-ins are kept by the plugin host and aren't
covered here.

Run:
- TestCanceledSignInAddsNoAccount (Codex: browser callback and pasted
  address, the token endpoint's reply held until CancelSignIn) and
  TestCanceledDeviceSignInAddsNoAccount (Copilot device code, GitHub's
  answer held, read whole, until after the cancel). On the old code all
  three FAIL: "the canceled sign-in wrote ~/.codex/auth.json", "the
  canceled sign-in added cx@example.com", "the canceled sign-in added
  late-user". With the fix they pass, -race -count=5.
- go test -tags nogui -timeout 45m ./internal/provider/... ok (sandbox
  HOME, private GOCACHE).
- gofmt -l clean; go vet ./internal/provider (darwin), GOOS=linux and
  GOOS=windows go vet -tags nogui ./internal/provider ok.
Rerun after rebasing on origin/main f71155591 (#2052, which touches
provider/models.go): gofmt and the three vets ok; the provider suite
(-timeout 45m) ended once in a bare FAIL with no test named, then passed
3 runs in a row (one -v). Filed as #2061. Rebased again on 8da304767:
gofmt, the three vets and the provider suite ok.
Not tried against a real vendor's sign-in.
2026-10-14 08:39:37 +08:00
yetone 7d15df78a2 gui tests: signin-proxy brings Custom… into sight before its second click, which the sign-in drawn again put under the editor's bar at 380 in German
The test's second click on "Custom…" failed now and then in German at
380 (also on origin/main 56fcd1dc2): the sign-in started again draws its
link anew at the editor's foot, partly under its bar, and the click
landed on the bar. It now scrolls the row into view first, as the first
click does.

Run: signin-proxy.test.cjs in Chromium and WebKit, every width and
language: 40/40; the German 380 case alone 8/8 after (it failed before
in the full sign-in run).
Not tried: the app's look at 380 by hand.
2026-10-14 08:36:07 +08:00
yetone b319657301 gui: a sign-in whose browser didn't open says why and shows its link, and Windows names rundll32 by its path (#2043)
xiaobaifly7: on Windows, signing in to Cloudflare's MCP server (and any
sign-in) opened no browser, and the window said to finish in the
browser until the sign-in timed out. Wails' Browser.OpenURL starts
rundll32 by its bare name, which Go looks up with PATHEXT's extensions;
a PATHEXT without .EXE (WSL passes one on as ".CPL") finds nothing, and
host.OpenURL dropped the error.

- proc.OpenBrowser starts %SystemRoot%\System32\rundll32.exe by its
  path (open / xdg-open / termux-open-url elsewhere) and returns the
  launcher's error. host.OpenURL falls back to it when Wails' fails, and
  the CLI's account sign-in uses it.
- Windows.OpenURL returns the error. /api/signin, the plugin sign-in and
  /api/library/mcp-signin answer it as openError; /api/open fails with
  it, so Open again says why.
- The sign-in card shows "magpie couldn't open your browser: {error}.
  Open the sign-in link below in a browser yourself." where it said
  magpie opened the page, with the link already shown below; the MCP
  editor shows the error with the link and a copy button. Translated
  (zh, zh-TW, ja, de).
- Open again matched its sign-in by identity, so a poll that put a fresh
  copy of the same sign-in in place kept the old error after a
  successful retry; it now matches by id.

Run:
- TestBrowserNamesRundll32ByItsPath, TestMCPSignInSaysTheBrowserDidntOpen
  and the /api/open and /api/signin tests in signin_open_2043_test.go.
  Broken by hand: the bare name back in browserCommand fails the first;
  openError returning "" fails the gui tests.
- On the Windows box (amd64, cmd with PATHEXT=.CPL): exec.Command
  ("rundll32", ...).Start() gave `exec: "rundll32": executable file not
  found in %PATH%`; proc.OpenBrowser started it (nil). The proc test
  binary's TestBrowserNamesRundll32ByItsPath passed there.
- signin-browser-down.test.cjs (new): the card's text, the link, no
  sideways overflow, Open again failing then succeeding, and the MCP
  editor's error and link, in Chromium and WebKit at 1100 and 420 in
  every language: 20/20. The related sign-in GUI tests: 451/452, the
  one a signin-proxy flake also on main (fixed in its own commit).
- gofmt -l clean; go vet darwin, linux -tags nogui, windows; GOOS=linux
  and windows builds; go test -tags nogui ./internal/gui/
  ./internal/proc/ ./internal/cli/.

Not tried: the real Wails app on Windows under PATHEXT=.CPL (the
fallback path is exercised only through proc.OpenBrowser), WSL itself,
the reporter's machine. Not covered: internal/tui/sessions.go and
internal/provider/install.go start `powershell` by its bare name, which
would miss the same way under such a PATHEXT.
2026-10-14 08:36:07 +08:00
yetone 8da304767a gui: Library is a plugin's page, its script, style and words in plugins/library
P2 of docs/subsystems/plugin-runtime.md, the second page after Sessions.

- library.js and library.css move to assets/plugins/library/ (client.js,
  library.css). The script registers with the kernel
  (magpie.plugin("library")) and adds its page to the "page" slot. Its
  hooks: open and relang load, redraw, close (its modal), dirty, discard.
  What it set up at load (list scroll and resize, the modal's backdrop
  and Escape, beforeunload, the stuck header, a quiet reload on focus)
  runs in mount.
- app.js calls those through magpie.call instead of window.loadLibrary,
  redrawLibrary, closeLibraryModal, libraryDirty and discardLibrary. It
  no longer lists library in its title map, hide loop or OPEN_VIEWS; the
  kernel's pages are in them.
- index.html: <main id="view-library"> goes, the kernel makes it.
  library.css keeps its place in the cascade.
- The 560 strings only Library says move from i18n.js to
  plugins/library/i18n.js (4 languages). i18n.js: 18826 → 16584 lines.
- plugins/library/library.go lists the client files.
- Tests that read i18n.js for a Library string read strings.cjs (i18n.js
  and the plugins'): 8 library tests and mcp-editor-cancel,
  mcp-oauth-app, mcp-signin-health. font-cascade, win-fonts and
  assets_revalidate_test.go name the new paths.
- "Check again" stays in i18n.js: Library said it alone when the words
  were split, and a5d72a095 (Settings' search keys) says it too since.
  i18n-keys has a new test, "a plugin's words are its own": a key in a
  plugin's i18n.js that any file outside the plugin's folder says fails
  it, naming the file. It was red on this key, and search-keys.test.cjs
  said "Check again" had no zh translation.
- docs: library.md, gui-shell.md, plugin-runtime.md.

Run, at this tree:
- 101 GUI test files touching Library, skills, MCP, the plugins, the
  shell and every language (gui-de/ja/zh-tw, i18n-keys, page-width,
  view-no-sideways, mobile-web, text-size, …): Chromium and WebKit, 4 at
  a time, all green but one. text-size's "zh: 100% picked at the foot"
  failed once in Chromium under load ("scrolled from 160 to 109 (max
  115)"); it passed alone, 6 at once here and on origin/main 8f34bbcd1,
  and at 6× and 12× CPU throttling. It's the Settings page, already
  "fixed" by 50dd39104, so I filed it as #2058.
- After rebasing onto origin/main 75cbc7e1e: i18n-keys, search-keys,
  library-mcp-tools, library-all, gui-de, mono-icon-redraw,
  group-first-token, Chromium and WebKit, green.
- go test ./internal/gui/ ./internal/pluginrt/ ./plugins/...; gofmt;
  go vet on darwin, GOOS=linux -tags nogui, GOOS=windows: clean.
2026-10-14 08:33:25 +08:00
yetone 5b76aa4da7 gui: a mask picture is named in full, so a plugin's stylesheet draws it from the right folder
maskSpan set a logo's picture as `--i: url(icons/x.png)`. A url() in a
custom property is read against the stylesheet whose rule uses the
variable, not the page. app.css sits beside index.html, so that was
right by luck. Moving Library's stylesheet into plugins/library/ (P2)
made `.lib-rtk-logo .mask` ask for plugins/library/icons/rtk.png, and
RTK's logo went blank: every library-rtk-* test went red, reading a
file that isn't there. maskSpan now names the picture against the
page's base (new URL(src, document.baseURI)), for its span and the
shelf's alike.

mono-icon-redraw's guard, that only maskSpan sets a mask's picture,
read assets/*.js only; it now reads the plugins' folders too and knows
maskSpan's `pic`. Broken by hand: a stray setProperty("--i", url(…))
in plugins/library/client.js turns it red, naming the line.

Run: library-rtk-{admin,gain,nohook,path,upgrade}, mono-icon-redraw,
factory-sub, mimo-sub, zed-sub, pi-default-note, usage-ledger-chart,
in Chromium and WebKit, all green (with the Library move on top; the
rtk tests failed without this).
2026-10-14 08:33:24 +08:00
yetone 1eaf1e890a gui: Sessions is a plugin's page, its script, styles and words under assets/plugins/sessions (P2)
The first page of P2 to leave app.js's core. sessions.js and sessions.css
move to assets/plugins/sessions/ (client.js, sessions.css). The page
registers through the kernel as magpie.plugin("sessions"): mount takes its
<main>, which the kernel now makes, open and relang read it again, and
reveal is the Usage page's way in. window.loadSessionsPage and
window.openSessionOnPage are gone. app.js reaches the page only through
magpie.call, and show() takes a page's title from its part. The plugin's
manifest lists i18n.js, sessions.css and client.js.

Words: the kernel's magpie.strings(dict) adds a plugin's words to I18N.
A key that is already there is logged and not taken, since the later one
would silently win. The 65 keys only the Sessions page says (own-keys over
every asset, Go and index.html) move, as written, from i18n.js to
plugins/sessions/i18n.js. tests/strings.cjs reads i18n.js and every
plugin's i18n.js as the page has them. gui-de/ja/zh-tw use it, and
i18n-keys now checks that no key is said twice across files and that a
plugin's words are in every language. TestBuiltinClientsLoaded takes a
.css entry as a <link> in <head>, and a script between kernel.js and
app.js.

Docs: plugin-runtime.md (Words, Pages moved out: Sessions), gui-shell.md,
gateway-sessions.md.

Run:
- go test ./internal/gui/ ./internal/pluginrt/ ./internal/gateway/: ok.
- gofmt clean. go vet darwin, GOOS=linux -tags nogui and GOOS=windows on
  gui, pluginrt and plugins: clean.
- GUI, in both chromium and webkit, 40 files, all green:
  - the sessions-* and sess-* tests, session-identity, routing-sessions,
    account-mask-sessions, usage-session*, gateway-conversations;
  - plugin-kernel, the plugin-move* tests, font-cascade, win-fonts;
  - i18n-keys, gui-de, gui-ja, gui-zh-tw.
- session-terminal's red under parallel load is the same on origin/main
  591ed58b5. It is fixed at its cause in the commit before this one.
2026-10-14 08:33:24 +08:00
yetone efbacd4e54 gui tests: session-terminal clicks Theme only once the Ghostty save has drawn the page again
The Theme click resolved its button before the Ghostty save came back.
When the save then redrew Settings, the click landed on the button from
before, whose handler still holds the page as it was drawn
(sessionTerminal ""). Against the new prefsBase that "" reads as a change,
so the theme save sent the terminal back to System default, and line 119
saw "". It failed 1 to 2 runs in 5 when 5 ran in parallel, on origin/main
591ed58b5 as well as on the P2 branch.

The test now marks the Theme buttons before the pick and waits for new
ones, as a reader can only click what is on the page.

Run: holding the Ghostty POST 400ms and the Theme click 600ms fails the
old test every time and passes the new one; 5 parallel runs
(chromium ×4, chromium+webkit ×1) all green.
2026-10-14 08:33:23 +08:00
yetone 82f3befd29 daemon: magpie daemon install --web serves the browser page from the service, with a link that lasts (HuanCheng Bai)
HuanCheng Bai on Discord runs `magpie daemon` on a Linux server and asked
for the daemon to serve the web page too, or for an option to turn it on.
`magpie web` run beside it is a second process, and he read it as not
seeing the daemon's state.

- `magpie serve --web[=host:port]` serves the gateway and `magpie web`'s
  page from one process (stats, StartWeb, Wait). The default page address
  is 127.0.0.1:3430. Any other argument is refused, where before it was
  ignored.
- `magpie daemon install --web | --lan | --addr host:port | --no-web` and
  `magpie daemon web [on|off] [--lan] [--addr host:port]`. The unit's
  ExecStart and the plist's ProgramArguments become `serve --web=<addr>`,
  and the key goes into the 0600 file's environment as MAGPIE_WEB_KEY. The
  key is made once. A reinstall with no flags keeps the page and its key
  (read back from the file by daemon.Web), so the link survives restarts
  and reinstalls. `web off` drops it. MAGPIE_WEB_KEY in the shell, when
  set, is used and checked like magpie web's. The page defaults to
  loopback; --lan or a non-loopback --addr prints the network links and
  magpie web --lan's warning.
- `magpie daemon status`, install and `daemon web` print the page's link.
- `magpie web` while the service serves a page prints that page's link and
  exits. Beside a gateway another magpie serves, it says so and points to
  `magpie daemon web on`.
- docs/reference.md (the service section and the Use list), and the
  site's start page (en, zh, ja). The READMEs don't cover the daemon.

Run:
- Tests: TestInstallWithWeb (systemd and launchd, plutil lint, read back,
  reinstall without the page, the shell's key not carried, no key
  refused), TestWebNotInstalled, TestParseDaemon, TestWebOptions,
  TestDaemonStatusPrintsPage and TestServeArgs. Each of these went red
  with its line reverted by hand: withKey, prevKey in webOptions, and the
  status page line.
- Sandbox HOME with a fake launchctl:
  - `daemon install --web --lan` wrote a 0600 plist with
    `serve --web=0.0.0.0:3430` and the key. plutil said OK, and it printed
    the link, the network links and the warning.
  - Reinstalling with no flags kept the key. `daemon status` showed the
    link.
  - `daemon web off` / `daemon web` / `daemon web on` behaved as above,
    with a new key after off.
  - `daemon web bogus` and `serve --lan` gave the usage errors.
- `serve --web=127.0.0.1:3462` served the gateway (3461) and the page in
  one process. The page answered 200 with the key and 401 without, and the
  page and /v1/models both showed 3 models. `magpie web --no-open` beside
  it printed the service's link and exited 0.
- gofmt -l; go vet (gui), and go vet -tags nogui for darwin, linux and
  windows; go test -tags nogui ./... in a sandbox HOME.

Not tried: a real systemd on Linux. The unit text is checked by test only.
2026-10-14 08:32:41 +08:00
yetone a39e675d2a gui: magpie web beside a busy gateway waits for the port instead of failing to bind it (K.Liu)
K.Liu on Discord: `magpie web` next to the systemd `magpie daemon` logged
"gateway: listen tcp 0.0.0.0:3425: bind: address already in use".

Cause: before listening, serveGatewayLocked asks the gateway's address
whether a magpie serves it (ServedBy, one GET with a 700ms timeout). A
magpie that holds the port but doesn't answer in time (busy on a small
server, or still starting) reads as "nobody", so the page's process
listened itself and the bind failed. With the service answering, no
second gateway was started and the page's state matched.

Now, after ServedBy says no, gateway.Taken() dials the address (500ms).
When something accepts, this magpie doesn't listen; it logs once that the
port is taken and leaves it to the 15s watch, which serves the gateway
once the port is free.

Run:
- Sandbox HOME, settings {"port":3461,"lan":true}: `magpie serve`, then
  `kill -STOP` it, then `magpie web --no-open --addr 127.0.0.1:3462`. The
  old binary printed the exact bind error. The new one logs "is taken but
  doesn't answer as magpie yet" and doesn't bind. After SIGCONT,
  /v1/models and the page's /api/state show the same 3 models. With the
  serve killed, the page's process took 3461 over in about 16s.
- TestGatewayNotServedBesideASlowOne (a listener whose handler blocks):
  it goes red with the Taken check reverted by hand.
- gofmt -l; go vet (gui), and go vet -tags nogui for darwin, linux and
  windows, on cli, daemon, gui and gateway; go test -tags nogui ./... in a
  sandbox HOME.
2026-10-14 08:32:40 +08:00
yetone 2d8f2a86a5 sessions: Kimi Code sessions open as a transcript (#2056)
infinitr0us: a Kimi Code session on the Sessions page had no transcript
to open. HasTranscript now lists kimi, and kimiTranscript reads the
session's main wire.jsonl:
- protocol 1.4/1.5: turn.prompt and turn.steer (a prompt not from the
  user, a skill's activation or a background task's news, is folded as
  context), and the loop events content.part (text, think), tool.call
  and tool.result, a result named for its call. These are there for
  every session, finished or running; agent.message.appended (1.5, only
  at a turn's end) and the timed context.append_message records say the
  same again and are passed over.
- kimi-cli imports (1.0, and the head of a ses_* session Kimi Code
  reopened): the untimed context.append_message records, with an
  assistant's toolCalls in both shapes (name/arguments and OpenAI's
  function.{name,arguments}).
Search and markdown export read the same parts.

Run:
- TestKimiCodeTranscript on the #1607 reporter's wire files in testdata
  (1.4, a cancelled 1.4, an early 1.5 started by a skill, a failed 1.5,
  a kimi-cli import), and TestKimiCodeTranscriptOrder on a synthetic
  file in the same record shapes, exact part order plus SearchSession.
- Broken by hand: kimi out of HasTranscript fails both tests; reading
  the timed context.append_message records fails both (user/text 9,
  not 3).
- A nogui build's `magpie web` under a sandbox HOME, KIMI_CODE_HOME on
  the reporter's whole zip (8 sessions, the July subagent session and
  a reopened ses_* among them): all 8 listed with a transcript;
  /api/sessions/transcript gave 105, 13 and 205 parts for June, the
  reopened ses_* and July; the markdown export worked.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows;
  go test -tags nogui ./internal/sessions/ ./internal/gui/.

Not tried: a live Kimi Code session on this machine (none here; the kimi
installed is kimi-cli 1.52.0), the GUI's look of the transcript, WSL.
A subagent's own wire file isn't shown; the main agent's is.
2026-10-14 08:28:52 +08:00
yetone 75cbc7e1e5 provider: a subscription switched off or removed makes no background requests, no claude auth status every minute (Riko on Discord)
Riko switched Claude off in Providers, and magpie still ran
`claude auth status --json` about every minute. Off only kept the
gateway from routing to it. Every page and request lists accounts,
which re-asked the CLI, and the background loops went on reading
allowances, renewing, switching, warming, checking in and fetching lists.
The same held for each sibling with a CLI or account check: Cursor
(`cursor-agent about`), Devin (`devin auth status`) and the rest.

What changed:
- left_alone.go: leftAlone(id), true for a provider that is Off or
  Hidden (account removed).
- account.go claudeIdentity and cli_identity.go get (Cursor, Devin): the
  CLI isn't asked; what it said last (memory or cli-identity.json) is
  served, so the account stays listed to switch on again.
- subscription_usage.go: claude, cursor and grok are checked as hidden
  before their account is looked up (the look-up ran the CLI).
- login_usage.go loginUsageAt, keepalive.go RenewLogins,
  codex_switch.go NextLogin, codex_warmup.go keepWarm: leftAlone where
  only accountRemoved (or nothing) was checked.
- models.go newDue: a provider that is off has no list fetched.
- checkin.go: each check-in account knows its card's provider; the loop
  skips one that is left alone, a press still checks it in (minimax,
  trae, qoder, workbuddy, plugin check-ins set it).
- docs/subsystems/providers-accounts.md says so.
Not covered: KeepPluginsListed lists every plugin at once in the host. A
Cursor switched off that was never asked who is signed in isn't listed
until switched on.

What was run:
- TestLeftAloneRunsNoCLI: fake claude, cursor-agent and devin on PATH log
  each run; with claude and cursor off and devin removed, All, Hidden,
  fetchSubscriptionUsage, LoginUsage, RenewLogins, SwitchWhenSpent and
  FetchNew run three times over stale caches and no CLI is run; switched
  back on, all three are asked again.
- Break check: with the source changes reverted it fails with
  "switched off or removed, the CLIs were run: [claude_auth_status_--json
  cursor-agent_about_--format_json devin_auth_status ...]"; with only the
  claude gate removed only claude is logged, with only cliIdentity's only
  cursor and devin.
- go test -tags nogui -timeout 45m ./internal/provider ./internal/gateway:
  ok (399s, 1271s).
- gofmt -l: clean. go vet (darwin), GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean, under set -o pipefail.
2026-10-14 08:28:08 +08:00
yetone 195a1009b0 gui: a routing group's Slow to start takes minutes of your own, beside Wait, 30 s, 1 min and 2 min (Kismet Alan on Discord)
The group editor's "Slow to start" (迟迟不出字) row offered only Wait,
30 s, 1 min and 2 min. Kismet Alan wanted a longer time of their own.

What changed:
- routing.js: the row gets a Custom segment, the same pattern as the
  Context row's Custom: picking it shows a small minutes box beside the
  segments (5 from Wait, else what was picked), focused to type in.
  Decimals are taken (2.5 is 150 s; a comma is read as a point). Anything
  else marks the box aria-invalid and the hint says "{v} is not a number
  of minutes"; the last good value is kept. A saved time that is none of
  the presets opens as Custom with its minutes. firstToken is still sent
  in seconds, and the card's "Next after 150 s without a first token"
  and the gateway are unchanged (provider.Group.FirstToken takes any
  seconds >= 0).
- routing.css: the box and its "min" unit inside the existing ctx-wrap.
- i18n.js: Custom was already there; "e.g. 5", "Minutes", "min" and the
  error in zh, zh-TW, ja and de.
- group-first-token.test.cjs: now five languages (en, zh, zh-TW, ja, de)
  at 1100 and 420 wide in Chromium and WebKit. It adds the Custom flow:
  no box until Custom, 5 to start and focused, "abc" refused with the
  hint naming it, 2.5 saved as 150 and shown on the card, reopened as
  Custom 2.5, back to 1 min hides the box, and the row stays inside the
  editor with no horizontal scroll. At 420 the editor runs past the
  window's foot and WebKit doesn't scroll the page's scroller to a
  click, so the test wheels each control into view.

What was run:
- NODE_PATH=<playwright@1.62.0> node --test group-first-token.test.cjs:
  20 of 20 pass (2 engines x 5 languages x 2 widths).
- Break check: with routing.js at the old code the test fails waiting
  for the Custom segment.
2026-10-14 08:28:08 +08:00
yetoneandlu123bing c9af654b26 gateway: Kimi Code takes a Claude Code session that loaded a deferred tool, and DeepSeek one that dropped a tool (#2042, davisjiahao)
Claude Code's deferred tools (ToolSearch, MCP tools that come and go) put
blocks of their own in a message: tool_addition (its tool a
tool_reference naming the tool, or a tool_definition), tool_removal, and
tool_reference. magpie relays an Anthropic body as it is, so they reached
vendors' Anthropic endpoints.

Checked against the real endpoints on 2026-10-14 (a Kimi Code CN key, a
DeepSeek key; shapes read from Claude Code 2.1.296's own builder):
- Kimi Code refuses any of them, in any role and either tool shape, with a
  whole-request 400 "Invalid request Error" that names nothing; a
  tool_reference inside a tool_result passes.
- DeepSeek takes a tool_addition naming a tool, but refuses one defining
  it, a tool_removal and a message's tool_reference: 422 "messages[1].
  content: unknown variant `tool_removal`, expected one of ...".

What changed:
- withoutDeferredTools (anthropic_shapes.go) drops those message blocks
  and a message they leave empty. The tools stay in the request's tools,
  and ToolSearch's answer (a tool_reference inside a tool_result) stays.
- Kimi (isKimi) is never sent them: its 400 says nothing to learn from.
- Any provider that refuses one in DeepSeek's words is marked
  (shapeDeferred, refuseShapes) and asked again at once without them, and
  not sent them again while magpie runs. The shape-retry loop in forward
  now reads a 422 as well as a 400 (refuseShapes and refuseBetas only act
  on wording they recognise).
- Anthropic and every provider that takes them get them as Claude Code
  wrote them. Kimi's bare "Invalid request Error" is not added to
  shapeWords: it names no field, and with the blocks gone there is nothing
  left for it to cover.
- docs/subsystems/gateway-routing.md: a paragraph on the above.

Builds on lu123bing's fork branch (c4a0564), widened from Kimi to the
learned refusal after the DeepSeek check; this keeps a tool_addition
naming a tool for providers that take it.

Run:
- TestKimiIsSentNoDeferredToolBlocks (the reporter's literal body plus
  Claude Code's real shapes, through Handler) and
  TestDeferredToolBlocksRefusedOnceLeftOut (DeepSeek's literal 422,
  learned once; a provider that takes them keeps getting them).
- Break checks, each red: without the Kimi drop, 5 subtests "status 400:
  Kimi Code: Invalid request Error"; with the loop on 400 only, and
  without the mark, "status 422: DeepSeek: ... unknown variant
  `tool_removal`". Restored: green.
- Real use: a nogui build served from a sandbox HOME on 127.0.0.1:35211
  with copies of the Kimi Code CN and DeepSeek providers. The reporter's
  body to kimi-for-coding now reaches Kimi's account check (403, the test
  key's plan has lapsed) instead of the 400; a tool_removal to DeepSeek
  reaches its balance check (402) instead of the 422. A full successful
  Kimi turn wasn't possible on this key.
- gofmt -l clean; go vet, GOOS=linux go vet -tags nogui, GOOS=windows
  go vet on internal/gateway; go test -tags nogui ./internal/gateway/
  in a sandbox HOME: ok (1516s). An earlier run of the same suite, with
  five other gateway.test binaries running on the machine, ended FAIL
  after 1484s; its output was cut to the last 30 lines, which held no
  test name, so the failing test is not known.

Co-authored-by: lu123bing <12312702@mail.sustech.edu.cn>
2026-10-14 08:26:38 +08:00
yetone 8f03b78069 cli, gateway: magpie statusline prints the session's model and each account's windows for Claude Code's status line (#1997, kensenzhao)
kensenzhao asked for magpie's routing and quota in Claude Code's status
line. Claude Code runs the statusLine command on every update and cancels
the run that is still going, so the command must answer fast. It must never
make a vendor read.

- `magpie statusline [<provider|account>]` reads Claude Code's statusLine
  JSON from stdin. It prints "→ <served model>" from
  /v1/magpie/route?session=<session_id>, then each subscription account's
  windows ("claude a@x* 5h 62% 7d 41%"). `*` marks the account that served
  last. A window whose reset has passed shows 0%. With the gateway off it
  prints an empty line. Each request times out after 1s.
- /v1/magpie/quotas?kept=1 (provider.KeptQuotaReport) builds the same
  report from the kept cards (CachedCards) and never starts a vendor read.
  The plain endpoint can take up to 12s.
- magpie never writes statusLine into Claude Code's settings. The user
  adds `"statusLine": {"type": "command", "command": "magpie statusline"}`
  themselves (magpie statusline's help, docs/reference.md).

Run: go test -tags nogui ./internal/cli ./internal/provider
./internal/gateway in a sandbox HOME; gofmt -l; go vet natively and with
GOOS=linux and GOOS=windows.

Broken by hand, each went red:
- the CLI asking without kept=1 (TestStatuslineTellsRouteAndEveryAccount);
- dropping the route line (same test);
- KeptQuotaReport calling QuotaReport (TestKeptQuotaReportAsksNobody).

Real use: a built binary against a sandbox gateway on 127.0.0.1:3517.
- kept=1 answered in 0.07s and route in under 1ms.
- `magpie statusline` with Claude-style stdin printed an empty line, since
  the sandbox has no accounts.
- Its ~1.1s wall time matches `magpie version`, so that is process start.
Not tried: real accounts, or the line inside a real Claude Code statusLine.
2026-10-14 08:26:04 +08:00
yetone a5d72a095b gateway, gui, cli: a search API's keys take turns, a refused one rests, and each Tavily key shows what it has used (SlouchyQuill)
SlouchyQuill on Discord asked for a Tavily key pool after
dsh-tavily-pool: several keys, each key's quota shown, keys rotated.
Before this, the comma-separated keys (#1477) always started from the
key that last answered, so one key took every search until it was
refused, a refused key kept no rest of its own, and nothing showed what
a key had left.

What changed:
- Turns (internal/gateway/search_keys.go). Searches take turns over the
  keys by default (round robin, a counter per vendor). pick=order (CLI)
  or In order (Settings) always starts from the first key; the pick is
  saved in SearchAPI.Pick.
- Rests. A refused key rests: 401/403 for 10m ("turned away"), 402 for
  1h ("out of credit"), 429 for its Retry-After held to 30s-10m (1m
  without one). 432/433 count as out of credit from Tavily only; from
  any other vendor they rest as a rate limit. A resting key is asked
  after the others, soonest back first, so failover is kept, and it
  wakes when it answers. Rests are keyed by a hash of the key.
- Quota (internal/gateway/search_quota.go). Each Tavily key's quota is
  read from GET /usage with that key. The fixture is the documented
  reply from docs.tavily.com. The key's own limit is used when it has
  one; otherwise its plan's plan_limit/plan_usage, which the account's
  keys share. A failed read, or a reply missing those fields, says
  unknown and why, never 0. A read is kept 2m unless asked fresh. A key
  found used up with no pay-as-you-go credit rests 1h; a later read
  with credit wakes it.
- Keys never appear in full. The vendor's error has the key masked
  (tvly-…abcd), and errors name "key N (tvly-…abcd)".
- GUI. Settings › Models › Web search adds a "Keys of <API>" row under
  an API with several keys or with Tavily's: In turn / In order, each
  key masked with what it has used and why it is asked last, and Check
  again. There is an API for it (POST /api/settings/search-quota), and
  13 strings in zh, zh-TW, ja and de.
- CLI. `magpie search` lists the pick and each Tavily key's quota, read
  fresh; `magpie search add … pick=turns|order`.
- Docs. gateway-routing.md has a new section "A search API's keys";
  both READMEs have a line on web search.

What was run:
- go test -tags nogui ./internal/gateway ./internal/provider
  ./internal/cli ./internal/gui: ok. After the last rebase, provider
  and cli again, and gateway -race -run Search.
- New tests: TestReadTavilyUsage, TestSearchKeysTakeTurnsRoundRobin,
  TestSearchKeyRefusedRests, TestSearchRestFor, TestSearchQuotas and
  TestSearchKeyNeverInFull. Each guarantee was broken by hand and its
  tests went red:
  - turns pinned to the first key: RoundRobin and RefusedRests;
  - rests ignored: TestSearchAPIKeysTakeTurns, RefusedRests and
    TestSearchQuotas;
  - key masking removed: NeverInFull;
  - a failed read reported as known: TestSearchQuotas.
- gofmt -l; go vet -tags nogui for darwin, linux and windows on the
  four packages.
- GUI: search-keys.test.cjs covers en, zh, zh-TW, ja and de ×
  Chromium and WebKit × 1100 and 420px: 20/20. Without the new
  .search-keys .val wrap rule, de at 420px fails ("Erneut prüfen" went
  past the window's edge).
  - search-api, search-first, search-instead, search-mcp,
    searcher-pick, settings-search, provider-search, gui-de, gui-ja and
    i18n-keys: 56/56 in each engine.
  - Full suite in Chromium (concurrency 6, load ~40): 4498/4504. The
    files that failed (gateway-key-groups, rest-try-now,
    routing-wb-restricted, text-size, usage-sum-whole) were rerun
    alone. All pass except usage-sum-whole, which fails now and then
    on an origin/main worktree too under the same load (#1864, #2023;
    rest-try-now and routing-wb-restricted are #1905). None of them
    touch search.
- Real Tavily API with two invalid keys: /search returns 401
  {"detail":{"error":"Unauthorized: missing or invalid API key."}},
  which counts as a refusal. Both keys rest 10m as turned away, the
  error names them only masked, and both quotas read "unknown · 401".
  Checked through a test and through the nogui CLI binary in a sandbox
  HOME.

Not tried: a valid key's /usage against the real API. No Tavily key
was at hand, so the quota parsing is checked against the documented
bytes only.
2026-10-14 08:24:03 +08:00
yetone 1555cddfa0 agent: with Claude Desktop on magpie, Claude Code runs each model at its own window, not the least of them all (#2025, 6.1sol)
Claude Desktop's Code tab runs Claude Code on ~/.claude/settings.json
with every model Desktop lists. Claude Code takes one window
(CLAUDE_CODE_MAX_CONTEXT_TOKENS) for every model it doesn't know, and
magpie told it the least of Desktop's (#1458), so one small model held
a 500K or 1M one to its 131K.

Now, while Desktop is on magpie, magpie tells Claude Code the largest
window of Desktop's models and of Claude Code's own main and tier
models, and holds each model below it to its own with
modelSettings.<id>.autoCompactWindow (claudePlan, claude_budget.go).
CLAUDE_CODE_AUTO_COMPACT_WINDOW would take precedence over those, so in
this mode magpie's working window goes in the top-level
autoCompactWindow instead, and an entry is written only where a
model's window or threshold differs from what it would run at
without one. Claude models (and groups of them) are left out as
before. magpie's entries and top-level value are stashed and go when
Desktop leaves magpie. The user's own entries, top-level value and
variables are never written over: an entry of theirs past its model's
window (or "auto") holds the largest to that window, and with a
CLAUDE_CODE_AUTO_COMPACT_WINDOW of theirs the least window is told as
before. Desktop off is unchanged.

Verified with real Claude Code 2.1.296 in a sandbox
CLAUDE_CONFIG_DIR, on a settings.json written through magpie's editor:
/context shows 256k for mythos-magpie-2's entry, 131k for
magpie/v/gpt-6.1-sol (dotted key, with and without [1m]), and the
top-level 272k for a model without an entry, under a 1M
MAX_CONTEXT_TOKENS.

Tests: TestClaudePlan and TestBudgetPath (new), and
TestClaudeDesktopContextWindow / TestClaudeDesktopAloneContextWindow
rewritten (largest window, per-model entries, Full window, the user's
entry and top-level kept, Desktop off removing only magpie's). They fail
on the old claude.go (256000 told), and with the skip of the user's
entries removed from claudePlan. Run: go test ./internal/agent (full),
gofmt -l, go vet for darwin, GOOS=linux -tags nogui and GOOS=windows.
2026-10-14 08:17:33 +08:00
yetone 8a4cfe0e4e proc: a command that isn't installed is answered from each PATH folder's listing, not a stat per extension, so a Library change after a start no longer looks for ~100 agents' commands one file at a time on Windows (#1624, Hipple)
On every Library create, switch or delete, Targets() asks agent.Detected for
about a hundred agents. Each one's command is looked up with exec.LookPath,
and on Windows with FindTool's findDirs as well. A command that isn't
installed costs a stat of name+each PATHEXT extension in every folder. The
answers are cached (looked), but that cache is empty after a start and is
dropped whenever any PATH folder's mtime changes. With an antivirus slowing
every stat, that is the slow first change Hipple sees.

Each folder's listing is now read once (lower-cased names, also each name up
to every dot) and read again only when the folder's mtime changes. A
command that no folder has a name for is not found without a stat. One a
folder may hold, and any folder that can't be read, goes to exec.LookPath
and toolIn as before. On Windows the current folder is included unless
NoDefaultCurrentDirectoryInExePath is set, as exec.LookPath does.

Measured on the Windows test box (47 PATH folders, WSL agents off,
library ops through a throwaway test in a sandbox HOME):
- the first create after a start went from 486ms to 285ms; the old CPU
  profile was mostly exec.LookPath/GetFileAttributesEx;
- warm ops ~10ms either way.
With WSL agents on, the first op costs ~3.0s on both builds, about 2.7s of
it in wsl.exe list and probe spawns. This commit doesn't change that. On the
box, wsl -l -q, wsl -l --running -q and a docker-desktop probe each take
40-75ms, so a failed-probe retry every 10 min doesn't explain the report
there. The 5-8s after 10 min idle wasn't reproduced: ops after 4, 8 and 12
min idle took ~120ms.

Run: go test ./internal/proc ./internal/agent ./internal/library (ok);
gofmt -l; GOOS=linux and GOOS=windows go vet on the three packages.
I broke the fix by hand (look.go/find.go back to exec.LookPath, mayBeIn
check off), and TestMissingCommandsReadEachFolderOnce failed: "100 missing
commands were looked for on PATH 200 times, want 0".
2026-10-14 08:08:50 +08:00
yetone f71155591e provider: a provider at a vendor's own endpoint is priced from that endpoint's models.dev catalog (#2052, mengyianx)
A custom provider added by its address alone, with no catalog named, was
priced only by the model's maker. Qwen3.8-27B, whose maker (Alibaba) sells
no such model on any of its seven models.dev catalogs, read "no price is
known for it" even at AMD's own endpoint, where models.dev's amd lists it
at $0, a price.

- catalog: models.dev's provider "api" is read; AtEndpoint names the
  catalogs at a base URL (trailing slash and case ignored).
- provider: EndpointCatalog is the one catalog models.dev lists at one of
  a key's provider's endpoints (an Anthropic base, kept as its root, also
  with /v1), used by ListPrice when the provider has no catalog of its
  own. Never for a subscription's account, never when two catalogs share
  the address (minimax / minimax-coding-plan), never a plan's catalog
  (an id with -plan, or membershipCatalogs), whose $0 is the membership's.
  A user's price and a named catalog still come first; a relay's endpoint
  matches nothing and its model stays unpriced (no reseller guess).
- cli: `magpie model price p/m` with no price gives the two commands that
  set one (p/m and */m); a price from an endpoint's catalog names it.
- gui: the Catalog field's hint says it also sets list prices (en, zh,
  zh-TW, ja, de).
- docs: reference.md's "What a model costs", providers-accounts.md row.

What was run:
- Reporter's exact case, built binary (go build -tags nogui), sandbox
  HOME with a copy of this machine's models.dev cache (2026-10-14, same
  amd entry as the report), providers 001 (relay), 002 and amd at
  https://developer.amd.com.cn/radeon/api/v1:
    001/gpt-5.5      $5/$30, tiers, as before
    001/Qwen3.8-27B  no price, now with the two commands to set one
    002/Qwen3.8-27B  $0/$0, "what models.dev's amd lists at its endpoint"
    amd/Qwen3.8-27B  $0/$0
  The two suggested commands were run and took effect.
- TestEndpointCatalogPrices / TestEndpointCatalogOnlyItsOwn, fixture
  testdata/endpoint_catalog.json trimmed from the real models.dev cache.
  Break checks, each FAILs with the case named:
    ListPrice not using EndpointCatalog -> 002/amd/001 at AMD unpriced,
      EffectivePrice(002, Qwen3.8-27B) unpriced
    plan exclusion removed -> "a plan's endpoint: EndpointCatalog() =
      alibaba-coding-plan", qwen3.5-plus at $0 instead of $0.4/$2.4
    single-match rule removed -> "an endpoint two catalogs share:
      EndpointCatalog() = minimax"
    Account check removed -> "a subscription's account ... = amd"
    Anthropic /v1 match removed -> thinkingmachines unmatched
- GUI: internal/gui/tests/catalog-hint.test.cjs, chromium and webkit, en
  zh zh-TW ja de, widths 1100 and 420: 20/20 pass, plus i18n-keys; with
  the old app.js/i18n.js it fails "one hint names list prices".
- go test -tags nogui -timeout 45m ./internal/catalog ./internal/provider
  ./internal/cli: ok (provider 244s, cli 125s, catalog 3s). gofmt -l
  clean; go vet (darwin), GOOS=linux go vet -tags nogui and GOOS=windows
  go vet -tags nogui on those packages: clean.
2026-10-14 07:51:41 +08:00