Commit Graph
3783 Commits
Author SHA1 Message Date
yetone 6b3ee5a03b library: a repository that keeps its skills again under a plugin's folder lists each once (碳碳双键 on Discord)
tw93/waza keeps its eight skills in skills/ and again in
plugins/waza/skills/. Some of the plugin copies lag the top ones.
Typing "tw93/waza" in Library → Skills listed "16 skills", each one
twice. unhiddenFirst only folded a copy in a hidden folder (.claude/
skills, #1964) into the unhidden one; two unhidden copies both stayed.

It now keeps one copy of each skill. It prefers the copy outside hidden
folders, then the one fewest folders deep, then the first. That covers
both candidates (the probe and install) and skillDirsIn (the new-skill
check).

Run:
- TestRepoWithAPluginCopyListsEachSkillOnce uses waza's real paths.
  Against the old skills.go it is red (9 lines: 16 candidates, the
  plugin's descriptions, 16 tree dirs); with the fix it is green.
  TestMarketInstallsASkillKeptInClaudesFolder (#1964) is green too.
- Real use: ProbeSkills("tw93/waza") against GitHub in a sandbox HOME
  lists skills/check … skills/write, 8 in all, each once.
- gofmt -l clean; go vet -tags nogui ./... clean for darwin, linux and
  windows.
- Full suite: go test -timeout 45m ./... at load average ~115 (other
  sessions' suites). 63 packages ok. internal/agent and internal/gateway
  timed out at 45m with no test hung (TestOpenCodeAndCrushKeep… and
  TestStrictAffinity… had each run 0s), and go list -deps shows that
  neither imports internal/library. internal/gui's
  TestPanelJoinsFullScreenSpaces is #2450, red on main already.
2026-10-16 15:35:20 +08:00
deephbz e72b6a3327 gateway: preserve cache splits and known 1h writes across updates (#1717)
Keep reported Anthropic cache_creation splits, including pure-5m replies,
through API and subscription parsing and client output. Only positive
counters replace known usage. Completed sums retain all counters and
split presence.

Across continuation tries, search rounds and internal bridge messages,
partial updates add earlier total writes only with a positive total. A
split with counts and zero 1h keeps the current message's known 1h before
adding earlier messages' usage. A zero-filled or absent split keeps the
per-counter rule. Omit a zero-filled partial split with a positive total
from output; retain a reported zero-total split. Split presence and the
parsed update's own count evidence remain separate.

Yetone's zero-filled bridge probe and matching continuation/search probes
failed at 0c9298d with 10 instead of 15 1h writes. Fable's partial-5m and
pure-5m cases failed at e1de9bc7 in bridge, continuation and both search
modes with the same loss. All pass after the repair. The 12-case matrix
matches main's client totals and 1h counts and continuation/search ledger
counts. A renderer test rejects a fabricated 50/0 split on a sparse delta.

Verified under sandbox HOME, pinned Go caches and nogui: focused race,
Darwin vet ./..., Linux/Windows gateway vet, gofmt and diff checks. Archive
mutations removing current-message carry, bypassing each of three callers,
and restoring the fabricated split each fail behavior assertions. Restored
archive passes. Earlier zero-total, unreported-split and pure-5m cases stay
green. No live-provider check in this repair.

Review (yetone's session, landed from the PR's head c4cf224 and 90cdb2f):
the partial-cache probes go red when carryUpdate is reverted by hand,
and the 12-case matrix gives the same client totals and 1h counts as
main a15e57656. Rebased on 8b84dc902; gofmt clean; GOOS=darwin/linux/windows
go vet -tags nogui ./... clean.
Full suite: set -o pipefail; go test -timeout 45m ./... at the rebased head -> 65 packages ok, internal/gui red only on TestPanelJoinsFullScreenSpaces ("the panel shown doesn't take the keyboard"), red the same without this change, filed as #2450.
2026-10-16 15:14:48 +08:00
deephbz d9e87eb328 gateway: clients opt into Claude subscription cache marks and TTLs (#1717)
Problem:
Messages clients need control of cache boundaries and TTLs when a Claude
subscription answers. Ordinary clients must retain their run identity,
prompt and environment. A routing group's API-key member keeps its marks
and must not report the subscription bridge's drops.

Change:
Select client-owned marks only with X-Magpie-Cache-Marks: client. Map system
and fresh-history boundaries and the request tail, default missing TTLs to
5m, validate slot and TTL order, and separate opted-in run identities.
Retain prefix constraints across live and saved runs. Report unmappable
marks only for the Claude subscription try. Bound its selection hold to
two seconds and clear the report and hold for a non-Claude fallback.
Check ordinary identity bytes without a version-specific hash golden.

What was run:
Sandbox HOME, nogui: go vet ./... on darwin; gateway vet with GOOS=linux
and GOOS=windows; full gateway tests; focused cache and usage tests with
-race. gofmt and git diff --check passed. The group probe failed before
the fix with tools:1 on the API-key reply in both routing orders and both
stream modes. Hand-broken candidate scoping, stale report clearing,
keepalive holds and ordinary identity bytes each failed behavior tests.
Live, Claude Code on a Claude subscription and an Anthropic API key,
through a recording proxy: in a group whose API-key member answers, in
either order and both stream modes, the reply has no dropped-mark header
and upstream receives the tool mark; a Claude answer reports tools:1; a
failed Claude try followed by an API-key answer leaves no report. With a
delayed API-key reply, the group's first keepalive came 0.85 s after a
direct request's. Without the header, the outgoing request equals one
from a gateway built at the same base. No GUI or real Linux/Windows
execution.
2026-10-16 14:16:51 +08:00
yetone 8b84dc902b gateway: a gateway key held to some models is told of those image and video models alone in /v1/models (塔哥 on Discord)
A key limited to some models (#882) saw only those in /v1/models' chat
list, but the image and video entries (kind image/video) were listed for
every provider. Requests with them were already refused (draw.go,
video.go), so this was a listing leak only. A remote magpie signed in with
such a key showed the owner's whole image and video catalog.
drawerObjects and videomakerObjects now take the request and drop what
the key doesn't allow, as the chat list does.

Test: TestGatewayKeyModelsHoldTheImageAndVideoLists (key_models_test.go):
this computer and an unrestricted key see grok-imagine-image/-video, a
key held to elsewhere/* sees neither, a key held to
grok/grok-imagine-video sees that alone. Red on the old code (the
restricted keys saw both), green now.

Run at a15e57656 + this change, sandbox HOME:
gofmt -l clean; GOOS=darwin/linux/windows go vet -tags nogui ./... clean.
Full suite: set -o pipefail; go test -timeout 45m ./... -> every package ok except internal/gui TestPanelJoinsFullScreenSpaces ("the panel shown doesn't take the keyboard"), red the same on a15e57656 without this change (3 of 3 alone), filed as #2450.
2026-10-16 14:15:36 +08:00
yetone 107fbbc36d provider: moved Factory users get opencode-factory-auth 0.1.31, whose OpenAI models' requests go without temperature and top_p, not 400 (sweanng424 on Discord; magpie-community/plugins#154)
Raises the factory mover's min to 0.1.31 (npm view --prefer-online
@magpie-community/opencode-factory-auth@0.1.31 answers 0.1.31; published
by plugins 4e64f26's publish run 38857895455). The magpie side of the
class, plugin models' temperature: false not read, is #2492.

Run at a15e57656 + this change, sandbox HOME, go test -timeout 45m ./...:
every package ok except internal/gui, red only on
TestPanelJoinsFullScreenSpaces ("the panel shown doesn't take the
keyboard"), which is #2450 and fails alone 3 of 3 here; this change
touches only a string in internal/provider. gofmt -l clean.
2026-10-16 14:13:32 +08:00
yetone a15e576564 agent: OpenPencil uses magpie's models (@JC_be_better on X)
OpenPencil (ZSeven-W/openpencil, the openpencil-desktop app) keeps the
builtin agents its chat runs on in settings.json under Rust's
dirs::config_dir()/openpencil (read from its settings_io.rs and
settings_payload.rs). magpie adds one builtin_agents entry, id "magpie",
kind openai-compat at the gateway's /v1 with the magpie-openpencil key,
preset custom, the picked models as OpenPencil writes a list: the first
as `model`, `models` only for two or more, at most 64. The user's other
entries and settings stay, and so do the display_name and enabled they
give magpie's entry; a sync with nothing to change doesn't write. A file
magpie makes gets "version": 1 (OpenPencil sets a file without it aside
as corrupt); a file with another version, or none, is left alone.
Disconnect takes the entry out, and the file when nothing else is left.
OpenPencil reads the file once at start and writes it all back when it
quits, so a change is refused while openpencil-desktop runs (Windows
can't be asked, so the notice says to quit it first). Notice translated
in zh-CN, zh-TW, ja and de. README (en, zh-CN), docs/reference.md and
docs/subsystems/agent-wiring.md list it.

open-pencil/open-pencil, the other app of the name, keeps its providers
in its webview's localStorage, so it gets no row.

Run, under a scratchpad HOME with GOCACHE/GOMODCACHE pinned:
- go test -p 2 -tags nogui -count=1 -timeout 45m ./...: ok, 66 packages
  ok, 18 with no test files
- gofmt -l: clean; GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean
- go test ./internal/agent -run '^TestOpenPencil': ok
- node --test agent-notice-lang, i18n-keys, header-relang (Chromium and
  WebKit, every language, wide and narrow): 37/37 pass
Broken by hand, each went red: the running check, the 64 cap, the
version check, keeping the user's display_name, the no-op sync, and
writing the version into a new file.

Real use: OpenPencil v0.8.4 (latest release, arm64, sha256 checked against
its SHA256SUMS) under a sandbox HOME, started on a settings.json magpie
wrote with the user's own Anthropic entry beside it. It started and ran
15s with the file intact and no .corrupt copy. v0.8.4 has no `models`
field, so it lists only the first magpie model; main lists them all.

Not tried: a chat request through OpenPencil's UI; its exit save (it
didn't quit on an AppleEvent and was stopped with TERM, so the write-back
wasn't seen); Linux and Windows; a build of OpenPencil's main.
2026-10-16 11:43:51 +08:00
yetone 7597c13237 gui: a curl example pasted into a provider's editor fills it in (@mark_li21 on X)
@mark_li21 asked: 能支持通过curl例子直接导入provider不? A curl example
from a vendor's docs, pasted into a custom provider's Base URL or API key,
now fills in the editor instead of being pasted as text.

curlOf (app.js) is one pure function. It reads the paste the way a shell
would: lines joined by \, cmd's ^ or PowerShell's backtick; curl.exe;
quotes and escapes. From that it takes:

- the API that the URL's endpoint names: /chat/completions is Chat,
  /messages is Anthropic and /responses is Responses;
- the base URL before that endpoint, spelled by respellURL the way the
  editor already wants it;
- the key from Authorization: Bearer, x-api-key or api-key;
- the model in the JSON body.

A key that is only a placeholder ($X, ${X}, %X%, <token>, YOUR_API_KEY)
is not taken. The key box is left empty and focused instead. A new
provider adds the model to its models. A saved provider's picks are left
alone, because adding to an empty list would narrow what it serves. A
preset's editor only takes the key.

A note in the editor says what was filled in. It also points out a
placeholder left in the URL, such as {WorkspaceId}, and a URL with no
known endpoint. Its four strings are translated into zh, zh-TW, ja and
de. Text that isn't curl pastes as before, including several keys at
once.

Found along the way: url.onpaste = fromCurl cancelled every plain paste
into the Base URL, because an on-handler that returns false cancels the
event. The handler is now wrapped. The test fails on the unwrapped one.

Fixtures, in internal/gui/tests/fixtures/curl, are the docs' own bytes:
- OpenAI chat (API reference) and Responses (quickstart);
- Anthropic Messages;
- DeepSeek, Zhipu, Moonshot and OpenRouter quick starts;
- Alibaba Bailian's Windows cmd example (^ and \"-escaped JSON);
- SAP AI Core's PowerShell one-liner (curl.exe, <Deployment_url>);
- Unsloth Studio's PowerShell example, with backtick continuations, as
  its usage panel renders the template. This one is not copied from a
  static doc page.

The doc row is "A pasted curl command" in
docs/subsystems/providers-accounts.md.

Run at 674b6ca28 (origin/main) plus this change:
- provider-curl-paste.test.cjs (new): 10/10. It covers Chromium and
  WebKit; curlOf on every fixture, with LF and CRLF line ends; and the
  editor in en and zh at 900px and 440px. The editor checks are the
  filled form, the focused key, the note's text, plain and many-key
  pastes, the saved body, no sideways scroll, no <select> and no page
  errors.
- Related GUI files, run together with the new one, 112/112:
  gui-de, gui-ja, gui-zh-tw, i18n-keys, key-import, nokey-editor,
  provider-add-gemini, provider-base-api, provider-many-keys,
  provider-many-keys-proxy, provider-url-each-api and vertex-editor.
- Broken by hand, the new test goes red:
  - fromCurl taking nothing: 8 of 10 fail (the editor runs);
  - the endpoint not cut from the base URL: 10 of 10 fail;
  - url.onpaste = fromCurl unwrapped: the plain-paste check fails.
- gofmt -l: none. GOOS=linux and GOOS=windows go vet -tags nogui ./...: ok.
- go test -tags nogui -count=1 -timeout 45m ./... in a sandbox HOME:
  exit 0, 66 packages ok, no FAIL.

Not tried:
- the real app (Wails) on macOS, or WebKitGTK on Linux;
- Windows;
- a pasted command used to reach a real vendor with a real key.
2026-10-16 11:01:24 +08:00
yetone 674b6ca288 gui: a provider's per-key proxy lines fold past eight keys (@NetRozee on X)
@NetRozee on X: a custom endpoint given a thousand keys froze magpie.

Cause. The editor's Advanced > Proxy drew a line for every key, each
with a Provider's proxy | Direct | Custom control. Each control, once in
the page, looked up its place among every .segs in the editor and slid
its thumb (segsPlace, slide): quadratic, with a layout read each. The
Accounts list above it already folded (keyFold); this list didn't.

Fix. proxyLines folds a provider's keys as keyFold does: past KEYS_FOLD,
the first KEYS_FIRST and those with a proxy of their own, then All N
keys; opened, a filter (keyMatches, as the Accounts list's) over
KEYS_PAGE lines and how many more, and Show fewer. Typing draws the
lines again under the filter, which stays in the page (#1055). A key not
drawn keeps its proxy: Save posts every key's own, drawn or not.
Subscription accounts' lines are unchanged. No new strings.

Measured (Playwright, the editor opened on a provider of N keys):
                1000 keys          5000 keys
  Chromium      1067ms -> 100ms    55.6s -> 93ms
  WebKit        4809ms -> 68ms     203s -> 81ms
  DOM           9388 -> 434 nodes  45388 -> 434 nodes

Tests: provider-many-keys-proxy.test.cjs (new, en and zh, Chromium and
WebKit): fails in all four on the old app.js (no All 300 keys). With
account-proxy, provider-many-keys, filter-ime, usage-keys-fold,
i18n-keys, click-scroll, provider-proxy, proxy-own-wording,
routing-proxy, plugin-proxy-page, signin-proxy and proxy-test: 221 of
221 pass in both engines.

Run: gofmt -l (clean); GOOS=linux and GOOS=windows go vet -tags nogui
./... (clean); go test -tags nogui -count=1 -timeout 45m ./... in a sandbox HOME (GOCACHE, GOMODCACHE pinned) on af601541e with this series: 66 packages ok, 18 without tests, no FAIL (gateway 468.5s, provider 215.9s, gui 122.8s).
provider-many-keys-proxy.test.cjs rerun after the suite: 4 of 4.
2026-10-16 08:43:02 +08:00
yetone 0bbb2f3ca4 provider, gui, gateway: a thousand keys are listed once and read eight at a time (@NetRozee on X)
@NetRozee on X: "when I add a thousand keys for a custom endpoint magpie
just froze or crash by itself".

Cause. The Providers page asked, for each key, what it rests by
(RestKey), and RestKey listed every key on again (KeysOn), which itself
looked along the list for each key: cubic in the keys. /api/providers
and every /api/keys/* answer, an import too, are drawn through it. The
gateway asked, for each key of every request, whether it serves the
model (Serves), and each asking read the provider's lists again (a
filememo stat, and a read while the file is new) and looked along each
model's key ids. fetchPerKey looked along the lists for each key and
model the same way.

Fix.
- KeysOn drops repeats by a set.
- RestKeys finds once whether several keys are on; providerInfo uses it.
- Serving(model) reads the lists once and answers for each key from sets
  (keyLists, made again when the lists are read anew); perKeyBarred and
  the test pick use it. Serves is Serving for one key.
- fetchPerKey keeps each model's keys as a set and indexes the old list
  by key once; a model kept for a failed key is kept once, as before.
- KeysListed and ListsRead count listings and list reads for the tests.
Behaviour is otherwise the same.

Measured (go test in a sandbox HOME, a custom provider, 50 models):
                         1000 keys          5000 keys
  providerInfo           1.54s -> 7.5ms     2m42.9s -> 18.3ms
  providersState         1.65s -> 110ms     2m40.3s -> 146ms
  POST /api/keys/import  1.64s -> 82ms      2m44.7s -> 288ms
  of one more key
  gateway perKey         100.9ms -> 8.2ms   (old not run) -> 40ms
  (each request)

Tests (counts, not time), each red on the old code by hand:
- TestProviderInfoListsKeysOnce: old 1001 listings for 1000 keys, 11 for
  10; new 0 and 0.
- TestPerKeyReadsListsOnce: old 1001 list reads for 1000 keys, 11 for
  10; new 1 and 1.
- TestServingReadsListsOnce, TestRestKeysIsRestKey,
  TestKeysOnDropsRepeats: same answers as before.

And the vendor reads. KeyBalances, PlanQuotas and remoteKeyCards started a goroutine
for each key and asked the vendor with all of them at once: a thousand
keys were a thousand requests to one relay together, each holding a
connection and its body.

Fix. keySlots holds each provider's reads to keyReadsAtOnce (8); other
providers' keys are read beside them. A read whose context is done goes
on without a slot and fails at once, as before.

Tests:
- TestKeyReadsEightAtOnce: a Command Code provider of 31 keys and a
  remote magpie of 31 keys behind a server that holds every request.
  Old code (the slots taken out by hand): 31 at once for balances, plans
  and remote limits; new: 8, every card still there.
- TestKeySlots: a done context takes no slot; another provider's keys
  have their own.

Run: gofmt -l (clean); GOOS=linux and GOOS=windows go vet -tags nogui
./... (clean); go test -tags nogui -count=1 -timeout 45m ./... in a sandbox HOME (GOCACHE, GOMODCACHE pinned) on af601541e with this series: 66 packages ok, 18 without tests, no FAIL (gateway 468.5s, provider 215.9s, gui 122.8s).
2026-10-16 08:43:02 +08:00
yetone af601541ef routing: a request opens to its request and response (Fate on Discord)
Fate asked on Discord to see what a single request on the Routing page sent
and got back, such as a Codex prediction. The bodies were captured already,
in the Gateway page's 40 recent calls and the opt-in request archive, but
nothing led there from a Routing request.

- gateway: a Call carries the Routing request it was (Call.Route = the
  trace's Route.ID), set where serve, the Codex backend and a refused title
  record it. Server.RouteCall finds it in the ring. A route id is not a
  call id. A route names its archive copy (Route.Archive =
  call.archiveName()), set only when the archive was on, so it reaches the
  saved history too.
- gui: GET /api/gateway/call takes ?route= besides ?id=. It is the same
  handler, the same no-store, the same key guard and the same 404 once the
  ring has let the call go.
- Routing page: the story's head has "Request and response". It fetches
  only when pressed, and shows the masked bodies through callBodyPanel (an
  SSE reply reads as its events). A request the ring no longer has shows
  the archive's copy through archivePanel when the route names one.
  Otherwise it says the last 40 are kept until magpie quits and how to turn
  the archive on. Nothing more is captured or kept than before.
- The head now wraps. At narrow widths its buttons ran past the story
  ("Back to live" was cut off at 440px).
- The two button words live in i18n.js: i18n-keys' "a plugin's words are
  its own" found them inside core strings.
- docs/subsystems/gui-shell.md says how a route reaches its bodies.

Tests:
- TestRoutingRequestOpensItsBodies (new): each of two routes gets its own
  bodies; route 0 and an unknown route get 404. Red without
  `call.Route = tr.ID` ("route …: 404").
- TestArchiveWholeBodies now checks that the route names the archive. Red
  without the t.Archive line (`route names archive ""`).
- routing-bodies.test.cjs (new), chromium and webkit at 440px, en, zh,
  zh-TW, ja and de, 10/10. It covers the ring's copy read only when asked,
  hiding, another request closing it, the archive's copy, the
  how-to-keep note, nothing past the story and no left border.
  - Red with the client asking ?id= and with the head's wrap removed.
- routing-request-metrics.test.cjs: with the head wrapped, its 480px
  picker clicks in WebKit landed on the footer. Playwright's WebKit places
  elements in the scrolled view hundreds of px lower than
  getBoundingClientRect, which elementFromPoint agrees with. The test now
  clicks where the page shows them. 5 runs of both engines, 20/20.

Run in a sandbox HOME at f1c91a99c plus this change:
- gofmt -l: clean. go vet -tags nogui: darwin, linux and windows ok.
- GUI: routing-*, panel-routing*, recent-call*, i18n-keys and
  header-relang in both engines: 1079 tests, 1079 pass (a first run had
  2 reds, both fixed above).
- go test ./internal/gui after the i18n move (TestPanelJoinsFullScreenSpaces
  skipped): ok.

Full suite: `go test -timeout 45m ./...` gave 65 ok, 1 FAIL. The FAIL is
internal/gui TestPanelJoinsFullScreenSpaces ("the panel shown doesn't take
the keyboard"), red 3/3 alone here and red the same on origin/main
1d227a7eb just fetched. It is filed as #2450.
2026-10-16 07:23:55 +08:00
yetoneandggbdpq 1d227a7eb9 tui: a group's page keeps the row picked and its header in view (#2452)
What changed
- viewGroup drew every member and every rule and left the rest to the
  terminal. A group with more of them than the terminal has rows (a
  whole provider's thirty models at 80x24) scrolled the header and the
  highlight off the top, and j/k moved a pick no one could see. The
  library page (#2220) and the agents page (#2428, fed24aa1d) had the
  same disease; this was the last page with a cursor and no window.
- groupWindow draws the rows around the pick, as ggbdpq's patch does: a
  pick among the models keeps the first rules below it, a pick among the
  rules keeps the models' tail above it, a short group is drawn whole.
- groupRows counts every other line the page draws, including the
  pattern lines, the classifier line and the "none" line, which the
  patch's flat h-10 left out. With h-10 the page still ran three lines
  past the terminal and its header scrolled away.

Run
- New TestGroupViewKeepsTheRowPicked: thirty models; one model with 24
  rules; both, with three patterns and an intent rule's classifier.
  Every pick at 24 and 40 rows must draw no more lines than a short
  group's page, keep "◉ magpie" on screen, and mark the pick's own
  numbered row. A tall terminal draws the whole group.
- Broken by hand: old routing.go goes red (pick 0 draws 41 lines,
  22 fit), the patch's h-10 goes red (25 lines), and leaving the
  patterns uncounted goes red (23). With the fix it's green.
- Other cursor pages were audited (agents, providers, groups, library,
  sessions, pickers). All are windowed; only the group page had none.
- gofmt -l clean; go vet -tags nogui for darwin, linux and windows.
- Full suite: go test -timeout 45m ./... at f1c91a99c: 65 packages ok, internal/gui red only in TestPanelJoinsFullScreenSpaces ("the panel shown doesn't take the keyboard"), the macOS 26.2 red filed as #2450 and red on main without this change.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-16 06:32:59 +08:00
yetone ba17c4f90d provider: a Command Code plan key's card shows the month's credits as a meter (#2451)
tianxia3111 runs Command Code on the keyed preset with a plan's key. Its
card showed the 5-hour and weekly windows as meters, but the month's
credits only as dollars left ($5.27), with no share of the month. The
cause: billing/credits leaves out the planId, so the key's card couldn't
know the plan's monthly pool. The signed-in subscription's card gets
that pool from billing/subscriptions.

The key's card (planKeyWindows -> cmdKeyWindows) now asks
billing/subscriptions with the same key for the plan. It then makes the
month a "Credits" window beside the other two, through the same
cmdQuotaOf the subscription's card uses ("$4.78 / $10.00" on a Go plan).

- The plan id is kept per key for ten minutes, since
  billing/subscriptions takes 15-20 s at times.
- The id read before still counts while the plan can't be read.
- A key whose plan was never read keeps its two windows alone.
- A pay-as-you-go key, with no windows, still gets no card.

planWindows' request and status handling move into planBody, so that
cmdKeyWindows can decode the reply itself; other vendors are unchanged.

Run:
- New TestCommandCodeKeyCardHasCredits uses the reporter's own
  billing/credits reply. Its billing/subscriptions reply has the shape
  the other Command Code tests use (individual-go-monthly), because the
  reporter's plan id isn't known.
- With the new branch disabled by hand, the test went red: two windows,
  no plan. With it, green.
- TestKeyQuotasKeepLast now answers billing/subscriptions with 503 and
  still sees its two windows.
- gofmt; go vet -tags nogui for darwin, linux and windows.
- Not tried against Command Code's real API: there is no plan key here.
- Full suite (go test -timeout 45m ./..., at f1c91a99c plus this change):
  every package ok except internal/gui, red only on
  TestPanelJoinsFullScreenSpaces, which is #2450 (macOS 26.2, red on
  main before this change).
2026-10-16 06:32:41 +08:00
yetone f1c91a99c0 gui: a redraw mid-move keeps the move running and its failure said
The redraw comes from renderProviders, for example when an account's
allowance read lands (loginUsageOf). It drew a subscription's "Move to
the plugin" field again from the provider alone. Midway through a move,
the button then said "Move to the plugin" again and took presses: a
second move could start while the first ran. A failure that came after
the redraw was said into the old field, which was gone, so the user saw
nothing.

renderMove now keeps the running move's label, and a failure's reason,
per provider in moveSaid. A redraw draws both again. A failure that lands
after a redraw redraws the providers, so the reason shows in the field
on screen.

Found while chasing #2431 (plugin-move's editor scrolls 23px in WebKit).
That shift was not reproduced: 16 loaded WebKit runs were green, and so
were injected late usage, late icons, a busy main thread and a forced
chain. The findings are on the issue. This doesn't close #2431.

plugin-move.test.cjs now redraws mid-move and after a failure.
- Broken by hand: without moveSaid it is red 4 of 4, both engines.
  The errors are "a redraw mid-move forgot the move" and "a redraw
  forgot why the move failed".
- With the fix: 8 of 8 green, 3 runs.

Review: a failure said is kept only while the move's state is the one it
failed from, so a move that lands another way (the hourly hand-over)
doesn't keep showing it. plugin-move*, fonts: 56/56 in both engines after.

Full suite: node --test --test-concurrency=4 internal/gui/tests/*.test.cjs
(chromium and webkit) on a61a6f954 with all three of these commits'
changes: 10655 tests, 10616 pass, 39 fail, all in 16 top-level tests.
Each of their files was then run alone:
- green alone on origin/main 008571462 and on this tree (load):
  import-link-gemini, market-have, plugin-page, readable-focus, text-size.
- red alone on main too, filed or commented:
  - quota-count-wrap and quota-name-translated: #2228
  - s3-sync: #2448
  - usage-agents-hide: #2276
  - usage-checkin: #2142
  - usage-fold: #2163
  - tray-usages: #2453, new
After rebasing onto 008571462, these were run again on this tree, alone:
- green: fonts, key-balance-card, plugin-move, i18n-keys.
- still red, the same as main: quota-name-translated, quota-count-wrap, tray-usages.
The full GUI run was not repeated after the rebase.
go test ./internal/gui on 008571462 plus these changes, sandbox HOME:
FAIL. The only failure is TestPanelJoinsFullScreenSpaces, which is #2450
and is red on main too. TestCoreScriptBudget passes.
2026-10-16 06:11:29 +08:00
yetone 96e9c0a080 gui: a usage card's reset line wraps its parts, never runs off the card (#2443)
At 560px, German's "Zurückgesetzt 19. Okt. 02:37 ·" was wider than the room
left beside the other parts of the reset line. The span is white-space:
nowrap, so it ran 10px past the card. key-balance-card's view-usage test
caught it only in weeks when the date fell on a long German month and
weekday, so it was red on main some days and not others.

Each part of .quota-reset (and .quota-holds) is now white-space: normal
and min-width: 0. A part goes whole onto its own line when it doesn't fit,
and only a part wider than the card breaks between its words.

The test now pins its weekly reset to the next 28 Sept 02:37 that is more
than eight days ahead. That is the widest German date, so the test no
longer depends on today's date.
- Broken by hand: with the old CSS, the pinned test is red in chromium de
  (10px past the card).
- With the fix: green in both engines, every language.

Full suite: node --test --test-concurrency=4 internal/gui/tests/*.test.cjs
(chromium and webkit) on a61a6f954 with all three of these commits'
changes: 10655 tests, 10616 pass, 39 fail, all in 16 top-level tests.
Each of their files was then run alone:
- green alone on origin/main 008571462 and on this tree (load):
  import-link-gemini, market-have, plugin-page, readable-focus, text-size.
- red alone on main too, filed or commented:
  - quota-count-wrap and quota-name-translated: #2228
  - s3-sync: #2448
  - usage-agents-hide: #2276
  - usage-checkin: #2142
  - usage-fold: #2163
  - tray-usages: #2453, new
After rebasing onto 008571462, these were run again on this tree, alone:
- green: fonts, key-balance-card, plugin-move, i18n-keys.
- still red, the same as main: quota-name-translated, quota-count-wrap, tray-usages.
The full GUI run was not repeated after the rebase.
go test ./internal/gui on 008571462 plus these changes, sandbox HOME:
FAIL. The only failure is TestPanelJoinsFullScreenSpaces, which is #2450
and is red on main too. TestCoreScriptBudget passes.
2026-10-16 06:11:29 +08:00
yetone ecb28abf2e gui: a menu redrawn under a still pointer leaves the typing in its search (#2439)
The font menu, session combo and row menus focus whichever item the
pointer moves onto. When the search narrowed the list under a pointer that
hadn't moved, the redrawn item under it got a mouseenter too, took the
focus out of the search, and the next letters went nowhere. fonts.test.cjs
went red whenever the list landed while the pointer sat over the menu.

hoverFocus now remembers where the last mousemove was. A mouseenter there
is a redraw's (UI Events fires mouseenter before its mousemove), so it
leaves the focus where it is. A real move still focuses the item.

The new fonts test hovers an item, then types "HarmonyOS" into the search.
The focus has to stay in the field, and Enter has to pick HarmonyOS Sans SC.
- Broken by hand: with the old `b.onmouseenter = () => b.focus()`, the test
  is red in chromium and webkit (the focus is on the item, and the typed
  text is cut short).
- With the fix: green in both engines, 3 runs.

Full suite: node --test --test-concurrency=4 internal/gui/tests/*.test.cjs
(chromium and webkit) on a61a6f954 with all three of these commits'
changes: 10655 tests, 10616 pass, 39 fail, all in 16 top-level tests.
Each of their files was then run alone:
- green alone on origin/main 008571462 and on this tree (load):
  import-link-gemini, market-have, plugin-page, readable-focus, text-size.
- red alone on main too, filed or commented:
  - quota-count-wrap and quota-name-translated: #2228
  - s3-sync: #2448
  - usage-agents-hide: #2276
  - usage-checkin: #2142
  - usage-fold: #2163
  - tray-usages: #2453, new
After rebasing onto 008571462, these were run again on this tree, alone:
- green: fonts, key-balance-card, plugin-move, i18n-keys.
- still red, the same as main: quota-name-translated, quota-count-wrap, tray-usages.
The full GUI run was not repeated after the rebase.
go test ./internal/gui on 008571462 plus these changes, sandbox HOME:
FAIL. The only failure is TestPanelJoinsFullScreenSpaces, which is #2450
and is red on main too. TestCoreScriptBudget passes.
2026-10-16 06:11:29 +08:00
yetone 97f264c7fb gateway: a 413 on the OpenAI routes says request_too_large, so pi compacts (@wilsonxuuuu on X)
@wilsonxuuuu's pi, on gpt-6.1 through magpie, stopped on
"magpie API error (413): {...,"type":"api_error"}" at 114k of a 1M
window and never auto-compacted. The vendor's 413 was a body byte cap.
pi's overflow table (pi-ai utils/overflow.ts) knows a byte cap only as
request_too_large, Anthropic's type, which magpie already gave on the
Anthropic route but not on chat/responses. writeErrorSaid now types
every 413 request_too_large (Gemini keeps its own status shape). The
status stays 413 and the byte-limit hint stays; it is not turned into
context_length_exceeded, so Codex and Claude Code read it as before
(Codex reads code, not type). pi compacts once and retries once
(_overflowRecoveryAttempted), so a body that is still too big after
compacting stops instead of looping.

Run:
- pi 1.1.0's own isContextOverflow on the reporter's body: api_error
  false, request_too_large true.
- TestPayloadTooLargeSaysRequestTooLargeToPi (an nginx 413 page from a
  chat upstream) and the new Chat/Responses rows of
  TestBodyRejectionErrorShapes fail with the gateway.go change reverted
  by hand, pass with it.
- go test -tags nogui -count=1 -timeout 45m ./... under a sandbox HOME:
  every package ok. gofmt clean; GOOS=linux and windows go vet of
  internal/gateway clean.
Not tried: a real pi session hitting a real vendor 413.
2026-10-16 06:09:50 +08:00
yetone 008571462b plugin: Settle starts no refresh while it settles (#2449)
Settle's own Restart tells the OnChange hooks, and one that calls
Cached() started refreshProvidersInBackground after Settle's last
refreshing.Wait. callWithTimeout starts the host under WithoutCancel, so
it went on once Settle returned and spawned a host in the test's removed
HOME ("Module not found host-....js", uv_cwd) or in the next test's,
while that one signed in. provSettling keeps Cached and the loop's
continue branch from starting one while Settle runs.

TestSettleStartsNoRefresh: red without the fix ("Settle started 3
refreshes"), green with it, also -race -count=20. In go test -v
./internal/cli the stray host lines went from 7 to 0.

Run: internal/cli, internal/plugin, internal/provider whole ok; gofmt -l
clean; go vet -tags nogui for darwin, linux, windows ok.
Full suite: go test -tags nogui -timeout 45m ./... at 7fefbc614 with both #2449 commits (bd4e9da7b's and this one's changes) (sandbox HOME, macOS): exit 0, 66 ok, 18 no test files, 0 FAIL.
2026-10-16 05:29:20 +08:00
yetone 6641e1b0ac provider: a plugin sign-in drops what a request holds at once (#2449)
TestPluginLoginInstallsItsCLIFirst went red on macOS CI (run
38798393584) with "not signed in after the install: []". cli's run()
sets catalog.Changed = agent.SyncCatalog, and a sync left going from an
earlier step holds the catalog (provider.Hold), plugins and their
sign-ins among it, for up to a second. The host's "auth" event dropped
that only through catalog.Touched, told in the background, so on a busy
runner provider.Logins right after the sign-in read the snapshot taken
before it.

plugin.OnChangeNow registers hooks run before changed() or listed()
returns, i.e. before the host's reply after the event is read; provider
registers dropHeld there. Changed() is filememo.Forget + dropHeld.

Reproduced by injecting a pause where SyncCatalog holds (patch kept
outside the tree): without the fix red 3/3 with the CI message; with it
ok -count=5. TestHeldGoesWithAPluginChange: red without the fix ("held
from before the change: built 1 times, want 2"), green with it, also
-race -count=20.

Run: -count=20 -run TestPluginLoginInstallsItsCLIFirst ./internal/cli
ok; internal/cli, internal/plugin, internal/provider whole ok; gofmt -l
clean; go vet -tags nogui for darwin, linux, windows on the three ok.
Full suite: go test -tags nogui -timeout 45m ./... at 7fefbc614 with both #2449 commits (this one and the Settle fix after it) (sandbox HOME, macOS): exit 0, 66 ok, 18 no test files, 0 FAIL.
2026-10-16 05:29:20 +08:00
yetone bbf901570e provider: a WorkBuddy account's spent credits leave its free models counted out, as the plugin does (plugins#138)
hheei (magpie-community/plugins#138): an account at 560 / 560 credits
was ranked spent for deepseek-v4.1-flash too, which WorkBuddy serves at
x0.00 and which draws no credits. The plugin was fixed in 0.1.23
(notModels) and the mover min is 0.1.24 already; the built-in, which
users who haven't moved still run, had the same fault. wbQuota's
personal Credits window and the enterprise window now pass through
wbSpareFree, which scopes them (QuotaWindow.matches) to the models not
marked Free in the provider's last fetched list (catalog.Live). With no
list read, every model counts, as before. The 14018 "Credits exhausted"
rest already rests only the paid model (PaidBesideFree).

Run:
- TestWorkBuddyCreditsSpareFreeModels (new): with no live list the free
  model reads 100%; with one, deepseek-v4.1-flash (either case) reads 0
  while -sg (x0.03) and gpt-5.5 read 100. Broken by hand (wbSpareFree
  returning early): red, "deepseek-v4.1-flash: 100% used, want 0".
- gofmt -l clean; go vet -tags nogui ./... for darwin, linux, windows: 0.
- Full suite: go test -timeout 45m ./... in a sandbox HOME, twice: every
  package ok except internal/gui's TestPanelJoinsFullScreenSpaces ("the
  panel shown doesn't take the keyboard"), which is red the same way
  alone on a fresh origin/main be1030ece worktree; filed as #2450.
2026-10-16 05:21:09 +08:00
yetone be1030ece3 agents: a row magpie can't connect says why, whole
"Only Cursor's own models" beside "Can't connect" read as two things.
Each of the four native-only rows now says it uses only its vendor's
models, so magpie can't connect it, in every language, and the line
wraps instead of being cut short.

Run at this head before the rebase onto 0f391a7a7: go test -tags nogui -count=1 -timeout 45m ./... under a sandbox HOME, every package ok; gofmt -l clean; go vet clean for darwin, linux (nogui) and windows; GUI files agent*, i18n*, gui-*, getting-started, library*, sess* and import-row in both engines: 1638/1638.
2026-10-16 05:10:43 +08:00
yetone 72ff0f5eea agents: Cursor CLI's row shows cursor-agent --version
Cursor CLI updates itself and isn't on npm or Homebrew, so magpie shows
its version only (@G_Z_Y on X saw none).

Run at this head before the rebase onto 0f391a7a7: go test -tags nogui -count=1 -timeout 45m ./... under a sandbox HOME, every package ok; gofmt -l clean; go vet clean for darwin, linux (nogui) and windows; GUI files agent*, i18n*, gui-*, getting-started, library*, sess* and import-row in both engines: 1638/1638.
2026-10-16 05:10:43 +08:00
yetone a80bc30092 agents: the Cursor editor's ~/.cursor is no Cursor CLI
The editor makes ~/.cursor on its own, so the folder alone says nothing
of cursor-agent (dirShared): cli-config.json or the command finds Cursor
CLI. The Library still writes the MCP servers and skills the editor reads
there when only the editor is here (SharedHere).

Run at this head before the rebase onto 0f391a7a7: go test -tags nogui -count=1 -timeout 45m ./... under a sandbox HOME, every package ok; gofmt -l clean; go vet clean for darwin, linux (nogui) and windows; GUI files agent*, i18n*, gui-*, getting-started, library*, sess* and import-row in both engines: 1638/1638.
2026-10-16 05:10:43 +08:00
yetone 486ea82378 agents: cursor-agent's row is Cursor CLI (@G_Z_Y on X)
@G_Z_Y looked for Cursor CLI on the Agents page and took the "Cursor" row
for the editor. The row is cursor-agent, so it is named Cursor CLI. What
it keeps in ~/.cursor is the Cursor editor's too (MCP servers, skills,
chats), so the Library and Sessions name it Cursor there (SharedName).

Run at this head before the rebase onto 0f391a7a7: go test -tags nogui -count=1 -timeout 45m ./... under a sandbox HOME, every package ok; gofmt -l clean; go vet clean for darwin, linux (nogui) and windows; GUI files agent*, i18n*, gui-*, getting-started, library*, sess* and import-row in both engines: 1638/1638.
2026-10-16 05:10:43 +08:00
yetone 7fefbc614e gateway: a relay's cap on one request's input fails over in a group (#2445)
B.ai answered a 380K request, under the model's 1M window, with 400
"Input token exceed the limit (request id: …)". No pattern in tooLongRe
matched it, and quotaWords wants "exceeded", so retryable() was false and
group/top's other three members were never asked (worksyang).

tooLongRe now also matches "input token(s) (count) exceed(s|ed) (the)
(max|maximum) limit". The refusal is taken as an overflow, so the chat
loop's existing #700 path asks the next member that may hold the request
(withRoom, failOverflow). Nobody rests, another account of the same model
isn't asked, and with no member left the agent is told it overflowed, to
compact. paceWords still keeps rate limits worded with input tokens out,
and a plain bad request still isn't asked of anyone else. System One's
decision groups (decide_group.go, which the report cites) are unchanged:
their requests are short decision text.

Test: TestRelayInputCapGoesToTheNextMember uses the reporter's message
verbatim. The JSON around it is not the reporter's; the issue shows only
the message. Docs: gateway-routing.md failure paragraph + verification.

Run:
- Broken by hand, the new test went red each time:
  - pattern removed: group answered 400, member 2 never asked;
  - paceWords check removed: two rate phrasings taken as overflow;
  - retryable true for every 400: the plain bad request reached member 2.
- TestRelayInputCap, TestEveryVendorsOverflow, TestOverflow*,
  TestContextOverflow*, TestOutOfBudget*: ok.
- gofmt -l: clean. go vet -tags nogui ./... on darwin, linux, windows: ok.

Full suite: go test -tags nogui -timeout 45m ./... at 0cad76cd9 + this
change, sandbox HOME: 66 packages ok, 0 FAIL (internal/gateway 1768s).
2026-10-16 04:58:32 +08:00
yetoneandggbdpq 7e4336e719 gateway: an event magpie appends to a cut stream begins after a blank line (#2446)
A passthrough stream cut mid-line got its error event written onto the
half-written line, so the client read "event: error" as more of that
line's data and never saw the error as an event. ggbdpq's patch (#2446)
tracks whether the last write ended a line (passthrough's write, and
holdWriter.atLine for cutLoop) and puts a blank line, two newlines when
mid-line, before the appended event.

The same join could happen to the other event passthrough appends: the
finish_reason filled in for a Gemini OpenAI-compatible reply that ended
done (a6f908ba5). It now goes through the same separator (apart). The
truncated pending event is still dispatched; SSE can't take it back, but
the error now arrives as an event of its own.

holdWriter's other appends (release, failTo) only follow keepalive
comment lines, so they already start on a line.

Tests: TestPassthroughStreamCutMidLine, TestPassthroughStreamEndsOnLineEnd,
TestLoopCutMidLine (ggbdpq), TestGeminiCompatFinishAfterPartialLine.
Broken by hand: apart returning "\n" always -> CutMidLine and
GeminiCompatFinishAfterPartialLine red; the Gemini fill-in without the
separator -> GeminiCompatFinishAfterPartialLine red; cutLoop's "\n\n" as
"\n" -> TestLoopCutMidLine red. Restored, all green.

gofmt -l clean; GOOS=darwin/linux/windows go vet -tags nogui ./... clean.
Full suite: go test -tags nogui -timeout 45m ./... at base 0cad76cd9, 66 packages ok, 0 FAIL (gateway 1869s, provider 445s; sandbox HOME)

Co-authored-by: ggbdpq <67929842+ggbdpq@users.noreply.github.com>
2026-10-16 04:56:34 +08:00
yetone 0f391a7a71 gui: a panel row's name keeps its width beside a long model summary (#2447)
EdwinDigital: in the tray panel, WorkBuddy's row said its models in words
("gpt-6.1-sol · Microsoft Foundry, claude-opus-5-5 · Microsoft Foundry +1"),
and the words took the row: the name was squeezed to 10px at 550px and to
nothing at 440px and below, or at any width once the pointer came onto the
row and the model's logo eased in. The row's columns were 20px, a name in
minmax(0, 1fr) and the words in auto, so the words claimed their whole
width and the name gave way.

Now the name's column is fit-content(60%): it keeps its own width, up to
60% of the row, and the words take what is left and cut first (.vt already
ellipsizes). The words sit at the row's end (justify-self: end), so their
effort bars and chevrons stay in one column down the list. It holds for
every panel row with a summary (a model list, one model's label, import,
launch, CLI not found), not WorkBuddy alone.

Name width, WorkBuddy / Claude Desktop, before -> after, chromium and webkit
the same: 550px 10.05 / 8.09 -> 76.05 / 103.92; 440px and 360px 0 / 0 ->
76.05 / 103.92; hovered the same after.

Run at 0cad76cd9:
- agent-panel-name-width.test.cjs (new): chromium and webkit; en, zh,
  zh-TW, ja and de; 550, 440 and 360px; hovered and not. Each name is
  whole, the words are after it and inside the row, right edges line up,
  the model lists are cut, and nothing scrolls sideways. 32/32 pass. With
  HEAD's app.css it fails 32/32 (name 10.05px at 550, 0 below).
- GUI, every file that renders the panel or an agent row (101 files,
  4-wide): # tests 1390, pass 1387, fail 3. The 3 reds also fail at HEAD
  without this change, run alone: key-balance-card chromium de
  (view-usage 570>560, #2443) and usage-fold chromium en/zh (the view
  didn't scroll, 184 !== 180, #2163).
- The whole GUI suite (780 files) was not run.
- gofmt -l clean; GOOS=darwin/linux/windows go vet -tags nogui ./... ok;
  go test -tags nogui -timeout 45m ./internal/gui/... ok (385.6s).
2026-10-16 04:54:34 +08:00
yetone 0cad76cd99 gui: the provider editor folds rarely used fields under Advanced
The owner: "Provider表单太复杂了…有一些可以折叠在高级里面". Headers,
proxy, concurrency and RPM limits, prices, context and output windows,
native compaction and fallback now sit in an "Advanced" fold beside the
key and models. It opens on its own when any of them is set, keeps the
state it was left in across the editor's redraws (keyed by the provider
being edited), and a Save refused on a field inside it opens it and
focuses that field. A signed-in account's editor folds the same.
Strings in zh, zh-TW, ja and de.

Motion ("整个弹窗高度的改变也应该是丝滑的动画"): the fold grows and
shrinks on one spring-like curve, its rows fading in, its arrow turning,
and the dialog's height follows on the same curve both ways; clicked
again mid-way it turns back from where it is. Reduce motion: at once.

Every dialog holds its place: the element last pressed or focused stays
where it was while the dialog grows or shrinks (a relative top plus a
max-height cap), so the button under the pointer doesn't run away. Where
there is no room above, only a pressed button below the fields shortens
them through the cap; nothing a click does scrolls the fields
(models-fold, names-fold). An element mid-scale (a Copy button's pop) is
measured by its parent (key-copy). The names list holds its height while
drawNames rebuilds it, so WebKit doesn't clamp the editor's scroll mid
rebuild (provider-detect, "Ask on one API moved" 64→190).

Tests: provider-advanced-fold (new, 5 languages × 2 engines, 420px);
about 21 editor tests open Advanced before reaching a folded field;
balance-method and plugin-move find the fold by its class; detect-draft
allows 0.5px. appScriptBudget 1,250,000 and coreScriptBudget 1,426,000
(1,232,466 and 1,405,937 with this).

Run: go test ./internal/gui/ ok. Every GUI file (771) in a full run,
4 at a time; its reds, rerun alone at this head, both engines:
key-copy 8/0, models-fold 4/0, names-fold 8/0, balance-method 42/0,
provider-detect 4/0, plus provider-remove 16/0, plugin-move 8/0,
provider-detect-draft 20/0, provider-advanced-fold 50/0,
provider-add-models 4/0. Red on origin/main as well, filed: #2435
(agent-connect-no-models, fixed in cf21b71ff), #2439 (fonts), #2443
(key-balance-card), #2228 (quota-count-wrap, quota-name-translated),
#1905 (routing-wb-restricted), #2448 (s3-sync); mobile-web and
library-workbuddy-trust red only under load, noted on #1544;
readable-focus and text-size fixed on main in 1a16fc0b5 and d3ca90afc.
2026-10-16 04:08:02 +08:00
yetone fbabe861e2 lessons: three GUI changes left other GUI files red on main, and a Windows rule left two Mac tests red on Windows CI
Added under 10-15's criteria still missed: 64b0f3a20 (menu-scroll, fixed
a61a6f954), 8f55c27ad (text-size, fixed d3ca90afc) and 94942f9f3
(agent-connect-no-models, cf21b71ff, #2435) each ran the GUI files they
chose; 6e2aa8e32's Windows rule and the dsh tests fixed in ce1251cc9.

Docs only; no code or test changed, nothing run.
2026-10-16 03:59:56 +08:00
yetone d3ca90afcc gui tests: text-size scrolls its control to below the Settings tabs held at the top
8f55c27ad (#2396) holds Settings' tabs at the view's top. "100% picked at
the foot of the page" scrolled until the 100% button was within 60px of
the view's top, which is now under that head, and the click timed out on
"<div class="row-head set-head stuck"> intercepts pointer events" in both
engines (20/2 on origin/main 1a16fc0b5). It stops 60px under the head's
foot now, as a reader could still click it.

Run: text-size 22/0 (chromium, webkit) at 1a16fc0b5 + this change.
2026-10-16 03:55:46 +08:00
yetone 056cfe3323 provider: Codex's keychain read waits for the user, tells a refusal from no answer, and is kept while the item is unchanged (#2367)
Dony2050 (#2367) runs Codex with cli_auth_credentials_store = "auto" and no
auth.json, so magpie reads "Codex Auth" through /usr/bin/security. Four
faults:
- One 10s timeout covered both of macOS's prompts and the user typing their
  password. A read they approved after 11-16s still failed.
- A timeout and a refusal gave the same error.
- A read was kept for 10s only. With "Allow" (once), background polls
  prompted again about every 30s.
- Only a restart cleared the 10-minute failure cache.

What changed:
- Reading the secret is one ask per item at a time (askCodexKeychain). It
  runs in its own goroutine for up to 2 minutes (keychainAsk), outside
  codexKeychainMu, so no `security` run happens under a lock a reader needs.
  A reader waits at most 5s from when the ask started (keychainHold), then
  gets errKeychainWaiting. A request or a page never waits out the prompt.
  The ask's answer is kept when it lands, unless magpie kept a newer one
  after it started.
- Each failure says what happened:
  - exit 44: no item.
  - exit 51 (errSecAuthFailed) or 128 (errSecUserCanceled): denied or
    cancelled (errKeychainRefused). Checked against SecBase.h. Exit 44 was
    also checked on a throwaway keychain in the scratchpad.
  - the 2 minutes ran out: no answer (errKeychainNoAnswer).
  - anything else: errKeychainUnread.
  None of them counts as signed out.
- A successful read is kept while the item is unchanged. After 10s a reader
  runs Stat (find-generic-password without -w), which shows no prompt and
  returns only the item's mdat. The secret is read again only when the mdat
  changed.
  - Every write of the credential re-derives the cache:
    - codexStore.write keeps the date of what it wrote (keepCodexKeychain).
    - Switch, sign-out (deleteCodexLogin) and refresh forget a read
      (forgetCodexKeychain), so the next read checks the date.
  - forget keeps a refusal for its 10 minutes (#2408).
  - resetCodexKeychain clears everything. Only tests use it.
- The saved accounts' line in the GUI has a "Try again" link beside Remove
  when a read was refused, got no answer or is waiting (Exclusion.Retry).
  It posts /api/provider/keychain-retry, and RetryCodexKeychain reads once
  past the refusal.
  - The reason now says "Always Allow" lets /usr/bin/security read the item,
    so macOS stops asking each time Codex changes it.
  - Two new strings in zh, zh-TW, ja and de.
- docs/subsystems/providers-accounts.md: the "Codex's credential store" row
  describes the above.

Tests:
- TestCodexKeychainAskedSeldom (rewritten) covers:
  - an unchanged item over aged and forgotten rounds asks once;
  - a changed item asks again;
  - a gone item is not found without asking;
  - a refusal is kept through forget.
- TestCodexKeychainPromptWaitedFor: a held prompt gives "waiting" to the
  first and to 8 concurrent readers without blocking. Once answered, the
  read succeeds with one ask.
- TestCodexKeychainRetry: Retry and Why for refused, no answer and no item,
  and RetryCodexKeychain.
- TestSecurityKeychainExits (codex_keychain_ask_unix_test.go): a fake
  `security` built with testenv.Program covers:
  - a 2s answer with keychainWait = 1s succeeds;
  - Stat parses the mdat;
  - exits 44, 51, 128 and 1 map as above;
  - a hang gives no answer.
- signedout_test: Retry is set only for an unread item.
- GUI keychain-retry.test.cjs runs in chromium and webkit, in en and zh:
  - order Try again, Remove;
  - the POST body;
  - the line leaves after a click;
  - no link without retry.

Broken by hand (each restored after):
- Find bounded by keychainWait again: TestSecurityKeychainExits red ("a read
  the user answered late ... no answer in time").
- exit 51 not classed as refused: TestSecurityKeychainExits red ("Find,
  denied").
- Readers wait on the ask (no hold): TestCodexKeychainPromptWaitedFor hangs;
  the package timed out.
- forget clears every read: TestCodexKeychainAskedSeldom red (4 asks).
- mdat match ignored: AskedSeldom red (7 asks).
- Cache never re-checked: AskedSeldom red (the changed item wasn't seen).
- RetryCodexKeychain also deleting the failure cache: still green, because
  a fresh read asks past a refusal. That loop was removed as redundant.

Not tried:
- A real macOS prompt, or an item Codex itself wrote. Every test uses a fake
  `security`; the real keychain and ~/.codex were not touched.
- Put and Remove are still bounded at 10s.

Run at this head, rebased on origin/main 1a16fc0b5:
- gofmt -l: clean.
- go vet -tags nogui ./...: ok for GOOS darwin, linux and windows.
- go test -race -count=2 on the keychain, signed-out and Codex sign-in tests
  in internal/provider: ok.
- GUI (node --test, NODE_PATH playwright 1.62.0): keychain-retry, i18n-keys,
  saved-signedout-remove, gui-de, gui-ja, gui-zh-tw: 24/24 pass.

Then rebased on origin/main 167df7055 (TestSecurityKeychainAnswers' fake is
a testenv.Program; no overlap in hunks): go vet -tags nogui for darwin, linux
and windows on provider and gui, and go test -race ./internal/provider: ok.

Full suite: go test -timeout 45m ./... in a sandbox HOME, set -o pipefail, at
this tree on origin/main 1a16fc0b5: exit 0, 66 packages ok, no FAIL (gateway
1588s, agent 1497s, provider 510s).

Rebased onto origin/main a6f908ba5 (#2440, #2437 Gemini finish_reason; no overlap): go test -tags nogui ./internal/provider ./internal/gui ok.
2026-10-16 03:46:15 +08:00
yetone a6f908ba58 gateway: a Gemini OpenAI-compatible stream that lost its finish_reason is ended by usage, or cut
Linka (Discord #feedback): Gemini's OpenAI-compatible API sends a whole
function call (its thought signature, the usage) in one chunk and the
finish_reason in the next. When the upstream hung up between the two,
magpie relayed a stream that ended with neither, and Pi threw the
complete call away ("Stream ended without finish_reason") and asked the
whole 160k turn again. On a Chat upstream only a failed read was a cut,
so a clean EOF there went on as a stream with no end.

That API counts the usage only on the generation's last chunk(s): the
Vertex fixture (testdata/vertex_openai_thoughts.sse) has it only beside
finish_reason, Linka's frames have it on the call chunk and the finish
chunk, and Google's forum and third-party docs say the same; no Google
doc states it. So for a Chat upstream that is Gemini's (geminiCompat,
saysItsEnd) and ended without a finish_reason:
- its last chunk carried usage: the generation was done and only the
  finish_reason was lost. It is filled in (chatTail), "tool_calls" after
  a call and "stop" otherwise: relayed, as one chunk before [DONE]
  (written only if [DONE] hadn't gone); translated, as the reply's normal
  end (tool_use for Claude Code), streamed and unstreamed. Recorded ok.
- no usage at its end: the reply was cut, and the client gets "the reply
  ended before it was complete" (errEndedShort), as a Gemini stream's
  finishReason is told (#1643, #1644): the relay's error chunk, the
  translated stream's error, an unstreamed 502.
A failed read keeps its own "connection lost mid-reply". Other vendors'
Chat streams are unchanged.

Tests (gemini_compat_cut_test.go, Linka's frames): relayed, the call
with usage ends with finish_reason tool_calls then [DONE], text with
usage with stop, the call without usage with the error and no
finish_reason; a whole reply with or without [DONE] goes as it came
with one finish_reason; kimi-k3 with and without usage unchanged.
Translated: with usage one message_stop with stop_reason tool_use and
no error, streamed, and a 200 tool_use unstreamed; without usage one
error and no message_stop, and a 502 unstreamed.
Broken by hand, each red: the relay fill off (relay test: no
finish_reason), the streamed fill off (0 stops, 1 error), the
unstreamed fill off (502), usage ignored in chatTail.finish (every
no-usage case ended as whole, unstreamed 200).

Run: gofmt -l clean; GOOS=darwin/linux/windows go vet -tags nogui ./...
ok; go test -run 'TestGeminiCompat|EndedShort|TestStreamCut|
TestWellFormed|Sniff' ./internal/gateway ok.
Docs: gateway-routing.md says when the finish_reason is filled in.
Full suite: go test -tags nogui -timeout 45m ./... at base a61a6f954 + this, EXIT 1: 65 packages ok, internal/gateway red only in TestVisionWaitIsntTheDescribersTime (300ms describer limit under load, unrelated; passes -count=5 alone; filed #2444). Rebased onto 1a16fc0b5, internal/gateway whole: ok.
2026-10-16 03:41:49 +08:00
yetone db8b791797 plugin: tools-, page- and agent- packages take their short name without the prefix
@magpie-community/tools-calc served its tools as tools-calc_eval and its
page under "tools-calc" because ShortName only dropped middleware- and
opencode-. It now drops tools-, page- and agent- too, so the calc example
serves calc_eval/calc_convert/calc_date as its README and the docs say.
`magpie plugin options` / SetOptions find a plugin by its short name or by
its bare package name (plugin.Called), so "agent-aider" keeps working
beside "aider".

Run at 1a16fc0b5:
- go test ./internal/plugin ./internal/cli ./internal/middleware, and
  gateway -run 'Tool|MCP', gui -run Page: ok.
- Broken by hand: ShortName without the new prefixes -> the new
  TestShortName cases red; Called without bareName -> the
  SetOptions("agent-aider") case red. Both green after restoring.
- Sandbox HOME: magpie plugin add @magpie-community/tools-calc listed
  tools calc_convert, calc_date, calc_eval.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: 0.
- go test -timeout 45m ./... : ok (load ~130).
2026-10-16 03:41:22 +08:00
yetone 167df70550 provider tests: TestSecurityKeychainAnswers's fake security is a program macOS has let run
The full suite at a61a6f954 (+ #2440's helper fix, which doesn't touch
internal/provider) went red in TestSecurityKeychainAnswers after 10.03s:
"exit 44: the keychain didn't give it to magpie (refused, or no answer)".
10s is keychainWait. The test wrote its fake `security` with os.WriteFile,
and on macOS a newly written program's first exec waits for the system's
check, several seconds while a go test ./... starts its binaries, which
ate the whole wait. It now writes it through testenv.Program, as the
other timed fakes do, from the pool of files macOS has let run.

Run:
- go test ./internal/provider -run '^TestSecurityKeychainAnswers$'
  -count=5: ok; go test -timeout 45m ./internal/provider
  ./internal/claudebridge: ok.
- gofmt -l clean; go vet -tags nogui darwin, linux, windows on
  internal/provider.
- Not reproduced on purpose: the red needs the system's first-run check
  to be slow, which only the full run's load gave.
- Full suite: go test -timeout 45m ./... at 1a16fc0b5 + these two commits, EXIT 1: 65 packages ok; internal/gui red only in TestSetAnswersWhileDevinAndProvidersHang (set slow/slow-1 took 12.4s, three suites running at once; untouched by this change), output added to #1375.
2026-10-16 03:27:22 +08:00
yetone 641f00e4c5 claudebridge: the MCP helper calls magpie back past the agent's proxy (#2440)
ump45nose's TestClaudeToolCallbackOnANonLoopbackAddress was red on their
macOS with "curl: (56) Recv failure: Connection reset by peer". The run
hands Claude Code the proxy magpie gives it for Anthropic (by default the
system's: netproxy.EnvWith), with NO_PROXY of localhost, 127.0.0.1, ::1
and the system's exceptions. A gateway on a LAN or Tailscale address
(MAGPIE_ADDR, #1546) isn't in it, so the helper Claude Code starts, which
inherits that environment, sent its tool callback to the proxy. A proxy
that resets it or can't reach back left the call short of the run, and the
turn with the tool's results found no run waiting. The same path is real,
not only the test's: Go's http client takes *_PROXY for every host but
loopback, and the helper serves Claude, Cursor and Grok runs alike.

The helper's callback is always magpie on this computer, so its client
now uses no proxy at all. The test stand-ins of the helper (the takeback
and fork scripts' curl) call back with --noproxy '*' as it does.

Run:
- Reproduced the report: settings.Proxy on a local listener that resets
  every connection, TestClaudeToolCallbackOnANonLoopbackAddress red with
  the reporter's exact curl (56) reset; green after (temporary edit, not
  kept).
- New TestCallbackGoesPastTheAgentsProxy runs the helper as its own
  process with every *_PROXY on a resetting proxy, calling back to this
  computer's non-loopback address. Red on the old helper ("read: connection
  reset by peer"), green now.
- gofmt -l clean; go vet -tags nogui for darwin, linux and windows on
  internal/claudebridge and internal/gateway.
- Full suite: go test -timeout 45m ./... at a61a6f954 + this change: 65
  ok, internal/provider red in TestSecurityKeychainAnswers only (10.03s,
  the 10s keychainWait on a fake `security` written with os.WriteFile;
  fixed at its cause in the next commit). internal/claudebridge and
  internal/gateway ok.
2026-10-16 02:51:37 +08:00
yetone 1a16fc0b5b gui: Settings' scroll hairline holds its head instead of finding it on each scroll
8f55c27ad (#2396) looked up `:scope > .set-head` on every scroll of
#view-settings. When the view's children are not the ones index.html
drew, the lookup is null and every scroll throws; readable-focus, which
replaces the view's children to test keyboard focus, went red on main
(a61a6f954) in both engines with "Cannot read properties of null
(reading 'classList')" / WebKit "null is not an object (evaluating
'sv.querySelector(":scope > .set-head").classList')". The head is now
found once, when the tabs are set up, and the handler toggles that.

Run at 55d6ea4ff + this change: readable-focus 8/0 (chromium, webkit),
settings-*.test.cjs 108/0.
2026-10-16 02:47:57 +08:00
yetone 55d6ea4ffc gateway: a translated model's messages say their phase, so Codex folds them (#2437)
Codex Desktop folds a finished turn's commentary and calls under "Worked
for …" by each assistant message's `phase`, which OpenAI's own models
write ("commentary" / "final_answer"). A message with none is read as an
answer, so every progress line of a model magpie translates (the
reporter's Qoder plugin, a chat upstream) stayed unfolded.

The Responses encoder now holds a message's output_item.done until the
next item that isn't reasoning opens (commentary) or the reply completes
(final_answer); the completed output carries the same phases.
renderResponses does the same for a whole reply. A Responses upstream
relayed as it is (passthrough) gets the same rule through a new phase
tidy, streamed or whole. A phase the upstream wrote is kept; a reply cut
short (incomplete, failed, error, a stream with no end) guesses no final
answer, since Codex reads a missing phase as the answer. Keepalives go
out at once; sequence numbers are given in write order. At most 512
events wait behind a message, then it goes without a phase. Codex's
base_instructions are not touched.

Run (worktree at origin/main cf21b71ff):
- new tests in internal/gateway/phase_test.go: encoder (call, reasoning
  then call, last, reasoning after, length cut, two messages around a
  call, keepalive while held), renderResponses, phase tidy (SSE fed a
  byte at a time, CRLF, upstream phase kept, incomplete, no end, whole
  reply with a 20-digit number kept) and a passthrough through the gateway
- broken by hand, each went red: encoder release ignoring the phase (3
  tests), renderResponses without phaseOutput (1), passthrough without
  the tidy (1), unphased ignoring an upstream phase (1 subtest)
- gofmt -l clean; go vet -tags nogui for darwin, linux, windows ok
- full suite: set -o pipefail; HOME=<scratch>/home-2437 GOMODCACHE=~/go/pkg/mod go test -tags nogui -count=1 -timeout 45m ./... at cf21b71ff plus this change: exit 0, 66 packages ok, none FAIL (gateway 844s, provider 355s)

- rebased onto origin/main a61a6f954 and run again: gofmt -l clean; go vet -tags nogui darwin, linux, windows ok; set -o pipefail; go test -timeout 45m ./... in a scratch HOME: exit 0, 66 packages ok

Full suite: green at a61a6f954 plus this change, 66 packages ok, exit 0.
2026-10-16 02:43:02 +08:00
yetone a61a6f9546 gui tests: menu-scroll's fixture answers /api/plugin-pages
menu-scroll has been failing 24 of 24 on main since 64b0f3a20 (10-15). That commit has the sidebar ask /api/plugin-pages for community plugins' pages. menu-scroll's route handler asserts on any API it doesn't serve, so it threw "Unexpected API: /api/plugin-pages" and closed the browser under every case. The fixture now answers with an empty list, meaning no plugin pages.

This changes the test only, not the app.

Run on b6533893a: menu-scroll failed 24 of 24 before the change. After it, the test passed 24 of 24, twice in a row, in chromium and webkit.
2026-10-16 02:01:29 +08:00
yetone a0a4d55ef7 gateway: a passed-through reply whose reasoning loops before it says anything is asked again once, and its tries counted (#2436)
lqisgod's five looped replies (pi → WorkBuddy, Chat in and out) each
ended at once with empty tries and status 200. The once-only re-ask of a
reasoning loop (loopReasks) lived only in streamTranslated's onLoop, so a
same-protocol passthrough had holdWriter.reask nil and cutLoop ran on the
first trip. A re-ask that did happen in place wasn't counted in the usage
record's tries either (tries came from route.Tries alone).

Now holdWriter lets such a try go (mayReloop/letGoLoop) when its
reasoning looped, nothing has spoken (loopGuard.spoke: no text or call),
the request has its re-ask left and its context is alive, and either
nothing of the try reached the agent (held bytes dropped, any protocol)
or the agent speaks Chat (bytes written up to the end of the tripping
event, the next try's chunks follow). The fallback loop records the try
as failLoop with reloopedError and asks the same provider again after
retryPause. In-place re-asks add to tries too. An Anthropic or Responses
stream whose reasoning already reached the agent still ends with the
loop error: a second message_start/response.created can't follow. The
plugin host's fetch goes through the same holdWriter
(TestLoopEndsWorkBuddysReply's plugin subtests).

Tests: loop_guard_test.go's chat case now expects 2 asks and an answer;
every passed-through `data:` line is valid JSON; the usage record has
Tries == asks and no error. docs/subsystems/gateway-routing.md updated.

Broken by hand, each red:
- hw.reloop = false (old behaviour): TestLoopEndsTheReplyOnEveryProtocol,
  TestLoopEndsWorkBuddysReply, TestReasoningLoopIsAskedAgain fail.
- reasked not added to tries: the same three fail with "usage record's
  tries 0, the vendor asked 2 times".
- spoke never set: TestLoopAfterTextIsNotAskedAgain fails.

Run: gofmt -l clean; go vet -tags nogui ./internal/gateway ./internal/usage
with GOOS=darwin, linux, windows ok; go test -run Loop ./internal/gateway ok.
Not tried: a real WorkBuddy account looping (the loop can't be forced).

Full suite: go test -tags nogui -count=1 -timeout 45m ./... on base
b03031738, every package ok, no FAIL line.
2026-10-16 01:55:47 +08:00
yetone 6f92815335 routing: each try says where its time went: magpie, the network, the vendor (Discord, Magic_zero)
A user read a slow turn as the gateway being slow. The try loop's
httptrace now also records DNS, connect, TLS, GotConn (reused or not)
and the first response byte. Each Try keeps a TryNet ("net"): magpie's
own time, requests made before it, the wait for a pooled connection,
DNS, connect, TLS, sending, the vendor's wait for its first byte, and
Head (from the try's start to that byte). A Route also carries the usage
record's Sent/Own/Retried/Queued split. Usage records are unchanged.

The Routing page's story shows "Where the time went" under each finished
try. It is one stacked bar plus named values, in three groups (magpie,
network, vendor): Waiting for a slot (tr.queued, which was never shown
before), In magpie, DNS, Connecting, TLS, Sending, Vendor (first byte),
First token, Streaming. Parts that took no time are left out. The
strings are in every language. "Waiting for a slot" moves from the
Usage plugin's i18n into i18n.js, since Routing uses it too.

Not covered: plugin providers (and any other request sent by something
other than Go's client). Their request goes out through the Bun host's
fetch, so no httptrace fires. Such a try has no net and shows no
breakdown, only the time it took, as before (and so does a trace from
before this change).

Run (worktree at origin/main b03031738):
- gofmt -l: clean. go vet -tags nogui ./... for GOOS darwin, linux and
  windows: ok.
- TestTryTellsWhereItsTimeWent uses a TLS fake whose headers are held
  300 ms. Wait must land in [hold-1, hold+5000]. On a new connection
  TLS is > 0. The steps sum to no more than Head, and Head is no more
  than TTFT. A reused connection has no DNS, connect or TLS.
  -race -count=3: ok.
- Broken by hand: with the old two-hook trace back in gateway.go, the
  test fails ("no timing").
- routing-time-went.test.cjs: chromium and webkit × en, zh, zh-TW, ja,
  de at 440px: 10/10. It checks that the bar is to scale, that nothing
  spills out of the story, that there is no left border, and that the
  plugin try shows no breakdown. i18n-keys: ok. Rerun on the committed
  tree: 13/13 with i18n-keys.
- routing-*, usage-ledger*, lane-limit at --test-concurrency=4:
  4 reds, all webkit click timeouts in routing-busy ("trace updates
  keep the rows…", en and zh) and routing-idle-frame ("hiding a running
  replay…", 2). Both files run alone: 13/13, twice. Recorded on #2211 (the same files go red under load on main cf21b71ff).
- Real use: magpie serve --web on 3571/3572 in a sandbox HOME, against
  a fake vendor (900 ms before its headers, 300 ms to its first token,
  then 1 s of chunks). New connection: In magpie 1.3 ms, DNS 0.3,
  Connecting 0.4, Sending 0.1, Vendor (first byte) 912 ms, First token
  294 ms, Streaming 1.0 s. A reused connection had no DNS or connect.
  Both were seen in the page, in headless Chromium.
- Not tried: a real vendor over TLS through the app; the Linux
  WebKitGTK app; Windows.

Full suite: go test -tags nogui -count=1 -timeout 45m ./... ok
(66 packages; gateway 811s, agent 728s, provider 359s).
2026-10-16 01:55:47 +08:00
yetone b6533893a7 plugins: Discover lists tools and page plugins, and the intro links to the plugin docs
Every kind of plugin magpie runs now has its place on the Plugins page, so
someone looking to extend magpie finds what exists and how to write one:

- Discover has "Tools for agents" (market kind "tools") and "Pages" (kind
  "page") sections beside Subscriptions, Gateway middleware and Agents,
  each card with its own chip (a new Tools chip, the Page chip). Before,
  both kinds fell under Subscriptions as Providers.
- A GitHub repository tagged magpie-plugin whose package.json has
  magpie.page.file is a Page, and that file must be committed, as a
  provider's entry must (TaggedRepos).
- An installed plugin that only gives tools wears the Tools chip.
- The intro says what a plugin can be (provider, gateway middleware,
  routing strategy, tools, an agent, a page) and its "Write a plugin" link
  opens usemagpie.ai/docs/plugins in the window's language (zh and zh-TW
  to zh/, ja to ja/), outside the window.
- The docs' Publishing section lists the "tools", "page" and "agent"
  registry kinds and the community package names for each, in en, zh, ja.

Run at the reviewed head (on origin/main cf21b71ff):
- go test ./internal/plugin: ok. Broken by hand: without the page case,
  and with the page's entry not checked, TestTaggedRepos goes red.
- plugin-kinds-discover.test.cjs (new): 5 languages x 980/420 x chromium
  and webkit, green. Broken by hand, each red: the old plugins.js (11/11
  fail), no "tools" kind (11/11), no ja/zh-TW docs link (3), no Tools chip
  on an installed row (11/11).
- plugin-middleware.test.cjs's intro test now checks the new copy and link;
  it still checks the click scrolls nothing.
- Every plugin*.test.cjs and i18n*.test.cjs, both engines: 505 pass, 0 fail.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: 0.
- go test -timeout 45m ./...: all 66 packages ok (full=0).
2026-10-16 01:48:45 +08:00
yetone cf21b71ff3 gui tests: agent-connect-no-models takes all_hidden's new words and gives its list to open (#2435)
94942f9f3 made a refused connect with every model hidden say "pick one,
then connect {agent}" and open the agent's model list right there. This
test still waited for the old "Model list → Pick" words, and its fake API
answered the list with {}, so the page threw "undefined is not an object
(evaluating 'm of models')" in WebKit. Both are the test's: the real
/api/agent-models always carries models. It now waits for the new words
in en/zh/ja/de and answers the list with one hidden model;
agent-connect-all-hidden.test.cjs covers picking from it.

Run: agent-connect-no-models.test.cjs, 16 of 16 (chromium and webkit,
en/zh/ja/de, no_models and all_hidden); 8 of 16 red before.
Full suite: go test -tags nogui -count=1 -timeout 45m ./... ok, every
package, at a7e1e8ed8 (this batch's head before this test-only commit),
which covers ggbdpq's 319b86fe7..a69b9b524 and 43fef0697, 39bebbbdf and
a7e1e8ed8; gofmt clean, go vet -tags nogui darwin/linux/windows clean.
2026-10-16 01:05:54 +08:00
yetone a7e1e8ed83 agent: Air starts the OpenCode an IDE installed from the ACP registry (#2423)
whiteS18 installed OpenCode from IDEA's ACP registry. The IDE unpacks it
into ~/Library/Caches/JetBrains/IntelliJIdea2026.2/acp-agents/opencode/
1.19.0/opencode, on no PATH, so Air's Magpie agent said "OpenCode not
installed". airOpenCode now also looks where JetBrains IDEs and Zed put
registry installs (Caches/JetBrains/*/acp-agents/opencode/*, Zed's
external_agents/registry/opencode/*; ~/.cache and ~/.local/share on
Linux, %LOCALAPPDATA% on Windows), the newest by mtime.

Run:
- TestAirFindsACPRegistryOpenCode: darwin, linux and windows layouts
  (the reporter's literal macOS paths), none installed gives "", the
  newer of two wins.
- XDG_CACHE_HOME listed in agentenv_test's notAnAgent (TestFolderVarsAreListed
  was red without it).
- go test -tags nogui -count=1 ./internal/agent ok; gofmt clean;
  go vet -tags nogui darwin, linux, windows ok on agent.
- Not tried: a real IDE registry install (none on this machine).
Full suite: agent only here; the release head runs ./... before its tag.
2026-10-16 00:46:28 +08:00
yetone 39bebbbdf3 gateway: Claude Desktop's Code tab and a build with no version keep the mythos alias (#2426)
67293346e gave Desktop the plain anthropic/magpie-<n> alias whenever its
User-Agent had no " Claude/<ver>". The Code tab's Claude Code calls with
"claude-cli/2.1.x (external, claude-desktop)" and current builds, so its
reasoning-level models lost their effort picker. desktopKnowsMythos is
now false only for a build whose version it reads and that is older
than 2; no version reads as a current build.

Run:
- On 67293346e's desktop.go the Code-tab UA listed
  anthropic/magpie-5487751739; with this it lists mythos-magpie-<n>.
- desktop_models_test: the old build gets the plain alias; the 2.7032
  UA, the claude-cli UA and "" get mythos-magpie-<n>.
- go test -count=1 -timeout 45m ./internal/gateway ./internal/provider ok.
- gofmt clean; go vet -tags nogui darwin, linux, windows ok on gateway.
Full suite: gateway and provider only here; the release head runs ./... before its tag.
2026-10-16 00:46:27 +08:00
yetone 43fef06978 gateway: a rule's group keeps its own order only for models it plans itself, not ones shared with a group ahead (#2407, #2361)
66e9c014d ranked a rule's named group as one block in the order the
group's own routing planned. A model the group shares with a group
ahead of it is planned in that earlier group's order, so the block
kept First's order and TestRuleNamesAGroupSharingModelsWithOneAhead
went red (alpha answered instead of beta). Member.In hands back the
shared place with ID == the named group, so the check is now on the
model's first place: homeAt keeps the At of the members whose own ID
is the named group, and only those rank as the block.

Run:
- With the block check forced off, TestRuleNamingARotateGroupKeepsItsTurns
  is red; with it, it and TestRuleNamesAGroupSharingModelsWithOneAhead
  are green.
- go test -run 'Desktop|Rule|Rotate|Nested|Shar' ./internal/gateway ok.
- go test -count=1 -timeout 45m ./internal/gateway ./internal/provider ok.
- gofmt clean; go vet -tags nogui darwin, linux, windows ok on gateway.
Full suite: gateway and provider only here; the release head runs ./... before its tag.
2026-10-16 00:46:27 +08:00
ggbdpq a69b9b524a gateway: list Claude Desktop a reasoning-level model by its plain alias when its build has no mythos word
What changed
- Claude Desktop builds older than the mythos word (the Store's 1.6608.2,
  #2426) keep a gateway model only when its id reads as a sonnet|opus|haiku
  tier or has claude, sonnet, opus, haiku or anthropic in it, so every
  reasoning-level model listed by mythos-magpie-<n> vanished from their
  model menu. desktopModels now takes what the request's User-Agent says of
  the build (desktopKnowsMythos: " Claude/2.x" and up takes mythos,
  anything older or unreadable does not) and lists such a model by its
  plain anthropic/magpie-<n> alias, which every build keeps, instead.
  Those builds have no mythos effort table either, so no picker is lost
  there. A build that says 2.x keeps the picker alias, and Desktop's
  Code-tab ids (Claude Code's) are unchanged.
- TestClaudeDesktopEffortIDs asks as 2.7032.0 now; the old build is
  covered by TestClaudeDesktopOldBuildModels and TestDesktopKnowsMythos.

Run
- before: TestClaudeDesktopOldBuildModels red at 422d057d —
  "opencode-go/deepseek-v4.1-flash is listed as mythos-magpie-5487751739,
  which the build drops" (the reporter's own id); after: green
- go test -tags nogui -p 2 -count=1 ./internal/gateway/ (full package, ok)
- gofmt -l internal/ clean; go vet and GOOS=linux vet -tags nogui and
  GOOS=windows vet clean; go build and GOOS=linux build -tags nogui and
  GOOS=windows build ok (darwin vet/build: known trayimage cgo warning
  and ld duplicate-library warnings)

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-16 00:46:26 +08:00
ggbdpq abc9006819 gateway: a rule naming a group in the group keeps the group's own routing's order (#2407)
What changed
ruleFirst ranked the candidates of a rule's member by the group's flattened
member order, so a rule that names a group in the group erased whatever that
group's own routing had planned: a rotate group's turn advanced underneath,
but every request the rule put first was served by its first member again.
The rule's own member that is a group in the group is one member now — its
models rank as the group's block, in the order the group's routing planned
them; the members the rules after it name keep their own ranks, so a model
the rule names that the group has too still leads over them (#625,
TestRuleNamesAModelAGroupInItHasToo). TestRuleNamingARotateGroupKeepsItsTurns.

Run
HOME=$(mktemp -d) GOTOOLCHAIN=auto go test -tags nogui -count=1 -p 2 -run 'Rule|Rotate|Nested' ./internal/gateway/ — ok
HOME=$(mktemp -d) GOTOOLCHAIN=auto go test -tags nogui -count=1 -p 2 -timeout 45m ./internal/gateway/ — ok 304s
TestRuleNamingARotateGroupKeepsItsTurns on rules.go at 2e2c8903 (fix stashed): red, "modelA modelA modelA modelA modelA modelA"
gofmt -l clean; go vet -tags nogui (darwin), GOOS=linux -tags nogui, GOOS=windows on ./internal/gateway — clean
go build -o /dev/null . (darwin, known ld warnings only), GOOS=linux -tags nogui, GOOS=windows — ok

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-16 00:46:26 +08:00
ggbdpq 06a4e71ecb qoder: a tool call written into the text that can't be read ends the turn as an error, never as the answer
What changed
A whole <tool_call> block whose JSON doesn't parse, or one the stream
ends inside, reached the agent as the reply text with finish "stop" and
a 200: the call was lost and nothing could fail over. The moved qoder
plugin's 0.2.16 ends such a turn as an error (plugins#132, as trae's
since plugins#38); 8fdd296d, which raised the mover's min, left the
built-in's two exits as they were. The built-in now ends the turn the
same way the plugin does: a block on its way to being a call (its JSON
began, or the XML function form) that can't be read is a 502 — an error
frame with no finish once text was streamed, the status alone before
anything was — and one the stream ends inside is the call when its JSON
is whole, else a 502. A marker that is no call at all, and a block
inside a code fence or inline span, stay text (TestQoderEOF's
"incomplete" case among them, unchanged). Splitter state is qoderText's
new sent (the text given out, so a block in code is told from a call)
and qoderFrag's err, lifted by decodeQoder's emit.

Run
- go test -tags nogui -p 2 -count=1 -run 'TestQoder|TestTextWritten|TestPluginTextWritten|TestQuiet' ./internal/gateway/: ok
  (new TestQoderUnreadableToolCall: the four defect shapes red on
  2e2c8903 — 200 with the block as content, and the cut-short whole-JSON
  call as text — green here; the two stays-text guards green on both)
- gofmt -l internal/: clean. go vet -tags nogui ./internal/gateway: clean.
- Full matrix and ablation recorded in the issue body.

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-16 00:44:19 +08:00
ggbdpq fed24aa1d6 tui: the agents page keeps the row picked in view, however many agents are installed
What changed
- viewList drew every agent and left the window to the terminal: on a
  machine with more agents than the terminal has rows the highlight
  scrolled off the top and the page froze — pressing j changed the row
  while the screen stood still, the same disease the library page had
  (#2220). The rows around the one picked are drawn now, as many as fit
  (the providers page's window).

Run
- TestAgentsViewKeepsTheRowPicked (new): 30 agents on a plain 80x24
  terminal, the row picked at 0, 4, 8, 15, 22 and 29 stays on screen,
  and a tall terminal still shows the list's top. Red at 422d057d
  ("row 0 (agent-00) picked, but the screen stops short of it",
  agents 06-29 with no highlight), green after; red again with only
  internal/tui/tui.go stashed. internal/tui and internal/library whole
  (ok, -tags nogui -p 2). gofmt clean; vet darwin, linux -tags nogui
  and windows = 0; build darwin, linux -tags nogui and windows = 0
  (trayimage_darwin.go's cgo -Wenum-conversion warning as ever).

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-16 00:44:19 +08:00
ggbdpq 3960dd2d5d provider: reading Claude Code's settings while routed takes the stashed tier models with it
What changed: when Claude Code's settings.json points at the gateway,
readClaudeSettings swaps in what routing stashed. It took the endpoint,
token and main model but left the claude.env.<VAR> keys behind — the
tier models (ANTHROPIC_DEFAULT_*_MODEL), ANTHROPIC_SMALL_FAST_MODEL and
CLAUDE_CODE_SUBAGENT_MODEL that routing set aside with them
(internal/agent/claude.go, "back with it when magpie steps out"). The
import entry then offered only the main model where stepping out would
have restored six more. The claude.env.* keys now come back with the
three, as Disconnect would put them.

Run: go test -tags nogui -run
'TestClaudeImportWhileRoutedTakesTheStashedEnv|TestClaudeConfigDirImport|TestImport'
./internal/provider/ green; the new test red on the parent (models
[claude-sonnet-5] miss claude-sonnet-5-x); gofmt -l clean; go vet and
build green on darwin (nogui), linux (nogui) and windows. Not run: the
GUI suite; trayimage cgo and ld warnings on darwin are known noise.

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-16 00:43:16 +08:00
ggbdpq 319b86fe74 provider: a provider's Gemini URL counts as its host when import and Add match the same account
What changed: sameProvider collected a provider's hosts from Chat,
Responses, Anthropic and Decide but not Gemini, so a Gemini-protocol
relay (#1346) was known to no comparison by its Gemini URL: adding the
same relay and key again from the editor went through Add's duplicate
check as a new provider (gemini-relay-2, its usage split — the exact
split the check exists to prevent), and an import entry at the relay
over another protocol read "new" instead of "same". The Gemini URL now
joins both lists, and the two places that rebuild the provider magpie
has (the key-join check in ImportFromApps, keyOf in settle) carry
h.Gemini so the same holding works from the other side.

Run: go test -tags nogui -run 'TestGeminiURLIsItsHost|TestImport|TestAdd'
./internal/provider/ green; the new test red on the parent
(same relay added again as "gemini-relay-2"); gofmt -l clean; go vet and
build green on darwin (nogui), linux (nogui) and windows. Not run: the
GUI suite; the trayimage cgo -Wenum-conversion and ld duplicate-library
warnings on darwin are known noise.

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-16 00:43:15 +08:00