Commit Graph
170 Commits
Author SHA1 Message Date
yetone 5dfbca6274 cli: magpie settings list|get|set|reset, through the window's own save (#4745)
Stage 1 of #4745 (StringKe): every setting POST /api/settings saves can
be read and set from the terminal.

- internal/settingsapi holds the save the handler made: Merge (the
  carry of keys a page leaves out, moved verbatim from api.go, plus
  upstream's RouterNote line), the vision/imageGen/searcher checks,
  settings.Save's own checks, catalog.Touched. POST /api/settings and
  `magpie settings` both call settingsapi.Apply, so a value is checked
  and saved one way. It sits outside internal/gui so the nogui build
  has it.
- `magpie settings` (list, the default, with value, default and
  choices; get; set; reset to settings.Defaults()), --json on list and
  get. Body sends the whole file with one key changed, so a key the
  save keeps when absent (noBird, refusalRetries, ...) is set even to
  off. A flag where a key or value goes, an unknown key (with near
  matches named) or a refused value writes nothing and exits 1;
  --help prints usage.
- Parity guards: TestKeysAreWhatTheSaveWrites (each Settings field sent
  changed on its own; what the save takes must equal Keys),
  TestSettingsCLISetsWhatTheWindowSaves (every key the page's prefsKeep
  and savePrefs send is a key), TestEveryRouteHasACommandOrIsNamed
  (each /api route has a command or a reason in notYet, which later
  stages shrink; 36 have one now).
- Item 3 of the stage (per-provider CLI-only fields in the window) is
  left for stage 2.
- The open app's in-process follow-ups (fonts, Dock, tray menu, alerts,
  language, update re-check) run only from the window's save: #4752.

Run (mote, at the pushed head 1c3591b5d + this):
- gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; GOOS=linux go build -tags nogui;
  GOOS=windows go build: clean (before rebase, the vets again after).
- go test internal/settingsapi, internal/settings, internal/cli: ok.
  internal/gui -run Settings|Prefs|Keep after the rebase: ok. The full
  internal/gui run before the rebase had three reds:
  TestSettingsSaveKeepsWhatItDoesNotSend (BusyLoad, fixed on main in
  b646a9127), TestColdTurnsTaken (fixed on main in 647323409) and
  TestMainWindowCorners/macOS_26_SDK (#3949, mote is macOS 27).
- Real run in a sandbox HOME on mote with a magpie built from this:
  settings --help / help, list, get, set theme dark, noBird on,
  redactWords "acme, globex", usageAlert 85; refused theme neon, `them`
  (names theme), usageAlert lots, trayUsageEvery 4, vision
  nobody/nothing, each exit 1 with settings.json unchanged; set
  usageAlert --help printed usage and wrote nothing. Then `magpie web`
  with MAGPIE_WEB_KEY: GET /api/settings read back each value the CLI
  set; POST /api/settings lang ja, then `settings get lang` said ja;
  reset theme gave system.

Broken by hand, each red, then put back: noBird dropped from Keys
(TestKeys, TestBodySetsOneKeyOnly, the CLI set test and the GUI parity
test red); Body dropping false values (TestBodySetsOneKeyOnly and the
CLI "noBird off" check red); a route taken out of notYet and another
renamed (TestEveryRouteHasACommandOrIsNamed red, 3 errors). On the old
code the new tests don't compile (no settingsapi, no command).

Not tried: a real run on Windows or Linux; the live app reacting to a
CLI write while open (#4752); the GUI node suite (no page file changed).
2026-11-01 15:57:43 +08:00
9097687a31 gui: Hide accounts leaves the user's own account names and plans in sight (#3656)
With Hide accounts (账号打码) on, the name a user gave an account
(#1515) was blurred like the account, so faketrader's several
Antigravity accounts couldn't be told apart; and an Antigravity
account whose value is "Google" blurred "Google" of its plan
"Google AI Pro" on Usage and on the Providers row. The name the user
gave an account is shown text, not an identity. The account is.

- provider: a card's Alias says whether it is the user's own name
  (SubscriptionQuota.Named, set by withAccountNames from
  AccountNameOf), since Alias is also a plugin's name for an account
  (PluginUserOf, a masked phone, #4416) or a seat's key plan, and the
  Usage page and tray panel may have no /api/providers to tell them
  apart. labelProvider is AccountLabelOf's "plugin:" lookup, shared.
- app.js names(): the user's own names (accountNames) and named
  aliases are no longer accounts to hide; accountUsers, an unnamed
  alias and a seat still are (noteAccounts keeps an alias without
  named).
- app.js mask(): labels are scoped by element, never by value
  (LESSONS: scope an exemption by where the value sits). In
  .own-name, .plan, .acct-plan (the Providers row's plan pill, new
  class), .model-value and .subscription-head > b only an address is
  hidden; a plan's and a model's tooltip too (TIPS). The own name's
  tooltip ("name · account") is masked in full.
- .own-name is set only where the text is the user's own: the
  editor's rename span when it has one (else it shows the raw
  account and stays hidden), Usage's quota-alias and the panel's
  pq-user when q.named.

From skygunner's patch (95c0511 on 19253f67), changed:
- Its .acct-who .rename exemption showed a raw non-email account
  (the rename span shows the account when it has no name of the
  user's). Now only an own-name span is exempt.
- Its [title]:not(LABELS) skipped those elements' tooltips
  altogether, so the address in "alias · user" (quota-alias, rename)
  went unmasked. Tooltips are masked; only a plan's or model's hides
  just an address.
- Dropping every alias from names() would have shown a plugin's name
  for an account (#4416 came after the patch's base). Named tells
  the user's own apart.
- The n.data.length < 2 skip the patch removed is kept.
- Its test is rewritten on the new fixtures: an unnamed plugin
  alias, an address in a plan, the editor with and without an own
  name, the panel, a model value, tooltips.

account-alias.test.cjs and account-eye.test.cjs said Hide accounts
hides the user's own name; they now say it stays in sight, the
accounts still hidden. account-alias brings the window's page to the
front before clicking #usageMask, and the panel's before waiting on
it: behind the panel's page it gets no
frames and the click waited for one, red 5 times in 2 runs at
fb3942ee6 (#2984's account-alias half), 0 in 100 after.

Not changed: the tray panel card's tooltip is one string of account
and plan, so a plan word that equals an account's value is still
hidden there (#4677). OpenCode Zen's "Signed in as <account>"
in the issue's screenshot is the raw account, hidden as before.

Core scripts: app.js's own comments in the masking module are cut, so
the core is 742 bytes under its budget at the pushed head (no raise).

What was run:
- At this on 4c815ac2a, on mote (then rebased onto 39bade71d, whose 8
  commits change only i18n.js and plugins/gateway/settings.js; the
  budget measured again, 742 under): gofmt -l; go vet
  of provider, gui, usageapi; go test -tags nogui ./internal/provider
  ./internal/usageapi ok; TestCoreScriptBudget ok; the 19 masking GUI
  files (account-*, mask-*, masking-records, privacy-*, provider-mask,
  provider-unmasked, routing-masking, window-mask, click-scroll,
  i18n-keys), both engines: 539/540. The red was account-alias's
  panel wait behind the window's page, fixed by the panel bringToFront
  above. account-alias + account-mask-alias-plan after it: 4 runs,
  159/160 (one red in "renamed in place", whose body this change doesn't
  touch, #4749). account-alias 6 more runs: 120/120 here, 117/120 on
  origin/main 90c02326b (#2984).
- account-mask-alias-plan: 20/20 on the fix (Chromium, WebKit; en, zh,
  zh-TW, ja, de; 1100 and 420), 20/20 red at fb3942ee6 (the alias is
  masked); red with the plan selectors taken out of LABELS by hand.
  account_plugin_user_test red with Named always false by hand.
- At 4eeba1ca6 (this on 90c02326b): go vet ./..., GOOS=linux go vet
  -tags nogui ./..., GOOS=windows go vet ./..., go build for darwin,
  linux (nogui) and windows: ok. go test -tags nogui ./... on the
  Linux box: every package ok except internal/agent (8 install tests
  red the same on origin/main there, #4033, #3548) and internal/gui
  (TestSettingsSaveKeepsWhatItDoesNotSend, red on main, #4514;
  TestColdTurnsTaken on mote once, #4510). The whole GUI suite on the
  Linux box, 6 wide: 16857 pass, 491 fail in 100 files, none of them
  the masking files but account-every-reset; being run against
  origin/main to sort.

Co-authored-by: skygunner <84759+skygunner@users.noreply.github.com>
Co-authored-by: vincent <vincent@users.noreply.github.com>
Co-authored-by: Fake Trader <9635792+faketrader@users.noreply.github.com>
2026-11-01 15:15:08 +08:00
yetone 4c815ac2a5 search: searchers picked to follow the one named, tried in their order when it fails (axelburks on Discord)
axelburks asked for more than one searcher, so that when one fails
another provider searches. A searcher named in Settings gave way to no
other provider before, only to the Search APIs. Automatic already fell
back to up to three.

- settings: SearcherThen, the searchers after the one named. Entries
  are trimmed. Blanks, "off", the named one and repeats are dropped.
- gateway: when the named searcher fails (the context still live),
  modelSearch asks each of SearcherThen in order and skips one that
  can't search now or is the same model. The first that searches
  answers, and the call is marked searchingInstead, so the Routing row
  says why the named one didn't search. If all of them fail, their
  errors go back together, saying "the searchers picked ..., in their
  order", and webSearch goes on to the Search APIs as before.
  SearchFailure.Instead names the one that searched in its place.
- gui api: searchFailed.instead. A save takes only searchers that
  Searchers() offers. A save without searcherThen keeps the list, since
  the page's prefsKeep doesn't send it, and [] clears it.
- Settings › Web search (plugins/search/settings.js, outside app.js's
  budget): an "If it fails" row under a named searcher, with numbered
  chips and Add. A chip's picker changes the chip or removes it. The
  row is hidden for Automatic and Off. The failure line names who
  searched instead, or says the ones after it failed too. The help
  text says the same in en, zh, zh-TW, ja and de.
- docs: gateway-routing's failing searcher, and gui-shell.

Tests:
- TestPickedSearchersInTheirOrder (gateway): one test where the named
  searcher answers without searching and one where it fails. A gone
  entry and one that can't search are skipped, and the third searches
  once. With no working entry, the error says so and Instead is empty.
- TestSearcherThenSaved (settings) and TestSearcherThenFromSettings
  (gui): what is saved, kept and cleared; refusing an entry that can't
  search. settings_keep_test sets SearcherThen.
- searcher-then.test.cjs: chromium and webkit, en, zh, zh-TW, ja, de,
  at 560 and 1000 wide. Checks the row's place and words, what Add
  offers, the posted lists, that the chips fit with no horizontal
  scroll, that no click moves the page, and both failure lines.
Broken by hand: running no fallback turned TestPickedSearchersInTheirOrder
red (both subtests: "ds2 searched []"). Not keeping the list on save
turned TestSearcherThenFromSettings and the keep test red.

Run on mote (mote-run):
- At the pre-rebase tree (base 21882a68d): go test of settings, and
  -run 'Searcher|Search' of gateway and gui: ok.
- searcher-then, searcher-pick and i18n-keys in both engines: 46 of 46.
- gofmt clean. go vet: darwin gateway, gui, settings; windows the same;
  linux gateway and settings on mote, gui with -tags gtk3 on the Linux
  box (wsl-run): ok.
- Rebased onto origin/main 1e6a27d4f, this tree: -run
  'Search|Searcher|CoreScriptBudget|SettingsSave' of gateway, gui and
  settings: gateway and settings ok; gui ok but for
  TestSettingsSaveKeepsWhatItDoesNotSend on BusyLoad, red on main
  since 8d8df0639 (#4739, not this change; SearcherThen passes its
  check). The three GUI files above: 46 of 46.
  Pushed on origin/main e62a1bc51. Its 6 commits since touch routing,
  sessions and rex files only, none of these, and weren't run here.
Not run before the tag: the whole GUI suite and the full go test of
gateway, gui and settings. They are queued behind other sessions'
suites on mote and run after the push; any red they find gets its own
commit.
Not tried: a real relay or a real searcher failing in the GUI app.
2026-11-01 14:43:18 +08:00
yetone 90c02326bb gui: an app takes the gateway over from its older copy once idle, and says any other version serving it (matrix0487)
matrix0487 on Discord: after an update, pi said 404 'magpie knows no
model "kimi/k3.1-pro" ... add a provider in magpie first'. The app had
written pi a model its older gateway didn't know, and updating the
gateway fixed it. A magpie that finds another one serving the gateway
used to log it and wait for that one to quit (watchGateway took the
port only once nothing answered). Only the Gateway page said so.

Now (otherServes, gateway_older.go):
- An older released copy of the app (it says serves app or tray, and a
  pid) is this app's predecessor. Once its /v1/magpie/concurrency says
  nothing is in flight (gateway.ServedBusy; unknown is never idle),
  the app quits it the way the Gateway page's button does
  (quitMagpieOnPort: a magpie only, by its program) and serves the
  gateway. A stream through it runs to its end first. watchGateway
  looks again every 15s while another serves. At most three times a
  run; a quit that fails is left to the button.
- Any other one (magpie serve or the service, magpie web, a TUI, a
  newer magpie, a build of its own) is left running. /api/state
  carries it as gatewayOther, and the Agents page says it above the
  list with what to do, plus the take-over button for an older one
  (gatewaySkewLine, in plugins/gateway/client.js so app.js stays under
  its budget). A dev build of this magpie says nothing. New strings in
  zh, zh-TW, ja and de.

How the reporter's older gateway outlived the update isn't known: they
never said whether one ran separately. A failed handover leaves the
old app serving for up to 15m, and a magpie serve left running is
another source. Both are covered now: the first is replaced, and the
second is said.

Known gap: a request that starts between the idle read and the quit
gets the older app's short drain. A socket handover between two
running apps (no gap) is not built.

Run on mote at 0f8ea30bb (this change on 2b067434d):
- go vet for internal/gui and internal/gateway, also GOOS=linux
  -tags nogui and GOOS=windows; gofmt -l clean.
- go test -count=1 -timeout 45m ./internal/gui ./internal/gateway:
  gateway ok. gui has two reds, the same on origin/main 0c3163804:
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestMainWindowCorners/macOS_26_SDK (#3949).
- GUI subset, Chromium and WebKit: gateway-*, agent-layout, agents-*,
  getting-started, i18n-keys, gui-ja/de/zh, panel-arrange, panel-fold:
  411 pass. Two reds, the same on origin/main 0c3163804:
  gateway-caller-keys chromium en (#3797) and gui-ja (#4580). Passing: the new gateway-skew.test.cjs (en and zh at 380px, the
  button POSTs take-over and the line goes).
- Real app on mote, sandbox HOMEs, port 3591, update feed pointed
  nowhere:
  - origin/main built as 0.1.2400 ran `magpie app`, and this head
    built as 0.1.2500 ran `magpie app` beside it. The new one logged
    "an older copy of this app ... with nothing in flight; quitting
    it" and served 0.1.2500 on the port 2s later. The old process was
    gone.
  - The same with the old one as `magpie serve`: it was left running,
    and the new one logged that it serves, older.

Red on origin/main: TestAppReplacesItsOlderGatewayOnceIdle ("the
older copy of the app still serves the gateway", 17s).

Again at the pushed head (this change on 6f3dfc282, mote): vet darwin, linux
nogui and windows; TestCoreScriptBudget (the core is 1,533,104 of
1,533,105: main's #4652 took the room, so app.js's hook line lost its
comment, no raise), TestAppReplacesItsOlderGatewayOnceIdle,
TestGatewaySkew*, TestGatewayFixQuitsOnlyAMagpie,
TestGatewayServedByAnOlderMagpie: ok. gateway-skew, i18n-keys, gui-zh,
gui-de: 11 of 11 pass.

Broken by hand, each red:
- quit without waiting for idle: "quit with a request in flight"
- replaceable() false: "still serves the gateway"
- any serves replaceable: TestGatewaySkewOfAnotherIsSaidNotQuit, the
  serve holder quit
- the Agents hook removed: gateway-skew.test.cjs red in both langs

Not tried: the whole GUI suite (mote was running another session's
full suite), a real app with a real agent stream in flight during the
take-over (the Go test holds a stream through a fake), Windows and
Linux apps (the replace path needs handoverHost, set by the app's Run
on every OS, but it was tried on macOS only).
2026-11-01 11:43:56 +08:00
yetone 3f2faef620 gui: the Providers page has its own Hide accounts switch
Routing's Hide accounts (账号打码) also masked the Providers page,
where nothing showed it was on or let you turn it off (Discord
#feedback, 1566189346665799752). The Providers page now has its own
switch beside its search box, placed and drawn like Routing's
(.rt-mask moved from routing.css to app.css), and each page follows
its own switch: Routing, Usage and the tray panel follow
magpie.maskEmails, Providers follows magpie.maskProviders.

The user's own choice is kept: when maskProviders was never stored,
it is seeded from maskEmails and written at once, so someone who had
masking on stays masked on both pages after the update, and someone
who turned it off stays unmasked. A switch with a stored choice is not
changed by Mask personal data's follow(); turning Mask personal data
on still masks both (hideAccounts.set(true, true), in app.js and
plugins/redact/page.js). show() asks hideAccounts.page() to re-mask
when the page in sight follows the other switch. No new strings: the
button reuses Routing's translated label and title. app.js
1,310,438, core under its budget, no raise.

Run:
- New internal/gui/tests/provider-mask.test.cjs, both engines, all
  5 languages, at 1000 and 420 wide, plus the touched window-mask,
  account-eye, privacy-hides-accounts, mask-emails,
  plugin-name-unmasked, masking-demo-unblurred: 134/134 on mote. At
  the rebased head (origin/main 573b21f4b) with gui-zh, gui-ja and
  i18n-keys: 140/141, the red is gui-ja's ja string from a7b47d57e
  (#4580), red on main.
- provider-mask on origin/main's assets: 60/60 red (no #pvMask).
- Broken by hand (chromium en), each red: cur() always Routing's
  switch ("Providers shows the account while its own switch is
  off"); the seed taken out (the upgrade on/off cases); show()'s
  page() call taken out.
- gofmt -l clean; go vet, GOOS=linux -tags nogui and GOOS=windows vet
  ok; the three builds ok; go test -tags nogui -timeout 45m ./... on
  mote at base 6712e367e: every package ok but internal/gui's
  TestSettingsSaveKeepsWhatItDoesNotSend, red on main too (#4514).
  At the rebased head: internal/gui's budget tests ok.
- Whole GUI suite on Linux (WSL magpie-desktop, concurrency 6, host at
  100% CPU), files a to l so far, the rest on mote: each red file was
  run alone at this head and at origin/main 6712e367e. Red alone at
  both, already filed: agent-panel-name-width (#4203), context-map
  webkit 420 (#3488), gateway-caller-keys (#3797), gateway-key-models
  (#4081), header-centre webkit ResizeObserver (#3479), key-replace
  webkit 420 (#4126), gui-ja (#4580). Red only under the whole run,
  green alone at this head: agent-plugin-agents (#4481), agent-prefs
  (#4552), allow-ips (#3699), api-key-theme (#3307), click-scroll,
  codex-predictions, currency (#3101), editor-advanced-align, fonts,
  gateway-key-limit, group-from-model-add, group-member-fast,
  group-member-off, group-morph, icon-url, inner-scroll-contain,
  keep-awake, lan-docker, ledger-hscroll, library-chip-fan,
  library-items, library-mcp-hub, library-mcp-tools, list-sort (the
  load class, #4400,
  #4471).

Not tried: the real desktop app's webview (Wails), and the GUI suite
on macOS beyond the files above.
2026-11-01 06:30:17 +08:00
yetone e1aec53895 routing: each session sending at once has its own context window, named by its title (tjhhhh on Discord)
tjhhhh runs several agent sessions at once. The Routing page's context
window card followed whichever request came last, so it jumped from one
session's prompt to another's. The card still tells of the request it
picked. Under it, while two or more sessions are live, a strip now
shows one small block per session (renderCtxSessions):
- keyed as the card's line of prompts is (sessionKey, else the
  conversation);
- named by the agent's title for the session (sessionName), else its
  folder's last level, never a bare id;
- holding that session's newest reading through context.js's stack bar,
  exported as window.ctxStack.

A session is live while a request of it is under way, or while its
newest request is within 15 minutes of the newest overall. At most six
blocks show, newest session first. A block keeps its place while the
sessions take turns, because blocks are ordered by each session's first
request. The block the card tells of is lit (aria-pressed), and a click
on a block picks that session's newest request. The card's footer names
the session by its title too. New words are in every locale in
plugins/routing/i18n.js. The strip reuses the card's tokens: no select,
no coloured border, no gradient.

The strip sits under the card, not over it. Over it, the strip's first
appearance moved the card, and routing-ctx-still ("the cache kept its
place") went red in both engines. It is green at base ccc791231, and
green again with the strip under.

What was run (mote, through mote-run):
- New routing-ctx-sessions.test.cjs: two engines, en/zh/zh-TW/ja/de at
  1100 and 390px, plus one session alone and one with no title. Red on
  origin/main, since there is no strip there. Broken by hand: ordering
  blocks by newest request instead of first request turns the
  "keeps its place" check red. Green, 4 of 4 tests, at the final tree.
- routing-ctx-still: red with the strip over the card, green with it
  under (tests 391/392, both engines).
- Whole GUI suite, at the first version (strip over the card), under
  load 25 to 30 from other sessions: 16892 tests, 16595 pass, 297 fail
  in 49 files. That version's own red was routing-ctx-still (fixed
  above). Every other red file has an issue:
  - Filed before: agent-panel-name-width #4203, context-map #3488,
    gui-ja #4580, i18n-keys "Unmarked" #4524, header-centre #3479,
    key-replace #4126, menu-input-scroll #3402, mobile-web #3952,
    model-chip-steady #4388, models-works-only #4391, page-width-steady
    #4541, phone-connect-menu #3524, plugin-card-update #3079,
    plugin-move-unserved #4392, provider-fetch-again #3292,
    provider-levels-scroll #4394, provider-models-rest #4396,
    provider-picks-stay #4397, provider-typed #4461, recovered-file
    #4320, remote-magpie #4398, rest-try-now #2564, routing-row-swap
    #3799, routing-steady #3412, the routing rule-drag, rule-remove,
    rules-line and upstream files #4585 and #4494, s3-sync #3413,
    searcher-pick #4274, segs-press-redraw #4189 and #4566,
    usage-agents-hide #3414, warm-now #4322.
  - Filed with this commit: editor-advanced-align #4615,
    gateway-key-models #4616, group-found-skip #4617, images-codex-one
    #4618, import-row #4619, market-have #4620, model-copy-id #4621,
    nav-timeout #4622, number-units #4623, omarchy #4624, tencent-cloud
    #4625, usage-ledger #4626, routing-order-unknown #4627,
    routing-steps-cap #4628, routing-story-shrinks #4629.
- The files this change can reach (routing-*, context-*, i18n-keys,
  gui-ja), alone at concurrency 2 on the first version against base
  ccc791231: 54 fail on the head and 34 at the base. The only red that
  was on the head and not the base was routing-ctx-still. The rest were
  routing reds under load that show on both.
- The same files rerun with the strip under the card: 2331 tests,
  35 fail. routing-ctx-sessions and routing-ctx-still are green. Each
  red has an issue: context-map webkit 420px "two tiles overlap"
  (#3488, the same at base), gui-ja (#4580), i18n-keys "Unmarked"
  (#4524), routing-many-keys (#4082), routing-row-swap (#3799),
  routing-steady (#3412), routing-order-unknown (#4627),
  routing-steps-cap (#4628), routing-story-shrinks (#4629), and
  rule-drag, rule-remove, rules-line and upstream (#4585).
- TestCoreScriptBudget went red after the rebase: the core was over by
  266 bytes, which is the new stackBar helper in context.js. The budget
  was not raised. stackBar was written tighter and the comments around
  it cut, and context.js is now 1 byte under its size at origin/main.
- Rebased on origin/main 2e9df9b1b, on mote:
  - `go test ./internal/gui`: TestCoreScriptBudget passes. Two reds are
    already filed: TestSettingsSaveKeepsWhatItDoesNotSend (#4514, red
    on main) and TestMainWindowCorners (#3949, macOS 27).
  - routing-ctx-*, context-*, i18n-keys and gui-ja: 337 tests, 8 fail.
    routing-ctx-sessions is 4/4, routing-ctx-still 2/2, and every
    context-* other than context-map is green. The reds are context-map
    "two tiles overlap" (webkit 420px in every language and chromium
    zh 420px, #3488), gui-ja (#4580) and i18n-keys "Unmarked" (#4524).
- Rebased again on origin/main e8347401f, which changes the core
  budget and fixes #4524. This is the pushed tree. TestCoreScriptBudget
  is ok, and routing-ctx-sessions, routing-ctx-still and i18n-keys pass
  44/44.

Not tried: a real gateway with several live agent sessions sending at
once (only the page's fixture feed was used), the Linux WebKitGTK app,
and the whole GUI suite at the final tree (only the files above,
which the change can reach).
2026-11-01 02:44:37 +08:00
yetone fb29cd30f9 tray: the Mac's menu bar figures are regular weight, a lone one in the menu bar's own font (qingnianxiaozhe on X)
Beside Surge's speeds and another app's stacked "0 KB/s", magpie's
"93% / 98%" read visibly bolder, and a lone "98%" too small and too
heavy, so the reporter kept it out of the menu bar. mpRowFont drew two
stacked rows in 9.5pt semibold and one row in 11pt medium, both since
ef4edf8c5 (the first drawn image, no owner call on the weight). Now:

- two rows: monospacedDigitSystemFont 10pt regular (was 9.5pt
  semibold); row gap unchanged (3.5pt), the block 17.6pt as Surge's;
- one row: monospacedDigitSystemFont at menuBarFont(0)'s size (13pt
  on macOS 27, was 11pt), regular (was medium);
- the letter-in-a-ring stand-in for a logo, the template tint and the
  light/dark colours are unchanged. Linux shows the figures as the
  tray's text label (the panel's font) and Windows' tray shows none,
  so neither has a font to change.

Measured in the reporter's q1: magpie's digits were Surge's height
(13px) with stems 1.30x as wide (2.80 vs 2.16px). Rendered at 2x the
stems go 2.47 -> 2.04px for two rows (medium was 2.14; regular is the
closer of the two to Surge and the other app).

TestTrayRowFont (new): two rows 9.5-10.5pt, weight trait <= medium,
digits of one width; one row the menu bar font's size, weight 0, one
width. Red on the old fonts by hand (9.5pt weight 0.30; 11pt weight
0.23 vs the menu bar's 13pt). gui-shell.md says the new sizes.

Run on mote at the pushed head (rebased on origin/main), through
mote-run: gofmt -l internal/gui (empty); go vet ./internal/gui/;
GOOS=linux go vet -tags nogui, GOOS=windows go vet (with and without
nogui) ./internal/gui/; go test -count=1 ./internal/gui/ and with
-tags nogui: all pass but TestSettingsSaveKeepsWhatItDoesNotSend
(#4514, SearchAll) and TestMainWindowCorners/macOS_26_SDK (#3949,
macOS 27), both filed and red on origin/main too; the nogui run also
met TestColdTurnsTaken (#4510, the turn warm-up's race: 1 of 5 red
alone, then a hang to the timeout, at load ~35). Every TestTray* test
passes, run again alone with -v.

Compared visually: a throwaway test rendered the image through
trayImagePNG at 24pt 2x, light and dark, before and after, for two
rows and one, plain and beside a logo, and a mixed pair; laid beside
the reporter's crop of Surge's figures.

Not tried: the live menu bar beside Surge and iStat Menus (no real
app run; renders only), a non-Retina screen, and the full Go suite
and GUI suite (the change is AppKit drawing in one package).
2026-10-31 22:29:48 +08:00
yetone ceeb73a0f1 app: the desktop app writes its log to app.log; magpie log and Settings › About › Log find it
rayem1w on X (0.1.2330, macOS) was asked for ~/Library/Logs/magpie/serve.log
while chasing a Codex "hit a snag" through the gateway, and had no such
folder. Only the launch agent (magpie daemon install, written by launchd)
and a gateway magpie tui left running wrote a log; the app opened from the
Finder, the Dock or the Start menu logged to a stderr nobody reads, on
every system.

Now runGUI and runPanel (magpie, app, tray, panel, a window view, a
magpie: link) call applog.Start before gui.Run. It sends the standard
logger (the gateway, the plugin host, providers and Wails' error handler
all log through it) to app.log as well as stderr, and points
debug.SetCrashOutput at it so a panic's trace is there too:

  macOS    ~/Library/Logs/magpie/app.log
  Windows  %LOCALAPPDATA%\magpie\logs\app.log
  Linux    $XDG_STATE_HOME/magpie/app.log, else ~/.local/state/magpie/app.log
  portable data/logs/app.log

app.log, not serve.log: on a Mac launchd writes serve.log for the service,
another process. The file is 0600. At 5 MiB it becomes app.old.log (two
files at most); when another magpie (an update's new process) rotated it
already, it is only opened again; when it can't be moved it is emptied.
stderr goes first, through a writer that never fails, since io.MultiWriter
stops at a failed writer and an app opened from Explorer has no stderr.

Secrets: the log calls name header names and paths without queries; no
key or token was found logged (grep of log.Print* in gateway, provider,
plugin, gui, agent). scrub masks bearer/basic credentials, key/token query
parameters and sk-, AIza, gh?_ and JWT shapes anyway.

How a user finds it: Settings › About › Log, with the path, Copy and an
Open that shows its folder (POST /api/settings/log/reveal; the row is
hidden in magpie web, which writes no file). magpie log prints where every
log is (the app's, app.old.log, the service's, the tui's background
serve.log); --path the app's alone, -n N its last lines, -f follows it
across a rotation. Docs: reference.md, gui-shell.md, site start (FAQ "Where
is magpie's log?" and the CLI table) and privacy (files on your computer),
en/zh/ja.

Run:
At 227ce6074 on origin/main fbb1b36d1:
- mote: go test ./internal/applog ./internal/appdir ./internal/cli ok;
  -run TestCoreScriptBudget ./internal/gui ok; GOOS=windows go vet
  ./internal/... and GOOS=linux go vet -tags nogui ./internal/... ok;
  gofmt -l clean. GUI, chromium: about-log (5 languages x 1100/420, and
  no row without a log), about-website, i18n-keys: 24 of 25, the one red
  "a plugin's words are its own" ("Unmarked") is the same at origin/main
  fbb1b36d1 (#4524).
- WSL (magpie-desktop), webkit: about-log and about-website 21 of 21.
- Windows (win-run): applog, appdir, tui ok; cli ok but
  TestLibraryMCPHub's TempDir cleanup (#4140, mcp-npm, not this change).
- WSL full go test -tags nogui -timeout 45m ./... at the previous base
  03f609e3f: every package ok but reds that fail the same at origin/main
  03f609e3f alone: TestSettingsSaveKeepsWhatItDoesNotSend (#4514),
  TestNoCommandBypassesProc (#4491), internal/agent's install-detection
  tests (#4033, #3548), and TestCoreScriptBudget, which was this change
  (app.js 321 over): its comment is cut to one line and both budgets
  are raised by the remaining 124 bytes, with no room added.
- Broken by hand: with startLog left out of runGUI, TestTheAppWritesItsLog
  is red ("app wrote no log: open .../Library/Logs/magpie/app.log: no such
  file or directory"); with proc.UserPath taken out of openApp,
  TestGatewayStartsGetUserPath is red ("runGUI doesn't call
  proc.UserPath"). The guard now follows a start into a function or func
  var of this package, since the Wails start sits behind openApp for the
  test.
- Real use on mote: the GUI build, magpie app in a sandbox HOME, wrote
  ~/Library/Logs/magpie/app.log (0600) with its "started" line; magpie
  log and magpie log -n 3 printed it.
Not tried: the app opened from Windows Explorer or a Linux desktop
launcher for real (the paths are unit-tested per OS, the writer on
Windows and Linux); the full GUI suite (running on WSL after the push,
reds filed if they fail at origin/main too).
2026-10-31 14:45:22 +08:00
yetone e6b851b0fe update: magpie update in a terminal restarts the app with its gateway handed over
gaubeebangeel on X has an agent run the magpie upgrade at 4am and had
to give that agent its own provider: magpie couldn't serve it through
the upgrade.

Cause: `magpie update` put the new version in and printed "quit and
reopen magpie to use it" (a .app) or "updated to X" (a binary). The
running app never restarted, so the agent (or the user) had to restart
it by hand, and a plain restart closes the port and drops streams.

Measured before, on mote, a sandbox HOME `magpie serve` with a fake
upstream streaming 61 chunks at 100ms, restarted by SIGTERM + start:
- the stream was cut at chunk 15 of 61 (unexpected EOF); SIGTERM to exit
  took ~18ms, no drain;
- requests during the restart: 289 answered, 5 refused over 87ms.

Now `magpie update`, once the new version is in, POSTs it to the
running app's /v1/magpie/restart (gateway/restart.go). It is answered
only to a program on this computer over loopback; a LAN caller, a page
(Origin / Sec-Fetch) and another Host get 403. The updater's
restartBeside (gui/update_beside.go) restarts only when its own exe was
the one replaced (replaced() now also compares a .app's binary,
bundleExe), takes the version as ready without the feed, and runs the
same restart as Settings' AutoRestart: at once when it cuts nothing
short, else through waitIdle. On macOS and Linux that restart is the
existing SCM_RIGHTS handover, so the port never closes and in-flight
streams finish in the old process. The command prints what happened:
restarting (handing the gateway over), waiting for N requests, another
copy (current), magpie serve (unsupported), not running, or too old
(404: the first update into this version still needs a manual
restart).

Tests:
- TestUpdateInATerminalRestartsTheAppWithoutCuttingIt (darwin, linux):
  a stream through the gateway, the exe rewritten, magpie update's ask
  answered "restarting" with handover; the successor serves a request
  while the stream runs, the stream ends whole, the old one quits only
  after it. Red by hand with the route removed ("magpie update's ask:
  404").
- TestUpdateOfAnotherCopyLeavesTheAppBe, TestRestartAskedOnlyFromThisComputer
  (refused cases never reach the restarter), TestUpdateAsksTheRunningMagpieToRestart
  (each reply, a 404 magpie, none running).

Run at this tree:
- rebased on bdc1617be, at this head on mote: gofmt -l clean;
  GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...;
  go test -run 'TestUpdate|TestRestartHandsTheGatewayOver|TestHandoverNotMade'
  ./internal/gui ./internal/cli and -run 'TestRestartAsked|TestReadOnlyKey'
  ./internal/gateway: ok
- before the rebase (88ecae173), mote: go test -count=1 ./internal/gui ./internal/cli ./internal/gateway:
  gateway ok (535s), cli ok; gui FAIL only on filed reds: the real-window AppKit
  tests killed at their deadline on mote (#4125, #2645) and
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514), both red the same
  run alone at 88ecae173, and TestColdTurnsTaken (#4510, a race in
  full gui runs, not touched here)
- wsl-run (magpie-desktop, -tags nogui): TestRestartHandsTheGatewayOver,
  TestUpdateInATerminal..., TestUpdateOfAnother...: ok
- mote: gofmt -l clean; go vet gui/gateway/cli; GOOS=linux go vet -tags
  nogui ./...; GOOS=windows go vet ./...: ok

Not tried: the real GUI app end to end with a real `magpie update`
against a published release; Windows (no handover there: the restart
waits for an idle gateway and the port closes while the new version
starts, #4521); `magpie serve` / the daemon, which has no handover and
says to restart it the way it was started.
2026-10-31 11:39:04 +08:00
yetoneandggbdpq bdc1617bed routing: Accounts and keys count the whole day, not the last kept requests (#3351)
1234fsdc: the live Routing page's Accounts and keys said tried and
answered over the requests the page still keeps in memory, so on a busy
day the counts were a sliver of what Usage showed for the same accounts
and went down as old requests fell off. /api/trace/history (the read the
live page already makes every 15s) now carries `tallies`: per account or
key, today's tries, answers, fails by reason, models answered, the last
answer and the latest rest, read from routing/<today>.jsonl. The page
seeds the list with them and still takes the latest rest and readings
from the requests it keeps; a day looked at, or a purpose picked, counts
its own list as before. The note says "over today's requests" then.
Ported from ggbdpq's patch on the issue.

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

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

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

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

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-31 11:29:38 +08:00
yetone d159314e35 gui: a hidden window's WebView2 goes on its low memory target on Windows
molamaker11 on X: "magpie后台占用快接近600MB了。win端 这个能优化一下吗。比如剔除一些动画".

Cause. On Windows the tray panel and the main window are both made at
start and only hidden when closed, so two WebView2 renderers, the GPU
process and the browser process stay up in the tray. They were kept at
WebView2's normal memory target, so a hidden window held what it last
drew: after the window had been open, the GPU process kept ~85 MB and the
main renderer ~70 MB. Animations are not the cost: hidden pages run no
layout or style (LayoutCount/RecalcStyleCount 0 over CDP), the JS heaps
are 5 to 8 MB each, and the Go process is ~40 MB private (liveHeap 25 MB).

Fix. lowWhileHidden (memtarget_windows.go) sets
ICoreWebView2_19::put_MemoryUsageTargetLevel to LOW on each hide and on a
page that comes while the window is hidden (both windows are made hidden,
and get no hide), and back to NORMAL on each show. The page stays loaded
and running, unlike lightweight mode, whose default the owner turned off
on 10-21 because reopening reloaded the page. The vtable slot is 120:
ICoreWebView2_19's vtable holds every inherited method, counted in
WebView2.h of SDK 1.0.2210.55 (a first build that used slot 4 called
get_Source and crashed at start). zoom_windows_arm64.go's reflection walk
to the controller is now chromiumPart, shared with it. macOS and Linux:
WKWebView and WebKitGTK have no memory target magpie can set, so
memtarget_other.go is a no-op.

Numbers. xiaomi-gpu, Windows 11, WebView2 156.0.4314.50, a release build
of each (-tags production,comlauncher -H windowsgui) in its own sandbox
profile with the same seeded sessions and usage (~248 MB of Claude
projects, 72 Codex rollouts, a 4.2 MB usage.jsonl), tray start. The whole
process tree (magpie plus msedgewebview2), private working set (Task
Manager's Memory column) / commit, MB:

                                       v0.1.2297     this change
  fresh tray, window never opened      205-209/316-332   81/323
  window open, every page clicked      304/482          236/467
  1 min after closing it               265/479           69/459
  5 min after closing it               ~203/~476         64/453
  idle 15-30 min later (sampled /5min) 200-214/474-481   -

  1 min after closing, by process: GPU 85 -> 2.6, main renderer 70 ->
  7.3, panel renderer ~50 -> 1.3, browser ~30 -> 6.2; magpie itself
  ~47 either way.

The commit charge barely moves: WebView2 trims the pages out of RAM to
the standby list and the page file rather than freeing them, so the
saving is RAM other apps get, not address space.

Reopening. Three trials, each window closed 3 to 5 minutes first, the
time for a view switch and two frames over CDP: the first trial took
901 ms on the first switch after reopening (v0.1.2297: 47 ms), then
12 to 31 ms; the other two trials were the same on both builds (first
frame 132 vs 131 ms, first switch 28 vs 30 ms, then 9 to 46 ms either
way).

Run: gofmt -l internal/gui (clean); on mote GOOS=windows go vet ./...,
GOOS=windows GOARCH=arm64 go vet ./internal/gui, GOOS=linux go vet -tags
nogui ./..., go vet ./..., go build; go test -timeout 45m ./... on this
tree (057c21b30, this commit with a draft message, on 91ffe5429): 80 packages ok, internal/gui and
internal/proc red. proc: TestNoCommandBypassesProc on
internal/claudetui/child_unix.go (c59c547c5, #4491). gui: ten AppKit
tests killed at their 30s bar on mote (#4125; TestDockJoinLeadsCommandTab,
TestPanelCloseHidesIt, TestCoveredWindowStaysUp and TestMainWindowCorners
red the same at 91ffe5429 alone) and TestSettingsSaveKeepsWhatItDoesNotSend
(#4514, red at 91ffe5429 too). This change adds no code to darwin; win-run go test ./internal/gui at this head: 6 red, the
same 6 at its parent 91ffe5429 run alone (TestGatewayHeldByAContainer,
#2107/#4115; TestLodyImportHandoff, TestImportStatusUnreadableIsUnknown,
TestAionUiImportRow, TestUpdateThatWontStart, #4115;
TestSettingsSaveKeepsWhatItDoesNotSend, #4514).

Not tried: a real user's profile with plugins (no bun/node host ran in
the sandbox) or signed-in accounts; an idle of many hours on the fix
build (#2515's 28h growth); Windows on arm64 (built and vetted, not run);
a WebView2 older than 1.0.2210, which answers E_NOINTERFACE and is
logged and left alone. No unit test: the call needs a live WebView2; it was checked on the box
by the numbers above. No GUI suite: app.js is unchanged.
2026-10-31 10:57:56 +08:00
yetone 2604d68db0 routing: the live card stays on the request it tells of while others come at once
qiang2040 on Discord ("狂闪", a screen recording): with Codex
conversations sending at once on group/glm-5.3-flash-free and
group/deepseek-v4.1-flash, the Routing page's top card (head, story,
context window) jumped to the newest request on every trace update,
and to "magpie hasn't routed this request yet" for each new one.

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

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

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

Not tried: the real app with several real Codex conversations sending
at once (the test drives a mocked trace). WebKit on the old code
(WebKit can't launch on mote now).
2026-10-31 01:04:08 +08:00
yetone 7d4a631480 tray: pick which of a subscription's windows the menu bar shows (StrikingRaw on X)
Claude Pro's menu bar card drew its 5-hour and 7-day windows as two
small stacked numbers, and the user wanted one of them alone. Settings ›
Usage › Menu bar windows (under Allowances in the menu bar) lists a pill
per ticked subscription with two or more windows ("Claude Code · All
windows"), opening the app's menu: All windows, then each window. The
choice is settings.TrayWindows, by provider id (every account of it, the
in-use "|*" card too) and by window kind from the span ("5h", "1d", "7d",
"month", "15m", "name:<name>" when the span is unknown), so a vendor
reordering windows changes nothing. Unset shows every window as before;
a pick whose windows are all gone shows every window again, never an
empty card. Only the bar's rows and the Linux label are filtered; the
tooltip still says every window. One row draws at mpRowFont's 11pt
single-row size. Hidden on Windows (its tray shows no text). Per
computer through KeepOwn. The GUI learns kinds from trayKind on
/api/usage/quotas (withTrayKinds; model and aside windows get none). The
row's code is a lazily imported traywindows.js, so the core script
budget is not raised (app.js +4 lines for the call and the prefs keep).

Run:
- mote (macOS): go test -run 'TrayWindow|TrayUsage|WithTrayKinds|
  CoreScriptBudget|AppScript|TrayImage' ./internal/gui/ ok;
  ./internal/settings/ ok; davsync TestSync ok. TestTrayImageOneWindow
  draws through AppKit: Claude's card one line ("42%"), both windows two;
  the PNGs were looked at.
- mote: gofmt -l empty; go vet ./..., GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./... ok; go build, GOOS=linux go build
  -tags nogui, GOOS=windows go build ok.
- magpie-desktop (Linux VM), --test-concurrency=1, BROWSER=chromium and
  webkit: tray-windows (en, zh, zh-TW, ja, de; picking All; hidden on
  Windows / single-window / no cards; 360px narrow), i18n-keys,
  old-webkit, tray-usages, tray-logos, tray-cost, quota-pace: 43/43 each.
After rebasing on ec5571d6f: the focused Go run above, davsync and vet of
the touched packages ok on mote; tray-windows, i18n-keys, old-webkit,
tray-usages 27/27 in chromium and webkit on the Linux VM.
Broken by hand: the row filter in trayCardText off -> TestTrayWindowsPicked
and TestTrayImageOneWindow red; trayWindows out of prefsKeep ->
tray-windows.test.cjs red in every language. Restored, green.
Not run: the full Go suite (owner: ship each verified fix at once; mote
was at load 20-27 under another session's full GUI suite) and the whole
GUI suite. The GUI ran on the Linux VM because mote's browsers crash or
hang under that load (#4125; TestTrayCellClickReleasedPanel is red the
same way on origin/main c84c3e1c0 there).
Not tried: the live app's real menu bar with a signed-in Claude account
(the AppKit drawer was exercised in-process instead); Linux tray label
on a real desktop.
2026-10-30 23:14:08 +08:00
yetone 2ec3453647 gui: the main window opens where it was left (jorbenzhu)
jorbenzhu on Discord: after every update and restart the panel is back in
the middle of the screen. It is the main window: after an update magpie
starts again with `magpie gui <tab>`, and Wails opens a window centred
unless told otherwise. Its size and maximised state were kept; its place
never was (gui-shell.md said "The window's position is not kept"), so
nothing was lost on upgrade, there was nothing to restore. The tray's
panel opens under the tray icon on the Mac and Windows, and where the
click was on Linux, so it is not what moved.

Now settings.WindowAt keeps the window's top left corner (system
coordinates across every screen), per machine like Window (KeepOwn, and
the Settings page's save carries it over). keepAt saves it once a move or
resize has rested 500ms, unless the window is maximised, full screen,
minimised or hidden; settings.Save writes through temp and rename, and an
unreadable settings file is left alone. On the first show placeMain puts
it back (putBack): openAt picks the screen holding most of the window and
moves it fully onto that screen's work area; when no screen holds any of
it (a monitor gone) or the screens or the file can't be read, it stays
centred. Under Wayland a window can't place itself, so nothing is kept or
restored there unless GDK_BACKEND is x11 (keepsPlace).

Run:
- mote, at 3f8f1d88b (on d99e213f5): go test -timeout 45m -count=1 ./...
  80 packages ok; internal/gui red only in its 10 real-window AppKit
  tests (TestDockJoinLeadsCommandTab, TestPanelCloseHidesIt,
  TestPanelJoinsFullScreenSpaces, TestPluginPageLoadsItsFilesInTheWindow,
  TestDockReopenKeepsTheWindowsSpace, TestMainWindowCorners,
  TestMainWindowRightToLeft, TestHandoverLeavesTheMenuBarIconForTheNextMagpie,
  TestTrayCellClickReleasedPanel, TestCoveredWindowStaysUp), each killed
  at its deadline. The same 10 fail the same way on origin/main
  fa427216a: mote has no console session (#4125).
- mote, after rebasing onto 024393fbb (two gateway commits, none of
  these files): internal/gui (less the 10 above), internal/settings and
  internal/gateway: ok.
- mote: gofmt -l; go vet ./internal/gui ./internal/settings; GOOS=linux
  go vet -tags nogui ./...; GOOS=windows go vet ./...; go build, and
  GOOS=windows / GOOS=linux -tags nogui builds: clean.
- Windows (win-run) and Linux (wsl-run, -tags gtk3): TestOpenAt,
  TestSettleAt, TestKeepsPlace, TestOpenSize, TestSettle*,
  TestSettingsSaveKeeps*, TestWindowMaximisedKeptAndOwn: ok.

Broken by hand (each red, then restored):
- api.go not carrying WindowAt over a Settings save:
  TestSettingsSaveKeepsWhatItDoesNotSend red ("WindowAt: [] after a save
  of the Settings page, was [-1440 120]").
- KeepOwn not keeping WindowAt: TestWindowMaximisedKeptAndOwn red.
- openAt without the clamp and the gone-screen check: TestOpenAt red in
  7 of 12 cases.

Real app, Linux X11 (magpie-desktop, Xvfb 1920x1080 + xfwm4, sandbox
HOME/XDG dirs, MAGPIE_ADDR 127.0.0.1:3447, gtk3 build of this tree):
first start centred (630,240 in X terms); xdotool moved it to 200,150 and
settings.json got windowAt; restarted, it opened at 200,150; windowAt
[5000,4000] (a gone monitor) opened centred; [1700,900] opened at
[1260,480], flush with the bottom right (660x600 + GTK's 26px shadow).

Not tried: the real app on macOS (mote has no console session, #4125)
and on Windows (a sandbox magpie.exe rewrites HKCU\Software\Classes\magpie,
which points at another session's build there). Wayland is not restored
by design. Multi-monitor setups with mixed scaling were not tried on real
hardware; openAt's cases cover a second screen left of and right of the
main one.
2026-10-30 21:56:29 +08:00
yetone 6d154ef1e1 context: scripts (curl, Bun, python-httpx…) are one Scripts card, not an agent each
A request whose User-Agent names only an HTTP library or an SDK (curl,
Bun, node-fetch, undici, python-httpx, requests, aiohttp, Go-http-client,
okhttp, the OpenAI/Anthropic SDKs, …) or nothing at all got a Context
scorecard of its own, as if it were an agent (theforeveriris on X: "Bun",
"curl", "python-httpx" cards). usage.IsLibrary names those clients;
contextOfRecs folds them and "other" into one "Scripts" card at read
time, so older history reads the same way, and the card's meta line and
tooltip list the libraries by count. The cached day records are not
changed. No setting: it works as is. The Usage page's Agents list still
shows each library by name, with its Hide and Count-as-agent controls.
i18n for zh, zh-TW, ja, de. Existing context.js comments were condensed
so TestCoreScriptBudget holds without a raise (core scripts -28 bytes).

Run, at this head (rebased on 40af66027):
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
  (mote) for usage and gui; earlier the whole tree on all three, exit 0.
- mote: go test -count=1 -tags nogui -timeout 45m ./internal/usage
  ./internal/gui: ok, ok.
- Windows box: context-scripts + i18n-keys 26/26 (chromium, webkit,
  5 languages, 360 and 1100px). Before the rebase, every reachable file
  (context-*, compact-one-value, group-context, routing-context-fold,
  routing-ctx-fold, routing-ctx-still, i18n-keys, gui-de/ja/zh-tw,
  header-relang): 333/349; the 16 reds are routing-ctx-still, red the
  same on origin/main 40af66027 on that box, listed in #4124.
Broken by hand: IsLibrary false and no fold -> TestIsLibrary and
TestContextScriptsAreOneCard red (cards python-httpx, claude, Bun, ...);
the JS label/clients removed -> context-scripts.test.cjs 0/22.
Not tried: a real app run with real curl/Bun traffic; Linux WebKitGTK;
GUI files on mote (its browsers were busy with another suite).
2026-10-30 16:05:58 +08:00
yetone 46fb0c1b93 gui: the tray panel switches a Claude Code's or Codex's account (shuizhuyu on X)
shuizhuyu asked for a global shortcut to switch accounts. v0.1.2143's
Quick panel shortcut opens the tray panel, but the panel had no account
switch: switchable() returned null there, because the panel reads no
provider list (a fresh /api/providers reads every sign-in, seconds after
a start, #1519).

Now a Claude Code or Codex not connected has an "account" line in its
opened panel row (switchEntry, the window's Switch accounts only menu).
The line is drawn from the list kept from the last read
(GET /api/providers?last=1, no keychain read; panelAccounts in app.js),
read fresh only when nothing is kept. Opening the menu does one fresh
read and opens on what it says. Manage accounts… and a lapsed pick open
the window's Providers (window/main?view=providers). The provider and
login actions now keep their answer as the last list (keepProviders), so
a switch made in the window or the panel is in the next kept read.

app.js stays under its budget with no raise: my own comments and two
older ones (the usage accounts note, the sidebar note) were cut down.

Run:
- GUI, Windows box (xiaomi-gpu, win-run), Chromium + WebKit: 31 files
  (panel-*, panel-switch-accounts, agent-switch-accounts, switch-only,
  claude-switch-only, keep-login, agent-failover, agent-row-disclose,
  getting-started, click-scroll, i18n-keys, gui-zh-tw, gui-ja, gui-de):
  503 of 503 pass. Not the whole GUI suite.
- mote: no browser could launch there (pboard down, #4125; every WebKit
  and later Chromium launch timed out at 180s), so the GUI runs there
  were cut short. agent-panel-name-width, red there in both engines, is
  red on origin/main too (#4304, #4203), and this change doesn't draw
  the closed rows it measures.
- mote: go vet ./internal/gui; go test -run 'TestKeptProvidersFollowActions|
  TestLastKnownProviders|Budget|TestProvider' ./internal/gui ok (includes
  TestCoreScriptBudget). gofmt -l clean. GOOS=windows go vet ./... ok.
  GOOS=linux go vet ./... fails only in wails/v3 pkg/application (cgo
  off when cross-compiling), the same on origin/main 32f5c3369 (#4406).

At the pushed head (rebased on origin/main 32f5c3369, whose switchEntry
now leaves setup-token logins out of the menu; kept): the Go run above
again ok, TestCoreScriptBudget at the new 1,536,586 included, app.js
1,314,856 of 1,315,316; on the Windows box, panel-switch-accounts,
agent-switch-accounts, switch-only, claude-switch-only, keep-login,
agent-failover, i18n-keys, panel-fold and panel-effort: 178 of 178.

Broken by hand:
- panel-switch-accounts on origin/main's assets: 12 of 12 red in
  Chromium (no account line).
- Panel always reading fresh (laziness removed): 11 of 12 red.
- keepProviders removed from the provider action:
  TestKeptProvidersFollowActions red.

Not tried: real Claude Code or Codex accounts; the real Wails panel
opened by the shortcut; the login/{action} keep has no test of its own.
2026-10-30 15:26:03 +08:00
yetone 3bebc38393 gui: a key combination opens the quick panel from any app (ben hanks)
ben hanks on Discord asked for a global shortcut that opens the menu bar
or tray panel. Settings › General has a new row, Quick panel shortcut,
with none set by default. Clicking its field records the next combination:
a letter, a digit, Space or F1–F20 with Ctrl, Alt/Option or Cmd/Win, or an
F key on its own. Esc or a click elsewhere stops recording, and the cross
clears the shortcut. It is shown the system's way (⇧⌘K on a Mac,
Ctrl+Alt+K elsewhere).

POST /api/settings/panel-shortcut checks the combination, has the running
app bind it through Wails' GlobalShortcut (Carbon hot keys on the Mac,
RegisterHotKey on Windows, XGrabKey on X11), and saves it only once it is
bound. One the system refuses is not saved, the old one stays bound, and
the status line says why. A pressed shortcut toggles the panel as a tray
click does. The shortcut belongs to each computer (KeepOwn), the Settings
page's own save leaves it alone, and the old Mac process lets go of it as
it hands over. On Wayland no app may grab keys, so the field is turned off
and the row names the command (`magpie panel`) to bind in the desktop's
own keyboard settings.

Every string is in en, zh, zh-TW, ja and de. No size budget was raised:
app.js is 1,315,252 of its 1,315,316 after older comments were cut.

Run at this head (rebased on origin/main 1534474c8):
- mote (macOS 27): gofmt; go vet for darwin, GOOS=linux -tags nogui and
  GOOS=windows on internal/gui and internal/settings; go build ./...:
  ok. go test: settings ok; gui ok except TestMainWindowCorners/
  macOS_26_SDK, red on macOS 27 already (#3949).
- Windows (xiaomi-gpu, win-run): go test internal/gui internal/settings.
  settings ok; gui has 5 reds, the same 5 on origin/main d19afb4c9
  (TestGatewayHeldByAContainer #2107/#3649; TestLodyImportHandoff,
  TestImportStatusUnreadableIsUnknown, TestAionUiImportRow and
  TestUpdateThatWontStart #4115).
- Linux (WSL magpie-desktop, wsl-run -tags nogui): internal/gui (the
  Wayland branch included) and internal/settings: ok.
- GUI: panel-shortcut.test.cjs (new) in Chromium and WebKit, in all 5
  languages, faking both a Mac and Windows: ok. Whole suite (make test-ui)
  on mote: unfinished at the push. Three other sessions' suites were on
  the same box (load 130 to 250), and after 1605 tests it was still in
  the "c" files. Its reds so far are agent-panel-name-width and
  connect-snippet-shell and context-map (each on #4304), and allow-ips
  zh, which is red alone on origin/main too (#4357).

Broken by hand, each red:
- leaving the shortcut out of the general Settings save:
  TestPanelShortcutSetting "the Settings page's save changed the
  shortcut";
- dropping KeepOwn's line: "a synced setup took this computer's shortcut";
- dropping the recorder's stopImmediatePropagation: panel-shortcut.test.cjs
  "a key typing needs was sent, or a window key ran".
TestSettingsSaveKeepsWhatItDoesNotSend now sets the new field.

Real build on mote: a dev build in a sandbox HOME bound a saved
Ctrl+Option+Shift+Cmd+F18 as it started, and a POST of F16 saved it and
bound it.

Not tried:
- a real key press on any system: mote gives ssh no Accessibility access
  to post events, and Windows' ssh session has no desktop;
- the Windows and X11 refusal of a combination another app holds (only
  the fake). On the Mac, Carbon takes a combination a second app
  registered too, so both apps get it and magpie can't say so. This was
  checked on mote with a helper holding F17;
- Wails' GlobalShortcuts portal on Wayland, which isn't used;
- a Linux GUI-tag build (WSL has no gtk4/webkitgtk-6.0).
2026-10-30 12:06:33 +08:00
yetone 9101bb8879 privacy: a request masking would change can go as written to a model you picked
jessyoungyu on X: when a masking rule hits, send the request to a
self-hosted model instead, so a prompt like 「百度这家公司怎么样」 gets an
answer about Baidu, not about a placeholder.

Settings › Privacy › Instead of masking, send to (settings
redactRouteTo). It is Off by default, and nothing changes for a user who
leaves it Off. It is picked in the app menu, and only models whose every
route is unmasked can be chosen: the provider is set to Send requests
unmasked, it is on this computer or the network, it has no account, and
any fallback or group member is unmasked too (gateway.MaskRoute, the
same rule as provider.SkipsRedaction). The setting is saved on its own
with POST /api/settings/redact-route, which checks it with MaskRoute.
The general settings save keeps the value.

Decisions:
- When a value would actually be masked on an agent's turn (maskHits.n
  > 0), serve sends the request to the chosen model unmasked. Warn-only
  hits don't count, and Block still answers 400.
- If that model fails, the request fails. It is never masked and re-sent
  to the model the agent asked for, and never goes to a cloud model with
  the unmasked text. Falling back to a masked cloud request would answer
  a different question in the background. The user picked this route
  because masking breaks the answer.
- Streaming works the same as on any route.
- The route is checked again on every request. A model that is gone or
  no longer unmasked, or that the caller's gateway key may not use,
  means the request is masked as before.
- Covered: agents' Messages, Chat, Responses and Gemini turns (serve,
  marked by serveAgent), count_tokens, Codex magpie-model turns, and
  Codex own-sign-in /responses (codexMaskRoute).
- Not covered: magpie's own asks (ownAsk clears the mark), embeddings,
  audio, images and video. These stay masked.

GUI: redactRouteRow lives in plugins/redact/settings.js and wraps
renderRedact, so app.js is byte-for-byte unchanged and the core budget
is not raised. Strings are added in zh, zh-TW, ja and de. Docs: gateway-routing.md,
gui-shell.md, and site/public/docs masking (en, zh, ja).

Tests: internal/gateway/mask_route_test.go
(TestMaskedRequestGoesToTheModelSet: unset, set, streamed, nothing to
mask, local fails, falls back to a vendor, no longer unmasked,
count_tokens; TestCodexSigninTurnGoesToTheModelSet;
TestMaskRouteTakesOnlyUnmaskedRoutes; TestMaskRouteOnlyForTheAgentsTurn);
internal/gui/redact_route_test.go; settings_keep_test.go;
internal/gui/tests/redact-route.test.cjs (every language, chromium and
webkit, 1100 and 640 wide).

Broken by hand, each red:
- serveAgent without the agent mark;
- MaskRoute taking any route (TestMaskedRequestGoesToTheModelSet,
  TestMaskRouteTakesOnlyUnmaskedRoutes; at the pushed head);
- the codex hook removed;
- count_tokens without the mark;
- ownAsk not clearing it;
- no key check;
- no reroute in serve;
- the GUI: no keep in the general save, no MaskRoute check on save, and
  the picker listing every model;
- the plugin script left out of index.html (redact-route.test.cjs 22 of
  24 red; at the pushed head).

Run on mote:
- at 221ede767's tree, this change on f5806ed21 (pushed on 44d697993,
  which adds only app.css lines and a Gateway page GUI test):
  go test -tags nogui ./internal/gui ./internal/settings ok (the core
  budget is green again since ec789445d; #4307, filed and closed);
  the mask-route tests in ./internal/gateway ok; GOOS=linux go vet
  -tags nogui ./internal/gui ./internal/gateway ok; GUI: node --test of
  redact-route, redact-*, privacy-*, mask-*, masking-*, settings-*,
  i18n-keys, account-discovery, sessions-reads and gui-de/ja/zh-tw:
  643 pass, 0 fail. gofmt -l clean.
- at the same change on af8f3a939, one rebase back (the only
  difference is index.html's script order and main's own commits):
  go test -timeout 45m ./internal/gateway (488s) ./internal/redact
  ./internal/settings ./internal/provider ok; GOOS=linux go vet -tags
  nogui ./..., GOOS=windows go vet ./..., go vet ./... ok.
The whole Go suite was not run; every package this change touches was
run above.

Not tried: a real self-hosted model (Ollama) with a real agent. The
local model is a fake Chat server in the tests.
2026-10-30 00:46:45 +08:00
yetone af8f3a9399 sessions: a new install reads no agent's session history until the user allows it (RustCats on X)
RustCats on X: a fresh magpie showed every agent's session history on
the Sessions page before anyone agreed to it, and asked for a per-agent
choice instead.

- sessions.Reads(agent) (internal/sessions/access.go) is the one gate,
  from settings.SessionReads {Asked, All, Agents}. Every lister asks it,
  the aggregators (allFiles, callFilesWith, callSourcesWith,
  traceLineFiles, wslFiles, DesktopDataDirs) filter by it again, and
  readers of an already-listed session (TranscriptOf, ContentOf,
  SearchSession, SubagentTranscript, CarryOver, ReadCallSource) return
  ErrNotRead, so a cache from before a switch was turned off goes no
  further. The Sessions list, stats, /api/sessions/overview, the call and
  trace indexes, Usage's agent-file calls and the Codex/Pi title readers
  all pass it.
- SettleReads decides once and saves: an install with sessions.json or
  a calls-v* cache read sessions before and keeps all on; a fresh one
  reads none, not asked. A saved value is never replaced; save, sync and
  restore keep it (KeepOwn); only SetSessionReads writes it. An
  unwritable settings.json reads nothing this run.
- GUI: GET/POST /api/sessions/reads. While not asked, the Sessions page
  shows a consent card: each agent found (by a stat of its folder only)
  with a switch, Allow selected and Allow all. Settings > Privacy >
  Agents' session history has "Agents found later" and a row per agent.
  Strings in en, zh, zh-TW, ja, de.
- CLI: magpie sessions read [on|off all|<agent>...]; magpie sessions
  says on stderr when nothing is allowed yet; the TUI's empty Sessions
  page says how.

Read either way, because none of it lists or shows a session: the
gateway's own usage ledger, its projections and the conversations it
recorded (magpie's own records, so usage and cost keep working); the
agents' config and sign-in files; Claude Code's and Codex's
history.jsonl last-used time and a session file's mtime for a quota's
first use; Codex's newest rollout's last line before magpie restarts
Codex (codexTurnOpen).

Tests: TestFreshInstallReadsNoAgentUntilAllowed,
TestSettleReadsKeepsWhatWasThere, TestSessionReadsRoutes,
TestSessionsRead, TestSessionsNotAskedSaysHow, sessions-reads.test.cjs
(26 cases: consent and Settings in 5 languages, Chromium and WebKit,
390 to 900 wide).

Run on mote:
- full Go suite (gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui,
  GOOS=windows go vet, go build, go test -timeout 45m ./...) at this
  change on 8c63c5b78: 79 packages ok; internal/gui red on
  TestSettingsSaveKeepsWhatItDoesNotSend (mine: SessionReads is written
  by SetSessionReads only, the test now sets it so; green after) and
  TestMainWindowCorners (the same on origin/main c1da9ccda, #3949).
- whole GUI suite (make test-ui, concurrency 2) at this change on
  8c63c5b78: 14985 tests, 276 failed in 44 files. Mine: i18n-keys
  (comments named "Allow all"/"Allow selected"; lowercased) and
  account-discovery (read the last Privacy heading; now the one above
  its list); both green after. The 44 files again on origin/main
  c1da9ccda: 36 red there too (#4304, with #3218, #3412, #3414, #3795,
  #4120, #4125). stays-strict green alone; gateway-key-models webkit red
  1 of 3 alone on main too; plugin-github de 440 red on main (#3218).
- at the pushed head (rebased on cd10dfbe6): go build ./...; go test
  internal/sessions, settings, cli, tui ok; internal/gui
  TestSettingsSave*, TestSessionReads*, TestSessions* ok; i18n-keys,
  account-discovery, sessions-reads: 62 pass, 0 fail.

Broken by hand:
- the aggregator filter off with the leaf gates on: green (the leaf
  gates hold); both off: TestFreshInstall red on List, Agents, Calls,
  CallSources, traces, stats, TranscriptOf and Search.
- consentApplies=false and Settings' old save({all}) without the rows:
  all 13 Chromium cases of sessions-reads red.
- sessNothing's hint removed: TestSessionsNotAskedSaysHow red.

Real binary in a sandbox HOME on mote (removed after): a fresh
`magpie sessions` is empty with the hint on stderr; `sessions read`
says not asked, claude off; `read --help` prints usage and saves
nothing; `read on claude` lists the one session; `read off all`
empties it again.

Not tried: the GUI and real app on Windows and Linux; WSL agents in the
consent list (WSL distros are not looked into; Allow all covers them);
a fresh install of a signed release build.
2026-10-29 23:56:05 +08:00
yetone 8e5567161e settings: an older settings.json with no Dock choice keeps Hide
v0.1.2060 (1407c9a3b) made With window the default for a settings file
with no Dock choice. Before it, Hide was the default and was stored as
nothing, so a user who picked Hide can't be told from one who never
chose, and v0.1.2060 put both in the Dock and Command-Tab. That broke
"never let magpie's default override a value the user set".

What changes:
- A new field, dockSettled, marks a file whose Dock choice is read with
  With window as the default.
- A file without it is read the way an older magpie read it
  (settleDock): no Dock, dockWindow or dockNever means Hide (dockNever),
  and the next save writes it settled. This happens once.
- A missing file (a new install) is settled from the start, so it gets
  With window.
- A file nobody can read is read like an older one, Hide.
- The Settings page never sends dockSettled; the API save keeps the
  file's. Without that, a new install's first save from the page would
  turn into Hide.
- KeepOwn keeps it machine-local, like the choice itself.
- An older magpie writing the file drops the marker, and the file then
  reads as old (Hide unless it chose), which is what that magpie meant.
- v0.1.2060 users who picked a choice keep it. Those who picked nothing
  are back to Hide and can choose With window under Settings › Show in
  Dock.

Tests:
- TestOlderSettingsKeepHide: {} and {"theme":"dark"} read and save as
  Hide; dockWindow, dock and dockNever are kept; a second read is
  unchanged.
- TestNewInstallFollowsWindow: no file means With window, settled, and
  the first save reads back the same.
- TestSettingsSaveKeepsDockReading (gui, !nogui): a POST /api/settings
  from the page keeps a new install in the Dock while open, and keeps an
  old file's Hide.
- TestLoadChecked's unreadable-file default now expects the settled Hide.

Broken by hand (each red, then restored):
- settleDock not setting dockNever: TestOlderSettingsKeepHide red,
  "{"theme":"dark"} read as ... never false".
- The missing-file branch not settling: TestNewInstallFollowsWindow red,
  "settled false".
- api.go not carrying DockSettled: TestSettingsSaveKeepsDockReading red,
  "a new install: after a save from the page ... in the Dock ... false".

Run at this commit's tree (9bdb831b7 before this body, on origin/main
66b5e4a84), on mote via mote-run:
- gofmt -l: clean.
- go vet ./... (darwin), GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: all ok.
- go test -count=1 -timeout 45m ./internal/settings ./internal/gui:
  settings ok. In gui the only red is TestMainWindowCorners/macOS_26_SDK,
  which is red on origin/main on mote too (#3949).
- node --test dock-choice, settings-general and i18n-keys: 34/34 (5
  languages, chromium and webkit, 1000px and 440px).

Real app on mote: a -tags dev build, bundled as com.yetone.magpie.sbtest,
in a sandbox HOME on 127.0.0.1:3591/3592, launched with its window open,
type read with lsappinfo:
- An old {"theme":"dark"} file: UIElement (not in Command-Tab); the file
  now has dockNever and dockSettled.
- No file: Foreground; dockSettled is set, dockNever is not.
- An old {"dockWindow":true} file: Foreground.

Not tried:
- Closing the window by hand on mote, since ssh has no Accessibility.
- A downgrade to v0.1.2060 and back again with a real file (reasoned
  above).
2026-10-29 20:53:36 +08:00
yetone 1407c9a3bb gui: the Mac's window is in the Dock and Command-Tab while it is open, by default (ShouguangCao on X)
ShouguangCao on X: on the Mac, with the window (Settings) open, magpie
wasn't in Command-Tab, so going back to it to paste an API key copied in
another app took the menu bar.

Cause: Settings > Show in Dock already had "With window" (#101: Regular
activation policy while the main window is up, Accessory once it closes,
in openMain/hideMain through inDock and setDock), but the default was
Hide, so out of the box magpie stayed Accessory with its window open. The
main window is magpie's only window besides the tray panel, so no other
window kind needed it.

Change: With window is now the default. inDock is
`s.Dock || !s.DockNever && shown || fullscreen`; Hide is a choice of its
own, settings.DockNever (KeepOwn, like Dock and DockWindow), and the page
reads the choice through dockChoice (With window unless Show or Hide was
chosen) and saves dockNever with it. DockWindow is still written when
chosen, so an older magpie reading the file keeps With window. The tray
panel never calls dock(), so it is unchanged; Windows and Linux have no
Dock (setDock is a no-op there) and are unchanged.

For existing users: Hide was the default and was stored as nothing, so a
user who picked Hide before can't be told from one who never chose; both
now get With window, and choosing Hide again sticks (dockNever).

Run on mote at origin/main 2c89794ac + this commit; after rebasing onto
2d11cde05 (internal/provider only) the Go tests below were run again at
this head, same result:
- gofmt -l: nothing; go vet (darwin), GOOS=linux go vet -tags nogui,
  GOOS=windows go vet of internal/gui and internal/settings: ok;
  GOOS=linux go build -tags nogui and GOOS=windows go build: ok.
- go test -count=1 ./internal/gui/ ./internal/settings/: settings ok; gui
  ok except TestMainWindowCorners/macOS_26_SDK, red on origin/main
  2c89794ac on mote too (#3949, macOS 27).
- GUI, chromium + webkit: dock-choice (new, 5 languages),
  settings-general, lightweight, keep-awake, i18n-keys,
  classify-timeout-setting, image-timeout-setting, searcher-pick,
  side-effort, gui-de, gui-ja, gui-zh-tw: 158 of 159; the one red,
  searcher-pick chromium zh (a null box at line 224 under load ~30),
  passed 22 of 22 alone and is filed as #4274.
- Real app on mote (macOS 27.2): a bundle with its own bundle id, sandbox
  HOME, MAGPIE_ADDR 127.0.0.1:3591, launched with `open -n ... --args
  app`. A fresh settings.json (no dock keys) with the window open:
  lsappinfo type="Foreground" (in Command-Tab and the Dock). Through the
  real /api/settings (dev build's MAGPIE_DEV_UI) with the window open:
  Hide -> "UIElement", With window -> "Foreground", Hide -> "UIElement",
  nothing chosen -> "Foreground".

Broken by hand: inDock put back to `s.DockWindow && shown`:
TestDockFollowsWindowByDefault red ("default, window open: inDock =
false, want true"). dockChoice put back to read dockWindow: dock-choice
red 5 of 5 (chromium).

Not tried: closing the window by hand on mote and watching it leave
Command-Tab (ssh there has no Accessibility to press Cmd-W or the close
button); that path is #101's hideMain -> inDock(shown=false), unchanged,
and TestDockFollowsWindowByDefault covers "default, window closed".
Not tried on a real Command-Tab switcher by eye.
2026-10-29 20:38:00 +08:00
yetone 75a7db27b9 usage: an allowance card can be hidden from the Overview (whqtian_07012 on Discord)
whqtian wanted StepFun's plan card on Usage › Overview without its
balance card. Right-click a card (or long-press it on a touch screen)
and the app menu offers "Hide from Overview". With several accounts on
one card it says "Hide this account from Overview". A plan card that
carries its key's balance also offers "Hide its balance from Overview",
which keeps the plan. Each hidden card is saved as its tray card id plus
its kind (stepfun|balance, kimi|me@x|plan) in settings.UsageCardsHidden,
through POST /api/usage/arrange (cardsHidden). The Settings save keeps
it. Under the cards, a quiet "{n} hidden" line opens them, each with
Unhide, and Show all from two. It is the same pattern as the Agents
list's hide.

Display only: routing, caps, counting, the Accounts list, the tray
panel's Allowances (it has its own Arrange) and the menu bar cells
never see it. A cell clicked for a hidden card shows it until the page
is left (usagePeek). UI: the app menu, not a native select, no
coloured stripes, no new button on the cards.

Run at this head (rebased on 96a703a59):
- mote: go test -timeout 45m ./internal/gui ./internal/settings.
  settings ok. gui: only TestMainWindowCorners/macOS_26_SDK red, and it
  is red on origin/main 96a703a59 too (#3949, macOS 27).
  TestUsageArrangeCardsHidden and TestSettingsSaveKeepsWhatItDoesNotSend
  pass.
- Linux box (wsl-run): 107 GUI files that reach the Usage page, the
  quotas, the panel, i18n and gui-de/ja/zh-tw, in Chromium and WebKit:
  1362 of 1419 pass. usage-cards-hide passes in both engines, in en, zh,
  zh-TW, ja and de, at 1200px, 560px and 390px (touch, magpie web).
  i18n-keys passes. The 9 red files were run alone at origin/main
  96a703a59 and are red there too (57 red at the base, 51 at the head).
  #4120 has 7 of them. usage-ledger-open-settled (#4262) and
  usage-ledger-chart (#4263) are newly filed.

Rebased again on 9f36d768d, which changed app.js elsewhere. At this
head: usage-cards-hide, i18n-keys, usage-arrange, panel-arrange,
key-balance-card and usage-shared-balance on the Linux box, 72 of 72
pass. On mote, go test -run 'TestUsageArrange|TestSettingsSave'
./internal/gui: ok.

Not tried: a real StepFun account in the real app. The fixture is a
StepFun plan card with its key's balance plus a balance-only card. Not
run on Windows.
2026-10-29 18:52:05 +08:00
yetone 6915c8cdea agents: a model list's button says its ticks: all, one or two by name, or how many of how many (NG_shiyu on X)
NG_shiyu on X: the closed model field reads 「路由组,模型+数字」 on one
row and just 「路由」 on another, while the menu opened shows every
model either way.

Why: two different controls stand in that place. An agent whose own
model menu is the list picked here (ZCode, Claude Desktop, Cursor
Private Inference, WorkBuddy, T3 Code, ...: listsMenu) has a
multi-select list, and menuSaid named its first two ticked models and
"+N". Routing groups are listed first, so with every model on it read
"Never stuck, DeepSeek Pro +2": like a pick of one group and one
model. Every other agent's start picker names the one model or group
it starts on, e.g. a group named 路由. Neither said "all".

Decided: the list's button (and the panel row's words) says what its
ticks are, as the open checklist shows them and as the Models entry
already words it (fillModelsEntry):
- every model ticked: "All N models";
- one or two ticked: their names (蓝猫's few-picked case, 03421f9f4);
- more: "Showing x / N models";
- none: "No models".
The start pickers keep naming the one model the agent starts on: that
is a single choice and its open menu ticks exactly that one. No new
strings; all four are translated already.

Run:
- agent-menu-label.test.cjs (new): a ZCode list of 4 with the routing
  group first, window and panel (360px), en zh zh-TW ja de, Chromium
  and WebKit: all pass. It ticks all -> 3 -> 2 -> 1 -> none -> all
  back and checks the button, its aria-label and the panel's words, no
  "+N", no <select>, no overflow. On the old app.js it fails:
  expected 'All 4 models', actual 'Never stuck, DeepSeek Pro +2'.
- zcode-models, cursor-local-models, desktop-model-menu updated from
  the old "X, Y +1" to "All 3 models" (ZCode, 3 of 3) and "Showing
  3 / 4 models" (Cursor, Desktop: 3 of 4 on): 16/16 and 8/8 in both
  engines; agent-row-disclose, click-scroll, agent-expand-steady pass.

All of the above ran at base 841bcf8da, where the i18n-keys red was
touches connectRow, expandLink, menuSaid or the three updated tests
(click-scroll changed). At c1660481c on mote, Chromium:
agent-expand-steady 2/2, agent-menu-label 9/10 (ja window: page.goto
timed out at 5s); WebKit's launch timed out at 180s there. mote was at
load ~280 under four full suites and then stopped answering ssh, so
the rest of the run at this head, and the whole GUI suite, were not
run before the push.
2026-10-29 15:08:30 +08:00
yetone 317aa54d9c agents: a click anywhere on a connected agent's row opens or closes it (NG_shiyu on X)
NG_shiyu, new from CC Switch: on the Agents page the space between a
row's name and its model did nothing; only the small "Models {n}" link
with its arrow opened the row, which is a long way to aim on a large
screen. A disclosure row on the Mac opens on a click anywhere on it,
and the panel's rows already did.

connectRow now hands a click on a connected row to that link
(expandLink), so the link stays the one control the keyboard and a
screen reader use, with its aria-expanded. Buttons, links, inputs,
labels, anything with a role (the start picker, the switch), the grip
(still hover-only) and the opened sheet (.ag-exp) keep their own
clicks, and a click that ends a text selection does nothing. An
unwired row has nothing to open and is unchanged.

Run:
- agent-row-disclose.test.cjs (new): window at 1100px and 560px, en
  zh zh-TW ja de, Chromium and WebKit: 20/20 pass. It clicks the empty
  gap between the name and the link, checks aria-expanded follows, that
  a click inside the sheet keeps it open, the name and the link toggle
  it, Enter on the link toggles it, the picker opens #pop.model-picker,
  the grip .pop.row-menu and the switch its #modal ask without opening
  the row, the scroll position is unchanged, no overflow, no page
  errors. On the old app.js it fails ("the row didn't open", webkit en
  1100).
- click-scroll, agent-expand-steady, zcode-models, cursor-local-models,
  desktop-model-menu, agent-menu-label, i18n-keys, both engines: all
  pass except i18n-keys' "a plugin's words are its own" ("Runs as" in
  plugins/library/i18n.js vs internal/cli/claude_code_cli.go), which
  this change doesn't touch (#3897).

All of the above ran at base 841bcf8da, where the i18n-keys red was
touches connectRow, expandLink, menuSaid or the three updated tests
(click-scroll changed). At c1660481c on mote, Chromium:
agent-expand-steady 2/2, agent-menu-label 9/10 (ja window: page.goto
timed out at 5s); WebKit's launch timed out at 180s there. mote was at
load ~280 under four full suites and then stopped answering ssh, so
the rest of the run at this head, and the whole GUI suite, were not
run before the push.
2026-10-29 15:08:30 +08:00
yetone 5eab14a8cc plugin pages: magpie web reaches a page's local service on its own address, so the chat page works from another computer
aigcfree (Discord DM) runs `magpie web --addr 0.0.0.0:3430` on an Ubuntu
server behind nginx and opens it from a Windows PC. Plugins -> 对话
(@magpie-community/page-chat) showed "127.0.0.1 refused to connect": the
page sends its frame to the chat server on 127.0.0.1, which in that
browser is the Windows PC.

A plugin now declares its page's service (package.json
magpie.page.service {port, option}: the port, or the plugin option that
holds it, from its plugins.json options; plugin.ServiceSpec). Served to a
browser (isWeb), /api/plugin-pages gives the page `service`:
_magpie/service/ under its token, and the bridge hands the frame
magpie.service as an absolute address. The desktop window and slot pages
get none, and the routes answer 404 there, so the local path is as before.

servePageService reverse-proxies /_magpie/plugin/<token>/_magpie/service/…
to 127.0.0.1:<port>. The service stays on loopback. The way in is the
page's own: the per-run token that only a signed-in /api hands out,
behind AllowGuard. Nothing is weakened:
- Host is set to 127.0.0.1:<port>, which the service's rebinding check
  wants.
- The window's cookie is taken off.
- Origin must be absent or null (403 otherwise).
- Set-Cookie is dropped.
- Every reply is sandboxed (sandbox allow-scripts; frame-ancestors
  'self'), with Referrer-Policy no-referrer and nosniff.
- The gateway's own port is never served, since a request from this
  server is loopback and the gateway takes that without a key.
- Event streams flush as they come (FlushInterval -1, X-Accel-Buffering:
  no for nginx). webCompressed no longer gzips text/event-stream, which
  held a stream back until gzip's buffer filled.
- A redirect to the service's own address is made relative.
- The entry starts the plugin host as the page's HTML does (pageHost).
- A service not up yet answers its frame with a 502 page that tries
  again in 2s.

page-chat 0.1.2 (magpie-community/plugins 4a46212, on dist) declares the
service, goes to magpie.service when given one (else 0.1.1's path:
127.0.0.1 on loopback, the SSH-tunnel note from elsewhere), and asks
api/… by relative address.

Docs: plugin-runtime.md P4 (the page row), gui-shell.md (no gzip for event
streams).

Tests: TestPluginPageServiceListedToBrowserOnly, TestPluginPageServiceSpec,
TestPluginPageServiceProxied (through webHandler: Host, cookie, Set-Cookie,
CSP, escaped path and query, foreign Origin 403, made-up token 404,
redirects, SSE first event before the end and not gzipped),
TestPluginPageServiceDown, TestServiceLocation; plugin-page.test.cjs
checks magpie.service in a browser page and its absence in a slot.

Run at 276683d85, this change on origin/main e61e10535. It was rebased
since onto c1660481c, a one-line WorkBuddy mover min in internal/provider.
181fd0a68
(another session's proxy, path _service/, {portOption}) is reverted
there by 3870ddf0a, and nothing of it is left:
- go test ./internal/gui/ ./internal/plugin/ -timeout 45m, native on the
  Windows box: every new test ok. 8 reds, none in code this touches:
  - 6 fail the same at origin/main c1660481c, run there by name:
    TestGatewayHeldByAContainer, TestLodyImportHandoff,
    TestImportStatusUnreadableIsUnknown, TestAionUiImportRow,
    TestUpdateThatWontStart, TestPiPackage. All are in #4115.
  - TestLoadConcurrentWithSavesAndEdits is red 2 of 3 alone here and red
    at c1660481c too (a rename "Access is denied"); it is in #1827.
  - TestDesktopSessionTitlesOnPages passes alone (3 of 3). In the package
    run it listed the box's real WSL Codex session. Filed as #4185.
- Earlier, at bc247a8cc, on mote: the new Go tests, and go vet of both
  packages.
- Not run at this tree: the full go test ./... . mote was at load 300+
  with three other sessions' full suites, and the Linux box had one. A
  run at an older base (fa5ff2fec) had 25 packages ok, internal/agent
  among them, and none red when it was stopped for the rebase.
- gofmt -l: clean. go vet ./internal/gui ./internal/plugin: darwin on
  mote, native Windows on xiaomi-gpu. A Linux vet from mote fails in wails'
  cgo files, and in WSL for lack of gtk4/webkitgtk-6.0 headers, both
  unrelated to this change; CI vets Linux with its headers.
- plugin-page.test.cjs on the Windows box, both engines: WebKit 3/3.
  Chromium's first test is #4180, which fails the same on origin/main
  f463a8aaf. The next commit fixes #4180 at its cause.
- Real: a sandbox magpie web on mote (0.0.0.0:3561, sandbox HOME,
  MAGPIE_WEB_KEY, the real chat package from a folder, a fake gateway).
  Playwright on the Windows box opened Plugins -> chat over the LAN in
  Chromium and WebKit. The frame went to
  http://mote.local:3561/_magpie/plugin/<tok>/_magpie/service/?theme=…
  with origin null. Its fonts.css and style.css came through the proxy. A
  sent message streamed back "remote chat works", and the fake gateway
  logged both POSTs.
  - From the Mac over the LAN: /api/plugin-pages without the cookie
    gives 401. A made-up token gives 404. A foreign Origin gives 403.
    POST api/chat without the chat token gives 403 (the service's own
    check). mote.local:3563 directly is refused (loopback only).
  - Before bun was reachable in the sandbox, the frame got the 502 retry
    page.
- Broken by hand, each red then restored:
  - Without the event-stream exclusion, the stream arrives gzipped.
  - Without the Host rewrite, the cookie strip or the web gate, each
    assertion is red.
  - With the bridge's service dropped, plugin-page.test.cjs is red in
    WebKit ("magpie.service").

Not tried:
- A real nginx in front.
- A WebSocket through the proxy (httputil handles the upgrade; the chat
  page uses none).
- TLS (--tls-cert).
- The desktop app with page-chat 0.1.2: its fallback is 0.1.1's path,
  covered by the plugin's launcher tests.
2026-10-29 14:28:24 +08:00
yetone 3959192e94 gui: Settings' web search rows move out of app.js to plugins/search/settings.js (#4133)
TestCoreScriptBudget was red on main: the context map's tile wording
(a4e929212) and Cindy's Add magpie (628ac36fc) took the core to
1,531,531, over its 1,530,861, and 0ee31d473 then raised both budgets
by its own 1,969 bytes. Settings › Models › Web search (renderSearch,
renderSearcher, the search APIs' keys) is Settings' page, drawn only in
the window, so it moves into the search plugin's settings.js beside
the gateway plugin's, loaded by index.html after it. Both budgets go
back to 1,311,735 and 1,530,861, with no raise: app.js is 1,292,527
and the core well under.

docs: gui-shell.md and plugin-runtime.md name the new file.

Run at this head (rebased on 0ee31d473):
- go test -count=1 -run 'Budget|Script|Asset|Index' ./internal/gui/ on
  Windows (win-run): ok. mote's ssh timed out; Linux can't build the
  gui package (no gtk4/webkitgtk-6.0 there).
- gofmt -l internal/gui: clean.
- account-models, add-partners-shine and api-key-theme GUI files on
  Linux (WSL), Chromium and WebKit: 5 WebKit reds, the same 5 at
  origin/main 0ee31d473 (run twice there; api-key-theme's one passed
  the second time), all listed in #4120.

Run before the rebase (at 449231c19 + this change):
- The internal/gui Go tests on mote: ok except
  TestPluginPageLoadsItsFilesInTheWindow, mote's AppKit pasteboard
  (#4125), which uses its own fake page.
- The whole GUI suite on Linux, about a third through at push time.
  Its reds so far besides those above: chromium en "a Codex account is
  kept for some models" and "the Partners heading lights once an
  opening" (ja 440), both green when their files run alone at this
  head. The rest of the run is checked after the push.

Not tried: the Settings › Web search page by hand in the real app.
2026-10-29 11:49:07 +08:00
yetone 0ee31d4736 gui: Routing and Usage keep the reader's place when wheeled as they open, heard late or never (issennknight)
issennknight on Discord (macOS 13.7.8, v0.1.1902), after f92db4cdd:
"路由 用量 页面 刚点开并滚动页面时会抖动复位".

Two causes, both in the window's own scroll guard, which every page
takes:

1. A load landing under the wheel (show()'s back on the page's first
   reads, loadProvidersNow's put-back after render) called backToReader
   with the place last heard of. The page hears of a scroll a frame or
   more late (WebKit scrolls off the main thread; a loaded Mac), so each
   load took the reader's last steps back and stopped their coast.
   backAfterLoad now keeps a view that has gone on the way the reader's
   own scrolls go (readerWay, set from each of theirs) as theirs, and
   puts back only a move against it (a redraw's clamp).
2. On macOS 13's WebKit (16.6) the page never hears the wheel. Every
   gesture's first scrolls were put back until three the same way made
   a run (puttingBack): a shake at the start of each gesture, a page
   just opened included. The first run given back is now remembered
   (localStorage magpie.unheardWheels, for the next start too); from
   then on a scroll at rest waits 120ms before it is put back
   (waitsBack), and a second the same way within 80ms, the page's
   height unchanged between them, is the reader's at once (code's two
   scrolls in a row, 100ms apart in view-wheel-unheard, are both put
   back). A lone
   scroll (a redraw's, code's) is still put back, 120ms later; one
   under a click's hold at once, as before. What the wait puts back is
   recorded as an at-once put-back is, so a wheel heard later than the
   wait (a loaded machine) still gives it back (givesBack).

Not changed: the browser's scroll anchoring. It lowers scrollTop as data
comes in above with what's on the screen still; the test tells that from
a put-back (view up and what was under the pointer going down with it).
Nothing between v0.1.1902 and 425a61322 touched this guard (68 commits;
none in backToReader, readerScrolls, readerLeaves, puttingBack or
overflow-anchor), and no view has smooth scrolling.

Size budgets: app.js 1,313,704, the core 1,532,830 (main's plus 1,969), both the guard's own,
with no room added.

Tests:
- New view-open-wheel.test.cjs: Usage and Routing, opened and opened
  again, the first data held until the wheel is going; the page told of
  each scroll 80ms late (late) or never (unheard, a capture listener
  stopping the wheel, learned on the Agents page first); every frame's
  place and every write moving a view up are recorded. en, zh, zh-TW,
  ja, de; 420 and 1000 wide; Chromium and WebKit. 162/162 on this tree
  (mote).
- Broken by hand: on the base's assets (425a61322) 117/162 red: late
  Routing 31, late Usage 4 (210 to 180 under the wheel), unheard all 80
  ("nothing put the view back up": 30, 30, 30 put back each gesture).
  With backAfterLoad but no waitsBack, the unheard half was 80/80 red
  the same way; with waitsBack but readerAt unset taken as no move, red
  too (found by logging each write's stack), fixed to 0 as backToReader
  reads it.
- click-scroll.test.cjs: new subtest, a wheel heard 250ms late with
  the unheard wheels learned still scrolls the view. Red in both
  engines (Windows, 2 of 2 runs) with the wait's put-back not recorded,
  24/24 green with it (3 of 3). Found from the whole suite's first run:
  under WSL's load, click-scroll's late-heard wheel subtest went red in
  webkit, which learned the unheard wheels from a run put back.
- Also tried and dropped: .view { overflow-anchor: none }. It only
  silenced a scrollTop-only check; anchoring moves nothing on screen.
- TestCoreScriptBudget ok (mote); gofmt -l clean.
- After the rebase onto 2f5548371: TestCoreScriptBudget and the
  app.js budget ok (mote); view-open-wheel, view-wheel-unheard,
  click-scroll on mote under another session's suite (load 16 to 35):
  192/192 once, and 1 of 80 unheard subtests red once (#4132: under
  load the driver's second wheel comes after waitsBack's 120ms).
- Rebased onto c3462d5fe (main's GUI changes: context.js, i18n.js,
  the Codex auto-reset title; none in the scroll guard). app.js budget
  ok (mote). TestCoreScriptBudget is red by 670 bytes at c3462d5fe
  itself (1,531,531 > 1,530,861, #4133, taken by another session); this
  commit adds its own 1,969 to both, so the core stays 670 over, not
  more. The four scroll files on WSL: chromium all green; Linux WebKit
  red in click-scroll, view-wheel-unheard and view-wheel-after-click as
  at 2f5548371, and 7 of 80 view-open-wheel unheard subtests (a first
  gesture's put-backs before the run is learned, the #4132 class). On
  mote at load 81 (another session's full GUI suite) 14 of 113 red,
  mostly 5s click timeouts; not counted as a run.
- Whole GUI suite at this tree, WSL magpie-desktop (mote had another
  session's suite): 14,519 tests, 14,263 pass, 256 red. Every red file
  is named on #4120 / #4121 (Linux reds at main) or was run alone at
  2f5548371 and is red there the same: routing-rule-models,
  recent-calls-more, searcher-pick, usage-ledger-chart, list-sort
  (#4131), click-scroll's late-heard wheel, inner-scroll-contain,
  view-wheel-after-click and view-wheel-unheard in WebKit on Linux
  (base 9 to 10 red, this tree 4 to 9). Recorded on #4120.
- Tried and dropped: a check in waitsBack's timer for a view gone on
  further untold. It took a code scroll whose event was still pending
  under load as the reader's (view-wheel-unheard webkit red on mote).

Not tried: a real macOS 13 WebKit 16.6 (none here). The unheard case is
an emulation (wheels stopped before the page), the same one
view-wheel-unheard and view-wheel-after-redraw use. The first gesture
of a fresh install on macOS 13 still shakes once, until the run is
seen.
2026-10-29 11:26:47 +08:00
yetone a0ba8e1f2e grok: each model's context_window follows Long conversations, and one set by hand stays through a sync (uk.jent)
uk.jent (Discord #feedback) reported that magpie writes every Grok Build model's context_window as the model's whole window. They wanted about 300K without editing dozens of models, and they lost hand edits on each sync, because SetTOMLTables replaces the [model."magpie/..."] tables whole.

Grok Build now uses Long conversations, the mechanism Codex and Claude Code already use. grokWindow gives:
- min(window, Compact) when the model or provider has its own threshold;
- otherwise settings.Working(window): 272K by default on longer windows, the typed size, or the whole window with Full context.

What magpie wrote is stashed under grok:<path>:windows, and grokOwnWindow uses it to tell a hand edit apart:
- A value that differs from what magpie last wrote is the user's, and it stays.
- In a config written before the record, a value other than the model's whole window is the user's.
- Disconnect forgets the record.

The agent sheet's Long conversations row now shows for Grok Build (AGENT_PREFS). Its texts, the provider editor's hint, the Context tab's note and `magpie model compact` now name Grok Build, in en/zh/zh-TW/ja/de. setCompact and setAsync now share prefWrite. That dedupe keeps app.js under its budget, which is not raised.

Behaviour change: a Grok Build model whose window is over 272K now gets 272K by default, as Codex does, unless Full context is on.

Run on mote, at this head (c893c2229, rebased on fe05f0a72):
- gofmt -l: 0 files.
- go vet ./internal/{agent,gui,cli,settings}: darwin, plus GOOS=linux and GOOS=windows with -tags nogui. All ok.
- go test -tags nogui -timeout 45m ./internal/agent ./internal/gui ./internal/cli ./internal/settings: all ok.
- GUI agent-prefs, compact-at, compact-one-value, context-tune, context-window, gateway-mode, i18n-keys, settings-general: 202/202 in Chromium and WebKit. The new cases cover Grok's sheet in five languages at 1100 and 440, and in the 360 panel.
- At the pre-rebase head, 104 GUI files the change can reach: 1590/1622.
  - 29 of the reds were browserType.launch timeouts at load 85. Run again one at a time, every one passed, and so did usage-fold.
  - context-map's WebKit 420px "two tiles overlap" is red on origin/main fe05f0a72 too, run alone. It is recorded on #3488.

Broken by hand:
- With the keep logic removed, TestGrokKeepsAWindowSetByHand and TestGrokKeepsAWindowSetBeforeTheRecord go red ("pro 1000000 (set by hand to 300000)").
- With grokWindow returning the whole window, TestGrokKeepsAWindowSetBeforeTheRecord and TestGrokWindowFollowsLongConversations go red ("compact at 300K: pro 1000000").

Not tried:
- A real Grok binary reading the written config. Grok 1.0.67's own help documents model.<id>.context_window as driving auto-compact.
- Linux/WSL and Windows runs. Only cross-OS vet was run.
- Grok App still writes the whole window, and neither agent writes the context_windows choice list: #4117.
2026-10-29 04:43:22 +08:00
yetone a1f06bd780 gui: a browser tab offers the fonts of the computer it runs on (Norcleeh)
Norcleeh (Discord #general): magpie in Docker, used through the web GUI,
Settings' font menu doesn't list the fonts he installed on his own
computer; the app does. Cause, confirmed in the code: a tab's list is
/api/fonts, the server's families (none in a nogui build such as Docker)
plus commonFamilies, filtered by what the browser draws. A family that
is only on the browser's computer was never offered, and a choice the
server doesn't list was dropped by desktopFonts.available.

Now (webfonts.js, which only a browser tab loads; the app's windows are
unchanged):
- Where the Local Font Access API is (Chromium on https or localhost),
  the press that opens a family menu calls queryLocalFonts() once a
  page, and at load when the local-fonts permission is already given.
  The families join the list with their real styles ("SemiBold
  Condensed Italic" -> weight 600, 75%, italic).
- Elsewhere (Safari, Firefox, a plain-http LAN address, a refused
  permission) the menu's search says "Search or type a font name…" and
  offers Use "name" for a family the list lacks, enabled when the canvas
  probe says this browser draws it, greyed with "This browser can't find
  this font" when not; Enter takes it.
- A chosen family the server doesn't list stays in the tab's list on
  later loads while the browser draws it, so it keeps being applied.
- The app's menu (openProtoMenu), never a <select>. Strings in zh,
  zh-TW, ja and de. docs/subsystems/gui-shell.md says so.
Budget: no raise. here() moved out of fonts.js into webfonts.js, which
isn't a core script: loadFonts import()s it in a tab only (the page has
no CSP). The core is 106 bytes smaller than origin/main's.

Run (mote-run). At this head on e8c7dddcb: gofmt, go build ./... and
-tags nogui, go test -run 'Font|Budget|Boot|Asset' ./internal/gui
./internal/fonts ok; fonts, i18n-keys, web-page, settings-general,
inner-scroll-contain 114/114. Earlier, on 6af83172d (with a <script>
loader in place of the import):
- fonts, font-cascade, win-fonts, i18n-keys, settings-* (10 files),
  text-size, web-page, web-app-standalone, mobile-web, gui-de, gui-ja,
  gui-zh-tw, menu-scroll, omarchy, proto-menu-overflow: 311 tests
  before the rebase, 300 ok. Red: mobile-web's 8 "desktop
  matches origin/main" subtests (they read origin/main through git, and
  a mote-run copy has no .git), and settings-lines-wrap webkit zh 440px
  (a Models tab press timing out at 8s under load). At the rebased
  head: fonts, i18n-keys, settings-general, web-page,
  settings-lines-wrap: fonts' WebKit half and a lines-wrap zh-TW press
  timed out at mote load ~210 (the box then rebooted); rerun at load
  ~14, fonts WebKit 21/21 and settings-lines-wrap 20/20, the rest of the
  first run ok. The 8s press is filed as #4026.
- New tests in fonts.test.cjs, Chromium and WebKit, en and zh, 1000px
  and 440px: "a browser tab lists the fonts of the computer it runs on"
  (queryLocalFonts stubbed: not asked before the press, asked once in
  it, families and real styles offered, applied, no settings POST) and
  "a browser tab takes a typed font when the API is missing/refused".
  All 16 red on origin/main's assets (MAGPIE_FONT_ASSETS): this
  computer's families not offered, the search not taking a name.
- Broken by hand: merge() without the tab's own chosen families: the
  typed tests go red at "kept across a reload, though the server lists
  no such font" in all 8 cases.
- go build ./... and -tags nogui, gofmt -l, GOOS=linux go vet -tags
  nogui ./internal/gui, GOOS=windows go vet ./internal/gui ok; go test
  -tags nogui -run 'Font|Budget|Boot|Asset' ./internal/gui
  ./internal/fonts ok.
- Real use on mote: a nogui `magpie web` in a sandbox HOME (server list
  57 common families). Chromium with local-fonts granted: 204 families,
  185 only on this Mac; Baskerville picked, drawn, kept across a reload.
  WebKit (no API): typed Didot, offered and taken, kept across a reload.

Not tried: Chromium's real permission prompt (Playwright grants it),
Firefox, a browser on another computer than magpie's, a Docker image
run, the full Go suite (no Go change).
2026-10-28 16:55:01 +08:00
yetone 1d7ca4c6b7 gui: every scroller in every stylesheet is held to keep the wheel; Safari 15 too
碳碳双键 (ysm119, Discord): a list scrolled to its top or foot by the
wheel went on to scroll the page, "in many places". d74ef5e04 (v0.1.1839)
already marks every box that scrolls and overflows between the pointer and
its .view (`holds`, app.js) and gives it overscroll-behavior-y: contain by
one rule in app.css. This makes that a guard and closes the one engine gap:

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

Run (mote, Playwright 1.62, Chromium and WebKit):
- inner-scroll-contain: the new guard and the Safari-15 test 4/4 alone;
  in the scroll batch 7/8, the one red a Chromium launch timeout (180s).
- Scroll batch (inner-scroll-contain, routing-scroll-end, click-scroll,
  view-wheel-*, menu-scroll, context-scroll-end, provider-levels-scroll,
  heatmap-scrollbar, ledger-hscroll*, old-webkit, view-trackpad-coast):
  195/209. Reds: 9 browser-launch timeouts (mote at load 30-60 with
  ~40 other test runners), old-webkit's ":has() in app.css" from
  c490165b1 on main (#4020, not this change), view-trackpad-coast
  chromium en ("the coast must ask for more than the 250ms": 6),
  view-wheel-unheard webkit 1 subtest, menu-scroll settings de 420px
  click timeout. None of those paths registers anything new in a modern
  engine; a rerun was cut off when mote dropped off the network.
- Agent batch (agent-connect/-disconnect/-leave-magpie/-notice-lang/
  -app-restart/-connect-no-models/-connect-all-hidden/-tweak-fold,
  claude-effort, tier-effort, subagent-effort, fast-ultra,
  hidden-agent-cleared, show-unset-agent, claude-signin, i18n-keys,
  panel-routing, routing-sessions, view-middle-autoscroll): every red
  but two a browser-launch timeout; agent-connect-all-hidden webkit zh
  and ja a click timeout under the same load.
- go test -tags nogui -count=1 ./internal/gui ok (budgets); gofmt -l clean.
Broken by hand: the :where(.holds) rule and the compat.js fallback
removed: the guard red for 25 scrollers per engine, the Safari-15 test
red in both. Fallback alone removed: only the Safari-15 test red. A rule
`.sess-new-list { max-height: 300px; overflow-y: auto; overscroll-behavior:
auto }` added to sessions.css: the guard red naming it, in both engines.
Not run: the full GUI suite; the agent batch's and scroll batch's
launch-timeout reds again (mote went down mid-rerun).
Not tried: a real Safari 15.0 WKWebView (the engine's lack is faked),
WebKitGTK and WebView2 in the app, a trackpad's momentum in the app,
plugin pages in their sandboxed frames (a plugin's own scroller is
the plugin's).
2026-10-28 16:36:28 +08:00
yetone d74ef5e04c gui: an inner list wheeled to its end keeps the wheel; the page stays put
碳碳双键 (ysm119, Discord): wheeling the Usage page's request list to its
top or bottom carried on into the whole page, and "this happens in many
places". It is the class: every box that scrolls inside a scrolling page.

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

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

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

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

Verification: modal-backdrop.test.cjs fails on the original CSS in both
Windows desktop Chromium cases (blur instead of none), with the other
10 cases passing. After the fix, 45 targeted tests pass across
Chromium and WebKit: modal-backdrop, dialog-backdrop-drag,
segment-press-dialog, gui-zh-tw, gui-ja and gui-de. node --check and
git diff --check pass. The full GUI suite, Go vet/build/test matrix and
native macOS/Linux tests were not run.
2026-10-28 14:24:40 +08:00
yetone 7b63feb908 gui: a browser tab's font rows show on a nogui magpie, and Text size no longer flashes
Norcleeh (Discord #general, after v0.1.1788): in magpie's web GUI the
interface-font and code-font rows "flash once and disappear" on refresh.

Cause, reproduced on a real nogui `magpie web` on mote in Chromium and
WebKit, at 127.0.0.1, localhost and the LAN address: a nogui build
(Docker, magpie-cli) has fonts.Available false, so boot.js carried no
`fonts` flag and app.js never showed the font rows at all. What flashed
was the Text size row: index.html shows it, and renderSettings hid it
for a browser tab 40-120ms later (`#textSizeRow.hidden = web`).

Fix:
- A browser tab always gets the font rows. Its /api/fonts answers the
  server's families plus a common list (Arial, Menlo, Consolas, PingFang
  SC, Microsoft YaHei, Noto Sans CJK SC, JetBrains Mono, ...) and never
  errors for a tab; fonts.js keeps only what this browser can draw, and
  "System default" is always offered, so with nothing kept the rows still
  show with it.
- The app-only rows (Text size, tray, login, tray usage) carry
  .app-only, which `body.web .app-only` hides before first paint, so none
  of them paints in a tab.
- The boot `fonts` flag is gone. app.js and core both got smaller; no
  budget changed.
- docs/subsystems/gui-shell.md "Desktop fonts" says so.

Run (mote-run, at this head rebased on 98e23350f):
- go build ./... and -tags nogui; gofmt -l clean; GOOS=linux go vet
  -tags nogui ./internal/gui and GOOS=windows go vet ./internal/gui
  ./internal/fonts ok (at the pre-rebase head).
- go test -tags nogui -run 'Font|Budget|Boot' ./internal/gui
  ./internal/fonts ok (and with cgo before the rebase); the new
  TestBrowserTabFontsWithoutInstalledFonts covers nogui, a failed read
  and a merge with the server's own families.
- fonts, i18n-keys, settings-general, text-size, web-page: 76/76.
- Before the rebase, 20 files (fonts, font-cascade, win-fonts,
  login-allow, omarchy, settings-general/-search/-sections/-groups/
  -lines-wrap/-tabs-stick, text-size, tray-usages, web-page,
  web-app-standalone, gui-de, gui-ja, gui-zh-tw, i18n-keys) 259 tests,
  all ok but i18n-keys' "Runs as" (#3897, green now on main).
- Whole GUI suite before the rebase, --test-concurrency=4 beside other
  sessions' load: 13,626 tests, 160 red in 31 files. Those 31 files
  run alone at head and at base 0a7633136: 166 vs 157 red, the same
  tests at other widths/languages (routing-*, segs-press-redraw's
  webkit 900/440px, usage-*); mobile-web's "matches origin/main" needs
  .git, which a mote-run copy lacks; old-webkit's :has() is on base.
  segs-press-redraw alone: 7 red at head, 8 at base.
- New GUI test, both engines, en and zh: "a browser tab's font rows show
  on a nogui magpie and nothing flashes" records every rAF frame. Red on
  the old assets (uiFontRow never shows). Broken by hand: without the
  .app-only CSS rule it goes red with textSizeRow painting ~20 frames
  then going away (the reported flash); with
  `row.hidden = web && fontList?.length === 0` it goes red.
- Real servers on mote, both engines, 3 origins: nogui shows the rows
  (19 families in Chromium, 21 in WebKit), Text size never shown; a cgo
  desktop server 204/181 families.

Not tried: a Windows server with the fix (old code showed the rows),
WebKit over a LAN tunnel, Brave/Safari fingerprinting modes, the full
Go suite.
2026-10-28 12:25:39 +08:00
JoeyWu-tech 11c427eaa6 gateway: a handed-off gateway stops accepting at once and answers every connection it took (#3568)
On a restart to update the old magpie hands its listening socket to the
new one (Inherit, then HandOff once the new one serves on it). HandOff
only marked the drain, so the old one went on accepting from the shared
socket beside the new one until its end's Shutdown closed its copy.
net/http's conn.serve returns without an answer when it reads a request
after Shutdown began (go1.26.8 net/http/server.go:1994), so a connection
the old one took in the moment before its Shutdown, whose request it
read a moment after, was closed unanswered. The agent got EOF on a fresh
connection, which Go's client doesn't retry for a POST. That is CI's red
at 81a58d2f (run 40210740758, ubuntu-latest):
  handover_test.go:142: request 0 during the handover: Post
  "http://127.0.0.1:.../v1/chat/completions": EOF
`make dev`'s handover (Handover) ends through the same drain and lost
such a connection the same way.

Now:
- HandOff lets this process's copy of the socket go at once
  (stopAccepting). The new one's copy keeps the socket open, so every
  connection from then on waits in its queue for the new one, and none
  is refused. A `make dev` backend lets its own listener go as its end
  begins; the one started beside it has the port on a socket of its own.
- Before Shutdown, a handover's end waits until Serve has returned and
  each connection it took has had its first request read (unreadConns,
  the server's ConnState), unreadWait (5s) at most: a connection that
  sends nothing for 5s is idle to Shutdown too. Serve returning counts
  because net/http notes a connection (StateNew) on the goroutine that
  took it, after Accept and before Serve can return; Shutdown marks the
  server shutting down before it waits for Serve, so one noted after
  that would have its request cut too.
- Serve ending because its listener was let go waits for the drain, as
  an end through Shutdown does.
An ordinary quit and a restart that waits are unchanged: no wait, the 2s
drain. Documented in docs/subsystems/gui-shell.md (the handover's step
3) and gateway-routing.md.

Not changed:
- With TLS on, tlsListener has a connection from this computer wait for
  its first byte (sniff) before handing it to the server, and closes one
  still waiting when the listener closes (hand, tls.go:288). Such a
  connection is still closed unanswered, at HandOff now and at Shutdown
  before (#3647).
- `make dev`'s own backend server (dev_on.go, dev builds only), which
  serves the page rather than agents, still calls Shutdown at once as
  its handover begins: the same drop for the page's requests (noted on
  #3568).
- An idle keep-alive connection is closed by Shutdown, as HTTP/1.1 lets
  a server do; a client sending on it in that moment sees it closed.
- What waits in `make dev`'s own SO_REUSEPORT queue when it closes is
  reset by the kernel, at its end's start now and at Shutdown before.

What was run (tree e1968b96, on origin/main 9fc382e6, go1.26.8; Linux,
outside graftcp, umask 077; line numbers at this tree):
  TestHandedOverGatewayFinishesItsStream as it is, -count=200: 3 of 200
  red at origin/main with CI's message (handover_test.go:142 there),
  0 of 200 with this change
  with the drain injected 50ms late and a connection taken once handed
  off served 100ms late (scratch, env-gated), -count=20: 10 of 20 red at
  origin/main's gateway, handover_test.go:144: request 0 during the
  handover: Post "http://127.0.0.1:.../v1/chat/completions": EOF; 0 of
  20 with this change. The drain 50ms late alone: 9 of 20 red there,
  handover_test.go:153: the new one answered 0 of the 5 requests after
  the handover; 0 of 20 with it
  the new tests on origin/main's gateway.go and handover.go, -count=20:
    TestHandedOffGatewayTakesNoNewConnection 20 of 20 red:
      handover_test.go:275: the old one answered 1 request(s) made once
      it had handed the gateway off
    TestHandedOffGatewayAnswersAConnectionItTook, both subtests 20 of
      20 red: handover_test.go:335: a request on a connection the old
      one took, sent once its end began: "" unexpected EOF
    TestHandedOffGatewayAnswersAConnectionNotedLate, both subtests 20
      of 20 red: handover_test.go:435: a request on a connection the old
      one took, noted once its end began: "" unexpected EOF
  with this change, -race -count=20 of those four, TestSameAddr,
  TestInheritedForAnotherAddressIsLetGo,
  TestToolCallOfTheMagpieBeforeGoesToIt,
  TestCallbacksSocketServesOnlyToolCalls and TestBridgeTurnsCount: ok,
  no race (load 94)
  broken by hand, with this change, -count=20 each:
    HandOff not letting its listener go:
      TestHandedOffGatewayTakesNoNewConnection 20 of 20 (:275), and
      TestHandedOverGatewayFinishesItsStream 1 of 20,
      handover_test.go:153: the new one answered 1 of the 5 requests
      after the handover
    Serve's end once its listener is let go not waiting for the drain:
      TestHandedOverGatewayFinishesItsStream 20 of 20,
      handover_test.go:159: the old one ended with a stream in flight:
      accept tcp 127.0.0.1:...: use of closed network connection; the
      four subtests above 20 of 20 with the same error (:342, :440)
    no wait before Shutdown: the four subtests 20 of 20 (:335, :435)
    the wait not waiting for Serve to return: both subtests of
      ...NotedLate 20 of 20 (:435)
    a `make dev` end keeping its listener: both make dev subtests 20 of
      20, handover_test.go:345: the old one never ended once its
      connections were answered (it waits out unreadWait's 5s; the
      tests give it 3s, against the ~0.1s it takes)
    the end's steps for a handed-off gateway only: both make dev
      subtests 20 of 20 (:335, :435)
  internal/gui TestRestartHandsTheGatewayOver -count=20, the other gui
  handover tests -count=3 and internal/handoff -count=3: ok, as at
  origin/main
  -run TestTLS ./internal/gateway -count=3: ok
  gofmt -l: nothing. GOOS=linux and darwin go vet -tags nogui ./...,
  GOOS=windows go vet ./...: exit 0. GOOS=linux and darwin go build
  -tags nogui ., GOOS=windows go build .: exit 0
  full suite, go test -tags nogui -count=1 -timeout 45m ./... (302 s,
  load 76 to 97): 64 packages ok, internal/gateway among them. 14 reds
  in 7 packages, none in a file this change touches:
    internal/agent TestCursorFolderFromTheEditorIsNotTheCLI,
    TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
    TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
    TestOmpDetectedWithPiDir: proc.Look keeps "not found" for a tool
    written in the tick of its folder's last change (#3141).
    internal/agent TestReasonixCLIRequiresSupportedNativeVersion and
    TestReasonixCLIRecoversAfterProbeTimeout: their fixture build under
    /tmp meets a /tmp/.git that isn't a repository of this user's
    ("error obtaining VCS status: exit status 128").
    internal/davsync TestSync and TestSyncTeraCloudStillSeesOtherWrites:
    the local save lands in the push's clock tick (#3420).
    internal/edit TestWriteAtomicReadOnlyHardLink and internal/testenv
    TestProgram: umask 077 here; the fixtures' own modes go through it.
    internal/gui TestGatewayHeldByAContainer and
    TestGatewayFixQuitsOnlyAMagpie: proc.ListeningOn reads every fd this
    user can, 19.7M on this machine (other projects' processes leak
    them), which takes 1m30s against the 30s the take-over gives it;
    both pass in a fresh pid namespace.
    internal/netproxy TestBunProxyLoginWithReservedCharacters: Bun
    1.3.11 on PATH (#3397).
    internal/provider: fatal error: close of synctest channel from
    outside bubble, in TestUnreadLoginsWriteErrorsKeepCredentials
    (#3632).
  (A first suite run under systemd's own PATH, node v12 and no Bun, had
  four more in internal/plugin, "Cannot find module
  'node:assert/strict'"; with the user's PATH, node v22, it is ok.)
Not tried: a real restart to update on Linux or macOS (the tests hand
the socket over within one process), and macOS at all; Windows, which
doesn't hand over (vet and build only); a Relisten reaching the old one
after HandOff, whose window is withdrawn by then.

Ported from JoeyWu-tech's fix/3568-handoff-stops-accepting (56c67ad2,
posted on #3568 on 10-25) after it went red on ubuntu CI again at
0a7633136 (run 40614167541, handover_test.go:142 EOF). Cherry-picked
unchanged onto origin/main.

Run again by the porter (mote-run, at a05b37353 + this; at the pushed
head 69626580b + this, go build ./... and the handover set -count=10 ok;
7bdefe212 since then changes only the Routing page's JS, CSS and GUI tests):
- the three new tests on the old gateway.go/handover.go, -count=5: 15 of
  15 red; with this change, with TestHandedOverGatewayFinishesItsStream,
  TestSameAddr and TestInherited*, -count=20: ok.
- the same set plus TestRestartHands*, -race -count=10: ok.
- GOOS=windows and GOOS=linux go vet ./internal/gateway: ok. gofmt -l clean.
- go test -timeout 45m ./internal/gateway: ok (510s). ./internal/gui/...:
  TestMainWindowCorners/macOS_26_SDK red on mote's macOS 27, #3949, not
  touched here.
Not tried: a real update restart.
2026-10-28 10:17:14 +08:00
yetone 833f51adcf gui: a browser tab has the font rows too, with its own choice
Norcleeh on Discord: magpie opened in a browser had no font setting in
Settings > General, while the app does. The rows were hidden on purpose:
/api/fonts answered 404 to a browser page and boot sent it no choice,
since the list is the fonts of the computer magpie runs on and the tab
can be on another one.

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

Run on mote at this tree (on b90e81da1), also GOOS=linux (nogui) and
GOOS=windows go vet ./internal/gui/..., go build, gofmt -l:
- fonts.test.cjs, font-cascade.test.cjs, win-fonts.test.cjs, i18n-keys
  and the 42 drag/arrange GUI files, Chromium and WebKit, en and zh (and
  ja/de where a file has them). The reds are 32 subtests in 4 files
  that fail the same on origin/main b90e81da1 run alone (and one from
  a stray path in the run command): i18n-keys "a
  plugin's words are its own" (#3897), routing-rule-drag webkit de
  (#3789), segs-press-redraw webkit (#3922), usage-agents-hide (#3414).
- go test -tags nogui ./internal/gui (TestCoreScriptBudget and
  TestFontSettingsAPIAndBoot included) ok; go test ./internal/gui -run
  Font (cgo, CoreText) ok.
- Real use: magpie built on mote, `magpie web` in a sandbox HOME, real
  /api/fonts (204 families). Chromium offered 204, WebKit 179; Georgia
  picked in each, the body drew it and kept it across a reload, and no
  settings.json was written.
Broken by hand: fontsOn = !web (rows hidden as before): the new test
red in all four engine/language cases; here() returning the list
unfiltered: red with "a family this browser doesn't draw isn't
offered".
Not tried: a browser on a different computer from magpie (the canvas
filter is what covers it, checked with a family the test machine
lacks), Firefox, the Windows and Linux apps' pages in a browser.
Budget: not raised; the previous commit's 1,097 bytes cover it.
2026-10-28 08:01:46 +08:00
yetoneandggbdpq 7f0f71a0ef gateway: a refused or empty-failed Codex relay's call carries its route (#2481)
The Routing page's "Request and response" finds a request's call by its
route (RouteCall). Of codexUpstreamOn's three record exits only the
success one set Call.Route, so a turn whose API key OpenAI refused (401)
or that the backend failed with nothing said opened as "the request is
gone" though its call was one of the last 40. Both failure exits now
carry the route through routeOf, which is 0 for a compaction: both exits
are reached by /responses/compact too, where no route opens.

Reported with a patch by ggbdpq (gua2100 on Discord). The patch set
Route: tr.ID unguarded on the empty-failure exit; since the
outrageous_piglet change that exit also takes a compaction, where tr is
nil, so that line panics on a compaction failed with an empty body.
routeOf guards both exits. gui-shell.md says which Codex exits carry
the route.

Run (sandbox HOME, caches pinned):
- TestCodexKeyRefusedCarriesItsRoute, TestCodexEmptyFailureCarriesItsRoute
  (ggbdpq's, the asserts moved into routeHasItsCall) and the new
  TestCodexCompactEmptyFailureRecordsNoRoute: ok.
- Broken by hand: with both exits back to no Route, the first two fail
  "route N: no call in the ring, so Request and response says the
  request is gone"; with the patch's unguarded tr.ID on the empty exit,
  the compaction test panics (nil pointer dereference). Restored: ok.
- go test -tags nogui -run 'TestCodex|TestRouting|TestArchive|TestRouteCall'
  ./internal/gateway: ok (31s).
- gofmt -l clean; go vet darwin, GOOS=windows, GOOS=linux -tags nogui on
  ./internal/gateway: clean.

Not tried: a real OpenAI 401 or a real empty ChatGPT backend failure
(fake upstreams); the GUI's routing-bodies test (the GUI is unchanged);
the full ./... suite (one suite per machine, others running).

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-28 00:41:37 +08:00
yetone e056779a67 gui: the app serves its page to a browser, behind its key (Settings › Browser access)
jiakun_zhao on X ran `magpie web` in a terminal beside the desktop app,
to manage it through a Cloudflare tunnel. Settings › Network and sharing ›
Browser access now has the app serve the same page itself: Off, This
computer (127.0.0.1, for a tunnel or SSH forward) or Local network.

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

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

Not tried: a real Cloudflare tunnel to the page, and Local network from
another machine.
2026-10-27 18:58:16 +08:00
yetone 6ce0f14b98 gui: magpie web's page port judges every gateway route as from another machine (reported privately by Coffemon)
Since 1b32bdcf (v0.1.1444) the page port of `magpie web` / `serve --web`
hands the gateway's client routes to the gateway. The gateway counts a
loopback request with no forwarding header as an agent on this computer,
which needs no key. A request reaching the page port over loopback without
such a header was answered that way, so the page port gave the gateway's
routes without a gateway key, with sharing off. Before 1b32bdcf every
request there needed the page's key.

Now every request the page port hands over is marked
(gateway.FromPagePort, the X-Magpie-Page-Port header) and local() is false
for it: answered only while magpie is shared (or on the network), with an
enabled gateway key, from loopback too, under any Host or browser marks,
and with MAGPIE_TRUST_PROXY set. While not shared lanGuard refuses it 403,
saying to use the gateway's own address. lanGuard moves the mark into the
request's context and drops the header, so it never goes upstream.
toGateway (another magpie serves the gateway) passes the mark on and adds
the loopback peer as X-Forwarded-For when no forwarding header came, so an
older gateway that doesn't know the mark still asks for a key. Agents on
this computer keep the gateway's own port (3425), key-free from loopback as
before. The page itself calls no client route (checked app.js and
plugins.js: the /mcp and /v1 addresses there are copied, not fetched), so
nothing in the GUI needs a key on the page port. The routes covered are
all of gateway.ClientPath (/v1, /v1beta, the routes without /v1, the Codex
backend path, the search path, /mcp), since the mark is set in onePort for
each of them.

docs/reference.md's one-port paragraph, gui-shell.md and
gateway-routing.md now say the page port answers these routes as from
another machine and that agents here use the gateway's port; the old text
said a same-machine proxy's requests carry forwarding headers, which a
forward that adds none doesn't.

Tests:
- TestWebOnePortServedHere / ServedElsewhere: a loopback request with no
  key and no forwarding header to /v1/chat/completions, /chat/completions,
  /v1/responses, /v1/messages, /v1/models, /v1beta/models, /mcp/github,
  /mcp/magpie/web-search and the Codex backend, under Host 127.0.0.1:3430,
  127.0.0.1, localhost:3430 and a public name, with a browser's marks, a
  CLI's user agent and an IPv6 loopback peer: 403 not shared, 401 shared.
  Red on the old code (404 "knows no model" / "isn't signed in to an MCP
  server": the handlers were reached). The old "for an agent here" 200 is
  now 401; loopback with a gateway key 200. Origin null, foreign Origin
  and rebound Host without a key now 401 (lanGuard asks the key first);
  a foreign Origin with a key still 403. A 429 from the process's
  failed-key bucket counts as the 401 it replaces.
- TestWebOnePortAgentsHereUseTheGatewayPort: the gateway's own Front from
  loopback without a key 200; the page port 403 with the reason and the
  gateway's URL; MAGPIE_TRUST_PROXY=1 doesn't make it local.
- TestPagePortMarkIsNeverLocal (gateway): marked requests never local
  under MAGPIE_TRUST_PROXY; refused unshared; with a key the handler sees
  no header and local false.

Broken by hand, each red, then restored:
- onePort not marking: ServedHere and AgentsHere red; ServedElsewhere
  stays green on the X-Forwarded-For fallback alone (the older-gateway
  path).
- local() ignoring the mark: ServedHere, AgentsHere, PagePortMark red.
- lanGuard not taking the header off: PagePortMark red (handler saw it).

Real try (built binaries, sandbox HOME, MAGPIE_NO_ACCOUNTS=1,
MAGPIE_TEST_SANDBOX; gateway 127.0.0.1:3561, page 3562, a raw TCP
forwarder (a Go listen/dial/copy loop, as socat would be) on 3563 -> 3562,
a fake OpenAI-compatible upstream on 3564 added as a provider):
- `serve --web` (gateway in process), origin/main c37bcdbfc binary: through
  the forward with no key, chat 200 (upstream called), /v1/models 200,
  /v1/responses and /v1/messages reached the provider, /mcp/magpie/web-search
  with Host 127.0.0.1 200; the page's /api/settings 401. 5 upstream calls.
  This change: every one of those 403 with the page-port reason; the
  gateway port's agent chat 200; 1 upstream call (the agent's).
- `serve` plus a separate `magpie web` (served elsewhere): old binary 200
  for chat and MCP through the forward, shared or not, with no key or the
  page's cookie only. This change: 403 not shared; shared, 401 with no key
  and with the page's cookie only, 200 with a gateway key; the page signs
  in through the forward and /api/settings is 200 with its cookie; the
  upstream request carries no X-Magpie-Page-Port.

Run at this head (rebased on origin/main f0ffee34c):
- go test ./internal/gui ./internal/gateway -run 'TestWebOnePort|TestClientPath|TestWebAssets|TestPagePortMark|TestAllowList|TestLAN|TestRebound|TestProxied' -count=1: ok
- gofmt -l internal/gateway internal/gui: empty; go vet (darwin),
  GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet -tags nogui
  ./... (before the rebase), GOOS=linux/windows go vet of gateway, gui and
  cli at this head: ok
- The full suite (go test -tags nogui -count=1 -timeout 45m ./..., one per
  machine, waiting behind another session's run) was not run before this
  push: a security fix ships at once. It runs at this head next; any red it
  names gets its own commit.

Not tried: Windows and Linux beyond vet; nginx (its XFF path is unchanged
and covered by the "through a proxy" cases); a real vendor account; the
GUI suite (no GUI asset changed).
2026-10-27 15:15:29 +08:00
yetone 9022169f6a web: magpie web added to a phone's home screen opens as an app (ninja_s6114 on Discord)
ninja_s6114 runs magpie in Docker and put the web UI on an iPhone's home
screen; it opened with Safari's address and bookmarks bars. Now it opens
standalone, with no setup:

- index.html links manifest.json (display standalone, name magpie, start_url
  and scope "./", 180 and 512 px icons) and an apple-touch-icon, and sets
  apple-mobile-web-app-capable, mobile-web-app-capable, the title and status
  bar style "default". theme-color is set only under (display-mode:
  standalone), light #f4f4f6 and dark #1a1a1e, so a browser tab and the
  Wails windows look as before.
- webGuard serves exactly /manifest.json, /icons/apple-touch-icon.png and
  /icons/icon-512.png on GET/HEAD without the key, since a home screen may
  fetch them without the page's cookie. Everything else still needs it.
- The header's safe-area padding already in app.css (body.web .top) keeps it
  out from under the status bar and notch; app.css is unchanged.

Run, at this head (rebased on origin/main):
- go test ./internal/gui: ok, except TestRestartHandsTheGatewayOver, the
  handover EOF under load (#3451); it and TestWebAppAddsToHomeScreen pass
  3 of 3 alone.
- gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui, and
  GOOS=windows: ok; go build ok.
- GUI web-app-standalone + i18n-keys: chromium 8/8, webkit 6/6 (the
  standalone cases are Chromium only, as WebKit can't emulate
  display-mode standalone; they run under --app with iPhone 13 safe-area
  insets 47/34 and touch, portrait and landscape, light and dark).
- Before the rebase, 34 GUI files picked for strict fixtures/assert.fail on
  unexpected requests, plus menu-scroll, phone-web, mobile-web, web-page,
  old-webkit, usage-ledger and i18n-keys, in both engines: 563 of 576 pass.
  The reds fail the same on an origin/main copy and are filed:
  old-webkit Safari 15 (#3403), phone-web flick under load (#3180),
  gateway-key-models webkit under load (#2648), usage-ledger
  return-to-live (#3104). provider-detect-draft timed out under load and
  passes 20/20 alone.

Broken by hand:
- the guard exemption removed: the Go test fails with 401 on the manifest
  and the icon;
- the old index.html: the Go test fails on the missing tags, and the GUI
  test fails in WebKit too;
- theme-color media without display-mode: the GUI test fails in both
  engines;
- app.css's body.web .top safe-area padding removed: the standalone test
  fails, ".top .brand under the status bar: 8".

Not tried: a real iPhone or Android device and a real install; the whole
GUI suite (the machine is loaded and nearly out of disk; run afterwards).
iOS keeps the display mode it saw when the icon was added, so a user
removes the old icon and adds it again. A home-screen app on iOS may not
share Safari's cookie, so it can ask for the key once; MAGPIE_WEB_KEY keeps
the key the same across restarts. iOS 27's top blur over the header is
#3515, not changed here.
2026-10-27 14:27:12 +08:00
yetone 5215108e53 gui: magpie web shows MAGPIE_PUBLIC_URL at the sidebar's foot and in About's Gateway URL, as the Gateway page does (noahhrreion on Discord)
noahhrreion runs magpie in Docker and sets the gateway's address with
MAGPIE_PUBLIC_URL; the address at the foot of the page didn't show it.
Since #1551 a page other machines open (magpie web) shows
MAGPIE_PUBLIC_URL, while they are let in, as the gateway's address on the
Gateway page, starts Connect and its snippets at it, and uses it for
Settings' MCP addresses. Two places still said the container's loopback:
- the sidebar's gateway line (renderSideGw): it drew providers' and
  boot.js's `url` only. It now draws `publicURL` in magpie web, and
  boot.js's `sideGateway` carries it (same rule as settingsState: shared,
  or MAGPIE_ADDR on the network, as the image's 0.0.0.0 is)
- Settings › About's Gateway URL: in magpie web it is the public URL,
  and the separate Public address row, then the same, is left out
In the app on this computer both stay the local address that agents here
are pointed at, as before. The address list in Share on local network
already gives MAGPIE_PUBLIC_URL alone, and Connect and the copy buttons
were already at it.

Run (worktree at origin/main 11dcc743f + this, darwin/arm64, load ~150):
- go test -count=1 ./internal/gui/: ok (TestBootSaysWhereItsGatewayListens
  now checks publicURL is in sideGateway on the network and absent on
  loopback; the script budget tests pass, not raised)
- gofmt -l clean; go vet darwin and windows on internal/gui. The linux vet
  of internal/gui doesn't build Wails without cgo on this Mac, in Wails
  itself, as on main
- public-url-default.test.cjs, Chromium and WebKit, en zh zh-TW ja de,
  1100 and 420 wide: 26 pass
- the 18 GUI files on the changed caller-keys fixture plus sidebar,
  gateway-port, i18n-keys, settings-general, settings-sections and
  settings-search, 3 wide: 322 pass, 4 fail. Rerun 1 wide, 3 passed and
  gateway-caller-keys webkit stayed red at line 137; it is red 4 of 5
  on 11dcc743f without this change too, #3797. gateway-key-models webkit
  (#2648) and gateway-own-key zh 440 (#3842, filed now) passed alone.
Broken by hand:
- renderSideGw back on g.url: public-url-default's magpie web test red
  at 1100 wide
- About back on s.gateway: red at both widths
- boot.js without publicURL: TestBootSaysWhereItsGatewayListens red
Not tried: a real Docker container with MAGPIE_PUBLIC_URL; the page was
driven with a faked API. Not asked of the reporter yet: whether they open
magpie web, or the desktop app, which keeps the local address.
2026-10-27 13:30:16 +08:00
yetone 66061fd4df gui: the tray panel's Usage cards have the same per-account eye as the window (yogurt36)
yogurt36 on Discord asked for Hide accounts per account wherever people
take a screenshot: the menu bar panel's usage as well as the window's
providers, with one logic and one interaction. d3191a51c gave the
window's provider rows and Usage cards an eye and left the panel always
masked. Now each panel Usage card has the same eye beside its name
(hideAccounts.eye in a .pq-who wrapper, so the name still ellipsizes and
the eye keeps its place), going through the same shown set that hits()
skips, with the same look: hidden with Hide accounts off, quiet until
the card is hovered or the eye has focus, in sight while it shows its
account. A click shows that account, its name and address together
(kin), on its card and in the card's tooltip; the others stay masked.

How long: until the panel is put away. The panel's page stays loaded
while hidden, so its visibilitychange (the one that already drops
panelPeek when the panel is put away) calls hideAccounts.closed(), which
now does nothing when nothing is shown. Memory only, never stored.

Shared or not: not shared. The window and the panel are separate pages
with separate sets, and that is kept on purpose: one shown in the window
for a screen share stays masked in the panel and the other way round,
so a screenshot of either shows only what was shown there, right in
front of the user. A shown account leaking into the other surface
would be the surprise a privacy switch can't afford.

Run (macOS, playwright 1.62.0, at d4699c00a; rebased on origin/main
1885c607e, which touched i18n.js, routing/client.js and providers.go
only, and the lines below marked "after rebase" were run again there):
- account-eye.test.cjs: 15/15 in chromium and 15/15 in webkit, en zh
  zh-TW ja de; the new panel test at 360px and 440px (no select, no
  stripe, no sideways scroll, the eye inside its card, a click scrolls
  nothing, the window still masks an account shown in the panel and
  the panel one shown in the window). After rebase: both engines again.
- Red on the old code (app.js/app.css from d4699c00a): the new panel
  test fails ("the panel's card has an eye").
- Broken by hand, each red, then restored: no closed() in the panel's
  visibilitychange; no .pq-card:hover rule; the shown check in hits().
- 35 GUI files that open the panel with its cards or masking
  (account-alias, account-mask*, mask-*, masking-records, window-mask,
  provider-unmasked, panel-*, quota-*, tray-*, codex-*, usage-fold,
  click-scroll, i18n-keys and others), both engines: 550/552. The two
  reds are usage-fold's "the view didn't scroll" (184 !== 180) in
  chromium en and zh; they fail the same, 3 runs of 3, with d4699c00a's
  own app.js and app.css: #2163, untouched here.
- go test ./internal/gui: ok (TestCoreScriptBudget included; app.js
  1,317,850 bytes, no budget raised). After rebase: ok.
- gofmt -l clean; go vet ./internal/gui on darwin, GOOS=linux -tags
  nogui and GOOS=windows: ok.

No new strings: the eye reuses "Show this account" / "Hide this
account", already in zh, zh-TW, ja and de.

Not run: the whole GUI suite and go test ./... (another session may be
running them). Not tried: the real tray panel being put away in the
Wails app on macOS, Windows (WebView2 is hidden through chromium.Hide)
and Linux; the visibilitychange it relies on was dispatched by hand.
2026-10-27 04:20:57 +08:00
yetone f92db4cdd0 gui: a page wheeled right after a click that redraws scrolls on macOS 13's WebKit (issennknight on Discord)
issennknight (macOS 13) tried v0.1.1621 (a6d7e02c7): the page still stood
still and shook back under the wheel right after switching the Usage
page's tabs (Overview/Requests/Sessions/Context), and after an agent's row
on the Agents page was opened and then closed.

Cause, the same class a6d7e02c7 left open: under a click's 4s hold, a
scroll put back counts toward the reader's run only when the page was not
redrawn since the hold last held it (redrawn(h), against h.lay). h.lay
measured the first three held parts with NaN for one gone from the page,
and NaN never equals NaN, so a click that draws what it clicked again (the
Usage tabs are rebuilt by renderUsageTab, the agents' list by
renderAgents) read as "redrawn" at every scroll for the whole hold. A held
part stuck to the view's edge (Settings' tabs, sticky below SIDE_AT) read
the same: its place in the page changes with every scroll. Every scroll
in those 4s was put back, as the old gate did.

Fix, at the one choke point (laid/redrawn): h.lay keeps the first three
held parts still in the page that scroll with it (no sticky or fixed
ancestor inside the view), with the nodes themselves. A part gone since is
a redraw once; hold() then lays the page again and the next scroll counts
as at rest. The view's height is checked as before. Every click on every
page goes through the same hold, so this covers every tab bar, list or
card drawn again under a click, not only the two reported.

Tests:
- New view-wheel-after-redraw.test.cjs, a wheel the page never hears
  (capture listener stopping it, as view-wheel-unheard): each Usage tab
  clicked in turn, an agent's row opened and then closed, and a Settings
  tab clicked with the page scrolled under the sticky tabs; after each
  click ten wheels down and ten up must move the page. en, zh, zh-TW, ja,
  de, 420 and 1000 wide (Settings at 420 only, where its tabs are sticky).
  On origin/main's assets (MAGPIE_AFTER_REDRAW_ASSETS): 25 of 25 red in
  Chromium and in WebKit, "ten wheels of 30px right after the click
  scroll the page: from 0 to 0". With the change: 25 of 25 green in both.
- Same tree, both engines: click-scroll 11/11, i18n-keys 4/4,
  view-wheel-after-click 13/13, view-wheel-unheard 3/3,
  view-trackpad-coast 3/3, agent-expand-steady 2/2, held-animations 2/2,
  routing-days-fit 6/6, routing-failed-open 4/4, stays-strict 15/15,
  update-auto 5/5. Box at load 40-140.
- go test -tags nogui -run 'Budget|Builtin' ./internal/gui ok
  (TestCoreScriptBudget; budget not raised).

At the pushed head (rebased on 6e9820a3a..d56c14e95, 31da93ccd touched
app.js): view-wheel-after-redraw 25/25, click-scroll 11/11, i18n-keys
4/4, view-wheel-after-click 13/13 in both engines; the Go budget tests
ok (app.js 1,317,342 bytes, budget not raised). The other files above
ran at the base e1709ab42.

Broken by hand: origin/main's laid/redrawn (above, all red); the sticky
check alone removed (scrolls() returning true): the five Settings
subtests go red in Chromium, the Usage and agent ones stay green.

Not tried: real macOS 13 / WebKit 16.6 and a real trackpad; the whole GUI
suite and the Go suite were not run.
2026-10-27 02:51:04 +08:00
yetone a6d7e02c77 gui: a page wheeled right after a click scrolls on macOS 13's WebKit too (issennknight on Discord)
issennknight (macOS, trackpad): every page scrolled again, but a saved
profile opened on the Agents page and then scrolled through often stayed
where it was. macOS 13's WebKit scrolls a view under wheels it never
dispatches, so the view guard puts each such scroll back and takes three
put back the same way within a second as the reader's run (30d3001a0).
That rule skipped every put-back while a click held what it clicked, and
a click holds for 4s: a profile opened and wheeled through at once was put
back on every scroll and the page stood still ("sometimes" = within 4s of
a click). A wheel the page hears was fine.

Now a held view's put-back is the hold's only when the page was redrawn
since the hold last held it (the view's height, or where the first held
parts sit, moved from what hold() left in h.lay). A scroll with the page
laid out as the hold left it counts as at rest, so the reader's run is
given back a click before it too. One scroll by code after a click is
still put back: view-wheel-unheard's last case now checks that (its old
per-frame code scroll is a run, given back by design).

Other inner scrollers checked: the panel's Profiles popover (overflow
auto, overscroll-behavior contain) is outside any .view and the guard;
the provider editor's .mchips keeps contain except under 640px tall, an
earlier deliberate call, left alone.

Tests:
- New view-wheel-after-click.test.cjs: wheels (unheard and heard) over
  the long profile's details right after the click, to the foot, past it
  and back up; the short one's too; nothing but the view scrolls. en, zh,
  zh-TW, ja, de at 420 and 1000 wide, Chromium and WebKit. Red on
  origin/main's assets (MAGPIE_AFTER_CLICK_ASSETS) in 20 of 24 subtests,
  "ten wheels of 30px right after the click scroll the page: from 153 to
  153"; the heard cases pass there. Green with the change.
- Before the rebase, 59 GUI files the change can reach (every scroll/wheel/view-/click/
  hold/held/keep/profile/unroll/jump/stay/still file, old-webkit,
  text-size, sidebar*, last-page, routing-days-fit, routing-failed-open,
  update-auto, i18n-keys, gui-de/ja/zh-tw), both engines, at
  --test-concurrency=4 on a box at load 130-160: 810 of 816 pass. Reds,
  each red alone on origin/main 865df2472 too: menu-input-scroll (#3402),
  old-webkit Safari 15.0 (#3403), quota-holds WebKit (#3777, new);
  routing-scroll-end 440x620 "stage's columns 3 !== 2" under load, 22/22
  alone on both (#3778, new). The whole GUI suite was not run: other
  sessions' GUI suites held the machine.
- go test -tags nogui ./internal/gui ok before the rebase.

At the pushed head (rebased on ca9b5048e, which touched app.js): the budget
tests ok (app.js 1,314,407 bytes of 1,321,319, not raised), and
view-wheel-after-click, view-wheel-unheard and click-scroll pass 54/54 in
both engines. The 59-file run above was at the base de54b4ff9.

Broken by hand: putting back the old gate (any put-back under a hold
skipped) turns the new test red as above. Removing the new redraw gate
(h = false) is not caught by a test: in both engines a redraw under a
click is held by heldSizes before the guard hears a scroll (logged: no
put-back during a 30-frame shrink at the foot), and the synthetic
redraw fixtures I tried passed with the hold removed too, so none is
shipped.

Not tried: real macOS 13 / WebKit 16.6 and a real trackpad; the unheard
wheel is a capture listener stopping the wheel event.
2026-10-27 00:54:18 +08:00
yetone d3191a51c8 gui: with Hide accounts on, an account's eye shows that one account in this window (yogurt36)
yogurt36 on Discord, for a screen share: with Hide accounts on, one
account should be readable while the others stay masked. Now an
account's name on the provider editor's row (accountNameButton and the
one-account line) and on its Usage card (quotaWho) has a quiet eye, in
sight on hover or keyboard focus, with an aria-label. A click shows
that account, its address and the name the user gave it together
(kin), everywhere the window draws it, tooltips included: the shown
set is skipped in hits(), which every mask goes through. It lives in
memory only. The tray panel keeps hiding it, and closing the window
hides it again: the page stays loaded while the window is hidden, so
hideMain runs mainClosedJS (hideAccounts.closed) first. With Hide
accounts off there is no eye. Strings in zh, zh-TW, ja and de.

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

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

Not run: the whole GUI suite and the full go test ./internal/gui
(another session's suite held the machine and the disk was full; one
link hit ENOSPC and passed on retry). They run after the push.
Not tried: the real Wails window's close (hideMain) by hand.
2026-10-26 18:18:24 +08:00
yetone 6e96903346 codex: auto-review follows the session on a ChatGPT Free plan (cybercaius)
cybercaius on Discord measured codex-auto-review spending a Free
account's allowance ("实测在 free 账号不免费"). magpie left an unset
auto-review to Codex (codex-auto-review), and held such a call by no
usage cap, on #1593's finding that OpenAI counts it in no window; that
was measured on a paid account.

Decision: with nothing picked and Codex signed in to a Free plan (the
ID token's chatgpt_plan_type is "free"), auto-review counts as "Same as
the session", as Codex's other side calls do, so the review stops
spending the free allowance when the session is on one of magpie's
models. On Codex's own model nothing changes (its entries keep OpenAI's
reviewer). A paid plan, or a plan magpie can't read, keeps Codex's pick;
a pick in Settings always wins.

- codexcat.AutoReviewModel is the setting in effect; the plan comes from
  provider.CodexSignInPlan (liveLogin, keychain read cached), read once
  per model list, and the list tag already re-stamps on auth.json.
- freeOnChatGPT no longer exempts a Free plan's codex-auto-review call
  from usage caps (capHeld).
- GUI tooltip says it (en, zh, zh-TW, ja, de); docs updated.

Run at the pushed tree (on origin/main 88ac42843), go test -tags nogui
-count=1 -timeout 45m: internal/gateway ok 447s, internal/codexcat ok,
internal/gui ok, internal/agent/... ok; internal/provider crashes in
TestUnreadLoginsWriteErrorsKeepCredentials ("close of synctest channel
from outside bubble" in filememo.Forget), red the same alone on
origin/main 88ac42843, filed as #3632 with a patch there; with that
test skipped internal/provider ok 152s. gofmt -l clean; GOOS=linux go
vet -tags nogui ./... and GOOS=windows go vet ./... clean.
- GUI (chromium + webkit, every language): codex-auto-review, i18n-keys,
  gui-ja, gui-zh-tw, gui-de, search-keys, agent-prefs: 79 of 79 pass
Broken by hand: with AutoReviewModel returning the raw setting,
TestCodexAutoReviewOnAFreePlan fails; with freeOnChatGPT ignoring the
plan, TestAccountCapHoldsAutoReviewOnAFreePlan fails.
TestCodexSignInPlan reads a Free plan from a sandbox auth.json.
Not tried: a real Free ChatGPT account; whether OpenAI bills
codex-auto-review on Plus/Pro is still #1593's measurement.
2026-10-26 17:19:00 +08:00
yetone a1174674da codex: subagents and memories follow the session's magpie model; auto-review can too (cybercaius on Discord)
Codex's side calls ask for one of Codex's own models by its bare name
whatever the conversation is on: a subagent goes on the model the lead
names in spawn_agent, memories on gpt-5.6-luna/terra, auto-review on
codex-auto-review. With Codex signed in to ChatGPT and the conversation
routed onto one of magpie's models, each of those went to the ChatGPT
account instead (cybercaius: "can't pick follow the main model").

- gateway (codexFollowTo, codexLeads): a collab_spawn or memory call
  that asks for a bare model, with nothing set for it (no magpie
  subagent model, no [agents] default_subagent_model, no [memories]
  extract/consolidation_model in Codex's config), goes on the model its
  conversation's own turns go on (parent thread, own thread, else the
  key's last turn), when that is a magpie model the key may use. A task
  the ChatGPT backend sealed stays on ChatGPT. The trace shows a
  subagent's pick as {asked -> to}.
- agent.CodexSideSet reads Codex's config.toml for those keys; an
  unreadable config counts as set (leave as sent).
- Auto-review gets "Same as the session" (settings value "session"):
  codexcat writes each magpie entry's own id as its
  auto_review_model_override. Not the default: codex-auto-review runs
  free on a ChatGPT sign-in (#1593).
- GUI: the option in all languages; Memories' default text says it
  follows the session. app.js stays under its budget by folding five
  identical writingPrefs then/catch chains into prefWrite.

Ran (sandbox HOME, -tags nogui -count=1 -timeout 45m):
- go test ./internal/gateway ./internal/agent ./internal/codexcat
  ./internal/settings ./internal/cli ./internal/gui: ok.
  ./internal/provider: FAIL with "close of synctest channel from outside
  bubble" in filememo.Forget (TestUnreadLoginsWriteErrorsKeepCredentials),
  which is #3632 on main; this change touches nothing there.
- TestCodexSubagentFollowsTheSession and TestCodexMemoriesFollowTheSession
  go red with codexFollowTo returning "" (broken by hand).
  TestCodexSideCallsKeepTheConfigsModel, TestCodexSideCallsStayOnChatGPT,
  TestCodexSideSet, TestCodexAutoReviewFollowsTheSession pass.
- GUI (playwright 1.62.0, chromium + webkit): codex-auto-review (en, zh,
  zh-TW, ja, de), codex-memories, codex-memories-settings, codex-titles,
  codex-predictions, codex-descriptions, settings-general, agent-prefs,
  i18n-keys: 120/120 pass. TestCoreScriptBudget passes, budget unchanged.
- gofmt -l clean; go vet -tags nogui for linux, windows and darwin ok.

Again after rebasing on origin/main 49f15d124 (25341b4ca on top touches
only internal/redact; rebuilt): nogui builds (darwin, linux,
windows), TestCoreScriptBudget, the tests above, and the GUI files 120/120.

Not tried: a real Codex with a real ChatGPT account and a relay model.
2026-10-26 15:35:12 +08:00
yetone 30d3001a04 gui: a wheel or coast macOS 13's WebKit never tells the page of still scrolls the view (issenn on Discord)
issenn, on macOS 13.7.8 (system WebKit 18615, Safari 16.6's): no page of
the window scrolls by trackpad or mouse wheel, the bar doesn't move, a
forced trackpad scroll shakes and snaps back, and only dragging the bar
works.

Cause (hedged, not seen on a real WebKit 16.6): the view guard puts back
every .view scroll outside a window the reader's own events open (wheel,
touch, keys, scrollOnPurpose). The bar's drag goes past it (barDrag),
which is why that alone works. WebKit 16.x can scroll a view under a
wheel or a coast it never dispatches to the page (WebKit bug 256582,
Safari 16.4.1: monitorEvents(window) showed no wheel over some
elements). With no wheel heard, no window opens, and every reader scroll
is taken as code's and put back. That is the shake, and the v0.1.1488
coast chain couldn't help, since it starts from a heard wheel.

Fix, in puttingBack: three put-backs on one view in one direction within
a second, with no click holding (held), are the reader's. They are given
back, and the fling window opens. Each later put-back the same way
within a second of the last is given back at once. So a wheel turned
slowly, or one run broken on a loaded Mac, loses no step. A scroll by
code happens once and makes no run: two at rest are still put back, and
scrolls a click holds against still are. On a WebKit that does dispatch
the wheel, nothing changes: the wheel opens the window first and
nothing is put back. To stay under appScriptBudget with no raise, the
guard header's click bullet was shortened, and its detail moved to
gui-shell.md.

Test: view-wheel-unheard.test.cjs (Chromium and WebKit, en and zh). A
capture listener stops every wheel before app.js hears it. Then:
- ten fast 20px wheels must move the view 190px or more;
- five notches 400ms apart must land, down and back up;
- six wheels up must bring it back;
- two code scrolls at rest are still put back;
- after a click on an agent row, a code scroll each frame leaves the
  row in place.

Run:
- At origin/main d2e0ea393: red 6/6 ("left at 0" before the slow case
  was added, "five slow notches" after).
- With the first version of this fix (a 150ms chain): red 6/6 on the
  slow notches. On a loaded box its fast case also lost a run (left at
  160).
- Broken by hand. With the held gate removed: red 6/6 ("the row clicked
  stays: at 311.5 ..., 191.5 once at rest"). With the continuation
  removed: red ("five slow notches").
- With the fix: green 6/6.
- go test -tags nogui -run Budget ./internal/gui: ok at the rebased head
  (app.js 1,323,345 of 1,323,401).
- GUI, the 27 files a view's scroll reaches (scroll, view-*, click-*,
  old-webkit, update-auto, routing-days-fit, routing-failed-open,
  text-size, sidebar, last-page), both engines, every language, under
  the suite lock: 306 pass, 15 fail. Every red fails the same way at
  origin/main 0cba7fa68, run in a base worktree:
  - sidebar.test, the masking tab (#3498);
  - menu-input-scroll, chromium (#3402);
  - old-webkit's :has() in app.css (#3403).
  An earlier run also had sidebar-overlay-scrollbar webkit (#1863) and
  menu-input-scroll webkit red under load, on base too. Both passed on
  this run.

Not tried: a real macOS 13 / WebKit 16.6 (none runs on this macOS 26.2),
a real trackpad, the whole GUI suite. A click followed within 4s by a
wheel the page never hears still holds the click's row, since a
put-back while held is never given back.
2026-10-25 19:08:53 +08:00
yetone 1b039a3c72 gui: a trackpad's coast after the lift is the reader's scroll, no longer put back (issenn on Discord)
issenn (v0.1.1472, macOS app): a page with a scrollbar wouldn't scroll by
trackpad. It shook fast and snapped back, and only dragging the bar
worked. Seen on Agents.

Cause: the scroll guard puts back any .view scroll that comes outside
a window the reader's own events open. A wheel opened 250ms. When the
fingers lift, WebKit on the Mac plays the coast itself, and the page
hears those scrolls with no wheel for each. Once the last wheel's 250ms
ran out, the guard put back every coast scroll. Each coast step moved
the page and each put-back moved it back, so it shook and came to rest
where the fingers lifted.

Fix: the wheel now starts the same chain a touch fling does (flings,
flingUntil). Each view scroll keeps the next one the reader's until the
coast rests, and a click still ends it (purposeUntil = flingUntil = 0).
A code scroll at rest is still put back. The code and the comment fit
the old app.js size; no budget raised.

Test: view-trackpad-coast.test.cjs, chromium and webkit, en and zh. It
does five trusted wheels, then a 1s coast the page plays each frame
with no wheel. The coast must reach its end, a code scroll at rest is
put back, and a click mid-coast stops the row under the pointer.
- On origin/main's app.js: red 6/6 ("lifted at 40, coast asked 166,
  left at 101/105").
- Broken by hand, flingUntil not reset by a click: red 6/6 ("the row
  was at 269 after the click, 140 once at rest").
- With the fix: 6/6.

Real WKWebView probe (a Swift app loading the GUI with synthetic
NSEvent scroll phases): with every momentum wheel delivered, old and new
both end at 277. With the wheels after the first 32 kept from the page,
standing in for the coast with no wheel, old ends at 249 and new at
277.

Run:
- click-scroll, view-scrollbar-drag, view-middle-autoscroll and
  view-trackpad-coast: 44/44.
- Whole GUI suite (internal/gui/tests/*.test.cjs, chromium and webkit,
  every language) through suite-lock: still running at push, no red in
  its first 30 minutes; a red it finds gets a follow-up commit and an issue.
- go test -tags nogui -run Budget ./internal/gui: ok, run again after
  the rebase.
- No Go changed, so no gofmt or vet.

Not tried: a real trackpad on the mac app. Synthetic NSEvents skip
WebKit's MomentumEventDispatcher, which swallows the system's momentum
and plays its own. That the page gets its coast with no wheel is the
best fit for the report, not something seen on issenn's hardware. Also
not tried: ProMotion 120Hz, and WebKitGTK and WebView2 with a real
touchpad.
2026-10-25 13:32:47 +08:00
yetone 75e78a5a04 tui: quitting hands the gateway to magpie's service on Linux
zaidu259434 on X: "启动codex这些cli连接会失败,AI分析没自动启动magpie的网关".
With magpie installed inside WSL (or on a server over SSH), nothing
opens magpie at login, and XDG autostart doesn't run there. So once
`magpie tui` quit, the agents it had connected asked a gateway that was
gone.

When the terminal quits having served the gateway with an agent
connected, on Linux and where magpie doesn't open at login, keepGateway:
- starts magpie's service (magpie daemon) when it is installed;
- installs it when the user never removed it (daemon.Removed: Uninstall
  now leaves a daemon-removed mark, and Install clears it), so it starts
  with the system or the login from then on, and says how to remove it;
- otherwise (no systemd, which is WSL's default, or the user removed it)
  starts `magpie serve` in its own session, logging to magpie's cache,
  and says so. In WSL it also says how to turn systemd on.
macOS, Windows, nothing connected, or magpie opening at login: the same
"gateway stopped" note as before. Docs: gui-shell.

Run:
- TestKeepGatewayAsTheTerminalQuits covers each of those cases, and
  TestUninstallRecordsTheUsersNo checks the mark.
- go test -timeout 45m on the four packages, the same run as the
  previous commit's: all four ok (gateway 428s, agent 255s, tui 23s, daemon 16s), at 6874095b1 plus this change, before the rebase
- GOOS=linux and GOOS=windows go vet, and gofmt -l, are clean.
- Real run in the magpie-desktop distro (WSL2, systemd on): a Linux build
  from this tree started under setsid as serveInBackground does,
  answered 200, and still answered 200 with its pid alive 30s after its
  wsl.exe session ended. It was stopped afterwards.

Not tried:
- the interactive TUI quit itself in WSL (over ssh there is no terminal
  to drive it), so the message and the path it picks are covered by the
  unit test only;
- a real daemon.Install inside WSL (it writes a systemd user unit for the
  distro's user).
2026-10-25 12:42:20 +08:00
yetone 208bd5c48b gui: Settings descriptions wrap instead of ending in … (arculongus on Discord)
arculongus (English UI, screenshot) couldn't read many Settings rows: the
line under a setting's name ended in "…". The generic `.row .sub` rule holds
a row's line to one line with an ellipsis; a few Settings rows opted out
(`.wraps`) and the rest were cut, among them Image generation's ChatGPT
note, Image recognition MCP server and Web search's Searches for other
models.

Fixed for the class, not the rows in the screenshot: every setting row's
line (`.row.pref .sub`) now wraps whole beside its control. That covers
every Settings part, Plugins › Built-in and an agent's own settings (the
same rows). The control keeps its size (`.prefs .val` is `flex: none`,
max 60%), and nothing else in the layout moves. The window is never
narrower than 560pt, so a row stays a few lines at most. Lines elsewhere (provider
and account cards, chips, URLs) stay one line; their full text is already
reachable through the hover title.

Tests:
- New settings-lines-wrap.test.cjs checks every visible Settings part plus
  Plugins › Built-in, in chromium and webkit, en/zh/zh-TW/ja/de, at
  1000px and 440px. No row's line is cut or nowrap, each control stays
  inside its row, and the page never scrolls sideways (more than 30 rows
  checked). It also checks the three reported rows by name.
- Tests that assumed one-line rows now follow the taller rows:
  - searcher-pick: the help wraps rather than ellipsizing with a title.
  - settings-general: one line only at 1000px, never cut at either width.
  - reader.cjs reach(): goes up to 8,000px, not 2,400.
  - member-model-setting, turn-done, connect-address-kept, tray-cost and
    tray-totals: wheel to the control with reach() before
    clicking, not scrollIntoViewIfNeeded or Playwright's own scroll, which
    the app undoes.
  - update-download, update-restart and tray-totals: a click whose row
    grows a line may scroll, but only to keep the clicked control under
    the pointer (the app's hold, #2134). tray-totals allows 2px, because
    WebKit's whole-pixel scrolls drifted 1.3px over four holds.
  - mobile-web: compares against an origin/main baseline without this
    change.
- Docs: gui-shell.md and gateway-routing.md.

Run (worktree from origin/main a6399dd49, then rebased):
- The new test passes 20/20. Broken by hand: pointed at the old assets
  (MAGPIE_WRAP_ASSETS), it is red 10/10 in chromium and red in webkit
  ("general: a row's line is cut short").
- Whole GUI suite (872 files) in two runs, at concurrency 3-4 and load
  20-150:
  - The 170 Settings-reaching files first: 2515/2575.
  - Then the other 702: 9767/9920.
  - Each red was rerun on settings-wrap-base. The files this change made
    red (settings-general, turn-done, update-download, update-restart,
    member-model-setting, codex-auto-reset-settings, mobile-web,
    connect-address-kept, quota-reads, tray-cost, tray-totals) are fixed
    above and pass on rerun: 86/86, 34/34, 112/112 and 50/50.
  - Also red on origin/main, already filed:
    - redact-words-any-case: #3500
    - s3-sync webkit: #2448
    - usage-checkin Qoder tab: #2549
    - plugin-card-update: #3079
    - builtins and gateway-mode masking tab: #3498
    - fonts webkit: #3227
  - The other files red on origin/main 31bff66be, run alone at a
    comparable count, all have issues: routing-pause #3410,
    routing-rule-effort #3411, routing-rule-remove #3094/#3096,
    routing-intent-entry #3408, routing-live-patch #2174, routing-manual
    #3409, routing-steady #3412, menu-input-scroll #3402, header-centre
    #3479, gateway-caller-keys #2572, gateway-key-models #2648,
    gateway-key-limit #3523, quota-count-wrap #3404, usage-agents-hide
    #3414, usage-fold #3415, usage-ledger #3001/#3104, sidebar and
    gateway-mode #3498, account-discovery #3497, sidebar-overlay-scrollbar
    #1863, account-alias #2984.
  - provider-user-agent failed only on browserType.launch timeouts (load)
    and passed on rerun.
- After the rebase onto b027ca264, these were run again at the pushed head: the
  14 changed or affected GUI files (the new test, the eleven above,
  quota-reads, which main already wheels, and i18n-keys) passed 302/302.
  go test -tags nogui ./internal/gui (budgets included) was ok, with no
  budget raised.
- Before and after screenshots, Settings › Models at 1000px and 700px,
  chromium and webkit, were looked at: the rows that ended in an ellipsis
  now read whole, and each control has the size and place it had before.

Not tried: the real app (WKWebView, WebKitGTK, WebView2). This is a CSS
white-space change with no motion and no new API.
2026-10-25 09:21:42 +08:00