Commit Graph
8164 Commits
Author SHA1 Message Date
yetone d6cb404754 gateway: the live reasoning fixture allows the time its first event really took
TestLiveVisibleReasoningFixture set start to now minus the event's at_ms
and then called see, which reads the clock again. Any time between the
two lands in the measured start, so on macOS CI (run 43530452364,
e730a14dc) it read 6790 where the fixture says 6789. The test now
records the time before setting start, and accepts the fixture's at_ms
up to the milliseconds that really passed during the first see.

Run on mica, at this change on f1f34d624:
- The test -count=20: ok. go vet -tags nogui ./internal/gateway: ok.
  -run 'Reasoning|TTFT|FirstToken' ./internal/gateway: ok. gofmt clean.
- Broken by hand:
  - The old test with a 3ms sleep before see: red, 6792/6789. The new
    one with the same sleep: ok.
  - ttft.go setting reasoning on every event, so the first is lost:
    the new test is red (0/6789).
- Not run: the whole gateway package or the full suite; this changes one
  test's bound only.
2026-11-14 10:18:03 +08:00
yetone 14f0046e7d agent: Pi's offered thinking levels are kept per stamp, as the model lists are
v0.1.4108 kept the drift poll's "is this value magpie's" answers. After it,
real accounts on mote (acgui6, w75, the window open) showed the poll's
cost had moved into Pi's Values: piOffered on every Drift, every 15s.
Each call walked the agent's model list and built the model's whole
models.json entry, which reads settings again under GroupHasNative. That
was 23 MB of the window's three minutes.

piOffered is now kept per agent and model in a stampedLists, as
sharedModels is: built again when provider.StampNow moves, or a minute
after it was. Its callers (Pi-like Values, their effort options, Aside)
only read it.

Run: TestPiOfferedKeptPerStamp (new), TestThinkingWithoutLevels* and the
Pi tests on mica. Broken by hand (the kept entry dropped on every call):
red, "built again while nothing changed".

Suite on mica at this commit: gofmt clean; go vet internal/agent for
darwin, linux and windows; go test ./internal/agent ok (281.1s).
2026-11-14 10:09:47 +08:00
yetone f1f34d624f gui: a model's key tag is drawn from keyrates.js, back under the core budget
92e760f3d put keysTag in app.js and took the core's scripts to 1,269,382
bytes of code, 421 over coreScriptBudget (1,268,961), so
TestCoreScriptBudget was red on main from it. The full suite at that
head on mica found it; the targeted run before the push did not include
the budget test.

The server sends a model's keys only for a provider with two or more keys
on, which is when keyrates.js is loaded already. keysTag moves there,
unchanged, and renderModels imports the file for a chip that has keys,
appending the tag when it arrives. The core is 1,268,954 now, 7 under,
with no raise.

Run (mica, at this tree on 8ce32d700):
- go test -tags nogui -run 'TestCoreScriptBudget|TestAppScriptBudget|
  TestModelSaysItsKeys|TestModelKeysCapped' ./internal/gui: ok
- GUI model-key-tag, model-same-name-tell, i18n-keys, key-price-rate,
  provider-price-rate, old-webkit (both engines, every language, 420px):
  74 of 76; the two reds are old-webkit's headerpresets.js list (#6030)
  and app.css :has() (#5919), both on main before this.
- gofmt -l: clean.

Not tried: the real app with a relay that lists models per key.
2026-11-14 10:07:21 +08:00
yetone 8ce32d7008 agent: the window's drift poll remembers which values are magpie's per stamp
/api/drift runs every agent's Drift every 15s while the window is up.
Each Drift asked every field's whole option list whether a value is one
of magpie's, and the model lists under them are built again once a
minute. With real accounts on mote (acgui6, w74), that was 27 MB of the
50 MB magpie allocated in three minutes with the window open.

DriftShown, which only /api/drift calls, keeps magpieValueIn's answer per
agent, field, value and settings while provider.StampNow stays the same,
5 minutes at most. Drift is unchanged for Reapply, rewiring, a launch and
/api/state, which act on the answer.

A provider resting or a model retired by its date is something the stamp
can't see. The window's drift row now shows that within 5 minutes, not 1.

Run: TestDriftShownAsksAValueOncePerStamp and the Drift tests on mica.
Broken by hand (the memo never hit): red, "five polls built the options
5 times, want 1".

Suite on mica at 6c88d61f0 + this commit: gofmt clean; go vet
internal/agent for darwin, linux and windows, internal/gui on darwin; go
test ./internal/agent ok (194.9s); ./internal/gui red only in
TestCoreScriptBudget (1269382 > 1268961). That test is red on
origin/main 6c88d61f0 as well, and #6518 is taken. This change adds no
script.
2026-11-14 09:58:49 +08:00
yetone ed63a5be5e gui: a picked accent colours what is chosen (CHENGJIAHEGOXIS on X)
「选中任意强调色没反应」: picking an accent in Settings › General seemed
to do nothing. The token did apply. With the real server, in Chromium
and WebKit, under light, dark and system, with and without a background
image, --accent was set by lookCSS and kept. Neither the theme nor the
wallpaper overrode it. But nothing on Settings, the sidebar, the header
tabs or the panel's tabs used --accent: every chosen option is graphite,
var(--fg), by design. So the colour only showed in a few buttons
elsewhere.

The fix is a --mark token, the ink of what is chosen.
- It is var(--fg) by default, so magpie's own look is unchanged, like a
  Mac's Graphite.
- accentVars sets it once the user picks an accent. It is moved toward
  black (light) or white (dark) until it reads at 4.5:1 on the surfaces a
  chosen option sits on: --pill-hover #e9e9ee, and the dark switch thumb
  #4c4c52.
- It is used by .seg/.opt/.ptabs/.warm-tabs/.am-seg/.klf-tab/.day-chip/
  .apptab .on, the header nav's chosen tab, the side-nav's open-page icon
  and Settings icon, and Library's switches and radios. Each is the same
  "chosen" role, so all of them follow the accent, not just one.

Tests:
- appearance_test.go's TestAccentReadable checks --mark's contrast on
  each surface, in both themes.
- appearance-look.test.cjs adds 8 tests, in Chromium and WebKit, light
  and dark:
  - Settings' theme and bird options and the side-nav icon at 1200 with a
    wallpaper set: graphite by default, the mark for #0d9488 and #db2777,
    and back to graphite on Default.
  - The header tabs at 900 and the panel's tabs at 380.

Run:
- gofmt clean. go vet ok on darwin, GOOS=linux -tags nogui and
  GOOS=windows (at 75bdc85fe, the same change on an older main).
- At 6f5549b1f (this change on 08f77528f), on Linux (WSL magpie-desktop),
  since mote's suite queue was hours deep:
  - The whole GUI suite, Chromium and WebKit, every language and the
    panel widths: 27231 tests, 1258 red in 183 files. The same 183 files
    at the parent were 1226 red. The 70 tests red only with the change
    were rerun with their 43 files at concurrency 2: 80 red with it, 89
    at the parent 783b69b8c. Every one left has a language or width
    sibling red at the parent too. None is about colour. They are the
    Linux reds #5559 and #4388 track.
  - go test -tags nogui ./... -timeout 45m: every package ok except
    internal/usage's TestRequestStateKeptAcrossACatalogFetchedAgain,
    red the same at the parent (#6572).
- At the pushed head, on mote (macOS):
  - TestAccent*, TestWallpaper*, TestLook* ok.
  - appearance-look 36/36, i18n-keys 4/4, library-all 26/26.
  - segs-press-redraw 16 red and api-key-theme 6/6 red, the same counts
    at the parent 6c88d61f0 (#4566, #3922, #6444).
  - TestCoreScriptBudget is red (1269382 > 1268961), the same at the
    parent. 92e760f3d took it over (#6518, taken). This change adds no
    script.
- Broken by hand:
  - With the old app.css and library.css, the 8 new GUI tests are red,
    8 of 8.
  - accentVars without --mark: TestAccentReadable fails ("…;--sel:#efefef",
    no mark).

Not tried:
- The whole GUI suite and the Go suite on macOS at the pushed head. mote's
  suite.lock queue was hours deep, so they ran on Linux instead.
- The real macOS app.
- Windows WebView2, and Linux WebKitGTK.
- Charts' --c1 series colour still does not follow the accent; that is
  left as it was.
2026-11-14 09:58:38 +08:00
yetone 6c88d61f0d mobile-web: drop the Claude Code mode row exemption 98cff4b0d left stale
98cff4b0d made Claude Code's mode one row in the Claude Code editor and
took #claudeTuiRow out of app.js. mobile-web still removed that row from
Settings whenever BASE_REF's app.js lacked it, which is now always, and
waited 5s for a row no page has: every "desktop matches" case (en, zh,
900 and 1280) was red on main from 98cff4b0d on.

Run on mica at this head, with BASE_REF an origin/main 783b69b8c copy of
the assets: mobile-web passes; before this, its four desktop cases timed
out on locator('#claudeTuiRow').
2026-11-14 09:31:24 +08:00
yetone 2c0d203156 i18n: zh drops the "Also sync" that 459d668b3 left behind
459d668b3 (#6428) took the Sync form's "Also sync" field out, with its
zh-TW, ja and de words, but kept zh's. Every language must have each zh
string, so gui-de, gui-ja and gui-zh-tw's "has every zh string" went red
on main ("missing in de: Also sync"). Nothing says the words any more
(git grep finds only zh's line), so zh's goes too.

Run on mica: gui-de, gui-ja, gui-zh-tw and i18n-keys (with the other
two commits) pass; at origin/main 783b69b8c the three gui-* were red.
2026-11-14 09:31:24 +08:00
yetone 57dc64ba12 usage: the Overview's lists rank by tokens, cost, calls or name (onducoder on X)
onducoder asked for a ranking of Usage › Overview's Agents, Models,
Gateway keys and Accounts by what each used. Each list's heading now
ends in a quiet pick (the order's name and a chevron) that opens the app
menu: Tokens (the default, the server's order), Cost, Calls or Name.
By tokens the list stays in the server's order (most tokens first,
the cache left out) unless "with cache" is on, when the cache counts
too; other orders fall back to tokens, then calls. By cost, a row
with no price goes last; by name, a row with no name goes last. Each
list keeps its own order in localStorage (magpie.usageSort), and a
folded list hides its pick. The code is in the
Usage plugin (page.js, its i18n.js); "Calls" is a core word, since other
files say it. The core script doesn't grow (TestCoreScriptBudget passes).

gateway-caller-keys and usage-accounts read the heading's .label, since
the heading's text now includes the pick; mobile-web takes the picks out
until BASE_REF has them.

Run: usage-sort.test.cjs (new; chromium and webkit, en zh zh-TW ja de,
1100 and 420 wide). On mica, with the next two commits, these files at
this head and at origin/main 783b69b8c: gui-de gui-ja gui-zh-tw i18n-keys
mobile-web phone-no-sideways usage-agents-hide usage-cards-hide
usage-count-client usage-fold usage-hidden-way-back usage-hit-rate
usage-ledger usage-range-times usage-speed-all-models, plus usage-sort,
gateway-caller-keys, usage-accounts and usage-overview-fold at this head
(333 tests). Red at both, and filed: phone-no-sideways (#5869),
usage-agents-hide (#3414), usage-cards-hide (#6294), usage-fold
(#3415), usage-hidden-way-back (#6295), usage-ledger (#5048),
usage-range-times (#6499), usage-speed-all-models (#5834). Everything
else passes. A first version re-sorted the server's list on the default
order too, which moved rows in usage-hit-rate and usage-count-client's
fixtures; the default keeps the server's order now, and both pass.
usage-*, panel-usage*, phone-* and gui-* ran on mote earlier;
TestCoreScriptBudget ok on mote at 783b69b8c. Rebased on 92e760f3d:
gui-de gui-ja gui-zh-tw i18n-keys mobile-web usage-sort
usage-overview-fold gateway-caller-keys usage-accounts usage-hit-rate
usage-count-client model-key-tag library-subagents-import, 187/187 on
mica; TestCoreScriptBudget is red there on main's own app.js (#6518,
1269382 > 1268961), the same without this change, which adds nothing to
the core.
Broken by hand: against origin/main's assets usage-sort is red (22
cases); with usageSorted returning the list unchanged, 11/11 order cases
fail.
Not tried: the real app, Linux WebKitGTK. The full GUI suite run on
mote was stopped part-way (its copy was replaced by a second run of
mine); its reds outside these files are main's (e.g. #6543, #5869).
2026-11-14 09:31:24 +08:00
yetone 2a75aafc16 provider: Antigravity's mover min is 0.1.11, which says omp's RFC 2119 line as "key words" (eric_li8983 on X)
magpie-community/plugins 4170d0e8 published antigravity 0.1.11 (dist
branch has magpie-community-opencode-antigravity-auth-0.1.11.tgz; the
package isn't on npm, as every earlier version). keepMovedCurrent brings
every moved Antigravity user's plugin up to it.

Run: go test -tags nogui ./internal/provider on WSL magpie-desktop: ok
2026-11-14 09:25:46 +08:00
yetone 0b64846bf7 gateway: Antigravity's cloak says omp's RFC 2119 line as "key words", and finds every turned-away line in any white space
eric_li8983 (X, 11-14): oh-my-pi (omp) on Windows with an Antigravity
account got "Antigravity answered 429 to this system prompt" for omp's
first line, "RFC 2119 keywords: MUST, REQUIRED, SHOULD, RECOMMENDED, MAY,
OPTIONAL." (omp 18.20.0's system-prompt.md, advisor/system.md and
live-instructions.md all start with it, byte for byte).

The built-in Antigravity path didn't know the line at all, and matched
the other turned-away lines only with single spaces. On a real account
on 11-14, Google's check turned omp's line away wrapped with LF or CRLF,
indented, with a tab, two spaces or a no-break space, so a literal match
misses copies that are refused. Now:

- agTurnedAway has omp's line, and each line is matched in any case with
  any run of white space between its words (agLineRe, agSpace: JavaScript's
  \s, as the plugin matches), Codex's and Hermes' lines too.
- omp's line goes as "RFC 2119 key words: …" (RFC 2119's own term), its
  white space as it was, rather than broken up by zero-width spaces: a
  broken-up copy was still refused 1 to 3 times in 10 (U+200B, U+2060 or
  a soft hyphen alike), "key words" 0 in 30 (plugin numbers below).
- A refusal of it gets its own hint (antigravityRFCHint, word for word the
  plugin's RFC_HINT), shown on the Routing page (AG_RFC) in en, zh, zh-TW,
  ja and de.

The plugin half is magpie-community/plugins 4170d0e8 (antigravity 0.1.11,
agy-cli 0.1.40, antigravity-cloak 0.1.6); the next commit raises the
mover min to it.

Real account (sandbox HOME, copy of the live Antigravity account,
gemini-3.8-flash, sequential, through the plugin's same rewrite): omp's
literal prompt 10/10, the full template 10/10, the line wrapped after
"REQUIRED," 10/10. Zero-width before it: 3, 1 and 5 bare 429s in 12 each.

Run at this tree (rebased on eb1b83000), on WSL magpie-desktop (mote's
suite lock was held by another session's full run, mica's disk is full):
go test -tags nogui -count=1 -timeout 45m ./...: 98 packages ok, one red,
internal/usage TestRequestStateKeptAcrossACatalogFetchedAgain ("a catalog
that changed kept the price key"), red 3 of 3 alone on Linux: that is
#6572 (catalog CacheKey and a same-mtime write), not this change.
gofmt -l clean; GOOS=windows go vet ./internal/gateway ./internal/gui on
xiaomi-gpu, exit 0; go vet ./... on Linux, with -tags nogui, exit 0 (without it the GUI package needs
webkitgtk, which the distro lacks).
GUI: routing-ag-turned-away (now 3 agents x 5 languages, chromium and
webkit) and i18n-keys, i18n-en-no-cjk: 38 pass, 0 fail.
Broken by hand: TestAntigravityCloakOmpLine and
TestAntigravityCloakLineWrappedOrWidened against origin/main's
codeassist.go: both red (line went whole, 9 copies not taken for turned
away, hint wrong).

Not tried: omp itself end to end on Windows; the gateway's built-in path
against the real account (the plugin's identical rewrite was). Seen in
the same probe: Claude Code's, Codex's and Hermes' broken-up lines were
each refused 1-2 times in 10 (magpie-community/plugins#1118).
2026-11-14 09:25:46 +08:00
yetone 92e760f3d1 providers: a model says which keys list it when not all of them do (cliddO11 on X)
cliddO11 on X asked for a tag or colour on the provider editor that shows
which key each model came from when several keys fetch models. fetchPerKey
already marks each merged model with the keys whose list has it
(catalog.Model.Keys), but the editor never received that. providerInfo now
sends it as modelJSON.keys: the ids of the keys in use that list the model,
in the keys' order. The field is left out when every key in use lists the
model, when only an off key does, or when the list was not asked per key.
At most six ids are sent, with keyCount when there are more, so a provider
with a thousand keys does not send a thousand ids with every model.

On the chip, after the name, a grey tag in the 1M tag's look (never the
accent, no stripe) shows one key's name (or its masked value, as its row
shows it), two names, or "3 keys". The tooltip lists the keys. One new
string, "Listed by {keys} only", in zh, zh-TW, ja and de.

Run (on mote, at this tree):
- go test -tags nogui -run 'TestModelSaysItsKeys|TestModelKeysCapped'
  ./internal/gui: ok. Broken by hand (every model tagged, keysApart not
  dropping "all keys"): both red.
- node --test model-key-tag, model-same-name-tell, i18n-keys: 32/32 ok
  (Chromium + WebKit, en zh zh-TW ja de at 1100px, en zh at 420px). With
  the tag call removed from app.js: webkit 0/7.
- GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gui: ok.
- gofmt -l: clean.
- Full go + GUI suite queued behind ~/suite.lock on mote; its result is
  posted on the follow-up.
Not tried: a real relay that gives each key its own models; the tag reads
catalog.Model.Keys, which fetchPerKey has filled since #904.
2026-11-14 09:11:46 +08:00
yetone 4e770f733a library: subagents imported from a repository
CHENGJIAHEGOXIS on X asked for an easy way to install a repository of
subagents such as msitarzewski/agency-agents. Library → Subagents now
has a find line. It takes what the skill installer takes: owner/repo, a
GitHub or GitLab link to a repository, folder or file, any git address,
or a folder on this computer. It lists the subagents found, lets the
user tick all or some, and imports them as Library subagents for the
agents ticked.

- Fetching is the skill importer's: resolvePluginRoot's source handling
  moved into fetchSourceRoot, which both use. tooBig still refuses a
  whole repository that is too big and asks for the folder's link.
- A subagent is a Markdown file whose front matter has a description.
  - Its name is the slug of `name`. In an `agents` or `droids` folder
    with no `name`, it is the file's own name.
  - The description is folded to one line of at most 1000 characters.
  - The body is the prompt.
- Dropped: every other front-matter key (agency-agents' color, emoji
  and vibe, and tools, model, author or anything else). A Codex TOML
  role is not read. A skill's folder (one with SKILL.md) and .git,
  .github and node_modules are skipped.
- Two files with one name: the shallower is taken, and the other is
  listed as left out, with why. So is a file Subagent.check refuses.
- An imported subagent records its source and file (From) and a hash
  of its description and prompt as imported (FromHash). Imported again,
  a subagent from the same file is:
  - have, when it is unchanged;
  - update, when upstream changed and the library's copy still matches
    FromHash (description and prompt replaced; agents, skills, servers
    and model kept);
  - edited, when the user changed it in magpie (left as it is).
- A name the library already uses for another subagent is never written
  over: the import takes the next free name-N.
- A carried library carries From.
- The page has Select all, a filter past eight, a tag per state, the
  files left out, and a summary of what was imported and updated.
  i18n: zh, zh-TW, ja, de.
- The fixture is agency-agents' own files in
  internal/library/testdata/agency-agents. No test reaches the network.

Run on 80ae5ba24, which is this change on e730a14dc:
- gofmt -l is clean. GOOS=linux and GOOS=windows go vet -tags nogui
  ./... are clean (mote).
- go test -tags nogui -count=1 -timeout 45m ./... on mica: 98 packages
  ok. internal/cli's TestEveryRouteHasACommandOrIsNamed was red because
  the new POST /api/library/subagents/probe wasn't named. It is now in
  notYet beside skills/probe and plugins/probe, and the test passes.
- GUI files run in chromium and webkit, in every language:
  - The new library-subagents-import.test.cjs and the doc's Library
    list: 117 of 118 passed. The red was i18n-keys: "{n} subagents" is
    the sessions plugin's key. The keys now use {count}.
  - A second run of the doc's Library list, i18n*, project-subagents,
    skill-install-* and plugin-*: 1652 of 1768 passed. The 116 reds are
    in 7 files that fail the same way alone on a fresh origin/main
    (e730a14dc): 116 there, 114 at this head. Each has an open issue:
    - found-skill-pick-remove: #4097 and #5013
    - plugin-option-placement: #6559
    - plugin-signin-no-url: #5938
    - plugin-signed-out-account: #5998
    - plugin-move-unserved: #4392 and #4410
    - plugin-page-foreign-error: #6117
    - plugin-card-update: #3079

Run at the pushed head, rebased on eb1b83000, on mica:
- gofmt -l is clean.
- go test ./internal/library ./internal/gui ./internal/cli: ok.
- library-subagents-import, library-subagents and i18n-keys: 38 of 38
  passed.

Broken by hand, each red, then reverted:
- Clash renaming off (`false && taken[name]`):
  TestSubagentImportLeavesTheUsersOwn red.
- The edited check made `case true:`: TestSubagentImportAgainUpdates
  red (paid-media-auditor read as update).

Real import, in a sandbox HOME magpie web on mote (built from this
change), with Claude Code and
Codex detected:
- The probe of https://github.com/msitarzewski/agency-agents found 283
  subagents. One was left out: the mcp-memory copy of
  backend-architect.
- Importing all 283 wrote 283 files to ~/.claude/agents (only name and
  description in the front matter) and 283 TOML roles to ~/.codex/agents.
- A probe of .../tree/main/engineering then showed 66, all have.

Not tried: the Windows and Linux runtime, GitLab and plain git sources
against real repositories, an agent in WSL, a repository over tooBig's
limit.
2026-11-14 09:11:31 +08:00
yetone eb1b830004 gateway: Cindy is told each model by its name with its provider's (cdredfox on X)
Cindy's picker listed magpie's GLM-5.3-Flash three times, 千问 3.8-Flash
and DeepSeek-Flash twice each, with nothing to tell them apart. Cindy
0.1.94's model discovery (parseModelsListResponse in its app bundle)
names a row by display_name before name, and magpie's display_name is
the bare model name. /v1/models asked with Cindy's key (magpie-cindy, as
its import link gives it) now gives display_name the name the agents'
lists use, provider.LabelsFor("cindy", ...): "GLM-5.3-Flash · Zhipu",
"... · routing group" for auto/, following Cindy's Provider in model
names (the picker the Agents page already showed for Cindy, which
changed nothing there before), a name the user gave a model kept as
they wrote it. Every other client's display_name is unchanged. In Cindy
a discovered model's shown name follows discoveredMetadata.name, which
its 刷新模型列表 updates for existing models; a name the user typed in
Cindy (nameExplicit) still wins there.

Run:
- TestCindyDiscoveryNamesModelsApart (new): on, own and off, three
  providers' GLM-5.3-Flash apart, a user's own name kept, another client
  plain. Red on the old gateway.go ("on: Cindy told
  map[... or/glm-5.3-flash:GLM-5.3-Flash zp/glm-5.3-flash:GLM-5.3-Flash]").
- Real use: this tree's magpie built and served in a sandbox HOME on
  mica with two custom providers serving glm-5.3-flash; its /v1/models
  with magpie-cindy fed to Cindy 0.1.94's own parseModelsListResponse
  (extracted from /Applications/Cindy.app's app.asar): "GLM-5.3-Flash ·
  OpenRouterX", "GLM-5.3-Flash · ZhipuX", "GLM-5.3-Flash · routing
  group"; with magpie-pi's key all three still "GLM-5.3-Flash".
- Full suite on mica at base e730a14dc (go test -count=1 -timeout 45m ./...): 99 packages ok, no FAIL. go vet ./... (darwin), GOOS=windows go vet ./... and GOOS=linux go vet -tags nogui ./... clean; gofmt -l clean.

Not tried: Cindy's own window. Adding magpie there writes into the live
CindyGlobal folder, which has no account database on this Mac.

- After the rebase onto 9a3f95f3f's parent (two gateway commits): internal/gateway, internal/provider and internal/agent ok on mica.
2026-11-14 08:39:31 +08:00
yetone 9366957788 gateway: a resent conversation shares the bytes a kept turn holds
A client that sends its whole conversation each turn, naming no
earlier response and not sending store:false, had previousResponse copy
the whole input out of the body on every turn (ownItems, ~2 MB a
request for a 2 MB conversation) and keep each copy for prevTTL, so the
store held the same history once per turn, up to prevCap (256 MB) for
six hours.

Now the leading items one of the four newest kept turns of the same
scope holds the same bytes of are shared with that turn, and only the
rest is copied. A turn keeps its items as chunks (prevChunk), each
counted once in the store's size for as long as any turn holds it, so
the cap still bounds what is held, and a chunk's bytes leave the count
only when its last holder goes. A turn that names an earlier one shares
that turn's chunks the same way, where before it counted only its own.

Run (mica, at dcf6e440f): gofmt -l clean, go vet ./internal/gateway for
darwin, linux and windows, go test -count=1 -timeout 45m
./internal/gateway ok (915s). Broken by hand: counting a shared chunk
again on each holder, and sharing nothing, each turn both new tests red.
BenchmarkLargeRequest/responses: 22.0 -> 20.0 MB a request, ~23 ms
either way. Real DeepSeek (deepseek-chat), a 3-turn Responses
conversation resent whole with no store:false: 200 each turn, and the
third recalled the first turn's code word.
2026-11-14 08:34:50 +08:00
yetone f53c4a1a14 usage: three tests hold the clock, so midnight never falls between a call and Today (#6486)
TestAliasCallsAreTheGatewaysNotDirect stamped its direct call 6 minutes
before time.Now() and asked Direct(Today), so in the six minutes after
local midnight the call was yesterday's: red on mote at 00:00 PST and on
macOS CI at 00:07 UTC (run 43523008440). TestLoopsCountedPerModel and
TestRequestsCountedOnceWithTheirRetries do the same with stamps up to 9 s
back (same class). All three now take their time from holdClock at a
fixed noon, as TestPeriodsReadTheClock does.

Run (mica, at 783b69b8c + this):
- the three tests -count=3 in TZ=UTC and TZ=Asia/Shanghai: ok
  (and in UTC, Asia/Shanghai, America/Los_Angeles on mote: ok)
- broken by hand: held at 00:00:03 instead of noon, all three red
  (gateway_alias_test.go:44 "0 calls", loop_count_test.go:55,
  retried_requests_test.go:55), so they read the held clock
- go test -count=1 ./internal/usage: ok 53s; go vet ./internal/usage: ok
Not run: the full suite (test-only change in one package).
Not changed: #6474 (TestWalletCapHolds, the 5 minutes before midnight)
is another package's sibling and stays open.
2026-11-14 08:31:52 +08:00
yetone 783b69b8cf gateway: a Chat request's call ids and messages are read without copying them
Every Chat attempt ran chatCallIDs, which decoded the whole body into
maps of json.RawMessage to see whether a call lacked an id: each level
(the body, its messages, each message) was copied, ~3.8 MB a request
for a 2 MB conversation, and silentAssistantsOut copied the body once
more. editMessages and silentAssistantsOut now decode with
decodeJSONView, sharing the body's bytes: an edit replaces a member,
never writes into one, keeps none past its return, and a changed body
is marshalled anew. chatCallIDs first scans the raw body (callIDsSet):
when every call has a non-empty string id there is nothing to give, as
a tool message is only given the id of a call that had none.

BenchmarkLargeRequest/chat (mica, 200x, count 3): 23.4 -> 21.8 ms,
23.8 -> 16.4 MB and 69.4k -> 38.1k allocs a request. Anthropic and
Responses unchanged (22.7 ms, 21.2 / 22.0 MB).

TestCallIDsSetNeverSkipsAnEdit holds callIDsSet to the decode over
20000 random conversations (escaped keys and roles, null, numeric and
empty ids, non-object calls), each answer and edits 1000+ times. Broken
by hand (every id counted as set): red; restored: green. Dropping the
tool-message check stayed green, which is why it isn't there.

Real account (mote, sandbox HOME, deepseek/deepseek-chat through
/v1/chat/completions with tools): paired call 200 "It's 18°C and sunny
in Paris."; unpaired 200; empty call and tool_call_id 200 "It's 18°C
and sunny in Paris right now." (the id given).

Run (mica, at fcb88a13c; rebased since onto main, which changed only
internal/update): gofmt -l clean, go vet ./internal/gateway for
darwin, linux and windows, go test -count=1 -timeout 45m
./internal/gateway ok (949s). Real DeepSeek Chat with tools (paired,
unpaired, empty call ids): 200 each.
2026-11-14 08:18:37 +08:00
yetone 830177ae53 update: a restart on Windows waits for the old magpie's WebView2 to end (vsoullai on X)
vsoullai on X (0.1.4096, Windows 10.0.26300): "自动更新 relaunch 未等待旧
WebView2 释放 EBWebView 导致新实例死锁" - after an update's restart the new
magpie hung.

Two holes, both in what the new process waits for before its WebView2
opens the same profile folder:

- AwaitPredecessor waited 20s at most for MAGPIE_REPLACES. An old magpie
  still in OnShutdown after that (Codex rollouts, agents' configs put back,
  an update installed) still holds Wails' single instance mutex, so
  webView2Ready's instanceHeld shortcut skipped the folder wait and
  application.New handed the start to the magpie quitting
  (SendMessage to its -siw window) and exited: no magpie at all.
- The old magpie gone is not its WebView2 gone: the folder's lockfile is
  let go before the browser's last msedgewebview2 processes end (seen on
  the box: lockfile free at 0.07s, two of the old one's processes ending
  at 0.10s).

Now, on Windows, AwaitPredecessor (awaitGone) opens the old magpie by pid
first (so its pid is no other's), takes every msedgewebview2.exe under it
from a Toolhelp snapshot and opens those too, then waits up to 60s for the
old magpie and up to 30s more for those processes, logging when it goes
on without them. Mac and Linux keep the 20s poll. Every restart passes
here: the update's restart and Settings' restart (RelaunchBinary), the
folder move's, and Respawn after a WebView2 failure, since all set
MAGPIE_REPLACES and every start runs AwaitPredecessor (cli startUp)
before gui.Run.

Tests (Windows):
- update TestAwaitGoneWaitsForTheOldWebView: a fake old magpie with a
  copy of the test binary named msedgewebview2.exe that outlives it by 3s.
  Red with the old 20s poll put back by hand ("went on after 402ms, while
  the old magpie's WebView2 still ran"), green with the fix (3.5s).
- gui TestRestartWaitsForTheOldWebView: real Wails windows and WebView2
  with Wails' single instance on, in the signed-in session on xiaomi-gpu
  (skips in session 0). The old app, its page loaded, starts the new one
  detached with MAGPIE_REPLACES and quits; the new one starts as Run does
  and must load its own page. slow (OnShutdown 25s) is red on the old
  code: the new one went on at 20.09s, handed over and never came up.
  Green with the fix: quick 1.3s, slow 27.4s, page loaded both times.

Run at this head (6faac2636 rebased on origin/main e730a14dc):
- xiaomi-gpu (win-run): both tests above green; earlier, at a8fa771a6
  plus this change, go test ./internal/update ./internal/gui in full: 10
  reds, the same 10 on fresh origin/main e730a14dc with no change, all
  filed (#6068, #4603): TestPackagedByDpkg, TestGatewayHeldByAContainer,
  TestLodyImportHandoff, TestImportStatusUnreadableIsUnknown,
  TestAionUiImportRow, TestCherryStudioImportRow,
  TestProviderSaveClientCert, TestPluginAgentMissingSaysSo,
  TestGatewayModeStatsNameTheGatewaySessions, TestUpdateThatWontStart.
- mote: go test ./internal/update ./internal/cli ok; gofmt -l clean;
  GOOS=windows go vet ./... and GOOS=linux go vet -tags nogui ./... clean.

Not run: the full go test ./... - mote's suite lock had a ~3h GUI+go run
and a 120m e2e queued ahead; the change touches Windows-only code plus
one call in AwaitPredecessor, whose non-Windows body is the old loop
moved as is. Not tried: a real update of a built magpie.exe in a sandbox
(the restart is played with real windows in the test instead), and an
old magpie that never quits within 60s (the start goes on as before).
2026-11-14 08:12:09 +08:00
yetone e730a14dc7 gateway: a Chat request's tool pairs are checked without decoding it
toolPairsOut decoded every Chat request that mentions a tool into
[]map[string]any to learn whether its calls are answered, which they
nearly always are: 0.79s of 5.1s in BenchmarkLargeRequest/chat, ~10 MB
of allocations a 2 MB request. rawToolsPaired reads the roles, the
tool_call_id and the calls' ids from the body as it came, and the
decoding path runs only when they aren't paired, or for a shape it
would read differently (a message that isn't an object, tool_calls
that aren't a list of objects). A key named twice counts as its last,
as decoding into a map does.

BenchmarkLargeRequest/chat on mica, 200x: 28.1 -> 23.4 ms, 33.7 ->
23.8 MB and 94.5k -> 69.4k allocations a request; the other protocols
are unchanged.

TestRawToolsPairedAsDecoded holds it to the decoding path's answer on
20000 random conversations (answered twice, out of order, left open,
ids repeated, missing or not strings, escaped roles, null messages).
Broken by hand (a repeated id no longer refuses the pairing) it is red;
restored, green.

Real account: the built app (mote, sandbox HOME) sent DeepSeek a 6KB
/v1/chat/completions request with tools and a call answered ("It's
18°C and sunny in Paris.", 200), and one with the call left unanswered,
which the decoding path still mends (200, "the request was
interrupted").

Run (mica, at this head): gofmt -l clean, go vet ./internal/gateway for
darwin, linux and windows, go test -count=1 ./internal/gateway ok (858s).
2026-11-14 07:53:44 +08:00
yetone a8fa771a63 gateway: the rest of the body checks look for the rarest byte too
63c91cae5 moved the request path's key checks with a literal needle to
bodyHas. A profile of BenchmarkLargeRequest at that head still had
bytes.Contains at ~14% of the gateway's CPU: the checks whose needle is
kept as a []byte (openaiOnly in forVendor alone took 0.49s of 6.8s,
cacheControlField, thinkingType, toolUseType, the Gemini signature
fields, contentParts), and those built as []byte(`"`+f+`"`). They go
through bodyHasBytes/bodyHas now, and the stream's bytes.Index loops
(turndone, refusal_handover, routing) through bodyIndexBytes; a line
under 1 KB takes strings.Index as before.

grokToolPatterns asked gjson for the model before it looked for a
"pattern" at all, so every request to every provider walked the body
to its model (0.43s of the same profile; Responses bodies carry the
model after the conversation). The pattern check now goes first; the
answer is the same, since both had to hold.

anthropic_shapes copied a tool_result's raw content into a []byte to
look in it; it uses strings.Contains on the string.

BenchmarkLargeRequest on mica, 200x, before -> after:
  anthropic        23.0 -> 21.9 ms
  anthropic-group  24.2 -> 22.9 ms
  chat             29.0 -> 28.4 ms
  responses        26.8 -> 22.8 ms

Run (mica, at this head): gofmt -l clean, go vet ./internal/gateway for
darwin, linux and windows, the benchmark above, go test -count=1 ./internal/gateway ok (860s). bodyIndex is held to
bytes.Index by TestBodyIndexIsIndex (63c91cae5).
Real account: the built app (mote, sandbox HOME) sent a 6KB request to
DeepSeek on /v1/responses and /v1/messages, both 200 "pong". Not tried:
Codex and Grok (the sandbox's Codex sign-in is stale; renewing it there
would rotate the live refresh token).
2026-11-14 06:54:01 +08:00
yetone 63c91cae5f gateway: the body's key checks look for the needle's rarest byte
Each request ran ~45 bytes.Contains over its whole body to ask whether
a key is there at all ("developer", "compaction, "display", the
passthrough key...). Most needles begin with a quote, JSON's commonest
byte, so bytes.Index stopped at every quote, gave up on that and
compared at every byte: on a 2 MB body ~9 ms a request, 36% of the
gateway's CPU in BenchmarkLargeRequest's profile.

bodyHas/bodyIndex find the needle's rarest byte (a static rank of the
bytes JSON, English and code use most) with IndexByte and compare the
needle only there; a needle of common bytes only hands the rest to
strings.Index after 64 misses, so it is never slower than before, and
it allocates nothing (a []byte(sep) of a needle over 32 bytes did).
148 literal and constant needles in internal/gateway use it, and
mayHoldHEIC's "eXB" walk uses bodyIndex.

mayHoldOddBase64 walked every byte through a switch (~2 ms a 2 MB
body); a run it looks for ends a string, so it now looks back from each
quote with a class table and gives the same answer.

Run on mica (Apple M6) at this tree:
- BenchmarkBodyHas, 7 needles over a 2 MB body: 4.43 ms -> 0.38 ms,
  0 allocs (was 1).
- BenchmarkLargeRequest -benchtime 200x, before -> after:
  anthropic 31.2 -> 28.9 ms, anthropic-group 31.4 -> 27.8,
  chat 35.7 -> 32.8, responses 39.8 -> 29.8.
- go vet ./internal/gateway; gofmt -l clean.
- go test ./internal/gateway -count 1 -timeout 45m: ok (858s).
- Broken by hand: bodyIndex's start off by one -> TestBodyIndexIsIndex
  red (wrong index on 5 needles and the random bodies); the URL-safe
  class never counted -> TestOddBase64LooksAsItWalked red. Both green
  again restored.

TestBodyIndexIsIndex holds bodyIndex to bytes.Index on a large
conversation and 3000 random bodies of common and rare bytes;
TestOddBase64LooksAsItWalked holds the new check to the old byte walk
(kept in the test) on 20000 random bodies and the three protocols'
large conversations.

Real account: the built app (mote, sandbox HOME) sent a 6KB request to
DeepSeek on /v1/responses and /v1/messages, both 200 "pong". Not
tried: Codex (the sandbox's sign-in is stale, and renewing it there
would rotate the live refresh token).
2026-11-14 05:51:42 +08:00
yetone 08f77528f4 usage: the serials sourceDigest met go when idle
sourceDigests.by and .last, the serials met this turn and the one
before, stayed for the life of the process: 577 KB of a real history's
idle heap. They only order which digests heat-digests.bin keeps first
when there are more than it holds (2*65536, against ~17k session
files). dropDerived, the 3-minute idle drop, now writes what was made
and lets them go; sourceDigest notes a read (derivedUsed) as the other
per-chunk caches do.

TestDigestTurnsGoWhenIdle: the turn's serials are nil after the idle
drop and the next key hashes nothing again. Red with the nil-ing taken
out by hand ("kept 1 and 0 serials when idle").

Run at this commit on mote (load 23.7, over its 18 cores; mica's disk
was full): go vet for darwin, linux and windows ok; go test
./internal/usage ok (52s), ./internal/gui ok (132s). Real Codex history
in a sandbox HOME (~/r2278), page open 30s then 8.5 min idle: liveHeap
13.13 MB against 13.68 MB before; the heap diff shows sourceDigest's
577 KB gone. Not run: the full suite.
2026-11-14 04:02:26 +08:00
yetone a532b646eb usage: the set of listed session paths is not kept on the index
readRequestBlocks makes a set of every session file's path (on), and
noteBuilt kept it on the index for save, the only reader, which it calls
right after. The set outlived the chunks' forget: 853 KB of a real Codex
history (pprof inuse_space at request_page.go:1214, the make of on) at
8 minutes idle. save takes it as an argument now; the field is gone.

Run at this commit on mote (load 24): go vet for darwin, linux and
windows ok; go test ./internal/usage ok (57s), ./internal/gui ok (158s).
Real Codex history in a sandbox HOME (~/r2278), page open 30s then 8.5
min idle: liveHeap 13.68 MB, against 17.07 MB for v0.1.4089; the heap
diff shows readRequestBlocks' 853 KB gone. One earlier capture read
22.3 MB with 5.2 MB under prefetchEach/sharedBuild; a goroutine dump of
the next run had no prefetchEach goroutine left, so that was a build in
flight when the heap was taken, not a stuck reader.
Not run: the full suite.
2026-11-14 03:46:32 +08:00
yetone 39a00e6f38 gui: the panel's Usage tells all providers' calls apart by model too (OHHHHHH05 on X)
OHHHHHH05 asked on X for usage by model in the tray panel's Usage tab,
which ranked all providers' calls only by provider. The card's head now
has a Provider / Model switch beside the metric switch. Model ranks and
charts the same answer by.model and the series' by.model, with no new
request, the same drawLedRank and drawLedColumns the window's Usage
page draws. The choice is kept (magpie.panelUseSplit). With one provider
picked the ranking is already its models, so the switch is left out.
A click in the ranking still picks a provider only when it ranks
providers. The labels reuse the Provider and Model words, so no string
is new.

panel-usage-models.test.cjs (new), Chromium and WebKit, en zh zh-TW ja
de: the switch's labels, Provider on by default, Model's ranking and
chart keys, no request on the switch, both switches inside the card
at 440px and 320px with nothing sideways, the choice kept on reopening,
the switch gone with a provider picked, no page errors.
panel-usage.test.cjs: its metric selectors skip the new switch.

Run:
- panel-usage-models + panel-usage on mote: 14 pass, 0 fail.
- Broken by hand: the old app.js is red 10 of 10 in Chromium (no
  switch); the split forced to provider is red 10 of 10 in WebKit (the
  ranking keeps providers).
- WSL magpie-desktop (Linux): the 116 GUI files that reach the panel or
  the usage answer (.pu-, panelUse, usage/requests, panel-*, tray-*,
  i18n-*): 1712 pass, 93 fail, panel-usage and panel-usage-models
  green. The 17 red files run again at origin/main ab4b1cf38 and at
  this change: the same files and tests red on both (WebKit language
  counts vary run to run), every one already filed: #4623, #5796,
  #4705, #5869, #2559/#4966, #5215, #4717, #4718, #4263, #4489, #5048,
  #5834, #5156.
- go test -tags nogui ./internal/gui/... on WSL: ok, with the size
  budgets; at the pushed head app.js has 1441 bytes of room and the
  core 96 (codeBytes measure).
- After rebasing onto 767029501: panel-usage-models, panel-usage,
  i18n-keys, i18n-en-no-cjk and the budget tests on WSL again.

Not tried: the whole GUI suite to its end (a full make test-ui at the
pre-rebase head is running on mica; on WSL it ran from a* to b* before
I stopped it for the run above), a real panel in the app, Windows.
2026-11-14 03:45:05 +08:00
yetone 7670295019 copilot: list each model's long-context tier, as Copilot Chat asks /models (gtliuu on X)
gtliuu on X: Copilot's Claude Opus 5.5 has a 200K and a long tier, and magpie
offered only 200K. magpie asked /models at X-GitHub-Api-Version 2026-01-09,
and at that version Copilot lists only the default tier's
max_prompt_tokens. Copilot Chat 0.68 never sends 2026-01-09:
@vscode/copilot-api 0.5.2's _mixinHeaders sets 2026-08-01 on every Copilot
API request, Models included, over networking.ts's 2026-01-09. At
2026-06-01 and later, /models gives each model its whole window (Opus 5.5
1M) and billing.token_prices with a default tier and a long_context tier.

- The editors' sign-in asks GET /models at 2026-08-01
  (copilotModelsVersion). The Copilot CLI's sign-in keeps its own
  2026-07-01, which already lists the tiers. Chat requests are unchanged:
  Copilot served prompts past the default tier at 2026-01-09. The other
  requests still on 2026-01-09 are #6571.
- The window follows Copilot Chat (languageModelAccess.ts and
  agentIntent.ts). A long tier at the default's prices gives the whole
  window: Claude Opus 5.5 1M, and the Sonnet, Fable and Gemini models
  936K or 983K. A long tier with a surcharge keeps the default tier's
  prompt as the window agents are told. The whole window becomes
  MaxContext, which the user can raise the window to. GPT-6 Luna gets
  272K and 872K, and Claude Haiku 5.5 100K and 936K. The whole window is
  the limits' max_prompt_tokens, not the long tier's prompt: Grok 4.7's
  long tier says 500000, but Copilot takes 372000.
- Price: Copilot's own list (AIU per batch_size tokens / 100 = USD per M)
  is the list price, ahead of models.dev. A long tier with a surcharge
  becomes a Tier above the default's prompt. Both 2026-06-01's field
  names (cache_price, context_max) and 2026-08-01's are read. GPT-4.1's
  all-zero list is no price. A flat, older list changes nothing.

Run (base origin/main 7b50e1f2c):
- go test -tags nogui -count=1 -timeout 45m ./internal/provider/...
  ./internal/catalog/... ./internal/gateway/... ./internal/usage/... on
  mote, in a sandbox HOME: all ok (provider 139s, catalog 3s, gateway
  918s, usage 42s). Not the whole ./...: mote's suite lock had six suites
  queued, and mica's disk is full.
- GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., and the
  linux and windows builds: ok.
- gofmt -l: clean.
- Fixtures are the owner's account's real /models replies at 2026-01-09,
  2026-06-01 and 2026-08-01, trimmed to four models.
- Real use: a -tags dev build in a sandbox HOME with only
  github-copilot/apps.json copied, on 127.0.0.1:3476. Its /v1/models
  lists copilot/claude-opus-5.5 at 1000000 (200000 before) and
  gpt-6-luna at 272000, both priced from Copilot's list. A
  584,849-token prompt to copilot/claude-opus-5.5 on /v1/messages got
  200 end_turn, billed by Copilot at 233.9 AIU (400 an M, the default
  tier's price).

Broken by hand, each red:
- /models asked without copilotModelsVersion: TestCopilotListsTheLongContextTier.
- tiers not applied: that test and TestCopilotTiersAtTheFirstTieredVersion.
- the long tier's prompt over the limits': red on Grok 4.7's 500000.
- context_max not read: TestCopilotTiersAtTheFirstTieredVersion.
- copilotListPrice off: TestCopilotListPriceIsCopilots.

Not tried: a request on a surcharged model raised past its default
tier (GPT-6 Luna over 272K), or a Business or Enterprise account's list.
2026-11-14 03:37:38 +08:00
yetone ab4b1cf38f sessions: a long Codex rollout is read on after a restart, not read again whole
shangyuan0818 on X: on Windows, Usage > Sessions took over ten seconds to
open with one very long session (tens to 100 MB), though there were only
a few sessions.

Cause: a Codex rollout's summary window (state.Codex) and its calls'
window (cxRun) lived in memory only. After a restart, or once the window
had been dropped, the first line a live rollout gained made parseRead,
prepareCalls and readsWhole read the rollout again from its first line:
once for the summary and once for the calls. Claude Code sessions were
already read on through their kept windows (#3493).

Fix: the window of a rollout being written (changed within the hour, the
same files memory keeps windows for) is now kept on disk with the parser
version, a window version, and the size, offset and content hash of the
read that made it. The summary's goes in codex-windows/<hash>.gob next
to sessions.json. It is written with sessions.json, and it is removed
once the cache drops that window. The calls' window goes in the shard's
.rev file next to Claude's. Each is used only when all of those match,
so a window from another read, or from an older layout, is never used;
the file is read whole instead, as before.

Measured (100 MB rollout built from testdata/codex-native-paginated.jsonl,
plus a 100 MB Claude Code session, GET /api/sessions in a sandbox HOME):
  mote (M5), before: after one line appended following a restart, 2.51 s
    (Codex alone 2.25 s). After: 9.7 ms (Codex alone 6.3 ms).
  Windows (xiaomi-gpu), before: 2.61 s. After: 22.8 ms.
  The first read with nothing kept is unchanged: 2.6 s on mote, 2.8 s on
    Windows. Warm and plain-restart opens were already 10 to 30 ms. stats
    and overview stayed at a few ms throughout.
  A real 32 MB rollout: 24 ms after an append, with 2 KB and 4 KB windows.
    A 100 MB rollout with a unique response id per turn: 11 ms, with
    623 KB and 834 KB windows.

Tests: TestCodexSessionReadOnAfterRestart reads a rollout, restarts, then
appends a replayed token_count and a new turn. It checks that neither
reader starts at offset 0, and that calls and the session's tokens,
models and cost match a read from scratch. TestCodexWindowLeavesWithItsSession
covers writing, reading back, refusing another read's window and
removal. TestPlainRolloutReadOnceForSessionsAndCalls (#4369) expected
both readers to start from 0 after a restart; it now expects them to
read on.

Broken by hand, each red: the summary window not read (starts [319830 0]);
the calls window not read ([0 319830]); a summary window emptied of what
it had seen (it panicked in codexUsageState.count, which is why the
version guard was added); a calls window emptied (62 calls vs 61).

Run: gofmt -l clean. GOOS=linux and GOOS=windows go vet -tags nogui ./...
on mote. Full go test -tags nogui -timeout 45m ./... on Linux (wsl-run,
magpie-desktop) at this change on 70bd270ae: every package ok but
internal/usage, whose TestRequestStateKeptAcrossACatalogFetchedAgain is
red the same way alone on origin/main 7b50e1f2c (11 of 20; a same-size
catalog write in one mtime tick, filed as #6572). mote's suite.lock had
five runs queued ahead, so its run of this change is still waiting.
Rebased onto 7b50e1f2c (7 files in internal/provider and internal/usage,
none under internal/sessions); provider, usage and sessions run again
there on Linux: all ok (#6572 passed this time). win-run ./internal/sessions/: only TestAgySessions,
TestAgyRowOnly, TestAntigravityAppFolder and TestCCListingKeepsItsNames
fail, and they fail the same way on origin/main ea9f2639b (#6071).
win-run -run 'Session|Usage|Calls' ./internal/gui/: only
TestGatewayModeStatsNameTheGatewaySessions fails, the same on ea9f2639b
(#6068).

Old data: right after updating, every user's live rollout is read whole
once more on its next change, since no window has been kept yet. From
then on it is read on. Nothing else changes for files not written within
the hour.

Not changed: WorkBuddy, WorkBuddy AI and CodeBuddy calls are still read
whole on every line (556 ms per 100 MB on mote), filed as #6565. Not
tried: the reporter's own machine and files.
2026-11-14 03:28:08 +08:00
yetone 7b50e1f2c6 provider: Claude Code's version-2 model catalog lists an account's models too (#6418)
Claude Code 2.1.323+ keeps an account's models in
<config dir>/cache/model-catalog/<organizationUuid>-<sha256(accountUuid)[:12]>-cc.json
(version 2, catalog.config.models), and magpie read only .claude.json's
additionalModelOptionsCache / modelAccessCache. A model only that catalog
has, and models.dev's anthropic list lacks, was missing from the Claude
provider, `magpie models` and Claude Code's own picker (pwn2ooown).

readClaudeCodeModels, which every reader of those caches goes through
(claudeModels, claudeModelsOf/claudeLists, ClaudeCodeModels,
claudeCodePrice), now adds the catalog of the account its .claude.json
names, from that config directory or Claude Code's own (~/.claude keeps
every account's that signed in there), the one fetched last. A model
models.dev doesn't describe takes the catalog's window, reply limit,
effort levels and mm_images. The legacy caches are read as before.
Another account's catalog is never read; a file of another version or
surface is unknown; a .claude.json or catalog that doesn't parse
(halfway through a write) is what it said last (readKeepingGood), a file
gone is gone.

The name and shape come from this Mac's Claude Code, read only: 7 files
in ~/.claude/cache/model-catalog and 2 in saved account dirs; the name's
first part is organizationUuid and its second sha256(accountUuid)[:12]
for every account whose .claude.json is here.

Run (mote):
- go test -tags nogui ./internal/provider ./internal/agent ./internal/cli
  ./internal/catalog ./internal/filememo ./internal/proc: all ok (provider 166s, agent 357s, cli 67s)
- go vet ./...; GOOS=linux go vet -tags nogui and GOOS=windows go vet of
  internal/provider and internal/agent; gofmt -l clean
- built magpie, `magpie models` in sandbox HOMEs (the issue's repro
  adapted): baseline, other account's catalog, half-written catalog: no
  Fable 5.2; the issue's catalog: listed; legacy cache: listed; a copy of
  a real Claude Code catalog's bytes under synthetic ids: all 13 models
  listed.
- after rebasing on 58629a0f8 (no change in these packages): provider
  and usage ok again at the pushed head.

Broken by hand (TestClaudeCodeCatalogV2Models red each time):
- catalog not read: "Fable 5.2 from the version-2 catalog not listed"
- last good dropped: "a half-written catalog dropped Fable 5.2"
- name keyed on org only: "another account's catalog listed"

Not tried: Claude Code on Linux/Windows (same path under the config dir
assumed); a real account whose catalog has a model models.dev lacks
(every model in this Mac's catalogs is in models.dev); the full ./...
suite. The issue's repro names its file <org>-<accountUuid>-cc.json,
which Claude Code doesn't write, so that literal name is not read.
2026-11-14 03:17:11 +08:00
yetone 58629a0f8e usage: a trim that lets most chunks go gives back the map's table
The usage page's index of session-file chunks is let go when no page has
asked for it in requestIdle + requestForget (trim(0)). A Go map never
shrinks, so the emptied map kept its table: 853 KB of a real Codex
history's index (pprof inuse_space at request_page.go:1461, the map
assignment in keep) stayed for the life of the process, 8 minutes after
the page was last open. trim now copies what is left into a map of its
size when it dropped more than it kept.

TestRequestTrimGivesBackTheMap fills an index with 100k chunks, holds
the keys, and checks trim(0) gives back the table. Broken by hand (the
copy skipped): red, heap 9,054,088 -> 9,051,552. Fixed: 3 of 3 green.

Real Codex account sandbox (mote, acctp HOME, page open 30s then 8 min
idle, memprofilerate=1): liveHeap 18.00 MB -> 17.07 MB; nothing held
under requestIndex.keep (was 853 KB). One earlier run read 23.1 MB with
a usage build in flight at the capture (sharedBuild 5.2 MB); the rerun
had none.

mica: gofmt clean; go vet ./internal/usage for darwin, linux, windows;
go test ./internal/usage ./internal/gui ok.
Not run: the full suite.
2026-11-14 03:11:29 +08:00
yetone 71079b69f5 gui tests: old-webkit knows appearance.js is imported lazily (#6467)
a65dade2e (v0.1.4005) added appearance.js, imported when Settings draws
General or the look changes. old-webkit's "compat.js is the first of
the page's own scripts" then failed with "appearance.js is not loaded
by index.html". It joins the test's list of lazy imports, with a line
saying when it loads.

Run on mote at this head (rebased on origin/main 70bd270ae):
- old-webkit.test.cjs + appearance-look.test.cjs: 32 pass, 2 fail. The
  two are filed and not this change: headerpresets.js unlisted (#6030)
  and .side-foot:has() (#5919).
- With headerpresets.js added in a copy, the test gets past
  appearance.js and stops at navpages.js, also unlisted (filed #6570).
Broken by hand: the same copy with appearance.js taken out of the list
fails on "appearance.js is not loaded by index.html".
Also checked: omarchy.test.cjs's "on Omarchy" timeout is the same at
2f2a0afa5, before a65dade2e (#6027).
Not tried: the full GUI suite again.
2026-11-14 03:04:38 +08:00
yetone 70bd270ae2 agents: Antigravity says how its own sign-in's models come back on magpie (T_t__biu on X)
T_t__biu on X: once magpie wires the Antigravity app, the Gemini models of
their own signed-in Google account leave the app's model list. Cause: magpie
connects the app through Google's Enterprise Gateway (gateway block in
~/.gemini/config/config.json and ~/.antigravity/settings.json). On a gateway
the app's language server runs in AUTH_MODE_ENTERPRISE_GATEWAY and drops the
Google sign-in (Google's docs: the two can't be used at once), so Code
Assist's fetchAvailableModels, which listed the account's models, is never
asked. No key in the file keeps both.

What does keep them: the same Google account signed in under magpie's
Antigravity subscription (the antigravity-auth plugin). The gateway's
antigravity catalog then lists that account's own models beside magpie's,
on that account's quota, pooled with any other Google account added there.
The notice shown on connecting now says so while magpie has no Antigravity
account (provider.Logins("antigravity") empty); with one, it reads as
before. Translated in zh, zh-TW, ja, de; the site's Antigravity page (en,
zh, ja), llms-full.txt and docs/subsystems/agent-wiring.md say the same,
and the subsystem page names what is not built: keeping the app's own
sign-in and adding magpie's models beside it would need the backend's
Code Assist endpoint (--cloud_code_endpoint / CLOUD_CODE_URL) pointed at
magpie.

Run at this head (base 331057743 = origin/main, fetched), on mote:
- go test -count=1 -timeout 45m ./internal/agent ./internal/gui ./internal/cli: ok
- go test -run 'Subsystem|Doc|Loop' ./internal/gateway: ok
- node --test i18n-keys, i18n-en-no-cjk, agent-notice-lang, about-notices
  (GUI): 50/50 pass
- site: node --test worker.test.mjs files.test.mjs: 52/52 (after
  regenerating llms-full.txt, which the first run caught stale)
- GOOS=linux and GOOS=windows go vet ./internal/agent: ok; gofmt -l clean
Real use, sandbox HOME on mote with one real Antigravity account (copied
plugin:antigravity entry only, @magpie-community/opencode-antigravity-auth):
- magpie antigravity magpie/up/g3 wrote the gateway block; GET
  /v1/models?format=antigravity with the app's key listed the account's
  models (Gemini 3.8 Flash, Gemini 3 Flash, Claude Sonnet/Opus 4.6, GPT-OSS
  120B, ...) beside up/g3; a chat on antigravity/gemini-3-flash:low through
  /v1/chat/completions answered "pong" on that account.
- the built binary prints the old notice in that HOME, and the old notice
  plus the new sentence in an empty sandbox HOME.
Broken by hand: Notice's account check forced off, TestAntigravityGateway
red ("no word of the app's own models with no Antigravity account").
Not tried: a real signed-in Antigravity app (none here; the app keeps its
token in the keyring); the whole GUI suite (app.js untouched, only i18n.js
keys added); Windows/Linux runs of the package (no OS-specific code).
2026-11-14 02:44:12 +08:00
yetone 331057743d agents: a provider an agent's visibility keeps is in its model list, off, and ticked is shown it (whysugarsweet on X)
whysugarsweet on X (v0.1.4066): OpenCode Go is in Pi's model list but
not in Claude Desktop's. Desktop's list showed Google Gemini, DeepSeek,
Anthropic, Codex and Grok only.

Nothing leaves OpenCode Go out by protocol. What can narrow one agent's
catalog to some providers is settings.Visible: `magpie visible`, a
profile or settings sync writes it. A provider added later is kept out
of that agent's /v1/models, its config and the Agents page's list. The
page showed no sign of it and had no way to undo it, so the user could
only see Go missing. I haven't seen the reporter's settings, so this is
the likely cause, not a confirmed one.

- GET /api/agent-models/{id} now lists the models the visibility keeps,
  after the rest, as hidden and `kept`. They sit under their provider
  in the list and its rail, so they can be found and ticked.
- POST takes `widen`: kept models that were ticked. provider.Widen adds
  each one's provider (or group) to the agent's visibility. When nothing
  is kept after that, the agent is no longer narrowed at all. The
  provider's other models are then listed and off, so ticking one adds
  just that model.
- A kept model is never saved as hidden or picked one by one. The row's
  count leaves kept models out of "listed".
- Every agent's list shares this code, so the fix applies to every
  narrowed agent, not only Claude Desktop. The gateway's model list and
  Desktop's inferenceModels both come from CatalogFor, so a widened
  provider is served and routed too.

Run, at db9d6507b plus this commit:
- go test ./internal/gui ./internal/provider (mote), whole packages:
  ok. The new tests:
  - TestAgentModelsKeptByVisibility: Go's models are kept and off;
    ticking Kimi widens Desktop to opencode-go; CatalogFor then has it;
    widening the last kept one deletes Visible.
  - TestAgentModelsKeptPicked: a widen is a pick in only-picks mode.
- go test ./internal/gateway with -run on the model, catalog and Desktop
  tests: ok.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., the three builds, gofmt -l: clean.
- New GUI file desktop-model-kept.test.cjs: chromium and webkit; en, zh,
  zh-TW, ja and de; window (1100px, with the rail) and tray panel
  (420px). 20/20 ok.
- GUI files around the list (agent-model*, agent-models*, desktop-*,
  agent-menu-label, agent-connect-*, cursor-local-models, codex-model-*,
  zcode-models, grip-inset, popover-mac-chrome, provider-*picked*,
  i18n-*) on mica: 597/608 at 65f745dd4 plus this change. Every red was
  red the same, alone, on origin/main ea9f2639b:
  - agent-menu-label, webkit panel en/ja/de: #6371
  - desktop-tiers: #6475
  - grip-inset: #6293
  - zcode-models, webkit de panel: filed as #6566
  At the rebased head I reran desktop-model-kept, desktop-model-menu,
  desktop-twin, agent-models, agent-models-provider-ticks,
  agent-models-only-picked and i18n-keys: 114/114 ok (mote).

Broken by hand:
- Kept models left out of agentModelList: the Go test is red ("no
  opencode-go/kimi-k2.6").
- The provider.Widen call removed: red ("visible: [deepseek-x]",
  "picks: [relay/a1]").
- The old app.js save(): the GUI test is red, with no widen posted.

Not tried:
- the reporter's own settings.json;
- the real Claude Desktop app reading a widened config;
- a real OpenCode Go account.
2026-11-14 02:22:28 +08:00
yetone 48f9764027 plugins: a model served on more APIs keeps the client's (gaubeebangeel on X)
gaubeebangeel on X: OpenDesign's Anthropic requests to an Open Design
Cloud account were all sent upstream as chat completions. The Open
Design plugin declares each model on one AI SDK package (chat
completions for most, Responses for deepseek-v4-pro and claude-haiku-5.5,
plugins#141), and pluginAPIs gave a plugin model that one API alone, so
attempt never relayed a /v1/messages request and translated it, though
amr-link serves every model on all three (plugins#888). A DeepSeek
API-key provider, the case first suspected, relays to /anthropic/v1/messages
as sent: tried with OpenCode's, node's and no User-Agent, bare and
prefixed ids, and web search.

A plugin model can now list the other APIs its vendor serves it on, as
their AI SDK packages (m.also; plugin.Model.Also through host.js, config
model and models hook). pluginProtocols gives the model's own API first,
then those; ListedAPIs, the catalog's APIs and the provider's bases come
from it, so a client's request on any of them is relayed as sent. usable
puts a plugin model's own API first, so a request on an API it isn't
served on is still translated to the declared one. A model with no also
is unchanged. opendesign 0.1.13 (plugins 397da020) sets also on every model.

Test: TestPluginModelServedOnMoreAPIsKeepsTheClientAPI (fake plugin,
FAKE_ALSO): Anthropic, Responses and Chat requests to the also model
reach the upstream on their own path; fake-1 (no also) is still
translated to /chat/completions. Red on HEAD's plugins.go: Anthropic and
Responses reached /v1/chat/completions, ListedAPIs and usable were [chat].

Run (mote unless said): go test ./internal/provider ./internal/plugin
./internal/catalog ok; go test ./internal/gateway ok (972s);
GOOS=linux/windows go vet of the three packages ok; gofmt clean.
Not run: the full ./... suite (mote and mica each had full suites
queued under suite.lock); not tried against a real amr-link account
(keyblues's plugins#888 measurements are the evidence it serves
/v1/messages for every model).
2026-11-14 02:14:31 +08:00
yetone db9d6507bb dsh: a thinking level set on magpie's route by hand is what its sessions start on
ming_li52905 on X set a level per route in dsh's config:

    providers:
      magpie-responses:
        reasoning: high

and magpie "overwrote" it. magpie never dropped the key. llm-pi-ai starts
a route's models on profile.reasoning only when the session names no
effort (options.reasoningEffort ?? profile.reasoning, dsh-llm-pi-ai
0.2.2-rc.3). agent-default-model's reasoningEffort, which magpie's
thinking setting writes, is the effort every new session names, so the
user's level never applied.

Now the route's own level wins over magpie's one default:
- A start magpie writes on such a route (switch, set) carries no effort
  of magpie's.
- A sync or round takes out an effort magpie wrote there before
  (dshStartYields). magpie keeps what it last wrote into each list's
  start (dsh-effort:<file> in the stash), so an effort dsh saved itself
  (a composer pick, #1392) is the user's and stays. When the home layer
  mirrors a profile's start, it takes that profile's record too.
- Thinking reads the route's level when the start names none, and
  setting it writes the route's reasoning wherever it is set: each
  profile, the home layer, settings.yaml. It writes no reasoningEffort.
- A route without a level still gets magpie's effort, as before.

Tests: TestDshRouteLevelOfTheUsersOwn (sync, round stability, a switch
away and back, thinking set, dsh's own saved effort kept),
TestDshRouteLevelInTheHomeLayer, TestDshRouteWithoutLevelTakesMagpiesEffort.

Run:
- The three tests at the old dsh.go: red (start keeps "medium" over
  high, thinking reads medium, thinking low leaves the level).
- Broken by hand, each red: the record check ignored (dsh's own effort
  stripped); Get not reading the level; the round's dshStartYields
  removed (both level tests red).
- go test -count=1 ./internal/agent on mote: ok (237.9s).
- GOOS=linux go vet -tags nogui and GOOS=windows go vet of
  ./internal/agent on mote: ok. gofmt -l: clean.

Not run: the full ./... suite. mote's suite lock had four full runs
queued ahead of it. The change is internal/agent only.

Not tried: a real dsh. The precedence comes from dsh-llm-pi-ai
0.2.2-rc.3's source, not from a session.

Risk: a start written before this release has no record. If its effort
differs from a route level the user set, it is taken for magpie's and
removed once, even if dsh had saved it.
2026-11-14 02:02:33 +08:00
yetone ea9f2639b9 LESSONS: a docs edit left llms-full.txt stale, unseen behind cancelled runs
459d668b3 changed docs/sync.html without regenerating llms-full.txt. The
site test was red from 21:05, and CI showed it only once a run was not
cancelled by the next push. Added under "A cancelled run tests nothing".
Docs only; nothing run.
2026-11-14 02:00:33 +08:00
yetone 3d88600100 site: llms-full.txt carries the sync page's pick, preview and undo
459d668b3 (#6428) added "Pick what syncs, preview, undo" to
docs/sync.html (en, ja, zh) without running `node llms-full.mjs`, so
site/worker.test.mjs's "llms-full.txt is current" test has been red on
main since 21:05. The cli (linux/amd64, nogui) job of CI run
43465016007 (d5585933f), the first run in hours not cancelled by the
next push, failed on it.

Regenerated with `node llms-full.mjs`; the diff is that section only
(+988 bytes).

Run at 640304a16 + this change, on mica:
  cd site && node --test worker.test.mjs   pass 41, fail 0
The same test against the old file is red on CI (run 43465016007).
Not run: the Go suite (no Go change).
2026-11-14 01:59:39 +08:00
yetone 640304a165 edit: a TOML file's table names are let go after 5 minutes unlisted
Codex's real config.toml (1.5 MB, ~11k project tables) had its table
names kept for the process's life once the start-up rename
(agent.RenameLegacy) listed them: 1.16 MB of packStrings in an exact
heap profile (memprofilerate=1) after 8 minutes idle in the real-account
sandbox, the largest holder left under cli.init. The whole parse was
already let go after a minute (tomlIdle); the names now go after
namesIdle (5 min) with no list, the other kept answers (GetTOMLTop,
GetTOMLTable, polled every 3s) stay, and a list a caller holds is not
touched.

Cost of a list after the let-go: BenchmarkTOMLTablesCold on that config,
9.0 ms and 21.5 MB of garbage per list (mote, M5 Pro).

Run: go test ./internal/edit (mote), TestTOMLNamesLetGoWhenIdle red with
the drop made a no-op by hand ("the names were kept past namesIdle"),
green with it.

Real-account sandbox (mote, real Codex config.toml), 8 minutes idle after
the page closed. Exact heap (memprofilerate=1): liveHeap 19.47 MB before
(v0.1.4082) -> 18.00 MB after, and RenameLegacy's held bytes 2.24 MB ->
0.86 MB, with no packStrings left. Without the profiler: liveHeap 19.57
-> 18.01 MB, heapInuse 33.1 -> 31.0 MB; footprint 71 vs 75 MB, within
one run's noise of each other. Also run on mica: gofmt, go vet for
darwin, windows and linux, go test -race ./internal/edit, and go test
./internal/agent ./internal/library ./internal/cli, all ok.
2026-11-14 01:58:42 +08:00
yetone 82512bb640 usage: the probe chunk is let go when the pages rest and after warm-up
probeChunk memoised its last chunk for the polling page (#2278), and
nothing ever cleared it: ~5 MB of unpacked probe rows held for the
process's life on a real gateway's history, the largest single live
holder left in an idle heap profile (makeProbeChunk -> rowChunk.add).
ReleaseScratch (page rest) and ReleaseMatchScratch (after warm-up) now
drop it with the rest of the reads' scratch; the next page read makes it
again, and while a page polls the memo still answers.

Run (mica): go test -run 'TestProbe|TestAnswered' ./internal/usage/ ok.
Broken by hand: without the two releaseProbes() calls,
TestProbeChunkLetGoAtRest fails ("ReleaseScratch kept the probe chunk").

Measured on mote, real accounts in the sandbox HOME, idle after the page
was open 30 s and closed 60 s (memv.sh), base vs this, two runs each:
  heap profile in use: 52.5 MB (4.91 MB under makeProbeChunk, held from
    gui.warmStart) vs 46.9 MB (none under it)
  liveHeap: 40.0 / 45.7 MB vs 40.4 / 40.4 MB
  footprint: 94 / 117 MB vs 102 / 107 MB (noisy run to run)
go test ./internal/usage/ ./internal/gui/ on mica: ok.
2026-11-14 01:06:11 +08:00
yetone 6112dd37c1 agents: Use Claude Magpie shows with Claude Magpie made too, and the row names it (xMopf7RF on X)
xMopf7RF on 0.1.4076: "没看到按钮". The Use Claude Magpie button beside
Claude Desktop's switch showed only while Desktop wasn't on magpie and
Claude Magpie was off (`!a.isolated.on`). The reporter had tried Claude
Magpie since 0.1.4064, so it was on while Desktop wasn't on magpie, the
one state where the button hid. The row then still read "on magpie,
Claude Desktop opens a separate profile…", though connecting there wires
only Claude-Magpie-3p (desktopSets), never their own Desktop.

States where Desktop isn't on magpie, before → now:
- Claude Magpie off: button shown (unchanged).
- Claude Magpie on, app there: no button, wrong line → button, and the
  line says connecting puts Claude Magpie on magpie and their own Desktop
  stays signed in with Anthropic.
- Claude Magpie on, app deleted from ~/Applications (launcher ""): no
  button, so nothing made it again → the button, whose
  settings/desktop-isolated on:true remakes the app (desktopiso.Add over
  nothing), then connects.
- isolated missing (not a Mac, WSL): no button (unchanged).

Run (mica, mote over its 18 cores):
- desktop-twin.test.cjs, new cases: Claude Magpie made with and without
  its app, every language, 1100 and 640px, Chromium and WebKit: 62/62 ok.
  Broken by hand: the same file on origin/main's app.js: 40 red (every new
  case), 22 ok.
- TestCoreScriptBudget ok (within the room app.js had).
- Every GUI file naming claude-desktop or isolated (31) with i18n-keys and
  i18n-en-no-cjk, both engines: 760/762; the two reds are
  desktop-tiers' Chromium cases, red the same on origin/main 65f745dd4
  with this change taken out (#6475).

Not tried: the real app on a Mac with a deleted Claude Magpie.app; the
switch alone (not the button) in that state still wires the folders
without making the app again.
2026-11-14 00:51:23 +08:00
yetone d5585933f1 usage: heat-digests.bin is read mapped, not copied into the heap
The heatmap's key names each session file's chunk by a digest kept on
disk by serial (#2278). The file holds up to 2*sourceDigestsKept digests
at 40 bytes each, 5MB on a long history, and every start read it whole
into the heap and kept it there for the process's life. After a save the
encoded bytes stayed instead, the same 5MB.

Where the system maps files (unix), the file is now mapped read-only,
as requests-v1.bin already is (mapDiskFile), and kept is read from the
mapping: its pages are clean file pages, not footprint, and a lookup is
a binary search that touches a few of them. After a save the file just
written is mapped in place of the encoded bytes, when it is still those
bytes. The file is only ever replaced by a rename, so a mapping stays
as it was read. Windows reads it into memory as before (mapsFiles).

Run (mica, go1.26.8):
- go test ./internal/usage/: ok (54s)
- go vet ./internal/usage/, GOOS=windows go vet ./internal/usage/: clean
- Broken by hand (no mapping on load, no keepMapped after save):
  TestSourceDigestsKeptAcrossStarts red, "after a save the digests are
  kept as encoded"; green again with the change.

Real account (mote, the owner's history in a sandbox HOME, magpie web
with the page open, 90s idle, footprint + Go MemStats):
- before (w63 = v0.1.4074's code): footprint 109MB, live heap 44.9MB
- after: footprint 101MB, live heap 39.6MB

- wsl-run and win-run: go test -run 'SourceDigest|Heat' ./internal/usage/
  ok on Linux (the mapped path) and Windows (read into memory).

Not run: the full ./... suite (only internal/usage is changed).
2026-11-14 00:40:00 +08:00
yetone 65f745dd4c plugins: Installed is narrowed by Discover's kinds and origins
WJaunita45604 on X asked for the Installed tab to be filtered by
Discover's categories, and by whether a plugin is official, with
Discover's own categorisation. Installed now has the same strip and menu
as Discover:
- the kinds strip (All, Subscriptions, Middleware, Agents, Tools, Pages),
  each with how many are installed;
- the Origin menu (magpie community, other authors, unofficial on GitHub),
  without Discover's "Not installed only".

browseBar's strip and Origin button are split out (kindStrip,
originButton) so both tabs draw the same component. The rest is in
plugininstalled.js, imported when Plugins first draws, as plugingrid.js
is (old-webkit lists it); until it is in, the list is drawn whole. What
is left in the core is 674 bytes, within its budget's room. A plugin Discover
lists is put where its card is (kindOf, srcOf). One it doesn't list (a
folder, an unlisted npm package) is put by what it is: middleware or
gateway, agent, tools only, a page, else a subscription; from GitHub,
@magpie-community, else other authors.

The strip shows only when two or more kinds are installed, and the menu
only when two or more origins are. A pick that leaves nothing says "No
plugin matches" with Show all. Installed keeps its pick across tabs and
Discover keeps its own. The list head grows when it wraps
(.pm-listhead.pm-bar), so a narrow row doesn't run under the list. There
are no new strings, no native select (the app menu), and no left-border
accents.

New plugin-installed-filter.test.cjs: seven installed plugins of every
kind and origin, two of them GitHub repos from fixtures/plugins-github-31.
It runs in every language, both engines, at 1100px and 420px.

Run (on mote, Playwright 1.62.0, chromium + webkit): the new test, 20 of
20. Red on origin/main 005178104 (no strip on Installed: waitFor
.pm-listhead .pm-kinds times out).

On mote, both engines: at base 077421733, go test -tags nogui
./internal/gui ok and add-sheet*, provider-env-paste, plugin*.test.cjs,
old-webkit, i18n-keys and i18n-en-no-cjk green but the reds below and
the two the scroll buttons' commit fixes. Rebased on origin/main
6e03b746b with that commit: TestCoreScriptBudget ok with no raise;
add-sheet*, provider-env-paste, plugin-installed-filter,
plugin-api-prompt-key, plugin-password-prompt, the eight plugin files
red before, old-webkit, i18n-keys and the scroll files that commit
names: green but the reds below.
Reds that fail the same on origin/main 6e03b746b, run alone there:
old-webkit (#6467 appearance.js, #5919 .side-foot:has), plugin-move-unserved
(#4392), plugin-signed-out-account (#5998), plugin-signin-no-url (#5938),
plugin-page-foreign-error (#6117), plugin-option-placement (#6559),
rollup-short (#6560), text-size in WebKit (#6561), phone-no-sideways de
375 (#5869). The whole GUI suite was not run: mote's and mica's loads
were over their cores all evening (mote 27-53 on 18, mica 66-104 on 12).

Rebased on origin/main 1730c75b9, the pushed head (mote): go test -tags
nogui ./internal/gui ok; add-sheet*, provider-env-paste,
plugin-installed-filter, plugin-api-prompt-key, plugin-password-prompt,
i18n-keys, i18n-en-no-cjk and view-ends, both engines: 252 of 252.
a82bae2bd, landed on top since, changes the routing plugin, the
gateway and i18n.js keys of its own, none of these files; the core
measure at the pushed head is 1,267,635 of 1,268,961.
2026-11-14 00:16:51 +08:00
yetone b3d1334458 providers: the Add sheet's search shows its hint whole
WJaunita45604 on X: 输入框里面的提示的字显示不全. Since a44da380b
(v0.1.4044) the Add sheet's search hint has been "Find a vendor, or paste a
URL and key…" (查找供应商,或粘贴地址和密钥…), in a box 160px wide, so it
was cut off in every language.

wholeHint (addfloat.js, which the sheet already imports) measures the hint in
the box's own font and sets
--hint-w, which the CSS now sizes the box by: in the sheet's row and when
the tools float into the title bar. Where even that has no room it shows
the shorter "Find a provider" (already in every language) instead. At 760px
and narrower the box keeps room for that short hint (--hint-s), and Import…
wraps to the next line rather than cut it; Custom provider stays on the
search's line (add-sheet-custom). Nothing changes in the observer's own turn,
the hint included: the next frame measures, sizes the box and then picks,
as WebKit calls a change while sizes are being told a loop.

The core grows 84 bytes, the import that calls wholeHint, within its
budget's room.

provider-env-paste asked for the long hint at 440px too. It now waits for
the box to be sized and takes either hint below 900px.

New add-sheet-hint.test.cjs: every language, both engines, at 1300, 1024,
900, 420 and 360px. It checks the hint's drawn width against the room in
the row, floated in the title bar, and after narrowing and widening the
window, and asks for the long hint at 1300 and 900px.

Run (on mote, Playwright 1.62.0, chromium + webkit):
- add-sheet-hint, add-sheet-float, add-sheet, add-sheet-custom,
  provider-env-paste: 140 of 140 (the add-sheet runs with the #6216 fix).
- Broken by hand: the test on origin/main 005178104 (no wholeHint, its
  wait for --hint-w swapped for 300ms) is 26 of 26 red, e.g. "the hint
  fits: 222.125 > 140".
- An earlier version that put the search on a line of its own at 520px and
  narrower broke add-sheet-custom's "on the search's line" at 420px. That
  is why Import… wraps instead.

On mote, both engines: at base 077421733, go test -tags nogui
./internal/gui ok and add-sheet*, provider-env-paste, plugin*.test.cjs,
old-webkit, i18n-keys and i18n-en-no-cjk green but the reds below and
the two the scroll buttons' commit fixes. Rebased on origin/main
6e03b746b with that commit: TestCoreScriptBudget ok with no raise;
add-sheet*, provider-env-paste, plugin-installed-filter,
plugin-api-prompt-key, plugin-password-prompt, the eight plugin files
red before, old-webkit, i18n-keys and the scroll files that commit
names: green but the reds below.
Reds that fail the same on origin/main 6e03b746b, run alone there:
old-webkit (#6467 appearance.js, #5919 .side-foot:has), plugin-move-unserved
(#4392), plugin-signed-out-account (#5998), plugin-signin-no-url (#5938),
plugin-page-foreign-error (#6117), plugin-option-placement (#6559),
rollup-short (#6560), text-size in WebKit (#6561), phone-no-sideways de
375 (#5869). The whole GUI suite was not run: mote's and mica's loads
were over their cores all evening (mote 27-53 on 18, mica 66-104 on 12).

Rebased on origin/main 1730c75b9, the pushed head (mote): go test -tags
nogui ./internal/gui ok; add-sheet*, provider-env-paste,
plugin-installed-filter, plugin-api-prompt-key, plugin-password-prompt,
i18n-keys, i18n-en-no-cjk and view-ends, both engines: 252 of 252.
a82bae2bd, landed on top since, changes the routing plugin, the
gateway and i18n.js keys of its own, none of these files; the core
measure at the pushed head is 1,267,635 of 1,268,961.
2026-11-14 00:16:51 +08:00
yetone 36126daeff gui: the scroll buttons don't watch the room kept under a held click
scrollends.js watched every child of the open page for a size change,
app.js's .view-room among them. "Where the reader is" (hold) sizes that
room from its own ResizeObserver, while sizes are being told, so WebKit
ended the turn with "ResizeObserver loop completed with undelivered
notifications" as a page error. It showed once the Add sheet's search
got its hint's width: in German at 420px, a provider's sign-in opened
from its tile made hold give the page room, and
plugin-api-prompt-key and plugin-password-prompt went red in WebKit
(de 420, every run). hold sets scrollTop with the room, and that scroll
is heard, so the buttons still follow.

Found by wrapping ResizeObserver to report each callback that changed an
observed size: hold (app.js heldSizes) took .view-room from 61px to 30px.

Run (on mote, Playwright 1.62.0, chromium + webkit), at this commit with
the next one (the search's width):
- plugin-api-prompt-key, plugin-password-prompt: 22 of 22, three times
  in WebKit; without this change 8 of 8 runs red at de 420.
- add-sheet*, provider-env-paste, old-webkit, and every file that
  touches the scroll buttons or the room (add-button, click-scroll,
  phone-no-sideways, rollup-short, routing-editor-foot,
  routing-save-blank, routing-save-keeps-the-row, sessions-paging,
  signin-closes-sheet, text-size, view-ends-relayout, view-ends):
  every test green but the reds below.

Reds that fail the same on origin/main 6e03b746b, run alone there:
old-webkit (#6467 appearance.js, #5919 .side-foot:has), plugin-move-unserved
(#4392), plugin-signed-out-account (#5998), plugin-signin-no-url (#5938),
plugin-page-foreign-error (#6117), plugin-option-placement (#6559),
rollup-short (#6560), text-size in WebKit (#6561), phone-no-sideways de
375 (#5869). The whole GUI suite was not run: mote's and mica's loads
were over their cores all evening (mote 27-53 on 18, mica 66-104 on 12).

Rebased on origin/main 1730c75b9, the pushed head (mote): go test -tags
nogui ./internal/gui ok; add-sheet*, provider-env-paste,
plugin-installed-filter, plugin-api-prompt-key, plugin-password-prompt,
i18n-keys, i18n-en-no-cjk and view-ends, both engines: 252 of 252.
a82bae2bd, landed on top since, changes the routing plugin, the
gateway and i18n.js keys of its own, none of these files; the core
measure at the pushed head is 1,267,635 of 1,268,961.
2026-11-14 00:16:51 +08:00
yetone 25e4d19c04 providers: an editor closed before its certificate rows load draws none (#6216)
drawEditor imported tlscerts.js and, once it was in, called tlsCertRows
with the module-wide draft. An editor closed (or swapped for another)
before the import resolved handed it null, and drawPin threw "Cannot
read properties of null (reading 'serverPin')". add-sheet.test.cjs opens
and closes editors quickly and went red on that pageerror under load
(#6216). The rows are now drawn only while the draft is still the one
the editor was drawn for. That is 50 bytes of core script, the hook
itself, within the core budget's room at 6e03b746b.

Run (on mote): add-sheet.test.cjs, both engines, 4 times on origin/main
005178104: red 2 of 4 (the serverPin pageerror); 6 of 6 green with this.

On mote, both engines: at base 077421733, go test -tags nogui
./internal/gui ok and add-sheet*, provider-env-paste, plugin*.test.cjs,
old-webkit, i18n-keys and i18n-en-no-cjk green but the reds below and
the two the scroll buttons' commit fixes. Rebased on origin/main
6e03b746b with that commit: TestCoreScriptBudget ok with no raise;
add-sheet*, provider-env-paste, plugin-installed-filter,
plugin-api-prompt-key, plugin-password-prompt, the eight plugin files
red before, old-webkit, i18n-keys and the scroll files that commit
names: green but the reds below.
Reds that fail the same on origin/main 6e03b746b, run alone there:
old-webkit (#6467 appearance.js, #5919 .side-foot:has), plugin-move-unserved
(#4392), plugin-signed-out-account (#5998), plugin-signin-no-url (#5938),
plugin-page-foreign-error (#6117), plugin-option-placement (#6559),
rollup-short (#6560), text-size in WebKit (#6561), phone-no-sideways de
375 (#5869). The whole GUI suite was not run: mote's and mica's loads
were over their cores all evening (mote 27-53 on 18, mica 66-104 on 12).

Rebased on origin/main 1730c75b9, the pushed head (mote): go test -tags
nogui ./internal/gui ok; add-sheet*, provider-env-paste,
plugin-installed-filter, plugin-api-prompt-key, plugin-password-prompt,
i18n-keys, i18n-en-no-cjk and view-ends, both engines: 252 of 252.
a82bae2bd, landed on top since, changes the routing plugin, the
gateway and i18n.js keys of its own, none of these files; the core
measure at the pushed head is 1,267,635 of 1,268,961.
2026-11-14 00:16:51 +08:00
yetone a82bae2bd3 routing: a request's row says the service tier it went at (Anotiaww on X)
Anotiaww on X: with Codex's fast mode on, the Routing page's request log
didn't show that a request went in fast mode.

Two gaps. Codex on its own ChatGPT sign-in (codexUpstreamOn) set only the
route's tier, never its tries', and the Routing row drew only a group
member's fast flag, never a tier.

- codex_backend.go: the try (first and askAgain) carries the body's tier
  (bodyTier), and its end notes tier_served through servedTierAt. The
  handed-on usage record has tier_asked/tier_sent too.
- plugins/routing/client.js: the row shows a quiet tag beside the model
  (fast for priority, Ultrafast, flex) from the try's tier, or the
  route's asked tier while in flight. Its title says the tier and, when
  the reply said another, what it said. No new column. rowSays' sig
  takes the tier, so the row is drawn again when it changes.
- "flex" is a core word in i18n.js (i18n-keys: a plugin can't own a
  word other code says); its title strings are the routing plugin's.
- docs/subsystems/gateway-routing.md says the Codex relay's tries carry
  the tier and what the row shows.

Price: a priority turn is still priced at the standard rate. Pricer and
catalog.Price don't read the tier. That is #1784's open work, in
hhh2210's fork PR (hhh2210/magpie#1, catalog.ServicePrice), so nothing
is duplicated here. No Flags bits added or changed.

Run on mica (mote and mica both over their core count; mica the lower),
at 74b5f2420 on origin/main 1730c75b9:
- gofmt -l clean; go vet darwin, GOOS=linux and GOOS=windows -tags
  nogui ./internal/gateway ./internal/gui: ok
- go test ./internal/gateway -run 'Tier|ChatGPTBackend|OpenAIAPI|
  CodexOwn|CodexRelay|FastPick|SessionRoute': ok
- go test ./internal/gui -run 'Budget|I18n|Routing' (core script
  budget): ok
- node --test routing-service-tier, i18n-keys, i18n-en-no-cjk,
  routing-entry, group-member-fast: 52 of 52
Before the last rebase, at the same change on 817d35ffa: every GUI file
that loads the routing page plus i18n-keys and i18n-en-no-cjk, 3672
tests, 38 red. i18n-keys' "flex" was mine and is fixed above. The other
reds were in six files, with the same 25 red when those files ran alone
at 817d35ffa itself. Each is filed: ctx-session-line #5801,
routing-context-fold #5586, routing-pin-away #6512, routing-row-swap
#3799, routing-story-shrinks #3954, and mobile-web #3952/#5013 (its
"desktop matches origin/main" needs .git, which a mica-run copy lacks).
The rest (codex-subagent-model, desktop-subagent-model, provider-mask,
routing-many-keys, usage-compact-counts) passed on a rerun at
concurrency 3.

Broken by hand: client.js from HEAD~ makes routing-service-tier 0 of 20;
the first Try's Tier dropped makes TestCodexRelayRouteSaysTier red.
Dropping servedTierAt in end leaves it green: uu.Tier is filtered before
end runs. Kept as a guard.

Not tried: a real ChatGPT account's /fast turn, the full Go suite, the
Windows and Linux runtime.
2026-11-14 00:14:26 +08:00
yetone 1730c75b97 library: Claude Magpie is an agent of its own (xMopf7RF on X)
xMopf7RF asked for Claude Magpie, the separate Claude Desktop, to show
on its own in the Library's instructions, skills and MCP, like an
independent agent. Before, Claude Desktop's target wrote its servers
(DesktopConfigs3p) and Cowork skills (desktopdir.Everywhere) into
Claude-Magpie-3p too, and the twin's Code tab folder
~/.claude-magpie-desktop (a claude# row) got nothing from the Library.

- agent.DesktopTwinApp: claude-desktop#magpie, "Claude Magpie", an app
  target while the Separate app is on and its folder is there (macOS).
  MCP to Claude-Magpie-3p's claude_desktop_config.json, Cowork skills to
  its skills-plugin. No instructions file: noPlace points to its Code
  tab's row.
- Claude Desktop's target leaves Claude-Magpie-3p out (DesktopConfigs3p,
  desktopSkillRoots).
- Every claude#<name> row takes CLAUDE.md, skills/ and .claude.json in
  its folder (~/.claude.json for ~/.claude itself). settings.json
  features (hooks, env, tools off) stay keyed on claude.
- Old data: carryTwin, on load and only while nothing is recorded for
  the twin, ticks for Claude Magpie each server and skill magpie gave
  Claude Desktop that is in Claude-Magpie-3p already, so an update takes
  nothing away. library.json syncs, so another Mac's twin sees the same
  ticks. Unticked later, it stays unticked.
- Not changed: desktopCarryMCP still copies the user's own Desktop
  servers into the twin when it is wired.

Run (mote, sandbox HOME in the tests):
- go test -tags nogui ./internal/library ./internal/agent
  ./internal/desktopiso ./internal/desktopdir: ok (167s, 251s).
  GOOS=linux and GOOS=windows go vet of library and agent ok; gofmt clean.
- TestClaudeMagpieIsItsOwnLibraryAgent: InstallSkills, SaveServer and
  SaveInstructions write only Claude-Magpie-3p and
  ~/.claude-magpie-desktop; Claude Desktop's config and manifest,
  ~/.claude/settings.json unchanged; ~/.claude.json, ~/.claude/CLAUDE.md
  and ~/.claude/skills/pdf not written. TestClaudeMagpieKeepsWhatDesktopWasGiven.
- GUI, both engines: library-*.test.cjs (76 files), by-agent,
  every-skill, group-skill-chips, pick-skills, project-*, skill-*,
  i18n-keys and the new library-desktop-twin.test.cjs (separate chips
  for Claude Magpie and Claude Code · Claude Magpie, lit only for what
  they were given, a click on Claude Desktop's asks for it alone; en,
  zh, zh-TW, ja, de at 980 and 420px). 1850 of 1878 the first run, with
  a library.css hand change since dropped; the 28 reds were all in
  library-new-skill, library-subagents, library-wsl-asleep and
  skill-where, and those four files plus the twin test, run again
  without it: 174 of 174.

Broken by hand, each red then restored: carryTwin off (fs/pdf not
ticked, nothing recorded); Desktop's skill roots with the twin's folder
(target reaches Claude Magpie's folder); the claude# branch off (Code
tab target nil); DesktopConfigs3p with the isolated config again
(library and agent tests red).

Filed: #6558, a row's chips reach past its edge at 420px (ja with four
agents, before this too with six); the twin test skips that check for ja
at 420px until it is fixed.
Not tried: a real Claude Magpie.app on a desktop reading the new files.
2026-11-14 00:01:24 +08:00
yetone d0fb3c0084 provider: Claude accounts can be set not to spend extra usage (baksili_ on X)
baksili_ on X asked for a way to keep magpie off Anthropic's paid extra
usage on Claude subscription accounts. magpie can't flip Anthropic's own
switch, so it holds the account itself.

Providers -> Claude -> Advanced has a new "Spend extra usage" row: On,
as before, by default (nothing changes for anyone who doesn't touch it).
Off saves claudeNoExtraUsage. While it is off, HoldCaps holds every
Claude account at 100% of any plan window with no cap of its own (the
same Credits hold a Codex account set not to spend its credits gets),
so a Claude account whose 5-hour or weekly window is used up gets no
requests until it renews and the other accounts take them. What its
plan has left is still used; a cap the user set lower still holds first.

A cap on an account's "Usage credits" window (its extra-usage spend,
set as an amount or a share on the usage card) now holds the account
the same way once that much extra usage is spent (Allowance.extraCapped,
called from CapHeld and NearCap). Before, aside windows carried no
amount, so an amount cap on one never held anything; allowanceOf now
gives aside limits their Amount, Of and Unit.

Every route that picks an account goes through capHeld, so the gateway,
groups and fallback obey it alike. Claude Code switching (NextLogin)
already moves off an account on overages. The warm-up sends a held,
used-up account nothing (codexWarmer.held / spentPast; claudeHeldFull
for Claude), since that request would be billed as extra usage. With
every account held, the client is told "has used up a usage window and
is set not to spend extra usage" and how to turn it back on, and the
call's record says "set not to spend extra usage" (Weighed.ExtraUsage).

Not done: Claude Code's hidden /limit-reset. It resets or buys limits
through endpoints Anthropic hasn't published, and calling them would be
mimicking Claude Code's client, which magpie doesn't do. A Claude Code
signed in on its own, not through magpie, still spends extra usage.

Run on mote at 5b0572ae3 + this change; rebased since on ce2ce86ab
(two gui commits on WebView2 and a GC read, no file in common), where
the gui budget tests passed again:
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./...: ok
- go test -timeout 45m ./internal/provider ./internal/gateway
  ./internal/settings ./internal/settingsapi ./internal/gui: all ok
  (gateway 939s; the core script budget passes)
- GUI (node --test, Chromium and WebKit): claude-extra-usage-setting
  (en, zh, zh-TW, ja, de at 1100 and 420), provider-prefs,
  claude-lean-prompt-setting, i18n-keys, account-cap, claude-overages,
  quota-credits: 114 of 114
- gofmt -l: clean

Broken by hand (at the 7eecbcc56 base), each red, then restored:
- HoldCaps' claude case -> TestClaudeNoExtraUsageHoldsAtThePlan,
  TestClaudeNoExtraUsageHoldsTheAccount (gateway)
- extraCapped in CapHeld -> TestClaudeExtraUsageCapHoldsAtThePlan
- aside Amount/Of in allowanceOf -> TestAsideWindowAmountCapHolds,
  TestClaudeExtraUsageCapHoldsAtThePlan, TestClaudeHeldFull
- spentPast in warmNow -> TestWarmUpSendsAHeldAccountNothing
- capHeld's extra flag -> TestClaudeNoExtraUsageHoldsTheAccount
- the row left out of #claudeRunList -> claude-extra-usage-setting
  20 of 20 red

Not tried: a real Claude account on extra usage; the hold was checked
with /usage reads built from the CLI's shape, not a live account past
its plan. The full ./... suite was not run (mote and mica over their
load limits, two full suites queued on mote's suite.lock).
2026-11-13 23:42:57 +08:00
yetone ce2ce86ab4 gui: windows drawn again when the screen comes back, WebView2 without occlusion tracking (aquaarboraurum on X)
aquaarboraurum: on Windows the window that comes back after every
auto-update restart is white. Its title bar and status bar are there,
and its page is alive. A restart by hand or a reload draws it.

AutoRestart only restarts once nothing is going through magpie and the
window has sat unused, which is when the user is away, often with the
screen locked or the display off. A WebView2 window first shown then
can keep a white surface: Chromium's native occlusion tracking takes
every window as covered while the screen is locked, and a surface first
drawn in that state may not be drawn again. Closing the window to the
tray and opening it again, which the reporter did by hand, draws it.

- windowsOptions starts WebView2 with CalculateNativeWinOcclusion
  disabled (occlusionOff), after the user's own features. A user who
  enables it in WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS keeps it on.
  Wails still tells a hidden or minimised window so (put_IsVisible).
- Wails' main-thread window registers for session and display-state
  notifications (watchScreenBack). The app's WndProcInterceptor
  (appWndProc, which still calls screensWndProc) draws each open window
  again (redrawShown) when the session is unlocked or the display comes
  on after being off, as mendOnWake already did on wake.

Not reproduced: the white window never showed on xiaomi-gpu (Windows
11, WebView2 157.0.4341.46). The tries:
- quiet and asked restarts, behind other windows, maximised, under a
  full-screen cover, cloaked, minimised then restored;
- the real sandboxed AutoRestart update path (v0.1.9000 to v0.1.9001
  from a local feed).
The box's screen can't be locked for a test, so the locked-screen case
the fix is aimed at wasn't tried.

Run:
- Windows (xiaomi-gpu, signed-in session):
  - TestRestartedWindowIsDrawn: all 13 modes pass on the fix. The test
    is new and plays the update restart (old process, markQuietRestart,
    AwaitPredecessor, openMain). Each mode now also posts an unlock to
    the app's own main-thread window, checks that the window is drawn
    again and stays drawn, and checks that the msedgewebview2 browser's
    command line has CalculateNativeWinOcclusion disabled.
  - Broken by hand (the interceptor ignoring the unlock, occlusionOff
    returning the list unchanged): red on both checks.
  - go vet ./internal/gui; TestScreenBackFrom,
    TestAppWndProcSaysTheScreenIsBack, TestWebView2* pass.
  - The real update path with exes built from this tree: the new
    process's window came up drawn (10 of 360 sampled points white,
    the same as the old window) over 22s of samples.
- mote:
  - gofmt -l;
  - go vet ./internal/gui/..., GOOS=linux -tags nogui, GOOS=windows;
  - GOOS=windows go build ./..., GOOS=linux go build -tags nogui ./...;
  - go test ./internal/gui (142s) and -tags nogui (95s): ok.

Not run: the full ./... suite. mote and mica were both over their load
(mote's suite.lock had four suites queued). The change is in
internal/gui only.
2026-11-13 23:36:49 +08:00
yetone 6f2d1a5ac0 gui: a read under a tight GC runs on four Ps
A collection every few MB wakes an idle-mark thread on every idle P,
and the reads' own workers keep them spinning in between. On mote
(18 cores), a request-index rebuild spent ~2 s in pthread_cond_signal,
~1 s in usleep and ~0.5 s in pthread_kill out of its ~16 s of CPU. The
reads use 4 workers (prefetchEach) or at most 8 (decodeCache), so they
gain nothing from more Ps. tightenGC now sets GOMAXPROCS to 4 for its
first read, and the last read to end calls runtime.SetDefaultGOMAXPROCS.
A GOMAXPROCS the user set in the environment is left alone.

Run: TestTightGCNarrowsProcs plus the other tight-GC tests in
internal/gui (ok, on mica, 12 cores), go vet and GOOS=windows go vet
./internal/gui, gofmt -l. Broken by hand (narrowProcs not called):
TestTightGCNarrowsProcs fails with "two reads on 12 Ps, want 4".

Real account on mote (75G sandbox HOME, network blocked, mote at load
23-47 on 18 cores): each run forced a request-index rebuild with a new
Anthropic price, then read the process CPU after the page closed and
again 20 s later. v0.1.4061 against this build, alternating:
15.3/15.6, 15.9/14.9, 16.8/14.8, 17.7/14.8, 15.0/12.5 s. Mean 16.1 s
before, 14.5 s after, about 10% less. Earlier, v0.1.4061 itself with
GOMAXPROCS=4 in the environment: 17.0/12.8, 15.6/13.5, 15.6/14.0,
15.9/15.5, 15.2/14.2 s. Peak cores during the rebuild: 2.8 and 2.9
before, 1.9 and 3.1 after.
At the pushed head (rebased on 55327848b): go build and internal/gui tests ok
on mica.
Not run: Linux vet (the WSL distro lacks webkitgtk-6.0 and gtk4), and
a machine with 4 or fewer cores, where nothing changes.
2026-11-13 23:26:11 +08:00
yetone 5b0572ae3b agents: Use Claude Magpie is its own button beside Claude Desktop's switch (xMopf7RF on X)
xMopf7RF read Claude Desktop's row as "connect Desktop first", and
connecting is what changes their own Desktop. They asked for one button
beside Claude Desktop that makes the clone and touches neither their
Desktop nor ~/.claude. The button that does this has been in the row
since v0.1.4029, but it was a quiet link at the end of a long status
line that warns about connecting. Their screenshot has no button at all,
so it was easy to miss or they were on an older version.

Now it is a real button (ag-add) beside the switch, where Claude Code's
model picker stands. The status line no longer holds it. What it does
is unchanged: Separate app on, then connect, which wires only
Claude-Magpie-3p (v0.1.4064 keeps ~/.claude out of it for a new twin).
It shows only while Desktop isn't on magpie and the twin isn't made yet,
on a Mac.

Run:
- At the pushed head, after the rebase: desktop-twin, desktop-isolated, desktop-isolated-claude and i18n-keys
  in Chromium and WebKit, every language, at 1100 and 640px: 38/38 per
  engine. desktop-twin now checks that the button isn't in .ag-st, sits
  level with the switch 8 to 28px left of it, and that the status ends
  before it. It waits for the fold's animations first.
- Every GUI file whose fixture has claude-desktop or isolated (38
  files), both engines: WebKit 345/345. Chromium 343/345: the two reds are
  desktop-tiers ("no tiers square"), red the same at origin/main
  6e03b746b and filed as #6475. Its fixture is wired with no isolated, so
  the button never draws there.
- TestCoreScriptBudget: ok.
- Sandbox HOME on mote with the real Claude.app, at this tree: CLI
  launcher add, then connect, then launcher remove. The original
  Desktop's config.json and claude_desktop_config.json, ~/.claude and
  ~/.claude.json were byte-identical after each step. The twin's script
  exports CLAUDE_CONFIG_DIR=~/.claude-magpie-desktop.

Broken by hand: with the button put back in the status line,
desktop-twin goes red ("in the status line").

Not tried: a click in the real GUI app. The backend calls are the same as
v0.1.4064's, which the sandbox covers.
2026-11-13 23:21:56 +08:00
yetone 55327848bb LESSONS: a budget raise that cut a menu item, and a move out (23457a51f, 817d35ffa) 2026-11-13 23:21:37 +08:00
yetone 6e03b746be gui: plugin pages load on Windows again, their sandboxed frame kept in the window's process (Mute06162 on X)
Mute06162 on X (0.1.4066, Windows): every plugin page (用量速览, 对话,
模型指纹, GPT号池) showed "This page stopped working / <page> didn't
answer", and Codex found "Worker request cancellation setup: The
parameter is incorrect" and "Resuming Windows asset request: The
parameter is incorrect" in the log. Both are Wails' own lines
(request_cancellation_windows.go, v3.0.0-beta.24).

Cause, reproduced on xiaomi-gpu (WebView2 157.0.4341.46): WebView2 runs
the plugin page's frame (sandbox="allow-scripts") in a process of its
own (Chromium's IsolateSandboxedIframes; CDP lists it as an "iframe"
target). Wails registers its WebResourceRequested filter with
AddWebResourceRequestedFilter, and that isn't raised for this process's
requests: the frame got its index.html (a navigation), but bridge.js,
app.js and style.css went to the network as http://wails.localhost/...
and failed with net::ERR_CONNECTION_REFUSED. The bridge never said
hello, so after 10s the page was broken. Wails' request cancellation
auto-attaches the frame's target, takes it for a worker, and its setup
on that session fails with E_INVALIDARG: that is the log line.

Fix: windowsOptions starts WebView2 with IsolateSandboxedIframes
disabled (sharedFrameProcess), merged into the one --disable-features
with the user's own, unless the user enables it in
WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS. This is app-wide, so it covers
every sandboxed frame magpie makes: plugin pages and plugin panels
(pluginpages.js, the only two), in the main window and the tray panel.
The frame keeps its sandbox: an opaque origin (its context's origin is
"://"), its CSP, messages only.

Run:
- Real repro on xiaomi-gpu, sandbox HOME (C:\Users\yeton\magpie-wvf),
  testdata/page-plugin (magpie-usage-glance, the reporter's 用量速览),
  `magpie app` started in the console session by a one-shot scheduled
  task, driven over CDP:
  - origin/main 077421733: the page shows "This page stopped working /
    Usage glance 的页面没有响应"; the frame target's three subresources
    fail ERR_CONNECTION_REFUSED; err.log has "Worker request
    cancellation setup: The parameter is incorrect." on every open.
  - origin/main with --disable-features=IsolateSandboxedIframes set by
    hand in WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS: the frame stays.
  - this change: the card draws (screenshot: "Today, 0 calls, 0 tokens,
    $0.00, Hide cost", so the bridge and usage:summary read work), and
    no Wails line is logged.
- TestWebView2KeepsPluginFramesInTheWindowProcess (new): win-run
  `go test -run WebView2 ./internal/gui` ok on xiaomi-gpu. Broken by
  hand (sharedFrameProcess not called): red on Windows, "disabled 0
  times". TestWebView2ArgsMergeTheUsers and
  TestWebView2ArgsSurviveWailsInit updated for the new default.
- mote: go test ./internal/gui ok (158s).
- mica: go vet ./internal/gui for GOOS=windows, GOOS=linux -tags nogui
  and darwin ok; gofmt -l clean.

Not tried: an older WebView2 runtime (when the runtime turned the
isolation on is not proven; 157 has it), the reporter's other three
plugins (they are frames like this one), Wails' own fix (registering the
filter for every request source kind), and the whole internal/gui
package on Windows.
2026-11-13 23:17:31 +08:00