Commit Graph
1476 Commits
Author SHA1 Message Date
yetone 88a0262bf2 claudetui: Claude Code's first-run notes send the run to -p at once, not after 45s
A config folder whose onboarding isn't done (one only -p was run in,
given CLAUDE_CODE_OAUTH_TOKEN) has the interactive mode show "Security
notes: … Press Enter to continue". The helper knew the sign-in screen
but not this one, so it waited out ReadyWait (45s) before running -p.
Now firstRun is matched like signIn: the run is -p at once and the
start is marked broken. Agreeing to the notes is left to the user.

The match is on the screen's words with any space between them one
(strings.Fields): the real 2.1.316 screen didn't match a plain regexp,
since Claude Code draws some spaces by moving the cursor.

Run:
- mote: go test ./internal/claudetui -count=1 ok; go vet for darwin,
  windows, linux; gofmt clean.
- Broken by hand: with the case off, TestShimFallsBackToPrint/first-run
  notes goes red ("wrote 0 lines of 1 in 30s").
- Real, on xiaomi-gpu (Windows 11), Claude Code 2.1.316 (official dist,
  sha256 checked), a real subscription token, a fresh config folder:
  before, "showed no prompt in 45s" and -p at 48s; with the first regexp
  still 45s (the space case above); now "shows its first-run notes" and
  the -p answer at 7.9s and 16.9s (two runs), streamed.

Not tried: WSL with a fresh folder (same helper code path); macOS/Linux
native with a fresh folder.
2026-11-01 01:43:35 +08:00
yetone 645eb92f3f gateway: a refusal after shown thinking goes to the next fallback
yhwangl on X: a request whose content trips a vendor's safety filter
after the model streamed its thinking, before any answer, stopped there;
the group's next member was never asked, as it is when credit runs out.

When a model's reasoning is shown, a try passes on its first thinking
event, so a refusal after it was the agent's. Now, for a streamed
Anthropic, Chat or Responses request with another member still to ask
(handsOver), the try's events go out one by one (passOver) and a refusal
or refusal error before any text or tool call hands the request on
(handOver): Anthropic's open blocks are closed and the next member's
stream is spliced into the same reply (spliceAfter): its message_start
or response.created/in_progress/queued are dropped, block indexes or
output_index go after those sent, sequence_number goes on. Chat chunks
go as they come. Once text or a call has gone, a refusal stays the
agent's as before. With no other member nothing changes. A refusal is
about the request, so nobody is rested for it.

Zhipu's finish_reason "sensitive" and error 1301 (敏感), DashScope's
data_inspection_failed and Volcengine Ark's *SensitiveContentDetected
are now read as refusals too.

Not covered (#4604): Gemini clients; a Responses reasoning item handed
over gets no output_item.done and the next completed lists only its own
output; A's thinking signature stays in the reply; non-streamed requests.

Run (mote, worktree at base 3baf3b6df):
- go test -count=1 -timeout 45m ./internal/gateway/...: ok (597s)
- targeted -run 'TestRefusal|TestSensitive|TestThinking|TestDeepSeek|
  TestStreamEvent|TestHighRisk|Refus': ok
- gofmt -l internal/: clean; go vet ./internal/gateway; GOOS=linux go vet
  -tags nogui ./...; GOOS=windows go vet ./...: ok
Rebased on 8a410f35a (5 commits, Claude TUI files in internal/gateway):
go vet ./internal/gateway and the targeted run plus ClaudeTUI|
ClaudeSubscription tests ok at the pushed head.
Broken by hand: handsOver forced to false (the old behaviour):
TestRefusalAfterShownThinkingGoesToTheNext (every upstream x client
subtest: b never asked), TestRefusalHandedOverTwice and
TestDeepSeekRefusalHoldsATrustedMemberAgain red; reverted.
Not tried: a real GLM, DashScope or Ark account tripping its filter, and
a real Claude Code or Codex client reading the spliced stream; the tests
use fake upstreams with GLM's, DeepSeek's and Anthropic's event shapes.
2026-11-01 00:40:07 +08:00
yetone 8a410f35a2 claudetui: Claude Code's interactive mode streams its replies, through a preload that copies the main turn's stream
The owner: make a Claude subscription stream as it goes while Claude
Code runs in its interactive mode (TUI), on macOS, Windows and WSL.
Until now the helper read Claude Code's transcript, which has a message
only once it ends, so a reply came to the client whole.

Claude Code is a Bun program, and Bun loads a script named in
BUN_OPTIONS (--preload) before it. The helper writes tap.js to a folder
of its own and starts Claude Code with BUN_OPTIONS="--preload tap.js"
(after the user's own BUN_OPTIONS, but not a Windows one's for a Claude
Code in WSL, where both go through WSLENV). tap.js makes Bun.FetchSession
a subclass whose fetch is the real one's, so the request, its headers,
its connection and TLS are Claude Code's own. For a reply to a
request marked x-claude-code-request-class: main to /v1/messages that
is text/event-stream, it tees the body: Claude Code reads its copy as
before, and tap.js writes each event, as it comes, as a JSON line to
the file MAGPIE_CLAUDE_TAP names. It takes itself out of BUN_OPTIONS,
execArgv and the environment first, so nothing Claude Code runs
inherits it.

The helper reads that file and tells the events as -p's stream_event
lines, so the gateway reads them as it reads -p's. A transcript message
waits up to 1s for its stream to begin (then it's told whole, its late
stream left out); a turn's end waits for its streams to end; a stream
cut short ends with a message_stop and no message_delta, as -p ends
one. The bridge now keeps the streamed messages by id, since a whole
message can come during the next message's stream, and a client
tool_use shown from the stream isn't told again from the whole message.

On Windows, BUN_OPTIONS has no quoting, so a temp path with a space
takes its short name; one that still has whitespace gets no tap, and
replies come whole, as they do from a Claude Code that isn't Bun or
doesn't send through FetchSession (2.1.281 on Windows doesn't; 2.1.289
and 2.1.316 do).

Run:
- gofmt -l: clean. go vet on mote for darwin, GOOS=linux and
  GOOS=windows: 0.
- go test ./internal/claudetui ./internal/gateway on mote
  (-timeout 45m): ok, ok (gateway 654s).
- go test ./internal/claudetui with win-run (Windows 11) and wsl-run
  (magpie-desktop): ok, ok.
- macOS, real account (Claude Code 2.1.316, sandbox HOME, keychain
  token): a reply came as message_start, text deltas,
  content_block_stop, message_delta, message_stop, then the whole
  message, then the result; stderr clean, the tap's folder removed.
- Windows native, Claude Code 2.1.316 against a fake that sends an SSE
  event every 250ms (a user preload marking the request main, which
  also checks the user's BUN_OPTIONS is kept): the deltas came 250ms
  apart, before the whole message. The same with TEMP holding a space
  (short name).
- WSL magpie-desktop, Claude Code 2.1.289 run through wsl.exe from the
  Windows helper, the fake in WSL: the same.
- The scrub, on macOS and Windows: Claude Code's BUN_OPTIONS and
  execArgv have no tap, MAGPIE_CLAUDE_TAP is gone, --smol is kept.
- Rebased on origin/main 02ff0e908 (no file in common): on mote, vet
  for darwin, windows and linux nogui 0; go test ./internal/claudetui
  ok; -run 'CoreScriptBudget|I18n|Claude|Budget' ./internal/gui ok;
  -run Claude ./internal/gateway ok. In WSL claude-mode, account-weight,
  old-webkit and i18n-keys: 59 of 60, the one red i18n-keys' "Unmarked"
  (#4524).

Broken by hand: the told mark removed, TestClaudeTUIStreamedCallToldOnce
went red; streamed kept as the last id only, TestClaudeTUILateRowOfStreamed
went red; before() made a no-op, and settle's end loop removed, the tap
tests went red. Each was put back.

TestTapMessageWaitsForItsStream failed now and then on mote: the whole
message can be told once its stream has begun, before the rest of the
stream is read. It now checks what is promised: the stream begins
before the message, every event is told, and the result comes last
(-count=30 ok).

Not tried: a real account on Windows or in WSL (the keychain token
went missing mid-session; those runs used the fake, whose request
carries no x-claude-code-request-class since a custom base URL drops
it); a real turn of several messages with the client's tools; Claude
Code 2.1.281 on Windows, which doesn't stream and is told whole as
before.
2026-11-01 00:37:29 +08:00
yetone 535371c8f3 providers: a Claude subscription says whether it runs as Claude Code's interactive mode or claude -p, and why
The owner: the Claude Code provider page should say whether its runs go
through the TUI or the CLI, and what tells them apart and what each gains.

Under a Claude subscription's accounts a row now says "Running as
Claude Code's interactive mode (TUI)" (a green dot) or "Running as
claude -p (CLI)" with why: turned off in Settings, failed to start lately, Claude
Code in WSL whose home wasn't found, not installed, or a system with no
interactive mode. Under the TUI it says which requests still run as -p
(safeguards, a JSON schema, an image by URL, a first message over
400KB). "TUI or -p?" opens what each is: entrypoint cli, the plan
counting a request at about half; entrypoint sdk-cli, about twice.
"Change in Settings" opens Settings › Models at the interactive mode's
row. Only switch, which serves nothing, shows no row.

The mode comes from GET /api/claude/mode (gateway.ClaudeModeNow), read
as the editor opens and kept 30s, never in /api/providers' polls. Its
machine-wide reasons are claudeMachineWhy, which claudePrintWhy now
calls first, so the row and the gateway's own choice can't disagree.
The row is drawn by claudemode.js, which app.js loads with that first
read, so it weighs nothing on the core: after a rebase on origin/main
29d0ab39f the core was 1,541,482 bytes, over its 1,539,856, and the
budget isn't raised. "Runs as" became "Running as" so its keys don't
clash with a plugin's "Runs as" in i18n-keys.
A per-account WSL folder the probe can't read is still found only at
run time; the doc says so.

Run:
- go vet ./internal/gateway ./internal/gui (darwin), GOOS=windows, and
  GOOS=linux -tags nogui: 0.
- go test -run 'ClaudeTUI|ClaudeMachine|ClaudeSub' ./internal/gateway:
  ok (TestClaudeMachineWhy is new).
- After the rebase on 29d0ab39f, on mote: go test -run
  'CoreScriptBudget|I18n|Claude' ./internal/gui ok, the budget not
  raised; old-webkit.test.cjs lists claudemode.js with the other
  scripts app.js imports. Before the rebase, go test ./internal/gui: three reds that fail the
  same on origin/main ccc791231: TestSettingsSaveKeepsWhatItDoesNotSend
  (#4514), TestMainWindowCorners (#3949), and i18n-keys' "Unmarked"
  (#4524).
- claude-mode.test.cjs in WSL (Chromium and WebKit, 1100 and 420, en,
  zh, ja, de): 48 of 48.
- The full GUI suite on mote (load ~30) had 301 reds in 49 files; each
  of those files was run again in WSL at this head (743 tests, 259 red)
  and at origin/main ccc791231 (259 red, the same tests; #4600). The
  one that held apart was account-weight at de web 390: the row puts
  the accounts a screen above By weight on a phone, and Playwright's
  click scrolled the chip back into view. The test now brings the chip
  into view before it measures, so it judges the click's own scrolling;
  account-weight and claude-mode, both engines: 50 of 50.
- After moving the row into claudemode.js: the 142 GUI files with a
  Claude Code agent, in WSL (Chromium and WebKit): 1392 tests, 8 WebKit
  reds in 7 files. Each of those files was run again alone at this head
  and at 29d0ab39f: the same kind of WebKit reds on both, which
  subtests changing from run to run (library-items, number-units,
  routing-rule-models, usage-heatmap, usage-ledger-chart). phone-rows'
  Routing click on .rt-day failed 1 of 4 runs at each (WebKit zh, ja,
  de); the Routing page draws no such row. Filed under #4600, #4471,
  #4112.
- Real use on xiaomi-gpu (Windows 11, sandbox HOME, Claude Code in WSL
  magpie-desktop): /api/claude/mode said {"tui":true,"wsl":true}; with
  the setting turned off through POST /api/settings,
  {"tui":false,"why":"off","wsl":true}; set back, TUI again.
- Rebased on origin/main 02ff0e908 (no file in common): on mote, vet
  for darwin, windows and linux nogui 0; go test ./internal/claudetui
  ok; -run 'CoreScriptBudget|I18n|Claude|Budget' ./internal/gui ok;
  -run Claude ./internal/gateway ok. In WSL claude-mode, account-weight,
  old-webkit and i18n-keys: 59 of 60, the one red i18n-keys' "Unmarked"
  (#4524).

Broken by hand: the editor draws twice before the read returns, and the
test's one-read check went red with two reads until the read in flight
was shared (claudeModeRead).
account-weight's check went red ("en 1000: a click scrolled") with the
chip's click made to scroll the editor 120px.

Not tried: the window on macOS with a real account (the row is the
same code as the web GUI's), and the "broken" reason with a real
failed start.
2026-11-01 00:37:29 +08:00
yetone 2cca111764 gateway: a 413 byte cap or an overflow tells Codex context_length_exceeded, so it compacts instead of reconnecting 5/5 (celestial_eagle_99230 on Discord)
A Codex user on a DeepSeek model kept getting "stream disconnected
before completion: 1017dp: 413 Request Entity Too Large: a web page,
not an API reply ... (request_too_large)" with "reconnecting 5/5".
The big body took the vendor past keepHeldAfter, so Codex's stream
had begun, and streamError sent response.failed with code
server_error. Codex (codex-api sse/responses_error.rs) reads any code
it doesn't know as Retryable, so it sent the same body five more
times. Each was refused the same way, and nothing compacted.
context_length_exceeded is the one code Codex stops on: it marks the
window full and compacts, and core compact.rs trims the oldest items
for as long as the compaction is refused too.

- streamError: a 413 on the Responses shape is code
  context_length_exceeded, for every Responses client. The text still
  says request_too_large for pi.
- failTo: Codex reads a 413 told by HTTP status as UnexpectedStatus,
  and a 400 context_length_exceeded as InvalidRequest
  (api_bridge.rs). Neither compacts. So when Codex (fromCodex, or
  Claude Code's Codex plugin) asked for a stream, a byte cap or an
  overflow goes to it in a stream even before one began
  (keptAlive.compactsInStream). A vendor's own overflow, released
  until now, goes this way too. Other clients keep the status they got
  before.
- Nothing changes for resting: a 413 still rests nobody, and a group
  still tries the next member first.

Tests: codex_byte_cap_test.go. It replays the reporter's nginx page
mid-stream and before the stream, plus a vendor overflow 400, and
checks a non-Codex client keeps its 413. Red on the old code:
TestCodexByteCapInStreamCompacts got "server_error" (the reporter's
exact text), and both TestCodexByteCapBeforeStreamCompacts cases got
a 413 or 400 JSON. TestStreamErrorByteCapInEveryShape now expects
context_length_exceeded for Responses.

Run on mote (mote-run, this tree): go test ./internal/gateway on the
byte-cap, stream-error, overflow, compact and Codex tests: ok. GOOS=linux
and GOOS=windows go vet ./internal/gateway: ok. gofmt -l: clean.
Full suite: mote-run go test -timeout 45m ./... at fb29cd30f plus this
change (before the gateway-routing.md paragraph, docs only): 82 packages
ok; internal/gui red in two tests this change doesn't reach, both filed:
TestSettingsSaveKeepsWhatItDoesNotSend (SearchAll not kept, #4514) and
TestMainWindowCorners/macOS_26_SDK (macOS 27 toolbar, #3949).

Not tried: a real Codex against a real 413 vendor. Codex's handling
was read from openai/codex main, not run. DeepSeek documents no
request-body byte limit, and whether 1017dp is DeepSeek's own API or
a relay in front of it is unknown.
2026-10-31 22:57:37 +08:00
yetone c30d3b7b63 plugin pages: a page the reader left is told, and let go after 10 minutes unless it keeps itself
A plugin's page kept its frame, with its scripts, timers and
connections, for as long as the window was open once it had been
looked at: show() only hid its view, and a frame in a hidden view isn't
hidden to itself (its visibilityState doesn't change), so a page
couldn't even pause on its own. Asked by the owner: is that by design?
Only the lazy first load was.

- The kernel's leave hook now reaches the page part: the page is told
  {event: "visibility", data: {visible}} as the reader leaves and comes
  back. The bridge has magpie.visible and magpie.onVisibility(fn); hello
  carries visible, for a page left before it said hello.
- A page left 10 minutes (IDLE_MS) has its frame removed and loads again
  when next opened. Back sooner, it is the same frame. Its hello timer is
  cleared, so nothing says it broke.
- magpie.page.keepAlive: true (plugin.PageSpec.KeepAlive, keepAlive in
  /api/plugin-pages) keeps a page however long, for one that works while
  no one looks at it. Anything but true is false, read as raw JSON so a
  wrong type never drops the package's page.
- plugin-runtime.md's page row says so.

Run on mote. The Go suite and most GUI files ran at this change on
557f51dbf. After rebasing onto 30cd39f19 (none of these files changed
upstream), the budgets, TestWindow* and the page GUI files ran again
at this tree:
- plugin-page-idle (new), plugin-page and plugin-panels, chromium and
  webkit: 14/14 at 557f51dbf. At the rebased tree, the first run was
  13/14: plugin-page's chromium "draws in its frame, shut in" was red
  once, and its assertion wasn't kept (#4589). After that: 42/42 over
  3 runs, then 16/16 chromium over 4.
- i18n-keys, plugin-actions, plugin-kinds-discover, plugin-kernel,
  plugin-replaced, plugin-proxy-page: 51/52. The red is i18n-keys'
  "Unmarked", the same on origin/main e0eb74987 (#4524).
- go test -timeout 45m ./...: every package ok except three reds, none in
  code touched here:
  - TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
    TestMainWindowCorners (#3949) fail the same on origin/main e0eb74987.
  - TestUnroutedHeldReportSaved (#4300) failed in the full run only.
    Alone, -count=5, it passes.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., go build ./..., gofmt -l: clean.

Broken by hand: with the leave hook taken out of the page part, the new
test is red in both engines.

Not tried: a real plugin page in the desktop app or WebKitGTK. The
IDLE_MS length (10 minutes) is a judgement, not measured.
2026-10-31 22:39:37 +08:00
yetone fb29cd30f9 tray: the Mac's menu bar figures are regular weight, a lone one in the menu bar's own font (qingnianxiaozhe on X)
Beside Surge's speeds and another app's stacked "0 KB/s", magpie's
"93% / 98%" read visibly bolder, and a lone "98%" too small and too
heavy, so the reporter kept it out of the menu bar. mpRowFont drew two
stacked rows in 9.5pt semibold and one row in 11pt medium, both since
ef4edf8c5 (the first drawn image, no owner call on the weight). Now:

- two rows: monospacedDigitSystemFont 10pt regular (was 9.5pt
  semibold); row gap unchanged (3.5pt), the block 17.6pt as Surge's;
- one row: monospacedDigitSystemFont at menuBarFont(0)'s size (13pt
  on macOS 27, was 11pt), regular (was medium);
- the letter-in-a-ring stand-in for a logo, the template tint and the
  light/dark colours are unchanged. Linux shows the figures as the
  tray's text label (the panel's font) and Windows' tray shows none,
  so neither has a font to change.

Measured in the reporter's q1: magpie's digits were Surge's height
(13px) with stems 1.30x as wide (2.80 vs 2.16px). Rendered at 2x the
stems go 2.47 -> 2.04px for two rows (medium was 2.14; regular is the
closer of the two to Surge and the other app).

TestTrayRowFont (new): two rows 9.5-10.5pt, weight trait <= medium,
digits of one width; one row the menu bar font's size, weight 0, one
width. Red on the old fonts by hand (9.5pt weight 0.30; 11pt weight
0.23 vs the menu bar's 13pt). gui-shell.md says the new sizes.

Run on mote at the pushed head (rebased on origin/main), through
mote-run: gofmt -l internal/gui (empty); go vet ./internal/gui/;
GOOS=linux go vet -tags nogui, GOOS=windows go vet (with and without
nogui) ./internal/gui/; go test -count=1 ./internal/gui/ and with
-tags nogui: all pass but TestSettingsSaveKeepsWhatItDoesNotSend
(#4514, SearchAll) and TestMainWindowCorners/macOS_26_SDK (#3949,
macOS 27), both filed and red on origin/main too; the nogui run also
met TestColdTurnsTaken (#4510, the turn warm-up's race: 1 of 5 red
alone, then a hang to the timeout, at load ~35). Every TestTray* test
passes, run again alone with -v.

Compared visually: a throwaway test rendered the image through
trayImagePNG at 24pt 2x, light and dark, before and after, for two
rows and one, plain and beside a logo, and a mixed pair; laid beside
the reporter's crop of Surge's figures.

Not tried: the live menu bar beside Surge and iStat Menus (no real
app run; renders only), a non-Retina screen, and the full Go suite
and GUI suite (the change is AppKit drawing in one package).
2026-10-31 22:29:48 +08:00
yetone 557f51dbf0 library: a skill linked into an app version the update deleted follows it to the current one (tjhhhh on Discord)
tjhhhh: ego lite keeps its skills in its framework's Versions/<v>. After
the app updated, the skill was in the new version's folder, the old folder
was gone, and magpie still linked the old one. dccfefdf7 (#2635) linked new
imports through the app's own steady link (~/.local/share/ego/ego-skills, or
Versions/Current), but a skill brought in before then links straight to the
resolved Versions/<old> path. tjhhhh's case is that old link: an import
made since dccfefdf7 already follows the update
(TestImportedSkillFollowsAppUpdate).

followMovedSkills (skill_moved.go) runs on every read of the Library page,
under the read's link memo, which is restarted when a link is mended. It
also runs as the first step of every sync. For each library skill that is
a link:
- Target gone, and its first missing part named like a version: link the
  same place under the folder's Current/current/latest link. With no such
  link, use the highest version beside it that has a SKILL.md there
  (1.10 after 1.9).
- Target in Versions/<v> while the bundle's Versions/Current links to
  another version with the same skill: link it through Current.
Source.Dir follows. Only the link is replaced (os.Remove of the link, then
dirLink, and the old link is put back if the new one can't be made). A
folder of the library's own, a link the user deleted that isn't a version
(still shown missing), and the app's old version folder are left alone.
docs/subsystems/library.md says so.

Run (all on mote via mote-run):
- New tests on ego lite's real layout (egoLite: framework Versions/<v>,
  Current, ~/.local/share/ego links): TestOldImportFollowsDeletedVersion
  (0.5.1.13 deleted, then 0.6.0.12, then the next update to 0.7.0.1 by
  itself, plus the agents' link through the library),
  TestOldImportFollowsVersionsCurrent (old kept, through Sync()),
  TestOldImportFollowsHighestVersion, TestMovedSkillsLeaveTheRest and
  TestVersionLess. All pass, as do dccfefdf7's three tests.
- Broken by hand: with followMovedSkills returning false at once, the
  three OldImport tests are red.
- go vet -tags nogui ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: clean. gofmt -l: nothing.
- Full go test -tags nogui -count=1 -timeout 45m ./... in a sandbox HOME:
  80 ok, 3 FAIL.
  - internal/library TestReadLooksAtEachFolderOnce was mine: the mend ran
    before the read's memo, so each skill link was looked at twice. Fixed
    (the memo starts first and restarts after a mend). The whole
    internal/library package then passed (75s).
  - internal/gui TestSettingsSaveKeepsWhatItDoesNotSend is red on
    origin/main 3ecc02b78 and ccc791231 alike (#4514, SearchAll).
  - internal/cli TestAgentFieldNameShowsIt failed once under load. It
    passes alone and in a whole internal/cli run, and its message was lost
    to my grep of the log (#4583).
  The full ./... was not run again after the memo fix.
- At the pushed head, rebased on a51776f9c (which changed internal/library
  too): go vet and the whole internal/library package ok (95s).

Not tried: tjhhhh's own machine and ego lite's real update (the layout is
the #2635 fixture, built from iomect's report). Windows junctions to a
deleted version (dirLink is the same call ImportSkill uses). An app that
renames the folder above the version is not followed: it stays missing.
2026-10-31 22:01:45 +08:00
yetone 2cfb8351d0 install.sh: a Linux desktop without WebKitGTK 4.1 has it installed through sudo, then gets the desktop app (shuhai)
shuhai on Discord, on f68ddca37's hint: "为什么不能帮用户直接装好?" On a
desktop without WebKitGTK 4.1 the installer put in the terminal build and
told the user to `sudo apt install libwebkit2gtk-4.1-0` and run it again.

Now, on a desktop without the libraries (and with --gui), when someone is
at the terminal, the script installs WebKitGTK 4.1 (GTK 3 comes with it)
with the distribution's package manager, says first in one line what and
why, and installs the desktop app:
- apt-get install -y libwebkit2gtk-4.1-0 (Debian/Ubuntu family), and when
  that fails, apt-get update and once more (lists missing or stale);
- dnf install -y webkit2gtk4.1 (Fedora/RHEL family);
- pacman -S --needed --noconfirm webkit2gtk-4.1 (Arch family; no -Sy, so
  no partial upgrade);
- zypper --non-interactive install libwebkit2gtk-4_1-0 (openSUSE).
Through sudo, which asks for the password itself; as root, without it.
"At the terminal" is /dev/tty opening (in a subshell, since a failed
redirection would end the script): curl | sh gives the script the pipe
for stdin, so every package command reads /dev/tty too, never the script.
No terminal, no sudo, the package manager missing, Void/Gentoo/another
distribution, or the install failing: the terminal build and the command,
as before, with "didn't work (see above)" when it was tried. --tui and
MAGPIE_CLI=1 install no package; a headless computer neither.
MAGPIE_TTY points the check at another file for the tests.
Docs: reference.md Install, README en/zh, docs start (en/zh/ja).

Run:
- sh -n, dash -n; shellcheck -s sh: only SC2010 at the uninstall's
  ls | grep, there before.
- site/install.test.mjs, 5 new tests (fake sudo, id and package managers;
  every distro's command, root without sudo, no tty, no sudo on PATH,
  Void, NixOS, a failing install, apt's update-and-retry, --gui, --tui,
  MAGPIE_CLI, headless): red on origin/main's install.sh (the 5 new fail,
  19 pass), green after. CI's site step (sh -n + node --test
  site/*.test.mjs) at this head, rebased on origin/main: 63/63 on mote
  (macOS sh) and 63/63 on magpie-desktop through wsl-run (/bin/sh = dash).
- Real installs in fresh containers (Docker on xiaomi-gpu, amd64), a user
  u with sudo, DISPLAY=:0, `cat install.sh | sh` (stdin a pipe), the
  terminal kept with setpriv (su -c starts a session without one),
  v0.1.2399/2400 from the real feed; then ldd (nothing missing),
  `magpie version`, and the package query:
  - Debian 12, sudo with a password, typed by expect at sudo's prompt,
    package lists deleted first: install failed "Unable to locate", apt-get
    update, retry ok, desktop app, libwebkit2gtk-4.1-0 installed;
  - Ubuntu 24.04 (NOPASSWD): libwebkit2gtk-4.1-0, desktop app;
  - Fedora 44, password via expect: webkit2gtk4.1, desktop app;
  - Arch (archlinux:latest): webkit2gtk-4.1 2.54.2, desktop app;
  - openSUSE Tumbleweed and Leap 15.6: libwebkit2gtk-4_1-0, desktop app;
  - Debian 12 as root: apt-get without sudo, desktop app;
  - Ubuntu 24.04 --gui: installed, desktop app; --tui: terminal build,
    nothing installed;
  - Debian 12 without -t (no terminal): terminal build + the apt line, no
    install tried; without sudo at a terminal: the same;
  - Ubuntu 20.04 (no WebKitGTK 4.1 in focal): install, update, retry all
    fail "Unable to locate", then the terminal build and the "didn't work
    (see above)" hint.

Not tried: a real desktop VM (the containers fake one with DISPLAY=:0);
the installed app wasn't opened, only `magpie version`. Void and Gentoo
stay hint-only (Gentoo would build WebKit from source). Debian 11 failed
in the container's own setup (archives unreachable), so focal stood in
for a distribution without 4.1. A held dpkg lock (unattended-upgrades)
would fail the install and fall back; not reproduced. On focal the hint
still names libwebkit2gtk-4.1-0, which focal lacks, as before.
2026-10-31 21:52:54 +08:00
yetone 7d11f7d428 gui: Rex opens sessions in a Rex session of magpie's own, with none, one or several open (#4565, StringKe)
StringKe tried b9e5bc6cb with the real Rex (server 0.0.1793131181,
Rex Beta 0.1.0) on v0.1.2391: it opened only when Rex had exactly one
session. Outside Rex, `rex run` with no -s exits 3 both for no session
and for several ("session target default is ambiguous"), and exit 3
means not found or ambiguous; magpie then ran `rex new <t> --label <t>`,
and `rex new` has no --label (exit 2). run's --label also names the
block, not the tab, and the CLI can't tell which session the app shows.

Now magpie keeps a Rex session of its own, labelled magpie. openInRex
lists sessions with `rex ls --json` and takes the one labelled exactly
magpie (else magpie in another case), by its full ID since labels can be
shared. It runs `rex run -s <id> --label=<t> --json -- /bin/sh -c ...`
and names the new tab with `rex window rename -s <id> -- <window_id> <t>`
from run's JSON. With no such session, or a 3 from run because it ended
since the list, it runs `rex new magpie --window=<t> -- /bin/sh -c ...`,
whose first tab is so named. Labels go as --flag=value and the rename's
positionals after --, so a title starting with "-" stays a title. Exit 4
still says to open Rex. rexRun now gives stdout only (for the JSON), and
rex's stderr comes back through ExitError for the message.
docs/reference.md's Session terminal paragraph says it.

Every flag was checked against the real rex CLI, not the report: the
snapshot build 0.0.1793420730-g6d0d9a (rex-darwin-arm64.zip from
blob.superlogical.com, sha256 checked against the release API) on mote,
in a sandbox HOME and XDG_RUNTIME_DIR, where rex autostarts a server of
its own. `rex new --help`, `run --help`, `window rename --help`; by hand
with 0, 1, 2 sessions and two labelled magpie/MAGPIE: no -s exits 3
"not found: no sessions" with 0 and "ambiguous" with 2; `new --label`
exits 2; `run -s <full id>` works with any number; `-s magpie` with two
so labelled exits 3 ambiguous; `rex new magpie --window=<t>` names the
first tab; rename sets the tab's label.

Tests: TestOpenInRex runs a fake rex modelled on those answers (target
by full ID or any-case label, 3 for not found and ambiguous alike, 2 for
new --label) with no session, one other, two others, magpie's among two
and two labelled magpie, opening twice each: one magpie session made,
then used, both tabs named. Also a session that ends between ls and run,
exit 4 and exit 1. TestOpenInRexReal runs the same cases against the real
rex when MAGPIE_TEST_REX names one (skipped otherwise), with a server of
its own that it kills and stops at the end.
TestDiscoverTerminalsOffersRex uses the fake with two sessions.

Ran, through mote-run at this tree rebased on origin/main f85a221c9:
- MAGPIE_TEST_REX=<real rex> go test -count=1 ./internal/gui: every test
  ok, TestOpenInRexReal included, except TestSettingsSaveKeepsWhatItDoes-
  NotSend (#4514) and TestMainWindowCorners/macOS_26_SDK (#3949), both
  red the same run alone on a detached origin/main f85a221c9.
- gofmt -l; go vet ./internal/gui; GOOS=linux -tags nogui and
  GOOS=windows go vet ./internal/gui and go build .: ok.
- No rex server or /tmp/rx* left after the tests.

Broke by hand, each red, then restored: the old openInRex (run with no
-s, then new --label): every TestOpenInRex case, the discovery test and
TestOpenInRexReal red ("unknown flag: --label"); the session lookup made
to find none: a second magpie session each time, red in the fake and
the real test; the window rename left out: tabs "Window <id>", red in
both.

Not tried: the Rex app itself (its download needs a Discord sign-in),
so whether Rex.app switches to the magpie session when a tab is added
from outside is not seen; nor whether an autostarted CLI server could
differ from the app's when the app is closed. Not the full go test ./...
(only internal/gui changed), no GUI Playwright run (no JS changed), not
run on Linux or Windows.
2026-10-31 21:38:56 +08:00
yetone 73a12e8bf6 wsl: a distro's agent folder that is a link is opened where it leads (#4502)
On Windows, adding a skill or switching RTK on for an agent in WSL failed
with `mkdir \\wsl.localhost\<distro>\root\.codex: Cannot create a file
when that file already exists` (linusxiong). In the distro ~/.codex is a
link to /mnt/c/Users/<user>/.codex. Through \\wsl.localhost Windows can't
follow a link the distro has: a mkdir of it says it exists, and nothing
below it can be made, written, read or listed. ggbdpq found and explained
the link (thanks); their patch, which takes that EEXIST as "there", wasn't
used: the writes below the link fail next (its test passed because a
symlink here is followed).

The fix, for every agent folder and every writer through \\wsl.localhost:
- The WSL probe asks `readlink -f` in the distro where each agent folder,
  its skills folder and the folders beside them lead (wslLinkPaths ->
  distro.Links; a $HOME that is itself through a link is left alone), and
  which drive each Windows mount is (win:/mnt/c C: -> distro.Drives).
- distro.open opens a path at or below a link where it leads: on a Windows
  drive, the drive's own path (C:\Users\<user>\.codex); elsewhere in the
  distro, through \\wsl.localhost again. native spells it back through
  the link, so the agent is told its own path.
- A link readlink couldn't resolve is never guessed at: distro.open
  errors, and the agent is unreached (Agent.Unreached: its notice says
  why; every field Set and Sync returns it).
- Writers: the agents' own files (place.join/place.open, every
  filepath.Join(at.home, ...) in internal/agent), the library's WSL
  targets (wslOpen/wslOpened; one "wsl" problem per agent and nothing
  written), RTK (rtkAt, rtkInstall checks agent.WSLOpen before its mkdir),
  the Sessions page's WSL reads (sessions.WSLHome.Open) and the Copilot
  CLI sign-in read (provider.CopilotWSLHomes -> CopilotWSLDirs).
- Not changed: magpie's image MCP server opens arbitrary paths an agent
  in WSL gives it the same way; filed as #4578. Links deeper than the
  probed paths (other than <agent dir>/skills) aren't resolved. A distro
  probed by an older magpie has no Links until probed again (each run).

Run:
- Real Windows box (xiaomi-gpu, distro magpie-desktop, sandbox
  /tmp/x4502/home with .codex -> /mnt/c/Users/yeton/runs/x4502-target/.codex,
  .claude -> /tmp/x4502/data/claude, .pi -> a missing folder), a throwaway
  Windows test running the real probe with that HOME: probe said
  link:.codex /mnt/c/..., link:.claude /tmp/x4502/data/claude, link:.pi,
  win:/mnt/c C:, win:/mnt/d D:. The old way, MkdirAll(\\wsl.localhost\
  magpie-desktop\tmp\x4502\home\.codex\skills\pdf) = "Cannot create a file
  when that file already exists" (the report's error). distro.open wrote
  SKILL.md to C:\Users\yeton\runs\x4502-target\.codex\skills\pdf and to
  \\wsl.localhost\magpie-desktop\tmp\x4502\data\claude\skills\pdf, both
  read back with cat in the distro through the links; .pi said "~/.pi in
  WSL magpie-desktop is a link magpie couldn't follow". Sandbox and target
  removed after.
- New tests with a fake distro whose ~/.codex and ~/.claude are links to
  /mnt/c/... that don't exist here, so, as through \\wsl.localhost,
  nothing below them can be made: TestWSLFolderIsALinkToC,
  TestWSLFolderLinkUnresolved, TestRTKWSLFolderIsALink,
  TestRTKWSLFolderLinkUnresolved (library); TestWSLProbeLinks (runs the
  probe script), TestWSLOpenThroughLinks, TestWSLAgentFolderIsALink
  (config and a Claude session read on C:), TestWSLAgentFolderLinkUnresolved
  (agent).
- Broken by hand: the library tests on the base (with a no-op
  FakeWSLDrives) fail with "mkdir .../home/me/.codex: file exists", the
  report's error; with ggbdpq's patch applied they still fail (the skill
  mkdir, and RTK's hook not written).
- mote: go build ./...; go vet of agent, library, sessions, provider for
  darwin, GOOS=windows (and linux for agent, library); gofmt -l clean;
  go test -timeout 45m ./internal/agent ./internal/library
  ./internal/sessions ./internal/provider: all ok.
- Windows (win-run): the same four packages. The new tests pass (the
  RTK ones skip: the fake distro runs sh). 32 tests are red, all already
  red at the base c63c2136b run on the same box, and filed (#4115, #2808:
  Hermes profiles, Codex keychain, Agy, desktop entries, ...); the Hermes
  ones fail alike on base and branch with -count=3.

- Rebased on origin/main 3ecc02b78 (it changed internal/agent): at this
  head on mote, go build ./..., go vet of the four packages for darwin,
  windows and linux, gofmt -l, go test ./internal/agent ./internal/library:
  ok.

Not tried: the full ./... suite; the GUI (no GUI change; the unreached
notice uses the existing Notice); a real Codex/Claude Code run against
the moved files in the distro.
2026-10-31 21:29:22 +08:00
yetone 3ecc02b78b agent: Claude Desktop is off magpie only when Desktop itself would be (dev_quj on X)
dev_quj on X: "magpie 一直提示Claude Desktop不经过magpie,我重启了依然还是
这个提示" — the Agents row said "已不经过 magpie:配置已变更" while
Desktop ran on magpie.

The check required deploymentMode "3p" in both Claude/ and
Claude-3p/claude_desktop_config.json. Desktop decides otherwise (m4 in
4.4212's and 2.7032's index.pre.js): with a 3p configuration applied it
starts in 3p when the profile has disableDeploymentModeChooser, whatever
deploymentMode says, and otherwise unless Claude-3p's file says "1p". The
Claude folder's deploymentMode is never read. And Desktop 4.4212 deletes
Claude-3p's deploymentMode itself: a stored "1p" with no claude.ai sign-in
is dropped at start (W5r -> "[custom-3p] deploymentMode written { mode:
undefined }") and Desktop relaunches in 3p on magpie. So a file left
without the key, by Desktop or another tool, was called off magpie, and
nothing magpie could do (Reconnect writes "3p" back) kept Desktop from
dropping it again.

desktop3p now asks Desktop's question with the applied profile (magpie's
or the user's for magpie's gateway). The appliedId, address and key
checks are as they were. appReads (the "restart Desktop" notice) reads
the same effective mode instead of the two files' words, so Desktop's own
write at start isn't a change to restart for.

Real Claude Desktop 4.4212.0 (macOS zip, on mote, sandbox
--user-data-dir, never the live config): three starts with magpie's
profile applied and Claude/ {} or "3p"; Claude-3p "1p" + chooser
disabled, "1p" + chooser not set, and {} — each ran in 3p with
apiHost=http://127.0.0.1:3425 in Claude-3p's main.log, and each left
Claude-3p's file without deploymentMode. The "1p", chooser-not-set case
started in 1p, logged "deploymentMode written { mode: undefined }" and
came back in 3p. An earlier start with both files "3p" kept them.

Run at the pushed head on mote (mote busy with other sessions' GUI and
gateway suites, so the touched package only, not the full suite):
go test -count=1 -timeout 45m ./internal/agent: ok
go vet, GOOS=linux go vet, GOOS=windows go vet ./internal/agent: ok
gofmt -l internal/agent: clean

Broken by hand: desktop3p put back to the old rule (both files "3p"):
TestClaudeDesktopModeAsDesktopReadsIt red on the dropped key, the Claude
folder's key gone, "1p" with the chooser disabled, and none with the
chooser on; TestClaudeDesktopChangedSince red too. Green with the fix.
TestClaudeDesktopMSIX and TestClaudeDesktopChangedSince's 1p cases now
turn the chooser on first, as Desktop needs for 1p to count.

Not tried: Windows' Desktop (MSIX or classic) and a real gateway request
from Desktop; a signed-in claude.ai cookie (Desktop keeps "1p" then,
which magpie says only with the chooser on); dev_quj's own files, so
this is the class the report is in, not their proven trigger. No other
desktop agent reads a mode the same way; Codex/WorkBuddy checks unchanged.
2026-10-31 21:11:45 +08:00
yetone cac655c14f gateway: GET /v1/magpie/mcp lists magpie's own MCP servers that are on (ferock on Discord)
ferock on Discord: the community chat page's "use all of magpie's MCP
servers" gave a chat only the servers in library.json, never magpie's own
web search, image recognition or image generation. Nothing told an app
which of magpie's own servers are on, so the page couldn't add them.

GET /v1/magpie/mcp (OwnMCPPath, own_mcp.go) answers
{"servers":[{"name","title","path"}]} for the ones on now, each named
as its initialize names it: magpie-web-search while plugins/search serves
and something searches (canSearch), magpie-vision while a model sees
(seer: not Off), magpie-image while a model draws (drawer: not Off),
magpie-tools while plugins/tools serves and a plugin that is on gives a
tool (plugin.ToolsOn; a note that can't be read lists it). It holds no
secret, so a read-only gateway key may read it (readOnlyRoutes); it is
otherwise guarded as every /v1/magpie/* route is. It is in / "apis".
page-chat 0.1.7 (magpie-community/plugins) reads it in every route the
page takes its MCP list from (readMcp: the list, a chat's tools, a tool
call, the connection check). Documented in gateway-routing.md.

Run (mote, at e2a65cbc9 plus this change, before the rebase onto
2987f5e2b, which adds three commits in gateway/gui/provider that this
doesn't touch):
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- go test -tags nogui -timeout 45m ./... in a sandbox HOME: 81 packages
  ok; internal/gateway ok. Two reds, neither in code this touches, both
  filed: internal/gui TestSettingsSaveKeepsWhatItDoesNotSend (SearchAll,
  #4514) and internal/update TestRelaunchOpenTriedAgain (#3881).
  The first run, at d6e111638, also had TestReadOnlyKeyEveryRoute red on
  the new route; it is in readOnlyRoutes now.
- At the pushed head (on 2987f5e2b): go vet ./internal/gateway and
  -run 'OwnMCP|ReadOnlyKey|ClientPath|ServingGates' ok.
- TestOwnMCP* (5 tests) red on the old code by hand: the route taken
  out, each answers 404.
- Real binary (go build -tags nogui, sandbox HOME, MAGPIE_ADDR
  127.0.0.1:3591, a fake vendor listing gpt-image-1 and gpt-4o): the list
  was magpie-image; tools/list on its path answered generate_image,
  generate_video, generation_result; with vision and imageGen "off" in
  settings.json the list was empty; a request with a foreign Origin got
  403.

Not tried: image recognition and web search listed by the real binary
(the fake vendor's gpt-4o wasn't known to see offline, and no search API
was set up; the unit tests cover both); a real vendor; the GUI (no GUI
change); Windows and Linux runs (vet only).
2026-10-31 20:37:19 +08:00
yetone e2a65cbc9b dsh: a start on a found group's old id moves onto the id its route lists (zyh6036 on X)
zyh6036 on X: DeepSeek Harness Desktop showed no model after magpie
turned dsh on and the app restarted, while the profile's patch file was
full of magpie's gateway.

Cause: a dsh start (agent-default-model) magpie had set to a found
routing group keeps the id the group had then, group/auto-<slug>. Since
81a24cf8f the group is listed as auto/<model>, and that is the only id
magpie's routes list. dsh looks up the start by route and id, finds
nothing, and shows "Select model" with nothing picked. The owner's live
desktop profile was in this state: the start was
"group/auto-gpt-6-sol" and the route listed auto/gpt-6-sol.
renameFoundGroups never reached it, because it moves only values that
applied.json records, and there was no dsh record there.

Fix: dshStartOnItsRoute already moves a start onto the route its model
is on now. It now also moves a start whose id magpie no longer lists it
by (provider.PublicRef for a found group, provider.RenamedRef for a
renamed provider) onto the id the route lists. The effort and the other
keys in the entry stay. It runs on every route write, in every profile
(desktop, web, CLI) and in the home layer, so KeepDshWired repairs an
existing install within a round. The fix is not OS-specific.

Run at this head (rebased on bb5eb83c3), on mote (macOS) through mote-run:
- go test ./internal/agent ./internal/provider -count=1 -timeout 45m:
  ok (284s, 164s)
- go test ./internal/agent -run 'Dsh|FoundGroup|Drift|Keeps': ok
- GOOS=windows go vet ./...: ok
- GOOS=linux go vet ./internal/agent ./internal/provider: ok
  (a GOOS=linux vet of ./... from macOS stops in wails' cgo files)
- go vet ./internal/agent (darwin): ok
- gofmt -l: clean
The full suite was not run, so that another session's suite on mote
isn't held up (one full suite per machine). Only internal/agent changed.
The -run 'Dsh|...' subset ran before the rebase.

Broken by hand: with dsh.go at HEAD,
TestDshStartOnAFoundGroupsOldIdMovesOntoItsId fails, and the start
stays "group/auto-pro" in the web profile.

Real app: DeepSeek Harness 0.2.1-rc.5 on mote, each run in a sandbox
HOME and DSH_HOME:
- Fresh wiring shows magpie's models, whether the app was opened first
  or magpie wrote first.
- A copy of the owner's live desktop patch: every route is listed, but
  the seat reads "Select model".
- The same copy with the start as the fix writes it (auto/gpt-6-sol):
  the seat reads "GPT-6 Sol · routing group High", ticked in the picker.

Not tried:
- Running the fixed magpie binary itself against that copy. The unit
  test covers the magpie side.
- Windows' desktop app.
- Whether zyh6036's install was in this state. A store or key that
  doesn't resolve also empties the list (seen with no key at all), and
  their reply will say which.
2026-10-31 20:18:40 +08:00
yetone d6e1116380 codex: each end of the Codex app's app-server says why, and list flaps are guarded (#4550)
70d50254c (v0.1.2387) took the model list out of the route the Codex
app's app-server is ended on. The effort the app saves on each pick
went into the catalog, the next sync rewrote it, and the route's hash
of the catalog changed, so the app-server was ended every few minutes
and the ChatGPT app read that as a crash (goto_nozomi on Discord,
ggbdpq on #4550). This adds two things on top of that.

- codexAppStep logs each end with what made the app-server stale:
  "codex: ended the Codex app's app-server [pid] for the app to start
  another: <why>". The reason is the ChatGPT account switched, the
  route changed, or the used-up takeover. Before this a successful end
  logged nothing, so a reported crash couldn't be put down to magpie or
  to the app (ggbdpq asked for it on #4550).
- TestCodexAppRouteKeepsThroughListFlaps runs in a sandbox HOME
  through SyncCatalog. A relay's list drops a model and has it back,
  the catalog is re-ranked in another order with other descriptions,
  and the catalog is caught half-written. Each must leave the route as
  it was. 70d50254c's tests cover an effort pick and a rename.

Product call, as 70d50254c made it: a list change alone never restarts
the app-server, not even once Codex has been idle for a while. The
restart is what crashes ChatGPT when an MCP server is slow, and idle
time doesn't make it safe. The new list is read at the app's next
launch, or on the Agents row's Restart (StaleCopies). Where requests
go (model_provider, openai_base_url, the magpie table's base_url,
requires_openai_auth, the used-up takeover) still restarts it, as
TestCodexAppRouteFollowsConnectAndDisconnect and
TestCodexAppRouteFollowsOpenAIAuth hold.

Run (mote):
- go vet, GOOS=linux go vet and GOOS=windows go vet of ./internal/agent
  and ./internal/provider: clean.
- go test -count=1 -timeout 45m ./internal/agent ./internal/provider on
  e484b1e93: ok. Rebased onto 5cc2eea2f (dsh in internal/agent), then
  go vet and go test -count=1 -timeout 45m ./internal/agent again, and
  -run CodexApp ./internal/provider: ok.
- gofmt -l on both packages: nothing.

Broken by hand:
- TestCodexAppRouteKeepsThroughListFlaps at 70d50254c^ (the route
  still hashed the catalog) is red three ways: a model dropped (:119),
  another order (:141) and a half-written catalog (:147) each changed
  the route.
- With the used-up reason taken out of codexAppStep,
  TestCodexAppEndSaysWhy is red ("... start another: where Codex's
  config sends it changed", want "used up").

Not tried:
- The real ChatGPT/Codex app. Nothing here changes when the app-server
  is ended, only what is logged.
- The whole ./... suite and the GUI suite. Neither package touches the
  GUI.
- Whether goto_nozomi's crashes stop on v0.1.2387. #4550 stays open
  for them to say, with the new log line asked for if any crash is
  left.
2026-10-31 19:55:12 +08:00
yetone e484b1e936 provider: an account Codex holds in another of its folders can be removed in magpie (charliepu)
charliepu on Discord (Windows), after v0.1.2385: the account that read no
allowance couldn't be removed. Remove answered "<email> is signed in to
Codex in C:\Users\charl\.codex-db-backup-20260803: sign it out there
(CODEX_HOME=... codex logout) to remove it". That folder is a backup no
Codex runs in. appdir.CodexHomes finds it by name (".codex*" holding an
auth.json), and rememberLogins read its account back at every look, so
forgetLogin refused rather than have it come back.

Now Remove forgets the account and sets that folder's sign-in aside in a
record of magpie's own (codex-homes-removed.json: the folder to a sha256
of its refresh token, or of its access token when it has none).
codexHomeLogins passes over a folder while it holds that sign-in. The
folder's files are left as they are: nothing in it is written, moved or
deleted. A sign-in made
in that folder again (Codex run there, a new token) isn't named by the
record, and is listed again with no step of the user's. With the record
unreadable, which sign-ins were removed is unknown, and no other folder's
account is read that time (accounts saved already stay listed).

Not done: treating ".codex-db-backup-*" folders as not Codex homes by
name. They are found by the same rule as ~/.codex-work, and their
sessions/ are still read for Sessions and usage as before; a name rule
would guess at what a user's folder is for. Removing is the user's own
answer, and works for any such folder.

Run at this head (origin/main 70d50254c plus this change; the doc line
added after):
- mote: go test -timeout 45m -count=1 ./internal/provider ./internal/appdir: ok (provider 142s;
  135s at the earlier base e90a635a9)
- mote: GOOS=windows and GOOS=linux go vet ./internal/provider: ok
- xiaomi-gpu (Windows 11, win-run): go test ./internal/provider -run
  'TestCodexHeldFolderAccountRemoved|TestCodexOtherHome|TestCodexHeldInOtherFolder':
  all four pass
- gofmt -l internal/provider: empty

Broken by hand, each red:
- logins.go as on main: TestCodexHeldFolderAccountRemoved fails with the
  "codex logout) to remove it" refusal, and so does
  TestCodexOtherHomeAccountReadsQuota (its last check pinned the refusal;
  it now expects the removal to go through).
- codexHomeLogins ignoring the record: "removed, then read back from the
  backup folder".
- an unreadable record read as empty: "with the record unreadable, the
  removed account came back".

docs/subsystems/providers-accounts.md's "Codex's other folders" row
said such an account couldn't be removed; it now says what Remove and
v0.1.2385's Sign in again do.

Not tried: the real app on Windows with a real backup folder (the test
runs on Windows with a sandbox HOME); a real account. No GUI change: the
row's Remove posts login/forget as before, which now goes through.
2026-10-31 19:42:52 +08:00
yetone 70d50254cb codex: a change to the model list alone no longer ends the Codex app's app-server
The Codex app crashed and relaunched every few minutes (indekkusu141209
on X, #4550: 08:06, 08:12, 08:26).

Cause. KeepCodexAppOnItsProvider ends the app's app-server whenever
codexAppRoute changes. Since ca8a6f346 (lucis0116 on X) the route held a
hash of the bytes in the catalog that model_catalog_json names. The
ChatGPT app takes an ended app-server as a crash. Those bytes change far
more often than where requests go:

- Each model's default_reasoning_level follows config.toml's
  model_reasoning_effort (codexcat.ModelDefault, Creat.wu on Discord).
- The Codex app writes that key on every effort pick, and on a switch to
  a model with other levels. So does magpie's settle() when a pick moves
  the effort.
- The next SyncCatalog, set off by things like a plugin token refresh or
  a providers.json save, rewrote the catalog. 3s later the route had
  changed, and the app-server was ended once idle.

The route doc's own promise, "nothing the Codex app writes itself is in
route", was broken through the catalog.

The repro was in a sandbox HOME, not the live ~/.codex. A throwaway
gateway test diffed CodexDesktopCatalog's bytes:
- Two passes with nothing changed: same bytes.
- A model pick: same bytes.
- models_cache.json refetched with a new fetched_at/etag: same bytes.
- model_reasoning_effort low -> high: different bytes.
The new agent tests below show the same for magpie-models.json, and the
old route moved with it.

Change. The route is where requests go, and only that:
model_provider, openai_base_url, magpie's base_url and
requires_openai_auth, and AppOut. model_catalog_json and the catalog's
content are out, and codexCatalogTag (codex_app_route.go) is gone. A
list-only change (a provider renamed, a model added, an effort picked)
restarts nothing. The app reads the new list at its next launch. The
Agents row already shows a Codex app on an older list, with its Restart
(StaleCopies). Its digest compares slugs and visibility, so an effort
pick doesn't flag it. No new UI.

The effort in the catalog is kept. It is the Creat.wu fix, and with the
restart decoupled, a rewrite of a file the app reads only at start costs
nothing.

Trade-off: a provider renamed or a model added in magpie shows in a
running Codex app only after it is reopened, or after the Agents row's
Restart. Before this commit that happened on its own, which was
lucis0116's ask.

Siblings, all read:
- RestartCodexApp (Agents row), RestartSwitchedCodexApp (switch notice,
  46aa7e6b8) and RestartCodexAppWhenIdle (uninstall) are user-started or
  a real route change. None reads the catalog. Unchanged.
- KeepCodexDaemonCurrent restarts the CLI's managed daemon only with no
  codex session on it, on the slug digest. That is not the desktop app.
  Unchanged.
- No other agent hashes its catalog into a restart.
- zhangjian94cn's fix/4243-codex-lifecycle-boundary takes away all of
  magpie's restarts. That goes further than this commit, and no code was
  taken from it. #4243 (aresxu8866-hue) asked for the catalog to count
  only when it is magpie's, which this commit supersedes.

Tests:
- TestCodexEffortPickKeepsTheAppRunning (new): the reporter's case. An
  effort saved as the app saves it, then SyncCatalog. The catalog
  changes and the route does not.
- TestCodexAppRouteIgnoresARename replaces
  TestCodexAppRouteFollowsTheCatalog, whose guarantee is now reversed.
- Broken by hand: both new tests run on the old codexAppRoute are red
  ("an effort picked in the Codex app changed its route", "a provider
  renamed changed the Codex app's route"). Green with the change.

Run at this head (5b0bb1349's tree, rebased on e90a635a9), on mote:
- go test -tags nogui -count=1 -timeout 45m ./internal/agent
  ./internal/provider: ok, ok. The same before the rebase.
- gofmt -l .: nothing.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
  go vet ./..., go build ./...: ok. That run was before the rebase; vet
  on agent and provider was run again after it.

Not run: the full go test ./... suite. Another session's full suite held
mote, and the owner's rule is to ship without holding for it; it follows
after the push. Not tried: a real ChatGPT/Codex desktop app. Nothing on
the ChatGPT side was changed or measured (the MCP handshake ggbdpq
traced). docs/subsystems/agent-wiring.md was updated.
2026-10-31 19:39:38 +08:00
yetone b9e5bc6cb3 gui: Rex is a session terminal, opened through its rex CLI (#4565)
Rex (com.superlogical.rex) claims no .command file, so Launch Services
never listed it and `open -a` can't hand it a script (StringKe).
Sessions' terminal list now offers Rex when its CLI is found: a native
`rex` on PATH, or one inside a Rex*.app in /Applications or
~/Applications (Rex puts rex on PATH only in its own terminals). Perl's
Rex installs a script named rex too, so only a Mach-O or ELF program
counts. Resume, carry and an agent's Open then run
`rex run --label <title> -- /bin/sh -c '<command>; exec login shell'`:
no shell parses the label or the command on the way. With no session
to add a tab to (exit 3) it runs `rex new`; with Rex's server not
running (exit 4) the error says to open Rex. Rex is then brought
forward with `open -b`. The GUI already lists s.terminalApps, so no
JS changed. reference.md's Session terminal says it.

Parts 2 to 4 of #4565 (accounts run per account, OSC 7501 status,
folder mapping) build on #992, which isn't merged; not done here.

Ran, at this tree on origin/main e90a635a9, through mote-run:
- go test ./internal/gui -run 'TestFindRex|TestOpenInRex|
  TestDiscoverTerminals|TestTerminalOpenArgs|TestAgentOpen': ok.
  TestOpenInRex runs the real sh script with SHELL=/usr/bin/true and
  checks the command ran in its folder, and a label holding $(...) and
  quotes stays one argument.
- go vet ./...; GOOS=linux (-tags nogui) and GOOS=windows go vet and
  go build: ok (at the pre-rebase head; go vet ./... again rebased).
- Full suite, go test -tags nogui -timeout 45m ./..., at the
  pre-rebase head: every package ok but internal/gui, red on
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514, red the same on
  origin/main e90a635a9) and TestColdTurnsTaken (#4510). Rebased,
  internal/gui and internal/provider whole again: red on #4514 only.

Broke by hand, each red, then restored: withRex taken out of
discovery (TestDiscoverTerminalsOffersRex); the exit-3 fallback to
rex new turned off (TestOpenInRex: "rex: Error: no session"); the
native-program check dropped for PATH (TestFindRex took the Perl
script).

Not tried: the real Rex app or rex binary. Its installer needs a
Discord sign-in, so the CLI was driven from Rex's docs only; whether
`rex run` with no -s from outside Rex targets the shown session or
exits 3 is not confirmed. Not run on Linux or Windows (Rex's Linux
build, and the tests skip on Windows). No GUI Playwright run, as no
JS changed.
2026-10-31 19:35:16 +08:00
yetone 01813c681a accounts: switch next takes accounts that are off too, as Use does (#4532)
`magpie accounts switch claude next` (v0.1.2376) took only accounts
switched On. An account the user signed in to themselves, picked up by
rememberLogins, starts off, so next said there was nothing to switch to
while the switch list and the GUI's Use took that same account
(StringKe). On is whether the gateway routes to an account beside the
one signed in, not whether the agent may be signed in to it, so
NextInOrder now takes every switchable account (no token, no home of
its own) that isn't the signed-in one and isn't spent, On or not.
NextLogin, the automatic switch when one is used up, still moves only
to accounts that are On; that is unchanged. reference.md and
providers-accounts.md say so.

Ran, at this tree on origin/main e90a635a9, through mote-run:
- go test ./internal/provider -run 'TestNext|TestSwitch': ok;
  TestNextTakesAccountsThatAreOff (codex and claude: accounts left
  off as picked up; next takes the first, then the second once the
  first is at 99; NextLogin doesn't move to an off one) and
  TestNextInOrder's new cases.
- go vet ./...; GOOS=linux (-tags nogui) and GOOS=windows go vet and
  go build: ok (at the pre-rebase head on 0379f2610; go vet ./...
  again at the rebased head).
- Full suite, go test -tags nogui -timeout 45m ./..., at the
  pre-rebase head: every package ok but internal/gui, red on
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514, red the same on
  origin/main e90a635a9, run alone) and TestColdTurnsTaken (#4510,
  red only in full gui runs). After the rebase internal/provider and
  internal/gui ran whole again: provider ok, gui red on #4514 only.

Broke by hand: put the l.On filter back in NextInOrder.
TestNextInOrder and TestNextTakesAccountsThatAreOff went red ("codex
has no other account in magpie to switch to", wrong picks). Restored.

Not tried: a real Claude or Codex account, or the CLI command end to
end; the tests use sandbox fakes under a test HOME. Nothing here
touches ~/.claude or the Keychain.
2026-10-31 19:35:16 +08:00
JoeyWu-tech bec9df0888 sessions: a provider move leaves a thread a Codex has open (#3751)
#3751's second half; 67b12956 fixed the half about lengths. A Codex
thread moved to another provider, by the Sessions page's Move
(MoveCodexProvider, #887) or as Codex steps off magpie (bringBack's
MoveCodexThreads), has each of its rollouts written whole into a temp
file that then takes its place. The move took no Codex lock and left
alone only a thread written to in the last minute. A Codex that resumed
the thread (the app-server, as run below; a resumed TUI too, by Codex's
source) keeps its rollout open to append to for as long as it has the
thread, so what it wrote after a move went into the file the rename had
put aside: a turn the upstream answered was in neither the rollout nor
what Codex sent after its next resume.

moveCodexPaths now holds the thread as Codex holds one it writes to,
archives or deletes (rollout/src/writer_lock.rs, acquire; thread-store
holds it through a whole archive, unarchive or delete): under
thread-writer-locks/.coordination.lock it makes and locks
thread-writer-locks/<thread>.lock, then lets the coordination lock go
and keeps the thread's lock from before a file is copied to the trash
until the thread's row in the state database has moved. Letting go takes
the lock file away under the coordination lock, as Codex's guard does. A
Codex that resumes the thread meanwhile is turned away by Codex itself
("already has an active writer"), so the files and the row move together
and a rollback is written under no Codex. A thread a Codex has open is
left as it was: its files, their time and its row, with no copy kept.

Its error, "a Codex has the session open", is ErrActive too, so it goes
where a thread written to in the last minute goes: MoveCodexThreads
leaves it for its next call, and the Sessions page's reply marks it
active, so the page says "{title} is still being written to; close it in
Codex and try again in a minute" ("{n} sessions ..." for several), in
en, zh, zh-TW, ja and de. No new words and no GUI file changed: app.js
grows 0 bytes. There is no CLI for the move. The minute is the page's
own: codex exec lets the thread go as it exits (the interactive TUI
wasn't tried), but Codex 0.164.0's app-server keeps a thread loaded, and
held, until 30 minutes after it went idle with nothing showing it
(thread_unload_delay_secs, 1800 by default), or until it ends. So a
thread the Codex app has shown can be refused for up to half an hour
after it is closed there, or until the app quits. Those words are left
as they are (#3986).

A Codex home without thread-writer-locks (a Codex from before them)
has no lock to take, and its threads move as before, with the
last-minute check alone. None is made there: PortCodexRollouts reads a
home with one as one whose Codex holds its threads, and would then
rewrite rollouts under a Codex that doesn't. A lock folder that can't
be read, or a lock file that can't be opened, refuses the move with
its error. The coordination lock is waited for at most 10s
(filelock.Wait), under storeMu and mu as the row's 5s busy_timeout
already is; not had by then, the thread counts as held, as in
editRollout.

editRollout, the port's writer, isn't used: it publishes one file under
the coordination lock alone, while a thread's files (a revert's, a
packed twin) and its row move together, and its edit can't refuse a
longer id in a paginated rollout as 67b12956's rewriteCodexProvider
does. rewriteCodexProvider is unchanged, so the padding and that
refusal stay as they were.

A thread bringBack leaves keeps its row on magpie, so the next bringBack
picks it again (codexThreadsOn) and moves it once its Codex has let go:
it isn't left for good. bringBack runs at Disconnect and in Codex's
Sync, which SyncCatalog runs: at the GUI's start, after a provider,
plugin or model list is saved or fetched, and when the catalog is
fetched again (catalog.KeepFresh, at least daily in the GUI and in
magpie serve). Until then the thread stays on magpie, as one written to
in the last minute does now, so for up to about a day while magpie runs.
At a Disconnect magpie also restarts the Codex app's app-server
(KeepCodexAppOnItsProvider, every 3s), which lets the thread go; when
that comes after bringBack's move, the thread waits for the next Sync.
When Codex goes back to openai, or another id of magpie's length,
RelabelCodexThreads first writes a plain rollout's provider in place,
held or not; MoveCodexThreads meets a held thread there only for what
that skips, a packed rollout mostly. For an id of another length it
moves them all.

RelabelCodexThreads takes no lock either. It writes the id over in the
first line, in place, so a Codex appending to the file loses nothing:
tried below, the turn after it was kept and the row stayed as it wrote
it. It is left as it is.

The port's paragraph in docs/subsystems/gateway-routing.md, where
67b12956 put the move's lengths, says so, and so do the comments of
MoveCodexProvider, MoveCodexThreads and bringBack.

What was run (tree d652ce94, on origin/main 74dcf40a, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077:
- TestMoveCodexProviderLeavesAnOpenThread (new): a thread's writer lock
  held as a resumed Codex holds it. The Move is refused with ErrActive;
  the file, its time and the row are as they were, nothing is kept in
  the trash and no temp file is left. With the lock let go (its file
  left behind, as a Codex that ended leaves it), the Move goes through
  and the lock file is gone.
- TestMoveCodexProviderHoldsTheThread (new): looked at from a trigger
  on the row's update, as the Move writes the row, the thread's lock is
  held and the file names the new provider already; the lock file is
  gone after.
- TestMoveCodexThreadsLeavesAnOpenThread (new): two threads on magpie,
  one held. The other moves; the held one keeps its file and row, with
  no copy and no error, and the next call moves it once let go. A home
  without thread-writer-locks moves its thread as before, and gets
  none.
- The three with 74dcf40a's codex_provider.go: red, "err <nil>, want
  ErrActive", "as the row was written: no lock file", and both threads
  moved.
- -race -count=10, the three and every move and port test of
  internal/sessions (TestCodexProviderIn, TestMoveCodexProvider,
  TestMoveCodexProviderPacked, TestMoveCodexProviderKeepsBytePlaces,
  TestMoveCodexThreads, TestMoveCodexThreadsNone,
  TestPortCodexRollouts and its KeepsBytePlaces, LeavesAnOpenThread,
  LongerLine and RepairsForks, TestPortLineDropsClaudeBlocks,
  TestPortLineLeavesOthers): 16 tests, 10 runs each, ok. -race
  -count=3: internal/agent's TestCodexThreadsComeBackOffMagpie and
  TestCodexThreadsFollowMagpieIn (bringBack, bringOver) and
  internal/gateway's TestPortedCompactionReadsTheSame, ok.
- Broken by hand, each alone in a scratch worktree at this tree, the
  eight move tests run, each red:
  - no lock taken: all three new tests, as at 74dcf40a.
  - the row written for a thread left: both LeavesAnOpenThread tests
    ("its row moved to ..., its files didn't"), and MoveCodexThreads
    never finds the thread again ("after its Codex let go: [] <nil>").
  - the lock taken after the copy to the trash: both
    LeavesAnOpenThread tests ("a copy kept of a thread left as it
    was").
  - the lock let go after the files, before the row:
    TestMoveCodexProviderHoldsTheThread.
  - the error not ErrActive: TestMoveCodexProviderLeavesAnOpenThread
    ("err a Codex has the session open, want ErrActive") and
    TestMoveCodexThreadsLeavesAnOpenThread (the held thread's error
    returned, "thread ...: a Codex has the session open").
  - the lock file left when the move lets go: both
    TestMoveCodexProvider tests.
  - thread-writer-locks made in a home without one:
    TestMoveCodexThreadsLeavesAnOpenThread.
  The other move tests stayed green under each.
- Codex CLI 0.164.0, real, with gw-c's #3616 move-open harness: a
  sandbox HOME and CODEX_HOME, loopback only, a fake Responses
  upstream, and MoveCodexThreads from fake-provider to fake through a
  test binary built from each tree. Two turns on a thread T; a codex
  app-server resumes T (T's lock file appears in thread-writer-locks),
  waits 80s and has a turn; at 70s, the move.
  - 74dcf40a: the move moved T, file and row. The turn completed and
    the upstream got it, but the rollout has it 0 times, and Codex
    resuming T on fake sent turns 1 and 2 without it.
  - here: the move moved nothing, file and row on fake-provider. The
    turn is in the rollout (2 lines). With the app-server gone (its
    lock file gone) and the rollout a minute old, the move moved T
    (files 1, db 1), and thread-writer-locks had only
    .coordination.lock after it. Codex resuming T on fake sent turns 1
    and 2 and the turn the app-server had.
  Each tree ran twice: in the first runs the move after the app-server
  came within the minute after its turn, which left T here; the script
  now waits the minute out.
- Codex CLI 0.164.0, the same sandbox: with T's lock file made and
  flocked under the coordination lock by another process, as
  holdCodexThread does, codex exec resume T exits 1 with "thread/resume
  failed: thread ... already has an active writer" and sends nothing;
  once it is let go and the file taken away, the resume runs.
- Codex CLI 0.164.0, the move-open run with RelabelCodexThreads from
  fake to fak2 (one length) at 70s: T relabelled at once, the turn in
  the rollout (2 lines), the row still fak2 after it, and Codex
  resuming T on fak2 sent the turn.
- gofmt -l clean. tools/vetset.sh: go vet -tags nogui for linux,
  windows and darwin, go vet for windows, go build -tags nogui for
  linux and darwin, and go build for windows, exit 0 each; untagged
  linux vet and build exit 1 (no GTK or WebKitGTK dev packages on this
  box).
- go test -tags nogui -count=1 -timeout 45m ./... (log kept), Bun
  1.4.2: 68 packages ok and 8 red, sessions ok; each red on the list of
  reds already filed: agent (#3141, #3398, #3641, and
  TestWSLColdPlaceOpensNothing, #3924), davsync TestSync (#3420), edit
  and testenv (umask 077, #3640), gateway
  TestPluginToldWhereTheAgentWorks (#3675), gui
  TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie
  (#3649), provider TestCodexAppServersOnHome (#3906), then "close of
  synctest channel from outside bubble" (#3632), tui
  TestTUIFetchesSubscriptionModels/agent (#3919)
- On origin/main 1a804859 with this commit cherry-picked (a scratch
  worktree, not this tree): go test ./internal/sessions ok; go test -run
  Codex ./internal/agent, only TestCodexDriftReached red (#3398)
Not run: the GUI tests, i18n-keys among them; no GUI file changed.

Not tried: Windows, where magpie's lock is LockFileEx on one byte and
Codex's on the whole file (as for the port), and macOS; the Codex app
itself, whose app-server was driven over stdio here as the app drives
one; a thread of a Codex in a WSL distro moved from Windows, where the
lock taken may not be the distro's; a file system without locks, where
the move is refused as held.

Review (yetone, at this commit on origin/main bb5e68cea, go1.26.8):
- Checked against Codex's codex-rs/rollout/src/writer_lock.rs: acquire
  takes thread-writer-locks/.coordination.lock, creates and try-locks
  <thread_id>.lock and lets coordination go; its guard's drop takes
  coordination again, closes the file, removes it and lets go. The move
  does the same, and leaves a home without the folder alone.
- On main, the three new tests red on macOS (mote): "err <nil>, want
  ErrActive", "as the row was written: no lock file", both threads
  moved. With this change, ok.
- Broken by hand, each red: letGo called at once (HoldsTheThread);
  os.Remove dropped ("lock file is left", both MoveCodexProvider
  tests); threadOpen's Is false (LeavesAnOpenThread x2); the lock
  folder always made (MoveCodexThreads, "thread-writer-locks made where
  Codex keeps none").
- macOS (mote): go test -tags nogui ./internal/sessions
  ./internal/filelock ./internal/agent ok; -race -count=10 -run
  'TestMoveCodex|TestPortCodex' ./internal/sessions ok (at d0a61b856);
  gofmt -l clean; go vet darwin, GOOS=linux -tags nogui and
  GOOS=windows for sessions and agent ok.
- Windows (xiaomi-gpu, win-run) and Linux (WSL magpie-desktop,
  wsl-run): go test -run 'TestMoveCodex|TestPortCodex'
  ./internal/sessions ok (at d0a61b856).
Not tried by the review: a real Codex CLI or app holding a thread
during a move, on any system; a WSL distro's Codex moved from Windows.

At the pushed tree (rebased on origin/main 7e0fe83d4), macOS (mote):
gofmt clean; go vet darwin, GOOS=windows and GOOS=linux -tags nogui for
sessions ok; go test -tags nogui ./internal/sessions ./internal/agent
ok; -run Budget ./internal/gui ok.
2026-10-31 18:52:01 +08:00
yetone 7e0fe83d4b provider: Listed as works for signed-in accounts and plugins (zeewell on X)
zeewell asked to list SuperGrok's grok/grok-4.6@500k as grok-4.6, and
Cursor, Devin and WorkBuddy models (all plugins) under ids of their own.
v0.1.2345's "Listed as" took ids only for key/relay providers
(takesModelIDs was p.Account == nil).

Why the restriction was there: the wire rewrite (Settings.Wires) turns
the request body's model back into the own id, but some code reads the
model by the vendor's id before that and got the listed one:
- plugin model lookup (pluginModel: the plugin's APIs, tiers, prices);
- the Claude subscription run (--model given to Claude Code);
- Code Assist/Antigravity variant choice (codeAssistBody, SentNameOnIn);
- account plan lists (fallback's Account.Lists, effort Levels/Tiers,
  AccountServes);
- moveModelRefs refused a provider with no providers.json entry, which
  is every plugin and account provider until a pick is set.
Each now translates with OwnModelID / the provider's ModelIDs, so the
upstream request still carries the vendor's or plugin's own id. Only a
decide-only provider refuses an id. The GUI box already follows
TakesModelIDs, so no GUI file changed.

Tests (red on the old code, each fix reverted by hand one at a time):
- TestModelIDRefused, TestModelIDAtAnAccount (takesModelIDs,
  AccountServes, SentNameOnIn);
- TestLocalModelIDAtAPlugin (Bun fake plugin: /v1/models, upstream
  path, X-Plugin-Model, body, usage; red on pluginModel and on
  moveModelRefs);
- TestLocalModelIDAtAnAntigravityAccount (codeAssistBody);
- TestLocalModelIDAtAClaudeAccount (claude got --model my-sonnet);
- antigravity pool test (fallback Lists, Levels).

Run on mote: gofmt clean; go vet darwin/linux/windows ok; go test
-tags nogui -count=1 -timeout 45m on internal/provider, gateway, cli,
gui, settings, access, usage, plugin: all ok except internal/gui's
TestSettingsSaveKeepsWhatItDoesNotSend (SearchAll), red on main since
b09349d17 and filed as #4514. After rebasing on 140efc8f7 (nothing new
under provider/gateway) the ModelID/LocalModelID/Antigravity tests
ran again: ok.

Real accounts, sandbox HOME, dev build on 127.0.0.1:3486: magpie model
id set grok/grok-4.6@500k -> grok-4.6, grok/grok-4.5@500k -> g45big,
cursor/composer-2.5 -> my-composer, devin/swe-2 -> my-swe,
workbuddy/deepseek-v4.1-flash -> ds-flash. /v1/models listed the new
ids. Requests for grok/grok-4.6, grok/g45big, cursor/my-composer and
devin/my-swe each answered 200 "pong", served as the vendor's id
(grok-4.5-build for g45big); usage records the listed id as model.
Plugin tokens were not rotated (no diff with live).

Not tried: WorkBuddy's real request (its own sign-in answers 401,
unrelated); the GUI box not clicked; no full ./... suite, no GUI suite
(no GUI file touched).
2026-10-31 18:38:31 +08:00
yetone d8cf4f74f9 plugins: a plugin's package.json names its row with magpie.name (#4558, MYCF711)
A plugin installed from git whose package.json says
"magpie": { "name": "华为云 HUAWEI" } read as its dependency key
(magpie-officeace) on Settings → Plugins. Bun takes no non-ASCII key, so
a package outside the community's list had no way to show a readable
name. magpie.name was never read at all: #3608's route (MYCF711's branch
1cc33700) didn't reach main, so no release has it, git or npm.

plugin.InstalledName reads magpie.name from the installed package's own
package.json, beside magpie.icon (installedOwn, one parse for both): one
line of at most 80 bytes, no control or format characters (a bidi
override would show it as another name), else nothing. /api/plugins gives
each row it as ownName, and plugins.js's shownName takes it after the
community list's name and before the git package or the spec, so a
listed package is still named by the list. The row's page, the "is up to
date" status and every message that names the row (options, prefer, Update
all) go through shownName; a page plugin's sidebar tab takes it when the
page names no title (windowParts). It is never used to resolve a name and
never shown with the community badge. Not changed: the CLI's plugin list
(the dependency key, as the reporter expects), Discover's cards for
uninstalled GitHub/npm packages, and magpie.summary. Documented in
docs/reference.md and site/public/docs (en, zh, ja).

Run:
- mote: go test -timeout 45m ./internal/plugin/ ./internal/gui/ — plugin
  ok; gui red only in TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  the AppKit window tests killed at their deadline (TestPanelCloseHidesIt,
  TestPluginPageLoadsItsFilesInTheWindow, TestMainWindowCorners, …;
  #4125, #2645). The first three run the same red on origin/main 7aa67e9e5.
- mote: go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet on
  internal/plugin and internal/gui: clean. gofmt -l internal/: nothing.
- wsl-run (magpie-desktop): plugin-own-name.test.cjs, Chromium and
  WebKit, en/zh/zh-TW/ja/de at 980 and 420: 22/22. Every plugin*,
  plugins-*, agent-plugin*, account-plugin*, signin-paste-plugin,
  sidebar* and i18n-keys file (67): all green but i18n-keys "a plugin's words are its own" (#4524), plugin-card-update webkit en/zh (#3079) and plugin-github-filter webkit ja 420px (#4564, filed now), each red the same at origin/main 7aa67e9e5
- Rebased on origin/main 7b883cc61, mote: -run "Budget|OwnName|TestPluginsState|
  TestWindowParts" on internal/gui and internal/plugin: ok (core scripts
  under the budget, no raise).

Broken by hand:
- InstalledName returning "": TestPluginsStateGivesAGitPackagesOwnName red
  (ownName "", and the sidebar title magpie-officeace).
- shownName without e.ownName: plugin-own-name.test.cjs red, the row
  reads 'magpie-officeace'.

Not tried: the desktop window itself, and a real git repository with
magpie.name (the fixture is shaped from the reporter's installed
package.json: name magpie-officeace, version 0.2.4).
2026-10-31 18:30:39 +08:00
yetone 64cdb68035 accounts: import claude reads claude-swap's export (#4532)
StringKe (#4532) is moving from claude-swap (cswap 0.29.0) to magpie,
and `magpie accounts import claude` didn't read cswap's export. It does
now: parseLoginImport takes cswap's format-1 envelope ({version: 1,
swapVersion, encrypted, accounts: [...]}, read from cswap 0.29.0's
transfer.py) and cswapEntry reads each account's
credentials.claudeAiOauth and config.oauthAccount: email, account and
organization uuid, and the organization's name. The tokens are kept as
the file has them; magpie asks Anthropic nothing.

Refused, each with what to do: an encrypted export (decrypt with gpg -d
first), another format version, a Codex entry, and an API-key entry
(added as a key instead). An entry with no refresh token is accessOnly,
as for every other file. cswap's alias becomes the account's name in
magpie (importNames) when the account was added or updated, has no name
yet, and no other account is called that or signed in as it, so the
name stays a selector for one account (the previous commit's rule).

testdata/cswap_0.29.0_export.json is claude-swap 0.29.0's own `cswap
export` output, made from its source in a sandbox HOME in WSL with two
accounts and fake tokens (cswap's add step asked Anthropic once with
the fake refresh token, which it called dead; no real account was
involved).

Run (mote unless said):
- At this commit's tree (on origin/main 47173f593):
  gofmt -l clean; GOOS=linux go vet -tags nogui ./... and GOOS=windows
  go vet ./... ok; go test -timeout 45m ./internal/provider (ok 100.7s),
  ./internal/cli (ok 31.8s), ./internal/gui: red on 11 real-window
  AppKit tests killed at their deadline on mote over ssh (#4125, #2645)
  and TestSettingsSaveKeepsWhatItDoesNotSend's SearchAll, red on main
  (#4514); none touches accounts.
- Rebased on origin/main 7aa67e9e5 (4 commits, none in accounts), then
  at the pushed tree: go test ./internal/provider (ok 163.5s),
  ./internal/cli (ok 55.8s), ./internal/gui -run 'Budget|I18n|Key'
  (ok), gofmt -l clean.
- TestImportCswapExport, TestImportCswapRefusals. Broken by hand, each
  red: no cswapEntry, no importNames, the taken-name check off (red on
  "the team seat took pro's name"), the encrypted check off, no
  organization name.
- CLI in a sandbox HOME in WSL: import of the fixture adds max@x.com and
  team@x.com, a second import says both are in magpie already, the alias
  "work" is team's name, `accounts forget claude work` picks it;
  `accounts import --help`, a missing file and an unknown agent each say
  what's wrong.
- On mote over ssh the same import added one account and failed the
  other on the Keychain ("Unable to obtain authorization", no GUI
  session there), and the failed one was still saved, so the second
  import called it "in magpie already". That's addLogin writing
  logins.json before signing Claude Code in, the same for every import
  and sign-in, not this change; not changed here.
- GUI: login-import in Chromium and WebKit on Linux (WSL), green.

Not tried: an export from a real cswap install with real accounts,
Claude Code running on an imported account, or cswap's encrypted export
decrypted and imported. A cswap account's plan (subscriptionType) isn't
carried: magpie reads it on the first usage read, as for CLIProxyAPI.
2026-10-31 18:22:02 +08:00
yetone a7b47d57ec accounts: removing the account Claude Code is signed in to switches it to another first (#4532)
StringKe (#4532): removing the signed-in Claude account was refused with
SignedInError, while Codex's switched away first. ForgetLogin now does
the same for Claude Code: nextOnForget picks another account (on first,
then one whose sign-in holds), SwitchLogin signs Claude Code in to it,
and only then is this one forgotten. If that switch fails, nothing is
removed and the error says why.

nextOnForget leaves out accounts Claude Code or Codex can't be signed in
to (switchable: not a setup-token account, not a Codex account held in
another folder). Claude Code is never signed out: when the account is
the only one it can be signed in to, it is kept, with
SignedInError{Only} (GUI code signed_in_only), which says to add another
account first or sign out in Claude Code. The GUI gives the signed-in
Claude row a Remove when another account it can use exists, and no
Remove or Sign out otherwise. Claude Code's own credential is never
deleted; forgetClaudeDir removes only the forgotten account's own
folder and its folder's Keychain item, and claudeHolders' check of
other records holding the same token is unchanged.

Tests: TestForgetLiveClaudeSwitchesFirst, TestForgetOnlyClaudeIsKept
(replacing TestClaudeInUseStillRefused, which held the old refusal);
codex-signout.test.cjs gets three Claude cases (Remove with another;
only + setup-token: no Remove, reason in zh/zh-TW/ja/de; the
signed_in_only refusal in en/zh).

Run (mote, sandbox HOME through the test helpers):
- go test ./internal/provider ./internal/cli, vet and gofmt at the
  stack head: in the next commit's body (one tree, same run).
- Broken by hand, each red: Claude not switched first
  (TestForgetLiveClaudeSwitchesFirst), Only left false, a setup-token
  account counted as another, nextOnForget unfiltered
  (TestForgetOnlyClaudeIsKept).
- GUI on Linux (WSL magpie-desktop), Chromium and WebKit: codex-signout,
  own-signin-remove, saved-signedout-remove, login-import, claude-signin,
  account-alias and i18n-keys all pass but i18n-keys' "a plugin's words
  are its own", red on main (#4524). On mote, codex-signout passed in
  Chromium; its WebKit launches were killed with mote at load ~25 under
  other sessions' suites (#4125), so WebKit's record is Linux's.

CLI in a sandbox HOME (WSL, file credentials): forget of the signed-in
account by its name switched Claude Code to the other (.claude.json then
says max@x.com); forget of the only one was refused with the message
above and left it signed in.

Not tried: a real Claude Code switch on removal with real accounts, or
in the CLI against a live ~/.claude (sandbox only).
2026-10-31 18:18:37 +08:00
yetone 149e763e9e accounts: a name you gave an account picks it wherever an email does (#4532)
StringKe (#4532): `magpie accounts switch claude work` failed when "work"
was the alias; accountNamed matched the email only.

provider.AccountByName resolves a name (magpie accounts alias) among an
agent's accounts. It refuses a name two accounts share, and a name that
is another account's email or email part, so a name never picks the wrong
account. It is used by:
- accountNamed: accounts switch/on/off/remove/alias/cap and the rest
  that take <email>;
- provider pool --accounts;
- accountRef (GUI and account-cap): the exact email first, then a name,
  so another account's alias never shadows an email;
- account-cap's display, through AccountRefOf (it filtered by email).

Run (mote, at this commit):
- go test -timeout 45m -count=1 ./internal/provider ./internal/cli: ok
  (104.9s, 33.2s).
- TestAccountsAliasPicksTheAccount, new: switch, alias, pool --accounts
  and account-cap by name; a shared name and another account's email
  refused. Red with each part removed by hand: the accountNamed call,
  pool's resolution, the clash check, the shared-name check, accountRef's
  name step.

Not run: the GUI suite (no GUI file changed); real accounts.
2026-10-31 18:18:37 +08:00
yetone 15b83901ac accounts: switch to the next account with room, or the one with the most left (#4532)
StringKe (#4532), comparing magpie with cswap 0.29.0: there was no "switch
to the next account", and when every account was past its line the
automatic switch stayed on the spent one, where cswap moves to the account
with the most room left.

- `magpie accounts switch <claude|codex> next` (provider.NextInOrder) takes
  the other accounts that are on in magpie, from the one after the account
  the agent is on, wrapping round: the first whose allowance is known and
  has room, else the one with the most room left, and says it is past its
  line. A saved Claude account not read yet is read first (readSpare), as
  the automatic switch's spares are. With no reading of any it refuses
  rather than guess; for any other agent it asks for the account by name.
- NextLogin (shared by Codex and Claude Code): when the account the agent
  is on is spent and every spare is past its line too, it moves to the
  spare with the most room left (roomLeft: the fullest stopping window's
  distance below the switch share, or the account's own cap when lower),
  when that has at least roomMargin (1 point) more than the one it is on,
  so two all but even accounts don't trade the agent each look. A held,
  failed or unknown reading is never moved to. One model's own window
  still counts for nothing, as before.
- docs: reference.md (the automatic switch and `next`; its "a Claude
  account magpie knows nothing of is not moved to" was stale since
  readSpare), providers-accounts.md's Used-up switch row, the en/zh/ja
  start pages' command table, `magpie help`.

Run (on mote, sandbox HOME through the packages' TestMain):
- go test -timeout 45m -count=1 ./internal/provider ./internal/cli: ok
  (144s, 44s), at this change's tree before the next commit's edits.
- TestNextLoginTakesTheMostRoomWhenAllArePast and TestNextInOrder, each
  over codex and claude with three accounts: green; red with the fallback
  taken out of NextLogin (the two "most room" cases, both agents) and with
  NextInOrder not starting after the signed-in account ("the one after
  it", both agents). The "none has more by the margin" case fails without
  roomMargin.
- Built the nogui binary and ran in a fresh sandbox HOME on mote:
  `accounts switch claude next --help` (prints the accounts help),
  `switch claude next` and `switch codex next` with no accounts ("has no
  other account that is on"), `switch gemini next` (asks for a name),
  `switch claude nxt` (no such account), `switch claude` (usage).
- gofmt -l clean. Cross-OS vet: run at the head of this stack.

Not tried: a real switch between real Claude or Codex accounts; the CLI
`next` with real saved accounts (the provider tests cover the choice).
2026-10-31 18:18:37 +08:00
yetone 6b8261029b routing: a request magpie put on another model says why (Neo)
Neo (Discord #feedback, Claude Desktop through the gateway) saw a
Requests row asking chatflowsai/claude-opus-5-5 served by AgentRouter's
gpt-6.1-sol, and read it as Claude asking for another provider's model
on its own. Claude Desktop names its own short requests (a title, its
connection check) on the first Claude-looking id in the list, here
chatflowsai's opus, and magpie keeps them on the chat's model by design
(desktopTurn, 51f66fe8b/13b4a29ab). The routing is right; the row never
said why the model changed.

Changed:
- Route gets Moved {to, why}, set wherever serve puts a request on
  another model before the trace starts: Desktop's tier, title, check,
  gone-model and side-turn moves (desktopMove returns the reason), the
  classifier and Claude tier stand-ins, the stand-in, Codex's turn and
  Privacy's mask route. A subagent's own move clears it (it has its own
  tag).
- Routing's list rows, replay, panel and story tag such a row "Title"
  or "Stand-in" and say why in the tooltip and story. Desktop's
  connection_check kind (da3c5e0c0) already explains itself, so it
  gets no second sentence (movedSays).
- zh, zh-TW, ja, de for the new strings; gateway-routing.md says it.
Not changed: codexFollowTo/codexMaskRoute still show the moved model as
asked.

Run:
- Full Go suite `go test -timeout 45m ./...` on mote at e30092847
  (before the rebase onto cae01311c): 79 ok; the one FAIL is
  internal/gui TestMainWindowCorners/macOS_26_SDK, #3949, same message.
- At 557c4f950 (on cae01311c), on mote: gofmt clean, go vet ./...,
  GOOS=windows go vet ./..., GOOS=linux go vet ./internal/gateway/...
  ./internal/usage/... (a whole-tree Linux vet needs cgo for Wails):
  ok. go test internal/gateway/... and internal/usage/... ok;
  internal/gui's reds are the AppKit windows killed at their deadline
  (#2645, #4125), TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestColdTurnsTaken (#4510), none of them Routing's.
- Rebased onto b1a1b950f (b52c39b65 changed routing/client.js): this
  head, on mote: gofmt clean, go vet ./internal/..., GOOS=windows go vet
  of gateway and gui, go test ./internal/gateway/... ok. Rebased again
  onto a511b11d8: go vet of gateway and gui, and go test -run
  'Desktop|Moved|Classif|StandIn|Subagent' ./internal/gateway/: ok.
- The full GUI suite at e30092847 was swamped by other sessions' suites
  (4771 browserType.launch 180s timeouts, #4125), so it tests nothing.
  mote's browsers were broken again (#4125), so the 208 GUI files that
  reach Routing or i18n ran on Linux (WSL magpie-desktop) at 557c4f950:
  2921 tests, 2823 pass, 98 fail in 37 files. Those 37 files at
  origin/main b1a1b950f: 76 of 428 red; at this head: 80 of 428, the
  differing ones the same tests in other languages or engines (rule
  drag/remove, rest-try-now, routing-flood, group-morph), filed as
  #4121, #4120, #4471, #2215, #3789, #3094, #2564. i18n-keys' one red
  is #4524 ("Unmarked", on main). At this head routing-moved-why,
  routing-session-title, claude-subagent-tag and i18n-keys: 83 of 84,
  the one is #4524.
- routing-moved-why.test.cjs runs en/zh/zh-TW/ja/de, both engines, at
  1100 and 420 wide.

Broken by hand: with `Moved: moved,` taken out of serve's Route literal,
TestClaudeDesktopMoveSaysWhy is red ("title's route moved <nil>, want
agentrouter/gpt-6.1-sol by desktop-title"); with origin/main's
client.js, routing-moved-why is red (0/2).

Not tried: a real Claude Desktop. Neo's earlier effort high-as-medium
report was not looked at here.
2026-10-31 18:05:17 +08:00
yetone a511b11d8b sync: an agent's model set back on a computer after a sync stays that computer's (hayden4608)
hayden4608 on Discord syncs two computers through GitHub, both with
Codex, and wants each one's Codex default model kept apart. Until now
the agents part carried every agent field ("codex.model", effort,
provider...) as one set: A's pick went up, B's sync brought it over B's,
B's pick went up again and A's next sync took it back. The two
computers fought, and the only way out was turning "agents' models"
off for every agent.

Now a sync that brings an agent field over this computer's value
records what it brought (Brought) and what it wrote over (Replaced,
only when that was picked here, not itself brought). If the user then
sets the field back to the value the sync replaced, the field is this
computer's own (Own): it leaves the hashes, a sync no longer brings it,
and a push keeps the server's value, so the other computer is not
changed either. Every other new pick is an ordinary pick and still goes
both ways, so a computer that changes the model for everyone (and
TestSyncAgentDefaults' reset) still reaches the rest. Nothing to set
up: the user's own act on this computer decides it, and a synced value
never overrides it again.

Settings > Sync lists the kept fields in one row ("Kept on this
computer: Codex model ...") with a "Follow the others" button
(davsync/follow), which brings the server's values on the next sync and
ends the keeping. Restore brings everything and ends it too. The row is
drawn only while sync and agents' models are on and something is kept;
plain row and button, no new layout. app.js grew 623 bytes; the budgets
are raised by that with a note.

Tests:
- internal/davsync/own_model_test.go TestOwnModelStaysOnEachComputer:
  two sandbox HOMEs (CODEX_HOME per computer) on the GitHub fixture.
  A picks a1, B joins and gets it, B picks b1 (goes up), A gets b1, A
  sets a1 back (own; the server keeps b1), B picks b2 + effort +
  provider (A gets effort and provider, keeps a1), A picks a2 and a
  Claude model (both go up, B gets them), A follows (gets b2), B's b3
  reaches A. TestNewPicksStillGoBothWays: alternating new picks always
  reach the other computer.
- internal/gui/tests/sync-own-fields.test.cjs: the row in en, zh,
  zh-TW, ja, de at 420px, no overflow, Follow posts once and the row
  goes, no scroll; no row without own fields or with agents off.

Broken by hand, each red: noticeOwn off (own_model_test:122); any pick
after a sync counts as own (TestSyncAgentDefaults and own test:106);
keepServersOwn off (:166); the bring ignoring Own (:146); withoutOwn
off in the hashes (:143, a notice); Follow off (:182).

Run at this head (rebased on 47173f593) on mote:
gofmt -l internal/davsync internal/gui clean; go vet ./..., GOOS=linux
go vet -tags nogui ./..., GOOS=windows go vet ./... ok; go test
./internal/davsync ok, ./internal/backup ok, ./internal/gui ok but
TestSettingsSaveKeepsWhatItDoesNotSend (#4514, red on main) and the
eleven real-window AppKit tests (dock, panel, tray, corners), which
time out on mote at origin/main 47173f593 too (#4125, #2645);
-run 'Budget|Sync|Backup|Settings' passes TestCoreScriptBudget.
GUI (node --test): sync-own-fields, sync-note-show, github-sync,
s3-sync, sync-other-kind, sync-not-backup, sync-auto-restore,
sync-usage-error, i18n-keys. Chromium on mote: all pass but
sync-not-backup and sync-usage-error, whose chromium.launch({channel:
"chromium"}) segfaults on mote at origin/main 47173f593 too; on the
WSL box (magpie-desktop) they pass, 25 of 25 with sync-own-fields.
WebKit on mote hangs on launch for every file, untouched ones too; on
WSL all nine files ran: 49 of 52, the reds being i18n-keys' "a
plugin's words are its own" (#4524, red on main) and the first
page.goto of sync-own-fields and sync-note-show at 5s under nine
files at once, which pass run alone (9 of 9).
Red on main and not from this change: TestSettingsSaveKeepsWhatItDoesNotSend
(#4514), i18n-keys "Unmarked" (#4524).

Not tried: a real GitHub repo and a real Codex on two computers; the
CLI has no follow command (only the GUI and Restore end the keeping);
Undo after a Restore doesn't bring Own back.
2026-10-31 18:01:04 +08:00
yetone fb9c176756 claudetui: Claude Code in WSL runs in its interactive mode too
A Claude Code found in a WSL distro (Windows has none of its own) was
always claude -p, the entrypoint the plan counts at about twice the
interactive mode's. Many Windows users run it there.

The Windows helper now runs wsl.exe in its pseudo console. The gateway
hands it MAGPIE_CLAUDE_TUI_WSL (claudetui.WSL, claudeCLI.tuiWSL): the
wsl.exe arguments up to Claude Code's (wslrun.Tool.Args, with
MAGPIE_WSL_RUN), the distro's mount, and the projects folder as Windows
reads it. That is the account's config directory, handed in through
CLAUDE_CONFIG_DIR/p, or the distro user's own ~/.claude/projects
through \\wsl$\<distro> (wslrun.Tool.Home, a new line in the probe;
wslrun.Tool.Windows). TERM is added to WSLENV, and an image's path is
pasted as the distro reads it (/mnt/c/…). The helper is the Windows
magpie.exe, not the /mnt/c/… path the MCP helper starts at; the first
real run failed on exactly that (fork/exec /mnt/c/...magpie.exe). The
gate keeps -p for a WSL Claude Code whose home is unknown, and, in the
distro user's own folder, when Windows can't stat \\wsl$\<distro>\<home>
(tuiWSLUnread): over ssh it can't (no 9P redirector), and the helper
would wait for a transcript it can't see. Doc updated.

Run:
- go test ./internal/claudetui ./internal/wslrun on mote and on Windows
  11 (xiaomi-gpu): ok. New: TestShimInWSL (image path, WSLENV),
  TestClaudeTUIWSL (projects folder both ways, wsl args), the home in
  the probe and Windows() in wslrun, the gate's two WSL cases, TestClaudeTUIWSLUnread.
- go test -run 'Claude|Refusal|Thinking' ./internal/gateway on mote: ok.
- go vet of claudetui, gateway, wslrun for darwin, linux, windows
  (-tags nogui, and the main package for windows); gofmt -l clean.
- Real account on xiaomi-gpu: a sandbox HOME gateway (3462) with no
  Windows Claude Code reachable (PATH trimmed, MAGPIE_TEST_SANDBOX so
  the registry PATH isn't read), the Claude Max account, Claude Code
  2.1.289 in magpie-desktop, haiku-5-5. Tree: helper -> wsl.exe ->
  claude on a pts in the distro, TERM=xterm-256color,
  CLAUDE_CONFIG_DIR=/mnt/c/..., no CLAUDE_CODE_ENTRYPOINT. One tool
  call, two in one message, text then a call, and two image turns: all
  right. Every transcript row "entrypoint":"cli", no "-p" line in the
  log, images noted as /mnt/c/.../magpie-claude-images-*/image-N.png
  and no folder left. Killing the gateway ended its four claude
  processes in the distro within 3s. The token wasn't refreshed; the
  copied credentials were deleted.

Broken by hand: shim.path returning the Windows path unchanged,
TestShimInWSL red; tuiWSLUnread ignoring the stat error,
TestClaudeTUIWSLUnread red.

Not tried: a WSL Claude Code run from the distro user's own ~/.claude
for real (only the account config directory ran; over ssh
\\wsl$\magpie-desktop is unreadable, so that run would be -p, and a
desktop session's \\wsl$ wasn't tried), a distro whose default user is root, a distro not sharing
Windows' loopback (wslrun.Tool.Host set), WSL1.
2026-10-31 17:29:01 +08:00
yetone f68ddca370 install.sh: a Linux desktop gets the desktop app, or the command that installs its WebKitGTK; --gui and --tui choose (shuhai)
shuhai on Discord: on a Linux desktop install.sh installed the terminal
build, and a desktop user expects the app. The script chose by
`ldconfig -p` alone, and on Debian a user's PATH has no /sbin, so
ldconfig wasn't found and every Debian desktop got the terminal build
even with WebKitGTK 4.1 installed. Without the libraries, the only hint
was a line mid-output.

Now, with nothing asked (curl | sh stays unattended):
- the libraries are looked up with ldconfig from PATH, /sbin or /usr/sbin,
  and in the usual lib folders when there is no cache (NixOS, Guix);
  GTK 3 is checked beside WebKitGTK 4.1, which brings the rest the app
  links (readelf -d of v0.1.2359's magpie-linux-amd64: gtk-3, webkit2gtk-4.1,
  soup-3.0, javascriptcoregtk-4.1, glib, X11, wayland-client, glibc);
- libraries there: the desktop app, as before;
- a desktop without them: the terminal build, and last in the output the
  distribution's command (apt/dnf/pacman/zypper/xbps/emerge from
  os-release ID and ID_LIKE), "run this again", or --gui. A desktop is
  DISPLAY, WAYLAND_DISPLAY, XDG_CURRENT_DESKTOP/XDG_SESSION_DESKTOP/
  DESKTOP_SESSION, XDG_SESSION_TYPE x11/wayland, the user's logind
  Display session when its Type is x11/wayland/mir (over ssh; logind
  falls back to a tty login, which doesn't count), or a session file in
  xsessions/wayland-sessions under XDG_DATA_DIRS;
- headless without them: the terminal build, with no desktop advice;
- --gui: the app even before its libraries, with the package to add;
  --tui (or MAGPIE_CLI=1, kept) the terminal build on a desktop too;
- musl (Alpine): always the terminal build; --gui refuses, since the
  app is built against glibc.
Docs: reference.md Install, README en/zh, docs start FAQ (en/zh/ja,
#linux-build).

Run:
- shellcheck -s sh: only SC2010 at the uninstall's `ls | grep`, there
  before this change. sh -n and dash -n clean.
- site/install.test.mjs (5 new tests): 19/19 on mote (macOS sh) and on
  magpie-desktop through wsl-run (dash); CI's site step
  (sh -n + node --test site/*.test.mjs) 58/58 on magpie-desktop and 58/58
  on mote.
- Red on the old install.sh: tests 16-19 fail (desktop advice, headless
  advice, --gui, --tui). With the logind Type check taken out by hand,
  the headless test fails on login "135 tty".
- Real installs on magpie-desktop (Ubuntu 24.04, XFCE, WSLg, /bin/sh =
  dash), `cat install.sh | env ... sh -s`, stdin a pipe, into a /tmp
  sandbox HOME/XDG dirs/MAGPIE_BIN_DIR, each removed after, v0.1.2360
  downloaded from the real feed and `magpie version` run:
  session with DISPLAY/WAYLAND_DISPLAY: desktop app + menu entry;
  env -i with PATH=/usr/local/bin:/usr/bin:/bin: desktop app (the old
  script gave the terminal build here, run the same way);
  an ldconfig whose cache lacks the libs + DISPLAY=:0, and the same in
  env -i (found by /usr/share/xsessions): terminal build + the apt line;
  that with XDG_DATA_DIRS=/nonexistent: terminal build, quiet; --gui
  there: desktop app + the apt line; --tui in the session: terminal build.
  The first run found the tty-login fallback (logind's Display=135 is
  this WSL user's pts session), fixed before commit.
- site/install.test.mjs on Windows (win-run): 0/19, the same 14 old
  tests too: the box has no sh for spawnSync; CI runs this file on Linux
  only.

Not tried: a real Debian, Fedora, Arch or openSUSE box, or a box without
WebKitGTK installed (simulated with a fake ldconfig); the package names
were checked against each index (Ubuntu noble, Debian bookworm, Arch,
Fedora mdapi, Tumbleweed oss, void-packages, Gentoo), not installed. The
installed app wasn't opened (only `magpie version`), to keep off ports
other sessions use there. Termux and macOS paths are unchanged and their
tests pass.
2026-10-31 17:27:55 +08:00
JoeyWu-tech d0a61b856a plugin: the pi tests keep the pinned pi's Bun cache between runs (#2865)
installPinnedPi's `bun install --frozen-lockfile` used the install
cache bunCommand names, which lies in the test's home. testenv makes a
new home for every go test process, so every run fetched pi's 118
tarballs before the host could start, inside the test's 4 minutes.
yetone saw TestPiPackage red at 86fef947e after 226s, most of it that
install, with gateway's tests run beside it on a Mac at load 26.

Now the install gets a Bun cache that outlives the home,
magpie-test-bun-cache-<uid>-<n> in os.TempDir() (pinnedPiCache), as
the last BUN_INSTALL_CACHE_DIR in its environment. The first run fills
it, and a run after that installs pi from it and asks npm for nothing.
Bun names each entry by package, version and registry, so a new pin,
or a run through another registry, fetches only what is missing. It
holds about 155 MB here. This is the first thing the tests leave
behind between runs, on purpose: testenv's own bound is the temp
folder (checkChild), so the folder is inside it, but it is outside the
test home, which goes when the run ends. agent-wiring.md's "Tests
never touch the real machine" now says so.

Why that folder:
- It is none of the user's own folders. testenv moves HOME, the XDG
  folders, APPDATA and LOCALAPPDATA into the sandbox, not the temp
  folder, and ~/.bun, ~/.cache and ~/.config/magpie are never named.
  Only the install's own process gets the variable, so the host and
  anything else a test starts never see it. The host keeps the home's
  cache, and pruneInstallCache, which prunes the app's cache, never
  touches this one.
- It is this user's. The uid is in its name, as Linux's temp folder is
  shared (macOS' and Windows' are the user's own). It is made 0700, and
  used only when it is a folder, not a link, that no one else has any
  permission on (not checked on Windows, where Go reports no real modes)
  and that this user can make a file in. One someone else made fails
  one of those, and the install then uses the home's cache as before.
  Root always uses the home's cache: root passes those checks in a
  folder another user made, and would run what that user put there.
- Its files are never old enough for a temp folder's cleaner. macOS
  takes files under its temp folder that went unread for about 3 days,
  and Bun doesn't notice a file missing from a cached package: it
  installs the rest, and pi doesn't load (shown below). So the folder
  is a new one every two days (<n> counts two day periods), the one
  before is kept for a run still using it, and older ones are taken
  out by the next run. The first run in a new period fetches pi again.
  TestPinnedPiCacheMovesOn checks the folder moves, the one before
  stays and older ones go.
- Two go test runs can share it. Bun unpacks each tarball into a folder
  of its own and renames it into the cache. When another install got
  there first, it swaps the two or removes the old one and renames
  again (move_to_cache_directory in Bun 1.4.2's extract_tarball.rs,
  written for concurrent installs sharing one cache; on Windows it
  retries the move). Two runs started at once on an empty cache both
  passed here.
- Bun's documented default on Linux is to hardlink the installed files
  to the cache (not looked at here), so a test that wrote into pi's
  installed files in place could change the cache. None does.

No assertion in the pi tests goes red when the cache is taken out: they
pass either way while npm answers inside their 4 minutes. What
regresses is the fetches, counted below; the times move with npm.

What was run (tree 93b344b1, on origin/main acdc85ac, go1.26.8,
linux/amd64, Linux 5.15, umask 077):
- npm's registry through a local relay (BUN_CONFIG_REGISTRY, Bun 1.4.2)
  that passes every request on at once and logs it, with `go test -tags
  nogui -count=1 -v -run <tests> ./internal/plugin/`, load 16 to 26,
  the cache folders removed first:
  - TestPiPackage alone: pass, 29.38s, 118 tarballs asked (no
    manifest). Run again: pass, 1.13s, nothing asked.
  - Then TestGatewayHookMixedPiPackage and TestPiPackage: pass, 0.92s
    and 1.04s, nothing asked.
  - Two TestPiPackage runs started at once: both pass (227.40s and
    115.58s), with every tarball asked twice (236 asked, 118
    distinct). A run after them: 1.13s, nothing asked.
- Broken by hand:
  - The cache not given to the install (the home's cache, as before
    this commit), the folder left full: TestPiPackage passes in 141.92s
    with 118 tarballs asked again.
  - One file of pi-coding-agent's cached package taken out, as a temp
    cleaner would: TestPiPackage red in 0.49s, nothing asked,
    `@earendil-works/pi-coding-agent isn't installed: add it as a
    plugin's dependency, or reinstall the pi plugin`.
  - The folder's name without its period: TestPinnedPiCacheMovesOn red,
    `after two days the cache is ".../magpie-test-bun-cache-<uid>-0",
    not a folder other than ...`. Older folders kept: red, `a folder
    four days old is kept (<nil>)`.
- go test -tags nogui -count=1 -timeout 45m ./internal/plugin/ (Bun
  1.4.2, npm direct): ok, 341 PASS lines counting subtests, 2 skip
  (TestFlowBigReplyProd wants MAGPIE_FLOW_BIG, TestRenewOtherHost is
  run by TestRenewOnceAcrossHosts). TestGatewayHookMixedPiPackage
  9.88s, TestPiPackage 1.08s.
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
  vet for windows, go build -tags nogui for linux and darwin and go
  build for windows: exit 0 each. go vet and go build without the tag
  on linux: exit 1 (no libsoup-3.0 or gio-unix-2.0 here).
- Not run again at this tree: -race and the full suite. This tree
  differs from tree f2b71fdd only in pi_test.go and agent-wiring.md;
  at f2b71fdd internal/plugin passed with -race, and the full suite
  had 79 packages ok, internal/plugin among them, and 7 tests red in 2
  packages, each filed: agent TestInstalledVersion,
  TestCursorFolderFromTheEditorIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141); gui TestGatewayHeldByAContainer and
  TestGatewayFixQuitsOnlyAMagpie (#3649).

Not tried: macOS and Windows (their checks and cleaners were only
read), a run as root, a real temp cleaner, and the pi tests under a
load like yetone's.

Reviewed and run again by the maintainer at the stack's tree 45994757c
(this commit and the six beside it, on origin/main 90518de26), go1.26.8:
- mote (macOS, arm64): gofmt -l clean; go vet and go build for darwin,
  GOOS=linux -tags nogui and GOOS=windows (library, plugin, gui): exit 0.
  go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gui TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  internal/proc TestNoCommandBypassesProc (#4491), both red on main
  from b09349d17 and c59c547c5, in files this stack doesn't touch.
  go test -race -run 'TestWSL|TestTagged|TestPinnedPiCache' for
  library and plugin: ok.
- magpie-desktop (Linux, wsl-run; WebKit hangs on mote), Chromium and
  WebKit: every library-*, sync-*, s3-sync, github-sync and i18n-keys
  file, 4 at a time: 1003 of 1020. The 17 reds are in 6 files no commit here
  touches: i18n-keys ("Unmarked", #4524), library-chip-fan, -items,
  -mcp-health, -mcp-hub (#4483) and -mcp-tools. Those 6 alone, one at a
  time, at load ~60: 74 of 92 here, 77 of 92 at 90518de26 itself. Red
  in both: i18n-keys, -chip-fan and -items in WebKit, -mcp-tools in
  Chromium ja 420; -mcp-health green in both; -mcp-hub's WebKit case
  red here only, the case #4483 has red on main. -chip-fan and -items
  are #3072's and #4501's kind, WebKit under load.
- On macOS (mote), the pi tests twice in a row: TestGatewayHookMixedPiPackage
  21.41s then 0.96s, TestPiPackage 1.23s then 1.24s, and
  TestPinnedPiCacheMovesOn ok: the second run installs from the kept
  cache. It sits in os.TempDir(), outside a test's HOME, by design.
- The stack rebased on origin/main e4c784177 (main's 7 commits since
  share only docs/subsystems/agent-wiring.md with it, a line apart),
  with no conflict: on mote gofmt -l, go vet (linux nogui,
  windows), go test -tags nogui -count=1 ./internal/library
  ./internal/plugin ok and internal/gui's budget tests ok; on Linux
  sync-note-show and library-wsl-asleep, both engines: 92 of 92.
2026-10-31 17:03:55 +08:00
JoeyWu-tech 722ca104c0 library: the Subagents page lists a stopped WSL distro's agents, greyed (#4238)
While a WSL distro runs, the Subagents page lists its agents that take
subagents here (Claude Code, Codex and the rest of SubagentAgents) with
a greyed chip that says magpie gives subagents only to agents on this
computer, not yet to it in WSL. With the distro stopped, they were gone
from the page: subagentsView built its agents from the targets only, and
an agent in a stopped distro is no target (#3896).

As the commit before did for the Hooks page: subagentsView now also
lists each stopped agent of those kinds that the MCP and Skills pages
list from its shape (asleepView), with the reason it has while the
distro runs (wslNoSubagents, which subagentSpecOf now shares), so its
chip, a subagent's problem for it and the "magpie can't give subagents
to ... yet" line are the same, stopped or running. Nothing of the
distro is opened. One magpie never saw (unseen) isn't listed.

No WSL agent can be given a subagent yet, so there is nothing to keep
for Woken. No change to the page; nothing new to translate. The line in
library.md that named the pages leaving a stopped distro's agents out
(#4182, #4237, #4238) is gone with this.

What was run (tree e03c52f0, on origin/main ec5571d6, go1.26.8,
linux/amd64, Linux 5.15, umask 077):
- TestWSLStoppedSubagents (new): the Subagents page's WSL agents read
  while a FakeWSL distro runs (Claude Code and Codex, the kinds it
  lists, each with the reason), then with it stopped and its folder
  moved away: the same two, field for field. A subagent given the
  stopped Claude Code has the same problem for it. Nothing was written
  into the distro and FakeWSLRuns didn't move.
- Broken by hand, each alone: subagentsView skipping the stopped agents
  ("... while it is stopped: map[], while it ran: map[claude@wsl:...]",
  and the subagent with no problem for Claude Code); the stopped agents
  listed with no reason ("No:" empty against the running ones', the
  same problem missing).
- library-wsl-asleep, its new Subagents case beside the Hooks one,
  Chromium and WebKit, en, zh, zh-TW, ja and de at 1100 and 390px: a
  subagent's chips are Claude Code and the stopped Codex, Codex's
  blocked, asleep, aria-disabled, with the WSL reason as its tooltip,
  the line names it, a click on it sends nothing. As for Hooks, the page
  isn't changed, so only TestWSLStoppedSubagents catches the gap.
- GUI files, each alone, Chromium and WebKit, Node 22.22.1, Playwright
  1.62.1, DISPLAY unset: library-wsl-asleep 44/44 each, i18n-keys 4/4,
  library-subagents 6/6, library-hooks 6/6, library-gone-agents 11/11:
  142 of 142.
- go test -tags nogui -count=1 ./internal/library ./internal/agent
  ./internal/cli: library and cli ok; agent red in TestInstalledVersion,
  TestCursorFolderFromTheEditorIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
  TestOmpDetectedWithPiDir
  (#3141). go test -race -run TestWSL ./internal/library: ok.
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
  vet for windows, go build -tags nogui for linux and darwin and go
  build for windows: exit 0 each. go vet and go build without the tag on
  linux: exit 1 (no GTK headers here).
- go test -tags nogui -count=1 -timeout 45m ./... (Bun 1.4.2; 9m49s,
  load 20 at its start): 78 packages ok, and 8 tests red in 3 packages,
  each filed: agent TestInstalledVersion,
  TestCursorFolderFromTheEditorIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141); gui TestGatewayHeldByAContainer and
  TestGatewayFixQuitsOnlyAMagpie (#3649); plugin
  TestGatewayHookMixedPiPackage ("starting plugins: context deadline
  exceeded", #2865, under load). The same suite on an origin/main
  ec5571d6 worktree right after (10m01s): the same agent and gui reds,
  test for test, and plugin ok there.

Not tried: a real distro, and the real app; FakeWSL counts the wsl.exe
-d commands run in the stopped distro (none).

Reviewed and run again by the maintainer at the stack's tree 45994757c
(this commit and the six beside it, on origin/main 90518de26), go1.26.8:
- mote (macOS, arm64): gofmt -l clean; go vet and go build for darwin,
  GOOS=linux -tags nogui and GOOS=windows (library, plugin, gui): exit 0.
  go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gui TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  internal/proc TestNoCommandBypassesProc (#4491), both red on main
  from b09349d17 and c59c547c5, in files this stack doesn't touch.
  go test -race -run 'TestWSL|TestTagged|TestPinnedPiCache' for
  library and plugin: ok.
- magpie-desktop (Linux, wsl-run; WebKit hangs on mote), Chromium and
  WebKit: every library-*, sync-*, s3-sync, github-sync and i18n-keys
  file, 4 at a time: 1003 of 1020. The 17 reds are in 6 files no commit here
  touches: i18n-keys ("Unmarked", #4524), library-chip-fan, -items,
  -mcp-health, -mcp-hub (#4483) and -mcp-tools. Those 6 alone, one at a
  time, at load ~60: 74 of 92 here, 77 of 92 at 90518de26 itself. Red
  in both: i18n-keys, -chip-fan and -items in WebKit, -mcp-tools in
  Chromium ja 420; -mcp-health green in both; -mcp-hub's WebKit case
  red here only, the case #4483 has red on main. -chip-fan and -items
  are #3072's and #4501's kind, WebKit under load.
- Broken by hand on mote: subagentsView skipping the stopped distro's
  agents turns TestWSLStoppedSubagents red.
2026-10-31 17:00:14 +08:00
JoeyWu-tech 0bd89a0237 library: the Hooks page lists a stopped WSL distro's agents, greyed (#4237)
While a WSL distro runs, the Hooks page lists each of its agents with a
greyed chip that says magpie gives hooks only to agents on this
computer, not yet to it in WSL. With the distro stopped, they were gone
from the page: hooksView built its agents from the targets only, and an
agent in a stopped distro is no target (#3896). So a hook's chips, and
the "magpie can't give hooks to ... yet" line, changed with whether WSL
was running.

hooksView now also lists each stopped agent that the MCP and Skills
pages list from its shape (asleepView), with the reason it has while
the distro runs (wslNoHooks, which hookSpecOf now shares), so its chip,
a hook's problem for it and the line are the same, stopped or running.
Nothing of the distro is opened. One magpie never saw (unseen) isn't
listed, as on the other pages.

No WSL agent can be given a hook yet, so there is nothing to keep for
Woken: the issue's "write a change once the distro runs" has no change
to write until hooks reach WSL. No change to the page, which already
greys a chip whose agent has `no` set; nothing new to translate.

What was run (tree fb979055, on origin/main ec5571d6, go1.26.8,
linux/amd64, Linux 5.15, umask 077):
- TestWSLStoppedHooks (new): the Hooks page's WSL agents read while a
  FakeWSL distro runs (Codex, Claude Code, Pi and OmO, each with the
  reason), then with it stopped and its folder moved away: the same
  four, field for field. A hook given the stopped Codex has the same
  problem for it. Nothing was written into the distro and FakeWSLRuns
  didn't move.
- Broken by hand, each alone: hooksView skipping the stopped agents
  ("... while it is stopped: map[], while it ran: map[claude@wsl:...]",
  and the hook with no problem for Codex); the stopped agents listed
  with no reason ("No:" empty against the running ones', the same
  problem missing).
- library-wsl-asleep, its new Hooks case, Chromium and WebKit, en, zh,
  zh-TW, ja and de at 1100 and 390px: a hook's chips are Claude Code and
  the stopped Codex, Codex's blocked, asleep, aria-disabled, with the
  WSL reason as its tooltip, the line names it, a click on it sends
  nothing. The page isn't changed, so this case pins what it draws from
  hooksView's answer and can't go red by a break in the Go code: only
  TestWSLStoppedHooks does.
- GUI files, each alone, Chromium and WebKit, Node 22.22.1, Playwright
  1.62.1, DISPLAY unset: library-wsl-asleep 33/33 each, i18n-keys 4/4,
  library-hooks 6/6, library-gone-agents 11/11: 108 of 108.
- go test -tags nogui -count=1 ./internal/library ./internal/agent
  ./internal/cli: library and cli ok; agent red in TestInstalledVersion,
  TestHowInstalled, TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
  TestOmpDetectedWithPiDir
  (#3141, a set that varies from run to run;
  three of them red at origin/main ec5571d6 in its suite too). go test
  -race -run TestWSL ./internal/library: ok.
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
  vet for windows, go build -tags nogui for linux and darwin and go
  build for windows: exit 0 each. go vet and go build without the tag on
  linux: exit 1 (no GTK headers here).

Not run at this tree: the full go test ./..., which ran at the
branch's last commit. Not tried: a real distro, and the real app;
FakeWSL counts the wsl.exe -d commands run in the stopped distro
(none). Not changed: the Subagents page (#4238, the next commit).

Reviewed and run again by the maintainer at the stack's tree 45994757c
(this commit and the six beside it, on origin/main 90518de26), go1.26.8:
- mote (macOS, arm64): gofmt -l clean; go vet and go build for darwin,
  GOOS=linux -tags nogui and GOOS=windows (library, plugin, gui): exit 0.
  go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gui TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  internal/proc TestNoCommandBypassesProc (#4491), both red on main
  from b09349d17 and c59c547c5, in files this stack doesn't touch.
  go test -race -run 'TestWSL|TestTagged|TestPinnedPiCache' for
  library and plugin: ok.
- magpie-desktop (Linux, wsl-run; WebKit hangs on mote), Chromium and
  WebKit: every library-*, sync-*, s3-sync, github-sync and i18n-keys
  file, 4 at a time: 1003 of 1020. The 17 reds are in 6 files no commit here
  touches: i18n-keys ("Unmarked", #4524), library-chip-fan, -items,
  -mcp-health, -mcp-hub (#4483) and -mcp-tools. Those 6 alone, one at a
  time, at load ~60: 74 of 92 here, 77 of 92 at 90518de26 itself. Red
  in both: i18n-keys, -chip-fan and -items in WebKit, -mcp-tools in
  Chromium ja 420; -mcp-health green in both; -mcp-hub's WebKit case
  red here only, the case #4483 has red on main. -chip-fan and -items
  are #3072's and #4501's kind, WebKit under load.
- Broken by hand on mote: hooksView skipping the stopped distro's
  agents turns TestWSLStoppedHooks red.
2026-10-31 17:00:14 +08:00
JoeyWu-tech 4ff086d1fb library: the Instructions page lists a stopped WSL distro's agents (#4182)
With a WSL distro stopped, the Instructions page listed none of its
agents: instructionsView built its rows from the targets only, and an
agent in a stopped distro is no target (#3896). So Claude Code, Codex
and the rest in WSL couldn't be switched on until the distro ran. And a
switch on the page sent the agents the page listed, so switching any
agent on or off while the distro was stopped took its agents off the
set, and the next sync once the distro ran took magpie's part out of
their files.

The same way c1da9ccda did it for the MCP and Skills pages: keepShape
keeps the instructions file's path in the shape (wsl.json, key
library:<kind>) while the distro runs. While it is stopped,
instructionsView lists its agents from that (asleepInstructions, asleep:
<distro>), switched on as library.json has them, with what each gets
besides, which is in magpie's own folder. The file itself isn't read:
its own lines, an edit to magpie's part and an override file aren't
known then, so the row says nothing of them, and Move its own and Write
again don't show. One switched on whose file magpie never saw (no path
in its shape, or a shape kept before this commit) is listed as unseen.
ReadInstructions, which the page reads after each instructions change,
lists them too, or the rows would go after the first switch. The TUI's
instructions picker sends the agents Read lists as on, so by its code it
had the same loss and keeps them now, with no change of its own (read,
not run).

A switch on one is kept in library.json, as any is. Takes accepts one
with a known file, so the CLI's `library instructions agents` records
it, and says on stderr that the distro isn't running (AsleepIn, as
before). Woken now watches a distro that Instructions.Agents names, or
whose agent still has magpie's part (Applied.Instructions), so a switch
on is written there once the distro runs, and a switch off is taken
out. Nothing is opened or run in the distro while it is stopped.

The page greys a stopped agent's row (icon as on the chips), shows its
path as text, not a button (showing it in Explorer opens the distro),
gives its switch the line's words as its tooltip and as the status after
a switch, and adds the one line per distro under the list
(asleepAsides, now given the page's own rows). An unseen agent's switch
is greyed out (aria-disabled), says why with the unseen chip's tooltip,
and sends nothing; every other switch keeps it on. No new strings: the
line, the unseen tooltip and "{agents} can be changed once it runs." are
c1da9ccda's, in en, zh, zh-TW, ja and de. The "keeps no user-wide
instructions file" line still leaves stopped agents out.

The MCP and Skills pages are the same, except that an agent seen with
an instructions file only (no MCP file or skills folder) now has a
shape: it is listed there as it is while the distro runs, among the
agents with no MCP servers or no skills folder, where before it was
listed only when unseen and named.

What was run (tree 7fd5f65a, on origin/main ec5571d6, go1.26.8,
linux/amd64, Linux 5.15, umask 077):
- TestWSLStoppedInstructions (new): Codex and Claude Code in a FakeWSL
  distro, seen running, then stopped with the distro's folder moved
  away. Both are on the Instructions page, asleep, at their files, Own,
  Edited and Override empty (Codex's AGENTS.md has a line of its own,
  counted once it runs), from Read and from ReadInstructions alike.
  Codex switched on while stopped is kept; Woken writes the shared text
  into its AGENTS.md once the distro runs. Stopped again and switched
  off, Woken takes the part out (the file is "Mine.\n" again). Nothing
  was written into the stopped distro and FakeWSLRuns didn't move.
- TestWSLStoppedInstructionsUnseen (new): Pi switched on in a distro
  stopped before magpie saw its file is listed on and unseen; Codex,
  never seen and off, isn't; Takes refuses it.
- Broken by hand, each alone, the two tests above run:
  instructionsView skipping the stopped agents: "a stopped distro's
  Codex isn't on the Instructions page", "Pi switched on while stopped:
  <nil>". distrosNamed without Instructions.Agents: "no sync once the
  distro ran" at the first start. distrosNamed without
  Applied.Instructions: the same at the second start, the switch off.
  ReadInstructions back on Targets(): "Read lists 15 instructions rows,
  ReadInstructions 11". Takes without instructions: "Takes while
  stopped: ... can be given instructions". keepShape without the path:
  Codex not on the page.
- library-wsl-asleep, its new Instructions case, Chromium and WebKit,
  en, zh, zh-TW, ja and de at 1100 and 390px: Codex's row greyed, its
  path a span, not the reveal button, its switch's tooltip the
  distro's line; Pi's switch aria-disabled with the unseen tooltip; one
  line naming the distro and Pi. A click on the path asks no reveal, a
  click on Pi's switch sends nothing, Codex switched on sends claude,
  Codex and Pi with the line as the status, and Claude Code switched off
  sends Codex and Pi. Broken by hand in the page, in Chromium: Pi's
  switch sending (all 10 red at the deepEqual of the posts with [] after
  Pi's switch is clicked), the path a reveal button again (all 10 red,
  tagName BUTTON for SPAN), no line (all 10 red, 0 .lib-asleep lines for
  1).
- GUI files, each alone, Chromium and WebKit, Node 22.22.1, Playwright
  1.62.1, DISPLAY unset: library-wsl-asleep 22/22 each, i18n-keys 4/4,
  library-instr-sets 3/3, library-instr-busy 6/6, library-linked-set
  11/11, library-alma-profile 6/6, library-gone-agents 11/11,
  library-items 9/9, library-mcp-hub 11/11: 166 of 166.
- go test -tags nogui -count=1 ./internal/library ./internal/agent
  ./internal/cli: library and cli ok; agent red in TestInstalledVersion,
  TestHowInstalled, TestCursorFolderFromTheEditorIsNotTheCLI,
  TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141, a set that varies from run to run;
  five of them red at origin/main ec5571d6 in its suite too). go test
  -race -run TestWSL ./internal/library: ok.
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
  vet for windows, go build -tags nogui for linux and darwin and go
  build for windows: exit 0 each. go vet and go build without the tag on
  linux: exit 1 (no GTK headers here).

Not run at this tree: the full go test ./..., which ran at the
branch's last commit. Not tried: a real distro stopped and started, and
the real app; FakeWSL counts the wsl.exe -d commands run in the stopped
distro (none). Not changed: the Hooks and Subagents pages (#4237,
#4238, the next commits), and the CLI's code for `library
instructions agents`, which already says on stderr that a stopped
distro's agent is written there once it runs.

Reviewed and run again by the maintainer at the stack's tree 45994757c
(this commit and the six beside it, on origin/main 90518de26), go1.26.8:
- mote (macOS, arm64): gofmt -l clean; go vet and go build for darwin,
  GOOS=linux -tags nogui and GOOS=windows (library, plugin, gui): exit 0.
  go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gui TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  internal/proc TestNoCommandBypassesProc (#4491), both red on main
  from b09349d17 and c59c547c5, in files this stack doesn't touch.
  go test -race -run 'TestWSL|TestTagged|TestPinnedPiCache' for
  library and plugin: ok.
- magpie-desktop (Linux, wsl-run; WebKit hangs on mote), Chromium and
  WebKit: every library-*, sync-*, s3-sync, github-sync and i18n-keys
  file, 4 at a time: 1003 of 1020. The 17 reds are in 6 files no commit here
  touches: i18n-keys ("Unmarked", #4524), library-chip-fan, -items,
  -mcp-health, -mcp-hub (#4483) and -mcp-tools. Those 6 alone, one at a
  time, at load ~60: 74 of 92 here, 77 of 92 at 90518de26 itself. Red
  in both: i18n-keys, -chip-fan and -items in WebKit, -mcp-tools in
  Chromium ja 420; -mcp-health green in both; -mcp-hub's WebKit case
  red here only, the case #4483 has red on main. -chip-fan and -items
  are #3072's and #4501's kind, WebKit under load.
- Broken by hand on mote, each red: instructionsView skipping the
  stopped distro's agents (TestWSLStoppedInstructions, "a stopped
  distro's Codex isn't on the Instructions page", and ...Unseen, "Pi
  switched on while stopped"); keepShape without Instructions (Codex
  not on the page); distrosNamed without Instructions.Agents ("no sync
  once the distro ran"). On Linux, client.js's asleep row back to
  pathLink with the unseen switch's guard gone: library-wsl-asleep's
  Instructions test red in both engines, 10 subtests each.
2026-10-31 17:00:13 +08:00
yetone 33a284497e plugin options: a switch a provider plugin declares is saved where the plugin reads it (plugins#550)
`magpie plugin options cursor '{"wire_trace": true}'` wrote the entry's
options in plugins.json (a middleware's ctx.options), while a provider
plugin's switches (auth.options, the editor's Plugin options) are read
from settings' PluginOptions (input.magpie.option). The command said
"options set" and Wire trace stayed off.

Now a key that the plugin declares as a switch for one of its providers
(from the providers last listed, else asked of the plugin host) goes to
PluginOptions for that provider, through settings.EditPluginOptions, and
a running host is handed it (SetProviderOptions, 5s, best effort). Only
true or false is taken for a switch. The other keys go to plugins.json
as before; set with switches only, a middleware's options stay, less a
switch written there before. `off` puts every switch back to the
plugin's default and clears plugins.json's options. Shown with no value,
each switch is listed with its value. docs/reference.md and the plugins
page (en, zh, ja) say so.

Run at this head on mote: go test ./internal/cli ./internal/settings
./internal/plugin ok; gofmt -l clean; go vet darwin and GOOS=windows ok;
Linux go vet -tags gtk3 in WSL (magpie-desktop) ok.
Broken by hand: no key read as declared, and both new tests went red
(PluginOptions empty, the old switch left in plugins.json).
Not tried: the real CLI against a running magpie with the Cursor plugin
installed; a plugin not listed yet (the host path) is not in a test.
2026-10-31 16:46:14 +08:00
yetone d83823d264 agent: a Claude Desktop Code tab session on WSL is told Desktop's window too (young02036)
young02036 on Discord: Claude Desktop 4.29.0 on Windows, a Code tab
session whose environment host is "WSL · Ubuntu", a magpie group of
Codex gpt-6.1-sol (500K) and Claude Opus 5.5 (1M) listed as
mythos-magpie-4247180078, and /context read "49.4k / 200k".

Cause: Desktop runs such a session on the distro's Claude Code, which
reads its user settings in the distro. Desktop 4.29.0's remote probe
reads them from `${CLAUDE_CONFIG_DIR:-$HOME/.claude}` there. Desktop sets
CLAUDE_CODE_MAX_CONTEXT_TOKENS only for Cowork (its bundle's one write of
it); a Code tab session gets the mythos-magpie id and no window. magpie
wrote Desktop's window, capabilities and Explore flag into Windows'
~/.claude/settings.json alone: desktopOn() was false for every
claude@wsl:<distro>. So the distro's Claude Code took the unknown id for
200K.

Fix: desktopOn() is true for a distro's Claude Code while this machine's
Desktop is on magpie (desktopSetsHere), so its Sync (desktopOnly when it
isn't on magpie itself, writeWindow when it is) writes the same values
into the distro's settings.json, and takes them out when Desktop leaves.
Turning Desktop on or off also syncs each running distro's Claude Code at
once; a stopped distro has no Sync (asleep) and is written on the first
catalog round after it starts.

Run:
- WSL (magpie-desktop, wsl-run), real Claude Code 2.1.289 in a sandbox
  HOME, `claude -p --model mythos-magpie-4247180078 /context`: no env in
  ~/.claude/settings.json gives "30.4k / 200k" and the unknown-model
  notice; CLAUDE_CODE_MAX_CONTEXT_TOKENS=500000 there gives "30.4k / 500k".
- New TestClaudeDesktopWSLContextWindow: a distro's settings.json gets
  1000000 and mythos-magpie capabilities with Desktop on, the user's
  model/theme kept, nothing before Desktop is on, all gone after it is off.
  mote and Windows (win-run) pass.
- Broken by hand: desktopOn returning false for a distro, the test is red
  ("the distro's window "", want glm's 1000000").
- win-run go test ./internal/agent -run 'TestClaudeDesktop|TestWSLClaude':
  only TestClaudeDesktopCarriesTheLanguage red, same at origin/main
  305c624ed on Windows alone (#4115).
- mote: go test -timeout 45m ./... at this tree (base 305c624ed):
  internal/agent ok (280s), 81 packages ok. Red, none touched here:
  internal/proc TestNoCommandBypassesProc (claudetui, #4491),
  internal/gui TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and the
  AppKit window tests killed at their deadlines on mote (#4125, #2645,
  #3949). GOOS=windows and GOOS=linux go vet ./internal/agent ok,
  gofmt clean.

Not tried: the real Desktop 4.29.0 on Windows with a WSL host session
end to end (the window read from the bundle and the distro's real Claude
Code, not a Desktop session); Claude Code 2.1.309 (the distro has
2.1.289). A session already open keeps the window it started with until
a new one starts.
2026-10-31 16:37:42 +08:00
yetone b52c39b65e routing: an account's row names the session it answers
connor_yang (Discord #help) asked that the Routing stage say which
session an account is serving next to its "answering…" / "answered this
request" status. The row now ends "· <title>", one line cut short with
the full title on hover, and only when the agent itself named that
session:

- Claude, Gemini and the other agents: sessions.Titles by agent:id, the
  same source the By session list heads use.
- Codex: its own name index (session_index.jsonl) by thread id.
- A Codex request whose parent the server inferred from prompt and
  reply fingerprints (parentMatched) shows nothing, since that parent
  is a guess. An untitled session shows nothing too.

Cost: no new server path. The titles come from the existing
/api/gateway/session-titles calls that refreshSessionNames already makes
every 15s and on focus. A session id the page hasn't seen is asked for
once (marked asked before the fetch, 300ms debounce, never two calls at
once), and the ask is skipped when a read since then already covered it
(namesDue). The per-second render only reads two maps. The title sits in
its own nowrap span, because the narrow stage (.max560/.max460) wraps
the status.

A Codex names reply silent on a session no longer clears the title
the trace brought. CodexTitles leaves unknown ids out, and returns {}
when the index can't be read, so the old loop turned a failed read into
"no title". With the earlier ask it also raced the trace: routing-sessions'
"title helpers belong to the named parent" went red 3 of 6 runs under
--test-concurrency=4 until this change, then 6 of 6 green.

Run:
- routing-session-title.test.cjs (new): engines x claude/codex x en, zh,
  zh-TW, ja, de x 1100/420px = 40 tests. Chromium 20/20 on mote.
  WebKit 20/20 on the Linux box (wsl-run, magpie-desktop). On mote even
  a bare webkit.launch() timed out at 60s under other sessions' load (21,
  67 pw_run processes), so WebKit there tested nothing.
- 16 nearby routing GUI files (answered-still, row-reuse, row-two-lines,
  stage-routes, sessions, reroute-title, tick-no-layout, live-patch,
  busy, served, js, steady, steady-garbage, session-folder, live-calm,
  request-model) in Chromium and WebKit on the Linux box, before the
  rebase onto 82b45888a. The reds that came back were compared with
  origin/main in a detached worktree:
  - routing-steady "requests coming in leave the routing groups" is red
    in both engines at main 03f609e3f (#3412).
  - routing-request-model's 5 WebKit cases are red at main 82b45888a,
    run alone (#4120 lists them).
  - routing-sessions "background memory groups" WebKit en is red at
    82b45888a, overflowing at 560px (filed #4538).
  - routing-sessions "title helpers" was mine; fixed above.
- After the rebase and the last edits, routing-session-title,
  routing-sessions, routing-session-folder and routing-rest-error
  (82b45888a's test, whose lines in client.js this change meets), three
  times per engine at --test-concurrency=4: Chromium 59/59 each time;
  WebKit 59/59 once, then 58/59 twice, the one red being #4538.

Broken by hand:
- titleOf without the parentMatched check (and the Codex name loop
  without it): the Codex cases go red, "a matched session's title is
  not shown".
- askUnnamed asking again on every pass: red, "asked 4 more times in 3s"
  (again on the final code).
- The silent-reply guard was not broken by hand on its own. What shows
  it is the title-helpers race above (3 of 6 red without it, 6 of 6
  green with it), not a deterministic test.

Not tried: a real app with a real agent's sessions, WebKitGTK in the
Linux app, and the whole GUI suite (it runs after the push).
2026-10-31 15:43:31 +08:00
yetone 7b09d2c951 provider: a model can be listed by an id of the user's at its provider, asked for by its own
zeewell on X (tweet 2116404121930432888): relays serve one model under
ids of their own (deepseek-v4.1-flash-1017, grok-4.6@500k). They want to
give each one their own id at the provider layer. magpie then lists,
routes, groups and finds groups by that id, and the upstream request
still carries the vendor's id.

Choice: a new per-model map, settings' ModelIDs
("<pid>/<local>": "<own id>"), served through the wire names that
already exist. ModelSameAs was not widened. It means "same as another
vendor's model": it lends specs and joins found groups. Making it rename
models everywhere would change every existing user's ids and refs.
ModelWires was not reinterpreted either, for the same reason. ModelIDs is
ModelWires turned round: a wire keeps magpie's id and changes the one
sent, and this keeps the one sent and changes magpie's. Settings.Wires()
merges each entry in as a wire name (wrapped by a "<pid>/*" wire). Every
place that sent a ModelWires name (gateway, usage ledger, request page,
UpstreamName, UpstreamNameAs) reads Wires(), so the upstream id needs no
new path. An explicit ModelWires entry for the same id wins.

- Listed by the local id: Available, liveIDs/liveByID, Serving and
  ListPrice translate through OwnModelID. /v1/models, agents' lists,
  Resolve, routing groups and found groups (auto/<local>, merged with
  every other provider serving that id) all see the local id.
- Only a provider of the user's own (Account == nil) takes one. An
  account's or a plugin's request is built from its list's id, which no
  wire reaches.
- Two variants of one provider given one id: the latest given it wins,
  and the earlier one is listed by its own id again. The CLI names it.
  The editor refuses two rows given one id in one save. A model of the
  provider's own id that a variant is listed by (plain grok-4.6 beside
  grok-4.6@500k) is not listed while the variant has it.
- The user's values are never overridden. SetModelID moves picks,
  contexts, fallbacks, groups' members/rules/fast/placed/off/weights/
  classifier/pick, the pickers' lists, every per-model setting
  (Settings.MoveModel) and gateway keys' models (provider.ModelMoved,
  set by access) to the new id, but only where nothing is under the new
  id yet. Agents' own files are not rewritten: an old provider/<own id>
  still resolves and is sent as it is. Group match patterns and key
  patterns stay as written.
- Key limits: a key held to either id passes for both (modelAllowed:
  the ref, OwnModelID, ListedModelID). Group members use the same check.
- Usage: model = the listed id, served = the vendor's id from its reply.
  The price is the own id's first.

CLI: magpie model id <provider/model> [<id>|--reset], magpie model ids.
GUI: Providers > a provider's editor > Names & levels > "Listed as",
beside Same as. It is staged with the editor's Save and taken back by
Restore default, in zh, zh-TW, ja and de. Accounts have no box.
Docs: providers-accounts.md, gateway-routing.md, and site start.html in
en, zh and ja.

Run (mote-run, at this tree rebased on 841326709):
- go test -tags nogui of internal/gateway, provider, settings, access,
  usage and cli: ok. internal/gui: ok but for
  TestSettingsSaveKeepsWhatItDoesNotSend's SearchAll, red on main since
  b09349d17 (#4514, yiqiui's patch); its ModelIDs case passes.
- TestAutoVisionDoesNotBuildListsAgain: 457 allocations with 4 models,
  458 with 400 (main 459), searcherModel within its 50. Reading
  Shared() per list cost 3041; SharedModelIDs parses only modelIDs once
  per file change, the settings path is built again only when what it is
  built from changes, and Serving looks up the own id only when a key is
  listed to some model.
- TestCoreScriptBudget: raised by 1,178 bytes for the Listed as box,
  with a note.
- gofmt -l clean; go vet, GOOS=linux and GOOS=windows go vet ok.
- GUI: provider-listed-as (en, zh, zh-TW, ja, de), provider-same-as,
  provider-detect in Chromium on mote and WebKit on the Linux box (mote's
  WebKit launch hangs, #4125): 9 of 9.
Broken by hand, each red: the wire name (wires), the list (list), a key
held to the own id (keyown), the key move hook (hook), liveIDs, liveByID,
moving refs (moverefs) and moving per-model settings (movemodel).
Not tried: a red for ListPrice's or Serving's own-id lookup; a real relay
with variant ids; Match patterns are not rewritten to the new id. The
full Go suite and the whole GUI suite are still running and their reds
get their own issues.
2026-10-31 15:04:44 +08:00
yetone 0407d69e84 provider: a group of Kimi models keeps always_thinking, dynamic tools and its default effort
jiabubu on Discord (#feedback): one Kimi Code model put in a routing group
so it lists first lost "always thinking" and "dynamic tool loading" in Kimi
Code, which the same model straight from its provider has. buildGroupEntries
never set AlwaysThinks, DynamicTools or DefaultEffort on a group (the Entry
comment said "a group has none of them"), so kimiModelTables wrote the
group's table without always_thinking and dynamically_loaded_tools, and
default_effort fell back to high.

groupSharedKimi now gives a group each of the three when every member's
entry says the same, and none of it when one member doesn't or has no
entry: a group request can reach any member (rule targets are members too,
ruledEntry's of()), so Kimi Code must not shape a request for a member that
can't take it. The capability words are Kimi Code 2.4.1's own
(catalog-runtime.ts capabilityFromDeclared), already written for direct
models; kimi-cli still gets neither.

Tests: TestGroupSharesKimiFacts (provider: all share, one without, efforts
differ) and TestKimiCodePlanCapabilities now writes a one-member group
"top" (the reporter's case: always_thinking, dynamically_loaded_tools,
default_effort max) and a group "mix" with a relay model (neither word).

Run on mote (mote-run, sandbox HOME):
- At 83a630d69 (on fbb1b36d1): gofmt -l internal/provider internal/agent
  clean; go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
  go vet ./... ok; go test -tags nogui -count=1 -timeout 45m ./...: every
  package ok but internal/gui TestSettingsSaveKeepsWhatItDoesNotSend
  (#4514) and internal/proc TestNoCommandBypassesProc (#4491). Both fail
  the same at origin/main 841326709, just fetched; neither touches this
  change.
- At the pushed head (rebased on 841326709): go test -count=1 -timeout 45m
  ./internal/provider ./internal/agent ./internal/catalog ok.

Broken by hand: without the groupSharedKimi call, both tests go red
(group/top loses always_thinking and dynamically_loaded_tools and gets
high). With "any member" instead of "every member", both go red
(group/mix and the mixed auto groups get the words).

Not tried: a real Kimi Code session picking the group (the words are the
ones real Kimi Code 2.4.1 already reads for direct models), Windows and
Linux test runs (vet only), nested groups.
2026-10-31 14:59:44 +08:00
yetone 8413267097 catalog: a list's image/jpeg is an image, so OpenCode Go's models that see take images again (zeo9901)
zeo9901 (CC01CC) on Discord #feedback: "magpie 中 opencode go 所有的模型似乎
都无法实现图片输入了". Their screenshot is a routing group of DeepSeek V4.1
Flash at Open Design and at OpenCode Go.

Cause: OpenCode Go's own /models (https://opencode.ai/inference/go/v1/models,
the same at /zen/go/v1/models) lists what a model takes as media types:
deepseek-v4.1-flash's modalities.input is ["text","image/jpeg","image/png",
"image/gif","image/webp"], Gemini's adds application/pdf and audio/*, and so
on. catalog's live-list reader took the list word for word and asked for
"image", found none, and recorded ImageInput = false, an explicit answer.
entryFor puts a list's explicit answer over models.dev's (which says
image), so with a working Go key every Go model was text-only: a direct
pick had its image described or turned away with "model does not support
image input", a group member was sent it described or not at all, and
agents were told the models take text only. It used to work while Go's
list spelt modalities as models.dev does, or said nothing.

Fix: catalog.Kinds reads a modalities list as models.dev words it
(image/* image, video/* video, audio/* audio, text/* text,
application/pdf pdf, each once, an unknown word kept, nil stays nil).
imageInput and the live reader's InputModalities/OutputModalities go
through it, as do Codex's input_modalities, the labs rows and a decision
provider's listed facts (decide.go). A list saved before this, still
holding Go's media types and false, is mended when read (mendKinds), so
a user sees images from the first read after the update, not the next
fetch. A user's own Accepts images answer still wins.

Which OpenCode Go models take images, per Go's list on 2026-10-31:
deepseek-v4.1-flash, kimi-k3, kimi-k3.1-pro, kimi-k2.7-code, glm-5.3-flash,
qwen3.8-max, qwen3.8-flash, qwen3.7-plus, minimax-m3, minimax-m3.1-flash,
mimo-v2.6-flash, mimo-v2.6-pro, step-5-preview, gemini-4-argon, grok-4.7,
gpt-6-luna, gpt-5.6-luna, claude-haiku-5-5, muse-spark-1.2/1.3-contributor.
Text only: deepseek-v4-pro, glm-5.2, glm-5.3, hy3, hy4-preview,
longcat-2.0, beam-free, iceman-contributor-free.

Tests (fixture: four rows of Go's real list, read without a key, no test
reaches the network):
- TestOpenCodeGoMediaTypesSee (catalog), TestKinds,
  TestSavedMediaTypesListSees, TestListedFactsMediaTypesSee (provider).
- Broken by hand: Kinds returning its input unchanged turns all four red
  (deepseek-v4.1-flash, kimi-k3, gemini-4-argon "Images false"); the
  mendKinds call taken out turns TestSavedMediaTypesListSees red.

Run on mote at the working tree on 82b45888a (origin/main 82b45888a plus this change):
- gofmt -l internal cmd: nothing.
- GOOS=linux go vet -tags nogui and GOOS=windows go vet of
  ./internal/catalog ./internal/provider ./internal/gateway: ok.
- go test -tags nogui ./internal/catalog ./internal/provider
  ./internal/gateway ./internal/agent -count=1 -timeout 45m: all ok
  (catalog 0.7s, provider 129s, gateway 665s, agent 203s).
  The docs paragraph was added after the run; no code changed since.
  The full go test ./... and the GUI suite were not run (no GUI file
  changed).
- Rebased onto ceeb73a0f (two commits outside catalog); at the rebased
  tree go test -tags nogui ./internal/catalog ./internal/provider
  -count=1 -timeout 45m: ok (catalog 0.8s, provider 98s).

Docs: gateway-routing.md, "A model that turns an image away".

Not tried: a real OpenCode Go request with an image (the only Go key here
has expired, and it isn't to be used). Not known: which agent and version
the reporter uses; Open Design's DeepSeek in the same group is a separate
provider and wasn't looked at.
2026-10-31 14:51:11 +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 fbb1b36d1f provider: the Claude keep-alive keeps off accounts, its reading, and its turn (#4532)
stringke read b48881f50 and 42c49e74d and left three notes on #4532
(issuecomment-6540015427). All three hold against the code:

1. Only accounts that were on were kept alive (claudeKeptAlive needed
   l.On). An account switched off as a reserve is still a sign-in the
   user kept for later, and Codex's keep-alive already renews saved
   ChatGPT sign-ins on or off. A run of Claude Code's /usage every eight
   days costs one local run and asks Anthropic nothing magpie doesn't
   already ask, so off accounts are kept too. Setup-token and signed-out
   accounts still aren't. The keep-alive never switches an account on.

2. The run's /usage reading was dropped (`_, err :=
   readSavedClaudeUsage`). The run now goes through the account's
   reading, the way a card's refresh reads a saved account:
   renewClaude forgets the account's minute-cached reading and calls
   loginReading with a keepingAlive ctx (asked, so nothing is held).
   claudeWindows runs Claude Code for it as for savedRefresh, past the
   30-second floor (the keep-alive is an hour apart at most), and keeps
   it in claudeUsage. loginReading keeps it beside the account and on
   disk (keepReading), and the new keepCardRead puts it on the account's
   card in the Usage cache with its history and the menu bar told, the
   way refreshCards does. A card the Usage page doesn't have isn't added.
   The run's own error comes back through the ctx, not the kept reading,
   so a failure is still told apart from a reading kept from before. This
   path doesn't bump the global ask generation, so Claude Code's own
   account isn't read again because of it.

3. A failed run held the hourly slot: still due, and with one renewal a
   look, the accounts after it never had theirs. A renewal that fails, for
   Claude and for Codex (the same loop had the same gap), now waits
   keepAliveRetry (6 hours, in memory) before the hourly look tries it
   again, and doesn't take the look's turn meanwhile. `magpie accounts
   refresh` (every 0) still tries it at once. A success clears it.

The help text, refreshAccounts' comment and providers-accounts.md say so.

Run on mote at 82b45888a plus this change: go test -timeout 45m
-count=1 ./internal/provider/... ./internal/cli/... ok; go test -race
-count=10 -run 'TestRenewLogins|WeeklyOnly|TestClaudeUsage'
./internal/provider ok; gofmt -l clean; GOOS=linux go vet -tags nogui,
GOOS=windows go vet and go vet of ./internal/provider/...
./internal/cli/... clean.

Broken by hand, each on mote:
- l.On put back in claudeKeptAlive: TestRenewLoginsKeepsSavedClaudeSignedIn
  ("renewed what wasn't due" with team@ missing), TestRenewLoginsKeepsClaudeReading,
  TestRenewLoginsFailedWaitsItsTurn and TestRenewLoginsLeavesClaudeSetupToken
  fail.
- renewClaude back to `_, err := readSavedClaudeUsage(...)`:
  TestRenewLoginsKeepsClaudeReading fails ("the account's reading: false").
- renewWaiting taken out of the loop: TestRenewLoginsFailedWaitsItsTurn
  fails at look 2 (the failed account took the turn again).

Not tried: real accounts and real Claude Code (fake runner, sandbox
HOME). The back-off is in memory, so a restarted magpie tries a failed
account on its first look. Codex's back-off is covered only through the
shared loop; there's no Codex-specific test for it.
2026-10-31 14:40:03 +08:00
yetone 03f609e3fd redact: a token count is not a secret (Discord, steven_4422; #3775)
steven_4422 in #feedback, with a screenshot of the Masking page: "total
number of tokens are masked as secret". Claude Code's system reminder
<total_tokens>1499872 tokens left</total_tokens> went upstream as
<total_tokens>{{SECRET_dkfgb3bf}} tokens left</total_tokens>, listed under
Secrets and found by the local model. #3775 had the same with AstrLink
Guard (<total_tokens>14902266).

Cause: the model labels the count `secret`; modelFits lets a hex run
(hexRe, which a run of decimal digits matches) through when secretCued
finds a key word right before it, and secretCued takes a cue anywhere in
the name before the value, with letters after it: the tag's name
total_tokens ends "token" + "s", so the count was "called a token". The
same held for "total_tokens": N, max_tokens: N and token_count=N.

Fix: a value of decimal digits alone that the model calls a secret is
masked only where the name right before it (then =, :, is, a tag's >,
quotes) ends with a key's, a token's, a password's or a PIN's word
(numberNamedSecret: api_key=, "token": , PIN:, user_pin=, 密码是,
<token>…). A name that runs on past the word counts what it names.
Rules are unchanged (numeric keys after key=/token: labels, phones,
ID numbers keep their own rules). The eval's token-count case now comes
out right for AstrLink Guard, so its #3775 marker is off.

Tests: TestTokenCountIsNoSecret uses the reporter's bytes in a Claude
Code user message's system reminder (the reporter's 7-digit counts, and
8-digit ones as Claude Code sends on a large window; the model's
len >= 8 secret check already let the 7-digit ones go, so the reporter's
exact values may have been 8 digits as read off the screenshot), plus a
usage object, max_tokens, token_count and "spin:". TestNamedNumber-
SecretStillMasked keeps api_key=, "token":, token is, PIN:, user_pin=,
password:, 密码是 and <token>…</token> masked.

Broken by hand: with model.go as on main, TestTokenCountIsNoSecret is
red for the 8-digit counts, total_tokens, max_tokens and token_count
(PIN:/user_pin= were not masked on main either; now they are).

Run (mote-run, base origin/main 93b31f5b7):
- gofmt -l clean; go vet ./internal/redact, GOOS=linux -tags nogui and
  GOOS=windows go vet ./internal/redact ./internal/masking ./internal/pii:
  clean.
- go test -timeout 45m ./internal/redact/... ./internal/masking
  ./internal/pii ./internal/otlp ./internal/sessions ./internal/settings
  ./internal/gui ./internal/gateway: all ok except
  - redact TestMaskEval: the token-count case's known issue was now
    fixed (marker removed, green after);
  - gui: TestCoreScriptBudget (green at 19594cc1c), TestSettingsSave-
    KeepsWhatItDoesNotSend (#4514, red on main, gui untouched here) and
    ten AppKit real-window tests killed at their deadlines on mote
    (#2645, #4125).
- Rebased on origin/main 19594cc1c: go test ./internal/redact/... ok,
  gofmt clean, TestCoreScriptBudget ok, #4514 still red there.

Not tried: the real local model (AstrLink Guard / Privacy Filter) on the
reporter's request; the gateway package was not run again after the
rebase (the commits in between touch usage, provider and the GUI).
2026-10-31 14:19:02 +08:00
yetone b48881f507 provider: keep idle saved Claude accounts signed in, by Claude Code itself (#4532)
#4532: a saved Claude account switched on but not needed for weeks
(switch-only) had nothing run on it, its refresh token sat idle, and it
was found signed out when the switch wanted it. Codex's saved sign-ins
already had a keep-alive (RenewLogins, every 8 days, one account an
hourly look).

The same loop now takes saved Claude accounts that are on, not Claude
Code's own, not added by setup-token and not already signed out
(claudeKeptAlive). For one that is due it has real Claude Code run
/usage in the account's own CLAUDE_CONFIG_DIR, the path a card's
refresh takes (readSavedClaudeUsage, inSavedClaudeDir), and
syncSavedClaude keeps whatever sign-in Claude Code refreshed. magpie
asks Anthropic nothing itself: no OAuth or usage endpoint, as removed in
9bf6d43527. A run that went through marks Renewed, so the account is not
run again for 8 days whether or not Claude Code rotated the token. A
refusal goes through NoteClaudeSignInFailure (and syncClaudeDir for an
emptied sign-in), so the row says to sign in again the way a request's
refusal does, and the keep-alive runs nothing more on it. A network
failure marks nothing. Anthropic's refresh-token idle lifetime is not
known, so the interval is Codex's conservative 8 days. The reading
itself is not kept as the card's cache.

`magpie accounts refresh` and its help say the Claude ones are renewed
too; providers-accounts.md describes it.

Run on mote at 93b31f5b7 (this tree): go test -timeout 45m -count=1
./internal/provider/... ./internal/cli/... ok; go test -race -count=10
-run 'TestRenewLogins|WeeklyOnly' ./internal/provider ok; gofmt -l
clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet of
./internal/provider/... ./internal/cli/... clean. The new tests also
passed with TZ=UTC and TZ=Pacific/Kiritimati.
Rebased onto origin/main 847f0c470 (a GUI-only change) and run again
at that tree on mote: provider and cli tests, gofmt, Linux and Windows
vet, all ok.

Broken by hand: with the Claude branch taken out of the loop's filter,
TestRenewLoginsKeepsSavedClaudeSignedIn and
TestRenewLoginsClaudeEmptiedSignIn fail ("renewed what wasn't due: []",
"emptied: []"); with the NoteClaudeSignInFailure call removed, the
refused case fails (Lapsed false).

Not tried: real accounts and real Claude Code; the tests use the
fake Claude Code runner and a sandbox HOME. Whether a /usage run makes
Claude Code refresh a token that is not near expiry is not known; the
run counts as the renewal either way. Left out (per #4532's scope):
per-model windows in the switch and caps, CLI commands, reset cards.
2026-10-31 14:15:52 +08:00
yetone 2eac916170 gateway: short-lived gateway keys, issued by POST /v1/magpie/keys or magpie gateway-key issue
xazaj on X is moving an enterprise LLM gateway onto magpie. Their
orchestrator gives each sandboxed agent a key of its own, and that key
has to stop working by itself.

A gateway key can now expire (Key.Expires) and can be issued under
another key (Key.Issuer). It lives from 1m to 30d. It can be held to a
set of models, a set of accounts, tokens or cost over its whole life
(one "hours" limit as long as its life), and read-only.

- POST /v1/magpie/keys {"ttl":"1h"|3600, name, models, accounts, tokens,
  cost, readOnly} answers 201 with the secret once, no-store. GET lists
  the caller's keys, masked. DELETE /v1/magpie/keys/{id} revokes one.
- magpie gateway-key issue --ttl 1h [--name] [--models] [--accounts]
  [--tokens] [--cost] [--read-only] [--from <id>] [--json] prints the key
  alone. gateway-key issuer <id> on|off lets a key issue keys. list shows
  until/expired/issued by.

Who may issue:
- a key the user let issue (Issues), from wherever that key is let in,
  so a container or CI can;
- with no key, a request that profileRefused passes: loopback, no
  forwarding header, no Origin/Sec-Fetch/Mozilla marks, a loopback Host.
  Such a request can already use every model with no key and run the CLI,
  so it gains nothing.
Never: a page, another computer without such a key, a key not let issue,
an issued or expiring key, or a read-only key (readOnlyGuard).

An issued key never outlives or exceeds its issuer. IssueKey clamps its
expiry and refuses models and accounts the issuer can't use. On every
authentication (access.Check, under Authenticate and On), identityOf
folds the key into its issuer as the issuer is now: models, accounts,
read-only, quotas and expiry. An issuer that is off, removed or expired
refuses its keys. Spend counts against the issuer too: the new usage
field callerIssuerId, budget.read/Append counting both keys, and Reserve
reserving on both. /v1/magpie/limit answers expires and issuerLimits.

An expired or refused key gets 401 with why ("… expired at …: ask for a
new one") on every route, from loopback too. Otherwise a held sandbox
whose key ran out would be let in as no key. Expired keys are pruned
after an hour (every 10 minutes while serving, and on each issue).
rowText packs CallerIssuerID: without it, usage.Visit returned the field
empty and the issuer's limit counted none of its keys' calls.

Docs: gateway-routing.md has "Short-lived gateway keys" and the
/v1/magpie stats API table. site/public/docs remote has "Short-lived
keys" and "Stats API" in en, zh and ja. GitHub OIDC is filed as #4531.

Run at base 07a3312c5 (origin/main, fetched just before):
- mote: go test -count=1 -timeout 45m on access, budget, gwbudget,
  usage, cli, gateway, davsync, agent: ok.
- mote: internal/gui fails TestCoreScriptBudget (#4526),
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and ten AppKit window
  tests killed at their deadline (#4125, #2645). The first three fail the
  same at origin/main 07a3312c5 on mote. This change touches no GUI file.
- mote: gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; go build; node --test site/*.test.mjs (49
  pass).
- win-run: access and budget ok. usage fails TestDesktopSessionAccountMetadata
  the same at origin/main (#1356). cli's TestLibraryMCPHub failed once on
  TempDir cleanup (#4140) and passed alone.
- Real binary on mote, sandbox HOME, port 47811: issued a 1m key with
  curl, read its limit, listed it, saw `gateway-key list` show "until",
  had a page's Origin refused 403, and after 62s /v1/models answered 401
  "the gateway key "sandbox-1" expired at …".

Broken by hand, each restored:
- no expiry check in Check: TestIssuedKeyExpires and
  TestIssuedKeyExpiresOnEveryRoute go red.
- no 401 for a refused key on loopback: TestIssuedKeyExpiresOnEveryRoute
  goes red (the expired key let in as no key).
- budget not counting CallerIssuerID: TestIssuedKeysSpendTheirIssuersLimit
  goes red (5 calls reached the upstream).

Not tried: a Responses WebSocket open across the expiry. The GUI shows
no expiry or issuer yet (issued keys look like plain keys until pruned).
A held issuer's /v1/magpie/usage shows its own rows, not its keys'. The
refused-key 401 doesn't count toward tooManyAuthFails. Issued keys sync
through davsync like other keys, with their expiry.
2026-10-31 13:44:29 +08:00
yetone 07a3312c53 library: sync and backup files carry the subagents
xixi_Sean_ on X asked why Sync leaves the Library's subagents out. There
was no reason: the library part of a bundle now carries them.

- library.Bundle.Subagents (*[]*Subagent): name, description, prompt,
  the skills and MCP servers named, the agents ticked. Collect always
  sets it, empty too. Applied.Subagents (which files magpie wrote here
  and their hashes) stays out: each computer writes the files into its
  own agents on the sync Put runs and records its own, so a file the
  user edited there, or one of theirs by the same name, stays theirs.
- Put replaces the subagents with the bundle's, so one taken out on one
  computer goes from the others. A nil list (a bundle from a magpie
  before this) is unknown and keeps this computer's.
- check refuses a subagent whose name isn't one (it is a file name in
  every agent) or comes twice; agent ids are carried as they come, so a
  newer magpie's tick for an agent this one can't give subagents to
  stays and writes nothing here.
- davsync: an empty list hashes as before the field, so upgrading with
  no subagents syncs nothing.
- backup files go through the same Collect/Put; the CLI's backup line
  counts subagents. The GUI's sync/export/import ticks say "instructions,
  MCP servers, skills and subagents" in every language.
- webdav-settings-refresh's "Agents" tick locator also matched the
  library tick's "subagents": it now asks for "Agents' models".
- library.md and sync-backup.md updated. Hooks still aren't carried.

Run (rebased on 0bf5adb11; Go runs at e0c57ffe2, same diff):
- mote: go test -tags nogui ./internal/backup ./internal/davsync
  ./internal/cli ok; ./internal/library -run 'TestCarry|TestSubagent|
  TestLocalServer|TestPutKeeps|TestPutSame|TestRestoreKeeps' ok
- wsl-run (Linux): ./internal/library ./internal/backup ./internal/davsync
  whole packages ok
- win-run (Windows): the same three, -run 'Subagent|TestCarry|TestLibrary|
  TestSyncLibrary' ok
- go vet -tags nogui for darwin, GOOS=linux and GOOS=windows on the four
  packages ok; gofmt -l clean
- GUI (wsl-run, Chromium + WebKit, every language): i18n-keys,
  github-sync, s3-sync, sync-auto-restore, sync-not-backup,
  sync-other-kind, sync-sign-in, sync-spin, sync-usage-error,
  webdav-settings-refresh, library-backups-top, gui-de, gui-ja,
  gui-zh-tw, settings-search, settings-sections: 170/173, then
  webdav-settings-refresh green after the locator fix. The one red left,
  i18n-keys "a plugin's words are its own" ("Unmarked" in
  plugins/routing/i18n.js), is on main already: #4524.
  mote ran five other GUI suites at load 18, where every WebKit
  github-sync case timed out at launch, so the GUI run moved to Linux.

Broken by hand: with Collect not setting Subagents and Put ignoring
them, TestCarrySubagents, TestCarrySubagentKeepsUsersFiles,
TestCarryNewerSubagents, TestBackupFileCarriesSubagents,
TestSyncSubagents and TestNoSubagentsHashAsBefore went red; with Put
treating a missing list as empty, TestCarryOldBundleKeepsSubagents and
TestBackupFileCarriesSubagents went red.

Not tried: a real WebDAV/S3/GitHub remote between two real computers;
the fake DAV server carries it between two sandbox HOMEs.
2026-10-31 13:14:16 +08:00
yetone 59546b3fdb gateway: Kimi Code's K3.1 Pro refusing reasoning none on Chat is asked again at its lowest (#3739)
7eleven.eth (Discord #feedback) hit "Kimi Code: K3.1 Pro does not
support disabled thinking mode. Please enable thinking and try again,
or choose another model." in ZCode. On Anthropic Messages, ZCode's
default format, this was fixed in 72e8d9fa6 (v0.1.2216): alwaysThinks
matches the wording, and the request goes again without
"thinking":{"type":"disabled"}, and without it from then on. The same
refusal on the Chat side was still handed back:

- a Chat client's reasoning_effort none, relayed (a ZCode provider set
  to OpenAI Chat, OpenCode's off variant): serve's retry for none
  matched only levels named, OpenRouter's mandatoryReasoning or
  effortRequired, and Kimi's words name no levels;
- a Responses or Chat client's none translated to Chat (Codex, Claude
  Desktop to a Kimi Code Chat endpoint): Kimi Code's catalog gives its
  toggled models none (reasoningOffProviders), so none went out, and
  forwardTranslated's retry read the same three.

needsReasoning is effortRequired, or for none and minimal alwaysThinks'
words, at both of those sites: asked again at the model's lowest
(onEffort), offRefused marked, so later requests go at it from the
start. Any other 400 still goes back as it came. Scoped by the
refusal's words, not by model name, so only a model that says it can't
stop thinking is changed.

Tests: TestKimiChatThinkingOffRefused (relayed and translated, Kimi's
literal sentence in Kimi's Chat error shape; turn 1 none then low, turn
2 low at once; a max_tokens 400 is not asked again).

Run (mote, macOS, Go 1.26.8, sandbox HOME by testenv):
- gofmt -l on the changed files: nothing.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./...: rc=0 each.
- go test -tags nogui -count=1 -timeout 45m ./... at this tree
  (0bf5adb11 + the change, origin/main unchanged since): 80 ok, two red.
  internal/proc TestNoCommandBypassesProc (claudetui/child_unix.go:32,
  #4491, untouched here) and internal/gateway
  TestRuleTimeWindowAtTurnStart ("a 5 b 2": a count changed between the
  check and its message; passes alone; filed #4528). Every thinking,
  effort, Kimi and mandatory-reasoning test in internal/gateway ok.
- Broken by hand: with needsReasoning back to effortRequired at both
  sites, both subtests fail with Kimi's 400 handed back; with only the
  translated site reverted, the translated subtest fails alone.

Not tried: the real Kimi Code endpoint (no account here), whether its
Chat endpoint answers none in these words (the Messages wording is the
reporter's; the Chat envelope is Kimi's usual {"error":{message,type}}),
a real ZCode session. Not changed: a Chat request with
"thinking":{"type":"disabled"} itself (no retry path reads it on Chat),
and #3739's second symptom (k3 losing thinking when
output_config.effort is asked).
2026-10-31 13:13:57 +08:00
yetone 79b4be4668 redact: a public IP goes as public-ip-<letters>, not a documentation address
akic404 on Discord (#feedback, 10-31): "ip的脱敏策略需要改进,会把公网ip直接
脱敏成内网ip,能不能沿用其他的方法用{ip:…}的代替". Since c2aad3db0 (10-28) a
masked public IP went as an address from RFC 5737's ranges (192.0.2.,
198.51.100., 203.0.113.). A 192.0.2. one reads as a LAN address to a
person, and every model knows the ranges: asked why ssh to the address
timed out, the models told the user they had an example address, not
their server's.

Now a public IPv4 or IPv6 address goes as public-ip- and eight lowercase
letters (public-ip-kvxqmrtz): visibly masked, still says it is public,
and a host name models ssh to. Same stand-in for an address every turn,
never shared, put back only as a whole name (no letter, digit, - or _
against it, no dot before it or before a name after it), in streamed
tool-call arguments too. A name with no dot reaches nobody if the vendor
tries it. A documentation address the user writes is no stand-in any
more, so it can't come back as someone's real address.

Run:
- Real models through the local gateway (deepseek-v4-pro, glm-5.3,
  kimi-k3, claude-sonnet-5-5, gpt-6-luna), two prompts each: "我的服务器
  是 X,帮我 ssh 上去看看磁盘" with a bash tool, and "阿里云服务器 X 从家里
  ssh 超时,是公网还是内网地址?最可能的原因?".
  - 203.0.113.147 / 198.51.100.147 / 192.0.2.183: ssh 5/5; diagnosis:
    4/5 (deepseek, kimi, gpt, glm) said "example address, use your real
    one", sonnet named it TEST-NET too.
  - {{IP_k3v9x2mq}}: ssh 0/5 (asked for the real IP, or grepped env);
    diagnosis fine.
  - public-ip-kvxqmrtz: ssh 5/5; diagnosis 5/5 security group or
    "public address", none said wrong/example address.
  - ip-kvxqmrtz (no "public"): ssh 4/5, but 4/5 called it an internal
    host name. Hence the public- head.
- On mote: gofmt -l, go vet ./internal/redact ./internal/gateway,
  go test -count=1 -tags nogui ./internal/redact ./internal/maskrec,
  and -run "Redact|Mask|Restore|IP|Privacy" ./internal/gateway: ok.
- Broken by hand: restoreAddr without its boundary check turns
  TestIPGoesAsAPublicIPName red; stand-ins made as 203.0.113.x again turn
  TestIPGoesAsAPublicIPName, TestIPv6GoesAsAPublicIPName,
  TestIPStandInsNeverShared and gateway TestRedactedKinds red.

Not tried:
- a real magpie build end to end with a real model (the gateway test runs
  the whole path against a fake upstream; the real models saw the
  stand-in text itself);
- the full suite, and Linux/Windows vet (no OS-specific code touched);
- an agent that resolves host names through a DNS search domain would
  look up public-ip-x.<domain> if a stand-in ever came back unrestored.
2026-10-31 11:48:21 +08:00
yetone e6b851b0fe update: magpie update in a terminal restarts the app with its gateway handed over
gaubeebangeel on X has an agent run the magpie upgrade at 4am and had
to give that agent its own provider: magpie couldn't serve it through
the upgrade.

Cause: `magpie update` put the new version in and printed "quit and
reopen magpie to use it" (a .app) or "updated to X" (a binary). The
running app never restarted, so the agent (or the user) had to restart
it by hand, and a plain restart closes the port and drops streams.

Measured before, on mote, a sandbox HOME `magpie serve` with a fake
upstream streaming 61 chunks at 100ms, restarted by SIGTERM + start:
- the stream was cut at chunk 15 of 61 (unexpected EOF); SIGTERM to exit
  took ~18ms, no drain;
- requests during the restart: 289 answered, 5 refused over 87ms.

Now `magpie update`, once the new version is in, POSTs it to the
running app's /v1/magpie/restart (gateway/restart.go). It is answered
only to a program on this computer over loopback; a LAN caller, a page
(Origin / Sec-Fetch) and another Host get 403. The updater's
restartBeside (gui/update_beside.go) restarts only when its own exe was
the one replaced (replaced() now also compares a .app's binary,
bundleExe), takes the version as ready without the feed, and runs the
same restart as Settings' AutoRestart: at once when it cuts nothing
short, else through waitIdle. On macOS and Linux that restart is the
existing SCM_RIGHTS handover, so the port never closes and in-flight
streams finish in the old process. The command prints what happened:
restarting (handing the gateway over), waiting for N requests, another
copy (current), magpie serve (unsupported), not running, or too old
(404: the first update into this version still needs a manual
restart).

Tests:
- TestUpdateInATerminalRestartsTheAppWithoutCuttingIt (darwin, linux):
  a stream through the gateway, the exe rewritten, magpie update's ask
  answered "restarting" with handover; the successor serves a request
  while the stream runs, the stream ends whole, the old one quits only
  after it. Red by hand with the route removed ("magpie update's ask:
  404").
- TestUpdateOfAnotherCopyLeavesTheAppBe, TestRestartAskedOnlyFromThisComputer
  (refused cases never reach the restarter), TestUpdateAsksTheRunningMagpieToRestart
  (each reply, a 404 magpie, none running).

Run at this tree:
- rebased on bdc1617be, at this head on mote: gofmt -l clean;
  GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...;
  go test -run 'TestUpdate|TestRestartHandsTheGatewayOver|TestHandoverNotMade'
  ./internal/gui ./internal/cli and -run 'TestRestartAsked|TestReadOnlyKey'
  ./internal/gateway: ok
- before the rebase (88ecae173), mote: go test -count=1 ./internal/gui ./internal/cli ./internal/gateway:
  gateway ok (535s), cli ok; gui FAIL only on filed reds: the real-window AppKit
  tests killed at their deadline on mote (#4125, #2645) and
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514), both red the same
  run alone at 88ecae173, and TestColdTurnsTaken (#4510, a race in
  full gui runs, not touched here)
- wsl-run (magpie-desktop, -tags nogui): TestRestartHandsTheGatewayOver,
  TestUpdateInATerminal..., TestUpdateOfAnother...: ok
- mote: gofmt -l clean; go vet gui/gateway/cli; GOOS=linux go vet -tags
  nogui ./...; GOOS=windows go vet ./...: ok

Not tried: the real GUI app end to end with a real `magpie update`
against a published release; Windows (no handover there: the restart
waits for an idle gateway and the port closes while the new version
starts, #4521); `magpie serve` / the daemon, which has no handover and
says to restart it the way it was started.
2026-10-31 11:39:04 +08:00
yetoneandggbdpq bdc1617bed routing: Accounts and keys count the whole day, not the last kept requests (#3351)
1234fsdc: the live Routing page's Accounts and keys said tried and
answered over the requests the page still keeps in memory, so on a busy
day the counts were a sliver of what Usage showed for the same accounts
and went down as old requests fell off. /api/trace/history (the read the
live page already makes every 15s) now carries `tallies`: per account or
key, today's tries, answers, fails by reason, models answered, the last
answer and the latest rest, read from routing/<today>.jsonl. The page
seeds the list with them and still takes the latest rest and readings
from the requests it keeps; a day looked at, or a purpose picked, counts
its own list as before. The note says "over today's requests" then.
Ported from ggbdpq's patch on the issue.

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

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

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

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

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-31 11:29:38 +08:00