Commit Graph
153 Commits
Author SHA1 Message Date
yetone dc098c1e82 library: a skill from a folder follows GitHub once installed from there (biubiu8802 on X)
biubiu8802 (X, 2119602075864903924) downloaded a skill from GitHub and
put it in the Library from its folder, so it had nothing to update from
and no way to link it to GitHub. Installing it from its GitHub link now
links the two, the way an update of a CC Switch skill already does: the
library's skill by that name takes GitHub's files and GitHub as its
source. A check and an update cover it from then on, and the agents'
links keep pointing at it. When its own files aren't GitHub's, they go to
the backups like UpdateSkill's replace does, and the result says so. A
folder of the user's it was linked to stays as it is.

followsHere (skill_link.go) decides it. It links only a skill with no
remote source that wasn't renamed and is that skill: it traces to this
repository (CC Switch, the skills CLI's lock, a git checkout, From), or
it traces nowhere and its SKILL.md has the same description as GitHub's,
as an older download of it does. One traced to another repository, or
an untraced one that describes something else (mora1n's case,
TestInstallSetPutsAnotherByTheSameNameBeside), still goes in beside it
(skill_beside.go). A had skill with
the same files and no source is bound to the GitHub source it was found
in, so a later install of another repository's skill by that name goes
beside it, not over it (TestSameFilesByNameAreHad).

The probe marks such a candidate links:true. The GUI's Add list tags it
"links to GitHub" with a tooltip, and the report names "updates from
GitHub now" and "files of their own kept with the backups". The TUI's
probe list and result line say the same. The new strings are in zh,
zh-TW, ja and de.

Run on mote (macOS), on 64ecd0f69, then rebased on 8a58c0e30, whose
new commits touch none of internal/library, the TUI's library or the
library page:
- gofmt -l clean; go vet ./..., GOOS=windows go vet ./...,
  GOOS=linux go vet -tags nogui ./..., GOOS=linux go build -tags nogui
  ./..., GOOS=windows go build ./... all ok
- go test ./internal/library/... ok at this tree; ./internal/tui/...,
  ./internal/cli/... and ./internal/gui/ ok at the tree before the
  description check (that change touches internal/library only)
- GUI (chromium + webkit, 5 languages, wide and narrow):
  skill-install-link (new), skill-install-beside, skill-install-skip,
  skill-install-agents-all, skill-git-source, skill-too-big,
  provider-discovery, i18n-en-no-cjk pass. i18n-keys' "a plugin's words
  are its own" is red on main for three strings this change doesn't
  touch, already filed: #5332/#5327 ("View routing"), #5482 ("Use the
  library's"), #5426 ("No session ID").

Broken by hand: without the description check (the first version),
TestInstallSetPutsAnotherByTheSameNameBeside is red (caveman taken over).
followsHere returning false always turns
TestFolderSkillFollowsGitHub red (probed As:pdf-pro-biubiu) and
TestOwnSkillFollowsGitHubKeepsItsFiles red (linked [] kept []).

Not run: the full go test ./... suite. mote's suite lock had a queue
waiting up to 16h, so this change ran the packages it touches.
No real GitHub install either: the tests use a fake tarball server. Not
tried on Windows or Linux. The market's had-check (haveSkill) is
unchanged: a market skill with a folder copy by that name still counts
as had.
2026-11-09 11:29:51 +08:00
yetone 814a625a24 usage: the top refresh reads saved Claude accounts again (#5380)
The tray panel's Allowances refresh said "Allowances refreshed" but a
saved, non-active Claude account kept its old reading: claudeWindows runs
Claude Code's /usage for a saved account only under savedRefresh, which
only that account's own card refresh sets.

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

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

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

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

Not tried: a real saved Claude account's /usage run from the real tray
panel (the test fakes Claude Code's /usage per account directory); the
full GUI suite; the de/ja/zh-TW GUI runs (no string changed).
2026-11-06 00:35:39 +08:00
yetone 00d8aac596 routing: Free quota by expiry spends the soonest-lapsing free quota first (wowbbs)
wowbbs (and shamen_xiaohong) keep check-in free accounts in one group:
WorkBuddy CN x2, MiniMax Code, TraeCode CN and Qoder CN. They asked that
the group spend the free quota that lapses soonest first, go on to the next
when one is used up or has lapsed, and use a paid account only when no free
quota is left.

This adds `expiring` (provider.FreeExpiring, routes.FreeExpiring). It is a
group's only, picked in the Routing page's group menu, with
`magpie group set <g> routing=expiring` or in the TUI. Nothing changes for a
group or provider that doesn't pick it. A provider keeps refusing it, as it
refuses `cheap`.

- routes: Seat.FreePlan and Strategy.ByPlan. FreeExpiring has three tiers:
  - free seats (Free, a model at no cost, or FreePlan) by Expires, the
    earliest of the window renewals and Lapse, to the hour; an unknown
    expiry goes last and ties keep their listed order;
  - then the paid seats, as Smart orders them;
  - then the spent and resting seats, by when they come back.
- provider.FreePlan reads an account's plan word: free, trial, 免费, 试用,
  体验, 體驗.
- gateway: weighRouted fills FreePlan when the strategy asks. The trace's
  Weighed rows gain `expires`, so the Routing page's story can say "its free
  quota is lost soonest, in 1d 2h". There are also lines for "a free one with
  no expiry told" and "no free quota left, so the paid one".
- GUI: an option in the group menu, the mode line, the story lines, and
  i18n in zh, zh-TW, ja and de. app.js only adds `expiring` to ROTATION,
  paid for by a shorter comment beside it, so the core is 11 bytes smaller
  than at its base.
- docs: gateway-routing.md (order of keys and accounts) and
  plugin-runtime.md (Seat and Strategies).

Plugins whose usage doesn't say when their free quota lapses got issues
rather than edits:
- magpie-community/plugins#718: Trae sums its packs; the soonest end comes
  from any pack, spent or past, and there is no runsOutAt.
- magpie-community/plugins#719: Qoder's plan is the raw userType
  personal_standard, which doesn't read as free, and its add-on, shared and
  dedicated pools have no expiry.
WorkBuddy (Free plan, resetsAt and runsOutAt) and MiniMax (Free, runsOutAt
on credits) already report what this needs.

Run, all on mote via mote-run at this tree (base 0ee424e3e):
- gofmt -l internal plugins: empty. go build ./....
- go vet of routes, gateway, provider, cli and tui; the same with
  GOOS=linux -tags nogui and with GOOS=windows.
- go test ./internal/routes ./plugins/rotation ./internal/tui: ok.
- provider -run TestFreePlan|Group|Routing: ok.
- cli -run Routing|Group: ok.
- gateway -run TestGroupSpendsFreeQuota|Wallet|Free|Cheapest|Routing|Weigh: ok.
- internal/gui -run Budget|Size: TestCoreScriptBudget is red, already red
  at the base (1,534,154 > 1,533,802, #5139). This change takes the core
  down 11 bytes and doesn't raise the budget.
- GUI, node --test in chromium and webkit, en, zh, zh-TW, ja and de, wide
  and 420px:
  - routing-free-expiring (new), routing-group-strategy, routing-cheapest-first,
    i18n-keys, builtins, group-member-free and provider-count-free: 176 of
    176 pass;
  - every routing-*.test.cjs: 2,478 of 2,520 pass. The 42 reds are in ten
    files (routing-rule-remove, rule-drag, rules-line, rule-models,
    row-swap, steady, order-unknown, steps-cap, story-shrinks and
    keys-fold). Run alone at this tree they give 27 reds, and at the base
    0ee424e3e 25, the same tests. They are filed as #5088, #4585, #3096,
    #3789, #3799, #4627, #4628 and #4629.

Again after rebasing on origin/main 0e804be29: gofmt; vet of routes,
gateway and provider; the same Go tests: ok. routing-free-expiring,
routing-group-strategy and i18n-keys: 62 of 62 pass. The core is 1,534,034
here, against main's 1,534,045.

Red on the old code: TestGroupSpendsFreeQuotaSoonestToExpireFirst at
0ee424e3e gives "pro,wb1,wb2,mm,qoder" where it wants
"mm,wb2,qoder,wb1,pro".

Broken by hand: with FreePlan never set, the gateway test gives
"pro,mm,wb2,qoder,wb1" (red). routing-free-expiring.test.cjs reads strings
that exist only with this change. routing-group-strategy's two menu counts
(11) went red with the new option, and they now count 12.

Not tried: no real account of any vendor. WorkBuddy, MiniMax, Trae and
Qoder check-in accounts were not routed live. The order was tested on
fabricated allowances shaped as their plugins report them. The full
`go test ./...` runs after the push.
2026-11-04 17:11:55 +08:00
yetone 50265256ba library: a note on a skill or an MCP server, the library's own (youyo.p_10001)
youyo.p_10001 on Discord: with many skills and MCP servers installed,
you can't tell what each is for or which to use. A skill has the
description its author wrote for models, often in English and about
what it does, not why you installed it. An MCP server has nothing but
its command and its tool list. So each now takes a note in the user's
own words.

- Server.Note and Skill.Note in library.json: one line of at most 200
  characters, whitespace run together (checkNote), as a hook's
  description (#2011). A longer one is turned away, not cut.
- The server editor has a Note field under the name. A skill's reader
  (2a19043af's file reader) has one over its files: Save shows once it
  changes, saves the file being edited with it, and a changed note is
  asked about before the dialog closes. SkillNote, POST skills/note.
- A row shows the note in place of its command or description, so rows
  keep their height; the tooltip gives the note, then that line. The
  skills' filter matches notes.
- No agent is given a note: not in any agent's MCP entry, a project's
  file, the MCP router's list or a skill's copied SKILL.md.
- A sync carries it (CarriedSkill.Note; a server goes whole), and
  clearing it is carried too. An older magpie on another computer
  doesn't know notes: a bundle it writes has none, so a sync from it
  clears them. The TUI's server editor keeps a note as it was.

Run at the pushed head:
Run at the pushed head (on origin/main f168dd278, then
rebased onto 94d0fbfcd, whose two commits change only
migrate_zcode.go and the searcher-pick test):
- mote: go test -timeout 45m internal/library (TestNoteNeverGiven,
  TestNoteCarried, TestNoteTooLong), gui, tui, davsync, backup: ok,
  except internal/gui's TestMainWindowCorners/macOS_26_SDK, mote's SDK
  (#3949). GOOS=windows go vet of library, gui, tui and GOOS=linux of
  library, tui: clean. gofmt -l: clean.
- mote, both engines, every language, narrow and wide: skill-edit (the
  skill reader's note), library-mcp-json (the server's note, its row and
  the filter), mcp-editor-cancel, library-mcp-win-line, market-address,
  market-have, i18n-keys: 108 of 108.
- WSL, the whole GUI suite: no red in a library file that origin/main
  hasn't too (see the command commit; #4120, #4471 for the rest).
- "Note" is in core i18n.js, not the plugin's: agent code says it as a
  word. The rebase had dropped main's title on a server row's command
  line (library-mcp-win-line went red); it is back, and with a note the
  tooltip gives the note, then that line.

Broken by hand, each red, then restored:
- add("note", s.Note) in Claude's MCP format: TestNoteNeverGiven
  (.claude.json held the note).
- the carry of Note left out: TestNoteCarried.
- note left out of the server editor's save: the GUI test, 22 of 22.
- notes left out of the skills' filter text: the GUI test, 22 of 22.
- the note's save left out of the skill reader's Save: skill-edit, 22
  of 22 (Save never goes away).
- the note left out of the reader's unsaved check: skill-edit, 22 of 22
  (closing never asks).

Not tried: a real sync between two computers, a real agent reading its
config (the guard reads every file magpie writes in a sandbox HOME), a
real app window, Linux WebKitGTK.
2026-11-03 21:43:54 +08:00
yetone af55a7917f tui: quitting where magpie opens at login says how to have the gateway handed on (#3756)
With #3372, Open at login on Linux reads a package's own autostart entry
in $XDG_CONFIG_DIRS (nixpkgs ships one). JoeyWu-tech's #3756 asked what
`magpie daemon install`'s guard and `magpie tui`'s hand-off as it quits
should count on a box no desktop logs into (NixOS-WSL, a server over SSH),
where nothing ever starts that entry.

Decided: both keep counting what Open at login shows (autostart.Enabled).
A session check can't tell (an SSH login into a desktop box has no
DISPLAY either), and counting less than the switch shows would install
the service beside an app the desktop does start. The install already
refuses with "run `magpie autostart off` first", which is the way out.
The terminal's quit only said "the gateway stopped", with nothing about
why or what to do; it now says magpie opens at login and serves it then,
and that `magpie autostart off` has magpie tui hand it on where no
desktop logs in (atLoginNote). Off Linux and with nothing connected the
note is as before.

What was run (wsl-run, magpie-desktop Ubuntu 24.04, go1.26.8):
  go test -tags nogui -count=1 ./internal/autostart ./internal/daemon
  ./internal/testenv ./internal/tui: ok
  With keep.go as before (the test kept): TestKeepGatewayAsTheTerminalQuits
  red, "app at login: ... the gateway stopped with magpie tui; ..."
  gofmt -l: nothing

Not tried: a real NixOS-WSL login; mtul0729 ran the #3372 patch on real
NixOS + COSMIC, at the systemd generator's level.

Batch run, at tree 104d75f0a (the twelve coffemon ports together, on
origin/main 7d022bdb6), mote, macOS, go1.26.8:
- go test -tags nogui -count=1 -timeout 45m on the packages the batch
  changes (agent, autostart, daemon, gateway, library, proc, provider,
  sessions, testenv, tui, gui): ok each.
- GUI, node --test with Playwright 1.62.0, Chromium and WebKit:
  library-*.test.cjs and i18n-keys.test.cjs, 1044 of 1044 pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... and go build ./...: ok at cdd7c8e46, the same
  batch on origin/main 00098f12b one rebase before.
- The whole go test ./... at cdd7c8e46: 86 packages ok, one red,
  internal/cli TestEveryRouteHasACommandOrIsNamed (GET
  /api/context/reply has no command), red on main too (#5026).
- Linux (wsl-run, Ubuntu 24.04, at 339055896, the batch on f4c664a09):
  proc, autostart, testenv, tui ok; agent: only TestGrokInstalled red
  (#3548); #4033's proc.Look reds (Zed, Copilot, Qoder, Cursor, Omp)
  pass.
- Windows (win-run, Windows 11, at 339055896): proc, autostart, testenv,
  tui ok; library and agent red in the same tests as on origin/main
  f4c664a09 (#4115, #1827, #4786; #5068, #5069, #5070 filed now).
- Rebased onto origin/main fb1f4856a (three commits, no file in
  common with the batch) and run again at the pushed tree: gofmt -l
  nothing, go build ./... and go vet ./... ok; go test -tags nogui
  sessions, agent, autostart, tui, proc, testenv ok; i18n-keys and
  library-* 1044 of 1044 pass.
- Not run before the push: the whole GUI suite (a run at cdd7c8e46 was
  cut off at 1170 of ~1174 tests when mote rebooted; it runs again after
  the tag and any red is filed).
2026-11-03 20:38:11 +08:00
yetone a9a8f11e7f plugin, proc: a plugin host is waited for when it ends, not when its stdout does
acezan on Discord (v0.1.2819, Linux x86_64, a systemd service): after
47 hours, 57 <defunct> magpie-bun children of magpie, growing toward the
unit's TasksMax until a restart.

One cause: the plugin host's only cmd.Wait ran in host.read after its
stdout reached EOF. A program a plugin started that kept a copy of the
host's stdout (Bun.spawn given Bun.stdout, which host.js's spawn guard
doesn't catch, #5063; a daemon left behind) held that pipe open past the
host's end, so EOF never came, Wait never ran, the host was never marked
dead, and every host stopped (Restart, a moved proxy, hostStale) stayed a
zombie until magpie quit. Reproduced on Linux (WSL magpie-desktop,
Bun 1.4.2): one more Z-state bun under the test process per Restart,
1, 2, 3, 4 over four rounds. The other cause, magpie web's restart to
update leaving the running host behind its exec (#3285), is the next
commit.

- proc.Output (new, internal/proc/output.go) gives a command's stdout and
  stderr pipes of magpie's own and waits for the command the moment it
  ends. Its readers then have OutputGrace (2s) to read the last lines;
  the pipes are closed after that, which ends a read held up by a
  grandchild. startOn uses it, and a reap goroutine fails the host when
  its child ends. host.read no longer calls Wait. The tests' fake hosts
  (no child) keep cmd.Wait.
- Every other start that wasn't waited for now goes through
  proc.StartReaped (Start, then go cmd.Wait()). Process.Release doesn't
  reap on Unix: codexrelay.Start (a relay that can end while magpie
  runs), tui serveInBackground, uninstall's startAfter, update's
  runAfterExit and OpenBeside (no Wait at all), and Windows' Reexec.
- TestEveryStartedCommandIsWaited (internal/proc) parses every non-test
  .go file. In each function, an x.Start() on a command needs an
  x.Wait(), or x handed on (a call's argument, a struct field), and
  .Process.Release() is refused. It found exactly the sites above.
- docs/subsystems/provider-plugins.md says how the host is reaped.

Checked and left as they are (each waits): the StartTree callers
(provider/install, library mcp_run and mcp_check, gateway claude_warmup
and claude_subscription), pii/serve, provider grok and claude_signin,
claudetui child_unix and wslread, awake, every other bun start (bun.go,
bunupdate, store, dist use Output/CombinedOutput).

Run at 82460a2f9 (on origin/main 40a287b21):
- mote (macOS): gofmt -l clean; go vet on the touched packages,
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: ok.
  go test -count=1 -timeout 45m ./internal/plugin ./internal/proc
  ./internal/codexrelay ./internal/tui ./internal/uninstall
  ./internal/update: all ok. -race -count=3 of the new proc tests: ok.
- WSL magpie-desktop (Linux): the same six packages ok, including
  TestHostReapedWhileItsChildHoldsStdout with a real Bun host; -race
  -count=3 of it and the Output tests: ok.
- Windows (xiaomi-gpu), at the tree before the rebase (base 5ee5274bd):
  proc and codexrelay ok. plugin and update had TestPiPackage,
  TestLoadConcurrentWithSavesAndEdits and TestPackagedByDpkg red; each
  fails the same at untouched origin/main 40a287b21 on that box, 3 of 3,
  and is filed (#4115, #1827, #4603).

Broken by hand, each red:
- host.go back to StdoutPipe with Wait only after EOF:
  TestHostReapedWhileItsChildHoldsStdout fails on Linux ("the host isn't
  marked ended 15s after Restart").
- Output.Start waiting for the readers before Wait:
  TestOutputWaitsPastWhatHoldsIt fails (not waited for in 10s).
- codexrelay back to Process.Release: TestEveryStartedCommandIsWaited
  names relay.go:89 and :92.

Not tried: a full go test ./... (mote and WSL were each running other
sessions' package runs, load 39 and 110); a real magpie serve or web
running for hours on Linux; the host test on macOS (no /proc; the
Output test runs there). Not changed: killing what a host left behind
(its process group) when it is stopped; an orphan like the sleep above
stays in the service's cgroup until it ends on its own.

Reported by acezan on Discord.
2026-11-03 17:58:31 +08:00
yetone 6b81344301 library: the keep-here switch says sync, and is on while it syncs (bin.90)
bin.90 on Discord read the Library editor's 「只在这台电脑」 switch as a
LAN-sharing switch: "this computer only" says nothing about what it keeps
from where. It is about sync, so it now says so.

- Library editor (MCP servers, skills): the switch is "Sync to your other
  computers" (同步到其他电脑 / 同步到其他電腦 / ほかのコンピュータと同期 /
  Mit deinen anderen Computern synchronisieren), on while the server or
  skill syncs. Its note says off keeps it here, and a sync from the
  others neither removes it nor replaces it.
- The stored value keeps its meaning: `local` true is still kept here.
  The switch shows !local and saves !on, so every saved library.json,
  sync payload and CLI flag (`magpie library mcp local NAME on|off`)
  means what it meant.
- Row tag: "Not synced" (不同步 / 同步しない / Nicht synchronisiert) where
  it said "This computer only", in the Library, the TUI ("not synced ·")
  and `magpie library` output.
- Agents page sibling (the same words for an agent's picks): its menu
  item is "Don't sync picks to your other computers", its tag "Not
  synced". The agentsHere setting is unchanged.
- docs/subsystems/library.md and sync-backup.md name the new labels.

app.js stays in its budget: origin/main 8af751987 was already 31 bytes
over coreScriptBudget (1,533,833 > 1,533,802), so a comment in
setAgentHidden was cut to one line (core 1,533,756 now), no raise.

Run on mote, rebased on 8af751987, budget again at 2cfeda3d3:
- GUI: mcp-local-server, agent-here, i18n-keys, skill-off-here: 78/78
  before the rebase, in Chromium and WebKit, every language, at 390, 640
  and 1100 wide and in the panel; after it agent-here, i18n-keys and
  mcp-local-server 56/56, agent-here again 30/30 after the trim.
- go test ./internal/tui ./internal/cli ok; ./internal/gui ok except
  TestMainWindowCorners/macOS_26_SDK, mote's macOS 27 (#3949, open,
  the same without this change); TestCoreScriptBudget ok after the trim.
- go vet ./internal/tui ./internal/cli ./internal/gui; GOOS=linux go vet
  -tags nogui and GOOS=windows go vet of tui and cli; gofmt -l clean.

Broken by hand: saving `d.local = on` (no negation) turns
mcp-local-server red (expected 'false', got 'true').

Not tried: a real sync between two computers with the switch flipped;
the stored value's meaning is checked through the saved request only.
2026-11-03 12:21:49 +08:00
yetone c28220a5e7 sessions: a Codex thread saved on another provider resumes from Sessions
mrten_95615 on Discord: opening a Codex session from Sessions ran
`codex resume <id>` and Codex 0.166 stopped at "This chat uses custom,
but your current provider is magpie. Switch to custom to continue."
(modelProviderMismatch). Codex 0.166's app-server resumes a thread only
on the provider it was saved with (its state-database row, else its
session_meta), checked against the one config.toml (with -c) selects
(codex-rs app-server config_manager.rs load_for_resume); no flag lets a
resume go on another provider, and a provider config.toml no longer has
fails as modelProviderNotConfigured. Codex 0.165 resumed it on its own
provider without asking.

sessions.ResumeNow is the line that runs when the user opens a session
(GUI Terminal, TUI enter); the listed line is unchanged and nothing more
is read on a listing. For a Codex thread saved on a provider other than
the one Codex is on:
- config.toml still has that provider's table, or it is a Codex
  built-in (openai, amazon-bedrock(-runtime), gcp, ollama, lmstudio):
  `codex resume -c model_provider=<it> <id>`. Codex runs that embedded
  (no shared daemon) on the thread's own provider.
- the provider is gone: MoveCodexProvider moves the thread to the
  provider Codex is on (files copied to magpie's trash first, the state
  row too) and it resumes there, the only way Codex resumes it at all. A
  thread written to in the last minute or open in a Codex is left
  (ErrActive) and the plain line runs.
A WSL distro's Codex session and every other agent are as listed.

Run at this head (mote):
- go test -count=1 -run 'TestCodexResume|TestMoveCodexProvider|TestCodexProviderIn' ./internal/sessions: ok
- go vet ./internal/{sessions,gui,tui}, GOOS=linux -tags nogui and GOOS=windows vet of them: ok; gofmt -l: clean
- At this head (rebased on origin/main bf05291e2): go test -count=1
  ./internal/sessions ./internal/tui: ok; ./internal/gui: ok but
  TestMainWindowCorners/macOS_26_SDK (#3949, mote is macOS 27; this
  change touches only gui/sessions.go's terminal route); go vet darwin,
  GOOS=linux -tags nogui, GOOS=windows of the three: ok; gofmt -l clean.
- Full suite before the rebase (go test -tags nogui -timeout 45m ./...
  on mote, at eb779ce92 + this change): 86 packages ok; internal/gateway
  red on TestCodexPoolSaysTheClientsVersion alone (#4807, open, a full
  package run's known red). Not re-run after the rebase.
Broken by hand: ResumeNow returning the listed line, TestCodexResumeOnItsProvider
fails "resume ... && codex resume 01a0bdc9-..., want ... codex resume -c
model_provider=custom 01a0bdc9-..."; with the move dropped it fails
"the thread's rollout wasn't moved to magpie".
Real Codex: codex-cli 0.166.0 (npm darwin-arm64) in a sandbox
CODEX_HOME with two fake Responses servers: a thread made on "custom",
config.toml switched to magpie. Plain `codex exec resume` failed with
the reporter's modelProviderMismatch; ResumeNow's line resumed it and the
turn reached custom's server. With custom's table removed, plain resume
failed with modelProviderNotConfigured; ResumeNow moved it and the turn
reached magpie's server. The TUI `codex resume -c model_provider=custom`
was also driven in tmux (resumed, turn on custom, "Running without the
shared background server" warning). Codex 0.165.0 resumes it plainly.
Not tried: a Codex profile that names its own model_provider (a -c
override may lose to it); the Codex desktop app's resume; Windows'
PowerShell line (same flag, not run there).
2026-11-03 10:50:30 +08:00
yetoneanderlinerd 1cb4d43013 profiles: a saved profile renames, in its details, the TUI and magpie rename (#2721, erlinerd)
erlinerd's patch on #2721 (profile.Rename, /api/state profile/rename,
a Rename button in the details), reviewed against main and adapted:

- profile.Rename trims both names, refuses an empty, taken or missing
  name and leaves profiles.json as it was, renames by case only
  (home -> Home), and keeps what the profile holds.
- GUI: Rename turns the details' name into a field. Enter renames
  through profileAction, so the chip is renamed at once, pending, and
  rolled back with the error if magpie refuses; the details stay open
  under the new name, with In use kept. Escape or a click away puts
  the name back. The field lives in profilerename.js, imported on
  press, so the core script stays under its budget (no raise; 50 bytes
  under after comments in app.js were cut). While the field is open
  In use, Apply and Rename hide so a 360px panel's field has room.
- TUI: ctrl+e on a profile renames it on the name line.
- CLI: `magpie rename <old> <new>`; a flag is never taken for a name.
- WebDAV: a rename syncs as the old name gone and the new one in
  (davsync test).

Run on mote at 47672f11c (on 70b96126e), and again after rebasing on
52195b6b0 (backup), as 3b279fdee:
- go test ./internal/profile ./internal/cli ./internal/gui ./internal/tui
  ./internal/davsync: ok except TestEveryRouteHasACommandOrIsNamed
  (#4826) and TestMainWindowCorners (#3949), both red on origin/main
  07f4d46c5 too. gofmt clean; GOOS=linux (-tags nogui) and
  GOOS=windows go vet ok.
- GUI, chromium and webkit: profile-rename (en, zh, zh-TW, ja, de;
  900x560 window and 360x420 panel), panel-profiles, profile-confirm,
  profile-in-use, profile-details, hermes-profiles,
  view-wheel-after-click, i18n-keys, gui-de, gui-ja, gui-zh-tw,
  editor-roomy: 219 pass, 0 fail. After the rebase: profile, cli,
  gui, tui and vet again (same two reds only, core budget ok), and the
  GUI files above with auto-backup in place of editor-roomy: 161 pass.
  Then rebased over ea51526b6 (gateway, plugin, provider only; no
  file of this change, no GUI asset) without another run.

Broken by hand, each red, then restored:
- Rename comparing names with EqualFold: TestRename red (case-only).
- Dropping the CLI's "-" check: TestRenameCommand red.
- Dropping `profileOpen = to`: profile-rename 22 of 22 red, both engines.

Not tried: the real app on Linux (WebKitGTK) or Windows; a rename
synced over a real WebDAV server.

Co-authored-by: erlinerd <erlinerd@outlook.com>
2026-11-02 18:37:25 +08:00
yetone 5ef19d0073 tui: the Usage page reads again while a read is under way, and on each opening (sean_80289)
sean_80289 on Discord: in the TUI the remaining-usage panel didn't show
new numbers; only refreshing each account on its own page did. The page
read the quotas once per TUI start, unasked, so it showed what was kept
and never what a read under way brought.

It now does what the GUI's Usage page does (#959):
- Opening the page more than 30s after the last ask (quotasOpenGap, the
  GUI's QUOTAS_OPEN_GAP) is an asked read (provider.Asked,
  AskClaudeUsage); within 30s it reads what is kept.
- While provider.SubscriptionUsageReading() says a read is under way, it
  reads again every 1.5s, at most 20 times, as the GUI does on
  X-Magpie-Reading; it stops when the page is left.
- "r" asks again. An answer to an earlier load is dropped (qgen).

Run on mote at a8d6a861a, one commit (internal/proc only) before the
pushed head: go test ./internal/tui ok; go vet
internal/tui internal/cli for darwin, linux (-tags nogui) and windows;
gofmt -l clean. go test ./internal/cli: TestEveryRouteHasACommandOrIsNamed
is red on origin/main too (POST /api/usage/checkin-account, #4826), not
this change.

At the pushed head after the rebase: go build ./... ok, go test
./internal/tui ./internal/proc ok.

Broken by hand: with the re-read in gotQuotas taken out and goTo back
to reading only once, TestUsagePageAsksAgainWhileReading,
TestUsagePageReadsAgainOnReturn and TestUsagePageAsksAgainAtMostTries
went red.

Not tried: a real TUI session against signed-in accounts; the tests
drive the model with a fake read.
2026-11-02 16:01:44 +08:00
yetone 9162277b91 routing: Until used up stays on the next account once the first is used up (dzxx0496)
dzxx0496 on Discord: with free accounts one after another, the first used
up, requests went to the second; when the first renewed they went back to
it ("如果第一个恢复了,它又优先用第一个了"). No routing did what they asked:
In order and Smart both put the first back first.

A new routing, Until used up (drain, 用完再换): requests stay on one seat
until its quota is used up, then go on to the next in the list and stay
there. A seat counts as used up when its known allowance is at 100% or
it was refused for quota or credit (failQuota / failCredit, routes.Drained
called where the rest is recorded, so a failover inside one request moves
the pool too). A rate limit or other failure only passes it over while
it rests, as In order does. Each pool (a provider, a group/<id>) keeps its
own place; routes.Forget clears it.

Offered wherever a routing is picked: the provider editor, a group's row
menu and editor (app menu, no native select), the TUI, `magpie group set
<id> routing=drain` and a provider's routing=drain. Nothing defaults to
it, so no saved setting changes. SpentShareOf is 100 for it, as for In
order. Words in en, zh, zh-TW, ja and de (i18n.js and the routing
plugin's own), docs/subsystems and the site's start page (en, zh, ja).

Tests:
- internal/routes/drain_test.go: stays on the next when the first renews,
  through a rate limit, all used up, a seat gone, per pool, Forget,
  Drained after a renewal.
- internal/gateway/drain_test.go: a real request path with a fake upstream;
  k1 refused for quota, k2 takes over, k1 renews: drain stays on k2,
  In order goes back to k1. Red without the Drained hook (request 3 went
  to k1). A rate limit comes back to k1; drain is saved on a provider and
  a group.
- routing-drain.test.cjs: the Routing page's why and mode line in 5
  languages, 1100px and 420px, Chromium and WebKit; red on the old assets
  (20 of 20).
- routing-group-strategy, routing-save, builtins: the menu has 11 routings.

Run on mote (macOS) at origin/main 699ddf152 with this commit and its
two neighbours (nb5p chip, dzxx0496 renewal, dzxx0496 Until used up).
Pushed on b2145eac1, whose five commits since change app.css and app.js
only for a key row's chips; at the pushed tree gofmt, the gui, routes
and gateway vets (Linux nogui, Windows), TestCoreScriptBudget (core
1,532,891), the Drain Go tests and 11 GUI files (gateway-model-chip-
height, routing-drain, routing-renews-stay, routing-behind-why,
routing-group-strategy, routing-save, builtins, i18n-keys, gui-de,
gui-zh-tw, key-row-chips-fit) were run again: 190 of 190 ok.
- gofmt -l clean; GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./... and go vet ok.
- go test internal/routes, internal/gateway, internal/provider,
  internal/cli, internal/tui, plugins/rotation: ok; internal/gui's
  TestCoreScriptBudget ok (core 1,532,816 of 1,533,105).
- GUI: routing-*, builtins, gateway-model*, model-chip*, i18n-keys,
  gui-* and codex-credits-last in both engines: 2211 tests, 68 red,
  none new: model-chip-steady 20 (#4388), gui-ja's {agent} string
  (#4580), and 11 routing-* files under load (#4585, #3789, #3799).
  The same 11 files run alone at cdfdb62c6 were 32 of 116 red, and 26
  with the stack, the same tests but rule-remove, whose red languages
  vary run to run (9 cases, then 5). model-chip-steady was 20 of 20 red
  at cdfdb62c6 alone.
Earlier, at f811bf291 with the stack: go test -timeout 45m ./... had 82
packages ok, internal/gui red only on
TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
TestMainWindowCorners/macOS_26_SDK (#3949). The whole GUI suite had 301
of 16930 red in 52 files. Those 52 files rerun had 272 red with the
stack and 276 at f811bf291 alone, the same tests.
2026-11-01 09:53:50 +08:00
yetone 20482d71ff library: a skill by a name the library has from elsewhere goes in beside it
mora1n on Discord: anthropics/skills' skill-creator and openai/skills'
are two skills by one name, and only the first could be added; the
second was skipped as "another skill called skill-creator, left as it
is". The library keyed being had by name in every place that asked.

Now being had is decided by source (hadSkill): the same source under any
name here, or a skill with no source (taken in from an agent's folder)
by that name with the very same files. Another skill from GitHub or a
git repository whose name is taken goes in beside it as
<name>-<owner> (skill-creator-openai), then owner-repo, repo, a number,
at most 64 bytes (freeSkillName in skill_beside.go). The library's copy
of its SKILL.md gets that name in the front matter's top-level name:
line (nameSkill), so no agent sees two skills by one name; Skill.Called
keeps the name it came with, and the carried bundle carries it. Its hash
is of the renamed copy, and checks (GitHub and git) and updates compare
what they fetch renamed the same way (fetchedHash), so it doesn't read
as edited and an update keeps the name.

The class: probe (Candidate.Have now means this skill; Candidate.As is
the name it has or would get), installFrom (listed and unlisted folder
by that name), the new-skills check (no longer drops a skill because
its name is taken), the market's had check (by name only for a skill
with no repository: none or a folder), carry, the TUI's probe list and
the GUI's probe list ("adds as {name}" with why in its title, "In the
library as {name}"; zh, zh-TW, ja, de; the tag is cut short in its row).

Old data: nothing is renamed. A skill already in the library keeps its
name, folder, SKILL.md and agent links; library.json without "called"
reads as before. Only a skill added from now on can get another name.
Not changed: a folder of the user's own is linked as it is and its
SKILL.md can't be named apart, so one by a taken name is still skipped,
now saying to rename it in its SKILL.md; and an agent's own skills
folder still holds one skill per name (an agent's own skill by the
library's name is settled by Use library / Keep agent's as before).

Run (mote, at c6fd4b37c on origin/main 6a900e0d0, then rebased on
0fe9f97c1, which touches only claudetui, gui and provider):
- gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build ./..., go build -tags nogui:
  clean.
- go test -tags nogui -count=1 -timeout 45m ./...: 82 packages ok,
  internal/gui red only in TestSettingsSaveKeepsWhatItDoesNotSend
  (SearchAll, #4514, open on main, not this change).
- After the rebase: internal/library and internal/tui ok.
- GUI, both engines: skill-install-beside (new), every skill-*,
  library-*, found-skill-*, remove-found-*, mcp-*, i18n-keys, gui-ja,
  gui-de, gui-zh-tw, font-cascade, inner-scroll-contain, win-fonts:
  1427 tests, 1423 pass. The 4 reds fail the same at origin/main
  3baf3b6df run alone: gui-ja (#4580), i18n-keys "Unmarked" (#4524),
  library-row-remove chromium (#3099).

Red on the old code: the anthropics-then-openai install against
origin/main code fails with "the library already has another skill
called skill-creator, left as it is". Broken by hand: fetchedHash made
to hash the fetched files unrenamed turns
TestSameNameFromAnotherSourceGoesInBeside red (hash mismatch); the
.lib-pick > .lib-tag rule removed turns skill-install-beside red ("the
tag stays in its row") in both widths.

Not tried: real anthropics/skills and openai/skills installs in a
sandbox HOME (the tests serve both repositories' layouts as tarballs;
the fixtures put both at skills/skill-creator. The real openai/skills
keeps it under skills/.system, which a probe of the repository's top
doesn't walk into; that is how probing has been and isn't changed
here); Windows and Linux runs of the GUI.
2026-11-01 02:02:24 +08:00
yetone ceeb73a0f1 app: the desktop app writes its log to app.log; magpie log and Settings › About › Log find it
rayem1w on X (0.1.2330, macOS) was asked for ~/Library/Logs/magpie/serve.log
while chasing a Codex "hit a snag" through the gateway, and had no such
folder. Only the launch agent (magpie daemon install, written by launchd)
and a gateway magpie tui left running wrote a log; the app opened from the
Finder, the Dock or the Start menu logged to a stderr nobody reads, on
every system.

Now runGUI and runPanel (magpie, app, tray, panel, a window view, a
magpie: link) call applog.Start before gui.Run. It sends the standard
logger (the gateway, the plugin host, providers and Wails' error handler
all log through it) to app.log as well as stderr, and points
debug.SetCrashOutput at it so a panic's trace is there too:

  macOS    ~/Library/Logs/magpie/app.log
  Windows  %LOCALAPPDATA%\magpie\logs\app.log
  Linux    $XDG_STATE_HOME/magpie/app.log, else ~/.local/state/magpie/app.log
  portable data/logs/app.log

app.log, not serve.log: on a Mac launchd writes serve.log for the service,
another process. The file is 0600. At 5 MiB it becomes app.old.log (two
files at most); when another magpie (an update's new process) rotated it
already, it is only opened again; when it can't be moved it is emptied.
stderr goes first, through a writer that never fails, since io.MultiWriter
stops at a failed writer and an app opened from Explorer has no stderr.

Secrets: the log calls name header names and paths without queries; no
key or token was found logged (grep of log.Print* in gateway, provider,
plugin, gui, agent). scrub masks bearer/basic credentials, key/token query
parameters and sk-, AIza, gh?_ and JWT shapes anyway.

How a user finds it: Settings › About › Log, with the path, Copy and an
Open that shows its folder (POST /api/settings/log/reveal; the row is
hidden in magpie web, which writes no file). magpie log prints where every
log is (the app's, app.old.log, the service's, the tui's background
serve.log); --path the app's alone, -n N its last lines, -f follows it
across a rotation. Docs: reference.md, gui-shell.md, site start (FAQ "Where
is magpie's log?" and the CLI table) and privacy (files on your computer),
en/zh/ja.

Run:
At 227ce6074 on origin/main fbb1b36d1:
- mote: go test ./internal/applog ./internal/appdir ./internal/cli ok;
  -run TestCoreScriptBudget ./internal/gui ok; GOOS=windows go vet
  ./internal/... and GOOS=linux go vet -tags nogui ./internal/... ok;
  gofmt -l clean. GUI, chromium: about-log (5 languages x 1100/420, and
  no row without a log), about-website, i18n-keys: 24 of 25, the one red
  "a plugin's words are its own" ("Unmarked") is the same at origin/main
  fbb1b36d1 (#4524).
- WSL (magpie-desktop), webkit: about-log and about-website 21 of 21.
- Windows (win-run): applog, appdir, tui ok; cli ok but
  TestLibraryMCPHub's TempDir cleanup (#4140, mcp-npm, not this change).
- WSL full go test -tags nogui -timeout 45m ./... at the previous base
  03f609e3f: every package ok but reds that fail the same at origin/main
  03f609e3f alone: TestSettingsSaveKeepsWhatItDoesNotSend (#4514),
  TestNoCommandBypassesProc (#4491), internal/agent's install-detection
  tests (#4033, #3548), and TestCoreScriptBudget, which was this change
  (app.js 321 over): its comment is cut to one line and both budgets
  are raised by the remaining 124 bytes, with no room added.
- Broken by hand: with startLog left out of runGUI, TestTheAppWritesItsLog
  is red ("app wrote no log: open .../Library/Logs/magpie/app.log: no such
  file or directory"); with proc.UserPath taken out of openApp,
  TestGatewayStartsGetUserPath is red ("runGUI doesn't call
  proc.UserPath"). The guard now follows a start into a function or func
  var of this package, since the Wails start sits behind openApp for the
  test.
- Real use on mote: the GUI build, magpie app in a sandbox HOME, wrote
  ~/Library/Logs/magpie/app.log (0600) with its "started" line; magpie
  log and magpie log -n 3 printed it.
Not tried: the app opened from Windows Explorer or a Linux desktop
launcher for real (the paths are unit-tested per OS, the writer on
Windows and Linux); the full GUI suite (running on WSL after the push,
reds filed if they fail at origin/main too).
2026-10-31 14:45:22 +08:00
yetone 3b5dccd527 accounts: a plugin account goes by its usage's name, not its id (#4416)
A Huawei Cloud CodeArts account is kept by its accountId, an IAM id
(iam::<domain>:user:<name>), and every list showed that id while its
quota card showed the masked phone the plugin's usage() names it by.
Display only: an account now reads as the name the user gave it, else
the `user` its plugin's last usage read gave (PluginUserOf: the
in-memory read, else quotas.json), else its id. The id stays the key
everything is kept by; nothing stored changes or migrates. A read that
fails keeps the last good name; nothing read yet is the id, never blank.

One rule in provider (AccountShown, AccountShownOf, AccountLabelOf),
used by every list: cards' Alias (Usage page, tray panel,
/v1/magpie/quotas, magpie quota), magpie accounts, magpie providers,
the TUI's Providers rows and quota titles, usageapi's Account filter,
the quota alert. The GUI gets it as /api/providers' accountUsers
(accountShownOf in app.js): the editor's account rows (the id in the
tooltip), the per-account proxy lines, Routing's userShown, the
Providers search, Hide accounts. app.js's account lookups share one
helper, so the core stays in its budget (1,536,561 of 1,536,586), with
no room added.

Run:
- go test ./... -timeout 45m on mote at 2f5a3f1c0 + this change: all ok
  but internal/agent TestPiModelsAskedOnTheirNativeAPI (fixed on main
  by 7474a86f1, green there; this is rebased onto it),
  internal/update TestRelaunchOpenTriedAgain (#3881, green alone x3),
  and internal/gui's real-window AppKit tests (TestPanelCloseHidesIt,
  TestMainWindowCorners, TestTrayCellClickReleasedPanel red the same
  on origin/main 99ad38b7c; #2645, #4125, #1936).
- go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet of the
  touched packages; gofmt -l clean.
- TestPluginAccountShownByItsUsageUser (new, real plugin host and fake
  plugin): id before a read, phone after, phone after a restart from
  quotas.json, phone kept over a failed read, own name wins, id when
  nothing is known. Red on the old code.
- GUI on the Linux box (mote's Chromium segfaults on these pages on
  origin/main too, #4125): account-plugin-user (new),
  routing-account-name (extended) and account-alias, Chromium and
  WebKit, every language, 34/34; the new checks red on the old code;
  the whole suite (make test-ui on the Linux box) was still running at
  push: 417 files in, 5 reds, none on a page this changes
  (account-models' row-moved check in WebKit, 81 vs 79px, and
  agent-models-all-hidden), not yet compared with origin/main; any
  that are new get an issue once it ends.
- At the rebased head (3bce283df): go test of provider, cli, tui,
  usageapi, plugin, agent -run TestPi, gui -run
  Budget|Provider|Quota|Account: all ok. Core scripts 1,535,513 of
  1,536,586.

Broken by hand: dropping the quotas.json fallback turns the test red
at "after a restart".

Not tried: a real Huawei CodeArts account (none here). A plugin whose
windows are all model pools isn't kept in quotas.json, so after a
restart it shows its id until its first read.
2026-10-31 01:01:49 +08:00
yetone b889ffe813 library: a server can stay each agent's own entry with the MCP hub on (#4382)
cuipengcx90's #4382, Option A's first step (nifengfanpan asked on
Discord): with the MCP hub on, every Library server went behind magpie's
one entry, so a server that reads its project from the folder it starts
in, or keeps a session's state, resolved the wrong repository or shared
state across agents. A server now has a hub policy, Server.Hub ("hub" in
library.json): "" (shared, the default, so nothing changes for existing
users; "shared" is saved as "") or "direct". A direct server is left out
of the hub through inHub, the test that already keeps magpie's own image
server out, so each agent given it keeps its own entry written as with
the hub off, beside the hub's entry for the rest. An agent whose every
server is direct gets no hub entry. The hub neither lists nor runs a
direct server, at /mcp/magpie/hub either, and hubPrune ends one it held.
Switching goes through change(), so the agents are written again at once
and the entry from the other policy is removed. An unknown policy is an
error.

- GUI: with the hub on, the server editor has a "Through the MCP hub"
  switch (role=switch, not a <select>; not shown with the hub off or for
  the image server), a direct server's row has a "Not through the hub"
  tag, and the hub's line and the Connect sheet name the direct servers
  with the image server as given directly. Strings are in zh, zh-TW, ja
  and de ("MCP 聚合" as the core uses it).
- CLI: magpie library mcp hub <name> shared|direct (ServerHub), and
  magpie library marks a direct server.
- TUI: an edit keeps the policy.
- Not done: Option B (per-roots/project backends behind the hub, keying
  hubPool by roots). It is left for later; #4382 stays open for it.

Run:
- TestHubDirectServer (internal/library) and the extended
  TestLibraryMCPHub (internal/cli) on mote. Broken by hand: inHub back to
  !isSelf(s) makes TestHubDirectServer red ("codex with the hub on:
  [magpie], want [index magpie]").
- Real configs in a sandbox HOME on mote (fake claude on PATH, the real
  binary built from this tree): mcp add index + web for claude and codex,
  hub on, hub index direct, shared, then both direct. The direct index
  entry was in .claude.json and .codex/config.toml beside magpie's; with
  every server direct both files were byte-for-byte as with the hub off
  (json.tool diff and diff); shared again removed the index entry.
- Full Go suite (-tags nogui -timeout 45m ./...) on mote at this tree
  rebased on origin/main 72ed121fd: 81 packages ok. Before the rebase
  the only red was TestQuotaSpanCarriesEveryWindowField (#4457, fixed by
  ccbefe2a2). GOOS=linux and GOOS=windows go vet clean, gofmt clean.
- GUI on WSL (magpie-desktop; mote's GUI is broken, #4125), both engines,
  every language: the new mcp-hub-direct.test.cjs (1100 and 390 wide,
  hub on and off), library-mcp-hub, mcp-local-server, i18n-keys: 88 pass.
  Broken by hand: not sending hub in the save makes mcp-hub-direct red
  (11 of 11 in chromium).
- The 54 library/mcp/i18n GUI files at --test-concurrency=4 on WSL at load
  ~160: 978 of 988 pass. Red: library-chip-fan (webkit, fan positions),
  library-mcp-tools (chromium ja 420, "the click scrolled the page") and
  mcp-oauth-app (chromium de 390). None of them touch the hub switch or
  the editor's new field. They are being rerun alone, here and on
  origin/main, after this push; a red that only this change has is fixed
  next, and a red on main too is filed.

Not tried: the whole GUI suite (1028 files); a real cwd-sensitive
server in a real agent session; the live app window.
2026-10-31 00:34:45 +08:00
yetone 4f2d5fc7e0 routing: a group can put its cheapest member first, by each one's price at that hour
liyuanzheng (#general) and lam_em (#feedback) both asked for the same
thing. Off-peak, DeepSeek's own API should come first for deepseek-flash.
At DeepSeek's peak (weekdays 01-04 and 06-10 UTC, billed 2x since
v0.1.2173), another provider should come first, Ollama say. A schedule
editor would make the user copy DeepSeek's hours into magpie. Instead,
a group gets one more routing, "Cheapest first" (`cheap`). Each request
sorts the members by what they cost right then: input + output price per
million, at the peak rate when it is peak hours. A tie goes to the lower
cache-read price. Free models count as 0. A member with no known price
keeps its listed place after the priced ones. Prices come from the same
priceOf the usage ledger bills with, so the user's own ModelPrices,
list prices and maker prices all count, and so does a provider's rate
windows.

- routes: Seat carries Priced/Cost/CacheCost; Strategy.ByPrice; Cheapest
  is a stable sort, so equal prices keep the user's order.
- gateway: weighRouted prices each seat at priceClock() (time.Now; a test
  holds it) through the new provider.PriceAt. The trace's Weighed row
  gets a price (input/output/cacheRead/peak) so Routing can say why.
- It is a group's alone, like Manual. A provider saved with it drops it,
  and `magpie provider set … routing=cheap` refuses it. Groups take it in
  the GUI menu (one more item, no new controls), the TUI and
  `magpie group set <id> routing=cheap` (aliases cheapest, price, cost).
- Routing's mode line says why the first one is first, e.g. "Cheapest
  first: deepseek-v4-flash costs least on ollama-cloud now — $0.150 in,
  $0.600 out a million tokens.", with peak and unpriced variants.
  en/zh/zh-TW/ja/de.
- Docs: gateway-routing, plugin-runtime, reference (it also points at
  Time window and Pause rules for a fixed schedule) and the site's start
  pages (en/zh/ja).

Run, at f7f2d75f2 (this change rebased onto it):
- Red on the old code: TestCheapestFirstGroupFollowsPeakHours (deepseek
  vs ollama with ModelPrices, priceClock held at 14:00 UTC off-peak and
  02:00 UTC peak) and TestCheapestOrdersByPriceNow did not compile
  without Cheapest. TestCheapestFirstIsAGroupsOnly checks that a provider
  drops it and a group keeps it.
- Broken by hand: without `pr = pr.In(at)` the gateway test is red ("at
  DeepSeek's peak ... went to deepseek"). With Cheapest returning the
  order unchanged, both the routes test and the gateway test are red.
  Both were restored.
- Full Go suite on mote (-count=1 -timeout 45m ./..., log kept): every
  package ok except two. internal/provider had
  TestQuotaSpanCarriesEveryWindowField, which is red on origin/main (#4457,
  fixed since in ccbefe2a2). internal/gui had ten AppKit window tests
  killed at their 20-40s deadlines (TestPanelCloseHidesIt,
  TestMainWindowCorners and others). Three of them are red the same way
  on a fresh origin/main f7f2d75f2 copy, under #2645/#4125 (mote has
  several GUI suites running). After the rebase, go vet and the Cheapest,
  SpeedFirstGroup, ParseRouting, ApplyGroupPairs and ProviderRouting tests
  are ok. go vet darwin, GOOS=linux -tags nogui and GOOS=windows are ok,
  and gofmt is clean.
- GUI on WSL (Linux, chromium + webkit): routing-cheapest-first (new,
  3 scenes x en/zh/zh-TW/ja/de x 2 engines), routing-group-strategy,
  builtins, i18n-keys and routing-speed-first gave 95 of 96. The one red,
  routing-group-strategy "webkit en light ... the pick moved nothing", is
  a wheel-scroll timing red. It fails 3 of 3 on origin/main and 1 of 3 here
  (#4459). Core-script budget ok (app.js +9 bytes).
- The whole GUI suite (1025 files) was started on WSL at this tree and
  was still running when this was pushed, at load ~160.

Not tried: real DeepSeek or Ollama accounts, and a real request during
DeepSeek's peak hours. Ollama Cloud's price here is the catalog's, not
checked against a bill.
2026-10-30 23:59:31 +08:00
yetone 4054251865 library: an MCP server can be kept to this computer, never synced
huhuy72219405 on X: "能不能把不同设备的mcp区分一下,有些mcp属于本地的,
同步之后其他设备不应该读取到". A server in Library > MCP now has a
"This computer only" switch in its editor (Server.Local; CLI
`magpie library mcp add ... --local` and `magpie library mcp local
<name> on|off`; the TUI keeps it on edit and marks the row).

- Collect leaves local servers out (carriedServers), so neither a sync
  nor a backup file takes one to another computer. Turning a shared
  server local takes it out of what is carried, so the other computers
  drop it at their next sync; the flag itself is never carried.
- Put (sync, join, Restore, Undo, backup file) keeps every local
  server, with its agents, and clears Local on what comes in.
- Another computer's server by a local server's name goes to
  Library.Away: given to no agent, not in the hub, carried on as it
  came, so a push from here never removes it from the computers that
  have it. settleAway (every change) promotes it once the name is gone
  here, and drops it once the name is shared here again.
- The hub serves local servers like any other (it runs here);
  subagents aren't carried, so one naming a local server keeps it.

Docs: docs/subsystems/library.md, docs/subsystems/sync-backup.md.

Run at f5dd4e142 + this change; after rebasing on d3898ca8d (gui/provider only, then 2a1ef15ba, routing), vet, the five new Go tests, mcp-local-server and i18n-keys again, ok:
- mote: gofmt -l clean; go vet of library/backup/davsync/cli/tui;
  GOOS=linux and GOOS=windows go vet -tags nogui of the same; go test
  of TestLocalServerNotCarried, TestPutKeepsLocalServer,
  TestPutSameNameAsLocal (library), TestRestoreKeepsLocalServer
  (backup), TestLocalServerThroughSync (davsync, two computers through
  the fake S3) ok.
- mote GUI, Chromium and WebKit: mcp-local-server.test.cjs (new; every
  language, 1100 and 390 wide, switch saves local true/false, row tag,
  no sideways scroll), i18n-keys, mcp-editor-cancel,
  mcp-startup-timeout, every library-mcp-*, mcp-oauth-app, mcp-signin*,
  library-items, library-servers-bulk, library-subagents,
  library-pick-remove, library-env-refs, library-zed-mcp,
  library-loading: all pass (126 of 126 in the last batch).
- Full Go suite, -tags nogui -timeout 45m, on the Linux box (wsl-run;
  mote had another session's full suite running): every package ok
  but internal/agent, whose TestInstalledVersion, TestGrokInstalled,
  TestOmpDetectedWithPiDir and TestZedAppPath fail the same at
  origin/main 9b4d0bda8 on that box; all four are #4033.
- Real CLI in a sandbox HOME on mote: mcp add --local, local on/off,
  `magpie library` shows "this computer only", library.json has
  "local": true; an unknown name and a bad value are refused.

Broken by hand: putServers not keeping local servers turned
TestPutKeepsLocalServer, TestPutSameNameAsLocal,
TestRestoreKeepsLocalServer and TestLocalServerThroughSync red;
carriedServers carrying local servers turned TestLocalServerNotCarried,
TestPutSameNameAsLocal, TestRestoreKeepsLocalServer and
TestLocalServerThroughSync red.

Not tried: a sync between two real computers; the real GUI app (the
Playwright run fakes the API); the full Go suite on macOS or Windows.
2026-10-30 02:31:08 +08:00
yetone 2a1ef15ba9 routing: a found group's card leaves out a provider switched off, and counts it (XYenon)
XYenon on Discord (#feedback, 10-30): "已经关闭的提供商还会显示在路由页的
自动成组里是不是不太对". A provider switched off stays a member of the
groups magpie found (#2671, on purpose: agents on auto-<model> aren't
moved while it is off), and the gateway already skips it (membersIn reads
only providers that are on; TestFoundGroupWithAProviderOff covers chat,
and a fallback group, affinity and a group's classifier (decide_group.go)
go through the same FindGroup). So no request reached it. What was wrong was the page: the
card still listed it as "B · model (switched off)" and its logo sat in
the group's icon stack, where every other model list leaves a provider
switched off out.

- Routing page (plugins/routing/client.js): a found group's card, its
  remove-picker row and its logos (groupIcons, also used by the group
  pickers) leave out members whose provider is switched off; a tag
  "{n} switched off" says how many, its title why (offWords). When none
  would be left they are listed as before. The editor and a manual
  group's pick still show them, greyed with why. A group of the user's
  is unchanged: it lists what they put in.
- i18n: "{n} switched off" in zh, zh-TW, ja, de.
- TUI (sibling): the routing list's line for a found group does the same
  ("N models · ... · 1 switched off"), and a group's page marks such a
  member "· switched off: skipped until it is on again" (any group).
- docs/subsystems/providers-accounts.md: the row says it.

Tests: routing-provider-off.test.cjs gains a found group (card text,
tag text and title, no logo of the provider off, editor still has it)
and one whose only member is off (listed as before, no tag); every
language, 1100 and 420 wide, Chromium and WebKit.
TestFoundGroupLineLeavesASwitchedOffProviderOut (internal/tui).

Run on mote (mote-run, this tree): node --test of 45 GUI files
(group-*, panel-routing*, routing-group*, routing-groups*,
routing-provider-off, i18n-keys, found-*, remove-found*): 488/488 pass.
go test ./internal/tui ok; go test ./internal/gui: all ok except
TestMainWindowCorners/macOS_26_SDK, red on macOS 27 and already filed
(#3949), an AppKit window test this change doesn't reach. gofmt -l
clean; go vet ./internal/tui for darwin, linux (-tags nogui), windows ok.

Broken by hand: with client.js from HEAD the new GUI case is red
(expected 'A Cloud · luna', actual 'A Cloud · luna → B Cloud · luna
(switched off)'); with listedMembers returning every member the TUI test
is red ("2 models · ... pa/luna → pb/luna").

Not tried: the real app with a real provider switched off; the full GUI
suite (1002 files) and the full go test ./... were not run.
2026-10-30 02:28:29 +08:00
yetone af8f3a9399 sessions: a new install reads no agent's session history until the user allows it (RustCats on X)
RustCats on X: a fresh magpie showed every agent's session history on
the Sessions page before anyone agreed to it, and asked for a per-agent
choice instead.

- sessions.Reads(agent) (internal/sessions/access.go) is the one gate,
  from settings.SessionReads {Asked, All, Agents}. Every lister asks it,
  the aggregators (allFiles, callFilesWith, callSourcesWith,
  traceLineFiles, wslFiles, DesktopDataDirs) filter by it again, and
  readers of an already-listed session (TranscriptOf, ContentOf,
  SearchSession, SubagentTranscript, CarryOver, ReadCallSource) return
  ErrNotRead, so a cache from before a switch was turned off goes no
  further. The Sessions list, stats, /api/sessions/overview, the call and
  trace indexes, Usage's agent-file calls and the Codex/Pi title readers
  all pass it.
- SettleReads decides once and saves: an install with sessions.json or
  a calls-v* cache read sessions before and keeps all on; a fresh one
  reads none, not asked. A saved value is never replaced; save, sync and
  restore keep it (KeepOwn); only SetSessionReads writes it. An
  unwritable settings.json reads nothing this run.
- GUI: GET/POST /api/sessions/reads. While not asked, the Sessions page
  shows a consent card: each agent found (by a stat of its folder only)
  with a switch, Allow selected and Allow all. Settings > Privacy >
  Agents' session history has "Agents found later" and a row per agent.
  Strings in en, zh, zh-TW, ja, de.
- CLI: magpie sessions read [on|off all|<agent>...]; magpie sessions
  says on stderr when nothing is allowed yet; the TUI's empty Sessions
  page says how.

Read either way, because none of it lists or shows a session: the
gateway's own usage ledger, its projections and the conversations it
recorded (magpie's own records, so usage and cost keep working); the
agents' config and sign-in files; Claude Code's and Codex's
history.jsonl last-used time and a session file's mtime for a quota's
first use; Codex's newest rollout's last line before magpie restarts
Codex (codexTurnOpen).

Tests: TestFreshInstallReadsNoAgentUntilAllowed,
TestSettleReadsKeepsWhatWasThere, TestSessionReadsRoutes,
TestSessionsRead, TestSessionsNotAskedSaysHow, sessions-reads.test.cjs
(26 cases: consent and Settings in 5 languages, Chromium and WebKit,
390 to 900 wide).

Run on mote:
- full Go suite (gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui,
  GOOS=windows go vet, go build, go test -timeout 45m ./...) at this
  change on 8c63c5b78: 79 packages ok; internal/gui red on
  TestSettingsSaveKeepsWhatItDoesNotSend (mine: SessionReads is written
  by SetSessionReads only, the test now sets it so; green after) and
  TestMainWindowCorners (the same on origin/main c1da9ccda, #3949).
- whole GUI suite (make test-ui, concurrency 2) at this change on
  8c63c5b78: 14985 tests, 276 failed in 44 files. Mine: i18n-keys
  (comments named "Allow all"/"Allow selected"; lowercased) and
  account-discovery (read the last Privacy heading; now the one above
  its list); both green after. The 44 files again on origin/main
  c1da9ccda: 36 red there too (#4304, with #3218, #3412, #3414, #3795,
  #4120, #4125). stays-strict green alone; gateway-key-models webkit red
  1 of 3 alone on main too; plugin-github de 440 red on main (#3218).
- at the pushed head (rebased on cd10dfbe6): go build ./...; go test
  internal/sessions, settings, cli, tui ok; internal/gui
  TestSettingsSave*, TestSessionReads*, TestSessions* ok; i18n-keys,
  account-discovery, sessions-reads: 62 pass, 0 fail.

Broken by hand:
- the aggregator filter off with the leaf gates on: green (the leaf
  gates hold); both off: TestFreshInstall red on List, Agents, Calls,
  CallSources, traces, stats, TranscriptOf and Search.
- consentApplies=false and Settings' old save({all}) without the rows:
  all 13 Chromium cases of sessions-reads red.
- sessNothing's hint removed: TestSessionsNotAskedSaysHow red.

Real binary in a sandbox HOME on mote (removed after): a fresh
`magpie sessions` is empty with the hint on stderr; `sessions read`
says not asked, claude off; `read --help` prints usage and saves
nothing; `read on claude` lists the one session; `read off all`
empties it again.

Not tried: the GUI and real app on Windows and Linux; WSL agents in the
consent list (WSL distros are not looked into; Allow all covers them);
a fresh install of a signed release build.
2026-10-29 23:56:05 +08:00
yetone fe05f0a721 library: a skill can be turned off on this computer alone, and a sync neither carries that nor turns it on
hanslin1666 on Discord (#general 1565016936344191096) wanted a library
skill off on one computer only ("只在这台电脑上关掉"). The only way to do
that was to untick its agents, and the ticks are what a sync carries, so
every other computer lost it too. A sync from a computer that had it on
also gave it back here.

Skill.OffHere (library.json "offHere", omitempty) turns a skill off on
this computer. No agent here gets it, whatever Agents says. Every reader
that gives a skill to an agent now asks gives():
- syncSkills, including the shared ~/.agents/skills check;
- desktop_skills.go;
- skill_changed.go;
- skill_edits.go;
- behind;
- Targets.
Agents stays what a sync carries, and the page shows those chips faded.

Collect never carries OffHere, so turning a skill off changes no part a
sync uploads. Put keeps this computer's OffHere for a skill it puts, so
a sync from a computer that has it on (or that gives it to more agents)
leaves it off here.

Where to turn it off:
- GUI: a power button on the skill row (aria-pressed). When off, an
  "Off on this computer" tag sits on its own line under the name; it
  says why and turns the skill on when clicked.
- CLI: `magpie library skill off-here|on-here <name>`.
- TUI: the row says the skill is off.
The strings are in en, zh, zh-TW, ja and de.

Existing users: nothing changes. An older library.json has no offHere,
so every skill stays on, and a skill that was never turned off writes no
key (TestSkillOffHereOldLibraryIsOn).

Not covered:
- a project's skills;
- a library skill whose own folder is inside ~/.agents/skills, which
  agents read in place;
- a skill another computer removes (the flag goes with it).
The skill's files in the library folder still update while it is off.

Docs: docs/subsystems/library.md and sync-backup.md.

Run at the parent aeacc6358 (rebased on origin/main), on mote:
- gofmt -l: clean.
- go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go
  vet ./...; go build ./...: ok.
- go test -tags nogui -timeout 45m ./internal/library ./internal/davsync
  ./internal/cli ./internal/tui ./internal/gui ./internal/backup: all ok.
- GUI, Chromium and WebKit:
  - skill-off-here: 22/22 (en, zh, zh-TW, ja, de at 860 and 400px).
  - i18n-keys, gui-ja, gui-de, gui-zh-tw, library-items, library-mcp-hub,
    library-all and library-toggle-status: green. The first try timed out
    in browserType.launch (mote at load ~60); run again one file at a
    time, they passed.
  - library-row-remove: Chromium red in the hooks part, 2 or 3 of 11
    each run. It is red the same way on origin/main aeacc6358, 3 of 3
    runs there too (#3099); this change doesn't touch hook rows.
- Before the rebase, at e5e2aa58e plus this change: the 98 GUI files
  that reach the library page (1350 tests). 68 reds, nearly all
  browserType.launch timeouts under load; run again one file at a time,
  all passed except mobile-web's "desktop matches origin/main"
  subtests. Those need .git, which mote-run doesn't copy.

Then rebased onto ec3dad75a, which changes no library file. At this
pushed head: go build ./..., go vet of library and gui, the gui Budget
tests, and i18n-keys plus skill-off-here in both engines (26/26), all
ok.

Broken by hand (restored afterwards):
- Put dropping OffHere:
  - TestSkillOffHereStaysHere:96 failed: "a sync from a computer with it
    on gave pdf to an agent here again".
  - TestSkillOffHereThroughSync:108 failed: "a sync from A, with pdf on,
    gave it to an agent on B again".
- gives() ignoring OffHere: TestSkillOffHereStaysHere:74 failed: "off
  here, claude still has pdf".
- The GUI test fails on the old code, which has no button.

Not tried:
- no real WebDAV or GitHub backend (the sync test uses the fake S3);
- no real app run with real agents;
- no Windows or Linux test runs (only GOOS=windows and GOOS=linux vet);
- not the whole GUI suite, only the 98 files that reach the library page,
  the i18n checks and gui-ja, gui-de and gui-zh-tw.
2026-10-29 04:23:33 +08:00
JoeyWu-tech d6c459c79c tui: the agent view's picker test wants codex/gpt-6-luna, from a row (#3919)
TestTUIFetchesSubscriptionModels/agent is red on ubuntu and macOS CI
since c80b32c9 ("agent: a model Codex hides but the user ticked is
offered in Codex's picker"): the picker gives codex/gpt-6-luna where
the test wants gpt-6-luna. The picker is right. The test passed before
c80b32c9 only because nothing matched.

The test signs a ChatGPT account in to Codex and writes no
models_cache.json, so Codex has no list of its own here, and
codexViaMagpieFor offers the models magpie serves on that account,
codex/gpt-5.5 and codex/gpt-6-luna, in Codex's group. Before c80b32c9
those were dropped: at e056779a, once the list is in, the agent view's
whole list is auto/gpt-5.5 and b/gpt-5.5, with no gpt-6-luna row.
Codex's model field takes a value of one's own, and a picker that does
hands back the typed text when no row matches, so choice() gave
"gpt-6-luna", the test's want.

The agent view now wants codex/gpt-6-luna, and every view's last check
also needs a row to match, so typed text can't pass it again. The
other five views' wants were rows already.

What was run (tree bca161d7, on origin/main 791e27ec, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077:
- TestTUIFetchesSubscriptionModels -v at 791e27ec: agent red as on CI
  (models_test.go:96: got "codex/gpt-6-luna", want "gpt-6-luna"), the
  other five views pass. Here, with TestTUIAsksAgainForAMissingList,
  -count=3: 24 of 24 PASS.
- The agent view's items before and after the list comes, printed by a
  throwaway test at e056779a and at 791e27ec: the lists above.
- Broken by hand, TestTUIFetchesSubscriptionModels -v:
  - codexViaMagpieFor dropping every codex/ entry, as before c80b32c9:
    agent red (got "gpt-6-luna", want "codex/gpt-6-luna"), the other
    five pass;
  - the same, with the test as on main: all six pass, which is how the
    agent view's missing row went unnoticed;
  - the same, with main's bare want and the row check kept: agent red
    (got "gpt-6-luna", want "gpt-6-luna"), so the row check alone
    catches the typed text.
- go test -tags nogui -count=1 -timeout 45m ./... (log kept), Bun
  1.4.2: 69 packages ok and 7 red, none in what this changes, and
  internal/tui ok. The reds: agent TestCodexDriftReached (#3398),
  TestInstalledVersion, TestCursorFolderFromTheEditorIsNotTheCLI,
  TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141),
  TestReasonixCLIRequiresSupportedNativeVersion and
  TestReasonixCLIRecoversAfterProbeTimeout (#3641), and
  TestWSLColdPlaceOpensNothing (#3924); davsync TestSync (#3420); edit
  TestWriteAtomicReadOnlyHardLink and testenv TestProgram (umask 077,
  #3640); gateway TestHandedOverGatewayFinishesItsStream (#3568) and
  TestPluginToldWhereTheAgentWorks (#3675); gui
  TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie
  (#3649); provider TestCodexAppServersOnHome (#3906), then "close of
  synctest channel from outside bubble" from
  TestUnreadLoginsWriteErrorsKeepCredentials (#3632).
- gofmt -l clean. go vet -tags nogui and go build -tags nogui for
  linux, windows and darwin, and go vet and go build for windows
  without the tag: exit 0 each. go vet and go build without the tag on
  linux: exit 1 (this box has no GTK or WebKitGTK dev packages).

Not tried: macOS, where CI is red too.

Merged from JoeyWu-tech's branch, cherry-picked onto origin/main f13aafa87 together with the other of #3919/#3924. Run on mote at that tree:
- go test ./internal/tui/: ok.
- GOOS=linux and GOOS=windows go vet ./internal/agent/ ./internal/tui/: ok.
2026-10-28 07:06:27 +08:00
yetone ca8a6f346a agent: a renamed routing group moves its agents, and the Codex app reloads a changed catalog
lucis0116 on X: renaming a provider or a group in magpie didn't reach
every agent.

Display names already reached the agents' files: store and SaveGroup
drop the catalog, and SyncCatalog writes the new "<model> · <name>" and
"<group> · routing group" labels into Codex's model_catalog_json, Claude
Code's picker, OpenCode and Pi (checked in a sandbox HOME). Two gaps
were left:

- A routing group given another id (Routing page, `magpie groups
  rename`, TUI) left every agent on group/<old>, which magpie no longer
  has. The CLI even said "agents set to group/from need group/to now".
  agent.RenameGroup now moves each agent field on group/<old> to
  group/<new>, spelled as the agent spells it. It goes through
  renameRefs, the move RenameProvider already made, now shared by both,
  then SyncCatalog. The GUI, CLI and TUI call it in place of
  provider.RenameGroup.
- The Codex app's own app-server reads model_catalog_json only as it
  starts, and KeepCodexAppOnItsProvider restarts it only when
  codexAppRoute changes. The route named the catalog's path, not what
  the file holds, so a renamed provider or group, or a model added,
  stayed on the old list until the user quit the app. The route now
  carries a hash of the catalog's bytes (codexCatalogTag, read again
  only when the file's size or time changes). The restart goes through
  the existing idle gate: no Codex request in flight, 10s idle, no turn
  open. A write of the same bytes is no change.

Run, in a sandbox HOME only:
- TestRenameGroupMovesTheAgentsOnIt (new): Codex, Claude Code, OpenCode
  and Pi on group/smart, renamed to clever: each said moved and each
  file on group/clever, none naming group/smart.
- TestCodexAppRouteFollowsTheCatalog (new): the route changes when a
  renamed provider rewrites the catalog, and stays put when the same
  bytes are written again.
- Broken by hand: RenameGroup's match turned off makes the first test
  red (no agent moved, every file on group/smart). The catalog line
  dropped from codexAppRoute makes the second red ("a provider renamed
  left the Codex app's route as it was").
- At aded9beea (base ad3833512): go test -tags nogui -timeout 45m
  ./internal/agent ./internal/cli ./internal/gui ./internal/tui
  ./internal/provider -count=1: cli, gui and tui ok. agent red on
  TestFolderVarsAreListed (#3884, red on main since e4552cca9) and
  TestCodexDisconnectStaysWithAccountsOn/login=api, which passed 3 of 3
  alone and isn't on this path (filed #3891). provider crashed in
  TestUnreadLoginsWriteErrorsKeepCredentials with "close of synctest
  channel from outside bubble" in filememo.Forget (#3632, open on main).
- Rebased on 56de2d192 (a312bf3e3 adds a switched account's app-server
  to the same stale set; no overlap): go test -tags nogui -count=1
  ./internal/agent -run 'Rename|CodexApp|Sync|Group|Codex|Hermes' ok
  at this head; ./internal/provider -run
  'CodexApp|Group' ok at a312bf3e3 + this change. The disk was full (other sessions' suites), so the
  whole of each package wasn't run again at this head.
- GUI: group-id-dots, group-morph, agent-model-groups and i18n-keys,
  32 of 32. No GUI script changed, and the GUI tests answer the API in
  memory.
- gofmt -l clean. go vet -tags nogui on agent, cli, gui and tui for
  darwin, linux and windows: ok.

Not covered:
- Claude Desktop reads the gateway's model list only as it starts. It
  still needs its Restart button (AppBehind) after a rename, as after
  any other catalog change.
- Pi, omp and StepCode enabledModels: RenameRefs renames magpie/<old>/
  provider entries only. A group's magpie/group/<old> entry goes as
  scope-gone, and the pick of group/<new> is added again. Not checked
  entry by entry.
- Codex signed in beside magpie (models_cache.json aged by the catalog
  tag) was not run again here.
- No real Codex app restart was watched. The reporter's agent isn't
  named.
2026-10-27 18:22:29 +08:00
yetone d9a8148d7c routing: Speed first sends a request to the provider or key that answered the model fastest lately
joeliu96872540 on X: when one model is reachable through several API
channels, they want an option that sends each request to whichever has
been answering fastest, because they compare channel speeds by hand
today. Speed first (`fast`; `fastest` and `speed` also work) is a new
routing beside Free first. It applies to a provider's keys and accounts
(provider editor › Routing) and to a group of one model on several
providers (Routing page › group › Routing).

How it decides. When a streamed answer ends, gateway/speed.go records two
numbers for that account or key and model (restID): the time to first
token and the output tokens per second, as usage.DecodeOf computes them
for the Requests page. Each is a decayed average with a 20m half-life.
After an hour with no answer the record goes stale, and the store holds
at most 4096 records. This is O(1) at the answer choke point, beside
servedCandidate. For a pool routed by BySpeed, weighRouted reads one map
entry per candidate, and only for that pool. The usage history is never
read on a request.

routes.Fastest ranks each awake seat by its estimated time to a
200-token reply: TTFT + 200/TPS. A seat that reported no TPS gets the
median TPS of the others. Seats within 10% of the fastest in their band
keep their listed order, so near-ties don't swap on every request.
Seats with no recent measurement go after the measured ones. One request
in five, counted per pool, goes first to an unmeasured seat, rotating
among them, so each gets measured again. Resting seats go behind the
awake ones, and used-up seats behind those. Rests and failover are the
same as for every other routing.

The request trace gets lateTtft and lateTps, and the row-story sentence
says "answered m fastest lately: first token in 0.8s, 60 tokens a
second". It has a variant for a probe turn and one for when no seat has
been measured yet. i18n covers zh, zh-TW, ja and de. Also updated: the
CLI (`magpie group|provider set <id> routing=fast`, plus a new
`routing=` pair on provider set that refuses manual), the TUI name, the
rotation plugin's Sub, docs/subsystems/gateway-routing.md,
plugin-runtime.md, docs/reference.md and site start.html (en, zh, ja).
There is no new layout: it is one more item in the existing pickers.
app.js stays under its budget with no raise.

Tests:
- routes/fastest_test.go:
  - ordering: fastest first, slow writer loses, alike keep order,
    resting and used-up, median pace, none measured;
  - the probe turn at 5, 10, 15 and 20, rotating between seats;
  - a resting seat never gets a probe turn.
- gateway/speed_test.go:
  - decay, staleness and per-model records, with an injected clock;
  - a group of slowv and fastv routed fast: after the speeds are
    measured and seeded, the request goes to fastv with lateTtft set;
  - the same group routed in order still goes to slowv.
- cli: parseRouting and the provider routing= pair.
- GUI routing-speed-first.test.cjs: the row story for measured,
  no-pace, probe and none, in en, zh, zh-TW, ja and de, in chromium and
  webkit: 40/40.

Broken by hand:
- Fastest returning the listed order: the routes tests and the gateway
  group test go red.
- noteTrySpeed removed: "the streamed answer wasn't measured".
- The client.js case renamed: routing-speed-first 0/20 in chromium.

Run at b5a5caff2 (base 5b4dec58e):
- `go test ./... -count=1 -timeout 45m`, alone on the machine, at load
  130-230. Every package is ok except:
  - internal/provider: TestUnreadLoginsWriteErrorsKeepCredentials
    crashes with "close of synctest channel from outside bubble"
    (#3632, open);
  - internal/gui: TestMainWindowCorners and
    TestTrayCellClickReleasedPanel are killed at their deadline under
    load (#1936, #2645).
- gofmt -l is empty. go vet is ok on darwin, on GOOS=linux with -tags
  nogui, and on GOOS=windows for ./internal/....
- GUI files the change reaches, both engines, every language they test,
  all ok: i18n-keys, gui-de, gui-ja, gui-zh-tw, routing-save,
  routing-save-keeps-the-row, builtins, panel-routing,
  panel-routing-pick, panel-routing-providers, panel-routing-hidden,
  routing-key-windows, key-weight, key-weight-fit, group-member-weight,
  routing-weight-chip, account-arrange and routing-speed-first (40/40).
- routing-group-strategy was 4/18: the menu now has 9 items and the test
  still counted 8. Fixed in this commit; rerun, it is 18/18.
- routing-save-blank (a webkit click timeout) and routing-columns (zh
  "side by side") each failed one subtest at load ~200. Rerun alone,
  they are 4/4 each. Both are already filed (#1924, #1612).

Rebased on 8f023b511, where upstream changed gateway.go, app.js, client.js,
the routing plugin's i18n.js and gateway-routing.md; the rebase was clean.
At this head I reran gofmt, go build ./... and go vet (darwin, linux
nogui, windows) on routes, gateway and cli, and go test for routes, cli,
provider and gateway (the routing and speed tests) and for gui -run
Budget: all ok. The GUI files i18n-keys (4/4), routing-speed-first
(40/40) and routing-group-strategy (18/18) also passed.

Not tried:
- A real run against several channels of one model. Speeds come from
  real answers, so the first minutes after a start are in listed order
  plus probes.
- A non-streamed reply is not measured, a sub-millisecond TTFT is not
  counted, and a restart forgets every speed.
- The Windows runtime: only go vet ran for it.
2026-10-27 01:37:38 +08:00
yetoneandskygunner cec54c1d01 proc: main's two reds, the TUI's serve start through proc.Command (#3567) and an RSS read before the loader ran
Test (ubuntu, macos) on main has been red since 75e78a5a0 on two tests.

TestNoCommandBypassesProc: internal/tui/keep.go's serveInBackground
started `magpie serve` with os/exec. It is proc.Command now, the fix
skygunner gave on #3567 (64bd29fa on their fork). Off Windows
proc.Command is exec.Command, and this path runs on Linux only, so
nothing else changes.

TestTreeRSS (ubuntu only): the test read sleep's VmRSS right after
StartTree and wanted at least 64 KiB. Just after its exec a command
holds a few pages until its loader maps libc: CI read 16384 bytes. The
test now reads again until it holds 64 KiB, for up to 10s. Tree.RSS
itself is unchanged.

Run at this head:
- golang:1.26 docker (Linux, CI's Go): TestTreeRSS -count=50,
  old test red 13 of 50 ("a running sleep holds ..."), new 50 of 50 ok.
- macOS: go test -count=3 ./internal/proc ./internal/tui ok (the old
  keep.go is the guard's red on CI's runs 40199986992 and earlier).
- GOOS=linux and GOOS=windows go vet -tags nogui on both packages,
  gofmt clean.
Not run: the full suite.

Co-authored-by: skygunner <skygunner@users.noreply.github.com>
2026-10-25 23:15:45 +08:00
yetone c888ef2725 routing: a rule's hours are kept in the zone they were set in (gaubeebangeel on X)
magpie on a cloud server in UTC read a routing group's rule hours on the
server's clock, so a Beijing user's 09:00-18:00 held at 17:00-02:00
Beijing time, with nothing saying so.

- provider.TimeWindow carries the IANA zone its hours were set in
  ("zone": "Asia/Shanghai", omitempty). Holds reads From, To and Days in
  that zone (time.LoadLocation, cached; Go's embedded tzdata, so Windows
  knows them too). A window with no zone, every one saved before this,
  stays on magpie's own clock (time.Local) as before. A zone magpie
  doesn't know is refused on save (clean); one in a file edited by hand
  makes the window never hold, so the rule is as if absent, never always
  on and never hours off. Text() adds " (Zone)"; Line() writes tz=.
- GUI: changing a rule's hours or days in the editor saves the browser's
  zone (Intl resolvedOptions().timeZone); hours left alone keep theirs.
  /api/groups gives magpie's clock (clock: zone, offset in seconds), and
  when its offset differs from the hours' zone the Routing page tells the
  zone beside them, on the group's rules and in the editor: "Asia/Shanghai
  time" (zh "Asia/Shanghai 时间"), or "server time, UTC+0" (zh "服务器时间
  UTC+0") for hours with no zone. Nothing is added when the clocks agree.
  zh, zh-TW, ja, de.
- CLI and TUI: time=09:00-18:00@Asia/Shanghai or tz=Asia/Shanghai; with
  none, this computer's zone ($TZ, time.Local, the /etc/localtime link)
  when it has an IANA name, otherwise none (magpie's clock). An unknown
  zone is refused with what one looks like; tz= alone needs time= or
  days=. Usage text updated.
- docs/subsystems/gateway-routing.md: the zone rules.

Older magpie reading a shared or synced group ignores zone and reads the
hours on its own clock, as before.

Run in a sandbox HOME with pinned Go caches, first at base 9277c2567,
then again after the rebase onto origin/main d58053720 (vet, builds, the five packages,
routing-time-zone and i18n-keys all ok again there; then rebased onto
11907448e, which changes migrate_side.go and sessions only, and
internal/provider ok again, 139s):
- gofmt -l on the changed files: nothing. go vet ./..., GOOS=linux go vet
  -tags nogui ./..., GOOS=windows go vet ./...: clean. go build, GOOS=linux
  go build -tags nogui, GOOS=windows go build: ok.
- go test -timeout 45m -count=1 ./internal/provider ./internal/cli
  ./internal/tui ./internal/gui ./internal/gateway: all ok (provider 170s,
  cli 64s, tui 30s, gui 192s, gateway 513s; after the rebase 180s, 62s,
  25s, 181s, 568s); logs kept whole and grepped, no FAIL.
- New tests: TestRuleTimeWindowInItsZone (window, past midnight and days
  in a zone, instants in UTC), TestRuleTimeWindowWithoutZoneIsLocal,
  TestRuleTimeWindowUnknownZone, TestParseRuleTimeZone, TestRuleInZoneHere,
  TestGroupRuleTimeZoneCmd, TestRuleTimeWindowInItsZoneAtTurnStart
  (gateway, ruleClock in UTC). Run under TZ=UTC, TZ=Asia/Shanghai and
  TZ=America/Los_Angeles: ok. The zone used is Asia/Shanghai, or
  America/New_York on a computer on Beijing's clock, so they are red on
  any machine.
- GUI (playwright 1.62.0, chromium and webkit): routing-time-zone (new:
  en, zh, zh-TW, ja, de, 420px wide, browser in Asia/Shanghai, server in
  UTC and in Asia/Shanghai) 14 of 14; routing-time with the browser in
  Asia/Shanghai, the typed rule saved with its zone; routing-time-went,
  routing-day-window, routing-save, routing-rules-line, i18n-keys: ok;
  TestCoreScriptBudget ok.

Broken by hand: Holds reading at.Local() instead of the zone made
TestRuleTimeWindowInItsZone red under TZ=UTC (Shanghai's 10:00 not held,
18:00 held) and under TZ=Asia/Shanghai (with New York), and
TestRuleTimeWindowInItsZoneAtTurnStart red (10:00 Beijing went to the
group's order). routing-time-zone.test.cjs run against origin/main's
client is red (no zone told beside the hours).

Reds not from this change, the same on an untouched origin/main 99de8e1ad
worktree: routing-pause chromium 7 of 7 (#3410); routing-time webkit "Add
a rule" outside the viewport, 1 of 3 runs on main too (#3465);
routing-rules-line webkit zh 1100 once under load, passes alone on both
(#3593, filed now).

Not tried: a real cloud server in UTC with a browser in Beijing (the GUI
test sets the browser's zone and the server's clock instead); the Windows
box; the whole GUI suite.
2026-10-25 18:18:02 +08:00
yetone 1dfa284840 usage: a plugin's row of text alone shows its text, not "· 100% left"
AutoClaw's 积分余额, Cline's balance, Cursor's Auto + Composer note and
the other plugin rows that are only words come to magpie as a window set
aside with a display and nothing counted (used 0, no amount, no limit).
Every surface read that used 0 as a share: the usage card said
"1,234 积分 · 100% left" (or "· 0% used") beside an empty meter, the
panel drew an empty ring, the TUI an empty bar, `magpie accounts` and
`magpie quota` "积分余额 0% (1,234 积分)", and the status line
"积分余额 0%".

provider: QuotaWindow.Text (json "text") marks such a row in
quotaOfPlugin: aside, a display, used/amount/limit all 0. Aside is
required: Cursor's On-demand "$0 / $20" isn't set aside and is a real
0%. QuotaSpan carries it to /api/quotas.
GUI (app.js): quotaText gives the display alone; the account row's
meter, the Usage page's track and the panel's rings leave the row out;
a panel card with only such rows shows their text on its line, as an
Unlimited card does. The tray's menu-bar text already skips aside rows.
TUI quotaCell, the CLI's quotaCell (accounts, quota) and statuslineCard
write the name and the text.

app.js stays under its budget (1,322,289, not raised; now 1,322,275):
to make room, the 8 copies of Math.max(0, Math.min(100, x)) are one
to100(x), and 8 one-line [..].filter(Boolean).join("\n") tooltips are
tipLines(..). Same results; the GUI files below cover those callers.

Readings cached before this release have no text flag and show as
before until the account is read again (a minute's cache, or Refresh).

Run, at this commit's tree (rebased on origin/main 9dc7d6eb8):
- internal/gui/tests/quota-text-row.test.cjs (new): a text row alone
  and beside a counted window, through accountQuota, panelQuotaCard,
  quotaWindows and quotaText; chromium and webkit, en and zh: 4 of 4.
- the GUI files the change reaches (quota*, usage*, panel*, tray*,
  profile*, plugin-plan, plugin-quota*, plugin-panels, api-key-usage,
  claude-usage, gateway-key-quotas, glm/opencode-go quota errors,
  routing-quota-left, gui-de/ja/zh-TW, i18n-keys; 114 files, both
  engines, 4 wide, load 130 to 200): 1433 of 1467. The reds, rerun
  alone here and with 9dc7d6eb8's own app.js: quota-count-wrap (webkit,
  #3404 #2228), usage-agents-hide (#3414 #2276), usage-checkin's Qoder
  tab (webkit, #2549), usage-fold (#3415 #2163) and usage-ledger's
  return-to-live (#3104) fail the same at both; api-key-usage failed
  once 4 wide and passes alone at both (#3589).
- go test -timeout 45m ./internal/gui/ ./internal/cli/ ./internal/tui/
  ./internal/provider/: ok (TestCoreScriptBudget included).
- gofmt -l internal/ clean; go vet on darwin, linux (nogui) and windows
  for provider, cli, tui (and gui on darwin): clean.
Broken by hand:
- app.js at HEAD under the new GUI test: red, quotaText gave
  "1,234 积分 · 0% used" / "1,234 积分 · 已用 0%".
- quotaOfPlugin's Text line removed: TestPluginTextRowIsText red.
- the CLI's quotaCell at HEAD: TestQuotaCell red ("积分余额 0% (1,234 积分)");
  statuslineCard at HEAD: red ("autoclaw-plugin 积分余额 0% 5h 40%").
- the TUI's quotaCell at HEAD: TestTextQuotaCell red
  ("积分余额 ░░░░░░░░ 1,234 积分 · 0% used").
Not tried: a real AutoClaw, Cline, Cursor, Factory or ZCode account in
the app (fixtures follow the plugins' own window shapes); the full
`go test ./...` and the whole GUI suite; the Linux and Windows apps.
2026-10-25 17:26:38 +08:00
yetone f99d27abc2 routing: a rule names several models, tried in order
monkeyin_92 on X: "can a rule take several models? Otherwise one rule
with several models is several rules." A rule now takes more than one
model (Rule.More after Rule.Use; `more` in the group's JSON, use=a,b
typed). They go first in that order: when the first fails or rests the
rule's next takes the request, ahead of the models the later matching
rules name and the group's others.

Every reader of Rule.Use goes through Uses/SetUses/MapUses/Without/Names
in grouprule.go:
- cleanRules: each must be the group's, each named once; a pause names one.
- gateway: ruleFor's turn hold, tool rounds and outgrown turns, compaction
  (the rule's first that takes the summary, the others in Small),
  ruleMembers/ruleOver/applyRule, nestedRules and ruleLed (the one a
  nested group's turn stays on), modelRuled, ruleEffort (useEffort asked
  of each), ThenUses (leaves out all of the rule's own). RuleHit.More is
  in the trace; Instead from More has Unready false, one from a later
  rule Unready true, as before.
- ruledEntry: what the group takes is what every one of them takes.
- provider rename, auto/ refs, groupfast, a member's removal (a rule
  goes with its last), ShareGroup and its import (one this magpie hasn't
  is left out of the rule).
- CLI `group rule add use=a,b` and its listing; `group models-=` keeps a
  rule's other models. The TUI shows them joined and keeps the rule when
  one is deleted.
- GUI (plugins/routing): a chip per model, a + for the next one, an ×
  on each while there is more than one, a chip picks another in its place
  (app menu, no native select); the card's tooltip and the trace's why
  ("…so c/mini, which the rule names after it, goes first"), nested too;
  en, zh, zh-TW, ja, de.

Old data: a rule of one model writes no `more`, so groups saved before
read and save unchanged (TestRuleMoreOnDisk). An older magpie reads `use`
alone: its requests go to the first model, the others are plain group
members in group order; if it saves the group, `more` is dropped.

Tests: TestRuleSeveralModelsInOrder, TestRuleEffortReachesTheRulesNextModel,
TestRuleCompactPassesOverTheRulesSmallModel (gateway); TestCleanRulesSeveralModels,
TestRuleMoreOnDisk, TestRuleWithout, TestParseRuleSeveralModels,
TestThenUsesLeavesOutTheRulesOwn, TestRuledEntrySeveralModels,
TestSharedGroupRuleSeveralModels, TestRuleMoreRenamedAndKept (provider);
TestGroupRuleSeveralModelsCmd (cli); TestGroupTakeOutKeepsARulesOtherModels
(tui); routing-rule-models.test.cjs. Broken by hand: ruleMembers on Use
alone turns the first two gateway tests red.

Run at this head:
- gofmt -l clean; go vet -tags nogui clean with GOOS=linux and GOOS=windows
  for provider, gateway, cli, tui.
- go test -tags nogui -timeout 45m: internal/provider, internal/cli,
  internal/tui ok; internal/gateway ok (384s); the new gateway tests
  again after; internal/gui budgets ok.
- GUI: every routing-*.test.cjs plus i18n-keys, click-scroll and
  group-member-drag, chromium and webkit (en, zh, zh-TW, ja, de where the
  file has them): 1319 pass, 57 red. routing-rule-models passes in both.
  The reds are in files that are red the same on origin/main 42976f9a0,
  run there just now: routing-pause (#3410), routing-intent-entry
  (#3408), routing-rule-effort (#3411), routing-rule-remove (#3096,
  #3094), routing-manual (#3409), routing-steady (#3412, #1804),
  routing-live-patch (#2174), routing-time (#3465). The other 10 reds are
  routing-rule-drag.test.cjs, which is the next commit's and not in this one.
- Real run, sandbox HOME, built binary: three fake OpenAI vendors, group
  Mix = three/m, one/m, two/m, rule `use=one/m,two/m tokens=1`. one/m
  answers 429: the request went one -> two (not three, the group's
  first); the next went straight to two, the trace saying
  instead=two/m with more=[two/m].

Not tried: a real vendor account; the TUI by hand; Windows and Linux
runs (vet only).

Rebased onto 5b2b3d3f5 (10 commits, gateway, gui and routing's
client.js among them) and run again at the rebased pair's head
68701dfe4: gofmt -l clean; GOOS=linux and windows vet -tags nogui of
provider, gateway, cli, tui clean; go test -tags nogui -timeout 45m
internal/provider (171s), cli, tui, gateway (422s), gui (budgets): all
ok; GUI routing-rule-drag, routing-rule-models, routing-compact,
i18n-keys, click-scroll, group-member-drag in both engines all pass;
routing-rule-remove red as on main (#3096, #3094).
2026-10-25 13:32:12 +08:00
yetone 5b2b3d3f50 providers: a switched-off provider says how to turn it on, after a sign-in too
Atlas (Discord) signed in to WorkBuddy AI with `magpie plugin login
workbuddy-ai`, and `magpie providers` then showed "○ switched off" with
nothing saying why or how to undo it. magpie never sets Provider.Off by
itself; only the user's own switch does, and a sign-in rightly keeps it.
So the setting stays as the user left it, and magpie now says how to
change it:

- `magpie plugin login <id>` and `magpie accounts add <id>` (plugin and
  built-in paths), finishing for a provider that is switched off, print
  "! <Name> is switched off in magpie, so agents aren't given its models
  · turn it on: magpie provider on <id>". One that can't be found says
  nothing (not known to be off).
- `magpie providers` puts "magpie provider on <id>" in the switched-off
  row's last, unpadded column, so the key column keeps its width.
- The TUI's Providers row notes "o switches it on" (its `o` key).
- The GUI row already shows a "Switched off" badge and its own switch,
  and the editor says how to switch it on: left alone.

Run, at this tree (base c9c28aa58):
- TestPluginLoginSaysItIsSwitchedOff (new), TestProvidersShowVertexCredentials
  and TestTUIAddsVertexWithItsProject (extended): red with the source
  changes reverted (no hint in the login output, providers row or TUI
  row), green with them.
- go test -timeout 45m ./internal/cli/... ./internal/provider/... ./internal/tui/...: ok (cli 45.8s, provider 120.1s, tui 21.8s)
- gofmt -l: clean. GOOS=linux go vet -tags nogui ./...: ok.
  GOOS=windows go vet of the three packages: ok. go build: ok.
- Real run in a sandbox HOME with the fake test plugin and real Bun:
  plugin login (on: no line), provider off, plugin login again (the
  line, still off), magpie providers (row shows the command), provider
  on (row back to "signed in", no hint).

Not tried: a real WorkBuddy AI account; the built-in (non-plugin)
`magpie accounts add` path's line has no test of its own (its sign-in
needs a vendor's OAuth); the TUI was checked through its test, not a
real terminal; the full ./... suite was not run.
2026-10-25 13:19:52 +08:00
yetone 75e78a5a04 tui: quitting hands the gateway to magpie's service on Linux
zaidu259434 on X: "启动codex这些cli连接会失败,AI分析没自动启动magpie的网关".
With magpie installed inside WSL (or on a server over SSH), nothing
opens magpie at login, and XDG autostart doesn't run there. So once
`magpie tui` quit, the agents it had connected asked a gateway that was
gone.

When the terminal quits having served the gateway with an agent
connected, on Linux and where magpie doesn't open at login, keepGateway:
- starts magpie's service (magpie daemon) when it is installed;
- installs it when the user never removed it (daemon.Removed: Uninstall
  now leaves a daemon-removed mark, and Install clears it), so it starts
  with the system or the login from then on, and says how to remove it;
- otherwise (no systemd, which is WSL's default, or the user removed it)
  starts `magpie serve` in its own session, logging to magpie's cache,
  and says so. In WSL it also says how to turn systemd on.
macOS, Windows, nothing connected, or magpie opening at login: the same
"gateway stopped" note as before. Docs: gui-shell.

Run:
- TestKeepGatewayAsTheTerminalQuits covers each of those cases, and
  TestUninstallRecordsTheUsersNo checks the mark.
- go test -timeout 45m on the four packages, the same run as the
  previous commit's: all four ok (gateway 428s, agent 255s, tui 23s, daemon 16s), at 6874095b1 plus this change, before the rebase
- GOOS=linux and GOOS=windows go vet, and gofmt -l, are clean.
- Real run in the magpie-desktop distro (WSL2, systemd on): a Linux build
  from this tree started under setsid as serveInBackground does,
  answered 200, and still answered 200 with its pid alive 30s after its
  wsl.exe session ended. It was stopped afterwards.

Not tried:
- the interactive TUI quit itself in WSL (over ssh there is no terminal
  to drive it), so the message and the path it picks are covered by the
  unit test only;
- a real daemon.Install inside WSL (it writes a systemd user unit for the
  distro's user).
2026-10-25 12:42:20 +08:00
yetone 769355ab93 library: an MCP server's startup timeout reaches Codex as startup_timeout_sec, a hand-written one stays (#3168, miaomiaozi)
The Library's MCP server editor has a "Startup timeout" field (seconds),
shown when an agent that reads one is installed (AgentView.Startup; Codex
only). It is written to Codex's [mcp_servers.<name>] startup_timeout_sec,
user-wide and in a project's .codex/config.toml. Empty writes nothing, so
Codex keeps its own 30s, as before. The key and its unit are from Codex's
own source: RawMcpServerConfig in codex-rs/config/src/mcp_types.rs
(cb2581dae8de) has startup_timeout_sec: Option<f64> in seconds, and the
older startup_timeout_ms, which is read only when _sec is absent.

A value the user wrote in config.toml is never written over. magpie
records the value it last wrote (Applied.Startup per agent,
Project.Startup per project file). A value in the entry that differs from
that record, one there before magpie wrote any, or any
startup_timeout_ms, is the user's (startupTheirs), and magpie leaves the
key alone. Once the user takes theirs out, magpie's goes in. The TUI's
server editor keeps the GUI-set value, as it does for OAuth.

Other agents with a startup timeout (Grok Build, Hermes, OpenCode) and a
`magpie mcp add` flag are #3536.

Run, in a sandbox HOME with pinned GOMODCACHE/GOCACHE:
- go test -tags nogui ./internal/library ./internal/tui: ok (162s, 16s).
- New tests: TestCodexStartupTimeout, TestCodexStartupTimeoutKeepsUsers,
  TestCodexProjectStartupTimeout. Broken by hand, each red:
  every existing value counted as the user's -> "startup_timeout_sec =
  120, want 45"; magpie always winning -> "= 20, want 90"; no encode (the
  old code) -> "= <nil>, want 120".
- GUI: new mcp-startup-timeout.test.cjs, Chromium and WebKit, en zh zh-TW
  ja de, 1100 and 390px: 22/22; red on the old client.js (no field).
  The 59 GUI files the change reaches (mcp-*, library-*, i18n-keys,
  gui-de/ja/zh-tw, every editServer/lib-editor file): 935 of 937 pass.
  The red, library-row-remove's hook-row trash in Chromium, fails the
  same way on origin/main 208bd5c48 run alone (2 of 2); it is #3099.
- gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; linux nogui, windows and darwin builds ok.
- Real Codex: config.toml written by magpie under a scratch CODEX_HOME,
  read by codex-cli 0.162.1 `codex mcp list --json`:
  "startup_timeout_sec": 2.0.

After rebasing on origin/main 208bd5c48: go vet library+tui, linux nogui
and windows builds ok; go test -tags nogui internal/library (130s), tui
ok; internal/gui red once on TestRestartHandsTheGatewayOver (#3451, a
handover EOF, untouched here), then -count=3 alone and the package again
ok; GUI mcp-startup-timeout + i18n-keys 26/26.

Not tried: a real Codex start that actually times out (codex exec needs
a signed-in account in the scratch home); the full ./... suite.
2026-10-25 09:41:32 +08:00
yetone ed91aa04ef checkin: an inactive or ineligible check-in shows the plugin's reason (plugins#304)
Qoder's plugin 0.2.32 (magpie-community/plugins 74be632) says why no
check-in was offered: it asked with this machine's own device identity
and Qoder offered no campaign, and Qoder desktop can claim one it shows.
magpie dropped a hook's message for inactive and ineligible and showed
only "No check-in event now". Now:

- GUI: the Usage card's row reads "<label> · <message>", wrapped under
  the label rather than cut off with "…" (data-why, as a failed row's
  reason wraps, #821); Settings' check-in line under the plugin's switch
  carries it too. A result without a message reads as before. No new
  i18n keys: the message is the plugin's own text, as for failed rows.
- TUI: the Usage cell is too narrow, so it adds "c says why"; c's flash
  carries the message (checkinWhy).
- CLI: `magpie accounts checkin` prints it after the label.
- The Qoder mover's min is 0.2.32 (npm view --prefer-online: 0.2.32).
- docs/subsystems/provider-plugins.md says how the message is shown.

Run at this tree (based on origin/main dd1e8822d):
- go test -timeout 45m ./... (tee'd, grepped): every package ok
  but internal/handoff, whose TestTakeOnlyAFreshOfferForThisProgram
  could not bind a unix socket under my long scratch TMPDIR (path over
  104 bytes); with the default TMPDIR internal/handoff is ok.
- gofmt -l: clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean.
- GUI, chromium and webkit: checkin-reason (new: en, zh, zh-TW, ja, de;
  900 and 440px), plugin-checkin, qoder-checkin-recheck, usage-checkin,
  checkin-account, checkin-early-done, usage-quota-head, i18n-keys:
  155/157. The 2 reds are usage-checkin's "webkit en/zh: Settings has a
  Qoder check-in tab", red the same on a fresh origin/main a9a001a7a
  (#2549, #3091).
- TestCoreScriptBudget: app.js 1,343,313 of 1,343,324, no raise.

Rebased on origin/main 4683a0382 (a9a001a7a's app.js line, 4683a0382's
provider change) and run again at this head: internal/gui (budget:
1,343,323 of 1,343,324), internal/cli, internal/tui and the whole
internal/provider ok; the same 8 GUI files in both engines, 155/157,
the same two #2549/#3091 reds.

Broken by hand: app.js's change reverted, checkin-reason goes red on the
reason; app.css's reverted, red on the wrap; checkinWhy returning "" in
internal/cli and internal/tui, TestCheckinSaysWhyNoneWasOffered red in
each.

Not tried: a real Qoder account offered no campaign (the fixture is the
plugin's own text); the real Linux app (WebKitGTK).
2026-10-24 14:52:13 +08:00
yetone 45fa29973c checkin: an early "already checked in" is asked again, not kept for the day (#3326)
connoryang331 (v0.1.1328, Windows): at 00:00:28 Beijing 14 of 29 plugin
check-ins (AutoClaw CN x5, WorkBuddy x2, CodeArts, Trae x3, MiniMax,
Raccoon x2) answered "already" (done). magpie kept that as the day's
result and never asked again, and Check in now answered from the record
without asking. A real claim at 10:54 paid +200: the vendors' days turn
later than Beijing midnight, so 00:00's "already" was yesterday's.

The class, in the checkiner every check-in shares (built-in and plugin):
- A done, inactive or ineligible answered before noon Beijing
  (checkinSureHour) for an account magpie hasn't seen claim that Beijing
  day is provisional. The loop asks it again 30 minutes (wbCheckinEvery)
  after the answer, until a claim or an answer from noon on: at most 24
  more asks a day per such account, none once magpie claims.
- A press (soon) asks again at once for done, inactive and ineligible,
  whatever the hour. own-app (Trae 9074) and captcha still stand.
- A claim stamps Claimed, carried over while later answers that day say
  done, so a done after magpie's own claim is settled (Qoder's claim then
  done case).
- The record goes out with again: true (worked out when shown, never
  kept). The card says "{name} says already checked in; its day may not
  have turned yet, so magpie asks again later" and keeps Check in now;
  Settings, TUI and CLI say the same. en, zh, zh-TW, ja, de.
- Qoder's recheck (#2696, pluginRechecks) is unchanged: its tests pass
  as they were.

The plugins repo does not cache "already": autoclaw reads the task list
or calls dailySignin each time, codearts, minimax, raccoon and trae ask
the server each call (read at magpie-community/plugins origin/main
652f06d). No plugin change, publish or mover min.

Tests:
- TestPluginCheckinEarlyDoneAskedAgain (the reporter's 00:00:28: loop at
  +29m no ask, +30m asks then claims; a press at 10:54 claims; done all
  day is 25 asks and settles at noon; done after magpie's claim settled)
  and TestWorkBuddyCheckinEarlyDoneAskedAgain.
- TestPluginCheckinOthersSettledForTheDay now answers at 12:00 Beijing
  and checks a press asks again (claimed still settled);
  TestPluginCheckinRunsAsTheBuiltinsDo, TestTraeCheckinAnswers and the
  WorkBuddy nothing-to-claim/refused tests follow the new rule.
- TestCheckinAgainNotShownAsToday (TUI words and cell).
- checkin-early-done.test.cjs: again card's wording, data-state wait,
  Check in now asks plugin-checkin {provider: autoclaw-cn}; a kept done
  is "Checked in today +50" with no press. Chromium and WebKit, 5
  languages, 900 and 440px, 20/20.

Red on the old code: with the non-test change reverse-applied (fields
kept so it compiles), TestPluginCheckinRunsAsTheBuiltinsDo,
TestPluginCheckinOthersSettledForTheDay (inactive, done, ineligible) and
all 4 subtests of TestPluginCheckinEarlyDoneAskedAgain fail; with
origin/main's app.js, checkin-early-done fails ("Checked in today").

Run at this tree:
- gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./... clean.
- go test -tags nogui ./internal/provider/ -run 'Checkin|CheckIn',
  ./internal/tui/ -run 'Checkin|OwnApp': ok.
- GUI: checkin-account, checkin-early-done, i18n-keys, plugin-checkin,
  qoder-checkin-recheck, usage-card-refresh, usage-checkin: 177/179. The
  2 reds are usage-checkin's "webkit en/zh: Settings has a Qoder check-in
  tab", red the same alone on origin/main 0815c9186 (filed #2549, #3091).
- Full suite: set -o pipefail; go test -tags nogui -timeout 45m ./...
  at c1a72f2b4 (this tree on origin/main 0815c9186), sandbox HOME: 69
  packages ok, exit 0.

Not tried: real vendor accounts (no early-morning "already" to replay),
Linux and Windows at run time. A vendor whose day turns after noon
Beijing (a US day) is not covered.
2026-10-23 19:03:58 +08:00
yetone 44d8c742bf remote magpie: the guide names Settings → Network and sharing → Share on local network
The Remote magpie provider's guide, its "isn't shared" message and the
gateway's LAN errors said "Settings → Share on local network", but that
switch sits under Settings → Network and sharing. Every place now names
the real path: the en key and its zh, zh-TW, ja and de words in i18n.js,
app.js's message key, the preset's EndpointHint, the gateway's and
agent's English errors, docs/reference.md, docs/integrating.md,
README.zh-CN.md and the remote and docker pages of the site (en, zh, ja).
errRemoteNotShared names no Settings path and app.js matches its prefix,
so it is left as it is.

Run at base 673651e8d with this change:
- gofmt -l: clean. go vet ./... (darwin), GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...: clean.
- GUI (playwright 1.62.0, chromium and webkit, every language): 12 files
  that reach the strings, 121 of 122. The red, quota-name-translated
  (webkit en, 2px past its quota at 440px), fails the same at
  673651e8d without this change; it is #2228.
- go test -timeout 45m ./...: every package ok but internal/gui,
  where TestCoreScriptBudget failed: app.js was 1,338,819 bytes at
  673651e8d itself, over its 1,337,735 budget; origin/main 34ad18ed8
  (#3367) moved code out. This change adds 24 bytes to app.js.

Run again after the rebase onto origin/main 34ad18ed8: gofmt -l clean,
go vet of internal/gui, gateway, provider, agent and tui clean,
go test ./internal/gui/ ok (TestCoreScriptBudget passes), and the same
12 GUI files 121 of 122 with the same #2228 red.
2026-10-23 18:01:03 +08:00
yetone c417b1f4e3 library: a skill removed from its source is said so, and every such skill goes in one click, asked first
スライム on Discord (#help, 10-22): taste-skills took some of its skills
out, Update all reported each of them as a failure, and the only way
out was to delete them one by one.

An update or a check that reads the source whole and finds the skill's
folder (or its SKILL.md) gone now calls it removed upstream, not a
failure. GitHub tarballs and other git repositories both work this way.
- UpdateSkill returns *GoneError.
- UpdateSkills and UpdateSomeSkills list it in Result.Gone, not
  Unupdated.
- A check gives status "gone".
- Each marks Skill.Gone. The mark is cleared when a check or an update
  finds the skill there again.
- A fetch that failed, a skill left out of a fetch as too big, and a
  folder that can't be read stay unknown, never gone (goneFrom).

Nothing is deleted by itself. RemoveGoneSkills takes the named skills
out, or every marked one when none are named, through RemoveSkills, so
the folders go to the backups. A skill found in its source again is
kept and said so.
- GUI: a "Removed upstream" tag replaces Update available and the
  update icon. Update all says gone skills apart from failures. "Clean
  up N" sits in the group heading, or in the bar when there is one
  group, and opens a sheet naming each skill. One changed here carries
  "Changed here". Strings are in en, zh, zh-TW, ja and de.
- CLI: `magpie library skill rm --gone [--yes]` asks at a terminal and
  refuses without --yes otherwise. It names the ones changed here.
  update and status print the hint.
- TUI: the row says "removed from <repo> · d takes it out".
- API: POST /api/library/skills/remove-gone {names}.
- Docs: the Skill updates row and Verification in
  docs/subsystems/library.md.

Record for this push: 13 commits on origin/main ca4a1cde0, head tree
539c84e92. Go 1.26.8, sandbox HOME, GOMODCACHE/GOCACHE pinned. The full Go
run and vet were at tree d6393dfc8, the same Go code as this head: only
app.js comments (cut under the core script budget) and one ja string
changed after it.
- gofmt -l: nothing. go build ./...; go vet ./... (darwin), GOOS=linux
  go vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -timeout 45m ./..., through tee, one suite on the machine:
  68 packages ok. The one red was internal/gui's
  TestCoreScriptBudget: app.js 1,335,314 > 1,335,000, since main grew
  app.js under the stack. The autoscroll commit's own comments were cut
  (to 1,334,629) rather than the budget raised, and go test -count=1
  ./internal/gui is ok at this head (113s). Packages the run took from
  Go's test cache had the same inputs.
- GUI: the 18 files this stack touches or names, both engines,
  202 of 204 pass (tree 068acf128, this push less the last commit). The
  two reds: gui-ja, red on main since c2636b7b5 and fixed by this push's
  last commit (gui-ja and i18n-keys 6 of 6 there), and usage-fold's
  chromium "several accounts" (#2163, red on main the same way).
- skill-gone passes, chromium and webkit, en and zh, 860 and 400px.
- internal/library, internal/cli and internal/tui ok, the Gone tests and
  TestLibrarySkillRm among them.
- The rebase onto main met c2636b7b5's Verification line in library.md;
  both sides' tests are kept in it.
  The whole GUI suite ran at 1c1fc7183 (this stack's first 12 commits on
  0ddcf28a1): 11713 of 11769 pass. Each of the 21 red files was then run
  alone at the stack and at origin/main 8278fd9b0. Eight are red the same
  way on main: plugin-card-update (#3079), quota-count-wrap and
  quota-name-translated (#2228), s3-sync (#2448), usage-agents-hide
  (#2276), usage-checkin (#3091), usage-fold's chromium "several
  accounts" (#2163), usage-ledger (#3104). The other 13 pass alone on both
  and were red only under that run's load (50 to 335): currency #3101,
  plugin-github #3218, provider-fetch-again #3292, rest-try-now #2564,
  routing-auto-reset #3293, routing-keys-fold #1612, routing-steady #1804,
  routing-wb-restricted #1905, sessions-folder-delete #2218,
  sessions-manage #3294, switch-only #3295, text-size #1866, usage-pack
  #3296.

Broken by hand, each red, then restored:
- prepare not returning GoneError
- apply not clearing Gone
- leftOutAt ignored
- every Stat error read as absent
- the git check not saying gone
- RemoveGoneSkills taking a skill that isn't marked

Not tried:
- the real taste-skills repo over the network
- the Windows box
- a skill CC Switch installed (Origin, adopt path), which still reports
  as a failure
- a GitHub check with a known commit, which keeps an existing gone
  mark but only marks gone after an update
2026-10-23 01:58:00 +08:00
yetone 1bd99194ea provider: Claude Code stays listed, signed out, when every saved account's sign-in is gone
LeeHom on Discord: two Claude Pro accounts vanished from Providers, and
signing one in again showed the other as "needs sign in again". While
Claude Code is signed out, the claude provider is built on
claudeStandIn's account. claudeStandIn skips an account whose sign-in
Claude Code let go of (claudeLoggedOut's claudeLogoutLapse) or that is
still Held. With every saved account like that, it returned "", no claude
provider was made, and the subscription and both accounts left the GUI,
the TUI and `magpie providers` at once.

claudeStandInAccount and Logins now ask claudeListed: the stand-in, else
the signed-out account seen last. A Held account is never listed this way,
because the sign-in Claude Code left on disk would then be served
(TestClaudeSignedOut still holds). The listed account's token still fails
with the lapse reason (claudeSavedDir), so nothing is served on it.
claudeStandIn itself is unchanged, since addLogin and logins_on rely on
it.

The app's row already said "{user} is signed out" when every login in use
had lapsed. Provider.SignedOut is that rule in Go. With it, `magpie
providers` says "○ <user> is signed out · sign in again" and the TUI says
"○ <user> is signed out", instead of a green "signed in". The CLI's key
column moved into keyColumn so it can be tested. The providers-accounts
doc row says this.

Tests:
- TestClaudeAllSignedOutStaysListed: signed in, a second account
  logout-lapsed, then Claude Code signed out. It fails on the old code
  ("Claude Code left the Providers list with every account signed out:
  false") and with SignedOut returning false (both broken by hand).
- TestProvidersSaySignedOut, in cli and tui: a signed-out account reads
  as signed out and a signed-in one still reads as signed in.

Run: gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags
nogui ./..., GOOS=windows go vet ./...; go build for all three.

Then go test -timeout 45m ./... under a sandbox HOME at base ba319a758
(load ~25). Every package was ok except two:
- internal/agent timed out with a 2s-old test running (rerun alone: ok
  1866s).
- internal/gateway failed TestRateLimitIsWaitedOut, "an hour away: passed
  on after 1.32s" against its 1s bound. That is #1971, open, a wall-clock
  bound under load and not this change; rerun alone: ok 1433s.

Rebased on d771138c4 (13 commits, including c79400556 in
agent/provider.go). At the pushed head: gofmt clean, go build for darwin,
linux nogui and windows, go vet of provider/cli/tui, and go test
./internal/provider ./internal/cli ./internal/tui all ok. No GUI file
changed, so the GUI suite was not run.

Not tried: a real Claude account signed out in Claude Code. The sandbox
test drives the same files (.credentials.json, .claude.json, logins.json).
2026-10-21 19:00:33 +08:00
yetone 5c557c793c usage: the allowance cards come in the Providers page's order (Zhenbao TONG on Discord)
Reported: Zhenbao TONG moved a provider on the Providers page, and the
tray panel's Allowances tab kept the old order.

Changed: provider.InProviderOrder(qs) (internal/provider/quotas.go) sorts
a copy of the quota cards, stably, by the provider's place in All().
Providers it doesn't know go last. Used by /api/quotas's two routes
(internal/gui/usage.go) and the TUI (internal/tui/pages.go). The app.js
comment says the order now comes from the server.

Test: TestQuotaCardsInProviderOrder (quotas_order_test.go). Broken by
hand:
  - InProviderOrder as the identity: "as added: [a/a1 remote:x/r c/c1
    b/pro a/a2 c/$1]".
  - sorting without the clone: "Quotas' list was sorted in place".
Not covered: the /api/quotas wiring has no test beyond the function's
unit test.

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
keeuu 75e769a9f9 routing: Free first spends the models that cost nothing before the ones that spend (#3054)
A provider or group can be routed `free`. Seats whose model the vendor
serves at no cost to the allowance or credits go first, in listed order.
The rest follow, also in listed order. Free means the vendor's own
catalog.Model.Free word, or else a $0 list price on every count
(provider.FreeModel). A pool with no free model behaves as In order.

routes.Seat gains Free and Strategy gains ByFree. weighRouted works Free
out only for a strategy that weighs by it, so other routings never read
a model list for it.

It is wired through every list a routing appears in:
- both save whitelists;
- plugins/rotation's Builtin;
- app.js's ROUTINGS (appScriptBudget 1,269,000 → 1,271,000 for the
  description) and the Routing page's options, hints and trace text;
- zh-TW, ja and de strings;
- the TUI's routings;
- the CLI's aliases (free, free-first).

Written by keeuu (issue #3054, three commits), squashed onto dee5c9d75
and reviewed:
- the harm checks were clean;
- FreeModel runs only for ByFree, so its Available() walk costs nothing
  for other routings;
- accounts can list different models, so Free first means something for
  a provider's own accounts too, not only for groups.

Run at this head:
- gofmt -l: clean.
- go vet: darwin (internal/routes, provider, gateway, cli, tui, gui);
  GOOS=windows ./internal/...; GOOS=linux -tags nogui ./... — all clean.
- go test ./internal/routes ./internal/provider -run
  'Free|Routing|Strateg|Builtin' ok; ./internal/gateway -run
  'FreeFirst|Weigh|Routing' ok.
- Broken by hand: with FreeFirst returning paid before free,
  internal/routes' Free tests and
  TestFreeFirstGroupSpendsTheFreeMemberFirst go red. Restored, green.
- go test ./... -count=1 -timeout 45m, at load average ~460 from other
  sessions: 62 packages ok, 3 red:
  - internal/gui TestMainWindowCorners (#1936/#2645, AppKit window
    killed at its deadline under load);
  - internal/gateway TestClaudeAccountsSpentFallBackToCodex ("no
    answer"): ok alone in 46s;
  - internal/agent timed out at 45m inside TestSnowSmallModel (1s in):
    the package is ok alone in 1519s.
- GUI, both engines (node --test, playwright 1.62.0), 23 files:
  account-arrange, builtins, context-text, context-scroll-end,
  context-window, group-member-weight, key-weight, rate-limited-sink,
  routing-reset-deadline, routing-compaction, routing-key-windows,
  routing-save, routing-sealed-task, routing-weight-chip, search-keys,
  i18n-keys, panel-routing-pick, panel-routing-providers, panel-routing,
  routing-columns, gui-de, gui-ja, gui-zh-tw. 230 of 236 pass.
  routing-save (the 6/7 counts), routing-columns, i18n-keys and the three
  language files are green.
  - account-arrange "every mode" (#2200): red in both engines, alone,
    and on origin/main dee5c9d75 too.
  - builtins chromium "Plugins › Built-in" (#2960): a 5s wait for the
    Plugins page. Red alone and on dee5c9d75 too; the webkit run checks
    the new Routing strategies subtitle and passes.
  - context-window and context-text, single cases in different
    language/engine pairs on each run: 5s waits under load (#1544,
    #2900). Untouched by this change.

Co-authored-by: keeuu <159448501+keeuu@users.noreply.github.com>
2026-10-20 20:08:25 +08:00
yetone 81a24cf8fe groups: a found group is listed as auto/<model id as the vendor spells it>
ZeroClover asked on X: Auto Group ids group/auto-<slug> can't be looked
up on models.dev. A found group is now listed and written as
auto/<model>, e.g. auto/claude-opus-5.5: /v1/models, the catalog, agent
configs, the GUI's Routing page and the CLI. Context and output limits
come from the model's metadata as before.

What stays the same:
- The internal id is still group/auto-<slug> (Group.Ref() gives the
  public one). Every old form is still accepted as input forever:
  provider.CanonicalRef turns auto/<model>[:level][[1m]] into it at the
  gateway (validateModel), keys, stats, affinity and usage, so both ids
  route to the same group and count as one.
- A key's model list allows a model by either id, group/* included
  (allows() in key_models.go).
- Hand-made groups stay group/<id>.
- A provider whose stored id is "auto" keeps its models: while one
  exists, found groups are listed by their old id (AutoRefsOn) and
  auto/<x> means that provider's model. Documented in
  docs/subsystems/gateway-routing.md.

Agent configs: SyncCatalog rewrites a field that holds a found group's
old id (renameFoundGroups), but only while the value is still what
applied.json says magpie wrote; a value the user set stays. A pick by
the old id written now is written as auto/<model> (Apply). Hidden,
picked and ordered model lists saved by the old id hold for the new one
(visible.go), and a bare model id still reaches its found group (bare.go).

Claude Code is given a dotted Claude version dashed (ClaudeSpelled), so
auto/claude-sonnet-4.5 sits in its settings as auto/claude-sonnet-4-5.
That routes to the same group, but with found groups off nothing reads
it back dotted, and Reseat took the field for changed and left the agent
on a group that was gone. Reseat now compares a group pick by its
canonical id (samePick). The old ids had no dots, so this is new with
auto/<model>.

Run at this tree (sandbox HOME, caches pinned):
- gofmt -l: clean. go vet ./...: clean on darwin, GOOS=linux -tags
  nogui, GOOS=windows.
- go test -p 4 -timeout 45m ./...: every package ok except agent and
  gateway, whose failures were the tests' expected ids (updated here)
  and two regressions now fixed (bare ids; desktop models hiding groups
  by prefix). Every failing test passes on rerun. Load average was
  ~210-290 from other sessions throughout.
- Reruns: provider, cli, codexcat ok. internal/gui: only
  TestSetAnswersWhileDevinAndProvidersHang fails (set slow/slow-1 took
  10.19s), and it fails the same in a git-archive export of 33dbdcc52.
- agent and gateway in full, -p 2 -timeout 120m: gateway ok (2996s).
  agent failed four tests that still expected the old ids
  (TestOmp/PiModelsAskedOnTheirNativeAPI, TestReseatFoundGroupsOff,
  TestReseatKeepsAFoundGroupWithAProviderOff); updating them showed the
  Reseat bug above. After the fix, go test -count=1 -timeout 120m
  ./internal/agent/: ok (1000s, load ~160-220).
- GUI files the change reaches, chromium and webkit: group-found-off and
  the routing files pass, except routing-bodies, routing-model-rest,
  routing-keys-fold and routing-request-metrics, which fail the same with
  33dbdcc52's JS.

Broken by hand and watched red, then restored: CanonicalRef in
validateModel (both-ids routing test), allows() (key tests both ways),
the Save refusal and AutoRefsOn checks in Ref/CanonicalRef (provider
named auto), catalog.Lists' preference (models.dev lookup of the part
after auto/), renameFoundGroups' applied.json check and its SyncCatalog
call (user values kept), PublicRef in visible.go, the codexcat prefix,
samePick in Reseat (TestReseatFoundGroupsOff: opus left on the gone
group).
TestBareModelIDsShared was red before the bare.go fix.

Not verified: no real agent, vendor or models.dev client run; no run on
the Windows box. Settings pickers (vision, title model) holding a saved
group/auto-... value may show it as saved. codexcat can't tell a stored
"auto" provider apart, so its models lose the "text only" hint. The
pre-existing reds above are not filed.
2026-10-20 00:18:51 +08:00
yetone 9fd80b2128 library: skills install from any git repository, GitLab and a company's own among them (sunset on Discord)
ProbeSkills took only a GitHub source or a folder. It now also takes any
git repository's address: https/http on gitlab.com or a self-hosted
server (any depth of groups), a GitLab or Gitea page of a folder
(/-/tree/<ref>/<path>, /-/blob/..., /src/branch/...), ssh://,
git@host:group/repo.git, a bare host.name/group/repo, and file://.
Such a source is kind "git" (gitSource, skillgit.go).

It is fetched with the user's own git (proc.FindTool), so their
credential helpers and SSH keys reach an intranet host: git init, then
fetch --depth 1 --no-tags -- <url> <ref|HEAD>, checkout FETCH_HEAD into
a magpie-skill-* folder, .git removed; the same keepProbe/maxFetch path
GitHub's tarball takes.

What the user typed is data: an address starting with - and any
transport:: address (ext::, fd::, file::) are refused before git runs;
the address follows --; git runs with protocol.ext.allow=never and
core.symlinks=false, no shell, GIT_TERMINAL_PROMPT=0, and ssh -o
BatchMode=yes unless the user set their own SSH command (GIT_SSH,
GIT_SSH_COMMAND, core.sshCommand), so a sign-in it can't make fails
instead of waiting. An address with a password or token in it is
refused: library.json is shown and backed up. Git missing, a sign-in
refused, an unknown host key, a missing branch and an unreachable host
each say so plainly (gitError).

Updates: Commit keeps the repository head the skill was fetched at. A
check runs git ls-remote; another head is fetched (once per repository
and ref) and the skill's folder hashed, so a commit elsewhere in the
repository leaves it current and moves Commit on. UpdateSkill and the
edited-skill refusal work as for GitHub; EditedError and the page's
Changed here / Update / replace question name the repository instead of
GitHub. findNew, Group again, icons and the market stay GitHub's only
(documented).

Page, TUI and docs: the add box's placeholder in en/zh/zh-TW/ja/de
(zh: owner/repo、GitHub 或 GitLab 链接、任意 git 仓库地址,或本机上的文件夹),
a git skill's source shown as a link (https) or text (SSH), its own
Update and Check for updates; the TUI's prompt; library.md's Skills and
Skill updates rows. GIT_SSH/GIT_SSH_COMMAND are listed in agentenv's
notAnAgent (TestFolderVarsAreListed).

Tests (fail on the old code: gitSource/gitPath don't exist there, and
skill-git-source.test.cjs fails on the old assets' placeholder, checked
by stashing client.js/i18n.js): TestGitSourceReads,
TestInstallFromGitRepo (a local bare repo over file://: probe, install,
check finds an update, update, a commit elsewhere stays current, an
edit here is refused naming the repo), TestGitTreeURLInstallsFolder,
TestGitMissingSaysSo, TestGitSignInRefusedSaysSo (a local httptest 401,
GIT_CONFIG_NOSYSTEM so no Keychain), TestGitRefusesOptionsAndTransports,
TestGitErrorsSaid. No test reaches the network.

Run (worktree at origin/main 224ea7d5b, machine load average ~120-145
from other sessions):
- gofmt -l: clean. go vet darwin, GOOS=linux -tags nogui, GOOS=windows:
  clean.
- set -o pipefail; go test -timeout 45m ./...: 63 packages ok; one red,
  internal/agent TestFolderVarsAreListed (GIT_SSH vars), fixed above
  and rerun alone: ok.
- After later edits, rerun ./internal/library ./internal/cli
  ./internal/tui ok; internal/gui TestMainWindowCorners red once at
  load 144 (76.5s, AppKit window test this change doesn't touch),
  passed alone (28.6s); internal/agent timed out at 45m in that
  combined rerun at load ~140 (it ran 962s in the full run) and passed
  alone (1808s, load ~100).
- GUI: the 88 test files that load the library page, chromium and
  webkit: 1420/1420 pass; skill-git-source + skill-update-edited rerun
  after the last client.js edit: 20/20.
- Real use in a sandbox HOME (GIT_CONFIG_NOSYSTEM=1): a local bare repo
  over file:// probed, installed, checked current, a new commit found as
  update, updated to v2; ext:: and --upload-pack refused with nothing
  run; https://gitlab.com/gitlab-org/ai/skills probed (52 skills), its
  /-/tree/main/skills/glab installed and checked current; a private
  gitlab.com address said "git couldn't sign in to gitlab.com ...".
- Not tried: a real self-hosted GitLab with credentials, ssh:// against
  a real host, Windows.
2026-10-19 18:16:57 +08:00
yetone e405315d79 provider: Cursor's built-in is retired; its plugin serves it
"cursor" joins retiredBuiltins (migrate.go), so PluginServes("cursor")
holds moved or not, and the built-in's code goes, as Zed's did in
c0605abc2 and Kiro's in the commit before this.

Removed:
- gateway/cursor.go (the Connect/protobuf translator) and its tests
  (cursor_test, cursor_conversation_test, cursor_maxmode_test,
  cursor_precision_test, cursor_stepusage_test), and gateway.go's
  Account.Agent == "cursor" dispatch to serveCursor;
- provider/cursor_usage.go (the usage card, cursorToken, cursorKeychain)
  and provider/cursor_picker.go, with their tests;
- from cursor.go: the built-in account (cursorAccount), its model list
  through `cursor-agent models` (cursorModels, parseCursorModels,
  cursorModelL), its sign-in (startCursorSignIn, cursorLinkWhole,
  cursorLoginUUID), the API client version (CursorClientVersion,
  cursorVersionFallback, cursorVersionRe) and the token refresh
  (CursorToken, cursorRefresh, tokenExpiry);
- StartSignIn's "cursor" case (signin.go), the usage fetch
  (subscription_usage.go), the login-list case and quota (login_usage.go)
  and the account (account.go);
- "cursor" from Native (provider.go) and asksOwnBackend (modelprefs.go).

Kept, because the mover, the plugin paths or other code need them:
- cursor.go's PLUGIN-SERVED notice (TestMovedBuiltinsSayTheirPlugin);
  cursorIdentity, cursorStatus, parseCursorAbout, readCursorToken,
  cursorTokenOf, cursorKeychainToken and cursorAuthFile: migrate_side.go
  and plugin_accounts.go ask whose account the agent is through them;
- cursorLoginURL (grok.go and claude_signin.go use it), cursorContext and
  withCursorContexts (the plugin's model contexts), CursorExecutable and
  isCursorAgent (the Cursor agent itself);
- cursor_models.go whole: CursorBase (agent/legacy.go), CursorVariants
  (groupfast.go, the plugin's fast pick), cursorPicks and the collapse
  (provider.go, models.go);
- accountIDs, builtinOrder, models.go's "cursor" live branch and
  servedByCursor, as Zed's and Kiro's commits left theirs. The live
  collapse and cursorPicks now only ever meet a built-in list, which a
  retired Cursor never has; they are left for a cleanup of their own.
- gateway/cursor_local_models_test.go (the Cursor agent, not the
  built-in) and the gateway's plugin_*_test.go parity tests.

Tests changed in meaning:
- cursor_signin_test.go became cli_signin_test.go: its two generic
  runCLISignIn tests stay (grok's), TestCursorSignInJoinsAWrappedLink
  goes with cursorLinkWhole.
- cursor_test.go keeps parseCursorModels as a test helper (the old
  parser, for the collapse tests' fixtures); TestParseCursorModels,
  TestCursorClientVersion, TestTokenExpiry and TestCursorLegacyPicks go,
  and cursor_names_test.go's TestCursorAvailableNames: they tested the
  built-in account's list and picks. Cursor's plugin lists its own
  picker models with their efforts (index.mjs), so magpie's collapse
  never runs for it; moving the two tests onto the plugin showed that.
- TestFetchNewWaitsForASlowSignIn (#1789) and
  TestFetchNewListsAgainForAnAnswerWhileListing (#1147) are gone: both
  were about a CLI account whose models `cursor-agent models` lists,
  and no built-in left lists its models through its CLI.
- internal/gui/providers_fetching_unix_test.go
  (TestProvidersAnswerWhileListsComeIn, #541) is gone: its slow vendor
  was the built-in's `cursor-agent models`. The guarantee (the
  Providers page answers while an account's list comes in) has no test
  now; re-homing it onto an HTTP-listed account (Antigravity, Copilot)
  needs exported test hooks and is left as a follow-up.
- TestNative drops its Cursor case; TestLeftAloneRunsNoCLI fakes and
  expects claude and devin only; isolate() and
  TestAccountDiscoveryOffReadsNoSignIn no longer set cursorKeychain
  (cursorTokenOf reads the Keychain on macOS only, as before).
- Dropped as built-in only: the Cursor case of the required-tools test,
  TestCodexToolImageCursor, TestCursorSplitParallelCallsKeepTheirResults.

Run at this tree (load ~300, so narrow runs only):
- gofmt -l internal: clean
- go vet -tags nogui ./... ; GOOS=linux and GOOS=windows the same: ok
- staticcheck -tags nogui -checks U1000 ./internal/provider/: clean;
  with -tests=false over provider and gateway: nothing Cursor or Kiro
- go test -tags nogui -count=1 -run 'Cursor|Kiro|Migrat|Mov|Retired|
  SignIn|AsksOwnBackend|Plugin|HandOver|NoWayBack|Adopt|Hide|
  RequiredTools|ToolImage|Split|Discovery|Account|Isolat' over
  provider, gateway, cli, gui: gateway ok 446s, cli ok 67s, gui ok 51s;
  provider failed TestCursorAvailableNames, TestCursorLegacyPicks,
  TestFetchNewWaitsForASlowSignIn (above) and
  TestSetUpstreamNameRefusesAnAccountBackend (Kiro's, fixed in that
  commit)
- every other test naming "cursor" or cursor-agent, by name, over the
  same four packages: gateway and cli ok; TestNative,
  TestLeftAloneRunsNoCLI, TestFetchNewListsAgainForAnAnswerWhileListing
  and TestProvidersAnswerWhileListsComeIn failed (above)
- after the changes: gofmt clean, vet ok on all three; -run 'Cursor|
  Kiro|Migrat|Mov|Retired|SignIn|AsksOwnBackend|Plugin|HandOver|
  NoWayBack|Adopt|Hide|Discovery|Account|Native|LeftAlone|SetUpstream|
  FetchNew|Hold|DailyCredits|NotSignedIn|ModelTest|Providers': provider
  ok 141s, gui ok 21s, cli ok 22s (gateway untouched since its ok run)
Not run: the whole packages, the full suite, the GUI node suite.
2026-10-17 23:11:00 +08:00
yetone 333c167575 routing: a rule can set the reasoning its model is asked for (#2633)
dengtongcai asked for a routing rule that picks both the model and the
reasoning it is asked for (a quick question goes to a cheap model at low).
A rule now has an output field, useEffort (low|medium|high|xhigh|max). When
the rule matches, its member is asked for that effort. A member's own fixed
effort still wins. Otherwise the rule beats the model's suffix, the turn's
pick and the agent's pick. The existing effort condition is unchanged.

- The value is fitted to the model's levels (max -> high on a model that
  tops out at high). A model with no Efforts is sent what the agent asked,
  untouched. Unset changes nothing. Failover members are not affected.
- The trace records it: Rule.UseEffort and the try's RuleEffort (the second
  Try construction in the candidate loop was missing it).
- Saving a group rejects an unknown value or one on a pause (cleanRules).
  The CLI takes use-effort=; the TUI and CLI lists show " at <effort>".
- GUI: a chip after the rule's model, picked from the app menu (pickFrom,
  no native select), set/changed from the rule's menu. A pause clears it.
  Strings in zh, zh-TW, ja, de.
- A Gemini-protocol client is left unchanged, as with every effort magpie
  sets.
- Docs: docs/subsystems/gateway-routing.md; site docs intent and start (en,
  zh, ja).

What was run, at d4c03a2c5 (rebased on d4a1b9baa) unless said:
- gofmt -l: none. go vet ./... (darwin), GOOS=linux and GOOS=windows
  go vet -tags nogui ./...: clean.
- go test -count=1 ./internal/gateway ./internal/provider ./internal/cli
  ./internal/tui: ok.
- The full go test -timeout 45m ./... under pipefail, before the rebase at
  6f950653f: every package ok except internal/gui. There, 8 real-window
  darwin tests were killed at their deadlines with the load average at
  150-300. Four passed on a rerun. TestMainWindowCorners,
  TestMainWindowRightToLeft, TestTrayCellClickReleasedPanel and
  TestCoveredWindowStaysUp fail the same way on a clean 6f950653f checkout
  (added to #1936). This change has no Go in internal/gui.
- Broken by hand: ruleEffort returning "" turns the four gateway tests red
  (Chat member, intent rule, failover member, Anthropic member). Returning
  the raw value for a model with no levels turns the unset/no-levels test
  red. Dropping the cleanRules checks turns TestCleanRulesUseEffort red.
  routing-rule-effort.test.cjs against the 6f950653f routing client.js and
  i18n.js is red.
- GUI: routing-rule-effort.test.cjs passes 18/18 in chromium and webkit
  (en, zh, zh-TW, ja, de; 1100 and 420 wide). The 140 GUI files that open
  the Routing view ran 560 tests before the run stopped with no summary.
  Two of the 560 were red: group-from-model-add (#2388) and
  name-suffix-where-named (filed #2640, a skeleton-row race). Both pass
  alone. The whole 791-file suite was not finished. At a load near 280 it
  covered about 20 files in 40 minutes. The reds it showed were in
  account-* files, and account-models passes 12/12 alone.
- Then rebased onto 8bb9375e7 (#2635, internal/library only) and
  go build ./... at the final head.
2026-10-17 10:04:39 +08:00
yetone 7170b5d8bd usage: the plan credits a reply says it cost are summed by model, agent and session (#2512)
wwcraft_ on Discord asked for the WorkBuddy credits spent on the Usage
page, by model, agent and session. WorkBuddy's chat stream ends with
usage.credit, the per-request figure its own app shows as "Credits
Consumed". The built-in and the moved plugin both hand that chunk to the
gateway's chat decoder (the plugin's renamed()/kept() pass usage on as it
came), so cUsage reads `credit` into Usage.Credits and the three record
sites keep it on the row. A reply that says nothing has no credits, not 0.

- usage: Record.Credits; Totals/Via sum Credits and count Credited; the
  packed row keeps it under its own flag bit (4096, in TestRowFlagsApart);
  the ledger CSV gains a trailing "credits" column.
- GUI: the Usage ranking's line says "0.7 credits" (积分, 積分,
  クレジット, Credits) beside the cost, its title how many requests said
  it; the Sessions page's Routed line says it per route. TUI usage page
  and `magpie usage` tables say it muted on the same line. No new layout.

Real replies on workbuddy-ai, 10-16: gemini-3.5-flash "credit":0.01;
deepseek-v4.1-flash, minimax-m3, kimi-k2.6 "credit":0; glm-5.3-flash
refused (14003). The tests use those bytes.

Run (at b07b518e7 on origin/main 63be47717, with #2511's commit):
- gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...: clean; go build: ok.
- go test -timeout 45m ./... with pipefail, sandbox HOME: 63 packages ok,
  usage (200s), cli, tui, gui among them; agent, gateway and library timed
  out at load ~270 (see the #2511 commit); library ok alone, agent and
  gateway ok with -timeout 150m: agent ok (5529s); gateway red only in TestIntentClassifierGroup (#1813), TestMaxRPMWaitsForRoomInTheMinute (#1791) and TestMaxRPMGroupPrefersMemberWithRoom (#2520), known timing reds under load, each passing alone here -count=3 (19s).
- New: TestPlanCreditsReachTheLedger (chat stream, whole reply,
  translated /v1/messages, free 0, none), TestPlanCreditsSummed,
  TestPlanCreditsPacked, TestFormatCredits, TestUsageSaysCredits, and
  plan-credits.test.cjs (en, zh, zh-TW, ja, de; Chromium and WebKit;
  420px fit) 12/12.
- Broken by hand: dropping Credits at the record site turns the gateway
  test red; skipping it in unpack turns the usage tests red; dropping the
  ranking's ledCredits turns plan-credits red in every language.
- GUI reds elsewhere: see the #2511 commit (#2536, #2552, a
  provider-detect-draft load timeout that passes 3/3 alone).
- Rebased onto origin/main ba132d68b (13 commits; chat.go, gateway.go, app.js, i18n.js among theirs): gofmt and go vet ./internal/... clean; Credits/DeepSeek/Balance/Ledger/RowFlags tests in usage, gateway, provider, cli, tui ok; plan-credits 12/12, balance-parts 4/4, i18n-keys 3/3 in both engines.
2026-10-16 20:11:34 +08:00
yetone 1bc61b66d7 provider: DeepSeek's balance says its granted and topped-up parts under the total (#2511)
wwcraft_ on Discord asked for DeepSeek's 赠金 apart from what was topped
up. /user/balance gives each currency's granted_balance and
topped_up_balance beside total_balance; the card's main figure stays the
total, and the two parts are told under it as secondary detail, the way a
balance's other parts already show (no new layout). The GUI's card and
menu bar panel, the TUI's quota page and `magpie quota` say them, labels
in every language (en, zh, zh-TW, ja, de). A reply without the parts, or one
with nothing granted, reads as before.

Real reply, read once from the owner's DeepSeek key on 10-16:
{"currency":"CNY","total_balance":"134.13","granted_balance":"34.14",
"topped_up_balance":"99.98"}. Fed through readDeepSeek/readDeepSeekSplit:
"¥134.13", Granted ¥34.14, Topped up ¥99.98.

Run (at b07b518e7, this commit plus #2512's on origin/main 63be47717):
- gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...: clean; go build: ok.
- go test -timeout 45m ./... with pipefail, sandbox HOME: 63 packages ok,
  provider, tui, cli, gui and usage among them. agent, gateway and library
  hit the 45m timeout at machine load ~270 on 14 cores; the tests running
  at the panic were 1s-1m14s old (TestCodexLoginAPI,
  TestLoopGuardLeavesOrdinaryRepliesAlone, TestZedMCP), not a hang. Rerun
  alone: library ok (1295s); agent and gateway timed out at 45m again, and
  ok with -timeout 150m: agent ok (5529s); gateway red only in TestIntentClassifierGroup (#1813), TestMaxRPMWaitsForRoomInTheMinute (#1791) and TestMaxRPMGroupPrefersMemberWithRoom (#2520), known timing reds under load, each passing alone here -count=3 (19s).
- GUI, Chromium and WebKit: balance-parts (DeepSeek's parts, en and zh,
  panel too) 4/4. Every GUI file touching balances, usage, sessions or
  i18n (176 files, 4 at a time): red only in model-id-space (#2536),
  provider-advanced-fold (#2552) and one provider-detect-draft case.
  The first two fail on origin/main 63be47717 run alone. The third was
  page.goto's 5s load timeout in the parallel run; run alone it passes
  20/20 three times here and on main, and this diff doesn't touch the
  provider editor (app.js changes are the balance card and the Usage
  ranking only).
- Broken by hand: dropping readDeepSeekSplit from DeepSeek's source
  turns TestDeepSeekBalanceSplit red (gift's split = "").
- Rebased onto origin/main ba132d68b (13 commits; chat.go, gateway.go, app.js, i18n.js among theirs): gofmt and go vet ./internal/... clean; Credits/DeepSeek/Balance/Ledger/RowFlags tests in usage, gateway, provider, cli, tui ok; plan-credits 12/12, balance-parts 4/4, i18n-keys 3/3 in both engines.
2026-10-16 20:11:33 +08:00
yetoneandggbdpq 1d227a7eb9 tui: a group's page keeps the row picked and its header in view (#2452)
What changed
- viewGroup drew every member and every rule and left the rest to the
  terminal. A group with more of them than the terminal has rows (a
  whole provider's thirty models at 80x24) scrolled the header and the
  highlight off the top, and j/k moved a pick no one could see. The
  library page (#2220) and the agents page (#2428, fed24aa1d) had the
  same disease; this was the last page with a cursor and no window.
- groupWindow draws the rows around the pick, as ggbdpq's patch does: a
  pick among the models keeps the first rules below it, a pick among the
  rules keeps the models' tail above it, a short group is drawn whole.
- groupRows counts every other line the page draws, including the
  pattern lines, the classifier line and the "none" line, which the
  patch's flat h-10 left out. With h-10 the page still ran three lines
  past the terminal and its header scrolled away.

Run
- New TestGroupViewKeepsTheRowPicked: thirty models; one model with 24
  rules; both, with three patterns and an intent rule's classifier.
  Every pick at 24 and 40 rows must draw no more lines than a short
  group's page, keep "◉ magpie" on screen, and mark the pick's own
  numbered row. A tall terminal draws the whole group.
- Broken by hand: old routing.go goes red (pick 0 draws 41 lines,
  22 fit), the patch's h-10 goes red (25 lines), and leaving the
  patterns uncounted goes red (23). With the fix it's green.
- Other cursor pages were audited (agents, providers, groups, library,
  sessions, pickers). All are windowed; only the group page had none.
- gofmt -l clean; go vet -tags nogui for darwin, linux and windows.
- Full suite: go test -timeout 45m ./... at f1c91a99c: 65 packages ok, internal/gui red only in TestPanelJoinsFullScreenSpaces ("the panel shown doesn't take the keyboard"), the macOS 26.2 red filed as #2450 and red on main without this change.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-16 06:32:59 +08:00
ggbdpq fed24aa1d6 tui: the agents page keeps the row picked in view, however many agents are installed
What changed
- viewList drew every agent and left the window to the terminal: on a
  machine with more agents than the terminal has rows the highlight
  scrolled off the top and the page froze — pressing j changed the row
  while the screen stood still, the same disease the library page had
  (#2220). The rows around the one picked are drawn now, as many as fit
  (the providers page's window).

Run
- TestAgentsViewKeepsTheRowPicked (new): 30 agents on a plain 80x24
  terminal, the row picked at 0, 4, 8, 15, 22 and 29 stays on screen,
  and a tall terminal still shows the list's top. Red at 422d057d
  ("row 0 (agent-00) picked, but the screen stops short of it",
  agents 06-29 with no highlight), green after; red again with only
  internal/tui/tui.go stashed. internal/tui and internal/library whole
  (ok, -tags nogui -p 2). gofmt clean; vet darwin, linux -tags nogui
  and windows = 0; build darwin, linux -tags nogui and windows = 0
  (trayimage_darwin.go's cgo -Wenum-conversion warning as ever).

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-16 00:44:19 +08:00
yetone e894443932 trae: a check-in Trae CN refused 9074 says Trae refused it and to check in in the Trae CN app, not that Trae pays only its own app (#1920)
#1920 showed Buddy Switch checking in third-party Trae CN accounts, so
"Trae CN only gives check-in credits to its own app" wasn't true. What is
known is that Trae CN answered the claim 9074 (当前参与用户太多). The
own-app outcome stays as it was (the day's answer, no Check in now), but a
Trae account (By "trae") now has its own text in every place it shows:

- GUI card and Settings line: two new keys in en, zh, zh-TW, ja and de
  ("Trae CN refused this check-in (9074: too many taking part); check in
  in the Trae CN app" / "Trae CN 拒绝了这次签到(9074 当前参与用户太多),
  请在 Trae CN App 里签到"). WorkBuddy keeps the shared own-app key.
- TUI line and cell, CLI: provider.TraeRefusedWords; the cell says
  "签到 refused by Trae CN (9074) · check in in its app".
- trae_checkin.go, workbuddy_checkin.go and provider-plugins.md comments
  and the claim's fallback message say the same. They also note the
  plugin side: since @magpie-community/opencode-trae-auth 0.2.14 the
  account the machine's own Trae CN client is signed in as checks in with
  the client's device id, read only. No id is made up or rotated (#1705).

Ran (worktree at origin/main 9d97fd073, -tags nogui, -p 1):
- gofmt -l internal/: clean. go vet ./internal/{tui,cli,provider} for
  darwin, linux and windows.
- go test ./internal/tui ./internal/cli: ok.
- go test -run 'Trae|Checkin|WorkBuddy' ./internal/provider: ok.
- GUI: usage-checkin.test.cjs and i18n-keys.test.cjs in Chromium and
  WebKit, en and zh: 31 pass, 0 fail.

Broken by hand:
- app.js's card without the Trae branch: the renamed usage-checkin test
  fails in chromium en/zh and webkit en/zh (4 of 4).
- pages.go's ownAppWords without the Trae branch: the new
  TestTraeOwnAppSaysTraeRefused fails.

Not tried: a real Trae CN account. No test checks the CLI line on its
own. The ja, de and zh-TW strings are checked only by i18n-keys.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetoneandggbdpq e413512d8e library: an agent whose CLI is gone (only its config folder left) is no Library write target, and nothing it already has is removed (#2254, ggbdpq)
After an agent is uninstalled, the Agents page shows "CLI not found"
(d0fcb8bc), but Library still offered it for skills, MCP servers, shared
instructions and rtk, and a sync wrote into a folder nothing reads.

- library.Targets() leaves out an agent whose CLI is missing
  (agent.CLIMissing: false for WSL, plugin and detect agents), so sync,
  the read view, market, instructions, skills and found servers all
  drop it at their one upstream.
- Takes() refuses a gone agent by name, so `library mcp add ...
  agents=hermes` says "Hermes Agent's CLI isn't installed here; nothing
  reads its MCP servers until it is installed again" instead of "every
  agent already has it".
- The guards that must still see a gone agent's files (projects'
  notGlobal for skills and MCP, instructions' own-file check) read
  everyTarget(), so a set kept in the agent's own file is still refused.
- rtk: a gone agent isn't offered rtk; one that still has the hook is
  listed so the hook can be taken out.
- Nothing a user wrote is removed: sync acts per target, so a gone
  agent's skills, servers and AGENTS.md stay as they are, and the client
  keeps agent ids it doesn't show.

Run:
- Sandbox HOME, real binaries: old wrote mcp_servers into a gone
  ~/.hermes/config.yaml; new refuses with the message above, exit 1.
- New tests TestTargetsLeaveGoneAgentsOut, TestGoneAgentKeepsWhatItHas,
  TestRTKLeavesGoneAgentsOut; each broken by hand (Targets check,
  Takes refusal, everyTarget in instructions, rtk gate) goes red.
- go test -tags nogui ./internal/library ./internal/tui ./internal/cli
  ./internal/gui: ok. Fixtures that relied on a gone CLI now place one
  (holdCLI, TestRTKHermesHome, TestRTKOffPath), and so do profile's
  and davsync's sandboxes, whose library syncs to claude and codex
  (TestOldProfiles, TestProfileCarriesLibrary, TestSyncLibrary went red
  in the full run without them).
- gofmt -l clean; go vet -tags nogui darwin/linux/windows clean.
- go test -tags nogui -p 4 ./... at the pushed head: see the last
  commit of this push.

Not tried: the real GUI with an uninstalled agent on a live machine.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-15 06:07:43 +08:00
yetone 8e8316ed2f provider, gui: a routing group's pickers offer OpenRouter's decision models only as the provider's picks say (coeo91 on Discord)
coeo91 picked two free OpenRouter models, and a new routing group's member
picker showed those two and then a run of others. Those were OpenRouter's
decision models (liquid/d1, pplx-decider, jev-latest and the rest of its
output_modalities=decisions list): Deciders() took decideModels() for a
provider that lists its decisions (OpenRouter, oMLX, MLX-Serve), Bailian,
a remote magpie or a plugin, whatever its picks, while the provider editor
draws the same models as unpicked chips.

OfferedDeciders is what a group's pickers offer: with picks saved, only
the picked decision models plus any a group already names as a member or
classifier (so a group made before reads the same); with no picks, every
one, as before. /api/groups' deciders (member and classifier pickers),
the templates and the TUI's member picker use it. Deciders() is
unchanged, so the gateway still lists every decision model to a remote
magpie (X-Magpie-Deciders) and RouteDecider still answers an unpicked one.
docs/subsystems/providers-accounts.md says which is which.

Run in a private GOCACHE and sandbox HOME:
- the new TestOpenRouterDecidersOfferedAsPicked passes; with the pick
  filter turned off by hand it fails ("chat models picked, offered:
  [pplx-decider-v1-27b liquid/d1 jev-latest]").
- go test ./internal/provider -run 'Decide|Decider|OpenRouter|Template|
  RemoteMagpie|Bailian|OMLX|Omlx|MLX': ok.
- go test -tags nogui ./...: every package ok except internal/library,
  which hit the 10m timeout with the machine at load ~150 (stacks in
  mcpauth flow.end sleeps; nothing here touches library). Rerun alone
  at the same load with -timeout 25m: ok in 252s, 285 tests passed, the
  slowest TestAgentMCPFiles at 33s, so the 10m was the whole suite's
  load on this box, not a hang.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows;
  GOOS=linux -tags nogui and GOOS=windows builds.

After rebasing on origin/main 924f62e90: provider, gui, tui ok; gateway
ok alone with -timeout 28m in 1129s at load ~100 (it hit the 10m default
beside the other three packages; it passed in the full run before).

Not run: the Playwright GUI suite. internal/gui/assets is unchanged and
those tests mock /api/groups, so they can't see this server-side list.
Not tried against the real OpenRouter API or in a running GUI; the fake
OpenRouter serves its real decision-list shape.
2026-10-15 02:00:44 +08:00
ggbdpq 05107bf03e tui: the library page keeps the row picked in view, however many section heads the window holds
What changed: viewLibrary sized its window from the row picked down in
rows (`start = lrow - visible + 3`), but the loop it feeds spends the
same budget in lines: every section head it crosses takes a line and
the blank before it, two the row count never paid for. With two or
more heads between the window's start and the row picked (servers,
then skills, then those found in the agents — a handful of each on a
terminal some thirty lines tall), the loop stopped above the row
picked: the highlight vanished, and j and down did nothing the screen
could see until the row count brought it back. The window now starts
where the lines to the row picked still fit, counted the way the loop
spends them.

Run: go test -tags nogui -count=1 ./internal/tui/ (the new
TestLibraryViewKeepsTheRowPicked is red without the change, watched on
a36319d6); gofmt -l internal/tui; go vet ./internal/tui/

Review (yetone, #2220): read line by line and kept as written. The
window's start is now counted in the lines the render loop spends, a
head and its blank line included, so it can't stop above the row
picked.

Run at the reviewed head, on origin/main 2a99e7a42, and
again on 91b9065a5 for vet, gui, provider, tui, gateway, agent and
the tests named here:
TestLibraryViewKeepsTheRowPicked is red with main's library.go ("row
21 (skill-10) picked, but the view stops short of it") and green with
the patch; go test -tags nogui ./internal/tui/ ok; gofmt -l, go vet on
three OSes, go test -tags nogui -count=1 -p 4 ./... at a machine load
of 100-150: 50 packages ok; internal/agent and internal/gateway ran past the 10m
default under that load and pass with -timeout 40m (674s, 798s);
internal/gui's TestSetAnswersWhileDevinAndProvidersHang failed once
(a state took 10.4s; open as #1375) and the package passes rerun.
Not tried: a real terminal; the test renders viewLibrary at 30 lines.
2026-10-15 01:56:35 +08:00
yetone d0fcb8bcdf agent: an agent uninstalled with its folder left behind shows "CLI not found" with no live settings, Hermes and the shared-folder agents too (#2177, mengyianx; #2173, SkyTodInfi)
Detection goes by an agent's folder, and an uninstall leaves the folder
behind. Before this commit, Hermes with only its 37-byte
~/.hermes/config.yaml (custom_providers: [], mcp_servers: {}) was listed as
installed in `magpie ls`, the GUI and the TUI, with model and effort pickers
that no program reads. CLIMissing (#843) covered only agents that have an
install command and their own folder. Hermes and the agents whose folder
something else keeps too (claude, codex, cline, opencode, goose) were never
gone.

What changes:
- internal/agent/gone.go adds cliHeld, which asks whether anything here still
  reads the folder:
  - the CLI on PATH or in proc.FindTool's folders (for goose, a binary that
    isn't pressly's Go goose);
  - its desktop app (HasApp) or sign;
  - the vendor installer's own place: ~/.claude/local, ~/.opencode/bin,
    ~/.codex/packages/standalone, Hermes' <home>/hermes-agent checkout;
  - for the shared folders, an editor extension under
    ~/.<editor>/extensions (anthropic.claude-code, openai.chatgpt,
    saoudrizwan.claude-dev), Claude.app or Claude Desktop, OpenCode.app or
    Goose.app on a Mac, a JetBrains IDE's settings (its agents bring their
    own program) or Zed's external_agents.
  When magpie can't tell, the agent is never gone. That covers OpenCode and
  Goose off a Mac, Gemini (its folder is Antigravity's and Code Assist's
  too), agents with their own detect, and WSL and plugin agents. It also
  covers Bin agents with no install command, except Hermes (cliOnly), since
  their installers' paths aren't verified.
- GUI: a gone row shows "CLI not found" and none of its settings, and the
  tag's tip says why. It offers no Apply again. While it is still wired it
  keeps its switch and Disconnect. Once it isn't wired it folds under Not
  set up, and Get started doesn't offer it (connectKind is "no"; the sandbox
  run showed Hermes offered there before). The panel shows the words only.
  The new tip is translated into zh, zh-TW, ja and de.
- The TUI leaves the agent out. `magpie ls` says "CLI not found" beside its
  path.
- docs/subsystems/agent-wiring.md describes all of the above.
- aside-native.test.cjs drops cliMissing from an Aside fixture. That state
  can't happen (Aside has no install command and isn't in cliOnly), and
  that test is about runtime_unavailable.

What was run:
- Sandbox HOME holding only the reporter's ~/.hermes/config.yaml (37 bytes)
  and a bare ~/.codex, with env -i and PATH=/usr/bin:/bin:
  - `magpie ls` at base 331c27703 lists "Hermes Agent — · effort —".
  - The fix lists "Hermes Agent  CLI not found  ~/.hermes/config.yaml".
  - Codex stays listed, because this Mac has ChatGPT.app's Codex (HasApp),
    so a really installed agent is kept.
- `magpie web` from the same sandbox, screenshot in Chromium: the Hermes row
  shows "CLI not found" and no pickers. That run found Get started still
  offering Hermes, which this commit fixes.
- go test ./internal/agent (2255s under load ~250 on 14 cores) and
  ./internal/cli and ./internal/tui pass. ./internal/gui fails only
  TestMainWindowCorners/macOS_26_SDK, killed at its 40s deadline under the
  same load. That is #1936; it has nothing from this change in its path, and
  it passed on base once and failed on it twice.
- GUI in Chromium and WebKit:
  - agent-cli-missing.test.cjs covers 5 languages, widths 1100 and 420, and
    the panel.
  - getting-started.test.cjs adds a gone Hermes to the fixture; the chips
    stay codex, claude and opencode.
  - Also run: i18n-keys, aside-native, agent-*, panel-* and click-scroll.
- gofmt -l is clean. go vet passes on darwin, linux (-tags nogui) and
  windows for the touched packages.

Broken by hand, and the tests went red each time:
- Dropping the openai.chatgpt check made TestCLIMissingSharedFolders' codex
  case red.
- Dropping the hermes-agent case made TestCLIMissingHermes red.
- Dropping the GUI gone branch, or the agentUsed change ("the one not
  connected stayed up"), made agent-cli-missing red.
- Dropping connectKind's cliMissing line made getting-started red
  (30 of 60 failed: chips gained hermes).

Not covered:
- library.Targets (Skills/MCP) still lists a gone agent as a place to give
  skills to.
2026-10-14 22:50:46 +08:00