Commit Graph
7089 Commits
Author SHA1 Message Date
yetoneandggbdpq 766d2a9f54 gateway: a Claude turn sent again while its run is busy with it goes on from a copy of its session (#5405)
A client's connection dropped mid-reply and its request was retried,
with no cancel reaching magpie (#5405, margbug01: a gateway between
the client and the server magpie retried after "unexpected EOF"). The
run the first attempt resumed was still busy with the very turn, so
resume and unshelve found nothing, and the retry started a new Claude
Code told the whole conversation in one message: only Claude Code's
own system prompt and tools read from the cache, the rest (92K to 142K
tokens in the report) written again on every retry.

retryBranch, tried in start between unshelve and retire, finds a busy
run of the account whose last heard request is this one, message for
message, and starts the retry's run from a copy of that run's session
cut before the turn (cutReply at backLine/backMsg), told only the
turn, as a branch off a side question already is. The busy run is left
alone; when both park at the same key, keepIdle lets the older go.
nil, and the conversation told whole as before, when no run matches,
the client places its own cache marks, the run was or is being taken
back, it was started for this turn (nothing before the turn to cut
at), or the session can't be cut (logged).

Changed from ggbdpq's patch: it matched with follows, which also takes
a request that goes on past the busy run's turn; the retry is matched
by the heard request's key alone. A copy cut for an older run is
discarded when a newer one is taken, a failed cut is logged as the
patch's notes say, and a run with a reply id but no line yet is cut
by the reply, as branchAt does. The test waits for the busy run to
have heard the turn instead of sleeping 200ms, and stops the held
first attempt in t.Cleanup, so a failing assert doesn't leave it
running. The doc's "goes on to step 3" now says step 4.

Run (mote, -tags nogui):
- TestClaudeTurnSentAgainWhileItsRunIsBusyBranchesOffItsSession
  (print, interactive) -count=3: ok.
- Broken by hand: claude_subscription.go back to origin/main, test
  kept: FAIL in both modes, "0 runs branched, 2 started anew, want one
  of each". Restored: ok.
- TestClaudeTurnPastABusyRunsTurnIsNotBranchedOffIt (print,
  interactive): a turn sent past the busy run's own, with a reply the
  client has, is told whole (one message, or the interactive mode's
  transcript), not branched off the busy run. -count=3 with the other
  test: ok; -race -count=5 of both: ok.
- Broken by hand: the match back to follows: FAIL in both modes, "the
  turn past the busy run's was branched off it" (nextTurn gives its run only
  "now commit it", the turn and reply before it lost). Restored: ok.
- -run TestClaude ./internal/gateway/: ok 139s.
- -race -count=5 -run of the busy-retry, fork, side-question,
  given-up, rewind, unshelve and branch tests: ok 52s.
- go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet of
  internal/gateway: clean.
- gofmt -l on both Go files: empty.

Not tried: a real Claude subscription with a real dropped
connection. The full suite runs after the push.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 10:04:01 +08:00
yetone 1493acb468 gui: Codex's memories default reads right on Codex 0.167.0 and before
Codex 0.167.0 (openai/codex#58091) moved its default memory models:
extraction from gpt-5.6-luna to gpt-6-luna, consolidation from
gpt-5.6-terra to gpt-6.1-terra. The memories square's unset text and the
Settings row's tooltip named the old pair. They now say "Codex's own
memory models", true on either version, in en, zh, zh-TW, ja and de.
The code comments (agent/codex.go, gateway/codex_memory.go,
gateway/codex_follow.go, the tests' headers) name both pairs with the
Codex version that uses them. No behaviour changes: magpie routes these
calls by kind (memgen, memory_consolidation), not by the model name.

Run on mote at the pre-rebase base 4e7661adc, both engines:
node --test codex-memories, codex-memories-settings, agent-prefs,
codex-sheet-providers, settings-general, i18n-keys, i18n-en-no-cjk:
127 of 128 ok. The one red is i18n-keys "a plugin's words are its own"
("No session ID", "View routing"), red on main before this change and
filed as #5327, #5332 and #5426. go vet of internal/agent and
internal/gateway for darwin, linux and windows, and gofmt -l: clean.
Not broken by hand: text-only change; codex-memories.test.cjs asserts
the new en and zh strings, so the old text fails it.
Not tried: a real Codex 0.167.0 writing memories through magpie.
2026-11-06 09:59:56 +08:00
yetoneandggbdpq 859b292d91 gateway: the Qoder plugin's queue answer ends a group's patience rounds (#5346)
#5346, hardy20260000: a Qoder route of 217 accounts (routing=order)
asked one request up to 656 times, 20 GB of re-uploaded bodies a day.
When magpie has another candidate, the Qoder plugin answers Qoder's
queue code 10605 at once with a 503 + Retry-After (#4049). busy() took
that for a moment's trouble, so once every member had given way the
group's patience asked all of them again, one whole round after
another, re-sending the body on every account each round. Now busy()
leaves the plugin's queue answer alone: each member is asked once, and
the last one, asked untold, has the plugin wait the queue out as Qoder's
own client does (polling its queue status, not re-sending the body),
then gets its same-one retries.

Changed from ggbdpq's patch: it matched `\bqueue|排队` in any
provider's 5xx. A relay's "Request queue is full" or "当前排队人数较多"
is the overload a pause mends, and would have lost its patience. The
match is the plugin's own words now ("queued the request", "this
plan's queue:"), and the tests use the plugin's real errorResponse
body for both its forms (isQueued, and the service out as in
testdata/qoder_queued_10605.json) instead of an invented message.

Not changed: the walk itself. With patience=off (the reporter's
setting now) a request still asks each account once until one answers,
~20x on this route; that is the routing group finding a free account,
and a per-request attempt budget is a separate decision.

Run (mote, -tags nogui, sandboxed by the package's TestMain):
- TestQueuedGroupAsksEachMemberOnce/{queued,busy}: 5 asks, 503 told.
- TestOverloadedGroupStillReplans/{overloaded,queue full,排队}: ok.
- Broken by hand: without `!queued(body)` both queued cases FAIL
  "a queued group asked 39 times, want 5 at most"; with the patch's
  broad regex, "queue full" and 排队 FAIL "asked 5 times, want more
  than 5". Restored, green.
- -run Queued|Overloaded|Plugin|Qoder|Patience|Replan|Single|Busy|
  Fallback|Nested|Affinity|Codex busy|Shared|Retry: ok.
- gofmt -l clean; go vet -tags nogui, GOOS=linux -tags nogui and
  GOOS=windows vet of internal/gateway: clean.
Not tried: a real Qoder queue on a many-account route; the full suite.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 09:59:13 +08:00
yetoneandggbdpq baf70992f6 usage: a call the vendor answered with another model is priced as the model that served it (#5340)
The ledger priced a call at the model asked for and fell back to the
model the reply named (Served) only when the asked-for one had no price
(#1498). That order is right for a relay that sells kimi-k3 as
moonshot-kimi-k3 and bills by the name it sold, but it also priced a
real substitution: claude-opus-5-5 asked, claude-opus-5 served. The
vendor bills for the model that ran. kaimo455's ledger had 836 such
rows, every one at the asked-for rate: $374.06 reported against
$493.28 at the served model's rate. gateway-key cost limits (KeySpent,
NewCoster) and budgets read the same pricer.

Pricer now prices a call the ledger marks swapped at the served model's
price. That covers a price the user set for the served model and every
other layer of BasePriceIn. A price the user set for the model asked for
still wins, 0 included (new provider.UserBasePriceIn is BasePriceIn's
user layer alone). When the served model has no price, the asked-for
one's stands. Renames, vendor aliases, serving names and region
deployments price as before, and rate windows still read each record's
own time. apiPricer, the API price behind a subscription window's whole,
follows the same rule: the served model's API price first, then the
asked-for one's.

Review changes on top of ggbdpq's patch:
- The swap is judged the way the ledger's Swapped column judges it: on
  the model id and on the name that went out (SentNameIn over the
  user's ModelWires). A model the user sends under the served one's name
  was answered as asked, so it keeps its own price. The patch judged the
  model id alone, so such a row was priced as swapped while the Requests
  page said it wasn't. The pricers' memo keys now include the effort,
  because the sent name depends on it.
- apiPricer (window holds) got the same rule. The patch left it on the
  old order.

Tests:
- TestLedgerPricesASwappedCallAsTheModelThatServed (patch, plus a
  ModelWires case) checks the ledger and the Requests page.
- TestLedgerPricesARenamedModelAsTheOneServed: the sol row (sol asked,
  kimi-k3 served, both priced) is a genuine swap, so it now prices at 3,
  not 2.
- TestHoldsPriceTheModelTheReplyNamed: claude-opus-4-7 answered by
  gpt-5.5 is priced at gpt-5.5's API price. Answered by an unpriced name,
  it keeps opus's.

Run on mote at this tree, on origin/main 4e7661adc:
- The three tests above: ok.
- Product files (ledger.go, window_holds.go, provider/models.go) put
  back to origin/main, tests kept: all three FAIL ("served luna:
  priced=true cost=10, want 33"; "sol: ... cost=2, want ... 3"; "a call
  answered by another model wasn't priced as that one: &{Input:5 ...}").
- servedInstead's sent-name check broken by hand (return true): the
  ModelWires case FAILs ("served luna: priced=true cost=33, want 10").
- go test -tags nogui -count=1 ./internal/usage/ ./internal/provider/
  ./internal/budget/ ./internal/otlp/ ./internal/middleware/: all ok
  (usage 44.9s, provider 158.3s).
- gofmt -l: clean. GOOS=linux go vet -tags nogui and GOOS=windows go vet
  of internal/usage and internal/provider: clean.

Not tried: a real ledger with Anthropic's refusal fallback. The rows in
the tests are built from the shape the reporter describes. The full
suite runs after the push.

#5340, kaimo455 (report, measurement and the proposed order)

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 09:57:18 +08:00
bfb0d92ca8 gateway: a ToolSearch answer's definition goes to DeepSeek as the reference it takes (#5404)
Newer Claude Code builds put the loaded tool's definition itself in the
ToolSearch answer's tool_result.content[] ({"type":"tool_definition",
"definition":{...}}, the same block shape Claude Code's own bundle
handles beside tool_reference). DeepSeek's Anthropic endpoint refuses
it there: 422 "messages[1].content: unknown variant `tool_definition`,
expected `tool_reference`". withoutDeferredTools walked the messages'
top-level blocks only, so the nested definition survived every learned
retry, and a body with no top-level deferred block never learned the
refusal at all.

hasDeferredTools now sees a tool_definition in a tool_result's content,
and withoutDeferredTools hoists each such definition onto the request's
tools (once; one already listed wins) and sends the block as
{"type":"tool_reference","tool_name":...}, which the endpoint takes only
once the tool is declared. A result whose content isn't an array, or a
definition without a name, goes as it came. DeepSeek's own host
(isDeepSeekAnthropic, by host, not preset) now gets the deferred blocks
stripped up front like Kimi (#2042), since it takes a tool_addition at
no position (erlinerd's live check of 2026-11-05).

Review change on top of ggbdpq's patch: added
TestDeepSeekAnthropicIsStrippedUpFront, which drives a provider at
api.deepseek.com (dial redirected to httptest) through the server; the
patch had no test for the forwardOnce wiring.

Run (mote, -tags nogui, -count=1):
- TestToolResultDefinitionRefusedOnceBecomesReference,
  TestNestedToolResultDefinitionBecomesReference,
  TestDeepSeekAnthropicRecognized, TestDeepSeekAnthropicIsStrippedUpFront:
  PASS.
- -run 'Deferred|Kimi|DeepSeek|ToolSearch|ToolReference|RefsOnly|OpenCode|Shape'
  ./internal/gateway: ok 18.3s.
- gofmt -l clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet
  of ./internal/gateway: clean.

Broken by hand:
- anthropic_shapes.go at the parent: the refused-once test 422s to the
  client, the unit test fails "a nested tool_definition was not seen as
  a deferred tool", the up-front test 422s.
- gateway.go at the parent: TestDeepSeekAnthropicIsStrippedUpFront fails
  "DeepSeek was asked 2 times, want once".

Not tried: a live api.deepseek.com request (no DeepSeek key here); the
endpoint's answers are the reporter's live checks. Not run: the whole
gateway package or ./... suite.

#5404, erlinerd.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
Co-authored-by: erlinerd <10431861+erlinerd@users.noreply.github.com>
2026-11-06 09:55:19 +08:00
yetoneandggbdpq d84f58fd2b claude bridge: Claude Desktop's own annotations are not the user's words (#5403)
Claude Desktop's Claude Code appends notes of its own after tool
results: the scaling note a wide Read gets ("[Image: original 2200x680,
displayed at 2000x618. Multiply coordinates by 1.10 …]"), the Skill
tool's "Base directory for this skill: …" and ToolSearch's "Tool
loaded.". The bridge took each for words the user sent mid-turn, so
the run was told "The user sent a new message while you were working:"
with the note, and the next turn's history marked it [user message].
The model answered messages nobody wrote (#5403, miroku9: about 30
such notes in 13 sessions, two answered).

They join agentNotice, the table #2060 built for hook notices and
token counts, so saidWithResults leaves them out and renderParts
closes the result without the [user message] mark. Wide images read
in parallel bring one note each; miroku9's inner-session queue shows
them joined by blank lines, so the image branch matches one or more
notes (with "Tool loaded.") separated by whitespace, both as one text
and as separate parts. A user's own words after a note still go on.

Patch from ggbdpq; the parallel-notes case and its test are added
here, after miroku9's follow-up on the issue.

Run (mote-run, go test -tags nogui ./internal/gateway/):
- TestDesktopAnnotations*, TestParallelImageNotesAreAgentNotices,
  TestAgentNotice*: with claude_subscription.go at origin/main all four
  new tests FAIL ("… was taken for the user's words", "[user message]"
  before the note); with the fix ok.
- With the patch's single-note regex, TestParallelImageNotes FAILs on
  the joined text only (the separate-parts case passes).
- -run 'Notice|MidTurn|SaidWith|RenderParts|UserWords|Claude': ok 74.8s.
- gofmt -l clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet
  of internal/gateway clean.
Not tried: a live Claude Desktop + inner Claude Code pairing; the note
shapes are the reporter's jsonl verbatim. userWords (routing's view of
a user text) is unchanged: these notes only follow tool results, where
routing doesn't start a turn. A new kind of note from a later Claude
Code needs its own line here.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 09:54:51 +08:00
yetoneandFlandern1211 5ca9f0f9d7 sessions: a ZCode fork's card shows its own title (#5365)
ZCode files a fork as sess_<id> with its parent's id in parent_id
(task_type=fork), and ocRoots groups it under the parent's key. A
request names the fork by its own id, but Titles only looked up
sess_subagent_agent_<id> children, so a fork's Routing card fell back
to the folder name though its row has a title of its own.

The child index in Titles now holds every ZCode session with a parent,
by its sid and its bare id (zcodeBareID), so a fork is named from its
own file the way a subagent is. A top-level session is still named by
its own group only. The parent's title is unchanged.

Changed from the patch: the index holds child sessions only (the patch
indexed every ZCode session, so a top-level session's empty group title
could be filled from the cache fallback), and the "session_" prefix the
patch also stripped is dropped, since no ZCode id has it.

Run (mote, sandbox HOME via the package's TestMain):
- go test -tags nogui -run 'TestZCode|TestSessionTitles' ./internal/sessions/: ok.
- go test -tags nogui ./internal/sessions/: ok (20.7s).
- go test -tags nogui -run TestSessionTitlesNameOtherAgents ./internal/gui/: ok.
- GOOS=linux go vet -tags nogui and GOOS=windows go vet ./internal/sessions/: ok; gofmt -l clean.
- Windows box (win-run): -run 'TestZCode|TestSessionTitles' ./internal/sessions/: ok.
Broken by hand: with origin/main's sessions.go, TestZCodeForkTitlesByRequestID
fails: fork by request id: "", want "Fork of The parent session's title".
Not tried: a real ZCode database here (none on this machine); the
reporter ran the patch against theirs on Windows and got the fork's own
title and the parent's.

#5365, Flandern1211 (report, patch, test).

Co-authored-by: Flandern1211 <163982805+Flandern1211@users.noreply.github.com>
2026-11-06 09:54:05 +08:00
yetoneandggbdpq cf15d79d7f gateway: a relay's Gemini refusing a tool's anyOf beside a description hands the request to the group's next member (#5374)
Google's Schema takes an anyOf alone: a tool whose parameters carry a
description beside an anyOf is turned away with "Unable to submit
request because `tool` functionDeclaration `parameters.response` schema
specified other fields alongside any_of. When using any_of, it must be
the only field set." Asked straight, Google points at
function_declarations[N].parameters, which shapeWords reads. A relay
(sub2api, TokenFree) passing Google's words on writes them camel-case,
the field in backticks and no path, so the 400 went back to the client
and the group's later members, a non-Gemini fallback among them, were
never asked (#5374, worksyang, with the two-channel comparison and the
one-line fix).

shapeWords now also reads "schema specified other fields alongside
any_?of" (any_of and anyOf). The next member is asked once and the relay
doesn't rest (failShape), as for every shape refusal. A plain "messages:
field required" and Google's "Invalid function name" 400 stay the
request's.

Run (mote, testenv sandbox HOME):
- TestGroupFailsOverAnAnyOfSchemaRefused with fallback.go put back to
  4e7661adc: FAIL, gemini_anyof_fallback_test.go:39 "400 ... (a 1, b 0)"
  (the relay's 400 went to the client, b never asked). With the change:
  ok.
- go test -tags nogui -run 'AnyOf|Shape|Fallback|Retryable|Group'
  ./internal/gateway/: ok 65.5s.
- gofmt -l on both files: nothing. go vet, GOOS=linux go vet -tags nogui,
  GOOS=windows go vet on ./internal/gateway/: clean.

Not tried: a real TokenFree / sub2api relay in front of Google (no such
credentials here); the wording is the reporter's gateway log. The full
suite is not run in this commit.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 09:53:30 +08:00
yetone 4e7661adce redact: an app's one-word name the model took for a person's goes as written
Reported by ylorn. on Discord (11-06): choosing apps in Alma, a question
about one app was answered with another's facts. Privacy Filter took the
apps' names (Cicada, Mimi, Phosphor, Parakeet, Muesli) for people's: in a
bare list of them, alone, and in the Markdown list of apps the assistant
answered with (probed on the real model: ~0.99 each). The follow-up
questions ("How about Mimi?", "Phosphor vs Parakeet") it did not flag, so
they went as written while the history held the names as placeholders;
Phosphor and Parakeet (8 bytes) then became known values and were masked
everywhere. The vendor could not tell which placeholder was which app.

Restore was not the cause: placeholders are a keyed hash of kind and value,
one per value, and restore maps each back to its own value in any case
(TestManyNamesRestoreEachToItself, a guard: it passes on the old code too).

personFits now lets one ASCII word go when what is around it says a thing
and nothing says a person (thingNamed, internal/redact/thingname.go): a
person's word beside it (my colleague, Hi, Mr, said, told) masks; a thing's
word beside it (using, switched to, the ... app, vs, apps like, 这个软件)
lets go; else its sentence decides (he/she/relations/greetings/said mask;
app/macOS/subscription/vs/软件 let go); else a list item among items that
speak of apps, or a text of capitalized names only, lets go.

Trade-off, by design: a single first name alone, or a first name in a
sentence that speaks of an app with nothing of a person ("Mimi uses the
app daily"), goes as written. A full name (John Smith), a Chinese name
(张伟), and a first name beside a relation, a greeting, said or a pronoun
are masked as before.

Run (mote, worktree at 84ad780b6 + this):
- go test ./internal/redact/... ./internal/pii/... ./internal/masking/...
  ./internal/otlp/... ./internal/sessions/... ./internal/settings/... ok
- go test -run 'Mask|Redact|Privacy|Person|Known' ./internal/gateway
  ./internal/gui ok
- TestMaskEval re-recorded with both real models (MAGPIE_EVAL_CACHE);
  only the 12 new cases' recordings are added, old entries kept as they
  were (mote's re-record drifted 4 AstrLink and 2 Privacy Filter entries
  by score; not taken in). New cases app-names, app-alone, app-markdown
  (real Privacy Filter flags), app-compare/vs/list/using/zh (model finds
  none; guard), app-and-person, app-and-full-name, app-and-zh-name,
  greeting (person controls).
- gofmt -l clean; GOOS=linux and GOOS=windows go vet ./internal/redact ok.

Broken by hand:
- the personFits hook off: TestAppNamesNotPersons red 9/9,
  TestPersonBesideAppStillMasked red on the 3 apps, TestMaskEval red on
  app-names (5), app-alone, app-markdown (3) with the real recordings.
- thingNamed always true: TestPersonBesideAppStillMasked red on Mimi (x2),
  Laura, Daniel.

Not tried: a real Alma chat through the gateway with the model on; Windows
and Linux runs (pure Go string code, vetted for both); the full suite runs
after the push.
2026-11-06 09:28:25 +08:00
yetone 8b70b7d976 usage: a request's bytes up and down, and what DeepSeek's image files saved, in Requests
Suggested by @faithleysath (matrix0487 on Discord): the usage ledger now
keeps what each request received back (down_bytes) beside what it sent up
(up_bytes, #4456), and what DeepSeek's image files (#5407) kept out of the
upload (image_files_saved).

Shown in Usage → Requests:
- a row's details: "Sent upstream", "Received" and "Saved by image files",
  each only when it is above 0. A row from before has none of them, not 0;
- under the Requests card, the period's "↑ up · ↓ down", with
  "{n} saved by image files" when there is a saving. Its title gives the
  exact bytes. A period with no counted bytes shows no line.

What is counted:
- Down bytes are counted as the reply body is read, after Go's transport
  has undone gzip, so a gzipped reply counts its plain size, not wire
  bytes. A plugin's row counts the local hop to the plugin host. A 101
  body is not wrapped. Every try counts, so a refused try plus the
  answering one add up (TestLedgerKeepsDownBytes).
- Image files saved, per try: the body before the swap minus the body
  sent, minus the upload bytes this request itself paid (len(b64)/4*3).
  It can be negative on the turn that uploads; the GUI shows only a
  saving above 0. Gaps: an upload that finishes after the wait timeout or
  ctx-done is not subtracted (as with up_bytes); a joined upload flight is
  paid by the request that started it; multipart overhead is approximate.
- packedRow grows by three int32 (152 bytes, still within the test's
  bound), clamped to the int32 range. Totals sum all three.
- settledCountVersion goes 1 → 2, because Totals now count bytes. The
  settled page, heat and effort caches recount once, on the first start
  after the update. The heat key hash includes the new fields.

Run on mote at 84ad780b6 (origin/main, fetched):
- go test ./internal/usage: ok.
- go test ./internal/gateway -run 'TestLedgerKeepsDownBytes|TestDeepSeek|
  TestCodexOwnTurnKeepsUpBytes|TestLedgerKeepsUpBytes|
  TestLedgerCountsATrysSecondAsk': ok.
- go test ./internal/gui: only TestMainWindowCorners/macOS_26_SDK fails,
  as on main (#3949).
- gofmt -l clean; go vet of usage and gateway for darwin, linux (nogui)
  and windows; go build ./...
- New GUI test usage-ledger-bytes.test.cjs: 30 of 30 in Chromium and
  WebKit, en/zh/zh-TW/ja/de, at 1180 and 420 wide. It is red on the old
  page.js.
- usage-*, ledger-*, i18n-* and nav-timeout GUI files: 1231 of 1267.
  Every red is red on a clean 84ad780b6 too: usage-agents-hide (#3414),
  usage-fold (#3415), usage-ledger's "newest live route" (#5048),
  usage-overview-fold, which flakes in other languages on each run
  (#3947), i18n-keys (#5332, and #5426 filed now for "No session ID"),
  and nav-timeout (#5425, filed now).

Broken by hand:
- gotDown not wrapping the body: red, "down 0; the vendors answered
  141/265 bytes" and "the backend answered 105 bytes".
- the saved += removed: red, "saved 0".
- the settled guard red with the bytes fixture until the version raise.

Not tried: a real DeepSeek or other vendor account through a built app,
and a screenshot of the real app. The CSV export does not have the new
columns yet.
2026-11-06 09:17:10 +08:00
yetone 84ad780b65 gui: DeepSeek's image-files setting in the provider editor's Advanced (#5407)
matrix0487 on Discord (#feedback, 11-05) asked to change image-files from
the GUI: 8fbf8e0af made it CLI-only (`magpie provider set <id>
image-files=off`). The editor's Advanced now has an Images tick, "Upload
images once and send them by file id", on by default. It shows only where
the setting has effect: a provider on api.deepseek.com, the built-in
DeepSeek or a custom one with that base.

The rule has one source: provider.ImageFilesAt(to) (own key, no account or
plugin, Chat/Responses/Anthropic, host == provider.DeepSeekHost), and
TakesImageFiles for the editor. The gateway's dsFilesOn and forward's
dsSent setup ask ImageFilesAt instead of their own host checks.
/api/providers sends imageFilesOff and takesImageFiles; /api/provider/save
takes imageFilesOff as *bool, so a save that leaves it out keeps the old
value (CLI-set off stays off), false turns it on, true off. app.js sends it
only when the row is shown. Strings in zh, zh-TW, ja and de. app.js is 135
bytes under its base (four comments cut to one line); no budget raised.

Run on mote:
- provider-image-files.test.cjs: chromium + webkit, en/zh/zh-TW/ja/de,
  1100 and 420 wide, 60/60. Shown for DeepSeek and a custom
  api.deepseek.com base, hidden for another relay, toggling saves the
  field, CLI-set off shows off.
- i18n-keys, i18n-en-no-cjk, editor-advanced-align, editor-fold-clickable,
  provider-limit-rest, provider-image-files: 131/132; the red is i18n-keys
  "a plugin's words are its own" from other tests' strings ("View
  routing", "No session ID"), #5332 / #5327.
- go test -timeout 45m ./internal/provider ./internal/gateway
  ./internal/cli ok; ./internal/gui ok but TestMainWindowCorners, the
  macOS 27 red (#3949). TestProviderSaveImageFiles and
  TestCoreScriptBudget rerun after the comment cut.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.

Broken by hand, each red then restored:
- row condition `if (false)`: GUI red (chromium en 420).
- save field renamed: GUI red (webkit zh 420).
- imageFilesOff left out of draftOf: GUI red ("one set off from the CLI").
- the old keep-only save restored: TestProviderSaveImageFiles red
  ("ticked on in the editor, still saved off").
- host rule loosened to contains "deepseek": TestProviderSaveImageFiles
  red (api.deepseek.com.example.com offered).

Not tried: a real DeepSeek key or the real app; a URL edit on an unsaved
provider doesn't show or hide the row live (it follows the saved row's
flag).
2026-11-06 08:01:14 +08:00
yetone ef176e21f6 sessions: a Claude Code session moved with /cd is listed under its new folder
usrname1833 on Discord (#feedback, 11-05): after Claude Code's /cd the
session's file is in the new folder's .claude/projects directory, while
magpie kept showing the session under the folder it was started in.

What /cd does (Claude Code 2.1.316, read in the binary and run for real
in a sandbox CLAUDE_CONFIG_DIR against a fake API): relocateSessionTranscript
renames projects/<old>/<id>.jsonl and its <id>/ folder to
projects/<new>/, and appends {"type":"relocated","relocatedCwd":"<new>"}.
The lines from before keep the old cwd; a second /cd adds another line,
and the last one names the folder.

Cause: a Claude Code session's folder was its first line's cwd only, and
a relocated line went to the default case. Every place that groups or
resumes by folder (GUI, TUI, `magpie sessions`, stats, the resume
command's cd) reads Session.Cwd, so all of them showed the old folder.

- claudeLine reads the relocated line (ccRelocated): the last move's
  folder is the session's.
- A parse kept by an earlier magpie isn't read again when the file
  hasn't changed. One whose folder isn't the project folder the file is
  in (ccStale, with Claude Code's own name: non-alphanumerics as "-",
  past 200 cut and a hash added) is read again once. state.CdRead marks a
  parse made by this reader, and a kept one in its right folder is marked
  on the first refresh, so the name isn't worked out on every poll.
  parseVersions isn't raised: that would read every Claude file again.
- A glance (a long file's row before its first read) takes a relocated
  line in the last 64 KB too.
- Sibling, magpie's own project move (relocateClaudeJSONL): a /cd'd
  session was judged by its first cwd, so moving the folder it was moved
  to failed with "a different project cwd", and relocatedCwd was never
  rewritten. It now judges by the last move and rewrites relocatedCwd.
- docs/subsystems/gateway-sessions.md says how the folder is found.

Fixtures (internal/sessions/testdata/claude-cd) are Claude Code
2.1.316's own lines from that run, paths written as /w, without request
records, attachments and file snapshots.

Run (mote, at a754660b2 + this):
- go test -count=1 ./internal/sessions ./internal/tui ./internal/cli: ok.
  ./internal/gui: ok but TestMainWindowCorners/macOS_26_SDK, which is
  #3949 (macOS 27 on mote), not this change.
- GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: ok.
  gofmt -l: clean.
- wsl-run go test ./internal/sessions: ok.
- win-run go test ./internal/sessions: the new tests ok; TestAgySessions,
  TestAgyRowOnly (#4115) and TestCCListingKeepsItsNames (#4925/#5277) are
  red on Windows the same on a754660b2 alone.

Red on the old code (a754660b2 with the new tests):
TestClaudeCdListedUnderNewFolder (under /w/projA, resume cd '/w/projA')
and TestClaudeRelocationAfterCd ("a different project cwd").

Broken by hand, each red: ccRelocated not called (ListedUnderNewFolder,
KeptParseReadAgain); ccStale always false (KeptParseReadAgain); the kept
parse not marked (KeptParseReadAgain); the glance tail skipping relocated
lines (TestClaudeCdGlance); relocateClaudeJSONL not resetting the first
cwd on a move, and not rewriting relocatedCwd (RelocationAfterCd).

No GUI file changed and the GUI tests stub /api, so no GUI test was run.

Not tried: the reporter's own files; the fixed build against a real /cd'd
session in the app (only the package's listing, Find and resume command
in tests); a /cd across WSL, or Windows paths beyond the vet and the
package run there.

Reported by usrname1833 on Discord.
2026-11-06 07:32:04 +08:00
yetone a754660b2a gateway: requests that come together spread over a pool's accounts (#5242)
Moody-Sin and Tericerice (#5242, magpie 0.1.3072 on Linux): an
antigravity provider with three accounts and affinity turn sent four
requests at once all to one account, under In turn and By pace alike,
each request with its own X-Magpie-Session.

Cause:
- Nothing counted the requests in flight when a request was planned.
  Pace (internal/routes/strategies.go:348) goes by pace, wallet and
  Tokens, all of which move only once a reply ends; a key's lane counts
  a request only once its try starts, after planning. Requests that came
  together were planned on the same figures and all went to the first.
- In turn's next turn (affinity.go:685 "new-turn" → after(), :937) reads
  a stick that moves only when an answer comes back, so a burst of turns
  of conversations already answered all went to the one next account.
- conversationID (gateway.go:9160 on origin/main) ignored
  X-Magpie-Session, so callers that named their own sessions but opened
  alike were one conversation and kept together.

Fix:
- burst.go: burstSpread, called in serve once the candidates are planned
  (gateway.go:3013), counts each request on the account it goes to until
  it ends, and puts first, among the accounts routing would as soon pick
  (burstAlike: In turn any ready one; By pace a pace within a tenth, no
  wallet told apart, none near its cap; Least used within a point), the
  one with the fewest in flight. A kept conversation (session, turn's
  stick, strict), a pin, a lead's account, a checkpoint and a new
  conversation leastHeld spread are counted where they are, not moved.
  Fallbacks, reserved, aside, resting, held, barred and capped accounts,
  other routings (Smart, In order, ...) and a group in a group keep
  their order. In a group, a member routed its own way is alike only to
  its own provider's. The one step covers direct models, groups, plugin
  providers and a remote magpie.
- affinityID: the stick key (stickKey), a group rule's key (ruleKey) and
  the sealed lead's stick read X-Magpie-Session after an agent's own
  session header. conversationID, which Kilo and a plugin are sent as the
  conversation, is unchanged, so the caller's session never goes
  upstream.
- docs/subsystems/gateway-routing.md says both.

Not done: putting a markedly slower account behind by its TTFT. A first
token's wait goes with the prompt's size and the vendor's queue more than
with the account, so a small sample would move turns away from a fine
account and off its cache; it needs its own design.

Run (mote, mote-run):
- go test ./internal/gateway -run 'TestABurst|TestBurst|TestMagpieSession|
  Kilo|Sealed|Rule|Stick|Affinity|Conversation': ok
- go test ./internal/gateway ./internal/routes: ok (654s, 0.3s)
- GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: ok; gofmt -l: clean
New tests (burst_spread_test.go): six at once over three keys, rotate
and pace × affinity turn/off/auto × x-session-id / X-Magpie-Session /
same body × fresh and warm; over a group of three providers and of one
provider's keys; behind a remote magpie; over a plugin's three accounts
(fake plugin, streaming); a kept session stays on one account; paces
{10, 9.5} spread and {10, 5} don't; three X-Magpie-Sessions in turn get
an account each under session affinity, and conversationID never
returns X-Magpie-Session.

On the old code every pace case went 6 of 6 to k1, and rotate's warm
cases 6 of 6 to the next account.

Broken by hand:
- reorder forced false: every pace case, rotate's warm cases, the group
  pace cases, the remote and the plugin tests red.
- !aff.Kept dropped: TestABurstKeepsAKeptConversation red
  (map[k1:2 k2:2 k3:2]).
- affinityID without X-Magpie-Session: TestMagpieSessionIsTheConversation
  red (map[k1:3]); the burst tests stay green, as the count covers them.

Not tried: real Antigravity accounts, a run on Linux, a real remote
magpie on another machine.
2026-11-06 07:05:37 +08:00
yetone 5ae0ed1ab0 claude warm-up: a week left out while the five hours run is one the account hasn't
koohoko5924 (v0.1.3057, Claude Enterprise): the account has only a
five-hour window, and the warmer kept warming a week it doesn't have
(state Idle, 189 tries). warmNow walks withExpected(q.Windows, expect),
which adds the 7-day window whenever a reading leaves it out, since
Anthropic leaves a window out until the request that starts it. But
any request starts every window a plan has, so a week left out while
the five hours are running is not a week waiting to start.

warmNow now marks such a window Absent (codex-warmup.json, compared in
mapsEqual) and sends it nothing (windowAbsent). The rule: the reading
leaves it out, the reading is whole (no partial window), a shorter
plan window is running (shorterRunning), and it was never seen with a
reset or use. A week seen running before, or left out of a partial
reading, is warmed as before. usageRead counts an expected missing
window as due only when no shorter window runs. withExpected itself is
unchanged: claudeWithUnstarted uses it for the card. Codex has no
expect list, so it is untouched.

Docs: providers-accounts.md gets the rule.

Run (mote, at this tree): go test ./internal/provider -run
'Warm|NotStarted|UsageRead|Claude|Codex' ok; gofmt -l clean.

Broken by hand: windowAbsent off and the old usageRead check:
TestClaudeWarmLeavesAWeekTheAccountHasnt red (12 "7 days" sends),
TestClaudeWarmStartsAWeekThatReset's "never read" warmed, and
TestUsageReadLeavesAWeekTheAccountHasnt told five-only@x. With the
seen/partial guard taken out, "reset" and "partly told" go red.

Not tried: a real Enterprise account or a real warm-up; the state is
the report's (Idle 189), rebuilt in the test.
2026-11-06 06:30:23 +08:00
yetone beba9e8a1f claude warm-up: the account it started is read again, its old reading keeping its time
koohoko5924 (v0.1.3057): after a warm-up the card said "just updated"
over windows read before it. claudeWarmedNow cleared the kept
reading's time (e.at) and kept its windows, so claudeReadAt gave nil
and readNow stamped them now. Nothing read the account again either:
claudeWindows' next read waits on when /usage last ran (e.tried),
which the warm-up left alone.

claudeWarmedNow now clears e.tried, which makes the next read due as
for an account never read, and keeps e.at, so until that read the card
shows the reading's own time. Codex's warmed hook only drops its cache
(its usage is a fresh API read), so it has no such sibling.

Run (mote, at this tree): go test ./internal/provider -run
'TestClaudeWarmedReadAgain|Warm|Claude' ok; gofmt -l clean.

Broken by hand: on the old claudeWarmedNow TestClaudeWarmedReadAgain is
red ("the kept reading's time is <nil>"); keeping e.at but not clearing
e.tried, red ("warmed, not read again", the 10% reading kept).

Not tried: a real warm-up on a real Claude account.
2026-11-06 06:30:23 +08:00
yetone 77031d5817 claude usage: a /usage panel with no window is no window started, and a failure says why
koohoko5924 (Discord #help, v0.1.3057, macOS): a Claude Enterprise
account with a five-hour window only. A manual refresh took ~5s and
gave the card no window and the error "Claude Code's usage showed no
usage figures: ▐▛███▜▌ … magpie-claude-work…": Claude Code's banner,
not a reason.

Claude Code 2.1.316's Usage tab (gi) draws a window only once
Anthropic's answer has it non-null, and a window is null until the
request that starts it. An idle 5h-only account's panel loads with
the session's cost, maybe the plan's credit bar, and no window. The
helper told that panel's words, joined from the top of the screen, and
the card took them as a failure with the banner first.

- claudetui: a panel that loaded (tabs, Session/Total cost, nothing
  loading, refreshing, stale or failed, no gateway Spend limit) with no
  "Current session"/"Current week" is told as NoUsageWindow ("No usage
  window has started"). The provider reads that as no window started:
  no error, the unstarted 5h window as for any account.
- claudetui: the two rate-limit errors gi draws ("Claude is temporarily
  limiting requests to the usage page (not your usage limit)…",
  "Usage endpoint is rate limited until …") are failures to load, like
  "Failed to load usage data": retried once, then told as an error with
  the panel's own "Error: …" text, never the banner. A panel with no
  window and no error is told from its tabs on, the session's cost
  lines left out.
- provider: "(not your usage limit)" no longer reads as an account
  refused (claudeDenied, at every place claudeUsageDenied judged a
  reading: the CLI parse, codex_switch, quota_last, subscription_usage).
  Counts ("Last 7d · 403 requests …") are taken out wherever they sit in
  a line before that check, as the panel's words come on one line now.
  A no-figures error keeps every line (600 runes), not the first clipped
  at 120.

Tests are built from 2.1.316's own strings (ko/gi/hi in the bundled
cli.js), drawn on the helper's 200x50 grid row by row. Guessed: the
exact bytes of a real Enterprise panel (not captured; no such account
here) and the credit bar's layout.

Run (mote, at this tree): go test ./internal/claudetui ./internal/provider
-run 'Usage|Claude|Shim|Quota|Codex' ok; go vet for claudetui, provider,
gateway; GOOS=linux -tags nogui and GOOS=windows go vet; gofmt -l clean.

Broken by hand (each red, then restored):
- the NoUsageWindow case off: TestShimReadsUsageWithNoWindow red in all
  three panels (told the panel's words as success);
- the provider's claudeNoWindow branch off: TestClaudeUsageNoWindowStarted
  red ("showed no usage figures: No usage window has started");
- claudeDenied back to claudeUsageDenied: TestClaudeUsageWhyKept red
  ("read as an account refused");
- usageFailed back to "Failed to load usage data" and the whole screen as
  the reason: TestShimToldWhyUsageFailed red in all three (the banner as
  the reason; the rate-limit panels told as no window), TestUsageNoWindow
  red.

Not tried: a real Claude Enterprise account; a real rate-limited panel.
2026-11-06 06:30:23 +08:00
qiqllandggbdpq b7631300ec claudetui: a successful interactive turn tells its account's allowance
Since the interactive mode replaced -p for Claude subscription turns
(43966a53, e5f66f8a, 10-31), a turn that succeeded told no
rate_limit_event, so NoteClaudeLimits never ran and the Usage page's
5h/7d figures moved only on a manual refresh (/usage). Only a turn that
ended in a <synthetic> API error told one, from its transcript row.

What changed:
- tap.js, when a main-class reply opens, also copies its
  anthropic-ratelimit-unified-* response headers into the {s, open}
  line as "h". It only reads them; the request to Anthropic is sent as
  Claude Code made it.
- tap.go (rateLimitInfo) turns them into the rate_limit_info -p tells
  (Claude Code 2.1.291): status plus unifiedWindows five_hour, seven_day,
  seven_day_overage_included (5h, 7d, 7d_oi), each only when both its
  utilization and reset are numbers, the reset rounded to a second.
- A streamed reply tells it just before its message_start, as -p does,
  so the bridge keeps it before the reply begins. A reply whose message
  was told whole from the transcript, or that never began one, keeps it
  for the turn's end (tap.settle). Only the latest is told: a kept
  reading from an older reply is never told after a later reply's
  (toldOf), whether the older one ended before or after the later one
  began, since NoteClaudeLimits keeps the last it hears.
- transcript.go: a <synthetic> API error settles the tap first, then
  tells its own rate_limit_info, so the error's reading is the newest.
- docs/subsystems/claude-subscription-bridge.md says all of this.
  The gateway is unchanged: it already turns a rate_limit_event into
  NoteClaudeLimits and limitHeaders.

Run at this head (base origin/main 6c201095):
- gofmt -l on the changed Go files: nothing
- go vet ./internal/claudetui/, GOOS=linux go vet -tags nogui, GOOS=windows
  go vet: clean
- go test -count=1 ./internal/claudetui/: ok (62s)
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway/ -run
  'Claude|Tap|TUI': ok (60s)

Broken by hand:
- tap.go, tap.js and transcript.go at 6c201095 with the new tests: all of
  TestTapTellsReplyLimits, TestTapLimitsOfMessageToldWhole,
  TestTapErrorLimitsLast, TestShimTellsTapLimits and
  TestTapKeptLimitsNotAfterNewer (both subtests) red.
- keepLimits without `n > t.toldOf`: TestTapKeptLimitsNotAfterNewer/
  ended_after red (told 0.42 then 0.3). message_start without dropping an
  older kept reading: /ended_before red the same way.

Not tried: a turn on a real claude.ai account, so the headers were not
checked against a captured reply; Windows and WSL; the full go test
./... suite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Review: chosen over #5012, which reads the same headers but emits a
rate_limit_event the moment its line arrives. That event can land while an
unstreamed message is pending, and the bridge settles that message early.
This one tells the limits just before message_start, keeps them for a cut
stream's end, and never tells an older reply's limits after a newer one's.
ddnio's real setup-token run on #5012 shows Bun's response headers are
readable there, the same thing this reads.
Run at the pushed head on mote, go1.26.8: go test -tags nogui -count=1
./internal/claudetui/ ok (83s).
Broken by hand: with the limits before message_start turned off,
TestTapTellsReplyLimits, TestShimTellsTapLimits and
TestTapKeptLimitsNotAfterNewer are red.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 05:54:00 +08:00
ggbdpq 0076fb0c9c gui tests: the lightweight click fails at once on an option out of sight (#3078)
The red reported on origin/main 75e769a9f ("posted []", 4 of 8, chromium
and webkit) was the row under the window's foot: rows added above
Settings › General had put the Off/On options past the 1000px viewport
(y about 1008 of 1000), where a mouse click lands on nothing. No save
ever came, and the failure read as an empty posted list. The product was
never broken: 28bec1507 raised this test's page to 1200 tall (with the
on-by-default change) and c627652e9 kept it, so the file has been green
on main since. The trap stayed, though: rows keep being added to
General, and one more row grown above puts the option under the foot
once more, where the same silent no-op click reads as "posted []"
again - the On option's middle sits at y 974 of 1200 now, about four
rows of room.

What changed: the click helper asserts, before the mouse click, that
the option is wholly inside #view-settings and nothing drawn over takes
the point pressed - the check segs-glide's reveal has had since #2683.
A row grown under the foot now fails at once with where the option is,
instead of "posted []" after the 2.5s poll.

Broken by hand: with this file's viewport at 900 (the option's middle
at y 974), main's file fails "posted []"; this file fails "the option
is out of sight at (851, 974) of 900" at once, in English and Chinese.

Run at origin/main f24829636 + this commit, macOS, playwright 1.62.0:
- lightweight.test.cjs 10 rounds (chromium and webkit): 9 all-green;
  the one red round was settingsDrawn's 5s wait timing out on a box at
  load about 8, in a subtest that makes no click at all (the wait bar
  #4470 leaves at the click's 5s on purpose), green again on a rerun.
- settings-general, segs-glide, segs-press-redraw: green, two rounds
  each.

Generated-by: GLM-5.3-Flash (ZCode)

Review (at the pushed head, mote, playwright 1.62.0): agent-expand-steady,
sidebar and lightweight together, Chromium and WebKit, 30/30 ok. The
change makes the failure say what is wrong at once instead of waiting out
the click's timeout; it does not change what passes.
2026-11-06 05:53:50 +08:00
ggbdpq faa69b8319 dsh: a dsh test's temp home is given up only once it is really gone
TestDshSetEffortWritesALegacyEntryWithTheCatalog died once at cleanup,
not in its body: on Windows, t.TempDir's RemoveAll found .config/magpie
not empty (LoKi's box, reported by yetone, #2982). Save replaces
providers.json by renaming a file over it, and a scanner holding the
file that was just renamed over keeps its entry listed while the entry
is pending deletion, so the folder reads as not empty for a moment;
t.TempDir's own cleanup retries a sharing violation but not a
"not empty" one, so it gave up on the first try. The seven dsh tests
that set up such a home now share dshTempHome, which tries the removal
until the folder is really gone, for a short while, before t.TempDir's
cleanup gets its turn.

Not verified on Windows: the failure is one-off under a scanner there,
and on macOS removing a folder whose file is still open succeeds, so
the race cannot be reproduced on this machine. With the retry taken
out the suite is green on macOS as before, so the only change in
behavior is the retry itself.

Generated-by: GLM-5.3-Flash (ZCode)

Review: go test -tags nogui -count=20 -run TestDsh ./internal/agent/ ok on
Windows 11 (xiaomi-gpu, win-run, 232s) and -count=3 on mote. The cleanup
is registered after t.TempDir, so it runs first (LIFO) and TempDir's own
RemoveAll finds the folder gone.
Not tried: a Windows box under the load that made the original red.
2026-11-06 05:53:50 +08:00
ggbdpq 24d4425944 gateway: TestRequestBuildsProvidersOnce judges the build's ask, not the
request's start (#2965)

Cause: the test judged the second request by when it began, letting it
want 0 rebuilds only within 900ms of the first, while what decides a
rebuild is the hold and the stamp, not the clock from a request's
start. Two ways that guess goes red: on a loaded machine a request can
begin within the second and reach the build after the hold has let what
was built go — "request 2 built the providers 1 times, want 0", seen in
full runs at load ~280–400; and since 6a050eeb keeps the catalog for
the next requests, a request that begins past the 900ms builds none at
all — "request 2 built the providers 0 times, want 1", which an idle
machine now reproduces with a plain 1.2s pause between the requests.

Fix: allProviders notes when the build it counts was asked for
(AllBuiltAt, beside AllBuilt), and the test judges a rebuild by that,
not by the request's start: a rebuild asked a second or more after the
first build's ask is the hold letting go, rightly, and is allowed only
when it is exactly one; a rebuild asked within the second, or more than
one build in a request (the #2502 bug class), stays red. Nothing rests
on how fast the machine gets from a request's start to its build.

Red first (macOS arm64, idle, this tree): with a 1.2s pause put before
the second request, the old test failed "request 2 built the providers
0 times, want 1"; the new test passed the same pause (-count=3); the
old form failed it again with the hook in place (ablation: the test is
what guards). The loaded-machine shape is the issue's own run at load
~280–400 and the maintainer's "request 2 built the providers 1 times,
want 0" at c8c0985df; the "request 1 built 2 times" red at dee5c9d75 is
not the guess — two builds inside one request stays red here by design,
per #2502.

Run (macOS arm64, go1.26.8, load ~4–7):
- go test -tags nogui -count=5 -run 'TestRequestBuildsProvidersOnce$'
  ./internal/gateway/: ok.
- go test -tags nogui -race -count=4 -run
  'TestRequestBuildsProvidersOnce$' ./internal/gateway/: ok.
- go test -tags nogui -count=1 ./internal/gateway/: ok (634.7s).
- go test -tags nogui -count=1 ./internal/provider/: ok (127.8s).
- gofmt -l internal/gateway/ internal/provider/: clean.
- go vet -tags nogui ./internal/gateway/ ./internal/provider/ for
  darwin, linux, windows: ok.
- CGO_ENABLED=0 go build -tags nogui ./..., darwin/linux/windows: ok.

Fixes #2965

Generated-by: GLM-5.3-Flash (ZCode)

Review (mote, go1.26.8): go test -tags nogui -count=3 -run
'TestRequestBuildsProvidersOnce$' ./internal/gateway/ ok. A rebuild
happens only when the second ask is a second or more after the build's
end (h.at is set after the build), so a second or more between the asks
is necessary and the new allowance excuses no wrong rebuild.
Broken by hand: heldFor at 1ns makes it red ("request 1 built the
providers 2 times, want 1"); a 1.2s pause before request 2 passes, which
is the case the old test misjudged.
2026-11-06 05:53:50 +08:00
ggbdpq d1b0b34430 gui tests: sidebar's unroll is counted as its animations are made
"the list opens and folds as it plays" sampled getAnimations() once
after the click to see the list's unroll still playing. Under a machine
load of ~175 that one sample landed after the whole play was over: a
finished animation is out of getAnimations(), so the test read "not
animating" and went red once (8be402816's GUI run; it passed on rerun).
The list unrolls for 460 ms and its rows come one after another for 636
ms in all - the round trip from the click through the element wait to
that one sample is not bound to that window.

The animations made are counted instead: Element.prototype.animate is
wrapped ahead of the click, and the assert reads that the nav-sub's own
unroll was among them. An animation made is a fact that stays put, so
the sampling race is gone. The assert is not looser: an opening with no
animation still fails it.

Run (playwright 1.62.0, idle machine):
- this file: 10 runs, 160/160 ok (Chromium and WebKit)
- nav-sub-unroll, sidebar-glide and sidebar-tab-top together: 2 runs,
  136/136 ok
- a 700 ms wait put between the click and the old sample turned it red
  with the reported "the list unrolls" assertion; with this change the
  same wait passes, and cutting navSubEnter's animations off turns it
  red again
Not tried: a machine at load ~175 (the load figure is the report's; the
delay injection stands in for it).

Siblings: provider-advanced-fold's boxMoves() reads getAnimations()
once after its own click the same way; it has no observed red, so it
stays as it is.

Fixes #2950

Generated-by: GLM-5.3-Flash (ZCode)

Review (at the pushed head, mote, playwright 1.62.0): agent-expand-steady,
sidebar and lightweight together, Chromium and WebKit, 30/30 ok.
navSubEnter animates the nav-sub box itself, so the wrapped animate sees
it. The sibling named above is filed as #5417.
2026-11-06 05:53:50 +08:00
ggbdpq 682848300c gui tests: agent-expand-steady checks the slide's animation, not the frames drawn (#2935)
yetone reported the webkit 980px leg going red once under load: "slid
open: 208". The test sampled the row's height every frame for 800ms and
wanted at least three heights between shut and open. A busy machine
drops frames — WebKit drew the whole slide in one frame, the sampler saw
only the final height (208), and the count came up short while the slide
itself was drawn correctly. Alone, the same test passed 3 of 3 at the
same load: a timing assumption, not a broken slide.

The drawn heights stay as an ordering check only; the slide itself is
now checked where it lives. A click drives a height animation on the
row's opened part (sheet() animates it through the Web Animations API),
so the sampler reads the opened part's animations in the same tick as
the click, before any frame is drawn: a keyframe animation carrying
height is the slide's witness, whatever number of frames the machine
went on to draw. The same evidence answers for the slide shut.

Run (playwright 1.62.0, darwin/arm64, node --test):
- agent-expand-steady: 40/40, ten rounds, Chromium and WebKit, 980px
  and 560px.
- A probe that starves requestAnimationFrame past the sampling window
  (the reported shape: one drawn frame, the final height) is red on the
  old assertions ("slid open: 746") and green on the new ones, then
  removed.
- agent-connected-unfolded and agent-models, the neighbouring agent-row
  files: green, two rounds.

Generated-by: GLM-5.3-Flash (ZCode)

Review (at the pushed head, mote, playwright 1.62.0): agent-expand-steady,
sidebar and lightweight together, Chromium and WebKit, 30/30 ok. sheet()
calls box.animate inside the click handler, so reading getAnimations()
right after the click sees the slide. These tests run in English only;
the change adds no text.
2026-11-06 05:53:50 +08:00
yetoneandggbdpq 83fdd09c07 agent: the Agents page's re-detect asks where updates come from again (#4980)
latestVersion kept its answer for 6 hours under a constant key, and the
page's re-detect (Rescan) forgot everything but it. A version published
after magpie started showed no update until the memo ran out or magpie
restarted, though a fresh process asked npm at once and saw it.

Rescan now expires the kept latest versions, the way it already forgot
where commands were found and what the slow readers had said. Unlike the
patch's forget, the entries are only expired, not dropped: the value stays
until a new ask answers, so a re-detect while npm is down still shows the
last version known instead of none (a failed ask keeps the old value in
memo.get). An ask already running is left to finish.

Run on mote (macOS arm64, go1.26.8), sandbox HOME:
go test -tags nogui -race -count=1 -run "Rescan|Latest|Update"
./internal/agent/ ok. TestRescanAsksLatestAgain: 1.4.0, then 1.5.0 after
a Rescan, then still 1.5.0 when the next ask fails with a 502 (asked 1, 2,
3 times).
Broken by hand: without the expire in Rescan, red ("1.4.0, asked 1
times"); with an expire that deletes the entry, as the patch did, red ("a
failed ask after the refresh: latest \"\", asked 3 times").
Not tried: the Agents page against the real npm registry; Windows and
Linux.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 05:53:50 +08:00
yetoneandggbdpq 59907fd554 claude: a /usage count of 401 or 403 is a count, not a denial (SCIYYDy, #4995)
SCIYYDy's Claude account closed /usage with the machine's own activity,
"Last 7d · 403 requests · 388 sessions", and magpie read the count of 403
as the HTTP status. parseClaudeUsage scans every line for
claudeUsageDenied before it reads the windows (account errors come first,
#4532), and the bare \b(401|403)\b in that regex cannot tell a statistic
from a status. So a whole reading with valid session and week windows came
back "told no allowance" and the card kept none. A count of 401 denies as
much.

The scan now skips a line that reads, whole, as one of /usage's count
lines ("Last <span> · N requests · N sessions", the numbers with or without
thousands commas, so "1,403 requests" is a count too). A line that says
more ("… · HTTP 403 Forbidden") is no count line, and a real 401
Unauthorized, 403 Forbidden or authentication failure still denies the
account, on its own line and beside the windows; the #4532 precedence
holds.

Sibling (review): a count line with no windows around it fell to the "no
usage figures" error, which quoted the panel's first line, so the error
text held "403". That error is matched with claudeUsageDenied again in
subscription_usage.go, quota_last.go and codex_switch.go, where it would
read as a denial after all. A counts-only panel now gets an error that does
not quote it, and the test asserts the error does not match
claudeUsageDenied.

Run on mote (macOS arm64, go1.26.8) at the pushed head, sandbox HOME:
go test -tags nogui -count=1 ./internal/provider/ ok (116s).
Broken by hand: without the count-line skip, the counts case is red ("told
no allowance: Last 7d · 403 requests"); with the patch's narrower regex
(no commas), the "1,403 requests" case is red.
Not tried: a real Claude account whose /usage shows 401 or 403 requests;
Windows and Linux.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 05:53:49 +08:00
ggbdpq 3da58c3dfc fix(plugin): end ordinary RPCs' plugin work when their caller leaves (#4678)
A plugin model list's deadline and an ordinary RPC's cancellation released
only the caller. inTime raced the hook without stopping it, and host.go
marked only gatewayRequest cancellable, so a cancelled usage or providers
call never told the host: the plugin's task kept running, the host's
pending count kept it, and repeated reads left task after task alive past
their callers. Reported with an offline host-script reproduction that
shows abort reaching none of three pending usage tasks and five model
tasks outliving their deadlines.

The cancellation path a fetch and a gateway request already take now
carries ordinary RPCs too:

- host.go marks every call but init cancellable, so a caller whose
  context ends has the host told (the existing callAborting write), the
  way it already tells it of a stopped fetch. init is left alone: a start
  that overruns is stopped whole.
- host.js registers each ordinary RPC's AbortController; an aborted
  RPC's answer, nobody's then, is not sent.
- the handler is handed the signal: usage passes it to the plugin's
  auth.usage hook as its own options, and a model list's hook options
  carry it, with the listWait deadline aborting the same controller, so
  vendor I/O that supports stopping stops at the deadline or when the
  caller leaves, whichever comes first.

Sign-in renewal and its persistence are untouched: fresh() runs before
the hooks, and an aborted RPC's handler still finishes what it saves.

Refs #4678

Generated-by: GLM-5.3-Flash (ZCode)

Reviewed and ported, narrowed: an aborted ordinary RPC is no longer
answered "Aborted" at once and dropped from pending. It stays pending
until its handler ends, as on main. host.go's stop() closes the host's
stdin and then gives a renewing host up to stopRenewing to save the
rotated token; with the early done(), host.js's own `pending === 0 &&
closed` exit ended the process at once under a cancelled call whose
handler was still renewing or saving (keepSignedIn, set, signOut, a
usage hook mid-refresh). The Go side needs no answer: an aborted call
is released once its abort is written. The signal to the usage and
models hooks, and the listWait deadline aborting the models hook, are
kept as the patch had them.
TestCancelledCallKeepsTheHostTillItsHookEnds is new: a usage hook that
ends 600ms after its abort, then Settle() closing the host's stdin; the
hook's end must reach its trace.

Run on mote (darwin arm64, Go 1.26.8, Bun via testenv): go test -tags
nogui -count=1 ./internal/plugin/... ok 102.8s; -run Plugin
./internal/gateway/ ok 52.1s and ./internal/provider/ ok 13.3s.
Broken by hand: host.js and host.go at main, tests kept:
TestOrdinaryCallCancelTellsTheHost FAIL "the host was told of the
cancellation didn't happen", TestCancelledUsageReachesThePlugin FAIL
"the plugin's usage hook was handed a signal didn't happen",
TestModelListDeadlineTellsTheHook FAIL "the models hook was handed a
signal didn't happen". host.js as the patch had it (early answer):
TestCancelledCallKeepsTheHostTillItsHookEnds FAIL "the host left
before the hook ended; trace: {"signal":"live"}...".
Not tried: the reporter's replay.py against the built host, and a real
plugin's usage hook that passes the signal to its fetch. The reporter's
"host lives on after stdin closes with a task pending" row is unchanged
by design: that is the renewal safeguard.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 05:53:23 +08:00
ggbdpq 9f6407321d library: a project whose folder was deleted outside magpie comes off the list when it's removed (#3510)
RemoveProject empties a project (Skills, Servers, then syncProject) and
takes the entry off the list only once nothing magpie placed or wrote is
left in it. But the only thing that empties those records, syncProject,
gives up on a folder that's gone: it says "the folder is gone" and
returns with the records as they were — and the Result RemoveProject
hands it is thrown away, so the removal itself says nothing; the toast
the user sees is the one the full sync after every change reports. With
the folder gone there is nothing magpie can ever take back, so the
records never empty and the entry stays for good: the only way out was
the keep checkbox, which takes the entry off the list without looking at
the folder (#514), though that reads as keeping what magpie wrote, not
as the way out of a dead removal.

So removal now does what a skill's removal already does when its folder
is gone (removeSkill: only the entry goes): a folder that isn't there
has nothing of magpie's on disk to take back, so the project and the
records of what it placed and wrote go together, and the removal says
nothing failed. A folder that is there removes as before; a project
gone from disk still shows its "folder is gone" badge and still reports
the folder on a full sync; keep is untouched.

TestRemoveProjectWhoseFolderIsGone is new: a project with placed skills
whose folder is deleted outside magpie, removed without keep — the
entry goes, the Result has no problem, the library's skills stay; and a
gone project removed with keep goes off the list as it always did. It
fails without the change (the removal says "the folder is gone" and the
entry stays) and passes with it.

go test -tags nogui -count=1 ./internal/library/ pass (28 project and
gone-family tests targeted first); gofmt, go vet -tags nogui and
go build -tags nogui ./... pass. The cgo warning from
internal/gui/trayimage_darwin.go is there before this change.

Generated-by: GLM-5.3-Flash (ZCode)

Reviewed and ported, narrowed: only a folder known to be gone (not
there, or not a folder) drops the records. A Stat that fails another way
(no permission, a drive answering with an error) isn't known to be gone,
so the removal goes as before and the records stay, to be taken back
once the folder answers; TestRemoveProjectWhoseFolderCantBeRead pins it.

Run on mote (darwin arm64, Go 1.26.8): go test -tags nogui -count=1
./internal/library/ ok 73.8s. On Linux (wsl-run, magpie-desktop):
-run TestRemoveProject ok.
Broken by hand: projects.go back at main, tests kept:
TestRemoveProjectWhoseFolderIsGone FAIL "the removal said: [... the
folder is gone]", the entry left with Placed [.agents/skills/pdf
.claude/skills/pdf]. The patch's own check (err != nil):
TestRemoveProjectWhoseFolderCantBeRead FAIL "projects: []".
Not tried: removing a deleted project from the GUI on Windows, the
reporter's system.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 05:46:03 +08:00
ggbdpq 8807f621f2 gateway: a relay's DeepSeek model reads max_tokens as its own (#5030)
deepseekTokenField named a chat request's reply length max_tokens for
the DeepSeek preset and api.deepseek.com alone; a relay on its own
domain serving a DeepSeek model got max_completion_tokens as it came,
DeepSeek behind it ignored it and answered with its default, 8K
without thinking (#5030, NOMOAX) — the gate the tool-schema
normalization's had too (#4852, ethanfly). DeepSeek's quirks are told
by the model named in the body now, as Grok's are (grokModel): a
model a relay names deepseek-whatever gets the field DeepSeek reads,
whoever serves it; another vendor's model through the same relay goes
as it came.

Generated-by: GLM-5.3-Flash (ZCode)

Reviewed and ported. The model's name decides only on a host that isn't
DeepSeek's: chatTokenField runs after deepseekTokenField in forwardOnce,
so OpenAI's own hosts still get max_completion_tokens and a relay whose
400 names max_completion_tokens is still asked that way from then on.
The model test (provider/test.go probe) already sends max_tokens to a
host that isn't OpenAI's, so it needs nothing. The tool-schema \0 gate,
the same narrow gate, is #4852's, open.

Run on mote (darwin arm64, Go 1.26.8): go test -tags nogui -count=1
-run 'TokenField|MaxTokens|MaxCompletionTokens|DeepSeek'
./internal/gateway/ ok.
Broken by hand: deepseek_schema.go back at main, test kept:
TestDeepSeekRelayChatGetsMaxTokens FAIL "upstream got
{...max_completion_tokens:393216...}".
Not tried: a real request through AI Flash API.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 05:42:22 +08:00
ggbdpqandIkki c6d2bd3316 library: ZCode reads the shared skills folder too (#4987)
ZCode reads ~/.agents/skills beside its own ~/.zcode/skills, but it
wasn't among the readers of the shared folder: a skill kept there
behaved as if ZCode didn't have it — its chip unlocked, a tick writing
a second link into its own folder. It reads it as the others do.

Generated-by: GLM-5.3-Flash (ZCode)

Reviewed and ported: docs/subsystems/library.md now lists ZCode among the
readers of ~/.agents/skills, as Ikki6666's own branch (a23828e81) had it;
the reporter checked the published ZCode builds for a version boundary
and found none (#4987).

Run on mote (darwin arm64, Go 1.26.8): go test -tags nogui -count=1
./internal/library/ ok 76.5s; -run 'ZCode|Shared|Always' ok.
Broken by hand: "zcode" taken out of readsShared, test kept:
TestSharedSkillReachesZCode FAIL "zcode has a second link to it in its
own folder" and "zcode's own folder got it on the sync too".
Not tried: a real ZCode install reading the skill.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
Co-authored-by: Ikki <824310075@qq.com>
2026-11-06 05:41:29 +08:00
yetone acde144a7a providers: a vendor of embedding and rerank models alone is detected on /embeddings and /rerank (heatonz)
heatonz on Discord (#help, 11-05): a custom provider whose models are only
embedding and rerank models couldn't be added. Detect APIs ("检测协议")
picked the first listed model, an embedding model, and asked it to chat on
every API, so nothing answered.

- tiny: an embedding or rerank model (catalog.ServesOf) on Chat is asked
  where the gateway's retrieve sends it: the OpenAI base's /embeddings
  ({"model","input"}) or /rerank ({"model","query","documents"}). tested
  adds no extra body there, as the gateway sends none.
- detectModel asks each API a model that chats when the list has one, so
  a chat vendor's detection is unchanged. A retrieval model is a last
  resort on Chat only. Responses, Anthropic and Gemini say why they weren't
  asked (DetectModels too).
- testModel: a saved provider with nothing to chat with tests on a
  retrieval model its list keeps apart (LiveServing). testOne asks such a
  model on Chat and never moves it to another API.
- provider.ListAll is List with Serves models kept. /api/provider/list and
  the provider's JSON carry a `retrieval` count. The add form's Fetch models
  and the saved editor say "Only embedding and rerank models are listed.
  They need no pick: ask them on /v1/embeddings and /v1/rerank." in place
  of "the list is empty". One new string, in zh, zh-TW, ja and de.
- app.js stays under TestCoreScriptBudget with no raise: +42 bytes, paid
  for by two add-form comments cut.
- The gateway already routes /v1/embeddings and /v1/rerank to such a
  provider (#765, resolveRetrievalModel by prefix or KindGroup), so nothing
  changed there.

Run (mote, at this tree on origin/main 60fe6645a):
- go test ./internal/provider ./internal/catalog: ok.
- go test ./internal/gui: ok, except TestMainWindowCorners/macOS_26_SDK,
  which is #3949 (mote is macOS 27).
- go build ./..., go vet (darwin), GOOS=linux go vet -tags nogui and
  GOOS=windows go vet of provider and gui: ok. gofmt -l: clean.
- node --test, chromium and webkit: provider-retrieval-only (new: en, zh,
  zh-TW, ja, de, with and without retrieval models, add form and saved
  editor), provider-detect, provider-add-models, azure-endpoint,
  provider-listed-as, provider-add-gemini, i18n-en-no-cjk and i18n-keys.
  94 of 95 pass. The red is i18n-keys "a plugin's words are its own", red
  on origin/main 60fe6645a too (#5332/#5327).

Broken by hand:
- New tests on origin/main's code. TestDetectEmbeddingOnly red ("The
  model BAAI/bge-m3 does not support chat" on chat, 404 on the rest).
  TestTestEmbeddingOnly red ("no model to try"). TestProviderListBeforeSave
  red (retrieval = 0).
- Retrieval models not kept out of chat probes: the mixed-list case is red
  (bge-m3 asked beside glm-5).
- tested adding the extra body to /embeddings: red (prompt_cache_key
  sent).
- detectOne asking non-Chat APIs with a retrieval model: red (404 on
  /v1/responses).
- testModel's LiveServing fallback off: TestTestEmbeddingOnly red.
- provider-retrieval-only on the old app.js with the new i18n.js: the 5
  retrieval cases red, the 5 empty-list ones green.

Not tried:
- A real embedding/rerank vendor (heatonz's is unknown). Fake httptest
  servers only.
- The whole GUI suite.
- Windows and Linux test runs (vet only).
- Models whose ids don't say embed, bge- or rerank (gte-, e5-, m3e-,
  text2vec-, voyage-) are still taken as chat models. The /embeddings probe
  goes by the id, and a Xinference model_type isn't read.
2026-11-06 05:21:05 +08:00
yetone 60fe6645a9 claude: a caller's folder Claude Code would ask about is known before the run, and the session kept (sleepy_shibe)
sleepy_shibe on Discord (magpie 0.1.2996, Claude Code 2.1.318, own
account, interactive mode): message counts 36, 65, 85, 108, 128 for one
conversation. Confirmed at origin/main 74d1cda42: a caller's folder Claude
Code asked about was passed over for untrustedFor (10 min) only. Past
that, the next run went in the caller's folder again, claudeSessions
pointed at another project folder than the conversation's session in
magpie's folder, so `from` went nil and the run was told the whole
conversation; Claude Code asked about trust, startTrusted dropped
req.branch and started from nil in magpie's folder (the deferred
from.discard() had already removed the session), told it all again.

Now, for the own account in the interactive mode, each run first decides
as Claude Code does (untrustedHere -> claudeTrusts), from
hasTrustDialogAccepted in claudeProfilePath()'s .claude.json
(provider.ClaudeTrustedProjects; a missing file is nothing trusted, an
unreadable one unknown, which goes on as before). The rules are Claude
Code 2.1.316's, read from its bundled JS (UI/zh/jh/Y0/lr): the key of the
repository's main checkout (a worktree's is the checkout it was added
from), or any folder from the run's up to the git root and never past it
(a nested repository isn't trusted by its parent), every folder above
outside a repository; NFC keys, forward slashes on Windows
(claudeTrustKey, shared with claudeTrustKeys). An untrusted folder stays
in magpie's folder with its session; a folder trusted since is run in on
the next run. When Claude Code asks all the same, startRun keeps `from`
and startTrusted goes on from it in magpie's folder with the branch.

Run (mote, at this tree on 74d1cda42):
- go test ./internal/gateway -run TestClaude: ok (118s);
  go test ./internal/provider -run Claude: ok
- GOOS=windows and GOOS=linux go vet ./internal/gateway ./internal/provider: ok
- win-run go test ./internal/gateway -run TestClaudeTrust: ok
- real Claude Code 2.1.316 in a sandbox HOME + CLAUDE_CONFIG_DIR (dummy
  key, no account), tmux, 10 cases: repo/subfolder/parent-in-repo/
  worktree-of-trusted/worktree-itself trusted -> no question; worktree
  under a trusted parent, nested repo in a trusted repo, repo under a
  trusted parent, unrelated folder -> asked; outside a repo a trusted
  parent -> no question. All ten match claudeTrustedBy.
Broken by hand:
- untrustedHere returning passedOver only (the old choice):
  TestClaudeTUIUntrustedFolderKeepsItsSession/untrusted red (helper
  started twice) and TestClaudeTUIFolderTrustedLaterRunInAtOnce red (ran
  in magpie's folder).
- startTrusted dropping req.branch and starting from nil (the old
  fallback): .../unknown red (resumed a new transcript, not the
  conversation's session).
Not tried: the owner's real account or a real turn through the gateway
(no sign-in in the sandbox); Claude Code 2.1.318 itself (2.1.316 is
installed here); a Windows or Linux real Claude Code; the full suite
before the push (it runs after, through the suite lock).
2026-11-06 04:35:12 +08:00
yetone 74d1cda421 gateway: a rate limit with a bracketed reset time rests the model until then, and says rate limited
taoxiaoxin on Discord (v0.1.2992, WorkBuddy China, plugin 0.2.24):
deepseek-v4.1-flash got 429

  {"error":{"code":null,"message":"WorkBuddy: 您的使用量已超出频率限制,将在
  2026-11-06 17:13:04 (UTC+8) 重置,您也可以切换其他模型继续使用。",
  "param":null,"type":"rate_limit_error"}}

with credits left, and Routing showed the account as 额度用尽.

Cause: WorkBuddy now writes the offset in brackets, "(UTC+8)".
resetsWhen read "UTC+8" only bare, so the reset time went unread, the
refusal fell to plannedWords (用量) as failQuota with no time, and the
whole account rested a quarter of an hour as quota used up. With the time
read, the existing path (resetsWhen + otherModels) rests only that model
on that account until 17:13.

- resetsWhen takes an optional ASCII or fullwidth bracket round the
  offset (zh and en forms); a body cut inside or after the bracket,
  before 重置, still reads no time.
- Rest.Rate (and provider.KeyRest.Rate): a refusal read as out of quota
  until a named time whose words say rate/frequency limit. Routing is
  unchanged (it rests as the quota it is until then); the Providers row,
  Routing's stage row, its Accounts line and the account tallies (live
  and the day's, history.go) say "rate limited" (限流, 限流, レート制限,
  Rate-Limit; strings already translated) with "back at {time}".
- workbuddy-ai gets the same: one path, tested for both ids. The plugin
  (opencode-workbuddy-auth) already reads the bracketed time; no plugin
  version or mover min.

Run (mote, at this tree):
- go test ./internal/gateway -run 'TestDayTallies|TestResetsWritten|
  TestWrittenReset|TestBracketedReset|TestMonthlyWritten|
  TestRateLimitBelieves': ok
- go test ./internal/gui ./internal/provider: provider ok; gui red only
  in TestMainWindowCorners/macOS_26_SDK, #3949 (macOS 27, untouched)
- go vet (darwin) gateway, gui, provider; GOOS=linux and GOOS=windows
  go vet gateway, provider: ok; gofmt -l clean
- node --test account-rate-rest (new; chromium + webkit, en zh zh-TW ja
  de, 1100 and 420px): 10/10
- GUI routing-*, account-*, i18n*, key-rest*, rate-limited-* (194
  files, 3127 tests): 3086 pass, 41 red. Rerun at concurrency 2 here
  and at origin/main 8fbf8e0af: the same 9 files red on both, each
  filed: i18n-keys (#5332), routing-intent-entry (#5392),
  routing-rule-drag (#3789), routing-rule-remove (#3096, #4585),
  routing-row-swap (#3799), routing-steady (#3412, #1804),
  routing-steps-cap (#4628), routing-story-shrinks (#3954),
  routing-order-unknown (#4627). account-weight, routing-levels,
  rule-models, rules-line passed on the rerun.
- TestCoreScriptBudget: app.js under 1,533,802 without a raise

Broken by hand:
- old resetsWhen: TestResetsWritten's bracket cases and
  TestBracketedResetRestsTheModelRateLimited red ("rests 14m59.99s by
  quota (quota), want 5h13m0s by resets": the whole account, 15 min)
- Rate forced false: "a frequency limit not marked a rate limit"
- history.go's count off: TestDayTalliesCountARateLimitAsOne red
  ("tallied map[quota:3]")
- app.js and routing client.js at HEAD: account-rate-rest 10/10 red

Not tried: a real WorkBuddy account answering this 429 (the body is the
reporter's literal one); the live app.
2026-11-06 04:09:30 +08:00
yetone 8fbf8e0af6 gateway: DeepSeek's own API gets an agent's images once, by file id, not on every turn (#5407)
DeepSeek's API is stateless, so every turn re-sent every inline image in
the history. Now, on api.deepseek.com only (never a relay or another
base), for a model with "flash" in its name (deepseek-flash sees images;
deepseek-v4-pro reads them as "[Unsupported Image]"), each base64 data:
image goes up once through POST /files (purpose=user_data, expires_after
a day) with the candidate's own key, and later turns name it by file id:
- Chat: {"type":"file","file_id":…} (flat, as DeepSeek's vision guide);
- Responses: input_image with file_id in place of image_url;
- Anthropic: source {"type":"file","file_id":…} plus anthropic-beta
  files-api-2025-04-14.
Shapes checked against api-docs.deepseek.com files_api, vision,
responses_api and anthropic_api. The Anthropic guide names the "file"
source type and the beta; the field name file_id is Anthropic's Files
API's, which DeepSeek says it follows. Not confirmed with a real call.

Ids are kept per key hash + image sha256 in deepseek-files.json beside
providers.json (temp+rename, unparseable file moved to .bad), reuploaded
with under an hour left. One upload per image and key however many
requests want it; a request waits at most 8s for its uploads, and what
isn't up goes inline this turn. A failed upload leaves the image inline
and rests that key's uploads for 10 minutes. A 4xx naming a file-api id
or a missing/expired file forgets the ids, uploads again and asks once
more; refused again, the request goes inline. detail:low stays inline.
`magpie provider set <id> image-files=off` turns it off (kept on GUI
save). Doc: docs/subsystems/gateway-routing.md.

Run (mote, at this tree on 498b6419f):
- go test -run 'DeepSeek|DsFileGone' ./internal/gateway: ok; -race -count=3 ok
- go test ./internal/gateway ./internal/provider ./internal/cli: ok
- go test ./internal/gui: TestMainWindowCorners/macOS_26_SDK red, the
  known macOS 27 red on mote (#3949); nothing in gui's code path changed
  but a kept field on save
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ok;
  go build ./... and GOOS=linux -tags nogui ok

Broken by hand, each red: host check removed (InlineElsewhere), switch
ignored (ImageFilesOff), singleflight off (FilesOneUpload), breaker off
(UploadFailsInline), key left out of the cache key (FilesPerKey and
others), beta not added (ImagesByFile/anthropic), retry off
(FileGoneUploadsAgain), store not read from disk (FilesKeptOnDisk), the
flash check removed (InlineElsewhere), the 8s wait cap removed
(UploadSlowGoesInline).

Not tried: a real DeepSeek key (none available in the sandbox), so the
exact refusal text for a gone file and the Anthropic file_id field are
unconfirmed against the live API. Not covered: a custom_tool_call_output's
images (walkImages doesn't read it); files aren't deleted (they expire in
a day).
2026-11-06 02:46:46 +08:00
yetone 7625481b9e library: a Codex MCP entry never keeps the other transport's keys
kwanyu (Discord #help, 11-06): with Codex connected to magpie, the
ChatGPT/Codex app wouldn't start: "config.toml:209:1: env_vars is not
supported for streamable_http". Codex refuses a command's keys (args,
env, env_vars, cwd) beside a url, and a url's (bearer_token_env_var,
http_headers, env_http_headers, http_headers_helper, oauth,
oauth_resource, auth) beside a command (codex-rs/config/src/
mcp_types.rs, TryFrom RawMcpServerConfig).

merged kept every old key magpie doesn't own. env_vars is magpie's only
while the server references a variable in its env, so a server changed
from a command to a URL (in the Library, or one imported from the
user's own stdio entry) kept its env_vars and cwd under the new url.
The converse kept bearer_token_env_var and env_http_headers under a
command. The sync's in-step check decodes neither key, so an entry
already broken was never written again.

Now codexRefused names the other transport's keys. merged drops them,
and behind reports an entry holding one, so the next sync (and a
project's .codex/config.toml) rewrites it. The user's keys of the
entry's own transport stay (enabled_tools, tool_timeout_sec, scopes, a
stdio entry's own env_vars). bearer_token, which Codex refuses for both
transports, is left as the user wrote it.

Run (mote): go test ./internal/library -count=1 ok (77.8s); GOOS=linux
and GOOS=windows go vet ./internal/library ok; gofmt -l clean.
Broken by hand: the four new tests against the old mcp.go are all red
(env_vars/cwd kept under a URL; bearer_token_env_var, env_http_headers
and oauth_resource under a command; a broken entry left in step; a
project entry read as in step).
Real Codex (codex-cli 0.165.0, sandbox CODEX_HOME, codex mcp list): a
url + env_vars entry fails with the reporter's exact error. The three
config.toml files the new tests write load and list their servers.
Not tried: the reporter's own config.toml (we only have the error line);
the ChatGPT desktop app itself; Grok's config (written by the same TOML
writer, its own transport rules not checked); a full suite before push
(runs after).
2026-11-06 02:04:53 +08:00
yetone 498b6419ff claude: a turn Anthropic refuses in the interactive mode as a third-party app's is asked again as claude -p, and the agent's prompt is remembered
Raven (Discord #general): Cindy with Pi as its engine, routed through
group/auto to a Claude subscription, failed every turn with "Anthropic
refused an interactive-mode turn on claude-opus-5-5 as a third-party
app's", and the message told them to turn the interactive mode off in
Settings, which makes every request of every agent run as -p (about twice
the plan count).

Now, with the interactive mode on:
- a refusal carrying "Third-party apps now draw from your extra usage",
  met before a byte of the reply reached the client (stream head, or a
  whole reply with no parts), is asked again once as claude -p
  (redoAsPrint); the client sees only the -p answer;
- the agent's system prompt (sha256 of its first 2KB, billing header
  dropped, so Pi's trailing <cwd> doesn't change it) is remembered for
  12h, and its next turns go straight to -p (wantTUI, req.tuiRefused,
  clientCache.print) while every other agent stays interactive;
- a refusal after the reply had begun (keepalive sent, or text said) is
  not redone, so nothing is spent twice; the prompt is still remembered
  and the message now says magpie runs its next turns as -p: ask again;
- a -p run that is refused too fails as before ("run as claude -p"),
  once, no loop;
- the setting is untouched; with it off (claudePrintMode) everything is
  -p as before. The run is the real claude binary, nothing else changed
  in what is sent.

This reverses the #4503 call (fbbdf6e05, v0.1.2754: no automatic -p redo)
and the 10-31/11-01 "nothing ever runs as -p with the interactive mode
on", for this refusal only. The switch's foot, the Settings text (en, zh,
zh-TW, ja, de) and docs/subsystems/claude-subscription-bridge.md say so.

Run (mote, at this head rebased on 1100ed649):
- go test -run 'ThirdParty|TUIRefusal|ClaudeTUI|ClaudeSubscription|ClaudePrint'
  ./internal/gateway/ ok; Budget/i18n tests in ./internal/gui ok
- gofmt -l clean; go vet ./internal/gateway (darwin, GOOS=linux,
  GOOS=windows) ok; GOOS=windows go vet ./internal/gui ok. GOOS=linux go
  vet ./internal/gui fails in wails' cgo-only linux files on mote, the same
  on main, untouched here.
- GUI, chromium and webkit: claude-mode, claude-tui-setting,
  claude-quota-onboarding, mobile-web, i18n-keys, gui-zh-tw, gui-ja,
  gui-de: 57 pass, 6 fail in each engine; the fails are i18n-keys "a
  plugin's words are its own" (#5327, #5332) and mobile-web (#3952,
  #5013), the same 6 at origin/main 1100ed649 alone.
- Red on the old code: the new tests run against 1d704f819 all fail (400,
  the old "turn the interactive mode off" message).

Broken by hand: dropping len(col.res.Parts)==0 from the whole-reply redo
turns TestClaudeTUIThirdPartyRefusalAfterWordsNotRedone/whole red;
dropping the refusedTUI call turns ...PromptRemembered, ...AfterStart and
...AfterWords/stream red.

Tests use the real Pi 1.1.0 system prompt (testdata/workdir/pi-1.1.0.json)
with its cwd changed per conversation.

Not tried: a real Claude account (no refused turn reproduced against
Anthropic; the refusal text is the one the reporter's log and #4503
carry). A -p run continuing with tool results under a remembered prompt
(the wantTUI resume path) has no test of its own.
2026-11-06 01:20:14 +08:00
yetone 1100ed6494 gateway: an overlong item id goes left out on every kind that may go without one, and under its kind's own prefix on the rest (echo_ts, web_search_call)
echo_ts (Discord, Codex on GitHub Copilot, after 125fd93ec / v0.1.3060):
with native web search on, the turn after a search failed with Copilot's
empty 400 {"error":{"message":"","code":"invalid_request_body"}}. Copilot
gives a web_search_call an id of ~450 characters of Base64 with no ws_ at
the front. plainItemIDs left out only a message's or function_call's
overlong id and bound the rest with boundItemID, which knew a kind prefix
for reasoning, tool_search_call and custom_tool_call only. So the search
call went as a bare 64-hex digest, the shape Copilot refuses (#5266). The
bare digest dates from dd809ea60 (v0.1.2652, #4525/#4527).

The fix covers every kind of input item, not only this one. Which kinds
need an id comes from OpenAI's own SDK, openai-go v3.42.0's
ResponseInputItemUnionParam, where each kind's id is either param.Opt or
required:

- id optional, so an overlong one is left out (idOptional): message
  (typed or not), function_call(_output), custom_tool_call(_output),
  tool_search_call/_output, computer_call_output, shell_call(_output),
  apply_patch_call(_output), mcp_approval_response, additional_tools,
  compaction. Each call and output keeps its call_id, which pairs them.
  Leaving the id out is the case both reporters saw Copilot answer 200.
- id required, so an overlong one is bound under the prefix OpenAI gives
  that kind (itemKindPrefix): reasoning rs_, web_search_call ws_,
  file_search_call fs_, computer_call cu_, image_generation_call ig_,
  code_interpreter_call ci_, mcp_call mcp_, mcp_list_tools mcpl_,
  mcp_approval_request mcpr_. A message bound as msg_+hash was 200 on
  Copilot (isnine, #4525).
- Kinds left as before, keeping their id's own prefix or else a bare
  digest: local_shell_call(_output), item_reference and
  program/program_output. Codex doesn't send these and Copilot isn't known
  to make them. An item_reference's id names a stored item, so hashing it
  can't keep it working anyway.

The 64-character bound (#4525/#4527) stays the same for every kind. An id
of 64 or fewer stays as it was, other characters as "_" (d75ea9282).
custom_tool_call and tool_search_call used to be bound as ctc_/tsc_ and are
now left out. Their schema makes the id optional, and callItemIDs still
re-prefixes a fitting fc_ id.

Tests (internal/gateway/item_ids_test.go):
- TestCopilotTakesItsOwnOpaqueSearchCallID: the reporter's shape, a
  452-character Base64 id with + and / and no prefix on a web_search_call
  between two turns, with tools [web_search], streamed and not, against
  the fake Copilot (opaqueCopilot, which now also checks ws_ on a search
  call). The fake answers the empty 400 word for word.
- TestPlainItemIDsBindsOtherKinds now lists every kind above, each with
  the prefix it gets or "without", and checks that every call kind keeps
  its call_id.
- TestPlainItemIDsBoundItemIDs: the "two ids that begin alike go to two"
  check moved from custom_tool_call to web_search_call (ws_).
- The fake Copilot's setup moved into onOpaqueCopilot, which both Copilot
  tests use.

Run (mote, -tags nogui): -run 'ItemID|CodexRewrites|OpaqueCallID|
OpaqueSearchCallID|BindsOtherKinds' ./internal/gateway: ok, 14 PASS
(including the CodexRewritesAsBefore parity test and its fuzz seed).
Broken by hand (codex_backend.go at origin/main, new tests kept): all
three red. The search-call test failed with Copilot's empty 400 verbatim
("stream true: 400 … invalid_request_body"), BoundItemIDs got msg_ for the
search calls, and BindsOtherKinds got the old ids.
Whole internal/gateway package (go test -tags nogui -timeout 45m): ok (700s).
go vet -tags nogui ./internal/gateway for GOOS darwin, linux and windows:
clean. gofmt -l: nothing.

Not tried: a real Copilot account; this session has none it can use
safely. ws_+hash on Copilot has not been tried live. The evidence is
msg_+hash 200 and bare digest 400 for a message (#4525) and the same 400
in echo_ts's report. The other required kinds' prefixes come from OpenAI's
documented id shapes, and none of them was sent to OpenAI or Copilot.
2026-11-06 01:13:42 +08:00
yetone 1d704f8190 codex: OpenAI's threads follow a provider of the user's at the top, where Codex resumes them
harris on Discord (the Codex app, after switching from CC Switch):
"This chat uses openai, but your current provider is custom. Switch to
openai to continue." CC Switch left its "custom" as config.toml's
model_provider, which magpie keeps since #4347, and Codex 0.166 resumes
a thread only on the provider it is on now. Every thread started on
OpenAI before was refused, and switching to OpenAI would refuse
custom's threads instead, so the user was stuck. Nothing moved them:
bringOver moves only onto magpie, bringBeside only from such a provider
onto OpenAI.

lendOwn (each Sync) moves OpenAI's threads onto that provider, as
bringBeside does the other way: in place at OpenAI's length, by the row
for a paginated thread, the last 30 days rewritten with a copy kept
otherwise. The ids go in stash codex.lent; giveLent returns exactly
those to OpenAI once Codex is on it again (CC Switch's official card),
keeps the record while Codex is on that provider or on magpie, and
drops it on any other. Nothing moves while a profile names openai,
after the user disconnected Codex, or from a distro's Codex.
TestCodexThreadsComeBackOffMagpie/by_hand expected an OpenAI thread to
stay on OpenAI with custom set by hand at the top, the stuck state
itself; it now expects it on custom. docs/subsystems/agent-wiring.md
says so.

Run (mote, go 1.26.8): go test -count=1 ./internal/agent/ ok (250s);
GOOS=windows, GOOS=linux and native go vet ./internal/agent/ ok;
gofmt -l clean.
Broken by hand: Sync without lendOwn, TestCodexOwnProviderTakesOpenAIThreads
red (thread left on "openai", rollout not on custom); without the
disconnected and profile guards, TestCodexOwnProviderLeavesOpenAIThreads
red for both cases.
Not tried: a real Codex app resuming a moved thread on a real relay;
harris's config.toml wasn't seen, so the "custom" here is CC Switch's
relay table as it writes it. A thread moved from the ChatGPT backend to
a relay carries its encrypted reasoning, which a relay on another
account may not accept; the thread then fails on the relay as a
switch to it by hand would.
2026-11-06 00:51:01 +08:00
yetone 845e324b13 liveagent: each model on its own API, and the request format the user picks stays (xiaoxiaofei)
xiaoxiaofei on Discord: "magpie 默认导入的是 message 格式的,要可以自定义请求格式".
magpie wrote one LiveAgent provider, "magpie", type claude_code with
api anthropic-messages, for every model. K-brain asks all of a
provider's models on the provider's one API (routing/client.go builds
the client per provider; PiModel.api is only validated), and LiveAgent's
settings lock an Anthropic provider's API: only an OpenAI provider
(type codex) has a request format to pick (ProviderModalView.tsx,
resolveProviderApi; K-brain settings_provider.go accepts
openai-completions and openai-responses). So the format couldn't be
changed, and a GPT served on Responses was translated from Messages on
every turn.

Now, as dsh's routes do (dshKinds), each model goes on the provider of
the API it is served on natively (catalog.Model.APIs):
- magpie: type codex, Chat Completions, baseUrl the gateway's /v1, for
  every model with no Responses or Messages API of its own (groups, Chat
  providers' models);
- magpie-responses: type codex, Responses, baseUrl /v1;
- magpie-anthropic: type claude_code, Messages, baseUrl the root (K-brain
  appends /v1; for OpenAI it appends only /chat/completions or
  /responses, hence /v1 there).
A codex provider is written with api and requestFormat, as LiveAgent's
settings write one; when the user switches it in LiveAgent, a sync keeps
their format (one LiveAgent doesn't offer goes back to magpie's). A
provider left with no model is taken out. A config.json from before (all
on one claude_code "magpie") is moved on the next sync: each model brings
its record (the user's display name) and whether it was turned off, and
a default/compact/task pick of it follows it to its new provider.
Disconnect takes all three out. Docs: reference.md, agent-wiring.md.

Run (mote, through mote-run):
- go test -tags nogui ./internal/agent -run '^TestLiveAgent|Key': all pass,
  new TestLiveAgentRequestFormat and TestLiveAgentFormatMove included.
- go test -tags nogui -timeout 45m ./internal/agent: ok (320s).
- GOOS=linux and GOOS=windows go vet ./internal/agent: clean; gofmt -l clean.
- K-brain 507f560 (the version LiveAgent af89ea7 pins), with Go 1.27.0
  on mote: config.LoadFile on the config.json magpie writes in
  TestLiveAgentRequestFormat loads it, and routing.ClientForProvider
  builds *ai.OpenAI at http://127.0.0.1:3425/v1 for magpie,
  *ai.Responses at /v1 for magpie-responses and *ai.Anthropic at the
  root for magpie-anthropic (a throwaway test, not committed).

Broken by hand (a copy), each turned a test red:
- the user's format not kept -> TestLiveAgentRequestFormat;
- no carried record from another provider of magpie's -> FormatMove;
- picks not following their model -> FormatMove;
- Responses models left on magpie -> both;
- an emptied provider not taken out -> FormatMove;
- turned-off not carried to the new provider -> FormatMove.

Full suite at c24915f04 (the change before this one), go test -timeout
45m ./... on mote: 86 packages ok, internal/gui red on
TestMainWindowCorners/macOS_26_SDK (#3949) and
TestPanelHiddenByWailsMarksPageOutOfSight (#5322), both filed, both
macOS 27 on mote.

Not tried: the LiveAgent app itself (its UI showing the three providers
and switching a format, then a real turn through the gateway); LiveAgent
on Windows or Linux; a real config.json of a user's.
2026-11-06 00:48:29 +08:00
yetone 814a625a24 usage: the top refresh reads saved Claude accounts again (#5380)
The tray panel's Allowances refresh said "Allowances refreshed" but a
saved, non-active Claude account kept its old reading: claudeWindows runs
Claude Code's /usage for a saved account only under savedRefresh, which
only that account's own card refresh sets.

Now a refresh of every allowance by hand asks usage/quotas?asked=1&all=1
(AskEveryClaudeUsage). It marks its ask generation in claudeEveryAsked,
and for claudeEveryFor (2 minutes) each saved account not read since is
read as its card's refresh would, under the same due check, the
30-second per-account floor and the same running holds. Opening the
Usage page or the Allowances tab (?asked=1 alone), the timed refresh and
every background read are unchanged, so nothing polls more. Callers:
the panel's top refresh (refreshPage "allowances"), the Usage page's
refresh and sidebar reload (refreshUsage -> loadQuotas("all")),
Routing's Read allowances, and the TUI's r. loadQuotas no longer lets a
lesser load on its way (an opening's asked read) swallow a Refresh.

Siblings: saved Codex accounts are already read anew on every asked
whole read (loginReading over HTTP after AskUsage clears the cache), so
Codex is unaffected. PlanQuotas and KeyBalances keep their 1-minute cache
on an asked read; left as is. The core scripts' budget is not raised:
the ~140 bytes are paid for by two loadQuotas/quotasOpened comments cut.

Run (mote, at 807341cdc on origin/main 5666cb049; rebased onto
505534992 after, which touches only internal/plugin and internal/proc;
the core script budget rechecked at the pushed head, 193 bytes under):
- go test ./internal/provider/ ./internal/gui/ ./internal/tui/ ok
  (TestMainWindowCorners/macOS_26_SDK red on mote's macOS 27, #3949;
  green when run with the -run set at the pushed head)
- go vet the three packages; GOOS=linux go vet -tags nogui and
  GOOS=windows go vet of them ok; go vet provider+tui in WSL ok; gofmt -l
  clean
- GUI, Chromium and WebKit, en+zh: refresh-page, claude-usage-asked,
  usage-refresh, routing-read-allowances, allowance-open-read,
  quota-refresh-order, usage-refresh-flight all pass. A wider set of 119
  files (quota*, panel-quota*, usage-*, allowance*, routing-read/account,
  menu-*, tray-*, i18n-keys) has reds in 6 files, identical at the parent
  commit and filed: i18n-keys #5332, menu-input-scroll #3402,
  tray-cell-click #5215, usage-agents-hide #3414, usage-fold #3415,
  usage-ledger #5048.
- New TestRefreshEveryReadsSavedClaude: an opening's ask runs nothing
  for saved accounts; a top refresh reads each anew; an unasked read and
  a plain asked read after it don't; rapid refreshes keep the floor; the
  every-ask lapses after claudeEveryFor.

Broken by hand: dropping "|| every" from claudeWindows' read turns
TestRefreshEveryReadsSavedClaude red ("top refresh read no allowance of
saved max@x.com"); the panel's refreshPage back on loadQuotas(true)
turns refresh-page's panel subtests red in both engines.

Not tried: a real saved Claude account's /usage run from the real tray
panel (the test fakes Claude Code's /usage per account directory); the
full GUI suite; the de/ja/zh-TW GUI runs (no string changed).
2026-11-06 00:35:39 +08:00
yetoneandbaijiu666 5055349922 plugin: a host ended ends what its plugin started, at any depth (#5402)
A plugin host was ended with cmd.Process.Kill(), the host alone. A
plugin that starts a browser or a daemon (magpie-magicrew-auth's
headless Edge behind a WAF) left it running with no parent: 620
msedge.exe (6.8GB) and 382 temp profiles (57GB) in an hour on one
Windows machine. Bun's own job ends its direct children with it on
Windows, but lets their children out, so Edge's gpu/renderer processes
lived on. On macOS and Linux nothing ended them at all.

The host now starts as a proc.Tree (new Output.StartTree): a session of
its own on Unix, a job (kill on close) on Windows. host.kill kills the
tree; stop (after stopWait, so EndHosts, Restart, a moved proxy, an
update) and the line-too-long path both use it. A host that ends by
itself is swept by the tree's Wait: the Unix group is killed, the
Windows job closed. Nothing outside the host's own session or job is
signalled, so magpie's own process group is never reached.

Ported from baijiu666's fix/plugin-host-tree (a8172a1), which called
proc.End then Process.Kill. Reviewed against it:
- macOS/Linux: proc.End is SIGTERM to the host pid alone, followed at
  once by SIGKILL; host.js has no SIGTERM handler and the host was in
  magpie's own process group with no session of its own, so nothing it
  started was ended. Red on mote and WSL, same as main.
- Windows: endTree walks living parents, so it covers the killed host
  but not a host that ends on its own (crash, process.exit) or one that
  leaves when its input closes; those were red on Windows too.
- Its test was Windows-only and checked a direct child, which Bun's job
  already ends: the new test checks a grandchild, through a real host.

Run (TestHostEndedEndsWhatItsPluginStarted: a real Bun host whose
plugin starts a child that starts another; subtests stop / killed /
own end):
- origin/main 125fd93ec: red 3/3 on macOS (mote), Windows (win-run) and
  Linux (wsl-run).
- baijiu666's host.go: red 3/3 on macOS and Linux; on Windows red on
  stop and own end, green on killed.
- this change: green 3/3 on all three; -race green on mote and WSL with
  TestEndHostsLeavesNoChild, TestHostReapedWhileItsChildHoldsStdout and
  TestHostRunsAsMagpieBun.
- go test ./internal/plugin ./internal/proc: ok on macOS and Linux; on
  Windows ok except TestPiPackage, red the same at 125fd93ec (no `sh`
  on PATH there; #4115).
- go vet: darwin, linux, windows (./internal/... for windows). gofmt -l
  clean.
Broken by hand: the old and baijiu666 trees above are the fix taken out.
Not tried: a real headless Edge plugin (magpie-magicrew-auth) on
Windows; a plugin reading /dev/tty (the host has no controlling
terminal now, as every proc.Tree child).

Co-authored-by: baijiu666 <198813975+baijiu666@users.noreply.github.com>
2026-11-06 00:34:42 +08:00
yetone 5666cb0490 search MCP: web_search takes a count, 6 by default, 1 to 20 (treeman)
The web search MCP server's web_search always gave 6 results: searchHits
was both what a search API (a plugin's included) was asked for and where
its pages were cut. It now takes an optional count, described in its
input schema (integer, minimum 1, maximum 20, default 6). A number or a
number in a string is taken, floored; below 1 is held to 1, above 20 to
20 (Brave and Tavily take no more than 20); null or a non-number is the
default 6. The tool's description is unchanged, and the web_search magpie
offers models on vendor requests keeps its schema (no count).

The count rides the search's context (withSearchCount/searchCount), so
every backend reads it: plugin search APIs by key and signed-in (the
count handed to the hook and the pages cut), Tavily max_results, Brave
count, Exa numResults, Firecrawl limit, DeepSeek count, Volcengine
Count, You.com count (all three routes), Yuanbao Search's Cnt (the
fewest of 10/20/... that covers it), SearXNG (cut only), Kimi Code's
limit, GLM's search MCP and Codex's backend search (cut only, neither
takes a count), WorkBuddy (its client's 5 unless more than 6 is asked).
A searcher model's search is prose and has no count.

Run (mote): go test -run 'Search|Codex|Kimi|GLM|WorkBuddy|Plugin'
./internal/gateway ok; -race of the new tests and TestSearchMCP* ok;
go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet of the
package ok; gofmt -l empty.
Broken by hand: searchCount ignoring the count went red in both new
tests (plugin asked for 6, said 6, every vendor asked 6); withSearchCount
without the clamp went red for 50, 0 and -3.
Not tried: a real search API or plugin with count > 6; the full suite
runs after the push.
2026-11-06 00:31:14 +08:00
yetone c24915f04e library: LiveAgent in the MCP and Skills pickers (zero2sin)
LiveAgent was missing from the Library's MCP and Skill agent pickers
(zero2sin on Discord #feedback). It is now a target, written in its own
engine's formats, read from K-brain 507f560 (the one LiveAgent af89ea7
pins), not guessed:

- MCP: <data dir>/config.json.live-mcp.json (cmd/kn/backend.go,
  internal/mcp/live.go LiveSettings): {"servers":[{"id","enabled",
  "transport":"stdio"|"http","command","args","env" | "url","headers",
  ...}],"selected":[...]}. Streamable HTTP only, so SSE is refused.
  ${NAME} in env and headers resolves as K-brain's secret refs
  (internal/config/secret.go). The user's servers and their
  description/enabled/cwd/timeoutMs/policy/auth/... are kept; untouched
  servers are written back byte for byte (json.RawMessage). A non-empty
  selected gets magpie's server added (or it would have no tools) and
  taken out on remove, never the last one. With no file yet, K-brain
  reads config.json's "mcp" object (settingsFromConfigs), so the first
  write carries those servers over the way K-brain's own first save
  does. A new file is 0600 like K-brain's. A file K-brain itself could
  not parse is not written over.
- Skills: <data dir>/skills, as copies (Target.Copy): K-brain refuses a
  link in a skill's path (safePath) and ScanDetailed walks past one. A
  skill there loads only when picked in skills-settings.json
  global.selected (Manager.Effective), so syncLiveAgentPicks picks each
  copy magpie makes once (Applied.Picked), never again after the user
  unpicks it, and unpicks it when the copy goes. Names K-brain refuses
  (validManagedName) are never put in selected, since its next save
  would fail on them. Its built-in skills-creator/skills-installer are
  not offered for import.
- Not added: instructions (K-brain's brain.md is its own memory file).
  A server written while LiveAgent runs is seen at its next start (the
  app holds the list in memory and saves it whole).

Run (mote-run, at base 326e72f4c):
- go test -run LiveAgent ./internal/library/: 7 tests ok
- go test ./internal/library/... ./internal/agent/ ./internal/gui/:
  library ok, agent ok, gui FAIL only TestMainWindowCorners/macOS_26_SDK
  (#3949, macOS 27 on mote, no library code)
- GOOS=linux and GOOS=windows go vet ./internal/library/: clean;
  gofmt -l: clean
- node --test of 100 GUI files (library-*, *skill*, *mcp*, i18n-keys)
  in chromium and webkit: 1941 of 1946 pass. Red: i18n-keys "a plugin's
  words are its own" (two Go test files elsewhere say a plugin's word)
  and found-skill-pick-remove "en at 420px" in both engines; this change
  touches no GUI file.
- Rebased on origin/main 125fd93ec and run again there:
  go test ./internal/library/ ok; found-skill-pick-remove and i18n-keys
  red the same (en at 420px both engines; "a plugin's words are its
  own"), and red the same on a clean origin/main 125fd93ec worktree:
  filed as #5013 and #5327/#5332.

Broken by hand, each red: Copy=false (TestLiveAgentTarget,
TestLiveAgentSkills: a link); no syncLiveAgentPicks call (nothing
picked); re-picking every sync (TestLiveAgentSkills: xlsx picked again
after the user unpicked it); no built-in skip (found lists
skills-creator); no selected append (TestLiveAgentMCP); no config.json
seeding (TestLiveAgentMCPFromConfig); no chmod (0644); no name check
(TestLiveAgentSkillsNewSettings: My_Skill picked).

Not tried: a real LiveAgent app reading the written files (no LiveAgent
on mote or here); Windows and Linux test runs (vet only).
2026-11-06 00:26:59 +08:00
yetone 125fd93ecd gateway: an overlong message or call id goes left out, and any other is bound under its kind's prefix, which Copilot checks (echo_ts, #5266, #4972)
echo_ts (Discord #feedback, v0.1.3058): after Codex's native compaction, a
tool call on GitHub Copilot failed with an empty 400 "invalid_request_body".
Copilot had handed the call a 452-character opaque id (Base64, + and / in
it, no fc_ prefix). plainItemIDs, on every relay that checks ids
(validatesItemIDs, Copilot among them), sent any id over 64 as
boundItemID's sha256. That kept an id's own prefix only when it had one, so
an opaque id went as a bare 64-hex digest. Copilot refuses that. By hand,
the reporter got 200 with the original id and 200 with the id left out
(call_id kept). isnine found the same thing for a message on #4525/#5266:
left out 200, bare digest 400, msg_+hash 200. The bare digest dates from
dd809ea60 (v0.1.2652, 11-01). Before it, + and / were already turned into
"_" since d75ea9282 (10-10).

The id doesn't go back unchanged, because Copilot doesn't always take its
own long ids: isnine's 420-character ones were refused "string too long …
maximum length 64" (#4525). Leaving the id out was 200 in both reports. So:

- a message (typed or not) or function_call whose id is over 64 goes
  without its id (idOptional). OpenAI's schema makes both optional, and
  the call keeps its call_id, so its output still pairs with it.
- any other kind keeps an id, bound under the prefix its type says
  (rs_ for reasoning, openaiItemPrefix's ctc_/tsc_). Only a kind with no
  known prefix takes one from its id, and a bare digest is left only for an
  unknown kind whose id has no prefix.

Every route takes the same function: the relay's prepare (streaming,
non-streaming, compaction through serve, and Responses over a WebSocket,
whose frames are served as the POST), the ask-again after a refusal, the
Codex relay and the ChatGPT backend. OpenAI, Azure and the ChatGPT backend
issue ids of 64 at most, so an id over that is always another vendor's.
Those upstreams also take a message or call without an id, and they check
an id's kind prefix too ("Expected an ID that begins with 'tsc'"), so the
typed prefix fits them as well.

Tests:
- TestCopilotTakesItsOwnOpaqueCallID: a fake Copilot that takes its own
  ids or none, and answers any other id that is over 64 or lacks its kind's
  prefix with its empty 400, word for word. A 452-character Base64 call id
  goes through streaming and non-streaming, paired by call_id.
- TestPlainItemIDsBindsOtherKinds: another vendor's overlong reasoning,
  tool_search_call, custom_tool_call and unknown-kind ids are still bound to
  64 (rs_, tsc_, ctc_, own prefix), and foreign-character reasoning is still
  left out.
- TestPlainItemIDsBoundItemIDs is changed to match: the overlong message
  id is left out, and the "two ids alike go to two" check is on
  custom_tool_call. The parity reference (wasPlainItemIDs) follows the same
  rule.

Run (mote, -tags nogui): -run 'ItemID|CodexRewrites|OpaqueCallID|
BindsOtherKinds' ./internal/gateway ok, 13 tests listed as PASS. Broken by
hand (old plainItemIDs/boundItemID, new tests kept): both new tests red,
the call test with Copilot's empty 400 verbatim. Whole internal/gateway
package: ok (791s). go vet darwin/linux/windows on internal/gateway:
clean. gofmt -l: nothing.

Not tried: a real Copilot account (both reporters' by-hand results are
the evidence that a left-out id is taken). fc_+hash was not tried live.
A Copilot reasoning item whose own id has + or / is still left out as
another vendor's (as before this change). Its seal goes with it, and the
turn still goes through.
2026-11-06 00:07:18 +08:00
yetone 2df5d40ee3 usage: a ChatGPT API account's calls count in the same ChatGPT account's Codex window estimate (jctaoo on Discord)
A ChatGPT account signed in through Sign in with ChatGPT (chatgpt-api) and
to Codex draws on one plan's five hours and week. Only the Codex card reads
those windows, and its whole-window estimate (usage.windowHolds) keyed the
ledger's calls by provider + account, so the chatgpt-api calls were never
counted and the estimate came out low.

provider.SamePlanAccounts maps each chatgpt-api account to the Codex
account that is the same ChatGPT account, matched on the tokens'
chatgpt_account_id and chatgpt_user_id, both known and both equal, never
on a name: two Team seats of one email share the name and the user id,
not the account id. A token that names neither matches nothing, as
before. windowHolds (current and HistoricalWindowHolds) counts a matched
account's calls as the Codex account's, dry runs included. chatgpt-api
alone (no Codex account) is unchanged: its card reads no windows, so
there is nothing to estimate. Routing's caps and pace go by the vendor's
own reading of the windows and don't sum the ledger, so they are
unchanged; the per-provider account breakdown in the summary stays per
provider on purpose.

Run (mote, at this tree):
- go test ./internal/usage/ ./internal/provider/: ok.
  ./internal/gui/: TestMainWindowCorners/macOS_26_SDK red, the AppKit
  test filed as #3949 (macOS 27 on mote), untouched by this change;
  the rest ok.
- go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet of
  internal/usage and internal/provider: ok. gofmt -l: nothing.
- quota-holds.test.cjs in Chromium and WebKit: 2/2 each (the GUI only
  renders the server's holds; no asset changed).
Broken by hand:
- remap removed in windowHolds: TestWindowHoldsCountsTheSameChatGPTAccount-
  ThroughTheAPI red, "whole 5 hours 2500 tokens, want 10000" and "the
  personal account holds 2500 tokens, want 10000".
- account id ignored (user id only) in SamePlanAccounts: red, "the Team
  seat holds 12500 tokens, want 5000" and "whole 5 hours 10000 tokens,
  want 2500" (token naming no account).
Not tried: a real chatgpt-api sign-in. No such account on this machine,
so whether OpenAI's Sign in with ChatGPT tokens carry chatgpt_account_id
and chatgpt_user_id (Codex's do, checked on the real Codex logins here)
is not verified; if they don't, nothing is matched and the estimate stays
as before. GUI suite in other languages not run (no strings changed).
2026-11-05 23:57:33 +08:00
yetone 326e72f4c5 routing: the "No session ID" group folds like the others, and one button folds or opens every group (zzzkl on Discord)
zzzkl: the Routing page's 未提供会话标识 group couldn't be collapsed. Its
head was a div with no click handler, no arrow and no aria-expanded,
because only a group with a key could be folded (`g.key ? "button" :
"div"`). closedSessions is keyed by the group's key, and "" is a key a Set
holds, so the no-session group now uses the same button, arrow and
handler as the rest.

Also, as asked: an icon button in the request list's existing header row
(.rt-fold-all, beside Replay) folds every group while any is open, and
opens them all otherwise. It shows only when the list is grouped (by
session or by key) into two or more groups. It has a tooltip and an
aria-label only, no text: "Collapse all" / "Expand all". Those two words
moved from plugins/library/i18n.js to the core i18n.js (zh, zh-TW, ja,
de), since Library and Routing now both say them (i18n-keys: a word used
by two plugins is the core's). The core script budget doesn't count
i18n.js or plugins/, so it isn't raised.

routing-sessions and inner-scroll-contain found group heads by
`button.rt-session` with a key; they now filter .rt-session by text, as
the no-session head is a button too.

Run (mote, node --test, Chromium + WebKit):
- routing-fold-all.test.cjs (new): 2 engines x 1100/420 x en, zh,
  zh-TW, ja, de. It covers the no-session group folding on click, the
  fold-all button folding then opening every group, its tooltip in each
  language, and it being hidden with one group.
- i18n-keys, i18n-en-no-cjk, routing-sessions, inner-scroll-contain,
  skill-fold-all, routing-row-swap, routing-rule-drag,
  routing-order-unknown, routing-many-keys, in one run at concurrency
  3 with routing-fold-all: 170 tests, 157 ok, 13 red. Every red is also
  red on a clean origin/main 8bfc551ee checkout run alone (concurrency
  1, 42 tests, 14 red), and each already has an issue:
  i18n-keys "a plugin's words are its own" ("View routing", "No session
  ID" said by Go tests, #5332), routing-many-keys "2 keys in sight"
  (#4082), routing-order-unknown webkit de 420 (#4627),
  routing-row-swap (#3799), routing-rule-drag chromium (#3789, #5088).
  routing-fold-all, routing-sessions, inner-scroll-contain,
  skill-fold-all and i18n-en-no-cjk are all ok.

Broken by hand: on the old client.js, routing-fold-all fails with "the
no-session group can't be folded" (and finds no fold-all button).

Not tried: the real app's WebKitGTK on Linux, or Windows WebView2.
2026-11-05 22:07:46 +08:00
yetone 8bfc551ee2 providers: a built-in icon picked over one found from the base URL is the one saved (Refeccd on Discord)
Get icon > Automatic looked for the site's icon from the base URL and kept
that base URL as the picture's address (iconFrom). The editor then opened
with the base URL in the Image URL box, and picking a built-in icon left the
box asking: Save flushed the "typed" address first, fetched the base URL as
a picture over the built-in one, and the built-in pick never stuck.

Now only icons/url's own address is kept as iconFrom, and picking a built-in
icon or choosing a file closes the address box and clears what was typed,
so nothing is fetched over the user's pick. A provider saved before with
the base URL as its address is fixed the first time a built-in icon (or a
file) is picked: the backend drops iconFrom with a non-file icon already.

Test: internal/gui/tests/icon-builtin-over-address.test.cjs (the reporter's
saved state: a file icon with iconFrom = base URL; pick github, Save, open
again; Automatic then Save; built-in over Automatic's), Chromium and WebKit,
420 and 1100 wide, en/zh/zh-TW/ja/de.

Run on mote (mote-run), at this tree:
- icon-builtin-over-address, icon-url-saved, icon-url: 60 of 60 pass.
- Broken by hand: the old app.js put back, the new test fails 20 of 20
  with "the base URL is still in the Image URL box" (1 !== 0).
- go test -tags nogui -run Budget ./internal/gui: ok (core scripts
  1,533,742 <= 1,533,802, paid for by one comment cut, no raise).
Not tried: the real app with a real provider's favicon; the full GUI suite
(runs once after the three fixes).
2026-11-05 21:24:52 +08:00
yetone 055a81e9ac gui: the image chips' names fit the core's script budget, no raise
0d73a6348 (GPT Image chip names) took the core's scripts to 1,533,986,
184 bytes over coreScriptBudget (1,533,802): TestCoreScriptBudget red on
main. Paid for without a raise: mediaChips' new comment dropped, its name
read once, and renderRouting's comment cut to two lines. app.js is now
1,311,215, 129 bytes under its size before 0d73a6348.

Run (on mote, at this tree):
- go test ./internal/gui: ok but TestMainWindowCorners/macOS_26_SDK, red
  on mote's macOS 27 as filed in #3949 (not touched here)
- GUI: chatgpt-image-chip 22/0, image-models-hide 52/0,
  video-models-hide 22/0, group-pick-drawers 4/0
- i18n-keys: 3 pass, 1 fail ("a plugin's words are its own": "No session
  ID", "View routing"), the same on origin/main d00e41604, #5327/#5332

Full suite at 0d73a6348's tree (go test ./... -timeout 45m on mote, plus
go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet and the three
builds): vet and builds ok; 86 packages ok; internal/gui red on
TestCoreScriptBudget (fixed here) and TestMainWindowCorners (#3949).
2026-11-05 20:16:12 +08:00
yetone d00e41604c settings: the image model error's example is gpt-image-2, not the shut-down gpt-image-1
OpenAI shut gpt-image-1 down on 2026-10-23. Run: go test ./internal/settings on mote: ok.
2026-11-05 19:57:29 +08:00
yetone 2d6939ec64 gateway: Automatic draws with the newest GPT Image, and a ChatGPT account's shows as GPT Image (StarBits on X)
StarBits asked on X whether magpie draws with OpenAI's newest image model,
as the editor showed "gpt-image-2".

- AutoDrawer took the cheapest priced model. An OpenAI key lists
  gpt-image-2.5/2.6 with no price (models.dev prices gpt-image-2 only), so
  Automatic kept an older GPT Image. Now a GPT Image that a newer one set
  up supersedes is never picked (gptImageGenOf: version, then
  base/Sunburst > Flare > mini; dall-e and chatgpt-image-latest under all),
  and an unpriced one is costed as the newest priced one. Another kind of
  model that costs less still wins.
- A ChatGPT (Codex) account's backend ignores the model name (#1865;
  re-checked today with a real account: gpt-image-2, 2.6-sunburst,
  2.5-flare and a bogus id all drew the same 1536x1024 image), so it is
  never superseded, and its chip now reads its name "GPT Image" with the
  id as tooltip (/api/providers drawNames). Unticking still saves the id.
- docs/subsystems/gateway-routing.md says both.

Run (on mote, at this tree):
- go test -tags nogui -run 'AutoDrawer|GPTImageGen|Codex.*Image|ImageGen|Drawer|Draw'
  ./internal/gateway ./internal/gui: ok
- GUI: chatgpt-image-chip (new), image-models-hide, video-models-hide,
  group-pick-drawers, chromium + webkit, en/zh/zh-TW/ja/de, 1000 and
  360px: 100 pass, 0 fail
- gofmt -l: clean
- Full go test ./... -timeout 45m and Linux/Windows vet: running; record
  follows in the next commit or a comment.

Broken by hand: without the supersede filter TestAutoDrawerTakesNewestGPTImage
picks oa/dall-e-3; without the ChatGPT exclusion TestAutoDrawerKeepsChatGPTsOwnPick
picks oa/gpt-image-2.6-sunburst; with the chip label reverted the GUI test
is red.

Not tried: a real OpenAI key's live model list in the app.
2026-11-05 19:56:08 +08:00
yetone 8c733bb362 gateway: a bare JSON error line in an event stream is the vendor's error
zRain (Discord #feedback, Windows, v0.1.3039/v0.1.3041) asked
antigravity/gemini-4-argon high. Code Assist answered 200
text/event-stream, a few thinking events, then ended the body with

  {"error":{"code":400,"message":"Request contains an invalid argument.","status":"INVALID_ARGUMENT"}}

on a line of its own, no "data:" before it. readSSEAlive and the
passthrough sniffer skip any line that is no SSE field, so the stream
ended with no finishReason and the agent was told "Antigravity: the
reply ended before it was complete" instead of Google's 400.

- sse_bare.go: bareErrors hands such a line (Google's shape, a list
  of one, pretty-printed over several lines, OpenAI's {"error":…},
  Anthropic's {"type":"error"}) on as the data event it means. Every
  other line goes byte for byte, a line under way at once; only a line
  starting { or [ waits for its end (held up to 1MB). eventStream wraps
  the body with it (passthrough, translated stream and whole reply,
  continuation, search), and readSSEAlive wraps every other reader.
- codeassist.go and carriedError take the status the error names
  (namedStatus, #4855), so a whole reply's error goes out at 400.
- continuation.go notes that status for routing (namedStatusHeader);
  refusal events and Antigravity's own turning away are left as they
  were.
- gateway.go: a reply broken off by an error frame that names a 4xx
  retryable() calls the request's fault rests nobody, as that 400 does
  before the 200.

Plugins: antigravity-cloak only rewrites the request, reads no stream,
so nothing to change there.

Run (mote, at this tree on a9b1877cf):
- go test -run 'TestBareError|TestAntigravityBareError|TestGeminiRelayBareError'
  ./internal/gateway: ok
- go test -run 'Gemini|Antigravity|Stream|Cut|Carried|ErrorReply|Rest|Relay|Late|Named|Passthrough|SSE|Continu|CodeAssist|Plugin'
  ./internal/gateway: ok (251s)
- gofmt -l; go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet
  ./internal/gateway; go build ./...: clean

Broken by hand:
- the new tests on a9b1877cf with bareErrors as identity: every case
  red, the whole reply 502 "Antigravity: the reply ended before it was
  complete" (the reporter's words), the stream with no error, the
  relayed Gemini stream without the error event.
- without the gateway.go rule (the status noted only), the three
  stream=true cases rest antigravity@u for 60s.

Not tried: a real Antigravity account (the reply can't be made to
happen on demand); the reporter's own thinking events (not sent, the
fixture's are in Google's shape, the error line is theirs byte for
byte); the Windows box. chat/anthropic/responses decoders still take
their status from filterRefused only; carriedError covers the shapes
they share.
2026-11-05 18:36:31 +08:00
yetone 7c5c90f958 provider: a ChatGPT account's GPT Image is tested by drawing, as the gateway draws it (ChangQiu on Discord)
ChangQiu added gpt-image-2.5 to a ChatGPT (Codex) subscription, and the
editor's Test failed. The Test asked every model as a chat on the Codex
backend's /responses, and that endpoint refuses an image model: 400
model_not_found, "The 'gpt-image-2.5' model is not supported when using
Codex with a ChatGPT account" (a real call). Drawing through the gateway
already worked: drawsFamily lets any gpt-image-* draw on
/backend-api/codex/images/generations.

What the vendor's own clients send:
- Codex CLI (codex-rs ext/image-generation tool.rs) names one model,
  IMAGE_MODEL = "gpt-image-2".
- CLIProxyAPI (executor/codex_openai_images.go) passes gpt-image-1.5 to
  2.6 and their -flare/-sunburst variants straight into the same
  /images/generations JSON. magpie sends the same shape.
- Real calls with one account: gpt-image-2.5, gpt-image-2 and the made-up
  gpt-image-9.9-nope each answered 200 with the same thing: 1536x1024, 12
  input / 343 output tokens, x-codex-active-limit imagegen_premium. The
  backend picks the model itself (#1865), so the list keeps one GPT Image.

Changes:
- provider.testOne: a ChatGPT account's gpt-image-* is tested on
  {codex base}/images/generations with a tiny drawing. probeOnce adds
  Codex's image headers (Accept json, x-codex-imagegen-request-id,
  x-codex-image-turn-id), as gateway sendWith does.
- The editor's Image models row, for a provider whose vendor picks the
  drawer (gateway.VendorPicksDrawer, new providerInfo.drawPicks), says
  why only one GPT Image is listed. It reuses an existing string, so
  there are no new keys. After the rebase onto 51bdc985b the core was
  44 bytes over its 1,533,802 budget. renderDrawers' comment line was
  dropped to fit, and the budget is not raised.

Run (mote):
- go vet, GOOS=linux go vet -tags nogui and GOOS=windows go vet, on
  internal/provider and internal/gui; gofmt -l is clean.
- go test -run of TestChatGPTAccountTestsGPTImageByDrawing (at this head),
  TestCoreScriptBudget, TestImageGenCodexOneEntry and
  TestProviderInfoListsImageModels: ok.
- node --test of image-models-hide, video-models-hide and i18n-keys: 77
  of 78. The red is i18n-keys "a plugin's words are its own" (routing's
  "No session ID", usage's "View routing"). It is red the same on a
  fresh origin/main 51bdc985b and filed as #5327/#5332.

Real account: a small main built on mote, run here under a sandbox
HOME holding a copy of ~/.codex/auth.json (the access token had 166h
left, so no refresh). provider.Find("codex").TestModels: gpt-image-2.5
ok 200 in 8.8s, gpt-image-2 ok 200 in 10.4s. The copy matched the live
auth.json byte for byte afterwards.

Broken by hand: with the old test.go, the new test goes red. Its
requests went to /responses with Accept text/event-stream.

Not tried: the editor's Test clicked in the GUI app, and Windows or
Linux runs of the Test. A Copilot account's image models likely have
the same Test gap; that is filed as #5377, not changed here.
2026-11-05 18:31:22 +08:00