Commit Graph
4 Commits
Author SHA1 Message Date
yetone 759b4d1d7d agents: a new user's list is folded under Get started (Renzexi01)
Renzexi01 on X (一进来就这么复杂): a new user saw Get started and, under
it, every agent found on the computer at once. While the Get started card
shows and no agent is in use yet, the whole Agents list is folded under
it behind "Show all {n} agents" (en, zh, zh-TW, ja, de); the card's
second step already names the agents found, each connected in a click.
Once one is connected, or the card is put away, the list is as before:
the ones in use in view, the rest under "Show {n} more".

getting-started checks the list folded under the card, the button's
words and aria-expanded in every language, and the list back once an
agent is connected or the card put away. Tests whose fake state is a new
user with no agent in use, and which read the agents' rows, now set
guideHidden as a user past Get started has (account-arrange,
aside-native, agent-*, claude-picker-magpie-first, codex-accounts-via,
omp-profile-connect, picker-rail-current, picker-speeds, pop-phone-room,
reasonix-roles, snow-fields).

What was run, on mote through mote-run, at a9a82a1c3 (tree e91b8e625,
the same as this commit once its fixup was squashed in), on base
0872bc2a0:
- The whole GUI suite (node --test --test-concurrency=4
  internal/gui/tests/*.test.cjs, both engines, every language), while
  mote ran 14 other test processes: 18901 pass, 292 fail in 57 files.
- Those 57 files again at a9a82a1c3 (concurrency 2): 748 pass, 275 fail;
  at 0872bc2a0: 756 pass, 267 fail. 43 files were red at both, most with
  the same counts (model-chip-steady 40/40, usage-agents-hide 22/22,
  segs-press-redraw 16/16, provider-fetch-again 14/14).
- Those 43 at origin/main e17b6cefc: 442 pass, 262 fail, the same files
  with the same counts. Each has an open issue (among them #4388, #4566,
  #3414, #5057, #5013, #4320, #4585, #4625).
- The 7 files red at a9a82a1c3 only, alone (concurrency 1): 79 of 82
  pass at a9a82a1c3 (group-found-skip 1, name-suffix-remote 2), 76 of 82
  at 0872bc2a0 (group-found-skip, images-codex-one 2, name-suffix-remote,
  title-bar-tools 2): load, nothing red at the head alone that is not red
  at the base alone. name-suffix-remote, red alone at both, is #5147;
  group-found-skip is #4617.
- getting-started and group-switch-add-many at a9a82a1c3: 64 of 64 pass.

Broken by hand: app.js and plugins/routing/client.js put back to
0872bc2a0 (tests and i18n kept), the same two test files: 30 of 64 red.
getting-started went red in all 30 of its "Get started ticks from state"
cases ("no agent row in view under Get started").

Not tried: the real app with a fresh HOME (macOS, Linux WebKitGTK,
Windows), and the tray panel beyond the test's panel layout.
2026-11-04 11:40:21 +08:00
yetone ce8b67de37 gui tests: a page's first load gets a minute, not a click's 5s (#4470)
claude-switch-only set page.setDefaultTimeout(5000) and then called
page.goto with no timeout of its own, so Playwright held the first load
of app.js, i18n.js and the plugins to the 5s bar meant for clicks. On a
busy box (a whole-suite run at load 130-160) that load took longer and
goto timed out. The same pattern is in 988 GUI test files (1174 pages):
every one of them now also sets setDefaultNavigationTimeout(60000) on
the same page, right after its default, so goto, reload and waitForURL
wait on the load itself with room, while clicks and waits keep their
short bar. group-from-model-add's own 20s navigation bar is raised to the
same minute. claude-switch-only also gives its first provider row (drawn
from the page's first reads) a minute before clicking it.

nav-timeout.test.cjs (no browser) reads every GUI test file and names
each page given a default under a minute without a navigation timeout of
at least a minute, so a new file can't bring the pattern back.

What was run (WSL magpie-desktop, Playwright 1.62.0, load 70-260 from
other sessions):
- node --check on every file in internal/gui/tests: all parse.
- nav-timeout.test.cjs against origin/main's test files: red (names the
  1174 pages); against this tree: its only reds were my own probe copies
  of the old files, since removed.
- By hand: claude-switch-only with app.js served 7s late (a busy box's
  first load), --test-name-pattern "1100 en": origin/main's file 4 of 4
  red with "page.goto: Timeout 5000ms exceeded"; this file 4 of 4 green.
- claude-switch-only.test.cjs, both engines, en/zh/ja/de, 1100 and 420:
  32 of 32. group-from-model-add, usage-access-key-card and i18n-keys:
  green. agent-plugin-agents: Chromium green; WebKit's de 420 subtest red
  on a 5s waitForFunction at line 115 (a wait after load, not the
  navigation), at load ~230.

Not tried: the whole GUI suite (about 1000 files; the change is one
mechanical line per page), Windows or mote (mote's browsers, #4125).
2026-10-31 02:09:18 +08:00
yetone d0fcb8bcdf agent: an agent uninstalled with its folder left behind shows "CLI not found" with no live settings, Hermes and the shared-folder agents too (#2177, mengyianx; #2173, SkyTodInfi)
Detection goes by an agent's folder, and an uninstall leaves the folder
behind. Before this commit, Hermes with only its 37-byte
~/.hermes/config.yaml (custom_providers: [], mcp_servers: {}) was listed as
installed in `magpie ls`, the GUI and the TUI, with model and effort pickers
that no program reads. CLIMissing (#843) covered only agents that have an
install command and their own folder. Hermes and the agents whose folder
something else keeps too (claude, codex, cline, opencode, goose) were never
gone.

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

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

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

Not covered:
- library.Targets (Skills/MCP) still lists a gone agent as a place to give
  skills to.
2026-10-14 22:50:46 +08:00
yetone 3e88fc09dc agent, gateway: Claude Code on a model Anthropic doesn't review gets auto mode's server review turned off, so it no longer says magpie isn't eligible (1EFLOPS on X)
1EFLOPS runs Claude Code through magpie on Codex's gpt-6.1-sol. In auto
mode, Claude Code 2.1.296 says "this session isn't eligible because your
requests go through 127.0.0.1:3425 ... ask your gateway to implement
https://code.claude.com/docs/en/auto-mode-classifier-billing".

What the page asks of a gateway: pass the anthropic-beta header
(dangerous-tool-use-2026-09-03), the request's `safeguards` field, and
`safeguard_results` in the reply through unchanged, and leave tool-use ids
alone. The results are verdicts from Anthropic's own safety classifier.
For a gateway that can't provide them, the page's remedy is
CLAUDE_CODE_AUTO_MODE_SERVER=0. Pro, Max and Team plans never see the
notice. In the bundle, Claude Code falls back on server_unsupported,
server_unavailable_disabled or server_no_result, and the notice shows
whenever there's no real verdict. Only that variable removes it.

Per route:
- Claude subscription bridge, Anthropic API key, relays in front of
  Anthropic, Bedrock and Vertex: already pass the beta, `safeguards` and
  `safeguard_results` through (e8cd4bac8, 8c21a4184). This commit doesn't
  change them. serverReview now uses the shared AutoModeReviewed rule
  (adding the subscription account, which never reaches serverReview).
- Codex/OpenAI and every other non-Claude model: magpie can't answer
  honestly. A verdict would be made up, and "unsupported" still shows the
  notice. So magpie answers nothing on Anthropic's behalf. Instead the
  Claude Code wiring writes env.CLAUDE_CODE_AUTO_MODE_SERVER="0" to
  settings.json. It does this only while Claude Code is routed through
  magpie and no model it can reach there is reviewed. That means checking
  the models shown to Claude Code (and Claude Desktop's while Desktop is on
  magpie), a shown group's members, those providers' fallbacks, and the
  models it is set to (claudeReviewed). If any one is reviewed, the
  variable stays unset, because /model can move the session onto it (the
  reason 8c21a4184 didn't write it at all). The value is rewritten on every
  model set and Sync, so adding a Claude provider turns the review back on.
  It is stash-tracked (claude.auto_mode_server): a user's own value is left
  alone, and magpie's goes on Disconnect, reset or a move off magpie.
- T3 Code (sibling): its magpie instance runs Claude Code on the gateway
  through its own environment, so it gets the same "0" by the models it
  lists.
Not covered: Claude Desktop's Code tab while Claude Code itself isn't
routed through magpie. Desktop users are on Pro/Max/Team, which never see
the notice.

Tests (each fails with its part of the change broken by hand):
- TestClaudeAutoModeReview: off on a non-Claude model; on with a Claude
  model shown, in a group or as a fallback; the user's "1" and "0" kept;
  dropped on reset and on a move to Claude Code's own model.
  A group that keeps its models out of the lists (#1783, Unlists) still
  routes to them, so its Claude member counts: members come from what is
  served, not from the catalog.
- TestT3CodeAutoModeReview.
- TestAutoModeReviewedRoutes: subscription, api.anthropic.com, relay,
  Bedrock and Vertex spellings yes; Codex, DeepSeek's Anthropic API,
  openai/gpt-6 and claudette no.
Mutations that went red: skipping group members, skipping fallbacks,
skipping an unlisting group, overwriting the user's value, not dropping it off magpie, always writing
it, the T3 env always or never, and the subscription not counted.

Real Claude Code 2.1.296, sandbox HOME/CLAUDE_CONFIG_DIR, magpie serve on
127.0.0.1:3591 under a scratch HOME, fake upstreams on 3593 (OpenAI Chat)
and 3594 (Anthropic):
- Before, on fakeai/fake-gpt, -p --permission-mode auto: the notice is on
  stderr (2 of 2 fresh config dirs). With the env in settings: none.
- With this build, `magpie claude fakeai/fake-gpt` wrote the "0", and a
  fresh run shows no notice. The same settings without it show the notice.
- `magpie provider add fakeanth anthropic=... models=claude-sonnet-5`:
  Sync took the "0" out. `magpie claude fakeanth/claude-sonnet-5` and a run
  in auto mode: the upstream got the dangerous-tool-use beta and
  `safeguards` on both turns, answered not_flagged in message_delta, and
  there was no notice.
Not tried: the Claude subscription bridge with a real account (its plans
don't see the notice), and a real Codex account (a fake Chat upstream
stood in for it).

Run: gofmt -l; go vet -tags nogui ./... for darwin, linux and windows;
go test -tags nogui ./... in a scratch HOME with the Go caches pinned.
The only red was TestOTelWaterfallIncludesUnbilledFallback, whose first
export was cut before the root span under load. That is #1794, filed
earlier today; this run is noted there. This change doesn't touch OTel.
internal/agent was timed against the unchanged base under the same load
and ran at the same pace.
2026-10-12 21:53:20 +08:00