Commit Graph
8210 Commits
Author SHA1 Message Date
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
yetone 015860f2da provider: the balance history is parsed once while the file is unchanged
Every usage read (the tray's, the panel's, a minute apart at most while
something asks) gave each balance its trend by reading and parsing all
of balance-history.json, 365 KB on the owner's real accounts, and
sharedBalanceHist parsed it a second time. It showed as 6% of an idle
tray's CPU profile, all of it encoding/json.

balanceHistShared now reads it through filememo, kept while the file's
size and time are the same (and, written just now, its bytes).
readBalanceHist, for the two callers that change and write it
(noteBalanceHistory's new points, fold's moved keys), is a copy of that
with each key's points its own, so nothing changes the shared parse.
The trends and shareBalances only read, and use the shared one.

Run (mote): go vet ./internal/provider; go test -run
'Balance|Fold|Unread|Quota|Shared' ./internal/provider ok (writes and
reads within one second among them).
2026-11-14 13:03:16 +08:00
yetone 8f4ef16ea3 gui: a tray logo is masked once, when the cells come, not on every draw
mpCells kept each provider logo as the NSImage decoded from its file,
and mpDraw masked it again (a 128x128 bitmap drawn, scanned twice and
cut) every time the menu bar image was drawn: each show, each
appearance change, each frame of the bird's flap. Drawing the source
also left its full-size decode cached in the NSImage for as long as the
cells were up, which vmmap showed as 4.6 MB of CG image on a tray with
a few large PNG logos.

mpGlyph now does the mask once per logo in mpCells and keeps only the
cropped mask (copied out of the 128x128 bitmap, so that goes too) and
whether it is a solid tile. The decoded logo is released at once.
mpMasked only fits and tints the kept mask.

Run (mote):
- go vet ./internal/gui; go test -run 'Tray|Image|Cell' ./internal/gui ok
  (TestTrayImageMonoLogos, TestTrayImageLogoSizes among them).
- Pixel identity: every logo in assets/icons (213), light and dark, at
  scale 1 and 2, rendered through trayImagePNG with the old and the new
  code: 852 of 852 PNGs byte-identical (a throwaway test, not committed).
2026-11-14 13:03:16 +08:00
yetone 27c998aba0 usage: the tray panel's and Requests' costs follow each provider's currency
onkashiko on X: with Currency set to By provider, the menu bar panel
still showed every cost in one currency; providers and models were not
each in their own. drawLedColumns and drawLedRank (shared by the tray
panel and the window's Requests tab) formatted every value with no
provider, so fmtCost fell back to the Totals in currency.

- usageapi.Ledger echoes the provider a page is filtered to
  (`provider`, omitempty).
- app.js: ledProv(l, split, id) names the provider of a value: the
  ledger's filter, the row's provider (provider split), the provider
  part of a modelAt id, or for a model split the provider(s) that served
  it when they all share a currency. ledFormat/ledFormatLong take it,
  so the rank's values and sub-lines, the tooltip's rows and the axis
  (when one provider is picked) are in that provider's currency. Sums
  (the panel total, the tooltip total, a model served in two currencies)
  stay in the Totals in currency.
- page.js: the Requests head and the cost head use the filter's
  provider; the heatmap tip too. Other fmtCost calls are sums or
  sessions with no provider and are unchanged.
- core script budget +491 (1,269,040 -> 1,269,531): drawLedColumns and
  drawLedRank are drawn by the panel, so there is no lazy page to move
  this to; packed to the shortest form.
- docs/subsystems/gui-shell.md says how By provider reaches the panel.

Run:
- At 065fb6a8b (rebased on 7d5475769), mote: gofmt clean;
  TestCoreScriptBudget and TestLedgerSaysItsOneProvider ok;
  panel-currency-provider.test.cjs 20/20 (chromium + webkit x en, zh,
  zh-TW, ja, de; panel 440/320px, window 1100/420px, no sideways
  scroll, no page errors).
- At ff3ab573d (same change on 90932ed1f), mica, under suite.lock:
  go vet darwin, linux nogui, windows ok; builds for all three ok;
  go test -tags nogui -count=1 -timeout 45m ./... : 99 packages ok,
  exit 0. mote: go test usageapi, gui, usage ok.
- GUI suite, the 155 files the change can reach, mote: 2581 tests, 105
  failures in 13 files; the same 13 files give 104 at 90932ed1f. The
  one extra is tray-cell-click webkit en, flaky on both trees run
  alone (head green twice, base red once). Filed: grip-inset,
  key-balance-card, panel-fold, tray-cell-click, usage-* (#6293,
  #6294, #6295, #6499, #6003, #5872, #6414, #5869, #5796, #5215,
  #4790); panel-shortcut's 20 reds newly filed as #6606.

Broken by hand:
- panel-currency-provider on the old assets (MAGPIE_ASSETS): 20/20 red,
  with the reporter's symptom (DeepSeek $1.00, SiliconFlow $0.500
  under By provider).
- TestLedgerSaysItsOneProvider red with `out.Provider = f.Provider`
  removed.

Not tried: the real app's tray panel with real yuan and dollar
providers.
2026-11-14 12:42:46 +08:00
yetone 7d5475769b gui: the page's files are typed from magpie's own table, not the system's
Handler registered the page's five types with mime.AddExtensionType. The
first call makes the mime package read and parse the system's whole type
table (/etc/apache2/mime.types on macOS, ~18,000 allocations) and keep
it: ~2 MB of an idle tray magpie's live heap (pprof inuse_space on a
real-account tray run on mote). http.ServeContent asks the same table
for any file whose Content-Type isn't set.

Now assetTypes names every type the page's own files, plugin pages'
files and provider icons are served as. servedAs sets it before
ServeContent looks at the name, so neither the registration nor
ServeContent reads the system table. The system's table (Windows'
registry, which another program may change) still never decides how the
page's files are read.
2026-11-14 12:34:47 +08:00
yetone 15d4acbadf lessons: 11-14 a second core budget raise (dc85a7ca5)
Docs only; no code run.
2026-11-14 12:34:37 +08:00
yetone 6ad734802e plugin sign-in: a login page that carries the sign-in page in its address can be finished from a pasted address (plugins#1090)
CodeArts' international browser sign-in opens Huawei Cloud's login page
with the authorize page, port and all, in service=. loopbackPorts read
only the page's own query, found no port, and the sign-in offered no
paste box. On magpie running on a server (yfishyon on plugins#1090) the
browser ended on 127.0.0.1:<port>/oauth/callback and nothing could finish
it, while the mainland sign-in (port= in its own query) could be pasted.

loopbackPorts now also reads a web address in the query one page deep.
A redirect to a non-loopback https page (ZCode's) still names no port.

Run: TestLoopbackPorts has the international and mainland shapes; the
international one is red on the old code ("" want "37093"). go vet and
go test -tags nogui -count=1 ./internal/provider pass on mica. Not tried:
a real international sign-in pasted from another machine.
2026-11-14 12:31:48 +08:00
yetone c51b0ca9fa sessions: the Antigravity app connected to WSL has its usage read from the distro (@guyng35955 on X)
@guyng35955 on X: on Windows, with the Antigravity app connected to a
WSL Ubuntu, magpie showed no Antigravity usage.

Why. Antigravity 2.x (dist/wsl.js and languageServer.js in its
app.asar) runs a Linux language server in the distro when it is
connected to WSL ($HOME/.antigravity-server/bin/<version>/
language_server, started through wsl.exe with --app_data_dir
antigravity), so the conversations go to the distro's
~/.gemini/antigravity, not %USERPROFILE%\.gemini\antigravity. magpie
read Antigravity's conversations only from this computer's folder:
- sessions.wslAgents had no antigravity (nor agy, whose
  ~/.gemini/antigravity-cli in a distro wasn't read either);
- internal/agent kept a distro for the Sessions page only when one of
  wslKinds or the Copilot CLI's folder was there, so a distro with only
  the app's data never reached sessions.WSLHomes;
- and, found on the Windows box: no SQLite database under
  \\wsl.localhost opens in place. Every form (file: URI, plain path,
  mode=ro, provider.OpenReadOnly) answers SQLITE_BUSY after its 3s
  busy_timeout, since the share doesn't take the locks a WAL database
  needs. So listing the files alone would have shown nothing still.

What changed.
- agent: wslKept keeps a distro with ~/.gemini/antigravity(-insiders),
  and the probe looks for them (no agent row for them).
- sessions: wslAgents reads the app's conversations (insiders under
  their own key) and agy's in a distro; their summary rows name the
  distro's folders as Linux does (agyFolder with goos "linux", so
  /home/me/site, not a Windows path). The distro's calls count in
  Calls (wslFiles("antigravity"), wslCallFiles("agy")). The listing
  kept on disk (sessions-wsl.json) carries each file's row, rev and
  read-only, so a stopped distro keeps its titles and folders. A
  distro's ~/.gemini that is this computer's own (a link) is read once,
  as this computer's (sameDir).
- sessions: openAppStore opens agy's and the app's databases read only
  in place, or, under \\wsl.localhost or \\wsl$, as OpenUntouched does
  (immutable with no -wal, else from a copy of the db and its -wal).
- docs/subsystems/agent-wiring.md says which distros are kept for reads
  only.

Not changed: session-read consent ("allow selected" names agents found
on this computer) doesn't look in WSL, as before for every WSL agent.
OpenCode's and ZCode's SQLite readers aren't used for a distro (not in
wslAgents), so they keep provider.OpenReadOnly.

Run (at the tree rebased on dc85a7ca5; then rebased on c8290df25, which
changes nothing under internal/sessions or internal/agent):
- mote: gofmt -l internal (clean); GOOS=linux go vet -tags nogui ./...
  and GOOS=windows go vet ./... ok; go test -tags nogui -count=1
  -timeout 45m ./internal/sessions/ ./internal/agent/: ok (sessions 104s,
  agent 223s).
- Windows 11 (xiaomi-gpu, win-run): go test -run TestWSL
  ./internal/sessions/ ok.
- Real \\wsl.localhost read on xiaomi-gpu: a fixture conversation
  (WAL) and conversation_summaries.db, and agy's conversations, written
  in the WSL distro magpie-desktop's real ~/.gemini from inside Linux;
  a throwaway test on Windows with WSLHomes at
  \\wsl.localhost\magpie-desktop\home\yeton. Before openAppStore: agy
  listed with no folders, the app's conversation missing, 0
  antigravity calls, listing 6.4s (each open waits 3s for BUSY).
  After: the conversation listed with the distro, its title, folder
  /home/me/site, tokens and 4 calls; agy's folders read; listing
  0.21s. With a writer in the distro holding a title only in the -wal
  (wal_autocheckpoint=0, db held open), Windows read the -wal's title.
  The fixture and binaries were removed after.

Broken by hand:
- the three wslAgents entries and the Calls line out:
  TestWSLAntigravityApp red (no antigravity session from the distro);
- sameDir check out: TestWSLAntigravityLinkedHomeOnce red (listed as
  the distro's);
- the listing's row (m.agy, m.rev) not carried: TestWSLAntigravityApp
  red (no title or folder);
- wslKept without the Antigravity dirs: TestWSLAntigravityHome red
  (no homes).

Not tried: a real Antigravity sign-in connected to WSL (the box's app
isn't signed in, and the connection needs its GUI), so the language
server's own files are this fixture, laid out as its source writes
them; the full suite (five full suites were queued on mote's
suite.lock and two on mica's).
2026-11-14 12:27:25 +08:00
yetone c8290df259 provider: Devin's Adaptive and Fusion picks are no longer served
The live gateway's /v1/models listed devin/Adaptive and devin/adaptive,
and Devin answered both with 502 "no API providers are available".
They came from magpie, not the plugin: the plugin's list (and its cached
copy in plugin-providers.json) has neither, since parseFamilies and
parseConfigFamilies skip Adaptive and Fusion. The owner's providers.json
keeps "Adaptive" and "adaptive" in the devin entry's picks (models), saved
when the built-in still listed Devin's router families, before ce8d0e065
served Devin's chat API. A pick only leaves Models when a list that had it
stops having it (dropGonePicks), and no list fetched since ever had these,
so after the move to the plugin they were served as picks of the user's
own (Exposed's unlisted picks) and offered to every agent.

normalize now reads a devin provider's Models and Delisted without
Adaptive and Fusion, in any case (devinRouter, withoutDevinRouters, which
devinModelsFlatten now uses too). Every reader that goes through All
(the gateway's /v1/models, the agents' lists, the editor's Picks) sees
them gone, so old files are fixed for every user on read; the next Save
writes the file without them, and a save that sends one back drops it.
Scoped to provider id devin: another provider's "adaptive" is its own.

Not changed: AccountModels (an account's own list only narrows what it
serves; dropping a lone "adaptive" there would widen it to every model),
Fallback ("devin/adaptive" as another provider's fallback is still tried
and refused) and settings.json's hiddenModels/picked lists (they hide or
pick, never add a model). PickedFrom keeps them, which only means "listed
then". The plugin needs no change.

Run:
- TestDevinRouterPicksNotServed (new): a sandbox HOME with the owner's
  devin entry as written, the plugin moved and its list cached. Red on
  the old provider.go: "served [Adaptive adaptive swe-2 claude-opus-5-5
  Fusion fusion], want [swe-2 claude-opus-5-5]"; green with the change.
- Real data: magpie built at a83fe2325 and at this change (-tags nogui,
  on mica), `magpie models` under a sandbox HOME holding copies of the
  owner's devin entry from providers.json, plugins.json, plugin-auth.json,
  migrations.json and plugin-providers.json. Old: devin/Adaptive and
  devin/adaptive first under Devin, as the live gateway lists them. New:
  the list starts at devin/swe-2, the rest unchanged.
- Full suite on mica through suite.lock at 3b164fafb (this change on
  a83fe2325): gofmt -l empty, go vet ./..., GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./..., go build for darwin, linux (nogui) and
  windows, go test -tags nogui -count=1 -timeout 45m ./...: suite exit 0,
  99 packages ok, no FAIL.
- Rebased onto dc85a7ca5 (56 files changed upstream, b76016676 in
  internal/provider): gofmt, vet (darwin, linux, windows) and
  internal/provider's tests again there: vet-ok, ok internal/provider 156s.
  Then rebased once more onto 74c94b5db and e36541ddf (internal/gui
  appearance and site/ only, not re-run).

Not tried: a request through a real gateway, since the requests that
still go (devin/swe-2 and the rest) take no path this change touches.
2026-11-14 12:25:28 +08:00
yetone 74c94b5db0 gui: a picked accent tints the theme's grounds (CHENGJIAHEGOXIS on X)
CHENGJIAHEGOXIS asked, on 0.1.4112 and again on 0.1.4116 ("依然没变,是不是
出bug了"), for the dark theme to follow the colour they picked. v0.1.4114
(a83fe2325) tinted only the chosen thumbs (--mark-fill). Their 0.1.4116
screenshot shows those thumbs purple, but the page, sidebar and cards are
still neutral grey: bg (25,25,27), card (32,32,34). Nothing tinted the
grounds.

lookCSS now also sets the theme's grounds from the picked colour.
- Window, light: --bg, --card-2, --pill, --pill-hover, --seg-track, --line,
  --line-2. Cards stay white.
- Window, dark: --bg, --card, --card-2, --pill, --pill-hover, --line,
  --line-2, plus the menus' --pop-bg.
- Tray panel: the body.panel grounds, in light and dark. tintPanel and the
  Windows title bar read --bg, so they follow.
Each ground takes 5% (light) or 8% (dark) of the colour's offset from its
own grey (base + k*(c - mean(c))). Lightness is kept, so a grey pick changes
nothing. With no accent, or under Omarchy, nothing is drawn.
accentOn and --mark are checked against the tinted grounds too.

Tests:
- TestAccentTintsGrounds covers:
  - every block is tinted;
  - lightness is kept (contrast to the base <= 1.1);
  - a grey pick changes nothing;
  - text is >= 7:1 and the accent >= 4.4:1 on the tinted --bg and --card,
    for many picks;
  - no accent gives no CSS.
- TestTintBasesAreAppCSS holds the Go bases to app.css.
- TestLookFixture holds tests/fixtures/look-accents.json to lookCSS
  (UPDATE=1 rewrites it).
- appearance-look.test.cjs now reads the real CSS from the fixture. A new
  case, in each engine and theme, picks a colour on Settings › General with
  and without a wallpaper, and checks:
  - the list, the sidebar and the body are tinted;
  - Default turns them grey again;
  - the panel's --bg is tinted.

Run on mote, at this commit rebased on origin/main 7b002b6be:
- gofmt -l internal/gui: clean.
- go vet -tags nogui ./internal/gui, the same with GOOS=linux, and
  GOOS=windows go vet ./internal/gui: ok.
- go test -tags nogui ./internal/gui: ok (126s).
- node --test, in both engines, of: appearance-look, omarchy,
  api-key-theme, checkbox-look, sidebar, settings-sections,
  settings-groups, i18n-keys, panel-options-fold and the seg-/theme files.
  Result: 120 of 138 pass. The 18 reds are api-key-theme (6, #6444),
  omarchy (#6027) and settings-groups' warm-ups case (#6597). On a fresh
  origin/main b005d1a47 the same three files give the same 18 reds.
- Screenshots in both engines: Settings › General, dark, zh, the reporter's
  purple #66258d. With no accent the ground is (26,26,30) and the card
  (35,35,39). Before this change the purple pick gives the same values.
  After it, the ground is (27,21,34) and the card (36,30,43).

Rebased on origin/main dc85a7ca5 (then e36541ddf, site/ only; 4 commits, none in appearance, app.css
or boot.js) and run again on mote at this head:
- go test -tags nogui -run 'TestAccent|TestLook|TestTint|TestWallpaper|Budget'
  ./internal/gui: ok.
- appearance-look and i18n-keys: 44 of 44.

Broken by hand: with both tints at 0.0 and the fixture regenerated,
TestAccentTintsGrounds fails and the four new GUI cases are red. Both pass
again with the change restored.

Not tried:
- the real macOS app, WebView2 and WebKitGTK;
- the full Go and GUI suites.
2026-11-14 12:24:31 +08:00
yetone e36541ddf2 site: llms-full.txt names AIGoCode with the other preset relays
dc85a7ca5 added AIGoCode to docs/relay.html and did not rebuild
llms-full.txt, so worker.test.mjs's check that the committed file is
what llms-full.mjs builds went red. Built with node llms-full.mjs.

Run on mote: node --test site/*.test.mjs: 121/121.
2026-11-14 12:23:40 +08:00
yetone dc85a7ca59 providers: AIGoCode is a preset that takes a key (MindfulReturn on X)
MindfulReturn on X asked why magpie's plugins have no AIGoCode sign-in
and whether they have to add the provider by hand. AIGoCode has no
sign-in to plug in: it hands out API keys, each bound to one group. So
the answer is a preset, like 鱼鱼连线's, not a plugin: Add provider ›
AIGoCode asks only for the key.

From AIGoCode's own docs (www.aigocode.net/docs/api, openai-compatible,
anthropic-compatible, responses): one root, https://api.aigocode.dev,
with Chat Completions and Responses at /v1 and Messages at the root.
It runs on sub2api ("Model ... is not available for this group",
API_KEY_REQUIRED from /v1/models and /v1/usage, /api/v1/settings/public
answers), so a key's balance is read at sub2api's /v1/usage by the
relay probe already there; no BalanceURL is needed. A key spends its
plan (Pro/Max/Ultra) and then its balance, so its billing is unsaid,
like MiniMax's Coding Plan keys. Website is the invite AIGoCode
sponsors magpie with (site/sponsors.js has the same one); it is not
badged Sponsored, as 鱼鱼连线 isn't. Keys page: /dashboard/keys.

- presets.go: the aigocode preset (KindRelay, icon aigocode).
- billing.go: aigocode in unsaidPresets.
- icons/aigocode.png and pngIcons: AIGoCode's own logo
  (www.aigocode.net/images/algocode-logo.png), trimmed to 124 in 128.
- core_budget_test.go: +12 for the name in pngIcons; main was at the
  budget to the byte, and the list is read wherever an icon draws.
- site docs (en, zh, ja): import's preset ids and relay's preset list.

Not wired: AIGoCode's Gemini-native endpoint (PresetDef has no Gemini
field). A key serves only its group's models, so a third-party
("可外接") group such as Claude API(AWS) or ChatGPT API(Azure) is
the one to use. If AIGoCode later takes the in-app seat, its partner
entry needs an id other than aigocode (checkPartner).

Tests: TestAIGoCodePresetTakesAKey: kind, key, endpoints as documented,
keys page, balance probed at api.aigocode.dev, billing unsaid. Broken
by hand: without aigocode in unsaidPresets it is red (billing "payg").

Run on mote (mica and mote both over their cores, so no full suite;
CI runs it), at origin/main 24effac0e + this change:
- gofmt -l clean; GOOS=linux go vet ./internal/provider and
  GOOS=windows go vet ./internal/provider ./internal/gui: ok.
- go test -count=1 ./internal/provider: ok (147s);
  go test -count=1 ./internal/gui (whole package, budget included): ok.
- node --test, Chromium and WebKit: icon-tile, icon-one-tone,
  add-sheet, add-sheet-custom, preset-name, icon-builtin-over-address
  (en, zh): 113/113 at a4937f8ff; i18n-keys, gui-de, gui-ja,
  gui-zh-tw, add-sheet, icon-tile: 19/19 each engine.
- Real use, sandbox HOME, built binary: `magpie presets` lists
  "AIGoCode  aigocode  magpie provider add aigocode <key>";
  `magpie provider add aigocode <fake key>` writes the preset's
  chat/responses/anthropic/website/keysUrl, and AIGoCode itself
  answers /v1/models with 401 "Invalid API key".

Not tried: a real AIGoCode key (models listed, a request, the balance).
2026-11-14 12:21:48 +08:00
yetone b005d1a473 update: a fresh install of Stable's version stays on Stable (fishmagic80 on X)
The site now offers Stable's downloads, but the app's Update channel is
Every version until changed, so a Stable install was offered the newest
at its first check. Before that check, a fresh install (no version run
before and magpie's folder new, from whatsNew.start) asks the feed for
Stable's version and the newest; when it is Stable's and a newer one is
out, settings take "updateChannel": "stable" (settings.TakeStable, under
the file lock, keeping a channel already set). A feed that can't be read
is unknown and asked again at the next check. A version that is both
Stable's and the newest stays on Every version: its download can't be
told apart. update.LatestStable never falls back to GitHub.

docs/reference.md and the privacy pages (en, zh, ja, llms-full.txt) say
a fresh install asks ?channel=stable once.

Old installs: nothing changes for them. Until a release with this
becomes Stable, a Stable download (0.1.3078 today) is still offered the
newest unless Settings → Update channel is set to Stable.

Run at 936c70756, on mote: gofmt -l internal/ clean; go vet (darwin),
GOOS=linux and GOOS=windows go vet of internal/gui, update, settings ok;
go test -count=1 ./internal/update ./internal/settings ./internal/gui ok
(gui 99.9s). TestFreshStableInstallStaysOnStable goes red (2 subtests)
with the takeStable call removed (broken by hand, on mica). llms-full.txt
regenerated and current.
Not run: the full go test ./... (mote and mica each had several suites
queued on the lock); not tried with a real Stable install.
2026-11-14 12:17:40 +08:00
yetone 60ad579979 site: show Stable's version and offer its downloads (fishmagic80 on X)
fishmagic80 asked on X for the site to show the Stable channel's version
and download it directly. The home page now asks /api/latest and
/api/latest?channel=stable together. When Stable is known and isn't the
newest, the hero's version line adds "· Stable <v>", and a quiet
two-button control over the platform cards switches every download link
between the newest (/download/<platform>) and Stable
(/download/stable/<platform>). #stable opens the page on Stable. While
Stable is unknown, or is the newest, the page is as before.

The worker serves /download/stable/<platform or file> from Stable's
release (the same stableOf ledger as ?channel=stable) and answers 503,
not the newest, while Stable is unknown. The download event's link
property gets a "stable/" prefix; no new property is sent.

Words in en, zh, ja, de, matching the app's (稳定版, 安定版, Stabil).

Run at 936c70756 (rebased on origin/main 7b002b6be), on mote:
- node --test site/*.test.mjs: 121/121. The new download/stable test is
  red on the old worker.js (broken by hand).
- Playwright (on mica, before the rebase; nothing under site/public/index.html or i18n.js changed in it), Chromium and WebKit × en/zh/ja/de × 1280/390 wide × light
  and dark against worker.js served locally with a stubbed feed: the
  hero and control show both versions, translated; Stable makes every
  card link /download/stable/…, Latest restores them; no horizontal
  scroll.
Not tried: the page in Firefox.
2026-11-14 12:17:40 +08:00
yetone 24effac0ec gui: the tray keeps the words it asked for, not a language's whole table
The tray tooltip says each usage window's name and unit the way the
Usage page does, from i18n.js's table. pageWords kept the language's
whole parsed table for good: ~2 MB of an idle tray magpie's live heap
(pprof inuse_space, real-account tray run on mote), for the dozen words
a card asks for.

Now pageWord keeps only the words asked for (capped at 512). A new word
parses the table once, and the table is kept a minute for the other new
words of the same card, then let go on the next ask. A word asked
before is answered without parsing again.
2026-11-14 12:13:19 +08:00
yetone 7b002b6be8 library: an MCP command's %USERPROFILE%, $USERPROFILE and ~\ are the home on every system (0xBCD18E on X)
0xBCD18E's Library server ran
"%USERPROFILE%\AppData\Local\Programs\Pinky\pinky.exe", and the check
said it couldn't find "%USERPROFILE%\A…": magpie read $NAME, ${NAME}
and ~ in a command but not cmd.exe's %NAME%, so the only way to share
one server across computers with different user names was a per-device
command.

Now HOME and USERPROFILE are both the home, on every system, as $NAME,
${NAME} or %NAME% (either case), and a leading ~ or ~\ too:
- library.json (and so sync and backups) keeps them as written;
- an agent that reads references in a command (Claude Code, CodeBuddy,
  WorkBuddy, Grok, Gemini, omp/Qoder/AtomCode, OpenCode, Cursor) is
  given the home's own variable where it runs: ${USERPROFILE} on
  Windows, where an agent seldom has HOME, ${HOME} on a Mac, Linux and
  in WSL, where nothing has USERPROFILE. Before this, $HOME went to
  Claude Code on Windows as ${HOME}, which it usually hasn't;
- every other agent (Codex, Kiro, Droid, Copilot, Crush, Goose, Pi, ...)
  and magpie's own start (the check, the router, Codex through the
  gateway) get the home's path;
- any other %NAME% (%APPDATA%) is a variable on Windows only, and is
  left as written elsewhere, so 100% or %Y% in an arg stays as it is;
- a command's environment: a leading ~ and %USERPROFILE% / %HOME% in a
  value are put in as the home for every agent and for magpie's start
  (homeEnv); ${NAME} there stays envref's.
No cwd: a Library server has none.

Tests: TestCmdVarsUserProfile forces cmdOS to windows, darwin and linux
for Codex, Claude, Cursor, OpenCode and Claude in WSL, command, args
and env; TestCmdVarsUserProfileLaunch starts a real server by
%USERPROFILE%<sep>prog, %HOME%/prog and $USERPROFILE/prog.
TestCmdVarsPerAgent pins the Unix variable; TestCmdVarsSync expects
${USERPROFILE} in .claude.json on Windows.

Run: the red was checked on origin/main e0889719c's cmdvars.go,
mcp_check.go and mcp_run.go with these tests: all 8 subtests of
TestCmdVarsUserProfile and TestCmdVarsUserProfileLaunch FAIL; with the
change, ok on mote (darwin), on xiaomi-gpu (Windows 11, win-run: the
real check starts the server by %USERPROFILE%\prog, and Claude Code's
.claude.json gets ${USERPROFILE}/bin/x) and in WSL magpie-desktop
(wsl-run). Full suite at b84b6dc3c (this change on e0889719c) on mica
under suite.lock: gofmt -l clean, go vet, GOOS=linux go vet -tags
nogui, GOOS=windows go vet, the three builds, and go test -tags nogui
-count=1 -timeout 45m ./...: 99 packages ok, suite exit 0. Rebased onto
8df4239a8; internal/library run again there.
Not tried: a real agent (Claude Code, Codex) launching the server on
Windows from its written config; no GUI change.
2026-11-14 12:04:38 +08:00
yetone 8df4239a8b lessons: 11-14 core budget raised again for one line (c5b40bf89)
Docs only; no code run.
2026-11-14 12:03:04 +08:00
yetone a4937f8ff9 gateway: the effort tests' fake upstream answers only the turns
TestEffortUpdateRefused went red on macOS CI at eb1b83000:
"effort_update_test.go:158: upstream body: unexpected end of JSON
input". The fake records the last request's body in f.got, and the Codex
account's model list (provider/codex_models.go, a GET to CodexBase +
"/models" with no body) can reach the same server after the turn. When
it lands between the post and sentShape, f.got is empty.

effortCodexAccount now hands only paths ending in /responses to the fake
and answers anything else 404, which is what the model list got in effect
before (an SSE body it couldn't parse).

Run: with a GET to /models injected after the turn, the old helper fails
with CI's exact message and the new one passes (mica). go vet and
go test -tags nogui -count=20 -run Effort ./internal/gateway pass on
mica; gofmt clean. Not run: the full suite (test file only).
2026-11-14 11:59:40 +08:00
yetone 6d8fcb93a7 memdistill: switched off, the background read asks no model
Keep called auto() before Run looked at the switch. auto is
gateway.AutoVision, which ranks every provider's models and loads the
whole models.dev catalog: 3.6 MB of a tray-only magpie's live heap
with real accounts, for a run that read nothing, five minutes after
start and every hour after. Memory reading is off by default.

Keep now reads distill.json first and skips the round when it is off;
a file it can't read goes on to Run as before, which reports it.

Run: go test ./internal/memdistill on mote, ok.
Broken by hand: skipping the check turns TestKeepOffAsksNoModel red
("switched off, it asked for a model"); the test then switches it on
and waits for the ask, so it can't pass on a loop that never runs.
2026-11-14 11:47:59 +08:00
yetone 6333ee5586 filememo: a parse unread for five minutes is let go
filememo kept every parse for the life of the process. What start up
reads once, RenameLegacy's look at every agent's config (a 1 MB YAML
look, a 600 KB JSON), stayed in a tray-only magpie's live heap: ~2 MB
of its 12.8 MB with real accounts.

A read sweeps when idleFor (5 minutes) has gone by since the last
sweep, dropping the parses not read since. What a poll reads (the
tray's every 3 minutes, the window's every 15 seconds) stays; a parse
goes 5 to 10 minutes after its last read, and the next read parses it
again. Swept on a read, not a timer, since a timer armed inside a
test's synctest bubble is the bubble's.

Run: go test ./internal/filememo on mote, ok.
Broken by hand: never deleting turns TestUnreadParseLetGo red.
2026-11-14 11:47:59 +08:00
yetone b76016676f provider: Gemini's and Antigravity's offered models are kept per stamp, so the tray's usage read lets the catalog go
visibleQuotas built exposedIDs("gemini", "antigravity") on every usage
read, and each build loaded the whole models.dev catalog through
knownElsewhere → catalog.ListedBy. The tray reads usage every few
minutes, so a tray-only magpie with real accounts kept 5.6 MB of
catalog (of a 12.8 MB live heap) that loadIdle never got to drop.

keptExposedIDs keeps the answer while provider.StampNow is the same
(no provider, account, setting, plugin or catalog change) and for 30
minutes at most, for what a stamp can't see.

Run: go test -run 'ExposedIDs|Quota' ./internal/provider on mote, ok.
Broken by hand: always building turns TestKeptExposedIDsBuiltOncePerChange
red ("built 5 more times while nothing changed").
2026-11-14 11:47:59 +08:00
yetone 90932ed1fa gateway: Claude Code's model discovery is shown every model by an id it keeps
Claude Code's Gateway Model Discovery (CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY)
puts in /model only the ids matching /(claude|anthropic)/i: Tvi in the
2.1.316 bundle, te.data.data.filter((se)=>/(claude|anthropic)/i.test(se.id)),
on GET <ANTHROPIC_BASE_URL>/v1/models?limit=1000 with User-Agent
claude-code/<version> (Xs(), not claude-cli/) and anthropic-version:
2023-06-01. A remote magpie's Kimi, GLM and DeepSeek never showed (zent00
on X, tweet 2121440002244747428).

That request alone (claudeCodeDiscovers: the User-Agent and the header,
never another magpie) is now shown a chat model whose id says neither by
Claude Desktop's alias anthropic/magpie-<n> (aliasFor), which unprefixed
already serves as the model for every client, before any provider's
model of that spelling; no Claude id is spelled so. Its display_name is
the agents' list name, which /model shows. Ids Claude Code keeps, names a
gateway key gives models, and every other client's list are unchanged; a
bare-id row it wouldn't keep is left out (its full id's row is there).
"anthropic/<magpie id>" was not used: a provider named anthropic (the
Anthropic preset's id) serves any model asked by that spelling. Zero
config, so no switch.

Run:
- TestClaudeCodeDiscoveryKeepsEveryModel, on mote: red on the old
  gateway.go ("not shown anthropic/magpie-9301644634 for auto/kimi-k3"),
  green with the change; with the anthropic-version check broken by hand
  it fails on the claude-cli/ client. TestCindyDiscovery and the Desktop
  tests green.
- Real Claude Code 2.1.316 binary on mote, sandbox HOME, against the
  gateway with a fake Anthropic upstream: its cache gateway-models.json
  held {"id":"anthropic/magpie-4484984192","display_name":"DeepSeek V4 ·
  DeepSeek"}; `claude -p --model anthropic/magpie-4484984192` answered
  PONG and the upstream was asked model deepseek-v4. Claude Code warns it
  assumes a 200k window for an id it doesn't know, as for any non-Claude
  id.
- gofmt -l: clean. Package vets/builds and go test ./internal/gateway
  started on mote; the full suite (go vet, GOOS=linux/windows vet,
  builds, go test -tags nogui -timeout 45m ./...) is queued under
  mote's suite.lock and runs after the push, per the ship-at-once rule;
  its reds get their own commits.
Not tried: interactive /model screen (the rows come from that cache
file), a real remote magpie over LAN with a gateway key.
2026-11-14 11:43:27 +08:00
yetone c5b40bf898 claude-desktop: after Use Claude Magpie the lit row is Claude Magpie, and its Code tab's row says it is on magpie (xMopf7RF on X)
xMopf7RF on X, 0.1.4111: clicking Use Claude Magpie seemed to connect
their own Claude Desktop, and left "Claude Code · Claude Magpie" saying
"Not connected · uses its own settings" with its switch off.

The wiring was right: with the Separate app on, connecting claude-desktop
writes only Claude-Magpie-3p's config (desktopSets), and the user's own
Desktop is left alone. The page said otherwise twice:
- the row that turned on was still named Claude Desktop. While the
  Separate app is on, state() now names the claude-desktop row Claude
  Magpie (desktopiso.Name), since that is the only config it wires.
- the claude#magpie-desktop row is not wired itself, and need not be:
  Desktop's Code tab runs Claude Code with
  CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST, so its requests go through
  Claude Magpie whatever that folder's settings.json says. While Claude
  Magpie is on magpie, the row carries twinCode (agent.DesktopTwinCode)
  and its line, lit, says "On magpie through Claude Magpie" (en, zh,
  zh-TW, ja, de).

The core script budget goes up 67 for that one connectLine line, cut to
the shortest words that say it; the Agents rows draw it, so there is no
page to move it to. docs/subsystems/agent-wiring.md says both.

Tests:
- TestClaudeMagpieCodeTabRowIsOnThroughIt (agent): DesktopTwinCode only
  for claude#magpie-desktop, only while Claude Magpie is on magpie.
- TestClaudeMagpieRowsAfterUseClaudeMagpie (gui): sandbox HOME, POST
  connect after turning the Separate app on: the wired row is named
  Claude Magpie, the Code tab row has twinCode, the user's own Desktop
  config is unchanged and no Claude-3p folder is made.
- desktop-twin-code.test.cjs: clicks Use Claude Magpie; no lit row is
  named Claude Desktop, the Code tab row's line is lit and fits, the
  click doesn't scroll; en/zh/zh-TW/ja/de, 1100 and 640 wide, Chromium
  and WebKit.

Run (mica; mote's load was over its cores), at e0889719c + this change
(the one later main commit, a83fe2325, is CSS and Go appearance only):
- gofmt -l clean; go vet -tags nogui ./internal/agent ./internal/gui on
  darwin, GOOS=linux and GOOS=windows: ok.
- go test -tags nogui -count=1 ./internal/gui (whole package, budget
  included): ok; ./internal/agent -run 'Claude|Desktop': ok.
- node --test, both engines, every agent-*, desktop-*, library-desktop-*
  and i18n-* file (78 files, 1358 tests): 1303 pass, 55 red in 4 files,
  each red the same at origin/main e0889719c and filed:
  agent-details-ready (#6373, #6369), agent-switch-accounts (#5925),
  agent-menu-label (#6371), desktop-tiers (#6475). desktop-twin-code 20
  of 20, desktop-twin, desktop-isolated, desktop-isolated-claude,
  library-desktop-twin, i18n-keys, i18n-en-no-cjk ok.

Broken by hand: at origin/main e0889719c (api.go given only the
TwinCode field, DesktopTwinCode stubbed false), both Go tests are red
("Claude Magpie on: \"Claude Desktop\" wired false"; the code row not
on), and desktop-twin-code is 20 of 20 red ("Not connected · Claude
Code · Claude Magpie uses its own settings").

Not tried: a real Claude Magpie.app in a sandbox HOME on this change
(005178104 did one for the button itself); this change only names rows
and reads the same wiring.
2026-11-14 11:42:50 +08:00
yetone b325718f0a antigravity: turned-away lines go reworded, not broken up; Antigravity min 0.1.12 (#1118)
Since 11-14 Google's check reads past invisible characters. A system
prompt with Claude Code's billing line and Agent SDK line, broken up
with two U+200B in every word as the cloak sent them, was turned away
5 of 5 with the bare 429 "Resource has been exhausted". Claude Desktop's
Code tab through magpie to Antigravity failed every turn (hc295971796
on X, tweet 2121429628019781849), and on v0.1.4110 with the Antigravity
Cloak plugin Antigravity hit 429 very often (daoche_wuzui, tweet
2121432333769433178).

The built-in cloak (codeassist.go) now rewords each line Google turns
away, in plain words:
- the x-anthropic-billing-header line is left out to its line's end; a
  system part or message holding only it is dropped;
- "built on Anthropic's Claude Agent SDK" -> "built on the Claude Agent
  SDK by Anthropic";
- Codex's "based on GPT-5" -> "built on GPT-5";
- Hermes' "created by Nous Research" -> "built by Nous Research";
- omp's RFC "keywords" -> "key words".
A copy an older magpie or middleware broke up (U+200B, U+2060, soft
hyphen, inside or between words) is matched and reworded as the line.
The Code tab's main line passes as written and is kept.

The plugins repo's packages carry the same rewording (plugins 5bb41941:
opencode-antigravity-auth 0.1.12, opencode-agy-cli-auth 0.1.41,
middleware-antigravity-cloak 0.1.7 on the dist branch). The Antigravity
mover's min goes to 0.1.12, the version dist has (these packages are
not on npm); the cloak middleware is Official and updates itself.

Run:
- real Antigravity account, sandbox HOME, gemini-3.8-flash, 10
  sequential requests each through the new plugin: Code tab main prompt
  as Claude Desktop sends it 10/10 200, Agent SDK subagent line 10/10,
  an old two-U+200B copy 10/10, Codex GPT-5 10/10, Hermes' earlier
  persona 10/10, omp's RFC line 10/10. The zero-width break went 0/5.
- mote-run: gofmt -l; go vet, GOOS=linux go vet -tags nogui and
  GOOS=windows go vet of internal/gateway, provider, cli;
  go test -count=1 -timeout 45m ./internal/gateway/ ./internal/provider/
  ./internal/cli/ ./internal/middleware/: all ok (gateway 926s);
  vet clean, gofmt clean.
Broken by hand: codeassist.go from origin/main with these tests: 6 fail
(TestAntigravityCloakClaudeCode2316, ...RewordsEveryLineItTurnsAway,
...AnswersHermesAndCodexByDefault, TestOnlyAntigravityIsSentThePrompt
Reworded, ...LineWrappedOrWidened, ...TurnsCodexsGPT5ThreadAwayOnce).
Not tried: models other than gemini-3.8-flash; the whole go test ./...
(only the four packages this touches); Claude Desktop itself (its Code
tab's system prompt was captured and replayed instead).
2026-11-14 11:42:32 +08:00
yetone 71a806749d sessions: a paginated Codex rollout moves to a longer provider id by its row (@xMopf7RF on X)
@xMopf7RF on X (tweet 2121441393424113800): the Sessions page's Move
refused an old Codex session with "rollout-2026-03-09T09-25-….jsonl.zst
keeps its history by byte, and "magpie" is longer than the provider it
names: Codex couldn't open it moved", and offered nothing else.

Since 67b12956a a paginated rollout's session_meta is only rewritten at
its own length (Codex keeps places in it by byte), and MoveCodexProvider
refused a longer id outright. But Codex reads a paginated thread's
provider from its row in the state database, never from its file
(codex-rs read_thread; RetagPagedCodexThreads already moves such threads
by the row alone, tried with the real codex 0.166). So now
rewriteCodexProvider leaves such a line as it was and says so (kept),
and moveCodexPaths moves the thread by its row. Every caller gets it:
the Sessions page's Move, Resume's move first, and the sync's
MoveCodexThreads/MoveRecentCodexThreads, which met the same refusal for
a provider shorter than magpie.

With no row to move it by, it can't move at all: it is refused as
sessions.StuckError, every file put back and no trash copy left, and the
API says stuck with the provider it stays on. The page then says why,
that the session stays on that provider unchanged and shows in Codex when
Codex uses it again, and that Delete clears it into magpie's trash, where
it can be restored. New string in zh, zh-TW, ja and de.

Run, at 7951989c6 (on origin/main e0889719c):
- go test -count=1 -run 'TestMoveCodexProvider|TestRetagPaged|TestPortCodex'
  ./internal/sessions/ on mote: ok.
- Old code back (codex_provider.go from e0889719c, StuckError stubbed):
  TestMoveCodexProviderPagedByRow and TestMoveCodexProviderPagedNoRow
  FAIL with the reporter's exact error text; green with the change.
- node --test sessions-codex-provider-stuck, sessions-codex-provider,
  sessions-codex-provider-pick, i18n-keys, i18n-en-no-cjk on mote,
  Chromium and WebKit, five languages, 900px and 420px: 42 of 42 pass.
  The new GUI file with the old client.js: 0 of 20 pass.
- gofmt -l on the changed packages: nothing.
- Full suite (vet x3, builds x3, go test -tags nogui ./... -timeout 45m)
  queued on mote's suite lock; pushed before it ran, per the owner's
  ship-at-once rule. Its result goes in a follow-up.

Not tried: a real Codex resuming a thread moved this way. The row-only
move is the one RetagPagedCodexThreads makes, which was tried with codex
0.166.0 exec resume (docs/subsystems/agent-wiring.md). Not reproduced:
the no-row case with real Codex, where Codex 0.166 keeps a row for every
paginated thread; it is covered by a fixture only.
2026-11-14 11:42:17 +08:00
yetone a83fe23252 gui: a picked accent tints the chosen thumb too (CHENGJIAHEGOXIS on X)
「强调色是按照颜色走的,但是主题深色依然还是灰色」 and 「就是我截图的原来的
灰色,还是没变化」: after ed63a5be5 the chosen option's word took the
accent, but the thumb under it stayed the theme's grey. In the dark theme
that is what the eye reads (Settings › General: the Dark segment and the
Off/On switches, with a purple accent and a wallpaper), so it still looked
grey.

- accentVars adds --mark-fill: the accent over white at 12% (light), over
  the dark switch thumb #3a3a3f at 26% (dark). --mark is now made to read
  at 4.5:1 on that fill as well as on the old surfaces (inkOn takes
  several).
- The same "chosen" grounds use var(--mark-fill, <their own grey>): every
  segmented thumb (.thumb, .seg > .thumb, so .segs/.ptabs/.sse-views),
  #gatewayKeys .klf-tab.on, .am-seg, .day-chip, .warm-tabs,
  importapps .apptab, Sessions' .sm-agents .opt.on, and Context's
  .ctx-look-b.on (which also takes --mark for its icon).
- --mark-fill is never set without an accent, so magpie's own look and
  Omarchy are unchanged: the fallback is each rule's old value.
- Not tinted, on purpose: the side-nav's open-page row (its icon already
  takes --mark, as a Mac sidebar does), list selections, icon buttons.

Tests:
- TestAccentReadable reads --mark-fill, checks --mark on it in both themes
  for eleven picks, and that a purple's fill is not grey.
- appearance-look.test.cjs: the window test reads the thumbs of Theme,
  Loading bird and Reduce motion: the card's grey with no accent, the
  fill for #0d9488 and #db2777, and the grey again on Default, in
  Chromium and WebKit, light and dark.

Run (on mote, macOS; mica's and mote's suite slots were busy):
- gofmt clean; go vet -tags nogui ./internal/gui on darwin and
  GOOS=linux, GOOS=windows go vet ./internal/gui.
- go test -tags nogui ./internal/gui -run 'TestAccent|TestLook|TestWallpaper|Budget|CSS': ok.
- appearance-look 36/36.
- 21 GUI files the change reaches (seg-contrast, segs-glide,
  segs-press-redraw, sidebar, sidebar-glide, api-key-theme, checkbox-look,
  omarchy, context-map, sessions-manage, sessions-toolbar,
  gateway-key-limits, provider-rate-windows, editor-thumbs-batched,
  import-opencode, i18n-keys, settings-sections, settings-groups,
  strip-scrollbar, panel-options-fold, appearance-look), both engines,
  every language and width they cover: 330/364. The 34 reds are the same
  34 tests at origin/main e0889719c run alone: api-key-theme 6 (#6444),
  segs-press-redraw 24 (#4566, #3922), omarchy 2 (#6027), settings-groups
  2 (filed #6597).
- Broken by hand: with the old app.css the new thumb checks are red, 4 of
  4 window tests. Screenshots of Settings › General, Chromium, dark and
  light, default/teal/pink: default identical, the accent's thumbs tinted.

Not tried:
- The whole GUI suite and the Go suite (both machines' suite slots busy).
- The real macOS app, Windows WebView2, Linux WebKitGTK.
2026-11-14 11:30:34 +08:00
yetone e0889719c8 gateway: a Responses WebSocket turn streams without the HTTP stream field (#5291)
OpenAI's WebSocket mode doesn't use the HTTP stream field: a
response.create leaves it out and is streamed all the same. magpie made
each frame into the HTTP body its route would have had and kept the
field as the frame said it, so a client that left it out (M4n5ter on X,
AnacondaKC's Niko in #5291) got the provider's reply unstreamed and
every frame of it at the end. Codex sends stream:true itself, so it
never showed there.

turn now sets stream:true on every generating turn, whatever the frame
says (left out or false). It is the one place the three socket routes
(/v1/responses, /responses and Codex's backend route) make their body,
so all three are covered; a warmup (generate false) still answers
locally before it, and HTTP POSTs are unchanged.

Ported from AnacondaKC's patch in #5291 (62e3fd1ad), with these
differences: the test runs on /v1/responses and /responses, with stream
left out and with stream:false, checks the body sent upstream, and
TestCodexSocketStreamsWithoutStreamField covers Codex's route.

Tests: TestResponsesSocketStreamsWithoutStreamField and
TestCodexSocketStreamsWithoutStreamField, both red with responses_ws.go
at origin/main 8ed2ae030 ("no text delta before the upstream
completed"; "sent to ChatGPT unstreamed"), green with the change (on
mica). go vet ./internal/gateway for darwin, linux (nogui) and windows
on mote; gofmt -l clean.

Full suite (go test -tags nogui -count=1 -timeout 45m ./...) runs on
mica after the push; its result goes on #5291.

Not tried: a real client (Niko or the reporter's) against a real
provider.
2026-11-14 11:05:49 +08:00
yetone 8ed2ae030c claudetui: an image goes into the interactive mode on Windows 10 as a long paste, not -p (ok123now on X, #5061)
ok123now (magpie v0.1.3901, Windows 10 LTSC 21H2, Claude Code 2.1.316,
Claude Desktop): text worked, one 64x64 PNG was a 502 every try, and the
client asked again without end.

Cause: the helper pastes an image as its file's path in bracketed-paste
marks. Windows 10's conhost (10.0.19041) drops the marks on the way in
(the reporter's lead; #5061 and #5205 measured it on 19044 and 19045),
so Claude Code got the path as typed words, the helper waited out
pasteWait and exited 1, and the gateway answered 502.

Fix:
- claudetui: Claude Code reads its console as VT input (mode 0x208, read
  from a real claude.exe 2.1.316) and takes one read of over 800
  characters as a paste with or without the marks ($X=800 in 2.1.316,
  q6=800 in 2.1.281), a path with spaces after it as the image alone. On
  Windows the path is sent padded with spaces to 900 characters, no
  marks: over 800, and under the 1024-byte blocks the same conhost loses
  of a longer write (#5205). Elsewhere it stays bracketed.
- If the interactive mode still doesn't take a message (an image, or a
  block it can't paste), the helper ends the turn with an error result
  beginning claudetui.Unpastable instead of exiting, the gateway asks it
  once as claude -p with the image itself, and remembers that for 12
  hours. A redo that can't run is a 400, not a 502, so no client loops.
- The reporter asked to keep images interactive: -p counts at about
  twice the plan quota and has none of the interactive run's cache. The
  -p reason (Routing chip, all four locales, and the log line) says so.

Run, at this head (rebased on 925bc7188):
- win-run (Windows 11 26200): ./internal/claudetui; every test passes
  but TestShimFirstMessageWaitsForTools, red on the old code too (#4810).
  TestShimPaddedImageTakenWithoutMarks 3 of 3, TestImagePasteWindowsLength.
- The helper on a real claude.exe 2.1.316 in a ConPTY (sandbox
  CLAUDE_CONFIG_DIR, ANTHROPIC_BASE_URL to a closed port): padded and
  bracketed, the image reached the transcript as an image. A direct
  probe: bracketed and padded paths shown as [Image #1], a bare path
  stays words.
- wsl-run: ./internal/claudetui ok; go vet of claudetui and gateway on
  Linux and Windows.
- GUI: routing-entry, routing-intent-entry, claude-mode,
  claude-tui-setting, i18n-keys, i18n-en-no-cjk in Chromium and WebKit
  (Linux), 112/112.
- Full suite, wsl-run (Linux), go test -tags nogui -timeout 45m ./...:
  every package ok (gateway 883s, claudetui 164s) but internal/usage's
  TestRequestStateKeptAcrossACatalogFetchedAgain, a catalog CacheKey red
  already filed as #6572 and untouched here. The mote suite stayed queued
  behind other sessions' runs, so the suite ran on Linux.

Broken by hand: TestShimPaddedImageTakenWithoutMarks on the old code
(bracketed paste, fake console dropping the marks) is red: the shim
wrote 1 line of 3 in 30s. Its bracketed half is the old behaviour and
ends in an Unpastable error result, not an exit.

Not tried: a real Windows 10 21H2 console (no such box here); the -p
redo with a real Claude subscription. Long pasted text on Windows 10
still loses 1 KB blocks (#5205); this doesn't change that.
2026-11-14 10:48:55 +08:00
yetone 925bc7188b usage: the Requests card's up arrow opens what the bytes sent upstream were made of
theforeveriris (X, 2121408745616162998) saw 8169 requests send 8.6 GB
up and 1.0 GB down and wanted to know why. About 1 MB a request is
normal: every request sends the whole conversation again, with the
system prompt and the tools' definitions. This shows it.

Gateway: promptOf, which already parses the body off the request path,
now also counts the bytes of the system prompt, the tool definitions
and images in the body it read. upParts scales those to the wire bytes
and puts them on Record.UpParts. Nothing new runs on the request path,
and a body that isn't parsed stays "Not measured".

Usage: a packed row keeps the mix in 255ths under flag rowUpParts
(32768); the row stays 152 bytes. Totals gain up_calls, up_measured,
up_system, up_tools and up_images, and Shares carry up_bytes and
up_calls by agent and by model. settledCountVersion goes 4 -> 5, so
settled days are counted again once on the next start.

GUI (Usage -> Requests): the "↑ 8.6 GB" on the Requests card is a
button that opens a "Sent upstream" card: the average per request, one
sentence on why, a bar and legend for Conversation / Tool definitions /
System prompt / Images / Not measured, and the top 8 agents and models
with bytes sent and per request. The open state is kept; × closes it.
A request's details get a "Made of" line. zh, zh-TW, ja, de strings.
Entrance is 200ms ease-out, no movement under reduced motion.

Run (mote, at this head on 27e43ed26):
- go test ./internal/usage ./internal/usageapi: ok
- go test -run 'Prompt|UpParts|UpBytes|DownBytes|Traffic|Ledger|
  CodexOwnTurn' ./internal/gateway: ok
- go test -run Budget ./internal/gui: ok (after the rebase)
- go vet -tags nogui for darwin, linux, windows on usage, gateway,
  usageapi, gui: ok; gofmt -l clean
- GUI: usage-upload.test.cjs 32/32 (chromium + webkit, 1180 and 420,
  en zh zh-TW ja de); with i18n-keys, i18n-en-no-cjk,
  usage-ledger-bytes, usage-traffic, usage-ledger-detail: 144 pass,
  0 fail
- GUI subset i18n*, usage*, ledger* at f1f34d624: the only reds are
  usage-agents-hide, usage-cards-hide, usage-fold,
  usage-hidden-way-back, usage-ledger, usage-range-times and
  usage-speed-all-models. They are red the same way on origin/main
  f1f34d624 without this change and are already filed (#3414, #3415,
  #6003, #6294, #6295, #6499, #5834).
- Screenshots of the card: chromium en 1180 light, webkit zh 1180
  dark, chromium zh 420 light.
- Benchmark: promptOf on a 1.17 MB body, 2.8-3.9 ms/op with counting
  vs 3.2-3.7 without, same allocations (noise).
- Broken by hand: without the b.again guard,
  TestPromptKnowsWhatItsBytesWere goes red.

Not run: the full go test ./... and the full GUI suite. mote and mica
were loaded, with a suite already queued under suite.lock.
2026-11-14 10:22:25 +08:00
yetone 27e43ed26c LESSONS: 11-14, a budget guard left out before a push, a red fixed twice, a clock read twice
From the loop review of 92e760f3d (#6518), f1f34d624 and d6cb40475.
Docs only; nothing run.
2026-11-14 10:18:42 +08:00
yetone d6cb404754 gateway: the live reasoning fixture allows the time its first event really took
TestLiveVisibleReasoningFixture set start to now minus the event's at_ms
and then called see, which reads the clock again. Any time between the
two lands in the measured start, so on macOS CI (run 43530452364,
e730a14dc) it read 6790 where the fixture says 6789. The test now
records the time before setting start, and accepts the fixture's at_ms
up to the milliseconds that really passed during the first see.

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

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

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

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

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

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

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

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

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

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

Suite on mica at 6c88d61f0 + this commit: gofmt clean; go vet
internal/agent for darwin, linux and windows, internal/gui on darwin; go
test ./internal/agent ok (194.9s); ./internal/gui red only in
TestCoreScriptBudget (1269382 > 1268961). That test is red on
origin/main 6c88d61f0 as well, and #6518 is taken. This change adds no
script.
2026-11-14 09:58:49 +08:00