Commit Graph
5705 Commits
Author SHA1 Message Date
yetone c7c19d49d5 provider: asking whether a model decides copies no list
DecidesModel answered for a remote magpie, and for a provider that lists
its decision models (OpenRouter's), by building decideListed's whole
list (catalog.Live copies every chat model) and scanning it. Every model
of such a provider is asked this from available(), pluginDecisions and
the decider list, so a list of n models was copied n times per look:
0.43 GB of the 4.1 GB a real config allocated over 20 polls of
/api/drift, /api/state and /api/providers (v0.1.2430,
DecidesModel -> decideListed -> catalog.Live -> catalog.Chat).

It now looks the model up in the list as kept (catalog.LiveByID, which
readLive indexes once per read), and catalog.LiveListed says whether the
list has any model, for the Jev fallback decideListed has. The answers
are decideListed's: a remote magpie's models its list marks Decides; a
listed decision list's models; with none listed, OpenRouter's Jev unless
the server marks its own.

TestDecidesModelCopiesNoList: 2000 decision models, each ask under a
twentieth of the list's bytes, for both kinds, and the answers above.
Red on the old code (an ask 869,336 bytes, the list 869,829).

Run at 6a900e0d0 plus this change, on mote: go vet (darwin, windows, linux)
and gofmt of internal/provider and internal/catalog clean;
go test -count=1 -timeout 45m ./internal/provider ./internal/catalog
./internal/agent ./internal/gateway all ok (126s, 0.6s, 612s, 1305s).
2026-11-01 01:55:09 +08:00
yetone 88a0262bf2 claudetui: Claude Code's first-run notes send the run to -p at once, not after 45s
A config folder whose onboarding isn't done (one only -p was run in,
given CLAUDE_CODE_OAUTH_TOKEN) has the interactive mode show "Security
notes: … Press Enter to continue". The helper knew the sign-in screen
but not this one, so it waited out ReadyWait (45s) before running -p.
Now firstRun is matched like signIn: the run is -p at once and the
start is marked broken. Agreeing to the notes is left to the user.

The match is on the screen's words with any space between them one
(strings.Fields): the real 2.1.316 screen didn't match a plain regexp,
since Claude Code draws some spaces by moving the cursor.

Run:
- mote: go test ./internal/claudetui -count=1 ok; go vet for darwin,
  windows, linux; gofmt clean.
- Broken by hand: with the case off, TestShimFallsBackToPrint/first-run
  notes goes red ("wrote 0 lines of 1 in 30s").
- Real, on xiaomi-gpu (Windows 11), Claude Code 2.1.316 (official dist,
  sha256 checked), a real subscription token, a fresh config folder:
  before, "showed no prompt in 45s" and -p at 48s; with the first regexp
  still 45s (the space case above); now "shows its first-run notes" and
  the -p answer at 7.9s and 16.9s (two runs), streamed.

Not tried: WSL with a fresh folder (same helper code path); macOS/Linux
native with a fresh folder.
2026-11-01 01:43:35 +08:00
yetone 6a900e0d04 gui: a poll of the Agents page no longer drops every cached model list
/api/state keeps the state it built in agents-state.json, written only
when the bytes change. They changed on every poll: a stale copy's start
is now less how long it has run, two clock reads apart, so it moved by
microseconds each time (on a real config, only
/agents[1]/staleCopies[i]/since differed between two polls). The file
was written through edit.WriteAtomic, whose write calls
filememo.Forget(). That bumps provider.StampNow, so every 15s poll threw
away each agent's model list and picker (magpieModels, viaMagpie) and
every provider's kept catalog, and the next look built them anew.

- StaleCopies' since is truncated to the second (the check against
  magpie's change still uses the exact time).
- keepState writes through steady.WriteFile (temp, flush, rename), which
  leaves filememo alone: nothing a request reads is built from this file.

Not changed: on Linux and WSL the process list gives a run time in whole
seconds (ps etime), so a copy's since can still move by a second between
polls there; macOS reads the exact start from sysctl.

Run on mote at 7428f3229 + this change:
- go test ./internal/agent ./internal/gui (-count=1 -timeout 45m):
  agent ok (280.8s). gui FAIL in two tests already red on main and
  filed: TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestMainWindowCorners/macOS_26_SDK on macOS 27 (#3949).
- node --test agent-stale-copies.test.cjs: 0 failed.
- go vet (darwin), GOOS=windows go vet of both packages, GOOS=linux go
  vet ./internal/agent, gofmt -l: clean. A Linux vet of internal/gui
  needs gtk4 and webkitgtk-6.0, which neither mote's cross build nor the
  WSL box has.

Broken by hand: without the truncation TestStaleCopySinceSameEachLook
is red (since 08:20:11.5 then 08:20:11.500001); with filememo.Forget()
after the write TestKeptStateLeavesFilememo is red.
2026-11-01 01:28:58 +08:00
yetone 7428f32294 provider: WorkBuddy's mover asks for opencode-workbuddy-auth 0.2.9, whose declared models take images (plugins #572)
kongbai01203 saw WorkBuddy AI's kimi-k3 as image: false. That came from the
models the plugin declares before an account's own list is read (an API
key, or a /v3/config that failed). Those declarations said no model took
images, while both builds' /v3/config mark every model supportsImages.
plugins 6727a1e (workbuddy 0.2.9) declares images for every model except
WorkBuddy AI's GLM models, which drop them. keepMovedCurrent now brings
every moved user up to it.

Run:
- go test -buildvcs=false -count=1 -timeout 45m ./... on mote at this
  commit (rebased on origin/main 4182e68ab, still main's head at push):
  every package ok except internal/gui, with two reds already filed on
  main and unrelated to this change: TestSettingsSaveKeepsWhatItDoesNotSend
  (SearchAll, #4514) and TestMainWindowCorners/macOS_26_SDK (#3949).
  internal/provider, internal/plugin and internal/gateway ok.
- npm view @magpie-community/opencode-workbuddy-auth version
  --prefer-online: 0.2.9.
- The plugin side (in 6727a1e): bun test in packages/workbuddy, 301 pass.
  declared-images.test.mjs goes red (0/2) with index.mjs at the previous
  main. A real chat through the plugin's fetch to www.workbuddy.ai kimi-k3
  with a blue|yellow PNG answered "Blue yellow".

Broken by hand: nothing on this side; the change is the min string.
Not tried: a real moved user's plugin updating from 0.2.8 to 0.2.9
through keepMovedCurrent; WorkBuddy (China) models with a real image.
2026-11-01 01:04:40 +08:00
yetone 4182e68ab4 agent: whether the installed magpie wired an agent is looked up in the bytes read, not a copy
A magpie beside the installed one (a dev build on its own port) asks,
for each field's drift, whether the agent's config names the installed
magpie's gateway (theInstalled). It took edit.Read's copy of the file
and two strings of it: with a Codex config.toml of 1.5 MB (one table
per project trusted) that was 311 MB in 60 drift polls of a sandbox
built from 4a7d1c63a plus the next commit, more than everything else
the poll allocated (219 MB).

It now looks in the bytes filememo keeps, with bytes.Contains, as
nothing is written from them. A magpie on the installed port never
gets here (elsewhere() is false), so users of a release are unchanged.

TestInstalledWiringReadsNoCopy: a 1 MB config wired to the installed
magpie is seen as its, and 10 looks allocate under 1 MB.
TestDriftInstalledMagpie still tells the installed wiring from one to
neither. Broken by hand: the copy and strings put back, red.

Run at this tree on mote: gofmt clean; go vet ./internal/agent on darwin, linux and windows; go test -count=1 -timeout 45m ./internal/agent ok (194.5s)
2026-11-01 00:43:45 +08:00
yetone 9fa11784db provider: a provider's proxy and off switch are read from providers.json as parsed once
A live magpie's heap profile (v0.1.2404, 53 minutes) allocated 3.6 GB of
its 33 GB in provider.load, a parse of the whole providers.json, mostly
for one field of one provider: storedPicks (its proxy, 1.73 GB) and
leftAlone (switched off or hidden, 1.24 GB), asked for each request and
each background look, then customIDs, keptAs, loginSwitching and
accountRemoved.

These six only read, so they now go through storedFile: filememo's
parse of the file, kept until its time or size changes (and its bytes,
written in the last two seconds), and dropped by every write magpie
makes (writePrivate's Forget). A file missing or not decoding goes the
way load goes, to its last good generation. What load's other callers
get is unchanged, as some of them edit what they read before a save.

TestStoredParsedOnceUntilTheFileChanges: 30 providers of 100 models.
storedPicks and leftAlone with the file unchanged take under 40
allocations (a parse is 3381); a provider switched off since is left
alone at once; another process's edit of the same size is seen; a
zeroed file still finds its providers. Broken by hand: storedFile
parsing each time, red (3386 allocations); a broken file read as none,
red.

Run at this tree on mote: gofmt clean; go vet ./internal/provider on darwin, linux and windows; go test -count=1 -timeout 45m ./internal/provider (ok 116.0s) ./internal/gateway (ok 613.2s).
2026-11-01 00:43:15 +08:00
yetone 645eb92f3f gateway: a refusal after shown thinking goes to the next fallback
yhwangl on X: a request whose content trips a vendor's safety filter
after the model streamed its thinking, before any answer, stopped there;
the group's next member was never asked, as it is when credit runs out.

When a model's reasoning is shown, a try passes on its first thinking
event, so a refusal after it was the agent's. Now, for a streamed
Anthropic, Chat or Responses request with another member still to ask
(handsOver), the try's events go out one by one (passOver) and a refusal
or refusal error before any text or tool call hands the request on
(handOver): Anthropic's open blocks are closed and the next member's
stream is spliced into the same reply (spliceAfter): its message_start
or response.created/in_progress/queued are dropped, block indexes or
output_index go after those sent, sequence_number goes on. Chat chunks
go as they come. Once text or a call has gone, a refusal stays the
agent's as before. With no other member nothing changes. A refusal is
about the request, so nobody is rested for it.

Zhipu's finish_reason "sensitive" and error 1301 (敏感), DashScope's
data_inspection_failed and Volcengine Ark's *SensitiveContentDetected
are now read as refusals too.

Not covered (#4604): Gemini clients; a Responses reasoning item handed
over gets no output_item.done and the next completed lists only its own
output; A's thinking signature stays in the reply; non-streamed requests.

Run (mote, worktree at base 3baf3b6df):
- go test -count=1 -timeout 45m ./internal/gateway/...: ok (597s)
- targeted -run 'TestRefusal|TestSensitive|TestThinking|TestDeepSeek|
  TestStreamEvent|TestHighRisk|Refus': ok
- gofmt -l internal/: clean; go vet ./internal/gateway; GOOS=linux go vet
  -tags nogui ./...; GOOS=windows go vet ./...: ok
Rebased on 8a410f35a (5 commits, Claude TUI files in internal/gateway):
go vet ./internal/gateway and the targeted run plus ClaudeTUI|
ClaudeSubscription tests ok at the pushed head.
Broken by hand: handsOver forced to false (the old behaviour):
TestRefusalAfterShownThinkingGoesToTheNext (every upstream x client
subtest: b never asked), TestRefusalHandedOverTwice and
TestDeepSeekRefusalHoldsATrustedMemberAgain red; reverted.
Not tried: a real GLM, DashScope or Ark account tripping its filter, and
a real Claude Code or Codex client reading the spliced stream; the tests
use fake upstreams with GLM's, DeepSeek's and Anthropic's event shapes.
2026-11-01 00:40:07 +08:00
yetone 8a410f35a2 claudetui: Claude Code's interactive mode streams its replies, through a preload that copies the main turn's stream
The owner: make a Claude subscription stream as it goes while Claude
Code runs in its interactive mode (TUI), on macOS, Windows and WSL.
Until now the helper read Claude Code's transcript, which has a message
only once it ends, so a reply came to the client whole.

Claude Code is a Bun program, and Bun loads a script named in
BUN_OPTIONS (--preload) before it. The helper writes tap.js to a folder
of its own and starts Claude Code with BUN_OPTIONS="--preload tap.js"
(after the user's own BUN_OPTIONS, but not a Windows one's for a Claude
Code in WSL, where both go through WSLENV). tap.js makes Bun.FetchSession
a subclass whose fetch is the real one's, so the request, its headers,
its connection and TLS are Claude Code's own. For a reply to a
request marked x-claude-code-request-class: main to /v1/messages that
is text/event-stream, it tees the body: Claude Code reads its copy as
before, and tap.js writes each event, as it comes, as a JSON line to
the file MAGPIE_CLAUDE_TAP names. It takes itself out of BUN_OPTIONS,
execArgv and the environment first, so nothing Claude Code runs
inherits it.

The helper reads that file and tells the events as -p's stream_event
lines, so the gateway reads them as it reads -p's. A transcript message
waits up to 1s for its stream to begin (then it's told whole, its late
stream left out); a turn's end waits for its streams to end; a stream
cut short ends with a message_stop and no message_delta, as -p ends
one. The bridge now keeps the streamed messages by id, since a whole
message can come during the next message's stream, and a client
tool_use shown from the stream isn't told again from the whole message.

On Windows, BUN_OPTIONS has no quoting, so a temp path with a space
takes its short name; one that still has whitespace gets no tap, and
replies come whole, as they do from a Claude Code that isn't Bun or
doesn't send through FetchSession (2.1.281 on Windows doesn't; 2.1.289
and 2.1.316 do).

Run:
- gofmt -l: clean. go vet on mote for darwin, GOOS=linux and
  GOOS=windows: 0.
- go test ./internal/claudetui ./internal/gateway on mote
  (-timeout 45m): ok, ok (gateway 654s).
- go test ./internal/claudetui with win-run (Windows 11) and wsl-run
  (magpie-desktop): ok, ok.
- macOS, real account (Claude Code 2.1.316, sandbox HOME, keychain
  token): a reply came as message_start, text deltas,
  content_block_stop, message_delta, message_stop, then the whole
  message, then the result; stderr clean, the tap's folder removed.
- Windows native, Claude Code 2.1.316 against a fake that sends an SSE
  event every 250ms (a user preload marking the request main, which
  also checks the user's BUN_OPTIONS is kept): the deltas came 250ms
  apart, before the whole message. The same with TEMP holding a space
  (short name).
- WSL magpie-desktop, Claude Code 2.1.289 run through wsl.exe from the
  Windows helper, the fake in WSL: the same.
- The scrub, on macOS and Windows: Claude Code's BUN_OPTIONS and
  execArgv have no tap, MAGPIE_CLAUDE_TAP is gone, --smol is kept.
- Rebased on origin/main 02ff0e908 (no file in common): on mote, vet
  for darwin, windows and linux nogui 0; go test ./internal/claudetui
  ok; -run 'CoreScriptBudget|I18n|Claude|Budget' ./internal/gui ok;
  -run Claude ./internal/gateway ok. In WSL claude-mode, account-weight,
  old-webkit and i18n-keys: 59 of 60, the one red i18n-keys' "Unmarked"
  (#4524).

Broken by hand: the told mark removed, TestClaudeTUIStreamedCallToldOnce
went red; streamed kept as the last id only, TestClaudeTUILateRowOfStreamed
went red; before() made a no-op, and settle's end loop removed, the tap
tests went red. Each was put back.

TestTapMessageWaitsForItsStream failed now and then on mote: the whole
message can be told once its stream has begun, before the rest of the
stream is read. It now checks what is promised: the stream begins
before the message, every event is told, and the result comes last
(-count=30 ok).

Not tried: a real account on Windows or in WSL (the keychain token
went missing mid-session; those runs used the fake, whose request
carries no x-claude-code-request-class since a custom base URL drops
it); a real turn of several messages with the client's tools; Claude
Code 2.1.281 on Windows, which doesn't stream and is told whole as
before.
2026-11-01 00:37:29 +08:00
yetone 535371c8f3 providers: a Claude subscription says whether it runs as Claude Code's interactive mode or claude -p, and why
The owner: the Claude Code provider page should say whether its runs go
through the TUI or the CLI, and what tells them apart and what each gains.

Under a Claude subscription's accounts a row now says "Running as
Claude Code's interactive mode (TUI)" (a green dot) or "Running as
claude -p (CLI)" with why: turned off in Settings, failed to start lately, Claude
Code in WSL whose home wasn't found, not installed, or a system with no
interactive mode. Under the TUI it says which requests still run as -p
(safeguards, a JSON schema, an image by URL, a first message over
400KB). "TUI or -p?" opens what each is: entrypoint cli, the plan
counting a request at about half; entrypoint sdk-cli, about twice.
"Change in Settings" opens Settings › Models at the interactive mode's
row. Only switch, which serves nothing, shows no row.

The mode comes from GET /api/claude/mode (gateway.ClaudeModeNow), read
as the editor opens and kept 30s, never in /api/providers' polls. Its
machine-wide reasons are claudeMachineWhy, which claudePrintWhy now
calls first, so the row and the gateway's own choice can't disagree.
The row is drawn by claudemode.js, which app.js loads with that first
read, so it weighs nothing on the core: after a rebase on origin/main
29d0ab39f the core was 1,541,482 bytes, over its 1,539,856, and the
budget isn't raised. "Runs as" became "Running as" so its keys don't
clash with a plugin's "Runs as" in i18n-keys.
A per-account WSL folder the probe can't read is still found only at
run time; the doc says so.

Run:
- go vet ./internal/gateway ./internal/gui (darwin), GOOS=windows, and
  GOOS=linux -tags nogui: 0.
- go test -run 'ClaudeTUI|ClaudeMachine|ClaudeSub' ./internal/gateway:
  ok (TestClaudeMachineWhy is new).
- After the rebase on 29d0ab39f, on mote: go test -run
  'CoreScriptBudget|I18n|Claude' ./internal/gui ok, the budget not
  raised; old-webkit.test.cjs lists claudemode.js with the other
  scripts app.js imports. Before the rebase, go test ./internal/gui: three reds that fail the
  same on origin/main ccc791231: TestSettingsSaveKeepsWhatItDoesNotSend
  (#4514), TestMainWindowCorners (#3949), and i18n-keys' "Unmarked"
  (#4524).
- claude-mode.test.cjs in WSL (Chromium and WebKit, 1100 and 420, en,
  zh, ja, de): 48 of 48.
- The full GUI suite on mote (load ~30) had 301 reds in 49 files; each
  of those files was run again in WSL at this head (743 tests, 259 red)
  and at origin/main ccc791231 (259 red, the same tests; #4600). The
  one that held apart was account-weight at de web 390: the row puts
  the accounts a screen above By weight on a phone, and Playwright's
  click scrolled the chip back into view. The test now brings the chip
  into view before it measures, so it judges the click's own scrolling;
  account-weight and claude-mode, both engines: 50 of 50.
- After moving the row into claudemode.js: the 142 GUI files with a
  Claude Code agent, in WSL (Chromium and WebKit): 1392 tests, 8 WebKit
  reds in 7 files. Each of those files was run again alone at this head
  and at 29d0ab39f: the same kind of WebKit reds on both, which
  subtests changing from run to run (library-items, number-units,
  routing-rule-models, usage-heatmap, usage-ledger-chart). phone-rows'
  Routing click on .rt-day failed 1 of 4 runs at each (WebKit zh, ja,
  de); the Routing page draws no such row. Filed under #4600, #4471,
  #4112.
- Real use on xiaomi-gpu (Windows 11, sandbox HOME, Claude Code in WSL
  magpie-desktop): /api/claude/mode said {"tui":true,"wsl":true}; with
  the setting turned off through POST /api/settings,
  {"tui":false,"why":"off","wsl":true}; set back, TUI again.
- Rebased on origin/main 02ff0e908 (no file in common): on mote, vet
  for darwin, windows and linux nogui 0; go test ./internal/claudetui
  ok; -run 'CoreScriptBudget|I18n|Claude|Budget' ./internal/gui ok;
  -run Claude ./internal/gateway ok. In WSL claude-mode, account-weight,
  old-webkit and i18n-keys: 59 of 60, the one red i18n-keys' "Unmarked"
  (#4524).

Broken by hand: the editor draws twice before the read returns, and the
test's one-read check went red with two reads until the read in flight
was shared (claudeModeRead).
account-weight's check went red ("en 1000: a click scrolled") with the
chip's click made to scroll the editor 120px.

Not tried: the window on macOS with a real account (the row is the
same code as the web GUI's), and the "broken" reason with a real
failed start.
2026-11-01 00:37:29 +08:00
yetone 02ff0e908f agent: the Codex app's route opens config.toml to see it can be read, not reads it whole
codexAppRoute runs every 3s for as long as magpie does (the Codex app's
app-server watcher). It read the whole of Codex's config.toml with
os.ReadFile only to learn the file could be read; the keys it uses come
from filememo, which parses the file once per change. Codex keeps every
project's trust level in that file, and the owner's is 1.5 MB, so this
was 1.55 GB of the 33 GB a live magpie allocated in 53 minutes (heap
profile: KeepCodexAppOnItsProvider → codexAppStep → os.ReadFile). It is
now opened and closed: a file that can't be opened is still an unknown
route, a missing one still a known one.

Run on mote:
- TestCodexAppRouteReadsNoWholeConfig (new): a 1.6 MB config, 10 looks
  allocate under 1 MB; a config with mode 0 gives no route.
- Broken by hand: ReadFile put back, red (14.4 MB for 10 looks); the
  unreadable check dropped, red.
- go test -run CodexAppRoute ./internal/agent: ok.
- go test -count=1 -timeout 45m ./internal/agent ok (185.3s), at this tree rebased on 4a7d1c63a; gofmt -l clean; go vet ./internal/agent for darwin, linux and windows ok
2026-11-01 00:32:35 +08:00
yetone 4a7d1c63ac provider: Resolve keeps the listed-by map and finds a group without copying the catalog
A live magpie's heap profile (v0.1.2404, 53 minutes) allocated 1.3 GB
in isMagpie -> provider.Resolve, from the window's drift poll asking
every 15s for each model value an agent's settings name:
- a bare model no entry has ("gpt-5.5") built listedBy, every
  provider's whole model list, again on each request: heldOf only kept
  it for one second inside a Hold (835 MB);
- a group ref copied the whole Catalog() to find one group (425 MB).

listedBy now goes through keptOf, the Stamp-keyed store the catalog
already uses, so it is built again only when providers.json, a group or
a setting changes. A group ref is looked up in the groups' own entries
first, and the full catalog stays the fallback.

TestResolveKeptAcrossRequests: three providers with 40 models each and
a group, each request in its own Hold. "group/g", "nope" and "m-b2"
take 44, 43 and 28 allocations once built (bar 60), they resolve right,
and a provider saved since is resolved by the next request. Broken by
hand: heldOf("listed", listedBy) put back, red; the Catalog() copy
first put back, red.

Run at this tree on mote: gofmt -l clean; go vet ./internal/provider
for darwin, linux and windows ok; go test -count=1 -timeout 45m
./internal/provider ok (126.0s), ./internal/agent ok (199.3s),
./internal/gateway ok (595.0s).
2026-11-01 00:28:03 +08:00
yetone 46ca9a6416 provider: a quota reading changes the history it wrote, not a new read of the file
Each new reading of a Codex or Claude account's windows (about one a
minute per account while the window or a client asks) read the whole
quota-history.json, parsed it, parsed it once more in KeepUnparsed to
see it could be written over, and wrote it. On the owner's live magpie
(a 512 KB history: 20 accounts, 39 lines, 5,031 points) that was 1.9 GB
of the 33 GB allocated in 53 minutes: json.Marshal 751 MB, KeepUnparsed
590 MB, readQuotaHist 599 MB.

The history this process wrote last is now kept with the file's stat,
under quotaHistMu. While the file is still that one (same inode, size
and modification time), noteQuotaHistory, MergeQuotaHistory and the
account-move fold change it instead of reading the file, and
writeQuotaHist skips KeepUnparsed: what it wrote parsed. Another
process's write renames a new file in, so it is read again, and a file
that doesn't parse is still kept aside. A failed write drops the copy.

Run on mote:
- TestQuotaHistoryWrittenNotReadAgain (new): six readings after the
  first read the file 0 times; a file another process renamed in is read
  and merged; an unparsed one is kept aside as .bad-*.
- Broken by hand: never using the copy, red (6 reads); ignoring the
  stat, red (the unparsed file not kept aside).
- go test -count=1 -timeout 45m ./internal/provider: ok (103.5s).
- gofmt -l clean; go vet for darwin, linux and windows: ok.
- A/B, 60 readings over a 20-account, 5,000-point history shaped like the
  live one: 238.3 MB and 1.30M mallocs before, 66.6 MB and 0.63M after.

Not tried: a live magpie with real accounts over an hour; the numbers
above are from the live profile's shape, not a new live profile.
json.Marshal of the whole history on each change is still there.
2026-11-01 00:14:17 +08:00
yetone 3baf3b6dfd agent: every agent's magpie options are built once per change, not per Drift poll
viaMagpie is the half of every agent's model picker that magpie serves.
It built CatalogFor, the own and first accounts, and the fast and ultra
picks on every call. The window's /api/drift poll asks each agent's
fields for their options every 15s. In a live magpie's 53-minute heap
profile (v0.1.2404), Claude Code's options alone (claudeViaMagpie)
allocated 4.7 GB of 32.8 GB.

viaMagpie now keeps its list per agent and prefix, the same way
magpieModels does since v0.1.2422. It builds the list again when
provider.StampNow moves, and after a minute for what the stamp can't
see (an account another app signed in to). Each caller gets its own
copy. The two now share stampedLists[T].

Run (mote, at this tree):
- go test ./internal/agent: ok, 191.501s.
- TestViaMagpieKeptWhileCatalogStays, TestMagpieModelsKept... and
  TestIsMagpieKept...: ok.
- go vet ./internal/agent: darwin, linux and windows ok.

Broken by hand, TestViaMagpieKeptWhileCatalogStays goes red each time:
- never kept: FAIL;
- the stamp not compared: FAIL;
- the kept list handed out unshared: FAIL.

Real A/B: magpie web --gateway under the same sandbox HOME as
v0.1.2422's record, 200 GET /api/drift each. Before = v0.1.2422's tree.
The drift JSON is byte-identical.
- allocated under Drift: 2065 MB before, 1717 MB after.
- under viaMagpie: 367 MB before, under pprof's cut after.
- under CatalogFor: 538 MB before, 229 MB after.
- CPU: 1.95s before, 1.80s after.
Most of what is left under Drift in this sandbox is theInstalled's read
of each agent's config. It runs only for a magpie beside the installed
one (this sandbox's gateway port), not for the installed app.
2026-11-01 00:07:57 +08:00
yetone 854fc81619 agent: magpie's model list is built once per change, not per field of every Drift poll
The window asks /api/drift every 15s. Each agent's Drift checks its
fields through magpieValue -> f.Options -> magpieModels, and
magpieModels built the whole catalog every time: CatalogFor, the
prices, Labels and Vision's ranking (provider.Described -> seersRanked).
A live magpie's heap profile (v0.1.2404, 53 minutes) allocated 32.8 GB.
Drift accounts for 14.5 GB of it, and magpieModels for 9.7 GB. The
footprint peak of 882 MB rides on that garbage.

magpieModels now keeps the list it built for each agent. It builds the
list again when provider.StampNow moves: a provider, account, plugin or
setting saved, catalog.Touched, or providers.json, settings.json or the
catalog cache rewritten by another process. It also builds it again
after a minute, for what the stamp can't see. Each caller gets its own
copy (slices.Clone). A model's own lists are clipped, so an append in a
caller's copy can't write into the kept list.

Run (mote, at this tree):
- go test ./internal/agent: ok, 188.985s.
- TestMagpieModelsKeptWhileCatalogStays: ok.
- go vet: darwin and windows ok, for internal/agent and internal/gui.
  Linux vet of internal/gui fails in wails' cgo menu_linux.go
  ("undefined: pointer"); that is the cross-compile from darwin and not
  this change.
- go test ./internal/gui: three reds, each filed already and none in
  code this touches: TestSettingsSaveKeepsWhatItDoesNotSend (#4514),
  TestMainWindowCorners/macOS_26_SDK (#3949), TestColdTurnsTaken
  (#4510).

Broken by hand, the new test goes red each time:
- never kept: 422 vs 407 allocations;
- the stamp not compared: "a provider saved since is not listed";
- the kept list handed out unshared: FAIL.
Removing the Clip lines leaves the test green: its catalog's lists have
no spare capacity. The clip is a guard that wasn't shown to matter.

Real A/B: magpie web --gateway under a sandbox HOME with the owner's
providers, 200 GET /api/drift each. "old" is this tree with
magpieModelsFor = 0. The drift JSON is byte-identical.
- CPU: old 3.45s, new 1.99s.
- allocated under Drift: old 3098 MB, new 2063 MB.
- allocated under magpieModels: old 1049 MB, new 20 MB.
Not tried: the sandbox has no OAuth sign-ins, so subscription models
weren't in its catalog; the live catalog is larger.
viaMagpie (claudeViaMagpie, 4.7 GB live) still builds per call; that is
the next change.
2026-11-01 00:02:15 +08:00
yetone f811bf2918 gateway: a request waiting for body room is not answered 408 (#4511 review)
The previous commit counted a body as still arriving whenever less of it
had been read than its Content-Length. Before the first read that holds
for a request waiting in bodyRoom.take, which is magpie's own wait. Its
client may have sent the whole body already, and a 408 there tells an
SDK to send it again at once, onto a room already full. bodyArriving
now holds only once the body's read has begun ("body" wait seen) and
while no body-room wait is under way. That is the gap between two reads
that #4511's full run raced into.

The patch's TestUnroutedBodyShortOfItsLengthAnswered408 asserted the
408 in the room wait. It is replaced by:
- TestUnroutedBodyRoomWaitNot408: same setup, not a 408.
- TestUnroutedBodyArrivingBetweenReads: not read yet / in the room wait /
  between reads / read whole / no length.

Reproduced #4511 by injecting a gap. waitedBody.Read ended its wait and
slept 30ms after each read, and TestUnroutedTrickledBodyAnswered408
-count=5:
- with the narrowed check: ok 5 of 5;
- with giveUp back to "case u.inBody():": red, answered 504 "held this
  request for 1s without routing", the CI red.

Broken by hand: bodyArriving back to the patch's (length only). Both
new tests fail, and the room wait gets the 408.

Run (on mote, through mote-run):
- Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack
  on c30d3b7b6: 82 packages ok. internal/gui was red only on
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514, SearchAll from
  b09349d17) and TestColdTurnsTaken (#4510). Both are filed, and neither
  touches this stack.
- Rebased onto 29d0ab39f, which changed internal/gateway since then:
  gofmt -l, go vet (darwin, GOOS=linux -tags nogui, GOOS=windows) and
  go test -count=1 ./internal/gateway ./internal/usage ./internal/provider
  ./internal/sessions all ok at the pushed head. go build ./... ok for
  darwin, linux (nogui) and windows.
- go test -race of the gateway tests this stack adds or touches, on
  the stack at fb29cd30f: ok.
2026-10-31 23:35:27 +08:00
ggbdpq 94e46b5fea gateway: a body short of its own Content-Length is answered 408 even with no read under way
The unrouted hold's 408 (the client is still sending its body) was
judged by whether the handler was inside a body read that instant.
unroutedMost can run out between two reads of a trickled body, or
before its first, and there the read's absence answered 504, as if
magpie held the request of its own (#4511, red in a full run). The
body is judged by its state now: less come than the request's own
Content-Length says is still arriving, and the time is the client's.
A body read whole, a length never said and an empty one are judged
by the read alone, as before.

Reviewed and applied from #4511 (ggbdpq, c59083f5f, SHA-256 matches).
The next commit narrows it. As written, a request still waiting for
magpie's own body room, before its first read, was answered 408 "its
body was still arriving". That blames a client whose body may all be
sent already.

Run (on mote, through mote-run):
- Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack
  on c30d3b7b6: 82 packages ok. internal/gui was red only on
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514, SearchAll from
  b09349d17) and TestColdTurnsTaken (#4510). Both are filed, and neither
  touches this stack.
- Rebased onto 29d0ab39f, which changed internal/gateway since then:
  gofmt -l, go vet (darwin, GOOS=linux -tags nogui, GOOS=windows) and
  go test -count=1 ./internal/gateway ./internal/usage ./internal/provider
  ./internal/sessions all ok at the pushed head. go build ./... ok for
  darwin, linux (nogui) and windows.
- go test -race of the gateway tests this stack adds or touches, on
  the stack at fb29cd30f: ok.
2026-10-31 23:35:27 +08:00
ggbdpq cd0875f5a0 provider: a Claude sign-in whose keychain write fails leaves logins.json alone (#4563)
addLogin wrote logins.json before the credential was stored, and a
keychain write that failed (the login keychain out of reach over ssh)
left the account kept all the same: importing the same file again
reported it as already there. The credential is stored first now; the
login is written only once it is in.

Reviewed and applied from #4563 (ggbdpq, 7b42e98a1, SHA-256 matches).
The test runs in signIn's sandbox HOME with a fake `security` first on
PATH that exits 51. proc.Command looks PATH up at call time, so the real
Keychain is never reached. Switching to a saved login still writes its
On marks before the credential: #4592.

Broken by hand: signin.go back at main with the test kept, and
TestClaudeLoginKeychainWriteFailureKeepsLoginsFile fails.

Run (on mote, through mote-run):
- Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack
  on c30d3b7b6: 82 packages ok. internal/gui was red only on
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514, SearchAll from
  b09349d17) and TestColdTurnsTaken (#4510). Both are filed, and neither
  touches this stack.
- Rebased onto 29d0ab39f, which changed internal/gateway since then:
  gofmt -l, go vet (darwin, GOOS=linux -tags nogui, GOOS=windows) and
  go test -count=1 ./internal/gateway ./internal/usage ./internal/provider
  ./internal/sessions all ok at the pushed head. go build ./... ok for
  darwin, linux (nogui) and windows.
- go test -race of the gateway tests this stack adds or touches, on
  the stack at fb29cd30f: ok.
2026-10-31 23:35:27 +08:00
ggbdpq d1b62f4604 usage: price a local session's call at the provider its file names
What changed

A call read from an agent's own session file (omp's model_usage, say) has
no billing provider of ours — its row reads session-unknown — so Pricer
priced it only through the maker lookups, which answer nothing for models
no vendor catalog lists as its own, even when the models.dev catalog
lists the model under the provider the file recorded (openrouter listing
typesafe/jev-1.14 at $0.042/M in, #4278). When the effective price is
unknown and the record is one of those, its session provider now prices
the call — but only what the catalog itself affirms: the very model id,
listed under that provider, with a price. A provider models.dev doesn't
know, a model it lists that provider without, and an entry with no price
stay unpriced, the CSV cost empty, rather than priced at another entry's
guess; the pricer's memo is keyed by the session provider too, so two
files naming different routes price apart.

Run

- go test -tags nogui -run 'TestUnknownProviderPricedBySessionProvider' ./internal/usage — red before (the named route stayed unpriced), green after
- go test -tags nogui ./internal/usage/... — ok
- gofmt -l internal/usage — clean

Generated-by: GLM-5.3-FlashX (ZCode)

Reviewed and applied from #4278 (ggbdpq, 645e80ab2). It differs from
the patch hashed on the issue only in its git-version trailer.

The reporter's own call stays unpriced for now. models.dev's default
api.json, which magpie fetches, does not list openrouter
typesafe/jev-1.14; only api.json?type=all does. #4278 stays open for
that. The Sessions page prices a session-unknown call through its own
priceOf, by model only: #4591.

Broken by hand: ledger.go back at main with the test kept, and
TestUnknownProviderPricedBySessionProvider fails.

Run (on mote, through mote-run):
- Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack
  on c30d3b7b6: 82 packages ok. internal/gui was red only on
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514, SearchAll from
  b09349d17) and TestColdTurnsTaken (#4510). Both are filed, and neither
  touches this stack.
- Rebased onto 29d0ab39f, which changed internal/gateway since then:
  gofmt -l, go vet (darwin, GOOS=linux -tags nogui, GOOS=windows) and
  go test -count=1 ./internal/gateway ./internal/usage ./internal/provider
  ./internal/sessions all ok at the pushed head. go build ./... ok for
  darwin, linux (nogui) and windows.
- go test -race of the gateway tests this stack adds or touches, on
  the stack at fb29cd30f: ok.
2026-10-31 23:35:27 +08:00
yetone c8df9ecbbc gateway: a search round ended without its stop hands on its held text (#4562 review)
textCallRound holds text from where a written call may begin, and gives
it back at KStop. A round whose channel closes without a KStop is one
searchRounds takes as ended, and its held text was lost with it. The
routes without a search give it back at their reply's end
(gateway.go's held(), continuation.go's release), and the round now
does the same after its loop.

The previous commit's doc comment for textCallRound had also been put
between searchReply's comment and its func. searchReply's comment is
back on searchReply.

TestTextCallRoundReleasesHeldAtEnd: a round that sends "Let me look."
and the start of a DSML call, then closes.

Broken by hand: the t.release() taken out. Red: it handed on only
"Let me look.\n\n".

Run (on mote, through mote-run):
- Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack
  on c30d3b7b6: 82 packages ok. internal/gui was red only on
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514, SearchAll from
  b09349d17) and TestColdTurnsTaken (#4510). Both are filed, and neither
  touches this stack.
- Rebased onto 29d0ab39f, which changed internal/gateway since then:
  gofmt -l, go vet (darwin, GOOS=linux -tags nogui, GOOS=windows) and
  go test -count=1 ./internal/gateway ./internal/usage ./internal/provider
  ./internal/sessions all ok at the pushed head. go build ./... ok for
  darwin, linux (nogui) and windows.
- go test -race of the gateway tests this stack adds or touches, on
  the stack at fb29cd30f: ok.
2026-10-31 23:35:27 +08:00
ggbdpq 90f8a10566 gateway: a search route's reply reads the calls written into its text (#4562)
searchReply's rounds answered a request that carried a hosted web
search — Messages' web_search_20250305, Chat's web_search_options,
Responses' web_search — for a model that can't search by itself, and
never ran the text-call recognizer: a call the model wrote into its
text (#823) reached the client as that text, while every route
without a search made it a call (streamTranslated, forwardTranslated
and the relayed Chat stream each wrap their reply in textCallSee or
textCallTidy). The three routes the reporter lists all pass through
searchReply, so its round is wrapped: textCallRound hands every
round's events through a textCallSee over the client's tools plus
magpie's own, and a call written out — the client's or the search
tool itself — is read as the call it is. A reply that made a call of
its own keeps the text as it came, as elsewhere.

A round with no tools keeps the round it was: textCallNames is nil
and the round passes unwrapped.

Verification on the branch's base 4f00a32ff, macOS arm64:
- RED before the fix, GREEN after: TestTextWrittenCallSearchRouted,
  new, asks a Chat fake that writes its Bash call out in DeepSeek's
  DSML through each of the three routes — Messages, Chat
  (web_search_options), Responses — and asks for the call, the text
  around it kept and the markup gone.
- Ablation: search.go back at 4f00a32ff, test kept, all three
  subtests fail again.

Generated-by: GLM-5.3-FlashX (ZCode)

Reviewed and applied from #4562 (ggbdpq, fff5d6435, SHA-256 matches).
The next commit fixes a held tail lost at a round's end, and moves
searchReply's doc comment back onto it.

Broken by hand: the line "ask = textCallRound(q.Tools, ask)" taken
out with the test kept. TestTextWrittenCallSearchRouted fails on
messages, chat and responses.

Run (on mote, through mote-run):
- Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack
  on c30d3b7b6: 82 packages ok. internal/gui was red only on
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514, SearchAll from
  b09349d17) and TestColdTurnsTaken (#4510). Both are filed, and neither
  touches this stack.
- Rebased onto 29d0ab39f, which changed internal/gateway since then:
  gofmt -l, go vet (darwin, GOOS=linux -tags nogui, GOOS=windows) and
  go test -count=1 ./internal/gateway ./internal/usage ./internal/provider
  ./internal/sessions all ok at the pushed head. go build ./... ok for
  darwin, linux (nogui) and windows.
- go test -race of the gateway tests this stack adds or touches, on
  the stack at fb29cd30f: ok.
2026-10-31 23:35:27 +08:00
yetone f2ae7bdecc gateway: plainSchema judges a self-reference by whole segments (#4561 review)
The previous commit's selfRef took a $ref as a self-reference when the
walk's path began with the ref's pointer as a string. So
"#/properties/a" inside /properties/ab, a sibling, was cut down to
{"type":"object"} instead of being resolved. A self-reference is now
the pointer itself or one of its containers: path == ref, or path
begins with ref + "/".

A "#/…" pointer that names nothing where it points also falls back to
its last segment as a $defs or definitions name again, as every ref did
before pointers were walked ("#/components/schemas/Mode" with Mode in
$defs).

TestPlainSchemaSelfRefBySegment covers both.

Broken by hand: selfRef and localRef back to the previous commit, test
kept. Red: "inner" and "mode" both go out as {"type":"object"}.

Not tried: a real Antigravity request with dsh's tool schema. The
fix is in the flattening, and the gateway tests send the result
through a fake upstream.

Run (on mote, through mote-run):
- Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack
  on c30d3b7b6: 82 packages ok. internal/gui was red only on
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514, SearchAll from
  b09349d17) and TestColdTurnsTaken (#4510). Both are filed, and neither
  touches this stack.
- Rebased onto 29d0ab39f, which changed internal/gateway since then:
  gofmt -l, go vet (darwin, GOOS=linux -tags nogui, GOOS=windows) and
  go test -count=1 ./internal/gateway ./internal/usage ./internal/provider
  ./internal/sessions all ok at the pushed head. go build ./... ok for
  darwin, linux (nogui) and windows.
- go test -race of the gateway tests this stack adds or touches, on
  the stack at fb29cd30f: ok.
2026-10-31 23:35:27 +08:00
ggbdpq abaf2c4e8f gateway: plainSchema resolves a $ref into properties (#4561)
A $ref that points inside the schema ("#/properties/func/properties/
triggers/items", as dsh's tool parameters carry one) is a local JSON
pointer like a "#/$defs/x" one, but plainSchema read a ref only by its
$defs or definitions name: the pointer's last segment named nothing
there, and the field it stood for went out as a bare {type: object} on
the Antigravity path, the tool losing that field's shape.

Any local pointer is resolved now, where it names; a self-reference —
a ref to the site or one of its containers — stops at the target's
type alone, as the plugin's googleSchema has it.

A test with the error's path fails on the old code.

Reviewed and applied from #4561 (ggbdpq, branch head ab39ddcbc; the
patch's SHA-256 matches the issue). A review fix follows in the next
commit: selfRef matched a pointer as a string prefix.

Broken by hand: plainSchema back at main with the test kept, and
TestPlainSchemaResolvesPointerIntoProperties fails ("again" goes out as a
bare {"type":"object"}).

Run (on mote, through mote-run):
- Full `go test -tags nogui -count=1 -timeout 45m ./...` with this stack
  on c30d3b7b6: 82 packages ok. internal/gui was red only on
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514, SearchAll from
  b09349d17) and TestColdTurnsTaken (#4510). Both are filed, and neither
  touches this stack.
- Rebased onto 29d0ab39f, which changed internal/gateway since then:
  gofmt -l, go vet (darwin, GOOS=linux -tags nogui, GOOS=windows) and
  go test -count=1 ./internal/gateway ./internal/usage ./internal/provider
  ./internal/sessions all ok at the pushed head. go build ./... ok for
  darwin, linux (nogui) and windows.
- go test -race of the gateway tests this stack adds or touches, on
  the stack at fb29cd30f: ok.
2026-10-31 23:35:27 +08:00
yetone 29d0ab39fb sessions: Antigravity CLI (agy) sessions can be deleted (ysm119 on Discord)
ysm119 (#help) could delete Codex sessions on the Sessions page but not
agy's, and wanted to clear out empty ones. A delete now moves a
conversation to magpie's trash the way agy's own /resume delete (F4)
removes it: brain/<id>/, conversations/<id>.db with the -wal, -shm and
-journal SQLite leaves beside it, and annotations/<id>.pbtxt. Restore puts
them back.

What agy keeps of a conversation, read from real agy 1.4.12 in a sandbox
HOME against a fake Gemini endpoint (the live ~/.gemini was only read):
the files above, presence/<id>.lock, a row in conversation_summaries.db,
an entry in jetbox_summaries_proto.pb, and cache/last_conversations.json.
agy's own delete removes the files, the row and the jetbox entry. It
leaves the lock and last_conversations.json. magpie leaves the row and
jetbox entry too, because agy keeps both files open and jetbox is an
unknown protobuf. agy's /resume list leaves out a row whose files are
gone, so it never lists a deleted conversation.

A conversation agy has open is not deleted: agy flocks presence/<id>.lock
for as long as it has it open, idle too, and a held lock (or one that
can't be tried) is ErrActive. On Windows how agy locks it hasn't been seen,
so the minute since a write decides there alone.

Siblings: Hermes, Alma, OpenCode, ZCode, Cline, Grok Build, Kimi Code and
Claude Desktop (Cowork) sessions still can't be deleted. Each keeps an
index magpie would have to edit or leave stale; filed as #4595 with what
each needs.

Run at d018b9302 (on origin/main c30d3b7b6), then rebased onto 2cca11176,
which changes internal/gateway only; go test ./internal/sessions passed
again at the pushed head:
- mote: gofmt -l internal/sessions clean; go vet ./internal/sessions
  (darwin, GOOS=linux -tags nogui, GOOS=windows -tags nogui); go build
  ./... and the linux/windows nogui builds: ok.
- mote: go test -tags nogui -count=1 -timeout 45m ./...: 82 packages ok,
  internal/gui red only on TestSettingsSaveKeepsWhatItDoesNotSend (#4514)
  and TestColdTurnsTaken (#4510), both filed before and untouched here.
  go test ./internal/gui alone also showed TestMainWindowCorners (#3949).
- Windows (win-run): go test -run Agy ./internal/sessions: both new tests
  pass. TestAgySessions and TestAgyRowOnly are red there already (#4115,
  a /work cwd read as \work).
- Real agy 1.4.12 in a sandbox HOME, with a test binary built from this
  tree: Delete of one of three conversations moved its brain folder,
  .db and .pbtxt. agy's /resume then listed 2 of 3 and Other "No
  conversations available". Restore brought it back, and /resume listed 3.
  Before this, with the files moved by hand, `agy --conversation <id>`
  resumed a restored conversation and appended to it.

Broken by hand (each red in TestAgyDeleteRestore/TestAgyDeleteRowOnly):
agy taken out of Deletable; the presence-lock check turned off (a
conversation agy has open was deleted); only <id>.db moved, not its
-wal/-shm (a fresh -wal wasn't seen as recent, and they'd be left behind).

Not tried: agy on Windows or Linux for real; the GUI suite (no GUI file
changed: the Sessions page shows Delete from /api/sessions/manage's
deletable flag).
2026-10-31 23:10:48 +08:00
yetone 2cca111764 gateway: a 413 byte cap or an overflow tells Codex context_length_exceeded, so it compacts instead of reconnecting 5/5 (celestial_eagle_99230 on Discord)
A Codex user on a DeepSeek model kept getting "stream disconnected
before completion: 1017dp: 413 Request Entity Too Large: a web page,
not an API reply ... (request_too_large)" with "reconnecting 5/5".
The big body took the vendor past keepHeldAfter, so Codex's stream
had begun, and streamError sent response.failed with code
server_error. Codex (codex-api sse/responses_error.rs) reads any code
it doesn't know as Retryable, so it sent the same body five more
times. Each was refused the same way, and nothing compacted.
context_length_exceeded is the one code Codex stops on: it marks the
window full and compacts, and core compact.rs trims the oldest items
for as long as the compaction is refused too.

- streamError: a 413 on the Responses shape is code
  context_length_exceeded, for every Responses client. The text still
  says request_too_large for pi.
- failTo: Codex reads a 413 told by HTTP status as UnexpectedStatus,
  and a 400 context_length_exceeded as InvalidRequest
  (api_bridge.rs). Neither compacts. So when Codex (fromCodex, or
  Claude Code's Codex plugin) asked for a stream, a byte cap or an
  overflow goes to it in a stream even before one began
  (keptAlive.compactsInStream). A vendor's own overflow, released
  until now, goes this way too. Other clients keep the status they got
  before.
- Nothing changes for resting: a 413 still rests nobody, and a group
  still tries the next member first.

Tests: codex_byte_cap_test.go. It replays the reporter's nginx page
mid-stream and before the stream, plus a vendor overflow 400, and
checks a non-Codex client keeps its 413. Red on the old code:
TestCodexByteCapInStreamCompacts got "server_error" (the reporter's
exact text), and both TestCodexByteCapBeforeStreamCompacts cases got
a 413 or 400 JSON. TestStreamErrorByteCapInEveryShape now expects
context_length_exceeded for Responses.

Run on mote (mote-run, this tree): go test ./internal/gateway on the
byte-cap, stream-error, overflow, compact and Codex tests: ok. GOOS=linux
and GOOS=windows go vet ./internal/gateway: ok. gofmt -l: clean.
Full suite: mote-run go test -timeout 45m ./... at fb29cd30f plus this
change (before the gateway-routing.md paragraph, docs only): 82 packages
ok; internal/gui red in two tests this change doesn't reach, both filed:
TestSettingsSaveKeepsWhatItDoesNotSend (SearchAll not kept, #4514) and
TestMainWindowCorners/macOS_26_SDK (macOS 27 toolbar, #3949).

Not tried: a real Codex against a real 413 vendor. Codex's handling
was read from openai/codex main, not run. DeepSeek documents no
request-body byte limit, and whether 1017dp is DeepSeek's own API or
a relay in front of it is unknown.
2026-10-31 22:57:37 +08:00
yetone c30d3b7b63 plugin pages: a page the reader left is told, and let go after 10 minutes unless it keeps itself
A plugin's page kept its frame, with its scripts, timers and
connections, for as long as the window was open once it had been
looked at: show() only hid its view, and a frame in a hidden view isn't
hidden to itself (its visibilityState doesn't change), so a page
couldn't even pause on its own. Asked by the owner: is that by design?
Only the lazy first load was.

- The kernel's leave hook now reaches the page part: the page is told
  {event: "visibility", data: {visible}} as the reader leaves and comes
  back. The bridge has magpie.visible and magpie.onVisibility(fn); hello
  carries visible, for a page left before it said hello.
- A page left 10 minutes (IDLE_MS) has its frame removed and loads again
  when next opened. Back sooner, it is the same frame. Its hello timer is
  cleared, so nothing says it broke.
- magpie.page.keepAlive: true (plugin.PageSpec.KeepAlive, keepAlive in
  /api/plugin-pages) keeps a page however long, for one that works while
  no one looks at it. Anything but true is false, read as raw JSON so a
  wrong type never drops the package's page.
- plugin-runtime.md's page row says so.

Run on mote. The Go suite and most GUI files ran at this change on
557f51dbf. After rebasing onto 30cd39f19 (none of these files changed
upstream), the budgets, TestWindow* and the page GUI files ran again
at this tree:
- plugin-page-idle (new), plugin-page and plugin-panels, chromium and
  webkit: 14/14 at 557f51dbf. At the rebased tree, the first run was
  13/14: plugin-page's chromium "draws in its frame, shut in" was red
  once, and its assertion wasn't kept (#4589). After that: 42/42 over
  3 runs, then 16/16 chromium over 4.
- i18n-keys, plugin-actions, plugin-kinds-discover, plugin-kernel,
  plugin-replaced, plugin-proxy-page: 51/52. The red is i18n-keys'
  "Unmarked", the same on origin/main e0eb74987 (#4524).
- go test -timeout 45m ./...: every package ok except three reds, none in
  code touched here:
  - TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
    TestMainWindowCorners (#3949) fail the same on origin/main e0eb74987.
  - TestUnroutedHeldReportSaved (#4300) failed in the full run only.
    Alone, -count=5, it passes.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., go build ./..., gofmt -l: clean.

Broken by hand: with the leave hook taken out of the page part, the new
test is red in both engines.

Not tried: a real plugin page in the desktop app or WebKitGTK. The
IDLE_MS length (10 minutes) is a judgement, not measured.
2026-10-31 22:39:37 +08:00
yetone b75fa328ce gui: the ban warning is said once, not again beside accounts signed in
The owner, on Claude Code's editor with four Claude accounts in it and
"Claude 账号可能被封禁" shown on Add another: "这里就不要显示可能被封禁了".
A subscription that warns before a sign-in (Claude, Antigravity and the
plugin-served ones with risk) now warns only while it has no account
signed in, and never to sign one of its accounts in again. startSignIn
asks hasLogins(agent), and its o.user, before the risk step. The import
box keeps its note.

What goes with it: Factory's warning offered "Use an API key instead…".
Factory is retired and the Add sheet leaves it out with no account, so
that warning was reachable only beside an account, and no longer is.
Its accounts list's "Add an account by API key…" row still offers the
key; factory-key.test.cjs now starts there. signin-close and
signin-proxy no longer click "Sign in anyway" in editors with accounts.

claude-risk.test.cjs: a new case opens a Claude editor with an account,
clicks Add another, and wants the sign-in asked at once with no warning
(chromium and webkit, en and zh). The first-account case is unchanged.

Run, on the Linux box (magpie-desktop):
- Broken by hand: the old app.js with the new test: red in both engines,
  nothing asked.
- All 46 GUI files that reach a sign-in or the warning, plus i18n-keys:
  739 ok, 2 red. login-import chromium en timed out waiting on its
  import box, then passed 4 of 4 alone. i18n-keys' "a plugin's words are
  its own" is red the same at origin/main fb29cd30f: #4524.
- An earlier run of the same files had claude-setup-token chromium zh
  and deprecated-subscriptions webkit zh red once each; both passed in
  the six-file rerun at this head (74 of 74).

At the pushed head (rebased on fb29cd30f): the four changed GUI files,
60 of 60 ok. go test ./internal/gui on mote: red only in
TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
TestMainWindowCorners/macOS_26_SDK (#3949), both red the same at
origin/main fb29cd30f.

Not tried: the real app, and macOS WebKit (mote's WebKit launches hang).
2026-10-31 22:39:21 +08:00
yetone fb29cd30f9 tray: the Mac's menu bar figures are regular weight, a lone one in the menu bar's own font (qingnianxiaozhe on X)
Beside Surge's speeds and another app's stacked "0 KB/s", magpie's
"93% / 98%" read visibly bolder, and a lone "98%" too small and too
heavy, so the reporter kept it out of the menu bar. mpRowFont drew two
stacked rows in 9.5pt semibold and one row in 11pt medium, both since
ef4edf8c5 (the first drawn image, no owner call on the weight). Now:

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

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

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

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

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

Not tried: the live menu bar beside Surge and iStat Menus (no real
app run; renders only), a non-Retina screen, and the full Go suite
and GUI suite (the change is AppKit drawing in one package).
2026-10-31 22:29:48 +08:00
yetone 30cd39f19b provider: Devin's plugin is 0.1.29 at least, its Claude models keep the client's cache marks (plugins#566)
Devin 0.1.28 asks its Claude models on Anthropic's Messages API and sends
each of the client's blocks as a prompt of its own, with Devin's cache
mark (prompt_cache_options EPHEMERAL) where the client put cache_control.
A grown Claude Code classifier history read 558 tokens from the cache
and wrote ~7.3k again; on a real account it now reads 7,318 and writes
the 560 it grew by (haiku-5-5 and opus-5-5). 0.1.29 says a failed tool
result in its text, "Error: " first, as the chat path does.

npm view @magpie-community/opencode-devin-auth version --prefer-online:
0.1.29 when this landed.

Run: mote-run go test -timeout 45m ./internal/provider/... ok (102.8s).
Not tried: a magpie gateway with Claude Code end to end on the new
plugin.
2026-10-31 22:28:02 +08:00
yetone 59ea5dc8f8 gateway: a failure with this computer off the network rests nobody (usrname1833)
usrname1833 on Discord: with the computer offline, a routing group's
members failed to connect one after another, each rested, and the first
stayed behind the others once the network was back.

A 502 whose error says no connection was made (dial, lookup, refused, no
route, TLS handshake timeout, and Bun's ConnectionRefused / ENOTFOUND
for a plugin's fetch) now asks whether this computer has a network,
unless any upstream answered in the last 15s: no interface up with a
global address means none; otherwise up to three hosts of the user's
other providers (not p's own, not proxied ones, not localhost / LAN) are
dialled at once (2s), and none taking the connection means offline. The
verdict is kept 5s and asked by one request at a time. Offline, the
member is passed over as a down proxy is (failProxy): no rest, no count,
the trace says Fail "offline". One provider that can't connect while
another's host takes a connection, or while replies came lately, still
rests as before.

Covered where every rest passes: restAfterMarked (so decide_group's and
count_tokens' rests too), the serve loop's next-member path, and the last
member's label. Routing page: "network down" tag and a story for the
next-member and last-member cases, in zh, zh-TW, ja and de.

Run (mote, at this tree):
- gofmt -l clean; go vet ./internal/gateway on darwin, GOOS=linux,
  GOOS=windows: ok
- go test -run 'TestOfflineRestsNobody|TestProxyDownDoesNotRest' -v
  ./internal/gateway: ok; go test -timeout 45m ./internal/gateway:
  ok (708s)
- GUI: routing-offline.test.cjs (new) 10/10 and routing-proxy 4/4,
  Chromium + WebKit, en zh zh-TW ja de. Every routing-*.test.cjs at once
  (load 30-44 on mote): 1997 pass, 29 fail. The untouched base 3d063e34f
  gives 1987 pass, 29 fail in the same files, with the subtests shuffled
  (#4585). i18n-keys: only "Unmarked" is red (#4524), as on the base.
Broken by hand: offlineFailure returning false -> TestOfflineRestsNobody
red ("nothing reachable" and "no interface up": Fail other, Rest set);
client.js at HEAD -> routing-offline 0/5 in Chromium.

Not tried: a real machine taken off the network; a plugin (Bun) fetch's
real offline error text (matched from Bun's error names only); providers
behind a proxy (left to failProxy and not dialled); a group whose
members all sit on the local network (near hosts aren't dialled, so
with an interface up their failures still rest); the full ./... suite.
2026-10-31 22:23:18 +08:00
yetone e0eb74987c plugins: a dist branch not read is unknown, not "not on npm", and its read isn't cut off by one ask
ferock on Discord (v0.1.2399): the Plugins page showed the Chat page
plugin (@magpie-community/page-chat, on the community repo's dist
branch only, never on npm) as Coming soon.

Cause: Info asks each package under npmEach (6s). npm said 404, and
npmAsk turned to distInfo -> distPkg, which read the ~1.6MB index.json
(GitHub and the jsDelivr mirror) under that same 6s context, holding
distMu. On a slow link the read was cut off, distPkg returned nil as if
the branch had no such package, and npmInfo kept "not on npm" (ok=true,
empty NPM) for an hour, saved to plugin-npm.json. distWait then held a
new read back for a minute.

Fix:
- distPkg returns (*distPackage, error): nil, nil only when the branch
  was read and lacks the package (or it is out of scope); an error
  wrapping errDistUnread when the branch couldn't be read (last read
  failed or not finished) and the kept index doesn't have it.
- The index is read in its own goroutine (readDist), apart from the
  asker's context, with its own distReadFor (2m). One read at a time
  (distReading); askers wait for it or their own ctx, distMu is not held
  across the network read. A read that ends after its asker stopped
  waiting is kept for the next ask.
- npmAsk: npm's errNotFound with the dist branch unknown becomes the
  dist error, so every caller that keeps "missing" (Info/npmInfo,
  newestOf in store.go, the update checks in updates.go) treats it as
  unknown and asks again. Readme says the branch couldn't be read instead
  of npm's not found. installDist returns the unread error rather than
  "has no".
- mendDist was checked: it reads only local files, no dist read.

Old data: a "not on npm" already kept in plugin-npm.json by an older
build is asked again once it is an hour old, as before.

Tests: TestDistReadSlowerThanAnAskIsntMissing (index.json held past
npmEach: not kept as missing, and the next Info after the read ends has
0.1.7) and TestDistReadFailedIsntMissing (index.json 503: unknown, asked
again; a read branch without the package is still errNotFound).
fakeDist's reset waits for a read under way (distSettled).

Run (mote-run; vet at base 2cfb8351d, tests again at this commit rebased
on origin/main 484b45d82, which changed no Go in plugin or gui; pushed on 7dc8a18d0, which
touches only internal/provider and internal/gateway):
- gofmt -l: nothing
- go vet ./internal/plugin/..., GOOS=windows go vet ./...,
  GOOS=linux go vet -tags nogui ./...: ok
- go test -count=1 -timeout 45m ./internal/plugin/... ./internal/gui/...:
  internal/plugin ok (103.6s). internal/gui FAIL, two tests only, both
  red the same on a fresh origin/main 484b45d82 run alone and filed:
  TestSettingsSaveKeepsWhatItDoesNotSend (SearchAll, #4514) and
  TestMainWindowCorners/macOS_26_SDK on mote's macOS 27 (#3949).

Broken by hand (mote-run, -run DistRead):
- npmAsk's errNotFound -> dist error override removed: both new tests
  red (the market kept an empty entry).
- readDist given the asker's ctx (the old cut-off): the slow test red
  (after the dist answered, still no version).

Not tried: a real slow link or ferock's machine; the real index.json
from the dist branch; the GUI page itself (actionFor already shows a
spinner for a package with no npm entry yet).
2026-10-31 22:22:12 +08:00
yetone 8e9da4e832 provider: Zed's plugin is 0.1.12 at least: a string message content goes as a text block (Been on Discord)
npm view @magpie-community/opencode-zed-auth version --prefer-online: 0.1.12
at landing. The plugin's change: magpie-community/plugins 3e940bc, bun test
49 pass on mote, its new test red 2 of 2 with the change reverted.
2026-10-31 22:21:44 +08:00
yetone 7dc8a18d0e provider: a plugin's Gemini model is tested on generateContent, as the gateway asks it
A plugin's @ai-sdk/google model is served by the gateway on Code Assist,
which it sends to the plugin's fetch as Gemini's generateContent. Test
models kept only chat, Responses, Anthropic and Gemini, so such a model was
sent the body of the plugin's first other API: Zed's cloud read a chat body
as a Google request and answered 400 "failed to parse Google AI request:
missing field contents" for every Gemini model (Been on Discord), while
agents were answered. Its test now goes through the gateway's translator
(testTranslated), with the plugin's longer wait.

Run (mote-run): go test ./internal/provider ./internal/gateway ok (120s,
710s) at e0bb3c30a; go vet ./internal/provider ./internal/gateway on
darwin, GOOS=linux and GOOS=windows ok; after rebasing on 484b45d82,
./internal/provider ok again.
Broken by hand: with the provider change reverted,
TestPluginGeminiModelTestedOnGenerateContent is red (fake-gemini tested on
chat, /v1/chat/completions reached).
Not tried: a real Zed account's Gemini model.
2026-10-31 22:21:29 +08:00
yetone 484b45d825 provider: WorkBuddy's mover asks for plugin 0.2.8, which lifts deepseek-v4.1-flash's 100k cap on copilot.tencent.com (plugins #561)
@magpie-community/opencode-workbuddy-auth 0.2.8 (plugins 42a5055) takes
0.2.7's 100000-token cap on deepseek-v4.1-flash off the China build: three
users' China Free-plan accounts took 110k to 992k-token prompts on it, and
the vendor's own refusal names 1048576 as the maximum. The cap made agents
compact at 100k. A prompt WorkBuddy does find too long is its own 400
"prompt is too long", passed on as it came, which overflowed() reads as an
overflow (no rest, not retried). keepMovedCurrent brings every moved user
to it.

Run: go test -timeout 45m ./internal/provider/... on mote at 63cb1af3c plus this
change: ok. npm view @magpie-community/opencode-workbuddy-auth version
--prefer-online: 0.2.8.

Not tried: a real copilot.tencent.com request (my CN sign-ins answer 401).
2026-10-31 22:16:57 +08:00
yetone 63cb1af3cb library: the MCP router's mark is the bird with its tail routed out to three ends
The owner asked for a mark that says MCP routing and picked, from three
generated drafts, magpie's bird whose tail fans out into lines ending in
dots. It is drawn as SVG on the bird itself, not a picture, so it stays
sharp at 17px and takes the theme's colour: the bird clipped short of its
tail (#bird-notail, beside #bird-tail in index.html), three strokes from
where the tail was and a dot at each end. Every place hubMark draws (the
Library's MCP router row, the Connect an app sheet) gets it.

Run on mote (macOS 27): library-mcp-hub now checks the clip, the three
routes and their ends (red on the old mark). library-*, i18n-keys and
old-webkit, both engines: 895 pass, 5 fail. The reds are i18n-keys
"a plugin's words are its own" (#4524) and library-row-remove's 3
subtests (#4304); both red the same at origin/main 2cfb8351d. Looked at
in dark and light at 17px, 34px and 220px.
2026-10-31 22:06:25 +08:00
yetone 557f51dbf0 library: a skill linked into an app version the update deleted follows it to the current one (tjhhhh on Discord)
tjhhhh: ego lite keeps its skills in its framework's Versions/<v>. After
the app updated, the skill was in the new version's folder, the old folder
was gone, and magpie still linked the old one. dccfefdf7 (#2635) linked new
imports through the app's own steady link (~/.local/share/ego/ego-skills, or
Versions/Current), but a skill brought in before then links straight to the
resolved Versions/<old> path. tjhhhh's case is that old link: an import
made since dccfefdf7 already follows the update
(TestImportedSkillFollowsAppUpdate).

followMovedSkills (skill_moved.go) runs on every read of the Library page,
under the read's link memo, which is restarted when a link is mended. It
also runs as the first step of every sync. For each library skill that is
a link:
- Target gone, and its first missing part named like a version: link the
  same place under the folder's Current/current/latest link. With no such
  link, use the highest version beside it that has a SKILL.md there
  (1.10 after 1.9).
- Target in Versions/<v> while the bundle's Versions/Current links to
  another version with the same skill: link it through Current.
Source.Dir follows. Only the link is replaced (os.Remove of the link, then
dirLink, and the old link is put back if the new one can't be made). A
folder of the library's own, a link the user deleted that isn't a version
(still shown missing), and the app's old version folder are left alone.
docs/subsystems/library.md says so.

Run (all on mote via mote-run):
- New tests on ego lite's real layout (egoLite: framework Versions/<v>,
  Current, ~/.local/share/ego links): TestOldImportFollowsDeletedVersion
  (0.5.1.13 deleted, then 0.6.0.12, then the next update to 0.7.0.1 by
  itself, plus the agents' link through the library),
  TestOldImportFollowsVersionsCurrent (old kept, through Sync()),
  TestOldImportFollowsHighestVersion, TestMovedSkillsLeaveTheRest and
  TestVersionLess. All pass, as do dccfefdf7's three tests.
- Broken by hand: with followMovedSkills returning false at once, the
  three OldImport tests are red.
- go vet -tags nogui ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: clean. gofmt -l: nothing.
- Full go test -tags nogui -count=1 -timeout 45m ./... in a sandbox HOME:
  80 ok, 3 FAIL.
  - internal/library TestReadLooksAtEachFolderOnce was mine: the mend ran
    before the read's memo, so each skill link was looked at twice. Fixed
    (the memo starts first and restarts after a mend). The whole
    internal/library package then passed (75s).
  - internal/gui TestSettingsSaveKeepsWhatItDoesNotSend is red on
    origin/main 3ecc02b78 and ccc791231 alike (#4514, SearchAll).
  - internal/cli TestAgentFieldNameShowsIt failed once under load. It
    passes alone and in a whole internal/cli run, and its message was lost
    to my grep of the log (#4583).
  The full ./... was not run again after the memo fix.
- At the pushed head, rebased on a51776f9c (which changed internal/library
  too): go vet and the whole internal/library package ok (95s).

Not tried: tjhhhh's own machine and ego lite's real update (the layout is
the #2635 fixture, built from iomect's report). Windows junctions to a
deleted version (dirLink is the same call ImportSkill uses). An app that
renames the folder above the version is not followed: it stays missing.
2026-10-31 22:01:45 +08:00
yetone 49b8c64559 dsh: deepseek-acp gets magpie's route in settings.yaml, and the key store is owner-only
liby233 on Discord: dsh in an editor over ACP (deepseek-acp, CodeG, the
desktop app) listed only DeepSeek's own models. Checked against the real
packages from npm (deepseek-acp 0.9.0, dsh 0.2.1-rc.5): deepseek-acp
mounts FileSettings on $DSH_HOME/settings.yaml alone, never profiles/,
and loads the pi-ai plugin only when that file mentions "llm-pi-ai". Its
credentials-local store throws when .credentials.yaml is readable beyond
its owner ("run chmod 600"), so a 0644 store stops it from starting.

- settings.yaml gets llm-pi-ai.providers.magpie, built by the same code
  as the profiles' route (dshPutProviders), at 0600 when magpie creates
  it. It gets no agent-default-model of magpie's. The user's routes,
  other sections, comments, mode and the api they chose for magpie's
  route are kept. Disconnect takes only magpie's route out, and the
  section too when nothing else is left in it.
- dsh 0.2 renames settings.yaml to settings.yaml.imported (over the one
  before) at each full start and imports it into the profile. The
  serving round, Sync, Set and Unwire write it again. The user's own
  import from before magpie's first write is copied once to
  settings.yaml.imported.kept, so magpie's import never overwrites it.
- .credentials.yaml is made owner-only (go-rwx) on every write and every
  Sync, whoever made it 0644. In a WSL distro, a file written through
  \\wsl.localhost comes out 0644, so the chmod runs inside the distro:
  wsl.exe -d <distro> -e chmod go-rwx <path>. A failure is logged and
  doesn't fail the write.

Run:
- internal/agent on mote (ok) and its Dsh/WSL tests on Windows
  (xiaomi-gpu, ok); gofmt; go vet on darwin, GOOS=linux -tags nogui
  and GOOS=windows.
- The new tests (dsh_acp_test.go) were broken by hand, each turning red:
  dshSettingsAgain disabled, ownerOnly disabled, dshKeepImported
  disabled, and the round's call removed.
- Real runs on mote in a sandbox HOME (~/runs/realdsh-home), never a
  live ~/.dsh. After magpie's Pick, real deepseek-acp's session/new
  listed magpie::deepseek/pro and magpie::deepseek/flash; without
  settings.yaml it listed only DeepSeek's. With a 0644 store its boot
  failed with the credentials-local error, and it started once magpie
  had made the store 0600. `dsh --profile web --dump-config` shows
  agent-default-model magpie and the route. `dsh headless` ate
  settings.yaml into the headless profile, and magpie's round
  (dshWiredOnce) wrote it again, after which ACP listed magpie's models
  again.
- On magpie-desktop: `wsl.exe -d magpie-desktop -e chmod go-rwx` takes
  a file written through UNC from 644 to 600.

Not tried:
- magpie's own write into a real WSL distro end to end; only the
  command form above, and fakeWSL in tests.
- A WSL distro has no serving round, so after dsh eats settings.yaml
  there, it comes back only on magpie's next Sync or model pick.
- A dsh from before profiles (config.yaml only) is left as before.

Also: fakeWSL answers the chmod without recording it, since it is neither
a start nor a probe (TestWSLMoreAgentsStopped counts starts).
2026-10-31 22:00:28 +08:00
yetone a51776f9c3 gateway: a socket's turn writes its conversation once, not through json.Marshal twice
Codex sends each turn on its Responses WebSocket with only what came
after the reply before it, and the gateway put the conversation back
together and wrote the body the HTTP route would have had: json.Marshal
of the list, then json.Marshal of the body around it. encoding/json
writes a json.RawMessage through its scanner a byte at a time into a
buffer that doubles and is then copied out, so a 3.2 MB conversation
allocated 9.6 MB on every turn. marshalRaw (#1532) had fixed this for
the HTTP routes' rewrites; the socket's turn was left on json.Marshal.

turnBody writes the same bytes, keys sorted, each value checked by
jsonCheck and compacted with <, > and & and U+2028/2029 escaped, into
one slice sized for them: its length plus the five bytes each <, > and
& grows by, counted with bytes.Count, since code is full of them. A
value encoding/json would refuse still goes to json.Marshal, which says
why. Live heap on the owner's running app had 8.8 MB under this
json.Marshal between collections.

Run on mote (M5 Pro), at this tree:
- TestTurnBodyIsJSONMarshal: byte for byte json.Marshal's for 0, 1 and
  40 pretty-printed items with literal <, >, &, U+2028, U+2029, tabs
  and CJK; nil input is null; a broken item is refused.
- TestTurnBodyWrittenOnce: a 3,225,123-byte turn allocates 3,252,336
  bytes (1.01x); json.Marshal twice, 9,605,256.
  Broken by hand in the mote copy, each red: the escape count dropped
  (2.9x, the slice grew twice); values written without HTML escaping
  (bytes differ for all three sizes); json.Marshal back inside
  turnBody (3.0x).
- TestResponsesSocket* and TestCodexSocket*: ok.
- go vet ./internal/gateway/ for darwin, linux and windows; gofmt clean.
- The whole internal/gateway package at the parent, v0.1.2406: ok (772s).

Real use: this build (go build -tags nogui) in a sandbox HOME with the
owner's DeepSeek key only, magpie serve on 127.0.0.1:3581, and Node 22's
WebSocket on /v1/responses: a 30 KB first turn of 400 lines with
<ZEBRA&n> and code, asked for the last one, answered <ZEBRA&399>; the
second turn, previous_response_id and one new message, asked for the
first, answered <ZEBRA&0>. The log: 2 turns, 1 continued, 88003 bytes
sent on as whole requests.

Not tried: a real Codex CLI session on the socket (the client here
sends what Codex sends: response.create, previous_response_id, input).
2026-10-31 21:58:06 +08:00
yetone 2cfb8351d0 install.sh: a Linux desktop without WebKitGTK 4.1 has it installed through sudo, then gets the desktop app (shuhai)
shuhai on Discord, on f68ddca37's hint: "为什么不能帮用户直接装好?" On a
desktop without WebKitGTK 4.1 the installer put in the terminal build and
told the user to `sudo apt install libwebkit2gtk-4.1-0` and run it again.

Now, on a desktop without the libraries (and with --gui), when someone is
at the terminal, the script installs WebKitGTK 4.1 (GTK 3 comes with it)
with the distribution's package manager, says first in one line what and
why, and installs the desktop app:
- apt-get install -y libwebkit2gtk-4.1-0 (Debian/Ubuntu family), and when
  that fails, apt-get update and once more (lists missing or stale);
- dnf install -y webkit2gtk4.1 (Fedora/RHEL family);
- pacman -S --needed --noconfirm webkit2gtk-4.1 (Arch family; no -Sy, so
  no partial upgrade);
- zypper --non-interactive install libwebkit2gtk-4_1-0 (openSUSE).
Through sudo, which asks for the password itself; as root, without it.
"At the terminal" is /dev/tty opening (in a subshell, since a failed
redirection would end the script): curl | sh gives the script the pipe
for stdin, so every package command reads /dev/tty too, never the script.
No terminal, no sudo, the package manager missing, Void/Gentoo/another
distribution, or the install failing: the terminal build and the command,
as before, with "didn't work (see above)" when it was tried. --tui and
MAGPIE_CLI=1 install no package; a headless computer neither.
MAGPIE_TTY points the check at another file for the tests.
Docs: reference.md Install, README en/zh, docs start (en/zh/ja).

Run:
- sh -n, dash -n; shellcheck -s sh: only SC2010 at the uninstall's
  ls | grep, there before.
- site/install.test.mjs, 5 new tests (fake sudo, id and package managers;
  every distro's command, root without sudo, no tty, no sudo on PATH,
  Void, NixOS, a failing install, apt's update-and-retry, --gui, --tui,
  MAGPIE_CLI, headless): red on origin/main's install.sh (the 5 new fail,
  19 pass), green after. CI's site step (sh -n + node --test
  site/*.test.mjs) at this head, rebased on origin/main: 63/63 on mote
  (macOS sh) and 63/63 on magpie-desktop through wsl-run (/bin/sh = dash).
- Real installs in fresh containers (Docker on xiaomi-gpu, amd64), a user
  u with sudo, DISPLAY=:0, `cat install.sh | sh` (stdin a pipe), the
  terminal kept with setpriv (su -c starts a session without one),
  v0.1.2399/2400 from the real feed; then ldd (nothing missing),
  `magpie version`, and the package query:
  - Debian 12, sudo with a password, typed by expect at sudo's prompt,
    package lists deleted first: install failed "Unable to locate", apt-get
    update, retry ok, desktop app, libwebkit2gtk-4.1-0 installed;
  - Ubuntu 24.04 (NOPASSWD): libwebkit2gtk-4.1-0, desktop app;
  - Fedora 44, password via expect: webkit2gtk4.1, desktop app;
  - Arch (archlinux:latest): webkit2gtk-4.1 2.54.2, desktop app;
  - openSUSE Tumbleweed and Leap 15.6: libwebkit2gtk-4_1-0, desktop app;
  - Debian 12 as root: apt-get without sudo, desktop app;
  - Ubuntu 24.04 --gui: installed, desktop app; --tui: terminal build,
    nothing installed;
  - Debian 12 without -t (no terminal): terminal build + the apt line, no
    install tried; without sudo at a terminal: the same;
  - Ubuntu 20.04 (no WebKitGTK 4.1 in focal): install, update, retry all
    fail "Unable to locate", then the terminal build and the "didn't work
    (see above)" hint.

Not tried: a real desktop VM (the containers fake one with DISPLAY=:0);
the installed app wasn't opened, only `magpie version`. Void and Gentoo
stay hint-only (Gentoo would build WebKit from source). Debian 11 failed
in the container's own setup (archives unreachable), so focal stood in
for a distribution without 4.1. A held dpkg lock (unattended-upgrades)
would fail the install and fall back; not reproduced. On focal the hint
still names libwebkit2gtk-4.1-0, which focal lacks, as before.
2026-10-31 21:52:54 +08:00
yetone ccc791231f gateway: a long turn sent to a Chat upstream is copied once, not five times
A 3.2 MB Codex /v1/responses request served by a Chat provider allocated
about 70 MB in the gateway, and that garbage, at GOGC 100 over the app's
live heap, set the peak footprint. Four copies went:

- unquoteJSON built an escaped string (any text with a newline) in a
  buffer and then copied it into a string; the buffer is the string now
  (unsafe.String, nothing writes to it again), with a copy only when
  \u escapes left more than a quarter of it unused.
- turnIn joined every user text of the conversation (userSaid) only to
  see whether any was there; saysAnything stops at the first.
- buildChat's user message grew a strings.Builder part by part across
  a merged turn; joinTexts sizes it once and takes a lone part as it is.
- marshalItems ran json.Marshal, whose buffer doubles and is then
  copied out, over one message that holds the whole turn. marshalSized
  sizes the maps, lists, strings, bools and ints a body is made of
  first and writes them into one slice of that size, as encoding/json
  writes them (HTML escaped, � for bad UTF-8, U+2028/2029); any
  other value is json.Marshal's own. A []any item, reached by its
  address, is a *any, which went to json.Marshal twice (to size, then
  to write) until it was dereferenced; TestMarshalBodyAllocatesTwoBodies
  caught that at 154 MiB for a 47 MiB body, now 52.

Run on mote (M5 Pro), at this tree:
- TestLongTurnCopiedFewTimes, a 2.0 MB 300-turn Responses body with
  CJK and newlines: read 6.72 MB -> 4.76 MB (3.4x -> 2.4x), turnIn
  1.93 MB -> 10 KB, buildChat 27.3 MB -> 6.06 MB (13.7x -> 3.0x).
  Broken by hand one at a time in the mote copy, each red on its own
  bound: unquote back to string(b) 3.4x; userSaid back in turnIn
  1.9 MB; the Builder back 7.4x; json.Marshal back 6.2x.
- TestMarshalSizedIsJSONMarshal: byte for byte against json.Marshal
  over all 256 bytes, bad UTF-8, a lone surrogate, U+2028/2029, HTML
  characters, keys needing escapes, nil maps and lists, floats,
  RawMessage, pointers, and a func json.Marshal refuses.
- go test -count=1 -timeout 45m ./internal/gateway/: ok (582.9s).
- go vet ./internal/gateway/ for darwin, linux and windows; gofmt clean.
- Gateway bench (120 requests of a 3.2 MB Responses body, 4 at a time,
  through a fake Chat provider, 200 MB ballast held live), 3 runs each,
  old/new: TotalAlloc 8368-8403 MB -> 5889-5891 MB (-30%), GCs 26-27
  -> 18-19, phys_footprint_peak 795/806/807 MB -> 763/762/749 MB,
  CPU 7.89-7.92 s -> 8.01-8.17 s (the size pass costs about what the
  copies saved).

Real use: this build (go build -tags nogui) in a sandbox HOME with the
owner's DeepSeek key only, magpie serve on 127.0.0.1:3581. A 180 KB
/v1/responses request (a long CJK turn with <tag> & "quotes" \ tabs,
a function_call and its output holding U+2028, then a question) to
deepseek/deepseek-flash, served through buildChat: answered with both
code words as sent (<ZEBRA&42>, MANGO), non-streamed and streamed.

Not tried: an Anthropic-in, Chat-out request, and the live app's own
peak (the bench stands in for it).
2026-10-31 21:39:37 +08:00
yetone 7d11f7d428 gui: Rex opens sessions in a Rex session of magpie's own, with none, one or several open (#4565, StringKe)
StringKe tried b9e5bc6cb with the real Rex (server 0.0.1793131181,
Rex Beta 0.1.0) on v0.1.2391: it opened only when Rex had exactly one
session. Outside Rex, `rex run` with no -s exits 3 both for no session
and for several ("session target default is ambiguous"), and exit 3
means not found or ambiguous; magpie then ran `rex new <t> --label <t>`,
and `rex new` has no --label (exit 2). run's --label also names the
block, not the tab, and the CLI can't tell which session the app shows.

Now magpie keeps a Rex session of its own, labelled magpie. openInRex
lists sessions with `rex ls --json` and takes the one labelled exactly
magpie (else magpie in another case), by its full ID since labels can be
shared. It runs `rex run -s <id> --label=<t> --json -- /bin/sh -c ...`
and names the new tab with `rex window rename -s <id> -- <window_id> <t>`
from run's JSON. With no such session, or a 3 from run because it ended
since the list, it runs `rex new magpie --window=<t> -- /bin/sh -c ...`,
whose first tab is so named. Labels go as --flag=value and the rename's
positionals after --, so a title starting with "-" stays a title. Exit 4
still says to open Rex. rexRun now gives stdout only (for the JSON), and
rex's stderr comes back through ExitError for the message.
docs/reference.md's Session terminal paragraph says it.

Every flag was checked against the real rex CLI, not the report: the
snapshot build 0.0.1793420730-g6d0d9a (rex-darwin-arm64.zip from
blob.superlogical.com, sha256 checked against the release API) on mote,
in a sandbox HOME and XDG_RUNTIME_DIR, where rex autostarts a server of
its own. `rex new --help`, `run --help`, `window rename --help`; by hand
with 0, 1, 2 sessions and two labelled magpie/MAGPIE: no -s exits 3
"not found: no sessions" with 0 and "ambiguous" with 2; `new --label`
exits 2; `run -s <full id>` works with any number; `-s magpie` with two
so labelled exits 3 ambiguous; `rex new magpie --window=<t>` names the
first tab; rename sets the tab's label.

Tests: TestOpenInRex runs a fake rex modelled on those answers (target
by full ID or any-case label, 3 for not found and ambiguous alike, 2 for
new --label) with no session, one other, two others, magpie's among two
and two labelled magpie, opening twice each: one magpie session made,
then used, both tabs named. Also a session that ends between ls and run,
exit 4 and exit 1. TestOpenInRexReal runs the same cases against the real
rex when MAGPIE_TEST_REX names one (skipped otherwise), with a server of
its own that it kills and stops at the end.
TestDiscoverTerminalsOffersRex uses the fake with two sessions.

Ran, through mote-run at this tree rebased on origin/main f85a221c9:
- MAGPIE_TEST_REX=<real rex> go test -count=1 ./internal/gui: every test
  ok, TestOpenInRexReal included, except TestSettingsSaveKeepsWhatItDoes-
  NotSend (#4514) and TestMainWindowCorners/macOS_26_SDK (#3949), both
  red the same run alone on a detached origin/main f85a221c9.
- gofmt -l; go vet ./internal/gui; GOOS=linux -tags nogui and
  GOOS=windows go vet ./internal/gui and go build .: ok.
- No rex server or /tmp/rx* left after the tests.

Broke by hand, each red, then restored: the old openInRex (run with no
-s, then new --label): every TestOpenInRex case, the discovery test and
TestOpenInRexReal red ("unknown flag: --label"); the session lookup made
to find none: a second magpie session each time, red in the fake and
the real test; the window rename left out: tabs "Window <id>", red in
both.

Not tried: the Rex app itself (its download needs a Discord sign-in),
so whether Rex.app switches to the magpie session when a tab is added
from outside is not seen; nor whether an autostarted CLI server could
differ from the app's when the app is closed. Not the full go test ./...
(only internal/gui changed), no GUI Playwright run (no JS changed), not
run on Linux or Windows.
2026-10-31 21:38:56 +08:00
yetone f85a221c96 plugins: a plugin installed twice says "another copy" once, not its own name per provider (plugins#565)
ferock (plugins#565) installed the CodeArts / OfficeAce plugin from two
specs. Each copy serves codearts and officeace, so each card got one
clash line per provider, built from the other copy's shownName, which
is the card's own name. In zh it read "CodeArts / OfficeAce 也登录 CodeArts;
由这个插件提供" and then again for OfficeAce.

clashLine is now given groups (clashGroups): a row's clashes grouped by
side (served here or by the other plugin) and by which specs they clash
with, with the provider names joined. When every other spec's name is
this row's own name, the line says another copy of this plugin ({spec})
does it. Otherwise several names use new plural keys, and one name uses
the old key. All four new keys are in zh, zh-TW, ja and de. The
existing zh and zh-TW singular line now reads "{other} 也能登录 {name},
现由这个插件提供" in place of the clipped "也登录 …;由这个插件提供".

Run on mote, at this tree rebased on origin/main 3d063e34f:
- plugin-clash.test.cjs: the new test, "one plugin installed twice
  says so once, not by its own name", covers both specs, every
  language, widths 1100 and 560, Chromium and WebKit. It passes, and
  with the old plugins.js and i18n.js (stashed) it is red, as are the
  zh and zh-TW `serves` lines.
- i18n-keys, gui-de/ja/zh-tw, dates-gui-lang and every plugin*.test.cjs
  in Chromium and WebKit. Before the rebase: 891/899 and 461/468 pass.
  origin/main 3d063e34f alone: 869/877 and 450/457. Every red is the
  same on main, and each is filed: gui-ja's {agent} (#4580, filed here),
  i18n-keys "Unmarked" (#4524), plugin-move-unserved Try again (#4392),
  plugin-card-update (#3079). plugin-namesake ja 440 and the
  "Install asks first" case were red once in the full run. Rerun at
  this head with plugin-card-update, plugin-replaced, i18n-keys,
  gui-zh-tw and gui-de in both engines, they pass (80/81, the one
  red is #4524).
- go test -tags nogui ./internal/gui: the only reds are
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestColdTurnsTaken
  (#4510), both red at 3d063e34f alone. The budgets pass.

Not tried: the real app with the plugin installed twice. The full GUI
suite beyond the plugin and i18n files was not run either, since the change adds no
API call and no shared class or layout.

Rebased on 3ecc02b78 (nav-lamp only), then 73a12e8bf (wsl, no GUI files): after the rebase, plugin-clash and nav-lamp
pass in both engines (32/32 each) and the budget tests pass.
2026-10-31 21:31:09 +08:00
yetone 73a12e8bf6 wsl: a distro's agent folder that is a link is opened where it leads (#4502)
On Windows, adding a skill or switching RTK on for an agent in WSL failed
with `mkdir \\wsl.localhost\<distro>\root\.codex: Cannot create a file
when that file already exists` (linusxiong). In the distro ~/.codex is a
link to /mnt/c/Users/<user>/.codex. Through \\wsl.localhost Windows can't
follow a link the distro has: a mkdir of it says it exists, and nothing
below it can be made, written, read or listed. ggbdpq found and explained
the link (thanks); their patch, which takes that EEXIST as "there", wasn't
used: the writes below the link fail next (its test passed because a
symlink here is followed).

The fix, for every agent folder and every writer through \\wsl.localhost:
- The WSL probe asks `readlink -f` in the distro where each agent folder,
  its skills folder and the folders beside them lead (wslLinkPaths ->
  distro.Links; a $HOME that is itself through a link is left alone), and
  which drive each Windows mount is (win:/mnt/c C: -> distro.Drives).
- distro.open opens a path at or below a link where it leads: on a Windows
  drive, the drive's own path (C:\Users\<user>\.codex); elsewhere in the
  distro, through \\wsl.localhost again. native spells it back through
  the link, so the agent is told its own path.
- A link readlink couldn't resolve is never guessed at: distro.open
  errors, and the agent is unreached (Agent.Unreached: its notice says
  why; every field Set and Sync returns it).
- Writers: the agents' own files (place.join/place.open, every
  filepath.Join(at.home, ...) in internal/agent), the library's WSL
  targets (wslOpen/wslOpened; one "wsl" problem per agent and nothing
  written), RTK (rtkAt, rtkInstall checks agent.WSLOpen before its mkdir),
  the Sessions page's WSL reads (sessions.WSLHome.Open) and the Copilot
  CLI sign-in read (provider.CopilotWSLHomes -> CopilotWSLDirs).
- Not changed: magpie's image MCP server opens arbitrary paths an agent
  in WSL gives it the same way; filed as #4578. Links deeper than the
  probed paths (other than <agent dir>/skills) aren't resolved. A distro
  probed by an older magpie has no Links until probed again (each run).

Run:
- Real Windows box (xiaomi-gpu, distro magpie-desktop, sandbox
  /tmp/x4502/home with .codex -> /mnt/c/Users/yeton/runs/x4502-target/.codex,
  .claude -> /tmp/x4502/data/claude, .pi -> a missing folder), a throwaway
  Windows test running the real probe with that HOME: probe said
  link:.codex /mnt/c/..., link:.claude /tmp/x4502/data/claude, link:.pi,
  win:/mnt/c C:, win:/mnt/d D:. The old way, MkdirAll(\\wsl.localhost\
  magpie-desktop\tmp\x4502\home\.codex\skills\pdf) = "Cannot create a file
  when that file already exists" (the report's error). distro.open wrote
  SKILL.md to C:\Users\yeton\runs\x4502-target\.codex\skills\pdf and to
  \\wsl.localhost\magpie-desktop\tmp\x4502\data\claude\skills\pdf, both
  read back with cat in the distro through the links; .pi said "~/.pi in
  WSL magpie-desktop is a link magpie couldn't follow". Sandbox and target
  removed after.
- New tests with a fake distro whose ~/.codex and ~/.claude are links to
  /mnt/c/... that don't exist here, so, as through \\wsl.localhost,
  nothing below them can be made: TestWSLFolderIsALinkToC,
  TestWSLFolderLinkUnresolved, TestRTKWSLFolderIsALink,
  TestRTKWSLFolderLinkUnresolved (library); TestWSLProbeLinks (runs the
  probe script), TestWSLOpenThroughLinks, TestWSLAgentFolderIsALink
  (config and a Claude session read on C:), TestWSLAgentFolderLinkUnresolved
  (agent).
- Broken by hand: the library tests on the base (with a no-op
  FakeWSLDrives) fail with "mkdir .../home/me/.codex: file exists", the
  report's error; with ggbdpq's patch applied they still fail (the skill
  mkdir, and RTK's hook not written).
- mote: go build ./...; go vet of agent, library, sessions, provider for
  darwin, GOOS=windows (and linux for agent, library); gofmt -l clean;
  go test -timeout 45m ./internal/agent ./internal/library
  ./internal/sessions ./internal/provider: all ok.
- Windows (win-run): the same four packages. The new tests pass (the
  RTK ones skip: the fake distro runs sh). 32 tests are red, all already
  red at the base c63c2136b run on the same box, and filed (#4115, #2808:
  Hermes profiles, Codex keychain, Agy, desktop entries, ...); the Hermes
  ones fail alike on base and branch with -count=3.

- Rebased on origin/main 3ecc02b78 (it changed internal/agent): at this
  head on mote, go build ./..., go vet of the four packages for darwin,
  windows and linux, gofmt -l, go test ./internal/agent ./internal/library:
  ok.

Not tried: the full ./... suite; the GUI (no GUI change; the unreached
notice uses the existing Notice); a real Codex/Claude Code run against
the moved files in the distro.
2026-10-31 21:29:22 +08:00
yetone 3ecc02b78b agent: Claude Desktop is off magpie only when Desktop itself would be (dev_quj on X)
dev_quj on X: "magpie 一直提示Claude Desktop不经过magpie,我重启了依然还是
这个提示" — the Agents row said "已不经过 magpie:配置已变更" while
Desktop ran on magpie.

The check required deploymentMode "3p" in both Claude/ and
Claude-3p/claude_desktop_config.json. Desktop decides otherwise (m4 in
4.4212's and 2.7032's index.pre.js): with a 3p configuration applied it
starts in 3p when the profile has disableDeploymentModeChooser, whatever
deploymentMode says, and otherwise unless Claude-3p's file says "1p". The
Claude folder's deploymentMode is never read. And Desktop 4.4212 deletes
Claude-3p's deploymentMode itself: a stored "1p" with no claude.ai sign-in
is dropped at start (W5r -> "[custom-3p] deploymentMode written { mode:
undefined }") and Desktop relaunches in 3p on magpie. So a file left
without the key, by Desktop or another tool, was called off magpie, and
nothing magpie could do (Reconnect writes "3p" back) kept Desktop from
dropping it again.

desktop3p now asks Desktop's question with the applied profile (magpie's
or the user's for magpie's gateway). The appliedId, address and key
checks are as they were. appReads (the "restart Desktop" notice) reads
the same effective mode instead of the two files' words, so Desktop's own
write at start isn't a change to restart for.

Real Claude Desktop 4.4212.0 (macOS zip, on mote, sandbox
--user-data-dir, never the live config): three starts with magpie's
profile applied and Claude/ {} or "3p"; Claude-3p "1p" + chooser
disabled, "1p" + chooser not set, and {} — each ran in 3p with
apiHost=http://127.0.0.1:3425 in Claude-3p's main.log, and each left
Claude-3p's file without deploymentMode. The "1p", chooser-not-set case
started in 1p, logged "deploymentMode written { mode: undefined }" and
came back in 3p. An earlier start with both files "3p" kept them.

Run at the pushed head on mote (mote busy with other sessions' GUI and
gateway suites, so the touched package only, not the full suite):
go test -count=1 -timeout 45m ./internal/agent: ok
go vet, GOOS=linux go vet, GOOS=windows go vet ./internal/agent: ok
gofmt -l internal/agent: clean

Broken by hand: desktop3p put back to the old rule (both files "3p"):
TestClaudeDesktopModeAsDesktopReadsIt red on the dropped key, the Claude
folder's key gone, "1p" with the chooser disabled, and none with the
chooser on; TestClaudeDesktopChangedSince red too. Green with the fix.
TestClaudeDesktopMSIX and TestClaudeDesktopChangedSince's 1p cases now
turn the chooser on first, as Desktop needs for 1p to count.

Not tried: Windows' Desktop (MSIX or classic) and a real gateway request
from Desktop; a signed-in claude.ai cookie (Desktop keeps "1p" then,
which magpie says only with the chooser on); dev_quj's own files, so
this is the class the report is in, not their proven trigger. No other
desktop agent reads a mode the same way; Codex/WorkBuddy checks unchanged.
2026-10-31 21:11:45 +08:00
yetone ba7c890223 sidebar: the gateway's address at its foot is lit as by a torch too
The owner asked for the gateway address row under Settings to get the
torch light the page rows got in 841025836. It lights the same way:
brightest where the pointer is, falling off along the address, one row
at a time with the others.

- navlamp.js: #sideGw joins the rows the lamp follows.
- app.css: the address's resting ink (--muted) is the lit word's ground
  (--lo); its plain hover ink stands down while the lamp is on, as the
  other rows' does. Its hover ground is kept, as the page rows' is.

Tests: nav-lamp.test.cjs's page-row case gives the window a running
gateway (bootPrefs.sideGateway) and checks the address: lit after Settings,
Settings going out, brightest at the pointer's end by pixels, out off the
sidebar.

Run at this head (on 7e0fe83d4):
- nav-lamp, old-webkit, sidebar, side-toggle on xiaomi-gpu (Windows), both
  engines: 70 pass, 0 fail.
- sidebar-glide chromium is red 3 of 8 here and 3 of 10 on 7e0fe83d4 alone,
  10 of 10 at 841025836: a flake on main since, filed as #4577.

Broken by hand: #sideGw taken out of navlamp.js's selector, the page-row
case red; put back.

Not tried: the real app on Linux and Windows, the whole GUI suite.
2026-10-31 21:10:42 +08:00
yetone 3d063e34fd providers: the editor names a routing group listed alone that keeps a model from agents (hayden4608)
hayden4608 on Discord: with a provider's "Only through routing groups"
switched off, its models still weren't on the Agents page. Switching it
off does bring them back to every list (tried in a sandbox HOME on mote:
POST /api/provider/save unlisted:false, then /api/agent-models/codex,
/api/state's Codex options and provider.Catalog all list them; nothing
caches the old list). What still keeps them out, with the switch off,
is a routing group whose Model lists is "The group alone"
(Group.Unlists, #1783): its members leave every agent's list. The
editor said nothing of it, so the switch looked broken.

The provider's JSON now carries keptBy (provider.GroupKept: model ->
the names of the groups listed alone that keep it out, a signed-in
subscription's models excepted as Catalog excepts them), and the editor
says under the models, and on each chip, which group keeps which model
out and that its Model lists is changed on the Routing page. Words in
zh, zh-TW, ja and de. unlistedByGroups returns the groups' names now
instead of a bool; Catalog and Unlisted read it as before.

Not confirmed for hayden's own setup: the other reasons a model is
missing there are Codex's list in "Only models I pick" (the editor
already names that agent) and GitHub sync bringing the other device's
providers.json back (newer wins per part). The reply asks which.

Run on mote at e94fb18b8 + this change; at this head (rebased on c63c2136b,
which touched internal/provider/visible.go) the provider and gui packages
and the new GUI file ran again with the same results:
- gofmt -l internal/provider internal/gui: clean
- go vet -tags nogui (darwin, GOOS=linux, GOOS=windows) ./internal/provider ./internal/gui: ok
- go test -tags nogui -count=1 ./internal/provider: ok
- go test -tags nogui -count=1 ./internal/gui: one red, TestSettingsSaveKeepsWhatItDoesNotSend
  (SearchAll), filed as #4514, not this change
- GUI, Chromium and WebKit: unlisted-group-kept (new, en/zh/zh-TW/ja/de,
  1000 and 420px), agent-hides-editor, unlisted-models, group-unlists,
  i18n-keys: 67 of 68; the red is i18n-keys' "Unmarked", #4524, not this
  change
- core budget tests: ok (app.js 1,310,619 of 1,316,874, no raise)
Broken by hand: GroupKept's loop out of providerInfo makes
TestUnlistedGroupKeptSaid red (keptBy map[]); the old app.js makes the
new GUI file 0 of 20.
Not run: the full go test ./... (another session's full GUI suite was
on mote); no real Discord user's settings tried.
2026-10-31 21:00:55 +08:00
yetone c63c2136b2 agent: with Claude Code's own models hidden, a tier's model keeps its /model row and the switch rewrites settings.json at once (#4548)
Two gaps in the previous commit's replaceBuiltInOptions:

- writePicker leaves out the row of a model a tier is on at an effort
  (#1616), since Claude Code shows it as that tier's row. With
  replaceBuiltInOptions Claude Code drops the tier rows along with its
  built-in lineup (2.1.316: only the Default row and the picker's own
  stay), so such a model was in /model nowhere. While the switch hides
  Claude Code's own models, every model keeps its row.
- SetOwnModelsHidden saved the setting without catalog.Touched, unlike
  SetHiddenModels, so flipping the switch in the GUI left Claude Code's
  settings.json as it was until some other change re-synced it.

Tests: TestClaudePickerLeavesOutATiersModelAtItsEffort gains the
replace case (Terra on Haiku at max is listed); TestOwnModelsSwitchTellsTheAgents
counts catalog.Changed per flip.

Reviewed and run by yetone at the batch head over cac655c14 (this commit,
the four others from ggbdpq's #4495/#4548/#4512/#3260 patches and the
#4548 follow-up), on mote:
- gofmt -l clean; go vet ./... for darwin, linux (-tags nogui), windows;
  go build ./... for darwin and windows.
- go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gui, with two filed reds: TestSettingsSaveKeepsWhatItDoesNotSend
  (#4514), red alone at origin/main cac655c14 too, and TestColdTurnsTaken
  (#4510), red only in the full run. Rebased afterwards onto e94fb18b8,
  a usage-page change that touches none of these files.
- Windows (xiaomi-gpu): go test -run 'TestVSCode|TestClaudePicker'
  ./internal/agent ok. TestCopilotFolderFromAnIDEPluginIsNotTheCLI is red
  there at cac655c14 too (#1827).
- Broken by hand: each half reverted alone -> TestClaudePickerLeavesOutATiersModelAtItsEffort and TestOwnModelsSwitchTellsTheAgents red.
2026-10-31 20:54:37 +08:00
ggbdpq 509d8e7d14 agent: a portable VS Code reads its User folder in its data folder
YOUIMARK's Windows has Scoop's VS Code 1.143, a portable build: magpie
showed the editor, but its Dir stayed %APPDATA%\Code\User, which doesn't
exist — code.cmd on PATH was detection enough — so the provider, models
and settings.json magpie wrote went where the build never reads.

Before: vscodeUserDir always took the OS's place for the User folder,
%APPDATA% on Windows; only detection ever looked at the editor itself,
by its launcher alone, so any portable build was found and then read
and written in a folder it doesn't use.

Now: a build whose launcher has a data folder beside it is portable, as
VS Code itself takes a build for portable by that folder alone — a zip's
own data folder, or Scoop's, whose apps\vscode\current\data is the
persisted one, current a junction into apps\vscode. Its User folder is
data\user-data\User there: found, wired, connected and disconnected
there. The launcher is found as detection finds it, and a Scoop shim
stands for the launcher the .shim beside it names, which proc.Unwrap
doesn't read. Zoo Code, which keeps its settings in VS Code's User
folder, is laid out by the same function and follows it. An installed
build's launcher has no data folder beside it, and keeps the OS's place;
so does a portable build before its first run, whose launcher alone is
still detection enough, its writes then making the folder where it
reads. VSCodium portable is left as it was: its data folder is named by
its product.json, which no report asks after.

This is the other half of the branch the Copilot-launcher fix came from
(taken along with 6f435677c, since reworked); it shares no code with
that one — this half is only where a portable build keeps its User
folder, not what magpie takes a copilot launcher for.

Run at this head (parent 841025836):
- New TestVSCodePortableUserDir: an installed build with the launcher on
  PATH keeps the OS's User folder; with the data folder beside the
  program the build's Dir is data\user-data\User, it is detected before
  its first run has made the folder, connecting writes magpie's group in
  the data folder's chatLanguageModels.json and disconnecting takes it
  out. New TestVSCodePortableScoopShim: the same through scoop's shims
  folder, the .shim naming the launcher in apps\vscode\current\bin, and
  a shim with no data folder beside the launcher it names staying an
  installed build. Both are red with vscodeUserDir taken back to the
  OS's place ("the portable build's User folder is .../Application
  Support/Code/User", "Scoop's portable VS Code reads ...") and green
  with the change.
- go test -tags nogui ./internal/agent -count=1: green but for
  TestMothX, which fails the same without this change — this machine's
  PATH has a real mothx (fnm), which the test's LookPath finds.
- gofmt -l clean; go vet ./internal/agent for darwin, linux and windows;
  go build ./... for darwin and windows, and for linux ./internal/agent
  (the repo's linux build fails in wails's own code on this machine
  without this change too).

Issue: #3260
Generated-by: GLM-5.3-Flash (ZCode)

Reviewed and run by yetone at the batch head over cac655c14 (this commit,
the four others from ggbdpq's #4495/#4548/#4512/#3260 patches and the
#4548 follow-up), on mote:
- gofmt -l clean; go vet ./... for darwin, linux (-tags nogui), windows;
  go build ./... for darwin and windows.
- go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gui, with two filed reds: TestSettingsSaveKeepsWhatItDoesNotSend
  (#4514), red alone at origin/main cac655c14 too, and TestColdTurnsTaken
  (#4510), red only in the full run. Rebased afterwards onto e94fb18b8,
  a usage-page change that touches none of these files.
- Windows (xiaomi-gpu): go test -run 'TestVSCode|TestClaudePicker'
  ./internal/agent ok. TestCopilotFolderFromAnIDEPluginIsNotTheCLI is red
  there at cac655c14 too (#1827).
- Broken by hand: vscodeUserDir's portable branch off -> TestVSCodePortableUserDir and TestVSCodePortableScoopShim red. Checked against Scoop: extras/vscode.json puts appsscode
2026-10-31 20:54:37 +08:00
ggbdpq 6585315e32 gateway: a DeepSeek member's reasoning streams through once it has answered cleanly three times running (#4512)
c8f199695 holds a member's thinking back for a refusal after it, so
WorkBuddy's filter (plugins #540) never hands the agent a refused
reply's reasoning as if it were an answer. Held, though, DeepSeek group
members kept every request's whole thinking from the agent: its first
token landed only when the first answer delta did (#4512, with the
reporter's per-line SSE timings; direct connections were never held).

Claude's, GPT's and Gemini's thinking is still held whatever the member
has answered lately (#248). DeepSeek's now streams through as it comes
once the member has gone on from its thinking to an answer three times
running (thoughtCleanMost); one refusal takes the trust back, and a
content_filter stop with nothing said does too. The count is per
"<provider>/<model>", and #248's per-vendor split is why the trust is
DeepSeek-only: the held vendors refuse after thinking by design, the
one that hardly ever does is the one whose hold the agent keeps paying
for.

Tests: TestDeepSeekThinkingStreamsOnceTrusted (three clean thinking
replies, then reasoning deltas arrive before any answer delta) and
TestDeepSeekRefusalHoldsATrustedMemberAgain (a refusal re-holds the
next try) cover the trust and its withdrawal; the refusal-family tests
including TestDeepSeekRefusalAfterThinkingFailsOver keep the original
WorkBuddy hold intact.

Verification on the base 91ffe5429, macOS arm64, Go with pinned
GOFLAGS: 8 targeted hold/thinking tests ok; gateway package full
-tags nogui; gofmt, vet on darwin/linux/windows and builds on all
three platforms clean; pre-existing sandbox failures untouched.

Generated-by: GLM-5.3-Flash (ZCode)

Reviewed and run by yetone at the batch head over cac655c14 (this commit,
the four others from ggbdpq's #4495/#4548/#4512/#3260 patches and the
#4548 follow-up), on mote:
- gofmt -l clean; go vet ./... for darwin, linux (-tags nogui), windows;
  go build ./... for darwin and windows.
- go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gui, with two filed reds: TestSettingsSaveKeepsWhatItDoesNotSend
  (#4514), red alone at origin/main cac655c14 too, and TestColdTurnsTaken
  (#4510), red only in the full run. Rebased afterwards onto e94fb18b8,
  a usage-page change that touches none of these files.
- Windows (xiaomi-gpu): go test -run 'TestVSCode|TestClaudePicker'
  ./internal/agent ok. TestCopilotFolderFromAnIDEPluginIsNotTheCLI is red
  there at cac655c14 too (#1827).
- Broken by hand: thinkingShown back to !refusesAfterThinking(c.model) -> TestDeepSeekThinkingStreamsOnceTrusted and TestDeepSeekRefusalHoldsATrustedMemberAgain red in 1.5s (no hang). Not tried: a real DeepSeek member in a group. Trade-off kept: once trusted, a member's rare refusal after thinking reaches the agent once (nothing said) before it is held again; trust is per process and builds only from replies that report output tokens.
2026-10-31 20:54:37 +08:00
ggbdpq 2672ba429b agent: Claude Code's /model honors the own-models switch too (#4548)
The "show the agent's own models" switch filtered magpie's pickers
alone (agent.Picks, #1642): Claude Code's own /model rows stayed put,
because nothing magpie wrote for Claude Code looked at the switch —
while /model is fed by magpie all the same (modelPicker's rows are
writePicker's). raclen traced the whole chain (#4548).

writePicker now sets modelPicker.replaceBuiltInOptions (Claude Code's
own key: with it the /model picker shows only the listed rows) while
the switch is off, and drops the flag again when it is on, so the
whole picker is written either way. The Default row stays under both
settings: Claude Code keeps it as its own fallback.

Tests: TestClaudePickerOwnModelsSwitch writes a settings.json and
checks modelPicker carries the rows plus the flag with the switch
off, and the flag without it with the switch on.

Verification on the base 5d955a4d4, macOS arm64: agent package
-targets nogui; gofmt, vet on darwin/linux/windows and builds clean.
Claude Code's reading of the key is per its documented modelPicker
behavior (code.claude.com/docs, model-config); the Default-row
fallback shape is per the reporter's capture, not re-run here.

Generated-by: GLM-5.3-Flash (ZCode)

Reviewed and run by yetone at the batch head over cac655c14 (this commit,
the four others from ggbdpq's #4495/#4548/#4512/#3260 patches and the
#4548 follow-up), on mote:
- gofmt -l clean; go vet ./... for darwin, linux (-tags nogui), windows;
  go build ./... for darwin and windows.
- go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gui, with two filed reds: TestSettingsSaveKeepsWhatItDoesNotSend
  (#4514), red alone at origin/main cac655c14 too, and TestColdTurnsTaken
  (#4510), red only in the full run. Rebased afterwards onto e94fb18b8,
  a usage-page change that touches none of these files.
- Windows (xiaomi-gpu): go test -run 'TestVSCode|TestClaudePicker'
  ./internal/agent ok. TestCopilotFolderFromAnIDEPluginIsNotTheCLI is red
  there at cac655c14 too (#1827).
- Broken by hand: the replaceBuiltInOptions line dropped -> TestClaudePickerOwnModelsSwitch red. Not tried: a real Claude Code /model with the switch flipped (2.1.316's handling of the flag was read from its binary).
2026-10-31 20:54:37 +08:00
ggbdpq 7804dfbb03 gateway: drop the locked sampling fields for Kimi on Volcengine Ark too
Volcengine Ark's plans lock the sampling parameters of the Kimi models
they serve: any request carrying temperature != 1 is refused 400
"Volcengine Ark: `temperature` only 1 is allowed for this model"
(#4495, kimi-k3.1-pro / kimi-k3 / kimi-k2.8-preview at
ark.cn-beijing.volces.com/api/coding/v3), before any token is read —
clients that send their own defaults (Claude Code, Copilot) fail every
call, and a routing group spends its failover window on each try.

kimiLockedSampling already drops temperature and top_p for the locked
models on Moonshot's own endpoints (#1197), but its isKimi guard knows
only Moonshot's hosts and presets, so the same models behind an Ark
host went through with the fields. The refusal names the model ("for
this model"), not the path, and the preset's Agent Plan and pay-as-you-
go regions list the same kimi-kX.Y models, so the guard now also takes
isArk — the ark.<region>.volces.com check the draw and video code
already uses, which covers the preset's plans and a provider added by
hand — and kimiLockedSamplingModel keeps deciding per model, as it
already does for kimi-k2.5 and later, kimi-for-coding* and k3*. Ark's
other models (doubao, glm, deepseek, minimax) are untouched, as is
everyone not served by Moonshot or Ark.

Run: TestKimiLockedSampling in internal/gateway grew four cases (the
coding plan's chat and anthropic routes, an Ark model the server
doesn't lock, a provider added by hand on an Ark host): the three drop
cases fail on the unmodified code and pass with it, the keep case
passes throughout. go test -tags nogui ./internal/gateway ok (499s);
gofmt clean; go vet -tags nogui on darwin, linux and windows clean;
go build -tags nogui ./... on darwin, linux and windows ok.

Generated-by: GLM-5.3-Flash (ZCode)

Reviewed and run by yetone at the batch head over cac655c14 (this commit,
the four others from ggbdpq's #4495/#4548/#4512/#3260 patches and the
#4548 follow-up), on mote:
- gofmt -l clean; go vet ./... for darwin, linux (-tags nogui), windows;
  go build ./... for darwin and windows.
- go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gui, with two filed reds: TestSettingsSaveKeepsWhatItDoesNotSend
  (#4514), red alone at origin/main cac655c14 too, and TestColdTurnsTaken
  (#4510), red only in the full run. Rebased afterwards onto e94fb18b8,
  a usage-page change that touches none of these files.
- Windows (xiaomi-gpu): go test -run 'TestVSCode|TestClaudePicker'
  ./internal/agent ok. TestCopilotFolderFromAnIDEPluginIsNotTheCLI is red
  there at cac655c14 too (#1827).
- Broken by hand: guard back to !isKimi(p, to) -> three TestKimiLockedSampling subtests red (volcengine coding plan, its anthropic endpoint, a hand-added Ark host). Not tried: a real Volcengine Ark Kimi request.
2026-10-31 20:54:37 +08:00