Commit Graph
2530 Commits
Author SHA1 Message Date
yetone c9e8422fa8 agent: a field label with no TUI Chinese fails internal/agent's tests
A new agent field's label with no entry in internal/tui's zh map left
TestEveryWordHasZh red on main twice (e9fcc6229 on 11-15 for
"permission mode", 618bfc1a9 on 11-17 for "subagent pool"), each by a
change that ran internal/agent but not internal/tui.
TestEveryFieldLabelHasTUIZh reads tui's i18n.go and keepAsIs (tui
imports agent) and fails in the package such a change runs. LESSONS and
the code standards' criterion 3 name it.

Run: on mote, go test ./internal/agent: ok (250s). The new test on
Linux (wsl-run) and Windows (win-run): ok. gofmt -l: clean.
Broken by hand: with "subagent pool" taken out of i18n.go, red ("kimi's
field \"subagent_pool\" (label \"subagent pool\") has no Chinese").
2026-11-17 15:09:29 +08:00
yetone 3b4983710a gateway: a usage cap holds with sessions in parallel (yalifesign on X)
yalifesign runs 4 or 5 sessions on one ChatGPT Plus account with a 90%
cap and capStop/capCareful off, and the five-hour window went to 100%
and Codex's own 429. Caps from 99 down to 90 all overshot.

Cause: a Codex reply reports usage (codex.rate_limits, x-codex-*) as
its turn begins, without that turn's own spend. The near-cap gate
(435f04151) took one turn at a time only once a reading was inside the
5-point band. It neither counted nor waited for the turns already out
on the account, and after waiting it read usage again only when the
reading hadn't changed, which a pre-turn reading always changed. Five
sessions start turns on readings outside the band that lag every turn
in flight, and they pile up past the cap.

Fix, in serve's walk and cap_near.go:
- turnSpends learns what one turn spends per account (the rise in used
  over the turns returned since it last moved, at most 2x the band) and
  Server.nearCapOf judges "near" on the reading plus that spend for
  every turn out or returned since the reading.
- Near the cap, after taking the near slot, a turn waits until no other
  turn is out on the account (lanes.out, lanes.idle; a lane slot handed
  to this request is its own and not waited for). With other
  candidates it moves behind them first, as before.
- nearCapAgain reads usage again (bounded by carefulWait) when a turn on
  the account came back after the last good read (lanes.ended vs
  UsageRead), and still when it waited and the reading is unchanged.
The gate is generic over the account, so Claude accounts and plugin
accounts get the same hold. capStop and capCareful are read as before;
nothing changes a value the user set. A key's usage cap has no
near-cap gate at all, before and after this: #6928.

Tests:
- TestCapHoldsUnderParallelSessions: a fake Codex that reports usage
  before each turn and adds 1.5 points after it, 5 sessions x 40 turns
  from 60% to a 90% cap. Fails above cap + one turn (91.5%).
- TestNearCapReadsAgainAfterATurnCameBack, TestNearCapWaitsForTurnsAlreadyOut,
  TestTurnSpendsAhead, TestLaneIdleLeavesItsOwnSlot.
- TestNearCapWaitsThenHolds now has the usage read after the first turn.

Run:
- origin/main adfa196db with the two gateway tests (-count=10, mote):
  TestCapHoldsUnderParallelSessions red 9 of 10 (91.5 to 97.5%),
  TestNearCapReadsAgainAfterATurnCameBack red 10 of 10.
- With the fix: the parallel test 20 of 20 at 90.0%, earlier 39 of 40
  at 90.0% and 1 at 91.5%; near-cap, lanes, key slot and careful tests
  -count=3 ok.
- Broken by hand: no spend estimate, 8 of 20 red (93.0, 94.5%); no
  re-read after a returned turn, ReadsAgainAfterATurnCameBack red 10 of
  10; no wait for turns out, WaitsForTurnsAlreadyOut red on every run.
- go test ./... -timeout 45m on mote at 884bcadb6 (base ff88ec264): 103
  ok, no FAIL. Rebased on 618bfc1a9 (kimi, agent and gui only), then
  internal/gateway, internal/agent and internal/gui again: gateway, agent and gui ok at bb23d1b69.
- gofmt -l clean; GOOS=windows go vet ./... ok; go vet ./... on Linux
  (wsl-run, magpie-desktop): ./internal/gateway/... and ./internal/provider/... ok; the whole tree stops on
  gtk4/webkitgtk-6.0 missing in that distro. GOOS=linux vet from macOS
  stops in Wails' cgo files, as on main.
- No GUI change, so no GUI suite.

Not tried: a real Codex account at its cap with parallel sessions (the
fake reproduces the reported shape, not OpenAI's exact accounting); the
spend estimate on a window that renews mid-run beyond the unit test;
key caps (#6928).
2026-11-17 14:54:11 +08:00
yetone 618bfc1a95 kimi: pick Kimi Code's subagent pool and its effort (XiaoLing_Arisa on X)
XiaoLing_Arisa asked on X for Kimi Code's subagent pool (子代理池) on the
Agents page: which models its subagents may run on, and how hard they
think. Kimi Code 2.x keeps them in config.toml's [secondary_model]:
default_model (the legacy `model` stands for it), the pool
[secondary_model.models] ("alias" = "when to use it") and default_effort.

- internal/agent/kimi_secondary.go: three fields, subagent_model,
  subagent_pool and subagent_effort, written the way Kimi Code takes
  them. Its validator refuses a pool that lacks the default, a name with
  no [models."…"] table, and an effort a pool model can't take, so a
  default goes into the pool, a pool without the default gets its first,
  and only the levels every pool model takes are offered
  (kimiPoolLevels). A magpie model goes in only while [providers.magpie]
  is there. Keys are set in place; hints, other keys and comments stay.
  Before Sync or Unwire drops a magpie model table, its name leaves the
  section (kimiPruneSecondary). The default goes back to the user's own
  (stashed at kimi:<path>:secondary) or to the pool's first, and an empty
  section goes. The user's own pool of their own models is never touched.
  kimi-cli (legacy) has no such section. A stopped WSL distro shows none
  of the three, since each reads the config (#3896).
- GUI: the three fields form one Subagents line in the opened row: the
  model, then the effort (disabled until a model is set), then a
  multi-pick pool menu that stays open between ticks. The model's tick
  can't be removed. The picker's note says an unset model runs each
  subagent on the lead's model. The line is drawn by kimisub.js, which
  Details imports before its first slide so the sheet measures it.
- Size budgets +457 (reason in core_budget_test.go). Translations in
  zh, zh-TW, ja and de. kimisub.js is added to old-webkit's list of
  scripts loaded on demand. The Kimi bullet in agent-wiring.md is
  updated.

Run at this tree on mica (mica-run):
- go test -tags nogui -count=1 ./internal/agent ./internal/gui: ok,
  including TestKimiSubagentPool*, TestWSLColdPlaceOpensNothing and
  TestCoreScriptBudget. An earlier run of these packages found the cold
  read and the budget overrun; both are fixed here.
- go vet ./... on darwin, GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: ok. go build: ok. gofmt -l .: empty.
- GUI: kimi-subagent-pool passes 20 of 20 (Chromium and WebKit, 5
  languages, 1100 and 560px). kimi-thinking passes. agent-details-ready,
  old-webkit and i18n-keys have 35 reds, and origin/main ff88ec264 has
  the same 35, all filed: #6373, #6369 (agent-details-ready), #6030,
  #5919 (old-webkit), #6877 (i18n-keys).
- Broken by hand: with Details not waiting for kimisub.js,
  kimi-subagent-pool goes 10 of 10 red in Chromium ("the Subagents line
  is there when Details first draws").
- Real Kimi Code 2.6.2 (npm) in a sandbox HOME with a fake SSE server:
  the pool and effort written here are read and used. A pool naming a
  model with no table is refused when a subagent starts. A bad effort is
  not refused at runtime, but magpie refuses it anyway, as the validator
  does.

Not run or tried:
- The full go test ./... and the full GUI suite: mica and mote were both
  past their load limits with other sessions' suites. Only the packages
  and GUI files above were run.
- A real Moonshot account. The subagent's "timed out" in the sandbox run
  came from the fake server.
2026-11-17 14:30:55 +08:00
yetone ff88ec264a sync: subscriptions whose sign-ins stay on this computer (Ethereal499 on X)
Sync's sign-ins can now leave chosen subscriptions out on one computer
(`signInsExcept`, provider ids; Ethereal499 on X keeps Claude's accounts
off other computers). On that computer:

- its accounts of those subscriptions never go up;
- the server's accounts of them are never merged in, so a removal or a
  new account on another computer changes nothing here;
- the server keeps them as they are for the computers that do sync them
  (syncOnce splits the remote set with SignIns.Except and puts the held
  part back with With after the merge, so the hash doesn't change);
- the preview and Restore count and restore none of them.

An id names both the built-in and its -plugin id. An old config has no
field and syncs everything as before. The setup text doesn't carry the
choice, since it belongs to one computer.

GUI: Settings > Sync > edit > Advanced, under "Sign-ins", a "Not synced"
row with a multi-select openProtoMenu of the subscriptions with an
account. The row shows only while the sign-ins tick is on. The strings
already existed in en, zh, zh-TW, ja and de. CLI: `sign-ins-except=`
on the WebDAV, S3 and GitHub setups ("none" clears it), and status
shows the excluded ids. docs/subsystems/sync-backup.md says it.

Tests:
- TestSignInsExcept (provider) and TestSyncSignInsExcept (davsync, two
  computers on a fake DAV).
- sync-signins-except.test.cjs: both engines, 1100 and 420px, all 5
  languages.

Broken by hand, each red and then restored:
- the Except in collect;
- the Except on the remote set before the merge;
- the Except in the preview;
- the With after the merge;
- the GUI form's post of signInsExcept.

Run:
- At ac4a4cf84 on mote: `go test -timeout 45m ./...`, 102 packages ok,
  exit 0.
- At ac4a4cf84, the whole GUI suite on mote. The first part ran at
  concurrency 6 under load 25 to 37, and mote rebooted mid-run (not
  this session's doing). The 410 files it never reached ran at
  concurrency 4. Reds fell in 125 files, none of them a sync-* file
  except s3-sync (see below).
- At the rebased head b781d0bcb on mote:
  - go test ./internal/davsync ./internal/provider ./internal/cli
    ./internal/gui: ok.
  - Every sync-*.test.cjs, webdav-settings-refresh and
    sync-signins-except: ok.
- gofmt -l: clean.
- On mica: go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./... ok, plus go build, GOOS=linux go build
  -tags nogui and GOOS=windows go build.

Red the same on origin/main 873b1f7d5, run there alone:
- s3-sync webkit en ("picking S3 must not scroll the page"), #3413 and
  #2448.
- i18n-keys (", with an image" in plugins/routing), #6877.

Not run: the full Go suite at the rebased head. Another session's full
suite held mote, and mica was full. The 125 GUI files red under load
were not each run alone on main.

Not tried: a real sync between two computers with real accounts.
2026-11-17 14:08:48 +08:00
yetone 873b1f7d5e classify: 15 seconds unset for a classifier that reasons, and its cut call is magpie's wait (ESern29751 on X)
ESern29751 on X (v0.1.4341): in a routing group with intent recognition,
magpie often 499-cancels the intent classifier's request, with MiniMax,
GPT-6 Luna and Grok 4.6 as the classifier.

Cause: those models reason before they answer. The classifier asks for
reasoning_effort none, but MiniMax thinks anyway and Grok 4.6 and Luna go
no lower than low. Through the live gateway with the classify prompt over
a real routing prompt (~5k tokens of context): grok-4.6 took 4.7-8.1s
(288-462 reasoning tokens), minimax-m2.5 3.7-10.3s (439-1012 output
tokens), gpt-6-luna 1.2-7.2s; cold calls reached 12-29s. The unset
classifier timeout was 8 seconds, so most turns were cut off, fell back to
the group's order and lost their intent routing. Each cut call was then
logged 499 "the agent canceled the request", which usage counts as no
failure, though no agent had canceled anything: askChat's own
context.WithTimeout had no cause, the mislabel #2318 fixed for an image's
description but never for the classifier.

Fix:
- settings.ClassifyTimeoutDefault 8 -> 15 (an existing Settings segment).
  A user who saved 8 keeps 8; only the unset value moves. The GUI's
  fallback segment follows (app.js), and the docs (en/zh/ja intent and
  start, gateway-routing.md) say 15.
- askChat's wait is context.WithTimeoutCause(..., sideTimedOut{"decision
  model", wait}): the usage row says "magpie stopped waiting: its
  decision model had no answer in Ns", a failure.
- Siblings checked: the advisor and Codex titles use the client's
  context, compaction and vision already carry sideTimedOut; askJev
  (decision providers) logs no 499 row of its own.
- Tests that assumed the 8-second unset wait now use 15 (classify,
  decide, decide_group, nested_classify_wait, settings).
- app.js grows by the one byte of the fallback's second digit: both
  core budgets +1 with the reason (TestCoreScriptBudget was red at
  exactly 1 over without it). A shorter `|| 15` would show a hand-edited
  negative value as its own segment, so it wasn't taken.
- site: llms-full.txt and the search indexes regenerated for the docs
  pages (node llms-full.mjs, node search-index.mjs).

Test: TestReasoningClassifierAnswersInTheWaitUnset - a classifier
answering in 10 units routes the turn with the timeout unset, and one
slower than 60 units gives no answer with one 499 usage row that says
magpie stopped waiting for its decision model and counts as a failure.

Broken by hand (mica-run): with askChat back on a plain WithTimeout the
test is red ("the classifier's cut call: 499 "the agent canceled the
request""); with the default back at 8 it is red ("gave no answer in
400ms").

Run at 0479372b8, this commit's tree (mica, through ~/suite.lock; mote was over its cores):
- gofmt -l: clean. go vet (darwin), GOOS=linux go vet -tags nogui,
  GOOS=windows go vet: rc 0 (darwin vet rc 0 at the first try on mote).
- go test -tags nogui -count=1 -timeout 45m ./...: rc 0, 103 ok.
  (The first run, on mote before the budget raise and the rebase onto
  adfa196db, was red on TestCoreScriptBudget alone.)
- node --test site/*.test.mjs: 132 of 132.
- GUI (node --test, Chromium and WebKit, five languages, 1100 and 420):
  classify-timeout-setting, settings-places, i18n-en-no-cjk green;
  i18n-keys red only on "a plugin's words are its own" over
  claude_image_budget_test.go's ", with an image", already #6877 from
  2896e82cc, untouched here.

Not tried: the real reporter's group in the GUI with these models after
the change (the timings above were measured through the live gateway
before it); the whole GUI suite (only a fallback value changed in app.js).
2026-11-17 13:31:08 +08:00
yetone adfa196db0 lessons: a docs page change regenerates the site's indexes (seen a fifth time)
00b2c11a6 added a docs row and left llms-full.txt and the search
indexes stale, the fifth time since 11-13 (459d668b3, 256910f17,
9dcec6751, dbbb2f26b). The rule moves into the code standards'
criterion 3. Docs only; nothing run.
2026-11-17 12:58:54 +08:00
yetone 255ccdd7ca omp: a Protocol row picks the API magpie's models are asked on (imty42 on X)
omp's models.yml had magpie's provider on openai-completions with no way
to change it: ompKept treated the provider's api as magpie's, so an api
typed there was written back on the next sync, and omp's row had no
protocol as Pi's has. An auto/* group whose members don't all take
Responses (provider.GroupAPI) could only be asked on Chat.

- omp's row gets the Protocol row Pi has (protocolField, now shared with
  Pi's piProtocolField): each model's own (unpicked, as before),
  openai-completions, openai-responses or anthropic-messages. omp takes
  each for the provider and a model (KnownApi in pi-catalog types.ts and
  the api enum of models-config-schema-bundle.ts, omp 18.9.1). The pick
  is kept per place and agent folder, so each profile has its own.
  `magpie omp protocol openai-responses` sets it from the CLI.
- ompOn puts the provider and every chat model on the pick: Chat and
  Responses with no api of their own and thinking mode effort; Messages
  at the gateway's root with budget, or anthropic-adaptive for a Claude
  that thinks only adaptively. Image models stay on openai-images.
- The provider's api typed into models.yml by hand now stays and shows
  as picked (ompAPIKept, the same api:<path>:wanted record as Pi's); a
  pick made after it replaces it.

Unchanged: unpicked, Responses-native models and groups whose members
all take Responses already went on openai-responses per model.

Run at this head (3d0cadfce, the same tree; only this message differs),
on mote:
- gofmt -l internal/agent: nothing. go vet ./..., GOOS=linux go vet
  -tags nogui ./..., GOOS=windows go vet ./...: rc 0. go build, linux
  nogui and windows builds: rc 0.
- go test -tags nogui -count=1 -timeout 45m ./... in a sandbox HOME
  under suite.lock: rc 0, 103 packages ok, no FAIL.
- Broken by hand: without ompAPIKept, TestOmpProtocolPicked is red
  ("an api typed by hand: file openai-completions, field \"\"").
- Real omp 18.9.1 in a sandbox HOME against a stand-in server: with the
  provider on openai-responses a group model posted to /v1/responses;
  a model on anthropic-messages at the root posted to /v1/messages.

Not tried: the GUI suite (no GUI file changed; the Protocol row is the
generic one Pi's uses, shown for any agent with a protocol field), and
omp against the real gateway with a real auto group.
Not changed: a model's api typed by hand in omp's models.yml is still
magpie's (the model list is magpie's whole); site docs for omp.
2026-11-17 12:46:56 +08:00
yetone 90d7ea9331 agent: a new agent named nowhere in the Library fails internal/agent's tests
TestEveryAgentInLibrary (internal/library) went red on main for a new
agent four times: 399010bef and 68cb92e8e (11-10), 7e8214d60 (11-12),
and effdd1beb today after 00b2c11a6 (Open Code Review). A change that
adds an agent runs internal/agent, and the guard is in another package,
so each was found after the push.

TestEveryAgentNamedForTheLibrary reads internal/library's targets.go and
every_agent_test.go (library imports agent, so it reads the files) and
fails when an agent on this machine's list is in neither a targetOf case
nor noLibrary. The library test still checks a target has something in
it. Same shape as internal/gui's TestEveryRouteIsNamedForTheCLI.

LESSONS.md: the route/setting guard lesson now covers agents, seen a
third day. code-standards criterion 3 names both twins.

Run (mote, at effdd1beb + this change):
- go test -count=1 -timeout 45m ./internal/agent ./internal/library: ok
- broken by hand (open-code-review's noLibrary line removed): red,
  "open-code-review (Open Code Review) isn't named in internal/library";
  restored
- win-run and wsl-run, -run TestEveryAgentNamedForTheLibrary: ok
- gofmt -l: clean
Not run: the full ./... suite (test-only change in one package).
2026-11-17 11:47:18 +08:00
yetone 2f25728ddf claude: Use switches Claude Code itself to a setup-token account (liukaybee on X)
liukaybee adds Claude accounts with `claude setup-token` and wants magpie
to switch only which one Claude Code itself uses, without connecting it
to magpie. Such an account has no sign-in to put in Claude Code's
keychain or .credentials.json, so Use was refused ("magpie only").

Claude Code takes CLAUDE_CODE_OAUTH_TOKEN from the env of its user
settings.json ahead of its stored sign-in. Use on a setup-token account
now writes the token there (claude_token_env.go). Claude Code's stored
sign-in stays as it is and stays Active; the token account is listed
with Uses. A switch to a signed-in account, Use on the signed-in row,
or removing the token's account takes the token out again.

- A value the user set is theirs: magpie keeps only the sha256 of what
  it wrote (claude-token-env.json), never writes over another value and
  never removes one whose hash differs, even if it once wrote it.
- An unreadable settings.json is "unknown": nothing is written, the
  record is kept, and the switch fails without moving the sign-in.
- NextLogin (Switch accounts only) leaves Claude Code on a token in use,
  as its allowance can't be read.
- magpie's own runs pass --setting-sources "" and are unaffected.
- GUI: the token row's Use and In use; the signed-in row says Signed in
  with a Use back. Every new string in zh, zh-TW, ja and de.
- app.js +864 bytes over its budget, raised with the reason in
  core_budget_test.go: one swUse helper shared by both buttons, packed;
  renderAccounts draws every account row, so no page to move it to.

Real use: real Claude Code 2.1.316 in a sandbox HOME/CLAUDE_CONFIG_DIR
(never the live ~/.claude) with a deliberately broken .credentials.json
access token. The settings.json magpie's switch writes (dumped from a
test) gave a PONG with a real account's token; the file after switching
back gave "401 OAuth access token is invalid", i.e. Claude Code was on
its stored sign-in again. Sandbox homes holding real tokens deleted.

Run (mote/mica, at f00e2059d rebased on 593517bf0, then this head):
- Rebased on effdd1beb (internal/gui and internal/provider untouched
  since, but for this): TestCoreScriptBudget and the provider TestClaude*,
  NextLogin and Forget tests rerun at the pushed head, ok.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./...: ok. gofmt -l: clean.
- go test ./... -timeout 45m on mote: 102 packages ok, internal/gui
  FAIL: TestCoreScriptBudget (fixed above, then green) and
  TestQuitKeepsTheMenuBarIconsPlace, killed at its 30s AppKit bar under
  load; passes alone in 1.1s here and on origin/main 00b2c11a6. Filed
  #6919.
- GUI, both engines, every language, on mica: the 45 account, Claude,
  switch, sign-in and i18n files (1275 tests, 68 red). The same 9 red
  files on origin/main effdd1beb give 67 of the same reds (#5925, #6660,
  #6179, #6424, #6010, #5998, #5814, #6877). The one red only at this
  head, accounts-own-signin webkit zh (access-control on /api/autobackup)
  is #6038 and passes 20/20 alone. claude-setup-token: green in all 10
  engine x language runs.

Broken by hand, each red, then restored: the own-value check
(TestClaudeOwnEnvTokenLeftAlone), clearing on an OAuth switch
(TestClaudeCodeSwitchedToSetupToken, ...UnreadableSettings), clearing
on Use back (Switched, InUseNotMovedOff), clearing on remove
(TestClaudeSetupTokenRemovedLeavesSettings), the NextLogin guard
(InUseNotMovedOff), unreadable settings read as empty
(TestClaudeEnvTokenUnreadableSettings).

Not tried: the whole GUI suite (both machines were running other
sessions' full suites for hours); a magpie GUI build clicking Use
against the real binary (the switch's file was checked instead);
Windows and Linux Claude Code.
2026-11-17 11:42:27 +08:00
yetone 00b2c11a6b agent: Open Code Review (ocr) is an agent magpie sets up (@AlanWang1027713 on X)
Open Code Review (github.com/alibaba/open-code-review, npm
@alibaba-group/open-code-review) is a Go CLI, `ocr`, that reviews a diff
with a model. Its Claude Code, Codex, Cursor, Kimi Code and OpenCode
plugins and its skills all run that command, which reads
~/.opencodereview/config.json on every run.

Picking one of magpie's models on its row writes a custom provider
"magpie" there (protocol openai, the gateway's /v1, a key naming Open
Code Review, the model) and points provider at it. The user's own
provider and model are stashed and come back on Disconnect, which also
drops a custom_providers left empty. A model of the user's own can be
picked too (written the way `ocr config model` writes it). Check reports
a hand-edited url or key, or a removed entry. The `ocr` command counts
only under a folder named for Open Code Review, since other programs
share the name. WSL distros get the row too (cold distros not opened).
Its User-Agent, open-code-review/<version>, already counts as this agent.
CLI update via npm. Docs, READMEs, site and icon (OCR's own logo,
Apache-2.0).

Run (mica, at 593517bf0; origin/main has one unrelated usage commit since):
- go test ./internal/agent -run 'TestOCR|WSL|Wsl|TestOwnProviderNamedAsMagpies|TestHandWiredMagpieProviderSiblings|TestAgentOf|TestEveryAgentNamedByItsKey|TestMarkedLinesEveryAgent': ok
- gofmt -l: clean; GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: ok
- Broken by hand: url dropped from Check -> TestOCRWiring red; stash
  turned off -> red at the Disconnect restore. TestWSLColdPlaceOpensNothing
  went red before the row's options were given an asleep path.
- Real e2e in a sandbox HOME: npm-installed ocr v1.13.10 (7e5ce06c)
  darwin/arm64, magpie built from this tree, a fake OpenAI upstream that
  calls tools. `magpie agents` lists the row with the user's
  deepseek/deepseek-chat; `magpie open-code-review magpie/fake/m1` wrote
  the entry and kept the user's keys and settings; `ocr llm test`:
  connection ok, tool-call round trip verified; `ocr review` on a repo
  with a nil dereference: 2 findings "[bug · high]" through magpie
  (8 /v1/chat/completions calls, UA open-code-review/v1.13.10, model m1,
  its six review tools); `magpie usage` counts them under Open Code
  Review; `magpie open-code-review default` put deepseek/deepseek-chat
  back and removed custom_providers.
- Full suite: not run before this push (ship at once; mote was running
  another session's suite). It runs on mica right after, at this head.

Not tried: a real vendor model behind magpie; WSL and Windows/Linux
machines for real; the Claude Code / OpenCode plugin path itself (it runs
the same `ocr`); an ocr installed by the curl script outside a folder
named for it is found by ~/.opencodereview only.
2026-11-17 11:10:43 +08:00
yetone 2071195ff4 usage: a plugin window named by one of its models counts that model (Google AI Studio)
WangYeruo on X: with the Google AI Studio plugin (@dorokuma/magpie-gemini-web's
ai-studio), one model's 429 for its quota held the account from every model
until the reset, while AI Studio limits each model's day on its own and argon
still answered after hydrogen was out.

The 429 itself already rested only the model: AIStudio2API's AllCoolingError
("模型 gemini-4-hydrogen 的可用账户均在冷却…;每日限额: … model:
gemini-4-hydrogen …") names it (TestAIStudioModelDayRestsTheModel, a guard;
it passes on the old code too). What held the account was the usage read
after it: the plugin's accountUsage (lib/studio.mjs, 0.15.3) tells a cooldown
as a window named after the model's id, used 100 until it ends, with no
model or models said. magpie read it as the whole account's window, so
Allowance.Full held every model and Pooled said the account was out.

namedModelWindows (pluginLoginQuota) now scopes a plugin window that says no
models, no family and no pool, and isn't text or aside, to the model whose id
its name is, when the provider serves that id. "所有模型" (a cooldown with no
model_id) and any other name stay the whole account's, as before.

Old data: such a reading has a matches, so keepLast doesn't write it down,
as with models/notModels. A reading kept on disk before this, still within
its cooldown, can hold the account from every model after a restart until
the first read (seconds); one past its reset holds nothing.
The plugin can't be fixed upstream: its repo has issues off, and it needs no
change now.

Run (mica-run, at this commit on origin/main acc358f07):
- go test ./internal/provider -run TestPluginWindowNamedByModelCountsThatModel:
  ok; broken by hand (namedModelWindows returning q unchanged) it is red:
  "hydrogen's cooldown holds argon till 2026-11-18 08:00:00", "a 429 of
  hydrogen rests the account, not the model".
- gofmt -l: clean; GOOS=linux go vet -tags nogui ./...: ok;
  GOOS=windows go vet ./...: ok.
- go test -count=1 -timeout 45m ./...: 103 packages ok, no FAIL.
Rebased onto 593517bf0 (codex/t3code/sessions only): go test -count=1
./internal/provider ./internal/gateway at the pushed head: ok.
Not tried: a real AI Studio account through the plugin (none here). No GUI
file touched.
2026-11-17 11:00:09 +08:00
yetone ce16633367 tune: a Codex card locked by config.toml's own compact limit hands it to magpie on a click (sufeng1894 on X)
sufeng1894 asked why Codex's compaction threshold can no longer be set by
hand. The card said config.toml's model_auto_compact_token_limit wins, and
the background row said features.async_compaction's
model_async_compact_threshold_percent wins: both locked, and nothing on
the card did anything about it.

Cause. Only the old tune card (9e665491e to f20118304, 10-10 to 10-28)
wrote model_auto_compact_token_limit, stashing the user's own raw value;
the 10-28 migration puts that raw value back, which then locks the card.
So the values on the screen are the user's, or the user's restored by
that migration. A magpie-written value could have lost its stash through
stash.json races (before 270b52573), an unparsable stash (before
58651568b), tuneMigrateCodex forgetting the stash even when its file
write failed, and codexAsyncSync stashing only after every write. The
last two are fixed here: the migration forgets only after the write
succeeds, and codexAsyncSync records its stash in a defer right after
reading the old state, advancing it per successful write.

Change. A locked card shows one button, "Let magpie set it" (zh 交给
magpie 设置, zh-TW, ja, de), only when the user clicks. POST
/api/tune/takeover (TuneTakeOver):
- the file's limit moves into Long conversations by tuneMigrateCodex's
  rule (a lower Long the user has is kept), the key is deleted from
  config.toml with every other key kept, and the file value is stashed
  (tune.codex.compact_file); Undo puts Long back and writes the key back,
  unless the user changed Long since;
- a background threshold of the user's (enabled = true) is adopted as
  magpie's background share with its own Undo, which turns the share off
  and gives back the percent and enabled as they were. enabled = false
  is not taken.
Nothing removes the user's value without that click.

Run:
- internal/agent, internal/gui, internal/cli, internal/tune at the pushed
  head (rebased on ca87ae9c5) on mica: ok. TestCoreScriptBudget raised
  by 189 (the button, its post and Undo background), reason in the file.
- Full Go suite -timeout 45m on mica at the pre-rebase head (2ba62f7f7
  base): every package ok except TestCoreScriptBudget, since fixed.
- Broken by hand, red: migrate forgetting first (TestTuneCodexMigrateKeepsStash),
  asyncGiveBack disabled (TestTuneCodexTakeOverAsync), longUndo in place
  of codexLongUndo (TestTuneCodexTakeOver), and the GUI button disabled
  (context-tune, 11 red).
- context-tune, compact-one-value, codex-async-compact, i18n-keys at the
  pushed head on mica, Chromium and WebKit, every language, 360 and 1100:
  the new test passes; reds are codex-async-compact's zh/zh-TW "kept the
  share out" (4, the same at ca87ae9c5) and i18n-keys' routing plugin
  word (#6877).
- win-run TestTune|TestCodexAsync in agent and gui: ok. wsl-run vet and
  those tests with -tags nogui: ok. GOOS=windows go vet and GOOS=linux
  go vet -tags nogui: ok. gofmt -l: clean.
- make test-ui on mote, pre-rebase head, through header-centre (about a
  third; the rest still running when pushed): reds in 29 files, none a
  tune file. The first 16 (account-arrange to context-cap) were run
  alone at this head and at origin/main ca87ae9c5 on mica: the same
  reds at both (base has 4 more, in agent-own-direct), the #5475 class.
  The next 13 (ctx-session-line to header-centre) were run the same way at the pushed head: 59 red at head, 60 at ca87ae9c5, the same tests (header-centre's halfway case red in one engine at each).

Not tried: a real Codex session after the takeover; codexAsyncSync's
defer has no test with a failing write.
2026-11-17 06:39:40 +08:00
yetone 2ba62f7f76 gateway: agy's "Individual quota reached … Resets in" rests the account until then
@Airan_FS on X (11-17): an Antigravity account served through agy-cli
answered "⚠ Individual quota reached. Please upgrade your subscription to
increase your limits. Resets in …" as the model's reply, and routing never
asked the next account.

The agy-cli plugin 0.1.87 (magpie-community/plugins afe4c086, on the dist
branch) now ends such a turn with a rate_limit_error in agy's words, before
or after reply text, so the gateway fails over and rests the account as for
any plugin quota error. Here, quotaResetAfter also reads the notice's
"Resets in 1h18m40s" (Go's duration form, which resetsInWords can't read
since no word ends after its "h"), scoped to the "individual quota reached"
line, so the account rests until Google's reset instead of quotaRest's 15
minutes and isn't asked again every quarter hour. gateway-routing.md says so.

Tests from the literal notice (discuss.ai.google.dev report, the tweet):
TestAgyCLIQuotaNoticeRestsUntilItsResetAndFallsOver (group falls over to
the next member, rest "resets" ~1h18m40s, next turn skips it),
TestAgyCLIQuotaNoticeMidReplyStillRests (partial text kept, still rests),
TestAgyQuotaNoticeResetIsRead.

Run (mica, at f33278541 = this change less the doc line): go test ./...
-timeout 45m: 102 ok, no FAIL. mote: GOOS=windows go vet ./... ok,
GOOS=linux go vet -tags nogui ./... ok; gofmt -l clean.

Broken by hand: the old quotaResetAfter with these tests: the account
rests 14m59s by "quota" and resetsAfter reads 0, so all three fail.

Not tried: a real agy account with its quota used up.
2026-11-17 04:14:34 +08:00
yetone ead91a9a50 gui: a browser tab's title names this magpie: MAGPIE_NAME or Settings › Network and sharing › Advanced › Name (starballl on X)
starballl on X (tweet 2122376116220633444) runs several magpie web pages
and every tab is titled "magpie", so they can't be told apart. A magpie
now has a name, and a browser tab's title is "<name> · magpie" (plain
"magpie" with none).

- settings.Name, set in Settings › Network and sharing › Advanced › Name
  (instancename.js, imported when Settings is drawn, so nothing is added
  to app.js's core). Advanced is closed until a name is set.
- MAGPIE_NAME (Docker, magpie web) names it while the field is empty and
  is the field's placeholder. It is read, never written, so a name typed
  in Settings always wins and clearing the field goes back to it.
- One line, at most 60 characters (settings.CleanName).
- This computer's own (KeepOwn): sync and a restored backup never bring
  another magpie's name. A Settings save that leaves `name` out keeps it
  (settingsapi.Merge).
- boot.js titles a browser tab itself for the first paint, so app.js's
  core gains only the line in applyPrefs, which sets the title again from
  every settings read (TestCoreScriptBudget was 74 bytes over with a
  title function in app.js). Only a browser page (web) is retitled: the
  app's windows and tray keep "magpie".
- Docker docs (en, zh, ja) list MAGPIE_NAME; docs/reference.md and
  docs/subsystems/gui-shell.md say how it works.

Tests:
- TestInstanceName (internal/gui): the variable alone names it at boot;
  a saved name wins over it, trimmed; a save without `name` keeps it;
  KeepOwn keeps it; cleared goes back to the variable; no name, none at
  boot. Broken by hand, each red: KeepOwn without Name ("KeepOwn took
  \"other\""), Merge without the keep ("a save without the name changed
  it to \"\""), boot.js with s.Name in place of InstanceName ("named by
  the variable alone: boot <nil>"), boot.js not setting the title ("a
  browser tab's boot.js sets no title"). The app window's boot.js sets
  none.
- TestSettingsSaveKeepsWhatItDoesNotSend now sets Name: the page's other
  saves leave it out, and it is kept.
- instance-name.test.cjs: title from the first paint, the field under a
  closed Advanced, save and clear retitle the tab, Advanced open after a
  reload, 360px, the app's window keeps "magpie"; en, zh, zh-TW, ja, de,
  Chromium and WebKit, 16/16. 14 of 16 red with applyPrefs not setting
  the title.

Run, at this commit on dbbb2f26b plus 9d5d8baf2 (the site index):
- go test ./... -count=1 -timeout 45m on Linux (WSL magpie-desktop, Go
  1.26.8), at the tree before the boot.js move: 99 packages ok,
  internal/gateway included (959s); ., internal/cli and internal/gui
  don't build there without GTK headers. On mica (macOS): . and
  internal/cli ok; internal/gui/... ok at this commit, after the two
  reds that run found (the core budget, the keep test) were fixed.
- go vet and GOOS=linux -tags nogui / GOOS=windows go vet of
  internal/gui and internal/settings, earlier the whole tree on all
  three: ok. gofmt -l clean.
- site: node --test *.test.mjs, 132/132.
- GUI: the 135 files the change reaches (settings, network, LAN, i18n,
  old-webkit, core budget) on mica: 16 files had reds. Run again on this
  tree and on its base, the same tests are red on both (allow-ips
  #4357, settings-hints #6107/#6353, lan-join #6353, i18n-keys #6877,
  old-webkit #6030/#5919 and the rest of the 16) but two:
  search-mcp-library (WebKit, #4756) and gateway-pause (WebKit de 420px,
  #6684), red only beside other files: alone, 0 of 10 and 0 of 3 red on
  both trees.
2026-11-17 03:11:31 +08:00
yetone dbbb2f26b1 groups: free: takes the models a catalog marks free (#5903)
A routing group's pattern may now start with free: (provider.FreePrefix):
free:workbuddy/* is, of the models workbuddy/* matches, those whose
catalog entry says free (Entry.Free, the vendor's or plugin's own flag as
the catalog was last read). The rest after free: is a glob, a re: pattern
or an id, matched as on its own, so free:re:workbuddy/hy.* works too. It
is expanded where every pattern is (matchesIn, PatternHits) each time the
groups are read, from the catalog magpie already keeps: no request to a
vendor, and a model the next list marks free joins without a save.

Only the flag decides. A $0 price (PricedFree), a rate of 0, an account
named Free or "free" in an id never counts; the test holds a
deepseek-v4-free id with no flag, a rate-0 model and an or/y priced at $0
out. Existing patterns read as before: openrouter/*:free still means ids
ending in :free (that is why the rule is a prefix, not a :free suffix),
and a provider's AutoInclude takes no free: (isIDPattern).

GUI: the Routing editor's pattern box counts and lists a free: rule live
as it does any pattern (patternTest in plugins/routing/client.js, from
groups.models' free), refuses "free:" alone, and one hint line says the
flag is the last catalog's, not a promise of no charge, in en, zh, zh-TW,
ja and de. CLI help, docs/subsystems/providers-accounts.md and the site's
routing-groups page (en, zh, ja) say the same.

routing-levels.test.cjs: the Advanced hint line made the editor taller,
so the second group's Levels row opened under the editor's sticky foot
and the click landed on the foot (webkit en). The test already wheels to
that row for its first group; it now does for the second too.

Run:
- TestGroupFreeRule, TestFreeRuleSyntax and the existing pattern tests
  pass. Broken by hand: with groupmatch.go and autolist.go from
  origin/main both are red (no members for free:workbuddy/*, IsPattern);
  with takes() ignoring the flag, TestGroupFreeRule is red (all six
  WorkBuddy models matched).
- group-free-rule.test.cjs (new): chromium and webkit, en and zh,
  green; red with origin/main's client.js.
- go vet ./... (darwin, mica), GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean. gofmt -l: nothing.
- Full suite go test -tags nogui -timeout 45m ./... on Linux (WSL
  magpie-desktop) at 1e180c630 (this change on ac4a4cf84): 102 ok, no
  FAIL. Not run whole on macOS: mote had another session's GUI suite
  and mica's disk was full (2 GB free; a run there failed on "no space
  left on device").
- At the pushed head 6801ae683 on Linux: internal/provider, cli,
  plugin, agent, gui packages; group-free-rule, group-patterns,
  routing-levels, gui-zh-tw, gui-ja, gui-de: all ok, 21 tests pass.
- GUI: the 182 files that reach the Routing page or i18n, on Linux at
  d55680755's tree: 2805 pass, 112 fail in 21 files. The same 21 run on
  origin/main cb4ad12bd: 102 fail in 18 of them. The three red only
  here (input-look, search-keys, routing-levels) were rerun at
  concurrency 2: input-look and search-keys green, routing-levels red
  from this change and fixed above (green 2 of 2). Reds on main, filed:
  group-editor-selected #5049, i18n-keys #6877, codex-memories-settings
  #6372, inner-scroll-contain #4689, grip-inset #6293, and the rest in
  #4120's class; form-align newly filed as #6894.

Not tried: a real WorkBuddy account's catalog (the flags come from the
plugin's list, as the test's fixture has them); the GUI files on macOS.
2026-11-17 02:19:48 +08:00
yetone cb4ad12bd1 zcode: the mover's min is 0.1.68, whose every account takes requests (mathfournity on X)
mathfournity on X: several ZCode accounts in magpie, and requests went to
two of them only. The plugin (0.1.40 to 0.1.67) declared maxAccounts 2,
so keepAtOnce held every account past the first two in reserve until one
rested. magpie's own handling of a plugin's accounts was right: on a
throwaway gateway test with the real plugin under bun and four accounts
on a fake Z.ai, 0.1.67 sent 12 requests at once 6/6 to two accounts and
none to the others, and 1302, 1308, 3008 and 500 on one account each
went to the next and rested the first.

plugins 36dc4007 (zcode 0.1.68) declares no maxAccounts and holds what
zcode.z.ai's firewall refuses an address for instead: six Start Plan
requests in flight from this computer over all accounts, besides each
account's three. On the same throwaway test, 0.1.68 sent the burst
3/3/3/3 over the four accounts, failover unchanged. Raising the min
updates moved users (keepMovedCurrent). gateway-routing.md's Accounts at
once row says the plugin no longer declares two.

npm: registry.npmjs.org has 0.1.68 as latest (npm view --prefer-online
--registry https://registry.npmjs.org). The plugins publish run is red
only for middleware-system-prompt and middleware-think-tags (trusted
publisher); its log shows "+ @magpie-community/opencode-zcode-auth@0.1.68".

Run:
- go test ./... -count=1 -timeout 45m on mica at 1c59acd36 plus this
  change: every package ok (102), exit 0.
- Rebased onto 4c6c3a453 (claudetui only): go test ./internal/provider
  ./internal/claudetui ./internal/plugin on mica: ok.
- Plugin: bun test in packages/zcode (HOME=$(mktemp -d), wsl-run):
  275 pass; the new tests red against 0.1.67's code (3 fail).

Not tried: a real ZCode account.
2026-11-17 01:48:56 +08:00
yetone 1c59acd36d plugin: a fetch whose head never comes is given up on; Devin min 0.1.45 (wu_chong4136 on X)
wu_chong4136 on X: with the Devin plugin a session sometimes hung for
10 to 20 minutes with no reply, until the effort or the context was
changed. The Devin plugin returns its fetch's head only once Devin sends
the reply's first content, and the host's headRead waited for that head
with no bound, while the gateway kept the agent alive on keepalives. A
request Devin took and never answered therefore hung silently. The body
already had bodyIdleWait (30m between bytes, #4934); the head had none.

- host.go headRead: the same bodyIdleWait bounds the wait for the head.
  On it the fetch ends with "the plugin sent no reply in 30m0s; that
  fetch was given up on", Fetch settles the call, and the host writes
  "abort", so the plugin's fetch signal ends its vendor request too. The
  gateway answers the agent its retryable 502 (an SSE error event on a
  stream). This holds for every plugin fetch, not only Devin's.
- ReplyWaitForTest lets the gateway test shorten the wait.
- Devin mover min 0.1.45 (on npm, `npm view --prefer-online`): the
  plugin itself gives up after 5 minutes of quiet from Devin (no head,
  or no frame between reads) with a retryable 504. A real probe saw
  Devin's first frame at 2.5s and at most 13s between frames.
  (magpie-community/plugins e30f8ed0)
- provider-plugins.md says so.

Tests:
- TestHostHeadWaitEndsAFetchNeverAnswered: a head that never comes ends
  in "sent no reply", the host is sent "abort", and the call is
  released; TestHostHeadWaitSparesAHeadInTime: a head in time is kept.
- TestPluginHeadNeverSentEndsInAnError (gateway, through the fake
  plugin in Bun): a vendor that reads the request and never answers
  gives the agent the error on a stream and on a whole reply, and every
  vendor request the plugin made is closed afterwards (asked 30, open 0).

Run:
- mote: the three tests above, ok.
- Broken by hand (headRead without the timer case): the host test fails
  ("held its reader for ever") and the gateway test hangs to its 60s
  timeout in io.ReadAll.
- mica: gofmt -l clean; go vet for darwin, GOOS=linux and GOOS=windows
  on internal/plugin, internal/gateway, internal/provider: ok.
- mica: go test -tags nogui -timeout 45m ./... at this tree (rebased on
  ac4a4cf84): 101 packages ok; internal/gateway FAIL on
  TestImageMCPKeepsDrawingsOffTheHeap alone ("the heap grew by 31 MB"),
  which passes 3 of 3 alone at the same tree and reads the whole
  process heap; filed as #6890.

Not tried: a real Devin request that goes quiet (it can't be made to
happen on demand).
2026-11-17 00:39:50 +08:00
yetone a24a5f6af4 gui: a model test its vendor queued shows queued, not green (sufeng1894 on X)
sufeng1894 (v0.1.4248) added Qoder China and QwenWork providers (both
served by the Qoder plugin): their models were green in the provider's
Test, and every request through Routing failed with 503.

A Qoder/QwenWork plan queues a model (code 10605, e.g. "this plan's
queue: p4"). The test sends x-magpie-fallback, the plugin answers the
queue's 503 at once, and probe counts it OK with Result.Queued
(d3aecfe95). The GUI drew that as a green dot and "answered", while
routing gives way from a queued member at once (503 busy) and the last
member's wait ends in the queue's 503 (4 minutes unstreamed; a frozen
queue after 5 minutes with qoder 0.2.71, v0.1.4321). So Test said the
opposite of what Routing does.

Now a queued result is its own state: an amber dot, its title
"Queued at its vendor, not answered: <queue>", and Test models' and
Test this model's status say the same and are not "ok". Working only
still keeps a queued model, as the test's OK says (a queue clears).
renderEndpoints is not a sibling: it is drawn only when no address is
plugin://, and only plugins report queued.

core_budget_test.go: +135 for it, the reason in the comment; one
string (queuedSaid) shared by all three places.

Run (mica-run/mote-run, at origin/main 8608ce024):
- models-queued.test.cjs (chromium, webkit): 4/4 ok; with the old
  app.js 4/4 red ("a queued model's dot isn't green", and the single
  test's status timed out waiting for the queued dot).
- go test -run Budget ./internal/gui: ok.
- every models-*, model-*, provider*, i18n-* and test-* GUI file:
  2430 tests, 2323 ok, 107 red (mote). The same 107 in the same 11
  files are red at untouched origin/main 8608ce024 (146 run, 107 red),
  all filed: i18n-keys (#6877), models-works-only (#4391),
  model-chip-steady (#4388), model-copy-id (#4621), model-api-preset
  (#5838), provider-max-output and provider-many-keys (#6209),
  provider-fetch-again, provider-models-rest, provider-picks-stay and
  provider-typed (#6532). A first run on mica died of ENOSPC (its disk
  is full) and tested nothing.
- Rebased onto 07f7e0b45 (nothing under internal/gui changed since
  8608ce024): the budget test and models-queued + model-test-one
  (8/8) ran again there, ok.

Not tried: a real Qoder China or QwenWork account; the reporter's 503
body, so which queue (or another cause) their 503s carry is not
confirmed.
2026-11-16 22:03:48 +08:00
yetone 07f7e0b45d claudetui: Windows 10 gets Microsoft's ConPTY with the release, no folder to place (#5205)
a49f3745e used a conpty folder beside magpie.exe holding conpty.dll and
OpenConsole.exe, which a user had to fetch and place. Windows 10's own
ConPTY drops a paste's bracketed-paste marks and loses 1024-byte blocks,
so without that folder long messages reached Claude Code cut.

Now a Windows release carries the pair. internal/conptypair pins
Microsoft.Windows.Console.ConPTY 1.25.260930003 from nuget.org (MIT): the
package's SHA-512 as nuget.org publishes it (catalog packageHash) and
each file's SHA-256. `make conpty-pair` (go run ./build/conpty, before
release-cli and release-windows) downloads it, checks both, and writes
the pair to internal/conptypair/<arch>/ (gitignored), which -tags
conptypair embeds: about 1.2 MB per Windows binary. At run time, on a
build below 22000 with no conpty folder of the user's, the pair is
written to %LocalAppData%\magpie\conpty\<version>\<arch> (temp file and
rename), each file checked against its pin there before conpty.dll is
loaded; a file that doesn't match is written again. The order is the
user's conpty folder, then the bundled pair on Windows 10, then the
system's; any failure leaves the system's, where the whole-message check
(previous commit) catches a cut message. Windows 11 keeps its own.
1.25.260930003 is the version 3leg0ocat ran whole on Windows 10 19044;
CoreyKatzburg ran 1.25.261109001 on 19045 (under two weeks old).

Run:
- The package hash: the download's SHA-512 matches nuget.org's
  packageHash; the four files' SHA-256 are taken from it.
- Authenticode on xiaomi-gpu (Get-AuthenticodeSignature): all four files
  Valid, CN=Microsoft Corporation.
- go run ./build/conpty on mote: fetched and written; a second run keeps
  them with no download; a package with the wrong hash is refused.
  GOOS=windows go build -tags nogui,packedassets,conptypair for amd64
  and arm64: built, 1.2 MB over the build without the tag.
- win-run (Windows 11 26200) go test -tags conptypair ./internal/conptypair:
  ok; TestBundledOpens writes the pair from the embedded bytes and
  CreatePseudoConsole through its conpty.dll returns S_OK.
- go test ./internal/conptypair ./internal/claudetui on mote: ok.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... on mote: ok.
- Full suite on mote (-timeout 45m) was still running at push, per the
  ship-at-once rule; a red it shows gets fixed or filed.

Not tried: Windows 10 itself (no Windows 10 box here; xiaomi-gpu is
Windows 11, whose own ConPTY doesn't have the bug, so the build gate
sends it to the system's), and a real Claude Code turn through the
bundled pair; the user folder route that loads the same way was
confirmed on Windows 10 by CoreyKatzburg (19045) and 3leg0ocat (19044).
2026-11-16 21:51:26 +08:00
3leg0ocat efb62fe901 claudetui: a message Claude Code didn't get whole is asked again as claude -p (#5205)
The helper took a message as sent once a row of it reached the
transcript (rows > before), whatever the row held. A console that loses
part of a paste, as Windows 10's own ConPTY does (#5205), gave Claude
Code the rest, and the model answered that as the message.

Now the words the transcript records of it (a user row's text, or a
queued message's) are compared with those pasted, white space, paste
tags, image marks and format characters aside, read in place with no
copy (whole.go). The paths of images Claude Code says it took
([Image: source: <path>] meta rows) are left out and the images counted.
What Claude Code answers meanwhile is held for up to 2s. A message that
isn't whole ends the turn as Unpastable before any of its reply, so the
bridge asks it again as claude -p, as it does an image the interactive
mode didn't take.

This is 3leg0ocat's patch (github.com/3leg0ocat/magpie-lite, branch
claudetui-whole-message, b800c0cb3b), applied as written, with
TestShimCutMessageIsUnpastable added: the fake Claude Code gets a
FAKE_CUT knob that keeps only a long paste's tail past its 1024-byte
blocks, as Windows 10's conhost lost them.

Run:
- go test ./internal/claudetui ./internal/conptypair on mote (macOS):
  ok. TestShimCutMessageIsUnpastable broken by hand (send returning nil
  in place of checkWhole): red, the cut tail answered as "echo: ...".
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./... on mote: ok (with the next commit).
- win-run go test ./internal/claudetui on xiaomi-gpu (Windows 11 26200,
  whose own ConPTY keeps the marks): every test ok but
  TestShimFirstMessageWaitsForTools, red on Windows at main (#4810).
3leg0ocat's own record: Windows 10 19044, Claude Code 2.1.319, Windows'
own ConPTY at 64 KB caught 4 of 4 before any reply; with ConPTY
1.25.260930003, none caught across 8/64 KB, a leading /, two images, a
queued message and two turns.

Not tried by me: Windows 10 itself (no Windows 10 box here).
2026-11-16 21:51:26 +08:00
yetone 5ba53b2392 agent: dsh and Pi ask a Gemini 3+ on Messages adaptively, so Xhigh reaches it as xhigh (#6778)
larryhaonlp: DSH's Xhigh on agy-cli/gemini-4-hydrogen through
magpie-anthropic reached agy-cli as high, and a compat
forceAdaptiveThinking: true added by hand in dsh went on restart.

Cause, from the installed sources (dsh 0.2.1-rc.2's and Pi 1.4.0's
pi-ai, anthropic-messages.js and simple-options.js): without
compat.forceAdaptiveThinking pi-ai asks a budget through
adjustMaxTokensForThinking, whose clampReasoning turns xhigh and max into
high (16384), and agy-cli's requestedEffort reads a budget of 16384 as
high. With the switch it sends thinking adaptive plus output_config.effort
from thinkingLevelMap, which agy-cli reads first. magpie wrote the switch
only for Claude that thinks only adaptively and GLM-5.2/5.3.

- gateway.AsksAdaptively is the one rule: adaptiveOnly, AdaptiveWithEffort
  or a Gemini 3 or later (geminiGeneration, the rule geminiLevelBody
  already turns a budget into adaptive + effort by). dsh's dshKindConfig
  and Pi's piModelOn (both cases) use it. Pi now also gets the switch for
  GLM-5.2/5.3, which it lacked (same clamp).
- omp is left on AdaptiveThinking, said in omp.go: its budget isn't
  clamped (ANTHROPIC_THINKING xhigh and max are 32768, read as xhigh), and
  its anthropic-adaptive mode turns thinking off by leaving thinking out at
  the lowest effort, which a model that can stop thinking takes as on.
- The user's own values: dshKeepCompat kept a hand-set switch magpie
  doesn't write, but magpie's own switch won over the user's. magpie
  writes its switches only as true (omitempty), so a false in the file is
  the user's, and now stays.
- The restart: dsh-settings' importLegacyDocument imports
  ~/.dsh/settings.yaml into the profile dsh starts on and renames it
  .imported; magpie writes settings.yaml again with routes that had no
  hand-set compat, so each start of dsh took it out of the profile.
  dshProfilesCompat carries the profiles' hand-set compat into
  settings.yaml's routes, by the same dshKeepCompat.

Existing users: KeepDshWired's sync (30s) and Pi's sync rewrite magpie's
routes, so forceAdaptiveThinking: true lands on a Gemini 3+ there with no
action; a false the user set stays. Pi's models.json provider block is
magpie's own and is written whole, as before.

Run (mote; sandbox HOME):
- go test -tags nogui ./internal/agent -run the new tests and the dsh,
  Pi and omp compat tests (TestDshMaxReachesOutputEffortModels,
  TestDshRefreshKeepsHandSetCompat, TestDshKeepCompatNotAcrossProtocols,
  Pi.*API, Omp): ok
- gofmt -l: clean
- Shipped before the whole ./internal/agent and ./internal/gateway run and
  vet (darwin, linux, windows) finished: it was still going on mote, over
  its cores, and mica's disk was full. A red there gets its own fix or
  issue.

Broken by hand:
- the new tests at origin/main 8608ce024: TestPiAgentsAskGeminiAdaptively
  red (dsh and Pi gemini-4-hydrogen, gemini-3.8-flash; Pi GLM-5.3) and
  TestDshHandSetCompatOutlivesGeminiRuleAndRestart red
- the explicit-false keep taken out: red (hydrogen's false put back on)
- dshProfilesCompat calls taken out: red (settings.yaml lacks the false)

Not tried: a real dsh or Pi run against agy-cli's gemini-4-hydrogen
(the effort agy-cli reads is taken from its requestedEffort source);
omp with a Gemini on Messages.
2026-11-16 21:40:30 +08:00
yetoneandZhuoyuan Hao 9b376de163 gateway: a Gemini model's levels above high come from its provider too (#6871, hhh2210)
withGeminiEffort (decide.go) and geminiLevelFor (gemini_level_body.go)
let a level above high through only where models.dev's catalog lists
it (catalog.EffortsOf). A model a plugin or relay lists that models.dev
doesn't have, such as ai-studio's gemini-4-hydrogen-search with
low/medium/high/xhigh, had agy's xhigh or max sent as high, after the
candidate step had already fitted it to xhigh from p.Efforts.

withGeminiEffortFor and geminiLevelForEfforts now take the provider's
levels (p.Efforts(model)) first and fall back to the catalog's; the four
withModelEffort sites in serve and passthrough's onEffort retry, and
geminiLevelBody, pass them. A model whose levels stop at high is still
asked high. Left as they were: aiStudioThinking and withFixedEffort
(no provider in scope there). Ported from hhh2210's
hhh2210/magpie#3 (8dd4c5f6e), the doc line reapplied by hand on
today's gateway-routing.md.

Broken by hand: with the tests alone on origin/main, both new tests
are red (gemini-4-hydrogen-search sent "high" for xhigh and max on
Gemini and Chat upstreams, output_config {"effort":"high"} on an
Anthropic relay); the high-only gemini-4-carbon-search case stays high
either way.

Run on mote at b394095c7 (origin/main ccae8e821 + this): gofmt -l clean;
go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./... ok; go build, GOOS=linux and GOOS=windows builds ok; go test
-tags nogui -count=1 -timeout 45m ./... under a sandbox HOME: 101
packages ok, none failed (internal/gateway 993s).
Rebased onto 2896e82cc (one Claude image commit in internal/gateway);
at 4e9533cdb go vet ./internal/gateway ok and go test -tags nogui
./internal/gateway ok (924s).

Not tried: a live ai-studio/gemini-4-hydrogen-search request. Not
changed: #6778 (dsh writes no forceAdaptiveThinking for
agy-cli/gemini-4-hydrogen on magpie-anthropic), which is the agent
wiring's per-model compat, not this fit.

Co-authored-by: Zhuoyuan Hao <hzy2210@gmail.com>
2026-11-16 21:10:12 +08:00
yetone 34606000da gui: the tray panel's Usage tab ends in a heatmap of recent weeks (eiyuuzaki2333 on X)
Asked for "a heatmap like GitHub's / Codex's, also in the tray". The
window already has one (Usage › Requests, 53 weeks, #1369), so no second
copy goes on the Overview, which counts gateway calls only while the
heatmap counts session-file calls too. The tray panel had none.

The panel's Usage tab now ends in a card of the recent weeks, one cell a
day, Monday on top, as many weeks as the card fits (8 to 53: about 25 at
the panel's 440, 17 at 320). It goes after the chart and ranking, so
nothing above it moves. Its shades are the existing monochrome accent
ramp (.l0 to .l4) and follow the tab's own Tokens / Cost / Requests
switch, with no new read; a provider or computer picked above narrows it.
A tooltip says the day and its tokens, requests and cost. Weeks with no
call show no card. No animation.

It reads the existing cached /api/usage/heatmap, at most once a minute
and again when a pick changes; the tab's own 10 s reads don't wait for
it, and no endpoint was added. The card, its reads and tooltip live in
plugins/usage/page.js, which shares its grid (heatGridOf, taken out of
drawLedHeat as it was) and tooltip (ledHeatTip, now told the metric and
provider) with the Requests tab. app.js keeps one guarded call in
renderPanelUse: the ledger read can come back before page.js has run, so
page.js draws the tab again when it loads. Both script budgets hold it
at this base with no raise. The card
is .pu-heat, not .pu-card, so the chart's card stays the tab's one
.pu-card. The panel's light pills are its card's white, so a quiet day
there is a 7% shade of the text over the card.

Run (rebased on origin/main 2896e82cc):
- panel-heatmap.test.cjs (new), Chromium and WebKit, en zh zh-TW ja de,
  440 light and 320 dark: 12 of 12, 3 runs on mote. Red 12 of 12 with
  MAGPIE_ASSETS at origin/main's assets.
- Affected files (usage-heatmap, panel-usage, panel-usage-models,
  panel-usage-first-account, panel-currency-provider, panel-units-follow,
  number-units, usage-chart-axis, usage-head-steady, usage-phone-head,
  i18n-keys, phone-no-sideways) and TestCoreScriptBudget: green but
  phone-no-sideways de 375, the same with origin/main's assets (#5869).
- At 2896e82cc again: panel-heatmap, panel-usage, panel-usage-models,
  usage-heatmap, panel-usage-first-account green; i18n-keys red on a
  routing-plugin phrase 2896e82cc's claude_image_budget_test.go added,
  red on origin/main alone (#6877).
- Whole GUI suite on mica at 91b3af847 (concurrency 4): not finished.
  The runner exited 7 with no message twice (after ~2231 and ~2371
  tests); the third part, grip-inset on, is still running, ~10,900
  tests in. None of the red files is touched by this change. Under the
  whole-suite load (#6709, #6782), with their issues:
  agent-details-ready #6369 #6373, agent-switch-accounts #5925,
  claude-quota-onboarding #6179, bark #6543, api-key-theme #6444,
  aside-native #6212, agent-menu-label #6371, allow-ips #4959,
  account-refresh-holds #6003, account-arrange #6010, desktop-tiers
  #6475, quota-refresh-order #6180, provider-max-output and
  provider-many-keys #6209, rest-try-now and key-switch #6232,
  provider-fetch-again, provider-typed, provider-picks-stay,
  provider-models-rest and menu-scroll #6532, omp-roles #6432,
  recovered-file #4320, quota-bars-alike #6700, login-export #6628,
  gateway-key-arrange #6268, first-untick #6660, editor-hints #6156,
  connect-address-kept #6755, recent-call-bodies #6665, quota-credits
  #6807, models-works-only #4391, codex-memories-settings #6372,
  panel-options-fold #6794, reset-providers #6196, quota-curve #6789,
  model-copy-id #4621, modal-backdrop #6663, loop-guard-setting #6662,
  lightweight #6340, keychain-retry #6661, key-replace #3476,
  key-balance-card #6414, gateway-pause #6684, duplicate-pause and
  key-box-once #6424, codex-async-compact #6658, name-suffix-remote
  #5147, menu-input-scroll #3402, rollup-short #6560, remote-magpie
  #6099, plugin-signin-no-url #5938, plugin-signed-out-account #5998,
  plugin-page-foreign-error #6117, plugin-option-placement #6559,
  phone-no-sideways #5869, partners #6664, panel-fold #5796, omarchy
  #4624, old-webkit #6030, model-api-preset #5838, mobile-web #6790,
  library-open-again #6751, key-import #6416, grip-inset #6293,
  fast-ultra and fast-pick #6201, ctx-session-line #5801, context-cap
  #6514, codex-auto-reset #6232, panel-usage-first-account #6181
  (green alone at this head), lan-join #6353, icon-tile #6759,
  model-chip-steady, header-centre, last-page, nav-timeout,
  plugin-card-update #6709. With no issue before, filed as #6876:
  data-folder, plugin-move-unserved, name-suffix-where-named,
  group-editor-selected, found-skill-pick-remove, quota-count-wrap,
  nav-sub-fold, model-suffix-own, account-models,
  account-models-available.
- Looked at screenshots of the panel at 440 and 320, light and dark, en
  zh de ja, with the tooltip shown.

Not tried: the real app's tray panel on macOS, Windows or Linux
webviews, real accounts' usage.
2026-11-16 20:58:35 +08:00
yetone 2896e82ccb claude: a turn with a new image after a reply split by thinking goes on in its run
Yqihotaru on X (omp 18.20.3, magpie 0.1.4314, DEBUG on): a user turn
with an image, after a reply with no tool calls, logged "no run here has
had this conversation" and was told to a new Claude Code from a
transcript (81 messages, 4 images; the turn before had 5), all of it
written to the prompt cache again. The same turn after a reply with tool
calls, and a text-only turn after it, went on in the run.

omp keeps 5 images in a request to a provider it has no image budget for
(clampProviderContextImages, providerImageBudget's default), so each new
image takes the oldest out: the conversation's earlier images moved, and
only looseTurn.rewrote's mediaMoved could match it. mediaMoved compared
the conversation part by part (heardRuns), and the run keeps its reply as
the one text it said while the client sends it back as the text blocks
Anthropic's stream told it, one between each thinking block (#5705).
#5705 made the turn keys read a reply's words without whitespace; the
part-by-part compare still read two blocks against one text, so the
first such turn found no run.

heardRuns now reads an assistant run's texts in a row as one part, their
words with no whitespace, as messageWords does. A user's texts stay
apart: the text an image left between them is what lostFromRun reads.

TestClaudeOmpImageBudgetGoesOnInItsRun sends omp's clamped history (the
budget of 5, "[image omitted: provider image limit]" in a message left
empty) eight turns, with the reply in one block and split by thinking,
and an image with words, alone, before words, and two at once. The
subsystem page says what heardRuns reads.

Run (on mote, through mote-run, at 98955300a + this change):
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway: ok (930s)
- GOOS=linux go vet ./internal/gateway, GOOS=windows go vet
  ./internal/gateway: clean; gofmt -l: clean
- rebased onto ccae8e821, which changes internal/agent only

Broken by hand: at 98955300a without the heardRuns change the new test
is red in all four "split by its thinking" cases at turn 1, the first
turn with an image, with the reporter's line, "no run waits for this
turn: no run here has had this conversation", then "a new Claude Code
is told the whole conversation: 13 messages, 5 images". The one-block
cases pass there.

Not tried: no real omp session or Claude account; the reply's block
shape is inferred (a text-only reply, thinking on) from the report, not
read from the reporter's request. The test skips on Windows (a shell
script stands in for Claude Code). No full ./... run: the change is
confined to internal/gateway.

Reported-by: Yqihotaru on X
2026-11-16 20:39:45 +08:00
yetone ccae8e8211 claude-desktop: a 1M model runs at 1M in the Code tab again (fwxkogaia on X)
Claude Desktop 5.11492 (released 11-13) starts its Code tab's Claude Code
with CLAUDE_CODE_MAX_CONTEXT_TOKENS=200000 in its --settings file whenever
the provider routes models itself, the gateway included (Fcn=2e5 and Lcn in
index.chunk-xV3fJhc7.js; 4.16336 had no such value). Flag settings come
before ~/.claude/settings.json, so the window magpie writes there no longer
reached the Code tab, and every model picked by its plain entry ran at 200K,
a 1M one too. No magpie change caused it: nothing in v0.1.4300..v0.1.4322
touched what Desktop is told about 1M.

Claude Code takes a "[1m]" id for 1M whatever that variable says (pT in
2.1.322). magpie's profile now gets Desktop's own "Use 1M wherever it's
available" (modelPrefer1mContext: true, 3p only, Desktop 1.28929+) once, on
a switch on and from Sync, as toolSearchEnabled is (desktopSeedPrefer1M):
Desktop then shows a model it offers a 1M entry for by that entry alone
(D5n: prefer1m on every supports1m entry) and hands Claude Code its [1m] id.
Desktop offers that entry only for a row whose max_input_tokens is 1M or
more, so nothing smaller changes. The user's own value, false too, or their
taking it away, stays theirs. Compaction is as before: the working window,
or the whole window under Full window.

Not fixable this way: a model between 200K and 1M (a 272K or 400K GPT)
still runs at Desktop's 200K; only a managed policy setting comes before
flag settings, and magpie writes none.

Run (mote, at this tree):
- go test ./internal/agent -run TestClaudeDesktop: ok
- TestClaudeDesktopPrefers1M red with desktopSeedPrefer1M returning nil
  ("switch on: modelPrefer1mContext <nil>"), green with it
- go vet ./internal/agent for darwin, linux, windows: ok; gofmt -l: clean
- go test -timeout 45m ./... at base 98955300a plus this diff: exit 0,
  101 packages ok, no FAIL (log kept whole)
Read, not run: Desktop 5.11492.5's app.asar (downloads.claude.ai zip) and
Claude Code 2.1.322's strings, for the 200K and the [1m] rule.
Not tried: a real Desktop 5.11492 on magpie in a sandbox; the Code tab's
/context with the new profile.
2026-11-16 20:25:25 +08:00
yetone 98955300a7 claude: no request-sized value on a run's command line or in its environment (#6848)
recih (on X) ran a long Claude Code session through the Claude
subscription's interactive mode on a Linux server: every start, the
resume and the replay alike, failed "fork/exec <magpie>: argument list
too long", 8 502s, and every request after. Linux starts nothing with one
argument or variable over 128KiB (MAX_ARG_STRLEN), and startRun put the
conversation's safeguards in CLAUDE_CODE_EXTRA_BODY whole and the JSON
schema in --json-schema whole.

Now no value of a request's goes on the command line or in the
environment over claudetui.StartValueMax (16KiB, under Windows' 32K
variable too):
- interactive mode: CLAUDE_CODE_EXTRA_BODY is a stand-in
  (startSafeguards: all when they fit, else without the parts Claude
  Code itself sheds, else []); guard.json keeps them whole and tap.js
  puts them in each request, as before. tap.js no longer sets the
  variable to a file over the bound, since Claude Code's MCP servers
  and tools inherit it. It is given no --json-schema (it never used it;
  the answer tool has the schema).
- -p: a schema over the bound goes with the initialize request
  (jsonSchema, as the Agent SDK sends it). Claude Code passes over an
  initialize schema it can't use silently, so such a schema is compiled
  first and refused with a 400, as the flag's exit was (#3036).
Other per-request starts checked (warmups, usage, sign-ins, other
agents' bridges): nothing request-sized on argv or env.

Run:
- TestClaudeTUIStartBounded, TestClaudePrintStartBounded,
  TestClaudePrintSchemaPlaces (gateway) and
  TestTapPutsSafeguardsTooLargeForTheEnvironment (claudetui, bun and
  node): red on the old code on mote (152KB env, 277KB arg, 502 for a
  bad large schema, 204KB variable left by tap.js), and on Linux
  (wsl-run, magpie-desktop) the old code failed with the real
  "fork/exec .../magpie: argument list too long" and the tap's child
  start with E2BIG. All green on the new code on mote and Linux.
- Real claude 2.1.316: an initialize jsonSchema answered
  structured_output {"city":"Paris"} (haiku); CLAUDE_CODE_EXTRA_BODY
  {"safeguards":[]} is sent as "safeguards":[] in every request (local
  listener, sandbox config).
- gofmt; go vet (darwin, GOOS=linux, GOOS=windows) on the two packages;
  go test -tags nogui ./internal/claudetui ./internal/gateway on mote:
  ok claudetui 182.5s, ok gateway 1066.8s (at base e25210b6e). Rebased
  on aa3307585: the four new tests plus the guard, safeguards and
  schema tests of both packages again, ok.
- Full suite (go test -tags nogui -timeout 45m ./... on mote): not
  finished at push; its result goes on #6848.

Not tried: the reporter's own session; a real interactive run with
safeguards over 16KiB end to end (the tap is tested with a FetchSession
stub); a Claude Code the helper gives no tap (a path with whitespace)
now sends the bounded stand-in instead of all the safeguards.
2026-11-16 19:18:49 +08:00
yetone 8707ea7757 gateway: Codex's prompt suggestions go on a model set for them (@0xcb198609 on X)
The Codex app's home-page prompt suggestions (thread_source
ambient_suggestions, and their safety check, ambient_suggestion_safety;
the Routing page's 提示词建议) are a background agentic turn that reads
the project and connected apps. The app asks for the model its server
config names (codex-app-model-routing's
codex_ambient_suggestions_model_slug, gpt-6-luna) with provider model
fallback on, so with magpie as Codex's provider they ran on the
provider's default model, often auto: @0xcb198609 saw 76.9k tokens in
113s on deepseek-v4-pro. Codex has no config.toml key for that model,
only an on/off switch in the app (store key ambient-suggestions-enabled,
Settings › Configuration › Homepage suggestions; read from the 26.1106
bundle).

magpie now has a setting for it, "Codex prompt suggestions" in Codex's
row on the Agents page (Settings, beside Codex composer predictions):
- Empty, the default, is Codex's own pick: nothing moves. A value the
  user set is never overridden.
- A model or group of magpie's puts both calls there: in serve as the
  codex-suggestions move (the Routing page says why), and on the ChatGPT
  backend's route before the split, carrying the asked model to serve so
  the trace and ledger keep it. codexOwnOffMagpie leaves a bare
  gpt-6-luna to magpie while the setting is on (codexSideSet).
- A target that is disabled, unserved or not allowed to the gateway key
  leaves the call as asked, with a log line (compactRefused).
- To fit app.js's script budget without raising it, the suggestions and
  auto-review pickers share codexPick with codexSidePick, and every
  Codex row's button comes from condButton. The new route is named for
  the CLI (settings_parity_test.go). agent-prefs and settings-general
  list the new row.
- The row's tooltip and the Routing page's Suggestions story say where
  Codex turns them off. magpie's old story said "Suggested prompts",
  which the current app no longer shows; corrected in all five languages
  from the app's own locale files.

Run (mote, at this head rebased on e25210b6e):
- go test -timeout 45m ./...: ok, every package (101). A first run
  at e97271f02 had cli and gui red on the CLI-parity guard and
  TestCoreScriptBudget; both fixed here, without raising the budget.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./...: clean. gofmt -l: clean.
- TestCodexSuggestionsMoved/Left/MovedOffChatGPT/ModelRefusesBareName,
  TestCodexSuggestionsSetting: ok.
- GUI: codex-suggestions (new), codex-predictions, codex-auto-review,
  routing-kind, i18n-keys: 58/58 ok before the rebase; at this head
  codex-suggestions, i18n-keys, agent-prefs, routing-kind 84/84 ok.
  Every GUI file that opens Codex's row or the Routing kind stories
  (26) ran too: red only in codex-async-compact (zh, zh-TW) and
  codex-memories-settings (chromium scroll), both red the same on
  origin/main e25210b6e and filed as #6658 and #6372.
- Rebased last onto 90d54a267 (internal/sessions and internal/usage
  only): internal/sessions, internal/usage, TestCoreScriptBudget, the
  route guards and the CodexSuggestions tests ok again there.

Broken by hand: codexSuggestionsTo returning "" and codexSideSet's new
case off: TestCodexSuggestionsMoved red (m1 sent, and a 404 "magpie
knows no model gpt-6-luna"), TestCodexSuggestionsMovedOffChatGPT red.

Not tried: a real Codex app's prompt suggestions against magpie (no
Codex.app here or on mote); the whole GUI suite (only the files that
open Codex's row, its settings or the Routing kind stories).
2026-11-16 18:59:40 +08:00
yetone e25210b6e4 providers: an Alibaba Token Plan's AccessKey says the grants it needs, in the reader's language (MetalHqa on X)
MetalHqa on X: "阿里云百炼 Token Plan 的额度查询需要的权限不明确,希望能够在里面备注出来".
Since 456b5c6c7 (#6506) the grants were named only in aliRAMHint, in
English, on the Usage card after a NotAuthorised refusal, and the editor
still said "a RAM user that may use Model Studio is enough", which is
wrong: the AliyunBailian*/AliyunModelStudio* policies don't cover the
Token Plan.

Now:
- The editor's AccessKey ID for an Alibaba Token Plan has one line under
  it (ALI_RAM): a RAM user's AccessKey needs AliyunTokenPlanReadOnlyAccess
  and AliyunBSSReadOnlyAccess, and Administrator or Subscription plan in
  Model Studio → Account Management; the main account's needs none. The
  Secret's hint loses the wrong sentence. Volcengine and Tencent keys are
  unchanged.
- A card refused with aliRAMHint says the same line in the reader's
  language (quotaError), the raw refusal still in its tooltip.
- zh, zh-TW, ja and de for both strings.
- aliRAMHint says "Subscription plan", as Alibaba's English docs do.

Checked against Alibaba's docs: Token Plan 权限与使用规范 (RAM 子账号授权:
AliyunTokenPlanReadOnlyAccess or FullAccess, AliyunBSSReadOnlyAccess or
FullAccess, 账号管理页面 → 管理员或订阅套餐权限), the personal FAQ (个人版
BSS policy is AliyunBSSReadOnlyAccess) and the English page (Account
Management, administrator or subscription plan permission). magpie reads
the personal plan's usage only, so the read-only policies are named.

Core script budget +275 (app.js and total): one string shown in two
places, less the wrong clause it replaces; the editor and quotaError draw
on every window, so there is no page to move it to.

Run on mote at e97271f02 + this change: gofmt -l clean; go vet
./internal/provider ./internal/gui, GOOS=linux and windows go vet
./internal/provider; go test ./internal/provider -run 'TestAli|Alibaba'
ok; go test -tags nogui ./internal/gui -run
'TestCoreScriptBudget|Words|I18n|Alibaba|AccessKey' ok; node --test of
the new alibaba-ram-grants (20/20, Chromium and WebKit, all five
languages, 420px) with every GUI file that draws an access key or a
card error, i18n-keys, i18n-en-no-cjk, form-align, editor-advanced-align
and quota-name-translated: 253 pass, 7 red, all under load ~70:
editor-advanced-align (#6421, a Claude editor) and qianwen-plan's 8s
sign-in wait (#6852); both green alone on this tree and on the base.
Broken by hand: alibaba-ram-grants on the base's app.js and i18n.js is
red in all 20 cases. After the rebase onto 1bfc6378c: TestCoreScriptBudget, TestAliGateway, alibaba-ram-grants (20/20), i18n-keys and volc-access-key ok on mote.
Not tried: a real RAM user's AccessKey (none here); the whole GUI suite.
2026-11-16 18:14:38 +08:00
yetone 1bfc6378c9 providers: Antigravity CLI's own Gemini API key is found and imported (shenggxhz on X)
shenggxhz set agy up on an AI Studio key: "modelProvider": "gemini" in
~/.gemini/antigravity-cli/settings.json, GEMINI_API_KEY exported in the
shell. `agy models` then listed Gemini 4 Carbon and Hydrogen. magpie's
model refresh didn't, because the agy-cli subscription runs agy on its
Google sign-in, whose models are the account's in Antigravity, and the
key was used nowhere in magpie.

The Providers page now finds that key on its own. A new import source,
"Antigravity CLI" (readAgySettings), reads agy's settings.json and offers
the key as the Google Gemini preset, which lists the key's models from
the Gemini API. With GOOGLE_GEMINI_BASE_URL set, it uses that endpoint's
Gemini API instead. The variables are taken from magpie's environment,
else from the login shell's: a key exported only in .zshrc is found when
magpie is opened from the Dock. proc.GeminiKeyVars are only read
(LoginEnv), never set in magpie's environment. agy on its sign-in offers
nothing. With no key the entry shows as not importable, and a key that
points at magpie itself is refused.

Not changed: the agy-cli plugin's own `agy models` reads the same
setting and, with no key in magpie's environment, fails and keeps the
old list silently. Filed as magpie-community/plugins#1218.

Run:
- red on the old code: with the appReaders entry removed, all four
  TestAgyGeminiKey* tests fail (no "agy" source); green with it.
- a real login shell on mica, in a sandbox HOME (key exported only in
  .zshrc, MAGPIE env without it): DiscoverSources gives status new,
  preset google, the key read.
- real agy 1.5.9 in a sandbox HOME: API-key mode lists the Gemini 4
  models from a list built into agy; without the key it exits 1 with the
  modelProvider error.
- go vet (darwin, GOOS=linux, GOOS=windows) for proc and provider, plus
  darwin internal/gui; gofmt -l clean.
- full `go test -timeout 45m ./...` on Linux (magpie-desktop): every
  package ok except internal/usage's TestRequestStateKeptAcrossACatalogFetchedAgain
  (#6572, filed, untouched here) and the root, internal/cli and
  internal/gui, which don't build there (no gtk4/webkitgtk-6.0 dev
  packages). Those three, plus provider and proc, ran on mote (darwin): ok.
  A first full run on mica died of a full disk (117G of shared Go build
  cache), so it tested nothing.
- GUI on Linux, Chromium + WebKit: icon-tile, import-collision,
  import-opencode, provider-discovery, import-row and i18n-keys pass,
  92 of 93. The one red is icon-tile's dim-color (#6759, red on main).
- appIcon became a table so the agy icon fits app.js's code budget
  without raising it (TestCoreScriptBudget ok).

Not tried: a real AI Studio key or a real Gemini request; the GUI import
sheet in a browser (the source shows through the existing discovery and
import sheets, with Antigravity's icon); Windows (LoginEnv is "" there,
so only magpie's own environment is read).
2026-11-16 17:59:26 +08:00
yetone b5688404da gateway: a body to another magpie goes as a delta against the one before (RFC 9842 dcz)
gaubeebangeel on X asked for RFC 9842 (Compression Dictionary Transport)
on the magpie-to-magpie hop: a Remote magpie provider, a LAN share, a
cloud or Docker deploy. Every agent request is its whole conversation,
and that hop carried it uncompressed each turn on Chat and Anthropic
(Responses already went as a semantic delta, remote_delta.go). Ideas
from jixoai/reply9842 (MIT, by jixoai): dcz turned round for a request,
content-defined anchors to pick the base. No code taken.

How it goes (remote_dict.go; docs/subsystems/gateway-routing.md):
- A request of 16 KB or more to a remote magpie offers its body
  (X-Magpie-Keep-Body: dcz). A magpie of this version keeps it, only from
  a magpie's request, scoped to the caller's key id and connection
  address, and answers X-Magpie-Kept-Body with the SHA-256. A magpie
  from before never answers, so it is sent every body as before.
- Next request to that route: Content-Encoding dcz (the RFC's magic,
  dictionary hash, zstd frame with checksum) against the kept body that
  shares the most content anchors, Available-Dictionary naming it and
  X-Magpie-Body-Digest the body's own SHA-256. No base sharing: zstd.
- Dictionary not held in that scope (restart, evicted, another key or
  computer), a corrupt frame, a digest that differs: 400 with
  X-Magpie-Dictionary-Miss before the key limit or any route, and this
  side sends it again whole at once; the agent sees nothing. A 415 does
  the same and the route goes uncompressed until it says it keeps
  bodies again.
- Bounds: up to 48 MB a body, 30 min, server 8 per scope / 96 MB per
  scope / 256 MB in all (LRU), client 8 per route / 128 MB in all. Memory
  only. The headers are stripped on arrival and from the relayed reply.

Measured (TestDictSavingOnALongConversation): two interleaved agent
conversations, 80 requests of real repo Go files as tool results plus a
300 KB screenshot, a moving cache_control, growing to 1.1 MB:
  as sent  44,606,511 bytes
  zstd     26,409,026 (59.2%)
  dcz         639,701 (1.43%); the last 1.1 MB request went as 1,368
  bytes; dcz encoding 179 ms over the 80 requests.

Tests: TestRemoteMagpieBodyGoesAgainstTheOneBefore (one gateway as both
computers, Anthropic protocol: turn 0 whole and offered, every turn after
dcz under a quarter of its size, the vendor gets the same messages and no
X-Magpie or encoding header), TestRemoteMagpieLostDictionaryResendsWhole
(restart: miss, resent whole, agent gets 200, next turn dcz again),
TestRemoteMagpieFromBeforeIsSentBodiesAsTheyWere, TestKeptBodyIsOnlyItsCallers
(another key, no key, another computer, a truncated or flipped frame,
another or no digest: 400 miss and the handler never reached),
TestKeptBodiesBounded. remote_delta_test's hopLog now logs bodies as the
other magpie reads them, and the raw wire bytes apart.

Run:
- go test ./internal/gateway -timeout 45m on mote on this change over e97271f02: ok (1012s).
- Broken by hand: sendDict returning nil at once ->
  TestRemoteMagpieBodyGoesAgainstTheOneBefore and ...LostDictionary...
  red; dictScope ignoring key and address -> TestKeptBodyIsOnlyItsCallers
  red ("another key: 200, reached 2"). Both restored.
- GOOS=linux and GOOS=windows go vet ./internal/gateway: ok. gofmt clean.
- Full go test ./... on mica (base 269e54de5): every red outside
  internal/gateway was "no space left on device" (mica's temp dir is
  81 GB of other runs, 583 MB free); internal/gateway's three
  remote_delta reds were the hopLog reading zstd, fixed above.

Not tried: a real pair of magpies across the internet (the tests run one
gateway as both); a full suite at this head (mica out of disk, mote
running another session's suite).
2026-11-16 17:58:15 +08:00
yetone e97271f027 agents: a client of a Remote magpie can connect new agents the remote has connected (KoiLx0 on X)
KoiLx0 runs one magpie as a client of another, through a gateway key, and
had to switch every agent on by hand on the client before it took the
remote's models. A Remote magpie's editor now has "Connect new agents to
this remote" (自动接入新 agent) under Advanced, off by default. It is kept
per computer in the stash (remote.<id>.connectAgents), not in
providers.json, so a synced or shared providers list doesn't turn it on
anywhere else. No server-side key permission.

With it on, the follow loop (FollowRemotePicks, every 5 minutes, and at
once when the switch is turned on) connects an agent installed here that
the remote has connected, on the remote's pick (connectFromRemote), and
records it as <agent>.remote.auto = on. An agent the user disconnected
here is never connected again:
- one with the Agents page's Disconnect mark, connected or not before;
- one recorded on that is no longer connected (taken out by hand in its
  file, or by any other route) is recorded off.
An agent magpie put back on quit (quit.restored) is left to RewireOnStart
and not taken for a disconnect. Connecting it by hand records on again.
The follow throttle's time is now under a mutex, since the save handler
resets it from another goroutine.

The switch shows in /api/providers as connectAgents and is saved as
connectAgents (a save that leaves it out keeps it; a provider that isn't
a Remote magpie is refused it). Advanced opens on its own while it is on.
docs/subsystems/providers-accounts.md says all of this.

app.js stays within its budget (TestCoreScriptBudget): the Remote
magpie's three ticks (MCP servers, skills and prompts, agents) and their
save are one loop, which the new switch costs less than it saves.

Run:
- mote, go test -tags nogui -count=1 -timeout 45m ./... with the first
  draft of app.js: every package ok but internal/gui, where only
  TestCoreScriptBudget failed (1087333 > 1086971). After the loop,
  rebased on origin/main 187d06724 (budget passes there alone), at this
  head: TestCoreScriptBudget, internal/gui, internal/agent and
  internal/cli ok.
- mica: TestRemoteConnectsNewAgents, TestConnectFollowsTheRemoteMagpiesPicks,
  TestProviderSaveConnectAgents ok.
- mote: go vet (darwin), GOOS=linux go vet -tags nogui, GOOS=windows go
  vet on internal/agent and internal/gui ok; gofmt -l clean.
- GUI, mica, both engines, at f261f7ba6 (before the loop and the rebase): remote-connect-agents.test.cjs (new: under
  Advanced and closed while off, sent as ticked, Advanced opens on it
  ticked, unticked sent so; en, zh, zh-TW, ja, de at 420px, no sideways
  scroll) passes, with i18n-keys, i18n-en-no-cjk and every file that
  reaches the provider editor's Advanced or a Remote magpie (64 files):
  1738 pass, 26 fail. The same files at origin/main 19794cc10: 1728 pass,
  24 fail, the same reds by name (editor-hints webkit #6156,
  account-arrange #6010, lan-join #6353, vertex-editor #4720,
  remote-magpie #5013, commented with this sha) except name-suffix-remote
  (#5147, red at base too on another language) and one count-free
  browser launch timeout; both files alone: 80 of 80 pass. At this
  head (rebased, with the loop): remote-connect-agents, library-mcp-on, provider-advanced-fold,
  i18n-keys, i18n-en-no-cjk pass; remote-magpie red as at base (#5013);
  editor-advanced-align red once in webkit, 1 of 4 alone (#6421, a
  Claude Code account's editor this change doesn't reach; it was red at
  base in the 64-file run).
- Real use on mica, sandbox HOMEs, this branch's binary: remote R
  (`magpie serve`, Claude Code on gpt-5.4-mini) and a fresh client C
  with Claude Code installed, not connected. Switch off: C's
  settings.json stayed {}. Switch on, C restarted: "agent: Claude Code
  connected as the remote magpie's", ANTHROPIC_DEFAULT_SONNET_MODEL
  office/openai/gpt-5.4-mini, recorded on. `magpie claude default`
  (disconnect) and C restarted: settings back to the user's, recorded
  off, not connected again.

Broken by hand, each red in TestRemoteConnectsNewAgents:
- connectFromRemote returning at once (the old code): "not connected on
  the remote's group/fast";
- without the on-then-unconnected record: "an agent the user
  disconnected by hand in its file was connected again";
- without the Disconnect mark check: "an agent marked disconnected,
  never recorded, was connected";
- without the quit.restored exception: "a quit-restored agent: wired
  false, recorded off".

Not tried: the switch turned on from the real app's window (the GUI test
fakes the API; the save handler is covered by TestProviderSaveConnectAgents
and real use wrote the stash key); agents other than Claude Code for real
(the code is the same ConnectHow for every agent with fields); Windows and
Linux runs.
2026-11-16 17:23:50 +08:00
yetone 187d067241 gui: a page's row in Sidebar pages is dragged by a finger too (chet030714 on X)
v0.1.4296's page order "根本拖不动" on a phone. Reproduced in Chromium
with real touch input (CDP Input.dispatchTouchEvent, 390px, hasTouch,
isMobile): the press on the grip went pointerdown, pointermove,
lostpointercapture, and the drag ended before it began. A finger (and a
pen, where the browser does so) is captured by what it pressed, here the
grip span inside the row; dragRows then takes the capture on the row,
the grip loses it, and its lostpointercapture bubbled to the row's
listener in dragListen, which cancelled the drag. A mouse has no
implicit capture, which is why the mouse test and the desktop app were
fine (mouse drags passed in Chromium and WebKit, 1100px and 390px).

dragListen now cancels only on the handle's own lostpointercapture. The
fix is in the shared listener, so every dragRows/dragCards whose handle
holds a child (the accounts' rows, a model's rows, plugin pages) gets it.
On a coarse pointer the grip is 40px wide instead of 26, a finger's
target. Alt+Up/Down is unchanged. No new motion: the rows' existing
0.16s strong ease-out shift (none under reduced motion) is what a finger
drag shows. The listener's lines were written shorter so app.js stays
under its budget (4 bytes of room left), no raise.

Run:
- nav-pages-order.test.cjs: a finger drag (CDP touch) and a pen drag
  (CDP pointerType pen) on the phone's menu, Chromium; WebKit checks the
  grip shows. 10/10 (Chromium, WebKit x en/zh/zh-TW/ja/de) on mica.
  Red on origin/main 269e54de5's app.js: "a finger dragged Masking up",
  chromium en and zh (2/2). The pen step passes on the old code too
  (Chromium's CDP pen isn't implicitly captured), so it guards nothing
  old, only the path.
- The drag GUI files (account-arrange, agent-grip, codex-model-order,
  drag-rows-shift, gateway-key-arrange, group-arrange, group-member-drag,
  group-member-row-drag, panel-arrange, plugin-page-arrange,
  provider-order, routing-rule-drag, usage-arrange, usage-drag,
  tap-lost-click, tap-inverted, tap-click, search-order, nav-pages-order)
  on mica: 196 pass / 12 fail. The 12 are account-arrange (53 !== 52,
  #6010) and gateway-key-arrange 420px (#6268); both fail the same 12 at
  origin/main 269e54de5's assets.
- go test ./internal/gui/ on mote: ok (TestCoreScriptBudget included).

Not tried: a real phone (iOS Safari, Android Chrome); WebKit touch,
which Playwright can't send; a real pen; the Wails windows.
2026-11-16 17:03:53 +08:00
yetone 91b3af8470 usage: Qoder's own calls are under Not through magpie, by the credits they cost (eating_dream on X)
Qoder's and Qoder CN's sessions were on the Sessions page and nowhere in
Usage: callSources never listed their files. They are Claude Code's
lines, and are now read for calls as Claude Code's are (ccCallAgent:
claudeCallLine, the call cache, continuations and revisions).

Qoder writes a reply on its own models ("auto" among them) with every
token count 0 unless QODER_EXPOSE_TOKEN_USAGE is set: the transcript
writer (vUl in qodercli, the same in Qoder.app's worker, qoder-agent-sdk)
zeroes them unless the model is a custom one, from qodercli 1.1.0 on. It
keeps the reply's credits. So such a call carries Credits (new on
sessions.Call, passed to the ledger's Record), counted with no tokens
and no price; "auto" names no model, so nothing is priced for it. A
model of the user's own, whose counts are written, is read and priced
as before. The GUI's direct section already shows credits (ledCredits).

Fixture: testdata/qoder-1.1.89 is lines as qodercli 1.1.89's writer
lays them out (key order, zeroed usage, credits/original_credits/
billable, a reply with no usage), read from its npm bundle; the ids are
made up. The older invented qoder fixtures got message ids of their own
(Calls counts a message id once across agents, and they shared
WorkBuddy's m1/m2).

Run (on mica, at f07e3e067's tree, rebased on 269e54de5):
- go test -count=1 -timeout 45m ./internal/sessions ./internal/usage
  ./internal/gui: ok
- GOOS=linux and GOOS=windows go vet of both packages: ok; gofmt -l clean
- red on the old code (origin/main's calls.go, call_cache.go,
  call_continuation.go, call_revisions.go, ledger.go with the new tests):
  TestQoderCalls got 0 calls, TestDirectQoderCallsByCredits Credits 0
  Credited 0

Not tried: no real Qoder transcript was captured (qodercli needs a
signed-in account here); the format comes from the bundle's writer. No
GUI change, so no GUI suite. A reply Qoder writes with no usage at all
is not counted. The tokens of Qoder's own models can't be shown: Qoder
doesn't write them.
2026-11-16 16:51:51 +08:00
yetone 269e54de5f gui: an update restart nobody clicked comes back in the tray alone (eating_dream on X)
eating_dream on X (v0.1.4303, macOS, Restart automatically on, a check
every half hour, prerelease channel): after each automatic update the
main window came back over what they were doing. A restart by itself
brought the window back when it was up (#2096), and minimised when it
was (#3495).

Now every restart nobody clicked comes back with the tray icon alone, on
every system, the window closed even when it was up. That covers
Settings' AutoRestart, `magpie update` from a terminal, a Remote
magpie's ask, and another copy replacing this binary. The restart path
is restartBySelf, which updates.autoRestart calls. It still takes no
focus and the Mac's Dock icon joins without coming to the front
(quiet_restart.go). A restart the user clicked (the pill, Settings, the
tray) opens the window as it was. No new setting.

restartInto loses its minimised parameter, and markQuietRestart writes
the seconds alone. An older version restarting into this one still asks
for its window and may write "<seconds> minimised", so the reading side
(takeQuietRestart, quietMinimised, showMinimised) stays. host.mainUp
had no caller left, so it moved into the Windows test that reads it.

Tests:
- New TestRestartBySelfComesBackToTheTray: by itself asks for no
  window, clicked asks for it.
- TestRestartBySelfComesBackQuietly now checks restartBySelf's mark and
  reads an older version's minimised mark (markOldQuietRestart, which
  the Windows minimised and quiet tests use too).

Run, at fd407bc99 + this change:
- mote-run:
  - go test ./internal/gui -count=1 -timeout 45m: ok
  - go vet ./internal/gui, GOOS=windows go vet ./internal/gui,
    GOOS=linux go vet -tags nogui ./internal/gui: clean
  - gofmt -l: clean
- Broken by hand: restartBySelf asking for the window (the old
  behaviour with it up) fails "windows asked for [true true], want
  [false true]". The old code read the window through a live Wails
  window, so the test can't run against it as it was.
- win-run go test ./internal/gui -run 'Quiet|BySelf|Minimised|RestartBy':
  ok. TestRestartMinimisedComesBackMinimised and
  TestRestartBySelfAsksNoAttention skip over ssh (session 0).
- wsl-run go test -tags nogui ./internal/gui -run 'Quiet|BySelf|Beside': ok

Not tried: a real automatic restart of the app on any system, and the
Windows desktop tests in the signed-in session. The first update into
this version is still made by the old one, which brings the window
back once.

Docs: gui-shell.md, restart by itself.
2026-11-16 16:37:40 +08:00
yetone e0f9218f91 update: Restart to update goes into the newest version out, not an older download (char1es_lu on X)
char1es_lu on X: Restart to update put in a version downloaded a while
ago, and right after the restart magpie offered an update again. Since
b05a525a3 (0.1.4051) a restart never asked the feed while a copy was
downloaded and waiting (keepsStaged). The clock's check runs every half
hour or more and magpie releases many times a day, so that copy was
often a release or more behind.

Every restart now asks the feed first (recheck, a check marked
restarting). This covers the page's Restart to update, the tray's, and
the restart AutoRestart or a click waits for. If a newer version is out
it is downloaded in place of the waiting copy, and the restart goes
into it once it is in. A restart waiting for an idle gateway takes it
too: run's waiting rule doesn't apply to the restart's own check. The
clock's check during that wait still keeps the waiting copy.

The feed is still not asked in two cases:
- The copy was downloaded by a restart's own check, or that check found
  it to be the newest (restartGot). The header's Update restarts once a
  click's download is in, and asking again there was elis_pina's loop of
  downloads that never restarted. This also stops a feed slower than
  recheck's wait from asking on every poll.
- Downloads wait for a click (NoAutoDownload). The copy clicked for is
  what goes in (sakamotokurome, iiiiiimone on X).

The update dialog's freshen still names the waiting copy (keep).

Trade-off: a click may now wait for a download (canlee886's earlier
complaint). The header's Update and the tray restart by themselves once
it is in. Settings' Version card shows the download and needs a second
click, which restarts without asking again. Making the card follow by
itself needs app.js bytes, and its budget has no room (tried: 337 over).

Tests:
- TestRestartTakesTheNewestOut replaces TestRestartTakesTheDownloadWaiting.
  With a fake feed it steps 0.1.11 waiting, 0.1.12 out, through the
  page's click, the restart once it is in (0.1.13 out, feed not asked),
  the tray (0.1.14), AutoRestart's wait (0.1.16) and the dialog.
- TestUpdateStagedGivesWayToNewer now checks that a restart's recheck
  takes 0.1.13 with downloads automatic, and keeps 0.1.11 on a click.
- The recheck lines in TestUpdateClockFetchesNewerThanWaiting asserted
  the old rule and are gone.

Run (mote-run, at 9c4e87736 + this change):
- go test ./internal/gui ./internal/update -count=1 -timeout 45m: ok, ok
- gofmt -l internal/: clean
- On the old update.go, TestRestartTakesTheNewestOut and
  TestUpdateStagedGivesWayToNewer fail: "the page's click ... Latest:0.1.11,
  1 downloads, want 0.1.12 after 2".
- Broken by hand:
  - Without restartGot set: "the restart once it is in: Latest:0.1.13,
    the feed asked 1 times".
  - With run's old waiting rule: "AutoRestart restarted into 0.1.15,
    want 0.1.16".

Docs: gui-shell.md "When an update downloads" and reference.md.
Not tried: a real release feed and real app restart; the fake feed
covers the updater only.
2026-11-16 16:37:40 +08:00
yetone 0f81c0b358 gateway: a Codex thread's system prompt says its latest collaboration mode, not the one it was compacted in (#6835, #6100)
@bubuweiying2026 on X (#6835): Codex Desktop on the Claude subscription,
interactive mode. A Codex compaction while the thread was in Plan mode
started a new Claude Code run whose append.md held the Plan block ("Plan
Mode is not changed by user intent"), since the Responses read lifts the
developer messages before the first reply into the system prompt. Every
later switch back to Default came after a reply, so it went into its
turn as a <system-reminder>, pasted text to Claude Code, and the model
refused to execute on every turn. #6100 is the same on a Chat provider:
a thread started in Plan keeps Plan in its system message.

Now every <collaboration_mode> block lifted into the system prompt says
the conversation's latest mode (latestModeInSystem in responses.go).
Codex's own words are not changed, and the switch stays in its turn too.
Every path that builds a run's instructions reads req.System, so
append.md for a new or resumed run, -p's first message and the
compaction request itself all carry the current mode. A switch changes
the system prompt once (one new run, one cache write), not every turn.

Run, at 8aaae20fa rebased on 19794cc10, on mote:
- TestCollaborationModeInTheSystemIsTheLatest (parse, Chat build) and
  TestClaudeRunTakesTheLatestCollaborationMode (interactive and -p) fail
  on the old responses.go: back_to_default's system prompt still holds
  Plan, Chat's system message holds Plan, and the run told "Please
  implement the plan." was given Plan in append.md / its first message.
  Both pass with the change; the interactive case checks the turn after
  the switch goes on in the same run.
- 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 -timeout 45m -count=1 ./...
  under a temp HOME: all ok.

Fixture: Default block from a real Codex 0.168 rollout; the Plan block
from the sentences #6835 quotes (no Plan rollout on hand).
Not tried: a real Codex Desktop thread compacted in Plan mode against a
real Claude account; a real Chat provider for #6100.
2026-11-16 16:32:42 +08:00
yetone fb711ae0fd settings: Quick check's Web search tests every search API, one line each (heyiwei5 on X)
heyiwei5 on X: "快速检测 联网搜索 是不是只检测第一个api 多个api的话 是不是不能检测?"
The Web search check ran one search (webSearch), which stops at the first
searcher that answers, so a second search API was never asked and a broken
one read as ok.

CheckPipeline's search now goes through checkSearch: it asks each searcher
a search can go to once, at the same time, by the path a search takes to
it, with no other standing in: the provider that searches (searcher, via
searchBy) unless provider search is off, and each search API on
(provider.SearchAPIs, via askSearchAPIKeys), in the order a search asks
them. The answer gains `searches` (name, ok, ms, error); the check is ok
only when every one is. Nothing set up, or the plugin off, says so as
before. pipecheck.js draws one line per searcher under the Web search row,
"Exa · 1.5 s" or "Tavily · <its error>" in red. Test and Test all are the
only things that ask, one call per searcher. No new strings. Documented
in docs/subsystems/gateway-routing.md.

Run (mica):
- TestCheckSearchAsksEveryAPI red on the old pipeline_check.go ("a broken
  API reads as ok: {"kind":"search","ok":true}"), green now.
- pipeline-check.test.cjs red on the old pipecheck.js (0/16), green now
  with i18n-keys.test.cjs, chromium + webkit, en/zh/zh-TW/ja/de, 1100px
  and 400px.
- At 56c988cb5: go test -timeout 45m ./internal/gateway ./internal/gui
  ./internal/cli ok; search-*.test.cjs and i18n-en-no-cjk both engines:
  284 pass, search-mcp-library webkit 420px "Turn on the Library" red,
  also red on a clean origin/main 9c4e87736 copy (open as #4756).
- Rebased on 9c4e87736 (this head's parent): go test -run
  'Check|Search|Pipeline|Searcher' ./internal/gateway, go test
  ./internal/gui ./internal/cli, pipeline-check + i18n-keys in chromium
  and webkit: all ok.
- gofmt -l clean; go vet darwin, GOOS=linux and GOOS=windows for
  internal/gateway.

Not tried: a real provider searcher or real search API keys (fakes only).
2026-11-16 16:24:38 +08:00
yetone 3d25679154 accounts: a setup-token pasted into the Claude import is added as one, not taken for a refresh token
liukaybee on X asked whether the token `claude setup-token` prints can be
pasted into Providers > Claude > Import accounts. It couldn't: the paste
box read every bare line as a refresh token, and a Claude one with no
email failed with "the file doesn't say which Claude account this is".

parseLoginImport now reads each bare line (and a JSON string) through
bareImport. A line that is a setup-token (sk-ant-oat..., bare, as
CLAUDE_CODE_OAUTH_TOKEN=... or export CLAUDE_CODE_OAUTH_TOKEN="...") is
checked by checkClaudeSetupToken and added by AddClaudeSetupToken, the
same path as "Add an account by setup-token...": kept in logins.json,
named by its hash, nothing asked of Anthropic. One magpie already has is
"exists", twice in one paste is "in the files twice", an sk-ant-api key
pasted there is refused as an API key. In the ChatGPT import a setup-token
is refused as Claude's and never sent to ChatGPT's token endpoint.
Refresh-token lines and JSON files in the same import work as before. No
result row carries the token; nothing here logs.

Run (mica, mica-run):
- TestImportClaudeSetupToken red on origin/main's login_import.go
  (#2..#5 failed, setup-token lines "doesn't say which Claude account"),
  green with the fix.
- go test ./internal/provider -run 'Import|SetupToken|Login': ok
- go vet ./internal/provider: ok
- go test -timeout 45m ./internal/provider ./internal/cli: ok, ok
- gofmt -l internal/provider: clean

Not tried: a real setup-token pasted in the real app (the add path it
calls is the existing one, itself not tried with a real token).
2026-11-16 15:58:58 +08:00
yetone 56c988cb5e gateway: /v1/realtime passes a Realtime API session on to its provider (Qwen Token Plan's realtime voice)
gaubeebangeel (X) set up Qwen's Token Plan in magpie and couldn't use its
realtime voice: magpie had no /v1/realtime, so the WebSocket upgrade got a
404. Token Plan does cover realtime: qwen-audio-3.0-realtime-plus at
wss://<plan host>/api-ws/v1/realtime?model=… with the plan's sk-sp- key,
OpenAI Realtime events
(platform.qianwenai.com/docs/token-plan/best-practices/realtime-voice).

GET /v1/realtime and /realtime upgrade to a WebSocket after the same Front
guards as every route (lanGuard, corsGuard, keys, the rebinding check),
plus a same-origin check on the socket's Origin. The model resolves as on
the other routes (a bare id unlisted anywhere goes to the one DashScope
provider that is on), with key, model and account holds, and each try is
dialled in turn with the account's key. A DashScope base ending
/compatible-mode/v1 dials /api-ws/v1/realtime; any other base dials
base+/realtime (OpenAI). Frames go both ways as they are; a close goes on
with its code and reason. Text frames are masked going up and restored
coming down (audio appends and deltas are not), failing closed. Each
response.done's usage is recorded as a "realtime" call (cached input as
cache read). openai-insecure-api-key / organization / project
subprotocols never go upstream. Shutdown ends open sessions with 1001.
/realtime is a client route on magpie web's port (and in the LazyCat
manifest), and a read-only key is refused it.

Run (mote, at this tree):
- TestRealtime* (fake upstream WebSocket, no network): Token Plan path,
  echo, binary, close both ways, usage 60 in / 40 cache read / 20 out,
  OpenAI-style path, subprotocol filter, masking; guards: 426, 400, 404,
  Origin evil/null/localhost subdomain 403, rebound host, remote without
  key 401, key held to another provider 403, vendor 401 passed on.
- Broken by hand, each went red: subprotocol filter removed, masking off,
  cached tokens not subtracted.
- GOOS=linux and GOOS=windows go vet ./internal/gateway: clean.
- go test -count=1 -timeout 45m ./internal/gateway ./internal/masking
  ./internal/gui: the first run found TestClientPathCoversHandler,
  TestReadOnlyKeyEveryRoute and then TestLazyCatManifestListsTheClientRoutes
  red, all fixed here and rerun green. Otherwise ok. The log has one
  recovered "close of closed channel" in continuation_test.go:781's
  doneHold fake upstream (a test fake this change doesn't touch; in both
  runs), already filed as #6505 (and its duplicate #6690).
- Rebased on origin/main 6dbd6e5b1 and rerun at the rebased head: the
  TestRealtime* tests, the three route-list guard tests, gofmt -l, and
  GOOS=linux / GOOS=windows go vet ./internal/gateway.

Not run: the full ./... suite at any head (mote at load ~22-33 of 18, mica ~66 of
12). Not tried with a real Token Plan account or a real Realtime client.
2026-11-16 15:31:53 +08:00
yetone afd2df09b9 gateway: a Copilot Gemini conversation past the model's 10 images goes on with its oldest left out (yuushabu_buyinn on X)
Copilot refuses a Gemini request whose conversation holds more images than
the model takes ("too many images: maximum allowed for model
gemini-4-carbon is 10, got 12"), and it counts every image in the
conversation, not one message's. A long chat with screenshots stopped
working for good.

Now, on that 400 from a Copilot account, the gateway learns the cap the
error states (per provider and model), replaces the oldest images outside
the latest user message with a one-line placeholder until the count fits,
and sends again once. Later turns are fitted before they are sent. A
request under the cap is never changed. If the latest user message alone
is over the cap, the refusal is passed on as it came. Other vendors are
untouched (imageCapped: Copilot accounts only).

The cap is learned from the 400, not from /models' max_prompt_images:
Copilot lists 1 for gpt-* and 5 for Claude models but took 3 images on
gpt-4.1 and 7 on claude-sonnet-5 live, so the list is enforced only for
Gemini and would strip images that are fine.

Run (suite at the pre-rebase tree 4649e2269; after rebasing on 58cf76453, internal/gateway ran again: ok, 923s; on b9c385286 the targeted gateway tests above plus Advisor: ok; and go vet ./internal/... plus linux and windows vet of gateway and provider: ok):
- Red on the old code: with the two gateway.go hooks taken out,
  TestCopilotGeminiImagesOverCap and the follow-up turn fail with 400
  "too many images"; green with them.
- go test ./internal/gateway -run 'ImageCap|CopilotGeminiImages|ByteCap|
  OverByteCap|CopilotGemini|BodyCap|Compaction': ok.
- Full suite on mote (go test ./... -timeout 45m, one suite on the box):
  101 packages ok, no FAIL (gateway 1049s, agent 447s, provider 277s).
- go vet for darwin, linux and windows: ok. gofmt -l: clean.
- Real Copilot (gh token, sandbox HOME, magpie serve -tags nogui on mote):
  gemini-4-carbon with 12 images: 200 after one refusal and a resend with
  10; the next turn with 12: 200, fitted before sending; 10 images: 200
  unchanged; claude-sonnet-5 with 12 images: 200 unchanged.

Not tried: Copilot Gemini over Responses or Anthropic routes (Copilot
serves Gemini on /chat/completions only); a GUI path (none changed).
2026-11-16 14:51:54 +08:00
yetone b9c385286b agent: the disconnect preview reads no sign-ins, so macOS never asks "Keychain Not Found"
jasonz3g on X (macOS, two Claude accounts): clicking Claude Code on the
Agents page made macOS ask "Keychain Not Found — A keychain cannot be
found to store …" (Cancel / Reset To Defaults), dozens of times.

The Agents page loads a disconnect preview each time an agent's box
shows: DisconnectPreview runs Disconnect on a copy, in a subprocess
whose HOME is a temporary folder. Claude Code's Disconnect builds the
model list (buildModels -> CatalogFor -> provider.All -> Accounts ->
rememberLogins -> liveLogin), which read the Claude sign-in with
`security find-generic-password`, and Cursor's too. On a Mac the
keychain is found through HOME, and the temporary one has none. With a
copy of real ~/.claude and ~/.config/magpie, the dry run ran security
three times under the temporary HOME, started Devin's CLI there, and
rewrote held/lapsed in the copy's logins.json.

previewEnv now sets MAGPIE_NO_ACCOUNTS=1, which every keychain read and
write, liveLogin and askClaudeStatus already honour. The dry run of
the same real copy then runs no security and no CLI, and the agent's
~/.claude files come out byte for byte the same as before (diff -r), so
the preview shows the same changes.

Run:
- TestDisconnectPreviewReadsNoSignIns (new), red on the old code
  (security find-generic-password -s Claude Code-credentials ... twice),
  green after; its second half checks the fixture does reach the
  keychain out of the dry run.
- go test ./internal/agent -count=1 -timeout 45m: ok on mica (macOS)
  and on WSL Ubuntu (magpie-desktop); GOOS=linux and GOOS=windows go
  vet ./internal/agent ok; gofmt -l clean.
- Real binary, dry run of `claude` on a copy of real ~/.claude and
  ~/.config/magpie with logging security/claude stubs: 3 security calls
  before, none after.

Not tried: the GUI dialog itself (no display over ssh); the
reporter's own accounts.
2026-11-16 14:45:15 +08:00
yetone 50f7a8e01f routing: a Smart row behind one renewing sooner says so; Smart says new conversations go there too
YsiCing on X: in Smart, every conversation went to one Codex account (pro,
74% of its week) while Business and team, both at 0%, said "已用 0% · 会话留在另一个账号" ("0% used · the conversation stays on another account").
That is what Smart is meant to do. It sends every request, new
conversations included, to the one account whose quota renews soonest, and
only Stays: Session or Strict spreads new conversations. But the row blamed
a kept conversation, and the Smart description said "one account at a time"
without saying that covers new conversations, plus "at 90%", which is wrong
for a week since d5d48f4f9.

- routing plugin client.js behindWhy: when the account in use also renews
  sooner, a row says "{n} used · one renewing sooner goes first" (and
  "renews in"/expires as before), not "kept"; "kept" is left for a row that
  would have gone first without the kept conversation. Four languages.
- The Smart description (app.js, i18n.js) now says every request, new
  conversations too, goes to the one account renewing soonest until it
  runs low. app.js is 4 bytes shorter; the budget is not raised.
- docs/reference.md: Smart is not load balancing; to spread conversations,
  set Stays to Session or pick Least used first.

Run:
- routing-behind-why.test.cjs on mote with the old client.js: 62 fail,
  40 pass (the "kept on the one renewing sooner" and "fresh" cases, both
  engines, all 5 languages). Green on the new code.
- mica-run go test -tags nogui ./internal/gui -run
  'TestCoreScriptBudget|I18n|Lang': ok. gofmt -l internal/: clean.
- GUI subset on mica at base c867a12c5: routing-*, i18n-*, account-arrange,
  account-weight, builtins, gateway-model-info, key-weight, rotate-figure
  and update-blocked (203 files). 3482 passed, 20 failed. I reran the 7
  red files at base c867a12c5 and with this change, one after the other:
  the same 17 are red at base (#6520 routing-signin, #6010 account-arrange,
  #6512 pin-away, #3799 row-swap, #3954 story-shrinks, #5647 pulse under
  load). routing-stage-routes 420px is red once in en and once in zh, on
  rows with no Smart account, a single read of the on class: #6830.

Not tried: real Codex accounts (fixtures only), and the Linux app's
WebKitGTK.
2026-11-16 14:40:53 +08:00
yetone 1aa348d145 gateway: Claude Code's /advisor works through a Claude subscription (#6804, #6813)
The Claude subscription bridge runs the real Claude Code with magpie's
tools only, so Claude Code's advisor (Anthropic's server tool
advisor_20260301) was read like a translation without one: dropped from
the request and its instructions rewritten to "The advisor tool is no
longer available". /advisor did nothing (recih on X, #6813; swordencao's
group advisor, #6804).

bridgeRequest now reads a Claude Code request whose advisor model magpie
serves (advisedInBridge: provider.Resolve takes it, groups and [1m]
included) as readAdvised does: Request.Advisor is set, the instructions
stay as Claude Code wrote them. The run is offered advisorToolDef beside
magpie's tools; mcpCall answers a call by asking the advisor model
(adviceRound, 55s), and the client is told a server_tool_use and an
advisor_tool_result as Anthropic's server tells it, max_uses_exceeded
past three a reply. Claude Desktop and an advisor magpie doesn't serve
go as before. Nothing about the request's identity changes: the run is
still the real Claude Code, and the advisor tool goes to no upstream.

adviceFor, shared with the vendor route, now cuts Claude Code's advisor
instructions from what the advisor model is asked (advisorCut). With
them, or advisorGone in their place, the advisor answered as the executor
that it had no advisor; seen in the reporter's exact #6804 run.

Not changed: Claude Code's Code Mode (read in 2.1.325) needs ANTHROPIC_BASE_URL
on api.anthropic.com, first-party auth with no auth token or helper, and
a GrowthBook flag; no gateway can serve it without faking Anthropic.

Run:
- go test ./internal/gateway -run 'Advis|ClaudeTUIAdvisor|BridgeRequest'
  ok (mote). Red on the old code: TestBridgeRequestKeepsTheAdvisor
  ("the advisor is \"\""); with advisorCut a no-op,
  TestAdvisorServedForAVendorModel and TestClaudeTUIAdvisorAnsweredHere
  ("the advisor was told of itself").
- go vet ./internal/gateway on darwin, linux, windows; go test
  ./internal/gateway -timeout 45m at 7abbfac34 (rebased on origin/main
  2026-11-16): ok, 946s (mote). At d54abb292, rebased on 58cf76453:
  vet on the three OSes and -run 'Advis|ClaudeTUI|BridgeRequest|
  Subscription|Doc|Subsystem' ok.
- Real Claude Code 2.1.316, sandbox CLAUDE_CONFIG_DIR and HOME, the
  owner's real Claude subscription, magpie serve on a sandbox port,
  #6804's settings (model group/claude-opus-max, advisorModel
  group/claude-fable-high[1m], effort max), claude -p: server_tool_use plus an
  advisor_tool_result with real advice (17x19 checked two ways), the
  answer built on it. Earlier, a natural coding task got advice mid-run
  and kept going. Tokens unchanged; the sandbox keychain item deleted.

Not tried: the interactive /advisor in the TUI client (only -p), Windows
and Linux runs of the bridge, Code Mode in a sandbox.
2026-11-16 14:35:47 +08:00
yetone b1dd96ab14 agents: a client of a Remote magpie starts its agents on the remote's models and follows them (KoiLx0 on X)
KoiLx0 runs several computers on one remote magpie and had to set every
agent's models again on each of them, and again whenever the remote
changed. Routing groups already reach a client (a group is a model of the
remote's list, TestRemoteMagpieNewGroupServedBesidePicks); the agents'
picks did not.

- The remote tells, per connected agent, each model field's catalog ref
  at GET /v1/magpie/agent-models (gateway.SharedAgentModels,
  agent.SharedModels). Guarded as the Library is: this computer, or a
  full-access key of a magpie shared on the network; a held key is
  refused (readonly_test), and another machine without a key gets 401
  (TestNetworkGatewayGuardsEveryRoute).
- An agent connected here starts on those picks where this magpie lists
  them as <remote id>/<ref> (How "remote", after "again" and "joined";
  the Agents page says "as on the remote magpie", in all five languages).
- A field taken from the remote, or found on its pick, is recorded in the
  stash and follows the remote's change every 5 minutes
  (FollowRemotePicks from library.KeepLinked). A model picked here is the
  user's: the record goes, and the field is left alone until it is on the
  remote's pick again. A pick this magpie doesn't list is skipped.
- app.js budget: no raise. The new line's 76 bytes come from same and
  alike sharing one string (CONN_WAS) and the native joined case
  returning plain instead of the same t() again.

Run at this head (rebased on c38753a7e, i18n-keys ok there; before that on b010fba05, whose budget raise left 2 bytes;
CONN_WAS's short name gives them):
- mote: go test -count=1 ./internal/agent ./internal/gui ./internal/library
  ./internal/provider: all ok.
- mica: go test ./internal/gateway (whole package, at the pre-rebase tree,
  ok 920s); at this head go build ./... and the gateway's guard, read-only
  and Library tests: ok.
- mica: GOOS=linux and GOOS=windows go vet of agent, provider, gateway,
  library: ok. gofmt -l: clean.
- mica at this head: go test ./internal/gui (budget ok), i18n-keys,
  agent-leave-magpie, agent-connect in chromium + webkit: ok.
- mica, chromium + webkit, before the last rebase: i18n-keys, i18n-en-no-cjk, agent-leave-magpie,
  agent-connect, agent-connect-no-models, agent-connected-unfolded: 0 fail.

Broken by hand: with connectRemote cut out of connect(),
TestConnectFollowsTheRemoteMagpiesPicks fails (connected on
aaa/claude-opus-5-5 (alike)); with the follow's "still the recorded value"
check made always true, it fails on the user's pick written over.

Not tried: two real computers; only a fake remote in the tests. Left for
#6824: a headless `magpie serve` client doesn't follow later changes
(the loop runs in the GUI), an empty field the remote fills later isn't
filled, and WSL / claude#name agent ids don't match across machines.
2026-11-16 14:18:47 +08:00
yetone c38753a7ee search: Settings can ask every search API at once, results merged (heyiwei5 on X)
The search APIs are asked in order: the next only when one fails or
finds nothing. Asking several together, with their pages merged and
repeats dropped, has existed since #2845 but only through
`magpie search mix`. Settings › Models › Web search now has an Advanced
fold, shown with two or more search APIs on, holding "Ask the search
APIs: In order | All at once". All at once marks every API on as mix
(POST /api/settings/search-api {"mix":[...]}, provider.MixSearchAPIs);
In order clears the marks. In order stays the default. A mix of some of
the APIs, set from the CLI, opens the fold with neither choice on and
names the APIs it asks.

Run (mote, at this tree):
- go test ./internal/gui -count=1: ok.
- TestSearchAPIsMixedFromSettings at origin/main's api.go: build fails
  (searchAPIJSON has no Mix), so it is red on the old code.
- node --test search-mix, search-count, search-api, i18n-keys:
  72/72 pass, chromium and webkit, en/zh/zh-TW/ja/de, 1100 and 560px.
- search-mix.test.cjs at origin/main's assets: 0 of 30 pass (red).
- gofmt -l: clean.
- After rebasing on b010fba05 (GUI pages): the gui Budget/I18n/mix Go
  tests and search-mix + i18n-keys GUI (34/34) pass again.

Not tried: the whole GUI suite, and a real search through mixed APIs
with real keys (the merge itself is unchanged since #2845).
2026-11-16 14:12:48 +08:00
yetone b010fba05b gui: the pages go in the reader's own order, in the sidebar and a phone's tab bar (chet030714 on X)
Settings › General › Sidebar pages, where pages are hidden, now also puts
them in order: a row is dragged by its grip (shown on hover, always on a
touch screen), or moved with Alt+↑/↓. The order is kept for this browser in
localStorage magpie.navOrder, beside magpie.navHidden. The sidebar and the
header's tabs follow it at once, and a phone's tab bar (phonetabs.js)
shows the first four with the rest under More. Providers is listed (it can
be moved, never hidden). While the order isn't the home one the sidebar's
group names (Work, Models, ...) are left out, since a reordered list breaks
the groups; Default order (shown only then) removes the key and puts the
pages and their names back. A page the kept order doesn't name (new in an
update) goes after the page it follows at home. Plugin pages keep their
place in their group. A reader who never reorders sees nothing change.

navOrder and navArrange live in the new navorder.js, imported by navHides
only once an order is kept (and by navpages.js with the menu), so what is
left in app.js is that one line: +107 on both core budgets, explained there.
old-webkit's list of on-demand scripts names navorder.js.

Built on the unpushed WIP 10b9ee22c (page-order worktree), cherry-picked
onto origin/main; the WIP test clicked the aria-disabled Providers row
without force, and its reload checks now wait for the async import.

Run:
- nav-pages-order.test.cjs (new): Chromium and WebKit, en/zh/zh-TW/ja/de,
  10/10 pass. Red on origin/main (no menu opens), 5/5 chromium.
- The whole GUI suite (make test-ui) on mote at the first, inline version
  (navArrange ran on every start; the final version runs nothing new for
  a reader with no order), stopped after 4,171 ok / 171 not ok, none in a
  nav, sidebar or phone file. Five of the red files (agent-switch-accounts,
  gateway-key-arrange, first-untick, data-folder, api-key-theme) rerun on
  mica at this tree and at origin/main c1ab9a494: 34 pass / 56 fail on both.
- At the final tree on mica: every nav*, phone*, side*, sidebar*, i18n*,
  last-page, menu-scroll*, settings-search and old-webkit file:
  377 pass / 42 fail; the reds (menu-scroll, nav-timeout,
  phone-no-sideways, side-effort, old-webkit) fail the same at origin/main
  c1ab9a494, and last-page webkit's (two requests cut off counted as page
  errors, #5972's kind) passed 3 of 3 alone; go test ./internal/gui/...: ok.
  old-webkit's two reds are #6570/#6030 (navpages.js, headerpresets.js
  missing from its list) and #5919, the same on origin/main.

Not tried: a finger drag on a real phone (the test taps the menu and
checks the grip shows; the drag is the mouse path dragRows shares), and
the real app's window (Wails); the GUI tests load the real assets.
2026-11-16 14:06:03 +08:00
yetone c1ab9a4946 gateway: an input item a Responses upstream has no type for is translated, and a compaction refused so is asked as text (cyberestro on X)
cyberestro on X: a Codex subagent on a local Qwen server's Responses API
(qwen, http://127.0.0.1:30010/v1) got "compaction: qwen (qwen, …) answered
the summary request 400 Bad Request: qwen: Unsupported input item:
agent_message". agent_message is the item Codex's MultiAgentV2 hands a
subagent its task in (author, recipient, input_text content, as #5259's
and plugins#61's requests carry it).

Two gaps, both fixed:
- The compaction's fallback for an input kind refused (inputKindRefused,
  #5181, #5259) read only "unsupported_input_item" and "unknown item
  type". inputKindWords now reads "unsupported input item" with spaces
  too, so the summary is asked again with the conversation as text, the
  agent_message as the user's turn (itemText), then compacted locally.
- The normal path relayed every subagent turn to the same server with
  the agent_message as Codex sent it, and gave the 400 back. passthrough
  now treats that refusal, on a request carrying an item other than a
  message, function call, its output or reasoning (hasOtherItem), like a
  custom tool refused (#2656): the model is marked (inputKindsRefused)
  and the turn is translated on the same API, where agent_message is the
  user's turn and a custom tool call a function call; later such turns
  go translated at once. A native compaction or sealed task still gets
  the refusal, and magpie's own summary ask (inCompaction) keeps its
  text fallback.

Run (mote, mica):
- New tests on the old code (ae0a78368), red: TestUnsupportedInputItemTranslated
  (400 "qwen: Unsupported input item: agent_message", stream and not),
  TestInputItemRefusalWordings, TestCodexCompactQwenInputItemAsksAgainAsText
  (the reporter's compaction error, word for word).
- Same tests green on the fix, with TestCodexCompact*, TestCustomTool*,
  AgentMessage, Sealed, Zed and Grok tests.
- A first version also translated the summary ask; it broke
  TestCodexCompactUnsupportedInputItem* (asked 4 times, not 2), so the
  summary ask was left to its own fallback.
- gofmt; go vet ./internal/gateway on darwin, GOOS=linux (nogui),
  GOOS=windows; go test -tags nogui -count=1 ./internal/gateway: ok (925s, this change on origin/main c867a12c5).

Not tried: a real Qwen server (the reporter's server and its exact JSON
body are unknown; the fixture uses the words magpie showed), Codex end to
end, and the full ./... suite (mote was running another session's).
2026-11-16 13:49:16 +08:00
yetone c867a12c5b claude: a client sending earlier turns' images back still goes on in its run
Yqihotaru (X) keeps a long conversation on claude-opus-5-5 through the
bridge, and their client takes the images of earlier turns out of some
requests and sends them back in others: the log's image count flips
between 2 and 4, every turn says "no run here has had this conversation",
and a new Claude Code starts from a transcript each time, so the prompt
cache is lost every turn.

lostMedia (#1382) took only images taken out, and looseTurn compared the
last turn alone with the whole history before it hashed exactly. Now
mediaMoved compares the conversation one role's run of messages at a
time, either way (images taken out, or put back where nothing or a line
of text stood). follows uses it for tool results; looseTurn keeps the
whole conversation and its settings apart, and rewrote takes a request
with the same settings whose images alone moved, in any turn. A sealed
tool result keeps the last 2KB of its words so one sent back without the
client's line is told from one changed otherwise.

Run (mica): go test ./internal/gateway (whole package, -tags nogui,
-timeout 45m) ok; go vet, GOOS=linux go vet -tags nogui, GOOS=windows go
vet of internal/gateway ok; gofmt -l clean. Rebased on origin/main f5f27070a (only a Gemini
slash-model change in gateway since); at that head the image, lost-media,
loose-turn and Gemini slash tests run again ok on mica.
Broken by hand: on the old matching (lostMedia in follows, no put-back in
mediaMoved) TestClaudeImagesComingAndGoingInEarlierTurnsGoOnInTheRun is
red at turn 2 ("2 runs") in both subtests, with the reporter's log lines,
and the sent-back cases of TestClaudeToolResultsAfterTheImagesSentBackGoOn
and TestMediaMovedIsOnlyImagesComingAndGoing are red.
Not tried: the reporter's real client or a real Claude account; the full
./... suite (gateway package only). branch() and whyNoRun still compare
exact hashes. A run that never had an image the client sends back goes on
without it, answering from the gap or line it was told before.
2026-11-16 13:20:43 +08:00
yetone 3ad5b93d41 provider: a Gemini model id with a slash keeps it in the request path (#6695)
A custom Gemini compatible provider's namespaced model id
(example/model-demo) was asked at /models/example%2Fmodel-demo, since
GeminiPath escaped the whole id. A relay that routes by literal path
segments answered 403 Invalid URL (POPOBE97 in #6695, LuoRuiyao on X).
GeminiModelPath now escapes each segment and keeps the slashes, so the
request goes to /models/example/model-demo:streamGenerateContent. An id
with an empty, . or .. segment, which a server could clean into a path
outside models/, still goes as one escaped segment. Google's own ids
(no slash) give the same bytes as before.

Siblings made to agree: Vertex AI's VertexPath, VertexWholePath, its
model test and the Claude rawPredict path (a slash id there goes to
partner chat completions, so only the pinned test changed), the
plugin Code Assist path in plugins.go and Gemini image generation in
draw.go, both of which put the id in raw before (a ? or space broke
the URL).

Run (on mote):
- red on the old code (old provider/gateway files, a shim for the new
  helper): TestGeminiModelPathKeepsSlashes FAIL
  `GeminiModelPath("example/model-demo") = "example%2Fmodel-demo"`;
  TestGeminiNamespacedModelKeepsItsSlash FAIL `status 403, asked
  [/v1beta/models/example%2Fmodel-demo:streamGenerateContent?alt=sse]`.
  Both pass with the change.
- 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 -timeout 45m ./...: all 101 packages ok.

Not tried: a real relay that routes by namespaced id, or a real call to
Google's endpoint (its paths for slash-free ids are byte-identical, held
by the test).
2026-11-16 13:17:46 +08:00
yetone 13e8002641 claude-desktop: two providers' Claude model read "Opus 5.5 · agy-cli", not the id's tail (onkashiko on X)
Claude Desktop names a row listed as magpie-<n>.anthropic.claude-opus-5-5
after its own catalog ("Opus 5.5"), whatever display_name says, so
agy-cli's and another provider's claude-opus-5-5 read alike and Desktop
5.11492 told them apart by the part of the ids that differs: "Opus 5.5
(…<n>.anthropic.claude-opu…)" (xVn/wVn in its app.asar). Only an
inferenceModels entry's labelOverride comes before the catalog's name,
and Desktop never suffixes such a label (keep in xVn).

magpie now writes the profile's inferenceModels, each row's display_name
as labelOverride, while two rows are named after one Claude model of
Desktop's catalog (desktopNamesClash), not only while a tier is picked.
The ids are unchanged. As with a tier's list, Desktop reads it at start
and its menu stays as listed until the next start; the Agents row's
Restart shows.

desktopNames' own fallback for two rows display_name still leaves alike
(one provider's models named alike) is now the model's id, "Z · D (z2)",
not the whole catalog id; two providers of one name keep the catalog id.
Claude Science takes the same names.

Run (mote, at origin/main 9dcec6751 + this):
- go test ./internal/gateway ./internal/agent ./internal/gui
  ./internal/provider -count=1 -timeout 45m: all ok.
- GOOS=linux and GOOS=windows go vet ./internal/gateway ./internal/agent: ok.
- gofmt -l: clean.
Rebased on 023a56373 (Windows install dialog only); at that head
go test ./internal/gateway ./internal/agent -run 'Desktop|Science': ok.
Broken by hand: with the list written only while a tier is picked (the old
rule), TestDesktopInferenceModelsCatalogNamesClash is red ("two Opus 5.5
rows, no list").
Not tried: a real Claude Desktop 5.11492 reading the list (the labelOverride
precedence and keep are read from its app.asar), and the reporter's setup.
2026-11-16 12:05:45 +08:00