Commit Graph
3181 Commits
Author SHA1 Message Date
yetone f230fa23b0 plugin tests: TestPiPackage runs on a pi pinned by a bun.lock, not npm's latest that minute (#1879)
TestPiPackage installed pi the way ensurePi does, `bun add
@earendil-works/pi-coding-agent` at npm's latest, so it ran on whatever
pi's packages were that minute. pi-codemode 1.2.0 (2026-10-12 23:00:01Z)
dropped MCP_TYPESCRIPT_PREAMBLE and mcpStructuredContentSchema, which
pi-coding-agent 1.0.x and 1.1.0 import from it; their ^1.x range takes
1.2.0. pi-coding-agent 1.2.0 (no longer importing them) came out at
23:03:25Z. A full run that reached TestPiPackage in between got
pi-coding-agent 1.1.0 + pi-codemode 1.2.0 and pi didn't load; the run
alone came after. Nothing is shared between tests here (each has its
own plugins folder, and bunCommand puts Bun's cache under the test's
HOME), so "only in the full run" was the clock, not the suite.

The test now writes testdata/pi-lock's package.json and bun.lock (pi
1.2.0, every package at its npm integrity) into the plugins folder and
runs `bun install --frozen-lockfile`; Add then finds pi there. The
"pi is installed with a pi package" half moves to TestEnsurePi, with bun
stubbed: installed once for a pi package, not again with pi there, not
for an OpenCode plugin. The BUN_INSTALL_CACHE_DIR the test set did
nothing (bunCommand sets its own after it) and is gone.

Users: magpie installs pi at latest (1.2.0 with 1.2.0 now), and bun
keeps a plugins folder's lock when other plugins are added, so a folder
installed before the 1.2.0 release keeps 1.1.0 with 1.1.0. Only a pi
install that resolved in those ~3-8 minutes (CDN metadata cache) got the
broken pair. No magpie change.

Run:
- with the lock swapped for pi-coding-agent 1.1.0 (codemode resolved to
  1.2.0): TestPiPackage fails with the issue's exact "Export named
  'MCP_TYPESCRIPT_PREAMBLE' not found"; with 1.1.0 + codemode 1.1.0 and
  with the 1.2.0 lock committed it passes
- TestEnsurePi fails with ensurePi's "pi is there" check removed
- go test ./internal/plugin/ -count=1 three times: ok (140s, 121s, 112s)
- go test ./internal/plugin/ -run 'TestPiPackage|TestEnsurePi' -count=5: ok
- go test -tags nogui ./internal/...: ok
- gofmt -l; go vet darwin, linux -tags nogui, windows: clean
2026-10-13 07:39:46 +08:00
yetone 1502433978 gui: a key's value can be changed in place, keeping its name, place and settings, and its rest is lifted (#1869)
A key rotated at its vendor had to be removed and added again, which
lost its name, its place in the order, its weight, protocol, models,
proxy and concurrency, and any gateway key restricted to it. As decided
on #1869, in multi-key mode the row now has a Change key action, with a
double-click on the row as a shortcut.

- provider.ReplaceKey(id, ref, key) sets the key's new value and moves
  what providers.json keys by the key's fingerprint (AccountModels,
  AccountProxies, AccountConcurrency) to the new one. An empty value, an
  unknown key and a value another key of the provider already holds are
  refused. The same value is a no-op.
- access.ReplaceAccount moves gateway keys' Accounts entries from
  provider/old to provider/new, under the caller-keys lock.
- gateway.Server.UnrestAll lifts a rest key and every per-model rest
  under it. The GUI's keys/replace lifts the key's rest (provider#key, and
  the provider's own rest key when it is the only key on), so the new
  value is asked from the next request.
- app.js: a pencil beside the key's copy button opens a password field in
  place of the masked value. Enter saves, Escape leaves it, and a
  double-click on the row away from its controls opens it too. The button
  has its own class (.key-edit) with the copy button's look.
- i18n: four strings in zh, zh-TW, ja and de.
- providers-accounts.md: ReplaceKey in the Keys table.

Past requests keep the old fingerprint in history, under the same name.
A rest is lifted only in the gateway this magpie serves.

Run:
- go test ./internal/gateway ./internal/provider ./internal/access
  ./internal/gui -count=1: ok. New TestReplaceKeyKeepsItsPlace,
  TestKeysReplaceKeepsTheKeyAndLiftsItsRest and
  TestUnrestAllLiftsAKeysModels each fail with their change taken out.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows.
- key-replace.test.cjs (new): en/zh/zh-TW/ja/de, chromium and webkit,
  1100 and 420px. Checks the post, order, note, no sideways scroll, and
  no scroll on change or on double-click plus Escape.
- With key-copy, rest-try-now and key-import: 96/96.
- 72 key*/routing*/rest* GUI files at concurrency 6: 863/871. The 8 reds
  were key-copy, whose button.copy locator matched the pencil; that's why
  it has its own class now, and key-copy passes.
- Under load, about one run in 300 saw the editor body go back to the top
  after the copy button's double-click, with no script scrolling it. That
  is #1504 (findings added there). The test checks scroll before that
  step.
2026-10-13 07:30:06 +08:00
yetone b88684096c gui: a resting key's note and Try now take a line of their own, so the row's buttons stay in reach (#1869)
In a provider's list of several keys, a resting key's row held the
"resting · back at …" note on the same line as its switch, name, value,
weight, protocol, Remove and Make first. At 1100px the row ran past the
editor's edge and Remove and Make first could not be clicked, in German
already before 9ac763d2c and in every language once its Try now joined
the note.

- app.js: the note and Try now go in a .key-rest-line appended after the
  row's controls; the row is marked .resting.
- app.css: a resting row wraps, and its rest line takes the full width
  under the key's own line, lined up with the name; the note ellipsizes
  before Try now does.

Run: rest-try-now.test.cjs now hovers the key's row and asserts Remove
and Make first are hit by elementFromPoint at their centres, in
en/zh/zh-TW/ja/de, chromium and webkit, 1100 and 420px: 40/40 at this
commit; on the old app.js/app.css 30/40, the 10 reds being every
language and engine at 1100px.
2026-10-13 07:30:06 +08:00
yetone 85a82aff22 gui tests: routing-group-fold's rests run from when the test builds them, not from when the file loaded
The fixture's rests ended 3 minutes after the module loaded. Under load
(71 files at --test-concurrency=6) the webkit half ran later than that,
so p2 and p3 were no longer resting and "6 available · 2 resting" read
"8 available" (3 webkit languages red). The page is told the time of
each poll, so the rest had simply expired.

Run: with the file's `now` moved 4 minutes back to inject the delay,
webkit was 15/20 before and 20/20 after; the file alone, both engines,
40/40.
2026-10-13 07:30:06 +08:00
yetone fd907c986e gui: every resting key or account can be tried again by hand, on Routing and in the provider's key list (#1869)
A key resting after a 429 with a long Retry-After (a relay's 3600s) came
back only by waiting or a restart, though relays often recover in a
minute or two. The Routing page offered the lift (/api/gateway/unrest,
which already takes any rest key) only to verify and restricted rests.

- routing.js: every resting row with a rest key gets the button: "Try
  now" for quota, rate, retry-after and backoff rests, the old wording for
  verify and restricted. A lifted rest is remembered by key and the time
  it was lifted (liftedAt), so the history re-render, which reuses the
  try's rest, doesn't show it again; a newer rest still shows.
- app.js: "Try now" beside the "resting · back at …" note in a
  provider's key list, posting the key's own rest key; not hover-only.
- i18n: the three new strings in zh, zh-TW, ja and de.
- gateway-routing.md: any rest can be lifted; only the rest ends, the
  backoff count stays.

Run: rest-try-now.test.cjs (new: Routing row with the issue's zx
retry-after rest, key list row; en/zh/zh-TW/ja/de, chromium and webkit,
1100 and 420px; asserts the post, the note gone, no sideways scroll,
reached by wheel, the click doesn't scroll) 40/40, red on the old
app.js/routing.js. 71 key*/routing*/rest* GUI files at concurrency 6:
826/831; the 5 reds (key-balance-card, routing-group-fold) pass alone
and are timing under load (routing-group-fold fixed in the next commit).
go test ./internal/gui passes.
2026-10-13 07:30:06 +08:00
yetone a68d2ac944 gateway: a held stream lets through only text, reasoning or a call, so a 200 that only framed a reply fails over (#1418)
Aliceonly's trace on #1418: sub2api answered 502 "Upstream HTTP/2 stream
failed", then Codex account A answered 200, sent only the frames before a
reply, and failed server_is_overloaded 37s in. Five candidates after it
were never asked, and Codex ended the turn. The stream had been let
through (h.passing), so holdWriter.failed() was false and neither the next
candidate nor a replan was tried.

Two ways a frames-only stream went through:
- streamEvent's default was eventContent: any event it didn't know (and an
  item of a type said() didn't know) counted as the reply begun. Now only
  the events of each protocol that carry text, reasoning, a call or a
  reply's end (replyEvent) count; anything else is eventLead, held as a
  ping is. An unknown item counts only when it is a call or a tool's
  (web_search_call, server_tool_use, mcp_*). A stream that ends well is
  still released whole, so this can only delay, never drop, a reply.
- a reply under a Content-Type that says neither JSON nor a stream, once
  the agent had a stream's headers, went straight through when its first
  bytes were SSE (sseStart -> pass()). It is now held as a stream from
  there and read event by event.

Which event Codex's backend actually sent isn't in the trace; the test
uses a keepalive, response.rate_limits.updated and an unknown item type.

Run: go test ./internal/gateway -count=1, green (428s).
TestFramesThenOverloadedGoesToTheNext (new: 502, then 200 frames + unknown
events + server_is_overloaded, then a third member) and
TestStreamEventUnknownOnlyFrames (new) fail on the old fallback.go: the
overloaded stream reaches the agent and c is never asked.
TestHeldUnsureStreamPasses/KeptAlive now expect the stream held until its
first word, and TestHeldUnsureStreamFailsHeld (new) a failure among held
frames; all fail on the old code. Not tried against the real ChatGPT
backend.
2026-10-13 07:30:06 +08:00
yetone 4a6c81e038 gateway: a group's Patience is waited out in full, not cut at 90s by the round count (#1418)
A group asks its busy members again after pauses of 2s, 4s, 8s, 16s, then
30s, for as long as its Patience lasts, but replanRounds stopped it after
6 rounds: 90s of pauses whatever the group was set to. real-jacket's trace
on #1418 shows patience=240 with replan=6 and ~103s in all. replanRounds
is now 12, a backstop sized so that the pauses alone reach
PatienceLongest (240s) in 11 rounds, and the patience is what ends the
wait. It stays bound by kept.tooQuiet, as before. The longest pause is
now 30 x retryPause (30s in use), so the tests' 1ms retryPause doesn't
grow a 4s pause at round 12.

Run: TestPatienceIsUsedUp (new) counts replan's pauses for 30s to 240s of
patience, and TestReplanRoundsOutlastPatience (new) sums the backstop's
schedule. With replanRounds back at 6, both fail: patience 3m0s and 4m0s
pause 1m30s. go test ./internal/gateway -run
'Overload|Patience|Replan|WaitsOut|Busy|Codex' is green. Not tried
against a real overloaded vendor for 240s.
2026-10-13 07:30:06 +08:00
yetone 3b4063e75e gateway: a 400 for a tool schema past a model's nesting depth goes to the group's next member (#1870)
OpenCode Go answered Claude Code's MCP tools on muse-spark-1.3-contributor
with 400 "JSON schema exceeds the maximum nesting depth of 10 levels", and
group/intent-auto returned it to the agent instead of asking the next
member. shapeWords didn't know the wording, so shapeRefused was false and
the error ended the turn. It now matches "schema exceeds the maximum
(nesting) depth" and "schema ... nesting depth". The schema isn't
truncated, nothing rests, and plain parameter errors ("Field required",
"not a valid type") and a 200 that mentions the depth still don't fail
over.

Run: go test ./internal/gateway -run 'TestGroupFailsOver' -count=1, green.
With the new alternatives removed, TestGroupFailsOverARequestShape fails
on both depth bodies and TestGroupFailsOverASchemaTooDeep gets the 400
back with b never asked (a 1, b 0).
2026-10-13 07:30:06 +08:00
yetone 23c6e865a7 plugin: a musl Linux (Alpine) runs plugins on Bun's musl build, kept apart from the glibc one (#1877)
emptyteeth found it: bunTarget picked Bun's build from GOOS/GOARCH alone,
so Alpine got bun-linux-x64-baseline, a glibc build whose interpreter
(/lib64/ld-linux-x86-64.so.2) Alpine lacks. exec then said "fork/exec
…/bun/1.4.2/magpie-bun: no such file or directory", which reads as a
missing file, and no plugin could be added or run.

- bunTarget: a musl Linux gets bun-linux-x64-musl-baseline or
  bun-linux-aarch64-musl. The musl check moves out of internal/claudecode
  into internal/libc (libc.Musl, unchanged rule: Anthropic's installer's
  /lib/libc.musl-*.so.1), which claudecode, the plugin host and the CLI
  test that skipped on musl now share.
- bunSums: the two musl builds' checksums, checked against Bun v1.4.2's
  own SHASUMS256.txt (downloaded from the GitHub release; they match the
  issue's numbers).
- Cache: a musl Linux keeps its Buns and state.json under bun/musl, so a
  machine whose C library changed never runs the other build, nor takes
  its state, whose Bad may list versions only the glibc build failed
  (CheckBun on Alpine set aside every newer Bun). glibc, macOS and Windows
  stay in bun/<v>, so a Bun downloaded before is used as it is, with no
  new download.
- A bun on disk that exec can't start with ENOENT says it is a build for
  another C library and names MAGPIE_BUN (cantStart), for the host's start
  and for bun add/bun update. The same for a $MAGPIE_BUN.
- Bun's musl build needs libstdc++ and libgcc, which a bare Alpine lacks:
  the loader then prints "Error loading shared library libstdc++.so.6"
  above ~40 "Error relocating" lines, and bun add cut it off. bun add,
  bun update and a host that died starting now say which library is
  missing and `apk add libstdc++ libgcc` (missingLibs, whyDied).

Decided: a Bun that can't be started at all is not counted as crashed.
The fallback goes to the version before, which is the same build for
this system and fails the same way, and setting the current one aside
would mark a good version bad for good. The libc check happens before the
download instead (the target), so Alpine never fetches the glibc build.

Run:
- docker alpine:3.20 (arm64, and amd64 under emulation), sandbox HOME in
  the container, linux nogui builds. origin/main's binary reproduces the
  report: "bun add …: fork/exec /sbx/.cache/magpie/bun/1.4.2/magpie-bun:
  no such file or directory". This one on bare Alpine downloads
  bun/musl/1.4.2 and says "this system lacks libstdc++.so.6 … apk add
  libstdc++ libgcc"; after apk add, `magpie plugin add
  @magpie-community/opencode-cursor-auth` adds it and `plugin list` starts
  the host and lists cursor (arm64 and amd64), with the old glibc
  bun/1.4.2 left beside it unused. With libstdc++ removed again, plugin
  list says the library; MAGPIE_BUN pointed at the glibc build gives the
  C library message.
- New tests (bunmusl_test.go, libc_test.go), each broken by hand and seen
  red: no musl branch (TestBunTargetForMusl, TestMuslBunKeptApartFromGlibc),
  no bun/musl root (TestMuslBunKeptApartFromGlibc), cantStart returning
  the error as is (TestCantStartSaysCLibrary,
  TestHostOnUnstartableBunSaysCLibrary, which fails with the reporter's
  exact message), host.go without it, no musl sum (TestBunDefaultSums),
  no hint in bun add (TestMissingLibsNamesThem) or in the host's start
  (TestHostOnBunLackingLibsSaysWhich), muslAt always false (TestMuslAt).
  -race -count=20 on them: green.
- gofmt -l; go vet ./... on darwin, GOOS=linux -tags nogui, GOOS=windows;
  go build for darwin, linux nogui, windows; go test -tags nogui for
  internal/plugin, libc, claudecode, cli in a sandbox HOME, and
  go test -tags nogui ./... (all green). One earlier run of
  internal/plugin with the other three packages went red, and its output
  was lost to a tail; four reruns of it, alone and together, were green,
  and the new tests were green under -race -count=20, so which test it
  was isn't known.

Not tried: a glibc Linux end to end after the change (the unit test
covers that its Bun stays at bun/<v>); a musl Linux other than Alpine
(the detection is unchanged and looks for Alpine's libc.musl-*.so.1).
The old glibc bun/<v> on an Alpine machine stays on disk (~90 MB); it
isn't removed, as a volume shared with a glibc container could be using
it.
2026-10-13 07:25:22 +08:00
yetoneandKoohoko 067f39f406 sessions: Desktop titles read once per second, from every handle Desktop keeps, and reach stats and Context (#1675)
Follow-up to Koohoko's 3d6f8b8e, after review.

- Cost: assemble asks DesktopTitles once per native Claude Desktop
  session, and each call globbed and stat'ed every local_*.json, so a
  list of N Cowork sessions looked at the metadata N times. The names
  are now one index, rebuilt at most once a second (desktopTitlesHeld);
  a rename in Desktop shows within that second. Files are read through
  filememo, the shared reader the usage resolver already uses for these
  same files, which also catches a same-size rewrite inside one mtime
  tick (the patch's own size+mtime cache didn't).
- A record that is there but doesn't parse (Desktop midway through a
  write) keeps its last parse instead of dropping to the bare id; a
  record gone still takes its names with it.
- Handles: Claude.app 2.7032's LocalSessionManager (app.asar, read-only)
  counts unarchivedCliSessionId as a live handle beside cliSessionId and
  preClearCliSessionId as lineage beside priorCliSessionIds, and runs a
  record with no cliSessionId under its sessionId without "local_".
  All are named now; the raw "local_..." id no longer is (no usage
  record carries it).
- Siblings: MergeExternalStats (the Sessions page's stats summaries)
  and the Context page named gateway-only Desktop sessions by the
  recorded prompt or nothing; both use the Desktop name now.
- docs/subsystems/gateway-sessions.md says all of the above.

Real layout: no Desktop session records exist on this Mac or the
Windows box (only claude_desktop_config.json), so field names and types
were checked against Claude.app 2.7032's own reader/writer code: a
string title, string cliSessionId/unarchivedCliSessionId/
preClearCliSessionId, an array priorCliSessionIds, files
<account>/<org>/local_*.json under claude-code-sessions and
local-agent-mode-sessions. Dirs come from desktopdir.Everywhere, the
resolver the other Desktop session readers use (Windows %APPDATA% and
MSIX LocalCache, Linux ~/.config); Windows/Linux not run.

Run: new tests TestDesktopSessionTitleHandles, TestDesktopSessionTitleInStats,
TestDesktopTitlesReadOncePerList, and context checks in
TestDesktopSessionTitlesOnPages. Each broken by hand went red:
rescan per call -> "metadata looked at 12 times, want once"; no
last-good -> "a half-written file lost its names"; no unarchived/stem ->
missing ids; stats without the name -> "stats titles map[cli-s:Recorded
prompt ...]"; Context without it -> "context titles map[...: ...]".
go test -race -count=20 -run TestDesktop ./internal/sessions;
go test -tags nogui ./... (sandbox HOME, pinned caches): all ok but
internal/plugin's TestPiPackage (pi-codemode export missing; passes
alone, doesn't import sessions or gui), filed as #1879; 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.
GUI: routing-sessions, session-identity, sessions-overview,
sessions-bar-names, sessions-gateway-delete, sessions-manage,
context-window in Chromium and WebKit (84/84 each).
Real binary: magpie web under a sandbox HOME with Claude-3p Code and
Claude Cowork fixture records and five claude-desktop usage records;
the Sessions page (Chromium, WebKit) showed both titles on current,
prior and unarchived ids and the bare id on the unmatched one;
/api/gateway/session-titles named them; a rename showed after 1.3s;
a half-written file kept the name; deleting the record went back to
the id.

Co-authored-by: Koohoko <koohoko@gmail.com>
2026-10-13 07:14:22 +08:00
Haogao Gu d46a5635c0 sessions: Claude Desktop uses its saved conversation titles (#1675)
Read Code and Cowork metadata when native CLI transcripts are absent,
including current/prior CLI IDs and renames. Keep gateway identity,
accounting and capabilities. Desktop titles take precedence over the
recorded first-prompt fallback added upstream; unknown names keep it.

Rebased onto 751e05d8. All three new regressions fail on that unmodified
base and pass with the patch. Full Go suite, targeted race checks repeated
20 times, and macOS/Linux/Windows vet/builds pass. Baseline and patched
binaries reproduce UUID/title display in Chromium and WebKit with the
same synthetic Code/Cowork metadata and recording off. The patch applies
cleanly to newer origin/main 84cd8153. Linux/Windows runtime UI was not
executed. No live gateway or agent files were modified.
2026-10-13 07:14:22 +08:00
yetone 1a44670302 gateway: a long Codex session full of images is read up to 512 MB, and magpie's 413 says it is magpie's limit and to /compact (#1422, NeoPengZhile)
NeoPengZhile's Codex (signed in to ChatGPT, through /backend-api/codex/
responses) got "413 Payload Too Large: request body exceeds gateway
limit" on all five reconnects in a long session that had read many
images; a new session worked. Codex sends the whole conversation every
turn, screenshots inline as base64, zstd-compressed; magpie's limit is on
the decoded body and was 128 MB, while magpie compresses a ChatGPT turn
again on the way out, so the backend sees about what Codex alone would
send. The message didn't say whose limit it was or what to do.

What changed:
- request_bounds.go: defaultBodyLimit 128 MB -> 512 MB (decoded, which
  also sets the zstd decoder's memory cap). Every route that reads with
  the default gets it, keyLimited's read among them, so a limited key
  isn't held to the old number first. Routes with their own lower limit
  (System One 16 MB, a Claude subscription's 16 MB) keep it.
- overLimit: magpie's own 413 says "request body is over magpie's
  gateway limit of 512 MB (decoded); the provider was not asked".
- gateway.go writeError: the hint added to a 413 now says it is a byte
  limit, not the model's context, and to /compact (Codex, Claude Code) or
  start a new conversation.
- request_bounds_test.go: TestRequestBodyTooLarge uses defaultBodyLimit+1
  in place of a literal 129 MB.
- docs/subsystems/gateway-routing.md says so.

Run: go test ./internal/gateway/ -count=1 (ok, 354s), with the new
TestImageHeavyCodexTurnIsRead (a zstd body of inline images decoding to
136 MB on Codex's backend path, read with the default limits) and
TestOverLimitSaysWhoseAndWhatToDo; go test ./internal/gui/ (ok); go vet
./... on darwin, GOOS=linux -tags nogui and GOOS=windows; gofmt -l.
Broken by hand: the limit back at 128 MB -> TestImageHeavyCodexTurnIsRead
fails with the 413; the old "exceeds gateway limit" message, or the old
hint, -> TestOverLimitSaysWhoseAndWhatToDo fails.
Not tried: the reporter's real session, or how big a turn the ChatGPT
backend itself takes; the test's images repeat, so its wire size is far
smaller than real screenshots'. Peak memory for a turn near 512 MB was
not measured.
2026-10-13 07:07:18 +08:00
yetone c6da41b04c agent: an IDE plugin's ~/.copilot or ~/.qoder-cn isn't taken for the CLI (#1495, v5tech)
v5tech traced two agents listed with no CLI installed to the JetBrains
plugins that write the CLI's folder:
- GitHub Copilot's JetBrains plugin writes ~/.copilot (ide/, instructions/,
  prompts/, agents/, skills/, hooks/; the paths are in its jar). Copilot
  CLI was detected by that folder alone.
- Qoder CN's JetBrains plugin fills ~/.qoder-cn (its indexer in
  shared_client/, app/, plugins/) and writes a settings.json holding only
  {"enabledPlugins":{...}}, which is the CLI's Path, so the CLI was found
  by its "config file".

What changed:
- Copilot CLI sets dirShared, as omp does for Pi's folder: settings.json
  or the copilot command still finds it.
- Agent gets pathOwn: when set, the file at Path counts only if it says
  the file is the agent's. Qoder (both builds, one qoderAt) sets dirShared
  and pathOwn = !qoderPluginOnly: a settings.json that parses as an object
  of enabledPlugins alone is the plugin's. Any other key, {}, or a file
  that can't be read or parsed still counts (unknown is not "the
  plugin's"), and so does qodercli / qoderclicn on PATH. The global build
  is held to the same because the code and the plugin are shared; that
  the intl plugin writes ~/.qoder the same way is by analogy, not seen.
- docs/subsystems/agent-wiring.md says so.

Run: go test ./internal/agent/ -count=1 (ok, 226s), including the new
TestCopilotFolderFromAnIDEPluginIsNotTheCLI and
TestQoderSettingsFromAnIDEPluginIsNotTheCLI (the reporter's folders,
then the command on PATH, then the CLI's own settings).
Broken by hand: Copilot's dirShared off -> the Copilot test fails; Qoder's
pathOwn nil -> both qoder subtests fail; Qoder's dirShared off -> both
fail.
Not tried: a real JetBrains plugin or Qoder CLI; WSL (its probe counts the
distro's folder and isn't changed; a Windows JetBrains writes the Windows
home, not the distro's).
2026-10-13 07:07:18 +08:00
yetone bf60d32bde gateway: a key set to a protocol its provider has no URL for is said on Routing and in the editor, not passed over quietly (#1702, edussss)
edussss set a relay key to Responses only on a provider with a Chat URL
and no Responses URL. perKeyBarred skipped the key (no endpoint for its
protocol), every key was skipped, so the provider was tried whole and the
request went out on Chat with nothing saying why. The owner: it shouldn't
fall back quietly.

Requests are still served on the URLs the provider has (so working setups
keep working), but now it is said:
- fallback.go: perKeyBarred remembers the protocol of the first key it
  skipped for having no URL, and the whole-provider candidate carries it
  as noURL.
- trace.go: Weighed.NoURL, so the Routing page sees it.
- routing.js: the row and the activity line say "key set to {api} only,
  no {api} URL · sent on the others".
- app.js/app.css: the editor's key row shows an amber "No {api} URL" chip
  (keyLacksURL) with a title that says how to fix it.
- i18n.js: the three strings in zh, zh-TW, ja and de.
- docs/subsystems/providers-accounts.md: the Keys row says so.

Run: go test -run 'TestKeyForAProtocolWithNoURLIsSaid' ./internal/gateway/
(the reporter's case: upstream /v1/chat/completions with k-resp, NoURL
"responses"; with an Any key added it goes to k-any and NoURL is empty);
key-nourl.test.cjs in chromium and webkit, en/zh/zh-TW/ja/de, at 420 and
1000 wide, no click-scroll, no sideways scroll: 40 pass; with i18n-keys,
gui-zh-tw/ja/de, key-copy, key-weight, key-weight-fit, key-import,
routing-key-windows, routing-keys-fold, proto-menu-overflow, nokey-editor
and ledger-protocol: 174 pass, 0 fail.
Broken by hand: without the noURL mark the Go test fails (noURL = "",
want "responses"); with keyLacksURL/noURLWord removed chromium fails 20
of 20.
Not tried: a real relay, or the GUI against a live gateway.
2026-10-13 07:07:18 +08:00
yetone 016760e520 agent: Goose's requests show as Goose on Routing and in Usage, by a key that names it (#1083, EZN7L2C3)
Goose's HTTP client sends no User-Agent (reqwest's default in
crates/goose-providers/src/api_client.rs, checked on block/goose main), and
the custom provider magpie writes for it (custom_providers/magpie.json)
carried the plain gateway key. The gateway tells an agent by its key first,
then its User-Agent, so Goose's requests were "your agent" on Routing and
"other" in Usage. The file now carries agentKeyAt("goose") (magpie-goose on
this machine, the LAN key from a NAT'd WSL distro, as before), the same as
Alma, Hanako, Snow, AstrBot and Prime Agent, which also send no User-Agent.
Goose's Check compares the same key, so a file an older magpie wrote counts
as drift and Sync rewrites it. Goose reads custom_providers at start, so a
running Goose needs a restart (the existing notice says so).

Tests: TestGooseKeyNamesGoose (the key written, an older file's plain key
noticed by Check and replaced by Sync) and TestGooseRunsOnMagpie's key
assertion fail on the old code (Authorization = "Bearer magpie", want
"Bearer magpie-goose"). Breaking only the Check back to the plain key fails
both with "headers.Authorization (magpie.json) was changed". The gateway's
TestGooseAgentByKey records a request with no User-Agent and magpie-goose
as goose's (it passes on the old code: the gateway side already worked; it
guards the path end to end). go test ./internal/agent/ ./internal/gateway/
in a sandbox HOME. Not tried with a real Goose.
2026-10-13 07:07:18 +08:00
yetone d3d1605c2c sessions: Kimi Code's own calls reach Usage, read from its wire files (#1607, infinitr0us)
Usage counts the gateway's calls and the calls the agents' own session
files record (sessions.Calls). Kimi Code had no reader, so its calls
straight to api.kimi.com on Kimi's own sign-in never showed (the
reporter's 47 k3 calls of one session on 2026-10-11).

The reader (calls_kimi.go) is built from the redacted real wire files
infinitr0us shared from two machines (protocols 1.0, 1.4, 1.5; text
replaced, every id, model and number kept) and their notes from Kimi
Code's source. It reads every agents/*/wire.jsonl under
$KIMI_CODE_HOME/sessions, else ~/.kimi-code/sessions (as agent.KimiDir
finds the new Kimi Code), main and subagents, ses_* folders included.
One call per usage.record: inputOther, inputCacheRead and
inputCacheCreation go to Input, CacheRead and CacheWrite, output as is,
the record's own model and time. Nothing is paired with step.end, since
1.4 and 1.5 write them in opposite orders and the June 1.4 build has no
messageId or llm.request. A model beginning "magpie/" (magpie's own
entry in Kimi's config) is skipped: the gateway counted it. kimi fork
copies the parent's records unchanged, so a call is keyed by agent
(agentId, else its agents/<id> folder), time, model and usage, and Calls
counts a key once. It is a whole-file call source (callSources,
wholeCallReaders) and the folder is watched (Dirs). The subsystem page
gets the list of call readers.

Fixtures (testdata/kimi-code) are the reporter's files cut to the lines
a call is read from, each line verbatim (50 KB; one of the July
session's eight agents kept).

Run: the reader over the reporter's whole, untrimmed files gives exactly
their README's totals (32/2,841,972/12,283; 151/7,025,587/122,782;
6/147,822/2,009; 10/338,328/2,176; 0 for the four others).
TestKimiCodeCalls (both homes), TestKimiCodeSkipsCallsThroughMagpie,
TestKimiCodeForkCountsOnce, TestKimiCodeBrokenFiles (cut mid-record,
empty, junk, null/negative/timeless usage) pass. Broken by hand, each
goes red: no magpie skip, no key, key without agent, no negative or
time guard, main only, KIMI_CODE_HOME ignored, cache read dropped.
go test -tags nogui ./internal/sessions ./internal/usage ./internal/cli
./internal/gui under a sandbox HOME, gofmt -l, go vet (darwin),
GOOS=linux go vet -tags nogui, GOOS=windows go vet.

Not tried: a live Kimi Code run (fixtures are the reporter's real
files, not a sandbox capture), a successful call through magpie (the
magpie-routed record in the test is the reporter's quoted 1.5 line with
a magpie/ model), a compaction record (usageScope "session", none in
the files), Kimi Code in WSL (not read), Windows paths at runtime. A
subagent's calls carry the session but no Subagent field.

Thanks to infinitr0us for the write-up from Kimi's source and the
redacted wire files.

Reported-by: infinitr0us
2026-10-13 06:59:17 +08:00
yetoneandcongee949 8179ce768f usage: a test that a row's own cost and its hidden reasoning are read back apart (#1463, #1874)
#1874 (d4c2512d2) gave the packed row's Flags bit 256 to rowOwnCost
while the #1463 rebase gave the same bit to rowReasoningHidden; the
rebase onto it moved rowReasoningHidden to 512. With both on 256 a
reported call that said its cost read back as hidden reasoning (its
speed dropped) and every hidden-reasoning row as having said its own
cost. TestRowFlagsApart checks both rows raw, priced and packed, and
that no Flags bit is used twice.

Run: go test -tags nogui -count=1 ./... ok on macOS at this head
(rebased on d4c2512d2); gofmt and vet clean.
Broken by hand: rowReasoningHidden back to 256 turns both subtests
and the bit check red.

Co-authored-by: congee949 <c86474321@gmail.com>
2026-10-13 06:52:42 +08:00
yetone a43fa6809b library: two changes in one millisecond each get a backup folder of their own (#1743)
liubing reported on #1743 that TestRemoveFoundEntryEveryFormat failed
in a full run on Linux, the backup read holding another format's
content, on an unmodified main too. The backup folder was named by
the millisecond and taken as this change's own: a second change in
the same millisecond wrote into the first's folder, its file kept
under its folder's name since the first's held the name, and the
copy at the name the change wrote was the other change's. The test's
loop runs one change per format, all named config.json, and on a fast
machine two land in one millisecond. A user's two quick changes did
the same: the backup the second change named wasn't its own.

freshBackup makes the folder with os.Mkdir, adding -2, -3... when the
millisecond's is taken. pruneBackups' sort keeps them in order.
Siblings checked: the skill backups (keepLibrarySkill, keepReplaced,
setAside, carry's and RemoveSkills' aside) use per-skill paths under
the stamp; setAside already steps past a taken name, and the others
only collide on the same skill in the same millisecond, where move
fails loudly rather than mixing; they are left as they were, since
a folder each would split one change's skills over many folders.

Run: go test -tags nogui ./internal/library/ ok on macOS and in
Docker golang:1.26.8 GOTOOLCHAIN=local (also -count=30 of the two
tests). The original red didn't show in Docker in 100 runs; it was
reproduced by injecting a minute-wide stamp, which turned
TestRemoveFoundEntryEveryFormat red on the old code and leaves it
green with the fix. Broken by hand: os.Mkdir -> os.MkdirAll (no
claim on the folder) turns TestBackupsInOneMillisecond red.
2026-10-13 06:43:50 +08:00
yetoneandliubing 9935119f1d sessions: search finds Cursor and OpenCode sessions read from their stores, and a Cursor chat's system prompt isn't shown as said (#1743)
Follow-up to liubing's #1743 patch, which put cursor and opencode in
HasTranscript. That moved their search from magpie's recorded
transcript to SearchSession, whose byte prefilter (mayHold) reads
s.Path. For these agents s.Path isn't the conversation:
- OpenCode's JSON storage: the session info file, without messages,
  so every word missed;
- OpenCode's and Cursor's SQLite stores: the newest pages are in the
  -wal, so a live chat's latest turns missed.
linesFile now skips the prefilter for them (a Cursor .jsonl still
gets it).

cursorTranscript also handed the CLI store's system message ("You
are a coding agent.") to the transcript as a said part; system
messages are skipped, as the listing already does.

The patch's tests commit left TestSearchSessionWithoutATranscript
red (it used cursor as the agent without a transcript; now gemini).
sessions-empty-range.test.cjs runs in every language, de at 420px.

Run: go test -tags nogui -count=1 ./internal/sessions/ ok, and -race
ok; sessions-empty-range 10/10 (Chromium+WebKit, en zh zh-TW ja de);
sessions-today/overview/toolbar/search/manage/calendar-fill/paging
GUI tests pass.
Broken by hand: prefilter always on -> TestSearchOpenCodeFiles and
TestSearchCursorLiveChat red; system skip removed ->
TestSearchCursorLiveChat red. Also broke the patch itself: editor
files not appended, readOnly Delete guard, stats message dates, CLI
dedupe, HasTranscript entries, parseCursor readOnly dispatch, and
the "All sessions" button (via MAGPIE_TEST_APP_JS); each went red.

Co-authored-by: liubing <lb0806@foxmail.com>
2026-10-13 06:43:50 +08:00
liubing 5d3d494431 sessions: reproduce missing editor histories and unreadable conversations (#1743)
The new Go tests fail on upstream 6a8b2c68 with missing editor sessions and ErrNoTranscript; the date-range UI test fails on the missing history shortcut.
2026-10-13 06:43:50 +08:00
liubing 1cd8140047 sessions: read Cursor editor history and Cursor/OpenCode conversations (#1743)
Discover editor project transcripts and cursorDiskKV histories without modifying the source. Share one SQLite/WAL snapshot across a scan, refresh metadata changes, deduplicate CLI histories, and reject deletion of read-only sessions.

Count message-only sessions and expose an all-dates action when a filter hides existing history. Read Cursor CLI text, reasoning and tool parts, and OpenCode v1/v2 transcripts through the existing transcript API.
2026-10-13 06:43:50 +08:00
yetoneandcongee949 296b63f8d6 usage, gateway: tests for the #1463 rebase: a priced row keeps its reasoning evidence, and a summary after an endpoint fallback stays hidden
Follow-up to congee949's rebased dfc24632
(#1463, streamed reasoning speed).

- TestPricedRowKeepsReasoningEvidence: the Requests page reads gateway rows
  through blockPricer, which sets swapKnown (64) on every row. The patch
  put ReasoningHidden on bit 64 too; on main that would have read every
  priced row as hidden, so a tool-only reply with no reasoning, and paced
  visible reasoning, lost their speed on the Requests tab. The rebase gave
  ReasoningHidden its own bit (256, Flags widened to uint16); this test
  prices visible, tool-only and hidden rows, raw and packed, and checks
  the flag and the speed read back.
- TestSummaryAfterEndpointFallbackStaysHidden: a Messages client, a model
  answered on /responses after /chat/completions said it isn't served
  there. call.To still reads Chat, so hidesReasoning(call.To) doesn't see
  the summary; only streamTranslated's summaryUpstream marking does. With
  no reasoning count the 1500 output tokens were otherwise timed from the
  first summary delta. Nothing covered that marking before.
- reasoning-speed.test.cjs: the "no reasoning: 500 in 5 s" comment had
  been joined onto the redacted row; put back on its own row.
- docs/subsystems/gui-shell.md: the flag bit, the fallback marking, the
  two tests.

Run: go test -tags nogui -count=1 ./internal/usage/ and the gateway's
reasoning tests; reasoning-speed.test.cjs in Chromium and WebKit (en, zh,
zh-TW, ja, de), 10/10.
Broken by hand: rowReasoningHidden = 64 turns TestPricedRowKeepsReasoningEvidence
red (visible and tool-only rows read hidden, 0 tok/s); summaryUpstream
forced false turns TestSummaryAfterEndpointFallbackStaysHidden red (1500
tokens in 314 ms).

Co-authored-by: congee949 <c86474321@gmail.com>
2026-10-13 06:43:50 +08:00
congee949 2d3b33bb78 usage: time tool-only replies only with visible reasoning evidence
Revises #1463 after the hidden-reasoning inflation review. Keep answers separate, retain evidence in routes and cached ledger rows, and exclude sealed or summary-only reasoning even without a token breakdown. Sync the backend and both GUI formulas.

Checked real WorkBuddy DeepSeek, Codex and Claude bridge responses in an isolated HOME; sanitized timings and failures are in docs/verification. Chromium/WebKit speed regressions pass (20 tests, five languages). New edge regressions and loop-order check pass under race repetition. Restoring the old formula or removing the hidden guard fails TestVisibleReasoningSpeed. macOS/Linux/Windows vet/build pass. Full-suite verification is recorded in the issue at this head; inherited proxy/Bun 1.3.14 failures are retained, with clean Bun 1.4.2 rerun in progress. No installed app replacement.

Rebased onto main by yetone (#1463). Conflicts with main's Own/Retried/
Queued/Tries row fields, HandedOn and the Codex speed floors were resolved
by keeping both. The packed row's ReasoningHidden bit was 64, which main
has since given to block_price.go's swapKnown, and main's rowHandedOn took
128, filling the uint8: Flags is now uint16 and ReasoningHidden is bit 512
(rowReasoningHidden; #1874's rowOwnCost took 256), read back in row(). The docs/verification notes and
their sample JSON are left out of the tree; they stay on the contributor's
branch and the issue. Run after the rebase: go test -tags nogui ./internal/usage/
and the gateway's reasoning/speed/TTFT tests, ok.
2026-10-13 06:43:50 +08:00
yetoneandggbdpq cc93b566e2 gateway: Zed's test still checks is_error true on a real result, beside the mended orphan (#1558)
What changed: d1d45dd3 made TestZedToolResultSaysIsError's toolu_2 result
an orphan turned to text, and its assertion went from [false true] to
[false]: nothing checked any more that a result with is_error true goes
to Zed's cloud with it (yetone/magpie-releases#9). The fixture's
assistant now makes toolu_2's call, so both real results keep [false
true], and a separate toolu_9 result with no call checks the orphan goes
as its text. The pairing tests also check the synthetic result is
is_error, and a new TestMessagesSecondAnswerDropped checks a call answered
twice keeps only its first answer. docs/subsystems/gateway-routing.md gets a bullet for the Messages build's mending, beside the Gemini and Responses ones.

Why: the patch's tests passed with is_error dropped from the synthetic
result and with the second-answer rule removed.

Run (sandbox HOME, private GOCACHE):
- go test -tags nogui -run 'TestMessages|TestZed' ./internal/gateway/: ok
- pairToolBlocks call removed: the six TestMessages tests and
  TestZedToolResultSaysIsError fail ("is_error: [false true false]",
  "what the lost result said is not kept").
- IsError dropped from the synthetic result: TestMessagesUnansweredCall
  GetsSyntheticResult fails. The duplicate's continue removed:
  TestMessagesSecondAnswerDropped fails ("user[A,A]").

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-13 06:43:00 +08:00
yetoneandggbdpq 861c2da147 provider: tests that a Claude usage ask on a read's own clock tick is answered (#1228)
What changed: three tests for c56eccab's generation counter, one per
place a Claude reading is kept against an ask: loginReading (LoginUsage),
SubscriptionUsage's whole-page cache, and claudeWindows' /usage run.
Each asks while the reading is under way and stores the ask's time as of
before the reading began, as Windows' ~15ms clock or a clock set back
reads it. TestLoginUsageClaudeAskedMeanwhile only failed on Windows, 3 in
5, because on macOS the two times never tie; these fail every time on the
old code. The claudeWindows test also ages the answered run past the 30s
floor and checks no run follows unasked.

Why: the patch came with no test of its own that fails on the old code
outside Windows.

Run (sandbox HOME, private GOCACHE, go1.26.8 darwin/arm64):
- with the three product files put back to origin/main: all three FAIL
  ("a reading from before the ask was kept", "cards read before the ask
  were kept as fresh", "the ask wasn't answered: <nil>, 1 runs").
- broken by hand, one at a time: loginReading's check made always true
  (login test red); SubscriptionUsage's reset dropped (page test red);
  the successful run's entry without asked (claudeWindows "ran again
  unasked: 3 runs"); markClaudeUsageAsked's Add removed (all three red);
  RefreshUsage's markClaudeUsageAsked removed (existing
  TestRefreshSavedClaudeUsage red).
- go test -tags nogui -count=3 -run 'AskedOnThe|AskedMeanwhile' passes.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-13 06:43:00 +08:00
ggbdpqandfactory-droid[bot] e21b1dbc16 gateway: a broken tool exchange a Chat or Zed client left is mended for a Messages upstream, as the Chat and Responses paths mend theirs
What changed: buildAnthropic (every request built for a Messages
upstream: a Chat or Responses client's conversation translated, Zed's
bridge) now runs its messages through pairToolBlocks, as buildChat's
pairToolMessages (#554) and the relayed Responses path's pairToolItems
(#1341) mend theirs. Anthropic refuses a tool_use the next message's
tool_results don't answer ("`tool_use` ids were found without
`tool_result` blocks immediately after") and a tool_result naming a call
it never saw ("unexpected `tool_use_id` found in `tool_result` blocks");
an interrupted turn leaves the first behind, a client that dropped a
call the second. A call left unanswered gets the synthetic result the
other paths make; an answer to no call becomes a text block keeping
what it said. A well-formed exchange is built exactly as it was (ids in
their places, results in the order the client sent, text after them).

TestZedToolResultSaysIsError's fixture carried a result for a call the
request never made; it asserted the orphan went through as a
tool_result, which the cloud refuses. It now goes out as the text it
said, and the test says so.

Run:
- /tmp/sbx.sh test -tags nogui -count=1 -run 'TestMessages' ./internal/gateway/
  with the pairing call taken out: 6 FAIL (trace "user assistant(A)",
  and the end-to-end one 400 "unexpected `tool_use_id` found in
  `tool_result` blocks"); with it back in, all pass
- /tmp/sbx.sh test -tags nogui -count=1 ./internal/gateway/ — ok
- gofmt -l (nothing), go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... (the trayimage_darwin.go -Wenum-conversion
  warning as on main), go build, GOOS=linux go build -tags nogui,
  GOOS=windows go build

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-10-13 06:43:00 +08:00
ggbdpqandfactory-droid[bot] 44b5b2b96b provider: a Claude usage ask invalidates an older read even in the same clock tick
Refs #1228. The original test fails with "a reading from before the ask
was kept". A temporary diagnostic measured identical UnixNano values for
the read's start and the later ask; that diagnostic is not shipped.

What changed:
- Count both whole-page and manual-card Claude asks with a generation.
  Advance it under subscription then login cache locks, so publication
  cannot check the old generation and then commit after the ask.
- Capture the generation before launching LoginUsage/SubscriptionUsage;
  reject an older account read or leave the cards due for another read.
- Record each Claude /usage run's ask generation. Keep timestamps, the
  zero sentinel, floor, idle behavior, saved-account scope and fallbacks.
- Document ordering and lock ownership in the providers/accounts design.
  No tests, routing.go, account files or dependency versions changed.

Run on upstream 8f2a314cf9:
- Original test unchanged: count=50 passes (12.317s). Product-only stash
  restores real red, count=30 (7.077s); pop then count=5 passes (2.137s).
- Expanded usage/header/saved-card paths race count=5 pass (122.691s),
  Go 1.26.8 and installed MinGW gcc, external sandbox home/temp and
  pinned Go caches.
- Provider nogui vet passes on Windows, Linux, Darwin. Windows default
  build and Linux/Darwin nogui builds pass. gofmt and staged diff clean.
- Provider full package and full ./... were not rerun; real account,
  GUI engines/languages, Darwin GUI build and cross-OS runtime not tried.
  Targeted evidence only, not a claim of complete merge acceptance.

Generated-by: Factory Droid (GPT-6.1 Sol)

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-10-13 06:43:00 +08:00
yetone d4c2512d2d usage: apps report their own calls with POST /v1/magpie/usage/requests, backfill included (#1874)
What changed
- POST /v1/magpie/usage/requests (internal/gateway/usage_ingest.go) takes
  one record or an array, in usage.jsonl's shape:
  - the post may carry up to 5000 records and 32 MiB;
  - t, agent, provider, model and rid are required.
  Each field is checked: unknown fields, quoted numbers, negative or absurd
  counts, a status outside 100-599, a cost over 10000 USD, and a t more
  than an hour ahead or before 2000-01-01T00:00:00Z. Any fault refuses the
  whole post with a 400 that names error.index and error.param, and nothing
  is written. A past t is otherwise taken as given, so history can be
  backfilled. The reply gives accepted and skipped counts and each
  record's index, rid and status.
- Access: lanGuard's rule (this machine, or another with a key while
  shared, behind the Host check). A browser page also needs a key, since
  corsGuard lets localhost pages and Origin null through. A held key is
  refused.
- usage.IngestReported writes under usage.mu to the same file as
  usage.Append. Rows carry source "reported" and no caller key. A rid
  already reported is skipped, as is one repeated in the post. The set of
  reported rids is read back from the log: one scan after a restart (lines
  without the reported mark aren't parsed), then only what was appended.
- Pricing: a record with cost keeps it (Record.OwnCost, the rowOwnCost
  flag; packed flags widened to uint16). Otherwise it is priced at
  magpie's prices.
- Display:
  - SourceReported is a source of its own: RequestPage.Reported,
    ?via=reported, and Ledger now honours via.
  - The Requests tab gains a fourth cell "reported by apps", shown once
    there are some, and a "Reported" badge (en, zh, zh-TW, ja, de).
- Nothing live: Record.IsReported keeps reported rows out of:
  - a key's budget/spend limit (budget.counts);
  - window holds, and the log start that decides whether a window can be
    reckoned (logSnapshot.firstOwn);
  - gateway sessions and Vias;
  - Codex's sealed answers and remembered model.
  There is no OTel span, rate limit, rest or alert for them.
- Docs: gateway-sessions.md, reference.md (with a curl), integrating.md,
  site integrate.html (en, zh).

Why: the reporter's apps call vendors directly, and their usage (and
history) should show on the Usage page without becoming live traffic.

Run, in a worktree with sandbox HOME and a private GOCACHE
- gofmt -l: clean.
- go vet ./...: darwin, GOOS=linux -tags nogui, and GOOS=windows.
- go test internal/usage, usageapi, budget, gateway, gui: ok.
- -race -count=3 of the new usage/gateway tests: ok.
- GUI with playwright 1.62.0:
  - usage-ledger-reported.test.cjs, 26/26 in chromium and webkit (5
    languages, 1180 and 420 wide, light and dark);
  - usage-ledger*.test.cjs, ledger-*.test.cjs, usage-sum-whole,
    usage-unpriced-sum and i18n-keys: all pass.
- Timings with 200k reported rows (47 MB log, darwin):
  - 40 posts of 5000 took 0.40 s (worst batch 18 ms);
  - the first post after a restart took 0.45 s (rid rescan), a later one
    1.6 ms;
  - the cold index build took 2.1 s (as for gateway rows);
  - page all took 27 ms warm, page 30d 39 ms, all via=reported 0.53 s;
  - summary all took 215 ms, 30d 20 ms.

Broken by hand, each went red, then restored
- Go: dedupe against stored rids; the restart scan; CostAt ignoring own
  cost; the block pricer overwriting own cost; the Reported split;
  fromBrowser's key rule; skipping bad records instead of refusing; the
  max-records and body limits; the ingest lock (race); both locks;
  firstOwn -> first; the IsReported guards in windowHolds,
  buildGatewaySessions, buildVias, budget.counts and loggedAnswers.
- GUI: the fourth cell, the --vias column count and the badge class.

Not shown red on its own: the remote-no-key and evil.example refusals come
from lanGuard and corsGuard before the handler, so breaking only the
handler's own check stays green. The codex_memory guard is not tested
alone: a reported row has no Requested there anyway. Not tried: a real
client against a live gateway, Windows/Linux runs of the tests, the full
GUI suite.
2026-10-13 06:32:03 +08:00
yetoneandappointat 84cd81533e gateway: the client's comment points at where the ChatGPT backend's HTTP/1.1 rule now lives (#1700)
The previous #1700 commit deleted gateway/codex_http1.go and moved the
rule into netproxy.HTTP1, which provider/codex_http1.go sets; the
comment on the gateway's client still named the deleted file.

Review of #1700 (no other change needed): every Codex request magpie
makes goes through a netproxy.Dispatch transport, http.DefaultClient's
(codexModels, warmCodex, accountJSON for /wham/usage and the reset
credits, consumeCodexReset) or the gateway's s.client (turns, /models);
the HTTP/1.1 clone keeps netproxy.Func, or the account's own proxy,
and Clone deep-copies TLSClientConfig, so clearing NextProtos there
leaves the base transport offering h2 to every other vendor.

Run on 7485065d (the cherry-picked #1700, sandbox HOME, private
GOCACHE): go test -tags nogui ./internal/netproxy ./internal/provider
./internal/gateway pass; -race on TestDispatchHTTP1, TestWith,
TestCodexBackendOwnRequestsOverHTTP1, TestAccountProxy (provider and
gateway) and TestCodexBackendOverHTTP1 pass. Broken by hand: with
netproxy.HTTP1 left nil, TestCodexBackendOwnRequestsOverHTTP1 fails
(all five requests "HTTP/2.0 (h2 offered)") and the gateway's
TestCodexBackendOverHTTP1 fails ("asked over HTTP/2.0"); without the
NextProtos reset TestDispatchHTTP1 fails ("malformed HTTP response",
the server took h2 from the hello). gofmt -l clean; go vet darwin,
GOOS=linux -tags nogui, GOOS=windows clean; linux and windows builds.
Not reproduced: the reporter's PROTOCOL_ERROR itself.

Co-authored-by: appointat <65004114+Appointat@users.noreply.github.com>
2026-10-13 06:18:27 +08:00
yetoneandggbdpq 4537e92093 mcpauth: an assigned method magpie can do is checked to sign in and renew, both ways round (#1490)
The previous commit refuses at registration a method the server assigns
that magpie can't send. The owner asked on #1490 that an assignment
magpie can do be shown still to work; no test did. One now does, for
the code exchange and a renewal after the access token is refused:

- asked none, assigned client_secret_basic with a secret;
- asked none, assigned client_secret_post with a secret;
- asked client_secret_post, assigned none with no secret (a public
  client), which sends no secret;
- asked client_secret_basic (the only one listed), assigned post.

The fake's registration took an assigned method only when its metadata
listed it, so "none" assigned to a server listing only post was turned
away as invalid_client_metadata; a method the server assigns is one it
supports, so with Assign set it is taken.

Run (sandbox HOME, private GOCACHE): the new test and
TestSignInRefusesAssignedSecretJWT, TestSignInBySecretBasic; go test
-race ./internal/mcpauth/... and ./internal/library (which signs in
through the fake) pass. Broken by hand: with register ignoring the
response's token_endpoint_auth_method the new test fails at the first
case ("the token endpoint answered 400: invalid_grant"); without the
previous commit's check TestSignInRefusesAssignedSecretJWT fails ("the
sign-in page was opened for a client magpie can't authenticate as").

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-13 06:18:27 +08:00
ggbdpqandfactory-droid[bot] c89a0f9d95 mcpauth: a server that registers magpie for a client authentication magpie can't do is said no at the registration
What changed: register took the registration response's
token_endpoint_auth_method as it came. RFC 7591's response lets the
server assign another of the methods it supports than the one asked
for, and one assigned that magpie can't send (client_secret_jwt,
private_key_jwt, tls_client_auth) opened the sign-in page all the
same: the failure came at the code exchange, after the browser round
trip, as "the token endpoint answered 400: invalid_grant", and every
renewal would fail the same way. A method outside none,
client_secret_post and client_secret_basic is now refused at the
registration, before the browser is opened, with the request side's
own wording. An assignment magpie can do (a server handing
client_secret_basic and a secret for a client that asked none) still
works as before.

mcpauthtest.Fake gains Assign: a server that registers the client for
another of the methods its metadata lists, giving a secret and taking
the token endpoint's word for it. Without it set, the fake answers as
it did.

Run:
- TestSignInRefusesAssignedSecretJWT (new) fails on the old register:
  "the sign-in page was opened for a client magpie can't authenticate
  as: http://127.0.0.1:…/oauth/authorize?…" — and passes now, Start
  saying the server registered magpie for client_secret_jwt, which
  magpie can't do.
- go test -tags nogui -count=1 ./internal/mcpauth/... ok, every
  existing case unchanged; full go test -tags nogui ./... under a temp
  HOME ok except testenv's TestOffline, red the same on the untouched
  baseline (loopback proxy escapes this machine).
- gofmt -l clean; go vet, GOOS=linux go vet -tags nogui, GOOS=windows
  go vet clean; go build, GOOS=linux go build -tags nogui, GOOS=windows
  go build ok.
- Not tried against a real authorization server that assigns a method:
  none is known in the wild; this is the response-side half of #1490's
  class, set by RFC 7591.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-10-13 06:18:27 +08:00
appointatandClaude Opus 5.5 abdc4b113d netproxy, provider, gateway: every request to the ChatGPT backend goes over HTTP/1.1, magpie's own too, not only the gateway's turns (#1700)
f6e1e98e put the gateway's turns to chatgpt.com on HTTP/1.1 through a
wrapper on the gateway's client. magpie's own requests there go through
http.DefaultClient and still spoke HTTP/2: the models list
(codexModels), the warm-up's POST to /backend-api/codex/responses
(warmCodex), the allowance (codexWindows via accountJSON), the reset
credits (codexResets) and spending one (consumeCodexReset). #1700's
reporter, on 0.1.1164, had Codex's /responses fail with PROTOCOL_ERROR
through a local proxy until GODEBUG=http2client=0, set by editing the
app bundle.

The rule now lives where every magpie Go client goes through.
netproxy.Dispatch sends a request netproxy.HTTP1 names through a clone
of its transport kept for HTTP/1.1, beside a provider's own proxy if
any, and the provider package sets HTTP1 to codexBackend (CodexBase's
host). The clone's TLS hello offers no ALPN, as codex-cli's: a transport
that has spoken HTTP/2 carries h2 in its TLS config, which a clone
copies, and a server that took it would be sent HTTP/1.1 on an HTTP/2
connection. The gateway's codexHTTP1 wrapper is folded into this; its
transport file is now upstream_transport.go. Every other vendor is still
offered HTTP/2, and GODEBUG=http2client=0 still turns HTTP/2 off for all.

What was run (Go 1.26.8, darwin/arm64, a sandbox HOME):
- TestCodexBackendOwnRequestsOverHTTP1 (provider): http.DefaultClient
  as netproxy.Install leaves it, a TLS server offering HTTP/2, the five
  requests directly, through Settings' proxy and through an account's
  own CONNECT proxy. On origin/main 6c1c0a74 it fails: all five
  "HTTP/2.0 (h2 offered)" each way. Another vendor's accountJSON read
  stays HTTP/2.0.
- TestDispatchHTTP1 (netproxy): after the transport has spoken HTTP/2
  to the server, a named request arrives HTTP/1.1 with no h2 offered,
  with a proxy choice too. Without the NextProtos reset it fails with
  "malformed HTTP response"; with HTTP1 ignored, with "HTTP/2.0".
- With the provider's hook off, the gateway's TestCodexBackendOverHTTP1
  fails too ("asked over HTTP/2.0, not HTTP/1.1"). TestAccountProxy,
  which stubs http.DefaultClient with a Dispatch of its own, passes; a
  separate Codex client in provider, tried first, failed it.
- go test -race -count=20: ./internal/netproxy TestDispatchHTTP1 and
  TestWith, ./internal/provider TestCodex* (this one included),
  ./internal/gateway TestCodexBackendOverHTTP1 and TestAccountProxy.
  gofmt -l; go vet (darwin, GOOS=linux -tags nogui, GOOS=windows); go
  build (the same three); go test -tags nogui ./... (49 packages) pass.
- Real use, behind Clash on a Mac: Codex's own sign-in copied into a
  sandbox HOME (days left on the token, nothing refreshed), and a
  CONNECT proxy in front of Clash logging each TLS hello's ALPN.
  origin/main: `magpie provider models codex` and one request at the
  gateway's start offered h2 to chatgpt.com, the turn none. This
  branch: no hello to chatgpt.com offered any, models.dev still h2.
  #1700's minimal request on codex/gpt-6-astra answered 200 with
  MAGPIE_CODEX_OK on both.

Not reproduced: PROTOCOL_ERROR itself; chatgpt.com answered HTTP/2 on
this Mac, so whether HTTP/1.1 is what the reporter's path needs is for
their use to say. The warm-up and spending a reset weren't sent for
real.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XSjhwVsPdGd6QUTrq4KvE4
2026-10-13 06:18:27 +08:00
yetoneandump45nose d0e412e7a6 library: a checked MCP server's PWD is home too, and #1727's cwd test holds on macOS (#1727)
The previous commit starts the check's server in home. Its own test
failed on macOS with that fix in: the child reported
/private/var/folders/.../magpie-test-home-N and HOME was
/var/folders/.../magpie-test-home-N, the same folder spelled through
macOS's /var symlink, compared as strings. The test now compares the
folders with os.SameFile.

exec sets PWD to Dir by itself only when Env is nil, and the check sets
Env, so the server ran in home with PWD still naming magpie's own
folder; a shell-script server that reads $PWD would see the folder the
fix moved it out of. The check now sets PWD=home with Dir (not on
Windows, which doesn't use PWD, as exec does), before the server's own
variables so one it sets still wins.

The two subtests now give each run a home of its own (t.Setenv HOME and
USERPROFILE) and move the process with t.Chdir, so the "needcwd" fake's
./logs goes with the test instead of staying in the package's shared
test home, and nothing is left in another cwd when a subtest fails. The
read-only-cwd subtest also checks that ./logs landed in home: Windows
doesn't enforce a folder's read-only bit, so that is what makes it fail
there without the fix.

Run (sandbox HOME, private GOCACHE): TestCheckStdio -count=3 on macOS;
the whole internal/library package. Broken by hand: without cmd.Dir both
subtests fail (wrong folder; "mkdir logs: permission denied"); without
the PWD line the cwd subtest fails on its PWD. On the Windows box
(windows/amd64 test binary): TestCheckStdio passes, and without cmd.Dir
both subtests fail there too (the server ran in the test's temp cwd,
and ./logs wasn't in home).

Co-authored-by: ump45nose <52391318+ump45nose@users.noreply.github.com>
2026-10-13 06:18:27 +08:00
ump45nose 0154fe1135 library: start stdio MCP checks in the home directory (#1727)
A magpie started from a Windows shortcut keeps C:\Windows\system32 as
its cwd. The Library check inherited that directory, so a server that
writes into "." failed as exited (1) with no log. Agents start the same
server from a project or home directory and succeed. Pin cmd.Dir to HOME
for the check.
2026-10-13 06:18:27 +08:00
yetoneandump45nose f2c30a8859 usage: the tags over the Context curve's dots never print over each other either (#1549)
The previous commit keeps the axis labels apart. The tags over the dots
had the same fault: a setting one step from the advice printed its
"+3%" on "Leanest", and a setting one step from the costliest value
printed "+147%" on "+150%". The tags now go by the same rule, "Leanest"
first, then the setting now, then the costliest: one within 16% of the
axis of a tag that matters more and at about its height (20 of the
plot's 100 units) keeps its dot and tooltip but not its tag.

Run: context-tune's overlap test gains a row whose setting sits one step
from the advice, checks the tags' boxes as well as the axis labels', and
runs in German ("Sparsamste", the widest "Leanest") as well as English,
at 360 and 1100px. With the previous commit's context.js it fails in
chromium and webkit ('en 360px: tag "+150%" overlaps "+147%"'); with
this one it passes. The axis test alone failed on main before the
previous commit ('360px: "160K" overlaps "170K"'). context-tune,
compact-at and context-window: 80/80. 56 context/usage/language GUI
files in both engines: 652/654; the two reds are usage-ledger's route
export (passes 3 of 3 alone, filed as #1876) and, in an earlier run,
usage-sum-whole at 780px in German (#1864, noted there); neither reads
context.js.

Co-authored-by: ump45nose <52391318+ump45nose@users.noreply.github.com>
2026-10-13 06:18:27 +08:00
ump45nose 9f54b6428e usage: the Context tab's curve no longer draws the leanest value's label over the axis's first one when they sit a step apart (#1549, Ti800)
The axis labels the advice's value, the setting now and the range's two
ends. One that sits within 16% of the axis of one that matters more (the
advice first, then the setting now, then the ends) is left off, so two
labels are never drawn over each other: 170K one step from 160K read as
"1170K".
2026-10-13 06:18:27 +08:00
yetoneand尤贺雨 38a07d890a gui: the line over each opened agent setting runs unbroken across label and value (#1169)
The label/value grid that keeps "In {agent}" on one line put 16px of
column-gap between the label's top border and the value's, so every
separator in the opened row had a 16px hole in it where one line ran
across before. The space between the columns is now the label's own
right padding (column at least 128px = the old 112px label + 16px gap),
so the two borders meet.

Run: agent-field-names' "one aligned line" test now also checks that
each value starts where its label's box ends. With the previous commit's
CSS it fails in all ten engine/language runs ("a gap between a label and
its value", valueLeft 16px past labelRight); with this one it passes.
The 45 GUI files that open an agent row plus gui-de/ja/zh-tw, chromium
and webkit: 701 tests; mobile-web's desktop screenshots match 97dfed0f
(BASE_REF=97dfed0f; against a newer origin/main its gateway shot
differs by #1514's Connect snippets, which this doesn't touch).
Screenshots in German at 980px before/after compared by eye.

Co-authored-by: 尤贺雨 <youheyu@sungrowpower.com>
2026-10-13 06:18:27 +08:00
尤贺雨 7f90f3f0cf gui: an opened agent's labels stay on one line, the column as wide as its longest label (#1169, emo172)
The opened row's label column was a fixed 112px with nothing to stop a
label from wrapping, so "In {agent}" broke over two lines for long agent
names (Cursor Private Inference, DeepSeek Harness) and for wider UI
fonts, and pushed its row taller than the rest. The rows now share one
grid whose label column is minmax(112px, max-content) with nowrap, so
every label sits on one line and every value starts at the same x. Under
600px the rows still stack, label over value.

Run (by the maintainer, on origin/main 97dfed0f with this commit):
- the new "opened agent labels stay on one aligned line" test fails on
  main in all ten engine/language runs (chromium and webkit; en, zh,
  zh-TW, ja, de): "a wide label wrapped: In Cursor Private Inference,
  lines 2, labelWidth 112"; passes with this commit.
- every GUI test that opens an agent row, plus gui-de/gui-ja/gui-zh-tw,
  45 files, chromium and webkit: 701 pass, 0 fail.
- the same test at 610, 680 and 760px wide (between the stacked
  breakpoint and the desk width), every language: no label wraps and
  nothing spills out of the opened row.
2026-10-13 06:18:27 +08:00
yetone 751e05d824 provider: moved Cursor users get plugin 0.2.10, which counts a Team's org-wide on-demand pool as the limit (#1868)
@magpie-community/opencode-cursor-auth 0.2.10 (magpie-community/plugins
a885a16) gives a team member with no limit of their own a fixed
On-demand window on the team's pool (pooledUsed / pooledLimit, the
member's own spend beside it) instead of unlimited, the same change as
the built-in's in the previous commit. keepMovedCurrent updates every
moved user's plugin to it.

Run: 0.2.10 checked on registry.npmjs.org (latest, its tarball holds the
fix); go test -tags nogui ./internal/provider/ under a sandbox HOME (ok,
TestMovedBuiltinsSayTheirPlugin included); gofmt -l and go vet on darwin,
linux (nogui) and windows clean.
2026-10-13 06:07:06 +08:00
yetone 9ddcee10ac provider: a Cursor Team member with no limit of their own spends the team's on-demand pool, shown and counted as the limit, not as unlimited (#1868)
PaSSw0rds' Team account (#1476) has on-demand turned on for the whole
organization: spendLimitUsage has no individualLimit, pooledLimit
"45120000" and pooledRemaining "38785730" are int64 strings, pooledUsed
6334270 a number, and GetHardLimit answers {"hardLimit": 451200} with or
without a team id. cursorOnDemandOf read that as unlimited, as
cursor-agent's own usage view does, so On-demand showed only the member's
$198.55 at 0%, aside, and a spent team pool never counted the account
used up; magpie would keep routing to it until Cursor refused.

Now a team member with no individualLimit and a pooledLimit > 0 gets a
fixed On-demand window on the pool: used = pooledUsed / pooledLimit,
display "$63,342.70 / $451,200.00 (you: $198.55)", not aside. A hard
limit that forbids on-demand still reads as disabled, and a team with no
pool and a hard limit still as unlimited. Dollar figures group thousands
(cursorDollars), as plugin 0.2.10 does. This is the built-in, for users
who haven't moved to the plugin; moved users get the same from
@magpie-community/opencode-cursor-auth 0.2.10 (next commit raises the
mover's min).

Run, under a sandbox HOME with pinned caches: go test -tags nogui
./internal/provider/ (ok); gofmt -l; go vet ./... on darwin,
GOOS=linux -tags nogui and GOOS=windows (clean).
Broken by hand: with the old cursor_usage.go,
TestCursorOnDemandKeepsTheAccount/a_team's_org-wide_on-demand_pool_is_the_allowance
fails (On-demand "$198.55", used 0, aside; the spent pool "used up
false"); with a fix that puts the member's spend against the pool, it
fails too. Built from the payloads quoted in #1476. Not tried against a
real Team account.
2026-10-13 06:07:06 +08:00
yetoneandmengyianx f31ae38aeb provider: Xiaomi MiMo is priced at xiaomi's list price, not its Token Plans' $0, and pay as you go looks only in xiaomi (#1873)
mengyianx found every pay-as-you-go MiMo call counted at $0.000:
models.dev's xiaomi-token-plan-cn, -sgp and -ams list all nine models
at cost 0 (the plan's per-token charge, not the model's price), the
preset's catalog was "xiaomi-token-plan-cn, xiaomi" at every region, and
catalog.PricedBy takes the first catalog with a cost field. makerCatalogs
puts the plan catalog ahead of xiaomi too, so the maker fallback gave $0
as well.

What changed:
- membershipCatalogs (never read for a price) gains the three
  xiaomi-token-plan catalogs, as #1370 did for Kimi Code. That covers
  ListPrice, MakerPrice and PricedName through makerPriceCatalogs.
  kimiCodeMember now checks a list of Kimi Code's plans of its own
  (kimiCodePlans), so a Xiaomi provider isn't taken for Kimi Code and
  its ids aren't mapped to Kimi's.
- Each Xiaomi region names its own catalog: plan-cn/sgp/ams
  "xiaomi-token-plan-<r>, xiaomi", pay as you go "xiaomi" alone. A plan
  user is priced at the API-equivalent price, the same meaning as #1370.
- PricedBy is unchanged: a catalog that lists a model at $0 still prices
  it at $0 (nvidia, modelscope have truly free models).
- docs/subsystems/providers-accounts.md says so.

Providers saved before this: the preset's own catalog stays
"xiaomi-token-plan-cn, xiaomi", the same string an existing provider
saved with the old default holds. normalize already lets a catalog that
equals the preset's or one of its regions' follow the region the
provider is at (the Tencent Cloud mechanism), on every read, so an old
default at pay-as-you-go reads as "xiaomi" and at Singapore as
"xiaomi-token-plan-sgp, xiaomi"; nothing is written to providers.json
until the user next saves it. Any other catalog the user typed is kept
as typed, and is priced right anyway because the plan catalogs are out
of pricing. The one value that can't be told apart is a bare "xiaomi"
typed at a plan region (the issue's workaround, which was for pay as
you go): it equals the pay-as-you-go region's catalog, so it reads as
that plan's "xiaomi-token-plan-<r>, xiaomi". Its prices are identical
either way; only the model-metadata lookup order differs. That is the
existing rule for every preset with region catalogs, kept rather than
special-cased.

Siblings: scanned the models.dev cache (read only) for catalogs whose
priced models are all or mostly $0. Of those, only kimi-code-plan-* and
xiaomi-token-plan-* are named by any preset or region. stepfun's
*-step-plan catalogs carry no cost at all, so they never shadowed a
price. alibaba/minimax/zai/zhipuai/volcengine/tencent coding and token
plan catalogs are all-$0 on models.dev but no preset uses them.

Tests (internal/provider/xiaomi_price_test.go, fixture
testdata/xiaomi_catalog.json cut from models.dev's real entries):
- TestXiaomiListPrice: every region, the old default, a user's own
  catalogs: mimo-v2.6-flash $0.14/$0.28/$0.0028, mimo-v2.6-pro
  $0.435/$0.87/$0.0036; MakerPrice; EffectivePrice of a saved provider;
  a relay's own $0 model ahead of xiaomi stays $0; a Xiaomi provider is
  not a Kimi Code member.
- TestXiaomiRegionCatalogs: each region resolves to its catalogs from
  the preset's, the old default and another region's; import links at
  each region; FromPreset; a user's catalog kept at two regions.

Broken by hand, each red, then restored:
- membershipCatalogs back to Kimi only: TestXiaomiListPrice FAIL, plan
  regions and MakerPrice at $0.
- region catalogs removed: TestXiaomiRegionCatalogs FAIL (api with the
  old default stays [xiaomi-token-plan-cn xiaomi], imports at sgp/ams
  get cn's).
- both: TestXiaomiListPrice FAIL, api with the old default at $0 (the
  reported bug).
- kimiCodeMember on membershipCatalogs: FAIL "a Xiaomi Token Plan
  provider counts as a Kimi Code membership".
- PricedBy's exact match skipping all-zero costs: FAIL "relay
  mimo-v2.6-flash: ... want its own $0".

Run: gofmt -l (nothing); go vet ./... on darwin, GOOS=linux -tags nogui,
GOOS=windows; go build on all three; go test -tags nogui -count=1
./internal/provider ./internal/catalog ./internal/cli ./internal/gui
./internal/usage, all ok, in a sandbox HOME with pinned caches.
Real use: built binaries before and after, sandbox HOME with a copy of
the real models.dev cache and a providers.json holding the reporter's
saved state. `magpie model price xiaomi/mimo-v2.6-flash` printed $0/$0
before and $0.14/$0.28 after; an old-default provider at Singapore went
$0 -> $0.14/$0.28 and shows catalog "xiaomi-token-plan-sgp, xiaomi";
one with the user's "openrouter, xiaomi" kept it; providers.json was
byte-identical afterwards. Not tried: a real MiMo key or call, the GUI
editor's region switch, the full go test ./... suite.

Co-authored-by: mengyianx <106875577+mengyianx@users.noreply.github.com>
2026-10-13 05:57:40 +08:00
yetone 304b347a39 tests: the skills-only and leftover-folder tests keep AppData in each case's own home, so Hermes isn't found from another test on Windows (#1388)
The same class as 7743c52e5 (syncHome), in two tests that don't use it.
On Windows Hermes keeps %LOCALAPPDATA%\hermes, and
TestSkillsOnlyFolderIsNotInstalled and TestLeftoverFoldersAreNotInstalled
left LOCALAPPDATA at the package's test home. The case's own home held
only skills (or cache, log, skills), but the shared folder held what an
earlier case or test had written there, so Hermes read as installed and
both tests failed on the Windows box, before and after RaykieLee's series.
ownAppData sets APPDATA and LOCALAPPDATA inside each case's home.

Run: go test ./internal/agent on macOS green. Windows box: both red
without this (main, and the series without it), green with it.
Windows box (Windows 11 x64, amd64 test binary of the whole package,
sandbox HOME/USERPROFILE/APPDATA/LOCALAPPDATA/TEMP): main plus the
series' base fails 21 tests; with the whole series only
TestInstallWithoutNodeParses (bash there is WSL's, whose default distro
has no /bin/bash) and the two TestReasonixCLI* (no Go on the box) fail,
both environmental and listed as untested by RaykieLee too.
2026-10-13 05:48:39 +08:00
yetoneandRaykieLee 688c062edf tests: the Codex process-list stale tests skip Windows, where the row's copy is the daemon's last check, tested on every OS (#1388)
TestCodexStaleOnlyForMagpiesChange, TestCodexStaleCopiesSayWhichIsLeft
and TestCodexDaemonHelperIsNoStaleCopy test copies told apart from the
process list. StaleCopies lists no processes on Windows (a PowerShell run
each look); there it returns codexDaemonBehind, the daemon as
KeepCodexDaemonCurrent last found it. So the three failed on Windows.

RaykieLee's f3e0672fd added Windows branches that seed codexDaemonSeen
with the answer and assert it back, so on Windows the tests named for
"only magpie's change" and "which copy is left" pass whatever those
guarantees do; its keepCodexDaemon mock is never called there, and one
branch leaves the seeded check behind for later tests. Taken instead:
the three skip on Windows and say why, and
TestCodexStaleOnWindowsIsTheDaemonsLastCheck drives the Windows path
itself, through codexDaemonCheck with keepCodexDaemon faked: none before
a check, none when not behind, the daemon (with its start) when behind,
none after CodexDaemonRestarted, none when magpie restarted it, none once
the check is older than three loops. It reads StaleCopies on Windows and
codexDaemonBehind elsewhere, and resets codexDaemonSeen when done.

Run: go test ./internal/agent on macOS green. Broken by hand, each red:
codexDaemonBehind ignoring Restarted, ignoring the check's age, and
CodexDaemonRestarted not clearing.
Windows box (Windows 11 x64, amd64 test binary of the whole package,
sandbox HOME/USERPROFILE/APPDATA/LOCALAPPDATA/TEMP): main plus the
series' base fails 21 tests; with the whole series only
TestInstallWithoutNodeParses (bash there is WSL's, whose default distro
has no /bin/bash) and the two TestReasonixCLI* (no Go on the box) fail,
both environmental and listed as untested by RaykieLee too. The three skip there
and TestCodexStaleOnWindowsIsTheDaemonsLastCheck passes.

Co-authored-by: RaykieLee <42793273+RaykieLee@users.noreply.github.com>
2026-10-13 05:48:39 +08:00
yetoneandRaykieLee 9650cd50c1 tests: the Aside offline tests refuse a write the way each OS does, and read the record's mode as Windows reports it (#1388)
On Windows six Aside tests failed: a directory's mode is ignored there,
so chmod 0500 on the record's folder refused nothing; os.Stat reports the
0600 record as 0666; and os.Symlink needs a right a test isn't given.

RaykieLee's 448967806 made the file itself read-only instead, on every
OS. That passes on Windows but turns four of the tests red on macOS and
Linux: edit.WriteAtomic renames a temporary file over the record, and a
rename over a 0400 file in a writable folder succeeds there, so nothing
is refused (TestAsidePostReadFailuresNeverOfferOffline/save_record,
TestAsideOfflineWriteFailureRollsBack,
TestAsideDisconnectUnavailableOnlyAtInitialRead/record,
TestAsideOfflineProviderWriteFailureRollsBackAllFiles; red at the
branch's own tip too). This keeps its Windows half and the folder elsewhere:
refuseWrites makes the folder unwritable on macOS and Linux, and the file
read-only on Windows, where neither a write nor a rename replaces it.
recordPerm wants 0666 on Windows. The provider-file test links its target
with a symlink, or a hard link on Windows, and refuses the target the same
way.

Run: go test ./internal/agent on macOS green; with refuseWrites a no-op
all four go red.
Windows box (Windows 11 x64, amd64 test binary of the whole package,
sandbox HOME/USERPROFILE/APPDATA/LOCALAPPDATA/TEMP): main plus the
series' base fails 21 tests; with the whole series only
TestInstallWithoutNodeParses (bash there is WSL's, whose default distro
has no /bin/bash) and the two TestReasonixCLI* (no Go on the box) fail,
both environmental and listed as untested by RaykieLee too. The six Aside tests are
among the 21 and pass.

Co-authored-by: RaykieLee <42793273+RaykieLee@users.noreply.github.com>
2026-10-13 05:48:39 +08:00
RaykieLee 5cb5b6b7ae tests: syncHome scopes APPDATA and LOCALAPPDATA into the per-test home 2026-10-13 05:48:39 +08:00
RaykieLee bac0ccb905 tests: Zed's relative config dir falls back to its Windows default 2026-10-13 05:48:39 +08:00
RaykieLee 5415e5473b tests: the Codex fixtures' Windows paths are quoted for TOML 2026-10-13 05:48:39 +08:00
yetoneandparkavenue9639 3b3dd47370 gui: the panel's usage rings are round on a 1x screen; the inner circle is 28px, so the band is a whole 3px a side (#1735, beansiayo)
A ring is .pq-dial (34px) with .pq-dial b (27px) over it. 34 - 27 is odd,
so the band was 3.5px a side and the inner circle sat on a half pixel. At
device scale 1 (an external 1080p display) each edge rounded its own way,
and the band came out 4, 3, 3 and 4 pixels left, right, above and below:
the slightly oval ring beansiayo saw. At 2x every edge falls on a whole
device pixel, which is why the built-in Retina screen looked fine.
parkavenue9639 found the cause and the fix: a 28px inner circle makes the
band a whole 3px.

quota-dial.test.cjs paints the band and the inner circle in flat colours
(sizes untouched), screenshots each ring in the panel and counts the
band's device pixels on each side of the inner circle, at device scale 1
and 2, Chromium and WebKit, en and zh.

Run: quota-dial.test.cjs on main's app.css fails all four (1x
{"left":4,"right":3,"top":3,"bottom":4}, the contributor's numbers); with
28px all four pass (1x 3/3/3/3, 2x 6/6/6/6). quota-pools, panel-usage,
quota-families and quota-curve pass (16). Screenshots looked at by eye.
Not tried on a real external 1x display.

Co-authored-by: parkavenue9639 <92194680+parkavenue9639@users.noreply.github.com>
2026-10-13 05:48:39 +08:00
yetoneandjueda12 743e330085 gateway: a system prompt or message that only quotes a compaction prompt is no longer taken for a compaction; the prompt must lead (#1635, jueda12)
What: compacting() looked for an agent's compaction prompt anywhere in the
system prompt (strings.Contains) and its ask anywhere in the last user
message. Minis puts the user's memory after its own prompt in every request,
so a memory that held Minis's compaction line made every turn of that
conversation a "compaction", routed to the compaction rule's model (28
requests in a row in the report, one with 4 tokens of chat). Now:
- a compactSystems prompt counts only when it begins within compactLead
  (2048 bytes) of the system prompt's start: alone, or behind a short lead
  (Claude Code's billing header and identity line, which its Anthropic
  system blocks join with no separator, so a line-start check would miss it);
- a compactAsks ask counts only when it begins within compactLead of a text
  part of the last user message (Claude Code 2.1.296 puts its ~420-byte
  "CRITICAL: Respond with TEXT ONLY" preamble first; Codex and Kimi start
  the part with it). Minis's END OF CONVERSATION TO COMPACT. follows the
  whole conversation in one part, so it counts only in a part that opens
  with Minis's own "Compact this conversation into a context summary:".
- Kimi Code's own compaction system prompt (kimi-cli 1.52.0,
  soul/compaction.py COMPACTION_SYSTEM_PROMPT) is added, so Kimi stays found
  without relying on the ask's part alone.

The approach (a leading window instead of the whole prompt) and the test
TestCompactingIgnoresQuotedPromptInSystem are jueda12's. Their sample put the
quote ~30 bytes into a short system prompt, which a leading window still
takes, and no rule can tell that apart from a short real lead; the test puts
the memory behind a long agent prompt, as Minis sends it.

Run (go1.26.8, sandbox HOME, private GOCACHE):
- the prompts were checked against the installed Claude Code 2.1.296
  binary (the hnn preamble, then "Your task is to create a detailed
  summary…") and kimi-cli 1.52.0's compaction.py (prompt in its own part).
- break checks: main's compacting.go -> TestCompactingIgnoresQuotedPromptInSystem
  FAIL (memory, claude code taken; kimi not taken) and
  TestCompactingAsksWhereTheAgentPutsThem FAIL (minis marker quoted, ask deep
  in a paste); leads() without the window -> the same, minus Minis; the
  Minis opens check dropped -> "minis marker quoted: taken for compacting".
  Restored: pass, with TestCompacting, TestCompactingMinis, TestRuleCompact,
  TestCompactionBrokeOffKeepsTheStick.
Not run: a real Minis client (the reporter offered to check with the
memory that still holds the line).

Co-authored-by: jueda12 <180685381+jueda12@users.noreply.github.com>
2026-10-13 05:48:39 +08:00
NineSu df29a511e6 gateway: Claude Desktop's model menu names a model as the agents' lists do, by the Provider in model names setting (#1746, marsxxl)
/v1/models for claude-desktop named every model by its own name alone,
with its provider's id in parentheses only where two read the same
(desktopNames, 03421f9f), so with the setting on Codex's list said
"Grok 4.7 @ 500k · Cursor" while Desktop's menu said "Grok 4.7 @ 500k",
and only same-name models got "(cursor)" (Gemini 3.8 Flash (cursor),
(antigravity)). The menu now names models as every agent's list does
(provider.Labels): on, the name with its provider's display name after
it; own, a name the user gave as they wrote it and a vendor's with its
provider's; off, plain names — and two of one name keep their provider's
so they stay apart, while where that still leaves two alike (one
provider's models named alike) the whole catalog id follows, for
Desktop's menu shows the name alone. 蓝猫's plain names (03421f9f) are
the setting's off; a user-given name that already says its provider is
left without it, as Label does everywhere.

Nothing changes for ids, routing, tiers, the 1M listing or the effort
picker. A model whose id reads as one of Desktop's own Claude models is
still renamed by Desktop's own catalog there ("Opus 5.5"), which no
gateway can reach; every other model's display_name is rendered, as the
reporter's "(cursor)" names show.

What was run: go test ./internal/gateway/ -count=1 (ok, 209s) with the
rewritten TestClaudeDesktopPickedModels and TestDesktopNames and the new
TestClaudeDesktopNamesFollowSuffixMode (on/own/off through /v1/models
with the claude-desktop key, red before the change); go test
./internal/provider/ ./internal/agent/ ./internal/codexcat/ -count=1
(ok); HOME=<temp> go test -tags nogui -count=1 ./... (ok, no FAIL);
gofmt -l clean; go vet on darwin, GOOS=linux and GOOS=windows. The
desktop GUI .cjs tests were not run (no playwright in this checkout):
they fake the backend and no GUI file changed. Not tried against a real
Claude Desktop: that it renders these display_name values is from the
reporter's screenshot, whose "(cursor)" names were this same field.
2026-10-13 05:48:39 +08:00