Commit Graph
78 Commits
Author SHA1 Message Date
yetone 3a7d0314a9 usage: a window's Pace as a number on its card, and in the menu bar when asked (fflake33)
fflake33 on Discord asked for the pace as a figure, "+12%" or "−8%"
against an even pace through the window, on the Usage cards and in the
menu bar.

- provider: QuotaWindow.Pace(readAt, now) is the share used (0-100) less
  the share of the window gone by, from Bounds (reset less span; a
  month's window a calendar month); none for an unlimited window, one
  whose span or reset isn't known, or outside it. WithWindowStarts sets
  startsAt on copies of the cards for the GUI (the caches' cards are
  left alone); /api/usage/quotas and its refresh send it.
- Usage page: "Pace +20%" on the reset line after the wait (quotaPace,
  paceLine), its sign turned with the meter in Left mode, amber while
  more is used than an even pace would have, what it means in its
  tooltip. Past cycles and windows with no known start show none.
- Menu bar: Settings > Menu bar pace (settings.TrayPace, off by default;
  hidden on Windows, whose tray shows no text) puts " +12%" beside each
  figure ("42% −14%", at most 10 runes, trayRowMax) and "pace −14%" in
  the tooltip. KeepOwn keeps it device-local like the other tray
  settings; the Settings save keeps it (prefsKeep).
- Strings in en, zh, zh-TW, ja, de. gui-shell.md says it.

Run:
- go test -tags nogui ./internal/provider ./internal/gui ./internal/settings
  ./internal/usage: ok; ./internal/davsync: ok (now covers TrayPace;
  red with TrayPace taken out of KeepOwn). go test ./internal/gui -run
  Tray (darwin, with the tray image tests): ok.
- New TestWindowPace, TestWithWindowStarts (input not mutated),
  TestTrayUsagePace (off unchanged, used and left, rows, tooltip).
- quota-pace.test.cjs, chromium and webkit: 4 pass; cards in en, zh,
  zh-TW, ja, de at 1100 and 420px, used and left, amber, tooltips, no
  sideways scroll, a click moves nothing; the Settings row in all five
  at both widths, On posts trayPace, a currency save keeps it, no
  scroll; hidden with no card and on Windows, shown on Linux. Red with
  paceLine not called, with trayPace out of prefsKeep, and with the
  Left-mode sign not turned.
- gui-de, gui-ja, gui-zh-tw, i18n-keys: 12 pass; tray-bird 6, quota-holds
  2, quota-read-at 4 pass.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean.
Not tried: the real menu bar on a Mac or Linux tray.
2026-10-14 13:02:48 +08:00
yetone 2076943915 plugin: a plugin declares its own switches, shown in its provider's editor and read by the plugin (#2038, Vocllum)
Vocllum asked that a plugin can offer the user generic on/off options
without magpie knowing what each one is for. A plugin now declares them
on its auth hook, beside checkin:

  auth.options: [{ key, label, description?, default?, confirm? }]

and reads the user's values through input.magpie.option(provider, key)
or input.magpie.options(provider). Each call reads the current values,
so a change reaches the plugin without a restart. magpie only keeps the
value and hands it over: nothing is scheduled or run when an option
changes. The check-in switch (settings.pluginCheckins) and the check-in
plugins are unchanged.

- host.js: optionsOf keeps a key matching [a-z0-9_-]{1,40} with a
  non-empty label, drops repeats, caps the label at 60 characters and
  the description and confirm at 300, takes default only when it is
  true, and keeps at most 16. The values come at init and through
  setProviderOptions.
- Go: plugin.Option, Provider.Options, OptionOn and SetProviderOptions
  (sent only to a host that is running). settings.PluginOptions is kept
  by the plugin's provider id, then the key. POST
  /api/settings/plugin-option {provider, key, on} checks the key the same
  way and hands the values to the host. The generic settings save keeps
  them, as it keeps PluginCheckins. /api/providers' plugins[].options
  carry each option's resolved `on`.
- GUI: a "Plugin options" field in a plugin provider's editor. Each
  option is a segs Off/On beside the plugin's label and description, put
  in with textContent. A confirm text is asked through confirmAction
  before turning an option on. Changes wait for Save, which posts each
  one before the provider. Strings are added for zh, zh-TW, ja and de.
- Docs: provider-plugins.md (a new section), reference.md, gui-shell.md
  and the tests README.

Run:
- TestPluginOptions (a real host with testdata/options). Red with the
  old host.js (no options listed) and red with setProviderOptions turned
  into a no-op (the plugin still reads the old value).
- TestPluginOptionSetting and TestSettingsSaveKeepsWhatItDoesNotSend.
  Both red with the generic save's PluginOptions line removed.
- plugin-options.test.cjs: 22/22 in Chromium and WebKit, at 1100 and 420
  wide, in en, zh, zh-TW, ja and de. Red on the old app.js (no field).
  The screenshots were looked at: long text wraps and the page has no
  sideways scroll at 420.
- provider-concurrency, plugin-signin, plugin-checkin, provider-price-rate
  and plugin-move-unserved: 68/68.
- go test ./internal/plugin/... ./internal/settings/... ./internal/gui/...
  ./internal/provider/..., gofmt -l, and go vet on darwin, linux
  (-tags nogui) and windows.

Not tried with a real community plugin, since none declares options yet.
The check-in row doesn't take a plugin-declared label or hint; it is
left as it was.
2026-10-14 08:50:41 +08:00
yetone 8da304767a gui: Library is a plugin's page, its script, style and words in plugins/library
P2 of docs/subsystems/plugin-runtime.md, the second page after Sessions.

- library.js and library.css move to assets/plugins/library/ (client.js,
  library.css). The script registers with the kernel
  (magpie.plugin("library")) and adds its page to the "page" slot. Its
  hooks: open and relang load, redraw, close (its modal), dirty, discard.
  What it set up at load (list scroll and resize, the modal's backdrop
  and Escape, beforeunload, the stuck header, a quiet reload on focus)
  runs in mount.
- app.js calls those through magpie.call instead of window.loadLibrary,
  redrawLibrary, closeLibraryModal, libraryDirty and discardLibrary. It
  no longer lists library in its title map, hide loop or OPEN_VIEWS; the
  kernel's pages are in them.
- index.html: <main id="view-library"> goes, the kernel makes it.
  library.css keeps its place in the cascade.
- The 560 strings only Library says move from i18n.js to
  plugins/library/i18n.js (4 languages). i18n.js: 18826 → 16584 lines.
- plugins/library/library.go lists the client files.
- Tests that read i18n.js for a Library string read strings.cjs (i18n.js
  and the plugins'): 8 library tests and mcp-editor-cancel,
  mcp-oauth-app, mcp-signin-health. font-cascade, win-fonts and
  assets_revalidate_test.go name the new paths.
- "Check again" stays in i18n.js: Library said it alone when the words
  were split, and a5d72a095 (Settings' search keys) says it too since.
  i18n-keys has a new test, "a plugin's words are its own": a key in a
  plugin's i18n.js that any file outside the plugin's folder says fails
  it, naming the file. It was red on this key, and search-keys.test.cjs
  said "Check again" had no zh translation.
- docs: library.md, gui-shell.md, plugin-runtime.md.

Run, at this tree:
- 101 GUI test files touching Library, skills, MCP, the plugins, the
  shell and every language (gui-de/ja/zh-tw, i18n-keys, page-width,
  view-no-sideways, mobile-web, text-size, …): Chromium and WebKit, 4 at
  a time, all green but one. text-size's "zh: 100% picked at the foot"
  failed once in Chromium under load ("scrolled from 160 to 109 (max
  115)"); it passed alone, 6 at once here and on origin/main 8f34bbcd1,
  and at 6× and 12× CPU throttling. It's the Settings page, already
  "fixed" by 50dd39104, so I filed it as #2058.
- After rebasing onto origin/main 75cbc7e1e: i18n-keys, search-keys,
  library-mcp-tools, library-all, gui-de, mono-icon-redraw,
  group-first-token, Chromium and WebKit, green.
- go test ./internal/gui/ ./internal/pluginrt/ ./plugins/...; gofmt;
  go vet on darwin, GOOS=linux -tags nogui, GOOS=windows: clean.
2026-10-14 08:33:25 +08:00
yetone 1eaf1e890a gui: Sessions is a plugin's page, its script, styles and words under assets/plugins/sessions (P2)
The first page of P2 to leave app.js's core. sessions.js and sessions.css
move to assets/plugins/sessions/ (client.js, sessions.css). The page
registers through the kernel as magpie.plugin("sessions"): mount takes its
<main>, which the kernel now makes, open and relang read it again, and
reveal is the Usage page's way in. window.loadSessionsPage and
window.openSessionOnPage are gone. app.js reaches the page only through
magpie.call, and show() takes a page's title from its part. The plugin's
manifest lists i18n.js, sessions.css and client.js.

Words: the kernel's magpie.strings(dict) adds a plugin's words to I18N.
A key that is already there is logged and not taken, since the later one
would silently win. The 65 keys only the Sessions page says (own-keys over
every asset, Go and index.html) move, as written, from i18n.js to
plugins/sessions/i18n.js. tests/strings.cjs reads i18n.js and every
plugin's i18n.js as the page has them. gui-de/ja/zh-tw use it, and
i18n-keys now checks that no key is said twice across files and that a
plugin's words are in every language. TestBuiltinClientsLoaded takes a
.css entry as a <link> in <head>, and a script between kernel.js and
app.js.

Docs: plugin-runtime.md (Words, Pages moved out: Sessions), gui-shell.md,
gateway-sessions.md.

Run:
- go test ./internal/gui/ ./internal/pluginrt/ ./internal/gateway/: ok.
- gofmt clean. go vet darwin, GOOS=linux -tags nogui and GOOS=windows on
  gui, pluginrt and plugins: clean.
- GUI, in both chromium and webkit, 40 files, all green:
  - the sessions-* and sess-* tests, session-identity, routing-sessions,
    account-mask-sessions, usage-session*, gateway-conversations;
  - plugin-kernel, the plugin-move* tests, font-cascade, win-fonts;
  - i18n-keys, gui-de, gui-ja, gui-zh-tw.
- session-terminal's red under parallel load is the same on origin/main
  591ed58b5. It is fixed at its cause in the commit before this one.
2026-10-14 08:33:24 +08:00
yetone 2d8f2a86a5 sessions: Kimi Code sessions open as a transcript (#2056)
infinitr0us: a Kimi Code session on the Sessions page had no transcript
to open. HasTranscript now lists kimi, and kimiTranscript reads the
session's main wire.jsonl:
- protocol 1.4/1.5: turn.prompt and turn.steer (a prompt not from the
  user, a skill's activation or a background task's news, is folded as
  context), and the loop events content.part (text, think), tool.call
  and tool.result, a result named for its call. These are there for
  every session, finished or running; agent.message.appended (1.5, only
  at a turn's end) and the timed context.append_message records say the
  same again and are passed over.
- kimi-cli imports (1.0, and the head of a ses_* session Kimi Code
  reopened): the untimed context.append_message records, with an
  assistant's toolCalls in both shapes (name/arguments and OpenAI's
  function.{name,arguments}).
Search and markdown export read the same parts.

Run:
- TestKimiCodeTranscript on the #1607 reporter's wire files in testdata
  (1.4, a cancelled 1.4, an early 1.5 started by a skill, a failed 1.5,
  a kimi-cli import), and TestKimiCodeTranscriptOrder on a synthetic
  file in the same record shapes, exact part order plus SearchSession.
- Broken by hand: kimi out of HasTranscript fails both tests; reading
  the timed context.append_message records fails both (user/text 9,
  not 3).
- A nogui build's `magpie web` under a sandbox HOME, KIMI_CODE_HOME on
  the reporter's whole zip (8 sessions, the July subagent session and
  a reopened ses_* among them): all 8 listed with a transcript;
  /api/sessions/transcript gave 105, 13 and 205 parts for June, the
  reopened ses_* and July; the markdown export worked.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows;
  go test -tags nogui ./internal/sessions/ ./internal/gui/.

Not tried: a live Kimi Code session on this machine (none here; the kimi
installed is kimi-cli 1.52.0), the GUI's look of the transcript, WSL.
A subagent's own wire file isn't shown; the main agent's is.
2026-10-14 08:28:52 +08:00
NorethSea 56fcd1dc27 usage: each account picks a recorded allowance cycle beside its curve, meters and legend following it (#2009, NorethSea)
Let each account choose completed cycles beside its allowance curve. The
meters, sampling dates, plot and legend follow that cycle. Missing readings
stay unknown, and current account actions and whole-window estimates are
not presented as historical data. Fixed-deadline refills preserve cycle
boundaries alongside natural and early resets.

Keep the upstream whole-window estimate for the current view; no separate
price endpoint or duplicate estimation is added.

Verified on the integrated tree based on origin/main a75de4c2:
- 155 allowance, translation and scroll UI tests pass in Chromium/WebKit.
- Quota history race tests pass with count=3.
- macOS/Linux/Windows vet and builds pass.
- New Go cases fail without the unchanged-deadline refill handling; the UI
  case fails against upstream assets because the picker is absent.
- Real local allowance snapshots confirm cycle and meter switching.
- Full Go suite has one failure: TestPluginModelListThroughAccountProxy
  exceeds its context deadline. Other packages, including provider, usage
  and gui, pass. No release or complete-suite pass is claimed.

Reviewed and landed by yetone's agent from NorethSea's commit 69021d2c8,
cherry-picked onto origin/main (README conflict only: both appends kept).
Run at this head: go test -tags nogui ./internal/provider -run Quota,
-race -count=3 -run QuotaHistory, gofmt, GOOS=linux/windows go vet;
TestQuotaHistoryUnscheduledResets goes red with the refill rule removed.
GUI: quota-*, usage-*, balance-*, panel-usage, tray-*, click-scroll,
i18n-keys, gui-ja/de/zh-tw in Chromium and WebKit: 923/926; the three
reds are usage-sum-whole (also red 3 of 4 runs alone on origin/main
591ed58b5, #1864) and a usage-ledger case that passes alone.
2026-10-14 05:32:03 +08:00
yetone 2dcc51417e plugins: the window gets a plugin kernel, and the Gateway page is the first page a plugin draws (P1)
P1 of docs/subsystems/plugin-runtime.md. P0 (3ccbe6bc1) gave built-in
plugins a manifest, plugins.yml and a switch; their pages were still
app.js's own code. Now the window has a kernel a plugin draws its page
through, and the Gateway page moved into plugins/gateway to prove it.

What changed:
- internal/gui/assets/kernel.js (new): window.magpie. A plugin
  registers with magpie.plugin(id, setup); ctx.slots.add("page", part)
  puts its markup where index.html's <template data-slot="page"> is.
  The shell calls its hooks through magpie.call, behind an error
  boundary: a hook that throws, or whose promise fails, is logged and
  its page shows "This page stopped working", what broke and Try
  again, while every other page goes on. ctx.ui is the kit (button,
  switch, the app menu, a settings row) and ui.form draws a plugin's
  settings from their schema. ctx.config / onConfig carry the settings,
  from boot.js before the first paint and from Plugins › Built-in after.
- internal/pluginrt/schema.go (new): a plugin's settings are a Go
  struct (Manifest.Settings); SchemaOf makes the JSON Schema the form
  is drawn from, and Validate is what SetConfig (config.go) takes into
  plugins.yml. Compose drops a hand-edited value the schema refuses.
- plugins/gateway: the Gateway page as a plugin, Essential and in use
  while a gateway key is there. One setting, callsPage (10/20/50/100,
  20 by default). Its client is plugins/gateway/{keys.js,client.js},
  moved out of app.js (and caller-keys.js) unchanged in behaviour.
- internal/gui: builtins.go takes POST {id, config} beside {id, on}
  and lists each plugin's schema and config; boot.js carries
  pluginConfig; /plugins/<id>/… files are served. Plugins › Built-in
  draws a plugin's settings rows under its switch.
- Docs: plugin-runtime.md has "The window's kernel (P1)"; gui-shell.md,
  subsystems/README.md and tests/README.md updated.

What was run:
- go test ./... (sandbox HOME, pinned caches): all packages ok;
  gofmt -l clean; go vet on darwin, GOOS=linux -tags nogui and
  GOOS=windows.
- New tests: TestSchemaOf, TestValidate, TestSetConfig,
  TestBuiltinConfig, TestBuiltinClientsLoaded;
  plugin-kernel.test.cjs (a page that throws breaks only itself and
  Try again draws it, at 1100 and 420 in en, zh, zh-TW, ja, de;
  callsPage from boot.js and from Plugins › Built-in), both engines.
- Broken by hand, each turned its test red: the boundary's catch
  removed; Try again not putting the page's markup back; the Gateway
  page's onConfig not re-reading callsPage; boot.js's pluginConfig
  ignored; SetConfig skipping Validate.
- The full GUI suite in Chromium and WebKit (node --test *.test.cjs).
  One red was this change's own. providers-fetching-retry lifts
  providersWhileFetching out of app.js, which now asks providersPage,
  and the lift lacked it. The test now lifts that too, and gains "a poll
  under the Gateway page, a plugin's page that reads with Providers,
  reads". That case goes red with providersPage dropped from the poll's
  guard.
- The reds that were on origin/main a75de4c21 too are fixed in their
  own commits after this one. Two of them came from P0's Built-in tab:
  nav-sub-unroll and plugin-check-github-limit.
2026-10-13 20:39:39 +08:00
yetone db0af71864 gui: the menu bar can show today's or the last 7 days' tokens and cost (#1984)
Settings → Usage → "In the menu bar" lists two more rows after the
subscriptions: "Tokens and cost today" and "Tokens and cost, last 7 days",
ticked and saved as a card is (ids "usage:today", "usage:7d" in
trayUsages; provider ids are [a-z0-9-], so the prefix can't collide). They
show beside the allowances or alone.

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

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

Not tried: a real macOS menu bar, nor a Windows or Linux tray; the tray
tooltip is English, as the existing tray tooltips are.
2026-10-13 18:15:18 +08:00
yetone 6d7b440924 gateway: a request's ms end with its reply, not with what magpie writes down after it (#1939)
bytecode-x's full-suite failures (Millis 3772 for a stream that ended at
~450 ms; Flow 377, so DecodeOf's flow*HeldShare < window told 0/0) came
from after the reply: serve took call.Millis at its very end, after the
answered bookkeeping. answered() saves sticks and servedCandidate's
provider.NoteServed rewrites the last-answer file, both on disk. With
timing stamps added between the last content byte and call.Millis, 12
CPU burners alone gave at most 7 ms of tail (420 samples); with three
dd+sync writers beside them the block between "before served" and
"after served" took 0.7-1.5 s, the whole of the tail, while the stream
itself had ended. A user's busy disk meets the same: a paced reply reads
as one held back and shows no speed, and its duration grows.

- serve keeps `ended`, the time the last try's reply ended (when its Try
  is made), reset at each try; call.Millis is ended-start when a try was
  made, as before otherwise (a lane turn-away). The handed-on records
  of a refused try take try.Millis, the same end.
- decide_group's usage row is timed before servedCandidate, the same
  sibling.
- ttft_test's paced fixture left a leading "~" on its first event (it
  strips it only for i > 0), so those fixtures' first event was no SSE
  event at all (bytecode-x's second point): it now strips it without a
  gap.
- docs/subsystems/gui-shell.md says where a duration ends.

Run: TestSpeedEndsWithTheReply (new: holds sticksSaving for 2 s during a
paced reasoning stream; the request must still take >= 2 s, and its
Millis must not), TestReasoningSpeed*, TestBurstTellsNoSpeed,
TestCodexBackendBurstTellsNoSpeed, TestHiddenReasoning*, TestTTFT*;
full internal/gateway and internal/provider; gofmt -l; go vet darwin,
windows, linux -tags nogui.
Broken by hand: gateway.go's change reverted -> TestSpeedEndsWithTheReply
red ("the reply's ms 2001 count the 2s magpie took saving after it").
Not done: the bookkeeping itself still runs before serve returns, so a
client that waits for the response's end still waits for the disk;
moving those writes off the request path is a separate change. The
decide_group sibling has no test of its own.
2026-10-13 18:11:23 +08:00
yetone 3ccbe6bc15 plugins: a runtime for built-in plugins, and Plugins › Built-in to switch them (P0)
Lxxyx on X (https://x.com/Lxxyx_/status/2109506752656150974): magpie has
too much in it. This is P0 of making magpie's parts plugins, as DeepSeek
Harness does: a runtime, plugins.yml, and the first five built-in plugins
the user can switch off.

- internal/pluginrt: a registry (Register from init), a manifest (API
  caret range, Requires/Provides, Essential, InUse, Apply, Parts,
  Defaults) and Reconcile: the plugins no longer wanted, with whatever
  needs a service they provided, are disposed newest first; the wanted
  ones are applied once their services are there. A plugin that fails or
  panics is failed and the rest run. TestPluginsImportOnlyCore keeps the
  boundary: nothing outside plugins/ imports one, none imports another.
- plugins.yml (appdir.Config()): default → preset (essentials | all) →
  the user's rows → in use. A new install is written Essentials, a magpie
  that ran here before (settings.RanBefore) All, so existing users keep
  everything. Writes are locked, whole and keep a .bak; a file that
  doesn't parse is an error, never empty, and is never written over.
- plugins/groups, library, otel, sessions, warmups. In P0 a plugin off
  is the window's alone: its page, sections and rows (data-feature) leave
  the window; the gateway, TUI and CLI serve the same, nothing is
  deleted. One in use stays on.
- The window: Plugins › Built-in, the first tab, a switch per plugin;
  GET/POST /api/plugins/builtin; boot.js says which are off before the
  first paint. CLI: magpie plugin builtin [on|off <id>], plugin preset,
  plugin dump [--json].
- docs/subsystems/plugin-runtime.md, gui-shell.md.

Run: go test ./internal/pluginrt/ ./internal/settings/ ./internal/gui/;
gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows
go vet ./.... GUI: builtins.test.cjs in Chromium and WebKit, 5 languages,
1100/800/420; list-sort, mobile-web, routing-keys-fold, routing-sessions
pass. By hand under a sandbox HOME: a new install gets essentials, an
existing one all, a broken plugins.yml is refused and kept, dump works.
Full suite results after the rebase are in the push notes.
2026-10-13 16:19:13 +08:00
bingqilinweimaotai 1af326806f sync: magpie's setup syncs to an encrypted file in a GitHub repository, beside WebDAV and S3 (#1130)
A third sync kind: github://owner/repo[/folder] keeps the same sealed
backup WebDAV and S3 keep, as <folder>/magpie/magpie.magpie-backup in a
repository the user already has, written through GitHub's Contents API
with a fine-grained token of its own (Contents read and write), kept in
sync.json apart from the library's GitHub token. The token goes only to
api.github.com: a redirect anywhere else is refused, and the passphrase
may not equal it. Each update is a commit; an empty repository is
initialised by the first backup. Settings › Sync gets a GitHub kind with
Repository, Branch, Folder and token; magpie github mirrors magpie s3.
Inactive servers of every kind are kept in Config.Servers (Other stays
for older clients).

Squashed from yetone/magpie#1130 at 6b5b1c693e1a3a23e177b4d376f3f7f70f3bc23d
onto main. Merge resolutions: the CLI moved to internal/cli since the PR
was cut, so github_cli_test.go moved there (package cli) and the github
command, its help line and `magpie help github` were wired in
internal/cli/main.go and help_cli.go; README's Sync row kept main's
links and took the PR's wording; i18n.js zh-TW kept both sides.
2026-10-13 15:25:06 +08:00
yetone 1133ca0fe2 gui: the window opens on the page you last left, as a Mac app comes back as it was
molvqingtai on Discord asked for Routing to be the first page, and lc for
the sidebar to be reordered by drag. Rather than a setting or a reorder,
the window now reopens on the page the reader last left: show() keeps the
page in localStorage magpie.lastView, and keptView() opens it at start.

- A page asked for in the address (?view=: the tray's links, a reload)
  still wins, Agents too.
- A kept name that is no page opens the first page; one gateway mode
  leaves out (Agents, Library) opens Providers, through show()'s and
  setGatewayMode's existing fallback.
- localStorage is how the window already keeps magpie.navLayout and
  magpie.panelTab across restarts; checked on a copy of the installed
  app's WebKit store (~/Library/WebKit/com.yetone.magpie), which holds
  those keys from earlier runs.
- Opening on the kept page scrolls nothing.

docs/reference.md and docs/subsystems/gui-shell.md say so.

Run:
- internal/gui/tests/last-page.test.cjs (new), Chromium and WebKit, at
  1100 (sidebar) and 420 (header tabs): left on Routing, opened again with
  no ?view= and reloaded -> Routing, nothing scrolled; Settings kept;
  ?view=usage and ?view=agents win; an unknown kept name -> Agents;
  gateway mode with agents/library kept -> Providers, routing kept ->
  Routing. Broken by hand, it goes red: with show() not saving, with the
  kept page not restored, with the kept page beating ?view=, and with
  both gateway fallbacks removed.
- model-rate.test.cjs opened "/" after Providers and took it for Agents;
  it now asks for ?view=agents.
- 171 GUI files that navigate more than once or touch the start page
  (gateway-mode, sidebar*, nav-*, click-scroll, view-*, getting-started,
  side-toggle, panel-*...) plus 151 that open the bare root URL, both
  engines, 5-6 files at once: all green but model-rate (fixed above) and
  load flakes that pass alone here and on origin/main 1e8859838:
  sidebar-overlay-scrollbar (#1863), sessions-toolbar (#1426),
  agent-stale-copies and copilot-ghe (route callbacks outliving the page,
  filed as #1949).
- go test -tags nogui ./internal/gui, gofmt -l, go vet ./internal/gui on
  darwin, GOOS=linux and GOOS=windows -tags nogui.
2026-10-13 15:10:25 +08:00
Rupert-WLLP-Bai 81f587d7be sessions: omp's sessions in a WSL distro are listed on Windows, on the Sessions page and in Usage's Sessions tab, as Claude Code's, Codex's and Pi's there already are (#1150, #1138)
omp keeps its sessions under ~/.omp/agent in the distro's home, and in
a profile's own folder for omp --profile. wslAgents now names omp, and
allFiles reads wslFiles("pi", "omp"), so a distro's omp sessions show on
Windows marked with their distro and resume through wsl.exe. A session
under a profile resumes with omp --profile <name> --resume <id>; a
profile name that isn't plain ([a-z0-9][a-z0-9._-]{0,63}) gets no resume
command rather than one built from it (resumeCommand takes the session's
path for this).

Squashed from yetone/magpie#1150 at d7968f11b2ef419e30e1a6a169554b12e58c885a
onto main; docs/subsystems/gui-shell.md conflicted and keeps main's
"Streamed output speed" section and the PR's "Stored agent sessions in
WSL" section.

Run at this tree: gofmt; go vet darwin, GOOS=linux -tags nogui,
GOOS=windows; builds for all three; go test -tags nogui on
internal/sessions, internal/gui and internal/agent (agent with
-timeout 45m, it took 17 min on a loaded machine) green.
Broken by hand: with omp taken out of wslAgents, TestWSLSessionsListed,
TestWSLOmpSessionDeleted, TestWSLOmpProfiles, TestWSLStoppedDistroKept
and TestWSLStoppedSinceNotOpened go red.
Not tried: a real WSL distro with omp on the Windows box.
2026-10-13 13:49:16 +08:00
yetone 63a361b5ff gui: a plugin that took over Trae's, WorkBuddy's, MiniMax's or Qoder's check-in keeps that switch after a state refresh (#1912)
The previous commit reads the saved pluginCheckins map before
/api/settings' list, but /api/state has neither the list nor, for a
provider whose own switch was never set, a map entry. Such a plugin follows
the built-in check-in it took over (provider.PluginCheckinOn: traeCheckin
for trae-cn, workbuddyCheckin, minimaxCheckin, qoderCheckin), so a refresh
still drew it off while the scheduler kept checking in. pluginCheckinOn now
falls back to that built-in's switch, from PLUGIN_CHECKIN_INHERITS.

Run: plugin-checkin.test.cjs gains cases for the inherited switch in
/api/state's shape (red with the fallback removed) and a test that the map
names the same ids and settings keys as Go's PluginCheckinOn (red with an
extra entry); plugin-checkin, i18n-keys, gui-zh-tw, gui-ja, gui-de in
Chromium and WebKit: 32 pass. No new strings.
2026-10-13 12:58:32 +08:00
snowlie 762db7c5a2 gui: a plugin's saved auto check-in stays on after a state refresh (#1912, 1939323749)
Reported by 1939323749 with a custom provider plugin on Windows. Read the persisted pluginCheckins map before the derived settings-only list, preserving explicit false and the existing default fallback.

Verified plugin-checkin tests in Chromium and WebKit across en, zh, zh-TW, ja and de, plus all three translation GUI suites. The WebKit English Usage-card regression fails without the fix: saved auto check-in stays on after a state refresh (false !== true).

Reviewed and landed from the reporter's branch (755c1f0): with the old
pluginCheckinOn the new refresh assertion fails in WebKit for every
language; with it, plugin-checkin, i18n-keys, gui-zh-tw, gui-ja and gui-de
pass in Chromium and WebKit.
2026-10-13 12:58:32 +08:00
yetone 1d927bcfe9 gui: a copy nothing could make says so, with the text to copy by hand (#1881, BabyLy233)
copy() tried /api/copy, then navigator.clipboard.writeText, then the copy
command, and when all three failed it put the bare text in the footer
with no word that nothing was copied. Now that magpie refuses a copy it
can't read back (the commit before), that last case is reachable in the
app on Linux, so it reads "Couldn't copy. Select it here and copy it
yourself: <text>" as an error (role=alert, 8s) and the button isn't
flashed as copied. Translated in zh, zh-TW, ja and de. The order of the
tries and the success path are unchanged, on macOS and Windows too.

docs/subsystems/gui-shell.md: the host's copy row says how a Linux copy
is made and checked, and where the page takes over.

Run:
- tests/copy-fallback.test.cjs (new): /api/copy 204 (no page copy),
  501 + clipboard API, 501 + API refused + copy command, all refused;
  en, zh, zh-TW, ja, de; Chromium and WebKit: 40 pass. With the failure
  line put back to status(text), the 10 "nothing copies" cases go red.
- copy-command, key-copy, model-copy-id, library-mcp-copy-config,
  i18n-keys: pass.
- go test -tags nogui ./internal/gui: pass.

Not tried: WebKitGTK's own clipboard API and copy command inside the real
Linux app window when /api/copy refuses (the container run drove the
host's copy directly).
2026-10-13 11:13:24 +08:00
eryajf 88f237e91b gui: the Agents list's footer has Manage, to hide or unhide many agents at once (#1302, eryajf)
Users who use a few agents had to hide the others one row menu at a time,
and disconnecting doesn't help: most are unconnected already. The Agents
list's footer now has Manage beside the fold control (shown even when
nothing is folded). Its dialog lists every agent, folded and hidden ones
too, with search by name or id, select or invert the search results,
select the unconnected ones, and clear. Hide selected / Unhide selected
save one arrangement each through the existing POST /api/agents/arrange,
keeping the order and every agent outside the selection; a failed save
keeps the selection for a retry. While it saves, Done, Escape and the
backdrop can't close it, and a state read that left before the save can't
put the old arrangement back (agentsVisibilityRevision). Nothing connects,
disconnects or edits an agent's files; the tray panel is unchanged.
Strings in en, zh, zh-TW, ja and de. docs/subsystems/gui-shell.md says
how it works. mobile-web's desktop comparison leaves the new footer out
while the baseline hasn't it.

Squashed from PR head 2a24d59e onto main, without the PR's unrelated
parts: the plugins.js search redraw and its plugin-market test change,
the purpose-filter and redact-rule-row test workarounds (main fixed those
flakes at their cause), and a .warm-at input min-width. Conflicts: load()
keeps main's reads with the PR's revision guard, i18n.js and app.css keep
both sides, the gui-shell doc keeps main's window-corners note.

Run (both engines; every agent* test, gui-de/ja/zh-tw, i18n-keys,
mobile-web, panel-fold, library-mcp-tools, click-scroll): 516 pass. Two
webkit zh-TW agent-failover failures were ENOSPC launching the browser
and pass on a rerun. mobile-web's 1280 comparison and a narrow-width
measure in agent-bulk-visibility needed fixes, in the next two commits.
Broken by hand: without closeConfirmAsk's saving guard, "saving blocks
Escape and backdrop" fails (success and failure); without the
visibilitySince block in load(), "an older state read cannot undo a
completed bulk save" fails.
Not tried: the real app with real agents.
2026-10-13 10:41:51 +08:00
forever 2c31129692 gui: on macOS 26 the main window has a plain title bar's corners (TextEdit's, not Finder's), its traffic lights still in the header (waitingsnow) (#1042)
* gui: on macOS 26 the main window has a plain title bar's corners (TextEdit's, not Finder's), its traffic lights still in the header (waitingsnow)

From macOS 26 a window with a toolbar has larger corners than one with a
plain title bar: 26pt, Finder's, against 16pt for TextEdit or an
Electron app. The main window has an empty toolbar only to inset its
traffic lights into the page's header (Wails' MacTitleBarHiddenInset),
so its corners were a toolbar window's. On macOS 15 a toolbar doesn't
change them (12pt either way, measured on 15.8).

On macOS 26 and later plainTitlebar now takes the toolbar off
(insetLights, titlebar_darwin.go), and MagpieLights keeps the lights and
the title bar's 66pt height where the toolbar had them. AppKit lays the
title bar out again at its own 32pt after a resize or zoom, a new title,
a new appearance and leaving full screen; the lights are put back once
it is done, and AppKit's hover tracking is told where they went. Their
autoresizing mask keeps their distance from the top: AppKit draws a new
system appearance (light or dark, more contrast, less transparency)
before the run loop turns, which drew them 8pt above the window for one
frame. A sheet, such as the folder chooser, still begins below the title
bar (Wails' window delegate gets window:willPositionSheet:usingRect:,
which places this window's sheets only).

A first press while another app is in front still moves the window from
anywhere in the 66pt title bar, as AppKit moved it with the toolbar
(firstPress, a local mouse-down monitor). AppKit's own band is now a
plain title bar's 32pt; below it the page doesn't take a first press, so
the press would only have brought the window forward. A press on a view
that takes a first press (a traffic light, a resize edge) is left alone,
as AppKit leaves it.

The macOS version is asked at run time. go build and go test build the
cgo objects for the Mac's own macOS, where @available(macOS 26.0, *) is
compiled away: a test binary built so on 26.7.1 took the toolbar off on
15.8. An older macOS, the lights on the right (a right-to-left language)
or a title bar not laid out as expected keep the toolbar. Linux and
Windows are unchanged; the GTK 3 comment now says its corners stay
square.

TestMainWindowCorners (new; darwin, run by CI's macOS job) measures the
main window beside a plain and a toolbar window in a process of its own
(runAppKit, so WebKit's data stays out of the real ~/Library): once
shown, after a new title and size and a new system appearance, as AppKit
draws that appearance, a first press 20, 40, 60 and 70pt below the top
while no window is key, and where a sheet begins.
TestMainWindowRightToLeft launches it right to left. Both pass on macOS
26.7.1 (3 runs in a row), 26.6.2 (CI's) and 15.8 Intel, where the
toolbar stays. With each part taken out, they fail:
- the change itself: "corners of 26.00pt; a window with a plain title
  bar has 16.00pt, one with a toolbar 26.00pt";
- putting the lights back: "traffic light 1 at [16 16] (x, y from the
  top left), the toolbar had it at [26 26]";
- the height: "a title bar 32pt tall, the toolbar's was 66pt";
- the mask: "as AppKit draws a new system appearance, traffic light 1
  is at [26 -8]";
- the sheet's place: "a sheet on a short window begins 16pt below its
  top; below the toolbar it began 66pt";
- the press monitor: "a first press 40pt below the top, with another
  app in front, began 0 window drags; with the toolbar it began 1";
- the right-to-left check: "the traffic lights are on the right, and
  the main window's toolbar was taken off";
- the run-time check (@available instead), on 15.8: "a toolbar doesn't
  change the corners on this macOS, yet the main window's was taken
  off".
The presses are sent within the test's own process, and a drag is
counted, not begun; no system setting changes.

The real app on 26.7.1, built from this commit and driven through
Accessibility under a HOME of its own, has 16.25pt corners (26.50pt on
main) and its lights where main has them, through resize, zoom, light
and dark, a new title, full screen, minimise, close and show, a
maximised start, and the window lightweight mode makes again. A real
pointer and a key window's press were not tried. go vet, the three
builds and go test -tags nogui ./... pass.

* gui: where AppKit gives magpie the Mac's earlier design (an SDK before macOS 26's, or UIDesignRequiresCompatibility), the main window keeps its toolbar (waitingsnow)

The main window's toolbar comes off only in the design of macOS 26,
where a toolbar gives a window larger corners. AppKit gives a program
that design from macOS 26 when the program is linked against the macOS
26 SDK or a later one and its Info.plist doesn't set
UIDesignRequiresCompatibility; the last commit asked only for the macOS
version. A program linked against an earlier SDK gets the earlier design
on macOS 26 too: yetone's test binary (Go 1.26.3, Xcode 26.2) names SDK
11.0, and on 26.2 every window there had 12pt corners, yet the main
window's toolbar was taken off and TestMainWindowCorners failed at every
stage.

designOf26 now reads each at run time: the macOS version (NSProcessInfo),
the key (NSBundle) and the SDK the program names. The SDK is in
LC_BUILD_VERSION, or in LC_VERSION_MIN_MACOSX in a program that runs on
macOS 10.13, as go build links one for an Intel Mac. The header is read
through _NSGetMachExecuteHeader (crt_externs.h):
dyld_get_program_sdk_version is declared only in dyld's private header,
and it doesn't see the key (27.0 in a bundle that sets it, where AppKit
gives the earlier design). The comment no longer says go build builds
for the Mac's own macOS: the program names 11.0, and it is clang that
compiles the cgo code for the Mac's own macOS (ld: "built for newer
'macOS' version (26.0) than being linked (11.0)"), where
@available(macOS 26.0, *) would be compiled away.

TestMainWindowCorners now runs the windows' program twice, as linked
against the macOS 26 SDK and against macOS 15's (runAppKitSDK; stampSDK
rewrites the SDK in a copy and signs it again), so on macOS 26 it checks
both designs whatever SDK the toolchain names. In the earlier design it
checks that the main window keeps its toolbar. gui-shell.md says which
design gets the change, which SDKs the test runs with, why the key has
no test, and how to run it as for an Intel Mac.

Both subtests and TestMainWindowRightToLeft pass on 26.7.1 (arm64, 3
runs in a row, and amd64 under Rosetta), 26.6.2 (arm64, as CI) and 15.8
(Intel). With each new part taken out, its subtest fails:
- reading the SDK (designOf26 answering yes after the macOS and the
  key): "a toolbar doesn't change the corners in this design, yet the
  main window's was taken off", with macOS 15's SDK;
- 26.0 itself (> for >=): "corners of 26.00pt; a window with a plain
  title bar has 16.00pt, one with a toolbar 26.00pt", with the macOS 26
  SDK;
- reading LC_VERSION_MIN_MACOSX, or 26.0 there, built for amd64: the
  corners message, with the macOS 26 SDK;
- the macOS version, asked with @available instead, built on 26.7.1 for
  amd64 and run on 15.8: the toolbar message, with the macOS 26 SDK.
Taking out the last commit's parts fails the macOS 26 SDK subtest or
TestMainWindowRightToLeft as before.

UIDesignRequiresCompatibility is checked by hand, not in a test: AppKit
reads it from an app bundle's Info.plist, LaunchServices registers each
bundle that runs (and keeps a temporary one after it is deleted), and in
a process run from a bundle a press sent within it began a window drag
in only 3 of 12 runs. On 26.7.1 the test program in a bundle whose
Info.plist sets the key has 12pt corners like every window there, and
keeps its toolbar; in a bundle without the key it has 16pt and no
toolbar, as when run on its own. With the key's check taken out, the
toolbar is taken off although AppKit gives the earlier design. The
bundles were unregistered (lsregister -u) and deleted.

go vet, the three builds, go test -tags nogui ./... and go test
./internal/gui/... pass. The real app wasn't run again.

* ci: run the checks again (waitingsnow)

test (macos-latest) failed in TestRelayKeepsClientAlive (internal/gateway, 1 ping in a 150ms gap), a timing test this PR doesn't touch; it passes on main and 5 times of 5 locally.
2026-10-13 09:55:23 +08:00
liubing 1cd8140047 sessions: read Cursor editor history and Cursor/OpenCode conversations (#1743)
Discover editor project transcripts and cursorDiskKV histories without modifying the source. Share one SQLite/WAL snapshot across a scan, refresh metadata changes, deduplicate CLI histories, and reject deletion of read-only sessions.

Count message-only sessions and expose an all-dates action when a filter hides existing history. Read Cursor CLI text, reasoning and tool parts, and OpenCode v1/v2 transcripts through the existing transcript API.
2026-10-13 06:43:50 +08:00
yetoneandcongee949 296b63f8d6 usage, gateway: tests for the #1463 rebase: a priced row keeps its reasoning evidence, and a summary after an endpoint fallback stays hidden
Follow-up to congee949's rebased dfc24632
(#1463, streamed reasoning speed).

- TestPricedRowKeepsReasoningEvidence: the Requests page reads gateway rows
  through blockPricer, which sets swapKnown (64) on every row. The patch
  put ReasoningHidden on bit 64 too; on main that would have read every
  priced row as hidden, so a tool-only reply with no reasoning, and paced
  visible reasoning, lost their speed on the Requests tab. The rebase gave
  ReasoningHidden its own bit (256, Flags widened to uint16); this test
  prices visible, tool-only and hidden rows, raw and packed, and checks
  the flag and the speed read back.
- TestSummaryAfterEndpointFallbackStaysHidden: a Messages client, a model
  answered on /responses after /chat/completions said it isn't served
  there. call.To still reads Chat, so hidesReasoning(call.To) doesn't see
  the summary; only streamTranslated's summaryUpstream marking does. With
  no reasoning count the 1500 output tokens were otherwise timed from the
  first summary delta. Nothing covered that marking before.
- reasoning-speed.test.cjs: the "no reasoning: 500 in 5 s" comment had
  been joined onto the redacted row; put back on its own row.
- docs/subsystems/gui-shell.md: the flag bit, the fallback marking, the
  two tests.

Run: go test -tags nogui -count=1 ./internal/usage/ and the gateway's
reasoning tests; reasoning-speed.test.cjs in Chromium and WebKit (en, zh,
zh-TW, ja, de), 10/10.
Broken by hand: rowReasoningHidden = 64 turns TestPricedRowKeepsReasoningEvidence
red (visible and tool-only rows read hidden, 0 tok/s); summaryUpstream
forced false turns TestSummaryAfterEndpointFallbackStaysHidden red (1500
tokens in 314 ms).

Co-authored-by: congee949 <c86474321@gmail.com>
2026-10-13 06:43:50 +08:00
congee949 2d3b33bb78 usage: time tool-only replies only with visible reasoning evidence
Revises #1463 after the hidden-reasoning inflation review. Keep answers separate, retain evidence in routes and cached ledger rows, and exclude sealed or summary-only reasoning even without a token breakdown. Sync the backend and both GUI formulas.

Checked real WorkBuddy DeepSeek, Codex and Claude bridge responses in an isolated HOME; sanitized timings and failures are in docs/verification. Chromium/WebKit speed regressions pass (20 tests, five languages). New edge regressions and loop-order check pass under race repetition. Restoring the old formula or removing the hidden guard fails TestVisibleReasoningSpeed. macOS/Linux/Windows vet/build pass. Full-suite verification is recorded in the issue at this head; inherited proxy/Bun 1.3.14 failures are retained, with clean Bun 1.4.2 rerun in progress. No installed app replacement.

Rebased onto main by yetone (#1463). Conflicts with main's Own/Retried/
Queued/Tries row fields, HandedOn and the Codex speed floors were resolved
by keeping both. The packed row's ReasoningHidden bit was 64, which main
has since given to block_price.go's swapKnown, and main's rowHandedOn took
128, filling the uint8: Flags is now uint16 and ReasoningHidden is bit 512
(rowReasoningHidden; #1874's rowOwnCost took 256), read back in row(). The docs/verification notes and
their sample JSON are left out of the tree; they stay on the contributor's
branch and the issue. Run after the rebase: go test -tags nogui ./internal/usage/
and the gateway's reasoning/speed/TTFT tests, ok.
2026-10-13 06:43:50 +08:00
yetone d01635797a gui: a window made wider or narrower keeps the reader where they were, or at the foot, while the page is laid out again, so Settings no longer ends 6px short of its foot across the sidebar's width in WebKit (#1672)
Cause: 18e82adc6 (the sidebar) added heldWidth, which lets go of what the
last click held when the window's width changes. Before it, the held
click's ResizeObserver followed the page as it grew back. text-size's
#911 case scrolls Settings to its foot and then resizes the window
across SIDE_AT (960 to 1440). In WebKit the scroll is clamped to each
layout the page passes through:
1. scrollTop goes from 120 to 46 on the resize;
2. after the side-nav swap the max is 10, so scrollTop is 10;
3. about 40ms later a part grows 6px (max 16), but nothing moves the
   scroll back.
So the page ends 6px short of its foot, and 3 of text-size's 11 subtests
fail in WebKit, run alone.

Change: on a width change, for a second, a ResizeObserver on the open
view's parts calls backToReader. The reader's own place (readerAt, still
120) is kept, or as far down as the page now goes. It doesn't act while a
click holds the page or while a purposeful scroll runs. Calling
backToReader at the end of layoutNav was tried first and didn't help,
because the growth comes after it. docs/subsystems/gui-shell.md says so.

Run (worktree on origin/main 31c1e3ab1, playwright 1.62.0, chromium-1234
and webkit-2336, each file alone):
- text-size: 11/11 in WebKit, repeated, and 11/11 in Chromium.
  Without the change 3 of 11 fail in WebKit, as on 31c1e3ab1.
- 37 files that resize the window and check scroll, or are the
  sidebar's: agent-update-all, cli-update, click-scroll, menu-scroll,
  panel-usage, sidebar*, side-toggle, sidebar-tab-top, phone-web,
  header-zoom-fit, usage-*, settings-groups and others. In both engines,
  4 at a time: 73 of 74 green.
  The one red is sidebar-overlay-scrollbar in chromium ("dragged to the
  end: 162 of 191"). It fails 1 run in 3 alone on unchanged 31c1e3ab1
  too, so it is filed as #1863.
- Under parallel load, text-size's "zh, dark: nothing runs off the side
  at 150%" sometimes fails on 31c1e3ab1 too ("ResizeObserver loop
  completed with undelivered notifications", 2 of 4 runs), and once with
  this change ("element not stable"). It passes 3/3 alone and 3/3 in
  parallel with the change. Noted on #1672.

Not run: the Windows and Linux apps, and the full GUI suite. No Go code
changed.
2026-10-13 03:54:48 +08:00
yetone 6669d497d0 gui: an account's seat on the Routing stage tells each of its windows and when each resets in its tooltip (#1835)
A seat on the stage says the fullest window's figure while idle
("40% used · renews in 2h"), and what it is doing while it answers. The
other windows, and their resets, weren't anywhere on the stage. Its
tooltip, which held only its id, now adds one line a window, the same
lines Accounts and keys shows (winsOf, the Usage page's readings,
#1833). It is a tooltip rather than a second line on each seat because
the stage is the live picture of a request, and a line more on every
seat would crowd it. Live only.

docs/subsystems/gui-shell.md: under Routing account windows.

Run: tests/routing-seat-windows.test.cjs (new), chromium and webkit,
en, zh, zh-TW, ja, de at 1100 and 420px: the answering seat's title is
its id and both windows, and the seat whose only card is another
computer's keeps its id alone. 22/22 pass, and 11 of 11 fail in chromium
with routing.js as before. Not tried with a real account.
2026-10-13 02:36:12 +08:00
yetone 0801c7bb02 gui: Routing's Accounts and keys has a refresh beside its heading that reads the accounts' allowances again, by hand only (#1834)
The windows each account shows (#1833) are the Usage page's readings,
read the ordinary way when Routing opens. To see them fresh one had to go
to Usage and back. The icon button beside "Accounts and keys" makes the
asked read Usage's Refresh now makes (loadQuotas(true),
/api/usage/quotas?asked=1). It turns while the read is on its way, a
click then asks nothing more, and the rows are drawn from what comes
back. There is no timer: nothing reads again by itself, as #1518 has
allowances read only when asked. It shows only live, with a subscription
account listed. Its tooltip is new ("Read the accounts' allowances
again", in zh, zh-TW, ja, de), and its label reuses "Refresh now".

docs/subsystems/gui-shell.md: under Routing account windows.

Run: tests/routing-read-allowances.test.cjs (new), chromium and webkit,
en, zh, zh-TW, ja, de at 1100 and 420px: title and label, on the heading's
line, opening reads only unasked, one asked read on click with the
button busy until it lands, a second click while busy asks nothing, the
windows show the new reading, the view doesn't move, and no asked read
in 2.5s after. A list of keys only has no button. 24/24 pass, and 11 of 12
fail with routing.js, routing.css and i18n.js as before. gui-ja,
gui-zh-tw, gui-de, i18n-keys and routing-account-windows pass. Looked at
in screenshots at 1100px (en) and 420px (ja). Not tried with a real
account.
2026-10-13 02:36:12 +08:00
yetone 6627ddd54b gui: a subscription account in Routing's Accounts and keys shows each of its windows and when each resets, as the Usage page read them (#1833)
The list said one figure for an account, the window routing went by. A
Claude account's 5 hours and 7 days, or Codex's, each with its reset, are
now on a line under it ("5 hours 40% used · resets in 2h"). cardOf matches
the route's account to app.js's quotas: a subscription card of this
computer (no from) whose provider is the account's agent (a plugin's
provider id) or its provider, and whose user is the account's, ignoring
case. Nothing new is read from vendors: opening Routing asks
/api/usage/quotas in the ordinary way when the readings are missing or
over a minute old, never ?asked=1. A kept day's list shows none, as its
requests were weighed by readings long gone.

loadQuotas now treats an answer that isn't a list of cards as a failed
read and keeps what it had. Routing reading quotas showed it: a page given
{} stored it and renderQuotas threw on quotas.some.

docs/subsystems/gui-shell.md: Routing account windows.

Run: tests/routing-account-windows.test.cjs (new), chromium and webkit,
en, zh, zh-TW, ja, de at 1100 and 420px: exact window lines, none for an
account whose only card is another computer's, no overflow, no asked
read. 22/22 pass; fails with app.js, routing.js and routing.css as
before. Looked at in a screenshot at 1100px (en) and 420px (de). All 60
routing-*.test.cjs and click-scroll: 636 pass, 5 fail, all in WebKit in
routing-group-fold (en, ja, de) and routing-sessions (en), which fail the
same alone on the old assets at 7a9490638 and are filed as #1672.
Not tried with a real Claude or Codex account.
2026-10-13 02:36:12 +08:00
lainbo 7d05a00f5f gui: a tab picked in the sidebar opens at its top, not where the tab before was left (#1844)
Usage, Library, Plugins and Settings list their tabs under the page in the
sidebar (navSubs), and a page's tabs share its one scroll. A row only
clicked the page's own tab, so scrolled to the foot of Settings › General
and Allowances picked, Allowances showed at its foot; Library › MCP
servers and Skills the same. A row that picks another tab now clicks it
and scrolls the page to its top through scrollOnPurpose with the row's own
click. The tab already open, picked again, leaves the page where it is.
The page's own strip (the header's tabs) and switching between pages are
unchanged.

sidebar-tab-top.test.cjs (Chromium, WebKit, en, zh) fails without the
change, 6 of 6: "Allowances opens at its top", 177 (en) and 228 (zh)
instead of 0; with the Settings part left out, "Skills opens at its top",
about 2100 instead of 0. It passes 6 of 6 with it. go test -tags nogui
./internal/gui in a temp HOME passes.
2026-10-13 01:44:40 +08:00
yetone 60808fd9cf usage, gateway, gui: magpie's own requests are told apart from the agent's, and a classifier on a subscription says it asks it every turn (#1839)
kensenzhao saw a subscription's allowance spent by requests the agent
didn't make: a routing group's classifier, set to a subscription's model,
asks it as every turn begins, and those calls looked like the agent's own.

What changed
- usage.Group has an own share (calls, tokens, cost) of the calls magpie
  made by itself, filled for models, keys and accounts. Record.ByMagpie
  is the test: agent "magpie", or one of its own User-Agents
  (magpie-router/1, magpie-search/1, magpie-vision/1) where the agents
  aren't loaded. The calls still count in the group's totals, as they
  went to the same key or account. A group with none sends no "own".
- The classifier's calls are Kind "routing": callKind marks RouterAgent's
  requests, and the decision model's record (Jev / System One) is written
  with it. A "Routing classifier" purpose names them in the ledger.
- Usage page: magpie's row among the agents and its ledger rows carry a
  "magpie's own" mark; an account's, key's or model's row adds "{n} by
  magpie itself"; an account's card says how many of the period's
  requests were magpie's own, drawn again once the summary arrives after
  the allowances.
- Routing page: /api/groups marks a model a subscription account serves
  (modelRef.Sub, servedRef). Beside a classifier on such a model, or a
  group whose first member is one, the editor says every turn starts
  with a request to that subscription, two when it picks both intent and
  effort in words. A classifier on a key or a free model says nothing.
- New strings in zh, zh-TW, ja and de. The mark is a muted chip with an
  even border all round (no left stripe).

Tests
- TestSummaryCountsMagpiesOwnCallsApart, TestByMagpie (usage).
- TestIntentRoutesATurn and TestJevPicksTheIntent (gateway) now check
  the classifier's records are Kind routing and magpie's own, and the
  agent's records are not.
- TestServedRefSaysASubscription (gui).
- own-requests.test.cjs: Chromium and WebKit, 1100 and 390 wide,
  en/zh/zh-TW/ja/de, the API faked; no click scroll, no sideways page.
- Broken by hand, each turned its test red: addOwn counting nothing;
  callKind's routing case removed; decide.go's Kind blanked; the ledger
  mark, the agents' mark, the "{n} by magpie itself" line, the card's
  line, its redraw after the summary, the Routing hint, its group case
  and modelRef.Sub each removed.

Run: gofmt -l; go vet on darwin, linux -tags nogui and windows; go test
for usage, access, catalog, gui (-tags nogui) and gateway in full; the
GUI tests above, the ledger, routing-intent and translation tests.
Not done: the warmups (warmClaude/askClaude) write no usage record at
all, so they can't be marked; that is left as it was. Not tried with a
real subscription classifier against a live account.
2026-10-13 01:41:50 +08:00
yetone 8653bead72 usage, gui: a usage record and a request's details carry its cache read and cache creation beside in and out (#1839)
kensenzhao asked for usage.jsonl and the Usage page's request details to
carry cache read and cache creation tokens beside input and output.

What changed
- usage.Record's cache_read and cache_write are written on every record,
  0 too (they were omitempty), so a prompt that missed the cache reads as
  that rather than as a record that kept no cache. A record from before
  has neither and reads as 0, as it did. Input still holds neither.
- Every route already filled them; this pins it per wire format:
  Anthropic messages, OpenAI Chat (prompt_tokens_details.cached_tokens and
  DeepSeek's prompt_cache_hit_tokens), Responses
  (input_tokens_details.cached_tokens) and Gemini
  (cachedContentTokenCount), relayed and translated, whole and streamed,
  a plugin's fetch, and the Claude subscription bridge. System One's
  decision calls report no cache and are left as they are.
- A request's details in the ledger have a Tokens row at every width:
  "{i} in · {o} out · {r} cache read · {w} cache creation", plus the
  5-minute/1-hour split when known. Before, the cache showed only as
  "{w} written · {r} read" when non-zero, so a missed cache said nothing.
  That string is gone; the new one is in zh, zh-TW, ja and de.

Prices and quotas: the JSON tag is the only change to the record, so the
cost math (CostAt -> CostSplit reads CacheRead/CacheWrite/CacheWrite1h),
Totals' cache sums, budget's CacheReads and access/limit's token windows
read the same values as before. Checked by reading each and by the usage,
access and catalog tests passing unchanged.

Tests
- TestRecordAlwaysCarriesCacheTokens (usage): 0s written, old records read.
- TestUsageRecordsCacheTokensOnEveryRoute, TestPluginUsageRecordsCacheTokens,
  TestClaudeSubscriptionUsageKeepsCacheTokens (gateway): each wire format,
  whole and streamed.
- ledger-cache-tokens.test.cjs: Chromium and WebKit, 1100 and 390 wide,
  en/zh/zh-TW/ja/de; usage-ledger-detail.test.cjs updated for the row.
- Broken by hand: putting omitempty back and dropping the Tokens row each
  turned its test red. The gateway route tests pin what the routes
  already did; they don't fail on the code before this commit.

Run: gofmt -l; go vet on darwin, linux -tags nogui and windows; go test
for usage, access, catalog, gui (-tags nogui) and gateway in full; the
GUI tests above plus the translation tests. Not run: a real vendor
request to see its cache figures land in usage.jsonl.
2026-10-13 01:41:50 +08:00
yetone f36e744c30 gui: Settings › General says each setting's name alone where it says enough, and Language is one menu (1ooogle on X)
1ooogle's mockup on X redrew Settings › General the way macOS System
Settings reads it. The owner approved, and this follows it.

Rows that now show only their name:
- Appearance, Text size, Interface and Code font, the tray click,
  Provider in model names, the Codex titles, auto-review and memories
  model rows, Open at login and Show in Dock.
- A font row's line shows only while its fonts are loading or have
  failed.
- The text size keys (⌘0 / Ctrl+0) move into the choices' tooltip.

Rows that keep one short line, because the name alone doesn't explain
the setting or what it costs:
- Codex subagents, Long conversations, Lightweight mode, Prevent sleep
  and Session terminal.

Renames:
- "Tray icon" becomes "Click the tray icon to", with the choices "Open
  the quick panel" and "Open the main window" (点击托盘图标: 打开快捷面板 /
  打开主窗口).
- "Keep awake while agents work" becomes "Prevent sleep" (防止休眠: 在
  magpie 运行任务时,让电脑保持唤醒状态).
- "Dock" becomes "Show in Dock" (显示程序坞).

Language is one button showing the language picked (renderLangPick).
It opens in the app's own menu (openProtoMenu, styled like Session
terminal's sess-pick), not a native <select> and not six segments.

Every language gets the same text: en, zh, zh-TW, ja and de. The 25
strings no longer used are removed from all four translations.

Tests:
- New: settings-general.test.cjs. In Chromium and WebKit, en, zh,
  zh-TW, ja and de, at 1000 and 440 px, on a Mac, it checks that:
  - the rows that should show only their name have no line;
  - the kept lines are one line each, and none is cut short at 1000px;
  - Language is a button showing the language, and its menu lists all
    six;
  - a pick saves lang and redraws the page in that language, with the
    button staying under the pointer;
  - nothing has a left stripe and nothing scrolls sideways.
  I broke it by hand twice and saw it fail both times: once by giving
  the Dock row a line back, once by making the pick save nothing.
- Updated to the new text and controls: codex-titles,
  codex-auto-review, codex-memories-settings, model-suffix-own,
  plain-names, lightweight, keep-awake, text-size, gateway-mode,
  omarchy, settings-search, gui-zh-tw (Language's button and menu fit
  at 1000/440px), header-relang (picks through the menu) and
  readable-focus (the first shown line).
- German's long-conversations line was shortened to fit on one line at
  1000px.

What was run:
- go test -tags nogui ./internal/gui passes; gofmt -l is clean; go vet
  passes on darwin, linux and windows.
- The whole GUI suite (601 files, --test-concurrency=4): 6584 passed,
  33 failed. Every failing file was then run alone:
  - mobile-web fails on purpose. It compares desktop screenshots with
    origin/main, and only the Settings page differs.
  - routing-group-fold, text-size, routing-sessions and pick-skills
    are #1672; searcher-pick is #1745. Each also fails alone on
    origin/main 260ded9af.
  - routing-provider-off, routing-steady and usage-sum-whole pass when
    run alone, both here and on main.
- Screenshots before and after (zh, en and de light at 1000px, zh at
  440px, zh dark) were looked at.

Not tried in the real Wails window.
2026-10-12 22:51:53 +08:00
yetone 61a0a69b5c gui: Routing, Usage and Sessions keep to the width the other pages do on a large screen, centred (面条 on Discord)
What changed: the window's page-width rule (#860), padding each view to
max(16px, calc(50% - 600px)), now names #view-routing, #view-usage and
to edge while Agents, Providers, Library, Gateway, Plugins and Settings
sat in a 1200px column in the middle. A narrow window keeps the 16px
gutter it had.

Routing's two columns, the Usage cards' packing and the requests ledger
lay out by the room they get (byWidth, packUsage), so they follow the
narrower box: at 1920 Routing still gets its two columns (min1150) and
the ledger fits 1200 without a sideways scroll.

sess-agent-strip.test.cjs asserted that eleven long agent names fit a
1600px window's Usage page in one row. With the page kept to 1200px they
were 8px too wide in WebKit zh (its scroll bar takes width), which is the
strip's designed overflow; the first two names are shortened so the "fits"
case is still one that fits, and the narrow case still overflows. One word
off the first name left it 0.34px of room (1159.66 in 1160), which went
red once in WebKit en under load; two names shorter leave 135px, and it
passed 3 runs in a row in each engine.
sessions-toolbar.test.cjs asserted that ten agents' tabs fit an 1800px
window; in a 1200px page they need 1115px of 912, so the page shows the
compact agent menu (its designed overflow). The fixture now has eight
agents (829px), so the wide case still tests tabs that fit.

Run:
- new page-width.test.cjs: every view's content width 1150..1200 and
  centred at en 1920, zh 2560, zh-TW 1920, ja 2560, de 1920; 16px at en
  900; every view's left edge and padding equal Agents'; chromium and
  webkit, 14/14. Without the CSS change it fails ("sessions: 1676 wide
  at 1920").
- before/after screenshots of Routing, Usage cards, the ledger,
  Sessions and Providers at 1920, 2560, 1100 and 800 (chromium).
- GUI regression set, both engines: click-scroll, editor-short-window,
  ledger-*, panel-usage, quota-*, routing-*, usage-*, sessions-*,
  sess-agent-strip and sessions-toolbar (after the fixture changes).
  routing-group-fold (webkit en/ja/de) and routing-sessions (webkit en)
  fail the same with origin/main 17c12621b's own assets, run alone:
  already filed as #1612 and #1672.
  usage-ledger's webkit "dark, and narrow" failed once in the full run;
  it fails the same with 48e59c5b8's assets (the view left scrolled 32px
  after the resize, the tab under the header), noted on #1671.
- Go: gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., the builds: clean. go test -tags nogui
  ./... at load ~25-60 (other sessions' runs): every package passed but
  internal/agent and internal/gateway, which hit the 30m timeout; run
  again alone, agent passed and gateway's only red was
  TestOTelWaterfallIncludesUnbilledFallback, filed as #1794 (passes
  alone, -count=3).

Not verified: real WebView2 or WebKitGTK windows; layouts were checked
in Playwright's chromium and webkit only.
2026-10-12 22:29:45 +08:00
yetone 66ec713af7 gui: a short window's sidebar has no scroll bar beside its pages, a thin one shows over them while they scroll and fades, as on a Mac (xybio and MOMO on Discord)
In a window shorter than the sidebar's pages, .side-scroll (scrollbar-width:
thin) and .side-foot kept a native bar and its gutter at rest on Windows and
Linux. On Windows this was MOMO's report (v0.1.1207, WebView2): a classic,
always-visible bar with arrows between the sidebar's items and the page,
because Chromium drops every ::-webkit-scrollbar rule on a box with
scrollbar-width set and draws the system bar. Both boxes now hide their native
bars (scrollbar-width: none and ::-webkit-scrollbar display:none, which
Chromium/WebView2, WebKit and WebKitGTK each honour), and app.js sideBars lays
a thin overlay bar inside, shown on scroll, faded ~900ms after, kept while
hovered or dragged, the thumb draggable with pointer capture, a click off it
pages the box, hidden when the box fits. ResizeObserver/MutationObserver keep
it placed as the nav's sub-tabs open and fold. gui-shell.md describes it.

Run: new sidebar-overlay-scrollbar.test.cjs (chromium with native bars on,
webkit; en, zh, zh-TW, ja, de at 1100x320 and a tall window) 14/14; it fails
without the change (no bar shown while scrolling, 5/5 languages both
engines). Its drag step first measured the thumb before the scroll event
had moved it, pressed the bar below the thumb and paged the box (3 of 6
webkit runs red, "162 of 191"); it now waits for that scroll, and 8 webkit
and 5 chromium runs in a row pass. sidebar, side-width, side-toggle, strip-scrollbar, view-scrollbar,
view-scrollbar-drag, click-scroll all pass in both engines. Screenshots at
rest and mid-scroll in both engines checked by eye.

Windows: on the Windows 11 box, headless Edge 155 (WebView2's engine)
rendered a sidebar box with origin/main's app.css and with this one. Old:
10px gutter and the classic bar with arrows, as in MOMO's screenshot. New:
0px gutter and no bar, with an unstyled overflow box beside it still drawing
its 10px bar, so system bars were on. Not tried: the overlay bar's JS inside a
real WebView2 or WebKitGTK window (it ran in Playwright's Chromium and WebKit
only).
2026-10-12 22:29:45 +08:00
yetone 0db8112afe omarchy: on Hyprland the tray panel opens under the click on a monitor that isn't at 0,0, not off the screen (#1785)
PanelAt answered where the panel goes in coordinates across the whole
layout (the cursor's, from hyprctl cursorpos), and PlacePanel handed them
to Hyprland's move rule. Hyprland counts a move from the corner of the
window's monitor (CDefaultFloatingAlgorithm::newTarget in 0.56.2:
COMPUTED + MONITOR_POS), so the monitor's place was added twice. The
reporter's click on the right of two 1920-wide monitors asked for
3238,40 and got 5158,40, off every screen. The monitor at 0,0 hid it,
and the only setup tried before (bf25a3ae8) had one monitor.

PanelAt now answers from the corner of the monitor under the cursor and
names it. The rule says monitor = that name, so the move counts from the
monitor clicked, not whichever one Hyprland would have opened the panel
on. The panel is still kept PanelGap inside that monitor's work area,
and the room below it is unchanged. ClickedOutside compares the cursor
with the clients' places, both across the layout, and stays as it was.
niri's placement already moves within the working area of the output and
doesn't share this. The fix follows laojianzi's draft (laojianzi/magpie#1).

Run:
- internal/omarchy TestPanelAtMonitorOffScreenOrigin (new), with the
  reporter's two 1920x1080 side by side, the right edge, a monitor left
  of and above 0,0, and a scaled one below. It plays Hyprland's sum and
  checks where the panel lands and that it's inside the clicked
  monitor's work area. With the old sum put back by hand it goes red,
  landing at 5158,40 for the reporter's case. TestPanelAt's turned
  monitor had the old global x written into it, and now has 6.
  TestPanelRule checks the rule's text.
- On the omarchy VM (Hyprland 0.56.2), with a headless second output at
  1600,0 made for the try and removed after, the same Lua rule on a
  throwaway foot window titled magpie-1785-probe (not magpie's rule
  name):
  - monitor = "PROBE-1785", move = { 100, 40 } landed at 1700,40;
  - the old global 1700,40 landed at 3300,40, off the screen;
  - monitor = "Virtual-1", move = { 100, 40 } landed at 100,40.
- go vet (darwin, windows; internal/omarchy for linux with nogui).
  gofmt is clean.

Not tried: magpie itself on two real monitors under Hyprland. The Linux
GUI build needs cgo and wasn't built here, so placePanel's two changed
lines are covered by the darwin and windows builds (app.go has no OS
tag).
2026-10-12 22:21:52 +08:00
yetone ff49ca72fe gui: Windows without the WebView2 runtime says so in a message box and offers the download page, instead of a double-click doing nothing (#1806)
magpie's windows are WebView2, which Windows 10 doesn't always have.
Without it Wails handed the failure to ErrorHandler and exited, and the
desktop build (-H windowsgui) has no console for the log line to land
in: ufec's double-click came up to nothing at all. ufec found the cause,
that Wails' own Env.Info().PlatformInfo["WebView2"] answers "" then, and
that a box can't come from ErrorHandler (it runs on the thread Wails
makes its windows on); this takes both from their branch.

Run asks webView2Check right after application.New, before any window.
Missing, it logs it and shows MessageBoxW (Yes/No, error icon, topmost)
in the reader's language (trayLang): the runtime is missing, Microsoft's
page https://developer.microsoft.com/microsoft-edge/webview2/, that
"magpie web" and "magpie tui" work without it, and whether to open the
page now; Yes opens it (ShellExecute), and Run ends. A key Wails doesn't
set is read as present: refusing to start a magpie that would have
worked is worse than the silent exit. The tray isn't kept: its panel is
a WebView2 window too.

Run: TestWebView2Missing and TestWebView2Notice (all OSes);
TestWebView2MissingFromWails on the Windows box (10.0.0.132, Windows
with WebView2 installed): a child process with Wails pointed at a folder
that isn't a runtime reads missing, the machine's own runtime reads
present. TestWebView2Missing goes red with webView2Missing made to answer
false. On the box, a throwaway -H windowsgui test binary calling
webView2Check with that bogus runtime path, run in the desktop session:
the box came up titled "magpie 需要 WebView2" with the Chinese text, the
page and 是/否 buttons (read back from the dialog's controls), the log
line was written, pressing 是 opened the page in Edge and the check
answered false. go test -tags nogui ./internal/gui in a sandbox HOME;
gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and
GOOS=windows; windows and linux builds.

Not tried: a machine that really lacks the runtime (the box has it; the
missing case is Wails' lookup failing on a path that isn't a runtime,
the same failure), nor a real magpie.exe start through Run.
2026-10-12 22:03:29 +08:00
yetone 897f6d32f1 gui: on Linux the tray panel is a solid window with an opaque page, as the main window is, so scrolling it leaves no ghost of the old position (#1803)
MizuIro-H (Bazzite / Fedora 44, KDE Plasma 6, Wayland) saw the panel's
Allowances tab leave a fainter copy of what it showed at the old scroll
position, on Wayland and under GDK_BACKEND=x11, with
WEBKIT_DISABLE_COMPOSITING_MODE=1 (which magpie already sets under
Wayland, so that try changed nothing), at scale 1, and without KWin's
corner effect. The main window, with the same page, never did.

The panel was the one window with per-pixel alpha: Wails'
BackgroundTypeTranslucent on Linux makes it an app-paintable GTK window
on the screen's RGBA visual under a 0-alpha webview, and body.panel
painted --bg at 93% over it. Paint not cleared before a scroll repaint
shows through 93%, which is the fainter copy. The main window is a plain
solid window painting --bg whole.

On Linux only, panelOptions now makes the panel BackgroundTypeSolid, and
body.linux.panel paints --panel-tint as --bg (no alpha). The Mac (tinted
by tintPanel) and Windows keep the translucent panel. The corners are
square on Linux now (the body's paint fills the canvas).

Run: gofmt -l internal/gui (clean); go vet darwin ./internal/gui,
GOOS=linux -tags nogui ./..., GOOS=windows ./... (clean);
go test ./internal/gui under a sandbox HOME (ok);
node --test internal/gui/tests/panel-*.test.cjs, chromium and webkit
(74 pass), the new panel-linux-opaque test across en/zh/zh-TW/ja/de and
light/dark. Broken by hand: TestPanelSolidOnLinux fails without the
panelOptions change, and panel-linux-opaque fails without the CSS rule
(the Linux body read color(srgb ... / 0.93)).

Not tried on the reporter's setup. A repro of the panel's window
(GTK3 + WebKit2 4.1, RGBA visual, 0-alpha webview, 93% page) under Xvfb
with picom, on Ubuntu and on Fedora 44 (WebKitGTK 2.54), scrolled by JS
and by a real X wheel, with compositing mode on and off, showed no ghost
either way: software rendering there doesn't reproduce it, so whether
the opaque panel ends it rests on the reporter's KDE/GPU machine. No
real Linux magpie build was run.
2026-10-12 22:01:27 +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
yetone 23e764d0e0 cli: magpie's commands move from the root into internal/cli; the root keeps only main.go
The root held 89 .go files (30 commands, 59 tests). They move as they are
to internal/cli (package cli), with git mv so history follows them. The
only code change is main() becoming cli.Main(version): the root's new
main.go keeps `var version` in package main, so -ldflags "-X
main.version=…" in the Makefile, the Dockerfile and magpie-releases, and
every workflow, work unchanged. go-winres's rsrc_windows_*.syso still land
next to package main in the root.

Tests that read testdata by a root-relative path now go up one level
(../plugin/testdata/fake, ../sessions/testdata). Five subsystem doc links
point at internal/cli/.

Run:
- go build ./..., gofmt -l, go vet on darwin, linux and windows (nogui)
- builds with tags production, dev, "production nogui"; windows
  -H windowsgui; linux CGO_ENABLED=0
- make release-cli TARGETS="darwin/arm64 linux/amd64 windows/amd64
  android/arm64" VERSION=9.9.9-tidy: all four built, binary prints
  "magpie 9.9.9-tidy"
- docker build --build-arg VERSION=7.7.7-tidy: container prints
  "magpie 7.7.7-tidy"
- go test ./internal/cli (default and nogui): 152 tests, the same count
  as the root on main
- go test ./...: all packages pass (agent, gateway, library, provider
  timed out at 10m under other sessions' load and passed rerun alone
  with -timeout 40m; none of them changed)
- the built binary in a sandbox HOME: version, help, ls, providers,
  claude, and an unknown command's error
2026-10-12 20:40:22 +08:00
yetone f5dd4d604e gui: the Linux app's sidebar button switches the layout at once, no view transition, which WebKitGTK with compositing off crashed in (depravity_wings on X)
Since 18e82adc6 (v0.1.1197) the sidebar button, Ctrl+Shift+S and dragging
the sidebar's edge past its narrowest trade the two layouts in a view
transition (navMorph). Under Wayland magpie turns WebKitGTK's compositing
off (webkit_linux.go), and WebKitGTK 2.52 then crashes in the transition:
SIGSEGV on the GTK main thread inside libwebkit2gtk-4.1, from a
JavaScriptCore run-loop timer. The reporter saw the window freeze.

The Linux app (body.linux) now has the new layout at once, the path reduced
motion already takes; magpie web in a Linux browser keeps the motion. Other
webviews get a guard: a transition still going after MORPH_MAX (1.5s, three
times its length) is skipped, so one that never ends can't leave the window
on the old layout's picture.

Run:
- Reproduced on the omarchy VM (Hyprland/Wayland, webkit2gtk-4.1 2.52.6),
  v0.1.1207 under a scratch HOME: the button crashed the app 4 of 4 clicks;
  with WEBKIT_DISABLE_COMPOSITING_MODE=0 it didn't.
- The fixed build there (same Linux path, compositing at magpie's default):
  8 button clicks, 4 Ctrl+Shift+S and an edge drag past its narrowest all
  switched the layout, checked by screenshot each step; no crash, no freeze.
- side-toggle.test.cjs: "Linux: at once, no transition" and "a transition
  that never ends is cut short", chromium and webkit; both go red with the
  change undone by hand. side-toggle, sidebar, side-width, header-centre
  pass in both engines (60 tests). go test -tags nogui ./internal/gui ok.
Not run: the 1.5s guard on a real webview that never ends a transition
(none found); it is tested with a stub.
2026-10-12 19:13:14 +08:00
yetone e21ea07e47 gui: a client in the Usage page's Agents list can be hidden from it, and shown again from the line under it (ikunbots on X)
ikunbots asked to hide curl, Go-http-client, python-httpx and other clients
from the Agents list beside the agents they actually use.

What changed:
- Each Agents row has a "…" button that shows on hover (always on touch) and
  opens the app's row menu (openRowMenu) with "Hide from this list".
  Right-clicking the row opens the same menu. No native select.
- The hidden ids are saved by client id in settings.UsageAgentsHidden,
  trimmed and deduped. They go through POST /api/usage/arrange
  (agentsHidden), which changes only that field, and the Settings save
  carries the field over.
- Hiding is display only. The ledger keeps the calls, and the totals, the
  chart and every share still count them.
- When anything is hidden, a quiet "3 hidden" / "已隐藏 3 个" line sits under
  the list. It opens the hidden rows, dimmed, each with "Unhide" / "取消隐藏".
  No click scrolls the page: the scroll guard holds the clicked line in place.
- Where a pointer hovers, the "…" takes no room. Its margins give back its
  width and gap, so a row at rest is laid out as on main (mobile-web's
  desktop comparison is the same). It shows over the end of the share bar.
  On phones (body.web) it has its own grid column.
- Translated into zh, zh-TW, ja and de. docs/subsystems/gui-shell.md
  describes it.

What was run, in a worktree off origin/main:
- gofmt -l: clean.
- go build ./... and go vet ./...: pass.
- GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: pass.
- HOME=<scratch> go test -tags nogui ./...: 49 packages ok. Includes the new
  TestUsageArrangeAgentsHidden, which covers saving, surviving a settings
  save, narrowing and emptying.
- New usage-agents-hide.test.cjs: 32/32 in Chromium and WebKit. It covers
  en, zh, zh-TW, ja and de at 1200, 560 and 390 (web). It hides by "…" and
  by right-click, checks the POST body, unchanged totals and an unmoved
  page, then unhides, reloads and checks the hidden rows persist.
- All 48 usage, panel-arrange and click-scroll GUI files: 503/503.
  old-webkit and mobile-web: pass.
- Full GUI suite (6489 tests, concurrency 5): the reds outside this change
  fail the same when run alone on origin/main 3deb85685, in WebKit only.
  They are filed in #1672 and #1609, and in #1745 (new: group-member-info,
  searcher-pick).
- Broken by hand:
  - Without the hidden filter in renderUsage, the new GUI test fails 16/16
    in Chromium (the shown rows still list curl).
  - Without the arrange handler, TestUsageArrangeAgentsHidden fails at
    line 82.
  - Without the Settings-save carry-over, it fails at line 84.
2026-10-12 14:56:28 +08:00
yetone 3deb85685f gui: Usage's subscription cards in one row are as tall as each other, so their bottoms line up (ikunbots on X)
ikunbots ("magpie 的这个卡片可以对齐吗") and duanjl_china ("有的长有的短"):
Claude Code, Codex and Antigravity sat side by side in one row on the
Usage page, each as tall as what it held, so their bottoms were ragged.

What changed
- packUsage (app.js) still packs the cards into columns as #860 made it
  (a short card stacks beside a tall one, never stretched to a row's
  height). After placing them, the last card in each column gets a
  min-height that takes it down to where the tallest column ends.
  - Cards side by side in one row (one card per column) are as tall as
    the tallest, bottoms on one line, content at each card's top.
  - A stack stays a stack: the upper cards are as tall as themselves and
    only the last one reaches down to end with the tall card beside it,
    which is what #860 asked for (堆叠和 Codex 对齐).
  - One column: each card is as tall as itself, nothing to line up.
  - The min-heights are cleared before every measuring, so a re-pack
    (resize, a fold opened, cards changed) measures each card as tall as
    itself. A min-height rather than a stretch keeps a card that outgrows
    it growing, so the ResizeObserver still re-packs.
- docs/subsystems/gui-shell.md says so.

Tests
- usage-pack.test.cjs:
  - New: ikunbots' three cards (Claude Code 2 windows, Codex, Antigravity
    6 families; content heights 107/169/217px) at 1400 and 1018px are one
    row with bottoms within 0.5px; at 480px one column, each card as tall
    as itself; widened again, one row lined up again.
  - The reporter's #860 stack at 897/1018/1400px still stacks:
    Antigravity as tall as itself, DeepSeek under it with the 7px gap,
    ending where Codex does.
  - sound(): a card is as tall as itself unless it is last in its column,
    which ends with the tallest; no card is shorter than its content.
  - The fold case: opening Codex's brief account grows what the card
    holds; the card already reaching down to the stack's end stays that
    tall rather than growing (was "the card grew").
- Broken by hand: no min-height applied -> "1400px: the cards' bottoms
  line up" red in all 8 (chromium/webkit x en/zh/ja/de); min-height not
  cleared before measuring -> "narrow: antigravity is as tall as itself"
  red. Restored: 8/8 pass.

Run
- usage-pack.test.cjs in Chromium and WebKit, en/zh/ja/de: 8/8 pass.
- Every GUI test file touching the Usage page (75 files, those naming
  #subscriptionUsage/.subscription-card/view=usage, plus click-scroll),
  both engines, concurrency 6: 917/918 pass. panel-usage webkit en failed
  once under that load ("asked: period=today&limit=1", a 2.4s poll in its
  Requests-window step this change doesn't reach), passes 3/3 alone;
  added to #1544 with its cause.
- Screenshots before/after with fixture data looked at: ragged row
  before, one line after; 897px stack unchanged but for DeepSeek/Codex
  ending together.
- No Go change; gofmt/vet/build not run. Full GUI suite not run.
2026-10-12 14:19:39 +08:00
yetone f131117976 gui: on niri the tray panel opens under the bar beside the clicked icon, not in the middle of the screen (#1670, Kenoia)
A Wayland window can't place itself. Under niri the panel opened where niri
floats a new window, the middle of the output. Hyprland already had an
adapter (omarchy/hypr.go); niri now has one too.

niri (checked in niri v26.04's source, niri-ipc/src/lib.rs and
src/ipc/server.rs) can't add window rules at runtime and doesn't report the
pointer over IPC. So omarchy.NiriPanel watches niri's event stream
($NIRI_SOCKET, one line of JSON per message) and moves each window of
magpie's pid titled "magpie panel" once as it opens:
MoveWindowToFloating if it was tiled, then MoveFloatingWindow with SetFixed
x/y, which count from the working area's top-left (below the bar). It goes 6
px under the bar, centred on the x that the tray host passed to the SNI
Activate(x, y), kept inside the output. Wails' Linux tray keeps that x in
private fields (lastClickX/lastClickY), read the same way trayProps already
reads props; TestTrayClickIsWails reads Wails' source to fail if they move.
Noctalia passes bar-surface-local coordinates, so the x is taken across
the focused output. With no click (`magpie panel`), or with one off the
output, it goes to the top right. Wails' HideOnFocusLost closes it when
another window takes the focus.

What was run:
- go test -race ./internal/omarchy/, go test ./internal/gui/ (sandbox
  HOME, pinned GOMODCACHE/GOCACHE). The IPC fixtures are built from
  niri-ipc 26.4.0's Window/Output/Event/Reply types, quoted in the test.
- Broke it by hand: dropping the placed-once map fails TestWatchWindows
  (placed [7 7 9 9 9]); dropping the right-edge clamp fails TestPanelSpot.
- gofmt -l; go vet (darwin), GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...; linux nogui and windows builds.
- A nested niri 26.04 (winit backend on Xvfb, scale 1.5, Fedora 43
  container, magpie built with -tags gtk3), with SNI Activate sent via
  dbus-send. Activate(300, 14) put the panel at [58, 6] (300 - 484/2).
  A second Activate closed it. `magpie panel` reopened it at the top right
  (853 - 484 - 6 = 363). Activate(800, 14) clamped it to 363. `magpie gui`
  taking the focus closed it.

Not tried: a real niri desktop, Noctalia or another real tray host
(Waybar, ironbar), more than one monitor, a bar at the bottom or the side
(not accounted for), focus-follows-mouse. The panel still opens in the
middle and slides up; how visible that is on real hardware wasn't seen.

Not from this change: omarchy's TestCurrent fails with -count=2 on main
(it passes with -count=1).
2026-10-12 05:21:23 +08:00
yetone a0c4dba97d gui: the tray icon closes an open panel on the Mac under a window over the whole screen too, not only when the panel can be seen (#1661)
TestTrayCellClickReleasedPanel went red with "initial quota click did not
open the panel". The cause: Wails' WebviewWindow.IsVisible on the Mac is
the window's occlusion state, not [NSWindow isVisible]. This Mac runs
UURemoteServer, whose privacy curtain is an opaque window over the whole
screen at layer 2147483631, above every app's. Under it, every window is
"occluded", so the panel the click had just opened read as closed.

The same check is a product bug too. togglePanelNow went through Wails'
SystemTray.ToggleWindow, which chooses hide or show by IsVisible. Under
such a cover, a click on the tray icon showed the already open panel
again and never closed it. With only the test's check changed, the test
failed on "second quota click did not close the panel".

Fix: on the Mac, togglePanelNow decides by windowOpen (shown and not
miniaturised, the check #1381 brought in for lightweight mode). It hides
the panel, or places it and shows it, itself. fitPanel, zoomWindows and
trayCellClick use windowOpen in place of IsVisible as well. Linux and
Windows still go through ToggleWindow, unchanged. The Hyprland branch's
IsVisible checks are left alone, since they are Wayland only. Both
AppKit tests (TestTrayCellClickReleasedPanel, TestPanelCloseHidesIt) now
read the panel's state through windowOpen. gui-shell.md item 5 says so.

Run, on darwin/arm64:
- Under an injected cover (scratchpad cover.swift: opaque, max level,
  sharingType none, the whole screen):
  - origin/main: TestTrayCellClickReleasedPanel 0/8, and
    TestPanelCloseHidesIt 0/4 ("timed out waiting until the panel shows").
  - Test-only change: 0/8 ("second quota click did not close the panel").
  - This commit: TestTrayCellClickReleasedPanel 25/25, and
    TestPanelCloseHidesIt 20/20.
- Under UU's own curtain:
  - origin/main: 30/30 red.
  - This commit: 10/10 green.
- Before the curtain was up, origin/main passed 75/75. Under an activator
  load, it was 5/40 red.
- go test ./internal/gui (GUI build) passes. go test -tags nogui
  ./internal/gui passes. gofmt is clean.
- go vet with -tags nogui passes for linux and windows; go vet passes
  on darwin.

Not tried: clicking the real status item by hand under a remote session.
The test drives trayCellClick and togglePanel's path through the host.
2026-10-12 01:45:14 +08:00
yetone 751ebe8f5a gui: magpie leads Command-Tab's order after opening its window on a busy Mac too, not only when the main thread keeps up (#1651)
TestDockJoinLeadsCommandTab failed under a full local go test ./...: the
test app was LaunchServices' front app, yet last in Command-Tab's order
(lsappinfo visibleProcessList), kitty first.

Cause: setDock decided whether to activate magpie again by way of the
Dock (#1381's fix) from [NSApp isActive]. The Mac makes an activated app
the front app at once, but NSApp says it is active only once its main
thread has taken the activation in. On a loaded machine the join came
first, isActive read NO, dockStep chose a plain activate (a no-op for
the front app), and magpie stayed last. A temporary print in setDock
showed active=false in every failing run (3 of 5 at load ~120) and true
in the passing ones. The same can happen to a user when the panel's
focus and Open come close together on a busy Mac.

Fix: joining the Dock to the front always goes by way of the Dock
(activateAgain), whatever NSApp says. When magpie truly isn't active
(the tray's Open), the Dock's turn in front changes nothing: magpie is
activated after it either way. dockStep loses its active argument and
appActive is gone. docs/subsystems/gui-shell.md item 7 says so.

The test now activates magpie, waits for LaunchServices to call it the
front app, and joins, all in one turn of the main thread, so the join
always comes before NSApp knows: the busy-machine order, made certain.

Run:
- New test on the old dockStep: 5 of 5 red (magpie not first, kitty first).
  With the fix: 25 of 25 green at load ~120-135.
- The old test (no injected order) with the fix: 10 of 10 green at load
  ~180; before the fix 3 of 5 red at load ~120.
- TestDockStep (table without active). go test ./internal/gui (GUI
  build, darwin) 5 runs green. One run before them failed and its
  output wasn't kept, so which test failed is unknown. After rebasing
  onto 18e82adc6, one package run failed TestTrayCellClickReleasedPanel
  (its own AppKit child, no setDock on its path); it passed alone and in
  3 package runs after. Filed as #1661, cause not found.
  go test -tags nogui ./internal/gui green. gofmt -l clean; go vet
  ./internal/gui (darwin), GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/gui clean.

Not tried: a real magpie build with osascript Command-Tabs (as 15872d977
did) after this change; the full-screen join (dockOnFullscreen), which
still reads isActive at NSWindowWillEnterFullScreen, long after any
activation, and is unchanged.
2026-10-12 00:57:27 +08:00
yetone 18e82adc62 gui: the window's pages down a sidebar in groups, the open page's tabs under it, and a button to have the header's tabs instead
From 1024 points wide (SIDE_AT) the window lays its pages down the left
as a Mac app's sidebar: Work (Agents, Sessions, Library), Models
(Providers, Routing, Gateway), Insights (Usage), Extend (Plugins), with
Settings and the gateway's address at the foot. The open page's own tabs
(Usage, Library, Plugins, Settings) are listed under it, opening and
folding on an iOS-like spring, and the page's strip is hidden. The header
becomes a breadcrumb, and pages whose head held only tools have them in
the title bar. Graphite: the open page is in the text's ink, not purple.
A pressed row darkens and never shrinks. The selection under the tabs
sets off as the row is pressed, on a 0.3s curve (it felt behind the
finger), and is the list's only shape: a sub-row hovered or pressed has
no ground of its own, which showed a block under the finger before the
selection slid there. The page's tab is clicked at once, so what is
typed next goes to it.

The title bar's button (or ⌃⌘S, Ctrl+Shift+S), there at every width,
picks the sidebar or the header's tabs. The choice is kept in
localStorage magpie.navLayout (side or top) at every width, so it is laid
out from the first frame; picked in a narrow window the sidebar is 184
points under 860. The two trade places in
a view transition: the sidebar slides, each tab flies to its place, and
the page slides as one. Without view transitions or under reduced
motion, the change is at once.

With nothing picked, narrower than 1024 the page beside a sidebar would
be narrower than Usage's requests table needs, so the header's tabs come
back. A resize
drops what a click held (heldWidth). Usage's KPI strip goes two to a line
by the room the page gives it (a container query), and Japanese counts
wrap there. Tests whose window is 1024+ were updated for the sidebar,
and docs/subsystems/gui-shell.md says how it works.

Run: sidebar.test.cjs and side-toggle.test.cjs 16/16 in chromium and
webkit, in en, zh, zh-TW, ja and de. Each was broken by hand (press
shrink, address cut, press glide, sub-row ground, view transition, kept
choice) and went red. Every page at 560 points with the sidebar picked,
zh and de, both engines: nothing scrolls sideways. session-identity's
ledger row sits under the footer beside the sidebar; WebKit's click
doesn't scroll to it, so the test wheels it up first. Animation frames were checked from a recorded video. The 105
affected GUI files in both engines; their reds were rerun alone and fixed
(filter-ime: the sub-row's click now at once; session-identity, above) or
fail the same on main (tray-logos). The full GUI suite in chromium, on
the rebase onto d5cae267a, was cut short at 352 tests on the owner's
"ship": 6 reds (account-alias, account-models, codex-auto-review,
codex-credits, context-text) each pass alone, here and on main d5cae267a,
so they are timing under the full run's load and are to be filed. After
rebasing onto e4e22b23e: sidebar, side-toggle, session-identity,
filter-ime, library-instr-busy, usage-speed-count and view-scrollbar,
50/50 in chromium and webkit. go build ./... passes.
2026-10-12 00:41:34 +08:00
yetone 96de5cac29 gui: Providers has a search box, and a provider's right-click moves it to the top or the bottom (#1614, ququdu)
ququdu has many providers and kept scrolling to find one, and moving one
far up the list meant a long drag. The Providers page had neither a search
nor a quick move; its rows moved only by dragging the logo or Alt+↑/↓ one
step at a time.

- A search box over the list, at its right edge as Settings' is (full width
  in a narrow window). The words typed keep the rows, on and off, whose
  text or data say them all: name, id, preset, addresses, every model's id
  and name, the account's user and plan and each login's, account names
  and key names. The Turned off fold stays open while searching; nothing
  found says so; Escape or clearing the box shows every row and the fold
  as it was (findProviders).
- A row that is on has a right-click menu, as an agent row has: Move to
  top, Move up, Move down, Move to bottom (openProviderMenu), with their
  keys. Alt+Shift+↑/↓ on the logo go to the top or the bottom.
- While searching, a row still moves, among the rows shown: Alt+↑/↓ and a
  drop put it where the shown row it passes was, and the hidden rows keep
  their order (stepProvider, shownToOn). Move to top and Move to bottom go
  to the ends of the whole list. Every move saves the whole order through
  /api/providers/arrange as before.
- After a save, the keyboard stays on the handle it is on, also when it
  was another row's taken up while the save was out (it was lost before).
- The logo's tooltip says right-click moves it to the top or the bottom.
- Drag already scrolls the page near its edges (dragRows); unchanged.

Strings in zh, zh-TW, ja and de. docs/subsystems/gui-shell.md says how it
works.

Run:
- provider-find.test.cjs (new), en, zh, zh-TW, ja, de at 420x560, Chromium
  and WebKit: matches by name, model id, account user, key name and two
  words; the off row found with its fold open; nothing-found text; Alt+↑ and
  a drag while filtered, with the posted order checked; Escape; the menu's
  four items, which are off at each end; Alt+Shift+↑/↓; nothing scrolled,
  nothing but the order posted, no overflow. Fails on the old assets ("no
  search box on the Providers page"), and goes red with each of five breaks
  by hand: steps over the full list while filtered, no right-click menu,
  drop index taken as a full-list index, no Alt+Shift, the off fold
  honoured while searching.
- provider-order.test.cjs updated for the tooltip.
- Every GUI test that opens the Providers page (150 files): WebKit 754/754;
  Chromium 748/752 under load ~100, the 4 in azure-endpoint and
  routing-save (30s waits on the add sheet and routing) pass alone in both
  engines, with provider-search, provider-order and settings-search
  (31/31). gui-zh-tw, gui-ja, gui-de pass in both.
- go test -tags nogui ./internal/gui/... (sandbox HOME), go vet darwin,
  GOOS=linux and GOOS=windows -tags nogui.
- Screenshots looked at: zh narrow with a search, zh wide with the menu.
2026-10-11 21:42:30 +08:00
yetone 917a365778 gui: opening the Usage page or the tray panel's Allowances reads the allowances now, once in 30s (#1588, qq666666qq)
On Windows the tray panel's Allowances tab, and the window brought back
on Usage, showed the reading magpie kept until "Read the allowances
again now" was pressed: picking the panel's tab and the panel shown
again only loaded usage/quotas without ?asked=1, which hands back the
backend's cache, and so did the window coming back to the front on
the Usage page.

Opening the allowances is now asking to see them (quotasOpened), as
Refresh now is and as #1518 counts the Usage page opened:
- the window: Usage from the nav (as before), the Overview tab picked,
  and the window back to the front on the Overview;
- the tray panel: the Allowances tab picked, the panel brought up on it
  (focus / visibility), and a menu bar cell clicked (panelQuotaFocus).
A panel page loaded while it is put away (hidden or without focus)
doesn't ask, so a panel prepared at login sends nothing with allowance
reads at "When I ask".

An asked read makes the backend read every account again (AskUsage
clears the caches; only Claude has its own 30s floor), so an opening
within 30s of the last asked read (QUOTAS_OPEN_GAP) sends an ordinary
read instead: switching tabs and back, focus and visibilitychange both
firing, focus-follows-mouse don't reach the vendors again. Reads stay
one at a time: an opening during an ordinary read goes after it
(loadQuotas, unchanged). Refresh now still asks every time; the timed
refresh is unchanged and never asks.

Written against main from qq666666qq's fork patch
(qq666666qq/magpie#1), which asked on every tab click and every return
without a gap; this keeps their entries and adds the gap, the Overview
tab, and the hidden-panel guard.

Run: new allowance-open-read.test.cjs (Chromium and WebKit, en and zh,
panel at 360px): passes; red on the old app.js (the panel's Allowances
never asks; the window re-asks on every nav click), red with
QUOTAS_OPEN_GAP = 0, and red with the window-return line removed. The
GUI tests touching the allowances (every test naming usage/quotas, the
Usage view or the panel's Allowances tab) in both engines, and
go test -tags nogui ./internal/gui. No Go changes. Not tried in the
native Windows tray.

Of the GUI run (3164 tests, load ~120-230), the 8 failures passed when
their files were run again, except library-mcp-tool-switch in WebKit,
which fails the same with main's app.js (76db4c6c2): filed as #1609.
Rebased onto f6e1e98ee; the new test, claude-usage-asked, panel-usage,
panel-arrange, click-scroll and ./internal/gui run again after it.
2026-10-11 19:46:37 +08:00
yetone 15872d977a gui: with the window open, magpie leads Command-Tab's order, so one Command-Tab away and one back returns to it (#1381, ttmouse)
ttmouse on v0.1.1168: open magpie's window, Command-Tab to another app,
Command-Tab back, and magpie is last in the switcher.

Cause: magpie is out of the Dock (Accessory) until the window opens.
With Settings > Dock set to "while the window is open" (or a full-screen
window), the quick panel's focus activates magpie while it is still
Accessory, and it joins the Dock (Regular) after that. An app activated
before it joins stays last in LaunchServices' front-to-back order
(lsappinfo visibleProcessList), which Command-Tab follows, though it is
frontmost. Wails' Focus only calls activateIgnoringOtherApps when the
app isn't active, and calling it again while active is a no-op. setDock
also ran async (dispatch_async), so openMain's Show/Focus could come
before the policy change.

Fix:
- setDock runs on the main thread at once (InvokeSync), so openMain
  joins before it shows the window.
- A pure dockStep(regular, on, active, front) decides the move. Joining
  while already active activates the Dock and then magpie again
  (activateAgain), which puts magpie first in the order. Joining while
  not active just activates it; leaving never re-activates.
- The full-screen join does the same once the window is in full screen
  (DidEnterFullScreen) if magpie was active when it joined.
- Dock "off" (the default) is unchanged: magpie stays out of the Dock
  and out of Command-Tab, by design. The tray panel's behaviour is
  unchanged.
- docs/subsystems/gui-shell.md: Runtime path item 7 for the Dock setting.

Run:
- TestDockStep (table, pure). TestDockJoinLeadsCommandTab (darwin GUI
  build): a real Accessory Wails app activated, then setDock(true,
  true) + window Show/Focus, asserts it is first in lsappinfo's order.
  Red with `again` forced false (front was the test, kitty first in the
  order), green with the fix.
- go test ./internal/gui (GUI build, darwin) passes; full
  go test -tags nogui ./... passes; gofmt -l clean; go vet ./internal/gui
  (darwin) and GOOS=linux / GOOS=windows go vet -tags nogui clean.
- Real build on this Mac, sandbox HOME, own bundle id, port 3481,
  DockWindow on: launched with the quick panel, window opened through the
  Mac's reopen, then two osascript Command-Tabs. Old build: magpie front
  but 11th of 11 in the order (the report). New build: magpie 1st; after
  Command-Tab, the other app 1st and magpie 2nd; Command-Tab again brings
  magpie back. Dock "always": magpie 1st, round trip works. Dock "off":
  stays UIElement, not in the order.

Not tried: the full-screen path in the real build, a human Command-Tab
(only osascript keystrokes), real accounts (not involved).
2026-10-11 19:30:17 +08:00
yetone 1c0eab7c84 gui, gateway: every search API takes a base URL of the user's own, under its key in Settings (#1580, xzhlksh)
The reporter has endpoints that answer as Tavily, Exa and others do, at
addresses that aren't the vendors', and Settings only took a key. The
saved SearchAPI already had a url, and the CLI's url= set it, but the
Settings row showed the field only for SearXNG and sent "" for the rest.

- Settings › Models › Web search: the add row has a base URL field on a
  line of its own under the key, for every API, with the vendor's own
  address as its placeholder (searchVendorJSON.base). Picking an API
  already added fills in its saved URL, so Add with a new key alone keeps
  it; Add with no key typed changes only the URL, the key kept (the key
  placeholder says so). Strings in zh, zh-TW, ja, de.
- provider: check() also refuses a URL with a ?query or #fragment, since
  the vendor's path goes after it.
- gateway: the key goes only to the URL set. Go drops Authorization on a
  redirect to another host but keeps Brave's X-Subscription-Token and
  Exa's x-api-key, so a search API's redirect to another host is not
  followed; the error names where it was sent. The request still goes
  through the gateway's client and so magpie's proxy settings.
- CLI: `magpie search add <api> <key>` keeps the url set before; `url=`
  with nothing after it puts the vendor's own back (was: a new key alone
  dropped the url).
- docs/subsystems/gateway-routing.md: "A search API's base URL";
  gui-shell.md: the field.
- search-api.test.cjs: Settings is drawn twice (/api/state, then
  /api/settings), so scrolling to the add row can hit a detached node
  (WebKit, 1 in ~6 runs here); it retries the scroll.

magpie ships and lists no third-party search endpoint; the URL is only
the user's.

Tests (sandbox HOME, pinned caches):
- TestSearchAPIAtItsOwnBaseURL: an httptest fake at <fake>/relay/<vendor>/
  gets tavily POST /relay/tavily/search with Bearer, exa POST
  /relay/exa/search with x-api-key, brave GET
  /relay/brave/res/v1/web/search with X-Subscription-Token, firecrawl
  POST /relay/firecrawl/v2/search with Bearer. Passes on the old gateway
  too: the backend already honoured a url.
- TestSearchKeyStaysAtItsBaseURL: with search_api.go put back, FAIL
  "a key reached another host: exa-secret / brave-secret".
- TestSearchCLI: with search_cli.go put back, FAIL "a new key took the
  base URL away"; with provider/search_api.go put back, FAIL
  "url=https://x.example.com/?k=1 taken".
- TestSearchAPIBaseURLFromSettings: POST /api/settings/search-api saves,
  keeps the key, refuses ftp/no-scheme/query URLs, lists vendor bases.
- search-api.test.cjs in Chromium and WebKit, en and zh, 980px and
  420px: 8/8; with the old app.js, FAIL "Tavily takes a base URL"
  (false !== true). WebKit 980px 10 runs in a row green after the retry.
  search-first, search-mcp, searcher-pick, i18n-keys, gui-ja, gui-de,
  gui-zh-tw, click-scroll with it: 45/45 in each engine.
- Screenshots at 980/420 in both engines checked by eye.
- go test -tags nogui -timeout 40m ./... on 5fa908c08 + this: all 48 packages ok. gofmt -l clean; go vet, GOOS=linux and GOOS=windows go vet -tags nogui on ., internal/gateway, internal/gui, internal/provider: clean.

Not tried against a real third-party endpoint or a real vendor key.
2026-10-11 14:21:29 +08:00
yetone afe0c59d2d gui: on a Mac window a popover that opens upward stops under the traffic lights, not over them (#1573, lyston11)
In a short Mac window, Pick (an agent's model list), the field picker
(#pop) and every app menu (placeMenu) were held only 8px from the top
when they opened upward or were held to the window's top, so they
covered the traffic lights and header.top, which the system draws them
over.

popTop(pad) is now the highest a popover's top edge may go: 8px under
header.top's measured bottom on a Mac window (so it follows --zoom), and
8px from the top everywhere else, as before. openAgentModels, placePop
and placeMenu use it in place of pad for the top. placePop also holds
#pop's max-height to the room between that edge and the foot when its
CSS max-height doesn't fit, so a picker held to the top scrolls inside
itself instead of running off the bottom (it already did run off before
this change in a very short window; moving the edge down would have
made that worse). Nothing else clamps a popover to the top: the
remaining getBoundingClientRect placements (profiles in the panel, the
heat-map tip, the rail tip) are kept inside their own card or panel.

Run:
- new internal/gui/tests/popover-mac-chrome.test.cjs: Chromium and
  WebKit, en and zh, MacIntel and Win32, 480px wide: 8/8 pass, 4 runs in
  a row. On the old app.js it fails (model list top 8 < 58 on Mac, the
  picker off the bottom on Windows). Breaking each placer by hand turns
  it red on its own: model list top 8, picker top 8, menu top 17.
- related GUI tests, Chromium and WebKit, all pass: click-scroll,
  agent-models, agent-models-picker, -all-hidden, -loading, -only-picked,
  -redraw, agent-model-groups, menu-scroll, proto-menu-overflow,
  codex-app-menu-cap, desktop-model-menu, editor-short-window,
  removed-groups-menu-scroll, agent-start-pick, agent-leave-magpie,
  claude-picker-fold, header-zoom-fit, header-centre, text-size.
- HOME=<scratch> go test -tags nogui ./internal/gui: ok.
- GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gui: ok.
2026-10-11 12:32:32 +08:00
yetone 9bb68615b0 gui: a scroll not the reader's made just before a click is put back, not kept as where the reader was (#1554)
skill-install-agents-all.test.cjs was red on main in Chromium at 420px
(en, ja, de): the install picker's All chip, clicked, left the Library
view 5px down.

Cause: the browser tells the page of a scroll at the next frame. The test
clicks while the Library view is still sliding in (view-in, translateY
5px), and Playwright's click scrolls the chip into view first; with the
view 5px taller than it is high at 420px, that scroll takes the view to
its 5px foot. The click came in before that scroll's event, so the click
guard took its snapshot (held.chain, held.top) at 5px and every hold()
after kept it there, the scroll event included. A real click can do the
same: WebKit scrolls a field focused on the press, or code scrolls just
before the click, and the scroll was adopted as the reader's.

Fix (app.js, the click guard): before taking a click's snapshot, a view
not scrolled by the reader (no purposeUntil window, no scrollbar drag)
is put back where the reader left it (backToReader), as the scroll
listener would have done a frame later. A click in quick turn after
another still holds that one first, as before.

The guard is shared by every view, so every picker and button is covered;
the library picker needs no change of its own (the MCP editor's picker is
in #modal, outside any view).

Tests:
- click-scroll.test.cjs: new "a scroll the page hears of after the click
  is still put back" (scrollTop += 40 and a click in one task). Red on the
  old app.js in Chromium and WebKit (expected 2020, actual 2060), green
  with the fix.
- sessions-manage-paging.test.cjs scrolled with Playwright's
  scrollIntoViewIfNeeded and clicked Show more before the next frame, so
  it passed in Chromium only through this bug (the guard puts that scroll
  back a frame later; it was red in WebKit on main). It now scrolls with
  the reader's wheel; green in both engines.
- docs/subsystems/gui-shell.md says a click is taken where the reader
  left the view.

Run: skill-install-agents-all.test.cjs red before (en/ja/de 420px,
"view:5,0"), green after in Chromium and WebKit, every language;
click-scroll.test.cjs green in both engines; 306 GUI test files that
assert on scrolling or touch the library/skills/MCP, then the other 253,
both engines. Failures seen there were rerun alone: purpose-filter (WebKit,
1px, #1291) and search-api (WebKit zh, #1442) fail the same on the old
app.js; the rest pass alone. No Go changed.
2026-10-11 12:14:35 +08:00
yetoneandxiaohei-info 3144868538 gui, gateway: the Providers and Gateway pages no longer download every recent call's bodies; an opened call reads its own (#1521, xiaohei-info)
GET /api/providers carried up to 40 recent gateway calls with their
request and response previews (up to 256 KB each) in gateway.calls,
and every provider write returned the same state. The Providers page
never shows them; only an opened row on Gateway does. With 40 calls of
~300 KB each, /api/providers was 21,019,635 bytes on origin/main.

Taken from xiaohei-info's patch (bb26b802, attached to #1521 as
external PRs are closed): providersState drops the bodies from the
calls it sends; GET /api/gateway/call returns one call's previews and
truncation flags with Cache-Control: no-store, 404 once it has left
the ring; the page fetches on open, dedupes a pending read, keeps
loaded bodies across refreshes, drops them with their call, shows
"Fetching…" and a "Try again" on a failed read; the strings in zh,
zh-TW, ja and de; the Go and Playwright tests; the gui-shell note.

Changed from the patch: a call is asked for by a number the gateway
gives it in the ring (Call.ID, Server.RecentCall), not by time, agent
and model, which two calls of one agent to one model can share. The
page keys a row by that id too (callRow), so two such calls no longer
open, or show the bodies of, each other. The tests ask with ids, and
the Playwright fixture gives two calls the same time, agent and model.

The route is on the same mux as the rest of the API, so magpie web's
key guard covers it, and the gateway's own port doesn't serve it. The
bodies are the ones the ring kept, masked as before (redacted runs
before capture). Nothing else reads gateway.calls' bodies: Routing
reads /api/gateway/trace, and the tray, TUI, CLI and /api/state don't
read the ring.

Run:
- Real use: magpie web built from origin/main and from this commit,
  sandbox HOME, a local upstream answering 300 KB, 40 calls of 300 KB.
  /api/providers 21,019,635 bytes before, 45,525 after (calls: 14,503
  bytes). Opening a row in Chromium and WebKit fetched
  /api/gateway/call once (524,412 bytes) and showed both bodies with
  their "first 256 KB" marks. Without the key: 401, also for a
  rebound Host; on the gateway port: 404; an evicted id: 404.
- TestRecentCallBodiesOnDemand fails with the bodies left in
  providersState ("providers must keep call metadata without sending
  bodies"), and with RecentCall ignoring the id ("the second call's
  detail isn't its own").
- recent-call-bodies.test.cjs fails on main's app.js, and with callRow
  keyed by time|agent|model again.
- GUI: gateway-fold, json-tree, phone-rows, recent-calls-more,
  request-archive, recent-call-bodies, sse-body: 24/24 in Chromium and
  24/24 in WebKit (en, zh, zh-TW, ja, de).
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on
  internal/gui and internal/gateway.
- Full GUI suite: 5225 tests, 71 failures under load ~200, none in a
  gateway or recent-call file. The 20 files with failures, rerun on
  this commit and on origin/main: 54 and 58 fail; what fails on one
  only (Sessions checkbox colour, Sessions paging scroll, account
  dragging, ZCode block) moves between runs on both.
- go test -tags nogui ./...: every package ok on the rebased head.

Co-authored-by: xiaohei-info <14011749+xiaohei-info@users.noreply.github.com>
2026-10-11 03:12:46 +08:00