Commit Graph
7089 Commits
Author SHA1 Message Date
yetone 844c355059 dsh: the model shown is the start of the profile in use, and the round's log says what it wrote (#5222)
#5222: with DeepSeek Harness Desktop and four profiles, the desktop
profile started on hy4free while web, headless and open-design started
on deepseek-v4.1-flash, and magpie's log said "wrote dsh's route again"
every half minute or so. Read against dsh 0.2.1-rc.2's own source and
reproduced in a sandbox HOME with dsh's real save (saveSelection through
ConfigEditor.edit and its yaml 2.9.1 library):

- dsh saves a model picked in it into the profile in use alone. The
  profiles drifting apart is dsh's design, and each start is the user's
  own: magpie copies it nowhere.
- magpie never wrote over that pick. After dsh's save the next round
  wrote once, moving magpie's web search entry to follow the new start,
  and then wrote nothing. The log called that "wrote dsh's route again",
  which read as magpie rewriting agent-default-model.
- magpie read the start from the web profile alone, so with the desktop
  app in use the Agents page showed a model its sessions don't start on,
  and picking what it showed changed nothing there.
- A session dsh already has keeps the model of its last request until a
  model is picked in it (selectionFor in dsh-api-session-controller), as
  noticeDsh1 says. The reporter's 429s were OpenCode Zen Free's own free
  limit, reached by a session still on it; the gateway didn't change the
  model.

Now the model and effort fields read the desktop profile when DeepSeek
Harness Desktop is installed (dshLead), else web's as before, and effort
levels are checked against that model. The round logs "dsh's web search
in <file> follows the model it starts on now" when that entry is all it
moved; "wrote dsh's route again" is kept for the route itself.

Run (mote, on origin/main 7dd2434d3; rebased onto 78128b510, which touches
no internal/agent file, and -run TestDsh ./internal/agent run again at
the pushed head: ok):
- go test -run TestDsh ./internal/agent: ok
- go test ./internal/agent, go vet ./internal/agent with GOOS linux and
  windows, gofmt -l: ok (internal/agent 230.6s)
- TestDshShowsTheStartOfTheProfileInUse uses the bytes dsh's own save
  wrote in the sandbox.

Broken by hand, each red:
- dshLead ignoring the desktop profile: "model shown =
  magpie/deepseek/pro, want the desktop profile's magpie/deepseek/flash".
- the search-only write logged as a route write: "the round's log doesn't
  say its one write was the search entry".

Not tried: the real DeepSeek Harness Desktop app with the reporter's
profiles; a user who runs dsh's web profile while the desktop app is
installed still sees the desktop profile's start. Not changed: magpie's
writers find the first agent-default-model entry while dsh writes the
last (dshFind vs findLastIndex); no profile with two was seen (#5229).
2026-11-04 19:23:49 +08:00
yetone 461f9b1ff9 providers: a model chip's right-click turns its image input on or off (archsiono on X)
archsiono on X: "Magpie 给模型开图片输入的开关藏在「名称与推理档位」里,谁能找到 😅
建议在模型右键提供配置". The only place to tell agents a model sees images was
the Accepts images tick inside Names, prices & levels.

A model chip's right-click menu in the provider editor now has Turn on
image input / Turn off image input (开启/关闭图片输入, zh-TW, ja, de too),
under Copy model ID, for every model but a decision model. It stages the
same modelPrefs images value the tick stages: the tick follows, the footer
says "{model} accepts images once saved", and the Save sends it. Nothing
is saved, picked or scrolled by the item.

The core scripts were already 105 bytes over TestCoreScriptBudget on
origin/main 7dd2434d3 (1,533,907 > 1,533,802). This change pays for itself
and that by cutting ten of the provider editor's model-list comments to one
line each: the core is 1,533,139, app.js 1,311,013, no raise.

model-test-as, model-test-why and model-api-preset count the menu's items;
they now expect the image item as the third.

Run on mote (macOS 27), at this tree:
- GUI: model-images-menu (new), model-kind, model-api-preset,
  model-test-as, model-test-why, model-test-one, provider-levels-save,
  i18n-keys, click-scroll, provider-detect-models: 102 of 102 pass,
  Chromium and WebKit; the new file covers en/zh/ja/de at 900 and 420.
- Broken by hand: the new file on origin/main without this change, 8 of
  8 red (no such item).
- go test ./internal/gui: ok except TestMainWindowCorners/macOS_26_SDK,
  red on macOS 27 and filed as #3949. TestCoreScriptBudget passes.
- gofmt -l: clean.
Seen on the way: model-copy-id is 4 of 4 red alone on origin/main
7dd2434d3 (gpt-5.1's chip isn't drawn); commented on #4621.
Not tried: the real app window.
2026-11-04 19:23:24 +08:00
yetone 78128b5101 provider: a plugin's thinking model listed as, or the same as, another takes that model's levels (axelburks)
axelburks on Discord: a plugin's model that thinks and declares no
variants, set the same as and listed as claude-opus-5.5, took Claude Opus
5.5's price but showed its reasoning levels unknown, none ticked.

Cause: pluginCatalog borrowed levels for the plugin's own model id
(borrowedEfforts(m.ID)), which no catalog knows, so it got none; the
rename to the id the user lists it by (localIDs.list) then kept that
empty list. The price is looked up by the listed/same-as id, which is why
only the levels were missing.

Fix: a model whose levels were borrowed (catalog.Model.EffortsBorrowed,
set only in pluginCatalog's borrow) borrows them again for the id it is
listed by, which also follows the user's same-as. Levels the plugin's
own variants give stay first, and the levels the user kept narrow the
borrowed ones as before (effortsKept).

Test: TestPluginModelListedAsBorrowsLevels (listed as and same as one
id, listed by a name of the user's own, a model with variants of its
own, the price, and kept levels narrowing them).

Red on the old code: with the localid.go hunk reverted it fails with
"claude-opus-5.5 listed with levels [] ... want [low medium high xhigh
max]", the same for the gateway's p.Efforts and for my-opus.
Broken by hand: dropping the EffortsBorrowed set in plugins.go turns it
red (4 "want [low" errors). TestPluginThinkingModelBorrowsEfforts and
TestClinePluginBorrowsEfforts stay green.

Run on mote at this tree (on 7dd2434d3): go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./...: ok. go test -count=1
-timeout 45m ./internal/catalog ./internal/provider ./internal/settings
./internal/cli: ok. ./internal/gui: two reds in files this change
doesn't touch, both filed: TestCoreScriptBudget (#5139, app.js budget;
no asset changed here) and TestMainWindowCorners/macOS_26_SDK on mote's
macOS 27 (#3949). No GUI file changes, so no GUI suite run.

Not tried: a real plugin account with such a model in the editor, and
the full suite before the push.
2026-11-04 19:16:10 +08:00
yetone 7dd2434d31 remote quotas: a key with Quotas on but told no card shows why too (yi_time)
ef6bd155f made a held remote read show the remote's own card saying why.
A key with Quotas on that may use no provider's cards is answered 403
held too (writeCards), so it now shows that card as well, and the full
suite went red on TestRemoteMagpieShowsHeldKeyItsQuotas, which expected
the key's own card alone. The test now expects the held card, and the
words tell such a key what is missing: let it use every model of a
provider whose usage it is to see, not only turn Quotas on. The GUI
string ends "hover for what to change there" in every language; the core
weighs 21 bytes less than before (1,533,980; main is over its budget
under #5139, not by this).

Run (mote, at 053fc9f9c, on ce21ea856):
- go test -count=1 -run 'Remote|Quota|HeldKey' ./internal/provider
  ./internal/gateway: ok, ok
- node --test usage-remote-cards, routing-remote-windows, i18n-keys
  (Chromium + WebKit; en, zh, zh-TW, ja, de): 36 pass, 0 fail
- TestCoreScriptBudget: red as on main (#5139)
- gofmt -l: clean
Broken by hand: errRemoteHeld's wording changed, the gateway test went
red with the new card's text; restored.
Not tried: a real Windows magpie against a real Mac one.
2026-11-04 18:49:38 +08:00
yetone 0ebe6c72c9 providers: each account row in the editor has its own Check in now, when the check-in reaches it and it isn't in today (xwoffice_91592 on Discord)
xwoffice_91592 asked for 立即签到 on each account in the provider editor
sheet (Trae CN, a plugin's subscription, one row per account with its
Credits line). The editor's rows read GET /api/login/usage, which carried
no check-in. It now passes those cards through provider.LoginCheckins,
which marks them as the Usage page's cards are (WithCheckins: checkins,
checkinBy, checkin, checkinOff) and adds checkinKey, the account's key
in its vendor's check-in (markCheckins sets it).

The row's button is Settings' Check in now for one account (xiaowu_95660),
not a fork. ciAcctFill in checkinnow.js presses ciNowSend with
{key, user} and checkinBy, so the same POST /api/usage/checkin-account,
the same status-line success and failure, then the row's usage is read
again. When to show it is checkinDue, taken out of checkinRow so the
Usage card's press and the row decide alike: the check-in reaches it, it
isn't off, and it isn't in today (a failed day, an "again" answer, or a
Qoder campaign not open yet still count as due). It sits at the end of
the account's usage line, small (.ci-acct), and wraps whole there rather
than being cut. app.js is 51 bytes smaller (comments cut); checkinnow.js
is lazy and not in the core.

Run (mote, worktree at origin/main 14f6d10de plus this):
- go test -run 'TestLoginCheckins|TestTraeCheckin|TestPluginCheckin|Checkin'
  ./internal/provider/: ok. GOOS=linux and GOOS=windows go vet -tags
  nogui ./internal/gui/ ./internal/provider/: ok. gofmt -l clean.
- New editor-checkin-account.test.cjs: 4 Trae CN accounts (due, in
  today, failed today, no check-in), en zh zh-TW ja de, 1000/560 desktop
  and 390 web, chromium and webkit: ok. It checks the translated label and
  tooltip, the placement (not cut, no sideways scroll), the press body
  {by, key}, the status line, the re-read, and that nothing scrolls.
- The editor-*, account-*, checkin-*, plugin-checkin,
  qoder-checkin-recheck, usage-card-* and i18n-keys files, both engines:
  634 of 635 ok. The red is account-eye's Usage card in chromium zh-TW,
  '' !== 'none', which is #5052; run alone it passed 30/30 twice.
- TestCoreScriptBudget: red at 1,533,950 > 1,533,802, which is #5139 (red
  on main at 1,534,001 before this); this change lowers it by 51.
- Rebased on c03dee7e3 (no core script or check-in file changed there):
  editor-checkin-account, i18n-keys and checkin-now-account, both
  engines, 28 of 28 ok; the Checkin provider tests ok; budget the same
  1,533,950.
- Broken by hand: no CheckinKey in markCheckins made
  TestLoginCheckinsPressOneAccount red.

Not tried: a real Trae CN account, WebView2 or WebKitGTK. The whole GUI
suite hadn't run before the push: another session's whole suite held
mote.
2026-11-04 18:49:11 +08:00
yetone ce21ea8566 usage, routing: counts are said short (K/M, 万/亿), the exact number on hover (skyhuang1994)
skyhuang1994 on Discord: long token and request counts on Usage and
Routing are hard to read at a glance. They now go through fmtN (K/M/B,
in Chinese 万/亿), with the exact grouped number (ledNum) as the title,
so hovering shows it. A count that fmtN already writes in full gets no
title.

- Usage (plugins/usage/page.js): the Requests table's input, output and
  cache cells (output keeps its reasoning line, cache write its TTLs
  under the exact number), the Requests block, retried, the sources
  tile and the ledger's sum line. sameRead moves here from app.js,
  beside loadSessions, its only reader.
- app.js: the Tokens and Requests blocks (blk takes a title), the
  ledger's call count, the rank's values and "{n} requests".
- Routing (plugins/routing/client.js): the day menu's note, the "more
  days" name, the day rows and the stats.
Core scripts: 22 bytes smaller than their base (1533979 at this head;
TestCoreScriptBudget stays red on #5139 as on main, not worse).

Tests: usage-compact-counts.test.cjs is new (Usage and Routing, every
language, chromium and webkit, 420 and 1100px). panel-usage's rank
value expects "900K" with title "900,000"; ledger-cache-unknown's
counted cells expect fmtN text with ledNum as the title.

Run (mote-run):
- at ded9e4a62 (on c03dee7e3): TestCoreScriptBudget 1533979 (red, #5139),
  usage-compact-counts, ledger-cache-unknown, panel-usage, i18n-keys:
  50/50.
- at c533a569d (on 69eb93e0a): 136 GUI files (usage-*, ledger-*,
  panel-usage, i18n-keys, routing day/stats files) 1868/1917. The reds,
  rest-try-now (#5035, #2564), usage-agents-hide (#2276), usage-fold
  (#3415), usage-ledger (#5048), ledger-swipe (#5223), usage-computers
  (#5224), are red the same or worse on origin/main 0a5dc40ab in a
  4-file run under the same load; c533a569d's 4-file run had a subset.
- at 56fff616a (on d5d48f4f9): 206 GUI files; besides the above,
  tray-cell-click (#5215) red the same on origin/main 009076a2a.
Broken by hand: page.js, client.js and app.js put back to main's ->
usage-compact-counts and ledger-cache-unknown 0 pass / 42 fail;
restored.
Not tried: the real app with real usage data, the Linux WebKitGTK app,
Windows.
2026-11-04 18:44:11 +08:00
yetone c03dee7e3e agent: LiveAgent, magpie's models in its model picker (xiaoxiaofei. on Discord)
xiaoxiaofei. asked for LiveAgent (Stack-Cairn/LiveAgent, v2). LiveAgent 2
is a Tauri app that runs its models through K-brain, a Go backend it
starts as `k-brain backend -data-dir <root>`; every provider lives in
<root>/config.json (JSONC, Pi's provider shape). Root: $LIVEAGENT_HOME,
else $K_BRAIN_HOME, else the folder ~/.liveagent/data-dir.json points to,
else ~/.liveagent, on every OS (LiveAgent's data_home.rs and
kbrain_backend.rs, K-brain's internal/config and internal/storage).

Connect adds providers.magpie: type claude_code + api anthropic-messages
(what LiveAgent's own settings write for an Anthropic-compatible
provider), baseUrl the gateway root (K-brain appends /v1 and posts
/messages with X-Api-Key), the key naming LiveAgent, activeModels null,
modelOrder in magpie's order, models sorted by id with display name,
window, output limit and input [text, image]. K-brain decodes with
unknown fields refused, so only its fields are written. A default or
compact model still K-brain's endpoint-less demo model1 becomes magpie's
first; the user's own pick stays. Through a sync the user's name, the
models they turned off, their order, K-brain's metadata and a model's
own displayName stay; a new model is on and last; nothing to change
writes nothing. A file K-brain wouldn't read as providers (not an
object, providers not an object, top-level models, a bare provider) is
left alone. Disconnect takes the entry out, puts picks back to K-brain's
default, gives a file left with no provider K-brain's demo back (its CLI
restores config.json.bak, which could hold magpie's, from a file with
none), and removes a file holding only what magpie made. LiveAgent's
backend holds the settings and writes them whole on any change, so a
change is refused while liveagent or k-brain runs (macOS/Linux; the
notice says to quit it first, in every language). Logo: the app's own
64px icon (src-tauri/icons/64x64.png, MIT) in an SVG.

Run on mote at this tree:
- gofmt -l clean; go vet ./internal/agent ./internal/agentenv for darwin,
  linux (nogui) and windows
- go test -tags nogui ./internal/agent -run 'LiveAgent|GatewayKey|ListsModels'
  ok; ./internal/agentenv ok; ./internal/gui: only TestCoreScriptBudget
  red, which is red on its base too (app.js untouched here; #5139)
- GUI icon-tile, i18n-keys, agent-notice-lang, gui-zh-tw, gui-ja, gui-de:
  Chromium 27/27, WebKit 27/27
Broken by hand on mote, each red: the user's activeModels not kept
(TestLiveAgentProvider "activeModels after sync [], want [...]"); the
demo provider not put back (TestLiveAgentMakesItsFile "emptied file");
the demo default not replaced (TestLiveAgentProvider, TestLiveAgentMakesItsFile).

Real use on mote (sandbox HOME and LIVEAGENT_HOME, this magpie on
127.0.0.1:3562, a fake Anthropic upstream on 3561, LiveAgent 2.0.5's
bundled k-brain from the release dmg):
- k-brain backend's first start wrote config.json as {}; magpie
  liveagent magpie then wrote providers.magpie and the default pick
- `k-brain run "Reply with exactly: pong"` (K-brain's CLI, same config
  and routing code) answered "pong"; the upstream saw POST /v1/messages
  from magpie
- the backend LiveAgent starts listed magpie's model in /v1/models with
  it as the default, and its /v1/text/generate answered "pong" through
  magpie
- with k-brain running, connect/disconnect were refused with the notice;
  after it quit, disconnect removed the file magpie made
Not tried: LiveAgent's window itself (its model picker was not opened;
the backend's API it reads was); LiveAgent on Linux or Windows; a real
vendor reply (fake upstream).
2026-11-04 18:41:13 +08:00
yetone 1a1ca0351b Revert "catalog: a listed model its id names a video model is one (agnes-video-2.5)"
This reverts commit b5b6cc573. It broke a rule #1399 set on purpose: a
model's name alone makes no video model, since magpie would then send
videos requests to a relay that may not serve them. A relay's video model
stays in the chat list until its list says "kind": "video" or the user
marks it Video in the provider editor, which needs the row there. The
full suite at b5b6cc573 (mote, go test -timeout 45m ./...) was red in
internal/gateway on TestCustomProviderMakesVideos,
TestCustomProviderVideoNeedsTheListsWord and
TestCustomProviderVideoTheUserMarks: sora-like-2, unmarked, became a
video maker and a /v1/videos request went out for it. I ran only
catalog, provider, agent and gui before pushing, not gateway.

Agnes's agnes-video-2.5 and -flash therefore stay among its chat models,
and the user marks them Video, as #1399 designed.

Run (mote, at this tree): go test ./internal/catalog and
go test -run 'TestCustomProvider' ./internal/gateway.
2026-11-04 18:38:32 +08:00
yetoneandwaynesguan 0a5dc40abc gateway: a group's trusted Claude, GPT and Gemini thinking streams as it comes, a refusal or error after it going to the next member (#4166)
A try whose model's vendor may refuse after its reasoning (#248) had its
reasoning held while another candidate could answer, whatever the member
had answered lately. Through a routing group Claude Code saw a Claude
member's thinking only with its text, all at once, and never its
"thinking with <effort> effort". waynesguan measured it on one WorkBuddy
account: `workbuddy claude-opus-5.5` alone, first thinking at 3.66s;
through the group, all 67 thinking deltas with the text at 17.25s.

Ported from waynesguan's 71aacaa (on f8987ce61): the trust #4512 gave
DeepSeek now covers Claude, GPT and Gemini, but only where a refusal
after the reasoning can be handed to the next candidate in the same
stream (handsOver, refusalHandover). Once a member's thinking has gone
on to an answer thoughtCleanMost (3) times running, its reasoning goes
as it comes; a refusal after it, nothing yet said, goes to the next
member, whose reply follows as the same one; the refusal takes the trust
back. Where no handover is possible (no stream, a Gemini-protocol agent,
a compaction wanted whole, refusals asked again enough, the last
candidate) it is held as before. holdsThinking is decided after hw.over.

Added in review: the port alone lost failover for errors. passOver
handed over only a refusal; a retryable error after shown reasoning
(Anthropic's mid-stream overloaded_error) counted as the answer begun and
reached the agent, the next member never asked, where the held stream
had failed over. passOver now hands a retryable error over too
(handOver(status, msg, refused=false)): the try fails with its status
and words, as a held one did, and the next member's stream follows. A
non-retryable error (a request at fault) still reaches the agent. This
also applies to GLM's and trusted DeepSeek's shown reasoning, which had
the same gap.

Tests:
- TestTrustedThinkingFailsOverOnEveryPath: claude (Anthropic upstream),
  gpt and gemini (Chat upstream) members x refused / overloaded /
  invalid x /v1/messages, /v1/chat/completions, /v1/responses, 27
  cases; spliced stream checked per protocol (one message_start, block
  indexes, sequence numbers, one [DONE]).
- TestClaudeThinkingStreamsOnceTrusted, TestClaudeTrustedThinkingStreamsThroughGroup
  (waynesguan's), TestClaudeTrustedThinkingErrorFailsOver.

Broken by hand:
- main's fallback.go + gateway.go: the 18 refused/overloaded cases,
  TestClaudeThinkingStreamsOnceTrusted ("a trusted Claude member's
  reasoning is still held") and ...ThroughGroup ("first thought only
  1.541µs before the text") FAIL.
- port without the error handover: the 9 overloaded cases and
  TestClaudeTrustedThinkingErrorFailsOver FAIL (the agent got
  "Overloaded", b asked 0 times).

Run (mote, via mote-run): go test ./internal/gateway/ at 741f7a8f2
(877s) ok but TestClosedBeforeSentEveryTimeSaysWhy (bare EOF, Codex
closed-unsent path, already #5031, not touched here); after rebase on
e7b0c398e: -run 'Thinking|Refusal|Handover|ObjectRoot|DeepSeek' ok;
gofmt -l clean; go vet ./internal/gateway/, GOOS=linux go vet -tags
nogui ./..., GOOS=windows go vet ./... ok. Full suite runs after push;
its reds are filed separately.

Not tried: a real refusal or overloaded_error after thinking from a real
account (can't be triggered at will); Claude Code against a real group
with this build; Windows/WSL runs (vet only).

Co-authored-by: waynesguan <wenwenguan@tencent.com>
2026-11-04 18:37:43 +08:00
yetoneandFlandern e7b0c398ee sessions: find a ZCode title by its gateway id (#5195)
ZCode sends its session id to the gateway without the sess_ prefix stored
in its database. Routing asks Titles with that bare id, gets no title, and
falls back to the folder name even though the Sessions page can show the
real title.

Titles treats zcode:<id> as an alias for zcode:sess_<id> when it reads
local session files, and returns the title under the key Routing asked
for (the sess_ key too, which callers ignore). A regression test uses the
database id shape ZCode writes and the bare request id it sends.

Ported from Flandern's b1a952b73 (fix/zcode-routing-session-titles on
flandern12111/magpie), code and test unchanged, reviewed line by line;
the body is rewritten (the original had literal \n's), and
gateway-sessions.md says it.

Run on mote via mote-run, at origin/main c7bbd3faf plus the change before
this one: go test ./internal/sessions -run
'TestZCodeTitlesByRequestID|TestSessionTitles|TestTitles|TestZCode'
-count=1: ok. Again at this commit on origin/main 14f6d10de: go test
./internal/sessions -count=1 ok.
  Pushed on c4245c4c2, which changes only internal/gateway's
  object_root and its doc after 14f6d10de; not run again on it.

Broken by hand: the alias lookup removed, TestZCodeTitlesByRequestID red
("zcode:578bd3d1-…: title \"\", want \"A ZCode session's title\"").

Not tried: a real ZCode session through a running gateway.

Co-authored-by: Flandern <3180066912wzw@gmail.com>
2026-11-04 18:33:07 +08:00
yetone 70a98dd85c routing: a long Accounts and keys shows its first rows, the rest behind Show N more (ferock4669, iyou00 on Discord)
With many keys the Routing page's Accounts and keys ran on and on: each
card held every window, the models it answered and a meter. Now a card
keeps its name, one line of what is left (or its rest) and how it fares,
with Try now or Sign in again when it needs one. The models it answered
are in its tooltip under its id, and a subscription's other windows are
on hover over its figure.

A list longer than 8 rows shows the first 8 and puts the rest behind
"Show N more" at its foot (kept across a reload in
magpie.routingActsAll). Never behind it: a row to sign in again, a
resting account or model, failures with no answer, a remote whose
allowance can't be read, rows under a fold the reader opened, and the
heading of a provider with a row shown. Two more alone aren't folded.
The button clicked stays where it is on the screen. "View usage" beside
it opens Usage's Overview, where each account's card says it all,
without making that tab the reader's own (window.openUsageOverview).

The foot writes only what changed, so an idle page writes nothing
(routing-live-calm).

Tests: routing-acts-compact.test.cjs (new; chromium and webkit, en zh
zh-TW ja de, 1300px and 420px). routing-account-windows,
routing-read-allowances, routing-wallet-lapse, routing-accounts-narrow
and routing-columns follow the card's new shape and the foot.

Run on mote via mote-run, worktree based on origin/main c7bbd3faf:
- Whole Routing GUI set (routing-*, panel-routing*) + i18n-keys,
  chromium and webkit: 2487 pass, 29 fail, every red one of those
  below (many-keys and routing-levels #3620 too)
- Same reds on clean origin/main c7bbd3faf (11 files run there): the
  routing-rule-remove (#3096), rule-drag (#3789), row-swap (#3799),
  order-unknown (#4627), rules-line (#3593), steady, steps-cap and
  story-shrinks reds of #5088, in different languages run to run.
- routing-folder went red 2 of 3 with this change (30/30 on main):
  its press() clicked Save while the group editor was still growing
  open, and the foot moved .rt-gsec 8px. press() now waits for the
  button to hold still: 3 runs x both engines 20/20, webkit alone
  10/10.
- TestCoreScriptBudget red, 1534154 > 1533802, identical on clean
  c7bbd3faf (#5139): this change adds nothing to the core scripts.
- routing-acts-compact twice, alone and beside 5 files: 22/22, 20/20.
- Rebased onto origin/main 14f6d10de (its routing client.js changes
  merged clean), at this commit, both engines: routing-remote-windows,
  week-low, free-expiring, group-strategy, acts-compact, live-calm,
  folder, account-windows, read-allowances, accounts-narrow,
  wallet-lapse, columns and i18n-keys all green.
  Pushed on c4245c4c2, which changes only internal/gateway's
  object_root and its doc after 14f6d10de; not run again on it.

Broken by hand:
- rows needing the reader no longer kept out of the collapse (m.keep
  ignored): routing-acts-compact red (Show 4 more never shown).
- a row to sign in again under a shut fold not drawn: red (Zed's fold
  row 0 !== 1).
- the foot's hidden/aria-expanded written every draw: routing-live-calm
  red in both engines (attrs: 6 !== 0), as in an earlier run of this.
- the button's hold removed: routing-acts-compact red (chromium en
  1300px, "the click moved the button: 572.9 → 592.1").

Not tried: the real app with a real long key list (fixtures only), the
Linux WebKitGTK app, Windows.
2026-11-04 18:33:07 +08:00
yetone c4245c4c20 gateway: a Messages body's tools with a root union go folded to every upstream
ziko on X (11-04): ZCode on Zed's subscription, Claude Sonnet refused
every request. Six of the GoAnyAPI MCP server's tools (goanyapi_adsense,
the 36th, among them) have a oneOf at their input_schema's root, ZCode
sends every tool with every request, and Anthropic's API turns such a
request away: "input_schema does not support oneOf, allOf, or anyOf at
the top level".

Cause: a request translated to Messages always had its tools folded to an
object root (objectSchema, #1271), but a Messages body relayed as it came
(ZCode or Claude Code to an Anthropic-protocol provider, the Zed plugin's
models among them, whose plugin provider has an Anthropic URL) never
was: foldsRoots and objectRootsBody handled Chat and Responses only, so
neither the first ask nor the retry after the refusal folded it.

Change (object_root.go):
- foldsRoots is true for every Anthropic-protocol relay, from the first
  ask, as a translated request already was.
- objectRootsBody takes a Messages body: a client tool's input_schema goes
  through provider.ObjectRoot; a server tool (no input_schema) and a
  schema with no root union go as they came. The translated path
  (to != Anthropic guard at gateway.go's objectRootsReq) is unchanged, so
  nothing is folded twice.
- docs/subsystems/gateway-routing.md gains the root-union bullet.

Test: TestMessagesRootUnionFolded, POST /v1/messages (stream) to a relay
with an Anthropic URL whose fake refuses a root union with Anthropic's
own wording: the union tool goes as an object root on the first ask, its
branches' properties merged; a plain tool's schema goes unchanged, and so
does a body with no union.

Run on mote at 69eb93e0a (origin/main, just fetched) plus this change:
gofmt -l clean; go vet ./internal/gateway on darwin, GOOS=windows and
GOOS=linux -tags nogui, ok; go test -timeout 45m ./internal/gateway:
ok (914s); go test ./internal/masking (reads the
subsystem docs), ok. Not run: the whole ./... suite; CI runs it.

Rebased after the run onto 14f6d10de: its three commits since 69eb93e0a
change catalog, provider/remote_quotas and GUI files, none in
internal/gateway.

Broken by hand: object_root.go back to HEAD, TestMessagesRootUnionFolded
answers 400 "tools.1.custom.input_schema: input_schema does not support
oneOf, allOf, or anyOf at the top level", the reported error.

Not tried: a real Zed account with GoAnyAPI's tools; the fake answers as
Anthropic's documented refusal does.
2026-11-04 18:26:37 +08:00
yetone 14f6d10de0 routing: a remote's Claude card whose read failed says so on its row, not nothing (yi_time on Discord)
remoteWinsOf (c7bbd3faf) drew a Remote magpie row's windows from the
remote's cards. It said "Allowance unavailable" only when the remote's own
card failed. When the remote answered but its Claude card there carried an
error (the remote's own Claude read failed), the Usage page showed that
card and its reason, while Routing's row showed nothing. The row now takes
the error of the card of its own family (Claude's on a claude row,
Codex's on a gpt/codex row), with the reason on hover. The remote's own
card still comes first. The plugin's file only; no core bytes.

Run (mote, worktree on origin/main 69eb93e0a plus 607f8b43a):
- routing-remote-windows.test.cjs (a new remote "elm", its model named
  as a remote really names it, claude/claude-opus-5, its Claude card
  erroring and its Codex card erroring otherwise) and
  routing-account-windows.test.cjs, 5 languages, 1100 and 420px, chromium
  and webkit: 44 pass, 0 fail.
- Broken by hand: the new fallback removed made routing-remote-windows go
  0 pass, 22 fail.
- Real two-magpie repro (see 607f8b43a): with A's key held, B's Routing
  row says "Allowance unavailable — hover for why", the held reason on
  hover; with Quotas on, 5 hours 40% · 7 days 12%.

Not tried: yi_time's own setup, which this may not be. Their Routing
report came before v0.1.2908 (c7bbd3faf) was published at 07:08 UTC on
11-04; a Windows magpie older than that draws no remote windows on
Routing at all. Not tried in WebView2 or WebKitGTK.
2026-11-04 18:14:11 +08:00
yetone ef6bd155ff provider: a remote magpie that holds this key says so, where its Claude card went missing with no word (yi_time on Discord)
yi_time on Discord: "没变化 还是不显示通过局域网添加的Claude额度". c7bbd3faf
(v0.1.2908) drew a Remote magpie's cards on Routing. It did not cover a
remote that answers 403 gateway_key_held. That is a key held to a budget,
models or accounts there, without the key's Quotas on (#1981, #2216). For
such a key, keepRemoteCards dropped the cards and remoteCards returned
nothing. The remote's Claude then vanished from Usage, the tray panel and
Routing, with no reason shown anywhere; only the key's own Limit card
stayed.

The remote's own card now carries errRemoteHeld. quotaError words it as
"That computer's magpie tells this key no quotas: it holds the key to a
budget, models or accounts — turn on Quotas for the key under Gateway keys
there", in en, zh, zh-TW, ja and de. Routing's existing "Allowance
unavailable — hover for why" shows it too. A failed read since the hold
(unreachable, refused) still leads with that read's own error.

Only the computer that shows the quota needs this release. The computer
that holds the account needs nothing new, but its owner turns on Quotas
for the key, or lifts the key's hold.

app.js pays for its one line with four quotaError comments cut. The core
weighs 1,534,001 against 1,534,022 on origin/main, so it grows nothing and
raises no budget. TestCoreScriptBudget stays red as on main (#5139, owned
there).

Run (mote, worktree on origin/main 69eb93e0a):
- Real two-magpie repro, sandbox HOMEs. A (old binary) on 3561/3562 had a
  Claude account and LAN on. B (this change) on 3571/3572 added A with
  `provider add remote-magpie <key> url=http://<lan ip>:3561`. A's key was
  held to claude/* models.
  - Before: B's Usage, panel and Routing had no Claude card and no reason.
  - After: Usage and the panel's Allowances show the new line; Routing
    shows "Allowance unavailable — hover for why".
  - With `gateway-key quotas <id> on` on A: B shows remote-magpie/claude,
    5 hours 40%, 7 days 12%.
- go test -run 'Remote|Quota' ./internal/provider: ok. gofmt -l clean.
  GOOS=windows and GOOS=linux go vet ./internal/provider: ok.
- usage-remote-cards.test.cjs (now en, zh, zh-TW, ja, de; chromium and
  webkit) and i18n-keys.test.cjs: 14 of 14 pass.

Broken by hand:
- remoteCards' held branch put back: TestRemoteMagpieHeldKeyShowsOnlyItsOwnCard
  red with 3 errors.
- quotaError's new line removed: usage-remote-cards went 0 pass, 5 fail.

Not tried: yi_time's own two computers, a real Claude account on the
remote (the repro's account is a fake token with a kept reading), the
Windows and Linux app engines (WebView2, WebKitGTK). Whether yi_time's key
is held is not known.

Sibling, filed rather than changed here: with Quotas on and a key held to
only some of a provider's models, the remote answers [] and this side says
"Nothing read on that computer yet" (#5217).
2026-11-04 18:14:10 +08:00
yetone b5b6cc5739 catalog: a listed model its id names a video model is one (agnes-video-2.5)
glorious_rabbit_30894 on Discord (#help): models of a custom provider
pointed at Agnes AI (apihub.agnes-ai.com/v1) "can't be added to an
agent". Agnes runs new-api; its /v1/models rows carry only id,
owned_by "custom" and supported_endpoint_types ["openai"], no kind,
domain or modalities. Nothing but the id tells agnes-video-2.5 and
agnes-video-2.5-flash from its chat models, and magpie had a name check
for image models (DrawsID) but none for video, so both were offered to
every agent as chat models, and never as video models.

FilmsID is DrawsID for videos (video, sora, veo, kling, seedance,
hailuo, vidu, runway, *-t2v/i2v/r2v; veo and kling only as a word of
their own, so inkling still chats). fetchPage marks a row a video model
by it when the list says no kind, no domain, no text output and the id
isn't an image model's. mendKinds applies the same to a list saved
before, so a fetched Agnes list is fixed on the first read, not the next
fetch. A model whose list says it answers in text is never moved.

Checked FilmsID against every id in models.dev's cache (~/.cache/magpie
models.json, 2026-11-04): every id it matches outputs video and no text,
except nvidia/synthetic-video-detector (a classifier, text out); video
models it misses are named for nothing it could know (ray2, minimax-h3,
gemini-omni), and their lists' modalities or a user's kind still mark
them.

Not the cause of the report, as far as can be told: with Agnes's real
list (testdata, fetched 2026-11-04) and models.dev's real cache, a
custom provider at .../v1, at the bare host, Anthropic or Responses
protocol, reaches Available, Exposed and Catalog with all four chat
models, and every agent's picker (claude, codex, opencode, pi, omp,
... 75 fields) lists them beside a relay's. The reporter says (#help 09:52) dsh, VS Code and Codex can't pick them,
with no error; that is not reproduced here and is asked for.

Run (mote):
- at this tree on origin/main 69eb93e0a: go test ./internal/catalog ok;
  go vet ./internal/catalog ./internal/provider for darwin, linux and
  windows ok; gofmt -l clean
- at the same change on 9595a503a: go test ./internal/provider
  ./internal/agent ok; ./internal/gui red only in TestCoreScriptBudget
  (#5139) and TestMainWindowCorners/macOS_26_SDK (#3949), both filed,
  neither in a file this touches
- sandbox HOME, Agnes's real list + models.dev's cache: Picks, Spell,
  Apply and Drift for codex, dsh, vscode, claude, opencode take
  agnes/agnes-2.5-flash with no error, and magpieModels for each lists
  the four chat models and, with this change, no video model
Broken by hand: live.go at HEAD with FilmsID kept: both Agnes tests red
(video models [] and listed as chat, saved list's too); green with it.
Not tried: a real Agnes key (none here); Agnes's video models asked at
/v1/videos (magpie's video path for a base URL) — whether Agnes serves
them there is unknown.
2026-11-04 18:10:35 +08:00
yetone 69eb93e0a2 antigravity: an account's tiers are asked again each hour, so one that became Ultra lists Gemini 4 without a restart (rick_49551 on Discord)
rick_49551 reports an Antigravity account on Google AI Ultra whose model
list in magpie has no Gemini 4. magpie lists whatever fetchAvailableModels
gives, less chat_/tab_ ids, six fixed ids and the models Google marks
disabled; which models Google gives depends on the tier named in
entitlement.userTier, and that tier came from loadCodeAssist once per
magpie run: googleState.projects kept it with no expiry, while Gemini
CLI's experiments (flags) are asked again each hour. An account that
became Pro or Ultra after magpie first asked went on naming its old tier
(none, for a free account) in every hourly relist, and Google went on
listing it gemini-4-argon-disabled with "disabled": true, as it does the
owner's free account today (app.log 11-04: "disabled
[gemini-4-argon-disabled]"), which a7ed2f61d leaves out. Only a restart
asked again.

Now the list (modelInfo) asks loadCodeAssist again once the tiers are an
hour old, keeps the project, and takes the new current/paid tier and plan;
a failed or empty answer keeps the old ones for another hour. A change is
logged with the old tiers. The request path (project()) is unchanged, so
no request waits on loadCodeAssist.

Tests: TestAntigravityTierAskedAgainAfterUpgrade (free account, then the
fake's loadCodeAssist says g1-ultra-tier "Google AI Ultra": within the hour
no new loadCodeAssist; an hour on the list names g1-ultra-tier and has
gemini-4-argon, the plan reads Google AI Ultra; a failed loadCodeAssist
keeps it).
Broken by hand: with the antigravityTiers call commented out it fails
"Ultra: models [gemini-3.8-flash-high], want [gemini-3.8-flash-high
gemini-4-argon]"; restored, it passes.
Run (mote, at this tree): gofmt -l; go vet ./internal/provider/ on darwin,
GOOS=linux -tags nogui, GOOS=windows; go test -tags nogui -count=1
./internal/provider/ (ok, 138s).
Not tried: a real Ultra account. The Ultra fixture (gemini-4-argon enabled
under g1-ultra-tier) is inferred from the free account's real list and
Google's forum notes, not rick's bytes. Whether this is rick's case
depends on his magpie log's loadCodeAssist/fetchAvailableModels lines:
if loadCodeAssist itself has no paid tier, or Google refuses
g1-ultra-tier (400), this change doesn't help, and those lines say so.
2026-11-04 17:46:30 +08:00
yetone 8ac5f98e2a claude: an interactive run's side question branches after the whole reply, not after its tool call
sleepy_shibe (Discord, magpie 0.1.2906, Claude Code 2.1.318,
claude-opus-5-5, macOS): in the bridge's interactive mode, the turn
after a prompt suggestion went on in a branch that held only U1, the
tool_use, "Tool call interrupted" and <synthetic>. The call's result
and the reply A1 were gone.

Cause: in TUI mode the reply streams through tap.js and the turn ends at
the stream's message_stop. The transcript translator, which polls the
session file every 50ms, notes the reply's row (and its uuid) only
after that. Claude Code asks for its suggestion straight away, so
resume saved run.lastLine as the place to branch, and lastLine was
still the tool_use row. branchAt then cut the copy just after the
call.

Fix: the run also keeps the reply's message id (lastMsg). It is set at
the stream's message_start, or from a row that was never streamed. The
id travels as backMsg, then behindMsg, then savedSession.behindMsg. The
cut (cutReply/cutAfterReply) keeps everything up to the last line of
the main thread whose message.id is the reply's, so the reply's
thinking and text rows and the tool_result before them stay in. A
sub-agent's (isSidechain) line with the same id doesn't count. With no
id, or none found in the file, the cut goes after the uuid as before.

Tests:
- TestClaudeInteractiveSideQuestionAfterACallKeepsTheReply. The fake
  claude writes its reply row a second late, as the real transcript
  does. The test runs a turn with an MCP call, then its result, then a
  suggestion, then "now commit it". The next turn must go on in a
  branch that holds 4 lines (U1, the call, the result, A1) and is told
  only "now commit it".
- TestClaudeCutReplyKeepsTheWholeReply cuts a Claude Code 2.1.318
  shaped jsonl: a tool_use and its tool_result, a reply split into
  thinking and text rows, a sidechain row of the same id, turn_duration,
  and the suggestion and its answer. The fake's MCP call body is built
  outside $( ), because macOS sh (bash 3.2) lost the $$ in there.

Run (mote, at this tree on 9595a503a):
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway/
  ./internal/claudetui/: claudetui ok. Gateway is red only on
  TestGroupBackupStandingInWhileTheFirstIsBackAndBehind and
  TestGroupMemberPutFirstOnItsMeritsKeepsItsCache. Both fail the same
  way on origin/main 9595a503a (just fetched, run alone on mote) and are
  filed as #5209.
- Rebased on 009076a2a, which fixed #5209. At the pushed head:
  go test -tags nogui -count=1 -run 'TestGroup|TestClaudeInteractive|
  TestClaudeCut|TestClaudeAside|TestClaudeToolChoice' ./internal/gateway/: ok
- go vet -tags nogui ./internal/gateway/, GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./..., go build ./...: ok
- gofmt -l: clean

Broken by hand: origin/main's claude_subscription.go with the new e2e
test, -count=3: red 3 of 3. "the turn after the suggestion: pid N had 2
turn 1": the branch was cut after the tool_use, the reporter's case.

Not tried: a real interactive Claude Code 2.1.318 run with a real
account. The fake reproduces the timing (the row lands after
message_stop), not the real TUI.
2026-11-04 17:45:34 +08:00
yetone 009076a2a4 gateway: group stand-in tests make Codex low by its 5 hours, a week at 92% is spent first (#5209)
d5d48f4f9 (v0.1.2920, ysicing_01858) stopped counting a week at 90%+
alone as "low": what the week has left is lost at its reset, so it is
spent before what keeps. TestGroupBackupStandingInWhileTheFirstIsBackAndBehind
and TestGroupMemberPutFirstOnItsMeritsKeepsItsCache used "Codex at 92% of
its week" only as a way to put Codex behind the pay-as-you-go key; their
guarantees (the stand-in keeps the conversation while the first is
behind, a member put first on its merits keeps its cache) are about the
stand-in and the cache, not about weeks. Under the new rule a Smart group
spending a subscription's week before a paid key is right, so the rule
gets no exemption: the tests now put Codex behind with its 5-hour window
at 92% (a rate cap, still low) and bring it back to 10%.

New: TestGroupWeekLowIsSpentBeforeTheKey states the new rule in a group:
Codex back at 92% of its week with 5 hours to spare takes a new
conversation ahead of the key listed after it.

Run (mote-run, at 9595a503a, origin/main):
- go test -count=1 -run 'Group|WeekLow|StandIn|Backup' ./internal/gateway: ok 63.8s
- gofmt -l: clean
Broken by hand: seatTier's WeekLow clause taken out (a week at 92% is
tier 1 again) -> TestGroupWeekLowIsSpentBeforeTheKey red ("went to mimo
(first), want codex"); restored.
Not tried: the full suite (runs after this ships); real accounts.
2026-11-04 17:39:36 +08:00
yetone 9595a503a9 provider: a Claude account made first stays first when Claude Code renews its sign-in under another's profile (motui9535)
motui9535 on Discord: after making another Claude account first in
Providers, a refresh at the top of Usage turned the previous account back
into the first.

Here is how. Make first switches Claude Code to the account (say Max). A
Claude Code started on the previous account (Pro) before the switch keeps
writing Pro's profile into ~/.claude.json afterwards. While the
credentials are still the ones a saved record holds, claudeSignInOwner
names the sign-in by them (#1938, netfishx). The Usage refresh then runs
/usage in Claude Code's own config, and that renews the sign-in. The new
tokens are held by no record, so the sign-in was named after the stale
profile: Pro. rememberLogins then saved Max's renewed tokens under Pro's
record and marked Pro active. Max's record kept a dead refresh token, and
Pro's record now held Max.

The fix: the held record now keeps the profile magpie read at its last
look (HeldAs). A sign-in held by no record is the held account's own
renewal when all three of these hold:
- its profile is that same profile;
- the profile names another account;
- its plan is not another's.
A /login writes its own account's profile, so it is still the new
account's.

Tests: TestClaudeMadeFirstStaysFirstWhenRenewedUnderAnothersProfile (the
reporter's sequence, then a SwitchWhenSpent look) and
TestClaudeLoginAnewIsTheNewAccounts (a /login with a new profile, or with
another plan, is the new account's).

Run on mote:
- go test -count=1 -timeout 45m ./internal/provider ./internal/gui
  ./internal/cli: ok.
- go vet for darwin, linux and windows on ./internal/provider: ok.
- gofmt -l: clean.

Broken by hand:
- claudeRenewedHeld never applied: the first test goes red ("first is
  pro@x.com", pro holds tok-max@x.com-renewed).
- No plan guard: the "its plan" subtest goes red.

Not tried:
- The reporter's real accounts and a real Claude Code renewing its token.
  The sequence is reproduced with files in a sandbox HOME, and that Claude
  Code renews during /usage is inferred, not observed.
- A /login back to the very account the stale profile names, on the same
  plan, still reads as the held account's renewal.
2026-11-04 17:12:50 +08:00
yetone 00d8aac596 routing: Free quota by expiry spends the soonest-lapsing free quota first (wowbbs)
wowbbs (and shamen_xiaohong) keep check-in free accounts in one group:
WorkBuddy CN x2, MiniMax Code, TraeCode CN and Qoder CN. They asked that
the group spend the free quota that lapses soonest first, go on to the next
when one is used up or has lapsed, and use a paid account only when no free
quota is left.

This adds `expiring` (provider.FreeExpiring, routes.FreeExpiring). It is a
group's only, picked in the Routing page's group menu, with
`magpie group set <g> routing=expiring` or in the TUI. Nothing changes for a
group or provider that doesn't pick it. A provider keeps refusing it, as it
refuses `cheap`.

- routes: Seat.FreePlan and Strategy.ByPlan. FreeExpiring has three tiers:
  - free seats (Free, a model at no cost, or FreePlan) by Expires, the
    earliest of the window renewals and Lapse, to the hour; an unknown
    expiry goes last and ties keep their listed order;
  - then the paid seats, as Smart orders them;
  - then the spent and resting seats, by when they come back.
- provider.FreePlan reads an account's plan word: free, trial, 免费, 试用,
  体验, 體驗.
- gateway: weighRouted fills FreePlan when the strategy asks. The trace's
  Weighed rows gain `expires`, so the Routing page's story can say "its free
  quota is lost soonest, in 1d 2h". There are also lines for "a free one with
  no expiry told" and "no free quota left, so the paid one".
- GUI: an option in the group menu, the mode line, the story lines, and
  i18n in zh, zh-TW, ja and de. app.js only adds `expiring` to ROTATION,
  paid for by a shorter comment beside it, so the core is 11 bytes smaller
  than at its base.
- docs: gateway-routing.md (order of keys and accounts) and
  plugin-runtime.md (Seat and Strategies).

Plugins whose usage doesn't say when their free quota lapses got issues
rather than edits:
- magpie-community/plugins#718: Trae sums its packs; the soonest end comes
  from any pack, spent or past, and there is no runsOutAt.
- magpie-community/plugins#719: Qoder's plan is the raw userType
  personal_standard, which doesn't read as free, and its add-on, shared and
  dedicated pools have no expiry.
WorkBuddy (Free plan, resetsAt and runsOutAt) and MiniMax (Free, runsOutAt
on credits) already report what this needs.

Run, all on mote via mote-run at this tree (base 0ee424e3e):
- gofmt -l internal plugins: empty. go build ./....
- go vet of routes, gateway, provider, cli and tui; the same with
  GOOS=linux -tags nogui and with GOOS=windows.
- go test ./internal/routes ./plugins/rotation ./internal/tui: ok.
- provider -run TestFreePlan|Group|Routing: ok.
- cli -run Routing|Group: ok.
- gateway -run TestGroupSpendsFreeQuota|Wallet|Free|Cheapest|Routing|Weigh: ok.
- internal/gui -run Budget|Size: TestCoreScriptBudget is red, already red
  at the base (1,534,154 > 1,533,802, #5139). This change takes the core
  down 11 bytes and doesn't raise the budget.
- GUI, node --test in chromium and webkit, en, zh, zh-TW, ja and de, wide
  and 420px:
  - routing-free-expiring (new), routing-group-strategy, routing-cheapest-first,
    i18n-keys, builtins, group-member-free and provider-count-free: 176 of
    176 pass;
  - every routing-*.test.cjs: 2,478 of 2,520 pass. The 42 reds are in ten
    files (routing-rule-remove, rule-drag, rules-line, rule-models,
    row-swap, steady, order-unknown, steps-cap, story-shrinks and
    keys-fold). Run alone at this tree they give 27 reds, and at the base
    0ee424e3e 25, the same tests. They are filed as #5088, #4585, #3096,
    #3789, #3799, #4627, #4628 and #4629.

Again after rebasing on origin/main 0e804be29: gofmt; vet of routes,
gateway and provider; the same Go tests: ok. routing-free-expiring,
routing-group-strategy and i18n-keys: 62 of 62 pass. The core is 1,534,034
here, against main's 1,534,045.

Red on the old code: TestGroupSpendsFreeQuotaSoonestToExpireFirst at
0ee424e3e gives "pro,wb1,wb2,mm,qoder" where it wants
"mm,wb2,qoder,wb1,pro".

Broken by hand: with FreePlan never set, the gateway test gives
"pro,mm,wb2,qoder,wb1" (red). routing-free-expiring.test.cjs reads strings
that exist only with this change. routing-group-strategy's two menu counts
(11) went red with the new option, and they now count 12.

Not tried: no real account of any vendor. WorkBuddy, MiniMax, Trae and
Qoder check-in accounts were not routed live. The order was tested on
fabricated allowances shaped as their plugins report them. The full
`go test ./...` runs after the push.
2026-11-04 17:11:55 +08:00
yetone d5d48f4f9b routing: a week at 90% renewing soonest is spent before its reset, not kept for last (ysicing_01858)
ysicing_01858 on Discord (Use before expiry, three accounts): the
account at 90% of its week, renewing today, took few requests, while most
went to one renewing tomorrow. Smart and Use before expiry put every
account at 90% of any window into tier 1 ("kept for last"), behind every
one with room, so what that week had left was lost at its reset.

Now 90% means "kept for last" only for a rate cap: the five hours, or a
window that doesn't say how long it runs (Allowance.CapUsed). An account
at 90% of its week alone (Seat.WeekLow) keeps its place: by its reset
(Smart) or by share left per hour (Use before expiry). 98% of any window
still puts it last. A new conversation kept for its session may go to
such an account (readyForNew). The trace carries weekLow, so the Routing
row doesn't call it "kept for last" and doesn't dim it. Least used first,
In order and the others are unchanged. The Pace description in Settings
says so in every language.

Their later report ("90% 额度账号已经自然重置了 现在的调度机制又默认主要调度到刚重置的
账号了") is not this bug, and this change doesn't alter it. Use before
expiry orders by share left / hours to reset. A fresh week is about
0.6%/h (100/168h), so it goes ahead of any account with less than that
per hour, e.g. 30% left in six days. Conversation affinity and the
fewest-tokens tie-break, for paces within a tenth, keep it there. Smart
is the routing that goes by the soonest reset alone. Their numbers would
tell whether a pace is wrong there.

Run on mote:
- At 49d6ad779, the same tree on 0ee424e3e:
  - go test internal/routes and internal/provider: ok.
  - internal/gateway -run WeekLow|Reset|Smart|Pace|Spread|Session|
    Affinity|Weigh|Trace|Routing: ok.
  - GUI: 162 routing-*, i18n-* and gui-* files, chromium and webkit:
    2535 tests, 2500 passed, 35 failed. The 35 are in 11 files:
    routing-folder, -many-keys, -order-unknown, -row-swap, -rule-drag,
    -rule-remove, -rules-line, -sky-under, -steady, -steps-cap and
    -story-shrinks. Run again alone at 49d6ad779: 26 red. At origin/main
    0ee424e3e: 24 red, the same tests (#5088, #4585, #4627, #4628,
    #4629). mote was at load 70-200 after a reboot.
  - routing-week-low (new) passed: pace and smart, en/zh/zh-TW/ja/de,
    1100 and 420, both engines.
- Rebased on origin/main 129baeca0, which changed internal/gateway's
  resting. At d187c0c0c (this tree):
  - go vet ok; internal/routes ok; internal/gateway -run with Rest|Fail|5 added: ok (146s).
  - TestCoreScriptBudget: still red as on main (#5139). This tree's core
    is 1534033, 12 bytes under main's.
  - routing-week-low and i18n-keys: 46 of 46 ok.
- gofmt clean. go vet for darwin, linux and windows ran at 0ee424e3e.

Broken by hand:
- seatTier back to tier(s.Used): TestWeekLowKeepsItsPlace and
  TestWeekLowIsSpentBeforeItsReset red.
- readyForNew without the weekLow clause: "isn't ready for a new
  conversation" red.
- client.js's row label back to !w.routing: routing-week-low red (pace
  rows lacked "kept for last" for the 93% five-hour account).

Not tried:
- Real accounts near 90% of a week.
- Smart's own description in Settings still says 90% of any window; it
  was left as is to keep the core budget from growing.
2026-11-04 17:09:59 +08:00
yetoneandggbdpq 0e804be29b provider: requests missing together list logins once, and a plan asks OwnPaused of the held list
Every request's routing plan lists the agent's accounts (perKeyEvery
asks AlsoOn, and OwnPaused of the signed-in one), and each list took
logins.json's lock. A write in a request (a token refresh) dropped what
was held, and every request then in flight listed again, one after
another on the lock: 20 requests queued on it in #5104's dump. And
OwnPaused was never held: each ask was its own read under the lock.

heldOf now builds a missed key once a request: the first caller builds,
the others wait for it and take its value. OwnPaused goes through
heldOf under its own key, so a write lists it anew as it does Logins.

Ported from ggbdpq's ecb829370 (#5104). Changed from that patch:
- A waiter takes the build only if nothing changed while it ran: held's
  generation, filememo's generation (settings.Save tells only filememo)
  and the environment. The patch skipped heldFreshLocked on wake and
  kept a build made across a filememo write, so a later caller could get
  settings from before the save.
- A caller outside a request (no Hold) never joins a build; it builds
  fresh, as on main.
- The wait is bounded (heldWait, 5s). A stuck or panicking builder, or
  one waiting on a lock its waiter holds, can't hang the request; the
  waiter builds on its own.
- When a write came during the build, waiters go round again (up to
  heldRounds) so one of them builds and the rest wait, instead of all
  rebuilding at once.
- With heldFor 0 a waiter takes the builder's own result (it is not
  kept, so the patch's waiters found nothing and built again).
- New tests: TestHeldWaiterBuildsAgainAfterAWrite (Changed and
  filememo.Forget), TestHeldWaiterTakesTheBuild, TestHeldWaiterNeverStuck
  (stuck builder, panicking builder). providers-accounts.md says it.

Run (mote, at the pushed tree):
- The patch's two tests on main's product code: red 3 of 3 ("20 listed
  before the first was built", "OwnPaused was not listed once a
  request").
- go test -race -count=20 -cpu 1,2,8 -run 'TestHeldWaiter|
  TestLoginsMissedTogetherListedOnce|TestOwnPausedListedOnceARequest|
  TestLoginsListedOnceARequest|TestHold' ./internal/provider: ok.
- go test ./internal/provider: ok. go vet for darwin, linux, windows;
  gofmt -l clean.
- Nesting: an instrumented run of provider, gui, agent, gateway and
  profile recorded every heldOf inside another build and every heldOf
  made under a file lock. No heldOf key reaches itself (only heldFrom,
  untouched). Under logins.json.lock only "migrations" is asked, and its
  build takes no lock and asks no key; under caller-keys.json.lock the
  keys asked take logins.json.lock only. No build takes caller-keys.json
  .lock. So a waiter never holds a lock its builder needs.
- Half-written files: unchanged readers. logins.json is written through
  temp+rename, sharedLogins keeps the last good list on a bad parse,
  another process's write is seen when loginsMu is taken (Look).

Broken by hand, each red:
- No filememo check on the build: TestHeldWaiterBuildsAgainAfterAWrite
  got "before", built 0 times.
- Unbounded wait: TestHeldWaiterNeverStuck timed out at 60s.
- No take of the builder's result: TestHeldWaiterTakesTheBuild built
  again.

Not tried: a live load of parallel Claude Code requests; two magpie
processes contending for logins.json; Windows and Linux test runs (vet
only).

#5104

Co-authored-by: ggbdpq <67929842+ggbdpq@users.noreply.github.com>
2026-11-04 17:06:31 +08:00
yetone 129baeca01 gateway: the same 5xx from two accounts in one request rests neither (mycf_711)
mycf_711 on Discord: 127 of one provider's 128 503s in a day were
"AIError AI服务异常" word for word, all one agent's request with an empty
tool schema the upstream always refused. forbiddenAlike/unforbid
(plugins#243) only took plain 403s, so each such request walked every
account of the provider into backoff, and other agents' normal requests
then found every account resting.

A 500/502/503 that says nothing of why (plainUnavailable: failOther, not
overloaded, no proxy down, not codexReset, not the protection refusal, not
"did not stream", some words) now joins forbiddenAlike when:
- a second account of the same provider, model and reasoning gives it in
  the same status and words, request/trace ids left out (refusalWords);
- and the provider answered another request within answeringLately (5m,
  noted in servedCandidate as routed.answered).
Then neither rests, the first one's rest and failure count are taken back,
the other mates go last (matesLast, so a group's other members are asked
first), and the last one left isn't asked again after a moment
(sameRefusal; before, the two-account case re-sent the request 13 times).

Kept as before: one account's 503 alone rests it; 503s in other words are
each account's own; a provider that answered nothing in the last 5 minutes
may be down, and its alike 503s rest as before, so an outage is backed off
once 5 minutes have passed since its last answer. A 403 is still alike only
to a 403. Overloads keep their own short model rest.

Ran (mote, via mote-run, at this tree on 6b47bce67; after the rebase onto
186453e00, vet and TestPlain*|TestQoder* again: ok):
- TestPlain5xxOnTwoMatesRestsNeither (5 cases: alone, two alike + a third
  answers, two alike nobody left, two in other words, two alike with the
  provider down), TestPlainUnavailableWords, TestPlain403*: ok.
- go test -run "Plain|Forbid|Rest|Overload|Fallback|Group|Busy|Patience|
  Codex|Refus|Served|Unavailable|Protection" ./internal/gateway/: ok 240s.
- go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet on
  ./internal/gateway/: ok. gofmt -l: nothing.
Broken by hand, each red with a real FAIL:
- no 5xx alike (words5xx never set, the old behaviour): acct-1 rests in
  "two alike, a third answers"; "nobody left" tried acct-1,acct-2 x13.
- last one asked again (sameRefusal dropped): tried acct-1,acct-2,acct-2,
  acct-1,acct-2.
- no outage guard (answeredLately always true): "provider down" case,
  acct-1 not resting.
- words not compared: "two in other words", acct-1 not resting.
Not tried: the reporter's real provider and plugin (unknown here, no
account); a group with another provider failing over during the first 5
minutes of a real outage (matesLast covers it, not tested here); the full
./... suite before push (run after the tag, per the loop rules). In the
first 5 minutes of a real outage alike 503s no longer rest, so each
request asks two accounts before moving on; a gateway whose only traffic
is the refused request still rests as before (no answer lately).
2026-11-04 16:59:02 +08:00
yetone 186453e009 provider: a plan key's card says when it was read (jiabubu)
jiabubu (Discord #feedback): on Usage -> Overview the Kimi Code card
showed no "Updated ..." line while every other provider's card did.
The GUI's readWhen shows it only when a quota carries readAt, and
PlanQuotas' key plan cards (Kimi Code, OpenCode Go, GLM Coding Plan,
MiniMax, Ollama, Command Code) and StepFun's, Volcengine's and
Tencent's never set it. Each now goes through readNow, which stamps
a reading that worked and has windows or a balance, as the other
subscriptions' cards already did. A failed read is left alone.

Test: TestPlanKeyCardSaysWhenRead (sandbox HOME, a fake Kimi
/coding/v1/usages, a kimi-code-cn key) wants the card's ReadAt between
the call's start and end.

Run on mote at this tree:
- go vet ./internal/provider: darwin, GOOS=linux -tags nogui, windows
- go test ./internal/provider: ok (184s)
- go test -run 'Quota|Usage|Plan|Balance' ./internal/gui ./internal/cli: ok
- gofmt -l: clean
Broken by hand: without readNow on the plan path the test is red
("readAt <nil>, asOf <nil>"); green with it.

Not tried: a real Kimi Code key; no GUI test, since the page already
draws readAt when the API gives it and the omission was the API's;
Windows/Linux runs.
2026-11-04 16:55:33 +08:00
yetone 17154e1654 provider: a Claude account not used in five hours shows its 5-hour window unused, not missing (motui9535)
motui9535 (Discord #feedback, v0.1.2909, screenshot): of three Team
accounts the preferred one showed 7 days 17% and 7 days · Fable 30% and
no 5-hour window; the two others showed all three. Anthropic leaves a
window out (null) while it hasn't started (claudeWindowsExpected says as
much for the warm-up), so Claude Code's /usage has no "Current session"
line for an account nobody used in the last five hours, and the card
took the missing line as no window at all. The aggregate's 5 hours
(100%) then averaged only the two other accounts.

A whole /usage reading (claudeWindows, the one place the active and the
saved accounts' readings are kept) now gets the 5-hour window it leaves
out as not started: 0% used, no reset, first, as Claude Code orders
them (claudeKindOrder, taken out of NoteClaudeLimits). A header heard
later replaces it as before. Only the 5-hour window: a reading that
tells any window tells the week. parseClaudeUsage is unchanged
(TestClaudeUsageWeeklyOnly still holds that the parser makes none up);
TestClaudeSwitchWeeklyOnly's card now has the unstarted 5-hour window.

Run (mote, at this tree):
- go test ./internal/provider: ok (132.9s)
- go test -run 'Claude|Usage|Quota' ./internal/gateway ./internal/cli ./internal/gui: ok
- go vet ./internal/provider on darwin, linux (-tags nogui), windows; gofmt -l clean
Broken by hand: without the claudeWithUnstarted call,
TestClaudeUnstartedSessionShownUnused is red: windows ["7 days" "7 days
· Fable"], motui's shape.
Not tried: a real Claude account's /usage with an unstarted session (the
null comes from claudeWindowsExpected's note and the screenshot); no GUI
test, the cards draw every window /api/usage/quotas gives and the change
is in what it gives; Windows/Linux runs.
2026-11-04 16:47:45 +08:00
yetone f8987ce617 gateway: Qoder 1.1.82's requests find their session in Qoder's own files
qodercli/qoderclicn 1.1.82 (11-03) stopped sending session-id to a
provider of the user's own, and nothing else in a request names the
session (coderlee233 on Discord). Its requests were recorded with no
session: the Sessions page lost the conversation's title and showed each
title and suggestion side call as a row of its own.

A request from Qoder or Qoder CN (by its agent token) on this computer
that names no session is now matched against Qoder's session files
(sessions.QoderDir/projects/<project>/<id>.jsonl and its subagents'
files): the session whose typed prompts (user lines with humanInput /
origin.kind human) appear most in the request's user text wins, the file
written last on a tie. Qoder's <system-reminder> blocks are left out. A
side call (no tools) no file matches yet is held up to 600ms, since the
first title is asked ~0.1s before Qoder writes the file. The id found
goes on the request as session-id, the header 1.1.81 sent, so it is
grouped and titled as before. A request that names a session (older
Qoder's session-id, X-Magpie-Session) is left as it came. Files are read
incrementally; a half-written last line waits for the next read.

Run (on mote, rebased on origin/main 6b47bce67):
- go test -run TestQoder ./internal/gateway: ok. Fixtures are the literal
  bodies and headers qodercli 1.1.82 sent to a capture server, and its
  own session files, from a sandbox HOME (headless turns, a subagent, a
  second headless session, interactive turns, first title, later title,
  transcript title, suggestion).
- go test -timeout 45m ./internal/gateway and the full suite run after
  the push (mote at load 200 from another suite); a red is filed.
- gofmt -l; GOOS=linux and GOOS=windows go vet ./internal/gateway: clean.
Broken by hand, each red: no qoderSession call in handle; no
named-session guard; no agent check; subagent files not read; array
content not read; no wait for side calls; no newest-file tie-break; a
half-written line taken.

Not tried: the reporter's own account or a real model (fake upstream
only); Qoder in WSL (its files are in the WSL home, not found from the
Windows magpie); a keyed or MAGPIE_ADDR gateway on another machine (not
matched by design). The in-flight Active session (status bar) is not
fed from this. A large session file is read whole once per process.
2026-11-04 16:45:47 +08:00
yetone 6b47bce670 cli: magpie model compact <agent> sets an agent's own Long conversations
3eb2bda4f added POST /api/settings/agent-compact with no command, and
internal/cli's TestEveryRouteHasACommandOrIsNamed went red in the full
suite run after the push (settings_parity_test.go:437). Rather than
park the route in notYet, the command it names is here:

  magpie model compact <codex|claude|grok>            says the agent's
  magpie model compact <agent> every|off|<size>       sets it

every takes the agent's own away (it follows the value for every
agent), off is Full window, a size such as 300k compacts there; another
word is refused and nothing is written. A first word that isn't one of
settings.CompactAgents goes to the command as before (on|off|<size>).
cliForRoute names it; the usage text and agent-wiring.md say it.

Run at this tree (3eb2bda4f + this), on mote: go vet ./internal/cli,
GOOS=windows go vet ./internal/cli, go test ./internal/cli: ok.
TestModelCompactAgentCmd broken by hand (the command setting the shared
value instead): red, "codex 300000, claude 300000".
Not tried: the command against a real agent's files (catalog.Changed is
nil in the test, as in TestModelCompactCmd).
2026-11-04 16:35:16 +08:00
yetone 2ba044aa66 gui: the Mac panel's page is told when Wails hides it, so it follows Settings' units (blrbrzkj)
blrbrzkj on Discord: Settings said ¥ 人民币 and 中文(万 / 亿), while the
tray panel's Usage tab still showed ≈$7.18 and 16M.

On the Mac a page in an ordered-out window keeps drawing, so magpie tells
it when it is hidden (hideWebview) and shown (showWebview), and the page
reloads its state, settings included, on the shown signal. The panel is
mostly closed by a click elsewhere, which Wails' HideOnFocusLost does
with a plain Hide, and by Escape (HideOnEscape), likewise. The page was
never told it was hidden there, so the shown signal was a no-op
(magpieWindowVisibility returns early when it was never told otherwise),
and the panel kept the currency and number units it was first drawn
with until magpie restarted.

sayWailsHides (windowvisibility.go), on the panel: on the Mac the page is
told on WindowLostFocus, as hideWebview tells it, and Escape hides the
panel through hideWebview. Other systems are unchanged: WebView2 and
WebKitGTK mark a hidden window's page hidden themselves.

Tests:
- TestPanelHiddenByWailsMarksPageOutOfSight (AppKit, darwin): makes the
  real panel (h.makePanel), closes it by a WindowLostFocus event and by
  the Escape key binding, as Wails does, shows it with showWebview, and
  checks the page saw itself hidden and marked. The probe page now
  reports what it saw when it is told it is shown, so a native hidden
  event before the told one can't be the record it sends.
- panel-units-follow.test.cjs: the page half. A panel open on its Usage
  tab in $ and K/M; Settings picks ¥ and 万 / 亿; hidden and shown, the
  panel re-reads the state and shows ≈¥185, 15.4 亿 (億 in zh-TW) and a
  万 axis, then back to ≈$26.40 and 1.54B. zh, en, zh-TW, ja, de;
  Chromium and WebKit.

Run on mote (macOS 27.2), at this tree:
- go test -run 'TestClosingWindowMarksPageOutOfSight|TestPanelHiddenByWailsMarksPageOutOfSight' ./internal/gui/: ok
- go vet ./internal/gui/, GOOS=linux go vet -tags nogui, GOOS=windows go vet: ok; gofmt -l: nothing
- node --test panel-units-follow, window-visibility, number-units: 20/20

Broken by hand:
- sayWailsHides(w) not called: the AppKit test times out with no hidden
  report.
- only its Escape binding removed: red, "hidden=true marked=false
  play=running".
- the page's visibilitychange without loadBack (a copy of the assets):
  panel-units-follow red, "shown again, the panel reads the state again".
- The panel test written to show without a told hide (the old Mac path)
  was 0/12 on the unchanged page, which is how the cause was found.

Not tried: the real tray panel by hand on a Mac (the AppKit test makes
the real panel window but no status item); blrbrzkj's system isn't
known, and on Windows and Linux the page is marked hidden by the webview
itself, so this changes nothing there.
2026-11-04 16:32:55 +08:00
yetone 75e30625f5 plugin: a command that serves no pages moves a page's service off the app's port (#5187)
MYCF711 (#5187, Windows, 0.1.2901): magpie plugin update run while the
app runs hung with no output. Its host loads every plugin, and
page-chat's service waits for port 3477, which the app's host holds:
each CLI command that starts a host waited ~6s on it, then kept trying
the port every second in the background, so it could take 3477 from
the app's host when that restarted after the update.

Now magpie run with a command that serves no pages (anything but the
app, tray, tui, web, serve, a bare magpie or a magpie: link opened in
the app; servesPages) sets plugin.ServePages(false), and its host hands
a plugin whose magpie.page.service names an option a free port of its
own in that option (hostOptions). The plugin's other parts load at once
and the app's port is left alone. plugins.json is not changed, and a
service no option moves is started as before. The class, not
page-chat: any plugin page service declared with an option.

Run, at base 0ee424e3e plus this change:
- mote: go vet ./internal/plugin ./internal/cli (darwin), GOOS=linux go
  vet -tags nogui and GOOS=windows go vet of both, GOOS=linux nogui and
  GOOS=windows builds, go test -count=1 ./internal/plugin ./internal/cli:
  ok (280s, 65s). gofmt -l clean.
- Broken by hand: hostOptions handing options unchanged makes
  TestHostServingNoPagesLeavesHeldPort red (the load "didn't finish in
  10s") and TestHostOptionsMoveOnlyTheService red; servesPages returning
  true makes TestServesPages red on daemon, autostart, providers.
- Windows (xiaomi-gpu, win-run): the new tests and TestServesPages ok.
  Sandbox with page-chat and the reporter's git plugin
  (KevinFX-code/magpie-wps-lingxi), nogui builds:
  - 3477 held by bun, magpie plugin update: 13.9s before (page-chat
    "被占着" then "每秒试一次"), 10.6s after (page-chat "listening on
    127.0.0.1:51493").
  - beside magpie serve's host on 3477: 13.98s before, 12.4s after;
    serve's host keeps 3477.

Not tried / not reproduced: the reporter's literal no-output hang. Before
this change, update finished on 0.1.2909 in every setup tried (nogui
CLI with 3477 held, beside nogui serve, beside the release GUI exe in
the interactive session: 6-20s), so this removes the wait and the
port contention seen, not a hang reproduced. Not tried on Linux or the
macOS app.
2026-11-04 16:25:02 +08:00
yetoneandchiperman 95a0ee1b9e providers: a long model id no longer squeezes its name field away in Names, prices & levels (#5170, chiperman)
chiperman's case: beside deepseek-v4-1-flash-economy-20261017 the
model's display-name field shrank to ~20px at 900px wide (77-94px at
400px), too small to click. The field could shrink to nothing
(min-width: 0) while the id beside it kept its whole width.

The field now keeps a 96px floor. It still fills only the room the id
leaves (flex: 1, basis 0, up to 220px), so a long id gives way after the
field reaches 96px and ends in an ellipsis. A short id is shown whole as
before.

Ported from chiperman's 8691d31 (issue thread; PRs are
collaborators-only), with one change. Their `flex: 0 1 220px` made the
field and the id shrink together, so a short id that fit was cut:
"example" went 48 -> 41px at 1100px in WebKit, and readable-focus's
"selecting a model ID" went red in WebKit (selection ran past the cut
id). Only the min-width is raised here. Their regression test is kept
(the reporter's id in provider-same-as at 900px). Added: one test per
engine, at 400/900/1440px in en, zh, zh-TW, ja and de. It checks the
field is >= 96px, the id is beside it, inside the row and ellipsized,
and that a short id is shown whole.

Run on mote (macOS 27, Playwright 1.62.0, chromium + webkit), at
0ee424e3e plus this change:
- provider-same-as + readable-focus, concurrency 1: 14/14 ok.
- Broken by hand, same files: old CSS -> 6 red ("a long model ID must
  not squeeze its name field away"; "en at 400px: the name field is
  77.203125px wide" in WebKit). chiperman's CSS -> 4 red ("en at 900px:
  a short id is shown whole" in both engines, readable-focus WebKit).
- Every GUI file that reaches the Names editor (21 files) plus gui-zh-tw,
  gui-ja, gui-de and i18n-keys: 320/325. The 5 reds are on origin/main
  0ee424e3e too, run the same way (2 of 2 runs each):
  models-select-all-api "Select all leaves the models..." (flaky at
  420/1100, #4389) and provider-levels-scroll WebKit (#4395).
After rebasing onto origin/main 3eb2bda4f (a Settings change only):
provider-same-as + readable-focus again at this commit, 14/14 ok.

Not tried: the whole GUI suite, the native macOS/Windows/Linux windows
(only Playwright's engines), Go tests (no Go or app.js change;
TestCoreScriptBudget covers app.js, which is unchanged).

Co-authored-by: chiperman <34889778+chiperman@users.noreply.github.com>
2026-11-04 16:22:34 +08:00
yetone 3eb2bda4f2 settings: Codex, Claude Code and Grok Build each take a Long conversations of their own (molianyin4227 on Discord)
molianyin4227 (Discord #help): models differ, so one compaction size
for every agent fits none; they asked for Codex, Claude Code and Grok
Build to each have their own, falling back to the shared one.

- settings.AgentCompacts[agent] {At, Full} for the agents that write a
  compaction window (CompactAgents: codex, claude, grok); Settings.
  ForAgent(agent) lays it over CompactAt/FullContext for that agent's
  readers only: codexcat.entriesAt, provider codexListed, Claude Code's
  writeCompact and desktopPlan, grokModelTables, the route list's
  buildModels, Codex's window line (api.go) and Tuned for you
  (gui/tune.go, agent/tune.go). A model's or provider's own Compact at
  still comes first. An agent with none follows the shared value, so
  nothing new is written for it, and an agent outside the three has no
  such key and is refused (provider.SetAgentCompact).
- POST /api/settings/agent-compact {agent, own, full, at}; own false
  takes the agent's value away. settingsapi.Merge keeps the map.
- GUI: a row "Long conversations in <agent>" under Long conversations,
  in the agent's opened row and its sheet: Every agent / Compact at N /
  Full window (segs, no select), a size box when Compact at. It lives in
  agentcompact.js, imported when the agent's settings hold Long
  conversations, then put in synchronously (an async put-in after a
  redraw moved the page in chromium: codex-memories-settings' scroll
  check). It draws again only when its own values change. i18n in
  zh, zh-TW, ja, de.
- Tuned for you's Use on an agent with its own value changes that one,
  stashed under tune.long.compact.<agent>; Undo puts it back.
- codex-memories-settings' "no Codex" check counts Long conversations
  alone again (:not(.agent-compact)) and waits for the new row.
- docs/subsystems/agent-wiring.md: a row for it.

Core size: app.js 1,311,919 bytes, 109 under origin/main 0ee424e3e
(1,312,028): the two calls are paid for by four comments cut. The core
total is 1,534,045, still over its budget as on main (#5139), 109 less
than main's 1,534,154. No budget raised.

Run at this tree (based on origin/main 0ee424e3e, fetched just before
the commit), all on mote via mote-run:
- go test settings, settingsapi, codexcat; provider/agent/gui with
  -run "Compact|Tune|Grok|SettingsSave|CodexWindow|Long": ok.
- New tests broken by hand, each red: ForAgent taken out of codexcat
  (TestCodexCatalogCompactAt), grok.go (TestGrokWindowFollowsLong
  Conversations), claude.go (TestClaudeCompactAt); tune's per-agent key
  turned off (TestTuneAgentOwnLong: "after apply: codex {At:0
  Full:true}"); the row's import call taken out of app.js
  (agent-compact.test.cjs 4 of 4 red in chromium).
- GUI, chromium + webkit (en/zh/zh-TW/ja/de as each file has, narrow
  and wide): agent-compact, agent-prefs, compact-at, compact-one-value,
  settings-general, codex-async-compact, codex-compact-held,
  codex-memories-settings, context-tune, segs-glide, i18n-keys,
  old-webkit: 432 of 432 ok.
- gofmt -l clean; go vet darwin and GOOS=windows on mote, linux with
  -tags gtk3 on magpie-desktop (wsl-run): ok.
- TestCoreScriptBudget: red, 1,534,045 > 1,533,802, as on main (#5139),
  109 bytes lower than main.

Not tried: real Codex, Claude Code or Grok Build reading the values
(the config writers are unit-tested); the full go test ./... (after
the push). `magpie model compact` has no per-agent flag, and t3code's
route list reads the shared value.
2026-11-04 16:17:47 +08:00
yetone 0ee424e3ee codex: a thread Codex 0.166 won't resume for its provider moves with Codex (毅, AcMilan on Discord)
Codex 0.166 (openai/codex#57840) refuses to resume a thread whose saved
provider isn't the configured one: "This chat uses openai, but your
current provider is magpie. Switch to openai to continue." (毅), and
"This chat uses cc-switch-official, but your current provider is
openai" (AcMilan). The rollout's session_meta provider wins over the
state DB row, and no -c override gets past it (openai/codex#58865).

Cause on magpie's side: bringOver relabelled only plain rollouts in
place. A thread Codex had packed to .jsonl.zst (a week after its last
turn) stayed on openai, so with magpie as provider it can't resume.
cc-switch-official is the id CC Switch 3.17-3.20 gave the official
account; CC Switch 4 moves those threads back to openai itself (#7948
there), but a user who left CC Switch keeps them stranded.

- sessions.MovePackedCodexThreads: packed threads on `from` updated in
  the last 30 days, newest first, up to 128 MB per sync, each moved by
  the existing packed rewrite with its copy kept in the trash. Rows
  are checked against the file (plain absent, .zst present, meta on
  `from`, same home). A state DB without updated_at moves nothing.
- bringOver calls it after RelabelCodexThreads; bringBack already
  moves packed threads back.
- bringOfficial: while magpie wires Codex and Codex is on openai or
  magpie, cc-switch-official threads move there, unless the user's
  top-level model_provider or a profile names cc-switch-official.
- Other providers and packed threads older than 30 days are left; the
  Sessions page's Move or Resume takes them.

Run (mote, at the pushed base c7bbd3faf):
- gofmt -l clean; go vet darwin, GOOS=linux, GOOS=windows on
  internal/agent and internal/sessions: ok.
- go test ./internal/agent ./internal/sessions: ok.
- Real codex-cli 0.166.0 app-server in a sandbox CODEX_HOME with a
  fake Responses server: an openai thread packed, Codex on magpie,
  thread/resume gave 毅's error word for word; RelabelCodexThreads
  alone left it; after MovePackedCodexThreads the resume said
  provider magpie and a turn started. A cc-switch-official thread with
  Codex on openai gave AcMilan's error; after the move it resumed on
  openai and a turn started.

Broken by hand (each red, then restored):
- budget check off: TestMovePackedCodexThreads red (both moved).
- the packed call in bringOver removed: TestCodexThreadsFollowMagpieIn
  red (packed thread stayed on openai).
- defer bringOfficial removed: TestCodexMovesCCSwitchOfficialThreads red.

Not tried: the Codex App GUI itself; agent Sync against a real Codex
(unit tests only); Windows and Linux runs; threads on other provider
ids, which 0.166 also refuses (left to the Sessions page).
2026-11-04 15:12:08 +08:00
yetone c7bbd3faf6 routing: a Claude joined over the network shows its windows in Accounts and keys (yi_time on Discord)
A remote magpie's provider row on the Routing page showed no usage, while
the subscriptions above it did. The remote's cards already reach the
window as /api/usage/quotas entries with `from` set (provider =
<remote id>/<card provider>), but the page's cardOf/winsOf match only
kind "account" with no `from`. remoteWinsOf (plugins/routing/client.js)
now draws those windows on a remote-magpie row: a claude-* model row
gets the remote's claude cards, gpt/codex/o\d rows its codex cards, each
window prefixed by the user when several cards match. When the remote's
read failed it says "Allowance unavailable — hover for why" with the
error as the title (existing string, all languages), never 0. The usage
comes from the machine that owns the account; no gateway change.

Run (mote, no Go change):
- routing-remote-windows.test.cjs (new; 5 languages, widths 1100 and 420,
  chromium and webkit) and routing-account-windows.test.cjs at ec697e692
  on origin/main 07f02d0d9..: 44 pass, 0 fail.
- Broken by hand: render call removed, and the model-family filter
  removed; each took the new test to 0 pass, 11 fail.
- Full go test -timeout 45m ./... at ea1aab179 (same client.js, rebased on
  f177c36a9): 86 ok, 2 red, neither from this change: TestCoreScriptBudget
  (1534154 > 1533802 at origin/main too, #5139) and
  TestMainWindowCorners/macOS_26_SDK (#3949).
- Six routing GUI files, serial, on origin/main cd83c3147 with no change:
  85 pass, 19 fail (rule-remove #3096, rule-drag #3789, row-swap #3799,
  order-unknown #4627, rules-line #3593; commented there). On this change
  27 and 28 fail; routing-rules-line alone 6 and 7 of 20 against 4 of 20
  on main, all the same 5s waitForFunction on .rt-gedit with the failing
  cells changing between runs. I judge it the same flake; not proven.
- The full GUI suite was started and killed after ~3h unfinished; its
  reds were in unrelated files (account-eye passes 15/15 alone).

Not tried: a real two-machine LAN run, a real Claude account on a remote,
Windows or Linux GUI engines (WebKitGTK).
2026-11-04 14:59:26 +08:00
yetone 07f02d0d96 provider: moved Zed users get opencode-zed-auth 0.1.17, which drops a thinking display Zed refuses (plugins#708)
Claude Code sends thinking.display "updates" for its newest models, and
Zed's cloud accepts only "omitted" or "summarized", so it answered 400.
@magpie-community/opencode-zed-auth 0.1.17 (plugins commit aa44cc3e)
sends "highlights" as summarized and drops any value Zed doesn't know.
Raising the Zed mover's min from 0.1.15 to 0.1.17 lets keepMovedCurrent
update every moved user's plugin.

Run:
- npm view --prefer-online --registry https://registry.npmjs.org
  @magpie-community/opencode-zed-auth@0.1.17 version: 0.1.17.
- mote-run -C <worktree> go test -count=1 -timeout 45m ./internal/provider/
  at f0b99745e plus this change: ok (132.9s).
- gofmt -l internal/provider/: prints nothing.
- grep: no test pins Zed's min, and no other "0.1.15" sits next to zed.

Not run: the full suite, the cross-OS vet/build (a string-literal change
in one file), and a real Zed account through the new plugin version; the
plugin's own fix was tested in the plugins repo.
2026-11-04 14:56:16 +08:00
yetone f0b99745ed provider: a Codex account is held on allowed false alone, as the 26.1029 app's Send gate reads it (xiaoq6285)
xiaoq6285 (Discord, Codex App 26.1029 on Windows, Plus, model_provider =
"magpie", requires_openai_auth = true) answered 40cfd32b0: "但是5小时也得算的
我就是5小时用完了 周额度还有" - their 5h window was used up with the week
open, and Send was grey.

What the app greys Send on, read from the bundles:
- ChatGPT.app 26.1029.61003 (the macOS build of the reporter's version,
  from persistent.oaistatic.com/codex-app-prod/appcast.xml), async chunk
  "a6kU": the composer gate returns open unless
  "n.rate_limit?.allowed!==!1" fails, i.e. it greys only on allowed
  false (then lets credits and a workspace within its overage through, and
  a window redeemed with a reset). The composer's sendBlocked is that gate
  or a model-scoped additional_rate_limits entry for the selected model.
- OpenAI.Codex 26.1027.3384 on the Windows box (app-primary lV,
  composer-content TN) and ChatGPT.app 26.1021: the same.
- The app keeps a window of an allowed account at 1% or more left
  ("Math.max(100-e,+(!0===t))"), so allowed true with 100% reads as room.

What the backend says at a used-up 5h window: the real Team reply in
testdata (codex_usage_team_spend_cap.json) has 5h at 100%, the week at
63%, and allowed false, limit_reached true.

So the reporter's case is allowed false, which codexHeld held before
40cfd32b0 and still does; no 5h rule is needed. 40cfd32b0's two new
held cases (allowed not said with limit_reached or a window at 100%;
allowed true with every window at 100%) are readings the app still sends
for, so holding them only took the app out of ChatGPT (#996) for nothing.
codexAtLimit is allowed false again. A new subcase pins the reporter's
shape (Plus, 5h at 100%, week open, allowed false, no credits: held).

Why Send stayed grey with requires_openai_auth still written is not
explained by the rule: with allowed false and no credits magpie holds
it. Left open: their reading, their magpie log, and whether a
model-scoped limit (additional_rate_limits, which magpie doesn't read)
was what greyed it.

Run on mote: go test -count=1 -timeout 45m ./internal/provider
./internal/agent ok (172s, 334s); go vet ./internal/provider native, GOOS=windows
and GOOS=linux ok; gofmt -l clean. Broken by hand: with origin/main's
subscription_usage.go and these tests, TestCodexUsedUpIsWhatTheAppHolds
fails on "limit reached, allowed not said", "window at 100%, allowed not
said" and "every window at 100% but allowed" (CodexUsedUp = true, want
false).
Not tried: the real 26.1029 app with a used-up account, a real Plus
/wham/usage reading at a used-up 5h window (the Team one is the only real
one), a Windows run.
2026-11-04 14:38:48 +08:00
yetone f177c36a9b provider: routed Until used up, Codex's sign-in stays on the account the requests went on to
WalterAIBuilder on X (11-04): two Codex accounts, A (Team, first) and B
(Plus), routed Until used up, affinity auto, stop at cap on. A used up
its 5h window (98% cap). Codex was signed in to B, then signed back in
to A once A had room, while B's week kept being spent until it was at
100%.

Cause: returnsToFirst (internal/provider/codex_switch.go) sent Codex's
sign-in back to the first account for every routing but Claude's and a
switch-only Codex's. Routed Until used up, the gateway keeps requests on
the account it moved to (routes.Drain, internal/routes/strategies.go),
and auto affinity keeps a conversation on whoever answered last while
the cache is warm (chatGPTCold, internal/gateway/affinity.go). So Codex
and the accounts list showed A in use, with B marked to go back from,
while requests through magpie stayed on B. The GUI note under Routing
also promised "back to the first" for drain. This is the hxy920830 rule
("not use one up, then the next") missing its Drain sibling.

Now, routed Until used up, Codex's sign-in stays on the account it moved
to till that one is used up too, the same as the requests. In order and
Smart still go back to the first. The Routing note has its own drain
text in en, zh, zh-TW, ja and de. The subsystem page says so.

Old data: a user signed back in to the first stays there. A user with a
return still pending stays on the next account until it is used up, and
the "First again" mark goes away.

Not changed (filing is the reviewer's call): a provider's own accounts
have no back-to-first under auto affinity (backToFirst and
backFromStandIn apply to groups only, inOrder := isGroup && ... in
internal/gateway/gateway.go). Routed In order, a conversation that moved
to the second account stays there after the first renews, for as long as
its cache is warm.

Run on mote (mote-run), at base 5957223d8 plus this change:
- go test ./internal/provider -count=1 -timeout 45m: ok (193.7s)
- GOOS=linux and GOOS=windows go vet ./internal/provider: ok; gofmt -l:
  clean
- node --test --test-concurrency=1 on the GUI tests account-return,
  keep-login, i18n-keys and routing-drain: 64 of 64 pass
Broken by hand: with "&& p.Routing != Drain" removed from
returnsToFirst, TestCodexDrainSignInStaysOnTheNext/drain fails ("first
marked to go back to: true, want false") and /order passes.
Not tried: real accounts; the whole GUI suite; Windows and Linux GUI; an
end-to-end gateway drain run together with a sign-in switch.
origin/main has since moved to d3c544ddf (3 commits); none of them
touch these files.
2026-11-04 14:28:02 +08:00
yetone d3c544ddf4 claude: a replayed transcript marks no earlier turn as the one to answer
The interactive mode gives a conversation no run has to a new Claude
Code as its own transcript (replaySession): a user line with the
messages before the last reply, the reply as the assistant line, and
the turn after it typed. The user line was rendered with
renderClaudePrompt, which ran historyEnd again on the cut messages, so
for U0 A0 U1 A1 U2 it was history(U0, A0) + <current_turn>U1, "the turn
to answer now", followed by A1, then U2 typed. U1 was answered already;
the reporter saw the model answer an old question again, and say
earlier tool calls had no results (愛睏柴犬阿茶 on Discord #feedback,
with the analysis and the fix suggested).

renderClaudePrompt is now renderClaudePromptAt(req, historyEnd(...));
replaySession calls it with the split at the end, which tells every
message before the reply inside <conversation_history> and closes it
there, with no <current_turn>. Every other render is unchanged.

Siblings: historyEnd has two callers, replaySession (whose own split,
on the whole request, is right: the reply and the turn typed after it)
and renderClaudePrompt. replaySession is the only place that renders a
cut slice of the messages (grep 'Messages = .*Messages\[:').
renderClaudeTurn (the typed turn) has no history marks.

Run (on mote, mote-run):
- go test ./internal/gateway -run TestClaudeTUIReplayMarksNoEarlierTurnCurrent:
  red on the old code (all 5 subtests: two turns, three turns, tool
  results in both turns, tool results only before the reply, the
  client's calls after the reply), green with the fix.
- Broken by hand: put renderClaudePrompt(&before) back in replaySession,
  the new test went red; restored.
- go vet ./internal/gateway, GOOS=linux and GOOS=windows go vet: ok.
- go test ./internal/gateway -run 'Claude|Replay|Prompt|Turn': ok 124.6s.
- go test ./internal/gateway -run 'Loop|Guard|Doc': ok.
- gofmt -l internal/: clean.

Not tried: a real Claude Code resumed on such a transcript with a real
account (the change to what the model sees was checked in the
transcript file only); the full suite runs after the tag.
2026-11-04 14:26:27 +08:00
yetone 1987fe220c agent restart: a script run on the app's own executable is not the app (WorkBuddy's sidecar)
Northes (Discord #feedback, 11-04): WorkBuddy's Agents row kept "重启
WorkBuddy 后生效" after they quit and reopened it, and its Restart quit
WorkBuddy and never opened it again. #3700 (Raters0) is the second half on
WorkBuddy AI.

Cause, from WorkBuddy 5.5.6's app.asar (read only) and its processes on the
Windows box: WorkBuddy starts a sidecar as `<its own executable>
.../app.asar/main/sidecar-entry.js --token ...` (ELECTRON_RUN_AS_NODE,
detached). The sidecar outlives the app's quit and the next start reuses
it, and its prewarm and `--serve` CLIs run as `<executable>
.../cli/bin/codebuddy ...`. The daemon is `WorkBuddy.exe ...
daemon-app-server-entry.js --stdio`. All of them match the running check's
`Contents/MacOS/<exe>` pattern (and WorkBuddy.exe's image on Windows), so:
- (a) findRestartable took the oldest match, the sidecar, as the app's
  start, so magpie's change was always "after" it and the row never
  cleared, however often the app restarted. On Windows the earliest start
  was used too.
- (b) reopenBundle waited for every process under Contents/ to end; the
  sidecar never does, so after 30s it said "still open" and never ran
  `open`.

Fix: runsScript(cmd, exe) tells a script run on the app's executable (a
.js/.cjs/.mjs argument, or a first non-flag argument that is an absolute
path) from the app itself and its helpers (--type=..., /prefetch:,
-psn_, a deep link). The macOS running check and the reopen's wait skip
such processes (appProcs), and the Windows check reads each process's
command line (proc.CommandLine, new) and skips them too. The reopen still
waits for real helpers (renderer, GPU). This is shared by every restartable
app: Claude desktop, WorkBuddy, WorkBuddy AI and the Codex app.

Tests (red on the old code: a copy of the base with runsScript returning
false failed all three, since = the sidecar's 2h, the Windows since the
sidecar's, and 6 RunsScript rows):
- TestWorkBuddySidecarOutlivesQuitOnMac (WorkBuddy and WorkBuddy AI, a
  space in the bundle): a 2h-old sidecar and prewarm beside the app; the
  row is behind by the app's start, a manual reopen clears it, the
  sidecar alone is not "running", Restart quits then opens.
- TestWorkBuddySidecarOutlivesQuitOnWindows: same, and Restart closes and
  ends only the app's tree, then opens it.
- TestRunsScript: real Windows command lines from WorkBuddy on the box,
  macOS ones, and #3700's `codebuddy --serve` line.

Run at this head (rebased on d6d3e6cc8):
- mote: gofmt -l clean; GOOS=windows, linux and darwin go vet
  ./internal/agent ./internal/proc; go test -count=1 ./internal/agent
  ./internal/proc ok.
- xiaomi-gpu (win-run): go test ./internal/agent ./internal/proc -run
  'Restart|Sidecar|RunsScript|WorkBuddy|List': the new tests pass; red are
  TestWorkBuddyRestartOnMac and TestWorkBuddyOwnSaveAfterStartIsNoChange/
  darwin (red the same at origin/main d6d3e6cc8, #4115) and
  TestWithViaKeepsTheJoinedList (#4786). The new mac test skips on Windows
  for #4115's reason.
- Real processes, uncommitted tests: on mote a fake "WorkBuddy AI.app"
  (Go sleeper as Electron) with a sidecar started first, through real
  pgrep and sysctl: since is the app's (0.66s), the sidecar alone is not
  running. On xiaomi-gpu a fake WorkBuddy.exe sidecar and app:
  readWinProc's command lines are the real ones and runsScript tells
  them apart.

Not tried: the real WorkBuddy or WorkBuddy AI (not run, ~/.workbuddy not
touched); a real Restart end to end through osascript/open or on Windows
(the quit/open steps are faked); Linux (no restartable app there).

Refs #3700
2026-11-04 14:25:43 +08:00
yetone d6d3e6cc82 provider: Devin's mover min is 0.1.36, which sends another model its earlier reasoning (plugins #703)
devin 0.1.36 (plugins 1a342edf) sends swe-2 and the other models that
aren't Claude their earlier turns' reasoning back as unsigned thinking
(field 11), from chat's reasoning_content, OpenCode 2's reasoning parts
and Messages thinking blocks. Claude still gets only signed thinking
(#665). keepMovedCurrent brings every moved Devin user up to it.

npm view --prefer-online showed 0.1.36 before this change.

Run: gofmt -l internal/provider (clean); on mote, go vet
./internal/provider and go test -timeout 30m ./internal/provider (ok,
229s) at 83bdfe70d plus this change. The plugin's own tests are in the
plugins commit: 208 pass in packages/devin, 7 red with the old index.mjs.
Not tried: a real Devin account through the plugin.
2026-11-04 14:05:05 +08:00
yetone 5957223d89 library: a project's skills can be given to DeepSeek Harness, in the project's .agents/skills
xingchen_c on Discord (#general, 11-04): "资源库按照项目配置能否支持一下dsh".
projectSkillsDirs left dsh out, its comment saying it reads no project
folder magpie can rely on. It does, and always has: the skill provider
every dsh profile mounts (dsh-base's cordis.patch.yml, id skill-filesystem)
scans <projectRoot>/.dsh/skills (rank 100) and <projectRoot>/.agents/skills
(rank 200), the project root being the nearest folder up from the
session's cwd with a .git, else the cwd (roots and findProjectRoot in
@deepseek-ai/dsh-skill-filesystem 0.2.1-rc.5; the same two joins in
0.0.1-rc.3, 0.1.0-rc.6, 0.1.5-rc.3, 0.1.7-rc.2, 0.2.0-rc.2, 0.2.1-rc.1
and 0.2.2-alpha.3). dsh now gets the shared .agents/skills, so the
project row lists it and one link serves it with Codex and the rest.

MCP stays as it was: dsh's servers are dsh-mcp-client rows in a
profile's patch layers (bundles, the profile's and $DSH_HOME's
cordis.patch.yml, --patch overlays; composeProfile in @deepseek-ai/dsh
0.2.1-rc.5), none of them the project's. Said in project_mcp.go and
docs/subsystems/library.md.

Run:
- mote: go test -count=1 ./internal/library/ ok (102.9s); gofmt -l
  clean; GOOS=windows and GOOS=linux go vet ./internal/library/ ok.
- Broken by hand: TestProjectSkillsDsh with projects.go at origin/main
  fails ("magpie knows of no folder dsh reads a project's skills from").
- Real dsh: @deepseek-ai/dsh 0.2.1-rc.5 from npm on mote, sandbox HOME
  and DSH_HOME, headless profile against a fake OpenAI-compatible server.
  Run in a folder with .git, a skill linked into its .agents/skills is in
  the request's <available_skills>; run in a folder with no .git, its own
  .agents/skills is read; run in a subfolder of the repository, only the
  root's is read, not the subfolder's (filed as #5172).
- GUI: /api/library's view from library.Read with a sandbox ~/.dsh,
  served to the real assets in Chromium and WebKit, en and zh: the
  project card's skill rows have a dsh chip (lit where given), and the
  "reads no project skills folder" line no longer names it.

Not tried: the dsh Desktop app (its own profile; the same base bundle
is assumed, not checked); the full GUI suite (no GUI file changed);
Windows copy mode with a real dsh.
2026-11-04 13:53:04 +08:00
yetoneandreyoung 83bdfe70d2 otlp: OTEL_RESOURCE_ATTRIBUTES and OTEL_SERVICE_NAME name the server a trace or metric came from (#5167)
Several magpie servers exporting to one collector or to Langfuse all sent
the same resource, service.name=magpie alone, so nothing said which server
an event came from. Both signals' resource now merges the standard
OTEL_RESOURCE_ATTRIBUTES over that default, and OTEL_SERVICE_NAME over
that (otelResourceAttributes in internal/otlp/otel_resource.go). Nothing
about the machine is looked up; only what the user set is sent. Neither
variable turns export on.

Ported from reyoung's 7ed03b819 (feat/otel-resource-attributes, base
4ca55c6b6), reviewed line by line; nothing in it reached past its goal.
Changed from it:
- service.name precedence. The resource SDK spec makes code-supplied
  attributes win over OTEL_RESOURCE_ATTRIBUTES, but magpie's "magpie" is
  the fallback in the role the spec gives unknown_service, not identity
  the user supplied, and magpie's default never overrides a value the
  user set (code standards). So a service.name in the variable wins, and
  OTEL_SERVICE_NAME, which the spec's env table puts over the variable's,
  wins over both. An empty service.name or blank OTEL_SERVICE_NAME counts
  as unset (the spec's "empty value = unset"), so the resource never
  carries service.name="".
- Bytes that aren't UTF-8 once decoded (%FF) are a decoding error and
  discard the variable; before, json.Marshal sent U+FFFD.
- The variable was parsed and, when bad, logged on every flush of each
  signal. It is now parsed once per value and logged once, naming the
  entry by position (never its contents).
- otlp tests clear both variables in otelConfig, so a developer's shell
  can't change what the existing wire tests see.
Kept: whole variable discarded on any invalid entry (no '=', empty key,
bad escape, empty entry such as a trailing comma), as the spec says;
keys and values trimmed and percent-decoded with PathUnescape ('+' stays
'+'); last repeated key wins; values are strings.

Docs: reference.md's OTLP export, plugin-runtime.md's internal/otlp row,
and the privacy pages (en, zh, ja) now say the resource carries what the
user sets there.

Verified:
- TestOTelResourceAttributes reads the resource a test collector gets on
  /v1/traces and /v1/metrics, 17 cases. On the old otelEnvelope it FAILs
  (server, override and duplicate, encoding and empty, unencoded UTF-8,
  OTEL_SERVICE_NAME cases: "traces resource attributes =
  map[service.name:magpie]", same for metrics). Broken by hand one at a
  time, each went red: UTF-8 check off (not_UTF-8_once_decoded), no
  OTEL_SERVICE_NAME (3 cases), empty service.name kept (empty_service_
  name_is_unset), valid entries kept from a bad variable (missing equals,
  trailing comma, empty key, ...), and the per-value cache off
  (TestOTelResourceAttributesLoggedOnceWithoutContents: "logged 4 times,
  want once"). All green restored.
- On mote: go test -tags nogui ./internal/otlp ok; go test -race -count=3
  -run TestOTel ./internal/otlp ok; go vet, GOOS=linux go vet -tags nogui,
  GOOS=windows go vet (internal/otlp); go build, GOOS=linux go build -tags
  nogui, GOOS=windows go build; node --test site/*.test.mjs; gofmt -l
  empty.
- Full suite: run after the push (go test -tags nogui -timeout 45m ./...
  on mote); reds, if any, filed separately.

Not tried: a real collector or Langfuse; Windows/Linux runs of the
package (the code has no OS-specific path).

Co-authored-by: reyoung <728699+reyoung@users.noreply.github.com>
2026-11-04 13:50:09 +08:00
yetone cd83c3147f plugin: a hook's auth.set doesn't sign in again an account signed out while it ran (#5126, #5119)
Cause: a plugin hook that saves a sign-in through client.auth.set (a
models list spending a rotating refresh token) wrote it into
plugin-auth.json unconditionally. A listing that began before a
sign-out, or before a failed move's putBack took the accounts back out
of the plugin (plugin.Take), landed after it and wrote the account in
again. TestMoveToPlugin's reset signs fakeco out, but a background
listing set off by the step before spent a@fake's "rot-a" token again
(rot-a+++++ seen in the file right after the sign-out), so the next
Move saw a@fake as the plugin's own (movedAccount.Was), restored it on
failure, and "the plugin kept an account of a failed move".
TestMoveCutShort (#5119) fails the same way: the account Take removed
came back through the same write. Not a leak between runs: the race is
inside one run, and more runs only gave it more chances. It is a real
bug for users too: signing out of a rotating-token account while its
models are listed brought it back.

Fix: inScope in host.js notes whether the account was signed in when
the call began (had); auth.set skips the write under the file's lock
when it was and is gone now, as renewLocked already does for renewals.
Sign-in steps (signingIn) are not held to it, their account is new.

Test: TestSignOutOutlastsRunningHook holds the fake plugin's models
hook (new FAKE_MODELS_HOLD: marker file in, release file out) across a
SignOut in a real host and checks the account stays gone, and that a
hook not raced still keeps the token it saved.

Run (all at this tree):
- mote-run go test -count=30 -run 'TestMoveToPlugin$|TestMoveCutShort$'
  ./internal/provider: ok. Before the fix the same run on mote failed
  3 TestMoveToPlugin + 9 TestMoveCutShort of 30 each; -count=15 of
  TestMoveToPlugin alone failed 2 to 4 of 15.
- wsl-run go test -count=20 of the two plus the new test: ok. Before
  the fix: 4 + 17 of 20 failed on Linux.
- mote-run go test -count=5 -run TestMoveToPlugin$: ok.
- mote-run go test -count=5 TestSignOutOutlastsRunningHook: ok.
- mote-run go test -timeout 45m ./internal/provider ./internal/plugin:
  ok (provider 171.6s, plugin 160.4s).
- gofmt -l clean; go vet, GOOS=linux and GOOS=windows go vet of both
  packages: ok.

Broken by hand: host.js reverted with the test kept:
TestSignOutOutlastsRunningHook red 3 of 3 ("the hook signed the account
in again"), and the provider tests red as above.

Not tried: a real vendor's rotating-token plugin signed out mid-listing
(the fake plugin's rot- sign-ins stand in for it); the full ./... suite
runs after the push.
2026-11-04 13:23:28 +08:00
yetone efe11df3a0 gui: a press and release on a button with no click after it is clicked once (refeccd, Tap to click)
refeccd (Discord) reports, a third time, that with macOS Tap to click the
first tap on a magpie button only shows the pressed state and does nothing;
the second tap works, a physical press works first time. Fixes 4c0cfafcf
(v0.1.2868, tap with a few px of movement is not a drag) and c360d9d30
(v0.1.2877, a tap sliding off a segmented option counts) did not help him.

Cause: NOT proven. No physical trackpad was used, so I could not see which
events the engine delivers. Checked and ruled out: Wails drag.ts only
suppresses click while dragging/resizing; mainwindow.go sets no
InvisibleTitleBarHeight, so the native first-press window drag does not
reach mid-window controls like the Form/JSON switch. The symptom (pressed
state, mouseup, no click) is what a lost click looks like.

Change: a capture-phase net in app.js. A trusted left mousedown on a
button-like control, released on the same control within 300ms and 12px
and not on a --wails-draggable element, that is followed by no click within
30ms gets one el.click(). A real click sets the flag first, so a working
engine is never double-clicked. Applies to every button-like control
(button, a[href], summary, label, .opt, role button/tab/switch/checkbox/
radio/menuitem/option), not one page. Comments in the tapLike/segs blocks
were shortened so the app.js budget (1,316,874) needs no raise.

Test: tap-lost-click.test.cjs emulates "mouseup arrives, click does not"
(a capture listener swallows the first trusted click after a mouseup), then
taps JSON, Form and the editor's Cancel in Library > MCP > Edit. Both
engines, en/zh/zh-TW/ja/de, 1100 and 390 wide. Red on the old app.js
(0/22 per engine), green with the change (22/22 per engine). The lost click
is emulated, not captured from a Mac.

Run on mote: tap-lost-click plus 8 neighbouring files (168/168, both
engines); a 33-file mouse/tap/segs subset before the comment trims; core
script budget test passes. Reds in the subset (segs-press-redraw,
routing-rule-drag, 21 failures) are identical on unmodified app.js and
already filed (#4566, #3922, #4932). The whole GUI suite was started and
killed at file ~57/1185 (about 6h on a loaded mote), so it was NOT run in
full. go test ./internal/gui: TestMainWindowCorners red, same on
origin/main 40cfd32b0 (#3949).

Not tried: a real trackpad with Tap to click, the real Wails app, Linux and
Windows webviews. If refeccd still sees it, the next step is a log of the
mousedown/mouseup/click sequence from his machine.
2026-11-04 13:21:50 +08:00
yetone 40cfd32b0b provider: a Codex account with no credits and every window at 100% counts held though allowed isn't false (xiaoq6285)
xiaoq6285 (Discord, magpie 0.1.2891, Codex App 26.1029, Windows): a used-up
Plus account, no credits, 用量 showing it used up, config.toml with
model_provider = "magpie" and requires_openai_auth = true, Send grey until
Codex was switched off in magpie. Banked resets and paid credits were ruled
out (codexHeld reads neither resets nor, here, any credits). What is left is
a reading that doesn't say allowed false: codexHeld needed exactly that, so
CodexUsedUp stayed false and Sync kept requires_openai_auth, which makes the
app read the account's rate limit and grey Send.

codexAtLimit now holds: allowed false (as before); allowed not said with
limit_reached or a window at 100%; allowed true with every reported window
at 100%. Credits and the workspace-overage exemptions are unchanged and
still run after it.

Why the two cases that were false stay narrow: a7c4e5ddd (#996) pinned
"limit_reached but allowed, no credits" to not held, because the composer
gate (hP / hardBlocked in 26.930) reads allowed alone and the app still
sent; holding such an account only takes the app out of ChatGPT (durable
threads, remote control, cloud tasks, its usage meter) for nothing. That
cost is real, so allowed true still stands unless no window has room: a 5h
window at 100% with the week open is not held (new case). The case
"limit_reached, allowed not said" does flip to held.

Not known: the reporter's actual reading (allowed true or missing, never
seen) or the 26.1029 gate (its bundle isn't on any test box; 26.1021 is).
If their reading says allowed false with no credits this changes nothing
for them.

Run on mote: go test -timeout 45m ./internal/provider ./internal/agent ok
(194s, 346s); GOOS=linux, GOOS=windows and native go vet on both ok; gofmt -l
clean. Broken by hand: with the old subscription_usage.go and the new tests,
TestCodexUsedUpIsWhatTheAppHolds fails on "limit_reached, allowed not said,
no credits" and "every window at 100% but allowed, no credits".
Not tried: the real 26.1029 app, a real used-up reading, Windows run.
2026-11-04 12:41:11 +08:00
yetone d1fa254b1d gui: masked words and Never mask are a list, a row per word (noahhrreion on Discord)
noahhrreion: "希望脱敏词选项可以做成真正的列表,在一个小输入框里面不方便管理多个脱敏词".
Settings → Privacy's Masked words was one comma-separated box. It is now a
list (wordList in plugins/redact/settings.js): each word is its own row,
edited in place (Enter or leaving the row saves, Escape puts it back,
emptied is removed), × removes it, and the last row adds. Its sibling,
Never mask under the mask actions, had the same box and gets the same list.

Stored values are unchanged: redactWords and the allow list are still
string arrays, saved through the same savePrefs / settings/redact-allow
calls, and nothing is rewritten on open (the new test checks that opening
the page saves nothing). Typed or pasted text splits as the old box did
(, , and newlines, trimmed, empties dropped), so a pasted "a, b" is two
rows. The Hide eye still shows every row as dots. New strings are in the
redact plugin's i18n for zh, zh-TW, ja and de; the two old "separated by
commas" hints are gone from the core i18n. The site's masking docs (en, zh,
ja) say a row each.

Run (on mote via mote-run, Chromium and WebKit):
- new redact-words-list.test.cjs: 5 languages × 1100/400px × both engines,
  draw, add with Enter, paste-split, edit, Escape, ×, empty-and-Tab, reload;
  with i18n-keys 24/24 ok
- redact-words-hidden, any-case, whole, mask-actions, redact-route,
  redact-kinds, redact-shape, settings-search, settings-sections,
  settings-lines-wrap, settings-hints, settings-groups, readable-focus,
  masking-records, mask-alert: 378/378 ok
- go test ./internal/gui/ -run 'TestCoreScriptBudget|TestSettings': ok
  (app.js shrank; no budget raised)
- screenshots light/dark, 1100/400px, both engines, looked at

Broken by hand: without wordFocusBack (focus kept across a redraw) the new
test goes red (waitForFunction timeout after the first add). Dropping the
blur guard during a redraw (wordsRedrawing / isConnected) stays green in
both Playwright engines, which fire no blur on removal; it is kept as a
guard for engines that do, with no test that fails without it.

Not tried: the real app on WebKitGTK / Windows WebView2; no Go files changed.
2026-11-04 12:38:10 +08:00
yetone 4ca55c6b62 gateway: a guard test that Only switch Claude Code's sign-in keeps every route off the Claude accounts (zhangxiaoxiaoxx on X)
zhangxiaoxiaoxx on X asked for a switch so that, with Claude signed in,
magpie never forwards or routes another agent's request onto it. That
switch exists: Providers > Claude, "Only switch Claude Code's sign-in"
(magpie accounts switch-only claude on, ec3dad75a). On it, KeptToAgent
makes On() false and magpie serves nothing on the Claude accounts. Its
only test asked by naming claude/... directly.

TestClaudeKeptToClaudeCodeOnEveryRoute asks as OpenCode through the
other routes: a routing group with a Claude member first (goes on to its
other member), a provider whose fallback is a Claude model, and a group
whose classifier is a Claude model. None runs a Claude Code through the
bridge. Unticked, the group reaches the Claude account again. No
behaviour change.

Run on mote:
- go test -count=1 -run TestClaudeKeptToClaudeCode ./internal/gateway:
  ok at 759b4d1d7, and again after rebasing on f4e52659a.
- wsl-run, the same -run: ok.
- go test -count=1 -timeout 45m ./... at 759b4d1d7: 86 packages ok,
  internal/gui red in TestCoreScriptBudget (#5139) and
  TestMainWindowCorners/macOS_26_SDK (#3949), both filed already; this
  commit touches neither.
Broken by hand: On() without !KeptToAgent(): group member, fallback and
classifier each red (a Claude Code ran through the bridge), and
TestClaudeKeptToClaudeCodeServesNothing red.
Not tried: a group magpie found (auto/claude-*): in the test sandbox the
Claude account lists no catalog model, so no such group formed with it.
It plans through the same per-member path as a user's group.
2026-11-04 12:00:01 +08:00
yetone f4e52659a8 plugins: a pick listed as another id leaves with its model (axelburks)
A plugin's model the user lists as another id ("list as", SetModelID) is
picked under that id, but pluginListedIDs held the plugin's own ids. The
hourly relist and Refresh compared the pick with a list that never had
it, so "in the old list, not in the new one" was false, and a model the
plugin dropped stayed picked and on, as if typed in by hand. The built-in
providers' liveIDs already mapped through modelIDsOf; the plugin path
now does too. The list-as stays in settings, so when the plugin lists the
model again relistPicks puts the pick back under the same id.

Run: TestListedAsPickLeavesWithItsModel (new: aaa listed as
claude-opus-5.5 and picked, next list lacks aaa -> pick set aside, alias
kept, a hand-typed pick stays; aaa back -> pick back, alias intact), on
mote. Broken by hand: with pluginListedIDs returning the raw ids the test
fails ("dropped []"). go test internal/provider, internal/plugin: ok.
internal/gui: TestCoreScriptBudget (1535230 > 1533802) and
TestMainWindowCorners (mote's macOS) red, neither touched by this change.
Not tried: a real plugin sign-in.
2026-11-04 11:56:33 +08:00
yetone 525e69b976 gui: a page served anew reloads once, not once per read (visamzh on X)
667317159's servedAnew reloads a magpie web page once another version
of magpie answers for it. Clicked back into on the Settings page, the
page reads /api/update twice, for the badge and for the Version row,
and each answer called location.reload(). When the second answer comes
a few ms after the first, Chromium starts the reload again and the page
is loaded twice. The whole GUI suite at 667317159 on the Linux box
caught it: update-served-anew's "en at 420" and "zh at 420" counted 3
loads (gui-full.log). servedAnew now reloads once per page.

The test answers the second post-update read 5 ms after the first, as a
busy machine does, and counts the loads after the page has settled.
app.js's comments on it are shorter, so app.js is 264 bytes smaller
than origin/main's; TestCoreScriptBudget is red on main already
(1534819 > 1533802, #5139) and stays red, 264 bytes less over.

Run (Linux box, magpie-desktop, through wsl-run, at e17b6cefc + this):
- node --test internal/gui/tests/update-served-anew.test.cjs three
  times: 34/34 each (Chromium and WebKit, 5 languages, 1100 and 420).
- go test -tags nogui -run 'Budget|Script|Asset|I18n|Boot'
  ./internal/gui/: only TestCoreScriptBudget red, the same at
  origin/main e17b6cefc alone (#5139).

Broken by hand: servedAnew calling location.reload() on every answer
again: the 10 Chromium "clicked back into" subtests red (3 loads).
WebKit passes either way; it doesn't start a second reload.

Not tried: the whole GUI suite again with this; mote (busy with other
sessions' suites).
2026-11-04 11:47:56 +08:00
yetone 759b4d1d7d agents: a new user's list is folded under Get started (Renzexi01)
Renzexi01 on X (一进来就这么复杂): a new user saw Get started and, under
it, every agent found on the computer at once. While the Get started card
shows and no agent is in use yet, the whole Agents list is folded under
it behind "Show all {n} agents" (en, zh, zh-TW, ja, de); the card's
second step already names the agents found, each connected in a click.
Once one is connected, or the card is put away, the list is as before:
the ones in use in view, the rest under "Show {n} more".

getting-started checks the list folded under the card, the button's
words and aria-expanded in every language, and the list back once an
agent is connected or the card put away. Tests whose fake state is a new
user with no agent in use, and which read the agents' rows, now set
guideHidden as a user past Get started has (account-arrange,
aside-native, agent-*, claude-picker-magpie-first, codex-accounts-via,
omp-profile-connect, picker-rail-current, picker-speeds, pop-phone-room,
reasonix-roles, snow-fields).

What was run, on mote through mote-run, at a9a82a1c3 (tree e91b8e625,
the same as this commit once its fixup was squashed in), on base
0872bc2a0:
- The whole GUI suite (node --test --test-concurrency=4
  internal/gui/tests/*.test.cjs, both engines, every language), while
  mote ran 14 other test processes: 18901 pass, 292 fail in 57 files.
- Those 57 files again at a9a82a1c3 (concurrency 2): 748 pass, 275 fail;
  at 0872bc2a0: 756 pass, 267 fail. 43 files were red at both, most with
  the same counts (model-chip-steady 40/40, usage-agents-hide 22/22,
  segs-press-redraw 16/16, provider-fetch-again 14/14).
- Those 43 at origin/main e17b6cefc: 442 pass, 262 fail, the same files
  with the same counts. Each has an open issue (among them #4388, #4566,
  #3414, #5057, #5013, #4320, #4585, #4625).
- The 7 files red at a9a82a1c3 only, alone (concurrency 1): 79 of 82
  pass at a9a82a1c3 (group-found-skip 1, name-suffix-remote 2), 76 of 82
  at 0872bc2a0 (group-found-skip, images-codex-one 2, name-suffix-remote,
  title-bar-tools 2): load, nothing red at the head alone that is not red
  at the base alone. name-suffix-remote, red alone at both, is #5147;
  group-found-skip is #4617.
- getting-started and group-switch-add-many at a9a82a1c3: 64 of 64 pass.

Broken by hand: app.js and plugins/routing/client.js put back to
0872bc2a0 (tests and i18n kept), the same two test files: 30 of 64 red.
getting-started went red in all 30 of its "Get started ticks from state"
cases ("no agent row in view under Get started").

Not tried: the real app with a fresh HOME (macOS, Linux WebKitGTK,
Windows), and the tray panel beyond the test's panel layout.
2026-11-04 11:40:21 +08:00
yetone 67bc50aa29 routing: a group switched off is listed after the ones on (justacati)
justacati on X: a group switched off stayed where it was among the ones
on, so the list read as if it were still in use. Routing's group list
now shows the ones on first and the ones off after them, each part in
the order the user set. Moving a group (drag, Move up/down) moves it
among its own part only: the last one on is not offered Move down into
the ones off, and a drag only passes cards of its own part. The saved
order is unchanged, so agents' pickers list groups as before, and a
group switched on again is back in its place.

group-switch-add-many checks the order after a switch off and on, and
that Move down is not offered on the last one on.

What was run, on mote through mote-run, at a9a82a1c3 (tree e91b8e625,
the same as this branch's head once the fixup was squashed in), on base
0872bc2a0:
- The whole GUI suite (node --test --test-concurrency=4
  internal/gui/tests/*.test.cjs, both engines, every language), while
  mote ran 14 other test processes: 18901 pass, 292 fail in 57 files.
- Those 57 files again at a9a82a1c3 (concurrency 2): 748 pass, 275 fail;
  at 0872bc2a0: 756 pass, 267 fail. 43 files were red at both, most with
  the same counts (model-chip-steady 40/40, usage-agents-hide 22/22,
  segs-press-redraw 16/16, provider-fetch-again 14/14).
- Those 43 at origin/main e17b6cefc: 442 pass, 262 fail, the same files
  with the same counts. Each has an open issue (among them #4388, #4566,
  #3414, #5057, #5013, #4320, #4585, #4625).
- The 7 files red at a9a82a1c3 only, alone (concurrency 1): 79 of 82
  pass at a9a82a1c3 (group-found-skip 1, name-suffix-remote 2), 76 of 82
  at 0872bc2a0 (group-found-skip, images-codex-one 2, name-suffix-remote,
  title-bar-tools 2): load, nothing red at the head alone that is not red
  at the base alone. name-suffix-remote, red alone at both, is #5147;
  group-found-skip is #4617.
- getting-started and group-switch-add-many at a9a82a1c3: 64 of 64 pass.

Broken by hand: app.js and plugins/routing/client.js put back to
0872bc2a0 (tests and i18n kept), the same two test files: 30 of 64 red.
group-switch-add-many went red in all 4 of its cases ("the group
switched off is not listed after the ones on").

Not tried: the real app (macOS, Linux WebKitGTK, Windows) with real
groups; a filtered group list with some switched off.
2026-11-04 11:40:21 +08:00