Commit Graph
6395 Commits
Author SHA1 Message Date
yetone d1fa254b1d gui: masked words and Never mask are a list, a row per word (noahhrreion on Discord)
noahhrreion: "希望脱敏词选项可以做成真正的列表,在一个小输入框里面不方便管理多个脱敏词".
Settings → Privacy's Masked words was one comma-separated box. It is now a
list (wordList in plugins/redact/settings.js): each word is its own row,
edited in place (Enter or leaving the row saves, Escape puts it back,
emptied is removed), × removes it, and the last row adds. Its sibling,
Never mask under the mask actions, had the same box and gets the same list.

Stored values are unchanged: redactWords and the allow list are still
string arrays, saved through the same savePrefs / settings/redact-allow
calls, and nothing is rewritten on open (the new test checks that opening
the page saves nothing). Typed or pasted text splits as the old box did
(, , and newlines, trimmed, empties dropped), so a pasted "a, b" is two
rows. The Hide eye still shows every row as dots. New strings are in the
redact plugin's i18n for zh, zh-TW, ja and de; the two old "separated by
commas" hints are gone from the core i18n. The site's masking docs (en, zh,
ja) say a row each.

Run (on mote via mote-run, Chromium and WebKit):
- new redact-words-list.test.cjs: 5 languages × 1100/400px × both engines,
  draw, add with Enter, paste-split, edit, Escape, ×, empty-and-Tab, reload;
  with i18n-keys 24/24 ok
- redact-words-hidden, any-case, whole, mask-actions, redact-route,
  redact-kinds, redact-shape, settings-search, settings-sections,
  settings-lines-wrap, settings-hints, settings-groups, readable-focus,
  masking-records, mask-alert: 378/378 ok
- go test ./internal/gui/ -run 'TestCoreScriptBudget|TestSettings': ok
  (app.js shrank; no budget raised)
- screenshots light/dark, 1100/400px, both engines, looked at

Broken by hand: without wordFocusBack (focus kept across a redraw) the new
test goes red (waitForFunction timeout after the first add). Dropping the
blur guard during a redraw (wordsRedrawing / isConnected) stays green in
both Playwright engines, which fire no blur on removal; it is kept as a
guard for engines that do, with no test that fails without it.

Not tried: the real app on WebKitGTK / Windows WebView2; no Go files changed.
2026-11-04 12:38:10 +08:00
yetone 4ca55c6b62 gateway: a guard test that Only switch Claude Code's sign-in keeps every route off the Claude accounts (zhangxiaoxiaoxx on X)
zhangxiaoxiaoxx on X asked for a switch so that, with Claude signed in,
magpie never forwards or routes another agent's request onto it. That
switch exists: Providers > Claude, "Only switch Claude Code's sign-in"
(magpie accounts switch-only claude on, ec3dad75a). On it, KeptToAgent
makes On() false and magpie serves nothing on the Claude accounts. Its
only test asked by naming claude/... directly.

TestClaudeKeptToClaudeCodeOnEveryRoute asks as OpenCode through the
other routes: a routing group with a Claude member first (goes on to its
other member), a provider whose fallback is a Claude model, and a group
whose classifier is a Claude model. None runs a Claude Code through the
bridge. Unticked, the group reaches the Claude account again. No
behaviour change.

Run on mote:
- go test -count=1 -run TestClaudeKeptToClaudeCode ./internal/gateway:
  ok at 759b4d1d7, and again after rebasing on f4e52659a.
- wsl-run, the same -run: ok.
- go test -count=1 -timeout 45m ./... at 759b4d1d7: 86 packages ok,
  internal/gui red in TestCoreScriptBudget (#5139) and
  TestMainWindowCorners/macOS_26_SDK (#3949), both filed already; this
  commit touches neither.
Broken by hand: On() without !KeptToAgent(): group member, fallback and
classifier each red (a Claude Code ran through the bridge), and
TestClaudeKeptToClaudeCodeServesNothing red.
Not tried: a group magpie found (auto/claude-*): in the test sandbox the
Claude account lists no catalog model, so no such group formed with it.
It plans through the same per-member path as a user's group.
2026-11-04 12:00:01 +08:00
yetone f4e52659a8 plugins: a pick listed as another id leaves with its model (axelburks)
A plugin's model the user lists as another id ("list as", SetModelID) is
picked under that id, but pluginListedIDs held the plugin's own ids. The
hourly relist and Refresh compared the pick with a list that never had
it, so "in the old list, not in the new one" was false, and a model the
plugin dropped stayed picked and on, as if typed in by hand. The built-in
providers' liveIDs already mapped through modelIDsOf; the plugin path
now does too. The list-as stays in settings, so when the plugin lists the
model again relistPicks puts the pick back under the same id.

Run: TestListedAsPickLeavesWithItsModel (new: aaa listed as
claude-opus-5.5 and picked, next list lacks aaa -> pick set aside, alias
kept, a hand-typed pick stays; aaa back -> pick back, alias intact), on
mote. Broken by hand: with pluginListedIDs returning the raw ids the test
fails ("dropped []"). go test internal/provider, internal/plugin: ok.
internal/gui: TestCoreScriptBudget (1535230 > 1533802) and
TestMainWindowCorners (mote's macOS) red, neither touched by this change.
Not tried: a real plugin sign-in.
2026-11-04 11:56:33 +08:00
yetone 525e69b976 gui: a page served anew reloads once, not once per read (visamzh on X)
667317159's servedAnew reloads a magpie web page once another version
of magpie answers for it. Clicked back into on the Settings page, the
page reads /api/update twice, for the badge and for the Version row,
and each answer called location.reload(). When the second answer comes
a few ms after the first, Chromium starts the reload again and the page
is loaded twice. The whole GUI suite at 667317159 on the Linux box
caught it: update-served-anew's "en at 420" and "zh at 420" counted 3
loads (gui-full.log). servedAnew now reloads once per page.

The test answers the second post-update read 5 ms after the first, as a
busy machine does, and counts the loads after the page has settled.
app.js's comments on it are shorter, so app.js is 264 bytes smaller
than origin/main's; TestCoreScriptBudget is red on main already
(1534819 > 1533802, #5139) and stays red, 264 bytes less over.

Run (Linux box, magpie-desktop, through wsl-run, at e17b6cefc + this):
- node --test internal/gui/tests/update-served-anew.test.cjs three
  times: 34/34 each (Chromium and WebKit, 5 languages, 1100 and 420).
- go test -tags nogui -run 'Budget|Script|Asset|I18n|Boot'
  ./internal/gui/: only TestCoreScriptBudget red, the same at
  origin/main e17b6cefc alone (#5139).

Broken by hand: servedAnew calling location.reload() on every answer
again: the 10 Chromium "clicked back into" subtests red (3 loads).
WebKit passes either way; it doesn't start a second reload.

Not tried: the whole GUI suite again with this; mote (busy with other
sessions' suites).
2026-11-04 11:47:56 +08:00
yetone 759b4d1d7d agents: a new user's list is folded under Get started (Renzexi01)
Renzexi01 on X (一进来就这么复杂): a new user saw Get started and, under
it, every agent found on the computer at once. While the Get started card
shows and no agent is in use yet, the whole Agents list is folded under
it behind "Show all {n} agents" (en, zh, zh-TW, ja, de); the card's
second step already names the agents found, each connected in a click.
Once one is connected, or the card is put away, the list is as before:
the ones in use in view, the rest under "Show {n} more".

getting-started checks the list folded under the card, the button's
words and aria-expanded in every language, and the list back once an
agent is connected or the card put away. Tests whose fake state is a new
user with no agent in use, and which read the agents' rows, now set
guideHidden as a user past Get started has (account-arrange,
aside-native, agent-*, claude-picker-magpie-first, codex-accounts-via,
omp-profile-connect, picker-rail-current, picker-speeds, pop-phone-room,
reasonix-roles, snow-fields).

What was run, on mote through mote-run, at a9a82a1c3 (tree e91b8e625,
the same as this commit once its fixup was squashed in), on base
0872bc2a0:
- The whole GUI suite (node --test --test-concurrency=4
  internal/gui/tests/*.test.cjs, both engines, every language), while
  mote ran 14 other test processes: 18901 pass, 292 fail in 57 files.
- Those 57 files again at a9a82a1c3 (concurrency 2): 748 pass, 275 fail;
  at 0872bc2a0: 756 pass, 267 fail. 43 files were red at both, most with
  the same counts (model-chip-steady 40/40, usage-agents-hide 22/22,
  segs-press-redraw 16/16, provider-fetch-again 14/14).
- Those 43 at origin/main e17b6cefc: 442 pass, 262 fail, the same files
  with the same counts. Each has an open issue (among them #4388, #4566,
  #3414, #5057, #5013, #4320, #4585, #4625).
- The 7 files red at a9a82a1c3 only, alone (concurrency 1): 79 of 82
  pass at a9a82a1c3 (group-found-skip 1, name-suffix-remote 2), 76 of 82
  at 0872bc2a0 (group-found-skip, images-codex-one 2, name-suffix-remote,
  title-bar-tools 2): load, nothing red at the head alone that is not red
  at the base alone. name-suffix-remote, red alone at both, is #5147;
  group-found-skip is #4617.
- getting-started and group-switch-add-many at a9a82a1c3: 64 of 64 pass.

Broken by hand: app.js and plugins/routing/client.js put back to
0872bc2a0 (tests and i18n kept), the same two test files: 30 of 64 red.
getting-started went red in all 30 of its "Get started ticks from state"
cases ("no agent row in view under Get started").

Not tried: the real app with a fresh HOME (macOS, Linux WebKitGTK,
Windows), and the tray panel beyond the test's panel layout.
2026-11-04 11:40:21 +08:00
yetone 67bc50aa29 routing: a group switched off is listed after the ones on (justacati)
justacati on X: a group switched off stayed where it was among the ones
on, so the list read as if it were still in use. Routing's group list
now shows the ones on first and the ones off after them, each part in
the order the user set. Moving a group (drag, Move up/down) moves it
among its own part only: the last one on is not offered Move down into
the ones off, and a drag only passes cards of its own part. The saved
order is unchanged, so agents' pickers list groups as before, and a
group switched on again is back in its place.

group-switch-add-many checks the order after a switch off and on, and
that Move down is not offered on the last one on.

What was run, on mote through mote-run, at a9a82a1c3 (tree e91b8e625,
the same as this branch's head once the fixup was squashed in), on base
0872bc2a0:
- The whole GUI suite (node --test --test-concurrency=4
  internal/gui/tests/*.test.cjs, both engines, every language), while
  mote ran 14 other test processes: 18901 pass, 292 fail in 57 files.
- Those 57 files again at a9a82a1c3 (concurrency 2): 748 pass, 275 fail;
  at 0872bc2a0: 756 pass, 267 fail. 43 files were red at both, most with
  the same counts (model-chip-steady 40/40, usage-agents-hide 22/22,
  segs-press-redraw 16/16, provider-fetch-again 14/14).
- Those 43 at origin/main e17b6cefc: 442 pass, 262 fail, the same files
  with the same counts. Each has an open issue (among them #4388, #4566,
  #3414, #5057, #5013, #4320, #4585, #4625).
- The 7 files red at a9a82a1c3 only, alone (concurrency 1): 79 of 82
  pass at a9a82a1c3 (group-found-skip 1, name-suffix-remote 2), 76 of 82
  at 0872bc2a0 (group-found-skip, images-codex-one 2, name-suffix-remote,
  title-bar-tools 2): load, nothing red at the head alone that is not red
  at the base alone. name-suffix-remote, red alone at both, is #5147;
  group-found-skip is #4617.
- getting-started and group-switch-add-many at a9a82a1c3: 64 of 64 pass.

Broken by hand: app.js and plugins/routing/client.js put back to
0872bc2a0 (tests and i18n kept), the same two test files: 30 of 64 red.
group-switch-add-many went red in all 4 of its cases ("the group
switched off is not listed after the ones on").

Not tried: the real app (macOS, Linux WebKitGTK, Windows) with real
groups; a filtered group list with some switched off.
2026-11-04 11:40:21 +08:00
yetone 43345c0ca8 docs: gateway-routing names the GPT ids sent output_config.effort 2026-11-04 11:33:01 +08:00
yetone 9a539e131e gateway: a GPT model on a Messages endpoint is asked its effort in output_config.effort (zxz8009195489)
A custom provider with the Messages format serving GPT models saw every
request at medium on its console. magpie said the level only as a thinking
budget (translated from Responses/Chat reasoning.effort, or passed on from a
Messages client), and said it in output_config.effort for an allow-list:
effortInOutputConfig (GLM-5.2/5.3, MiniMax M3.1 Flash) and DeepSeek's host.
A relay that maps Messages onto OpenAI reads the level from output_config,
so a GPT model was left at the relay's default.

gpt-<digit> ids join effortInOutputConfig, on any host: both the translated
path (buildAnthropic) and the Messages passthrough (withOutputEffort, fitted
to the model's levels when known) now send output_config.effort beside the
budget. Claude and other vendors' models are unchanged.

Run (mote, at this tree): new TestGPTMessagesEffortInOutputConfig and
TestGPTMessagesEffortThroughGateway (local fake upstream) red on the old code
(output_config.effort "" for low/medium/high/xhigh), green after; go test
-timeout 45m ./internal/gateway ok (685s). Unchanged checks in the tests: a
Claude model and kimi on a relay or their own host send no output_config.
Not tried: a real relay (the reporter's is unknown), other packages' suites
(only the gateway package changed), GOOS=windows/linux vet.
2026-11-04 11:32:49 +08:00
yetone e17b6cefc7 provider: the Qoder movers install opencode-qoder-auth 0.2.61 (plugins #692, #638)
0.2.61 puts business.model_key in the request, as qodercli 1.1.82 does, so
Qoder and Qoder CN bill the model chosen, not Auto. 0.2.61 also holds 0.2.60's
429-message change (c1a625d is an ancestor of the 0.2.61 tree).

Run (mote): go test ./internal/provider -run 'TestQoderMovers|TestMovedBuiltinsSayTheirPlugin|Mover'
ok. With min put back to 0.2.60 the new TestQoderMoversNameTheModelInTheBusinessRecord
fails. npm view @magpie-community/opencode-qoder-auth@0.2.61 --prefer-online
--registry https://registry.npmjs.org prints 0.2.61. gofmt -l clean.
Not run before this push: the full suite (run after the tag). Not tried on a real
Qoder or Qoder CN account.
2026-11-04 10:23:34 +08:00
yetone 247794c613 codex: an account that is out takes over for other models too (reverses f37742e14)
With one ChatGPT account out and nothing to serve Codex's own model on
(provider.CodexServesWhileOut false), f37742e14 left Codex on its sign-in
to keep the account's menu. But the Codex app greys Send for every model
while authMethod is chatgpt and /wham/usage says not allowed, so shamen
(mac, banner "Codex 和工作使用额度已用完"), chenhan and xiaoq6285 could send
nothing on GLM-5.3 or any other magpie model. A grey Send for every model
costs more than the menu, so this is the owner's product call: sending on
other models comes first.

When joined, on ChatGPT and held, and magpie has a model on no ChatGPT
account (codexOtherModel), Sync makes magpie the provider on that
stand-in, keeps the user's model in codex.out_own and the stand-in in
codex.out_stand, and at the reset puts Codex back joined on its own model
(#540 way back). Once per held/unheld transition: on the stand-in the model
is magpie's, so the branch is not met again. With nothing else to offer,
Codex stays on its sign-in as in f37742e14. Nothing about identity,
base_instructions or the account's state is changed or faked; magpie only
becomes the provider, as for any held account.

Run (mote-run, win-run, sandbox HOME, fake upstream; no real exhausted
account was tried):
- go test -tags nogui ./internal/agent -run Codex: ok; ./internal/provider
  -run CodexServes: ok; win-run ./internal/agent: see the tag notes.
- gofmt -l, go vet linux/windows/native on internal/agent: clean.
- New TestCodexOwnModelOneSpentAccountTakenOverForOtherModels: takeover,
  three more Syncs with no config write and no codexAppRoute change, the
  reset back once, a further Sync changing nothing. TestCodexOwnModel-
  OneSpentAccountStaysOnItsSignIn now covers only the nothing-else case
  (fake provider deleted).
- Broken by hand: new branch disabled -> the new test red; the
  !isMagpie(m) one-shot guard removed -> red.
Not tried: a real exhausted account in the Codex app; the stand-in picked
by the user is indistinguishable from staying on it and gives way to the
own model at the reset (documented in agent-wiring.md).
2026-11-04 10:05:32 +08:00
yetone 68c43bba65 copilot: a Copilot account draws with the image models its /models lists
Copilot CLI draws with an image model (GPT Image 2.5 Flare) at the API
base's /images/generations and /images/edits, OpenAI-shaped. copilotModels
kept chat models only, so such a model was never seen. It is now saved as a
drawer (Draws, so agents' chat lists still leave it out), found by the
entry's capabilities.type or, for an unknown type, by an id that names
images. The gateway lists them in DrawersOf and sends generation as Copilot
CLI does: model, prompt, size, quality (and n).

Run: gofmt; go vet (host, GOOS=linux -tags nogui, GOOS=windows) for
provider, gateway, catalog; go test of the same three packages, all ok, on
mote. New TestCopilotDrawsItsImageModel uses a fake Copilot API.
Broken by hand: copilotDrawsModel returning false turns it red.
Not tried: a real Copilot account. The model's real id, its /models type
value, n and the edits shape on Copilot's side are unconfirmed.
2026-11-04 10:04:53 +08:00
yetone 6d1e3f1e29 gui tests: library-problems-hide and panel-open-once load with a minute's room
nav-timeout (#4470) holds every page given a short default timeout to a
navigation timeout of at least a minute. Two files broke it on main:
c0dd5838c (#3745, the coffemon batch in v0.1.2855) gave
library-problems-hide 20s, and 7033f5072 gave panel-open-once an 8s
default with no navigation timeout. Both now get 60000.

Found by the whole GUI suite run at 6cfe78635 after the tag (the batch's
pre-push GUI run covered library-* and i18n-keys, not nav-timeout).

Run, mote, Playwright 1.62.0, at this tree on origin/main 2741b749f:
- node --test nav-timeout, library-problems-hide, panel-open-once:
  53 of 53 pass. Before the change nav-timeout was red at origin/main
  listing both files (library-problems-hide alone at 6cfe78635).
2026-11-04 09:49:07 +08:00
yetoneandSKYhuangjing 2741b749f9 sessions: a codex fork's rollout-<n> turn does not end the copied head (#5090)
ownTurn ended a Codex fork's copied head at the first turn id the parent's
file didn't hold (fb1f4856a). codex-rs names a turn that has no id of its
own "rollout-<n>" (the rollout canonicalizer's implicit turns; the
thread-history builder), and a copied head can carry one the parent's file
lacks. It was taken for the fork's first own turn, so every copied
checkpoint after it was booked as the fork's call: July and August usage
that was the parent's history over again. Reporter: SKYhuangjing, whose
fork branch codex-fork-head-marker (acb034645) this ports.

ownTurn now leaves a "rollout-" turn id alone. callParseVersions and
parseVersions raise codex to 3, so kept shards and call caches are read
again once (the same one-time re-read the codex 2 raise cost).

Changed from the patch: the code comment and the subsystem page
(docs/subsystems/gateway-sessions.md) say what codex-rs does, not what
the reporter's corpus showed; the test comment names #5090.

Checked, not changed: ZCode's fork path (zcDB.copied) matches copies by
the original message id and never reads a turn id; ownTurn has one
caller (codexUsageState.context).

Run (mote-run, at this tree on origin/main + this commit):
- TestCodexForkHeadMarkerDoesNotEndTheCopies red with ownTurn as on
  origin/main (4 calls on the fork, want 1), green with the fix.
- go test -count=1 ./internal/sessions ./internal/usage ok; gofmt -l clean.
- GOOS=windows and GOOS=linux go vet ./internal/sessions clean.
Not tried: the reporter's real database (we have no copy of their
corpus). Not confirmed: codex-rs main has no writer that puts a
turn_context with "rollout-<n>" into a forked file from
record_initial_history, as the issue says; the prefix is confirmed from
the two codex-rs writers above, but which one produced the reporter's
files is unknown. Not handled: a fork whose own first turn is itself a
"rollout-<n>" (a legacy rollout migrated with no ids) still doesn't end
the copies by turn id; checkpoints still match it as before.

Full suite: run after the push, result on #5090.

Co-authored-by: SKYhuangjing <13705011+SKYhuangjing@users.noreply.github.com>
2026-11-04 09:10:52 +08:00
yetone 90bf96a23d search: a plugin can give a web search API (its search hook)
treeman on Discord #help asked for web search to be pluggable so users can
add search vendors. A plugin's `search` hook, {search: {<id>: {name, keysURL?,
keyOptional?, url?, execute({query, count, key, url}, ctx)}}}, adds an API to
Settings > Models > Web search as `<plugin>:<id>`. It is added, keyed, ordered,
switched off and removed like Tavily or Brave. The built-in APIs stay built in.

How: host.js collects the hook's entries (id [a-z0-9-], an execute) into
Loaded.Searches and runs one with the `search` op (timeout from ctx, an error
with a numeric status comes back as a refusal). The host notes them in
plugin-searches.json (internal/plugin/search.go); provider.AllSearchVendors
adds the noted ones of plugins that are on to SearchVendors, so Ready, check,
the CLI and the GUI list see them. askSearchAPI hands a plugin vendor to
askPluginSearch below askSearchAPIKeys, so keys, rest on 401/402/403/429,
order, the masked query and the request-log row are the built-ins' own.

Run (mote, on this tree, whose base df7c94bdf was just fetched):
- go test -timeout 45m ./internal/plugin ./internal/provider ./internal/gateway
  ./internal/cli: ok.
- go vet native; GOOS=windows go vet plugin, provider, gateway, cli: ok;
  GOOS=linux go vet plugin, provider, gateway: ok. gofmt -l: empty.
- internal/gui: TestCoreScriptBudget and TestMainWindowCorners fail in a
  full run. This change touches no script (only api.go's loop), so the
  budget red is the base's (re-checked after the rebase, below);
  TestMainWindowCorners is AppKit on mote (macOS 27).
Broken by hand: skipping off plugins in NotedSearches turns TestPluginSearch
red; the refusal mapping removed turns TestPluginSearchAPI red.
Not tried: a real plugin against a real vendor's API; the GUI JS suite (no
GUI script changed); a Linux or Windows window; site/public/docs (en, zh, ja)
do not describe the hook yet. A plugin just added is listed once the host has
loaded it; RestoreSearchAPIs drops a plugin's entry on a machine without it.
The community README has the template (magpie-community/plugins 3ec42d4).

Reported by treeman.
2026-11-04 08:37:21 +08:00
yetoneandMYCF711 df7c94bdf5 gateway: inline image descriptions survive a restart (#5121)
The vision description cache (Server.sights) was in memory only, so a
restart, update or handover described every image of a long conversation
again (62 calls in 2.5 minutes in the report). Completed descriptions of
inline images are now appended to vision-cache.jsonl (0600) in the config
dir before their waiters are released, and New restores them under the
same 2048-entry LRU. URL images stay in memory (their bytes can change);
failures are never written. Appends and compaction go through a file lock,
a corrupt or truncated line is skipped (and backed up before compaction),
and shutdown waits for pending saves within the drain window.

Patch by MYCF711, applied clean on main. One change: the Unix permission
test now makes the config folder before it pre-creates the file (it failed
on a fresh sandbox, where the folder doesn't exist yet).

Run (mote, at this tree): go test ./internal/gateway filtered to the
vision/sight/cache tests, ok; gofmt -l clean; go vet ./internal/gateway
for linux and windows, clean. Broken by hand: saveSight call removed from
see(), TestDescriptionSurvivesGatewayRestart red (2 descriptions, want 1),
green again with it back. Windows: the same filtered tests on xiaomi-gpu
via win-run. Not tried: full go test ./..., go vet ./... for linux (wails
cgo doesn't build off-platform on mote), a real process kill or a real
handover, a real gateway with a real vision model.

Co-authored-by: MYCF711 <323101370+MYCF711@users.noreply.github.com>
2026-11-04 07:57:43 +08:00
yetone 6673171595 update: the app and magpie web follow each other's update (visamzh on X)
visamzh on X: with the desktop app and magpie web both open, an update
from either side left the other still offering it ("↑ 更新") until it was
quit by hand.

Cause: the app and magpie web are two processes over one program, each
with its own updater (state, download, latest) in memory. One restarting
to update puts the new binary in; the other is told nothing. Its
replaced() (the binary on disk is no longer the one it started from) was
read only on a click of its own Update or on magpie update's gateway ask
(restartBeside), which reaches only the process serving the gateway. And
a browser's page reloaded (backAsNew) only after a restart it asked for
itself, so magpie web's tab kept the old page and its pill even once
the process under it was new.

Fix:
- followReplaced (update_beside.go): every updater stats its binary each
  5 s and, once another magpie replaced it, restarts into it through
  restartBeside, once: at once when idle, else after the gateway's
  requests (waitIdle), as for magpie update's ask. Not for what this
  process put in itself (installed, set by install, cleared by
  wontStart), not twice (followed), not for a build that isn't a release
  (make dev, go build rebuild in place). It stops with backendCtx, so a
  copy left draining after a handover doesn't look.
- waitFor (update_wait.go): a wait for the gateway restarts into what
  another magpie put in whatever the feed says now; before, a feed out
  of reach or a "latest" answer ended the wait with nothing restarted.
- boot.js names the version that served the page (bootPrefs.version);
  app.js's servedAnew reloads a browser's page (web) when /api/update's
  current names another, on the reads it already made (load, focus, back
  into view) and once a minute while shown. The app's own windows come
  back with their new process and are left alone.
- docs/subsystems/gui-shell.md describes it.

Run (mote, through mote-run, at 1e1068c86 + this change unless said):
- gofmt -l internal/gui: nothing.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., go build, GOOS=linux go build -tags nogui, GOOS=windows go
  build: all ok.
- go test -tags nogui -race -count=5 -run
  'Follow|AnotherMagpies|OwnUpdate|OwnBuild|UpdateClicked|Wait|Beside|
  Restart|Install|WhatsNew|Quiet' ./internal/gui/: ok (102.9s).
- go test -tags nogui -timeout 45m ./internal/gui/... ./internal/cli/...
  ./internal/update/... . : gui, update, update/launcher and magpie ok;
  internal/cli red in TestEveryRouteHasACommandOrIsNamed (GET
  /api/context/reply has no command), red the same on origin/main
  51fa4b7eb alone, filed as #5026 (from 0872bc2a0).
- node --test internal/gui/tests/update-served-anew.test.cjs: 34/34
  (Chromium and WebKit; en, zh, zh-TW, ja, de; 1100 and 420 wide; the
  minute poll under page.clock; the app's window not reloaded).

Broken by hand, each red, then put back:
- followReplaced never restarting: TestAnotherMagpiesUpdateRestartsThisOne
  and TestAnotherMagpiesUpdateWaitsForTheGatewayThenRestarts red.
- the installed guard dropped: TestOwnUpdateIsNotFollowedAgain and
  TestUpdateClickedOverAnothersIsNotFollowedAgain red (a second restart).
- waitFor's "in" case off: TestAnotherMagpiesUpdateWaitsForTheGateway
  ThenRestarts red (the wait ends with nothing restarted).
- boot.js without the version: TestBootNamesTheVersionThatServedThePage
  red.
- servedAnew not reloading: 15 of 16 subtests red in Chromium.
- the minute poll removed: the 5 "left on screen" subtests red in WebKit.

A first cut also refused a second install() once one was in; that made
TestRestartBySelfComesBackQuietly and TestWhatsNewQuietAfterRestartTo
Update red (they restart one updater several times), so the flag only
keeps followReplaced off.

Not tried: a real pair of the app and magpie web on two release builds
with one replacing the binary (only temp files and fakes); Windows
(InstallBinaryAside starts the staged file there, so the own-install
test is skipped and the click test covers the flag) and Linux runs;
the whole GUI suite: mote was never free (two other sessions' full GUI suites, load ~400), so it runs on the Linux box after this lands.
2026-11-04 06:59:29 +08:00
yetone 452c28a78c cli: GET /api/context/reply is named as the window's own (#5026)
TestEveryRouteHasACommandOrIsNamed was red on main: the route came in with
0872bc2a0 and nothing named it. It is the reply half of the Context page's
detail view, served beside GET /api/context/text, which is already in
notYet as W (the window's own); it gets the same entry. #4826
(POST /api/usage/checkin-account) was already named in 8abdf53a8 and
passes.

Run on mote at the pushed head: go test -tags nogui -count=1 ./internal/cli
ok; GOOS=linux and GOOS=windows go vet -tags nogui ./internal/cli ok;
gofmt -l clean. Broken by hand: with the line removed the test is red with
the issue's message. Test-only change. Not tried: other packages (no code
outside the test table changed).
2026-11-04 06:50:38 +08:00
yetone 0e1054ce19 statusline: the gateway serves Claude Code's status line to another computer (steven_4422)
steven_4422 (Discord) runs magpie in Docker and Claude Code on the host.
The status line square writes the host's settings.json, which the
container can't reach, with a command naming a binary inside the container.

GET or POST /v1/magpie/statusline answers the line `magpie statusline`
prints, as text/plain, so the host needs only curl:
  curl -fsS -m 1 -H 'Authorization: Bearer <key>' --data-binary @- http://<host>:3425/v1/magpie/statusline || true
Claude Code's stdin JSON (session_id) adds the model, as /v1/magpie/route
does; ?session= and ?only= work too. The renderer moved to
provider.StatuslineText, shared by the CLI and the endpoint. A caller that
isn't this computer needs a gateway key (lanGuard, unchanged; the handler
also refuses a non-local caller without one). A read-only key is allowed
(GET and POST in readOnlyRoutes) and gets the windows without the model; a
key held to budget, models or accounts sees only its own (scopeQuotas).
corsGuard and origin checks are untouched.
magpie web shows the command in Settings -> About (en, zh, zh-TW, ja, de).
Docs: reference.md, agent-wiring.md, gateway-routing.md, docker pages en/zh/ja.

Run at this head (rebased on d8b3749ef), on mote:
- go build, gofmt -l, GOOS=windows go vet and GOOS=linux go vet -tags nogui
  on gateway, cli, provider: clean.
- go test: internal/gateway ok (a first full run failed once, 888s, name not
  kept; the rerun had no failure), TestStatusline*, TestReadOnlyKeyEveryRoute,
  TestStatuslineEndpointIsTheCLIsLine ok. internal/agent ok earlier, at the
  pre-rebase base.
- TestCoreScriptBudget ok after shortening the new strings (no raise).
- GUI: statusline-remote (22: 2 engines x 5 languages x 1100/400, plus the
  app without the row), public-url-default, i18n-keys, claude-statusline: all pass.
Broken by hand: model made wrong -> TestStatuslineEndpoint red; held-key
scope removed -> red; separator changed in the shared renderer ->
TestStatuslineEndpoint and cli TestStatuslineTellsRouteAndEveryAccount red;
the row's web check inverted -> the GUI test 0 of 22. Removing the
handler's own key check stays green because lanGuard refuses first (the
401 asserts hold through it).
Reds not from this change: cli TestEveryRouteHasACommandOrIsNamed
(GET /api/context/reply, from main), gui TestMainWindowCorners (red on
origin/main on mote), provider TestMoveToPlugin and TestMoveCutShort (red in
the full run, green alone).
Not tried: Docker or any container (not on mote or WSL); the real binary
from another computer over the LAN with a real Claude Code; the whole GUI
suite (running, 1182 files, finishes after the push); Windows and Linux
test runs.
2026-11-04 06:39:37 +08:00
yetone 59c1306035 claude: an auto-mode client's tool loop keeps its interactive run (#4804)
Auto mode's safeguards change with every tool batch: prior_turn_context
grows by the turn before. An interactive Claude Code run read them once,
from CLAUDE_CODE_EXTRA_BODY in its environment as it started. So a tool
loop either started the run again (the whole conversation written to the
cache again), or kept it and sent the classifier the context it started
with, which is not what real Claude Code sends.

Each turn's safeguards now reach the running run:
- The bridge writes the extra body to <run tmp>/guard.json and hands its
  path to the helper as MAGPIE_CLAUDE_GUARD (mapped for WSL in newTap).
- tap.js, on each /v1/messages request whose string body has a
  safeguards key, reads the file and puts its safeguards in the body. It
  also sets CLAUDE_CODE_EXTRA_BODY to the file's text, so Claude Code's
  own later reads agree. The first time, it writes guard.json.live.
- setSafeguards rewrites the file (temp and rename, retried for Windows)
  instead of restarting, once .live exists. Without .live (a Claude Code
  that doesn't load the tap), it falls back to the old rule: keep the run
  when only the varying parts changed, otherwise restart. A beta change,
  or safeguards appearing or going, still restarts.
The tap changes only the safeguards value; any other byte of the body is
Claude Code's own. Bodies without safeguards, count_tokens and non-string
bodies are passed through untouched.

The tool-results path logged "process expired" alone while the run's end
read "magpie ended it". It now aborts the run with the reason and logs
"tool results process expired: <reason>". continueWith's "not waiting for
tool results" does the same.

Tests:
- TestClaudeTUIToolLoopCarriesEachBatchsSafeguards: three tool batches
  with growing prior_turn_context, then the answer. Checks one run and
  that each request carried its own batch's safeguards.
- TestClaudeTUIToolResultsLogWhyTheRunEnded: no tap and the rules change.
  Checks that the log has the reason.
- TestTapPutsTheGuardFilesSafeguards (bun and node): the rewrite, the
  bodies left alone, the env, and .live.
- TestTapEnv: MAGPIE_CLAUDE_GUARD is passed through, WSL-mapped.

Run (worktree at c360d9d30 + this change):
- mote: go test -run 'TestClaudeTUI|TestClaudeBridgeSafeguard|
  TestClaudeToolResults|TestClaudeNoRunSaysWhy' ./internal/gateway ok
  (73 PASS); go test -run TestTap ./internal/claudetui ok (bun and
  node); go vet ./internal/claudetui ./internal/gateway on darwin, linux
  and windows ok; gofmt -l internal clean.
- Full suite, go test -timeout 45m ./..., ran on the Linux box (wsl-run,
  magpie-desktop), not mote. mote had two other sessions' GUI suites
  sitting at 0% CPU for 3h42m at load 300, and one suite per machine.
  Result: 80 packages ok, internal/claudetui ok. Red:
  - TestGrokInstalled (#3548)
  - TestCodexBodyLimitFromMemory (#5118)
  - TestMoveCutShort (#5119)
  - TestCCListingKeepsItsNames (#4925)
  All four are red the same way run alone at origin/main d8b3749ef on
  that box. Root, internal/cli and internal/gui don't build there
  without GTK4 (#5120).
- Real use, macOS:
  - Sandbox HOME and CLAUDE_CONFIG_DIR, the owner's Max account copied
    to the sandbox dir's keychain item and deleted after. The refresh
    token didn't rotate.
  - A gateway on 127.0.0.1:3496; magpie built -tags dev at c360d9d30
    (before) and with this change (after).
  - Client: real interactive Claude Code 2.1.316 in tmux,
    --permission-mode auto, sonnet 5.5 through the gateway.
  - One turn, three sequential Bash calls (echo one, ls -la, echo three),
    four upstream requests.
  - Before: one run (pid 49488), cache_write 23005/86/162/86 (the first
    request cold). Its CLAUDE_CODE_EXTRA_BODY stayed the first request's
    safeguards, with no prior_turn_context, so requests 2 to 4 sent the
    classifier stale context.
  - After: one run (pid 64000), cache_read 23005/23091/23091/23253,
    cache_write 0/0/162/86. guard.json.live was written; the tap logged
    3 "guard":"set" (requests 2 to 4), and guard.json ended with 3
    prior_turn_context entries.

Broken by hand:
- The old claude_subscription.go makes both gateway tests red ("request
  0 carried ..."; the log said "tool results process expired" alone).
- tap.js without the rewrite makes TestTapPutsTheGuardFilesSafeguards
  red in bun and node.

Not tried:
- A tool loop whose rules change mid-loop with a real client (restart
  path; only the fake covers it).
- Linux or WSL with a real Claude Code (the TUI isn't used on Windows).
- Comparing the before/after upstream bodies byte for byte (the tap
  logs that it set the value, not the bodies).
- The gateway package as its own -timeout 45m run on macOS: only the
  targeted tests ran on mote, and the full package ran on Linux.
2026-11-04 06:38:56 +08:00
yetone d8b3749ef7 agents: Copilot CLI reaches magpie's models through its providers.json (BYOK)
tony9759 on Discord asked for Copilot CLI to be wired to magpie, since its
docs say it takes a custom model provider URL.

What Copilot does (1.0.105, @github/copilot-darwin-arm64's cli-main.js,
`copilot help providers` / `help environment`; GitHub docs
docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/use-byok-models):
env BYOK (COPILOT_PROVIDER_BASE_URL, _TYPE openai|azure|anthropic, _API_KEY,
_WIRE_API completions|responses) and a providers.json at
$COPILOT_PROVIDERS_CONFIG, else <COPILOT_HOME or ~/.copilot>/providers.json:
{providers:[{name,type,baseUrl,apiKey}], models:[{id,provider,name,
maxPromptTokens,maxOutputTokens,...}]}, picked as <provider>/<id> in
settings.json "model". Neither needs a GitHub sign-in. The multi-provider
file is marked experimental in the SDK types. The version BYOK started in is
not verified (github/gh-aw#25014 says 1.0.19; GitHub's changelog of
2026-04-07 announces it).

magpie writes the persistent file, not the environment: provider "magpie"
(openai chat completions, the gateway's /v1, the agent-named key) and one
models entry per catalog model, then model = magpie/<ref>. Only entries
naming magpie are magpie's; the user's providers, models and other keys stay
through connect, Sync and Disconnect (which also restores the model they were
on); a file that does not parse is never written over. COPILOT_HOME and
COPILOT_PROVIDERS_CONFIG are honoured (the latter added to agentenv.Vars).
Copilot's own models stay in the field's list.

Run at this head (a4fb75bfd's tree on 47b7ba303, mote): go test -timeout 45m
-count=1 ./internal/agent ./internal/agentenv ok; gofmt -l clean; GOOS=linux
and GOOS=windows go vet ./internal/agent ./internal/agentenv ok. Before the
rebase also ./internal/gui (only TestMainWindowCorners, red on origin/main
47b7ba303 too, #3949) and ./internal/library ok. TestModelReadersShareTheList
caught a first draft ranging over magpieModels; it uses sharedModels.
Real e2e: magpie's own Pick wrote the files into a sandbox COPILOT_HOME, the
real copilot 1.0.105 binary (no GitHub account) ran `-p "say hi"` against a
fake OpenAI server and sent POST /v1/chat/completions, model deepseek/pro,
Bearer magpie-copilot. The interactive TUI was also started earlier on a hand-written
providers.json and answered from it.
Broken by hand, each red: user providers dropped on write, Disconnect's
unwrite a no-op, an unparseable file treated as empty, Sync a no-op.

Not tried: a real magpie gateway behind it (the fake stood in), Copilot's
`anthropic`/`responses` wire types, Windows/WSL Copilot, an org with
forceLoginOrgs, tools/streaming against a real vendor model, the GUI suite
(no Agents-row layout change).
2026-11-04 05:13:45 +08:00
yetone 47b7ba3030 models: a model its provider lists at $0 says free in the pickers and Routing (jiangguochao666 on X)
jiangguochao666 asked for each provider's free models to show in Routing
and the model settings, to route to them. The green free tag was shown
only for a plan's free model or a model with "free" in its name.

provider.PricedFree says a model is free only when its price for that
provider is known to be $0:
- A price the user set comes first (provider/model, provider/*, then
  the model's own key). A $0 one makes it free, and any other price, a
  paid tier included, makes it paid.
- Otherwise the provider's own catalogs decide. A $0 from a plan's
  catalog (-plan, membership catalogs) is the plan's per-token price,
  not free. A $0 from only the model's maker is not free either: a
  relay serving Zhipu's free glm-4.7-flash may charge for it.
- No known price means not free.
FreeModel (Free first, Cheapest first routing) is unchanged.

From the local models.dev cache this tags:
- every model of NVIDIA NIM and ModelScope;
- the :free / -free models of OpenRouter, OpenCode Zen and Go, Kilo,
  AIHubMix, ZenMux, Vercel, Requesty and other relays;
- Zhipu's and Z.ai's glm-4.x-flash.
No coding or token plan is tagged.

Where it shows, with the hover "free: listed at $0 on this provider":
- an agent's model picker (agent.Option.Zero);
- the provider editor's model chips, and its Free only button
  (modelJSON.Zero);
- Routing's Add a model and classifier pickers (modelRef.Zero).
The word is new in en, zh, zh-TW, ja and de.

Tests, each red on the old code:
- TestPricedFreeIsTheProvidersOwnZero: own, plan, maker-only, unpriced
  and user prices.
- TestPickerSaysAZeroPricedModelIsFree: Option.Zero, cleared at once by
  a price the user saves.
- TestZeroPricedModelsSayFree: the editor's and Routing's JSON.
- zero-priced-free.test.cjs: the three surfaces, in Chromium and WebKit,
  at 1100 and 420px, in all 5 languages. It checks the tag's text,
  hover and fit, that the paid model has no tag, that a plan's free
  model keeps its own hover, no sideways scroll and no page errors.

Broken by hand (each restored, diff checked):
- The source check ignored (maker and plan $0 count): the provider test
  goes red on the plan model and the relay's glm-4.7-flash.
- PricedFree always false: the provider, agent and gui tests go red.
- The user's price ignored: the provider and agent tests go red.
- The badge's o.zero / m.zero and Routing's zero dropped in app.js and
  routing/client.js: zero-priced-free goes red, "the $0 model has no
  free tag in the agent's picker".

Run at this commit's tree (base 3f1f1882a):
- mote, go test -timeout 45m ./...: 84 ok, 19 with no tests, 3 FAIL.
  Each red is filed and fails the same way at origin/main 7d022bdb6:
  - TestEveryRouteHasACommandOrIsNamed: /api/context/reply, #5026.
  - TestMainWindowCorners/macOS_26_SDK: macOS 27, #3949.
  - TestCompactionOverByteCapEveryTime: red only in the full gateway
    run, ok alone here and at main, #4862.
  TestCoreScriptBudget passed; no budget was raised.
- gofmt -l: clean. GOOS=windows go vet (mote): ok. go vet -tags gtk3 on
  Linux (wsl, magpie-desktop): ok. A cross GOOS=linux vet from macOS
  fails inside wails' cgo files on main too.
- wsl: zero-priced-free + i18n-keys, 24 of 24 pass.
- wsl: the whole GUI suite, concurrency 4: 19062 of 19585 pass,
  523 fail in 127 files, at load ~86 on a shared box. Those 127 files
  run again at concurrency 2: 465 red here and 417 at the base
  3f1f1882a, the same files on both. 11 files with a red only on this
  tree, the routing, model and search ones near this change, run again
  alone at load ~3: the same 7 fail on both trees
  (33 here, 27 at the base), and which cases fail changes from run to
  run with the same errors. None is in a test that reads the free tag.
  Filed already: #3096 and #5035/#5088 (routing-rule-*, rest-try-now),
  #4388 (model-chip-steady alone on WSL), #4585 and #4932 (under load).
  The other files red only on this tree (usage wheels, tray, archive
  rows) were not run again alone; nothing in them reads the free tag.

Not tried: a real provider's list in the live app (the tests use
fixture catalogs); Free first routing choosing a $0-priced model it
didn't choose before (FreeModel is unchanged on purpose).
2026-11-04 05:00:18 +08:00
yetone 1cb346f2dc gui: on Linux the folder and Backups buttons start the opener and return (pkh1585)
pkh1585 on Discord: on Linux, clicking the Library's folder / Backups
button froze magpie and the file manager that opened closed by itself.

Cause: Linux openFolder was Wails' OpenFileManager, which runs the desktop's
file manager (the inode/directory .desktop Exec, or xdg-open) with cmd.Run
under a 10 second context. A file manager that isn't running yet stays in
the foreground, so the click waited the full 10 seconds and then the
context killed the window that had just opened. Windows had the same shape
and was fixed earlier (folder_windows.go); macOS's `open` returns at once.

Fix: proc.OpenFolder (Linux) starts xdg-open (else gio open, exo-open) with
no stdio and a session of its own, reaps it in a goroutine, and returns. All
callers go through Host.OpenFolder (Library folder, Backups reveal, usage
and backup saves, logs/config reveals, browser reveal), so every sibling is
reached. macOS keeps Wails' way (folder_other.go is now !linux).

Run:
- mote-run go test ./internal/proc, wsl-run (magpie-desktop) go test
  ./internal/proc: ok. New TestOpenFolderDoesNotWaitForTheFileManager: with
  the Wait made synchronous it fails on WSL (waited 1m0s); with Setsid off
  it fails (shares magpie's session); green with the fix, -count=3.
- Real XFCE (magpie-desktop, DISPLAY :0, real Thunar): the old way
  (`timeout 10 thunar dir`) blocked 10s and killed Thunar (rc 124, no
  thunar left); `setsid xdg-open dir` returned at once and Thunar stayed up
  12s later.
- gofmt clean; go vet ./internal/proc for linux, windows (mote), linux (wsl);
  go vet ./internal/gui on macOS.

Not tried: a built Linux magpie GUI clicking the real button (WSL has no
gtk4/webkitgtk-6.0, so internal/gui can't build there, and linux gui vet
wasn't run); Omarchy/Hyprland; AppImage env (LD_LIBRARY_PATH) leaking into
the opener, which is unchanged; the full go test ./... suite and GUI tests
(no GUI or JS file changed).
2026-11-04 04:47:02 +08:00
yetone b045362a92 routing: importing a shared group whose id is one of yours replaces that group (issennknight)
Import on the Routing page always added a new group. When the pasted text
carries the id of a group of the user's own (not one magpie found), the
box now says so before it is pressed: the button reads "Replace <name>"
and a line under the box says its models, routing and rules are replaced
and its accounts and folder rules stay. Pressing it posts groups/import
with replace, and provider.ImportGroupOver saves the text's group over
that one, in its place in the list. Matching is by id only; no other group
changes. Kept as the user has them, since the text can't carry them: the
group's accounts, its folder rules (that still fit the new members) and
its on/off switch. A name another group has gets a number. A text whose
id nobody has, a found group's id, or any import that doesn't ask to
replace adds a group as before. ImportGroup is unchanged.

Run on mote at the pushed tree before rebase:
- go test ./internal/provider (Share|ImportGroup): ok; the new
  TestImportGroupOverReplacesSameID is red with the match switched off by
  hand (replaced=false, id three-2).
- go test ./internal/gui -skip TestMainWindowCorners: ok. TestMainWindowCorners
  fails on mote's macOS 27 box and on an untouched origin/main checkout
  alike (c360d9d30), so it is not this change; not filed here.
- GOOS=windows go vet ./internal/provider ./internal/gui, gofmt -l: clean.
  GOOS=linux go vet of internal/gui can't cross-compile wails (cgo), not run.
- group-import-replace.test.cjs (new, 10 tests: chromium and webkit x en,
  zh, zh-TW, ja, de, at 420px): green; red 10 of 10 with the id match
  broken by hand. Its checks: Import for an unknown id or a found group's
  id, Replace One + the line for an own id, the label survives a redraw,
  replace is posted only then, the list keeps its groups.
- group-*.test.cjs, i18n-keys, gui-de/ja/zh-tw, routing-accounts-narrow,
  routing-save (407 tests, chromium and webkit): all pass. A wider run of
  group/routing/i18n/gui-* files at concurrency 3 was cut at 444 tests with
  one red, routing-accounts-narrow, chromium en, which passes alone (load
  from other sessions on mote); the rest of that wide run was not finished.

Not tried: a real account's group pasted into a real magpie; the TUI/CLI
have no import, so nothing there changed.
2026-11-04 03:56:38 +08:00
yetone c360d9d30d gui: a tap that slides off its Form | JSON option still picks it (refeccd)
A trackpad's tap lifts a few pixels from where it came down. On the small
options of a segmented control (Form | JSON in the MCP server editor) the
lift can land off the option, so the browser clicks neither it nor the
option it came down on: the press shows (the option shrinks) and nothing is
picked, and the next tap, lifted in place, works. segsPress already clicked
the same option again when a redraw replaced it between down and up; it now
does so too when the option is still there but the press was let go off it,
within tapLike's bounds (under 300ms, under 12px). A press dragged farther,
or held longer, is still no pick, as for any button. Every segs control
(the same helper) takes it, in the editors, Settings and the lists.

Test: library-mcp-first-click presses near the top of the option, slides 8px
up, off the switch, lets go inside 300ms, both ways, in en zh zh-TW ja de,
Chromium and WebKit, at 1100 (desktop) and 390 (web). Red on the old code
(12 of 22: every 1100 case in both engines), green with the fix (22 of 22),
run through mote-run.
Not tried: the reporter's own trackpad and video (not seen); the whole GUI
suite is run before the push, see the push record.
2026-11-04 02:26:08 +08:00
yetone 12d4825afa gateway: a turn of only waits (sleep, wait, delay, pause, poll) is not a tool loop
xiaozhi09400 (Discord, Codex): clock__sleep {"duration_ms":60000} called 8 times
while CI ran was stopped as "the same tool call, the same result". A wait
is asked again with the same arguments and answers the same by design; the
time passing is the progress, and a request carries no timestamps to
measure it, so the guard now skips a turn whose calls are all waits.

A call is a wait when the tool's own name (after server__ / namespace
prefix, so a server called "wait" does not count; snake and camelCase
split into words) has sleep, wait, delay, pause or poll, or when its
arguments are only duration keys with numbers (duration_ms, seconds, ms,
timeout...). A turn that waits and also runs another call is judged as
before. Any other tool repeated 8 times is still stopped.

Run (mote-run): TestToolLoopLetsWaitsBy is red on the old code (8 wait
shapes stopped; guard disabled by hand) and green now; ./internal/gateway
-timeout 45m ok (696s); GOOS=windows and GOOS=linux -tags nogui go vet ok;
gofmt clean. Not tried: a real Codex with the clock MCP server; Codex's
exact namespaced name is taken from the report (clock__sleep).
2026-11-04 02:18:23 +08:00
yetone a6f5d738fc gateway: a group's serial walk has a total budget of 540s (#5113)
Nine members at a 60s first-token wait took 660s, past the 600s a client
waits. The client hung up first and the member it was on was told as the
failure. Nothing bounded the sum of the members' waits.

groupBudget (540s) counts from the walk's start. A member asked with less
left than its FirstToken gets only what is left (holdWriter.budgeted); when
that runs out, or the walk has used the budget, no further member is asked,
the member isn't rested (it was cut short, not slow), and the error is a 504
naming the budget. A client cancel was already read first (nobody blamed),
and is unchanged.

Reported by mycf_711 in #5112; #5113 stays open for the reporter.

Run at the pushed head (rebased on origin/main 7aff42d86): mote-run
go test ./internal/gateway -timeout 45m: ok (667s); GOOS=linux and
GOOS=windows go vet ./internal/gateway and gofmt -l: clean.
TestGroupWalkStopsAtItsBudget waits on the response, not a duration; with
gateway.go's change reverted it is red (the second member is asked after
60s and answers 200).
Not tried: a real 9-member group against a vendor; the budget is not
configurable per group.
2026-11-04 02:11:09 +08:00
yetone e2d52b5012 provider: ZCode's mover min is 0.1.49, whose -Trial entry is no longer answered "quota exhausted" after a free-first refusal (Can4ry_ on X)
Can4ry_ on X: GLM-5.3-Flash-Trial answered "429 · ZCode's limited quota
for glm-5.3-flash is exhausted or temporarily unavailable" in magpie while
ZCode's own app was served. The plain GLM-5.3-Flash also kept going to
the Coding Plan after the Start Plan opened at 23:00. And there was no
freeFirst under Providers › ZCode.

zcode 0.1.49 (plugins 36a017a):
- A free-first gift refusal that isn't a quota answer (405/3012) now
  rests only free first's use of the model. Before, it shared the rest a
  -Trial entry obeys, so the Trial answered a local 429 without asking
  ZCode.
- The local 429 keeps the spent words last. 0.1.48 appended "(ZCode
  answered 429 …)" after them, so zcodeSpentWords didn't match and the
  account rested whole.
- free first is a switch, "Free quota first", in the provider's editor
  under Plugin options, just above Advanced (auth.options free_first,
  on by default).
keepMovedCurrent updates every moved user to 0.1.49.

The gateway test gets 0.1.49's rested wording, which rests the Trial
entry alone, and 0.1.48's, which rested the account.

Correction to plugins 36a017a's body: its old-code block-page test
fails because the old code has no `sidelined` map. Its second plain
request did not go to the gift again.

Run on mote, at this tree (rebased on origin/main 7aff42d86, run again there):
- go vet ./internal/provider ./internal/gateway
- go test ./internal/provider -run 'Mov|Migrat|Mover|ZCode|Zcode|Plugin',
  ok
- go test ./internal/gateway -run 'ZCode|Zcode', ok, both new subtests
  pass
- gofmt -l clean
- npm view --prefer-online @magpie-community/opencode-zcode-auth version
  says 0.1.49

Broken by hand: in the plugin (see 36a017a), the new tests against the
old index.mjs, 4 fail, the reported case among them (429 for 200).

Not tried:
- the full suite. mote is running other sessions' suites, and this
  change is one string in the mover plus test cases.
- a real move to 0.1.49.
- a real Start Plan refusal: the owner's account has no live gift.
- the editor's switch in a running app. It comes from host.js optionsOf
  and app.js pluginOptionsField, unchanged.
2026-11-04 02:07:15 +08:00
yetone 7aff42d863 plugin host: the sign-in lock and file waits no longer freeze the event loop (#5112)
pause() was Atomics.wait, which blocks Bun's one thread. lockAuth spun on
plugin-auth.json.lock with pause(5) for up to 2 x AUTH_LOCK_STALE (20s),
and writeDurable and readFileSteady waited up to 500ms each, so one
plugin's renewal storm stalled every plugin's requests, model lists and
check-ins (499s while the port still answered). Reported by mycf_711.

- pause() is gone; sleep() is an awaited setTimeout.
- lockAuth, writeDurable, keepAuth, writeAuth and changeAuth are async,
  and so are their callers (setAuth, removeAuth, settle, save, apiKey,
  staleAccess, import/take/signOut, pi.js modify/delete).
- changeAuth takes in-process changes one at a time (authQueue) before
  the file lock, so a host's own changes don't poll against each other;
  the lock poll backs off 5ms to 50ms. Stale-lock takeover (10s) and the
  change being made on a fresh read under the lock are unchanged.
- The sync readFileSteady (readAuth, hot path) no longer waits: it retries
  twice at once, and readAuth keeps the last good read when the OS still
  refuses (a failed read is unknown, not none). Under the lock the wait
  is async (readFileSteadyAsync, 50 x 10ms as before).

Test: TestAuthLockWaitDoesNotFreezeTheHost holds the lock 600ms and checks
a timer keeps ticking while changeAuth waits, 20 concurrent changes lose
none, and a lock 11s old is taken over. On the old host.js it fails
("the lock is still held at 300ms": the loop froze 10s). Verified by
putting the old host.js and pi.js back.

Run (mote, at this tree): go test ./internal/plugin ./internal/gateway
./internal/provider all ok; gofmt, GOOS=windows/linux go vet of
internal/plugin clean. Not run: full go test ./..., a real Windows host
under a renewal storm. The serial-fallback total budget is #5113.
2026-11-04 01:53:46 +08:00
yetone e4bc3eeb6f gui: the context window card's head keeps its title, icons and model apart at every width
packinggoods on Discord, in #feedback: in a narrow window the Routing
page's "Context window" head drew the provider's icon over the end of
the title. The mono model id (remote-magpie/claude/cla...) and the Live
pill sat beside it. The cause was .ctx-fold, the title's button when the
card can fold. It had min-width:0, so it shrank under the route, and the
title's nowrap text ran on under the icons.

The title no longer shrinks (flex:none). The route and the state now go
together in .ctx-end, and the head wraps. Where the title leaves them too
little room they take a line of their own, ending at the right, and the
model id is cut there with an ellipsis. A folded card stays one line. At
520px and below it drops the agent's name and the lab part of the route.
At 420px and below it drops the route and the state's word, keeping the
state dot and the bar. The fold button keeps an outer height of 20px
(margin -1px), so opening the card doesn't move the page.

New test, ctx-head-narrow.test.cjs. It uses the reporter's model, live
and counted, with and without the agent, with and without a known window.
It runs en, zh, zh-TW, ja and de, at 1100 down to 340px, open and folded,
in Chromium and WebKit. It checks that the title's text is whole, that no
drawn parts overlap (boxes clipped to their overflow ancestors), that an
icon is never part-cut, and that nothing runs past the card.

Run at this head (rebased on a fresh origin/main), on mote, both engines:
ctx-head-narrow, ctx-route, context-window, routing-context-fold,
routing-ctx-still, routing-ctx-fold, routing-live-patch and i18n-keys:
188 pass, 0 fail. The whole GUI suite is running on WSL (Linux, both engines)
and had not reported when this was pushed. Mote was busy with three other
sessions' full suites. The owner's rule is to ship a verified fix at once.
Any red it finds that this change caused gets an issue.

Broken by hand: ctx-head-narrow on the old context.css/js is 52 of 52
red (e.g. "open at 580px: the title is whole ... cut:true", "title and
lab icon overlap").

Not tried: the real Wails app (WebKit on macOS, WebKitGTK on Linux,
WebView2 on Windows).
2026-11-04 01:39:01 +08:00
yetone 9ce59b8340 routing: a request's row says the credits its reply said it cost (jiabubu)
jiabubu on Discord (#feedback): the Routing page's request list showed no
credits for a request that spent them. The gateway already read a reply's
usage.credit (#2512) into the usage ledger, which the Usage page shows,
but the route trace's RouteUsage had no field for it.

RouteUsage now carries Credits (the reply's, nil when it said none). The
Routing page's request row shows "N credits" after its cost, or alone
when the request has no known price (it read "—" before), with the Usage
page's help text under the pointer; By session sums them in the session's
cost, shown even when no request in it was priced. The help text "What it
cost in its plan's credits, as the reply said" moves from the Usage
plugin's i18n.js to the core's, since two plugins say it now.

Tests: TestPluginPlanCreditsReachTheLedger also checks the route's usage
carries 0.01 on every endpoint (red without the field: Credits <nil>).
routing-credits.test.cjs: credits alone, priced plus credits, none, and
a session's sum, in chromium and webkit, en zh zh-TW ja de, at 1100 and
420, with no overflow.

Broken by hand: the old client.js makes routing-credits 10 of 10 red.

Run at the pushed head on mote: gofmt -l clean; go test -run 'TestDailyCredits|TestPluginPlanCredits|Credits' ./internal/provider ./internal/gateway ok; GOOS=linux go vet -tags nogui and GOOS=windows go vet of provider, gateway, gui ok (rebased on origin/main b92b3bc5b). The full GUI suite (WSL, both engines, every language) ran at the earlier base 50265256b; its 58 files red on head but not in main's run were run again, and the 11 files still in question were run on head and on origin/main b92b3bc5b side by side: routing-credits and i18n-keys pass, and every other red is a test main fails too, with an open issue (#4489 usage-ledger-ttft, #4719 usage-speed, #3593/#4560/#4585 routing-rules-line, #4713 routing-time-went, #2559/#4966 routing-bodies, #4400 sessions-bar-names, #1745 group-member-info, #5052 account-eye); head shows a few more languages of those same tests.

Not tried: a real WorkBuddy request through the GUI; history written
before this release has no credits in its routes and reads as before.
2026-11-04 01:27:06 +08:00
yetone ec3111d873 usage: a pool set aside counts in its card's credits a day (jiabubu)
jiabubu on Discord (#feedback): Usage → Overview's "Credits used per day"
for WorkBuddy left out the extra credits, and read 0 every day while only
extra credits were spent. The WorkBuddy plugin (0.2.19) sends the plan's
"Credits" and "Extra credits", the one whose running out doesn't stop the
account set aside (aside: true), usually Extra credits. creditWindows
dropped every window set aside whenever the card had one that wasn't, a
rule meant for CodeArts, whose buckets set aside are its 总积分's credits
again. So WorkBuddy's extra credits, Kiro's bonus credits and a MiniMax
credits window set aside were never counted.

Now every credit window is read, and noteDailyCredits tells a breakdown
from a pool by what the readings used: a window set aside counts unless
the card's counted windows in its unit used at least as much over the
same span, which makes it their credits again (CodeArts). It is kept as
creditsAccount.Part; a window set aside that is a breakdown, with no
days of its own, isn't shown. No vendor is named in the rule.

Days before this release can't be recovered: magpie never kept the extra
credits' readings, so the chart counts them from the first reading after
the update.

Tests: TestDailyCreditsPoolSetAside, WorkBuddy's card shaped as the
plugin sends it for a China free account (CN_FREE_SUMMARY's 0 / 500 and
282 / 2900 in the plugins repo's workbuddy usage.test.mjs), the plan
untouched while extra credits grow, then the plan spent and set aside
instead; and a Kiro card with bonus credits. Red on the old
credits_daily.go (no days for Extra credits or Bonus credits).
TestDailyCreditsEveryVendor (CodeArts' buckets) still counts only 总积分.

Broken by hand: Part always false makes TestDailyCreditsEveryVendor red
(基础积分 counted beside 总积分).

Run at the pushed head on mote: gofmt -l clean; go test -run 'TestDailyCredits|TestPluginPlanCredits|Credits' ./internal/provider ./internal/gateway ok; GOOS=linux go vet -tags nogui and GOOS=windows go vet of provider, gateway, gui ok (rebased on origin/main b92b3bc5b). The full GUI suite (WSL, both engines, every language) ran at the earlier base 50265256b; its 58 files red on head but not in main's run were run again, and the 11 files still in question were run on head and on origin/main b92b3bc5b side by side: routing-credits and i18n-keys pass, and every other red is a test main fails too, with an open issue (#4489 usage-ledger-ttft, #4719 usage-speed, #3593/#4560/#4585 routing-rules-line, #4713 routing-time-went, #2559/#4966 routing-bodies, #4400 sessions-bar-names, #1745 group-member-info, #5052 account-eye); head shows a few more languages of those same tests.

Not tried: a real WorkBuddy account's readings over a day; the fixture
is the plugin's own window shapes, not jiabubu's bytes (not seen).
2026-11-04 01:27:06 +08:00
yetone b92b3bc5b1 provider: raise the ZCode mover min to 0.1.48
0.1.48 (npm, checked with npm view --prefer-online) puts ZCode 3.17.2's
prompt texts in the Start Plan request (jinpy666's plugins#682). 0.1.46
said 3.17.2 in the headers with 3.14.3's system blocks in the body, which
zcode.z.ai has answered with 405/3012 since 11-03 while the ZCode app
works on the same accounts (plugins#348, Discord reports).

Run: go test -timeout 45m ./internal/provider on mote, gofmt -l clean.
Not tried: a real ZCode account; the plugin side rests on #682's live run.
2026-11-04 01:21:48 +08:00
yetone 7785c42787 provider: raise the ZCode mover min to 0.1.47
0.1.47 (npm, checked with npm view --prefer-online) sends a free gift
model such as GLM-5.3-Flash-Trial to ZCode spelled as the registry does
("GLM-5.3-Flash"), as the 3.17.2 app sends it, not the lowercase bucket
name, and the plugin's own 429 says when ZCode answered 429 to the last
request for the model (rested a minute). Reported on Discord as the
free Flash model failing in magpie while working in the ZCode app.

Run: go test -timeout 45m ./internal/provider on mote: ok. go vet for
linux and windows: no errors. gofmt -l: clean. The plugin side ran
bun test packages/zcode on mote.
Not tried: a real ZCode account; the cause is not proven. A 405/3012 is
ZCode's account risk control (plugins#348) and this does not lift it.
2026-11-04 00:47:54 +08:00
yetone 4c0cfafcf8 gui: a tap that slides a few pixels is a click, not a drag (refeccd)
A trackpad's tap-to-click presses and lets go within tens of ms and the
pointer can slide a few pixels between. dragRows and dragCards lifted the
row after 4px and marked the handle dragged, so the click that followed was
swallowed: an agent row's logo, a provider row, a usage card took a second
tap. A press let go under 300ms and under 12px from where it came down now
sets nothing down and lets the click through (tapLike). A real drag, held or
long, still moves the row.

Reported by refeccd (Discord #feedback, 2026-11-03).

Run at the pushed head (mote, node --test, Playwright chromium + webkit):
tap-click.test.cjs (new; en/zh, window/panel, slid 0/5/9px; 26 ok), and
account-arrange, agent-grip, drag-rows-shift, fold-show-grip,
gateway-key-arrange, grip-inset, group-arrange, group-member-drag,
list-sort, panel-arrange, usage-arrange, click-scroll: ok.
Broken by hand: with the old app.js tap-click is 18 of 26 red (every slid
5px and 9px case, both engines); the 0px case passes on both.
routing-rule-drag chromium is red on the old app.js too (known: #3789,
#5088), not from this.
Not run: the whole GUI suite (another session's was running on mote), a
real trackpad tap (can't be done from a test), and hover-revealed controls
that shift under a tap, none found to be the cause.
2026-11-04 00:41:08 +08:00
yetone 7033f50722 gui: the panel opens the main window from its edge nearest the tray
isaac_bai on Discord, after v0.1.2857 named the header's icon "Open the
main window": with Windows' taskbar at the bottom, the panel stands above
the tray and its header is the panel's whole height from the icon; the
button left of Quit was where his pointer already was. yogurt36 had asked
for one opener, not two, so the panel still has exactly one, now on the
edge nearest the tray:

- Hung below its icon (the Mac's menu bar, a taskbar or bar at the top)
  it is the header's icon, as before.
- Standing above it (Windows' bottom taskbar, a bottom panel on Linux) it
  is "Open the main window" left of Quit in the foot (#openMain), and the
  header has no icon. The string is the one the icon's name already
  uses, in all five languages.

Which side: once togglePanelNow has placed and shown the panel,
tellPanelSide reads the panel's bounds and its screen's and sends
magpiePanelOpenAt("foot") when the panel is nearer the screen's bottom,
"head" otherwise (panelOpenAt, panelside.go; the Mac is always "head").
Under Wayland a window can't read where the compositor put it, so there,
and until the app says, layout.js sets body[data-open-at] by the system:
"foot" on Windows, "head" elsewhere. CSS shows one of the two from it.

Tests:
- TestPanelOpensTheWindowFromTheEdgeNearestTheTray: Windows bottom/top
  taskbar, a tall panel, a second screen above the first, Linux X11
  bottom/top, Wayland, a screen not read, the Mac, unknown places; only
  "head" or "foot" reach the page.
- TestPanelToldItsSideWhenShown: both show paths in togglePanelNow call
  tellPanelSide after placing; app.js has magpiePanelOpenAt.
- panel-open-once.test.cjs, Chromium and WebKit x en/zh/zh-TW/ja/de:
  on a Mac platform exactly one opener, the header's, named per
  language, opening /api/window/main, foot ["profBtn","quit"]; told
  "foot" it moves. On Win32 exactly one opener, the foot's, left of Quit
  (["profBtn","openMain","quit"]), the foot's buttons fitting apart with
  their words whole at 360px, opening /api/window/main; told "head" it
  moves back; an unknown side changes nothing.

Run on mote via mote-run:
- At this head (rebased on 8468afecb): go test ./internal/gui -run
  'TestPanel|TestTrayDouble|Budget|I18n|Asset': ok; node --test
  panel-open-once, i18n-keys, window-no-footer, panel-profiles,
  quit-ask-setting, gui-de, gui-ja, gui-zh-tw: 165 of 165 pass.
- At the same change rebased on f168dd278 (main's 8 commits since are
  Library, Routing, browser and Codex-subagent work, none in the
  panel's header or foot): the 127 GUI files that load
  mode=panel or touch the foot, Quit, i18n or a budget, both engines,
  6 at a time: 2112 of 2136 pass. The 24 reds are in 7 other files; run
  again 2 at a time, 16 stay red at this change and 17 at origin/main
  1e1068c86, the same tests: usage-fold, tray-cell-click and
  codex-auto-reset webkit de (#4790), remote-magpie (#4398), and one
  provider-mask case (filed #5109); account-mask (#3951) and
  quota-curve (#4768) went green on the second run.
- At this head: wsl-run go vet -tags gtk3 ./internal/gui: ok
- win-run go vet ./internal/gui: ok; win-run go test -run
  'TestPanelOpens|TestPanelToldItsSide|TestTrayDouble' ./internal/gui: ok
- gofmt -l internal/gui: empty

Broken by hand (in a copy): panelOpenAt always "head" plus the page's
default and magpiePanelOpenAt doing nothing: the Go test red on 5 cases,
panel-open-once 20 of 20 red. Only the CSS rule that hides the header's
icon at the foot dropped: panel-open-once red (two openers shown).

Not tried: a real Windows tray with the taskbar at the bottom or the top,
or a Linux X11 bottom panel; the bounds Wails reports there are read from
its source (positionWindow, the screen's Bounds), not seen. The whole GUI
suite (1175 files) was not run: mote was at load ~55-100 from other
sessions' suites.
2026-11-04 00:22:54 +08:00
yetone 8468afecb3 claude: a turn's images say they are attached, so the file notes after them are not taken for the images
Claude Code notes each image it is given ([Image: source: .../images/N.jpg])
in a note after the message, with a path in the gateway's temp folder. With
no history before the turn, nothing said what they are: the model took the
paths for the images, said it could not see them and quoted the paths as on
another computer (sinsoul1647 on Discord, v0.1.2862, 7 tool-result photos).
The prompt (renderClaudePrompt) and a saved session's turn (renderClaudeTurn)
now say the images, tool results' too, are in the message.

Tried: real claude 2.1.316 on mote against a fake Anthropic server, with
-p user images, MCP tool-result images, a url source, the TUI paste and a
resumed transcript: every one reached the API as image blocks, so the loss
is the model's reading of the notes, not a dropped image.
Not tried: the reporter's client; whether the model stops quoting paths.
Broken by hand: with the note left out, TestClaudePromptSaysToolResultImagesAreAttached is red.

Run at the pushed head (rebased on 8e27369bd): gofmt -l clean; go vet gateway linux and windows ok; go test ./internal/gateway -run Claude|Subscription|Prompt|Image ok (not the full gateway suite: another full suite was on mote).
2026-11-04 00:14:37 +08:00
yetone 8e27369bd6 browser: record_start and record_stop make a GIF of what an agent did
Asked for in chat ("Magpie Browser MCP 也要支持录屏哦"), like
claude-in-chrome's gif_creator. The browser tool gets two actions:

- record_start: from now on, after each action that can change the page
  (not tabs, snapshot, text, console, screenshot, tab_close), the gateway
  takes a picture of the session's window, 800 wide, with the action and
  what it was done to written in a strip under it (the url, ref, key or
  drag; never what was typed).
- record_stop: the frames as an animated GIF, a second a frame and the
  last three, each frame after the first only the rectangle that changed.
  It is kept an hour behind the image server's tokened files link and
  named in FilesMeta, so `magpie tool` saves it; the text says to curl it.

The gateway does it all through browser_screenshot, so every extension
version records and nobody has to reload theirs. At most 300 frames;
a recording nobody stops goes after 30 minutes. A picture an action's
screenshot: true asks for is the same one the frame is made from.

Run on mote (macOS, Chrome for Testing 1234 headless):
- GOOS=darwin/linux/windows go vet ./internal/gateway, gofmt -l: clean.
- MAGPIE_BROWSER_CHROME=... go test ./internal/gateway -count=1
  -timeout 45m: ok (794s).
- New: TestBrowserRecordsAGIF (real Chromium: navigate, type, snapshot,
  navigate → 3 frames, GIF fetched from the link, 800 wide),
  TestBrowserGIFFramesHoldWhatChanged, TestBrowserRecSayKeepsTypedTextOut,
  TestBrowserRecordStopWithNothing.
Broken by hand: with browserRecWorth always false, TestBrowserRecordsAGIF
is red ("no frames").
Not tried: a real headful Chrome, Edge or Arc; Windows and Linux browsers.
2026-11-04 00:10:50 +08:00
yetone 51fa4b7eb0 browser: agents work in tabs of their own, behind the user's
The owner: Magpie Browser "老是会代替掉用户正在浏览的网页". A call that
named no tab, from a session with none, took the tab the user had in
front and navigated it away under them. Now:

- such a call opens a new tab of the session's (about:blank), behind the
  shown one, in its Magpie tab group, in the window used last, or an
  unfocused window of its own when none is open (open() in background.js);
- browser_tabs new / tab_new open behind too; front: true shows the tab,
  for when the user asked to see it (background is still taken, and is
  now the default);
- a screenshot of a tab behind shows it for the picture, then gives the
  window back the tab the user had in front;
- a link with target=_blank clicked in a tab behind: Chrome shows the new
  tab and names the user's shown tab as its opener. It is still followed,
  grouped in the session's group, and the user's tab is put back in front.
- the tool descriptions say so; the user's tabs are acted in only when a
  call names one.

Extension 0.1.4. When an older one connects, the gateway writes this
magpie's over its folders (browserext.Refresh; only folders already
written, never a newer one's: browserext.Older), so the browser picks it
up when it starts again or on the extension's reload in
chrome://extensions. Before, only opening Library's Browser page did. The
dir helpers moved from gui to browserext for it.

Tried and dropped: telling the extension to chrome.runtime.reload()
itself. In Chrome for Testing 1234 on mote an unpacked extension that
calls it never comes back (headless and headful, --load-extension and
CDP Extensions.loadUnpacked, with an onInstalled listener), which would
leave the user with none until a restart.

Run on mote at 1e1068c86 + this:
- MAGPIE_BROWSER_CHROME=Chrome for Testing 1234, go test -run Browser -v
  ./internal/gateway: ok, 16 passed, including the new
  TestBrowserLeavesTheUsersTabAlone (navigate, link to a new tab, tab new,
  screenshot, tab_new: the user's about:blank tab stays + and unchanged,
  the agent's in [Magpie]) and TestBrowserOlderExtensionsFolderWritten.
- go test ./internal/browserext (TestOlder, TestRefreshWritesOnlyWrittenFolders): ok.
- go test ./internal/gui: one red, TestMainWindowCorners/macOS_26_SDK,
  filed as #3949 (macOS 27 on mote), not touched here.
- gofmt -l; GOOS=darwin/linux/windows go vet of the three packages: clean.

Broken by hand: TestBrowserLeavesTheUsersTabAlone with origin/main's
background.js is red ("navigated the user's tab"). The link case was
found by TestBrowserToolsInARealBrowser going red on the first version.

Not tried: the user's own Chrome (headful Chrome with real sign-ins),
Edge and Arc; Windows and Linux browsers.
2026-11-03 23:48:36 +08:00
yetone 1e1068c86c codex: "Same as the lead" holds every subagent to the lead's model (cleverpigo on X)
cleverpigo (Windows, Codex App 26.1027.6604.0) had Codex's lead on
WorkBuddy's DeepSeek-V4.1-Flash, the subagent model on what the GUI called
"Same as the lead", and the Routing page still showed a subagent on
gpt-5.6-sol through Codex's own sign-in.

Cause: that setting, unset, never held a subagent to anything. Since
67c8f562c (mengxiao) a subagent keeps the model its lead names in
spawn_agent (codexFollowTo leaves subagents alone; codexSubagentPick
returns nil with nothing set), and Codex lists its own models first under
spawn_agent's model overrides, so the DeepSeek lead named gpt-5.6-sol.
Codex's side calls use luna, terra or codex-auto-review, not sol, so it
was the subagent, not a side call.

Now:
- "lead" (settings.CodexSubagentLead / provider.CodexSubagentLead) is a
  value of CodexSubagentModel: every Codex subagent goes on the model the
  lead's own turns last went on (codexLeads.lookup), whatever it names.
  The trace says so (SubagentPick.Lead) and Routing tells it as "the
  model its lead is on".
- A lead on one of Codex's own models is followed on the ChatGPT backend
  route only; in serve such a lead leaves the request as asked. With no
  lead turn seen, a subagent goes as asked.
- The GUI's picker offers "Lead's pick" (unset, mengxiao's case, as
  before) and "Same as the lead" (the new value); the texts say which one
  holds the subagents. en, zh, zh-TW, ja and de.
- No prompt text sent to a vendor changes.

Users who had it unset stay on Lead's pick; the label now says what it
does, and they pick Same as the lead to hold their subagents.

Docs: agent-wiring.md (subagent model field), gateway-routing.md
(CodexSubagentModel paragraph).

Ran, on mote through mote-run at this tree (base origin/main 50265256b):
- go test -tags nogui ./internal/gateway (whole package, -timeout 45m): ok
- go test -tags nogui ./internal/provider ./internal/settings
  ./internal/settingsapi: ok; -run Codex ./internal/agent ./internal/gui:
  ok; -run Budget ./internal/gui (TestCoreScriptBudget): ok
- go vet ./..., GOOS=windows go vet ./..., GOOS=linux go vet -tags nogui
  ./... (and -tags nogui darwin/windows): clean; gofmt -l: nothing
- node --test, both engines: codex-subagent-model (now picks Same as the
  lead and back, sheet row, Routing story of a lead-moved subagent, five
  languages), codex-subagents-lead, i18n-keys, routing-request-model,
  routing-sealed-task: pass. routing-story-shrinks is red in WebKit (4
  subtests, "held while under way"), the same alone at origin/main
  50265256b: #3954.

Broken by hand (in mote's copy only):
- lead lookup turned off in codexSubagentPick: both new tests red
  (TestCodexSubagentFollowsTheLeadWhenSet: "ChatGPT was asked for
  [gpt-5.6-sol]", the reporter's case).
- codexBackend's gate back to bare models only:
  TestCodexSubagentFollowsALeadOnCodexsOwnModel red.
- On the old code the tests don't build (no "lead" value), and
  SetCodexSubagentModel refused "lead".

Not tried: a real Codex App/CLI with a DeepSeek lead spawning a subagent,
and nothing on Windows (the change has no OS-specific path). The whole GUI
suite wasn't run: mote had two other sessions' full GUI suites going.
2026-11-03 23:12:33 +08:00
yetone 50265256ba library: a note on a skill or an MCP server, the library's own (youyo.p_10001)
youyo.p_10001 on Discord: with many skills and MCP servers installed,
you can't tell what each is for or which to use. A skill has the
description its author wrote for models, often in English and about
what it does, not why you installed it. An MCP server has nothing but
its command and its tool list. So each now takes a note in the user's
own words.

- Server.Note and Skill.Note in library.json: one line of at most 200
  characters, whitespace run together (checkNote), as a hook's
  description (#2011). A longer one is turned away, not cut.
- The server editor has a Note field under the name. A skill's reader
  (2a19043af's file reader) has one over its files: Save shows once it
  changes, saves the file being edited with it, and a changed note is
  asked about before the dialog closes. SkillNote, POST skills/note.
- A row shows the note in place of its command or description, so rows
  keep their height; the tooltip gives the note, then that line. The
  skills' filter matches notes.
- No agent is given a note: not in any agent's MCP entry, a project's
  file, the MCP router's list or a skill's copied SKILL.md.
- A sync carries it (CarriedSkill.Note; a server goes whole), and
  clearing it is carried too. An older magpie on another computer
  doesn't know notes: a bundle it writes has none, so a sync from it
  clears them. The TUI's server editor keeps a note as it was.

Run at the pushed head:
Run at the pushed head (on origin/main f168dd278, then
rebased onto 94d0fbfcd, whose two commits change only
migrate_zcode.go and the searcher-pick test):
- mote: go test -timeout 45m internal/library (TestNoteNeverGiven,
  TestNoteCarried, TestNoteTooLong), gui, tui, davsync, backup: ok,
  except internal/gui's TestMainWindowCorners/macOS_26_SDK, mote's SDK
  (#3949). GOOS=windows go vet of library, gui, tui and GOOS=linux of
  library, tui: clean. gofmt -l: clean.
- mote, both engines, every language, narrow and wide: skill-edit (the
  skill reader's note), library-mcp-json (the server's note, its row and
  the filter), mcp-editor-cancel, library-mcp-win-line, market-address,
  market-have, i18n-keys: 108 of 108.
- WSL, the whole GUI suite: no red in a library file that origin/main
  hasn't too (see the command commit; #4120, #4471 for the rest).
- "Note" is in core i18n.js, not the plugin's: agent code says it as a
  word. The rebase had dropped main's title on a server row's command
  line (library-mcp-win-line went red); it is back, and with a note the
  tooltip gives the note, then that line.

Broken by hand, each red, then restored:
- add("note", s.Note) in Claude's MCP format: TestNoteNeverGiven
  (.claude.json held the note).
- the carry of Note left out: TestNoteCarried.
- note left out of the server editor's save: the GUI test, 22 of 22.
- notes left out of the skills' filter text: the GUI test, 22 of 22.
- the note's save left out of the skill reader's Save: skill-edit, 22
  of 22 (Save never goes away).
- the note left out of the reader's unsaved check: skill-edit, 22 of 22
  (closing never asks).

Not tried: a real sync between two computers, a real agent reading its
config (the guard reads every file magpie writes in a sandbox HOME), a
real app window, Linux WebKitGTK.
2026-11-03 21:43:54 +08:00
yetone a80575cc86 library: an MCP server's command wraps, and the editor shows the server as JSON (hema_17384)
hema_17384 on Discord: in Library > MCP servers, the editor's Command
field was one line, so `npx -y universal-db-mcp --type sqlserver --host
... --user sa --password ... --database ...` was cut off, and they asked
to see and edit the server as JSON.

- The command is a box that wraps (lineBox, a textarea of one row that
  grows with autosize). It is still one line: Enter saves, Escape
  closes, and a newline is a space between words (a shell's \ before it
  too, except on Windows, whose lines keep their backslashes). At 390
  wide it wraps over several rows; nothing scrolls sideways.
- The editor's head has a Form | JSON switch (the app's segmented
  control, not a <select>). JSON is the server as Copy config gives it
  for Claude Code: {"mcpServers": {name: {type, command, args, env}}},
  or {type, url, headers} for a URL, with ${NAME} references as written.
  An edit there is read as a paste is (serversIn) and becomes the form's
  at once. JSON that isn't one server's marks the box invalid, says so,
  and keeps the dialog from saving or going back to the form, and
  counts as unsaved for Cancel. The agents, sync and the startup
  timeout and OAuth app stay in the form and are kept as they were.
  ⌘/Ctrl-Enter saves from the box; a paste into it is the box's, not
  the dialog's "paste a README's JSON".
- Strings in en, zh, zh-TW, ja and de.

Run at the pushed head (on top of the note commit, which shares these
files):
Run at the pushed head (on origin/main f168dd278, then
rebased onto 94d0fbfcd, whose two commits change only
migrate_zcode.go and the searcher-pick test, with the note commit
on top, which shares these files):
- mote: go test -timeout 45m internal/library, gui, tui, davsync, backup:
  ok, except internal/gui's TestMainWindowCorners/macOS_26_SDK, mote's
  SDK (#3949). GOOS=windows go vet of library, gui, tui and GOOS=linux of
  library, tui: clean (internal/gui's Linux vet needs gtk3 and ran clean
  on WSL before the rebase, with no Go change since). gofmt -l: clean.
- mote, both engines, en/zh/zh-TW/ja/de, 390 to 1100 wide:
  library-mcp-json (new), mcp-editor-cancel, library-mcp-win-line,
  market-address, market-have, skill-edit, i18n-keys: 108 of 108.
- WSL, the whole GUI suite (before this rebase, at the same change):
  541 subtests red in 57 tests, the WSL baseline (#4120, #4471). Those
  in library files are red on origin/main too, run side by side:
  found-skill-pick-remove (#5013, #4097), library-mcp-hub (#4483),
  market-more (#5076), library-chip-fan (#3072), library-mcp-tools ja
  420 (#4693). market-address and market-have were mine: they still
  looked for the command's <input>; they find textarea.lib-cmd now and
  pass 32 of 32 on WSL.
- "Form" is in core i18n.js, not the plugin's: agent code says it as a
  word, which i18n-keys turns away in a plugin.

Broken by hand, each red, then restored:
- .lib-cmd back to white-space: pre: "the command scrolls sideways".
- the command field back to an <input>: the new test and
  library-mcp-win-line fail (28 of 28).
- save without the JSON check: the "isn't an MCP server's JSON" error
  never shows and the broken JSON goes to save.
- (wrap="off" on the textarea alone stays green: the CSS's pre-wrap
  wins, so the CSS is the guard.)

Not tried: a real magpie app window (the GUI tests fake the API), the
reporter's real server, Linux WebKitGTK.
2026-11-03 21:43:54 +08:00
yetone 94d0fbfcd3 provider: the ZCode mover installs opencode-zcode-auth 0.1.46 (plugins#676, #678)
ZCode 3.17.2's marketing feed answers empty to the 3.16.3 the plugin
signed in as, so from 11-03 the daily claim found nothing (plugins#676,
jinpy666; rick_49551 on Discord). 0.1.45 (#678, jinpy666) reads the feed
under 3.17.2's version header and drops billing/preview, which the 3.17
client no longer polls. 0.1.46 sends every call as 3.17.2, since the
client says the Start Plan balance judges capability by the real
app_version, and takes a sign-in whose only Start Plan starts later, as
the client's resolveStartPlanBalanceAvailability does, instead of
refusing it as "ended or never started" (sliyrainbow on Discord, whose
account works in the official client). Checked against
zai-org/ZCode@a9fe401. Raising min moves every moved user onto 0.1.46
through keepMovedCurrent.

npm has 0.1.46 as latest (published 2026-11-03T13:41:44Z, plugins
8fc12a3).

Run on mote at this change (on f168dd278; the rebase onto 93b1b4904
only touches a GUI test): go test -timeout 45m ./internal/provider ok
(121s); GOOS=windows and GOOS=linux go vet ./internal/provider ok;
gofmt -l clean. Plugin side: bun test packages/zcode 191 pass; with
the old app version, without the later-start Start Plan, or with the
old locale put back by hand, 7, 2 and 1 tests went red.

Broken by hand here: nothing; this is a version string, and no test
pins the zcode min.

Not tried: no real ZCode account was available, so neither the claim
nor the sign-in was run live by us; the feed's version gate rests on
jinpy666's live run in #678. Packages that import internal/provider
were not run.
2026-11-03 21:43:09 +08:00
yetone 93b1b49047 gui tests: searcher-pick waits for the reloaded Settings to be drawn (#1745)
After the reload, the test took the first searcher row it found and
scrolled to it. Settings draws the row when the page opens and again
when load() has the state, so on a busy machine the row was replaced
under scrollIntoViewIfNeeded: "Element is not attached to the DOM"
(webkit zh alone on WSL at 01de489de, webkit en in a whole run).

Now the test waits for settingsDrawn, as it does on first open (#1659).
The fake server can hold the state and settings reads (st.slowRead, 400ms
here), so the page's first drawing and load()'s are apart every run, and
the test checks the row it scrolled to is the one that stays.

Run:
- Broken by hand (settingsDrawn after the reload removed), with the
  injected read delay, on WSL: 2 of 4 red with the reported error,
  "locator.scrollIntoViewIfNeeded: Element is not attached to the DOM"
  (chromium en, webkit zh).
- Fixed, on mote: node --test searcher-pick.test.cjs, both engines,
  22 pass, 0 fail.
- Fixed, on WSL: the picked-in-Settings cases in WebKit, 2 of 2 ok.

Not tried: the whole GUI suite (test-only change to one file).
2026-11-03 21:39:10 +08:00
f168dd2784 gateway: a relayed Messages stream is read in whole events, however its reads are cut (#4868)
anthropicTextCalls (the filter that turns calls a model wrote into its
text into tool_use blocks, on a Messages passthrough that offered tools)
split each read with bytes.SplitAfter on "\n". The piece ending a read
always left a trailing empty slice, which line() took for the blank
line that ends an SSE event. So an upstream that flushed `event:` and
`data:` in separate reads had its events dispatched early: a
content_block_start reached the client without its data ("Unexpected
end of JSON input"), or a held block start was joined to the next
event without a blank line ("Unexpected non-whitespace character after
JSON"). Claude Code retried and gave up; hugemulberry on Discord sees
499s often.

The filter now reads whole events with tidyEvents and eventData, as
responsesTextCalls, phaseTidy and idTidy already do. Because tidyEvents
hands out slices of a buffer the next write reuses, the held block
start and stop are copied (startHeld, stopHeld); nothing else the
filter keeps past an event points into the buffer (pending and held
are strings, m is read within the call).

Siblings: the other SSE writers that cut a read on its last "\n"
(textCallTidy, geminiTextCalls, chatTidy, crTidy, usageSniffer) handle
each line alone and keep no event across lines, so the trailing empty
piece goes on as nothing; phase.go's withData and redact's splitEvent
split a whole event. Only this filter gathered lines into events.

Port of oDaiSuno's fix (7bee8c4d0) and tinytub's regression tests and
doc line (d1a7b02a8); yetone/magpie PRs are collaborators-only. Added
here: TestAnthropicTextCallsSSEChunksKeepFraming feeds each stream in
two reads cut at every byte (LF and CRLF), and
TestAnthropicMessagesSSEChunksKeepFraming cuts the handler's upstream
after each line and adds a request with no tools.

Run on mote at this tree (origin/main 4c0c6c02b + this change):
- go test ./internal/gateway -timeout 45m -count=1: ok (628s)
- gofmt -l internal/gateway: empty
- GOOS=linux go vet ./internal/gateway, GOOS=windows go vet
  ./internal/gateway: ok

Broken by hand:
- textcalls_anthropic.go from origin/main: 36 subtests red (lines,
  bytes, CRLF lines, every cut, each line cut, for all four streams in
  both tests: "SSE frame "content_block_start" has 0 data lines");
  whole, events and no-tools stay green.
- the fix without the startHeld/stopHeld copies: 30 subtests red,
  events reads included (a held start overwritten by the next event's
  bytes: "has 2 data lines").

Not tried: a live provider through this build (tinytub reproduced the
original failure through JoyCode on v0.1.2838 with Claude Code
2.1.316); lone-CR line endings, which neither the old nor the new
reader supports.

Co-authored-by: oDaiSuno <157346420+oDaiSuno@users.noreply.github.com>
Co-authored-by: tinytub <1871460+tinytub@users.noreply.github.com>
2026-11-03 21:20:26 +08:00
yetone bdb856b23c icon: the bird is white in macOS 26's clear and tinted icon styles, where it was a dark glass bird on a dark tile
psikent (Discord #feedback, 11-03) sent a dark Launchpad where magpie's
icon was a near-black tile with a near-black, glassy bird. AppIcon.icon
gave the bird a fill for the light and dark appearances only, so in the
Clear and Tinted styles (System Settings, Appearance, Icon & widget
style), which draw from the tintable rendition, actool used the light
fill: the bird at 0.086 grey, whose luminance is what the system tints.
On a dark tile that is dark on dark. The bird now has a "tinted" fill of
white, so it takes the tint (or the clear glass) at full brightness.
Light and plain Dark are unchanged.

Not (a) or (c): the shipped Assets.car (v0.1.2816 in /Applications,
same sha as build/darwin/Assets.car) matched icon.json, its dark
rendition already a 0.957 bird on the dark grey tile, and the release
build (magpie-releases release.yml, `make app`) copies that file.

Run at this head, on mote (macOS 27.2, Xcode 27.2):
- xcrun actool on build/darwin/AppIcon.icon, as `make icons` runs it;
  that output is this Assets.car (sha 72fe0ee3). The old one was made by
  Xcode 26.5; StorageVersion 17 and the 25 renditions are the same, and
  this Mac's macOS 26.2 assetutil reads it, the tintable group now
  filled with Color-2 (white).
- A test bundle (build/darwin/Info.plist, magpie.icns, the Assets.car)
  drawn by IconServices for appearances 0-3 x variants 0-3, and by
  NSWorkspace iconForFile under AppleIconAppearanceTheme RegularLight,
  RegularDark, ClearLight, ClearDark, TintedLight and TintedDark (mote's
  setting put back after). The old Assets.car reproduces the report in
  ClearDark and TintedDark; the new one shows a bright bird in all six,
  and RegularLight / RegularDark look as before.
- Broken by hand: a colour-coded icon (light red, dark green, tinted
  blue) showed Clear and Tinted draw from the "tinted" fill.

Not tried: drawing it on macOS 26 itself (no macOS 26 test box; mote is
on 27), and macOS 15 or older, which use the flattened renditions that
this change doesn't alter. IconServices' variant 1 with dark appearance
(no setting in the six themes maps to it) still draws the light bird on
a black tile, as before.
2026-11-03 21:14:33 +08:00
yetone d16dcba227 routing: the stage's agent and magpie columns grow with their words, up to 15% of the stage
refeccd on Discord (#help): on the Routing page, in a full-screen
window, the stage kept the agent and magpie in columns of 124px each, so
the agent read "Claude Desk…" (and its model auto/claude-opus… was cut)
while the group's member rows ran on across the rest of the stage.

The two columns are now fit-content(max(124px, 15%)): as wide as their
words, at least 124px (min-width on .rt-srcs/.rt-hub, dropped again in
the narrow layout), at most 15% of the stage. Where 15% is no more than
124px (a stage up to ~826px) they are exactly as before, so the member
rows lose nothing on a narrow window; the narrow layout (560px and less)
is unchanged. The stage's ResizeObserver now also watches the agents'
and magpie's cards, so the wires follow a card that changes width while
the stage keeps its size (a new agent name or gateway address).

Run, on mote:
- new routing-stage-wide.test.cjs: 60/60 (chromium + webkit, en zh
  zh-TW ja de, 2560/1920/1100/800/560/390px): name, model and address
  read whole at 1920+, columns 124px..15%, exactly 124px where 15% is
  less, wires start and end at the cards, no sideways scroll.
- broken by hand: with the old routing.css the same test is red in all
  20 cases at 2560 and 1920px ("Claude Desktop" cut, columns 124/124).
- every routing-*.test.cjs + i18n-keys at 8d7583a78 (this change on
  6c201095d): 2442 tests, 2409 ok, 33 red in 12 files. The 12 files
  rerun at 6c201095d and at 8d7583a78 side by side: 29 red at the
  base, 28 with the change, the same tests (routing-folder, rule-drag,
  rule-remove, rules-line, rule-models, many-keys, row-swap, steady,
  steps-cap, story-shrinks, order-unknown); sky-under's one red in the
  whole run passed in the rerun. Filed with both outputs as #5088.
- at this tree, rebased on 4c0c6c02b (nothing new on main touches
  routing): routing-stage-wide, routing-sky-under, routing-scroll-end,
  i18n-keys: 126/126.

Not tried: the whole GUI suite (mote was down mid-run; it runs after
the push), the real Wails/WebKitGTK app, and a test of the wires
following a card that changes width with the stage's size unchanged.
2026-11-03 21:14:09 +08:00
yetone 4c0c6c02b8 plugin: keep idle plugin sign-ins alive in the background (#5080)
A plugin with auth.refresh had a sign-in renewed only when something
used the account (a request, its models, usage or check-in) within its
refreshLead of expiry. An account left idle past its token's life
lapsed. OrcaTerm's WeChat token lives two hours, and after that its
refresh answers SESSION_EXPIRED for good, so the user had to sign in
again (orinsid, magpie-community/plugins#675).

The gateway now renews each such sign-in as it comes due
(provider.KeepPluginsSignedIn, started beside KeepPluginsListed):

- Due times come from plugin-auth.json through filememo
  (plugin.RenewAt: expires less the lead the host reckons, now listed
  as Provider.Renews/RenewLead). Nothing is asked, and no host started,
  until an account is due. The loop sleeps until the next one, at most
  5 minutes, and renews them one after another.
- A due sign-in goes through the host's own renewal (host.js
  keepSignedIn, which shares renewal() with fresh()). It is one at a
  time per account whoever asks: a request arriving meanwhile waits
  for the same promise, under the cross-process lock file, through the
  account's proxy.
- Kept: accounts switched on and not marked, of a plugin provider not
  switched off, hidden (leftAlone) or being moved.
- A failed renewal marks nothing. It is held back for 1m, doubling to
  at most 30m, for that sign-in only. Only the plugin's
  signIn:"expired" marks it, as at a request.
- A plugin can opt out with auth.keepAlive: false. None in the plugins
  repo needs to: no refresh costs quota, the ones rotating single-use
  refresh tokens (Cline, Factory, Nous, SenseNova, CodeArts, Qoder,
  MiniMax) rotate at use already, and kimi-work's reference accounts
  and Raccoon's desktop reuse never refresh another app's token.

Docs: provider-plugins.md "A sign-in nothing uses"; leftAlone list in
providers-accounts.md.

Run at the pushed head, on mote (mote-run), -tags nogui:
- go test -count=1 -timeout 45m ./internal/plugin ./internal/provider
  ./internal/gateway: ok (109s, 119s, 637s), rebased on origin/main
  6cfe78635. Rebased again on b088fd0f0 (gateway.go, prompt.go
  changed): go build ./..., go vet of the three packages and the new
  tests plus TestLivePrompt*: ok.
- the new tests on Windows (win-run) and Linux (wsl-run): ok.
- GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...,
  go vet ./...: ok. gofmt -l: clean.

Broken by hand, each red, then restored:
- keepSignedIn refreshing by itself, not through renewal()/the lock:
  TestKeepSignedInRenewsIdleSignIns red (r-ok-busy renewed twice
  beside concurrent requests).
- keepAlive:false ignored: red (stayco listed as renewed).
- a network failure reported as gone: red (down: Gone true).
- Go backoff removed: TestKeeperBacksOffAFailedRenewal red.
- the On, Lapsed and leftAlone filters each dropped:
  TestKeptSignInsAreTheOnesSwitchedOn red.
The new tests don't compile on the old code (no KeepSignedIn).

Not tried: a real OrcaTerm account idling past its 2h token with the
gateway running; Windows/Linux runs of the new tests (vet only); a
magpie with many plugin accounts beyond the unit test's look.
2026-11-03 21:01:27 +08:00
yetone b088fd0f09 gui: the panel's header icon is named "Open the main window"; a double-click on the Windows tray icon opens it
isaac_bai on Discord missed the "Open magpie" button beside the quick
panel's Quit, and was setting the tray click to open the main window just
to get back to it; he asked for a double-click on the tray icon.

History: the foot's button (#openMain) was taken out on purpose in
e0ad48641 (10-30, yogurt36 on Discord): the panel had two buttons to the
same window, the header's open-as-a-window icon (#open) and the foot's
"Open magpie". The header icon stayed, but its tooltip said "Open as a
window", which reads as this panel in a window. Rather than bring the
second button back (and undo yogurt36's ask four days later), the icon now
says what it opens: "Open the main window", a string every language
already had (Settings' tray-click choice). "Open as a window" is out of
i18n.js, nothing else used it.

Double-click, per OS, from Wails v3.0.0-beta.24's source:
- Windows: systemtray_windows.go passes WM_LBUTTONDBLCLK on as
  OnDoubleClick. A double-click arrives as LBUTTONUP (the click: the panel
  opens), LBUTTONDBLCLK (now: ShowMain, whose openMain hides the panel),
  LBUTTONUP again; that last one is swallowed once (trayDouble, within
  2s) so it doesn't open the panel over the window.
- macOS: the status item's action runs per mouse-down with no click count
  (systemtray_darwin.m statusItemClicked); a double-click would be the
  panel opened and closed. Not added.
- Linux: StatusNotifierItem has Activate only (systemtray_linux.go); the
  same. Not added.
docs/subsystems/gui-shell.md step 10 says so.

Tests:
- TestTrayDoubleClickOpensTheWindowOnWindowsOnly: windows on, darwin and
  linux off, and app.go wires OnDoubleClick to ShowMain and checks the
  swallow first in OnClick.
- TestTrayDoubleClickReleaseSwallowedOnce: the release after a
  double-click opens nothing, once; the next click, or one past the bound,
  opens the panel. Fixed instants, no sleeps.
- panel-open-once.test.cjs: the header icon's title and accessible name
  are "Open the main window" in en, zh, zh-TW, ja and de, both engines.

Run (at the pushed head's tree before rebase onto 78667e9b7, which changes
only docs/subsystems/gui-shell.md among these files):
- mote: gofmt -l internal/gui clean; GOOS=windows go vet ./internal/gui ok;
  go test -run TrayDouble ./internal/gui ok.
- Linux (wsl-run, magpie-desktop): go vet -tags gtk3 ./internal/gui ok;
  go test -tags gtk3 -run 'TrayDouble|TrayMenu' ./internal/gui ok.
- Windows (win-run, xiaomi-gpu): go test -run TrayDouble ./internal/gui ok.
- mote GUI, both engines: panel-*, phone-web, old-webkit and i18n-keys
  (24 files), 280/280 ok.
- Broken by hand (a copy on mote): trayDoubleClicks false for windows and
  the swallow never reset are both red; the old "Open as a window" title
  is red in every language, Chromium 0/5 and WebKit 0/5.

At the pushed head (rebased on 78667e9b7), mote: gofmt clean, go test -run
TrayDouble ./internal/gui ok, panel-open-once + i18n-keys 14/14 ok.

Not run: the whole GUI suite (a tooltip only, no layout or API change) or
the whole Go suite. Not tried: a real double-click on the Windows tray
icon in the built app, or the panel in the real tray on any OS.
2026-11-03 20:54:01 +08:00
yetone 78667e9b77 gateway: a request in flight shows its model's context window
packinggoods on Discord: Routing's context window card said "the model's
window isn't known" for a request on remote-magpie/claude/claude-opus-5-5
that was still answering, though the remote magpie's list gives that
model's window. The window was put on a route's prompt only when the
request ended (calibrate at the route's end). A live request always
showed it as unknown, on every provider.

Now the window of the model a try goes to is read as the try goes out.
That is windowOf(c.p, c.model), the same call the route's end makes. It
is kept on the route (Route.window, unexported), and the prompt shows it
while the request is under way (livePrompt). This holds whether the
prompt is read before or after the try starts. A fallback to another
model updates it. At the end the answering model's window still comes
first, as before. Codex turns through magpie's Codex backend now work out
Codex's own window (CodexWindow, else models.dev) when the turn begins,
not when it ends, so they show it live too.

Run at this head (rebased on fb1f4856a), on mote:
- go test ./internal/gateway -run 'Window|Prompt|Context|Trace|Codex': ok
- GOOS=linux and GOOS=windows go vet ./internal/gateway: ok; gofmt clean
Run before the rebase (base 7d022bdb6; since then main changed only
gateway-key code in internal/gateway):
- go test -count=1 -timeout 45m ./internal/gateway: ok (724s)
- go vet (darwin, linux, windows) ./internal/gateway: ok

Broken by hand: TestLivePromptHasItsWindow, run on the old code, is red in
both subtests ("in flight: prompt &{Window:0 ...}, want the window
1000000", and Codex's 272000). The done route was right on the old code
too.

Not tried: a real remote magpie on another computer. The test serves its
/v1/models window through catalog.SaveLive, as the remote's list does.
2026-11-03 20:49:32 +08:00
JoeyWu-techandyetone 6cfe786351 agent: Codex that can't be joined again isn't connected by its helper models alone (#3868)
why8023: Codex switched off and on again showed 「已接入」 with its
subagents' and memories' models back, while its own model never reached
magpie. fae438b4a (NancyTom18 on X) made reconnect call Join first, which
fixed the ChatGPT sign-in case, but where Join can't apply then (a
model_provider of the user's own, magpie API) reconnect still put the
helper fields back alone and answered Wired(), which a helper field on
one of magpie's models makes true. So the switch said connected while
Codex's own turns went to the user's provider.

Now, when Join doesn't join and the model Codex was on wasn't one of
magpie's, reconnect gives up and the switch connects Codex as at first,
on one of magpie's models. Where its model was magpie's, that model
routes it, as before. docs/subsystems/agent-wiring.md says so.

coffemon's (JoeyWu-tech) patch 9ee95ba9, re-ported onto fae438b4a: main
already joins first, so only the !ok check is taken, with his
TestCodexOffAndOnJoinsAgainWithItsHelpersOnMagpie (seven cases, all
green on main too since fae438b4a). TestCodexOwnProviderOffAndOnIsNot-
ConnectedByItsHelpers is new and covers the case that was left: a relay
model_provider, Connect, subagents' model on magpie, gpt-5.5 picked
back, off and on.

Run (mote-run, macOS, go1.26.8, -tags nogui):
- the new test: ok. With the check turned off by hand (if false && ...):
  red, "on again ({How:again ...}) with its own model off magpie".
- TestCodexOffAndOnJoinsAgainWithItsHelpersOnMagpie,
  TestCodexReconnectStaysJoined, TestCodexConnectKeepsItsPick,
  TestReconnectKeepsTheLastPick, TestCodexDisconnectStaysWithAccountsOn
  and the OpenCode/OpenChamber tests: ok.

Not tried: the Agents page and a real Codex on a relay afterwards; the
test drives ConnectHow and Disconnect, which the switch calls, with
config.toml in a sandbox HOME.

Batch run, at tree 104d75f0a (the twelve coffemon ports together, on
origin/main 7d022bdb6), mote, macOS, go1.26.8:
- go test -tags nogui -count=1 -timeout 45m on the packages the batch
  changes (agent, autostart, daemon, gateway, library, proc, provider,
  sessions, testenv, tui, gui): ok each.
- GUI, node --test with Playwright 1.62.0, Chromium and WebKit:
  library-*.test.cjs and i18n-keys.test.cjs, 1044 of 1044 pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... and go build ./...: ok at cdd7c8e46, the same
  batch on origin/main 00098f12b one rebase before.
- The whole go test ./... at cdd7c8e46: 86 packages ok, one red,
  internal/cli TestEveryRouteHasACommandOrIsNamed (GET
  /api/context/reply has no command), red on main too (#5026).
- Linux (wsl-run, Ubuntu 24.04, at 339055896, the batch on f4c664a09):
  proc, autostart, testenv, tui ok; agent: only TestGrokInstalled red
  (#3548); #4033's proc.Look reds (Zed, Copilot, Qoder, Cursor, Omp)
  pass.
- Windows (win-run, Windows 11, at 339055896): proc, autostart, testenv,
  tui ok; library and agent red in the same tests as on origin/main
  f4c664a09 (#4115, #1827, #4786; #5068, #5069, #5070 filed now).
- Rebased onto origin/main fb1f4856a (three commits, no file in
  common with the batch) and run again at the pushed tree: gofmt -l
  nothing, go build ./... and go vet ./... ok; go test -tags nogui
  sessions, agent, autostart, tui, proc, testenv ok; i18n-keys and
  library-* 1044 of 1044 pass.
- Not run before the push: the whole GUI suite (a run at cdd7c8e46 was
  cut off at 1170 of ~1174 tests when mote rebooted; it runs again after
  the tag and any red is filed).

Co-authored-by: yetone <9rqwv2ak@gmail.com>
2026-11-03 20:38:11 +08:00