Commit Graph
7089 Commits
Author SHA1 Message Date
yetoneandFlandern1211 b90e130902 dsh: a fork's call waiting for its reply counts on neither card, not its source's (#5542)
d052fec0e gave a dsh fork without a parentSession its own row, named by
the reply ids it gets. A call whose reply dsh hasn't written down yet
still went by the opening, which the fork copied and only the source
owns, so the source's context line climbed with the fork's turns
(Flandern1211: the source's card showed the fork's 30,778 while its own
last call was 21,944).

routeOwners keeps each opening a fork's seed carried a second time
(ownerCopied). joinConvs leaves a call that names no session out of both
cards (ctxRec.Unmatched) only when its opening is such a shared one, it
has a reply id, and it ended within convsKept: the window Routing's
looseKeys waits in. A call with no reply id (routes from before
e8df78f33, a dsh that writes none) and one past that window go by their
opening as before, so the source keeps its history. An answer that left
a call out stands ctxWhileUnmatched (5s) instead of ctxAgain's minute,
and only while such a call is inside that window. This answers both
review points on 1bce689ed.

Ported from Flandern1211's ad461f7d4, with these changes:
- ctxRec.End time.Time is now Millis int64. The tab keeps one ctxRec
  per route in the range (up to 30 days); End took it from 240 to 264
  bytes, Millis to 248.
- The conflict with #2398's Canceled is resolved by keeping both.
- TestDshForkRouteAwaitingItsReplyIsNeithers also has a long call
  (begun 2m ago, ended 20s ago), and clears Session as well as
  Unmatched before its second join.
- New TestContextHeldAnswerStandsOnlyWhileAReplyIsAwaited covers
  contextFor's cache: an answer without held stands past 6s, one with
  held does not, one with held stands for 1s.

Run (mote, HOME=$(mktemp -d), -tags nogui):
- go test -run 'Dsh|Fork|Routing|Context|Conv' ./internal/gui/, and
  -run 'Dsh|ResponseID' ./internal/gateway/ ./internal/sessions/: ok.
- go test -count=1 ./internal/gui/ ./internal/sessions/: ok (117s, 60s).
- go vet ./internal/gui/ for darwin, linux and windows; gofmt -l: clean.
- node --test internal/gui/tests/context-*.test.cjs and
  compact-one-value.test.cjs (11 files): 474 of 474 pass. No GUI file
  changed; they guard the Context page it draws.
- Benchmark (temporary, not committed), 300k dsh routes over 2000
  sources and 2000 forks: joinConvs 125-135ms per pass with the change,
  140-270ms without; contextOfRecs 130-145ms with, 140-150ms without;
  allocations the same (108MB per pass). mote was at load ~120.

Broken by hand, each red: the age check, the reply-id check, the
Unmatched skip (phantom magpie-… row), held never set, held not
shortening the cache, Millis ignored, sharedOpening always false.

Not tried: a real dsh fork on this side. Flandern1211 measured the pair
on their computer: the source kept its 8 pre-#5491 calls, and a second
/api/context 6s later took 9ms instead of 575ms. Not changed: Routing
still goes by the opening for such a call (its looseKeys retries every
2s), and a fork call whose reply never comes goes back to the source
after a minute.

Reported-by: Flandern1211
Co-authored-by: Flandern1211 <163982805+Flandern1211@users.noreply.github.com>
2026-11-07 20:10:28 +08:00
yetone 61394481c7 agent: DeepSeek Harness Desktop is found on Linux (AUR, .deb, AppImage entry)
xianhongtao (magpie 0.1.3232, Arch Linux) has DeepSeek Harness Desktop
from the AUR (deepseek-harness-desktop 0.2.2rc.1-1) and no dsh CLI.
magpie knew the app on macOS and Windows only, so it said "DeepSeek
Harness CLI not found ~/.dsh/profiles/web/cordis.patch.yml".

HasApp for dsh now also finds the Linux app (linuxApp, desktopapp_xdg.go):
- a folder holding the Electron executable deepseek-harness with
  resources/app.asar beside it: /usr/lib/deepseek-harness-desktop (the
  AUR's) or /opt/DeepSeek Harness (electron-builder's .deb/.rpm);
- or the app's desktop entry in the XDG data dirs (XDG_DATA_HOME first,
  then XDG_DATA_DIRS, the first file of a name wins, Hidden=true hides
  it): Name=DeepSeek Harness, Type Application, MimeType holding
  x-scheme-handler/dsh, and its Exec program there (on PATH, or an
  absolute executable file: an AppImage anywhere). Scans of a folder are
  kept by its mtime, trusted only when read over a second after it
  changed and for a minute at most.
Linux only; macOS and Windows keep their own checks.

Siblings: everything reading HasApp for dsh follows: the profile a fresh
~/.dsh gets (profiles/desktop), the desktop lead and notices, cliHeld and
CLIMissing (so the GUI's and the CLI's "CLI not found" go away). The
"running" check for noticeDsh2 also knows deepseek-harness, the app's
Linux executable. With both profiles present (the reporter's case) Path
stays profiles/web as on macOS; the desktop lead picks the model shown.

Run (mote, through mote-run):
- go test -count=1 -race -run 'TestDshLinux|TestDshDesktop|TestCodexLinux|Lody' ./internal/agent/: ok
- go test -count=1 ./internal/agent/ ./internal/gui/ ./internal/cli/: ok
- gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; GOOS=linux/windows go build: ok
Run (wsl-run, magpie-desktop, Ubuntu 24.04): the TestDshLinux tests
-count=3: ok. The first WSL run caught a stale scan of a folder made
again within the same mtime tick; the 1s rule fixes it.

Broken by hand (mote), each red, then restored:
- installed() without onLinux: all three new tests red ("the AUR's app:
  app false, CLI missing true", "the AUR's entry, its program on PATH,
  not found", the profile = profiles/web, want profiles/desktop);
- no scheme check: "another app's entry taken for DeepSeek Harness's";
- no Hidden check: "an entry the user hid still counts".

Not tried: a real AUR, .deb or AppImage install of DeepSeek Harness
Desktop (the fixtures are the AUR PKGBUILD's entry and layout as the
reporter gave them, and AppImageLauncher's entry shape); the GUI suite
(no GUI file changed). The full suite runs after the push.

Reported-by: xianhongtao (Discord)
2026-11-07 19:48:49 +08:00
yetone 75d40ba48b ci: race gateway tests run in chunks taken in turn; 64 MB bodies are 20 MB under -race
The macOS -race gateway step split 3772 tests by sorted name into one
fixed share per core (3 on macos-latest), and the shares ran out of their
20 minutes with no test hung: run 42354008450 at 191f3c0af ended at 12m,
16m and over 20m (shard 2 in TestMediaJSONPastOldBodyLimit/images), and
42350695944 ran all three at ~19m20s. Two causes: the shares were uneven,
and a few tests scan tens of MB byte by byte, which the race detector
makes 14 to 30 times as slow.

Measured on mote (M5 Pro), -race, -test.v, old script, per test (plain
run in brackets): TestLoopGuardLeavesOrdinaryRepliesAlone 104s (7.6s),
TestLargeRequestEndpoints 104s (3.6s), TestRequestTailAfterOldLimit 33s
(4s), TestCodexBodyReadsPastOldLimit 14.6s (0.55s),
TestMediaJSONPastOldBodyLimit 10.7s (0.7s), TestCodexCompressedTailError
10.2s. Sums of test time per share: 487s, 641s, 761s.

- build/race-shards.sh: the tests go in ~118 chunks of about 32 (test N
  in chunk N mod m, so TestCodex..., TestCompaction... spread out), and
  each of the N workers takes the next chunk when it is done (xargs -P).
  Workers end within a chunk of each other. Each chunk logs in its own
  ::group:: with its time; the five slowest are printed at the end. A
  chunk whose process didn't finish counts as failed.
- oldBodyLimit (the pre-#118 64 MB) is 20 MB under -race
  (race_on_test.go), 64 MB in the plain run. 20 MB still passes every cut
  below 64 MB (bodyKept's 4 MB, the 8 MB and 16 MB reads); the plain Test
  step on ubuntu and macOS still sends the full 64 MB.
- TestLoopGuardLeavesOrdinaryRepliesAlone is skipped under -race: one
  goroutine feeds one loopGuard (loop_guard.go starts none), so there is
  no race to find; the plain run reads the whole corpus.

After, per test on mote under -race: TestLargeRequestEndpoints 40.7s,
TestRequestTailAfterOldLimit 13.05s, TestCodexBodyReadsPastOldLimit
5.1s, TestMediaJSONPastOldBodyLimit 4.46s, TestCodexCompressedTailError
3.1s, TestLoopGuard skipped: ~210s less race time.
A/B in one window on mote (same commit, binaries built from base and
change, 3 workers, load 15 to 30): old script with old tests 12m59s
wall (red: TestTranslatedStreamKeepsClientAlive, the load-timing test
of #2711/#2737); new script with new tests 10m57s, green, slowest
chunk 62s. On 3-core CI the wall should be about the total over three
plus a chunk, instead of the slowest share.

Broken by hand (wsl-run, Linux): defaultBodyLimit 16<<20 under -race
turns TestCodexBodyReadsPastOldLimit, TestLargeRequestEndpoints and
TestRequestTailAfterOldLimit red (body rejected / 413); defaultBodyLimit
48<<20 in the plain run turns the same three red. So the race run guards
the read-whole path past 16 MB and the plain run still guards 64 MB.
TestCodexCompressedTailError and TestMediaJSONPastOldBodyLimit stay green
with either cap: they never guarded the limit (true before this change).

Run: gofmt -l; on mote GOOS=linux go vet -tags nogui ./..., GOOS=windows
go vet ./..., go vet ./..., go vet -race ./internal/gateway; the seven
touched tests plain on mote (all pass, 21.9s); the whole gateway package
under -race through the new script on mote twice (one red,
TestBurstTellsNoSpeed/responses_from_chat_burst, the load timing of
#2719; the second run green).
Not tried: the race run with a 48 MB cap (it would pass: under -race
nothing now covers 20 to 64 MB, the plain step does); a CI run before
the push.

Fixes #5361
Fixes #5320
2026-11-07 19:45:30 +08:00
yetone e8efe05b22 awake: TestKeepOffWaitsForTheSetting keeps its 50ms clear of a beat (#3687)
Turned off, Keep looks at the setting at each beat, the multiples of
filememo.OthersEvery (5s) on the clock. The test counted Keep's looks
over a fixed 50ms, so a beat inside that window made a second look and
the test red, about one run in 100. That happened in the full suite on
mote at e9bde2520 ("looked at the setting 2 times in 50ms"). The test
now waits out a beat that is under a second away before it starts Keep,
as TestKeepOffSeesAWriteDuringTheLook does. Keep's code is unchanged,
as #3687 found.

Run (mote): go test -count=400 -run 'TestKeepOffWaitsForTheSetting$'
./internal/awake ok (26.7s); go test ./internal/awake ./internal/beat
ok; GOOS=linux and GOOS=windows go vet ./internal/awake ok; gofmt clean.
Broken by hand: the window put 30ms before a beat (sleep to it) without
the new wait, red 3 of 3 with the line above. With the wait, ok 3 of 3.

Not done here: #3687's comment also asks for a write-while-off check in
this test and a deferred cancel in TestKeep and TestKeepDisplay. Those
stay open on #3687.
2026-11-07 19:42:47 +08:00
yetone 2683123c7e gateway: TestClientGoneRecordedAsCanceled waits for the run's words, and takes either end of a killed run's stream (#5388)
The red on macOS CI (runs 42012262661 and 42354008450) was not the
fixed 200ms wait the issue's title names. Both logs have "thinking it
over" in the reply; what is missing is message_stop, and in its place
is `event: error` "Claude Code was ended by magpie before it ended its
reply". When the client leaves, letGo aborts the fake Claude Code run:
abort sends SIGTERM (Tree.Stop) and then r.finish() closes the run's
segment. Two goroutines race from there. If finish() closes the segment
first, relay sees its events end and enc.finish() writes message_stop.
If readOutput reaches the end of the dead process's output first, the
reply is still unended and, since a8e98e1ab (#4822), it emits KError,
which relay writes as the stream's error event, with no message_stop.
The test required message_stop, so on a slow runner (-race on macOS)
it went red. Neither end is the reply made whole, and h.ended stays
false in both; the test's guarantee (a stream end written after the
agent left is not taken as whole) holds either way.

The 200ms wait was a second, separate fault: with the fake's words
slower than 200ms the test canceled before the reply began.

- TestClientGoneRecordedAsCanceled: cancels once "thinking it over"
  reached the writer (saidRecorder closes said on it), not 200ms after
  hang.pid; accepts message_stop or the "ended by magpie before it
  ended its reply" error event as the stream's end; h.ended is checked
  as before.
- Sibling, same file family and helper: TestClaudeRunEndsWhenTheClientLeaves
  slept the same 200ms "its reply under way" after hang.pid. It now
  waits on the same state (saidRecorder), so it tests a client leaving
  mid-reply, not before the reply began. No other test of
  fakeClaudeCalling's hang uses a fixed wait (claude_runs_test waits on
  runsUntil).

Reproduced by injecting the delay, on mote, at 191f3c0af:
- time.Sleep(300ms) between t.Stop and r.finish() in abort (readOutput
  first): old test 3 of 3 red with CI's exact reply (the error event);
  new test 3 of 3 green.
- `sleep 0.5` in the fake after hang.pid (words slower than the wait):
  old TestClientGoneRecordedAsCanceled 3 of 3 red ("ended without an
  answer"), old TestClaudeRunEndsWhenTheClientLeaves passed while
  canceling before the reply; new tests 3 of 3 green.
Broken by hand: holdWriter.see without its ctx check makes
TestClientGoneRecordedAsCanceled red 3 of 3 (its first half).

Run at this tree, on origin/main 191f3c0af, on mote:
- go test -race -count=50 -run 'TestClientGoneRecordedAsCanceled$|TestClaudeRunEndsWhenTheClientLeaves$' ./internal/gateway: ok
- go vet ./internal/gateway, GOOS=linux and GOOS=windows go vet -tags
  nogui ./internal/gateway: ok; gofmt -l clean
- go test -tags nogui -timeout 45m ./internal/gateway: red on TestBurstTellsNoSpeed/responses_from_chat_burst alone (5000 tokens in 823ms read 6075 tok/s; a TTFT timing test this change doesn't touch), which passes -count=10 alone; recorded on #2719, its open issue
- full suite, go test -tags nogui -timeout 45m ./... under suite.lock: ok, every package (88), internal/gateway ok in 941s

Rebased onto origin/main f2412fd59 (8 commits since 191f3c0af, none
touching held_keepalive_test.go, claude_subscription_park_test.go,
claude_subscription.go or fallback.go). At that pushed head, on mote:
go test -race -count=5 -run 'TestClientGoneRecordedAsCanceled$|TestClaudeRunEndsWhenTheClientLeaves$'
./internal/gateway ok; go vet (darwin) and GOOS=linux/windows go vet
-tags nogui ./internal/gateway ok; gofmt -l clean. The full suite and
gateway runs above are at 191f3c0af, not again at this head.

Not changed: which end a killed run's stream gets stays a race in
abort (SIGTERM before finish); for a gone client nothing reaches it.
Not tried on Windows (fakeClaudeCalling skips there) or on CI before
the push.

Fixes #5388
2026-11-07 19:29:43 +08:00
yetone f2412fd599 gateway: the Claude Code and Codex header tests expect another agent's own User-Agent
abe7b0063 (v0.1.3237) made a key+URL provider receive the agent's own
User-Agent by default. Two tests still asserted that a non-Claude-Code
or non-Codex agent ("opencode/1.0") reaches the relay as magpie/..., so
internal/gateway was red in the full suite on mote at abe7b0063. They
now assert the agent's own UA. They still check that none of Claude
Code's or Codex's own headers is copied.

Run (mote): go test -run
'TestClaudeCodeHeadersReachAnthropicRelay|TestCodexHeadersReachKeyedRelay'
./internal/gateway: ok. The full ./... run at abe7b0063 had no other red
(87 packages ok).

Reported-by: nb5p on Discord
2026-11-07 18:40:57 +08:00
yetone e9bde2520d codex: OpenAI's threads follow Codex onto magpie from a provider of the user's, and a move the budget stopped asks for the next sync (Lice9735 on X)
Lice9735 on X, Windows, magpie 0.1.3233, Codex app 26.1104: an old chat
(10-13) answered "模型提供商不匹配 — 此聊天使用的是 OpenAI,但你当前
的提供商是 magpie。请切换至 OpenAI 以继续", only a new chat worked,
after d620ff6b5 and d2c29abe7. Their config.toml has a provider table
of their own, openai-http.

Cause. The banner is the app-server's modelProviderMismatch on
thread/resume (app 26.1103: providerBlock is set only from that error;
codex 0.167 load_for_resume compares the stored thread's provider, the
row for a paginated thread, the rollout's session_meta for a legacy
one, with config.toml's). With Codex on a provider of the user's at the
takeover, the stash's codex.provider is that provider, and bringOver
moved only its threads: OpenAI's stayed on openai by design ("whose
threads bringBack would hand them to"). The Codex app lists them and
refuses each one on magpie. A second gap on the same path: the
rewriting moves (MovePackedCodexThreads, MoveRecentCodexThreads) go
128 MB a sync, newest first, and the rest waited for a sync nothing
asked for, which can be hours away.

- bringOver, with Codex on a provider of the user's before magpie (not
  OpenAI, magpie or cc-switch-official, and no profile naming OpenAI),
  moves OpenAI's threads to magpie too: in place, a paginated one by its
  row, the last 30 days rewritten. They are recorded in codex.lent with
  that provider as To, as lendOwn records its own: the Disconnect gives
  every magpie thread to that provider (bringBack), where Codex resumes
  them, and giveLent gives these back to OpenAI once Codex is on OpenAI
  again. One the app holds open waits (codexThreadsLater on openai).
- MovePackedCodexThreads and MoveRecentCodexThreads say more when the
  budget stopped them with a thread left, and bringOver, bringBeside and
  lendOwn ask for the next sync at once (codexThreadsAgain). The three
  share one mover now (codexOnto); bringBeside also waits on a held
  thread as the other two do. packedBudget is a var, for the test.
- Tests: TestCodexOpenAIThreadsFollowMagpieFromOwnProvider (new: an
  openai-http table named "OpenAI", a plain and a packed OpenAI thread,
  moved, lent, to openai-http at the Disconnect, back to OpenAI after;
  none while a profile names openai), TestCodexThreadsLeftByTheBudgetAskAgain
  (new), TestMovePackedCodexThreads checks more. TestCodexThreadsFollowMagpieIn's
  two user-provider subtests now expect OpenAI's thread on magpie, then
  on that provider after the Disconnect.
- docs/subsystems/agent-wiring.md says so.

Run:
- Real codex-cli 0.166.0 on mote, sandbox HOME and CODEX_HOME, a fake
  Responses server: a thread started on the built-in openai (API key,
  openai_base_url), a second after switching to model_provider
  openai-http (name "OpenAI"); both paginated. On openai-http the first
  was refused ("This chat uses openai, but your current provider is
  openai-http"). A throwaway test (not committed) ran magpie's takeover
  (Set fake/m1, Sync) on a copy of that home: with origin/main's code
  the openai row stayed and `codex exec resume` on magpie (the copy's
  base URLs pointed at the fake) failed with exactly "This chat uses
  openai, but your current provider is magpie"
  (modelProviderMismatch); with this change the row was magpie,
  codex.lent {"to":"openai-http",...}, and the resume answered.
- New and changed tests red on origin/main 191f3c0af (the openai thread
  on "openai", want "magpie"; after the Disconnect "openai", want the
  user's provider).
- Broken by hand: bringOver's `if more` dropped ->
  TestCodexThreadsLeftByTheBudgetAskAgain red ("0 sync(s) asked for");
  `more = true` turned false -> TestMovePackedCodexThreads red.
- mote: gofmt -l clean; GOOS=windows go vet and GOOS=linux go vet
  -tags nogui of internal/agent and internal/sessions ok;
  go test ./internal/sessions ./internal/agent ok at this head
  (this change on e6cdeac9c; rebased after onto 5dbdfc1bd, which
  changes internal/provider only), agent 292.2s, sessions 47.4s. Pushed and tagged
  without waiting for the full `go test -timeout 45m ./...`, per the
  owner's rule to ship each verified fix at once; it runs on mote after
  another session's suite, and a red it shows is filed or fixed in a
  follow-up.
- win-run (xiaomi-gpu), go test ./internal/sessions ./internal/agent
  (at the commit's parent before a rebase onto abe7b0063, which touches
  neither package): every test this change adds or touches passes; 29
  reds, 28 of them red the same at origin/main 191f3c0af run alone
  there. The 29th, TestHermesProfilesFollowMagpieModel, passes alone
  3/3 on this tree and is in #4115.

Not tried: the Codex app itself (the CLI's app-server gives the same
error the app shows); Windows with a real Codex; a legacy (non-paginated)
thread with a real Codex, covered by the unit tests only; a history
over 128 MB with real files. The chat the app has loaded at the switch
goes on once the app lets it go: fully quit the Codex app and reopen it
after magpie updates.
2026-11-07 18:08:39 +08:00
yetone 5dbdfc1bd5 provider: zcode's mover min is 0.1.56, the Start Plan three at a time
ZCode users of other agent apps saw "rate limited 5 times in a minute":
the plugin's busy hold, tripped by refusals the plugin drove itself (up
to six re-asks over ~10s, nothing holding the Start Plan to its in-flight
cap). zcode 0.1.56 (plugins a313a003) re-asks a cap twice, after 1s and
2s, as ZCode 3.17.2 does, keeps an account's Start Plan requests to three
in flight with the rest waiting in the plugin, and counts toward the hold
only a request refused again at its re-ask. keepMovedCurrent brings every
moved user up to it.

Run: npm view --prefer-online --registry https://registry.npmjs.org
@magpie-community/opencode-zcode-auth version = 0.1.56; gofmt -l clean;
go test -count=1 ./internal/provider on mote: ok (171.6s). The plugin's
own runs are in its commit body.
Not tried: a real moved ZCode account updating to 0.1.56 in magpie.

Reported-by: star21321321124
2026-11-07 18:07:13 +08:00
yetone e6cdeac9c6 proc: with no WSL distro registered, or after wsl.exe asks to be updated, magpie starts no wsl.exe (TraderX219 on X)
TraderX219 on Windows: while magpie ran, a console window "WSL 必须更新到
最新版本……按任意键安装" came up every 20 to 30 seconds. magpie asked
wsl.exe for its distros (the running list retries every 30s after a
failure), and Windows' inbox wsl.exe answers each run on a computer
without a current WSL package by starting `wsl.exe --update --confirm
--prompt-before-exit` in a console of its own.

proc.Command, CommandContext and ProbeContext are where every wsl.exe
magpie runs is made (agent's wslRun/wslExec, wslrun, claudetui, the
library's rtk and MCP checks, the gateway's TUI helper), so both gates
sit in wslOff beside #1264's ErrWSLOff:

- The registry is read first (HKCU\...\CurrentVersion\Lxss, one subkey
  with a DistributionName per distro). With the key there or gone and no
  distro in it, wsl.exe isn't started: ErrNoWSLDistro. agent's wslList
  and wslrun's running list read that as "no distros", not as a failure
  or a hang, so nothing is retried every 30s. It is read at every start,
  so a distro installed later is seen at once. A read that fails is
  unknown: wsl.exe is asked as before.
- When a run's output (UTF-16LE or UTF-8, stdout and stderr) says WSL
  must be updated or installed, proc.WSLSaid writes settings' wsl-update
  mark (atomic, like wsl-hung) and no magpie process starts wsl.exe for
  6h: ErrWSLNeedsUpdate. The mark holds the WSL package version (HKLM
  Lxss\MSI Version) and the registered distros; a change to either
  clears it. A refused listing is unknown, so wsl.seen, WSLKept values
  and links are kept, never removed.

docs/subsystems/agent-wiring.md describes both.

Run:
- mote: gofmt -l (clean); go vet ./..., GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...; go build for darwin, linux (nogui),
  windows: all ok.
- mote: go test -count=1 of internal/proc, agent, wslrun, library,
  sessions, claudetui at base 191f3c0af: all ok.
- mote, full suite through suite.lock (go test -count=1 -timeout 45m
  ./...) at base 191f3c0af: 88 packages ok, none failed.
- xiaomi-gpu (Windows 11, win-run): go test -count=1 ./internal/agent/...
  ./internal/proc/... ./internal/wslrun/...: proc and wslrun ok;
  agent has 25 reds, the same 25 by name on untouched origin/main
  191f3c0af. 24 were filed (#4115, #4786, #5068 and others);
  TestCodexOwnModelsFollowPicks wasn't, now #5605.
- xiaomi-gpu, read-only: TestWSLRegistryLive (MAGPIE_WSL_REGISTRY_LIVE=1)
  read the real Lxss key (magpie-fedora, Ubuntu, docker-desktop,
  magpie-3896, magpie-desktop; package 2.6.1.0) and ran `wsl.exe -l -q`
  (docker-desktop, magpie-fedora, Ubuntu, magpie-desktop): every listed
  distro is registered, so the gate never reads none while wsl.exe has
  some. magpie-3896 is registered in State 4 (uninstalling) and not
  listed, which only keeps wsl.exe being asked. No distro was stopped or
  changed.
- At the pushed head (rebased on f13d5f16f, which touches gateway and
  provider only), mote: go test of proc, wslrun, provider ok. agent's
  TestWSLMoreAgentsPick failed with "no space left on device" (mote's
  data volume was at 100%). Rerun: -count=3 -run 'TestWSLMoreAgents|WSL'
  ./internal/agent/ ok, and -run History ./internal/gateway/ ok. abe7b0063 (gateway) and
  e4fdf9ed3 (gui) landed after that run and were rebased onto unrun; they
  touch no file this change does.

Broken by hand, each red:
- registry check off: TestNoWSLDistroStartsNoWSL ("wsl.exe wasn't
  refused") and TestNoWSLDistroRunsNoWSL ("no distro registered read as
  wsl.exe failing").
- WSLSaid left out of agent's wslRun: TestWSLUpdateKeepsDistros ("wsl.exe
  -l -q was started: exit status 1").
- wslList's ErrNoWSLDistro as listed: TestNoWSLDistroRunsNoWSL.
- wslUpdateLately always false: TestWSLUpdateBacksOff ("wsl.exe run again
  after it asked for an update").

Not tried:
- The stub's window itself: xiaomi-gpu has a current WSL and distros, so
  it doesn't pop there. The fix wasn't run on the reporter's machine.
- The registry key missing (ErrNotExist) on a real Windows without WSL.
- The stub's real exit code and stdout: the update text is matched from
  the inbox wsl.exe's .mui strings (en, zh-CN) and the reporter's words.
- A wsl.exe that times out is not taken as asking for an update; the
  existing wsl-hung back-off still covers it.
2026-11-07 17:51:51 +08:00
yetone abe7b00631 gateway: a key+URL provider is sent the agent's own User-Agent by default, through a remote magpie too
nb5p runs a gateway of their own behind magpie and saw nearly every
request arrive as "magpie/<version>". The agent's User-Agent now goes
on as the agent sent it, wherever magpie isn't itself the client.

What each path sends now:
- Key+URL providers (official vendor keys and custom OpenAI/Anthropic
  compatible ones), on chat, Anthropic, Responses, Gemini,
  count_tokens, embeddings, images and videos: the agent's User-Agent,
  as sent. Before, this was the opt-in passUserAgent (#1851) and the
  default was magpie's. The opt-out is magpieUserAgent:
  `magpie provider set <id> user-agent=magpie`, or untick "Send the
  agent's own User-Agent" in the editor. passUserAgent is no longer a
  field, so a file that set it true reads the same as the new default.
  A provider someone turned back off after opting in can't be told
  apart from one never touched, and now sends the agent's too.
- When the agent sent no User-Agent, and on magpie's own requests
  (classifier magpie-router/1, vision, search, the image tool, model
  lists): magpie's, unchanged.
- A header.User-Agent the user set: still wins over both.
- Subscription accounts (Claude, Codex, Copilot, Google, ZCode…),
  plugins, and OpenCode/Cline/Kilo: unchanged. Their signing sets the
  official client's UA (provider.PassesUserAgent still refuses an
  Account or OwnClient).
- Claude Code and Codex header copies: unchanged.
- Remote magpie: the near magpie still asks as magpie/<v>, because the
  far end trusts X-Magpie-Agent/Via only from that. It now adds
  X-Magpie-User-Agent (passOnUA, on forwardOnce, embeddings, draw and
  video; the classifier's decision request names none). The far end
  takes it only from a magpie/ request (callerFrom) and strips it on
  arrival (withCaller). agentUA/callerUA then hand it to userAgentFor,
  so the far vendor sees the agent's. A client that writes the header
  itself, straight to a magpie, is ignored. magpie's own UAs are never
  relayed (magpiesOwn).

Vendor check: invalid-key requests with magpie/, claude-cli, a Chrome
UA and pi's went to Anthropic, OpenAI, Gemini, DeepSeek, Moonshot, Kimi
For Coding, Zhipu, OpenRouter, xAI, DashScope, MiniMax, Volcengine Ark,
Groq and Mistral. Every vendor gave the same auth error for every UA,
so no edge-level UA gating was seen. Kimi For Coding's agent allow-list
sits behind a valid key, which wasn't tried.

Run (mote):
- go test -run 'UserAgent|RemoteMagpie|ZCode|Blocked' ./internal/gateway: ok
- go test ./internal/provider ./internal/cli ./internal/gui: ok
- node --test provider-user-agent, provider-native-compaction and
  i18n-keys (chromium and webkit; en/zh/zh-TW/ja/de; 900 and 440 wide):
  123 of 124 pass. The red is i18n-keys "a plugin's words are its own"
  (plugins' words said in files this change doesn't touch), already
  filed as #5327/#5332, #5426 and #5482.
- gofmt -l clean; go vet; GOOS=linux -tags nogui and GOOS=windows vet:
  ok at the rebased head (on f13d5f16f). Targeted gateway, provider,
  cli and gui packages (UserAgent|RemoteMagpie|ZCode|Blocked|Budget)
  ok there too; whole packages ran at the pre-rebase base 4461957b9.

Broken by hand:
- PassesUserAgent back to opt-in: TestUserAgentPassedOn/default,
  TestUserAgentFor, TestRemoteMagpieRelaysUserAgent, TestPassesUserAgent
  and TestProviderUserAgentPair go red.
- agentUA's relay off, or passOnUA a no-op: TestRemoteMagpieRelaysUserAgent
  goes red; the far vendor is asked as magpie/dev.
- withCaller's Del(X-Magpie-User-Agent) removed: stays green. Nothing
  copies incoming headers to a vendor today, so the Del only guards
  against that.

Not tried: a real remote magpie on two machines, a real valid-key vendor
request, and nb5p's own gateway.

Reported-by: nb5p on Discord
2026-11-07 17:44:31 +08:00
yetone e4fdf9ed3d gui: Fetch models again leaves the provider's dialog where it was (indexyz)
Pressing Fetch models again (重新获取模型) in a provider's editor moved the
whole dialog down about 30px and left it there. The redraw that brings the
list back built the models' "Expand the list" fold shown and hid it a
requestAnimationFrame later, once the chips were measured. The dialog had
been pressed, so holdModal keeps the pressed button where it is, and it took
the button's place with the fold showing (30px lower) as the place to hold:
when the fold went, it moved the dialog down by the fold's height.

The fold now starts as it was last measured for that provider (foldNeeded)
and is measured in a microtask, after openModal has put the editor on the
page in the same task and before any frame is drawn; a redraw while the
editor is already on the page measures at once. A fold that really comes
or goes (the list grew or shrank past the box) still does, a frame sooner
than before.

Measured frame by frame, before and after, on mote (Chromium and WebKit,
900x820, 420x820, 1300x900; lists of 5 and 150, picked and unpicked, the
same list back, grown and shrunk): before, Chromium's dialog went 58 -> 89
and stayed, WebKit's button jumped 32px for a frame; after, nothing moves
more than the redraw's own 2px swap.

Run on mote (the new test and the budget again at this head, cb0c97cb4's tree):
- provider-fetch-holds.test.cjs (new): 12/12 ok, Chromium and WebKit, zh
  900 and 420, en 1300, a list with no fold and one with. Broken by hand
  (origin/main's app.js): 6 of 12 red, every no-fold case in both engines
  ("the dialog moved 31.4px (58,...,60,89,89,88,...)", "the button moved
  31.7px"); the fold cases stay green, which is what they guard.
- models-fold, provider-fetch-again, provider-picks-stay,
  provider-retrieval-only, azure-endpoint, modal-centred-late, modal-morph,
  i18n-keys, i18n-en-no-cjk, under lockf suite.lock: 89 of 109 ok. The 20
  red are red the same on origin/main's app.js, run the same way:
  provider-fetch-again (#5057, #5232), provider-picks-stay (#5233, #4397),
  models-fold webkit (#4071; webkit en and zh both red on main, zh only
  with this), i18n-keys "a plugin's words are its own" (#5332, #5426,
  #5482).
- go test -tags nogui ./internal/gui -run Budget: TestCoreScriptBudget ok
  (app.js 1,311,491 of 1,316,874; no raise).

Not tried: the real app's WebKit (Wails on macOS) or WebView2 by hand; the
whole GUI suite runs after the push. Not changed: at 420px the footer's
"vendor list · 1小时前" becoming "刚刚" rewraps the footer and the body's
scroll is clamped, which is the content changing, not this.

Reported-by: indexyz on Discord
2026-11-07 17:42:46 +08:00
yetone f13d5f16f4 history: today's plain file takes no room from the days before it
pruneHistory held every file in routing/ to historyBytes (200 MB),
today's plain .jsonl included. Today is never dropped, and its file is
written plain, about ten times what it is once gzipped (this Mac's
2026-11-06: 5,785 routes, 1.1 MB gzipped). On a busy gateway, today's
file took the room of the days before it, and every prune (the first
save after a start, then hourly) dropped the oldest days until it fit;
past 200 MB plain, it dropped every day but today. The Context tab then
listed only today's sessions, while Usage's Requests, read from the
ledger, kept them. The budget now holds the days that are over; today's
file is counted from the next day on, gzipped.

From linkaww's report: on their Docker magpie, after each nightly
update, Context lists only today's sessions while Requests keeps the
older ones. NOT confirmed as their cause. A real Docker run on
xiaomi-gpu (the image built from this tree, a named volume on /config,
a fake upstream in a second container) kept every session across
`docker restart` and across rm + run on the same volume, as the
documented update does; so did a sandbox chain (desktop magpie ->
remote magpie with a gateway key, the remote restarted). A plain
restart loses nothing; this budget is the one path found that drops
past days while the ledger keeps them. Their routing/ listing would
tell.

History already dropped is gone: the routing days are their only copy,
and the ledger keeps no prompt tokens or sessions to rebuild them from.

Run (mote, at 4461957b9 + this):
- TestHistoryTodayTakesNoRoomFromPastDays, new: red on the old
  history.go (kept [2026-09-30], want the three days before it too),
  green with the change.
- go test -run 'History|Route|Prune' ./internal/gateway: ok.
- go test -run Context ./internal/gui: ok.
- gofmt -l; GOOS=linux go vet -tags nogui and GOOS=windows go vet
  ./internal/gateway: clean.
Not tried: linkaww's own container and data; the full suite (run after
the tag, per the loop rules). Not changed: the remote-magpie hop passes
no x-claude-code-agent-id on, so a Claude Code subagent's calls through
it count as the main session's on the remote's Context tab; a separate
change.

Reported-by: linkaww on Discord
2026-11-07 17:30:06 +08:00
yetone 4461957b9e provider: Kiro's mover min is 0.1.30, which says an account's request rate plainly and stops the 1/2/4s re-asks
onemezao on Discord (one Kiro account, pi, claude-haiku-5.5): every
request failed after 42s with "Kiro: Too many requests, please wait
before trying again. (USER_REQUEST_RATE_EXCEEDED)" while the Kiro IDE
answered on the same account. Kiro gave no wait, so the gateway asked
the one account again after 1, 2 and 4s with the whole 965KB request.

Kiro plugin 0.1.30 (plugins 44df5f05) says that 429 is Kiro limiting
this account's requests, to wait a minute, and that one persisting
while the Kiro app works is for Kiro support, with the request ID; with
no wait from Kiro it gives Retry-After 30s, past longestPause (8s), so
the same-account retries stop. keepMovedCurrent brings moved users up.

Run on mote: go test ./internal/provider/ (ok). npm view --prefer-online
shows 0.1.30. The plugin's own record is in its commit (package tests,
check.mjs, the repo's bun test, the new tests red on the old code).
Not tried: a real USER_REQUEST_RATE_EXCEEDED through magpie, which
can't be drawn without hammering an account.

Reported-by: onemezao
2026-11-07 17:09:09 +08:00
yetone 191f3c0af1 gateway: POST /v1/decisions goes to OpenAI, Azure OpenAI or another magpie
A Discord user's POST /v1/decisions was answered 404 ("magpie serves
/v1/chat/completions, ..."). It is OpenAI's Decisions API (gpt-6-luna):
one input, up to 400 questions, typed answers, input tokens billed only.

The shape was taken from openai-python (resources/decisions.py,
types/decision_create_params.py, types/decision.py, added in #4033 on
10-06) and the Decisions guide, not guessed: POST /v1/decisions, a JSON
body of model, input (a string or messages/items with input_text,
input_image as a data or http(s) URL, JSON parts; function and custom
tool calls and their outputs), questions (predicate / choice / score),
and optional prompt_cache_key, prompt_cache_options, safety_identifier.
The answer is {answers, model, usage}, not streamed; usage.input_tokens
includes input_tokens_details.cached_tokens and cache_write_tokens. The
Azure client sends it on the v1 API (/openai/v1/decisions), the model in
the body.

- decide (decisions.go) goes through serveRetrieval as embeddings and
  rerank do, body as sent with only model changed. So a disabled model,
  a key's models, accounts and spent limits, pause rules, keys/accounts
  of the provider, masking and the Routing page hold here as on every
  route.
- Only a provider canDecide takes is sent it: an OpenAI API key on
  api.openai.com, Azure OpenAI (IsAzure, at its OpenAIBase, so
  /openai/v1/decisions with api-key), or another magpie. Anyone else (a
  relay, a plugin, a ChatGPT sign-in) gets a 400 that says who serves
  it, checked in serveRetrieval's try loop beside the no-OpenAI-API
  check (refusingRetrieval), never the vendor's 404; a group moves on.
- A bare gpt-6-luna is a kind group "decision" (servesDecision), so a
  relay that lists the same id is never its member.
- Usage is recorded as "decisions" (countedRetrieval): input less the
  cached and cache-written tokens, those as CacheRead/CacheWrite, and
  no output, so gpt-6-luna's own models.dev rates price it as OpenAI
  bills ($0.10/1M input, cache read/write at their rates).
- /decisions joins the one-port client prefixes, another magpie's URL
  suffixes, the 404's route list and info's apis. The readonly, LAN
  and CORS guard tests list the route.
- native_endpoints is left alone: it names the chat APIs a model is
  relayed on (Cursor's names, a remote's API choice).
- docs: gateway-routing.md has a Decisions row; reference.md a section.

Run on mote at this tree (mote-run): gofmt -l clean; go vet of gateway
and provider; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet
./...; go build ./..., linux nogui and windows builds ok;
go test -count=1 -timeout 45m ./internal/gateway ./internal/provider
./internal/usage: ok (gateway 413s, provider 88s, usage 18s).

Red on the old code (e0930b1de, the new tests copied in): every
TestDecisions* is red with magpie's 404.
Broken by hand, each red: refuses always "" (the relay is sent it:
TestDecisionsRefusedWhereNotServed); the cache split not read
(Input 1200, CacheRead 0: TestDecisionsReachOpenAIAndAzure); canDecide
without the api.openai.com check (TestCanDecide, the relay sent it);
/v1/decisions out of the remote suffixes (TestRemoteMagpie).

Not tried: a real OpenAI Decisions request, or a real Azure resource.
Tests reach only httptest servers (OpenAI's host through the provider's
proxy).
2026-11-07 16:05:37 +08:00
yetone e0930b1dee kiro: the mover installs 0.1.29, which says what Kiro's meteringEvents say a request cost as usage.credit
kiro 0.1.29 is on registry.npmjs.org (npm view --prefer-online with a
fresh cache, checked again just before this commit: 0.1.29, the latest,
shasum 4fbdc3fd2195ffa6bb6adcb6b409f02955cd9fbb). It is 4200fed09 in
magpie-community/plugins (plugins#823, caozhenyuan): Kiro gives no token
counts, only a meteringEvent ({"unit": "credit", "usage": 0.091}) near
the end of its reply. The plugin now sums a request's meteringEvents (a
hosted web search's turns are one request) and says them as usage.credit
in the last message_delta, or the message's usage. keepMovedCurrent
brings every moved Kiro user to 0.1.29.

What users see: nothing yet on the Usage page. The gateway reads
usage.credit on /v1/messages only once the host half of #4328 (ggbdpq's
patch on that issue) lands; until then the field is passed over, as the
plugin's body says. The rest of the reply is unchanged.

Run on mote at c39d36644 + this change (the pushed head's tree):
gofmt -l internal/provider empty; go vet ./..., GOOS=linux go vet -tags
nogui ./... and GOOS=windows go vet ./... ok; go test -count=1
./internal/provider/... ok (211s), which holds the mover guard tests
(TestMovedBuiltinsSayTheirPlugin, TestKiroMoverHasTheTooLongFix and the
migrate_* tests). No other package reads movers. The plugin's own run
(bun test packages/kiro 144 pass, the whole repo 6679 pass) and what was
broken by hand are in 4200fed09's body.

Not tried: a real Kiro account through magpie on 0.1.29; the ledger with
#4328's host half. The full suite runs after the push (agent rules'
release flow).
2026-11-07 15:40:31 +08:00
yetone c39d366447 cline: the Upstream tick never writes providerOptions, which Cline refuses with 403 (#5442)
Since 2026-11-06 the Cline API answers any request carrying a
client-supplied providerOptions with 403 `client-supplied
"providerOptions" model routing is not supported`. HK-bruc1 showed it
with the same key: 403 with the field, 200 without. magpie's Upstream
tick ("DeepSeek and GLM models only from their makers' own APIs")
wrote providerOptions.gateway.only (and has) into every ClinePass
DeepSeek and GLM request, usage-billed deepseek/… and zai/glm-… too,
so with the tick on every one of them failed.

This overrides a value the user set. It is done because the value
breaks every request it touches: the models Cline sends through
Vercel's AI Gateway can only be pinned with providerOptions, and that
field is refused on each request. The saved pinUpstream is left as
set, so if Cline takes the field again the pin can come back without
asking anyone to tick it again.

Changed:
- provider.ClinePin pins only the OpenRouter entry (glm-5.3-flash,
  provider.only ["z-ai"], which Cline still accepts); DeepSeek and the
  other GLM models get "". The Cline plugin's DeepSeek skip and
  ClinePassHas/clinePassDeepSeek are gone.
- gateway clinePin writes only top-level provider.only, never
  providerOptions. A body's own provider/providerOptions goes as sent.
- provider.ClinePassAsked is what magpie actually wrote (ClinePin). It
  no longer claims "deepseek" for the Cline plugin's DeepSeek models:
  opencode-cline-auth 0.1.13 pins nothing by default, and a pin it
  writes is refused, so no reply is served on it.
- GUI: the Upstream note says Cline refuses the pin since 11-06 and
  only glm-5.3-flash still asks Z.ai (en, zh, zh-TW, ja, de). The
  Routing page's "tick … to ask for the maker's own API" is gone.

Run on mote at this tree on origin/main a1774d123, HOME=$(mktemp -d):
- go test ./internal/provider -run Cline, ./internal/gateway -run
  Cline: ok. go test ./internal/gui -run 'Budget|I18n|Script': ok.
- GOOS=linux go vet provider, gateway, testenv; GOOS=windows go vet
  those and internal/gui: ok. gofmt -l: nothing.
- GUI, Chromium and WebKit, node --test (concurrency 6): every
  Cline file (clinepass-pin, routing-cline-route and 15 more naming
  Cline), all routing-* files, i18n-keys, i18n-en-no-cjk, gui-zh-tw,
  gui-ja, gui-de: 2878 tests, 20 red in 7 routing-* files. Run alone
  and serially, routing-idle-frame passed; the other 6 files had the
  same 19 reds on a fresh origin/main 325dc3ab3 copy (#5475, #5586).
- Broken by hand: origin/main's cline.go and cline_pin.go with the new
  tests, red: TestClinePassAsked, TestClinePassTryKeepsWhatWasAsked,
  TestClineTickSendsNoProviderOptions,
  TestClinePluginTickSendsNoProviderOptions.
- Rebased on 325dc3ab3, again on mote: go test provider and gateway
  -run Cline, gui -run 'Budget|I18n|Script': ok; clinepass-pin and
  routing-cline-route: ok; i18n-keys "a plugin's words are its own"
  red for three words none of this touches, red the same on a
  325dc3ab3 copy (#5332, #5426, #5482).

Not tried: a live Cline request (no Cline account here), glm-5.3-flash
actually served by Z.ai (the #819 author's checks say Cline ignores
provider.only there), GOOS=linux vet of internal/gui on mote (Wails
needs cgo).

Reported-by: kvjxhjwentnwm
2026-11-07 15:27:29 +08:00
yetone 325dc3ab32 claude-tui: a Claude Code that draws nothing is said with what it waits on, and its turn isn't waited out twice
sowhynot (v0.1.3222, macOS): every interactive run ended "Claude Code
showed no prompt in 45s: nothing on its screen (0 bytes read)", and the
bridge then started a new Claude Code told the whole conversation, which
waited out another 45s before the turn was answered 502.

Cause class: Claude Code blocks before its first draw on something it
waits for and writes nothing to the pty. Reproduced on mote with real
Claude Code 2.1.319 (npm latest) in a sandbox HOME: its read of the
"Claude Code" Keychain item is a synchronous `security
find-generic-password` with no time limit (its other Keychain reads have
2s/10s limits), so a Keychain waiting on an allow window or a locked
keychain gives exactly "0 bytes read" at 45s. Its network waits
(remote managed settings and policy limits, for a setup-token or team
account with --mcp-config) are bounded at ~30s and draw after, so they
don't give 0 bytes.

- claudetui: with 0 bytes read, the reason adds what Claude Code runs
  (its descendants from ps, longest first) and how much it holds; a
  Keychain read is named with its item and what to do. Other commands
  are named by program (and an interpreter's script) only, never their
  arguments. macOS and Linux; Windows says what it said before.
- gateway: a helper that ends saying why the interactive mode didn't
  come up is tuiNoStart, not tried again told the whole conversation,
  unless Claude Code ended itself before its prompt
  (claudetui.EndedEarly, the "No conversation found" case the retry is
  for).
- No early end on 0 bytes: a Keychain window may still be answered.
  No -p fallback: removed on purpose in e5f66f8a6, and -p waits on the
  same things.

Run (mote, at this tree on 05f6fd423; after the rebase onto 0978a6868, the new claudetui tests, TestShimNeverPrints, TestShimEndsAtItsCallersDeadline and -run TestClaudeTUI in gateway again: ok):
- go test -count=1 ./internal/claudetui/: ok
- go test -run 'TestClaudeTUI' ./internal/gateway/: ok
- go test -run 'TestClaude|TestSubscription' ./internal/gateway/: ok
- wsl-run (magpie-desktop): the new claudetui tests and
  TestShimEndsAtItsCallersDeadline: ok
- go vet darwin, GOOS=linux and GOOS=windows -tags nogui for
  claudetui and gateway: ok
- real Claude Code 2.1.319 under the rebuilt helper, sandbox HOME, a
  `security` on PATH that never answers: "...(0 bytes read); it waits on
  the macOS Keychain, whose `security find-generic-password` read of
  "Claude Code" hasn't answered in 33s: ..."

Broken by hand: with undrawn's result dropped,
TestShimSaysWhatAnUndrawnClaudeWaitsOn fails both cases; with the
gateway check off, TestClaudeTUINoPromptNotTriedAgain/no_prompt fails
"the helper started 2 times, want 1".

Not tried: a real Keychain allow window or a locked keychain, the
reporter's own machine (unconfirmed it is the Keychain; Gatekeeper or
endpoint software holding the exec fits the 51s too), a real Pro or
team account, Windows (no ps read there).

Reported-by: sowhynot
2026-11-07 15:17:47 +08:00
yetone 0978a68681 gateway: a ZCode trial entry's 3012 rests that entry, not the account
young02036 (Discord, 11-07): on an account with a GLM Coding Plan,
GLM-5.3-Flash-Trial answered 405 code 3012 (ZCode's risk control) while
the account's paid models worked. The plugin's 3012 words read as
failRestricted, which rested the whole account for two hours
(restrictedRest), so magpie stopped sending the paid models the account
still served. A -Trial entry goes to zcode.z.ai's Start Plan, and a dual
account's plain models to its GLM Coding Plan on api.z.ai, so the 3012
is zcode.z.ai's: zcodeTrialRestricted rests the entry alone (restID),
as zcodeTrialBlocked already does for the edge block page. On a
gift-only account the plain model goes to zcode.z.ai too, gets its own
3012 and rests the account, at the cost of that one more refused
request per rest. riskRefused still walls the provider's other accounts
off for the rest of the request.

TestZCodeTrialRefusalRestsTheTrialAlone: "trial risk control" now wants
the entry's rest and the account's GLM-5.3 served after it; new cases
"plain risk control" and "another vendor's risk control" want the
account's rest. docs/subsystems/gateway-routing.md says so.

Run (mote): go test -count=1 -run 'TestZCode|TestRisk|TestRestricted|TestMovedZCode'
./internal/gateway/ ok; gofmt -l clean; GOOS=linux and GOOS=windows go
vet ./internal/gateway/ ok.
Broken by hand: the routing.go check removed, trial_risk_control red
(rested "zcode@api key", want ".../GLM-5.3-Flash-Trial"), then restored.
Not tried: a real 3012 account (the reporter's); the full suite runs
after this push.

Reported-by: young02036
2026-11-07 15:13:03 +08:00
yetone 682d72075a provider: zcode's mover min is 0.1.55, no claim while ZCode asks its security check
young02036 (Discord, 11-07): the daily check-in got ZCode's captcha every
day, and the free GLM-5.3-Flash-Trial answered 405 code 3012 while the
account's Coding Plan models worked. plugins ea9904d5 (zcode 0.1.55,
npm latest per npm view --prefer-online) posts no claim while ZCode's
client config asks its security check for claims, and sends the desktop
app's X-Title (Z Code@electron) and a per-turn x-query-id, as ZCode
3.17.2 does. The min also brings in 0.1.54's busy hold for requests in
flight (plugins#801).

Run (mote): go test -timeout 30m ./internal/provider/ ok (142.5s).
Not tried: a real move or claim with the new min; the reporter's
3012-blocked account (the probe on the owner's account passed every
request shape, so the 3012 looks like the account's risk-control block).

Reported-by: young02036
2026-11-07 15:05:22 +08:00
yetone 75d0fc3aca gui: on macOS 27 the main window keeps its toolbar, which no longer changes the corners (#3949)
TestMainWindowCorners/macOS_26_SDK was red in every run on mote
(macOS 27.2). The test was right and the code wrong: insetLights took
the main window's toolbar off whenever AppKit gives the program the
design of macOS 26 (designOf26), on the grounds that a toolbar gives a
window Finder's larger corners there. macOS 27 doesn't: a window with a
toolbar and one with a plain title bar both get 16pt corners (AppKit's
_cornerRadius and _cornerMask are the same for both, measured on mote
with a 26.2-SDK probe). So on 27 the toolbar went for nothing, and the
lights, the title bar's height, first presses and sheets were all held
in place by hand where the toolbar would have kept them itself.

insetLights now also asks toolbarRounder: the window's corner radius
held against a window of its style with no toolbar, never shown. The
toolbar is taken off only when it makes the corners larger (or when
AppKit doesn't tell the radius, as before). The test is unchanged
except its comments: it already checks, by measurement and not by OS
version, that the toolbar stays where it doesn't change the corners
and that the main window has a plain title bar's corners,
so on macOS 26 a toolbar kept wrongly is red too.
docs/subsystems/gui-shell.md says so.

Run (mote, macOS 27.2, arm64, at this tree on 05f6fd423):
- go test -count=1 -run 'TestMainWindowCorners$|TestMainWindowRightToLeft'
  -v ./internal/gui: both subtests and right-to-left pass; macOS 26 SDK
  now reads "toolbar kept true", corners 16/16/16, lights, 66pt title
  bar, presses and sheet the same as the toolbar window's.
- go test -count=1 ./internal/gui/...: ok (133s).
- gofmt -l . (empty), go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build: ok.

Broken by hand: toolbarRounder made to return YES (the old behaviour):
TestMainWindowCorners/macOS_26_SDK red at "a toolbar doesn't change the corners" on all three stages,
as in #3949. Restored.

Not tried: macOS 26 (no macOS 26 test machine; heavy runs stay off this
Mac), where toolbarRounder must still read 26pt against 16pt and take
the toolbar off; CI's macOS job runs macOS 15, which never reaches it.
No screenshot of the corners on mote (screencapture has no Screen
Recording permission over ssh); the corner mask was compared instead.
The full suite runs after the push.
2026-11-07 15:04:26 +08:00
yetone 05f6fd423b kiro: the mover installs 0.1.28, which uses both of an Identity Center account's credit regions
kiro 0.1.28 is on registry.npmjs.org (npm view --prefer-online with a
fresh cache: 0.1.28, shasum c643deaeb9366d5b43b841db0bdf89523479bba1;
publish.yml run 42346180094's npm step printed "+
@magpie-community/opencode-kiro-auth@0.1.28", the run red only for
think-tags, plugins#180). It is e7cb9dc5 in magpie-community/plugins
(plugins#820): an IAM Identity Center organization can enable Kiro in
us-east-1 and eu-central-1, each with its own profile, month of credits
and overage cap. The plugin used the first profile only, so the account
left rotation when that region ran out while the other still had
credits. Now a used-up region rests and the request goes once to the
other, overage counts against overageCap, and the Usage card shows each
region. keepMovedCurrent brings every moved Kiro user to 0.1.28.

Run on mote at d052fec0e + this change: gofmt -l internal/provider
empty; go vet ./internal/provider for darwin, linux and windows ok;
go test -count=1 ./internal/provider ok (127s).
The plugin's own run (bun test packages/kiro, 140 pass), what was broken
by hand and the reviewer's probes are in e7cb9dc5's body.

Not tried: a real Identity Center account running out in one region,
through magpie or otherwise; the author ran real accounts enabled in one
region each.
2026-11-07 14:22:16 +08:00
Flandern1211 d052fec0e3 dsh: a fork without a parent gets its own row, named by its replies (#5542)
#5491 names a dsh fork's completed requests by the reply id dsh writes
with them, over the conversation's opening only where the two agree: the
reply's session owns the opening, or is a fork of its owner, which the
fork header's parentSession says (Session.ForkOf).

dsh 0.2.2's ordinary fork writes isSeeded and session/end-seed but no
parentSession. ForkOf is empty, the guard refuses the reply id's own
session, and the fork's requests stay under its source on Routing and
Context; the fork's own row never appears (Flandern1211: 7 of 17
top-level seeded sessions on one computer are such forks).

end-seed now keeps the conversation ids its copied events opened
(SeedConvs) instead of dropping them with the seed's counts. That is the
fork's own file saying it copied that opening, and forkedFrom accepts it
when the fork names no parent, only to admit a reply id that is already
one session's. A route with no reply id still goes by the opening, and a
reply id two sessions share stays ambiguous. dsh's parse version rises
so kept parses are read again; the Routing integration fixture leaves
parentSession out, as current dsh does.

Flandern1211's fix/dsh-fork-without-parent @ ead1abcce, as written; one
conflict taken (parseVersions has antigravity 2 on main). ggbdpq's port
on #5542 (0d7e18d1e) is the same change.

Not ported: the follow-up fix/dsh-fork-unmatched @ 1bce689ed (Context
page leaves a fork-shared opening's unread route out of both cards).
Review findings are on #5542.

Run at aca932bf7 (this change on 5c5160c94), on mote; the pushed head
adds only e20517a88 under it, a one-line Qoder mover min:
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., go build ./..., GOOS=linux go build -tags nogui ./...,
  GOOS=windows go build ./...: all ok.
- go test -tags nogui -count=1 ./internal/sessions/ ./internal/gui/
  ./internal/gateway/: ok (18.8s, 82.8s, 783.9s).
- gofmt -l on the six files: nothing.

Broken by hand (mote, -run 'Dsh|Fork|Routing|Context'):
- end-seed dropping SeedConvs: TestDshForkWithoutAParentKeepsItsSeedOpenings
  red ("seed openings [], want [magpie-e2f7b8e6… …]") and
  TestRoutingTellsAForkByItsReply red ("route 1: session
  \"session-source\", want \"session-fork\"").
- forkedFrom ignoring the seed: TestDshForkWithoutAParentIsNamedByItsReply
  red ("reply \"chatcmpl-fork\", opening \"magpie-open\": \"source\",
  want \"fork\"") and TestRoutingTellsAForkByItsReply red.
- assembleListed not carrying SeedConvs onto the Session:
  TestRoutingTellsAForkByItsReply red.
- Review check: the source's routes from before reply ids were kept (no
  ResponseID) still make the source's Context card, 3 of 3 requests.

Not tried: a replay of real dsh session files (the reporter's numbers
are on #5542; ~/.dsh here is a live config and was not read); dsh's
parse version bump is not pinned by a test of its own (the generic
re-read on a raise is, in cache_decode_test.go).

Reported-by: Flandern1211
Co-authored-by: Flandern1211 <163982805+Flandern1211@users.noreply.github.com>
2026-11-07 13:54:24 +08:00
yetone e20517a886 provider: Qoder's mover min is 0.2.63 (plugins#822)
qoder 0.2.63 never sends a request's max_tokens above the model's
ceiling: Qoder CN's QoDuck (lmodel) refused anything above 131072 with
"Error in upstream response: Range of max_tokens should be [1, 131072]",
which the plugin read as the vendor's 502, so every lmodel request failed
and each qoder-cn account was rested in turn. A smaller max_tokens goes as
asked; a model with no known ceiling is asked again once at the one Qoder
names, and a refusal that holds is the request's 400 with Qoder's words.
Raising the min lets keepMovedCurrent update every moved Qoder and Qoder
CN user.

npm checked first: `npm view --prefer-online --registry
https://registry.npmjs.org @magpie-community/opencode-qoder-auth version`
gives 0.2.63 (latest). Plugins commit 978bb42b.
Run on mote: `go test -count=1 -run 'Moved|Mover|Qoder|Min|Retir|Plugin'
./internal/provider` ok. `gofmt -l internal/provider` is clean.
Not tried: a real qoder-cn account on lmodel.

Reported-by: Gruu6y
2026-11-07 13:47:00 +08:00
5c5160c940 provider: a model's test asks the account or key routing sends it to (#4992)
On a provider with several accounts or keys whose models differ (a
magpie-newapi pool, a relay whose keys sit in different groups), "测试模型",
the right-click test and the provider's Test asked the first account or
key. A model that only another account serves failed (grok-4.7: 503 "no
available channel") while real requests were answered, because the
gateway's perKeyEvery passes over accounts and keys the user set not to
serve the model (AccountModels, #474) and accounts whose own list lacks
it. The test path had none of that.

Cause: the choice lived in the gateway only (perKeyEvery and accountsOn
in gateway/fallback.go), so the test had nothing to share. keySeeing
checked the key's list but not AccountModels.

Change:
- internal/provider/route_accounts.go: AccountsOn, AccountsFor and
  KeysFor are the routing choice. The code moved there from perKeyEvery
  and accountsOn, and the gateway's caps are passed in as a held func.
- gateway/fallback.go: perKeyEvery and accountsOn call it. They behave
  as before.
- test.go:
  - testOne (the model test and the right-click test) runs as
    AccountsFor's first account. A model barred on every account is
    not asked; it says so.
  - The provider's Test picks key and model together (testWith), then
    the account that serves the model (routedTo).
  - The log row names the account asked (loggedAs).
  - keySeeing and testModel take keys from KeysFor and AccountServes.
- detect.go: detectOne, a sibling, asks each model with keySeeing's key.
  Before, it asked the endpoint's first key.
- Not changed: AskSystemOne's decision model still asks the provider's
  own account.

Tests (internal/provider/test_account_route_test.go), on a two-account
fake plugin and a relay that answers one key:model:
- TestModelTestAsksTheAccountThatServesIt
- TestModelTestPassesAnAccountWhoseListLacksIt
- TestProviderTestAsksAnAccountThatServesItsModel
- TestModelTestUsesTheKeyServingIt
- TestModelTestBarredModelIsNotAsked
- TestDetectModelsUsesTheKeyServingIt

All six are red on origin/main e932cd258 (test file alone): "Bearer a@fake
/v1/responses" 503, sk-a asked m-b, and so on. All six are green after.

Run on mote:
- go test -count=1 -timeout 45m ./internal/provider ./internal/gateway: ok
  on e932cd258. After the rebase onto d9f63dfee: go vet, the whole of
  internal/provider, and internal/gateway -run
  "Fallback|PerKey|Account|Key|Cap|Spend", all ok.
- go vet, GOOS=linux -tags nogui go vet, GOOS=windows go vet for both
  packages; gofmt -l clean.
- node --test with the GUI files that test models (model-test-as,
  model-test-one, model-test-stop, model-test-why,
  test-models-key-hint): 60/60, Chromium and WebKit. They fake /api, so
  they don't reach this change.

Broken by hand:
- `|| true` on Lists in AccountsFor: TestModelTestPassesAnAccountWhoseListLacksIt
  and the gateway's TestCodexProviderListsEveryAccountsModels go red.
- The AccountServes case in KeysFor turned off:
  TestModelTestUsesTheKeyServingIt goes red. The gateway goes through
  the shared code.

Not tried:
- A real newapi pool or a real multi-account sign-in.
- Usage and spend caps are not applied to a test (held is nil).
- The Windows and Linux runs.
- The full suite was started on mote after the push, under suite.lock.

Reported-by: scutken
Co-authored-by: xiejiayu <scut_ken@qq.com>
Co-authored-by: Jackzigen <zigenhan@gmail.com>
2026-11-07 13:34:54 +08:00
yetone d9f63dfee8 antigravity: a model read apart from its group is a pool of its own; a model no window counts rests alone
runking on Discord: Antigravity has three groups (Gemini 3, Gemini 4,
Claude); Claude was used up, Gemini 4 not, and the card showed only
Gemini 5h/7d and Claude 5h/7d, no Gemini 4.

Cause: when retrieveUserQuotaSummary has no "Gemini 4 Argon" group (an
Ultra account's, whose Argon quota Antigravity-Manager reads in
Gemini's; or the prod endpoint's, per CodexBar), pools() put every
Gemini model into the family-wide "Gemini Models" pool, gemini-4-argon
too, though fetchAvailableModels gave it a reading of its own. The card
then showed Gemini's reading for it and hid Argon's.

Now a model is folded into its family's pool only when its own reading
matches the pool's 5 hours (share left within half a point, reset within
a minute when both tell one). Otherwise it is a pool of its own, named
as Google names the model without its level ("Gemini 4 Argon (High)" is
Gemini 4 Argon), with a week's span when its reset is past 5 hours. It
is Aside, as every pool is, so routing still reads the model's own
window. The GUI already shows a model's own pool ("Gemini 4 7d" ring);
its code is unchanged.

Routing: Allowance.Pooled said a model no window counts was the
account's. Antigravity's Gemini models that fetchAvailableModels gives
no quotaInfo (#3737) have no window, so a 429 on one rested the whole
account. When every window an account has is some models' only, a
refusal of a model none counts now rests the model. An account with a
window of its whole stays as before. A used-up Claude group already
rested only Claude's models.

pools() logs the summary's group names and bucket ids once per change
per account, under an 8-hex hash of the account, with no token or
email, so the next report shows the shape Google sent.

Run (mote, at this head): go test ./internal/provider ./internal/gateway
-count=1 -timeout 45m ok; GUI quota-pool-model, quota-pools,
quota-pool-order (Chromium and WebKit, en and zh) 12/12 ok; gofmt; GOOS
linux and windows go vet ./internal/provider ok.
Red on the old code: TestAntigravityQuotaModelApartFromGroup (Argon
folded into Gemini) and TestAllowancePooledModelNoWindowCounts (rests
the account).
Broken by hand: sameReading always false makes the "read alike" case red
(every Gemini model split off).
Not tried: a real account. The fixtures come from the proto in the agy
binary and the shapes Antigravity-Manager and CodexBar record, with and
without the Argon group. Whether runking's summary lacks the group, or
has it inside Gemini Models, is unconfirmed; the new log will show it.

Reported-by: runking (Discord)
2026-11-07 13:26:51 +08:00
yetone 32fc5809e1 agents: OpenMausBot gets magpie as an engine of its own, written as its own Claude endpoints are (a user on X)
A user on X asked for OpenMausBot (github.com/milind-soni/OpenMausBot,
read at 516ca75; released 0.1.145). Its bots run on engines from
`instances` in ~/.openmausbot/config.json ($OMB_DATA_DIR,
server/config.ts:713). Without this, a Claude bot reached magpie only
through ~/.claude/settings.json, and its picker listed Claude's static
models alone: OpenMausBot doesn't read the model from env
(readClaudeModelCatalog, claude.ts:296-316).

- openmausbot.go writes `instances.magpie` in the shape of OpenMausBot's
  own "Claude endpoint" (newClaudeEndpoint, claude-endpoints.ts:91-139):
  - driver claudeAgent, access custom
  - config.configDir is <data>/providers/magpie. Given that,
    OpenMausBot starts Claude Code with that CLAUDE_CONFIG_DIR and
    strips account keys the engine doesn't set (claudeEnvironment,
    claude.ts:111-136, 158-179), so the engine owns its routing.
  - requireApiKey
  - ANTHROPIC_BASE_URL, AUTH_TOKEN, API_KEY and MODEL point at the
    gateway
  - endpointModels holds magpie's models, kept to the ids
    CLAUDE_MODEL_ID accepts. One bad id makes OpenMausBot refuse the
    whole engine (claude.ts:636).
- A non-empty `instances` is the whole fleet (config.ts:1173). With
  none saved, magpie writes DEFAULT_FLEET (instance-fleets.ts) beside
  magpie, stashed as openmausbot.fleet. Off takes the fleet out again
  if the user hasn't changed it.
- What stays the user's: the engine's name, a model they picked from
  the list, their other env and an inherited `cli`.
- Check reports the base URL drifting away from the gateway.
- OpenMausBot reads config.json once at start (index.ts:780), and an
  engine edited in it writes back the fleet it holds
  (routes/instances.ts:132, config.ts:997-1012). So Set is refused
  while it runs (errOMBRunning), and the notice asks to quit it first,
  since Windows can't tell.
- ListOnly, ListsModels, OMB_DATA_DIR in agentenv. The icon is
  OpenMausBot's build/icon.svg (Apache-2.0).
- i18n in zh, zh-TW, ja and de. Docs: reference, agent-wiring, both
  READMEs.
- Codex bots use ~/.codex (codex.ts:373-386), which the Codex wiring
  already covers.
- The agent package's TestMain holds ombRunning false. An OpenMausBot
  open on the test machine refused every test that turns magpie on for
  each agent: my own sandbox OpenMausBot on mote turned
  TestSyncKeepsAnAddressOnAnotherMachine, TestListOnlyAgentsReadConnected
  and TestReverseProxyIsStillMagpie red. With a process named
  openmausbot running, they now pass. LiveAgent's, OpenPencil's and
  NewMax's running checks have the same hole and are left to #5587.

Run (all on mote):
- gofmt -l: clean
- go vet ./... on darwin, GOOS=linux -tags nogui and GOOS=windows: ok
- go build for the same three targets: ok
- go test -tags nogui ./... -timeout 45m at e1453a168 (this change on
  origin/main 30ae0e3f9): 88 packages ok, none failed. Rebased after
  it onto e932cd258, which changes internal/library and adds one GUI
  test only. At the pushed head: go vet of internal/agent and
  internal/library, and go test of internal/agent, agentenv and
  appdir, all ok.
- GUI: the 71 files this change reaches, in chromium and webkit, every
  language they cover: agent-*, agents-*, i18n-*, icon-*, gui-de,
  gui-ja, gui-zh-tw, about-notices, deprecation-notice, header-relang,
  market-icon-corners. 1145 of 1146 pass. The one red is i18n-keys'
  "a plugin's words are its own" for plugins' "Use the library's",
  "No session ID" and "View routing", the same on main and filed
  (#5332, #5426, #5482). The whole GUI suite was started too and
  stopped at 369 ok, 0 failed: at ~5h on mote it runs after this push.

Real OpenMausBot: 0.1.145's arm64 app was run on mote, its own server
(ELECTRON_RUN_AS_NODE, Resources/server/index.js) with HOME and
OMB_DATA_DIR in a sandbox, on a free port, against a config.json
magpie's Set wrote. /api/instances listed 28 engines, among them
`magpie`: access custom, claudeEndpoint at http://127.0.0.1:3425, and
models relay/glm-4.6 and relay/gpt-5.5 in its picker, with the first as
default. It read "unavailable: `claude` CLI not found" only because the
sandbox PATH had no claude. The file was left as magpie wrote it.

Broken by hand:
- The fleet not written: TestOpenMausBotEngine red.
- The model-id filter taken out: TestOpenMausBotEngine and
  TestOpenMausBotKeepsTheUsers red ("relay/glm 4.6 (beta)"). Green
  before a bad id was added to the fixture, so one was added.

Not tried:
- A bot turn through Claude Code to a gateway. No claude CLI or
  account on mote.
- The desktop app's window, Linux and Windows builds.
- An OpenMausBot running while magpie writes. The refusal is
  unit-tested only.
2026-11-07 13:13:36 +08:00
yetone e932cd2589 library: a program whose path has spaces, typed as it is, is that program (zachzhao1984)
Library → MCP's command field splits a line at each unquoted space, as a
shell does, so "/Applications/Agent HUD.app/Contents/MacOS/Agent HUD --mcp"
reached the library as the program /Applications/Agent with the arguments
HUD.app/Contents/MacOS/Agent, HUD and --mcp. The save itself went through;
what was saved and written into every agent's config was a program that
isn't there, so the server never started. `magpie mcp add` with an
unquoted path and the TUI's line (strings.Fields) split it the same way.

Server.check, which every way in passes (the GUI's save, `magpie mcp add`,
the TUI, a market install, a backup or sync read in), now joins the words
back: when the command is a full path to no file, and it with the words
after it, joined by a space, is a program on this computer (a regular
file, executable outside Windows), that is the program and the rest are
its arguments; the fewest words that make one, as Windows reads an
unquoted path. A command that is there, a bare name (npx -y foo), or a
path no join makes stay as typed. Each agent is then given the program as
one argument with its spaces (JSON's and TOML's own quoting), and the GUI
shows it quoted ('/Applications/…/Agent HUD' --mcp), which reads back as
one word. A path typed in quotes, or with \ before its spaces, was already
one word. A server saved split before stays so until it is saved again:
opened and saved, its line is joined.

Tests:
- internal/library TestSpacedProgram: split, no arguments, given whole,
  a bare name, a path no join makes, a program that is there keeps its
  next word, a folder is no program.
- TestSpacedProgramSaved: ServerOf from the split words, SaveServer, the
  library and Claude Code's .claude.json and Codex's config.toml each
  hold the program whole and --mcp.
- internal/gui/tests/library-mcp-spaced-path.test.cjs: the reporter's
  line typed in a new server's dialog is sent as typed; the row and the
  editor show the path quoted; saving unchanged sends it whole; a quoted
  path is sent whole; a save the library refuses (a name with a space)
  shows its reason and the dialog stays. en and zh, 1100 and 390 wide,
  Chromium and WebKit, nothing scrolls sideways. The fake save stands in
  for the Go join.

Run (mote, via mote-run, at this tree on 30ae0e3f9):
- go test -count=1 ./internal/library ./internal/cli ./internal/tui: ok.
- go vet (library, cli, tui), GOOS=linux go vet -tags nogui and
  GOOS=windows go vet ./internal/library, go build ./..., GOOS=linux
  go build -tags nogui ./..., GOOS=windows go build ./...: ok. gofmt -l:
  nothing.
- win-run go test -run TestSpacedProgram ./internal/library (Windows 11):
  ok.
- node --test library-mcp-spaced-path: 10 of 10, four runs in a row.
  library-mcp-win-line, library-mcp-json, mcp-local-server: ok.
  i18n-keys "a plugin's words are its own" is red, the same three lines
  on a clean origin/main 30ae0e3f9 copy (filed: #5332, #5426, #5482);
  this change adds no strings.

Broken by hand:
- the spacedProgram call in check() commented out: TestSpacedProgramSaved
  FAIL, the library has Command .../Agent and Args [HUD.app/Contents/
  MacOS/Agent HUD --mcp].
- quote() taking a space as safe: library-mcp-spaced-path 0 of 10, the
  editor shows the line unquoted.
- The GUI test first flaked 2 of 10: a new dialog focuses its name a
  frame after it opens, and a command typed sooner landed in the name.
  The test waits for that focus now.

Not tried: the real Agent HUD app (not installed here), nor a real agent
starting the saved server; a program path with spaces given to an agent
in WSL (the join stats this computer's files, so a Linux path typed for a
distro is left as typed); the full go suite before this push (runs after,
under the lock).

Reported-by: zachzhao1984 (Discord)
2026-11-07 12:59:36 +08:00
yetone 30ae0e3f92 context: Tuned for you draws only the advice rows it knows (Linka)
Linka on Discord (v0.1.3199, a Docker magpie added as a Remote magpie):
Usage › Context showed "undefined is not an object (evaluating 'r.cost')".

Cause: since v0.1.3120 (6b91c2ea5, fcc0daa23) /api/tune sends "few"
rows, a setting put in with too few calls to weigh, with no compact
and no ttl. A page from before then reads `(a.compact || a.ttl).cost`
and throws on such a row. No Go code relays /api/tune from a Remote
magpie, so the throw needs a page from v0.1.3119 or earlier against a
newer server, such as a window left open while the container updated
(the page reloads only when /api/update is asked). Today's page
survives few rows but still threw on a null agent or row ("null is
not an object (evaluating 'a.advice')") and on a row with no setting.

loadTune now keeps only the agents and rows that are objects, and the
rows with a compact or ttl replay or few: true, each with a setting
object. Every reader of advice (adviceRow, tuneCard's totals,
renderTune's filter, the few checks) reads that normalized tuneData.
Two long comments in context.js were cut to pay for it. The core
script budget is not raised.

Run (mote):
- context-tune-shapes.test.cjs (new), Chromium and WebKit, en and zh,
  900 and 420px: 20 of 20 ok.
- context-tune, i18n-keys, TestCoreScriptBudget: ok, except i18n-keys'
  "a plugin's words are its own", red on main as #5332, #5426, #5482.
- Every context*.test.cjs and routing-context-fold.test.cjs at this
  head and at origin/main 82403f9f6: 484 ok / 2 red here, 464 ok / 2
  red there. The red on both is routing-context-fold's WebKit
  ResizeObserver loop error (#5586).
- The whole GUI suite under the suite lock is still running. Its reds
  so far are on pages this change doesn't reach. Each one that is red
  on main too gets its own issue.

Broken by hand: the new test run against v0.1.3119's assets
(MAGPIE_ASSETS) fails 20 of 20, with Linka's exact text in WebKit
("undefined is not an object (evaluating 'r.cost')") and "Cannot read
properties of undefined (reading 'cost')" in Chromium. Against the
assets of origin/main before this change, its unknown-shapes case
fails in both engines on the null agent.

Not tried: Linka's real Docker setup, or a real old page left open
across a server update. The Go suite was not run, since there is no
Go change.

Reported-by: Linka (Discord)
2026-11-07 12:13:15 +08:00
yetone 82403f9f6d claude: /usage is read through -p, never the interactive mode, which opened idle accounts' 5-hour window (#5582)
Since v0.1.2635 (ccd746e03), when the interactive mode is on (the
default), magpie read the plan's allowance by starting the interactive
Claude Code in its helper and typing /usage there (claudeUsageTUI). The
interactive Claude Code 2.1.316 sends a model request as it starts,
before anything is typed. That is probeQuotaStatus: haiku, max_tokens 1,
content "quota". It sends it unless CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC
is set, and that variable also keeps /usage from loading. The request
counts, so on an account with no 5-hour window it started one. The
reporter's reads came at magpie's start and when a window ended, and
each opened a window with warm-up off. Their counterexample (11-01,
v0.1.2433, before ccd746e03) read /usage through -p and opened nothing.

Recorded (sandbox HOME and CLAUDE_CONFIG_DIR, a fake sign-in, the real
Claude Code 2.1.316 behind a recording proxy that answers everything
itself, so no account was spent):
- magpie's interactive args and env, in a pty. At start, before /usage
  was typed:
  POST api.anthropic.com /v1/messages?beta=true
  {"model":"claude-haiku-4-5-20251001","max_tokens":1,
   "messages":[{"role":"user","content":"quota"}],...}
  then GET /api/oauth/usage once /usage was typed.
- The same with CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1: no POST, but
  no /api/oauth/usage either, and the panel says "Failed to load usage
  data". This can't be the fix.
- `claude -p /usage` with claudeUsageArgs and claudeUsageEnv: no
  /v1/messages at all, only GET /api/oauth/usage (plus profile and
  bootstrap GETs). It printed "You are currently using your subscription
  to power your Claude Code usage" / "Current session: 13% used · resets
  Nov 7 at 4pm (Asia/Shanghai)" / "Current week (all models): 4% used ·
  ...". ccd746e03 said -p's /usage tells only the session's cost. In
  2.1.316's source that is only for a sign-in without a subscription or
  the user:profile scope, such as a setup-token, which provider never
  reads (errClaudeSetupToken), or an API key.

Fix: claudeUsage always runs `claude -p /usage`, with the interactive
mode on or off. claudeUsageTUI and claudeTUIUsageArgs are gone. This is
the one choke point (provider.UsageClaudeVia -> runClaudeUsage) for
every magpie read of Claude usage: the signed-in account's card,
saved accounts (readSavedClaudeUsage), the 8-day keep-alive, the
used-up switch's spare reads and refreshes. The other interactive
starts are the bridge's turns, the warm-up and the model test. Each one
sends a model request the user asked for, and each runs with
cleanClaudeEnv's CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1, so the
startup probe isn't added there. Not changed: claudetui still takes a
typed /usage, and magpie no longer sends it.

Docs: docs/subsystems/claude-subscription-bridge.md says why and
removes the wrong -p claim. The comments in claude_warmup.go, tui.go
and claude_usage_cli.go are updated to match.

Tests: TestClaudeUsageStartsNoInteractiveRun replaces
TestClaudeUsageTUIOn, TestClaudeUsageTUIWorksInMagpiesFolder and
TestClaudeUsageTUISaysItsDeadline. With the interactive mode on, it
checks that a read of the signed-in account and of a saved one starts
no helper, runs -p /usage, and leaves the traffic variable off. The
"usage" rows of TestClaudeOneOffTrustsMagpiesFolder and
TestClaudeOneOffFailureLogged are removed, since a /usage read is no
longer an interactive one-off run. Their "test" rows stay.

Run (mote, at this tree on origin/main 665b9aff1; after the rebase on 9e6687e3a, vet and claudetui plus gateway's ClaudeUsage|OneOff|Trust|TUI tests again: ok):
- gofmt -l internal/gateway internal/provider internal/claudetui: clean.
- go vet for darwin, and for linux and windows with -tags nogui:
  ./internal/gateway ./internal/provider ./internal/claudetui ok.
- On mote: go test -count=1 -timeout 45m ./internal/provider ./internal/claudetui: ok (114s, 110s);
  go test -run 'Claude|Usage|Warm|Trust|OneOff|TUI|Shim|Guard|Loop|Budget' ./internal/gateway: ok (89s).

Broken by hand: with HEAD's claude_warmup.go (its claudeTUIOn branch
back) and the new test, TestClaudeUsageStartsNoInteractiveRun went red:
"a /usage read started the interactive Claude Code: claude-tui-helper
.../claude -p --output-format stream-json --input-format stream-json ...".

Not tried: a real account's -p /usage on this build. The windows output
above comes from the recorder's fake usage reply, and the reporter's
v0.1.2433 readings came from -p. Not tried: an Enterprise account whose
usage reply leaves the windows out. -p then prints only the
subscription line, which reads as "temporarily unavailable" and keeps
the last reading, where the interactive panel had said no window has
started. Not run on Windows or in WSL. The -p read there is the same code
(claudeUsage); the interactive read had run on Windows too.
Not run: the full ./... suite (mote's suite.lock had four full runs
queued).
2026-11-07 11:52:30 +08:00
yetone 9e6687e3a5 claudetui: the Claude in Chrome offer is declined once it has stayed drawn, and an error never ends on an empty screen
sowhynot (Discord, magpie 0.1.3216, Claude Code 2.1.319, macOS, Claude
Pro, interactive mode): every request and the endpoint test failed with
"claude-tui: Claude Code showed no prompt in the 21.9s its caller waits
for it:" and nothing after the colon; `claude -p` worked.

Cause: where the Claude in Chrome extension is installed and Claude
Code's tengu_chrome_auto_enable flag is on, 2.1.319 opens its
ChromeAutoEnableDialog as it starts (a claude.ai sign-in, no answer
recorded). The helper cleared its screen and sent Esc the moment it saw
"keep browser tools off". The dialog turns away a key that comes just
after it opens (refuseInput/refusedWithin) and draws nothing again for
it, so the screen the helper read stayed empty: nothing matched again,
the run waited out its caller, and lastScreen() had nothing to say. The
decline is never recorded, so every run met it again.

Fix:
- The offer is answered through onboard(): Esc once it has stayed drawn
  trustSettle, at most onboardTries times, then an error that says the
  offer takes no answer.
- seen(): with nothing drawn since the screen was cleared for
  redrawWait (1.5s), ready() reads the screen as it stands (the grid),
  so a key lost to a dialog that draws nothing again is sent again.
- What the run hadn't done is read from the screen as it stands too:
  "asked whether to use Claude in Chrome, not answered".
- lastScreen(): with nothing drawn since a clear it gives the grid's
  text, and with nothing on it, "nothing on its screen (N bytes read)".

There is no -p fallback for the one-off runs (the endpoint test, a
/usage read) by design: the shim never turns into -p (TestShimNeverPrints).

Run, on mote at this tree (base 665b9aff1):
- go test -count=1 ./internal/claudetui/: ok (118s).
- go vet ./internal/claudetui/ for darwin, linux and windows; go build
  ./... (darwin), GOOS=windows go build ./..., GOOS=linux go build
  -tags nogui ./...: ok. gofmt -l: clean.
- win-run (xiaomi-gpu): TestShimDeclinesChromeOffer,
  TestShimEndsAtItsCallersDeadline, TestShimNeverPrints,
  TestShimGoesThroughOnboarding: ok.
- Real Claude Code 2.1.319 (npm) through this helper in sandbox HOMEs on
  mote: onboarded, classic and CLAUDE_CODE_NO_FLICKER=1 renderers, init
  emitted; folder not trusted (MAGPIE_CLAUDE_TUI_TRUST=1), and
  onboarding not done (theme, notes) plus trust: gone through to the
  prompt, the message sent (401 on the fake API key, as expected).

Broken by hand:
- The old tui.go with the new tests: TestShimDeclinesChromeOffer waits
  30s with no answer; TestShimEndsAtItsCallersDeadline/chrome offer
  unanswered gives "showed no prompt in the 3s its caller waits for it: "
  with nothing after it, the reporter's line.
- seen() never reading the grid: TestShimDeclinesChromeOffer red (the
  fake turns keys away for 700ms, past the first Esc).

Not tried: the Chrome offer itself in a real 2.1.319. It needs a
claude.ai OAuth sign-in whose token /api/oauth/validate accepts, the
extension's folder in a Chrome profile and the GrowthBook flag on; no
sign-in is available on mote. The fake draws 2.1.319's dialog text and
its refusal is modelled on the dialog's source. Not run: the full
go test ./... before the push (it runs after, as the rules say).

Reported-by: sowhynot
2026-11-07 11:27:58 +08:00
yetone 665b9aff12 gateway: a reply of several requests tells the last one's prompt, bills them all
Claude Code reads a reply's input, cache_creation and cache_read as how
full its conversation is. A reply more than one upstream request made
summed all three across them. In the bridge: Claude Code's own
ToolSearch/WebSearch going on into the answering message, a TUI message
written after its call was told (lateUsage), a cut stream's retry
(b42ff722). Each later request re-sends what the earlier one had, so the
reporter's TaskStop reply after a ToolSearch said cache_read 1,154,857
(577,009 + 577,848) and cache_creation 829 (253 + 576) for a ~577k
conversation, and Claude Code compacted early. 12 of their 30 replies
after ToolSearch were about 2x.

The translated route summed the same way across its tries (#5115): the
empty reply asked again (#667), a loop's re-ask (#1359), a cut reply's
continuation (#853), and search.go's web search rounds. The Anthropic
passthrough has no in-reply fold; each try is its own call.

Usage.after (claude_subscription.go) replaces plus at these joins: the
client is told the last request's input, cache writes and cache reads,
and every request's output and reasoning (all of it was streamed). The
earlier requests' prompts go in Deferred, which the ledger bills
(billed()) and no encoder tells. Usage.restart makes a later request's
prompt counts replace the earlier's, a zero too, so a later request that
reads nothing from the cache isn't told, or billed again, the earlier's
reads. Cache writes are last-only for the client as well: the later
request reads what the earlier wrote, so summed they count it twice.
ggbdpq's #5115 analysis named the translated route's case; no code of
theirs was used.

Tests (usage_last_prompt_test.go), on the reporter's numbers:
- TestClaudeOwnCallReplyTellsLastPrompt: bridge, told 6/576/577848,
  billed 8/829/1154857; and a second request that missed the cache.
- TestClaudeTUILateMessagePromptNotTold: interactive mode's late message.
- TestRetriedReplyTellsLastPrompt: Gemini three reasoning-only replies
  then an answer, Chat and Anthropic clients; ledger has all four.
- TestLaterTryZeroCacheReadNotTold: a continuation and a search round
  whose later request reads 0 from the cache.
Tests that pinned the summed client numbers now pin the last request's
and check the billed sum (CachePartialUpdateMatrix, Probe1717 zero split,
cut stream retry, own WebSearch, search rounds, StreamCutUsage renamed
TestStreamCutUsageTellsLastTry).

Run (mote, Go 1.26.8, -tags nogui):
- The new tests on origin/main ca77a9ea8: red, the client told
  8/829/1154857 (the report's numbers), prompt_tokens 2,000,000 for
  four 500k tries.
- Broken by hand: restart dropped -> TestClaudeCutStreamGoesOnInRetry
  and the cache-missed case red (reads billed twice); after() put back
  to plus -> 12 tests red; restart on the translated tries dropped ->
  TestLaterTryZeroCacheReadNotTold red (cache reads 200 billed, 111
  told). The last one was green before that test was added.
- go test ./internal/gateway/ whole: ok except
  TestClaudeInternalMessagesKeepCacheWrites, which pinned the sum and
  was updated after; that test with the usage, cache, search,
  continuation and TUI tests then ok (61.8s).
- go vet ./internal/gateway for darwin, linux and windows; gofmt clean.
- The full suite runs after the push (mote's suite lock held 3h+ by
  another session).

Not tried: a real Claude Code account or the real TUI, the reporter's
session, a real Gemini/translated provider, Windows or Linux runs of
the package.

Reported-by: sleepy_shibe (Discord)
2026-11-07 10:03:52 +08:00
yetone e2f085fda2 provider: Grok's mover min is 0.2.5 (plugins#818)
opencode-grok-auth 0.2.5 (plugins 5bbdb826) stops telling a user to add
the account again when xAI answers 401 "Authentication required" on a
token Grok Build left as it was and that hasn't expired. That refusal
isn't xAI's verdict on the token (which reads "Invalid or expired
credentials (... upstream=...)"), and it passed by itself within minutes
in the report. The plugin now answers it as a 503 with Retry-After: 60
and X-Magpie-Sign-In: kept, so the gateway rests the account briefly and
fails over (failOther, as for any kept 401 or 503); a real verdict is
still 401 "sign in again". A 401's wait on `grok models` is capped at
15s (was the 30s exec timeout).

npm has 0.2.5: `npm view --prefer-online
@magpie-community/opencode-grok-auth time` gives 2026-11-07T01:58:19Z.
The publish run's npm job is red only for middleware-think-tags 0.1.2
(E404, not its trusted publisher); grok 0.2.5 published in it.

Run: go test ./internal/provider/ on mote, ok (125s); gofmt -l clean.
The plugin side ran its package tests (mote), the repo bun test (Linux
VM, 6571 pass) and check.mjs grok; its body has the hand-breaks.

Not tried: a real "Authentication required" 401 (could not provoke
one), a revoked real token, a Grok Build renewal slower than 15s.

Reported-by: zane668
2026-11-07 10:00:21 +08:00
yetone a1774d1235 sessions: an Antigravity app conversation's folder is its summary row's workspace
The Antigravity app's Sessions tab put every conversation under "No
folder". Since 24dc1651b the app reader reads each conversation's row of
~/.gemini/antigravity/conversation_summaries.db for its title, and the
row's workspace_uris (a JSON list of file:// URIs) was already parsed into
the row's folder for agy, but parseAntigravity never set it as the
session's folder. It now does: the first local workspace URI, the same
rule as agy (agyFolder, including Windows drive and UNC forms). A row with
"[]", and a conversation with no row, still have no folder.

The antigravity parse version goes to 2: a parse kept in the Sessions
cache has the same row revision (agyRev already holds the folder) and
would otherwise keep its empty folder until the conversation changed.

Sibling, agy (the Antigravity CLI tab): already sets the folder from the
same column, for transcripts and row-only conversations (TestAgy*); no
change. A transcript with no row has no folder there, as before.

Shapes: workspace_uris and raw_summary as this Mac's agy writes them
(read only; ["file:///<project>"]); the fixture's paths are made up.

Run (mote): go test -tags nogui ./internal/sessions ./internal/usage ok;
GOOS=linux go vet -tags nogui and GOOS=windows go vet ./internal/sessions
ok; gofmt clean; GUI sessions-folder-list, -paging and -delete in
Chromium (34 pass) and WebKit (17 pass).

Broken by hand: with the old antigravity_app.go and sessions.go,
TestAntigravityAppFolder reads "" for both conversations with a workspace,
and TestAntigravityAppParseBeforeFolderReadAgain keeps the old parse.

Not tried: a real Antigravity app summaries database with workspace rows
(this Mac's app data folder has no conversations); the reporter's own
data; Windows paths beyond agyFolder's existing unit test.

Reported-by: xxooioo (Discord)
2026-11-07 09:42:37 +08:00
yetone ca77a9ea85 provider: the ZCode mover needs zcode 0.1.53 (plugins#817)
zcode 0.1.53 turns a spent bucket's HTTP 200 ("exceed quota limit"
1005, 1113) into a 429 on the plain path too, so a gift-only account
whose GLM-5.3 day is spent rests that model and still serves
GLM-5.3-Flash (with fd0cac250 on the gateway side). keepMovedCurrent
brings every moved user up to it.

npm view @magpie-community/opencode-zcode-auth@0.1.53 version
--prefer-online --registry https://registry.npmjs.org: 0.1.53, the
latest, at the time of this change (publish run 42322705464: zcode
published; the run is red for think-tags only, plugins#180).

Run: go test -count=1 ./internal/provider/ on mote: ok (117.7s), at
fd0cac250 plus this change.
Broken by hand: nothing; only the min string and its note change.
Not tried: a moved user's real update to 0.1.53.

Reported-by: zane668
2026-11-07 09:22:36 +08:00
yetone fd0cac2505 gateway: a full window of some models only rests that model (plugins#817)
A subscription account that fails with a window full rests until that
window renews (restAfter's "window" branch). The rest was always on the
account (restKey), whatever the window counted. Now, when every full
window that counts the model counts some models only (Allowance.Pooled,
the same reading a quota refusal already narrows by), the model rests
(restID), and its siblings in their own windows still answer. A full
window of the whole account rests the account as before.

zane668's ZCode Start Plan gift account: GLM-5.3's daily bucket was
spent, and the plugin passed its 200 "exceed quota limit" on as it came.
The gateway read that as a 502 that did not stream (failOther), the
window branch took GLM-5.3's full bucket, and the account rested ~22h.
GLM-5.3-Flash, with its own bucket 71% left and a weekend bucket unused,
was skipped by every group. zcode 0.1.53 now says that answer as a 429
(failQuota, which pooled already narrowed). This change is for any
plugin or built-in whose failure isn't worded as quota while a
per-model window is full.

Checked the reporter's reading before changing anything: spentUp runs
only on the forcedGift and freeGift paths, and the plain path returns
done(kept(res)). failure(502, "... did not stream: exceed quota limit")
is failOther. pooled is computed for failQuota only, and the window
branch set modelBackoff false and kept restKey.

TestScopedWindowFullRestsTheModelOnly builds the allowance through
PluginAllowanceForTest from the plugin's startUsage windows as the
report read them (GLM-5.3 100%, Flash 29%, the weekend bucket 0%):
- the 502 that did not stream rests GLM-5.3 alone till its reset, and
  Flash not;
- the plugin's new 429 1005 does too;
- with a whole-account plan window full as well, or alone, the account
  rests and Flash with it.
Not changed: the Codex out-of-credit branch's window. Its credits are
the account's.

Run at 93c258ef9 on mote: go vet ./internal/gateway ok; go test -run
'Rest|Window|Pool|Quota|Spent|Narrow|Renew|ZCode|Zcode|Backoff|Fail'
./internal/gateway ok (70.8s). Broken by hand: windowModel left out of
the restID condition, and the 502 subtest fails ("rests
zcode@me@zcode (model ""), want the model alone"). The 429 subtest
passes either way (pooled already covered it), as a guard.

Not tried: a live ZCode account with a spent bucket. The full suite
runs after the push.

Reported-by: zane668
2026-11-07 09:15:16 +08:00
yetone 93c258ef9d gateway: an account its vendor restricted isn't asked again while it rests
leowang (Discord #help, 11-07) had two Antigravity accounts that Google
suspended for a Terms of Service violation. Their usage rows read
"tried 23, answered 0, 23 account restricted by the vendor" and 22/0/22.
2e58f85e4 (v0.1.3110) reads that 403 as failRestricted and rests the
account restrictedRest (2h), and the comment promises one refused request
per account per two hours. But when the model has no other account,
restLast keeps a lone resting candidate ("there is no other") and
probeOne keeps the resting one back soonest. So every request still went
to Google, alternating between the two accounts. The same held for every
failRestricted refusal (WorkBuddy 11140, ZCode 3012, a Codex risk block).

restAfterMarked now keeps the vendor's words with a restricted rest.
restrictedHeld gives them again, with the refusal's status, when the
last candidate of a request is an account resting for that reason. This
mirrors verifyHeld: nobody is asked, the try is marked restricted so the
panel keeps saying why, and the rest isn't taken anew, including in a
strictly kept conversation. When the rest ends (or Unrest), the account
is asked once again. A refusal of the request's content (Antigravity's
400 high-risk text, or its 429 on agent prompts, failPrompt) rests
nothing and still asks.

Run (mote, macOS 27):
- go test -count=1 -timeout 45m ./internal/gateway: ok
- the new tests (restricted_held_test.go) and -run
  'TestAntigravitySuspended|TestRiskRefusal|TestWorkBuddyRestricted|
  TestPluginRestrictedAccountSkipped|TestZCodeStartPlanBlockRestsRestricted|
  Restricted|Verif': ok
- gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean
Broken by hand:
- On the old gateway.go/routing.go,
  TestSuspendedAccountsNotAskedWhileTheyRest is red ("turn 2: 403 ...
  asked [u1]") and TestRestrictedLoneAccountNotAskedWhileItRests is red
  ("request 2 ... asked [acct-1 acct-1]").
  TestContentRefusalStillAsksTheAccount passes on both.
- With the !heldRestricted rest guard replaced by true,
  TestSuspendedStrictConversationKeepsItsRest is red ("turn 3 moved the
  rest").
Not tried:
- A real suspended Google account. The fixture is the 403 body from
  2e58f85e4's test.
- A restricted rest still lives in memory only (rests.json keeps ladder
  rests), so a restart asks each such account once more. Not changed.

Reported-by: leowang (Discord)
2026-11-07 08:55:36 +08:00
yetone be927cd907 gui: the sidebar's shape lands where its row comes to rest, not past it
小李 on Discord: switching tabs in the latest version animates wrongly;
from the Library to another provider page "the white background bounces
up". Since 17a2b00ef (v0.1.1355) the open page's row is marked by one
shape (.nav-top-hl) that springs toward the row's offsetTop each frame.
Leaving the Library, its six-tab list folds away above Providers, so the
row rises while the shape travels down to it: the shape went 38-43px past
the row and came back up under it, white on the light theme.

navTopStep now aims at navTopLands(row): the row's offsetTop less the
height and margins of every .nav-sub.leaving above it, which is where it
will rest. No new motion, no layout change, no new timing; the rest check
(nothing still folding) is unchanged. Nearby comments in app.js were cut
so app.js is 73 bytes smaller than before, no budget raised.

sidebar-glide.test.cjs adds a Library fixture and walks usage, agents,
library, providers, asserting the Library's list is open above when
Providers is pressed; its existing "settles with at most a little
overshoot" (< 3px) check is the guard.

Run (mote, through mote-run):
- sidebar-glide.test.cjs, Chromium and WebKit, en and zh, 1024 and 1440:
  12 of 12 pass.
- go test -run Budget ./internal/gui: ok.
- whole GUI suite (make test-ui), at load ~40 from other sessions'
  unlocked Go suites: 21483 pass, 303 fail in 53 files, none a sidebar
  test. The 53 files run at origin/main d4a221f79: 292 fail in the same
  files (the class #5475 has). The 8 files red only in the whole run
  passed at main; run again at this head, 7 pass and skill-edit's
  chromium 400px cases fail, as they do at main (3 there, 2 here), where
  the sidebar isn't drawn (filed).

Broken by hand: navTopLands taken out (old code): all 8 sidebar cases red,
"providers: it settles with at most a little overshoot", 38.65-43.19px.

Not tried: the real Mac app; the reporter's screen recording never came
through, so the first report ("tab 切换动画错乱") is taken to be this same
bounce, not checked against their video.

Reported-by: 小李 (Discord)
2026-11-07 08:49:49 +08:00
yetone 24dc1651b0 sessions: Antigravity's conversations take their title from conversation_summaries.db
The Antigravity desktop app's Sessions tab read every row as "(no
prompt)". The app keeps its step payloads encrypted, and the reader only
read their metadata, so no title was ever found. The app's language
server (the same code as agy) writes a row per conversation into
~/.gemini/antigravity/conversation_summaries.db: title once one is made,
and preview (the first request) from the start. The app reader now reads
that row, the same way agy's reader does, with title as the session's
name and preview as its prompt, and reparses when the row changes.

Sibling, agy: a row-only conversation with no title yet (the real row on
this Mac, agy 1.4.12: title "", preview "hi") was not listed at all; it
now shows its preview. A summaries database made before preview was a
column is still read (falls back to title only). The rows cache is kept
per database, since both readers now read one each.

Run (mote): go test -tags nogui ./internal/sessions ./internal/usage ok;
GOOS=linux go vet -tags nogui and GOOS=windows go vet ./internal/sessions
ok; gofmt clean. DDL in the test is from Antigravity 2.29.0's
language_server, started in a sandbox HOME on mote, which created
conversation_summaries.db on first start.

Broken by hand: with the old agy.go, antigravity_app.go and sessions.go,
TestAntigravityAppTitle fails ("before a title: \"\", want the preview")
and TestAgyRowOnlyPreview finds no session. With the preview-less
fallback query removed, TestAgyRowsWithoutPreview fails (rows map[] ok
false).

Not tried: a real Antigravity app database with summary rows (this Mac's
app data has none to read, and its files were only read); app versions
older than 2.29.0, which may keep summaries in agyhub_summaries_proto.pb
instead. workspace_uris is not used as the app session's folder.

Reported-by: xxooioo (Discord)
2026-11-07 08:43:16 +08:00
yetone 42f78ba08e usage: WorkBuddy's credits a day count each pool, adding up to Total credits (yapechan)
yapechan on Discord (#feedback, 11-07, WorkBuddy China): the card's
"Credits used per day" read 今天 0 for 积分 and 额外积分 and 今天 34.06
for 积分合计, so the total wasn't the two pools' sum.

Since the plugin's 0.2.22/0.2.24 the card has both pools set aside,
Credits and Extra credits, and Total credits, the two together, as the
window that stops the account. noteDailyCredits takes a window set aside
for a counted window's breakdown when that window used at least as much
over the same span (the CodeArts rule, ec3111d87), and the total always
does, so both pools were marked Part and counted nothing; they still
showed because they had days from before 0.2.22. The card's figures
themselves (x / 500, y / 2900, x+y / 3400) were right; only the days were.

Now pools set aside that together grant what a counted window grants
(poolsOfWhole: two or more, same unit, limits summing to its limit) are
that whole's pools: each counts its own days beside the whole's, and is
shown even with none. A bucket that is only part of its whole (CodeArts'
基础积分 under 总积分) stays its breakdown. Both WorkBuddy builds send the
same shape, so workbuddy-ai is covered too. Days already counted can't be
split again: today's 34.06 stays on the total alone.

TestDailyCreditsPoolsOfWhole (new): the plugin's current card for
CN_FREE_SUMMARY's shape, the extra credits moving alone, then the plan's,
then both: Credits 20 + Extra credits 28 = Total credits 48; and a
CodeArts-like card with two buckets that don't make up its whole shows
总积分 alone.

Run at this head (origin/main 8e350155b) on mote: gofmt -l clean;
go test -count=1 ./internal/provider ok (115s); GOOS=linux and
GOOS=windows go vet -tags nogui ./internal/provider ok.
Broken by hand: the old credits_daily.go makes the new test red (Total
credits 48 alone); dropping the sum check makes its CodeArts half red
(基础积分 shown).

Not tried: yapechan's own readings or a real China account with extra
credits (the desktop's sign-in on this Mac gets 401 from the meter); no
GUI change, so no GUI run.

Reported-by: yapechan
2026-11-07 08:07:58 +08:00
yetone 8e350155b6 routing: a provider set to Use first goes ahead of the others Smart weighs it with
hzh_1119 on Discord: ChatGPT Pro and Business now come with monthly API
credit, and they want an OpenAI API key spent before the ChatGPT
subscription where both serve a model, the subscription taking over
after. Smart had no way to say so: an API key tells no allowance, so it
went after every account with room, in every model's found group
(auto/<model>). The only way round was a group set to In order with its
members dragged, one group at a time, which nothing pointed to.

A provider row's right-click has Use first (provider/usefirst,
provider.SetUseFirst, Provider.UseFirst, copied onto its accounts by
accountSettings, kept by the editor's Save). Its keys and accounts are
routes.Seat.Lead, and Smart (leadFirst) puts those not all but used up
ahead of every other seat, each side in Smart's own order. A resting one
is passed over as before, so a 429 insufficient_quota (out of credit) or
a failure moves the request on to the subscription. Off by default;
within one provider nothing changes. The Routing page says why the first
went first (Weighed.UseFirst, firstWhy) and doesn't call the one behind
it "renewing later" (behindWhy). The menu shows a tick when it is on.
Free quota by expiry orders its paid seats with Smart and so follows it;
other strategies don't read it. The core's script budget is met by
cutting three Providers-page comments in app.js, no raise.

Run (on mote via mote-run, at da548b454 = origin/main):
- go test ./internal/routes ./internal/provider: ok. ./internal/gui: ok
  but TestMainWindowCorners/macOS_26_SDK, red the same on a fresh
  origin/main da548b454 checkout (#3949, macOS 27).
- go test -run 'TestUseFirstLeadsTheGroup|TestRoutingGroups'
  ./internal/gateway: ok.
- node --test use-first.test.cjs (new: 40 cases, Chromium and WebKit,
  1100 and 420 wide, en zh zh-TW ja de) and provider-find.test.cjs
  (its menu now lists Use first): 52 pass.
- i18n-keys, i18n-en-no-cjk, routing-behind-why: pass but i18n-keys'
  "a plugin's words are its own", red the same on origin/main
  (#5327, #5426, #5482; none of its keys are this change's).
- GOOS=linux and GOOS=windows go vet -tags nogui ./...: ok. gofmt -l: none.

Broken by hand:
- Lead left out of weighRouted's seat: TestUseFirstLeadsTheGroup red
  (served from ksub with api set to Use first).
- Smart without leadFirst: TestSmartLeadFirst red
  ([plus pro api ...], want api first).
- firstWhy's Use first case off: use-first.test.cjs's Routing cases red
  in every language.

Not tried: a real ChatGPT account beside a real OpenAI key with API
credit; the 429 insufficient_quota fallthrough is from the fake
vendor's body (carriedQuotaBody). The full suite runs after the push.

Reported-by: hzh_1119
2026-11-07 07:15:40 +08:00
yetone da548b4548 codex: a reset about to expire can be used from 3 minutes before, or after any minutes typed (Custom…)
shangyuan0818 asked again, and the coordinator agreed: magpie runs the
whole time, a reset's expiry is known to the second, and a user who is
worried can pick a long lead. So the menu ends with Custom…, and the
floor is now what the gateway needs, not 15 or 5 minutes.

- settings: CodexResetLeadLeast 5 -> 3; the presets start at 3. The CLI
  (magpie quota reset-lead) and settings/codex-reset-lead check the same
  constant. Saved values stay valid: everything from 5 to 1440 still is.
- Why 3: since v0.1.3204 the loop wakes at the lead's start (timer, at
  most 1s late), a try is bounded by the pass's 2 minutes, and a failure
  in the last 15 minutes is tried again a minute after it began, at once
  when that has passed. At 3 minutes a try hung to its bound ends at
  T-0:57 and a retry starts at T-0:56. At 2 minutes a hung try leaves no
  retry before expiry.
- GUI (autoresetown.js): Custom…, the menu's last item, puts a field of
  minutes where the button was, at the button's size, so the row doesn't
  rewrap. Enter or leaving it saves. Escape keeps the lead. A number
  outside 3 to 1440 is shown as an error and not written. A redraw
  leaves the field alone while it is open. It uses the app menu and no
  native select. There is one new string, in all five languages.

Tests:
- TestShortLeadSpentInTime: at the least lead, for four phases, the
  reset is spent at T-3:00, and after a 2-minute hung try plus a 30s
  retry it is spent before expiry.
- TestQuotaResetLeadCmd: 3m is taken and 2m is refused.
- codex-reset-lead.test.cjs: 12 items, picking 3 min, and Custom… in
  every language at 1100 and 420. Typing 7 and pressing Enter posts 7.
  Typing 2 is said and not posted. Escape posts nothing, and leaving the
  field posts 12. Opening the field moves no page.

Run on mote at this tree:
- go test of the reset-lead, short-lead, reset-loop, expiring and
  quota-reset tests in provider, cli and settings: ok.
- go vet: darwin, linux -tags nogui and windows on provider, settings
  and cli, plus darwin on gui: ok.
- go test ./internal/gui: TestCoreScriptBudget ok with no raise (the
  field lives in the lazy autoresetown.js). TestMainWindowCorners is red,
  as in #3949.
- GUI codex-reset-lead, codex-auto-reset-settings and i18n-keys in
  Chromium and WebKit: 49/50. The red is i18n-keys "a plugin's words are
  its own", filed as #5327, #5332, #5426 and #5482. Before the last
  comment trims, codex-reset-lead, codex-auto-reset-settings and
  providers-reset-use passed 86/86.

Broken by hand, each red:
- Floor at 2: the least-lead hung case goes red (one try, no retry), and
  so does the CLI (2m taken).
- Floor at 5: the CLI refuses 3m.
- The GUI range check removed: "2 isn't posted".
- Escape saving: "Escape posts nothing".
- The field at its own size (76x27) instead of the button's: WebKit ja
  and de at 1100 move the page 1px.

Not tried: a real ChatGPT reset spent at 3 minutes, since none of my
accounts has a reset about to expire. The redraw guard has no test of
its own, because a click elsewhere blurs the field and saves first.

Reported-by: shangyuan0818 (Discord)
2026-11-07 06:39:39 +08:00
yetone 5f01b9d052 agent tests: the WSL probe test has a timeout(1) where macOS has none (#5570)
TestWSLProbeLooksPastWindowsCommand runs the distro probe in the host's
/bin/sh, and the probe asks a command's version under `timeout 10`.
A distro has timeout (coreutils); macOS 26.2 has none (mote's macOS
27.2 has one), so the ver: line was "sh: timeout: command not found", no version,
and the test was red on every macos-latest run since it landed in
f9a88c4fb (42279775186, 42285312651, 42292490462, 42295916081), not
intermittently. The probe itself is right. The test now puts a stand-in
timeout on PATH when /usr/bin/timeout is missing, and its failure prints
the probe's output.

Run (mote, macOS 27): go test -count=3 -run TestWSLProbe ./internal/agent,
ok, with the injection below and the stand-in renamed to match.
Broken by hand: mote has /usr/bin/timeout, so the probe's `timeout 10`
was renamed `timeoutx 10` in the test: with no stand-in it is red as on
CI (Has bin:pi, Versions empty; out shows "timeoutx: command not
found"), green with the stand-in.
Not tried: a macos-latest (macOS 26) runner itself; this Mac is 26.2 and
has no /usr/bin/timeout, which is the cause.

Fixes #5570
2026-11-07 06:13:32 +08:00
yetone d88fc64715 gateway tests: big compaction bodies aren't held to the 30s unrouted stop (#5571)
TestCompactionOverByteCapSlowFitting (and its siblings through cappedOn)
send bodies up to 42MB. magpie's work on one before its first route takes
~0.6s, ~9s under -race on a loaded Mac, and on a loaded ubuntu runner
under -race past unroutedUnknown's 30s: the request was stopped with 504
"held this request for 30s without routing" after 65s of test, the CI
goroutine dump in parseRequest. Not a product bug: without -race the
same work is well under a second. cappedOn now lifts the two unrouted
limits for these tests (unknownLimit, unroutedLimits, restored at
cleanup); the hold's own tests are in unrouted_test.go.

Run (mote): go test -race -run 'TestCompaction|TestTurnOverByteCap|
TestOverByteCap|TestByteCap|TestWithoutOldImages|TestCodexCompact|
TestDeepSeekByteCap|TestUnrouted|TestBrowser' ./internal/gateway, ok.
Broken by hand: a 31s sleep at the start of codexCompact turns the old
test red with CI's 504 (33.2s); with this change and the same sleep it
is green (67.8s).
Not tried: an ubuntu runner under -race itself.

Fixes #5571
2026-11-07 06:13:32 +08:00
yetone 589680bc4c gateway: a browser's key watch takes its interval as the browser connects (#5569)
watchKey read the package var browserKeyCheck on its own goroutine, with
nothing ordering that read before TestBrowserKeyOffClosesItsBrowser's
later write (browser_key_test.go:210): under -race on a loaded runner
the goroutine was still starting when the test set 20ms, a DATA RACE.
The handler now reads it and hands it over, before s.browser.add, whose
lock the test's count() takes, so the test's write is ordered after it.
Behaviour is unchanged: the interval is the same value, read earlier.

Run (mote): go test -race -run TestBrowserKey ./internal/gateway, ok;
go vet darwin, GOOS=linux -tags nogui and GOOS=windows on the package.
Broken by hand: with a 300ms sleep at the start of watchKey, the old
code is red, DATA RACE at browser.go:422 against browser_key_test.go:210
(the CI trace); the fix with the same sleep is green, -count=3.
Not tried: a real browser extension (the interval it uses is unchanged).

Fixes #5569
2026-11-07 06:13:32 +08:00
yetone e484b4ff26 update: a slow download still moving is never ended by a total time; Bun, Claude Code and pf-serve too
#5572: since 80a47abba a silent download is broken off after 30s and
tried again, but the update's download still had a 10-minute total
(the update client's Timeout, the GUI run's ctx, `magpie update`'s ctx).
A download under ~140 KB/s, still receiving bytes, failed the 83 MB
Windows exe at 10 minutes part way. The stall timer is what ends a dead
one now; nothing ends one that is still moving.

- internal/update: fetch downloads through fileClient, the client without
  its Timeout. The feed and notes keep the 10-minute client. fetch's stall
  timer runs from the ask to the last byte, so a server that never answers
  still ends at stallAfter (30s), and download's retries stay bounded
  (len(retryWaits)+1 = 6 tries), so a connection that keeps going silent
  ends in about 4 minutes.
- internal/gui (Mac Stage, Windows/Linux StageBinary): run's 10 minutes
  (checkWait, a var for tests) bound only LatestIn; the download runs
  under a ctx with no deadline.
- internal/cli `magpie update` (Mac Stage, Windows/Linux ReplaceBinary):
  the same split.
- Siblings with the same fixed cap:
  - new internal/stall: Start(ctx, after) gives a ctx that ends with
    ErrStalled once `after` goes by with no byte read through w.Reader.
  - Bun (internal/plugin getURLOnce): watched with a 60s stall;
    KeepBunUpdated's 10-minute ctx around CheckBun is gone.
  - Claude Code (internal/claudecode downloadOnce, ~200 MB): watched with
    a 60s stall; keepOnce's 30-minute ctx around install is gone.
  - pf-serve (internal/pii upgrade): its 10-minute ctx is gone; get
    already had a 60s stall and the client a 60s header timeout, as the
    model's download (no total) does.
- Left as they are: plugin installs and npm updates (KeepUpdated's 10
  minutes) run `bun install`, whose network is Bun's own, small tarballs;
  rtk (5 min client), skills (2 min client), skilltree and market reads
  are small files; Grok CLI install has no cap of its own (its caller's
  ctx). None of them carries a large download behind a wall-clock total.

Run on mote (mote-run), at 49f207c78 + this change; the targeted
set again after rebasing on d4a221f79 (ok):
- go test ./internal/stall ./internal/update ./internal/claudecode
  ./internal/pii -run 'Stall|Slow|Silen|TestDownload|TestInstall|TestKeep';
  go test ./internal/plugin -run Bun; go test ./internal/gui -run
  TestUpdate: ok
- new: TestSlowButMovingIsReadWhole, TestSilenceIsAStall (no answer, part
  way), TestDownloadSlowButMovingOutlastsTheClientTimeout (client Timeout
  300ms, body ~1.2s: one try, no retry), TestUpdateSlowDownloadOutlastsTheCheckBound
  (checkWait 200ms, body ~600ms: ready), TestDownloadThatGoesSilentIsAStall
  (claudecode), TestBunDownloadThatGoesSilentIsAStall. The silent server
  after its retries stays covered by TestDownloadStallEveryTimeSaysSo
  (6 tries, errStalled).
- go test -race -count=3 ./internal/stall ./internal/update -run
  'Stall|Slow|Silen': ok
- win-run (Windows 11): ./internal/stall ./internal/update
  ./internal/claudecode ./internal/plugin with the same -run, and
  ./internal/gui -run 'TestUpdateSlowDownload|TestUpdateDownloadSaysStepAndSpeed': ok
- wsl-run (Ubuntu 24.04), -tags nogui: the same packages and ./internal/gui
  -run TestUpdate: ok
- gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; go build; GOOS=linux go build -tags nogui;
  GOOS=windows go build: clean
- Full suite: run after the push under the suite lock.

Broken by hand: fetch back on `client` fails
TestDownloadSlowButMovingOutlastsTheClientTimeout ("broke off ...
Client.Timeout or context cancellation while reading body"); the GUI's
download back under the check's ctx fails
TestUpdateSlowDownloadOutlastsTheCheckBound (state error, "context
deadline exceeded"); stall's reader not putting the timer off fails
TestSlowButMovingIsReadWhole (50 of 120 bytes); Bun's and Claude Code's
downloads unwatched fail their silent tests at the 20s bound ("context
deadline exceeded").

Not tried: a real update over a slow or throttled link, on any OS; a real
Bun or Claude Code download over one. The Mac's unpack and signature
check now run with no deadline (they had the 10 minutes before).

Fixes #5572
2026-11-07 06:09:42 +08:00
yetone d4a221f79c codex: a reset about to expire can be used 5 or 10 minutes before it does
shangyuan0818 on Discord asked for leads under 15 minutes (1, 3, 5, 10, or
free seconds) for Codex's auto-use of the reset about to expire, to use
more of the windows first. The shortest was 15m because the gateway only
looked every 5 minutes after a pass ended (a pass is bounded at 2
minutes), so the gap between looks could reach ~7 minutes. With a 5-minute
lead, the reset could run out before any look landed inside it.

- provider: a look lands on the lead's start (nextResetLook takes the
  sooner of +5m and until-lead), and the loop sleeps until the soonest look
  due among the accounts its pass went over (expiringResets.wake: 5m at
  most, 1s at least; an account the pass skipped wakes nothing). A read or
  spend that fails inside the lead in the last 15 minutes is tried again
  in 1 minute (retryResetLook), not 5; a long lead failing earlier keeps
  the 5-minute cadence. A retry that came due while a hung pass ran is
  made at once.
- settings: CodexResetLeadLeast 15 -> 5; choices 5m, 10m, 15m, 30m (default),
  1h ... 24h. Saved values from 15 to 1440 stay valid; the default is
  unchanged.
- GUI (app.js RESET_LEADS, resetLeadMinutes) and CLI (magpie quota
  auto-reset lead) follow the same range. No new strings ("{n} min"
  already exists). Still the app menu, no seconds field.

Why 5 and not 3 or 1: in the worst case a try hangs to the pass's 2-minute
bound. At 5m: try at T-5:00, hung until T-2:57, retried at T-2:56, so two
tries before expiry (four when ChatGPT refuses at once). At 3m a hung try
leaves no retry. At 1m one try cannot even run to its own bound, and
local-vs-server clock skew eats the rest.

Run (mote, via mote-run, at base 49f207c78):
- go test -run 'Reset|Expir|Lead' ./internal/provider ./internal/settings
  ./internal/cli: ok. New: TestShortLeadSpentInTime (5m lead at four loop
  phases: spent at T-5 within 5s; a 2-minute hung try then a retry before
  T-1m; four quick failures, all before expiry; a 7m CLI lead lands on
  T-7; a 6h lead failing all along makes 70 to 90 tries, not ~360),
  TestResetLoopWakesForTheSoonestLook.
- go vet: darwin (provider, settings, cli, gui), GOOS=linux -tags nogui,
  GOOS=windows. go test ./internal/settings ./internal/settingsapi: ok.
  ./internal/gui: ok but TestMainWindowCorners/macOS_26_SDK (#3949) and
  TestPanelHiddenByWailsMarksPageOutOfSight (#5322), AppKit window tests
  red on mote's macOS 27, both filed; the size budgets pass.
- GUI: codex-reset-lead.test.cjs (now also picks 5 min and checks the
  10-item menu), codex-auto-reset-settings, i18n-keys; Chromium and
  WebKit, en/zh/zh-TW/ja/de, 1100 and 420 px: 49/50. The one red is
  i18n-keys "a plugin's words are its own", red on main and filed
  (#5327, #5332, #5426, #5482); nothing here touches those files.

Broken by hand, each went red:
- the look not landing on the lead's start: TestShortLeadSpentInTime's
  7m case (spent 4m59s before).
- wake fixed at 5m: TestShortLeadSpentInTime, TestResetLoopWakes...
- the 1-minute retry turned into nextResetLook: the hung-try case.
- CodexResetLeadLeast back at 15: TestShortLeadSpentInTime,
  TestQuotaResetLeadCmd.

Not tried: a real Codex account spending a card at a 5m lead; a Mac
asleep across the lead (no lead can help there, same as before); the
3-minute delay after start is unchanged, so a magpie started within the
lead spends at its first pass; Windows and Linux runs (vet only).

Reported-by: shangyuan0818 (Discord)
2026-11-07 06:07:03 +08:00
yetone 49f207c784 agents: DS Bot, wired in the DSH home it runs on
DS Bot (github.com/Fei2411/DS-Bot, Apache-2.0, dsbot.app) is a DSH plugin
and an Electron app built on it. The app ships its own DSH (0.2.2-rc.1 in
0.3.0) and runs it with DSH_HOME at a data folder of its own, booting the
profile ds-bot, and never reads ~/.dsh: magpie's dsh row didn't reach it.

It is a row of its own now, ds-bot (dsbot.go), wired by dsh's code on its
folder (dshOn, split out of dshAt): magpie's routes and start in
profiles/ds-bot/cordis.patch.yml, the key in that folder's .env and
.credentials.yaml. The folder is $DS_BOT_HOME, else locations.json's
dataDir in the app's userData ($DS_BOT_SHELL_DATA, else <config>/DS Bot,
or the legacy DeepSeek Bot), else ~/.ds-bot, as the app's first-run.mjs and
legacy.mjs choose it. A locations.json that can't be read or names no
folder is unknown: nothing is read or written. The routes there list the
models shown for DS Bot on the Agents page (dshListFor), and the serving
round fills a profile the app makes there as it does ~/.dsh's
(dshHomesRounds). Found by DS Bot.app (io.github.fei2411.dsbot) or its
Windows per-user install (guid from its electron-builder.yml). Three
notices, translated into zh, zh-TW, ja and de. DS_BOT_HOME and
DS_BOT_SHELL_DATA are in agentenv's sandbox list.

Run:
- go test ./internal/agent/ ./internal/agentenv/ ./internal/gui/
  ./internal/cli/ ./internal/appdir/ on mote: ok but
  internal/gui TestMainWindowCorners/macOS_26_SDK, red on mote's macOS 27
  whatever the change (#3949).
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./... on mote: ok. gofmt -l: clean.
- node --test i18n-keys, i18n-en-no-cjk, agent-notice-lang (chromium), and
  agent-notice-lang in webkit: all pass but i18n-keys "a plugin's words
  are its own", red on main for three plugin words (#5332, #5426, #5482).
- Real DS Bot 0.3.0 (DS-Bot-0.3.0-mac-arm64.zip) on mote, all in a sandbox
  HOME with DS_BOT_HOME, DS_BOT_SHELL_DATA and DS_BOT_WORKSPACE under it:
  a magpie built from this tree (nogui), MAGPIE_ADDR 127.0.0.1:3572, a
  fake OpenAI upstream on 3571 added as a provider. `magpie ds-bot
  magpie/fake/m1` before the app was ever opened wrote the profile; the
  app's first start kept it (agent-default-model still magpie's) and added
  its own files beside it. Its Chief Bot offered "Magpie: m1 · fake, m2 ·
  fake"; picking m1 and sending "ping" over CDP went through magpie to the
  fake (POST /v1/chat/completions model m1, stream) and "pong from fake"
  showed. `magpie ds-bot default` then took every magpie entry out and the
  .env with it. Only my own pids (app, serve, fake) were stopped.

Broken by hand, each red, then put back:
- dsbot's desktopApps entry out: TestDsBotWired (not detected).
- dshListFor always "dsh": TestDsBotOwnModels.
- dshHomesRounds without DS Bot's home: TestDsBotProfileMadeWhileServing.
- a bad locations.json taken for ~/.ds-bot: TestDsBotDataFolder.
On the old code the tests don't build (no ds-bot row at all).

Not tried: the Windows app (install path and registry guid read from its
electron-builder.yml, not from an installed copy); Linux (its AppImage and
deb aren't looked for; the data folder its first start makes finds it);
a real vendor behind magpie; a default Bot model set in DS Bot (the notice
says it wins, per its models.js). Not done: usage gives DS Bot no
User-Agent of its own (its DSH's requests likely count as dsh's), and the
Sessions page doesn't read its data folder's sessions.

Reported-by: rnhung
2026-11-07 05:43:04 +08:00
yetone 9ed0f1fa49 agents: Claude Code's prompt cache lifetime is picked in its settings
Linka (Discord) asked to set Claude Code's prompt cache TTL from magpie.
Until now only Usage › Context's "Tuned for you" card wrote it, and that
card offers nothing when the value is already the cheapest it found.

Claude Code's opened row and settings sheet now have two rows under its
own Long conversations: "Prompt cache · main conversation" and "Prompt
cache · subagents". Each opens the app menu with Claude Code's default,
5 min and 1 hour. They write the keys the card writes, promptCacheTtl and
subagentPromptCacheTtl in Claude Code's settings.json
(agent.ClaudeCacheSet, POST /api/settings/claude-cache). Default takes
the key out. A pick is the user's own: it forgets the card's stash, so
the card's Undo leaves it. A variable that comes before the setting
(FORCE_PROMPT_CACHING_5M, CLAUDE_CODE_PROMPT_CACHE_TTL,
CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL, in settings.json's env or
magpie's own) disables the row and names the variable, and the route
refuses it, so a value the user set by hand is never written over.

The names were checked in Claude Code 2.1.316's binary. Its resolver
checks FORCE_PROMPT_CACHING_5M, then the env var, then the setting
(enum "5m"/"1h"), then an agent's experimental.cacheTtl, then
ENABLE_PROMPT_CACHING_1H. With nothing set, the main conversation gets
1h on a subscription within its limits and subagents get 5m.

Run (mote, at this tree on 2ce44dc28):
- go test -count=1 -run 'TestClaudeCache|TestTune' ./internal/agent
  ./internal/gui: ok; go test ./internal/cli: ok (route parity).
- node --test claude-cache.test.cjs: 8/8 (Chromium and WebKit, en and
  zh, 900 and 420px), with agent-compact, i18n-*, gui-ja/zh-tw/de,
  old-webkit, agent-details-ready and context-tune: ok.
- Whole GUI suite on the Linux VM (wsl-run, concurrency 4), still
  running at commit: 74 files red there, mostly WebKitGTK. Of those
  only codex-memories-settings reaches Claude Code's settings: it
  counted Claude Code's rows as Long conversations alone, and now
  leaves out the two cache rows and checks they are there (18/18 on
  mote). desktop-subagent-model, account-eye, allow-ips and builtins
  pass alone on mote. codex-auto-reset (webkit de, #4790) and
  i18n-keys (#5327, #5332, #5426, #5482) fail the same way at
  origin/main f0620db63 on mote.
- go test ./internal/gui ./internal/agent ./internal/tune: agent and
  tune ok; gui red only in TestMainWindowCorners/macOS_26_SDK (#3949).
- gofmt -l: clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build ./...: ok.

Broken by hand:
- Without forget, TestClaudeCacheSet fails ("the pick is the user's,
  not the card's").
- Without the lock check, it fails ("set under
  CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL").
- With default leaving the key, TestClaudeCacheSet and
  TestClaudeCacheRoute fail.
- Without the rows in agentcompact.js, claude-cache.test.cjs fails 8/8.
  Without the same-pick check, it fails on the extra post.
- The first GUI run was red in WebKit at 420px: Playwright's own
  scroll to an off-screen button was taken as the page scrolling. The
  test now wheels the rows into sight as a reader does, and checks they
  came into view.

Not tried: a real Claude Code session reading the picked value (only
the settings.json it reads was checked); the live ~/.claude was never
touched.

Reported-by: Linka
2026-11-07 05:16:53 +08:00
yetone 80a47abba8 update: a download says its speed and each step after it, and a silent connection is tried again (esir_tech)
esir_tech on Discord: after clicking Update the progress sat on 17% and
looked stuck. Cause: nothing watched a download that stopped sending. A
connection GitHub's asset host keeps open but silent (seen from some
networks) held the percent still until the client's 10-minute timeout,
then failed. The waits between retries showed the same still percent, and
after the bytes the Mac's unpack and codesign check showed a stale 100%.

- internal/update: fetch cancels a body that sends nothing for 30s
  (stallAfter) as a network error, so download's existing retry resumes it
  with Range. A step callback (update.WithStep) names download, retry,
  verify, unpack and signature.
- internal/gui: /api/update's downloading answer carries step, and speed
  (bytes/s over the last ~5s; it falls to 0 when bytes stop).
- app.js: the pill says "Downloading… 50% · 1.5 MB/s", "Reconnecting…",
  then "Verifying…", "Unpacking…", "Checking signature…"; its tooltip
  carries the text where the tight header hides it. Settings' Version row
  says the same after its MB count. i18n in zh, zh-TW, ja, de. Comments
  cut to stay under the core script budget (not raised).

Run on mote (mote-run):
- go test ./internal/update ./internal/gui -run 'TestDownload|TestUpdate|TestStage|Budget': ok
- new: TestDownloadStallIsTriedAgain, TestDownloadStallEveryTimeSaysSo,
  TestUpdateDownloadSaysStepAndSpeed, TestUpdateSpeedFallsWhenStalled
- GUI, chromium and webkit: update-download-steps (new: en, zh, zh-TW, ja,
  de at 900 and 420px), update-download-percent, update-download,
  update-row-steady, update-stuck, update-network, update-mirror: 178 pass
- i18n-en-no-cjk, header-relang: pass. i18n-keys "a plugin's words are
  its own" is red on origin/main 0d70f335e too (plugins/library,
  routing, usage i18n.js vs Go strings), untouched here.
- gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...: clean

Broken by hand: with the idle timer a no-op, TestDownloadStallIsTriedAgain
and TestDownloadStallEveryTimeSaysSo fail at their 20s bound (context
deadline exceeded); with speed left out of the answer
TestUpdateDownloadSaysStepAndSpeed fails ("never said how fast"); on the
old app.js/i18n.js update-download-steps fails in every case.

Not tried: a real update on a stalling network, a real Mac unpack and
codesign step (tests cover download/verify only), Windows/Linux runs.
The 10-minute total cap (client Timeout, GUI run ctx, CLI update) is
unchanged, so a moving download slower than ~140KB/s for the 83MB
Windows exe still fails at 10 minutes.

Reported-by: esir_tech
2026-11-07 05:02:02 +08:00
yetone 0d70f335ec agent: the disconnect preview of a plugin's agent shows what it puts back, not nothing (plugins#799)
Purfeather found that disconnecting MiniMax Design (an agent a plugin adds)
showed the dialog's generic sentence: /api/agents/.../disconnect-preview
returned changes: []. The preview runs Disconnect in a process whose HOME
(and APPDATA, LOCALAPPDATA, XDG_*) is a temporary copy, but a plugin agent's
stash key is "plugin:<id>:" + the file's whole path, so the copied
stash.json named the file under the real home. The dry run found no stash,
read the agent as not on magpie, and changed nothing.

The same holds for every built-in whose stash key carries its file's path
(Droid, AtomCode, Cline, Qwen, Kimi, Zed, Hermes, Muse, Snow, ...): their
previews found the file wired but not what to put back, and showed magpie's
lines taken out instead of the user's model going back.

The fix is in one place, DisconnectPreview: after copying magpie's files it
rewrites the copy's stash so each key naming a path under home names it
under the copy's home (moveStashKeys/movedKey; a separator must follow
home, and Windows compares without case, since %APPDATA% can spell the
home folder otherwise). The real stash, its key format and the real
connect/disconnect are unchanged, so stashes users already have keep
working and nothing is migrated. A stash that is missing or doesn't parse
is left as it is.

Run at this head (30a0bfe88 + this commit; origin/main had not moved):
- mote: go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
  go vet ./...: clean. gofmt -l: nothing.
- mote: go test -tags nogui -timeout 45m ./...: 87 packages ok, exit 0
  (internal/agent 381s).
- xiaomi-gpu (Windows): go test -tags nogui -run
  'TestDisconnectPreview|TestMovedKey' ./internal/agent: ok, the four new
  tests PASS (the case-insensitive branch runs there only).
- mote GUI files that show the preview (agent-changes-before-now,
  agent-disconnect-preview, agent-leave-magpie, agent-own-direct,
  aside-native, mask-actions): Chromium 60/60, WebKit 34/34.

Broken by hand: with the key rewrite skipped, TestDisconnectPreviewOfAPluginAgent
fails with "the preview doesn't take magpie's entry out: []" (the
reporter's exact empty list), TestDisconnectPreviewOfAPluginAgentsModel
and TestDisconnectPreviewOfDroidPutsItsModelBack fail with no "~" line
putting the user's model back. Restored: all pass.

Not tried: a real MiniMax Design on Windows, or the GUI dialog against a
real magpie; the tests run the real preview path (this test binary as the
dry run's process) with the plugin's agent module as plugins#799 has it.
Paths stored in stash values (not keys) are not rewritten; none of the
values read in a disconnect hold a whole path.

Reported-by: Purfeather
2026-11-07 04:55:56 +08:00