Commit Graph
28 Commits
Author SHA1 Message Date
yetone dae104bfac capre: a length check, not an unrolled repeat, holds nine patterns
Go's regexp unrolls a bounded repeat into that many copies of its
class: [A-Za-z0-9.-]{0,254} (the session terminal's bundle id) was
89kB of program, kept from start to exit, and Codex's item-id refusal
`.{0,1000}?` 88kB. Measured one by one over magpie's 540 package-level
patterns (1.5MB in all), the nine largest bounded ones were ~440kB.

capre.MustCompile(expr, max) is the pattern with * or +, matching only
a string of max characters at most (rune count, so the (?i) Kelvin
sign and invalid bytes count as the regexp counted them). The nine:
settings' bundle id, library's name and agent id (now name@wsl:distro
cut in two), Anthropic tool names, the trace page's name and find,
access's MCP server, OpenClaw's profile and Codex's provider id. The
item-id refusal is a function: the tail within 1000 characters of a
head.

Run on mote (go1.26.8):
- go test ./internal/capre ./internal/access ./internal/settings
  ./internal/library ./internal/sessions ./internal/agent ./internal/gui
  . : ok; ./internal/gateway -run 'ItemID|Undeclared|ToolName|Refus': ok
- TestCappedMatchesBounded holds each old pattern against its new one
  over 14 units x 19 lengths (0..300, at each bound +-1); with the
  length check taken out it is red (1586 mismatches).
  TestItemIDRefusalAsTheRegexp holds the function against the old
  regexp at 998..1002 characters of x, é, 日, \xff, \n; with 1001 it is
  red. TestCappedIsSmall: 1304 bytes held, 49680 bounded.
- go vet native, GOOS=linux and GOOS=windows over the touched packages
  (gui natively: its Linux build needs cgo); gofmt -l clean.
- Real build, GODEBUG=inittrace=1: magpie's own inits allocate
  11.93MB -> 10.61MB.
- Idle on the real-account copy, 180s heap: regexp programs (sampled)
  4.54MB -> 3.01MB.

Not tried: the full ./... suite; the gateway package beyond the run
above.
2026-11-09 21:47:24 +08:00
yetoneandFlandern1211 16e79fc6b0 dsh: a request still answering shows under its fork, not its source (#5542)
The Routing page's live card for a dsh fork's request showed under the
source until the reply was written: it has no reply id yet, and the
opening it is keyed by is the one the fork copied. The messages of the
request's turn are in the branch's own session file before the request
goes out, so they name it:

- gateway: Route.LastConvs, the ids of the user messages the request's
  turn carries, newest first (dshLastConvs, dsh only, at most 4);
- sessions: TurnConvs, the ids of the newest turn's user messages, reset
  at turn/start, not kept from a fork's seed, at most 4 (dshTurnKept);
  dsh's parse version goes to 3;
- gui: ownerBy asks the reply id, then the turn's messages, then the
  opening (ownerOfRoute on the Routing page).

Changed from Flandern1211's patch (957caf84) in review:
- the turn lookup has the reply id's guard (forkedFrom): a "继续" in
  another conversation's newest turn no longer takes a route;
- in dsh's captured requests (sessions/testdata/dsh-gateway) the newest
  user message is the runtime context, the same for every session of a
  folder, so it names no one: the gateway reads the whole run of the
  turn's user messages (typed + context), and passes over Messages'
  tool_result steps, where the patch returned nil;
- looseKeys asks for a turn's keys only while the route answers and for
  convsKept, not for every older route: those keys are never listed
  once a newer turn starts, and would relist every agent's sessions on
  each 2s poll;
- one spelling per message and at most 4 kept (a v3 file has no
  turn/start, so TurnConvs grew with every message, 3 ids each);
- no TurnConvs on Context's records (it counts done calls, named by
  reply), LastConvs dropped from the history (saveRoute) and from what
  the page is sent;
- dshLastConvs reads messages by their members, not decoded: 0.49 ms
  on a 2.2 MB body of 800 tool steps (convOf 0.30 ms), 1.10 ms before.

Run on mote at 2be7aaeea (this change on 9730e0199; then rebased over
ec7a18d12, which changes GUI strings and .cjs tests only, no Go):
- go test -count=1 -timeout 45m ./internal/sessions/ ./internal/gui/
  ./internal/gateway/ ./internal/agent/: ok (sessions 30s, gui 158s,
  gateway 952s, agent 262s).
- CGO_ENABLED=0 GOOS=linux and GOOS=windows go vet -tags nogui of the
  three packages: clean; gofmt -l internal: clean.
- No GUI asset changed, so no .cjs run.

Broken by hand, each red: LastConvs not set in serve
(TestDshRoutesCarryTheSessionConvs on the real captured requests), no
turn/start reset, no cap, no guard on the turn lookup, no looseKeys
bound, no LastConvs keys in looseKeys (end-to-end Routing test stays on
the source), no strip of the page's routes, no tool_result skip, no
strip in saveRoute.

Not tried: a real dsh fork live (no dsh session files on this Mac or
mote); the contributor measured their version on magpie web.

Co-authored-by: Flandern1211 <163982805+Flandern1211@users.noreply.github.com>
2026-11-08 22:25:58 +08:00
yetone 80ae904c23 routing: routing groups get a page of their own, beside Routing
The owner asked for the groups to leave the Routing page (11-06): under
the live stage and every request they were a long scroll down, and New
group with them. The design was reviewed before this was built.

- New page, Routing groups (#view-groups), drawn by the routing plugin's
  same script (routingPage), so the editor, its dirty/discard and every
  group action are unchanged. Toolbar: filter, "N groups · M on",
  Templates, Import, Select, and New group as the filled button. The list
  is right under it, and a Settings section under the list holds Found
  groups (with Exclude providers…) and Names in agents' lists.
- No Export button: each group already has its own Copy to share.
- Routing keeps the live stage and the requests. A request's group opens
  the groups page at its row.
- The sidebar has a Routing groups tab right after Routing (from 1024
  points). The header's row has no room for one: at 860px the extra tab
  pushed the logo out (brand.test). There the tab is hidden, Routing's
  tab is lit for both pages (markNav), and Routing's head has a
  "Routing groups ›" button, hidden beside the sidebar.
- Every way in now goes to the groups page: the guide's Open routing
  groups, the panel's and the provider editor's Make a routing group
  (window/main?view=groups&newgroup=…). mainView still takes
  view=routing&newgroup from an older panel.
- Words: "Routing groups", "Open routing groups", "Once saved, make a
  group of them in Routing groups.", and the editor's names note now says
  the setting is under the list, in zh, zh-TW, ja and de. "Open Routing"
  stays for the Agents page's button.
- Docs: providers-accounts, gateway-routing, plugin-runtime, gui-shell
  and reference say "Routing groups page" where they mean the groups.
- Core budget: the core's scripts are 1,533,774 of 1,533,802, paid for
  by three show()/setGatewayMode comments cut in app.js. No raise.

Tests: routing-groups-page.test.cjs (new) covers the page in Chromium and
WebKit, en/zh/zh-TW/ja/de, at 1280, 640 (window) and 420 (web): no
groups on Routing, the tab or the head's button by width, the lit tab,
toolbar order, New group primary and in sight, list then Settings, no
sideways scroll, no native select, no left-border accent; a request's
group to its row; quotas redrawn with an open editor left alone. The
trace tests (routing-compact, -pause-folder, -rule-models, -folder) open
Routing, then show the groups; routing-editor-foot and
name-suffix-where-named scroll by wheel, as the scroll guard lets a
reader; builtins expects the groups tab beside the sidebar only.
Removed: routing-groups-jump (the head's "Routing groups ↓" that scrolled
down to them, gone with them), routing-pointer-pin and routing-steady
(the groups kept in place under requests streaming in above them: no
request is above them now). Their guarantee that what redraws leaves an
open editor and its typing alone is routing-groups-page's quotas case;
Routing's own lists keep their keepInView.

The groups page's jump: a request's group, or a pool's "Several keys"
chip, opened the groups page and scrolled the row to the centre, and the
next frame show()'s backAfterLoad put the page back where the reader
last left it, then brought the focused segment in by "nearest": in
WebKit the pool sat half under the window's foot (routing-mode-goes, 9
of its 10 WebKit cases). goRouting now jumps at once on a page it opens and
marks it arrived(). The wheel in routing-many-keys turns over the keys:
at the page's foot, now shorter, the mouse rested over the requests list
(.rt-reqs, overscroll-behavior: contain), which took every wheel up, and
the test stopped with 2 keys in sight. That is #4082's cause.
routing-days-fit's fixture has 12 requests, a day that fills the window,
since the day bar held needs room under it.

Run on mote (macOS 27, load 25 to 65), Playwright 1.62.0:
- Go: go vet, gofmt -l and go test ./... at the rebased head (650bf8412
  base) ok except TestMainWindowCorners (#3949); internal/gui again
  after the last edits: the same, TestCoreScriptBudget ok (1,533,773 of
  1,533,802, no raise).
- GUI, the 262 files a change here can reach, at the head and at the
  base: the reds at the head are the base's, with their issues:
  menu-input-scroll #3402, provider-mask #5109, context-fold and
  order-unknown (webkit) #3479, header-centre #3479, i18n-keys
  #5332/#5426/#5482, account-eye #5052/#4244, call-headers webkit de
  #5045, codex-predictions #2624, codex-auto-reset webkit de #4790,
  routing-* under load #5088, and zero-priced-free, last-page,
  reasoning-speed, routing-row-swap/-tag-whole/-story-shrinks/-steps-cap
  and routing-intent-entry, red at the base the same way.
- After the last edits: the 11 files with a way to the groups page or
  its scroll (group-*, routing-groups-page, routing-mode-goes,
  routing-groups-off, routing-provider-off, routing-many-keys,
  click-scroll), 175 of 176; the one red is routing-many-keys webkit's
  wire at the foot, red at the base in 8 of 12 (#5543). brand,
  gateway-mode-sessions, header-zoom-fit, header-centre,
  inner-scroll-contain and mobile-web: the same 11 reds at the head and
  the base (mobile-web compares with origin/main through git, which a
  mote-run copy hasn't).
- Rebased on ecc26a339, again: gofmt -l, go vet ./internal/gui and
  TestCoreScriptBudget ok; 10 GUI files (i18n-keys, routing-groups-page,
  routing-mode-goes, sidebar, brand, menu-first-second, library-bar-more,
  click-scroll, name-suffix-saved, unlisted-models) 211 of 212, the one
  red i18n-keys' "a plugin's words are its own", red the same at
  ecc26a339 (#5332/#5426/#5482).
- Broken by hand: without the groups page's CSS rule, brand and
  routing-groups-page go red (32 fails); with the old goRouting,
  routing-mode-goes is red in 9 of its 10 WebKit cases.

Not tried: the whole GUI suite on Linux (WSL magpie-desktop) at this
head; a run at an earlier head is under way and has the Linux reds
#4120/#4121 name. Not tried in the real macOS app, only Playwright's
WebKit.
2026-11-06 23:11:43 +08:00
yetoneandFlandern1211 e8df78f33e routing: a dsh fork's requests are named by the reply its client was given (#5491)
dsh's chat and messages routes send no session id, so Routing and Context
found a dsh session by the hash of the conversation's opening. A fork
repeats its source's opening, so every request the fork made showed under
the source, and the fork's name never appeared.

Flandern1211's patch, ported:
- The gateway keeps the id of the reply it gave the client
  (Route.ResponseID). It is set from clientResponseID in the same update
  that marks the route done, so a poll that sees Done also sees the id,
  with no race against the usage ledger. When magpie translates, it is
  the id after translation, e.g. chatcmpl-…, not the upstream's msg_….
- sessions reads dsh's replayState.response.responseId into
  Session.ResponseIDs. Only main files are read, only replies served by
  the gateway, and only the fork's own replies after its session/end-seed
  (seedLength for version 1).
- Routing (pricedRoutes) and Context (joinConvs) look up a finished
  request by its reply id first, then by its opening. A request logged
  before this keeps the opening's session.

Changed from the patch:
- A reply id names a session over the opening only when the opening is
  that session's own, or a session it was forked from, or the opening is
  unknown. Vendors' ids can repeat: an encoder keeps the upstream's id,
  and Ollama's is chatcmpl-<0..999>. Without the guard, two unrelated
  conversations could swap names. Session.ForkOf comes from the fork
  header's parentSession, isSeeded and delegationDepth 0, which is how
  dsh's buildForkSeed writes it. ownerOf walks that chain, so a fork of a
  fork works too.
- Poll cost: dsh never writes down some reply ids (a title call, a
  refused turn). Under the patch, each such id made Routing list every
  session again every 2s, for as long as the route was on the page. Now
  an id is waited for only up to a minute (convsKept) after its request
  ended (looseKeys). After that the regular one-minute rebuild covers it.
- A page whose loose routes carry only a reply id still builds the map
  (looseRoute).
- The patch's synthetic fork headers gain parentSession, as dsh writes
  them.
- docs/subsystems/gateway-routing.md describes the reply-id join.

Tests:
- TestDshForkNamedByTheReplyTheGatewayGave sends dsh 0.2.0-rc.2's real
  captured completions request (testdata/dsh-gateway) through
  gateway.New() twice, to an Anthropic-only upstream, so the reply is
  translated. It writes the source's real session file with the first
  client id, and a fork shaped like dsh's buildForkSeed output with the
  second. It then checks that pricedRoutes and contextOf put each request
  under its own session, and an old route without an id under the source.
- TestDshForkOfARealSessionListsItsOwnReplies forks the real fixture
  session: the fork lists only its own reply and ForkOf, the source
  keeps [c1].
- TestDshReplyIDOfAnotherConversationNamesNoOne covers the guard.
- TestRoutingWaitsForAReplyIDOnlyAWhile covers the poll bound.
- The patch's own tests: TestDoneRouteKeepsTheClientResponseID (json and
  stream), TestDshResponseIDs*, TestRoutingTellsAForkByItsReply,
  TestContextTellsAForkByItsReply.

Run on mote (mote-run), at this tree on origin/main be5e8f29f. The vet and
go test lines below were run again after rebasing on e6b9d1199, which
changed only the README and library (ok):
- gofmt -l internal/ printed nothing.
- go vet ./internal/... . is clean.
- GOOS=linux go vet -tags nogui and GOOS=windows go vet of
  internal/{sessions,gui,gateway} are ok.
- go test ./internal/sessions ./internal/gateway ./internal/gui -run
  'Dsh|ResponseID|Fork|Routing|Context|Conv' -count=1: ok.
- GUI: routing-by-key, routing-ctx-sessions, routing-request-metrics,
  routing-sessions, routing-session-folder, sessions-empty-range,
  ctx-route, context-map and panel-routing pass in chromium (120/120)
  and webkit (120/120).

Broken by hand, each red, then restored:
- guard off: TestDshReplyIDOfAnotherConversationNamesNoOne;
- poll bound off: TestRoutingWaitsForAReplyIDOnlyAWhile;
- end-seed keeps the inherited reply ids: TestDshResponseIDsSkipTheSeed,
  TestDshResponseIDsEndSeedAcrossReads and
  TestDshForkOfARealSessionListsItsOwnReplies;
- ForkOf not set: TestDshForkOfARealSessionListsItsOwnReplies,
  TestDshForkNamedByTheReplyTheGatewayGave,
  TestRoutingTellsAForkByItsReply and TestContextTellsAForkByItsReply;
- gateway keeps no id: TestDoneRouteKeepsTheClientResponseID and
  TestDshForkNamedByTheReplyTheGatewayGave.

Not tried:
- a real dsh fork against a running magpie. The session shapes come from
  the real rc.2 fixture and dsh's fork source.
- A request still running, or a failed one, still shows under the source
  until it has a reply id. The patch says the same.
- Delegated subagent files (delegationDepth > 0) are not read for reply
  ids; they stay under their parent as before.
- Not changed: the gateway's turn clock (sessionTurnKey) also falls back
  to the opening's hash, so a fork and its source running at once share
  one. Filed as #5496.

The full suite runs after the push.

Co-authored-by: Flandern1211 <163982805+Flandern1211@users.noreply.github.com>
Reported-by: flandern1211_58540 (Discord)
2026-11-06 17:22:52 +08:00
yetone 6d9fb7ef0f routing: a dsh request names the dsh session its first prompt was read from
changqiu4890 on Discord: Routing -> Requests showed dsh's requests with no
session id. dsh 0.2.1's pi-ai routes (openai-completions, anthropic), which
magpie configures, send no session header (pi-ai's session affinity is
withheld by dsh's compat gate), so a route had only its Conv, the hash of
its first user message. The Context page already found dsh's session by
that hash (dshConvs); the Routing page grouped by header session only.

pricedRoutes now gives a dsh route with no session of its own the dsh
session whose Convs hold its Conv (convOwners, shared with the Context
page's joinConvs), from an index rebuilt at most every 2s when a conv is
missing and every minute otherwise. Grouping and titles (dsh:<id>) follow.
A route with its own session, another agent's route, and a conv two
sessions share stay as they were.

Run (mote-run, this tree):
- go test -tags nogui ./internal/gui/ ./internal/sessions/: ok, ok
- TestRoutingDshRoutesNameTheirSession and TestContext*: ok
- GUI routing-sessions, routing-session-folder, routing-by-key, ctx-route,
  routing-day-window: Chromium 160/0, WebKit 80/0
- go vet darwin, linux (nogui), windows ./internal/gui; go build all three
- gofmt -l clean
Broken by hand: `r.Session = owners[k]` -> `_ = owners[k]`; the new test's
dsh chat and messages routes went red.
Not tried: a real dsh through magpie. A brand-new session's first request
shows no session until dsh writes its session file and the index refreshes.
The in-flight list (Active, concurrency endpoint) is unchanged.
2026-11-05 17:25:26 +08:00
yetone 43849d51c3 routing: By session heads a session by its title, its folder quieter beside it (flandern1211_58540 on Discord)
Routing's By session headed each session "Claude Code · folder · title",
and with no title only the folder and id ("路由这里的会话名只能看到目录名和
会话ID吗"). Now the head is the agent and the session's title on one
line (whitespace folded), with its folder after it in a quieter .dir; with
no title the folder stands in, and with neither the id. The tooltip keeps
the title, the folder and the id.

The title comes from what magpie already reads, no second reader:
sessions.Titles (the agent's own title, else its first prompt) and Codex's
name index, and where both find nothing, the first prompt the gateway
recorded for that session (sessions.GatewayTitler, the title the Sessions
page shows for it), looked up under the agent the page names and the one
the gateway records it under (usage.AgentOf). A Codex thread Codex never
named now goes to sessions.Titles as a codex: key, so its rollout's first
prompt names it. withGatewayTitles and codexReadableTitles in trace.go.
Nothing is read that the Sessions page doesn't show already, and nothing
leaves the local GUI.

Tests: TestSessionTitlesFallBackToFirstPrompt (new): an unnamed Codex
thread gets its first prompt, a named one keeps its name, an unknown id
stays out, a pi session known only to the gateway gets its first words.
routing-session-folder.test.cjs follows the new head: title then .dir,
the first prompt on one line, the folder said once, the id with neither,
nothing clipped (chromium and webkit, en zh zh-TW ja de, 1100 and 420px).

Run on mote via mote-run, at origin/main e7b0c398e plus this change:
- Whole Routing GUI set (routing-*, panel-routing*) + i18n-keys,
  chromium and webkit: 2583 pass, 35 fail. Every red is a known one:
  rule-remove (#3096), rule-drag (#3789), row-swap (#3799),
  order-unknown (#4627), rules-line (#3593), many-keys, steady,
  steps-cap and story-shrinks (#5088), and under the load of another
  session's whole GUI suite (load ~200) routing-credits webkit ja 420
  (#5161) and routing-flood webkit en (#2215). Run again: credits 20/20
  and flood 12/12 here; order-unknown's webkit de 420 red the same at
  e7b0c398e alone.
- routing-session-folder: 20/20 (both engines, 5 languages, 2 widths).
- go test ./internal/gui: TestSessionTitlesFallBackToFirstPrompt ok;
  red only TestCoreScriptBudget (1534001 > 1533802, the same at
  e7b0c398e, #5139: this change adds nothing to the core scripts) and
  TestMainWindowCorners (the same at e7b0c398e, #3949).
- Rebased onto origin/main 1a67ca614 (its routing client.js changes
  merged clean), at this commit: routing-session-folder 20/20,
  routing-session-title 40/40, routing-kept-again 20/20,
  usage-compact-counts 30/30, routing-live-calm 2/2, i18n-keys 4/4, and
  go test ./internal/gui -run 'TestSession|TestCoreScriptBudget' ok
  (the budget passes at this base). The whole Routing set was not run
  again here. Then onto 0f1b40bbc (routing client.js and css again,
  merged clean): routing-session-folder 20/20, routing-live-bytes
  20/20, routing-live-calm 2/2, i18n-keys 4/4.

Broken by hand:
- withGatewayTitles a no-op: TestSessionTitlesFallBackToFirstPrompt red
  ("titles = map[]").
- client.js back to the old head: routing-session-folder red in every
  engine, language and width.

Not tried: the real app with real Codex, Claude Code and gateway-only
sessions (fixtures only), the Linux WebKitGTK app, Windows.
2026-11-04 19:43:00 +08:00
yetoneandggbdpq bdc1617bed routing: Accounts and keys count the whole day, not the last kept requests (#3351)
1234fsdc: the live Routing page's Accounts and keys said tried and
answered over the requests the page still keeps in memory, so on a busy
day the counts were a sliver of what Usage showed for the same accounts
and went down as old requests fell off. /api/trace/history (the read the
live page already makes every 15s) now carries `tallies`: per account or
key, today's tries, answers, fails by reason, models answered, the last
answer and the latest rest, read from routing/<today>.jsonl. The page
seeds the list with them and still takes the latest rest and readings
from the requests it keeps; a day looked at, or a purpose picked, counts
its own list as before. The note says "over today's requests" then.
Ported from ggbdpq's patch on the issue.

Changed from the patch:
- The patch parsed the whole day's file under history.mu on every look.
  A busy day's file is hundreds of MB (#3383) and saveRoute takes the
  same lock, so every 15s poll would stall the routes being written.
  DayTallies now folds in only the whole lines added since the last
  look (it keeps the offset, as History does); a line still being
  written waits for its end. It starts again when the day changes, the
  file shrank or was compressed, or the folder moved (another HOME).
- What it returns is a copy: the patch handed out the live tallies,
  and the JSON writer read a Fails map the next fold wrote.
- The latest name and rest go by the try's time, so no sort per look.
- docs/subsystems/gui-shell.md says how the counts are made and that a
  request done since the last look is counted at the next one.

Run on mote at this change on 394a92f0f. The pushed parent 5787d758a
adds usage, tray, redact and search changes and none of this change's
files:
- gofmt -l clean; go vet ./internal/gateway ./internal/gui for darwin,
  windows, and linux -tags nogui.
- go test ./internal/gateway -race -run 'History|DayTallies': ok.
- go test ./internal/gui -count=1 -timeout 45m: red in 11 tests, all
  red on main too. Ten are real-window AppKit tests killed at their
  deadline on mote (the same ten at 03f3e1528, #4125).
  TestSettingsSaveKeepsWhatItDoesNotSend is SearchAll on main (#4514).
  TestLiveHistoryTalliesTheWholeDay passes. At the pushed head, -run
  'Budget|Tallies': ok.
- GUI on WSL (wsl-run, Ubuntu 24.04, Playwright 1.62.0, Chromium and
  WebKit, every language each file runs):
  - The 229 test files that reach the Routing page, plus i18n-keys, at
    this change on 576b5dcbc (--test-concurrency=4): 3498 tests, 101 red
    in 31 files.
  - Those 31 files on main 03f3e1528: 94 red. With this change: 99 red.
    The same tests fail; which language or engine goes red changes from
    run to run (#4121, #4471).
  - Four of them run alone: 27 red on main, 21 with the change.
  - At 394a92f0f, routing-day-tallies, i18n-keys, account-weight,
    key-weight and routing-weight-chip passed. routing-columns' WebKit
    rows were red, as on main (#4520). Its fixture has no tallies.

Broken by hand:
- DayTallies re-reading the whole file each look (reset always true):
  TestDayTalliesFoldOnlyWhatWasAdded red, "a look after one route read
  101 lines, want 1".
- handing out the live tallies, no copy: red, "a tally handed out
  changed after: ... fails map[rate:3]".

Not tried: a real day's file of hundreds of MB. The first look after a
start still reads the whole day once under history.mu, as History's own
first read does. A real app beside a running gateway. Past days
are unchanged: still counted over their latest historyMax routes.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-31 11:29:38 +08:00
JoeyWu-tech ef9cd2fd6c gui: the tray panel's More in Plugins opens the window on Discover (#3579)
yetone (#3579): in the tray panel, the add sheet's More in Plugins, and
its search's "look for a plugin", asked the window for Plugins with no
more than the view's name (window/main?view=plugins). The window opened
on the tab of Plugins kept from before, Installed or Built-in, with
nothing looked for. 894ec960 made both open Discover in the window
itself; this is the panel's half.

The panel now asks for view=plugins&q=, with what its add sheet looked
for, empty when nothing was. More in Plugins sends the sheet's search,
lowercased, when it shows beside one (a search naming a subscription a
plugin serves, kiro say), and look for a plugin sends the search that
found nothing. mainView passes q on for Plugins whenever it is there,
empty too, since its being there is what says Discover; a q with a
control character (a newline, a tab) or over 100 code points goes on
empty. The window
opened on that address does what its own More in Plugins does
(pluginQuery): Discover, looking for q. start.js does it when the
window's first show() is done, so after show() has sent a window with a
plugin's update waiting to Installed, as the window's own More in
Plugins calls pluginQuery after show() too. It does it once: syncURL,
which show() calls, now takes q out of the address, so a reload, or the
window opened on Plugins again without a q, shows the tab kept, as
before. In the same window Plugins stays on Discover until another tab
is picked, as after the window's own More in Plugins. The GUI tests'
README describes the new half.

The deprecation note's Review in Plugins (several deprecated
subscriptions signed in) goes through openPlugins too, so from the
panel it now opens Discover as well, as it has in the window since
894ec960. openPlugins is the only sender of window/main?view=plugins.

plugins.js is not changed. app.js grows 94 bytes and start.js 182; with
the previous commit the core's scripts are 3 bytes under main's,
1,527,969 of 1,528,076, and app.js is 1,309,997 of 1,310,460.

Not changed: the window's own More in Plugins, and every other page the
panel opens the window on. mainView takes the view's own value
unchecked, so a q inside it skips mainFind (#3846); q goes no further
than Plugins' search field and its npm search, as typed there.

What was run (tree 7dce6444, on origin/main 56602426, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, the Go tests at umask 077:
- plugins-more-discover (Node 22.22.1, Playwright 1.58.2), its panel and
  window halves new, in English and Chinese, 5 times in Chromium and 5
  in WebKit: 3 of 3 pass each time. The panel, on a first use (where it
  shows the add sheet), asks for ?view=plugins&q= from More in Plugins
  and ?view=plugins&q=fake%20co%26x from "look for a plugin" after a
  search for "fake co&x" found nothing. The window, at what mainView
  makes of those (?view=plugins&q=fake+co%26x, and &q=) with Installed
  the tab kept, shows Discover with the search in its field, and its
  address keeps no q, so a reload shows Installed. With a plugin's
  update waiting (the test holds start.js until the update's answer is
  sent; WebKit has it by the first show(), Chromium not always, see the
  breaks), Plugins opened without a q shows Installed, and the window
  the panel opened shows Discover.
- TestMainView's new cases: Plugins with no q, an empty q, a word,
  "fake co&x", Chinese with &view=settings in it, a newline, a tab, 100
  and 101 characters, 100 and 101 Chinese characters, and Settings with
  a q. TestMainURL's: "智谱 glm" reads back from the window's address as
  it was sent. With TestCoreScriptBudget, -count=50: 150 of 150 pass.
- Broken by hand, each red in plugins-more-discover:
  - the panel asking for view=plugins alone, as on main: 0 of 3 in
    each engine, at the panel's asks (?view=plugins for
    ?view=plugins&q= and for ?view=plugins&q=fake%20co%26x);
  - start.js not looking for q, as on main: 0 of 3 in each engine, the
    window the panel opened on Installed (已安装 in Chinese) for
    Discover;
  - Discover asked as start.js loads, before show(): WebKit 0 of 3 in
    each of 5 runs, en and zh at "the window the panel opened, an
    update waiting", Installed for Discover; Chromium red there in 2
    of the 5 (en in both, zh in one). 25e1d038's record, its window
    half in plugins.js, had Chromium red in 4 runs of 4 (en every run,
    zh in 2);
  - q left in the address (syncURL's q.delete taken out): 0 of 3 in
    each engine, the address after the window opened still
    ?view=plugins&q=fake+co%26x for ?view=plugins.
- Every GUI file that reaches Plugins, the panel's add sheet or the
  window the panel opens (the same 53 as 25e1d038's record, by a grep
  for view=plugins, window/main, more-plugins, pluginQuery, pluginTab,
  lookFor, look for a plugin, show("plugins") and #view-plugins), and
  i18n-keys, each alone in both engines: 94 of 108 runs green. The
  other 14 are red at 56602426 too, alone, and none is in what this
  changes. Playwright here is 1.58.2, older than the 1.62.1 the GUI
  tests' README names, so some of these may be red with this
  Chromium or WebKit only; those with no issue named have none yet:
  - builtins, WebKit: Plugins › Built-in, the Observability switch's
    click times out; the stuck Plugins head intercepts the pointer.
  - i18n-keys, run twice (it needs no browser): "a plugin's words are
    its own", for plugins/routing/i18n.js's "masking…" (#4053).
  - mobile-web, both engines: its "desktop matches origin/main" cases
    compare with BASE_REF, origin/main by default, as git has it at
    the run, which had moved on from 56602426 (the Gateway page's
    screenshots differ). A copy with BASE_REF set to 56602426 passes
    15 of 15 in each engine.
  - modal-centred-late, WebKit: 820px and 560px, the dialog reaches its
    README's height with fewer than 3 frames between
    ([407,575,676,674,672] and [407,466,519,520,520,520]).
  - plugin-card-update, WebKit: en and zh, the wait for the Update
    button times out, in 4 runs of 4; at 56602426 the same in 3 runs
    of 4, and zh alone in the other (#3079 has en).
  - plugin-github, WebKit: de 440, a click moves #view-plugins from 73
    to 135 (#3218 has the same check red in Chromium, by 1px).
  - plugin-github-wait, Chromium: de 440, a press on Try again
    moves #view-plugins by 2.
  - plugin-release, WebKit: en and zh read the line with a trailing
    newline ("Serves Zed\n").
  - settings-lines-wrap, both engines: de 440px, a row's line is cut
    short, Usage's in Chromium and General's in WebKit.
  - title-bar-tools: in Chromium, de, the wait for the Plugins head
    times out; in WebKit, all five languages, here and at 56602426:
    zh, zh-TW, ja and en for page errors from the fetches a reload cut
    off (/api/agents/cli, /api/agents/install, /api/update and
    /api/whatsnew; #2740 has /api/providers'), and de for that same
    wait.
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
  vet for windows, go build -tags nogui for linux and darwin and go
  build for windows: exit 0 each. go vet and go build without the tag
  on linux: exit 1 (no libsoup-3.0 or gio-unix-2.0 here).
- go test -tags nogui -count=1 -timeout 45m ./... (Bun 1.4.2, log
  kept; 8m41s, load 40 at its start): 72 packages ok, and 12 tests red
  in 5 packages, none of them this commit's tests or what they cover
  (internal/gui's are its gateway tests): agent TestInstalledVersion,
  TestCursorFolderFromTheEditorIsNotTheCLI,
  TestCopilotFolderFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141);
  TestReasonixCLIRequiresSupportedNativeVersion and
  TestReasonixCLIRecoversAfterProbeTimeout (#3641); edit
  TestWriteAtomicReadOnlyHardLink and testenv TestProgram
  (umask 077, #3640); gateway TestPluginToldWhereTheAgentWorks
  (the /tmp/.git of #3675); gui TestGatewayHeldByAContainer and
  TestGatewayFixQuitsOnlyAMagpie (#3649).

The rest is what was run for 25e1d038, at tree ffc1adb1 on origin/main
02cbdf5b, the same Go code, tests and README (its window half was in
plugins.js, where this one's is in start.js; not this tree):
- Broken by hand in the Go, each red in the Go tests named:
  - mainView passing no q: TestMainURL, and TestMainView's every
    Plugins case with a q;
  - mainView passing any q: TestMainView's newline, tab, 101
    characters and 101 Chinese characters;
  - mainFind as ^.{0,100}$: TestMainView's tab;
  - mainFind counting bytes too: TestMainView's 100 Chinese characters.

Not tried: the real app's tray panel and window, on macOS, Windows or
Linux.

Landed by yetone in a batch of Coffemon's patches from the issues.
What was run, go1.26.8, on origin/main cc81ad4ea, then again at
70a0c387c (gofmt, the three vets, the changed tests, umask 077):
- mote (macOS 27): gofmt -l clean; go vet, GOOS=linux go vet -tags
  nogui and GOOS=windows go vet ./...: ok. edit and testenv at umask
  077; agent, provider, library and gateway with an empty .git above
  TMPDIR; davsync, imagemcp, plugin, library, edit, testenv whole; the
  changed tests in agent, provider, gateway and gui; the timing tests
  -count=10 (gateway, davsync, imagemcp) and -count=5 (agent): all ok.
  TestCoreScriptBudget ok: core 1,536,751 of 1,537,034, app.js
  1,312,975 of 1,315,316, no budget raised.
- Red on the old code: on origin/main, TestWriteAtomicReadOnlyHardLink
  at umask 077 and two Reasonix tests under an empty .git; on Linux
  (wsl-run) TestProgram at umask 077 with the old program.go. With
  each fix's code taken back to main's, the Gemini imageConfig tests,
  TestPluginToldWhereTheAgentWorks, TestSkillRepoTraced,
  TestTaggedHooksAlone, TestMainURL/TestMainView and update-auto,
  plugin-github-hooks, plugins-more-discover, plugin-namesake were
  red. Broken by hand: claudeKeyed always true (both
  OwnEndpointNeverAsked tests red), claudeAsk a no-op
  (TestClaudeFirstWriteAsksTheProxy red), GitAt taking any .git folder
  (the three TestGitOnDisk tests red).
- GUI: 123 files (plugins*, update-*, panel/tray/start/context, i18n,
  gui-zh-tw/ja/de and every file that evals app.js parts) in WebKit on
  Linux (wsl-run). 11 files had reds (click-scroll, panel-fold,
  plugin-card-update, plugin-github, plugin-move*, segs-glide,
  tray-totals, update-*), and run again side by side they fail the
  same on origin/main d80d75f30 (79 pass, 26 fail here; 78 and 27
  there). They are click-scroll guards ("the click must not scroll
  the page"), varying by language from run to run (#4385).
  copilot-ghe's route-after-close red is #1949, seen on main 244d80e23
  too. In Chromium on mote, Chromium segfaulted partway through files
  (#4125): context-map, context-scroll-end and context-tune fail the
  same on origin/main 0911a65e7, so the batch's own files
  (plugin-namesake, update-auto, plugins-more-discover,
  plugin-github-hooks) ran in Chromium on Linux: 62 of 62.
- Full suite (go test -tags nogui -count=1 -timeout 45m ./..., mote)
  at 472a0608f (on 70a0c387c): every package ok but internal/gateway,
  whose five reds were #4362's (Antigravity turned-away and
  TestCodexSpentGrokFailingIsTold), fixed on main in d80d75f30. After
  the rebase on 244d80e23 the five pass, and gofmt, the three vets
  and the targeted runs above were run again: ok. In Linux the
  sign-in, copilot, plugin-github*, plugins-more-discover,
  plugin-namesake, plugin-gateway, update-auto, quota-refresh-order
  and i18n files ran in both engines: 475 pass, 4 fail (copilot-ghe
  #1949, plugin-github's click scroll, both red on main too).
- Rebased again on c7171a256, over its budget fix e94bf7a08: gofmt, vet of
  gui, gateway, provider and plugin, TestCoreScriptBudget (core
  1,536,265 of 1,536,586 with the batch's last commit, statusTErr and settingsErr), the Gemini,
  GitOnDisk and plugin tests, and in Linux both engines i18n-keys,
  update-mirror, plugin-namesake, plugins-more-discover,
  plugin-github-hooks and update-auto (138 of 138): ok.
Not tried: the whole GUI suite (mote's WebKit wouldn't launch and its
Chromium segfaulted, #4125); macOS WebKit; the real app's window.
2026-10-30 15:53:22 +08:00
yetone 29185e3bbc gateway: a request held too long before routing leaves a report its user can copy
Jason on Discord (#general, v0.1.1995, AirbuildEnvironment over Codex's
/backend-api/codex/responses) got the 2m 504: "magpie held this request
for 2m0s without routing it to any provider ... report it with magpie's
log". The desktop app runs the gateway in-process and logs only to
stderr, so there is no log for him to send.

giveUp now writes a report of the held request to a small file in
magpie's cache (held/, folder 0700, temp file renamed into place, the
newest 5 kept). It holds the time, version, OS, the method and path, the
model and agent, how long it was held, each named wait with its time and
whether it was still under way (noteWait now takes a kind: body, body
room, decision model, image description, plugin hooks, JS middleware,
Codex reset, masking), the body room's state, the requests in flight,
and a goroutine profile (function names and lines only, cut at 128KB).
It holds no body and no headers. Route.Held names the file. On the
Routing page, the request's story then says a report was saved, with
Copy Report and Open Folder (Open Folder is left out in magpie web).
GET /api/gateway/held/{name} reads only a report's own name. The 504's
text no longer points to a log: it names Copy Report on the Routing page
and the folder. The log line names the waits too. i18n is in zh, zh-TW,
ja and de, and docs/subsystems/gateway-routing.md has the section.

What held Jason's request is not known from what he sent. The waits that
count before routing are: the body arriving (idle deadline only), body
room (up to 100s, then 503), the decision model (see the next commit),
plugin hooks (11s), JS middleware (250ms a hook), image description
(bounded by the request) and the Codex reset (20s). Slots, RPM and
upstream come after the route begins. A WebSocket upgrade gets a 426.
The report names the wait, so the next one says which.

Run:
- mote, at 57b21abd9 before the rebase: go test ./internal/gateway
  -run 'Unrouted|Held|...' passed. The full go test ./... -timeout 45m
  was cut off when mote dropped off the network (2 packages ok). The
  full suite then went to the Windows box (see the next commit).
- xiaomi-gpu (Windows), node --test: routing-held-report 50/50 in
  chromium and webkit, 5 languages, 1100/420px, app and web.
  routing-held-request and i18n-keys pass. All routing-* and i18n*:
  1742 tests, 94 reds, none in i18n*. The same files are red alone at
  origin/main 033b17baf (22 of 46 in WebKit), recorded on #4124.
- GOOS=windows/darwin go vet ./internal/gateway ./internal/gui,
  GOOS=linux go vet ./internal/gateway, go build ./... : ok.
Broken by hand: leaving Route.Held unset turned
TestUnroutedHeldReportSaved red ("names no report"). Dropping the
story's report line in client.js turned routing-held-report red in both
engines.
Not tried: a real held request in the real app. Linux vet of
internal/gui (cgo for Wails, cross-compiled). The GUI test on macOS
WebKit, since mote was unreachable.
2026-10-29 15:10:34 +08:00
yetone 3a47e377e0 usage: a call whose vendor counts no cache is left out of every hit rate (#3464)
#3464 (zeewell on X): Kiro caches on its side, but its replies give only
credits and a context share, never cache tokens. Every hit rate outside
the Routing page read those calls' CacheRead of 0 as a miss. A Kiro-heavy
day showed "hit rate 6%" when the counted calls hit 90%.

The plugin already says so (opencode-kiro-auth 0.1.16 sends
usage.magpie_cache_unknown), and the gateway already kept it as
RouteUsage.CacheUnknown for Routing. This carries it the rest of the way:

- gateway: Usage.cacheNotCounted() (the vendor said so and no try
  reported a cache token) goes into usage.Record.CacheUnknown on every
  path that records a call: the gateway's own record, the OTel attempt
  path in observe.go, and trace's routeUsage.
- usage: Record.CacheUnknown is kept as ledger row flag 8192
  (rowCacheUnknown; grepped, no other flag uses that bit). Totals sums
  such calls' prompt into cache_unknown and counts them in
  cache_unknown_calls. Totals.HitRate leaves that prompt out of its
  denominator, and gives no rate when nothing is left.
- Old records: calls kept before the plugin said so carry no flag. A
  Kiro call (provider kiro or kiro-plugin) with no cache counted is read
  as uncounted (usage.CountsNoCache): in the ledger's row read, in
  Totals, and for Routing's history in internal/gui/trace.go
  (cacheCounted). The rule is scoped to Kiro's two ids, so another
  vendor's 0 stays a miss (tested).
- GUI: cacheHitOf in app.js drives the tray panel's card, the Usage
  page's agent rows and cache tile, the requests' Cache hit rate card and
  each ranking row. When only uncounted calls are left it shows "—" or
  nothing instead of 0%. Otherwise it says "{n} requests left out: their
  vendor doesn't count the cache". A request row's cache cells show "—",
  and its details say the vendor doesn't count the cache. The Context
  page (context.go, context.js) shows no cache for such a call and doesn't
  score it as a miss.
- No budget raised. This adds 625 bytes to app.js (1,320,224 to
  1,320,849, under its 1,321,336); d08b6118b had already moved the
  masking page's maskWho, maskProv and stillMotion out to
  plugins/redact, which an earlier version of this change did too.
- Strings in zh, zh-TW, ja and de. docs/subsystems/provider-plugins.md
  now describes the ledger side and what is not covered.

Not covered, filed: hit rates read from the agents' own session files
(the TUI and CLI session lists, the Sessions tab's totals) still count
Kiro's 0 as a miss (#3470). Found on the way: System One's calls are
recorded without their cache tokens (#3471).

Run at this tree (on origin/main e57e78563, fetched just before; the
54-file GUI run was at a84d2ec80, and the 14 files that main's
redact page change since could reach were run again here):
- gofmt -l . prints nothing. go build ./... ok. go vet ./... ok,
  GOOS=linux go vet -tags nogui ./... ok, GOOS=windows go vet ./... ok.
- go test -count=1 -timeout 45m ./internal/usage ./internal/gui
  ./internal/gateway: all ok (gateway 388s), TestCoreScriptBudget
  included.
- GUI, 54 files (ledger-*, panel-*, i18n-*, context-*, request*,
  usage-card*, usage-ledger and the masking/redact files),
  concurrency 2: WebKit 439/452, Chromium 444/457. The new
  ledger-cache-unknown test passed in both. Again here (ledger-*,
  masking-*, redact-*, mask-*, usage-ledger): WebKit 104/117,
  Chromium 109/122, the same reds. The reds, both already
  red alone on main before this change:
  - redact-words-any-case, 10/10 in each engine (#3500)
  - usage-ledger "newest live route needs no return-to-live button",
    en and zh in each engine (#3104)
- At earlier bases, with the same change: usage-agents-hide (#3414),
  usage-checkin's WebKit Qoder tab (#3091), usage-fold (#3415),
  usage-focus-steady (#3501) were red, each red alone on main too;
  usage-card-refresh read a row before it was laid out, under load
  (#3509); context-picks (#3483) and
  context-map's tile overlap (#3488) in Chromium. Filed while doing
  this: TestUsageReadAfterAppendHashesNothingOnAFineClock goes red
  about 1 in 20 on main aa3112f4e (#3511); it passed in this run.
- Red on the old code: the new Go tests in usage, gateway and gui, and
  ledger-cache-unknown.test.cjs (the old page shows "hit rate 6%"
  where this shows 90%). Each changed piece was broken by hand and
  turned a test red. The exception is the OTel attempt path in
  observe.go, which no test reaches.

Not tried: a real Kiro account through the GUI.
2026-10-25 01:23:42 +08:00
yetone 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 f5b1d36ff (rebased since onto 344d11484, which only raised the
budgets and changed a dialog's centring and two unrelated files):
- masking-records.test.cjs: 32/32, Chromium and WebKit, 5 languages,
  1100px and 640px (card, list, filters, detail, put back, held back,
  Gateway badge, deep link, Settings row, no scroll on click), with
  key-import and i18n-keys: 48/48.
- go test ./internal/maskrec ./internal/redact ./plugins/redact
  ./internal/gui ./internal/provider: ok. TestCoreScriptBudget and
  TestMainView ok; gofmt -l clean.
- Before the rebase, on 628e18987: go test ./... -timeout 45m, every
  package ok; GOOS=linux go vet -tags nogui ./... and GOOS=windows go
  vet ./... clean.
- Budgets lowered to the sizes at the pushed head (app.js 1,317,486,
  core 1,524,789), ~26KB under what f35c721c4 raised them to after
  ce5b23cdb's add-key spinner put the core over.

Broken by hand: the bird's href (#bird → #nobird) turns masking-records
red.

Not run at this head when pushed: internal/gateway, which main's newer
commits touched (run right after; the result goes on the release).
Not tried: the whole GUI suite (hours long, and another session's runs
held the machine), the real Linux (WebKitGTK) and Windows apps.
2026-10-24 19:45:03 +08:00
yetone 0eb5cbe81a routing: the live view and Usage's Requested name a found group auto/<model>, not group/auto-<model> (未寒 on Discord)
Reported: 未寒 picked auto/claude-opus-5-5, and the Routing live view and
Usage's Requested column named it group/auto-claude-opus-5-5, an internal
id that agents never see.

Changed:
  - internal/gateway/trace.go: GroupRef and SubGroup carry Ref
    (Group.Ref(), the id agents pick the group by).
  - internal/gui/trace.go: publicRoute rewrites a route's Model,
    For.Model, Subagent.Asked/To and the group's and subs' Ref through
    provider.PublicRef (memoised per answer). It copies the pointers
    before writing, so the gateway's trace is left as it was.
  - internal/gui/context.go: the Context page's model too.
  - internal/usageapi/usageapi.go: the ledger page's Requested.
  - routing/client.js: useName falls back to a sub's ref.

Test: TestRoutesNameFoundGroupsByTheirPublicID
(internal/gui/trace_publicref_test.go). Broken by hand, each one red:
  - publicRoute made a no-op: red on model, group, subagent, For, Subs
    and route.
  - usageapi mapping removed: `the ledger's Requested:
    ["group/auto-claude-opus-5-5" "group/mine"]`.
  - contextRoutes mapping removed: `the Context page's model:
    "group/auto-claude-opus-5-5:high"`.
  - Ref dropped from gateway/trace.go alone stays green, as expected:
    publicRoute fills an empty Ref.
Not covered: the ledger's text search (usage.Filter.Query) still matches
the stored group/auto-… form, not the shown auto/… (package usage can't
import provider). client.js's ref fallback has no GUI test of its own.

Run, go1.26.8 darwin/arm64, sandbox HOME, private GOCACHE:
  At this stack on origin/main df6bd3efe (head 48522d851):
    gofmt -l: nothing
    go vet ./... (darwin), GOOS=linux go vet -tags nogui ./...,
      GOOS=windows go vet ./...: ok
    set -o pipefail; go test -timeout 45m ./...: ok, EXIT=0
      (68 ok, 19 with no test files; agent 528s, gateway 628s,
      library 482s)
    GUI, playwright 1.62.0, chromium and webkit, concurrency 3: the
      171 files near this change (routing*, panel-routing*,
      window-mask, privacy*, usage*, quota*, providers*): 2217 tests,
      2183 pass, 34 fail. Every red is also red alone on origin/main:
      quota-count-wrap and quota-name-translated (#2228),
      usage-agents-hide (#2276), usage-checkin (#3091), usage-fold
      (#2163), usage-ledger (#3104, red since df6bd3efe, green at its
      parent). window-mask: 20 of 20.
  At this stack on origin/main c922225f1 (head 91baa7adb), before
  df6bd3efe's routing trace change:
    set -o pipefail; go test -timeout 45m ./...: ok, EXIT=0
      (66 ok, 20 with no test files)
    the whole GUI suite (823 files, both engines, concurrency 3):
      11589 tests, 11554 pass, 35 fail. The 9 files red were run again
      alone at --test-concurrency=1 on the head and on origin/main
      a8ecf4020. The same 7 files were red on both: the five issues
      above plus s3-sync (#2448) and library-row-remove (#3099).
      nav-sub-unroll (#1950) and plugin-updates (#3103) were red only
      under the full run. codex-predictions (#2624) was 20 of 20.
2026-10-21 08:40:49 +08:00
!am9a09eandfatcutegg ef655acb40 gateway, gui: a console shows the routing of the magpie that serves the gateway (#2606, fatcutegg)
fatcutegg's patch (fatcutegg/magpie 40ceb22df). The routing trace is held
by the process that serves the gateway. A second magpie on this computer
(`magpie web`, or the app while a launchd `magpie serve` holds the port)
showed none of it. Now its console reads the serving magpie's
GET /v1/magpie/trace (and /v1/magpie/concurrency for the lanes) over
loopback, and plays that trace as its own. The heading names which magpie
is routing ("serve (pid N) is routing").

Reviewed as a community change. A trace names accounts and emails, session
ids, a folder's last two parts and error text. It holds no prompt text and
no key. The endpoint answers local(r) alone: a request from another address
gets 403, and so does a loopback request carrying a proxy or Tailscale
header, or a LAN request while the gateway is shared, whatever key it holds.
lanGuard and corsGuard stop rebinding Hosts, Origin: null and *.localhost
first, as on every route.

Changed on top of the patch:
- A gateway key held to a budget, models or accounts is refused with
  KeyHeldCode (refuseHeld), as concurrency and quotas refuse it.
- The console reads loopback alone (ownerURL). A non-loopback MAGPIE_ADDR is
  never asked, and 0.0.0.0, :port, [::] and localhost are read at
  127.0.0.1.
- OwnerTrace lets a hung magpie go at wait+5s (was +20s). OwnerLanes waits
  700ms like ServedBy (was 2s) and is asked only when a magpie answers.
- `/` tells pid and serves to a loopback request alone. A plain `magpie`
  that opens the TUI reports itself as "tui".
- Takeover: in the real two-instance run, after B took the gateway over the
  hub still read "serve (pid A) is routing", from the providers state. Now
  the trace carries `by` (pid, serves), and the page names the router from
  it. When `by` changes, the page drops its routes and reads the new
  magpie's whole trace, so route ids from two magpies never mix. The
  label's full text is in its title, because the node cuts it with an
  ellipsis.
- Trace's doc comment, which the patch had orphaned, is back on it. Docs
  (gateway-routing.md, gui-shell.md) say all of the above. Issue
  references are #2606 (were #110).
- Tests: a proxy-header subtest, TestOwnerReadOnLoopbackAlone, the trace
  added to TestHeldKeyToldNoAccounts, and `by` / pid / serves asserted in
  both packages' peer tests.

Run:
- Each guarantee broken by hand, and its test went red: refuseHeld removed,
  ownerURL returning MAGPIE_ADDR, local(r) replaced by a RemoteAddr check,
  pid/serves dropped from the answer, `by` dropped in OwnerTrace, and the
  console's OwnerTrace fallback turned off.
- A real sandbox (own HOME, ports 3591-3593, fake upstream on 3564):
  - A `magpie serve`, B `magpie web`. B's Routing page played A's routes
    live (the long poll counted 3 requests through A).
  - Probes of A's /v1/magpie/trace. 200 from plain loopback. 403 for
    evil Origin, Origin: null, evil.localhost, a rebound Host with and
    without Origin, x.localhost Host, X-Forwarded-For and
    Tailscale-User-Login.
  - A LAN-shared instance answered 403 from 10.0.0.111 even with a valid
    key, and gave no pid on `/`.
  - Killed A: B took over in ~11s. The hub dropped the "is routing" label,
    and the next request through B showed as a fresh trace (1 request).
  - Chromium and WebKit screenshots at 1280 and 390 wide, in en, zh and ja.
    No horizontal scroll.
- gofmt -l clean. go vet darwin, GOOS=linux -tags nogui and GOOS=windows
  pass, and all three builds pass.
- go test -timeout 45m ./... at this tree (sandbox HOME, load 250-400):
  every package ok except four.
  - agent, gateway and library hit 45m in TestClaudeTierPickedAsTheMainModelStays,
    TestQueuedStreamKeptAliveOnceSentToItsVendor and TestWellKnownKitGrouped.
  - plugin failed TestGatewayHookMixedPiPackage (#2865).
  - Rerun alone with -p 1: plugin ok (464s). gateway finished in 45m with
    one red, TestRequestBuildsProvidersOnce, a 900ms/1s timing window under
    load. It is 8/8 green alone here and on origin/main f73378365. Filed as
    #2965.
  - agent ok (2162s) and library ok (377s), each run alone.
- GUI suite, whole, Chromium (playwright 1.62.0, 8 at a time, load
  ~300): 5608 of 5661 pass. The 15 red files were run alone at this tree
  and at origin/main f73378365. The fails are the same set, give or take
  load (136 of 162 pass here, 137 of 162 on main), and each already has
  an issue: routing-bodies #2559, segs-glide #2683, lightweight #2638,
  codex-predictions #2624, routing-model-rest #2115, routing-keys-fold
  #1612/#2658, quota-count-wrap #2228/#2399, sidebar-overlay-scrollbar
  #1863. routing-keys-fold's live fold test, which plays a live trace, is
  3 of 3 green alone both here and on main.
- WebKit: the whole pass was cut short at ~1576 tests by load (nothing
  routing-related red in it). The 9 files that drive the hub or the live
  trace (routing-js, routing-keys-fold, routing-group-fold,
  routing-held-dot, routing-held-member, routing-answered-still,
  routing-weight-chip, routing-mode-goes, claude-subagent-tag) are 108 of
  108 in WebKit here.

Co-authored-by: fatcutegg <29221285+fatcutegg@users.noreply.github.com>
2026-10-19 23:19:24 +08:00
yetone 7d4ad7c628 gui: the menu bar's total is every token, cache too, marked Σ, as the Requests tab sums it (NextCommit)
NextCommit on Discord: the menu bar's usage showed only input tokens, and
more input than the Usage page. It showed input + output, unlabelled, so
it read as the input and came out above the page's input. And it was summed
as the Overview sums (usage.SummarizeTop: the gateway's calls only, cache
aside), while a click opens the panel's Usage tab, which sums the ledger
(the agents' own session-file calls too) and counts the cache's tokens
in its Tokens. Two numbers under one name.

- trayTotalSum is the ledger's cached sum, usage.QueryPage(p, {}, 0, 1).Sum,
  the one the panel's Usage tab and the window's Requests tab show.
- The cell's top row is every token (in + out + cache read + write, as
  allTokens) prefixed Σ; the cost stays under it. The tooltip spells out
  "N tokens (a in · b out · c cached)".
- With the window as the tray's, a click opens the Requests tab at the
  period (quotaView), not the Overview, which sums differently.
- docs/reference.md and gui-shell.md say so.

Run:
- TestTrayTotalIsTheLedgers (new): a Codex session-file call of 1000 in,
  200 out, 8000 cache read; the menu bar's sum equals ledgerPage's and the
  cell reads Σ9.2K. With trayTotalSum put back to SummarizeTop it fails
  (menu bar all zeros, ledger 1 call).
- TestTrayTotals/BesideCards updated for Σ, the cache and tab=requests.
- go test -tags nogui ./internal/gui (sandbox HOME via the package): ok.
- tray-totals, tray-usages, tray-cell-click .test.cjs, chromium and
  webkit, five languages, 1100 and 420: 70 pass.
- The Mac cell rendered with trayImagePNG and looked at: "Σ6.3M" over
  "$3.40", "Σ47M" alone, both inside the row width.
- gofmt -l, go vet darwin, GOOS=linux -tags nogui, GOOS=windows; builds.
Not tried: the real menu bar on the reporter's data.
2026-10-14 17:29:43 +08:00
yetone db0af71864 gui: the menu bar can show today's or the last 7 days' tokens and cost (#1984)
Settings → Usage → "In the menu bar" lists two more rows after the
subscriptions: "Tokens and cost today" and "Tokens and cost, last 7 days",
ticked and saved as a card is (ids "usage:today", "usage:7d" in
trayUsages; provider ids are [a-z0-9-], so the prefix can't collide). They
show beside the allowances or alone.

- trayusage.go: a total is a card built from usage.SummarizeTop(p, 0)'s
  Totals (the Usage page's own cached numbers, Input+Output as its
  tokensOf counts them): tokens over cost, in the currency Settings picks,
  "+" when some requests had no known price. On the Mac it is a Plain cell
  (no vendor logo; the bird beside it says whose it is); on Windows/Linux
  the tray's text label and tooltip ("Today in magpie / 1.2M tokens (912K
  in · 318K out) / ≈$3.40+ / 152 requests…"). Quotas aren't fetched when
  only totals are picked.
- Clicked, a total opens the Usage page's Overview at its period
  (quotaView → ?view=usage&tab=usage&period=…, read and dropped from the
  URL) or the panel's Usage tab at that period (panelUseFocus).
- Only today and 7d: the Usage page has no 3-day window, and a menu-bar
  number nobody can open in magpie at the same span would disagree with it.
- The pill names a lone total, and counts a mix as "{n} shown" rather than
  calling it subscriptions. Strings in en/zh/zh-TW/ja/de.
- docs/reference.md and gui-shell.md say so.

Run:
- go test -tags nogui ./internal/gui/ (sandbox HOME): ok. The new
  TestTrayTotals/BesideCards/TrayCount went red with each piece broken by
  hand (no Plain, no text branch, no quotaView branch, 3d accepted).
- tray-totals.test.cjs (new) plus tray-usages, tray-inuse,
  proto-menu-overflow (updated for the two rows), i18n-keys, panel-usage,
  allowance-open-read, tray-cell-click: 46/46 in Chromium and WebKit, five
  languages, 1100 and 420 wide. tray-totals fails 5/5 against the old
  app.js.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- The Mac cell image rendered and looked at (bird, "1.2M" over "$3.40").

Not tried: a real macOS menu bar, nor a Windows or Linux tray; the tray
tooltip is English, as the existing tray tooltips are.
2026-10-13 18:15:18 +08:00
yetone 4b8bfd4676 gui: Routing's By session heads a Claude Code (and every other agent's) session with its own name, not its UUID (#1293, luzhuang)
Only Codex sessions were named (from Codex's index). The page now also asks
POST /api/gateway/session-titles for the other agents' sessions it lists,
as agent:id keys, and sessions.Titles reads each from the agent's own files
the way the Sessions page does: the name given in magpie, else the agent's
own title (Claude Code's ai-title / custom-title), else the first prompt.
Each key is asked once; the names are kept on the page, so a live update
that replaces the rows keeps them. A session with no file here keeps its id.

TestSessionTitlesNameOtherAgents fails without the change (titles = map[]),
and routing-sessions' "other agents' sessions show their own names" times
out waiting for the name without the routing.js change.

Run: HOME=<temp> go test -tags nogui ./internal/gui ./internal/sessions;
go vet for darwin, linux and windows; the 72 routing GUI test files in
Chromium and WebKit (491 pass, 0 fail). No new t() strings.
2026-10-08 18:49:16 +08:00
Zhu Wang a13923a1e3 fix(routing): automatically group Codex title requests with their chats (#768)
* fix(routing): associate Codex title requests with applied chat titles

* fix(routing): address automatic title grouping review
2026-10-04 18:56:31 +08:00
lizhuo ebcd5281c2 gui: open matching allowance cards from macOS menu-bar quotas (#662)
* gui: navigate menu-bar quota cells to allowance cards

* gui: fix quota navigation in lightweight and folded views

Route quota hits through the existing status-item monitor rather than relying on local monitor ordering. Recreate released panels through panelWin, and expand hidden accounts before focusing them. Keep panel headers non-draggable and cancel pending navigation after five seconds or purposeful scrolling.

Add a native AppKit subprocess regression that fails with the former nil-panel dereference and verifies runtime-queued focus, closing, and recreation. Extend browser checks for folded accounts, expiry, cancellation, and panel drag state.
2026-10-03 19:01:13 +08:00
Zhu Wang 1adb2b571e feat(routing): group requests by session with names and estimated costs (#396)
* feat(routing): group requests by session with names and estimated costs

* fix(routing): address session view review feedback

Preserve Luna Reserve and other header fallbacks for ordinary Codex turn metadata; reuse metadata and the kind across trace and native accounting. Default to By request and persist the grouping choice. Store only token accounting fields in route history while retaining legacy JSON compatibility.

Add regressions for helper precedence, native kind accounting, history compatibility and grouping preferences.
2026-10-01 20:50:15 +08:00
c0f3fa012a usage: combine gateway and local session requests with model charts and account labels (#239)
* usage: Requests lists the agents' own session-file calls, put to the vendor and account their files prove, charts them by provider, agent or model, shows what was said, and the tray panel gets a Usage tab

The Usage page's Requests tab now covers requests an agent sends with its own sign-in (Claude Desktop's Code tab and Cowork, Claude Code, Codex), which never pass the gateway, and shows more of every request: why it failed, what was said in it, who it was of.

Requests tab: a strip of four totals (tokens, requests, cost, cache hit rate); the trend of one metric — tokens, cost or requests — as columns by the hour, day or week, told apart by provider, agent or model (both remembered), beside a ranking of the same that is its legend and a way in (a click lists only that provider's or agent's requests; a provider picker sits beside the agent's). The ranking is as tall as the chart and scrolls in itself, with no scrollbar: a slim rail in the card's margin shows how much there is and where it is (its thumb dragged, the rail clicked), and the edge with more beyond it fades; under the chart (860px and narrower) it shows whole. A row opens to its details: the vendor's error type and words, request id, endpoint, and what was said in it (input and output, read from the agent's session file when opened, the call that ended nearest the request — nothing stored). A refresh period (off / 5 s / 10 s / 30 s / 1 min) and refresh-now. The Overview says it counts gateway calls only; Requests and the panel say they count both. The tray panel gets a Usage tab (today / 7 / 30 days, provider picker, four totals, a small chart, top five, "Open Usage"), and is as tall as its tallest tab (#124).

Provider and account of a session-file call: never magpie's "claude" or "codex" subscription. Anthropic's when Claude Desktop's session metadata (not Claude-3p) names the account and organization, with that account's email; OpenAI's when Codex's rollout names a provider that is OpenAI's in config.toml — the built-in "openai", or a named one at OpenAI's address or signed in with the ChatGPT account and no base_url (requires_openai_auth) — with the creator account's email when the file records it. Anything else is "Local session", its recorded provider id and session account kept (CSV: session_provider, session_account). The config read is today's: a file names the provider id only.

Gateway: a failed call keeps the vendor's error text and type, request id and endpoint; a Claude subscription's failure uses the status Claude Code reports (api_error_status). A request turned away before any vendor was asked is logged, marked rejected, listed in Requests and left out of every total. The client's own session header is kept as native_session beside X-Magpie-Session, and a session-file call is matched to a gateway record by request id, then by that session, equal tokens and an end within 2 s, only when unique both ways.

Reading: session-file calls live in the session index main keeps on disk, parsed incrementally and outside its lock (Claude Code, Cowork in both Claude folders, Codex); the usage log is read on from where it was; a page builds the ledger once. Days are counted on calendar dates (DST). CSV gains request_id, endpoint, error_message, error_type, source, session_provider, session_account. i18n: one "Endpoint" (终结点), which a second key had turned for Azure's field.

Tested: go vet ./..., go build (also GOOS=linux/windows, -tags nogui) and go test -tags nogui ./... pass. The whole GUI suite in Chromium and WebKit, en and zh (Playwright 1.62.1): all 393 tests pass. On this computer's files (7 days): 3,330 Claude Desktop calls resolve to Anthropic with the account, 1,991 Codex calls on a named ChatGPT-signed-in provider to OpenAI (620 with the account; older rollouts don't record it), 9 Claude Code CLI calls stay Local session.

Co-authored-by: yetone <yetoneful@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* usage: a session-file call of one of magpie's own Codex or Claude accounts is told as that provider, beside the gateway's calls on it — "OpenAI" and "Codex" (or "Anthropic" and "Claude Code") read as two vendors when they were one subscription

Codex: an official route (above) whose creator account and user are one of magpie's Codex sign-ins (the CLI's own or a saved one) is magpie's "codex", with that account's email as the gateway's rows have it. Claude Desktop (not Claude-3p): an account and organization that are one of magpie's Claude sign-ins is magpie's "claude". Only while magpie has that provider signed in; another account, a rollout with no account recorded, or an ambiguous workspace stays OpenAI or Anthropic, and a relay stays Local session.

Tested: TestSessionCallsOfMagpiesAccountsAreItsProviders (the account matched, another account, none recorded, magpie's account through a relay, Desktop in magpie's and another organization, Claude-3p, magpie signed out) and TestLedgerTellsCodexSessionCallsAsMagpiesCodex (a gateway Codex call and a session call of its account one provider of two calls, another account's OpenAI). On this computer (7 days): 3,439 Claude Desktop calls are magpie's Claude, 626 Codex calls its Codex, 1,322 older Codex rollouts with no account stay OpenAI. go test -tags nogui ./... and the usage GUI tests pass.

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

* fix: 修复请求统计缓存膨胀与会话账号误归属 #239

调用明细改为按会话文件分片保存并限制内存缓存,汇总索引仅保留统计数据;网关日志按需读取。

严格匹配订阅账号与用户 ID,排除自定义渠道、非官方端点覆盖、外部 CODEX_HOME 及关闭的供应商。补齐零 token 失败去重、Codex 原始会话 ID、拒绝标记导出和面板显示修复。

通过全量 Go 测试、静态检查、受影响模块的并发检查、52 项浏览器测试及 macOS/Linux/Windows 构建;使用 35 万条合成调用验证索引体积与内存改善。

* fix: 降低请求统计刷新与写入开销并明确本地账号展示 #239

请求分片改为追加帧和字符串去重,分页复用未变化的紧凑快照,采用 LRU 并移出全局锁内的磁盘读取。缓存 Cowork 目录,补齐同前缀改写检测及崩溃临时文件清理。

本地记录仅显示匹配账号或本地会话,明确官方登录标记与请求路由的区别。默认今日与模型维度,Auto Review 复用共享目录定价并单独标注估价参考。

完整 Go 测试、vet、相关 race 和 52 项浏览器回归通过;提供 2000 文件及四个大会话连续追加的可复现性能对照。

* fix: 优化用量徽标与耗时分级并保护分页边界 #239

官方登录、API、订阅和本地会话采用独立颜色与柔和底色,兼容明暗主题。耗时按 10 秒及 30 秒阈值着色,保留估算标识与原始毫秒提示;无有效耗时显示短横线。

限制分页选取范围,避免超大偏移整数溢出及越界空页的无效堆构造。补充阈值、徽标对比度和极端分页参数回归。

* fix: 将账号与来源徽标分为两行展示 #239

* fix: 提高用量表格模型文字对比度 #239

发送模型和已知实际模型使用主题正文次级色,表头与时间同步加深。保留缺失值弱化、转发提示和本地日志来源说明。Chromium 与 WebKit 的中英文、浅深色主题 10 项界面检查通过。

---------

Co-authored-by: yetone <yetoneful@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 17:42:10 +08:00
yetone ead06b1ccf gui: a model kept for routing groups is said, not silently gone (悠悠哥 on Discord: after turning on 只通过路由分组使用, hy4 vanished from the agents' model lists) — a provider set to "Only through routing groups" (Unlisted) keeps its models out of provider.Catalog(), which feeds every agent's picker, /v1/models and the configs magpie writes; Served() still serves them, but only to the routing groups they are in or a request naming the id. A model in no group was therefore usable by nothing the UI offers, and nothing said so. The option keeps its purpose (the models stay out of the lists); instead /api/state now carries the unlisted models with the groups each is in, and the picker, finding one in its filter, says why it isn't offered: in a group, "agents reach hy3 by picking Mine" with a "Pick Mine" button; in none, "no agent can use it" with "Make a routing group of it", which opens the Routing page on a new group of that model (from the tray panel, the window is opened on it through window/main?view=routing&newgroup=…). The provider's editor, while the tick is on, names its exposed models in no group in amber, each a click from a group of its own (before saving, it says to make them in Routing once saved). /api/providers gives each model's groups. No left-border accent; the clicks scroll nothing (scrollOnPurpose). TestUnlistedModelsSaid and unlisted-models.test.cjs (Chromium, WebKit, en/zh) fail without the change. A sandbox magpie with an unlisted Hunyuan (hy3 in a group, hy4 in none) listed neither in the pickers, and said each as above. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass; unlisted-models, model-pick, routing-manual, click-scroll, old-webkit pass. 2026-10-01 16:20:11 +08:00
Aliceandraper 02d501894b usage: link request accounting to routing history (#361)
Co-authored-by: raper <raper@raperdeMacBook-Air.local>
2026-10-01 16:18:02 +08:00
yetone c6ca0ec3e5 gui: the tray panel's link to one request opens the Routing page on it again — ShowMain escaped the whole view it was given (831df85, v0.1.458, for magpie gui <tab>), so "routing&req=42" reached the window as one view named that, which is none: the window came up on no tab, the request not picked. Found reviewing #239, whose "Open Usage" link hit the same. The view mainView builds keeps its req as its own parameter (mainURL); only a tab named on the command line — magpie gui settings, a restart to update — is escaped (argView). Tested with a new TestMainURL (routing&req=42 comes through as view=routing, req=42; a command-line tab is escaped); it fails with the old escaping. panel-routing.test.cjs passes; go vet, go build (GUI, -tags nogui, GOOS=linux, GOOS=windows), go test -tags nogui ./... pass. 2026-09-30 13:09:27 +08:00
yetone 04dc3bca72 panel: a Routing tab shows the gateway's latest requests, and the allowances' tab is named Allowances (v on Discord #feedback: the panel's Usage tab and the window's Usage page mean different things, and the panel had no routing) — the tray panel had Agents, Usage and Profiles, its Usage being each subscription's allowance while the window's Usage counts requests and Routing shows where they went. The panel's tab now reads Allowances (额度; the window keeps Usage/用量, and the tab's id and remembered choice are unchanged), and a new Routing tab (路由) lists the gateway's last 8 requests as they come, from the trace the Routing page already long-polls (/api/gateway/trace, which routing.js polled in the panel too; no new endpoint): each a two-line row with the agent's dot, icon and name and the model it asked for, the time, then where it went (provider · account or key), the model that try sent and, when the reply named another model (the new served/swapped fields), the amber "served gpt-6-luna" (实际 …) tag of the Requests list, beside the tokens and time taken; a failed one says its status and why (429 · rate limited), one under way who is answering. Over them, today's calls and tokens (the Usage page's /api/usage?period=today, read when the tab is shown and after a request ends, at most every 5 s) and Open Routing. A click on a request opens the window's Routing page on it: POST /api/window/main takes req beside view=routing (mainView lets only a positive id through), and the page, loaded so, picks that request as a click in its list would (its story told) and drops req from the address. The panel's height counts the tab as its tallest, as the others; the tab redraws keeping the panel's scroll, the click moves nothing, no border stripe. Tested with a new internal/gui/tests/panel-routing.test.cjs in Chromium and WebKit, en and zh: the Routing and Allowances labels, four fixture requests listed newest first with agent, model, "Relay · team" and "Claude · ann@example.com", the served tag on the swapped one only (not on a dated name), the 429 row, times, no row overflowing, today's 42 calls · 1.2M tokens, a click with the panel scrolled asking for view=routing&req=100 and leaving the scroll as it was, Open Routing, and the window opened on ?view=routing&req=101 with that request picked and its story shown; and TestMainView. go build -tags nogui (and GOOS=linux, GOOS=windows), go test -tags nogui ./... and the whole GUI suite (102 tests) pass. Not tried in the real tray panel or with a live gateway: the window opening on the request is tested in the page, not through Wails. 2026-09-29 20:22:19 +08:00
yetone 4cc32dbcb0 routing: every request's route is kept on disk, for a day long gone to be looked at and replayed, with retention (历史中的路由记录是不是都应该保存下来,方便用户去回放?…这种历史记录会特别大,应该有自动的retention) — the trace holds only the last 60 routes, and only since the gateway started. Now each route, once done, is appended to ~/.config/magpie/routing/YYYY-MM-DD.jsonl; a day that is over is gzipped, days older than 30 are dropped, then the oldest until all of it fits 200 MB (today is never dropped), checked at most hourly. Route ids start at the time the gateway started, so they don't repeat across runs. /api/gateway/history?day= gives the days kept with their counts and a day's routes (its latest 2000). The Requests list has a chip per day (实时, 今天 3, 昨天, …): a day's requests can be picked, looked at, replayed all, or replayed from one on (从这里重放), with the real-time clock as before. Checked in a sandbox HOME against real DeepSeek: three requests written to the day's file, the gateway restarted, the list showed 今天 3 with them, 从这里重放 played them at 02:19:46 · 第 1/3, stop and 实时 came back to live 2026-09-29 02:22:35 +08:00
yetone e665d70b56 gateway: an Antigravity account Google wants verified says so, and rests (marsxxl: Antigravity 返回「Verify your account to continue」403) — Cloud Code Assist refuses such an account with a 403 whose details say VALIDATION_REQUIRED, a validation_url in their metadata (as pi-ai's google-validation reads it); magpie passed on only the message, and every reconnect went back to the account Google had stopped. Now provider.Verification knows the refusal (the reason, or its words) and APIError adds what to do: open the link, when it's https, in a browser signed in to that account, or else the Antigravity app (or Gemini CLI), then try again. The account rests half an hour as failVerify ("needs verification", 账号需验证) — the last one left too, which rested never — and for a minute the agent's retries get the same error from magpie without asking Google. The Routing page shows the rest with a Verify link and "It's verified — try it again", which lifts it (POST /api/gateway/unrest, Server.Unrest); an answer lifts it as before. Tested with fake upstreams in a sandbox HOME: with a link and without, held retries not sent on, a group falling back past it; the exact body marsxxl got isn't known 2026-09-28 20:56:33 +08:00
yetone cb609d2cb4 update: after an update on Windows one magpie is left, not two — a magpie running when another updated the binary (it runs on from magpie.exe.old) no longer downloads the update again to magpie.exe.new and swaps it in when it quits; it says a restart is all that is left. A magpie.exe.new that is magpie.exe over again is removed at start. The tray that found the gateway taken serves it once the magpie that had it is gone, checked every 15 s 2026-09-26 14:30:16 +08:00
yetone af5889085a gateway(routing, live): the Gateway view plays what routing does with each request as it happens — the site's Model Routing stage, driven by the gateway's own trace: the agent, magpie with the provider's routing, and its accounts or keys in the order routing weighed them, each saying what it was weighed by (how much is used and when it renews, kept for last, not known yet, resting and until when, left out as its plan doesn't list the model); a request travels to the one put first, one that fails shows what it answered and hands it on, and the story beside it says why the first went first, why each other stands where it does, how long a failed one rests and what said so, and what the agent got; recent requests can be picked to see how each was routed, and the counts are the gateway's since it started. Nothing is worked out again in the page: the gateway records each decision where it makes it. A vendor's Retry-After and rate-limit reset headers now come through with its error, so a rate-limited key or account rests as long as the vendor says rather than a minute 2026-09-25 02:28:32 +08:00