Commit Graph
112 Commits
Author SHA1 Message Date
yetone cba59b05e1 gui: the middle button's autoscroll scrolls a page instead of twitching (#2767)
#2767 (znbsf, with AvatarGanymede's recording on the Discover page) and
多喝热水 on Discord, on Windows: pressing the wheel and moving the mouse
made a page twitch instead of scrolling, or pulled it back. znbsf's patch
found the same cause.

Chromium and WebView2 give the autoscroll a pointerdown of button 1 and
then no wheel, touch or drag of the reader's. The "where the reader is"
rule put back each of its scrolls as it came, so the page twitched
between where it went and where it was.

What changed (internal/gui/assets/app.js, the click guard):
- From a trusted middle press on a view that can scroll (`panning`),
  that view's scrolls count as the reader's, and what a click held is let
  go. This lasts until the autoscroll ends as Chromium ends it: on the
  next press (seen only as a pointerup with no pointerdown), on a key, on
  blur, or on the lift after the mouse moved more than 15px while held.
- A field the guard brings back into view after putting a scroll back
  must have been focused since the reader last scrolled that view
  (`scrolledFrom`). Before, the button the middle press focused, which
  the autoscroll or the wheel took out of sight, was brought back by the
  next scroll that was put back, and the page jumped to it.
- docs/subsystems/gui-shell.md says both.

Guarded by internal/gui/tests/view-middle-autoscroll.test.cjs: a real
middle press and move in Chromium, en and zh, a scroll by code still put
back after the autoscroll ends, and WebKit (no autoscroll) left as it
was.

Broken by hand:
- app.js put back to its base: Chromium 0/3 ("the autoscroll scrolled
  the page: at 0, passed 0,0,0,…"). WebKit passes, as expected.
- Only the panning line taken out: Chromium 0/3, same message.
- Only the scrolledFrom check taken out: Chromium 0/3 ("after the
  autoscroll: a scroll by code is put back (was 374, asked 1212, at
  126)").

Record for this push: 13 commits on origin/main ca4a1cde0, head tree
539c84e92. Go 1.26.8, sandbox HOME, GOMODCACHE/GOCACHE pinned. The full Go
run and vet were at tree d6393dfc8, the same Go code as this head: only
app.js comments (cut under the core script budget) and one ja string
changed after it.
- gofmt -l: nothing. go build ./...; go vet ./... (darwin), GOOS=linux
  go vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -timeout 45m ./..., through tee, one suite on the machine:
  68 packages ok. The one red was internal/gui's
  TestCoreScriptBudget: app.js 1,335,314 > 1,335,000, since main grew
  app.js under the stack. The autoscroll commit's own comments were cut
  (to 1,334,629) rather than the budget raised, and go test -count=1
  ./internal/gui is ok at this head (113s). Packages the run took from
  Go's test cache had the same inputs.
- GUI: the 18 files this stack touches or names, both engines,
  202 of 204 pass (tree 068acf128, this push less the last commit). The
  two reds: gui-ja, red on main since c2636b7b5 and fixed by this push's
  last commit (gui-ja and i18n-keys 6 of 6 there), and usage-fold's
  chromium "several accounts" (#2163, red on main the same way).
- view-middle-autoscroll and click-scroll pass, both engines.
- plugin-github's "a click scrolls nothing" (1px) was red under the
  whole run's load and passes alone at the stack and on main (#3218).
  The whole GUI suite ran at 1c1fc7183 (this stack's first 12 commits on
  0ddcf28a1): 11713 of 11769 pass. Each of the 21 red files was then run
  alone at the stack and at origin/main 8278fd9b0. Eight are red the same
  way on main: plugin-card-update (#3079), quota-count-wrap and
  quota-name-translated (#2228), s3-sync (#2448), usage-agents-hide
  (#2276), usage-checkin (#3091), usage-fold's chromium "several
  accounts" (#2163), usage-ledger (#3104). The other 13 pass alone on both
  and were red only under that run's load (50 to 335): currency #3101,
  plugin-github #3218, provider-fetch-again #3292, rest-try-now #2564,
  routing-auto-reset #3293, routing-keys-fold #1612, routing-steady #1804,
  routing-wb-restricted #1905, sessions-folder-delete #2218,
  sessions-manage #3294, switch-only #3295, text-size #1866, usage-pack
  #3296.

Not tried: the real Windows app (WebView2) on the Windows box; only
headless Chromium's autoscroll. Linux WebKitGTK has no middle-button
autoscroll, so it is left as WebKit is.
Not done: znbsf's patch doesn't start this on a middle press on a link
(which opens a tab, not an autoscroll). Here it does start, and lets a
scroll by code in that view stand until the next press or key. Left on
#2767, which stays open for the reporters.
2026-10-23 01:58:01 +08:00
yetone c036d6c34a gui: what the window shows can be selected and copied, its controls can't
Outvi V on Discord: the page is user-select: none as a whole, so nothing
could be selected or copied into a bug report, only the few places that
opted in. Two rules at no specificity after body in app.css now make
content selectable: paragraphs, pre and code, a detail's values (dd,
td), hints, notes, every error class (.err, .error, *-err, *-error), a
conversation (.sess-talk, a subagent's too), a request's story and log
on Routing (.rt-log, .rt-steps, .rt-time). Controls stay unselectable
with what is in them, as in a Mac app: buttons, labels, summary,
select, the navigation, menus (.pop), tabs, switches, segments, grips,
draggable rows. With no specificity, a view's own rule still decides
(a list being sorted, a blurred value), and a field stays a field.
An account's or a key's name was selectable by accident through its
row (a button inside .accts > [data-account-id]); .acc .rename now says
so itself, and account-arrange keeps checking it.

user-select.test.cjs: on Routing, a mouse drag across a vendor's error
in a request's story selects it; a drag across a request's row selects
nothing, and the row still opens on a click with text selected
elsewhere; no nav, button, tab, segment or option is selectable, and no
field is unselectable. Both engines, en/zh/ja/de, 1100 and 420 wide:
16/16, twice. Red on HEAD's app.css (16/16 fail: 'none' !== 'text').
Ran: click-scroll 22/22, agent-grip 10/10, provider-order 6/6,
search-order 16/16, account-arrange 2/2 (red in chromium before the
.acc .rename line), account-alias 20/20, panel-arrange 8/8,
sessions-talk 4/4, sessions-subagents 40/40, usage-ledger-detail 6/6.

Not tried: the app's own webviews (WKWebView, WebView2, WebKitGTK); only Playwright's Chromium and WebKit.

Run for this batch of seven commits (devin, routing zh, qoder, masked words
any case, Long conversations, Claude subagents, user-select), in a worktree,
sandbox HOME, never against live configs:
- At e352cc823 (tree ea497c9f5, on origin/main 7dd965ed2): go test
  -timeout 45m ./... with pipefail, tee'd: 68 packages ok, exit 0, no
  ENOSPC. gofmt -l clean; go vet ./... for darwin, GOOS=linux -tags nogui
  and GOOS=windows: clean.
- The whole GUI suite at e352cc823 (node --test --test-concurrency=3
  internal/gui/tests/*.test.cjs, Chromium and WebKit, every language):
  11725 tests, 11679 pass, 46 fail, none ENOSPC. Each red file run alone at
  both 7dd965ed2 and e352cc823 gives the same counts on both, so none is
  from this batch: usage-agents-hide 5/16 (#2276), usage-ledger 28/34
  (#3104), usage-fold, quota-count-wrap, quota-name-translated (#2399),
  usage-checkin 26/28 (#2549), plugin-github 14/18 (#3218), s3-sync 3/4
  (#2448), modal-morph (#3179), fonts (filed as #3227, 1 in 9 alone on
  main). tray-usages (#2453), plugin-card-update (#3079) and
  proto-menu-overflow (filed as #3229) were red only under the full run
  and pass alone on both.
- Rebased onto origin/main 4a87c4476 (only Zed's mover min changed), tree
  8944b5dbb: go test ./internal/provider ./internal/gui (TestCoreScriptBudget
  and the app.js budget) ./internal/redact ./internal/settings
  ./internal/agent: all five ok; gofmt -l clean.
2026-10-22 10:52:04 +08:00
yetone 9691997bb0 gui: Long conversations stays in Settings when no Codex or Claude Code is here to hold it (Linka)
Linka on Discord runs magpie in Docker, with no agent installed. f1e4516da
(10-20) moved Long conversations (#fullContextRow: Compact at / Full
window) into Codex's and Claude Code's settings on the Agents page. In
gateway mode agentPrefsOf is null, and with neither agent present nothing
shows the row, so the compaction threshold couldn't be changed at all.
The setting still applies there: settings.Compact() sets the windows the
gateway serves, which agents on other computers read.

renderAgentPrefLinks now puts the row in Settings › General (before the
search-link rows) when no present agent owns it, and sends it back to
#agentPrefRows when one appears. With Codex or Claude Code present,
nothing changes. No new page. The backend is unchanged, so a compactAt
saved before is read and shown as it was.

Tests:
- agent-prefs.test.cjs: in gateway mode and with only Pi present, the row
  is in General. It shows the saved 200K, a typed 150k posts
  settings/full-context {on:false, at:150000}, and no other agent row is
  in Settings.
- settings-general.test.cjs: its no-agent fixture now leaves
  fullContextRow out of the "not in Settings" check.

Broken by hand: with HEAD's app.js the two new cases are red in Chromium
(the row never appears in General).

Not tried: magpie in a real Docker container; the GUI test fakes gateway mode.

Run for this batch of seven commits (devin, routing zh, qoder, masked words
any case, Long conversations, Claude subagents, user-select), in a worktree,
sandbox HOME, never against live configs:
- At e352cc823 (tree ea497c9f5, on origin/main 7dd965ed2): go test
  -timeout 45m ./... with pipefail, tee'd: 68 packages ok, exit 0, no
  ENOSPC. gofmt -l clean; go vet ./... for darwin, GOOS=linux -tags nogui
  and GOOS=windows: clean.
- The whole GUI suite at e352cc823 (node --test --test-concurrency=3
  internal/gui/tests/*.test.cjs, Chromium and WebKit, every language):
  11725 tests, 11679 pass, 46 fail, none ENOSPC. Each red file run alone at
  both 7dd965ed2 and e352cc823 gives the same counts on both, so none is
  from this batch: usage-agents-hide 5/16 (#2276), usage-ledger 28/34
  (#3104), usage-fold, quota-count-wrap, quota-name-translated (#2399),
  usage-checkin 26/28 (#2549), plugin-github 14/18 (#3218), s3-sync 3/4
  (#2448), modal-morph (#3179), fonts (filed as #3227, 1 in 9 alone on
  main). tray-usages (#2453), plugin-card-update (#3079) and
  proto-menu-overflow (filed as #3229) were red only under the full run
  and pass alone on both.
- Rebased onto origin/main 4a87c4476 (only Zed's mover min changed), tree
  8944b5dbb: go test ./internal/provider ./internal/gui (TestCoreScriptBudget
  and the app.js budget) ./internal/redact ./internal/settings
  ./internal/agent: all five ok; gofmt -l clean.
2026-10-22 10:52:04 +08:00
yetone b00c82acfa masking: each kind is masked, sent with a warning or held back; a Never mask list and Try it (#1977)
Settings › Privacy gets two sections under What to mask:

- When a value is found: Mask, Warn or Block per kind (redactActions;
  a kind left out is masked). Warn sends the value as written and records
  it with a placeholder nobody remembers, not counted as masked. Block
  masks it as before and the gateway answers 400 naming the kind and the
  value's hint, never the value, with nothing sent (maskBlocked); the
  record is kept as Blocked. The secret kinds come first, the personal
  ones behind Show all kinds. A Never mask list (redactAllow) lets a whole
  value go as written in any case; a longer value it is part of is masked.
- Try it: POST /api/masking/preview masks a text as a request would
  (redact.Preview) and remembers nothing: no placeholder stands for it
  afterwards and its values aren't masked later as seen before. The page
  shows the vendor's text, what was found and what would be done, and
  keeps the text in no storage.

The masking card counts requests held back and values sent as written; a
call whose values only went as written gets an amber badge on Recent calls
and the Routing log. zh, zh-TW, ja and de throughout. Docs: gateway-routing
and gui-shell.

Broken by hand: the new GUI badge assertion fails on the old maskedBadge
(no .warn badge drawn); TestSettingsSaveKeepsWhatItDoesNotSend went red
until the two settings were in its fixture; "{n} held back" turned
i18n-keys red against the routing plugin's "{n} held" and was renamed.

Run at this tree (base origin/main 9b0f48612):
- gofmt clean; go vet on macOS, GOOS=linux -tags nogui, GOOS=windows.
- go test -count=1 -timeout 45m redact, maskrec, settings, gwmw, gui,
  gateway: ok.
- GUI, both engines: every Privacy file, mask-actions, masking-records,
  routing-bodies, i18n-keys, old-webkit: 263/263.
- Whole GUI suite earlier at 083b1c8e7's base, beside 7 other runs:
  53 red; alone, the ones left red fail the same on origin/main
  6fc532198 and are filed (#3179, #2228, #2448, #2276, #2549, #2163,
  #2399), except privacy-usage-stats and account-discovery, which this
  change's taller page moved off screen; both fixed here.

Not tried: a real vendor request held back by Block from a real agent.
2026-10-22 04:07:55 +08:00
yetone f21dd99f5a privacy: every masking is recorded, and Settings › Privacy shows it
What was masked is now kept, so the user can see it. Settings › Privacy
opens on a summary card: how many values were kept from vendors over 1,
7 or 30 days, by kind, by finder (rules, your words, the local model,
known values) and by where they went, with a day strip. The page is
grouped into What to mask, How it's found (rules and the local model are
layers, not a toggle: the model adds names and addresses rules can't
see) and Sharing. A records view lists each masked request: its kinds,
finders, placeholders and, while magpie runs, the line around each
value. Gateway › Recent calls and the Routing log carry a masked-N badge
that opens the record.

Originals never go to disk. internal/maskrec writes day files under
~/.config/magpie/masking (0600, 30 days, 100MB at most) holding kinds,
finders, placeholders, a first character or key prefix and a length.
The lines around values are kept in memory for the last 400 records
only, and /api/masking/value answers only while the masker remembers a
placeholder. Nothing is written under MAGPIE_TEST_SANDBOX.

A masker says what it masked through gwmw.Teller (JSONHits, TextHits,
Value); a plugin masker that doesn't is counted only, so older redact
plugins keep working. Every route that masks notes it: chat, Responses,
Codex backend and search, embeddings, images, video, transcription,
decide and the search MCP query. Masking still fails closed: a masker
that panics on any path refuses the request (TestMaskingOnAndOff's fake
now panics on JSONHits and TextHits too, since the gateway asks a Teller
through those).

app.js grows to 1,314,432 bytes, so its budget rises to 1,335,000 and
the core's to 1,528,800 (+1.5%): Settings is the core's own page.

Run at this head (rebased on origin/main a3ebed202):
- go vet clean on macOS, GOOS=linux -tags nogui and GOOS=windows;
  go test ./internal/gateway ok (561s).
- On origin/main c922225f1 (one commit back, the packages either side
  touches): agent, gateway, gui, gwmw, maskrec, provider, redact ok.
- On origin/main 592899467: go test ./... -timeout 45m, 65 packages ok;
  agent and gateway hit the 45m timeout under load ~26 (each mid-way
  through a short test, not a hang) and pass alone with -timeout 100m
  (1133s, 890s).
- GUI, on 592899467, the 42 files this change or main's new commits reach (privacy-*,
  redact-*, masking-records, settings-*, gateway-*, routing-bodies,
  routing-request-metrics, routing-log-icons, account-discovery,
  click-scroll, i18n-keys, old-webkit), both engines, every language:
  475 tests, 475 pass. routing-bodies is green here since 2543fb2c1.

Run on the previous base, origin/main c84864ffc (the whole suites):
- go test ./... -timeout 45m: every package ok (66), exit 0. An earlier
  run found TestMaskingOnAndOff/panics (its fake, above) and
  TestCoreScriptBudget (the budget, above); both fixed.
- gofmt -l clean; go vet on macOS, GOOS=linux -tags nogui and
  GOOS=windows clean; node --check on the changed scripts.
- GUI suite, both engines, every language, --test-concurrency=6:
  11533 tests, 11483 pass, 50 fail. Each failing file rerun alone here
  and on origin/main:
  - red the same on main, filed: codex-predictions (#2624),
    usage-checkin (#2549), usage-agents-hide (#2276), usage-fold
    (#2163), s3-sync (#2448), quota-count-wrap and
    quota-name-translated (#2228), routing-request-metrics (#2571),
    routing-bodies (#2559: red at its "second request pressed" step;
    this change's badge checks before and after it pass),
    routing-rule-remove (#3096, filed now: 0 2 1 alone here, 0 0 2 on
    c84864ffc).
  - load, pass alone: group-member-weight (#2387), routing-model-rest,
    context-tune (Chromium didn't launch in 180s at load average ~45;
    0 0 0 alone on both). An earlier whole run's library-chip-fan red is
    #3072 (filed), plugin-card-update #3079, lightweight #2638,
    segs-glide #2683.
  - mine, fixed: old-webkit, three ":hover, :focus-visible" lists
    Safari before 15.4 drops; split, 6/6.
- Broken by hand, each went red: masked values kept on disk
  (TestNoValueOnDisk), a snip that runs past an escaped quote
  (TestSnipStaysInItsString), the shared-line dedup in the records view
  (masking-records, 10 of 12).
- Real app in a sandbox HOME with the local model on: the summary card,
  flow, chips and records view in light and dark; persons and
  addresses, Chinese names among them, recorded by=model; a grep of the
  masking folder and the sandbox config for the masked values found
  none.
2026-10-21 06:12:37 +08:00
yetone f1e4516da2 gui: Codex's and Claude Code's own settings are in the agent's row on the Agents page, not in Settings
The owner, 10-20: Settings › General held Codex subagents, Long
conversations, Codex background compaction, thread titles, thread
descriptions, composer predictions, the auto-review model and the
memories model, apart from the agents they set; "很割裂、很分散,不直观".

They now sit with their agent (AGENT_PREFS): in its opened row on the
Agents page (a Settings list in connectPanel), in a sheet from the
tray panel's row ("Settings" line, openAgentPrefs) and from the agent's
menu ("{agent} settings"). Each row is the one element moved between
those places, so its handlers and state go with it. Settings' search
still finds them, with a row that opens the agent's sheet
(#agentPrefLinks). A gateway has no Agents page and none of them.
Strings for zh, zh-TW, ja and de; docs (reference, agent-wiring,
gui-shell) point at the new place. app.js 1,277,298 bytes and the core
scripts 1,469,058, so both budgets rise.

Run on 6416d639c (the dialog morph, on origin/main 75e769a9f), macOS,
playwright 1.62.0:
- agent-prefs.test.cjs (new) plus the 10 migrated files (codex-titles,
  codex-descriptions, codex-auto-review, codex-predictions,
  codex-memories-settings, codex-async-compact, compact-at,
  settings-general, bare-ids, gateway-mode) and modal-morph: 152/152,
  chromium and webkit, every language, wide and 420px.
- go test ./internal/gui/: ok after the budget rise.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.

Two GUI tests leaned on the Agents page's old height and are moved with it:
agent-models-loading clicked "elsewhere" at (900, 650), which is now
Codex's Disconnect button in its opened row, so it clicks the page's lead
line; agent-expand-steady clicked Goose's row while Codex's opened row
(~554px with its settings) pushed it out of a 560px view, so it wheels
Goose's link into sight first (reader.cjs reach). codex-subagents-lead
and agent-models-redraw clicked controls below Codex's opened row and
timed out in WebKit ("outside of the viewport"); they wait for the row to
finish sliding open, then wheel the control into sight. With Settings ›
General shorter, segs-press-redraw's sweep left Usage's warm-up tabs
above the view in WebKit; it wheels them back when they are. panel-effort
opened Kimi's row below Codex's opened one the same way. login-allow's
wheel loop read the shorter General page's button 50ms after each wheel and
clicked beside it (de, 440px); it uses reach. mobile-web shut each agent
picker by tapping the Agents tab, which a picker opened low in Codex's
taller row covers on a phone; it taps the header's name (the lead line
can sit under the header's tabs, and a tap there opened Library), wheels
each row and field into sight before tapping it, and says which agent and
field a step timed out on. All seven pass in Chromium and WebKit.

After the rebase onto main (32 commits on), with the test fixes above:
- go test ./internal/gui/ ./internal/plugin/ ./internal/agent/ ok;
  gofmt -l clean; go vet GOOS=linux -tags nogui and GOOS=windows.
- 95 GUI files (every agent-, codex-, claude-, settings- and modal- file,
  and every file either side changed): 1375 pass; the 8 reds were
  segs-press-redraw, fixed above. The 16 other files that click an
  Agents row: 369/370, rail-tip red on main too (#3091).
- The full suite's reds are listed in the dialog morph's commit; each was
  run alone on this head and on origin/main.
- mobile-web's "desktop matches origin/main" compares Settings and the
  Agents page with main's assets, so it is red until this is on main; its
  phone checks pass in Chromium and WebKit.
2026-10-21 02:06:23 +08:00
yetone 5e30d5b5ae autostart, gui: Open at login says when the Mac's own switch for it is off (#2120)
Anoninz on #2120: Settings said Open at login was On while System
Settings › General › Login Items › Allow in the Background had magpie
switched off, so magpie never opened at login. autostart.Enabled now
returns a State: off, on, or needs allowing.

- macOS 13+: with the plist present, Enabled asks Background Task
  Management through SMAppService statusForLegacyURL: (cgo, ServiceManagement
  weak-linked, minos stays 12.0). RequiresApproval reads as needs allowing.
  Any other answer, a failed ask (-1), macOS 12 or a build without cgo
  (the darwin CLI release) leaves the plist alone deciding, as before: a
  failed read is never "off". launchctl print-disabled did not follow
  the switch on macOS 26.2, so it isn't used.
- BTM matches the item by the plist's Label, not its path: the tests ask
  about a label of their own, and TestMain stubs the ask so no test reads
  the user's real item.
- GUI: Settings › General keeps On and adds one line, "Switched off in
  System Settings’ Login Items…", with an "Open Login Items" button that
  opens x-apple.systempreferences:com.apple.LoginItems-Settings.extension
  through /api/open (that one URL is allowed; other x-apple URLs aren't).
  The window's focus reload clears it once switched back on. The row is
  hidden in magpie web, as before. Strings in zh, zh-TW, ja, de.
- CLI `magpie autostart` says where to switch it on. The daemon counts a
  held-back record as on (it is the user's choice, held by the system).

Part B (SMAppService.mainApp) is not in this commit: it can't be verified
here without registering in the user's real login items and logging out
to see a login launch stay tray-only.

Run:
- go test ./internal/autostart (cgo and CGO_ENABLED=0), cli, daemon, gui
  after rebasing on origin/main e4ac5e871: ok except gui's
  TestSetAnswersWhileDevinAndProvidersHang, red the same alone on
  origin/main e4ac5e871 at load ~400 (1 of 2), #1375.
- set -o pipefail; go test -timeout 45m ./... (base dd70c5e6a): every
  package ok but internal/agent, past 45m at load ~300; alone: ok (1761s).
- gofmt -l clean; go vet darwin; GOOS=linux -tags nogui and GOOS=windows
  go vet ./... clean.
- Broken by hand, each red: the binding always -1
  (TestLegacyStatusAsksTheSystem), heldBack always false and heldBack
  "!= Enabled" (TestEnabledFollowsTheSystemsSwitch); renderLoginAllow not
  called, the line not removed on focus, a wrong URL opened
  (login-allow.test.cjs).
- Real use, macOS 26.2, a build with the label patched to
  com.yetone.magpie-autostart-probe and the user's own HOME: autostart on
  -> "opens at login"; its Allow in the Background switch turned off in
  System Settings -> the needs-allowing message; back on -> "opens at
  login"; autostart off -> plist gone. com.yetone.magpie.plist untouched.
- GUI (playwright 1.62.0, chromium + webkit): login-allow.test.cjs new,
  40 of 40 (5 languages, 1000/440px, app and web). The 106 GUI files that
  load Settings or open URLs, 6 wide: reds were codex-predictions (#2624),
  segs-glide (#2683), lightweight (#2638), usage-checkin (#2549) - each
  the same alone on origin/main e4ac5e871 -, mobile-web (compares to
  origin/main, which had moved; 30 of 30 after the rebase), and
  account-alias and fonts under load only (#2984, pass alone). After the
  rebase: mobile-web, login-allow, settings-general, i18n-keys all green.
  The other ~700 GUI files were not run: at load 200-400 the whole suite
  was going at ~1000 tests an hour.
2026-10-20 02:29:39 +08:00
!am9a09eandfatcutegg ef655acb40 gateway, gui: a console shows the routing of the magpie that serves the gateway (#2606, fatcutegg)
fatcutegg's patch (fatcutegg/magpie 40ceb22df). The routing trace is held
by the process that serves the gateway. A second magpie on this computer
(`magpie web`, or the app while a launchd `magpie serve` holds the port)
showed none of it. Now its console reads the serving magpie's
GET /v1/magpie/trace (and /v1/magpie/concurrency for the lanes) over
loopback, and plays that trace as its own. The heading names which magpie
is routing ("serve (pid N) is routing").

Reviewed as a community change. A trace names accounts and emails, session
ids, a folder's last two parts and error text. It holds no prompt text and
no key. The endpoint answers local(r) alone: a request from another address
gets 403, and so does a loopback request carrying a proxy or Tailscale
header, or a LAN request while the gateway is shared, whatever key it holds.
lanGuard and corsGuard stop rebinding Hosts, Origin: null and *.localhost
first, as on every route.

Changed on top of the patch:
- A gateway key held to a budget, models or accounts is refused with
  KeyHeldCode (refuseHeld), as concurrency and quotas refuse it.
- The console reads loopback alone (ownerURL). A non-loopback MAGPIE_ADDR is
  never asked, and 0.0.0.0, :port, [::] and localhost are read at
  127.0.0.1.
- OwnerTrace lets a hung magpie go at wait+5s (was +20s). OwnerLanes waits
  700ms like ServedBy (was 2s) and is asked only when a magpie answers.
- `/` tells pid and serves to a loopback request alone. A plain `magpie`
  that opens the TUI reports itself as "tui".
- Takeover: in the real two-instance run, after B took the gateway over the
  hub still read "serve (pid A) is routing", from the providers state. Now
  the trace carries `by` (pid, serves), and the page names the router from
  it. When `by` changes, the page drops its routes and reads the new
  magpie's whole trace, so route ids from two magpies never mix. The
  label's full text is in its title, because the node cuts it with an
  ellipsis.
- Trace's doc comment, which the patch had orphaned, is back on it. Docs
  (gateway-routing.md, gui-shell.md) say all of the above. Issue
  references are #2606 (were #110).
- Tests: a proxy-header subtest, TestOwnerReadOnLoopbackAlone, the trace
  added to TestHeldKeyToldNoAccounts, and `by` / pid / serves asserted in
  both packages' peer tests.

Run:
- Each guarantee broken by hand, and its test went red: refuseHeld removed,
  ownerURL returning MAGPIE_ADDR, local(r) replaced by a RemoteAddr check,
  pid/serves dropped from the answer, `by` dropped in OwnerTrace, and the
  console's OwnerTrace fallback turned off.
- A real sandbox (own HOME, ports 3591-3593, fake upstream on 3564):
  - A `magpie serve`, B `magpie web`. B's Routing page played A's routes
    live (the long poll counted 3 requests through A).
  - Probes of A's /v1/magpie/trace. 200 from plain loopback. 403 for
    evil Origin, Origin: null, evil.localhost, a rebound Host with and
    without Origin, x.localhost Host, X-Forwarded-For and
    Tailscale-User-Login.
  - A LAN-shared instance answered 403 from 10.0.0.111 even with a valid
    key, and gave no pid on `/`.
  - Killed A: B took over in ~11s. The hub dropped the "is routing" label,
    and the next request through B showed as a fresh trace (1 request).
  - Chromium and WebKit screenshots at 1280 and 390 wide, in en, zh and ja.
    No horizontal scroll.
- gofmt -l clean. go vet darwin, GOOS=linux -tags nogui and GOOS=windows
  pass, and all three builds pass.
- go test -timeout 45m ./... at this tree (sandbox HOME, load 250-400):
  every package ok except four.
  - agent, gateway and library hit 45m in TestClaudeTierPickedAsTheMainModelStays,
    TestQueuedStreamKeptAliveOnceSentToItsVendor and TestWellKnownKitGrouped.
  - plugin failed TestGatewayHookMixedPiPackage (#2865).
  - Rerun alone with -p 1: plugin ok (464s). gateway finished in 45m with
    one red, TestRequestBuildsProvidersOnce, a 900ms/1s timing window under
    load. It is 8/8 green alone here and on origin/main f73378365. Filed as
    #2965.
  - agent ok (2162s) and library ok (377s), each run alone.
- GUI suite, whole, Chromium (playwright 1.62.0, 8 at a time, load
  ~300): 5608 of 5661 pass. The 15 red files were run alone at this tree
  and at origin/main f73378365. The fails are the same set, give or take
  load (136 of 162 pass here, 137 of 162 on main), and each already has
  an issue: routing-bodies #2559, segs-glide #2683, lightweight #2638,
  codex-predictions #2624, routing-model-rest #2115, routing-keys-fold
  #1612/#2658, quota-count-wrap #2228/#2399, sidebar-overlay-scrollbar
  #1863. routing-keys-fold's live fold test, which plays a live trace, is
  3 of 3 green alone both here and on main.
- WebKit: the whole pass was cut short at ~1576 tests by load (nothing
  routing-related red in it). The 9 files that drive the hub or the live
  trace (routing-js, routing-keys-fold, routing-group-fold,
  routing-held-dot, routing-held-member, routing-answered-still,
  routing-weight-chip, routing-mode-goes, claude-subagent-tag) are 108 of
  108 in WebKit here.

Co-authored-by: fatcutegg <29221285+fatcutegg@users.noreply.github.com>
2026-10-19 23:19:24 +08:00
yetone 04e8aa8f10 library: typing with an input method no longer moves the page (#2636)
In Library -> Instructions, typing Chinese through an input method made the
page jump up or down while a word was composed. The cause: the textarea's
autosize set height:auto to measure scrollHeight, so the page went short for
a moment and the browser clamped the view's scrollTop. Putting the height
back doesn't undo a clamp. app.js's scroll guard took the clamp for a scroll
the reader didn't make, and its scrollIntoView({block:"nearest"}) pulled a
textarea taller than the view to one of its edges. Every composition step is
an input, so this happened on every keystroke.

autosize (the only one in the GUI, used by a set's text, an agent's own
text, a skill's description and subagent boxes) now holds the textarea's
parent at its height while measuring, so the page never goes short.

What was run:
- New internal/gui/tests/library-ime-scroll.test.cjs covers en/zh, 980/560px,
  a Default set's text and Cline's own text. Chromium composes through CDP
  Input.imeSetComposition/insertText. WebKit gets synthetic
  composition events and inputs.
  - With the fix: 9/9 in both engines, before and after rebasing onto f191d6423.
  - With client.js reverted by hand: red in both engines (4 of 9), set:default
    in every lang/width; the page went e.g. 1000 -> 862, 1401, 1634.
  - extra:cline wasn't red on main: its clamp is put back before paint. It
    stays as a sibling guard.
- library-row-open-scroll and library-instr-sets pass in both engines.
- The whole GUI suite ran in both engines at concurrency 6, load ~150-300.
  - Chromium: 5408/5519. WebKit: 5442/5547.
  - Failed files were rerun at concurrency 2 and on unmodified main
    (c1e95f919). All are red on main too and already filed (codex-predictions
    #2624, segs-glide/lightweight #2683, provider-advanced-fold #2710,
    tray-cell-click #2686, removed-groups-menu-scroll #2172/#2211, others as
    filed).
  - WebKit plugin-moved-signin and update-release-page passed alone.
    removed-groups-menu-scroll went 4/4 three times. No library file
    stayed red.
- gofmt -l: clean. go vet: darwin, and GOOS=linux and GOOS=windows with
  -tags nogui: clean.
- go test -timeout 45m ./... under pipefail in a sandbox HOME: exit 0.

Not tried: a real system input method (macOS Pinyin) in the real app. Only
CDP and synthetic composition were used.
2026-10-17 19:04:59 +08:00
yetone 17557132cb gui: in a narrow window the title bar's tools show their icons, then the title gives way; nothing lies over it (#2625, linusxiong)
Beside the sidebar, Library's, Plugins' and Settings' heads sit in the
title bar after the breadcrumb, between --tools-l (the crumb's right +
16) and the window's buttons, laid out flex-end. When the tools needed
more than that room they ran on to the left, over the crumb: at about
650pt with the sidebar, Library -> MCP servers had 「发现」 over
「MCP 服务器」's last character. The crumb never gave way to them.

app.js tools() now shares the room out, laying out and reading each
step in its one frame, the next only if the tools still run over:
1. the crumb whole (its natural width from its parts, the last one's
   scrollWidth) and the tools with their words;
2. body.tools-tight: Library's Discover / Library folder / Backups and
   Plugins' "Mirrors in China" show their icon (or switch) alone. Each
   keeps its name as aria-label (a hidden span leaves the accessible
   name) and its tooltip as before (the folder's path, the backups'
   note and path, Discover's and the mirrors' sentences);
3. --crumb-max: the crumb drops its leading parts ("Work /"), a part
   and its slash at a time, and last cuts the page's name at its end.
In the side-nav head the Library buttons and the mirror switch are
flex: none and Plugins' search keeps 120px, so what doesn't fit shows
as running over rather than shrinking out of sight. The views'
MutationObserver also asks tools() again, as a tab's own tools change
(Discover only on MCP servers and Skills) without the crumb resizing.

title-bar-tools.test.cjs (new): every Library tab, Plugins' three and
Settings, sidebar picked, window mode, at 560 (the window's least),
650, 760, 900, 1024 and 1280px, in zh, zh-TW, ja, de and en, Chromium
and WebKit. No tool lies over the shown title or another tool or out
of the bar, no label is cut, an icon-only tool has aria-label and
title, only leading crumb parts go and the page's name shows, whole
from 650px. Against the old assets (MAGPIE_GUI_ASSETS) it fails in all
five languages at 560px Library Instructions ("a tool lies over the
title"); with the change Chromium 5/5 and WebKit 5/5. Looked at
screenshots of zh Library MCP servers and Plugins Discover at 560, 650
and 760px.

docs/subsystems/gui-shell.md says how the title bar gives way.

Run with both #2623's and #2625's changes, on b7d9616d0 (macOS, Go
1.26.8, load average 80-270 from other sessions):
- gofmt -l: nothing. go vet -tags nogui ./... with GOOS darwin, linux and
  windows: clean.
- set -o pipefail; go test -timeout 45m ./...: every package ok except
  internal/agent (2702s) and internal/gateway (2721s), which ran past
  45m under the load (#2544, #2108; no test hung, each was seconds into
  its run). Rerun with -timeout 90m: internal/agent ok (2816s);
  internal/gateway's only red is TestDesktopSubagentUnsetDoesNotDecode,
  "allocated 1 times" (10/10 green alone, filed as #2699). The textcalls
  tests passed in that run.
- The whole GUI suite, both engines (NODE_PATH at playwright@1.62.0). It
  ran in two parts, because another session deleted the first part's log
  mid-run; the files from provider-* on were run again. title-bar-tools
  passed 10/10 inside the suite. The reds are red the same way on
  b7d9616d0's assets, rerun beside them (MAGPIE_GUI_ASSETS) at
  concurrency 1-2:
  - segs-glide 20/20: filed #2683.
  - sidebar under load: filed #2684; 4/6 red on the old assets.
  - lightweight: filed #2638.
  - Already filed:
    - usage-agents-hide (#2276), routing-bodies (#2559, #2658),
      routing-keys-fold (#1612), routing-model-rest (#2115),
      routing-wb-restricted (#1905), rest-try-now (#2564), s3-sync (#2448).
    - quota-count-wrap, quota-name-translated and usage-fold (#2399),
      usage-checkin (#2549), usage-refresh (#2184), usage-ledger (#1876).
    - codex-predictions (#2624), github-sync (#2631), login-import (#1307).
  - The rest were Playwright launch timeouts under load (#2371).
- After rebasing on origin/main 85eef5d87: title-bar-tools Chromium 5/5,
  WebKit 5/5. Before that, WebKit zh and ja failed on a page error, "Fetch
  API cannot load /api/providers due to access control checks". That is
  WebKit's report of a sidebar read cancelled by the test going to the
  next page (#1350, #1307). The test now leaves that one WebKit message
  out. Against b7d9616d0's assets, WebKit ja is still red: "a tool lies
  over the title at 560px library instructions".

Not tried in the real app on Linux (WebKitGTK) or Windows (WebView2);
no motion or new browser API is involved, only layout.
2026-10-17 18:41:43 +08:00
yetoneandchiperman 85eef5d87a gui: quota refreshes stay centered and finish each turn without jumping (#2397)
chiperman's patch (df288db, #2397), landed here since external PRs are
collaborators only. The card redraw replaced its refresh button on a
background reading and again when the click finished, restarting its
rotation and hover reveal and moving the Updated text; a fast reply also
stopped the spin partway through a turn. Each account's control and its
animation are kept through redraws, the reply is shown at once and the
current 800ms turn finishes (at least one), Reduce Motion skips it, and the
glyph sits on the text baseline in an inline grid instead of a pixel offset.

Changed in landing: main had since given the tray panel's Allowances the
same quotaRefresh (#panelQuota, #840). A kept button is reused only when its
redraw took it out of the page, so a refresh started on the Usage page is
never moved out of the panel (or back); the other place's copy of a turning
control gets busy+spun and turns by itself until done() clears it. The
panel's hover rule (.pq-card:hover) reveals it as the Usage card's does.
quota-refresh-order's vm harness gets a document stub for that.

app.js's budget goes from 1,250,000 to 1,269,000: with four comments
shortened it is 1,250,904 here, the core's own code since the tray panel
draws the same control, plus 1.5% as the budget's comment asks. Every core
script together is still under coreScriptBudget, which is unchanged.

Run, sandbox HOME, pinned GOMODCACHE/GOCACHE, load ~110-360 from other
sessions' suites:
- Full suite on 81313b912 + this change: set -o pipefail; go test
  -timeout 45m ./...: 64 packages ok; gateway and gui red
  in 3 tests:
  - TestCoreScriptBudget (app.js 47 bytes over; this change, fixed above)
  - TestPluginModelServiceTiersListed: ENOSPC, disk full; -count=3 ok
  - TestMainWindowCorners: killed at its deadline, red alone on main too
    (#1936)
- At this head:
  - go test ./internal/gui/: only TestMainWindowCorners red (#1936)
  - TestCoreScriptBudget: ok
  - gofmt -l: clean
  - go vet -tags nogui for darwin, linux and windows: ok (./... on
    81313b912 + this change; ./internal/gui/... at the rebase)
  - node --check app.js: clean
- GUI, Chromium and WebKit, at e085d6e92 + this change: usage-card-refresh,
  quota-refresh-order, panel-quota-refresh, gui-zh-tw, gui-ja, gui-de:
  84 pass, 0 fail. At this head usage-card-refresh, quota-refresh-order
  and panel-quota-refresh: 75 pass, 0 fail.
- Broken by hand: the new tests against the old app.js/app.css fail 26 of
  46 in usage-card-refresh ("a background reading replaced the spinning
  control", "the refresh icon and the first text line must share a
  vertical center": 253.875 vs 252.375).
- Whole GUI suite (789 files) on 81313b912 + this change, per file, 3 at a
  time. Every red file was rerun alone and checked against plain main
  where it stayed red. None is from this change:
  - Red on main as well, already filed: codex-predictions (#2624),
    lightweight (#2638), segs-glide (#2683), sidebar (#2684),
    login-import, routing-keys-fold, routing-bodies (#2658),
    usage-agents-hide (#2276), quota-count-wrap, quota-name-translated
    (#2228, #2399), routing-model-rest (#2115), rest-try-now (#2564),
    routing-request-metrics (#2571), s3-sync (#2448), usage-checkin
    (#2549), usage-refresh (#2184), quota-curve (load).
  - Load reds filed now, red on main too: tray-cell-click (#2686),
    usage-ledger-abort (#2700), sessions-paging (#2703).
  - The rest were launch or goto timeouts in the parallel run and pass
    alone (about 30 files, among them provider-max-output and
    plugin-agent).

Co-authored-by: chiperman <chipermanju@gmail.com>
2026-10-17 17:26:58 +08:00
yetone af601541ef routing: a request opens to its request and response (Fate on Discord)
Fate asked on Discord to see what a single request on the Routing page sent
and got back, such as a Codex prediction. The bodies were captured already,
in the Gateway page's 40 recent calls and the opt-in request archive, but
nothing led there from a Routing request.

- gateway: a Call carries the Routing request it was (Call.Route = the
  trace's Route.ID), set where serve, the Codex backend and a refused title
  record it. Server.RouteCall finds it in the ring. A route id is not a
  call id. A route names its archive copy (Route.Archive =
  call.archiveName()), set only when the archive was on, so it reaches the
  saved history too.
- gui: GET /api/gateway/call takes ?route= besides ?id=. It is the same
  handler, the same no-store, the same key guard and the same 404 once the
  ring has let the call go.
- Routing page: the story's head has "Request and response". It fetches
  only when pressed, and shows the masked bodies through callBodyPanel (an
  SSE reply reads as its events). A request the ring no longer has shows
  the archive's copy through archivePanel when the route names one.
  Otherwise it says the last 40 are kept until magpie quits and how to turn
  the archive on. Nothing more is captured or kept than before.
- The head now wraps. At narrow widths its buttons ran past the story
  ("Back to live" was cut off at 440px).
- The two button words live in i18n.js: i18n-keys' "a plugin's words are
  its own" found them inside core strings.
- docs/subsystems/gui-shell.md says how a route reaches its bodies.

Tests:
- TestRoutingRequestOpensItsBodies (new): each of two routes gets its own
  bodies; route 0 and an unknown route get 404. Red without
  `call.Route = tr.ID` ("route …: 404").
- TestArchiveWholeBodies now checks that the route names the archive. Red
  without the t.Archive line (`route names archive ""`).
- routing-bodies.test.cjs (new), chromium and webkit at 440px, en, zh,
  zh-TW, ja and de, 10/10. It covers the ring's copy read only when asked,
  hiding, another request closing it, the archive's copy, the
  how-to-keep note, nothing past the story and no left border.
  - Red with the client asking ?id= and with the head's wrap removed.
- routing-request-metrics.test.cjs: with the head wrapped, its 480px
  picker clicks in WebKit landed on the footer. Playwright's WebKit places
  elements in the scrolled view hundreds of px lower than
  getBoundingClientRect, which elementFromPoint agrees with. The test now
  clicks where the page shows them. 5 runs of both engines, 20/20.

Run in a sandbox HOME at f1c91a99c plus this change:
- gofmt -l: clean. go vet -tags nogui: darwin, linux and windows ok.
- GUI: routing-*, panel-routing*, recent-call*, i18n-keys and
  header-relang in both engines: 1079 tests, 1079 pass (a first run had
  2 reds, both fixed above).
- go test ./internal/gui after the i18n move (TestPanelJoinsFullScreenSpaces
  skipped): ok.

Full suite: `go test -timeout 45m ./...` gave 65 ok, 1 FAIL. The FAIL is
internal/gui TestPanelJoinsFullScreenSpaces ("the panel shown doesn't take
the keyboard"), red 3/3 alone here and red the same on origin/main
1d227a7eb just fetched. It is filed as #2450.
2026-10-16 07:23:55 +08:00
yetone d6b045a7e7 usage: the Overview's lists fold under their headings and stay folded, the token totals can count the cache, and the Requests Tokens card wraps its cache count instead of cutting it (#2378)
The reporter asked for three things on the Usage page: fold Agents,
Models and Accounts from their titles and remember it (日常看账号维度
较多,都要拉到最底下); an option to count the cache in the token totals;
and the Requests tab's Tokens card cut its cache count off on a wide
window ("缓存 879…").

- Folds: each Overview list's heading (Agents, Models, Accounts, and
  Gateway keys beside them) is a .fold button with its chevron, the
  Gateway page's pattern. A click keeps the page still (backToReader).
  What is folded is kept per viewer in localStorage magpie.usageFolded
  (mountUsageFolds at the plugin's mount, showUsageFolds per render).
- Cache: the tokens tile's label is a pop-up (usageTokensPick, the app
  menu, no <select>) of Without cache / With cache, kept in
  localStorage magpie.usageWithCache. With cache, the tile, the chart,
  and every row's count and share add cache read and written
  (usageTokens), and the tile says the cache's count. Default unchanged.
- Cut count: a token line in parts (the Requests strip's Tokens card,
  the Overview's tokens tile) wraps between its counts and keeps each
  whole (usageParts, .parts); only a count wider than its card on its
  own is cut. The part spans undo .kpi span's label capitals.
- Strings in zh, zh-TW, ja, de. docs/subsystems/gui-shell.md bullet.
- mobile-web.test.cjs: until BASE_REF has mountUsageFolds, the
  desktop Usage comparison puts the new fold buttons and the pop-up
  back to their plain labels and compares the rest as before. That
  comparison caught the tile's line in the label's capitals and 5px
  taller; both fixed, and usage-overview-fold now checks them.

Run at this head (base dd25997a4), BROWSER=chromium and webkit each,
single files:
- usage-overview-fold (new, en/zh/zh-TW/ja/de at 1100 and 420 on the
  Overview, 1500/1100/420 on Requests; the ledger fixture is the
  reporter's numbers, zh in 万/亿 as they read them): 26/26 both.
- usage-accounts, usage-hit-rate, usage-ledger-fit, usage-ledger,
  usage-ledger-agent-middle, own-requests, mobile-web,
  usage-speed-count, usage-sum-whole, usage-head-steady, i18n-keys,
  click-scroll, number-units, gui-zh-tw, gui-ja, gui-de: all pass
  both engines.
- usage-agents-hide: 5 pass, 11 fail in both, "unhiding a row leaves
  the hidden line where it was", identical with this change taken out
  at dd25997a4: #2276, open.
Broken by hand, chromium, each red then restored: the .parts CSS gone
(9 red, among them zh 1500 cut at "缓存 8793.3 万"); folded lists not
hidden (11 red); the cache never counted (11 red, 8.1M vs 568M); the
parts' label-style reset gone (11 red, uppercase/600).
No Go changes, so no gofmt or vet. Not tried in the real app.

Full suite: SUITE_LINE
2026-10-15 23:08:05 +08:00
yetone 1242367020 gui: the menu bar's idle tooltip splits today's tokens into input, output and cache (NextCommit on Discord)
With no cards ticked, the tooltip said only "Today: 6.3M tokens". It
now says "Today: 6.3M tokens (912K in · 318K out · 5.1M cached)" over the
cost and requests, as the usage:today card's tooltip has since #1984
(trayTokens, shared by both; cached left out when nothing was cached).

Run: TestTrayIdleTip and the SNI tip case, updated. gofmt -l clean.

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetone 49d60394ef gui: the Mac's menu bar item shows its tooltip, which Wails never set there (NextCommit on Discord)
NextCommit (macOS, 0.1.1244) hovered the menu bar item for today's
tokens split into input, output and cache and saw nothing. Nothing was
shown at all: Wails v3.0.0-beta.24's macosSystemTray.setTooltip is a
no-op ("Tooltips not supported on macOS"), so neither the idle tip nor a
card's tooltip (usage:today already said "6.3M tokens (912K in · 318K
out · 5.1M cached)") ever reached a Mac. Linux has its own setTrayTip
(SNI); Windows keeps Wails'.

setTrayTip on the Mac now sets the status item's button toolTip on the
main queue (trayTipNative, mpTip in trayimage_darwin.go), returning false
while the item isn't up yet so it is tried again, as Linux's does.

Run: TestMacTrayTipIsSet (darwin, cgo): setTrayTip reaches the native
setter, false before the item is up, and a real NSStatusBarButton keeps a
multi-line tip whole. go vet: darwin (cgo, GUI) and -tags nogui for
darwin, linux and windows. Not tried: hovering the icon in a built app.

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetoneandhhh2210 94c70a2dd9 gui: the tray's Allowances cards say "Resets 14:26", not a bare ↻ that read as a button, and each card has the Usage page's own refresh (#840, hhh2210)
In the tray panel the first reset deadline was drawn as "↻ 14:26": text
with no click handler, which reads as a refresh to click (hhh2210 clicked
it). It now uses resetText, "Resets 14:26" / "重置于 14:26", as the
Usage page does; the other windows keep "Weekly Oct 31".

The tray cards also had no per-card refresh. They now get the main
window's quotaRefresh, the same single-card API and response-order
guard, at the start of the line under the account (the deadline, the
error, "Unlimited", or a balance's name): opened as the card is hovered
or the button is focused, spinning while it reads, closed taking no room
(the balance row's flex gap is closed with it). renderPanelQuota puts the
focus back on the button after the redraw. A failed read keeps the
figures and says the error in the footer, as on the Usage page.

Based on hhh2210's fork commit 9ea883ffb. Kept: the reset label, the
refresh on every tray card kind, the focus kept through the redraw, the
test's fixtures. Trimmed for the owner's UI restraint: the always-visible
24px button and the new "Updated N ago" row on every card (now hover-
revealed in the existing line, as on the Usage page), and the new status
texts (reading / cached, no new data / refresh failed / Claude's 30s
interval), which the Usage page's own refresh doesn't have either. No new
strings: "Resets {when}" and "Refresh this card" exist in every language.

Run (macOS arm64, Playwright 1.62.0, Chromium and WebKit):
- panel-quota-refresh.test.cjs, rewritten for this behaviour: 20/20,
  en/zh/zh-TW/ja/de at 440 and 360px tray widths.
- Broken by hand, each red with its own message: the ↻ label back ("the
  deadline says 重置于, got ↻ 14:31"); no refresh in the deadline line
  ("has its own refresh"); no focus restore ("the redraw keeps the
  focus"); no .pq-card:hover rule (hover never opens it); the error card
  without one ("kimi has its own refresh"); without the .pq-bn margin the
  closed button moved the balance's logo ("relay's closed refresh moves
  nothing").
- 68 GUI files that open the tray's Allowances or the Usage refresh
  (every mode=panel file reading usage/quotas, usage-card-refresh,
  quota-balance-error, usage-remote-*, quota-read-at): 943/944. The one
  red, usage-fold chromium "the view didn't scroll" 184 !== 180, is red
  alone on origin/main 95e7c6bcc too and is filed as #2163.
- No Go change.

Full suite: SUITE_LINE

Co-authored-by: hhh2210 <hzy2210@gmail.com>
2026-10-15 23:08:01 +08:00
yetone ec13d1162a search: the search APIs are dragged into the order they are asked in, and each switches off without losing its key (#2286, blackrion)
The search APIs were asked in the order they were added, and the only way
to keep one out of the chain (to try another alone, or rest one whose
credit is nearly spent) was to remove it and paste its key again later.

- provider: SearchAPI.Off; SearchAPIs() leaves an API switched off out, so
  neither a model's search nor the web_search MCP asks it. SwitchSearchAPI
  keeps key, URL and place; SetSearchAPI keeps Off. ArrangeSearchAPIs puts
  them in the vendors' order, refuses an unknown or twice-named vendor, and
  keeps one not named after them. RestoreSearchAPIs now puts a backup's
  APIs in the backup's order (one only here after them), so a restored
  order and Off come back as they were; sync already mirrors the list.
- GUI: each API's row and its keys' row are one unit, dragged off its
  buttons with dragRows (as routing's groups, #779) or moved with Alt+↑/↓,
  renumbered at once, focus kept, redrawn as saved if the order is
  refused. A lib-switch per row posts {vendor, on}; one off is dimmed and
  says Off; Search first with counts only APIs that are on. The row's
  buttons wrap instead of running past a 420px window.
- CLI: magpie search off|on <api>, move <api> <n>; the list says off.
- POST /api/settings/search-api takes {arrange} and {vendor, on}.
- Docs: gateway-routing "The search APIs' order, and one switched off",
  gui-shell, README (en, zh-CN).

Run: go test -tags nogui ./internal/provider ./internal/cli ./internal/gui
./internal/gateway (TestSearch*) ./internal/backup ./internal/davsync;
GOOS=linux/windows go vet of the touched packages; gofmt -l clean.
GUI: search-order.test.cjs 16/16 (chromium + webkit, en/zh/ja/de,
1100/420), and search-api, search-first, search-instead, search-keys,
search-mcp, searcher-pick, i18n-keys, gui-ja, gui-de, gui-zh-tw 100/100.
Broken by hand: SearchAPIs without the Off filter turns
TestSearchAPIOrderAndOff and TestSearchCLIOffAndMove red; the GUI
counting off APIs for Search first turns search-order red.
Full suite: SUITE_LINE
2026-10-15 23:08:00 +08:00
yetone 5ca37ef86b tray: Settings › Menu bar cost off shows magpie's today and 7-day totals as tokens alone, in the menu bar and its tooltip (BussanQ on Discord)
BussanQ asked for the menu bar's today card with the token count only.
A new Settings › Usage › Menu bar row, "Menu bar cost" (On by default,
segs, every OS, shown with or without cards since the no-card tooltip
says the cost too), saves settings.TrayNoCost. Off, trayMoney drops a
total's cost and its count of unpriced calls before trayTotalCard and
trayIdleTip see it, so the macOS cells and title, and the tooltip on
macOS, Windows and Linux, say the tokens and requests alone. A relay's
or subscription's balance card is money itself and stays. TrayNoCost is
per computer (KeepOwn, beside the other Tray* fields), and a change
redraws the tray (api.go). Translated in zh, zh-TW, ja and de.

Run:
- TestTrayNoCost (internal/gui): broken by hand (trayMoney a no-op) it
  fails with label "Σ47M · $128 | Σ6.3M · $3.40+", want tokens alone,
  plus the tooltip and idle tooltip.
- TestSync (internal/davsync) now sets TrayNoCost on one computer; with
  TrayNoCost left out of KeepOwn it fails "b's menu bar: … TrayNoCost:true".
- tray-cost.test.cjs: Chromium + WebKit, en/zh/zh-TW/ja/de, widths 1100
  and 420, Mac/Windows/Linux and no cards: 22/22 pass. With trayNoCost
  dropped from the prefs it fails "a save of another setting keeps the
  cost off". Also green: i18n-keys, tray-bird, tray-logos, tray-totals,
  tray-usages, tray-usage-redraw, quota-pace, tray-inuse.
- gofmt -l clean; go vet ./... and -tags nogui for GOOS=darwin, linux,
  windows clean.
- go test ./internal/tune ./internal/gui ./internal/settings ./internal/davsync
  green at this head, rebased on origin/main 95e7c6bcc.

Full suite: SUITE_LINE
2026-10-15 23:08:00 +08:00
yetoneandNorethSea b00da3860c usage: a past cycle shows its own whole-window estimate, and a reset ends a dry run (#2009, #2010, NorethSea)
Ported from NorethSea's fork (abed2e224) and re-derived on main.

What it does:
- A known reset ends a dry run (a stretch where a window read 0% left), even
  when the next poll sees the refill later. A stale dry reading taken after
  its own reset no longer extends the run. Calls from the reset on are not
  treated as "maybe paid from credits".
- A refill observed later than reset minus span
  (QuotaPoint.StartsCycleAfter, the boundaries history sampling keeps)
  starts what is reckoned. Calls before a fixed-deadline refill stay in the
  cycle before it. A first reading is not a reset.
- Picking a past cycle in Usage > Allowances > Trends > Cycle asks
  GET /api/usage/quotas/history/holds once per selection
  (quotaCycleHoldsOf). The route asks no vendor. HistoricalWindowHolds
  reckons each window at its own last reading in the cycle, using the
  ledger and readings from before that reading. "Loading..." shows while it
  is pending. An answer for a cycle no longer picked is dropped. The card's
  Refresh, or an asked read, reckons again. The estimate's tooltip names the
  window's start and the reading's time.

Changed from the fork:
- After a run closed at its reset, the fork reset lastLeft to zero. A
  window that ran dry again before its next reset then opened a run from
  time zero, which hid every window's estimate, the weekly one included.
  The next run now starts no earlier than that reset.
  TestWindowHoldsDryAgainAfterReset covers it (red with the fork's line).
- The fork narrowed the live card's Span to the observed refill. Span also
  feeds provider.WithWindowStarts, so the window's Pace would have moved.
  withSpansOf puts the card's spans back after reckoning. A span assertion
  in TestWindowHoldsUsesObservedRefillStart covers it (red without it).
- The fork's historical snapshot dropped the card's Balance. That slipped
  past the gate a live card has (holdsBounds), so a card that tells a
  balance got past-cycle estimates. Balance is now kept. Covered in
  TestHistoricalWindowHoldsUsesEachWindowsOwnReading (red without it). The
  fork's fixture had a Codex card with a Balance, which no Codex card has.
- Main has since added HoldsWhy (#2045). The fork's own "Whole: not enough
  reliable data" line and its .quota-holds-unknown CSS are left out. A past
  cycle uses main's holdsUnknownLine and its reasons, as a live card does.
  A window with neither an estimate nor a reason shows nothing, where the
  fork showed its unknown line.
- withRecordedWindowStarts is ported to main's holdsBounds(start, end, why).
- quota-refresh-order.test.cjs's VM harness now stubs quotaCycleHolds,
  which loadQuotas and quotaRefresh clear.

Left out: nothing else from the fork. Past prices aren't kept, so a past
cycle's cost uses today's API list prices (documented). Credits can't be
attributed per call, so none is attempted (documented).

What was run:
- gofmt -l: clean. go vet -tags nogui ./... for GOOS darwin, linux and windows.
- go test -tags nogui ./internal/usage ./internal/gui ./internal/provider:
  ok.
- Each of the three fixes above was reverted by hand, and its test went red.
- GUI, Chromium and WebKit:
  - quota-curve: 30/30. Also run at 1100 and 420 wide: 60/60 (all five
    languages).
  - Also: quota-*, i18n-keys, gui-de/ja/zh-tw, usage-card-refresh,
    usage-refresh*, usage-stale-answer, usage-remote-cards,
    usage-accounts*, usage-quota-head, usage-pack and usage-alert.
  - Reds: quota-count-wrap and quota-name-translated are red in WebKit,
    the same as on origin/main 707fbb249. Filed as #2228.
  - The GUI break-check (main's !sub.history gate put back) turns the new
    quota-curve test red.
- Full suite: SUITE_LINE

Co-authored-by: NorethSea <963979204@qq.com>
2026-10-15 23:08:00 +08:00
yetone 64b0f3a201 plugins: a community plugin's own page in magpie's window, shut in a sandboxed frame (P4)
A plugin's package.json may declare magpie.page {title, file, icon} and
magpie.permissions.reads. While the plugin is on, its page gets a tab in a
"Plugins" group after the built-in pages, drawn in an iframe sandboxed to
allow-scripts only (an opaque origin: no cookie, no storage, no parent).
Its files come from /_magpie/plugin/<token>/ (HMAC of the spec with a
per-process secret) under a CSP with connect-src 'none' and
frame-ancestors 'self'; a path that leaves the page's folder, a symlink
out, or an off plugin's token is refused. The window's postMessage bridge
answers only that frame (event.source checked) with theme and language,
the plugin's own options.get/set (throttled), and the reads it declared;
any other read is refused in the window and again by the server, and no
read carries a secret. /api refuses Origin: null and frame/iframe
fetch-dest requests (noFramedAPI), so the frame never reaches the GUI's
API even with the cookie. A page that throws or never says hello shows
the kernel's broken-page state with Try again. The Plugins page shows the
page and what it reads before the plugin is turned on.

Docs: gui-shell.md, plugin-runtime.md (P4 section), site docs en/zh/ja
with an example plugin; i18n zh, zh-TW, ja, de; fixture in
internal/gui/testdata/page-plugin.

Run (worktree at base 4df1ba0c6, -p 2, one package at a time):
- go test -count=1 -timeout 45m: internal/gui ok, internal/plugin ok,
  internal/pluginrt ok, plugins/... (budget groups middleware otel redact
  rotation search) ok.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean.
- Playwright (chromium + webkit, 5 languages, narrow widths): plugin-page 4/4,
  plugin-kernel 4/4, builtins 4/4, i18n-keys, gui-de, gui-ja, gui-zh-tw 3/3,
  plugin-middleware 24/24, plugin-own-icon 22/22, plugin-options 22/22,
  plugin-local 8/8, plugin-agent 22/22, click-scroll 22/22.

Broken by hand, each went red: CSP without connect-src; apiFramed always
false; the server's read check removed; the noFramedAPI wrap removed from
api.go (red through the real Handler); inside() letting every path
through; CORP same-origin re-added; in JS the client read check removed,
the ev.source check removed, and allow-same-origin added to the sandbox.
Without the Array.isArray guard on /api/plugin-pages, plugin-kernel,
builtins and plugin-middleware/own-icon/options went red (their mocks
answer a non-list) - that was found by the run, then fixed.

Real use: built magpie, `magpie web` on 127.0.0.1:3472 (gateway 3471) in a
sandbox HOME with the example plugin added. curl: the page file loads
with the CSP and no cookie, traversal and a bad token are 404, /api with
Origin: null or Sec-Fetch-Dest: iframe is 403 even with the cookie, an
undeclared read 403, a declared one 200. Chromium and WebKit at 1100 and
420: the page draws its declared read, the probe's fetch/absolute
fetch/top access/undeclared read are all refused, an <img> of /api is
refused, no page errors. Real use found that a
Cross-Origin-Resource-Policy: same-origin header blocked the frame's own
files (its origin is opaque); it is gone and a test guards it.

Not tried: the desktop (Wails) window. Market cards of plugins not yet
installed don't show a page's reads. The Playwright suite mirrors the
CSP in a mock route rather than the Go server (the Go tests and real use
cover the server).
2026-10-15 22:36:59 +08:00
yetone c7830731ca sessions: a session nothing was said in, which the Sessions page lists, opens and exports instead of "no such session" (#2273)
ListAgent lists a session assemble calls empty (no title, nothing
counted), so it can be cleared away, but Find searched only List(0) and
Get, and both drop it. The row's conversation, Markdown and Terminal
routes all go through Find, so they answered "no such session" for a row
the page itself shows. A real case is Codex's Image Session Helper: a
rollout with session_meta, settings, task_started and turn_aborted only.

Find now falls back to get(), which reports a session's files were found
even when assemble calls it empty, and fills it in the way ListAgent does
(listed(): Resume, Carry, Transcript), so Find finds every session
ListAgent lists. Get and List are unchanged: an empty session still
isn't in the main list and Get still says ok=false for it.

Run:
- TestFindEmptySession (internal/sessions) and TestEmptySessionOpens
  (internal/gui), on a fixture made from the real aborted helper rollout
  (paths and ids redacted). Both fail with Find's fallback broken by
  hand (only taking ok sessions), and pass with it.
- gofmt -l clean; go vet for darwin, linux (nogui) and windows.
- go test -p 4 -timeout 40m ./... with pipefail, sandbox HOME, at
  2b0037f41 plus this change, with four other full suites running on the
  machine: every package green but internal/gateway, whose
  TestOTelFastRequestTranscriptDiscovery/true failed ("request must still
  have a cached discovery miss"). That is #1811, its 2s discovery cache
  window under load; this change doesn't reach that path (TraceSessionIndex
  reads headers itself, never Find or ListAgent). Run alone with -count=10
  with its sibling it passes 10/10. Noted on #1811.
- Real use: a dev-tagged build in a sandbox HOME holding a copy of the
  real empty rollout, sessions feature on. /api/sessions/manage lists it,
  /api/sessions/transcript returns 200 {"parts":[]}, /api/sessions/markdown
  returns 200 with the .md attachment.

Not run: real use on Windows or Linux; the GUI suite (no GUI asset
changes). Whether an aborted helper rollout should count as something
said, and so show in the main list, is left as it was.
2026-10-15 09:40:51 +08:00
yetone 5618ade1e6 sessions: each reply in a session's conversation names the model its own line in the agent's file names (#2253, cnlove7777777-art)
Usage -> Sessions' conversation said only "Assistant", so which model
wrote a reply couldn't be told, though the agents' files name it.

- sessions.Part gains model (omitempty), set on assistant parts only,
  from the part's own line: Claude Code's message.model (the model that
  answered; none for its "<synthetic>" lines), Codex's
  turn_context.model (the model the turn was sent to; a /model between
  turns moves the next turn), Pi's and omp's message.model, OpenCode's
  modelID and OpenCode 2's model.id.
- Kimi Code (its model is only on a usage.record written after the
  reply), Cursor (no model in the transcript) and gateway transcripts
  (GatewayTurn.Model is the model asked for, not the one that answered)
  name none. Nothing is guessed from nearby requests.
- The reader (sessions client.js) says it muted after the role, once a
  reply at its first part and again only where it changes inside the
  reply; the tooltip is "Model: <id>" (an existing string, translated).
  ledSaid takes the model as an argument, so the Usage page's
  per-request content, whose row already names its model, is unchanged.
  No layout change: one muted span in the existing header line,
  ellipsized at narrow widths.

Run:
- TestTranscriptModelClaude/Codex/Pi/OpenCodeV2/OpenCodeFiles: all five
  fail on the old content.go/transcript*.go, pass on the new.
- sessions-talk-model.test.cjs: 20/20 (chromium+webkit, en/zh/zh-TW/
  ja/de, 1100 and 420). Fails on the old app.js/client.js, and with the
  once-a-reply rule removed by hand (label every assistant part).
- sessions-talk, sessions-export, gateway-conversations,
  usage-ledger-content, usage-ledger-detail GUI tests: all pass.
- go test -tags nogui ./internal/sessions ./internal/gui
  ./internal/gateway: ok. gofmt -l clean; go vet -tags nogui darwin/
  linux/windows clean.

Full suite for this push (#2257, #2251, #2254, #2253) at 53677ed8d:
go test -tags nogui -p 4 -timeout 40m ./... with pipefail: every
package ok. (An earlier full run caught davsync's TestSyncLibrary and
profile's TestOldProfiles/TestProfileCarriesLibrary relying on a gone
CLI after #2254; their sandboxes now have the CLIs, in #2254's commit.)

Not tried: the real app against a live Codex rollout (fixtures follow
the lines the readers already parse for usage).
2026-10-15 06:07:43 +08:00
yetone 52ee847612 gui: a Linux bar's tray icon is the bird's silhouette, not the app's tile, and the tooltip says today's total (ylorn on Discord)
ylorn (Hyprland, 0.1.1241): the StatusNotifierItem's IconPixmap was the
coloured app icon on an opaque white tile, which clashed with a bar's
monochrome icons and became a solid block on bars that tint icons by
alpha; the tooltip said only "magpie".

- Linux now gets the macOS menu bar's template bird (tray.png) in one
  colour on transparency (trayIconFor / linuxTrayIcon, trayglyph.go):
  light, or dark when xdg-desktop-portal's org.freedesktop.appearance
  color-scheme is 2 (prefer light); it is set again on the portal's
  SettingChanged (watchTrayScheme, own D-Bus connection). An unreadable
  portal counts as no preference (light). No IconName is set: a host
  that resolves a -symbolic name but draws it untinted would show a
  black bird on a dark bar with no pixmap fallback. macOS keeps its
  template icon, Windows the coloured app icon.
- With no cards in the menu bar the tooltip is "magpie" over one line of
  today's total, as the panel's Usage tab sums it (trayIdleTip: all
  tokens, cost in Settings' currency, requests), refreshed with the
  cards' loop. Cards picked: unchanged.
- The menu is unchanged (Open / version / Quit): no info lines. The
  panel one click away has the models and usage, and the menu is shared
  with Windows and macOS.

Run (sandbox HOME, pinned GOMODCACHE, shared GOCACHE), on origin/main
21aa40285:
- TestTrayIconPerOS fails with Linux given appIcon back ("linux:
  (0,0)-(64,64), want the menu bar bird's (0,0)-(44,44)"); TestTrayIdleTip
  fails with the tooltip back to plain "magpie". Both pass restored, with
  TestPortalLight, TestTrayTotals, TestTrayIconSize, TestSNITipIsSafeMarkup.
- gofmt -l clean; go vet ./... (darwin), GOOS=windows go vet ./...,
  GOOS=linux go vet -tags nogui ./... clean; GOOS=windows go build and
  GOOS=linux go build -tags nogui OK.
- traytip_linux.go (linux && !nogui, cgo) can't be vetted from macOS: the
  two new functions were copied into a darwin build and vetted there.
- go test -p 4 -timeout 40m ./...: exit 0, 53 ok, no FAIL.
- GUI: tray-*.test.cjs (Playwright 1.62.0): 112/112 pass.

Not tried on a real Linux bar (the Windows box with its WSL2/Omarchy VM
was unreachable over ssh): the pixmap, its colour on a light/dark scheme
and the tooltip on waybar/Quickshell/KDE are unverified on hardware.
2026-10-15 05:30:58 +08:00
Haogao Gu d966e19154 gateway, gui: the Routing page tags a Claude Code subagent's turn as it does Codex's
Codex names a subagent's request (x-openai-subagent: collab_spawn), and
the Routing page tags its row Subagent, with why it went where it did.
Claude Code names no kind, so Claude Desktop's subagent turns, which
magpie now moves to their own model and effort, read as the lead's: a
Desktop session's rows on one routing group could not be told apart.

Claude Code 2.1.295 sends x-claude-code-agent-id from every agent context
but the main one. Its x-claude-code-request-class and
x-claude-code-agent-type hints go only to a first-party base URL or with
CLAUDE_CODE_GATEWAY_HINT_HEADERS, so magpie doesn't get them.

- subagentTurnOf keeps the id in Route.SubagentID for a request that
  offers tools and names no kind: the turn desktopSubagentPick and
  desktopSubagentEffort take. Desktop's and terminal Claude Code's turns
  are kept, moved or not. The lead's turns, a subagent's tool-less helper
  calls (#2081: Claude Code's housekeeping) and a blank id are not. A
  kind wins over the id.
- A Desktop pick or effort that found the turn is trusted, so the body
  isn't decoded again; a request without the id isn't decoded at all.
  Only a subagent's turn with neither setting reads its tools once.
- Kind stays empty (#2081), so the ledger, the Usage page and the
  Purpose filter keep the turn unmarked. The ledger's Subagent already
  keeps the same id, on the helper calls too.
- routing.js tags it through tagKind in the request list (by request and
  by session), the story, the replay and the tray panel, with Codex's
  words and reasons (kindWhy's collab_spawn: moved or kept, within a
  routing group, on the model asked for). No new strings.
- The day's history keeps the id. A route kept before it has no tag, and
  its moved/kept story reads as before.

Verified at this head, on b9c589eb, under a temporary HOME with Go's
caches pinned:
- Each new test fails with its guarantee broken by hand (a real FAIL, not
  a build error), then passes restored. Go, 10: the id never set; tools,
  kind or the trusted pick ignored; tools decoded before the header (the
  lead's request then allocates 10 times, 1 for its headers); the route
  not given the id; Desktop only (terminal fails); every request trusted
  (the helpers fail); the JSON key renamed; the field left out of the
  history. GUI, 8, each 0 pass / 4 fail (Chromium and WebKit, 1100 and
  420, zh) at its own assertion: tagKind ignoring the id; the list, the
  story, the replay or the panel testing Kind alone; kindWhy's
  collab_spawn reasons on Kind alone; the id over a kind; the Purpose
  filter following the tag.
- go test -tags nogui ./...: 53 packages ok.
- go test -race -count=20 -run
  '^(TestSubagentTurn|TestHistoryKeepsSubagentID|TestDesktopSubagent)'
  ./internal/gateway: ok.
- gofmt -l: 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: exit 0.
- claude-subagent-tag.test.cjs: 20/20 (Chromium and WebKit; en, zh,
  zh-TW, ja, de; 1100 and 420), three runs in a row.
- Desktop-bundled Claude Code 2.1.295 through the built gateway, a
  temporary HOME, a loopback-only sandbox and local fixture replies, its
  Agent tool spawning a real subagent: with nothing set, with a subagent
  model, and as terminal Claude Code, each run kept 4 routes; the
  subagent's one turn has the id the client sent upstream, the lead's 3
  requests none, Kind empty; the model pick moved it to m2. No tool-less
  helper call came in these runs; the Go tests cover them.
- The Routing GUI tests around it, 91 files (every routing-*, the tray
  panel's two, purpose-filter, click-scroll, the Codex and Desktop
  subagent files, subagent-effort, search-instead, search-mcp, vision-mcp,
  remote-group-served, reasoning-speed, usage-ledger, sessions-overview
  and the new one), six files at a time: Chromium 602/617, WebKit
  572/617. Each failure fails without this commit too. On b9c589eb
  untouched (checked for the effort commit): routing-days-fit,
  routing-failed-open and routing-side-calls in both engines (their
  position checks against #2134's at-top rule), routing-wb-restricted
  (#2115's wheel), and at 420 in WebKit routing-agent-gone,
  routing-agent-hue-not-red, routing-rest-off and routing-held-member.
  On 6926b7ce: search-instead in WebKit, 5 of 5 alone, and
  routing-context-fold's picked request in WebKit, a row out of view, 2
  of 5 runs alone there and 3 of 5 here.

Not run: the whole GUI suite, a real Claude Desktop window or Cowork,
Linux and Windows machines (GOOS vet and build only), WebKitGTK.
2026-10-15 03:34:59 +08:00
yetone 3c7ec4ba24 gui: Usage is a plugin's page, its code, markup and words in plugins/usage (P2)
P2 of docs/subsystems/plugin-runtime.md, the fourth page after Sessions,
Library and Routing, and the largest part of app.js.

- The Usage page's code (~3000 lines: the Overview's cards, the
  Requests ledger and heatmap, the Sessions tab, the Agents list) moves
  from app.js to assets/plugins/usage/page.js; its markup, index.html's
  <main id="view-usage">, is client.js's part html. app.js 25756 →
  22675 lines (1,355,376 → 1,198,239 bytes).
- page.js builds on app.js at the top level (its timers, ?view=usage's
  tab and filters), so it is the one plugin script that loads after
  app.js. index.html: kernel.js, the plugins' other scripts, app.js and
  the scripts beside it, each page.js, then start.js, which is app.js's
  old tail (magpie.start(), navHides, OPEN_VIEWS, the first page shown,
  load()), so the first page has its code. TestBuiltinClientsLoaded
  holds that order.
- Hooks: open loads it, refresh(again) is load()'s read of it, reload is
  Refresh now, costs redraws costs on a currency change, tab says the
  tab for focusQuotaCard. app.js calls those through magpie.call. The
  allowance cards, quotasOpened, panelQuotaFocus and panelUseFocus stay
  in app.js: the tray panel draws them too.
- plugins/usage: Essential, Requires window, no InUse. Off, its nav tab
  goes and so do the ways to it (data-feature="usage": the panel's Open
  Usage, Routing's View usage); show("usage") gives way to Agents; the
  panel's Allowances tab stays. builtins.test.cjs switches it off and
  checks each.
- The 173 strings only Usage says move to plugins/usage/i18n.js;
  i18n.js 15032 → 14344 lines. "{n}s" and
  "All sessions" stay: context.js says them too since #1591.
- context.js: with context.js now in before the first page is shown,
  the page's open and load()'s first refresh both reached loadContext,
  and the second drew "Reading…" again over the advice the first had
  just drawn, so its curves never played their entrance (context-tune,
  3 of 3 red). loadContext draws the waiting pane once for the same
  days. Its dead last line, which loaded the tab once context.js came
  in late, goes.
- context-window.test.cjs's "arrives after the state" becomes "loads at
  once though context.js is slow": start.js now waits for it.
  usage-stale-answer reads page.js beside app.js. quota-refresh-order
  (#1630) cut app.js at the period picker's comment, now in page.js; it
  ends at the next comment that stays (5 of 5; without keepRefreshedQuotas'
  call, 2 of 5 red).
- docs: plugin-runtime.md, gui-shell.md.

Run, at this tree on origin/main af27b70b4 (main's keepRefreshedQuotas
and quotaRefresh changes, #1630, stay in app.js beside loadQuotas: the
tray panel draws those cards too):
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- go test -count=1 ./internal/gui ./internal/pluginrt ./plugins/...: ok
  (-skip TestMainWindowCorners, #1936); gateway and usage as above.
- usage-card-refresh, quota-refresh-order, builtins, editor-picker-clicks,
  context-window, usage-stale-answer: Chromium and WebKit green.
- The full GUI set: see the Routing commit; every Usage red there is the
  same on main or red only under load.
2026-10-15 01:32:13 +08:00
yetone eb7199e120 gui: Routing is a plugin's page, its script, style and words in plugins/routing (P2)
P2 of docs/subsystems/plugin-runtime.md, the third page after Sessions
and Library.

- routing.js and routing.css move to assets/plugins/routing/ (client.js,
  routing.css). Its part's html is the page's head and boxes that were
  index.html's <main id="view-routing">; the rest is drawn by
  routingPage, run at mount since it builds on app.js. It keeps itself
  after that as it did (its own hidden, the language, focus), so its
  hooks are dirty and discard, a routing group being edited, which
  show() and the window's close ask through magpie.call:
  window.routingDirty and discardRouting are gone.
- plugins/routing: Essential, Requires window and gateway, in use while
  the user has a routing group (not Auto, not Hidden), since the page is
  where it is edited. The gateway routes the same with it off.
- With it off, what leads to the page goes too: the nav and panel tabs
  and the panel's section (data-feature="routing"), the guide's Open
  Routing, Providers' "Make a routing group of …", the Usage list's
  View routing and its time as a link, the context card's Latest
  request. A panel left on its Routing tab shows Agents.
- What other pages use of it stays on window: openRoute (context.js),
  kindName, swapWhy, routedWhy (Usage's Requests), newGroupWith
  (Providers), panelRoutingShown (the panel).
- The 505 strings only Routing says move from i18n.js to
  plugins/routing/i18n.js (4 languages); i18n.js 17048 → 15032 lines.
  The plugin's own name and line stay in i18n.js: the Plugins page
  says them with the plugin off (TestBuiltinsTranslated).
- Tests and comments that named routing.js name the new path (gateway's
  antigravity_rest and loop_guard, codeassist.go, usage.go,
  web_compress, group_member_info, assets_revalidate, font-cascade,
  win-fonts, three routing-*.test.cjs). builtins.test.cjs and
  builtins_test.go count seven built-ins and switch Routing off: its
  tabs go, the page shown stays.
- docs: plugin-runtime.md, gui-shell.md, gateway-routing.md.

Run, first on origin/main 3ec45e715, then after rebasing onto af27b70b4
(main's routing.js, css, app.js and i18n.js changes since were carried
into the moved files; its new Routing words, as the rules' conditions,
are in the plugin's i18n.js):
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- go test -count=1 ./internal/gui ./internal/gateway ./internal/usage
  ./internal/pluginrt ./plugins/...: ok (gateway 1800s under load,
  -timeout 45m; gui with -skip TestMainWindowCorners, #1936).
- All 193 GUI test files, 3 at a time at load ~250, Chromium and WebKit,
  at the Usage commit on 743fcc035: 185 and 186 green. Every red run
  alone here and on a just-fetched origin/main c524bc018:
  - the same on main: routing-model-rest (#2115), routing-wb-restricted
    (#1905), usage-agents-hide (11 of 16 in both, #2211), usage-fold
    (#2163: 12 of 14 here, 9 of 14 on main over 7 runs, the same 4px),
    quota-count-wrap and quota-name-translated in WebKit (#2228);
  - red only under load, green alone on both: routing-flood (#2215),
    routing-log-icons, usage-ledger (#2211), and three plugin-* files
    whose tree was rebased under them mid-run.
- days-fit, failed-open, side-calls and burst-speed, red on main after
  cf455ebd5, are fixed before this commit (#2134, d692b2548).
2026-10-15 01:32:12 +08:00
hhh2210 2a99e7a429 gui: keep refreshed cards when their account identity changes (#1630)
The ce5d9f9d4 review correctly restored replies whose account was first
named by a refresh. Its full-list fallback bypassed the ordering guard:
an older GET could restore the unnamed card, or the fallback could undo
another card's completed refresh.

Apply the fallback to its provider's cards (a remote summary's namespaced
children included), keep other providers, and preserve card refreshes that
completed since the request began. Mark the replaced keys as well as the
new cards, so an old response cannot resurrect the unnamed summary. Only
a serialized whole-page read retires the markers it no longer needs.
No changes to account reading, authentication, throttling or auto-refresh.

Verification on macOS arm64, Go 1.27.2, Bun 1.4.3, isolated homes/APIs:
- On ce5d9f9d4, four new ordering cases fail: renamed account vs old GET,
  crossed card replies, a pending GET after another provider's completed
  refresh, and a remote summary becoming child cards. All nine now pass.
- The real browser page on ce5d9f9d4 reverts 61% to 28% after the late
  response. Named and unnamed cards now pass in both engines/all five
  languages. 21 related frontend files pass 184/184; the whole GUI suite
  was not run. The remote-card suite caught a missing namespace case in
  the first draft; corrected and the 21-file run repeated successfully.
- Three-platform vet and darwin/linux-nogui/windows builds pass. Final
  internal/gui Go tests pass after the namespace correction. Diff clean.
- Full go test -tags nogui ./... completed. The first isolation wrapper
  made TMPDIR too long for the omarchy Unix sockets; shortening TMPDIR
  makes that package pass. The unresolved failure is the already recorded
  TestPluginSOCKSProxy HTTPS/dead-SOCKS response-vs-error mismatch. No Go
  source or proxy paths changed; no full-suite-green claim.

Not tried: the native app or real account identity changes. These are
controlled response-order regressions, not the cause of the user's clicks
on the noninteractive reset-date glyph.

Review record (magpie maintainer session, on origin/main 429698f96, then
rebased onto fad96ea0f; sandbox HOME, private GOCACHE):
- gofmt -l clean; go vet darwin/linux/windows and the three builds pass.
- go test -tags nogui ./...: 52 packages ok at once. agent and gateway hit
  the 10m default under load ~190, middleware's TestFailOpen was slow and
  omarchy's sockets hit a long TMPDIR; rerun with a short TMPDIR and
  -timeout 40m all four are ok. internal/gui ok again after the rebase.
- quota-refresh-order: on main's app.js cases 6-9 fail; patched 9/9.
  Broken by hand, each red: no marker on replaced keys (6,8,9); an older
  reply may restore a removed key (6,8,9); fallback skipping
  keepRefreshedQuotas (7); remote children not matched (9); markers
  retired inside keepRefreshedQuotas (8); belongs() always true (8).
- Full GUI suite in chromium and webkit, 5 languages, 1100/420. Reds also
  red on main alone: usage-agents-hide and usage-fold (#2211, #2163),
  usage-sum-whole ja/de 780px (#1864: main 1/3, patched 2/3; that test
  serves no quotas). quota-name-translated and quota-pace goto timeouts
  under load passed rerun. After the rebase quota-refresh-order and
  usage-card-refresh pass 21/21 in both engines.
- Not tried: the native app or a real account whose identity changes.
2026-10-15 00:44:51 +08:00
yetone 743fcc0351 gui: a click at the view's top keeps the clicked control under the pointer, not the view at its top (#2134)
cf455ebd5 (#2134) kept a view that was at its top when clicked at its
top, whatever came in above what was clicked. That fixed the 2px slide
of Settings' Version row, but on Routing a day picked with the view at
its top brings that day's stage in above the bar (~138px), and the bar
was pushed down out from under the pointer. routing-days-fit ("picking
a day moved the bar") and routing-failed-open ("picking the request
moved the page") went red on main from then, 4 of 4 each in Chromium;
routing-side-calls 2 of 2.

The rule, decided: a view at its top stays at its top only while what
was clicked moves less than half its own height, so it is still under
the pointer. Anything larger above it is scrolled past, and the control
is held where it was clicked as before cf455ebd5. hold()'s comment, the
click guard's header and gui-shell.md say so.

Run on origin/main 7f968b95d, at load ~220-300, and again after moving
onto origin/main a36319d60 (no change to the click guard between):
- routing-days-fit 12/12, routing-failed-open 8/8, routing-side-calls
  4/4, update-auto 10/10, update-restart 22/22, in Chromium and WebKit.
- Broken by hand: with the old `h.top && want > 0` line, days-fit and
  failed-open go red (as on main); with the at-top rule removed,
  update-auto goes red (#2134's 2px).
- The click guard's GUI set (211 files that click and scroll), 4 at a
  time in Chromium and 3 in WebKit, at load ~300: Chromium 208 green,
  WebKit 207. The rest, run alone on this tree and on origin/main:
  routing-keys-fold (#1612), routing-model-rest (#2115) and
  routing-wb-restricted (#1905) fail the same on main;
  routing-flood (#2215) and sessions-folder-delete (#2218) failed once
  under the load and pass alone, 2 of 2 here and on main a36319d60.
- On a36319d60: routing-days-fit, routing-failed-open, update-auto and
  routing-side-calls green in Chromium and WebKit.
2026-10-14 23:27:46 +08:00
hhh2210 86cc7ac56d usage, gui: keep refreshed cards and distinguish deferred readings (#1630)
A card refresh and a whole-page quota read could replace each other's
entire snapshots. An older GET arriving after a successful refresh put
the old number back on screen; two card refreshes could undo each other.
Apply each POST's requested card alone and retain completed card readings
against whole-page requests that began before them. Later reads can still
update or remove cards. Failed refreshes do not block background results.

A saved Claude account not asked for, or allowances held by When I ask,
could also show "couldn't be read just now" without making a request.
Carry readDeferred through the cached card and CLI/gateway report, and
give that state a separate translated notice. Keep original read times,
network-failure notices and authentication errors. Automatic saved-account
reads and the existing 30-second floor are unchanged.

Verification (macOS arm64, Go 1.27.2, Bun 1.4.3; isolated homes/API fixtures):
- On base 2c5db1c6, quota-refresh-order.test.cjs fails three cases:
  old whole-page replies restore 0 over 32; crossed card replies restore
  0 over the other card's 61. With the fix, 4/4 pass.
- TestQuotaDeferredReadIsNotFailure fails the three deliberate-skip cases
  on the base, passes here; checks real read failures and auth refusals too.
- Original assets fail the new browser case with "a request not made was
  described as failed". Related frontend checks pass 71/71, including the
  real card button in Chromium and WebKit across en/zh/zh-TW/ja/de. The
  extra locale/i18n checks pass 12/12. The full GUI suite was not run.
- Provider tests for deferred/kept/saved readings pass -race -count=20.
- gofmt and git diff --check clean. Full vet on darwin, linux nogui and
  windows; darwin build, linux nogui build and windows build pass.
- go test -tags nogui ./... completed: every tested package passed except
  internal/plugin's TestPluginSOCKSProxy. HTTPS through a dead SOCKS proxy
  produces "proxyconnect tcp: 502 Bad Gateway: socks connect ... refused",
  while the test expects an HTTP 502 response. Reproduced unchanged on
  freshly fetched upstream 68552188 in an independent worktree; already
  reported in #1630. The full suite is not green; no proxy change here.

Not tried: the patched native app with a real Claude account. The response
ordering is injected in tests, not captured from the reported incident;
this does not establish that every intermittent refresh failure is fixed.
2026-10-14 21:54:12 +08:00
yetone bfef5d51b5 gui: Routing is back to v0.1.1231's layout; reverts dae2618ad (#1354)
v0.1.1233 shipped community PR #1354 (dae2618ad), which put "How the
last request was routed" in a right column beside the stage on wide
windows, split the context card into overview/contents columns, and
replaced the context card's own head with one lazily built disclosure
header. Two users on Discord asked for the old page back: wongxy
("这是哪个人才要改成这样的,丑死了", "UI方面的需求响应要克制一点", with a
screenshot of the new page) and molvqingtai ("v0.1.1231 没有这个问题").
The owner delegated the call: Routing goes back to v0.1.1231's look.

Only the lazy construction of the context body was a candidate to keep,
as it is invisible. It doesn't separate cleanly: it is built on the new
unified header (ctxSummary in the closed state, ctx-body/ctx-overview in
the open one), which is itself the visible change. So this reverts
dae2618ad whole: assets, its doc section, its README entry, the new
routing-context-layout test, and the test edits that existed only for
the new layout (wheel-scrolling to rows the right column pushed down,
mobile-web's skip of Routing in the pixel comparison). No later commit
on main is a follow-up of it.

Later commits touching the same files are kept: 20350dafa's subagent
reason in routing.js and README entry, a7a38193f/5fc2f87d1's gui-shell.md
lines, 00afcf97a's README entry. routing.css and context.js are now
byte-identical to v0.1.1231; routing.js differs only by later features
(#1068 folders, subagent reasons).

Run (worktree on origin/main 3ec45e715 + this revert):
- Routing page screenshots against v0.1.1231's assets with one counted
  request (the .rt card): Chromium and WebKit, en/zh/zh-TW/ja/de, 1100
  and 420 wide, plus 1440/1800 in en/zh: 0 pixels differ in all 28.
  origin/main differs in all of them (the folded header, the columns).
- node --test routing-*, panel-routing*, group-fold, held-animations,
  phone-rows, context-*: 1025 of 1034 pass. The 9 reds are
  routing-keys-fold's "a request that comes flies to the fold" (WebKit,
  and Chromium de) and routing-model-rest's "Try now" reach. Both files
  run alone fail the same way on origin/main bda271999 (12 fails there,
  11 here, different cases of model-rest each run), at load average
  ~350 from other sessions; filed as #1612 and #2115.
- mobile-web (pixel baseline) with BASE_REF=dae2618ad^: every phone
  case and Routing's desktop compare pass; the 8 reds are all Settings,
  changed since by #2073's colorblind switch, not by this.
- gofmt -l, go vet (darwin, linux nogui, windows) and
  go test -tags nogui ./internal/gui pass.
Not tried: the native Wails window; the complete GUI suite.
2026-10-14 18:07:59 +08:00
yetone 7d4ad7c628 gui: the menu bar's total is every token, cache too, marked Σ, as the Requests tab sums it (NextCommit)
NextCommit on Discord: the menu bar's usage showed only input tokens, and
more input than the Usage page. It showed input + output, unlabelled, so
it read as the input and came out above the page's input. And it was summed
as the Overview sums (usage.SummarizeTop: the gateway's calls only, cache
aside), while a click opens the panel's Usage tab, which sums the ledger
(the agents' own session-file calls too) and counts the cache's tokens
in its Tokens. Two numbers under one name.

- trayTotalSum is the ledger's cached sum, usage.QueryPage(p, {}, 0, 1).Sum,
  the one the panel's Usage tab and the window's Requests tab show.
- The cell's top row is every token (in + out + cache read + write, as
  allTokens) prefixed Σ; the cost stays under it. The tooltip spells out
  "N tokens (a in · b out · c cached)".
- With the window as the tray's, a click opens the Requests tab at the
  period (quotaView), not the Overview, which sums differently.
- docs/reference.md and gui-shell.md say so.

Run:
- TestTrayTotalIsTheLedgers (new): a Codex session-file call of 1000 in,
  200 out, 8000 cache read; the menu bar's sum equals ledgerPage's and the
  cell reads Σ9.2K. With trayTotalSum put back to SummarizeTop it fails
  (menu bar all zeros, ledger 1 call).
- TestTrayTotals/BesideCards updated for Σ, the cache and tab=requests.
- go test -tags nogui ./internal/gui (sandbox HOME via the package): ok.
- tray-totals, tray-usages, tray-cell-click .test.cjs, chromium and
  webkit, five languages, 1100 and 420: 70 pass.
- The Mac cell rendered with trayImagePNG and looked at: "Σ6.3M" over
  "$3.40", "Σ47M" alone, both inside the row width.
- gofmt -l, go vet darwin, GOOS=linux -tags nogui, GOOS=windows; builds.
Not tried: the real menu bar on the reporter's data.
2026-10-14 17:29:43 +08:00
chenluzhou 5fc2f87d13 gui: in colorblind mode a quota legend key is its window's dash, the even paces are dotted, and the balance curve and the good grade keep their look (#2073)
A review of db25c4ee found that colorblind mode reached past the quota
curve and that its legend shapes matched nothing on the plot:

- The fallback rules `.qc-line:not([data-series="0"])...` and the
  matching `.qc-key` rule also matched elements with no data-series, so
  the balance curve's solid line became dashed like its fitted line, and
  its legend dot became a ring in var(--c4) while the line was var(--c1).
- A filled circle, hollow square or diamond in the legend appeared
  nowhere on the plot, so it didn't tell a reader which line was which.
  Series 3 and up shared one dash and one shape.
- The 7-day line's 6 2.5 dash sat beside its own 3 3 dashed even pace in
  the same colour, while the tooltip still said "Solid: what was left.
  Dashed: an even pace".
- The Context tab's "good" grade took var(--c2), which the palette turns
  amber, next to "fair" in --amber (dark #fbbf24 vs #f2b544).
- omarchy.css made the first legend dot round with colorblind mode off.
- The legend set its colour twice (--sw and background) and undid it
  with !important.

Now, with colorblind mode on:

- drawQuotaPlot tags each window's path.qc-line and line.qc-even with
  data-series (its index mod 7, the same slot as its colour), and the
  quota legend tags its key. Seven dash patterns, one per slot, apply to
  `:is(.qc-line, .qc-dash)[data-series=N]`, so a line and its key can't
  drift apart. Nothing else sets data-series, so the balance curve is as
  on main.
- Each quota legend key shows a 22px sample of its window's line
  (svg.qc-sample > line.qc-dash) in place of the dot; with the mode off
  the sample is hidden and the dot is as on main.
- The even paces are dotted (0 4, round caps), unlike every window's
  dash; the curve's tooltip, set in box.draw, says "Each window's line
  has the dash shown beside its name. Dotted: an even pace, ..." in en,
  zh, zh-TW, ja and de.
- `.ctx-ring.good` / `.ctx-grade-word.good` take --c1, the palette's
  blue.
- omarchy.css is back to main's; the legend's `--sw` and !important are
  gone.
- The Settings note now says what the mode does ("Colorblind-safe chart
  colors, and each allowance window's line in a dash of its own"), and
  gui-shell.md says the note is the Off/On control's tooltip, as the
  code has it.

Run on db25c4ee + this change (upstream/main f074996d9 unchanged),
Playwright 1.58.2, Chromium and WebKit:

- New tests fail without the change: with db25c4ee's assets the 10
  "colorblind mode separates quota windows by colour and dash, in the
  legend too" (both engines, 5 languages), the 2 "seven windows have
  seven dashes" and the 2 balance-curve "colorblind mode leaves the
  balance curve's solid line, dashed fit and dot" fail, 14/14 (e.g.
  "key 0 shows its line, not a dot"). Broken by hand on this change,
  each is caught: the good-grade rule removed ("good and fair too close:
  light: {good: 41.5, fair: 26.0}"), the dotted pace removed (pace dash
  equals its default), the colorblind tooltip removed ("the tooltip names
  the dashes and dots: Solid: ..."), the :not() fallback put back ("the
  balance stays solid: line 2.5px, 2px"), series 3-6 given one dash
  ("every window its own dash: 4 !== 7"), the sample's dash rule dropped
  (key 1's dash).
- quota-curve.test.cjs 27/27, balance-curve.test.cjs 6/6; the colorblind
  tests 14/14 three runs in a row at --test-concurrency=4.
- balance-currencies, context-window, quota-read-at, settings-general,
  usage-ledger-chart, api-key-theme, gui-de, gui-ja, gui-zh-tw,
  i18n-keys, keep-awake, lightweight, omarchy, seg-contrast, segs-glide,
  settings-search, settings-sections and usage-ledger*: with the two
  above, 305/315. The 10 failures are settings-general's WebKit cases
  ('English\n' for 'English' from #langPick's innerText, a span and an
  svg), which fail the same 10 on upstream/main f074996d9 in this
  Playwright's WebKit; not fixed here.
- node --check app.js, i18n.js and both tests: clean.
- Sandbox HOME, GOPATH/GOMODCACHE/GOCACHE pinned, set -o pipefail:
  gofmt -l on the changed .go files prints 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 and
  go test -tags nogui ./... all exit 0 (the only output is the existing
  cgo -Wenum-conversion warning in trayimage_darwin.go);
  TestSettingsColorblindMode passes.
- Not run: the whole GUI suite (707 files; only the files above), the real Linux app under
  WebKitGTK, and a check by a colour-blind reader.
2026-10-14 16:28:05 +08:00
chenluzhouandDevin a7a38193f5 gui, settings: colorblind mode for quota curves and chart series (#2073)
In Usage -> Allowances, the 5-hour and weekly quota curves and their
legend dots took --c1 and --c2, which are both shades of blue in light
(#4f46e5, #0ea5e9) and dark (#a5b4fc, #7dd3fc) themes, with identical
solid lines and 7px round dots and the 5-hour line dimmed to .45 over a
week (#2073, chenlz22550).

- settings.Colorblind ("colorblind" in settings.json), passed in GET
  /boot.js when on and applied before first paint by theme.js and on
  every state/settings read by applyPrefs as data-colorblind="1" on
  :root.
- Settings -> General adds a Colorblind mode row (#colorblindRow,
  #colorblindSegs) under Appearance, in en, zh, zh-TW, ja and de.
- Under :root[data-colorblind="1"], --c1...--c7 switch to an Okabe-Ito
  qualitative palette in both light and dark themes so adjacent series
  differ in hue and lightness across quota curves, tray sparklines, the
  usage ledger and context charts.
- drawQuotaPlot and quotaCurve's drawLegend tag each series with
  data-series on path.qc-line and .qc-key; in colorblind mode series 0
  and series 1+ use distinct stroke-dasharray patterns and legend swatch
  shapes (filled circle vs hollow square/diamond), and .qc-line.qc-short
  keeps .85 opacity so short windows stay legible over a weekly span.
- docs/subsystems/gui-shell.md documents the boot and Settings contract.

Run (on origin/main f074996d9, sandbox HOME, pinned GOPATH/GOMODCACHE/GOCACHE):
- quota-curve.test.cjs in chromium and webkit (en, zh, zh-TW, ja, de):
  25/25 pass; with HEAD's assets via MAGPIE_QUOTA_ASSETS, all 10 new
  colorblind subtests fail (TimeoutError waiting for #colorblindRow).
- TestSettingsColorblindMode (new in internal/gui): passes; fails when
  boot.js omits colorblind.
- i18n-keys.test.cjs, gui-zh-tw.test.cjs, gui-ja.test.cjs,
  gui-de.test.cjs: 12/12 pass.
- settings-general.test.cjs (chromium 10/10), settings-sections.test.cjs,
  settings-search.test.cjs, omarchy.test.cjs, lightweight.test.cjs,
  keep-awake.test.cjs, segs-glide.test.cjs, api-key-theme.test.cjs,
  seg-contrast.test.cjs, balance-curve.test.cjs,
  usage-ledger-chart.test.cjs in chromium and webkit: 140/140 pass.
- node --check on app.js, theme.js, i18n.js: clean.
- gofmt -l: clean. With set -o pipefail: 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 clean.
- go test -tags nogui ./...: all packages ok.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-14 16:28:05 +08:00
Zhu Wang dae2618ade gui: make the Routing context lazy and align wide cards (#1354)
* gui: make the Routing context lazy and align wide cards (#1354)

Rebuild the context and wide-layout change on main e1b70c13 following
the Oct 13 review. Keep the complete request story, original heading,
visible stage caption and main's unchanged line/logo retention.

Use one context header, construct its body only while open, migrate the
existing fold choice and retain live card updates and the text viewer.
Align the stage/story and overview/contents splits within the page's
existing width cap. Keep the narrow stage sizing and prevent flex shrink
from moving the header when context contents appear.

Three-platform vet and builds and the sandboxed nogui suite passed.
Base assets fail the new context test because a closed card constructs
the detail grid (1 instead of 0). Focused disclosure checks passed;
the complete GUI suite is still running and is tracked in the PR body.

* gui tests: exercise the new Routing layout with user scrolling

Open the lazy context explicitly for its retained-animation check and wait for page entrance animations as well as cells. Reach the group Cancel button and history day with user wheel input rather than relying on forbidden click scrolling. Until the baseline contains the new Routing wrapper, keep its intentional desktop layout out of the unchanged-page pixel comparison; the focused layout matrix covers it and mobile fit still checks Routing.

Validation: group-fold and held-animations passed all 8 cases; phone-rows passed all 10 cases across five languages and both engines; mobile-web passed all 30 cases. git diff --check and JavaScript syntax passed. The complete GUI suite is still being recorded on unchanged d6d5738a assets. Library switch failures are independently reproduced on e1b70c13 assets and tracked by upstream #1609; they are not claimed as passing.

* gui tests: scroll to narrow Routing history before selecting it

The visible full request story can leave a historical request below a narrow window. Reach the day and request row with wheel input before selecting them, while retaining the app scroll guard and all cancellation and failure-colour assertions.

Validation: all 37 checks in routing-agent-gone and routing-agent-hue-not-red pass across both engines, four/five languages and 420/1100px widths. The whole GUI run had exposed the two WebKit German 420px click-scroll failures. git diff --check and JavaScript syntax passed.

* gui: keep context disclosure usable while the next prompt is read

Keep the last available live prompt separately from the render key. Opening or closing the unified header can redraw that carried context while a new request has no prompt yet; clearing a render key for a disclosure no longer removes the entire card. Explicitly picked requests still start fresh, and unavailable or completed requests clear the carried data.

Validation: before the fix, the new pending-prompt disclosure regression fails because the carried context becomes invisible. After the fix, all 134 context disclosure, saved-choice, Usage-link, live patch, every-frame and provider-logo checks pass in Chromium and WebKit across five languages and desktop/phone widths. Native macOS, Linux nogui and Windows builds, syntax and git diff --check pass. The complete GUI run is recorded separately with unresolved existing failures linked in the PR description.
2026-10-14 15:27:59 +08:00
yetone 3a7d0314a9 usage: a window's Pace as a number on its card, and in the menu bar when asked (fflake33)
fflake33 on Discord asked for the pace as a figure, "+12%" or "−8%"
against an even pace through the window, on the Usage cards and in the
menu bar.

- provider: QuotaWindow.Pace(readAt, now) is the share used (0-100) less
  the share of the window gone by, from Bounds (reset less span; a
  month's window a calendar month); none for an unlimited window, one
  whose span or reset isn't known, or outside it. WithWindowStarts sets
  startsAt on copies of the cards for the GUI (the caches' cards are
  left alone); /api/usage/quotas and its refresh send it.
- Usage page: "Pace +20%" on the reset line after the wait (quotaPace,
  paceLine), its sign turned with the meter in Left mode, amber while
  more is used than an even pace would have, what it means in its
  tooltip. Past cycles and windows with no known start show none.
- Menu bar: Settings > Menu bar pace (settings.TrayPace, off by default;
  hidden on Windows, whose tray shows no text) puts " +12%" beside each
  figure ("42% −14%", at most 10 runes, trayRowMax) and "pace −14%" in
  the tooltip. KeepOwn keeps it device-local like the other tray
  settings; the Settings save keeps it (prefsKeep).
- Strings in en, zh, zh-TW, ja, de. gui-shell.md says it.

Run:
- go test -tags nogui ./internal/provider ./internal/gui ./internal/settings
  ./internal/usage: ok; ./internal/davsync: ok (now covers TrayPace;
  red with TrayPace taken out of KeepOwn). go test ./internal/gui -run
  Tray (darwin, with the tray image tests): ok.
- New TestWindowPace, TestWithWindowStarts (input not mutated),
  TestTrayUsagePace (off unchanged, used and left, rows, tooltip).
- quota-pace.test.cjs, chromium and webkit: 4 pass; cards in en, zh,
  zh-TW, ja, de at 1100 and 420px, used and left, amber, tooltips, no
  sideways scroll, a click moves nothing; the Settings row in all five
  at both widths, On posts trayPace, a currency save keeps it, no
  scroll; hidden with no card and on Windows, shown on Linux. Red with
  paceLine not called, with trayPace out of prefsKeep, and with the
  Left-mode sign not turned.
- gui-de, gui-ja, gui-zh-tw, i18n-keys: 12 pass; tray-bird 6, quota-holds
  2, quota-read-at 4 pass.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean.
Not tried: the real menu bar on a Mac or Linux tray.
2026-10-14 13:02:48 +08:00
yetone 2076943915 plugin: a plugin declares its own switches, shown in its provider's editor and read by the plugin (#2038, Vocllum)
Vocllum asked that a plugin can offer the user generic on/off options
without magpie knowing what each one is for. A plugin now declares them
on its auth hook, beside checkin:

  auth.options: [{ key, label, description?, default?, confirm? }]

and reads the user's values through input.magpie.option(provider, key)
or input.magpie.options(provider). Each call reads the current values,
so a change reaches the plugin without a restart. magpie only keeps the
value and hands it over: nothing is scheduled or run when an option
changes. The check-in switch (settings.pluginCheckins) and the check-in
plugins are unchanged.

- host.js: optionsOf keeps a key matching [a-z0-9_-]{1,40} with a
  non-empty label, drops repeats, caps the label at 60 characters and
  the description and confirm at 300, takes default only when it is
  true, and keeps at most 16. The values come at init and through
  setProviderOptions.
- Go: plugin.Option, Provider.Options, OptionOn and SetProviderOptions
  (sent only to a host that is running). settings.PluginOptions is kept
  by the plugin's provider id, then the key. POST
  /api/settings/plugin-option {provider, key, on} checks the key the same
  way and hands the values to the host. The generic settings save keeps
  them, as it keeps PluginCheckins. /api/providers' plugins[].options
  carry each option's resolved `on`.
- GUI: a "Plugin options" field in a plugin provider's editor. Each
  option is a segs Off/On beside the plugin's label and description, put
  in with textContent. A confirm text is asked through confirmAction
  before turning an option on. Changes wait for Save, which posts each
  one before the provider. Strings are added for zh, zh-TW, ja and de.
- Docs: provider-plugins.md (a new section), reference.md, gui-shell.md
  and the tests README.

Run:
- TestPluginOptions (a real host with testdata/options). Red with the
  old host.js (no options listed) and red with setProviderOptions turned
  into a no-op (the plugin still reads the old value).
- TestPluginOptionSetting and TestSettingsSaveKeepsWhatItDoesNotSend.
  Both red with the generic save's PluginOptions line removed.
- plugin-options.test.cjs: 22/22 in Chromium and WebKit, at 1100 and 420
  wide, in en, zh, zh-TW, ja and de. Red on the old app.js (no field).
  The screenshots were looked at: long text wraps and the page has no
  sideways scroll at 420.
- provider-concurrency, plugin-signin, plugin-checkin, provider-price-rate
  and plugin-move-unserved: 68/68.
- go test ./internal/plugin/... ./internal/settings/... ./internal/gui/...
  ./internal/provider/..., gofmt -l, and go vet on darwin, linux
  (-tags nogui) and windows.

Not tried with a real community plugin, since none declares options yet.
The check-in row doesn't take a plugin-declared label or hint; it is
left as it was.
2026-10-14 08:50:41 +08:00
yetone 8da304767a gui: Library is a plugin's page, its script, style and words in plugins/library
P2 of docs/subsystems/plugin-runtime.md, the second page after Sessions.

- library.js and library.css move to assets/plugins/library/ (client.js,
  library.css). The script registers with the kernel
  (magpie.plugin("library")) and adds its page to the "page" slot. Its
  hooks: open and relang load, redraw, close (its modal), dirty, discard.
  What it set up at load (list scroll and resize, the modal's backdrop
  and Escape, beforeunload, the stuck header, a quiet reload on focus)
  runs in mount.
- app.js calls those through magpie.call instead of window.loadLibrary,
  redrawLibrary, closeLibraryModal, libraryDirty and discardLibrary. It
  no longer lists library in its title map, hide loop or OPEN_VIEWS; the
  kernel's pages are in them.
- index.html: <main id="view-library"> goes, the kernel makes it.
  library.css keeps its place in the cascade.
- The 560 strings only Library says move from i18n.js to
  plugins/library/i18n.js (4 languages). i18n.js: 18826 → 16584 lines.
- plugins/library/library.go lists the client files.
- Tests that read i18n.js for a Library string read strings.cjs (i18n.js
  and the plugins'): 8 library tests and mcp-editor-cancel,
  mcp-oauth-app, mcp-signin-health. font-cascade, win-fonts and
  assets_revalidate_test.go name the new paths.
- "Check again" stays in i18n.js: Library said it alone when the words
  were split, and a5d72a095 (Settings' search keys) says it too since.
  i18n-keys has a new test, "a plugin's words are its own": a key in a
  plugin's i18n.js that any file outside the plugin's folder says fails
  it, naming the file. It was red on this key, and search-keys.test.cjs
  said "Check again" had no zh translation.
- docs: library.md, gui-shell.md, plugin-runtime.md.

Run, at this tree:
- 101 GUI test files touching Library, skills, MCP, the plugins, the
  shell and every language (gui-de/ja/zh-tw, i18n-keys, page-width,
  view-no-sideways, mobile-web, text-size, …): Chromium and WebKit, 4 at
  a time, all green but one. text-size's "zh: 100% picked at the foot"
  failed once in Chromium under load ("scrolled from 160 to 109 (max
  115)"); it passed alone, 6 at once here and on origin/main 8f34bbcd1,
  and at 6× and 12× CPU throttling. It's the Settings page, already
  "fixed" by 50dd39104, so I filed it as #2058.
- After rebasing onto origin/main 75cbc7e1e: i18n-keys, search-keys,
  library-mcp-tools, library-all, gui-de, mono-icon-redraw,
  group-first-token, Chromium and WebKit, green.
- go test ./internal/gui/ ./internal/pluginrt/ ./plugins/...; gofmt;
  go vet on darwin, GOOS=linux -tags nogui, GOOS=windows: clean.
2026-10-14 08:33:25 +08:00
yetone 1eaf1e890a gui: Sessions is a plugin's page, its script, styles and words under assets/plugins/sessions (P2)
The first page of P2 to leave app.js's core. sessions.js and sessions.css
move to assets/plugins/sessions/ (client.js, sessions.css). The page
registers through the kernel as magpie.plugin("sessions"): mount takes its
<main>, which the kernel now makes, open and relang read it again, and
reveal is the Usage page's way in. window.loadSessionsPage and
window.openSessionOnPage are gone. app.js reaches the page only through
magpie.call, and show() takes a page's title from its part. The plugin's
manifest lists i18n.js, sessions.css and client.js.

Words: the kernel's magpie.strings(dict) adds a plugin's words to I18N.
A key that is already there is logged and not taken, since the later one
would silently win. The 65 keys only the Sessions page says (own-keys over
every asset, Go and index.html) move, as written, from i18n.js to
plugins/sessions/i18n.js. tests/strings.cjs reads i18n.js and every
plugin's i18n.js as the page has them. gui-de/ja/zh-tw use it, and
i18n-keys now checks that no key is said twice across files and that a
plugin's words are in every language. TestBuiltinClientsLoaded takes a
.css entry as a <link> in <head>, and a script between kernel.js and
app.js.

Docs: plugin-runtime.md (Words, Pages moved out: Sessions), gui-shell.md,
gateway-sessions.md.

Run:
- go test ./internal/gui/ ./internal/pluginrt/ ./internal/gateway/: ok.
- gofmt clean. go vet darwin, GOOS=linux -tags nogui and GOOS=windows on
  gui, pluginrt and plugins: clean.
- GUI, in both chromium and webkit, 40 files, all green:
  - the sessions-* and sess-* tests, session-identity, routing-sessions,
    account-mask-sessions, usage-session*, gateway-conversations;
  - plugin-kernel, the plugin-move* tests, font-cascade, win-fonts;
  - i18n-keys, gui-de, gui-ja, gui-zh-tw.
- session-terminal's red under parallel load is the same on origin/main
  591ed58b5. It is fixed at its cause in the commit before this one.
2026-10-14 08:33:24 +08:00
yetone 2d8f2a86a5 sessions: Kimi Code sessions open as a transcript (#2056)
infinitr0us: a Kimi Code session on the Sessions page had no transcript
to open. HasTranscript now lists kimi, and kimiTranscript reads the
session's main wire.jsonl:
- protocol 1.4/1.5: turn.prompt and turn.steer (a prompt not from the
  user, a skill's activation or a background task's news, is folded as
  context), and the loop events content.part (text, think), tool.call
  and tool.result, a result named for its call. These are there for
  every session, finished or running; agent.message.appended (1.5, only
  at a turn's end) and the timed context.append_message records say the
  same again and are passed over.
- kimi-cli imports (1.0, and the head of a ses_* session Kimi Code
  reopened): the untimed context.append_message records, with an
  assistant's toolCalls in both shapes (name/arguments and OpenAI's
  function.{name,arguments}).
Search and markdown export read the same parts.

Run:
- TestKimiCodeTranscript on the #1607 reporter's wire files in testdata
  (1.4, a cancelled 1.4, an early 1.5 started by a skill, a failed 1.5,
  a kimi-cli import), and TestKimiCodeTranscriptOrder on a synthetic
  file in the same record shapes, exact part order plus SearchSession.
- Broken by hand: kimi out of HasTranscript fails both tests; reading
  the timed context.append_message records fails both (user/text 9,
  not 3).
- A nogui build's `magpie web` under a sandbox HOME, KIMI_CODE_HOME on
  the reporter's whole zip (8 sessions, the July subagent session and
  a reopened ses_* among them): all 8 listed with a transcript;
  /api/sessions/transcript gave 105, 13 and 205 parts for June, the
  reopened ses_* and July; the markdown export worked.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows;
  go test -tags nogui ./internal/sessions/ ./internal/gui/.

Not tried: a live Kimi Code session on this machine (none here; the kimi
installed is kimi-cli 1.52.0), the GUI's look of the transcript, WSL.
A subagent's own wire file isn't shown; the main agent's is.
2026-10-14 08:28:52 +08:00
NorethSea 56fcd1dc27 usage: each account picks a recorded allowance cycle beside its curve, meters and legend following it (#2009, NorethSea)
Let each account choose completed cycles beside its allowance curve. The
meters, sampling dates, plot and legend follow that cycle. Missing readings
stay unknown, and current account actions and whole-window estimates are
not presented as historical data. Fixed-deadline refills preserve cycle
boundaries alongside natural and early resets.

Keep the upstream whole-window estimate for the current view; no separate
price endpoint or duplicate estimation is added.

Verified on the integrated tree based on origin/main a75de4c2:
- 155 allowance, translation and scroll UI tests pass in Chromium/WebKit.
- Quota history race tests pass with count=3.
- macOS/Linux/Windows vet and builds pass.
- New Go cases fail without the unchanged-deadline refill handling; the UI
  case fails against upstream assets because the picker is absent.
- Real local allowance snapshots confirm cycle and meter switching.
- Full Go suite has one failure: TestPluginModelListThroughAccountProxy
  exceeds its context deadline. Other packages, including provider, usage
  and gui, pass. No release or complete-suite pass is claimed.

Reviewed and landed by yetone's agent from NorethSea's commit 69021d2c8,
cherry-picked onto origin/main (README conflict only: both appends kept).
Run at this head: go test -tags nogui ./internal/provider -run Quota,
-race -count=3 -run QuotaHistory, gofmt, GOOS=linux/windows go vet;
TestQuotaHistoryUnscheduledResets goes red with the refill rule removed.
GUI: quota-*, usage-*, balance-*, panel-usage, tray-*, click-scroll,
i18n-keys, gui-ja/de/zh-tw in Chromium and WebKit: 923/926; the three
reds are usage-sum-whole (also red 3 of 4 runs alone on origin/main
591ed58b5, #1864) and a usage-ledger case that passes alone.
2026-10-14 05:32:03 +08:00
yetone 2dcc51417e plugins: the window gets a plugin kernel, and the Gateway page is the first page a plugin draws (P1)
P1 of docs/subsystems/plugin-runtime.md. P0 (3ccbe6bc1) gave built-in
plugins a manifest, plugins.yml and a switch; their pages were still
app.js's own code. Now the window has a kernel a plugin draws its page
through, and the Gateway page moved into plugins/gateway to prove it.

What changed:
- internal/gui/assets/kernel.js (new): window.magpie. A plugin
  registers with magpie.plugin(id, setup); ctx.slots.add("page", part)
  puts its markup where index.html's <template data-slot="page"> is.
  The shell calls its hooks through magpie.call, behind an error
  boundary: a hook that throws, or whose promise fails, is logged and
  its page shows "This page stopped working", what broke and Try
  again, while every other page goes on. ctx.ui is the kit (button,
  switch, the app menu, a settings row) and ui.form draws a plugin's
  settings from their schema. ctx.config / onConfig carry the settings,
  from boot.js before the first paint and from Plugins › Built-in after.
- internal/pluginrt/schema.go (new): a plugin's settings are a Go
  struct (Manifest.Settings); SchemaOf makes the JSON Schema the form
  is drawn from, and Validate is what SetConfig (config.go) takes into
  plugins.yml. Compose drops a hand-edited value the schema refuses.
- plugins/gateway: the Gateway page as a plugin, Essential and in use
  while a gateway key is there. One setting, callsPage (10/20/50/100,
  20 by default). Its client is plugins/gateway/{keys.js,client.js},
  moved out of app.js (and caller-keys.js) unchanged in behaviour.
- internal/gui: builtins.go takes POST {id, config} beside {id, on}
  and lists each plugin's schema and config; boot.js carries
  pluginConfig; /plugins/<id>/… files are served. Plugins › Built-in
  draws a plugin's settings rows under its switch.
- Docs: plugin-runtime.md has "The window's kernel (P1)"; gui-shell.md,
  subsystems/README.md and tests/README.md updated.

What was run:
- go test ./... (sandbox HOME, pinned caches): all packages ok;
  gofmt -l clean; go vet on darwin, GOOS=linux -tags nogui and
  GOOS=windows.
- New tests: TestSchemaOf, TestValidate, TestSetConfig,
  TestBuiltinConfig, TestBuiltinClientsLoaded;
  plugin-kernel.test.cjs (a page that throws breaks only itself and
  Try again draws it, at 1100 and 420 in en, zh, zh-TW, ja, de;
  callsPage from boot.js and from Plugins › Built-in), both engines.
- Broken by hand, each turned its test red: the boundary's catch
  removed; Try again not putting the page's markup back; the Gateway
  page's onConfig not re-reading callsPage; boot.js's pluginConfig
  ignored; SetConfig skipping Validate.
- The full GUI suite in Chromium and WebKit (node --test *.test.cjs).
  One red was this change's own. providers-fetching-retry lifts
  providersWhileFetching out of app.js, which now asks providersPage,
  and the lift lacked it. The test now lifts that too, and gains "a poll
  under the Gateway page, a plugin's page that reads with Providers,
  reads". That case goes red with providersPage dropped from the poll's
  guard.
- The reds that were on origin/main a75de4c21 too are fixed in their
  own commits after this one. Two of them came from P0's Built-in tab:
  nav-sub-unroll and plugin-check-github-limit.
2026-10-13 20:39:39 +08:00
yetone db0af71864 gui: the menu bar can show today's or the last 7 days' tokens and cost (#1984)
Settings → Usage → "In the menu bar" lists two more rows after the
subscriptions: "Tokens and cost today" and "Tokens and cost, last 7 days",
ticked and saved as a card is (ids "usage:today", "usage:7d" in
trayUsages; provider ids are [a-z0-9-], so the prefix can't collide). They
show beside the allowances or alone.

- trayusage.go: a total is a card built from usage.SummarizeTop(p, 0)'s
  Totals (the Usage page's own cached numbers, Input+Output as its
  tokensOf counts them): tokens over cost, in the currency Settings picks,
  "+" when some requests had no known price. On the Mac it is a Plain cell
  (no vendor logo; the bird beside it says whose it is); on Windows/Linux
  the tray's text label and tooltip ("Today in magpie / 1.2M tokens (912K
  in · 318K out) / ≈$3.40+ / 152 requests…"). Quotas aren't fetched when
  only totals are picked.
- Clicked, a total opens the Usage page's Overview at its period
  (quotaView → ?view=usage&tab=usage&period=…, read and dropped from the
  URL) or the panel's Usage tab at that period (panelUseFocus).
- Only today and 7d: the Usage page has no 3-day window, and a menu-bar
  number nobody can open in magpie at the same span would disagree with it.
- The pill names a lone total, and counts a mix as "{n} shown" rather than
  calling it subscriptions. Strings in en/zh/zh-TW/ja/de.
- docs/reference.md and gui-shell.md say so.

Run:
- go test -tags nogui ./internal/gui/ (sandbox HOME): ok. The new
  TestTrayTotals/BesideCards/TrayCount went red with each piece broken by
  hand (no Plain, no text branch, no quotaView branch, 3d accepted).
- tray-totals.test.cjs (new) plus tray-usages, tray-inuse,
  proto-menu-overflow (updated for the two rows), i18n-keys, panel-usage,
  allowance-open-read, tray-cell-click: 46/46 in Chromium and WebKit, five
  languages, 1100 and 420 wide. tray-totals fails 5/5 against the old
  app.js.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- The Mac cell image rendered and looked at (bird, "1.2M" over "$3.40").

Not tried: a real macOS menu bar, nor a Windows or Linux tray; the tray
tooltip is English, as the existing tray tooltips are.
2026-10-13 18:15:18 +08:00
yetone 6d7b440924 gateway: a request's ms end with its reply, not with what magpie writes down after it (#1939)
bytecode-x's full-suite failures (Millis 3772 for a stream that ended at
~450 ms; Flow 377, so DecodeOf's flow*HeldShare < window told 0/0) came
from after the reply: serve took call.Millis at its very end, after the
answered bookkeeping. answered() saves sticks and servedCandidate's
provider.NoteServed rewrites the last-answer file, both on disk. With
timing stamps added between the last content byte and call.Millis, 12
CPU burners alone gave at most 7 ms of tail (420 samples); with three
dd+sync writers beside them the block between "before served" and
"after served" took 0.7-1.5 s, the whole of the tail, while the stream
itself had ended. A user's busy disk meets the same: a paced reply reads
as one held back and shows no speed, and its duration grows.

- serve keeps `ended`, the time the last try's reply ended (when its Try
  is made), reset at each try; call.Millis is ended-start when a try was
  made, as before otherwise (a lane turn-away). The handed-on records
  of a refused try take try.Millis, the same end.
- decide_group's usage row is timed before servedCandidate, the same
  sibling.
- ttft_test's paced fixture left a leading "~" on its first event (it
  strips it only for i > 0), so those fixtures' first event was no SSE
  event at all (bytecode-x's second point): it now strips it without a
  gap.
- docs/subsystems/gui-shell.md says where a duration ends.

Run: TestSpeedEndsWithTheReply (new: holds sticksSaving for 2 s during a
paced reasoning stream; the request must still take >= 2 s, and its
Millis must not), TestReasoningSpeed*, TestBurstTellsNoSpeed,
TestCodexBackendBurstTellsNoSpeed, TestHiddenReasoning*, TestTTFT*;
full internal/gateway and internal/provider; gofmt -l; go vet darwin,
windows, linux -tags nogui.
Broken by hand: gateway.go's change reverted -> TestSpeedEndsWithTheReply
red ("the reply's ms 2001 count the 2s magpie took saving after it").
Not done: the bookkeeping itself still runs before serve returns, so a
client that waits for the response's end still waits for the disk;
moving those writes off the request path is a separate change. The
decide_group sibling has no test of its own.
2026-10-13 18:11:23 +08:00
yetone 3ccbe6bc15 plugins: a runtime for built-in plugins, and Plugins › Built-in to switch them (P0)
Lxxyx on X (https://x.com/Lxxyx_/status/2109506752656150974): magpie has
too much in it. This is P0 of making magpie's parts plugins, as DeepSeek
Harness does: a runtime, plugins.yml, and the first five built-in plugins
the user can switch off.

- internal/pluginrt: a registry (Register from init), a manifest (API
  caret range, Requires/Provides, Essential, InUse, Apply, Parts,
  Defaults) and Reconcile: the plugins no longer wanted, with whatever
  needs a service they provided, are disposed newest first; the wanted
  ones are applied once their services are there. A plugin that fails or
  panics is failed and the rest run. TestPluginsImportOnlyCore keeps the
  boundary: nothing outside plugins/ imports one, none imports another.
- plugins.yml (appdir.Config()): default → preset (essentials | all) →
  the user's rows → in use. A new install is written Essentials, a magpie
  that ran here before (settings.RanBefore) All, so existing users keep
  everything. Writes are locked, whole and keep a .bak; a file that
  doesn't parse is an error, never empty, and is never written over.
- plugins/groups, library, otel, sessions, warmups. In P0 a plugin off
  is the window's alone: its page, sections and rows (data-feature) leave
  the window; the gateway, TUI and CLI serve the same, nothing is
  deleted. One in use stays on.
- The window: Plugins › Built-in, the first tab, a switch per plugin;
  GET/POST /api/plugins/builtin; boot.js says which are off before the
  first paint. CLI: magpie plugin builtin [on|off <id>], plugin preset,
  plugin dump [--json].
- docs/subsystems/plugin-runtime.md, gui-shell.md.

Run: go test ./internal/pluginrt/ ./internal/settings/ ./internal/gui/;
gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows
go vet ./.... GUI: builtins.test.cjs in Chromium and WebKit, 5 languages,
1100/800/420; list-sort, mobile-web, routing-keys-fold, routing-sessions
pass. By hand under a sandbox HOME: a new install gets essentials, an
existing one all, a broken plugins.yml is refused and kept, dump works.
Full suite results after the rebase are in the push notes.
2026-10-13 16:19:13 +08:00
bingqilinweimaotai 1af326806f sync: magpie's setup syncs to an encrypted file in a GitHub repository, beside WebDAV and S3 (#1130)
A third sync kind: github://owner/repo[/folder] keeps the same sealed
backup WebDAV and S3 keep, as <folder>/magpie/magpie.magpie-backup in a
repository the user already has, written through GitHub's Contents API
with a fine-grained token of its own (Contents read and write), kept in
sync.json apart from the library's GitHub token. The token goes only to
api.github.com: a redirect anywhere else is refused, and the passphrase
may not equal it. Each update is a commit; an empty repository is
initialised by the first backup. Settings › Sync gets a GitHub kind with
Repository, Branch, Folder and token; magpie github mirrors magpie s3.
Inactive servers of every kind are kept in Config.Servers (Other stays
for older clients).

Squashed from yetone/magpie#1130 at 6b5b1c693e1a3a23e177b4d376f3f7f70f3bc23d
onto main. Merge resolutions: the CLI moved to internal/cli since the PR
was cut, so github_cli_test.go moved there (package cli) and the github
command, its help line and `magpie help github` were wired in
internal/cli/main.go and help_cli.go; README's Sync row kept main's
links and took the PR's wording; i18n.js zh-TW kept both sides.
2026-10-13 15:25:06 +08:00
yetone 1133ca0fe2 gui: the window opens on the page you last left, as a Mac app comes back as it was
molvqingtai on Discord asked for Routing to be the first page, and lc for
the sidebar to be reordered by drag. Rather than a setting or a reorder,
the window now reopens on the page the reader last left: show() keeps the
page in localStorage magpie.lastView, and keptView() opens it at start.

- A page asked for in the address (?view=: the tray's links, a reload)
  still wins, Agents too.
- A kept name that is no page opens the first page; one gateway mode
  leaves out (Agents, Library) opens Providers, through show()'s and
  setGatewayMode's existing fallback.
- localStorage is how the window already keeps magpie.navLayout and
  magpie.panelTab across restarts; checked on a copy of the installed
  app's WebKit store (~/Library/WebKit/com.yetone.magpie), which holds
  those keys from earlier runs.
- Opening on the kept page scrolls nothing.

docs/reference.md and docs/subsystems/gui-shell.md say so.

Run:
- internal/gui/tests/last-page.test.cjs (new), Chromium and WebKit, at
  1100 (sidebar) and 420 (header tabs): left on Routing, opened again with
  no ?view= and reloaded -> Routing, nothing scrolled; Settings kept;
  ?view=usage and ?view=agents win; an unknown kept name -> Agents;
  gateway mode with agents/library kept -> Providers, routing kept ->
  Routing. Broken by hand, it goes red: with show() not saving, with the
  kept page not restored, with the kept page beating ?view=, and with
  both gateway fallbacks removed.
- model-rate.test.cjs opened "/" after Providers and took it for Agents;
  it now asks for ?view=agents.
- 171 GUI files that navigate more than once or touch the start page
  (gateway-mode, sidebar*, nav-*, click-scroll, view-*, getting-started,
  side-toggle, panel-*...) plus 151 that open the bare root URL, both
  engines, 5-6 files at once: all green but model-rate (fixed above) and
  load flakes that pass alone here and on origin/main 1e8859838:
  sidebar-overlay-scrollbar (#1863), sessions-toolbar (#1426),
  agent-stale-copies and copilot-ghe (route callbacks outliving the page,
  filed as #1949).
- go test -tags nogui ./internal/gui, gofmt -l, go vet ./internal/gui on
  darwin, GOOS=linux and GOOS=windows -tags nogui.
2026-10-13 15:10:25 +08:00
Rupert-WLLP-Bai 81f587d7be sessions: omp's sessions in a WSL distro are listed on Windows, on the Sessions page and in Usage's Sessions tab, as Claude Code's, Codex's and Pi's there already are (#1150, #1138)
omp keeps its sessions under ~/.omp/agent in the distro's home, and in
a profile's own folder for omp --profile. wslAgents now names omp, and
allFiles reads wslFiles("pi", "omp"), so a distro's omp sessions show on
Windows marked with their distro and resume through wsl.exe. A session
under a profile resumes with omp --profile <name> --resume <id>; a
profile name that isn't plain ([a-z0-9][a-z0-9._-]{0,63}) gets no resume
command rather than one built from it (resumeCommand takes the session's
path for this).

Squashed from yetone/magpie#1150 at d7968f11b2ef419e30e1a6a169554b12e58c885a
onto main; docs/subsystems/gui-shell.md conflicted and keeps main's
"Streamed output speed" section and the PR's "Stored agent sessions in
WSL" section.

Run at this tree: gofmt; go vet darwin, GOOS=linux -tags nogui,
GOOS=windows; builds for all three; go test -tags nogui on
internal/sessions, internal/gui and internal/agent (agent with
-timeout 45m, it took 17 min on a loaded machine) green.
Broken by hand: with omp taken out of wslAgents, TestWSLSessionsListed,
TestWSLOmpSessionDeleted, TestWSLOmpProfiles, TestWSLStoppedDistroKept
and TestWSLStoppedSinceNotOpened go red.
Not tried: a real WSL distro with omp on the Windows box.
2026-10-13 13:49:16 +08:00
yetone 63a361b5ff gui: a plugin that took over Trae's, WorkBuddy's, MiniMax's or Qoder's check-in keeps that switch after a state refresh (#1912)
The previous commit reads the saved pluginCheckins map before
/api/settings' list, but /api/state has neither the list nor, for a
provider whose own switch was never set, a map entry. Such a plugin follows
the built-in check-in it took over (provider.PluginCheckinOn: traeCheckin
for trae-cn, workbuddyCheckin, minimaxCheckin, qoderCheckin), so a refresh
still drew it off while the scheduler kept checking in. pluginCheckinOn now
falls back to that built-in's switch, from PLUGIN_CHECKIN_INHERITS.

Run: plugin-checkin.test.cjs gains cases for the inherited switch in
/api/state's shape (red with the fallback removed) and a test that the map
names the same ids and settings keys as Go's PluginCheckinOn (red with an
extra entry); plugin-checkin, i18n-keys, gui-zh-tw, gui-ja, gui-de in
Chromium and WebKit: 32 pass. No new strings.
2026-10-13 12:58:32 +08:00
snowlie 762db7c5a2 gui: a plugin's saved auto check-in stays on after a state refresh (#1912, 1939323749)
Reported by 1939323749 with a custom provider plugin on Windows. Read the persisted pluginCheckins map before the derived settings-only list, preserving explicit false and the existing default fallback.

Verified plugin-checkin tests in Chromium and WebKit across en, zh, zh-TW, ja and de, plus all three translation GUI suites. The WebKit English Usage-card regression fails without the fix: saved auto check-in stays on after a state refresh (false !== true).

Reviewed and landed from the reporter's branch (755c1f0): with the old
pluginCheckinOn the new refresh assertion fails in WebKit for every
language; with it, plugin-checkin, i18n-keys, gui-zh-tw, gui-ja and gui-de
pass in Chromium and WebKit.
2026-10-13 12:58:32 +08:00
yetone 1d927bcfe9 gui: a copy nothing could make says so, with the text to copy by hand (#1881, BabyLy233)
copy() tried /api/copy, then navigator.clipboard.writeText, then the copy
command, and when all three failed it put the bare text in the footer
with no word that nothing was copied. Now that magpie refuses a copy it
can't read back (the commit before), that last case is reachable in the
app on Linux, so it reads "Couldn't copy. Select it here and copy it
yourself: <text>" as an error (role=alert, 8s) and the button isn't
flashed as copied. Translated in zh, zh-TW, ja and de. The order of the
tries and the success path are unchanged, on macOS and Windows too.

docs/subsystems/gui-shell.md: the host's copy row says how a Linux copy
is made and checked, and where the page takes over.

Run:
- tests/copy-fallback.test.cjs (new): /api/copy 204 (no page copy),
  501 + clipboard API, 501 + API refused + copy command, all refused;
  en, zh, zh-TW, ja, de; Chromium and WebKit: 40 pass. With the failure
  line put back to status(text), the 10 "nothing copies" cases go red.
- copy-command, key-copy, model-copy-id, library-mcp-copy-config,
  i18n-keys: pass.
- go test -tags nogui ./internal/gui: pass.

Not tried: WebKitGTK's own clipboard API and copy command inside the real
Linux app window when /api/copy refuses (the container run drove the
host's copy directly).
2026-10-13 11:13:24 +08:00