Commit Graph
4291 Commits
Author SHA1 Message Date
yetone ccbbcbffcb gui: a restart to update leaves the Mac's menu bar icon for the next magpie (Mitsuha, audie)
From v0.1.1354 a restart to update hands the gateway over, and the old
magpie hides its own menu bar item with Wails' Hide, which is
[statusItem setVisible:NO]. AppKit keeps that in the app's defaults by
the item's autosave name ("NSStatusItem VisibleCC Item-0" = 0 on macOS
26), and the next item made under that name starts hidden. So after the
update the icon was gone, and quitting and reopening didn't bring it
back (Mitsuha on v0.1.1364; audie on two Macs, macOS 27.0.1).

Evidence: a 30-line Cocoa probe made a status item, setVisible:NO, and
every later launch of the same program started with visible=0 and the
key = 0; removeStatusItem kept nothing; removing the key brought it back
on the next launch. This machine's com.yetone.magpie.sbhandover.plist
(the handover commit's own sandbox run) holds
"NSStatusItem VisibleCC Item-0" => false.

Fix (internal/gui/trayshown_darwin.go, app.go):
- leaveMenuBar (was the onHandedOver closure) queues forgetTrayHidden
  on the main thread after Wails' hide block, so the hide is made on
  screen but not kept.
- bringTrayBack, once per computer (a flag in the Mac's defaults, never
  in a WebDAV backup), forgets a kept hide before the tray is made: that
  repairs everyone an older magpie already hit. A hide kept after that
  is the user's and is left alone.
- A magpie handed over to by an older one (which still hides for good)
  forgets the hide once that pid has quit and shows its item, unless a
  hide was already kept when it started.
docs/subsystems/gui-shell.md says so under the handover.

Run (worktree at origin/main ed91aa04e):
- TestHandoverLeavesTheMenuBarIconForTheNextMagpie (AppKit child with a
  real Wails tray, CFFIXED_USER_HOME sandbox): ok, -count=3.
- Broken by hand: leaveMenuBar without forgetTrayHiddenLater -> "handing
  over kept the menu bar icon hidden for the next magpie (1 kept)";
  bringTrayBack without forgetTrayHidden -> "the icon an older magpie hid
  wasn't brought back (still hidden true, 1 kept)".
- go test ./internal/gui/ -count=1: ok 86.7s; go test -tags nogui
  ./internal/gui/: ok 67.2s.
- gofmt -l: nothing. go vet ./internal/gui/ (darwin), GOOS=linux go vet
  -tags nogui, GOOS=windows go vet: ok. go build, GOOS=linux go build
  -tags nogui, GOOS=windows go build: ok.
- No GUI asset changed, so no Playwright run.

Not tried: a real signed update from v0.1.1367 to this build on the
user's bundle id; whether Control Center hides the new version's running
item live when the old one writes the key (the probe's running item kept
visible=1; the on-screen window list needs screen recording rights). Not
run: the full go test ./... (one package touched; other sessions are
queued for the suite). audie's WebDAV sync carries no tray setting and
doesn't restart magpie; the icon going there is taken to be the same
update's restart, not confirmed with them.
2026-10-24 15:20:37 +08:00
yetone ed91aa04ef checkin: an inactive or ineligible check-in shows the plugin's reason (plugins#304)
Qoder's plugin 0.2.32 (magpie-community/plugins 74be632) says why no
check-in was offered: it asked with this machine's own device identity
and Qoder offered no campaign, and Qoder desktop can claim one it shows.
magpie dropped a hook's message for inactive and ineligible and showed
only "No check-in event now". Now:

- GUI: the Usage card's row reads "<label> · <message>", wrapped under
  the label rather than cut off with "…" (data-why, as a failed row's
  reason wraps, #821); Settings' check-in line under the plugin's switch
  carries it too. A result without a message reads as before. No new
  i18n keys: the message is the plugin's own text, as for failed rows.
- TUI: the Usage cell is too narrow, so it adds "c says why"; c's flash
  carries the message (checkinWhy).
- CLI: `magpie accounts checkin` prints it after the label.
- The Qoder mover's min is 0.2.32 (npm view --prefer-online: 0.2.32).
- docs/subsystems/provider-plugins.md says how the message is shown.

Run at this tree (based on origin/main dd1e8822d):
- go test -timeout 45m ./... (tee'd, grepped): every package ok
  but internal/handoff, whose TestTakeOnlyAFreshOfferForThisProgram
  could not bind a unix socket under my long scratch TMPDIR (path over
  104 bytes); with the default TMPDIR internal/handoff is ok.
- gofmt -l: clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean.
- GUI, chromium and webkit: checkin-reason (new: en, zh, zh-TW, ja, de;
  900 and 440px), plugin-checkin, qoder-checkin-recheck, usage-checkin,
  checkin-account, checkin-early-done, usage-quota-head, i18n-keys:
  155/157. The 2 reds are usage-checkin's "webkit en/zh: Settings has a
  Qoder check-in tab", red the same on a fresh origin/main a9a001a7a
  (#2549, #3091).
- TestCoreScriptBudget: app.js 1,343,313 of 1,343,324, no raise.

Rebased on origin/main 4683a0382 (a9a001a7a's app.js line, 4683a0382's
provider change) and run again at this head: internal/gui (budget:
1,343,323 of 1,343,324), internal/cli, internal/tui and the whole
internal/provider ok; the same 8 GUI files in both engines, 155/157,
the same two #2549/#3091 reds.

Broken by hand: app.js's change reverted, checkin-reason goes red on the
reason; app.css's reverted, red on the wrap; checkinWhy returning "" in
internal/cli and internal/tui, TestCheckinSaysWhyNoneWasOffered red in
each.

Not tried: a real Qoder account offered no campaign (the fixture is the
plugin's own text); the real Linux app (WebKitGTK).
2026-10-24 14:52:13 +08:00
yetone 4683a0382c provider: a saved ChatGPT account Codex is signed in to is refreshed in Codex's auth.json, not in its copy
A ChatGPT account switched in to Codex is one sign-in in two places:
logins.json's copy and Codex's auth.json hold one refresh token.
renewSaved refreshed the copy whenever it was asked to: a provider made
for the account while another was Codex's, held over a switch
(SwitchWhenSpent, keep-first), a usage or models read, keep-alive or a
revoked-token check decided "not the live one" just before a switch.
OpenAI rotates the refresh token as it answers, so auth.json was left
with a spent one. The Codex app of an edu or business workspace fetches
its workspace config bundle (/backend-api/wham/config/bundle) at start
with it; the refresh is refused (refresh_token_reused), app-server
answers configRequirements/read with -32603 "failed to read
configuration layers: Your access token could not be refreshed ...",
and the app stays paused on "无法加载组织设置". Reinstalling the app or
changing the preferred account doesn't help: auth.json stays.

renewSaved now asks, under savedTokenMu (which a switch holds too),
whether the saved account is the one Codex is signed in to (sameLogin,
or the same refresh token) and renews it through codexTokenRenewing on
Codex's own store instead.

Reported by 万贤凯 on Discord (two edu_plus accounts, "Codex 始终登录首选
账号" on, both used up).

Run:
- TestSavedRefreshOfCodexOwnRenewsCodexOwn: red on the old code (auth.json
  kept refresh token "r" after it was spent), green with the fix.
- Codex app-server 0.163.0-alpha.10.2 in a sandbox CODEX_HOME, edu_plus
  auth.json, fake bundle (401) and token endpoint (refresh_token_reused):
  configRequirements/read gives the -32603 above, the reply the desktop
  shows as the org-settings dialog. magpie's openai_base_url and
  [model_providers.magpie] don't move the bundle request (it goes to
  chatgpt_base_url, which magpie never writes).
- gofmt -l; go vet darwin, linux -tags nogui, windows.
- Full suite (go test -tags nogui -timeout 45m ./..., through suite-lock,
  at dd1e8822d plus this change): every package ok except internal/gui's
  TestRestartHandsTheGatewayOver (one request during the handover got
  EOF, 12 of 13). It passes 5 of 5 alone and this change doesn't reach
  it; filed as #3451.

Not tried: the reporter's own auth.json and logins.json, so which caller
spent their token isn't known; a real edu account; the GUI (unchanged).
2026-10-24 14:37:39 +08:00
yetone a9a001a7a6 usage: a window's name too wide for its column goes on to a second line, not under the window beside it (rtbeilin on X)
rtbeilin's ZCode card (X, 10-24) has two windows of one plan side by
side, named by the plugin's byPlan "ZCode 1024 Dev Day · GLM-5.3…",
and the first name ran on under the second window's: the name span was
nowrap with nothing to stop it. Stacked (quotaFit already stacks a card
whose name and count don't fit side by side, and a name wider than its
column always is), the name (now .quota-name) wraps inside its column,
breaking anywhere if a word is wider still. Not cut with an ellipsis:
two windows of one plan differ only at the end of their names.

Run at this head (origin/main 3b10a403d's successor), Chromium and WebKit:
- quota-name-wrap.test.cjs (new): the reporter's two windows, en, zh,
  zh-TW, ja, de at 380, 600 and 1100px; each name is inside its column
  and not cut. Red on the old CSS in both engines ("runs past its
  column (0, -5.3)" at 380px).
- every other quota-*.test.cjs and i18n-keys: 140 pass. Red the same on
  main without this change: quota-count-wrap in WebKit at 1100px
  (#3404, #2228) and quota-reads WebKit de 360 (#3406, #2150).
Not tried: the real tray panel with a ZCode account.
2026-10-24 14:27:08 +08:00
yetone dd1e8822d9 provider: the ZCode move installs zcode-auth 0.1.24, so a Claude Code subagent on ZCode sees Bash, Read and Write
小八 on Discord (10-24): through magpie's ZCode plugin (glm-5.3, glm-5.3-flash)
a Claude Code subagent's tool list held only deferred MCP tools; Bash, Read
and Write were gone, the main conversation was fine. api.z.ai's Anthropic
endpoint, given a tool named exactly ToolSearch, shows the model no tool
but the ones a tool_reference loaded (input tokens 2886 with ToolSearch,
2439 with no tools, 6346 with it renamed). zcode-auth 0.1.24 (plugins
d1b6500) sends the search as ToolSearchTool, without defer_loading or the
placeholder, and renames the model's calls back. The Zhipu/Z.ai presets on
the gateway's Anthropic route are the same upstream; the cause is on #3253.

npm view @magpie-community/opencode-zcode-auth version --prefer-online:
0.1.24 at 23:44 UTC. The plugins publish run is red only for think-tags'
known E404 (plugins#180); zcode's line is "+ ...@0.1.24".

Run at this tree: gofmt -l internal/provider (clean); GOOS=linux, windows,
darwin go vet ./internal/provider (clean); go test -count=1 -timeout 45m
-ldflags='-s -w' ./internal/provider ok 86s (the disk had 250MB free, and
the unstripped test binary failed to link: no space left on device).
Not run: the full suite (same disk).
2026-10-24 07:46:27 +08:00
yetone a3b45eb91e provider: a re: pattern matches in any case, as a glob does (usrname1833 on Discord)
A routing group's patterns (Group.Match) and a provider's auto-include
rules both compile through compilePattern. A glob compiled with (?i)
and a re: pattern without it, so re:gpt-.* missed GPT-5.5 while gpt-*
took it. A re: pattern now compiles as (?i)^(?:…)$; (?-i) inside it
makes case matter again from there on (re:(?-i)gpt-.*).

The Routing page's editor works out a pattern's models in JS
(patternRe in plugins/routing/client.js) and refused what JS can't
read. It now reads re: with the i flag too, and takes Go's leading
flag group ((?-i), (?s), ...) as JS flags, so re:(?-i)OR/B is taken
and matches as the gateway will. A flag group further in is still
refused there (JS has no bare (?-i)); the CLI takes it.

Said in groupmatch.go's comments, magpie group's and magpie provider
auto-include's help, and providers-accounts.md (Routing groups, List
schedule and rules). No GUI hint said a pattern's case, so none
changed and no string was added.

Run:
- TestRegexpPatternIgnoresCase (new): ok. With compilePattern's (?i)
  taken off by hand: FAIL, "re:GPT-.* ~ gpt-5.5: false, want true" and
  three more cases.
- group-patterns.test.cjs, chromium and webkit, en and zh: 4 of 4 ok.
  With patternRe put back to the old re: line by hand: 4 of 4 red,
  "(?-i) keeps case 0 !== 1" (old JS refused re:(?-i)OR/B).
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean.
- go test -tags nogui -timeout 45m ./internal/provider ./internal/cli
  ./internal/gateway under a sandbox HOME at 1a956129c's tree: ok,
  ok, ok (380s). go build for darwin, linux (nogui) and windows: ok.
- A full ./... run was started and stopped: the machine's disk was
  full (1GB free), and internal/agent's tests failed on "no space
  left on device" in TempDir, not on this change. No full suite ran.

Not tried: the full suite (above); a real provider's auto-include fetch with mixed-case ids;
the Linux app's WebKitGTK; a (?-i) further into a re: in the GUI.
2026-10-24 07:07:57 +08:00
yetone 1c617c1532 usage: the Requests chart can be drawn as lines, kept per viewer (molvqingtai, Discord)
molvqingtai asked on Discord for the request chart on Usage > Requests to be
a line chart. A small two-icon switch (bars, lines) now sits in the chart's
header row beside the Token / Cost / Requests / Speed tabs. Bars stay the
default. The choice is kept in localStorage magpie.ledChart, next to
magpie.ledMetric; any other value, or a read that throws, gives bars.

Lines cover every tab. Tokens, cost and requests draw the stacked totals as
cumulative lines with a faint band per model and "other" last, so the top
line meets the stacked column's top. Speed draws a dashed all-models line
and each model's own line, broken where a model has no value. Tooltip, day
pick, ranking hover (it now strokes a series instead of filling it), the
time-zone handling and the empty state are the columns'.

drawLedColumns in core app.js gets one hook, box.drawn, which the Usage
page sets; the line code lives in plugins/usage/page.js. The tray panel's
chart is unchanged (bars). app.js is 1,343,276 bytes, under
TestCoreScriptBudget's 1,343,324; the budget is not raised.

New test usage-chart-line.test.cjs (en, zh, zh-TW, ja, de x light, dark x
1180, 420): bars by default, translated labels, the switch inside the
header with no sideways scroll and no left border, a click doesn't scroll
the page, lines still chosen and drawn after a reload, the top line within
1px of the column top for tokens, cost and requests, speed's dashed line
and broken runs, tooltip and ranking hover, the empty state; a "pie" value
and a throwing getItem give bars.

Run at a93190ae1 plus this change:
- usage-chart-line: 44/44 in chromium and webkit.
- go test ./internal/gui (TestCoreScriptBudget included): ok.
- gofmt -l: nothing. go vet ./... (darwin), GOOS=linux go vet -tags
  nogui ./..., GOOS=windows go vet ./...: ok.
- Whole GUI suite, chromium: 6141 tests, 49 red. The 14 red files were run
  alone on a clean origin/main a6a3dbde8 and on this branch: 43 red on
  each, the same tests (a few routing-rule-remove subtests flip, #3094,
  #3096). All are filed: usage-agents-hide #2276 #3414, usage-fold #3415,
  usage-ledger #3001 #3104, routing-pause #3410, routing-rule-effort
  #3411, routing-intent-entry #3408, routing-steady #3412,
  menu-input-scroll #3402, old-webkit #3403, quota-count-wrap #3404,
  plugin-github #3218, library-mcp-health-wsl #3350. routing-busy-frames
  was red in the full run only and passed alone on both.
- Whole GUI suite, webkit: still running at commit time (1236 tests in,
  0 red); the result follows on this commit's issue thread.

Rebased onto edff2f819 and run again there: TestCoreScriptBudget ok
(app.js 1,343,276), usage-chart-line and i18n-keys 25/25 in chromium
and webkit.

Broken by hand: without the localStorage read the test fails "lines kept
across a reload" (bars, not line); with chart.drawn = null it times out
waiting for #ledChart g.ln.

Not tried: the real Linux app (WebKitGTK) and the Windows box. Screenshots
of both styles in light and dark were checked by eye.
2026-10-24 05:55:44 +08:00
yetone edff2f819a provider: levels kept of a model's own narrow only what is offered again (#92)
4a3e07f1c made provider.Efforts return the levels a user kept, so the
gateway fitted every request to them. That reversed #92 (47e12df41),
which was explicit that narrowing a model's levels changes only what is
shown and "the levels the vendor is asked at stay as they were": a user
who had trimmed a picker with `magpie model efforts` or Names & levels
would have had their agents' xhigh and max asks lowered unasked. Dani's
request (magpie model spec) needs levels to count only where magpie
knows none for the model.

- Efforts is back to what it was before 4a3e07f1c: the vendor's list's
  or models.dev's levels when known, else the ones the user declared
  (`magpie model spec --reasoning` on a custom provider's model), which
  a request is then fitted to. --reasoning off (reasonless) is as
  4a3e07f1c built it.
- TestModelEfforts' "the vendor is still asked at any level it has" is
  restored as it was.
- TestKeptLevelsBoundTheAsk becomes TestNarrowedVendorLevelsAskAsBefore:
  a models.dev-known model narrowed to low-high is offered low..high and
  still sends xhigh, max and low as asked.
- gateway-routing.md, reference.md, the settings.go comment and spec's
  usage say so: narrowing is display-only, declared levels are fitted.

Run at this tree (base 4a3e07f1c):
- go test -count=1 -timeout 45m ./internal/gateway ./internal/provider
  ./internal/cli ./internal/settings: ok (gateway 386s).
- gofmt -l empty; go vet darwin, linux -tags nogui, windows clean.
- Broken by hand, each red: 4a3e07f1c's Efforts (TestNarrowedVendor-
  LevelsAskAsBefore: xhigh and max went as high; TestModelEfforts:
  [low high]); declared levels ignored (TestModelSpecReachesTheGateway:
  xhigh sent as xhigh with low-high declared).
- Every other p.Efforts caller (gateway fit, decide, classify, automode,
  rules, side effort) is on the request path and is back to its
  behaviour before 4a3e07f1c.

Not run: the GUI suite (no GUI file changed; the GUI reads entry
Efforts, which still carry the kept levels) and a full go test ./....
2026-10-24 05:51:22 +08:00
yetone 4a3e07f1cf model: magpie model spec sets a model's window, output, vision and levels at once
Dani Ariyanto on Discord (#feedback, 10-24): a custom provider's models
(kenari/*:free) had no window, reply limit, vision or reasoning known,
and there was no one place to say them.

  magpie model spec <provider/model>                 what it has, and whose each value is
  magpie model spec <provider/model> [--context <n>] [--output <n>] [--vision on|off|auto] [--reasoning <levels>|off|auto]
  magpie model spec '<provider>/*' --context <n> --output <n>
  magpie model spec <provider/model> --reset
  magpie model specs

It writes the stores magpie model context/output/images/efforts write
(providers.json contexts; settings.json modelOutputs, modelImages,
modelEfforts, modelReasonless), so every reader that went by those goes
by a spec: entryFor/EntryOf/Served, /v1/models, max_tokens, the GUI's
/api/providers badges and chips, and the agents' model lists. Every
part is checked before anything is written; a refused command writes
nothing. Agents are told once.

Readers that bypassed the stores and now honour them:
- provider.Efforts returns the kept levels, so the gateway fits a
  request to them (fitEffort): xhigh asked of a model kept to low-high
  goes as high. This reverses #92 (47e12df41), which narrowed only the
  lists handed out; docs/subsystems/gateway-routing.md says so.
- entryFor: levels given a model with none known make it Reasoning.
- gateway AutoVision picks by the user's ModelImages (seesAt).
- GUI gateway client: a reasonless model offers no level chips.

Run at this tree (base a93190ae1):
- go test -count=1 -timeout 45m ./internal/{provider,cli,gui,gateway,
  settings,tui,agent,catalog}: all ok (gateway 505s, agent 360s).
- GUI: gateway-*.test.cjs, model-reasonless, plugin-gateway, i18n-keys
  (25 files, both engines, the new file at 1100 and 420 in en, zh,
  zh-TW, ja, de): 225/225 pass. app.js untouched.
- gofmt -l empty; go vet darwin, linux -tags nogui, windows clean.
- Sandbox HOME, built binary, `magpie web` on 47821/47820 and a fake
  Chat vendor on 47811: before, kenari/glm-5:free had no window or
  levels; after spec 128k/16k/on/low-high, /v1/models said 128000,
  16000, image input, [low medium high]; max_tokens 100000 went as
  16000, xhigh as high, low as low; qwen-x with --reasoning off was
  sent no reasoning field; /api/providers had context 128000, output
  16000, images/imageSet, kept [low medium high], reasonless for qwen-x.
  A models.dev sync during the run (GLM-5 202752/131072) didn't move
  the spec; after --reset the vendor's values came back. Bad values,
  an unknown flag and --help wrote nothing (files hashed).

Rebased onto a6a3dbde8 (the ZCode mover's min, one line): at the
pushed head 5af093d8b's tree, ./internal/provider and ./internal/cli
-timeout 45m ok, and the spec tests in gateway and gui ok.

Broken by hand, each went red: AutoVision on raw sees; Efforts on the
full list; the Reasoning line removed; output, vision or context not
written; ParseLevels skipped; agents told twice; --context 0 taken;
help printing modelUsage; old client.js; the GUI named() image and
reasonless branches.

Not tried / not changed: no full go test ./... (another session's
full GUI suite was running). Codex's ChatGPT-model /models pass-through
and the Codex effort dropdown read catalog.Codex(), not a spec. The
TUI shows no spec badges. A Context-tab trace keeps the window it was
recorded with. Pre-existing and the same on origin/main a6a3dbde8: a
GLM-5 relay with no levels known has xhigh sent as high.
2026-10-24 05:31:59 +08:00
yetone a6a3dbde83 provider: the ZCode mover's min is 0.1.23, so a second gift plan's GLM-5.3 shows beside a spent one (01huadalang on Discord)
01huadalang's ZCode account has two gift plans, the 1024 Dev Day plan and
the new-user plan. Once the new-user plan's GLM-5.3 was used up the card
showed GLM-5.3 at 0 and never the 1024 plan's GLM-5.3. The plugin named
every bucket by its show_name alone and sent them in the balance's
order, so the account row's first two windows were the spent plan's and
the live plan's allowance sat in the tooltip under the same name.

Plugin 0.1.23 (magpie-community/plugins 1f8d38b) names each bucket after
its plan when there are several ("ZCode 1024 Dev Day · GLM-5.3") and puts
the buckets a request spends before those set aside. `npm view
@magpie-community/opencode-zcode-auth version --prefer-online` gives
0.1.23.

Run at this tree (origin/main a93190ae1 + this line): gofmt -l
internal/provider clean; GOOS=darwin, linux and windows go vet
./internal/provider ok; go build ./... ok; go test -timeout 45m
./internal/provider ok (89.7s). Plugin side: package tests 92 pass,
whole plugins repo 2375 pass, check.mjs ok; the new tests are red on
0.1.22's index.mjs.
Not tried: a real account with two active gift plans; the reporter's
own balance wasn't read.
2026-10-24 05:08:55 +08:00
yetone a93190ae19 agent: the Codex threads test names what its HOME still holds after removal (#3422)
TestCodexThreadsComeBackOffMagpie/disconnect went red once on macOS CI
(27a8255fd, run 40004148936) with "TempDir RemoveAll cleanup: directory
not empty", its own checks passing. It doesn't reproduce here: 40 runs
alone and three full internal/agent runs with a probe for late writes
were all ok, nothing written after the test. A cleanup registered before
the TempDir's now runs after its removal and logs each entry left, so
the next red names the writer.

Run: go vet ./internal/agent, gofmt; go test ./internal/agent -run
TestCodexThreadsComeBackOffMagpie -count=3 ok. Test-only.
2026-10-24 02:58:50 +08:00
yetone ea9454d2d8 usage: count two ids of one model as one, magpie model alias (SlouchyQuill507 on Discord)
A vendor names one model two ways (deepseek-v4.1-flash and deepseek-flash),
and Usage, Usage > Sessions and `magpie usage` showed two rows. Now:

  magpie model alias deepseek-v4.1-flash deepseek-flash
  magpie model alias deepseek-v4.1-flash            (what it is counted as)
  magpie model alias deepseek-v4.1-flash --reset
  magpie model aliases

kept as settings.json "usageAliases" {from: to}. Off until one is written.
Ids match as routing groups match them (provider.sameModel: vendor/ prefix,
case, "_", snapshot date), at every provider; a chain is followed to its
end; an alias to itself, a loop, or a flag as an id is refused. A loop
written into the file by hand counts each model under its own id.

Display only: requests, agents' model lists, /v1/models, routing groups,
Same as and prices never read it. Each call is priced by the id it was
made under and only then counted under the alias; the alias's own price
is never put on the other id's calls, and a merged row is priced only
when every id in it is. Applied in usage summarize/direct (Models
groups), the gateway sessions projection (alias read before
gatewayCache's lock; the cache key hashes usageAliases), and
sessions.List/Get/Find/Stats (read before storeMu/mu, merged into new
slices so the memo is untouched; ModelEffort rows merged too). A failed
settings.json read keeps the last aliases read, and SetUsageAlias refuses
to write over an unreadable file (EditUsageAliases under fileMu). The GUI
settings save carries usageAliases. No GUI control.

Not aliased: the Requests ledger's per-request model and its model
filter, which show each call's own id.

Run (worktree at f4640c0ae, rebased onto 2b4c0664e with no overlap):
- gofmt -l: clean. go vet ./... darwin, GOOS=linux -tags nogui, GOOS=windows: ok.
- go test -count=1 -timeout 45m (sandbox HOME) internal/usage,
  sessions, provider, cli, settings, gui, tui: all ok.
- Real binary in a sandbox HOME: two usage.jsonl calls priced $2 and
  $100 per M: `magpie usage` showed two model rows ($2.00, $100), and
  after `magpie model alias` one row, 2.0M, 2 calls, $102; the session
  row too. alias/aliases/--reset/loop/self output checked by hand.

Broken by hand, each red then restored:
- no alias in summarizeFrom: TestUsageAlias* red
- nil alias into the gateway projection: TestUsageAlias* red
- statsIn without aliasStats / List without aliasSession:
  TestSessionsCountAliasedModelsAsOne red
- merged usage row keeps Priced true: TestAliasStatsLeavesItsInputAlone red
- loop check off / self check by == / last-good read off / flag check off:
  TestUsageAliasRefusesSelfAndLoops, TestUsageAliasUnreadSettings,
  TestModelAliasCmd red
- GUI save drops UsageAliases: TestSettingsSaveKeepsWhatItDoesNotSend red

Not tried: the GUI pages in a browser (no app.js change; the Usage and
Sessions pages read the same rows), the full go test ./... before push,
Windows box.
2026-10-24 02:48:50 +08:00
yetone 2b4c0664ee update: the fake open in the relaunch test keeps -n on Linux
TestRelaunchOpenTriedAgain was red on ubuntu CI at 27a8255fd (run
40004148936): opened "<bundle> --args tray", want "-n <bundle> --args
tray". The relaunch passed -n; the test's fake `open` lost it. It wrote
its arguments with echo "$@", and ubuntu's /bin/sh is dash, whose echo
takes a leading -n as its own flag. macOS's sh is bash, so it passed
there. The fake now writes them with printf '%s\n' "$*".

Run: in Docker golang:1.26.8 (GOTOOLCHAIN=local, -tags nogui) the old
test fails the same way as CI and the new one passes go test
./internal/update -run TestRelaunch; on macOS go test ./internal/update
-run TestRelaunch passes. Test-only change, no release.
2026-10-24 02:47:28 +08:00
yetone a218946341 gateway: the text-calls tests keep what a run is told as it is written
TestClaudeTextToolCallsUnstreamed was red on macOS CI at 843417957
(run 39990171140): the reply was right, but told() came back empty. The
recorder read the run's stdin through an io.Pipe, whose Write returns
once the reader goroutine has the bytes, before that goroutine appends
the line, so the check could come first. The recorder now keeps each
line inside Write, with no goroutine.

Run: with a 20ms sleep injected before the old goroutine's append,
TestClaudeTextToolCallsAreMadeForReal, ...AskedOnce and ...Unstreamed
all failed; with the new recorder the text-call tests pass -count=20,
and go test ./internal/gateway -run Claude passes. gofmt and vet clean.
Test-only change, no release.
2026-10-24 02:33:54 +08:00
yetone 27a8255fd7 update: the Mac relaunch opens a new instance (open -n), not a reopen of the gone one (Linka on Discord)
Linka's log (Discord, macOS 27.0.1, v0.1.1308) shows the cause of the
"magpie stays closed after updating itself" report that molvqingtai also
hit with the screen locked. After the old process's "Termination
complete", open found LaunchServices still holding the gone app as
running ("Specified target process 41267 does not exist"), so it sent
that process a reopen Apple event (aevt/rapp) instead of launching the
bundle, and failed with -600 procNotFound ("LAUNCH: Launch failed in
CSUI"). The retries from fb23bca5c asked for the same reopen each time.

Fix (internal/update/update.go): relaunchOpen is `open -n <bundle>`,
with `--args tray` when no window was up. -n asks LaunchServices for a
new instance, so it launches the bundle rather than look for a running
one. The retries and f3eb92924's direct start of the bundle's program
stay as the backup, with relaunch.log.

A magpie that really is up still has one instance: the new process
takes internal/gui's instance lock (a flock on app-<hash>.lock, keyed by
the program's path), finds it held and hands over (runningAlready): a
tray start ends, a window start asks the running one to show its window.

Other opens, checked: OpenBeside (a95f0b83f, the handover restart) uses
open -n already, and when it never starts the new version the handover
falls back to Relaunch after helloWait. The Codex app restart
(673651e8d, internal/agent/codex_app.go) opens another app and is
unchanged, as are the link and `open -b` handovers in instance_darwin.go.

Tests: TestRelaunchOpen wants -n in both commands, and
TestRelaunchOpenTriedAgain's fake open records its arguments and wants
"-n <bundle> --args tray". fakeOpen names the .app argument in its -600
text rather than $1. Red by hand: with -n dropped from relaunchOpen,
TestRelaunchOpen failed for both commands and TestRelaunchOpenTriedAgain
failed with opened "<bundle> --args tray"; green with it.

Real run: a scratch Lock.app (LSUIElement, ad-hoc signed) whose program
takes the same flock as holdInstance and logs its args. Real
`open -n Lock.app --args tray` twice, 1.5s apart: the first got
args=[tray] and held the lock, the second got args=[tray], found the
lock held and handed over. With one instance up, a plain
`open Lock.app --args tray` exited 0 and started nothing (routed to
the running one), the shape of Linka's reopen. The scratch app was
unregistered from LaunchServices afterwards.

Run at 17a2b00ef plus this change: gofmt -l internal/ (clean);
go vet ./... (darwin); GOOS=linux go vet -tags nogui ./...;
GOOS=windows go vet ./...; go test -count=1 ./internal/update (ok).
Rebased onto f4640c0ae (sessions GUI only); go test -count=1
./internal/update ok again at the pushed tree.

Not tried: a real update with LaunchServices holding a stale
registration (Linka's case) or with the screen locked; the real magpie
binary under open -n (the handover's OpenBeside has run that way since
a95f0b83f).
2026-10-24 02:32:29 +08:00
yetone f4640c0aee sessions: an agent's folders are one list, newest first, the temporary ones folded at the end
The Sessions page drew each folder as a boxed group with its checkbox,
path and buttons always showing. Now it is one list, the way Finder's
recents read: a row says the folder's name, where it is (home as ~, from
the manage reply's new `home`), its newest session's title, when, and how
many. Temporary folders, the disk's root and apps' hidden folders under
home wait folded under Other folders at the end; a search or a session
opened from elsewhere unfolds them. Checkboxes and the Delete bar come
only with Select, and Done lets the pick go. Relocate project and Delete
all sessions move into a folder's ⋯ menu (hover, always on touch, and
right-click); Delete all asks in magpie's own dialog.

Asked for by the owner ("这个会话页面其实特别丑"), who approved the design.

Tests: sessions-folder-list.test.cjs (new) checks the order, the ~ path,
the fold and its count, Select/Done, the ⋯ menu's Delete all and its ask,
and no horizontal scroll, in Chromium and WebKit, en/zh/zh-TW/ja/de, at
1000 and 420px. The other sessions tests follow the ⋯ menu and Select.

Run at this head (rebased on 17a2b00ef):
- node --test, 37 GUI files (every sessions*/session*, i18n*,
  checkbox-look, account-mask-sessions, routing-session*,
  usage-session*): 493 pass, 0 fail.
- gofmt -l internal/gui: clean; go vet -tags nogui ./internal/gui: ok;
  go test -tags nogui ./internal/gui: ok (budgets included).
Not run: the whole GUI suite at this head. The last full run (183fa169b,
10-23) had its reds filed (#3402 to #3416 and earlier issues); none is a
sessions file. Not tried in the Wails window on a real machine's sessions.
2026-10-24 02:31:17 +08:00
yetone 17a2b00efb gui: the sidebar's open page moves from row to row on a spring, as iOS's selection does
The owner asked for the sidebar's pages (Providers, Routing, Gateway…)
to slide from one to the next like their sub-tabs do, "like iOS".

The open page's row is now marked by one shape (.nav-top-hl) that
navTopGo moves on a damped spring (NAV_SPRING: SwiftUI's response
0.42s, damping 0.84; navTopStep, four sub-steps a frame, dt capped):
- it sets off as the row is pressed, and comes back if the press
  leaves the row or the page refuses to be left;
- being physics, a press that changes its mind turns it with the speed
  it has, never a jump;
- it follows its row while Usage's tab list folds above it and lands
  where the row ends up;
- it is put in place, not sent, when the window opens on a kept page or
  the rows move under it at rest (ResizeObserver); away while Settings
  is open, it fades back in on its row; reduced motion jumps; the
  header's tabs keep their .thumb and draw none.
The rows give up their own ground (open, hovered, pressed) to it.
#nav is position: relative in the sidebar for it, so .seg's centring
left/top are reset (without that the whole list sat 105px right).

Tests:
- sidebar-glide.test.cjs (new): Chromium + WebKit, en + zh, 1024 and
  1440, plus 900 (header): at rest on its row and the list in the
  sidebar, no ground hovered, press sets off before release and comes
  back off the row, Providers→Usage→Agents by frames (≥3 moving
  frames, overshoot < 3px) landing on the row, Settings hides it and
  Routing brings it back, reduced motion jumps, no page errors.
  Broken by hand: without the left/top reset the list check goes red;
  before the "not seen yet" rule the boot slid from Agents (red).
- sidebar.test.cjs: a pressed page row no longer darkens itself (the
  shape comes to it); Settings still must.
- routing-idle-frame.test.cjs counted every self-asking rAF callback as
  Routing's loop, so navTopStep after the click read as 33 Routing
  frames. It now counts only callbacks no global holds (app.js's are
  globals; Routing's frame is in its plugin's scope). Broken by hand:
  Routing's loop made to always ask again → 4 red; green on main's
  assets and on this change.
- TestCoreScriptBudget: app.js 1,343,324 / core 1,535,084 with no room
  added; the sidebar is the window's shell, not a page a plugin can take.

Run:
- Full GUI suite at 183fa169b (this change on 3b10a403d), alone on the
  machine but at load ~216: 11942 pass, 104 fail. The 25 red files
  rerun at load ~10 on this change and on 3b10a403d: the same reds on
  both except routing-idle-frame (fixed above); plugin-card-update,
  segment-press-dialog and sidebar-overlay-scrollbar pass alone here
  (segment-press-dialog red alone on main: #3416). Reds on main, filed:
  #3402 #3403 #3404 #3405 #3406 #3407 #3408 #3409 #3410 #3411 #3412
  #3413 #3414 #3415; already filed: #3350 #3099 #3096 #3094 #3091
  #3104 #3001. codex-predictions and codex-auto-reset were red only at
  load ~216 and passed in both reruns.
- At the pushed head (rebased on f3eb92924): sidebar, sidebar-glide,
  nav-sub-unroll, side-toggle, side-width, header-relang,
  sidebar-tab-top, settings-tabs-stick, omarchy,
  sidebar-overlay-scrollbar, click-scroll, routing-idle-frame,
  plugin-card-update, segment-press-dialog, i18n-keys: 230/230;
  go test -tags nogui -run 'TestCoreScriptBudget|I18n|Docs'
  ./internal/gui: ok; gofmt -l clean.

Not tried: the real Linux app (WebKitGTK); this uses only rAF and
transforms, no view transition. Not run: the full Go suite (only
internal/gui's budget/docs tests; no Go code changed).
2026-10-24 02:21:45 +08:00
yetone a95f0b83ff gui: a restart to update hands the gateway to the new version (xuanwo on X)
Before, a restart to update ended the gateway, so it waited until no
agent request was in flight (#577). An agent busy for hours held the
update back, and Restart now cut its replies off. On a Mac and on Linux
the restart now starts the new version beside the old one and hands it
the gateway's listening socket. The new version takes every new
connection at once. The old one stops accepting, finishes the requests
it has (up to 15 minutes, as `make dev` already gave), then quits.
Nothing an agent sends is refused or cut short.

How (docs/subsystems/gui-shell.md, "A restart to update hands the
gateway over"):
- internal/handoff, new, darwin and linux. The old magpie opens a unix
  socket in a 0700 temporary folder and writes handover.json (fresh for
  2 minutes) in its config folder. The new one finds it, says Hello, and
  gets the listening socket by SCM_RIGHTS with the address, its pid and
  a callbacks socket. Only the same program (same path, same uid) is
  given it. When TMPDIR is too long for a socket path (sun_path is 104
  bytes on a Mac), the folder goes in /tmp (sockDir).
- gateway: Inherit/Listen serve on the socket given, and acknowledge
  once serving. HandOff gives the old one handedOffDrain (15m) instead
  of the 2s an ordinary end gives. A Claude Code run of the old magpie
  whose helper calls its tools on the port gets those calls passed back
  to the old one over the callbacks socket (forwardCallback, mcpCall,
  ownCallback). The bridge's turns are counted on their own
  (Busy.Bridge, BridgeLast).
- gui: restartInto calls beginHandover (OpenBeside `open -n` on a Mac,
  StartBeside for the binary on Linux). On the new version's ack, the
  old one hides its menu bar icon, panel, window and Dock icon (Mac),
  ends its backend, waits for its requests, and quits. OnShutdown
  leaves Codex's failover, the thread port and the install to the new
  one, which serves the gateway they point at.
- Never two on screen. Mac: the old one lets go of its instance lock
  just before giving the socket and takes it back if the handover
  fails, then hides on the ack. Linux: Wails holds the D-Bus name until
  exit, so the new one serves the gateway at once but puts its tray up
  only once the old pid has exited (awaitExit, 16m at most). Until
  then the old tray stays.
- What a handover can't carry: the subscription bridge's Claude Code
  turns live in the old process, so the restart still waits for those
  (restartBusy = blocking(Busy, true)), along with turns parked on
  tools. Every other request is not waited for. The update badge, the
  Updates page and Settings' "Restart automatically" say so, in every
  language in i18n.js.
- A handover that isn't made restarts as before: socket not opened,
  new version not started, no hello in 60s, no ack in 90s. Because the
  restart didn't wait for the requests in flight, it now waits for
  gatewayBusy to be idle (fallbackWait, 15m at most) before it quits
  and relaunches, so a failed handover never cuts a request.
- The overlap. The instance lock is handled as above. Both processes
  write: the sticky routing is flushed before the hand (FlushSticks),
  and files go through the existing locked or atomic writes. Counters
  (RPM, concurrency) are per process for the overlap (gateway-routing
  Constraints). OAuth refresh: the previous commit locks Codex's and
  the ChatGPT API's refreshes across processes. The rest were already
  locked or don't rotate (providers-accounts Constraints).
- Not changed: Windows (no SCM_RIGHTS; it restarts as before and still
  waits for idle, #577), `magpie web` (re-execs in place), and
  `make dev` (its own Handover). MAGPIE_NO_HANDOVER=1 turns it off.

Found by the sandbox run, fixed here: in run 2 the sandbox's long TMPDIR
made the socket bind fail ("bind: invalid argument"). The restart fell
back at once, cut the stream at chunk 6 (curl exit 18), and 4 of 381
requests got no answer over ~2s. Two fixes: sockDir (/tmp fallback), and
the fallback that waits for idle.

Tests (each red when broken by hand or on the old code):
- gateway/handover_test.go: TestHandedOverGatewayFinishesItsStream
  (drainFor without handedOff: "the old one ended with a stream in
  flight"; takeAck off: "the new one never said it serves").
  TestToolCallOfTheMagpieBeforeGoesToIt (mcpCall forward off: 404;
  ownCallback forwarding off: 401). TestInheritedForAnotherAddressIsLetGo,
  TestCallbacksSocketServesOnlyToolCalls, TestBridgeTurnsCount,
  TestSameAddr.
- handoff/handoff_test.go: TestHandOverListener, TestNoAckKeepsTheSocket,
  TestTakeOnlyAFreshOfferForThisProgram, TestCloseRemovesOnlyItsPointer,
  and TestOpenWithALongTemporaryFolder (red on the old Open: "bind:
  invalid argument").
- gui/handover_unix_test.go: TestRestartHandsTheGatewayOver, cross-
  process. The test binary re-execs as the new magpie. A stream through
  the old one finishes whole, requests during the restart are all
  answered, the next ones reach the new pid, and the old one quits only
  after its stream. On the old restart it is red: "quit with a reply
  streaming". TestHandoverNotMadeRestartsAsBeforeOnceIdle ("never says
  hello", "doesn't start") is red on the code before the fallback
  drain: "quit with a reply streaming" / "the restart didn't try to
  hand over".
- gui/handover_test.go: TestRestartWaitsForWhatAHandoverCantCarry,
  TestHandsOverOnlyWhereItCan.
- update/relaunch_open_test.go: TestOpenBeside,
  TestStartBesideWaitsForNothing.
- GUI: update-wait.test.cjs (the handover wording on the badge and
  page), update-restart.test.cjs (Settings' description).

Real run, Mac, sandbox (env -i, HOME and XDG_CONFIG_HOME in a scratch
folder, a long TMPDIR, MAGPIE_ADDR 127.0.0.1:63249, MAGPIE_UPDATE_FEED
pointed at a fake feed). The app is -tags production, ad-hoc signed,
bundle id com.yetone.magpie.sbhandover, built as 0.1.9001 and 0.1.9002.
autoRestart is on. A fake upstream streams 100 one-second chunks. The
real app found the update, downloaded and staged it, and restarted with
the stream in flight (run 3, at this change's tree before the rebase):
- 18:31:43, pid 59833 serves. 18:31:51, the new pid 60477 serves; v1
  logged "magpie 0.1.9002 (pid 60477) serves the gateway now".
- Requests: 375, failed 0. 19 were answered by 59833, then 356 by 60477.
- The stream got all 100 chunks, END and [DONE] at 18:33:24, curl exit
  0, 92s after the hand. 59833 exited within 3s of the stream's end.

Run at the pushed head (7a5bca443's tree, on origin/main f3eb92924),
one suite at a time, each log tee'd:
- gofmt -l internal/ cmd/: none. go vet ./... (darwin), GOOS=linux go
  vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -count=1 -timeout 45m: internal/handoff ok, internal/update
  ok, internal/gui ok (95s), internal/provider ok, internal/gateway ok
  (367s).
- TestCoreScriptBudget: app.js is 1,338,901 of its 1,338,929. My
  additions first went 372 bytes over after the rebase; the badge's two
  wordings now share one args object and the comments I added were cut,
  with no budget raised.
- GUI (NODE_PATH playwright 1.62.0, both engines): i18n-keys, every
  update-*.test.cjs (update-wait 22/22, update-restart 22/22, update-stuck
  40/40 among them), gui-de, gui-ja, gui-zh-tw: all pass.
- f3eb92924 (the Mac relaunch's exec fallback) landed under this. A
  handover that never gets its hello falls back to update.Relaunch, which
  now carries that fallback; OpenBeside keeps open's tries only, since
  the old one is still running then and the fallback follows.
- Linux, Docker golang:1.26.8 with -tags gtk3 (before the rebase): the
  handoff package, the gui handover tests including the cross-process
  TestRestartHandsTheGatewayOver, and the gateway handover tests pass.
- Full GUI suite at f09e9a066 (before the rebases, load ~250 from other
  sessions): 11958 tests, 61 failed in 22 files. 13 pass alone (fonts,
  plugin-updates, rail-tip, routing-keys-fold, routing-mode-goes,
  routing-model-rest, routing-rule-remove, routing-went-on, search-keys,
  segment-press-dialog, sidebar-overlay-scrollbar, usage-overview-fold,
  usage-pack); load reds of this kind are #3393. 9 fail the same on
  origin/main 843417957, each filed: library-mcp-health-wsl #3350,
  quota-count-wrap and quota-name-translated #2228, quota-reads #2150,
  s3-sync #2448, usage-agents-hide #2276, usage-checkin #2549/#3091,
  usage-fold #2163, usage-ledger #3104.

Not tried:
- Windows: unchanged by design, nothing to run there beyond vet.
- A real Linux desktop app. The tests ran in Docker (above); the D-Bus
  wait (awaitExit) was not seen in a real tray.
- Whether the menu bar showed two birds for a moment on the Mac. B's
  tray goes up as it starts, and A hides on the ack, which follows B's
  first listen. They are close, but not ordered, and I didn't capture
  the screen.
- The Mac's real bundle id and LaunchServices registration
  (com.yetone.magpie), the real signed and notarised update, and real
  accounts (the run used a fake upstream).
2026-10-24 02:20:38 +08:00
yetone 85cde4a4de provider: Codex and ChatGPT API refreshes lock across magpies
Two magpies can now run at once: a restart to update hands the gateway
over and the old one finishes its requests for up to 15 minutes (next
commit), and a magpie run from a terminal can sit beside the app. Codex's
auth.json and the ChatGPT API sign-in rotate their refresh token on every
refresh. Their refresh locks (codexMu, siwcRefreshing) were a sync.Mutex,
held in one process only. So both magpies could refresh with the same
refresh token, and the second got refresh_token_reused, which signs the
account out.

Both are now a filelock.Mutex beside logins.json (.codex.lock,
.siwc.lock). The sign-in is read again once the lock is held, so a magpie
that waited uses the tokens the other one wrote instead of refreshing
again. Claude's saved tokens, MCP servers' and plugins' were already
locked across processes. Google's, Vertex AI's and Copilot's refresh
tokens don't rotate. Docs: providers-accounts.md, Constraints.

Tests: TestCodexRefreshWaitsForAnotherMagpie and
TestChatGPTAPIRefreshWaitsForAnotherMagpie. Each holds the file lock as
another magpie would, mid-refresh, writes that magpie's rotated tokens,
then lets go. The refresh must return those tokens and send nothing to
the token endpoint.

Broken by hand: with both locks put back to sync.Mutex, both tests are
red ("refreshed 1 times beside another magpie").

Run: see the next commit's body. The provider package ran at the pushed
head with -timeout 45m.

Not tried: a real Codex or ChatGPT API account refreshing in two magpies
at once. The tests use fake token endpoints.
2026-10-24 02:11:14 +08:00
yetone f3eb92924e update: the Mac relaunch starts the bundle's program when open never works (molvqingtai on Discord)
molvqingtai (Discord, 10-24): on macOS, magpie's restart after a
self-update still leaves it closed on versions after fb23bca5c, and only
while the screen is locked. Their 10-22 log (v0.1.1314) had the old
process exit 0 and `open` of the bundle fail ~160ms later with -600
(procNotFound), LaunchServices still sending to the gone process.
fb23bca5c tried that open again for ~13.5s (8 tries), and the report
says that isn't enough: LaunchServices can go on refusing for as long as
the session is locked, and the relaunch had nothing but LaunchServices
to start magpie with. With magpie closed, Prevent sleep is off too: the
Mac sleeps and the agents lose their connection.

Cause, as far as it could be checked: every route back went through
LaunchServices. A locked session was not reproduced here (the screen was
never locked), so "refuses for as long as it is locked" is the report's
shape, not something observed.

Fix (internal/update/update.go): relaunchCommand is now relaunchScript
over openWaits. The same open with the same pauses runs first; once the
last try has failed, the bundle's own program (Contents/MacOS/<the
CFBundleExecutable its Info.plist names, else this one's name, else
magpie>) is exec'd by the helper shell with RelaunchArgs: `tray` when no
window was up, `gui` when one was. That is what the Open at login launch
agent runs (ProgramArguments: Contents/MacOS/magpie tray), so it needs
nothing from LaunchServices. The shell is runAfterExit's, in a session of
its own (#2362); `exec` makes it the new magpie, so there is no shell
left to exit and take it with it. The instance lock is a flock on a file
keyed by the program's path, the same for open and for this start, so a
late open from LaunchServices hands over to the one already running.

Each try is written to relaunch.log in magpie's own folder
(appdir.Config(), ~/.config/magpie on the Mac): "magpie has exited;
opening <bundle>", then per try "open try N: exit S <open's stderr on
one line>", then "open gave up after N tries; starting <program> <args>"
or "no executable at <path>". The file is moved to relaunch.log.old past
64KB. A missing log folder writes nothing and changes nothing else.

Tests (internal/update/relaunch_fallback_test.go), with fakeOpen from
relaunch_retry_test.go first on PATH answering with the -600 text and a
fake bundle whose program writes the arguments it got:
- TestRelaunchStartsTheBundleWhenOpenNeverWorks: through runAfterExit
  after a gone pid, open refused every time; the program runs with tray
  (no window) and gui (window), after len(waits)+1 opens.
- TestRelaunchLogsEachTry: the log has the opening line, each try's exit
  status with open's -600 text, and the fallback's program and args.
- TestRelaunchOpenedStartsNothingElse: open working on try 2 is the
  whole relaunch; the program isn't also run; the log says exit 0.
- TestRelaunchNoProgramIsLogged: a bundle without its program is
  logged and the shell exits non-zero.
- TestRelaunchRunsTheProgramInfoPlistNames: "magpie dev" from
  Info.plist, in a bundle path with a quote in it.
- TestRelaunchLogInMagpiesFolder: the log is under XDG_CONFIG_HOME's
  magpie, and is moved to .old past 64KB.
Red by hand: with the fallback replaced by the old `|| exit 1`,
StartsTheBundle timed out at 30s ("the new version starting never
happened"), and LogsEachTry, NoProgramIsLogged and
RunsTheProgramInfoPlistNames failed; with note() a no-op, LogsEachTry, OpenedStartsNothingElse
and NoProgramIsLogged failed. All green with the fix.

Real run: a relauncher built from this tree calling update.Relaunch on
a scratch Scratch.app (CFBundleExecutable scratch, a script writing a
marker), under env -i with a sandbox HOME and an `open` first on PATH
that always fails with the -600 text. The relauncher exited at once;
relaunch.log under the sandbox's ~/.config/magpie had 8 tries 02:02:45
to 02:02:59, each "exit 1 _LSOpenURLsWithCompletionHandler() ... -600.",
then "open gave up after 8 tries; starting '.../scratch' 'tray'". The
marker: args=tray ppid=1 pgid=pid (own group), no tty, and still alive
3s later, after the relauncher and its shell were gone.

Run at 843417957 plus this change: gofmt -l internal/ (clean);
go vet ./... (darwin); GOOS=linux go vet -tags nogui ./...;
GOOS=windows go vet ./...; go test -count=1 ./internal/update (ok).
The full suite (-timeout 45m) was started on this tree before the push
and had not finished; per the owner's ship-at-once rule this didn't wait
for it.

Not tried: a real update with the screen locked (the screen here was
never locked), so whether the program started by path comes up under a
locked session is not seen, only that the login agent starts it the
same way. Not tried with the real magpie binary in the scratch bundle
(it would read the Keychain): the tray and the instance lock under this
start are the login agent's path, not observed here. An open that exits
0 while magpie doesn't come up isn't covered; relaunch.log will show it.
2026-10-24 02:05:05 +08:00
yetone 843417957c provider: the ZCode mover's min is 0.1.22, so a Start Plan request goes with ZCode 3.16.3's headers alone (01huadalang on Discord)
01huadalang got the Start Plan's 405 again on plugin 0.1.21. A plugin
provider has no account of its own in the gateway, so Claude Code's own
headers (anthropic-beta, x-app, x-stainless-*,
anthropic-dangerous-direct-browser-access, x-claude-code-session-id)
and ?beta=true reached the plugin. 0.1.21 passed them on to zcode.z.ai.
The retired built-in never sent them.

Plugin 0.1.22 (magpie-community/plugins 57ec655) builds a Start Plan
request's headers from scratch, as ZCode.app 3.16.3 sends them: the new
x-zcode-query-source: main_turn, X-Os-Version as os.release(), and app
version 3.16.3. It also drops the URL's query. `npm view
@magpie-community/opencode-zcode-auth version --prefer-online` gives
0.1.22.

Run: go build ./..., go vet ./internal/provider, and go test -run
'Mover|Moved|Migrat|ZCode|Zcode|Min' ./internal/provider ok. Plugin
bun test (temp HOME): 90 pass.
Not tried: a real Start Plan account. Whether zcode.z.ai keys on these
headers is not established, and an IP block is still possible.
2026-10-24 00:50:49 +08:00
yetone a7ed2f61d9 antigravity: a model Google marks disabled is left out of the list (kwanyu on Discord: gemini-4-argon-disabled answered 404)
kwanyu picked an Antigravity model in DeepSeek Harness and every request
was a 404 "Requested entity was not found" for gemini-4-argon-disabled.
The id is not made by the Harness: its source (HEAD 22ddee379), the
bundled pi-ai 1.3.0 and dsh's patch add no suffix to a model id, and
magpie's gateway has no generic suffix either. It is Antigravity's own:
a real account's fetchAvailableModels lists gemini-4-argon-disabled with
"disabled": true (magpie's log: "disabled [gemini-4-argon-disabled]"),
and modelInfo kept every disabled model in the list ("still listed, as
before", since 7806395c7 only logged them). So magpie offered it to
every client, the Harness among them, and Google refuses it.

Now a model Antigravity marks disabled is left out of the list, as the
chat_/tab_ ids are, and the log still names it under "disabled". It
comes back on the first refresh after Google enables it. This is not
scoped to the Harness: the id comes from the list every client reads,
and no client can use it. Every other model's id, name and quota are as
Google sent them.

Tests: TestAntigravityDisabledModelLeftOut (the real ids beside
gemini-4-argon-disabled; gpt-oss with "disabled": false stays) is red
on the old code (the list had gemini-4-argon-disabled) and green now.
TestAntigravityProAccountNamesItsTier and
TestAntigravityProInvalidTierAsksWithoutOne listed their made-up
disabled claude-sonnet-5-5 and now count it left out.

Run: gofmt -l; go vet ./... on darwin, GOOS=linux -tags nogui, and
GOOS=windows; go test -tags nogui -count=1 ./internal/provider/ under a
sandbox HOME (ok, 103s).
Broken by hand: with google.go put back, TestAntigravityDisabledModelLeftOut
fails listing gemini-4-argon-disabled.
Not tried: a real Antigravity account refresh with this build, and
DeepSeek Harness's picker after it; Antigravity's own client's handling
of a disabled model was not read from its binary (not installed here).
A Harness profile written before keeps the id until magpie's next sync
of the Harness's models.
2026-10-24 00:48:04 +08:00
yetone b437e4adb4 settings: a proxy's username and password have fields of their own for every proxy, HTTP too (微雨南山 on Discord)
Settings > Proxy > Custom now shows Username and Password fields beside the
address for every proxy kind. Before, only a SOCKS5 address had them (the
password is masked). An HTTP or HTTPS proxy's login had to go inside the URL,
so a password holding @ : / % # or a space broke it. Each field is
percent-encoded (encodeURIComponent) when the address is saved.

The setting's format is unchanged: still one URL with the login as its
userinfo. A proxy saved before with user:pass@ loads into the fields. It is
split the way Go's url.Parse splits it (last @, then first :), so
"https://al%20ice:se@cr%23et@proxy.example:8443" shows "al ice" and
"se@cr#et". It is not split through WHATWG URL, which would add a "/" or drop
a default port. A part left as it was loaded keeps its own escapes, so
non-UTF-8 bytes survive. A login pasted into the address moves into the
fields. Describe, Redact and the status line already hid the userinfo
(#1886), and a new test checks that again.

Credit: 微雨南山 on Discord (#feedback), who asked for macOS-style
address / username / password fields after a special character in the
password broke the URL.

Tests:
- internal/netproxy/login_test.go: the login "me@corp:x" / "p@ss:w/rd% #1 x",
  saved as the page encodes it, reads back as typed. It signs in to a fake HTTP
  proxy (Basic Proxy-Authorization), and to a fake SOCKS5 proxy through both Go's
  transport and the plugin bridge's socksHandshake. It also reaches a CLI's
  HTTPS_PROXY. One character off is refused (407 / SOCKS fails), and Describe and
  Redact show no part of it. TestBunProxyLoginWithReservedCharacters signs in with
  the real bun 1.4.2's fetch({proxy}). These pass on the old Go code too: the Go
  side needed no change.
- internal/gui/tests/settings-proxy-auth.test.cjs, Chromium and WebKit, en zh
  zh-TW ja de, at 560 and 375px: an HTTP proxy has the fields, the login
  round-trips encoded and comes back decoded, the password is type=password, and
  the status hides it. A login saved in the address loads into the fields, and
  Enter on it saves nothing. On the old app.js both tests fail in every language
  checked ("an HTTP proxy has a username field / false !== true"; the address
  still showed 'https://al%20ice:se@cr%23et@proxy.example:8443').

Run:
- gofmt -l: empty.
- go vet (darwin), GOOS=linux go vet -tags nogui, GOOS=windows go vet: clean.
- Full Go suite at c7ad43426 through the suite lock (-tags nogui -timeout 45m):
  68 ok, one red, internal/gui TestCoreScriptBudget. The first app.js was
  1338904 bytes over 1338084. The helpers and comments were tightened (not the
  budget raised): app.js is 172 bytes under its parent. Then internal/gui,
  internal/netproxy and internal/settings: ok at the final tree. After the
  rebase onto c551a2299, app.js is 1,338,757 against the parent's 1,338,929.
  TestCoreScriptBudget, internal/netproxy and the two proxy GUI files (30/30)
  pass again.
- settings-proxy-auth + settings-proxy-remember: 30/30, and 30/30 three more
  times at load 60-150.
- Whole GUI suite: stopped after ~2h, at 11,507 passes, to free the suite lock.
  It ran beside two other sessions' GUI suites (load ~300). It showed 43
  top-level reds, whose errors were not printed because the run was cut short.
  Three were in the proxy files, and those passed alone afterwards. All are
  filed in #3393, not compared against origin/main.

Not tried:
- a real authenticated proxy, and the real app;
- Windows and Linux runs;
- how Codex's reqwest or other agent CLIs decode the percent-encoded *_PROXY
  login.
The plugin host's host.js proxyRefuses (auth only when there is a username,
and a decodeURIComponent that can throw), and the per-provider, account, key
and sign-in proxy fields that still take the login inside one URL, are filed
as #3382.
2026-10-24 00:02:02 +08:00
yetone a2e98cd799 gateway: a streamed Codex turn goes to ChatGPT over its WebSocket (brickhao)
brickhao on Discord: long Codex turns through magpie died with "stream
closed before response.completed". Their network (FlClash) cuts a
streamed HTTP reply from chatgpt.com at about 120 s: 120.7 s through
magpie, 121.5 s over HTTP without magpie. Codex's own WebSocket to the
same backend ran to the end twice (124.5 s, 131.4 s). magpie has no
120 s timer of its own (no WriteTimeout, 10 min to the first header).
The cut is on the leg from magpie to chatgpt.com, which was always
HTTP. Codex answers magpie's 426 by falling back to HTTP, and over
loopback that is harmless.

What changed: codexSocket, first in upstreamTransport, sends a POST to
CodexBase/responses with "stream":true over the backend's WebSocket, as
codex-rs does (ResponseCreateWsRequest, build_websocket_headers).
- Handshake: the turn's headers plus OpenAI-Beta:
  responses_websockets=2026-02-06. x-codex-turn-state and the
  responses-lite header go in client_metadata instead. The message is
  the body (zstd decoded) with "type":"response.create" ahead of it.
- Frames come back as the SSE the HTTP route sends.
  codex.rate_limits and codex.response.metadata are also given as the
  x-codex-* and x-codex-turn-state headers. websocket_timing is dropped.
- An error frame ahead of the reply becomes its HTTP status and body,
  so account rests and failover work as before.
- These go over HTTP: a refused handshake (and the host stays on HTTP
  for 10 min, unless the refusal was 401/429/5xx),
  websocket_connection_limit_reached, and a body that isn't a streamed
  turn.
- A socket closed before the end reads as a cut stream.
- Both Codex's own sign-in passthrough and magpie's ChatGPT accounts
  take this path. Codex identity, instructions and prompts are
  unchanged. coder/websocket is now a direct dependency (it was
  indirect).

Run:
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ok.
- go test -race -count=3 of the five new tests: ok.
- go test -timeout 45m at 1a5911612 (rebased on origin/main c551a2299),
  sandbox HOME: internal/gateway ok 760.9s, internal/agent ok 596.8s,
  internal/provider ok 172.5s. The rest of ./... was not run before the push.
- Real: a sandbox magpie (this tree, 127.0.0.1:3488, sandbox HOME and
  CODEX_HOME, a copy of the Codex access token with the refresh token
  blanked so nothing could rotate). A curl turn on gpt-6-luna came back
  200 with codex.rate_limits in the SSE (which only the socket sends)
  and the x-codex-* headers. Real Codex CLI 0.162.1 (codex exec,
  xhigh) through it: a 6121-word reply over 165 s ended whole, exit 0.
  Codex logged its own 426 from magpie and fell back, as expected.

Broken by hand:
- socket off in the tests: all four socket tests red (the reply cut
  before response.completed, no handshake, 200 not 429).
- error-frame mapping off: TestCodexSocketErrorIsItsStatus red.
- turn-state into client_metadata off: TestCodexTurnGoesOverWebSocket
  red.

Not tried:
- brickhao's network: this network doesn't cut at 120 s, so the 165 s
  turn shows the socket carries a long turn whole, not that it gets
  past their cut.
- A real turn on a magpie-saved ChatGPT account (fake only).
- Through an HTTP or SOCKS proxy for real.
- Windows/Linux runs.
2026-10-23 23:59:55 +08:00
yetone c551a22997 provider: the ZCode mover's min is 0.1.21, whose Start Plan request keeps ZCode's three system blocks (plugins #343)
zcode.z.ai answers a Start Plan request whose system has a fourth block
with 405/3012 "request has been blocked due to unusual activity", and the
plugin up to 0.1.20 sent the agent's system prompt as that fourth block,
so every agent was turned away on a Start Plan account (fordlyn). 0.1.21
(plugins 44036e2) joins it to the end of ZCode's third block, as ZCode
3.14.3's ContextBuilder joins every dynamic system section.
keepMovedCurrent brings every moved user's plugin up to it.

npm view @magpie-community/opencode-zcode-auth version --prefer-online:
0.1.21 (its tarball carries the #343 change).
Run: gofmt -l internal/provider (clean); GOOS=darwin|linux|windows go vet
./internal/provider/ (ok); go test -timeout 45m ./internal/provider/ (ok,
98.9s). Not tried against the real API: no Start Plan account at hand.
2026-10-23 23:26:13 +08:00
yetone fa22bc6467 cline: the Upstream tick holds Pass DeepSeek on DeepSeek with has, and leaves the plugin's to it
hy125245 (X, 10-23) found that providerOptions.gateway.only ["deepseek"]
alone does nothing on ClinePass: a fake upstream still succeeded. Adding
has ["vision","implicit-caching"] beside it routed the request to
DeepSeek (finalProvider deepseek, ~200-246 tok/s, creditsUsed 0) and made
a fake upstream fail with "no matching upstream".

Changed:
- The built-in ClinePass's Upstream tick now sends, for cline-pass/deepseek*,
  providerOptions.gateway {only:[deepseek], has:[implicit-caching]}, with
  "vision" first when the model takes images (live catalog) or the request
  carries an image part (messages[].content[].type image_url/image/
  input_image; the word in text does not count). GLM, glm-5.3-flash's
  OpenRouter provider.only and the client's own providerOptions/provider are
  as before.
- On the Cline plugin's provider the tick no longer pins cline-pass/deepseek*:
  opencode-cline-auth 0.1.11 pins them itself by default, with the has
  filter and one unpinned retry on "no matching upstream" or a 5xx, and it
  keeps a body's own providerOptions, so magpie's only alone would take its
  place. The plugin's GLM pin from the tick is unchanged.

Run at 03951798a (origin/main) plus this change:
- go build ./..., go vet ./internal/... (darwin), GOOS=linux and
  GOOS=windows go vet ./internal/gateway ./internal/provider, gofmt -l: clean.
- go test -count=1 ./internal/provider: ok (112s).
- go test -count=1 -run 'Cline|Plugin' ./internal/gateway: ok (53s).

Broken by hand, each red:
- the plugin provider pinned again: TestClinePluginPinsDeepSeekAndGLM;
- no has: TestClinePinsDeepSeekAndGLM, all three Pass DeepSeek models;
- vision always: the same test, text-only requests;
- an image found by substring: the "image_url in text" case.

Not run: the full go test ./... suite. The box is at load ~256 with about
ten sessions queued on it, so it went out on the touched packages. Not
tried: a real ClinePass request. There is no Cline sign-in on this
machine, so finalProvider, speed and credits are the reporter's numbers,
not measured here.
2026-10-23 22:28:52 +08:00
yetone 34f9686bd2 agent: dsh's desktop app is DeepSeek's own DeepSeek Harness; the community DeepSeek Hermes is not it
WuSix on Discord (Windows 11), on v0.1.1337: the desktop app still isn't
in magpie's Agents, and the repo 0c679c640 built on
(motongv/deepseek-hermes-desktop, "DeepSeek Hermes") is not DeepSeek's.
The official one is github.com/deepseek-ai/deepseek-harness.

What was wrong: 0c679c640 took a community Electron wrapper around
`dsh web` for the app WuSix runs, and listed dsh, wrote the web profile
and dropped dsh's key store for it. That is taken out whole (dshHermes,
the store switch, the web-profile app file, noticeDsh6 and its zh, zh-TW,
ja and de strings, the Running pattern, dsh_hermes_test.go). A user that
v0.1.1337 wired this way keeps profiles/web, which is dsh web's own
profile; the next Apply or Sync writes the key store again.

The official app, read from its source (deepseek-harness at 687f282e8,
dsh-v0.2.1-rc.2) and its real release files:
- apps/desktop/scripts/electron-builder-config.mjs: productName
  DeepSeek Harness, appId from DSH_DESKTOP_APP_ID; first config
  19444907f0 hard-codes com.deepseek.dsh. NSIS per-user
  (perMachine false), a folder the user may pick; installer.nsh writes
  HKCU ${INSTALL_REGISTRY_KEY} InstallLocation and refuses all-users.
- deepseek-harness-0.2.1-rc.2-mac-arm64.zip (sha512 as the feed
  download.deepseek.com/dsh-desk/feeds/mac-arm64/nightly-mac.yml says):
  DeepSeek Harness.app, CFBundleIdentifier com.deepseek.dsh, 0.2.1-rc.2,
  team NAN929V4UM.
- deepseek-harness-0.2.1-rc.2-win-x64.exe installed with /S on the
  Windows 11 box (26200): %LOCALAPPDATA%\Programs\DeepSeek Harness\
  DeepSeek Harness.exe, HKCU\Software\1bf39983-50d0-5fe0-9ef4-
  cece76f67c5e InstallLocation, Uninstall entry DisplayVersion
  0.2.1-rc.2, DisplayIcon <exe>,0. Nothing under HKLM.
- packages/util/home-paths/src/index.ts (defaultDshHome = ~/.dsh,
  DSH_HOME) and apps/desktop/src/paths.ts (profiles/desktop, "shared
  with npm-installed dsh"): the same ~/.dsh as the CLI on every OS.
- No Linux desktop build is published (UPDATE_TARGETS is mac-arm64,
  mac-x64, win-x64; dsh-latest-linux-x64.AppImage is 404); Linux has
  the npm CLI only.
magpie's desktopApps["dsh"] already had all of these (#2279, #2325);
the row is named DeepSeek Harness, the app's own name.

Run:
- Windows box, sandbox USERPROFILE/APPDATA/LOCALAPPDATA (Programs a
  junction to the real one, where the installer put the app), no ~\.dsh:
  the released v0.1.1337 magpie-cli-windows-amd64.exe and this commit's
  build both list "DeepSeek Harness ... ~\.dsh\profiles\desktop\
  cordis.patch.yml" in `magpie ls`. So on a default install v0.1.1337
  already listed it; what WuSix sees isn't reproduced. An unconnected
  agent sits under the Agents page's 未设置 (Not set up) fold; WuSix's
  screenshot and install folder are still to be asked for.
- macOS: the real 0.2.1-rc.2 .app in a sandbox HOME's Applications:
  HasApp true, version 0.2.1-rc.2, `magpie ls` lists it.
- New tests: TestDshOnlyTheOfficialApp (red on 0c679c640's dsh.go:
  "DeepSeek Hermes taken for DeepSeek Harness: detected true") and
  TestDshWindowsAsTheInstallerRegistersIt (the registry values above,
  and the GUID as UUID v5 of com.deepseek.dsh in electron-builder's
  namespace).
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- GUI: i18n-keys, agent-notice-lang, gui-de, gui-ja, gui-zh-tw: 34/34.
- Full suite: not run at push time (queued behind the suite lock;
  pushed per the owner's ship-at-once rule). TestDsh*, TestDesktop*,
  TestCLIMissing*, TestRegistered* rerun ok at the rebased head on
  origin/main 03951798a; the full run follows through the lock, reds filed.

Not tried:
- The real app opened (neither the .app nor the .exe was started), so
  no request from it through the gateway.
- WuSix's own machine: why their row doesn't show is still unknown.
2026-10-23 22:26:33 +08:00
yetone 03951798a1 gui: the sidebar's magpie sits 6px further from the traffic lights
The owner asked for a little more room between the Mac window's traffic
lights and the logo at the sidebar's top. .side-top's left padding goes
from 84px to 90px (still divided by --zoom, so it stays in points).

Run at this head: brand, side-width, sidebar, side-toggle,
header-zoom-fit and sidebar-tab-top GUI tests, chromium and webkit,
92/92 on three runs. The first run, at load ~290, had 6 reds whose
names were lost (only the log's tail was kept); the three runs after
it, logs kept whole, were green. Measured in WebKit at 2x: the logo's
left edge 84 -> 90px, and at the narrowest sidebar (168px) the name
ends at 163px, inside it.
Not tried: the real Mac app.
2026-10-23 22:23:54 +08:00
yetone 3b10a403d1 provider: WorkBuddy's mover asks for plugin 0.1.31, which renews a 401 once and says to sign in again
wenchen855443 on X reported that WorkBuddy requests return 401.
Plugin 0.1.31 (magpie-community/plugins f658842) handles a 401 on a
chat or a usage read like this:
- It renews the sign-in once, whatever the token's time, and sends the
  request once more. A token another process saved since is used
  first; a desktop sign-in re-reads the app's file instead of renewing.
- If there is no new token, or the retry is refused too, it answers 401
  with a message to sign in again: Providers → WorkBuddy → this
  account's Sign in again.
- It sends X-Magpie-Sign-In: expired only on WorkBuddy's word that the
  sign-in is gone: the refresh token was refused, or the token got
  invalid_token with nothing to renew it with.

Only the min changes. keepMovedCurrent brings every moved user's plugin
up to it.

The min is the version npm has at landing: npm view
@magpie-community/opencode-workbuddy-auth version --prefer-online gives
0.1.31. The publish run (39967751526) is red only for think-tags' known
E404 (plugins#180); its log shows + ...workbuddy-auth@0.1.31.

Run (rebased on origin/main, run again after the rebase):
- go test ./internal/provider/ -run
  'Mover|Moved|Min|Migrat|Move|WorkBuddy|Retir|Plugin' -count=1, with
  a scratch HOME: ok.
- gofmt -l internal/provider: clean.
- GOOS=linux and GOOS=windows go vet ./internal/provider/: ok.

Not tried: the full suite. The change is one string on the min line,
and the mover and plugin guards above cover it.
2026-10-23 22:19:19 +08:00
yetone ade2f06288 gui: a new partner's tile in the add sheet keeps a small dot until it is opened
yetone asked that a new partner's card carry a dot too, small and quiet:
"有了新的合作方、供应商,它对应的Card上应该也有小点来提醒一下用户…不要太打扰
用户,也不要太丑". The dot on the + button (05b596587) goes once the sheet
shows the partner, so the sheet itself said nothing about which tile was
new.

Each partner still new (p.new, not added) when the sheet first shows it
gets a 6px accent dot after its name, the same dot and colour as the +
button's. It scales in and rings once, then rests; a hidden sheet's
animation would start over on showing, so the dot drops .in when its
ring ends, and a tile drawn again doesn't animate. Reduced motion: none.
Opening the tile spends the dot. The set lives for this run of the GUI,
since p.new is spent on the server once the sheet showed it. The dot is
role=img, labelled "New" (zh/zh-TW 新, ja 新着, de Neu).

app.js grows 850 bytes, in the add sheet, the core's own; the budgets
are raised by exactly that, with no room added.

Run at 7e0c03105, then rebased on 91b0be836 (the routing plugin only,
outside the core budget), where go test ./internal/gui -run
'Budget|Asset|I18n' is ok:
- partners.test.cjs, chromium and webkit, en/zh/ja/de at 900 and 440,
  with new cases for en and zh at both widths: the dot on Acme only in
  en (China Only is zh-only), on both in zh; 6px, painted, inside its
  tile, labelled; still there after the sheet closes and opens; no .in
  on a dot drawn again; gone from Acme after opening it, in the sheet it
  folds back into and in the sheet opened again: 30/30.
- Broken by hand (the dot never appended): 10 of 30 red, the new cases
  in both engines.
- i18n-keys, gui-ja, gui-de: 9/9.
- go test ./internal/gui: ok (TestCoreScriptBudget red at 1,339,300
  before trimming comments and raising the budget).
- gofmt -l internal/gui: clean.

Not run: the whole GUI suite (850 files). Only partners.test.cjs gives
a partner new, and the dot draws only for one. Not tried in the real app.
2026-10-23 22:15:50 +08:00
yetone 91b0be8363 routing: a group's row opens into its editor and folds back in motion, and Save shows it
The owner asked (10-23) for iOS-like motion when a routing group opens and
folds, and for a save animation. drawGroups now measures each slot (a
group's row or its editor, data-gslot) before replaceKeeping and, where a
slot changed between row and editor, animates its height from the old one
to the new: opening on SPRING (570ms) with the editor's parts coming in
staggered from 6px above, folding on IOS_EASE (420ms) with the row's
content fading in. A new group's editor grows from nothing. Save shows a
spinner while the gateway saves; the saved row folds from the editor's
height and lights up, with a check that pops in by its name and goes
after ~1.5s. With reduced motion asked for nothing moves.

Folding from the editor's foot (where Save and Cancel are) would let the
browser clamp the shorter page and leave the row above the window
(WebKit showed it). foldInSight moves the page up with the fold, step
for step with the slot's height, as the reader's scroll; groupAction's
own keep-the-saved-row-in-sight check is skipped when the fold did it.

Run at this head (rebased on origin/main), Chromium and WebKit:
- group-morph.test.cjs (new): en, zh, zh-TW, ja, de at 1100 and 420px;
  the editor grows from the row's height, the row folds from the
  editor's, Save spins, the saved row folds from the editor's height
  with its check, the row is in sight after each fold; reduced motion
  has no height animation.
- routing-save, group-fold, routing-group-fold, routing-save-blank,
  routing-save-keeps-the-row, group-editor-align, group-editor-fits,
  i18n-keys.
- go test ./internal/gui -run 'Budget|Plugin|Asset': ok.
Broken by hand: without morphSlots the new test is red ("the editor grows from the row's 57px, not null", Chromium); without foldInSight it is red in WebKit ("the folded row is in sight").
Not tried: the real Linux (WebKitGTK) app.
2026-10-23 22:13:00 +08:00
yetone 7e0c031059 provider, gateway: the magpie serving the gateway fetches the partner list every hour, asked for or not
yetone: 改成后台每小时定时请求一次. Until now the list was fetched again
only when the Add sheet or the TUI asked for it, so an app left open on
another page never learned of a partner added.

KeepPartnersFresh runs beside the gateway's other Keep* loops: it
fetches when the gateway starts, then whenever partnerNext is due (an
hour, ten minutes after a failed fetch). It shares Partners'
one-fetch-at-a-time flag, so it never runs beside a fetch a page
started; while one runs it looks again a second later. Partners and
PartnersNow keep their own due check for a magpie that doesn't serve
the gateway (the CLI, a TUI beside a running app). MAGPIE_PARTNERS=off,
and every test (partnersSource), still asks nobody.

Run at this tree (base d3f3df746):
- go build ./..., GOOS=linux and GOOS=windows go vet of internal/provider
  and internal/gateway, gofmt -l clean.
- go test ./internal/provider -count=1: ok (94s).
- go test ./internal/provider -run Partner -count=3 -race: ok.
- Broken by hand: KeepPartnersFresh returning at once makes
  TestPartnersKeptFreshUnasked fail ("fetched on start").
Not tried: a real app left running for an hour against usemagpie.ai;
the internal/gateway suite (only a goroutine added to ListenAndServe).
2026-10-23 21:45:32 +08:00
yetone d3f3df746e routing: the page's head has Routing groups, which brings the groups at the page's foot into view (shihh on Discord)
The routing groups sit below the stage, the story and every request; with
many models (shihh on Discord) they are a long scroll down. The Routing
page's head now has Routing groups (#rtGoGroups) beside New group: a down
arrow, its name, and a tooltip saying where they are. Its click goes
through scrollOnPurpose, brings .rt-gsec to the top of the view and moves
the focus into it. The page's layout is unchanged (no #1354-style move):
the groups stay last in #rtMore. fitGo gives the button only the head's
spare room (the .grow spacer): named, its arrow alone (still named to a
screen reader), or left out, so nothing else in the head moves or wraps.
Strings in zh, zh-TW, ja and de. app.js untouched (plugin files only).

Test: routing-groups-jump.test.cjs, Chromium and WebKit x en/zh/zh-TW/ja/de
x 1000px web, 480px web, 640px window: 30/30. It is red on main's assets (no
button), red with the scrollOnPurpose check removed (the app's guard pulls
the view back), red without the focus move, and red with fitGo removed
(de at 480px web: Hide accounts moves).

Run at this change on 50f52b540 (de281760e, rebased under it, touches only internal/gateway):
- go test -tags nogui -timeout 45m ./...: 69 packages ok, no FAIL
- gofmt -l: clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: ok
- TestCoreScriptBudget and the other budget tests: ok
- GUI files the change can reach (routing*, group*, i18n-keys,
  click-scroll, title-bar-tools; 125 files, both engines): 1495/1495

Not run: the whole GUI suite. Another session's full GUI run held the
machine for 2h45m+, and this touches only the routing plugin's files.
Not changed: on a phone the web head already shrinks to its 40px
min-height on main, so wrapped buttons slide under the first card (Hide
accounts at 360px in German). Where the head has no spare room, the button
is left out rather than wrapped.
2026-10-23 21:37:16 +08:00
yetone de281760e2 gateway: a conversation going round one tool call with the same result is answered by magpie after 8 turns (audie on Discord)
audie on Discord: on 10-21 Codex Desktop, routed to WorkBuddy's
deepseek-v4-pro, ran the same read-code tool call 308 times between 13:24
and 13:52 (316 requests, 212.65 credits). That evening it did it 340 more
times between 19:58 and 20:22 (343 requests, 324.52 credits). loopGuard
only catches a loop inside one streamed reply. Here every reply was a
short, valid call. The loop runs across turns, so it shows in the
request's own history.

stoppedToolLoop (internal/gateway/tool_loop.go) runs in serveAgent after
the session is recorded and before hooks, middleware and routing. It also
runs in the Codex backend's passthrough on Codex's own ChatGPT sign-in. It
needs the last 8 turns to be the same exchange:
- the same calls: name plus arguments, key order ignored, call ids ignored;
- answered with the same results: text, error flag and images, with
  Codex's "Wall time", "Chunk ID" and "duration_seconds" taken out
  (runNoise);
- with nothing else said on the user's side.
When it finds one, it answers the turn in the agent's own protocol,
streamed or whole (Responses, Chat, Anthropic, Gemini through
relayStatus), with a notice that names the call. Nothing goes upstream, and
no prompt, base_instructions or identity text sent to a vendor changes.
A different result, or any word from the user, starts the count again.
The notice is a turn without calls, so the user's next message carries
on. The check keeps no state, so it is per conversation, and a retried
request doesn't count twice.

The turn is recorded the way Codex's title turns are. sentNowhere's body
becomes answeredHere (from-protocol aware): the Routing trace shows "Tool
loop stopped", and a usage row has provider magpie, rejected, the
conversation's session and native session, and an error starting
"tool loop:". So Usage and Sessions both show why.

Cost: a body with fewer than 8 tool results isn't parsed (a
bytes.Count). For a longer one, only the newest 64 items are parsed,
found with gjson (tailOf). For a 1.5MB Codex turn that is 1.1ms and
2.5MB, against 30ms and 20MB for a full parse (BenchmarkToolLoopCheck).

There is no new setting. Settings › Models › Replies › Stop looping
replies (noLoopGuard, on by default) turns this off together with the
reply guard, and the notice says so. The GUI sub-text is unchanged.
docs/subsystems/gateway-routing.md has a bullet on it.

Run at this commit (vet/build/race at parent bf2e067ef; the full suite
after the rebase onto 50f52b540, at 558b21b7e):
- gofmt -l clean.
- go vet ./... on darwin, GOOS=linux go vet -tags nogui ./..., and
  GOOS=windows go vet ./....
- go build on darwin, linux (-tags nogui) and windows.
- TestToolLoop* and the Codex title/description/prediction tests under
  -race (TestToolLoop* -count=3).
- The tests, in a sandbox HOME against fake vendors:
  - TestToolLoopIsStoppedOnEveryProtocol: 60 poll turns then 8 Codex
    reads with a varying chunk id and wall time, on Responses (stream and
    whole), Codex's backend path, Chat (stream and whole), Anthropic
    (stream and whole) and Gemini. The vendor is asked 0 times, the
    notice and the protocol's done marker reach the agent, and the usage
    row is magpie, rejected, "tool loop", with the session.
  - TestToolLoopStoppedOnCodexsOwnSignIn: gpt-5.5 on the passthrough,
    with a fake CodexBase.
  - TestToolLoopShortOrOffGoesOn: 7 turns, and 40 with the setting off.
  - TestToolLoopLetsProgressBy: 200 polls whose answer moves, and a loop
    followed by the notice and a word from the user. Neither is stopped.
  - TestToolLoopSums.
- Broken by hand, each red, each restored:
  - The guard skipped: every protocol subtest and the Codex sign-in test
    fail ("the agent wasn't told of the loop").
  - runNoise removed: the same tests fail, plus TestToolLoopSums.
  - Results left out of the sum: every progress subtest fails ("a poll
    whose answer moves was stopped").
- Full suite: set -o pipefail; go test -tags nogui -timeout 45m ./...
  through suite-lock, in a sandbox HOME, at 558b21b7e on 50f52b540:
  exit 0, 69 packages ok, no FAIL (internal/gateway 854s, internal/agent
  812s, internal/provider 393s, internal/gui 291s).
- No GUI file changed, so the GUI suite wasn't run.

Not tried:
- A real Codex Desktop or WorkBuddy loop, or any real account. The
  fixture's shape is Codex's exec_command output; audie's literal bytes
  weren't available.
- The Windows box.
- Codex over websocket (magpie answers it 426).
- Responses conversations that use previous_response_id. They carry only
  the newest turn, so they are never stopped.
- Loops with more parallel calls a turn than fit in 64 items.
- A poll that gets the same answer 8 times in a row is stopped too. The
  user's next word, or the setting, carries on.
- dsh's two ~1M-token requests to DeepSeek on 10-23 are a different
  problem, not addressed here.
2026-10-23 21:36:51 +08:00
yetone 50f52b540b redact: a text masked for a vendor before is masked as it was then, so a cached prompt stays cached
With Privacy masking on, a value masked once is "known" and masked
wherever a later request has it (redact/known.go). When a rule first
finds a value in a later turn (a tool printing DB_PASSWORD=...), that
value was masked from then on in the system prompt and the turns already
sent with it as written. The prefix the vendor had cached changed, so
the whole prompt was written to the cache again and none of it was read.

Reported by audie on Discord: DeepSeek Harness on a routing group served
by a custom Anthropic-compatible provider. Adjacent turns 10s apart had
cache_read 0 and cache_write 412K to 427K.

Fix: Mask and MaskJSON (the vendor-bound paths, via masking.Masker) now
use sentKnownSpans. A text masked before gets the known values it had
the first time, keyed by a sha256 of the text and the options. Only
hashes and spans are kept, never a value, in two generations of 65536.
New text still gets every known value masked. Scrub (archives, sessions,
OTel; local only) keeps the latest known set.

Unchanged: if magpie restarts, or a text falls out of both generations,
the text is masked under the current known set once, as before.

What was run:
- internal/redact TestSentTextKeepsItsMasking and internal/gateway
  TestMaskedConversationKeepsItsCachedPrefix. The gateway test sends a
  dsh-shaped Chat Completions conversation to a group with an Anthropic
  member, and a Claude Code-shaped /v1/messages one. It checks that each
  turn's system, tools and earlier messages reach the fake upstream byte
  for byte. Both tests are red with sentKnownSpans forced back to
  knownSpans: the system prompt became "{{SECRET_...}}" on turn 3. Both
  are green with the fix.
- With masking off, a probe of the same dsh shape had the system, tools
  and earlier turns byte-identical on every turn.
- gofmt -l: clean. go vet: darwin, GOOS=linux -tags nogui ./...,
  GOOS=windows ./...: clean.
- Full suite at 8187919d7 (this tree, on origin/main bf2e067ef):
  set -o pipefail; go test -tags nogui -timeout 45m ./..., through the
  suite lock. 69 packages ok, none red (gateway 519s, agent 393s).

Not tried: audie's real setup. Their Privacy setting isn't known; with
masking off this is not the cause, and every breakpoint reading 0
(even the unchanged system block) points at the provider's own cache or
pool. Not tried against a real Anthropic or relay account. GUI not
touched, so the GUI suite was not run. Windows tests not run.
2026-10-23 20:53:53 +08:00
yetone bf2e067ef6 gateway: a Codex account with credits is asked again at its allowance's edge, never benched (豆子, Zhenzhen)
Two Discord reports about ChatGPT accounts left to spend their credits
(the default):
- 豆子: an account whose allowance is used up but which still holds
  credits got a long rest. It should go ahead of accounts with neither.
- Zhenzhen: a Pro lite account ran out mid-session and the running
  session failed with "usage exhausted", while a new session worked.

The cause: when a window fills, ChatGPT can answer that turn 429
usage_limit_reached before it spends the credits, and serve the next
turn on them. magpie took the 429 as quota. On the routed path it
rested the account until the window renewed (candidate.full drove
those rests). On the relay (Codex's own sign-in) it passed the 429 to
Codex, which ended the session.

- /wham/usage's credits (has_credits with a balance over 0, or
  unlimited) are now read into QuotaWindow.Credits, Limit.Credits and
  Allowance.OnCredits.
- Routed path: a 429 quota refusal from such an account (and one let
  spend them, CodexCredits) is asked again at once, once per request,
  before a reset is looked at (creditsAgain, Try.Credits). If it is
  refused again, it rests fallbackCooldown (Rest.By "credits") and its
  usage is read again. full() is zero for it, so a full window rests it
  nowhere else (spendsCredits).
- Relay: the same ask-again, once (relayOnCredits).
- Order: Smart, Pace and Least used put a credits account first of the
  98%+ tier (Seat.Credits, spentBefore). That is after accounts with
  allowance left and ahead of those with nothing left.
- Routing page: says why such an account went first or where it waits,
  tells the asked-again try ("{n} used · on credits"), and the "credits"
  rest. Strings in zh, zh-TW, ja and de.
- Not a plugin path: Codex has no plugin.

Zhenzhen's suggestion to switch to credits early (~3% left) was weighed
and not done: the vendor spends credits only once the allowance is used
up, so switching early only wastes what is left. Retrying at the edge
keeps the running session alive. Codex identity, base_instructions and
prompts are untouched.

Tests, each red on the old code (the GUI test against the old
client.js, the Go ones with spendsCredits/relayOnCredits forced false
or the old strategies.go):
- TestCodexCreditsAskedAgainAtTheEdge: relayed, routed, set not to
  spend. Fake ChatGPT backend that refuses the edge turn and then
  serves on credits.
- TestCodexCreditsNoLongRest: refused again gets a rest of at most
  fallbackCooldown; a 500 gets backoff; no credits keeps the long rest.
- TestCodexCreditsFirstOfTheSpent (gateway) and TestCreditsFirstOfTheSpent
  (routes, Smart/Pace/LeastUsed).
- TestCodexCreditsBalance gains the onCredits column.
- routing-codex-credits-again.test.cjs: en/zh/ja/de, Chromium and
  WebKit, 8/8.

Run at this head (rebased on origin/main e96d577f2):
- gofmt -l clean.
- go vet ./... on darwin, linux (-tags nogui) and windows.
- go test -tags nogui -timeout 45m ./...: 69 packages ok, exit 0.
- GUI: routing-*.test.cjs, panel-routing-*, codex-credits, plan-credits
  and i18n-keys (103 files, both engines), before the rebase. 1251 of
  1253 passed at load ~50-70. The two reds each pass alone (3 of 3):
  routing-effort-change, filed as #3376, and routing-model-rest, #2115.

Not tried:
- The real ChatGPT backend. The 429 at the edge is inferred from
  Zhenzhen's report; no account was run out live.
- The live x-codex-credits-* response headers are not read.
- A workspace plan still within its overage is not treated as on
  credits.
- Affinity between two credits accounts is unchanged.
2026-10-23 20:11:17 +08:00
yetone e96d577f28 gui: Privacy's kept-from-vendors card, redrawn (the owner's Night design)
The card Settings › Privacy opens with ("没让厂商看到的") is redrawn to
the design the owner approved: quiet, the same background and 1px line
as every other card, no shadow, no gradient, and no shield in the head.

- The number of values masked, in full (5,812, not 5.8K), large and
  thin, with Different values, Requests (and Held back / Sent as written
  when there are any) on hairlines beside it, over the days' bars.
- From the agents, through this computer, to the providers: a hairline
  per share of each agent's values, uneven on the way in, even on the
  way out in the accent, crossing a ticked line under the shield, with
  a value (round) and a placeholder (square) moving along them, on a
  dot grid. Drawn in the middle's own pixels on every resize.
- The latest request with lines: what the vendor saw, placeholders
  marked; "As written here" swaps in each value from this magpie's
  memory (/api/masking/value, asked only then, never written down).
- What was kept and what found it, beside the values masked most as a
  ranked 01-08 list with a hairline share; pointing still shows the
  value, a click opens its records.
- Each part rises out of a blur in turn on first draw; reduced motion
  turns the moving parts off.

New strings "Different values", "As written here" (zh, zh-TW, ja, de);
"On this computer" is the library plugin's key, so not reused. The
seven strings only the old card used are removed from i18n.js.

app.js stays under its budget with no raise (1,338,079 <= 1,338,084):
the dot grid is a CSS mask, the lines' dash array is CSS, and the
redraw's own code was tightened until it fit.

Tests:
- masking-records: waits for the hairlines, checks the card has no
  box-shadow, and toggles the latest request to "As written here" and
  back (the value shown, a forgotten one greyed, the marks back).
  Viewport 1800 tall so the clicks don't scroll the page.
- mask-actions and privacy-model: the taller card pushed their rows out
  of the viewport (mask-actions at 640px de, privacy-model's model row
  in WebKit), so they wheel to the row first, as reach-based tests do.
  Both were red on my change and green on its base 0815c9186 before
  the fix.

Run at this head (rebased on origin/main 0c679c640; its only GUI change is i18n.js, so i18n-keys and the budget were run again there, ok):
- GUI, both engines, every file that reaches Privacy: 16 files, 249 pass, 0 fail.
- go test ./internal/gui -run Budget: ok.
- Screenshots of the card in Chromium dark/light and WebKit dark at
  1100 and 640px, compared with the design.

Not tried: the real Linux (WebKitGTK) and Windows apps; the whole GUI
suite (only the 16 files that reach Settings › Privacy).
2026-10-23 19:48:55 +08:00
yetone 0c679c6404 agent: DeepSeek Hermes, dsh's web UI in a window, is found and wired as dsh
WuSix on Discord: magpie's Agents page didn't find the "DeepSeek Hermes"
desktop app, so its models were added in the app by hand.

DeepSeek Hermes is motongv/deepseek-hermes-desktop 1.0.0, an Electron
window around `dsh web` (not Nous Research's Hermes Agent). Read from its
real release files: the macOS zip's Info.plist (bundle id
com.deepseek.hermes.desktop, 1.0.0) and the Windows NSIS installer's
header (InstallLocation under HKCU/HKLM Software\df9f5892-ad1c-5623-a260-
30fb0acc7e55, default %LOCALAPPDATA%\Programs\DeepSeek Hermes\DeepSeek
Hermes.exe). Both bundle @deepseek-ai/dsh 0.1.0-rc.6, which boots the
`web` profile in ~/.dsh (DSH_HOME). There is no Linux build.

Before: with no dsh CLI the dsh row was 未找到 CLI with its settings
hidden, an unopened app wasn't found at all, and a pick would have made
DeepSeek Harness Desktop's profiles/desktop, which Hermes never reads.

Now:
- desktopapp: installed() also takes the Windows exe under the app folders
  or the registered InstallLocation; HasApp uses it.
- dsh: DeepSeek Hermes counts as dsh's app. With it (and no Harness
  Desktop) magpie writes profiles/web/cordis.patch.yml and the key in .env
  only. rc.6's dsh-credentials-local reads only the flat store and refuses
  to start on the version 1 .credentials.yaml magpie writes for Harness
  Desktop ("the value for "version" ... must be a string"), so that store is
  not written, and one magpie wrote before (nothing but its key) is
  removed. A store with the user's own keys is left alone. With Harness
  Desktop also installed, its profile and store are used as before.
- noticeDsh6 for an unopened Hermes, in zh, zh-TW, ja and de.

Run:
- Real rc.6 in a sandbox HOME (npm --before=2026-08-17), never the live ~/.dsh:
  - `dsh -p headless` with magpie's route and the key in .env only against
    a fake gateway: POST /v1/chat/completions, model deepseek/deepseek-chat,
    Bearer key, answered.
  - With magpie's v1 store: `dsh web` exits on the error above; without it,
    it boots.
  - A web profile holding only magpie's cordis.patch.yml, `dsh web
    --dump-config`: rc=0, dsh added package.json, cordis.yml and
    pnpm-workspace.yaml, the patch was byte-identical after, and the
    composed config has the magpie route, agent-default-model and
    web-search-deepseek.
- New tests TestDshHermesFound/Windows/Wired. On the old code (0815c9186)
  all three are red: "never opened: detected false", "under Programs not
  found", "the web profile magpie made". The opened-with-no-CLI step alone
  is red too ("opened: detected true, CLI missing true").
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- GUI: i18n-keys, agent-notice-lang, gui-de, gui-ja, gui-zh-tw: 34/34.
- Full suite: set -o pipefail; go test -tags nogui -timeout 45m ./... at
  this commit on origin/main a77b5b4fc: 69 packages ok (internal/agent
  420s, internal/gateway 567s, internal/gui 159s), no FAIL.

Not tried:
- The real app itself (neither the .app nor the .exe was run); detection
  is from the release files' bytes.
- With both Hermes and Harness Desktop installed, Harness's v1 store still
  stops Hermes's rc.6 from starting; magpie keeps the store Harness needs.
  A user's own v1 store does the same, which isn't magpie's to change.
- The Windows run on the Windows box.
2026-10-23 19:35:50 +08:00
yetone a77b5b4fc9 gui: Check in now says what the press came to, not "refreshed" (#3326)
Promised to connoryang331 on #3326: a press of Check in now said "Check-in
status refreshed" whatever happened. It now says, in the same toast, a
count per kind (checkinPressSaid): "Claimed: 1 (+200 credits)",
"Already checked in today: N", "Not available yet: N" (inactive,
ineligible, or an "already" magpie asks again), "Check in in its own app:
N" (captcha, Trae's 9074), "Check-in failed for N account(s)" (red, as
before). No layout change. en, zh, zh-TW, ja, de.

A result counts as claimed now only when the vendor was asked on this
press: WorkBuddyCheckin.Asked is now sent as "asked" (omitempty). It is
still never kept: checkinNow writes the file before setting it. An
account claimed earlier today, settled and not asked, counts as already.
The TUI and CLI already say each account's result ("+N", "· already"),
unchanged.

app.js and the core budget: +771 bytes over the previous commit, 349 over
the budget after compacting the helper, raised by exactly that with the
reason in core_budget_test.go (the check-in row is the core's, the tray
panel draws it too).

Tests:
- checkin-early-done.test.cjs: the press's toast is "Claimed: 1 (+200
  credits)" in each language, and checkinPressSaid's text for already,
  not yet and a mix (claimed x2 +150, already, failed), bad = 1 for a
  failure. qoder-checkin-recheck.test.cjs now wants "Not available yet:
  1" for its inactive press.
- Red on the previous commit's app.js: both files 0/20 in Chromium.

Run at this tree:
- GUI: checkin-account, checkin-early-done, i18n-keys, plugin-checkin,
  qoder-checkin-recheck, usage-card-refresh, usage-checkin, Chromium and
  WebKit: 177/179; the 2 reds are usage-checkin's WebKit Qoder check-in
  tab, red alone on origin/main 0815c9186 (#2549, #3091).
- go test -tags nogui ./internal/gui/ -run Budget, ./internal/provider/
  -run 'Checkin|CheckIn': ok.
- Full suite: set -o pipefail; go test -tags nogui -timeout 45m ./...
  at 70c6bb072 (this tree on the previous commit), sandbox HOME: 69
  packages ok, exit 0. go vet of internal/gui and internal/provider on
  darwin, linux (nogui) and windows clean; gofmt -l clean.

Not tried: a press against a real vendor account.
2026-10-23 19:03:58 +08:00
yetone 45fa29973c checkin: an early "already checked in" is asked again, not kept for the day (#3326)
connoryang331 (v0.1.1328, Windows): at 00:00:28 Beijing 14 of 29 plugin
check-ins (AutoClaw CN x5, WorkBuddy x2, CodeArts, Trae x3, MiniMax,
Raccoon x2) answered "already" (done). magpie kept that as the day's
result and never asked again, and Check in now answered from the record
without asking. A real claim at 10:54 paid +200: the vendors' days turn
later than Beijing midnight, so 00:00's "already" was yesterday's.

The class, in the checkiner every check-in shares (built-in and plugin):
- A done, inactive or ineligible answered before noon Beijing
  (checkinSureHour) for an account magpie hasn't seen claim that Beijing
  day is provisional. The loop asks it again 30 minutes (wbCheckinEvery)
  after the answer, until a claim or an answer from noon on: at most 24
  more asks a day per such account, none once magpie claims.
- A press (soon) asks again at once for done, inactive and ineligible,
  whatever the hour. own-app (Trae 9074) and captcha still stand.
- A claim stamps Claimed, carried over while later answers that day say
  done, so a done after magpie's own claim is settled (Qoder's claim then
  done case).
- The record goes out with again: true (worked out when shown, never
  kept). The card says "{name} says already checked in; its day may not
  have turned yet, so magpie asks again later" and keeps Check in now;
  Settings, TUI and CLI say the same. en, zh, zh-TW, ja, de.
- Qoder's recheck (#2696, pluginRechecks) is unchanged: its tests pass
  as they were.

The plugins repo does not cache "already": autoclaw reads the task list
or calls dailySignin each time, codearts, minimax, raccoon and trae ask
the server each call (read at magpie-community/plugins origin/main
652f06d). No plugin change, publish or mover min.

Tests:
- TestPluginCheckinEarlyDoneAskedAgain (the reporter's 00:00:28: loop at
  +29m no ask, +30m asks then claims; a press at 10:54 claims; done all
  day is 25 asks and settles at noon; done after magpie's claim settled)
  and TestWorkBuddyCheckinEarlyDoneAskedAgain.
- TestPluginCheckinOthersSettledForTheDay now answers at 12:00 Beijing
  and checks a press asks again (claimed still settled);
  TestPluginCheckinRunsAsTheBuiltinsDo, TestTraeCheckinAnswers and the
  WorkBuddy nothing-to-claim/refused tests follow the new rule.
- TestCheckinAgainNotShownAsToday (TUI words and cell).
- checkin-early-done.test.cjs: again card's wording, data-state wait,
  Check in now asks plugin-checkin {provider: autoclaw-cn}; a kept done
  is "Checked in today +50" with no press. Chromium and WebKit, 5
  languages, 900 and 440px, 20/20.

Red on the old code: with the non-test change reverse-applied (fields
kept so it compiles), TestPluginCheckinRunsAsTheBuiltinsDo,
TestPluginCheckinOthersSettledForTheDay (inactive, done, ineligible) and
all 4 subtests of TestPluginCheckinEarlyDoneAskedAgain fail; with
origin/main's app.js, checkin-early-done fails ("Checked in today").

Run at this tree:
- gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./... clean.
- go test -tags nogui ./internal/provider/ -run 'Checkin|CheckIn',
  ./internal/tui/ -run 'Checkin|OwnApp': ok.
- GUI: checkin-account, checkin-early-done, i18n-keys, plugin-checkin,
  qoder-checkin-recheck, usage-card-refresh, usage-checkin: 177/179. The
  2 reds are usage-checkin's "webkit en/zh: Settings has a Qoder check-in
  tab", red the same alone on origin/main 0815c9186 (filed #2549, #3091).
- Full suite: set -o pipefail; go test -tags nogui -timeout 45m ./...
  at c1a72f2b4 (this tree on origin/main 0815c9186), sandbox HOME: 69
  packages ok, exit 0.

Not tried: real vendor accounts (no early-morning "already" to replay),
Linux and Windows at run time. A vendor whose day turns after noon
Beijing (a US day) is not covered.
2026-10-23 19:03:58 +08:00
yetone 0815c91864 claude: a reply that writes its tool calls as "[tool call …]" text makes them for real instead of showing the lines (Zhenzhen on Discord)
Claude Desktop 3.1623.0 on a Claude subscription ("Fable 5.1 High",
magpie 0.1.1327) showed replies holding lines like
  [tool call mcp__magpie__mcp__ccd_turn__update_plan id=toolu_0Validate args={"advance":true}]
  [tool call mcp__magpie__Bash id=toolu_0Validate bash args={"command":"cd /Users/... && git diff --check ..."}]
and nothing ran. That is the form renderCachedParts gives past calls when
a run is told the conversation as text (renderClaudePrompt for a run
started anew, renderClaudeTurn for a turn with the client's own calls).
The model copied it: Claude Code had no call to make, the turn ended
end_turn, and the client showed the lines as words.

- readOutput holds a reply's words back from the first line that opens
  with "[tool call " (textCalls); words before it, and lines that only
  start like it, go on as they come. A reply that ends there with
  end_turn and calls none of the client's tools isn't ended: once the
  turn's result is in, the run is told textCallsAsk as a user message on
  its input, and the reply goes on in the next message (one
  message_start, as after Claude Code's own call). The client gets the
  real tool_use, registered by mcpCall, so its results go on in the run.
  Asked once per reply; written as text again, the words reach the
  client as before. No input (a run that ends by itself) or a reply that
  also called a client tool: not asked.
- A prompt that tells past calls as text ends with pastCallsNote: the
  lines record earlier calls, and writing one calls nothing. Placed after
  the messages (before </current_turn>), so the history chunks and their
  cache marks are unchanged. A prompt with no call is told as before.
- Neither text names magpie, Claude or Anthropic (checked in the test).
  Claude Code's own prompt and identity are untouched.

docs/subsystems/claude-subscription-bridge.md: new section "Tool calls
written as text", tests added to Verification.

Run at base 34ad18ed8 (origin/main) + this change, sandbox HOME with
pinned caches:
- New tests in claude_text_calls_test.go, built from the report's lines.
  With claude_subscription.go put back to 34ad18ed8 (claude_text_calls.go
  kept so it builds): TestClaudeTextToolCallsAreMadeForReal FAILs "the
  client was shown the calls written as text" (the raw [tool call …]
  deltas in the stream), TestClaudeTextToolCallsAskedOnce FAILs (reply
  ended end_turn after the first text call, run never asked),
  TestClaudeTextToolCallsUnstreamed and
  TestClaudePromptSaysPastCallsAreARecord fail too. Restored: all pass,
  also -race -count=3.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- go test -tags nogui -timeout 45m -count=1 ./internal/gateway/ (log
  teed): ok 515.4s. The first such run failed
  TestClaudeTurnWithItsImagesTakenOutGoesOnInItsRun (passes at
  34ad18ed8): push built each line from string(byte), which turns
  UTF-8 into Latin-1 runes, so "一只猫" reached the client garbled. Now
  s[i:i+1]; TestClaudeTextCallsHoldsOnlyTheLine has a CJK case that
  fails with string(ch) put back (shown "ä\xb8\x80只猫…") and passes
  without.
- Rebased on origin/main 8ef9fc578 (it changed internal/gateway's
  redact paths), then again at the pushed head: gofmt, the three vets
  ok, go test -tags nogui -timeout 45m -count=1 ./internal/gateway/:
  ok 385.4s. Rebased once more on 3b8bcc365 (Codex sign-in refresh,
  internal/gateway's signin_revoked.go): go vet of gateway and
  provider, and -run 'Claude|CodexRefresh' ./internal/gateway/: ok
  39.9s; the whole package not run again at that head.
- Full suite: not run; another session's go test ./... (pid 72083) was
  running on this machine.

Not tried: a real Claude Code or a real Claude subscription. Writing a
user message to an idle run after its result is the path resume already
takes for each next turn; that the model then makes the call it wrote
as text is not shown on a real model. Not tried with Claude Desktop.
2026-10-23 18:19:59 +08:00
yetoneandggbdpq 3b8bcc3654 provider: a ChatGPT token the backend calls expired before its exp is refreshed once and read again (willz on Discord, #2973)
willz on Discord (macOS, v0.1.1330): two saved Team Codex accounts showed
only "Unauthorized". /backend-api/wham/usage answered 401 "authentication
token has expired. Please try refreshing it." while each access token's
JWT exp was still ahead, so codexToken and savedLoginToken handed the
same token back on every read, and on every request, until the account
was signed in again. #2973 is the same 401 on the request path.

What changed
- SignInExpired (codex_expired.go) tells such a 401 by its words:
  token_expired, "authentication token is/has expired", "Please try
  refreshing it". It never matches refresh_token_expired, which is a
  revoked sign-in. accountJSON now keeps the first 4KB of a refusal's
  body on accountStatusError for it.
- Refreshes are keyed on the token that was turned away:
  codexTokenRenewing(dir, stale) for Codex's own sign-in and
  renewSavedLoginFrom(user, stale) for a saved one. Under the lock that
  signing waits on, each reads its store afresh. If the store holds
  another token by then (renewed by Codex or by another reply), that
  token is used and no refresh is spent, so two replies for one token
  spend one rotation. Otherwise they refresh. Codex's own sign-in is
  written back through codexStore.write (temp and rename, every other
  field kept). A saved one goes through writeLogins and only its own
  row is changed; nothing is matched by name.
- The usage read (codexWindowsRenewing) refreshes once on such a 401 and
  reads once more, never again. It is used by loginQuota (saved and
  current accounts), codexSubscriptionUsage, and the reset spenders
  through codexUserWindows (autoreset, expiring, stillExpiring), which
  read the same windows with the same tokens.
  - A refresh that is refused shows its own words on the card: a saved
    account is marked lapsed, "add the account again to use it"
    (savedRefreshFailed); Codex's own says "run codex login".
  - A token that was refreshed and is still called expired says "sign in
    to this account again" (errCodexStillExpired).
  - A refresh that got no answer is shown as that, not as signed out.
- Request path: noteSignIn renews the account a request went with
  (NoteExpiredSignIn, at most 20s, through Account.renew, which is set
  on Codex's own account and each saved one). Nothing is marked. The
  request fails over as a 401 did before, and the next one goes with
  the new token.
- Docs: providers-accounts.md ("A token called expired") and
  gateway-routing.md.

The request-path hook and its gateway tests (codex_refresh_401_test.go,
taken as written) are ggbdpq's patch on #2973. Here they rest on the
stale-keyed refresh. The patch's forced refresh skipped the fresh
keychain read, so it could spend a refresh token Codex had already
rotated.

Tests
- TestCodexUsageRenewsTokenCalledExpired: a saved and a current account,
  both with an hour left, get 401 token_expired. Each is refreshed once,
  read once more, and kept where it lives (auth.json in the sandbox
  HOME, logins.json). A second read refreshes nothing.
- TestCodexUsageExpiredOnce: a refused refresh says to sign in again; a
  token still called expired is read no third time.
- TestCodexUsageOther401NotRenewed, TestSignInExpiredWords,
  TestNoteExpiredSignIn (two replies for one token make one refresh).
- ggbdpq's TestCodexExpired401RefreshesLogin and
  TestCodexOther401DoesntRefresh.

Run at 482d6707a (this change) (rebased on 8ef9fc578):
- gofmt -l internal clean; go vet ./... (darwin), GOOS=linux go vet
  -tags nogui ./..., GOOS=windows go vet ./... clean
- set -o pipefail; go test -tags nogui -timeout 45m -count=1 ./... in a
  sandbox HOME, log teed: every package ok (69 ok, no FAIL), provider
  221.1s, gateway 574.4s, agent 434.4s. No other full suite was running
  (another session's gateway-only run was).
Broken by hand: with codexWindowsRenewing's retry and NoteExpiredSignIn
turned off (the old behaviour), TestCodexUsageRenewsTokenCalledExpired,
TestCodexUsageExpiredOnce, TestNoteExpiredSignIn and
TestCodexExpired401RefreshesLogin are red. The card read "Unauthorized",
the reporter's words, and the gateway test's sign-in was "renewed 0
times, want once". The new tests passed under -race.
Not tried:
- the real ChatGPT backend or a real Team account; the live ~/.codex and
  logins.json are off limits to this session;
- a keychain-stored Codex sign-in (the fresh keychain read is the
  existing codexToken path, run here only through file stores);
- Windows and Linux beyond go vet.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-23 18:15:15 +08:00
yetone 8ef9fc578c provider: a message sent again to the ChatGPT backend goes without its status, as it goes without its id (Doby on Discord)
Doby on Discord: Pi 1.4.0 on Codex through magpie 0.1.1327 is turned
away on every continued conversation:

  400 {"code":"unknown_parameter","message":"Codex: Unknown parameter:
  'input[8].status'.","param":"input[8].status","type":"invalid_request_error"}

Pi (pi-ai's convertResponsesMessages) sends each earlier assistant
message as the output item it was, {type:"message", role:"assistant",
id, status:"completed", content:[output_text]}. codexInput drops every
item's id, since the backend keeps nothing (store false), but kept the
status. A message with no id is read as an input message, which has no
status field, so the backend refused it. Codex itself sends status only
on the items whose schema has one: codex-rs/protocol/src/models.rs gives
Message an optional status beside its id, Reasoning none at all, and the
tool calls (function_call, custom_tool_call, local_shell_call, whose
status is required) their own.

codexInput now drops status from messages (typed or not) and reasoning
items, the kinds whose ids it drops, and leaves it on tool calls as Codex
sends them. Checked for the same gap: the gateway's own Codex relay
(codex_backend.go) keeps ids, so status stays valid there; the only other
id stripping (chat_call_ids.go) is chat tool_calls; no plugin serves
Codex.

Tests: TestCodexInputDropsStatusWithID (provider) covers each item kind.
TestPiResponsesRelayedToChatGPT's fake backend now refuses an item with
status and no id the way the backend does (codexBackendRefuses).

Run at 34ad18ed8 with this change:
- gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./... clean
- go test -tags nogui -timeout 45m -count=1 ./internal/provider/
  ./internal/gateway/ in a sandbox HOME: ok 121.0s, ok 421.8s
Rebased on 243594410 (redact escapes and the remote guide's wording,
nothing on this path); at 087ad3935: gofmt -l and go vet on provider and
gateway clean, go test -run 'Codex|Pi' on both packages ok.
Broken by hand: on the old codexInput both new tests are red.
TestCodexInputDropsStatusWithID keeps input[0..2]'s status, and
TestPiResponsesRelayedToChatGPT gets 400 {"error":{"code":
"unknown_parameter","message":"Codex: Unknown parameter:
'input[3].status'.",...}}, the reporter's words.
Not tried: the real ChatGPT backend (the live ~/.codex sign-in is off
limits to this session); the theory that status needs its id fits
OpenAI's item schemas and the reporter's error, nothing more. The full
suite was not run, because another session's full go test ./... was
running on this machine at the time.
2026-10-23 18:02:59 +08:00
yetoneandggbdpq 243594410d redact: a tool call's arguments stay JSON when a value follows an escape (#3022)
A history tool call's function.arguments is JSON text inside a string.
MaskJSON masked it as plain text, so the n of a \n started a match:
"\n@mcp.tool()" became "\{{EMAIL_…}}()", the arguments were no longer
JSON, and Ollama Cloud refused every turn that replayed the call with
400 "invalid tool call arguments". Reported by xiaobaifly7 and reproduced
independently by Shane-Meng (\n\n\n@pytest.mark…).

Where a string holds JSON text (asJSON), mask now reads it the way the
vendor reads it once it is unescaped:
- unescapedView: a same-length view in which \n, \r, \t, \b and \f read
  as control characters and a \u escape reads as line breaks, so no word
  starts or ends on an escape's letter. \" \\ \/ stay as written, so the
  SECRET rule's \"-aware quote and Windows paths read as before.
- outsideEscapes: any span (rule, word, model, known) that starts or
  ends inside an escape is cut back to the escape's edges, so the JSON
  holds and what the span held is still masked. A span left empty is
  dropped.
- unescapedPut: the value kept for Restore is the unescaped one, so
  Restore (which escapes it again in arguments) gives the agent exactly
  what it wrote. Before this, a private key's \n came back as \\n.

Ported from ggbdpq's hunt53-f-redact-json-escape. Their test
TestMaskJSONKeepsArgumentsJSON is kept verbatim. Their guard alone let
"\njo@quill.dev" through unmasked, so this port also adds the view, the
trimming and the restore.

Run at base 673651e8d (origin/main) plus this change:
- gofmt -l: clean
- go vet ./... (darwin), GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok
- go test -tags nogui -race -count=3 ./internal/redact: ok
- go test -tags nogui -count=1 -timeout 45m ./internal/redact/...
  ./internal/gateway/...: ok (redact 3.7s, gateway 423s; internal/masking has no tests)
- Full suite NOT run: another session's `go test -timeout 45m ./...`
  was already running on this machine (one suite per machine).

Broken by hand (each run against the new tests in escape_test.go):
- old code (origin/main's redact.go, json.go and scrub.go, with a no-op
  outsideEscapes shim): all 4 tests red. TestMaskJSONKeepsArgumentsJSON
  "2 masked, want 1"; Escapes "invalid character '{' in string escape
  code" with \{{EMAIL_…}}; Restore gets \\n back; CutShort red.
- unescapedView off: KeepsArgumentsJSON, Escapes and CutShort red.
- unescapedPut off: TestRestoreArgumentsFromArguments red.
- outsideEscapes call off: CutShort red (a user rule
  `REL-[a-z\\]+` ending on the backslash of \" breaks the JSON).
- trimming replaced by dropping: CutShort's unit check red.

Fixtures come from the reporters' bytes: xiaobaifly7's \n@mcp.tool() and
Shane-Meng's \n\n\n@pytest.mark…. They also cover an address after \n,
\t, \" or \r\n, after a Windows path, and after é/—; an npm key
after \n; a key-context password; and cut-short arguments. Each checks
that the arguments still parse, the values are gone and the decorators
are unchanged.

Not tried / not covered:
- No real Ollama Cloud round trip, and nothing end to end on Windows.
- A user rule that reads past the string's closing quote (e.g. \S+ over
  JSON text) can still break arguments. That was true before this change
  and is not an escape case.
- Allow-list matching and a Hit's hint use the escaped text as written.
  A value remembered earlier with real newlines is not found by
  knownSpans in arguments unless a rule finds it again.
- A personal value written as a JSON number in arguments is not masked
  (masking it would break the JSON).

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-23 18:01:26 +08:00
yetone 44d8c742bf remote magpie: the guide names Settings → Network and sharing → Share on local network
The Remote magpie provider's guide, its "isn't shared" message and the
gateway's LAN errors said "Settings → Share on local network", but that
switch sits under Settings → Network and sharing. Every place now names
the real path: the en key and its zh, zh-TW, ja and de words in i18n.js,
app.js's message key, the preset's EndpointHint, the gateway's and
agent's English errors, docs/reference.md, docs/integrating.md,
README.zh-CN.md and the remote and docker pages of the site (en, zh, ja).
errRemoteNotShared names no Settings path and app.js matches its prefix,
so it is left as it is.

Run at base 673651e8d with this change:
- gofmt -l: clean. go vet ./... (darwin), GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...: clean.
- GUI (playwright 1.62.0, chromium and webkit, every language): 12 files
  that reach the strings, 121 of 122. The red, quota-name-translated
  (webkit en, 2px past its quota at 440px), fails the same at
  673651e8d without this change; it is #2228.
- go test -timeout 45m ./...: every package ok but internal/gui,
  where TestCoreScriptBudget failed: app.js was 1,338,819 bytes at
  673651e8d itself, over its 1,337,735 budget; origin/main 34ad18ed8
  (#3367) moved code out. This change adds 24 bytes to app.js.

Run again after the rebase onto origin/main 34ad18ed8: gofmt -l clean,
go vet of internal/gui, gateway, provider, agent and tui clean,
go test ./internal/gui/ ok (TestCoreScriptBudget passes), and the same
12 GUI files 121 of 122 with the same #2228 red.
2026-10-23 18:01:03 +08:00
yetone 34ad18ed86 gui: a session's row helpers move from app.js to the Usage page's script (#3367)
TestCoreScriptBudget was red on main since db48697d6 (app.js 1,338,090
over its 1,337,735 budget), and 673651e8d took app.js to 1,338,819 and
the core's scripts to 1,530,579 (budget 1,529,495). The budget is not
raised.

What moved: sessModelNames, wslBadge, sessModelsText, sessUsageDetail
and viaText, unchanged, from app.js into plugins/usage/page.js's
"sessions" section. Nothing in app.js calls them. Their callers are
plugins/usage/page.js (the Usage page's Sessions tab) and
plugins/sessions/client.js (the Sessions page), which calls them only
from inside its mount/render callbacks, after page.js has loaded
(index.html loads page.js after app.js and before start.js, which
mounts the pages). Their words stay in i18n.js, since both pages say
them.

Bytes (at this commit):
- app.js: 1,338,819 -> 1,336,507 (budget 1,337,735; 1,228 under)
- core scripts: 1,530,579 -> 1,528,267 (budget 1,529,495; 1,228 under)
- plugins/usage/page.js: 170,601 -> 173,032, +2,431 with the section's comment (not core)

Run at 673651e8d + this change (origin/main fetched, unmoved):
- go test -tags nogui ./internal/gui/...: ok (TestCoreScriptBudget, the
  i18n and guard tests included)
- GUI, node --test, Chromium and WebKit, playwright 1.62.0: 39 files,
  467/467 pass: every sessions-*, session-*, usage-sessions*,
  usage-session-speed, usage-unpriced-*, sess-agent-strip,
  account-mask-sessions, i18n-keys, old-webkit, mobile-web, phone-web
  and web-page test.
- gofmt -l: none; go vet ./internal/gui/... on darwin, linux (nogui)
  and windows: ok.

Not run: the whole GUI suite (other sessions were queued on the
machine's suite turn), and no Go code changed, so no full go test ./....
2026-10-23 17:41:11 +08:00
yetone 673651e8dd agents: the Codex app left on the old list has a Restart that quits and reopens it
The owner (10-23): the Agents row said "quit it with ⌘Q and open it again"
and asked for a one-click restart. The app copy's line now has a Restart
beside it, like the daemon's. magpie asks the app to quit (osascript
"tell application <bundle> to quit", as ⌘Q does), waits up to 30s for
every process under the bundle to end, then opens it again. If the app
doesn't end in time (for example, it asks something in its window), that
is reported and the app is not opened a second time.

Only a bundle that StaleCopies lists as an app left on the old list is
quit. StaleCopy now carries the app's Bundle. POST /api/codex/app/reopen
refuses any other path. This is macOS only; elsewhere the route says so.

Run:
- go test ./internal/agent -run 'TestCodexAppReopen|TestCodexStale': ok.
  TestCodexAppReopen went red with the listed-bundle check broken by hand.
- go test ./internal/gui -run TestCodexDaemon: ok.
- GUI: agent-stale-copies + i18n-keys, chromium and webkit, en zh zh-TW
  ja de, 980 and 440px: 83 of 83 pass.
- Real osascript quit by bundle path and open, on a stand-in .app in the
  scratchpad: quit ended its process, and open started it again.
- gofmt -l clean; GOOS=linux go vet ./internal/agent and GOOS=windows
  go vet ./internal/agent ./internal/gui: ok.
Not tried: quitting the real Codex app (it is the owner's live one), and
the full suite.
2026-10-23 17:20:24 +08:00
yetone 3dc25a6168 tests: a plugin fake's vendor counts only its own test's requests (#3357)
Run 39913278700 at 65e80405b (ubuntu, Race): TestClinePluginPinsDeepSeekAndGLM
"the plugin sent 7 requests" for 6 asks, in 0.33s. #3347 was the same
class: TestPluginToldWhereTheAgentWorks got 2 for 1, in 0.66s.

Cause, as far as it is known. The extra request did not come from the
test's own route:
- not a gateway retry: retryPause is 1s, so a retried ask can't finish
  in 0.33s or 0.66s. #3347's "a first try failed with a 5xx and was
  retried" doesn't fit either run's time;
- not the plugin host: the gateway reaches the host over stdio JSON-RPC
  (no HTTP retry), and host.js fetchAs calls the loader's fetch once;
- a never-reset log of every request the cline test's vendor got showed
  exactly 12 (6 asks x 2 runs), all POST /v1/chat/completions from
  magpie/dev, with nothing in the background.
So the seventh came from outside the test. The likely sender is a late
request from another test, in this shard or another of race-shards.sh's
four processes, reaching a port the kernel handed to this test's
httptest server (the class d0ccbbebc met with a freed port). Which test
sent it is still unknown.

Fix the class: testenv.FakeVendor(t, h) serves a fake plugin's vendor
at $FAKE_BASE and sets $FAKE_RUN to a nonce made for the test. The fake,
renew and renewrace plugins send it as X-Fake-Run. A request without it
gets 421 and is logged with its method, URI, remote address, User-Agent,
Authorization and size, so the next one on CI names its sender. Every
gateway and plugin test that served the fake's vendor with
httptest.NewServer plus FAKE_BASE now uses it (10 gateway, 5 plugin
files). The cline test now counts against the asks' recorded tries, as
65e80405b did for the workdir test: it fails on a real duplicate and
logs each retry's status. No exactly-once guarantee was loosened.

Reproduction by injection, at be002aca0:
- a request to FAKE_BASE from outside the route, with the filter off:
  "the plugin sent 7 requests for 6 asks tried 6 times" (the CI shape);
  with it on, the test passes and logs the 421 line;
- the fake plugin fetching twice for glm-5.3 (a real duplicate) still
  fails: "sent 8 ... tried 6". Both breaks were restored.

Ran at be002aca0 (macOS, -tags nogui):
- gofmt -l clean; go vet ./... darwin, GOOS=linux -tags nogui, GOOS=windows ok;
- internal/plugin -race -count=20 ok (157.5s);
- the edited gateway files' tests -race -count=20 ok (93.1s);
Rebased on c8c6e7e23 (it brings TestPluginThinkingOff, on besideFake),
and ran there: gofmt -l clean; vet of the three packages for darwin,
linux nogui and windows ok; TestPluginThinkingOff, the cline and the
workdir tests -race -count=20 ok (18.3s); internal/gateway (363.6s),
internal/plugin (83.9s) and internal/testenv -timeout 45m ok, with no
421 line logged;
- a Linux container run of gateway.race in four shards like CI's,
  -test.v: ok, and no stray was seen.

Not tried: the stray was never caught in the act, here or in the
container, so the sender is a hypothesis. The count=20 run over all 142
besideFake tests hit 45m in TestPluginStreamLargeReplies (sizing, no
FAIL) and was narrowed to the edited files. No product code changed, so
the full ./... suite was not run.
2026-10-23 16:57:33 +08:00
yetone c8c6e7e23f gui tests: modal-morph measures the provider row once the list is still
Chromium at 420px read the row 1 to 5px off the strip the dialog grew
from (401 vs 404-406), red 4 of 4 here on db48697d6 and on its parent:
the list's rows were still coming in when the row was measured. The
test now waits until the row's top is the same 100ms apart.

Run: modal-morph.test.cjs chromium 3 of 3 green (was 0 of 4), webkit
green. The app is unchanged.
2026-10-23 16:49:06 +08:00
yetone db48697d67 gui: a segment pressed in a dialog leaves the dialog where it was
The owner (10-23, a screenshot of Kimi Code's add dialog): every click
on a Plan segment moved the dialog a few pixels down.

The dialog's hold (modalMark at pointerdown, holdModal on the redraw)
keeps what was pressed where it was. A pressed .opt scales (.opt:active,
a .14s transition) and is still scaled when its click redraws; an element
that scales was measured by its parent, the .segs strip, 2px (its
padding) above the button's own top marked at the press. The dialog
went 2px down at every click. modalDepth now measures a scaled element
by its own top as drawn unscaled, from its matrix and transform-origin;
one that turns or skews is measured by its parent as before.

Run at this tree (base eee9ece29):
- Reproduced with presses held 120ms as a hand does, Kimi's four plans,
  eight presses: 262→264→…→278 in Chromium and WebKit; with the fix
  262.1 throughout. Instant Playwright clicks never showed it.
- segment-press-dialog.test.cjs (new): 4/4 green; on the old app.js 4/4
  red ("press 1: the dialog moved from 262.09 to 264.09").
- Every GUI file that opens a dialog (109 files, grep '#modal'): 1467
  pass, 3 red. plugin-github-filter passed rerun. modal-morph chromium
  420 ("the strip's top on the row's", 401 vs 404-406) is red on the old
  app.js too, 2 of 2: it measures the row before the page settles. Fixed
  in its own commit next.
- gofmt -l clean.
2026-10-23 16:48:00 +08:00