dcfda5f166fd428849afa2ed73e2b41990f224a6
4359
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
dcfda5f166 |
gateway: a relayed Responses stream's tidies pass its events in place (#3383)
idTidy and phaseTidy each copied every event of a relayed Responses stream twice, once out of their buffer and again onto an output grown event by event, and dropped their buffer's bytes at each write so the next write took new ones. eventData copied each event's data even when it is one line, as nearly every upstream's is, and phaseTidy decoded a reply's whole last event into a map to find no message without a phase. - tidyEvents goes through a write's whole events into one output sized for them; an event that goes as it came is copied once, and the part of an event still coming moves to the buffer's front. - eventData gives a one-line event's data as ev's own bytes; its callers only read it. - phaseTidy.ended reads the output in place (anyUnphased, which agrees with unphased item by item) and decodes only when a message needs a phase. Measured with BenchmarkZZCodexStream (a 680 KB Codex /v1/responses stream through serve, kept out of the tree): 14.16 -> 12.53 MB/op, ~53,450 -> ~49,700 allocs/op. Run at this head: - go test ./internal/gateway -timeout 45m: ok (439s, at 848b3bf7e rebased on |
||
|
|
4b9694c34c |
gateway: a prompt's estimate reads the request's items in place (#3383)
promptBuilder decoded every item of a request through decodeJSON, which
copies each content and output RawMessage out of the body unless it is
at least 1/16 of a held body. On a long Codex conversation that is every
item, copied once per request on promptOf's goroutine. What the builder
keeps of the body lives no longer than the builder, and the body
outlives it (promptOf's request; promptPieces' kept body, whose pieces
are read out before PromptText returns), so its 18 decodes now use
decodeJSONView, which shares capped slices of the body.
Measured with BenchmarkZZCodexStream (a 680 KB Codex /v1/responses
stream through serve, kept out of the tree): 14.92 -> 14.16 MB/op,
~54,200 -> ~53,450 allocs/op.
Run at this head:
- go test ./internal/gateway -timeout 45m: ok (399 s)
- go test ./internal/gateway -run Prompt: ok
- gofmt -l clean; go vet ./internal/gateway on darwin, and GOOS=linux and
GOOS=windows with -tags nogui: ok
- Real DeepSeek (deepseek-flash, sandbox HOME with only that provider
copied), five Codex-shaped /v1/responses streams through a recording
proxy, built at
|
||
|
|
1184862583 |
agent: Codex background compaction writes the bare async_compaction = true where a Codex older than 0.163 reads the config (多喝热水)
多喝热水 (Discord #help, Windows, v0.1.1384, Codex desktop with ChatGPT
sign-in): Codex wouldn't open, "config.toml:154:1: invalid type: map,
expected a boolean". That line is the [features.async_compaction] table
|
||
|
|
1859da57bd |
gateway: readers of a rewritten request see its input in place (#3383)
Only the body a request arrived with is held (holdBody), so decodeJSON
shares a raw value with it and copies one from any other body. Once a
route rewrites a Codex request (its model, its fields), the new body is
held by nobody, and each reader that only looks at it copied the whole
input to do so: conversationID, hasSealedAgentMessage,
orphanedToolOutputs, joinToolRuns, pairToolItems, withReasoningText,
and affinity's seal and kind strippers. Each such copy was ~0.4 to
0.5 MB on a 680 KB request.
decodeJSONView is decodeJSON whose raw values always share the bytes
they came from, capped, for a reader that keeps nothing it decodes and
writes none of it. Those readers use it. Each one only reads, or builds
a new body with json.Marshal or marshalPlain (which copy), or returns
the body it was given. promptBuilder keeps raw parts past its return,
and parseResponses keeps its result, so both stay on decodeJSON.
Measured on the 680 KB Codex request benchmark (30x, 3 runs):
16.37 MB/op, 54,703 allocs/op -> 14.96 MB/op, 54,222 allocs/op (-8.6%).
What was run:
- TestDecodeJSONViewShares: q["input"], q["tools"] and an item's
content from decodeJSONView point into the body and are capped, and
decodeJSON still copies from a body that isn't held. With `share ||`
taken out of fillJSONIn it is red ("tools []: not body's own bytes,
capped"); restored, green.
- fjCompare checks decodeJSONView against json.Unmarshal on every seed
as it does decodeJSON.
- Real DeepSeek A/B through a recording proxy in a sandbox HOME, Codex
UA, 5 requests with a tool-call history:
|
||
|
|
2d21034d81 |
gateway: a decoded struct's keys are read without a string made for each (#3383)
fillJSONIn made a string of every member key of every object it decoded into a struct (unquoteJSON), then a []byte of that string to look the field up, and a []bool for each struct to see a key twice. A Codex request's history is thousands of small objects, so these were a quarter of its allocations. keyName gives a plain ASCII key's bytes between its quotes and leaves any other key to unquoteJSON as before, and the fields seen are bits of a uint64 unless a struct has more than 64 of them. Run at |
||
|
|
d7ad3f2a3e |
gateway: input scanners read a request's items in place, not copied (#3383)
Seven readers of a Responses request's input (the seal stripper and withoutKinds in affinity, hasSealedAgentMessage, joinToolRuns, orphanedToolOutputs, pairToolItems, withReasoningText) and the prompt builder decoded `input` into a []json.RawMessage. fillJSONIn clones each RawMessage under a sixteenth of the held body, so every item of a long Codex history was copied once per reader, per request. None of them keeps an item past its return (they marshal new output or assign into the slice), so inputList hands them elementsOf's capped subslices of the raw input instead. hasSealedAgentMessage reads an item's content the same way. Run at |
||
|
|
1537817e0d |
provider: a partners.json that doesn't parse is kept aside before a try writes over it (#3362)
loadPartners reads a partners.json that is there but doesn't parse as
an empty cache: no list, and no Seen. Before 603408f38 only a fetch
that got the list wrote the file, so the loss waited for one. Now every
try writes it before the fetch is sent (Tried), offline too, so the
first try after a start wrote the empty cache over it: Seen holds the
presets of partners no longer listed, which providers added from them
still use (their endpoints, regions and key page), and those were gone.
A failed read is unknown, not empty (docs/code-standards.md).
savePartners now goes through lastgood.KeepUnparsed first, as
balance_history, credits_daily and codex_switch do for files their
readers take as empty when they don't parse: such a file is copied
aside as partners.json.bad-<time> before it is written over, and a
file that can't be read at all (or a copy that can't be kept) is not
written over. A file not there, or empty, writes as before.
Old data: a file already written over by 603408f38 is not in any
release (603408f38 lands in the same push), so nothing is lost before
this; a partners.json damaged earlier was written over by the next
successful fetch, as it still is, now with its copy kept.
Run (tree of this stack, on
|
||
|
|
c5e71f7a0b |
netproxy: a system proxy read that answers within readWait is what the request waiting for it goes through (#3421)
Review of 3370a79f7 (JoeyWu-tech's #3421). Breaking its "a request waits for a read until since+readWait" by hand (wait = 0, so every request went on at once with the proxy held, Proxy{} on a first start) turned its tests red only through an incidental read count, not through what the wait is for: magpie started where only the system's proxy reaches the vendors sending its first requests through that proxy, not direct. TestQuickSystemProxyReadIsWaitedFor holds a read, starts a request, and answers the read at once with http://127.0.0.1:7890: the request must take it. Run (tree of this stack, go1.26.8, darwin/arm64): - wait = 0 by hand: red, "the first read answered at once, but the request waiting for it took {URL: Mode:...}" (no proxy). Restored: green. - go test -tags nogui -race -count=20 ./internal/netproxy: ok (72s). The stack's full-suite record is in the #3362 fix's body. |
||
|
|
93435f27dc |
docs: the partner list is fetched on a process's first ask and hourly, and by the gateway's magpie unasked (#3362)
providers-accounts.md still said the list is fetched every 6 hours. |
||
|
|
b18a6a080b |
gateway, cli: magpie goroutines writes the running magpie's goroutine stacks to a file (#3362)
#3362's second ask: an app stuck at something could only be read by killing it, which ends what was stuck. magpie heap and magpie cpu already ask the running gateway for a profile over loopback; magpie goroutines asks it for every goroutine's stack. That works on Windows too, where there is no SIGUSR1. GET /v1/magpie/goroutines (goroutines.go) answers the callers /v1/magpie/heap answers (profileRefused: a program on this computer over loopback, no browser mark, a loopback Host; a gateway key lets nothing else in) with runtime/pprof's goroutine profile at debug=2, the form a crash prints: each goroutine's state and wait ("[select, 4320 minutes]"), its frames with source lines, and who started it. It is text/plain and no-store, and X-Magpie-Goroutine-Stats names the process (pid, program, version, window, uptime, goroutine count). Arguments are words in hex, never what they point at, so the dump holds no keys, prompts or messages; it does name magpie's source files and the program's path, which the usage says. magpie goroutines [<file>] writes it to <file>, else magpie-goroutines-<date>-<time>.txt in this folder, 0600 and never over a file there, then prints the file and the process. --help, -h and help print the usage and ask nothing; a flag it doesn't take, "-", a blank name or a second file are refused before the gateway is asked. A magpie older than this one answers 404 and is told to update; with none answering, it says so. The refused callers TestHeapProfileOnlyToThisComputer listed move into profileCallersRefused, which the CPU test and the new one share. Run on |
||
|
|
a2cef8bf4f |
provider: partners.json keeps when the list was last tried and how it ended (#3362)
"partners":null} for three days, and nothing told a fetch that failed every time from one that never came back, or from none being asked. A failed fetch wrote nothing and logged nothing. refreshPartners now keeps two fields with the list: - tried: when the last fetch started, written before it is sent; - error: how it failed (whitespace folded, cut at 500 runes), cleared when the next one starts. Read together: error set, the last try failed; tried after at with no error, a try is still out; tried long ago, nothing has asked since. A failure is logged once until its error changes or a fetch gets the list again, and the fetch that gets it after a failure is logged too. The desktop app's log goes nowhere a user can read, so for the app the file is what tells. Checked for #3362 on the way: v0.1.1296's fetch, keep and save, given the bytes /api/partners serves now (Kimi Code, listed from 10-23 00:00 +08:00) over the 10-20 file, writes the file, with the icon fetched or not. So it isn't the save or the list. Run on |
||
|
|
f252b403d3 |
provider: the icon prune leaves a listed partner's logo, so the add sheet keeps drawing it (#3424)
partnerIcon keeps a partner's logo in the icons folder beside providers.json and, while its iconUrl stays the same, uses the file it kept as it is ( |
||
|
|
4725c772bb |
netproxy: a hung system proxy read holds no request; a failed one keeps the last proxy (#3421)
System() ran readSystem under sysCache's lock, and on macOS that is scutil --proxy, started with proc.Command and no timeout. When neither magpie's settings nor the environment name a proxy, every request's proxy comes from there (For, through Func: http.DefaultTransport, the gateway's upstream transport, MCP, updates), so a scutil that never answered held each of them on that lock for as long as it hung, past its own deadline too: net/http looks at a request's context before it calls Proxy, not while. With no system proxy set, scutil runs again every 2 s it is asked. And a read that failed was taken as no proxy: where vendors are reached only through the system's proxy, a scutil that failed once sent the next 2 s of requests direct. The code standards' "nothing that can block runs under a lock its reader needs" and "a failed read means unknown". Found while chasing #3362, an app whose partner fetch never came back. Nothing there shows scutil was what hung; it is the one wait on that path with no end. Now: - One read runs at a time, outside the lock. A request waits for it until readWait (2 s) after it began, then takes what was read before. Before the first read that is nothing, so direct, as a failed first read was. A read already past readWait holds nobody. - A read that fails keeps what was read before, and the read after it holds nobody either: requests go on with the proxy read before until a read answers. - scutil gets toolWait (10 s) and is then ended (readTool, through proc.CommandContext), and that read fails. - Windows' registry: a key or value that isn't there is no proxy, as before; any other error is a failed read. Elsewhere there is no system proxy to read, and nothing changes. ggbdpq's patch on #2562 has testenv stand in for scutil with exit 1. Under this change that read fails with nothing read before it, which is still no proxy, so it does what it did. What was run (tree 6f5e4b92, on |
||
|
|
ba4b754b22 |
gateway: a relayed Chat stream's tool call with no index is given its call's (#3386)
xianfeng-zhu (#3386): Cursor's Private Inference on magpie's /v1/chat/completions, a Gemini model behind it, failed every turn that made a tool call with AI_TypeValidationError at choices[0].delta.tool_calls[0].index ("expected number, received undefined"), then a 499 loop; turns without tools went fine. Gemini's OpenAI-compatible API sends its calls with no index (Linka's frames in gemini_compat_cut_test.go have none either), where the OpenAI contract has one on every fragment, and a relayed stream went on without one. The AI SDK's OpenAI provider, which the report names as what Cursor reads Chat with, checks every chunk and turns that one away, so the call is never made. OpenAI's own node SDK, through its stream helper, keeps no call at all. chatTidy, which already mends a relayed Chat stream's empty ids, empty names and "stop" after calls, now gives a fragment with no index (none, or null) the index of its call (streamCallIndexes.give). A fragment with an id other than the open call's, or after the first in its delta, starts the next call, as chatDecoder reads a new id; any other goes on with the open one. So two calls in chunks of their own are 0 and 1. Given both 0, as their place in the delta would give them, OpenAI's node SDK merged them into one call with both arguments run together. A fragment with an index keeps it, and a stream whose calls have theirs goes as it came. It runs before the ids are mended, so a call with no id either (#3386's chunk) gets both. Not changed: the translations write an index already (chatEncoder, chatWholeEvents), and a whole reply's message needs none. Nor is a call given a type: Gemini's frames have "type": "function". The report's chunk has neither an id nor a type, and is taken as cut short: magpie gives a call with no id one (#2611, v0.1.1277), so the chunk it sent would have had one. What was run (tree e6023c66, on |
||
|
|
9a2106220c |
gateway: a background sub-agent's notification after tool results reaches the Claude run (stones_2026 on Discord)
Claude Code 2.1.310 runs Agent sub-agents in the background by default.
When one ends while the main agent is mid-turn, Claude Code tells its
model with a <task-notification> in a {role: "system"} message after the
tool results (several that end together share one text block), or as a
text block of the results' message. On the Claude subscription path
saidWithResults drops every system message that isn't the user's own
mid-turn words (#2060,
|
||
|
|
83234fe920 |
gateway, gui: the skills an agent lists are their own part, not memory
The owner (10-24, on the Routing context map's "技能 / 记忆 · 9.6K"):
为什么这里又叫技能,又叫记忆?Skill 跟 Memory 应该是不一样的东西. The
gateway put Codex's <skills_instructions> in the memory part beside the
instruction files and reminders, so the tile said Skills of Memory.
Claude Code's skill list wasn't seen at all: it sat in its environment
message, counted as the system prompt.
- gateway: PartSkills ("skills") comes after tools. Codex's
<skills_instructions> goes there. So does Claude Code's list, from
"The following skills are available for use with the Skill tool:" to
the next blank line, taken out of whatever text holds it: its own
prompt, a harness message or a reminder.
- Routes kept before this (routing history) are read with an item
tagged skills moved out of memory into the skills part, so old
requests read the same way. The text view re-reads the body and finds
them under skills too.
- Usage's context baseline counts skills, as it did inside memory.
memory-heavy is now instruction files and reminders alone.
- gui: the card has a Skills part (slate, --c7), with its note in en,
zh, zh-TW, ja and de. The text view's "no longer kept" line is one
helper instead of two copies of the sentence, which makes the room for
it under the core script budget, with no room added.
Run (darwin):
- go test ./internal/gateway -run 'Text|Prompt|Context|History|Skill|Route'
ok; go test ./internal/gui ok; go vet both, gofmt clean.
- New: TestPromptOfClaudeCodeSkills (on testdata/workdir's real Claude
Code 2.1.296 body: 1502 tokens of skills out of the 2130-token
environment item), TestSplitSkillsEnds, TestSkillsApartOfKeptPrompt.
Broken by hand (splitSkills and skillsApart made no-ops): all three
red.
- GUI, chromium and webkit: context-map 22/22 (new: the skills tile's
tip names Skills and not Memory in every language, and it isn't
memory's colour), context-window 24/24, context-text 20/20,
context-scroll-end 14/14, routing-context-fold 24/24,
routing-ctx-still 16/16, i18n-keys 4/4.
Not run: the whole GUI suite (load ~400 on the box); a live Codex or
Claude Code request through the real app.
Not changed: the "system prompt, tools and memory" wording of the
baseline's tags, which now count skills too.
|
||
|
|
e219f699ca |
gateway: with no S3 bucket the request archive keeps calls on this computer, oldest removed past 1 GiB (CyberCaius)
CyberCaius on Discord: "请求存档只能存在 s3 存储桶里,不能保存在本地吗". The Usage page's Request archive switch refused without an s3:// sync. Now, with no bucket, the same switch keeps each call in <settings.Dir()>/request-archive/<date>/<id>.json: the same file the bucket gets, masked the same way (Archived, archiveRequest), written to a temporary file beside it, synced and renamed, 0600 in a 0700 folder. Past its size (RequestArchiveLocalMB, 1 GiB unless set) the oldest calls go first, down to a tenth under it; the call just written is never removed, empty day folders go, and a .part file an hour old is removed on the next scan. The running total is counted once and then added to, so a write walks the folder only once it is over. On by default or a switch: a switch, still off unless turned on. Bodies can hold secrets, so nothing is written to a disk where the user didn't ask. The local switch is its own field, RequestArchiveLocal, in KeepOwn with its size, so sync never turns it on at another computer, and RequestArchive synced from a computer with a bucket keeps nothing on one without (archiveDest). The GUI switch writes RequestArchive while sync has a bucket and RequestArchiveLocal while it has none; the tooltip names the folder and the size, and a failed write reads "Not saved" (en, zh, zh-TW, ja, de). GET /api/archive reads this computer's copy first, then the bucket. The Settings page's save keeps both fields (api.go). Docs: sync-backup.md and gui-shell.md say where the archive goes and why the switch is per computer; the privacy pages (en, zh, ja) say what the folder holds, that it is off by default, and how large it grows. The READMEs' Privacy is about what is sent and is unchanged. app.js stays under TestCoreScriptBudget (its comment was shortened, and one t() call folded); no budget raised. Run (worktree diff on |
||
|
|
f6a96b2f0b |
usage: a change time with a fraction settles in 100ms, so a read after an append hashes no log (#3394)
readLogSnapshot checks its snapshot against a SHA-256 of the log's whole prefix whenever the log's change time is under a second old. Under steady traffic every read came within a second of the gateway's last append, so each one hashed the whole usage.jsonl again: 1.8 times the log for each append and read. A stamp with a nonzero fraction of a second comes from a clock that ticks in milliseconds (APFS in ns, Linux's coarse clock 1-10 ms, NTFS ~15.6 ms), so it settles in logFineSettle = 100ms. A stamp in whole seconds (HFS+, FAT, a share) keeps the one-second settle. Run: - go test -count=1 -timeout 45m ./internal/usage/ ./internal/budget/: ok. - TestUsageReadAfterAppendHashesNothingOnAFineClock (20000-row log, 5 appends, each followed by two reads): fine stamp 0 bytes hashed; whole-second stamp 50.7 MB. Broken by hand (logFineSettle = time.Second): 54 MB hashed, red. - Real account, sandbox HOME, a deepseek-only providers.json and a 98 MB usage.jsonl (the owner's own log, repeated 50 times). magpie serve took 30 real /v1/responses calls with a Codex user agent to deepseek/deepseek-flash, all answered, while /v1/magpie/usage?period=today (the Usage page's read) was polled every second. Process CPU time, two runs each: before 3.11 s and 3.05 s, after 1.95 s and 2.25 s. The same calls with /v1/magpie/quotas polled cost 0.2 s on both binaries, since that path never reads the log. - gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui ./internal/usage/ clean. Not tried: an HFS+ or FAT volume (the test skips when the file system gives whole-second stamps, and covers that case by truncating the stamp); the full suite at this head runs after the push. |
||
|
|
2dfaf75539 |
redact: a masked body is held at its size, not in a buffer grown by doubling (#3383)
With masking on, the masked body is what a request holds while it
streams (MaskJSON, 285 MB live in the report's heap). walk built it in a
bytes.Buffer grown by doubling, up to twice the body. It now makes room
for the body and a sixteenth at the first value it masks, and copies the
result to its size when placeholders grew it past an eighth spare.
Run:
- the heap probe, 8 requests of 9.7 MB held mid-stream with Privacy
masking on: 138 MB before, 86 MB after (Anthropic to Anthropic);
translated to Chat 235 MB before, 183 MB after.
- TestMaskedBodyHeldAtItsSize: green; red with both changes off
("the masked body of 4356589 bytes is held in 7077888").
- go test ./internal/redact/ ./internal/masking/ ok; gateway -run
'Mask|Redact|…' ok (see the commit before).
|
||
|
|
106a245502 |
gateway: a request's body goes once it is answered, not when its stream ends (#3383)
The transport holds a request until its reply's body is closed, a
stream's whole length, and with it the bytes.Reader body and the GetBody
NewRequest made over it. So every streaming request kept the body it
sent upstream alive to its end: for a Claude Code request translated to
Chat, the marshalled body (marshalRaw/appendHTMLEscaped in the report's
heap, 503 MB live).
provider.SetBody gives a request a body whose reader drops its bytes
once read and whose GetBody reads them again until provider.LetGo.
forwardOnce lets go once its retries (RetryOneAuth, RetryZhipuCoding)
are done; Codex's zstd turn, Copilot Auto's model swap and Gemini's Code
Assist envelope set their bodies the same way, so LetGo reaches them.
Run (worktree perf-stack, on the four commits before it, over
origin/main
|
||
|
|
b0d0092be5 |
middleware: a streaming request's runtimes let its body go once its request hooks are done (#3383)
A request keeps its middleware runtimes until its reply has streamed,
so its hooks share ctx.state, and moejs kept the body each hook was
given, parsed, in the runtime's registers until End: a long context's
body was alive for the whole reply, ~10 MB for a 7 MB body. The report's
inuse profile had 448 MB under moejs ParseJSON with many agents
streaming at once. Request and Tried now call ReleaseCallData on the
request's runtimes once their hooks are done; ctx, and what ctx.state
holds, stay. Not after each onEvent: an event is small and its hooks run
a thousand times a reply.
Run:
- TestStreamingRequestHoldsNoBody: 8 requests streaming with a 7 MB
body hold under 7 MB, and onEvent still reads ctx.state; with the
release commented out by hand it fails ("8 streaming requests hold 69
MB, their body is 7 MB").
- go test -count=1 ./internal/middleware/ ./internal/gwmw/: ok.
- go test -count=1 -run 'Middleware|Think|Strateg' ./internal/gateway/
./plugins/...: ok.
- gofmt -l clean; go vet darwin, GOOS=linux and GOOS=windows -tags nogui
clean for internal/middleware.
|
||
|
|
4753a6cfbb |
gateway: a look at the routing history reads today's file only past what it counted, and parses only its latest routes (#3383)
The Routing view asks /api/gateway/history every 15s while requests are
done. History read a day's .jsonl whole whenever its size had changed,
which today's always has, so a busy day's 350 MB file (19,751 routes in
the report) was read through at every look, and asking for today
unmarshalled all its routes to keep the latest 2000. Now a .jsonl's
count is kept with where each of its lines starts: a look reads only the
bytes added since, and the asked day parses its latest historyMax plus
200 lines (historySlack, for a route done after later ones began). A
last line without its newline is counted, as readDay reads it, but
tallied again at the next look, as it may be half written; a file
smaller than what was counted is counted again from its start. .gz days
are read as before, an asked one skipping the unmarshal of all but its
latest lines.
Run:
- TestHistoryReadsOnlyWhatWasAdded: ok; red on the old history.go
("want 2252 requests", got 2251: it read the blanked routes again).
- BenchmarkHistoryLook (20k routes, ~100 MB, one added per look):
54.1 ms/op on the old code, 1.19 ms/op now.
- go test -count=1 -run 'History|Trace|Route' ./internal/gateway/
./internal/gui/: once exited 1 with the failing test's name lost to a
tail; rerun with the whole log kept, then -count=3: ok every time.
- gofmt -l clean; go vet darwin, GOOS=linux and GOOS=windows -tags nogui
clean for internal/gateway.
Not done here: the route's Order list's size on disk, and moejs's
retained JSON (#3383's other two findings).
|
||
|
|
f8fa8147ba |
sessions: a page-asked first read uses half the cores, not twice them (#3238)
The index's cold scan with a page waiting started min(max(8, 2*NumCPU),
32) readers, as if reading waited on the disk. On an SSD decoding and
parsing is the work: on the Windows box (32 cores) a cold start over
6751 real Codex session files (15156 MB) with /api/sessions waiting
held 2154% CPU, the ~2000% the reporter saw, while other apps ran
beside it. Now max(2, NumCPU/2) readers; the quiet warm-up's NumCPU/4
slots are unchanged.
Run:
- TestAskedIndexReadsWithHalfTheCores: ok; with the old count put back
by hand it fails ("the index read 28 files at once, want 2 to 7").
- go test -count=1 ./internal/sessions/: ok (64s).
- gofmt -l clean; go vet darwin, GOOS=linux and GOOS=windows -tags nogui
clean for internal/sessions.
- On the Windows box (32 cores), a cold read of 14051 session files
(~44 GB) with a page waiting, magpie built from this commit's parent
against this one: peak CPU 1634% -> 1172% (about 900-1100% sustained),
peak working set 1612 MB -> 1108 MB, ~22s -> ~27s to read them all.
|
||
|
|
fc9430e12d | proc: Windows lists processes from a Toolhelp snapshot, not a new PowerShell and WMI each time (#3467) | ||
|
|
b5d46acbed |
agent: Kiro Crew runs on a harness connected to magpie
Vincent on Discord asked for Kiro Crew (kirodotdev/KiroCrew v0.9.0: the KiroCrew.app desktop app, the kirocrew CLI, its dashboard and the Gateway on :5476). Crew has no model provider of its own. It runs each session on an ACP harness picked by agent.acp_backend (and dispatched members by agent.member_acp_backend) in $KIROCREW_HOME/config.json, default ~/.kiro/crew (src/kiro_crew/config/paths.py, loader.py, sections.py; ACP_BACKENDS_MEMBER_DISPATCH in agent_sdk/backends.py). Connecting sets those keys to an agent already connected to magpie, tried in this order: Codex, Claude Code, OpenCode, Pi, Goose. One whose ACP adapter is installed (codex-acp, claude-agent-acp, pi-acp) wins, so one click is enough. magpie looks for the adapter where Crew does and installs nothing; when it's missing, the notice gives the npm command. With no harness connected the connect is refused with a message naming which agents to connect. A harness set in config.local.json wins over config.json, so magpie doesn't write it and the row says so. The previous values are stashed. On Disconnect they are put back, but only for keys that still hold what magpie wrote, and a file magpie created is removed once it's empty. The row reads as connected only while its harness is still wired to magpie. deepseek is not offered: Crew runs it as dsh --profile acp, which magpie's dsh wiring doesn't reach. KIROCREW_HOME and the adapter path variables are read from the login shell (agentenv). Run (Go and the GUI files at base |
||
|
|
3840333c51 |
site: APIKEY.FAN is a README sponsor
APIKEY.FAN added a README seat to its in-app one. README.md shows its
English logo ("Enterprise AI Gateway"), README.zh-CN.md its Chinese one
("企业级 AI 中转站"), each with a dark copy whose #111111 lettering is
#F2F2F2, the orange mark unchanged. Both link usemagpie.ai/go/apikeyfan/readme,
which sponsors.js sends to apikey.fan/?aff=mg_readme, the link APIKEY.FAN
gave for the README.
Run: node --test site/*.test.mjs (30 of 30 ok). The four logos rendered
with rsvg-convert on white and on GitHub's dark background and looked at.
After the deploy, /go/apikeyfan/readme is checked for its 302.
|
||
|
|
3d758d0345 |
gui: Settings › About's Version row keeps its height while the update read is out (#3469)
xisdumpling: going back to Settings › About from another page made every row jump up about 12px and back. renderSettings rebuilds #about, and the new Version row had no line under its name and no Check button until renderUpdate's GET /api/update came back. Now renderUpdate keeps the last state it drew (updateLast, which renderUpdateBadge's read at start fills in too). A row made again draws that state at once, then reads. Once the read is back it bumps the row's sequence, so timers the early draw started stop. There are two exceptions: - no early draw while a check is out (the old code drew the row blank, then "checking"); - Download from GitHub clears the cache before it redraws Settings, so the mirror's old error isn't drawn again. Size: app.js and the core are under their budgets, which are not raised. No function in app.js has a single plugin as its only user, so the room came from renderUpdate itself: one opener for the release page (4 copies), one dim() (2) and seqOf(r) (9). Run, at a3b8d706e's tree rebased on |
||
|
|
7765f27fcc |
gateway: a model an account refuses goes on to the accounts not listing it yet
01huadalang (Discord): Antigravity with several accounts, only some can
use Gemini 4. The model and its bar showed only after the right account
was made preferred and probed, and a request failed with the preferred
account's error instead of going on to the account that serves it.
st3lland (Discord): on ZCode (plugin) accounts serve different models.
Owner: no manual setting, magpie knows per account and routes.
Two causes:
- perKeyBarred puts an account whose own saved list lacks the model in
pl.unlisted / pl.left (Unlisted) and serve never asked it. So when
the listing accounts refused the model (Antigravity's real 404
NOT_FOUND "Requested entity was not found.", codeAssistModelMissing;
plugins through modelRefused's unservedWords), the agent got that
error even though an account whose list was simply stale serves it.
Now, once every listing account of that subscription/model has been
asked and one refused it as unserved (unservedTry), its unlisted
accounts are asked next, right after it and before any other member
or fallback (unlistedNext, askUnlisted for the trace). The refusing
try rests as before (restAfterMarked, for that model). Not for a
pinned account, a sealed conversation or strict affinity; a gateway
key's account list narrows unlisted too (allowedCandidates). Other
refusals (403 PERMISSION_DENIED, 429 RESOURCE_EXHAUSTED) don't open
the unlisted accounts.
- Antigravity's per-account lists were refreshed only on the first
listing, a probe, a sync or a Refetch, so a model granted later and
its bar (chosenWindows filters by exposed models) stayed hidden. Its
quota reading already fetches fetchAvailableModels per account; now
it saves that account's list (noteAntigravityList) and re-merges the
pooled list from every On account's list when it changed. An Off
account's reading changes nothing.
Other vendors: the unlisted route only opens on the existing unserved
classifiers (Antigravity's 404, plugins' unservedWords), unchanged here;
TestUnlistedAccountNotAskedForOtherRefusals holds that the other real
Antigravity bodies don't open it.
Run (at the rebased head on origin/main
|
||
|
|
5222a4b129 |
gui tests: segment-press-dialog waits for the add sheet the page opens itself
With no provider, the Providers page opens its add sheet itself once /api/providers is in (app.js renderProviders), and the add button goes away. The test pressed #addProvider right after goto: when the list came first, as it does on a busy machine, the press waited 30s for a button that was gone. It was red 1 of 2 runs at f35c721c4~1 (load ~310) and 3 of 4 in the 112-file #modal run; the test now waits for the sheet's tile instead. Run: segment-press-dialog, chromium and webkit, en and zh, 3 runs in a row: 4/4 ok each. No other test that presses #addProvider has an empty list. |
||
|
|
3d56822d41 |
gui: a provider's editor grows from where its row was pressed
The owner (10-24, 点击这里,然后放大弹窗的时候,应该从点击处可放大吧): pressed past its name, a provider row's editor grew from the row's left end, its logo and name, not from the press. Pressed on the logo itself (the row's drag handle), it didn't grow from the row at all: the handle was recorded with no way to find it again once the row was drawn anew, so the dialog opened with no morph. The press now keeps its x. rowOwnRect still takes a strip the size of the logo and name, and when the press is past them it centres that strip on the press, inside the row. A press on .pv-handle counts as the row's. Closing goes back to the same strip. Run (darwin, chromium and webkit, on d0a54d74a's calm() refactor): - modal-morph: 6/6 ok at 1240 and 420px. Its first open now presses the logo, and a new case presses at 62% of the row and checks the strip: centred within 3px of the press, as wide as the first one, inside the row, closing back to it. Broken by hand: without the handle mapping, red at "opening clips the dialog: none"; without the centring, red at "again: the strip centred on the press". - modal-centred-late 6/6, group-morph 22/22 ok. - go test ./internal/gui -run TestCoreScriptBudget: ok, with no room added (calm() made the room). Not run: the whole GUI suite (load ~400 on the box); the real Wails app. |
||
|
|
ed0425fc9f |
gui: every reduced-motion check in app.js asks calm()
app.js asked matchMedia("(prefers-reduced-motion: reduce)") in nine
places, and calm() did the same as a const defined at the dialog code.
calm is now a function declaration, so code above it can call it too,
and every other place asks calm(); stillMotion and navCalm stay its
names where they were. Nothing changes in what moves: this frees ~470
bytes of the core script budget for the next change (the editor
growing from where its row was pressed).
Run (darwin, chromium and webkit):
- node --check app.js: ok. go test ./internal/gui -run
TestCoreScriptBudget: ok.
- GUI: modal-morph 6/6, held-animations 4/4, routing-ctx-still 16/16,
context-map 22/22 ok.
Not run: the whole GUI suite (load ~400 on the box).
|
||
|
|
31275d0734 |
gateway: a history call to a tool the request doesn't declare gets a stub where it is refused (pi, T3 Code tool_search)
Gearclickist on Discord: pi and T3 Code, on magpie's /v1 chat/completions,
load tools on demand. The tools a tool_search found are called in the
history but not declared in the next request's tools, and pi sends
"tools": [] with history calls when it has no tools left.
Cause, per upstream (magpie forwarded the calls unchanged on every path,
seen in a probe through fakes):
- Anthropic Messages (API, Bedrock/Vertex Claude, relays): a call to a
tool it isn't given is accepted, but calls with no tools at all get
400 "Requests which include tool_use or tool_result blocks must
define tools". anthropicBody dropped tools when the request had none,
so pi's tools: [] turn failed. Now each tool the history called is
declared as a stub (any object, "Called earlier in this conversation;
not available now.") with tool_choice none, as LiteLLM's dummy tool
and the Kiro plugin do.
- OpenAI Chat/Responses, ChatGPT backend, Gemini/Code Assist: take the
history as it is; left as sent (TestUndeclaredHistoryToolTakenAsSent).
- Stricter Chat/Responses/Messages upstreams (relays in front of Kiro or
Bedrock, vendors that check each call's name): a 400/422 that names an
undeclared history tool as not found/unknown/not defined, or says tools
must be defined beside the calls, is asked once more with a stub per
missing tool, relayed or translated, and remembered per provider and
API (historyToolsRefused). tool_choice none only where the client
offered no tools. Namespaced Responses calls are left to the namespace.
- Claude subscription: runs real Claude Code with the history as text,
not affected. Kiro plugin already stubs its history's tools.
Run, at 54874c9ee rebased on origin/main:
- the new tests and the gateway's ToolStrict/Anthropic tests: ok
- gofmt -l: clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: clean (before the rebase)
- go test -tags nogui ./... -timeout 45m was running at the pre-rebase
commit when this was pushed (ship-immediately); its result goes on the
tag's report.
Broken by hand, each red, then restored green:
- the refusal matcher off: RefusedThenStubbed (chat, responses,
anthropic) and ToollessHistoryRefusedOnChat red
- the remembered upfront stubs off: RefusedThenStubbed red (3 asks)
- anthropicBody's stubs off: ToollessHistoryToAnthropicDeclaresStubs red
- the stubs' tool_choice none off: same test red ("tool_choice \"\"")
Not tried: no real vendor was asked (fakes only); the refusal wordings
for stricter vendors are modelled, not captured from the reporter, who
named no upstream; the other community plugins' own translators
(Cursor, Devin, Qoder, ...) were not read for this; real pi/T3 Code not
run against this build.
|
||
|
|
b995095637 |
gui: a routing group's strategy is switched from its row (MoChou, #3450)
MoChou (#3450): changing a routing group's strategy took opening the editor, finding the routing control, picking and saving. The routing tag on each group row is now a pop-up button: it opens the app's own menu (openProtoMenu, no native select) with the routings the editor offers (GROUP_ROUTE_OPTS plus JS plugin routings), the current one checked. Picking one saves the group through /api/groups/save with every other field as it was, as the editor's Save would. Manual keeps the pick the group had; with none the gateway takes the first member (provider.cleanGroup), as with the editor. "Rate limited to the back" is dropped when the new routing can't sink, as the editor does. Re-picking the checked routing saves nothing; an editor with unsaved changes asks first (confirmDiscard). The row's Edit button and switch are unchanged; clicking the tag doesn't open the editor and doesn't scroll. Keyboard: Enter/Space opens, arrows move, Escape closes back to the tag, and focus returns to the same group's tag after the save redraws the list. At <=560px in the window the row keeps only its routing tag (the other tags stay hidden as before). New string "How {name} routes: click to change it" in zh, zh-TW, ja, de. Run (worktree; the new test, i18n-keys and internal/gui budget/i18n tests again at this head after rebasing on |
||
|
|
137187a401 |
gateway: Claude Code's auto mode classifier follows a /model switch at once
CyberCaius on Discord: after switching models, the first auto mode permission check went to the previous model. The model is Claude Code's choice, not magpie's. Claude Code 2.1.310 ($Xe/BB) names ANTHROPIC_DEFAULT_SONNET_MODEL for the classifier, not the session's model. magpie's sonnet tier follows the main model only once Follow runs (the GUI's state poll), and Claude Code reads env again only on its next start. So right after /model the classifier named the old main model. At the gateway, a classifier request (recognised from its body: a <transcript> and a <block>/<severity> verdict, no tools) on a sonnet tier that follows a main model settings.json no longer has goes to the tier the new main model gives it (followAt, keeping the tier's effort). It is left alone when the user set CLAUDE_CODE_AUTO_MODE_MODEL, when the sonnet tier is their own, when the base URL isn't magpie's, or when the main model hasn't moved. WSL distros are read the same way. Only the classifier is rerouted: a turn naming the old model may be another open session that is still on it. The haiku, opus and subagent siblings are #3474. Run (sandbox HOME; packages at |
||
|
|
e698a688fd |
gui: Insights › Masking shows each request as sent, what was masked and how
What masking did moves out of Settings › Privacy into a page of its own under Insights (plugins/redact: client.js, page.js, redact.css, i18n.js). Privacy keeps how it is found and what to mask, with a "What was masked" row that opens the page. - The top card is Privacy's card, made shorter: the flow animation (agents → this computer → providers) with magpie's bird on the centre line and "magpie masks it on this computer" under it, so a screenshot says who masked it; the count and a 7-day bar. Nothing the list repeats. - The list: one row per masked request, narrowed by kind, by who found it (rules or the local model), by agent or provider, or to held-back requests; or by value, each with how often it was put back. - A request: the message as it went to the vendor beside the original, each mask marked, unchanged parts folded; picking a value lights every place it was masked; a held-back request offers "Mask it instead". - Gateway's masked badge and ?view=masking&key=N (trace.go's mainView) open one request. - Classes are msk-: library.css owns mk- (a first cut stacked the flow). - Budgets lowered to the core's size after the move. - Not shown: rule names and the local model's confidence; the records don't keep them. Run on |
||
|
|
51667a34c6 |
maskrec: records narrow by several kinds, by who found them, and to held-back requests
The Masking page's facets ask for a set of kinds (Secrets is API keys, passwords, private keys...), for what found the values (rules or the local model), and for the requests held back. Filter.Kind takes a comma list, Filter.By and Filter.Blocked are new, and /api/masking/records passes by= and blocked=1 through. Run: go test ./internal/maskrec ./internal/gui -run 'Filter|Records|Masking|MainView|ShowMain' ok. |
||
|
|
9b57261b62 |
masking: a record keeps its request as sent, how long masking took and what the answer put back
For the 观测 › 脱敏 page's request view. In memory only: the masked body of the latest 100 requests (each up to 4MB, 64MB in all), and by placeholder how many places of the answer had the value put back (redact.Writer.Put, counted once per place even when a stream splits the placeholder). Took (µs) is written to disk too; it holds nothing of the request. GET /api/masking/sent?key= gives the body, POST /api/masking/values the values the masker still remembers, both no-store. Run: go test ./internal/maskrec ./internal/redact ./internal/gui -run TestMaskingRecordsAPI and ./internal/gateway -run TestMasked; ok. Broken by hand: without toldBack, TestMaskedRecordKeepsSentAndBack is red. |
||
|
|
344d11484e |
provider: Remove takes the account listed, by its slot, not a hidden one of the same name
dev (Discord) couldn't remove a ZCode account. The ZCode app's own
account had been removed in magpie (hidden), and a second one signed in
through magpie had the same name. Two things in the source caused it:
- editSideLogin matched the first saved entry by agent and name, hidden
ones included, so Forget took the hidden "zcode" slot. It signed out
the ZCode app's own account and left the listed zcode#l47q19 one.
- pluginLogins applied the own account's name (pluginOwnUser) after
pluginLabels had added the slot suffix to tell same-name accounts
apart, so both read "dev@z".
Now:
- pluginLabels applies the own names first and adds the suffix after,
so the listed names are unique ("dev@z (l47q19)").
- Forget, Switch and On/Off resolve the name against the accounts as
listed, then edit that saved entry by its slot (Home) or own-ness
(listedMatch/sameSaved). editSideLogin, which the other callers use
(chatgpt_api, copilot_lapsed, google, signin_revoked), prefers a shown
entry over a hidden one of the same name.
- A saved id doesn't help here: it is made from the name, so both
accounts had the same id (66dbee89c5d33fcd).
Existing data: an account whose name collided with another one is shown
with its slot suffix from the next read on. Nothing is rewritten.
Run:
- go test -tags nogui -timeout 45m ./... in a sandbox HOME: ok, every
package, at
|
||
|
|
f35c721c48 |
gui: a dialog stays centred while its content comes in, until it is pressed
The owner (10-24): a plugin's page opened low, not in the middle. It opens short, with a skeleton, and its README comes after; holdModal held the top the skeleton had put it at, so the dialog grew down to the window's foot and sat low. Until the reader's first press or key in it, holdModal now keeps the dialog centred over what it holds, measured by its layout height (content that comes during the open's morph was read under its scale). From the first pointerdown or keydown it holds its place as before, so what is under the pointer doesn't move. Run (darwin, chromium and webkit, logs kept whole): - modal-centred-late (new): 6/6 ok, 3 runs in a row; on the old app.js red at "centred after the README came" (bottom gap 0, top 181.5). - The 112 GUI files that use #modal: started, not finished at the push; the owner asked to release without waiting. Reds it finds get their own commits. TestCoreScriptBudget: main was already 208 bytes over the core budget (f5b1d36ff's refresh and ce5b23cdb's spinner, each checked alone); with this change's ~1.1KB both budgets are raised to the exact sizes, with no room added. go test ./internal/gui -run Budget: ok. Not tried: the real Wails app; Windows and Linux webviews. |
||
|
|
c819e00c4e |
routing: a ClinePass route reads as its route, with what was asked for (zRain)
zRain (Discord #feedback, 10-24; magpie 0.1.1377, Windows, Codex CLI 0.164.0) asked clinepass/cline-pass/deepseek-v4.1-flash-1017 from Codex (/backend-api/codex/responses -> /v1/chat/completions, 200). The reply named vmc/deepseek-v4p1-flash-1017-contributor-fallbacks. Routing showed "served vmc/..." titled "likely another model", with no upstream. What was found: - The pin goes out on Codex's Responses path the same as on a Chat client's. The test below checks the sent body on both paths. The built-in ClinePass pins only with "DeepSeek and GLM models only from their makers' own APIs" ticked. The Cline plugin pins Pass DeepSeek by default. zRain's id is the built-in, so with the tick off nothing asked for DeepSeek. - upstreamOf reads finalProvider from choices[].delta/message provider_metadata on every path (Codex streamed, chat streamed, Responses streamed and not). zRain's rows had none, so the reply most likely carried none there. canonicalSlug is not recorded; left alone. - The contributor-fallbacks name is ClinePass's own route. Its name does not mean another model. Change: - provider.ClinePassAsked: the upstream a request asks the Cline API for (ClinePin with the tick, or deepseek on the plugin's provider). - Try.Pin records it on the answering try. - Routing: a cline-pass/ model served as vmc/... is tagged "ClinePass route ...". Its title and story say it is the route's name, not another model's, and then one of: - who answered, when the reply said; - that the asked provider wasn't confirmed; - that nothing was asked, naming the tick for DeepSeek/GLM. - The Usage page's Requests title says the route too, without the pin it doesn't keep. - Strings in zh, zh-TW, ja and de. What was run (rebased on origin/main |
||
|
|
f5b1d36ffa |
usage: a card's refresh opens after its "Refreshed just now", so the text never moves
The owner: on hovering a usage card, the refresh icon appearing pushed "刚刚刷新" right each time. The icon opened from width 0 in front of the text, so the text moved by the icon's width on every hover. The refresh button now comes after the text in every place quotaRefresh is put (the read-when line, a panel row's name, the panel's error line, both panel sub lines, and a failed window's line after its fix button), and opens rightward into the card's padding: open, it is 14px with a -2px right margin, so the text before it stays where it was. A panel row's name ellipsizes rather than being pushed. Run (darwin, chromium and webkit, logs kept whole): - usage-card-refresh, panel-quota-refresh, quota-curve, quota-balance-error, usage-remote-key-limits, usage-remote-cards: 144/144 ok - quota-refresh-order, usage-refresh, i18n-keys: 17/17 ok usage-card-refresh's hover check now asserts the text's rects don't move when the icon opens and that the icon sits after the last of them; on the old code it fails at the text moving. Not tried: the real Wails app; the Windows and Linux webviews. |
||
|
|
ce5b23cdb4 |
gui: adding a key shows a spinner and Adding… until it is done; the name field is narrower
The owner, on the provider editor's add-key row: a key's Add (one key, and Paste several's) only faded while the gateway checked the key with its provider, which can take seconds, so nothing seemed to happen. It now goes through saving(), the editor Save's spinner and "Adding…", takes Enter once while it runs, and gives its label back when the key is refused. The name field, only for telling keys apart, takes 1/3 of the row instead of 2/5. Run: - key-import.test.cjs, new case: spinner, aria-busy and Adding… while keys/add is held, a second Enter posts nothing, a refusal puts Add back and keeps the row, the name field narrower than the key's. 12/12, Chromium and WebKit, en and zh, at load 510. - The GUI files on the key list, provider editor and accounts (key*, provider-*, account-*, zen-anon-key, gateway-own-key, api-key-usage, keep-login, lane-limit, i18n-keys) in both engines. Four reds at load ~190: the new case (a click over the file's 5s; the file now allows 15s) and key-replace (420px, twice) and provider-advanced-fold, files this change doesn't touch; checked against origin/main after this push. - go test ./internal/gui -run Budget ok. Broken by hand: old app.js turns the new case red (Add, not Adding…); old app.css too (name 180px beside a 269px key). An injected 3.5s delay before the first post turned the case red through its 3s wait; it now waits for the posts it expects. Not tried: the real Linux and Windows apps, the whole GUI suite. |
||
|
|
48194bbee0 |
routing: an In order group's later members aren't said to go after a known allowance (bitssly on X)
bitssly on X (10-24) asked why, with a group set 按顺序 (In order), an
account whose quota isn't known "can't be used", quoting the Routing
page: "opencode:剩余额度未知,排在已知的之后。" and "腾讯-国际:剩余额度未知,
排在已知的之后。"
Cause: the gateway does what the mode says. planGroup/planLevel try an
In order group's members in the order given and never by what each has
left; each member's own accounts go as that member's provider routes
them (Smart by default, where an unknown allowance still comes before
any account at 90% or more and is tried when the known ones fail). The
explanation was wrong. weighed() gives an ordered group's rows their
member's routing (""), so the page's smart() judged each row against
every known row of the whole request: an In order group's later
members read as ranked behind a known allowance, and the first got a
Smart reason ("its allowance renews soonest ...") instead of In order.
A By weight group's first had the same fault.
Change:
- client.js: placeRouting/wholeMembers/weighedWith scope what a row is
weighed against to its own member when the level that placed it takes
members whole (order, weight). firstWhy says "In order: {who} is
first ..." for such a group, and "By weight: it's {who}'s share ..."
for a weighted one; the unknown, learns, spent and low asides are said
only of an account weighed against another of its own member. Rebased
onto
|
||
|
|
117937b8d9 |
sessions: every agent in the Agent menu and in Continue in shows its icon
The Sessions page's agent picker showed the chosen agent's icon on its button, but the menu it opened listed bare names. Each item now carries its icon between the tick and the name, level with the name; the "Continue in another agent" menu does the same. The icons are drawn by the sessions plugin after the menu opens, so the core scripts stay within TestCoreScriptBudget (a first try in openProtoMenu went 116 bytes over). Run: sessions-toolbar and sessions-talk GUI tests, chromium and webkit, en and zh, light and dark: 8 pass. Broken by hand (no icons drawn): sessions-toolbar red in chromium, "every agent in the menu has its icon". go test ./internal/gui/ -run 'TestCoreScriptBudget|Plugin' ok. Looked at the webkit zh dark menu screenshot. Not run: the whole GUI suite (load ~380 on this machine). |
||
|
|
7edf5b0a3d |
gui: the context window is a map of tiles by default, the block grid a switch away
After flohoeller's "Context map" on X. The Context window card (Usage ›
Context, and Routing's request card) drew its window as 400 cells. It now
draws it as a map:
- Each item is a tile sized by its tokens, inside its part's area
(squarified, parts in their usual order).
- The tile has a soft fill of its part's colour, its name, and
"tokens · part".
- The free space is a hatched tile that names its share.
- The used share is drawn on a gentle curve (share^0.35), so a window
8% full still has tiles to read. The free tile states the real share.
Small items:
- Items too small to read go in one "{n} more" tile.
- A part whose items would leave a strip thinner than 14px is one tile.
- No tile is laid under 700px².
Hover and click:
- A hovered tile tells its item, part, tokens and share (a part's tile
lists its largest five) and dims the others.
- A row or the legend lights its tiles.
- A clicked tile opens its text, as a cell does.
Motion:
- Tiles come in with a short stagger (opacity, scale .94, blur), over
560ms with the iOS ease.
- A live update keeps the same nodes and glides them to their new rects.
- Tiles that are gone fade out.
- With motion reduced, or on a still pane, nothing moves.
The block grid is kept. A small segmented switch at the end of the legend
(Context map / Block grid) picks the look for every card, remembered in
localStorage magpie.ctxLook. The card eases to the other look's height.
The new look is the default, and the old one stays one click away (UI
restraint, owner's ask).
The text view shows an image the request sent inline (the gateway's Src,
previous commit), where it said "An image: magpie doesn't show it here".
It fades in, and a click opens it larger with a FLIP scale. An image with
no Src, or one that fails to load, keeps the old note.
Words: "Context map" and "Block grid" in zh, zh-TW, ja and de.
The core budget goes to 1,549,478, the new size with no room added:
context.js is drawn by the Routing page as well as Usage, so it is the
core's own (+14.4KB).
Tests:
- Seven existing tests read the grid's cells. They now pin
magpie.ctxLook=grid.
- New context-map.test.cjs, in both engines, en/zh/zh-TW/ja/de, at
1100 and 420px:
- The map is the default, with a free tile.
- Every tile is inside the map, none overlap, and none is a sliver.
- Hover gives the tip and dims the others.
- A refresh keeps the nodes.
- A click opens the text.
- An inline image loads (naturalWidth 2) and opens larger. One without
Src is named.
- The switch to the grid survives a reload, and the map comes back.
- With motion reduced, nothing animates.
Run at this head (rebased on
|
||
|
|
069bf0583b |
gateway: a prompt's inline image comes to the text view as a picture it can show
The Context window's text view said "An image: magpie doesn't show it here" for every image a request carried. The gateway now reads the image's source as the request sent it (Anthropic's base64 source, a Responses input_image's image_url, a Chat image_url, Gemini's inlineData) into PromptPiece.Src, from the same masked bodies kept in memory as the text. Only a data: URL of PNG, JPEG, GIF or WebP whose payload is base64 is given: a remote URL (Gemini fileData, an http image_url) or anything else (svg, a data URL with markup in it) stays "", so the view never fetches from anywhere and never renders markup. Src is read out only when the text is asked for (read()), like the text itself. Run: - go test ./internal/gateway/ -run PromptText: ok. TestPromptTextImagesArePictures sends each protocol's image and checks its Src, and that a URL source, an svg, a data URL with <script> and Gemini's fileData come back "". - Broken by hand: read() setting pc.Src = "" turns the test red; restored, green. - gofmt -l internal/: nothing. go vet ./internal/gateway/, GOOS=linux and GOOS=windows: ok. Not tried: a real Claude Code or Codex session's image through a live gateway (the GUI side is covered by context-map.test.cjs with a fixture). |
||
|
|
1f8f80e4af |
provider: Kiro's mover min is 0.1.16 (cache unknown, not 0)
opencode-kiro-auth 0.1.16 (plugins 9f6c4e8) says magpie_cache_unknown
when Kiro gives no token counts. Before, it reported cache_read 0, which
the Routing page showed as 0% (zeewell on X). keepMovedCurrent brings
every moved Kiro user up to it.
`npm view @magpie-community/opencode-kiro-auth version --prefer-online`
gives 0.1.16 at landing. Its publish run is red only on the known
think-tags E404 (plugins#180); the run's log has
"+ @magpie-community/opencode-kiro-auth@0.1.16".
Run at this head (origin/main
|
||
|
|
436bcc946d |
routing: a request whose vendor counts no cache tokens shows no hit rate, not 0% (zeewell on X)
zeewell on X: every Kiro request in a routing group showed cache 0%, for
claude-sonnet-5.5 and claude-opus-5.5 from Claude Code, with 148k to
182k tokens and consecutive calls.
The cause, from real Kiro calls on the owner's account (read-only, from
a sandbox): Kiro does cache. A repeated 900-line prefix cost 0.0912
credits and then 0.0484, with or without cachePoints, and with a fixed
conversationId too. But Kiro's reply holds only assistantResponseEvent,
metadataEvent {stopReason}, contextUsageEvent (a percent) and
meteringEvent (credits). There are no token counts at all, and
kiro-cli 2.32's own trace shows the same. The plugin wrote
cache_read_input_tokens: 0, which magpie showed as 0%.
opencode-kiro-auth 0.1.16 (plugins 9f6c4e8) now leaves the cache fields
out and says `magpie_cache_unknown: true`. This commit reads that field:
- aUsage reads it into Usage.cacheUnknown, ORed in Usage.add.
- routeUsage sets RouteUsage.CacheUnknown (cache_unknown, omitempty) on
a try that counted no cache read or write.
- The Routing page's promptOf leaves such a try out of the hit rate. The
row and its session then show no Cache metric, as for older history.
Clients are never told the field. Usage.anthropic() leaves it out, and
a passthrough forwards the plugin's bytes as they came. The gateway
already relays cache_control to an Anthropic-protocol plugin as Claude
Code sent it, so nothing was lost on the way to Kiro.
Left alone: the usage ledger. usage.Record has no such flag, so the
Usage page's aggregate hit rate still counts a Kiro prompt as a miss.
Filed as #3464.
Run at this head (rebased on origin/main
|
||
|
|
628e18987b |
gui: Settings › Privacy puts the local model first, marked New
The owner asked for "Find with a local model" to come earlier on Settings › Privacy, where people see it at once, with a light mark. "How it's found" (#findList) moves from below the try box to right under the masking card, before "What to mask", and its first row is the local model, then Rules. The model's name carries a small accent "New" badge (.badge.new: accent-soft background, accent text; en New, zh/zh-TW 新, ja 新着, de Neu). app.js stays inside its budget with no raise (1,343,322 of 1,343,324): comments were trimmed to fit. Tests: privacy-model checks the badge in every language, that the model's row is the page's first settings row, and that #findList comes before #redactList. redact-rule-row and redact-words-any-case wheel their row into view first (wheelTo, reach): with the section above them, at 640px their row sat under the bar along the page's foot, and the second control under the sticky tabs in WebKit. Run at 35c648593 (on |
||
|
|
56b90893f7 |
provider: Command Code's mover asks for commandcode 0.1.16 and Qoder's for qoder 0.2.33, so no request names magpie (plugins #352, #354)
commandcode 0.1.16 sends the Go catalog with Node fetch's own User-Agent
and /alpha/generate with the working folder's slug, as command-code
1.88.0 does, where both said "magpie". qoder 0.2.33 names a task with
the prompt's first ten characters, as Qoder.app 0.4.3 does, not "magpie
session". keepMovedCurrent brings every moved user up to them.
Both versions checked with npm view --prefer-online at landing:
opencode-commandcode-auth 0.1.16, opencode-qoder-auth 0.2.33.
Run at this tree (base origin/main
|