Commit Graph
182 Commits
Author SHA1 Message Date
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 6af83172d3 gui: the masking demo shows no video where WebKitGTK can't play one (avk458 on X)
On Omarchy (Arch + Hyprland) without gst-plugins-good, opening Masking's
"How masking works" aborted WebKitWebProcess about 3s later: WebKitGTK
2.52.6 gives every <video>, muted ones too, an autoaudiosink, which lives
in libgstautodetect.so ("no such element factory autoaudiosink", then a
SIGABRT). The window was left frozen on its last frame ("一点就崩溃再点
magpie就卡死了").

Cause: b90e81da1's noVideo was only in GET /api/settings. The page's
state.settings comes from /api/state, which never carried it, so a demo
opened before Settings was visited set the webm src. The GUI fixture put
noVideo into /api/state's settings and hid it.

Now boot.js says noVideo (app only, not a browser tab) before the page
paints, and demo.js reads window.bootPrefs.noVideo; the poster shows
instead. Also, for BoyC338's memory question: folded, or with the page
left, the video lets go of its source (removeAttribute src + load), so
no decoder or buffer is held; opened again it goes on from where it was.

Run:
- mote: GUI masking-demo, masking-records, i18n-keys in Chromium and
  WebKit: 116 pass, 0 fail.
- mote: go test -run 'TestBootSaysNoVideo|TestBoot|TestSettings|
  TestFontSettingsAPIAndBoot|Budget' ./internal/gui ok; gofmt -l none;
  vet for darwin, GOOS=windows, GOOS=linux -tags nogui ok.
- WSL magpie-desktop: go test -tags gtk3 -run 'TestBootSaysNoVideo|
  TestGstAutodetect|TestWebkitDefaults|TestSettings' ./internal/gui ok.
- Real app on omarchy, v0.1.1840 release: Masking > demo row aborted
  WebKitWebProcess (coredump 07:10:10 UTC), window frozen. Built this
  tree with make release-linux in WSL and ran it there: demo opens with
  the poster and animates, fold/reopen, Agents and back to Masking all
  respond; no coredump, no autoaudiosink line, both web processes alive.
These ran at base ea53eb126; rebased onto 05ed578bd (redact/gateway
changes, none in internal/gui) and the budgets run again before push.

Broken by hand:
- demo.js reading state.settings?.noVideo: the poster test is red in
  both engines.
- hold() commented out: the folded test is red in WebKit.
- boot flag removed: TestBootSaysNoVideo is red.

Not tried: a Linux system with gst-plugins-good (the video path there
is unchanged); arm64 Linux. Recovering a window whose web process died
(web-process-terminated) is not handled by magpie or Wails; not in this
commit.
2026-10-28 15:25:53 +08:00
yetone a41d0d5098 redact: the demo's notebook has a square icon and its entries under the header
The owner's screenshot of the masking demo's "小鹊的小本本" box: the
notebook icon was stretched tall, and the two entries overlapped the
subtitle and each other.

- The icon carried the class "acc", which app.css already styles as an
  accounts row (flex, min-height 38px, padding), so the 22px tile came
  out 38px tall. It is xq-acc now; none of the demo's other short class
  names (on, done, hot, ok, hl, far) has an app.css rule of its own.
- The entries were placed at fixed tops (40 and 81) under a header that
  is ~41px tall in CJK fonts. They are a flowing list now, after the
  header: each entry is its placeholder pill over its value, 5px apart,
  and a highlighted entry gets a soft background instead of colliding.
  The flyers already land on the values' measured positions, so the
  animation follows.
- German's title "Notizbuch der kleinen Elster" wrapped to two lines
  in the 220px box and pushed the last entry 14px out of it (the
  existing no-clip check caught it). It is "Notizbuch der Elster".

Test: masking-demo's layout test checks every box icon is 22×22 and
that each notebook entry starts at least 4px below what is above it.

Run at this tree (a463b3ede + this change), on mote:
- masking-demo + masking-records, both engines: 110 of 110.
- gui-de, gui-ja, gui-zh-tw, i18n-keys, mask-actions, mask-emails,
  masking-demo, masking-records, redact-kinds, redact-rule-edit,
  redact-rule-row, redact-shape, redact-words-any-case,
  redact-words-whole: chromium 259 of 259; webkit 135 of 136. The red
  was mask-emails' page.goto at its 5s default on the Routing page,
  at load ~80; alone it passes 3 of 3 here and 2 of 2 on origin/main
  a463b3ede. Filed as #3995 (the class of #3525).
- Screenshots of the notebook at the demo's end in zh dark, en light,
  de light and ja dark, both engines: square icon, entries under the
  header, nothing clipped.

Rebased onto 58fb3a778 (it adds a Windows modal-backdrop rule to app.css),
then run again at the pushed tree: masking-demo, masking-records,
i18n-keys and gui-de, both engines: 117 of 117. 60520ddb3 (moejs's module path, no GUI
file) landed after; the push is rebased onto it.

Broken by hand: the old demo.js and redact.css with the new test are
red in every language (icon 22×38, gaps false); with only the class
renamed, the old fixed-top entries are still red (gaps false, false).

Not tried: the real desktop app; the change is CSS and DOM order in a
page the GUI suite loads as the app does.
2026-10-28 14:39:34 +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 98e23350f1 gateway: a key's limit lines are read again while the page is open
Young (Discord #feedback, v0.1.18xx) reset his gateway keys' usage
(three keys held to 2-3 models, $30 per 5 hours, $153 per 7 days and a
token cap per 30 days) and their lines read "$0.00 / $30.00" from then
on, while Usage's gateway-key section showed the same keys spending.

The cause is in the GUI: the Gateway page read /api/caller-keys, where
each key's used limits come from, only on a visit to the page (the
`open` hook). Coming back to the window and Refresh re-read providers
(`render`) but not the keys, and nothing ticked, so a page left open
after Reset usage kept the $0.00 it drew then. The app reopens on its
last page, so it could read $0 for days.

Now refreshGatewayKeys reads the keys again from `render` (the window
back, Refresh) and every 15s while the Gateway page is in sight and a
key has a limit, as Usage's own timer does (#3185). The list is drawn
again only when the keys changed, and never over a key being added,
renamed or its limit edited, nor while an action is on its way.

The gateway side was checked first and counts right: a probe test with
Young's key shape (model scope incl. a group, $ and token limits),
reset, the budget cache dropped as a restart does, and requests on
chat/completions, messages and responses, streamed and not, counted
every call into each limit's window. The probe is not committed.

Test: internal/gui/tests/gateway-key-used-live.test.cjs, Young's key
shape, chromium and webkit, en and zh: the line goes from $0.00 to
$9.93 on window focus, to $12.50 on the timer, and an open limit editor
keeps its typed value and focus through both.

Run on mote:
- the new file: 4 of 4 ok.
- every gateway-*, connect-* GUI file and i18n-keys, both engines
  (262 tests): 259 ok. The 3 reds are the same on the base without
  this change and filed: gateway-caller-keys webkit en and
  gateway-key-models chromium/webkit en at 560px (#3797), i18n-keys
  "Runs as" (#3897).
- go test -tags nogui -timeout 45m ./...: 76 packages ok, exit 0, at 5ed6669ce plus this change.
- after rebasing on 6f0e40572 (two commits, neither in the gateway
  page): go build ./..., the new file with gateway-key-limits and
  i18n-keys (28 of 28 ok), and internal/gui's Go tests 3 times at
  -count=1: 2 ok, 1 red in TestRestartHandsTheGatewayOver (a request
  reset during the handover, #3451, not from this change).

Broken by hand, each red in the new test:
- render not calling refreshGatewayKeys: red at the focus step.
- the timer at 15e6 ms: red at the timer step.
- refreshGatewayKeys drawing over an open editor: red (focus lost).

Not covered: Young also says Usage's per-key spend stays still while
the Overview's gateway tokens move. Usage reads its own data on its own
timer, so this change doesn't touch that. The Overview counts every
gateway call, keyed or not, while a key's row and limits count only
calls that carried that enabled key. A loopback call (an agent here, or
a TCP forward like frp tcp or ssh -R to the gateway's port) with a
stale or rotated key is still answered, by design, but is counted under
no key. Whether that is Young's case is not known yet.

Not tried: the real app with a real key over hours.
2026-10-28 12:17:18 +08:00
yetone 0c973cd9a4 usage: the Sessions bars are rows of their own, not a subgrid (#3955)
The Sessions overview's bars (Projects, Models, Tool use) and Top
skills were each a subgrid of their card, the same layout that crashed
Safari 16's WebKit sizing the Routing requests (#3731). Each row is now
a grid of its own. sessLineUp reads each column's width with the rows at
their natural width, once, when the card is first shown, and sets it on
the card as --sb<i>. The widths don't change with the window's, and text
size is the window's zoom, so it never measures again on a resize. The
@supports not (subgrid) fallback is gone: Safari 16 has subgrid, so it
never helped.

sessions-bar-names now checks that no rule of the bars says subgrid,
that every row's bar starts and ends at one x (wide, at 420 and wide
again), and runs in every language, not only en and zh.

Run on mote at this head:
- sessions-bar-names: 41/41 pass. At origin/main's assets
  (MAGPIE_SESS_ASSETS) 40/41: only the subgrid check fails, so the bars
  line up as they did.
- Broken by hand (sessLineUp returns at once): 20 of 21 red, bars' left
  at 527,338.
- sessions-overview, account-mask-sessions, i18n-keys: pass.
- go test -run 'Budget|Asset|CSS' ./internal/gui: ok.
- node --check page.js: ok.

Not tried: a real Safari 16 (no macOS 13 machine). Next for #3955:
.quota-windows .quota's rows subgrid.
2026-10-28 12:09:02 +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 396e0e4638 usage: a deleted provider's requests merged into another, or named, from the Requests filter
CyberCaius on Discord: a deleted provider's requests sat under its old id
("<date> 已删除"), and the only way to put them under a provider they
have was renaming that provider onto the old id. Now, with a deleted
provider picked in Usage › Requests' Provider filter, a "…" beside it
offers Merge into… (an app menu of the providers there are now) and
Rename… (the filter's button turns into a name field; Enter or leaving
it saves, Escape keeps it). With the merged-into provider picked, the
same "…" lists Separate <name> for each, the undo.

Nothing in the log is rewritten. Both live on the deletion's own record
in providers.json (Deleted.Into/MergedAt, Deleted.Label), so a provider
added later under the old id inherits neither: it is a different
provider, and its record of its own is what it has. Renaming the target
carries the merge (Rename rewrites Into); deleting the target ends it.

Renames.Both(id, time) gives the id a call is shown under and the one it
was made to (Own). Listing, filtering, the summary and vias go by the
shown id; pricing (Record.priceID, block_price's as), window holds and
the gateway's loggedAnswers go by the own one, so a merge moves no cost
or token, only whose name they sit under. The target's face lists what
was merged into it (Named.Merged). Routes: GET /api/usage/deleted/into,
POST /api/usage/deleted {id, into?, name?}; a field not sent stays.

Run (mote, at this tree on d50f84c9f):
- go test -tags nogui -timeout 45m ./... : every package ok, exit 0.
- GOOS=linux and GOOS=windows go vet -tags nogui on usage, usageapi,
  provider, gui, gateway: ok. gofmt -l clean.
- New: TestDeletedProviderMergedIntoAnother (usage: cost 306 before and
  after the merge, 3 calls under main, coster/pricer price a relay call
  at its own price, a new "relay" keeps only its own call, rename and
  delete of the target, undo), TestDeletedProviderNamedAndMerged
  (usageapi), TestUsageDeletedProviderRoutes (gui).
- GUI: usage-ledger-deleted-merge.test.cjs, chromium and webkit, en zh
  zh-TW ja de at 1400 and 760px: ok. All 63 usage-*/ledger-* files and
  i18n-keys, both engines: 923 of 954 ok. The reds are red the same on
  origin/main c3b0484a9 run alone: usage-agents-hide (#3414),
  usage-fold (#3415), usage-ledger's "newest live route needs no
  return-to-live button" (#3104), and i18n-keys' "a plugin's words are
  its own" on library's "Runs as" (#3897).

After rebasing on origin/main 3e96197da (i18n.js merged with c3b0484a9's
balance keys): go build ./..., go test of internal/usage/...,
usageapi/..., provider/..., gui/... ok; the new GUI file in both
engines and every language ok; i18n-keys only #3897's red.

Broken by hand:
- Both returning (to, to): TestDeletedProviderMergedIntoAnother red,
  "cost 900, before 306".
- renamesOf not setting into: both Go tests red (relay still listed).
- ledProviderMore returning at once: the GUI test red (timeout waiting
  for the …), 5 of 5 subtests in chromium.
- On the old code the new tests don't compile (no MergeDeleted).

Not tried: the real app on a real providers.json with a deleted
provider; Linux/Windows GUI. gateway_sessions still prices by the raw
id, and a deleted provider's per-provider price stops applying once its
id is reused (both before this change, unchanged by it).
2026-10-28 11:15:57 +08:00
yetone c3b0484a96 usage: keys of one account show its balance once (mimi)
mimi on Discord (#feedback): "同一个网站,添加多个key时,余额会重复展示" -
a site's keys 1-A031-Pro, 2-S009-Plus and 3-S010-Team-2 each showed the
account's $8.39 and its own curve.

KeyBalances still reads, keeps and charts every key on its own. What
changed is what the Usage page draws:
- balanceRead says whether the reading is the account's (balanceAccountWide),
  going by the source, not the vendor's name:
  - account-wide: a balance token (new-api /api/user/self, sub2api
    /api/v1/user/profile, AiHubMix), a known host's account query
    (DeepSeek, Moonshot, OpenRouter credits, SiliconFlow, StepFun, ...),
    and sub2api /v1/usage when its mode is "unrestricted" (wallet or the
    group's subscription, per sub2api's gateway_handler.go Usage);
  - per key: AiHubMix's /dashboard/billing/remain, new-api's
    /api/usage/token, sub2api in quota_limited mode, any other Balance
    URL the user named.
- Two such keys of one provider with the same amount are one account only
  when their balances moved together: the same latest change (from and
  to), first read within balanceHistGap. Two accounts with the same
  amount stay apart until one is spent from; keys whose amounts differ
  are never one. SharedBalance (the first key's name) says so in
  /api/usage/quotas, magpie quota --json and /v1/magpie/quotas.
- Refreshing a shared card reads every key it stands for (sharesAskedCard),
  so it stays one card. The history is read outside the cache's lock.
- The Usage page draws them as one row, one balance, one curve, with
  "+2 keys" beside the key and the keys on hover; the head's sum counts
  the account once. The code is in plugins/usage/page.js, so app.js is 9
  bytes smaller than before; no budget raised.

Run (mote-run, at the pre-rebase base d50f84c9f):
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./...: ok. gofmt -l: clean.
- go test -tags nogui -timeout 45m ./...: every package ok except
  internal/gui's TestCoreScriptBudget (app.js 676 bytes over; fixed by
  moving the code into the Usage plugin, then ok) and internal/update's
  TestRelaunchOpenTriedAgain (TempDir cleanup under load, #3881; 3 of 3 ok
  alone).
- go test -race on internal/provider's balance tests: ok.
- GUI, both engines, en and zh: 122 files (balance-*, usage-*, quota-*,
  tray-*, panel-*, gui-ja/de/zh-tw, i18n-keys, key-balance-card,
  routing-wallet-balance, ...): 1637 pass, 42 fail in 6 files, all the
  same at base a05b37353 run alone and all filed (#3679 quota-refresh-
  order, #3404 quota-count-wrap, #3414 usage-agents-hide, #3415
  usage-fold, #3104 usage-ledger, #3897 i18n-keys "Runs as"). After the
  move into the plugin, 17 of those files again: only #3897's red.

Broken by hand, each red:
- SharedBalance never set (the old code): "after they moved together".
- Shared on equal amount alone: "first reading" ("other" merged).
- Every query taken as account-wide: quota'd and new-api token keys
  merged.
- No sharesAskedCard: the shared card's refresh didn't read sk-plus.
- keyCards without sharedBalances: usage-shared-balance red in all four
  (chromium/webkit x en/zh).

Not tried: a real sub2api or new-api account (fake server with sub2api's
literal replies). A key's balance is shown once only after the account's
next change is seen by every key, not on the first read. Multi-currency
balances (DeepSeek "$ · ¥") and balances with parts are never shared.
2026-10-28 10:52:46 +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 b90e81da14 gui: on Linux without gst-plugins-good the masking demo shows her poster
On stock Omarchy (Arch + Hyprland, WebKitGTK 2.52.6, GStreamer 1.28.6
with gst-plugins-base and -bad only), opening the masking demo aborted
WebKitWebProcess about three seconds in, so the app's window went blank.
WebKitGTK gives every video, a muted one too, an audio sink it makes with
autoaudiosink ("GStreamer element autoaudiosink not found", then a NULL
g_signal_connect, then SIGABRT); that element is in gst-plugins-good.
canPlayType can't tell: an Ogg Theora copy, "probably" playable there,
crashed the same way, so no other format would do.

The Linux app now looks for libgstautodetect.so in GStreamer's plugin
folders (its variables' and the system's): GStreamer's core there and
autodetect in none of them means no video (webkitPlaysVideo). Settings
state says noVideo then, in the app only (magpie web plays in the user's
own browser), and the demo sets no src: she is her poster and the sheets
move on the frame clock, as when the video can't load. No GStreamer folder
found says nothing, and video stays on.

Run at this head (origin/main 0f053024f + this change; the runs were at
ec6c2de52 + this change, and 0f053024f changes only README and site/):
- mote: node --test masking-demo, masking-records: 110 pass, 0 fail
  (Chromium and WebKit; the new poster test in both).
- magpie-desktop (WSL, Ubuntu 24.04): go test -tags gtk3 -run
  'TestGstAutodetect|TestWebkitDefaults|TestRenderNodeOpens|TestSettings'
  ./internal/gui: ok.
- mote: GOOS=linux CGO_ENABLED=0 go vet -tags gtk3, GOOS=windows go vet
  and go vet of ./internal/gui: ok. gofmt -l: none.
- omarchy, the real check on the real system, from a test binary built
  at this head: webkitPlaysVideo() is false
  ([/usr/lib/gstreamer-1.0 /usr/lib64/gstreamer-1.0]); on magpie-desktop,
  which has gst-plugins-good, true.
- omarchy, WebKitGTK driven from Python on `magpie web`'s page: with the
  demo's webm src set, the web process aborts every time (core dumps
  23:07:33, 23:10:17, 23:12:59, and 23:18:30 with an .ogv); with no src,
  as this change does, it stays up and T runs (2.99 -> 4.39 s).
- Broken by hand: gstAutodetect returning true makes TestGstAutodetect
  red ("stock omarchy: gstAutodetect = true, want false"); demo.js setting
  src regardless makes the poster test red in both engines.

Not tried: clicking the demo row in the real desktop app on omarchy (no
pointer tool there); the app's half was checked through the same
WebKitGTK and the detection through the real folders, separately.
2026-10-28 07:31:02 +08:00
yetone f13aafa87e redact: the masking demo card keeps 14px from the card above it
The page has no gap of its own; the request list keeps its distance from
the card with margin-top: 14px. The demo card, put between them in
cad7bbbdb, had none, so it sat flush under the card above. It gets the
same 14px, and masking-demo checks the room above and below it is 14
and 14.

Run at this head (origin/main cad7bbbdb + this change), on mote:
- node --test masking-demo, masking-records: 108 pass, 0 fail
  (Chromium and WebKit, five languages, 1100 and 640px).
- Broken by hand: without the margin, the new check is red (0 for 14,
  WebKit en 1100px).
2026-10-28 06:56:38 +08:00
yetone cad7bbbdb7 redact: Insights › Masking shows how masking works, with Little Magpie, folded until opened
A card under "What the vendor didn't see" and above the request list
plays a 27s demo: Little Magpie takes one request (a GitHub sign-in with
a password and an email), tears the real values out into her notebook,
pastes placeholders in, sends it, and swaps them back on your computer
when the tool call comes home.

- Folded by default. The video (xq_light/xq_dark.webm, 1.7MB/1.5MB) and
  the stage are built only on the first open, so a folded card fetches
  nothing but its 0:27 thumbnail.
- It plays only while open, on screen, in a visible window and not
  covered by a single record's sheet; it plays once and rests on the
  last step. Under reduced motion it shows the last step, still.
- The stage (request, notebook, browser, provider) is drawn in the page
  and translated in every language (41 keys, zh, zh-TW, ja, de); only
  Little Magpie herself is video. Light and dark takes match the card's
  colour exactly, and the take follows the theme as it changes, still
  playing (a new source starts paused, so it is woken where T is).
- The request and provider boxes keep room for taller fonts: WebKitGTK's
  Noto ran the provider's note 16px past its box. The stage is 1000x420.
- T, the frame clock, is the authority; a video that drifts (a seek
  it couldn't make) is sent back to T, never the other way.

Run at this head (origin/main 4842f69be + this change), on mote (macOS 27):
- node --test masking-demo, masking-records, i18n-keys: 111 pass, 1
  fail. The red is i18n-keys "a plugin's words are its own" on
  plugins/library "Runs as", red on main since 7f827b3b0 (#3897).
- masking-demo: Chromium and WebKit x en/zh/zh-TW/ja/de x 1100/640:
  folded fetches no webm, opening fetches one, the stage fits, no
  English left, nothing wider than the window, every box's text inside
  it (4px to spare in request and provider); plays, stops when folded
  or covered, rests at the end, restarts; dark take on the card colour;
  a theme changed mid-play goes on playing in the new take.
- go test ./internal/gui/: only TestMainWindowCorners/macOS_26_SDK red,
  the same on main (#3949); TestCoreScriptBudget ok.
- gofmt clean (no Go changed); go vet, GOOS=linux go vet -tags nogui,
  GOOS=windows go vet ./internal/gui/ clean.

Broken by hand:
- T following vid.currentTime (the first take): "plays while open" red
  in Chromium (the step 7 seek never stuck); green after.
- pickVid without wake(): the theme test red in both engines (0/2).
- The provider box at 350px: the no-clip check red ("prov -26px").

Whole GUI suite (*.test.cjs, mote, before the rebase, at dc1cfe015 +
this change): 75 files pass, 33 fail; origin/main 9e6347608 alone: 73
pass, 35 fail. Every file red with this change is red on main too:
account-mask (#3951), gateway-caller-keys (#3797), gateway-key-models
(#2648), header-centre (#3479), icon-tile (#3858), library-row-remove
(#3099), menu-input-scroll (#3402), mobile-web (#3952), old-webkit
(#3403), phone-web (#3876), quota-count-wrap (#3404),
quota-refresh-order (#3679).

Real use, magpie web from this tree:
- Windows 11 (xiaomi-gpu), Edge 156 headless = WebView2's engine:
  folded fetches no webm, VP9 "probably"; rAF 60fps, video 30fps, T
  never steps back; the step 7 seek holds; the theme switch keeps
  playing; rests at 27.5s; no page errors; every box fits in all five
  languages (8px or more to spare).
- Linux (WSL2 magpie-desktop, WebKitGTK 2.52.6 under Xvfb, compositing
  off as under Wayland): plays with T on the video's time, seeks, rests
  at the end, no errors. It found the two fixes above: the theme switch
  left the new take paused, and the provider's note ran 16px past its
  box in English and Japanese (and the request box 6px in ja and de). After: 10px or more to
  spare in all five languages.

Not tried: the packaged Linux and Windows apps themselves (magpie web
in their engines stood in); a real request through masking (the demo
is drawn, not live).
2026-10-28 06:43:31 +08:00
yetone 73fb77e1d0 sessions: a session's title keeps its room in a narrow Sessions list
cybercaius (Discord, Windows app, zh): at a narrow window a session row's
title shrank to one character ("7") while its tokens, cost and buttons
kept their width. The page's 560px media queries look at the viewport, not
at the list beside the sidebar, so they never fired.

.sm-tree is now a size container. Under 700px the token count goes and
the row gaps tighten; under 600px the row wraps: the title takes the
first line and the cost and buttons sit right-aligned on the second.

New sessions-row-narrow.test.cjs (zh title, tokens, cost, resume,
terminal, carry, delete; widths 1100 to 360): the title keeps at least
min(140px, 35% of the row) and ellipsizes, and nothing passes the row's
edge. Red before at every width up to 720 (title 0 to 100px); green
after in chromium and webkit, en and zh, on mote.
Not tried: the real Windows app (WebView2); Chromium covers its engine.
2026-10-28 04:18:21 +08:00
yetone 3e22123c9c usage: a deleted provider's calls stay apart from a new one under its id
cybercaius (Discord): after deleting a provider and adding a new one
that took the same id, the old provider's usage showed under the new one.

Delete now records the provider in providers.json ("deleted": id, name,
icon, when, its Was and Gave). UsageRenames gives a deleted id to
<id>~<when> only once something reuses it (a live provider, a later
deleted record, or a later Was), so a deleted provider nobody replaced
keeps its raw id and the existing probe/usage tests stay as they were.
/api/usage's provider faces name a deleted id from its record and set
Named.deleted; the Usage provider picker notes "Deleted {date}" (zh, zh-TW,
ja, de translated). Old deletes, made before this, have no record and
stay merged: nothing tells their calls apart now.

Run (mote): go test -tags nogui -run 'Deleted|Rename|NotSetUp|Probe'
./internal/usage ./internal/usageapi ./internal/provider ok; gofmt -l
clean; go vet -tags nogui ok.
Broken by hand: dropping the f.Deleted append turns
TestDeletedProviderKeepsItsCallsFromOneAddedUnderItsID and
TestDeletedProviderListedApartAndMarked red; restored, green.
Not tried: a real delete-and-re-add in the GUI app.
2026-10-28 04:18:21 +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 e056779a67 gui: the app serves its page to a browser, behind its key (Settings › Browser access)
jiakun_zhao on X ran `magpie web` in a terminal beside the desktop app,
to manage it through a Cloudflare tunnel. Settings › Network and sharing ›
Browser access now has the app serve the same page itself: Off, This
computer (127.0.0.1, for a tunnel or SSH forward) or Local network.

Access is magpie web's, unchanged: the key in the link is traded for the
cookie (webGuard), the allow list holds, and the gateway's client routes
on the page's port need a gateway key (onePort). A rebound Host and
Origin: null get no cookie. There is no way to serve it without the key.
The key and choice live in web-page.json (0600) beside settings.json, so
a sync never carries them. GET/POST /api/web-page are the app windows'
alone: a browser on the page can't read the key or turn the page off. A
busy port (magpie web, the magpie before an update) is tried every 4s;
`magpie web` on the same port opens the app's link instead.

Run at d43b7c40d (this change on ef155a5ca), then rebased onto the four
newer main commits, which touch gateway, usage, proc and library only:
- gofmt -l internal/gui internal/cli: nothing. go vet, GOOS=linux go vet
  -tags nogui and GOOS=windows go vet of internal/gui and internal/cli:
  clean. go build: ok.
- go test -timeout 45m ./internal/gui/ ./internal/cli/: ok (180s, 70s).
- GUI, alone: browser-access.test.cjs and model-test-one.test.cjs pass in
  both engines; i18n-keys 23 of 24, its red is #3897 ("Runs as" from
  7f827b3b0), not this change. agent-stale-copies.test.cjs 80 of 80 at
  8d343a811 (this change before the rebase).
- Full GUI suite at 8d343a811: cut short. The disk filled (708MB free):
  browsers failed to launch with ENOSPC in agent-stale-copies, which then
  passed 80 of 80 alone, and node ended with exit 7 before the rest of
  the files ran. There is no full GUI record for this change.

Not tried: a real Cloudflare tunnel to the page, and Local network from
another machine.
2026-10-27 18:58:16 +08:00
yetone ad3833512e gui: Settings' gateway rows move out of app.js to plugins/gateway/settings.js
Settings › Network and sharing's gateway rows (renderPort, renderBareIds,
renderCORS, renderAllow, renderLAN and their drafts) move as they are, byte
for byte, into plugins/gateway/settings.js, loaded after app.js beside
plugins/otel/page.js, as Observability's moved on 10-26. app.js had 416
bytes left under its budget; the next change (the app serving its page to
a browser) adds a section to that tab. Both budgets are lowered to what is
left: app.js 1,310,129, the core 1,526,251.

Run at this tree (68bbcc01c + this):
- go test ./internal/gui -run 'TestCoreScriptBudget|Asset': ok
- GUI (playwright 1.62.0, both engines, every language they cover):
  bare-ids, allow-ips, cors-origins, gateway-port, lan-docker,
  connect-address-kept, gateway-connect-keys, gateway-keys-off,
  agent-unreachable, api-key-theme, import-row, proto-menu-overflow,
  remote-magpie, usage-remote-cards, i18n-keys: ok. gateway-caller-keys en
  (#3797) and phone-web (#3876, filed now) red, the same 4 at the base
  68bbcc01c run alone.
2026-10-27 17:11:07 +08:00
yetone e4552cca9f library: a cargo RTK upgrades on Windows, and says why when it can't
新v学员 (Discord #feedback, 10-27): upgrading an RTK installed with cargo
failed silently on Windows. Four causes, each fixed:

- No cargo on magpie's PATH (magpie started before Rust was installed,
  or from a shortcut whose PATH rustup never touched): rtkUpgrader gave
  no upgrade, so Upgrade was greyed with only a tooltip, which a click
  never shows. Now the cargo rustup put beside rtk is run by its path;
  with no cargo anywhere, the card (and the CLI) says it was installed
  with cargo, to install Rust from rustup.rs or run the command shown
  (RTKView.NoUpgrade, Manual), and UpgradeRTK's error says the same.
- CARGO_HOME (D:\Rust\.cargo is common) moved cargo's folder: an rtk
  there wasn't cargo's to magpie. cargoBins reads it, for finding rtk
  and for the upgrade; on Windows the folder matches whatever its case.
- cargo install --git built rtk-ai/rtk's default branch, develop, whose
  Cargo.toml says 0.49.0 while v1.1.0 is out from master: the upgrade
  left rtk as it was, or older, on every OS. It now names --branch
  master, as rtk's own installation guide does.
- Windows refuses cargo's move over a running rtk.exe ("failed to move
  … (os error 5)", exit 101, after the whole build), and an agent runs
  rtk for every command. On that refusal the rtk is renamed aside
  (rtk.exe.old-<pid>, which Windows allows), a copy put in its place,
  and cargo run again; its build is kept in magpie's CARGO_TARGET_DIR,
  so the retry builds nothing. Old copies are removed on the next
  upgrade.

A failed cargo now says its first error with the cause, and what to do
for the common ones (rtk in use, link.exe/dlltool missing, GitHub
unreachable), not its last three lines, which only said the build
failed and where its files were left.

Run:
- Real Windows (10.0.0.132, sandbox CARGO_HOME/RUSTUP_HOME/USERPROFILE,
  rustup + cargo 1.99.1, removed after): plain cargo install over a
  running rtk.exe fails with "拒绝访问。 (os error 5)" exit 101; a
  Windows build of this package's tests (GOOS=windows go test -c, a
  scratch test calling ReadRTK/UpgradeRTK, not committed) with no cargo
  anywhere gave NoUpgrade "cargo" and the new error; with cargo only
  beside rtk (not on PATH) and the old rtk.exe running, UpgradeRTK
  built rtk-ai/rtk master and went 1.0.0 -> 1.1.0 in 3m26s, the running
  rtk kept running, rtk.exe.old-<pid> was left and removed once it
  exited. The build used the gnullvm toolchain with llvm-mingw; the
  gnu toolchain failed with "error calling dlltool" and lld's missing
  -lgcc_eh, which is the output the tests use.
- New tests (rtk_cargo_test.go) and the updated
  TestRTKUpgradeCargoNamesThePackage are red on origin/main
  (32ea16c5a): no upgrader without cargo on PATH, the generic error,
  the last-three-lines message, no --branch. The Windows paths are
  forced through rtkOnWindows.
- go test ./internal/library ./internal/cli ./internal/gui (sandbox
  HOME): ok. gofmt -l clean; go vet ./..., GOOS=linux go vet -tags
  nogui ./..., GOOS=windows go vet ./...: clean.
- GUI, chromium and webkit: library-rtk-*.test.cjs and i18n-keys (136
  pass), the new card test in en, zh, zh-TW, ja, de at 440px; then
  every library*.test.cjs file (736 pass, 0 fail).
- Rebased on origin/main 68bbcc01c (none of these files changed
  since 32ea16c5a): the three packages ok again, gofmt and vet clean.

Not tried: the MSVC toolchain (the box has no Visual Studio Build
Tools), so the link.exe hint is from cargo's known message, not seen
here; an rtk installed with non-default features is upgraded with the
default ones; CARGO_HOME is read from magpie's own environment only.
2026-10-27 17:08:57 +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 4a1cd77653 library: an MCP server's command reads and saves as cmd does on Windows
fremontdango (Discord #feedback) saw chrome-devtools' command shown as
'C:\...\npx.cmd' in single quotes and took them for quotes magpie adds
to the launch. They were display only: quote() wrote sh's quoting on
every system. On Windows it now writes cmd's: bare when nothing needs
quoting, else double quotes with "" for a quote.

words(), which reads the line back on save, treated \ as an escape on
every system, so a Windows path typed into the command field lost its
\ and : (#2685, first half). On Windows a \ is now a path's, and "" in
double quotes is one ". macOS and Linux keep sh's rules.

Not in this commit: #2685's second half, fnm's node not found on
Windows.

Run:
- library-mcp-win-line.test.cjs (new), both engines: 6 pass. It fakes
  navigator.platform Win32/MacIntel and checks the row line, the editor
  field, an unchanged save keeping the args, and #2685's typed path
  saving with \ and : intact. Red on the old code, and red with only
  words() reverted.
- Broad GUI run (728 tests): only library-row-remove red, red alone on
  origin/main eee571999 (#3099).
- go test ./internal/gui: ok.
Not tried: the real Windows app.
2026-10-27 06:26:03 +08:00
yetone 8bc72bf10a gui: the Sessions tab's 15 s reads send only what changed, not the ~8 MB list
Every 15 s the Sessions tab read /api/sessions (7.9 MB over a long
history, 5000 rows) and /api/sessions/stats (0.7 to 5.7 MB), parsed both
and ran JSON.stringify over the old and new answers to find them the
same. While an agent works one row changes, so it was all of it, every
poll, in the WebView.

- writeJSONSame (api.go) tags an answer with a hash of its bytes. An ask
  whose X-Magpie-Had is that tag gets X-Magpie-Same and no body, and the
  page keeps the object it has. Used for the stats.
- writeJSONRows does the same for the list, and keeps each row's hash
  for the last 4 lists it sent. Asked with the tag of one of those, it
  sends X-Magpie-Delta: sessions and a list of only the new rows, each
  run of old rows written [from, count].
- api() in app.js sends the tag it has, rebuilds a delta on the rows it
  holds (the same objects), and remembers each answer's tag. The tab
  compares answers by tag, so it no longer stringifies 8 MB twice.
- Not an ETag and a 304: on Windows Wails strips If-None-Match from
  WebView2's requests and turns a 304 into a 505.

Run at this head (macOS, go1.27, parent eee571999 = origin/main):
- TestSessionsSentOnceWhileTheSame: an unchanged answer is sent with no
  body, another tag gets it whole, and after a new session the list is
  the new row plus [0,1], which rebuilt on the old list equals the whole
  answer. Red with the Had check or the delta turned off by hand.
- tests/sessions-same.test.cjs (chromium and webkit, en and zh): no body
  sent again while unchanged, and the very objects kept. One new session
  sends a delta, and the old row is the object the tab had. The new
  title is drawn. Red in chromium with the client's rebuild removed.
- go test -tags nogui -timeout 45m ./internal/gui/ ./internal/sessions/
  ./internal/usage/: ok. gofmt -l clean; GOOS=linux and GOOS=windows
  go vet -tags nogui ./internal/gui/ ./internal/sessions/: ok.
- GUI: the 72 files that read /api/sessions or its stats, and
  i18n-keys, both engines: 1081 tests, 1053 pass, 28 fail. The fails are
  usage-agents-hide (#3414) and usage-ledger's "newest live route needs
  no return-to-live button" (#3104). Each file fails the same alone
  with eee571999's app.js and page.js (5/11 and 14/3 in chromium).
- A built binary on the real history (~15.9k sessions, a Claude Code
  session being written), six reads 15 s apart sending the last tag:
  20,753 B once (only this session's row), then 0 B with Same five
  times; the list was 7,928,438 B whole. Each rebuilt list equalled a
  whole read taken just after it. Stats asked again: 0 B, against
  5,688,332 B whole.

Not run: the whole GUI suite (~12.5k tests, ~5 h at this load). It was
stopped at 1,218 tests with only account-discovery red, which is #3497
and is red the same with this change's app.js and page.js put back.
Not tried: the Windows app (WebView2) and the Linux app.
2026-10-27 06:18:24 +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 e52a5e50ba redact: a request opens by its key again; the key goes to the GUI as a string
The owner opened the newest masked request and got "This request's
record is gone: records are kept for 30 days", and a request opened from
the list said its whole text was no longer in memory. A record's key is
its time in nanoseconds (~1.79e18), past 2^53, so JSON.parse rounded it
to 256ns: /api/masking/record?key= and /api/masking/sent?key= looked up
a key no record has. A list row worked only because it carried its
record. Every way in by key failed: the Gateway page's and tray panel's
masked badge, ?key= in the address, and each request's sent text; the
list's before= paging was off by the rounding too.

gateway.Masked's key and /api/masking/record(s)' key now go as JSON
strings (",string"); records on disk keep their number. The page keeps
the key a string (no unary +), and a refresh compares keys as BigInt.

Tests: TestMaskedRequestIsRecorded and TestMaskingRecordsAPI check the
key is a string, and masking-records' fake API uses 19-digit string keys
in place of 1001-1005, which no rounding touched.
Broken by hand: with the Go change out, both Go tests fail ("key not a
string"); with the page.js/client.js change out, "chromium: a masked call
on the Gateway page, and a key in the address, open its request" fails.

Run: go test ./internal/gui (twice ok; a first run under load ~180 went
red with its log cut by tail, so the test is unnamed; two reruns with
the whole log were ok), ./internal/gateway ok, ./internal/maskrec ok;
GOOS=linux/windows go vet ./internal/gateway ok; GUI masking-records,
routing-bodies, i18n-keys: 96 of 96 ok, both engines.
Not tried: the real app with a real masked request.
2026-10-26 22:50:37 +08:00
yetone 29f1a5a717 redact: a request's steps are joined number to number, not by a dash before each
The owner's screenshot of a masked request showed a short dash left of
steps 2 to 5. The connector (li + li::before) was 10px wide at left
-10px, so it covered only the grid gap, and read as a stray dash beside
each number. It now runs from the number before to this one, 6px clear
of each (columns are equal, 10px apart, numbers 20px).

masking-records' request test measures each line's ends against the two
numbers: 6px from each.

Run: masking-records.test.cjs whole (both engines, every language, 1100
and 640px), 82 of 82 ok. At 640px (container under 760px) the lines stay
hidden, as before.
2026-10-26 22:50:37 +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 d3191a51c8 gui: with Hide accounts on, an account's eye shows that one account in this window (yogurt36)
yogurt36 on Discord, for a screen share: with Hide accounts on, one
account should be readable while the others stay masked. Now an
account's name on the provider editor's row (accountNameButton and the
one-account line) and on its Usage card (quotaWho) has a quiet eye, in
sight on hover or keyboard focus, with an aria-label. A click shows
that account, its address and the name the user gave it together
(kin), everywhere the window draws it, tooltips included: the shown
set is skipped in hits(), which every mask goes through. It lives in
memory only. The tray panel keeps hiding it, and closing the window
hides it again: the page stays loaded while the window is hidden, so
hideMain runs mainClosedJS (hideAccounts.closed) first. With Hide
accounts off there is no eye. Strings in zh, zh-TW, ja and de.

Run (macOS, playwright 1.62.0, rebased on 630fd1d69; at push 0f6615ffc, site only, came under it):
- account-eye.test.cjs: 20/20 in chromium and webkit, en zh zh-TW ja
  de, 900px and 360px (no select, no stripe, no sideways scroll, a
  click scrolls nothing, Tab (Alt+Tab in WebKit) reaches the eye).
- Red on the old code (feature stashed): both tests fail.
- Broken by hand, each red, then restored: the shown check in hits();
  closed() without shown.clear(); kin() returning only the address.
- TestClosingHidesShownAccounts (new): red without shown.clear() and
  without the ExecJS(mainClosedJS) call in hideMain.
- go test -run 'TestCoreScriptBudget|TestBuiltinClientsLoaded|
  TestClosingHidesShownAccounts' ./internal/gui: ok. app.js
  1,306,355 bytes, under 1,321,319; budgets not raised.
- i18n-keys.test.cjs: 4/4.
- gofmt -l clean; go vet (mac), GOOS=linux go vet -tags nogui,
  GOOS=windows go vet ./internal/gui; go build, GOOS=linux go build
  -tags nogui, GOOS=windows go build: ok.

After the last rebase one chromium en/zh run of account-eye showed 1
fail of 4 with 179MiB free on the disk; its log wasn't kept, so the
test is unnamed. Every run since, with its log kept, passed: 4/4 and
then 20/20 in both engines.

Not run: the whole GUI suite and the full go test ./internal/gui
(another session's suite held the machine and the disk was full; one
link hit ENOSPC and passed on retry). They run after the push.
Not tried: the real Wails window's close (hideMain) by hand.
2026-10-26 18:18:24 +08:00
yetone 05eeb4e1b9 gui: a recorded call's body viewer moves from app.js to the Gateway plugin's script
callBodyPanel and what only it uses (the JSON tree, the stream's events
and reply, sseView/sseShown) move whole, unchanged, from app.js to the
end of plugins/gateway/client.js. Nothing in the core called them: the
Gateway page's recent calls, Usage's ledger and Routing's trace do, and
every plugin's script is loaded by index.html whether the plugin is on
or off, before any of them runs. app.js goes from 1,320,558 to
1,304,307 bytes; the budgets are not changed here. This makes room for
the per-account eye in the next commit without raising a budget.

Checked that the moved block is closed: none of its 12 names (and
sseView, sseShown) is used in app.js outside it, or in context.js,
plugins.js, kernel.js, pluginpages.js or start.js, and none is declared
in another script. docs/subsystems/plugin-runtime.md says where it is.

Run at this commit (Chromium + WebKit, NODE_PATH playwright 1.62.0):
json-tree, recent-call-bodies, request-archive-usage, request-archive,
routing-bodies, sse-body and i18n-keys: 58 pass, 0 fail.
go test ./internal/gui -run 'TestCoreScriptBudget|TestBuiltinClientsLoaded': ok.
The whole GUI suite and go test ./internal/gui ran with the next commit
at the pushed head (see its body).
2026-10-26 18:18:18 +08:00
yetone 630fd1d691 masking: Clear records… deletes what masking kept, after a confirm (maxyou2090)
maxyou2090 (#feedback) turned on strict masking and it recorded many
requests, with no way to delete them short of finding
~/.config/magpie/masking by hand.

Insights › Masking's list now ends in "Clear records…" (beside "Kept on
this computer for 30 days", shown while anything is kept). It asks first
with the app's confirm dialog (Cancel / Clear, red), then posts
/api/masking/clear and reads the page again: an empty list and card. A
clear that fails says why in the status pill and the list stays.

maskrec.Clear removes each day's file whole under the store's lock (a
day is removed, never rewritten, so there is no half-written file to
guard against), forgets each day's cached summary, and drops the text
around placeholders and the bodies kept in memory. A day it can't
remove stays, is still listed, and is named in the error. Keys keep
rising, so a record after the clear never takes an old key. What the
masker holds for each placeholder stays: a placeholder still in an
agent's context is put back in its answers. GET on the route does
nothing. Strings in zh, zh-TW, ja and de. gateway-routing.md says it.

Tests:
- internal/maskrec TestClear (three days and a stray file: the days go,
  the stray stays, List/Sum/Get/SentOf are empty, keys keep rising, a
  new Add counts) and TestClearSaysWhatStays (a directory it can't
  write: the error names 2026-10-26.jsonl and the record is still
  listed). With Clear stubbed to return nil both go red
  (maskrec_test.go:220 "left in ...", :260 "err <nil>").
- internal/gui TestMaskingRecordsAPI: GET clears nothing, POST clears,
  records/summary empty, record/sent 404. Red with Clear stubbed
  (masking_test.go:127).
- GUI masking-records.test.cjs: "Clear records asks first, then
  empties the page" in Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and
  640px (Cancel sends nothing; Clear posts once; nothing wider than the
  window; the click scrolls nothing; nothing left in English), and "a
  clear that fails says why and keeps the list". Red on the old page.js
  (the button never appears).

Run, at this commit (on origin/main 44a626bed; vet, maskrec, the gui Masking tests and the 22 new GUI cases again after that rebase):
- gofmt -l internal/maskrec internal/gui: clean. go vet on darwin,
  GOOS=linux -tags nogui and GOOS=windows for both packages: ok.
- go test ./internal/maskrec: ok. go test -run 'Masking|Budget|Script'
  ./internal/gui: ok.
- GUI: masking-records.test.cjs whole and i18n-keys.test.cjs, both
  engines: 86 pass, 0 fail (before the rebase onto a6c808b68, which
  touched no GUI file); the 22 new cases again after it: pass.
- Full suite, go test -tags nogui ./... -timeout 45m, at bdc25ec13: not
  a record. The machine's data volume was full (897 of 926 GiB, 3.2 GiB
  free afterwards), and backup, mcpauth, davsync, provider, cli, gateway
  and gui failed on "no space left on device" or failed to build.
  maskrec passed in it. The whole GUI suite was not run for the same
  reason.

Not tried: clearing in the real app with a real masking folder.
2026-10-26 18:07:19 +08:00
yetone ef0a03e137 otel: Langfuse is set up from its host and the project's two keys
A user on X asked for Langfuse built in. magpie could already export to
Langfuse over OTLP, but Settings › Observability had the user type the
endpoint .../api/public/otel and a percent-encoded
Authorization=Basic%20<base64(pk:sk)> header by hand.

Settings › Observability now has a Collector row: OTLP or Langfuse.
With Langfuse, the user picks the host (Cloud EU, Cloud US, or
Self-hosted with an address, which also covers Langfuse's JP and HIPAA
regions) and fills in the public and secret keys. Once both keys are
there, magpie saves:
- the endpoint <host>/api/public/otel;
- Authorization: Basic base64(pk:sk), in otel.headers as before, so the
  secret is stored where it was and a backup without keys leaves it out;
- on a first setup, also x-langfuse-ingestion-version: 4, metrics off and
  export on. langfuse.com/docs/opentelemetry/get-started (read 10-26)
  gives the same header for every region and for self-hosted, and says
  that without it OTLP data can arrive up to 10 minutes late.
A Langfuse endpoint set up by hand opens in this view with its keys
decoded into the fields. Opening it saves nothing. Changing a key or the
host keeps the user's other headers, their metrics and export choices,
and an ingestion header they set or left out. Switching from another
collector leaves that collector's headers behind and does not send them
to Langfuse.

The Observability page moved from app.js into the otel plugin
(assets/plugins/otel/page.js, with i18n.js for its words, in Client),
because app.js had 13 bytes of budget left. The app.js and core budgets
are lowered to what is left (1,321,319 and 1,537,645; app.js is
1,321,313 after rebasing on 2620dc319). "Collector" and "Secret key" go
in the core i18n.js because other files use the same words.

Docs: reference.md's Langfuse paragraph (with the env form for magpie
serve) and the en/zh/ja privacy pages.

Run (macOS):
- go test ./... -timeout 45m -count=1 at the pre-rebase head (parent
  e5dd86965): every package ok but internal/provider, which crashed in
  TestUnreadLoginsWriteErrorsKeepCredentials with "close of synctest
  channel from outside bubble" in filememo.Forget. That is #3632, red on
  main since 091153bf7.
- The whole GUI suite (make test-ui, concurrency 4, Chromium and WebKit)
  at the same head: 16 reds. Each red file was run alone here and at the
  parent e5dd86965. The same reds came back at both: menu-input-scroll
  (#3402), old-webkit (#3403) and plugin-card-update's webkit Update
  (#3079). The parent also failed fonts' webkit run. page-width,
  api-key-theme, panel-arrange, panel-balance-order, own-requests,
  library-mcp-health-wsl and plugin-list-error passed alone here: 137
  passes, 7 fails, all of them the three filed above.
- At the pushed head (rebased on origin/main c87a0179b): the budget
  tests; otel, otel-langfuse, i18n-keys, settings-sections, builtins,
  idle-ticks and page-width, both engines, 58 pass; go test
  ./internal/otlp ./plugins/otel ./internal/gui, all ok except
  TestRestartHandsTheGatewayOver (#3451). That test failed 1 of 8 here
  and 1 of 8 on origin/main dce7fe609.
- Before the rebase: otel-langfuse (new: first setup, US, self-hosted,
  hand setup kept, another collector's headers dropped, 5 languages at
  1100/520/360px) with otel, i18n-keys, settings-sections, builtins,
  readable-focus, segs-press-redraw, ux-safety, dialog-backdrop-drag and
  mono-icon-redraw: 113 pass. go vet for darwin, linux and windows on the
  touched packages; gofmt -l clean.
- Broken by hand: with every save treated as a first setup and the old
  collector's headers carried over, otel-langfuse's "set up by hand keeps
  its values" and "another collector's headers" went red.
- New TestOTelLangfuseSetup: settings saved as the page writes them reach
  a fake collector at /api/public/otel/v1/traces with the Basic header and
  ingestion version 4, and nothing on /v1/metrics.
- Real app: a -tags dev build in a sandbox HOME (ports 3461/3462). I
  drove its real Settings page with Playwright: Langfuse, then
  Self-hosted http://127.0.0.1:3463, then both keys. settings.json got the
  endpoint, Basic header, version 4 and enabled. A gateway request then
  reached a local fake collector at /api/public/otel/v1/traces with
  Authorization Basic base64(pk-lf-real-ui:sk-lf-real-ui) and
  x-langfuse-ingestion-version 4.

Not tried: a real Langfuse Cloud or self-hosted project (no account here),
so Langfuse accepting the spans and how they show in its UI aren't checked.
The TUI and magpie serve still have no Langfuse shortcut; serve takes the
env form in reference.md. The Linux app (WebKitGTK) and Windows weren't
tried; the change is form fields and segs, with no motion.
2026-10-26 15:11:37 +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
yetone 9787ca436c routing: Accounts and keys are folded again only when a request listed changes (#3164)
renderActs folded every kept request's seats (60 routes x ~800 seats on
the issue's load, ~48k entries) on each of its ~10 draws a second, and
in 63% of draws the requests were the very same objects. The fold now
lives in foldActs, kept while the list holds the same route objects
(routes are replaced whole on an update, ghost() makes new ones in a
replay). The rests lifted by hand (#1869) are taken off afterwards,
without touching the kept fold, since lifted() goes by the time shown
and a replay takes it back.

Run at this head (014680033 + this change), WebKit, the bin3164
sandbox app under load.sh (60 routes, ~800 keys), two folds open, 10s,
two runs each:
- renderActs 341 / 352 ms -> 181 / 174 ms (98-109 calls)
- renderHist (includes it) 407 / 417 ms -> 283 / 278 ms

GUI: every test file that reads .rt-act or replays/history (49 files,
1452 tests, concurrency 4, load ~33): 1403 ok, 49 red. Each red file run
alone on origin/main 014680033 and on this change, same counts both:
routing-live-patch 4/6 (#3637), routing-manual 2/2 (#3409),
routing-pause 0/14 (#3410), routing-rule-effort 4/14 (#3411);
routing-model-rest 20/20 on both. The others red in the full run,
routing-rule-remove (#3094, #3096), routing-intent-entry (#3408) and
routing-steady (#3412), are rule-editor and scroll tests this doesn't
reach, and were red on main already.

Not tried: the real app window (a dev shell showed a blank page here).
2026-10-26 04:55:49 +08:00
yetone d18d48e90f routing: a flight's points along a wire are read from its d, not asked of the browser each frame (#3164)
getPointAtLength walks a path from its start on every call. The flights
pose three points a frame, and along the wires to keys hundreds of rows
down (two groups of 500 and 300 keys open) WebKit spent 810-860 ms of
every 5 s in it, over half of the page's time in frames (1.43-1.51 s).

pointAt now flattens a d once, into points no more than 2 px apart along
its curve's control points, with the length along it to each, and finds
a point by a binary search between two of them. Only what the stage
draws with is read so (an absolute M, then L, Q and C); any other d is
still asked of the browser, a point every ptStep, as before. The wire
ends (tips) are still asked of the browser, once a d.

Run:
- the sandbox app (bin3164, fake upstream, 501 + 301 keys, a request
  every 0.3 s), WebKit, both groups open, 5 s, 2 runs each: points asked
  4759-5845 -> 104-132, their time 854-860 ms -> 19-38 ms, time in frame
  callbacks 1461-1507 ms -> 860-874 ms.
- accuracy, every wire and flight path on that page (815 paths, 162k
  points): the flattened point is within 0.12 px of Chromium's
  getPointAtLength and 0.76 px of WebKit's; WebKit's own getTotalLength
  is 1.39 px off Chromium's on the longest, so most of that is WebKit's.
- frames in 10 s (4 runs, alternating): 462-541 before, 446-463 after,
  within the noise of a machine at load ~6. The frames are bound by
  WebKit's painting now, not the script; this saves CPU, not frames.
- routing-busy-frames now counts points asked of the browser per d
  measured (<= 2): 6 of 6 pass here, 6 of 6 red on origin/main
  ("5737 points asked of the browser along the 1749 d's measured").
- every routing*.test.cjs and panel-routing*.test.cjs (112 files,
  --test-concurrency=6, load ~8): 1418 tests, 1365 pass, 53 fail. The
  reds are those of 3173440ca and 9fc382e66 (#3408-#3412, #3094, #3096,
  #3637) and three that pass alone at this head: routing-mode-goes 40/0
  (#2151), routing-model-rest 20/0 (a read before the frame, fixed in the
  next commit), routing-log-icons 14/0 (#3645).

Not tried: the macOS app's own WKWebView (Playwright's WebKit here).
2026-10-26 03:45:23 +08:00
yetone 9fc382e66d routing: a key off screen is not laid out or painted, so hundreds of open keys keep WebKit's frames (#3164)
With a group's 500 and 300 keys both open, WebKit drew ~40 frames a
second on the Routing page: hiding the keys below row 60 alone gave
back ~100 frames in 10s, so it painted every row again on each frame a
magpie flew. Chromium was at 60 already.

A key row now has content-visibility: auto, so one out of sight is
skipped. Its height while skipped is contain-intrinsic-size: auto
var(--rt-row): the last height it was drawn at, or, never drawn, the
content height of a key drawn now, which layout() reads with the boxes
it reads already and sets a frame later (set in the stage's own
ResizeObserver, WebKit reported a loop). Rows keep their heights, so
the wires to them and the list's scroll height are as before. A row a
429 hit (.hit) is drawn whole: its tag stands over its top edge, which
the paint containment would cut. A WebKit without content-visibility
or checkVisibility draws every row as before.

Run at this head (rebased on origin/main 5214d5114):
- routing-many-keys.test.cjs, new checks: a key in sight is drawn, the
  last of 800 is not, and every key is one height. Chromium and WebKit,
  en/zh/de: 6/6. On the old routing.css and client.js: 0/6 (the last
  key drawn); with this routing.css but the old client.js: 0/6 (keys
  61 or 62px drawn, 58px not).
- every routing*.test.cjs and panel-routing*.test.cjs (112 files,
  --test-concurrency=6, load ~27): 1418 tests, 1362 pass, 56 fail. Run
  alone at origin/main 5214d5114 and at this head: routing-kind 4/0,
  routing-keys-fold 32/0 and routing-rule-drag 10/0 on both (their reds
  were the full run's); routing-steady 0/2 on both (#3412);
  routing-rule-remove 9/11 at main, 12/8 here (#3094, #3096). The rest
  are the files 3173440ca compared on main: routing-intent-entry
  (#3408), -manual (#3409), -pause (#3410), -rule-effort (#3411),
  -live-patch (#3637).
- go test ./internal/gui/ (budgets included): ok.
- Sandbox (sbh-paint: providers of 500 and 300 keys on a fake upstream,
  a request every 0.3s, both groups open, Playwright WebKit 1280x900,
  10s, the served client.js and routing.css swapped four times):
  frames 367/391/410/412 -> 444/469/472/533, frames over 50ms
  3/4/3/4 -> 2/1/2/0. Off-screen row heights at 1280 and 700px wide
  measured the same as uncontained (38 and 61).

Tried and left out: the flowing wire's dashes on an SVG layer of its own
(no change past the noise, ~±30 frames); will-change on the wires and
the sky (none). Stopping the live wire's dash animation gives ~+40
frames more, but it is what says a request is with that key (#2386).

Not tried: the macOS app's own WKWebView window, WebKitGTK, a real
upstream.

Rebased on origin/main 385ce789e (a sidebar change only) and run again
there: routing-many-keys and routing-row-swap 8 pass, 0 fail.
2026-10-26 02:51:05 +08:00