Commit Graph
3679 Commits
Author SHA1 Message Date
yetone 0f398c4895 gateway: a group member whose window can't hold the request isn't asked it (dgqyushen on Discord)
dgqyushen on Discord: OpenCode Zen's free DeepSeek V4.1 Flash (200K)
first in a group and a 1M DeepSeek subscription second, so that the
first 200K go free and past that go to the subscription.

The gateway fell over only on a refusal it reads as too long (#700,
withRoom/failOverflow, tooLongUnsaid past 1.2x the window). A vendor that
refuses a request just past its window without saying why (between 1.0x
and 1.2x) reached the agent as that error while the next member had
room, and every doomed request spent one against the free tier's limits.

roomy (fallback.go), in serve after rules, affinity, the image filter and
pinTo and before probeOne, estimates the request as the overflow path
does (estimate) and leaves out the candidates whose known window
(windowOf: Contexts, the catalog, ContextOf) is no larger, and their
order rows with them. It is a check before sending, not a retry. Kept:
a window not known, a body that doesn't parse, a single model, and a
request no candidate holds (the first is asked, its overflow told to the
agent to compact). A conversation stuck to the small member by affinity
moves once it outgrows it. count_tokens (a count on the first member) and
System One's decision models don't go through serve's candidate path and
are left alone; every generation route (middleware, classify, search,
vision, codex titles/backend, auto groups) goes through serve. No UI
change: a member left out is absent from the route's order.

TestPayloadTooLargeOverWindowTriesMemberWithRoom now expects the members
too small not to be asked at all (c only, one try).

Run:
- go test -tags nogui -p 1 ./internal/gateway -run
  'TestMemberTooSmallIsNotAsked|TestConversationOutgrowingItsMemberMoves|
  TestRoomyLeavesWhatItCantJudge|TestPayloadTooLarge': ok
- the overflow tests (TestPayloadTooLarge, TestOverflow,
  TestContextOverflow, TestEveryVendorsOverflow, TestCodexOverflowInGroup,
  TestStreamOverflow, TestRateLimitNotContextOverflow) with the new ones:
  ok
- gofmt -l clean; go vet ./internal/gateway (darwin); GOOS=linux and
  GOOS=windows go vet -tags nogui ./...: clean; go build darwin, linux,
  windows: ok.
Broken by hand: the roomy call in serve commented out:
TestMemberTooSmallIsNotAsked red (400 "FREE: Invalid request
parameters"), TestConversationOutgrowingItsMemberMoves red (free 2,
paid 0), TestPayloadTooLargeOverWindowTriesMemberWithRoom red (a 1, c 1,
2 tries); restored, all green.
Not run: the whole internal/gateway package (the run failed to build,
"no space left on device", the disk at 0 GB free) and the full suite
(left to the batch's run). Not tried against the real OpenCode Zen.
Known: the estimate is bytes/4, so mostly-CJK text counts high and a
member may be passed over a little early.

Full suite: SUITE_LINE
2026-10-15 23:08:03 +08:00
yetone 62020b9c26 gateway: a chat request to DeepSeek that asks max_completion_tokens reaches it as max_tokens, not ignored at DeepSeek's 8K default (#2355, h4rk8s)
DeepSeek's chat API reads the reply length from max_tokens only (its
create-chat-completion docs list no max_completion_tokens). A Chat client
that asks OpenAI's way, as DSH's pi-ai does for a custom provider at
magpie's address, had the field passed through as it came, so DeepSeek
fell back to its default: the reporter's non-thinking turn asked 393216
and stopped at length after 8192.

deepseekTokenField (deepseek_schema.go), in forwardOnce beside
deepseekToolPatterns, renames the top-level key in place when the
provider is the deepseek preset or api.deepseek.com and the wire is Chat.
Only the key's bytes change. A request that names max_tokens too goes as
it is, since DeepSeek reads that one. Other vendors' chat APIs are not
touched (OpenAI's and Azure's want max_completion_tokens; Bedrock/Azure
keep asCompletionTokens). A request translated from another protocol
already went out as max_tokens (buildChat), so passthrough was the only
path that missed it.

Tested: TestDeepSeekChatGetsMaxTokens, through New().Handler() with the
deepseek preset on a fake upstream: max_completion_tokens (also with
spaces around the colon) arrives as max_tokens; max_tokens alone and both
fields go as sent; a custom provider gets max_completion_tokens
unchanged; a message whose text says "max_completion_tokens" keeps it.
Broken by hand: the forwardOnce call removed -> FAIL "upstream got
{...max_completion_tokens":393216...}"; the DeepSeek scope dropped -> FAIL
on relay/m; the max_tokens-present guard dropped -> FAIL on the both-
fields case. go test -run 'DeepSeek|MaxOutput|Tokens|Bedrock|Azure|Chat'
./internal/gateway ok; gofmt clean; vet darwin/linux/windows on gateway
ok. Not tried against the real DeepSeek API: the owner's key answers 402
Insufficient Balance to both fields.

Full suite: SUITE_LINE
2026-10-15 23:08:03 +08:00
yetone 0889fdb844 agent: a model picked for dsh says that a session made before keeps its model, also with no dsh running, and how to switch it there (#2359, IanLi592)
IanLi592 picked a non-DeepSeek model for DeepSeek Harness in magpie, went
on in a workspace's session made earlier, and it still went to DeepSeek on
their DeepSeek key. That is dsh's design: magpie writes
agent-default-model in the profile's cordis.patch.yml, which dsh reads for
new sessions only; a session keeps the provider/model in its own log
(dsh-agent-default-model README: "An existing session whose request log
already names a selection keeps that selection"; dsh-client-ui-model-
selection: switch with /model or the composer's model control). Read in
dsh 0.2.0-rc.2's installed packages.

magpie told them so only while dsh was running (Running gate in dsh's
Notice), and said "one already open", while a closed session reopened later
keeps its model too. For dsh 0.1.5+ (a profile patch exists) the notice is
now given after every pick, and says a session made before keeps its
model, open now or reopened later, until /model or the model button by its
message box picks another. Before 0.1.5 the restart advice stays as it was,
given while dsh runs. Session logs are dsh's and stay untouched. Strings in
zh, zh-TW, ja, de and NOTICES.

Tested: TestDshPickSaysOldSessionsKeepTheirModel (sandbox home with a web
profile, Running stubbed false). With dsh.go and i18n.js put back it fails:
"a pick says nothing of the sessions dsh already has: \"dsh's web search
goes through magpie, ...\"". go test -run 'TestDsh|TestEveryNoticeIsTranslated'
./internal/agent ok; agent-notice-lang and i18n-keys GUI tests pass in
Chromium and WebKit (14/14 each); gofmt clean; vet darwin/linux/windows on
internal/agent ok. Not tried in the real dsh app (the notice is magpie's
text; dsh's behaviour is from its own package docs).

Rebased onto 370eaba97: dsh's Notice keeps the base's first branch (a
desktop app never opened says noticeDsh5 alone, #2279), then this
commit's profile-before-Running order; the zh/zh-TW/ja/de NOTICES
entries keep the new noticeDsh5 string beside the reworded noticeDsh1.
TestDsh and TestEveryNoticeIsTranslated: ok.

Full suite: SUITE_LINE
2026-10-15 23:08:03 +08:00
yetone 6f87624dbf library: the three Windows-red tests write Hermes and Codex fixtures where those apps do, not the Unix layout (#2275)
All three were test fixtures, not magpie writing a bad file.

TestHooksCodexTrustMovesWithTheGroups wrote Codex's [hooks.state."<path>"]
keys itself as basic strings, so on Windows "C:\Users\..." held \U, and
toml read the test's own file as broken ("toml: non-hex character").
Codex doesn't write that. Driving the real `codex app-server`
(0.162.1, config/batchWrite on hooks.state, as its /hooks does) under a
sandbox CODEX_HOME shows its toml_writer spelling: a basic string when
nothing needs escaping, a literal string ('C:\Users\x\...') when a
backslash does, and an escaped basic string ("C:\\Users\\O'Brien\\...")
when the key has an apostrophe too, under a bare [hooks.state] header.
codexKey in the test now spells keys that way, and the test runs for
the default home, a CODEX_HOME with a backslash in it and one with an
apostrophe as well, so macOS and Linux exercise both quoted forms too.
codexRekey already reads both and rewrites only the key's tail, so the
spelling is kept.

Every place magpie writes a path into TOML was checked: edit.tomlString
(every edit.KV string value, model_catalog_json among them),
library/mcp.go tomlString/tomlKey, provider/devin.go tomlString all
escape backslashes; the strconv.Quote writers (grok/kimi/atomcode/jcode/
reasonix/codex reasoning efforts, Grok hook blocks) write model ids,
efforts and commands, where a backslash comes out as \\ too. None writes
an unescaped path, so no writer changes.

TestAgentsSkillsFolders and TestTargetsLeaveGoneAgentsOut wrote Hermes's
config.yaml into ~/.hermes, but Hermes's folder on Windows is
%LOCALAPPDATA%\hermes (appdir.HermesHome). There Hermes wasn't there at
all: its skills folder was the Windows one, and Takes for an agent with
no folder says yes rather than "isn't installed". Both now write into
appdir.HermesHome(), and TestTargetsLeaveGoneAgentsOut first checks
Hermes is detected by that config, so a fixture in the wrong place fails
as that rather than as a Takes result.

Run:
- Windows 11 box, test binaries cross-built (GOOS=windows -tags nogui),
  fresh USERPROFILE/HOME/APPDATA/LOCALAPPDATA/TEMP each run, cwd with
  internal/library/testdata:
  - origin/main 2b0037f41: the three fail as in the issue.
  - this change: the whole internal/library package PASS.
  - this change with codexRekey's literal-key branch disabled by hand:
    TestHooksCodexTrustMovesWithTheGroups/default and /backslash FAIL
    ("keeps Codex's trust of ... in a way magpie can't move").
- macOS: the same break fails /backslash; restored, all pass.
- real codex 0.162.1 app-server in a sandbox HOME/CODEX_HOME for the
  three key spellings above.

- macOS, rebased on origin/main 9d97fd073: gofmt -l prints
  nothing; go vet -tags nogui ./internal/library for GOOS=darwin, linux
  and windows ok; go test -p 1 -count=1 ./internal/library ok (132s)
  in a sandbox HOME/TMPDIR with Go's caches pinned.
- Full suite: SUITE_LINE
2026-10-15 23:08:03 +08:00
yetone ff670797a1 gui: an update found waits for Download update when Settings' Download updates automatically is off (#2296, meifu2027)
On a metered network or a proxy billed by traffic, a newer version was
downloaded as soon as a check found it, by the clock or by Settings'
Check. Settings → About now has "Download updates automatically", on by
default (as before). Off (settings.json noAutoDownload):

- a check, by the clock or by a click, only reports the version: the
  version row says "{v} is out · {size} MB" with its notes, and the
  header's Update pill shows; the updater's state is "found";
- "Download update" on that row, or a click on the pill, posts
  update/install, which downloads it (updater.download) as a retry does;
- a version downloaded on a click stays ready: a newer one found later
  isn't fetched over it;
- a settings save that doesn't send the field keeps it (api.go), so an
  older page can't switch it back on.

CLI: `magpie update auto notify|download` sets it, and the status says
which. The proxy-change retry in api.go goes through the same run, so it
respects the setting too.

hold() (the click guard that keeps what was clicked in place) took a
zero-height element as its anchor: the empty .val beside Settings' Add
to PATH. "Moved by less than half its height" never held for it, so
once the new row made About 27px taller than a 900x760 window, the click
slid the view 11px off its top (cli-path.test.cjs, red on this branch,
green on origin/main where About couldn't scroll). hold now prefers an
anchor with a height, and falls back to the old choice.

Run:
- go test -tags nogui ./internal/gui ./internal/cli ./internal/settings
  (sandbox HOME): ok (gui 547s, cli 678s; settings ok 253s). A first run
  with the default 10m timeout lost cli to it at load ~100
- TestUpdateDownloadWaitsForAClick broken by hand three ways, red each
  time: no `case hold` (Check gave ready, 1 download); no api.go keep
  ("a save without noAutoDownload turned it off"); no `|| hold` ("a
  newer one, downloads held: found 0.1.12").
- gofmt -l clean; go vet -tags nogui for darwin, linux and windows on
  gui, cli and settings: ok.
- GUI: update-download.test.cjs (en, zh, zh-TW, ja, de at 1100 and 420)
  passes in Chromium and WebKit; breaking the found case times it out.
  cli-path, click-scroll and update-download pass in both engines after
  the hold fix. Every GUI test that checks scrolling (327
  files): Chromium 2261 pass, WebKit 2263 pass,
  6-wide at load ~100. Red: refusal-retries-setting ja 420 (#2258; base
  95e7c6bcc red 2 of 3 alone too), usage-agents-hide (#2276) and
  usage-fold (#2163), red alone on base as well; fonts (chromium) and
  sessions-manage-paging (webkit zh) red only in the loaded run, green
  alone twice on both. gui-ja, gui-de, gui-zh-tw, i18n-keys and
  update-stuck: 32/32 in each engine.
- Not tried: a real metered connection or a real release download.

Full suite: SUITE_LINE
2026-10-15 23:08:03 +08:00
yetone 0dbb1a8490 library: subagents are written once and given to every agent in its own format, with what each agent can't bind shown (#2283, chuanchinatest)
The Library has a Subagents tab beside Hooks. A subagent is a name, a
description, a prompt, and the library's skills and MCP servers it uses.
magpie writes it to each ticked agent's user-level folder in that agent's
format, rewrites it on every change, and takes back only files it wrote.

Where each one goes (syncSubagents, subagentSpecOf):
- Claude Code: ~/.claude/agents/<n>.md, with skills and mcpServers
- Codex: $CODEX_HOME/agents/<n>.toml (name, description, developer_instructions)
- OpenCode: ~/.config/opencode/agents/<n>.md (mode: subagent)
- Gemini CLI ~/.gemini/agents, Qwen Code ~/.qwen/agents, Grok ~/.grok/agents,
  Cursor ~/.cursor/agents, Copilot CLI ~/.copilot/agents/<n>.agent.md
- Factory Droid: ~/.factory/droids/<n>.md, with mcpServers
Skills and servers are named only where the agent's file can name them.
The page says, per agent, which of the two it won't bind, and that only
the Cursor app reads ~/.cursor/agents (cursor-agent reads a project's only).
Agents in WSL and agents with no user-level folder are greyed out.

The user's own files: every file is recorded by the hash of what magpie
wrote (Applied.Subagents). A same-name file of the user's is never written
over (the agent gets a problem). A file the user edited is theirs from then
on: it is neither rewritten nor removed. A carried library doesn't carry
subagents yet (as with hooks).

The Library's tabs now wrap onto a second line rather than scroll a narrow
window sideways (eight tabs in German at 560px). library-servers-bulk's
window goes from 1000 to 1100px tall to keep its stated premise that the
whole list fits.

Run:
- gofmt -l, and go vet -tags nogui for darwin, windows and linux: clean.
- go test of internal/library, internal/gui and the packages that import
  internal/library, at this head: green.
Full suite: SUITE_LINE
- New tests: TestSubagentsEachAgentsFile, TestSubagentsLeaveTheUsersFiles
  (covers the user editing magpie's file and then a sync), TestSubagentCheck.
- GUI: library-subagents (new) passes in Chromium and WebKit, at 1100 and
  420, in en, zh, zh-TW, ja and de. Also all library-*, gui-ja, gui-de,
  gui-zh-tw, i18n-keys, images-library-way, skill-* and mcp-* tests pass.
  Greying out the WSL agent was broken by hand, and library-subagents
  went red.
- Real binaries in a sandbox HOME against a fake upstream: each one sees
  the subagent magpie wrote.
  - Claude Code 2.1.300: it is listed in the system prompt.
  - OpenCode 2.0.25: debug agents.
  - Grok 1.0.50: grok inspect.
  - Codex 0.162.1: spawn_agent's roles, with --enable multi_agent_v2. v1
    showed no spawn_agent with a custom provider.
  - Gemini CLI 0.63.0: <subagent> in the request.
  - Qwen Code 0.21.9: its agent types.

Not tried: Factory Droid and Copilot CLI (both need a sign-in; Copilot
stops on auth before it reads agents), and the Cursor app.
2026-10-15 23:08:03 +08:00
yetone c14842fbb7 routing: a try the gateway went on from says it went on, not that the agent got it (#2281, xishuchkui-code)
xishuchkui-code's Antigravity account answered 502 with an empty reply,
which doesn't rest it; the gateway went on to the next account and that
one answered. The Routing page's story said "answered 502 — an error
another account wouldn't fix, so Claude Code gets it" (换账号也无法解决,
Claude Code 收到此错误), and the account's row said "502 · failed ·
passed to Claude Code". Both guessed the outcome from where the try stood
in the order (not last, no rest, no retry), not from what the gateway did.

What came of a try is now read from the record. The gateway appends a try
to Route.Tries only as it asks it, so a later try is the request going
on; with none, the error ended the request, the agent's once the route
is done. No marker was needed for that. The one case the record can't
show is the `other` hand-back: the last try left, out of its allowance
after an earlier failure that wasn't one, while the agent is told the
earlier error (Discord, waroy). That try is now marked Try.Earlier.

Siblings in trySaid that guessed the same way:
- a try that went on with no rest: "answered {status}, and the request
  goes on to {next} … doesn't rest for it" (was "wouldn't fix … gets it");
- a resting try with nobody after it (the last key, #1772) said the
  request goes on to "the next"; it now says nobody is left and the
  agent gets the error;
- slow to begin with nobody left said it went on to the next; same;
- the Earlier try says the agent got the earlier try's error;
- a failed try with no next on a route still running says only what it
  answered.
The account row: "passed to {agent}" only for the route's last try once
it is done; a try the gateway went on from says "{status} · {fail} ·
went on to the next". Usage's request detail only shows the gateway's
"answered on a retry" counts and the CLI/TUI don't tell tries, so neither
changes. 6 new strings, in en, zh, zh-TW, ja and de.

Run at this head (rebased on origin/main 95e7c6bcc):
- gofmt -l . clean; go vet ./... on darwin, GOOS=linux -tags nogui,
  GOOS=windows: all 0.
- go test of internal/gateway and internal/gui under a sandbox HOME:
  ok on af9bd6c3e (gateway 600s, gui 123s). After the rebase onto
  95e7c6bcc, gui ok (608s); gateway ran out its 25m and then 30m
  -timeout with no test failed (the alarm caught TestTextWrittenCallWhole
  4s in), at load average ~100 with ~15 other go test runs going, and
  was not run again: free disk fell to 2.7G.
- routing-went-on.test.cjs (new): 20/20 in Chromium and WebKit, en, zh,
  zh-TW, ja, de, 1100 and 420. It fails on the old client.js with the
  reporter's own words ("…返回 502,换账号也无法解决,Claude Code 收到此
  错误。"), and with only the old row line put back it fails on
  "502 · failed · passed to Claude Code".
- TestCodexSpentGrokFailingIsTold now asserts Earlier; with the gateway
  line reverted it fails.
- routing-*, panel-routing*, gui-de, gui-ja, gui-zh-tw, i18n-keys in
  both engines, after the rebase: Chromium 513/514, WebKit 512/514
  (before it: 513/514, 510/514). WebKit's two after the rebase are
  routing-model-rest de ("the Opus row doesn't rest"), red on
  95e7c6bcc too (1 of 3 runs, alone; #2115 has it in Chromium). The reds are
  routing-held-member at 420 in WebKit (#2252; also 2-4 red per run on
  origin/main 707fbb249, alone, 4 runs) and routing-wb-restricted's
  wheel-scroll "button can't be reached" (#1905; 4/4 green alone on both
  this branch and main 707fbb249, alternated). routing-proxy and
  routing-shape asserted the failed member's tag, which only appeared in
  the wrong "passed to" row; the went-on row keeps it and both pass.
Not tried: a real Antigravity account answering empty; the fixture is
the reporter's case as the trace records it.

Full suite: SUITE_LINE
2026-10-15 23:08:03 +08:00
yetone 0fe7892320 library: shared instructions can be given to Alma, after the profile in its ~/.config/alma/USER.md (#2315, Jie211)
Alma had no instructions target: the library said it "has no user-wide
place for instructions". Alma 0.4.164's own main process
(out/main/index.js in its app.asar) does read one. Its main chat puts
~/.config/alma/USER.md into the system prompt as "USER PROFILE (your
owner/primary user...)", or a workspace's USER.md in its place. Alma's
prompt calls the file "your owner/primary user's profile (name,
preferences, habits - editable)". Its leading front matter (name,
telegram_id, discord_id, matched with ^---\n...\n---) is who its bots
answer to.

So Alma's target gets Instructions = ~/.config/alma/USER.md and a new
Profile flag:
- magpie's part goes after the user's, so the front matter stays first
  and Alma still finds its owner. Turning Alma off leaves the file as it
  was. A USER.md magpie made holding only its part is taken away again.
- ImportInstructions refuses a Profile target. Moving the user's lines
  out would take the front matter out of USER.md and put the owner's
  telegram/discord ids into every agent's file. The page hides "Move its
  own into the shared text" for it (AgentInstructions.Profile), and adds
  an aside in en/zh/zh-TW/ja/de. The aside says the file is Alma's
  profile of the user, and a workspace USER.md is read instead.

Not tried with the real Alma app. Its live ~/.config/alma was not touched.
What Alma reads was taken from its bundled source. Sub-agents are not
confirmed to read USER.md.

Tests (sandbox HOME, Jie211's own line as the shared text, a USER.md in
the shape Alma's setup writes):
- TestTakesAlma
- TestAlmaInstructionsKeepTheProfile: the front matter is still matched
  by Alma's own regexp after the sync; turned off, the file is the same
  bytes.
- TestAlmaInstructionsWithoutUserMD
- TestAlmaProfileIsNotImported
Broken by hand:
- the Profile check in ImportInstructions taken out:
  TestAlmaProfileIsNotImported goes red;
- Alma's Instructions path taken out: TestTakesAlma and
  TestAlmaInstructionsKeepTheProfile go red.

Ran (at the reviewed head, on origin/main 01c41e8ba): go test -p 1 -tags nogui ./internal/library ./internal/provider ok; library also ok in 5 of 6 -count=1 reruns after the rebase. The 1 red run came while ~1G of disk was free, and its output was not kept; the new Alma tests passed in every run. gofmt -l clean; go vet -tags nogui GOOS=darwin/linux/windows ok; node --test internal/gui/tests/library-*.test.cjs (33 files, chromium and webkit) 518 pass, 0 fail; library-alma-profile.test.cjs went red with the !a.profile guard taken out by hand.
Full suite: SUITE_LINE
2026-10-15 23:08:03 +08:00
yetone 299498dec1 gateway: a compaction magpie summarises itself tells the provider it is a local one, not Codex's remote compaction_v2 (#2352, yhxwyzm; #1171, tcxp001)
Codex Desktop 26.1007 marks a compaction for a provider named "OpenAI"
with a compaction_trigger item and turn metadata saying
compaction.implementation "responses_compaction_v2", in both
client_metadata["x-codex-turn-metadata"] and the X-Codex-Turn-Metadata
header. When 原生压缩 is off, magpie replaces the trigger with its own
summary prompt and sends tools [], but it forwarded the metadata
unchanged. The request then said "remote compaction" and carried no
trigger, a shape Codex never sends. Codex 0.162.1, captured in a sandbox
against a provider not named OpenAI, says "responses" for the summary it
asks for; under the name OpenAI it sends the trigger with
"responses_compaction_v2". Neither the #292 test nor the #1171 test
carried client_metadata, so neither saw this.

codexInputAs (both the ChatGPT-backend path and /v1/responses) now sets
implementation to "responses" in the body's turn metadata, and
codexCompact does the same in the header. Every other byte of the
metadata is unchanged, including mcp_attribution and
guardian_credits_requested. With native compaction on, the trigger and
its metadata still go as Codex sent them.

The fixture testdata/codex-26.1007-compaction.json uses the reporter's
own bytes from the Routing page bodies attached to #2352 (on.txt and
off.txt): four history items, among them an mcp__fastctx call with its
list output, and the client_metadata as sent. The fake upstream refuses
with the relay's words when a request says responses_compaction_v2 and
has no trigger.

Not verified against Anyrouter itself. The reporter says the error text
is the same with native compaction on, and there magpie sends the
trigger as an OpenAI-named Codex would; that path is unchanged. If the
relay doesn't take remote compaction at all, this commit doesn't help
there.

Run (worktree on origin/main 35aa50cfb, -p 1 -tags nogui, sandbox HOME):
- go test ./internal/gateway -run 'TestLocalCompaction|TestNativeCompaction|Native|Compact|TestSearchHistory|TestCodexOpenAIFields|TestCodex|ClientMetadata|Bare': ok (308 tests match the pattern)
- gofmt -l: clean; go vet for darwin, linux and windows: clean
Broken by hand: I turned off the codexInputAs rewrite, and then
separately the header rewrite in codexCompact. Each time
TestLocalCompactionSaysLocal went red on both paths with
400 "Fake: invalid codex request".

Full suite: SUITE_LINE
2026-10-15 23:08:03 +08:00
yetone 357ffac7be usage: a model's Same as prices its calls when no list does (#2344, liuweifeng)
A model a provider serves under its own id (a WorkBuddy kimi-k3-1, a
relay's renamed gpt) had no price unless the user typed one, even when the
user had already told magpie in the editor's "Same as" box which model it
is. Its calls showed no API-price cost in Usage, window holds had no price
to weigh, and `magpie model price` said unpriced.

Now, when neither the user's prices, the provider's list nor models.dev's
maker price covers a model, provider.SamePriceIn takes the maker's list
price of the model it is the same as (settings.ModelSameAs), and the
provider's price rate still applies. A price the user set, or a list that
prices the model, always wins; nothing is inferred without a Same as.
The same fallback is used by priceOf (Usage costs, re-priced when the
ledger is read, so past calls pick it up), usage's apiPricer (window
holds), the model editor's greyed list price, and `magpie model price`,
which names where the price came from. The "Same as" tooltip says so in
en, zh, zh-TW, ja and de.

Run:
- go test -p 1 -tags nogui ./internal/provider ./internal/usage
  ./internal/cli ./internal/gui (focused: TestSameAsPricesAnUnlistedModel,
  TestHoldsPriceTheModelItIsTheSameAs, TestModelEditorShowsTheSameAsPrice,
  TestModelPriceCmdSaysWhereThePriceCameFrom, plus the packages): ok
- GUI (chromium + webkit): provider-same-as, i18n-keys, model-price-edit,
  11/11 pass
- gofmt -l clean; go vet -tags nogui for darwin, linux, windows: clean

Broken by hand, each went red:
- SamePriceIn dropped from priceOf: "kimi-k3-1 ... false; want $0.3"
- usage's apiPricer fallback removed: "wasn't its API price: <nil>"
- the GUI editor branch removed: "list <nil>"
- the CLI source line disabled: TestModelPriceCmd... FAIL
- the zh tooltip left untranslated: provider-same-as.test.cjs 0/2
A prefix-stripping branch passed when removed (MakerPrice already resolves
vendor-prefixed ids like moonshotai/kimi-k3), so it was dropped.

Not tried: a real WorkBuddy account's usage after the change.

Full suite: SUITE_LINE
2026-10-15 23:08:03 +08:00
yetone 0c0665126b quota: magpie quota --json and /v1/magpie/quotas tell each window's whole (holds / holdsWhy) as the Usage page does (#2333, zhenghaowen0967)
usage.WithWindowHolds reckoned a subscription window's whole (tokens, and
cost at API list prices) from magpie's own calls, or why it can't, but
only GET /api/usage/quotas and its refresh called it. magpie quota --json,
GET /v1/magpie/quotas and its ?kept=1 list showed name, used, remaining
and resetsAt only, so a script comparing plans had to rebuild the estimate
from the log without its guards.

Package provider can't import usage, so usage sets provider.ReckonHolds in
an init (like the other provider hooks). quotaReport, which QuotaReport,
KeptQuotaReport and RefreshReport share, runs it once over every card and
QuotaSpan carries Holds and HoldsWhy. The log is read through usage's
cached snapshot, so ?kept=1 (magpie statusline, every message) adds no full
read after the first. A key held to a budget, models or accounts and told
cards (#2216) is not told holds: they are reckoned from every call routed
through the account, other keys' too, so quotaScope.quotas drops them;
this machine and unheld keys get them.

The Balance guard in holdsBounds (a Codex account holding credits gets no
whole and no reason) is unchanged; it is answered on the issue.

Docs: reference.md's /v1/magpie/quotas section names holds/holdsWhy and
each reason; providers-accounts.md's Allowance row names the hook.

Run (sandbox HOME, -tags nogui, -p 1):
- New TestQuotaReportTellsWindowHolds (provider), TestQuotaReportsReckonByTheLog
  (usage, against a real usage.jsonl in the sandbox) and
  TestHeldKeyToldNoWindowHolds (gateway) pass.
- Broken by hand: the ReckonHolds call in quotaReport skipped → provider
  test FAIL "reckoned 0 times over 0 cards"; Holds/HoldsWhy not copied into
  QuotaSpan → FAIL "5 hours told no whole"; usage's init removed → usage
  test FAIL "provider.ReckonHolds isn't set"; quotaScope not clearing them
  → gateway test FAIL "a held key was told 5 hours's whole".
- go test ./internal/provider ./internal/usage ./internal/cli
  ./internal/gateway: ok.
- gofmt -l clean; go vet -tags nogui darwin, GOOS=linux, GOOS=windows on
  provider, usage, gateway: ok.
- Not run: the GUI suite (no GUI file changed), and against the owner's
  real accounts.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone d8d52c6e97 agent: Raycast is an agent magpie connects: a magpie entry in its Custom Providers' providers.yaml, magpie's models in Raycast AI's picker (lx_78654 on Discord)
lx_78654 asked on Discord: "agents能否加一个raycast".

Raycast AI takes models of the user's own as Custom Providers (Raycast
Pro, "Available on: Mac, Windows"), from ~/.config/raycast/ai/
providers.yaml in the user's folder on both systems
(https://manual.raycast.com/ai/custom-providers). Raycast watches the file,
so no restart notice.

What changed:
- internal/agent/raycast.go: a new agent, "raycast". One field, provider:
  connecting adds an entry, id magpie, to the providers list: the gateway's
  /v1 (OpenAI compatible, no /chat/completions), an api_keys alias holding
  magpie-raycast (Raycast's User-Agent isn't known, so its key tells it
  apart), and one model per magpie model with name, context and all five
  abilities said (Raycast assumes tools and vision off when left out):
  tools and system_message on, vision for a model taking images,
  temperature off for one that refuses it, reasoning_effort for one with
  effort levels. ListsModels: the model is picked in Raycast.
  - The list is edited as a yaml node, so the user's other providers, the
    top-level tools block (anchors too) and comments stay.
  - A key the user adds to magpie's entry or to one of its models
    (include_user_email, a description) is kept on a sync; a model gone
    from the catalog leaves the list. A sync with nothing to change
    doesn't write.
  - Disconnect takes the entry out, the list when it was the only one, and
    a file left with nothing in it (Raycast's providers.template.yaml is
    never touched). A providers key that isn't a list is refused and the
    file left as it is.
  - Detected by Raycast.app (com.raycast.macos) or the ~/.config/raycast
    folder.
- agents.go: registers it.
- icons/raycast.svg: Raycast's mark from Simple Icons (CC0), currentColor.
- docs/reference.md, docs/subsystems/agent-wiring.md, README.md,
  README.zh-CN.md: Raycast's row and its place in the agent list.

What was run:
- go test -p 1 -tags nogui ./internal/agent -run '^TestRaycast' in a
  sandbox HOME: ok. The fixture is the manual's LM Studio and tools
  examples, with comments and an anchor; the result is decoded strictly
  (KnownFields) into the manual's schema. Red by hand when I:
  - turned off the no-op check ("a sync with nothing to change wrote");
  - replaced the merge with magpie's entry alone (the user's
    include_user_email and a model's description gone).
- go test -p 1 -tags nogui ./internal/agentenv: ok.
- The whole ./internal/agent package didn't finish here: the first run hit
  the 10m default timeout at TestInstalledVersion with the machine at load
  ~110 (other sessions' suites), the second (-timeout 40m) ran 20 minutes
  with no FAIL and then stopped on "no space left on device" when the disk
  filled (0 GB free, not this run's files). It needs a run on CI.
- gofmt -l; GOOS={darwin,linux,windows} go vet -tags nogui ./internal/agent: ok.

Not tried with a real Raycast. On Windows it is found by the
~/.config/raycast folder only (its install path isn't verified). WSL isn't
covered.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone 521e25806b gui: About's Download source tooltip says a mirror file that doesn't match the checksum isn't installed, in a whole sentence (AlwaySleepyZzz on Discord)
The tooltip's second half read "镜像下载的文件对不上校验和就不会安装":
the mirror doesn't download anything, and "对不上…就不会安装" has
no one doing the installing. It now reads
"从镜像下载的文件如果与校验和不符,magpie 不会安装它", the same
meaning as the English ("a file from the mirror that doesn't match it
is not installed"). zh-TW had the same wording and gets the same fix.
Japanese read "一致しないミラーのファイル" ("a file of the mismatching
mirror"); it now says the file taken from the mirror doesn't match the
checksum. German's "die nicht passt" now names what it doesn't match.
No other string on the page changed.

update-mirror.test.cjs now checks the tooltip's text in en and zh.

Run:
- NODE_PATH=<playwright 1.62.0> node --test internal/gui/tests/update-mirror.test.cjs
  (chromium + webkit, en + zh): pass 10, fail 0.
- Broken by hand: old i18n.js put back, BROWSER=chromium: zh fails
  with "the tooltip says a mismatched mirror file is not installed";
  restored, passes.
- gui-de, gui-ja, gui-zh-tw, i18n-keys .test.cjs: all pass (3/3 each).
- No Go code touched, so no go vet/test run for this commit.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone ecaa7e7dd7 gateway: a decision provider of several keys asks the next when one is out of quota, at /v1/systemone and as a classifier, in its routing's order (fflake33 on Discord)
A TypeSafe Jev provider with several keys never left its first key when that
one's quota ran out. serveSystemOne and the classifier (askClassifier → askJev)
always sent to p.Key, with no rest and no rotation. Only a decision group
failed over (serveDecisionGroup, askDecisionGroup).

Now the single provider goes the same way as a group:
- decideKeys plans its keys and accounts with s.plan, so Smart or In order,
  rests and barred keys apply. probeOne keeps only the resting one back
  soonest.
- serveDecideTries and askDecideTries (the group's loops, pulled out) ask
  each in turn. A retryable failure that isn't the request's own rests it and
  the next is asked.
- serveSystemOne keeps #905's limits. A gateway key held to some accounts is
  asked only on those (allowedCandidates), and gets 403 keyAccountsError when
  none serves the model.
- A provider whose every key is set not to serve the model is refused 403
  (barredError) instead of being sent on its first key.
- decideSeat is gone; the trace lists every key tried.
- docs/subsystems/gateway-routing.md says so.

Run: go test -p 1 -tags nogui -run 'SystemOne|Decid|Decide|Jev|Classif|
KeyAccount|KeyModel|Disabled|RemoteMagpie|Caller|Usage|Plugin.*Decide|
Barred|Rest|Probe' ./internal/gateway (ok, 124s).
TestDecisionProviderKeysFailOver (Smart and In order) refuses the first key
429 and checks:
- /v1/systemone answers 200 from the second, the trace has two tries and the
  first rests, and one usage row goes to the provider;
- the next request asks only the second;
- the same holds through askClassifier.
Broken by hand: with the old decide.go, decide_group.go and classify.go it
fails "systemone: 429 no capacity for k1" in both. The first version of the
reordering ran the barred check before the held-key one, and
TestGatewayKeyAccountsSystemOne caught the changed 403 message. The held
check now runs first.
gofmt -l clean; GOOS=darwin/linux/windows go vet -tags nogui
./internal/gateway ok.
Not tried against the real TypeSafe API.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone 01e4268913 gui: a decision-only preset's editor keeps In order, the session stick, the rate-limited-to-the-back switch, Unlisted and each key's proxy on Save (fflake33 on Discord)
TypeSafe Jev set to 按顺序 said "已保存 Typesafe JEV" and came back as 智能.
The save handler rebuilds a preset provider from the preset when the editor
sent no chat, Responses, Anthropic or Gemini URL. A decision-only preset
(typesafe, vercel-jev and the other Jev presets) has none, so every Save of
its editor came there and dropped routing, affinity, sink, unlisted and
accountProxies. Since the body did name routing, the old value was not kept
either, so it read as Smart. The editor sends them correctly; the fix is in
the server's preset branch, which now takes them from the request like the
key and auth header.

Run: go test -p 1 -tags nogui -run 'ProviderSave|Preset|Routing|Decide'
./internal/gui (ok). TestDecidePresetSaveKeepsRouting saves the typesafe
preset (decide URL at 127.0.0.1:1, no network) with a second key, then
In order, session, sink, unlisted and a key's proxy; checks they are kept,
that a Save without them keeps them, and that Smart and sink off save.
Broken by hand: with the old providers.go it fails "after Save: routing "",
affinity "", sink false, unlisted false, proxies map[]".
gofmt -l clean; GOOS=darwin/linux/windows go vet -tags nogui ./internal/gui ok.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone 6d606a75f0 library: an MCP server's row and a hook's have a Remove of their own, as a skill's has (#2364)
szoxidy turned off exa-2 for every agent and found no way to take that one
server out of the Library: a server's (and a hook's) only single Remove was
at the foot of the editor its row opens, while a skill's row has a trash
button. Clicking the server's status opens its tool list, not the editor, so
the turned-off server looked stuck, with only Select and Remove all offered.

Each server row and hook row now has the skill row's trash button (shown on
hover, titled Remove). Its click opens no editor; it asks first in the page,
titled with the one it takes ("Remove the MCP server exa-2?" /
"删除 MCP 服务器 exa-2?", "Remove the hook fmt?"), and says what goes with
it, as library.RemoveServer/RemoveHook do: out of the library and out of the
agents named (or "no agent has it" for one turned off everywhere), out of the
projects magpie placed it in, its sign-in forgotten, and the agents' own
servers left as they are. Remove posts servers/remove (hooks/remove) with
its name, the same change the editor's button makes. While Select is on the
row shows no trash (the bar's Remove is the one), so a picking row keeps the
room it had. New strings in zh, zh-TW, ja and de.

Run:
- new internal/gui/tests/library-row-remove.test.cjs: 22/22 (Chromium and
  WebKit, 1100px and 420px, en/zh/zh-TW/ja/de): exa-2 turned off and exa
  given to two agents, in a project and signed in; Cancel posts nothing; the
  sheet's title and lines in each language; no sideways overflow, no click
  scrolls; a hook removed from its row.
- Broken by hand: with origin/main's library/client.js the new test fails
  11/11 in Chromium ("exa-2's row has no Remove").
- The first version also put the trash on rows while picking: WebKit en
  library-servers-bulk went red ("lib-select moved on the screen from 289 to
  307"; it passes on origin/main's client.js), fixed by leaving the trash off
  a picking row; that test then 5/5 WebKit.
- Related, both engines, with the new test (19 files, --test-concurrency=2):
  317/317: library-servers-bulk, -hooks, -pick-remove, -mcp-tools,
  -mcp-health, -mcp-tool-switch, -row-open-scroll, -chip-fan, -mcp-unshown,
  -items, -all, -toggle-status, -null-agents, -gone-agents, -zed-mcp,
  -mcp-copy-config, -env-refs, i18n-keys.
- Not tried in the real app (fake API only); no Go changed, so no go vet.

Full suite: not run (focused GUI tests only)
2026-10-15 23:08:02 +08:00
yetone e894443932 trae: a check-in Trae CN refused 9074 says Trae refused it and to check in in the Trae CN app, not that Trae pays only its own app (#1920)
#1920 showed Buddy Switch checking in third-party Trae CN accounts, so
"Trae CN only gives check-in credits to its own app" wasn't true. What is
known is that Trae CN answered the claim 9074 (当前参与用户太多). The
own-app outcome stays as it was (the day's answer, no Check in now), but a
Trae account (By "trae") now has its own text in every place it shows:

- GUI card and Settings line: two new keys in en, zh, zh-TW, ja and de
  ("Trae CN refused this check-in (9074: too many taking part); check in
  in the Trae CN app" / "Trae CN 拒绝了这次签到(9074 当前参与用户太多),
  请在 Trae CN App 里签到"). WorkBuddy keeps the shared own-app key.
- TUI line and cell, CLI: provider.TraeRefusedWords; the cell says
  "签到 refused by Trae CN (9074) · check in in its app".
- trae_checkin.go, workbuddy_checkin.go and provider-plugins.md comments
  and the claim's fallback message say the same. They also note the
  plugin side: since @magpie-community/opencode-trae-auth 0.2.14 the
  account the machine's own Trae CN client is signed in as checks in with
  the client's device id, read only. No id is made up or rotated (#1705).

Ran (worktree at origin/main 9d97fd073, -tags nogui, -p 1):
- gofmt -l internal/: clean. go vet ./internal/{tui,cli,provider} for
  darwin, linux and windows.
- go test ./internal/tui ./internal/cli: ok.
- go test -run 'Trae|Checkin|WorkBuddy' ./internal/provider: ok.
- GUI: usage-checkin.test.cjs and i18n-keys.test.cjs in Chromium and
  WebKit, en and zh: 31 pass, 0 fail.

Broken by hand:
- app.js's card without the Trae branch: the renamed usage-checkin test
  fails in chromium en/zh and webkit en/zh (4 of 4).
- pages.go's ownAppWords without the Trae branch: the new
  TestTraeOwnAppSaysTraeRefused fails.

Not tried: a real Trae CN account. No test checks the CLI line on its
own. The ja, de and zh-TW strings are checked only by i18n-keys.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone 9810648726 usage: a filter picked on Requests is seen taken at once, the rows shown wait dimmed till its read comes (#1990)
overstarry (Windows, v0.1.1224): picking an agent on Usage > Requests
"has no response" and "the selection change does not take effect". The
menu closed, but the button kept the old name and the table its old rows,
with nothing to say a read was on its way. Over a long history that read
takes seconds. The read's own cost (the whole history, twice) is not
changed here; it is asked about on the issue.

- sessPick (app.js) writes the pick on its button at once, before
  choose(), for every picker built on it (Requests' six, Sessions' two,
  the panel's two).
- loadLedger (usage/page.js), on a pick over rows already shown, marks
  #ledWrap led-pending and aria-busy; the rows stay, dimmed, till the
  answer is drawn, and are undimmed on a failed read too. An aborted read
  leaves it to the read that replaced it.
- app.css: the dim, and no transition under reduced motion.

Run: new usage-ledger-pick-pending.test.cjs (read held by the test; en,
zh, zh-TW, ja, de; Chromium and WebKit) 10/10, three runs in a row.
Neighbours in both engines 67/67 + 79/80 then 80/80: usage-ledger,
-abort, -agent-middle, -fit, -content, -detail, ledger-hscroll,
panel-usage, sessions-toolbar, -folder-paging, -talk-model, -search,
i18n-keys. The one red first time was this test reading opacity mid
transition (chromium zh/zh-TW/ja, 2-3 of 5 per run); fixed by the
reduced-motion rule, not by waiting.
Broken by hand, then restored: sessPick passing choose straight through
-> 5/5 FAIL in WebKit ("the picker says the pick at once"); loadLedger
never setting pending -> 5/5 FAIL in Chromium. node --check on both
files ok.
Not run: go tests (no Go changed; disk at 2 GB free), the real Windows
app over a long history.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone 2494517696 agent: DeepSeek Harness Desktop installed to a folder of the user's own on Windows is found when it was installed for all users too, or registered only in its Uninstall entry (#2325, cjyrainbow, Andrew0767)
On top of #2279's commit (041e99063), which reads the folder DeepSeek
Harness Desktop's installer registers under HKCU\Software\<guid>.

cjyrainbow installed it to D:\tools\dsh; magpie 0.1.1248 showed
"未找到 CLI" with no switch. Since d0fcb8bcd (#2177) an agent whose folder
(~/.dsh) has no CLI and no app magpie can find is shown as gone, so a
desktop app outside %LOCALAPPDATA%\Programs, listed before by its ~/.dsh
alone, lost its row's settings ("it used to be recognised").

electron-builder's installer writes Software\<guid> InstallLocation and
an Uninstall\<guid> entry under HKCU for a per-user install and under HKLM
for an all-users one. #2279 read HKCU only. registeredIn now reads both
hives (64-bit view, then 32-bit), and when InstallLocation is missing the
Uninstall entry's InstallLocation, else the folder of its DisplayIcon
("…\DeepSeek Harness.exe,0") or UninstallString. The exe must still be in
that folder (registered(), from #2279).

Test: TestDshDesktopRegisteredAnyHive (per user, all users, the Uninstall
entry's folder, icon and uninstaller; an icon that is no exe finds nothing).

Run in this worktree:
- gofmt -l internal/agent: clean
- go vet -tags nogui ./internal/agent/ (darwin), GOOS=linux -tags nogui,
  GOOS=windows: clean
- go test: NOT run. The disk had 300-750 MB free (the session rule is
  1 GB before any go test), so the new test and the package were not run
  and nothing was broken by hand yet. Run before landing:
  go test -tags nogui -p 1 -run 'TestDshDesktop' ./internal/agent/

Not tried: no real Windows install; the registry reader was not run on
the Windows box. The reporter's hive (HKCU or HKLM) is not known.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone c68270dae7 update: a Mac opened from the Dock or Finder comes back after "Update and Restart", not quits for good (#2362, danbo610)
update.Relaunch left the shell that waits for magpie to exit and then
runs `open` in magpie's own process group. launchd ends a job's process
group when its process exits, so the shell died with magpie and the new
version never opened. ee16c657 fixed this for the Open at login agent
only (AbandonProcessGroup in the plist magpie writes). The job
LaunchServices makes for an app opened from the Dock or Finder carries
no such key, and on the reporter's macOS 13 (Intel, 0.1.1250) the
restart quit and nothing came back until a manual launch. The shell now
starts in a session of its own (detach, as RelaunchBinary's helper on
Windows and Linux already does). That holds for both job kinds, however
the previous version was started.

Tried on this Mac (macOS 26.2) with throwaway jobs, all removed after:
- A LaunchAgent without AbandonProcessGroup (a Go parent starting the
  same wait-then-run shell, then exiting): the shell in the parent's
  group never ran; one with Setsid did.
- A Cocoa .app opened with `open`, relaunching itself through the same
  shell: macOS 26 didn't kill the group, and both inherit and setsid
  relaunched. The application-job half is the reporter's macOS 13
  observation (their isolated A/B matches the agent case above). It
  was not reproduced on this OS.
- A setsid shell's `open` relaunched the .app fine (open rc 0, new pid).
Not tried: a real magpie update on macOS 13. No such machine here.

Siblings: RelaunchBinary (Windows, Linux) already detaches its child
through launch. Reexec (magpie web) runs in place. No other code
waits for magpie's pid and then opens it.

Tested: TestRelaunchOutlivesItsJobsGroup. A child of the test leads a
process group as a job's process does, starts the helper through
runAfterExit and exits. The test then kills the group as launchd does,
and the helper must still run its command. With detach(cmd) removed it
fails: "the relaunch helper died with the job's process group: the new
version was never opened" (15s). Restored, it passes (1.06s, 3 of 3).
go test -tags nogui -p 1 ./internal/update ok. gofmt -l clean. go vet
-tags nogui (darwin, GOOS=linux) and GOOS=windows go vet on
./internal/update ok.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone 35467e2a32 gui tests: codex-auto-reset flips the panel's switches after the tab's own read has drawn them, not on the cards that read replaces (#2360)
codex-auto-reset was red about once a run in Chromium, one 420px case in
a different language each time: "locator.scrollIntoViewIfNeeded: Element
is not attached to the DOM" in flip(), at the panel's first switch.

Opening the panel's Allowances tab calls quotasOpened(), an asked read
(usage/quotas?asked=1); when it answers, loadQuotas' finally calls
renderQuotas() -> renderPanelQuota(), which builds every card anew. The
cards drawn at boot are already there, so waitFor(psel) passed on them,
and when the asked answer came a few ms later than usual it landed
between flip's locate and its scroll. Instrumented on main (Chromium, en,
420): boot draw at 3ms, the tab's asked read at 76ms, its redraw at
105ms, the first flip after it. codex-credits met the same thing in
#1622 (0b3444999) and waits for !quotasLoading after opening the tab;
this test now does too, and codex-resets-used, which measures the
panel's card on the same draw, gets the same wait. No app change: a
fresh read redrawing the cards can only swallow a press held across
the moment it lands, and a real read's cards differ (their read time),
so skipping an unchanged redraw would not help a user.

Run: the asked answer held back on purpose (a scratch copy serving
usage/quotas?asked=1 60ms late, en 420 Chromium): the old test failed 2
of 3 with the reported "Element is not attached to the DOM" at flip; the
new one passed 3 of 3 (also passed held 30, 120 and 250ms). Unchanged
copies: codex-auto-reset + codex-resets-used pass 15/15 in Chromium 3
runs out of 3, and 15/15 in WebKit, every language. Test-only change, no
Go code touched.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone 7b1fdf669e provider: the Mac's menu bar reads a Codex card again as soon as a reset is spent or the card is refreshed, not at its next tick (#2357, zkhCreator)
After a Codex reset the tray panel's card showed the windows started
again and "Updated just now", while the menu bar's cells still showed the
old figures. The menu bar (watchTrayUsage) re-reads the cards on its
timer, every 3 minutes unless Settings says otherwise, or when
OnSubscriptionUsage's hook says a whole read of the accounts landed. Two
paths change what Quotas answers without that hook: a card read again on
its own (RefreshUsage, the card's refresh button and the gateway's
quotas refresh) and a Codex reset spent (useCodexReset, by hand, before
one expires or when the week runs out), which drops the cached cards. The
panel read the new card at once; the menu bar waited for its tick.

toldUsage() fires the hook; the background read uses it as before, and
RefreshUsage and useCodexReset now call it after they change the cache.
After a reset the menu bar's read finds the cache empty and waits for the
new reading (up to its 15 s), whose landing tells it once more; that
second read hits the fresh cache, so nothing loops.

Tested: TestRefreshOneCard and TestUseCodexReset now hold a hook and fail
without the calls (broken by hand, both removed):
  quota_refresh_test.go:81: a card read again on its own didn't tell the menu bar
  codex_resets_test.go:229: a reset spent didn't tell the menu bar
and pass with them. go test -tags nogui -p 1 ./internal/provider passes;
-race -count=5 on TestRefreshOneCard, TestUseCodexReset and
TestSubscriptionUsage* passes. gofmt -l clean; go vet (darwin nogui,
GOOS=linux nogui, GOOS=windows) on internal/provider and go build
./internal/gui pass.

Not tried in the real menu bar with a real Codex reset: no reset was
spent. Whether the reporter refreshed the card by its own button, used a
reset in magpie, or OpenAI reset every account (a read with no card
refresh, which already told the menu bar) is asked on the issue.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone fa725d47cd gateway: a rule naming a group in the group that shares its models with one ahead of it sends the turn there, in that group's own order, not unready (#2361, davisjiahao)
davisjiahao's Parent held First (Alpha, Beta) and Second (Beta, Alpha), with
a rule sending every request to group/second. Each request came out
"use=group/second, unready=true" and First's Alpha answered; with Beta
failing, Second's own failover (Beta, then Alpha) never happened, as Beta
was never asked.

membersOff walks the group down and keeps each provider/model/effort once,
where it meets it first (so a request never asks one model twice), and
dropped every later place of it. Second's models were all First's, so a
rule naming group/second (named, ruleMembers) found none of them.

Each member now keeps its later places in Member.Also, each with its own
path, way down, Fast and At (where the walk met it, so a group's own models
come in its own order). A model is still asked once a request. A rule
naming a group has the models as that group does (Member.In,
membersNamed), sorted by that group's order, for the rule's own and its
Then members. Further down the turn, nestedRules looks at the rules of the
group the rule chose (homed, at the top and at each nested rule naming a
group), Fast and the first token's wait go by it (homeCands), the length a
held rule outgrows (memberContexts) counts it, and the catalog's rule
capabilities (ruledEntry) find it. A pause rule naming the later group
still leaves a shared model to the group ahead of it, as before.

Tested, in the gateway through New().Handler(), the reporter's config
with a token rule in place of the agent one:
- TestRuleNamesAGroupSharingModelsWithOneAhead: all ready, Beta answers,
  rule not unready; Beta 402, Beta then Alpha; both 402, two tries.
- TestRuleNamesAGroupSharingSomeModels: First (Alpha, Beta), Second
  (Beta, Gamma): Beta, Gamma, then Alpha.
- TestRuleGroupSharingModelsKeepsItsRulesAndTurn: Second's own rule picks
  Alpha (Nested shows second), and the turn's tool round stays there.
Broken by hand, each run with -run on the three:
- every source file put back: all three FAIL ("from ka", unready);
- no sort in membersNamed: WithOneAhead FAILs (Alpha first);
- nested rules given ms, not homed: KeepsItsRulesAndTurn FAILs (Beta,
  Second's rule never looked at);
- dedup off (the later place appended as well): WithOneAhead and
  SomeModels FAIL.
TestRuleNamesAModelAGroupInItHasToo (#625) passes. gofmt -l clean; go vet
-tags nogui ./internal/gateway ./internal/provider for darwin, linux and
windows ok. go test -tags nogui -p 1 -timeout 45m ./internal/provider ./internal/gateway: ok (263s, 518s, load ~30). A first run at the default 10m timeout ran out in internal/gateway under that load, in a TempDir cleanup, no test failing.
Not tried: an agent-matched rule against the installed binary (the rule's
match is the same code either way), and Fast differing between two groups
sharing a model end to end.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone 29afe38797 gui: a Codex card's Auto-use resets and Use credits fold to one line in the menu bar panel (#2356, detail47)
detail47: "Codex占用过多界面空间,导致其他供应商被遮挡". In the panel's
Usage tab a named Codex account's card always drew both options in full:
the "Auto-use resets:" say with its two cases and switches, then the
"Use credits:" row, four lines under the rings that the window's Usage
page hides on a brief account but the panel had no way to.

panelQuotaCard now puts a chevron on the first options row, the same
chevron, size and turn as the Usage page's account fold. Clicked, the rows
fold to one line saying how each is set: "Auto-use resets: when its week
runs out · Use credits: On" (On / Off, or the one case on), with the
chevron to open them again. Open until the user folds it, so nothing
changes for anyone who doesn't; kept per card id in localStorage
(magpie.panelOptsFolded, read and written in try/catch). The click keeps
the focus on the chevron and doesn't move the panel. No new strings:
Fold, Unfold, On, Off and the options' own words are translated already.

Run:
- internal/gui/tests/panel-options-fold.test.cjs (new), Chromium and
  WebKit, en/zh/zh-TW/ja/de, 440 and 360px: 10/10. Open by default with
  both rows; folded, the line's words, aria-expanded/title, focus kept,
  card shorter, line fits the card, nothing scrolled; kept over a
  reload; unfolded, the credits switch still posts and the folded line
  then says Off; no left-border accent; every key translated.
- codex-credits, codex-auto-reset, codex-resets-used, panel-usage,
  panel-arrange (both engines, all their languages): all pass.
- Broke by hand: without the localStorage write the test fails at
  "kept over a reload"; with the line always saying On/Off it fails on
  the line's words. Both restored.
- Looked at the open and folded screenshots (WebKit, zh, 360px).

Not tried in the real tray panel on a Mac.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone 6e2aa8e321 agent: on Windows DeepSeek Harness is never taken for uninstalled by ~\.dsh alone, so it no longer shows "CLI not found" with no model to pick (#2300, yangkai2; #2304, wlj521)
From v0.1.1239 (d0fcb8bcd, #2177) an agent whose folder is here and whose
CLI isn't found shows "CLI not found" with its settings hidden. On Windows
dsh's folder is read by DeepSeek Harness Desktop too, which installs to any
folder and puts its dsh.cmd in one the user picks, and a dsh installed
through fnm sits on a PATH only a shell profile sets: magpie can't tell
those readers are gone, so ~\.dsh was taken for a leftover and the row
hid its model picker (both screenshots: 未找到 CLI). #1482 already made a
shared folder unknown on Windows; a folder an agent's desktop app reads
(desktopApps: dsh, and codex, already shared) is one too. On macOS and
Linux ~/.dsh with no dsh and no app is still gone (#843); Hermes, whose
folder only its CLI keeps, is still gone on Windows.

TestCLIMissingDshWindows: ~\.dsh as the desktop app leaves it, no dsh,
no app found; judged for Windows it isn't gone nor offered again, judged
for a Mac it is. It fails on the old gone.go (put back by hand: "dsh taken
for uninstalled on Windows, its settings hidden").

Run on this tree, on 6b7ea178d (#2279) over origin/main 707fbb249:
- gofmt -l: clean; go vet -tags nogui for darwin, windows, linux
- go test -p 1 -tags nogui ./internal/agent/: ok (857s)
Full suite: SUITE_LINE

Not tried: the reporters' own machines (how their dsh is installed is
asked on both issues); not run on the Windows box (the test forces the OS
switch, goneOS).
2026-10-15 23:08:02 +08:00
yetone 2a1637f4f6 agent: DeepSeek Harness Desktop is wired when installed but never opened, and found in any folder it was installed to on Windows (#2279, liangjinyuan-sihan)
DeepSeek Harness Desktop already reads magpie's route: its lib/main.js
(0.2.0-rc.2, the latest on its update feed, read from download.deepseek.com's
dmg and Windows installer) resolves $DSH_HOME, else ~/.dsh, and runs on
profiles/desktop, so the CLI's wiring applies. Three gaps remained:

- Installed but never opened, there is no ~/.dsh: the row wasn't listed,
  and connecting wrote the legacy config.yaml the app never reads. magpie
  now writes profiles/desktop/cordis.patch.yml from dsh's own template
  (PROFILE_PATCH_TEMPLATE) with its routes; the app's initProfile writes
  only missing files, so its first start keeps them. The notice says it
  starts on this when first opened (noticeDsh5, in all 5 languages).
  Disconnect before that first start removes what magpie made, when
  nothing else is there; afterwards only magpie's entries go.
- On Windows the installer lets the user pick the folder and registers it
  under HKCU\Software\1bf39983-50d0-5fe0-9ef4-cece76f67c5e InstallLocation
  (read from the NSIS script of dsh-latest-windows-x64.exe). magpie reads
  that, so a custom folder is found, and the Uninstall entry's
  DisplayVersion gives the version shown.

Tests: TestDshDesktopNeverOpened (pick on a never-opened app writes the
desktop profile, a user's key in .credentials.yaml and the user's own start
survive Disconnect, the app's first start is told apart),
TestDshDesktopRegisteredFolder (registry stubbed; exe must be there; WSL
twin has none).

Run on this tree, rebased onto 707fbb249:
- gofmt -l: clean; go vet darwin, GOOS=windows, GOOS=linux -tags nogui
- go test -tags nogui ./internal/agent/: ok (846s, loaded box)
- GUI, Chromium and WebKit: agent-notice-lang, gui-de, gui-ja,
  gui-zh-tw, agent-app-version, agent-cli-missing: 79 pass
Full suite: SUITE_LINE

Not tried: the real app was not run (Electron's userData isn't fully
redirected by a sandbox HOME); it was inspected statically (dmg mounted
read-only, app.asar extracted, NSIS header decoded). The registry reader
was not run on a real Windows install; the test stubs the registry.
2026-10-15 23:08:02 +08:00
yetone 59ceabafcf provider: a routing group renamed stays picked in Pi's and every agent's list (#2289, eachann1024)
RenameGroup moved the group, its place in the order and other groups'
members and rules that use it, but left what each agent's lists said of
it under the old id. A group picked for an
agent shown only its picks (Pi in #2289) was off after a rename, since
group/<old> was no longer in the catalog; the same held for a group taken
out of a list, put in an order, or sent fast. renameGroupPicks now moves
group/<old> to group/<new> in HiddenModels, PickedModels, OrderedModels
and FastPicks for every agent, as renameModelPrefs does for a provider
rename. GUI, TUI and CLI all rename through RenameGroup.

The reported case itself did not reproduce on main or v0.1.1234: with
"Only models I pick" on, Pi's model list shows every routing group under
"Routing groups", unticked, and ticking one writes group/<id> and offers
it in Pi's picker. A group added later stays off until ticked (#1337).
The rename is the one path found where a picked group is lost.

Run: TestRenameGroupKeepsPicks fails without the fix ("pi shown
[relay/m1]") and passes with it; go test -tags nogui ./internal/provider
./internal/gui; gofmt -l; GOOS=darwin, linux and windows go vet
./internal/provider.
Full suite: SUITE_LINE
Not tried: an agent whose own config is set to group/<old> is not
reseated on rename; that is a separate change.
2026-10-15 23:08:02 +08:00
yetone 420bf2ee3e gui: the Update pill's × sits off the pill, so a click meant for Update no longer hides it (#2291, MuiseDestiny)
The × that hides the Update pill for a version sat over the pill's top
right corner (top -5px, right 3px). In a narrow header, where the pill is
just its round 22px arrow, the × took about a fifth of it, the top right
quarter, and it appears as soon as the pointer is over the pill, right
where it is aimed. A click meant for Update hid the pill, and the update
was then only in Settings.

The × now sits just off the pill, touching its rounded corner (top -9px,
right -3px; -5px in a narrow header, whose pill has a 4px margin). Same
size, same hover reveal, same right-click; nothing else in the header
moves.

Run: update-hide.test.cjs gets "the × covers no part of the pill", in the
panel and in a narrow header (fitTop's tight class), en and zh, Chromium
and WebKit: every point inside the pill's round hit-tests to the pill,
and the × itself still takes a click. 18/18 pass; with the app.css change
reverted the new subtests fail ("the × takes clicks meant for the pill")
in both engines.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone 431e2941bb gui: a Routing request whose numbers don't fit one line keeps where it went whole and its numbers on one line under it (#2288, xishuchkui-code)
On a laptop's screen (about 1300px wide at 150%) the request list beside
the accounts is ~800px: wider than 760px, where a row goes onto three
lines, but too narrow for one. A row there cut where it went to
"Op… · deepseek-v4.1-fla…" and broke its metrics over two lines of their
own, at a different place on each row.

Now, where a row's metrics would wrap in their column on one line, the
list's column gets a meta-under mark and every row keeps its time, the
model asked and where it went on its first line and its metrics on one
line under them. metaFit decides it on the next frame after a resize or a
render: it takes the mark off, measures whether any row's metrics wrap,
and puts it back if so, before the frame is drawn, keeping what scrolls in
place (rows are shorter on one line). Measuring under the mark instead let
it flip: metrics within their 40% share can still wrap beside a wide model.
Where they fit, the row stays on one line as before (#860's
routing-columns); 760px and narrower is unchanged.

A fixed max1100 width mark was tried first and dropped: it put #860's
fixtures, which fit one line at a 900–1056px list, onto two lines.

Run: new routing-row-two-lines.test.cjs (Chromium and WebKit; en, zh,
zh-TW, ja, de; viewport 1500 = list ~845px beside the accounts, the
reporter's, plus 1300, 1100 and 420) and routing-columns pass, 14/14;
with the meta-under toggle removed by hand the new test fails in every
language ("where it went is cut"). Related GUI tests (172 files: routing-*
and every test that opens view=routing or the header), both engines, at
concurrency 4: 2449/2463; the 14 reds are routing-held-member WebKit 420
(#2252), routing-model-rest (#2115) and routing-wb-restricted (#1905),
each red alone on origin/main d0ccbbebc too (1-2 per run of these files on
both, across 3 runs), and routing-weight-chip, 16/16 alone. After the
switch to measuring on one line: routing-row-two-lines, routing-columns,
routing-scroll-end, routing-pointer-pin, routing-failed-open, click-scroll,
routing-request-model, routing-weight-chip 98/98. A probe at viewports
1500/1300/1240/1100/900 in both engines saw the mark settle (no
frame-by-frame flipping) and every reporter row whole on two lines.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone 97b4174a50 gateway: a Grok model is sent a tool's ^[^\s[\]]+$ as Rust's regex reads it, not turned away as "is not a regex" (#2317, x121381)
x121381 runs grok-4.6 from a third-party API key in Claude Code (Claude
for Windows). Every turn came back 400 from upstream: "Invalid request
content: Schema validation failed: /properties/breakpoints/items/oneOf/1/
properties/class_name/allOf/1/pattern: "^[^\\s[\\]]+$" is not a "regex""
(and the same for selector). The pattern is valid ECMAScript, which JSON
Schema's pattern is; a "[" inside a class is a plain character there. In
Rust's regex syntax it opens a nested class, so the class is never closed
and the pattern doesn't parse; "&&", "--" and "~~" in a class are set
operations there too.

grokToolPatterns (forwardOnce, beside deepseekToolPatterns) escapes those
characters inside a class of every tool schema's "pattern" when the model
named in the body is Grok's (grokModel: grok-*, xai/grok-*, x-ai/grok-*)
or the provider is api.x.ai. The escaped character is the same character
to ECMAScript, so the tool means what it meant. Patterns are spliced in
place (toolPatterns, the walker deepseekToolPatterns used, now taking the
fix as a function), so the rest of the body, its key order and a cache's
prefix, stays byte for byte; other models' tools go as they came.

Tests: TestECMAClassForRust (the reporter's pattern, POSIX-looking
[[:alpha:]], &&, --, ~~, escapes and text outside a class);
TestGrokToolPatterns2317 builds the schema path the error names
(breakpoints.items.oneOf[1].class_name/selector.allOf[1].pattern) and
checks only the two patterns change, for grok-4.6, xai/grok-4.7,
x-ai/grok-4 and api.x.ai by any model name;
TestGrokToolPatternsOtherModelsAsTheyCame keeps gpt/claude/deepseek/kimi
bodies and a Grok body with nothing to fix byte for byte.

Run: gofmt -l internal/gateway clean; go vet -tags nogui ./internal/gateway
clean. NOT run: go test (the disk had 208 MB free, under the 1 GB the
session needs before a test run), and nothing broken by hand yet. Before
landing: go test -tags nogui -p 1 -run 'TestECMAClassForRust|TestGrokToolPatterns|TestDeepSeekToolPatterns|TestUnicodeNullEscape' ./internal/gateway/,
then drop the grokToolPatterns call in forwardOnce / the in-class "["
case and watch TestGrokToolPatterns2317 go red. Not tried against xAI or
the reporter's relay; that Rust regex syntax is what xAI checks with is
read from the error, not from xAI's docs.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone fb159a503a provider: moved WorkBuddy users get plugin 0.1.23, where used-up credits leave the free models routable (plugins #138, hheei)
hheei's WorkBuddy account reached 560 / 560 credits. The plugin's credits
window covered every model, so magpie ranked the account spent, and last,
for deepseek-v4.1-flash too, which costs nothing. Plugin 0.1.23
(magpie-community/plugins ec8ae09) gives that window notModels = the
models the account's own config lists as free (x0.00, or free at night).
magpie already scopes a window by models/notModels (quotaOfPlugin ->
Limit.matches). This raises the mover's min, so keepMovedCurrent updates
moved users to 0.1.23.

Ran in the plugin repo: bun test (92 pass), and the 2 new usage tests
went red with spareFree taken out by hand. `npm view
@magpie-community/opencode-workbuddy-auth version --prefer-online` shows
0.1.23. Not tried against a real account at 100% credits.
Ran (on origin/main 01c41e8ba): go test -p 1 -tags nogui ./internal/provider ok; go vet -tags nogui GOOS=darwin/linux/windows ok.
Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone 7cad9a6185 agent: magpie's own files written during a sync with ~/.config a link are left alone, and the window's size saved after a resize no longer hangs the app for good (ylorn on Discord)
ylorn (v0.1.1250, macOS arm64, ~/.config a symlink): ~10s after every
start the GUI froze, beachball, CPU ~0, SIGTERM ignored. Their SIGQUIT
stack: the window's resize timer -> settings.Save (fileMu write lock) ->
edit.WriteAtomic -> the sync's filter keptAway -> gateway.URL ->
settings.Load -> fileMu.RLock, the same lock, forever.

Cause: edit.Filtered's filter sees every file written through edit while
a sync runs, from any goroutine, under whatever lock the writer holds.
keptAway read the settings (gateway.URL, and access.LANSecret through
ourToken) inside it, and skipped magpie's own files by a prefix check on
the unresolved ~/.config/magpie while WriteAtomic hands it the path
edit.Target resolved, so with a linked ~/.config settings.json fell
through to the settings read.

Fix (the class): what the filter needs of this magpie, the gateway's
address and the LAN key, is read before it is on (keeping(), kept.away,
kept.ours), so the filter takes no settings or access lock. magpieFile
compares magpie's folder as named and as EvalSymlinks resolves it, with
the written file's folder resolved too (for a file not there yet).

Siblings found: wslSaveLocked writes wsl.json under wsl's mutex, and the
filter's wslHost takes that mutex: with a linked config folder the same
self-deadlock on Windows (now skipped as magpie's own; the test covers
it). access.save writes keys.json under access.mu, which LANSecret took
inside the filter (now read before). No other prefix check against
provider.Path()/appdir gets a Target-resolved path; the filter is
edit.Target's only consumer of that kind. edit.Filtered's doc now says
the filter waits on nothing.

Run at this head (macOS arm64, go1.26.8, -tags nogui, -p 1):
- TestOwnWritesDuringASyncWithALinkedConfig (new; sandbox HOME with
  .config a symlink): on origin/main 35aa50cfb it fails with the
  reporter's stack (settings.go:972 <- keptaway.go:92 <- settings.go:1324).
- go test ./internal/agent (whole package, 810s): ok
- go test ./internal/edit: ok
- -race TestOwnWrites...|TestKeptAwayOnlyWhatIsSure -count=2: ok
- gofmt -l clean; GOOS=darwin/linux/windows go vet ./internal/agent
  ./internal/edit: ok

Broken by hand:
- magpieFile comparing the unresolved folder only (settings read kept
  out of the filter): red, wsl.json deadlocks in wslHost.
- the settings read put back inside the filter, own check fixed: green
  (settings.json is skipped as magpie's own before it); with the old
  check as well: red with the reporter's stack. The hoist is guarded only
  together with the own check.

Not tried: the real GUI with a linked ~/.config; the Windows box.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone f15542d2ea sessions: OpenCode 2 subagents show their type, and a Kimi Code subagent opens on its task, not a context chip (#2290, infinitr0us)
OpenCode 2.0.29 keeps a child session's agent in session_v2.agent and
titles it with the task alone, so ocSubagentTitle found no kind and every
OpenCode subagent row showed only its title and time. The kind now comes
from session_v2.agent when set (ocV2DB.agent, kept once found; a missing
column or NULL reads as none and isn't kept), and the "(@agent subagent)"
title split stays the fallback for older versions.

A Kimi Code subagent's own wire.jsonl starts with the task its parent
gave it, a turn.prompt whose origin is {kind: system_trigger, name:
subagent}; the transcript folded every system_trigger as context. In a
subagent's own wire (not agents/main) that prompt now opens as its first
user message (kimiTask). Other system triggers, and a "subagent" one in
the session's main wire, stay folded.

Fixtures follow the reporter's described shapes: ocMakeV2's real
session_v2 schema with agent 'explore' and a task-only title beside a
child with no agent and an older suffixed title; a 1.5-shaped subagent
wire (agentId, promptId, turnId) with the subagent trigger, a reply and a
background_task trigger, plus a subagent trigger appended to main.
No real OpenCode child sessions or Kimi Code subagents on this machine.
No GUI change: the Sessions client already draws a subagent's kind.

Run: TestOpenCodeV2SubagentKind and TestKimiSubagentTask fail on the old
subagents.go/transcript_kimi.go (no kind; user/context first), and
TestKimiSubagentTask fails with the agents/main scope check dropped.
go test -p 1 -tags nogui ./internal/sessions/ ok at the rebased head;
gofmt -l clean; go vet -tags nogui ./internal/sessions/ for darwin,
GOOS=linux and GOOS=windows.
Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetoneandggbdpq 8820646f7c library, agent: the gone-agent tests pass on Windows, with or without the Codex app installed, and no package's tests read the machine's Store apps (#2254, ggbdpq)
ggbdpq found TestTargetsLeaveGoneAgentsOut and TestGoneAgentKeepsWhatItHas
(from e413512d8) red on a Windows machine with the Codex desktop app.
Their patch (ggbdpq/magpie fix-2254-gone-test, ddd44c36) skipped the
tests when HasApp said so, which proves nothing on such machines, and set
a PATH of the test's own. This takes their hermes fixture fix and makes
the rest hermetic instead:

- agent: windowsStorePackages reads none of the machine's AppX registry
  in a test binary testenv isolated (proc.Isolated), as SystemDirs already
  keeps the machine's folders out. Only agent's own TestMain stood in for
  it before, so library's tests (and any other package's) saw a real
  Codex app, and codex's CLI was never gone there.
- library: the hermes fixture goes where Hermes reads it
  (appdir.HermesHome: %LOCALAPPDATA%\hermes on Windows). In ~/.hermes
  hermes was never detected there, and Takes refused nothing.
- library: TestGoneAgentKeepsWhatItHas uses Pi, which goes on every
  system. On Windows a ~\.codex whose CLI isn't found is never taken for
  a leftover (#1482, by design), so the test with codex failed on every
  Windows machine, Codex app or not. The PATH change in the patch made
  no difference to that.
- TestRTKLeavesGoneAgentsOut keeps codex; it already skips on Windows
  (its fake rtk is a shell script).

Run:
- Windows 11 box, test binaries cross-built (amd64): old main had
  TestTargetsLeaveGoneAgentsOut and TestGoneAgentKeepsWhatItHas FAIL
  (Takes(hermes) <nil>; codex a target), new both PASS. Full library and
  agent packages there: new fails only what old fails too (library:
  TestAgentsSkillsFolders, TestHooksCodexTrustMovesWithTheGroups, filed as
  #2275; TestCheckKeepsToolNames and agent's 10 are from running a test
  .exe away from its source: testdata, ../gui, go and bash not there).
- Broken by hand: TestStorePackagesNotTheMachinesInTests without the
  Isolated check reads the box's 152 Store packages and goes red; with
  Targets' CLIMissing filter removed, both library tests go red on macOS.
- macOS: go test of agent, proc, library; gofmt -l; go vet -tags nogui
  for darwin, linux, windows on the three packages.

Full suite: SUITE_LINE

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-15 23:08:01 +08:00
yetone 014363b3d5 agent: the Codex app is offered max for magpie's models while its config is on Codex's own model, so a High/Max group gets its effort control (#2127, cnlove7777777-art)
#2127: a routing group Dash (over the LAN share) could run at High or Max
showed in the Codex app at High, with no effort control. Its catalog entry
lists high and max, as /v1/models does for Dash, but the Codex app offers
a model only the efforts in [desktop] enabled-reasoning-efforts, whose
default leaves max out. magpie adds the efforts its models take there
(codexEnableEfforts, #310), but on a sync only through settle, which ran
only when config.toml's model was one of magpie's. With the config on
Codex's own model (the app's last pick), the group's levels arriving
later (8c5190a20 in v0.1.1234, any catalog change) rewrote the catalog
with high and max and left the app offering high alone.

Codex's Sync now adds the missing efforts whenever Codex is routed through
magpie, whatever model the config is on. The user's entries, order and
comments stay; an inline [desktop] is still left alone; a Codex not routed
is unchanged.

Test: TestCodexDesktopEffortsFollowTheCatalog connects Codex to a model
with no levels, writes model = "gpt-5.5" as the app does, then adds a
group of glm-5.3 (low/high/max) and deepseek-v4 (high/max), checks its
levels are high,max, and syncs: max must be enabled and the app's pick
kept. Broken by hand: with the new Sync lines removed (the old code) it
fails with no [desktop] written at all.

Run (worktree on origin/main 35aa50cfb, shared GOCACHE): gofmt -l clean;
go vet -tags nogui ./internal/agent on darwin, GOOS=linux and
GOOS=windows clean; go test -tags nogui -p 1 -run Codex ./internal/agent
ok; go test -tags nogui -p 1 -count=1 -timeout 40m ./internal/agent ok
(1038s; the default 10m timeout cuts this package short at -p 1)
Not tried: a real Codex app session against the reporter's group (their
config.toml isn't known; the reply asks for its [desktop] line).

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetoneandggbdpq 540454acec gateway: a turn on Codex's own ChatGPT sign-in is counted on that account, so the card's window holds see it (#2297, Edward4226, ggbdpq)
codexUpstreamOn wrote the relay's ledger row as Provider: call.Provider
("openai") with no account. The account card's window holds key rows by
codex + the sign-in's email (usage/window_holds.go), so every turn Codex
relayed on its own sign-in was left out: the reporter's 7-day window read
2.3M/$0.31 where its calls were 19.0M/$64.26.

codexServed (ggbdpq's patch) records such a relay as the codex account
signed in to, or the account compactOn signed it with. An API-key call
and a relay with no sign-in to name stay openai with no account. The
Routing view's seat stays OpenAI. loggedAnswers (#1367) still leaves the
relay out of a lead's answerers, as openai or as codex without a
"host as email". Rows already written are not rewritten.

On top of the patch: the relay goes out with the token Codex sent, which
is the sign-in magpie reads only when it is the same ChatGPT account. A
request whose chatgpt-account-id isn't the account auth.json here is
signed in to (a Codex in WSL, another CODEX_HOME) stays openai rather than
being put on this machine's account (provider.CodexSignedInAccount).
TestCodexServedNamesTheAccountThatSigned is back and covers it.

Run, go1.26.8 darwin/arm64, on 03eb0633a, -tags nogui -p 1:
- go test ./internal/gateway -run 'TestCodex|TestSealedTaskFromChatGPTLead|
  TestLoggedAnswer|Lead': ok (48.8s). The four new tests -race -count=3: ok.
- go test ./internal/provider -run 'TestSessionIdentit|TestCodex': ok;
  ./internal/usage -run 'Window|Hold': ok.
- go vet ./internal/gateway ./internal/provider for darwin, GOOS=linux and
  GOOS=windows: clean. gofmt -l: nothing.
Broken by hand, each red, then put back:
- codexServed always "openai": TestCodexOwnModelRecordedAsCodexAccount
  (Provider:openai, no account) and TestCodexServedNamesTheAccountThatSigned.
- chatgpt-account-id check dropped: TestCodexServedNamesTheAccountThatSigned
  ("another account's token: codex me@example.com").
- loggedAnswers back to provider == "openai" only:
  TestCodexOwnModelRecordedAsCodexAccount and TestCodexOwnRelayAnswersNoLead
  ("own sign-in answered a lead").
ggbdpq's own record (Windows, 38d25fe3/1d61458b on 01c41e8b): the same
tests red with codex_backend.go reverted, green after; -race -count=5;
vet/build for windows, linux, darwin.
Not run: the full suite, GUI, a real Codex sign-in.

Full suite: SUITE_LINE

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-15 23:08:01 +08:00
yetoneandcyh 7faf55778a gateway: OpenCode's DeepSeek is sent no deferred-tool blocks, and an inline-only tool definition joins tools (#2338, Emaj77)
Claude Code's deferred tools put tool_addition / tool_removal /
tool_reference blocks in a message. OpenCode Go's DeepSeek route answers
one defining a tool with a bare 422 "Upstream request failed: Endpoint is
unavailable.", which names nothing deferredRefused can learn from, so
every turn went out the same way and failed the same way. The reporter
checked it straight against opencode.ai/zen/go/v1/messages on 2026-10-15
(3/3 422 inline, 3/3 200 plain and with the definition in tools).

forwardOnce now drops the blocks for a Messages request to an OpenCode
host (p.IsOpenCode) whose model names deepseek, as it already did for Kimi
(#2042). Other OpenCode models and every other provider are sent the
blocks as Claude Code wrote them; no retry or fallback is added.

withoutDeferredTools assumed every tool was also in the top-level tools.
A tool defined only in a tool_addition's definition was dropped, so the
model could no longer call it; that held for Kimi too. Such a definition
now joins tools once, by name, a top-level definition of the same name
winning; ToolSearch's tool_reference inside a tool_result stays. A later
tool_removal is not applied to tools (out of scope, as before).

Run (go1.26 darwin/arm64, sandbox HOME, -p 1 -tags nogui):
  go test ./internal/gateway -run 'TestOpenCodeDeepSeekInlineTools|
    TestDeferredInlineDefinitionPreserved|TestKimiIsSentNoDeferredToolBlocks|
    TestDeferredToolBlocksRefusedOnceLeftOut|TestOpenCodeGoModelsGoOnTheirOwnAPI|
    TestRefsOnly|TestRefsSaid|Deferred' -count=1  -> ok, 14 pass
Broken by hand:
  - forwardOnce's condition put back to isKimi alone:
    TestOpenCodeDeepSeekInlineTools/go/deepseek-v4.1-flash fails with the
    reporter's 422.
  - withoutDeferredTools not writing tools back: both new tests fail
    ("inline definition was not preserved", "tools lost or duplicated").
gofmt -l clean. GOOS=windows and GOOS=linux go vet -tags nogui
./internal/gateway clean. Not run: other packages, the GUI suite (disk
had under 1 GB free); not tried against the real OpenCode Go endpoint through
magpie (the reporter's direct requests are the evidence).

Full suite: SUITE_LINE

Co-authored-by: cyh <2293985047@qq.com>
2026-10-15 23:08:01 +08:00
yetone 73b2845500 gui: the Usage speed chart's tooltip shows each model's name whole, its speed and first token in columns (#2343, tsuixl)
Requests tab, Speed chart: the tooltip cut model names to "claude-sonnet-5..."
(.tip max-width 260px, names ellipsized), put each model's tok/s and TTFT
into one run of text, and wrapped the period's line. In speed mode the
tooltip is now a grid: swatch, the name in full (wrapping only when it
can't fit, never cut), the speed, and the first-token time, each in its
own column, so the numbers line up row to row; the "All · N requests" line
uses the same columns. Up to 400px wide and never wider than the chart.
The other metrics' tooltips are unchanged.

Run:
- New internal/gui/tests/usage-speed-tip.test.cjs (three long model
  names, en/zh, 1100 and 420 wide): chromium + webkit, 10 pass.
- Broken by hand: the test pointed at origin/main's assets
  (MAGPIE_SPEED_TIP_ASSETS) fails every subtest with
  "claude-sonnet-5-20260929-thinking is cut short".
- Neighbours, both engines: usage-ttft-rounding 6/6, usage-ledger-chart
  18/18, usage-speed 6/6, usage-speed-count 52/52, usage-chart-axis 10/10,
  usage-chart-dates 8/8, usage-ledger 34/34.
- Screenshots of the tooltip looked at in chromium en 1100 and webkit zh 420.
- No new strings, so zh-TW/ja/de have nothing new; their suites not run.
- No Go changed; go vet/build not run (disk near full).
- Not run: the whole GUI suite, Wails/WebKitGTK/Windows.

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetone fbbb9a8ffb agent, wslrun: a wsl.exe that failed to say which distros run is asked again after 30s, not every 3s (#2341)
Both caches of `wsl.exe -l --running -q` (wslrun.running and agent's
wslRunningLocked) kept a failed answer as long as a real one: 3s. When
WSL hangs, each ask waits its whole 10s timeout, under a lock the GUI's
state build waits on (wslUp), and the timed-out wsl.exe is killed but the
Store WSL's own child isn't (CommandContext can't put it in a job), so
the lag came back every few seconds and wsl.exe processes piled up. A
failure is now kept upFailedAge / wslRunningFailedAge (30s). A failure
already reads as "none runs", so nothing is opened on a guess; a real
answer still lasts 3s, so a distro stopped is seen as quickly as before.

Run: go test -p 1 -tags nogui -count=1 ./internal/wslrun -run 'TestUp|TestFind'
and ./internal/agent -run TestWSL (both ok, macOS, sandbox HOME).
TestUpFailedKept and TestWSLRunningFailedKept count wsl.exe asks: a
failure isn't asked again after 3s, is after 30s, and an answer is asked
again after 3s.
Broken by hand: upFailedAge and wslRunningFailedAge set back to 3s ->
TestUpFailedKept and TestWSLRunningFailedKept fail ("a failure was asked
again after 3s: 2 asks"). GOOS=windows and GOOS=linux go vet -tags nogui
./internal/provider ./internal/agent ./internal/wslrun: clean; gofmt clean.
Not tried on Windows. The leftover wsl.exe children of a timed-out run
are not fixed here.

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetone 12d3db7332 provider: the Codex daemon check lists processes only when a pid file is behind, not a PowerShell run every 15s on Windows (#2341)
KeepCodexDaemonCurrent runs every codexDaemonEvery (15s, internal/agent/
codex_daemon.go) for as long as magpie runs, and listed every process
first. On Windows that is `powershell Get-CimInstance Win32_Process`, a
cold start each time, which is the run the reporter saw over and over.
A daemon is only ever found behind through a pid file written before the
change (daemonStarted), so with no pid file, or only newer ones, the
answer was always "nothing to do". pidFileBehind checks that first, with
the same one-second slack, and processes are listed only when it can
matter.

Run: go test -p 1 -tags nogui -count=1 ./internal/provider
  -run 'TestKeepCodexDaemon|CodexDaemon' (ok, macOS, sandbox HOME).
TestKeepCodexDaemonCurrentListsOnlyWhenBehind counts listProcesses calls:
none with no pid file or a newer one, one with an older one.
Broken by hand: codex_daemon.go put back to 03eb0633a -> the test fails
("processes listed 2 times with no daemon behind").
GOOS=windows and GOOS=linux go vet -tags nogui ./internal/provider
./internal/agent ./internal/wslrun: clean; gofmt clean. Not tried on Windows.

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetone 5ca897690f library: an instructions set linked to the file an agent reads is read without magpie's part, so it isn't written into itself until gigabytes (#2349, eachann1024)
instructions.md linked to ~/.claude/CLAUDE.md (or both linked to one
dotfile) made the set's text the whole file, magpie's part included.
wanted() read it as is, syncInstructions wrote it into that same file's
part, and split() only knows the first begin/end pair, so the part never
matched and each sync nested the whole file in it again: the file doubled
at every sync. linkable() refuses an agent's own file for a set kept in
the user's file, but the default set's instructions.md being a link went
around it.

- setText reads a set's text with every magpie part taken out; used where
  the set's text is read (wanted, the page, ImportInstructions, carry,
  setup snapshot/compare).
- own() takes out every part, and the end lines a part nested in itself
  leaves behind, so a file already grown comes back to the user's text.
- An agent whose instructions file is, links followed (realBelow), the
  file the set on is kept in gets no part; one written before is taken
  out, the file kept aside first. ImportInstructions refuses that agent.
- docs/subsystems/library.md: Instructions row.

Run (worktree on origin/main 03eb0633a, go1.26, sandbox HOME via the
package's sandbox()):
- go test -p 1 -tags nogui ./internal/library -count=1: ok (114s)
- gofmt -l internal/library: clean
- GOOS=windows and GOOS=linux go vet -tags nogui ./internal/library: clean
Broken by hand: with instructions.go, carry.go and setup.go put back to
origin/main, TestInstructionsSetLinkedToAgentsFile fails: CLAUDE.md
holds nested magpie parts after three syncs, codex gets them, the page's
shared text has them, and a 4-deep grown file stays grown.
Not run: the real app with a linked instructions.md; Windows (symlink
creation skips the test there without the privilege).

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetone 861bbef2d5 sqlite: an environment entry with no "=" no longer ends magpie at its first SQLite open, where modernc's libc printed TODOTODO and exited (#2327, goodloop)
A magpie started from Alfred under the MacSec DLP tool quit about two
seconds after launch, exit 1, no crash report. Its environment held an
entry with no "=" ("hains/MacSec/libesafenet.dylib", a fragment of the
tool's injected dylib path). The first SQLite open (a session scan)
reads SQLITE_TMPDIR through modernc's libc, whose getenv on darwin,
windows and the BSDs (libc.go, not the musl build Linux uses) hits that
entry, calls todo() and os.Exit(1): "libc.go:1816:getenv: TODOTODO
"SQLITE_TMPDIR" "hains/MacSec/libesafenet.dylib"", the reporter's line.

New package internal/sqlitedb is the one importer of modernc.org/sqlite
in magpie's own code (it replaces the blank imports in
internal/provider/importapps.go and internal/agent/cindy.go, the only
two). Its init hands libc.SetEnviron a copy of os.Environ with the
entries that have no "=" left out, before any open and before any
goroutine, which also keeps libc's unlocked first-use SetEnviron from
racing. modernc.org/libc becomes a direct requirement (v1.67.6, same
version). Snapshot timing: libc's copy is now taken at init, not at the
first open; nothing in magpie sets SQLITE_TMPDIR, TMPDIR or TZ, the
only variables SQLite reads.

Run (worktree at origin/main 01c41e8ba, sandbox HOME, go1.26.8 darwin):
- internal/sqlitedb: TestSQLiteSurvivesMalformedEnv starts the test
  binary again with the reporter's entry first in a raw Env and opens
  and reads a database there; TestWellFormed; and
  TestOnlyThisPackageReachesSQLite (no non-test file outside
  internal/sqlitedb imports modernc.org/sqlite or modernc.org/libc).
- Broken by hand: with init's SetEnviron call removed,
  TestSQLiteSurvivesMalformedEnv goes red with the child's exit 1 and
  the reporter's exact TODOTODO line. With cindy.go importing
  modernc.org/sqlite again, the import guard goes red naming it.
- go test -p 1 -count=1 -tags nogui ./internal/sqlitedb ./internal/agent
  ./internal/provider ./internal/sessions ./internal/proc: all ok.
- gofmt -l: clean. go vet -tags nogui on the three packages for
  GOOS=darwin, linux, windows: clean. go mod verify: ok.
- Real binary: go build -tags nogui, then execve'd (python ctypes, raw
  envp) as `magpie sessions` with the reporter's entry and a sandbox
  HOME holding an opencode.db: exit 0, it listed. The hand-broken
  binary for comparison couldn't be linked (disk full), so that run
  shows only that the fixed binary survives, not that this command
  reached SQLite; the test above is what goes red on the old code.
- Not tried: the reporter's Alfred + MacSec machine, Windows.
- Linux getenv (musl-based) already skips such entries; the test passes
  there either way.

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetone 15a8656bc2 gui: an added preset provider can be renamed in its editor, as a custom one can (yapechan on Discord)
yapechan couldn't tell Kimi from Kimi (China) at a glance and asked for
names of their own. A custom provider's editor has a Name box; an added
preset's had only its id, so the name could be changed only through
`magpie provider set <id> name=…`. The editor of an added preset (not a
subscription) now has a Name box: empty, the preset's name as its
placeholder; what is typed is what Save sends (the save handler already
takes a name), and a box left empty sends the preset's name back. The id
is unchanged, so agents and routing groups on it stay.

Relabelling the presets themselves wouldn't reach anyone: a preset's name
is stored when it is added.

Run: preset-name.test.cjs (new) in Chromium and WebKit, en and zh: 4/4.
With the box taken out by hand it goes red ("one Name box"). The 111
GUI test files that open a provider's editor: see the record below.
No new strings ("Name" is translated in every language).

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetone 1242367020 gui: the menu bar's idle tooltip splits today's tokens into input, output and cache (NextCommit on Discord)
With no cards ticked, the tooltip said only "Today: 6.3M tokens". It
now says "Today: 6.3M tokens (912K in · 318K out · 5.1M cached)" over the
cost and requests, as the usage:today card's tooltip has since #1984
(trayTokens, shared by both; cached left out when nothing was cached).

Run: TestTrayIdleTip and the SNI tip case, updated. gofmt -l clean.

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetone 49d60394ef gui: the Mac's menu bar item shows its tooltip, which Wails never set there (NextCommit on Discord)
NextCommit (macOS, 0.1.1244) hovered the menu bar item for today's
tokens split into input, output and cache and saw nothing. Nothing was
shown at all: Wails v3.0.0-beta.24's macosSystemTray.setTooltip is a
no-op ("Tooltips not supported on macOS"), so neither the idle tip nor a
card's tooltip (usage:today already said "6.3M tokens (912K in · 318K
out · 5.1M cached)") ever reached a Mac. Linux has its own setTrayTip
(SNI); Windows keeps Wails'.

setTrayTip on the Mac now sets the status item's button toolTip on the
main queue (trayTipNative, mpTip in trayimage_darwin.go), returning false
while the item isn't up yet so it is tried again, as Linux's does.

Run: TestMacTrayTipIsSet (darwin, cgo): setTrayTip reaches the native
setter, false before the item is up, and a real NSStatusBarButton keeps a
multi-line tip whole. go vet: darwin (cgo, GUI) and -tags nogui for
darwin, linux and windows. Not tried: hovering the icon in a built app.

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetone 24a1f92446 gui: Library's intro text is as wide as the cards under it, not broken off at 640px (#2319, emo172)
.lib-intro had max-width: 640px, the only cap on a paragraph in the
Library plugin's CSS. On a wide window RTK's intro broke mid-sentence
("…只输出模型需要的部分," / "节省 token。") while the RTK card under it
ran across the whole column, which read as text cut for no reason. Every
tab's intro shares the class (RTK, MCP servers, Instructions, Hooks,
Skills), so the cap goes for all of them; text-wrap: pretty keeps a last
word from standing alone on its line (ignored where unsupported). No other
change to the layout.

Test: library-intro-width.test.cjs, Chromium and WebKit, en/zh/zh-TW/ja/de,
at 1100px and 420px, on the RTK, MCP and Instructions tabs: the intro spans
its column less its 2px sides, ends where the RTK card ends, and the page
doesn't scroll sideways. With the old CSS it fails at 1100px ("intro 640px
in a 856px column"); with the fix 62/62 pass.

Run: node --test internal/gui/tests/library*.test.cjs
internal/gui/tests/view-no-sideways.test.cjs (both engines): 610 pass,
0 fail.

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetone 4594d66d2d gateway: an image description's time limit is the describer's, not its wait in the queue, and the usage log no longer calls it the agent canceling (#2318, davisjiahao)
askVisionWith put a 2-minute context.WithTimeout around the whole
description, which goes through the gateway itself (s.serve): its wait for
a slot (MaxConcurrency, QueueWait), for room in the minute, and the pauses
between tries all spent it. A reasoning seer (gpt-6.1-sol on a Codex
account) queued or retried had little or nothing left to describe in, and
the image's turn failed. The usage log said 499 "the agent canceled the
request" for magpie's own limit.

sideDeadline (side_deadline.go) now bounds a request magpie asks of itself:
the vendor has its limit from when the request last went out to it
(httptrace WroteRequest, each try's own), and the whole of it, waits
included, a larger one. Image descriptions get 3 minutes per try (a dense
screenshot at a high reasoning level can take over two) and 10 in all; a
model's search (modelSearch, the same 2-minute limit, the #1522 message)
keeps 2 minutes per try and 5 in all. The context's cause says which limit
ended it, and the 499 sites in serve record "magpie stopped waiting: its
image description had no answer in 3m0s" instead of the agent canceling.
Still 499, no fault of the vendor's.

Not done: the issue's setting for the limit (none needed once the wait
isn't counted) and sending the raw image to a model that can't see it.
A pause between two tries still runs on the first try's limit.

Tests (vision_wait_test.go): TestVisionWaitIsntTheDescribersTime queues
the description behind a held request for twice the limit;
TestVisionLimitEndsASlowDescriber has a describer slower than the limit
and checks the 502 and the usage row. Broken by hand (WithTimeout back,
the old 499 text) both fail: "no answer in 300ms" and "vision usage: 499
the agent canceled the request". modelSearch has no test of its own; it
uses the same sideDeadline.

Run: go test -tags nogui ./internal/gateway -run
'Vision|Search|Image|Seer|Describ|Concurren|Queue|Cancel|Usage|Lane|RPM'
ok (58s); gofmt clean; go vet -tags nogui ./internal/gateway on darwin,
linux, windows clean. Not tried with a real queued seer.

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetone 6f6b7d4077 gateway: a Codex request with web_search stays alive while its provider is queued, not cut at Codex's idle timeout (#2316, clxsh)
A request that offers web_search to a model that can't run it goes through
searchReply, which reads the provider's reply in rounds. That reader used
readSSE, so the provider's keepalives (": keepalive", response.in_progress)
were dropped, and relay waited for the first event past KStart before it
made the client's encoder. A provider queued for minutes sent the client
nothing but the holdWriter's comments, which Codex's idle timeout doesn't
count: it hung up at ~315s and asked again, losing its place in the queue.
The plain translated path has kept the client alive since #436.

Now askTranslated reads with readSSEAlive and, after keepaliveGap with
nothing else sent, hands its reader a KAlive event (nothing of the reply).
searchRounds passes it on without collecting it, the collector ignores it
(no reasoning block boundary moves), and relay takes it as the provider
being heard from: it begins the client's stream and sends the protocol's
own keepalive (response.in_progress, Anthropic's ping) when the client has
been quiet keepaliveGap. A provider that goes silent sends no KAlive, so
relayEvents' keepaliveLongest still ends the keepalives; an error before
any keepalive is still a status for the next account.

Test: clxsh's TestSearchQueueKeepsCodexAlive as filed (comments, progress,
cancel, silent). On the old code all four fail (pings=0 complete=false,
only comments reach the client); with the fix they pass, -count=3.

Run: go test -tags nogui ./internal/gateway -run
'Search|Keep|Alive|Relay|Zen|Draw|Probe|Held|Hold|Queue|Codex.*Stream|Translated'
ok (75s); gofmt -l clean; go vet -tags nogui ./internal/gateway on
darwin, linux, windows clean. Not tried against a real queued provider.

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetone 095d77ae75 gateway tests: Codex's Fast reaches a ChatGPT account from Claude Code and OpenCode, switched in their picker or asked with speed fast (莫 on Discord)
莫 asked how another agent gets Codex's Fast (service_tier "priority",
what Codex CLI's /fast and service_tier = "fast" in config.toml send)
once it goes through magpie. It already does (#954): the bolt beside a
ChatGPT account's GPT in the agent's picker sends that agent's requests
for it at priority, and a routing group's member can be marked fast. No
test held it for a non-Codex agent on a ChatGPT account:
TestFastPickKeepsTheClientsUltrafast covers OMP on /v1/responses only.

TestCodexFastForOtherAgents posts Claude Code (/v1/messages) and OpenCode
(/v1/chat/completions) to codex/gpt-6-luna: unswitched it goes with no
tier, switched it goes to chatgpt.com at priority and is traced Fast, and
Claude's own speed "fast" asks priority too. No code changed.

Run: go test -tags nogui ./internal/gateway -run 'Tier|Fast' -count=3
(ok); go vet; gofmt -l clean. Broken by hand: with buildResponses' r.Fast
priority line off, the test fails for all three asks.
2026-10-15 23:08:01 +08:00
yetone ba0bd421ea provider, sessions: Grok's grok-4.7-build-fast is priced at twice grok-4.7, so a group of Cursor's and Grok's Grok 4.7 fast counts Grok's calls too (TradingLife on Discord)
cbc96b599 priced Cursor's grok-4.7-fast ids, but the group's other half,
Grok's own fast variant, stayed unpriced: Grok Build lists it as
grok-4.7-build-fast, which no models.dev catalog has, and
TestCursorGrokFastPrice asserted it unpriced. Every call the group sent
to Grok (built-in or moved to the Grok plugin, both provider "grok") was
recorded with no cost, so on v0.1.1247 the group still showed none for
those calls.

xAI says what it costs (https://x.ai/news/grok-4-7, read 2026-10-15):
"We also serve a fast variant with twice the output speed at twice the
price". Provider.ListPrice now prices a Grok account's (Account.Agent
"grok" or the grok plugin's) grok-<ver>-build-fast, at a window too
(@500k), at twice its model's list price, every tier with it ($4 / $1 /
$12, $8 / $2 / $24 past 200k for grok-4.7). A Grok CLI session's bare
grok-4.7-build-fast on the Sessions page is priced the same way. Other
providers and a build-fast of a model with no price stay unpriced.

Not changed: a member sent fast through Group.Fast (Cursor plugin
grok-4.7 with service_tier priority, or Codex priority) is still priced
at the standard rate; no record's price reads TierSent yet.

Run: go test -tags nogui ./internal/provider ./internal/sessions
./internal/usage (ok); go vet -tags nogui for darwin, linux, windows on
provider and sessions; gofmt -l clean. Broken by hand: with the
grokFastPrice lookup off, TestGrokBuildFastPrice fails for the built-in
and the plugin; with the sessions branch off, TestPriceOfGrokEffort
fails. Not checked against the reporter's own usage log or a live Grok
account.
2026-10-15 23:08:01 +08:00