Commit Graph
337 Commits
Author SHA1 Message Date
yetone b62117287b gui: a moved plugin's first question offers its other ways, the API key among them
mahiro233 on Discord (v0.1.3372, Kiro plugin 0.1.34): Kiro's account
sheet asked "Choose a sign-in method" with three choices and Cancel, and
offered no API key. The plugin has one (its third way, "Kiro API key
(ksk_…)"), but a moved subscription opens its plugin's first way at once
(#777), and when that way asks a question first, as Kiro's does since
plugin 0.1.21, the question had no way to the others: "Other ways to sign
in…" and "Use an API key instead" are on the waiting box only, which the
question comes before. Kiro CLI's or IDE's sign-in was out of reach too.

The first question of a moved subscription's way, when the plugin has
other ways, now has "Other ways to sign in…" (already in every language),
which shows the way picker, as the waiting box's does. A later question
(Kiro's Start URL) doesn't: the user chose that way already.

Test: plugin-ask-ways.test.cjs, en and zh, Chromium and WebKit: the
question's choices and hint, the link, the picker with the key way, the
key field titled by its label, nothing signed in before a key, no link on
the Start URL question, and the plugin's words in Chinese where it gives
them.

Run on mote at the pushed head, Chromium and WebKit: plugin-ask-ways,
plugin-other-ways, -moved-signin, -key-hint, -password-prompt, -signin,
-keyless-signin, signin-paste-plugin, deprecated-subscriptions,
i18n-keys and i18n-en-no-cjk, 49 of 50 each; the one red is i18n-keys'
"a plugin's words are its own", the same 3 words on origin/main
2a48974e8 (#5327, #5426, #5482). TestCoreScriptBudget is red at both, as
below. Broken by hand: with origin/main's app.js,
plugin-ask-ways is red (en waits for the link, zh for the Chinese
question). Not tried: a real Kiro key (none entered anywhere).

Core script budget: the two commits add 1,284 bytes to app.js, paid for
by cutting the Add sheet's comments on retired built-ins (Cursor, Grok,
WorkBuddy, Command Code, Qoder, Devin, Zed, Factory, MiMo, Kiro) and
inLang's to one line: the core is 1,535,556, 260 under origin/main's
1,535,816, no raise. Main stays over 1,533,802 from 40cbdaa7e (#5795).
2026-11-09 18:36:07 +08:00
yetone c630d9a29c gateway: the key page's Claude Code setup keeps each tier on its own family
The /me page's Claude Code tab wrote the picked model into
ANTHROPIC_MODEL and into ANTHROPIC_DEFAULT_OPUS_MODEL, _SONNET_ and
_HAIKU_ alike, so picking Opus sent every Haiku background call to Opus
too (and picking a GPT model made "haiku" a GPT model).

The pick now sets only ANTHROPIC_MODEL. /v1/magpie/me returns `tiers`,
built by keyPageTiers from the models this key may use: for opus,
sonnet and haiku, the newest model of that family (claudeTier and
claudeVersionOf; routing groups and fable are skipped). A tier the key
has no model for is left out of the snippet, so Claude Code keeps its
own default for it.

Siblings: the agent writer (internal/agent/claude.go) has its own tier
design (tiers follow the main model, haiku to the provider's Haiku, the
user's own tiers kept) and writes the user's real config; it is a
different situation and is left as is. OpenMausBot's snippet writes
only ANTHROPIC_MODEL.

Run (mote, via suite.lock):
- go test -count=1 -run KeyPage ./internal/gateway/: ok
- GUI key-page.test.cjs: chromium 13/13, webkit 13/13
- gofmt -l: clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., and go build for darwin, linux (nogui) and
  windows: ok
Broken by hand:
- old keypage.html: the new GUI test is red in both engines
  (ANTHROPIC_DEFAULT_HAIKU_MODEL 'claude/claude-opus-5', want
  'claude/claude-haiku-4-5')
- keyInfo without keyPageTiers: TestKeyPageTiersAreTheirFamilys red
  ("tiers map[]")
Full suite (go test -tags nogui -timeout 45m ./...): queued behind
other sessions on suite.lock at push time; its result goes on the
follow-up, with an issue for any red.
Not tried: a real Claude Code against the page's snippet, and the
gateway binary in a sandbox HOME.

Reported-by: strinah (Discord)
2026-11-09 14:22:05 +08:00
yetone 8544d5fdb5 settings: Download source says usemagpie.ai first, GitHub when it fails
Since v0.1.3345 an update's files come from usemagpie.ai (R2) and go to
github.com only when that fails; a mirror stands in for github.com only.
Settings › About › Download source still showed "GitHub", said updates
come from GitHub, and its button "Use GitHub" (zh 恢复官方) read as
switching back to GitHub. Now it shows usemagpie.ai, says GitHub (or the
mirror) is the fallback, and the button is Remove mirror (不用镜像), in
en, zh, zh-TW, ja and de. `magpie update mirror` says the same.

Run on mote (update-mirror, i18n-en-no-cjk, i18n-keys and cli vet again at the rebased head: ok but #5332):
- update-mirror, i18n-keys, i18n-en-no-cjk and every GUI file that opens
  About (19 files), chromium + webkit: update-mirror and i18n-en-no-cjk ok.
  The reds, rerun one file at a time:
  - i18n-keys "a plugin's words are its own" and segs-press-redraw
    "clicks its new self once": red the same at origin/main 26e9c9566,
    filed as #5332/#5426/#5482 and #4566/#3922.
  - lan-docker, public-url-default: red at load ~400, 62/62 ok at load 36.
  - about-*, cli-path, settings-sections, statusline-remote,
    uninstall-settings: ok alone (red only at load 278 to 400).
- go test ./internal/cli ok, go vet ./internal/cli ok, gofmt clean.
Broken by hand: the new update-mirror test run against origin/main's
app.js and i18n.js: 0 of 10 pass.
Not tried: the real app's About page; the whole GUI suite.
2026-11-09 09:36:33 +08:00
yetone f418edffc3 sessions: a session's details show how full its context was, request by request
liang_yongxiang on Discord: Routing tells how full one request's context
window was; does Sessions have the same, each turn's share?

A session's details on the Sessions page (and in Usage's Sessions list,
which draws the same details) get a Context line when the gateway sent
calls of it (s.via): the Context tab's spark of its prompts, request by
request against its window, and the fullest one's share beside it, toned
as the tab tones it. A point's tip says "Request 2: 80K of 200K (40%)" (the
tab's spark says it too now, where the window is known); a point clicked
opens that request in Routing with its card. A session the gateway never
saw asks nothing; one it kept no prompt of shows no line.

The data is the routing history the Context tab already reads. A new
GET /api/context/session?agent=&id=&from=&to= reads only the days from the
session's first to its last (30 at most), through the tab's per-day cache
(daysRecsLocked, split out of contextRecsLocked, so the tab's cached days
are not evicted), and keeps that one session (contextOfRecsFor), with up
to 1000 of its requests. The tab keeps the latest 80 sessions and would
leave an older one out. Subagent and side calls are left out as the tab
leaves them out; the same id under another agent is that agent's.

The line's code is in plugins/usage/page.js (sessCtxLine). context.js only
exports spark and health, and pays for its tip by cutting comments, so
the core's scripts are 10 bytes under main's, no budget raise.

Run at this head (rebased on e215d335a), on WSL (magpie-desktop, Linux;
mote rebooted mid-run):
- gofmt -l clean; go test -tags nogui -run
  'TestContextSessionLine|TestCoreScriptBudget|TestContext' ./internal/gui/: ok
  (also ok on mote at this head).
- node --test sessions-context-line (new: Chromium and WebKit, en zh zh-TW
  ja de, 1100 and 420 wide) and context-window: 44 of 44.
Run on mote before the rebase, at 627fd1a3b:
- the whole internal/gui package: its one red, TestCoreScriptBudget
  (1,536,110 > 1,533,802), is why the line moved into the plugin.
- sessions-context-line: 20 of 20.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- i18n-keys: "a plugin's words are its own" red, the same on origin/main
  e215d335a (#5327, #5332, #5426, #5482); the new strings pass its other
  checks.

Broken by hand:
- the one-session filter dropped: TestContextSessionLine red ("its
  requests' prompts: [21000]", another session's line).
- the tip back to "Request {n}: {tokens} tokens": sessions-context-line red
  in de ("Anfrage 2: 80K Token" for "Anfrage 2: 80K von 200K (40%)").
- the details line turned off: sessions-context-line red in en and zh.

Not tried: the whole GUI suite (it was running under mote's suite lock
when mote rebooted; not run at push); a real magpie with real routing history (the GUI test stubs
/api/context/session; the Go test reads real history files in a sandbox
config); the Linux app's WebKitGTK.

Reported-by: liang_yongxiang (Discord)
2026-11-08 18:13:30 +08:00
yetone 7a6211d047 providers: a model's own headers, in Model settings
axelburks on Discord: a vendor routes one model by a header of its own.
A key's provider (built-in or custom) can give each model headers
(settings.ModelHeaders["pid/model"]). They go on that provider's
requests for that model alone, after the provider's headers and after
auth: a name both have is sent once, as the model's, so a user's value
is never overridden by the provider's or magpie's key header. The
gateway names the model (provider.WithModel) on every route that asks
one: chat on each API, translated and streamed, count_tokens, System
One's decision, embeddings, images, videos and the model test. A
fallback provider serving the same model id gets its own headers only.
Accounts and plugins carry their sign-in's headers and take none.

The editor's "Name, price and reasoning level" panel is now "Model
settings" (every language), with + Add header per model, staged and
made with the Save; Restore default takes them away.
The rows being typed are kept out of the draft's
compare, so an untouched editor still closes without asking.

Broken by hand: dropping WithModel from gateway.go turns
TestModelHeadersReachTheirModelOnEveryRoute red; dropping the provider
id check in modelOf turns TestModelHeadersStayWithTheirProvider red.

Run, on this stack over origin/main 0fc3455e2 (mote's suite lock had
hours of queue, so the suites ran on WSL magpie-desktop under flock):
- go test -timeout 45m ./internal/{provider,gateway,gui,cli,settings,fx}
  on WSL, ok; ./internal/codexcat on mote, ok; gofmt -l clean;
  go vet on mac, GOOS=linux -tags nogui and GOOS=windows on mote, ok;
  TestCoreScriptBudget ok (paid by cutting comments, no raise).
- GUI, both engines, every language, on WSL at the pushed head and at
  0fc3455e2: every touched test file plus the provider-editor files a
  first run found red. No red at head that isn't red at 0fc3455e2. The
  shared reds have issues: i18n-keys #5332, model-chip-steady #4388,
  model-copy-id #4621, models-works-only #4391, plugin-move-unserved
  #4392, provider-fetch-again #5232, provider-levels-save #4394,
  provider-levels-scroll #4395, provider-models-rest #4396,
  provider-picks-stay #4397, provider-typed #4673, remote-magpie #4398,
  zero-priced-free #5262, model-reasonless (webkit de) #4100,
  name-suffix-no-names #1937.
- Rebased on origin/main 4ab1191bc (gateway.go moved under it) and run
  again at the pushed head: gateway and provider ok on WSL, gofmt,
  vet (mac, linux nogui, windows) and the budget ok, i18n-keys,
  model-headers and routing-groups-back with only #5332's red.
Not run at push: the whole GUI suite (1277 files).

Not tried: a real vendor that routes by header (Ark); fake vendors only.

Reported-by: axelburks (Discord)
2026-11-08 11:28:54 +08:00
yetone 9451ad59f1 gateway: MAGPIE_PUBLIC_URL at a private address is the local network's, the Docker bridge's other containers', alike in Connect's menu
jiezhengj (Discord) runs magpie in Docker on a NAS, MAGPIE_PUBLIC_URL at
the NAS's own 192.168.31.218. The web UI's Gateway list called that
address "Public address" (公网地址), which reads as the internet's, and
Connect's Base URL menu offered 本机 / 公网地址 / 局域网, where 局域网 was
really the Docker bridge's 172.17.0.1 that other containers on the host
use, while the list above it named that one "Other containers on this
host".

The classification itself was right (gateway.PublicIP never takes
RFC 1918, CGNAT or ULA for the internet); the labels weren't: any
MAGPIE_PUBLIC_URL was "Public address", and Connect's menu had its own
three-way rule that knew nothing of the bridge or of internet addresses.

- gateway.URLKind(u): "internet" (PublicIP), "local" (any other IP
  literal) or "" (a name, not looked up). /api/settings and
  /api/providers' gateway carry it as publicKind beside publicURL.
- settings.js addrWho(g, u, others) is the one rule: this computer;
  the bridge address as other containers'; an internet address as such;
  MAGPIE_PUBLIC_URL by its kind (private: Local network; a name: Public
  address); anything else Local network. The Gateway list (each label
  said once for the lines it heads; local, then other containers, then
  internet), Connect's Base URL menu and About's MAGPIE_PUBLIC_URL row
  all use it.
- "Public address" now only names a MAGPIE_PUBLIC_URL that is a host
  name; zh 公网地址 → 对外地址, zh-TW 公開位址 → 對外位址 (ja/de already
  neutral enough: 公開アドレス, Öffentliche Adresse). No new strings.

Run, on mote (sandbox HOME, Go 1.26.8):
- go test -run 'URLKind|PublicURL|LAN|Container|DefaultGateway|HostNetwork'
  ./internal/gateway ./internal/gui: ok, at 2dac9b84e and again at this
  rebased head on 6b7ee4a98
  (then rebased onto a7113d5c9, which shares no file with this, and
  not run again).
- GUI, chromium and webkit, 18 files (allow-ips, api-key-theme,
  connect-snippet-shell, gateway-card, gateway-connect-keys,
  gateway-caller-keys, connect-address-kept, gateway-keys-off,
  lan-public, lan-docker, phone-connect-menu, public-url,
  public-url-default, side-gateway-lan, key-page, statusline-remote,
  i18n-keys, i18n-en-no-cjk): chromium 152/156, webkit 153/156. Every
  red is red at base 2dac9b84e too and filed: i18n-keys "a plugin's
  words are its own" (#5332, #5327, #5482, #5426), phone-connect-menu
  420 public / no public URL (#4706, #4707), gateway-caller-keys
  chromium en (#3797, passed at base this time).
- Again at this rebased head: lan-docker, public-url-default,
  public-url, lan-public in both engines, 86/86.
- gofmt -l clean; go vet darwin (gateway, gui, cli),
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: ok.
- Full go test -tags nogui -timeout 45m ./... through suite.lock was
  still running at push (the owner's rule: no verified commit waits on
  the queue); a red it shows gets its own issue.

Broken by hand: TestPublicURLSaysItsKind on the old source fails
"publicKind <nil>, want local" (and want internet); the new lan-docker
test with the old JS fails 'Public address' vs 'Local network' and
'公网地址' vs '局域网' (chromium en, zh).

Not tried:
- a real Docker container or NAS; the cases are fixtures.
- magpie web's and the share banner's CLI lines still say "network" for
  every address, internet ones too; left alone.
- an in-container page opened at a public IP the host derived (not in
  lanPublic, not MAGPIE_PUBLIC_URL) is still labelled Local network.
- ja/de "Public address" wording kept.

Reported-by: jiezhengj on Discord
2026-11-08 02:13:14 +08:00
yetone 80ae904c23 routing: routing groups get a page of their own, beside Routing
The owner asked for the groups to leave the Routing page (11-06): under
the live stage and every request they were a long scroll down, and New
group with them. The design was reviewed before this was built.

- New page, Routing groups (#view-groups), drawn by the routing plugin's
  same script (routingPage), so the editor, its dirty/discard and every
  group action are unchanged. Toolbar: filter, "N groups · M on",
  Templates, Import, Select, and New group as the filled button. The list
  is right under it, and a Settings section under the list holds Found
  groups (with Exclude providers…) and Names in agents' lists.
- No Export button: each group already has its own Copy to share.
- Routing keeps the live stage and the requests. A request's group opens
  the groups page at its row.
- The sidebar has a Routing groups tab right after Routing (from 1024
  points). The header's row has no room for one: at 860px the extra tab
  pushed the logo out (brand.test). There the tab is hidden, Routing's
  tab is lit for both pages (markNav), and Routing's head has a
  "Routing groups ›" button, hidden beside the sidebar.
- Every way in now goes to the groups page: the guide's Open routing
  groups, the panel's and the provider editor's Make a routing group
  (window/main?view=groups&newgroup=…). mainView still takes
  view=routing&newgroup from an older panel.
- Words: "Routing groups", "Open routing groups", "Once saved, make a
  group of them in Routing groups.", and the editor's names note now says
  the setting is under the list, in zh, zh-TW, ja and de. "Open Routing"
  stays for the Agents page's button.
- Docs: providers-accounts, gateway-routing, plugin-runtime, gui-shell
  and reference say "Routing groups page" where they mean the groups.
- Core budget: the core's scripts are 1,533,774 of 1,533,802, paid for
  by three show()/setGatewayMode comments cut in app.js. No raise.

Tests: routing-groups-page.test.cjs (new) covers the page in Chromium and
WebKit, en/zh/zh-TW/ja/de, at 1280, 640 (window) and 420 (web): no
groups on Routing, the tab or the head's button by width, the lit tab,
toolbar order, New group primary and in sight, list then Settings, no
sideways scroll, no native select, no left-border accent; a request's
group to its row; quotas redrawn with an open editor left alone. The
trace tests (routing-compact, -pause-folder, -rule-models, -folder) open
Routing, then show the groups; routing-editor-foot and
name-suffix-where-named scroll by wheel, as the scroll guard lets a
reader; builtins expects the groups tab beside the sidebar only.
Removed: routing-groups-jump (the head's "Routing groups ↓" that scrolled
down to them, gone with them), routing-pointer-pin and routing-steady
(the groups kept in place under requests streaming in above them: no
request is above them now). Their guarantee that what redraws leaves an
open editor and its typing alone is routing-groups-page's quotas case;
Routing's own lists keep their keepInView.

The groups page's jump: a request's group, or a pool's "Several keys"
chip, opened the groups page and scrolled the row to the centre, and the
next frame show()'s backAfterLoad put the page back where the reader
last left it, then brought the focused segment in by "nearest": in
WebKit the pool sat half under the window's foot (routing-mode-goes, 9
of its 10 WebKit cases). goRouting now jumps at once on a page it opens and
marks it arrived(). The wheel in routing-many-keys turns over the keys:
at the page's foot, now shorter, the mouse rested over the requests list
(.rt-reqs, overscroll-behavior: contain), which took every wheel up, and
the test stopped with 2 keys in sight. That is #4082's cause.
routing-days-fit's fixture has 12 requests, a day that fills the window,
since the day bar held needs room under it.

Run on mote (macOS 27, load 25 to 65), Playwright 1.62.0:
- Go: go vet, gofmt -l and go test ./... at the rebased head (650bf8412
  base) ok except TestMainWindowCorners (#3949); internal/gui again
  after the last edits: the same, TestCoreScriptBudget ok (1,533,773 of
  1,533,802, no raise).
- GUI, the 262 files a change here can reach, at the head and at the
  base: the reds at the head are the base's, with their issues:
  menu-input-scroll #3402, provider-mask #5109, context-fold and
  order-unknown (webkit) #3479, header-centre #3479, i18n-keys
  #5332/#5426/#5482, account-eye #5052/#4244, call-headers webkit de
  #5045, codex-predictions #2624, codex-auto-reset webkit de #4790,
  routing-* under load #5088, and zero-priced-free, last-page,
  reasoning-speed, routing-row-swap/-tag-whole/-story-shrinks/-steps-cap
  and routing-intent-entry, red at the base the same way.
- After the last edits: the 11 files with a way to the groups page or
  its scroll (group-*, routing-groups-page, routing-mode-goes,
  routing-groups-off, routing-provider-off, routing-many-keys,
  click-scroll), 175 of 176; the one red is routing-many-keys webkit's
  wire at the foot, red at the base in 8 of 12 (#5543). brand,
  gateway-mode-sessions, header-zoom-fit, header-centre,
  inner-scroll-contain and mobile-web: the same 11 reds at the head and
  the base (mobile-web compares with origin/main through git, which a
  mote-run copy hasn't).
- Rebased on ecc26a339, again: gofmt -l, go vet ./internal/gui and
  TestCoreScriptBudget ok; 10 GUI files (i18n-keys, routing-groups-page,
  routing-mode-goes, sidebar, brand, menu-first-second, library-bar-more,
  click-scroll, name-suffix-saved, unlisted-models) 211 of 212, the one
  red i18n-keys' "a plugin's words are its own", red the same at
  ecc26a339 (#5332/#5426/#5482).
- Broken by hand: without the groups page's CSS rule, brand and
  routing-groups-page go red (32 fails); with the old goRouting,
  routing-mode-goes is red in 9 of its 10 WebKit cases.

Not tried: the whole GUI suite on Linux (WSL magpie-desktop) at this
head; a run at an earlier head is under way and has the Linux reds
#4120/#4121 name. Not tried in the real macOS app, only Playwright's
WebKit.
2026-11-06 23:11:43 +08:00
yetoneandchiperman ju 0f07fbd0c6 agents: a first Details opening reads its settings before it slides (#5360)
The first time an agent's Details opened, sheet() measured the row before
/api/settings (and, for a full-context row, agentcompact.js) had arrived,
slid to that half height, then jumped to the full one when they landed.
The click now loads what the row needs first (the button shows Loading…),
and only then measures once and slides. A later click supersedes a load
still in flight. agentcompact.js finds #fullContextSegs on the list it is
given, so it fills a row before it is in the page. This is chiperman's
patch (8886a860a) without its core budget raise: Agents-page comments in
app.js were cut instead (app.js 1,311,357 -> 1,311,024; core 1,533,459 of
1,533,802).

agent-expand-steady's slide check looked for the height animation only in
the click's own task. A first opening now waits for the settings read, so
it looks in every frame; it still fails when no frame is animated.

Run (mote, at base 8ee85c59f):
- agent-details-ready.test.cjs (new) + agent-expand-steady: 40/40.
- Every GUI file touching ag-link/ag-exp/agent-compact, click-scroll,
  i18n-keys: all green except i18n-keys "a plugin's words are its own"
  (red on origin/main 8ee85c59f too: #5332, #5426), agent-models-redraw
  chromium 560 "page closed" (4/4 alone), mobile-web "desktop matches
  origin/main" (needs .git, which mote-run's copy has none of), and
  agent-expand-steady's sync check (fixed above).
- TestCoreScriptBudget: ok.
Broken by hand: agent-details-ready on the old app.js fails with
"Details must end without a height jump: 202.984375 -> 729.6875".
Not tried: the real app with the reporter's agents; mobile-web.

Reported-by: chiperman
Co-authored-by: chiperman ju <chipermanju@gmail.com>
2026-11-06 13:43:30 +08:00
yetone 8b70b7d976 usage: a request's bytes up and down, and what DeepSeek's image files saved, in Requests
Suggested by @faithleysath (matrix0487 on Discord): the usage ledger now
keeps what each request received back (down_bytes) beside what it sent up
(up_bytes, #4456), and what DeepSeek's image files (#5407) kept out of the
upload (image_files_saved).

Shown in Usage → Requests:
- a row's details: "Sent upstream", "Received" and "Saved by image files",
  each only when it is above 0. A row from before has none of them, not 0;
- under the Requests card, the period's "↑ up · ↓ down", with
  "{n} saved by image files" when there is a saving. Its title gives the
  exact bytes. A period with no counted bytes shows no line.

What is counted:
- Down bytes are counted as the reply body is read, after Go's transport
  has undone gzip, so a gzipped reply counts its plain size, not wire
  bytes. A plugin's row counts the local hop to the plugin host. A 101
  body is not wrapped. Every try counts, so a refused try plus the
  answering one add up (TestLedgerKeepsDownBytes).
- Image files saved, per try: the body before the swap minus the body
  sent, minus the upload bytes this request itself paid (len(b64)/4*3).
  It can be negative on the turn that uploads; the GUI shows only a
  saving above 0. Gaps: an upload that finishes after the wait timeout or
  ctx-done is not subtracted (as with up_bytes); a joined upload flight is
  paid by the request that started it; multipart overhead is approximate.
- packedRow grows by three int32 (152 bytes, still within the test's
  bound), clamped to the int32 range. Totals sum all three.
- settledCountVersion goes 1 → 2, because Totals now count bytes. The
  settled page, heat and effort caches recount once, on the first start
  after the update. The heat key hash includes the new fields.

Run on mote at 84ad780b6 (origin/main, fetched):
- go test ./internal/usage: ok.
- go test ./internal/gateway -run 'TestLedgerKeepsDownBytes|TestDeepSeek|
  TestCodexOwnTurnKeepsUpBytes|TestLedgerKeepsUpBytes|
  TestLedgerCountsATrysSecondAsk': ok.
- go test ./internal/gui: only TestMainWindowCorners/macOS_26_SDK fails,
  as on main (#3949).
- gofmt -l clean; go vet of usage and gateway for darwin, linux (nogui)
  and windows; go build ./...
- New GUI test usage-ledger-bytes.test.cjs: 30 of 30 in Chromium and
  WebKit, en/zh/zh-TW/ja/de, at 1180 and 420 wide. It is red on the old
  page.js.
- usage-*, ledger-*, i18n-* and nav-timeout GUI files: 1231 of 1267.
  Every red is red on a clean 84ad780b6 too: usage-agents-hide (#3414),
  usage-fold (#3415), usage-ledger's "newest live route" (#5048),
  usage-overview-fold, which flakes in other languages on each run
  (#3947), i18n-keys (#5332, and #5426 filed now for "No session ID"),
  and nav-timeout (#5425, filed now).

Broken by hand:
- gotDown not wrapping the body: red, "down 0; the vendors answered
  141/265 bytes" and "the backend answered 105 bytes".
- the saved += removed: red, "saved 0".
- the settled guard red with the bytes fixture until the version raise.

Not tried: a real DeepSeek or other vendor account through a built app,
and a screenshot of the real app. The CSV export does not have the new
columns yet.
2026-11-06 09:17:10 +08:00
yetone 4164edce60 gui: a one-tone dark or light logo is drawn in the text colour, so Open Design's shows in dark mode (chen2652)
chen2652 (Discord #help) reported that Open Design's icon is almost invisible
in dark mode, with no browser dark-mode extension on. The icon is the plugin's
own picture, open-design.ai/favicon.svg: a single fill, #26251E, drawn as an
<img> on the dark card (#232327).

Now icon() judges each picture once, after the picture's own load, so lazy
loading is kept (#909). The result is cached per src. If every opaque pixel
of a picture is one tone (the range of each channel is at most 24), and that
tone is near-black (every channel at most 72) or near-white (every channel at
least 224), the picture is replaced by maskSpan, the way a mono logo is drawn:
a mask in the text colour. This holds on any ground, Omarchy's themes
included. It covers user pictures (file:), plugin pictures, and bundled
-color and PNG icons.

Audit: every bundled picture icon, plus the plugin registry's pictures, was
measured in CIELAB against #232327 and #fff. Two were invisible in dark mode:
Open Design's plugin picture and bundled voyage-color.svg (#012E33, in the
provider icon picker). Both are now masks. Multi-tone and tiled logos stay as
they are (pipellm, zcode, mothx, deepinfra and others: low contrast in places
but readable). Mono icons were masks already.

Test: icon-one-tone.test.cjs, with the real favicon bytes in fixtures/.
- It draws every picture logo on the dark and the light card and measures,
  on a screenshot, how much of each stands apart from the ground.
- It opens Open Design's Installed row on the Plugins page and checks that it
  is a mask in the icon's text colour and visible in both themes: 5
  languages, 980px and 420px, Chromium and WebKit.
icon-url and icon-url-saved served a plain black square as the fetched
picture. That square is one tone, so it is now a mask. Their fixture is now a
coloured tile, like the letter icons the server makes (favicon.go).

Run (on mote unless named):
- icon-one-tone: 48/48. The 14 icon/theme GUI files (icon-tile,
  plugin-own-icon, mono-icon-redraw, plugin-registry-icon,
  models-add-and-icons, market-icon-corners, request-provider-icon,
  routing-client-icons, routing-log-icons, tray-logos, api-key-theme,
  icon-url, icon-url-saved, icon-one-tone): green in both engines.
- go test ./internal/gui -run 'Budget|I18n|Asset', gofmt -l,
  GOOS=linux go vet -tags nogui and GOOS=windows go vet of ./internal/gui:
  all clean, and no size budget was raised.
- A whole GUI suite on Linux (WSL) was cut off when the SSH connection to
  xiaomi-gpu dropped, after about 9,160 passes and 277 reds:
  - 40 of the reds were icon-url and icon-url-saved (fixed above).
  - The rest were in 75 other files. Those 75 files were run on mote with
    this change and at origin/main 76f00399c: 196 reds with the change and
    208 at main, in the same files.
  - The one file red only with the change, copilot-ghe (webkit zh,
    "route.fulfill: Target page ... has been closed"), is #1949's teardown
    race and passes 6/6 alone.
  - Every file red at main already has an open issue except
    redact-words-list, filed as #5288 and fixed by a18ff505b before this
    rebase.
- At the pushed head (a18ff505b + this commit): the budget/vet/gofmt checks
  above, the 14 icon files, redact-words-list and copilot-ghe, rerun.

Broken by hand: with both toneCheck(img) calls commented out,
icon-one-tone fails 46 of 48. voyage-color shows 0.0% ink in dark, and the
Open Design row stays an <img>. Before and after screenshots of the row in
both themes were taken from the same test.

Not tried: the real desktop app (Wails, WebKitGTK) and a real install of the
Open Design plugin. The page was driven with the API faked and the real
favicon bytes. The whole GUI suite has not had a complete run.
2026-11-05 06:11:49 +08:00
yetone 79477604a5 providers: a plugin option that says placement "top" sits under the accounts, above Routing (#5269)
mycf_711 (#5269): WorkBuddy Pro's plugin-level "panel" switch was drawn in
Plugin options, under the whole model list, so it took a scroll every time.
An option in auth.options may now say `placement: "top"`: the provider's
editor draws those in a Plugin options block right under the accounts,
above Routing, and the rest under the models as before. The note that the
plugin reads them goes with the first block. host.js keeps placement only
when it is "top" (anything else is left out, so the option goes under the
models), and plugin.Option carries it to /api/providers. A plugin that says
no placement is drawn exactly as before, and an older magpie ignores the
field. Documented in docs/subsystems/provider-plugins.md and
docs/reference.md.

Run (mote, through mote-run):
- new internal/gui/tests/plugin-option-placement.test.cjs: chromium 31/31,
  webkit 31/31 (1100 and 420 wide, en/zh/zh-TW/ja/de; mixed, top only,
  none or an unknown placement; the top switch posted on Save).
- plugin-options.test.cjs 11/11 and plugin-option-words.test.cjs 21/21,
  i18n-keys 4/4, each in chromium and webkit.
- go test ./internal/plugin ok (TestPluginOptions checks "top" kept and
  "sidebar" left out); go test -run Budget|Script|Asset ./internal/gui ok.
- gofmt -l internal/plugin empty; go vet ./internal/plugin ./internal/gui
  ./internal/cli, GOOS=linux -tags nogui and GOOS=windows vet of
  internal/plugin ok.

Broken by hand:
- app.js put back to its parent: the placement test fails "mixed" and
  "top" in both engines (blocks under the models), "none" still passes.
- host.js's placement line removed: TestPluginOptions fails
  "second = {... Placement:}".

Not tried: a real WorkBuddy Pro plugin (Gitee, private) with the field;
the full go test ./... and the whole GUI suite run after the next commit.
2026-11-05 00:55:36 +08:00
yetone 083821dc96 plugins: a search entry can use the plugin's own sign-in, with its own rests
Asked for by axelburks on Discord. A plugin's search hook entry can name
a provider its own auth hook signs in to, `auth: "<provider id>"`. It then
takes no key. The host picks an account, renews it under `fresh` (the wait
counts within the search's time), runs the hook in `inScope`, and gives it
`ctx.getAuth()`, which returns that account's sign-in. A token the hook saves
with client.auth.set goes to the same account.

The gateway (askSearchSignedIn) asks one account at a time. It takes the
accounts that are on, in the order the provider's model requests take them
(accountsOn, now shared with fallback.go), and puts an account resting from
a search refusal last. A refusal rests only that account's search
(restSearchKey "account <key>"), never its models' rest (restingUntil). Every
attempt gets its own request-log row. An entry without `auth`, or naming a
provider the plugin doesn't sign in to, is a keyed entry as before, with no
getAuth. In Settings → Search, a bound entry shows "Signs in with {name}" in
place of the key field, and the row says whether it is signed in and how
many accounts are on (every language).
Docs: reference.md (with an example), plugin-runtime, plugin-tools and
provider-plugins.

Run on mote at f44fa2ef6 + this change. After rebasing on acd789d45 (an
unrelated responses_ws change), go build ./... and -run "Search|Budget"
on plugin, gateway and provider are ok again at this tree.
- gofmt -l clean; go vet ./internal/... ok; Linux and Windows vet of
  plugin/gateway/provider/gui ok
- go test -count=1 -timeout 45m ./internal/plugin ./internal/provider
  ./internal/gateway ./internal/gui: plugin, provider and gateway
  ok; gui red only in TestMainWindowCorners/macOS_26_SDK, mote's
  macOS 27 title bar, already filed as #3949
- node --test on 15 GUI files: search-signs-in, search-api, search-keys,
  search-order, search-all, search-first, search-instead, searcher-pick,
  searcher-then, provider-search, settings-search, i18n-keys, gui-zh-tw,
  gui-ja, gui-de. 207 of 207 pass (chromium and webkit, 980/420px, en/zh).

Broken by hand. Each break made its test red:
- B1, no ctx.getAuth: plugin TestPluginSearchSignsIn "ctx.getAuth is not a
  function"
- B2, no renewal: "searched as due@seek acc-due", "the renewal never began"
- B3, gateway with no auth branch: gateway TestPluginSearchSignsIn "signed
  in: k9 undefined"
- B4, a refusal that also rests the model account: "a search's rate limit
  rested a@seek for its models"
- B5, getAuth handing out the provider's first account: "as the second
  account: a@seek acc-a"
- B6, the hook run outside inScope: "a token saved while searching as b: a
  rotated-b@seek"
- B7, getAuth given to every entry: "keyed: k9 function"
- settings.js showing the key field for a bound entry: search-signs-in red
  in every engine, width and language

Not tried: a real search vendor or Axel's own plugin; real accounts; runs
on the Windows or Linux boxes; the full GUI suite. The full go test ./...
runs after the push.
2026-11-04 20:55:42 +08:00
JoeyWu-tech c0dd5838c2 library: the write-failure card can be hidden until a new failure (#3745)
Zachary-wW (#3745): the Library's "Some of the Library couldn't be
written" card had Try again and nothing else. Their Grok Build has an
AGENTS.md magpie can't stat, and every change writes every agent again,
so the card stood over the page through every edit on the Instructions
tab, with no way to put it away.

The card has a × beside Try again now, named "Hide until something new
can't be written". It hides the write failures the card lists, on every
tab, and sends nothing. The page keeps what was hidden by agent and item
("grok" and "instructions"). After every answer, a read or a change, it
lets go of a hidden failure that no longer stands, and a failure not
hidden brings the card back with all it lists; so does a hidden one
whose item was written in between and fails again. So the card stays
hidden while the reporter keeps editing, though each change fails on
Grok Build's file again, and a new write error shows it again.

The key is not the error's text: a write goes through a temp file named
anew at each try (edit.WriteAtomic), so a folder that can't be written
fails with a new text at every sync, and the card would never stay
hidden. Meanwhile each change's toast still names what failed, as
before, and a skill that couldn't be given keeps the dot on its agent's
chip. The list magpie keeps (lastProblems) is not touched. The × is
named by its title, as the Library's other × buttons are.

An agent's own skills in the library's way are the agent's to settle,
not failures: they stay, under their own title, with no ×. The view
keeps its scroll as the card goes, as render() keeps it for Try again;
Chromium's scroll anchoring moved it. From the keyboard the focus goes
to the card's next button, or to the tab open. On a phone the × is 44px
wide and as tall as Try again. The card's title keeps its words whole:
with less than 10em beside it, Try again and the × go to a line of their
own (beside them, a German title at 320px broke "Bibliothek" and
"geschrieben" inside).

library-problems-hide.test.cjs is new. Its API answers as
internal/gui/library.go does: a change's problems are its full sync's,
an Instructions change keeps the rest and puts its own in, and a read
gets the list with no result. Its error texts are the ones magpie's own
sync gave in a sandbox HOME, through Handler in a scratch Go test (not
kept): Grok Build's AGENTS.md a link into a folder magpie can't search,
its folder read-only, and its skills folder read-only.

Not covered: what was hidden lasts as long as the page, so a reload
shows the card again. The × hides, it doesn't fold: while the card is
hidden, its error texts and Try again are out of reach, though any
change writes every agent again. An agent's instructions, and its whole
MCP file, have no mark of their own as a skill's chip has, so with the
card hidden only a change's toast names their failure (#3987).

What was run (tree f98a4b99, on origin/main f8cd964a, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077:

  library-problems-hide.test.cjs, Node's runner with Playwright 1.58,
  Chromium and WebKit, three runs each: 16 of 16 pass in every run (15
  cases and the file's own)
  Without this change (f8cd964a's client.js, i18n.js and library.css,
  the new test kept): 16 of 16 red in both. Broken by hand, one at a
  time, Chromium and WebKit unless said:
    any change that fails at all brings the card back (the first
    draft's rule): the reporter's case, the same failure under another
    error and a hidden failure written since, red
    a change's failure not hidden brings it back, nothing let go: a
    hidden failure written since, red
    a new failure never brings it back while anything is hidden: a
    failure not hidden, a hidden failure written since and another
    window's change, red
    the key with the error's text in it (Chromium): the same failure
    under another error, red
    the × writes every agent again (Chromium): 9 red, the reporter's
    case among them
    the view's scroll not kept as the card goes: 9 red in Chromium,
    green in WebKit, which keeps it without
    the × 44px wide on a phone taken out (Chromium): the five locales'
    "named and inside the card", red
    the head as the draft had it, no wrap and the title shrinking: de,
    red
    the focus moved without preventScroll (Chromium): green, 16 of 16;
    no test here tells it apart
  Library and siblings, Chromium and WebKit: 69 files, the Library's
  own tests, the skills' and market's that share its page, gui-de,
  gui-ja, gui-zh-tw and i18n-keys: all pass but two, red the same at
  f8cd964a without this change: i18n-keys "a plugin's words are its
  own", fixed on main since (#3897), and title-bar-tools (Chromium de,
  WebKit all five locales: a locator.waitFor timeout)
  TestCoreScriptBudget: ok (the Library is a plugin, outside the core);
  on origin/main c752082e with this commit applied too (a scratch
  worktree, not this tree)
  On origin/main e9dd8e83 with this commit applied (a scratch
  worktree, not this tree), Chromium and WebKit:
  library-problems-hide, i18n-keys, library-items and
  library-instr-busy, 66 of 66 pass
  gofmt -l of every .go file: nothing. GOOS=linux, windows and darwin
  go vet -tags nogui ./..., GOOS=windows go vet ./...: exit 0.
  GOOS=linux and darwin go build -tags nogui ./..., GOOS=windows go
  build ./...: exit 0. Untagged linux vet and build stop at pkg-config
  (no libsoup-3.0 or gio-unix-2.0 here)
  full suite, go test -tags nogui -count=1 -timeout 45m ./... (8m25s,
  load 35 at its start, Bun 1.4.2): 68 packages ok, reds in 8, none
  in internal/gui's library code:
    internal/agent TestInstalledVersion, TestZedAppPath,
    TestCursorFolderFromTheEditorIsNotTheCLI,
    TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
    TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
    TestOmpDetectedWithPiDir (#3141); TestCodexDriftReached (#3398);
    the two Reasonix tests (#3641); TestWSLColdPlaceOpensNothing
    (#3924, fixed on main since)
    internal/davsync TestSyncTeraCloudStillSeesOtherWrites (#3420)
    internal/edit TestWriteAtomicReadOnlyHardLink and internal/testenv
    TestProgram, umask 077 (#3640)
    internal/gateway TestPluginToldWhereTheAgentWorks (#3675)
    internal/gui TestGatewayHeldByAContainer and
    TestGatewayFixQuitsOnlyAMagpie (#3649)
    internal/provider TestCodexAppServersOnHome (#3906), then "fatal
    error: close of synctest channel from outside bubble" (#3632),
    which ends the package's run
    internal/tui TestTUIFetchesSubscriptionModels/agent (#3919)

Not tried: the × in a running magpie, in macOS's or Windows' window or
WebKitGTK; the page here is the test's, with magpie's own replies.

Batch run, at tree 104d75f0a (the twelve coffemon ports together, on
origin/main 7d022bdb6), mote, macOS, go1.26.8:
- go test -tags nogui -count=1 -timeout 45m on the packages the batch
  changes (agent, autostart, daemon, gateway, library, proc, provider,
  sessions, testenv, tui, gui): ok each.
- GUI, node --test with Playwright 1.62.0, Chromium and WebKit:
  library-*.test.cjs and i18n-keys.test.cjs, 1044 of 1044 pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... and go build ./...: ok at cdd7c8e46, the same
  batch on origin/main 00098f12b one rebase before.
- The whole go test ./... at cdd7c8e46: 86 packages ok, one red,
  internal/cli TestEveryRouteHasACommandOrIsNamed (GET
  /api/context/reply has no command), red on main too (#5026).
- Linux (wsl-run, Ubuntu 24.04, at 339055896, the batch on f4c664a09):
  proc, autostart, testenv, tui ok; agent: only TestGrokInstalled red
  (#3548); #4033's proc.Look reds (Zed, Copilot, Qoder, Cursor, Omp)
  pass.
- Windows (win-run, Windows 11, at 339055896): proc, autostart, testenv,
  tui ok; library and agent red in the same tests as on origin/main
  f4c664a09 (#4115, #1827, #4786; #5068, #5069, #5070 filed now).
- Rebased onto origin/main fb1f4856a (three commits, no file in
  common with the batch) and run again at the pushed tree: gofmt -l
  nothing, go build ./... and go vet ./... ok; go test -tags nogui
  sessions, agent, autostart, tui, proc, testenv ok; i18n-keys and
  library-* 1044 of 1044 pass.
- Not run before the push: the whole GUI suite (a run at cdd7c8e46 was
  cut off at 1170 of ~1174 tests when mote rebooted; it runs again after
  the tag and any red is filed).
2026-11-03 20:38:11 +08:00
yetone d10f377657 providers: Names & levels is Names, prices & levels, where a model's own price at one provider is set (ferock4669)
ferock4669 asked on Discord whether magpie has a screen to price each
model, since one model can cost differently on each provider. It has:
each row in a provider's per-model list has a price box (input, output,
cache read, cache write, 1h cache write, long-context tier, $ / 1M
tokens), saved in settings' ModelPrices under pid/model. It wins over
the list price in Usage (usage.Pricer through provider.BasePriceIn) and
in a key's spend cap (usage.KeySpent through NewCoster). Nothing has to
be built; the button opening it said only "Names & levels", so nobody
finds a price there.

What changed:
- The button, its panel's heading and fold, and every note that sends
  the user there say "Names, prices & levels" (zh 名称、价格与推理档位,
  zh-TW 名稱、價格與推理檔位, ja 名前・価格・推論レベル, de "Namen,
  Preise & Stufen"); the gateway's vision and compaction notes, the
  provider package's text, the subsystem pages and the site's start
  docs (en, zh, ja) follow.
- The button's tooltip says it sets what each model costs at this
  provider; Usage's "estimated" tooltip says where a provider's own
  price is set and that it counts over the list price. Both in en, zh,
  zh-TW, ja and de.
- Not changed: the Codex model description text in internal/codexcat
  (it goes to Codex, so a vendor sees it) and core_budget_test's
  history comment.
- app.js: a comment above the price box is shortened so the core
  script stays under its budget, not raised (app.js 116 bytes under
  origin/main).

Run at the pushed head (rebased on origin/main 1af868a15), on mote:
- go test -run 'Budget|ModelPrice|ModelPref|Vision|Compaction'
  ./internal/gui ./internal/provider ./internal/gateway: ok.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows:
  ok (before the rebase, which touched no Go of this change).
- GUI, both engines, every language each file runs: the 149 files that
  name the label or open a provider's editor (before the rebase): 1191
  ok, 30 red in 7 files. Each of the 7 is red the same way alone at
  origin/main without this change: provider-fetch-again (#5057),
  provider-typed (#4673), provider-levels-scroll webkit (#4395),
  provider-picks-stay (#4397), usage-agents-hide (#3414), usage-ledger
  Requests (#5048), mobile-web (#3952, no .git in mote-run's copy).
  name-suffix-remote "chromium de" (ERR_NAME_NOT_RESOLVED once) passed
  alone at the head. After the rebase: model-price-edit, i18n-keys,
  name-suffix-remote, usage-ledger, usage-agents-hide again: go tests above ok; model-price-edit, i18n-keys and
  name-suffix-remote (all 10 cases) ok; usage-ledger Requests and
  usage-agents-hide red as at origin/main 1af868a15.
Broken by hand: model-price-edit.test.cjs at origin/main's label is red
in all 4 cases (the button "Names, prices & levels" is not found).
Not tried: the whole GUI suite (another session's full suite was on
mote, WSL at load ~100 with 31 test runners); the real app.
2026-11-03 17:00:38 +08:00
yetone 276c806db2 plugins: a plugin's own requests are counted; a provider plugin's options get the editor (plugins#592)
zelong77 asked for two things once Devin 0.1.30's cache keep-alive
worked: its pings were invisible in magpie, and the interval and ping
count could only be edited in plugins.json. The owner decided pings are
shown as counted usage and the two numbers are edited in the GUI.

- host.js gives plugins input.magpie.usage(provider, call) and
  input.magpie.account(provider). usage validates the call (kind
  [a-z0-9_-]{1,40}, a model id, whole-number tokens from 0, status at
  most 999, error clipped to 500) and sends an unasked "usage" event;
  host.go hands it to plugin.OnUsage in the background.
- internal/usage/plugin_calls.go writes each one as a row of agent
  magpie on the plugin's provider (provider.PluginID) and account
  (provider.PluginAccountUser), with its kind. It is counted, priced
  and in every total, not a probe. Kind cache_keepalive is in the
  purpose catalog as "Cache keep-alive" (five languages), so the
  request log names and filters it. The ping itself still goes straight
  to Devin, never through the gateway, which would break the cache.
- /api/plugins reads every plugin's package options example, not only a
  middleware's or request hook's, and the Installed row offers the same
  Options JSON editor for a provider or agent plugin that suggests or
  has options (not while it is off). Clear's confirm no longer calls
  them a middleware's options.
- The Devin mover's min is 0.1.31, which reports each ping and gives
  its two settings' defaults (285 s, 6) to the editor. npm has 0.1.31
  (published 10:03Z); the plugins publish run is red only for
  think-tags' known E404 (plugins#180).
- docs: provider-plugins.md (the API, the options editor),
  gateway-sessions.md (the counted row beside probes).

Run at this tree (rebased on origin/main 85e37162e):
- mote (mote-run): go test -count=1 -timeout 45m ./internal/plugin
  ./internal/usage ./internal/gui ./internal/provider: plugin, usage,
  provider ok; gui red only in TestMainWindowCorners/macOS_26_SDK, the
  macOS 27 red already filed as #3949 (not this change's code).
- mote: GOOS=linux and GOOS=windows go vet of plugin, usage, provider ok;
  gofmt -l clean.
- mote: plugin-provider-options.test.cjs (new, 5 languages, 980/420px,
  Chromium + WebKit), plugin-gateway.test.cjs and i18n-keys.test.cjs:
  28 of 28 pass.
- The whole GUI suite (make test-ui) on WSL magpie-desktop (mote was at
  load ~100 with other sessions' suites, #4125), at the 8f804396f base:
  cut off after 498 test entries, when the session's background jobs
  were killed; 495 ok, 3 red, none on a page this change touches. Run
  again alone at origin/main 85e37162e, the same files are red there
  too: account-eye webkit (#4244), agent-expand-steady webkit 980px
  (#2935), add-button zh's 3000ms waitForFunction (filed #4792). The
  rest of the suite was not run.
Broken by hand (each red, then put back):
- host.go dropping the "usage" event: TestPluginReportsOwnUsage fails.
- plugins.go reading optionsExample for middleware/hooks only:
  TestProviderPluginOptionsExample fails.
- purpose.go without the Cache keep-alive kind:
  TestPluginKeepaliveIsCounted fails (purpose {}).
- plugins.js without ownOpts: plugin-provider-options.test.cjs times
  out waiting for the Options button in every language.
Not tried: a real Devin account's keep-alive ping reported into a real
magpie (needs a live Devin conversation idle for 285 s); a plugin can
report a row for any provider id, as magpie.load can.
2026-11-01 22:14:19 +08:00
yetone e84870f173 plugins: an option's words in the window's language, and a filtered model list says so (plugins#590)
anewuser6937 (Discord, plugins#590) saw one model in WorkBuddy's editor
and took the plugin for broken. They had turned on "Free models only"
themselves, but its label and description read in English in the Chinese
window, and nothing by the models said the list was filtered.

A plugin option (auth.options, magpie's own field; OpenCode's AuthHook is
provider/loader/methods and never reads it) may now give `labels`,
`descriptions` and `confirms`, each keyed by the window's language
("zh", "zh-TW", "ja", "de"), beside the plain strings, as a page's
`titles` do. The host keeps only non-empty strings under language names
of 16 or less, 16 languages at most, each capped as the plain one is
(60/300/300). The editor shows the exact language, then its first part
(zh-TW reads zh), else the plain words, in the row, the hint, and the
confirm dialog and its title. `filtersModels: true` says the plugin's
model list leaves models out while the switch is on; while one is on, as
saved, the Models field says under the chips "Only some models are
listed: the plugin option “…” is on." (zh 只列出部分模型:插件选项「…」已开启。,
zh-TW, ja, de too). An older plugin shows what it showed before, and an
older magpie shows a new plugin's plain words with no note.

WorkBuddy 0.2.10 gives "Free models only" in all four languages with
filtersModels (magpie-community/plugins aec58ae, on npm: `npm view
@magpie-community/opencode-workbuddy-auth@0.2.10 --prefer-online` on mote
says 0.2.10, latest), and the mover's min is raised to it so every moved
user gets it. The CLI's `magpie plugin options` stays English, as the CLI is.

The core scripts would have gone 608 bytes over their budget; three of the
provider editor's comments in app.js are cut down instead, no raise
(1,532,865 of 1,533,105).

Run, on mote (mote-run), at this tree:
- node --test plugin-option-words.test.cjs (new): Chromium and WebKit,
  1100 and 420 wide, en/zh/zh-TW/ja/de, switch on and off: each
  language's label and description, zh-TW falling back to zh and ja/de to
  the plain words for a zh-only option, the note exactly once under the
  chips in a .hint inside the editor with no sideways scroll, none while
  off, the confirm in the language. With app.js put back: 19 of 21 red
  in Chromium (only "en off" passes, both widths).
- With plugin-options.test.cjs and i18n-keys.test.cjs, both engines:
  68 pass, 0 fail.
- go test ./internal/plugin ./internal/provider ./internal/cli: ok.
  TestPluginOptions with host.js put back: red (empty maps, FiltersModels
  false). The real WorkBuddy 0.2.10 index.mjs loaded into this host
  (a temporary test, not kept): plugin.Providers lists free_only for
  workbuddy and workbuddy-ai with all four languages and filtersModels true.
- go test ./internal/gui: TestCoreScriptBudget ok after the cut. Red,
  and red the same at origin/main ed5872d18 (run there too):
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514), TestMainWindowCorners
  /macOS_26_SDK on macOS 27 (#3949); TestColdTurnsTaken red once in the
  package run and passed at origin/main (#4510, the same 0.00s red).
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- plugins: HOME=$(mktemp -d) bun test packages/workbuddy 303 pass 0
  fail; the new freeonly test red 2 of 2 with index.mjs put back.

Not run: the whole GUI suite. mote and the WSL box were each running
another session's full GUI suite (hours left on both), and one runs per
machine; it runs on mote once that one ends. Not tried: a real WorkBuddy
account in the real app window. go test ./... was not run.
2026-11-01 13:24:50 +08:00
yetone a6217e83d3 plugins: a plugin npm said nothing of offers Install, not Coming soon (zhudabao8433 on Discord)
zhudabao8433 on Discord (#general, 11-01): PowerContext
(@magpie-community/gateway-powercontext) could be installed yesterday and
today reads 即将上线 again.

Cause: PowerContext was never pulled. It is in registry.json since
plugins 1e4c8a2 (10-29) and on the dist branch (0.2.0, every dist commit
since), and not on npm (E404), so magpie learns its version from the
dist branch's ~1.7MB index.json. Coming soon is drawn whenever a listing
has an npm answer with no version, and three paths gave one without
anything confirming the package is missing:
- builds before v0.1.2413 kept a dist read cut off at npmEach (6s) as
  "not on npm" in plugin-npm.json (ferock, e0eb74987). After an update,
  InfoCached (the listings) and Info ("what it said last") still served
  that empty answer while a new ask couldn't read the branch;
- the page turned every listing /api/plugins/npm said nothing of
  (unknown: npm or the branch not read in time) into { weekly: 0 }, i.e.
  Coming soon, and never asked again;
- /api/plugins/market gave every listing &NPM{} even when Info had no
  answer for it.

Fix:
- market.go: a cached "not on npm" over an hour old is unknown
  (npmEntry.missingStale): left out of InfoCached and of Info's seed.
  One said within the hour stands, as before.
- plugins.js: a listing npm said nothing of is marked unknown ({ u: 1 }), which
  offers Install (installDist waits for the branch with its own read);
  the page asks again up to 4 times, 15s apart, and the answer replaces
  it. A listing npm answered with no version still reads Coming soon.
- plugins.go: pluginMarketState leaves NPM nil when Info has no answer.

Old data: an old "not on npm" is unknown once an hour old, for every
user, with nothing to do on their side.

Tests:
- TestStaleMissingIsUnknownWhileDistUnread (internal/plugin): an
  hours-old "not on npm" with the dist branch 503 is in neither
  InfoCached nor Info; a minute-old one stands; once the branch answers,
  Info has 0.2.0.
- plugin-npm-unknown.test.cjs: PowerContext with no npm answer shows
  Install (enabled), Qoder answered without a version shows Coming soon,
  and after the 15s re-ask (page.clock) PowerContext shows v0.2.0. en,
  zh, zh-TW, ja, de; 980 and 420px; Chromium and WebKit.

Run (mote, at this commit rebased on origin/main 36af588e2):
- gofmt -l clean; go vet darwin, GOOS=windows, GOOS=linux -tags nogui on
  ./internal/plugin/... ./internal/gui/...: ok.
- go test -count=1 -timeout 45m ./internal/plugin/...: ok.
  ./internal/gui/...: TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestMainWindowCorners/macOS_26_SDK (#3949) red, the same on an
  origin/main 36af588e2 copy; TestCoreScriptBudget green (plugins.js is
  1 byte under main's, a comment cut, no raise).
- node --test plugin-npm-unknown (22/22), plugin-market, i18n-keys: ok.
  plugin-market webkit "the Plugins tab" was red once in the run after
  the Go suite, its output lost; 3 of 3 green after, alone.
- Broken by hand: the Go test is red on origin/main's market.go (an
  hours-old "not on npm" served; want it unknown); plugin-npm-unknown is
  red (waits for Install) on origin/main's plugins.js.
- Earlier GUI batch (70 files: plugin*, market*, i18n*,
  deprecation-notice, list-sort), before the rebase: 968/974; the reds
  are plugin-move-unserved (#4410, #4392, red the same on main) and
  plugin-github-filter chromium en 420px, batch only (#4679).

Not tried: a real slow network from China; zhudabao8433's version is not
known.
2026-11-01 12:12:05 +08:00
JoeyWu-tech a9154b170a gui: the open provider editor holds still as allowances come in (#3492)
congee949 (#3492, Playwright on v0.1.1403's assets, a fixture of five
accounts and 16 models): with a subscription's editor open, the whole
dialog, its head and buttons too, went to opacity .5 and 2px down and
came back as its accounts' allowances came in, for an empty answer
({}) as well. The editor reads them (loginUsageOf) as it is drawn, and
the read's end draws it again (renderProviders). openModal took every
redraw of an open dialog for new content and played the soft refresh
it gives one (.dialog.swap: content-in, 220ms from opacity .5 and
translateY(2px)).

That redraw is now a quiet one: loginUsageOf's finally calls
renderProviders(true), renderProviders hands it to openModal, and
openModal adds no swap for it. The rest of the redraw is as before: the
body keeps its scroll, the focus stays on its control and the dialog
keeps its place (holdModal). Every other call of renderProviders and
openModal passes nothing and does as before. The issue's other way,
filling in only the allowances, would take a second way of drawing an
account's meters and its at-its-cap note beside the editor's own; this
keeps the one. app.js is 33 bytes bigger (1,309,476 of its 1,310,460;
the core's scripts 1,525,572 of 1,526,556), no budget raised. On
origin/main 1a804859 app.js is 1,309,717, so its budget has room, but
the core's scripts are 1,526,548, so coreScriptBudget needs 25 bytes
more for this.

Why the caller says so, and not openModal by comparing the old content
with the new: the allowances coming in and a change the reader makes
in the same editor (an account switched on or off, made first,
renamed) both draw the editor again under the same title, and the swap
is for the second. Of the redraws of an open dialog that no press
starts, only this one draws the same content again:
- a sign-in being followed (followSignIn) draws again only when its
  state, link or code changed, which is new content;
- the list's poll while models are fetched (providersWhileFetching)
  and the window coming back (load) skip an open editor;
- Check balance, a plugin page's buttons and README, a request's
  context text and the update notes fill their dialog in place;
- What's new and the CLI's note open only on a closed dialog.
Every other redraw of an open dialog follows a press: a question and
back, a switch, a sign-in started, an account or a key changed.

account-eye.test.cjs now moves the pointer off the rows before it
checks that an account's eye is quiet with Hide accounts on. The click
on the list's ZCode row leaves the pointer at 180,204, and in the
360px editor the Personal account's name is drawn at y 204 to 221, so
its eye shows. On main the WebKit check passed only because the
allowances' redraw had just started its swap, still on its first
frame when the check ran: the dialog was 2px lower, with the name at
206 to 223. With that redraw quiet, the test as it was is red in
WebKit in en, zh, zh-TW and ja; de's name sits lower (227 to 244).

Not changed: a read that ends while an account is being moved waits
for the move to be saved (accountRenderPending) and is drawn with the
move's own redraw, which plays the swap as any change the reader
makes does. A read that ends while Codex's Sign out question is up
puts the editor back over the question, here as on main (#3943).

What was run (tree fb30c3f4, on origin/main f8cd964a, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077:
- editor-quota-quiet.test.cjs (new; Node 22.22.1, Playwright 1.58.2),
  Chromium and WebKit, en and zh: 3 runs at load 22 to 29, 12 of 12
  each
- the same test with f8cd964a's app.js and app.css: 8 of 12 red, both
  answers in both engines and languages, each at opacity 0.5 as the
  class changed. Chromium: "the dialog dimmed or moved as the
  allowances came in: its opacity 0.5 content-in as its class changed,
  0.5 at its lowest over 5 frames, its top from 16 to 18px". WebKit's
  frames read it later in its 220ms: 0.95 to 0.99 at their lowest, its
  top up to 16.2px. The 4 switch cases ok.
- broken by hand, each alone in a scratch worktree, both engines:
  - loginUsageOf's finally calling renderProviders() again: the same
    8 red
  - renderProviders not handing it on (openModal(dialog)): the same 8
  - openModal not reading it (if (!fresh)): the same 8
  - openModal never swapping (if (false)): the 4 switch cases red,
    "the dialog turned to the question without its swap:
    [{"opacity":1,"anims":[]}]"
  - .dialog.swap's animation set to none in app.css: the same 4
- account-eye.test.cjs, both engines: 2 runs, 30 of 30 each; with
  f8cd964a's app.js and app.css, 30 of 30. As it is at f8cd964a, at
  this tree: red in WebKit's en, zh, zh-TW and ja editor cases, the
  eye at opacity 1 where 0 is wanted. With app.css showing the eye
  always (opacity 1): 30 of 30 red, the editor's on that same check.
- the 214 GUI files that name the modal (#modal, .modal or
  openModal), open a provider's editor, answer /api/login/usage or
  name the swap, and window-mask: each alone, Chromium then WebKit,
  four at a time at load 27 to 72: 411 of 428 runs ok. Each red file
  was run again alone, here and on f8cd964a in turn: red on both with
  the same cases, but for the last two, which come and go:
  - account-arrange, Chromium: the key rename's page error (#3944)
  - update-notes-ask (3 en cases) and whats-new, WebKit:
    "ResizeObserver loop completed with undelivered notifications." as
    a page error (#3942)
  - plugin-github, WebKit, de 440: a click scrolls #view-plugins (55
    to 121), the check #3218 is about
  - vertex-editor, WebKit zh: "a Vertex AI row names its Google
    credentials" and its pills and fields fitting a narrow window and
    browser (a file #1671 names)
  - copilot-signed-out-account (20 cases), revoked-signin-account (10)
    and agent-failover (10), WebKit: innerText read with a newline at
    its end ("Signed out\n") or start, in this box's WebKit (Playwright
    1.58.2; the tests' README names 1.62.1)
  - session-identity, both engines, en light and dark: "both badges
    share one row below the account at 440"
  - usage-ledger, both engines, en and zh: "newest live route needs no
    return-to-live button"
  - provider-remove, WebKit zh: "the Remove click didn't push the page
    down"
  - readable-focus, WebKit: "Tab's focused field stays in sight"
  - modal-centred-late, WebKit, 820px and 560px: "grew over frames"
  - mcp-oauth-app, Chromium, de 390: the box's Cancel sent no cancel.
    Alone, red 2 of 6 runs here and 1 of 12 on f8cd964a: a Cancel
    pressed while the sign-in is still opening (#3984)
  - found-skill-pick-remove, WebKit, en 420: a click moved
    #view-library by 1px; alone, ok 2 of 2 here and on f8cd964a
- go test -tags nogui -count=1 -timeout 45m ./... (tools/suite.sh, Bun
  1.4.2): 69 packages ok and 7 red, none in what this changes: agent
  TestCodexDriftReached (#3398), TestInstalledVersion,
  TestCursorFolderFromTheEditorIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141), the two Reasonix tests (#3641) and
  TestWSLColdPlaceOpensNothing (#3924); edit
  TestWriteAtomicReadOnlyHardLink and testenv TestProgram (umask 077,
  #3640); gateway TestPluginToldWhereTheAgentWorks (#3675); gui
  TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie
  (#3649), TestCoreScriptBudget ok; provider TestCodexAppServersOnHome
  (#3906), then "close of synctest channel from outside bubble"
  (#3632); tui TestTUIFetchesSubscriptionModels/agent (#3919)
- On origin/main 1a804859 with this commit cherry-picked (a scratch
  worktree, not this tree): editor-quota-quiet and account-eye, both
  engines, 42 of 42
Not run: gofmt, vet and the builds; no Go file changes.

Not tried: the real app's webviews (WebKitGTK, WKWebView, WebView2)
and a real subscription's allowance read; the fixture is the
reporter's. Whether every flash in the Qoder recording the issue
started from was this one; the recording wasn't posted.

Review (yetone, at this commit on origin/main bb5e68cea, after
09e09e994 made the 25 bytes' room without raising coreScriptBudget):
- The test moved onto today's editor: since 18005c803 an account's
  buttons, Sign out among them, sit under its ⋯ and the reporter's
  editor fits 1015px whole, so the window is 760 high (251px to
  scroll), the focus is on an account's ⋯, the swap case opens ⋯
  before Sign out, and the focus is matched by its row, class and
  words, not its index, which moves as each account's own refresh
  (923812362) comes in above it. That redraw goes through loginUsageOf
  too, so it is quiet as well.
- Linux (WSL magpie-desktop, Playwright 1.62.0), Chromium and WebKit,
  en and zh: editor-quota-quiet 12 of 12; on main bb5e68cea with only
  the test added, 8 red ("its opacity 0.5 content-in as its class
  changed ... its top from 16 to 18px"), the 4 swap cases ok.
- Broken by hand, Linux: finally's renderProviders(true) back to
  renderProviders(): 8 red; openModal not reading quiet: 8 red;
  openModal never swapping: the 4 swap cases red.
- go test -tags nogui -run Budget ./internal/gui ok on macOS (mote).
- The 94 GUI files this can reach (those with logins, a provider row or
  editor, the swap, the modal, i18n-keys, gui-de, gui-ja, gui-zh-tw and
  sessions-row-narrow), both engines, Linux, 6 at a time: 1725 of 1745
  ok. The red files were run again, 2 at a time, on main with only the
  new test added and at this tree. The reds are the same on both:
  - i18n-keys "Unmarked" (#4524)
  - modal-centred-late in WebKit (#4116)
  - plugin-move-unserved Try again (#4392, #4410)
  - plugin-move "for good" in WebKit (#4471)
  - routing-cline-route in WebKit (#4121)
  - usage-ledger Requests (#4120)
  - session-identity in WebKit, 3 of 3 on both (#4567, filed now)
  account-arrange's WebKit red in the full run passed in both reruns.
Not verified: macOS. On mote at load 25, every browser launch timed
out (180s), so that run tested nothing. Also not tried: the real
Wails webviews, and a real allowance read.

At the pushed tree (rebased on origin/main 7e0fe83d4), Linux, both
engines: editor-quota-quiet and account-eye ok, i18n-keys red only on
#4524; go test -tags nogui -run Budget ./internal/gui ok on mote.
2026-10-31 18:52:01 +08:00
yetone a7b47d57ec accounts: removing the account Claude Code is signed in to switches it to another first (#4532)
StringKe (#4532): removing the signed-in Claude account was refused with
SignedInError, while Codex's switched away first. ForgetLogin now does
the same for Claude Code: nextOnForget picks another account (on first,
then one whose sign-in holds), SwitchLogin signs Claude Code in to it,
and only then is this one forgotten. If that switch fails, nothing is
removed and the error says why.

nextOnForget leaves out accounts Claude Code or Codex can't be signed in
to (switchable: not a setup-token account, not a Codex account held in
another folder). Claude Code is never signed out: when the account is
the only one it can be signed in to, it is kept, with
SignedInError{Only} (GUI code signed_in_only), which says to add another
account first or sign out in Claude Code. The GUI gives the signed-in
Claude row a Remove when another account it can use exists, and no
Remove or Sign out otherwise. Claude Code's own credential is never
deleted; forgetClaudeDir removes only the forgotten account's own
folder and its folder's Keychain item, and claudeHolders' check of
other records holding the same token is unchanged.

Tests: TestForgetLiveClaudeSwitchesFirst, TestForgetOnlyClaudeIsKept
(replacing TestClaudeInUseStillRefused, which held the old refusal);
codex-signout.test.cjs gets three Claude cases (Remove with another;
only + setup-token: no Remove, reason in zh/zh-TW/ja/de; the
signed_in_only refusal in en/zh).

Run (mote, sandbox HOME through the test helpers):
- go test ./internal/provider ./internal/cli, vet and gofmt at the
  stack head: in the next commit's body (one tree, same run).
- Broken by hand, each red: Claude not switched first
  (TestForgetLiveClaudeSwitchesFirst), Only left false, a setup-token
  account counted as another, nextOnForget unfiltered
  (TestForgetOnlyClaudeIsKept).
- GUI on Linux (WSL magpie-desktop), Chromium and WebKit: codex-signout,
  own-signin-remove, saved-signedout-remove, login-import, claude-signin,
  account-alias and i18n-keys all pass but i18n-keys' "a plugin's words
  are its own", red on main (#4524). On mote, codex-signout passed in
  Chromium; its WebKit launches were killed with mote at load ~25 under
  other sessions' suites (#4125), so WebKit's record is Linux's.

CLI in a sandbox HOME (WSL, file credentials): forget of the signed-in
account by its name switched Claude Code to the other (.claude.json then
says max@x.com); forget of the only one was refused with the message
above and left it signed in.

Not tried: a real Claude Code switch on removal with real accounts, or
in the CLI against a live ~/.claude (sandbox only).
2026-10-31 18:18:37 +08:00
yetone 847f0c4703 gui: Masking alert lives on the Masking page
nb5p on Discord (#feedback): "这个脱敏提醒被放到额度设置里了,害得我找半天没找到".
The Masking alert row sat in Settings › Usage. It now closes Insights ›
Masking, after the list of requests, in the page's own `.list.prefs` rows
(same Off/On segs, same ids #maskAlertRow/#maskAlertSegs, same i18n keys
and the same maskAlert setting). Nothing is left in Usage. The page draws
it from page.js after loadSettings, hides it while one request is open,
and gateway mode leaves it out as Settings did. Placed after the list so
the requests still start in the first screen (masking-records at 640px)
and the demo keeps its place between the card and the list.

Run at base 07a3312c5 with this change:
- mask-alert.test.cjs, Chromium (WSL magpie-desktop and mote) and WebKit
  (WSL), en/zh/zh-TW/ja/de at 900 and 380px: all pass.
- WebKit (WSL): mask-alert, masking-records, masking-demo,
  masking-demo-unblurred: 87 pass, 0 fail (tree differed from the pushed
  one by a client.js comment reflow only). Earlier WebKit run: turn-done,
  quota-reads, routing-masking, gateway-mode, builtins, sidebar pass.
- Chromium (WSL) at the final tree: i18n-keys, mask-alert, masking-records,
  masking-demo, masking-demo-unblurred, turn-done, quota-reads,
  routing-masking, gateway-mode, builtins, sidebar: 131 pass, 1 fail. The
  fail is i18n-keys "a plugin's words are its own" on "Unmarked"
  (plugins/routing/i18n.js), red on main, #4524.
- mote: go test -timeout 45m ./internal/gui/...: TestCoreScriptBudget and
  the budgets pass (app.js only shrinks). Red: TestSettingsSaveKeepsWhat-
  ItDoesNotSend (SearchAll, red on origin/main 93b31f5b7 too, #4514),
  TestColdTurnsTaken (passes alone 3 of 3, #4510), and the AppKit window
  tests killed at their 30s bar on mote over ssh (no window session).

Broken by hand: with internal/gui/assets back as on 07a3312c5 (row in
Settings › Usage, none on the page), mask-alert.test.cjs went 11 of 12
red in Chromium; the feature-off test is the one that still passes.

Not tried: the real app (desktop window) and WebKit on mote, whose
Playwright WebKit launch hangs there.
2026-10-31 14:05:02 +08:00
yetoneandggbdpq bdc1617bed routing: Accounts and keys count the whole day, not the last kept requests (#3351)
1234fsdc: the live Routing page's Accounts and keys said tried and
answered over the requests the page still keeps in memory, so on a busy
day the counts were a sliver of what Usage showed for the same accounts
and went down as old requests fell off. /api/trace/history (the read the
live page already makes every 15s) now carries `tallies`: per account or
key, today's tries, answers, fails by reason, models answered, the last
answer and the latest rest, read from routing/<today>.jsonl. The page
seeds the list with them and still takes the latest rest and readings
from the requests it keeps; a day looked at, or a purpose picked, counts
its own list as before. The note says "over today's requests" then.
Ported from ggbdpq's patch on the issue.

Changed from the patch:
- The patch parsed the whole day's file under history.mu on every look.
  A busy day's file is hundreds of MB (#3383) and saveRoute takes the
  same lock, so every 15s poll would stall the routes being written.
  DayTallies now folds in only the whole lines added since the last
  look (it keeps the offset, as History does); a line still being
  written waits for its end. It starts again when the day changes, the
  file shrank or was compressed, or the folder moved (another HOME).
- What it returns is a copy: the patch handed out the live tallies,
  and the JSON writer read a Fails map the next fold wrote.
- The latest name and rest go by the try's time, so no sort per look.
- docs/subsystems/gui-shell.md says how the counts are made and that a
  request done since the last look is counted at the next one.

Run on mote at this change on 394a92f0f. The pushed parent 5787d758a
adds usage, tray, redact and search changes and none of this change's
files:
- gofmt -l clean; go vet ./internal/gateway ./internal/gui for darwin,
  windows, and linux -tags nogui.
- go test ./internal/gateway -race -run 'History|DayTallies': ok.
- go test ./internal/gui -count=1 -timeout 45m: red in 11 tests, all
  red on main too. Ten are real-window AppKit tests killed at their
  deadline on mote (the same ten at 03f3e1528, #4125).
  TestSettingsSaveKeepsWhatItDoesNotSend is SearchAll on main (#4514).
  TestLiveHistoryTalliesTheWholeDay passes. At the pushed head, -run
  'Budget|Tallies': ok.
- GUI on WSL (wsl-run, Ubuntu 24.04, Playwright 1.62.0, Chromium and
  WebKit, every language each file runs):
  - The 229 test files that reach the Routing page, plus i18n-keys, at
    this change on 576b5dcbc (--test-concurrency=4): 3498 tests, 101 red
    in 31 files.
  - Those 31 files on main 03f3e1528: 94 red. With this change: 99 red.
    The same tests fail; which language or engine goes red changes from
    run to run (#4121, #4471).
  - Four of them run alone: 27 red on main, 21 with the change.
  - At 394a92f0f, routing-day-tallies, i18n-keys, account-weight,
    key-weight and routing-weight-chip passed. routing-columns' WebKit
    rows were red, as on main (#4520). Its fixture has no tallies.

Broken by hand:
- DayTallies re-reading the whole file each look (reset always true):
  TestDayTalliesFoldOnlyWhatWasAdded red, "a look after one route read
  101 lines, want 1".
- handing out the live tallies, no copy: red, "a tally handed out
  changed after: ... fails map[rate:3]".

Not tried: a real day's file of hundreds of MB. The first look after a
start still reads the whole day once under history.mu, as History's own
first read does. A real app beside a running gateway. Past days
are unchanged: still counted over their latest historyMax routes.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-31 11:29:38 +08:00
yetone 62c8d21ee5 gui tests: account-arrange acts once the allowances are drawn (#4468)
account-arrange's "account dragging uses the routing order in every mode"
was red alone in WebKit at 31728e29a: line 169's first Antigravity row
had no box. The app is right and the test was wrong. A signed-in
provider's editor is drawn at once and drawn again when its accounts'
allowances come in (loginUsageOf: "loads on its own and fills the rows
in when it's there"), and that redraw replaces every row. The test took
a row from the first draw; when /api/login/usage answered after it (a
busy machine, WebKit), the row it held was gone.

open() and the reload now wait for drawn(page): the first row (with a
load's minute, #4470), then the editing provider's allowance answer in
and not loading, so every action works on the rows that stay. The README
paragraph says so.

What was run (WSL magpie-desktop, Playwright 1.62.0):
- By hand: /api/login/usage answered 1.5s late, a marker set on the name
  first selected. origin/main's file: red in Chromium and WebKit, "the
  name selected is the one drawn last"; this file green in both.
- account-arrange.test.cjs, Chromium, at load ~230-258: green (the first
  run, before the first row got its load's minute; WebKit then went red
  at that 5s first wait, which this file now gives a minute).
- Both engines at load 205-245 (other sessions' suites): this file and
  origin/main's own file both run past the test's 90s budget, Chromium
  and WebKit alike (origin/main's Chromium once red at 14s instead). That
  budget under load is #2200, the same on origin/main, not changed here.

Not tried: the whole GUI suite; mote (#4125) or Windows.
2026-10-31 02:09:18 +08:00
yetone ce8b67de37 gui tests: a page's first load gets a minute, not a click's 5s (#4470)
claude-switch-only set page.setDefaultTimeout(5000) and then called
page.goto with no timeout of its own, so Playwright held the first load
of app.js, i18n.js and the plugins to the 5s bar meant for clicks. On a
busy box (a whole-suite run at load 130-160) that load took longer and
goto timed out. The same pattern is in 988 GUI test files (1174 pages):
every one of them now also sets setDefaultNavigationTimeout(60000) on
the same page, right after its default, so goto, reload and waitForURL
wait on the load itself with room, while clicks and waits keep their
short bar. group-from-model-add's own 20s navigation bar is raised to the
same minute. claude-switch-only also gives its first provider row (drawn
from the page's first reads) a minute before clicking it.

nav-timeout.test.cjs (no browser) reads every GUI test file and names
each page given a default under a minute without a navigation timeout of
at least a minute, so a new file can't bring the pattern back.

What was run (WSL magpie-desktop, Playwright 1.62.0, load 70-260 from
other sessions):
- node --check on every file in internal/gui/tests: all parse.
- nav-timeout.test.cjs against origin/main's test files: red (names the
  1174 pages); against this tree: its only reds were my own probe copies
  of the old files, since removed.
- By hand: claude-switch-only with app.js served 7s late (a busy box's
  first load), --test-name-pattern "1100 en": origin/main's file 4 of 4
  red with "page.goto: Timeout 5000ms exceeded"; this file 4 of 4 green.
- claude-switch-only.test.cjs, both engines, en/zh/ja/de, 1100 and 420:
  32 of 32. group-from-model-add, usage-access-key-card and i18n-keys:
  green. agent-plugin-agents: Chromium green; WebKit's de 420 subtest red
  on a 5s waitForFunction at line 115 (a wait after load, not the
  navigation), at load ~230.

Not tried: the whole GUI suite (about 1000 files; the change is one
mechanical line per page), Windows or mote (mote's browsers, #4125).
2026-10-31 02:09:18 +08:00
yetone a45a0f1c5d signin: Settings can keep sign-in pages out of the default browser (max2020)
max2020 on Discord signs in from a separate, fingerprint browser so the
vendor never sees their default one. Every waiting sign-in already shows
its link with Copy link (since 52c8e838d), but magpie still opened the
page in the default browser first.

Settings › Privacy › Sign-in pages › "Open sign-in pages in the browser",
On by default, so nothing changes unless it is turned off. Off
(settings.SignInLinkOnly) opens nothing: /api/signin and
/api/plugin-signin go through openSignIn, which skips the open and
answers linkOnly; a web tab skips window.open on linkOnly, after an
install step too; the box says the page wasn't opened and its button
reads Open, not Open again. `magpie accounts add` and a plugin's
command-line login print the link without opening it. A plugin whose own
CLI opens the page (Grok Build on macOS and Windows, opened) still does.

Callbacks, by flow: Claude Code's login, Codex (localhost:1455), ChatGPT
API, Gemini/Antigravity and localhost plugins come back to this machine,
so another browser on it finishes them, and the pasted final address
covers one whose proxy keeps it off loopback. Copilot, Grok and other
device-code flows work from any browser.

Run:
- TestSignInLinkOnlyOpensNothing (new; built-in and plugin sign-in, the
  setting on and off) with TestPluginSignIn*, TestSettingsSave*,
  TestCoreScriptBudget and TestI18n* on mote: ok. Budget holds with no
  raise (app.js 1,313,244 of 1,315,316).
- signin-link-only.test.cjs (new; every language, Chromium and WebKit,
  900 and 360px), signin-link and account-discovery on WSL: 42/42 and
  the neighbours green.
- Full Go suite on WSL (go test -timeout 45m ./...): every package ok
  except internal/agent's TestInstalledVersion, TestGrokInstalled,
  TestOmpDetectedWithPiDir and TestZedAppPath, red the same on
  origin/main 387e8572a there (#4033, #3548); root, internal/cli and
  internal/gui need gtk4 there and were run with -tags nogui: ok.
- gofmt; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: clean.
- The whole GUI suite (both engines) is still running on mote at push
  time; reds it shows that aren't on file get issues.

Broken by hand: openSignIn ignoring the setting made the Go test red
("built-in: kept to its link, its page was opened 1 times"); dropping
startSignIn's linkOnly check made the GUI test red ("no page opened",
12 of 42).

Not tried: a real vendor sign-in from a fingerprint browser; Grok on
macOS/Windows still opens its own page; MCP server sign-ins unchanged.
2026-10-31 01:02:24 +08:00
yetone c84c3e1c03 gateway: a key's holder sees its own usage and setup at /me
zytszone on X runs one magpie's gateway for a whole department, whose
people can't be given the admin's app. Each now opens the gateway's /me
at the address they reach it at, types the gateway key they were given,
and sees that key's own name, limits and what is spent of them, its
usage over today, 7 and 30 days with its most used models, the models
it may use, and copy-ready setup for Claude Code (settings.json env),
Codex (config.toml provider, /v1, responses), any OpenAI-compatible
client and a curl test. The base URL is the address the page was
opened at, never 127.0.0.1; the key is a placeholder until "Put my key
in the setup" is ticked. Strings in en, zh, zh-TW, ja and de.

- GET /me (keypage.html, embedded) is the same bytes for everyone and
  holds no data, so lanGuard serves exactly GET/HEAD /me (no escaped
  path) to another machine without a key, after the allow list, the
  rebinding check and the not-shared 403, which still apply. Its CSP
  loads nothing from elsewhere, posts no form and forbids framing.
- GET /v1/magpie/me (keyInfo) answers access.Caller's own key only. No
  key, a wrong one, one turned off and magpie's own token are 401
  alike; ?key= is refused 400 so a key never sits in an address or a
  log. It names no account, other key, provider or secret; its models
  are /v1/models' for that key (keyAllowed), none for a read-only key.
  The page sends the key as Authorization to its own origin with
  credentials omitted and keeps it in sessionStorage only.
- Both are in readOnlyRoutes, /me in clientPrefixes (magpie web's page
  port), and Gateway -> Gateway keys shows the page's address
  (MAGPIE_PUBLIC_URL, else the LAN address offered) with a Copy, while
  shared and with a key. Docs: gateway-routing.md, reference.md.

Run:
- mote: go build -tags nogui ./...; go vet -tags nogui gateway+gui;
  GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gateway;
  go test -tags nogui -count=1 ./internal/gateway ./internal/gui: ok
  (gateway 732s). gofmt -l clean. Rebased onto 18b63fe5f after that;
  there: build, vet, and the KeyPage, read-only, client path, page
  port, LAN guard, caller usage and core script budget tests ok.
- Key page Go tests, through the real lanGuard(Handler()) chain, from
  the network and from loopback: the key sees its own name, usage, top
  model, limits and allowed models and nothing of Bob, Bob's secret,
  the upstream key or magpie's token; no key, wrong key, turned-off key
  (Bearer and x-api-key), magpie's Token, ?key=, Origin null, an
  evil.localhost page, a foreign origin with a good key and a rebound
  Host all get nothing; the page opens without a key, not on POST,
  /me/x or /%6De, and not while unshared; a read-only key gets no
  models.
- GUI, key-page.test.cjs: Chromium on mote and WebKit on the Linux box
  (magpie-desktop), 390px, all five languages, 24 of 24; i18n-keys ok.
  The 46 Gateway/caller-key GUI files and i18n-keys on the Linux box,
  both engines: 645 pass, 11 red at concurrency 4. Serially 6 stay red,
  and the same tests are red on origin/main a0cb8b646 there:
  api-key-theme "system", gateway-key-limit webkit en/zh,
  connect-snippet-shell, gateway-key-models (#4120), phone-rows (#4218).
Broken by hand, each red then restored: lanGuard's /me exemption
removed (page 401); the KeyID check removed (no key/wrong/off/Token got
data); keyAllowed dropped (Alice saw plan/m2); the RawPath check dropped
(/%6De served); the ?key refusal dropped (200 with Alice's data).
Not tried: a real Claude Code or Codex pointed at a shared gateway with
the page's snippets; WebKit on macOS (every WebKit launch on mote hangs
right now, for every session, a bare launch included); the whole GUI
suite and a full go test ./... (one suite per machine; mote is running
other sessions' suites).
2026-10-30 22:52:05 +08:00
JoeyWu-tech ef9cd2fd6c gui: the tray panel's More in Plugins opens the window on Discover (#3579)
yetone (#3579): in the tray panel, the add sheet's More in Plugins, and
its search's "look for a plugin", asked the window for Plugins with no
more than the view's name (window/main?view=plugins). The window opened
on the tab of Plugins kept from before, Installed or Built-in, with
nothing looked for. 894ec960 made both open Discover in the window
itself; this is the panel's half.

The panel now asks for view=plugins&q=, with what its add sheet looked
for, empty when nothing was. More in Plugins sends the sheet's search,
lowercased, when it shows beside one (a search naming a subscription a
plugin serves, kiro say), and look for a plugin sends the search that
found nothing. mainView passes q on for Plugins whenever it is there,
empty too, since its being there is what says Discover; a q with a
control character (a newline, a tab) or over 100 code points goes on
empty. The window
opened on that address does what its own More in Plugins does
(pluginQuery): Discover, looking for q. start.js does it when the
window's first show() is done, so after show() has sent a window with a
plugin's update waiting to Installed, as the window's own More in
Plugins calls pluginQuery after show() too. It does it once: syncURL,
which show() calls, now takes q out of the address, so a reload, or the
window opened on Plugins again without a q, shows the tab kept, as
before. In the same window Plugins stays on Discover until another tab
is picked, as after the window's own More in Plugins. The GUI tests'
README describes the new half.

The deprecation note's Review in Plugins (several deprecated
subscriptions signed in) goes through openPlugins too, so from the
panel it now opens Discover as well, as it has in the window since
894ec960. openPlugins is the only sender of window/main?view=plugins.

plugins.js is not changed. app.js grows 94 bytes and start.js 182; with
the previous commit the core's scripts are 3 bytes under main's,
1,527,969 of 1,528,076, and app.js is 1,309,997 of 1,310,460.

Not changed: the window's own More in Plugins, and every other page the
panel opens the window on. mainView takes the view's own value
unchecked, so a q inside it skips mainFind (#3846); q goes no further
than Plugins' search field and its npm search, as typed there.

What was run (tree 7dce6444, on origin/main 56602426, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, the Go tests at umask 077:
- plugins-more-discover (Node 22.22.1, Playwright 1.58.2), its panel and
  window halves new, in English and Chinese, 5 times in Chromium and 5
  in WebKit: 3 of 3 pass each time. The panel, on a first use (where it
  shows the add sheet), asks for ?view=plugins&q= from More in Plugins
  and ?view=plugins&q=fake%20co%26x from "look for a plugin" after a
  search for "fake co&x" found nothing. The window, at what mainView
  makes of those (?view=plugins&q=fake+co%26x, and &q=) with Installed
  the tab kept, shows Discover with the search in its field, and its
  address keeps no q, so a reload shows Installed. With a plugin's
  update waiting (the test holds start.js until the update's answer is
  sent; WebKit has it by the first show(), Chromium not always, see the
  breaks), Plugins opened without a q shows Installed, and the window
  the panel opened shows Discover.
- TestMainView's new cases: Plugins with no q, an empty q, a word,
  "fake co&x", Chinese with &view=settings in it, a newline, a tab, 100
  and 101 characters, 100 and 101 Chinese characters, and Settings with
  a q. TestMainURL's: "智谱 glm" reads back from the window's address as
  it was sent. With TestCoreScriptBudget, -count=50: 150 of 150 pass.
- Broken by hand, each red in plugins-more-discover:
  - the panel asking for view=plugins alone, as on main: 0 of 3 in
    each engine, at the panel's asks (?view=plugins for
    ?view=plugins&q= and for ?view=plugins&q=fake%20co%26x);
  - start.js not looking for q, as on main: 0 of 3 in each engine, the
    window the panel opened on Installed (已安装 in Chinese) for
    Discover;
  - Discover asked as start.js loads, before show(): WebKit 0 of 3 in
    each of 5 runs, en and zh at "the window the panel opened, an
    update waiting", Installed for Discover; Chromium red there in 2
    of the 5 (en in both, zh in one). 25e1d038's record, its window
    half in plugins.js, had Chromium red in 4 runs of 4 (en every run,
    zh in 2);
  - q left in the address (syncURL's q.delete taken out): 0 of 3 in
    each engine, the address after the window opened still
    ?view=plugins&q=fake+co%26x for ?view=plugins.
- Every GUI file that reaches Plugins, the panel's add sheet or the
  window the panel opens (the same 53 as 25e1d038's record, by a grep
  for view=plugins, window/main, more-plugins, pluginQuery, pluginTab,
  lookFor, look for a plugin, show("plugins") and #view-plugins), and
  i18n-keys, each alone in both engines: 94 of 108 runs green. The
  other 14 are red at 56602426 too, alone, and none is in what this
  changes. Playwright here is 1.58.2, older than the 1.62.1 the GUI
  tests' README names, so some of these may be red with this
  Chromium or WebKit only; those with no issue named have none yet:
  - builtins, WebKit: Plugins › Built-in, the Observability switch's
    click times out; the stuck Plugins head intercepts the pointer.
  - i18n-keys, run twice (it needs no browser): "a plugin's words are
    its own", for plugins/routing/i18n.js's "masking…" (#4053).
  - mobile-web, both engines: its "desktop matches origin/main" cases
    compare with BASE_REF, origin/main by default, as git has it at
    the run, which had moved on from 56602426 (the Gateway page's
    screenshots differ). A copy with BASE_REF set to 56602426 passes
    15 of 15 in each engine.
  - modal-centred-late, WebKit: 820px and 560px, the dialog reaches its
    README's height with fewer than 3 frames between
    ([407,575,676,674,672] and [407,466,519,520,520,520]).
  - plugin-card-update, WebKit: en and zh, the wait for the Update
    button times out, in 4 runs of 4; at 56602426 the same in 3 runs
    of 4, and zh alone in the other (#3079 has en).
  - plugin-github, WebKit: de 440, a click moves #view-plugins from 73
    to 135 (#3218 has the same check red in Chromium, by 1px).
  - plugin-github-wait, Chromium: de 440, a press on Try again
    moves #view-plugins by 2.
  - plugin-release, WebKit: en and zh read the line with a trailing
    newline ("Serves Zed\n").
  - settings-lines-wrap, both engines: de 440px, a row's line is cut
    short, Usage's in Chromium and General's in WebKit.
  - title-bar-tools: in Chromium, de, the wait for the Plugins head
    times out; in WebKit, all five languages, here and at 56602426:
    zh, zh-TW, ja and en for page errors from the fetches a reload cut
    off (/api/agents/cli, /api/agents/install, /api/update and
    /api/whatsnew; #2740 has /api/providers'), and de for that same
    wait.
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
  vet for windows, go build -tags nogui for linux and darwin and go
  build for windows: exit 0 each. go vet and go build without the tag
  on linux: exit 1 (no libsoup-3.0 or gio-unix-2.0 here).
- go test -tags nogui -count=1 -timeout 45m ./... (Bun 1.4.2, log
  kept; 8m41s, load 40 at its start): 72 packages ok, and 12 tests red
  in 5 packages, none of them this commit's tests or what they cover
  (internal/gui's are its gateway tests): agent TestInstalledVersion,
  TestCursorFolderFromTheEditorIsNotTheCLI,
  TestCopilotFolderFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141);
  TestReasonixCLIRequiresSupportedNativeVersion and
  TestReasonixCLIRecoversAfterProbeTimeout (#3641); edit
  TestWriteAtomicReadOnlyHardLink and testenv TestProgram
  (umask 077, #3640); gateway TestPluginToldWhereTheAgentWorks
  (the /tmp/.git of #3675); gui TestGatewayHeldByAContainer and
  TestGatewayFixQuitsOnlyAMagpie (#3649).

The rest is what was run for 25e1d038, at tree ffc1adb1 on origin/main
02cbdf5b, the same Go code, tests and README (its window half was in
plugins.js, where this one's is in start.js; not this tree):
- Broken by hand in the Go, each red in the Go tests named:
  - mainView passing no q: TestMainURL, and TestMainView's every
    Plugins case with a q;
  - mainView passing any q: TestMainView's newline, tab, 101
    characters and 101 Chinese characters;
  - mainFind as ^.{0,100}$: TestMainView's tab;
  - mainFind counting bytes too: TestMainView's 100 Chinese characters.

Not tried: the real app's tray panel and window, on macOS, Windows or
Linux.

Landed by yetone in a batch of Coffemon's patches from the issues.
What was run, go1.26.8, on origin/main cc81ad4ea, then again at
70a0c387c (gofmt, the three vets, the changed tests, umask 077):
- mote (macOS 27): gofmt -l clean; go vet, GOOS=linux go vet -tags
  nogui and GOOS=windows go vet ./...: ok. edit and testenv at umask
  077; agent, provider, library and gateway with an empty .git above
  TMPDIR; davsync, imagemcp, plugin, library, edit, testenv whole; the
  changed tests in agent, provider, gateway and gui; the timing tests
  -count=10 (gateway, davsync, imagemcp) and -count=5 (agent): all ok.
  TestCoreScriptBudget ok: core 1,536,751 of 1,537,034, app.js
  1,312,975 of 1,315,316, no budget raised.
- Red on the old code: on origin/main, TestWriteAtomicReadOnlyHardLink
  at umask 077 and two Reasonix tests under an empty .git; on Linux
  (wsl-run) TestProgram at umask 077 with the old program.go. With
  each fix's code taken back to main's, the Gemini imageConfig tests,
  TestPluginToldWhereTheAgentWorks, TestSkillRepoTraced,
  TestTaggedHooksAlone, TestMainURL/TestMainView and update-auto,
  plugin-github-hooks, plugins-more-discover, plugin-namesake were
  red. Broken by hand: claudeKeyed always true (both
  OwnEndpointNeverAsked tests red), claudeAsk a no-op
  (TestClaudeFirstWriteAsksTheProxy red), GitAt taking any .git folder
  (the three TestGitOnDisk tests red).
- GUI: 123 files (plugins*, update-*, panel/tray/start/context, i18n,
  gui-zh-tw/ja/de and every file that evals app.js parts) in WebKit on
  Linux (wsl-run). 11 files had reds (click-scroll, panel-fold,
  plugin-card-update, plugin-github, plugin-move*, segs-glide,
  tray-totals, update-*), and run again side by side they fail the
  same on origin/main d80d75f30 (79 pass, 26 fail here; 78 and 27
  there). They are click-scroll guards ("the click must not scroll
  the page"), varying by language from run to run (#4385).
  copilot-ghe's route-after-close red is #1949, seen on main 244d80e23
  too. In Chromium on mote, Chromium segfaulted partway through files
  (#4125): context-map, context-scroll-end and context-tune fail the
  same on origin/main 0911a65e7, so the batch's own files
  (plugin-namesake, update-auto, plugins-more-discover,
  plugin-github-hooks) ran in Chromium on Linux: 62 of 62.
- Full suite (go test -tags nogui -count=1 -timeout 45m ./..., mote)
  at 472a0608f (on 70a0c387c): every package ok but internal/gateway,
  whose five reds were #4362's (Antigravity turned-away and
  TestCodexSpentGrokFailingIsTold), fixed on main in d80d75f30. After
  the rebase on 244d80e23 the five pass, and gofmt, the three vets
  and the targeted runs above were run again: ok. In Linux the
  sign-in, copilot, plugin-github*, plugins-more-discover,
  plugin-namesake, plugin-gateway, update-auto, quota-refresh-order
  and i18n files ran in both engines: 475 pass, 4 fail (copilot-ghe
  #1949, plugin-github's click scroll, both red on main too).
- Rebased again on c7171a256, over its budget fix e94bf7a08: gofmt, vet of
  gui, gateway, provider and plugin, TestCoreScriptBudget (core
  1,536,265 of 1,536,586 with the batch's last commit, statusTErr and settingsErr), the Gemini,
  GitOnDisk and plugin tests, and in Linux both engines i18n-keys,
  update-mirror, plugin-namesake, plugins-more-discover,
  plugin-github-hooks and update-auto (138 of 138): ok.
Not tried: the whole GUI suite (mote's WebKit wouldn't launch and its
Chromium segfaulted, #4125); macOS WebKit; the real app's window.
2026-10-30 15:53:22 +08:00
yetone 44d6979930 gui: a page scrolls rather than squeeze its heads, so opening the Gateway page's models moves nothing over them
The owner, 10-29: 展开模型的时候,这块部分会整体向上移动几个像素. A view is a flex column (since 50db5ccbe), and every box in it has flex-shrink 1. Once the open models list made the Gateway page taller than its window, flex shrank each box of a set height down to its content. Connect's head went from 26px to 21.4, the models' head to its search field's 24, and the models' label moved up 5.6px. Every view's direct children now have `:where(.view) > * { flex-shrink: 0 }`, so the view scrolls instead. :where() weighs nothing, so a box that sets its own flex (.view-room's none) keeps it. This reaches every page: any head or box of a set height on a page taller than its window was squeezed the same way.

gateway-models-open-steady.test.cjs opens the folded models with 30 of them, in Chromium and WebKit, en and zh, in the window and in magpie web. Connect's head, the models' head and its label keep their top and height, every head on the page keeps its height, and folded again the label is back.

Run on mote (node 22, Playwright 1.62.0):
- gateway-models-open-steady: 8 of 8. With app.css put back to origin/main's, 8 of 8 red ("opening took connect from 26px to 21.390625px").
- A measuring script on origin/main c46829e0b, before the fix: connect 26 → 21.4, models 26 → 24, label 286 → 280.4. After the fix: all unchanged, in both engines, window and web.
Rebased onto f5806ed21 and pushed without the rest: the whole GUI suite
(this change reaches every page) was still running on mote at 936bc67ee,
the same tree before the rebase. Its result goes on an issue when it ends,
with every new red against #4119's run.
2026-10-30 00:39:03 +08:00
yetone 5637cca141 settings: a notification when masking swaps a value for the first time (Must2333 on X)
Must2333 on X: "我还希望能即时的知道发生了替换,但不是通过随时监控网关的方式".
They want to know when magpie masks something without watching the
gateway or the 脱敏 page.

Settings › Usage has a new row, "Masking alert" (zh 脱敏提醒), after the
task done alert. Off/On, off by default. When on, a value masked for the
first time gives a system notification through the same notifier as the
other alerts. It says only how many new values, each kind and its count,
and the agents that sent them (two named, "+N" for more). It never says
the value, any piece of it, or the Head hint the 脱敏 page keeps. A click
opens the 脱敏 page on the latest record (clickView, "masking&key=<key>").

Why off by default: every other notification in this group is off until
turned on; turning one on asks macOS for notification permission; for
most users a notice each time masking works is noise, since masking's
expected behaviour is quiet protection. It is one row, in the group that
already holds the alerts, hidden while masking is switched off
(data-feature="redact") and in gateway mode.

Staying quiet:
- First time only: maskrec.Fresh says which values a record has that no
  record before it had. A conversation sends its whole history each turn,
  so a value is masked again every turn after its first. The index is by
  placeholder (HMAC-stable across restarts), filled from memory and from
  the days kept on disk, so a restart doesn't make a history new again.
  The days are read off the lock, since Hold takes it on the request's
  way. Values sent as written (Action "warn") are left out.
- A burst is one notification: records gather for 3s (maskGather).
- At most one every minute (maskGap); what comes in between is said
  together after it. At most 5000 records wait.
- With the setting off, nothing is kept.

The gateway tells the app through gateway.OnMasked, after maskrec.Hold,
with Snips and Back taken out; nil under `magpie serve`.

Strings: en, zh, zh-TW, ja, de, in i18n.js (the row) and in
mask_alert.go (the notification's title and kind names, the 脱敏 page's
own words for the kinds). docs/subsystems/gateway-routing.md has the
bullet. The core script budget isn't raised: main's 10-29 budget leaves
room for the row's 287 bytes.

Tests, each broken by hand and seen red:
- TestMaskAlertFirstTimeOnly: masks through redact.Mask as the gateway
  does; the history masked again says nothing, a new email in turn 4 is
  said alone. Red when flush counts r.Values instead of the fresh ones.
- TestMaskAlertNeverSaysTheValue: no 4-character piece of the key, email
  or phone, and no Head, in any of the 5 languages. Red with the Head
  added to the kind's name.
- TestMaskAlertCoalesces: a burst of 5 from 3 agents is one wait of
  maskGather and one notification ("+1"); two more 10s later wait
  maskGap-10s and are said as one; off keeps nothing. Red without the
  waiting check (5 waits) and without the maskGap wait ("waits 3s want
  50s").
- TestFreshOnlyTheFirstTime, TestFreshHeldWhileReading (maskrec). Red
  with loadFirst skipping the disk read (the history new after a
  restart), and with the index broken (both).
- TestDismissedAlertOpensNothing covers the mask notice's click.
- mask-alert.test.cjs: every language at 900 and 380px, both engines:
  the row after the task done alert, Off at first, On saves maskAlert,
  another save keeps it, Off saves false, no click moves the page, no
  left border, gone with masking switched off. Red with maskAlert taken
  out of prefsKeep, and with data-feature taken off the row.

Run:
- This change on main 2b6ff0fbf (its parent here, c93d9e0c0, changes
  only usage's Codex effort cache after it), on mote: go test ./internal/gui
  ./internal/maskrec ./internal/settings ./internal/gateway; GUI files
  mask-alert, turn-done, gateway-mode, settings-search, i18n-keys (68
  pass, 0 fail); gofmt -l; go vet for darwin, GOOS=windows, and
  GOOS=linux -tags nogui, all ok. internal/gui's one red is
  TestMainWindowCorners/macOS_26_SDK, #3949, red on main too.
- At the same change on main ddf31ca30, 23 commits back: the full Go
  suite on mote, -timeout 45m. Every package ok but internal/gui: the
  budget (since fixed by the rebase), TestMainWindowCorners (#3949), and
  nine real-window AppKit tests killed at their deadlines while mote's
  pboard was down (#4125). Run again once pboard was back, all nine
  passed.
- The whole GUI suite, both engines, every language, on the Windows box
  (mote's GUI run was cut short by the pboard crash, #4125): 14235
  tests, 13951 pass, 284 fail in 65 files. The same files at ddf31ca30:
  291 fail. All 22 mask-alert tests pass there. The 8 files red only at
  this change were run again at both commits and each goes red and
  green on its own, mostly WebKit (#4124).
- The real app on mote, in a sandbox HOME, with a fake upstream: what
  the upstream got was placeholders only ({{API_KEY_…}}, {{EMAIL_…}},
  {{PHONE_…}}). Three turns in a minute became one notification 3s after
  the first, and a new email in a later turn the next one, exactly 60.0s
  after.

Not tried:
- The banner itself: macOS refused notification permission to the
  sandbox bundle (ad hoc signed and dev signed, "didGrant: 0 hasError:
  1"), and no one was at mote's screen to allow it. What was seen is the
  send, in the app's log.
- Windows and Linux notifications, and a click from a real banner.
- Values masked again after the 30 days the records are kept are said
  again. Blocked requests and warn-only values aren't notified. No
  session id is shown.
2026-10-29 06:38:04 +08:00
yetone 11cbf4de1d usage: Sessions' agent filter is a menu, as the model and folder ones beside it
The owner (10-28, screenshot of Usage › Sessions with 13 agents in a strip
across the page): "这应该是个 Combo Box". The agent filter was a segmented
strip, one segment per agent in range, that scrolled sideways in itself
once it ran past the window (#929). It is now the same sessPick button
as 全部模型 and 全部文件夹, with the same searchable menu: "All agents",
then every agent with sessions or usage in the range, the most used
first, each with its tokens under the other two filters. One agent in
range still leaves it hidden; the pick still resets to All when its agent
leaves the range. The request ledger's agent filter was already this menu.

#sessAgent left the CSS rules for scrolling strips; the strip's own test
(sess-agent-strip, #929's sideways scroll) is gone with the strip, and
usage-sessions-agents-fit now checks the menu: no sideways scroll at 860
and 560 wide, the three filters on one line inside the window, the
menu's order, search, a pick shown on the button and kept when the page
is drawn again, All clearing it, one agent hidden. sessions-empty-range
and sessions-overview-once pick their agent from the menu.

Run on mote (node 22, Playwright 1.62.0):
- usage-sessions-agents-fit, sessions-empty-range, sessions-overview-once:
  24 of 24, Chromium and WebKit, every language they cover.
- usage-sessions-agents-fit against origin/main's page.js, client.js and
  app.css: red in all four (BUTTON.sess-pick expected, a div of segments).
- go test -tags nogui -run Budget ./internal/gui: ok.
- 122 other GUI files that touch Usage, sess-pick or i18n, concurrency 3,
  beside another session's full GUI suite (load 36-75): 1944 pass, 24
  fail in gateway-caller-keys, gateway-key-cycle, i18n-keys,
  mcp-oauth-app, usage-ledger and web-page. Rerun alone at concurrency
  1 on this tree and on origin/main (d4f1d6480, then c4972b36e after the
  rebase): the same reds on both. gateway-key-cycle is #4072,
  gateway-caller-keys #3797, usage-ledger's "newest live route" #4078,
  web-page's #gateway .dot #4079. i18n-keys' "masking…" was fixed on
  main in 174250b27. mcp-oauth-app passes alone on both.
- At this tree, rebased onto 6ecc65b6d (the pushed tree):
  usage-sessions-agents-fit, sessions-empty-range,
  sessions-overview-once, i18n-keys and click-scroll 50 of 50, and
  go test -tags nogui -run Budget ./internal/gui ok.
Not run: the whole GUI suite (another session's was running on mote).
2026-10-28 22:52:30 +08:00
yetoneandJoeyWu-tech 761e0e0105 gui: a Settings option pressed through two redraws clicks its newest self (#3922)
Browser access draws twice per renderSettings: once at once, and once
more when its /api/web-page answer comes. When that answer landed
between the release and the click segs' pointerup sets off, the option
the release found was gone by the click and nothing was sent, which
segs-press-redraw's sweep saw on Network's web-page list. The click now
goes to the control's newest self (same segsWho, same option), found
again whether or not a draw came since; dragged off or gone still picks
nothing.

From Coffemon's patch on #3922 (JoeyWu-tech, fix/3922-segs-newest,
c1b5575af and e8c831736): the test's new redrawn-twice case, reveal()
waiting for each wheel's scroll to land, and the README entry, taken as
is. The app.js change is his, shorter: his kept b when still there and
looked up the newest self otherwise (+298 bytes); the lookup finds b
itself when b is still there, so it is used alone (+129 bytes). Main's
core had 18 bytes of room left when this landed; TestCoreScriptBudget
is green and no budget is raised.

What was run (mote, Playwright 1.62.0, Chromium and WebKit, en, zh, ja,
de, 900 and 440px):
- The new test on main's app.js: 22 of 42 red, both engines.
- With this change: 42 of 42.
- Broken by hand (the newest self's option taken as [0], not p.i):
  Chromium 17 red.
- go test -run TestCoreScriptBudget ./internal/gui: ok.

Not tried: the real app's webview, or a loaded Mac.

Co-authored-by: JoeyWu-tech <joey110551567@gmail.com>
2026-10-28 16:58:22 +08:00
yetone 1d7ca4c6b7 gui: every scroller in every stylesheet is held to keep the wheel; Safari 15 too
碳碳双键 (ysm119, Discord): a list scrolled to its top or foot by the
wheel went on to scroll the page, "in many places". d74ef5e04 (v0.1.1839)
already marks every box that scrolls and overflows between the pointer and
its .view (`holds`, app.js) and gives it overscroll-behavior-y: contain by
one rule in app.css. This makes that a guard and closes the one engine gap:

- inner-scroll-contain.test.cjs gains a test that reads every rule in every
  stylesheet under assets (app.css, plugins.css, context.css, omarchy.css
  and plugins/*/*.css; any not linked is added) that sets overflow or
  overflow-y to auto/scroll, builds a box from each selector (each compound
  an element; body classes put on body; @media rules tried at a size they
  hold for), fills it past its height, points at it, and requires
  overscroll-behavior-y: contain. 39 scrollers hold; .view is the one left
  to chain. A failure names the file and selector.
- compat.js: Safari 15 (macOS 12's WebKit until Safari is updated, #220)
  has no overscroll-behavior, so there a wheel over a .holds box already at
  its end in the wheel's direction is cancelled. Only where
  CSS.supports("overscroll-behavior-y", "contain") is false; Chromium,
  Safari 16+ and WebKitGTK 2.52.6 (probed on the Linux VM: true) never
  register it. There the Mac's bounce at the box's end is lost.
- app.js: the six "notice or ok" status lines share saidOk, to make room
  for compat.js under TestCoreScriptBudget (core 1,526,424 of 1,526,556 at the rebased head);
  no budget raised.

Run (mote, Playwright 1.62, Chromium and WebKit):
- inner-scroll-contain: the new guard and the Safari-15 test 4/4 alone;
  in the scroll batch 7/8, the one red a Chromium launch timeout (180s).
- Scroll batch (inner-scroll-contain, routing-scroll-end, click-scroll,
  view-wheel-*, menu-scroll, context-scroll-end, provider-levels-scroll,
  heatmap-scrollbar, ledger-hscroll*, old-webkit, view-trackpad-coast):
  195/209. Reds: 9 browser-launch timeouts (mote at load 30-60 with
  ~40 other test runners), old-webkit's ":has() in app.css" from
  c490165b1 on main (#4020, not this change), view-trackpad-coast
  chromium en ("the coast must ask for more than the 250ms": 6),
  view-wheel-unheard webkit 1 subtest, menu-scroll settings de 420px
  click timeout. None of those paths registers anything new in a modern
  engine; a rerun was cut off when mote dropped off the network.
- Agent batch (agent-connect/-disconnect/-leave-magpie/-notice-lang/
  -app-restart/-connect-no-models/-connect-all-hidden/-tweak-fold,
  claude-effort, tier-effort, subagent-effort, fast-ultra,
  hidden-agent-cleared, show-unset-agent, claude-signin, i18n-keys,
  panel-routing, routing-sessions, view-middle-autoscroll): every red
  but two a browser-launch timeout; agent-connect-all-hidden webkit zh
  and ja a click timeout under the same load.
- go test -tags nogui -count=1 ./internal/gui ok (budgets); gofmt -l clean.
Broken by hand: the :where(.holds) rule and the compat.js fallback
removed: the guard red for 25 scrollers per engine, the Safari-15 test
red in both. Fallback alone removed: only the Safari-15 test red. A rule
`.sess-new-list { max-height: 300px; overflow-y: auto; overscroll-behavior:
auto }` added to sessions.css: the guard red naming it, in both engines.
Not run: the full GUI suite; the agent batch's and scroll batch's
launch-timeout reds again (mote went down mid-rerun).
Not tried: a real Safari 15.0 WKWebView (the engine's lack is faked),
WebKitGTK and WebView2 in the app, a trackpad's momentum in the app,
plugin pages in their sandboxed frames (a plugin's own scroller is
the plugin's).
2026-10-28 16:36:28 +08:00
yetoneandJoeyWu-tech 6bec526f7a gui: a key's rename saves once on Enter and never on Escape (#3944)
A provider's key name was edited in an input whose Escape drew the
editor again and whose blur saved. Chromium blurs the input as that
redraw takes it out, so Escape after typing saved the typed name, and
Enter, or Enter twice before the save answered, sent keys/rename twice.
The account rename already guarded this with a once flag. Both now go
through one helper, renameIn: Enter saves a changed name, Escape keeps
it, and whichever comes first ends it, so the blur that follows does
nothing. Taking the two copies into one makes app.js 93 bytes smaller;
no budget is raised.

From Coffemon's patch on #3944 (JoeyWu-tech, joey/fix/3944): the test
key-rename-once.test.cjs and its README entry taken as is. The app.js
change differs: the patch copied the account rename's guard into the
key rename; this shares it instead, to keep core script inside its
budget.

What was run (mote, Playwright 1.62.0, Chromium and WebKit, en and zh):
- origin/main f02d92c7b: key-rename-once 8 of 16 red (Chromium's
  Escape after typing, Enter, Enter twice; WebKit's Enter twice).
- With this change: key-rename-once 16 of 16, account-arrange 2/2,
  account-alias 20/20, api-key-usage 4/4, api-key-theme 6/6,
  key-copy 8/8.
- Broken by hand (the once guard in renameIn taken out):
  key-rename-once 8 of 16 red; account-alias hung and was stopped.
- TestCoreScriptBudget green.

Not reproduced on mote: the issue's replaceChildren page error on an
unchanged Escape and account-arrange's red; both passed on main here.
Not tried: the real desktop app's webview.

Co-authored-by: JoeyWu-tech <joey110551567@gmail.com>
2026-10-28 16:27:00 +08:00
yetoneandJoeyWu-tech 03a8d981ea gui tests: quota-refresh-order runs again, with seven more orders (#3679)
09c0a844 (#3160) gave the quota loader and quotaRefresh three names
quota-refresh-order's VM sandbox didn't have: the top-level quotasKept,
the page's mode, and a refresh button's classList.toggle. Every case
threw "quotasKept is not defined" before testing any order, 9 of 9
red since. The sandbox now has them, and the nine cases are unchanged.

Seven cases are added for orders the loader's comments promise that
hand edits to app.js passed unseen: the tray panel keeping the merged
reading it shows (magpie.panelQuotas), Refresh now behind a read on
its way, reads serialized, a newer card's marker kept after a read
lands, a renamed reply's replaced cards kept out, a background read
taking the asked one, and one card's reply leaving another's marker.
The README lists the file among the VM tests.

Patch from Coffemon (JoeyWu-tech) on #3679, 5ac2b9f7 (five commits,
squashed here into one), reviewed line by line and taken as is; the
README hunk applied to today's README.

What was run (mote, Node 22, no browser needed; at origin/main
f02d92c7b):
- origin/main: quota-refresh-order 0 of 9, each ReferenceError.
- This change: quota-refresh-order, usage-stale-answer and
  providers-fetching-retry 38 of 38.
- Broken by hand through MAGPIE_APP_JS: keepRefreshedQuotas skipped
  (the reply taken as it came): 10 of 16 red (1, 2, 6, 8, 9, 10, 13 to
  16); the panel saving the reply from before the merge: case 10 red,
  the other 15 green.

Not run: the Go checks (no Go file), the browser suite (no browser
test reads this file).

Co-authored-by: JoeyWu-tech <joey110551567@gmail.com>
2026-10-28 16:27:00 +08:00
yetone d74ef5e04c gui: an inner list wheeled to its end keeps the wheel; the page stays put
碳碳双键 (ysm119, Discord): wheeling the Usage page's request list to its
top or bottom carried on into the whole page, and "this happens in many
places". It is the class: every box that scrolls inside a scrolling page.

app.js marks such a box `.holds` while it overflows vertically, on
pointerover and on each wheel (the box under the pointer and its
ancestors up to the .view), and app.css gives `:where(.holds)`
overscroll-behavior-y: contain, which keeps the Mac's bounce on the box.
Not one CSS rule for every overflow:auto box: in Chromium `contain` holds
the wheel even in a box that doesn't overflow, or is overflow:hidden, or
only scrolls sideways, so short lists and the heatmap's and ledger's
sideways scrollers would have stopped the page. The .view itself is never
marked. :where() weighs nothing, so .mchips in a short window
(@media max-height 640px, #833) still passes the wheel on.

The new test, inner-scroll-contain.test.cjs, wheels the Routing page's
requests list past each end (en and zh, 900x560 and 1300x600, under
"By session" / 未提供会话标识), and ten kinds of inner box, and asserts
the page's scrollTop didn't move. A short list, heat-scroll, led-wrap and
snip must still pass the wheel to the page. routing-scroll-end now wheels
over the page's gutter: at its view centre the pointer sat on the
requests' list, which now keeps the wheel at its end (600 of 1066).

Run (mote, Playwright 1.62, Chromium and WebKit):
- inner-scroll-contain 40/40.
- 17 files: inner-scroll-contain, click-scroll, routing-scroll-end,
  routing-sessions, view-wheel-after-click/-after-redraw/-unheard,
  heatmap-scrollbar, ledger-hscroll, ledger-hscroll-foot,
  context-scroll-end, menu-scroll, provider-levels-scroll, panel-usage,
  panel-routing, qoder-cn-tile, agent-disconnect: 268/287. Reds were
  routing-scroll-end (this change, fixed above) and panel-usage webkit zh
  (#3311, commented). Rerun of routing-scroll-end, panel-usage and
  inner-scroll-contain: 66/66.
- go test -tags nogui ./internal/gui ok (TestCoreScriptBudget passes at the rebased head:
  core under 1,526,556, app.js under 1,310,460; no budget raised).
Broken by hand: the old app.js and app.css: the requests list and every
held box red in both engines (mchips aside, it had contain already).
Only the CSS rule removed: red, "the page didn't move" x8 plus each held
box x2. Only the overflow check removed: a short rt-reqs red (Chromium),
led-wrap and snip red in both engines.
Not run: full GUI suite (mote was busy with another session's suite).
Not tried: WebKitGTK on Linux, WebView2 on Windows, a real Mac's
trackpad rubber band and momentum in the app, older macOS WKWebView,
touch; zh-TW/ja/de (no strings changed).
2026-10-28 14:54:09 +08:00
Henry-916 824100f30f gui: keep Windows modal backdrops responsive without blur
Disable full-window modal backdrop filtering in Windows desktop windows
and tray panels, retaining the dimming veil. Browser pages and other
platforms keep their existing blur through the existing win/web markers.
Document the platform behavior in the GUI shell reference.

On an affected 0.1.1805 installation with WebView2 155.0.4283.62 and Intel
UHD D3D11, disabling the filter made provider tests visibly responsive.
The reporter confirmed the improvement. Scripted scrolling measured
roughly 67 to 165 rAF callbacks/s, not presented FPS.

Verification: modal-backdrop.test.cjs fails on the original CSS in both
Windows desktop Chromium cases (blur instead of none), with the other
10 cases passing. After the fix, 45 targeted tests pass across
Chromium and WebKit: modal-backdrop, dialog-backdrop-drag,
segment-press-dialog, gui-zh-tw, gui-ja and gui-de. node --check and
git diff --check pass. The full GUI suite, Go vet/build/test matrix and
native macOS/Linux tests were not run.
2026-10-28 14:24:40 +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 833f51adcf gui: a browser tab has the font rows too, with its own choice
Norcleeh on Discord: magpie opened in a browser had no font setting in
Settings > General, while the app does. The rows were hidden on purpose:
/api/fonts answered 404 to a browser page and boot sent it no choice,
since the list is the fonts of the computer magpie runs on and the tab
can be on another one.

Now a browser tab (magpie web, or the app's page in a browser) has both
rows wherever magpie can read its fonts (boot's fonts; a nogui build
can't, and keeps them hidden). Its list is /api/fonts less the families
this browser doesn't draw (fonts.js here(): text in the family measures
apart from monospace's or serif's on a canvas), so another computer's
fonts and Safari's user-installed ones aren't offered. The choice is the
browser's own, in localStorage (magpie.fonts), applied by fonts.js
before the first paint; it neither changes nor takes the app's
settings.UIFont/CodeFont, and a settings save from a browser still
keeps the app's.

Run on mote at this tree (on b90e81da1), also GOOS=linux (nogui) and
GOOS=windows go vet ./internal/gui/..., go build, gofmt -l:
- fonts.test.cjs, font-cascade.test.cjs, win-fonts.test.cjs, i18n-keys
  and the 42 drag/arrange GUI files, Chromium and WebKit, en and zh (and
  ja/de where a file has them). The reds are 32 subtests in 4 files
  that fail the same on origin/main b90e81da1 run alone (and one from
  a stray path in the run command): i18n-keys "a
  plugin's words are its own" (#3897), routing-rule-drag webkit de
  (#3789), segs-press-redraw webkit (#3922), usage-agents-hide (#3414).
- go test -tags nogui ./internal/gui (TestCoreScriptBudget and
  TestFontSettingsAPIAndBoot included) ok; go test ./internal/gui -run
  Font (cgo, CoreText) ok.
- Real use: magpie built on mote, `magpie web` in a sandbox HOME, real
  /api/fonts (204 families). Chromium offered 204, WebKit 179; Georgia
  picked in each, the body drew it and kept it across a reload, and no
  settings.json was written.
Broken by hand: fontsOn = !web (rows hidden as before): the new test
red in all four engine/language cases; here() returning the list
unfiltered: red with "a family this browser doesn't draw isn't
offered".
Not tried: a browser on a different computer from magpie (the canvas
filter is what covers it, checked with a family the test machine
lacks), Firefox, the Windows and Linux apps' pages in a browser.
Budget: not raised; the previous commit's 1,097 bytes cover it.
2026-10-28 08:01:46 +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 aa766289bf gui: a routing group switched on no longer folds away the one provider's models
shiqi_40904 on Discord (#general, 10-27): with Codex as the provider,
switching a routing group of their own on made models go missing from an
agent's model list, and switching it off brought them back.

The cause is in the agent model list dialog. A section with more than 8
models starts folded when the list has more than one section, so that
several providers can be told apart. The Routing groups section counted as
one. With only Codex serving there is one section and Codex's 10 models
show. Switch a group on and there are two sections, so Codex's 10 start
folded under a "Codex 10 / 10" header with no rows. Nothing was missing on
the server side: /api/state's options and counts for every agent only
gained the group (27 -> 28 in the sandbox).

Now only provider sections count toward folding. With two or more
providers the long ones still start folded, as before
(agent-models.test.cjs is unchanged and passes).

Run (worktree at origin/main 5e3dd1d52 + this commit):
- Sandbox: HOME under scratchpad, magpie built from this tree with -tags
  dev, Codex upstream faked on 127.0.0.1:3713, app on 3711/3712, found
  groups off, a second provider off, Codex connected. Before: group mygpt
  off -> Codex 10 rows; on -> Routing groups 1 row, Codex 0 rows. After:
  on -> Routing groups 1 row (MyGPT), Codex 10 rows; off -> Codex 10 rows.
  With the second provider back on, both providers still start folded.
- New agent-models-group-on.test.cjs, chromium + webkit, en + zh, group
  off and on: 8/8 pass. Broken by hand (old rule put back): the 4
  "group on" cases fail on "every Codex model is on the screen".
- GUI files that reach the dialog (agent-connect-all-hidden,
  agent-models*, agent-model-groups, codex-model-order,
  desktop-model-menu, cursor-local-models, grip-inset,
  popover-mac-chrome, zcode-models) + i18n-keys: 286/286 pass.
- go test -timeout 45m ./internal/gui/: all ok except
  TestMainWindowCorners. Both of its SDK subtests were killed at the 40s
  deadline at load ~175 (#1936, #2645). Run alone afterwards: ok in 43.7s.
  No Go files changed, so gofmt and vet have nothing new to check.

Not tried: the whole GUI suite (~900 files, at load 150-175; the change
reads no new API and adds no strings). Codex's own /model inside the
Codex app, which this list doesn't decide. Nor the reporter's separate
note that GPT 6.1 sol was missing in Codex itself.

Reported-by: shiqi_40904 (Discord)
2026-10-27 11:00:23 +08:00
yetone 78a0dbdd29 gui: a download the network broke off says so, not the signed address
AIMetaPhD on X: Settings › About read "0.1.1618 下载失败 · https://github.com/
…/magpie-windows-amd64.exe: Get \"https://release-assets.githubusercontent.com/
…?sig=…&jwt=…\": EOF". The text was hundreds of characters of signature and
token, and it said nothing about what to do.

/api/update now carries network: true when update.Network(err) is true
(the previous commit's NetError, after its own tries). The Version row
then says "{v}'s download broke off, a network problem. Click Check to
try again, or download it from the release page", translated into zh,
zh-TW, ja and de. The raw error stays in the tooltip. The release page
button the row already had stays. A mirror's failure keeps its own text
(#893). begin() clears the flag along with the mirror.

Run: GUI tests (Playwright 1.62.0, Chromium and WebKit):
update-*.test.cjs (16 files, the new update-network among them) and
i18n-keys, 266 of 266 pass. go test ./internal/gui (ok, 224s); go
test ./internal/update ./internal/cli (ok, previous commit); gofmt -l
clean; go vet; GOOS=windows go vet; GOOS=linux go vet -tags nogui
(./internal/gui ./internal/update).

After rebasing both commits onto origin/main b5d17b26e (its i18n.js
changed), these were run again at this tree: go test ./internal/update
(ok), go test ./internal/gui -run 'Budget|I18n|Update|Asset' (ok), and
i18n-keys, update-network and update-mirror in both engines (36 of 36).

Broken by hand: with the row's new line turned off, update-network
is red, 11 of 11 in Chromium. TestUpdateMirrorSetting now also checks
that a mirror's 404 isn't flagged as a network failure.

Not tried: the real app on Windows, or a real dropped connection, and
the gui-*.test.cjs language suites beyond i18n-keys.
2026-10-27 01:37:04 +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 894ec96036 plugins: "More in Plugins" opens Discover, not the tab visited last (outloudvi on Discord)
On Providers, 「插件里还有更多」 / "More in Plugins" opened whichever
Plugins tab was visited last (Built-in, Installed). pluginQuery("")
returned early when the query was already empty, before it set the
tab to Discover. The early return is gone, so an empty query also
switches to Discover; a non-empty one already did.

plugins-more-discover.test.cjs visits Built-in, then Installed, in en
and zh, goes back to Providers and clicks the add sheet's More in
Plugins tile, expecting Discover with its cards and no Built-in list;
then the "look for a plugin" link with a search, expecting Discover
with that search.

Run:
- plugins-more-discover.test.cjs, chromium and webkit: 3 of 3 green.
- 61 GUI files the change can reach (plugin-*, plugins-*, builtins,
  deprecat*, add-sheet*, provider-search*, i18n-keys, nav-sub-unroll,
  mobile-web, market-have, sidebar-tab-top), both engines: 412 pass,
  1 fail each: builtins.test.cjs's sidebar list lacks the masking
  tab, red the same with the old plugins.js (#3498).
- go test ./internal/gui/ -count=1 (budgets included): ok but
  TestMainWindowCorners/macOS_15_SDK killed at load ~200 (#1936,
  #2645); alone it passes.
- At the rebased head (b28e5ffd8): the new test and i18n-keys green in
  both engines, go test -run Budget ok.
- No bytes added: core and app script budgets untouched.

Broken by hand: with the early return put back, the new test is red
in both engines (expected Discover, got Built-in; expected 发现, got
内置).

Not tried: the tray panel's link, which opens the main window through
window/main?view=plugins and still shows the last tab (#3579, a
sibling); the full Go suite (no suite-lock.sh on this machine).
2026-10-25 16:00:21 +08:00
yetone c9c28aa586 gui: a gateway key list that can't be read keeps saying so in its card, and one read before stays
Found beside HarriesChen's report: when /api/caller-keys failed,
loadGatewayKeys put the error straight into #gatewayKeys, and the page's
next redraw (renderGatewayKeys from renderGatewayView, the providers'
poll) wiped it, since it returns early while no list was read. A failed
re-read also replaced a list already shown with the error.

gatewayKeysErr now holds why a never-read list failed, and
renderGatewayKeys says it in the list's card (styled like the empty line
by the previous commit). A list read before stays, and the error goes to
the status line. A read that works clears it.

Run:
- gateway-keys-empty.test.cjs: the unreadable case (past a
  renderGatewayView redraw) and the read-before case, both engines: green;
  with keys.js from main both red (".none" never visible; the 3 keys gone).
  All 22+2 of the file green with the change.
- The whole GUI suite was still running at push time (see the previous
  commit); not in this record.

Not tried: a real failing gateway (only the fixture's 500).
2026-10-25 13:04:41 +08:00
yetone 5046e4fc84 gui: no gateway key yet is said muted and inset in its card, as Recent calls says none (HarriesChen on Discord)
HarriesChen (#feedback, 10-25), magpie web on an iPhone: under Gateway
keys, "No gateway keys yet" was drawn in the body's own text (14px, the
foreground colour) flush against the edges of its white card. The
`.none` line inside `#gatewayKeys > .accts` had no rule: `.accts` gives
its rows padding through `.acc`, and the empty line isn't one.

`#gatewayKeys .none` now takes the look of the same page's Recent calls
empty line: muted colour, 11.5px, line-height 1.45, inset 13px 14px in
the card. The page's other empty lines (Recent calls, Models' "No models
match") already had rules and are unchanged.

Run:
- Reproduced at 390x844, magpie web (bootPrefs web), Chromium and WebKit,
  light and dark: before, colour rgb(28,28,33) / rgb(237,237,241), 14px,
  padding 0; after, rgb(133,133,141) / rgb(139,139,148), 11.5px, 13px 14px,
  equal to #activity .none in each. Screenshots looked at.
- New gateway-keys-empty.test.cjs (390px, web, both engines, en, zh,
  zh-TW, ja, de, light and dark): 20/20 green; with app.css from main
  20/20 red (colour, size, inset). fixtures/caller-keys.cjs takes
  options.keys.
- go test -tags nogui ./internal/gui -run 'Budget|Asset|I18n|CSS': ok
  (no budget raised).
- The whole GUI suite (node --test --test-concurrency=2 tests/*.test.cjs,
  both engines) was started at 687c3645f's tree and was still running
  when this was pushed (owner: ship at once). Its result is not in this
  record.

Not tried: a real iPhone Safari; the Go suite (only CSS and GUI tests
change).
2026-10-25 13:04:41 +08:00
yetone b437e4adb4 settings: a proxy's username and password have fields of their own for every proxy, HTTP too (微雨南山 on Discord)
Settings > Proxy > Custom now shows Username and Password fields beside the
address for every proxy kind. Before, only a SOCKS5 address had them (the
password is masked). An HTTP or HTTPS proxy's login had to go inside the URL,
so a password holding @ : / % # or a space broke it. Each field is
percent-encoded (encodeURIComponent) when the address is saved.

The setting's format is unchanged: still one URL with the login as its
userinfo. A proxy saved before with user:pass@ loads into the fields. It is
split the way Go's url.Parse splits it (last @, then first :), so
"https://al%20ice:se@cr%23et@proxy.example:8443" shows "al ice" and
"se@cr#et". It is not split through WHATWG URL, which would add a "/" or drop
a default port. A part left as it was loaded keeps its own escapes, so
non-UTF-8 bytes survive. A login pasted into the address moves into the
fields. Describe, Redact and the status line already hid the userinfo
(#1886), and a new test checks that again.

Credit: 微雨南山 on Discord (#feedback), who asked for macOS-style
address / username / password fields after a special character in the
password broke the URL.

Tests:
- internal/netproxy/login_test.go: the login "me@corp:x" / "p@ss:w/rd% #1 x",
  saved as the page encodes it, reads back as typed. It signs in to a fake HTTP
  proxy (Basic Proxy-Authorization), and to a fake SOCKS5 proxy through both Go's
  transport and the plugin bridge's socksHandshake. It also reaches a CLI's
  HTTPS_PROXY. One character off is refused (407 / SOCKS fails), and Describe and
  Redact show no part of it. TestBunProxyLoginWithReservedCharacters signs in with
  the real bun 1.4.2's fetch({proxy}). These pass on the old Go code too: the Go
  side needed no change.
- internal/gui/tests/settings-proxy-auth.test.cjs, Chromium and WebKit, en zh
  zh-TW ja de, at 560 and 375px: an HTTP proxy has the fields, the login
  round-trips encoded and comes back decoded, the password is type=password, and
  the status hides it. A login saved in the address loads into the fields, and
  Enter on it saves nothing. On the old app.js both tests fail in every language
  checked ("an HTTP proxy has a username field / false !== true"; the address
  still showed 'https://al%20ice:se@cr%23et@proxy.example:8443').

Run:
- gofmt -l: empty.
- go vet (darwin), GOOS=linux go vet -tags nogui, GOOS=windows go vet: clean.
- Full Go suite at c7ad43426 through the suite lock (-tags nogui -timeout 45m):
  68 ok, one red, internal/gui TestCoreScriptBudget. The first app.js was
  1338904 bytes over 1338084. The helpers and comments were tightened (not the
  budget raised): app.js is 172 bytes under its parent. Then internal/gui,
  internal/netproxy and internal/settings: ok at the final tree. After the
  rebase onto c551a2299, app.js is 1,338,757 against the parent's 1,338,929.
  TestCoreScriptBudget, internal/netproxy and the two proxy GUI files (30/30)
  pass again.
- settings-proxy-auth + settings-proxy-remember: 30/30, and 30/30 three more
  times at load 60-150.
- Whole GUI suite: stopped after ~2h, at 11,507 passes, to free the suite lock.
  It ran beside two other sessions' GUI suites (load ~300). It showed 43
  top-level reds, whose errors were not printed because the run was cut short.
  Three were in the proxy files, and those passed alone afterwards. All are
  filed in #3393, not compared against origin/main.

Not tried:
- a real authenticated proxy, and the real app;
- Windows and Linux runs;
- how Codex's reqwest or other agent CLIs decode the percent-encoded *_PROXY
  login.
The plugin host's host.js proxyRefuses (auth only when there is a username,
and a decodeURIComponent that can throw), and the per-provider, account, key
and sign-in proxy fields that still take the login inside one URL, are filed
as #3382.
2026-10-24 00:02:02 +08:00
yetone ecd9835005 agent: Claude Code's subagent effort writes nothing without a subagent model (KorenKrita)
KorenKrita on Discord (cause confirmed by them): with Claude Code's
subagent model unset ("Claude Code picks") and a subagent effort set,
claude.go wrote spell(tierWith(main model, effort)) into
env.CLAUDE_CODE_SUBAGENT_MODEL. That pinned every subagent to the main
model, so Claude Code's own pick (the Agent call's model, the subagent's
frontmatter) never ran.

Agent wiring (internal/agent/claude.go):
- With no subagent model, magpie writes no effort, and
  CLAUDE_CODE_SUBAGENT_MODEL stays unset.
- The saved effort is kept, not deleted (the user set it). It lives in
  the stash under claude.subagent_effort, and the subagent effort's Get
  reads "" while there is no model. A model picked later takes it
  ("v/glm:high").
- A value an older magpie wrote that way (the main model at an effort,
  not own, while routed: subagentFollowing) is moved into the stash and
  taken out of the env by writeTiers and by Sync on start.
- subagentOwn no longer counts that value as the user's own model.
- Doc: docs/subsystems/agent-wiring.md, the Claude Code "subagents" entry.

GUI (window, opened Claude Code row):
- The subagent effort moves from its square under the session defaults
  to the right of the Subagents row. It uses the tier rows' markup and
  code (effortBtn in connectPanel, ag-eff), so it lines up with
  Opus/Sonnet/Haiku's effort.
- While the subagent model is unset it shows Default, is disabled, and
  its title says "Set a subagent model first". The new string is in zh,
  zh-TW, ja and de.
- The old square is removed from the opened row. No other layout changes.
- The tray panel's own square is left alone: #3308.

Tests:
- New internal/agent/claude_subagent_effort_test.go
  (TestClaudeSubagentEffortNeedsAModel). On the old code it is red:
    an effort with no subagent model wrote
    CLAUDE_CODE_SUBAGENT_MODEL="v/glm:high"
  With the Sync branch broken by hand it is red at "Sync left an older
  magpie's CLAUDE_CODE_SUBAGENT_MODEL="v/flash:high"". It also checks
  that a set model plus effort still writes "v/glm:low".
- claude_tiereffort_test.go now expects no env for an effort with no
  model.
- New internal/gui/tests/claude-subagent-effort-row.test.cjs (16 cases):
  chromium/webkit x en/zh x 1100/560px x with/without a subagent model.
  It checks:
  - the control sits in the Subagents row at the tier efforts' x and
    height;
  - with no model it is disabled at Default and opens no slider;
  - with a model it posts subagent_effort, with no scroll;
  - the old square is gone.
  It is red against the old app.js ("the old square is still there").
- tier-effort.test.cjs is updated for the moved control.

Run at this tree (parent f985d6bdb):
- go test -count=1 ./internal/gui/ ./internal/agent/ ./internal/provider/:
  ok.
- GUI: claude-subagent-effort-row, tier-effort, i18n-keys,
  subagent-effort, claude-subagents-pick, desktop-subagent-model,
  agent-prefs, agent-tweak-fold, claude-signin and agent-field-names:
  147/147.
- gofmt clean. go vet darwin, linux -tags nogui and windows: ok.

Run at the same change before its last rebase:
- Full Go suite (`go test -count=1 -timeout 45m ./...`, sandbox HOME,
  through the suite lock) at 11b9d671c (on 45593cc1d): every package ok
  but internal/gui's TestCoreScriptBudget. app.js was 1,337,535 bytes,
  over its 1,337,000 budget, after the rebase brought in upstream growth.
  This commit trims its own additions to 1,336,991 (one shared effortBtn,
  shorter comments, a shorter new string) and raises no budget.
  TestCoreScriptBudget now passes.
- Full Go suite at 41737d214 (on 802fb6e61): all 69 packages ok.
- Whole GUI suite at 41737d214 (11,741 tests, 5.8h at load ~250): 48 red,
  none from this change.
  - Red the same on origin/main 45593cc1d, all filed: quota-count-wrap
    and quota-name-translated (#2228), quota-reads (#2150), s3-sync
    (#2448), usage-agents-hide (#2276), usage-checkin (#2549, #3091),
    usage-fold (#2163), usage-ledger (#3104, #3001).
  - Red under load only and green alone: agent-notice-lang (#2960),
    agent-stale-copies (#1949), modal-morph (#3179), plugin-card-update
    (#3079), plugin-github (#3218), and agent-field-names and
    api-key-theme (filed as #3307).
  - Also seen red once under load: codex-subagent-model's fixed 300ms
    wait (#3277).

Not tried:
- a real Claude Code run reading the written settings;
- the Windows box;
- the whole GUI suite again after the string was shortened (only the
  files above were run);
- the tray panel (#3308).
2026-10-23 03:44:55 +08:00
yetone c627652e9a settings: lightweight mode is off for a user who never chose
The owner, 10-21: "要默认关闭「轻量模式」,不然太卡了". With it on, the window
is made again and its page loaded again on every opening, which is slow.
28bec1507 had made it on for a user who never chose, against a hidden
webview growing ~20 MB a minute on Windows (#2515); that user now gets
the kept window again. A user who turned it on or off keeps their choice:
only an unset value changes meaning (LightweightOn, Settings › General's
row).

Run on origin/main b855cfee9 + this commit, macOS, playwright 1.62.0:
- go test ./internal/settings/ -run Lightweight ok; red with the old
  LightweightOn.
- lightweight.test.cjs, segs-glide, segs-press-redraw, settings-general:
  89/90 in chromium and webkit, every language; the red was
  segs-press-redraw chromium en 440px while a full GUI suite ran beside
  it, and the file passes 42/42 alone. lightweight.test.cjs goes 4 of 8
  red with app.js's old `!== false`.
- gofmt -l clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet
  of internal/settings and internal/gui.

Shipped at the owner's word (10-21, "赶紧上线") before the full GUI suite
finished: it was stopped at ~2,040 passing tests (about a quarter of the
files, on b855cfee9 + the dialog change), with two reds,
desktop-longest chromium zh 640px and gateway-key-groups chromium en,
both under load at ~100. On origin/main c79400556 + both commits (rebased after onto
e68a0b1db, which adds only internal/sessions):
desktop-longest, gateway-key-groups, modal-morph, lightweight,
segs-glide, segs-press-redraw and settings-general 108/108 in chromium
and webkit; go test ./internal/settings/ ok; go test ./internal/gui/
-run 'Budget|Lightweight' ok; gofmt -l clean; GOOS=linux go vet -tags
nogui and GOOS=windows go vet of internal/settings and internal/gui.
Not run: the rest of the GUI suite.
2026-10-21 18:45:23 +08:00
yetone 28bec1507c settings: lightweight mode is on for a user who never chose it, and off for one who turned it off
The owner: 改成默认开,只对没设过的用户. A webview kept for good holds what
its page drew while hidden, which grew ~20 MB a minute on Windows under
steady requests (#2515); lightweight mode lets it go.

- settings.Lightweight is a *bool: nil (never chosen) is on, false is
  off, true is on. LightweightOn() says which; gui/lightweight.go reads
  it. KeepOwn still keeps this computer's value on a sync or a restore.
- app.js shows On unless lightweight is false, and the prefs save sends
  s.lightweight as it is: unchosen stays out of the JSON, so saving
  another setting doesn't choose it.

Caveat: until now Off was a bool with omitempty, so it was never stored.
A user who chose Off before this can't be told from one who never chose,
and gets On. Only choices made from this release on are kept.

Tests:
- settings TestLightweightKeptAndOwn: on when unset, Off saved reads back
  off, another save keeps it off, KeepOwn keeps this computer's Off over
  the other's On, and an empty one stays unset. Broken by hand
  (`!= nil && *`) it fails "off for a user who never chose".
- lightweight.test.cjs: On shown for a user who never chose; another
  setting's save posts no lightweight; Off posts false and shows Off;
  another save keeps false; On posts true; nothing scrolls. Its viewport
  is 1200 tall: rows added above had put Off under the window's foot
  (y≈1008 of 1000), where the mouse click did nothing.
- segs-glide and segs-press-redraw start from a user who turned it off,
  so On is still a pick away; README's lightweight line says the new
  default.

Run at this commit's parent (the #2683 test fix on origin/main
f73378365), chromium 1234 and webkit 2336, playwright 1.62.0:
- lightweight, segs-glide, segs-press-redraw, settings-general
  (--test-concurrency=1): 90 of 90. These are every GUI file that reads
  lightweight (grep); no others reach it.
- go test -timeout 45m ./internal/settings ./internal/gui: ok (gui 554s).
- gofmt -l internal/: nothing. GOOS=linux and GOOS=windows go vet -tags
  nogui ./...: clean.

Not tried: the real app's webview being let go after this change on
Windows or Linux; the release path is the same as with On chosen before.
2026-10-20 20:23:50 +08:00
yetone 7916045591 library: RTK's tag for Grok Build and Grok App gives their own reason and rtk-ai/rtk#2136, not DeepSeek Harness's (新v学员 on Discord)
Every agent RTK has no hook for got dsh's tooltip on the RTK tab: "{agent}'s
hooks can only allow or deny a command, not change it" with
rtk-ai/rtk#3847 ("FR: Support DSH"). For Grok Build that is wrong twice:
the issue is dsh's, and Grok's PreToolUse hooks can rewrite a command
(updatedInput, shown on rtk-ai/rtk#1890). What holds is that rtk init has
no Grok agent (src/hooks/init in rtk v1.0.1 has none), and
rtk-ai/rtk#2136 is the open request for Grok Build (#4513 was closed as
its duplicate). Each link was checked with gh issue view; the others in
rtk.go (#3847, #3934, #4311, #3898, #4187, #3404) are right.

rtkNoHookWhy in plugins/library/client.js gives each agent its own reason:
dsh keeps its text and #3847, Grok Build and Grok App cite #2136 (Grok App
runs Grok Build), and an agent with no entry gets a reason with no link.
New strings in zh, zh-TW, ja and de. rtk.go's grok and grok-app reasons,
which the CLI shows, cite #2136 too.

TestRTKNoHookIssuesAreEachAgents fails when an rtkNoHook agent has no page
reason (or the reverse), when the page and rtk.go cite different issues,
when two agents cite the same issues without a reason in sharedRTKIssues,
or when the fallback carries a link. library-rtk-nohook.test.cjs checks
Grok Build's tag says #2136 and never #3847, DeepSeek or "hook".

Run in a worktree rebased on origin/main 16327872c, sandbox HOME, caches
pinned:
- Broken by hand: with the old client.js the new test fails "client.js has
  no rtkNoHookWhy: the no-hook tag isn't per agent"; with Grok's page link
  set to #3847 it fails "dsh and grok both cite [rtk-ai/rtk#3847]: one's
  reason was copied onto the other". Restored, it passes.
- gofmt -l on the changed Go files: empty. go vet ./..., GOOS=linux go vet
  -tags nogui ./..., GOOS=windows go vet ./...: ok. go build, GOOS=linux
  go build -tags nogui, GOOS=windows go build: ok (before the rebase).
- GUI: i18n-keys plus all 39 library-*.test.cjs, Chromium 351/351 and
  WebKit 351/351.
- set -o pipefail; go test -timeout 45m ./... at load ~500-650: 60
  packages ok; 4 red, none in the code changed here, each already filed:
  internal/agent timed out at 45m (#2544), internal/gateway timed out at
  45m (#2870), internal/gui TestSetAnswersWhileDevinAndProvidersHang
  10.4s set under load (#1375), internal/library
  TestCheckStdio/timeout_ends_the_tree (#2765). go test ./internal/library
  -run 'RTK|TestCheckStdio' then passed (136.9s).
- Not tried: the real app with a real Grok Build install; the change is
  tooltip text and links only.
2026-10-20 04:13:35 +08:00
yetoneandTsukikage7 9b04c4e20f plugin: async gateway request hooks, run in Bun before routing and after the reply (#2118)
A package's magpie.hooks entry (or a *.hooks.{js,mjs,ts,mts} file) exports
`async onRequest(body, ctx)` and an optional `onResponse(reply, ctx)`. They
run in the Bun plugin host, so a hook can await I/O, for example a context
service like PowerContext, which the sync moejs middleware can't. The
gateway still makes one model request per client request. A hook adds
context to the body; it doesn't register tools or run a loop, so magpie
doesn't become an agent runtime.

Ported from Tsukikage7/magpie#1. Changes from the fork:
- The entry name is magpie.hooks / *.hooks.*. The fork's magpie.gateway /
  *.gateway.mjs is already the middleware's alias, so a hook importing
  node:fs was also loaded as moejs middleware and failed there.
  TestGatewayHookNamesApartFromMiddleware fails if the two sets overlap.
- onRequest is rolled back, and counts as failed with no onResponse, when
  it throws, times out, returns non-JSON, or changes tools, tool_choice,
  function_call, functions, toolConfig, model or stream.
- onResponse gets the client-facing reply, merged through the gateway's own
  stream decoder, collector and renderer (no second merger).
- Codex's native passthrough (/backend-api/codex) runs the hooks too,
  without the sync middleware.
- The run ends with the request handler, not the client connection. Codex
  hangs up on response.completed, and the reply it got is still captured
  as a success. TestGatewayHookSeesReplyAfterClientHangsUp is red on the
  old `r.Context().Err()` check and green with -count=3.
- ctx.origin is host-derived (local / gateway-key / remote). Headers, keys
  and peer addresses never reach the hook.
- Plugins page: a hook package shows a "Request hook" chip, a diagnostics
  line (outcome code, calls, avg ms, bytes, failures; no content), and
  Options. Strings are in en, zh, zh-TW, ja and de.

Docs: docs/subsystems/gateway-request-hooks.md (new), provider-plugins.md,
gateway-middleware.md, and site docs plugins.html in en, zh and ja.

Real use, sandbox HOME on 127.0.0.1:3486 with the owner's real Codex Pro
sign-in. The probe hook adds a codename note and logs both callbacks:
- /v1/responses, /v1/messages, Gemini generateContent: stream and
  non-stream. onRequest's note reached the model (the answer had the
  codename), and onResponse got success=true and the whole reply.
- /v1/chat/completions: with the probe also changing `model`, the change
  was rolled back (the reply came from the asked model) and no onResponse
  ran. Without that change, earlier: stream and non-stream success.
- The real Codex CLI 0.162.1 `codex exec` through openai_base_url ->
  /backend-api/codex: the hook saw origin=local, agent=codex and the
  query; the answer had the codename; onResponse success=true (before the
  hang-up fix it never ran: the context was already cancelled).
- `magpie plugin list` shows only "async gateway hook onRequest" for the
  hook package, no failed middleware.

Tests (base origin/main 63be47717, macbook at load avg 220-340 from other
sessions' suites):
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean. go build and GOOS=linux -tags nogui
  build: ok.
- go test ./... -timeout 45m: every package ok except:
  - agent, gateway and library timed out at 45m under the load;
  - gui's TestSetAnswersWhileDevinAndProvidersHang (#1375, also red on a
    clean 63be47717 run alone; commented there);
  - library's TestSkillRelinkKeepsUnreadableCopy, which passes -count=2 alone.
  Rerun at -timeout 150m: agent ok (4524s), library ok (2581s). gateway was
  ok except TestVisionWaitIsntTheDescribersTime's 300ms limit (#2444,
  commented), which passes -count=5 alone on this tree and on 63be47717.
- internal/plugin and internal/gateway hook tests: ok.
- GUI (chromium+webkit; en, zh, zh-TW, ja, de): plugin-gateway 12/12 twice.
  It failed earlier at load ~340, chromium only, on page.goto's 5s (#2542).
  All 43 plugin-*.test.cjs files and mobile-web are green except:
  - plugin-move: red on a clean 63be47717 too (#2399, commented);
  - plugin-moved-signin: one 5s waitFor under load, then 6/6 twice.

Rebased onto ea3dee96a (21 commits; main touched host.go, host.js, i18n.js and
the plugin docs; clean rebase), then rerun at the rebased head:
- gofmt, vet (darwin, linux nogui, windows) and build: clean.
- go test: plugin ok, cli ok, gateway -run 'Hook|Middleware|Codex|Plugin' ok.
  gui ok except TestMainWindowCorners, which was killed under load (#1936)
  and passes alone.
- GUI: plugin-gateway 12/12, plugin-middleware 24/24, plugin-tools 22/22,
  plugin-agent 22/22.
- Real account with the rebased binary: every protocol and the real Codex
  CLI gave the same results as above (codename answered, success=true,
  chat's model change rolled back).

Co-authored-by: Tsukikage7 <65526564+Tsukikage7@users.noreply.github.com>
2026-10-16 20:48:51 +08:00