Commit Graph
2846 Commits
Author SHA1 Message Date
yetone 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.
2026-10-12 02:56:01 +08:00
yetone 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.
2026-10-12 02:56:01 +08:00
yetone 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.
2026-10-12 02:47:08 +08:00
yetone 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.
2026-10-12 02:47:08 +08:00
yetone 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 (ee7a9b24a) reads
$XDG_DATA_HOME/grok-app, so the App's config was written outside the
home the test walks, its base_url never swapped, and no drift showed:
"applied_test.go:219: unwired: <nil>" on ubuntu CI (run 38162553532).

Run: with grokAppOS forced to "linux" in a throwaway file, the test fails
exactly so without this and passes with it. go test ./internal/agent/
ok on macOS; gofmt clean; GOOS=linux and GOOS=windows go vet ok.
2026-10-12 02:35:18 +08:00
yetone 054bdb8bbe gui tests: the sidebar's room
18e82adc6 shows the sidebar from 1024pt, so the window's pages are 212pt
narrower and start at x=212. Eight files assumed the old room:

- header-centre measures the tabs' gap from the layout button.
- phone-web's desktop browser at 1000pt, under the sidebar's width.
- routing-pause and routing-pointer-pin wheel over the view, not the
  sidebar at x<212.
- routing-scroll-end takes its columns from .rt-more's own width
  (routing.js byWidth); usage-pack opens at 1512 to keep 1300 of room.
- purpose-filter closes the menu by a scroll that ends at the view's
  top, and measures once the rows and scroll are at rest.
- sessions-overview scrolls the shape card no further than a third down,
  and waits a frame after a resize: WebKit starts the reduced-motion
  transition of the sidebar's padding and settles it in the next frame.

Run: all eight, plus sidebar, side-toggle, session-identity and
usage-ledger, pass in Chromium and WebKit; each failed with 18e82adc6
and passed on d4eae3618 with it reverted.
2026-10-12 01:58:58 +08:00
yetone 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 d4eae3618 minus the sidebar at 888pt. number-units, usage-speed,
usage-speed-count, usage-refresh, usage-refresh-flight and
usage-ttft-rounding pass in both engines; go test ./internal/gui/ ok.
Screenshots of the tiles in en and zh at 1100 and 1400 looked right.
2026-10-12 01:58:58 +08:00
yetone 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.
2026-10-12 01:55:05 +08:00
yetone 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 (917a36577) loadUsage(asked)
calls quotasOpened(), which the test's faked page didn't have, so the
asked read threw before it read anything ([] for [true]). The test now
lifts quotasOpened and QUOTAS_OPEN_GAP from app.js with loadUsage, in
both of its pages. Broken by hand (loadUsage no longer opening the
allowances when asked): red again.

Run: privacy-hides-accounts 20/20 green in WebKit and 20/20 in Chromium;
usage-stale-answer 20/20; the other browserless GUI tests pass.
2026-10-12 01:55:05 +08:00
yetone 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.
2026-10-12 01:55:05 +08:00
yetone 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.
2026-10-12 01:55:05 +08:00
yetone 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 5dfcf4346); with it 0.
- strip-scrollbar.test.cjs now says the Mac strip has no bar (width none,
  bar 0), and goes red without the CSS.

Run: tencent-cloud 20/20 green in WebKit and 20/20 in Chromium;
strip-scrollbar, sess-agent-strip, usage-sessions-agents-fit,
tencent-access-key, system-one, click-scroll, segs-press-redraw in both
engines (segs-press-redraw's Chromium 440px case is red now and then
under load in other trees too: it is one of the Settings tests #1659 is
moving onto the page's last settings read; green 8/8 in each engine
with this change).
2026-10-12 01:55:05 +08:00
yetone 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.
2026-10-12 01:55:04 +08:00
yetone 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.
2026-10-12 01:51:05 +08:00
yetone 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.
2026-10-12 01:51:05 +08:00
yetone a0c4dba97d gui: the tray icon closes an open panel on the Mac under a window over the whole screen too, not only when the panel can be seen (#1661)
TestTrayCellClickReleasedPanel went red with "initial quota click did not
open the panel". The cause: Wails' WebviewWindow.IsVisible on the Mac is
the window's occlusion state, not [NSWindow isVisible]. This Mac runs
UURemoteServer, whose privacy curtain is an opaque window over the whole
screen at layer 2147483631, above every app's. Under it, every window is
"occluded", so the panel the click had just opened read as closed.

The same check is a product bug too. togglePanelNow went through Wails'
SystemTray.ToggleWindow, which chooses hide or show by IsVisible. Under
such a cover, a click on the tray icon showed the already open panel
again and never closed it. With only the test's check changed, the test
failed on "second quota click did not close the panel".

Fix: on the Mac, togglePanelNow decides by windowOpen (shown and not
miniaturised, the check #1381 brought in for lightweight mode). It hides
the panel, or places it and shows it, itself. fitPanel, zoomWindows and
trayCellClick use windowOpen in place of IsVisible as well. Linux and
Windows still go through ToggleWindow, unchanged. The Hyprland branch's
IsVisible checks are left alone, since they are Wayland only. Both
AppKit tests (TestTrayCellClickReleasedPanel, TestPanelCloseHidesIt) now
read the panel's state through windowOpen. gui-shell.md item 5 says so.

Run, on darwin/arm64:
- Under an injected cover (scratchpad cover.swift: opaque, max level,
  sharingType none, the whole screen):
  - origin/main: TestTrayCellClickReleasedPanel 0/8, and
    TestPanelCloseHidesIt 0/4 ("timed out waiting until the panel shows").
  - Test-only change: 0/8 ("second quota click did not close the panel").
  - This commit: TestTrayCellClickReleasedPanel 25/25, and
    TestPanelCloseHidesIt 20/20.
- Under UU's own curtain:
  - origin/main: 30/30 red.
  - This commit: 10/10 green.
- Before the curtain was up, origin/main passed 75/75. Under an activator
  load, it was 5/40 red.
- go test ./internal/gui (GUI build) passes. go test -tags nogui
  ./internal/gui passes. gofmt is clean.
- go vet with -tags nogui passes for linux and windows; go vet passes
  on darwin.

Not tried: clicking the real status item by hand under a remote session.
The test drives trayCellClick and togglePanel's path through the host.
2026-10-12 01:45:14 +08:00
yetone 94fd332c35 agent, gui, tui: an agent's own models can be left out of its model picker (#1642, MizuIro-H)
DeepSeek Harness offers its own DeepSeek models beside magpie's in its
model picker, and nothing in magpie could leave them out: `magpie visible`
and the model list only cover magpie's catalog. An agent's model list now
has a switch at the top, "Show {agent}'s own models", for an agent that
has models of its own. Off, its picker offers magpie's alone.

- settings.OwnModelsHidden lists the agents whose own models are left
  out. provider.OwnModelsHidden / SetOwnModelsHidden read and write it.
  POST /api/settings keeps it: the Settings page doesn't send it.
- agent.Picks(f, cur) is a field's options without the agent's own
  (no Ref, a value). It leaves them in when the field has no magpie
  option at all, and always keeps the value the agent is set to now, so
  the user's own choice isn't dropped or rewritten. The GUI's agent
  fields and the TUI picker read it. The CLI still sets an own model by
  name.
- GET /api/agent-models/{id} says `own` and `ownHidden`. POST
  {ownHidden} sets it. The GUI's switch rolls back if the save fails,
  and closing the list filters the picker at once, before the state is
  read again. The order view (magpie's models alone) hides the switch.
- Strings in zh, zh-TW, ja, de.

Run: go test ./internal/agent ./internal/provider ./internal/settings
./internal/tui, all green. go test ./internal/gui is green apart from
TestTrayCellClickReleasedPanel, which fails the same alone on
origin/main ee20a1511 (#1661). The new TestAgentOwnModelsHidden goes red
with Picks returning every option. The GUI suites agent-*, gui-*, i18n-*
and settings-* pass 424/424. The new agent-models-own.test.cjs runs in
Chromium and WebKit, en/zh/de/ja, at 420 and 1100 wide, and goes red with
the close-time filter taken out. gofmt is clean, and linux and windows
vet are clean (gui on windows only).

Not tried: the real dsh in the live GUI.
2026-10-12 01:29:57 +08:00
yetone 781cb386cc gui tests: quota-curve measures the tray's spark in one go once it is drawn, so it no longer reads a card that was just redrawn as having no box
quota-curve.test.cjs could fail with "TypeError: Cannot read properties of
null (reading 'height')". It looked up the tray's spark and its card in one
call each, then measured them. When the tab opens, the allowances it reads
come back and the cards are drawn again (#1588). Under load, the card found
first could be taken out before it was measured, so boundingBox() gave null.

Now one waitForFunction finds the card and the spark, and measures both, in
a single pass in the page, once the spark has a width.

What was run, with one busy-looping node per CPU:
- origin/main 5dfcf4346, chromium only, 3 runs: red in 1 of 6 tests.
- This branch before this change, same load: red in 4 of 6.
- After this change, same load: 6 of 6 pass.
- Without load: quota-curve, balance-curve and panel-balance-order pass in
  both engines.
2026-10-12 01:19:37 +08:00
yetone 7c23ecea9d gui: the tray's quota spark no longer has a dotted now line, and clicking into the panel's list no longer rings the whole list (#1601, MizuIro-H)
The reporter uses the Linux GTK/WebKit tray panel. Two of their points
reproduce in both engines:

- The 16px spark under a card drew the large curve's dotted upright now
  line. In that size it reads as a stray mark under the curve. The spark's
  solid line already ends at now. drawQuotaPlot now leaves the now line out
  when it draws thin; the large curves keep theirs.
- A view takes focus (tabIndex -1) so the arrow keys scroll it after a
  click. A click and then a key made it :focus-visible, and the browser drew
  its own ring round the whole list: 3px in WebKit, 1px in Chromium.
  `.view:focus { outline: none }`. The view can't be reached by Tab, and
  every control inside it keeps its own ring.

The content cut off at the bottom in their screenshot is the list before it
is scrolled. Scrolled to its end at 440x560, the last card ends 44px above
the footer at both 1x and 1.75x, in both engines.

What was run:
- quota-curve.test.cjs now checks that there is no now line in the spark,
  and that a click and then a key leave the view with no outline.
- Breaking each fix by hand turns the test red in chromium and webkit, en
  and zh.
- quota-curve, balance-curve, readable-focus, click-scroll and
  panel-balance-order pass in both engines, twice in a row after the rebase.
  In one earlier run of this set, click-scroll's late-wheel subtest went red
  once in Chromium under load. It is filed as #1660; this change touches no
  scrolling.
- The new focus check runs after the spark is measured. A click focuses the
  window, the window's focus reloads the cards, and a card measured during
  that redraw had no box.
- A probe of the reporter's cards (Codex with credits, Command Code, and
  SudoCode and DeepSeek balances) at 440x560, 1x and 1.75x, light and dark.

Not tried: real Linux, WebKitGTK or Wayland. The lightweight panel that
never maps (Gdk-CRITICAL) is not looked at here.
2026-10-12 01:19:37 +08:00
yetone 9ce12eec71 gateway: a tool_use turn sent to DeepSeek's Anthropic endpoint carries a thinking block, so DeepSeek no longer refuses the request with 400, or with 422 over Claude's redacted thinking (#1611)
What changed: in thinking mode, DeepSeek's Anthropic endpoint
(api.deepseek.com/anthropic) refuses a request when an assistant turn has a
tool_use and no thinking block: 400 "The `content[].thinking` in the
thinking mode must be passed back to the API". It also refuses
redacted_thinking anywhere in the request with 422 "unknown variant
`redacted_thinking`". A Claude Code routing group whose Claude turns fall
over to DeepSeek met both refusals. This is the Anthropic-endpoint sibling of
#1592 (Responses) and #1462 (Chat).

- anthropicReplaysThinking(host, model): DeepSeek only, by host or model id.
  It is never api.anthropic.com or a Claude model.
- withThinkingOnToolTurns: a tool_use turn with no thinking gets a
  {"type":"thinking","thinking":" "} block first. Redacted thinking becomes
  that block, or is dropped when the turn already has thinking. The body is
  returned byte for byte when nothing changes.
- The passthrough and the translated build (a Chat/Responses client to an
  Anthropic-only DeepSeek) both use it. The translated build also replays
  the turn's own reasoning text, where it has one.
- docs/subsystems/gateway-routing.md describes it.

Checked live on 2026-10-11 against api.deepseek.com/anthropic with
deepseek-flash and deepseek-v4-pro:
- Thinking on (no field, enabled or adaptive) with a bare tool_use: 400.
- Thinking disabled with a bare tool_use: 200.
- redacted_thinking, even in a text-only turn: 422.
- Thinking " ", thinking "", unsigned thinking and thinking after text: all
  200.

What was run:
- New tests in deepseek_anthropic_thinking_test.go:
  - direct and through group/cc;
  - glm-5.2 and claude-sonnet-4-6 on the same upstream are sent unchanged;
  - the translated path;
  - the body is returned byte for byte when nothing changes.
- Breaking each call site by hand turns its test red.
- go test ./internal/gateway passed (410s). gofmt -l is clean, and go vet
  passes for linux, windows and darwin.
- End to end, with a built binary on port 3611 and a sandbox HOME holding
  the owner's real DeepSeek key:
  - before this change: 422 with redacted thinking, and 400 with thinking
    adaptive;
  - after it: 200 with a complete reply in all 8 cases (direct and
    group/cc, streamed and whole, adaptive and no thinking field).
2026-10-12 01:19:37 +08:00
yetone ee20a1511b gateway: the package's tests wait ~42s less for queues and OTel exports (#1654)
internal/gateway hit go test's default 10m timeout under a full ./... on
a loaded Mac. go test -json timed its 1583 top-level tests at ~306s
summed (they run one after another); the slowest few waited on real
clocks for things the tests don't check.

- TestQueuedStreamFailureIsTheStreamsError (27s -> 0.3s): it queued for
  room in a 3s minute (MaxRPM 1), and each of the vendor's two retries
  waited a minute more, 9s a protocol. It now queues for a slot
  (MaxConcurrency 1, freed once the agent has heard a keepalive), which
  goes through the same keepQueued, queuedAlive and watch around the
  attempt, so its retries go at once. The assertions are unchanged.
- TestQueuedStreamKeptAliveOnceSentToItsVendor (15s -> 7.6s): the same
  slot instead of a 4s minute; keepHeldAfter 1.5s, keepalive 100ms and
  the vendor's 1s quiet stay. With the h.alive.sent clause in
  holdWriter.watch removed by hand it goes red on all three protocols
  ("wrote nothing ... between the vendor being asked and its answer").
- TestQueuedStreamKeptAliveForTheMinute keeps the MaxRPM queue.
- A shared holdSlot helper holds the slot; it frees itself after 5s and
  in cleanup, so a test that hears nothing fails instead of hanging.
- usage.OTelEvery / OTelSessionsEvery (5s / 2s, read once when StartOTel
  starts an exporter) replace the hard-coded tickers; the gateway's OTel
  tests set them to 200ms / 50ms through fastOTel.
  TestOTelClaudeMainAndChildDedupRetainsHelper 10s -> 4.5s (the rest is
  sessions' 2s settle before a Claude transcript counts as finished),
  TestOTelSessionDedupOnlyUnkeyedLoopback 2.25s -> 0.4s. Production
  intervals are unchanged.

Not cut: TestPluginStreamLargeReplies (22s, 24MB throttled at 3MB/s),
TestPluginStreamLongActiveReader (16s, sized to outlast a 10s stall
window the plugin host dropped in c38728145), TestLargeRequestEndpoints
(16s, a 64MB body the gateway parses many times over - product speed,
not test waits), and the many 1-3s tests.

Run: go test -count=3 -run 'TestQueued|TestOTel' ./internal/gateway (ok),
-race -count=2 of the same (ok), go test ./internal/usage (ok);
go test -count=1 -json ./internal/gateway: tests summed 305.9s before,
the changed ones ~41.6s less after; the whole run took 330.6s at load
average ~125 against 306.7s for the baseline, other tests slowing under
that load (e.g. TestWarmClaudeSaysWhyNot 0.26s -> 5.3s). gofmt -l clean;
GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gateway
./internal/usage clean.
2026-10-12 01:16:36 +08:00
yetone 3f6db48f50 provider: moving Cursor onto its plugin no longer fails "unserved" on the built-in's model ids the plugin still runs (#1656, delete-cloud)
The Cursor plugin lists Cursor's picker since 0.2.0 (plugins #51): a model
once per context size (grok-4.7@256k), effort and fast as the request's
parameters. The built-in ticks 0.1.x-style ids (grok-4.7-fast,
claude-opus-5-thinking, cursor-grok-4.5, a stale grok-4.7-low), which the
plugin's named() runs as the variants they stood for, but move() only
counted an id served when the plugin's list had it literally, and the
cursor mover had no served hook. A move failed for most ticked models.

The cursor mover now has served (cursorServed): an id is served when its
family, taken apart by splitCursorID and without -thinking/-fast, is a
model the plugin lists (its id before "@"), with or without Cursor's
"cursor-" prefix; default/auto when the plugin lists Auto. A family the
picker hasn't got (claude-fable-5-thinking-no-zdr, codex-5.3-fast) is
still refused. Known limit, as the report says: the list is flat, so a
-fast id of a listed family counts as served though the account may lack
fast; the plugin runs it as the nearest variant.

Siblings checked: Devin already has served, ZCode builtin; Grok's plugin
keeps the plain id for the default window (grok-4.7, grok-4.7@500k
beside it); the other plugins list the vendor's ids as the built-in did.

Run:
- TestCursorMoverServesBuiltinIDs, with the ids plugin 0.2.7 lists for
  its own context.test.mjs PICKER (got by running the plugin under bun;
  request() resolves each id the test calls served to a Cursor variant).
  Failed with the hook removed ("the Cursor mover has no served hook")
  and with the "@" cut removed (claude-opus-5-5 ... not served).
- go test -tags nogui ./internal/provider/ in a sandbox HOME: ok.
- gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/provider/: clean.
Not run: a real move with a real Cursor account (the reporter ran the same
approach end to end on their account: 17 unserved down to the 2 above).
2026-10-12 01:15:46 +08:00
yetone 5dfcf43465 gui tests: the masking-rules tests act on Settings' rows once the page has drawn its last read of the settings, not the first (#1653)
redact-rule-row failed in WebKit zh on a loaded machine with
"locator.scrollIntoViewIfNeeded: Element is not attached to the DOM".

Cause: opening Settings reads the settings twice, the page's own read
(showView) and the window's load() once the state is in, and each read
redraws every row (renderRedact replaces #redactList's children). The
test found the row after the first draw and scrolled it; when the second
read landed during Playwright's stability check, the element it held was
gone. Locator clicks retry on a detached element, but
scrollIntoViewIfNeeded and boundingBox act on the element they found.
A probe wrapping #redactList's replaceChildren showed the two draws
(renderSettings < loadSettings, then the same < async load).

Fix: reader.cjs gains watchSettingsReads (an init script counting the
page's GET /api/settings reads, each counted drawn a task after its body
is read, after loadSettings has drawn from it) and settingsDrawn (waits
for load.done, which load() sets in the same run that then asks for the
settings, and for every read asked to be drawn). redact-rule-row and its
two siblings on the same rows, redact-rule-edit and redact-kinds, wait
for it after finding their first row. The page is unchanged: its second
draw is how Settings catches up with the state.

Run (injected: the test's route holds the page's second settings read
until the row is found, and lets it go as the test acts on it):
- Injected, without the wait: 8 of 8 red in Chromium and WebKit, en and
  zh, 1100 and 640px, the issue's exact error. With the wait: 8 of 8
  green.
- redact-rule-row WebKit, 25 runs: 100 of 100 cases green at load ~115.
- redact-rule-row, redact-rule-edit and redact-kinds in both engines:
  50 of 50, and again 50 of 50 (injected 8 of 8) after rebasing
  onto 18e82adc6.

Not done here: 37 other Settings tests use boundingBox or
scrollIntoViewIfNeeded after finding a row and can meet the same second
draw; #1659 lists them, to move onto settingsDrawn.
2026-10-12 00:57:27 +08:00
yetone 751ebe8f5a gui: magpie leads Command-Tab's order after opening its window on a busy Mac too, not only when the main thread keeps up (#1651)
TestDockJoinLeadsCommandTab failed under a full local go test ./...: the
test app was LaunchServices' front app, yet last in Command-Tab's order
(lsappinfo visibleProcessList), kitty first.

Cause: setDock decided whether to activate magpie again by way of the
Dock (#1381's fix) from [NSApp isActive]. The Mac makes an activated app
the front app at once, but NSApp says it is active only once its main
thread has taken the activation in. On a loaded machine the join came
first, isActive read NO, dockStep chose a plain activate (a no-op for
the front app), and magpie stayed last. A temporary print in setDock
showed active=false in every failing run (3 of 5 at load ~120) and true
in the passing ones. The same can happen to a user when the panel's
focus and Open come close together on a busy Mac.

Fix: joining the Dock to the front always goes by way of the Dock
(activateAgain), whatever NSApp says. When magpie truly isn't active
(the tray's Open), the Dock's turn in front changes nothing: magpie is
activated after it either way. dockStep loses its active argument and
appActive is gone. docs/subsystems/gui-shell.md item 7 says so.

The test now activates magpie, waits for LaunchServices to call it the
front app, and joins, all in one turn of the main thread, so the join
always comes before NSApp knows: the busy-machine order, made certain.

Run:
- New test on the old dockStep: 5 of 5 red (magpie not first, kitty first).
  With the fix: 25 of 25 green at load ~120-135.
- The old test (no injected order) with the fix: 10 of 10 green at load
  ~180; before the fix 3 of 5 red at load ~120.
- TestDockStep (table without active). go test ./internal/gui (GUI
  build, darwin) 5 runs green. One run before them failed and its
  output wasn't kept, so which test failed is unknown. After rebasing
  onto 18e82adc6, one package run failed TestTrayCellClickReleasedPanel
  (its own AppKit child, no setDock on its path); it passed alone and in
  3 package runs after. Filed as #1661, cause not found.
  go test -tags nogui ./internal/gui green. gofmt -l clean; go vet
  ./internal/gui (darwin), GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/gui clean.

Not tried: a real magpie build with osascript Command-Tabs (as 15872d977
did) after this change; the full-screen join (dockOnFullscreen), which
still reads isActive at NSWindowWillEnterFullScreen, long after any
activation, and is unchanged.
2026-10-12 00:57:27 +08:00
yetone d4eae3618f gateway: reasoning off goes to an Anthropic API as thinking off, and the log says the level a translated request went at (#1636, jswysnemc)
jswysnemc saw a custom provider think at another level than the one the
agent asked. This commit fixes two places where magpie's own translation
did that.

- A Chat or Responses client turning reasoning off (effort none),
  translated to an Anthropic endpoint, was sent thinking enabled at a
  4096-token budget (buildAnthropic read Effort "none" as a level). It
  now goes as thinking disabled. A model that refuses disabled
  (alwaysThinks / mandatoryReasoning / thinkingOffRefused, e.g. GLM) is
  asked again at its least (thinkingBackOn), and markUnfit(offRefused)
  sends it that way at once until restart.
- none/minimal go as low to Chat/Responses for a model whose levels
  aren't known (effortOf). The route, the try and the usage log all
  said none/minimal. The route still keeps the level asked; the try and
  the usage log now say the level built (noteWireEffort/wireEffort via
  a context slot filled in forwardTranslated). Routing already draws
  asked -> went from the two.

The passthrough path (a client on the provider's own API, e.g. Claude
Code to an Anthropic relay) is unchanged: it sends the client's level
as it came.

Run: go test ./internal/gateway/ (full package, 304s, green);
TestTranslatedEffortLoggedAsSent (8 cases) and
TestTranslatedThinkingOffRefused fail with 11 assertions when the
gateway.go/anthropic.go changes are reverted. gofmt; GOOS=linux and
GOOS=windows go vet.
Not tried: a real vendor's Anthropic API with thinking disabled.
2026-10-12 00:53:48 +08:00
yetone 4b1b5dd822 agent: CC Switch's unified-history mirror waits for the proxy check and drops failover on quit too, tested on its own bytes (xuxing0727 on X)
CC Switch with "unify Codex session history" runs the official sign-in
as model_provider = "custom" (name OpenAI, requires_openai_auth,
supports_websockets), so failover goes on that table's base_url, not
openai_base_url. f156d9046 already gates and ends both; this pins it with
CC Switch's literal config. Run: the test, red with the proxy gate removed
and with dropMirrorFailover left out of EndFailover; CCSwitch tests green.
2026-10-12 00:50:18 +08:00
yetone cec9647a2a access: a default gateway key the user removed isn't made again when sharing is turned off and on (#1655, GradientLive)
Turning on Settings -> Share on local network makes a default gateway key
named "Magpie". A user who wants only their own, stronger key could remove
it from Gateway -> Gateway keys, but configureLAN looked for the default key
by LANKeyID, found none, and made a fresh enabled "Magpie" key the next time
sharing was turned on. That reads as a default key that is always there.

configureLAN now leaves a removed default key removed: when its id is
recorded (LANKeyID), or an older magpie dropped the id and kept only the
revoked mirror, sharing is turned on with the keys there are. Asking for a
new sharing key (newKey / rotate) still makes one, as
TestLANSettingSharesCallerKeyStore expects. A disabled default key already
stayed disabled; the test now holds that too. First-time sharing is
unchanged. docs/reference.md says so.

Run: go test ./internal/access ./internal/gui ./internal/agent (ok);
TestRemovedDefaultKeyStaysRemovedOnReshare goes red with the new check
disabled by hand (a second "Magpie" key appears). gofmt -l clean; GOOS=linux
and GOOS=windows go vet ./internal/access clean. Not tried in the real GUI.
2026-10-12 00:47:10 +08:00
yetone df49305e22 agent: TestOmo and TestJcodeHome no longer fail where omo or jcode is installed (#1646, ggbdpq)
Both tests check that the agent is not detected before its folder exists.
Detected also looks for the agent's command on PATH, so an omo or jcode
installed on the host made the tests fail. Both tests now run with an
empty temp dir as PATH. The TestOmo line is the reporter's.

To find every test with this problem, the whole agent package was run
with a fake executable on PATH for each agent id and Bin (145 names):
- TestOmo and TestJcodeHome failed.
- TestInstallWithoutNodeStopsWhenTheDownloadFails also failed, but only
  because the fake curl stood in for the real one. That is not an agent
  detection.

With this change, both tests pass with the fakes on PATH. go test -tags
nogui ./internal/agent/ is green, and gofmt -l and go vet are clean on
darwin, linux and windows.
2026-10-12 00:44:47 +08:00
yetone 11d1d5d208 usage: a model asked for at a window (grok-4.7@500k) and answered under its plain name is no longer marked swapped (#1645, ggbdpq)
magpie offers some models at a window beside their default, spelled as
<model>@<size>: grok-4.7@500k, and Cursor's grok-4.7@256k. The vendor
answers under the plain name. bareModel left the @500k in place, so
Swapped marked every such request as answered by another model.

What changed: bareModel now drops a trailing @<digits>[k|m], right after
the [1m] tail Claude Code writes, using the reporter's regexp. Another
version or variant answered for a windowed id is still a swap.

What was run:
- TestSwappedGrokWindowID uses the reporter's cases.
- It is red with the new line commented out (all five same-model cases
  fail) and green with it.
- go test -tags nogui ./internal/usage/ is green.
- gofmt -l and go vet are clean on darwin, linux and windows.

Not tried against real SuperGrok traffic.
2026-10-12 00:44:47 +08:00
yetone bc320e249f agent: T3 Code, Air, OpenChamber and the rest send the LAN key to a gateway pinned beyond loopback (#1647, ggbdpq)
The gateway takes gateway.Token, and the keys that name an agent
(gateway.TokenFor), only from loopback. When MAGPIE_ADDR pins the
gateway to an address beyond loopback and sharing is on, keyAt gives the
LAN sharing key, and most writers use it. T3 Code's instance still wrote
gateway.Token, so every call it made got 401. Air's and OpenChamber's
Checks compared against gateway.Token, so they said the wiring Sync had
just written was off.

The same mistake was in every writer that pairs gateway.URL() or
gatewayV1() with a fixed token:
- agy, Alma, Cindy, Claude Desktop, Copilot for JetBrains, Cursor's
  local agent, OpenHanako, Pencil, VS Code / Insiders / VSCodium,
  WorkBuddy-family models.json, ZCode (both files), Zed's credential,
  Aside's provider, and the legacy Claude token rename.
- Fix: these now take agentKey(agent) or hereKey(), which are keyAt and
  agentKeyAt for gateway.URL(). On loopback they are unchanged.
- Alma re-keys a provider that holds any of magpie's keys other than the
  one it should have now.
- WorkBuddy and Aside also count the new key as theirs.
- ZCode treats a saved address equal to the pinned gateway as this
  machine's, not another magpie's.

What was run:
- New tests: TestT3CodeKeyBeyondLoopback and
  TestAirAndOpenChamberChecksTakeTheKeyForTheGateway (from the
  reporter's patch), and TestPinnedGatewayKeyForEveryWriter, which covers
  the other writers.
- With the product files reverted, all three are red. The T3 token reads
  "magpie", and each of the 11 writers shows its old key. They are green
  with the fix.
- go test -tags nogui ./internal/agent/ is green.
- gofmt -l and go vet are clean on darwin, linux and windows.

Not tried with a real T3 Code, Air, OpenChamber or a real pinned
MAGPIE_ADDR on a second machine.
2026-10-12 00:44:47 +08:00
yetone 18e82adc62 gui: the window's pages down a sidebar in groups, the open page's tabs under it, and a button to have the header's tabs instead
From 1024 points wide (SIDE_AT) the window lays its pages down the left
as a Mac app's sidebar: Work (Agents, Sessions, Library), Models
(Providers, Routing, Gateway), Insights (Usage), Extend (Plugins), with
Settings and the gateway's address at the foot. The open page's own tabs
(Usage, Library, Plugins, Settings) are listed under it, opening and
folding on an iOS-like spring, and the page's strip is hidden. The header
becomes a breadcrumb, and pages whose head held only tools have them in
the title bar. Graphite: the open page is in the text's ink, not purple.
A pressed row darkens and never shrinks. The selection under the tabs
sets off as the row is pressed, on a 0.3s curve (it felt behind the
finger), and is the list's only shape: a sub-row hovered or pressed has
no ground of its own, which showed a block under the finger before the
selection slid there. The page's tab is clicked at once, so what is
typed next goes to it.

The title bar's button (or ⌃⌘S, Ctrl+Shift+S), there at every width,
picks the sidebar or the header's tabs. The choice is kept in
localStorage magpie.navLayout (side or top) at every width, so it is laid
out from the first frame; picked in a narrow window the sidebar is 184
points under 860. The two trade places in
a view transition: the sidebar slides, each tab flies to its place, and
the page slides as one. Without view transitions or under reduced
motion, the change is at once.

With nothing picked, narrower than 1024 the page beside a sidebar would
be narrower than Usage's requests table needs, so the header's tabs come
back. A resize
drops what a click held (heldWidth). Usage's KPI strip goes two to a line
by the room the page gives it (a container query), and Japanese counts
wrap there. Tests whose window is 1024+ were updated for the sidebar,
and docs/subsystems/gui-shell.md says how it works.

Run: sidebar.test.cjs and side-toggle.test.cjs 16/16 in chromium and
webkit, in en, zh, zh-TW, ja and de. Each was broken by hand (press
shrink, address cut, press glide, sub-row ground, view transition, kept
choice) and went red. Every page at 560 points with the sidebar picked,
zh and de, both engines: nothing scrolls sideways. session-identity's
ledger row sits under the footer beside the sidebar; WebKit's click
doesn't scroll to it, so the test wheels it up first. Animation frames were checked from a recorded video. The 105
affected GUI files in both engines; their reds were rerun alone and fixed
(filter-ime: the sub-row's click now at once; session-identity, above) or
fail the same on main (tray-logos). The full GUI suite in chromium, on
the rebase onto d5cae267a, was cut short at 352 tests on the owner's
"ship": 6 reds (account-alias, account-models, codex-auto-review,
codex-credits, context-text) each pass alone, here and on main d5cae267a,
so they are timing under the full run's load and are to be filed. After
rebasing onto e4e22b23e: sidebar, side-toggle, session-identity,
filter-ime, library-instr-busy, usage-speed-count and view-scrollbar,
50/50 in chromium and webkit. go build ./... passes.
2026-10-12 00:41:34 +08:00
yetone f11fdd854c provider: oMLX's Clef, Clef-Flash and OpenJev classify routing groups through System One, and agents no longer see them as chat models (#1641, ObsidianArch02)
oMLX 0.7.1.dev1 (jundot/omlx#4315) serves decision models at POST
/v1/systemone. Its /v1/models lists them among the chat models with
nothing to mark them, by the alias the user gave one. Its
/v1/models/status (same key) gives each model's model_type, which is
"decision" for these. oMLX finds that from the checkpoint's files, so
the folder's name needn't say "clef" or "openjev". A name rule would
miss an aliased OpenJev, so magpie reads the status list instead.

- The omlx preset has a decision base, http://localhost:8000/v1. An oMLX
  provider saved before this gets its chat base as one, at whatever port
  it was given (the same backfill Zen and OpenRouter got).
- omlxDecides joins listsDecisions. fetchDecide reads
  /v1/models/status and keeps the decision models under <id>.decisions,
  each by its alias where it has one. It leaves out the ones the user hid
  in oMLX and keeps the window oMLX serves. Clef and OpenJev both read
  images, so ImageInput is set.
- DecidesModel then takes them out of the agents' lists and offers them
  as deciders. Jev() is the first of them. A server with none (or an
  older oMLX) lists none, and no Jev alias is made up for it.

Run:
- TestOMLXDecisionModels: the fake answers with get_status's real fields.
  Clef-Flash by name and OpenJev under the alias "router" are deciders,
  the hidden Clef isn't, the chat model alone reaches agents, and
  RouteDecider plus AskSystemOne post "router" to /v1/systemone. Red
  with omlxDecides taken out of listsDecisions.
- TestOMLXWithoutDecisionModels: no decision model means none, not Jev.
- go test ./internal/provider, gofmt, linux and windows vet.

Not tried: a real oMLX 0.7.1.dev1 with a Clef checkpoint (no Apple-silicon
oMLX install here). The fixture follows the server's source at the
v0.7.1.dev1 tag, not captured bytes.
2026-10-12 00:37:27 +08:00
yetone 1d67f79ca3 gateway: a Claude subscription's next turn goes on in the Claude Code that had the conversation, whatever the client's billing line says (#1638, chicring)
The bridge finds the run a conversation went on in by turnKey, and a
rewritten turn's by newLooseTurn. Both hashed the request's system prompt
raw, with the client Claude Code's x-anthropic-billing-header line in it.
renderClaudePrompt already leaves that line out of what a run is told,
but its fields change from turn to turn on the clients that send them:
cch (#1600, 2.1.114), and cc_prev_req, cc_prompt_id, cc_prompt_index and
cc_turn_index (2.1.296's binary, when it counts itself first party). So
no next user turn found its idle run or its shelved session. Each turn
started a new Claude Code that was told the whole conversation in one
message, which wrote it to the prompt cache again: the reporter's
cache_read stayed fixed (~18k, system + tools) while cache_write grew
with the conversation (~368k). Tool rounds inside one turn still went on
(follows doesn't look at the system), which is why it showed only when a
turn ended.

Both keys now hash withoutBillingHeader(req.System). The rest of the
system prompt stays in, so a real change to it still starts a new run.

Run:
- TestClaudeBillingLineKeepsTheRun: two turns whose billing lines differ
  only in cch, cc_prev_req and cc_prompt_id go on in one run, and the run
  is told "b2" alone, never the billing line. Red on the old turnKey
  (2 runs; the second told the whole conversation).
- TestClaudeRunKeysLeaveOutTheBillingLine: both keys ignore the line and
  still change with the rest of the system. Red with only newLooseTurn
  reverted.
- go test ./internal/gateway (434s), gofmt, linux and windows vet.
- Real Claude Code 2.1.296 under a fake upstream: --resume sent bytes
  identical to an in-process run, with and without an MCP tool round, so
  the resume itself doesn't move the prefix.

Not tried: the reporter's own client version and setup. A 2.1.296 client
pointed at a plain base URL sent a constant billing line, so I couldn't
see the per-turn fields from the client side here. If a miss remains, it
is logged as "a new Claude Code is told the whole conversation".
2026-10-12 00:37:27 +08:00
yetone e4e22b23ec gateway: a relayed Gemini stream the upstream cut short ends in Gemini's own error (#1644, ggbdpq)
What: a Gemini client's stream relayed as it comes (a custom provider's
Gemini URL, Vertex AI) that the upstream stopped cleanly before a
candidate's finishReason was delivered as if whole: the relay's cut check
(#370) only knew Anthropic's message_stop and Responses'
response.completed. Now the usage sniffer marks a Gemini SSE stream ended
on geminiEnds (the #1643 rule: a candidate's finishReason, or a chunk with
no candidate), the tail switch counts Gemini, and streamFailure writes
Gemini's own mid-stream error, the shape geminiEncoder already uses:
data: {"error":{"code":502,"message":...,"status":"UNAVAILABLE"}} with no
event line (Google's SDK reads none).

Sibling: before this, a read that failed mid-reply on a Gemini relay
(cutMidReply) also went through streamFailure's default and wrote
Anthropic's "event: error" shape to a Gemini client; it now gets Gemini's.

usageMetadata is not taken as an end, as the reporter suggested: Vertex AI
sends it on every chunk (the captured vertexThought bytes).

Run:
- New TestGeminiRelayEndedShort: the captured Vertex reply cut mid-answer
  ends in the Gemini error and no event: line; the whole reply and a
  usage-only reply go as they came.
- Broken by hand three ways, each red: Gemini dropped from the tail switch
  (the cut ended silently); streamFailure's Gemini case removed (Anthropic's
  event: error was written); the sniffer's geminiEnds removed (the whole
  and usage-only replies wrongly got the error).
- go test -tags nogui ./internal/gateway -run 'GeminiRelay|Sniff|Passthrough|CustomGemini|Vertex': ok.
- go test -tags nogui -count=1 -timeout 40m ./internal/gateway after rebase on origin/main: ok (505s).
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gateway clean.

Not run: no real Gemini CLI or Vertex relay cut mid-reply; httptest
serving captured Vertex bytes cut by hand.
2026-10-12 00:36:49 +08:00
yetone 17c56ed245 gateway: a Gemini reply the upstream cut short ends in an error, not as if whole (#1643, ggbdpq)
What: a translated reply from a Gemini upstream (a custom provider's
Gemini URL, Vertex AI, Factory's generate route) or Code Assist
(Antigravity) whose stream stopped cleanly before the last chunk was
delivered to the client as a whole reply: finish_reason "stop" to a Chat
client, end_turn to Claude Code, 200 to a client that asked for no stream.
The cut check from #1562/#1563 (errEndedShort) only ran for Anthropic and
Responses, since Gemini chunks have no type and there is no [DONE].

Why this way: geminiEnds reads a candidate's finishReason (Code Assist's
inside "response"). The reporter's patch also counted usageMetadata as an
end, but Vertex AI sends usageMetadata on every chunk
({"trafficType":"ON_DEMAND"} until the last; the captured vertexThought
bytes), so a real Vertex stream cut after any chunk would still read as
whole. A chunk with no candidate at all (usage alone, a blocked prompt)
does end the stream: the reply said nothing, and #667's empty-reply path
still handles it (TestGeminiEmptyReplyIsAnError's "no candidate"). An
error chunk still reaches the client as the vendor's own error, because
failed is set and the cut check needs failed == "".

Run:
- New TestGeminiUpstreamEndedShort (Chat and Anthropic clients) and
  TestGeminiNonStreamEndedShort use the captured Vertex AI reply cut
  after "No, 391 is not prime because it is". Broken by hand (geminiKin
  dropped from the two cut checks), both fail: the Chat stream ended
  "stop", the Anthropic one end_turn, and the non-streamed one came back
  200 whole. With the fix, the Chat and Anthropic streams carry the
  error, the non-streamed request gets a 502, and the whole reply is
  served as it came.
- TestGeminiEnds: the Vertex usage-only chunk is no end; finishReason,
  Code Assist's wrapped one, and no-candidate chunks are.
- go test -tags nogui -count=1 -timeout 40m ./internal/gateway: ok (425s).
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/gateway: clean.

Not run: no real Gemini/Vertex/Antigravity stream cut mid-reply. There is
no reporter's live case; the fixture is a captured Vertex reply cut by
hand. Code Assist is covered by the geminiEnds unit test only, not an
end-to-end Antigravity request. A relay that strips finishReason from
whole Gemini streams would now get the error; none is known.
2026-10-12 00:27:55 +08:00
yetone 53abc8e283 gateway: a script Claude Code starts, naming a Claude id magpie doesn't serve, goes to Claude Code's tier (tbxark on X)
tbxark's request log: Claude Code's own requests went to its tier, while
Python-urllib asked /v1/messages for claude-sonnet-4-6 and claude-opus-5-5
and got 404 "unknown model" in 5 ms. A hook, the statusline or a plugin's
script that Claude Code starts inherits its ANTHROPIC_BASE_URL and token, so
it reaches magpie with the plain gateway token and its own User-Agent.
claudeTierStandIn mapped a Claude id to Claude Code's tier only for a
request magpie took for Claude Code, by its User-Agent, so the script's
ids went nowhere.

Now a request that came with the plain token (not a magpie-<agent> token
magpie gave an agent), whose User-Agent names no agent magpie knows
(usage.IsAgent; claude-desktop and cursor-local are known too), and that
names a Claude-family id magpie doesn't serve, gets Claude Code's stand-in
for it, on /v1/messages and on count_tokens (the one choke point both
use). Nothing changes when:
- the id is served (a Claude subscription or an Anthropic key in the
  catalog lists it): it goes where it is served, as before;
- the caller is an agent magpie knows, or uses an agent's own token;
- Claude Code isn't routed through this gateway (StandIn says nothing),
  so the 404 stays.

Run:
- TestClaudeTierForAScriptClaudeCodeStarted (new) fails on the old
  gateway.go (404 for urllib, "", anthropic-python; count_tokens counted 0
  without reaching the tier). Breaking the token check by hand or the
  served-id check by hand turns it red too. TestIsAgentByUserAgent (new,
  internal/agent) covers IsAgent with the real agent list.
- Sandbox HOME, a fake Anthropic upstream, `magpie serve` on 127.0.0.1:3561
  with Claude Code's settings.json routed there (sonnet/opus tiers set):
  python3 urllib POST /v1/messages claude-sonnet-4-6 with x-api-key magpie:
  old binary 404 "magpie knows no model", new binary 200, upstream got
  m-sonnet-tier; claude-opus-5-5 -> m-opus-tier; count_tokens reached the
  upstream on m-sonnet-tier. A codex_cli_rs User-Agent still gets 404.
- gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; go test of every package (gateway with
  -timeout 25m).

A full ./... run on the loaded Mac timed the gateway package out at 10m
(#1654); run alone it passed in 330s.
2026-10-12 00:22:49 +08:00
yetone f57dc9610b library, gui: an instruction set made, saved or removed writes only the instructions, and the page holds its buttons while it does (#1624, Hipple)
On Windows 11 the Library's Instructions tab took 30s+ to show, and each
instruction made, saved or removed took about a minute with nothing on
the page to say so; a second click made a second set or removed twice.

What an instruction change cost:
- SaveInstructions and ImportInstructions went through change(), which
  gives every agent its MCP servers and skills again too (takeEdits and
  syncSkills look through every skill folder, and the projects), and
  the API then answered with a whole library.Read, which reads every
  agent's skill folders through again (foundSkills, behind: minutes on
  a machine with many skills, #541).
- Every read of the library found the agents (Targets: every agent's
  folders, WSL too) three times: ReadInstructions, readView, and
  foundServers.

Now:
- library: changeInstructions writes only the instructions into the
  agents (with backups as before); readView finds the agents once and
  passes them to instructionsView and foundServersOf. ReadInstructions
  stays for the TUI.
- gui: an instructions/* action answers {part: "instructions",
  instructions, result, problems}; the problems the last change had with
  servers and skills stay, those with the instructions are the new
  change's.
- library.js change(): one change at a time; while one is out the
  page's (and the Library dialog's) buttons are disabled, the page is
  aria-busy, the button pressed says "Saving…" and so does the status.
  An answer with part "instructions" is merged into the page's library.

Timed on the Windows test box (sandbox profile, 1 agent, 80 skills, copy
mode): an instruction create was ~170ms + a ~460ms Read, now ~80ms + a
~70ms instructions read; Glance 350 -> 200ms, Read 480 -> 320ms. The
30s/1min the reporter sees wasn't reproduced there.

Tests (each fails on the old code):
- TestInstructionChangeWritesOnlyInstructions: a server taken out of
  codex's config by hand stays out through instruction create, switch,
  save and remove, and comes back with a server change.
- TestInstructionChangeAnswersInstructions: the instructions answer and
  the problems kept.
- library-instr-busy.test.cjs: a double click on Add sends one create,
  every page button is disabled and the pressed one says Saving… while
  the answer is held, the page keeps the rest of the library after an
  instructions-only answer; the sure Remove double-clicked sends one.
  Chromium and WebKit, en/zh/zh-TW/ja/de.

Also run: go test ./internal/library ./internal/gui ./internal/tui;
gofmt; GOOS=linux and windows go vet; every library*.test.cjs plus the
30 other GUI tests that reach the Library, Chromium and WebKit: all pass
but library-mcp-tool-switch in WebKit, which fails the same alone on
origin/main (#1609), and mobile-web's desktop-vs-main check, which needs
a git checkout the scratch copy it ran in hadn't.
2026-10-12 00:10:59 +08:00
yetone 47ccb7165b gui: Usage's Output speed card keeps its number inside it, and a page's bar across its foot is as thin as at its side on mac (#1623, fanbuz)
At ~983px on Usage › Requests the Output speed figure with its reply
count ("48 token/秒(781 次)", since 3964ea65) ran past its card, as
.led-strip .v is nowrap, in zh, zh-TW and ja. The page then scrolled
sideways, and the mac page scrollbar rule set only width: 8px, so that
bar across the foot was drawn at the engine's default thickness.

- ledGroupSpeed also gives the figure in parts (the speed, then the
  count), and renderLedgerDash draws an array value as parts: each kept
  whole (ellipsised only if one alone is wider than the card), the count
  going under the speed in a card too narrow for both.
- body.mac's page/dialog scrollbar gets height: 8px beside width: 8px.
- usage-speed-count.test.cjs: widths 1400, 983, 789 (guzi171's window,
  #1634, the same overflow), 700, 560; the "read whole"
  check measured an element box that never overflows, now it measures
  every visible .led-strip .v's text (Range rects) against its card,
  which also covers the sibling cards and #ledVia's .led-strip; the
  sideways check reads #view-usage, the real scroller, not
  documentElement.
- view-scrollbar.test.cjs: a 3000px-wide page's bar across its foot is
  8px, as at its side.

Run: on the old code usage-speed-count fails in WebKit (zh, zh-TW, ja:
'75 token/秒(3 次)' outside its card) and view-scrollbar fails (foot
17px WebKit, 16px Chromium); with the change both pass in Chromium and
WebKit, en/zh/zh-TW/ja/de. Whole GUI suite (concurrency 4, load average
70-180): Chromium 3138 pass / 8 fail, WebKit 3135 / 9. None in Usage
but usage-stale-answer, red on main alone (#1632). The others pass alone
or fail the same alone on origin/main 756fef492: market-have (#1631),
routing-side-calls (#1640), redact-rule-row (#1653), privacy-hides-
accounts WebKit (#1632), segs-press-redraw (b0e25696e on main since),
routing-save/routing-flood (pass alone); library-instr-busy is #1624's
test, run here before its change.
2026-10-12 00:10:59 +08:00
yetone d5cae267a7 gateway: image recognition and web search pick only models the user enabled (JonahFu on X)
On a provider with a long list, AutoVision and the searcher picked their
small model from everything the vendor lists (Available), not from what
the user enabled. A Trae CN user's text-only model had its image sent to
OpenRouter's anthropic/claude-haiku-5.5, which they never enabled and
which OpenRouter refused for their region (403).

smallModel, and so AutoVision, searcherModel and the searcher's
first-model fallback, now chooses from Exposed: the user's picks, else
what agents are offered. With no enabled model that sees, a request
turned away says so ("none of the models enabled in magpie can see
images ... enable one that can, or pick one in Settings → Models → Image
recognition"); Vision off says it is off; a describer magpie picked
itself that fails is named as magpie's pick.

Not done: no fallback to another describer on a refusal. With the pick
limited to enabled models, a refusal is of a model the user chose, and
the error now names it and where to change it. Image generation's
AutoDrawer still picks from image models a provider lists: image models
aren't in the chat pickers, so limiting it to picks would turn drawing
off for nearly everyone.

Run: the two new tests fail on the old code (AutoVision =
router/google/gemini-3-flash, searcherModel = google/gemini-3-flash) and
pass now; go test ./... green except internal/gui's
TestDockJoinLeadsCommandTab, which reads the live desktop's Command-Tab
order and passes run alone; gofmt; GOOS=linux and windows go vet
./internal/gateway.
2026-10-12 00:01:28 +08:00
yetone 221e24a3c7 agents, gateway: Codex's subagent model offers every provider's models, not only ChatGPT's (#1633, laacmilan)
The Agents page's Codex "subagent model" field (settings.CodexSubagentModel,
which the gateway puts x-openai-subagent collab_spawn requests on) listed
only the ChatGPT accounts' models, and its setter refused any other
provider's. A user whose lead runs on a chat provider (Token中心, 智谱Plan)
couldn't put its subagents there.

- provider: CodexSubagentModels is Codex's shown catalog
  (CatalogFor("codex"), so hidden or unpicked models stay out), ChatGPT
  accounts first, routing groups included. SetCodexSubagentModel takes any
  provider/model or group id, refuses a bare Codex name.
  CodexSubagentUnserved says "magpie doesn't serve it now" for a non-ChatGPT
  id that isn't served. CodexAccountModel exported.
- gateway: codexSubagentPick gets the body. When the lead ran on the
  ChatGPT backend the task arrives sealed (encrypted_content), and only a
  ChatGPT account can open it: set to another provider, such a subagent
  stays on the model asked for, with Kept = sealedKept in the route trace
  (#1613's constraint; the reverse, a chat lead with a subagent on ChatGPT,
  was already handled by 149ab950e). A plain task moves, and sealed
  MESSAGE items are stripped as before.
- gui: i18n for both new reasons (zh, zh-TW, ja, de); the GUI test lists a
  chat provider's model and shows the sealed reason in every language.
- docs: agent-wiring and gateway-routing say the same.

Run:
- go test ./internal/gateway/ ./internal/agent/ ./internal/provider/
  ./internal/gui/ (ok), gofmt -l clean, GOOS=linux and windows go vet
  -tags nogui on the four packages.
- GUI node tests (codex-subagent-model, routing-kind, i18n-keys,
  codex-start-model-field, gui-ja, gui-de, gui-zh-tw) in Chromium and
  WebKit: 38/38.
- Broken by hand: without the sealed check,
  TestCodexSubagentSealedTaskStaysOffAChatProvider fails with a 400;
  options limited to ChatGPT entries, TestCodexSubagentModelTakesAnyProvider
  fails; options from Served() instead of Codex's shown catalog,
  TestAgentModelLineAllHidden and TestAgentModelsOnlyPicked fail.
- Sandbox HOME e2e with the built binary and a fake chat upstream:
  `magpie codex subagent_model token/gpt-6.1-sol` set, a bare gpt-5.5
  refused; a collab_spawn plain-task request on gpt-6-astra to
  /backend-api/codex/responses was answered by token/gpt-6.1-sol and the
  upstream got the task text.

Not tried: a real Codex CLI or ChatGPT account; the sealed case only in
unit tests.
2026-10-11 23:43:37 +08:00
yetone 0b0bd38b3f release: each tagged release is copied onto yetone/magpie with its notes and all 16 assets (PapainTea on X)
The main repo's Releases page was empty: the installers live only on
yetone/magpie-releases, which is bad for finding magpie and confusing to
people who look here first. A new mirror-release job, after the dispatch,
waits (up to an hour, every 30s) until the magpie-releases release for the
tag has 16 assets, downloads them, and creates the same release here with
GITHUB_TOKEN (contents: write): title "magpie vX", the same notes plus a link
to the magpie-releases page. A rerun edits the notes and replaces the assets.
It fails when fewer than 16 land here.

Nothing reads this repo's releases: self-update (internal/update),
install.sh and the site's /api/latest still read magpie-releases, unchanged.
A release made with GITHUB_TOKEN triggers no workflow, and none here listens
for release events.

Run: YAML parses; the wait and download half by hand against v0.1.1191
(16 assets, 554M, title "magpie v0.1.1191"). The create half runs for the
first time on the next tag.
2026-10-11 23:38:35 +08:00
yetone 639826a89d gateway: a routing group's compaction rule takes Minis's compactions (#1635, jueda12)
Minis (OpenMinis, iOS and Android) compacts with one request and no
tools: its own system prompt ("You are a context compaction engine. Your
summary will REPLACE the original messages in the conversation context
window. ...") and the conversation wrapped in one user message ending
"END OF CONVERSATION TO COMPACT.". Neither was in compactSystems or
compactAsks, so a group's Compact rule never matched it and Minis's
compactions went to the group's ordinary model.

Both are added, keyed on Minis's own text, not its User-Agent (which
Android lets the user change). The prompts were read from OpenMinis at
b4c0661 (Android ChatViewModel.kt compactSummarySystemPrompt and its user
message; iOS AIChatViewModel+Compaction.swift, whose line continuations
render the first paragraph to the same bytes), and the test's fixture is
those literal bytes.

A general signal (no tools plus a summarize request) was considered and
not taken: an ordinary tool-less chat asking for a summary would be sent
to the compaction model too.

Run: go test -tags nogui ./internal/gateway, gofmt -l, GOOS=linux and
GOOS=windows go vet. With the two entries removed, TestCompactingMinis
fails for all four compaction cases.
2026-10-11 23:37:34 +08:00
yetoneandhhh2210 957aa79aa3 provider, gateway: refreshing a saved Claude account's card reads its allowance through Claude Code, without switching to it (#1630, hhh2210)
A saved (not signed-in) Claude account's Usage card read nothing on
Refresh: claudeWindows only ever ran /usage for the account Claude Code
itself is signed in to, so the button did nothing for the rest.

Now the card's own refresh (RefreshUsage for that account, savedRefresh)
runs the real Claude Code's /usage with CLAUDE_CONFIG_DIR set to the
account's claudeSavedDir (readSavedClaudeUsage). magpie still never calls
Anthropic with the token itself, and Claude Code's own account is not
switched. The 30-second per-account floor holds, background reads keep
the last reading, and asks for every card (the Usage page opened, magpie
quota, magpie accounts) start no Claude Code per saved account: they keep
the last reading, or the "not read yet: refresh this account's card"
note.

Claude Code may refresh the account's token in that directory while it
runs, spending the old refresh token. So:
- inSavedClaudeDir holds a per-account RWMutex (claudeDirRun) for the run,
  and switchSavedLogin takes it for writing first, so a switch never hands
  Claude Code a copy the run has just spent;
- syncSavedClaude copies a rotated sign-in from the directory back into
  logins.json right after the run, under savedTokenMu and loginsMu.
Two Claude Codes in one directory are kept from refreshing at once by
Claude Code's own lock file (2.1.296's refresh lock in its config dir).
A saved account's warm-up, which already ran in that directory, now goes
through inSavedClaudeDir too.

The plumbing (configDir through UsageClaudeVia, readClaudeUsage and the
gateway's claudeUsage, and TestClaudeUsageRunsInSavedAccountDirectory)
is from hhh2210's patch 043ee7d7, reviewed line by line. Its gate (any
explicit read reads every saved account) was narrowed to the card's own
refresh, and the lock and sync back are new.

Run: go test -tags nogui ./internal/provider ./internal/gateway . (sandbox
HOME, fake claude via UsageClaudeVia, no real token), gofmt -l, GOOS=linux
and GOOS=windows go vet on the three packages. Broken by hand, each red:
saved never read (all three new tests), any ask reads saved
(TestRefreshSavedClaudeUsage), switch not held and no sync back
(TestSavedClaudeUsageKeepsRotatedSignIn / SavesRotatedSignIn), run in ""
instead of the account's directory. Not tried with a real Claude Code
binary against a real saved account.

Co-authored-by: hhh2210 <hzy2210@gmail.com>
2026-10-11 23:37:34 +08:00
yetone 756fef4921 gui: an update out, downloading or failed offers its release page in the browser (PapainTea on X)
Where GitHub is slow to magpie, the built-in download can take ages. The
About row's update now has "Open the release page" while an update is
available (desktop; on web Download already opens it), while it downloads,
and after a download error. The browser can then fetch the installer through
the user's own proxy or accelerator. The mirror setting is unchanged. The
button is kept across the 700ms download redraws, so a click on it isn't
lost, and it goes away once the row is back to up to date. The string was
already translated (en, zh, zh-TW, ja, de).

Run: new update-release-page.test.cjs (5 languages, 560/900px, chromium and
webkit: 22 pass, twice). Broken by hand three ways: the button made again
on every redraw, no button while downloading, and the button never removed.
Each one went red. All update-*.test.cjs pass (auto, blocked, check,
download-percent, hide, mirror, notes-ask, stuck, wait).
2026-10-11 23:36:47 +08:00
yetone 396a6a3d4f gateway: a flood of wrong remote keys is capped to 429, so a weak caller key can't be guessed unthrottled and each try stops being a valid/invalid oracle (akic404 on Discord)
A pentest of a publicly-exposed magpie gateway found the auth entry had no
rate limit: a remote client could try keys as fast as it liked. The system
key (sk-magpie-key-<48 hex>) is infeasible to guess, but a weak user-set key
(8+ ASCII) is not, and every try returned a distinct 401 that told the
caller whether the key was valid/well-formed.

tooManyAuthFails is one token bucket (50 wrong keys, then ~1/s) shared across
all remote callers. identifyCaller spends a token only on the !ok && !local
branch; once empty, later wrong keys get 429 + Retry-After instead of the
401 message, closing the oracle and bounding the work. A request carrying a
valid key, and any loopback request, never touch the bucket, so flooding
wrong keys can only clamp later wrong keys -- it can never lock out a real
caller (no self-DoS, which is why the bucket is global, not per-IP: behind a
reverse proxy every caller shares the proxy's address anyway).

Left unchanged, by design: the last-4 echo for a long key (#545, it names
only the caller's own submitted key, for debugging), and MAGPIE_WEB_KEY
(already forced >=16 chars + a charset in internal/gui/web.go).

Run (macOS): go test ./internal/gateway/ ./internal/access/ (both ok);
gofmt -l clean; GOOS=linux and GOOS=windows go vet ./internal/gateway/ clean.
Broke tooManyAuthFails to always return false and watched
TestAuthThrottleSparesValidAndLocal go red ("never clamped to 429").
2026-10-11 23:14:44 +08:00
yetone b0e25696eb gui: a segmented control's thumb glides once, one way, and no other thumb moves when a save redraws the page
Settings' Off/On (Lightweight mode in the report) shook back and forth when
clicked, and the first click on the page replayed every thumb's animation.

Why, in the old slide():
- Every save's answer runs renderSettings(), which draws a new control and
  a new thumb for each one. The new thumb took its place from what was
  remembered: within 300ms of the click it started from the position
  before the click, so a redraw mid-glide sent the thumb back to Off and
  slid it again.
- Settings is drawn while hidden (at start, or from another tab), so every
  control was remembered 0 wide. thumbsUnderPicks put the DOM right when
  the tab was shown but never the memory, so the first save's redraw grew
  every thumb on the page in from the left.

#1211 (700315dff) only kept a press made across a redraw (pointerdown on
one button, pointerup on its replacement); it never touched how the thumb
moves across a redraw, which is why the shake stayed.

Now:
- A redrawn control takes over the old thumb element itself, with its
  running animation, so a glide in flight just goes on. No clock math.
- slide() glides only when the target changes, from where the thumb is
  drawn now (computed transform), with a WAAPI animation; the CSS
  transform/width transition is gone so nothing else starts one.
- One shared ResizeObserver puts a thumb under its option, without motion,
  when its control is shown or resized. A control drawn hidden is never
  measured. thumbsUnderPicks and the two per-bar ResizeObservers go.

Run:
- segs-glide.test.cjs (new): records every thumb on General per frame and
  between frames, for an answer mid-glide, an answer at once with two more
  redraws on the way, and a refused save; Chromium and WebKit, en zh zh-TW
  ja de, 900 and 440px. 80/80 over two runs; on the old code 20/20 fail
  (thumb jumps back to 0).
- Full GUI suite, concurrency 6: 6157 tests, 10 fail. Each fails the same
  alone on origin/main 96de5cac2 (library-mcp-tool-switch #1609,
  privacy-hides-accounts and usage-stale-answer #1632) or passes alone on
  both (purpose-filter, routing-signin, filed in #1632). tencent-cloud's
  WebKit flake also happens on the old code (#1620).
- Checked by hand against a sandbox magpie web (real server, sandbox
  HOME): the clicked thumb moves one way, no other thumb moves, including
  Settings opened from Usage first.
- gofmt, go vet (darwin, linux nogui, windows), go test ./internal/gui.

Not tried: the Wails app itself, Windows and Linux webviews.
2026-10-11 23:04:12 +08:00
yetone f156d90460 agent, gui: Codex isn't handed to a magpie it can't reach, through a proxy or after magpie quits (Muma102kMichael, Leon920717, thisisvainxx on X)
Muma102kMichael (Windows): after magpie took Codex over, every project
and every new chat got 502. Codex's reqwest sends its requests for
http://127.0.0.1:3425 through HTTP_PROXY/ALL_PROXY or the system's
proxy, and only an exact IP or a CIDR in NO_PROXY (on Windows, with no
NO_PROXY, the bypass list with "*." removed) keeps 127.0.0.1 off it:
"127.*" and "localhost" don't, and macOS' exceptions aren't read. A
proxy in global mode answers 502 for every request. With [features]
respect_system_proxy Codex asks the system alone and goes direct with
no proxy set there. Account failover, which magpie writes uninvited
when 2+ ChatGPT accounts are on, put all of Codex's traffic, its own
models included, behind that proxy.

- codex_proxy.go works out Codex's proxy the way Codex does and probes
  GET / through it (must answer as magpie). Failover waits for that
  probe and isn't written while the proxy doesn't pass Codex on; one
  written before goes again.
- New drift kind "proxied": the Agents pill says Codex reaches magpie
  through a proxy that doesn't pass its requests on, How to fix names
  the fix (DIRECT rule for 127.0.0.0/8, NO_PROXY=127.0.0.1, or
  127.0.0.1 in Windows' bypass list), and the dialog has a one-click
  Disconnect from magpie (also on unreachable drift).
- Leon920717: after quitting magpie Codex kept retrying. The app that
  serves the gateway now takes failover out in OnShutdown
  (EndCodexFailover); the next start's Sync writes it again. A
  connected Codex is kept (its model is magpie's; Disconnect restores).
  A kill or crash still leaves failover in place.
- thisisvainxx: "several restarts". Codex's app-server keeps the base
  URL it started with, and KeepCodexDaemonCurrent ends with magpie, so
  EndCodexFailover restarts it when no codex session is on it.

Run:
- real codex-cli 0.162.1 in a sandbox CODEX_HOME against a fake 502
  proxy and a fake gateway: NO_PROXY=localhost,127.* -> 30 POSTs to the
  proxy; NO_PROXY=localhost -> proxy; NO_PROXY=127.0.0.1 -> gateway;
  respect_system_proxy with HTTP_PROXY set -> gateway directly.
- go test -tags nogui ./internal/agent/ (full package, 465s, ok) and
  the new tests after the daemon change; each new test went red with
  its guarantee broken by hand (failover gate, drift, EndFailover,
  daemon restart on quit).
- node --test agent-proxied/agent-unreachable/agent-failover/
  agent-disconnect-preview: 104 passed, chromium + webkit, en zh zh-TW
  ja de, window and panel.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui clean.
Not tried: the quit path in the real app, on the Windows box, or
whether computer use / remote connection broke for this same reason.
2026-10-11 23:00:00 +08:00
yetone 8029d98b7e gateway: a large Codex request ChatGPT closes on is asked again, not told 413 (#1628, ScarfQian)
ScarfQian (#1628, v0.1.1184, Codex desktop computer use on a ChatGPT
subscription): a 1.1 MiB turn answered with ChatGPT's 503 "upstream
connect error or disconnect/reset before headers. reset reason: remote
connection failure" came back as a2b96139c's 413 "dropped this 1.1 MiB
request ... magpie didn't retry it". Codex doesn't retry a 4xx, and every
later turn carries the same screenshots, so each one got one try and the
same 413 and the conversation was stuck.

a2b96139c took that 503 as deterministic for bodies of 1 MiB or more from
one report (ylorn: every turn past ~1 MiB, also without magpie). The
evidence says it isn't the request's: from here a Pro account answered
bodies of 0.5 to 20 MiB (a2b96139c's own body); Codex's own client sends
>1 MiB computer-use turns to the same endpoint; ScarfQian's other tool got
a 200 on the 9th try after 8 of these 503s; and "remote connection
failure" is Envoy failing to reach the backend, not a size check. So it is
transient, on some networks/times more than others. Nothing was remembered
per session or size: the "session keeps failing" was the history carrying
the images into every next turn, each refused 413 at once.

Now codexDropped leaves the 503 a 503, with a message that says the
backend closed the connection on this N MiB request, that magpie asked
again without resting the account, and, if it keeps happening, /compact or
shrink the images. In the accounts loop a large request's reset moves to
the next account without resting this one (ylorn's acct-1 rest stays
fixed); the last one left is asked again as for any 503 (lastRetries). On
the passthrough (Codex's own sign-in alone) it is asked again up to
lastRetries times after retryPause<<n. Codex then asks again itself for
the 503. A small request's reset is unchanged.

Tests (codex_dropped_test.go, a backend answering the literal 503 to
bodies over 1 MiB the first N times):
- TestCodexResetBigBodyAskedAgain: two accounts, closed on twice then
  served: 200, asked acct-1,acct-2,acct-2, nobody rests. Old code: 413
  after one try.
- TestCodexResetBigBodyStays503: closed on always: 503 with the advice,
  asked acct-1 then acct-2 3x, nobody rests; the next turn as large goes to
  acct-1 and is answered once the backend takes it. Old code: 413.
- TestCodexResetBigBodyRelayed: sign-in alone, closed once: 200 on the
  2nd try; always: 503 after 3 tries. Old code: 413 after one.
Broken by hand: old code -> all three red; the no-rest branch off -> acct-1
rests (and the next turn goes to acct-2); the passthrough retry off ->
Relayed red.

Run: go test -tags nogui ./internal/gateway, gofmt -l, go vet -tags nogui
with GOOS=linux and windows on ./internal/gateway. Not tried: the
reporter's network or a real ChatGPT reset (none reproduces on demand);
what Codex desktop shows after its own retries of the 503.
2026-10-11 22:54:49 +08:00
yetone cfa280a6c2 provider, gateway, gui: You.com can be added as a search API, with no key for its free search or with a key (#1626, brainsparker)
A model's web search, when no provider can search, goes to the search
APIs the user added; each of them needed a key except a SearXNG of the
user's own. You.com answers with no key too, so it is one a user can
add in one step.

- provider: SearchVendor has KeyOptional (You.com, SearXNG); Ready and
  check let a vendor that has it go with no key. You.com is listed
  between Firecrawl and SearXNG, its keys at you.com/platform.
- gateway: with no key, GET https://api.you.com/v1/agents/search?query=
  &count=6 (YouFreeSearch); with a key, POST https://ydc-index.io/v1/search
  {"query","count"} with X-API-Key, as its API reference says; with a
  base URL of the user's own and no key, GET <url>/v1/agents/search.
  Both replies are read from results.web then results.news: the
  snippets, else the description, and page_age. You.com's errors are a
  code beside a message, so the message is what the user is told (a
  402 "prepaid credit balance has been depleted" is a refused key, the
  next key or API is asked). Its requests carry the User-Agent tag You.com
  asked for, "youdotcom-integration/yetone-magpie", after magpie's own.
- gui: Settings › Web search lets You.com be added with the key empty,
  its placeholder saying so (zh, zh-TW, ja, de).
- cli: magpie search add you [<key>]; the help lists it.

New network addresses: api.you.com (keyless) and ydc-index.io (keyed),
asked only when the user adds You.com, with the search query only.

Checked against the real service on 10-11: a keyless GET to
api.you.com/v1/agents/search answered 200 (testdata/you/free_search.json
is that reply, cut to 3 hits), and a real run through askSearchAPIKeys
returned 6 pages. ydc-index.io/v1/search answered 402 with no key
(testdata/you/keyed_402.json, real bytes) and 403 to a made-up key. The
keyless endpoint isn't in the API reference; You.com's own docs pages for
third-party tools describe it (free, 100 a day per address, no account),
as LiteLLM, ragflow and AnythingLLM use it. you.com/terms bars automated
use of its website and apps, not the API. The keyed request shape is
from its API reference only: no key with credit was tried.

Run: go test -tags nogui . ./internal/gui/ ./internal/provider/
./internal/backup/ green; ./internal/gateway/ green but
TestTurnDoneSaidAtTheTurnsEnd (#1629, fixed in its own commit);
search-api.test.cjs in Chromium and WebKit, en/zh, 980/420px green;
gui-ja, gui-de and i18n-keys green; gofmt -l; go vet -tags nogui for
linux, windows and darwin. The tests make no network request (a stub
RoundTripper). Without the change, TestYouSearch, TestYouKeyOutOfCredit,
TestYouNeedsNoKey and TestSearchCLIYouWithoutKey fail, and with the GUI's
keyOptional check taken out search-api.test.cjs fails in all four
Chromium runs (Add sends nothing).
2026-10-11 22:45:11 +08:00
yetone 09136a6bf1 gateway tests: TestTurnDoneSaidAtTheTurnsEnd starts its clock at the turn's first request, as Took does (#1629)
Took runs from the turn's first request, but the bound took its start
just before the third, so the first two sends and the two noEnd waits were
outside it. A slow first request on a busy machine pushed Took past
Since(start)+20*quiet ("took 1.488977083s", a full gateway run). start is
now taken before the first send, so Took can never be over it, and the
slack is gone.

Reproduced by injecting a 1.5s sleep in the fake's tool-calling reply:
the old bound fails both subtests (took 1.99s, 2.40s), the new one
passes; the lower bound (8*quiet) still catches a Took measured from the
last request. Run: go test -tags nogui -run TestTurnDone ./internal/gateway/.
2026-10-11 22:45:10 +08:00