4794de398ea8337d223a91e207181c56fcf4ad76
3181
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f8214ec972 |
provider: a third-party Anthropic API that refuses x-api-key and Authorization together is sent one, picked in the editor or learned from its 401 (Aloha on Discord)
magpie sends a user's own Anthropic-compatible provider its key in both
x-api-key and Authorization: Bearer. Some relays answer 401 "鉴权 header,
x-api-key 和 Authorization 不可以同时存在", so every request failed.
- Provider.AuthHeader ("" both, "x-api-key", "bearer") picks which
AuthHeaders sends on the Anthropic protocol. Anthropic's own API,
Bedrock, Azure, Vertex and subscription accounts are untouched: they
send x-api-key alone (or their own) whatever it says, and BothAuth()
is false for them.
- Left at both, a 401 whose body catalog.BothAuthRefused tells as that
refusal (names both headers and says they can't be together, Chinese or
English) is asked once more with x-api-key alone, then Bearer alone
(RetryOneAuth, in the gateway's forwardOnce and the provider test's
probe; the model-list fetch through catalog.fetchOne too). The first not
answered 401/403 is saved (LearnAuthHeader), never over a pick the user
made. A request carrying the user's own Authorization/x-api-key header
is never retried; any other 401 is passed on as it came, asked once.
- The editor has a "Key header" row (Both / x-api-key /
Authorization: Bearer, the app's segmented control) while the provider
has a third-party Anthropic URL; strings in zh, zh-TW, ja, de.
- docs/subsystems/providers-accounts.md: an "Anthropic key header" row.
Run (sandbox HOME, GOCACHE/GOMODCACHE pinned, set -o pipefail):
- gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...;
GOOS=windows go vet ./...; GOOS=linux/windows go build.
- go test -tags nogui ./...: 47 packages ok; agent and gateway timed out
at 10m under load average ~50-98 (other sessions' test runs), so rerun
with -p 1 -timeout 60m: agent ok; gateway ok but for
TestOTelWaterfallIncludesUnbilledFallback, a load flake unrelated to
this (it reads only the first 200ms OTel export; passes 5/5 alone),
filed as #1794.
- New tests: internal/provider/authheader_test.go (official Anthropic and
Bedrock unchanged for every pick; Aloha's 401 body retried with
x-api-key and kept; Bearer-only relay learns bearer; the model list
learns; another 401 and the user's own header aren't retried; a user's
pick isn't overwritten), internal/gateway/authheader_test.go (a
/v1/messages turn through the gateway to such a relay succeeds and the
next Chat Completions turn goes with one header first).
- Broken by hand: RetryOneAuth returning at once and AuthHeaders ignoring
the pick -> TestAuthHeaderChoice, TestRetryOneAuthLearns,
TestRetryOneAuthBearer, TestOneAuthHeaderRelay FAIL; the list retry off
in live.go -> TestListLearnsOneAuth FAIL.
- GUI: provider-auth-header.test.cjs 20/20 in chromium and webkit, en and
zh, 390px wide; the editor's other tests (provider-*, nokey-editor,
editor-short-window, segs-*, vertex-editor) 439/440, the one
(provider-discovery, chromium zh) passing 26/26 alone.
Not tried: a real relay of Aloha's; the retry is built from the body the
user quoted.
|
||
|
|
aafddbe589 |
gateway: a Claude Code turn after its prompt suggestion goes on in its run, taken back from the suggestion; a turn that finds no run says why (#1638, chicring)
Cause (case 2: 41 messages told to a new Claude Code at 02:40:00, minutes
after the last reply at 02:37:13, no stop log). Claude Code 2.1.290 asks
its prompt suggestion after each turn: the conversation so far, with the
turn's system prompt, tools and thinking, and one more user message,
"[SUGGESTION MODE: ...", with no system message after it. That request
goes on from the turn's reply, so resume handed it the conversation's
run, and ended kept the run waiting at the suggestion's reply. The user's
real next turn didn't follow the suggestion, found no run under its key,
and was told the whole conversation in a new run (88k tokens written to
the cache again). Nothing was logged because nothing ended.
Fix. ended keeps, beside the run's new key, the key it went on from
(behindKey) and the turn's uuid (behindTurn). resume, finding no run
under a turn's key, takes one whose behindKey is that key, rewinds it to
behindTurn (rewind_conversation, as letGo does), marks it rewound so it
isn't shelved, and tells it only the turn's messages. A run that can't be
rewound is let go and the turn told whole to a new run, as before.
Logging. A turn after a reply that starts a new run logs "claude: no run
waits for this turn: <why>" (whyNoRun): it went on with a turn this one
doesn't follow, waits under another key (model, settings, system prompt
or tools differ), waits at an earlier turn, is busy, ended (how long ago
and why: abortFor's reason, or how Claude Code exited), or no run here
had the conversation. "tool results no run waiting" now adds "the run
that made the calls ended Xs ago: <why>" (whyCallsLost).
Case 1 (499 mid-reply, then "tool results no run waiting" and 17 messages
told) is not fixed. The run that answered had been started anew for that
turn, so letGo has no earlier user message to rewind to, and its results
were already handed to it over MCP. Keeping its cache would mean rewinding
to Claude Code's own tool_result message and telling the results again as
text, or interrupting instead of ending the run; neither can be checked
without the reporter's request shapes, and a fork that took the lead's
calls (claimResume) looks the same from here. The new log line says which
run ended and why, so the next report can tell.
Tests (claude_side_question_test.go), with 2.1.290's request shapes
(billing line with changing cch, 1h cache_control, adaptive thinking,
output_config effort, context_management, system messages, signed
thinking sent back):
- TestClaudeSideQuestionKeepsTheConversationsRun: turn, turn, suggestion,
real turn go to one Claude Code (turn 4), rewound to the suggestion's
uuid, told only the new message; twice. Red with the take-back disabled
("went to another Claude Code: pid ... turn 1").
- TestClaudeSideQuestionNotRewound: a run refusing the rewind is let go,
the turn goes to a new run, 1 run left. Red with the fix disabled (2 runs).
- TestClaudeNoRunSaysWhy (gone / another key) and
TestClaudeToolResultsNoRunSaysWhy: red with the log line, or the
lostCalls record, removed by hand.
Run:
- the new tests -race -count=5: ok
- real e2e: the real 2.1.290 client in -p --prompt-suggestions against
the bridge, whose Claude Code was the real 2.1.290 too, both against a
local mock of Anthropic: one bridge run for the whole session, "taken
back from the side question" logged after each suggestion, 0 runs told
the whole conversation; the real turn's request to the mock went on
from the reply before the suggestion, without it.
- gofmt -l .: clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: ok
- set -o pipefail; go test -tags nogui ./... at load average ~45-53:
every package ok but agent, gateway, library, plugin and provider, which
hit go test's 10m default. Rerun with -timeout 40m -p 2: agent, library,
plugin ok; gateway red only in TestOTelWaterfallIncludesUnbilledFallback
and TestOTelWaterfallFailureAndCancellation (#1794, already filed: they
read only the first OTel export; -count=10 alone passes); provider red
only in TestCopilotSecretToolUsername (#1627, already filed; red 1 of 5
alone under load, then 5 of 5 green). Neither touches this change.
- the new tests with the bridge's neighbours (LetGo, TurnGivenUpOn,
ToolResultsGivenUpOn, Idle, EndedRunSaysWhy, ForksAnswering) -race
-count=5: ok
Not tried: the real Claude subscription upstream, the interactive TUI
(the -p flag turns on the same suggestion), other side requests
(extract_memories, away_summary, /btw), case 1's actual requests.
|
||
|
|
1bf722e289 |
proc, provider, agent: a claude (or other agent CLI) that is a mise wrapper script is run as the program mise names, and a Claude sign-in that gets no link says which program it ran (deluxe on Discord)
deluxe (Omarchy Linux, magpie started from the desktop) never saw the
Claude sign-in link. ~/.local/bin/claude was a script ending
`exec mise x "claude" -- "claude" "$@"`; without the shell's mise
environment, `mise x` looks claude up on PATH, finds the same script
(~/.local/bin is before mise's shims) and it runs itself for ever.
What changed:
- proc.Unwrap / proc.LookPath (internal/proc/wrapper.go): a small #!
script whose line is `[exec] mise|rtx x|exec [opts] [tool] -- <name>`
is resolved with `mise which <name>` (then `mise which --tool <tool>
<name>`), run as a probe (process group killed) with a 5s timeout,
magpie's environment and the home folder as cwd. The answer must be an
executable file that isn't the wrapper or another wrapper; otherwise,
or with no mise, the old path is kept. Answers are cached per file
(path, mtime, size); a failed ask is retried after a minute.
Windows is unchanged.
- proc.FindTool (claude via claudecode.Find: the sign-in, the gateway's
Claude subscription, `magpie claude-code`) unwraps what it finds.
- The siblings that looked an agent CLI up with exec.LookPath use
proc.LookPath: agent.binAt (detection, CLI version/update), codex,
kiro-cli, devin, cursor-agent, Air's opencode, nativemodels' npm
package lookup.
- The Claude sign-in already gave up after linkWait (30s) with "claude
auth login gave no link to open". It now adds the last line the CLI
printed, or, when it printed nothing, the program it ran and to run
`<path> auth login` in a terminal to see what it does.
asdf shims (`exec asdf exec "claude" "$@"`) are left alone: asdf exec
resolves the real program itself and doesn't recurse.
Verified (macOS, sandbox HOME, Go caches pinned):
- New tests: internal/proc/wrapper_test.go (wrapper -> mise's program;
no mise -> wrapper; mise fails / names the wrapper / names a folder /
hangs -> wrapper, and the hung mise's pid is gone; deluxe's own fixed
script, a node launcher, a wrapper of another command, a commented
line -> unchanged and mise never asked; parse cases; --tool retry),
internal/provider/signin_claude_wrapper_test.go (the full Claude
sign-in through the wrapper with a fake mise that really recurses:
link shown, account added; with no `mise which`, the sign-in fails in
linkWait naming the wrapper).
- Break checks: with find.go put back, TestFindToolUnwrapsMiseWrapper and
TestFindToolAsksWithWrappersTool FAIL (FindTool = the wrapper), and
TestClaudeSignInThroughMiseWrapper FAILs with "claude auth login gave
no link to open: .../local-bin/claude printed nothing in 5s". With the
old error string, TestClaudeSignInWrapperThatNeverStarts FAILs.
- gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
GOOS=windows go vet ./...; GOOS=linux go build -tags nogui;
GOOS=windows go build.
- go test -tags nogui ./...: every package ok except internal/agent and
internal/gateway, which hit the default 10m timeout with the machine
at load ~45 (different tests each run, none in the new code). Those
two were rerun with -timeout 40m; origin/main 217d2f8f2's
internal/agent alone took 2094s under the same load.
- Rebased on
|
||
|
|
0738154520 |
plugin, gui: an installed plugin's row and page show its own magpie.icon, not its first provider's (#1775)
peterroe's plugin signs in to several providers. Each provider gets its own picture from the auth hook, and package.json's magpie.icon is the picture for the plugin itself. Settings → Plugins → Installed only took a plugin picture from the market listing. A plugin that isn't listed (installed from a path, git or an unlisted npm package) had none, so its row and its page showed its first provider's picture. - plugin.InstalledIcon reads magpie.icon from the installed package.json. It goes through the same ownIcon check as a listing's icon (data: or https only). - pluginsState stores the picture through provider.RepoIcons, as listed plugins' pictures are, and returns it as `icon` on each plugin entry. - plugins.js: the installed row and the detail page use the listing's icon, then the plugin's own, then its first provider's, as before. - Docs (en, zh, ja): magpie.icon is the plugin's picture (Discover card and Installed row) and the fallback for providers without their own. A plugin of several providers gives each provider auth.icon. Run: - go test ./internal/plugin ./internal/gui: ok. TestPluginsStateGivesThePluginsOwnIcon covers a data: icon (kept), no icon and a plain-http icon (both ""). - internal/gui/tests/plugin-own-icon.test.cjs: Chromium and WebKit, en, zh, zh-TW, ja, de, at 980 and 420 wide. It fails on the old plugins.js (the row shows pa.png). - The plugins GUI tests: 34/34 in each engine. - gofmt; go vet darwin, windows, and linux -tags nogui. - Full go test ./...: the only red is gateway OTel timing under load ~79. That's #1794, commented there; alone it passes 3/3. Not tried with peterroe's real package; the fixture follows the layout the issue describes. |
||
|
|
c533499446 |
provider, gui, cli: a group can keep its models out of the lists agents see, offered through the group alone (#1783)
cybershape asked for a client's model list to show only a group, not every model behind it. A provider could already be kept for routing groups (Provider.Unlisted), but that hides the whole provider, and the models a group names may come from providers used elsewhere too. Group.Unlists (json "unlists"): the models a group names (a member fixed at an effort counts as its model) and those its patterns match leave Catalog(), so `magpie models`, /v1/models and every agent's list (CatalogFor) show the group without them. They stay in Served(), so a group routes over them and a request naming one as provider/model is still answered, and Unlisted() returns them for the GUI as it does an unlisted provider's. A nested group keeps its own setting; a group switched off or hidden keeps nothing out. With no group unlisting, Catalog() takes a fast path and is unchanged. - Routing view: the group editor's "Model lists" (Its models too / The group alone, segmented, with a hint), saved with Save; the card shows "Its models unlisted". Both group Save paths send unlists. zh, zh-TW, ja, de. - CLI: `magpie group set <id> listed=no|yes`; `magpie group <id>` shows listed: no. - TUI: the group member picker offered Catalog(), so models kept out of the lists (an unlisted provider's, before this too) couldn't be put in a group from the TUI. It offers Served(), as the GUI's picker does. - docs/reference.md, Routing groups: listed=no. Product call: a per-group switch, off by default, rather than hiding members of every group, so existing lists don't change under anyone. Run: - go test ./internal/provider -run 'Group|Catalog|Unlisted|Served', ./internal/gui, root package, ./internal/tui: ok. TestGroupUnlistsItsModels fails with the Catalog filter removed; TestMemberOptionsOfferUnlistedModels fails with the picker on Catalog(); TestApplyGroupPairs covers listed=no/YES/maybe. - GUI group-unlists.test.cjs, Chromium and WebKit, en zh zh-TW ja de, at 1100px and 420px: 20/20. i18n-keys: ok. - gofmt; go vet darwin, windows, linux (-tags nogui): clean. Not tried: with the reporter's own client; a real agent's model file written after toggling (CatalogFor is covered by the test). |
||
|
|
0d58ec8dcb |
davsync: a write a server without conditional PUTs let another go over is merged again at the next sync (#1776)
On an S3 server that refuses If-Match (Aliyun OSS answers 400 NotImplemented), put falls back to HEAD then an unconditional PUT. Two computers writing in the moment between both pass the HEAD, both are told they wrote, and the later file is kept. Worse, the loser's next sync then took the winner's file as having seen its own: its st.Remote was the file it wrote, so its changed parts looked unchanged here and changed there, and the old parts were brought in over its own changes. The edit was lost on the server and on the computer that made it. - version.Blind marks a write the server didn't check (s3.go's fallback). - state.Blind keeps, for such a write, the file's sum and the remote and local part hashes from before it. The next sync that reads another file than that one merges from before the write. What this computer changed counts as changed again and goes back up beside the other's. A 304 or the same file clears it. Restore and Upload clear it. - docs/reference.md says what happens on such a server. No compare-and-swap exists on OSS, so the race itself isn't closed: the other computer's file is kept for up to one sync interval (3 minutes) before this computer's change is merged back. The reporter's AppendObject journal would close it but needs every computer upgraded and OSS-only signing. If the other computer saw this one's write and then changed the same part again, the next sync can't tell that from a write that went over it. It counts the part as changed on both sides: the newer stays, the other is saved, and a notice says so. Nothing is lost. Run: - TestS3BlindWriteGoneOverIsMergedAgain (fake S3 with no conditional writes, two computers): A renames a provider and B sets the theme, B's PUT goes over A's, then A's next sync puts both on the server with no conflict notice, B brings in the rename, and nothing more is written. With the reset taken out (broken by hand), it fails: "A's rename here after its next sync: \"DeepSeek\"". - go test ./internal/davsync whole. Not tried against real Aliyun OSS: the fake answers conditional PUTs the way the reporter quotes OSS (NotImplemented). |
||
|
|
446bffcac7 |
gateway, gui: a Routing row's share used renews with its own window, not the biggest one (#1778)
Vigilans' Factory account showed "32% used · renews in 27 days": the week's 32% beside the month's reset. Allowance.For gives the fullest window's share and the renewals biggest first, and routing.js paired the share with renews[0], so for any account of more than one window the row mixed two windows. - provider.Allowance.Fullest(model, now): the reset of the window For's share is of (the later of two as full; a window whose reset has passed counts as empty, as For does). - The trace's Weighed gains usedRenews (from weighRouted's left.fullest); routing.js's usedRenews(w) uses it in both the story rows and the account rows, and falls back to renews[0] only for an account of one window (a route recorded before this commit). - Smart's order is unchanged on purpose: it goes by the biggest window, and Factory's month holds less than its weeks add up to, so what a week leaves isn't lost at the week's reset. docs/reference.md says so, and gateway-routing.md names Fullest/usedRenews. Run: - go test ./internal/provider ./internal/gateway -run 'Fullest|UsedRenews|Weigh|Routing|Smart' and the packages whole. - TestUsedRenewsWithItsOwnWindow fails with left.fullest set to the biggest window's reset (broken by hand, then restored). - routing-key-windows.test.cjs: 44/44 in Chromium and WebKit, all languages and widths; it fails on HEAD's routing.js. - Every routing-*.test.cjs plus panel-routing in both engines: 594/601. The 7 WebKit failures are clicks waiting for an element to be "stable" under load average ~44, in routing-group-fold (#1612, #1672), routing-sessions (#1307) and routing-days-fit. routing-days-fit passes run alone. The other two fail the same alone with HEAD's routing.js. Not tried against a real Factory account: the windows are those the Factory plugin's limitWindows reports (5h/7d/30d with resetsAt). |
||
|
|
04747d00ad |
provider, gui: a ChatGPT sign-in whose port 1455 can't be opened goes on, says why, and is finished by the pasted address (#1782)
nianlee-official's ChatGPT sign-in stopped at "port 1455, where ChatGPT
sends the sign-in back, is busy" with nothing of ChatGPT's running. That
message was given for every listen error: a Windows port in a range
Hyper-V, WSL or Docker excluded (WSAEACCES, no program holds it) read the
same as one another program held, and either way the sign-in stopped,
though ChatGPT's page puts the code in the address the browser ends on.
What changed:
- begin (signin.go): when listenCodexCallback can't have the port, the
codex sign-in still starts. Its handler serves no port and it waits for
the address, pasted, as a Docker sign-in does (pastedCallback goes
through the same handler). SignInState says why in CallbackBlocked
("reserved" for Windows' WSAEACCES 10013, else "busy") and names the
port in CallbackPort. The redirect stays localhost:1455, the only one
ChatGPT's client takes. listenCodexCallback returns the real error.
- GUI: the sign-in box says which of the two it is, with the port, in
place of the server-or-Docker guess (5 languages). CLI: the same.
- Not changed: Kiro's built-in tries ten ports already; the ChatGPT API
sign-in falls back to any port.
What was run:
- go test ./internal/provider -run
'TestCodexSignInGoesOnWithItsPortTaken|TestCallbackBlocked|TestCodexSignIn|TestPasted|TestLoopback'
-race -count=5: ok. With begin returning the listen error again,
TestCodexSignInGoesOnWithItsPortTaken FAILs: "the sign-in stopped at the
taken port: listen tcp 127.0.0.1:61025: bind: address already in use".
- signin-port-blocked.test.cjs (new), signin-paste-codex,
signin-callback: 45/45 in Chromium and WebKit, en/zh/zh-TW/ja/de, 900
and 420 wide. With app.js from HEAD the new test FAILs (the note never
shows, TimeoutError).
- gofmt -l, go vet (darwin, GOOS=linux -tags nogui, GOOS=windows), full
go test -tags nogui ./... before the push.
Not tried: a real Windows excluded port range (the Windows box was
unreachable over ssh); the reserved case is tested with errno 10013 as
Go's net.Listen wraps it. The reporter's own cause isn't confirmed yet;
the issue asks them.
|
||
|
|
bfaedf1830 |
gui, profile: the profile in use is ticked and named on the panel's Profiles button, not a count read as its name (superhtoooth on X)
superhtoooth (macOS): 保存方案设置了方案名字,但是应用方案没有用这个名字。
menu 里面变成了方案 1,方案 2。而且在应用里面没有显示当前使用的方案.
The bug: the tray panel's Profiles button showed the number of saved
profiles next to its label ("方案" + "2"), which reads as a profile
named 方案 2. Profiles were saved and applied under the typed name all
along; nothing anywhere said which profile was in use.
What changed:
- profile.InUse: a profile is in use while applying it would change
nothing on this computer - every detected agent's saved field is as
the profile has it (compared with the same renamed-ref spelling Apply
writes), its model lists are held (provider.ModelListsHeld, a dry run
of SetModelLists via the extracted putModelLists) and its library
setup is as saved (library.Holds, the mirror of Restore). A profile
that touches no agent here is not in use.
- Why not "last applied": that would stay ticked after the user changes
a model by hand, a tick that lies. With this definition a profile
saved from the current setup is in use at once, a hand change clears
the tick, and applying puts it back. Two identical profiles are both
ticked; the button names the first.
- GUI: /api/state carries inUse. The panel's button names the profile
in use (a pop-up button showing what is picked), else counts them as
before; its chip gets a check mark and aria-current, in panel and
window; the chip's tooltip and its details say "In use" (string
already in every language). CLI `magpie profiles` marks it, the TUI
notes "in use". Docs (reference, start en/zh/ja) say so.
What was run:
- go test ./internal/profile (new TestProfileInUse: save, hand change,
apply, hidden model list, library instructions, absent agents) and
./internal/gui (new TestStateProfileInUse through the HTTP handler),
scratch HOME. Broken by hand: field compare, ModelListsHeld,
library.Holds and state's InUse each turned a test red.
- go test -tags nogui ./... in a scratch HOME (the four slow packages
rerun with -timeout 40m under load ~45).
- GUI: new profile-in-use.test.cjs (reporter's steps in the panel at
360px, every language, plus the window) and panel-profiles,
profile-confirm, profile-details, old-webkit, i18n-keys, gui-zh-tw,
gui-ja, gui-de in chromium and webkit: all pass. Old app.js fails the
new test.
- Real CLI in a sandbox HOME with a codex config: save/use/profiles
show the mark, and it goes after a hand edit.
- gofmt; go vet darwin, linux (nogui), windows.
Not tried: the real tray app with real agents, and Windows/Linux at
runtime.
|
||
|
|
f5dd4d604e |
gui: the Linux app's sidebar button switches the layout at once, no view transition, which WebKitGTK with compositing off crashed in (depravity_wings on X)
Since
|
||
|
|
9964535adc |
provider: a model models.dev has just listed without its reasoning levels takes its family's, so Codex's picker offers them for a relay's gpt-6.1-sol (NextCommit on Discord)
NextCommit's Codex showed no reasoning-effort picker for a relay's (an OpenAI-compatible key provider) gpt-6.1-sol, while gpt-6-astra had one, and magpie's log said the effort went from none to low. models.dev had listed gpt-6.1-sol as a reasoning model but without reasoning_options yet, or not at all, so magpie knew no levels for it: Codex's catalog got supported_reasoning_levels [] (no picker), and the gateway, not knowing "none" was one of the model's levels, sent Codex's "none" as "low" (#899). What changed: - catalog: a thinking model with no levels of its own and no budget takes the levels of the newest model of its models.dev family (same provider, thinking, with levels) released on or before it (mdProvider.levels). Used by Provider and ListedBy. A model with its own levels, a budgeted one, one that doesn't think, or one with no family is as before. - catalog.KinEfforts: for an id no provider lists, the levels of the newest listed model of the same shape with the version numbers left out (gpt-6.1-sol -> gpt-#-sol), never a budgeted or non-thinking one. - provider.borrowedEfforts: tries ListedBy, then EffortsOf, then KinEfforts. Entry.Efforts, which every agent's model list is built from (Codex, Claude Code, OpenCode, dsh, ...), goes through it, as do Known, Levelless, groups and plugins. - Xiaomi's mimo, which takes a thinking switch only (#214), still gets no levels; gpt-4.1 gets none. With levels known, an effort the user picks in Codex goes through as picked. The none->low mapping remains for models whose levels are still unknown (#899). What was run: - New tests: TestFamilyLevels (catalog) and TestNewModelTakesItsFamilysLevels (provider, Codex catalog levels for relay/gpt-6.1-sol). Both fail with levels() and the KinEfforts call neutered (levels "" against the family's), and pass with them. - Real Codex CLI 0.162.1 under a sandbox HOME against a sandbox magpie gateway (127.0.0.1:3592) and a fake relay (127.0.0.1:3591) listing gpt-6.1-sol and gpt-6-astra. The models.dev cache had reasoning_options stripped from every gpt-6.1-sol entry to match the reporter's. - Built from origin/main: magpie-models.json gave relay/gpt-6.1-sol default None, levels []. - With this change: default medium, levels none..max,ultra. - Codex /model showed "Select Reasoning Level for GPT-6.1 Sol · relay". Picking Medium, High and None sent reasoning_effort "medium", "high" and "none" to the relay. - gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...; GOOS=linux and GOOS=windows builds: all clean. - go test ./... under a temp HOME, with GOCACHE and GOMODCACHE pinned. Every package passed except four that hit the 10-minute default timeout with load average ~40 (TestCopilotSecretToolUsername's 5s secret-tool wait as well). Rerun with -timeout 40m -p 2, internal/agent, gateway, library and provider all passed. Not tried: the Claude Code, OpenCode and dsh model files written for the same relay model; they take Entry.Efforts like Codex. |
||
|
|
17c12621bb |
provider: moved Cursor users get plugin 0.2.8, whose empty-reply error says what Cursor's Run sent before it (magpie-community/plugins#60, congee949)
Raises the cursor mover's min from 0.2.7 to 0.2.8 (published, npm view shows 0.2.8), so keepMovedCurrent updates moved users. 0.2.8 adds the thinking length, tokens, refused built-in tools, unknown messages and last frame to the empty-reply 502, for the next report on plugins #60. Ran gofmt -l, go vet (darwin, windows) and go test ./internal/provider (ok, 525s). |
||
|
|
217d2f8f20 |
site, readme: APINEBULA joins the sponsors, a card on usemagpie.ai and a small logo under the README badges
APINEBULA paid for the website seat and the en/zh README seat. The logo is the SVG they sent (143x37). A white-text copy is used on dark backgrounds, through .for-light/.for-dark on the site and <picture> in the READMEs (the .bird invert would turn the orange mark blue). The site's sponsor cards now stack in an equal-width grid, so the two cards line up; the intro has zh, ja and de strings. Run: site worker and install tests (28 pass). The home page served locally and checked in chromium and webkit, at 1200 and 390px, light and dark, in en/zh/ja/de (dictionary applied in the page): both logos load, the right one per theme, and there is no horizontal scroll. |
||
|
|
48e59c5b89 |
plugin: the unofficial plugins on GitHub aren't cut short through a slow proxy, and a list cut short is asked again in 20s, not kept ten minutes (larchsis on X)
larchsis (Windows, no system proxy, magpie's own proxy on) saw no
unofficial plugins on the Plugins page, and saw them with the system
proxy on and magpie's set to automatic.
No request bypasses magpie's proxy. Every listing and install read
(market.json, npm info and search, GitHub's search, package.json and
README, Bun's download, plugin icons) goes through http.DefaultClient or
DefaultTransport, which netproxy.Install routes through settings.Proxy,
else the environment, else the system proxy (HKCU Internet Settings on
Windows). Checked with a counting CONNECT proxy in a sandbox magpie on
macOS and on the Windows box: every connection to api.github.com,
raw.githubusercontent.com and registry.npmjs.org went through it, and
lsof / Get-NetTCPConnection showed none going direct.
The cause is timing. askTagged gave the whole listing 8s, six package.json
reads at once, each bounded by that same 8s, and a repository whose read
hadn't finished was left out. The cut list was then kept ten minutes, and
on disk for a restart. Through a sandbox proxy that adds latency per
chunk: no delay 29 repos, 150ms 21, 300ms 6. A slow proxy loses most of
"Unofficial, on GitHub", and when it loses all of them the section is gone.
The two setups differ in latency and in what was cached, not in proxy
handling.
Now:
- Reads go on past the page's wait (taggedEach 20s each, 12 at once), on a
context detached from the request. They are kept by repository and push,
as before, so the next ask has them.
- A repository whose read didn't come in time is as the last list had it
(in memory, else on disk), with the search's current stars and
description.
- A list that left one out is asked again after 20s, not ten minutes. Its
copy on disk is dated so that a restarted magpie asks again too.
Run:
- TestTaggedReposSlowRead (new) holds word-guard's package.json past a
300ms wait. It fails on the old code (5 repos, word-guard missing). It
also fails with each part broken by hand: no fallback to the last list,
a partial list kept 10 minutes, reads cancelled at the wait, and the disk
copy not aged back.
- Sandbox magpie web (own HOME, own ports, proxy 127.0.0.1:3481 with
injected latency), no cache: at 300ms 11 repos at 8s, then all 29 25s
later (the old code kept 6 for ten minutes). At 1s none at first, all 29
25s later.
- go test ./... on
|
||
|
|
5e7efce3bc |
gateway: a key held to some models gets its model list as fast as one held to none, its groups read once a list, not once a group (#1762, LumenXY on X)
LumenXY's /v1/models over Tailscale took 12.4s with a gateway key held to
some models and 1.5s with an unheld one, so apps that list models timed
out and showed an empty list.
Cause (pprof, 1,000 models, 500 found groups): keyAllowed checked each
catalog entry on its own. Each group entry called provider.FindGroup,
which builds a new GroupFinder, so every provider's models were read again
(providerEntries, its files stat'ed and settings loaded) once a group.
That was 96% of the request. Each glob in the key's models was also
compiled to a regexp on every check, and a key held to accounts listed
each provider's accounts (Logins, from disk) once a model.
What changed:
- gateway/key_models.go: keyAllowed weighs a list through a keyList made
for that request alone. It has one GroupFinder and each provider's
AccountIDs read once. entryAllowed and accountServes are the same
checks over them. accountServes(who, p, model) stays for decide.go's
single check.
- access/models.go: globRe keeps each pattern's compiled expression. A
pattern compiles to the same expression whatever key holds it, so
nothing kept goes stale. The map is let go of whole past 4096 patterns.
- gui/groups.go: groupsState (the Routing page) called FindGroup once a
group too, the same class. It now uses one GroupFinder.
Every route that lists models goes through keyAllowed: /v1/models,
/v1/models/{id}, /v1beta/models, /v1/codex/models, Muse's list and the
deciders. The single-model checks (serve, count_tokens, embeddings,
System One, draw, video) ask one group and are unchanged. Nothing is kept
past a request, so a change to a key's models or accounts, a group's
members or an account's own models shows on the next request. No key
limit is loosened. The documented behaviour is unchanged, so no subsystem
page changes.
Tests:
- TestKeyListShowsWhatItDid compares keyAllowed with the old per-entry
check, kept in the test, for 14 keys over a catalog with found groups,
named and nested groups, a no-key provider and an account's own models.
The keys cover exact ids in any case, globs, group/<id>, group/*, a
group inside one named, accounts, and models with accounts.
- TestKeyListSeesChangesNextRequest goes through /v1/models and
/v1beta/models on one server while the key's models, the group's members,
the key's accounts and an account's models change.
- TestModelPatternsKeptCompiled checks each pattern keeps its own
expression and that past the cap works.
- Broken by hand, each went red: the accounts memo shared across providers
(ShowsWhatItDid), the GroupFinder kept across requests
(SeesChangesNextRequest), and the glob cache keyed by the pattern's first
letter (KeptCompiled).
Numbers, BenchmarkHeldKeyListsModels (2 providers x 500 models, 500 found
groups, M4 Pro):
- held to models: 2.36s before, 55ms after
- held to accounts: 2.35s before, 60ms after
- held to none: 43ms either way
Real use: sandbox magpie on 127.0.0.1:3486 with its own HOME, the same
1,500-entry catalog, a key held to 5 patterns, and curl 3x each:
- held key, /v1/models and /v1beta/models: 27.8-28.7s before, 0.18s after
- unheld key: 0.12s either way
- The held list (212 entries) and the unheld one (1500) were
byte-identical between the old and new builds.
- Changing the key's models while the server ran showed on the next
request (10 entries, then 212 again).
Run at origin/main
|
||
|
|
8f2a314cf9 |
gateway: a ChatGPT account's turn goes zstd-compressed, as Codex's own client sends it (ylorn on X)
ylorn (X, v0.1.1202) sent a text-only gpt-6-luna turn of 1,100,224 bytes
straight to chatgpt.com/backend-api/codex/responses. Sent plain it got 503.
The same turn zstd-compressed (259 B) got 200. magpie decodes Codex's
inbound zstd and sent the backend plain JSON, so the turn got 503 through
magpie too.
What Codex does (openai/codex a9b08151, 2026-10-11):
- codex-rs/core/src/client.rs:1704-1712 responses_request_compression:
Zstd only with the enable_request_compression feature, a sign-in that
uses_codex_backend, and the OpenAI provider.
- client.rs:1780: used for the POST /responses stream only.
/responses/compact and /models go plain.
- codex-rs/features/src/lib.rs:1411-1416: the feature is Stable and on by
default.
- codex-rs/protocol/src/auth.rs:54-63: uses_codex_backend is true for the
ChatGPT sign-ins and false for ApiKey and Bedrock.
- codex-rs/codex-api/src/endpoint/responses.rs:130-147 sets it for
/responses.
- codex-rs/http-client/src/request.rs:196-217 compresses with
zstd encode_all at level 3, sets Content-Encoding: zstd, and never
compresses twice.
What changed:
- provider.CodexCompressed compresses a body sent to CodexBase/responses
with klauspost zstd, already a dependency. It uses SpeedDefault (about
level 3) and no frame checksum, like libzstd's default. It sets
Content-Encoding, Body, GetBody and ContentLength to the compressed
bytes, and returns the wire size.
- It is called once the body is final and signed: in forwardOnce for a
codex account, in codexUpstreamOn (the relay) on every try (so a try
again or a body without an unreadable image is compressed afresh), and
in warmCodex.
- Unchanged: /responses/compact, an sk- key's requests to api.openai.com,
every key provider (even one at the same URL), and a body already
encoded.
- The plain body is still what magpie keeps, masks, traces and shows.
- codexDropped (#1628, a2b96139c/8029d98b7) judges "large request" by the
bytes sent on the wire. A text turn that compresses to a few KB and is
reset is a small request's 503, not a "MiB" hint asked again. A
screenshot's random bytes stay past 1 MiB, and those are still asked
again.
- The gateway and provider TestMains leave turns plain
(CodexZstdForTests), since their fake backends read the body as JSON.
The new tests turn it on.
- TestAsksOwnBackendAgreesWithTheGatewayDispatch read any call whose sixth
letter is upper case (CodexCompressed) as a serveX dispatch. It now
needs the "serve" prefix. Removing "kiro" from asksOwnBackend still
turns it red.
- docs/subsystems/gateway-routing.md: the "sent plain JSON" line now names
this exception.
Tests: internal/gateway/codex_zstd_test.go covers the accounts loop, the
relay (inbound zstd and plain), a try again after a drop, compact and an
API key plain, a key provider at the same URL plain, and a reset judged by
wire bytes. internal/provider/codex_zstd_test.go covers the round trip,
GetBody, Content-Length and the URLs left alone. Broken by hand, each went
red:
- no compression in forwardOnce: Account and AskedAgain
- no compression in the relay: Relayed, AskedAgain and JudgedByBytes
- no account guard: KeyProviderTurnStaysPlain
- compact compressed: CompactAndAPIKeyStayPlain
- the drop judged by len(body): JudgedByTheBytesSent
Real account (the owner's ChatGPT sign-in, gpt-6-luna, 1,100,279 B
text-only body, 391 B zstd):
- Direct to chatgpt.com, twice: plain 200/200, zstd 200/200. ylorn's 503
did NOT reproduce from here (
|
||
|
|
e21ea07e47 |
gui: a client in the Usage page's Agents list can be hidden from it, and shown again from the line under it (ikunbots on X)
ikunbots asked to hide curl, Go-http-client, python-httpx and other clients
from the Agents list beside the agents they actually use.
What changed:
- Each Agents row has a "…" button that shows on hover (always on touch) and
opens the app's row menu (openRowMenu) with "Hide from this list".
Right-clicking the row opens the same menu. No native select.
- The hidden ids are saved by client id in settings.UsageAgentsHidden,
trimmed and deduped. They go through POST /api/usage/arrange
(agentsHidden), which changes only that field, and the Settings save
carries the field over.
- Hiding is display only. The ledger keeps the calls, and the totals, the
chart and every share still count them.
- When anything is hidden, a quiet "3 hidden" / "已隐藏 3 个" line sits under
the list. It opens the hidden rows, dimmed, each with "Unhide" / "取消隐藏".
No click scrolls the page: the scroll guard holds the clicked line in place.
- Where a pointer hovers, the "…" takes no room. Its margins give back its
width and gap, so a row at rest is laid out as on main (mobile-web's
desktop comparison is the same). It shows over the end of the share bar.
On phones (body.web) it has its own grid column.
- Translated into zh, zh-TW, ja and de. docs/subsystems/gui-shell.md
describes it.
What was run, in a worktree off origin/main:
- gofmt -l: clean.
- go build ./... and go vet ./...: pass.
- GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: pass.
- HOME=<scratch> go test -tags nogui ./...: 49 packages ok. Includes the new
TestUsageArrangeAgentsHidden, which covers saving, surviving a settings
save, narrowing and emptying.
- New usage-agents-hide.test.cjs: 32/32 in Chromium and WebKit. It covers
en, zh, zh-TW, ja and de at 1200, 560 and 390 (web). It hides by "…" and
by right-click, checks the POST body, unchanged totals and an unmoved
page, then unhides, reloads and checks the hidden rows persist.
- All 48 usage, panel-arrange and click-scroll GUI files: 503/503.
old-webkit and mobile-web: pass.
- Full GUI suite (6489 tests, concurrency 5): the reds outside this change
fail the same when run alone on origin/main
|
||
|
|
6a8b2c6831 |
provider: a moved ZCode account is brought to plugin 0.1.16, whose app sign-in follows ZCode only while it is signed in to the same account (LingYi_Stu on X)
Raises the zcode mover's min so keepMovedCurrent updates every moved user to @magpie-community/opencode-zcode-auth 0.1.16 (plugins d2be892). With the "ZCode app's sign-in" added for account A and again after ZCode switched to B, A's entry read ZCode's current credentials on every request, so it sent B's requests and its usage card showed B. 0.1.16 follows ZCode only while ZCode's user is the entry's account; otherwise it uses what was saved at sign-in, and asks for sign-in again when that session has run out. Published by the plugins repo's publish workflow; npm view says 0.1.16 is latest. Run: go test ./internal/provider/ (ok, 99s); gofmt -l internal/provider (clean); go vet ./internal/provider/ on darwin, GOOS=linux, GOOS=windows. |
||
|
|
3deb85685f |
gui: Usage's subscription cards in one row are as tall as each other, so their bottoms line up (ikunbots on X)
ikunbots ("magpie 的这个卡片可以对齐吗") and duanjl_china ("有的长有的短"):
Claude Code, Codex and Antigravity sat side by side in one row on the
Usage page, each as tall as what it held, so their bottoms were ragged.
What changed
- packUsage (app.js) still packs the cards into columns as #860 made it
(a short card stacks beside a tall one, never stretched to a row's
height). After placing them, the last card in each column gets a
min-height that takes it down to where the tallest column ends.
- Cards side by side in one row (one card per column) are as tall as
the tallest, bottoms on one line, content at each card's top.
- A stack stays a stack: the upper cards are as tall as themselves and
only the last one reaches down to end with the tall card beside it,
which is what #860 asked for (堆叠和 Codex 对齐).
- One column: each card is as tall as itself, nothing to line up.
- The min-heights are cleared before every measuring, so a re-pack
(resize, a fold opened, cards changed) measures each card as tall as
itself. A min-height rather than a stretch keeps a card that outgrows
it growing, so the ResizeObserver still re-packs.
- docs/subsystems/gui-shell.md says so.
Tests
- usage-pack.test.cjs:
- New: ikunbots' three cards (Claude Code 2 windows, Codex, Antigravity
6 families; content heights 107/169/217px) at 1400 and 1018px are one
row with bottoms within 0.5px; at 480px one column, each card as tall
as itself; widened again, one row lined up again.
- The reporter's #860 stack at 897/1018/1400px still stacks:
Antigravity as tall as itself, DeepSeek under it with the 7px gap,
ending where Codex does.
- sound(): a card is as tall as itself unless it is last in its column,
which ends with the tallest; no card is shorter than its content.
- The fold case: opening Codex's brief account grows what the card
holds; the card already reaching down to the stack's end stays that
tall rather than growing (was "the card grew").
- Broken by hand: no min-height applied -> "1400px: the cards' bottoms
line up" red in all 8 (chromium/webkit x en/zh/ja/de); min-height not
cleared before measuring -> "narrow: antigravity is as tall as itself"
red. Restored: 8/8 pass.
Run
- usage-pack.test.cjs in Chromium and WebKit, en/zh/ja/de: 8/8 pass.
- Every GUI test file touching the Usage page (75 files, those naming
#subscriptionUsage/.subscription-card/view=usage, plus click-scroll),
both engines, concurrency 6: 917/918 pass. panel-usage webkit en failed
once under that load ("asked: period=today&limit=1", a 2.4s poll in its
Requests-window step this change doesn't reach), passes 3/3 alone;
added to #1544 with its cause.
- Screenshots before/after with fixture data looked at: ragged row
before, one line after; 897px stack unchanged but for DeepSeek/Codex
ending together.
- No Go change; gofmt/vet/build not run. Full GUI suite not run.
|
||
|
|
6c1c0a7472 |
gateway, gui: magpie's image recognition is an MCP server of its own, /mcp/magpie/vision, with one analyze_image tool (JonahFu on X)
What: beside /mcp/magpie/web-search, the gateway serves the model that describes images (Settings › Models › Image recognition, else magpie's automatic pick) as a Streamable HTTP MCP server. analyze_image takes an image (absolute file path, http(s) URL or data:image URL) and an optional prompt: without one it is described as a model's image is (same cache and system text), with one the prompt is asked beside it. The JSON-RPC serving, guard and Origin check are shared with the web search server (serveMCP). A file path is read only for a local, unproxied caller, up to 20 MB, and only when its bytes are an image; another computer sends a URL or data URL with a gateway key. Each call holds the key's limit (budget.Reserve) and reads in Routing as the agent's analyze_image call. Settings › Models shows the address under Image generation (#visionMcpRow), in every language. Run: - go test -tags nogui ./... (no failures); gofmt -l clean; GOOS=linux and GOOS=windows go vet ./internal/gateway. - New TestVisionMCPAnalyzesImage / WithNoSeer / Guarded / HeldToKeyLimit. Broke the local() guard by hand: TestVisionMCPGuarded went red on the other computer's file path being read. - GUI (chromium + webkit, en/zh/zh-TW/ja/de, 1100 and 520px): vision-mcp, search-mcp, public-url-default, images-missing, settings-sections, i18n-keys, routing-vision-why: 95 pass. The row was first put between the two pickers and images-missing went red (it finds them by position), so it sits last. - Real use: this build under a sandbox HOME holding only the owner's OpenRouter provider, Image recognition set to openai/gpt-6-luna. initialize, then tools/call with docs/screenshots/font-settings.png as a file path and a prompt: the model listed every settings row and its value correctly. Not tried: a real agent (Claude Code, Cursor) mounting it; its MCP exchange is the same as the web search server's. |
||
|
|
74b30cb7f8 |
gui: the sidebar's edge drags it wider or narrower, kept for the window; dragged well past its narrowest it folds away, as a Mac app's sidebar does (enzyme_dev on X)
The sidebar was always 212 points (184 in a narrow window). Its right
edge is now a separator (role=separator, col-resize, no-drag for the
window): dragged, it follows the hand between 168 and 320 points, the page
beside it moving with it, and the width is kept in localStorage
(magpie.sideWidth). A narrow window has it no wider than 36% of itself, so
the page keeps its room, and back at full width when the window is. Dragged
more than 64 points under its narrowest it folds into the header's tabs
(the same as the title bar's button), and comes back at the width it had
before that drag. The arrow keys move it 8 points, 32 with Shift. Under a
coarse pointer (an iPad's magpie web) the edge is 24 points wide for a
finger; a phone's magpie web has no sidebar and so no edge. "Sidebar
width" (its label) in zh, zh-TW, ja and de.
Run: side-width.test.cjs (new) in Chromium and WebKit, 3 times each: the
drag mid-way and after, the narrowest and widest, every name and the magpie
whole at 168, the keys, a reload, a 760 window, the fold and its width on
return, an iPad touch drag (Chromium; WebKit's Playwright sends no touch
moves), a phone with no edge. Without the fold's reset the return width
test fails (168 for 240). sidebar, side-toggle, phone-web, mobile-web,
view-no-sideways, header-centre, text-size pass in both engines, except
WebKit text-size's two "100% picked at the foot" cases, which fail the same
on origin/main
|
||
|
|
336605dc96 |
omarchy tests: TestCurrent starts from no theme read, so a second run (-count=2) isn't handed the first run's cached font
Current keeps the last theme it read for a second, and the package state
outlived the test, so the second run's first read came back from the cache
with the font the first run ended on. Seen while working on #1670.
Ran: go test -count=2 -run 'TestCurrent$' ./internal/omarchy/ fails on
|
||
|
|
f131117976 |
gui: on niri the tray panel opens under the bar beside the clicked icon, not in the middle of the screen (#1670, Kenoia)
A Wayland window can't place itself. Under niri the panel opened where niri floats a new window, the middle of the output. Hyprland already had an adapter (omarchy/hypr.go); niri now has one too. niri (checked in niri v26.04's source, niri-ipc/src/lib.rs and src/ipc/server.rs) can't add window rules at runtime and doesn't report the pointer over IPC. So omarchy.NiriPanel watches niri's event stream ($NIRI_SOCKET, one line of JSON per message) and moves each window of magpie's pid titled "magpie panel" once as it opens: MoveWindowToFloating if it was tiled, then MoveFloatingWindow with SetFixed x/y, which count from the working area's top-left (below the bar). It goes 6 px under the bar, centred on the x that the tray host passed to the SNI Activate(x, y), kept inside the output. Wails' Linux tray keeps that x in private fields (lastClickX/lastClickY), read the same way trayProps already reads props; TestTrayClickIsWails reads Wails' source to fail if they move. Noctalia passes bar-surface-local coordinates, so the x is taken across the focused output. With no click (`magpie panel`), or with one off the output, it goes to the top right. Wails' HideOnFocusLost closes it when another window takes the focus. What was run: - go test -race ./internal/omarchy/, go test ./internal/gui/ (sandbox HOME, pinned GOMODCACHE/GOCACHE). The IPC fixtures are built from niri-ipc 26.4.0's Window/Output/Event/Reply types, quoted in the test. - Broke it by hand: dropping the placed-once map fails TestWatchWindows (placed [7 7 9 9 9]); dropping the right-edge clamp fails TestPanelSpot. - gofmt -l; go vet (darwin), GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...; linux nogui and windows builds. - A nested niri 26.04 (winit backend on Xvfb, scale 1.5, Fedora 43 container, magpie built with -tags gtk3), with SNI Activate sent via dbus-send. Activate(300, 14) put the panel at [58, 6] (300 - 484/2). A second Activate closed it. `magpie panel` reopened it at the top right (853 - 484 - 6 = 363). Activate(800, 14) clamped it to 363. `magpie gui` taking the focus closed it. Not tried: a real niri desktop, Noctalia or another real tray host (Waybar, ironbar), more than one monitor, a bar at the bottom or the side (not accounted for), focus-follows-mouse. The panel still opens in the middle and slides up; how visible that is on real hardware wasn't seen. Not from this change: omarchy's TestCurrent fails with -count=2 on main (it passes with -count=1). |
||
|
|
206dc085be |
provider: a magpie run from a terminal that only lists accounts no longer writes logins.json, and every change to it is made under a lock the gateway holds too, so a token the gateway just refreshed is never written back over (#1674, FaintGhost)
Every CLI command that reached Logins() (magpie ls, providers, sessions,
usage) ran rememberLogins, whose 30-second throttle (loginsSeenAt) lives
in the process, so in a new process it never held: each run moved Seen on
for the signed-in Codex and Claude accounts and wrote logins.json back.
loginsMu was an in-process mutex, so that read-modify-write could
interleave with the gateway's renewSavedLogin: the CLI reads, the gateway
writes a refreshed sign-in, the CLI writes what it read. Codex/OpenAI
refresh tokens are single use, so the account would be signed out.
- rememberLogins writes nothing when the only change is Seen and the saved
Seen is less than seenEvery (10 minutes) old (onlySeenMoved, comparing
with what was read, IDs and order normalised as writeLogins writes them;
sortLogins is split out of writeLogins for that).
- internal/filelock (new): davsync's TryLock/Unlock (flock; LockFileEx on
Windows) moved here and davsync uses it; Lock(path, wait) and
filelock.Mutex, a sync.Mutex that also holds the OS lock on a lock file.
A lock another magpie holds is waited for up to filelock.Wait (10s),
then gone on without, as before, so a stuck magpie never hangs others.
- loginsMu is a filelock.Mutex on logins.json.lock, so all 107 existing
Lock sites (every writeLogins is under one) are cross-process with no
change at the call sites. Taking it calls filememo.Look (new), so the
read under it isn't a parse filememo.Hold kept from before another
magpie's write. savedTokenMu holds logins.json.renew.lock the same way:
two magpies never refresh one saved account at once.
- Siblings: caller-keys.json (access.mu: magpie keys from the CLI vs the
window; a lost revoke would bring a key back) and mcp-signins.json
(mcpauth.fileMu, plus mcp-signins.json.renew.lock around renew, since
library's MCP check renews from the CLI too) get the same lock.
plugin-auth.json already has one (plugin-auth.json.lock, shared with
host.js). Not covered: providers.json (33 store sites with no
in-process lock either; user-entered keys, nothing refreshed there),
migrations.json/settings.json (no credentials), and the agents' own
files (~/.codex/auth.json etc.: the agent itself writes them without
any lock of ours, so a magpie-only lock can't make them safe).
Tests:
- TestReadOnlyRunLeavesLogins: Codex and Claude signed in, Seen a minute
old, file time set back; three "new processes" of Logins("")/codex/
claude/All() leave logins.json's bytes and mtime as they were. Seen an
hour old is written; Codex's own refresh is written at once.
- TestLoginsKeepAnotherMagpiesWrite: between this process's read and write
(beforeLoginsWrite hook) a second test process (TestLoginsOtherMagpie,
os.Args[0] -test.run) renews the saved work@ account's refresh token;
both the renewed token and this process's change are in the file.
- TestLoginsReadAfreshUnderLock: with filememo.Hold held, a write
filememo never heard of is seen by a read under loginsMu.
- TestLockAcrossProcesses (filelock): a holder subprocess makes Lock wait
and give up after its wait; killed, the lock is free; a Mutex holds it.
Broken by hand: onlySeenMoved bypassed -> TestReadOnlyRunLeavesLogins
FAIL "a run that only listed the accounts wrote logins.json"; the file
lock taken out of filelock.Mutex.Lock -> TestLoginsKeepAnotherMagpiesWrite
FAIL "the other magpie's renewed sign-in was written over"; Locked hook
emptied -> TestLoginsReadAfreshUnderLock FAIL. Each restored, green.
Ran: gofmt -l (nothing); go vet ./..., GOOS=linux go vet -tags nogui
./..., GOOS=windows go vet ./...; go build, GOOS=linux go build -tags
nogui, GOOS=windows go build; go test -tags nogui -count=1 ./... under a
temp HOME with pinned caches: all ok but internal/provider, whose
TestReadOnlyRunLeavesLogins failed at that point from its own fixture
(two rewrites of one size given the same mtime read as unchanged by
filememo); fixed in the test, then internal/provider, access, mcpauth,
filememo, filelock and davsync -count=1 all ok, and the three new provider
tests -race -count=10 ok.
Not tried: the reporter's Linux arm64 box with a real systemd gateway and
real Codex accounts; Windows (LockFileEx path) only vetted and built, not
run on the Windows box.
|
||
|
|
34ce89945b |
gateway: an error that escapes its Chinese as \uXXXX is read as one that doesn't, for why it failed and when it's back (#1669, Natsumeretsu)
Every word list that decides why a reply failed (creditWords, brokeWords, rateWords, plannedWords, usedUpWords, quotaCodes) and af0558e6d's resetsWhen were matched against the raw body. A JSON error whose encoder escapes what isn't ASCII (Python's json.dumps by default) carries 用量 as 用量, so none of the Chinese words matched: WorkBuddy's escaped refusal read as a 1-minute rate limit with no reset time, Zhipu's escaped 1113 "余额不足…请充值" as a rate limit instead of out of credit, a sub2api key's escaped "7天限额已用完" as a rate limit instead of out of quota. wordsOf is the one shared point: a JSON body containing \u has its string values decoded and put after it, one to a line; any other body is matched as it is. failure() matches its words on it, resetsWritten reads the reset from it, the per-model rest's otherModels check uses it, and the two creditWords checks beside failure() (fallback.go's same-one retry, patience.go's busy) use it too. Tests: TestResetsWritten gains the reporter's Chinese refusal escaped (read, 3h16m2s) and escaped-but-cut-short (not read); TestWrittenResetRestsUntilThen rests the escaped refusal's model until then; TestFailureReadsEscapedWords: escaped Zhipu 1113 is credit, escaped sub2api 7天限额已用完 is quota, escaped WorkBuddy is quota. With wordsOf returning the body unchanged, all three fail. internal/gateway passes; go test -tags nogui ./... under a temp HOME; gofmt -l, go vet darwin, GOOS=linux, GOOS=windows on internal/gateway. |
||
|
|
e4aadb4840 |
gui: the header is fitted again when the language or the interface font changes, so the tabs no longer run under the magpie and the traffic lights (kiwiflysky on X)
With a wide interface font, the macOS window's header fit in Chinese but not in English, Japanese or German: the tabs slid left under the magpie and the window's buttons, and in German into the refresh button and the gear. fitTop draws the header in step by step (tight, cramped, inrow, crowded, packed), but it only ran again when .top, .brand or .actions changed size (ResizeObserver) and once on document.fonts.ready. Another language or a font picked later changes only #nav's width, so the header kept the fit it had for the old one. Now translateStatic (every language change) and desktopFonts.apply (every font applied: picked, saved in the other webview, from settings) call fitTop, and document.fonts' loadingdone does too, for a font still loading when it's applied. Both run synchronously, where the change happens. A ResizeObserver on #nav was tried first. It had to defer to a frame, since fitting resizes the nav and WebKit reports that loop as a page error, and the deferred refit moved the page after a click: text-size, number-units, tray-logos and rail-tip went red. That approach was dropped. Measured (830px, macOS window, before): switched live to en, ja and de, the tabs ran 61, 105 and 148px under the magpie (Chromium and WebKit alike). header-relang.test.cjs (new): - Opens a macOS window in Chinese, with the header's tabs picked over the sidebar. - Switches it from Settings to en, zh-TW, ja, de and back. - In English, on the Agents page, it hands in Menlo at each width from 1000 to 640px. Each fit must equal a fresh fitTop. - Sweeps each language from 1100 to 600px: 7.5px clear of the magpie or padding and of the buttons. - Chromium and WebKit. Run on this commit: - header-relang: 12/12 in Chromium and WebKit. Red on origin/main |
||
|
|
5feadabef6 |
gateway: a long conversation's request costs about a third of the CPU it did, with the same bytes sent on (#1532, #1654)
The gateway reads one request's body a dozen times or more on its way:
modelOf, streamOf, conversationID, requestEffort, bodyEffort,
walkImages and swapImageBlocks (more than once through a group), turnOf's
parse, promptOf, chatToolNames, thinkingOffUnlessAsked, decodeRequest,
and for Responses pairToolItems, orphanedToolOutputs,
hasSealedAgentMessage and askedTier. Each read took a field or two with
json.Unmarshal, which checks the whole input and then steps through every
byte of every string one call at a time, so each read cost as much as
decoding the whole conversation: 74-77% of a request's CPU in pprof, most
of it checkValid and stateInString.
decodeJSON (fastjson.go) is json.Unmarshal for these reads. It checks the
body once with its own validator (json.Valid's grammar and 10000 depth,
8 string bytes at a time), splits objects and arrays at their members
without decoding them, and decodes only what dst has a place for:
strings, booleans, json.RawMessage (copied, as encoding/json does),
structs, pointers, slices and string-keyed maps by their parts, and
everything else (numbers, interfaces, types that decode themselves) by
encoding/json itself. Whatever it doesn't take on exactly as
json.Unmarshal would goes to json.Unmarshal with dst zeroed: invalid
input, a dst already holding something, an embedded field, a ",string"
option, two fields of one name, a key given twice, a value of the wrong
type. A list or object where dst takes a string (a "string or parts"
read) is answered by json.Unmarshal of its opening and close, which gives
the same error at the same offset without reading the rest. The request
paths' json.Unmarshal calls in gateway.go, decide.go, affinity.go,
image_input.go, textcalls.go, anthropic.go, ir.go, prompt.go, chat.go,
chattidy.go and responses.go, and hasSealedAgentMessage and askedTier,
now call it. Nothing that writes a body changed.
Numbers, M4 Pro under load 10-20 from other sessions, BenchmarkLargeRequest
(new: a 2 MB agent conversation with 30 tools, tool calls and results,
through a fake vendor), 20 requests each:
CPU in the request's handler time per request
(pprof, per request) (ns/op)
anthropic 154ms -> 45ms 208-212ms -> 52ms
anthropic, group 178ms -> 51ms 249-262ms -> 65-67ms
chat 122ms -> 35ms 167-254ms -> 50-54ms
responses 215ms -> 56ms 294-452ms -> 70ms
TestLargeRequestEndpoints (64 MB padded bodies): 16.8-17.6s -> 2.9-4.8s
(skipping runs of spaces 8 bytes at a time took its last ~5s).
Tests:
- TestUpstreamBodiesUnchanged sends 18 requests (Anthropic, Chat and
Responses; direct, through a group, translated to each other protocol,
with images, thinking, escapes, odd spacing, a repeated key, and four
2 MB conversations) and compares what the vendor gets with
testdata/upstream_bodies, recorded on the code before this change
(all 18 identical; three runs agreed). Breaking decodeJSON's \n
unescape by hand turns the three translated cases holding one red.
- TestDecodeJSONIsUnmarshal / FuzzDecodeJSON compare decodeJSON with
json.Unmarshal (dst DeepEqual, error nil-ness) for 19 types shaped like
the gateway's, and jsonValid with json.Valid, over seeds, every cut
and a changed byte at every place of each seed, and 2.5 minutes of
fuzzing (~1.75M inputs). Breaking the validator's control-byte check
by hand turns it red.
- go test -tags nogui -timeout 40m ./... on this commit rebased onto
origin/main
|
||
|
|
c9fb7c9a1f |
gateway: a Claude run its timer ended mid-reply is no longer kept idle, holding one of 6 places (#1667)
A resumed turn's 30-minute timer calls abort. Fired during a reply, finish closed the run and removeRun took it out of b.idle, where it wasn't yet. The reply's last event, already in the segment, still reached the client whole, so ended was told ok and kept the closed run with keepIdle, then re-armed its timer. That timer found it closed and never took it out, so it held one of idleMost places until pushed out, and the push-out shelved a session removeRun may already have deleted. letGo's keepIdle had the same window. keepIdle now reads r.closed under b.mu and refuses an ended run, returning false; ended and letGo then return without re-arming the timer or rewinding. finish sets closed before removeRun takes b.mu, so a run is either refused here or kept and then taken out by removeRun. Tests: TestClaudeRunEndedMidReplyIsNotKeptIdle fires the run's timer (abort through removeRun) and then calls ended with a whole reply. On the old code it fails: "a run its timer ended mid-reply is kept idle (1 runs), holding a slot of 6"; it passes with the fix. TestClaudeIdle* kept closed runs only so abort did nothing; they now keep live runs, and TestClaudeIdleReplacementKeepsItsKey sets the other run at old's key directly, since keeping it there through keepIdle would end old. Run: go test -race -run 'Claude|Subscription|Idle|LetGo|Rewind' ./internal/gateway (ok); the full suite is in the next commit's body. Not tried with a real Claude Code: the window needs a 30-minute reply. |
||
|
|
6f87335302 |
gui tests: otel measures its rows at each width two frames after resizing, since WebKit can still hand back the old width's layout when setViewportSize returns
otel's "no overflowing controls at 360px" was red in WebKit with no change to the page, on origin/main's own copy of the test too (1 of 6 cases passed, 2 runs, at a load average near 11). #1659's injected runs first showed it. A probe at each width, run straight after setViewportSize and again two frames later, showed the cause. Going from 1100px to 520px, innerWidth is already 520 and body no longer has side-nav. But the views still start at left 212, the side nav's padding at the old width. #otelList measures 268px instead of 488px. Two frames later the views start at 0 and the list is 488px. At 360px a row then measured 106-108px instead of 320px, so its control overflowed it. The test now waits two requestAnimationFrames after each setViewportSize before measuring. The page is unchanged: a user's window is drawn at its new width by the next frame. Run (WebKit, the engine that was red): - Without the wait: 14 of 15 cases red over 5 runs, each on "no overflowing controls at 360px". - With it: 20 runs, 60 of 60 cases passed (load average 15-16). 33 other test files measure right after setViewportSize. They are filed as a follow-up, not changed here. |
||
|
|
8f9bc3fccf |
gui tests: the 37 other Settings tests act on rows once the page has drawn its last read of the settings, as the masking-rules tests do since #1653 (#1659)
Opening Settings reads the settings twice: the page's own read (showView), then the window's load() once the state is in. Each read redraws every row. A test that found a row after the first draw, and then called scrollIntoViewIfNeeded or boundingBox on it, failed when the second read landed in between. The errors were "Element is not attached", or a null box. #1653 fixed the three masking-rules tests and listed these 37 in #1659. Each of the 37 now calls watchSettingsReads(page) before every page.goto, and settingsDrawn(page) right after it. Right after goto is exact for ?view=settings: at boot, show(view) asks for showView's read before load() runs. load() sets load.done in the same run that then asks for its own read, so settingsDrawn's "load.done and every read asked for drawn" holds only once the second read is drawn. For a test opened on another page that clicks into Settings later, load is done by then, the click makes the only read, and the wait passes at once. watchSettingsReads now watches a page once, however many times it is opened, since some of these tests open one page several times. The page is unchanged. Reproduced with a generic injection (scratchpad inject1659.cjs, loaded with NODE_OPTIONS=--require). A route added at each goto holds the page's second GET /api/settings. It lets the read go just as the test calls scrollIntoViewIfNeeded or boundingBox, or waits on the page with waitForFunction (which settingsDrawn is), with a 4s timer as a backstop. This is #1653's injection, made generic. Before, injected, both engines, all languages: - 5 files red with the issue's error: - github-token: null box. - member-model-setting, searcher-pick, search-first and update-wait: "Element is not attached to the DOM". - 4 files red on a check of a row drawn from the first read: model-suffix-own, otel, readable-focus and warm-at-times. - 28 green. After, injected: 36 of the 37 files green, every held read let go by settingsDrawn's wait. otel stays red in WebKit at 360px. It is red the same way with no injection, on origin/main's own copy of the test. That cause is separate (the narrow nav laid out after setViewportSize returns) and has its own commit next. Plain (no injection), both engines, all 37 files: 460 cases passed and 2 failed, both otel's WebKit 360px check above. The 8 files red under injection before, injected again after, 5 rounds: 390 of 390 cases passed. |
||
|
|
45303db0e3 |
gui tests: click-scroll's late wheel is looked at once the page has heard it and the reader's moment is over, not after a fixed 400ms (#1660)
"a wheel the page hears of after its scroll is still the reader's" failed
once in Chromium on a loaded machine.
Cause: the subtest delays the app's wheel listener by 60ms (the busy page
of the subtest), then waited a fixed 400ms before looking at the view,
and 100ms after a scroll by code. The listener opens a 250ms moment in
which scrolls are the reader's (readerScrolls(250)). That moment starts
when the page hears the wheel, not when the wheel happens. When the
machine ran the 60ms timer more than ~150ms late, the code's scroll that
followed fell inside that moment and stood ("code's scroll is put
back"). Later still, the view was looked at before the wheel was heard
("the late-heard wheel must scroll the view").
Fix: the wrapper counts the wheels the page has heard. Each wheel is
looked at once the page has heard it and performance.now() has passed
purposeUntil, the end of the reader's moment. The code's scroll is
looked at three frames on, since it is put back at the frame it is told
of. The wait of 100ms before the last wheel stays as a minimum gap: what
was put back from 50ms before a wheel counts as that wheel's own
(givesBack). The page is unchanged.
Run (injected: the late wheel's delay raised from 60ms, the test copied
to the scratchpad with only that number changed):
- Before, Chromium:
- 200ms: 4 of 22 cases red, "code's scroll is put back".
- 500ms: 4 of 22 red, "the late-heard wheel must scroll the view".
- 60ms: green.
- After:
- 200ms Chromium: 22 of 22.
- 500ms Chromium: 22 of 22.
- 500ms WebKit: 22 of 22.
- Broken by hand: with givesBack left out of the wheel listener, the
test is red on "the late-heard wheel must scroll the view".
- A first try with no gap before the last wheel went red: the code's
scroll was handed to the wheel. That is why the 100ms stays.
- click-scroll.test.cjs, both engines, 20 runs: 440 of 440 cases passed, with a load average of 12 to 17.
|
||
|
|
af0558e6d0 |
gateway: a 429 that says in words when it's back rests until then, in Chinese as in English (#1669, Natsumeretsu)
WorkBuddy answers a frequency limit with the time it resets, in words:
"将在 2026-10-11 20:16:02 UTC+8重置" and "your usage will reset at
2026-10-11 12:37:53 UTC+8, ...". resetsAt read neither (only Claude
Code's "limit reached|<unix>" and ChatGPT's resets_at), so the Chinese
one rested quotaRest (15 min, matched 用量) and the English one
fallbackCooldown (1 min, no word list matched): the account was asked
again long before it was back, refused, and benched again.
- resetsWritten reads a time beside the reset phrasing (resetsWhen:
"reset(s) at", 将在/将于), in the UTC/GMT offset it is written with.
The offset must be followed by 重置 or punctuation, so a refusal cut
after "UTC" or "UTC+" is never read as UTC; a date that isn't real,
one past, or more than a week off (longestWritten) isn't read; another
vendor's date in passing ("deprecated on ...", "retry after ...") is no
reset. resetsAt falls back to it, so keepRetry notes it too.
- failure reads such a 429 as out of quota in either language.
- One that points to the account's other models ("切换其他模型",
"switch to the other models") rests that model alone (restID), so
the account's other models are still asked during an hours-long rest.
- rateRest: a reset time the refusal names (resetsAt, or as keepRetry
noted it) is believed up to longestQuota, as the quota branch does,
and the trace says "resets"; a Retry-After or rate-limit reset header
stays held to longestWait. Decided: the stated time is the vendor's
statement of when the account is back, and how far it is believed
shouldn't hang on which word list the message happened to match
(8 days as quota vs 1 hour as rate for the same words); a Retry-After
is generic advice and keeps the hour.
The rest is the gateway's, so it holds for moved WorkBuddy users too:
the plugin (packages/workbuddy 0.1.14, explained()) passes a 429 that
isn't "unapproved channel"/14018 on as it came.
TestPluginWrittenResetRests shows a plugin-served 429 with the
reporter's refusal resting the model until the stated time.
Tests: TestResetsWritten (reporter's bytes in both languages, other
offsets, cut-short, garbled, past, >7 days, other vendors' dates),
TestWrittenResetRestsUntilThen (both languages rest the model by
"resets", noted path, cut-short falls back, other vendors' 429s
unchanged), TestRateLimitBelievesItsReset, TestPluginWrittenResetRests.
Broke each piece by hand (reader, classification, rate cap, model
scope, offset, the terminator) and each made one of them fail.
TestRateLimitBacksOffWhenItComesBack now expects "resets" for a noted
reset. go test -tags nogui ./... under a temp HOME, rebased
on
|
||
|
|
6ebe481f8e |
agent: Hermes's other bots (profiles) get magpie's provider too, and Disconnect takes it out of each (lijiho96940561 on X)
Each Hermes bot is a profile at <root>/profiles/<name>/ whose config.yaml
is read on its own (hermes_cli/config.py get_config_path; load_config
doesn't fall back to the root's). magpie wrote providers.magpie only into
$HERMES_HOME/config.yaml, so only the main bot's picker offered magpie.
Now, with magpie connected, its provider entry also goes into the
config.yaml of every profile Hermes lists (hermes_cli/profiles.py and
hermes_constants.py, Hermes be5e9f72c): a name matching PROFILE_ID_RE,
not "default", not tombstoned under profiles/.deleted/, with a config.yaml.
The root follows get_default_hermes_root: ~/.hermes, or for a HERMES_HOME
outside it, <root> of <root>/profiles/<name>, else HERMES_HOME itself.
Connecting writes it there, and each Sync refreshes it and adds it to
profiles made later. Only providers.magpie is written, so each bot's own
model.default/model.provider stays as its user set them. Disconnect deletes
providers.magpie from every profile. In a profile whose model.provider is
magpie (cloned from a connected main config, or picked in that bot), the
model and provider are deleted too, so the profile isn't left naming a
provider that is gone. There's no stash for those, so Hermes falls back to
its defaults there.
Run: go test ./... -count=1 under a scratchpad HOME (all ok); gofmt -l; go
vet ./internal/agent for darwin, linux and windows. TestHermesProfiles and
TestHermesProfilesOfCustomRoot fail on the old hermes.go ("coder after
connect"). Fixtures follow Hermes's profile layout, read from its source.
Not tried with a real Hermes running several bots; the live ~/.hermes was
not touched and hermes was not run.
|
||
|
|
2a8a9aecfa |
provider: signing out of ChatGPT and Devin's CLI checks go through the account's own proxy, as its sign-in does (#1663, demystify0137)
What changed: two siblings of
|
||
|
|
e044ea862f |
sessions: the warm-up at start reads with a quarter of the cores unless a page waits, and a long first read keeps what it read (#1665, laowangba233)
#1665: magpie pegs the CPU on every start (Windows Task Manager showed 95.8%). Three seconds after start, warmSessions indexes every Claude/Codex session file and reads every file's calls for usage. refresh() ran min(max(8, 2*NumCPU), 32) parsers at once and usage's prefetch 8 more, so the background warm-up took every core while nobody was looking at the result. Two goals, in one commit because they touch the same loop in refresh(): 1. Quiet warm-up (quiet.go). gui's warmSessions runs inside sessions.Warm. While a warm-up runs and no request waits, every parse in refresh() and every readCalls takes one of max(1, NumCPU/4) slots. A request to /api/sessions* or /api/usage* (gui's held middleware) calls sessions.Ask(), which lifts the limit for as long as it runs, so a page the user opened isn't slowed down. A waiting reader re-checks every 50ms, so Ask takes effect mid-read. 2. Checkpoints. refresh() saved sessions.json only once all files were parsed. Quitting magpie before that (a slow machine, or the user closing it because the CPU is pegged) kept nothing, and the next start parsed every file again. Now every 5s (checkpointEvery) the files done so far are published and saved, if the cache generation still matches. Measured on a Mac (14 cores) with a sandbox HOME holding 8.9 GB of real sessions (copied read-only), sessions.json and calls-v11 removed, sampling ps every 2s: - cold start before: 41.2 CPU-s, peak 580-600%, done ~14s - cold start after: 34.7 CPU-s, peak ~300-360%, done ~16s - quit mid-index, before: quit at 6s (13.5 CPU-s spent) left no sessions.json and no calls files; the next start spent 41 CPU-s again. - quit mid-index, after: quit at 12s left a 1.3 MB sessions.json (of 3.0 MB); the next start spent 26.6 CPU-s instead of 34.7. Tests (each red with its part undone, script-checked: refresh's slot replaced by a no-op, readCalls' slot removed, the checkpoint block removed): - TestWarmReadsOnlyInItsSlots: with every slot held, neither the index nor the calls read anything for 300ms; Ask() lets both finish. - TestReadSlotOnlyWhileWarming: outside Warm, or while asked, reads don't wait. - TestLongReadKeepsWhatItRead: a read held after its 3rd file has saved sessions.json with fewer files than it has to do. Run: go test -tags nogui ./internal/sessions ./internal/gui ./internal/library ./internal/usage; gofmt -l; GOOS=linux and GOOS=windows go vet of sessions, gui, library; full go test ./... before push. Not tried: the reporter's machine or data volume; a Windows re-measure. |
||
|
|
ddb3cef517 |
sessions: a visit to Sessions no longer parses Codex's config.toml again when it hasn't changed (#1665, laowangba233)
Profiled for laowangba233's report of CPU jumping on page switches: in a sandbox HOME with a copy of a real Codex config.toml (10,927 [projects."<dir>"] tables), 67% of GET /api/sessions/manage's CPU was go-toml parsing config.toml in readCodexConfig, for the provider Codex uses now (codexProviders -> CodexProviderIn). go-toml checks each table name against every sibling before it, so a file with that many projects takes ~0.2 s to parse, and it was parsed on every visit. readCodexConfig now keeps the parse through filememo, keyed by the file's size and time (and its bytes while it is less than two seconds old). Its callers only read the struct. Measured (sandbox HOME, 8.9 GB of copied sessions, macOS, 10 warm GET /api/sessions/manage after start): 3.00 s of CPU before, 0.94 s after (~0.30 s -> ~0.09 s a visit). TestCodexConfigParsedOncePerChange rewrites config.toml with the same size and time and expects the first parse; a real change is read. It fails with the memo undone. go test -tags nogui ./internal/sessions passes. |
||
|
|
9300b2a126 |
library: a visit to the Library no longer parses Codex's config.toml again when it hasn't changed (#1665, laowangba233)
laowangba233 saw magpie's CPU jump on each switch to a Library page. Profiled in a sandbox HOME with a copy of a real Codex config.toml (1.5 MB, 10,927 [projects."<dir>"] tables, one per folder Codex was ever opened in): 69% of GET /api/library's CPU was go-toml parsing that file through foundServersOf -> mcpFile.entries. go-toml's SeenTracker looks each table name up among every sibling before it, so the parse is quadratic in the number of projects, ~0.2 s of CPU each time, and the Library parsed it on every visit (edit.Read already kept the bytes, not the parse). mcpFile.entries now keeps what it parsed through filememo, keyed by the file's size and time (and, written in the last two seconds, its bytes), and hands each caller a deep copy of the servers it found, so a caller changing an entry doesn't change the next caller's. The RTK page's codexSandbox (Windows, Codex with rtk on) parsed the same file the same way on each visit and is kept the same way. Measured (sandbox HOME, the copied config and library, macOS, 10 warm GET /api/library after start): 2.67 s of CPU before, 0.55 s after (~0.27 s -> ~0.055 s a visit). TestCodexEntriesParsedOncePerChange: a config with 2000 projects read four times parses once, a caller's change to the entries doesn't reach the next, a change to the file is read, a file gone is no servers. It fails with the memo undone (entries parsing edit.Read's bytes each time) and with the copy undone. go test -tags nogui ./internal/library ./internal/filememo pass; TestCodexSandbox passes. The RTK memo has no test of its own (Windows only); filememo's own tests cover the keep. |
||
|
|
498b77fbca |
gui: the sign-in box shows the proxy it goes through, and another can be picked and kept as the account's (#1663, demystify0137)
What changed: while a sign-in waits (or after it failed), the box shows "Proxy: …" beside Open again. It opens the app menu (openProtoMenu, no native select) with Global (only when it could be kept), Direct, the subscription's proxy, each account's proxy and Custom…, which asks for an http://, https:// or socks5:// address. Picking one starts the sign-in again through it and cancels the open one; when it ends, the backend keeps the pick as the account's (keepSignInProxy). Userinfo in a proxy URL is never shown. "Sign in again" on an account now names that account (user), so it goes through the account's own proxy. The user and the pick are carried through the risk, site and plugin-method steps. Strings in zh, zh-TW, ja and de. docs/subsystems/providers-accounts.md describes the sign-in proxy. Why: the reporter asked that a sign-in use the subscription's or the account's proxy and be able to choose one; the default now does, and this lets the user choose and see it. What was run: - signin-proxy.test.cjs (new): Chromium and WebKit, en/zh/zh-TW/ja/de, at 900 and 380 wide, 40/40. It fails against HEAD's app.js (no link). - The sign-in, add-sheet, plugin-signin, click-scroll, i18n-keys and gui-<lang> files: 203/203; signin-close.test.cjs updated (the acts row now also holds the proxy link). - go test -tags nogui ./... ok; gofmt; linux/windows vet. Not tried: a real vendor sign-in through a real proxy from the window. |
||
|
|
3a53d06d99 |
provider, plugin: a subscription's sign-in goes through the proxy its account's requests use, not always the global one (#1663, demystify0137)
What changed: every sign-in started in magpie now leaves through the
account's own proxy (ProxyOfLogin: the account's, else the
subscription's, else the global one). Before, the sign-in's token
exchange and checks went through the global proxy while the account's
later refresh and usage calls went through its own (ViaLogin), so the
vendor saw one account come from two exits.
- signin.go: SignInOptions{Site, Proxy, User}, StartSignInWith; the flow
picks its proxy (pickProxy, validated with settings.CheckProxy) and
every request goes through s.via. Each built-in sign-in (Claude,
Codex/ChatGPT, Grok, Zed, WorkBuddy, Copilot, ZCode, Factory, MiMo,
Qoder, Command Code, Kiro) uses s.via; Claude Code's own login gets the
proxy as *_PROXY (netproxy.EnvWith).
- proxy.go keepSignInProxy: a proxy picked for the sign-in is kept as
the subscription's when the account is its only one, else as that
account's own entry. "" (global) is refused while the subscription has
a proxy and other accounts, since nothing could keep it.
- plugin host: authorize and callback run under via.run(proxy), so a
plugin's sign-in fetches go through the same proxy; plugins_cli.go
does the same for `magpie plugins login`. PluginAPIKey goes through Via.
- gui: POST /api/signin and /api/plugin-signin take proxy and user.
What was run:
- go test -tags nogui ./... (sandbox HOME), all packages ok.
- gofmt -l, GOOS=linux and GOOS=windows go vet -tags nogui on the
touched packages.
- Red without the change (each broken by hand, then restored):
TestSignInGoesThroughItsProxy, TestDeviceSignInGoesThroughItsProxy,
TestPluginSignInGoesThroughItsProxy, TestClaudeSignInGoesThroughItsProxy
(internal/provider) and TestPluginSignInProxy (internal/plugin) each
fail with the s.via / EnvWith / via.run / keepSignInProxy removed.
Not tried: a real vendor account through a real proxy. The browser's own
leg of an OAuth sign-in goes through the browser's network, not magpie's.
Devin's CLI probes still use the global proxy.
|
||
|
|
f38f65030c |
agent tests: the sandbox home holds XDG_DATA_HOME and XDG_STATE_HOME too, so Grok App's drift test passes on Linux (#1668)
codexHome, the helper TestDriftUnwiredEveryAgent and others start from,
pointed HOME, XDG_CONFIG_HOME and XDG_CACHE_HOME at the test's home but
left XDG_DATA_HOME at testenv's. On Linux grokAppDir (
|
||
|
|
054bdb8bbe |
gui tests: the sidebar's room
|
||
|
|
2927023b99 |
gui: a Sessions figure never wraps, so picking a project no longer moves the page
In Chinese at a 142pt tile (a 1100pt window beside the sidebar, or an
888pt one without it) "139 小时 27 分" broke onto a second line. Picking a
project shortened it to "4 小时 28 分", the row of figures lost 23pt and
everything under it moved up under the pointer.
- .kpi b keeps to one line (ellipsis and a title as the last resort).
- The active time's units are drawn smaller and muted, as the Health
app draws "h" and "min", so the figure fits.
- The six figures go to three columns under 960pt of pane, not 820pt.
Run: sessions-overview (28/0) in Chromium and WebKit; before this it
failed at the project bar (505.8 vs 528.8) on main with the sidebar and
on
|
||
|
|
cfd2ee7f7c |
gui tests: routing-side-calls measures a row once Routing's groups are in and the row has stayed put (#1640)
"a title and magpie's web search say what they were" failed with "picking the request moved the row" in Chromium, now and then alone and often under load. The row hadn't moved because of the click: it was measured before the page was done. Recorded frame by frame, the day's list draws at one frame and the part above it grows on a later one (rt 271 -> 428px), while the click guard scrolls to hold the day that was clicked (scrollTop 0 -> 176), so the rows move 444 -> 424 before any row is clicked. The test measured "was" between the two. Holding Routing's groups answer (/api/groups) 300, 600 or 1000ms makes the old test fail in most runs (7 of 9 runs red); that is what landed late. The test now waits for the first groups answer and for the row to stay put for 10 frames before measuring. Nothing a reader sees changes: the clicked day stays where it was, as the click guard means it to. Run: with groups held 600 and 2500ms the fixed test is green every run (3 runs each); 20/20 green in WebKit and 20/20 in Chromium. |
||
|
|
f3a8b38550 |
gui tests: privacy-hides-accounts scrolls to Hide accounts as a reader does, and usage-stale-answer lifts quotasOpened with loadUsage (#1632)
Both were red on origin/main when run alone; each had its own cause.
privacy-hides-accounts (WebKit, every run): since Settings' search box
(51042630e; the test passes on its parent and fails on it) the Hide
accounts row sits under the window's foot at 900x760. Playwright scrolls
it into view by code, and the click guard puts a scroll that isn't the
reader's back (a scrollIntoView from the page: 0 -> 38 -> 0 in both
engines); WebKit's click came after the put-back and hit the foot.
Nothing a reader meets: they scroll with the wheel. The test now wheels
the settings view until the row is clear of the foot, waits for the
scroll to settle, and checks the click doesn't move the view's own
scrollTop (it read window.scrollY, which is always 0 here, so "a click
never scrolls" checked nothing).
usage-stale-answer (every run): since #1588 (
|
||
|
|
9424639744 |
gui tests: market-have waits for the market's answer, not 2s, before looking for a mark (#1631)
"a server added by hand is marked added" timed out under the full suite. The mark comes after two reads in a row: the change's answer, then the market asked again (take() -> fetchMarket). Holding those answers in the test showed nothing is dropped: with the save, the library and the market each held 0 to 1200ms the mark always came, at about the sum of the holds. The 2s bound on the whole was the busy machine's to miss: with the save and the market each held 1200ms the old test failed in both engines. Each of the three steps now waits for the market's answer that follows its change (10s, the page's 5s for each of the two reads), then for the mark with the page's own timeout. What the test checks is that the mark comes with no focus (still asserted), not how fast. Run: the save, library and market each held 0, 1200 and 3000ms: 8/8 green in Chromium and WebKit each time. Broken by hand (take() no longer asks the market again): all three steps red, 8 of 8. 20/20 green in WebKit and 20/20 in Chromium. |
||
|
|
0b34449999 |
gui tests: codex-credits measures the credits row it finds, after the panel's own read has drawn it (#1622)
codex-credits.test.cjs was red in Chromium now and then: "the say fits the panel's card" got a switch 0 wide. The cause, found by holding the tray panel's own allowances read (usage/quotas?asked=1) 0-300ms: picking the Allowances tab reads the accounts again, and its answer redraws the cards (renderPanelQuota replaces them) 100-400ms after the click. fits() found the row through a locator and measured it in a second step; a redraw between the two left it measuring a row out of the page, all zeros. Answered 0, 20 or 40ms late the old test failed every time; 60ms and later it passed. Nothing a reader sees: the redraw is synchronous and draws the same row. fits() now finds and measures the row in one page.evaluate, and the panel step waits for the tab's read to finish (quotasLoading) before measuring. Run: with the read held 0, 20, 40, 60, 80, 100, 150, 200, 300ms the test passes every time (en and de, Chromium); 20/20 green in Chromium and 20/20 in WebKit. |
||
|
|
0f6defe78b |
gui: on a Mac a region or agent strip scrolls with no bar, so a click right after a scroll picks the option under it (#1620)
tencent-cloud.test.cjs was red in WebKit now and then: a region clicked
was not picked. The cause, found by scrolling the strip from the test and
clicking 30ms later: on a Mac page (body.mac) WebKit shows its overlay
scrollbar over the lower half of a scrolled strip for a moment, and
elementsFromPoint at an option's centre returned the strip, not the
option. A press there goes to the bar's track, which pages the strip
sideways (smoothly, 198 -> 44) and picks nothing. A reader on a Mac who
scrolls the regions and clicks at once meets the same miss.
On a Mac these strips (.segs.regions, Connect's segs, #sessAgent) now
scroll with no bar, as a Mac's own tab strips do (scrollbar-width: none,
::-webkit-scrollbar display none). Other systems keep their thin bar.
z-index, isolation and position on the options didn't help; only hiding
the bar did.
Tests:
- tencent-cloud.test.cjs: new "a region clicked right after the strip
scrolled is the one picked", 480x1200 (the strip in the window; it
checks so), 10 rounds over 5 scroll positions. Without the CSS WebKit
missed 39 of 50 clicks (40 of 50 on origin/main
|
||
|
|
ee7a9b24a6 |
agent: Grok App is an agent magpie connects: a magpie provider channel with magpie's models and their efforts (#1625, fjrtdk)
fjrtdk asked for Grok App (RongleCat/grok-app, a desktop GUI over the Grok
Build CLI) as a full agent: MCP, skills, RTK, models and effort.
What was already there, read in the App's source:
- MCP: the App reads ~/.grok/config.toml's [mcp_servers] in both of its
modes and hands them to the CLI it starts, so the Grok Build row's MCP
sync already reaches it.
- Skills: Grok Build's ~/.agents/skills, synced from the Grok Build row.
- RTK: rtk has no installer for Grok Build, so there is nothing to wire.
What was missing is models, and that is what changed:
- internal/agent/grokapp.go: a new agent, "grok-app" (alias grokapp), for
the App's agent-home/config.toml under its data folder: GROK_APP_HOME,
else ~/Library/Application Support/com.grokapp.grok-app or ~/.grok-app
on a Mac, %APPDATA%\grokapp\grok-app\data (and two older places) on
Windows, $XDG_DATA_HOME/grok-app or ~/.grok-app on Linux; the first
that exists.
- Connecting writes a [model.magpie] channel in the App's own format
(its custom routes): model, base_url = the gateway's /v1, name,
api_key (magpie-grok-app, so usage says the App), api_backend =
"chat_completions", app_provider_mode = "generic", app_models and
app_efforts as JSON strings (the App unquotes them with serde_json),
supports_reasoning_effort, app_supports_vision for a model that takes
images, and context_window when magpie knows it. app_models lists
magpie's models with their effort levels ("none" left out), so the
App's model and effort pickers show them.
- It sets [models] default = "magpie"; what was there is stashed, and
Disconnect puts it back and drops the channel: the file is
byte-identical to before (TestGrokApp).
- A sync keeps the model and the default effort the user picked in the
App while magpie still serves them, and writes nothing when nothing
changed.
- Picking one of the App's own routes (the official "grok", or a
channel of the user's with a base_url) takes magpie out.
- The notice says to start a new chat or restart the App, which reads
its providers when it starts an agent; translated in i18n.js (zh-CN,
zh-TW, ja, de) and listed in NOTICES.
- agents.go, agentenv.go (GROK_APP_HOME), docs/reference.md,
docs/subsystems/agent-wiring.md, both READMEs' agent lists.
Picking magpie in the App is a custom route, so the App runs that agent in
its independent mode (its own #557): it clears agent-home's auth.json
rather than syncing the official sign-in. ~/.grok is never written.
What was run:
- go test -tags nogui ./internal/agent ./internal/agentenv ./internal/gui:
ok. Full go test -tags nogui ./... under a temp HOME: ok.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui: ok.
- Broken by hand, each red: context_window written quoted (TestGrokApp);
the user's picked model ignored (TestGrokAppSyncKeepsTheirs); their
default effort dropped (SyncKeepsTheirs); Disconnect not unstashing
(TestGrokApp); a no-op sync writing (SyncKeepsTheirs); "none" listed
as an effort (TestGrokApp).
- Real use in a sandbox HOME: a built magpie on 127.0.0.1:3681 with a
fake upstream; `magpie grok-app magpie/fake/echo-1` wrote the channel;
the real grok 1.0.50, started as the App starts it on a custom route
(GROK_HOME=agent-home, --model magpie), answered through magpie, the
upstream saw echo-1 and usage.jsonl counted agent "grok-app". `magpie
grok-app default` restored the file (the only difference was grok's own
[marketplace] line written while it ran). ~/.grok/config.toml untouched.
Not tried: the real Grok App GUI (it would sign in through the keychain
and ~/.grok), a model with effort levels end to end, Windows and Linux
paths beyond TestGrokAppDir.
|
||
|
|
658fbdc140 |
gui: a key's balance shows on its plan's card, so Command Code is one card, not two of one name (#1658, MizuIro-H)
A key provider reports its plan (PlanQuotas) and its balance (KeyBalances) as two quota records. The tray panel's Allowances tab and the Usage page drew each as its own card, so a Command Code key showed "Command Code" with its 5-hour and weekly rings and, under Balances, a second "Command Code" with $63.78. keyCards (app.js) now folds a balance-only record into the plan record of the same provider and source before renderQuotas and renderPanelQuota lay them out. The balance becomes the existing "Balance" row under the windows, the same row a subscription that reports both in one record (Command Code signed in) already shows. Matching: - same user (key name or mask) when the plan names one; - a plan with no user (a single key) takes the provider's one balance only when the provider has exactly one plan card and one balance card. A balance that failed (error) or is a stale stand-in (asOf) stays its own card, as before, so it still says so. The balance's card id goes on the plan's card as data-bal-card, so a menu bar cell for the balance (panelQuotaFocus / focusQuotaCard) still opens and flashes the merged card. No new strings. Product call: merge rather than add a hide toggle. Apple's own pattern (one account, one card) fits, a hide toggle would hide the money too, and the panel already merges this case for subscriptions. Run: - internal/gui/tests/key-balance-card.test.cjs (new): the reporter's case (Codex, Command Code plan + $63.78, SudoCode, DeepSeek) on the panel at 380px and the Usage page at 560px (windowMinW); two keys each taking their own balance; a failed and a stale balance staying apart; the balance's menu-bar id flashing the merged card; nothing running off sideways. Chromium and WebKit x en, zh, zh-TW, ja, de: 20/20. - Broken by hand: keyCards returning list unchanged turns all 10 Chromium cases red. - account-alias, allowance-open-read, balance-curve, balance-parts, panel-arrange, panel-balance-order, panel-usage, plugin-plan, tray-cell-click, usage-arrange, usage-fold: 82/82. Seen on the way, not changed: the Usage page at 380px in WebKit/de runs 3px off sideways (#quotaMode's German Used/Left segments), on main as well. The window can't be that narrow (windowMinW 560), so the test checks 560. Not tried with a real Command Code key. |
||
|
|
0923ef4ae2 |
gateway: an image, an embedding or a provider's own video goes to the key whose own models list it, not always the first key (#1657, wangru8080)
A provider of several keys, each set to serve some models (#474), had images/generations sent on its first key whatever the key's list said: drawOnAccounts went over a subscription's accounts but took a key provider's first key (or the first the calling gateway key may use). Embeddings and rerank sent a model of one provider on its first key too, and a video at a provider's own OpenAI-shaped videos API started on it. A relay that issues one key per model then refused the request. - draw.go: a key provider now goes through the same candidates and perKeyBarred as accounts, so a key whose list leaves the model out never draws, one the vendor lists for another goes last, and with every key set not to serve the model the caller gets the 403 barredError a chat gets. Accounts and keys are told apart by AccountID in the left-over dedupe (accountOf is "" for every key). - key_models.go: onKeys, the keys or accounts a non-chat request of one provider goes over, in routing order, barred and calling-key-held ones out, with the status and message when none is left. - embeddings.go: a model of one provider goes over onKeys; a group's members were already planned per key. - video.go: a custom videomaker starts on onKeys' first key; its id already carries the key mark, so polling follows it. Grok, Volcengine and remote videos keep the first allowed key, since their polls are asked on it again. - count_tokens already used s.candidates; there is no audio endpoint. Run: new TestNonChatGoesToTheKeyThatServesIt (draw + embeddings, key-a text only, key-b image/embedding only; asserts the upstream saw key-b alone and a 403 with nothing sent when no key serves it) and TestCustomVideoGoesToTheKeyThatServesIt. Each was broken by hand: reverting draw.go, embeddings.go or video.go's hunk turns its check red ("drawn on [key-a]", "embedded on [key-a]", "POST /v1/videos kA"). go test -tags nogui ./internal/gateway/ (full package), gofmt -l, and GOOS=linux/windows go vet -tags nogui ./internal/gateway/. Not tried against a real relay with per-key model lists. |