Commit Graph
8243 Commits
Author SHA1 Message Date
yetone a71aa25d22 routing: a session's Avg. speed says the wait for the first token is left out, and gives the speed with it counted
@verymoes on X (tweet 2121533934332985393): an opencode session over
the Command Code plugin read "平均速率 142 token/秒" on Routing's
By session row, while CC Switch read ≈77 tok/s for the same 26-27
requests and opencode's footer 76.7 tok/s, and asked whether magpie
counts wrong.

It doesn't; the three divide by different times. magpie's average is
Σ answer tokens over Σ (end − first token) of the timed replies
(decodeOf; for a reply that reasoned, its answer from its first text),
so the wait for the first token is left out. CC Switch's "≈" is its
estimate from the session log's timestamps, which it documents as
counting the wait for the first token (src/components/usage/format.ts,
docs/user-manual 4.4). opencode's footer is one turn, not the session,
and counted from the request until #63321 (11-11) moved it to the first
streamed token, with reasoning tokens added in. With a ~28K-token
prompt each and short agent replies, the wait is about half of a
request's time, which is the gap. Nothing in the measurement is wrong,
so it isn't changed; the tooltip now says what it measures:

- "the time from each reply's first token to its end; the wait for the
  first token, and replies without usable timing, are left out" in
  place of "total decode time; excludes waiting";
- a line with the same timed replies over their whole time, the wait
  and the reasoning counted ("Over each request's whole time ...:
  N tok/s"), the number a tool that times the whole request reads.
In zh, zh-TW, ja and de. The Usage page's speeds and a row's own speed
already say "from its first token to its end".

routing-request-metrics checks the tooltip's wording and its whole-time
number (4,000 tokens over 82 s, 49 tok/s, beside the 133 average) in
en and zh, both engines.

Run on mica at this tree (mote was over its 18 cores):
- node --test, Chromium then WebKit: routing-request-metrics,
  reasoning-speed, routing-burst-speed, routing-speed-first,
  routing-row-floor-speed, routing-sessions, routing-by-key,
  routing-session-title, i18n-keys, gui-ja, gui-de, gui-zh-tw.
  Chromium 191/191; WebKit 101/102, the one red reasoning-speed's
  cut-off fetch (#1350), fixed in the commit before this.
- Broken by hand: the test against the old client.js and i18n.js is red
  in all four (chromium/webkit × en/zh) at "the tooltip says the wait
  for the first token is left out".
No Go code changed. Not tried with the reporter's data: their session
isn't on this machine, and the owner's Command Code account answers
401.
2026-11-14 18:01:16 +08:00
yetone ee4a4c7432 gui tests: reasoning-speed leaves WebKit's cut-off fetch out of its page errors (#1350)
The test goes from Routing to Usage, and WebKit reports the Routing
page's /api/gateway/session-titles fetch that the goto cuts off as a
page error ("... due to access control checks"), though the page
catches it. webkit zh-TW and zh went red that way in 2 of 7 runs on
mica. The filter is the one builtin-places, checkin-account and
checkin-at already use for #1350.

Run on mica: BROWSER=webkit node --test reasoning-speed 4 times, and
both engines once after it (results in the next commit's record).
2026-11-14 18:01:16 +08:00
yetone 683265e867 gateway: spawn_agent names every model in Codex 0.169's Lite and catalog requests
@m0eaki on X (Codex 0.169): spawn_agent listed only Codex's first five
models, though a remote magpie's model could be spawned by its full slug.
In Codex 0.169 a lead on one of OpenAI's own models (the Codex App's
default) sends Lite requests (use_responses_lite), with no top-level
tools: in multi-agent V2 spawn_agent sits in an additional_tools input
item, and with features.model_catalog_in_context the models are in a
<model_catalog> developer message, spawn_agent pointing there. magpie
widened only tools and tool_search_output, so neither was reached.

spawnAgentModels now widens additional_tools like a tool_search_output,
and adds the rest of the catalog to a <model_catalog> listing ahead of
its closing tag, under the same neutral spawnMore line (no magpie, Codex
or count named). The listing is found escaped too (<model_catalog>):
on CodexPath a followed or moved subagent's body goes through withModel,
whose encoder escapes angle brackets, before spawnAgentModels sees it.

Fixtures are real Codex 0.169.0 captures (second request of a turn, sandbox
CODEX_HOME, gpt-5.6-luna): V2 Lite, model_catalog_in_context, Lite with a
tool search, and a plain tool search. TestSpawnAgentNamesEveryModelInCodex0169
posts each at CodexPath with a lead on OpenAI's model, and calls
spawnAgentModels with a lead on magpie's at CodexPath and /v1, the body as
Codex wrote it and as withModel writes it again.

Sibling left alone, filed: #6639 (a Lite request reshaped for a provider
that takes neither Lite's items nor a tool search drops the tools its lead
searched for).

Run:
- Old codex_spawn_models.go: V2 and model_catalog red on all 5 routes
  each (10 subtests); the two tool-search shapes passed before too.
- Broken by hand: hasSpawnCatalog matching only the raw form: the three
  escaped-body model_catalog subtests go red. Restored, green.
- gofmt -l clean. go vet ./internal/gateway and GOOS=windows go vet ./internal/gateway (./... needs Wails' cgo, which the VM lacks), and
  go test ./internal/gateway -count=1 -timeout 45m: vet clean, gateway ok (861s), at base d987cc7d5. Rebased on 69946f43c (gateway: masked_checked_test.go, native.go changed); there vet and -run "Spawn|Codex" ok (187s)
- Ran in the Linux VM (wsl-run): mote was at load 25-27 on 18 cores and
  mica's disk was full (595MB free, 64G shared Go cache), so no full
  ./... suite was run on a Mac. Not tried: a real Codex App session.
2026-11-14 18:00:13 +08:00
yetone 69946f43c4 cli: POST /api/page-away is named as the window's own, so the route parity test is green
80a315a70 added POST /api/page-away, the page saying it went from view
so its Sessions and Usage caches can go. It has no CLI meaning, and
TestEveryRouteHasACommandOrIsNamed was red on main for it. It is now
in notYet as a window route.

Run: go test -run TestEveryRouteHasACommandOrIsNamed ./internal/cli on
mote at origin/main 75f872ef1: red before, ok after.
2026-11-14 17:48:48 +08:00
yetone 81825ed81d agent: fx gets each model's reasoning levels through magpie (@beillusyn on X)
fx through magpie had no effort to pick: magpie wrote its models into
fx's settings without levels, so fx sent no reasoning_effort and every
model ran at its vendor's default.

fx 0.0.17 reads a model's reasoning_efforts in model_metadata (level
name to request fields, listed in /effort and Ctrl+T). magpie now writes
each model's catalog levels there, weakest first, each asked as
{"reasoning_effort": <level>}. Levels fx refuses are left out: auto,
adaptive, default (its word for "none picked"), names outside
[A-Za-z0-9._-]{1,64}, duplicates, and past 16 a model. With no level
picked fx sends none and the vendor's default applies, as before.

fx 0.0.16 refuses an unknown model_metadata key (UnknownField) and with
it the whole settings file, so the levels are written only when fx at
the place says 0.0.17 or later (~/.local/bin/fx, else fx on PATH; a
version not 0.x is the JSON viewer also named fx). An unknown version
gets no levels, and a sync after fx is upgraded writes them. fx's own
effort setting (top level and per workspace) is the user's and stays.

Left alone: fx inside a WSL distro has no version probe, so it gets no
levels (#6636).

Run:
- go test ./internal/agent -run 'TestFx|TestWSL' on mica: ok.
  TestFxEfforts (exact ordered JSON at 0.0.17, the user's effort and
  workspace effort kept, levels gone at 0.0.16 and unknown, back at
  0.0.18), TestFxEffortNames, TestFxVersionIsTheAgents.
- Broken by hand, each red: fxTakesEfforts always true (TestFxEfforts),
  no 0.x check (TestFxVersionIsTheAgents), a sorted map for the levels
  (the order checks).
- Real fx on mica, sandbox HOME, magpie-written settings, a fake chat
  completions server: fx 0.0.17 dev (3c8fab37) --effort high sent
  reasoning_effort high; no effort sent none; --effort xhigh on a model
  without it said so and sent none; --effort none sent "none". fx 0.0.16
  with the levels failed with UnknownField; without them it worked.
  fxVersion read the real binaries as "0.0.17" (takes levels) and
  "0.0.16" (doesn't).
- Full suite on mote (mica out of disk) at d987cc7d5 plus this change,
  -timeout 45m: 98 packages ok, two red. TestNoEagerPackageRegexps
  was this change's package-level regexp, now lazyre.New; after it,
  that test and TestFx/TestWSL ok again at origin/main 75f872ef1.
  TestEveryRouteHasACommandOrIsNamed (POST /api/page-away, from
  80a315a70) is red on main and fixed in the next commit.
- GOOS=linux and GOOS=windows go vet ./internal/agent on mote: ok.
  gofmt -l clean.

Not tried: fx in WSL; a real vendor through the real gateway.
2026-11-14 17:48:48 +08:00
yetone 75f872ef19 sessions: a page gone from view lets the parsed session files go in 30 s, not 3 minutes
v0.1.4150's away timer let the Sessions stats and the Requests chunks go
30 s after the app's page went from view, but a web page open 70 s and
closed still held 92-93 MB 45 and 90 s on. A heap taken 45 s after the
close (liveHeap 57 MB, 15 MB at +180 s) showed why: opening the page
starts the warm-up (warmStart), which parses every session file, and
those parses (decodeCache, the listings, Codex identities: ~40 MB live
for the acctp history) go only by the sessions package's own cacheIdle,
3 minutes after their last read.

forgetAwayPage now also calls sessions.ForgetParses, which is
dropIdleCache without the 3-minute wait (dropCache(0)): it still keeps
the parses while a save isn't on disk, the last failed, or a file is
being parsed, and the next read has them back from sessions.json with
no session file read. It runs only when the stats went too, so a range
being read keeps them.

Test: TestForgetParsesLetsGoAtOnce (red with ForgetParses waiting
cacheIdle, broken by hand).
Measured on mote (pageclose2.sh, acctp, page open 70 s and closed,
footprint-overlay build like the release):
  v0.1.4150 (w90): close 122 MB, +45 s 93, +90 s 90, +180 s 55, +600 s 52
  this (w92):      close 125 MB, +45 s 64, +90 s 61, +180 s 56, +600 s 53
A debug build (w91) logged the away timer firing with no read since,
so the 90 MB left was this cache, not a skipped let-go.

Run: go test ./internal/sessions ./internal/gui ./internal/usage on mote
(ok); GOOS=linux go vet -tags nogui and GOOS=windows go vet of the two
packages (ok).
2026-11-14 17:45:41 +08:00
yetone 3932d01acf provider: ZCode's mover min is 0.1.64, which queues a Start Plan request refused beside the account's others (JJLIN070414 on X)
Two sessions on ZCode's Start Plan showed 429s: an account ZCode serves
one at a time refused the second request (3008), and the plugin handed
it back after its 1s and 2s re-asks. 0.1.64 (plugins 8e19b6a0) narrows
the account's gate and requeues that request until the other ends, as
ZCode's own client queues a capped request. The min makes
keepMovedCurrent update every moved user; it also carries 0.1.62 and
0.1.63 (plugins 3f37b858).

Run: npm view --prefer-online shows 0.1.64; on mica, go test -tags nogui
-run 'Moved|Mover|Migrat|ZCode' ./internal/provider ok; gofmt clean.
Plugin: packages/zcode bun test 262 pass, 0 fail; the three requeue
tests red with the requeue turned off.
Not tried: a full go test ./... before the tag, a real Start Plan
account with two sessions.
2026-11-14 17:39:09 +08:00
yetone b592c1fde1 masking: the page counts each agent's requests looked over, nothing masked in them or not
eiyuuzaki2333 on X: the Gateway page showed Pi's calls, the Masking page
records from dsh alone, and nothing said whether Pi's requests were
masked. They were: a Pi turn goes through the same masking as every
agent's, on each API Pi uses (chat completions, responses, messages),
with no agent or protocol scoping. But a record is made only for a
request masking changed (noteMasked: hits or held values), and the
page's agents came from records alone, so an agent whose requests
carried nothing to mask didn't appear at all, the same as one never
masked.

Now, while masking is on for a request (redactionWantedFor, a key's own
switch included), the gateway counts it under its agent
(maskrec.Checked): looked over, and whether masking changed something,
or sent as written to a model the user set to go unmasked. The counts
hold no text: a small checked-<day>.json beside the day's records,
written over through temp and rename at most every 5 s, read back after
a restart, pruned at 30 days with the records and removed by Clear
records. /api/masking/summary returns them as checked.

Counted where a turn's masking is decided: serve (every routed chat
turn, plugins and groups included), Codex's own sign-in's /responses
turn, and the native API passthroughs (nativeArk, nativeAny). Not
counted: searches, images, video, embeddings, System One's decisions and
Codex's compactions, which are not an agent's turn; they keep their
records as before.

The Masking page's card lists each agent under the flow: "Pi · 128
checked · none to mask · 3 sent as written". A click narrows the list
to it; the agent picker lists checked agents too; and a list with no
records says "128 requests from Pi checked, and none carried anything to
mask" instead of "Nothing masked matches these filters". Strings in zh,
zh-TW, ja and de.

Run (code at this head; first at base c41fa8e47 on mica, then rebased
on origin/main d987cc7d5 on mote):
- c41fa8e47, mica: go test ./internal/maskrec ./internal/gateway
  (-timeout 45m, 986s) ./internal/gui: ok.
- d987cc7d5, mote: go test ./internal/maskrec ./internal/gui: ok;
  go test -run "Checked|Masked|Mask|Codex|Native" ./internal/gateway: ok.
- GUI on mote, Chromium + WebKit: masking-records 124/124 (every
  language at 640px, en at 1100px), i18n-keys 4/4, i18n-en-no-cjk 4/4,
  mask-actions, mask-alert, mask-emails, mask-value-menu, masking-demo,
  masking-demo-unblurred, routing-masking, gateway-key-redact,
  group-redact, redact-route, window-mask: all pass. Screenshots checked
  in WebKit, en 1100 and zh 640.
- GOOS=linux and GOOS=windows go vet ./internal/maskrec ./internal/gateway:
  ok (internal/gui's cross vet stops in wails' cgo, as on main); gofmt -l
  clean.

Broken by hand: without the noteChecked line in serve,
TestPiTurnsCountedAsChecked fails ("three turns with nothing to mask:
{Looked:0}"); without the one in codex_backend.go,
TestCodexOwnSignInKeepsItsMaskingTime fails (Looked 0).

Not tried: a real Pi binary against a built magpie (the test sends Pi's
own headers: magpie's token, User-Agent pi/…, X-Session-Affinity, on
each of its three protocols); the counts across a real restart of the
app (the unit test reads the day's file back after a reset).
2026-11-14 17:38:39 +08:00
yetone d987cc7d5a provider: Devin's mover min is 0.1.41, which sends a Gemini reply's thought signature back
devin 0.1.41 (magpie-community/plugins 191d94bf) puts a Gemini model's
thought signature, signature_type "gemini" and the model that wrote it on
the next request's assistant prompt, as the devin CLI sends it. The
plugin had dropped Gemini signatures, so Gemini 4 Hydrogen lost its
thoughts on every tool turn (liuzhengdong99 on X: 502 empty replies and
long waits in DSH). keepMovedCurrent brings every moved user to it.

Run: go test ./internal/provider/ on mote at this head (rebased on 8334f1e6e): ok (140s). gofmt -l clean.
npm view --prefer-online @magpie-community/opencode-devin-auth version:
0.1.41 before this commit. The plugin's own record (tests red on the old
code, real-account runs, the case not reproduced on the old code) is in
191d94bf.
2026-11-14 17:14:58 +08:00
yetone 8334f1e6e0 lessons: 11-14 a sixth budget raise; 11ddf076b ran chosen packages and left the eager-regexp guard red 2026-11-14 17:09:31 +08:00
yetone c41fa8e478 sessions: an OpenMausBot conversation can be shown (@qingqingdilaiP on X)
@qingqingdilaiP's OpenMausBot rows in Usage → Sessions (b507b5f69,
v0.1.4146) had a time, an id and ~\.openmausbot\messages.db#<id>, but no
Show conversation: HasTranscript left openmausbot out, so the row had no
transcript flag and /api/sessions/transcript, the Markdown export and the
Sessions filter refused it.

ombTranscript reads the conversation from messages.db (the listing's
path up to its last "#", the session's id as thread_id), on its own
read-only connection, in one read transaction, ordered by at and rowid
as the listing reads it:
- a user text is the person's message;
- a bot text, and an options card's words (MausBot's first message is
  one), are the bot's;
- an activity of a turn's item (tool.itemId, as server/index.js writes
  on item.started) is a tool_use with its input (else its summary, else
  its name: the sample's agents_list_bots kept no input), and its output
  a tool_result;
- an activity with no item (a notice, a queue or engine move, which
  OpenMausBot adds itself) and a turn's digest, which repeats the reply,
  aren't said.

Sibling check: Hermes and Alma, listed the same way (read-only database
rows, 5a4104632, dc3deaf09), have no Show conversation either, nor do
zcode, dsh, cline, grok, droid, workbuddy, workbuddy-ai, codebuddy and
antigravity. Filed as #6633; not changed here.

Tests (testdata/openmausbot, OpenMausBot 0.1.155's own data folder as
b507b5f69 recorded it):
- TestOpenMausBotTranscript: both conversations flagged in List and on
  the Sessions page; Find + TranscriptOf as the GUI route does gives the
  team thread's prompt, "Checking the team.", agents_list_bots, its
  result, the reply, and the fruits thread's 4 texts with no digest;
  WriteMarkdown and SearchSession read the same rows; messages.db's bytes
  unchanged.
- TestOpenMausBotTranscriptToolsAndNotices: rows inserted in the shapes
  OpenMausBot writes (item.started/completed with input and output, a
  cloud-credit-moves notice): the tool shown with its arguments and
  result, the notice not said.
Broken by hand, each red: openmausbot out of HasTranscript (no flag,
"can't be shown"); the itemId check removed (the notice said as a tool).

Run on mote: gofmt -l clean; go vet ./internal/sessions ./internal/gui,
GOOS=windows go vet ./internal/sessions, GOOS=linux go vet -tags nogui
./internal/sessions; go test -count=1 ./internal/sessions ./internal/gui
ok; node --test sessions-talk, sessions-talk-sheet, sessions-talk-model,
sessions-export, sessions-search (Chromium and WebKit, their languages
and widths): 54 of 54 pass (the GUI is unchanged: it shows the button
from the row's transcript flag). On Windows (xiaomi-gpu): go test -run
'OpenMausBot|Alma|Hermes' ./internal/sessions ok.

After a rebase onto 80a315a70 (no internal/sessions change; internal/gui's
cache change): on mica (mote over its cores), go vet and go test -count=1
./internal/sessions ./internal/gui ok, at the pushed tree.

Not tried: the live GUI against a real OpenMausBot on Windows (the
reporter's case); a conversation with images or cards other than options
(secret, signin, connector are left out); not the full ./... suite (the
change is inside internal/sessions, whose only callers here are
internal/gui's routes, both run).
2026-11-14 17:04:45 +08:00
yetone 80a315a70a gui: a closed or hidden page lets its Sessions and Usage caches go in 30 s
What a visit to the app's page read stayed until each cache's own idle
timer fired: the Sessions stats after 2 minutes, the Requests chunks
trimmed at 2 and forgotten 5 after that, each chunk's derived keys at 3.
On a real history (acctp, requests-v1.bin 71.5 MB) a web page open 70 s
and closed held 123 MB at the close, 108 MB a minute on, 74-76 MB three
to five minutes on, and was back to the tray's 52 MB only at ten.

The page now says it has gone from view (POST /api/page-away, sent from
the visibilitychange listener every window already has, when hidden: a
browser fires it as a tab closes, and the Mac window's orderOut
dispatches it too). 30 s later (pageAwayFor), unless a Sessions or Usage read
was in flight or ended since, the stats, overviews and tags go
(letGoStats, split out of forgetIdleStats), the Requests chunks and each
chunk's derived caches go (usage.ForgetPages: trim(0) + dropDerived,
idle timers stopped) and the pages go back to the system. A second tab
still polling, or a tab looked away from for under 30 s, keeps them. The
beacon writes nothing, so held's provider.Changed passes it by. The panel
sends it as well when it hides; it reads no Sessions or Usage page, so
there is nothing of its own to keep.

Tests: TestPageAwayLetsStatsGo (red with the forget skipped, and red
when a read after the beacon is ignored, both broken by hand) and
TestForgetPagesLetsChunksGoAtOnce.

The core script budget goes up 83 bytes, with the reason in its
comment: the beacon is folded into the existing listener and packed to
its shortest form (335 over as first written, with a pagehide listener
and a panel check).

Measured on mote (pageclose2.sh, the acctp history, a web page open
70 s and closed, footprint-overlay build like the release):
  before (w88): close 123 MB, +60 s 108, +180 s 76, +300 s 74, +600 s 52;
                peak 154
  after  (w89): close 123 MB, +45 s 92, +90 s 90, +180 s 54, +600 s 53;
                peak 149, 3.08 s CPU over 11 min
  final (w90, visibilitychange only): close 122 MB, +45 s 93, +90 s 90,
                +180 s 55, +600 s 52; peak 152

Run: go test ./internal/gui ./internal/usage on mote (ok);
GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./... (ok);
16 visibility GUI files + i18n-keys in chromium and webkit: red only in
routing-pin-away (the same subtest red alone at origin/main 4739ec92c,
2026-11-14 17:00:00 +08:00
yetone 09aa60d4ae gateway: a test that Claude Code on a Codex account is asked as Codex asks
qingchen060106 on X: gpt-6-astra (Codex account) seemed to spend the
plan faster from Claude Code than from Codex. Their screenshot: Claude
Code, astra high, 1 subagent: input 121K, cache read 1.6M, output 12.1K,
~$3.44; Codex, 4 messages: input 58.0K, cache 213K, output 2.4K, ~$0.915.

Checked the Messages -> Responses translation against Codex 0.162's
request (testdata/workdir/codex-0.162.0.json) with Claude Code 2.1.296's
own request (testdata/workdir/claude-code-2.1.296.json) through a fake
ChatGPT backend. No gap:
- prompt_cache_key is the same on every turn, and session-id/thread-id
  carry it, as Codex sends them;
- effort goes as picked (output_config high -> reasoning.effort high);
- the step's encrypted_content reasoning goes back before its call
  (carried in the call id, reasoning_carry.go);
- the system prompt and the 23 tools go once each, the billing line is
  cut, and nothing else is added to the input; turn 1's items are
  turn 2's prefix byte for byte.

What accounts for the difference: the fixed prompt per call is ~24.5K
tokens for Claude Code (o200k: instructions 4.1K, Claude Code's 23 tool
schemas 16.8K, input 3.6K) against ~13.0K for Codex (tools 4.0K), and
the session made several times as many calls (1.72M prompt tokens read
against 271K). Cache hits were higher through magpie (93% vs 79%). At
$10 in / $1 cached / $50 out both screenshots' costs come out as shown
(1.21 + 1.60 + 0.61; 0.58 + 0.21 + 0.12).

This adds TestClaudeCodeOnCodexSpendsAsCodex, which holds all of the
above: no test covered a Codex account's sealed reasoning through
Claude Code (only Grok's).

Run (on mica, at 05d25d8dc + this): go vet ./internal/gateway; go test
./internal/gateway -run 'TestClaudeCodeOnCodexSpendsAsCodex|
TestGrokReasoningGoesBackThroughOtherAPIs|TestSealedReasoningAskedOfGrokAlone|
TestHeadersCarry' -race -count=3: ok.
Broken by hand: carryReasoning returning dec as is -> red (second turn
has 5 items, no reasoning); sessionHeaders not setting session-id and
thread-id -> red on both turns.
Not tried: a real ChatGPT account; the full suite (test-only change).
2026-11-14 16:59:45 +08:00
yetone 05d25d8dcb provider: the Qwen sign-in's status words are compiled when first read (TestNoEagerPackageRegexps)
11ddf076b added a package-level regexp.MustCompile in qianwen_plan.go, which turned TestNoEagerPackageRegexps (lazyre_test.go) red on main. lazyre.New compiles the regexp on first use instead, as the guard asks.

Run on mote: the full go test -timeout 45m ./... at 039025ac6 was red in this test alone (qianwen_plan.go:331:25). At 1a8fc99f4, with this fix, gofmt, go vet (darwin, linux -tags nogui, windows) and the full suite were all ok (EXIT=0).
2026-11-14 16:55:15 +08:00
yetone 0fa221b6ec vision: a describer whose every account has to sign in again is not magpie's first pick
@freefcw on X (tweet 2121512865970737221): images sent to Grok's
grok-4.7-build-fast were described by Claude Haiku, whose sign-in had
expired, and the request failed. AutoVision ranked describers by
allowance (spentModel: quota and credit rests, full windows) and then
by tier, a Claude account first, and never asked whether the account
could be used at all. A Claude sign-in Anthropic refused stayed the
first pick, ready, for every image.

smallReadyOf now calls a model not ready when every account of its
provider in use has to be signed in again (provider.SignInNeeded, the
same test the Providers page and the sign-in alerts use: needsSignIn).
Such a model gives way to any other model that sees. When nothing else
sees, it is still named, as a pick out of allowance is (#1801), so
agents are still told images are described. Every small-model pick
goes through smallReadyOf (the searcher and the decide model as well
as vision), so they all skip a signed-out account the same way.

The other half of the report doesn't reproduce: grok-4.7-build-fast
reads as seeing. The Grok plugin has declared input.image for every
model since its first version (0.2.7 now). On the live 0.1.4131 the
model's entry says image:true/imageSaid:true. With the owner's real
Grok account, Chat Completions and Responses images (including a
function_call_output image, Codex's view_image shape) reached Grok
undescribed and were answered. Grok's image refusals (invalid_image
for gif/tiff/heic, more than 26214400 bytes, an unresolvable URL, and
a 422 for a missing image_url) don't match imageRefusedWords, so none
of them marks the model blind. That was checked with a throwaway test
and not committed.

Run (mote, at 1a8fc99f4 = this commit plus the Qwen lazyre fix, on
origin/main 07a62b373; rebased after onto two lessons-only commits):
  gofmt -l: clean
  go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok
  go test -timeout 45m ./...: every package ok (EXIT=0)
An earlier full run at 039025ac6 was red only in
TestNoEagerPackageRegexps (qianwen_plan.go, from 11ddf076b), fixed in
the next commit.

Broken by hand: with search.go's change reverted, the new
TestAutoVisionPassesOverASignedOutAccount fails ("a describer whose
account has to be signed in again said to be ready"). With the change
it passes.

Not tried: a real Claude account whose sign-in really lapsed (the test
uses Claude Code's refusal through a stand-in binary), and the
reporter's own setup (a smart routing group or the analyze_image MCP
tool, on v0.1.3375). Windows skips the new test, because a shell
script stands in for Claude Code.
2026-11-14 16:55:08 +08:00
yetone 4739ec92cc lessons: the counts of the 11-14 no-green stretch, measured (81 commits, 51 releases) 2026-11-14 16:38:36 +08:00
yetone 5e7ce5d91d lessons: 11-14 a fifth budget raise; 11 hours with no Test run finished green 2026-11-14 16:38:19 +08:00
yetone 07a62b3739 providers: Copy all keys, and magpie provider keys, carry a provider's keys to another magpie
@emilochen on X asked to batch-export one provider's keys, to sync them
between a local and a cloud magpie. Each key row could copy only its own
key (#1480), and nothing printed them all.

- A provider with two or more keys gets a "Copy all N keys" row under
  Add another key. It asks provider/key with allKeys (provider.AllKeys:
  the main key and every listed key, deduplicated, turned-off ones too)
  and copies them one a line, for the other magpie's Paste several
  (keys/import). The secret goes only to the clipboard on the click,
  through the page's copy(); nothing logs it, and the route sits behind
  the GUI API's existing local/origin guards. A signed-in account has
  no keys and is refused.
- The row is drawn by keyrates.js (copyAllKeysRow), already imported
  when a provider with two or more keys opens; keyRateField now takes
  which of its parts to draw. It has its own class, keys-copy-all, not
  .add, since ~21 GUI tests take .acc.add as the one adding row.
  TestCoreScriptBudget's core budget goes up by the 72 bytes left in
  app.js (the placing line and the helper's new argument); app.js stays
  under its own budget.
- CLI: `magpie provider keys <id>` prints the keys one a line;
  `magpie provider keys <id> add [key… | -]` adds them from words or
  stdin (SplitKeys + AddKeys), so
  `magpie provider keys relay | ssh cloud magpie provider keys relay add`
  works. A word starting with "-" is refused, never taken as a key.
- Strings in en, zh, zh-TW, ja, de.

Related: #5387 (sharing saved providers through magpie:// links), not
closed by this.

Run on mote (mote-run) at this tree on 11ddf076b (debc80271, its new parent, changes LESSONS.md only):
- gofmt -l internal/: clean. go vet (darwin) ./internal/provider
  ./internal/gui ./internal/cli; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; GOOS=linux go build -tags nogui and
  GOOS=windows go build: ok.
- go test -count=1 ./internal/provider ./internal/cli: ok;
  ./internal/gui: ok (TestCoreScriptBudget included, after the budget
  change).
- GUI, Chromium + WebKit: key-copy-all (en/zh/zh-TW/ja/de × 900/420px),
  api-key-usage, i18n-keys, key-price-rate, key-copy, key-weight,
  click-scroll: 104/104. key-copy-all again in WebKit twice: 15/15 each.
- GUI, 43 key/provider/i18n files at the change vs the same files at
  untouched 11ddf076b: the only new reds were api-key-usage's key-row
  count (it counted .acc:not(.add); now leaves keys-copy-all out). The
  other 67 reds are the same on the base and filed: #5835 key-switch,
  #6414 key-balance-card de, #6424 key-box-once, #5866 signin-proxy
  380, #6444 api-key-theme, #4126 key-replace 420, #4673
  provider-typed, #6416 key-import Paste several, and #6628 (filed now)
  login-export's Export row count.

Broken by hand: key-copy-all.test.cjs at untouched 11ddf076b assets
fails 10 of 15 in WebKit (the 5 that pass are "one key has no Copy
all"). The Go tests can't build on the old code (AllKeys, keysCmd).

Not tried: the real app and the system clipboard, the Windows and
Linux boxes, a real cloud/headless magpie over ssh, and the full Go
suite (mote and mica were both over their load limits; the three
touched packages and cross-OS vet ran instead).
2026-11-14 16:34:10 +08:00
yetone debc80271f lessons: 11-14 a fourth budget raise; vendored yaml.v3 left a guard red (fc75d90af) 2026-11-14 16:06:37 +08:00
yetone 11ddf076b4 usage: a Qwen AI platform Token Plan is read through a sign-in to the platform (@imthe99galaxy on X, #5829)
On v0.1.4137 a provider on the Qwen AI platform's Token Plan
(qwen-token-plan, token-plan.maas.qianwenaiapi.com) had no quota card at
all. The plan key (sk-sp-) only authorizes inference; the platform tells
the plan's usage only to a sign-in on the platform, and magpie had none.

Now each such provider can sign in to the platform, as the QianWen CLI
1.10.0 does (qianwen_plan.go, UA qianwen-cli/1.10.0):
- a device sign-in with PKCE S256 at t.qianwenai.com/cli/device/code and
  /cli/device/token, approved in the user's browser; the editor's
  "Sign in to the Qwen AI platform" opens the page and waits for it;
- the session is the provider's own, kept by provider id in
  qianwen-auth.json (0600), moved on Rename and dropped on Delete;
- cli.qianwenai.com/data/v2/api.json (GenerateCLIAccessToken) mints a
  console token, kept and minted once more when the gateway answers
  NotLogined; ConsoleNeedLogin or a fresh token refused signs it out;
- the usage is the Alibaba Token Plan's BroadScopeAspnGateway call at
  cs-data.qianwenai.com with consoleSite QIANWENAI, region cn-beijing,
  read by the shared aliAskUsage/aliReadWindows (alibaba_usage.go now
  takes the console per call). The sk-sp- key is never sent there.
- Plan windows (planquota.go) and routing's key allowance
  (key_allowance.go, keyTag "qianwen") read it; not signed in, the card
  says so with Open settings (NeedsAccessKey).
- GUI routes /api/qianwen/{id}/signin (POST start, GET state),
  /signin/cancel, /signout; the editor's field lives in qianwenplan.js,
  imported when such a provider's editor opens. The core script budget
  is raised by 326 for the import and one quotaError line (its reason in
  core_budget_test.go). The routes are in the CLI parity's notYet, as
  StepFun's are.

Run, on mote at the base df2b819c6 (= origin/main then):
- gofmt -l: clean. go vet (darwin), GOOS=linux go vet -tags nogui,
  GOOS=windows go vet on internal/provider, internal/gui, internal/cli: ok.
- go test -count=1 -timeout 45m ./internal/provider ./internal/gui
  ./internal/cli: provider ok; gui and cli red on TestCoreScriptBudget
  and TestEveryRouteHasACommandOrIsNamed, both mine; fixed (code moved to
  qianwenplan.js, budget +326, routes named), then gui ok, cli ok.
- go test -race -run Qianwen ./internal/provider: ok.
- GUI (chromium + webkit, 900/420px, en zh zh-TW ja de where the file
  has them): qianwen-plan 20/20, stepfun-per-provider,
  usage-access-key-card, volc-access-key, quota-balance-error,
  i18n-en-no-cjk all ok; earlier also opencode-zen-balance,
  siliconflow-balance, usage-card-refresh, usage-remote-key-limits,
  usage-remote-cards ok. Reds not mine: i18n-keys "a plugin's words are
  its own" (#6619, fixed on main by ea6470cb7), old-webkit's
  headerpresets.js (#6030) and app.css :has() (#5919).
- Rebased on origin/main 79a30eb9c and run again at that tree on mote:
  go test -count=1 -timeout 45m ./internal/provider ./internal/gui
  ./internal/cli all ok; qianwen-plan + i18n-keys 24 pass, 0 fail. Rebased again onto
  fc75d90af before the push; b507b5f69 and fc75d90af touch only
  internal/sessions and third_party/yaml.v3, not run again.

Broken by hand, each red, then restored: the NotLogined retry, the
code_verifier, renameQianwen, the planquota channel, forgetQianwen on
Delete, the session expiry check, qianwenWatch not called, the sign-in
quotaError mapping.

Not tried: a real sign-in. No Qwen AI platform account is available here,
and approving the device sign-in grants an OAuth permission. Fixtures are
built from the QianWen CLI 1.10.0 source and the live device/code and
unauthenticated replies; the usage reply's shape is the Alibaba Token
Plan's, which the CLI reads with the same code.
2026-11-14 15:46:34 +08:00
yetone fc75d90af7 yaml.v3: its two regexps are compiled on first use, not at launch
0caa09b3d vendored gopkg.in/yaml.v3 into third_party/yaml.v3, inside
magpie's tree, and TestNoEagerPackageRegexps, which walks the tree, has
been red on main since:

  third_party/yaml.v3/encode.go:307:19: a package-level regexp is
  compiled at launch; use lazyre.New
  third_party/yaml.v3/resolve.go:124:22: (the same)

yaml.v3 is its own module and can't import internal/lazyre, and its
go.mod has no go line (Go 1.16 language, so no sync.OnceValue).
base60float and yamlStyleFloat are now functions that compile their
expression once behind a sync.Once; the patterns are as upstream's.
MAGPIE.md lists this as the second change from v3.0.1.

Seen red in the full suite of the OpenMausBot sessions change (mote, at
13cb07fde + that change), which doesn't touch yaml.

Run (mote): gofmt -l clean; go vet in third_party/yaml.v3; go vet ./..., GOOS=linux -tags nogui and GOOS=windows go vet ./...; go test -count=1 -timeout 45m ./... at 59c5b59ea (on df2b819c6): 100 packages ok, TestNoEagerPackageRegexps among them. Red before: the two lines above, on 13cb07fde.
After a rebase onto ea6470cb7 (01c3efc4f's library change and a GUI
test): vet as above, and go test . ./internal/sessions ./internal/library
./internal/catalog ok. After another onto 79a30eb9c (edit/toml.go and
provider/remote_follow.go perf): go vet ./..., go test . ./internal/sessions
./internal/edit ./internal/provider ok, at the pushed tree.

Not run: upstream yaml.v3's own tests (not copied here, need
gopkg.in/check.v1).
2026-11-14 15:42:01 +08:00
yetone b507b5f692 sessions: OpenMausBot's conversations are read (@qingqingdilaiP on X)
@qingqingdilaiP asked for OpenMausBot's sessions in Sessions. OpenMausBot
(milind-soni/OpenMausBot, npm 0.1.155) is already an agent in magpie,
but its conversations were not read. It keeps its data in $OMB_DATA_DIR,
else ~/.openmausbot on every system (server/config.ts):
- bots.json: bots[].tasks[], one a conversation (threadId, title, "New
  thread" until named, and cwd once a turn pins it);
- messages.db: SQLite in WAL mode (thread_id, at ms, role user|bot, kind
  text|activity|..., text, json; an activity's json holds tool.name, a
  bot text its turnId);
- usage/<YYYY-MM>.jsonl: one row a turn (driverKind, model, input with
  cachedInput and cacheWrite included, output).

internal/sessions/openmausbot.go lists each conversation as a read-only
session, like Alma's and Hermes's rows: prompts, one reply a turn (a
turn says a line before a tool and again after it), tools by name,
title from bots.json (else the first prompt), folder from task.cwd,
times from messages and usage rows. A conversation holding only a bot's
greeting is left out. Its rev joins the thread's count, last time,
bytes, usage rows, title and cwd, so a write to it, or a new title,
reads it again while the database file looks the same. Tokens count
only for API drivers (server/agents-bridge-switch.ts's
CHAT_RUNTIME_DRIVERS): a bot on Claude Code, Codex, Pi or another agent
CLI runs that CLI, which keeps the turn in its own session, so its
tokens are counted there and would be counted twice. Fresh input is
input less cache reads and writes. bots.json and the usage files are
read again only when their size or time change. Dirs() and Reads/access
cover messages.db. Delete refuses it: OpenMausBot keeps the database
open.

Tests (testdata/openmausbot is OpenMausBot 0.1.155's own data folder,
written by the real app in a sandbox on mica with an OpenAI-compatible
fake model, database checkpointed):
- TestOpenMausBotSessions: titles, tokens, times, greeting-only threads
  left out, the Sessions page (2 rows, not deletable, 4 and 2
  messages), Delete refused, stats (1 prompt, 1 reply, agents_list_bots
  once), Dirs(), the database's bytes unchanged.
- TestOpenMausBotCountsCLITurnsOnce: the sample's rows with one turn on
  claudeAgent and one with cache read and write, cwd pinned.
- TestOpenMausBotReadAgainWhenItChanges: a new title alone, then a new
  row with the file's time held.
- skillsCounted: openmausbot says why its skills are not counted (a bot
  reads a SKILL.md with its file tools, and the sample has no such turn).
Broken by hand, each red: CLI rows counted (claude tokens 1202/42),
no turnId dedupe (team 3 messages, 2 replies), no rev check and title
ignored (new title not read), cache left in fresh input (1203), greeting
threads listed (4 rows).

Run: gofmt -l clean. On mote (load ~20 on 18 cores, mica busier with a
GUI run): go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
go vet ./..., go test -count=1 -timeout 45m ./... at 59c5b59ea (this and the yaml.v3 commit on df2b819c6): 100 packages ok. The first run, at 13cb07fde, was red in internal/sessions' TestEveryAgentSaysItsSkills (openmausbot not in skillsCounted, added here) and the root's TestNoEagerPackageRegexps (main's yaml.v3, the next commit). On Windows
(xiaomi-gpu): go test -run 'OpenMausBot|Alma|Hermes' ./internal/sessions ok.

After a rebase onto ea6470cb7 (01c3efc4f's library change and a GUI
test): vet as above, and go test . ./internal/sessions ./internal/library
./internal/catalog ok. After another onto 79a30eb9c (edit/toml.go and
provider/remote_follow.go perf): go vet ./..., go test . ./internal/sessions
./internal/edit ./internal/provider ok, at the pushed tree.

Not tried: a conversation on a Claude Code or Codex engine in the real
app (its tokens come from that CLI's own session, by design here); the
live GUI (unchanged); OpenMausBot on Windows or Linux. Not covered:
magpie's own engine in OpenMausBot runs Claude Code with its config in
<data>/providers/magpie, a Claude home Sessions doesn't read, so those
turns show nowhere yet.
2026-11-14 15:42:01 +08:00
yetone 79a30eb9cc perf: the remote-magpie follower reads providers.json's kept parse
KeepRemoteListsFollowed looks every minute (and on each write) for the
Remote magpies to follow, and followedMagpies parsed the whole of
providers.json again for it and normalized every provider in it. It now
reads storedFile, the parse kept until the file changes, and normalizes
only a provider that has an Anthropic address; what it returns is still
each provider's own normalized copy. In the tray-only profile this was
3 MB of the 11 MB providers.json decoding allocated over seven minutes.

Run: go test -race -run 'Follow|Remote' ./internal/provider on mote,
then the whole package.
2026-11-14 15:36:16 +08:00
yetone c8d47121b4 perf: a TOML key's dotted name is built in one reused buffer
parseTOMLSource made a string for each part of every key, a second one
for its raw text, two slices to hold them, then joined them: several
allocations a key, over Codex's ~11k trusted projects on each parse of
its config. Each name is now appended into a buffer every expression
reuses and copied out once.

Run: go test ./internal/edit ./internal/provider on mote; agent,
library, sessions and cli on mica; tray-only real-account run on mote.
2026-11-14 15:36:16 +08:00
yetone 5a02584476 perf: a TOML file is parsed from its own bytes, not a joined copy
tomlFileOf split the file into lines, then parseTOMLFile joined the lines
back together and converted the result to bytes for the parser: two more
copies of the whole file on every parse. Codex's config is 1.5 MB with
the ~11k projects it trusts, and it is parsed again each time it changes.
parseTOMLSource takes the bytes the caller already holds; parseTOMLFile
keeps its signature for the callers that only have lines.

Run: go test ./internal/edit on mote; tray-only run with the real Codex
account (tray7.sh) on mote, numbers in the release note.
2026-11-14 15:36:16 +08:00
yetone ea6470cb75 gui tests: i18n-keys leaves vendored third_party code out
0caa09b3d vendored yaml.v3 under third_party/, and its yamlh.go says
"Error type", a key of the usage plugin's i18n.js, so "a plugin's words
are its own" went red on main. Vendored code says nothing to magpie's
window; the walk now skips third_party like node_modules.

Run (mote): node --test internal/gui/tests/i18n-keys.test.cjs: 4 of 4
pass; red before this change at 01c3efc4f (and on origin/main
df2b819c6) with 'plugins/usage/i18n.js "Error type":
third_party/yaml.v3/yamlh.go says it too'.
2026-11-14 15:34:08 +08:00
yetone 01c3efc4f7 library: billion-context's compression markers can be switched off (@JamesYu32 on X)
@JamesYu32 asked for a switch that turns off the markers billion-context
adds after it folds: compress.visibilityMarkers. In bili 0.1.213
(CONFIGURATION.md, dist/index.js) it is a boolean, true by default; true
appends the 📦/❌ line after a compress, decompress, search_context or
acp_status call and re-injects it into the rebuilt history, false drops
both, and the tool calls still run. Some models imitate the markers.

The billion-context tab's Advanced fold gets "Show compression markers",
on unless the file says false. Off writes compress.visibilityMarkers:
false through edit.PatchJSON (comments and every other key kept); on
takes the key out, back to bili's default, rather than leaving a value
magpie chose. A provider's or model's own compress.visibilityMarkers is
the user's and is left as it is; a non-boolean value (which bili
rejects) is not read as off. The running bili is asked to reload, as
for the other settings. Under Advanced because it is rarely changed.

Run (mote, at this tree on origin/main df2b819c6):
- go test -count=1 ./internal/library/ ./internal/gui/: ok (117s, 136s)
- go vet ./internal/library/ ./internal/gui/; GOOS=linux go vet -tags
  nogui and GOOS=windows go vet of both: clean. gofmt -l: nothing.
- node --test of every library*.test.cjs and i18n*.test.cjs (81 files,
  Chromium and WebKit, every language, 1100 and 420 wide): 1753 of
  1754 pass. library-bili-settings now switches the markers off under
  Advanced and checks the post is {markers:false}. The one red is
  i18n-keys "a plugin's words are its own": third_party/yaml.v3/yamlh.go
  (0caa09b3d) says the usage plugin's "Error type"; red on origin/main
  without this change, fixed in the next commit.
- Real bili 0.1.213 (npm, sandbox HOME/XDG on mote): started with
  {"compress":{"visibilityMarkers":false}}, GET /__bili/config showed
  "compress": {"visibilityMarkers": false}; with the key taken out,
  POST /__bili/config/reload answered 200 and the config had no
  visibilityMarkers (default on).

Broken by hand: on writing true instead of taking the key out,
TestBiliMarkersSwitch fails ("turning markers back on left the key in").

Not tried: a real agent session through bili to watch the markers
disappear from the model's view; only the config bili loads was checked.
2026-11-14 15:33:24 +08:00
yetone df2b819c67 library: Antigravity and Crush get copies of skills on Windows (#6610, #5107)
On Windows without the right to make a symlink, magpie links a skill with
a junction. Go 1.23+ lists a junction as ModeIrregular, neither a folder
nor a symlink, and Antigravity (the app and agy: customizations'
discoverInSubDirsFiltered) and Crush (internal/skills on fastwalk, which
follows only a ModeSymlink) keep only folders and symlinks, so a
junctioned skill never showed in them. dsh, pi and the other Node, Bun,
Rust and Python agents follow a junction.

Checked against the real apps on xiaomi-gpu (Windows 11) in a sandbox
USERPROFILE: Antigravity 2.30.0's language_server.exe (--standalone)
GetAllSkills lists a skill in a folder and one behind a symlink, not one
behind a junction. crush v0.101.0's `crush run` request to a local
capture server listed the folder and the symlink, not the junction. On
macOS agy 1.5.8 (ACP session/new, available_commands_update) takes a
symlink that leads out of ~/.gemini/config, so #6610's "confined to the
folder" filter doesn't touch magpie's links there.

- junctionBlind (agy, antigravity, crush) and skipsJunctions: on Windows
  these targets have Copy, so they get marked copies, made again when
  the library's changes, and the Library page shows "Only ever takes
  copies" for them. A junction an older magpie made becomes a copy.
- inShared: a link in ~/.agents/skills is no skill to them, so Crush,
  which reads that folder too, gets its own copy.
- A project's .agents/skills entry that one of them reads is a copy
  (syncFolder's per-entry flag); one no such agent reads is a link again.
- takeEdits takes an edit made in a project's copy into the library, as
  one in an agent's copy is, so a copy a user edits isn't undone by the
  next sync (Project.Copy's copies too, which were made again over an
  edit before).
- behind lists these agents' stale copies.

Run:
- go vet ./internal/library, GOOS=windows and GOOS=linux go vet, gofmt -l:
  clean (mote).
- go test -count=1 ./internal/library: ok on mote (macOS) 107.9s and on
  xiaomi-gpu (Windows 11) 440.0s, at this change on 0caa09b3d.
- go test -run JunctionBlind ./internal/library: ok on mote and on the
  Windows box (-v: all four new tests PASS, TestJunctionIsALink too).
- After rebasing on be7d22edd: go test ./internal/library on mote, ok.

Broken by hand:
- Without `t.Copy = skipsJunctions(a.ID)`, the inShared check and the
  project per-entry copy: TestJunctionBlindAgentsGetCopies,
  ...AgentSkipsSharedLink and ...ProjectCopies red on mote; on Windows
  TestJunctionBlindJunctionBecomesCopy red (both entries stay junctions,
  Lstat mode 2684354563 attrs, not a dir).
- Without the project loop in takeEdits: TestJunctionBlindProjectCopies
  red, the user's edit replaced by the library's.

Not tried: magpie's own binary syncing a real Antigravity on Windows end
to end (the apps were checked against a folder, a symlink and a junction
made by hand; magpie's copy is a plain folder, which the test checks a Go
ReadDir sees as one). Antigravity and Crush on Linux (symlinks there,
which both take). The full go test ./... suite.
2026-11-14 15:05:21 +08:00
yetone 8e1d3095a2 lessons: 11-14 yaml.v3 vendored for an allocation cut (0caa09b3d)
The review diffed third_party/yaml.v3 against gopkg.in/yaml.v3 v3.0.1
after gofmt: only the 7-line emitter change differs. Docs only; no code
run.
2026-11-14 15:03:13 +08:00
yetone be7d22edda gateway: a pi 1.x run of the Claude bridge starts in pi's own folder
fysly on X: a Pi turn on a Claude subscription told the model two working
directories, Pi's own and magpie's shared work folder under /private/var/
folders (magpie-claude-work-<uid>), where the bridge's Claude Code ran.

Pi 1.x states its folder as a system prompt section with the path on a
line of its own, "<cwd>\n/x\n</cwd>" (buildSystemPromptSections, joined
by getSystemMessageText). clientSaidWorkDir and clientTurnWorkDir read
<cwd> only on one line, as Codex writes it, so clientWorkDir found no
folder and the run started in the shared folder: Claude Code's own
environment then named that folder beside Pi's <cwd>. The folder rules'
reader (workDirIn) already allowed whitespace inside <cwd>; the bridge's
now does too.

Sibling in the same reader: workDirIn decodes the path's &, < and > as
entities (Codex escapes them in <cwd>, Claude Code < and >), the bridge's
did not, so such a folder failed os.Stat and its run went to the shared
folder too. Now decoded the same way.

No text of Claude Code's prompt changes: only the folder it runs in, the
existing clientWorkDir path for Claude Code, Codex and OpenCode callers
(--setting-sources "", no auto memory, CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS).

Run (mote, at 0caa09b3d plus this change): gofmt -l internal/ clean;
go vet ./internal/gateway/ for darwin, GOOS=linux and GOOS=windows ok;
go test -count=1 -timeout 45m ./internal/gateway/ ok (894.8s).
Rebased onto 3e38e4ba2 (codexcat, antigravity, codeassist): go vet and
go test -run 'WorkDir|WorkPlace|Claude' ./internal/gateway/ ok (150.5s)
at the pushed tree.
Broken by hand: with origin/main's claude_subscription.go and the new
tests, TestClaudeRunsInTheCallersWorkDir's "pi 1.x" and "Codex, a folder
written as entities" are red (both runs in magpie-claude-work-<uid>);
green with the fix.
Real pi: pi 1.4.0 in a sandbox HOME/PI_CODING_AGENT_DIR, pointed at a
local capture server; its real /v1/messages body ends
"<cwd>\n<proj>\n</cwd>". That body, sent through the bridge with a fake
claude, ran in <proj>, not the shared folder.
Not tried: a real Claude subscription turn from pi (no sandbox Claude
account here); the full go test ./... (mote and mica both over their load
limits); pi 1.5.x's prompt (1.4.0 installed, workdir.go names the same
<cwd> form since 1.1).
2026-11-14 15:01:56 +08:00
yetone 3e38e4ba21 antigravity: Codex's GPT-5 line goes reworded in a user's turn too
@daoche_wuzui (X, v0.1.4131, Antigravity Cloak 0.1.7) still got 429s on
Antigravity. Since 11-14, Google answers a bare 429 "Resource has been
exhausted (e.g. check quota)" when either of Codex's identity lines
("You are Codex, an agent based on GPT-5" / "You are Codex, a coding
agent based on GPT-5") is in a user turn. The plugin, the cloak
middleware and the gateway reworded system/developer text only. A
mid-thread developer item becomes a user "<system-reminder>" message in
responses.go, and a pasted AGENTS.md does the same, so the line reached
Google in a user turn as written.

Real account, gemini-3.8-flash, plugin fetch directly:
- each Codex line in a user turn: 429 3/3; reworded "built on GPT-5": 200 3/3
- billing header, Agent SDK, Claude Code, Hermes and RFC lines in a
  user turn: 200 3/3 each, so only Codex's two lines are reworded there
- Codex line in the model turn or a functionResponse: 200, left as is
- "You are Codex." alone, "based on GPT-5" alone: 200
So the refusal is about the content, not the account or the model.

Through a sandbox magpie (sandbox HOME, port 3476), plugin 0.1.12 +
cloak 0.1.7, /v1/messages with the line in a user turn: 429 3/3
"Antigravity: Resource has been exhausted". With 0.1.13 + 0.1.8 in place
and the plugin host restarted: 200 3/3. A real Claude Code and a real
Codex request capture still 200 2/2.

- gateway: codeAssistBody rewords Codex's two lines in non-model turns
  for an Antigravity account (antigravityCloakMessages), on a copy; Gemini
  CLI accounts and prompt=as-written go untouched.
- mover min 0.1.12 -> 0.1.13 (plugins fb7bbebd: plugin 0.1.13, cloak
  0.1.8; both in the dist branch's index.json, checked after publish run
  43566168677; its npm job is red on middleware-system-prompt only,
  plugins#887).

Run on mica at e0f856ec0 (this change on origin/main 0caa09b3d):
- go test -count=1 -timeout 45m ./internal/gateway/ ./internal/provider/: ok (gateway 1103s, provider 142s)
- GOOS=linux and GOOS=windows go vet of both packages: ok
- gofmt -l: clean
At the pushed head, rebased onto 13cb07fde (codexcat compaction windows,
internal/gui): go vet of gateway, provider and codexcat; go test -run
'Antigravity|Cloak|CodeAssist|TurnedAway|Mover|Migrat' of gateway and
provider, and codexcat whole: ok.
Plugins at fb7bbebd's tree (before its rebase onto 09c05dfa, a
trae-only change): root bun test with a temp HOME, 8781 pass 0 fail.

Broken by hand: with antigravityCloakMessages's call removed,
TestAntigravityCloaksTheLineInAUsersTurn goes red. In the plugins,
without the user-turn cloak the shape test (1) and cloak cases (5) go red.

Not tried: the reporter's own agent and prompt (they didn't say which);
a real Codex CLI session driving Antigravity end to end; the GUI
(untouched). Not changed: antigravityTurnedAway/Foreseen still judge
the uncloaked system prompt, which can call a real quota 429 "turned
away" and skips the account for 6h (#6613).
2026-11-14 14:57:33 +08:00
yetone 13cb07fde7 codexcat: an OpenAI model is compacted where Codex's own catalog holds it, GPT-6.1 Terra at 500K (@flower__daisy on X)
@flower__daisy: Codex compacts often after connecting to magpie, "don't
Codex models have 500k now?". Codex's bundled catalog (rust-v0.165.0 to
rust-v0.169.0, models-manager/models.json) gives gpt-6.1-terra a
context_window of 500000; every other listed model 272000 (red-latest
372000). Long conversations' default, the working window, told Codex to
compact every model with a longer window at 272K, "what OpenAI does
with its own models". For GPT-6.1 Terra that is no longer what OpenAI
does:
- a ChatGPT account's codex/gpt-6.1-terra in magpie, with no entry in
  Codex's models_cache.json, got context_window 500000 and
  auto_compact_token_limit 272000;
- an OpenAI API key, relay or found auto/ gpt-6.1-terra got models.dev's
  922K and 272000.
Codex's own entries, passed through beside a ChatGPT sign-in, were
already as the backend gave them.

codexcat.Working is now Long conversations' threshold, except that at
its default an OpenAI model is held to the window official Codex holds
it to (OwnWindow: the account's models_cache.json list, else the bundled
catalog, matched by longest prefix as Codex does), never above the
model's own window. A size the user set (CompactAt, Codex's own Long
conversations) and Full window are as they were. Another vendor's model
and a routing group keep 272K. A model whose window magpie doesn't know
gets the same threshold. The Context tab's advice (tune.go codexWindow)
and the Long conversations row (codexWindowUnder) read it too.

Tests:
- TestBundledWindowsAreCodexOwn: bundledWindows equals the
  context_window of every model in testdata's rust-v0.166.0 models.json.
- TestCodexCatalogHoldsOpenAIModelToCodexWindow: terra on an API key,
  a dated auto/ id, a 400K relay, codex/ at 500K, a relay with no
  window; sol, DeepSeek, Claude and a group at 272K; the account's list
  before the bundled one; CompactAt 300K and Full window as set.
  Broken by hand: with entriesAt back on work.Working, 6 cases red
  (codex/gpt-6.1-terra told [500000 272000]).

Run (mica, mote over its load): go test ./internal/codexcat; go vet
codexcat and gui for darwin, linux (nogui), windows; gofmt -l; go test
./internal/gui -run 'Tune|CodexWindow|Codex.*Window|LongConv|Compact';
then -run 'Codex|Compact|Window|Tune|Catalog|Ultra|Relist' over
gateway, provider, agent, gui and codexcat: all ok (gateway 280s).
Full suite: queued on mica behind another session's suite.lock, not
finished at push (the owner's ship-at-once rule).

Not tried: a real Codex 0.169 session running past 272K on GPT-6.1
Terra through magpie. Claude Code and Grok Build keep the 272K working
window for every model; no Anthropic or xAI catalog gives an OpenAI
model a window of its own.
2026-11-14 14:50:56 +08:00
yetone 0caa09b3d9 perf: yaml's event queue, TOMLWithout's buffer and the catalog's hash stop holding whole documents
A start with the owner's real accounts (release build, mote) allocated
279 MB in its first seven minutes; three of the largest were buffers
the size of a whole document that nothing needed whole:

- yaml.v3's emitter appends every event to a queue it never empties,
  so encoding dsh's route of a few hundred models held ~24 MB of
  events (dshPutProviders' Node.Encode and dshNodeLines). That round
  runs on the first start of each version and on each catalog change.
  yaml.v3 is vendored in third_party/yaml.v3 (replace in go.mod, as
  jsonschema is) with the queue started again once it is drained;
  MAGPIE.md says what changed. go.yaml.in/yaml/v3 v3.0.5 has the same
  queue.
- edit.TOMLWithout made its output as large as the input: 1.5 MB per
  read of Codex's config, which five readers make, to keep a few KB
  around the projects tables. It now grows to what is kept.
- catalog.fileKey read the ~6 MB catalog whole to hash it; it is now
  hashed as it is read.

Measured with the owner's real accounts (~/r2278/acct, tray only, no
window), release ldflags and the footprint overlay, a version new to
the HOME so dsh's full round runs, on mote:
- allocations in the first 7 minutes 279 MB -> 260 MB;
  yaml_emitter_emit 24.9 MB -> under pprof's cut (1.3 MB),
  dshPutProviders 23.1 -> 8.1 MB, dshNodeLines 12 MB -> under the cut,
  edit.tomlUnder 12.2 -> 4.0 MB
- footprint at +300 s 59 -> 58 MB, live heap 5.5 MB both; peak 84 vs
  89 MB, within the run-to-run spread seen before (84-88 MB)

Run at this tree: upstream yaml.v3's own tests on the patched emitter
(go test ., ok); go test ./internal/agent ./internal/cli ./internal/edit
./internal/library ./internal/pluginrt ./internal/catalog on mica (ok),
and ./internal/sessions on mote before the yaml change (ok); go vet ./...
(mac), GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...
ok; gofmt -l on the changed files prints nothing.
Not run: the full suite.
2026-11-14 14:33:16 +08:00
yetone 73ecef0b36 memory: each memory is a Markdown file of its own
memory.json held every memory in one JSON file, which grew without
bound, was hard to read or fix by hand, and was rewritten whole on every
change. Memory is now a folder, `memory/` beside where memory.json was:

- `<id>.md` is the memory: YAML front matter (kind, scope, status,
  origin, pinned, tags, why, sources, times) and the text as the body.
  The file is the source of truth.
- `meta.json` holds what isn't one memory's: projects, the digest,
  dismissed texts, deletions, declined suggestions, when a search last
  returned each memory (so a search never rewrites a memory's file), and
  the hash of each file as magpie last wrote it.
- `index.json` is a cache of the parsed files by size and mtime only:
  deleted or garbled, memory reads the same.
- `journal.json` holds a change to more than one file (a merge, a sync)
  before any is written; the next read finishes one cut off halfway.

A file whose hash isn't the one magpie wrote was edited or added by hand:
it is the user's (origin user, Edited), so a tidy leaves it and an
agent's change synced from another computer never writes over it. A file
with no front matter is a global fact named by its file. A write leaves
any file that changed on disk since it was read (a hand edit made
meanwhile), and so does a remove. A file that can't be parsed is left
out and never written over nor removed, sync included; meta.json that
can't be read is unknown (an error), as memory.json was.

memory.json is moved in on the first read, all under one journal, and
kept as memory.json.migrated. One that can't be read is an error and
nothing is written.

The scope of a hand-written file keeps its case (a project's holds a
path); "global" in any case is global.

Ran at this head (rebased on origin/main 50d88f17c), on mote:
- go test -count=1 ./internal/memory ./internal/memdistill
  ./internal/memembed ./internal/backup ./internal/library ./internal/gui:
  ./internal/davsync ./internal/appdir: ok; go vet ./internal/...: ok;
  go test -run 'Memory|memory|Doc|Subsystem' ./internal/...: 98 ok
- go vet ./... and GOOS=windows go vet ./... (before the rebase, whose
  three commits touch no memory code): ok; gofmt -l: clean
- win-run go test ./internal/memory ./internal/backup: ok
- wsl-run go vet of memory, backup, library, memdistill, memembed,
  davsync and go test of memory, backup, memdistill: ok
- A copy of the real memory.json (206 memories) migrated in a sandbox:
  every field of every memory the same on the first read, from the
  index, and with the index rebuilt; no memory read as the user's.

Broken by hand, each red, green restored:
- no journal: TestCutOffChangeIsFinished
- no on-disk hash check on write: TestHandEditDuringAChangeStays
- no on-disk hash check on remove: TestHandEditDuringARemoveStays
- broken files written: TestBrokenFileIsLeftAsItIs
- no hand-edit detection: TestHandEditIsTheUsers
- scope lowercased: TestEachMemoryIsAMarkdownFile (and memdistill's
  TestReadsQuietSessionsOnce, which found it)

Not tried: the full go test ./... (mote and mica both over their cores);
the live app's own memory moved in (a sandbox copy only);
`go vet ./...` on Linux (the WSL box has no gtk4 headers for Wails);
a hand edit through a sync service's own conflict copies.
2026-11-14 14:27:01 +08:00
yetone 50d88f17ce sessions: the Claude subscription bridge's own runs are not local sessions
iwinux on X: a Pi request through a group a Claude subscription serves
was listed twice in the request log, once as "Pi · Claude Code" and once
as "Claude Code · Local session", with the same tokens and cost.

Cause: a bridge run is the real Claude Code. It saves its session in the
account's projects folder, in the caller's folder's project: the user's
own ~/.claude or a saved account's claude-accounts folder, both of which
appdir.ClaudeHomes lists. listCCFiles read it as a session of the user's,
and the ledger's pairing (request id, then session and tokens) didn't
match it with the gateway's record, whose session is the caller's. So
every call was counted twice: request log, usage ledger, cost totals,
the Sessions page. -p runs and interactive (TUI) runs alike, plus a
branch's cut copy and a replayed transcript.

Fix: every session a bridge run saves is named by the new
internal/bridgesid. New is a version 4 UUID whose last six bytes are a
keyed SHA-256 of its first ten, the key a random file of this computer's
(<config>/claude-bridge-session-key, made once by temp file + link). To
Anthropic, which Claude Code sends the session id to, it is as random as
any, so it marks nothing upstream. startRun passes --session-id for a new
run (-p and interactive; the TUI helper keeps a --session-id it is given
and makes a marked one otherwise), replaySession and cutSessionWhere name
their files with it. listCCFiles leaves out a .jsonl, and a session's
sub-agent folder, whose id bridgesid.Is knows, for agent "claude" only.
That one listing feeds calls, the ledger, the request log, Sessions,
traces and WSL distros, so all of them drop the double count. Other
bridged runs (warm-up, askClaude, /usage, WSL -p) use
--no-session-persistence and write no session.

Rows already counted twice: a bridge session already removed (a run's
session is removed when it ends) is gone from the ledger already, as it
is read from the files there are. One still on disk under an old random
id (a live or shelved run resumed under it, or a stopped gateway's
leftover in a caller's folder) can't be told from the user's and stays
counted until it is removed; old ids carry no mark to fix it on read.

Tests: TestNewIsKnown, TestKeyKept, TestKeyMadeOnce (bridgesid);
TestBridgeSessionsAreNotLocal (sessions: a marked session in the user's
folder, its sub-agent file, and one in a saved account's folder give no
calls and no rows; the user's session beside them counts);
TestClaudeRunSessionsAreTheBridges (-p and interactive, a new run and a
replayed transcript) and TestClaudeCutSessionIsTheBridges (gateway).

Broken by hand, on mica: bridged() returning false made
TestBridgeSessionsAreNotLocal red (calls req_m1..m4, want req_m1 alone);
newUUID back in startRun, replaySession and cutSessionWhere made both
gateway tests red (print, interactive and the cut copy).

Run on mica at this head (rebased on 7ea1e6a4b): gofmt -l clean, go vet
./... ok, go build ok; go test -tags nogui ./internal/bridgesid
./internal/sessions ./internal/usage ok; ./internal/gateway -run
'Claude|Subscription|Bridge|Fork|Shelf' ok. At the first base (8a59e7616):
the same vet plus GOOS=linux -tags nogui and GOOS=windows vet ok, the three
builds ok, ./internal/claudetui ./internal/appdir ./internal/masking ok.
The full ./... suite was not run: mica's suite lock had five full suites
queued ahead of it, and this ships now.

Not tried: a real Claude Code run with a real account (mote is down;
the -p --session-id flag is Claude Code's documented one, and the
interactive helper already passed it); Windows and WSL runs.
2026-11-14 14:17:52 +08:00
yetone 7ea1e6a4b3 usage: the tray panel and the TUI leave out what the Usage page hides
onkashiko on X: a provider whose allowance card was hidden in the main
window (Usage > Overview, "Hide from Overview") still showed in the menu
bar's panel. The panel's Allowances tab had only its own Arrange list
(panelUsageHidden) and read the full cards.

Now the panel leaves out a card whose cardHideKey is in usageCardsHidden
and the rows in usageWindowsHidden (withoutHiddenRows), as Overview does;
a menu bar cell's card still shows (panelPeek). A subscription whose
every card the page hides counts in the foot's "{n} hidden" and shows as
hidden in Arrange; Show there
also drops its keys from usageCardsHidden, since the panel follows the
page. All of it is panelPageCut in the Usage plugin's page.js, which every
window loads, so the core scripts get no bigger (TestCoreScriptBudget
unchanged). Hiding from the panel alone still leaves the page as it is. The
panel reads settings again each time it is shown (loadBack), so a hide or
unhide in the main window reaches it with no restart.

Siblings: magpie tui's Usage page leaves out the same cards and rows
(usageShown, read at every quota read). The menu bar's cells and tooltip
show only the cards picked in Settings, so they keep a hidden card as
before; routing, caps and counting are unchanged.

Run:
- panel-page-hidden.test.cjs (new): chromium + webkit, en/zh/zh-TW/ja/de,
  10/10 green; red on the old app.js/panelarrange.js (cards still drawn).
- TestUsagePageLeavesOutWhatTheAppHides (new): green; red on the old
  pages.go (balance, account and row still listed).
- GUI: the 128 files that read the panel, Usage or tray code, chromium +
  webkit, every language, on mote: 17 files red, rerun alone at
  concurrency 1 here 123/449 red and at origin/main 015860f2d 122/449,
  the same tests but tray-cell-click's chromium en, which is red alone on
  main too (#5215); the rest noted on #5475. tray-cell-click + panel-arrange +
  panel-page-hidden together before the last rebase (no GUI file changed
  in it): 21 of 22, the one red tray-cell-click's (#5215). At this head
  (after the move into page.js): panel-page-hidden, panel-arrange,
  panel-balance-order and i18n-keys green; the reds in key-balance-card
  (de), panel-fold, tray-cell-click (zh) and usage-cards-hide are each
  in the origin/main 015860f2d record above.
- Full suite (go test -tags nogui -count=1 -timeout 45m ./...) on mica
  under suite.lock at 734f06b64 (this change before the move into
  page.js): 97 packages ok; internal/gui red only on TestCoreScriptBudget
  (fixed by the move), internal/gateway red from "too many open files in
  system" at mica's load ~65. At this head on mote: internal/gateway,
  internal/gui, internal/tui, internal/settings and internal/redact (the
  one commit rebased over) ok; gofmt -l clean; go vet, GOOS=linux go vet
  -tags nogui and GOOS=windows go vet ./... clean; go build ok.
- Rebased onto origin/main 667ac8bd6 (5faed634d): internal/gui (budget
  included), internal/tui and internal/settings ok on mote;
  panel-page-hidden + panel-arrange 18 of 18.
Not tried: the real tray panel by hand on a live install.
2026-11-14 14:10:24 +08:00
yetone 667ac8bd6f settings: a look at one setting takes the shared settings, not a copy
settings.Load() copies the whole Settings (clone + deepCopy of every map
and slice) for each caller. 133 places read one field of it and threw
the rest away: the proxy for every outgoing request (netproxy), the
GitHub token, the China mirror switch, a model's output cap, wire or
price on a gateway request. With a real account in the tray, Load's
clone was 26.6 MB of the 318 MB the process allocated in its first
seven minutes, most of it through netproxy.For on each request.

Each of them now reads settings.Shared(), the read-only settings every
caller is given for the same settings.json. Only reads were changed:
a scalar field (string, bool, int, float) or a map field's index
read. A caller that keeps a whole map or slice, or calls a method on
the settings, still takes Load's copy.
2026-11-14 14:02:49 +08:00
yetone 8a59e76165 memory: candidates and set-aside memories don't stay forever
memory.json grew from distilled candidates nobody reviewed and from the
superseded members of merges, which nothing ever removed. memory.Prune
now applies retention on every hourly tick of memdistill.Keep, with
distilling and dreaming on or off:

- a candidate unchanged for 30 days (memory.Keep) is archived;
- an archived or superseded memory unchanged for 30 more is removed,
  recorded in removed (a sync doesn't bring it back) and, if distilled,
  dismissed (never proposed again);
- what the user wrote or pinned (Fixed) is never archived or removed.

Untidy keeps a merged memory when one of its members was removed since:
it is all that is left of that member.

Run on mote at base fc896a9f6, then again at base 90ad90646 (main moved
by GUI-only commits; memory, memdistill and backup rerun ok there):
go test -count=1 ./internal/memory/... ./internal/memdistill/...
./internal/memembed/... ./internal/backup/... ./internal/davsync/...
./internal/library/...: all ok. go vet of memory and memdistill for
darwin, windows and linux: clean. gofmt -l: clean.

Broken by hand, each red: Prune without the Fixed check (archived 3,
removed 3: the pinned and the user's own went); without removed()
(Removed empty, a sync would bring it back); Untidy without the gone
check (the merged memory deleted).

Real data (~/.config/magpie/memory.json, read only): 206 memories, all
changed since 11-13, so the first run changes nothing.

Not tried: the full suite and the GUI suite (no GUI or route change).
2026-11-14 14:00:48 +08:00
yetone 90ad90646a gui: black draws a black dark theme, not Graphite's grey (CHENGJIAHEGOXIS on X)
CHENGJIAHEGOXIS, on v0.1.4124 (tweet 2121468612238266666), with three
dark-theme screenshots of Settings > General, one each with Default,
Graphite and a custom black picked: 「这三个颜色……都显示是一样的」,
「尤其是黑色始终一直是灰色」. Their screenshots show the same page in all
three: ground (25,25,27), card (32,32,34).

Why:
- v0.1.4124 tints the grounds with the pick's hue only (base + k*(c -
  mean(c))), lightness kept. Black and Graphite have no hue, so they
  changed nothing. Default draws no look at all (magpie's own).
- accentOn lifts a dark pick toward white only until it reads at 4.5:1,
  so black's dark ink came out #8a8a8a, next to Graphite's #89898f.

What changes (appearance.go):
- ground(): on the dark theme, a pick darker than the theme's background
  darkens every dark ground by as much (depth()). Black draws a black page
  (#000003), with cards, pills, lines, menus and the tray panel the same
  steps above it as in app.css (card #08080c, line #18181e). Graphite,
  and any colour as light as the ground, draw as before.
- lifted(): black's ink starts most of the way to white, so it is a light
  mono ink (#e0e0e0, dark text on its buttons), not Graphite's grey. On
  the light theme black is #000000, as before. The sibling, white on the
  light theme, now gets a dark ink instead of a mid grey.
- The light theme's grounds keep their lightness: a white pick would melt
  its white cards into the page.
- app.css: a swatch's edge and the chosen ring take a little of the text's
  ink, so the black swatch stays seen on the black page it draws.
- Default stays magpie's own look (grey grounds, indigo accent) for every
  user. Not changed here.

Tests:
- TestBlackIsBlack: black's dark page is black and each ground keeps its
  step; Graphite moves nothing; black's ink is light in dark (>= 1.8:1
  from Graphite's) and #000000 in light; white's light ink is dark; text
  reads >= 7:1 on black's grounds.
- appearance-look.test.cjs: "Default, Graphite and black are three looks",
  light and dark, both engines: three different --accent values; Graphite
  keeps the grey page; in dark, black's page is black, Settings' list sits
  on black's card a step above it, its ink is light; in light, black is
  #000000 ink.
- TestLookFixture's fixture gains #000000 and #52525b.

Run on mote (mote was unreachable for ~20 minutes; the red check ran on
mica), at this commit rebased on origin/main fc896a9f6:
- gofmt -l internal/gui: clean. go vet -tags nogui ./internal/gui, the
  same with GOOS=linux, and GOOS=windows go vet ./internal/gui: ok
  (before the rebase onto fc896a9f6, which touched nothing in gui).
- go test -tags nogui -timeout 45m ./internal/gui: ok (95s, before the
  rebase); at the rebased head go test -run
  'TestAccent|TestLook|TestTint|TestWallpaper|TestBlack|Budget': ok.
- node --test, both engines (the files run every language at 420 and
  1000px where they have that matrix): appearance-look 44/44, i18n-keys
  4/4 at the rebased head; checkbox-look 8/8, seg-contrast 14/14,
  settings-general 20/20, settings-sections 10/10, input-look 20/20
  before the rebase. api-key-theme 0/6 (#6444) and omarchy 8/14 (#6027)
  are red with the same cases on a copy of origin/main fc896a9f6.
- Broken by hand: with origin/main's appearance.go and its fixture
  regenerated for #000000 and #52525b, the new GUI case is red in dark in
  both engines ("black's page is black, not rgb(26, 26, 30)"); light
  passes there, as black was already #000000 ink on the light theme.
- Screenshots, both engines, Settings > General zh at 1200, Default /
  Graphite / black, light and dark, before (origin/main's lookCSS) and
  after (before shots on mica, after on mote): dark black's page goes (26,26,30) -> (0,0,3), card (35,35,39)
  -> (8,8,12); Default and Graphite unchanged; black's ring still shows.

Not tried:
- the real macOS app, WebView2 and WebKitGTK;
- the full Go and GUI suites.
2026-11-14 13:59:58 +08:00
yetone fc896a9f6f redact: a Bilibili BV id, an av number or a YouTube link's id goes as written, whatever the local model takes it for (jimlee0824v2 on X)
jimlee0824v2 on X: in a script's list of nine Bilibili videos
(bvs = ['BV1f94c6uEr3', …]), five BV ids went to the vendor as
{{SECRET_…}}, and the script the vendor's model wrote back could no
longer fetch them. A BV id (BV1 and nine base58 characters) is a public
video's id, not a secret.

Which finder took them: no rule. With Secrets and Personal on and every
kind on, the rules alone mask none of them (the "by the rules" checks in
TestPublicVideoIDGoesAsWritten). The local model did. Asked for real
(Privacy Filter and AstrLink Guard from mote's ~/evalcache) on the
reporter's script: Privacy Filter took all nine BV ids for secrets,
AstrLink Guard eight, and AstrLink Guard took av170001 for an account
number. That the screenshot shows five of nine is the model's score
around its threshold.

The class: a public video's id that the vendor's model needs as written
to look the video up. Now modelFits takes no span of any kind that is
- a BV id (^BV1[base58]{9}$) or an av number (av and up to 12 digits),
  by its own shape;
- a YouTube video's, playlist's or channel's id (10 to 64 of base64url's
  characters) only where its link is right before it: watch?v=, list=,
  youtu.be/, /shorts/, /embed/, /live/, /channel/ on youtube.com,
  youtube-nocookie.com or youtu.be. Eleven base64url characters alone may
  be a key's piece, so no shape alone exempts one.
Nothing is keyed on a field's name. The rules are unchanged: a key in a
BV id's shape after its name (api_key=BV1…) is masked still. Numeric
public ids (a Douyin video's, an X status's) were already held back by
the model checks for bare digits (numberNamedSecret, accountCues).

Tests:
- TestPublicVideoIDGoesAsWritten (new): the reporter's nine BV ids in
  the tool call's arguments as the screenshot shows them, a bilibili.com
  video link, av170001, YouTube watch/youtu.be/shorts/embed/playlist/
  channel links; none masked by the rules, nor as secret or
  account_number from the model. Still masked: a 12-character secret
  (Xq7vR2mK9pLs), BV1 with 0/O/I/l (not base58), a BV id with a 13th
  character, a bare 11-character run, the same run after example.com's
  watch?v=, a key after a YouTube link's &key=, and api_key=BV1VMnk68E9Q
  by the rules.
- TestBVScriptToolCallKeepsIDs (new): the same through MaskJSON as an
  OpenAI tool call's arguments.
- TestMaskEval: cases bilibili-bvids (the reporter's script) and
  video-links, with both real models' recordings added (only these two
  entries; the rest of the recordings were left as committed).
- Broken by hand: the publicID check taken out of modelFits.
  TestPublicVideoIDGoesAsWritten FAILs with each of the nine BV ids
  masked ('"BV1VMnk68E9Q" as secret: masked in "…'{{SECRET_ekl3f6pv}}'…"'),
  av170001 as {{SECRET_…}} and {{ACCOUNT_…}}, the watch?v= id and the
  playlist id; TestBVScriptToolCallKeepsIDs FAILs with all nine as
  {{SECRET_…}}. Restored: both pass.

Run at 3f862a27c's tree (base 1248dc16c, origin/main when pushed):
- mica-run: gofmt -l internal/redact docs (empty); go test -count=1
  ./internal/redact/... ./internal/masking/... ok; GOOS=linux go vet
  -tags nogui ./... ok; GOOS=windows go vet ./... ok; go vet
  ./internal/redact/ ok.
- mote-run (the models' cache is on mote only):
  MAGPIE_EVAL_CACHE=~/evalcache go test -run TestMaskEval -v
  ./internal/redact/ PASS, both models asked.
Not run before the push: the full suite (mica's suite lock had three
suites queued at load 53); it runs after the tag. Not tried: a running
magpie with the model on, and the reporter's whole request (only the
screenshot was posted).

docs/subsystems/gateway-routing.md says it beside the hex number rule.
2026-11-14 13:47:23 +08:00
yetone 1248dc16c7 gateway: Gemini's own tools (Google Search, URL context, code execution) reach Gemini (daoche_wuzui on X)
daoche_wuzui (X, v0.1.4095): magpie's Gemini route ignored Gemini's built-in
tools. A generateContent body's googleSearch/urlContext/codeExecution were
dropped in parseGemini, so the model never searched and no
groundingMetadata came back.

- ir.Request carries GoogleTools. parseGemini keeps googleSearch (and
  google_search_retrieval), urlContext and codeExecution; chat's tools
  read them in both shapes ({"googleSearch":{}} and {"type":"url_context"}).
- buildCodeAssistSent, shared by Code Assist, AI Studio, Vertex and plugins
  spoken to on Code Assist, sends them when no function is declared
  (Google refuses built-ins beside functionDeclarations), Gemini models only.
- A plugin whose API is googleapis.com (Antigravity) now searches itself
  for Anthropic web_search, like the built-in Gemini accounts.
- The Gemini reply carries groundingMetadata (chunks + webSearchQueries),
  streamed and not; executableCode/codeExecutionResult parts are read
  as text instead of being lost.

Run:
- mote-run at 3dc1f13ed (before rebasing onto 27 newer commits):
  go test -tags nogui ./internal/gateway ./internal/provider ok (916s, 139s);
  go vet both; GOOS=windows go vet ./... ok; GOOS=linux go vet -tags nogui
  ./... ok; gofmt -l clean.
- At 80f1e05a3 (the rebase after it only took agent, claude and davsync commits): go vet and GOOS=windows go vet of gateway and provider ok; go test -run "Gemini|CodeAssist|Search|Google|Antigravity|AIStudio|Vertex|Chat|Plugin" ./internal/gateway ok (83s); go test ./internal/provider ok (136s).
- Broken by hand, each red: googleToolsFor, googlePlugin, the reply's
  grounding, the ranCode decode, chatGoogleTool.
- Real account, sandbox HOME (Antigravity plugin, gemini-3.8-flash-low),
  the plugin patched in the sandbox to log what magpie sent it:
  - generateContent with googleSearch+urlContext+codeExecution: the three
    tools reached the plugin, the reply had groundingMetadata (3 chunks,
    webSearchQueries).
  - streamGenerateContent: groundingMetadata in the stream.
  - /v1/chat/completions with {"googleSearch":{}},{"type":"url_context"}:
    both reached the plugin, a grounded answer came back.
  - /v1/messages web_search_20250305: googleSearch sent, the reply had
    server_tool_use + web_search_tool_result.

Not tried: an AI Studio key or Vertex account (unit tests only); the
Gemini CLI account (Google refuses individual Code Assist now); real
code-execution parts (Antigravity's model wrote code as text); whether
Antigravity honours urlContext (a fetch gave the same stale page with and
without it). Anthropic web_fetch is not mapped to urlContext. The full
./... suite is queued behind six runs on mote's suite.lock and had not
run when this was pushed.
2026-11-14 13:15:20 +08:00
yetone 6cc70b2b3c agent: deskCatalog cleans an absolute /-spelled path too (#4785)
Dopetaiga's 3751d6cb3 made ownCatalog clean an absolute catalog path, so
a /-spelled one names magpie's list on Windows. deskCatalog, the same
predicate for the Codex app's list, still joined dir onto an absolute
path and never matched one. With the app gone, Sync left
model_catalog_json naming a list it had removed. It now has the same
shape; the WSL spelling keeps its branch.

Run on Windows 11 (xiaomi-gpu, win-run, -tags nogui):
TestCodexSyncMendsGoneCatalog, TestCodexDesktopListSlashSpelled (new),
TestCodexOwnCatalogGoneNotPutBack and TestCodexDesktopList.* are ok at
this tree. With main's codex.go, not_the_provider and the new test are
red. With 3751d6cb3's codex.go (ownCatalog fixed, deskCatalog not), only
the new test is red. On macOS the bug is not visible (/ is the native
spelling there).

Batch record (ggbdpq's five patches #3254 #3356 #4258 #6391 #4785 and
the two follow-ups), on mica through suite.lock:
- At 8c58d9b0b (base 7b002b6be): gofmt -l clean; go vet ./... on darwin,
  windows and linux (nogui) ok; builds ok;
  go test -tags nogui -count=1 -timeout 45m ./... exit 0, 99 packages ok.
- Rebased onto 27c998aba (12 commits, no file in common) at 0806a4fe8:
  vet on all three OSes ok, and internal/agent, internal/provider and
  internal/davsync are ok. Rebased again onto aba6aeac2 (a provider
  balance-history commit, no file in common): at this tree, go vet
  ./internal/... (plus windows for agent, provider and davsync) is ok,
  and internal/provider, internal/agent and internal/davsync are ok.
- Ablations: each new test is red with its product file reverted to main.
  The Windows ones ran on xiaomi-gpu.
Not tried: a real two-process forget, and a real WebDAV server.
2026-11-14 13:14:36 +08:00
yetone f62e93b8aa agent: Claude's Unwire gives up the stashed model in every case (#4258)
The #4258 patch kept the model in the stash until the write that puts it
back or takes magpie's out has gone through. When neither write runs (the
stash kept one of magpie's models and the user has picked their own
since), the model stayed stashed after the Unwire. Before the patch,
unroute's unstash always took it out. It is now forgotten after the
switch in every case that returns nil, which is main's behaviour with
#4258's ordering.

Run (mica, at this tree): TestClaudeDisconnectLeavesNoModelStashed is ok
here and ok at main's claude.go, codex.go and stash.go. With 46b365337's
claude.go alone it is red ("the stash still holds a model after the
Unwire: relay/glm-4.6"). TestDisconnectFailureKeepsStashedOriginals is ok.
gofmt -l clean; go vet of internal/{provider,davsync,agent} on darwin,
GOOS=windows and GOOS=linux is ok.

Not changed: the other agents' restore paths, filed as #6601.
2026-11-14 13:08:40 +08:00
Dopetaiga f12a1f79d8 agent: ownCatalog cleans an absolute /-spelled catalog path on Windows (#4785)
A config.toml naming the catalog with an absolute /-spelled path was
not recognised as magpie's own: the raw string matched neither the
base-name ref nor the \ spelling, so Sync left the key in and Codex
could not load its config once the list was gone. Clean the absolute
path too; on Windows that turns its slashes into the native ones.
The WSL spelling keeps its own branch.
2026-11-14 13:08:40 +08:00
ggbdpq 8cd8cf31bc claude: a saved account's directory sign-in older than the saved one is not taken over it (#6391)
A spare handed to Claude Code comes back from the switch signed out
when its own config directory was made again meanwhile (#4750): the
directory keeps the sign-in from before the hand-over, Claude Code
refreshes its own copy while it serves on the account, and the switch
back saves that as the account's. The next run on the account then took
the directory's older sign-in over the fresh saved one — takeClaudeDir
takes whatever tokens differ — so the spent copy replaced the fresh one
in logins.json, the refresh in the directory was refused and emptied,
and every request on the account failed till it is signed in again.

The directory's sign-in is now left to the saved one when it is older
(the later expiresAt is the newer, as the imports' newer-wins, #4532):
has=false has claudeSavedDir make the directory from the saved sign-in
again, so the account comes back usable whichever way the directory
came to hold an older copy. What was there is cleared first, so an
older keychain item cannot shadow the fresh file on a Mac.

Run (-tags nogui, GOCACHE private, parent e730a14dc):
- TestClaudeDirOlderSignInKeepsTheSavedOne: red with claude_dirs.go
  ablated back to the parent (test kept; the same red on the parent
  commit a8fa771a6 first showed it), green with the fix restored.
- go test ./internal/provider: one failure, TestResolveVia, failing the
  same on the parent commit alone (Get "https://gw.invalid:58207/v1":
  EOF, this machine's proxy); the new test passed in the full run.
- targeted and directory/switch-adjacent tests with -race: ok
- gofmt clean, go vet ok, GOOS linux/windows/darwin build ok

Generated-by: GLM-5.3-Flash (ZCode)
(#6391, ggbdpq)
2026-11-14 13:08:40 +08:00
ggbdpq 1dbd3bb07c agent: a Disconnect whose restore write fails leaves the originals stashed
skygunner (#4258): Claude and Codex unroute took the stashed originals
out of the stash before the config write that puts them back, so a write
that failed (a full disk, a file a watcher held) lost them for good, and
a retry had nothing to put back. The same shape was in Claude's
putClouds, and the model's original was taken out before the write that
restores or replaces it, which comes after unroute.

The originals are read with peek and taken out by forgetValues only once
the write has gone through, each only while it is still the value peeked:
one a concurrent change wrote since stays stashed. The model stays stashed
for the caller: Unwire takes it out after its write, and picking a model
of the agent's own after it.

A file that doesn't parse is copied aside before it is written over, as
it was (lastgood.KeepUnparsed); a change reports nothing new. The same
take-out-before-put-back shape in the other agents' restore paths (agy,
antigravity, cline, claudedesktop, astrbot) is left as it is.

Run (worktree at base a8fa771a6):
- go test ./internal/agent -run TestDisconnectFailureKeepsStashedOriginals:
  ok, both computers; broken by hand: forgetValues called before the
  write (claude, injected) puts the failure back
- go test ./internal/agent: ok
- gofmt -l: clean; go vet ./internal/agent: clean

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-14 13:08:40 +08:00
ggbdpq 4082f6d00e davsync: a part re-enabled on a state with no Off mark joins again
kupakupar (#3356): re-enabling the library (or an agent's models) on a
computer that synced with the part left out sent that computer's older
content up over the server's newer one. What #6428 fixed for states
since it writes — a part left out is marked in Off, and one synced again
joins like a first sync — did not reach the states older magpies wrote:
they carry no Off mark, so the join saw a real hash against the
nothing-hash the last sync left and took it as a change here, against a
server it had already seen.

A part that syncs now, whose baseline is the nothing-hash a left-out
part carries and that holds something of its own here, joins again the
same way: each side's own counts as changed there, the newer stays. A
state since #6428 already names such parts in Off and takes the old
path; a first sync has no baseline to compare and is the join already.

Run (worktree at base a8fa771a6):
- go test ./internal/davsync -run TestSyncPartTurnedBackOn: ok, the
  marked and the unmarked state both; broken by hand: the unmarked
  state's fallback loop taken out puts the overwrite back
  (TestSyncPartTurnedBackOnWithoutOffMark)
- go test ./internal/davsync -count=1 -timeout 25m: ok
- gofmt -l: clean; go vet ./internal/davsync: clean

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-14 13:08:40 +08:00
ggbdpq 284b221727 claude: a forget waits for runs in the account's directory (#3254)
switchSavedLogin waits on the run marks another magpie's process leaves
beside a saved account's directory (#4532), but ForgetLogin removed the
directory with no look at them: another process's run in it (a /usage, a
warm-up, a keep-alive) had its directory taken from under it, and the
switch ForgetLogin does first handed nothing over — the removed
account's run may still refresh its sign-in there.

ForgetLogin (claude) now takes the account's in-process run mutex and
waits on every other process's run mark up to claudeRunWait, refusing
with errClaudeRunning past it, before it switches away or removes
anything: nothing is removed under a run, and the saved sign-in stays.

Left: forgetClaudeDir's two other callers keep their shape — a fresh
sign-in's replacement of an older saved directory (signin.go) rebuilds
one at once, and the switch hand-over's removal runs behind
switchSavedLogin's own wait.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-14 13:08:40 +08:00
yetone aba6aeac22 lessons: the third raise landed by 13:00, not 11:00
Docs only; no code run.
2026-11-14 13:05:56 +08:00
yetone 2a8e77f99d lessons: 11-14 a third core budget raise (27c998aba)
Docs only; no code run.
2026-11-14 13:05:44 +08:00