Commit Graph
8099 Commits
Author SHA1 Message Date
Edward4226 873a5caa2f daemon: the macOS gateway runs as Standard, not Background (#2961)
Generate ProcessType Standard for the gateway launch agent so launchd does not apply Background throttling on an interactive request path. KeepAlive, throttling interval, logs, environment, and lifecycle behavior are unchanged. Verified with gofmt, git diff --check, TestLaunchdPlistProcessType, and TestLaunchdInstall. Not tried: a real macOS launchd reload, plutil on macOS, and a current-main performance A/B.
2026-11-13 21:31:01 +08:00
yetone bda69db0ee awake: the gateway's process keeps macOS from App Napping it (#6261)
ChasLui (#6261, and on X): with the screen locked, every request after a
quiet while got the 30s pre-routing 504 from the menu-bar app (160 in one
night). The app serves the gateway in its own process, and a locked
screen leaves it a background app, which macOS App Naps: priority band 4,
timers throttled, so parsing the 6MB catalog took ~800ms instead of 50ms
and requests queued behind it past unroutedUnknown. Keep-awake
(caffeinate) holds sleep off, not App Nap.

ListenAndServe now holds an NSProcessInfo activity for as long as it
serves (awake.NoNap): NSActivityUserInitiatedAllowingIdleSystemSleep,
Apple's App Nap opt-out without the idle-sleep hold. Held for the whole
life of the gateway, not only while a request is in flight: the request
that suffered is the first one after an idle stretch, which arrives at
an already napped process. NSActivityLatencyCritical is left out: it is
timer precision for audio/video, at an energy cost, and App Nap's
throttling is what the reporter measured. Sleep is still Keep's alone,
only while the user turned keep-awake on.

The command-line magpie is built without cgo and runs from a terminal or
launchd, where App Nap doesn't reach it; there NoNap does nothing.

Run:
- Real App Nap on mote (macOS 27.2): two copies of a throwaway AppKit
  .app (regular policy, launched hidden with open -j -g), one holding
  NoNap. Without it: runningboardd "Set AppNap state: active:Y
  priority:Y timer:Tier5" and ps pri=4 (42 of 42 samples once napped).
  With it: "active:N socket:N priority:N timer:Tier0" and pri=20, never
  4. pmset -g assertions listed nothing for either pid.
- TestNoNapLetsTheMacSleep (darwin+cgo): holds NoNap, reads pmset -g
  assertions, fails on a Prevent* assertion of its own pid. Broken by
  hand with NSActivityUserInitiated: red ("PreventUserIdleSystemSleep
  named: magpie serves the gateway ..."); green with the shipped option.
- go vet (darwin), GOOS=linux and GOOS=windows go vet -tags nogui of
  awake, daemon, cli, gateway; CGO_ENABLED=0 nogui build; gofmt -l.
- go test -count=1 -timeout 45m . ./internal/{awake,daemon,cli,gateway,
  proc,update,masking,plugin} on mote: all ok (gateway 908s, plugin 159s, cli 52s) at base 7eecbcc56; at the pushed head (rebased on 459d668b3, which touches none of these files) build, gofmt, linux and windows vet, and awake, daemon, cli tests ok again

Not tried: the real magpie.app with a real screen lock. mote and mica
were running other sessions' AppKit and simulator tests, which a lock
would break; the hidden-app case above is the same App Nap path
(runningboardd's AppNap state), reached without the lock. The full
suite: both machines' suite.lock queues were hours deep.
2026-11-13 21:31:01 +08:00
yetone 459d668b35 sync: pick what syncs, preview a sync, undo the last one (#6428)
jinpwng (#6428, on X) syncs two computers and wants only Library and
memory to go between them: each keeps its own providers, settings and
models. They also want to see what a sync would change before it
applies, and to roll the last one back.

What syncs: providers, settings and profiles now have switches like
agents' models, library and memory (Config.Providers/Settings/Profiles,
*bool, nil = synced as before, so an existing setup syncs exactly what
it did). The sync form shows Providers (and its API keys), Settings and
Agents' models up front; Profiles, usage and sign-ins sit under
Advanced, closed unless one is set away from its default. The form
sends a part's choice only when it is or was off. A part left out
stays as it is here and on the server; turning it back on joins it
like a first sync (st.Off, rejoin). The sync's line says which parts
each computer keeps ("Stays as it is on each computer: ..."). The
setup text and the CLI carry it: magpie <webdav|s3|github> set
providers=no settings=no profiles=no.

Preview: davsync.Preview (plan.go) says, per part, what syncing now
would bring in, send up, or leave; library items and memory files by
name, sign-ins and plugins gone. Preview... in Settings > Sync shows it,
and Sync now from there runs SyncPreviewed(token): if the server or
this computer changed since, it says so and shows the new plan instead
of syncing something else. CLI: magpie <kind> preview.

Undo: a sync that brings parts in records them (st.Applied) and keeps
a sealed copy of this computer first (keepSealed, as Restore does).
Undo the last sync puts those parts back from that copy, on this
computer only (st.Local, so the next sync sends it up rather than
fetching the server's again). If one of them changed here since, it
asks first (409 changed, Undo anyway). CLI: magpie <kind> undo-sync
[anyway]. Restore's own Undo is unchanged.

docs/subsystems/sync-backup.md and the site's sync docs (en, zh, ja)
have a section on it. i18n: zh, zh-TW, ja, de.

Run (worktree at base 48e394146):
- go test -count=1 . ./internal/davsync ./internal/cli: ok (mote).
  Broken by hand, each went red: syncs() forced true (scope tests),
  rejoin's again forced false, UndoSync without the st.Local update.
- go test -count=1 ./internal/gui: TestCoreScriptBudget was over by
  85 bytes; the sync-left line moved into syncfiles.js, now ok.
- go vet ./internal/gui, GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok. gofmt -l: nothing.
- node --check app.js, syncfiles.js, sync-scope.test.cjs: ok.
- GUI (mica), every test file that opens Settings > Sync or calls
  davsync (22 files) plus i18n-keys, Chromium and WebKit, 1100 and
  420px, en/zh/zh-TW/ja/de: 453 of 454 pass. The red is s3-sync webkit
  en "picking S3 must not scroll the page" (0 !== 98), the same on
  origin/main 52c9880cb (#3413, #2448). An earlier run also had
  library-new-skill chromium en 420 red, the same on main (#6539).
  sync-scope.test.cjs is new: on the old code there is no Providers
  switch, Preview or Undo, so it fails at once.
- Rebased on origin/main 7eecbcc56 (app.js and i18n.js changed there):
  TestCoreScriptBudget, go test . ./internal/davsync, node --check, and
  i18n-keys, sync-scope, webdav-settings-refresh (both engines): ok.
- The full go test ./... was started through mote's suite lock when
  this was pushed; its result goes on #6428.

Not tried: a real WebDAV, S3 or GitHub server (the tests use fakes);
the real app on Linux WebKitGTK. "Save and sync" from the form, after a
preview, syncs without the preview's token check.
2026-11-13 21:09:44 +08:00
yetone 7eecbcc56b routing: a wider window never shows a request on more lines, nor cut off
normalcoder_ on X (v0.1.4053): on the Routing page a request still
answering had its numbers (60 B, ≈ tokens, ago) drawn past the list's
edge, cut off, and widening the window moved Accounts and keys beside the
requests, where each request took two lines it had on one in a narrower
window.

- The hidden probes that size the list's columns now carry a request in
  flight's numbers, measured as "59 min ago" (the widest it says in the
  hour): measured without them, their column had no room; measured as
  "3 s ago", they wrapped once it said "13 s ago" and stayed two lines.
- The accounts go beside only where the page is 1150px or wider and the
  requests, tried beside before the frame is drawn, still keep their
  numbers on one line (sideFit). By width alone, a page kept to 1200px
  left the requests ~850px.

Metrics are never hidden by width: they wrap or go under the model, so
the same ones show at every width; the Metrics menu still picks them.

New routing-rows-widths.test.cjs: a request in flight alone, and with six
finished, on the desktop and the browser page, by request and by session,
from 2000px down to 520px and back: no cell past the list, the same
metrics narrowed and widened, none gone and no row taller on a wider
page. Chromium and WebKit, en and zh.

Broken by hand: byWidth's min1150 put back, red at a page of 1096 -> 1156px
(31 -> 50px); the probe's live numbers measured as they are, red at 768 ->
796px (31 -> 50px). On the original code the live row's numbers were past
the list's edge.
2026-11-13 20:45:46 +08:00
yetone 52c9880cbb providers: a setup pasted into Providers' own search opens the provider too (WJaunita45604 on X)
a44da380b (v0.1.4044) read a pasted vendor setup only in the Add sheet's
search box. With providers already there, the box in sight is the
Providers page's own "Find a provider" (#pvQ), and a paste there only
filtered the list: a real Cmd+V of export ANTHROPIC_BASE_URL / _AUTH_TOKEN
left the text in the box with "No provider matches", in Chromium and
WebKit alike. The reader also took the tweet's own shape wrong:
`export XXX_BASE_URL="…" export XXXAUTH_TOKEN="…"` on one line gave an
OpenAI URL with the second export in it and no key.

- pastedProvider (pasteread.js) opens the custom provider from either
  search box, for env lines, JSON, "address + key" lines and now a curl
  command too, and says what it filled. A setup with no web address (the
  tweet's example-xx) opens with its key and asks for the base URL,
  rather than doing nothing. "token plan" and other words after KEY or
  TOKEN open nothing.
- Both boxes also read a paste from its input event (insertFromPaste,
  insertFromDrop), for a paste whose event has no text or that came
  before pasteread.js loaded; the one-line box runs the lines together,
  so the reader takes several NAME=value on one line, glued or not.
- envOf reads what pages and Windows do to the text: zero-width
  characters, no-break and ideographic spaces, full-width = and :, curly
  quotes, cmd's set "NAME=value", CR-only lines, and a piece of
  settings.json ("env": {…}, or its lines, a trailing comma included).
- The site's icon arriving no longer wipes the note of what was filled.
- New string in zh, zh-TW, ja, de: "The pasted text gives no web
  address: type the base URL."

Run (mote, base origin/main 48e394146, rebased on 9e3b269c5, which
touches none of these files):
- provider-env-paste, Chromium and WebKit, en/zh at 900 and 440px:
  34 of 34. Red on the old app.js/pasteread.js/i18n.js with the new
  test: 18 of 34 (envOf's oneLine case, Providers' search, the input-event
  paste).
- A real keyboard paste (text copied from a textarea with Cmd+C, then
  Cmd+V into the box, CRLF lines), a scratch script not committed: on
  the old code #pvQ keeps the text, no editor, both engines; on the new,
  both boxes open the editor with the URL and key, both engines.
- add-sheet*, custom-*, i18n-keys, i18n-en-no-cjk, provider*, providers*
  (76 files, both engines): 1838 of 1890. The 52 reds are in
  provider-fetch-again, provider-many-keys, provider-max-output,
  provider-models-rest, provider-picks-stay and provider-typed, and the
  same 52 fail in a clean origin/main 9e3b269c5 copy: #6532, #6209.
- At the pushed head (rebased on 9e3b269c5): provider-env-paste,
  provider-curl-paste, i18n-keys, i18n-en-no-cjk: 52 of 52.
- go test -tags nogui ./internal/gui (mica): ok, TestCoreScriptBudget
  included (app.js is smaller; the opening moved to pasteread.js).

Not tried: the packaged app itself (the release build serves
pasteread.js from assets.zip as before), WebKitGTK, Windows WebView2's
context-menu paste.
2026-11-13 20:28:54 +08:00
yetone ea03a56518 update: a restart goes into the version its own check just downloaded
elis_pina on X (Windows): a click on the header's Update downloaded to
100%, then downloaded again, over and over; Settings > About did update.

The pill restarts by itself once the download a click started is in
(pulling in app.js). That restart asks the feed first (recheck, coeo91's
"take the newest"), and magpie releases every 5 to 10 minutes, so with a
download slower than that (80 MB on Windows, from China) a newer version
was out each time: it was downloaded in place of the one just in, and the
restart after it asked again. Settings' button only restarts on a click,
so its loop stopped whenever the user clicked before the next release.

b05a525a3 (v0.1.4051) already ends this with downloads automatic: a ready
download is restarted into without asking. With Settings' "Download
updates automatically" off the loop was still there. Now a version a
restart's own check downloaded (forRestart, restartStaged) is restarted
into without asking the feed again for freshAfter (5 min): at most one
newer download per click, and coeo91's case, a restart long after the
download, still asks for the newest.

Test: TestRestartAfterItsDownloadDoesNotAskAgain downloads 0.1.11 on a
click, publishes 0.1.12, restarts (0.1.12 downloaded), then publishes
0.1.13 to 0.1.15 before each of three more restarts: each goes into
0.1.12 with the feed not asked; with restartStaged freshAfter old the
restart takes 0.1.15.

Run:
- Old update.go: the test is red (restart 2, 0.1.13 out, went to 0.1.13
  with 3 downloads).
- mote-run go test -count=1 -run
  'Update|Restart|Tray|Available|Freshen|Wait|Auto' ./internal/gui/: ok.
- win-run go test -count=1 -run
  'TestRestart|TestTrayRestart|TestUpdate|TestAvailable' ./internal/gui/:
  all ok but TestUpdateThatWontStart ("relaunched 0 times"), red the same
  on base 48e394146, filed as #6059.
- mica-run go test -count=1 -timeout 45m ./...: exit 0, 99 packages ok
  (internal/gui 168.5s), at this change before a comment-only rewording
  of recheck's doc comment.
- go vet ./internal/gui/, GOOS=linux -tags nogui, GOOS=windows: ok.
  gofmt -l: clean. No GUI file changed.
- Rebased on origin/main 9e3b269c5 (3 commits, none in internal/gui or
  internal/update): mica-run go test -count=1 ./internal/gui/ ok (195.9s).

Not tried: a real packaged Windows restart across live releases; the
reporter's version is unknown.
2026-11-13 20:27:53 +08:00
yetone 9e3b269c51 lessons: the eager-regexp guard red a third time on 11-13 (d21cb563e)
d21cb563e ran its packages and not the root guard; 48e394146 fixed it.
The rule is in LESSONS six times, so it needs a check, not a line.

Docs only; nothing run.
2026-11-13 20:12:44 +08:00
yetone 49ebd63578 codex: the app's app-server is not ended under a turn still running
Norethcy on X (v0.1.4045): the Codex app (ChatGPT.app) went through a
routing group. The ChatGPT account ran out mid-conversation, and the
group's fallback answered. While that reply went on, magpie restarted
the app's app-server and cut the turn off.

magpie ends the app's app-server (codexAppStep, every 3s) once Codex's
route has changed. That happens here: the account is spent, so magpie
becomes Codex's provider. The end waits for the gateway to be idle for
10s, and for no turn open in a session file. The causes:

- sessionTurnOpen read only the last 512 KB of a rollout. A turn that
  wrote more than that counted as no turn at all: a tool's long output,
  images, an hour of work (one of the owner's own turns is 22 MB). A tool
  running 10s between two requests was then taken for the turn's end.
  The file is now read back in 512 KB chunks to the last task_started,
  task_complete or turn_aborted. Each chunk overlaps the next by a
  mark's length, so a mark across two reads is found whole.
- With the account spent, a turn open past 2m with quiet sessions
  counted as stuck on the spent account and was ended. A turn that went
  on through magpie after the route changed is served, not stuck. It is
  no longer ended for that (goneOn).
- busy was read before CodexBeforeAppEnd moved the open chats. A request
  that began meanwhile was ended under. It is read again just before the
  end.
- When the listing showed no new app-server after the end, the app was
  quit and reopened (Windows) even while it sent through magpie. Now it
  isn't reopened while a request is in flight or one began since the end.
- A magpie that took the gateway over (an update) saw none of the old
  magpie's streams, so its first look could end the app-server under one.
  Its start now counts as a Codex request just ended.

The crash relaunch (codexAppCrashStep) and RestartCodexAppWhenIdle use
the same turn check, so they wait for a long turn too. The buttons the
user presses restart at once, as before.

Tests (internal/provider/codex_app_inflight_test.go). All 6 fail with
the old codex_app_server.go swapped in, and pass now:
- TestCodexTurnOpenPastTheTail: turns of 512 KB+1, 1.5 MB and 22 MB,
  open and ended, with the app-server's start before and after the turn.
- TestCodexTurnOpenMarkAcrossReads: each mark straddling the read
  boundary at every byte.
- TestCodexAppServerWaitsForATurnTheFallbackServes: the reporter's case
  with the real session-file check. The route goes out while the
  fallback streams; a 600 KB turn has a 15s tool gap, then a tool running
  past 2m. The app-server is ended only once the turn ends.
- TestCodexAppServerEndLooksAtRequestsAgain,
  TestCodexAppNotReopenedWhileItSends, TestCodexAppStartCountsAsARequest.
Broken by hand: with goneOn forced false, the fallback test fails at
"a tool running over 2m0s in a turn the fallback served".

Cost: an open 22 MB turn takes 97 ms and 559 KB per look (benchmark on
mica). A look happens at most every 3s, and only while an app-server is
waiting to be ended, the gateway is idle and such a turn is open. An
ended or short turn is found in the last chunk, as before.

Run on mote:
- Full suite, go test -timeout 45m ./..., at this change on b3395ffda:
  every package ok (internal/gateway 969s, internal/provider 223s)
  except two. TestNoEagerPackageRegexps failed on
  internal/davsync/setuptext.go, which 48e394146 fixed on main.
  TestMainWindowCorners/macOS_15_SDK was killed at its 40s deadline
  at load ~29 (#1936, #2645). Log kept in the scratch folder.
- Rebased onto origin/main 36c5ee1e6 (three commits: davsync, claude,
  gui WebView2), then ran . ./internal/provider ./internal/davsync: ok.
  TestMainWindowCorners alone: ok (17s).
- gofmt -l: clean. GOOS=windows go vet ./...: ok. GOOS=linux go vet
  -tags nogui ./...: ok.

Not tried: the real ChatGPT app in a sandbox HOME, or a real account
running out. Real rollout files were checked for the marks
(task_started, task_complete, turn_aborted) and for turn sizes of 14 to
22 MB.
2026-11-13 20:12:28 +08:00
yetone 36c5ee1e6c claude: a run that ends during a turn keeps its session for the answer, retry or summary after (#6528)
When the Claude Code bridge ended a run in a turn the client still goes
on with (runTimeout on an AskUserQuestion, or letGo when the client went
away mid-reply), removeRun deleted its session file. The late answer,
the tunnel-drop retry and the delayed AgentSummary then found no run and
were told whole to a new Claude Code (recih: 118K and 305K written to
the cache again).

removeRun now keeps such a run (keepEnded, claude_ended.go) in the same
b.mu section that takes it out of runs, so no request in between finds
neither. The bounds: at most endedMost (16), each for endedLongest
(idleLongest, the cache hour), the oldest let go first, with its files
removed. Not kept: shelved, rewound, client cache marks, a handed-over
account, or anything at gateway stop (abortAll drops them all, and
sweepSessions takes what a crash leaves). branch and retryBranch look at
kept runs after live ones, latest first. Each branch cuts its own copy,
so the kept file is never written and the AgentSummary that comes after
a recovery still branches.

Real Claude Code 2.1.316 (mock Anthropic plus an MCP tool that never
answers, both -p and interactive): the text and tool_use lines are in
the jsonl ~30-60ms after the reply streams, and on SIGTERM only
cost-state lines are added, with no result and no interrupt marker. So
a cut after the call line is sound.

Run:
- New tests: TestClaudeAnswerAfterTheRunEndedBranchesOffItsKeptSession,
  TestClaudeEndedRunsSessionsAreBounded (time, count, stop, unkept),
  TestClaudeTurnSentAgainAfterItsRunEndedBranchesOffItsSession (real
  letGo through the interactive harness, -count=10).
- Broken by hand on mote: with keepable() returning false, the answer,
  count and retry tests went red; with (gone || !run.closed) put back to
  !run.closed, the answer and retry tests went red.
- gofmt -l clean. go vet -tags nogui ./... with GOOS=linux, GOOS=windows
  and darwin on mote: ok.
- Full suite, go test -tags nogui ./... -timeout 45m on mica at
  07ed85f97 (origin/main d21cb563e + this change): every package ok
  except the root package's TestNoEagerPackageRegexps
  (internal/davsync/setuptext.go:73). That red was on main and is
  fixed by 48e394146 (#6534). After rebasing onto it (this head): ., internal/davsync,
  internal/gui and internal/gateway ok.

Not tried: a real AskUserQuestion answer through a live magpie with a
real Claude account; the reporter's case is reproduced in tests with an
injected end (abortFor and a cancelled client).
2026-11-13 20:04:42 +08:00
yetone 48e394146b davsync: the setup text's body regexp is compiled when first used (#6534)
d21cb563e compiled setupBody at launch, so TestNoEagerPackageRegexps was
red on main. It is a lazyre.New now, as every other package-level regexp.

Run (mica): go vet ./internal/davsync; go test -count=1 -run
TestNoEagerPackageRegexps . ok; go test -count=1 ./internal/davsync ok.
2026-11-13 19:45:24 +08:00
yetone f46a37f509 gui: a WebView2 process that fails is logged and the window comes back by itself
aquaarboraurum on X (magpie 0.1.4040, Windows 11, WebView2 138): the
main window went white after a while, leaving the title bar, a strip at
the left edge and the status bar. Closing it to the tray and opening it
again brought it back, and the log said nothing.

Wails registers for WebView2's ProcessFailed but leaves its
ProcessFailedCallback unset, so nothing in magpie heard any WebView2
process end or fail. Now each window's failures are handled, once its
first page has come (webviewmend*.go):

- each one is logged: "webview (main window): GPU process exited;
  drawing it again", and so on for every COREWEBVIEW2_PROCESS_FAILED_KIND;
- GPU, unknown or a new kind: the controller is hidden and shown again
  (put_IsVisible), what the tray close and open did, without the window
  going;
- a render process that exits or hangs, or a frame's: the page is
  reloaded (ICoreWebView2::Reload);
- the browser process: the window is let go as lightweight mode does and
  the main window made again, once the old browser has let go of the
  profile folder (made at once, Wails ended magpie on a controller
  timeout);
- utility, sandbox helper and plugin processes: logged only;
- a reload or remake again within 30s is logged and left alone, so a
  failing renderer doesn't loop;
- after the computer wakes (SystemDidWake), each open window is drawn
  again the same way, since a GPU that lost its device while asleep is
  the likeliest way to a white surface with the window's frame left.

The cause of the report is not proven. Ending the GPU process on the
Windows box doesn't leave the old code white (WebView2 makes a new one
and the page keeps drawing), and a dead renderer doesn't match a window
that the tray brings back. The log line is what the next report needs.

Run:
- TestWebViewComesBackFromEachProcessEnd (new) on xiaomi-gpu, Windows 11
  25H2, WebView2 157, in the signed-in session (schtasks /it; it skips
  over ssh, session 0): it ends the test build's own renderer, GPU
  process and browser process and checks the page comes back drawn
  (screen pixels over the client area, white share 0.00) - renderer,
  gpu-process and browser all PASS (16.4s).
- Broken by hand (mendWebView taken out of makeMain): all three red -
  "the page didn't load", "hidden=false, never visible again", "timed
  out waiting until the window is made again".
- Old code, GPU process ended, white share sampled 10s: 0.00 every second
  (not white: the cause above is not reproduced).
- TestWebViewMendForEachFailure, TestMendGapHoldsOnlyReloadAndRemake.
- mica: go vet ./internal/gui (darwin, GOOS=windows), go vet -tags nogui
  (darwin, linux, windows), go test -count=1 ./internal/gui ok 137s.
- mica, go test -count=1 -timeout 45m ./... at f9ad4122b plus this
  change: 98 packages ok, one red, TestNoEagerPackageRegexps on
  davsync's setuptext.go (#6534, red on main, fixed in the next commit).
- xiaomi-gpu, go test ./internal/gui over ssh: 9 reds, the same 9 at
  origin/main f9ad4122b run the same way (#6068, #6059, #5928): %AppData%
  unset over ssh, file locks, Smart App Control; none touch WebView2.

Not tried: a real GPU device loss after sleep or display off, the
reporter's WebView2 138, the panel's remake (the same code path as
lightweight mode's let-go).
2026-11-13 19:45:24 +08:00
yetone b3395ffdaf usage: a models.dev change no call of the user's names keeps the request index
The request index's meta named the catalog by models.json's bytes
(catalog.CacheKey, v0.1.4037), so every real change models.dev made, most
of them to aggregators' lists (OpenRouter, NanoGPT, Kilo, Vercel) no call
names, dropped every chunk and read every session file again: ~15 s of
CPU on a long history, several times a day.

The meta now names catalogBase: the catalog the rows were made under,
kept while each question the rows asked of the catalog is answered the
same. The questions are Pricer's base price (basePriceIn, taken out of
Pricer whole) and ListedAs's listed name; each is noted with its answer
the first time it is asked (noteAsk). A new catalog file, or a catalog
read again (catalog.Resets: Sync writes the file before it resets), asks
them all again; one answered otherwise names the index anew, as any
change did before. A question answered otherwise than first, or more
than 50k of them, does the same. The asks are kept in
catalog-asks-v1.json, written before any file of rows under the meta
(toDisk, heat, page, effort, digests), so a restart holds the rows on
disk to them too. The price cache key (usagePriceCacheKey) is unchanged.

Run on mica at this tree: go test ./internal/usage ./internal/catalog
./internal/gateway ok (gateway 1038s); go vet, GOOS=linux and
GOOS=windows go vet of usage and catalog clean; gofmt clean. Broken by
hand, each red in TestRequestStateKeptAcrossACatalogChangeNoRowAsks:
answersSame always true, the meta back on catalog.CacheKey, and the
catalog.Resets check dropped (a check between Sync's write and its reset).
catalog_asks.go joins the row code's go:embed, so the index is built
once after this update.
Not tried yet: a real models.dev change on a real account (next, on mote).
2026-11-13 19:42:11 +08:00
yetone e5994a0159 gateway tests: a fake upstream judges only what the gateway sent it (#6535)
TestTencentTokenHubRoutes went red once in a full internal/gateway run
on the Linux box: "asked at /ws/herdr". Another program on the machine,
a herdr client, reached the fake upstream's loopback port, and the test
fails on any path its fake was asked at. TestQianfan's and Bedrock's
"asked at" loops do the same.

All three now judge only requests that carry the test's key
(sentByTest). The gateway sends that key on every call, so a wrong path
it asks at still fails.

Run:
- wsl-run go test ./internal/gateway -count=3 -run
  'TestTencentTokenHubRoutes|Qianfan|Bedrock': ok.
- GOOS=windows go vet ./internal/gateway: ok. gofmt -l: clean.
- Broken by hand: a GET of srv.URL+"/ws/herdr" added before
  TokenHub's check is green with the filter, and red
  ("tokenhub_test.go:155: asked at /ws/herdr") with it taken out.

Not changed: the shared fake that native_compaction_test.go's "asked at"
reads keeps only the last request's path, so a stray request can still
overwrite it. Noted on #6535.
2026-11-13 19:36:33 +08:00
yetone d628a1c803 settings: Automatic updates' hover card says why an update can be trusted
ArcticLampyrid on X asked for Settings to say why automatic updates are
safe. Two lines now join the Automatic updates row's explanation. Like
every Settings line, they show only in the row's hover card (or on focus,
or inline where there is no hover), and a small info mark goes on the
row's name where there is hover. There is no new section or row.
- Every update is signed: its SHA-256 checksums carry an ed25519
  signature, checked against a key built into magpie
  (internal/update/signed.go).
- Its SLSA build attestation, signed through Sigstore, is checked too:
  it shows magpie's release workflow on GitHub built those exact files.
  An update that fails a check is not installed
  (internal/update/attest.go).

The lines are added by updatetrust.js, a module settingshints.js loads
on demand. It watches #about and adds them each time About is drawn.
They live there and not in app.js because the core scripts' budget
(TestCoreScriptBudget) has no room. old-webkit's list of on-demand
scripts names it. Translated in zh, zh-TW, ja and de.

update-auto.test.cjs: at rest the two lines are out of sight; hovering
the name shows the card with the row's line, "ed25519" and "Sigstore";
the mark is there; and the card goes once the pointer leaves. The
existing check of the switch's own line now reads the first line only.

Run (mote-run, at this commit rebased on 414517ccf):
  node --test old-webkit phone-no-sideways settings-hints
    settings-lines-wrap settings-search update-auto (Chromium + WebKit)
  66 pass, 26 fail. The 26 are the same tests, failing the same way, on
  plain 414517ccf: #6467 (appearance.js), #5919 (:has), #5869 (de 375),
  #6107 (settings-hints ja/de 420px), #6353 and #6133 (settings-search
  /api/update/using, settings-lines-wrap de 440px). update-auto passes
  in both engines.
  The first run, at e5b8f381d, covered 38 update-*, settings-*, about-*,
  i18n-keys, i18n-en-no-cjk, remote-update, whats-new and
  uninstall-settings files: 720 of 746 passed, and the 26 reds are the
  ones above.
  go test ./internal/gui/... (TestCoreScriptBudget included): ok.
Broken by hand: without the import in settingshints.js, update-auto
goes red (no .update-trust lines within 5s).
Not tried: the real app window; only the faked API in Playwright.
2026-11-13 19:31:37 +08:00
yetone b05a525a33 update: Restart to update goes into the download waiting when downloads are automatic
canlee886 on X: auto-download had a version ready, but magpie releases
many times a day, so by the time they pressed Restart to update a newer
one was out. The click asked the feed (coeo91's "take the newest") and
downloaded the newer one whole while they waited, which made the
download done ahead of time useless ("这个自动下载在如此频繁的更新之下
简直就是摆设了").

Two ways to fix it: keep the staged copy current (check more often,
download each newer one), or restart into the staged copy and let the
next check fetch anything newer. This takes the second:
- the restart is at once, which is what the download ahead of time is for;
- no more bytes from R2 than before: one download per update. Keeping
  the copy current would download 40 to 95 MB per release, several times
  a day, which iiiiiimone's fix (the clock leaves the one waiting) took
  out;
- the new version's first clock check, 5s after it starts, fetches
  anything newer in the background, and the next restart goes into that.

So with downloads automatic (the default), recheck leaves a ready
download alone and doesn't ask the feed (keepsStaged). That covers the
page's Restart to update, the tray's restart, and Restart when idle.
The notes dialog's freshen (#910) still asks the feed for late notes
(#649), but with `keep` set it leaves the staged copy as the clock's
check does, so the dialog names the version the restart goes into.
With "Download updates automatically" off, nothing changes: a click asks
the feed and downloads the newest (coeo91).

Tests: TestRestartTakesTheDownloadWaiting (new) covers the page's click,
the tray's restartAsked, AutoRestart's waitIdle and a stale freshen. Each
keeps 0.1.11 with one download while the feed has 0.1.12, and a later
check takes 0.1.12. The coeo91 and #910 tests now set NoAutoDownload
(downloadsOnClick), the behaviour they guard.
TestUpdateClockLeavesWaitingDownload and TestUpdateNotesAskTheFeedAgain
expect the staged copy kept under auto-download.

Run (mote-run, at this change rebased on 414517ccf, with the next commit):
  go test -count=1 -timeout 45m ./internal/gui/... .
  internal/gui ok (129s); the root package's TestNoEagerPackageRegexps is
  red the same on plain 414517ccf (internal/davsync/setuptext.go:73,
  filed as #6534), nothing else.
  go vet ./internal/gui/, GOOS=linux go vet -tags nogui ./internal/gui/,
  GOOS=windows go vet ./internal/gui/: ok. gofmt -l clean.
Broken by hand: keepsStaged returning false makes
TestRestartTakesTheDownloadWaiting ("the page's click: Latest 0.1.12")
and TestUpdateClockLeavesWaitingDownload ("2 downloads") red.
Not tried: a real restart of the packaged app across two releases.
2026-11-13 19:31:37 +08:00
yetone f9ad4122bb providers: Compact at's size chips set several models at once (Yanzhongixuy on X)
A Compact at chip (128K, 200K, 272K, 500K, 1M) opens a menu of All
models and each served model, with the ones at that size ticked.
Ticking one gives it that size, unticking takes it back; the menu stays
open, so several models get one size in a few clicks. Context window
and Max output chips keep setting every model at once, as before.

The three fields' chip rows are now one helper, sizePicks, which keeps
app.js and the core script inside their budgets without a raise. Menu
strings (All models, Compact at {n}, Search models) already exist in
every language.

Run at 414517ccf + this change, on mica:
- compact-at, context-picks, provider-output-picks,
  provider-advanced-fold, model-limits, i18n-keys, i18n-en-no-cjk:
  130/130 in Chromium and WebKit; compact-at's new test runs en, zh,
  zh-TW, ja, de at 900 and 400px.
- go test -tags nogui ./internal/gui -run Budget: ok.
- Broken by hand (a chip always sets every model): the 20 new tests
  went red.
- 94 provider/model GUI files at 24cdfb546: 80 reds, identical by name
  with and without this change (#6209, #6196, #6532).

Not tried: the real app; Linux WebKitGTK (no motion added).
2026-11-13 19:25:01 +08:00
yetone 414517ccf5 gateway: a plugin's 4xx turning the agent's prompt away asks the next member (plugins#1094)
The AutoClaw plugin answers 406 when a chat's system prompt carries
another agent's identity line it doesn't rewrite ("AutoClaw refuses
chats whose system prompt carries another agent's identity line …, so
an unknown one needs another provider in this group"). retryable only
read refusedWords at 400 and 422, so holdWriter.failed() was false for
the 406, the try never reached the promptRefused branch, and the group
stopped at AutoClaw while its other members, taking the same prompt,
were never asked.

refusedWords now also matches AutoClaw's own words, and retryable
counts a refusal at any 4xx. Like WorkBuddy's 400, the refusing account
isn't rested and its mates are asked last.

Run:
- wsl-run go test ./internal/gateway -run
  'PromptRefus|Restricted|Refus|TokenWall|Volcengine|Decide|Retryable':
  ok. TestPromptRefusalRestsNobody is now table-driven, with AutoClaw's
  406 body in a "next answers" case and a "nobody left" case.
- Broken by hand: with the new retryable case removed, both AutoClaw
  subtests go red ("tried [acct-1]"); restored, green.
- gofmt -l: clean.

Not tried: a real AutoClaw account. The plugin side, rewriting ZCode's
subagent line, is autoclaw 0.2.23 (plugins f053e327).

Reported-by: aynauynij
2026-11-13 19:16:22 +08:00
yetone 24cdfb5460 lessons: #6482 closed on one green release while the 403 came back
Five tags after the close never published (notarisation 403 and a
notarytool timeout). Recorded under keeping an issue open until the
case works.

Docs only; nothing run.
2026-11-13 19:10:42 +08:00
yetone f5553d7103 sessions: a Pi subagent's calls are its lead session's, on its own model (nzvzbmz78932 on X)
nzvzbmz78932 on X: "在pi子代理中使用了deepseek 但是不显示用量". pi-subagents
(npm 0.88.1) runs each subagent as a Pi of its own, its session in
<lead file's folder>/<run id>/run-<n>/session.jsonl (async and parallel
runs a level deeper), or under extensions/subagent/config.json's
defaultSessionDir, its header's parentSession naming the lead's file.
magpie read only sessions/*/*.jsonl, so those files were never read. The
lead's `subagent` tool result carries the subagents' usage summed, and
piParse counted it on the lead's model and provider: a lead on magpie's
entry made it the gateway's (piGateway), so DeepSeek's calls were on no
page, Usage or Sessions.

- piFilesIn reads every session file under a lead's folder as the
  lead's (non-main, like omp's), and the defaultSessionDir ones through
  their headers' parentSession, up to 8 levels.
- piSubagentsRead: a tool result whose every sessionFile is one of those
  counts nothing, in piParse and piCall; one naming a file not read
  still counts as before.
- The scout's header id is in Session.Subs (pi is idInFile), so a
  subagent on magpie's entry is the lead's row to the gateway too.
- state.codexPath is parsePath, the file read, for piLeadID: a new field
  took state past its 416-byte class (TestStateFitsItsSizeClass).
- parseVersions and callParseVersions pi/raft/cindy raised.

The fixture is a real run: Pi 1.4.0 with pi-subagents 0.88.1 in a
sandbox PI_CODING_AGENT_DIR, a lead and one scout on a relay's
deepseek/deepseek-flash; system prompts dropped, paths rewritten.

Run (mica, at this head):
- go test ./internal/sessions: ok (119s)
- GOOS=linux and GOOS=windows go vet ./internal/sessions: ok; gofmt clean.
- Linux (wsl-run, magpie-desktop): TestPi*, TestOmp*, TestCodex*,
  TestStateFits*: ok
TestPiSubagentCalls: beside the lead and in defaultSessionDir, each with
the lead on the relay and on magpie's entry (the reporter's case).
Broken by hand: without the walk, 3 of 5 calls and 0 of 2 with the lead
on magpie (red); without the tool-result skip, 6 calls, the sum counted
again (red); the Subs check was red while it named the run id.
Not tried: the reporter's own files; a subagent nesting subagents; a
subagent run on magpie's entry against a live gateway.

With f0fb22c6b and 5bc816c1a below it, at this head (mica): go test
./internal/sessions ./internal/agent ./internal/claudecode ok,
./internal/gateway -run TestClaude ok, GOOS=linux and windows go vet of
the four ok, gofmt clean.
2026-11-13 19:07:34 +08:00
yetone 9205ee109c agent: the Claude Code magpie downloaded keeps ~/.claude from reading as "CLI not found"
Wing8Aqua on X runs magpie as a systemd service on Ubuntu, where the
Claude subscription runs the Claude Code magpie downloaded
(claudecode.Install, in its cache folder, off PATH). Magpie's own runs
make ~/.claude, and the Agents page took that folder, with no `claude`
on PATH, for an uninstall's leftover: Claude showed "CLI not found"
while that Claude Code answered every request, and `magpie claude`
starts it. cliHeld now counts claudecode.Downloaded() for Claude Code.

Run: TestCLIMissing* in internal/agent on Linux (wsl-run): ok, with a
case for a download and one for a version folder without its binary.
Broken by hand (the download not counted): case 5 red.
2026-11-13 19:07:34 +08:00
yetone 6fad0d0465 gateway: a run waiting a minute on its subagents gives its Claude Code place to one that needs it
Wing8Aqua on X (0.1.4026, Ubuntu, magpie.service with memory.high 768M):
"4 Claude Code processes are running, as many as may run at once (768 MiB
of memory (cgroup /system.slice/magpie.service/memory.high) holds 4);
none ended within 2m0s". An ask that finds the room full lets go of an
idle run, else of a run parked on tool results, but only one parked
parkLongest (5 minutes), while it waits claudeRoomWait (2 minutes). A
lead conversation waits on its parallel subagents' Task calls for as
long as they work, and every subagent is a conversation needing its own
Claude Code: the lead held a place, doing nothing, while a subagent
waited the 2 minutes and was answered 503.

letGoForRoom now takes a parked run once it has waited roomParkLongest
(1 minute), well inside claudeRoomWait. Its results go to a new run told
the whole conversation, as past parkLongest; a tool answered within the
minute keeps its run, and busy runs are never let go.

Run: TestClaudeRoomLetsALeadWaitingOnSubagentsGo, with the room tests
(TestClaudeRoom*, TestClaudeRunsHeld*, TestClaudeOneOffs*,
TestClaudeParked*, TestClaudeNoRoom*, TestClaudeMem*) on Linux
(wsl-run, magpie-desktop): ok. Broken by hand (parkMost back to
parkLongest): the subagent got the 503 after 30s, red.
Not tried: the reporter's machine; whether their 4 were busy rather than
parked is not known (their `magpie claude-code runs` would say).
2026-11-13 19:07:33 +08:00
yetone 6fc8fdae41 cli: the Usage page's switched-off check-ins route is named (wxkwxk666 on X)
5d54a990d added GET /api/usage/checkins/off and left it out of the
CLI parity list, so TestEveryRouteHasACommandOrIsNamed went red on main
(seen in that commit's full suite on mote). It is named in notYet as a
Usage page read; `magpie accounts checkin` already checks in every
account, as for POST /api/usage/checkin-account.

Run, on mote: go test -run TestEveryRouteHasACommandOrIsNamed
./internal/cli, red at 5d54a990d's full suite, ok with this line.
2026-11-13 19:04:48 +08:00
yetone e5b8f381dc provider: a Gemini provider saved as a bare host reads its Host without building a URL (#6479)
16b8c300f made Base(Gemini) return GeminiAsked(p.Gemini), which runs
GeminiBase (a regexp replace and url.Parse) and url.Parse again, and
adds /v1beta to a bare host. Host goes through Base on every look, so
f856d381a's guarantee (Host builds nothing; one list a look was 8 MB
over twenty Providers polls with real accounts) was gone for Gemini
providers. baffcb65d gave GeminiAsked a no-allocation path for a base
that is already versioned (case d of TestHostBuildsNoList), but a bare
host saved as typed, WandAPI's https://api.wandapi.ai (the very case
16b8c300f was for), still allocates 6 times a look, and an untrimmed or
pasted endpoint 5.

Host now asks baseHost, which is HostOf(Base(pr)) without building the
base: for a Gemini base saved with its scheme and a host, the host is
read from the saved URL, since what GeminiAsked trims (spaces, slashes,
a pasted /models/… endpoint) or adds (/v1beta) is all after the host.
Anything else (no scheme, no host, Factory's or Vertex's Gemini) still
goes through Base. Requests are unchanged: Base(Gemini) still returns
the asked URL. The test was right and is unchanged apart from two more
Gemini cases (d2: a bare host; d3: a pasted endpoint with spaces and a
trailing slash). The new TestHostOfGeminiIsAskedHost checks Host against
HostOf(Base(Gemini)) over odd saved values (no scheme,
"https:///models", "https://?x", "/x.example/v1", a port, a fragment).

Run (mica, -tags nogui; mote was at load 184):
- at 456b5c6c7, before baffcb65d: TestHostBuildsNoList red ("d: Host
  allocated 5 times a look", 3 of 3, also on mote), green after.
- rebased on origin/main ea3edd4b1: with Host's old loop put back by
  hand, d2 and d3 red (6 and 5 allocations); with this change
  TestHostBuildsNoList and TestHostOfGeminiIsAskedHost ok -count=3;
  go test ./internal/provider ok (144s); GOOS=darwin/linux/windows go
  vet ./internal/provider ok; gofmt -l clean.
Not run: the full ./... suite; the change is inside Host alone.
2026-11-13 18:59:59 +08:00
yetone 880da8c17e agent: ZCode is told a model takes video, so a video it attaches reaches it (Flandern1211 on X, #5098)
A model whose source lists video input (antigravity/gemini-4-argon, say)
reached ZCode as text and image only, in config.json's modalities.input
and in provider_config.json's inputFormat, so ZCode never attached a
video to it. buildModels left the catalog's kinds out of the agent
model, and zcode.go rebuilt the list from m.Images.

- buildModels carries Entry.Modalities() into InputModalities and
  OutputModalities.
- zcodeInputs adds "video" when the model lists it and the provider's
  format is Messages or Chat. ZCode's own built-in rules (3.14.3's
  zcode-builtin.json) use inputFormat.supportsVideo, so the key is one
  its strict schema takes; it is written only when true.

Ported from Flandern1211's fork branch (fix/zcode-video-input,
e955d3c24), with these differences after review:
- Its gateway half (Messages video block and Chat video_url as a file
  part) is on main already, since b4fc29a6e (#6135), so it is not
  taken; TestZCodeVideoReachesCodeAssist keeps their captured ZCode
  shapes as a guard.
- PDF is not offered (no supportsPdf, no "pdf" input), and Messages'
  document block is not read as a file: a translated request still
  loses a PDF (#5452), so ZCode would be told of a kind that doesn't
  arrive.

Test: TestZCodeToldOfVideoInput, red on origin/main e4ea31321
("config.json's media/gemini takes [text image], want [text image
video]"), and red with the Responses gate taken out by hand.

Not tried: a real ZCode with a video against a real Gemini model here;
the reporter captured ZCode 0.17.1's video block and video_url on
Windows 11.

Co-authored-by: Flandern1211 <163982805+Flandern1211@users.noreply.github.com>

Ran (mica, at this tree on e4ea31321): gofmt -l internal (nothing),
go vet ./..., GOOS=windows go vet ./..., GOOS=linux go vet -tags nogui
./..., go test -tags nogui -timeout 45m ./internal/agent
./internal/gateway ./internal/catalog ./internal/provider: ok agent
(297s), gateway (1080s), catalog; provider red on TestHostBuildsNoList
only ("Host allocated 5 times"), #6479, red on main and untouched here
(baffcb65d on main since). Rebased on origin/main ea3edd4b1 (no change
to these files): the new tests and TestZCode/TestCrush again, ok.
2026-11-13 18:57:10 +08:00
yetone 7758da0770 agent: Crush is told which models take images (Novello42 on X, #6515)
Crush's view tool answered "This model (…) does not support image data",
its file picker (ctrl+f) was hidden and a pasted image was left out, for
every model through magpie. magpie wrote Crush's providers.magpie.models
without catwalk's supports_attachments, so each model decoded with
SupportsImages false (capabilities.vision false once Crush 0.99 migrates
the file: migrateCatwalkV2Model, internal/config/load.go). Each model now
carries supports_attachments from m.Images, as OpenCode's modalities do.

Checked against catwalk and Crush main: Crush's load.go moves
supports_attachments to capabilities.vision; catwalk v3 reads vision.
Report and root cause: #6515 by DaVinci42.

Not changed: magpie still writes Catwalk v2 keys, which Crush 0.99+
rewrites to v3 on load; filed as #6521.

Test: TestCrushModelsSayTheyTakeImages, red on origin/main e4ea31321
("see/looks has no supports_attachments").

Ran (mica, at this tree on e4ea31321): gofmt -l internal (nothing),
go vet ./..., GOOS=windows go vet ./..., GOOS=linux go vet -tags nogui
./..., go test -tags nogui -timeout 45m ./internal/agent
./internal/gateway ./internal/catalog ./internal/provider: ok agent
(297s), gateway (1080s), catalog; provider red on TestHostBuildsNoList
only ("Host allocated 5 times"), #6479, red on main and untouched here
(baffcb65d on main since). Rebased on origin/main ea3edd4b1 (no change
to these files): the new tests and TestZCode/TestCrush again, ok.
2026-11-13 18:57:10 +08:00
yetone ea3edd4b13 routing: an account's share names its window when more than one counts the model (Wing8Aqua on X)
On the Routing page, under In turn, each account showed its week's share
("41% used") while its five hours were at 0%, and read as the five-hour
window. The row's share is Allowance.For's, the fullest window's, and
that is the one routing goes by: In turn rotates without weighing usage,
and sets an account aside only when a window reaches 98%, so the week at
98% stops it with the five hours empty. The number was right; it didn't
say which window it was.

Allowance.FullestName gives the name of the window the share is of when
two or more windows count the model (empty for one, as before). The
gateway puts it in Weighed.usedWindow, and the Routing row puts its short
form in front: "7d 41% used" (zh "7d 已用 41%").

Run (mica, -tags nogui): go test -run 'Fullest|UsedWindow|UsedRenews|Weigh'
./internal/provider ./internal/gateway ok; go vet darwin, linux, windows
on provider and gateway ok; gofmt clean. GUI (mote): the new
routing-used-window.test.cjs, 22 of 22 in chromium and webkit, en, zh,
zh-TW, ja and de, at 1100px and 420px; routing-*, i18n-keys, gui-zh-tw, gui-ja and
gui-de: 3234 of 3253; the reds are gui-de/gui-ja (fixed in this push's
sessions commit) and routing-context-fold, pin-away, row-swap, signin and
story-shrinks, red the same on a clean origin/main e4ea31321 run on mica
(#5586, #6512, #3799, #6520, #3954).
Broken by hand: w.UsedWindow not set in trace.go: TestUsedWindowNamesTheWeekInTurn
and TestUsedRenewsWithItsOwnWindow red; the prefix taken out of client.js:
routing-used-window 22 of 22 red. Both restored.
Not tried: a real Claude account with a full week, and the full suite
(both test machines had a long suite.lock queue).
2026-11-13 18:50:25 +08:00
yetone ba60e2e7f4 sessions: de and ja name the uninstalled agent once, as the English does
fe20e4dbd's "{agent} isn't installed here…" has {agent} once; its German
and Japanese said it twice, so gui-de and gui-ja's placeholder check was
red on main. The second mention is now "seine eigenen Dateien" and
"そのファイル自体".

Run (mica): node --test gui-de, gui-ja, i18n-keys, sessions-forget: 20 of
20 pass. Before: gui-de and gui-ja "de/ja has every zh string" red on a
mote run of this branch.
2026-11-13 18:50:25 +08:00
yetone baffcb65dd provider: Host asks a saved Gemini base without building a string again
16b8c300f made Base(Gemini) GeminiAsked(p.Gemini), which runs the base
through GeminiBase and url.Parse twice on every call. Provider.Host asks
Base for each protocol on every look, so a Gemini provider's Host
allocated 5 times a look and TestHostBuildsNoList was red on main
(e4ea31321: "d: Host allocated 5 times a look").

GeminiAsked now gives back a base that is already what geminiVersioned
would make (a scheme, a path of its own, no trailing slash, query,
fragment, /models or surrounding space) as it is, without allocating.
A bare host, a pasted endpoint and anything untrimmed still go through
geminiVersioned, so TestGeminiAsked's cases are unchanged.

Run (mica, -tags nogui): go test -run 'TestHostBuildsNoList|Gemini|Vertex'
./internal/provider ./internal/gateway ./internal/catalog ok; gofmt clean.
Red on the old code: the same test on a clean origin/main e4ea31321
worktree, "d: Host allocated 5 times a look".
2026-11-13 18:50:25 +08:00
yetone 456b5c6c74 alibaba: a RAM user's NotAuthorised names the grants Token Plan needs (#6506)
hkxhkxhkx on X (#6506, v0.1.4026, gateway on OpenCloudOS): the Token
Plan personal edition's usage, read with a RAM user's AccessKey, fails
with BailianGateway.Team.NotAuthorised. The RAM user had the
AliyunBailian* and AliyunModelStudio* policies.

magpie calls the right API: GenerateCLIAccessToken, then the console
gateway's zeldaHttp.apikeyMgr./tokenplan/personal/api/v2/usage, the same
call Alibaba's own CLI (modelstudioai/cli, `bl usage token-plan`) makes;
its only other parameter, switchAgent, is for delegated access, not RAM
users. Alibaba's Token Plan docs (personal FAQ; permissions and usage)
list what a RAM user needs, and none of it is a Bailian/ModelStudio
policy:
- the AliyunTokenPlanReadOnlyAccess (or FullAccess) system policy,
- AliyunBSSReadOnlyAccess for the personal edition,
- the Administrator or Subscribe Plan permission for the RAM user on
  Model Studio's Account Management page.
The NotAuthorised error now says those three and where, or to use the
main account's AccessKey. Any other refusal now carries the console's
errorMsg (read as raw JSON, so an odd type doesn't hide the code).

Tests: TestAliGatewayRAMNotAuthorised answers the call with the
console's NotAuthorised envelope and checks each grant is named, and
that another code shows its errorMsg. Broken by hand: the old message
makes it red on five checks.

Run on mica (and again after the rebase onto 49d7adef7): gofmt -l clean; go test ./internal/provider
-run TestAliGateway ok; vet as in the parent commit; go test ./internal/provider red only on
TestHostBuildsNoList (#6479). The editor's alibaba hint is unchanged:
the core script budget is red at base (#6518), and the error on the
Usage page carries the whole list. Not run: a real RAM
user's key (none here); the full suite.
2026-11-13 18:41:28 +08:00
yetone dc1f17c1c8 library: RTK's chart says its top number is the busiest day, not a total (jasonchia58 on X)
jasonchia58 on X (macOS, v0.1.3119): the number at the top right of
Library → RTK's chart (1.6M) stopped changing, while the total under the
chart kept growing. That number is the bars' scale: the busiest day's
(or week's) input in the range, shown bare since 5b43bdd61. It changes
only when a day passes the old busiest, so it read as a stuck total.
Nothing on main changed it since 3119.

It now says "peak day 1.2M" / "peak week 1.2M" (zh 单日最高, zh-TW 單日最高,
ja 1日の最大, de Stärkster Tag), in the library plugin's own words, and
a range with nothing in it shows none. The total stays under the chart.

The Usage page's charts have the same bare peak (plugins/usage/page.js
875 and 4315); filed as #6517, not changed here.

Tests:
- internal/library/testdata/rtk-gain-daily.json is real rtk 1.0.1
  `rtk gain --daily --format json` output from a sandbox HOME;
  TestRTKGainRealDaily parses it and checks the days add up to the
  summary.
- library-rtk-chart.test.cjs feeds those days (moved to end yesterday)
  through a faked /api/library/rtk, chromium and webkit, en/zh/zh-TW/ja/de
  at 980 and 420px: the head says the peak, the busiest bar is the one
  at full height, the foot is the total; an empty 30-day range has no
  peak.

Run on mica (base 5b25d7e9e, then again after the rebase onto
49d7adef7: gofmt, the provider and library tests, library-rtk-chart,
library-rtk-gain, i18n-keys, i18n-en-no-cjk all pass): gofmt -l clean; go test
./internal/library ok; GOOS=darwin/windows go vet and GOOS=linux go vet
-tags nogui of internal/{provider,library,gui} ok; GUI files
library-rtk-chart, library-rtk-gain, library-rtk-admin,
library-rtk-nohook, i18n-keys, i18n-en-no-cjk all pass (both engines).
Broken by hand: the old head (bare tokens(peak)) makes all 12
library-rtk-chart subtests red.
Also run: go test -tags nogui ./internal/gui ./internal/provider: red
only on TestCoreScriptBudget (1,268,751 > 1,268,645, the same number
#6518 records at base 5b25d7e9e; this change adds no core script) and
TestHostBuildsNoList (#6479); editor-hints webkit red as in #6156.
Not run: the full Go suite and the whole GUI suite.
2026-11-13 18:41:28 +08:00
yetone d21cb563e9 sync: Copy setup gives the sync setup as text, sealed with the passphrase (WJaunita45604 on X)
Setting sync up on a second computer meant typing the server, user,
password (or S3 keys, or GitHub token) and every tick again. Settings ›
Sync's form, with sync on, now has Copy setup. It copies one line,
`magpie-sync:…`, to paste into the same form on the other computer.

- The line is not base64 of the settings. It is the setup (server,
  password or token, endpoint, region, path style, branch, the ticks)
  sealed with the sync passphrase by backup.SealData, the AES-GCM and
  PBKDF2 envelope the server's file already uses. The passphrase is never
  in it. Whoever has the line and not the passphrase has nothing. The
  copied note says what it holds and that the same passphrase opens it.
- Pasted into any field of the form, the line is not typed in; the form
  asks for the passphrase, opens it (POST /api/davsync/setup-open), picks
  WebDAV, S3 or GitHub from its address and fills every field and tick.
  Nothing is saved until Turn on, and Turn on opens a pasted line first. A
  wrong passphrase, or text that isn't a setup, is said in the reader's
  language. A line a chat wrapped, or text around it, still opens.
- Not built: GitLab or MySQL sync backends.

Run (mica):
- At the pushed tree (run as 8fadc2ef8, the same tree before these bodies): go test ./internal/gui ./internal/davsync
  ok; sync-setup-text, i18n-keys and i18n-en-no-cjk in the 110 of 110 the
  commit before names. At the base 5b25d7e9e: ./internal/backup ok too.
  New TestSetupTextOpensWithItsPassphrase (WebDAV, S3, GitHub; no secret
  readable in the text or its decoded bytes; wrapped line; wrong
  passphrase), TestSetupTextNeedsSyncAndItsOwnText and
  TestDavsyncSetupTextRoutes (through the page's routes: off, copy, open on
  a computer with sync off, wrong passphrase, nothing saved).
- New sync-setup-text.test.cjs, Chromium and WebKit, en, zh, zh-TW, ja, de
  at 900px and en, zh at 440px: 42 of 42. The sync GUI files and
  i18n-keys / i18n-en-no-cjk: green but s3-sync webkit en, red the same
  alone on origin/main e4ea31321 (#3413).
- GOOS=linux go vet -tags nogui, GOOS=windows go vet: clean. gofmt clean.
- Broken by hand: SetupText unsealed (base64 of the JSON) made
  TestSetupTextOpensWithItsPassphrase red ("dav-app-password-9z is
  readable"); Turn on without opening the pasted line made all seven
  "pasted setup fills" GUI tests red. Both restored green.

Not tried: a real WebDAV, S3 or GitHub server between two computers, a
paste in the real app, WebKitGTK.
2026-11-13 18:39:28 +08:00
yetone a44da380b9 providers: a vendor's setup pasted in any form fills the custom provider (WJaunita45604 on X)
2bb201162 (v0.1.3788) opened a custom provider from pasted env lines, but
only for ANTHROPIC_, OPENAI_ and GEMINI_ names. A vendor's page that writes
`export XXX_BASE_URL=…` / `XXX_AUTH_TOKEN=…`, a bare BASE_URL, a JSON
snippet in snake_case, or a plain "Base URL: … / API Key: …" (also 地址 /
密钥) fell through to the search box as text.

- envOf takes any prefix before BASE_URL, API_BASE, ENDPOINT, HOST, … and
  AUTH_TOKEN, API_KEY, TOKEN, SECRET_KEY, …. An unknown prefix needs an
  http(s) value, and its API comes from the path (/anthropic or /claude is
  Anthropic, else OpenAI compatible). *_PROXY and GITHUB_, GH_, NPM_, AWS_,
  HF_, SLACK_, DISCORD_ names are left alone, so a pasted .env of other
  things opens nothing. Named vendors come first when both are there.
- plainOf reads text that is not variables: it needs an http(s) address and
  a key (labelled, or shaped like one), cuts /chat/completions, /messages
  and /responses off the address, and leaves curl to curlOf.
- The search placeholder says it: "Find a vendor, or paste a URL and key…"
  in en, zh, zh-TW, ja and de.
- The key still goes only into the draft. The logo is the site's icon
  fetched by icons/favicon with the address alone, as before.
- The favicon callback is packed to one line, so the core scripts are 12
  bytes smaller than at its base despite the longer placeholder.

Run (mica, mote over its 18 cores), at the base 5b25d7e9e unless said:
- provider-env-paste and sync-setup-text, Chromium and WebKit: 60 of 60.
- add-sheet*, provider-add-*, provider-curl-paste, provider-env-paste,
  custom-systemone-url, the sync GUI files, i18n-keys, i18n-en-no-cjk: 349
  of 350. The red is s3-sync webkit en ("picking S3 must not scroll the
  page"), red 3 of 3 alone on untouched origin/main e4ea31321: #3413.
- go test ./internal/gui ./internal/davsync at the pushed tree (run as 8fadc2ef8, the same tree before these bodies)
  (rebased on e4ea31321): ok, TestCoreScriptBudget included (1,268,622 of
  1,268,645). At the base 5b25d7e9e the budget was red as on that main,
  fixed by e4ea31321.
- At the pushed head: provider-env-paste, provider-curl-paste,
  add-sheet-custom, sync-setup-text, i18n-keys, i18n-en-no-cjk: 110 of 110.
- GOOS=linux go vet -tags nogui, GOOS=windows go vet: clean. gofmt -l clean.
- Broken by hand: envOf named-only and no plainOf; provider-env-paste's
  new cases went red in Chromium, restored green.

Not tried: a paste into the real app's Add sheet (only the GUI suite's page),
and WebKitGTK.
2026-11-13 18:39:28 +08:00
yetone 49d7adef74 lessons: 5b25d7e9e tagged with the core budget red; packing lines is not a move
5b25d7e9e added 106 bytes to context.js at a core already at its
budget and was tagged v0.1.4040 with TestCoreScriptBudget red.
e4ea31321 met it again without a raise, partly by joining lines.

Docs only; nothing run.
2026-11-13 18:37:50 +08:00
yetone e4ea313215 context: the last-cache fix fits the core script budget again
5b25d7e9e (shenggxhz on X) added 106 bytes of code to context.js while
the core scripts sat exactly at their budget (1,268,645 at its parent),
so TestCoreScriptBudget has been red on main since (1,268,751). The
budget is not raised; the change is packed instead:

- Routing passes the session key whole (sk, the conversation, or the
  line's first request), so ctxCard keys on opts.session alone. Routing
  is ctxCard's only caller.
- cacheOf takes a missing route, so the seed is `lastCache ||=
  cacheOf(opts.prev)`, and the cache shows when lastCache is set: it is
  set only by a shown cache (cacheShown) or by prev, which Routing passes
  only for a request under way, so `live &&` added nothing.
- Three nearby lines in the same card packed to one statement each
  (the health word, the big figure, the cache's class), same output.

core scripts now 1,268,634 of 1,268,645 (117 bytes less than 5b25d7e9e).

Run (mica-run, at this tree on 5b25d7e9e): go test ./internal/gui -run
'TestCoreScriptBudget|TestAppScriptBudget' ok; node --test routing-ctx-cache-long,
-still, -sessions, -fold, i18n-keys, context-cap, ctx-session-line: 150 of
154. The 4 reds are context-cap chromium en/zh (#6514) and ctx-session-line's
session-line test in both engines (#5801), red the same on main before this.
Broken by hand: without `|| lastCache` in the cache's condition, and
separately without the prev seed, routing-ctx-cache-long goes 12 of 22 red
in both engines.
Not tried: the real app; the change has no new behaviour, and the
Routing ctx GUI files cover the card's cache states in both engines.
2026-11-13 18:20:09 +08:00
yetone f07c5de1f0 wsl: a distro whose vEthernet path to Windows is firewalled reaches magpie at Windows' LAN address (H1_B1_K1 on X)
H1_B1_K1 on X: a company firewall (火绒企业版) that the user can't open
blocks a NAT distro's path to Windows' address on vEthernet (WSL), the
172.x one magpie wires agents in WSL to. Windows' LAN address answers
from WSL. Nothing told magpie to try it, and nothing should have to:

- When the reach check from inside a NAT distro finds the gateway's WSL
  address shut (reachFrom's probe, told and not ok), wslFindVia asks the
  gateway (gateway.SetWSLVia, kept in settings.Dir()/wsl-via) to listen at
  each of Windows' other IPv4 addresses too. The LAN's addresses come
  first and Hyper-V's other vEthernets last. It then asks from the distro
  which one answers, keeps the first that does as the via and lets the
  others go.
- A via listener lets in only Windows itself (peer == local address,
  which is how a NAT distro's connection to the LAN address arrives) and
  the WSL networks. A LAN peer is reset before HTTP. fromWSL takes the
  WSL key there as it does on vEthernet.
- distro.host() is the via under NAT, so base(), the Claude Science
  relay and keptaway's wslHost use it. Every NAT distro's wired agents
  are set again (Rewire). WSL Codex now moves its own two URLs
  (codexMoveGateway), as on Windows, because openai_base_url wasn't
  moved by a rewire. The address left behind goes into the distro's Was,
  and the unreachable line offers "Use" for a config still on the old
  one (wslMovedFrom).
- When the via shuts later and the WSL address answers again, the via is
  dropped and agents go back.

Not changed: wslrun.Tool.proxy still turns a user's 127.0.0.1 proxy into
the distro's vEthernet host (Tool.Host). That is the user's own proxy,
which magpie can't make listen elsewhere. Filed as an issue.

Run:
- go vet for darwin, windows and linux of internal/agent, gateway and
  wslrun: ok (mica).
- go test internal/gateway and internal/wslrun -run "WSL|Via": ok, on
  mica and on Windows (xiaomi-gpu).
- go test internal/agent -run "WSL|Kept|Reach|Unreach|Codex|
  ClaudeScience": ok (mica, 104s). On Windows, -run "WSL|ClaudeScience|Kept|Reach|Unreach": every WSL
  test ok. Its first run was red in three WSL tests: a distro found
  shut searched the box's real addresses, 15s each, under wslViaMu, so
  the next test's probes waited. TestMain now gives the package no
  candidates. The four "kept" allocation reds there are red at base
  too (#4786).
- Real, on xiaomi-gpu with the magpie-desktop distro (NAT, Windows at
  172.17.32.1, LAN 10.0.0.132). A firewall rule blocked inbound on
  172.17.32.1 at the test's port. A throwaway Windows test (not
  committed) started gateway.New().ListenAndServe and called wslFindVia
  with the real wsl.exe:
  - curl from the distro to 172.17.32.1: no;
  - candidates [10.0.0.132 192.168.77.1 172.28.224.1];
  - via [10.0.0.132] kept in 0.66s, and the distro reaches magpie there;
  - curl to 10.0.0.132 from mote and from this Mac: reset by peer;
  - from the distro: an HTTP answer.
  The rules were removed afterwards.
Broken by hand, each red:
- dropping the wslFindVia call in reachFrom:
  TestWSLFirewalledFindsAnotherWay;
- dropping fromWSL's via clause: TestWSLViaCallerServed;
- dropping the peer == local check in viaPeer:
  TestWSLViaListenerLetsInWindowsAndWSLOnly.
reach_test's reachForget now waits for a probe still out before it
clears the answers. TestWSLFirewalledFindsAnotherWay's last driftSettled
starts a probe for the address the agent was just set at, and clearing
under it panicked (assignment to entry in nil map). That was once in 1
and once in 3 runs at -count=3 on mica, and 0 in 5 after the change.
At the rebased head (5b25d7e9e): -count=5 of the agent run above on
mica, ok except TestCodexServedKeptWhileCatalogStays once, a TotalAlloc
ratio that counts another test's goroutine (#5435, passes 10/10 alone).
TestCoreScriptBudget is red at 5b25d7e9e without this change (#6518).

Not tried: 火绒 itself, a real agent session in the distro across the
switch, and a mirrored or bridged distro (left alone by design).
2026-11-13 18:17:36 +08:00
yetone 2f22cc7e80 redact: Settings › Privacy's masking rules are imported in bulk and copied out (hgk0x on X)
hgk0x on X had many fields to mask, and adding custom rules one at a
time was slow. The Masking rules row now has Import… and Copy beside its
words, as the word lists have:

- Import… opens a box under the row's fields. One rule a line: a name,
  then a tab, =, : or comma, then the pattern; a bare pattern is CUSTOM.
  The box's Regex/Prefix choice says how a pattern is read. A JSON list
  (what Copy writes) is taken as it is, prefix and regex rules alike.
  What was read is listed (the first eight, then "and N more"); a rule
  the list has, or one pasted twice, is passed over. Import saves once,
  after the rules there are. Escape and Cancel save nothing; a redraw
  keeps the box, its text and its choice; a list the gateway refuses is
  said in the box and the paste is kept.
- Copy writes the rules as JSON.

MaxRules stays 32. Measured on this machine: 32 rules took 83ms on a
190KB body, 100 took 343ms, and that cost is on every request. One
rule's regex with alternation (a|b|c) covers many fields, which the
reply says. There is no CLI for masking rules, so none was added.

Run (GUI, mote/mica, both engines):
- new redact-rules-import.test.cjs: 5 languages x chromium/webkit at
  400px, 10/10 ok.
- the 56 GUI files that reach the privacy page, masking or i18n
  (i18n-keys, i18n-en-no-cjk, plugin-own-words, redact-*, mask-*,
  privacy-*, settings-*): 1333 tests, 27 red on loaded mica. The reds,
  run again on mote at base 5d54a990d and at this change: the same 20
  in settings-hints, settings-search and settings-lines-wrap de 440px
  on both (#6353, #6156, #6133). provider-mask's 6 reds were mica's
  load (load 60-85); it passed in both mote runs.
Broken by hand: reading every line as unnamed (named = false) turns
the new test red in every language and engine.
Not tried: the whole GUI suite, and the real app.
2026-11-13 18:17:36 +08:00
yetone f9678cebe2 gui: Routing's quota bars are Usage's, and every account in a Usage card has a line over it
normalcoder_ on X: Routing's remaining/total bars were grey and black
while the Usage overview's are blue, and in a Usage card with several
accounts two accounts ran together with no divider.

Routing's bars were never Usage's: af5889085 drew them grey (--muted),
black (--fg) for the account that answered, on --card-2, from the start.
It was not a regression. Now the stage's rows, a fold's row and each
account's row under the requests carry Usage's .quota-track, so the track
and fill come from that one rule (--pill, --accent) in light and dark.
routing.css keeps only their size and place. The account that answered
still shows by its frame and dot.

The Usage dividers came from six rules spread over app.css, each naming
one kind of row that could end an account (windows, error, balance, read
time, credit days, curve, resets, key line, auto-reset, credits). A
brief account's check-in row (Trae, WorkBuddy, MiniMax Code) and
magpie's own requests line (quota-own) were never named, so the account
after one had no line. One rule now draws the hairline over every
account that follows anything but the card's head or its "All accounts"
box.

Tested: new quota-bars-alike.test.cjs, in Chromium and WebKit, en zh
zh-TW ja de, light and dark, 1100 and 420px. It checks that every
account after the first in a card has a 1px solid --line border, the
first has none, and every visible Routing bar (stage and account list)
has the same track and fill colours as Usage's .quota-track: 10/10.
Broken by hand: the old app.css fails it, the old routing.css fails
it, and the old client.js (no quota-track class) fails it.
Screenshots before and after in both engines, both themes, 1100 and
420px: Routing's bars are accent on the pill track, and the Trae card's
t2/t3 have the line that was missing.
The GUI files that reach Routing, Usage, quota cards and accounts (354
files, every routing-*, usage-*, panel-usage*, quota-*, plus the
subscription-account/rt-acct users, i18n-keys and old-webkit) on mica:
5854 pass, 141 fail. The failures are in 23 files. Rerun at
concurrency 2 on origin/main 51b98b1a8 and on this tree, they fail the
same (130 at base, 133 here, the same files). The extra ones are
tray-cell-click, which fails 2 of 4 on base when run alone, and a
rest-try-now case. old-webkit's red is app.css:~422 :has(), not this
change. go test -tags nogui ./internal/gui -run Budget: ok.
At the pushed head 4176025f4 (rebased): quota-bars-alike, routing-quota-left,
usage-accounts-fold and i18n-keys pass, 30/30.
Not tried: the real app on Linux WebKitGTK (colours only, no motion).
2026-11-13 18:11:09 +08:00
yetone 5b25d7e9e8 context: a request under way in a long session shows the last cache, not "—" (shenggxhz on X)
shenggxhz's Codex session (T3 Code) on Routing showed "— 命中 · 供应商回答后可见" while a request was under way, and read it as the cache missing. The cache was there: Codex's rows record cache_read at about 32K of 34K. The card was dropping it for two reasons.

- The card forgot the last cache whenever the first request in its session line changed (its key was opts.series[0].id). Routing keeps only the latest 60 requests. In a session longer than that, the first request moves on with every new request, so every request under way showed the dash. The key is now the caller's session key (opts.session: the Routing session key, else the conversation).
- A card opened while a request was under way had no last cache to show, even when the session's answered requests were in the list. Routing now passes the session's last answered request with usage (opts.prev). Its cache is shown, dimmed and labelled "the last request's", until this request's own cache is read.

Run (mote):
- At the pushed head (rebased on 80c22eecb): routing-ctx-cache-long, routing-ctx-still, routing-ctx-sessions, routing-ctx-fold and i18n-keys pass 146 of 146.
- At the pre-rebase base 5d54a990d:
- New routing-ctx-cache-long.test.cjs: 22 of 22, in Chromium and WebKit, in en, zh, zh-TW, ja and de. It covers 60 answered requests followed by three more that stream start, then read, then done, with the figure dimmed and right at each step. It also covers a page opened mid-request.
- The 24 context-*, ctx-*, routing-ctx*, routing-context*, sessions-context*, group-context and i18n-* files: 800 of 806. The 6 reds are red the same way alone on origin/main 80c22eecb:
  - context-cap chromium: filed as #6514.
  - ctx-session-line, both engines: #5801.
  - routing-context-fold webkit, ResizeObserver: #5586.

Broken by hand:
- Without prev: the opened-mid-request cases are red, 10 of 22 (5 languages x 2 engines).
- Without prev and with the old series[0] key: all 20 subtests are red.
- With the old key alone, the test stays green, because prev seeds the cache again after each reset. The key is still the cause and is fixed here. prev alone would not cover a request whose prior answer is no longer listed.

Not tried: the real app with a live Codex session past 60 requests; Usage's and Sessions' cards (they pass no session or prev and behave as before); a Windows or Linux run.
2026-11-13 17:46:44 +08:00
yetone 83b8910388 gateway: TestRetriedRequestCountsOnce holds Failed to d370bef98's rule (#6466)
d370bef98 made Usage's Failed filter list every request a try failed
on, the ones a later try answered too. The gateway test still expected
Failed to list nothing for a request the group's third member answered,
so it was red on main every run since. It now expects both rows of that
request; the counts (1 call, 0 errors, 1 retried) and the outright
failure's case are unchanged.

Run on mica: go test -count=3 -run '^TestRetriedRequestCountsOnce$'
./internal/gateway, ok (red 1 of 1 in the full suite at 98dcbf5b1
before the change).
2026-11-13 17:45:01 +08:00
yetone 80c22eecba agents: Codex leaves a model unchecked in its provider's list (JNDliuliuM on X)
JNDliuliuM: after picking new models for a provider, Codex CLI didn't
change, and after a restart it was still on the old model. magpie wrote
the new list, but Codex's `model` (config.toml, or magpie.config.toml for
`codex -p magpie`) stayed on the model the user had unchecked. Resolve
still takes any provider/model, so Codex kept starting on it and asking
the vendor for it.

Tried with the real codex-cli 0.165.0 in a sandbox CODEX_HOME, profile
wiring: the list was swapped from sub/old-a, sub/old-b to sub/new-x,
sub/new-y. After a restart, /model listed only the new ones, but the
status line still read sub/old-a, as the profile named it.

What changed:
- provider.Unpicked(id) reports a model the user has since unchecked:
  the provider has picks, its served models lack the model, and it isn't
  a decision model. This is the same rule ResolveRoute already applies
  to routing groups (#3911).
- agent.pickedInstead moves such a model to the first model of that
  provider that magpie lists for the agent now.
- Codex's Sync calls it before its other model branches, through set, as
  picking the model does. The profile's Sync calls it through put. The
  Codex app reads the same config.toml, so it follows too.
- Left alone:
  - a provider with no picks, whose list is the vendor's and may lack
    the model (#2642);
  - a provider with none of its models listed any more.

Run on mote:
- TestCodexLeavesAModelUncheckedInItsProvider (as provider, beside a
  ChatGPT sign-in, profile) and TestCodexKeepsAModelOfAProviderWithNoPicks;
- go test ./internal/agent/ ./internal/provider/;
- go vet for darwin, linux and windows on both packages;
- gofmt.
Result: internal/agent ok (470s). internal/provider is red only on
TestHostBuildsNoList (a Gemini provider's Host allocates 5 times), which
is #6479 and was already red on main.

Broken by hand: with the Codex Sync call disabled, the "as its provider"
and "beside the sign-in" subtests are red ("model = sub/old after sub/old
was unchecked"). With the profile call disabled, the "by its profile"
subtest is red.

Not tried:
- the fixed magpie with a real Codex;
- the Codex app.

Not changed, filed as #6504: other agents' model fields, and Codex's
subagent and compaction models.
2026-11-13 17:37:48 +08:00
yetone f4a73672ef routing: a ChatGPT API account is weighed by its Codex twin's reading, and its story lines wear its own logo
tmr11235 on X (v0.1.3924): a routing group of two ChatGPT accounts, each
added both as Codex and as ChatGPT API (chatgpt-api). The Codex rows read
their week and reset; the story below said "剩余额度未知,排在已知的之后"
next to the Codex logo, so it read as the Codex rows being unknown.

Two causes, both still on main:

- The story's lines were about the ChatGPT API accounts, but a line
  named only an account's name, and logoed() put the logo of the first
  member of that name in the order: the Codex twin. asides() now says
  which member each line is about (by its place, as two lines may say
  the same words), and renderSteps hands it to logoed(), as it did for
  a skipped member's line only.
- OpenAI tells a ChatGPT API account's plan usage nowhere magpie can
  ask, so Smart weighed it as unknown and put it after every known
  account, though it spends the same plan as its Codex twin.
  Allowances("chatgpt-api") now gives such an account the Codex
  account's allowance (samePlanAllowances), matched as
  SamePlanAccounts matches them: both tokens' chatgpt_account_id and
  chatgpt_user_id, never the name, so two Team seats of one email stay
  apart. One with no Codex twin stays unknown. The Routing card reads
  the same figure, as it reads the gateway's.

What was run (GUI on the Linux box through wsl-run, mote over its load
then; Go on mote):
- go test ./internal/provider -run 'TestChatGPTAPIAllowanceIsTheSameAccountsCodexReading|TestRenewedAccountForgetsItsAllowance|SamePlan': ok
- node --test routing-twin-logo (new; chromium and webkit; en, zh,
  zh-TW, ja, de; 1100 and 420): 20 of 20 ok.
- Every GUI file that opens the Routing page (199) plus i18n-keys and
  i18n-en-no-cjk: 3533 ok, 61 red in 13 files (click-scroll,
  ctx-head-narrow, ctx-route-align, ctx-session-line,
  inner-scroll-contain, mobile-web, routing-ctx-sessions,
  routing-many-keys, routing-pin-away, routing-pulse-composited,
  routing-row-swap, routing-sky-under, routing-story-shrinks). The same
  13 files at origin/main daaa11cb5 on the same Linux box: 57 red in
  the same tests; on mote the 13 files give 23 red at both
  origin/main and this change, test for test (ctx-session-line,
  mobile-web, routing-pin-away, routing-row-swap,
  routing-story-shrinks).
- go vet ./internal/provider ./internal/gateway (darwin), GOOS=linux
  and GOOS=windows go vet ./internal/provider: ok; gofmt -l: none.

Broken by hand:
- samePlanAllowances not applied: the new provider test is red ("the
  chatgpt-api account reads [] (known false)").
- asides' member dropped (about[i] -> undefined): routing-twin-logo is
  red in all 20 cases, the unknown lines lead with codex-color.

Not tried: a real ChatGPT API + Codex pair in a sandbox HOME (the
match is SamePlanAccounts', run for real since 2df5d40ee); the full
suite before the push (started after it).
2026-11-13 17:36:40 +08:00
yetone 2f1759c96c usage, catalog: the same catalog fetched again keeps the usage index
A Claude account's model list fetches models.dev again every 45
minutes (catalog.Asked), most often to the same bytes. Each fetch
rewrote models.json, so its mtime changed, and usage keyed its request
index, the index's file on disk (requests-v1.bin, heat, page, effort)
and its priced summaries on that mtime: the next usage query dropped
every chunk and read every session file again. On the acctp history
(15.7k session files) a start that rebuilds takes ~15 s of CPU in its
first 30 s, against ~2 s for one that keeps the index. Each fetch also
forgot the parsed catalog and told every agent to rewrite its list
(catalog.Changed), for nothing changed.

- catalog.CacheKey names models.json and labs.json by a hash of their
  bytes, kept by their stat so a key costs a stat until a file changes.
  Usage's request meta and price key use it in place of the mtime, as
  liveListKey already did for the providers' lists.
- Sync writes models.json and labs.json only when their bytes changed;
  the same bytes are dated now (Stale, Missing and Asked read the time),
  and Reset and Touched run only when either file changed.

Tests: TestSameCatalogFetchedAgainChangesNothing (catalog) and
TestRequestStateKeptAcrossACatalogFetchedAgain (usage). Broken by hand:
with keepFetched always writing, the catalog test is red (told the
agents on the same bytes); with usage keyed on statKey again, the usage
test is red (meta and price key changed).
2026-11-13 17:16:47 +08:00
yetone cc42ec1d7e agent: an api set by hand in Pi's models.json stays (xiaomanweiman on X)
T3 Code's Pi puts all 71 of its tools into the context on
openai-completions and only 3 on openai-responses, loading the rest when
asked. The reporter set providers.magpie.api to openai-responses in
~/.pi/agent/models.json, and the next catalog sync wrote
openai-completions back.

piAPIsKept (pi_api_kept.go), called from piBlockKept (Pi, its forks and
Aside), keeps an api the user set for magpie's provider or for one of its
models. As with a maxTokens typed by hand (output_kept.go), the stash
records the APIs magpie wanted per file (api:<path>:wanted), and an api in
the file that is none of them is the user's. A model's keeps its baseUrl
and compat with it. With no record yet, the provider's is taken as
openai-completions, the only value magpie ever wrote there, so a file
edited before this release keeps the user's value on its first sync. An
api the file lacks is magpie's. A Chat model left on a provider the user
put on Responses gets compat.supportsStrictMode, as magpie's own
Responses models have it (#3055).

magpie's default is unchanged: a model whose provider speaks Chat stays
on Chat, relayed as Pi sent it, and no setting was added.

Run (mote): go test -count=1 ./internal/agent/ ok (322s); go vet
./internal/agent/ for darwin, GOOS=linux and GOOS=windows; gofmt -l clean.
TestPiKeepsAnAPISetByHand covers a value set before any record, set back
by hand, a model's api with its baseUrl, and one taken out.
Broken by hand: with the piAPIsKept call commented out the test goes red
("provider api = openai-completions, want the user's openai-responses").
Not tried: a real Pi or T3 Code (neither is installed here); the full
suite runs after the push.
2026-11-13 17:14:57 +08:00
yetone 37e3d4d45f LESSONS: a95a7a1cd is the ninth core budget raise on 11-13
+397 for per-key price rates; the day is now +3,028 bytes.

Docs only; nothing run.
2026-11-13 17:03:31 +08:00
yetone 5d54a990d4 usage: switched-off providers' accounts can be checked in, and Check in all (wxkwxk666 on X)
wxkwxk666 asked for two things on the Usage page. First, a provider
switched off should still show its accounts, at the bottom and folded,
so they can still be checked in each day. Second, one button should check
in every account at once.

- provider.OffCheckins (off_checkins.go) lists every account a
  checkiner reaches whose provider is switched off (Off, not Hidden).
  Each is a card with no windows. Nothing is read or asked for it. Its
  check-in result is matched by its own key, not by its name, since two
  sign-ins can share a name (plugins#254).
  GET /api/usage/checkins/off serves the list.
- The Usage page (plugins/usage) adds a "Switched off · n" line after
  the cards and the hidden line. It is folded until clicked. Each
  account shows today's check-in, and a Check in button when it isn't
  checked in yet. The button uses checkinnow.js's ciNowSend, which
  POSTs /api/usage/checkin-account.
- Check in all, at the head of the allowances, presses every account
  not checked in today, from the cards and from the switched-off line.
  It sends one checkin-account request per account, three at a time,
  shows "Checking in i/n…", then gives the counts (checkinPressSaid).
  When no account is due, it says so and sends nothing.
- Nothing switches a provider back on. The new strings are in zh,
  zh-TW, ja and de. Plugin files only: app.js is unchanged.
- docs/subsystems/provider-plugins.md says all of this.

Run, on mote:
- TestOffCheckinsListsSwitchedOffAccounts, in the fakeco plugin
  sandbox:
  - nothing is listed before the switch-off;
  - after it, two cards with distinct keys;
  - a press on one checks in exactly that account;
  - the provider stays off;
  - only the pressed card carries a result;
  - nothing is listed once the provider is switched on.
- go test ./internal/provider ./internal/gui, at this commit on
  origin/main 0fda3a1c1: gui ok; provider ok but for
  TestHostBuildsNoList, red on main already (#6479)
- gofmt
- go vet for darwin, linux (-tags nogui, ./...) and windows
- usage-checkin-all.test.cjs, in Chromium and WebKit, at 900 and
  420px, in en, zh, zh-TW, ja and de (20 of 20). It covers:
  - the line is folded, at the end, with its count;
  - opening it doesn't scroll;
  - a row's own press asks for that account only;
  - Check in all shows 0/2 while held, presses only the two due
    accounts, and POSTs nothing else (no provider switched on);
  - a second press asks nothing and says every account is in.
- 187 GUI files (the Usage page, panel, tray, settings and their
  neighbours), at the rebased head on mote: 3080 cases, 104 red in 16
  files. Those 16 run again on mote at origin/main 5a2d0ff47 and at
  this commit, under the same load: the same 12 files are red on both
  (checkin-now-account #6029, codex-auto-reset #4790, key-balance-card
  #6414, menu-scroll #5982, mobile-web #3952, old-webkit #6030,
  quota-refresh-order #6180, tray-cell-click #5215, usage-cards-hide
  #6294, usage-fold #4790, usage-hidden-way-back #6295,
  usage-range-times #6499, filed now). account-eye, i18n-keys,
  last-page and quota-warm pass on both in that rerun.
- That wide run found account-alias and account-eye red on an earlier
  draft: a fixture answering {} for the new endpoint made the page
  spread a non-array. The page now takes only an array.

Broken by hand:
- Without checkinAll's not-due skip, all 20 GUI cases go red.
- Without OffCheckins' check-in result (q.Checkin), the Go test goes
  red at off_checkins_test.go:56.
- Matching results by name (WithCheckins), as an earlier draft did,
  also went red.

Not tried: checking in a real switched-off vendor account through the
real app. The press is the existing CheckInAccount path, the same one
Settings' per-account Check in now already uses.
2026-11-13 16:56:19 +08:00
yetone 0fda3a1c12 cli: provider set resolve.<host>=…, the editor's Connect to from the CLI (quantum_lsfc on X)
v0.1.4012 added Advanced › Connect to (Provider.Resolve) in the GUI
only; the reporter asked for it from the CLI. `magpie provider set <id>
resolve.<host>=<IP or dns:name>[,…]` sets a host's connect addresses,
an empty value takes the host out, and `resolve=` clears them all (any
other resolve= value is refused, never saved). provider.Save checks
them as the GUI's do (netproxy.CheckResolve, TakesResolve), so a bad
place or a vendor's own host is refused with nothing written. `magpie
provider <id>` lists them as "connect". Usage and docs/reference.md say
how.

Run on mote: go test -count=1 ./internal/cli ok (166s);
TestProviderSetResolve ok; go vet ./internal/cli for darwin, linux
(-tags nogui) and windows ok; gofmt -l clean. A nogui build in a
sandbox HOME on mote: provider add + set resolve.api.corp.example=
10.0.0.5,dns:gw.corp.example saved and shown as connect; resolve=oops
and a bad place refused; resolve= cleared it; provider set --help
printed usage.
Broken by hand: not deleting the host on an empty value, and taking a
non-empty resolve=, each turn TestProviderSetResolve red.
Rebased on origin/main 9572a2b4c and run again on mote: the resolve,
Pair and Help tests of internal/cli ok.
Not tried: a request actually dialled through the rule from the CLI
(the dial is the GUI's, covered by netproxy's and provider's tests),
nor the reporter's managed network; Windows and Linux beyond go vet.
2026-11-13 16:39:09 +08:00
yetone a4cd61f77f claude: a turn refused for the account's limit keeps its session till the reset (#6292)
A Claude subscription turn refused for the 5-hour limit before any reply
(429) ended its run through relay's abort, and the conversation's native
session went with it. After the reset the turn was told whole to a new
Claude Code: 354,900 tokens written to the cache again (recih).

Now relay's abort is told the status and words (relayFailing); on a 429
keepForReset shelves a copy of the session cut before the refused turn
(no user line, no synthetic error line), under the turn's key. Cut at
backLine/backMsg for a resumed idle run, or at fromLen (the saved file's
length at start) for a run started from a saved session that has answered
nothing, so a turn refused again while still limited is kept again.

It waits until the reset the refusal names, else the account's used-up
window's reset from the rate_limit_event (KeptClaudeLimits), else 5h; plus
1h, at least idleLongest, at most longestQuota (8d). until goes into
claude-shelf.json, so the entry survives a restart. Shelf still capped at
shelfMost.

Run (on mica; mote was over its cores):
- go test -tags nogui ./internal/gateway/ -run 'Claude|Shelf|Relay|Bridge|Subscription': ok 93s
- new TestClaudeTurnRefusedForTheLimitKeepsItsSessionTillTheReset (print and
  interactive: two refusals, restart, then --resume of the cut session told
  the turn alone) and TestQuotaShelfFor: ok
- GOOS=linux and GOOS=windows go vet ./internal/gateway/: ok; gofmt clean

Broken by hand, each red:
- keepForReset call removed: "try 1: no session kept"
- fromLen forced to 0: "try 2: no session kept"
- fromLen cut at the file's end (refused turn kept): "try 2: the kept
  session isn't the conversation before the refused turn"

Not tried: a real account hitting its real 5-hour limit; Claude's
"resets 9pm" text is still not parsed by resetsAt (the rate_limit_event's
resetsAt covers it). The full suite runs after the push.
2026-11-13 16:36:09 +08:00
yetone 9572a2b4cc LESSONS: three more core budget raises on 11-13, eight in all
6bc0d1e20 +180, 5a2d0ff47 +81 and 287a1ffa2 +225, which put back the
Hermes profiles section 1d60b165c had moved out while the Agents rows
still drew it. +2,631 bytes on the day; #2710 still has no growth rate.

Docs only; nothing run.
2026-11-13 16:31:39 +08:00
yetone a95a7a1cd8 providers: each API key can bill at a price rate of its own (tnt12231 on X)
A relay sells keys in groups that bill at different rates against the
official price (0.5x on one, 1.2x on another) under one endpoint, and
magpie had only the provider's price rate. Now a key can have its own:

- provider.KeyPriceRates, keyed by key id like KeySpendCaps: cloned,
  normalized on save, carried when a key is replaced. A key without one
  bills at the provider's PriceRate. A price the user set for a model
  stands as set, as it does under the provider's rate.
- Usage prices each call at its key's rate (usage.Pricer memoizes per
  key id, BaseKeyPriceIn), so the Usage page, a key's spend cap and its
  typed balance follow it. PriceAt, used to route by price, takes the
  rate of the key the provider holds.
- GUI: the provider editor's Advanced has "Price rate per key" under
  Price rate, shown only with two or more keys, folded past 8 keys like
  the per-key proxies. An empty line shows the provider's rate as its
  placeholder. Save sends keyPriceRates ({} clears, left out keeps).
  The lines, the check and the placeholder live in keyrates.js,
  imported when a provider with two or more keys opens. The core's
  budget goes up 397 for what is left in app.js (the import, the
  draft's copy, Advanced opening for it, the save's line, proxyLines
  drawing another kind of line); app.js stays under its own.
- CLI: magpie provider key-rate <id> [key [rate|default]].
- docs/subsystems/providers-accounts.md: a Key price rates row.

Run, at this head (rebased on 287a1ffa2) through mote-run:
- go test ./internal/usage ./internal/cli ./internal/gui: ok.
  ./internal/provider: ok but TestHostBuildsNoList, red the same on
  origin/main 51b98b1a8 (3 of 3), filed as #6479 (likely 16b8c300f).
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build: ok.
- GUI: key-price-rate.test.cjs (chromium and webkit x en, zh, zh-TW,
  ja, de: own rates saved, provider rate as placeholder, bad values
  refused, comma decimals, {} on clear, a folded key keeps its rate,
  one key shows no lines and posts none), i18n-keys and
  provider-many-keys-proxy (it shares proxyLines): ok. old-webkit:
  keyrates.js added to its on-demand list; its two reds (compat.js
  first, Safari 15.0 styles) fail the same on origin/main 51b98b1a8
  (#5919 and the on-demand list's #6467 family).
- Earlier, at 92bce5c72: the GUI files that reach the provider editor
  (134 tests). The 6 provider-many-keys reds fail the same on that base
  (#6209); proxy-login-fields' chromium zh timeout passes 12/12 alone on
  base and branch (#6374).

Broken by hand: atKeyRate leaving PriceRate as the provider's made
TestKeyPriceRatePrices and TestPricerKeyPriceRates red; the save not
sending keyPriceRates made 20 of 30 key-price-rate GUI tests red, and
keyrates.js dropping each parsed rate made them red again after the
move.

Not tried: a real relay with several keys at different rates; the real
Linux WebKitGTK app. The budget estimate and the Sessions page's costs
still use the provider's rate.
2026-11-13 16:31:24 +08:00
yetone 287a1ffa26 gui: Hermes's other profiles are picked on the one Hermes row again (Norethcy on X)
Norethcy on X, v0.1.4022: "Hermes 其他 profile 的配置消失了,只有默认的
Hermes Agent". 1d60b165c (v0.1.3743) took the connected row's Other profiles
lines out because each profile had a row of its own (hermes#<name>, from
7050da0a4, Norethcy). c96f33d65 (v0.1.3912, geekbb on X) then took those rows
out of the Agents list (Agent.Nested) to keep Hermes one entry, but left the
section out, so from v0.1.3912 a profile's model could be picked nowhere and
the profiles looked gone. The profile:<name> fields were in /api/state all
along (hermesProfileFields, TestHermesProfileModels), the Library still gives
each profile its skills and MCP servers (hermes#<name> through agent.All),
and nothing in any profile's config.yaml was touched.

The opened Hermes row has its Other profiles section again: one line per
profile, its name (a Chinese one as its name), its model picker (the app's
model picker, Default noted as putting back what it had before magpie) and
`hermes -p <id>`. Hermes stays one row, as geekbb asked. The picker note's
hermes# branch is gone: no hermes# row is drawn since c96f33d65.
The "Other profiles" key is back in zh, zh-TW, ja and de.
docs/subsystems/agent-wiring.md says so.

Core script budget +225 (TestCoreScriptBudget): the section was in the core
before 1d60b165c took it out; the Agents rows draw it, so there is no lazy
page to move it to, and it is packed to the shortest form.

Run on mote (the GUI files at the tree before the rebase onto
origin/main 51b98b1a8; at the pushed head again where named):
- hermes-profiles.test.cjs (restored from before 1d60b165c, plus a profile
  named in Chinese whose hint is its id): chromium + webkit, en/zh/zh-TW/ja/
  de, 1100 and 560px, 20 of 20 green.
- Broken by hand: origin/main's app.js with this test: 20 of 20 red.
- go test ./internal/gui at the pushed head: ok (TestCoreScriptBudget was
  red before the pack and the raise). hermes-profiles, hermes-profile-row
  and i18n-keys at the pushed head: green. go test ./internal/agent -run Hermes: ok.
- GUI files hermes-*, agent-*, i18n-*, click-scroll in both engines
  (64 files, 1082 cases): 1027 pass, 55 red, all in agent-details-ready
  (#6373, #6369), agent-switch-accounts (#5925) and agent-menu-label
  (#6371); the same 55 are red on origin/main 51b98b1a8 run alone.
Not tried: a real Hermes install with several profiles in the real app;
Linux WebKitGTK; Windows. No Go code changed outside the budget constant.
2026-11-13 16:22:51 +08:00