Commit Graph
3181 Commits
Author SHA1 Message Date
yetone 5b46b6142f gui: Names in agents' lists shows the saved choice on Routing and in the provider editor before Settings is opened (#1433, ObsidianArch02)
With plainNames: true, plainOwnNames: false saved, a restart that opened
Routing before Settings showed "Names in agents' lists" as On. suffixMode()
read only `prefs`, Settings' own read of the settings, which stays null
until the Settings page loads, though startup had already read the same
settings into state.settings. The provider editor's Names & levels
(Provider in model names, and its "Agents' lists show ..." line) and a
group editor's label read the same thing, and were wrong the same way.

- suffixMode() reads state.settings, the copy every page draws from. A
  plain-names pick and Settings' own read (loadSettings) now set it as
  well as prefs, as savePrefs and the other cross-page writes already do,
  so the two copies agree.
- Routing's groups can answer before /api/state, so the page can be
  drawn before any settings are in. Each suffix choice records the mode
  it was drawn with, and load() redraws one whose mode the incoming state
  changes (redrawSuffix), with its place's own redraw (Routing's groups,
  the editor's line).

Siblings checked: every other read of `prefs` outside the Settings page.
loadFonts already falls back to bootPrefs, the update row's "Automatic
updates are off" is drawn only on Settings, and the other cross-page
settings (agent order, usage order, panel cards, quota left, desktop
longest, codex credits, auto-reset, check-ins, update pill) already read
state.settings. suffixMode was the only one.

Verified:
- new internal/gui/tests/name-suffix-saved.test.cjs: Routing opened first
  with Off saved (then Settings and back), Routing drawn before a late
  state with "Not on names I set" saved, and the provider editor opened
  first with Off saved; no settings write, no page error. Chromium and
  WebKit, en/zh/zh-TW/ja/de, 1100 and 560px: 30/30 each.
- On the old app.js it fails 30/30 in each engine (expected 'Off',
  actual 'On'; expected 'Not on names I set', actual 'On'). With the
  fix but without redrawSuffix() in load(), the late-state case fails
  10/10 in each engine.
- 86 related GUI files (name-suffix-*, model-suffix-own, plain-names,
  names-fold, gateway-mode, group-*, panel-routing, settings-*, routing-*,
  currency, webdav-settings-refresh, codex-memories-settings,
  click-scroll, i18n-keys): WebKit 376/376; Chromium 375/376, the one
  being routing-blocked en, which fails the same on the old app.js
  (5 of 8 runs of a traced copy): the view scrolls 0 -> 42 -> 201px in
  the frames after the day click and the test takes its "before"
  position during that. Not caused by this change.
- 186 more GUI files that open Settings or Providers: Chromium 943/943,
  WebKit 935/935.
- go build/vet -tags nogui ./internal/gui (embedded assets). No Go
  source changed.
2026-10-10 01:20:25 +08:00
yetoneandtimonwong ca0867e412 gateway: a Grok model's 2500.0 in a call's arguments reaches the agent as 2500, on every route and protocol, deltas and done alike (#1431, timonwong)
Grok's models (grok-4.6, grok-4.7) write a whole number in a tool call's
arguments with a fraction of zeros. Codex reads exec_command's
yield_time_ms and max_output_tokens as u64/usize and write_stdin's
session_id as i32, though their schemas say "number", and serde turned the
whole call away ("failed to parse function arguments: invalid type:
floating point `2500.0`, expected u64 at line 1 column 77"; `17277.0`,
expected i32), so the turn stopped at its first command. Reported 11 of 11
turns through a sub2api relay in front of grok-4.6 and grok-4.7.

What changed (grok_integral.go):
- grokModel/grokServed: a Grok model is one whose id, as magpie names it
  or as it is sent upstream, has a last `/` segment beginning "grok"
  (relay/grok-4.6, x-ai/grok-4, the plugin's grok-4.7).
- wholeNums: a streaming scanner over the arguments' JSON text. A number
  written with a fraction of zeros and no exponent loses the fraction
  (2500.0 -> 2500, -3.00 -> -3, [1.0,2.0] -> [1,2]). Strings, keys, other
  fractions (2.5, 2.50) and exponents (1.0e3) stay as written. It holds
  only a run of ".0…" until the next byte, so arguments cut into deltas
  anywhere come out the same as whole, and the deltas add up to what the
  done events say.
- Relayed (passthrough): intTidy, beside nsTidy and built like it, on
  Responses (function_call items, argument deltas and done, the completed
  response, a whole reply), Chat (tool_calls deltas and messages) and
  Messages (tool_use input and input_json_delta), streamed or whole. A
  line that carries no call passes as it came. Plugin-served Grok and the
  built-in subscription go through the same passthrough.
- Translated: translate sets Request.Grok; encoder() wraps the client's
  encoder in wholeEncoder (outside usageEncoder) and render() rewrites the
  Result's calls (wholeResult), so every client protocol is covered at
  those two choke points.
- Any other model's reply is relayed byte for byte, as before.
- gateway-routing.md says so, and lists the tests.

Scope, against the reporter's 9fd6855b: that commit rewrote only fields a
tool schema typed "integer" or a fixed list of Codex's (codexInts), only
on Responses, and left deltas as they came, so the deltas disagreed with
the done events, and the list missed Codex's other integers (shell's
timeout_ms, sleep's duration_ms, tool_search's limit, the multi-agent
tools' timeout_ms). Codex's own schemas say "number", and JSON has one number type, so 2500 is the same value as
2500.0 for every client; this drops the zero fraction everywhere in a
Grok model's call arguments instead. Its rollout fixtures are kept
verbatim (testdata/grok_integral_args) and its test helpers adapted.

Tests: TestWholeNumsAnyCut (every split point and byte by byte),
TestGrokCallsGiveCodexIntegers (relayed Responses, streamed with deltas
cut whole, byte by byte and at every '.'/zero, and whole),
TestGrokCallsGiveCodexIntegersTranslated (Chat upstream -> Codex),
TestGrokCallsGiveIntegersOnEveryProtocol (Chat relayed, Messages relayed,
Messages translated from Chat), TestGrokCallsByUpstreamName,
TestGrokPluginCallsGiveCodexIntegers (fake plugin, $FAKE_GROK),
TestOnlyGrokCallsGetIntegers (gpt-5.5 byte for byte on Responses, Chat
and Messages relayed; translated keeps 2500.0), TestGrokModel. Each
recorded case checks that the field Codex's own error names is now an
integer of the Rust type it named, wherever Codex reads the call.
With grokModel forced false, every Grok test fails; with the delta
rewriting turned off (intTidy and wholeEncoder), every streamed case
fails on deltas != done.

Run: gofmt -l (clean); go vet -tags nogui ./... on darwin, GOOS=linux
and GOOS=windows; go build ./... and GOOS=linux/windows -tags nogui
builds; go test -tags nogui ./... under a temp HOME; -race -count=3 on
the new tests. End to end: the built binary (`serve`, sandbox HOME, port
47812) in front of a fake upstream streaming 2500.0 a byte per delta on
Responses and Chat; a client reading /v1/responses and
/v1/chat/completions, streamed and whole, got integers in deltas,
arguments.done, output_item.done, completed and output for grok-4.6
(relayed) and grok-4.7 (translated from Chat), and 2500.0 unchanged for
gpt-5.5. The same client against a binary of the parent commit failed
all 12 Grok checks.

Not verified: a real Grok model or a real Codex turn; Messages and Chat
Grok replies have not been seen in the field; a relayed Messages
tool_use input that is rewritten has its keys re-marshalled in sorted
order; exponent forms (2.5e3) are left as written.

Co-authored-by: timonwong <timon86.wang@gmail.com>
2026-10-10 01:09:31 +08:00
yetone 7d0e415e62 plugins: two plugins that sign in to one provider are both listed, each row says which serves it, and Use for picks the other (neiko on Discord)
neiko on Discord installed a third-party plugin beside a plugin of their
own, added by its folder. Only the third-party one could be seen. Both
plugins' auth hooks name the same provider id. The host's auths() keeps
the last plugin in plugins.json for an id, as OpenCode does, so the
user's own plugin silently lost it:
- its row read "Signs in to nothing magpie can use";
- its provider was gone from the Add sheet;
- keepUnloaded could list the id a second time, from the
  plugin-providers.json kept before.
A package-name clash and a display-name clash were tried as well. Both
plugins stay visible in those cases, because a folder plugin's name is
its path.

What changed:
- host.js:
  - init gives each loaded plugin the ids it signs in to (provides) and,
    for each id another plugin serves, that plugin's spec (servedBy).
  - auths() honours plugins.json's new prefer map (id -> spec).
  - Only the serving plugin's provider.models hook runs for the id.
- plugin:
  - Clashes() turns provides and servedBy into {id, by, with} per spec.
  - Prefer() records a pick and restarts the host.
  - Remove drops the removed plugin's picks.
  - Re-adding a plugin under a new spec carries its picks over.
  - remove, off, options and prefer find a plugin by its exact spec
    before its package name (indexOf), so acting on one plugin never
    reaches another of the same package.
  - keepUnloaded no longer re-adds a provider from before when another
    plugin serves its id now.
- GUI:
  - /api/plugins rows carry clashes, with the provider's listed name.
  - POST /api/plugins/prefer {spec, provider}.
  - The serving row says "{other} signs in to {name} too; this one
    serves it".
  - The other row says, in amber, "{name} is served by {other}, which
    signs in to it too", with a "Use for {name}" button.
  - New strings in zh, zh-TW, ja and de.
- CLI: `magpie plugin` prints the same lines, with the command that
  fixes it, and `magpie plugin use <name> <provider>` makes the pick.
- Docs: docs/subsystems/provider-plugins.md, docs/reference.md and
  site/public/docs/{,zh/,ja/}plugins.html.

What was run:
- Reproduced under a sandbox HOME with magpie web on 3562: a fake npm
  plugin and a folder plugin, both on id "acme".
  - Old binary: the local row had providers [] and /api/providers
    listed acme twice.
  - New binary: both rows carry the clash; prefer moves acme to the
    folder plugin; remove clears the pick and leaves the other plugin
    serving acme.
- New Go tests:
  - TestTwoPluginsOneProvider, a real Bun host: Prefer, restart,
    off/on and Remove.
  - TestClashes, TestPluginNamedExactlyFirst and
    TestKeepUnloadedLeavesAServedID.
  - TestPluginsClashRows (gui) and TestPluginListSaysClash (CLI).
  - Each fails when its piece is broken by hand: prefer ignored in
    host.js, the keepUnloaded id check removed, name before exact spec,
    Remove keeping picks, no provides, no clashes in the rows, no
    prefer route.
- plugin-clash.test.cjs, in Chromium and WebKit, in en, zh, zh-TW, ja
  and de, at 1100 and 560px: 22/22 pass. It times out on the old
  plugins.js.
- gui-de, gui-ja, gui-zh-tw, i18n-keys and every plugin-*.test.cjs:
  248 tests.
  - 245 passed in the 4-wide run.
  - plugin-moved-signin (webkit) failed once in that run, then passed
    3/3 alone and 26/26 in a smaller 4-wide rerun.
- gofmt -l; go vet ./...; GOOS=linux and GOOS=windows go vet -tags
  nogui ./...; go build ./...
- The full go test -tags nogui ./... under a temp HOME with the caches
  pinned: 44 packages ok, none failed.
- After rebasing onto 05917100 (plugins.css conflict with a3a8e257's
  chip rules, both kept): plugin, gui and the root plugin tests, vet on
  darwin, linux and windows, and the 248 GUI tests above, all green
  (248/248 this time).

Not tried: a real third-party plugin, neiko's own plugins, and Windows
beyond vet.
2026-10-10 00:55:38 +08:00
yetone 059171006b library: DeepSeek Harness is given a server's ${NAME} as a !!js expression it reads from its environment (#1435, CnsMaple)
A Library MCP server whose headers or env named a variable as ${NAME}
(#1250) was refused for dsh, because dsh had no reference syntax in
refsOf. dsh does have one: a YAML !!js value is evaluated as the row
activates (dsh 0.2.0-rc.2: cordis-plugin-include's entryListSchema
reads the tag, quoted or not; cordis-plugin-loader's interpolate
evaluates it across the whole config), and dsh-mcp-client's README uses
GITHUB_TOKEN: !!js process.env.GITHUB_TOKEN. A stdio server needs it so:
it inherits dsh's environment without credential-shaped names
(scrubbedParentEnv).

What magpie writes now (refsOf fmtDsh -> refDsh, dshRef):
- a whole ${NAME}: !!js process.env.NAME (bare, as the README has it)
- text mixed with variables: the text as JSON string literals joined
  with (process.env.NAME ?? ""), YAML-quoted. The user's text is only
  ever inside a JSON string literal, so nothing in it runs as code, and
  NAME is the envRef pattern [A-Za-z_][A-Za-z0-9_]*. An unset variable
  inside a mixed value is "", not "undefined".
dshUnref reads exactly those forms back as ${NAME}, so an entry magpie
wrote reads as same and a sync changes nothing; any other !!js still
keeps the entry the user's (hasJS), as before.

The reporter asked for the value to be resolved into a literal when the
file is written. This writes a reference instead, keeping #1250's rule
that the token never lands in an agent's file as plain text. dsh
evaluates it from its own environment at load time. Their side note
that a quoted !!js isn't evaluated is not what dsh 0.2.0-rc.2 does: its
own --dump-config prints !!js quoted, and the quoted forms evaluated in
the run below.

Since AgentView.NoEnvRefs comes from refsOf, dsh's chip is no longer
greyed and the GUI notice drops it with no string change.
docs/subsystems/library.md says what dsh gets.

Run:
- real dsh 0.2.0-rc.2 `dsh headless` in a sandbox (HOME and DSH_HOME
  under a scratch dir, never ~/.dsh), on a cordis.patch.yml written by
  magpie's mcpFile: a stdio fixture got T1435_A=<token> (whole) and
  "Bearer <token>" (mixed); an injection string with quotes, backticks,
  ${, backslashes and "'); process.exit(3); ('" arrived verbatim; an
  unset variable in a mixed value gave "pre--post"; a streamable-http
  fixture received Authorization: Bearer <token>, the whole-variable
  header and the literal header. magpie read every entry back as same.
  A whole !!js process.env.UNSET makes dsh leave the server out as an
  invalid config.
- go test -tags nogui ./... (temp HOME, pinned caches): green.
- break by hand: refsOf without fmtDsh, encode writing raw values, and
  decode not unref'ing each make TestEnvRefsDsh fail (decode also
  TestDshImportKeepsJS).
- gofmt -l; go vet ./...; GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/library; go build for darwin, linux and windows (nogui).

Not run: dsh on Windows (the reporter's system), and a real LLM turn
calling a tool through the server (no dsh account in the sandbox; the
MCP servers had connected before dsh stopped for its missing LLM
credential). No GUI test was run, as no GUI file changed.
2026-10-10 00:43:26 +08:00
yetone a3a8e25792 plugins: a repository tagged magpie-plugin shows the icon its package.json gives (yetone: 非官方的插件能否支持 icon)
magpie.icon, an https URL or a data:image URI, is read with the rest of
package.json and kept through pluginOwnIcon as an installed plugin's is;
the card shows it, else the puzzle piece.

Ran: go test ./internal/plugin ./internal/gui ./internal/provider; the
plugin GUI tests in Chromium and WebKit (en/zh/ja/de, 980 and 440).
2026-10-10 00:42:37 +08:00
yetone 849faea3a3 plugins: a card's kind and Unofficial chips without fills, provider and middleware each their own hue (yetone)
Unofficial is a hairline with a small amber dot; what a plugin is reads as
its glyph and word, periwinkle for a provider and teal for middleware,
apart from the community badge's green.

Ran: plugin-github, plugin-middleware and plugin-check-updates GUI tests in
Chromium and WebKit (en/zh/ja/de, 980 and 440), light and dark looked at.
2026-10-10 00:42:37 +08:00
yetone 2c1b593675 library: Zed takes MCP servers, in its settings.json context_servers (lc on Discord)
lc on Discord ("agent未识别到zed"): the MCP server editor's agent chips
had no Zed. magpie already edits Zed's settings.json for its model, and
Zed reads its MCP servers from context_servers in that same file, so Zed
is now an MCP target like the other agents.

What Zed takes, from its own source (zed-industries/zed 2c99f547):
- crates/settings_content/src/project.rs ContextServerSettingsContent is
  untagged: a command as command/args/env (enabled, remote, timeout
  beside it), a url as url/headers (enabled, timeout, oauth), or an
  extension's entry as settings. docs/src/ai/mcp.md writes the same.
- crates/context_server/src/transport/http.rs only POSTs (and DELETEs):
  streamable HTTP, no SSE. So an SSE server is refused for Zed and its
  chip is greyed with the existing reason (AgentView.NoSSE).
- stdio_transport.rs hands command.envs over as written and http.rs sends
  headers as written: no ${NAME}. Zed is refNone, so a server naming a
  variable is refused and its chip greyed (AgentView.NoEnvRefs).

Changes:
- targets.go: "zed" gets mcpFile{agent.zed's settings.json, fmtZed}; the
  path is agent.zed's for every OS (~/.config/zed, $XDG_CONFIG_HOME/zed,
  %APPDATA%\Zed, $MAGPIE_ZED_CONFIG_DIR).
- mcp.go: fmtZed under "context_servers", encoded as Cursor/Desktop are;
  magpie owns url/headers/command/args/env only, so enabled, remote,
  timeout and oauth the user sets on magpie's entry stay. The file is
  JSONC and edited in place (edit.SetJSON/DelJSON), so comments, other
  settings and the user's own servers are kept.
- mcp.go, sync.go: an entry Zed's extensions configure (settings, no
  command or url) is never written over: a library server by that name
  is a Problem for Zed (errZedExtension), asking for another name.
- envref.go: a comment citing why Zed has no syntax.
- docs/subsystems/library.md: Zed's file, format, no SSE, no ${NAME},
  the extension guard, and the new tests.

Tests:
- internal/library/zed_mcp_test.go TestZedMCP, on a Zed-style JSONC
  settings.json with comments, trailing commas, a user stdio server
  (enabled:false, timeout), a user remote server and an extension's
  entry, at the default path and under MAGPIE_ZED_CONFIG_DIR: found
  servers, the page's chips, written entries, SSE/${NAME}/extension
  refusals, user keys kept through an edit, uncheck and remove leaving
  only the user's, comments kept, a Sync rewriting nothing.
- internal/gui/tests/library-zed-mcp.test.cjs: Zed's chip on every row
  and in the editor, a click gives it the server, greyed with the reason
  for SSE and ${NAME}; Chromium and WebKit, en/zh/zh-TW/ja/de, 1100 and
  560px, no sideways scroll. No new strings.

Broken by hand, each went red and was restored: no zed target, no
extension guard, SSE allowed, enabled owned by magpie, wrong key (Go);
Zed without noSSE (GUI).

Run (temp HOME, Go caches pinned): gofmt -l internal/ (clean); go vet
-tags nogui ./... on darwin, GOOS=linux and GOOS=windows; go vet
./internal/library ./internal/agent; go build ./..., GOOS=linux go build
-tags nogui ./..., GOOS=windows go build ./...; go test -tags nogui ./...
(all ok); node --test library-zed-mcp.test.cjs (22/22, both engines).

Not verified: a real Zed reading the written file (the live
~/.config/zed was never touched); Linux and Windows beyond vet/build;
Zed found in WSL (not in ownFolder, so no MCP target there); a
project's .zed/settings.json (not added).
2026-10-10 00:37:32 +08:00
yetone 189586612e agents, gateway: Codex's subagents go on a model set in its row, a ChatGPT account's (willz on Discord)
Codex's lead names each subagent's model itself in spawn_agent, and
Codex's [agents] config can't overrule it. The Agents page's Codex row
now has a "subagent model" square (the app's model picker, Default
first). Its options are only models a ChatGPT account in magpie serves,
because a subagent's task is sealed for ChatGPT accounts.

- settings.CodexSubagentModel holds it. It is an agent Field
  (subagent_model), so the TUI/CLI, profiles, davsync's "agents" part
  and WSL twins carry it too. The setter refuses another provider's
  model. It keeps a ChatGPT account's model that isn't served now, so a
  backup restored on another computer still applies (ApplyFields stops
  at the first failed Set). POST /api/settings keeps it.
- The gateway (codexSubagentPick) moves a collab_spawn request onto it.
  codexBackend does this for Codex's own bare models; serve() does it
  for any other model. When no ChatGPT account on in magpie serves it,
  or a held gateway key may not use it, the request stays on the model
  asked for. Route.Subagent records asked/to/kept. The lead's turns,
  titles, guardian and the rest are never moved. Off (the default)
  changes nothing.
- Routing page: kindWhy says the subagent was put on the model set, or
  stayed on its own and why. "only account on for" names the model it
  went on. Strings added in zh, zh-TW, ja and de.
- docs/subsystems: gateway-routing.md and agent-wiring.md describe it.

Run (darwin, rebased on origin/main):
- gofmt -l internal/: clean.
- go vet -tags nogui on gateway, provider, agent, gui and settings:
  darwin, GOOS=linux and GOOS=windows.
- go build ./...
- HOME=<temp> go test -tags nogui ./...: all ok.
  TestSettingsSaveKeepsWhatItDoesNotSend flagged the new field; it is
  now set there.
- GUI tests, Chromium + WebKit:
  - codex-subagent-model.test.cjs: 20/20 (en, zh, zh-TW, ja, de at
    1100 and 560 px).
  - Also green: routing-kind, subagent-effort, codex-memories,
    codex-memories-settings, i18n-keys, gui-ja, gui-de, gui-zh-tw and
    click-scroll.

Failing without the change (codexSubagentPick returning nil):
- TestCodexSubagentPutOnTheModelSet
- TestCodexSubagentOnAnotherProviderPutOnTheModelSet
- TestCodexSubagentModelNotServedKeepsTheAsked
- TestCodexSubagentModelHeldKeyKeepsTheAsked
TestCodexSubagentModelLeavesOtherRequests guards the other side: the
lead's turns, titles and guardian stay untouched.

Not tried with a real Codex CLI and ChatGPT account. A subagent spawn
needs a signed-in Codex home, and this session may not touch the live
~/.codex. The fake ChatGPT backend tests cover both routes.
2026-10-09 23:38:50 +08:00
YAYOI27andClaude aa82288fb6 usage: Volcengine Ark's Coding Plan and Agent Plan windows, read with the account's access key (#1427, yayoinoyume)
Ark tells a Coding Plan's or Agent Plan's 5-hour, weekly and monthly
windows only to the account's control plane (GetCodingPlanUsage,
GetAFPUsage on open.volcengineapi.com), signed with the account's
AccessKey ID and Secret, never to the plan's inference key. An Ark
provider's editor now takes that access key, and the Usage page shows the
plan's windows as a card.

From yayoinoyume's feat/volcengine-usage, reviewed and reworked:
- Signing is volc-sdk-golang's (base/sign.go GetSignRequest, 06f9ef66):
  signed headers sorted (content-type;host;x-content-sha256;x-date), only
  Action and Version in the query. The branch signed them unsorted and put
  Region in the query. TestVolcSignMatchesSDK pins two signatures the SDK
  made.
- The card is in PlanQuotas beside the Step Plan's (its cache, last
  reading, refresh and `magpie quota wait`), not in the subscription
  cards. One per access key and plan.
- The plan is the endpoint's: /api/coding asks GetCodingPlanUsage,
  /api/plan GetAFPUsage, pay-as-you-go none, in the host's region. The
  branch asked both and showed whichever answered.
- Dropped guessed reply fields; the Coding Plan reply is the one
  pi-ark-usage, dsh-ark-quota and ArkCodingPlanUsage read. AFP buckets are
  read in the forms dsh-ark-quota and arkcli read (Used of Quota or Total,
  or Percent), plus Tier; none was seen from a real account.
- An Ark provider is known by its host, not the preset id, so a copy or a
  custom provider takes the key too.
- The Secret is never sent to the page (accessKey {id, secretSet}); a
  blank Secret keeps it, a save without the ID keeps both, Remove
  (clearAccessKey) drops both, an ID with no Secret is refused.
- The pair goes where keys go: AddCopy, Restore, Mirror, backups and
  davsync carry it only with keys (withoutKeys), and a keyless restore or
  sync keeps this machine's. CLI: access.key, access.secret.
- A changed access key drops the cached cards (ForgetPlanQuotas).
- UI strings in zh, zh-TW, ja and de.

Nothing was tried against the real Volcengine API: there was no access
key. A local fake checked the real request PlanQuotas makes against
volc-sdk-golang's own GetSignRequest (both actions, two regions); it
lives outside the repo, so go.mod is unchanged.

Run: gofmt -l; go vet (darwin), GOOS=linux and GOOS=windows go vet
-tags nogui on provider, gui, backup, davsync and the root; go test
-tags nogui ./internal/provider ./internal/gui ./internal/backup
./internal/davsync . under a temp HOME; node --test
volc-access-key, zhipu-team, gui-ja, gui-de, i18n-keys in Chromium and
WebKit. Fail without the change: TestVolcSignMatchesSDK (unsorted
headers), TestAddCopy, TestBackupBalanceToken, TestNoKeys,
TestTakeBalanceToken, TestSyncBalanceToken (pair not carried),
TestProviderSaveKeepsVolcengineSecret (blank Secret dropped),
volc-access-key (Remove not posted).

Co-authored-by: YAYOI27 <111715843+yayoinoyume@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
2026-10-09 23:25:04 +08:00
yetone ea1c5d0457 gateway: Antigravity's 429 to a Claude Code / Agent SDK system prompt is the prompt turned away, not a quota, everywhere, and the agent gets 400 (#1425)
Antigravity answers the system prompt of Claude Code and the Claude Agent
SDK (Claude Desktop's chats) with 429 "Resource has been exhausted" at
whatever quota is left (#666). The detail text already said it was not a
quota, but when Antigravity was the last one left (a direct model, the
reporter's case) the route still fell through to failureOf: the try was
counted 额度用尽 on the Routing page and in the account's tally, and the
429 went to the client, so Claude Desktop asked ten times over.

What changed:
- codeassist.go: antigravityTurnedAway(p, system, said) needs the
  Antigravity account, a Claude Code / SDK system prompt and the
  "resource has been exhausted" words. A real quota 429 ("You have
  exhausted your capacity ... reset after ...", QUOTA_EXHAUSTED) stays a
  quota and rests the account as before. turnedAwayStatus = 400 (the
  Anthropic and OpenAI SDKs retry 408, 409, 429 and 5xx, not 400);
  ledger ErrType "prompt_turned_away".
- gateway.go: such a try is failPrompt (was failRefused in a group, and
  failQuota as the last), no rest, no usage re-asked, no passing retry,
  no auto reset. The last one left answers the agent 400 with the
  vendor's words and the hint; in a group the next member is asked, and
  if it fails only on a quota the agent is told the turned-away 400. The
  in-reply (stream error event) form is told the same way.
- continuation.go / translate: the hint is appended to the in-reply form
  too, and the ledger row carries the ErrType.
- routing.js: the hint joins HINTS, so the Routing page shows Antigravity's
  words as "It said: ..." and the explanation on its own line, translated
  in zh, zh-TW, ja and de (i18n.js).

Tests (each fails on the old gateway.go/continuation.go/routing.js):
- TestAntigravityTurnedAwayLastIsNoQuota (stream and not): 400, asked once,
  failPrompt, no rest, ledger 400 prompt_turned_away.
- TestAntigravityTurnedAwayInsideTheReplyLast, TestAntigravityTurnedAwayThenAQuota,
  TestAntigravityQuotaOnAClaudeCodeTurnStaysQuota (scope: a real quota
  429 still rests and reaches the agent as 429),
  TestAntigravityTurnedAwayHintIsTheRoutingPages.
- gui/tests/routing-ag-turned-away.test.cjs: row status word, account
  tally, "It said" line and the hint line, in en/zh/zh-TW/ja/de.
The real-quota fixture's words are from public reports, not captured from
a real account.

Run: gofmt -l internal/ (clean); go vet ./internal/gateway/ and
GOOS=linux / GOOS=windows go vet -tags nogui ./internal/gateway/;
go build ./..., GOOS=linux and GOOS=windows go build -tags nogui ./...;
go test -tags nogui ./internal/gateway/ ./internal/gui/... under a
scratch HOME with pinned caches (ok); GUI node tests (new test,
routing-*, gui-de, gui-ja, gui-zh-tw, i18n-keys) in Chromium and WebKit.
2026-10-09 23:21:41 +08:00
yetone c3e673b061 codex: the account Codex is signed in to goes by the name it is saved under, so two Team seats of one email are weighed apart (#1424, lingqiqi5211)
One email in two Team workspaces is saved as "me@example.com · Team" and
"me@example.com · Team · <workspace>" (codexName). codexAccount still named
the account Codex is on by codexUser alone, "me@example.com · Team". With
Codex signed in to the second seat, its candidate used the second seat's
credentials under the first seat's name. Everything keyed on Account.User
then read the first seat's records: Smart's allowance (98% used, so the
seat with 2% left was ranked last), rests and sticks (restKey/who), the
usage cap, per-account proxy and model list, a gateway key's account list
(LoginID), OwnPaused, and the Routing page's name.

- codexLiveName (logins.go): codexName over the saved logins, shared by
  liveLogin and codexAccount, so the provider's Account.User is the saved
  name.
- SessionIdentities: a saved Codex identity goes by its saved name, and the
  one from auth.json by that of the saved one of its workspace and member,
  so a session of the second seat is told as that seat's.
- providers-accounts.md: the Codex naming rule.

Stored records: nothing keyed under a name that goes away. The first seat
keeps "email · Team"; the second seat's rests, caps, proxy, model list and
usage are already under its saved name, written while it wasn't the one in
use. Records written under the first seat's name while the second was in
use can't be told apart now. Rests run out and readings are read again, so
none is migrated.

Tests: TestCodexTeamSeatsOfOneEmailWeighedApart (gateway): Team A 98%,
Team B (Codex on it) 2% with its week renewing first, another email 20%.
On the old code it fails with "sent to ws-other; want the seat Codex is on"
(and, with its name check, "goes by \"me@example.com · Team\""). With
session_identity.go reverted, TestCodexWorkspaceSessionIdentities (provider)
fails with "the seat Codex is on: [me@example.com · Team]".

Run: gofmt -l (clean); go vet, GOOS=linux and GOOS=windows go vet -tags
nogui on provider, gateway, usage; go build -tags nogui ./... on darwin,
linux, windows; go test -tags nogui ./internal/provider ./internal/gateway
./internal/usage under a temp HOME with pinned caches: all ok. Not tried
with real accounts: no two Team seats of one email are available here.
2026-10-09 23:16:53 +08:00
yetone 319b72c7a5 gateway: the loop guard's long-reply test streams 1000 lines, not all of gateway.go, and waits a minute (69c21cdd's macOS -race CI red)
TestLongReplyThatDoesNotLoopGoesThrough/gemini failed on macOS -race in
run 37946485821: "the stream never ended". It streamed all of gateway.go
(199KB, ~20k events of 11 bytes) through the gateway on each protocol, and
askStream waited 20s. Locally under -race each protocol took ~5s with the
guard and ~5s without it (5.0s off, 6.0s on for gemini), so the time is
the gateway translating 20k events, and CI's runner is ~4x slower: a
bound with no room, not a slow guard.

- The test streams gateway.go's first 40KB, cut at a line end (1001
  lines, several times the guard's 256-unit window).
- askStream waits a minute.
- TestLoopGuardLeavesOrdinaryRepliesAlone feeds the first 256KB of each
  file (app.js and i18n.js run to megabytes): 72s -> 37s under -race.

Ran: gofmt -l, go vet (darwin, GOOS=linux, GOOS=windows), go test -race
-run 'TestLong|TestLoop' ./internal/gateway (long reply 3.9-4.7s per run
for all 4 protocols).
2026-10-09 23:14:39 +08:00
yetone ab72c8eb85 gui: TestCoveredWindowStaysUp hides magpie and checks the window in one step, so the activation its open asked for can't unhide magpie in between (macos-latest, CI run 37942751214)
Cause: on macos-latest the helper exited 1 with "window up: timed out
waiting until magpie is hidden" (6.06 s: the whole 5 s wait). It passed
on 3cd0b5f7's own run and the ten green runs after it, so it is a flake,
not a missing window server: the open and covered steps before it
passed on the same machine. Opening the window (openMain -> showHere ->
Focus) asks the Mac to activate magpie, which it does through the
window server and the run loop, not at once. On a loaded CI machine that
activation can still be pending when the test hides magpie a moment
later; it lands right after the hide and unhides magpie, which puts the
window back, so every poll found it open. NSApp hide: itself is
synchronous here (hidden with no window ordered in, in the same
main-thread block), active or not, and under full CPU load. That the
CI log has no line between is inferred from this: the only thing that
puts a hidden app's windows back is unhiding it, and the helper's only
activation is the open's.

Change: the test's hide step hides magpie and reads whether the window
counts as up in one block on the main thread, and hides again when it
finds magpie shown again. No production code changes: a user can't hide
magpie with Command-H before it is active. Not skipped: the test needs
nothing CI lacks.

Run:
- The old step with a late activation injected (queued from another
  goroutine while the hide block runs, not committed): FAIL 3 of 3,
  "window up: timed out waiting until magpie is hidden" in 5.8-6.3 s,
  the CI failure. The new step with the same injection: ok, 3 of 3.
- Guarantee still checked: windowUp with its "open as magpie was hidden"
  clause removed fails the new test, "hidden with magpie: the window
  counts as up=false, want true".
- go test -count=10 -run TestCoveredWindowStaysUp ./internal/gui: ok.
  Before the change, load alone didn't reproduce it here: three copies
  at a time, 15 runs, with a busy loop on every core, all passed.
- gofmt -l: nothing. go vet ./internal/gui (darwin), GOOS=linux and
  GOOS=windows go vet -tags nogui ./internal/gui, GOOS=windows go vet
  ./internal/gui: clean. go test ./internal/gui (darwin, under a temp
  HOME with pinned caches): ok.
2026-10-09 23:07:44 +08:00
yetone 570b8fdb2a provider: swapping LoginUsage's or Claude /usage's stand-in waits for the readings still running through the old one (data race in CI run 37942751214)
Cause: TestClaudeAccountBackOnceItsWindowRenews (a2c39053) failed the
ubuntu race shard of run 37942751214. Its Cleanup's LoginUsageVia(nil)
wrote the package-level stand-in while a reading Allowances had started
(routing.go:419) was still reading it in loginUsageAt. Allowances reads
in the background on purpose and returns without waiting (only the very
first ask waits, and not for long), so a reading can outlast the caller,
and the test. The window: Allowances deletes c.loading before it tells
the renewed hooks, so the test's next poll can start another reading
just as the rest it waits on is lifted; the test ends with that reading
in flight. In production the stand-in is never set, so there is no
production race; the goroutine outliving its caller is the design (it is
bounded by its 30 s context).

Change: the stand-in is held for reading while it runs, and
LoginUsageVia takes it for writing, so it returns once no reading is
running through the one it replaces and none starts through it after.
That fixes every test that swaps it (gateway claude_renewed and
allowance_stale, provider routing, allowance_renewed,
codex_reset_deadline, window_renewed), not only the one that failed.
UsageClaudeVia's claudeCLIUsage is the same shape (tests swap it, and
Allowances' background reading of a Claude account reaches it through
readClaudeUsage), so it gets the same treatment; claude_usage_test's
restore goes through UsageClaudeVia. ProbeClaudeVia is left: a Claude
account test calls it synchronously, nothing reads it in the background.

Tests: login_usage_via_test.go holds a call through each stand-in and
checks the swap waits for it.

Run:
- Red before: with a 30 ms delay injected into loginUsageAt and before
  Allowances tells the renewed hooks (not committed),
  go test -race -count=20 -run TestClaudeAccountBackOnceItsWindowRenews
  ./internal/gateway/ printed 7 "WARNING: DATA RACE", the write at
  login_usage.go:43 from the test's Cleanup and the read at
  login_usage.go:63 from Allowances.func1, as on CI. Same injection with
  this change: ok, no race. (-race -count=50 without the injection
  passed on the old code too; the window is too narrow on this Mac.)
- The new tests with the swap made unsynchronised again: both FAIL
  "swapped while a call was still running through the stand-in it
  replaced"; with the change: PASS, -race -count=5.
- gofmt -l: nothing. go vet (darwin) ./internal/provider ./internal/gateway
  ./internal/gui; GOOS=linux and GOOS=windows go vet -tags nogui on the
  same: clean.
- Under a temp HOME with pinned caches: go test -tags nogui
  ./internal/provider ./internal/gateway ok; go test -race
  ./internal/provider ok; go test -race -count=20 -run
  '^(TestClaudeAccountBackOnceItsWindowRenews|TestAllowance.*)$'
  ./internal/gateway ok.
- go test -race -tags nogui ./internal/gateway (whole package, temp HOME):
  ok in 635 s, no race.
2026-10-09 23:07:44 +08:00
yetone d7f3c20be3 grok: a Codex subagent's plain agent_message goes to Grok as the user's message, not refused with 422 "unknown item type" (plugins#61, opencode-grok-auth 0.1.11)
Grok's Responses backend refuses a request carrying Codex MultiAgentV2's
agent_message item (a subagent's task, or its reply kept in the lead's
history) with 422 unknown item type "agent_message". plugins#61 counted
512 such 422s on a moved Grok subscription from 10-03 to 10-09, and fixed
it in @magpie-community/opencode-grok-auth 0.1.11 (on npm).

What changed:
- the grok mover's min goes from 0.1.10 to 0.1.11, so keepMovedCurrent
  updates moved users' plugin, and its comment says the fix.
- grokBody (the built-in's request shaper, which also runs for the Grok
  plugin's provider, plugins.go) does what the plugin does: an
  agent_message whose content is a non-empty list of input_text /
  input_image parts goes as {"type":"message","role":"user"}, with
  "From <author> to <recipient>\n\n" (or From / To alone, or nothing)
  as its first part, in its place among the input. One with
  encrypted_content on the item or a part, an empty or null content, or a
  part of another kind is left byte for byte, so magpie reads no sealed
  task and the gateway's sealed-task guard still sees it. A body with no
  agent_message is returned as it came.

Tests:
- provider: TestGrokBodyAgentMessageGoesAsUser (the plugin's task, reply
  with an image between a call and its output, sender alone / recipient
  alone / none) and TestGrokBodyLeavesSealedAgentMessage (the plugin's
  seven sealed or malformed items, and an ordinary history byte for byte).
- gateway: TestGrokGetsAgentMessageAsUser (built-in, streamed and not,
  through the handler) and its parity TestGrokPluginGetsAgentMessageAsUser
  (the Grok plugin's provider, streamed, relayed).
- With origin/main's grok.go back, TestGrokBodyAgentMessageGoesAsUser,
  TestGrokGetsAgentMessageAsUser and TestGrokPluginGetsAgentMessageAsUser
  FAIL ("the agent_message went as" the untouched item); with the change
  they pass.

Run: gofmt -l (nothing); go vet, GOOS=linux and GOOS=windows go vet
-tags nogui on ./internal/provider ./internal/gateway (clean);
go test -tags nogui ./internal/provider ./internal/gateway under a temp
HOME with pinned caches (ok). Not tried against the real Grok backend:
no live Grok request was made.
2026-10-09 22:48:55 +08:00
yetone acdaa28aa1 codex: a conversation that searched the web declares cached search to the ChatGPT backend, so its compaction and turns aren't refused "response protection is unavailable" (#1270, #1099)
The ChatGPT backend answers HTTP 200 and only `event: error` "response
protection is unavailable" to any request whose input replays one of its
own web_search_call items while the request doesn't declare the web_search
tool. Probed on a real ChatGPT Pro account (gpt-6.1-sol, 2026-10-09) with
a real searched turn: refused with tools [], with function tools only and
with a compaction_trigger; answered once {"type":"web_search",
"external_web_access":false} is declared. A Responses Lite request refuses
a top-level web_search (400) but takes it in an additional_tools item. So
xjdata's case (Codex compacting a custom provider's conversation itself, a
plain /responses with tools [] that magpie's codexCompact never sees) failed
every time once the session had searched, and congee949's thread
descriptions too.

What changed:
- provider.DeclareSearch / declareSearch: when the input holds a
  web_search_call and nothing declares search, add cached-only web_search to
  the tools, or for Lite (header, reasoning.context all_turns, or an
  additional_tools item present) to the additional_tools item (prepended
  when there is none). With no tools offered, tool_choice becomes "none" so
  the model can't search; a forced choice is kept. Otherwise the body is
  unchanged (bytes untouched when no web_search_call is in it).
- codexBody (every ChatGPT account route: serveAgent, codexCompact, warmup,
  magpie's codex/* models) calls it; codexUpstreamOn calls it for Codex's
  own sign-in relayed to the backend's /responses.
- Not changed: siwc, API-key passthrough to api.openai.com, the legacy
  /responses/compact endpoint (no evidence they are refused so; not probed).
- docs/subsystems/gateway-routing.md names the cause and the fix.

Tests: internal/gateway/search_history_test.go replays the backend's real
items from that probe against a fake that refuses as the backend did.
TestSearchedConversationCompactsOnAnAccount, ...FunctionTools and
...OnCodexSignIn fail on the old code with "event: error"; ...CompactionTrigger
fails with "asked 2 times, not once". TestUnsearchedConversationUnchanged
and provider TestDeclareSearch cover what's left alone.

Run: gofmt -l (clean); go vet, GOOS=linux go vet -tags nogui, GOOS=windows
go vet -tags nogui on internal/provider and internal/gateway; HOME=<temp>
go test -tags nogui ./internal/provider ./internal/gateway (ok). Real
account, sandbox magpie on 127.0.0.1:3491 under a scratch HOME, replaying
the real searched history: old binary -> /v1/responses codex/gpt-6.1-sol
text compaction with tools [] and /backend-api/codex/responses (standard
and Lite compaction_trigger) all "response protection is unavailable";
new binary -> all response.completed, Lite with a compaction item.
Codex CLI 0.161.0 end to end was not done: on a custom provider it
offered no web_search tool, so no search could get into its history.
2026-10-09 22:40:53 +08:00
yetone 69c21cdd77 gateway, settings, gui: a reply whose reasoning or text has become a loop of the same few lines is ended with an error the agent can act on, instead of running on to its output limit (#1359, Moody-Sin: WorkBuddy's DeepSeek v4.1 flash at max effort reasoned "Now." "Writing." "Go." "Let me write." "OK." "Producing." … until max tokens, while dsh waited and Pi hung)
holdWriter.Write, which every streamed try goes through (passed through or translated; a key's, a built-in subscription's, or a plugin's fetch, as a moved WorkBuddy's), feeds a loopGuard (loop_guard.go). It reads the reasoning and the text of each protocol's deltas (Anthropic, Chat, Responses, Gemini) and cuts each into units: lines and sentences, compared without case or a closing stop. A list's "1." or a decimal doesn't end a sentence. A unit with no word in it (braces, rules, 0x00, hashes, rows of numbers) isn't counted. When the last 256 counted units of either are among 24 or fewer distinct ones, the try is cut. What came with that write goes out, then the protocol's stream error (Anthropic error event, Chat error chunk, Responses response.failed server_error, Gemini 502 UNAVAILABLE), naming the loop and quoting its units, and the vendor's request is cancelled. The cycle needn't be exact; the reporter's has 9 units in two variants. It falls back to nobody and rests nobody (fail "loop"), and the usage record's err_type is reply_loop. A reply sent whole (no stream, or Gemini without alt=sse) isn't read. Settings › Models › Replies › Stop looping replies (noLoopGuard, on by default) turns it off; new strings in zh, zh-TW, ja and de.

Tested:
- loop_guard_test.go, with the screenshot's 28 lines cut into random 1–7 byte pieces, as one line, and in Chinese. It trips within the window. It reads every protocol's shapes, and tool-call arguments never trip it.
- No trip on magpie's own sources fed as both reasoning and text: gateway.go, fallback.go, anthropic.go, app.js, i18n.js, app.css, routing.js, sessions.js, index.html, docs, LESSONS.md and go.sum. Nor on generated numbered lists, logs, CSV, hex, rules and base64.
- Through the gateway on all 4 protocols with a fake DeepSeek, and on WorkBuddy both built-in and through the community plugin's fetch in the plugin host (TestLoopEndsWorkBuddysReply). In each case the agent gets the reasoning and then the error, the vendor is let go within 2000 lines, nobody rests, and usage keeps reply_loop.
- gateway.go as 4,900 lines of reasoning passes whole on every protocol. With the setting off, a loop runs to its end.
- With the guard removed, the end-to-end and WorkBuddy tests fail on every route.
- The built binary (magpie serve on 127.0.0.1:3592, temp HOME, fake DeepSeek upstream), checked with curl on chat, messages, responses and gemini alt=sse. Each loop ended with that protocol's error, the upstream was let go after 256–271 lines, and the usage log had err_type reply_loop and routing fail "loop". The long gateway.go reasoning came through to [DONE], message_stop, response.completed and STOP. With noLoopGuard, all 100,000 lines passed.
- GUI: loop-guard-setting.test.cjs in Chromium and WebKit, en/zh/ja/de, at 1100 and 420 wide. gui-ja, gui-de, gui-zh-tw, i18n-keys, member-model-setting, click-scroll and settings-sections/groups pass.
- go vet, GOOS=linux/windows vet and builds, go test -race ./internal/gateway ./internal/settings, and the full go test -tags nogui ./... all pass.

Not tried with the real WorkBuddy or DeepSeek model.
2026-10-09 22:32:31 +08:00
yetone ab3fe0fe41 gateway: a Claude subscription turn whose saved session Claude Code can't load goes on in a new Claude Code instead of 502 "Claude Code ended", and a Claude Code that ends early says why (FrierenF on Discord)
What: a conversation let go past idleMost is resumed from its saved
session (unshelve, `claude --resume <sid>`). Claude Code 2.1.295 that
can't load the session prints "No conversation found with session ID"
and exits 1 before it reads anything, without answering a control
request (tried with the real binary in a scratch CLAUDE_CONFIG_DIR: a
missing and an empty session file both do this; a loadable one answers
initialize). With the safety context set (Claude Code's auto mode),
start's initialize got its reply channel closed and the turn was
answered 502 "Claude Code: Claude Code ended", with no reason; without
it, the turn got an empty 200.

Now:
- start sends initialize to a run resumed from a saved session too, as
  the probe that Claude Code loaded it; when that run fails, the session
  is let go and a new Claude Code is told the whole conversation in the
  same request (start / startRun).
- cliControl reports a run that ended before answering with its exit
  status and stderr tail (endedBefore, shared with whyEnded), and its
  timeout no longer says "safety context" for every request.
- The other paths that can meet an ended run already start a new one:
  resume (setSafeguards / tell failing -> abort, fall through) and the
  tool-results path (claimResume / continueWith -> runExpired).
- The resume harness's fake Claude Code now acknowledges control
  requests as Claude Code does.

Not known: why FrierenF's saved session couldn't be loaded, or whether
their run ended for another reason; their next failure will now name it.

Run:
- TestClaudeUnloadableSessionStartsAnew (both with and without
  safeguards) and TestClaudeEndedRunSaysWhy fail on origin/main:
  "502 Claude Code ended"; no run started anew (empty 200);
  "Claude Code: Claude Code ended" lacks exit status 3 and stderr.
  They pass with the change, -race -count=10.
- go test -tags nogui ./internal/gateway/ under a temp HOME, pinned
  caches: ok (174s).
- gofmt -l clean; go vet (darwin), GOOS=linux go vet -tags nogui,
  GOOS=windows go vet (with and without nogui) for internal/gateway;
  go build, GOOS=linux go build -tags nogui, GOOS=windows go build: ok.
- Not run: a real signed-in Claude account (no credentials copied), the
  Windows box, the rest of the repo's packages.
2026-10-09 22:29:41 +08:00
yetone 7953c7ef9b agent: a config folder holding only skills/ no longer counts as the agent installed, since skill installers make one for every agent they know (qtwaiter on X)
qtwaiter's Agents page listed Goose, Crush, Command Code, fx, Devin,
Hermes and Droid, none installed. Skill installers (npx skills and the
like) write <folder>/skills for each agent they support, and a config
folder alone made an agent detected. agentDir now takes a folder for the
agent's own only when it holds something besides skills/ (.DS_Store
aside); the default rule, Goose's and fx's detect use it.

Run: go test ./internal/agent ./internal/library ./internal/gui
./internal/profile ./internal/backup ./internal/tui;
TestSkillsOnlyFolderIsNotInstalled fails on the old code for all seven.
gofmt, go vet darwin/linux/windows clean.
2026-10-09 22:26:05 +08:00
yetone 603dc0c44f dsh: Disconnect keeps the model picked in dsh 0.2, which saves it into magpie's agent-default-model entry (#1392)
What dsh 0.2.0-rc.2 changed (read in @deepseek-ai/dsh-settings and
dsh-agent-default-model from npm): ~/.dsh/settings.yaml is gone. On its
first boot dsh renames it to settings.yaml.imported and merges its sections
into the booted profile's patch list (profiles/<name>/cordis.patch.yml);
nothing reads the .imported file afterwards. A /model pick is no longer
kept in settings.yaml either: agentDefaultModel.saveSelection goes through
ConfigEditor.edit, which replaces the config of the profile's last
agent-default-model entry. That entry is magpie's, so the user's pick sits
under magpie's "# magpie" mark. Profile paths, the home layer, .env and
.credentials.yaml are unchanged.

What broke: Disconnect took that entry for magpie's own, dropped it and put
back what magpie stashed from before it connected, so the model picked in
dsh (or imported from settings.yaml) was lost. Seen with real dsh
0.2.0-rc.2: after the import, Disconnect left `[]` and dsh started on its
shipped deepseek-flash instead of the imported deepseek-v4-flash.

Fix: dshKeepPick, run per profile before Disconnect takes magpie's wiring
out, hands a marked agent-default-model that is off magpie's route back to
the user (mark removed, old stash discarded). An entry on magpie's route,
or one on the pre-0.1.5 wiring, is still magpie's. dshStart still reads a
settings.yaml not yet imported, which dsh will put over the booted profile.

Run: TestDshPickSavedIntoMagpiesEntryOutlivesDisconnect (fixture from the
patch real dsh 0.2.0-rc.2 wrote) fails on the old code ("the pick made in
dsh was lost", the stashed deepseek-v4-pro came back) and passes. Real dsh
0.2.0-rc.2 under a temp HOME/DSH_HOME, fake gateway on 127.0.0.1:3561:
`dsh headless "say hi"` sent POST /v1/chat/completions, Bearer magpie,
model deepseek/pro to it, before and after a settings.yaml import; after
Disconnect `dsh headless --dump-config` keeps deepseek-v4-flash;
reconnecting sends deepseek/flash to the fake gateway. go test -tags nogui
./... (temp HOME, pinned caches) passes, -race -count=5 -run TestDsh
passes, gofmt -l clean, go vet and GOOS=linux/windows go vet -tags nogui
./internal/agent pass.
2026-10-09 22:26:00 +08:00
yetone dec951229c agent: Grok Build installed by xAI's installer shows its newest version and offers grok update, and its version is read again after each update (xiaoxiaofeixz on Discord: Grok at C:\Users\<user>\.grok\bin\grok.exe)
Grok Build had no cliSpec and no Bin (grok is also Homebrew's regex
tool), so the Agents page showed nothing about its CLI: no version, no
newest, no update.

xAI's installers (read from https://x.ai/cli/install.ps1 and install.sh):
- install.ps1 copies grok.exe (and agent.exe) into %USERPROFILE%\.grok\bin
  and puts that on the user PATH; no junction, no versioned folder.
  grok update copies the new grok.exe over it (the running one renamed to
  grok.exe.old), so its size and time change.
- install.sh links ~/.grok/bin/grok to ../downloads/grok-<platform>;
  grok update downloads ../downloads/grok-<version>-<platform> and relinks,
  a new real path per version.
- The newest version of a channel is the body of x.ai/cli/<channel>
  (stable, alpha, enterprise; GCS fallback), the channel kept under [cli]
  in ~/.grok/config.toml.

cliSpec gains `at` (where the vendor installer puts the CLI under home,
read there instead of PATH for an agent with no Bin) and `latest` (the
newest its own updater installs, for a CLI not on npm). grok's spec: at
.grok/bin/grok(.exe), self = grok update for a real path under
.grok/bin or .grok/downloads, latest = grokLatest (channel pointer, 6h
memo per channel).

TestGrokInstalled builds the platform's installer layout under a temp
HOME/USERPROFILE with a fake grok on PATH, a served channel pointer and
fake version/update runs: PATH's grok isn't taken; 1.0.46 shows 1.0.50 and
"grok update" (grok.exe update on Windows); the update reads 1.0.50; grok's
own update outside magpie (auto_update) is read again; the alpha channel's
newest is alpha's. It fails without the grok spec (macOS and the Windows
box: "before: {Version: ...} false") and passes with it.

Real use: macOS, a sandbox HOME with the real grok 1.0.46 in install.sh's
layout: CLI() said 1.0.46 / 1.0.50 / grok update, UpdateCLI ran the real
grok update and read 1.0.50 (~/.grok untouched). Windows box (10.0.0.132,
sandboxed USERPROFILE/APPDATA/LOCALAPPDATA): the real grok-1.0.46 exe at
home\.grok\bin\grok.exe, same result through a real grok update; the real
profile's .grok, LocalAppData\grok and user PATH unchanged. There
TestGrokInstalled, TestCodexInstallPs1Junctions and
TestHowInstalledWindowsShim pass.

Siblings: Claude's install.ps1 lands in ~/.local/bin/claude.exe (already
matched); Cursor's and Qoder's Windows installers make no junctions or
links, and those agents have no cliSpec (not in scope); opencode has no
install.ps1 (404); Factory's refused the fetch (403), droid has no
cliSpec either.

go test -tags nogui ./internal/agent (temp HOME), gofmt -l, go vet, and
GOOS=linux / GOOS=windows go vet -tags nogui ./internal/agent pass.
2026-10-09 22:25:24 +08:00
wizzy-yangandwizzy-yang 6dd8c9aaf0 gui: a page's own scrollbar is dragged by the mouse (#1213)
Dragging a scrollbar did nothing on any page with content taller than the
window: the thumb would not move, and letting go left it where it started
(emo172, #1089). The wheel worked, so only the drag was broken, and a
scrollbar dragged in a container the app does not listen to scrolled
normally.

"Where the reader is" holds a view still unless the reader asked for the
scroll: the wheel, a touch, the keys, or a drag of the content, each of
which says so through an event. A scrollbar dragged by the mouse has no
such event — Chromium and WebView2 give it no pointermove — so every
scroll it produced was put back as it came, the thumb sliding back under
the pointer. The wheel works because wheel is one of the events.

The press on a scrollbar does reach the view, with the pointer past its
content in the scrollbar's band, and the lift ends the drag. Held from
that press to the lift, the drag's scrolls count as the reader's.

Two more things hold the page still that a wheel already lets go of, and
the drag lets go of the same two:

- what the last click was holding in place, which keeps what was clicked
  on the screen frame by frame for a few seconds after it;
- the reader's window itself, which WebKit needs held open past the lift:
  it sends the drag's last scrolls once the gesture is over, after the
  pointerup, so closing the window on the lift put those back.

A scroll nothing asked for — code setting scrollTop — is still put back:
only the bar's own drag counts as the reader's, not every scroll.

view-scrollbar-drag.test.cjs is new. It drags a page's own scrollbar in
both engines in English and Chinese, straight away and after a click in
the page that holds what was clicked; it checks the page follows the bar
and stays where it was left, that the wheel still scrolls, that a scroll
code set is still put back, and that a scroll arriving after the lift is
still the reader's. It uses the pages' own scrollbar CSS rather than one
of its own: a scrollbar-width set on the view makes Chromium drop every
::-webkit-scrollbar rule (app.css) and draw Windows' classic bar. The
Routing page is dragged at a narrow window, where it has room to scroll:
at a wide one it lays its stage beside the list and has ~35px left, not
enough to tell a drag from a nudge. The scroll arriving after the lift is
checked on the list page only. It was left off Routing while #1249 was
open — WebKit clamped Routing's last stretch there, so a scroll sent
after the lift measured that bug rather than the window held open past
it. #1249 is fixed in main now, so the check could be widened to Routing;
it is not, because that clamp was only ever checked on Windows headless
WebKit here and not on the macOS WKWebView, and widening a check is
beyond what review asked for.

Three of the checks were reworked after they were run four test files at
a time and each was found to pass for the wrong reason, or to race:

- the click in the page lands on a part that leaves the page as it is.
  The Routing page's own header opens the group editor in English,
  growing the page and scrolling it on its own, so where the drag left
  the page passed without the drag having moved it. The page is measured
  again where it is now and the drag is judged by how far it moves it.
- the scroll arriving after the lift is written from the pointerup
  itself, installed in the page before the lift. A round trip between the
  lift and that scroll measured 6-180ms alone and 314ms four files at a
  time — past the 250ms window the app holds open for it.
- the wheel's scroll is waited for to come to rest, not for a fixed
  time, which under load was not always long enough.

The scroll code sets a value the page is not already at, and runs before
any click: a click holds what was clicked on the screen for a few
seconds, and that hold moves the page on its own, which would answer for
the app.

It fails on main (the drag leaves the page at 0) and passes with this.

Verified at this head, rebased onto main 0d8f85e4 — which brought
#1249's fix, a change to the same scroll handler (its early return and
puttingBack), and #1236's scrollbar CSS. The merge kept main's structure
and folded barDrag === v into its first branch, so a dragged bar is
treated as the reader's and never recorded as a put-back.
node --check; go vet ./...; go build (windows); GOOS=linux build -tags
nogui. view-scrollbar-drag 5/5 in Chromium and WebKit, en and zh, three
solo runs each with no flake, and 5/5 again four test files at a time,
three rounds each on both engines. The nineteen scroll-related GUI files
(click-scroll, menu-scroll, strip-scrollbar, view-scrollbar,
view-no-sideways, sessions-toolbar, sess-agent-strip, agent-grip,
group-member-drag, usage-arrange, provider-order, purpose-filter,
proto-menu-overflow, routing-scroll-end, routing-purpose-state,
routing-steady, routing-served, fold-show-grip) 94/94 in both engines,
main's new view-no-sideways included since the base changed the
scrollbar CSS this test measures against; gui-ja / gui-de / gui-zh-tw /
i18n-keys 10/10 in both. Two mutations at this head: main's app.js fails
all five (the drag leaves the page at 0), and removing only the merged
barDrag === v condition — leaving the rest of the feature — fails WebKit
5/5 and Chromium 2/5 ("a scroll arriving after the lift is still the
reader's"), so the line the rebase folded in is guarded and the new
scrollbar CSS has not let the page pass without it. The other four
per-guard mutations (the whole barDrag rule, the hold let go on the
press, the window held open past the lift, the reader-position
put-back) were each run red without their guard at the pre-rebase head;
the rebase only folded barDrag into main's first branch and left those
four paths as they were.

Not verified here: only on Windows, in Chromium and WebKit through
Playwright. Not tried on macOS or Linux.

Co-authored-by: wizzy-yang <wizzy-yang@users.noreply.github.com>
2026-10-09 22:24:07 +08:00
yetone ecc94dbf41 gateway: a routing group's DeepSeek reasoning, its text in it, no longer sticks a Codex conversation on OpenAI destinations (#1411, cth123456: "Invalid 'input[n].content': array too long")
A group turn served on DeepSeek hands Codex a reasoning item with both
content (reasoning_text) and encrypted_content. Codex sends it back on
every later turn, and the /backend-api/codex handler keeps reasoning for a
group (codexInput(body, true)). Routed next to a Codex account or a relay
in front of OpenAI, the request was turned away with 400 "Invalid
'input[n].content': array too long. Expected an array with maximum length
0 ...", which neither the foreign-seal retry nor #1044's bare-reasoning
retry matched, so every later turn failed the same way.

In passthrough, for an upstream that isn't sent reasoning text back
(not replaysReasoning, so DeepSeek still gets it):
- a Codex account, openai.com or Azure is never sent a reasoning item with
  content parts (withoutReasoningText), as codexInput already leaves it out
  for Codex's own models; its seal is the other vendor's, so the item goes;
- any other upstream that answers 400 naming input[n].content "array too
  long", where item n is reasoning with content, is asked once more without
  such items, and the provider's model is marked unfit for them
  (reasoningTextRefused), so later turns go without them the first time,
  as #1044 does for bare reasoning.
The destination's own sealed reasoning, messages and tool calls stay.

Verified:
- TestReasoningTextLeftOutWhereRefused (group to a strict relay, the
  issue's literal item) and TestReasoningTextNotSentToCodexAccount (group
  to a Codex account) fail without the change with 400 "AgentRouter:/Codex:
  Invalid 'input[1].content': array too long ..."; the relay is asked twice
  then once, the account once. TestReasoningTextKeptWhereTaken keeps the
  item for an upstream that takes it.
- Real ChatGPT backend (the owner's Pro account, gpt-5.5, store false): the
  issue's item answers 400 "Invalid 'input[1].content': array too long.
  Expected an array with maximum length 0, but got an array with length 1
  instead." param input[1].content, code array_above_max_length; the test
  fixture uses those bytes. The same request without the item completes.
  Not tried against AgentRouter itself.
- gofmt -l, go vet, GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/gateway, go test -tags nogui -count=1 ./internal/gateway
  under a temp HOME: all pass.
2026-10-09 22:14:45 +08:00
yetone 1ddcc3e8cc gateway: a provider that refuses a system message inside messages gets its text on the top-level system, and an empty one left out (#1407, liuyejinghong: Command Code "Invalid input at messages.1.role")
Claude Code puts system messages inside messages[] (its environment, and a
turn's effort as output_config on an empty one). Command Code's Provider
API (the "commandcode" API-key preset, Anthropic at
api.commandcode.ai/provider) turns away any of them with 400 "Invalid input
at messages.N.role", so every such turn failed.

It is handled as the other shapes Claude Code sends and a relay may refuse
(anthropic_shapes.go): on a 400 naming messages.N.role, where message N of
the body as sent is a system one, the provider is marked unfit for
shape:messages[].role=system, asked again at once, and from then on sent
each system message's text at the end of the top-level system (a string
system becomes one text block first), an empty one left out. A role
refusal over a user or assistant message marks nothing, and a provider that
takes system messages gets them where the agent put them. This runs in
forward/forwardOnce, so it also covers a moved commandcode-plan, whose
plugin fetch passes the gateway's Messages body to the same API.

Verified:
- TestSystemMessageRefusedGoesOnTop (the issue's request and the
  effort-only system message) fails without the change with
  "status 400: ... Command Code: Invalid input at messages.1.role";
  TestSystemMessageKeptWhereTaken checks the neighbours stay as sent.
- Real Command Code (the owner's GOAT key): curl user,system,user gives
  400 "Invalid input at messages.1.role"; user,user and a top-level system
  array give 200. Through this gateway (New().Handler(), temp HOME, real
  key) both the issue's request and the effort-only variant answer 200.
- gofmt -l, go vet, GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/gateway, go test -tags nogui -count=1 ./internal/gateway
  under a temp HOME: all pass.
2026-10-09 22:14:45 +08:00
yetone 02dfb7aa2c profile: applying a profile writes only agents found on this computer, so a profile synced from another one no longer makes missing agents look installed (qtwaiter on X)
ApplyFields looped over every known agent. A profile saved on another
computer (profiles sync over WebDAV) names agents missing here; writing
their model created their config folder, and a config folder alone counts
as installed, so the Agents page grew agents never installed. Snapshot
already takes only detected agents; Apply now matches it.

Run: go test ./internal/profile ./internal/gui ./internal/tui
./internal/backup; TestApplySkipsUndetectedAgents fails on the old code
(agy made to look installed). gofmt, go vet darwin/linux/windows clean.
2026-10-09 21:50:19 +08:00
yetone 3691c2047d plugin, agent: bun is given a SOCKS proxy through the bridge, so a plugin installs with only a SOCKS system proxy (#1409)
With only a SOCKS system proxy on macOS (127.0.0.1:4401), every plugin
install failed: netproxy.Env put socks5://… in bun add's *_PROXY, and Bun
takes only http:// and https:// proxies, so it stopped with
"UnsupportedProxyProtocol downloading package manifest". The plugin
host's own fetches already went through netproxy.Bridge (hostEnv), but
bunCommand, which runs bun add, update and remove, did not.

- netproxy.EnvForBun rewrites a SOCKS5 HTTPS_PROXY/HTTP_PROXY/ALL_PROXY
  (any case) to the loopback HTTP bridge in front of it; others as they are.
- bunCommand uses it, so add, update, remove and the host's run all get it.
- Sibling: an agent CLI installed with bun is updated by `bun add -g`
  with the same env (updateEnv in cliupdate.go); npm is left as it is.
- provider-plugins.md says so.

Run:
- TestInstallThroughSOCKSProxy (real bun 1.4.2, fake registry, SOCKS
  proxy only): on the old bunCommand it fails with the reporter's exact
  "error: UnsupportedProxyProtocol downloading package manifest"; passes
  with the fix, through the SOCKS proxy.
- TestEnvForBunBridgesSystemSOCKS (system SOCKS proxy via Env) and
  TestUpdateWithBunBridgesSOCKS fail with EnvForBun / the bun branch
  broken ("bun is given …socks5://…"), pass with it.
- Real use: a throwaway test with a real SOCKS5 server and only
  *_PROXY=socks5://… installed @magpie-community/opencode-cursor-auth
  0.2.2 from registry.npmjs.org through it; on the old code the same
  failed as UnsupportedProxyProtocol. Scratch HOME, not committed.
- gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; go build; GOOS=linux go build -tags nogui;
  GOOS=windows go build; go test -tags nogui ./... (scratch HOME) all ok.
2026-10-09 19:35:35 +08:00
yetone bc7362904f quotas: another computer's magpie that won't tell its quotas says why on its card — not shared there, this key not taken, or not reached — instead of "Allowance unavailable" (Fim980 on X)
Fim980's tray showed one "Remote magpie · 暂时无法获取额度" card and
nothing else. A remote magpie's 403 (a gateway MAGPIE_ADDR opens, as
Docker's does, serves models to anyone but tells its quotas only when
shared on its local network — TestQuotasOverLAN keeps that), its 401 and
a failed connection all fell to the generic label. remoteJSON now gives
each its own error (errRemoteNotShared, errRemoteKey,
errRemoteUnreachable), and quotaError says what to do there, in en, zh,
zh-TW, ja and de; magpie quota and the TUI show the English sentence.

Run: go test ./internal/provider ./internal/gateway (pass);
TestRemoteMagpieUnreachable's new 403/401 cases and
usage-remote-cards.test.cjs's three new cards fail on the old code;
the GUI test passes in Chromium and WebKit, en/zh/ja/de; gofmt, go vet
darwin/linux/windows clean.
2026-10-09 19:34:11 +08:00
yetone f575da41cc provider: the Kiro mover asks for opencode-kiro-auth 0.1.8, which sends a tool named past 64 characters under a short name (#1393)
Kiro answers a tool name longer than 64 characters "Invalid tool use
format." (REQUEST_BODY_INVALID). Claude Code names a plugin's MCP tools
mcp__plugin_<plugin>_<server>__<tool> (the reporter's Cloudflare docs
tools are 70 and 71), so every turn of a moved Kiro account that offered
one failed: the plugin passed the name through. The built-in has cut such
names since e3b6397a (#369, TestBuildKiroToolImagesAndLongNames), so
users who haven't moved were not affected and the built-in is unchanged.

magpie-community/plugins e1efc3d (kiro 0.1.8) gives the plugin the
built-in's rule: a name outside [a-zA-Z0-9_-]{1,64} is sent as its head
plus a hash of the whole name, the same in every turn, and Kiro's calls
come back under the caller's name, streamed and not. Raising min makes
keepMovedCurrent update every moved user's plugin.

Run: HOME=<temp> go test -tags nogui ./internal/provider (ok) and
-run Kiro ./internal/gateway (ok); go vet (darwin, linux, windows) and
gofmt -l on ./internal/provider. Plugin side: tool-names.test.mjs fails
3 of 3 without its change and passes; bun test across the repo 1003
pass. npm view shows 0.1.8. Not tried against Kiro itself: no Kiro
sign-in on this machine.
2026-10-09 19:31:37 +08:00
yetone 655f96ede4 gui tests: usage-fold and account-mask no longer reload the Usage page the moment it opens, so WebKit has no first reads to cancel and report as page errors (#1350)
Both tests opened the page in a new browser context, cleared their
localStorage keys and reloaded at once. A new context's storage is already
empty, and the reload lands while the page's first reads (agents/cli,
agents/install, usage, upstream, update, whatsnew) are on their way. WebKit
logs each fetch it cancels as "Fetch API cannot load … due to access
control checks." with source "javascript", which Playwright's WebKit turns
into a pageerror, and the tests' final assert.deepEqual(errors, []) failed.
The app catches every one of those reads; nothing is wrong in the page.

Instrumented runs show it: requestfailed "cancelled" for whatsnew/update
and the two page errors within 70ms after the first reload, none after.

Verified (Playwright 1.62.1, macOS arm64), WebKit "several accounts"
(en+zh), 8 copies at once, 5 rounds:
- before: 3 of 80 cases red, each with "Fetch API cannot load … due to
  access control checks" right after the first reload
- after: 80 of 80 pass, no page error
- usage-fold.test.cjs + account-mask.test.cjs, Chromium and WebKit,
  10 runs: 100/100 pass (10 cases each run)
2026-10-09 19:24:16 +08:00
yetone ee14595ff3 gui tests: warm-at-times opens each language in its own locale and calls a time field squeezed when it is narrower than its own text, not under a fixed 60px (#1353)
WebKit draws <input type=time> in the context locale's clock. Playwright's
WebKit takes the machine's locale when none is given, so on a machine set
to a 24-hour locale the field reads "09:00" and is 59.0625px wide, whole,
with nothing clipped; in en-US it reads "09:00 AM" and is 82.0625px.
The 60px floor was calibrated to a 12-hour machine, so the 900px WebKit
cases failed for every reporter on a 24-hour locale. Chromium draws the
field at 85.125px in every locale.

Each language now runs in its locale (en-US, zh-CN, ja-JP, de-DE), so the
test is the same on every machine and covers both clocks, and "squeezed"
compares the field with a copy of itself laid out in a .warm-at of its own
in the same row.

Verified (Playwright 1.62.1, macOS arm64):
- with the locale pinned and the old 60px floor: webkit zh/ja/de 900px
  fail with "time field squeezed to 59.0625", as reported; en passes.
- new test, 20 runs of the whole file, Chromium and WebKit, en/zh/ja/de,
  900px and 440px: 320/320 pass.
- break check: #warmAtSegs .warm-time input.at { width: 44px } fails all
  8 cases at 900px ("squeezed to 44 of 59.0625 / 82.0625 / 85.125").
2026-10-09 19:24:16 +08:00
yetone 62b1c995ff provider, codex: an account the Codex app holds is switched off whatever its windows read, and never switched to (CavillZhang on X: "out of Codex and Work usage", some accounts not switched)
A Business seat at its workspace owner's limit (rate_limit.allowed false,
no credits) reads, say, 40% on every window, so NextLogin never counted it
spent: Codex said "You're out of Codex usage" and magpie kept it there. It
could also move Codex onto, or back to, a held account.

NextLogin now treats SubscriptionQuota.Held (codexHeld) as spent: moved off
at any share, skipped as a spare, and not gone back to while held.

The test TestCodexHeldAccountSwitchedUnderTheShare was already on main,
unfinished and failing (swept into 34a59837 from a stalled session's
working tree); this finishes it: all held -> stays; a spare freed -> moved
to it; not back while the first is held; back once it has room. It fails on
the old NextLogin. go test provider, gateway; go vet darwin/linux/windows;
gofmt -l clean. Not tried with a real held Business seat.
2026-10-09 14:24:50 +08:00
yetone 68aab298d3 gateway, codex: a provider the user added by its address is sent the service_tier Codex asks for, and offered Fast and Ultrafast (hsiangron on X)
Codex's Fast (service_tier=priority) and Ultrafast (ultrafast) were dropped
on the way to a custom provider: the gateway only passed a tier on to
chatgpt.com and Cursor, and magpie's models.json entries for such a
provider's models offered no tiers, so the user's own picks were written
over.

- Request.Tier keeps the client's service_tier as sent; for a provider with
  no preset and no account (OwnTier) both buildResponses and buildChat send
  it as it is. One that refuses the field by name is asked again without it
  and remembered as unfit for it, as the other optional fields are.
- codexcat offers such a provider's model the tiers Codex's own entry gives
  the same slug (dated snapshot and provider prefix stripped), Fast on
  another GPT model, none otherwise. Presets and groups are unchanged.

Run: TestOwnProviderGetsTier (Responses/Chat x priority/ultrafast/flex),
TestPresetProviderGetsNoTier, TestOwnProviderRefusingTier,
TestOwnProviderTiers; the gateway ones fail without the gateway change and
TestOwnProviderTiers fails without the codexcat change. go test gateway,
codexcat, catalog, provider; go vet darwin/linux/windows; gofmt -l clean.
Not tried against the reporter's relay.
2026-10-09 14:16:53 +08:00
yetone 0b5b10da2a agent, gateway, gui, tui: a Codex that goes through magpie only to fail over to the user's other ChatGPT accounts says so on the Agents row and keeps to its own models (#1385, shenghsi)
With several ChatGPT accounts on, failover writes openai_base_url into
~/.codex/config.toml so a turn the signed-in account can't pay for goes on
to the next account. With Codex's switch off, the row said only "not
connected", but every request still went through the gateway, and the
gateway's /backend-api/codex/models answer added all of magpie's models
(62 for the reporter).

- agent: Agent.FailingOver means not wired, while the stash's codex.failover
  (or a CC Switch mirror's codex.mirror_failover) base URL points at magpie.
  FailoverSaid is the line the CLI list and the TUI show. CodexOwnOnly is
  true for this machine's Codex when it is failing over and no WSL Codex is
  connected, since a WSL Codex shares the gateway path. Sync ages a
  models_cache.json that isn't tagged with the own-only list.
- gateway: codexModels leaves out provider.CodexListed when
  gateway.CodexOwnOnly (set by main to agent.CodexOwnOnly) says so. The
  ETag and X-Models-Etag carry provider.CodexOwnListTag. Neither tag
  contains the other, so Codex fetches the list again when it is connected
  or disconnected.
- gui: /api/state carries failover. The row says "Not connected · goes
  through magpie only to fail over to your other ChatGPT accounts". Its
  title says what turns it off. A "ChatGPT accounts" button opens
  Providers › Codex. Strings are in zh, zh-TW, ja and de. openProvider no
  longer draws the Providers list before it has loaded. It was only safe
  once the tab had been opened, and this is its first caller from another
  page.
- docs: agent-wiring and gateway-routing describe the failover-only Codex
  and list the new tests.

A user's hand-written openai_base_url (#856) isn't failover's, so it stays a
plain not-connected row.

Verified:
- TestCodexFailoverOnlyKeepsOwnModels (agent) builds the reporter's state in
  a temp HOME: Codex signed in, two more ChatGPT logins on, Sync, so the
  stash has codex.failover=1 and no joined/beside. It checks that the row is
  not wired and is FailingOver, that FailoverSaid names Providers › Codex,
  and that the real gateway handler's /backend-api/codex/models lists only
  the backend's gpt-5.5. It also checks that the cached full list is aged,
  and that after Join magpie's fake/m1 is back.
- TestCodexModelListOwnOnlyForFailover (gateway) checks the list and both
  ETags with the hook on and off.
- agent-failover.test.cjs checks the row text, title and button in en, zh,
  zh-TW, ja and de, at 980px and 420px, in Chromium and WebKit (20 pass).
  It also checks that the button opens Codex's editor, that the page
  doesn't scroll sideways, and that no click moves it.
- Broken by hand, each test goes red:
  - codexModels ignoring the hook fails both Go tests.
  - failingOver returning false fails the agent test.
  - dropping the Sync cache case fails the agent test.
  - removing the GUI branch fails the GUI test.
  - drawing the list before it has loaded (the old openProvider) fails the
    GUI test.
- go test -tags nogui ./internal/agent ./internal/gateway ./internal/provider
  ./internal/gui ./internal/tui ./internal/codexcat . in a temp HOME: all ok.
- node --test agent-*.test.cjs (254 pass) and i18n-keys, gui-ja, gui-de,
  click-scroll: all pass.
- gofmt -l is clean.
- go vet -tags nogui on darwin, linux and windows: clean.
- go build, and GOOS=windows go build: ok.
2026-10-09 14:10:13 +08:00
yetone 1bc0ed404a minimax-code: magpie's models have one slash in the whole ref, so SubAgents take them (#1387, worksyang)
MiniMax Code 3.1.0 checks a SubAgent's model against /^[^/\s]+\/[^/\s]+$/
(uQn in @minimax-ai/code's chunk-2XPMNZVR.js), and magpie wrote its models
under custom_provider.magpie by catalog id, so
custom_provider:magpie/bb-codex/gpt-6.1-sol was refused
(AGENT_CONFIG_INVALID).

- The writer keys each model by its catalog id with "~" for each slash
  (bb-codex~gpt-6.1-sol, provider.FlatID), when exactly one served id
  spells that way (provider.Flattened); else it keeps the slashed id.
- The gateway takes such an id back to that one provider's model or group
  in validateModel and unprefixed (unflat / provider.Unflat): only an id
  with "~", no slash, that resolves as nothing else; two ids spelled alike
  are neither. Never a bare-name first hit. Key limits, middleware and
  usage see the catalog id, so a key held to bb-codex/* is refused
  other~gpt-6.1-sol on every route, count_tokens too.
- A config an older magpie wrote moves on the next sync: the user's keys on
  a model go to its new key, defaultModel, defaultLightModel and
  memory.captureModel/consolidationModel follow, and the slashed key stays
  with enabled: false, so a session begun on it still resumes (checked
  with mcode exec --continue). Get still reads magpie/<catalog id>, and
  Disconnect still puts back the stashed default and variant.

Other agents: no installed agent bundle here (cline, command-code,
qwen-code, deepseek, pi, omp, codebuff, openclaw) has this regex; native
agents were not checked.

Verified:
- go test -tags nogui ./internal/agent ./internal/gateway ./internal/provider
  (temp HOME), gofmt -l, go vet darwin/linux/windows.
- New TestMiniMaxCodeOneSlash uses the reporter's regex and ids;
  TestFlatModelIDsReachTheirProvider has two providers serving
  gpt-6.1-sol. Breaking unflat, mcodeKey, the key carry-over, the legacy
  enabled:false and the ref rewrite each turned the tests red.
- Real run: built magpie serve in a temp HOME on 47812, two fake upstreams;
  `magpie mcode magpie/other/gpt-6.1-sol` wrote other~gpt-6.1-sol; real
  mcode 0.6.5 exec reached other's upstream with gpt-6.1-sol (usage:
  other/gpt-6.1-sol); its agent loader accepted an agent.md with
  custom_provider:magpie/other~gpt-6.1-sol and refused the two-slash one;
  `magpie mcode default` put minimax/MiniMax-M2.7 back.
2026-10-09 14:08:07 +08:00
yetone e66fa16593 codex: magpie's actor header goes into a [model_providers.magpie.http_headers] table the config already has, instead of failing every model switch (wztlink1013 on Discord)
wztlink1013 (v0.1.1134, Windows, Codex 0.162.0) could not switch Codex's
model on the Agents page: "config.toml: edited TOML is invalid: toml: key
http_headers should be a table, not a value".

Cause: putProvider rewrites [model_providers.magpie] whole with
http_headers = { "x-openai-actor-authorization" = "magpie" }. A config
that holds the headers as their own [model_providers.magpie.http_headers]
table keeps that table (a separate block the rewrite leaves), so the file
defined http_headers twice and writeTOML refused it. Reproduced in a temp
dir with exactly that message, in LF and CRLF files alike, so line
endings are not the cause. With only the subtable and no parent table the
same edit failed as "key http_headers is already defined". Dotted keys
inside the table (http_headers."x-org" = …) did not fail but were
dropped, the user's other headers with them.

Fix: edit.Inline, an inline table SetTOMLTable merges into the spelling
the file has: in [name.key] each entry is set with SetTOMLKey's in-place
edit (other headers and comments kept); among dotted keys their lines are
kept as written and each entry set there; otherwise written inline,
byte for byte as before. putProvider passes the header as an Inline.
SetTOMLKey's body moved into setTOMLKeyLines so both share it.

Siblings checked: no other agent writes an inline table with
SetTOMLTable (kimi's providers.magpie and Codex's thread tables are
scalars only); the MCP writer (putCodex) already removes a server's
subtables before writing it. Not changed: a magpie provider spelled by
dotted keys outside its own table ([model_providers] magpie.x = …, or at
the top) still fails as "table magpie already exists"; that is not this
report's shape.

Run:
- TestSetTOMLTableInlineMergesUsersSpelling (internal/edit): own table,
  own table without the header, own table only, dotted keys (with and
  without the header), inline, absent; each LF and CRLF, checked by
  decoding the result. Red with the subtable branch disabled (the
  reported error) and with the dotted branch disabled (user's x-org lost).
- TestCodexMagpieHeadersAsOwnTable (internal/agent): the reporter's shape
  through codex().Fields[0].Set, LF and CRLF. Red with putProvider back
  on edit.Raw: "key http_headers should be a table, not a value".
- gofmt -l (clean); go vet, GOOS=linux go vet -tags nogui, GOOS=windows
  go vet (with and without nogui) on internal/edit and internal/agent;
  go build for darwin, windows and linux (nogui).
- go test -tags nogui ./internal/edit ./internal/agent ./internal/library
  ./internal/provider under a temp HOME with pinned caches: all ok.
- codex-cli 0.161.0 (CODEX_HOME in a temp dir, codex mcp list) loads the
  merged config. Not tried on the Windows box or Codex 0.162.0.
2026-10-09 13:50:53 +08:00
yetone 71ee5e3519 gateway: a Claude subscription conversation whose client took its images out goes on in its run (#1382, Songxiaor)
Hana's pre-step hook replaces each image before the last assistant message
with "[图片已省略:历史图片保留为文件引用,避免重复发送原始 base64]" in the
tool result or user message that held it. Over pi-ai's openai-completions
the user message of the results' images ("Attached image(s) from tool
result:" and the images) is gone and each result's text has the line added
to its end. The step after one that read an image missed its run both
ways: tool results failed follows() (the hash of what the run heard), and a
new turn failed turnKey and looseTurn.rewrote (message count changed). A
new claude -p was told the whole conversation: 10 of 67 requests, 79% of
the session's cache writes.

lostMedia (claude_lost_media.go) tells this rewrite by its shape, not by
Hana's string: comparing the conversation a run had (each part kept as the
hash and length of its words, heardRuns) with the request's, a role's run
of messages at a time, it holds when at least one image or file was taken
out and nothing else changed: each image/file is still there, gone, or has
text in its place; a tool result may have text added to its end only when
it carried images or the images after the results went; the caption
before those images goes with them only when a result before it grew.
follows() checks it when the hash misses (toldRuns), and looseTurn.rewrote
when the #912 cut rule doesn't match; the looseTurn key drops the message
count, which the per-turn comparison covers. messageWords is now built from
messageParts, the same words, so the hash and the comparison can't drift.
The shape over the string: any client that strips media the same way is
covered, and a compaction or edit (#459) changes words lostMedia never
accepts. Not covered: a tool result of an image alone, whose pi-ai text
"(see attached image)" is replaced rather than added to.

claude_lost_media_test.go builds its fixtures from pi-ai's literal Chat
Completions bodies (read from the installed HanaAgent server seed, 1.0.0-beta: pi-ai
openai-completions.js and Hana's media-strip hook): a table of 18 shapes
for lostMedia, an end-to-end new turn through serveClaudeSubscription with
the script Claude Code (a tool's image, a user's image), and tool results
after the image step through serveSubscription (goes on; a changed user
message or a changed result still starts anew). The two end-to-end tests
fail with lostMedia unhooked from follows/rewrote; each guard in
lostFromRun was broken by hand and turned a table case red.
docs/subsystems/claude-subscription-bridge.md has the rule.

Run: gofmt -l; go vet -tags nogui ./internal/gateway/ (darwin, GOOS=linux,
GOOS=windows); go test -tags nogui ./internal/gateway/ -count=1 under a
temp HOME (ok); -race -count=5 on the lost-media, rewritten, #459, letGo,
given-up and fork tests (ok). Not tried against a real Hana or a sandbox
magpie with a real claude: the harness's script stands in for Claude Code.
2026-10-09 13:45:42 +08:00
yetone 98236edd77 agent: Codex installed by install.ps1 on Windows shows its newest version and offers codex update, and its version is read again after each update (xiaoxiaofeixz on Discord: 不会自动检测最新的版本)
Codex's install.ps1 puts %LOCALAPPDATA%\Programs\OpenAI\Codex\bin on PATH.
That folder is a junction to ~\.codex\packages\standalone\current\bin, and
current is a junction to releases\<version>-<target>, retargeted by each
update. filepath.EvalSymlinks leaves junctions alone since Go 1.23, so
magpie saw the binary only as ...\Programs\OpenAI\Codex\bin\codex.exe:

- howInstalled didn't find .codex/packages/standalone in its path, so the
  Agents page showed the version with no newest version and no update.
- installedVersion's stamp was that unchanged path plus size and mtime.
  npm's archive, which install.ps1's legacy layout copies from, gives every
  version's codex.exe the same 1985 mtime. So a new release was asked again
  only if its size happened to differ, else after the 24h memo.

proc.RealPath is now the path Windows opens (GetFinalPathNameByHandle),
junctions followed, and filepath.EvalSymlinks elsewhere. cliupdate's
howInstalled and installedVersion and proc.Version use it.

TestCodexInstallPs1Junctions (Windows) builds install.ps1's layout with
mklink /J, two releases whose codex.exe have the same bytes and mtime. It
checks that codex is recognized as self-updated (codex update) and that
retargeting current makes the version asked again. On the Windows box
(10.0.0.132, sandboxed USERPROFILE/APPDATA/LOCALAPPDATA) it fails on the old
code (howInstalled nil; "0.161.0" after the update) and passes on the new.
The rest of the agent package fails on Windows with the same 17 tests
before and after (TestFolderVarsAreListed, TestAside*, TestVSCodium, ...),
which CI never runs there. `codex update` on Windows is in codex.exe 0.162.0
(win32-x64): it runs install.ps1. The layout was read from
https://chatgpt.com/codex/install.ps1.

Not tried with a real install.ps1 install (it rewrites the user's PATH in
the registry). go test -tags nogui ./internal/agent ./internal/proc
./internal/provider ./internal/library (macOS), gofmt, and go vet for
GOOS=linux and windows pass.
2026-10-09 13:44:50 +08:00
yetone 1069785dc7 catalog: a model a relay renamed (claude-deepseek-v4.1-flash[1M]) gets its levels, window, images, name and price from the model it is (#1383, uWydnA)
Relays rename models for Claude Code with a "claude-" prefix and/or a
window mark ("[1M]", "[200K]"). Every capability getter looked the bare id
up exactly, so such a model had an empty reasoning menu, no images (the
gateway's vision stand-in described pictures to a model that sees them)
and a 0 window.

Now every getter shares one lookup (lookup -> found -> renamed):
- found is the chain EffortsOf and ContextOf already had (exact, a Bedrock
  geography, "(variant)", ":tag"), now also used by Thinks, SeesImages,
  NameOf and OutputOf, which matched the exact id only.
- renamed applies only when models.dev lists no model by the id at all
  (a new `listed` set of every bare id, whatever it says of it): a window
  mark comes off first, and if what is left is listed it is the model
  (Claude Code's claude-opus-5[1m] stays claude-opus-5, never "opus-5");
  else a "claude-" prefix comes off when the rest is listed and names a
  version, so the reporter's counter-example claude-auto[1M] is not
  models.dev's router "auto".
- ContextOf gives a mark's window (what the relay serves it at, as Claude
  Code takes [1m] for 1M); NameOf keeps the mark ("DeepSeek V4.1 Flash
  [1M]") so two models apart by window alone read apart.
- Siblings: PricedBy (last, after the dot/dash match) and ListedBy take
  the rename too; Knows follows from ContextOf/EffortsOf/Thinks.

Ran: the reporter's TestRelayRenamedIDLosesCapabilities verbatim, plus
tests for every getter on the renamed forms, Claude [1m] ids, a listed
claude-glm-5 keeping its own (empty) levels over glm-5's, near misses
(claude-auto, -flashy, [fast], [infm], anthropic- prefix) matching
nothing, gpt-5.5/auto/opus-5/glm-5 unchanged. Broken by hand seven ways
(no rename, no listed gate, no version check, mark window ignored, prefix
before the mark-stripped id, PricedBy or ListedBy without the rename):
each FAILs naming the getter. Against today's models.dev api.json:
claude-deepseek-v4.1-flash[1M] -> low,high,max, 1M, images; claude-auto[1M]
-> nothing; claude-code (listed) as before. gofmt -l clean; go vet,
GOOS=linux go vet -tags nogui, GOOS=windows go vet ./...; go build for
darwin, linux (nogui), windows; go test -tags nogui ./... in a temp HOME
all ok.
2026-10-09 13:35:14 +08:00
yetone 4cbde14cea gui tests: rate-limited-sink wheels the WorkBuddy AI pool's "Goes to the back" into sight before clicking it, as aab2e441 did for the group editor's rows (#1376)
The pool sits under the 1400px window's foot. In WebKit Playwright's own
scroll into view is put back by the page (it undoes a scroll the reader
didn't make), so the click timed out with the option outside the
viewport, en and zh. The test now wheels to it as the reader would, then
reads the scroll position the "a click never scrolls the page" check
compares against, so that check still covers the click alone.

Ran: before the change, BROWSER=webkit: 2 pass, 2 fail (both "the
Routing page sets it", "element is outside of the viewport"). After:
Chromium + WebKit, en + zh (the languages this test covers), 3 runs of
8/8 pass, then WebKit alone 3 runs of 4/4 pass.
2026-10-09 13:31:30 +08:00
yetone 2c36d3f282 gui tests: TestSetAnswersWhileDevinAndProvidersHang tells that the set didn't wait by order, not a 1.5s clock, and its fake devin ends with the test (#1375)
The 1.5s wall-clock bound failed at 1.6s under a loaded full run. The
fake devin CLI now takes 20s and touches a marker when its answer lands;
after the requests the test says no marker is there, which no request
that didn't wait can see, whatever the load. The bounds are 10s: slack
against load on one side and against the fake's 20s on the other, and
they still stop a set that waits on the never-answering provider.

As ggbdpq proposed on the issue, with one change: their fake ran
`sleep 20` and outlived the test (LESSONS: a fake a test starts ends
when the test does). This one sleeps in 0.1s steps, stops on a file the
test's cleanup writes, and the cleanup waits (5s at most, else an error)
until every run of it has ended. Seen: 2 runs alive at cleanup, 0 after.

Ran: -count=3 -v pass (sets 5-111ms); -race -count=10 pass; the whole
internal/gui package pass; gofmt -l clean; go vet, GOOS=linux and
GOOS=windows go vet -tags nogui ./internal/gui clean. Broken by hand
(DevinFamilies ignoring DevinNoWait): FAIL, "set claude-opus-5-5 took
21.6s" and "a devin answer landed before the requests were done".
2026-10-09 13:29:08 +08:00
yetone 3cd0b5f78d gui: lightweight mode no longer lets go of a main window that is open under another app's, so Command-Tab back to magpie finds it there (#1381, ttmouse)
Cause: lightweight mode (#580) let go of the main window once two of its
30 s looks found it "not shown", and it asked Wails' IsVisible, which on
the Mac is the window's occlusion state. A window the user had
Command-Tabbed away from, covered by the other app's window, counted as
closed: 30-60 s later its webview was dropped and the window closed, and
Command-Tab back to magpie found a blank shell or no window at all. Hidden
with magpie (Command-H) it went the same way, since hiding orders every
window out.

Change: windowUp says whether a window is up as the user sees it:
ordered in on any Space, covered or not, minimised, or open as magpie was
hidden (watchHide records those on NSApplicationWillHideNotification).
Only a window magpie closed itself is down. lighten (through lightShown)
and mainShown use it, so the Dock-while-open setting and a restart to
update also keep a covered window as open. Elsewhere windowUp is
IsVisible as before (visible there covers covered and minimised).

Run:
- Reproduced with a sandbox build of origin/main (own HOME and
  CFFIXED_USER_HOME, port 3481, dock+lightweight on): with the open
  window covered by a full-screen window of a helper process for 70 s the
  log said "the main window's webview let go" and the window was a blank
  white shell. With this change, the same run let go only the closed
  panel and the window kept its page (screenshot of the window).
- Activation itself was checked by handing activation from the helper to
  magpie (NSRunningApplication activateFromApplication): with the window
  there it came forward. A real Command-Tab keystroke was not sent.
- New TestCoveredWindowStaysUp (AppKit, own process): open, covered by
  another window (until IsVisible says false), hidden with the app,
  minimised -> up; closed by magpie, also with the app hidden -> down.
  With windowUp put back to IsVisible it fails: "open: the window counts
  as up=false, want true"; without the hidden clause: "hidden with
  magpie: the window counts as up=false, want true". Passes -count=10.
- gofmt -l; go vet ./internal/gui; GOOS=linux go vet -tags nogui and
  GOOS=windows go vet (with and without nogui) ./internal/gui; go build,
  GOOS=linux go build -tags nogui, GOOS=windows go build;
  go test ./internal/gui and go test -tags nogui ./internal/gui under a
  temp HOME: ok.
2026-10-09 12:59:29 +08:00
yetone 4b56c8672d plugin: an update Bun holds back says why, instead of saying it was made (sweanng424 on Discord)
What: Update, Update all, the hourly auto-update and the move's install
ask npm for the plugin's newest version and have bun install that exact
version (installAt), then check it is the one installed. When bun won't,
the error says why, reason first for the status pill: "<pkg> 0.1.21 isn't
installed yet: Bun's minimumReleaseAge (in a .bunfig.toml) holds back
versions published less than 2 days ago, and magpie installs it once it
is older (bun's own words)". Another bun error (a registry of the user's
own without the version) is "<pkg> <v> isn't installed: <bun's error:
lines>". Specs stay as they were (name@latest); pinned and git plugins,
and npm not answering, install as their spec says, as before.

Why: the Factory card stayed at 0.1.18 with 0.1.21 out, through clicking
update and restarts. bun add pkg@latest resolves "latest" by bun's own
config: a minimumReleaseAge in the user's ~/.bunfig.toml or
$XDG_CONFIG_HOME/.bunfig.toml makes it install the newest version older
than that and exit 0. 172800s (2 days) gives exactly 0.1.18 (0.1.19-21
were published 10-08). So every update path succeeded with nothing
changed, and the page said "updated to v0.1.21". Asked for 0.1.21 itself,
bun fails with "blocked by minimum-release-age: 172800 seconds". The same
code serves every moved plugin (Cursor, Devin, Kiro, Qoder, ...), so all
of them had it. npm view: 0.1.21 is latest; npmmirror has it too.

Run:
- TestUpdateBunHoldsBackSaysWhy (new): real bun 1.4.2 against a fake
  registry with 0.1.18 (3 days old) and 0.1.21 (1 hour), a bunfig with
  minimumReleaseAge = 172800. On the old code it fails: "Update with
  0.1.21 held back by Bun: <nil>, want bun's reason (installed 0.1.18)".
  Breaking Update alone fails at "Update all: <nil>", breaking the hourly
  update alone at "the hourly update: <nil>". Without the bunfig it
  installs 0.1.21 and keeps the spec @latest.
- Real use: magpie web (nogui build) under a sandbox HOME, real npm, with
  the bunfig: add factory-auth@0.1.18, spec @latest, POST
  /api/plugins/upgrade and /update return the reason above, the card
  stays 0.1.18; bunfig removed, upgrade installs 0.1.21.
- Ruled out on macOS and the Windows box: plain upgrade 0.1.18 -> 0.1.21
  works there without a bunfig, host running or not.
- gofmt -l; go vet (darwin, GOOS=linux, GOOS=windows, -tags nogui) on
  internal/plugin, internal/provider, internal/gui; go build (darwin),
  GOOS=linux and GOOS=windows -tags nogui builds; go test -tags nogui ./...
  under a temp HOME, all ok.
2026-10-09 12:57:56 +08:00
yetone 8e0e7d3c40 dsh: the desktop app's profile made while magpie runs gets magpie's route within a round, not at magpie's next start (star on Discord)
star on Discord reported DeepSeek Harness Desktop with the red
"已不经过 magpie" line. One way there that a desktop user meets: the
CLI's web profile wired, then the desktop app opened for the first time
while magpie runs. dsh makes profiles/desktop/cordis.patch.yml as its
empty template ([]), dshCheck says the desktop profile has none of
magpie's models (Drift "unwired"), and only dshSync — the catalog sync,
at magpie's start or a catalog change — filled new profiles, so it stayed
so until Reapply or a restart. The reporter's exact detail is cut off in
the screenshot, so this is a likely cause, not a confirmed one.

dshWiredOnce, the 30s serving round, now runs dshFillNewProfiles over a
profile that is dsh's empty template, beside the wired ones: magpie's
route and start go in as the catalog sync would put them. A profile with
entries of its own and no route is the user's and is still left alone.

Run: TestDshDesktopProfileMadeWhileServing fails on the old code ("the
round left the desktop profile bare"), passes with the fix, and checks a
user's own unrouted profile is not written. go test -tags nogui
./internal/agent ./internal/gui under a temp HOME with pinned caches: ok;
go test -race -run TestDsh -count=3: ok. gofmt clean; go vet darwin,
GOOS=linux -tags nogui, GOOS=windows; go build darwin, linux nogui,
windows: ok. Not tried with the real desktop app live.
2026-10-09 12:56:08 +08:00
yetone ee3f83b59d agents: DeepSeek Harness Desktop installed is no missing dsh CLI — its version shows instead of 未找到 CLI (star on Discord)
star on Discord: "DeepSeek Harness 就是现在已经有桌面版了,但是他还是非要找CLI".
With DeepSeek Harness Desktop in use and no dsh on PATH, the Agents page
said 未找到 CLI and Install another agent offered npm's dsh: CLIMissing
(#843) took ~/.dsh without a CLI for an uninstall. The desktop app
(DeepSeek Harness.app, com.deepseek.dsh, 0.2.0-rc.2 from
download.deepseek.com) keeps the same ~/.dsh — its own profile,
profiles/desktop/cordis.patch.yml, and .credentials.yaml — and needs no
CLI; its terminal command (Manage dsh Command…) is optional.

- desktopapp.go: dsh's app is known by its bundle id on macOS and by
  %LOCALAPPDATA%\Programs\DeepSeek Harness\DeepSeek Harness.exe on
  Windows (electron-builder per-user NSIS, productName DeepSeek Harness,
  getWindowsInstallationDirName); HasApp says either is installed.
- install.go: CLIMissing is false with the agent's desktop app installed,
  so the GUI row, Install another agent and /api all follow; the app's
  version shows through the existing CLI().App path.
- dsh.go: the restart notice also sees DeepSeek Harness.app running.

The red "已不经过 magpie" line in the report is a separate dshCheck
finding, not caused by the missing CLI: a desktop-only ~/.dsh shaped
from the app's real new-profile template wires cleanly (Check "", no
Drift; TestDshDesktopOnlyWired). The reporter's exact detail is cut off
in the screenshot and is not reproduced.

Run: TestDshDesktopAppIsNoMissingCLI fails on the old code ("with the
desktop app: missing true, offered true"; with the Windows path removed,
"with the Windows app: missing true, offered true"), passes with the
fix. go test -tags nogui ./internal/agent ./internal/gui under a temp
HOME with pinned caches: ok. gofmt -l clean; go vet darwin, GOOS=linux
-tags nogui, GOOS=windows on both packages; go build darwin,
GOOS=linux -tags nogui, GOOS=windows: ok. Not tried: the real desktop
app running live (not installed here; its userData isn't redirected by
a sandbox HOME), a real Windows install.
2026-10-09 12:56:08 +08:00
yetone 4dc7222fdc kimi: each of magpie's models in Kimi Code has its name (display_name) and, where magpie knows it, its most output (max_output_size); a value the user set in the table stays (Sorghum on Discord)
What: kimiModelTables writes display_name (the name magpie shows for
the model, left out when it is just the id) in every [models."magpie/…"]
table, and for the new Kimi Code max_output_size (the catalog's output,
capped at the window by maxTokens; left out when unknown). kimi-cli gets
display_name only: it has no max_output_size. What magpie last wrote in
each table is kept in the stash (kimi:<path>:wrote); a value there that
isn't it is the user's and stays, while magpie's own follows the catalog
and goes when the catalog no longer knows it. The record goes when magpie
steps out.

Why the keys are safe: Kimi Code (MoonshotAI/kimi-code) has had both
maxOutputSize and displayName on its model alias since 0.2.0, its model
record passthrough on 2.x (agent-core-v2 kosongConfig/configSection.ts);
max_output_size becomes the request's max_completion_tokens for the kimi
type. kimi-cli (MoonshotAI/kimi-cli) added display_name to LLMModel in
1.37.0 (0bc7928, #1948); its config never sets pydantic extra, so older
ones ignore the key.

Run: TestKimiNamesAndOutput (new; both config dirs, with hand-set values)
fails three ways with the change broken: user values not kept
(display_name "Big One · Relay", want "My Big"), magpie's stale value kept
(max_output_size 32000, want 64000), neither key written (display_name "").
go test -tags nogui ./internal/agent/... (temp HOME, caches pinned) ok;
gofmt -l clean; go vet + GOOS=linux/windows go vet ./internal/agent ok;
go build, GOOS=linux go build -tags nogui, GOOS=windows go build ok.
Real use in a temp HOME: Kimi Code 2.1.1 (npm) `kimi doctor config` OK on
the written config, and `kimi -p` against a local fake server answered,
its request carrying max_completion_tokens 32000; kimi-cli 1.52.0's own
load_config read display_name and ignored an extra max_output_size.
2026-10-09 12:51:30 +08:00
yetone 6f59be4ef7 plugins: Qoder's mover asks for 0.2.11, so a moved Qoder CN enterprise VPC account keeps its model list and renewal mark apart from a public account with the same uid (plugins#40)
0.2.11 (magpie-community/plugins#40, AwadYoo) keys the plugin's model
listings and its "renewed" marks by deployment and uid instead of uid
alone. Raising min lets keepMovedCurrent update every moved Qoder user.

Run: plugins bun test 1000/0 under a temp HOME at the PR head, the two
new tests fail with the key reverted to cred.uid; npm view shows 0.2.11;
here go test -tags nogui ./internal/provider -run Moved|Migrat|Qoder|
Mover|KeepMoved ok, gofmt -l clean.
2026-10-09 12:51:13 +08:00
如是 e119470a70 gui: the ZCode plugin's claim line is translated — its name is a sentence magpie knows, its count and plan name are data (#1244)
* gui: the ZCode plugin's claim line is translated — its name is a sentence magpie knows, its count and plan name are data

The ZCode plugin's card gets a line when the app holds a gift plan the
account hasn't been granted yet. It was a window named after the plan and
displaying "1 to claim · claim it in the ZCode app", which stayed English
on a Chinese interface: a window's display is shown as it came
(quotaCount returns w.display for a window with no limit, app.js) and only
its name goes through t() — on the card, in the tips and in the chart. The
plugin cannot know the interface's language (host.js and provider.Provider
hand it no locale) and magpie's translation is keyed by the string, so the
sentence has to be the name. The plugin's own change is
magpie-community/plugins#43: the window is named "Gift plans to claim in
the ZCode app" and the display carries "1 · ZCode Trust Build" — one name
for any count, and the plan's name as the vendor gave it.

zh, zh-TW, ja and de each get that name: 有赠送额度待领取 · 请在 ZCode
客户端领取, 有贈送額度待領取 · 請在 ZCode 用戶端領取, 受け取り待ちのギフト
枠があります · ZCode クライアントで受け取ってください, Geschenk-Kontingente
zum Abholen in der ZCode-App (yetone/magpie#1001).

quota-name-translated.test.cjs is new and holds the rule itself, not just
this line: a window whose name is a sentence magpie knows and whose
display is the plugin's own, in English and Chinese, Chromium and WebKit —
the name reads in the language, the display does not. It fails on the two
Chinese runs without the zh entry. gui-de/gui-ja/gui-zh-tw keep every zh
string covered, and i18n-keys.test.cjs passes.

* gui: the claim line's translations fit the card at 560px, and the test checks every language at 440 and 560

The names added for "Gift plans to claim in the ZCode app" were too long for
the card: .quota-labels > span is nowrap with no ellipsis and no tooltip, so
anything wider than its .quota is cut off mid-word with nothing saying so
(yetone on #1001, measured in en/zh/zh-TW/ja/de at 360–1000px in both
engines). ja was the worst — cut by 79px at the default 660px window and
129px at 560 — with de cut at 560 and zh/zh-TW at 440.

Every language is now a shorter sentence, checked in the real page at 440
and 560px in Chromium and WebKit: nothing overflows and nothing is clipped.
en is unchanged (it is the key, and it fits at 440). zh/zh-TW drop the
"· 请在…领取" clause for a leading "待在…领取的"; ja uses the wording
suggested in review; de likewise.

quota-name-translated.test.cjs now covers every language magpie has, not
only en and zh, and renders each at 440, 560 and 1000px rather than 1000
alone — the width that could never catch this — asserting the name's right
edge stays inside its .quota and that it isn't clipped. Red/green: with the
previous long wording restored, the fit assertion fails with the measured
overflow (zh and zh-TW by 14px at 440, ja by 189px, de by 68px); with the
new wording all ten pass. i18n-keys, gui-de, gui-ja and gui-zh-tw pass.

* gui: the claim-line test's README says what it covers, and its fit check measures the box

Two things from review (#1001): the README paragraph still said "in
English and Chinese" and said nothing about the widths, though the test
now covers every language magpie has at 440, 560 and 1000px — a
translated name is a sentence and .quota-labels > span is nowrap with no
ellipsis, so the width is the point of the test, and 1000 alone could
never catch a name that is too wide.

And the fit check read `s.scrollWidth > s.clientWidth + 1`, which is
always false on an inline span: the dead half is gone and the name's own
box is compared with its .quota instead, which is what actually catches a
cut name (the `over` value beside it was doing the work). Red/green, with
the long wording restored: "the name is cut off at 440px: 14px past its
quota, wider=true" (zh, zh-TW), 189px (ja), 68px (de).
2026-10-09 12:35:34 +08:00
yetone 78ae171a6d gui: the folded Codex row says which copy to reopen, "已接入 · 重新加载编辑器窗口后生效" for an editor's Codex, instead of only "reopen Codex" (#1374, SivanCola)
Folded, the row said "Connected · takes effect once Codex is reopened"
whichever copy was left on the old list. The reporter reopened the
ChatGPT app while the copy left was VS Code's Codex, and read the line
that stayed as a false alarm; only the opened row (2f74a963) said which.

connectLine now names the copy from a.staleCopies' kinds, as the
opened row does:
- one kind left: how that one is reopened ("reload the editor's
  window", "quit and reopen the Codex app", "restart Codex's
  app-server", "reopen {app}" for another app's own Codex, "restart
  Codex in the terminal"), worded short with the kind first, since the
  folded line is cut at narrow widths;
- several kinds: "{n} copies of Codex to reopen";
- the line's title has every copy whole, with its start and command
  (⌘Q, codex app-server daemon restart), for when the words are cut;
- no staleCopies, or a kind magpie doesn't know (Claude Code): the
  old words.
Strings in zh, zh-TW, ja and de with the same placeholders.

Verified:
- agent-stale-copies.test.cjs gains "the folded row says which Codex
  to reopen": ide (the reporter's case), app, embedded and several,
  Chromium and WebKit, en/zh/zh-TW/ja/de, 980px and 440px: 20/20
  pass; with app.js put back they fail ("ide: Connected · takes
  effect once Codex is reopened"). The opened-row tests still pass.
- gui-ja, gui-de, gui-zh-tw (every string, same placeholders) pass in
  both engines.
- real GUI: a magpie built from this tree, `magpie web` under a
  sandbox HOME on 127.0.0.1:3486, a real codex app-server started
  from <HOME>/.vscode/extensions/openai.chatgpt-…/bin/…/codex before
  Codex was connected: /api/state gave staleCopies ide plus the
  machine's ChatGPT.app, and the folded row read "已接入 · 2 个运行中的
  Codex 待重开" / "Connected · 2 copies of Codex to reopen", its title
  naming the editor's copy and the app's, Chromium and WebKit, 440px
  and 980px. The one-kind case wasn't reproduced live (the machine's
  ChatGPT app isn't mine to quit); it is covered by the test above.
- go test -tags nogui ./internal/gui under a temp HOME; GOOS=linux and
  GOOS=windows go vet -tags nogui ./internal/gui.
2026-10-09 12:17:21 +08:00
yetone 457119fec3 gui: text selected in a dialog and let go outside it no longer closes the dialog; only a press and a release both on the backdrop do (#1373, xiaozhu1337)
Dragging a selection out of a field (to bring in the part past its
end) and letting go over the backdrop gave the click to the press's and
release's nearest shared ancestor, the backdrop, so every backdrop
handler that checked only e.target closed the dialog.

backdropClick(el, on) in app.js records where the pointer was pressed
and let go, and a click counts as one on the backdrop only when both
were. Every dialog that closes from its backdrop now asks it:
- the shared #modal (provider and other editors, cancelEdit),
- the confirmation that borrows #modal (closeConfirmAsk),
- the library's dialog that borrows #modal (closeLibModal, library.js),
- confirmAction's <dialog> (its ::backdrop is the dialog outside its box).
Menus and pickers close on mousedown outside and were never affected.

Verified:
- new internal/gui/tests/dialog-backdrop-drag.test.cjs, Chromium and
  WebKit, en and zh, 1100px and 440px: 8/8 pass. With the change
  reverted all 8 fail ("a selection dragged out keeps the dialog");
  with only confirmAction reverted they fail on "a selection dragged
  out of the confirmation keeps it".
- the whole GUI suite in both engines: the only failures are
  purpose-filter in WebKit (fails the same without this change, #1291),
  rate-limited-sink "says who is at the back" in WebKit (fails the same
  without this change) and library-servers-bulk in Chromium (failed
  under the full run only, passes alone).
- real GUI: a magpie built from this tree (`magpie web` under a sandbox
  HOME on 127.0.0.1:3486), Chromium and WebKit, zh and en, 440px and
  980px: a drag from the provider editor's Name field out over the
  backdrop selects the text and leaves the editor open; a click on the
  backdrop still closes it.
- go test -tags nogui ./internal/gui under a temp HOME; GOOS=linux and
  GOOS=windows go vet -tags nogui ./internal/gui.
2026-10-09 12:17:21 +08:00
yetone be2037285a davsync, gui: a server file that isn't a backup is said as what it is, and can be replaced by this computer's setup (JasonLeeForOnly on Discord)
JasonLeeForOnly's WebDAV sync failed with only "not a magpie backup" for
several versions, and nothing on the page got past it. A WebDAV GET of the
backup can come back as a body that isn't the file in several ways; each is
now reproduced with an httptest server that answers the way the real one
does:

Unpacked (WebDAV and S3): gzip with or without Content-Encoding (a proxy
that drops the header), x-gzip, zstd with or without the header, deflate
(zlib or raw), and a header that says gzip over a plain body. Bodies are
told by magic number; a backup is JSON, so either magic is never the file.
Brotli (br) can't be unpacked and is said as itself, with what to turn off.

Said, with no upload offered: an HTML page answered with 200 (Nextcloud
login after a redirect, Cloudflare Access, an AList/OpenList web app, an
rclone directory listing, a captive portal), with its <title> and the
host/path a redirect ended at (query, fragment and user dropped), and
where the WebDAV address is for 坚果云 and Nextcloud; an XML answer, by its
root element.

Said, with Upload as the way out: an empty (0-byte) file, a backup cut
short or damaged (the automatic rebuild is unchanged and still goes first
when its rules allow), another app's file ("format": "…"), other JSON,
and any other file by its content type. Messages carry the size, kind and a
page title only, never the file's contents.

backup.Open now tells ErrNotBackup (doesn't begin like a backup) from
ErrCorrupt (begins like one, cut short). The status carries the kind as
serverFile; Settings › Sync and backup says it in the reader's language,
wraps it whole, and shows "Upload this computer's setup" only when the file
may be replaced. davsync.Upload (POST /api/davsync/upload, `magpie webdav
upload`, `magpie s3 upload`) asks first in the GUI, re-reads the file,
refuses a backup this computer opens, one sealed with another passphrase,
a newer magpie's, a page and an XML answer, keeps the server's copy in the
sync folder (0600, newest 5) and writes nothing if that fails, then writes
with If-Match on the version read. New strings in en, zh, zh-TW, ja, de.

Verified: internal/davsync/not_backup_test.go (TestReadCompressedBackup,
TestReadBrotliSaid, TestServerAnswerSaid, TestCutBackupSaidAndUploaded,
TestS3ReadCompressedObject; Upload-only parts stripped to compile) fails
on e4a90aa6 for every compressed case but "gzip said", Brotli, every
server-answer case, the cut case and S3 gzip, and passes here. Dropping
the Replace check in Upload turns the page/XML cases red ("Upload wrote
over a page"). gofmt -l clean; go vet darwin, GOOS=linux and GOOS=windows
-tags nogui on ., davsync, backup, gui; full go test -tags nogui ./... ok;
-race on davsync and backup ok. GUI: sync-not-backup.test.cjs (en, zh,
zh-TW, ja, de; 900 and 440px), sync-*, s3-sync, gui-de, gui-ja, gui-zh-tw,
click-scroll in Chromium and WebKit, 81 pass. Not tried against a real
WebDAV server or on the Windows box; the reporter's server is unknown.

Note: 2018882e on main carries this subject by mistake (another session read a shared message file); it holds only GTK DPI code. This commit is the actual WebDAV change.
2026-10-09 12:14:26 +08:00