Commit Graph
220 Commits
Author SHA1 Message Date
yetone fdd38154b8 docs: the Usage, Video generation and sign-in links to their settings
gui-shell.md, gateway-routing.md and providers-accounts.md name the
links 22c665d6f, cedacf1ae and 3b550a99c added: the Usage page's
Allowances head to Settings › Allowances, Video generation's how-to
to the Providers page, and a sign-in kept to its link to Privacy's
Sign-in pages row. Library's limit tag (8607a7a02) has no passage in
library.md to change.

Docs only; nothing run.
2026-11-10 00:02:22 +08:00
yetone be9dbce02c settings search: built-ins are found too, off or on, and Open goes to their row
A built-in's switch and the settings it keeps in Plugins › Built-in or on
its own page (Gateway's Recent calls at a time) were found by nothing in
Settings' search, and one switched off took its Settings tab and rows
with it, so searching "Observability" with it off said no setting
matched (the scattered settings audit after netube99 on X). The search
now lists, after Settings' own rows and under "Plugins › Built-in", each
built-in whose name, line or schema setting has the words, in the
language shown or English, one off saying Off. Open goes to Plugins ›
Built-in and lights that row, again when the list is drawn a second time
as the plugins are read.

The list is drawn by a lazy setfeats.js the first time a search runs,
and only when what it finds changes, as Settings' observer runs the
search again on each change under the view.

Run (mote, at f98e954ce's tree plus this): settings-search,
old-webkit, builtin-places, provider-prefs, i18n-keys: 170 pass, 0 fail,
Chromium and WebKit, every language; TestCoreScriptBudget ok. Broken by
hand: without the row's light, and with the match always false, the new
case went red in Chromium (7 pass, 2 fail each).
2026-11-09 22:11:00 +08:00
yetone 7cabf0da98 sessions: one place says which ids a ZCode request names, and drafts are one group (#5754)
On top of Flandern1211's cherry-picked fix (the commit before this one).
GatewayKeys gave the bare id of a ZCode session (sess_<id> in ZCode's
database, <id> in the gateway's record), but NativeIDs kept its own copy
of the keys: the management page still counted every ZCode session sent
through the gateway as a gateway-only session, its delete listed them,
and its search read them a second time. requestIDs is now the one place
that says which ids a request names a session by; GatewayKeys (Sessions
list, its spend, the stats' native set, viaOf, the manage search) and
NativeIDs (the manage page's count and delete) both read it.

ZCode runs a session started without a project in a folder it makes for
that session alone: <workspaceDirectory>/draft-<id> or <ms>-<uuid>, with
workspaceDirectory = ~/.zcode/workspace (read from ZCode 3.17.2's
out/host/index.js, downloaded from cdn-zcode.z.ai; never the live
~/.zcode). The reporter's group is renamed from "Scratch sessions" to
"Draft sessions" (草稿会话 / 草稿會話 / 下書きセッション /
Entwurfssitzungen), after ZCode's own word for them, with a GUI test of
its own. Comments no longer quote "Seen through the gateway", which
i18n-keys' plugin-words guard read as the core saying the word.

Run (mote, at this tree, rebased on 0eac4e6aa):
- gofmt -l: clean. go vet of sessions/gui/usage for darwin, linux
  (-tags nogui), windows; GOOS=linux -tags nogui and GOOS=windows
  go build: ok.
- go test -run 'ZCode|Gateway|Native|Manage|Merge|External'
  ./internal/sessions ./internal/usage ./internal/gui: ok.
- GUI, Chromium and WebKit: sessions-zcode-drafts (new, 5 languages x 2
  widths), sessions-folder-list, i18n-en-no-cjk: ok. i18n-keys' "a
  plugin's words are its own" is red at origin/main for three words not
  touched here, filed: #5332 (View routing), #5426 (No session ID),
  #5482 (Use the library's). The reporter's comments quoted "Seen
  through the gateway" and made a fourth; reworded.

Broken by hand:
- TestZCodeGatewayRowIsTheSessionItself on origin/main's raft.go,
  manage.go and external.go: red (keys lack zcode|main, fork_of_main,
  abc; NativeIDs lack them; 29 rows for 26 sessions).
- sessions-zcode-drafts on origin/main's Sessions client.js/i18n.js:
  red in every language and width.

Not tried:
- The full Go suite and the whole Sessions GUI set: queued behind other
  sessions on mote's suite lock; run after the push, reds filed.
- A real ZCode database: none on this machine; the reporter's own run
  over 1,105 sessions is in the issue.
- Windows/WSL GUI, and a ZCode data folder the user moved elsewhere
  (only ~/.zcode/workspace is matched).

Reported-by: flandern1211_58540 (Discord)
Refs #5754 (left open for the reporter)
2026-11-09 18:55:01 +08:00
Flandern1211 a39b63e886 sessions: a ZCode session is listed once, and its draft folders are one group
A ZCode request names its session by the id its database gives with a
prefix stripped (sess_…, a subagent's sess_subagent_agent_…: zcodeBareID,
which Titles already used for names), while GatewayKeys kept only the
prefixed id. MergeExternal therefore matched no native session for any
ZCode session sent through magpie's gateway, and each was a row under its
folder and again a row under "Seen through the gateway" with no files
behind it. On this computer's database (1,105 sessions, 3,536 gateway
records) that was 70 of 70 gateway rows: 38 top-level sessions, 9 forks,
23 subagents. A group already holds its forks' and subagents' files
(ocRoots), and assembleListed counts every file's calls in the row, so
each of the 70 counted the same calls a second time.

GatewayKeys now gives the bare id of a ZCode session and of its forks and
subagents; externalAdded reads GatewayKeys instead of keeping its own copy
of the keys in pairs; idInFile names ZCode, so subIDs collects the ids
their own rows give (their files are in the group, no row lists them
apart). The Sessions page draws a ZCode session whose folder ZCode made
for that one session (~/.zcode/workspace/<draft|time>-<uuid>, one for
each session started without a project) in one "Scratch sessions" group
after the projects: 42 of them here were 40 folders of one session under
Other folders, and they are no projects of the reader's. cwd, files and
usage are untouched; a row's tooltip gives the folder it ran in.

The list went from 1,286 rows to 1,216 over the same 1,213 native ones;
the 70 gateway rows had 34.3M input and 2.59M output tokens and $125.66
of the ledger's cost on top of the rows that already counted those calls.
A ZCode row now prices its own calls from the catalog like every other
agent's, and Usage keeps the ledger's figures.

Run:
- go test ./internal/sessions -run 'TestZCode' -count=1: ok.
- go test ./internal/gui -run 'Session|Gateway' -count=1: ok.
- go build ./...; go vet ./internal/sessions: ok.
- gofmt -l; git diff --check; node --check on client.js and i18n.js: clean.
- go test ./internal/sessions -count=1: the same failures as without this
  change (TestAgySessions, TestAgyRowOnly, TestAntigravityAppFolder,
  TestCCListingKeepsItsNames: path separators and allocation counts on
  this Windows box).
- go test ./internal/gui -count=1: the same failures as without this
  change (lody's %AppData%, pageservice's symlink privilege here).

Broken by hand:
- dropping the bare key puts the 70 rows back under Seen through the
  gateway (TestZCodeGatewayRowIsTheSessionItself fails);
- leaving ZCode out of idInFile keeps a fork's and a subagent's own rows
  as gateway rows while the group already counts their calls.

Not changed: the scratch group is worked out on the page (client.js), so
Usage's folder filter still lists the draft folders by their paths; the
group is ZCode's only, and other agents' per-session folders are left as
they were.
2026-11-09 18:49:15 +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 4ab1191bc9 routing: Routing groups opened from Routing lead back to it
Since Routing groups became a page of their own, a group chip on a
request (or Routing's "Routing groups ›") switched to the groups page
with nothing leading back. Without the sidebar the only way out was the
tab bar, and the request you came from was gone from view.

The groups toolbar now starts with "‹ Routing" (gBack). It goes back to
Routing through window.show, so a dirty draft is still asked about, and
focus returns to the chip or button the page was opened from. Esc does
the same, except while an editor, Import, Select or a modal is open, or
focus is in a text field. With the sidebar the back control shows only
when the page was opened from Routing (.rt-gfrom); from the sidebar's own
Groups tab the page is top level and has none. No other drill-in page in
app.js binds Cmd-[, so neither does this. The label follows the language
on every draw. No new layout, no accent stripe.

Run (mote, playwright 1.62.0):
- routing-groups-back.test.cjs (new): 30/30, Chromium and WebKit x
  en/zh/zh-TW/ja/de x 1280 window, 640 window, 420 web. Red on
  origin/main's assets (MAGPIE_ROUTING_ASSETS): no visible .rt-gback.
- Broken by hand: Escape handler off -> red (chromium en 1280); the
  side-nav hide rule off -> red (webkit en 1280, "no back from the
  sidebar's own tab").
- Every routing*, sidebar*, group-*, i18n-keys, i18n-en-no-cjk,
  old-webkit and settings-groups file at 2d66e9f23 (main 0fc3455e2 +
  this): 3548 tests, 3526 pass, 22 red. The same files at origin/main
  cdf734757 alone: the same 18 red, all filed: i18n-keys (#5332, #5426,
  #5482), routing-intent-entry 8/8 (#5392), routing-context-fold webkit
  (#5586), routing-row-swap (#3799), routing-story-shrinks webkit
  (#3954). The other 4 (routing-busy chromium zh, routing-many-keys
  chromium en, routing-pace-expiry chromium de, routing-rule-drag webkit
  ja) passed whole, with routing-groups-back, at this commit on
  cdf734757 (70/70); filed #5665, #5664, seen in #4082, #3789.
- Whole GUI suite and ./...: queued on mote, not run at push; results to
  follow.

Reported-by: unscientific9 (Discord)
2026-11-08 11:04:43 +08:00
yetone b77400826a usage: the Overview read again keeps its cards and its place, and shows it is reading
jiabubu on Discord: a refresh of the Usage page's Overview showed nothing
while it read, flashed the page and dropped cards for a moment, and
pressing Usage again while on the Overview flashed it or moved its scroll.

- Pressing Usage again (show() calls the plugin's open, loadUsage(true))
  put the skeleton up, which hid the sections, collapsed the page and
  clamped its scrollTop. loadUsage now puts the skeleton up only for a
  first read or another period or zone (usageFor/usageKey); a page that
  already shows that read reads again quietly through refreshUsage, so
  nothing is blanked and the scroll stays.
- The refresh beside the period turns while such a read is out
  (#usageReload.reading, after 200ms), and while every card is read
  (loadQuotas) each card's refresh turns (#subscriptionUsage.reading,
  quotaReading in page.js). A card's own busy turn is left to its own
  animation (:not(.busy)). No turning under reduced motion.
- renderQuotas draws the cards again in one go, as their reset
  countdowns need, but now keeps their logo nodes (keepIcons), and the
  Overview's lists do too: a logo made afresh blinked out while its
  picture loaded.
- app.js stays in its budget: a three-line comment in renderQuotas cut
  to one. Core 1,533,507 of 1,533,802 before the rebase on 0b4cda048.

Tests:
- New usage-quiet-refresh.test.cjs: Usage pressed again at the top,
  halfway and at the foot, with the read held: no skeleton, chart not
  hidden, scrollTop the same, the refresh turning, then the same figure,
  row and logo nodes; and Refresh with the allowances held: every card
  stays, each card's refresh is shown and turning, the logos kept.
  Chromium and WebKit, en and zh, 1180 and 560px. Red on the old assets
  (8 of 8 per part: "nothing blanked while it reads ['skeleton','chart
  hidden']", "the cards' logos are the ones drawn before: false,false,
  false"), green on the new.
- usage-quota-head.test.cjs waited for the skeleton on Agents -> Usage;
  it now waits for the quiet read (the page kept, the refresh turning).
- usage-stale-answer.test.cjs lifts loadUsage out of page.js; it now
  lifts usageFor/usageKey with it and stubs the page's loading state.

Run on mote (mote-run), at the rebased head 344cdcde3: go test -run
TestCoreScriptBudget ./internal/gui ok; gofmt -l clean; the nine usage,
quota and panel files above plus panel-fit-tabs, panel-usage and
panel-quota-refresh: 140 of 140. Before the rebase (at d32a7a70c's base,
same change less the stale-answer stub): go test ./internal/gui ok apart
from TestSettingsSaveKeepsWhatItDoesNotSend, fixed on main by c7c05dcf2;
GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./... clean;
every GUI file named usage, quota, allowance, click-scroll, sidebar or
last-page (129 files, 1880 tests): red only in files red on main too or
filed: usage-agents-hide (#2276, #3414, red at d32a7a70c alone),
usage-fold (#3415, red at d32a7a70c alone), usage-ledger's Requests
(#5048), and usage-compact-counts' zh-TW 420px tip under load (#5648,
30 of 30 alone); usage-stale-answer's reds there are fixed here (11 of
11).

Not tried: the whole GUI suite (1,274 files; mote at load 60 to 80
from other sessions), the real app and WebKitGTK, languages beyond en
and zh in the new test (no new strings), and the other pages' re-open
by probe (Sessions, Library, Gateway and Masking were read: none puts a
skeleton up over a page already drawn).

Reported-by: jiabubu (Discord)
2026-11-08 03:57:04 +08:00
yetone 0b4cda048c gui: the tray panel shrinks back to a short tab, gliding there
The tray panel was held at its tallest tab's height (#124): fit()
measured every tab and asked for the largest. Once Routing or Usage had
been opened, Agents sat over empty room under its rows until the panel
was let go (refeccd on Discord, macOS). fit() now lays every tab out
the same way and asks for the height of the tab showing (Agents when
none is set), so the panel shrinks as well as grows. #124's complaint
was the panel jumping bigger on a tab switch, so a tab picked glides
the edge there instead (TAB_GLIDE: 240ms on app.css's --ease-out, as
.nav-hl; a jump under reduced motion). Content fits inside a tab
(rows unrolling, Allowances landing) are unchanged.

Siblings: the Go side already shrinks on every OS. FitPanel takes the
height asked, panelFrame clamps it to panelMin/panelMax/the screen, and
glidePanel animates the Mac's frame with its top under the menu bar and
steps Windows/Linux by the tray icon. All three take their height from
this one fit(), so nothing there changed. The web host has no panel.

panel-fit-tabs.test.cjs gets "the tray panel shrinks back to a short
tab": two agents and Routing's eight requests, Agents -> Routing ->
Agents, with reduced motion and without. Agents' height is asked
again, and the tab's fit carries ms=240 and the ease (none under
reduced motion). Its Routing-skeleton check now picks the Routing tab
first, as that is the tab whose height it is about. panel-usage's
assertion is now the showing tab's height, not the tallest.

Run on mote (mote-run). At this commit, rebased on d32a7a70c: gofmt -l
internal/gui nothing; go test -tags nogui ./internal/gui ok (sandbox
HOME); panel-fit-tabs, panel-usage, panel-fit-order, panel-fold 40/40.
Earlier, at the same change on c7c05dcf2:
- new test on origin/main's app.js: 10 of 10 red, Chromium and WebKit
  x en/zh/zh-TW/ja/de: "reduce: Routing asked no taller a panel than
  two agents: 163 629" (the short tab asked the tallest's 629)
- with the change: panel-fit-tabs + panel-usage 24/24 ok (both
  engines, five languages); again at the rebased head with i18n-keys:
  27/28, the one red is i18n-keys' "a plugin's words are its own",
  filed as #5332, #5426, #5482
- the 46 GUI files that read /api/window/fit (at d32a7a70c, before
  the rebase; the change is the same): 1182/1186. Reds, none in the
  panel: images-codex-one (Settings window; red alone on origin/main
  d32a7a70c too, #4618, commented) and view-open-wheel's "wheels
  unheard, usage, en, 1000px" in WebKit (window only, no panel page,
  where fit() returns at once; #4132)
- gofmt -l internal/gui: nothing; go vet, GOOS=linux go vet -tags
  nogui, GOOS=windows go vet ./internal/gui: ok
- go test -tags nogui ./internal/gui (sandbox HOME, pinned caches): ok
  (before trimming, TestCoreScriptBudget was 346 bytes over; the
  comments were cut, the budget not raised)

Not tried: the real app's panel on the Mac, Windows or Linux (no
desktop session driven); the whole GUI suite (mote's suite.lock queue
was full); go test ./... .

Reported-by: refeccd (Discord)
2026-11-08 03:41:23 +08:00
yetone d32a7a70cb remote magpie: once magpie updates, the Remote magpies it uses update too
nnlrl_75403 on Discord: a magpie used as another's Remote magpie stayed on
its old version after the local one updated, and had to be updated by
hand on the other computer. Now nothing needs setting up:

- provider.KeepRemotesUpdated (started by the app's updater and by
  magpie serve) runs UpdateRemotes 30 s after start and hourly. A
  released build with automatic updates on reads each Remote magpie's
  version (GET /v1) and, when it is older, asks it through
  POST /v1/magpie/update?version=<v> with the provider's key, at most
  once in six hours per version. Off here, or a dev build: nothing asked.
- The remote updates as its own automatic update would: the app
  downloads and restarts once idle (updater.updateAsked → download,
  waitIdle); magpie serve puts the latest in where it runs from, one at
  a time, never elevated, and serveFollow restarts into it. Automatic
  updates or downloads off there: it answers "off" and stays.
- A copy that can't replace itself says why: a container (docker pull
  ghcr.io/yetone/magpie:latest), a package manager's (its command), a
  folder it can't write, a build from source. A magpie from before the
  route answers 404 ("too old"), a read-only or held key is "refused".
  The provider's row on the Providers page adds a short status to its
  line ("updating to v…" for 30 min, or "can't update itself" etc.),
  with the reason and the command in its tooltip. en/zh/zh-TW/ja/de.
- The route replaces the program, so it takes the Codex reset's
  admission: another machine only while shared, never a browser page,
  an enabled key with full access from loopback too (401 without one),
  read-only 403 gateway_key_read_only, held 403 gateway_key_held. It is
  in readOnlyRefused and the CORS route list.

App.js stays under TestCoreScriptBudget by cutting two comments; the
budget is not raised.

Run (on mote, at the tree committed here):
- gofmt -l internal/: clean. go vet of gateway, gui, cli, provider for
  darwin, GOOS=linux and GOOS=windows: ok.
- go test -count=1 ./internal/gui ./internal/cli ./internal/provider
  ./internal/gateway: gui and cli ok but for #5644's two settings tests
  (red on main since 6b7ee4a98, owned); provider and gateway were
  still running at the push, and go in the full run after it.
- Rebased on origin/main c7c05dcf2, again: gofmt, vet, the new tests,
  ReadOnlyKeyEveryRoute, CORS, TestCoreScriptBudget (not raised) and
  both GUI files 32 of 32: ok.
- New: TestRemoteUpdateNeedsAFullKey (no key from loopback, Origin null,
  an app scheme, *.localhost, a rebound Host, a foreign page with and
  without the full key, another machine with none or a wrong key,
  read-only and held keys, then not shared; the updater is never
  called until a full key asks, from LAN and loopback),
  TestRemoteMagpieAskedToFollow (UpdateRemotes against a real gateway:
  dev build, same and newer remote, NoAutoUpdate here, asked once per
  version, container answer kept, read-only key refused, a 404 magpie
  "old"), TestUpdateAskedByAnotherMagpie, TestRemoteUpdateNote,
  TestServeUpdateAsked.
- GUI: remote-update.test.cjs (new) and remote-self.test.cjs, Chromium
  and WebKit, 1100 and 420 wide, en/zh/ja/de: 32 of 32 ok, with every
  key checked in zh, zh-TW, ja and de. i18n-en-no-cjk ok. i18n-keys'
  "a plugin's words are its own" is red, the same on origin/main
  f8525323d (#5327/#5332, #5426, #5482); its other cases ok.

Broken by hand, each red, then put back: the handler's key check
(loopback without a key got 200 updating), its held-key check, the
route itself (404 = the old code), asking a remote that is current,
ignoring NoAutoUpdate here, asking again for the same version, the
app ignoring automatic updates off, the app never waiting to restart,
serve's single flight (2 downloads), serve's container answer.
The handler's own Origin and not-shared checks stay green when removed:
corsGuard and lanGuard refuse those first; they are kept as the Codex
reset keeps them.

Not tried: a real update of a real remote (a Docker magpie and an app
on another Mac) end to end; Windows and Linux runs of the new tests
(vet only); the full suite (run after the push).

Reported-by: nnlrl_75403
2026-11-08 03:13:15 +08:00
yetone ea1a8ae809 routing: a folded fold of accounts on one plan says what they have left together
chen2652 (Discord #help): a provider with several accounts on one plan
should show, when its group is folded, one bar and what is left in all;
opened, each account's own quota as now.

A Routing account fold (3+ adjacent accounts of one provider and model),
when folded, now writes its tightest shared window before its status
("5 hours 40% used · …") and a bar under it, from quotaall.js's
mergeQuotas over the accounts' Usage cards. Its tip lists every window,
how they were put together (the mean of n accounts on one plan, added up,
or unlimited on each) and when the first of them starts again. Only when
every account has a card, all on one plan, none free; with different
plans, a card missing, the fold open, or the day view, nothing changes.
An open fold shows only each account's own row, as before. No new words:
every string is already in i18n.js in every language. routing.css is
unchanged (the account rows' bar grid). foldQuota in plugins/routing/
client.js; documented in docs/subsystems/gui-shell.md.

Run:
- routing-fold-accounts-together.test.cjs (new): 5 languages x 1100/420px
  x Chromium/WebKit, 22/22 on mote. Folded: figure, 40% fill, tip in each
  language, no email in the figure; mixed plans: no bar; open: no bar;
  nothing overflows.
- At this tree (rebased on origin/main 999ba6a00), on mote: the new test,
  routing-fold-all, routing-folder and i18n-keys: 66 tests, 65 pass. The
  one red is i18n-keys "a plugin's words are its own" (plugins/library and
  plugins/routing "No session ID"), filed as #5327/#5332/#5426/#5482, not
  a string of this change.
- Earlier, on WSL at d7b298dec vs base 56f095604: every routing GUI file
  plus i18n-keys, provider-at-once and quota-all, 2942 tests; the same
  WebKit/load reds at the base (36 there, 38 here). The one head-only red,
  provider-at-once "webkit en: accounts at once are typed and saved" (a
  Providers editor timeout), passed 60/60 with the new test on a rerun.
- Screenshots of every language at both widths (WebKit) looked at.

Broken by hand, each red in the new test:
- the old client.js;
- combining while the fold is open (no !f.open): "an open fold has no
  bar of its own";
- no one-plan check: the mixed-plan fold drew a bar.

Not tried: the whole GUI suite and the Go suite before the tag (run after
it); the real app with the reporter's real accounts on one plan.

Reported-by: chen2652
2026-11-07 22:03:32 +08:00
yetone 75d0fc3aca gui: on macOS 27 the main window keeps its toolbar, which no longer changes the corners (#3949)
TestMainWindowCorners/macOS_26_SDK was red in every run on mote
(macOS 27.2). The test was right and the code wrong: insetLights took
the main window's toolbar off whenever AppKit gives the program the
design of macOS 26 (designOf26), on the grounds that a toolbar gives a
window Finder's larger corners there. macOS 27 doesn't: a window with a
toolbar and one with a plain title bar both get 16pt corners (AppKit's
_cornerRadius and _cornerMask are the same for both, measured on mote
with a 26.2-SDK probe). So on 27 the toolbar went for nothing, and the
lights, the title bar's height, first presses and sheets were all held
in place by hand where the toolbar would have kept them itself.

insetLights now also asks toolbarRounder: the window's corner radius
held against a window of its style with no toolbar, never shown. The
toolbar is taken off only when it makes the corners larger (or when
AppKit doesn't tell the radius, as before). The test is unchanged
except its comments: it already checks, by measurement and not by OS
version, that the toolbar stays where it doesn't change the corners
and that the main window has a plain title bar's corners,
so on macOS 26 a toolbar kept wrongly is red too.
docs/subsystems/gui-shell.md says so.

Run (mote, macOS 27.2, arm64, at this tree on 05f6fd423):
- go test -count=1 -run 'TestMainWindowCorners$|TestMainWindowRightToLeft'
  -v ./internal/gui: both subtests and right-to-left pass; macOS 26 SDK
  now reads "toolbar kept true", corners 16/16/16, lights, 66pt title
  bar, presses and sheet the same as the toolbar window's.
- go test -count=1 ./internal/gui/...: ok (133s).
- gofmt -l . (empty), go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build: ok.

Broken by hand: toolbarRounder made to return YES (the old behaviour):
TestMainWindowCorners/macOS_26_SDK red at "a toolbar doesn't change the corners" on all three stages,
as in #3949. Restored.

Not tried: macOS 26 (no macOS 26 test machine; heavy runs stay off this
Mac), where toolbarRounder must still read 26pt against 16pt and take
the toolbar off; CI's macOS job runs macOS 15, which never reaches it.
No screenshot of the corners on mote (screencapture has no Screen
Recording permission over ssh); the corner mask was compared instead.
The full suite runs after the push.
2026-11-07 15:04:26 +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
yetone 361da10ee9 web: the page's API answers its own origin only, not a page on another port or a sibling subdomain
With browser access on (Settings > Browser access, or magpie web), the
sign-in cookie magpie_web_<port> is SameSite=Lax, which a browser sends
with any same-site request: another port of 127.0.0.1 or of the LAN
address, or a sibling name behind the same reverse proxy. apiFramed
refused Origin null, frames and cross-site, but not same-site, and /api
decodes JSON from any Content-Type. So such a page could POST a stdio MCP
server to /api/library/servers/save (text/plain, no-cors) and start it
with /api/library/mcp/check: code run as the user.

webOwnPage (in webHandler, behind webGuard, /api/ only) now judges every
write (all methods but GET/HEAD/OPTIONS) with net/http's
CrossOriginProtection: Sec-Fetch-Site same-origin or none passes, any
other value is refused; from a browser without Sec-Fetch-Site, Origin must
be absent or name the request's Host (or MAGPIE_PUBLIC_URL, for a proxy
that rewrites Host). Any /api request, a GET too, whose Sec-Fetch-Site is
same-site or cross-site is refused, so no GET route with a side effect
(GET /api/import/{id} reads once and deletes) is another page's to call,
without auditing each one. A Sec-Fetch-Site same-origin with an Origin
that doesn't match the Host passes: the browser compared the origins
itself, and nginx's default proxy_set_header Host $proxy_host would
otherwise break every write behind it. The desktop window's /api is served
in-process over no port with no cookie, so it isn't wrapped and its
headers are unchanged. No Content-Type rule: every write the page makes
goes through api() as application/json, but multipart and text/plain are
both CORS-safelisted, so the rule would add nothing the origin check
doesn't already give.

Run on mote at 49c9491b7 + this commit; after the rebase onto e1eeeed73 (38 commits, none in web.go/pluginpage.go/api.go) gofmt, the three vets of internal/gui and -run TestWeb were run again: ok.
- TestWebAPIAnswersItsOwnPageOnly, through webServed (onePort ->
  AllowGuard -> webGuard -> webOwnPage) with the page's cookie and no
  gateway key. Refused: same-site Origin on another port, cross-port
  Origin without Sec-Fetch-Site, localhost on another port, the LAN
  address on another port (both), a sibling subdomain (both), cross-site,
  Origin null (both), no Origin with Sec-Fetch-Site same-site and
  cross-site, GETs from another port, a sibling and a cross-site link, a
  cross-port preflight. Allowed: the page's own origin (with and without
  Sec-Fetch-Site), on the LAN, behind a proxy keeping or rewriting the
  Host, MAGPIE_PUBLIC_URL with an old browser, Sec-Fetch-Site none, a
  non-browser client with the cookie.
- Real browsers: magpie web built from origin/main and from this commit
  (-tags nogui, sandbox HOME, MAGPIE_WEB_KEY), an attacker page on
  127.0.0.1:3497 / localhost:3497 running the no-cors text/plain POST.
  Old: the attacker's server was saved in Chromium and WebKit. New: not
  saved in either, logged "turned away ... Sec-Fetch-Site"; the page's
  own JSON write answered 200 in both.
- go test -tags nogui ./internal/gui -timeout 45m: ok
- gofmt -l: nothing; go vet ./internal/gui/... ./internal/cli/...,
  GOOS=windows go vet ./internal/gui/..., GOOS=linux go vet -tags nogui
  ./internal/gui/...: ok

Broken by hand: webOwnPage taken out of webHandler -> 29 cases red
("reached true, want reached false"). The read rule taken out -> the
three GETs and the preflight red. cop.Check skipped -> the 8 old-browser
cases red.

Not tried: the full ./... suite (the change is one handler in
internal/gui); the GUI Playwright suite (its pages mock /api with
page.route and never reach this server; the real-browser check above
stands in); a real reverse proxy; the Windows and Linux app pages; the
MAGPIE_DEV_UI dev server, which serves /api with no key and isn't
wrapped.
2026-11-06 22:17:04 +08:00
yetone 251cce2059 usage: a click on All N accounts folds that provider's accounts under it (justfreefall on X)
justfreefall on X (CODEX (2), "既然已经有汇总信息了,能不能出个按钮把下面两个折叠?"):
the All N accounts strip already sums the accounts, so its accounts can go.
The strip gets the per-account card's own chevron (quota-acct-fold, aria-expanded,
Fold/Unfold title, no new strings). A click on the strip or the chevron, or
Enter/Space on the chevron, folds that provider's account cards in the Usage
page and in the tray panel's Allowances; again unfolds. Default open. Kept per
provider in localStorage magpie.usageAllFolded beside the other view choices,
and a storage event redraws the other window. The head's "Show ..." button
stays in its room, hidden and inert, so the strip does not move under the
pointer. A menu-bar cell that asks for one folded account unfolds them first
(focusQuotaCard). quotaall.js reads the choice on first use, so loading it
touches no app.js global (usage-merge runs it in a bare vm).

Core script budget: not raised. app.js +35 bytes, met by shortening comments.

Run (mote, macOS 27, unless said):
- go test -tags nogui ./internal/gui/: ok at the rebased head (130s); Budget
  tests again after the last edit: ok. gofmt -l: clean.
- usage-all-fold.test.cjs (new): 10/10, chromium + webkit x en zh zh-TW ja de,
  window 440x520 and panel 360x760. Broken by hand: with main's assets it is
  red (no .quota-all-fold).
- usage-merge, usage-all-fold, tray-cell-click, quota-caption-contrast, old-webkit
  after the last edit: all ok except tray-cell-click 4/4, red the same at
  origin/main fcc0daa23 (#5215).
- Usage/quota files alone, base fcc0daa23 vs this: usage-fold ("several accounts",
  "17 subscriptions"), usage-agents-hide, usage-compact-counts, usage-ledger
  Requests red the same on both (32 each); usage-merge was red only here
  (kept is not defined) and is fixed above.
- i18n-keys "a plugin's words are its own": red the same on base (#5332).
- account-eye webkit "Usage card's eye" on WSL: base 9/10 red, this 5/10 (#5052, #4244).
- click-scroll webkit "a wheel the page hears of after its scroll": red on base too (WSL).
- Whole GUI suite on WSL (concurrency 8) before the usage-merge fix: ~40 reds
  outside usage (Connect, Copilot GHE, gateway keys, groups, skills, routing
  headers, plugins), the class #5475 records on main; each usage/quota/panel
  red was rerun against base above.
Not run: go test ./..., cross-OS vet (assets and one .cjs only); the real app.
2026-11-06 19:27:42 +08:00
yetone 49c9491b73 update: the Windows app asks where to install, the first time
The Windows exe opened from Downloads (or the Desktop, or temp)
installed itself into %LOCALAPPDATA%\Programs\magpie without a word.
Now, the first time, with nothing installed yet, Windows' task dialog
asks "Install magpie in this folder?". It shows the folder and offers
Install, Change… and Cancel, in the tray's language (en, zh, zh-TW,
ja, de).

- Change… opens the system folder picker. A picked folder gets
  "magpie" added unless it is already named that (update.InstallDir).
- A folder other than the default is recorded at HKCU\Software\magpie
  InstallLocation. So the next exe downloaded replaces the copy there
  in place and asks nothing (installed(), forwards()).
- Cancel runs the exe where it is, as a portable copy, and nothing is
  recorded.
- Uninstall forgets the record (update.ForgetInstallDir, a new System
  step).
- The shortcut, App Paths, autostart, magpie://, the PATH entry and
  self-update already take the running exe's folder, so they follow
  the choice.

Program Files and other folders only an administrator can write to
are refused in the dialog (update.Installable test-writes and maps a
permission error to ErrNeedsAdmin). They are not elevated into.
magpie installs per user (HKCU Run, the user's PATH), and its
self-update replaces the exe without elevation (CanElevate is false on
Windows). So an admin folder would make every update fail, or would
need a UAC prompt on each one. A downloads folder is refused too.
Refusing is the simplest correct choice: it costs a user nothing they
had before, and keeps updates silent. Any folders the test-write made
are removed again.

Docs: gui-shell.md, "Where Windows installs magpie".

Run (mote, at this head on origin/main f9e6061b8):
- gofmt -l is clean.
- go build ./... and go vet of update, uninstall and gui.
- GOOS=windows go vet of gui, update and uninstall.
- GOOS=windows GOARCH=arm64 go build ./....
- GOOS=linux go vet -tags nogui of the same packages.
- go test -count=1 ./internal/update ./internal/uninstall, and
  -run TestInstallWords|TestTrayLang ./internal/gui: ok.

Run (win-run, xiaomi-gpu):
- internal/uninstall ok, and gui TestInstallWordsEveryLanguage ok.
- internal/update: one red, TestPackagedByDpkg. It is red on
  origin/main too: an NTFS stream from the fixture name
  magpie:amd64.list (#4603).

Real Windows 11 run (xiaomi-gpu, a sandbox USERPROFILE/LOCALAPPDATA
under C:\Users\yeton\magpie-idir, MAGPIE_ADDR on 3481, exe in its
Downloads, driven over UI Automation and TDM_CLICK_BUTTON):
- The dialog came up in Chinese, with the app icon and the default
  folder.
- Change… → C:\Program Files was refused with the administrator note
  and the warning icon, and no folder was left behind. C:\Windows was
  refused the same way.
- Change… → …\Tools gave …\Tools\magpie. Install put magpie.exe and
  magpie.com there, and the app ran from there.
- Afterwards InstallLocation, the user's PATH, App Paths and
  magpie:// all named …\Tools\magpie. `magpie version` from a fresh
  PATH resolved to …\Tools\magpie\magpie.com. `magpie autostart on`
  wrote Run = "…\Tools\magpie\magpie.exe" tray.
- Upgrade: a 0.1.9001 build downloaded into Downloads asked nothing.
  It replaced …\Tools\magpie\magpie.exe (FileVersion 0.1.9001) and ran
  from there.
- `magpie uninstall --yes` removed autostart, App Paths, the scheme
  and the record, and deleted the sandbox data. The next exe asked
  again.
- Cancel ran the exe from Downloads and recorded nothing.
- The registry and folders were put back as they were before the run,
  checked by a snapshot diff.

Broken by hand:
- recordedDir's lookup turned off: TestSettleInstallsWhereTheUserChose
  and TestSettleOffersTheChosenFolderAgain went red.
- AskFolder skipped: those two and TestSettleDeclinedRunsHere went red.

Not tried:
- The in-app self-update download. There is no newer release to
  download; the in-place replace path was run with a downloaded exe.
- The en, ja, de and zh-TW dialogs on screen. Their words are checked
  by TestInstallWordsEveryLanguage only.
- arm64 Windows.
- A Downloads folder moved by OneDrive.
- The Start-menu shortcut. The box's real App Paths already held
  another session's magpie, so shortcut.ensure took the shortcut as
  removed by the user. This is existing behaviour.

Not changed: uninstall still leaves the PATH entry and the exe, as
before for every install (#5500). Related to #2663, which asks for a
first-run choice of where magpie lives.

Reported-by: feng_21795_78266 (Discord)
2026-11-06 17:34:48 +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 f285426ac2 library: the MCP router turns on with no agent, and in gateway mode
treeman_26897 on Discord runs magpie as an MCP entry point for remote
clients on a server with no agents. The router could only be turned on
from the Library, and the Library said "No agents to write to" with no
agent. In gateway mode (magpie web on a headless server, on by itself
with no agents) GATEWAY_HIDES left the Library out altogether. The
router's switch also showed only once a server was in the library. The
gateway and `magpie library mcp router on` had no agent gate: the gate
was the page's alone.

Now, with no agent to write to, or in gateway mode (where no agent is
shown), the Library is its MCP tab alone (`agentless` in client.js):
- servers without agent chips, found servers or projects;
- the router's switch, there before the first server too;
- its lines and status say any app connects at its address, the
  router is on or off;
- the servers it serves are checked once it is on;
- Connect… has Other apps alone, with the gateway key line.
Gateway mode hides only Agents now. The two keys of the empty state
are gone; the gateway-mode subtitle no longer says "no Library".

Remote use goes through the guard /v1 has, unchanged: lanGuard and
serveMCP. TestHubMCPRemoteEntryNeedsKey holds /mcp/magpie/hub to it
from another computer: not shared 403; shared with no key 401 (no
Origin, tools/list, a wrong key); Origin null, chrome-extension://,
file://, moz-extension://, a foreign site and another computer's page
refused from there and from here; a rebound Host with a browser's
marks (Origin = Host, Sec-Fetch only, a Mozilla UA) refused from
here and there; a proxy or tunnel here (X-Forwarded-For,
Cf-Connecting-IP) with no key refused; nothing ran for any of them;
with the key it runs, through the proxy too.

Run on mote at ef20ff690 (on origin/main b4799a6bb); rebased again on
6a78060c6 (gateway.go changed there), the gateway's Hub and LAN tests
and the Budget test ran again ok:
- go test -tags nogui ./internal/gateway -run Hub: ok
- go test ./internal/gui -run Budget: ok (no budget raised; the core
  scripts were 137 bytes over with a longer comment, cut back)
- gofmt -l clean; GOOS=linux and GOOS=windows go vet of gateway, gui: ok
- GUI, both engines, every language: library-mcp-agentless (new, 22
  of 22), gateway-mode, last-page, library-mcp-hub, mcp-hub-direct,
  library-servers-bulk, i18n-keys: 87 of 88; the red is i18n-keys
  "a plugin's words are its own", below.
- Before the rebase, the GUI files a change here can reach (every
  library-*, gateway-mode*, last-page, i18n-*, mcp-hub-direct,
  agent-prefs, bare-ids, images-library-way, search-/vision-mcp-library,
  gateway-conversations; 70 files): 1535 of 1536. The one red is
  i18n-keys "a plugin's words are its own", on main already: #5327,
  #5332, #5426 (files this change doesn't touch).

Broken by hand:
- library-mcp-agentless against origin/main's client.js and app.js:
  22 of 22 red (no router row with no agent; no Library tab in
  gateway mode).
- rebound() returning false and serveMCP's Origin check off:
  TestHubMCPRemoteEntryNeedsKey red on the rebound Host cases and on
  chrome-extension://, file:// and moz-extension:// from here. The
  test passes on the old Go code: the guard was there already.

Not tried: a real remote MCP client against a headless magpie serve
or magpie web on another machine; the TUI (it has no Library page of
its own for the router; the CLI's router on needs no agent).

Reported-by: treeman_26897
2026-11-06 12:12:20 +08:00
yetone 814a625a24 usage: the top refresh reads saved Claude accounts again (#5380)
The tray panel's Allowances refresh said "Allowances refreshed" but a
saved, non-active Claude account kept its old reading: claudeWindows runs
Claude Code's /usage for a saved account only under savedRefresh, which
only that account's own card refresh sets.

Now a refresh of every allowance by hand asks usage/quotas?asked=1&all=1
(AskEveryClaudeUsage). It marks its ask generation in claudeEveryAsked,
and for claudeEveryFor (2 minutes) each saved account not read since is
read as its card's refresh would, under the same due check, the
30-second per-account floor and the same running holds. Opening the
Usage page or the Allowances tab (?asked=1 alone), the timed refresh and
every background read are unchanged, so nothing polls more. Callers:
the panel's top refresh (refreshPage "allowances"), the Usage page's
refresh and sidebar reload (refreshUsage -> loadQuotas("all")),
Routing's Read allowances, and the TUI's r. loadQuotas no longer lets a
lesser load on its way (an opening's asked read) swallow a Refresh.

Siblings: saved Codex accounts are already read anew on every asked
whole read (loginReading over HTTP after AskUsage clears the cache), so
Codex is unaffected. PlanQuotas and KeyBalances keep their 1-minute cache
on an asked read; left as is. The core scripts' budget is not raised:
the ~140 bytes are paid for by two loadQuotas/quotasOpened comments cut.

Run (mote, at 807341cdc on origin/main 5666cb049; rebased onto
505534992 after, which touches only internal/plugin and internal/proc;
the core script budget rechecked at the pushed head, 193 bytes under):
- go test ./internal/provider/ ./internal/gui/ ./internal/tui/ ok
  (TestMainWindowCorners/macOS_26_SDK red on mote's macOS 27, #3949;
  green when run with the -run set at the pushed head)
- go vet the three packages; GOOS=linux go vet -tags nogui and
  GOOS=windows go vet of them ok; go vet provider+tui in WSL ok; gofmt -l
  clean
- GUI, Chromium and WebKit, en+zh: refresh-page, claude-usage-asked,
  usage-refresh, routing-read-allowances, allowance-open-read,
  quota-refresh-order, usage-refresh-flight all pass. A wider set of 119
  files (quota*, panel-quota*, usage-*, allowance*, routing-read/account,
  menu-*, tray-*, i18n-keys) has reds in 6 files, identical at the parent
  commit and filed: i18n-keys #5332, menu-input-scroll #3402,
  tray-cell-click #5215, usage-agents-hide #3414, usage-fold #3415,
  usage-ledger #5048.
- New TestRefreshEveryReadsSavedClaude: an opening's ask runs nothing
  for saved accounts; a top refresh reads each anew; an unasked read and
  a plain asked read after it don't; rapid refreshes keep the floor; the
  every-ask lapses after claudeEveryFor.

Broken by hand: dropping "|| every" from claudeWindows' read turns
TestRefreshEveryReadsSavedClaude red ("top refresh read no allowance of
saved max@x.com"); the panel's refreshPage back on loadQuotas(true)
turns refresh-page's panel subtests red in both engines.

Not tried: a real saved Claude account's /usage run from the real tray
panel (the test fakes Claude Code's /usage per account directory); the
full GUI suite; the de/ja/zh-TW GUI runs (no string changed).
2026-11-06 00:35:39 +08:00
yetone 11d9d0a3a5 routing: each account one calm cell in Accounts and keys (danzi002 on Discord)
danzi002 (v0.1.2945): Accounts and keys "显示的好乱啊,没有之前一目了然".
70a98dd85 (v0.1.2929) made the cards compact for ferock4669 and iyou00,
but left each card 3-5 lines of uneven height (tally, latest answer, a
Try now on its own line) in 168px columns: names cut, the status
wrapped, red twice on every resting account and on healthy ones with
old failures, Try now links scattered. Rendered with 9 Codex, 1
WorkBuddy and 3 WorkBuddy AI accounts, zh at 1100/1440, parent
c4245c4c2 against main.

Kept the compact change (still short, long lists still fold) and made
each account one uniform cell instead of reverting:
- a dot for its state: green in use (the provider's not-resting account
  that answered last), amber resting, grey otherwise, red to act on;
- name, plan and a muted Try now on one line, then one line of what is
  left and when it renews, or when it is back, wrapped in full, never cut;
- how it fared (the tally) and when it was read ("as of") on hover;
- red only where the reader must act: sign in again, a restriction or
  verification, a key failing with nothing else to say. Those rows keep
  their tally in sight;
- columns min(240px, 40vw), the usage bar back in the flow (Chromium
  misplaced the absolute bar inside a multicol .rt-lead).
routing-account-windows and routing-wallet-lapse now find "as of" last
in the tooltip instead of on the line.

Run on mote (Chromium + WebKit, en/zh/zh-TW/ja/de, 1100/420 and the
files' own widths):
- new routing-acts-calm.test.cjs: green both engines, all 5 languages.
- every Routing file that renders .rt-act plus i18n-keys and
  panel-routing*: 679 tests, 610 pass; the reds besides mine were
  rest-try-now WebKit, rules-line, rule-drag/remove, row-swap, steady,
  steps-cap, story-shrinks, order-unknown and many-keys webkit zh, the
  same set as main f44fa2ef6 run alone (41 reds there), filed as #5035,
  #5088, #4585, #3593, #4082, #4628, #3789, #3799, #3412, #4629, #3954.
  After fixing my own reds, acts-calm, account-windows, wallet-lapse,
  many-keys, rules-line and key-windows: 135 pass, 1 red (rules-line
  webkit en 1100, #3593/#5035).
- At the pushed head (rebased on 34116ec01): acts-calm,
  account-windows, wallet-lapse and i18n-keys 70/70 pass, the Go size
  budgets pass.
- go test ./internal/gui/...: TestMainWindowCorners/macOS_26_SDK red
  only (#3949, AppKit on macOS 27); the size budgets pass.

Broken by hand, each red in routing-acts-calm (Chromium):
- the resting line red everywhere (.st.rest red): red outside ivy;
- the tally shown on calm rows: "main: its name and what it says";
- columns back to 168px: a one-line status fails;
- no rest class: expected 'rest'.

Not tried: dark mode by eye, the real app on WebKitGTK (Linux) and on
Windows, real accounts (the fixture is synthetic), and the 8-row fold
with more than 8 Codex accounts by eye.
2026-11-04 22:04:17 +08:00
yetone 532d054bee sessions: every Cursor row has a delete, and the right-hand column lines up
ysm119 (Discord), Sessions page, Cursor tab: some rows had a delete and
some had none, and the time / "N sessions" column stood at a different x
from row to row.

Causes:
- Delete: listAgentWith set Deletable = Deletable(agent) && !ReadOnly, so
  every editor-transcript row (read only) came back deletable:false, and
  client.js drew .sm-del only for deletable rows.
- Alignment: a folder adds its ⋯ only when it has actions, and a session
  row's Resume / terminal / Continue in / delete come and go per row, so
  .sm-when, .cost and .num moved with them. "Copied" is wider than
  "Resume", and at <=600px the cost line wrapped at different places.

Change:
- rowDeletable decides per row. An editor transcript the editor no longer
  keeps (no state.vscdb, or it was read and has no composer for that id)
  is "loose" and deletable: Delete trashes only its <id>/ folder or
  <id>.jsonl/.txt, never state.vscdb. A chat the editor keeps, or a store
  that can't be read, stays undeletable with undeletable:"cursor-editor".
- In an agent magpie deletes from, every row has its delete. One it can't
  delete is aria-disabled, says why in its title, and a click shows the
  reason in the status line and sends nothing (en, zh, zh-TW, ja, de).
- A row without Resume, Continue in or a terminal, and a folder without
  its ⋯, keep that room with an inert, aria-hidden slot. Resume reserves
  the wider of Resume and Copied; at <=600px the cost keeps a min width.
- docs/subsystems/gui-shell.md says so.

Run (on mote via mote-run, base f44fa2ef6; origin/main 93d5c76c0's 3
commits since touch none of these files):
- go test ./internal/sessions: ok. go test ./internal/gui: ok except
  TestMainWindowCorners/macOS_26_SDK, an AppKit titlebar red on macOS 27
  already filed as #3949.
- gofmt -l clean; go vet native, GOOS=linux -tags nogui, GOOS=windows ok.
- New sessions-cursor-align.test.cjs: 10/10 (chromium + webkit x en, zh,
  zh-TW, ja, de; widths 1100/660/420, hover, Copied).
- Sessions GUI set (sessions-*, session-*, gateway-conversations,
  gateway-mode-sessions, account-mask-sessions, header-session-hint,
  routing-session*, routing-ctx-sessions, usage-session*, i18n-keys,
  gui-de, gui-ja, gui-zh-tw): 728/728, and 728/728 again after the
  rebase onto 93d5c76c0 (which changed app.css and i18n.js).

Broken by hand:
- rowDeletable forced to "read only": all 3 new Go tests red.
- sessionPaths' editor-path branch off: TestCursorLooseFlatTranscript red
  (it trashed agent-transcripts/ itself).
- Old client.js/sessions.css/i18n.js: new GUI test 10/10 red. Folder slot
  alone removed: red at 1100 (when 1071 vs 1037). Lanes removed: cost
  edges differ. Before the Copied and de 420 fixes, those cases were red.

Not tried: a real Cursor editor or a real ~/.cursor (every delete ran on
fixture copies in a sandbox HOME); the Windows and Linux apps; deleting a
chat from Cursor's own UI and seeing magpie's list follow.
2026-11-04 21:15:33 +08:00
yetone 70a98dd85c routing: a long Accounts and keys shows its first rows, the rest behind Show N more (ferock4669, iyou00 on Discord)
With many keys the Routing page's Accounts and keys ran on and on: each
card held every window, the models it answered and a meter. Now a card
keeps its name, one line of what is left (or its rest) and how it fares,
with Try now or Sign in again when it needs one. The models it answered
are in its tooltip under its id, and a subscription's other windows are
on hover over its figure.

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

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

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

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

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

Not tried: the real app with a real long key list (fixtures only), the
Linux WebKitGTK app, Windows.
2026-11-04 18:33:07 +08:00
yetone 14f6d10de0 routing: a remote's Claude card whose read failed says so on its row, not nothing (yi_time on Discord)
remoteWinsOf (c7bbd3faf) drew a Remote magpie row's windows from the
remote's cards. It said "Allowance unavailable" only when the remote's own
card failed. When the remote answered but its Claude card there carried an
error (the remote's own Claude read failed), the Usage page showed that
card and its reason, while Routing's row showed nothing. The row now takes
the error of the card of its own family (Claude's on a claude row,
Codex's on a gpt/codex row), with the reason on hover. The remote's own
card still comes first. The plugin's file only; no core bytes.

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

Not tried: yi_time's own setup, which this may not be. Their Routing
report came before v0.1.2908 (c7bbd3faf) was published at 07:08 UTC on
11-04; a Windows magpie older than that draws no remote windows on
Routing at all. Not tried in WebView2 or WebKitGTK.
2026-11-04 18:14:11 +08:00
yetone c7bbd3faf6 routing: a Claude joined over the network shows its windows in Accounts and keys (yi_time on Discord)
A remote magpie's provider row on the Routing page showed no usage, while
the subscriptions above it did. The remote's cards already reach the
window as /api/usage/quotas entries with `from` set (provider =
<remote id>/<card provider>), but the page's cardOf/winsOf match only
kind "account" with no `from`. remoteWinsOf (plugins/routing/client.js)
now draws those windows on a remote-magpie row: a claude-* model row
gets the remote's claude cards, gpt/codex/o\d rows its codex cards, each
window prefixed by the user when several cards match. When the remote's
read failed it says "Allowance unavailable — hover for why" with the
error as the title (existing string, all languages), never 0. The usage
comes from the machine that owns the account; no gateway change.

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

Not tried: a real two-machine LAN run, a real Claude account on a remote,
Windows or Linux GUI engines (WebKitGTK).
2026-11-04 14:59:26 +08:00
yetone d1fa254b1d gui: masked words and Never mask are a list, a row per word (noahhrreion on Discord)
noahhrreion: "希望脱敏词选项可以做成真正的列表,在一个小输入框里面不方便管理多个脱敏词".
Settings → Privacy's Masked words was one comma-separated box. It is now a
list (wordList in plugins/redact/settings.js): each word is its own row,
edited in place (Enter or leaving the row saves, Escape puts it back,
emptied is removed), × removes it, and the last row adds. Its sibling,
Never mask under the mask actions, had the same box and gets the same list.

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

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

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

Not tried: the real app on WebKitGTK / Windows WebView2; no Go files changed.
2026-11-04 12:38:10 +08:00
yetone 6673171595 update: the app and magpie web follow each other's update (visamzh on X)
visamzh on X: with the desktop app and magpie web both open, an update
from either side left the other still offering it ("↑ 更新") until it was
quit by hand.

Cause: the app and magpie web are two processes over one program, each
with its own updater (state, download, latest) in memory. One restarting
to update puts the new binary in; the other is told nothing. Its
replaced() (the binary on disk is no longer the one it started from) was
read only on a click of its own Update or on magpie update's gateway ask
(restartBeside), which reaches only the process serving the gateway. And
a browser's page reloaded (backAsNew) only after a restart it asked for
itself, so magpie web's tab kept the old page and its pill even once
the process under it was new.

Fix:
- followReplaced (update_beside.go): every updater stats its binary each
  5 s and, once another magpie replaced it, restarts into it through
  restartBeside, once: at once when idle, else after the gateway's
  requests (waitIdle), as for magpie update's ask. Not for what this
  process put in itself (installed, set by install, cleared by
  wontStart), not twice (followed), not for a build that isn't a release
  (make dev, go build rebuild in place). It stops with backendCtx, so a
  copy left draining after a handover doesn't look.
- waitFor (update_wait.go): a wait for the gateway restarts into what
  another magpie put in whatever the feed says now; before, a feed out
  of reach or a "latest" answer ended the wait with nothing restarted.
- boot.js names the version that served the page (bootPrefs.version);
  app.js's servedAnew reloads a browser's page (web) when /api/update's
  current names another, on the reads it already made (load, focus, back
  into view) and once a minute while shown. The app's own windows come
  back with their new process and are left alone.
- docs/subsystems/gui-shell.md describes it.

Run (mote, through mote-run, at 1e1068c86 + this change unless said):
- gofmt -l internal/gui: nothing.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., go build, GOOS=linux go build -tags nogui, GOOS=windows go
  build: all ok.
- go test -tags nogui -race -count=5 -run
  'Follow|AnotherMagpies|OwnUpdate|OwnBuild|UpdateClicked|Wait|Beside|
  Restart|Install|WhatsNew|Quiet' ./internal/gui/: ok (102.9s).
- go test -tags nogui -timeout 45m ./internal/gui/... ./internal/cli/...
  ./internal/update/... . : gui, update, update/launcher and magpie ok;
  internal/cli red in TestEveryRouteHasACommandOrIsNamed (GET
  /api/context/reply has no command), red the same on origin/main
  51fa4b7eb alone, filed as #5026 (from 0872bc2a0).
- node --test internal/gui/tests/update-served-anew.test.cjs: 34/34
  (Chromium and WebKit; en, zh, zh-TW, ja, de; 1100 and 420 wide; the
  minute poll under page.clock; the app's window not reloaded).

Broken by hand, each red, then put back:
- followReplaced never restarting: TestAnotherMagpiesUpdateRestartsThisOne
  and TestAnotherMagpiesUpdateWaitsForTheGatewayThenRestarts red.
- the installed guard dropped: TestOwnUpdateIsNotFollowedAgain and
  TestUpdateClickedOverAnothersIsNotFollowedAgain red (a second restart).
- waitFor's "in" case off: TestAnotherMagpiesUpdateWaitsForTheGateway
  ThenRestarts red (the wait ends with nothing restarted).
- boot.js without the version: TestBootNamesTheVersionThatServedThePage
  red.
- servedAnew not reloading: 15 of 16 subtests red in Chromium.
- the minute poll removed: the 5 "left on screen" subtests red in WebKit.

A first cut also refused a second install() once one was in; that made
TestRestartBySelfComesBackQuietly and TestWhatsNewQuietAfterRestartTo
Update red (they restart one updater several times), so the flag only
keeps followReplaced off.

Not tried: a real pair of the app and magpie web on two release builds
with one replacing the binary (only temp files and fakes); Windows
(InstallBinaryAside starts the staged file there, so the own-install
test is skipped and the click test covers the flag) and Linux runs;
the whole GUI suite: mote was never free (two other sessions' full GUI suites, load ~400), so it runs on the Linux box after this lands.
2026-11-04 06:59:29 +08:00
yetone 7033f50722 gui: the panel opens the main window from its edge nearest the tray
isaac_bai on Discord, after v0.1.2857 named the header's icon "Open the
main window": with Windows' taskbar at the bottom, the panel stands above
the tray and its header is the panel's whole height from the icon; the
button left of Quit was where his pointer already was. yogurt36 had asked
for one opener, not two, so the panel still has exactly one, now on the
edge nearest the tray:

- Hung below its icon (the Mac's menu bar, a taskbar or bar at the top)
  it is the header's icon, as before.
- Standing above it (Windows' bottom taskbar, a bottom panel on Linux) it
  is "Open the main window" left of Quit in the foot (#openMain), and the
  header has no icon. The string is the one the icon's name already
  uses, in all five languages.

Which side: once togglePanelNow has placed and shown the panel,
tellPanelSide reads the panel's bounds and its screen's and sends
magpiePanelOpenAt("foot") when the panel is nearer the screen's bottom,
"head" otherwise (panelOpenAt, panelside.go; the Mac is always "head").
Under Wayland a window can't read where the compositor put it, so there,
and until the app says, layout.js sets body[data-open-at] by the system:
"foot" on Windows, "head" elsewhere. CSS shows one of the two from it.

Tests:
- TestPanelOpensTheWindowFromTheEdgeNearestTheTray: Windows bottom/top
  taskbar, a tall panel, a second screen above the first, Linux X11
  bottom/top, Wayland, a screen not read, the Mac, unknown places; only
  "head" or "foot" reach the page.
- TestPanelToldItsSideWhenShown: both show paths in togglePanelNow call
  tellPanelSide after placing; app.js has magpiePanelOpenAt.
- panel-open-once.test.cjs, Chromium and WebKit x en/zh/zh-TW/ja/de:
  on a Mac platform exactly one opener, the header's, named per
  language, opening /api/window/main, foot ["profBtn","quit"]; told
  "foot" it moves. On Win32 exactly one opener, the foot's, left of Quit
  (["profBtn","openMain","quit"]), the foot's buttons fitting apart with
  their words whole at 360px, opening /api/window/main; told "head" it
  moves back; an unknown side changes nothing.

Run on mote via mote-run:
- At this head (rebased on 8468afecb): go test ./internal/gui -run
  'TestPanel|TestTrayDouble|Budget|I18n|Asset': ok; node --test
  panel-open-once, i18n-keys, window-no-footer, panel-profiles,
  quit-ask-setting, gui-de, gui-ja, gui-zh-tw: 165 of 165 pass.
- At the same change rebased on f168dd278 (main's 8 commits since are
  Library, Routing, browser and Codex-subagent work, none in the
  panel's header or foot): the 127 GUI files that load
  mode=panel or touch the foot, Quit, i18n or a budget, both engines,
  6 at a time: 2112 of 2136 pass. The 24 reds are in 7 other files; run
  again 2 at a time, 16 stay red at this change and 17 at origin/main
  1e1068c86, the same tests: usage-fold, tray-cell-click and
  codex-auto-reset webkit de (#4790), remote-magpie (#4398), and one
  provider-mask case (filed #5109); account-mask (#3951) and
  quota-curve (#4768) went green on the second run.
- At this head: wsl-run go vet -tags gtk3 ./internal/gui: ok
- win-run go vet ./internal/gui: ok; win-run go test -run
  'TestPanelOpens|TestPanelToldItsSide|TestTrayDouble' ./internal/gui: ok
- gofmt -l internal/gui: empty

Broken by hand (in a copy): panelOpenAt always "head" plus the page's
default and magpiePanelOpenAt doing nothing: the Go test red on 5 cases,
panel-open-once 20 of 20 red. Only the CSS rule that hides the header's
icon at the foot dropped: panel-open-once red (two openers shown).

Not tried: a real Windows tray with the taskbar at the bottom or the top,
or a Linux X11 bottom panel; the bounds Wails reports there are read from
its source (positionWindow, the screen's Bounds), not seen. The whole GUI
suite (1175 files) was not run: mote was at load ~55-100 from other
sessions' suites.
2026-11-04 00:22:54 +08:00
yetone b088fd0f09 gui: the panel's header icon is named "Open the main window"; a double-click on the Windows tray icon opens it
isaac_bai on Discord missed the "Open magpie" button beside the quick
panel's Quit, and was setting the tray click to open the main window just
to get back to it; he asked for a double-click on the tray icon.

History: the foot's button (#openMain) was taken out on purpose in
e0ad48641 (10-30, yogurt36 on Discord): the panel had two buttons to the
same window, the header's open-as-a-window icon (#open) and the foot's
"Open magpie". The header icon stayed, but its tooltip said "Open as a
window", which reads as this panel in a window. Rather than bring the
second button back (and undo yogurt36's ask four days later), the icon now
says what it opens: "Open the main window", a string every language
already had (Settings' tray-click choice). "Open as a window" is out of
i18n.js, nothing else used it.

Double-click, per OS, from Wails v3.0.0-beta.24's source:
- Windows: systemtray_windows.go passes WM_LBUTTONDBLCLK on as
  OnDoubleClick. A double-click arrives as LBUTTONUP (the click: the panel
  opens), LBUTTONDBLCLK (now: ShowMain, whose openMain hides the panel),
  LBUTTONUP again; that last one is swallowed once (trayDouble, within
  2s) so it doesn't open the panel over the window.
- macOS: the status item's action runs per mouse-down with no click count
  (systemtray_darwin.m statusItemClicked); a double-click would be the
  panel opened and closed. Not added.
- Linux: StatusNotifierItem has Activate only (systemtray_linux.go); the
  same. Not added.
docs/subsystems/gui-shell.md step 10 says so.

Tests:
- TestTrayDoubleClickOpensTheWindowOnWindowsOnly: windows on, darwin and
  linux off, and app.go wires OnDoubleClick to ShowMain and checks the
  swallow first in OnClick.
- TestTrayDoubleClickReleaseSwallowedOnce: the release after a
  double-click opens nothing, once; the next click, or one past the bound,
  opens the panel. Fixed instants, no sleeps.
- panel-open-once.test.cjs: the header icon's title and accessible name
  are "Open the main window" in en, zh, zh-TW, ja and de, both engines.

Run (at the pushed head's tree before rebase onto 78667e9b7, which changes
only docs/subsystems/gui-shell.md among these files):
- mote: gofmt -l internal/gui clean; GOOS=windows go vet ./internal/gui ok;
  go test -run TrayDouble ./internal/gui ok.
- Linux (wsl-run, magpie-desktop): go vet -tags gtk3 ./internal/gui ok;
  go test -tags gtk3 -run 'TrayDouble|TrayMenu' ./internal/gui ok.
- Windows (win-run, xiaomi-gpu): go test -run TrayDouble ./internal/gui ok.
- mote GUI, both engines: panel-*, phone-web, old-webkit and i18n-keys
  (24 files), 280/280 ok.
- Broken by hand (a copy on mote): trayDoubleClicks false for windows and
  the swallow never reset are both red; the old "Open as a window" title
  is red in every language, Chromium 0/5 and WebKit 0/5.

At the pushed head (rebased on 78667e9b7), mote: gofmt clean, go test -run
TrayDouble ./internal/gui ok, panel-open-once + i18n-keys 14/14 ok.

Not run: the whole GUI suite (a tooltip only, no layout or API change) or
the whole Go suite. Not tried: a real double-click on the Windows tray
icon in the built app, or the panel in the real tray on any OS.
2026-11-03 20:54:01 +08:00
yetone af55a7917f tui: quitting where magpie opens at login says how to have the gateway handed on (#3756)
With #3372, Open at login on Linux reads a package's own autostart entry
in $XDG_CONFIG_DIRS (nixpkgs ships one). JoeyWu-tech's #3756 asked what
`magpie daemon install`'s guard and `magpie tui`'s hand-off as it quits
should count on a box no desktop logs into (NixOS-WSL, a server over SSH),
where nothing ever starts that entry.

Decided: both keep counting what Open at login shows (autostart.Enabled).
A session check can't tell (an SSH login into a desktop box has no
DISPLAY either), and counting less than the switch shows would install
the service beside an app the desktop does start. The install already
refuses with "run `magpie autostart off` first", which is the way out.
The terminal's quit only said "the gateway stopped", with nothing about
why or what to do; it now says magpie opens at login and serves it then,
and that `magpie autostart off` has magpie tui hand it on where no
desktop logs in (atLoginNote). Off Linux and with nothing connected the
note is as before.

What was run (wsl-run, magpie-desktop Ubuntu 24.04, go1.26.8):
  go test -tags nogui -count=1 ./internal/autostart ./internal/daemon
  ./internal/testenv ./internal/tui: ok
  With keep.go as before (the test kept): TestKeepGatewayAsTheTerminalQuits
  red, "app at login: ... the gateway stopped with magpie tui; ..."
  gofmt -l: nothing

Not tried: a real NixOS-WSL login; mtul0729 ran the #3372 patch on real
NixOS + COSMIC, at the systemd generator's level.

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
JoeyWu-tech ab25a2317b autostart: on Linux the switch follows a package's own entry (#3372)
mtul0729, packaging magpie for nixpkgs (#3372, COSMIC on Wayland,
v0.1.1334): a package that ships its own autostart entry
($XDG_CONFIG_DIRS/autostart/magpie.desktop, /etc/xdg when unset) has
magpie open at login, but enabled() read only
$XDG_CONFIG_HOME/autostart, so Open at login said off over it. Off
removed a user file that wasn't there, and the package's entry went on
starting magpie. On wrote this copy's own path over the package's entry:
under a package manager a versioned path, gone once the package is
upgraded and collected. The package doc says the switch "can't say one
thing while the system does another"; on such a system it did.

Now, as the XDG Autostart spec has it:
- The entry that counts is the user's, else the first of the
  $XDG_CONFIG_DIRS folders (/etc/xdg when unset or empty) that has one.
  A relative folder has none, as the spec says, and neither has a file
  listed there, a folder this user can't search or a name too long,
  which systemd's generator and GLib can't open either. The user's own
  folder listed there too, by any name (os.SameFile, so /home linked to
  /var/home too), is still the user's.
- An entry is read as GLib's key file and systemd's parser read it: the
  keys of its [Desktop Entry] group alone (a [Desktop Action]'s Exec is
  not the entry's), spaces around = and CRLF lines as any others, the
  last of a key given twice, true or 1 for Hidden. It opens magpie when
  it is an application (Type=Application) with an Exec other than true
  (below), not Hidden.
- X-GNOME-Autostart-enabled=false (or 0) reads off too, as the issue
  asks. GNOME's and Cinnamon's sessions read it; systemd's generator
  (KDE's and COSMIC's sessions under systemd) doesn't, so there such an
  entry reads off while it starts.
- Off, over a package's entry that some desktop starts, writes an entry
  of the user's that hides it; that includes one GNOME has off, which
  systemd's generator still starts. Otherwise off removes the user's
  entry, as before. On, over a package's entry that starts magpie,
  removes the user's entry and writes no path; otherwise (no package
  entry, a hidden one, or one GNOME has off) it writes this copy's
  entry, as before.

The hiding entry is "[Desktop Entry] Type=Application Name=magpie
Exec=true Hidden=true". A session holds back the entries of a name only
once it has read one, and each reads differently (from their source):
- gnome-session (main and 42.0) and cinnamon-session load an entry with
  g_desktop_app_info_new_from_filename. GLib (main,
  g_desktop_app_info_load_from_keyfile) refuses one with no Type or
  Name, or whose Exec names a program it can't find, and the session
  skips an entry it can't load, so the package's starts.
- mate-session's egg_desktop_file_new refuses an application entry with
  no Exec, and the entry then takes no app id.
- cosmic-session without systemd never reads Hidden: it starts what Exec
  names, and takes the name once that ran.
- systemd's generator (main, xdg-autostart-service.c) reads Hidden
  first, and hides an entry it can't parse, which still holds back the
  rest.
true is on every system by that name, so each session reads the entry,
and COSMIC's runs true where it would have run magpie. A copy of the
package's own Exec would stop holding the package's back on GNOME once
its store path is collected. With this box's GLib 2.72.4 (Ubuntu
22.04's) and 2.84.2 (anaconda's), through ctypes: Exec=true and no Exec
load, hidden; an Exec naming a store path that is gone, and a bare
"[Desktop Entry] Hidden=true", don't load. An entry that runs true opens
nothing, so it reads off: XFCE's Session and Startup lists the hiding
entry as magpie, unticked, and ticking it there writes Hidden=false into
it (xfae-model.c), which runs true, not magpie. On takes it away for the
package's.

What is no entry, and what can't be read: a path where no regular file
is (a folder, a link that leads nowhere or round in a loop) is no entry,
as systemd's generator and GLib pass over it, and on leaves a folder
there alone. A file that can't be read (EACCES, EPERM, EIO) counts and
starts nothing, as systemd's generator has it; GLib passes over it, so
where the first entry is unreadable GNOME starts the next folder's while
Open at login reads off. Any other failed read, magpie out of files or
memory, says nothing of what the desktop reads at login: Set returns it
and writes nothing, and Open at login reads on, as the package's doc has
it for a system that can't be asked (Windows' Run key that can't be read
is not a no either).

The user's entry is written where the desktop reads it. A link there (to
magpie's launcher, which install.sh writes, the usual way to have an app
open at login; or into a read-only store), or a hard link, is replaced
by the entry, not written through: edit.WriteAtomic writes a link's
target, and a hard-linked file in place, so off over a package's entry
would have left the launcher running true, and failed over a read-only
target with the switch still on. Main's enable() wrote through such a
link too, when on was asked over one (a linked launcher already reads
on); it goes through the same write now.

Old entries: a user entry an older magpie wrote stays and still counts
over a package's, as before. The switch reads on over it, so in the app
taking it away is off, then on; `magpie autostart on` does it in one
step. One whose store path was collected reads on as well, though
systemd's generator starts nothing for it and still holds the package's
back, so on COSMIC or KDE magpie doesn't open while the switch says on;
GLib passes over it, and GNOME starts the package's.

The daemon and the terminal: `magpie daemon install` refuses while
magpie opens at login, so the app and the service don't both serve the
gateway, and `magpie tui` quitting hands the gateway on (keepGateway,
75e78a5a) only where nothing opens magpie at login. Both read
autostart.Enabled, code unchanged, so a package's entry counts for both
now. Where a desktop session runs XDG autostart that is the point:
install says to run `magpie autostart off` first, which now hides the
entry, where before the service went in beside an app the package's
entry went on opening. On a box no desktop logs into (NixOS-WSL, a NixOS
server over SSH) nothing runs the entry, yet install refuses and
keepGateway only says the gateway stopped; `magpie autostart off` gets
both going. That is #3756, filed with this, for yetone to say what they
should count on Linux; a session check wouldn't settle it, since install
over SSH into a desktop box has no DISPLAY either.

An entry the desktop's own settings switched off reads off for the guard
as well: XFCE writes Hidden=true into the user's entry, which main still
counted (it read Type and Exec alone), so install refused; now it goes
in. I kept that reading, and daemon.go's comment now says so, rather
than have the guard count such an entry. The switch and `magpie
autostart` read it off, and a guard counting it would refuse with
"magpie already opens at login" where `magpie autostart` says it
doesn't. The Mac has a state for that case (NeedsAllowing, which the CLI
and the app explain in System Settings' words), and Linux has none to
show it; Windows reads a Run value Task Manager switched off as off, and
on switches it back, as Set(true) does here. What it costs: ticking
magpie again in the desktop's settings after the install opens the app
beside the service, in #3756 too. For an AppImage or a tarball, with no
package entry, on and off write and remove as before, and what changes
is how an entry reads (Hidden, the GNOME key, a failed read, as above)
and that a link at the entry is replaced, not written through.

docs/subsystems/gui-shell.md says how Open at login reads on Linux, and
that the terminal's hand-off counts a package's entry (#3756).

Rebased onto origin/main 58fb3a77: 824100f3 added a line to
gui-shell.md next to the one this patch changes, so 7e9003aa no longer
applied. The code and the docs line are as they were (the same patch
for internal/).

What was run (tree 59fb33a8, on origin/main 58fb3a77, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077:
- go test -tags nogui ./internal/autostart ./internal/testenv -v:
  autostart ok, its new tests among them; testenv ok but TestProgram,
  red under this box's umask 077 (#3640), as on main.
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
  vet for windows without the tag, go build -tags nogui for linux and
  darwin, and go build for windows: exit 0 each; untagged linux vet and
  build stop at pkg-config (no GTK headers here). GOOS=freebsd vet: not
  run at this tree.
- go test -tags nogui -count=1 -timeout 45m ./... (log kept), Bun
  1.4.2, 8m35s, load 19 at its start: 70 packages ok, autostart,
  daemon, cli and tui among them; reds in 6, each known: agent
  TestInstalledVersion, TestCursorFolderFromTheEditorIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141), TestCodexDriftReached (#3398) and the two
  Reasonix tests (#3641); davsync TestSyncTeraCloudStillSeesOtherWrites
  (#3420);
  edit TestWriteAtomicReadOnlyHardLink and testenv TestProgram
  (umask 077, #3640); gateway TestPluginToldWhereTheAgentWorks (#3675),
  the package ran to its end; gui TestGatewayHeldByAContainer and
  TestGatewayFixQuitsOnlyAMagpie (#3649).

The rest is what was run for 7e9003aa, at tree 719db0e7 on origin/main
6e6aba51, the same code (not this tree):
- Real use (real.log): the built magpie (-tags nogui) and origin/main's,
  each in a sandbox HOME under env -i, with a package entry (Exec=magpie
  tray, magpie on PATH) in XDG_CONFIG_DIRS, and systemd 249's
  systemd-xdg-autostart-generator after each step:
  - the package's entry alone: main says magpie doesn't open at login
    while the generator starts magpie tray; this says on.
  - off, twice: main writes nothing and it still starts; this writes the
    hiding entry, and the generator starts nothing.
  - on: main writes its own path, which it starts; this takes the hiding
    entry away, and the generator starts the package's magpie tray.
  - no package entry, on then off: both write their own path, which
    starts, then remove it, and nothing starts. The package's entry put
    back, off again: as the first off.
  - the package's entry with X-GNOME-Autostart-enabled=false: both say
    off while the generator starts it. Off: main writes nothing and it
    still starts; this writes the hiding entry, and nothing starts. On:
    both write their own path.
  - the hiding entry ticked again as XFCE does (Exec=true, Hidden=false)
    over the package's: the generator runs /usr/bin/true; main says on,
    this says off. On: this takes it away and the package's magpie tray
    starts; main writes its own path.
  - the user's entry a link to magpie's launcher, off over the
    package's: main takes the link away and the package's entry still
    starts; this writes the hiding entry in the link's place, and
    nothing starts. The launcher is unchanged in both.
  - an old entry of magpie's naming a store path that is gone, over the
    package's: both say on, and the generator starts nothing. On: this
    takes it away and the package's starts; main writes its own path.
- The new tests over origin/main's autostart_other.go, with a nil
  systemRecords and readEntry added so they build (red-on-main.log): all
  9 new ones red, and TestSet and TestSetThenTruncatedRecordReadsAsOff,
  which main has, pass. The first red of each: :101 "the package's entry
  opens magpie at login, and Open at login reads off"; :226 "the second
  system folder's alone: off, want on" (and 5 more rows: three more
  where a system folder alone has the entry, the user's own entry
  Hidden, and the user's own off by the GNOME key); :241
  "XDG_CONFIG_DIRS unset: [], want
  ["/etc/xdg/autostart/magpie.desktop"]"; :311 and :373, no hiding entry
  written; :440, off over a link to the launcher left no entry of the
  user's, and :437, on over it with no package's entry wrote through to
  the launcher (main's own enable(), the sibling above); :491 "a folder
  at the user's entry, the package's entry there: true: off, want on";
  :534, on over an unreadable user entry leaves it; :568, no hiding
  entry to read.
- Broken by hand (breaks.log), each one part of the fix undone, all 36
  red, the fix put back ok after. The first red of each:
  - where entries come from: no system folders :101; the system's
    folders over the user's :108; unset XDG_CONFIG_DIRS with no /etc/xdg
    :241; a relative folder kept :266; the user's folder, by any name,
    taken for a system's :290.
  - how an entry reads: Hidden ignored, Hidden=false read as hidden,
    Hidden=1 not read, all :226; the GNOME key ignored, and its 0 not
    read, :226; the system's entry starting whatever its Type :226;
    spaces around = kept, a line's CR kept, every group's keys read as
    the entry's, all :226; an entry that runs true read as opening
    magpie :120.
  - what off and on write: off always removing :108; off writing the
    hiding entry with no package entry :173; off deciding by GNOME's
    reading :373; on always writing this copy's path :131; on over a
    package's entry keeping the hiding entry :127; on taking away a
    folder of the entry's name :495.
  - the hiding entry: with no Exec :323, no Type :318, a store path for
    Exec :326, true named by a path :326.
  - what can't be read: a file in XDG_CONFIG_DIRS, a folder this user
    can't search and a name too long, each read as a failed read, :269;
    a folder at the entry's path, and a link loop, read as one :491; an
    unreadable entry read as no entry :528; every failed read an entry
    that starts nothing :576; magpie's own failed read read as no entry
    :576, and taken for a no :580.
  - links: a symlinked entry written through :437, and a hard-linked one
    :437.
- internal/autostart, daemon, cli and tui (pkgs.log): ok.
  internal/autostart with -race -count=3 (race.log): ok; nothing in it
  runs in a goroutine of its own.
- Probes at this tree, thrown away after (probes-3756.log): keepGateway
  with the real reading and all else stubbed, and Install behind
  daemon_test's fakes (fake systemctl, launchctl and loginctl alone on
  PATH). With the package's entry, keepGateway only says the gateway
  stopped and Install refuses before any systemctl call. Under the
  hiding entry off writes, and with no package entry but the user's own
  entry Hidden=true as XFCE writes it, keepGateway installs the service
  and Install goes through (the fake's daemon-reload, enable and
  restart).
- Full suite, -tags nogui (CI's Linux job tags gtk3), outside graftcp
  (systemd-run, umask 077, Bun 1.4.2 first on PATH as on CI, -timeout
  45m, log kept): 64 packages ok, autostart, daemon, cli and tui among
  them, and 8 packages red, each filed:
  - agent TestCodexDriftReached: #3398; TestInstalledVersion,
    TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
    TestQoderSettingsFromAnIDEPluginIsNotTheCLI,
    TestOmpDetectedWithPiDir and TestZedAppPath: #3141;
    TestReasonixCLIRequiresSupportedNativeVersion and
    TestReasonixCLIRecoversAfterProbeTimeout: this box's /tmp/.git,
    #3641.
  - davsync TestSyncTeraCloudStillSeesOtherWrites: #3420.
  - edit TestWriteAtomicReadOnlyHardLink: this box's umask 077, #3640.
  - gateway TestPluginToldWhereTheAgentWorks: this box's /tmp/.git,
    #3675.
  - gui TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie:
    this box's millions of open fds, #3649.
  - #3741.
  - provider: "fatal error: close of synctest channel from outside
    bubble" in TestUnreadLoginsWriteErrorsKeepCredentials, main's CI
    red, #3632; the package's tests after it didn't run.
  - testenv TestProgram: this box's umask 077, #3640, red so at
    origin/main 6e6aba51 alone too (testprogram-main.log).
- gofmt -l: clean. go vet -tags nogui for linux, windows and darwin,
  GOOS=windows go vet ./..., GOOS=freebsd go vet ./internal/autostart/
  ./internal/daemon/, go build -tags nogui for linux and darwin and
  GOOS=windows go build ./...: all clean. Untagged linux vet and build
  stop at pkg-config here (no GTK headers on this box).

Not changed: gnome-session also reads $XDG_DATA_DIRS/gnome/autostart,
between the user's folder and $XDG_CONFIG_DIRS; it isn't in the spec,
and this doesn't read it. systemd reads an XDG_CONFIG_DIRS that is set
but empty as no folders, and opens a relative folder from its working
directory; this follows the spec: /etc/xdg for an empty one, and no
relative folder. Whether the program an entry's Exec or TryExec names is
there isn't checked, and an entry with any Exec (Exec=magpie serve,
another program's magpie.desktop) reads as magpie opening at login. With
no package entry that starts magpie (none, a hidden one, or one GNOME
has off), on still writes the path self() gives, a versioned one under a
package manager (#3621, where skygunner has a branch, 0aac5452, which
git apply --check takes over this one); a Linux refresh() that took away
an old entry of magpie's whose Exec is gone, where a package's entry
starts magpie, belongs there too.

Not tried: a real login into GNOME, KDE, MATE, Cinnamon, XFCE or COSMIC
(what each session does is read from its source, GLib's loading tried
with the two GLibs above); NixOS itself, and home-manager's links; a
real `magpie daemon install` or keepGateway over a package's entry,
which would reach this box's own systemd and gateway
(TestRefusedBesideAutostart and TestKeepGatewayAsTheTerminalQuits stub
what they read, and the probes above use the real reading).

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 9019ca88d6 gui: Scroll to top and Scroll to bottom move when the page under them changes, not only on a scroll (Jiabubu)
Jiabubu on Discord: with the capsule in sight, a click that opened a
Routing group left it over the editor's member rows (Remove beside Up
and Down) and its held Cancel and Add, and it moved off them only once
the page was scrolled.

scrollends.js placed the capsule on a scroll, a resize, focus or the
pointer leaving it, and a hidden attribute set anywhere. Opening a group
in place sets none, unless something else on the page happened to be
hidden again in the same draw (an empty pool list is, on every draw,
which is why the earlier tests saw it move). It now also watches the
open page and each of its own children with a ResizeObserver, and the
page's child list, so any change of size under it (a group opened or
closed, rows added or taken out) places it again on the next frame: it
rises above a held foot, steps aside at the page's foot, or comes back.
One file serves every page with the capsule (Agents, Providers, Routing,
Library, Settings, plugin pages), so they all take it. No core script
changed; scrollends.js loads lazily and has no budget.

view-ends-relayout.test.cjs: with no scroll after the change, the capsule
must be where the reader's next scroll puts it, and over nothing of the
editor's:
- Routing, 16 groups of the reporter's rows ("低-ultra", 922K), a pool in
  the list: a screen down, a click on the card lowest in sight opens its
  editor; then Cancel closes it.
- Agents, 40 rows: a little above the foot, a block at the list's end
  taken out so the foot comes up under the capsule.
Desktop 1100, 700, 560; browser page 1100, 440, 360; Chromium and WebKit,
en/zh/zh-TW/ja/de.

Run on mote (mote-run) at this tree:
- view-ends-relayout, both engines, every language: 10 of 10 ok.
- On 5ee5274bd (origin/main just fetched) plus this change:
  view-ends-relayout, view-ends, routing-editor-foot, old-webkit and
  i18n-keys: 62 of 62 ok.
- Before the rebase (on c0d4f17a3), with group-editor-selected,
  group-editor-fits, group-member-drag, drag-rows-shift, routing-rows-fit,
  click-scroll, add-button, library-discover-jump and account-eye beside
  those: 214 of 214 ok.

Broken by hand: scrollends.js as at origin/main, 20 of 20 red (both
engines, every language), each part on its own:
- Routing: "desktop 1100px: opened, the capsule above the held Cancel
  and Add, with no scroll: 569-624, bar from 591".
- Agents only: "desktop 1100px agents shorter: the capsule stepped aside
  as a scroll has it, with no scroll: [[true,569,624,1739],[false,...]]".

Not tried: the whole GUI suite. Both machines already had full suites of
other sessions running (WSL: four, at load ~140; mote: one, 49 minutes
in), and one full suite runs on a machine at a time. The capsule's
behaviour is the only change, no layout and no new API call. Also not
tried: the Windows app (WebView2) and the Linux app (WebKitGTK) themselves,
and the reporter's own groups.
2026-11-03 17:26:53 +08:00
yetone 0872bc2a0e context: a request's text and reply from the request archive (wangbinyq)
wangbinyq on Discord: with the request archive on, clicking a block of
the context window card still said "只保留最近 10 个请求的原文", since the
card read only the last 10 bodies magpie keeps in memory.

What changed:
- /api/context/text tries memory first, then the request archive's copy
  when the route names one (Route.Archive, the route found in the trace
  or in the history file of the card's ?day=, HistoryRoute looks a day
  either side). gateway.ArchivedPromptText parses it as PromptText does
  and masks it through maskedCopy, as the body in memory is; it is
  marked from "archive" and the card says so.
- New /api/context/reply: the reply to the request, from the Recent
  calls (Server.ReplyBody) or the archive's Response. gateway.ReplyPieces
  reads it into thinking/assistant/call pieces (conversationOutput, split
  out of conversationTurn) after redact.ScrubJSON, and masks every piece
  through maskedCopy. The card's text view has a Reply button beside
  Close that shows it and goes back to the part.
- What is shown is what the archive stores, masked as the memory copy
  would be, nothing more. A body or reply that can't be masked shows
  nothing (404 "unread"); one the archive cut short isn't parsed ("cut");
  one it names and doesn't have says so ("missing"), and one with no
  archive copy keeps the old "only the last 10" line ("off"). A failed
  bucket read is an error, not "gone".
- The archive read is capped at archiveReadMost and the last copy read is
  kept 5 minutes, so the items opened one by one read it once.
- ctxtext.js takes the route (id and time) instead of the id; context.js
  passes it (its one-line change paid for by a comment cut, core budget
  not raised). New strings in zh, zh-TW, ja and de.
- docs/subsystems/gateway-routing.md (Prompt) and gui-shell.md.

Run on f3335dd1b (main has since d73f2254d, textcalls_anthropic.go and
its test only, none of these files), on mote (macOS 27):
- go test -run 'TestArchivedPromptText|TestReplyPieces|TestPromptText|
  TestConversation|TestContext|TestCoreScriptBudget' ./internal/gateway
  ./internal/gui: ok.
- Whole ./internal/gui and ./internal/gateway (before the last rebase,
  same change): ok except TestMainWindowCorners/macOS_26_SDK (#3949) and
  TestCodexPoolSaysTheClientsVersion (#4807, fixed on main by 17f2387e1
  since).
- GOOS=linux go vet -tags nogui and GOOS=windows go vet of both: ok;
  gofmt -l clean.
- GUI, both engines, every language, 1100 and 420 wide: every file that
  reaches the context card (context-text, context-map, context-window,
  context-map-live, context-scroll-end, context-scripts, context-tune,
  ctx-route, compact-one-value, routing-ctx-*, routing-context-fold,
  routing-live-patch, routing-return-cost) plus i18n-keys: 514 of 518.
  The 4 reds are context-map's webkit 420px "two tiles overlap", red the
  same on origin/main f3335dd1b run alone (5 of 10 webkit there), #3488.
- The whole GUI suite is running on the Linux box (wsl-run) as this is
  pushed; mote had another session's full suite on it.

Broken by hand (each went red):
- maskReplyPieces skipped: TestReplyPiecesAreMasked (phone unmasked).
- ArchivedPromptText's masking skipped: TestArchivedPromptTextIsMasked
  and TestContextTextFromTheArchive (phone in the 200 body).
- ctxtext.js's "missing" reason dropped: context-text.test.cjs, 10 of 10
  chromium.

Not tried: a real archived request in the running app, the bucket
(WebDAV) archive with a real server, and a reply cut short by the
archive's size in a real call.
2026-11-03 13:34:35 +08:00
yetone 84da86ebd5 gui: Hide accounts is one switch for every page, window and the panel (paultian)
paultian on Discord (#feedback): Routing, Usage and Providers each kept
their own "Hide accounts" state, so turning it on in one page left the
others showing emails. Now window.hideAccounts is one switch, one
localStorage value (magpie.maskEmails), behind #rtMask, #usageMask and
#pvMask alike. Flipping it in any page applies to every page at once,
and a storage event carries it to other windows and the tray panel.
The old magpie.maskProviders value is folded in on first load (hidden
if either value was on) and then removed, so nobody who hid accounts
on one page sees them shown after updating. The tooltip and the
Settings line now say "on every page" instead of "on this page", in
every language.

Tests: provider-mask.test.cjs checks that one switch hides accounts on
every page and in a second window, that the state survives a reload,
and that an old maskProviders=1 comes through as hidden.
account-mask's expected tooltip text is updated.

Run on mote (GUI files at base 05aba5ca4; the Go asset/budget tests again
at this head after rebasing on a92cc3f33):
- go test -run 'Budget|I18n|Asset|Script|Strings|Lang' ./internal/gui: ok
- The masking/privacy GUI files at --test-concurrency=2, chromium and
  webkit, every language (account-mask-alias-plan, account-eye,
  window-mask, usage-fold, masking-demo-unblurred, account-alias,
  provider-mask, account-eye-provider, account-mask,
  privacy-hides-accounts, account-mask-sessions, mask-emails,
  plugin-name-unmasked, i18n-keys, masking-records): 403 of 408 pass.
  The 5 reds:
  - provider-mask "chromium en 420" (a click timed out). Rerun with
    usage-fold at concurrency 1: provider-mask is all green, and that
    run is 146 of 150.
  - usage-fold, 4 subtests: "17 subscriptions and 29 accounts" in
    chromium and webkit, and "several accounts" in webkit en and zh.
    They fail the same 4 at origin/main 625938a2f at concurrency 1
    (6 of 10 pass). That is #3415 / #4790, not this change.
- Not touched: Go code, so no go vet.

Broken by hand: with the old assets, provider-mask's one-switch tests
go red; with the maskProviders migration taken out, the
old-value-comes-through test goes red.

Not tried: the whole GUI suite (the owner's rule is to ship each
verified fix right away), and the real tray panel on Windows/Linux
following a switch flipped in the main window. Only the browser
storage event is tested.
2026-11-03 11:32:47 +08:00
yetone b295d11965 serve, update: one magpie works the gateway; the service waits, the copy an update left stops (#4938)
ox01024's #4938, Bug 2. Two magpies did the gateway's work at once on a
Mac:

- launchd's com.yetone.magpie.serve ran `magpie serve` beside the app.
  It ran startUp (plugin Settle/Refresh, FoldCopies, Hold, the agent
  moves), the plugin host and every account's model fetch, then failed
  to bind, exited 1 and was started again 5s later: 6,035 times in two
  days, a 279MB serve.log, and logins.json.lock held against the app's
  requests until they went 504.
- The copy an update left (.magpie-update/old) handed the socket over,
  hid, and lived on ~3h, its loops writing beside the new one.

What changed:

- cli: `magpie serve` (no --web) checks codexrelay.Leave,
  gateway.ServedBy and gateway.Taken before startUp, as the app's
  serveGatewayLocked does. While the port is held it prints one line
  and looks again every 15s, doing nothing else. Once the port is free
  it serves (serve_wait.go). It waits rather than exiting 0: under
  KeepAlive SuccessfulExit:false a clean exit would leave no service
  after the app quits.
- gui: after a handover the old magpie's loops end with backendCtx:
  - library.KeepLinked (now takes a ctx),
  - provider.WatchQuotas,
  - the menu bar usage loop,
  - the updater's check/auto-restart loop.
  lighten lets its hidden webviews go as lightweight mode does, so
  their polls stop. quitBy exits it at handedOffDrain + 3m whatever
  holds its quit up (gateway.HandedOffDrain getter; exitNow stubbable).
- docs/subsystems/gui-shell.md says both.

Run at the pushed head on mote (mote-run):
- gofmt -l internal/: nothing. go vet ./internal/{cli,gui,library,gateway};
  GOOS=linux go vet -tags nogui and GOOS=windows go vet of the same: ok.
- go test -count=1 -timeout 45m ./internal/cli ./internal/library
  ./internal/gui ./internal/gateway at bf05291e2 + this: cli and
  library ok. Two reds, both already filed:
  - gui TestMainWindowCorners/macOS_26_SDK (#3949). It is red the same
    on origin/main 443e53d6b, run alone.
  - gateway TestCodexPoolSaysTheClientsVersion (#4807). It is red only
    in the full package run, and passes alone 5 of 5 at this head.
- After rebasing on 8819beeb0, on that head: the vets above; cli and
  library in full, ok; gui and gateway with -run for handover, handoff
  and lightweight, ok.
- Sandbox HOME on mote, a fake app answering / as magpie 0.1.2770 on a
  private port (3593), `magpie serve` built from this tree beside it:
  alive after 8s at 0% CPU, nothing written under HOME, one standby
  line. 20s after the fake quit it served the port. The same with the
  old wait call removed: "magpie: listen tcp 127.0.0.1:3593: bind:
  address already in use", exit, and plugins.yml and lock files written
  first.

Broken by hand, each red:
- No wait before startUp: TestServeWaitsForTheGatewayBeforeStartingUp
  ("ran the start-up moves while another magpie served the gateway").
- KeepLinked ignoring its ctx: TestKeepLinkedEndsWithItsContext
  ("went on after its context ended").
- No quitBy in handover.run: TestRestartHandsTheGatewayOver ("has no
  deadline to quit by").

Not tried:
- A real launchd service beside the real app, and a real update
  handover on a Mac. Neither was run: no live app or launchd.
- The lighten change (needs Wails webviews) has no test.
- Not done here: serve.log rotation, `magpie daemon install` beside a
  running app (#4887), the old copy's appPage port, and Bug 1 and
  Bug 3 (ggbdpq has Bug 1).

cdredfox on Discord reports ~270% CPU after v0.1.2770. That fits this,
but it is not confirmed as their cause.
2026-11-03 11:16:02 +08:00
yetone eb779ce92a gui: the tray icon's tooltip is in magpie's language (yi_time)
yi_time in #feedback: magpie set to Chinese on Windows, and the tray
icon's hover tooltip said "Today: 121K tokens (2.9K in · 180 out ·
118K cached)" and "3 requests" in English. The tray menu already
followed magpie's language (trayLang, #301); the tooltip's words were
hard-coded English in trayusage.go.

Now every tooltip is in trayLang(settings.Lang, systemLang), on
Windows, macOS and Linux alike. That covers trayIdleTip, magpie's
totals (trayTotalCard), and each subscription card (trayCardText: its
use or what is left, the pace, when it resets, until's d/h/m, "as of
…"). The words are in trayWords beside the menu's, for zh, zh-TW, ja
and de; English stays the key and the fallback. A window's name and an
error are still the card's own. A change of language in Settings now
also refreshes the tooltip (onTrayUsage); before, only the menu was
relabelled. The test-only trayUsageText and trayUsageView stay in
English, so the existing tests keep their strings.

Test: TestTrayTooltipFollowsMagpiesLanguage.
- yi_time's own numbers in zh: "magpie\n今天:121K token(输入 2.9K ·
  输出 180 · 缓存 118K)\n3 个请求".
- The same numbers in en are unchanged.
- Covers the total card and a card's used, left, reset and as-of.
- For zh, zh-TW, ja and de, no English word in the idle, totals, card
  (with pace) or combined tooltips.

Run at this head (rebased on 5573f7923):
- mote: gofmt -l clean; CGO_ENABLED=0 GOOS=linux go vet -tags nogui
  and GOOS=windows go vet of ./internal/gui ok.
- mote: go test ./internal/gui. Everything passes except
  TestMainWindowCorners/macOS_26_SDK, which is #3949 (red on mote's
  macOS 27, not touched here).
- Windows (xiaomi-gpu, win-run): go test -run Tray ./internal/gui ok.

Broken by hand: with the tooltip words taken out of trayWords, the
test goes red. Its zh output is then exactly the old English tooltip.

Not tried:
- The real tray on Windows, hovering the icon.
- The watch loop's choice of language has no test of its own. Passing
  "en" there would not go red.
2026-11-03 10:14:23 +08:00
yetone 5ec2375688 gateway: a call's HTTP headers both ways, masked, folded under its bodies
usrname1833 on Discord asked to see the raw request and response HTTP
headers (查看原始请求和原始响应的http头), to debug as with a capture.
magpie kept the client's request headers and its own response headers
only in the request archive, and nothing of what went upstream.

Now a call keeps its headers both ways (internal/gateway/wire_headers.go):
- the client's, as they reached magpie: headerLogged in Handler() clones
  them for every request that isn't a GET, HEAD or OPTIONS;
- each request magpie sent upstream for the call: method, address,
  headers, and the answer's status, protocol, headers and time, or the
  error. rpmTransport (under s.client) records it as it is sent;
  provider.SendsThroughPlugin records a plugin account's hand-off, shown
  as handed to the plugin, since the plugin's own request to its vendor
  is made in Bun and magpie doesn't see it (the view says so). The first
  8 tries are kept, the rest counted.
Recording copies each header map; nothing is masked or sorted as a
request goes. Secrets are taken out when the headers are read
(Call.Headers): by what each header is (new redact.SecretHeader, now
behind redact.ScrubHeader: Authorization, cookies, x-api-key, api-key,
any *-Key, *-Token, *-Secret, *-Auth, *-Signature, but Idempotency-Key
and a count of tokens such as anthropic-ratelimit-tokens-remaining),
any Bearer or Basic value, and redact.Scrub on the rest; an address
loses its password, a secret-named query value (?key=) and its fragment.
They live with the call in the 40-call ring; /api/gateway/call gives
them as "headers". The request archive keeps the upstream ones as
"upstream" beside the request's and response's headers, masked the same
way. No body is stored that wasn't before.

GUI: under a recent call's bodies on Gateway and a request's on Routing,
"HTTP headers" folds open the client's headers, then each upstream
request beside its answer (wireHeadersView, plugins/usage/page.js); the
archive's copy shows its upstream requests too. Strings in all four
languages. docs/subsystems/gui-shell.md describes it.

Also changed by SecretHeader: the request archive no longer masks a
rate-limit count header (…-tokens-remaining), which the old name rule
took for a token. (provider.SecretHeader, which backups use, is another
function and unchanged.)

Tests: TestRecentCallHeadersBothWays (a fake vendor; the client's key and
cookie, magpie's upstream key and the vendor's Set-Cookie all masked;
status, protocol and response headers kept), TestRecentCallHeadersEachTry
(a 429 then the next key, both kept in order), TestPluginHandOffHeaders,
TestScrubURL, TestSecretHeaderRealNames (real header names both ways),
TestArchiveOnThisComputer and TestRecentCallBodiesOnDemand extended,
call-headers.test.cjs (Gateway, Routing and the archive's copy; chromium
and webkit; en at 1100px, zh, zh-TW, ja, de at 380px and Routing at 440;
nothing out of the box, no left-border accent).

Run (on mote, macOS 27.2, through mote-run, unless named):
- Full suite at ebd22b1b4 (the same change on 5daba8337): gofmt -l
  empty, GOOS=windows go vet ./... ok, GOOS=linux go vet -tags nogui
  ./... ok, go test -count=1 -timeout 45m ./...: every package ok but
  four tests, none in this change's code, each filed:
  TestEveryRouteHasACommandOrIsNamed (internal/cli,
  /api/usage/checkin-account from e87140242, #4826),
  TestCodexPoolSaysTheClientsVersion (#4807: another test's Codex
  identity, passes alone, 3 of 3 here), TestMainWindowCorners/macOS_26_SDK
  (#3949, macOS 27), TestClosingWindowMarksPageOutOfSight (passes
  alone; filed #4924).
- Rebased on a3768cdd1 (it changed internal/gateway, routing/client.js
  and i18n.js): gofmt, go vet, Linux (nogui) and Windows vet of
  internal/... ok; go test of internal/gateway, gui, redact, provider:
  ok but TestCodexPoolSaysTheClientsVersion (#4807, ok 3 of 3 alone
  with this change's gateway tests) and TestMainWindowCorners (#3949);
  TestCoreScriptBudget ok. GUI: call-headers, routing-bodies,
  recent-call-bodies, request-archive and i18n-keys, 58 of 58.
- Rebased again on 2c90922b0 (app.js and internal/provider, no file of
  this change): TestCoreScriptBudget and TestRecentCall* ok;
  i18n-keys plus call-headers 24 of 24 three times out of four at load
  ~130 on mote. The first try had 1 red of 24 whose name was lost
  (its output was grepped, not kept); it did not come back in 3 runs.
- At the pushed head, rebased on 898c314b7, then 3e61d814e and 8d4d8b2d5 (gateway search, redact; vet, internal/redact and the header tests again ok) (app.css, app.js, i18n.js,
  gui-shell.md and internal/gateway changed): gofmt, vet of gateway and
  gui ok; TestCoreScriptBudget, TestRecentCall*, TestRouteCall,
  TestPluginHandOffHeaders, TestArchiveOnThisComputer, TestScrubURL ok;
  i18n-keys, call-headers, routing-bodies, recent-call-bodies 54 of 54.
- call-headers.test.cjs 20 of 20 (chromium and webkit; en at 1100, zh,
  zh-TW, ja, de at 380; Routing at 440), screenshots looked over.
- GUI: not the whole suite. mote had three other sessions' full GUI
  suites running and the Linux box one, so 131 files the change can
  reach (gateway*, routing bodies/log/steady/story/time, recent*,
  call-*, request-archive, masking*, usage*, i18n*, gui-*, account-eye)
  ran on the Windows box: 1739 of 1862. Every red file was run again at
  5daba8337 on the same box: routing-bodies, gateway-card,
  gateway-systemone, masking-demo, usage-ledger's Requests and the rest
  are red there too (Windows WebKit and Windows-only), and account-eye,
  routing-log-icons, usage-ledger-leave and -probe pass alone at this
  change. call-headers' 4 webkit Routing reds on Windows are
  routing-bodies' own (".rt-day" never visible in Windows WebKit).

Broken by hand, each then put back:
- ScrubHeader back on the name rule: TestSecretHeaderRealNames red
  ("a count of tokens: [REDACTED]").
- rpm.go's upstreamBegins taken out: TestRecentCallHeadersBothWays,
  TestRecentCallHeadersEachTry, TestArchiveOnThisComputer and
  TestRecentCallBodiesOnDemand red.
- scrubHeaders off the sent headers: TestPluginHandOffHeaders red with
  the plugin's key shown.
- Gateway client.js's toggle taken out: the 5 chromium recent-call GUI
  tests red.

Not tried:
- The whole GUI suite (above), and the GUI on Linux.
- A real account or the real app: only fakes.
- What a plugin sends its vendor (made in Bun, not seen by magpie; the
  view says so), and headers Go's transport adds itself
  (Accept-Encoding, Content-Length).
- magpie's own requests (System One's decision, titles, search) keep no
  headers; a gateway served by another magpie shows none.

Asked by usrname1833 on Discord.
2026-11-03 02:25:23 +08:00
yetone d5dc8eeccc gui: Scroll to top and Scroll to bottom on a long page (emo172)
#1090 (emo172) asked for back-to-top and back-to-bottom buttons on the
main pages. Once a page is scrolled more than one window down, a small
capsule with two buttons, Scroll to top and Scroll to bottom, fades in.
It sits in the page's right margin when a wide window leaves one, and
otherwise over the page's corner, above Providers' sticky Add buttons.
It stays hidden near the top of the page, while a dialog is open, and
(over the corner) at the page's foot, where the last row can't scroll
out from under it, unless it has the pointer or keyboard focus. The
page's own height never changes for it, because app.js's scroll guard
measures that height.

A press goes through scrollOnPurpose, so the window's scroll guard
takes it as the reader's own scroll. It scrolls smoothly, or at once
under reduced motion, and the button at the end it already reached is
aria-disabled. Both buttons are real buttons, reachable by Tab, with a
label and tooltip in en, zh, zh-TW, ja and de. They are drawn from the
window's tokens in both themes, with no gradient and no coloured edge.

scrollends.js is imported on the window's first scroll, so the core
scripts carry one line in app.js, paid for by two comments cut from
the scroll guard's. No budget was raised. old-webkit lists scrollends.js among the lazy scripts.
docs/subsystems/gui-shell.md says where the capsule sits and when it
shows.

Run on mote at this head (on 2c90922b0, with the next commit):
- view-ends.test.cjs, 32 of 32: Chromium and WebKit, light and dark,
  420 and 1180 wide, every language. It checks that the capsule shows
  only past one window, that Scroll to bottom reaches the foot and stays
  there, and that the page is never taller under the capsule. It checks
  that the capsule is beside every row, or steps aside at the foot, and
  that Tab plus Enter on Scroll to top reaches 0 and stays.
- click-scroll, i18n-keys and old-webkit: ok.
- go test -run Budget ./internal/gui, gofmt -l, and go vet with
  GOOS=linux -tags nogui and with GOOS=windows: ok.
- The whole GUI suite at the pre-rebase head (5f0a84a00 + this):
  18,675 tests, 18,370 pass, 305 fail in 51 files. All 51 files were run
  again at 5f0a84a00 without this change, and 48 were red there too
  (297 fails).
  - The other three, import-row, provider-detect-models and
    routing-many-keys, and every test red at the head but not at the
    base, were run again alone at the head. They passed, or failed in a
    different engine or language than the first run, in the same tests
    that were red at the base. These are known load reds: #4389, #3488,
    #4585, #3415, #4127, #4126, #4244, #4082, #4619, #4431 and #4035.
  - old-webkit's red ("profilerename.js is not loaded by index.html")
    is on main since 1cb4d4301 and is fixed in the next commit.
- go test ./internal/gui: red only at TestMainWindowCorners on mote's
  macOS 27 (#3949), the same as on main.

Broken by hand:
- At the old code, view-ends is red: the capsule's ::after room made the
  page taller ("the page grew under the capsule"). That room had also
  turned add-button, library-discover-jump and account-eye red in the
  whole suite, which is why the capsule steps aside instead.
- Without the step-aside at the foot, view-ends is red.
- Without the import hook in app.js, every case is red.
- Without scrollOnPurpose, "the page stays at its foot" is red, because
  the guard puts the scroll back.

Not tried: the real Wails app on macOS, Windows and Linux (WebKitGTK),
and the tray panel, which has no long page to show it on.
2026-11-03 02:14:32 +08:00
yetone 18c69aa467 gui: Windows reads the screens with one callback, not one per display change (1111_13879)
1111_13879 on Discord: on Windows the app died after a few hours with
"fatal error: too many callback functions", taking the gateway with it
(clients got connection refused). Five dumps all ended in
w32.GetAllScreens -> syscall.NewCallback -> runtime.compileCallback,
from Wails' WM_DISPLAYCHANGE handling.

Wails (v3.0.0-beta.24 here; v3.1.0 and v3.2.0-nightly.20261101 are the
same) reads the screens again on every WM_DISPLAYCHANGE, and on
WM_SETTINGCHANGE for SPI_SETWORKAREA, through w32.GetAllScreens, which
passes a fresh closure to syscall.NewCallback each call. Go never frees
a callback and throws past about 2000, unrecoverably.

magpie now sets WndProcInterceptor (screensWndProc): on Wails' hidden
main-thread window ("__wails_hidden_mainthread") it takes those two
messages before Wails does, enumerates the monitors with one callback
made once at package level (allScreens), builds the screens exactly as
Wails' processAndCacheScreens does (wailsScreen) and hands them to
Screen.LayoutScreens, then answers as Wails would (DefWindowProc for
WM_DISPLAYCHANGE, 0 for WM_SETTINGCHANGE). Other windows and messages go
on to Wails. Wails' one read at start-up is the only per-call callback
left. No go.mod change: no newer Wails fixes it, and magpie has no fork.

Other per-call NewCallbacks in Wails' Windows code: w32.EnumChildWindows
and w32.SetWindowsHookEx, neither called by Wails or magpie. WndProc
classes are registered once; the WebView2 COM vtables are package-level.
magpie's own (internal/agent apprestart) is already made once.

Run at this tree (base e156fdd03; origin/main since adds only
2251ca1ce, providers, no shared file):
- Windows (win-run, xiaomi-gpu): the three new tests pass;
  TestScreensReadFarPastTheCallbackLimit reads 5000 times and matches
  Wails' own read field for field. go test ./internal/gui: 5 reds,
  TestGatewayHeldByAContainer, TestLodyImportHandoff,
  TestImportStatusUnreadableIsUnknown, TestAionUiImportRow,
  TestUpdateThatWontStart, the same 5 at e156fdd03 without this change
  (#4115, #2107). internal/proc, agentenv, pluginrt ok; sqlitedb's
  TestSQLiteSurvivesMalformedEnv red, the same at the base (#4115).
- mote: gofmt -l clean; go vet ./internal/gui ./internal/cli .;
  GOOS=windows go vet ./...; GOOS=linux go vet -tags nogui ./...;
  go build, GOOS=windows go build, GOOS=linux go build -tags nogui;
  go test ./internal/gui: ok but TestMainWindowCorners (#3949, macOS 27).
- Linux (wsl-run): go test -tags nogui ./... was still running at push (the nogui build leaves these files out), so it had no result to record here.

Broken by hand:
- allScreens with a NewCallback per call (as Wails does):
  TestScreensReadFarPastTheCallbackLimit dies with the reporter's
  "fatal error: too many callback functions" from
  syscall.compileCallback.
- A throwaway test calling Wails' w32.GetAllScreens 5000 times dies the
  same way at w32/screen.go:145.
- WndProcInterceptor left out of windowsOptions:
  TestAppReadsDisplayChangesItself fails.
- wailsMainThread misspelt: TestWailsScreensAreReadOnTheMainThreadWindow
  fails.

Not tried: the real app through real display changes on a desktop
session (win-run has no interactive desktop; the test creates a window
titled as Wails' own and sends it the messages); a multi-monitor or
rotated-display layout (the box has one screen). No upstream Wails issue
filed yet; text drafted.
2026-11-02 20:00:54 +08:00
yetone ed978e560f gui: the Quit question's Don't ask again, and Settings › General › Ask before quitting (zhujiu on Discord)
zhujiu (Discord #feedback) asked for a 不再提示 on the question a tray
Quit asks while agents go through magpie (8826a15ea), and a switch in
Settings to turn it on and off again.

- The question (quitask.js, an in-app sheet) has a "Don't ask again"
  checkbox above its buttons, unticked each time. It goes with the Quit
  chosen: Quit and Disconnect and quit post window/quit?now=1&noAsk=1,
  which saves settings.quitNoAsk (settings.SetQuitNoAsk, under the file
  lock) before quitting; a failed save keeps magpie open. Cancel saves
  nothing.
- AskQuit quits at once when quitNoAsk is set (quitAtOnce); otherwise as
  before. The default is unchanged: it asks.
- Settings › General has "Ask before quitting" On/Off (segs, app-only),
  after Open at login. settingsapi.Keys lists quitNoAsk, and Merge carries
  it when a save doesn't send it, so the tray panel or an older page
  can't turn the question back on.
- zh, zh-TW, ja, de strings. Five app.js comments shortened to stay in
  the core script budget (no raise).

Run at the pushed head (on origin/main f95bacdfb), on mote:
- gofmt clean; go vet darwin, linux, windows (nogui too).
- go test internal/settings, internal/settingsapi ok; internal/gui
  -run "Budget|Quit" ok.
- internal/cli: TestEveryRouteHasACommandOrIsNamed red for
  POST /api/usage/checkin-account, from e87140242, filed as #4826; this
  change adds no route.
- GUI, chromium and webkit: quit-ask-setting (25: en, zh, zh-TW, ja, de
  at 1100 and 420), quit-ask (35), settings-general, settings-sections,
  settings-search, settings-tabs-stick, wsl-agents-setting, agent-prefs,
  i18n-keys, old-webkit, auto-backup, all pass.

Broken by hand, each red:
- api.go's noAsk ignored: TestQuitDontAskAgain "wasn't saved".
- quitAtOnce not reading the setting: TestQuitDontAskAgain "still asks".
- Merge carry dropped: TestQuitNoAskKeptUnlessSent.
- SetQuitNoAsk saving false: TestSetQuitNoAsk.
- quitask.js without &noAsk=1: quit-ask's two Don't ask again tests.

Not tried: a real tray Quit with the box ticked in the built app on
macOS, Windows or Linux; only the sheet in Playwright and the handler
in Go. Not the whole GUI suite.
2026-11-02 18:53:07 +08:00
yetone 70b96126ef gui: a provider's editor grows with a large window (5046312 on Discord)
5046312 on Discord: in a large, wide window the provider editor (Codex's,
with its accounts, meters, cap pill, switches and many option rows) stayed
a 600px box in the middle, cramped, and asked for a better layout or a
resizable sheet.

drawEditor's editor now carries `roomy`, and openModal copies it onto
#modal's dialog as it already did `wide`. `.modal .dialog.roomy` is
min(max(600px, 56vw), 880px, 100%): 600 up to a 1071px window, then 56%
of it, at most 880, as a Mac sheet takes the room its content needs. Its
height already follows the content up to the window, so no new height
rule. A question that takes the editor's place in the same dialog (Sign
out's forget-ask, Disconnect, ...) drops the class and stays 600. No
drag handle. The rows themselves are unchanged. Every provider editor
(subscriptions, keys, new providers, presets) goes through drawEditor.
The core-script budget is not raised (7 bytes under).

Sizes (chromium, en; width x height of the dialog):
  window       before        after
  2560x1440    600 x 1228    880 x 1038.5
  1440x900     600 x 810     806.4 x 810
  1100x800     600           616
  1024x768     600           600
  560x420      512           512
  390 web      374           374

Run at the pushed tree (this commit on 019b308f1; the whole-suite runs below at earlier bases, editor-roomy, i18n-keys and the budget tests again at 019b308f1):
- editor-roomy.test.cjs (new), chromium and webkit, en zh zh-TW ja de, at
  2560, 1440, 1100, 1024, 800, 560 and 390 (magpie web): the width, the
  dialog in the window, head and buttons in sight, no sideways scroll,
  nothing past its sides; and at 2560 Sign out's question is 600 and the
  editor is 880 again after Cancel. 80/80 on mote and on WSL.
- go test -tags nogui ./internal/gui on mote (TestCoreScriptBudget): ok.
- The whole GUI suite on WSL magpie-desktop (Linux, both engines) at
  ed852df10 (the same change on 838d12d6f): 18363 tests, 17874 pass, 489
  red in 100 files. The 100 files again alone at head and at origin/main
  b2f7818d2: 472 and 452 red, the same tests save flakes that change
  language between runs. editor-advanced-align, gateway-key-models,
  codex-predictions and codex-credits-first, one at a time: identical
  reds on both. Named issues: #4471 (WSL whole-suite reds, the class),
  #4203 agent-panel-name-width, #4683 balance-fix, #4908
  codex-credits-first, #2624 codex-predictions, #4616 gateway-key-models,
  #4541 page-width-steady, #3699 allow-ips.

Broken by hand: the test on origin/main's assets fails 40 of 80 (every
size from 1100 up, "dialog is 880px wide...: 600"), the narrow ones pass;
with openModal's toggle made add-only, the Sign out case fails 10/10
("the question is 600px wide").

Not tried: the real Wails app on macOS, Windows and Linux (WebKitGTK);
the whole GUI suite on mote (another session's full suite held it);
other dialogs, left at 600 on purpose.
2026-11-02 18:21:14 +08:00
yetone f9595e7684 gateway: System One requests are kept in the request archive, and Routing says when the archive is on (wangb on Discord)
wangb on Discord: 「请求存档开启, 但是 systemone 的请求没有记录下来」. The
Routing page then said "magpie 只保留最近 40 个请求的请求体和响应体… 要保留
每个请求的,请在「用量 › 请求」顶部打开「请求存档」", as if the archive
were off.

Why: only serve() made an archive wire (archiving). The two System One
paths never reached it:
- /v1/systemone, which an app sends (serveDecideTries, also used for a
  decision group), opened a Route but recorded no Call. It was in
  neither Recent calls nor the archive, so the Routing page could never
  open its bodies.
- the question a routing group's Jev classifier asks for a turn
  (askJev / jevLevelled -> systemOne -> postDecide) only appended a
  usage row.

What changed:
- serveDecideTries captures its reply, makes the wire as serve does,
  names it on the Route from the start (Route.Archive), and records a
  Call (Route, status, error, fallbacks, usage, bodies) when it ends.
  So the call is in Recent calls and, with the archive on, in the
  archive. Its usage row carries Archive.
- systemOne keeps the call magpie made itself through a new
  archiveOwn. It keeps the request as it went (method, path, the headers
  magpie signed it with, the body in the provider's shape) and the
  answer, with secrets scrubbed as for any call. Its "routing" usage
  row names the archive entry. postDecide became postDecideSent, which
  also returns the request it sent. archive's queueing moved into
  queueArchive, which both share. archiveID makes the name.
- Routing's "Request and response" for a request in neither the ring
  nor the archive: with the archive on (gateway.archive.on in
  /api/providers) it says the archive is on and this request isn't in
  it (made while it was off, or not saved). It no longer says to turn
  the archive on. New string in zh, zh-TW, ja and de.
- docs/subsystems/gui-shell.md says which calls are archived and which
  still aren't.

Still not archived (unchanged): Codex's own backend (codexUpstreamOn),
draw, embeddings and video side routes, and replies magpie writes
itself (answeredHere). Masking makes no outgoing call. Chat classifiers
and Codex titles to a model already go through serve and are archived.

Run on mote at base 4b407bb79, then rebased onto 0285f572f, whose one
commit changes only internal/gui/whatsnew*.go (nothing here reads it):
- TestArchiveKeepsSystemOne and TestArchiveKeepsJevClassifier (new)
  pass. Broken by hand: with archiving(...) taken out of
  serveDecideTries, the first is red ("uploaded []"). With archiveOwn
  returning at once, the second is red (only the chat turn uploaded).
- routing-bodies.test.cjs, chromium and webkit, every language, 440px:
  the new "archive on" case passes, and the archive-off case asserts
  the old text. Against the old client.js the new case is red in all 5
  languages (chromium). i18n-keys passes.
- gofmt -l clean. go vet ./... (darwin) and GOOS=windows go vet
  ./internal/gateway ./internal/gui are clean. GOOS=linux go vet
  -tags nogui is also clean for both (without nogui, wails' linux cgo
  doesn't build in a cross vet).
- go test ./internal/gateway: ok except TestCodexPoolSaysTheClientsVersion
  (#4807: red in a whole package run on mote, passes alone).
- go test ./internal/gui (an earlier base, 834c6c7df): ok except
  TestMainWindowCorners (#3949, macOS 27).
- The other routing-* GUI files (an earlier base, 834c6c7df): the whole
  set was cut short when mote rebooted. Six files went red:
  routing-many-keys, order-unknown, row-swap, rule-drag, rule-remove
  and rules-line. Run alone they are red the same way at base
  834c6c7df without this change (filed: #4082, #4627, #3799, #3789,
  #3096, #4585).

Not tried: a real Jev or System One account. The tests use fake
System One servers. Not tried either: an S3 bucket (memBucket), the
local disk archive, or the GUI's whole suite.
2026-11-02 16:21:58 +08:00
yetone 1a864f156e usage: a hidden card a menu bar cell showed offers Show in Overview, not Hide again
Found while fixing yuu003348's report (dee1afa40). A card hidden from
Usage › Overview still shows when a menu bar cell asks for it (usagePeek),
and the "{n} hidden" line leaves it out while it shows. Its menu offered
only "Hide from Overview" again, so from that card there was no way back.
Now its menu has "Show in Overview" (unhides what of it is hidden) and no
Hide items. Translated in zh, zh-TW, ja, de; gui-shell.md says it.

Run (mote, node --test, chromium and webkit):
- usage-hidden-way-back (now with the peek case, every language and
  width), usage-cards-hide, usage-count-client, i18n-keys: ok.
- usage-agents-hide and tray-cell-click: red as at origin/main fdfce4d98
  (#2276/#3414, #4790), same messages.

Broken by hand: the new test on dee1afa40's page.js is 32 of 32 red,
the peek card's menu reads ['Hide from Overview'], not ['Show in Overview'].

Not tried: a real menu bar cell click in the real app.

At the pushed head (rebased on d39358f1b, both commits): usage-hidden-way-
back, usage-cards-hide, usage-count-client, i18n-keys and
claude-quota-onboarding, 100 of 100 ok.
2026-11-02 10:32:37 +08:00
yetone dee1afa400 usage: what is hidden from the Overview can be found again (yuu003348 on Discord)
yuu003348 on Discord: "观测/用量/概览 从概览中隐藏 后 无法取消隐藏". The way
back was there: a "{n} hidden" line under the cards (#quotaHid), each row with
Unhide, Show all from two. But it was drawn in --faint (#b9b9c2 on #f4f4f6,
1.77:1, 11.5px), so it couldn't be found; the Agents list's line (ikunbots on
X) is the same class.

- app.css: .us-hid .us-hidline is --muted (3:1 or more in light; ~5:1 in
  dark by the tokens), for both lines.
- plugins/usage/page.js: while any are hidden, a card's menu and an Agents
  row's menu end with "Show {n} Hidden". It opens the line under its list,
  puts the keyboard on it and brings it into sight on the menu's click
  (openHidden, scrollOnPurpose). hiddenQuotas() is the one count both the
  line and the menu read.
- i18n: "Show {n} Hidden" in zh, zh-TW, ja, de.
- docs/subsystems/gui-shell.md says both.
- usage-cards-hide / usage-agents-hide now expect the new item when
  something is hidden already.

Run (mote, node --test):
- usage-hidden-way-back.test.cjs (new): chromium and webkit, en/zh/zh-TW/ja/
  de, 1200, 560 and 390 (touch long-press): 2 of 2 ok (32 cases).
- 130 Usage/menu/tray GUI files: the only reds the change made were
  usage-cards-hide and usage-agents-hide's exact menu lists, now updated.
  Every other red there is red at origin/main fdfce4d98 too, run alone side
  by side (216 tests at base, 248 at head, the same 72 fail by name):
  balance-fix (#4683), menu-input-scroll (#3402), tray-cell-click and
  usage-fold "most on one screen" (#4790, #3415), usage-ledger "newest
  live route" (#3104, #4078), usage-agents-hide "unhiding a row leaves the
  hidden line where it was" (#2276, #3414; it fails after the menu checks).
  usage-cards-hide is ok at head.
- go test ./internal/gui: ok but TestMainWindowCorners/macOS_26_SDK (#3949).
  No Go changed, so no gofmt or vet.

Broken by hand: on the old assets the new test is red on contrast
("#quotaHid .us-hidline reads rgb(185, 185, 194) on rgb(244, 244, 246):
1.77:1"); with the new CSS and the old page.js it is red on the menu (no
"Show 1 Hidden").

Not tried: the real app or a real account; dark mode's contrast is from
the tokens, not measured in a test; Windows and Linux webviews; the whole
GUI suite (the change is a menu item and a colour, no new API call or
layout).
2026-11-02 10:29:13 +08:00
yetone e44ad72cfd gui: a failed status dot is an x, not a red dot alone
coolmantou on Discord (#feedback), who is red-green colour-weak, could
barely tell the green status dot from the red one. Under a deuteranopia
or protanopia simulation the two are one olive colour, in light and dark.
Making the green lighter would not help a greyscale or protan reader, so
the failed state now says it by shape (Apple HIG: never colour alone).

What changed
- app.css: a --x-mark token (an SVG x, used as a mask). Each failed dot
  keeps its red and its 6-7px box, is drawn through the mask and scaled
  1.5 so it reads as heavy as the round dot. Layout is unchanged.
  Dots: Test models (.tdot.bad), an agent's status (.ag-st.bad .ag-dot),
  the check-in (.ci-dot.bad), the request ledger (.led tr.bad .st .dot).
- routing.css: a try or probe (.rt-req/.rt-probe.bad .to i), a step
  (.rt-steps li.bad::before), the preview (.ps-dst.bad > i).
- library.css: a server that failed (.lib-health.err::before). A ring
  was not used because "not checked" is already a ring there (#2308).
- Not changed: green-only dots with no red pair (gateway, keys, tiles,
  live), chart markers, routing's animated packets, redact's categorical
  facet dots. The tray has no status dots of its own.
- docs/subsystems/gui-shell.md says it beside "State is shown with a dot".

Tests
- status-dot-shape.test.cjs (new): for all 9 pairs with the real
  stylesheets, in chromium and webkit, light and dark, 980 and 420 wide:
  the good dot has no mask, the failed one has the x mask and the good
  one's box, and its pixels have ink on the arms and centre and none
  above the centre.
- library-mcp-health.test.cjs: its "a dot, not a stripe" check now
  expects the x for a failed server and a round dot for the rest.

Run at the pushed head (mote, via mote-run)
- status-dot-shape + library-mcp-health: 16 pass, 0 fail (chromium and
  webkit).
- go test -run 'Asset|CSS|Budget|Compress|Revalidate' ./internal/gui: ok.
- At 377e3ca6e + this change (rebase since added only site/ files):
  the 232 GUI files that touch these dots, Test models, Routing, Library,
  check-in or the ledger, in both engines and every language they run:
  3588 tests, 3526 pass, 62 fail. library-mcp-health (2) was this
  change's and is fixed above. The other reds (import-row, models-works-only,
  provider-typed, rest-try-now, routing-order-unknown, routing-row-swap,
  routing-steady) fail the same on a clean origin/main 377e3ca6e copy and
  are filed: #4619, #4391, #4673, #2564/#4127, #4627, #3799/#4585, #3412.
- go test ./internal/gui: TestMainWindowCorners/macOS_26_SDK red on mote's
  macOS 27, #3949; nothing else.

Broken by hand
- The three stylesheets put back to main's: status-dot-shape 10 of 10 red
  ("the failed dot is drawn through the x").
- The x token swapped for a filled circle: red ("the failed dot isn't a
  round dot").

Checked by eye: screenshots of every pair and of the real Usage ledger,
before and after, normal, deuteranopia, protanopia and greyscale
(Machado 2009 feColorMatrix), light and dark. Before, the pair is one
colour in both simulations; after, dot vs x in all of them.

Not tried: the real app in Linux WebKitGTK, Windows WebView2 and
Omarchy's square-corner theme (the mask doesn't depend on border-radius,
so it should hold there); the Playwright engines only.
2026-11-02 07:41:23 +08:00
yetoneand胡峻果 89ffc58f5b gui: a card's Refresh says the read's failure, and Claude Code's first-run screens say what to do (#4817, uiuing)
From uiuing's branch (1eeb8928b, 66818dbf6), adapted. A usage card's
Refresh showed nothing when the read came back as a card with an
error: only a thrown request reached status. quotaRefresh now says the
refreshed card's error through quotaError, for a single account and
for a provider whose cards were replaced (the one kept in quotas).
quotaError reads the helper's new "stays on its first-run screens" and
an older magpie's "shows its first-run notes" as "Finish Claude Code's
first-run setup, then refresh", in en, zh, zh-TW, ja and de. Comments in
quotaError and quotaRefresh were cut so the core scripts stay in their
budget (1,533,732 of 1,533,802; main was at 1,533,780), with no raise.

Run at the pushed head, on mote: node --test of claude-quota-onboarding,
quota-refresh-order, usage-card-refresh, usage-refresh,
usage-refresh-flight, account-refresh, editor-quota-quiet,
usage-no-reading, usage-remote-cards, tray-usages, glm-quota-error,
claude-usage-asked, allowance-open-read, api-key-usage,
key-balance-card, copilot-signed-out-account, signin-again, plugin-git
and i18n-keys (chromium and webkit, every language each file runs, 440px
where it sets it): 287 of 287.
go test -run 'Budget|I18n|Lang' ./internal/gui ok.
go test -run "Claude|TUI" ./internal/gateway ok. The full
./internal/gateway (-timeout 45m, before the rebase onto 6b3a6d42c) is ok but for
TestCodexPoolSaysTheClientsVersion, #4807 (another test's Codex
identity reaches it in a full run); nothing Claude or GUI.

Broken by hand: without the new status line, 13 of the 31 tests in
claude-quota-onboarding and quota-refresh-order go red (all ten
engine/language cases and three VM ones).

Not tried: the real app's card against a real signed-in Claude Code
that stays on its notes.

Co-authored-by: 胡峻果 <uiuing@foxmail.com>
2026-11-02 04:19:23 +08:00
yetone 16ce5ed232 usage: an account whose longer window is used up adds no headroom to the all-accounts sum (#4791)
hayden4608 (Discord) and handong66 (#4791) have four Codex accounts. Three
show 5 hours 100% left with 7 days 0% left, and one shows 5 hours 0% left
with 7 days 22% left. The All accounts strip read "5 hours 75% left", but
none of those three can spend its 5 hours until its week starts again.
The right figure is 0%.

mergeQuotas (quotaall.js) is the one place that sums windows across
accounts. It feeds the Usage page's strip, the tray panel's strip and the
Routing groups' line. The native menu-bar tray, the TUI, the CLI and
/v1/magpie/quotas show one account at a time and are unchanged. The GUI's
JSON doesn't carry Aside, Model or the matches, so the call is made in Go.
provider.WithHeldWindows marks a window heldBy another window of the same
account when that other window:
- stops the account for every model, by routing's rule: not aside, no
  model, no matches, used >= 100, reset not passed, and not Codex credits
  that go on; and
- starts again after this one (by reset times, else by span).
So 7 days used up holds 5 hours, but 5 hours used up doesn't hold a week
with 22% left. /api/usage/quotas and its refresh apply it. mergeQuotas
counts a held share window as 100 used and a held counted one as its
limit, and the strip's tooltip says how many were counted that way
(en/zh/zh-TW/ja/de). The account cards still show the vendor's own figure.

Run on mote (macOS) at this head's parent tree:
- go vet for darwin, linux (nogui) and windows: ok; gofmt -l: none.
- go test -count=1 ./internal/provider ./internal/gui, before the
  quota_span leftOut line and an i18n comment fix. The provider package's
  only red was TestQuotaSpanCarriesEveryWindowField, which wanted heldBy
  named, and it is now named. internal/gui's only red was
  TestMainWindowCorners/macOS_26_SDK, which is #3949.
- GUI, chromium and webkit, every language, 440px and 360px: quota-*,
  usage-* (all-accounts, merge, accounts, fold, refresh and more),
  panel-usage/quota/switch-accounts/balance-order, routing-quota-left,
  routing-group, tray-usage, i18n-keys, gui-de/ja/zh-tw, old-webkit:
  704 of 707. The reds were i18n-keys (a quoted "All accounts" in
  window_held.go's comment, fixed here) and usage-fold's "17
  subscriptions and 29 accounts" in both engines, which is #4790 and is
  red at origin/main too (see below).
At the pushed head, rebased on eb3b9376e, on mote: gofmt none, vet ok.
internal/provider ok. internal/gui is red only on TestMainWindowCorners
(#3949). GUI usage-merge, usage-all-accounts, i18n-keys and usage-fold,
both engines: 44 of 46. The 2 reds are usage-fold's 29 accounts, which
fail the same at origin/main eb3b9376e on mote (noted on #4790).

Broken by hand, each red, then restored (cmp):
- Go, no HeldBy set: both TestHeldWindows tests red (a, b, c not held).
- Go, outlasts always true: red on d and on "a week that starts again
  first".
- JS, held forced false: usage-merge plus all 5 languages of
  usage-all-accounts red in chromium, showing the reporter's
  "5 hours · 75% left".

Not tried: real accounts. The issue names no provider; Codex is assumed
from the cards' 5 hours / 7 days. Not done: marking a card as held by its
week, the reporter's optional second ask. Not written: a handler-level
test that /api/usage/quotas carries heldBy. Not run on Linux or Windows.
2026-11-02 03:46:01 +08:00
yetone da275848b6 tray: Windows shows a card's number in its icon (Benjaminliang_1 on X)
Windows' notification area shows no text beside an icon, so with a card
in the tray the icon itself is now the first card's figure: the first
row of the first card whose first row is a percentage, used or left as
Allowance display has it, its digits alone (trayIconFigure). It is drawn
in Segoe UI Semibold (Go's bold if the font can't be read) at
SM_CXSMICON, white on a dark taskbar, near black on a light one, as tall
as fits, centred by its ink, three digits narrowed into the square
(trayNumberIcon). It is drawn again when the figure, the icon size or
the taskbar theme changes (SystemThemeChanged wakes the loop); the
tooltip still lists every card. A balance or magpie's totals are
skipped; with no such card, or no cards at all, the icon is the bird as
before. Settings > Usage > Tray icon number (settings.TrayNoNumber,
Windows only, on by default, kept per computer) keeps the bird when off;
Menu bar windows is now shown on Windows too, since it picks the row
the number comes from. The number row sits after Menu bar cost, so the
bird > pace > cost order the other tests pin holds. Linux and the Mac
are unchanged. New words in zh, zh-TW, ja and de. app.js stays in the
core budget with one comment shortened, no raise.

Run at this commit on origin/main ec104b862 (traywindows.js merged with
94f6f6092's trayExtra pills; its "not on Windows" note dropped), mote:
gofmt -l empty; go vet and GOOS=windows go vet of gui and settings ok;
go test -count=1 -timeout 45m ./internal/settings ./internal/davsync
ok; ./internal/gui red only on TestMainWindowCorners (#3949),
TestCoreScriptBudget ok. GUI tray-windows, tray-cost, quota-pace,
i18n-keys, tray-bird, tray-logos, tray-usages, quit-ask: 140 pass,
0 fail. win-run on xiaomi-gpu: TestTrayNumberIcon and
TestTrayIconFigure ok. At c0477aa72 the same GUI set once had
quota-pace webkit "On moved the page" (439 !== 120), a late wheel
(#4784); green twice after, and quota-pace alone 3 of 3 green there
and on c0477aa72 itself.

Run before on the same change over origin/main 9d08993c8, mote:
- gofmt -l on gui/settings/davsync: empty; go vet ./internal/gui
  ./internal/settings and GOOS=windows go vet: ok.
- go test -count=1 -timeout 45m ./internal/gui ./internal/settings
  ./internal/davsync: settings ok, davsync ok; gui red only on
  TestMainWindowCorners/macOS_26_SDK (#3949) and TestCoreScriptBudget
  (5 bytes over after the rebase), which is green after the comment
  trim, rerun with TestTrayNumberIcon and TestTrayIconFigure: ok.
- GUI (both engines): tray-windows, tray-cost, quota-pace: 56 pass,
  0 fail. Earlier at this tree: tray-bird, tray-logos, tray-usages,
  i18n-keys green; quota-pace webkit de 420 red once, from a late wheel
  scroll (#4784), green on the rerun; segs-press-redraw red on
  searchAllRow, the same on a clean origin/main 9d08993c8 copy (#4566).
- A 184-file GUI run (the files touching Settings, the tray or i18n,
  before the rebase) under mote load 40-90: 3095 pass, 224 fail. My
  files' reds there (tray-cost: the number row was between pace and
  cost) are fixed above. The rest are in files this change doesn't
  reach (account-alias, model chips, menu-input-scroll, mobile-web,
  omarchy, plugin-github, key-replace, context-map and others; #4600
  lists several). Each was not compared on main one by one.
Windows (win-run on xiaomi-gpu, real Segoe UI): TestTrayNumberIcon and
TestTrayIconFigure ok.
Real Windows 11 run: a production build in a portable sandbox (own
data\, USERPROFILE/APPDATA/LOCALAPPDATA redirected, gateway on a free
port, a fake remote magpie serving one Claude card). The dark taskbar
showed a white "42", then a narrowed "100" when the card read 100%,
and the bird with trayNoNumber set. Only my processes, tasks and
NotifyIconSettings entry were removed afterwards.

Broken by hand: trayIconFigure always "" turns TestTrayIconFigure red
(6 cases); the dark and light colours swapped turn TestTrayNumberIcon
red; the old advance-width centring turns it red too.

Not tried: a light taskbar on the real box (it would change the user's
theme; covered by the test only), hovering the tooltip (screen locked),
other DPIs on real hardware, Windows on ARM64. Linux's code is
unchanged and was not run.
2026-11-01 21:31:55 +08:00
yetone 8826a15ea4 gui: a Quit while agents go through magpie asks first, naming them (Aisiverto on X)
Aisiverto on X (Windows, v0.1.2519) wired Codex to magpie and quit magpie.
Codex then retried "unexpected status 502 Bad Gateway ... url:
http://127.0.0.1:3425/backend-api/codex/responses" five times and gave up,
and it took a long search to find magpie's openai_base_url in config.toml.

A Quit the user chooses (the tray's Quit, the panel's and window's Quit,
Command-Q on the Mac) now asks first when this process serves the gateway
and agents are wired to it. The window comes up on a sheet
(quitask.js, lazy-loaded) that names each agent cut off, says closing the
window keeps magpie running (menu bar on a Mac, system tray elsewhere),
and offers Quit (focused), Disconnect and quit, and Cancel. Disconnect and
quit puts each agent back as its row's Disconnect does, then quits; a
disconnect that fails keeps magpie open, named in the status line. A
second Quit within a minute of the question quits, so a window that
can't show it traps nobody. With nothing wired, or another magpie serving
the gateway, Quit quits at once.

Not asked: a restart to update, Uninstall, a browser's page (magpie web),
logging out or shutting down, and the Dock's Quit (AppKit terminate:).

Found while checking the report:
- Closing the window on Windows hides it; magpie stays in the tray and
  the gateway keeps serving (tried for real, below). Not a bug.
- Autostart is off by default on Windows.
- The proxy / NO_PROXY in the report isn't magpie's to fix: the 502 is
  magpie's port with nothing behind it.

Strings in en, zh, zh-TW, ja and de (existing terms: Agent, 退出). No
native dialog, no <select>. TestCoreScriptBudget met without a raise:
app.js gains two lines, the sheet is outside the core, and driftFix's
comment block is cut to six lines (453 bytes back; main's core had grown
to 258 bytes over with these lines in).

Run, at this head (on origin/main 94f6f6092), on mote unless said:
- gofmt -l internal/gui: clean.
- go vet ./..., GOOS=windows go vet ./..., GOOS=linux go vet -tags
  nogui ./..., go build, GOOS=linux go build -tags nogui, GOOS=windows
  go build: ok.
- go test ./internal/gui -run 'Budget|Quit|CommandQ', and with -tags
  nogui -run 'Budget|Quit': ok (TestCommandQAsksFirst runs AppKit in a
  child process).
- quit-ask.test.cjs, old-webkit.test.cjs, i18n-keys.test.cjs in chromium
  and webkit, en/zh/zh-TW/ja/de: 60/60 ok.
- At the previous base (9d08993c8): go test ./internal/gui (whole
  package, GUI build): two reds. TestCoreScriptBudget (258 over, fixed
  above) and TestMainWindowCorners/macOS_26_SDK, red the same at
  9d08993c8 itself (#3949, macOS 27). The nogui run of the package was
  not reached.
- The whole GUI suite: started at 24fd4a250 on WSL (magpie-desktop),
  stopped about halfway (3,915 results) to rebase; 68 reds in 28 files.
  Those 28 files with quit-ask, old-webkit and i18n-keys at 9d08993c8+this
  on mote: 74 reds in 7 files, none in this change's files. The 7 alone
  at origin/main 9d08993c8: the same 6 files red (73), and
  gateway-caller-keys red at main when run alone (1 of 4). All filed:
  balance-fix #4682 #4683, key-replace #4126 #3476, agent-panel-name-width
  #4203 (red on macOS too, commented), context-map #3488, header-centre
  #3479, gateway-key-models #4616, gateway-caller-keys #3797.
- Not run: go test ./... in full (mote at load 140-160 with others' full
  suites, WSL with two GUI suites), and the GUI suite to its end.

Broken by hand, each red:
- api.go's ask skipped (false &&): TestWindowQuitAsksFirst "the window's
  Quit didn't ask (AskQuit never ran)".
- askingQuit without RemoveMenuItem: TestCommandQAsksFirst "the app menu
  still has the Quit role".
- quitNow as asked == 0 ||: TestQuitNow "connected, never asked: quitNow
  = true, want false".
- The return after a failed disconnect removed: quit-ask 5/25 chromium
  red (the failed-disconnect test in every language).
- app.js's ?ask=quit line removed: 20/25 webkit red.

Windows, for real (xiaomi-gpu, sandbox HOME/APPDATA under
C:\Users\yeton\quitask-sb, MAGPIE_ADDR 127.0.0.1:3471, MAGPIE_NO_ACCOUNTS,
a -H windowsgui build of this branch, launched in the desktop session):
`magpie codex fakeq/m1` wired the sandbox Codex to
http://127.0.0.1:3471/backend-api/codex; WM_CLOSE on the window left
the process alive with no visible window and the gateway listening.

Not tried:
- The tray's Quit and the sheet on real Windows: WebView2's CDP port
  never listened and UI Automation didn't find the tray icon, so the
  sheet was tried in Playwright only.
- A real Codex run against the sandbox gateway before and after a quit.
- The Dock's Quit (not covered by design).
2026-11-01 21:16:35 +08:00
yetone 57246b3818 usage: a provider's accounts together, and a routing group's (CryptoSarom on X)
CryptoSarom on X (tweet 2116797183207035245, the tray panel's Usage tab):
"能否支持合并用量和额度显示? 有时候更关心某个模型还能用多少 ... 同个供应商
同模型可以合并 ... 或者单个路由组单独显示用量和额度. 有需要关心账号限制
的时候可以进详情再去看".

What it does:
- A Usage card of several accounts has "All N accounts" under its head:
  each window the accounts share, one figure and a thin bar, and how
  many couldn't be read. The tray panel's group of several has the same
  strip above its cards (at most 3 windows). Each account stays below it
  as it was: the details are where they were.
- A routing group's row (Routing › groups) has a line for each provider
  among its members: "WorkBuddy AI, 4 accounts: Credits 355 / 1,500
  credits · 23.7% used · 1 couldn't be read", following Used/Left.

The design, and why:
- Only what reads alike goes together (mergeQuotas). Counted windows of
  one name and unit add their amounts and limits, the share is of the
  sum; wallets add balances in one unit. A window said only as a share
  is the mean over accounts on one plan, whose allowances are the same
  size, so the mean is the share of their allowance together; two plans
  are never averaged, and a share is never added to a count. Text-only
  windows are left out; unlimited only when every account read says so.
- An account whose reading failed is unknown, not 0 or 100: left out of
  the figure and counted ("1 couldn't be read"). A window an earlier
  reading (asOf) stands in for, past its reset, is left out the same way
  and counted in its tooltip. No single reset is claimed for the whole;
  the tooltip says when the first of them starts again.
- Only what two or more accounts have goes together: one account's
  window is already below it.
- No switch: the strip is additive and quiet (no gradient, no coloured
  stripe; the pill grey of the page, the accent bar the cards use), and
  it names no account, so Hide accounts holds.
- The code is in quotaall.js, imported when a provider first has two
  accounts (quotaAllJS) or a routing group's member has readings, and
  each place is drawn again once it is in. app.js has the loader and the
  two call sites; three comments in the quota code were cut to keep the
  core inside its budget (1,533,096 of 1,533,105), no raise.

Run, at this tree (rebased on origin/main df0320156):
- mote (macOS 27), node --test: usage-merge (7/7), usage-all-accounts
  (14/14: Chromium and WebKit; en, zh, zh-TW, ja, de; light and dark for
  en and zh; Usage page at 440px, tray panel at 360x760, Routing), i18n-keys
  (4/4), old-webkit (6/6): 31 of 31 ok.
- mote, go test -count=1 ./internal/gui: TestCoreScriptBudget ok (app.js
  1,311,777, core 1,533,096); one red, TestMainWindowCorners/macOS_26_SDK,
  #3949 (macOS 27, AppKit), no Go changed here.
- Screenshots of all three places in both engines, every language,
  light and dark (en, zh), looked at.
- Not run: the whole GUI suite. mote had four other sessions' full GUI
  suites running (1h46m+, load 57 to 240) and the WSL box three, so
  per the one-suite-a-machine rule it waited and wasn't run.

Broken by hand (red, then put back):
- quotaall.js counting a failed account as read and dropping the
  two-account rule: usage-merge 4 of 7 red (share vs count, failed is
  unknown, plans apart, balances/unlimited). Before the move to
  quotaall.js, dropping the kind from the key and the stale skip each
  turned their tests red too.
- the loader not drawing again once quotaall.js is in:
  usage-all-accounts 14 of 14 red (both engines, every language).
- usage-merge.test.cjs is red on the old code: quotaall.js isn't there.

Not tried: real accounts (the figures come from fixtures: WorkBuddy AI
credits, Codex Plus and Pro, Claude Max ×2, Kimi); the real tray app on
macOS, Windows or WebKitGTK; a slow first load of quotaall.js (the strip
comes in after the cards on its first draw, measured only on a local
server).
2026-11-01 18:27:45 +08:00
pipi f06551c277 gui: a closed window's page is told it is out of sight
A macOS orderOut hides the NSWindow but can leave its WKWebView document
visible. The Routing page's frame loop and SVG animations therefore kept
running in a closed window (20-40% Web Content CPU; reopening and closing
returned it to 0%).

Tell the page before every app-window hide and again on show. Compose that
signal with WebKit's own hidden state, and pause CSS animations while out of
sight.

Verified with:
- go test ./internal/gui -run '^(TestCoreScriptBudget|TestClosingWindowMarksPageOutOfSight|TestClosingHidesShownAccounts|TestPanelCloseHidesIt|TestPanelJoinsFullScreenSpaces)$' -count=1
- node --test internal/gui/tests/window-visibility.test.cjs (Chromium and WebKit)
- the new JS test against v0.1.2049's app.js: it times out without the bridge
- the new AppKit test with hideMain calling Hide directly: it times out without the visibility signal
- go vet ./internal/gui
- GOOS=linux CGO_ENABLED=0 go vet -tags nogui ./internal/gui
- GOOS=windows CGO_ENABLED=0 go vet ./internal/gui

The full GUI package still has unrelated environment failures in
TestProxyCheckSaysAProxyPassedBy and TestMainWindowCorners on this macOS 27
setup.
2026-11-01 17:28:30 +08:00
ggbdpq 947377307b usage: the Sessions tab's token totals count the cache, as the Overview's do (#2591)
n1majne3 reports the usage totals ignoring the cache reads the same page
shows beside them. The Overview's totals have counted the cache on request
since #2378 (magpie.usageWithCache); the Sessions tab counted tokens in and
out alone wherever they showed: the tokens tile, a session's row in both
lists (the Usage page's and the Sessions page's, sessSpent), the projects
and models bars and pickers (sessSums, spent), the day chart's bars,
tooltips and calendar, and the top sessions. A reader who asked for the
cache on the Overview saw two different totals for the same period.

The tab now reads usageTokens everywhere, so the one pick decides for both
pages. Its tokens tile carries the same label pop-up and says the cache's
count in its line; a pick made there refreshes the tab it is on, not the
Overview. The chart's day and week buckets carry the cache's counts now
that their value reads them, and the top sessions, ranked without the
cache, are ranked again by the count the reader sees. The default stays
without the cache, as #2378 left it; the per-session median and p90 stay
counted in and out (Stats.Overview ranks them), and the Requests tab's
totals always counted every token (allTokens).

Run at 89521b03 + this: sessions-cache-tokens.test.cjs (new; Chromium and
WebKit, en and zh, APIs faked) fails on the base with "AssertionError: the
tile's tokens: '57.0K' !== '168K'" and passes with the change;
sessions-overview, usage-overview-fold, api-key-usage and
sessions-usage-open pass with it (120 tests, both engines, en and zh).
Broken by hand, each red at its own assertion: the pick's callback pinned
back to renderUsage() (the tab doesn't follow the pick), the top list's
re-ranking left out ("ranked by the count shown"), and the day buckets
without their cache counts ("the day's tokens count the cache").

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 16:43:21 +08:00