Commit Graph
3483 Commits
Author SHA1 Message Date
yetone 22d7ef08fe gui: the model picker opened from a provider's editor takes clicks, not the editor's fields beneath it (#2188, Deja-vuuu)
In a provider's editor, the Agents row's chip opens that agent's model
picker over the dialog. Nothing in the picker could be clicked: a
provider in the rail or a model in the list sent the click through to
the editor's fields underneath. Cause: 2cc663d0a (#820) has
modalBackground make every <body> child except #modal inert while the
editor is open. The picker, #pop, is another <body> child, so it was made
inert too. #pop is now left out with #modal. The only other static
<body> children are the views and the footer, and popups created later
aren't in the list it takes at open.

editor-picker-clicks.test.cjs (chromium + webkit; en, zh, zh-TW, ja, de;
1100 and 420 wide; API faked): opens the editor and the chip's picker,
checks #pop has no inert ancestor, clicks Zhipu in the rail (the list
narrows to it), picks GLM-5.2, and checks one /api/set for
claude/model=zhipu/glm-5-2 while the editor stays open.
Broken by hand (origin's modalBackground put back): it fails on the
inert assertion in every variant. With that assertion dropped, the rail
click times out in both engines on "<button>检测协议</button> from <div
id="modal"> subtree intercepts pointer events", which is the reporter's
symptom. Restored, it passes in both engines.

Run: the 161 GUI files that touch .modal, #pop, pickerRail, achip or
.editor, both engines, concurrency 4, load ~240: 2212 pass, 7 fail, 1
cancelled. Every one of those passes when its file runs alone
(provider-detect-draft, model-id-space, searcher-pick, zhipu-team;
noted on #1544), or fails the same with origin's app.js (login-import
chromium, #1307; account-arrange chromium's 90s budget, which passes in
113s given room, filed as #2200). node --check app.js.
Not tried: the real macOS Wails app.
2026-10-14 23:49:26 +08:00
yetone 743fcc0351 gui: a click at the view's top keeps the clicked control under the pointer, not the view at its top (#2134)
cf455ebd5 (#2134) kept a view that was at its top when clicked at its
top, whatever came in above what was clicked. That fixed the 2px slide
of Settings' Version row, but on Routing a day picked with the view at
its top brings that day's stage in above the bar (~138px), and the bar
was pushed down out from under the pointer. routing-days-fit ("picking
a day moved the bar") and routing-failed-open ("picking the request
moved the page") went red on main from then, 4 of 4 each in Chromium;
routing-side-calls 2 of 2.

The rule, decided: a view at its top stays at its top only while what
was clicked moves less than half its own height, so it is still under
the pointer. Anything larger above it is scrolled past, and the control
is held where it was clicked as before cf455ebd5. hold()'s comment, the
click guard's header and gui-shell.md say so.

Run on origin/main 7f968b95d, at load ~220-300, and again after moving
onto origin/main a36319d60 (no change to the click guard between):
- routing-days-fit 12/12, routing-failed-open 8/8, routing-side-calls
  4/4, update-auto 10/10, update-restart 22/22, in Chromium and WebKit.
- Broken by hand: with the old `h.top && want > 0` line, days-fit and
  failed-open go red (as on main); with the at-top rule removed,
  update-auto goes red (#2134's 2px).
- The click guard's GUI set (211 files that click and scroll), 4 at a
  time in Chromium and 3 in WebKit, at load ~300: Chromium 208 green,
  WebKit 207. The rest, run alone on this tree and on origin/main:
  routing-keys-fold (#1612), routing-model-rest (#2115) and
  routing-wb-restricted (#1905) fail the same on main;
  routing-flood (#2215) and sessions-folder-delete (#2218) failed once
  under the load and pass alone, 2 of 2 here and on main a36319d60.
- On a36319d60: routing-days-fit, routing-failed-open, update-auto and
  routing-side-calls green in Chromium and WebKit.
2026-10-14 23:27:46 +08:00
yetone a36319d607 tests: TestProviderListReadsSettingsOnce counts settings.json's parses, not a 2s bar a loaded runner exceeds (#2185)
The guarantee is that a provider's model list parses settings.json once,
not once to three times per model. The test timed one providerInfo call
against 2s, and on a Mac at load 270-360 it took 6.4s with the settings
read once. It now counts settings.Parses() around the call: 6 parses for
300 models, failing at 50, while reading per model gives 300 to 900. The
settings file no longer needs 20000 entries to make a read slow; 200 are
kept so the user's own answers still sit among others'.

Broken by hand, both fail with a real FAIL:
- ImageOverrideIn given a fresh settings.Load() per model: "300 models
  parsed settings.json 306 times".
- providerInfo put back to before 9db5753ba (ApplyImage, ImageOverride,
  ReplyLimit per model): "parsed settings.json 906 times".
Restored: passes, -count=3 under load ~290 (1.98s, 0.31s, 0.27s).

Run: gofmt -l, go vet ./internal/gui for darwin, GOOS=linux -tags nogui
and GOOS=windows; go test -tags nogui -timeout 40m ./... under a sandbox HOME at load
~240-300: internal/gui ok (835s) and every other package ok but three.
internal/agent and internal/gateway hit the 40m package timeout with a
test that had run 1m39s and 52s, not a hang; rerun with -timeout 90m
both pass (1273s, 1286s). internal/provider's
TestCopilotSecretToolUsername failed on its 5s secret-tool bound, which
is #1627 (open). Not run: Windows box (test-only change, no OS path).
2026-10-14 23:06:35 +08:00
yetone 87d83e7aba gui: Requests' head stays still on each refresh with Today picked, not shaking sideways in a window about as tall as the page (@LingYi_Stu on X)
The report: v0.1.1233, macOS, zh-CN, top nav, a narrow window with the
vertical scrollbar. On Usage > Requests with Today picked, the head's
right side (refresh, "5 秒", "≈$0.007") kept shaking left and right.

Cause: Usage's year heatmap (.heat-grid i { aspect-ratio: 1 }) makes the
page taller as it gets wider, for windows from about 720 to 1210px. So do
Sessions' calendar and the context waffle, which Routing's context card
uses too. With the window about as tall as the page, WebKit lays the
view out at full width under the 8px Mac bar (scrollWidth 1044 >
clientWidth 1036). On each redraw (Requests' 5s refresh with Today) it
lays it out 8px narrower for a few frames, so the head's right side
jumps 8px and back. Chromium doesn't do this. The reporter's "~1300" is
approximate: at 1300 the heatmap is at its widest and nothing shakes,
while 828 to 1044 at the page's own height does.

Fix: #view-usage and #view-routing keep the bar's room always
(overflow-y: scroll), as .modal .editor.framed > .ebody does. A short
page draws no thumb in either engine (checked by screenshot). The first
version applied this to every view, and agent-layout went red at 601px
(the identity column 148 < 150), so it is limited to these two views.

Test: usage-head-steady.test.cjs. Today, Codex rows, a year of heatmap
data and a cost that grows on each read, at 1044, 936 and 828 wide and
every height around the page's own. It clicks refresh and reads the
head's right edge, the interval's left edge and the view's
clientWidth/scrollWidth on every frame for 36 frames. It fails on the
old assets in WebKit for en/zh/zh-TW/ja/de (for example 1044x1109 zh)
and passes with the fix, 10 of 10, in Chromium and WebKit.

What was run (no Go was touched; baseline is origin/main b9c589ebb in
its own worktree; load 260-415 from other sessions):
- A WebKit probe from 600 to 1400px: shakes before, 0 after.
- usage-head-steady in both engines and 5 languages: red on the old
  assets in WebKit, green with the fix.
- agent-layout and account-arrange alone: pass.
- 159 related GUI files, 6 at a time (usage*, sessions*, context*,
  routing*, rt-*, view-*, gui-*, click-scroll, text-size, panel-usage,
  request-archive, tray-usage): 136 pass, including gui-zh-tw, gui-ja
  and gui-de. Each of the 23 reds was rerun A/B against b9c589ebb:
  - routing-context-fold (#1529) and usage-refresh (#2184) pass with the
    change and are red on base.
  - The rest are red on both sides, or vary case by case. Filed as #2211:
    routing-days-fit (red alone on base 4/4), failed-open, side-calls,
    agent-gone and hue-not-red WebKit 420, usage-agents-hide, and the
    agent-gone Chromium page.goto 5s timeout (8/8 alone on each side).
  - Already filed: #2115, #1905, #2163, #1864, #2200, #1612, #1544.
- Rebased on origin/main adf30aa63: usage-head-steady 10/10, and the 9
  GUI files changed since b9c589ebb (routing-rules-line, routing-compact,
  routing-pause, routing-pause-folder, routing-time, routing-intent-entry,
  menu-input-scroll, quota-refresh-order, usage-card-refresh) 93/93.
2026-10-14 23:06:25 +08:00
yetone 984917376c gui: a routing rule's fields keep the line's size on a phone's page
At a phone's width (magpie web, 390px) a rule's intent, tokens, folders
and hours were set at 16px while the rest of the line ("意图是", the
model, the →) is 12px, so the intent read a size larger than its own
label. app.css sets every box on a phone's page at 16px, and 538753a7a
set the intent's copy to 16px to match; both are there so a focused box
doesn't zoom. iOS already gets maximum-scale=1 from layout.js
(phone-web.test.cjs checks it), so a rule's fields now inherit the
pill's size; the pills keep their 44px tap height.

Run: routing-rules-line now checks that every field in a rule has its
pill's font size. With the CSS taken out, chromium zh 390 goes red
listing 7 fields at 16px; with it, routing-rules-line,
routing-intent-entry, routing-pause-folder, routing-time,
menu-input-scroll and phone-web pass 62/62 in Chromium and WebKit.
Measured at 390 in both engines: every field 12px.

Not tried: a real iPhone or Android browser.
2026-10-14 23:02:56 +08:00
yetone d0fcb8bcdf agent: an agent uninstalled with its folder left behind shows "CLI not found" with no live settings, Hermes and the shared-folder agents too (#2177, mengyianx; #2173, SkyTodInfi)
Detection goes by an agent's folder, and an uninstall leaves the folder
behind. Before this commit, Hermes with only its 37-byte
~/.hermes/config.yaml (custom_providers: [], mcp_servers: {}) was listed as
installed in `magpie ls`, the GUI and the TUI, with model and effort pickers
that no program reads. CLIMissing (#843) covered only agents that have an
install command and their own folder. Hermes and the agents whose folder
something else keeps too (claude, codex, cline, opencode, goose) were never
gone.

What changes:
- internal/agent/gone.go adds cliHeld, which asks whether anything here still
  reads the folder:
  - the CLI on PATH or in proc.FindTool's folders (for goose, a binary that
    isn't pressly's Go goose);
  - its desktop app (HasApp) or sign;
  - the vendor installer's own place: ~/.claude/local, ~/.opencode/bin,
    ~/.codex/packages/standalone, Hermes' <home>/hermes-agent checkout;
  - for the shared folders, an editor extension under
    ~/.<editor>/extensions (anthropic.claude-code, openai.chatgpt,
    saoudrizwan.claude-dev), Claude.app or Claude Desktop, OpenCode.app or
    Goose.app on a Mac, a JetBrains IDE's settings (its agents bring their
    own program) or Zed's external_agents.
  When magpie can't tell, the agent is never gone. That covers OpenCode and
  Goose off a Mac, Gemini (its folder is Antigravity's and Code Assist's
  too), agents with their own detect, and WSL and plugin agents. It also
  covers Bin agents with no install command, except Hermes (cliOnly), since
  their installers' paths aren't verified.
- GUI: a gone row shows "CLI not found" and none of its settings, and the
  tag's tip says why. It offers no Apply again. While it is still wired it
  keeps its switch and Disconnect. Once it isn't wired it folds under Not
  set up, and Get started doesn't offer it (connectKind is "no"; the sandbox
  run showed Hermes offered there before). The panel shows the words only.
  The new tip is translated into zh, zh-TW, ja and de.
- The TUI leaves the agent out. `magpie ls` says "CLI not found" beside its
  path.
- docs/subsystems/agent-wiring.md describes all of the above.
- aside-native.test.cjs drops cliMissing from an Aside fixture. That state
  can't happen (Aside has no install command and isn't in cliOnly), and
  that test is about runtime_unavailable.

What was run:
- Sandbox HOME holding only the reporter's ~/.hermes/config.yaml (37 bytes)
  and a bare ~/.codex, with env -i and PATH=/usr/bin:/bin:
  - `magpie ls` at base 331c27703 lists "Hermes Agent — · effort —".
  - The fix lists "Hermes Agent  CLI not found  ~/.hermes/config.yaml".
  - Codex stays listed, because this Mac has ChatGPT.app's Codex (HasApp),
    so a really installed agent is kept.
- `magpie web` from the same sandbox, screenshot in Chromium: the Hermes row
  shows "CLI not found" and no pickers. That run found Get started still
  offering Hermes, which this commit fixes.
- go test ./internal/agent (2255s under load ~250 on 14 cores) and
  ./internal/cli and ./internal/tui pass. ./internal/gui fails only
  TestMainWindowCorners/macOS_26_SDK, killed at its 40s deadline under the
  same load. That is #1936; it has nothing from this change in its path, and
  it passed on base once and failed on it twice.
- GUI in Chromium and WebKit:
  - agent-cli-missing.test.cjs covers 5 languages, widths 1100 and 420, and
    the panel.
  - getting-started.test.cjs adds a gone Hermes to the fixture; the chips
    stay codex, claude and opencode.
  - Also run: i18n-keys, aside-native, agent-*, panel-* and click-scroll.
- gofmt -l is clean. go vet passes on darwin, linux (-tags nogui) and
  windows for the touched packages.

Broken by hand, and the tests went red each time:
- Dropping the openai.chatgpt check made TestCLIMissingSharedFolders' codex
  case red.
- Dropping the hermes-agent case made TestCLIMissingHermes red.
- Dropping the GUI gone branch, or the agentUsed change ("the one not
  connected stayed up"), made agent-cli-missing red.
- Dropping connectKind's cliMissing line made getting-started red
  (30 of 60 failed: chips gained hermes).

Not covered:
- library.Targets (Skills/MCP) still lists a gone agent as a place to give
  skills to.
2026-10-14 22:50:46 +08:00
yetone 019199e0f7 usage: Codex threads' model/effort consumption is read again only when a call, price or identity changed (#1591)
e3d3f75fd added model_effort to /api/sessions, /one, /manage and
/overview. Each answer read the whole ledger (LedgerOf(All) for the list),
and the Sessions page asks for the list and the overview every 15s while it
is open, so a long history was worked out again on every refresh.

CodexModelEffort now keeps its last answer per period under the key the
request index already keys its pages on (gateway log version, the agents'
call files, other computers' days, Codex identities, prices, the day).
That key is read by readRequestState, taken out of queryPage unchanged. An
answer from a log read part way is not kept, as cachedVias does. Callers
get their own copy.

Run at this commit on d692b2548 (Go 1.26.8 darwin/arm64, sandbox HOME):
- go test -tags nogui -run Codex ./internal/usage: pass
- TestCodexModelEffortReadsLedgerOnlyWhenCallsChange, broken by hand three
  ways, each red: the key not compared (a changed rollout still read 20,
  not 2000), the cache never hit (ledger read 2 times), the cached slice
  handed out (a caller's write showed in the next answer).
The full suite, vet and builds are in the commit that lands with it.
Not measured against a real 750k-call history.
2026-10-14 22:45:40 +08:00
Hogee 644f4316f9 sessions, usage, gui: separate Codex thread relationships and consumption (#1591)
Preserve native Codex thread IDs and explicit parent chains. Associate gateway
calls with their actual thread by unique response ID before legacy matching;
fold identical native history copies and keep ambiguous actors unknown.

Existing Sessions APIs expose optional Codex roles, parent/root relationships
and per-thread model/effort consumption. The overview uses its existing calendar
range. Usage request APIs expose query-time actor classification and reuse
session/subagent/parent_agent for Codex. Other agents, pricing, gateway routing,
UI assets, raw Usage logs and model-only aggregation retain their semantics.

Verified after rebasing onto main 331c27703a,
at commit 50baace0a52953263dddc49f4dc55f97a8457dd1, code tree
78743e334f8c841e2a188aafe26996c016a8fa4b. Only this message is amended afterward.
Go 1.26.8 darwin/arm64; tests used temporary HOME and pinned Go caches.

Passed (each exit 0):
- git diff --name-only origin/main...HEAD -- '*.go' | xargs gofmt -l (no output)
- go vet ./...
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go vet -tags nogui ./...
- GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go vet ./...
- go build -o /tmp/magpie-codex-session-identity-p4-darwin
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -tags nogui -o /tmp/magpie-codex-session-identity-p4-linux
- GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o /tmp/magpie-codex-session-identity-p4-windows.exe
- go test -tags nogui ./...
- go test -race -tags nogui ./internal/sessions ./internal/usage ./internal/gui -run '^(TestCodexIdentityParentChainsAndSummaryCache|TestCodexIdentityParentMergeAcrossRolloutFiles|TestCodexCallThreadIDPriorityAndCache|TestCodexCompactionPromotesThreadID|TestCodexSourceNativeVariants|TestCodexIdentityFieldsOmitOtherAgents|TestCodexIdentityInvalidatesOldSummaryCache|TestCodexLedgerResponseIdentityAndOwnConsumption|TestCodexRequestPageFoldsCopiesBeforeResponseMatching|TestCodexExactResponsePairPreemptsLegacyMatchInLedgerAndDirect|TestCodexQueryPageExactResponsePairPreemptsLegacyMatch|TestCodexRejectedGatewayDoesNotPairWithNativeCall|TestCodexKnownSubagentWithUnknownRootKeepsOwnConsumption|TestCodexQueryPageRefreshesIdentityAndSharesJSONFields|TestCodexActorSurvivesPackedRequestChunk|TestPackedRequestPageCallerAndRouteIdentity|TestPackedGatewayRetainsOversizedSnapshot|TestCodexSessionAPIAddsOwnModelEffort)$' -count=1
- git diff --check

Behavior-break proof: removing identity/thread-ID promotion fails native identity,
upgrade/conflict and compaction assertions. Disabling exact-pair preemption loses
a neighboring main call. Removing API enrichment yields missing consumption;
using All for a 7-day overview yields 740/74 instead of 40/4. Restored code passed
its targeted tests and the final checks above.

Native checks had Clang enum/linker deployment-target warnings.
Linux/Windows runtime, real accounts/vendors and manual UI were not exercised.
No frontend suite was run because the change does not touch GUI assets.

Refs #1591 (Codex portion only).

Reviewed and applied by yetone (cherry-picked from Hogeexxl's fork, bf8c8c9e).
The one conflict was call_cache.go's version: main had taken calls-v13 for
compaction times (e1dcd1e1d), so this is calls-v14. Run with the follow-up
commit on top, at tree 122b933ba4c474e443f2b29c6d0a4163ae364f78 on origin/main e5cd125f0 (Go 1.26.8
darwin/arm64, sandbox HOME, private GOCACHE):
- gofmt -l on the changed files: none
- go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...
- the darwin, linux (nogui) and windows builds
- go test -tags nogui -timeout 40m ./...: all ok
- go test -race -tags nogui -run 'Codex|Packed|QueryPage|RequestPage'
  ./internal/sessions ./internal/usage ./internal/gui: ok
Broken by hand, each red: codexIdentityRow not setting Subagent (8 usage
tests), setting it for a main thread too (2), Session kept raw instead of
the root (7), thread_spawn's parent_thread_id not read (3 sessions tests),
response pairs not reserved before the old matching (6).
Not tried: a real Codex subagent rollout (none on this machine; every
recent rollout is a vscode main thread whose session_id equals its id),
and the GUI by hand. Claude Code's fields are unchanged.
2026-10-14 22:45:40 +08:00
yetone adf30aa634 gui: a menu opened from beside a long text box stays open
A text box whose text is longer than it goes back to its start as it
loses focus, which fires a scroll event on the box. Every app menu
closes on a scroll outside itself (scrollCloses), so clicking a routing
rule's ⋯ or + right after typing a long folder list opened the menu and
shut it in the same frame: nothing showed. Both engines do it.

scrollCloses now ignores a scroll whose target is an input or textarea:
a box scrolling its own text moves nothing the menu is placed by. It is
the one helper every menu (openRowMenu, openProtoMenu, the agent models
menu, the removed-groups menu) asks, so all of them get it.

Run: new menu-input-scroll.test.cjs (⋯ and + after a folder list longer
than its box; Chromium and WebKit, en and zh): 4/4, 8/8 WebKit reruns.
With the line taken out: 0/4. click-scroll and every *menu* test pass
but removed-groups-menu-scroll, which is red 1-2 of 8 per run on
a4d580fa2 too.
2026-10-14 22:43:43 +08:00
yetone 538753a7a6 gui: a routing group's rule reads as one line, its conditions added from its + menu
The rules editor drew every condition of every rule as an empty box to
fill (tokens, images, effort, agents, intent, compact, folders, hours),
then "send to" and the model, with Move up / Remove as words and two
paragraphs of help below. Three intent rules took ~600px and the intent
itself was cut at 24ch. The owner: "现在这个页面太复杂了,用户要输入、
填写这么多东西,太恐怖了。"

Now each rule is one line, read as a sentence:

  1  asks for <intent…>  +   →  [model]   ⋯

- Only the conditions a rule has are drawn, in the rule's own order;
  each has a × (shown on hover or focus, always on touch) that clears it
  back to "not set". The rule's + opens the app menu (openProtoMenu,
  never a native select) with the conditions it doesn't have yet; a
  pause is offered only the conditions a pause can hold by.
- "→ model" sits in its own grid column (subgrid), so it lines up
  across rules whatever the conditions' widths; under 640px it wraps
  under the conditions.
- The intent is a one-row textarea that grows with its words (a hidden
  copy sizes it), so the whole intent shows and wraps; Enter and pasted
  newlines stay one line, as saved before.
- Folder boxes size to their text (canvas-measured with the box's own
  font, +8px so the caret never scrolls the text inside).
- Sending is the default and goes unsaid; a pause says "pause" before
  its model. The ⋯ menu holds Move up, Move down, Send to / Pause the
  model instead, and Remove rule.
- "Add a rule" starts a rule with the intent box ready. The two
  help paragraphs became an ⓘ beside it, and beside Effort and the
  intent model.
- Saved data is unchanged: an unchanged editor saves the same rules
  field for field (routing-rules-line round-trips the old assets too).

Docs: intent.html and start.html (en, zh, ja) say where Add a rule's
intent box and the ⋯ menu's pause now are. The /img/intent-rules-*.png
screenshots still show the old editor; not regenerated here.

Run:
- New routing-rules-line.test.cjs: every condition drawn in order, none
  empty, + menu (app menu, not select), × removes, ⋯ moves, no overflow
  or sideways scroll; Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and
  390px. Broken by hand, it went red.
- Updated routing-intent-entry, routing-compact, routing-pause,
  routing-pause-folder, routing-time; with routing-folder,
  routing-manual, routing-levels, own-requests, i18n-keys, click-scroll
  and every *menu* test: all pass in both engines but
  removed-groups-menu-scroll, red 1-2 of 8 per run on a4d580fa2's
  assets too.
- The full routing-*/group-*/images-* GUI set (1261 tests, both engines,
  concurrency 6): reds outside the editor (routing-days-fit,
  -agent-gone, -agent-hue-not-red, -burst-speed, -failed-open,
  -keys-fold, -model-rest, -side-calls, -wb-restricted, group-found-off)
  fail the same on a4d580fa2's assets run alone here. Of the editor's
  own reds in that run, two were the tests' clicks (now wheeled to, both
  ways). The third was real: in WebKit routing-pause-folder's ⋯ menu shut
  at once, because the folder box's text had scrolled inside it. The box
  now has room for the caret; the next commit fixes the menu itself.
- go test ./internal/gui: ok.
- Shots: zh 1000px before/after, en 390 WebKit, zh 390 Chromium, dark.

Not tried: the real Wails window, the Windows box, a WebKitGTK without
subgrid (falls back to unaligned columns), the docs images.
2026-10-14 22:43:42 +08:00
yetone 429698f969 gateway: Claude Desktop's sonnet classifier on a Remote magpie's Claude session goes to that magpie's sonnet, not the session's opus (#2187, SuInk)
A Claude Desktop session on another magpie's Claude model
(office/claude/claude-opus-5-5) sent Claude Code's own background
requests for claude-sonnet-5 (auto mode's safety and notification
classifiers) to the session's opus. The remote lists the model as
office/claude/claude-sonnet-5 with the model claude/claude-sonnet-5, so no
entry had "claude-sonnet-5" as its id or model, unserved() said magpie
didn't serve it, and desktopTurn fell back to the session's pick. The
reporter's 9 such calls wrote 480K tokens of 1-hour cache on opus.

desktopTurn now asks servedBeside first for such a request: the entry of
the session's own provider whose model is "<prefix>/<asked>", preferring
the one beside the session's model (same subscription on that magpie).
Only the picked model's provider is looked at, so a same-named model of
another provider doesn't take it, and Desktop's title (and a title Claude
Code asks for on Desktop's behalf) still follows the session. A Claude
model the session's provider doesn't serve still goes to the session's.
unserved() itself is unchanged, so terminal Claude Code's stand-in and
DesktopTiers keep their meaning; Resolve couldn't serve a bare id of a
nested model anyway, which is why the answer is a catalog id here.

Test: TestClaudeDesktopClassifierOnRemoteMagpie (desktop_remote_classifier_test.go):
the gateway serves as the other magpie's model list over httptest, the
local "work" provider is then removed so only the remote serves Claude; the
session turn goes by the alias Desktop was shown (DesktopID), then two
classifier bodies (Claude Code 2.1.295/2.1.296 bytes from #1539), a
Desktop title, and claude-haiku-4-5 the remote doesn't list.

Broken by hand:
- servedBeside skipped (if false &&): FAIL "classifier: the other magpie
  was asked for "work/claude-opus-5-5", want work/claude-sonnet-5".
- applied to titles too (title rule dropped): FAIL "title: sent
  "work/claude-sonnet-5"".
Restored, it passes.

Run at d692b2548: gofmt -l (clean); go vet ./..., GOOS=linux go vet -tags
nogui ./..., GOOS=windows go vet ./... (clean); go test -tags nogui
-timeout 40m ./... under a sandbox HOME with pinned caches: 50 packages ok; internal/gui's
TestProviderListReadsSettingsOnce failed (23s against its 2s bar, load
~260), which is #2185, filed and being fixed apart; internal/agent and
internal/gateway hit the 40m package timeout at load ~260 with a test
that had just started (no hang in the stacks), and rerun alone with
-timeout 100m both pass (1304s, 1355s). go test -run
'TestClaudeTier|Desktop|Remote' ./internal/gateway passes.
Not tried: the reporter's real Claude Desktop against a real remote
magpie with a Claude subscription (no second machine with one here).
2026-10-14 22:36:15 +08:00
yetone 6087c82b02 provider: moved Factory users get opencode-factory-auth 0.1.28, whose Fast Mode models come last, so GPT-5.3-Codex, Grok and GLM are in the first 24 again (plugins #119, psylch)
Plugins 95af6cf moved the six -fast entries after every other model;
0.1.27 had put them beside their bases, pushing five models past the 24 a
provider with no picks exposes. npm view --prefer-online shows 0.1.28 on
registry.npmjs.org.

Run: go test -tags nogui -run 'Moved|Migrat|Mover|Factory|Adopt|HandOver|KeepMoved' ./internal/provider passes; gofmt clean.
Not run: a real moved account updating to 0.1.28.
2026-10-14 22:35:59 +08:00
yetone 0c9e3e391c provider: a Factory -fast model is priced at its base model's price times the vendor's Fast Mode multiple, not standard Opus (plugins #119, psylch)
Factory serves claude-opus-5-5-fast and the other Fast Mode ids, but
replies naming the base model, and no catalog prices the -fast ids, so
usage priced a fast turn at the standard rate. ListPrice now prices a
Factory (built-in or moved to the plugin) -fast id at its base model's
list price times the vendor's own fast multiple: Anthropic's Opus fast
mode 2x, OpenAI priority from models.dev's prices: gpt-5.5 2.5x, gpt-5.4
and gpt-5.3-codex 2x. Every field scales, cache writes and context
tiers too. Other ids (grok-4.7-fast is a model of its own) and other
providers are unchanged. It is an estimate: Factory bills credits.

Not changed: tier_served still comes only from Factory's reply, and a
base model asked with speed fast is still priced at standard, since the
pricer doesn't read the tier.

Run: TestFactoryFastPrice (built-in and moved account, tiers, 1h write,
grok-4.7-fast and a Claude account left unpriced) fails with the
factoryFastPrice call disabled and passes with it. go test -tags nogui
./internal/provider ./internal/usage ./internal/sessions pass. gofmt -l
clean, go vet darwin, linux -tags nogui and windows clean.
Not run: the whole go test ./... (disk under the 10G floor, other
sessions), and no real Factory account was billed.
2026-10-14 22:35:59 +08:00
yetone 0c1e9b79d3 agent: Claude Science runs on magpie's gateway, its daemon restarted with ANTHROPIC_BASE_URL (leesunrise2364)
Claude Science (Anthropic's research app, 0.1.62, "operon") has no
third-party inference setting, but its daemon reads ANTHROPIC_BASE_URL
(http allowed on loopback). It still requires its own Claude sign-in
(no API keys); magpie never bypasses, forges or forwards it.

- agent/claudescience.go: a claude-science agent, found in the Mac
  bundle, %LOCALAPPDATA%\Programs\ClaudeScience or ~/.local/bin.
  Connecting runs `claude-science stop` then
  `serve --detached --no-browser --port <its port>` with
  ANTHROPIC_BASE_URL set to the gateway, in that process only (no
  user-wide env); disconnecting restarts it without the variable. A
  mark in magpie's config notes the pid/port/URL; a daemon started
  elsewhere shows as drift, never stopped behind the user's back.
  KeepClaudeScience (WhileServing) starts it again on the gateway when
  none runs (after a reboot). Setting the same value again is a no-op,
  so Connect's connect+Apply restarts once.
- gateway/science.go: a request with X-Anthropic-Surface: operon is
  Claude Science's. /v1/models lists every model by a
  claude-magpie-<n> alias with a non-slug name (its picker drops other
  ids); a Claude id magpie doesn't serve (its default, its haiku) goes
  to the model last picked, else the first listed. Its sk-ant-oat
  bearer is dropped like any Claude sign-in.
- Notice in 5 languages; agent-wiring and gateway-routing docs; README.

Run:
- go test -tags nogui ./internal/agent -run ClaudeScience and
  ./internal/gateway -run TestClaudeScience: pass; each broken by hand
  (no variable in env, keeper touching a running daemon, no
  scienceTurn, isClaudeScience off) went red.
- Real 0.1.62 binary in a sandbox HOME on macOS (from the dmg, port
  8481): connect restarted it once with ANTHROPIC_BASE_URL (ps -E),
  connect again was a no-op, disconnect restarted it without, the
  keeper in `magpie serve` restarted a stopped daemon with it.
- Sandbox gateway with a mock provider, sent the app's post-sign-in
  headers (a made-up sk-ant-oat bearer, X-Anthropic-Surface: operon,
  oauth beta): /v1/models gave the aliases, model retrieve worked, a
  streamed turn and a haiku request went to the mock's model, the
  upstream saw only the provider key, sk-ant 0 times in its log.
- Windows 11: the real daemon runs in a sandbox profile against a
  sandbox gateway; before sign-in it asks nothing.
- gofmt -l clean; go vet darwin, linux (nogui), windows clean; full
  go test -tags nogui ./... green except six packages that hit the
  10m timeout at load average 250-460 (other sessions); agent,
  gateway, cli, gui, library, provider rerun with -timeout 50m: all
  ok; GUI agent-notice-lang + i18n-keys in
  chromium and webkit at 1100/420, 5 languages: 25/25.
- Rebased onto origin/main 6 commits back (874e4e8ad; 29 upstream
  commits incl. gateway.go, i18n.js): vet darwin/linux(nogui)/windows
  clean; go test -tags nogui agent, gateway, cli, gui: ok; GUI
  notice/i18n 25/25. The Windows sandbox gateway was swapped to that
  build and the app's headers replayed through it: the alias list, a
  tools turn and a haiku request reached mock-sci-1, sk-ant 0 times in
  the upstream log.
- Rebased again onto ce5d9f9d4 (6 commits: affinity, max output,
  OpenCode Gemini, i18n.js): vet on 3 OSes clean; gateway
  -run 'TestClaudeScience|Affinity|UserOutput|MaxOutput|OpenCodeGemini|
  TestClaudeDesktop|Alias', agent -run 'ClaudeScience|TestEveryNotice|
  TestAgentConnect|TestRewire', gui notice/i18n Go tests: ok; GUI
  notice/i18n 25/25.

Not tried: a real Claude sign-in (left to the owner) and so any turn
the app itself sends; whether the Mac/Windows window attaches to the
daemon magpie started rather than starting its own (drift is shown
and fixed by picking magpie again); Linux.
2026-10-14 22:24:11 +08:00
yetone ce5d9f9d4e provider, gui: a held vendor read is "not refreshed this time" too, and a card refresh answered under another account still shows (#1630 review)
Review of hhh2210's f1c1be3c (applied as the commit before this one,
unchanged, onto origin/main).

- keepLast marked a reading deferred only when the error equalled one of
  the three "not read yet" sentinels. With allowances read only when asked,
  most vendors' reads are stopped by holdUnasked inside the HTTP client, so
  the error arrives wrapped ("Get \"https://…\": not read yet: …") and the
  card still said "couldn't be read just now". readDeferred now matches the
  sentinels inside the error; TestQuotaDeferredReadIsNotFailure has a
  "held request" case for it.
- quotaRefresh applied only the card whose key matched the refreshed one.
  A card first read without its account (no user) comes back under the
  account's name, and its reply was dropped until the next whole-page read.
  When the requested key isn't in the reply, the reply's list is taken as
  before f1c1be3c. quota-refresh-order.test.cjs covers it.

Broken by hand:
- the patch's exact-equality check back: "held request" fails with
  readDeferred = false, and the report check fails;
- ReadDeferred always false: saved / not asked / manual only / held
  request fail;
- ReadDeferred dropped from quotaReport: "CLI/gateway report lost
  readDeferred";
- fallback removed: "the refreshed card's reply was dropped";
- keepRefreshedQuotas call removed: both "older whole-page reply
  overwrote the refreshed card" cases fail;
- asOfText's deferred wording removed: usage-card-refresh fails "a request
  not made was described as failed" (chromium en/zh).

Run (worktree on origin/main, sandbox HOME, private GOCACHE):
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... clean; go build, GOOS=linux -tags nogui and
  GOOS=windows builds ok.
- go test -tags nogui ./...: every package ok except internal/provider
  TestCopilotSecretToolUsername ("token """, the 5s secret-tool bound
  under load ~270, open as #1627); it passes alone -count=3. Nothing on
  that path changed here.
- GUI, chromium and webkit: quota-refresh-order, usage-card-refresh (all five
  languages), claude-usage-asked, quota-read-at, quota-reads,
  quota-reading-again, usage-refresh, usage-refresh-flight,
  usage-stale-answer, panel-usage, tray-usages, tray-usage-redraw,
  usage-remote-cards, usage-quota-head, quota-balance-error, quota-holds,
  usage-accounts, i18n-keys, gui-de, gui-ja, gui-zh-tw: all pass in both
  engines. The whole GUI suite was not run.

Not tried: the native app with a real saved Claude account; the response
ordering is injected in tests.
2026-10-14 21:54:12 +08:00
hhh2210 86cc7ac56d usage, gui: keep refreshed cards and distinguish deferred readings (#1630)
A card refresh and a whole-page quota read could replace each other's
entire snapshots. An older GET arriving after a successful refresh put
the old number back on screen; two card refreshes could undo each other.
Apply each POST's requested card alone and retain completed card readings
against whole-page requests that began before them. Later reads can still
update or remove cards. Failed refreshes do not block background results.

A saved Claude account not asked for, or allowances held by When I ask,
could also show "couldn't be read just now" without making a request.
Carry readDeferred through the cached card and CLI/gateway report, and
give that state a separate translated notice. Keep original read times,
network-failure notices and authentication errors. Automatic saved-account
reads and the existing 30-second floor are unchanged.

Verification (macOS arm64, Go 1.27.2, Bun 1.4.3; isolated homes/API fixtures):
- On base 2c5db1c6, quota-refresh-order.test.cjs fails three cases:
  old whole-page replies restore 0 over 32; crossed card replies restore
  0 over the other card's 61. With the fix, 4/4 pass.
- TestQuotaDeferredReadIsNotFailure fails the three deliberate-skip cases
  on the base, passes here; checks real read failures and auth refusals too.
- Original assets fail the new browser case with "a request not made was
  described as failed". Related frontend checks pass 71/71, including the
  real card button in Chromium and WebKit across en/zh/zh-TW/ja/de. The
  extra locale/i18n checks pass 12/12. The full GUI suite was not run.
- Provider tests for deferred/kept/saved readings pass -race -count=20.
- gofmt and git diff --check clean. Full vet on darwin, linux nogui and
  windows; darwin build, linux nogui build and windows build pass.
- go test -tags nogui ./... completed: every tested package passed except
  internal/plugin's TestPluginSOCKSProxy. HTTPS through a dead SOCKS proxy
  produces "proxyconnect tcp: 502 Bad Gateway: socks connect ... refused",
  while the test expects an HTTP 502 response. Reproduced unchanged on
  freshly fetched upstream 68552188 in an independent worktree; already
  reported in #1630. The full suite is not green; no proxy change here.

Not tried: the patched native app with a real Claude account. The response
ordering is injected in tests, not captured from the reported incident;
this does not establish that every intermittent refresh failure is fixed.
2026-10-14 21:54:12 +08:00
yetone 2c18c697c2 provider: moved WorkBuddy users get plugin 0.1.22, so an MCP server's tools reach Kimi, not 400 11133 (magpie-community/plugins#122, clearmann)
The mover's min, so keepMovedCurrent updates every moved user's plugin.
workbuddy 0.1.22 (plugins a6bed5e): Kimi (kimi-k3-1, kimi-k2.7) and
DeepSeek turn away tool schemas MCP servers commonly send (an enum with
no type or of several types, an empty enum, true/false where a schema
goes, a required that isn't a list, an unknown type) with 400 11133 /
11129. It is the request's content, not the account. The plugin now
gives each the shape these models take, meaning the same. Tried on the
owner's real account: each refused shape 400 before, 200 after.

On npm: npm view @magpie-community/opencode-workbuddy-auth version is
0.1.22 (tarball holds fitShape).

Run: gofmt -l, go vet ./internal/provider for darwin, GOOS=linux -tags
nogui and GOOS=windows, go test ./internal/provider (ok, 439s). Not
tried: a moved user's update in a running magpie.
2026-10-14 21:47:24 +08:00
yetone e5cd125f06 provider: OpenCode Go's and Zen's Gemini models are asked on Gemini's generateContent, not chat (#2168, @bugyaluwang on X)
OpenCode Go's gemini-4-argon-contributor went to
/zen/go/v1/chat/completions, then Responses and Messages, and Go turns
each away with "Model does not support this protocol". OpenCode serves
each model on the API of the AI SDK package models.dev names in its
per-model provider.npm. catalog.APIOf knew @ai-sdk/openai (Responses)
and @ai-sdk/anthropic (Messages) but not @ai-sdk/google, and an OpenCode
provider had no Gemini URL. So a Gemini model had no API it is served
on. Zen's nine Gemini models (gemini-3-flash, 3.1-pro, 4-argon, ...)
failed the same way: the sibling.

- catalog.APIOf: @ai-sdk/google is "gemini".
- openCodeEndpoints fills in the Gemini base:
  - Zen's /zen/v1. OpenCode's proxy relays models/X:streamGenerateContent
    there to Google's route and reads the key from x-goog-api-key.
  - Go's /inference/go/v1. /zen/go/v1 has no Gemini route (404).
  openCodeRoot also takes /inference and /inference/go URLs.
- The gateway's existing Gemini translator does the rest:
  - models/<id>:streamGenerateContent?alt=sse, the key in x-goog-api-key;
  - OpenCode's x-opencode-session and its variants, as for every API;
  - the client is answered in its own API;
  - reasoning effort low/medium/high becomes thinkingConfig.thinkingLevel.
- Provider.NamedOnlyOn(Gemini) for OpenCode: a model the list names no
  API for (GLM, Kimi...) is never tried on Gemini's, in usable() and in
  the Test probe's model choice. Without it, a model turned away on all
  three falls through to Gemini's and answers with a bare 404.
- The model list isn't fetched at OpenCode's Gemini base: its models
  come from the chat list.
- Existing saved providers get the URL through normalize, as #1215's
  did. The GUI's per-model API picker already offers Gemini once
  p.gemini is set.

Run:
- New TestOpenCodeGoGeminiModelOnGeminiAPI. The fake answers with Zen's
  real SSE bytes. It checks:
  - the URL, x-goog-api-key, no Authorization, and a stable
    x-opencode-session across two turns;
  - chat, chat stream, messages, responses and a Gemini client are each
    answered;
  - thinkingLevel for low, medium and high.
- New TestOpenCodeZenGeminiAndOtherModelsUnchanged: Zen's gemini-3-flash
  goes on /zen/v1/models/...; GLM on Zen and Go stays on chat with
  Bearer; a model with no API named and turned away everywhere is never
  sent to Gemini's.
- TestOpenCodeEndpointsFilledIn now has a gemini column and /inference
  cases.
- Broken by hand, each went red:
  - APIOf's google case: the reporter's error, Go and Zen;
  - the Gemini URL fill;
  - NamedOnlyOn in usable (kimi-k3 sent to Gemini's API).
- gofmt -l; go vet on darwin, linux (nogui) and windows for catalog,
  provider and gateway.
- go test -tags nogui ./internal/catalog ./internal/provider
  ./internal/gateway ./internal/agent: all ok (gateway 1260s, agent
  1170s on a loaded machine).
- Real use, the owner's OpenCode key through the gateway in a sandbox
  HOME (in-process, fresh(t), real network, the live models.dev catalog):
  - Zen gemini-3-flash before the fix: 400 "OpenCode Zen: Model does not
    support this protocol" on chat and messages.
  - Zen gemini-3-flash after:
    - chat: 200 "Hi" (reasoning_effort low);
    - chat stream: 200 "Hi.", [DONE];
    - messages: 200 "Hi.".
  - Go gemini-4-argon-contributor at /inference/go/v1: 400 "This Go model
    trains on request data. Allow paid endpoints that train on request
    data in your workspace's Privacy settings to use it." Not consented
    to, as the issue asks.

Not run:
- A successful Go Gemini answer. The owner's workspace hasn't given that
  consent and has no active Go subscription (glm-5.3 on chat: 403). With
  the fix broken, Go gives this account the same consent 400 on chat,
  so Go's before/after rests on the reporter's error and the fakes.
- The full go test ./...
- The GUI.
2026-10-14 21:23:15 +08:00
yetone b9c589ebb1 gateway: the user's own Max output lowers a plain provider's max_tokens, not only a group's (YaCo on Discord)
Claude Code asks claude-opus-5-5 for max_tokens 128000. A relay that
holds back max_tokens x price from a key's quota answered 403 "token
quota is not enough ... need $2.59" for every turn (128000 x $20/M plus
~8K input x $4/M). Setting the provider's Max output didn't help: the
gateway lowered max_tokens with withMaxOutput only inside a group
(outputLimit), so a request routed straight to a provider went out as
the agent asked.

userOutput finds the Max output the user set for the provider's model
(provider > model or the provider's "*", Entry.OutputSet) and lowers a
larger request to it on any route. Only the user's own value does this
outside a group: a vendor's catalog figure may be stale. Group routing
is unchanged.

Run:
- TestUserMaxOutputLowersAPlainProvidersRequest (new): 128000 -> 32000
  with Max output 32k on the model, 8000 kept, a sibling model with no
  Max output kept at 128000. Red without the gateway.go change ("went
  as 128000").
- go test ./internal/gateway -count=1 (whole package, -timeout 45m):
  ok, 1200s, before rebasing onto 4e9335c96; after the rebase the
  Output/MaxTokens tests again: ok.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: clean.
- A real Claude Code 2.1.29x against a fake server with the reporter's
  env: it sends max_tokens 128000 for claude-opus-5-5 with or without
  magpie. Not tried against the reporter's relay.
2026-10-14 21:11:42 +08:00
yetone 7f968b95dd gateway: auto affinity keeps a conversation on the cache its last reply wrote, not only one it read (vilicvane on Discord)
Affinity's auto mode kept a conversation on its last answerer across turns
only while that reply had read at least cacheWorth (1024) tokens from the
vendor's cache. A first turn reads nothing and writes the whole prompt
(Anthropic's cache_creation_input_tokens), so the second turn was moved as
"no-cache" and the cache just built was thrown away (vilicvane on Discord,
「会话保持 → 自动」: 「新的 cache 都建好了,再切走不可惜吗?」).

answered() is now given the usage's CacheWrite beside CacheRead (both
already parsed at that call site for every route: Anthropic, Chat's
cache_write_tokens / cache_creation_input_tokens, Cursor, Command Code,
plugins), and affine counts read + written against cacheWorth. The stick
keeps cacheWrite in memory and in affinity.json (`cacheWrite`, omitempty);
a file from before has no such field and reads as 0, so an old stick is
judged by its read alone, as before. The trace's Affinity carries
CacheWrite, and the Routing page's "cache" and "no-cache" explanations say
what was read and what was written (en, zh, zh-TW, ja, de).

Not covered: a vendor that caches without reporting a write (OpenAI's
automatic prefix cache, Gemini) still reports CacheWrite 0 on a first turn,
so its second turn may still move. Noted in gateway-routing.md.

Docs: docs/subsystems/gateway-routing.md (affinity bullet), docs/reference.md
(step 6 of how magpie picks an account).

Run:
- TestAffinityKeepsACacheJustWritten (new): an Anthropic Messages upstream
  streaming cache_creation_input_tokens 3000 / read 0; the second turn is
  kept as "cache", also across a restart (affinity.json reloaded); 600+600
  is kept, 300+300 moves as "no-cache". Broken by hand twice and watched
  red: the old `st.cacheRead < cacheWorth` (written: why no-cache), and
  stickOf not reading CacheWrite from the file (restarted: no-cache).
- routing-affinity-cache-write.test.cjs (new): chromium and webkit, 1100
  and 420 wide, en/zh/zh-TW/ja/de, 20/20 pass; red on the old routing.js
  and i18n.js. i18n-keys.test.cjs and routing-account-identity.test.cjs
  pass.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows for
  internal/gateway.
- go test ./internal/gateway/...: all pass except
  TestAgentGoneInTheRetryPause/group_replan, which failed in two full runs
  at load average 150-380 and passes alone (-count=3); its fixed 100ms
  sleep before cancelling assumes the pause has begun. Filed as #2175; it
  never reaches the affinity path this changes (a first request).
- go test -timeout 40m ./... at load ~300-377: 50 packages ok; agent and
  gateway hit the 40m package timeout (no test failed before it); gui's
  TestSetAnswersWhileDevinAndProvidersHang (#1375) and
  TestMainWindowCorners (#1936) failed, both filed load reds.
  internal/agent rerun alone: ok (1008s at load ~200).
- Not tried against a real Anthropic account.
2026-10-14 21:05:26 +08:00
yetone 4e9335c96c plugin: Windows on ARM downloads Bun's native windows-aarch64 build and runs plugins, not "Bun has no build for windows/arm64" (#2183, EdwinDigital)
bunTargetFor turned windows/arm64 away, so magpie-windows-arm64.exe
listed a plugin as on while its host never started, and its providers
never showed. Bun publishes bun-windows-aarch64.zip (1.4.2 and later),
so windows/arm64 now maps to it, with no baseline suffix (arm64 has no
baseline build). Its SHA-256 a7a16b87…0cfd is added to bunSums, taken
from Bun 1.4.2's SHASUMS256.txt, so the download is still checked and
can come through a mirror. The provider-plugins page says so.

What was run (macOS arm64, sandbox HOME, private GOCACHE):
- TestWindowsOnArmGetsNativeBun (new): with windows/arm64 stubbed,
  Bun() downloads bun-windows-aarch64.zip from an httptest release and
  runs it; the checksum is the official one. Old bun.go: FAIL
  "bunTarget = "", Bun has no build for windows/arm64".
- TestBunTargetForMusl gains windows/arm64 and now checks every
  target has a checksum; TestBunDefaultSums and TestBunTarget list
  bun-windows-aarch64. Both FAIL on the old code.
- go test ./internal/plugin/ ok; gofmt -l clean; go vet darwin,
  GOOS=linux -tags nogui, GOOS=windows clean;
  GOOS=windows GOARCH=arm64 go build ok.
- Downloaded the real bun-v1.4.2/bun-windows-aarch64.zip: SHA-256
  matches, it holds bun-windows-aarch64/bun.exe, a PE32+ Aarch64 binary.
Not tried: a real Windows ARM64 machine (the Windows box is x64), so
the plugin host starting on that bun is not verified.
2026-10-14 20:56:18 +08:00
yetone 35230ba1fb gui: a plugin sign-in with no page to open waits with its proxy link, not "[object HTMLButtonElement]" (#2181, guanwenpeng2001-bot)
A plugin whose authorize gives url "" (it drives a desktop app and the
host waits on its callback) reaches the sign-in box's "waiting" branch,
which wrapped signInProxyLink's button in el("span", "acts", button).
el() wrote its third argument into textContent, so the box showed the
string "[object HTMLButtonElement]" and no proxy link. el() now puts a
Node inside the element as it is and keeps textContent for everything
else, so this caller and any other that hands it a node are fixed at
the one helper; that was the only static call passing one
(grep of el(..., <call>) across internal/gui/assets).

What was run (macOS, playwright 1.62.0):
- new internal/gui/tests/plugin-signin-no-url.test.cjs, en/zh/zh-TW/
  ja/de at 1100 and 420: chromium 11/11, webkit 11/11 pass. With el()
  put back it fails 11/11 in webkit and chromium with
  "a node written out as text".
- plugin-signin, signin-proxy, signin-link, plugin-moved-signin,
  signin-callback, signin-paste-plugin, add-sheet in both engines:
  67 pass, 0 fail.
- go vet (darwin, linux nogui, windows) clean.
Not run: the whole GUI suite (machine load ~200); el()'s output for a
non-Node argument is unchanged. Not tried with the reporter's own plugin.
At 420px in WebKit the method button sits under the sheet's footer
after Playwright scrolls it, so the test presses it with Enter.
2026-10-14 20:56:18 +08:00
yetone d1c485f7e9 agent: a model at max without xhigh tells Claude Code it has xhigh, so Ultracode shows on GLM, DeepSeek and Kimi in Claude Desktop
leesunrise2364 on Discord: Claude Desktop on magpie has no Ultracode effort,
which cc-switch had, and Ultracode is what turns on dynamic workflows.

Desktop 2.7032.0 shows Ultracode only when the model's effort options
include xhigh and Claude Code takes it. magpie lists a model with known
levels to Desktop as mythos-magpie-<n>, whose options include xhigh, and
tells Claude Code what each model can do in CLAUDE_CODE_MODEL_CAPABILITIES.
That value said only the levels magpie knows the model has. GLM-5.3
(low/high/max), DeepSeek V4 (high/max), Kimi K3 and the like reach max
without xhigh, so they were written as "effort,max_effort", and Claude Code
refuses Ultracode there: "Ultracode isn't available on <model>". cc-switch
names its models as real Claude ids, which Claude Code already knows have
xhigh.

A model Claude Code doesn't know whose levels reach max now also gets
xhigh_effort. The gateway already runs xhigh at max for such a model
(fitEffort: a tie goes up), so no level the model doesn't take is sent.
Claude models Claude Code knows are unchanged: Opus and Sonnet 4.6 still
get no xhigh, as Claude Code's own table has it. Models that top out at
high, or have no known levels, are unchanged too.

Tests: TestClaudeModelCapabilities gets v/glm (low/high/max) and v/top
(high/max), both now "effort,xhigh_effort,max_effort", while
v/claude-opus-4-6 stays "effort,max_effort". TestClaudeCapabilitiesSync's
w/b (low/max) now has xhigh_effort. TestFitEffort covers xhigh to
[high,max] going out as max. With the change turned off by hand, both
agent tests go red on exactly those values.

Run:
- Real Claude Code 2.1.299 in a sandbox HOME, gateway mode
  (CLAUDE_CODE_USE_GATEWAY=1), `-p '/effort ultracode'`, with the value
  magpie's own code wrote for v/glm-5.3 at low/high/max
  ("v/glm-5.3=effort,xhigh_effort,max_effort") printed "Ultracode on (this
  session only): dynamic workflows on every task". The old value
  "effort,max_effort" printed "Ultracode isn't available on v/glm-5.3".
  The same pair was run for Desktop's id mythos-magpie-7, with the same
  two results.
- gofmt -l is clean. go vet passes for darwin, GOOS=linux -tags nogui and
  GOOS=windows.
- go test ./internal/agent passes when run alone (1110s at load ~250),
  and so do the caps and fitEffort tests.
- The full go test ./... ran twice at load average ~300.
  - The first run hit internal/provider's 10m timeout (#2051).
  - The second run (-timeout 30m) had these reds:
    - internal/agent and internal/gateway passed 30m as whole packages;
    - TestAgentGoneInTheRetryPause/last_one_left (#2175's sibling);
    - TestMainWindowCorners was killed at its deadline (#1936).
  - None of these is in code this commit touches.

Not tried: a live Claude Desktop. The packaged app won't start on a
sandbox user-data dir, and the live Desktop config is not to be touched.
So Desktop's effort menu showing Ultracode was not seen. It rests on
Desktop's renderer code (the Ultracode gate needs xhigh among the options
and the claude_code_workflows capability) and on the Claude Code probe
above.
2026-10-14 20:51:01 +08:00
yetone 22512cde53 provider, gateway: rest-cap off never rests a provider's keys after an unknown failure (Kismet Alan on Discord)
A relay or account pool fails now and then with errors that say nothing
of why (a 5xx, a dropped connection), and the next request often goes
through. Every such failure rested the key or account a minute, doubling
up to 10, and `rest-cap` could only move that cap (1 minute at least;
`off` read as `default`).

`magpie provider rest-cap <id> off` (provider.RestCapOff, restCap: -1 in
providers.json) now has a failure that says nothing of why (failOther)
rest nobody and not count toward the backoff: restAfterMarked returns a
Rest by "off" with no time left. What says why still rests as before: a
401 or 403, a model not served (restID), an account's window full, a
rate limit (magpie's own 30-minute cap; RestCapOr treats off as unset),
quota, credit, a restriction. `rest-cap <id> 30s` is turned away and names
1m and off (the first rest is a minute already). The Routing page tells a
try rested by "off" as not resting (one new string, zh/zh-TW/ja/de).
No "fail N times before switching" counter: a failed try already moves
the same request on to the next key or member, so a count would only
keep requests on a failing upstream longer.

Run:
- TestRestCapOff (gateway), TestRestCapCmd (cli), TestOwnRestCap: pass;
  each goes red with the change taken out by hand (the early return
  disabled: "#1 500: rests 59.99s by backoff"; restMinutes in place of
  restCapMinutes: "off: <nil> 0").
- routing-rest-off.test.cjs: 20/20 (chromium, webkit; 1100, 420; en zh
  zh-TW ja de); red 10/10 with the "off" case renamed.
  routing-wb-restricted 20/20. rest-try-now and routing-model-rest fail
  a varying few under load average 200-420 here, and fail more on
  origin/main 331c27703 run at the same time; neither reads "off".
- gofmt -l clean; go vet darwin (provider, gateway, cli, gui), GOOS=linux
  -tags nogui and GOOS=windows (provider, gateway, cli).
- go test ./... with pipefail, sandbox HOME: every package ok except
  agent, gateway and library, which hit the 10m timeout under load
  average ~200 (no test hung: each stack shows a different test seconds
  in). Rerun with a longer -timeout: library ok (603s), gateway ok
  (1572s) and agent ok (1457s).
Not tried: a real relay; the change is in the rest bookkeeping only.
2026-10-14 20:49:20 +08:00
yetone d692b25481 tests: routing-burst-speed scrolls to a row with a wheel over a point in sight, not hover()
The row pick was red on a loaded machine ("picking the request moved the
page", zh in Chromium, 2 of 4 on origin/main 331c27703 at load ~250).
hover() on .rt-reqs scrolled the list's bottom into view by script; the
day's click still held the view at its top and put that scroll back, and
only a wheel made within 50 ms of the put-back gives it back (givesBack).
When the wheel came ~150 ms later the view stayed 18px short, and the
click then scrolled the row into view itself. Traced with a scroll-write
probe: the put-back at hold(), and givesBack's SET18 only on the green
runs.

The test now wheels over the part of the list in sight while the row is
below the list's end, and over the view's head while the list ends below
the window, so every scroll is the reader's.

Run: routing-burst-speed, both engines, en and zh, 3 of 3 green at load
~300. Broken by hand (hold() returning at once, and a pick scrolling the
view 30px) it goes red in en and zh; with only the pick's scroll it stays
green, as the hold puts that back.
2026-10-14 20:41:06 +08:00
yetone 6855218884 gateway tests: TestCanceledRequestRestsNobody cancels once a is asked, not 50ms after the request began (#2175)
The sibling of #2175 (fixed for TestAgentGoneInTheRetryPause in
b8070cc6c): this test canceled 50ms after the request began and let a
answer 50ms later, assuming a was being asked by then. On a busy
machine the cancel could land before a was asked, or a's 200 race the
cancel, and the test no longer covers an agent leaving mid-request.
The scripted fake now closes `hanging` as its first request starts to
wait; the test cancels then, and a answers only once the gateway is
done with the request (or after 10s, so nothing outlives the test).

Run (rebased on origin/main 5ccc05afe):
- broken by hand: a 150ms delay before ServeHTTP (the request reaching
  a late) still passes with the new wait. Before the rebase, with my
  own version of the TestAgentGoneInTheRetryPause wait: a 300ms delay
  in its fake upstream turned the old test red with the issue's shape
  (Millis 110/131, Again 0, Fail:canceled).
- go test -race -run 'TestCanceledRequestRestsNobody$|TestAgentGoneInTheRetryPause$'
  -count=20: ok (360s, before rebase); -count=5 after rebase: ok
- go test ./internal/gateway/ -count=1: ok (1419s, load average ~395,
  before rebase; the rebase changed only agent_gone_pause_test.go,
  taken as origin/main has it)
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: clean

Looked at and left alone: the 100-200ms sleeps before cancel in the
claude_subscription rewind/takeback/park tests and in
TestVertexMintWaitCancelled come after the state they need is already
seen (the fake holds its reply forever), so a late cancel changes
nothing.
2026-10-14 20:33:22 +08:00
yetone 5ccc05afe7 gateway: a plugin's non-streaming Responses request is relayed streamed and given back whole, so Grok's x_search runs (plugins#112, Watchyourback)
Plugin accounts only stream (Account.Stream), so a stream:false request
was translated: parsed to the IR and rebuilt. The Responses parser keeps
only function and web_search tools, so x_search never reached the Grok
plugin, and Grok answered "let me look that up" without searching. The
rendered reply also hardcoded "tools": [], dropped
usage.server_side_tool_usage_details, and dropped web_search's open_page
item. Watchyourback's capture of the plugin's fetch showed this (no tools
field, input wrapped into message[], store:false); CodeAlex52's code read
agreed.

Now a plugin's request on Responses that asked for one body is relayed
like a streamed one (gathers, used by serve's relay decision and by
passthrough):
- It is asked with stream:true, and the stream goes through the relay's
  usual tidies.
- The client gets the `response` of the stream's response.completed (or
  response.incomplete) as one application/json body. Its output is
  filled from response.output_item.done items, or else the streamed
  text, when that event's output is empty (gathered.go).
- A non-200 goes back as before.
- A whole reply goes back as it came.
- A stream that fails, or ends without its last event, is a 502, as a
  translated one is, never an empty 200.
- Usage is counted from the stream, as for a streamed relay.

Left as it was:
- Messages: its stream has no event holding the whole reply, so
  gathering it means assembling the message from deltas. That is not a
  simple sibling.
- Subscriptions magpie signs in to itself (ChatGPT backend, Qoder,
  MiMo...): their own code fits their requests, and their fakes end in a
  response.completed with no output. A first version that covered every
  stream-only account broke 7 Codex/ChatGPT-API tests, so it was
  narrowed to plugins.

TestGrokPluginGetsNamespacedTools now expects the namespace's freeform
custom tool to be left out (grokBody), as the built-in and the streamed
plugin already did. The translation had offered it as a function.

Tests (fake grok plugin through the plugin host):
- TestGrokPluginNonStreamKeepsHostedTools: upstream SSE with a
  custom_tool_call, tools [x_search] and server_side_tool_usage_details.
  Asserts the plugin was asked stream:true with tools [x_search]; the
  client gets application/json with the custom_tool_call, message,
  tools and details; usage is recorded at 50/7.
- TestGrokPluginNonStreamEndedShort: no response.completed gives 502.
- TestGatheredTextOnlyStream: deltas only.
Each was broken by hand and went red:
- the relay condition reverted: "the plugin was offered null";
- the missing-completed check removed: 200;
- the text fallback removed.

Run: gofmt -l; go vet ./internal/gateway on darwin, GOOS=linux -tags
nogui and GOOS=windows; go test ./internal/gateway -count=1 (ok, 1400s,
load ~200).
Not tried: a real Grok account or the real grok plugin; the reporter's
allowed_x_handles case.
2026-10-14 20:25:21 +08:00
yetone f3ea4bd69e gui: an agent's model picker lists magpie's models before the ones it asks for itself (abledo on Discord)
abledo: "为什么claudecode的magpie模型选不了?其他的agent可以选". Claude Code
pointed at a relay through its own ANTHROPIC_BASE_URL showed that relay's
Claude models first ("Claude Code · <host>", a dozen-plus rows), and with
the current model lifted to the top every magpie model sat below the fold.
The server always sent them; only the order hid them.

openPicker now orders: the picker's own choices (Automatic, Off), routing
groups, each provider's models, then the agent's own direct rows. This
covers every agent with direct rows (Claude Code, Codex, dsh), not only
Claude Code. The current model is still lifted to the top.

Run:
- new claude-picker-magpie-first.test.cjs: chromium + webkit, widths 1100
  and 420, en/zh/zh-TW/ja/de, wired false and true: 22/22. Fails on the
  old app.js (own group before Zhipu).
- claude-picker-fold.test.cjs updated for the new order (own group and
  its fold row last): 22/22.
- the 67 GUI tests that touch direct rows or #pop, with the change: green
  except claude-picker-fold before its update. searcher-pick chromium zh
  failed twice under load at its scrollIntoViewIfNeeded after reload
  (#1745); it passes alone 2/2 and in the later batch.
- go test -tags nogui ./internal/gui: ok.
Not tried: the real desktop app with a real relay-configured Claude Code.
2026-10-14 20:21:25 +08:00
yetone 07e95265af gui: a picker on a phone keeps to the room it was placed in, never off the window's top
On magpie web at phone width the pop may grow to the window's height
(body.web .pop { max-height: calc(100% - 16px) }), more than the 420 the
model picker is placed by. Opened upward from a row low in the page, its
top went above the window (y = -241 at 420x760 in zh): the filter and the
first rows were out of reach. placePop now holds the pop to the room it
chose, above the button or below it (holdPop), and the list scrolls.
Found while testing abledo's Claude Code picker at 420.

Run:
- pop-phone-room.test.cjs (new): chromium + webkit, 1100 and 420,
  en/zh/zh-TW/ja/de, 22/22. On main's app.js all five languages at 420
  fail with the pop at y -223/-241. Run 4 at once in webkit, 4/4 green.
- The 45 GUI tests that open #pop, both engines: green but
  claude-picker-magpie-first (the next commit's, red until it) and
  searcher-pick, which failed chromium zh twice at line 304
  (scrollIntoViewIfNeeded after page.reload: element not attached),
  passed 2 of 2 alone with this change and 1 of 1 on main's app.js; no
  pop is open at that step.
Not tried: a real phone; the desktop app (its picker's max-height already
equals the h it is placed by, so nothing changes there).
2026-10-14 20:21:24 +08:00
yetone 2c2155c452 gateway: Claude Code through magpie on any model lets a relay be tested as Claude Code
neiko on Discord: Claude Code connected to magpie, and "Test as Claude
Code" stayed grey. The test asks with the headers Claude Code last sent
(client-shapes.json), and those were noted only where they were passed
on: a request forwarded on Anthropic Messages to a keyed provider. A
Claude Code on a subscription, a Chat provider's model or any translated
one never got there, so the test kept saying no Claude Code request had
come. They are now noted as the request arrives on /v1/messages, after
the caller guard, whatever serves it; the forward still passes them on
only to a keyed provider on Messages, as before.

Run:
- TestClaudeCodeSeenOnAnyRoute (new): Claude Code on a Chat-only
  provider, then a relay's model tested as Claude Code with its headers.
  Fails on main ("no Claude Code request has come through magpie yet").
- TestModelTestAsClient still green.
- gofmt; go vet darwin, GOOS=linux -tags nogui, GOOS=windows for
  internal/gateway and internal/provider.
- go test -tags nogui ./internal/gateway ./internal/provider (-timeout
  60m; the machine was at load ~300): gateway ok; provider red only on
  TestCopilotSecretToolUsername's 10s bound under load (#1627), green
  3 of 3 alone. The full ./... ran twice and timed out package by
  package at load ~270-300 (10m default, then build failures in the
  second), so it is not a pass.
Not tried: a real Claude Code against a real Claude Code-only relay.
2026-10-14 20:21:12 +08:00
yetone 2c5db1c6ea gui: a template picked from Routing's Templates menu opens filled in, in the editor and in view
Owner, 10-14: picking a template from the menu added a group somewhere
below the fold, with nothing to show what happened. Now a pick opens the
new-group editor with the template in it (as the cards' Edit first does),
scrolls the editor's top into view and focuses its name. Nothing is saved
until the user saves. The cards' Add still adds in a click, since the
group then shows in place of the cards.

- openRowMenu passes its click to run(e), so an item can scroll through
  scrollOnPurpose; every run is an arrow function, the others ignore it.
- block "start" with scroll-margin-top 12px, not "center": the editor
  is taller than the window, and centred it opened halfway down the form
  (ja/de/zh-TW failed the new test that way).

Run: group-template.test.cjs + click-scroll.test.cjs, chromium and
webkit, en/zh/zh-TW/ja/de at 420px: 52/52. The new test (12 groups of
the user's, so the editor opens below the window) goes red with the
scroll removed by hand. Load average was ~300 during the runs.
2026-10-14 20:18:40 +08:00
yetone e1dcd1e1d7 tune: a compaction window advised never makes you wait longer on compactions, and says the wait (HirotaNagai on X)
Tuned for you advised the compaction window by tokens alone, so a smaller
window that compacts far more often could be advised however long each
compaction keeps the user waiting.

What changed
- sessions: a call now carries how long a compaction took (Call.Compact).
  Claude Code's compact_boundary line gives compactMetadata.durationMs,
  which goes on the first call after it that isn't an error. Codex compacts
  by a call of its own (the token_usage_record a compacted line names), and
  that call's own time is the compaction's. Older rollouts with no such
  record stay untimed. callCacheVersion is now calls-v13.
- tune: with 3 or more compactions timed for a model (minTimed), Facts.took
  is their median in seconds, and each window's Point.wait is its
  compactions x took. When compactions are timed, the advice never takes a
  window that compacts more often than the current one. Of the windows that
  don't, it takes the cheapest, and of those within 3% of that (sameCost)
  the one that compacts least. Tokens and seconds share no unit the files
  measure, so magpie doesn't trade one for the other at a guessed rate. The
  token-cheapest window is reported (cheapest, wait_cheapest) so the user
  can pick it. A model with fewer than 3 timed compactions is advised as
  before, with no wait shown.
- GUI (Usage > Context): when timed, the advice is labelled
  "Tokens + wait". The explanation says what a compaction took, the wait at
  the advice against the window now, and the cheaper window that would wait
  longer (if it saves 3% or more). The caveat says tokens and waiting only.
  The picker shows each window's wait, with "Fewest tokens" on the
  cheapest. Untimed rows are unchanged. The new strings are in zh, zh-TW,
  ja and de.
- docs/subsystems/agent-wiring.md describes the timing sources and the
  rule.

What was run
- go test -tags nogui ./internal/sessions ./internal/tune ./internal/gui
  ./internal/agent pass.
  - internal/agent ran before the rebase. It took 1416s under a load
    average of 120-300 and passed with -timeout 40m (the default 10m timed
    out mid-suite). Its Tune/Compact/CacheTTL tests pass on their own.
  - sessions, tune and gui ran again after rebasing on origin/main
    331c27703. fcd6f3519, the head this was pushed onto, touches none of
    these files.
  - internal/gui's TestProviderListReadsSettingsOnce failed 1 of 3 runs
    under load (7.0s against its 2s bar). It passed 6 of 6 on this branch
    and 9 of 9 on origin/main 4048ead7f, and it doesn't touch this code.
    Filed as #2185.
  - TestCallsClaudeCompactTook and TestCallsCodexCompactTook check the
    timings, also after Reset.
  - TestCompactTimedWaitsLeast checks the advice from 1M, 600K and 150K.
    With the timed rule disabled it fails ("advised 260000 makes 36
    compactions, more than 4 now").
  - TestCompactUntimedUnchanged checks that 2 timed compactions give the
    same advice as none, with no wait.
- GUI: context-tune, i18n-keys and context-window pass, 97/97 in Chromium
  and WebKit, in en/zh/zh-TW/ja/de at 360 and 1100 px. The new timed test
  fails against the old assets ("Fewest tokens" where "Tokens + wait" is
  expected).
- gofmt -l is clean. go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./... are clean.
- Real data, from copies of the owner's 4 Codex rollouts and 8 Claude
  transcripts in a sandbox HOME:
  - Compactions took 28-46s (opus-5-5), 85-139s (fable-5-1) and 52-121s
    (Codex gpt-5.6-sol).
  - gpt-5.6-sol keeps 230K. Before this change it was advised 70K: 44%
    fewer tokens, but about 3.5h of waiting against 30m.
  - opus-5 moves 200K to 190K, with 6% fewer tokens and the same wait.
  - Untimed models are unchanged.

Not tried: the live app with real accounts. The replay assumes a
compaction takes the same time at every window, since the files only time
compactions near the window the user ran with.
2026-10-14 20:03:53 +08:00
yetone b7a2e73761 agent: connecting an app that gets magpie's models as its provider, with none listed for it, says why instead of reporting success (Lumens on Discord)
Lumens (v0.1.1233) connected WorkBuddy from the Agents page. The toast
said it was connected, but the toggle flipped straight back and
WorkBuddy had no magpie models. For agents that take magpie itself as
the provider (WorkBuddy, WorkBuddy AI, ZCode, Pencil, T3 Code, Copilot
JetBrains), Agent.connect() went down the "magpie" branch and called
Apply without checking whether any model was listed for the agent. With
none listed (no provider or subscription yet, or "only picked" with
every pick gone), Apply wrote nothing, connect still answered 200, and
the next read found nothing wired.

The fix applies, then, if the agent still doesn't read as wired, returns
the same NoModelsError or AllHiddenError the field-less path already
used. The GUI already maps both to no_models and all_hidden, in all five
languages. The check comes after Apply because Cursor Private Inference
is wired through its environment with no models at all, and
TestCursorLocalConnects keeps that connecting. The noModelLeft helper is
shared with the existing field-less path.

Tests:
- TestConnectMagpieAsProviderWithNoModelLeft (agent): WorkBuddy with no
  provider gives NoModelsError. With its only picked provider switched
  off it gives AllHiddenError and stays unwired. Switched back on, it
  connects and is wired.
- TestAgentConnectNoModelsMagpieAsProvider (gui): POST
  /api/agents/connect/workbuddy with nothing in magpie gives 400
  no_models. The old code gave 200.
Both fail on the old code.

Run:
- gofmt -l is clean.
- go vet passes on darwin, on GOOS=linux -tags nogui and on GOOS=windows,
  for internal/agent and internal/gui.
- go test -tags nogui passes for ./internal/agent and ./internal/gui under
  a sandbox HOME (load ~250 from sibling sessions).
- An earlier full ./... run: gateway, library and provider passed on a
  rerun with a longer -timeout. Their first run hit the 10m timeout under
  load, with no assertion failures.

Not tried: the real WorkBuddy app, and Lumens' own settings, which
haven't been seen. Left for its own change: workbuddyWired counts only
vendor "magpie" entries, while buddyWrite also treats an entry under
magpie's key that WorkBuddy re-saved as vendor "Custom" as magpie's.
2026-10-14 20:01:06 +08:00
yetone 62e012b3e2 gui tests: Settings tabs are opened with Enter, not a click that waits on frames a loaded WebKit doesn't draw (#2150)
Cause: quota-reads (webkit de 360) timed out on
`:is(#setTab-usage, .nav-s[data-of=setTab-usage]):visible").click()`. Its
call log ends at "waiting for element to be visible, enabled and stable",
with no "element is not stable" retries, so the tab wasn't moving.
Playwright's stability check compares the box over two
requestAnimationFrame callbacks. WebKit's frames are driven by its UI
process, and on a loaded machine they stall for seconds while the page's
ordinary tasks run on, so the click sat out the whole 5s page timeout over
a still tab.

Reproduced by injecting a delay: SIGSTOP/SIGCONT duty-cycling of WebKit's
UI process (10ms on / 990ms off) around the tab step in a copy of
quota-reads. click() took 3-4s and timed out in 4 of 6 runs.
press("Enter") on the same locator took 2-3s and passed 6 of 6.

Fix: reader.cjs gets openPart(page, id), which presses Enter on the tab or
its sidebar strip entry. Both are <button>s, so Enter clicks them with no
frame to wait for. All 49 call sites of that locator shape across 35 test
files use it now. The other shapes (getAttribute, focus, boundingBox, the
.nav-s strip's own pointer tests) are left as they are, since they test
the tab itself.

Run (playwright 1.62.0, chromium + webkit, each file's own languages and
widths): all 35 changed files, four at a time, at load average ~400 from
other sessions. 450 tests passed. sync-not-backup (#prefs not there yet)
and tray-inuse (a 180s browser launch timeout) failed one test each
before the tab step; alone they pass 20/20 and 4/4.

Not tried: the other rAF-polled waits across the suite (waitForFunction
defaults to rAF polling, and settingsDrawn is one of them). They starve
the same way under this load, but none is named in #2150 or #2151.
2026-10-14 20:00:55 +08:00
yetone fcd6f35198 gateway: a decision model's intent counts by its option probabilities, not its own confidence field (@VersunPan on X)
Cause: readJev took an intent (and kept a level over the turn before's)
only when the answer's `confidence` was at least jevSure (0.4). That
scale is System One's: 0 for an even spread, 1 for one option certain
(provider.Confidence, (top - 1/n) / (1 - 1/n)). Other decision models
fill the field their own way. Cloudflare's @cf/cloudflare/clef-flash
compresses it: "提醒我明天下午三点给 Dora 打电话" came back light at
0.2866 while its top probability was about 0.68, so everyday requests
matched no rule and fell through to the group's default (Opus).
MLX-Serve's clef-flash-4bit says its top probability (0.68-0.95) and
passed. Both picked the same choice 15 of 15.

Fix: sureOf reads sureness from the answer's `probabilities` when it
gives two or more numbers, on System One's scale. Cloudflare's
clef-flash output schema makes probabilities (summing to 1) and
confidence required for a choice answer, and calls confidence only
"derived from the probabilities". Jev's own confidence is that same
formula, so Jev's decisions don't change. An answer without
probabilities is read by its confidence as before. A near-even spread
still comes out near 0 and matches nothing. The threshold stays 0.4.
The level path, which falls back to the turn before's level when
unsure, uses sureOf too. Verdict.Sure, which the Routing page shows, is
now the value the decision used. The effort pick reads only `score`, so
it is unchanged. The GUI line "An intent it isn't sure of matches no
rule" stays accurate.

Tests (decide_sure_test.go):
- TestClefFlashSureByProbabilities runs end to end through Workers AI's
  envelope at /ai/run/@cf/cloudflare/clef-flash, with answers shaped as
  that schema has them. Light at 0.68/0.14/0.10/0.08 with confidence
  0.2866 now routes to its rule (Sure 0.573). A 0.28/0.25/0.24/0.23
  spread matches none.
- TestJevLevelSureByProbabilities: a clear level is taken over the turn
  before's, a torn one keeps it, and an answer with no probabilities
  falls back to its confidence.

Run: gofmt -l (clean). go vet ./internal/gateway on darwin, GOOS=linux
and GOOS=windows. go test ./internal/gateway -count=1 -timeout 40m: ok
(2086s at load ~250. A first run hit go test's default 10m package
timeout under that load).

Broken by hand:
- readJev back on a.Confidence: both tests red. The CF case went to
  "from ka" with Sure 0.2866, the reporter's miss.
- sureOf floored at 0.5: the near-even spread and the torn level went
  red.

Not tried: a real Workers AI call. The fixture's spread is built from
the reporter's numbers (sure 0.2866, MLX top 0.68, MAE 1.6%), not from
saved bytes of that request.
2026-10-14 19:54:31 +08:00
yetone 430871d632 provider: SiliconFlow offers its international site as a region beside China
SiliconFlow asked (by mail) for its international site, api.siliconflow.com,
in magpie. It is a separate account with its own keys page and a $ balance,
so the siliconflow preset now has two regions: China (the default, so every
saved provider and link reads as before) and Global, with
cloud.siliconflow.com's key page and console. The balance read already knew
the .com host. Import links take region=intl; the import docs (en, zh, ja)
list it. "Global" reuses the GUI's existing translations.

Run: go test ./internal/provider/ (ok, 541s), incl. the new
TestSiliconFlowInternational: an intl link gets the .com endpoint, key
page, console and $ balance source; FromPreset stays on .cn; a saved .cn
provider sits at region cn and an intl one at intl. gofmt, go vet clean.
Not tried with a real international-site key (no account).
2026-10-14 19:52:21 +08:00
yetone 4048ead7fa provider: a balance query's header takes the key as {token} too, and the key pasted as its token goes as a Bearer (lx_78654 on Discord)
A key usage query that takes only "Authorization: Bearer <key>"
answered magpie's Check balance with {"code":"INVALID_AUTH_HEADER",
"message":"Authorization header format must be 'Bearer {token}'"}. Two
ways got there:
- a header written as the vendor's own error names it, "Authorization:
  Bearer {token}", went with "{token}" in it as written: only {key},
  {apiKey} and {api_key} were put in;
- the key pasted into the Account balance (token) field went bare in
  Authorization, the way a new-api access token goes.

The key is now put in for {token} as well, for any case of key, apikey,
api_key, api-key and token, and in {{…}} or ${…}. A balance token that
is the provider's own key (with or without "Bearer ") is taken as no
token, so the query is asked as a chat request is, with the key as a
Bearer. A token of the account's own still goes as it is. Without a
header or a token the key already went as a Bearer.

Run:
- TestBalanceKeyAsBearer: an httptest server that answers only
  "Bearer <key>"; no header, Bearer {token}/{key}/{API_KEY}/{{apikey}}/
  ${API_KEY}, the key and "Bearer <key>" as the token all read $8.50;
  {TOKEN} in the URL is escaped; an access token still goes bare. On the
  old code it fails with the reporter's INVALID_AUTH_HEADER for {token},
  {API_KEY}, {{apikey}}, ${API_KEY} and the key as token.
- go test -tags nogui ./internal/provider/ ./internal/cli/.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.

Not tried: the vendor's real endpoint (a relay, not contacted). Chat
requests still send Headers exactly as typed (provider.go's Headers
doc); only the balance query puts the key in.
2026-10-14 19:47:17 +08:00
yetone 8ea4fec90a tui: w changes a custom provider's base URLs (luluxiu_1_4392 on Discord)
On Linux, with no window, the TUI had no way to change an API-key
provider's base URL: w only moved a local server's address or a preset
with an endpoint, and for a provider of the user's own it only pointed
to `magpie provider set <id> url=…`.

w on a provider with no preset now asks each base URL it has (Chat,
Responses, Anthropic, Gemini) in turn, prefilled with the one there now;
Enter alone keeps one. Only http(s) addresses with a host are taken, a
trailing / is dropped, and only the URLs that changed are saved, the
balance cache forgotten. A vendor preset is still asked at its own
address, and the footer already said "w address".

TestTUIAddsARemoteMagpieWithItsAddress asserted w asks nothing on the
custom provider "a"; its vendor case now uses a DeepSeek preset.

Run:
- TestTUIEditsACustomProvidersBaseURL: one URL changed and saved
  without the trailing slash, a bad URL refused, a two-URL provider with
  one kept and one changed, Enter Enter = unchanged. With the new branch
  disabled it fails ("w opened "" (mode 0)").
- go test -tags nogui ./internal/tui/ (the full run caught the old
  assertion above, now updated).
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.

Not tried: the TUI by hand in a real terminal on Linux.
2026-10-14 19:47:16 +08:00
yetone ef0c515eb0 provider: a sub2api or new-api account query left without its token asks the key's query instead (lx_78654 on Discord)
The editor's "Use …/api/v1/user/profile" sets the Balance URL to the
sub2api panel's account query, which only the login JWT can ask. Its
Remove button clears the token but not the URL, so the profile query was
then asked with the key, refused with 401, and the Usage card said
"Allowance unavailable" for good.

keyQueryOf now asks the same panel's key query when the Balance URL is
an account query (sub2api /api/v1/user/profile, new-api /api/user/self)
and no token is set: /v1/usage and /api/usage/token, with the key, their
own default field unless the user wrote another. The saved URL is left
as set, so pasting a token again asks the account query again. A
provider whose Headers carry its own Authorization or Cookie is asked as
set. It covers every reader: the Usage page and `magpie quota`
(KeyBalances), the editor's Check balance, routing's key windows
(sub2APIKeyLimits), and `magpie provider <id>`, whose "from" line now
says the query actually asked (BalanceQuery).

Run:
- TestAccountQueryWithoutTokenAsksTheKey (httptest sub2api + new-api):
  JWT, removed, JWT again; new-api without token; custom field kept;
  account query never asked with the key; own Authorization kept.
  With keyQueryOf a no-op it fails with the reporter's 401 card.
- Sandbox CLI (scratch HOME, fake sub2api on 127.0.0.1): old binary,
  after `provider set sub2 balance.token=`, `magpie quota` shows
  "401 Unauthorized…"; new binary shows "$7.25 left", from /v1/usage.
- go test -tags nogui ./internal/provider/ ./internal/cli/ ./internal/tui/,
  and internal/gateway's balance, allowance, quota and key-limit tests.
  The full `go test -tags nogui ./...` passed every other package;
  internal/gateway and internal/agent ran out of time (10m, then 40m)
  with the machine at a load average of ~300-370, the tests running at
  the deadline seconds old, so not a hang; neither run finished.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.

Not tried: a real sub2api or new-api account; the GUI not clicked
through (no asset changed, it reads the same KeyBalances).
2026-10-14 19:47:16 +08:00
yetone b8070cc6c8 tests: TestAgentGoneInTheRetryPause cancels once the last try is in its pause, not 100ms after the upstream counted it
CI on b75e21be3 (ubuntu, run 38549121391) failed group_replan: the last
try ended 499 "canceled" after 112ms with Again 0, so the agent had left
while the try was still in flight, not in the pause the test is about.
The test counted the upstream's request and then slept a fixed 100ms
before cancelling; on a loaded runner the gateway hadn't read the 503 by
then. It now polls the trace until the last route has its tries and the
last one carries Again (written just before the pause starts), then
cancels.

Run (worktree on origin/main 331c27703):
- Injected a 150ms sleep in the fake upstream between counting and
  answering: the old test fails both subtests with CI's exact shape
  (Millis ~110, Again 0); the new one passes, -count=3.
- Break check: with try.Gone = true taken out of both pause paths in
  gateway.go, the new test fails both subtests.
- go test -race -run TestAgentGoneInTheRetryPause -count=8: ok (116s,
  load average ~300).
- gofmt -l clean, go vet -tags nogui ./internal/gateway ok.
Not run: the whole gateway package (only this test file changed).
2026-10-14 19:46:29 +08:00
yetone 331c27703a gateway, provider: send no prompt_cache_options to Codex, and ask again without it when an upstream refuses it (#2154)
pi-ai sends {"prompt_cache_options":{"mode":"explicit"}} on the Responses
API. The ChatGPT backend behind a Codex subscription answers 400:

  {"error":{"message":"prompt_cache_options is not supported on this
  model","type":"invalid_request_error","param":"prompt_cache_options",
  "code":"invalid_parameter"}}

Probed on 2026-10-14 with a read-only use of the owner's Codex token
(never refreshed or written): gpt-5.5, gpt-6-sol, gpt-6-astra,
gpt-6-luna and gpt-5.6-sol all refuse it, and the same requests without
the field return 200.

- codexBody drops prompt_cache_options with the other fields the backend
  turns away. prompt_cache_key stays; the backend follows it (#1473).
- prompt_cache_options joins the gateway's optional fields. Its refusal
  names the field bare, at the start of the message, which none of the
  existing patterns read, so unsupportedOptionalField also takes
  "<field> is not supported/unsupported" when the message starts with
  it. Only at the start, so a field named inside an echo of the input is
  not taken for it. As for the other optional fields, the refusal is
  remembered per provider, though OpenAI's wording says "on this model";
  the cost of that is a cache hint left off, never a failed request.

Run: go test -tags nogui for internal/gateway (40m timeout; load ~380
from other sessions), provider, catalog, codexcat and agent; gofmt -l;
go vet darwin, GOOS=linux -tags nogui, GOOS=windows. With each fix taken
out by hand, TestRefusedOptionalNamesOnlyUnsupportedFields,
TestPromptCacheOptionsRefusedRetried and
TestCodexBodyDropsPromptCacheOptions go red.
Not tried: pi-ai itself against a Codex subscription.
2026-10-14 19:06:51 +08:00
yetone f51863b3da catalog: a relay channel's word before a known model is that model, so Codex lets it see images (#2157)
The reporter's relay lists nyro-gpt-5.5, nyro-gemini-3.8-flash and
nyro-deepseek-v4.1-flash. None of those ids is in models.dev, so magpie
knew nothing about them: magpie-models.json gave each one
input_modalities ["text"], no context window and no reasoning levels, and
Codex refused every image. The bare ids are known (gpt-5.5: images, a context
window and reasoning levels).

renamed now also takes a leading channel word off an unknown id: 2 to 24
lowercase letters and a dash, when what is left has a digit and is a
known model. models.dev's own data backs it: 147 of its listed ids have
the form word-<another listed id> (openai-, databricks-, anthropic-,
doubao-, zai-, ...), and each is the same model. A listed id is never
renamed, so a vendor's own chan-gpt-5.5 keeps its entry; nyro-auto,
ny2-gpt-5.5 and nyro-gpt-5.5x stay unknown. NameOf keeps the word, so the
shown name is still the relay's own.

TestRenameNeverTakesAModelForAnother (#1383) had
anthropic-deepseek-v4.1-flash as a near miss. By the evidence above, that
id is DeepSeek's model under a vendor word, so the guard row is now
anthropic2-deepseek-v4.1-flash, which the rule still leaves alone.

A model magpie still can't place stays text-only: telling Codex a
text-only model sees images makes it offer view_image and fails the turn
upstream. For those the per-model "sees images" switch already writes
image into the catalog, which TestChannelModelsReachCodexWithImages
covers along with the renamed ids.

Run: go test -tags nogui for internal/catalog, codexcat, provider,
gateway (40m timeout; load ~380 from other sessions) and agent; gofmt -l;
go vet darwin, GOOS=linux -tags nogui, GOOS=windows. With the channel rule
turned off by hand both new tests go red (nyro-gpt-5.5 images false,
window 0; input_modalities [text]).
Not tried: a real Codex image turn through the reporter's relay.
2026-10-14 19:06:50 +08:00
yetone bab1b30009 routing: the hub's mode chip is written only when it changes, so a press held over the once-a-second redraw still clicks in WebKit (#2151)
Cause: the routing view redraws every second (setInterval → render →
header). header() set chip.textContent and goTo() re-set data-go, tabindex,
role and title each time, even when nothing changed. Setting textContent
swaps the chip's text node. In WebKit, a press whose mousedown and mouseup
straddle that swap gets no click, so goRouting never ran and
routing-mode-goes timed out waiting for .rt-found (webkit zh 420 on CI).
A reader pressing the chip for a moment could miss it the same way.

Reproduced by injecting a delay: SIGSTOP/SIGCONT duty-cycling of WebKit's
UI process. At 10ms on / 490ms off, a MutationObserver on .rt-hub plus
pointer logging showed pointerdown at 2407ms, the hub's childList swap at
2869ms, pointerup at 2904ms, and no click. At 50/450, 1 of 30 runs timed
out at the rt-found wait on the old code; 0 of 30 do with this change.

Fix: header() and hubText() go through setText (write only if different),
and goTo() sets each attribute only when it differs. The activity list's
heading chips already keep equal nodes through patch().

Test: routing-mode-goes now holds a press over one redraw. It counts the
routing interval's ticks through a wrapped setInterval, then does
mouse.down, waits for a tick, does mouse.up and expects .rt-found. On the
old routing.js this fails in all 10 WebKit cases at that wait (chromium
passes, since it clicks the common ancestor); with the fix it passes.

Run (playwright 1.62.0, chromium + webkit):
- routing-mode-goes: 40/40, en zh zh-TW ja de at 1100 and 420.
- group-switch-add-many, group-share, routing-key-windows,
  routing-weight-chip, view-scrollbar-drag, routing-steady,
  routing-idle-frame and routing-shape all pass.
- routing-live-patch failed one folded subtest only with 9 files run at
  once. It passes 2/2 alone with and without this change: a fixed 400ms
  sample, filed as #2174.

Not tried: the desktop app's WKWebView by hand. At 2% CPU (10/490) the
chip now clicks, but the view's scroll guard can still refuse or put back
the scroll when the click is handled more than 1s late. I left that
alone; it doesn't appear at 10%.
2026-10-14 18:59:50 +08:00
yetone 0506f011d7 agent: a Codex reaching the gateway from another machine is never joined beside its ChatGPT sign-in (#2145, lazydao)
A Codex in a WSL distro under NAT (or with MAGPIE_ADDR pinned beyond
loopback) signed in to ChatGPT was joined beside its sign-in: it sent
its ChatGPT token to <gw>/backend-api/codex, and from another machine
the gateway takes a named key alone, so every request was a 401.

chatGPT() is now false when onAnotherMachine(at.gw()): such a Codex is
wired as one with no ChatGPT sign-in, magpie as its provider with gwKey()
(the LAN sharing key). One of its own models picked still goes straight
to OpenAI on its sign-in, as it does for a Codex with no sign-in.

Run: TestCodexBeyondLoopbackNotJoined (new; fails on the old code with
the joined config), go test -tags nogui -count=1 ./internal/agent (975s,
ok), gofmt -l, go vet darwin / GOOS=linux -tags nogui / GOOS=windows.
A first version forced magpie API under NAT and broke
TestWSLCodexProvider (own model refused); this one keeps that path.
Not tried: a real WSL distro under NAT with a ChatGPT-signed-in Codex.
A NAT Codex already joined is rewired on the next connect or model pick.
2026-10-14 18:44:45 +08:00
yetone a4d580fa24 gateway: a group skips Antigravity for the system prompt it just turned away (#2156)
Antigravity answers Claude Code's and the Agent SDK's system prompt (the
x-anthropic-billing-header line, "built on Anthropic's Claude Agent SDK")
with 429 "Resource has been exhausted" whatever quota is left (#666).
magpie already tells it as prompt_turned_away, rests nobody and hands it
on, but each Claude Desktop turn in a group waited on the same refusal
first (#2156: 429 in 1073ms, then cursor/composer-2.5 200).

Now, once Antigravity has turned such a request away (any of the three
paths that set holdWriter.turnedAway), for agForeseeing (6h) after, the
candidate loop skips an Antigravity candidate for a request that carries
the line, when someone is left after it (antigravityForeseen). The skip
goes in Fallback with the hint, sets `other` as the asked path does, and
changes no account state. The last one left is still asked and told the
400 with the hint. A request without the line (titles, Codex) still goes.
An old refusal foresees nothing, so a block Google lifts is noticed. The
lines are still neither rewritten nor hidden (#666). The stamp is per
Server, in memory.

TestAntigravityTurnedAwayRestsNobody's "asked first again" half now
checks it with a turn without the line, since one with it is foreseen.

Run:
- TestAntigravityTurnedAwayIsForeseen: fails with the skip turned off
  ("Antigravity was asked again for the prompt it just turned away"),
  passes with it; TestAntigravity* -count=3 green.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ok.
- go test -tags nogui ./... in a sandbox HOME at load average 140-220:
  everything green except 10m timeouts in agent, cli, gateway, library,
  provider and TestSetAnswersWhileDevinAndProvidersHang (#1375, noted
  there); those six packages rerun with -timeout 45m: all ok.
Not tried: the skip against the real Antigravity account (the refusal
itself was reproduced with a real account before: 400 with the line,
200 without), nor Windows/Claude Desktop as the reporter uses. No GUI
change.
2026-10-14 18:41:56 +08:00
yetone 9bc9a6e5e1 tests: TestRefreshInvalidationCancelsStaleCall gives the second ask 10s, not 1s, so a loaded runner doesn't read it as a stale listing left running
Seen red during a full run at load average 200-360 ("stale listing was not
cancelled and followed by the new state", 1.73s). The test's fake first ask
waits on its context alone, so a listing that invalidation fails to cancel
never ends; a 1s bound only measured how fast the second ask and the commit
ran. 10s keeps that apart with room on both sides.

Run: a 1.5s sleep injected into the second ask fails the old 1s bound with
the same message and passes the 10s one; with provCancel() taken out of
forgetProviders the test still fails (Fatal at 10s, then the package times
out on Settle, as before). go test -race -count=20 -run the test, go test
-tags nogui ./internal/plugin (179s), gofmt -l, go vet darwin, GOOS=linux
-tags nogui and GOOS=windows on ./internal/plugin pass. Test-only change;
./... not run. TestRefreshDeadlineBoundsRealProviderCall in the same file
still bounds a 100ms deadline against a 1.5s plugin call with a 1s wait
(900ms/500ms of room); not changed here.
2026-10-14 18:41:45 +08:00
yetone bc2d351337 gui: a routing group's member held at its cap, or used up and set not to spend credits, stays on the Routing stage (#2129, wyq0x55)
A member whose accounts were all held — Codex used up with "spend
credits" off, or an account past the usage cap set on it — went to the
route's left list, and the stage draws r.order only, so the member
vanished from the group on the stage (d-task's gpt-sol-6.1), while a
used-up Claude, resting, stayed there faded. The stage now seats left
entries held at a cap or for credits (not those a gateway key may not
use, nor those whose plan doesn't list the model, which 01cee5a26 kept
off on purpose) in their place among the group's members, faded with
the existing "held" wording. A fold of a provider's accounts counts them
apart: "1 available · 2 held" ({n} held in zh, zh-TW, ja, de).

Run: routing-held-member.test.cjs (new) in chromium and webkit, en zh
zh-TW ja de, 1100 and 420 wide: 20/20; with routing.js reverted it fails
10/10 in chromium. All routing-*, codex-credits, account-cap, window-cap
and i18n* GUI tests, 4-wide, both engines: 1032 pass, 13 fail, all in
routing-keys-fold and routing-model-rest, which fail the same alone on
origin/main bda271999 (9/52 there, load ~300; #1612, #2115), and use no
left entries. Not tried against a live gateway with a used-up Codex.
2026-10-14 18:40:39 +08:00
yetone 845b5c4ddd gui: Settings › General's Codex model rows and Open at login say what they do in their tooltip, and Lightweight mode that the gateway keeps running (#2120)
Anoninz asked on #2120 what the Codex model rows do, why Open at login
shows under App Background Activity on macOS, and what Lightweight mode
gives up. These rows were made to say their name alone in f36e744c3
(1ooogle's mockup, approved by the owner), so this adds no line under
them. The explanation goes into the row's tooltip, the way the text size
keys went in that same commit.
- Codex thread titles, descriptions, composer predictions, auto-review
  and memories model rows: what Codex uses the model for and when, and
  what "Codex's own" means. The facts are from settings.go and
  codexcat.go.
- Open at login: opens in the menu bar (tray) with no window. On a Mac
  it is a launch agent, which System Settings › General › Login Items
  lists under App Background Activity, not Open at Login. The section
  names are from macOS 26's LoginItems loctables.
- Lightweight mode keeps its one line. It now says the gateway and tasks
  keep running and only the page reloads (lightweight_rule.go: only a
  closed window's webview is let go). It still fits on one line at 1000px
  in every language. In de, "only the page reloads" didn't fit, so de
  says that the gateway and tasks keep running.
All five languages are covered: en, zh, zh-TW, ja and de.

Run: NODE_PATH playwright 1.62.0, chromium and webkit, all green:
- i18n-keys, bare-ids, gui-de, gui-ja, gui-zh-tw, search-keys
- lightweight, settings-general, settings-groups, settings-sections,
  settings-search, keep-login
- codex-titles, codex-descriptions, codex-predictions,
  codex-auto-review, codex-auto-reset-settings, codex-memories,
  codex-memories-settings, codex-subagent-model
A scratch check (not committed) loaded Settings › General in both
engines, at 1100 and 420, in all five languages, with Mac and non-Mac
platforms. It found each tooltip set and translated, the Mac/other
login text picked right, no sideways scroll, no row overflow and no
page errors (40/40).

Not tried: the tooltips weren't hovered in the real Wails window. No
Go code changed, so no go vet or go test was run.
2026-10-14 18:36:42 +08:00
Edward4226 52b5d9f83f gui: an allowance curve says when it runs out, so its 52px shape need not be read (#2079, #2146, Edward4226)
A window's curve is asked one question — will this run out before its reset,
and when — and answers it with the angle between two lines in a 52px box. In
the issue's card (a monthly window 13 days into 30, 28% used, under even
burn) the curve's own slope is 4.9° on the Usage page and 1.5° in the tray's
spark, against even burns at 7.8° and 2.4°: the two differ by 2.9° and 0.9°,
and in the panel their right-hand ends sit about 2px apart. 65a8365 has since
drawn that spark 30px tall and shaded which side of the burn it is on, which
answers "which side" at a glance; the hour is the half a shape still cannot
give. An axis fitted to the readings does not give it either: the dashes are
the cycle's even burn, a full-height diagonal from a window's start to its
reset, so fitting the axis pulls the burn out of the readings' own range and
inverts the reading. That change is right for a balance and wrong here (the
commit before this one).

So the answer is said, in the reader's own clock. Main grew a quotaPace of
its own — 3a7d031, "Pace +20%" on the reset line, the meter's share less the
share of the window gone by. That is where a window stands, which the eye
still has to turn into a rate; the hour is the missing half. The helpers here
are named quotaEta / quotaEtaText / quotaEtaSpan so as not to shadow that
quotaPace, and the two are meant to sit on one card: "Pace +9%" above
"Runs out Oct 26 13:22 at this pace".

- quotaEta: a window's recent run — the readings since it last refilled,
  within the week, walked back while each older one is the higher, as
  balance_history.go fits a balance's over balanceFitSpan — fitted to a line
  and carried to where it meets zero. {out} is that hour; {lasts} is whether
  it falls after the reset. Nothing is said with fewer than three readings,
  less than an hour of them, nothing left, a line that is not falling, or one
  already past zero.
- quotaCurve: the head carries the sentence, for the window whose deadline
  is furthest off, beside the range it already names; the title holds the
  full stamp. The plot itself is untouched, behind it.
- panelQuotaCard: the same sentence on the card whose deadline line it
  belongs to, for the window the thin spark draws. quotaWindowLine is the
  reading quotaSpark draws from, now shared by both, so the words cannot
  drift from the line they are about.
- "Runs out {when} at this pace" joins the existing "{in}" string, which the
  balance curve keeps, in all five languages: the hour is named (10月26日
  13:22) rather than counted to, since a counted-to run-out is the reader's
  arithmetic to do. "Lasts past the reset at this pace" is the other answer,
  and the one most windows should be giving.

Run (Node v22.20.0, Playwright 1.64, Chromium and WebKit, no backend, the
API faked), rebased onto 3b6ca05, whose own tray-spark-gap test still passes
underneath:

- node --test internal/gui/tests/quota-curve.test.cjs — 15 pass, both
  engines. Run against an LF copy of the assets: the file's quotaCycleBreak
  case slices app.js on indexOf("\n}\n"), so a checkout with
  core.autocrlf=true reads that function back as undefined and is red there
  whatever this patch does.
- node --test internal/gui/tests/quota-pace.test.cjs — 4 pass (the shipped
  Pace is unchanged by the rename and by the span beside it).
- node --test internal/gui/tests/balance-curve.test.cjs — 4 pass (the other
  commit).
- node --test internal/gui/tests/tray-spark-gap.test.cjs — 65a8365's 30px
  spark and its shading, unchanged, with the window line now coming from
  quotaWindowLine.
- With main's own app.js, app.css and i18n.js put back in place, both
  engines fail the new assertions by name: waiting for
  locator('.subscription-card').filter({ hasText: 'Codex' })
  .locator('.quota-curve').first().locator('.qc-pace').

Not tried: no real DeepSeek or Codex key, so the numbers behind the sentence
are only ever the fixtures'; a card whose window is read once every few hours
has three readings within the week and speaks, and nothing here decides
whether a run of one reading an hour is representative. The rate itself is
not shown (the balance curve's "about {amount} a day" is the precedent, and
a "%/day" unit for a 5-hour window reads oddly). No dark-theme-specific,
multi-account or pool treatment beyond what the shared card already does.

Review changes on merge (#2146), by the maintainer side:

- Rebased onto bda271999: main has dropped the box.title line beside the
  head, so the conflict there keeps main's (quotaCurveTitle draws it now).
- quotaEta says nothing for a cycle that is already over, and quotaCurve
  asks it only for the current cycle: a past cycle picked from the cycle
  menu has no pace left to tell. A unit case runs quotaEta in a vm (a
  falling run, one past its reset, too few readings, half an hour, nothing
  left, a flat run, and a past cycle flat and falling); with the guard
  removed it goes red.
- The tray card adds the sentence only when its reset line names the first
  window's deadline alone. With both Codex windows begun the line reads
  "↻ 14:26 · Weekly Oct 31", and the sentence (about the 5-hour window)
  after it read as the week's. The existing tray case now wants no sentence
  there, and a second fixture with only the 5-hour window begun wants it;
  with the old gate the first goes red in both languages. It is also left
  out while the curves are off, like the spark it speaks for.
- The Usage head keeps "Left over time" on one line and cuts the sentence
  short rather than wrapping it; its tooltip names the window (when the
  card has more than one) and the full stamp. German was cut at 420px
  ("Bei diesem Tempo leer um 15. Okt. 17:…"), so the German strings are
  shorter: "Leer ca. {when}" and "Reicht so bis zum Reset".
- Not taken: 25a2886 (the balance curve's axis fitted to its readings).
  The balance curve already says its run-out in words ("Runs out {in} at
  this pace", "about {amount} a day"), so the slope no longer has to carry
  it; a value axis that doesn't start at zero makes a cents-a-day drift
  look like a fall to empty; and valueBand only takes the floor in when the
  padded band already reaches below it, so when the dashes do reach zero
  inside the window they are drawn past the plot's foot instead of meeting
  it, the case its own comment promises.

Run on this tree (Playwright 1.62, Chromium and WebKit, load avg ~300):
quota-curve 28/28, quota-pace 4/4, balance-curve 6/6, tray-spark-gap
22/22, panel-usage 4/4, i18n-keys 3/3, usage-quota-head 4/4, quota-reads
22/22, quota-read-at 4/4, tray-usages 16/16, tray-usage-redraw 4/4,
quota-families 4/4, quota-pools 4/4, panel-balance-order 16/16,
quota-count-wrap 2/2, quota-name-translated 10/10, quota-credits 8/8,
quota-holds 2/2. An ad-hoc check (not committed) loaded the Usage page and
the tray in en, zh, zh-TW, ja and de at 1100 and 420 in both engines with a
falling week and a lone 5-hour window: the sentence is one line, nothing is
cut, no card or page overflows. gofmt, go vet (darwin, linux nogui,
windows) on internal/gui. go test ./internal/gui failed only
TestSetAnswersWhileDevinAndProvidersHang (#1375) and
TestMainWindowCorners/macOS_26_SDK killed at its deadline (#1936), both
already filed as load reds and neither touching these assets.

Not tried: real Codex or DeepSeek readings; dark theme beyond the shared
card; the full GUI suite.
2026-10-14 18:34:27 +08:00
yetone cf455ebd5f gui: a view at its top when a control is clicked stays at its top, what came in above moving the control down (#2134)
The click guard's own rule says "A view at its top stays at its top:
what comes in above the control there moves it down instead of
scrolling itself out of sight", but hold() only kept that rule for the
room at the foot. Anything that grew above the held control scrolled
the view to follow it. At 420 wide, Settings › About turning Automatic
updates Off gave the Version row its "are off" line ~2.3px tall once the
save answered, and the view slid from 0 to 2. hold() now keeps a view
that was at its top (h.top) at 0, so the switch moves down by those
pixels instead.

Tests:
- update-auto: a new case at 420x640 clicks Off with Settings at its top
  and checks scrollTop after the save's redraw (600ms), not only right
  after the click. On origin/main's app.js it is red in both engines
  (2 !== 0); with the change green.
- update-restart (#2096) held the switch to within 1px, which is the
  old behaviour at the top. It now checks the at-top rule when the view
  is at its top (scrollTop 0, switch down by at most 4px), and the old
  1px hold otherwise.

Run (load avg 200-340 from other sessions):
- update-auto + update-restart, chromium and webkit, widths 1100 and
  420, en/zh/zh-TW/ja/de: 32/32.
- 71 scroll-guard files (click-scroll, *scroll*, *steady*, *pin*,
  *profile*, settings*, stays-strict, held-animations, and every file
  checking "must not scroll the page"), both engines, 4 wide: 921 pass,
  11 fail. The fails are nav-sub-unroll, removed-groups-menu-scroll,
  settings-proxy-auth and text-size. Alone, settings-proxy-auth passes
  10/10 and nav-sub-unroll chromium 2 of 2; nav-sub-unroll webkit,
  removed-groups-menu-scroll and text-size are red alone on origin/main
  bda271999's app.js too (#1950, #1866, filed #2172).
Not tried: the real app window; only the Playwright engines.
2026-10-14 18:25:52 +08:00