Commit Graph
120 Commits
Author SHA1 Message Date
yetone 2570efb5f7 gateway: an image the picked model can't describe is described by the next model that sees (kelvinjason11 on X)
kelvinjason11 on X: "图片识别好像只支持一个模型识别 没有fallback". When
the describer (Settings' Image recognition model, or AutoVision's pick)
failed, the turn failed with it, though other models that see were there.

Now describeWith asks the pick first, always. When it fails for any reason
but the client's own cancel, magpie asks the next model that sees: the
first ready one of seersRanked, AutoVision's own order (ready, then
Claude account, Codex, API key, other, then cost), leaving out each model
already tried and each one that turned an image away (sightRefused). At
most 3 models (visionTries), and all of them within visionWaitMost
together: each try gets what is left of it, not a fresh visionTimeout.

- The text header names the model that described the image
  ("as other/bigeye describes it"), not the pick.
- The Routing row of the stand-in carries Instead, Why and Picked
  (describingInstead, the same fields web search's searchingInstead
  sets), and the Routing page says in every language that the pick
  couldn't describe it, why, and which model did instead.
- When none answers, the error is the first failure as before, then
  "nor could X, asked in its place: why" for each other model tried.
- Spent/allowance: each try goes through serve as before, so autoSpent
  and spentModel judge every stand-in the same as they judged the pick.
- vision_mcp's describe_image tool gets the same fallback.

Cache (s.sights): a description is kept under the pick and the image,
whichever model described it, with the describer's name beside it. The
same image sent again asks no one, the stand-in's text is reused, and
its header still names the stand-in. A new image asks the pick first
again, so a pick that comes back is used at once. Failures are not kept.

Settings' text ("When the model in use can't see images, this one
describes them to it") is left as it is: the pick is still asked first
for every image.

Tests (internal/gateway/vision_fallback_test.go):
- TestPickedDescriberThatFailsGivesWayToTheNextThatSees
- TestAutoDescriberThatFailsGivesWayToTheNext
- TestNoDescriberAnswersNamesEach
- TestPickedDescriberThatAnswersIsTheOnlyOneAsked
- TestCanceledDescriptionAsksNoOther
TestDescriberThatCantSeeIsntAskedToDescribe now expects the next model
that sees to describe in place of a text-only pick, not a 502.
GUI: internal/gui/tests/vision-instead.test.cjs (every language, 1100
and 520 wide).

Run on mote at 45739f15b (this tree, on origin/main 74f1df869):
- go test -tags nogui ./internal/gateway/ -count=1 -timeout 45m: ok
  (542.988s). An earlier run while mote was at load ~26 failed four
  Antigravity turned-away tests and TestCodexSpentGrokFailingIsTold.
  None of them touches vision, and all passed in this run.
- gofmt -l: nothing.
- GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: ok.
- GUI, Chromium: vision-instead, search-instead, routing-vision-why,
  vision-mcp, routing-kind and i18n-keys (4/4) pass.

Broken by hand (in a worktree at 0fcb3acb3):
- The old code with the new tests: Picked, Auto and NoDescriberAnswers
  go red. PickedThatAnswers and Canceled pass, as they should on code
  that never falls back.
- The ctx.Err() check removed from describeWith: Canceled goes red (a
  vision row for other/bigeye appears).
- describeWith made to ask the next model after a success:
  PickedThatAnswers goes red ("eye asked 1 times, bigeye 1").

Not tried:
- The GUI files in WebKit. Playwright's WebKit launch timed out at 180s
  while mote was at load ~25 from other suites. To be rerun.
- vision-instead against the old Routing client, to watch it go red.
- No real account: the fallback was run only against fake upstreams.
2026-10-31 02:28:18 +08:00
yetone 2604d68db0 routing: the live card stays on the request it tells of while others come at once
qiang2040 on Discord ("狂闪", a screen recording): with Codex
conversations sending at once on group/glm-5.3-flash-free and
group/deepseek-v4.1-flash, the Routing page's top card (head, story,
context window) jumped to the newest request on every trace update,
and to "magpie hasn't routed this request yet" for each new one.

told() picks the request the card tells of: it stays on the one it
shows until that one is done, then goes to the newest, and a newer
request routing hasn't picked for yet doesn't take it from one that
was routed. play(), resume(), the live poll and rebuild() use it;
requests that come meanwhile still fly on the stage, without a caption
of their own. Pinned, replay and day views are unchanged.

Run:
- routing-concurrent-hold.test.cjs (new; two conversations interleaved,
  every frame's head watched; en, zh, zh-TW, ja, de): red on the old
  code in Chromium (mote); green on this code in Chromium (mote and
  WSL) and WebKit (WSL).
- Broken by hand: told() returning newest() -> 6 of 6 red in Chromium
  and WebKit (WSL), "the card stays on 101 while it is under way".
- routing-* and panel-routing* in both engines on WSL, against a base
  worktree at origin/main: the reds are the same on base. row-swap is
  red 3/3 on base too (#3799); live-patch's folded sample caught a
  count-up mid-way once (129K vs 130K, the right request; #2174); the
  rest are WSL WebKit reds under #4121.
- go test ./... -timeout 45m on mote: 80 packages ok; internal/gui's
  10 real-window AppKit tests were killed at their deadlines (mote's
  pboard/launchd state, #4125; also #2645, #1936). This change is
  JavaScript only.
- The whole GUI suite (node --test, both engines) is still running on
  WSL at push time; reds it shows that aren't on file get issues.

- At the pushed head (rebased on 59bdd4dbc): the new test 12/12 green in
  both engines on WSL.

Not tried: the real app with several real Codex conversations sending
at once (the test drives a mocked trace). WebKit on the old code
(WebKit can't launch on mote now).
2026-10-31 01:04:08 +08:00
yetone 59bdd4dbc3 routing: a group's pattern members can be put in order by hand (usrname1833)
In a routing group, members a pattern added followed the catalog's
order. The editor gave them no grip or Up/Down, and the gateway tried
them in that order. Now every row gets the same grip, Alt+arrow and
Up/Down that named members have. Matched rows still have no Remove,
since the pattern decides those.

The order is stored as Group.Placed, keyed by provider/model as Members
spells them. It is nil while the order equals the default (named, then
matched in catalog order), so existing groups.json files don't change.
Read (withMatches -> placedIn): members follow Placed. A model matched
since goes after them, and one no longer matched drops out. The gateway
tries members in the order the group is read, so it follows the editor.
Saved (SaveGroup -> placedOver): Members orders the named members, and
Placed (sent, or the stored one when a save doesn't send it) places the
matched ones. A save that doesn't know Placed (card routing, the CLI's
models+=, TUI, import) keeps the matched where they were, and a model it
names newly goes after the last named one. A provider rename, fold,
group rename and RenameMember carry Placed along.

Run:
- go test -timeout 45m -count=1 ./... on mote: 80 packages ok.
  internal/gui fails 10 AppKit window tests at 30s (TestDockJoinLeadsCommandTab,
  TestPanelCloseHidesIt, TestMainWindowCorners, ...). On a fresh origin/main
  cf9ea977c the five I reran fail the same way. That is mote's #4125 (open).
- TestGroupPatternMembersKeepTheirPlace is red on the old code
  (read [zen/y or/a:free or/c:free]).
- Broken by hand, each red at its own step: no stored-Placed fallback
  ("after a named-only save"), a newly named model put last instead of
  after the last named one ("after an add"). On the earlier draft, no
  rename mapping ("after a rename").
- GUI: group-member-drag and group-patterns in chromium and webkit on
  Linux (wsl-run), 8/8 at this head. group-member-drag was red on the old
  client.js. The whole GUI suite ran at the draft before the save
  payload's `placed` field. It was still running when this was pushed,
  and its reds will be filed once it ends.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet of provider and
  gateway on mote.

Not tried: a real account or the real app's window; WebKit on macOS
(mote's browser launches hang, #4125), so WebKit only on Linux. The TUI
has no way to reorder matched members; it keeps the stored order.
2026-10-31 01:02:35 +08:00
yetone 3b5dccd527 accounts: a plugin account goes by its usage's name, not its id (#4416)
A Huawei Cloud CodeArts account is kept by its accountId, an IAM id
(iam::<domain>:user:<name>), and every list showed that id while its
quota card showed the masked phone the plugin's usage() names it by.
Display only: an account now reads as the name the user gave it, else
the `user` its plugin's last usage read gave (PluginUserOf: the
in-memory read, else quotas.json), else its id. The id stays the key
everything is kept by; nothing stored changes or migrates. A read that
fails keeps the last good name; nothing read yet is the id, never blank.

One rule in provider (AccountShown, AccountShownOf, AccountLabelOf),
used by every list: cards' Alias (Usage page, tray panel,
/v1/magpie/quotas, magpie quota), magpie accounts, magpie providers,
the TUI's Providers rows and quota titles, usageapi's Account filter,
the quota alert. The GUI gets it as /api/providers' accountUsers
(accountShownOf in app.js): the editor's account rows (the id in the
tooltip), the per-account proxy lines, Routing's userShown, the
Providers search, Hide accounts. app.js's account lookups share one
helper, so the core stays in its budget (1,536,561 of 1,536,586), with
no room added.

Run:
- go test ./... -timeout 45m on mote at 2f5a3f1c0 + this change: all ok
  but internal/agent TestPiModelsAskedOnTheirNativeAPI (fixed on main
  by 7474a86f1, green there; this is rebased onto it),
  internal/update TestRelaunchOpenTriedAgain (#3881, green alone x3),
  and internal/gui's real-window AppKit tests (TestPanelCloseHidesIt,
  TestMainWindowCorners, TestTrayCellClickReleasedPanel red the same
  on origin/main 99ad38b7c; #2645, #4125, #1936).
- go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet of the
  touched packages; gofmt -l clean.
- TestPluginAccountShownByItsUsageUser (new, real plugin host and fake
  plugin): id before a read, phone after, phone after a restart from
  quotas.json, phone kept over a failed read, own name wins, id when
  nothing is known. Red on the old code.
- GUI on the Linux box (mote's Chromium segfaults on these pages on
  origin/main too, #4125): account-plugin-user (new),
  routing-account-name (extended) and account-alias, Chromium and
  WebKit, every language, 34/34; the new checks red on the old code;
  the whole suite (make test-ui on the Linux box) was still running at
  push: 417 files in, 5 reds, none on a page this changes
  (account-models' row-moved check in WebKit, 81 vs 79px, and
  agent-models-all-hidden), not yet compared with origin/main; any
  that are new get an issue once it ends.
- At the rebased head (3bce283df): go test of provider, cli, tui,
  usageapi, plugin, agent -run TestPi, gui -run
  Budget|Provider|Quota|Account: all ok. Core scripts 1,535,513 of
  1,536,586.

Broken by hand: dropping the quotas.json fallback turns the test red
at "after a restart".

Not tried: a real Huawei CodeArts account (none here). A plugin whose
windows are all model pools isn't kept in quotas.json, so after a
restart it shows its id until its first read.
2026-10-31 01:01:49 +08:00
yetone 0621e70fb9 routing: leave a provider out of the groups magpie finds
chenxiang0010 on Discord asked to keep a provider or a model out of the
auto-created routing groups. A model could already be kept out (remove
its found group; magpie keeps it removed), but a provider could only be
turned off per group or everywhere. Now Routing -> Groups, under "Find
groups on their own", has "Leave out a provider..." (app menu, saved
when it closes) and `magpie group auto skip <provider>...|none`. The
providers chosen (providers.json autoGroupSkip) join no found group; a
group the user made or changed keeps them, a found group left with one
provider goes away, and a request for it is served by AutoStandIn from
a provider still in, and agents on it are reseated (agent.Reseat). A
rename carries the id along. en, zh, zh-TW, ja, de.

Run at 383947fce (this change on origin/main 2ff75161d):
- go test -timeout 45m ./... on mote: 80 packages ok; internal/gui red
  only in its real-window AppKit tests (TestDockJoinLeadsCommandTab,
  TestPanelCloseHidesIt, TestMainWindowCorners, ...), which fail the same
  on fresh origin/main 2f65a33aa on mote (#4125, #2645).
- gofmt -l clean; go vet ./... on Windows (win-run) clean; on Linux
  (wsl-run) clean with -tags nogui (the WSL distro has no gtk4).
- GUI: group-found-skip (new) and group-found-off, all five languages,
  1100px and 390px, Chromium and WebKit on Linux (wsl-run): 24/24. On
  mote every WebKit launch times out (#4125), Chromium 12/12 there.
- The routing files the full run flagged (concurrency 6) rerun alone on
  wsl-run, here and at fresh origin/main 380032cda: click-scroll's
  WebKit case and group-morph's WebKit 420px cases fail the same on
  origin/main. group-duplicate's de case was mine: the found groups'
  new "Anbieter ausnehmen..." line made German taller than the test's
  420x1200 window, which it assumes needs no scroll; it now uses 1400
  and passes 10/10 in both engines.
- Whole GUI suite on wsl-run, concurrency 6: still running at push time
  (5092 ok, 170 not ok so far, mostly in files this change doesn't load:
  account-*, agent-*, connect-*, gui-de/gui-ja's "{agent}" placeholder
  string). They are compared against origin/main after the push.

Broken by hand: foundGroups without unskipped -> TestAutoGroupSkip and
TestGroupsSkip red. Test calls before the fix to groupCmd's args ->
TestGroupAutoSkip red.

Not tried: the real app with real providers; a model-level skip (a
model is kept out by removing its found group, as before).
2026-10-31 00:57:21 +08:00
yetone 31728e29a8 routing: the German connection-check note names {agent} as often as the English one
The sibling of ec5571d6f's ja fix: da3c5e0c0's de string for "{agent}
checked that magpie answers ..." had a third {agent} too, so gui-de's "de
has every zh string, with its placeholders and tags" was red on main. "Das
Modell dieser Prüfung wählt {agent} selbst" now reads "wählt es selbst";
the sentence opens with {agent} already. zh and zh-TW had two.

Run: wsl-run gui-de, gui-ja, gui-zh-tw, i18n-keys: 13/13; gui-de alone
before this change: red, this test. Found in the whole GUI suite run
after v0.1.2228 (ec5571d6f was checked with gui-ja only, and missed it).
Not tried: a German speaker's read of the wording.
2026-10-31 00:54:52 +08:00
yetone 4f2d5fc7e0 routing: a group can put its cheapest member first, by each one's price at that hour
liyuanzheng (#general) and lam_em (#feedback) both asked for the same
thing. Off-peak, DeepSeek's own API should come first for deepseek-flash.
At DeepSeek's peak (weekdays 01-04 and 06-10 UTC, billed 2x since
v0.1.2173), another provider should come first, Ollama say. A schedule
editor would make the user copy DeepSeek's hours into magpie. Instead,
a group gets one more routing, "Cheapest first" (`cheap`). Each request
sorts the members by what they cost right then: input + output price per
million, at the peak rate when it is peak hours. A tie goes to the lower
cache-read price. Free models count as 0. A member with no known price
keeps its listed place after the priced ones. Prices come from the same
priceOf the usage ledger bills with, so the user's own ModelPrices,
list prices and maker prices all count, and so does a provider's rate
windows.

- routes: Seat carries Priced/Cost/CacheCost; Strategy.ByPrice; Cheapest
  is a stable sort, so equal prices keep the user's order.
- gateway: weighRouted prices each seat at priceClock() (time.Now; a test
  holds it) through the new provider.PriceAt. The trace's Weighed row
  gets a price (input/output/cacheRead/peak) so Routing can say why.
- It is a group's alone, like Manual. A provider saved with it drops it,
  and `magpie provider set … routing=cheap` refuses it. Groups take it in
  the GUI menu (one more item, no new controls), the TUI and
  `magpie group set <id> routing=cheap` (aliases cheapest, price, cost).
- Routing's mode line says why the first one is first, e.g. "Cheapest
  first: deepseek-v4-flash costs least on ollama-cloud now — $0.150 in,
  $0.600 out a million tokens.", with peak and unpriced variants.
  en/zh/zh-TW/ja/de.
- Docs: gateway-routing, plugin-runtime, reference (it also points at
  Time window and Pause rules for a fixed schedule) and the site's start
  pages (en/zh/ja).

Run, at f7f2d75f2 (this change rebased onto it):
- Red on the old code: TestCheapestFirstGroupFollowsPeakHours (deepseek
  vs ollama with ModelPrices, priceClock held at 14:00 UTC off-peak and
  02:00 UTC peak) and TestCheapestOrdersByPriceNow did not compile
  without Cheapest. TestCheapestFirstIsAGroupsOnly checks that a provider
  drops it and a group keeps it.
- Broken by hand: without `pr = pr.In(at)` the gateway test is red ("at
  DeepSeek's peak ... went to deepseek"). With Cheapest returning the
  order unchanged, both the routes test and the gateway test are red.
  Both were restored.
- Full Go suite on mote (-count=1 -timeout 45m ./..., log kept): every
  package ok except two. internal/provider had
  TestQuotaSpanCarriesEveryWindowField, which is red on origin/main (#4457,
  fixed since in ccbefe2a2). internal/gui had ten AppKit window tests
  killed at their 20-40s deadlines (TestPanelCloseHidesIt,
  TestMainWindowCorners and others). Three of them are red the same way
  on a fresh origin/main f7f2d75f2 copy, under #2645/#4125 (mote has
  several GUI suites running). After the rebase, go vet and the Cheapest,
  SpeedFirstGroup, ParseRouting, ApplyGroupPairs and ProviderRouting tests
  are ok. go vet darwin, GOOS=linux -tags nogui and GOOS=windows are ok,
  and gofmt is clean.
- GUI on WSL (Linux, chromium + webkit): routing-cheapest-first (new,
  3 scenes x en/zh/zh-TW/ja/de x 2 engines), routing-group-strategy,
  builtins, i18n-keys and routing-speed-first gave 95 of 96. The one red,
  routing-group-strategy "webkit en light ... the pick moved nothing", is
  a wheel-scroll timing red. It fails 3 of 3 on origin/main and 1 of 3 here
  (#4459). Core-script budget ok (app.js +9 bytes).
- The whole GUI suite (1025 files) was started on WSL at this tree and
  was still running when this was pushed, at load ~160.

Not tried: real DeepSeek or Ollama accounts, and a real request during
DeepSeek's peak hours. Ollama Cloud's price here is the catalog's, not
checked against a bill.
2026-10-30 23:59:31 +08:00
yetone ec5571d6f2 routing: the Japanese connection-check note names {agent} as often as the English one
da3c5e0c0's ja string for "{agent} checked that magpie answers ..." had a
third {agent}, so gui-ja's "ja has every zh string, with its placeholders
and tags" was red on origin/main (a0cb8b646), in Chromium and WebKit.
"このチェックのモデルは {agent} がモデル一覧の名前から自分で選んだもの"
now reads "このチェックのモデルはモデル一覧の名前から自分で選んだもの"; the
sentence already says the agent picks it.

Run: wsl-run node --test gui-ja.test.cjs i18n-keys.test.cjs: 7/7 (red
before: 1 fail, the same test, in both engines).
Not tried: a Japanese speaker's read of the new wording.
2026-10-30 23:00:01 +08:00
yetone da3c5e0c0f gateway: Claude Desktop's connection check is tagged as one on the Routing page (cybercaius on Discord)
Also: the check follows a Desktop model switch made after the last turn.

cybercaius (#help): with gpt-6.1-sol on AnyRouter chosen in the
conversation, the Routing page showed "Claude Desktop requested
deepseek/deepseek-flash" while the answer came from gpt-6.1-sol. The route
was right; the row was not explained.

Those rows are Desktop's own connection check ({"max_tokens":1, content
"."}, app.asar 2.7032 lWt/YT). Desktop names its model itself: the
shortest listed id with haiku, else sonnet, else opus, else the FIRST
listed model. magpie lists no Claude-named ids to it, so the check names
the first one (deepseek-flash), whatever the conversation is on, and
magpie sends it to the model chosen in Desktop's menu (desktopChosen).

- The check is recorded with kind connection_check (KindDesktopCheck,
  usage purposeKinds "Connection check", purposes.js regenerated). The
  Routing page tags the row "Connection check" next to the requested id
  and its story says the id is the one Desktop named from its list, not
  the conversation's model, and where magpie sent it. zh/zh-TW/ja/de.
  The requested id itself stays what Desktop sent.
- desktopChosen: a turn sent after cowork_account_settings.json was last
  written wins over the menus (newer of the two). Before, the last
  session's model came first whenever any menu still held it, so the Code
  tab switched off DeepSeek with Cowork left on it kept the check on
  DeepSeek. desktopPicked now carries when that turn was sent (the
  file's mtime once read).

The two 400s were AnyRouter's own (the reporter says so); not changed.

Run (at 0013f990c, this tree before its rebase on e0ad48641 and the
version stamp v0.1.2208 -> v0.1.2212 in comments/doc):
- mote: go test -tags nogui -timeout 45m -count=1 ./... : 81 ok, exit 0.
- mote: go vet ./internal/gateway ./internal/usage for darwin, linux
  (nogui) and windows: ok. gofmt clean. go generate ./internal/usage
  gives the same purposes.js as committed.
- GUI: routing-desktop-check (new; en, zh, zh-TW, ja, de), routing-kind,
  i18n-keys: chromium on mote ok; WebKit could not launch on mote (90+
  hung pw_run.sh launches from other sessions), so both engines ran on
  the Linux box (wsl-run): 14/14 ok.
- Whole GUI suite (wsl-run, concurrency 4) still running at push; reds
  so far are in account-arrange, account-models and agent-expand-steady,
  files this change does not reach. Checked against main after.
Broken by hand:
- call.Kind = KindDesktopCheck turned off: TestClaudeDesktopProbeAsksNoClassifier
  red ('recorded as kind "" (unmarked)').
- the connection_check story removed from client.js: routing-desktop-check red.
- old desktop.go: the new "Code tab switched off the last session's
  model" case red; the at.After check turned off: red too.
Not tried: a real Claude Desktop. Whether Desktop sends a check on each
model switch, and whether its composer switch writes the menu file, are
read from its bundle, not seen live. AnyRouter's 400s not looked into.
2026-10-30 20:32:25 +08:00
yetone 88e6fb9cf7 provider: a signed-in subscription's models stay in every agent's list with a group listing alone on
士奇 on Discord (Simplified Chinese GUI, the third report of this): with
routing groups off, Hermes Agent's and WorkBuddy's model lists had the
ChatGPT subscription's GPT models. With routing groups on, they were gone.

Cause: the user's group names those models and lists itself alone
(Group.Unlists, the routing plugin's option for that, #1783). While the
group is on, catalogKeeping drops what it names from Catalog(), and every
agent's list starts from Catalog(). With groups gated off the group's
Unlists goes away, so the models came back. a3ee00c05 kept them for the
Codex agent only; its body said other agents still didn't see them.

Fix, at the one point every agent's list starts from: catalogOf(agent)
keeps a signed-in subscription's own models (SubscriptionKept: no group
entry, Provider.Account set, the provider not kept for routing groups)
for every agent, so a group is added on top of what agents had. A client
that is no agent ("" on /v1/models) still gets the group alone, as #1783
asked. Provider.Unlisted ("Only through routing groups") still hides the
provider's models from agents other than Codex. Unlisted() no longer names
a kept subscription model, so the picker's note doesn't call it kept for
groups.

Siblings: every agent writer reaches catalogOf through CatalogFor and
ListedFor. Two gateway lookups read Catalog() directly and now use the
agent's catalog (CatalogOf): /v1/models/{id} and Claude Desktop/Science's
alias lookup. agent.go and codex.go read Catalog() only for error text or
a fallback and are left alone. The routing plugin's hint for that option
says, in every language, that a signed-in subscription's models stay in
agents' lists.

Test: TestSubscriptionModelsStayInEveryAgentsListWithGroupOn signs in a
ChatGPT account in a sandbox and switches on a group naming its 5 models
that lists itself alone. For every agent that lists the group (68,
including hermes, workbuddy, claude and codex), the agent's list and
CatalogFor have the models, and a picker offering the group offers them.
Catalog() and CatalogFor("") still don't. With the provider set to
Unlisted, Hermes doesn't list them. TestCodexOwnModelsListedOnlyThroughGroups
now expects Claude Code to keep the models under a group alone.

Run (on mote):
- Broken by hand: catalogOf reverted to a3ee00c05's Codex-only version.
  The new test went red with 340 errors across 68 agents, e.g.
  "codex/gpt-5.5 not in hermes's list map[group/mygpt:true]", and the
  same for workbuddy, claude and claude-desktop. Green with the fix back.
- gofmt -l; go vet on darwin, linux (nogui) and windows; builds: clean.
- go test -timeout 45m ./... at 035d87b80 (this change on 4a4a90c23,
  before a test comment was reworded): every package ok except
  - internal/gui TestMainWindowCorners/macOS_26_SDK: #3949, red on
    origin/main accb951ab on mote too (macOS 27);
  - internal/provider TestClaudeAccountServesModelsListedSinceItsFetch:
    #3174 (red in a full run, green alone). 5 of 5 green alone and
    green in a whole internal/provider run at that head.
- At this commit on b26fa0903: gofmt -l on the
  changed Go files, go vet of provider, gateway and gui on darwin, linux
  (nogui) and windows: clean. internal/provider whole: ok.
  internal/gui and internal/gateway with -run
  "Codex|Group|Subscription|Unlist|Catalog|AgentModel": gui ok; gateway
  red on TestAntigravityTurnsCodexsGPT5ThreadAwayOnce and
  TestCodexSpentGrokFailingIsTold, both red the same way on origin/main
  b26fa0903 (3 of 3) and filed as #4362.
- GUI files the change reaches, on b26fa0903: agent-model*, group-unlists and
  i18n-keys: every Chromium case and i18n-keys pass (46); every WebKit
  case timed out launching the browser (180s, #4125: WebKit doesn't start
  on mote right now). The same files at 035d87b80 passed in both engines
  but i18n-keys, whose one red (the new test quoted a routing-plugin
  word) is fixed here.
- Rebased on 101775657 (main had moved models.go and gateway.go): gofmt,
  go build for darwin, linux (nogui) and windows, go vet of provider,
  gateway and gui on all three: clean. go test -run
  "Codex|Group|Subscription|Unlist|Catalog|AgentModel" ./internal/gui
  ./internal/provider and -run "Model|Desktop|Alias|Catalog"
  ./internal/gateway: ok.
- The whole GUI suite (1004 files) at fd50ed116 was still running when
  this was pushed (mote shared with other sessions' suites). Reds it
  shows get their own issue unless already red on main.

Not tried: no live ChatGPT account and no real GUI app run (the test signs
in a sandbox account). No separate gateway test for /v1/models/{id} or the
Desktop alias lookup. Provider.Unlisted stays honoured, on purpose.
2026-10-30 15:38:06 +08:00
yetone 869c4d112d routing: the magpies fly under the cards, and a long intent is cut short on its row (penershu on X)
penershu on X (v0.1.2123): with two agents sending at once through
jd-auto-balanced, one magpie sat on the hub's "127.0.0.1:3425" with its
dot beside it, another on the group's split dot, and the row smart
routing picked ran "回答中… · 按意图“Design architecture…”" off the
right edge.

Cause:
- .rt-sky (birds and dots) was z-index 2, over the cards (z 1). Flights
  cross the hub's box (via(), 520a2425f), so a bird crossed its words.
- Every wire ends at a card edge, so a held or waiting dot sat half on
  the card.
- .rt-accts li's last column was auto with a nowrap em. The intent text
  ec8fe29b8 added has any length, so it squeezed the name to 0 and pushed
  the row past the stage card.

Fix: the sky goes under the cards (z 0); pose() starts and ends each
flight 6px clear of the cards at either end; the em column is
fit-content(60%) with ellipsis, and the full intent goes in the em's
title. The panel's small stage has no birds and was already under.

Run (mote-run, Playwright 1.62):
- new routing-sky-under.test.cjs: 3 agents at once (one waiting at
  magpie), chromium + webkit x en/zh/zh-TW/ja/de x 1600/1100/560/390 =
  40 tests. Checks nothing in the sky is drawn over a card's words
  (elementFromPoint with a probe), every dot is whole beside its card,
  the intent row stays inside its row and the stage card, keeps the
  name >= 60px, is cut short, and has the whole intent in its title.
  Together with routing-held-dot and routing-smart-intent: green.
- Red on origin/main's client.js + routing.css: 50/50 (sky over the
  words, held dot on the card edge).
- Broken by hand: new JS with old CSS minus the em rule -> 1600 red
  ("name":0, the reporter's squeeze); old JS with new CSS -> dot test
  red (dots over the rows and the hub).
- Screenshots looked at, old and new, both engines, zh 1600/560.
- Whole GUI suite: mote was held at load ~120 by three other sessions'
  full suites for 2h, so it ran on WSL magpie-desktop instead
  (node --test --test-concurrency=8 internal/gui/tests/*.test.cjs). At
  push time, 4438 results were in with 95 not ok, none of them in a
  routing file. They are in untouched pages (account limits, gateway
  keys, Codex settings, agent-panel-name-width, click-scroll and
  others), which reads as WSL load. The whole suite on mote was not run.

Not tried: the real app (WKWebView, WebKitGTK); a real decision model
and real concurrent requests; the full GUI suite on mote.
2026-10-30 11:40:02 +08:00
yetone 2a1ef15ba9 routing: a found group's card leaves out a provider switched off, and counts it (XYenon)
XYenon on Discord (#feedback, 10-30): "已经关闭的提供商还会显示在路由页的
自动成组里是不是不太对". A provider switched off stays a member of the
groups magpie found (#2671, on purpose: agents on auto-<model> aren't
moved while it is off), and the gateway already skips it (membersIn reads
only providers that are on; TestFoundGroupWithAProviderOff covers chat,
and a fallback group, affinity and a group's classifier (decide_group.go)
go through the same FindGroup). So no request reached it. What was wrong was the page: the
card still listed it as "B · model (switched off)" and its logo sat in
the group's icon stack, where every other model list leaves a provider
switched off out.

- Routing page (plugins/routing/client.js): a found group's card, its
  remove-picker row and its logos (groupIcons, also used by the group
  pickers) leave out members whose provider is switched off; a tag
  "{n} switched off" says how many, its title why (offWords). When none
  would be left they are listed as before. The editor and a manual
  group's pick still show them, greyed with why. A group of the user's
  is unchanged: it lists what they put in.
- i18n: "{n} switched off" in zh, zh-TW, ja, de.
- TUI (sibling): the routing list's line for a found group does the same
  ("N models · ... · 1 switched off"), and a group's page marks such a
  member "· switched off: skipped until it is on again" (any group).
- docs/subsystems/providers-accounts.md: the row says it.

Tests: routing-provider-off.test.cjs gains a found group (card text,
tag text and title, no logo of the provider off, editor still has it)
and one whose only member is off (listed as before, no tag); every
language, 1100 and 420 wide, Chromium and WebKit.
TestFoundGroupLineLeavesASwitchedOffProviderOut (internal/tui).

Run on mote (mote-run, this tree): node --test of 45 GUI files
(group-*, panel-routing*, routing-group*, routing-groups*,
routing-provider-off, i18n-keys, found-*, remove-found*): 488/488 pass.
go test ./internal/tui ok; go test ./internal/gui: all ok except
TestMainWindowCorners/macOS_26_SDK, red on macOS 27 and already filed
(#3949), an AppKit window test this change doesn't reach. gofmt -l
clean; go vet ./internal/tui for darwin, linux (-tags nogui), windows ok.

Broken by hand: with client.js from HEAD the new GUI case is red
(expected 'A Cloud · luna', actual 'A Cloud · luna → B Cloud · luna
(switched off)'); with listedMembers returning every member the TUI test
is red ("2 models · ... pa/luna → pb/luna").

Not tried: the real app with a real provider switched off; the full GUI
suite (1002 files) and the full go test ./... were not run.
2026-10-30 02:28:29 +08:00
yetone f5dd4e1423 routing: a try a plugin or Claude Code sent says why it has no time split
"Where the time went" needs magpie's own client to send the request
(TryNet). A plugin sends its own through the plugin host, and a Claude
subscription's goes through Claude Code, so those tries never have a
split, and the page showed nothing in its place, which read as a
request that lost its details (Discord, lute).

A try now records who sent it when magpie didn't (Try.SentBy: "plugin"
or "claude", from sentBy), and the request's story says it under a
done, answered try with no timing: "Its plugin sent this request
itself, so magpie can't split its time" (or Claude Code), in every
language.

Run (mote, go1.26.8, Node 22, Playwright 1.62.0):
- TestPluginTrySaysWhoSentIt: red without the gateway.go line (SentBy
  empty), green with it. TestSentBy, TestTryTellsWhereItsTimeWent,
  TestCursorPlugin*: ok.
- go test ./internal/gateway ./internal/usage -count=1 -timeout 45m:
  ok (gateway 502s, usage 16s).
- node --test routing-time-went (now checks the plugin try's line and
  that a routed try has none), routing-masking, i18n-keys, routing-js,
  routing-time, routing-went-on, routing-steps-cap: 57 of 58 ok in
  Chromium and WebKit, every language. The red is
  routing-steps-cap's WebKit ResizeObserver error, red the same at
  8cbd0a9c9 without this change and listed in #4304.
- go vet for darwin, linux (-tags nogui), windows: ok. gofmt -l: clean.
Not tried: a real plugin or Claude subscription request in the app.

The three commits' full package runs were at base 8cbd0a9c9. Rebased
onto fb2e11e28 (#4308, which changed codex_backend.go), this head ran:
go vet ./internal/gateway for darwin, linux (-tags nogui), windows: ok;
go test ./internal/gateway -run 'TestCodex|TestMasking|TestNoMasking|
TestPluginTrySaysWhoSentIt|TestSentBy|TestTryTellsWhereItsTimeWent|
Revoked': ok.
2026-10-30 01:56:03 +08:00
yetone 8cbd0a9c91 gui: once the loading bird comes it lands before the page fills
The owner (10-30): a load that finished just as the bird came had it
appear over no skeleton and streak off, which read as a bug. The bird
still comes only after ~450ms of skeletons. Once it has come, a GET read
through api() (and routing's history fetch) that comes back before its
first landing waits for it: the skeletons stay, the bird drops and lands
(about 0.5s), then flies off as the content goes in. A read back later
isn't held. The hold lets go after 1.5s at most, for a hidden window that
draws no frames. If its bar goes during the drop anyway (a read not
through api()), the bird fades where it is instead of flying across the
content. Reduced motion and Loading bird off never hold anything, since
no bird comes.

Run on mote (macOS 27), at this tree on origin/main 81bdca1fe:
- skeleton-bird, tray-bird, plugin-readme-bird, both engines: 26 pass,
  0 fail, the new "a load done as the bird comes keeps its skeletons
  until the bird has landed once" included.
- Broken by hand: the new test on the old app.js fails in both engines
  ("the bird landed on a bar before the skeletons went").
- 22 GUI files around loading pages (modal-centred-late,
  plugin-github-wait, plugin-progressive, usage-focus-steady,
  usage-stale-answer, routing-js, routing-steady, routing-day-window,
  routing-time, usage-ledger, usage-refresh, library-loading,
  sessions-overview, plugin-market, providers-fetching, gateway-card,
  panel-usage, agent-models-loading, plugin-page, i18n-keys,
  reduce-motion, held-animations): 237 pass, 8 fail. The 8 are
  routing-steady (#3412) and usage-ledger's "newest live route needs no
  return-to-live button" (#3104, #4078), which fail the same at
  81bdca1fe without this change.
- go test -run Budget ./internal/gui/: ok, no raise. gofmt -l: clean.

Not run: the full GUI suite (another session's full suite was running on
mote; one per machine), Linux and Windows.
2026-10-30 01:31:51 +08:00
yetone ec8fe29b89 routing: the row smart routing's intent chose says the intent where its allowance goes (joey_xue on Discord)
joey_xue (#feedback) asked that the Routing stage's row a smart-routing
decision picked say why, in the spot that shows the account's allowance
("剩余 90% · …"). When a group's rule by intent (the decision model's
answer, recorded in the trace as the rule's `intent "…"` condition, in the
group or a group in it) put the request's first where it is, that row now
says "picked for “<intent>”" in place of what it has left; while it
answers or once it answered it keeps saying so, the intent after it
("answered this request · picked for “complex”"). Resting, failed, passed
over and every other row, and a rule by no intent, read as before. No
gateway change: the trace already carries the rule step; nothing goes
upstream. New string in zh, zh-TW, ja, de (routing/i18n.js).

Run (Linux, WSL magpie-desktop, Playwright 1.62.0):
- routing-smart-intent.test.cjs, Chromium + WebKit, 5 languages, 1100 and
  390px: 40/40 ok. With client.js at the parent (BROWSER=chromium): 30 red
  ("the chosen row: {a: 20% used, b: 10% used}"), the 10 no-intent cases ok.
- Every GUI file that opens the Routing page (184) + i18n-keys, both
  engines, concurrency 6: 2421/2501 ok, 80 red in 28 files. Those 28
  rerun at concurrency 2 here: 61 red; the same 28 at the parent adc618bbf:
  63 red, the same tests (rule editor, drag, bodies, menu scroll,
  click-scroll …) give or take 5 flaky rule-editor cases each way. Filed
  as #4120/#4121 (WSL reds at main); i18n-keys ok.
- mote: go test ./internal/gui/ ok but TestMainWindowCorners (#3949, macOS
  27 AppKit, untouched). No Go files changed, so no gofmt/vet.
- Rebased on 2768f04f9: routing-smart-intent + i18n-keys, both engines: 44/44 ok.
Not tried: a real request through a real decision model in the app.
2026-10-29 19:51:41 +08:00
yetone b64ec9d64f gateway: a picked model that turns an image away gets it described, not another provider (xyenon)
xyenon (Discord #feedback) picked provider-1/DeepSeek-V4.1-Flash in pi
with an Image recognition model set. An image they sent wasn't
described; the request was answered by provider-2/DeepSeek-V4.1-Flash.

Cause: provider-1's list says nothing of images, so magpie took
models.dev's word for the model (catalog.SeesImages: text+image) and sent
the raw image. The relay answered DeepSeek's 400 "Failed to deserialize
the JSON body ... unknown variant `image_url`, expected `text`". That
matches shapeWords, so the try failed as a shape refusal and went on to
the next candidate: provider-1's fallback (or the next group member),
the same model at provider-2, which sees. The describer was never asked.

Fix: a 400/415/422 whose words say images aren't taken (imageRefused:
unknown variant image_url/input_image/image, OpenAI's "only supported by
certain models", OpenRouter's "no endpoints found that support image",
vLLM's "not a multimodal model", 不支持图片 and the like) marks the model
blind for this server's run (refuseSight; blindTo checks it first). With
a describer, the same candidate is asked again at once with the images
described (seenBody, or seenGroup for a group), before any fallback or
other member; the try reads failSight, which the Routing page tells as
its own story (en/zh/zh-TW/ja/de); the row then reads answered, as
for floor's and foreign's re-asks. Later requests
are described up front, for a direct pick and a group (user or auto)
alike, on Chat, Responses and Messages.

Kept on purpose: with no describer (Image recognition off, or no model
that sees), going on to a candidate whose copy sees is the only way to
answer, so it still does (TestRefusedImageWithNoDescriberGoesToOneThatSees).
Documented in docs/subsystems/gateway-routing.md, "A model that turns an
image away".

Run (on mote, through mote-run):
- TestPickedModelThatRefusesAnImageIsGivenItDescribed (9 subtests:
  direct pick with a fallback, user group, group/auto-…; each API),
  TestRefusedImageWithNoDescriberGoesToOneThatSees, TestImageRefused: ok.
- Broken by hand: with gateway.go/vision.go/routing.go reverted to
  origin/main (d9cf85ae8), all 9 subtests fail with "the same model at
  the other provider was asked 2 times" and the raw image sent there.
- go test -tags nogui ./internal/gateway -count=1 -timeout 45m: ok (996s)
  at the d9cf85ae8 base. After rebasing onto 4534561f6: the new tests
  and -run 'Vision|Image|Shape|Group' in internal/gateway ok, and the
  three vets and gofmt again clean.
- go vet ./internal/gateway (darwin), GOOS=linux and GOOS=windows
  go vet -tags nogui ./internal/gateway, gofmt -l: clean.
- GUI: routing-sight (new, 5 languages) and i18n-keys in chromium on
  mote: ok. routing-sight and routing-shape in webkit on the Linux box
  (wsl-run): ok. WebKit on mote couldn't launch (browserType.launch
  timed out at 180s beside other sessions' webkit stuck 2h, routing-shape
  untouched failed the same), so its webkit leg ran on Linux instead.

Not tried: a real pi session against a real text-only DeepSeek relay
(no such account here); the fixture uses DeepSeek's literal 400 body.
The full go test ./... and the whole GUI suite were not run.
2026-10-29 17:23:24 +08:00
yetone 8701eb35ea routing: with several routes on the stage, each route's rows hang under its own heading (hoobnn on Discord)
hoobnn: "路由这里,会莫名出现两个没有使用的路由,并且鼠标悬浮,显示错误的
供应商". The screenshot's header read "DeepSeek-V4.1-Flash · 路由组 · 启用
3 个 · 3 个 Agent 同时在发" over five rows: the group's three (Volcengine
Ark, a DF Model account, Qwen China) and, between and below them, Pi's
zcode account and OpenCode's Kimi Code (China) key.

Cause: the stage shows up to four agents at once (520a2425f), and
rebuild() drew every staged route's seats in one column. The header names
the latest request's route alone, and nothing marked which rows were
another agent's route, so Pi's and OpenCode's direct providers read as two
unused members of the DeepSeek group.

Fix: when more than one route is on the stage, each route's rows hang
under a heading of its own, the same heading a group in the group has
(subNode), keyed by a route key no group id can spell. A group's heading
names the group, its ref and its routing; a provider's names the provider,
with its logo, and the model asked for, and no routing when it has one
key. The heading's tooltip says which agents send to it ("Sent by
{agents}"). It starts open and folds like a group heading, remembered
under route/<group or provider>. Fold runs, wires and depths follow the
row's path (route, then the groups in the group). One route alone looks
as it did. New words in zh, zh-TW, ja and de.

The hover: in code, each row's title is its own id (render() sets
[w.id, ...]), and the new test hovers Kimi Code's row and finds
"kimi-code-cn". I couldn't make a row show another's id. The likely
reading of "qwen-cn" over the Kimi row is a native tooltip that stayed
while rows moved under a still pointer, as routes came onto the stage and
left. That is inferred, not reproduced. With headings, rows move less
between routes, but a route coming or going still moves the rows below it.

Sibling: the panel's mini stage (pSeat/pDraw) draws each provider a try
went to, with no union of group members, so it has no such mix. Not
changed.

Test: internal/gui/tests/routing-stage-routes.test.cjs, with the report's
shape. DeepSeek Harness on the group (three members, in order), Pi on a
zcode account, OpenCode on Kimi Code's one key, all live. It checks one
route alone has no heading; three headings in order, each with its own
rows only, "Sent by" its agent, the group's "In order" and the lone key's
empty routing; wires; the hovered Kimi row's id; no spills; no page
errors. Chromium and WebKit, en zh zh-TW ja de, 1100 and 420px.

What was run (WSL magpie-desktop via wsl-run, mote via mote-run):
- the new test on the old code (client.js, routing.css and i18n.js put
  back): Chromium 0 of 10, every case times out waiting for 3 headings.
- the new test on the fix: 20 of 20, twice.
- the new test on the old code (origin/main 9b538a3f3 with only the new
  test file): WebKit 0 of 10, the same timeout.
- at the pushed head (d4866daf5 on origin/main 9b538a3f3): the new test and
  i18n-keys, 24 of 24, both engines.
- mote: go test -tags nogui ./internal/gui (budgets, compress,
  revalidate): ok.
- the whole GUI suite, Chromium and then WebKit (wsl-run, concurrency 4),
  was started on the pre-rebase head and is still running at push. Reds
  so far, none in routing: account-eye (ja), agent-panel-name-width,
  api-key-theme. Each is to be checked against origin/main alone and
  filed if it is new.
- No Go code changed; no full Go suite.

Broken by hand: the old code, above. While writing the test, its hover
check went red at 420px when the pointer landed while the view was still
scrolling to the row; the test now hovers in a viewport tall enough that
nothing scrolls.

Not tried: the real app with three agents sending at once (a fake
trace feed only); the reporter's own setup.
2026-10-29 15:34:16 +08:00
yetone 29185e3bbc gateway: a request held too long before routing leaves a report its user can copy
Jason on Discord (#general, v0.1.1995, AirbuildEnvironment over Codex's
/backend-api/codex/responses) got the 2m 504: "magpie held this request
for 2m0s without routing it to any provider ... report it with magpie's
log". The desktop app runs the gateway in-process and logs only to
stderr, so there is no log for him to send.

giveUp now writes a report of the held request to a small file in
magpie's cache (held/, folder 0700, temp file renamed into place, the
newest 5 kept). It holds the time, version, OS, the method and path, the
model and agent, how long it was held, each named wait with its time and
whether it was still under way (noteWait now takes a kind: body, body
room, decision model, image description, plugin hooks, JS middleware,
Codex reset, masking), the body room's state, the requests in flight,
and a goroutine profile (function names and lines only, cut at 128KB).
It holds no body and no headers. Route.Held names the file. On the
Routing page, the request's story then says a report was saved, with
Copy Report and Open Folder (Open Folder is left out in magpie web).
GET /api/gateway/held/{name} reads only a report's own name. The 504's
text no longer points to a log: it names Copy Report on the Routing page
and the folder. The log line names the waits too. i18n is in zh, zh-TW,
ja and de, and docs/subsystems/gateway-routing.md has the section.

What held Jason's request is not known from what he sent. The waits that
count before routing are: the body arriving (idle deadline only), body
room (up to 100s, then 503), the decision model (see the next commit),
plugin hooks (11s), JS middleware (250ms a hook), image description
(bounded by the request) and the Codex reset (20s). Slots, RPM and
upstream come after the route begins. A WebSocket upgrade gets a 426.
The report names the wait, so the next one says which.

Run:
- mote, at 57b21abd9 before the rebase: go test ./internal/gateway
  -run 'Unrouted|Held|...' passed. The full go test ./... -timeout 45m
  was cut off when mote dropped off the network (2 packages ok). The
  full suite then went to the Windows box (see the next commit).
- xiaomi-gpu (Windows), node --test: routing-held-report 50/50 in
  chromium and webkit, 5 languages, 1100/420px, app and web.
  routing-held-request and i18n-keys pass. All routing-* and i18n*:
  1742 tests, 94 reds, none in i18n*. The same files are red alone at
  origin/main 033b17baf (22 of 46 in WebKit), recorded on #4124.
- GOOS=windows/darwin go vet ./internal/gateway ./internal/gui,
  GOOS=linux go vet ./internal/gateway, go build ./... : ok.
Broken by hand: leaving Route.Held unset turned
TestUnroutedHeldReportSaved red ("names no report"). Dropping the
story's report line in client.js turned routing-held-report red in both
engines.
Not tried: a real held request in the real app. Linux vet of
internal/gui (cgo for Wails, cross-compiled). The GUI test on macOS
WebKit, since mote was unreachable.
2026-10-29 15:10:34 +08:00
yetone 0daf363325 gateway: a key resting after an outage is asked again in the background
heatonz on Discord: a key or provider paused after a failure stayed out
for its whole rest, even after its vendor was back. Only Try now got it
back early. probeOne asks only the resting candidate that comes back
soonest, so a key behind ready ones was never asked again early.

What changed:
- gateway/rest_probe.go: the background ask, with no setting.
  - Which rests it asks: a key's own rest from a failure that names no
    time (a 5xx, a 408, no connection), resting by backoff, at a vendor
    whose model list is asked over the network (provider.ListAsks).
  - How it asks: the vendor's model list, with the key and its p.Via
    proxy. A list costs no allowance.
  - When: 1m into the rest, then 2m, 5m and every 10m, each ask at least
    half a step before the rest ends. The rest is lifted as soon as the
    list answers, the way Try now lifts it (unsink, trace).
  - Cost: one list per resting key per step, so at most 4 lists in a
    10-minute rest.
- The loop runs from ListenAndServe. A Server whose loop isn't running
  (a test's) queues nothing. A loop that ends waits for the asks under way.
- Not asked: a Retry-After or ratelimit reset header, quota or credit, a
  rate limit, a refused key, a 4xx, one model's rest, a subscription's
  account, a plugin. Those still end on time.
  - Rate limits are left out on purpose. A model list answers while chat
    still gets 429, so lifting early would undo Sink and go around the
    vendor's limit.
- A list answers for the vendor, not for every model behind it. A key
  that fails again within 30 minutes of a lift is not asked again until
  it answers a real request (probeAnswered in served).
- Rest.Probed / KeyRest.Probed. The provider's key row and Routing's
  words for the try add "checked in the background, back as soon as it
  answers", in en, zh, zh-TW, ja and de.
- app.js stays under its budget with no raise: a shared hhmm helper, and
  resetUsedWhen folded into the identical stamp.
- docs/subsystems/gateway-routing.md describes it.

Tests:
- rest_probe_test.go:
  - lifted after one failed ask and one answered, asked with the resting
    key;
  - no ask again after a missed lift;
  - each excluded rest: never queued, 0 asks;
  - no loop, no queue; the loop waits for its asks, and a cut-short ask
    doesn't lift.
- gui/tests/rest-probed.test.cjs: 5 languages x 1100/420px x chromium and
  webkit, 40/40. Red on origin/main's assets.

Broken by hand on mote, each red:
- no lift: test 1 times out;
- no status check: refused key and bad request get asked;
- Retry-After ignored;
- no miss guard;
- no asks.Wait() in the loop's exit.

Run:
- go test -race -count=5 -run TestRestProbe ./internal/gateway: ok.
- mote: internal/gateway ok (636s); internal/provider ok.
  internal/gui TestMainWindowCorners/macOS_26_SDK is red on macOS 27,
  unrelated, #3949.
- Linux Go full suite (wsl-run, -timeout 45m) at 6cbd77608 (the same
  change on 157d575c3):
  - 72 packages ok, gateway ok (445s), provider ok;
  - root, cli and gui don't build there (no gtk4/webkitgtk-6.0 in that
    distro);
  - internal/agent reds are #4033, red at base too;
  - internal/library TestUpdateKeepsASkillChangedHere red once under load,
    passes 3/3 alone at head and base: #4106.
- gofmt -l clean. go vet on darwin (gateway, provider, gui), GOOS=linux
  -tags nogui ./..., GOOS=windows ./...: clean.
GUI:
  - The whole suite on mote was stopped at 744 tests: mote was at load 140
    from other sessions' suites, and browsers took over 180s to launch.
    The reds there were launch timeouts and one account-alias click.
  - Instead, the 141 files the change can reach (key-*, rest-*, routing-*,
    search-keys, codex-resets-used, usage-ledger, i18n-keys, plus the files
    red on mote), in both engines on Linux (wsl-run), at a6f01cf23 rebased
    on ddf31ca30: 2001/2096 pass. The same files at base ddf31ca30:
    1974/2056. The reds are in the same files at head and base, mostly
    WebKit.
  - Serial rerun of the files red only at head: head 200/211, base
    196/211, with the same files red on both sides. Filed as #4121.
    rest-try-now and routing-bodies are already #2564 and #2559.
  - rest-probed 40/40; codex-resets-used (stamp) 10/10.
  - mote at a6f01cf23: go vet for gateway, provider and gui ok; the gui
    Budget tests ok; TestRestProbe -race ok.

Not tried:
- a real outage at a real vendor;
- subscriptions and plugins, which aren't asked;
- a Windows run of the gateway package;
- a macOS full Go suite at the pushed head (mote was busy with other
  sessions' suites).
2026-10-29 05:13:53 +08:00
yetone 2fc2d53583 routing: the head's line keeps its height live, so a pick doesn't pull the list up
c5cdb043e (v0.1.1926) gave a finished request nothing took its own line
under the head ("Nothing took this request: …") where it had the
one-account hint. That line sits over the list, so in English picking
the WorkBuddy 400 of routing-failed-open (mythfish's case) shrank it
from three lines to one and pulled the list up under the click:
"picking the request moved the page", chromium and webkit en live.

holdMode keeps the line, live, as tall as the last three requests told
it, as holdStory does the story, keyed by width and language. A layout
is read only when the line's words or the width change (#3164), and the
head is told again once the steps' width is first known, so a pick
before the next second's telling is held too.

Run (mote):
- routing-failed-open at c5cdb043e: 2 of 8 red (en live, both
  engines); at 602ad84ad (before it) green; with this change green
  alone, beside held-request and mode-goes (108 pass, 0 fail), and
  under load beside rule-remove, rules-line, rule-drag and affinity
  (all failed-open and held-request cases ok).
- Every routing-* and click-scroll* file at the first version of this
  change (before the header retell): 1666 pass, 30 fail. All but two
  of the reds are in files red at 602ad84ad too (rule-drag,
  rule-remove, rules-line, rule-models, row-swap, steady,
  story-shrinks). routing-failed-open webkit en live was still red
  under that load, which the header retell fixes (green in the runs
  above); routing-many-keys' two reds passed in the next run
  (failed-open, held-request, mode-goes, many-keys, story-shrinks,
  steady: only steady's 2 and story-shrinks' webkit red, both red at
  602ad84ad).

Not run: the whole GUI suite; the Go suite (no Go change).
2026-10-29 01:50:14 +08:00
yetone ca221e115e routing: a pick lets the stage go live when the reader is back to newer requests
未寒 on Discord (#feedback, 10-28): the Routing page's stage stayed on
a 16:36 Mozilla request to qwenwork/flash, "The agent canceled the
request", headed "16:36 的请求是怎么路由的", while the requests list
under it went on with auto/deepseek-v4-flash at 17:08 and 17:09.

Cause: that head is a pick. A click on a list row, the errors stat,
the context card, Usage's openRoute or the tray's ?req= pins the stage
to one request. #1389 lets a pin go only when the request leaves the
60 the page keeps, so at a calm pace a pick holds for hours. A reader
who left for another app or another page and came back finds the
stage on a request they no longer remember picking, and reads it as
stuck.

Fix (plugins/routing/client.js): the reader leaving while a pick holds
the stage (window blur, another page, the window hidden) marks the
newest request then. Back in sight and focused, if a request newer
than the mark has come, the pin is dropped and the stage follows live
(followListed). This is checked in start() when the poll was running,
and in the poll's catch-up pass when it had slept out of sight, so
requests read only on return count too. Back to nothing new, the pick
stays. A reader who never left keeps it as requests come, as before. A
new pick clears the mark. Day mode and a replay are left alone. The
tray panel has no pin, so there is no sibling there.

Test: internal/gui/tests/routing-pin-away.test.cjs. The canceled
request is picked from the list. It holds while requests come, and it
holds after leaving and coming back to nothing new. The reader then
leaves while 8 more come, still within the 60, and comes back: the
head is "How the last request was routed", there is no Back to live,
the first row is pressed and the stage shows the newest model. Three
ways of leaving (another app, another page, the window hidden), en at
1100 and zh at 420, in Chromium and WebKit.

Run on mote at this head (rebased on c5cdb043e; main to 5a85a9836 changed nothing under internal/gui, and the two pin files ran again there):
- routing-pin-away: red on the old code in every case (the head kept
  "How the request at … was routed…Back to live"); green after.
- All routing-*, panel-routing*, i18n-keys, gui-zh-tw, usage-ledger,
  click-scroll and dates-gui-lang GUI files in both engines (132 files):
  1755 of 1793 pass. The 38 reds are in 9 files. Run alone, they are
  red the same way on an unchanged copy of main c5cdb043e (33 there,
  36 here, at mote load 70 to 200; the counts in the rule-editor files
  vary between runs): routing-row-swap #3799, routing-steady #3412,
  routing-story-shrinks #3954, usage-ledger #4078, routing-rule-drag
  #3789, routing-rule-remove #3094/#3096, routing-rules-line #3593,
  and routing-failed-open's en live case, which had no issue and is
  filed as #4105. routing-pin-away and routing-pin-leaves are green.
- go test -tags nogui ./internal/gui/ (TestCoreScriptBudget and the
  asset tests): ok. TestLoopGuardLeavesOrdinaryRepliesAlone and
  TestAntigravityTurnedAwayHintIsTheRoutingPages (they read
  client.js): ok.
- GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gui/...:
  ok. gofmt -l: clean. No budget raised.

Broken by hand:
- Dropping the poll's catch-up check: the another-page and
  window-hidden cases go red (the poll slept while away), and
  another-app stays green.
- Dropping the check in start(): the another-app cases go red in both
  engines.

Not tried: the real Wails window's blur and focus in WKWebView,
WebView2 and WebKitGTK. The test dispatches the window events and fakes
document.hidden. Not tried with the reporter's own gateway either.
2026-10-29 01:19:25 +08:00
yetone c5cdb043e6 routing: a request held before routing says so, not "0 on" and one account
Jason on Discord (v0.1.1818): the Routing card read "magpie · 0 on",
gave the one-account hint and "Nothing could take ." while his
ChatGPT Pro accounts were healthy. His client (AirbuildEnvironment)
sends Codex turns to /backend-api/codex/responses. A request held over
15s before routing (masking, Settings › Privacy) gets the unrouted
watch's placeholder route; codexBackend never called noteAsked, so the
placeholder had no model, and the card read its empty order as zero
accounts on and one account. The requests themselves were held, then
routed; only the page was wrong.

- codexBackend notes the asked model, as handle and gemini do.
- The card: an empty order says masking…/routing… (or nothing when
  done) instead of "{n} on", hides the chip, and its line says why
  (masking before routing, not routed yet, or the error it ended
  with). The one-account hint needs exactly one account on.
- New keys in zh, zh-TW, ja, de.

Run (mote, at c12d2f130's tree before rebase onto 298bfce59):
- go test -tags nogui -run TestUnrouted ./internal/gateway: ok.
  TestUnroutedCodexPathShowsItsModel is red with noteAsked removed
  (placeholder Model "").
- GUI: routing-held-request (new, 60 cases: chromium+webkit, en zh
  zh-TW ja de, masking/routing/ended, 1100 and 420px) and
  routing-mode-goes: 100 pass, 0 fail. With the old client.js the new
  file is 60 of 60 red.
- go test -tags nogui -timeout 45m ./...: 75 packages ok; the only red
  is internal/provider TestClaudeAccountServesModelsListedSinceItsFetch,
  #3174, unrelated.
- After rebase: gofmt -l clean, go build -tags nogui ./... ok.

Not run: the whole GUI suite (routing-*, i18n-*, gui-* files were
running, 35 ok and 0 not ok when pushed); a real AirbuildEnvironment
client; masking with a real local model.
2026-10-29 00:01:58 +08:00
yetone df9376592d routing: a group's member may offer several reasoning levels for the agent to pick among
Garydesu on X: "能不能让路由组里的模型设置多个可选推理强度,现在只能选一个或者整个
路由组的". A member was one fixed `:effort` or followed the group's levels.

A member's suffix may now join several levels with "+",
`provider/model:low+xhigh`, kept lowest first, each once. provider.MemberLevels
splits it into Member.Levels and leaves Effort empty, so the member isn't
fixed; one level is a fixed effort as before. The whole stays the member's
id, so rules, fast, off, weights, share and the CLI key it as any member.
The gateway fits the agent's ask to the member's own levels (groupLevels
returns the candidate's levels first; ofMember, the quiet check and the
trace see them), and the group lists them to agents (buildGroupEntries),
intersected with the other members' as usual. In the Routing page's group
editor the member's reasoning menu has "Several levels…", a menu that stays
open with each level ticked or not; a fixed level picked from the first menu
replaces the old one as before. i18n in zh, zh-TW, ja, de; CLI help and
docs/subsystems/gateway-routing.md say it.

Run on mote (mote-run). Rebased on efb55b5c9 (past e1721d640, which
changed the group editor) and run again there: provider, gateway, cli ok;
gofmt clean; GUI group-member-levels, group-member-fast,
group-member-weight, group-from-model-add and i18n-keys 53 of 54, the red
being i18n-keys' "masking…" from e296211b8, red on main (#4053). Linux
and Windows vet were clean at 7fe98c2af. Earlier, at the first base:
- go test -tags nogui -timeout 45m ./internal/provider ./internal/gateway
  ./internal/cli ./internal/tui ./internal/gui: all ok (gateway 525s).
  internal/cli again after the help wording below: ok.
- gofmt -l: nothing.
- GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., go vet
  ./...: clean (darwin prints cgo warnings only).
- Whole GUI suite (node --test "internal/gui/tests/*.test.cjs", both
  engines, load 140 at its peak): 13,931 tests, 119 red in 31 files. One
  was this change: i18n-keys' "a plugin's words are its own", because the
  CLI help said "the agent picks among them" too; reworded the help, and
  i18n-keys passes. The other 30 files, run alone at --test-concurrency=4
  at this tree and at its parent e8c7dddcb: the same files red on both
  (97 and 100 cases, the routing-rule ones a random subset each run, all
  waiting on clicks), each with an open issue (#3527 lists the pattern;
  segs-press-redraw #3922, routing-story-shrinks #3954).
  group-from-model-add, account-*, login-import and signin-* pass alone.
- group-member-levels.test.cjs: 30 of 30 (5 languages, both engines,
  1100px and 420px); group-member-fast.test.cjs 4 of 4.

Broken by hand:
- groupLevels without the member's levels: TestMemberSeveralLevelsFollowAgent
  red (asked high, sent high, not xhigh).
- buildGroupEntries without the member's levels: TestMemberSeveralLevels red
  (offered all four, not low and xhigh).
- main's routing client.js: group-member-levels red 3 of 3 (chromium en).

Not tried: a real agent picking among a member's levels against a real
vendor; the TUI (its reasoning toggle cycles a "low+high" member back to
following the group, unchanged code).
2026-10-28 18:52:39 +08:00
yetone e1721d6404 routing: a weighted group's editor sorts its members by weight once (Norcleeh)
Norcleeh (Discord #general) asked for a way to order a By weight
group's members by weight. The order matters there: it is the
fallback's when a model fails.

Now the group editor has a "Sort by weight" text button beside Add
another model. It shows while the group routes By weight and the order
would change. A press puts the named members heaviest first (no weight
counts as 1, equal weights keep their order, one switched off is
sorted too; a pattern's members stay after them) and draw()s. The
button then goes. It is a one-off reorder of the draft, saved with the
group's Save; no mode is stored. Its title says the order is the
fallback's. Strings in zh, zh-TW, ja and de. The routing plugin's
client.js isn't a core script; no budget changed.

Run (mote-run, at this head on a1f06bd78):
- group-member-weight.test.cjs, Chromium and WebKit, en/zh 1100px and
  en/de 420px: In order offers no sort. By weight it does and fits.
  The press orders glm-5 (6), gpt (3), kimi (2, off), o4-mini (1),
  each keeps its weight, the button goes, and Save sends that member
  order. Every new string has its four translations. 8/8.
- Red on origin/main's client.js: 8/8 fail (no button). Broken by hand,
  the button kept while sorted: 4/4 Chromium red at "sorted, it has
  nothing to do".
- The routing GUI files (group-*, routing-*, panel-routing*), i18n-keys and
  gui-de/ja/zh-tw, both engines, at load ~230: 1879 of 1913 passed.
  Adding the button into .rt-gadds made routing-intent-entry count 3
  buttons, so the row has its own class, rt-madds; that file passes.
  The reds left are in routing-flood, -levels, -row-swap, -rule-drag,
  -rule-remove, -rules-line, -steady and -story-shrinks. The same 27
  fail at a1f06bd78 without this change, and rule-drag, row-swap and
  steady fail 7/7 at 7fcf642ee. Each has an open issue: #2215, #3620,
  #3799, #3789, #3096/#3094, #3593, #3412/#1804 and #3954.
- go test -tags nogui ./internal/gui: ok. gofmt -l: clean.
- Again after the rebase onto 7fe98c2af: go build ./..., go test
  ./internal/gui ok; group-member-weight 8/8, routing-intent-entry 8/8,
  group-context 4/4. i18n-keys is 3/4: its "a plugin's words are its
  own" is red on main, from a masking.go comment that quotes "masking…"
  (e296211b8), not from these strings. Filed as #4053.

Not tried: the real desktop app, and a group with members by pattern
(those aren't sorted, by the code).
2026-10-28 18:33:46 +08:00
yetone 6e080ca044 gateway: every model in /v1/models says it takes tools, a routing group too
psikent on Discord: an SSH client judges what a model can do from its
list entry, and a routing group, whose id is the user's own name, said
nothing of tools, so the client handed it none. /v1/models and
/v1/models/{id} now give every chat row models.dev's tool_call: true
(beside the reasoning it already had) and OpenRouter's
supported_parameters (tools, tool_choice, and reasoning when it thinks),
which Kilo's and Cline's list readers use (kilo.go reads the same field).
magpie has no model that takes no tools (a call written as text is read
back as one), so a group's members all take them and the group says so.
No `capabilities` key: Cursor Private Inference reads it as an object,
Ollama and LM Studio as arrays of their own words; magpie's Ollama
/api/show already says "tools". Desktop's, Science's and the decision
models' lists are unchanged.

windy on Discord: a 1M DeepSeek group with a 128K Trae member. A group's
window and output stay its largest member's, images any member's, as
#712, #756 and ARNO's truncation report decided: the gateway sends a
longer conversation only to members with room (roomy, withRoom), and
Context: Smallest model's tells agents the smallest. The editor's Context
hint now names the member a longer conversation skips when the windows
differ ("…longer than 128,000 skips Trae CN · DeepSeek-V4.1-Flash…"), in en, zh, zh-TW, ja, de.
Compaction written to agent configs follows the same window (CompactFor,
CompactSet takes the smallest threshold the user set); unchanged.

Run (mote unreachable all session, so on the other test boxes):
- TestGroupListedTakesTools on Linux (wsl-run): green; red on the old
  gateway.go (a/m, b/m, group/g and /v1/models/group/g: tool_call false,
  supported_parameters []).
- group-context.test.cjs on the Windows box, Playwright 1.62.0,
  Chromium + WebKit, en and zh: 4/4 green; 4/4 red with the old
  routing assets (the hint named neither 128,000 nor the member).
- Every GUI file that opens the group editor (56) plus i18n-keys, both
  engines, on Windows: 816 tests, 792 pass, 24 red (793/23 on the run
  before the hint named a member's provider). The red files with the old
  assets: the same tests red (25). They are #3402, #3412, #3789, #3096 and name-suffix-saved's
  WebKit provider editor, not this change.
- Full Go suite, -tags nogui -timeout 45m, on Linux: all ok but
  internal/agent (7 install-detection tests), internal/proc TestTreeRSS
  and internal/gateway TestUploadStillUnderwayIsNotCutByHealthPing; each
  red at origin/main eb6d1d8d9 on that box too (#4033, #3909).
- gofmt -l clean.
Not tried: psikent's SSH client itself (not named yet), the GUI on macOS
WebKit (mote down), a real group in the running app.
2026-10-28 17:20:24 +08:00
yetone 9e33962c05 gui: Settings has Reduce motion, stilling magpie as the system's does (#3813)
CupOfBread asked for a switch that turns magpie's motion off to save
resources on the desktop, and linull24 saw the Routing page keep a
phone's browser busy. magpie already stills its animations under the
system's Reduce Motion: 46 @media (prefers-reduced-motion: reduce)
rules across app.css and the plugins' styles, and calm() in the
scripts. Settings -> General now has "Reduce motion" (Off / On) that
does the same without the system setting.

- settings.json keeps reduceMotion; boot.js passes it; a POST that
  leaves it out keeps it, as the other prefs.
- theme.js's holdStill(on) sets data-motion="reduce" on <html> and sets
  the media of every stylesheet rule written for reduced motion to
  "all" (and back when turned off), so the same rules apply and no CSS
  is written twice. layout.js calls it before the first paint when the
  saved setting is on; applyPrefs calls it on a change.
- calm() is true when data-motion is reduce too, so the scripts'
  motion (Routing's stage, Library, Usage) holds still with it.
- routing.css: the reduced-motion rule for the live dot was
  .rt-livedot, which lost to .rt-livedot.on's animation; it is now
  .rt-livedot.on, so the dot stands still with either setting.

Measured on mote (Chromium 390x844, 4x CPU throttle, live Routing
traffic, CDP Performance over 10s, two runs each): main-thread task time
0.18 and 0.22 s/s with it off, 0.090 and 0.085 s/s on; style recalc
0.021/0.025 off, 0.008/0.011 on.

Tests: reduce-motion.test.cjs (new, both engines): saved on, the
reduced-motion rules apply from the start (a probe's live dot has no
animation, calm() is true); Off restores them and posts false; On again
posts true. TestSettingsReduceMotion: off by default, kept by a POST
that leaves it out, cleared by false, in settings.json and boot.js.
The Settings row is in settings-general's list of rows.

Run on mote at this head (rebased on e8c7dddcb): go test -run
"TestCoreScriptBudget|TestAppScriptBudget|TestSettings|TestBoot|TestI18n"
./internal/gui ./internal/settings: ok (the core budget not raised);
GOOS=linux, windows and darwin go vet -tags nogui of both: clean.
reduce-motion, settings-general, i18n-keys, routing-live-calm,
codex-descriptions, codex-predictions, codex-titles and old-webkit:
61 pass, 1 fail, the Safari 15.0 styles check below.
gofmt -l: clean.

Not tried: the real Linux (WebKitGTK) and Windows (WebView2) apps; the
setting changes only which existing CSS rules apply. old-webkit's
"Safari 15.0" check is red on origin/main from c490165b1's :has() in
.proto-menu (#4020), not from this change.
2026-10-28 16:50:16 +08:00
yetone 5ced5b1aa0 routing: a wallet's row says what of it lapses first, as the Usage card does (#3964)
MYCF711's SuperMagic plugin (magpie-magicrew-auth daca18e) sends a
balance window 积分余额 with runsOut, and 今日 / 限时 / 永久 as aside
rows. The Routing page already showed all four rows, in the stage row's
tooltip and the account list's .wins line, both through cardOf/winsOf
(the Usage page's own readings). The row's own text said only
"6,291 积分 left". For a wallet seat, quota() now adds the Usage card's
runsOutText for the card's window of the same balance and unit:
"6,291 积分 left · 185 积分 expire 23:59". It is client only. The
Go side (allowanceOf, Weighed) is unchanged, because the aside rows are
display only and routing weighs the total.

Run (mote, at 7b63feb90 + this):
- routing-wallet-lapse.test.cjs (new, the reporter's literal windows):
  chromium + webkit, en/zh/zh-TW/ja/de, 1100 and 420px, 22/22 ok.
- Broken by hand (quota without lapses): 11/11 red in chromium,
  expected '750 积分 left · 50 积分 expire Thu 02:06', actual
  '750 积分 left'.
- routing-wallet-balance, usage-wallet-balance, i18n-keys: ok.
- Every routing-*.test.cjs (124 files) + the two above: red only in 12
  files that are red the same way without this change at 4655e1659
  (83 fails there) and that have open issues: routing-intent-entry
  #3408, routing-manual #3409, routing-pause #3410, routing-rule-effort
  #3411, routing-steady #3412, routing-row-swap #3799, routing-model-rest
  #2115, routing-rule-drag #3789, routing-rule-remove #3094/#3096,
  routing-rules-line #3593, routing-story-shrinks #3954,
  routing-wb-restricted #1905. Mote was at load ~16-28 with another
  session's suites.
- go test -tags nogui ./internal/gui/ (budgets): ok.

Not run: the full Go suite and the whole GUI suite (another session's
were on mote; this commit touches no Go). Not tried: a real SuperMagic
account, or the Windows/Linux app.
2026-10-28 12:40:16 +08:00
yetone 7dcc0aedc6 routing: a group's rules line up without a subgrid, as the requests do since #3731 (#3955)
Each .rt-rule was a subgrid of the rules list with a fit-content(50%)
conditions column, the shape gpboyer2's Safari 16 crash stack showed for
the request rows (#3731). Now the list is a flex column and each rule is
a grid of its own on 16px fit-content(50%) minmax(0, 1fr) auto. Its
conditions are at least --rt-condw wide: fitConds takes the property off,
reads each rule's conditions width under its own fit-content(50%), and
sets the widest, rounded up to 1/64px, on the list. It runs when the
rules are drawn, and a frame after the list or a rule's conditions
change size (ResizeObserver, disconnected on each redraw so rules drawn
before are not held) or a condition is typed into. Under 640px the
property is unused (min-width 0), as the layout there was its own before.

New test routing-rule-columns: no rule of the rules' CSS says subgrid;
in both engines and five languages, every rule's → and its conditions
start at one x at 1100, 900 and 700px; at 390px what a rule does is under
its conditions and nothing passes the editor's side; an intent typed
longer moves every rule's → right, and shorter again back left, still at
one x.

Run on mote (Playwright 1.62.0, Chromium and WebKit). At the rebased
head on origin/main 5ed6669ce: node --check client.js ok;
routing-rule-columns and routing-own-columns 16 of 16 ok, one at a
time; i18n-keys 3 ok, 1 red, "a plugin's words are its own", which is
#3897 (red on main since 7f827b3b0, not this change). Before the rebase,
at cc04ce68c: routing-rule-columns on the assets before this change
fails only its CSS check (the subgrid lines up as this does), and with
the min-width rule taken out by hand its four en/zh cases go red. The
seven routing-rule* / routing-rules-line / routing-own-columns files,
head then base back to back under another session's GUI suite (load
16 to 28): head 80 ok 33 red, base 87 ok 26 red. Of the reds only
on head, eight are routing-rule-remove; run alone one at a time it is
red 8 of 20 on base and fewer on head, the flakes filed as #3096 and
#3094. The rest (routing-rule-effort narrow #3411, routing-rules-line
under load #3593) are red on base too.

Not tried: a real Safari 16 on macOS 13 (no such machine here), so the
crash itself is not reproduced for the rules; the shape it had is gone.
2026-10-28 12:00:01 +08:00
yetone 7bdefe212f routing: the stage's pulses play again with no layout, and the list's heights keep only its rows (#3731)
gpboyer2 measured both on #3731. Each pulse on the stage (a node a
request passes, the caption, a failed try's row) took its class off, read
offsetWidth to start the animation again and put the class back: a
synchronous layout of the whole page, three or four times a request under
steady traffic. rerun() rewinds a running animation instead, and takes
the class off when it ends, so putting it on again starts it with no
layout. The heights the requests list measured were never dropped for
rows gone from the list, and every one was summed again on each draw;
now only the list's own rows are kept.

Not changed: the FLIP in the rows' reorder still reads offsetWidth once
per reorder, which is what starts its transition, and a found group's
flash (a click) still does.

Tests: routing-tick-no-layout.test.cjs (new) streams 24 trace answers in
Chromium and WebKit and counts reads of an animated node's offsetWidth:
19 on the old client.js, 0 now. With tick made a no-op by hand its other
check goes red ("the stage still pulses: 0").

Run at this stack's head 103631319 on main 0a7633136, on mote: the
routing GUI files with panel-routing, i18n-keys, old-webkit and
menu-input-scroll, both engines: 1625 tests, 91 red. The same files at
0a7633136 alone: 1618 tests, 94 red. Every red at the head is red at the
base too, apart from routing-rule-remove and rules-line subtests in one
language or the other, which flake in both (#3096, #3593); each red
already has an issue (#3409-#3412, #3799, #2115, #3789, #3402, #3403).

Rebased onto 69626580b (no routing change since 0a7633136) and run again
at the pushed head on mote: routing-own-columns, routing-tick-no-layout,
routing-day-window, routing-scroll-end and routing-live-calm, 61 of 61
ok, and go test -run 'Budget|Size' ./internal/gui ok.
2026-10-28 10:16:05 +08:00
yetone a1f0a6109a routing: the requests list lines up its rows without a subgrid, so Safari 16 stops crashing on it (#3731)
gpboyer2 found the cause: each .rt-req was a subgrid of .rt-reqs with
fit-content() tracks, and Safari 16's grid track sizing recursed on it
until the WebContent process died and the page reloaded, again and again
under steady traffic.

Now .rt-reqs is a flex column and each row is its own grid on
var(--rt-cols, var(--rt-tpl)). A hidden .rt-sizer grid at the list's
foot holds one probe per row shape (display: contents cells placed by
column), and fitCols reads its computed columns into --rt-cols: the fixed
ones rounded up to the layout's 1/64px, the flexible one minmax(0, 1fr).
A ResizeObserver on the probes' cells, deferred a frame so WebKit logs no
"ResizeObserver loop", refits when a cell's width changes. New columns
drop the rows' measured heights (listKey carries --rt-cols) but keep the
average, and metaFit measures with the columns of the layout it tests.

Found on the way and fixed here since the new key needs it: drawList
sized the gaps with the average from before it was recomputed.

The other subgrids of the same kind (.rt-rule, .sess-bar, .sess-skill,
.quota-windows .quota) are #3955.

Tests: routing-own-columns.test.cjs (new) fails on the old code (a
subgrid in routing.css) and checks, in Chromium and WebKit, en and zh,
at 1440, 1100, 940 and 700, that every route has a row and the rows'
columns line up. routing-day-window, routing-scroll-end and
routing-live-calm read the rows' own columns and skip the sizer.

Run at this stack's head 103631319 on main 0a7633136, on mote: the
routing GUI files with panel-routing, i18n-keys, old-webkit and
menu-input-scroll, both engines: 1625 tests, 91 red. The same files at
0a7633136 alone: 1618 tests, 94 red. Every red at the head is red at the
base too, apart from routing-rule-remove and rules-line subtests in one
language or the other, which flake in both (#3096, #3593); each red
already has an issue (#3409-#3412, #3799, #2115, #3789, #3402, #3403).
2026-10-28 10:13:14 +08:00
yetoneandMYCF711 0a7633136d routing: a skipped member's story line leads with its own logo (#3953)
A story line about a member the gateway skipped before trying it
(r.left, "API key is left out: this request is longer than its 200K
context window…") got no logo, or another member's: logoed walked only
r.order. MYCF711 found it and proposed walking r.left too, skipped
members first, with r.left in the logos memo keys; this ports that
(their branch MYCF711/magpie fix/routing-left-logos, 003611a02).

Changed from their patch: list order alone can't settle two members
named alike (an order key and a skipped account both "API key"). Left
first gave a failed order key's try line the skipped one's logo; order
first gives the skipped one's line the order key's. So a line now
carries the member it is about where it has one (a skipped one's line
via leftWhy, a try's via tried()), and that member wins a tie at the
same place; otherwise order before left. The memo keys take that
member's seat and every r.order + r.left logo.

Siblings checked: say()'s caption is plain text; the rows (3650) and
the stage list (1911) already read r.left; app.js has no story logos.

Run (mote-run, at 8bade6c5e):
- routing-log-icons.test.cjs, chromium + webkit, en/zh (+ the live
  case's en/zh/zh-TW/ja/de): 14/14 ok. New case: order [glm, DeepSeek
  key "API key", gpt], left [Zen "API key", 200K window], DeepSeek tried
  and failed; the 200K line must lead with opencode, the DeepSeek try
  line with deepseek-color.
- Broken by hand, each red: r.order only (skipped line got
  deepseek-color, the reporter's symptom), the reporter's left-first
  without the about member (try line got opencode), order-first
  without it (skipped line got deepseek-color).
- Every GUI file that reaches the Routing page (184 files with
  i18n-keys, 2375 tests): 98 red; the 15 red files run again side by
  side on a clean origin/main 8bade6c5e copy and this tree: 99 red on
  main, 93 here, the same files, under load ~100 on mote. Each has an
  open issue: #3897 (i18n-keys "Runs as"), #3402, #3408, #3409,
  #2115/#2658, #3410, #3799, #3789, #3411, #3094/#3096, #3593, #3412,
  #3954, #1905, #1345/#1948.
- go test -tags nogui ./internal/gui -run 'Budget|Size|I18n|Plugin':
  ok (client.js is the routing plugin's, not a core script).

Not tried: the real app with a real skipped Zen member; Windows/Linux
webviews.

Co-authored-by: MYCF711 <323101370+MYCF711@users.noreply.github.com>
2026-10-28 09:17:18 +08:00
yetone 8bade6c5e2 provider: a plugin's usage window can be a prepaid wallet's balance (#3950)
SuperMagic's accounts (mycf_711's magicrew plugin) are prepaid wallets of
points with no total. A plugin can now send a usage window as
{name, balance: 6291, unit: "积分"} with no used or limit.

- host.js passes a finite balance on (at least 0), anything else as null.
  plugin.UsageWindow.Balance and provider.QuotaWindow.Balance are *float64.
- quotaOfPlugin keeps the figure and does not make the window Text or
  Aside, so routing knows the account with no Used invented. allowanceOf
  copies it into Limit.Balance; an empty wallet counts as used up.
  Allowance.Left(model) is the least balance of the windows that count
  the model.
- weighRouted fills routes.Seat.Left and Seat.LeftIn (the account's
  provider and unit). Smart, pace and usage (least used) put the seat
  with more left first where they would otherwise tie (byLeft), only
  when every seat with a balance shares one LeftIn: balances in two
  units or two providers are never compared. Tiers still come first.
- The Usage card, the Routing page (Weighed.Balance: the small row's
  text, no bar, a why sentence, the account list), magpie accounts and
  the status line show the figure, "6,291 积分 left", never a share.
- Docs: provider-plugins (new section), gateway-routing,
  providers-accounts, plugin-runtime, host.js typings and the site's
  plugins page (en, zh, ja).

Run, at base f13aafa87, on mote:
- go test -tags nogui -timeout 45m ./...: 72 packages ok; red were
  TestQuotaSpanCarriesEveryWindowField (this change's: its fixture now
  sets Balance, green after), and on the unchanged base too
  TestWSLColdPlaceOpensNothing (#3924), TestFetchAsksASharedBaseOnce and
  two siblings (#3854), TestTUIFetchesSubscriptionModels (#3919), all
  fixed on main since and run again after the rebase; and
  TestPluginStreamsPastTheBudgetWait (#3946), green alone on both.
- GOOS=linux and GOOS=windows go vet -tags nogui ./internal/..., go
  build ./..., gofmt -l: clean.
- New tests: TestPluginWalletBalanceIsAReading, TestAllowanceLeftIsTheLeastBalance,
  TestPluginHostPassesABalanceOn (through real Bun and host.js),
  TestWalletsGoByWhatTheyHaveLeft, TestWalletLeftWithinItsTier,
  TestWalletWithMoreLeftGoesFirst, TestQuotaCell's balance cases;
  usage-wallet-balance.test.cjs and routing-wallet-balance.test.cjs,
  34 of 34 in Chromium and WebKit, en zh zh-TW ja de, 1100/900/420/390px.
- GUI: every quota*, usage*, panel*, routing*, i18n* and tray* file (220
  files, 2928 tests), concurrency 4: 130 red, in 21 files. Those 21 files
  run again on an unchanged base copy and on this change, concurrency 2:
  the same 19 files red on both (126 and 131), the differing subtests
  being routing-rule-remove / rules-line / intent-entry flaps that go
  both ways. Each is filed (#3679, #2115, #3410, #3404, #3411, #3897,
  #1905, #3096, #3593, #3408, #3409, #3799, #3789, #3412, #3947, #3415,
  #3414, #1345); routing-story-shrinks had none and is #3954.

After rebasing on origin/main 833f51adc, on mote: Linux and Windows vet,
go build, gofmt clean; go test -tags nogui of internal/routes, provider,
gateway, cli, plugin, gui (the script budgets), agent and tui: all ok;
the two wallet GUI files and i18n-keys: 37 of 38, the red being
i18n-keys' "Runs as" (#3897, not this change).

Broken by hand, each red then restored: quotaReport's Balance copy
removed (TestQuotaSpanCarriesEveryWindowField red); byLeft always nil (routes and
gateway tests red); host.js's balance line removed (host test red);
quotaOfPlugin's balance copy removed (provider tests red); app.js and
client.js at base (both GUI files 34 of 34 red, "0% used" / "已用 0%").

Not tried: a real SuperMagic account or the magicrew plugin (it isn't
in the community repo; it needs to send balance), Windows and Linux
GUI apps, and the WebKitGTK app.
2026-10-28 08:28:56 +08:00
yetone 8fff54dab7 routing: a group in a group left on Smart is routed as the outer one (#3847)
mycf_711 (#3847): an outer group set to Free first held a group whose
routing was left blank (Smart); the inner group's free seat was tried
after its paid one, as if Free first stopped at the inner group.

provider.Group.Within: in membersOff's walk, a nested group with no
routing of its own takes the outer group's when the outer one pools its
members (Smart, Free first, Fastest, ... ; not In order, By weight or
Manual, which try each member whole by its own order, #576). A group
that sets a routing keeps it. The gateway, the trace's Subs and the
Routing page all read membersOff, so they agree; GROUP_NEST's help
sentence says so (zh, zh-TW, ja, de).

Run (mote): go test -tags nogui -run 'FreeFirst|Group' ./internal/gateway
./internal/provider ok; GOOS=linux and GOOS=windows go vet -tags nogui
on both packages ok; go build -tags nogui ./... ok; gofmt -l clean.
Broken by hand: without the Within call
TestFreeFirstReachesAGroupInItLeftOnTheDefault is red (paid seat first),
green with it.
Not tried: the reporter's own groups in the real app.
2026-10-28 04:18:21 +08:00
yetone f2b4b98948 routing: a pool's account list is the name's tooltip, not the row's (#3785)
renderPools set the account list (p.who) as the title of the whole
.rt-pool row, so the Routing and Stays segment buttons, which carry no
title of their own, inherited it: hovering either showed the account
names instead of nothing about the button. The title now sits on the
name cell (nm.title), the element that names what the accounts are
behind. The text is unchanged.

Patch by skygunner (fix/3785-pool-tooltip, a5f315a3), with only the
code comment reworded; MYCF711 found the bug and withdrew their own
copy for this one.

Run at this commit's tree (base a42d90d7d), on mote:
- routing-pool-tooltip.test.cjs (new): red 4 of 4 with client.js put
  back to origin/main ("the row itself carries no tooltip"), green 4 of
  4 with the change, chromium and webkit, en and zh.
- Every GUI file whose fixtures draw a pool row: rate-limited-sink,
  routing-manual, routing-js, routing-time-went, routing-mode-goes,
  routing-pool-tooltip, routing-steady, routing-weight-chip,
  stays-strict: 118 of 122. The 4 reds are routing-manual's webkit
  cases (#3409) and routing-steady's two (#3412); both files fail the
  same 4 at origin/main a42d90d7d run alone.

Not tried: the other ~160 GUI files that open the Routing page (the
change touches only the pool row's title); a real hover in the app.
2026-10-28 03:24:02 +08:00
yetone 68bbcc01c5 routing: wire lengths and ends are read from their d, not getTotalLength (#3813)
linull24 (#3813): the Routing page used too much over mobile remote.
Reproduced it with a 390x844 phone viewport at 4x CPU throttle, three
live and three done requests coming every 400ms: the main thread was
busy 0.88s of each second. A 10s profile had getTotalLength at 1.66s,
the largest single item: while rows slide (the 520ms after each
rebuild, when layout() runs every frame) every wire's d is new each
frame, and measure() asked the browser for each one's length just to
find its ends, then pose() asked again for each leg of every flight.

- measure() no longer asks for a length up front.
- A wire's ends and the way it heads there are read off its d
  (wireEnds: magpie's own absolute M/L/Q/C), the browser only for
  any other d.
- A path's length is its points' (flat(), which pointAt already
  used), so pointAt reads s along them directly; the browser's
  getTotalLength is kept for a d flat() can't read.

Measured (same probe, same load, main's client.js swapped in for the
"before"): layouts 590/s -> 235/s, script 0.187 -> 0.144 s/s, main
thread 0.89 -> 0.84 s/s at load ~100; 0.71-0.74 s/s at load ~10.
getTotalLength is gone from the profile. A per-frame check that each
row's wire ends at the row's own centre while rows slide: worst 0px
over 1546 frames, as on main.

Tried and dropped: drawing a slide's frames from the boxes of the
last layout, each moved by its row's eased slide. Rows also move
during a slide for reasons that aren't the transform (a row above
changing height), and the wires were off by up to 153px.

Not changed: the rest of a busy page is the browser's own style,
layout and paint of the motion; with reduced motion it is 0.31 s/s.

GUI (both engines): every routing-*, panel-routing* and idle-ticks
file at 6ce0f14b9 with this change. Reds were in 12 files, all rule /
pause / model-rest timeouts; the same 12 files with main's client.js
gave 89 reds against 91 here, the same tests, timeouts landing on
different subtests at load 40-110. Filed already: #3096, #3094,
#2115, #3410, #3408, #3593, #3411. routing-busy-frames, routing-busy,
routing-flood, routing-idle-frame and idle-ticks pass.

On the rebased tree (parent b5582912a, which changed app.js): routing-busy-frames, routing-busy, routing-flood, routing-idle-frame, idle-ticks, routing-steady-garbage, routing-held-dot and routing-js, both engines, 65 of 65 ok; go test -tags nogui -run 'Budget|Script' ./internal/gui ok.
2026-10-27 16:46:48 +08:00
yetone 8fba65d0bc gateway: what masking took a request is kept, and shown as Masking in its time
fremontdango on Discord asked, after the request that sat as "routing…"
while it was masked, how long masking took. Now each request keeps it.

noteRedacting adds up the time from the first masking at once to the
last's end (redaction.spent); maskingMs gives it in ms, at least 1 when
there was any, never more than Own, magpie's own time before the request
went out (splitSent), since masking happens inside it. It goes on the
route (Route.Masking, /api/gateway/trace) and in the usage record
(Record.Masking, masking_ms; packedRow's int32 fits in its padding, so
TestRowsOfOneSessionShareAShape's 216 bytes are unchanged, and the
process-private snapshot carries it). It is a duration, no text.

The Routing page shows it as magpie's "Masking" part, first in where the
first try's time went (timeParts, renderSteps); the Usage page's detail
splits it out of "In magpie" (page.js). Both use the core "Masking"
string every language already has (脱敏, 脫敏, マスク, Maskierung).

Why masking can be slow, measured on this machine (go1.27, M-series):
the rules are linear, ~0.25 ms/KB. redact.MaskJSON over a Claude Code
shaped body: 283 KB 35 ms (secrets) / 63 ms (+ personal data); 511 KB
70 / 122 ms; a dense 402 KB with 7,821 hits 173 ms with personal data,
144 ms with the user's words too. Through the gateway (redactedHits,
secrets + personal, 402 KB dense) 145 ms the first time, 123 ms again;
noteMasked ~2.6 ms. Doubling the body doubles the time; nothing
quadratic or repeated per hit. So a request held "routing…" for 15 s or
more (unroutedShow) while masked is the local model (Settings → Privacy
→ Find with a local model, internal/pii): it reads each text it hasn't
seen (a new turn's tool results are the misses), one model turn at a
time, so requests queue behind each other (#3682: 480 KB took 90 s on an
RX 470/580). No change to masking's speed here; the phase and the time
now say which it was.

Run at this head, on origin/main 9ae791221 (Go, M-series macOS):
- go test -timeout 45m ./internal/gateway ./internal/gui ./internal/redact
  ./internal/usage: ok (gateway 425s, gui 99s); ./internal/masking and
  ./internal/pii ok at the pre-rebase head 3a4a13d04
- gofmt -l internal: clean; go vet ./..., GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...: clean; go build: ok
- go test -race -count=3 TestMaskingIsAPhaseWithItsTime,
  TestNoMaskingNoMaskingTime: ok
- GUI, chromium and webkit: routing-masking (every language) 10/10,
  usage-ledger-detail 6/6, i18n-keys and routing-levels green. The whole
  routing-*, panel-routing*, usage-ledger* and i18n-keys set: 1,824
  tests, 96 red at load ~47, in 15 files. The first run's i18n-keys red
  was this change's (a Go comment quoting the core word), fixed in the
  commit before. The other 14 files, rerun two at a time at this head
  and at origin/main 9ae791221: the same files red on both (89 here, 86
  there; routing-rule-remove alone 5 red here, 7 on main). Each has an
  issue: #2115, #3410, #3411, #1905, #3593, #3408, #3096, #3094, #3001,
  #3104, #3786.

Broken by hand, each red: spent not added (route and record Masking 0),
no t.Masking on the route, no Masking in the usage record, the snapshot's
put/take of Masking (TestRowsOfOneSessionShareAShape), timeParts without
Masking or renderSteps without the first try's masking
(routing-masking), the Usage page without the Masking line
(usage-ledger-detail, 3 red).

Not tried: a real local model (Settings → Privacy → Find with a local
model) on the reporter's Windows box or any GPU, so a long masking was
only held by a fake masker; the Codex backend's usage record has no
Masking yet; the Windows test box wasn't used.

Reported by fremontdango on Discord.
2026-10-27 08:08:23 +08:00
yetone 3300616492 gateway: a request being masked has the phase redact, and its row says masking
fremontdango on Discord: a Claude Code request to deepseek/deepseek-flash
sat on the Routing page as "routing…" for a long while that it was
actually being masked (Settings → Privacy). The placeholder route shows a
held request after 15s with nothing to say what holds it.

noteRedacting (redact_phase.go) wraps every masking, at the one place
each route masks through: redactedHits and maskTextHits in redact.go
(chat, Codex backend, search, images, video, System One, embeddings,
audio, count_tokens). It keeps noteMasking's exemption from the unrouted
limits, sets the request's phase to "redact" (notePhase, on
/v1/magpie/concurrency) and puts Route.Phase "redact" on the route that
shows it, its own or the unrouted placeholder, until the last masking at
once ends. A route that is done never carries it. It holds no text.

The Routing page says "masking…" for such a row, in the list and the
panel row, in every language (plugins/routing/i18n.js: 脱敏中…, 脫敏中…,
マスク中…, maskiert…).

Run, in a copy of this commit's tree:
- go test -race -count=2 -run 'TestMaskingIsAPhase|TestNoMaskingNoPhase|Unrouted' ./internal/gateway: ok
- routing-masking.test.cjs, chromium and webkit, en zh zh-TW ja de: 10/10
- gofmt -l, go vet ./internal/gateway: clean
The full suite is in the next commit's body, at the pushed head.

Broken by hand, each red: noteRedacting without notePhase (phase ""),
redact.go back to noteMasking (phase and route ""), showLocked without
the phase; waitWord back to "routing…" (5/5 GUI red per engine).

Not tried: a real local masking model (the Windows box, its GPU); a
masking that starts after a route is already shown (showRedacting at
the start) has no test that fails without it.
2026-10-27 08:08:23 +08:00
yetone 95f674008a routing: a Smart row with quota left says why another went first (demonyins on X)
demonyins on X: under Smart, an Open Design "Design Plan Go" account at
75% left sat grey beside the Claude Max account that answered a
claude-haiku-5.5 request. Its row said only "75% left · renews in 20h",
and read as "paused with 75% left". Nothing was paused or rested: Smart
puts first, among accounts under 90% used, the one whose allowance
renews soonest (cmpRenews, the biggest window first), so a Max week
renewing in ~9h went before a Design Plan week renewing in 20h. The
page said none of that.

The row of an account Smart weighed with quota to spare, behind the one
tried first, now says why: "75% left · renews in 20 h · one renewing
sooner goes first" when the first renews sooner, or "75% left ·
conversation kept on another" when session, turn or cache affinity kept
the conversation on the first. behindWhy returns nothing (the row reads
as before) when the first is resting or a fallback, when the two weren't
weighed together, when a whole-member group split them, under a rule or
a sealed task, or when the first is still being learnt or isn't in the
fine tier. Text only, no new layout. zh, zh-TW, ja and de translated.

Run, at the pushed tree (rebased on origin/main d56c14e95):
- routing-behind-why.test.cjs (new): 42/42 green, chromium and webkit,
  en/zh/zh-TW/ja/de, 1100px and 420px, no horizontal overflow, no page
  errors. i18n-keys green.
- Every routing-*, panel-routing* and i18n-keys file at concurrency 4:
  1540 tests, 1450 pass, 90 fail. Each red file run alone at this tree
  and at an origin/main d56c14e95 copy: the same count on both for
  intent-entry 3, manual 2, pause 14, row-swap 2, rule-drag 1,
  rule-effort 14, steady 2, story-shrinks 5, wb-restricted 10,
  model-rest 20; keys-fold and kind green alone. rule-remove and
  rules-line are flaky on both, varying languages each run, all
  waitForFunction timeouts: rule-remove main 7/7, this tree 6/12 at load
  5-6 (#3094, #3096); rules-line main 3, this tree 5 then 4. Filed:
  #3408/#3410/#3411/#3409 (intent-entry, pause, rule-effort, manual),
  #2115 (model-rest), #3786 (row-swap), #1612/#2658 (keys-fold).
- gofmt -l clean; go vet, GOOS=linux go vet -tags nogui and
  GOOS=windows go vet ./internal/gui ok; go test ./internal/routes ok
  (no Go changed).

Broken by hand: the new test against origin/main's assets
(MAGPIE_ROUTING_ASSETS) is 21/21 red, the row reading only "75% left ·
renews in 20 h".

Not tried: a real Open Design account (the fixture is the screenshot's
shape: Max at ~80% used, Design Plan Go at 25%); the Accounts list
(.rt-act) is unchanged; the Linux WebKitGTK app.
2026-10-27 04:31:37 +08:00
yetone 1885c607e2 gateway: Antigravity answers Codex's switched threads and Hermes' old persona with no setup
Antigravity answers some agents' system prompts with a fake 429 "Resource
has been exhausted", whatever quota is left. Jodiezzzzzz on X (10-27): a
Codex thread begun on GPT-5.x and switched to an Antigravity model got 429
again and again. zgoodz on X: "antigravity在Hermes里一样429". v0.1.1625
told the Codex case as a 400 with "start a new chat", which isn't zero
setup.

What Google matches, each tried on a real Antigravity account on 10-27
(in the system instruction, any case):
- "x-anthropic-billing-header:" (Claude Code)
- "built on Anthropic's Claude Agent SDK" ("running within the Claude
  Agent SDK" goes through)
- "You are Codex, an agent based on GPT-5" / "..., a coding agent based
  on GPT-5"
- new: "Hermes Agent, an intelligent AI assistant created by Nous
  Research", Hermes' earlier default SOUL.md, kept by anyone who edited
  their SOUL.md. Hermes' current default ("You are Hermes Agent, built by
  Nous Research") goes through.
Each goes through with a zero-width space after its first letter.
"Y​ou are Hermes Agent, an intelligent..." still fails, so the
break goes inside the matched phrase itself.

Now codeAssistBody puts that zero-width space into each matched line
(antigravityCloak), in the system instruction only, and only for an
Antigravity account. Gemini CLI's account on the same envelope, and
every other provider and protocol, get the prompt as the agent wrote
it. The text added names nothing; it is one U+200B per line.
`magpie provider set antigravity prompt=as-written` (PromptAsWritten,
kept through Save/withPicks and the GUI's save) turns it off. Then the
v0.1.1625/#2156 fallback stands: a 400 with a hint (now one for Hermes
too, in the Routing page's five languages) and Antigravity skipped for
6h in a group.

Default-on, as the community antigravity-cloak middleware's README
says, changes what Google is sent so a request it means to refuse goes
through. That may be against Antigravity's terms. The owner asked for
it ("破解过 antigravity 提示词让其可以在别的 agent 中使用"), and it is
scoped to Antigravity accounts with an off switch.

Run at this tree (rebased on origin/main):
- go test -count=1 -timeout 45m ./internal/gateway/ ./internal/provider/
  ./internal/cli/ ./internal/gui/: gateway, cli and gui ok; provider
  died in TestUnreadLoginsWriteErrorsKeepCredentials ("close of synctest
  channel from outside bubble" in filememo.Forget), #3632, red on main
  since 091153bf; with -skip of that test, provider ok.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok. go build: ok.
- GUI (node --test, Playwright 1.62, chromium and webkit):
  routing-ag-turned-away, i18n-keys, gui-ja, gui-de, gui-zh-tw,
  routing-js, panel-routing: 45 pass, 0 fail.
- Broken by hand: with the cloak skipped, TestAntigravityAnswersHermes
  AndCodexByDefault and TestOnlyAntigravityIsSentThePromptBrokenUp go
  red; without withPicks' line, "prompt=as-written isn't kept".
- Real account, sandbox HOME with only the Antigravity login copied,
  this build on 127.0.0.1:3496:
  - real Hermes Agent (AIAgent, sandbox SOUL.md = the old persona plus
    one line): "OK", 200. With prompt=as-written: 400 with the Hermes
    hint. Back on default: 200.
  - real Codex 0.162.1: a thread begun on gpt-5.5 (against a local
    fake Responses server), then `codex exec resume <id> -m
    antigravity/gemini-3-flash` through this build: "OK". With
    prompt=as-written: 400 with the Codex hint.
  - a synthetic switched Codex Responses thread, with and without
    web_search: 200.
  - opencode, droid, kimi, pi, gemini-cli, qwen, crush, goose, amp and
    openclaw identity sentences: never refused, as written.
Not tried: Claude models on Antigravity (the sandbox account's Claude
quota is spent, so the Claude Code lines were checked on Gemini 3
Flash only); other agents' whole prompts, only their identity lines;
the Windows box; the whole GUI suite.

The plugins repo's antigravity-cloak 0.1.2 adds the Hermes line for
magpies before this one.
2026-10-27 04:16:20 +08:00
yetoneandMYCF711 6afbe3f304 routing: a member too small for the request keeps its row and says why (#3749)
roomy leaves out a member whose model's context window the request is
longer than, and the trace dropped it from the order with no word of
it: on the Routing page its row went away, and the reason was only an
absence. Now the trace lists it in the route's left with Weighed.window
set to the window it lacked. Its row stays, faded as a seat held out
is, and says "request longer than its 200K window · passed over"; the
why list says it is left out because the request is longer than its
context window, and is asked only once every one with room is out of
its allowance (en, zh, zh-TW, ja, de). When the last resort does ask
it, its row moves from left to the order with window cleared, as
askUnlisted and unhold move theirs.

MYCF711's patch (pr/small-seats) added a Route.Small list and a row
map fix. This takes their finding but not the shape: left already
carries seats not asked (unlisted, capped, out of credits), so a new
flag on Weighed reaches the page, the session copies and the last
resort without a second list, and the row map bug they fixed doesn't
exist on main. Limit: roomy fills smallW only when the order has one
row per candidate (pl.order parallel to the candidates); a member left
out otherwise still shows only by its absence, as before.

Run: go test ./internal/gateway -run
'Roomy|TooSmall|Small|Window|Trace|Left|Unhold|AutoReset' ok;
go test -timeout 45m ./internal/gateway/...
./internal/provider/... at fcf2a5271 plus this change: gateway ok
(426s); provider crashed in TestUnreadLoginsWriteErrorsKeepCredentials
(synctest close outside bubble, #3632) and with it skipped is ok. gofmt -l clean; GOOS=linux go vet -tags nogui and
GOOS=windows go vet of ./internal/gateway clean. go test
./internal/gui -run 'CoreScriptBudget|I18n|Strings|Plugin' ok.
tests/routing-small-seat.test.cjs (new), chromium and webkit,
en/zh/zh-TW/ja/de at 1100px and 420px: 11/11 each. The routing, panel-routing and
i18n GUI files, both engines, concurrency 3, load 40-280 from other
sessions: 1468 tests, 1410 pass, 58 fail. The reds are in
routing-pause (#3410), routing-rule-effort (#3411), intent-entry
(#3408), keys-fold (#1612, #2658), live-patch (#3637), rule-remove
(#3094, #3096) and the unfiled ones in #3786, plus seven more files
(agent-hue-not-red, columns, order-unknown, rule-remove, levels,
ctx-fold, many-keys). Those seven alone, one at a time: 68/81 here,
69/81 on origin/main d56c14e95, with only rule-remove red on both
(13 and 12). None of the red fixtures builds a left: list.
Again at the pushed head, on f92db4cdd: gofmt, linux/windows vet,
the gateway -run set above and the gui Go tests ok; routing-small-seat,
routing-free-seat, routing-held-member and i18n-keys 68/68.
Broken by hand: TestMemberTooSmallIsNotAsked red with smallW not
added to Left, and TestMemberTooSmallIsTheLastResort red with Left not
pruned after the last resort; routing-small-seat 0/11 on the client
without this change.
Not tried: a real request past a real 200K member's window in the
GUI; the trace was built by the gateway tests and the page by fixture.

Co-authored-by: MYCF711 <MYCF711@users.noreply.github.com>
2026-10-27 03:02:50 +08:00
yetone d9a8148d7c routing: Speed first sends a request to the provider or key that answered the model fastest lately
joeliu96872540 on X: when one model is reachable through several API
channels, they want an option that sends each request to whichever has
been answering fastest, because they compare channel speeds by hand
today. Speed first (`fast`; `fastest` and `speed` also work) is a new
routing beside Free first. It applies to a provider's keys and accounts
(provider editor › Routing) and to a group of one model on several
providers (Routing page › group › Routing).

How it decides. When a streamed answer ends, gateway/speed.go records two
numbers for that account or key and model (restID): the time to first
token and the output tokens per second, as usage.DecodeOf computes them
for the Requests page. Each is a decayed average with a 20m half-life.
After an hour with no answer the record goes stale, and the store holds
at most 4096 records. This is O(1) at the answer choke point, beside
servedCandidate. For a pool routed by BySpeed, weighRouted reads one map
entry per candidate, and only for that pool. The usage history is never
read on a request.

routes.Fastest ranks each awake seat by its estimated time to a
200-token reply: TTFT + 200/TPS. A seat that reported no TPS gets the
median TPS of the others. Seats within 10% of the fastest in their band
keep their listed order, so near-ties don't swap on every request.
Seats with no recent measurement go after the measured ones. One request
in five, counted per pool, goes first to an unmeasured seat, rotating
among them, so each gets measured again. Resting seats go behind the
awake ones, and used-up seats behind those. Rests and failover are the
same as for every other routing.

The request trace gets lateTtft and lateTps, and the row-story sentence
says "answered m fastest lately: first token in 0.8s, 60 tokens a
second". It has a variant for a probe turn and one for when no seat has
been measured yet. i18n covers zh, zh-TW, ja and de. Also updated: the
CLI (`magpie group|provider set <id> routing=fast`, plus a new
`routing=` pair on provider set that refuses manual), the TUI name, the
rotation plugin's Sub, docs/subsystems/gateway-routing.md,
plugin-runtime.md, docs/reference.md and site start.html (en, zh, ja).
There is no new layout: it is one more item in the existing pickers.
app.js stays under its budget with no raise.

Tests:
- routes/fastest_test.go:
  - ordering: fastest first, slow writer loses, alike keep order,
    resting and used-up, median pace, none measured;
  - the probe turn at 5, 10, 15 and 20, rotating between seats;
  - a resting seat never gets a probe turn.
- gateway/speed_test.go:
  - decay, staleness and per-model records, with an injected clock;
  - a group of slowv and fastv routed fast: after the speeds are
    measured and seeded, the request goes to fastv with lateTtft set;
  - the same group routed in order still goes to slowv.
- cli: parseRouting and the provider routing= pair.
- GUI routing-speed-first.test.cjs: the row story for measured,
  no-pace, probe and none, in en, zh, zh-TW, ja and de, in chromium and
  webkit: 40/40.

Broken by hand:
- Fastest returning the listed order: the routes tests and the gateway
  group test go red.
- noteTrySpeed removed: "the streamed answer wasn't measured".
- The client.js case renamed: routing-speed-first 0/20 in chromium.

Run at b5a5caff2 (base 5b4dec58e):
- `go test ./... -count=1 -timeout 45m`, alone on the machine, at load
  130-230. Every package is ok except:
  - internal/provider: TestUnreadLoginsWriteErrorsKeepCredentials
    crashes with "close of synctest channel from outside bubble"
    (#3632, open);
  - internal/gui: TestMainWindowCorners and
    TestTrayCellClickReleasedPanel are killed at their deadline under
    load (#1936, #2645).
- gofmt -l is empty. go vet is ok on darwin, on GOOS=linux with -tags
  nogui, and on GOOS=windows for ./internal/....
- GUI files the change reaches, both engines, every language they test,
  all ok: i18n-keys, gui-de, gui-ja, gui-zh-tw, routing-save,
  routing-save-keeps-the-row, builtins, panel-routing,
  panel-routing-pick, panel-routing-providers, panel-routing-hidden,
  routing-key-windows, key-weight, key-weight-fit, group-member-weight,
  routing-weight-chip, account-arrange and routing-speed-first (40/40).
- routing-group-strategy was 4/18: the menu now has 9 items and the test
  still counted 8. Fixed in this commit; rerun, it is 18/18.
- routing-save-blank (a webkit click timeout) and routing-columns (zh
  "side by side") each failed one subtest at load ~200. Rerun alone,
  they are 4/4 each. Both are already filed (#1924, #1612).

Rebased on 8f023b511, where upstream changed gateway.go, app.js, client.js,
the routing plugin's i18n.js and gateway-routing.md; the rebase was clean.
At this head I reran gofmt, go build ./... and go vet (darwin, linux
nogui, windows) on routes, gateway and cli, and go test for routes, cli,
provider and gateway (the routing and speed tests) and for gui -run
Budget: all ok. The GUI files i18n-keys (4/4), routing-speed-first
(40/40) and routing-group-strategy (18/18) also passed.

Not tried:
- A real run against several channels of one model. Speeds come from
  real answers, so the first minutes after a start are in listed order
  plus probes.
- A non-streamed reply is not measured, a sub-millisecond TTFT is not
  counted, and a restart forgets every speed.
- The Windows runtime: only go vet ran for it.
2026-10-27 01:37:38 +08:00
yetone b5d17b26e0 gateway: Antigravity's 429 to Codex's GPT-5 prompt says why and rests nothing, on the web-search path too (Jodiezzzzzz on X)
From Codex, every call to antigravity/claude-opus-5-5 failed with
"exceeded retry limit, last status: 429" while dsh worked on the same
account. The call was an agent_created_thread, and the vendor said
"Resource has been exhausted (e.g. check quota)".

Cause: a Codex thread begun on a GPT-5.x model keeps "You are Codex, an
agent based on GPT-5..." as its first developer message after /model,
resume -m or a fork, and magpie lifts it into systemInstruction.
Antigravity answers that line with a fake 429, whatever quota is left,
as it does Claude Code's (#666). Codex also sends a web_search tool every
turn, so for an Antigravity model magpie serves search itself (translate
-> searchReply -> askTranslated), and that path passed the bare 429 back:
no hint, no 400, so Codex retried to its limit.

- antigravityTurnsCodexAway: the two Codex GPT-5 opening lines count as
  a turned-away prompt; antigravityHint picks the Codex hint for them.
- antigravityRound wraps the search path's ask, so its 429 and an
  in-stream refusal get the same 400, hint and no rest as translate's.
- antigravityForeseen returns the hint, so a group skips Antigravity for
  the next 6h saying which prompt.
- The Routing page shows the new hint (routing/client.js HINTS) in en,
  zh, zh-TW, ja and de.
- Rest: none. The refusal is about the prompt, not the account (Fail
  "prompt"); a second account answers the same.

Plugins: middleware-antigravity-cloak 0.1.1 (plugins a52d1b3) breaks
the two Codex lines with U+200B. Its body says "npm had 0.1.0": wrong,
the package is not on npm; dist had 0.1.0 and now has 0.1.1 (6fd1438).
No mover applies.

Real account (owner's Antigravity, sandbox HOME copy, gateway built from
this branch) and real Codex 0.162.1:
- codex exec resume <a gpt-5.5 thread> -m antigravity/gemini-3-flash:
  before, 429 retried to "exceeded retry limit"; after, one request and a
  400 with the Codex hint; route try (429, prompt), no rest.
- A new Codex chat on the same model: 200.
- The two lines with U+200B after the first letter: 200; whole: 400.

Broken by hand:
- antigravityTurnsCodexAway returning false: the Codex tests go red
  (Codex got 429; the group's skip doesn't say why).
- The antigravityRound wrap removed: the search=true subtests go red
  ("Codex got 429").

Run:
- go test -count=1 -timeout 45m ./internal/gateway/: ok (476s, at
  865df2472; main's next three commits touch only GUI files).
- go test -count=1 -timeout 45m ./internal/gui/: ok (230s, at the pushed tree on a6d7e02c7).
- gofmt -l: clean; go vet ./internal/gateway/ for darwin, linux, windows.
- GUI, chromium and webkit: routing-ag-turned-away, i18n-keys, gui-ja,
  gui-de, gui-zh-tw, routing-wb-refused, routing-blocked 41/41; at the
  pushed tree routing-ag-turned-away, i18n-keys, routing-steps-cap and routing-js 34/34.
- Rebased on b9ab17231 (routing client.js): routing-ag-turned-away,
  i18n-keys, routing-free-seat 45/46, the red webkit zh-TW `.rt-day`
  click timeout at load 163 (#3781's class); routing-ag-turned-away
  alone 20/20 after. go test -run 'Budget|I18n|Hint|Routing' on
  internal/gui and internal/gateway: ok.
- Rebased again on 68ee4117a (gateway: gemini_schema, unrouted,
  masking wait): gofmt, vet x3, and go test -run
  'Antigravity|CodeAssist|Search|Gemini|Unrouted|Masking|Translate|Continu'
  ./internal/gateway/ ok; the whole package was not run again at this
  tree.
- Under load 89-150: TestTrayCellClickReleasedPanel killed at 20s
  (#2645), routing-js webkit zh (#3774), panel-routing and
  routing-zcode-blocked webkit zh click timeouts (#3781). All pass alone.

Not tried: Claude Opus itself (the sandbox account's free-tier Claude
quota was spent while probing, so gemini-3-flash stood in; the prompt
check is model-blind); the cloak installed in a running magpie; the
Windows box; the full GUI suite.
2026-10-27 01:33:53 +08:00
yetoneandMYCF711 b9ab172318 routing: a seat whose model costs nothing says free, not "100% used" (#3763)
On the Routing page a seat serving a model its vendor gives away
(Weighed.free, OpenCode Zen's *-free models under Free first) read
"100% used" with a full bar: the account's windows are what the rest
of it costs, not this model, so the one seat that can always answer
looked spent. Its row now says "free · costs nothing" (zh, zh-TW, ja,
de too) and draws no bar. A resting free seat still says its rest
first, and a paid seat beside it still says its share.

MYCF711's patch (pr/free-seat) built the case on free seats with no
routing, which the gateway never sends: .free is set only where
weighRouted weighs by it, so a real free seat always carries its
routing and read "100% used", not "all but used up". The test is
built on that real shape. Not taken from the patch: the green status
colour (UI restraint; the word says it) and the `low` change, which
no real free seat reaches. Their German string would have failed
their own test's /verbraucht/ check; this one is "kostenlos · zählt
nicht zum Kontingent".

Run: tests/routing-free-seat.test.cjs (new), chromium and webkit,
en/zh/zh-TW/ja/de at 1100px and 420px, 22/22. go test ./internal/gui
-run 'CoreScriptBudget|I18n|Strings|Plugin' ok. The routing,
panel-routing and i18n GUI files ran at concurrency 6 under load
280-300 from other sessions: 49 timeouts in 12 files, none of whose
fixtures has a free seat, and the run was stopped there. Those 12
files again, one at a time: 50 ok, 5 red in two
files: routing-intent-entry's "Add a rule makes a rule by intent" at
1100px (red the same alone on origin/main ca9b5048e, 2 of 8; #3408)
and routing-keys-fold's "flies to the fold" in chromium ja and de
(red alone on origin/main ca9b5048e too, 5 of 32; #1612, #2658).
i18n-keys 4/4. Again at the pushed head, on a6d7e02c7: routing-free-seat
and i18n-keys 26/26, the gui Go budget/i18n tests ok.
Broken by hand: old client.js, the test is red ("100% used"); with
the status line kept and only the bar check removed, 11/11 red in
chromium.
Not tried: a real OpenCode Zen account in the GUI.

Co-authored-by: MYCF711 <MYCF711@users.noreply.github.com>
2026-10-27 01:04:53 +08:00
jayswu ca9b5048e3 routing: a request tried on many keys keeps its steps in a box of 200px, so the list below stays where it was (#3764)
A trace tried on 40 keys says a line or two a key, so .rt-steps grew
to ~2500px and pushed the request list a screen down; clicking between
it and a one-key request moved the list by that much each time
(hheei's analysis in #3764). The list now holds at most 200px (eight
or so steps) and scrolls in itself; short stories start at its top as
before.

jayswu's patch (their branch gui/cap-routing-steps-height, ported here
since the repo takes no outside PRs). One change to it: a different
request's story starts scrolled to the top, and that reset now runs
before renderSteps' "nothing changed" return. In the patch it ran
after, so two requests whose stories read alike (the same keys
refused the same way) kept the first one's scroll.

Run at base 479de8900 plus this change, then rebased on 865df2472
(nothing under routing/ or app.js changed between them):
- new tests/routing-steps-cap.test.cjs, chromium and webkit: 2 of 2
  ok, again at the pushed head. Broken by hand: without the CSS cap, red ("the story's box grew
  to 2518px"); with the reset where the patch had it, red ("another
  request's story opened scrolled down", 400 !== 0).
- go test -tags nogui ./internal/gui/: ok (71s).
- every routing-*.test.cjs plus i18n-keys, --test-concurrency=4 at
  load ~100: 531 ok and 5 red when this was written (the run goes on).
  Of the reds, routing-intent-entry is #3408; routing-affinity-cache-
  write, routing-idle-frame and routing-js each pass whole when run
  alone and are filed as #3772, #3773 and #3774.

Not tried: the real app with a real 40-key provider; the steps box is
CSS only and the test draws the real page.
2026-10-27 00:46:24 +08:00
yetone 834935149a routing: a request still going is patched in its row, not made again, so the page holds still under traffic (#3731)
gpboyer2 (#3731, v0.1.1579): with requests coming, the Routing page kept
redrawing, its stage, caption and request list jumping so nothing could
be read; idle it was still.

Measured on main 4a33cf0a9 with a probe (MutationObserver on
#view-routing, plus animationstart), 12 requests listed, then one still
going answered by the trace every 150ms, as under traffic:
- idle, 5s: 25 nodes put in and 25 taken out, 30 attribute writes. The
  countdown's second ran rebuild(), and header() replaced the head's
  nodes and wrote the mode line and each agent's name, sub and title
  whatever they said.
- one live request, 5s (41 answers): 217 nodes in, 219 out, 824
  attribute writes (nearly all the same value), and the row's rtlive
  pulse started over 62 times. rowOf made the request's row again
  whenever its signature changed, and a request still going changes it
  on each answer (its tokens), so the row and its pulse came in afresh
  4 to 8 times a second: the flashing.

Now rowOf patches the row it has (morphRow, as context.js's morph does
for the Context card), and the head, the agents' nodes, the wires'
viewBox, the list head's titles and aria (setAttr), the hub's title and
the packet's cx/cy are written only when they change. Same probe after:
idle 0 writes of any kind; one live request 0 nodes made again (2 taken
out: the packet's flight ending), 177 attribute writes, 0 pulse
restarts, in Chromium and WebKit.

Not changed: the stage still follows the newest request, so with
several agents at once it shows each in turn (by design; pinning a
request holds it), and the issue's "Pause live" switch and fixed stage
height (#2598) are not added here.

Test: tests/routing-live-calm.test.cjs. Idle three seconds the page
gets no write; with the live request answered again and again the row
is the same element, says the new tokens, its pulse never restarts and
no node is put in afresh. Green in chromium and webkit; with
client.js reverted to 4a33cf0a9 both red (rows made again, pulse
restarted).

Run (rt3731 worktree):
- At 4a33cf0a9 with this change: go test -timeout 45m ./internal/gui/
  ok (176s). Rebased onto e9c1066c4 (no routing file changed between):
  the same run red on TestRestartHandsTheGatewayOver only ("1 of 2
  requests during the restart answered", #3451, the update handover);
  run again with the budgets, -count=3: ok 3 of 3, TestCoreScriptBudget
  ok. routing-live-calm.test.cjs at e9c1066c4: 2 of 2 ok.
- GUI tests/routing-*.test.cjs, whole, at this change and at 4a33cf0a9,
  both cut at 1500s under load 100+: head 509 ok 4 red, base 462 ok 4
  red; every red at head is routing-intent-entry's "Add a rule makes a
  rule by intent" (#3408), red alone at both, different subtests each
  time.
- 30 row, stage and head files alone at this change: 458 ok, 9 red:
  routing-live-patch's folded subtests (an extra 0% context part, red
  the same alone at 4a33cf0a9: 4 ok 6 red, #3637) and routing-keys-fold
  "flies to the fold" in webkit zh/ja/de (#1612, #2658).
2026-10-26 23:21:30 +08:00
yetone 77f860105c routing: a flowing wire is drawn in a layer of its own, so WebView2 doesn't redraw every wire each frame (#3164)
On Windows the Routing page with an 800-key group open ran at 31 fps.
A flowing wire (stroke-dashoffset animated) sat in the one svg of every
wire, 993x36215 px with 803 paths, and Chromium re-rasterized that whole
svg on the GPU each frame: CrGpuMain was busy 5s in 5s, 3.6s of it in
RasterDecoderImpl::DoRasterCHROMIUM. Hiding the wires svg gave 118 fps,
taking the dash animation off the wires 102 fps; WebKit (macOS) was
never slow here.

Now flowNear draws each flowing wire by a copy in .rt-flows, an svg over
the wires with will-change: transform, with the wire's d, --agent and
the dashes it worked out, and hides the wire itself (.flown: hidden,
no animation). The look is the same; the svg of every wire no longer
changes while a request flows. Reduced motion stops the copies too.

Real WebView2 (Edg/155, Windows 11, Radeon 8060S), the magpie window at
1281x1128 CSS px, dpr 1.1, a sandbox HOME with two providers of 499 and
299 keys in one group, both folds open, a request every 0.3s through a
fake upstream; v0.1.1587's release exe against this commit built with
GOOS=windows:
  steady 15s x3   31 fps, 89-94 frames >40ms  ->  114 fps, 4-9 >40ms
  scroll 12s      58 fps                       ->  88 fps
  fold+unfold 4s  41 fps                       ->  103 fps
The same injected by hand into the old page first: 38 -> 48 fps with
the copies in a plain svg, 94 fps with will-change, so the layer is
what does it.

Test: routing-answered-still checks that each flowing wire has a copy
with its d, animated, in a will-change layer, the wire itself hidden
and still, and that nothing is left once the request is done. Without
this change .rt-flows doesn't exist and it times out.

Run at this commit (rebased on origin/main 5a94eec3a, which touches
nothing under routing): routing-answered-still 20 of 20 alone in
chromium and webkit. Eleven routing GUI files at concurrency 3 against
the base 44a626bed under load ~74: 127 pass / 45 fail here, 123 / 49 on
the base; the reds are rule-editor files that fail the same on the base
(#3408). routing-keys-fold had 2 reds here under that load (its "3
resting" wait, not a wire) and is 32 of 32 alone 3 of 3. go test
./internal/gui ok; GOOS=linux and GOOS=windows go vet -tags nogui ok.
Not tried: WebKitGTK.
2026-10-26 19:31:27 +08:00
yetone 2620dc319f gui: Routing's countdowns, Usage's refresh look and the lanes' read tick only while in sight (#3185)
#3185 reports magpie's Energy Impact while nobody uses it. In the real
app (sandbox HOME, main window open on Providers, panel hidden) the two
WebKit WebContent processes woke ~5.9 and ~6.0 times a second. A census
of every setInterval in WebKit over 30s idle found three that fired from
anywhere, drawing nothing:
- routing/client.js's 1s countdown tick (30 in 30s),
- usage/page.js's 1s look at the refresh period (30 in 30s),
- app.js's refreshLanes every 2s (15 in 30s), which returned at once
  with no lane pill in sight.
Each now runs only while its page (or a lane pill) is in sight and stops
itself otherwise: Routing's starts again from start() when the page is
seen, Usage's from its view's hidden attribute, visibilitychange and
focus, the lanes' from laneText drawing a pill and visibilitychange.

Measured on the built app (go build -tags production, sandbox HOME,
`magpie app`, 90s warm-up, then 120s of proc_pid_rusage wakeups):
- before (e5dd86965): WebContent 5.93 and 6.01 /s, main 6.69 /s
- after: WebContent 1.61 and 0.93 /s, main 7.70 /s
The main process is unchanged: its threads are Go's (sample + per-thread
CPU: ~10ms CPU in 30s, ~0.03%), and a Go trace of the new build shows
~2.6 goroutine starts/s, mostly the minute loops lined up at :10 and :40
and the 2-min forced GC. That is left to its own change.

Test: tests/idle-ticks.test.cjs counts each interval's ticks by script
and period under Playwright's clock: on Providers none of the three
ticks in 10s; on Usage its look ticks and Routing's doesn't; on Routing
the reverse. Red on e5dd86965 in both engines ("plugins/routing/
client.js ticked out of sight, 10 !== 0"), green here.

Run at this head (rebased on origin/main e5dd86965):
- go test -count=1 -timeout 45m ./internal/gui: ok (budgets included;
  app.js 1,326,086 under 1,326,105, core scripts under 1,542,418)
- GUI, both engines: idle-ticks, i18n-keys, lane-limit, usage-refresh,
  quota-curve, quota-holds, sess-agent-strip, usage-head-steady,
  click-scroll, routing-time, routing-time-went, routing-reset-deadline,
  routing-auto-reset, usage-card-refresh, usage-refresh-flight,
  usage-loops, routing-idle-frame, routing-hidden-stage,
  panel-routing-hidden, routing-js, routing-sessions,
  usage-focus-steady: all pass.
- routing-steady (2 red) and routing-live-patch (6 red) fail the same
  on origin/main e5dd86965 run alone: #3412 and #3637.
Not tried: the window minimised or closed (WebKit's own throttling), and
Linux/Windows webviews; the change is plain JS timers.
2026-10-26 14:59:13 +08:00
yetone 098ac9696d routing: with 200 keys or more only those near sight are in the list (#3164)
With both groups open (800 keys) every update laid out, read and moved
every key, longer than a frame in WebKit. From 200 keys on, a run of
keys far from sight is now one gap li as tall as they are (place), and
a key in it is given the box it would have there, so its wire is drawn
as before. Scrolled half a screen on, or when layout finds the view
moved, the list is made again around where it is, keeping what is in
sight where it was. put() moves only the nodes out of order, so a fold
held where it was clicked doesn't move with a re-place. A gap is a new
li each time, never one used again for other keys, so app.js's click
hold can't keep a gap that now stands for other rows (app.js unchanged).

The stage's ResizeObserver lays out in the next frame: layout() reads
the rows, and rows coming into sight change #rt's height by a fraction
of a pixel, which WebKit reported as a ResizeObserver loop.

Run at c158b0439 (origin/main, just fetched) + this change:
- routing-many-keys.test.cjs (now also scrolls to the foot, checks a
  wire ends at each key in sight, and clicks the second fold mid-list
  shut and open, checking it stays where it was clicked): 6/6 in both
  engines in six runs, the last three with the fold check (the last two
  at this exact tree). Before the rAF it was red in WebKit 3 of 3. The
  fold check also passes with gaps used again; the jump that made me
  keep gaps out of the hold isn't reproduced by any test.
- TestCoreScriptBudget ok; click-scroll, i18n-keys, quota-holds,
  view-middle-autoscroll 34/34.
- routing-*.test.cjs together: 55 reds, under load. Each red file run
  alone here and at c158b0439: no file redder here. intent-entry 3/4,
  live-patch 6/6, manual 2/2, pause 14/14, rule-effort 14/14,
  rule-remove 4/7, steady 2/2 (here/main), all filed (#3408-#3412,
  #3637, #3094, #3096); busy-frames, groups-jump, keys-fold, levels,
  mode-goes, row-two-lines, rules-line 0/0.
- Bench, 800 keys both groups open, WebKit, 15s of scrolling: 901/901/901
  frames vs 896/890/891 before; worst jank 457/440/362ms vs 833/930/835ms.

Not tried: the real Linux app (WebKitGTK).
2026-10-26 13:20:58 +08:00
yetone 19253f67bc routing: a flowing wire is dashed only near what is in sight (#3164)
A wire to a key hundreds of rows down is ~18,000px long, and WebKit
stroked every dash of it again on each frame it flowed (.live's
dashoffset animation), keeping Routing under 50 fps with both groups
open. Each live wire now gets a stroke-dasharray that is the usual
"3 5" only from a screen above to a screen below what is in sight,
started on a multiple of 8px so it stays in step with the whole
wire's, and a gap elsewhere. The edges move in steps of 200px, so
scrolling redashes a wire only now and then. layout() records where
the stage and the view were (it reads them anyway) and the view's
scroll events track the scroll, so flowNear forces no layout of its
own.

Where a wire crosses those edges is measured from its own d (magpie's
M, L, Q and C, each bend walked in 16 steps, edges moved out 64px).
A first version asked WebKit's getPointAtLength, which cost ~3.8ms a
call, 780ms per 15s with 800 keys: a wire's d changes with most
updates, so a cache missed 147 of 179 times. Measured from d it is
13ms per 15s.

Run:
- Sandbox magpie app, sandbox HOME, fake upstream under load, Routing
  with both groups open (~900 rows), first version, WebKit paired runs
  (old and new at once, 20s, 5 pairs): frames 913/914/936/912/893 ->
  1012/1018/1029/1004/979 (about +10%).
- Page-route mock (routing-many-keys' 500 + 300 keys, a request every
  300ms, both folds open), this version against v0.1.1558's client.js,
  WebKit, 15s, 3 pairs at once: frames 840/843/844 -> 870/876/875,
  on time (<18ms) 507/538/568 -> 660/670/668, jank over 16.7ms
  1799/1693/1638 -> 1221/1187/1189ms. Chromium 901 -> 901 (60 fps).
- Coverage in the mock, WebKit and Chromium, wheeled to scrollTop 0,
  4000, 9000, 15000, 22000, 30000, 2000, 0, read 40ms and 400ms after:
  every point of every live wire inside the view (2824 sampled) lies
  inside its dashed window. The first try of measuring from d missed
  long straight L steps (a lane 5000px down got a window of 64px) and
  this check caught it; crossings are now interpolated inside a step.
- GUI: all 108 routing*.test.cjs files at this change, both engines:
  1341 pass, 47 fail, in 7 files that are red the same on c0985122b
  run beside it (intent-entry 4/4 vs 4/4 on a second pair, live-patch
  6/6, manual 2/2, pause 14/14, rule-effort 14/14, rule-remove 6/7,
  steady 1/1), each filed: #3408, #3637, #3409, #3410, #3411, #3096,
  #3412. routing-many-keys passes.
- node --check on client.js.

Not fixed: WebKit is still below 60 fps with both groups open. Hiding
rows past 40 gains more again, so the rest is the number of rows laid
out (rebuild alone is ~690ms per 15s); drawing only the rows in sight
is the next step on #3164.
2026-10-26 09:15:53 +08:00
yetone c0985122b3 routing: the story's width is the one its observer last read (#3164)
holdStory read steps.clientWidth on each of the story's ~10 draws a
second, and each read laid the whole page out again first. The width
now comes from the ResizeObserver already on steps, which runs after
layout and so reads it for free; it fires on the first layout and on
every change of width, which is all holdStory keys on.

Run at 014680033 + this change, WebKit, the bin3164 sandbox app under
load.sh (60 routes, ~800 keys), two folds open, 10s, two runs each:
- holdStory 346 / 373 ms -> 170 / 200 ms (105-114 calls)
- renderLog (includes it) 618 / 662 ms -> 430 / 503 ms

GUI, each file alone, concurrency 2: routing-story-shrinks 10/10,
routing-day-window 30/30, routing-bodies 10/10, routing-pin-leaves
22/22, routing-failed-open 8/8, routing-purpose-state 4/4. Broken by
hand (the observer no longer sets the width): routing-story-shrinks
0/10.

Stacked on 9787ca436, routing-story-shrinks and routing-model-rest
together: one run had 1 red whose log wasn't kept, so it is unnamed;
four runs after it, logs kept, 30/30 each.

Not tried: the real app window.
2026-10-26 05:12:51 +08:00