starballl on X (tweet 2122376116220633444) runs several magpie web pages
and every tab is titled "magpie", so they can't be told apart. A magpie
now has a name, and a browser tab's title is "<name> · magpie" (plain
"magpie" with none).
- settings.Name, set in Settings › Network and sharing › Advanced › Name
(instancename.js, imported when Settings is drawn, so nothing is added
to app.js's core). Advanced is closed until a name is set.
- MAGPIE_NAME (Docker, magpie web) names it while the field is empty and
is the field's placeholder. It is read, never written, so a name typed
in Settings always wins and clearing the field goes back to it.
- One line, at most 60 characters (settings.CleanName).
- This computer's own (KeepOwn): sync and a restored backup never bring
another magpie's name. A Settings save that leaves `name` out keeps it
(settingsapi.Merge).
- boot.js titles a browser tab itself for the first paint, so app.js's
core gains only the line in applyPrefs, which sets the title again from
every settings read (TestCoreScriptBudget was 74 bytes over with a
title function in app.js). Only a browser page (web) is retitled: the
app's windows and tray keep "magpie".
- Docker docs (en, zh, ja) list MAGPIE_NAME; docs/reference.md and
docs/subsystems/gui-shell.md say how it works.
Tests:
- TestInstanceName (internal/gui): the variable alone names it at boot;
a saved name wins over it, trimmed; a save without `name` keeps it;
KeepOwn keeps it; cleared goes back to the variable; no name, none at
boot. Broken by hand, each red: KeepOwn without Name ("KeepOwn took
\"other\""), Merge without the keep ("a save without the name changed
it to \"\""), boot.js with s.Name in place of InstanceName ("named by
the variable alone: boot <nil>"), boot.js not setting the title ("a
browser tab's boot.js sets no title"). The app window's boot.js sets
none.
- TestSettingsSaveKeepsWhatItDoesNotSend now sets Name: the page's other
saves leave it out, and it is kept.
- instance-name.test.cjs: title from the first paint, the field under a
closed Advanced, save and clear retitle the tab, Advanced open after a
reload, 360px, the app's window keeps "magpie"; en, zh, zh-TW, ja, de,
Chromium and WebKit, 16/16. 14 of 16 red with applyPrefs not setting
the title.
Run, at this commit on dbbb2f26b plus 9d5d8baf2 (the site index):
- go test ./... -count=1 -timeout 45m on Linux (WSL magpie-desktop, Go
1.26.8), at the tree before the boot.js move: 99 packages ok,
internal/gateway included (959s); ., internal/cli and internal/gui
don't build there without GTK headers. On mica (macOS): . and
internal/cli ok; internal/gui/... ok at this commit, after the two
reds that run found (the core budget, the keep test) were fixed.
- go vet and GOOS=linux -tags nogui / GOOS=windows go vet of
internal/gui and internal/settings, earlier the whole tree on all
three: ok. gofmt -l clean.
- site: node --test *.test.mjs, 132/132.
- GUI: the 135 files the change reaches (settings, network, LAN, i18n,
old-webkit, core budget) on mica: 16 files had reds. Run again on this
tree and on its base, the same tests are red on both (allow-ips
#4357, settings-hints #6107/#6353, lan-join #6353, i18n-keys #6877,
old-webkit #6030/#5919 and the rest of the 16) but two:
search-mcp-library (WebKit, #4756) and gateway-pause (WebKit de 420px,
#6684), red only beside other files: alone, 0 of 10 and 0 of 3 red on
both trees.
200 KiB
GUI app shell
The desktop app has a tray (menu bar) icon whose click drops a compact
panel, and a regular window. Both show one small web UI served from
embedded assets. The page talks to Go over a JSON API on the same handler,
with no binding generator and no bundler. magpie web serves the same page
to a browser for a machine with no desktop. Package internal/gui hosts all
three.
Responsibilities and sources of truth
| Part | Responsibility | Source |
|---|---|---|
| Native host | Run starts the Wails v3 app: the tray icon, the panel, the main window, single-instance handover, magpie:// import links and open at login. host implements Windows for the API: show and hide, open URLs and folders, copy to the clipboard, fit and tint the panel, and set the text size. A copy on Linux sets PRIMARY before CLIPBOARD, since GTK 3 serves CLIPBOARD empty when PRIMARY is set after it on a compositor with no primary selection (KDE Plasma with middle-click paste off, #1881); on Wayland the copy is read back through the compositor, and one that doesn't read back whole answers /api/copy with 501, so the page tries its clipboard API, then the copy command, then says the copy failed with the text to copy by hand (copy-fallback.test.cjs). On Windows, Wails reads the screens again on each display change (WM_DISPLAYCHANGE, and WM_SETTINGCHANGE for the work area) through w32.GetAllScreens, which makes a new Win32 callback each time; Go never frees one and throws past about 2000, killing the app and its gateway after hours of display changes (1111_13879 on Discord). screensWndProc, the app's WndProcInterceptor, takes those messages on Wails' main-thread window first and reads the screens with one callback made once (allScreens), then hands them to Screen.LayoutScreens as Wails would; see TestScreensReadFarPastTheCallbackLimit, TestDisplayChangesAreReadOnWailsWindowOnly (Windows) and TestWailsScreensAreReadOnTheMainThreadWindow, which fails when a Wails upgrade changes what that relies on. On Windows appWndProc also installs a thread-local WH_CBT hook (hookNoActivate, noActivateCBT in noactivate_windows.go) on Wails' main thread to turn down HCBT_ACTIVATE for hidden windows and windows shown quietly (showQuietly, showMinimised), and unhooks it (unhookNoActivate) when the main-thread window is destroyed or the app shuts down so ExitProcess's FLS cleanup (msctf!CicFlsCallback) cannot call back into Go while runtime.exit holds runtime.finlock (#6705, TestUnhookNoActivatePreventsExitDeadlock). |
app.go, screens_windows.go, noactivate_windows.go, clipboard_gtk3.go, clipboard_gtk3.h, mainwindow.go, traymenu.go |
| Backend | startBackend starts the gateway this process serves, unless another magpie already serves it. In that case this process only shows the other one's status (gw is nil), and watchGateway looks at it again every 15 s (gatewayWatch). A magpie of another version there (otherServes in gateway_older.go) is told the page as gatewayOther in /api/state and said over the Agents list (gatewaySkewLine in plugins/gateway/client.js), in the panel and the window: pi got 404 for a model the newer app had written it while an older copy of the app kept the gateway, and only the Gateway page said so (matrix0487 on Discord). An older released copy of the app (serves app or tray, with a pid) is this app's own predecessor: once its /v1/magpie/concurrency says nothing is in flight (gateway.ServedBusy; unknown is never idle) the app quits it as the Gateway page's button does (quitMagpieOnPort, a magpie only) and serves the gateway, so no stream is cut; at most three times a run (replaceMost), and a quit that fails is left to the button. Any other (magpie serve or the service, magpie web, a TUI, a newer magpie, a build of its own) is left running, with what to do; a dev build of this magpie says nothing. A request that starts between the idle read and the quit gets the older app's short drain. See TestAppReplacesItsOlderGatewayOnceIdle, TestGatewaySkewOfAnotherIsSaidNotQuit and gateway-skew.test.cjs. magpie serve (the service's, launchd's com.yetone.magpie.serve or systemd's) does the same beside a magpie serving or another program holding the port: before it moves or starts anything (startUp), it waits, looking every 15 s, and serves once the port is free (awaitGatewayFree in serve_wait.go; --web excepted, which shows the other one). Before, it ran the start-up moves, the plugin host and every account's model fetch, failed to bind, exited 1 and was started again by the service, 6,035 times in two days with a 279MB serve.log and requests 504 behind it (#4938, TestServeWaitsForTheGatewayBeforeStartingUp). stopServing drains requests in flight. A restart to update can hand the listening socket to the new version instead (see A restart to update hands the gateway over). |
backend.go, gateway_older.go |
| API and assets | Handler serves assets/ (embedded with //go:embed assets) and the /api/* routes, such as /api/state, /api/set, /api/agents/{action}/{id} and /api/agents/restart/{id} (a desktop app's Restart, after the row's confirm). held lets one API request's reads share one catalog build (provider.Hold), and drops it after any write. revalidated and versionedPage name each script by its content hash, so a cache never serves an old app.js under a new page; a file asked for under its current hash (?v=) is cached for good (immutable), anything else is revalidated by its ETag. |
api.go |
| Settings from the terminal | POST /api/settings saves through settingsapi.Apply (internal/settingsapi, outside the GUI so the nogui build has it): the carry of keys a page leaves out (Merge), the vision, image and searcher checks, settings.Save's own checks, and catalog.Touched. magpie settings list|get|set|reset (#4745) builds the same body with settingsapi.Body (the whole file with one key changed, so a key the save keeps when it isn't sent is set even to off) and calls the same Apply; a refused value writes nothing. settingsapi.Keys names what the save writes; TestKeysAreWhatTheSaveWrites fails when a field of settings.Settings is saved without it, TestSettingsCLISetsWhatTheWindowSaves when a key the page's savePrefs sends isn't one, and TestEveryRouteHasACommandOrIsNamed when an /api route has neither a command nor a reason in notYet (internal/cli/settings_parity_test.go). The running app's in-process follow-ups (fonts, Dock, tray menu, alerts, language, update check) run only from the window's save; a change from the terminal is read from the file. |
internal/settingsapi/settingsapi.go, settings_cli.go |
| Browser mode | StartWeb serves the page and the gateway for magpie web. The browser signs in with a run key in a link. On a LazyCat box MAGPIE_WEB_SIGN_IN=lazycat lets the box's administrators in without it, signed in to the box (webBoxSignIn, lazyCatSignIn): the box's ingress names the account, its role and what sent the request (X-HC-User-ID, X-HC-User-Role, X-HC-Source) in place of the caller's own, and an ADMIN from a browser (client), each named once, gets in with no cookie of the page's own, asked for each request. The box's sign-in is the box's cookie, which a browser may send with another app's page's requests (the box's apps are one site), so it takes only what the page or a browser opening it asked for (boxFetched: Sec-Fetch-Site same-origin or none, or a GET or HEAD navigation to a document from another page); any other request, and one from a browser without Fetch Metadata, is turned away with the reason. StartWeb refuses another value, and lazycat without LAZYCAT_APP_DOMAIN, where no box's ingress sets those headers; that is all it can check: the setting is the package's word that the ingress is the only way to the page's port. The app's Browser access page takes its key alone (apppage.go), and the client routes on the page's port never take the box's sign-in. See TestLazyCatSignInOpensThePage, TestLazyCatSignInTurnsAway, TestLazyCatSignInAsksWhereFrom, TestLazyCatSignInIsAskedEachTime, TestLazyCatSignInIsNoGatewayKey and TestWebBoxSignInChecksItsValue. Added to a phone's home screen the page opens as an app of its own, with no browser bars (ninja_s6114 on Discord): index.html names manifest.json (display standalone), an apple-touch-icon and the iOS meta tags, the status bar keeps its own ground (default), and its theme colours match only (display-mode: standalone), so a browser's tab and the app's windows take none. webGuard serves those three files (webAppFiles: the manifest, icons/apple-touch-icon.png, icons/icon-512.png) without the key, to GET and HEAD at those exact paths alone, as a home screen may ask without the cookie; see TestWebAppAddsToHomeScreen and web-app-standalone.test.cjs. The cookie is SameSite=Lax, which a browser sends with any request from the same site, other ports and sibling subdomains included, so webOwnPage answers /api for the page's own origin only: a write goes through net/http's CrossOriginProtection (Sec-Fetch-Site same-origin or none; from a browser without it, an Origin that is absent or names the Host or MAGPIE_PUBLIC_URL), and any request whose Sec-Fetch-Site says another origin sent it is refused, a GET too; see TestWebAPIAnswersItsOwnPageOnly. The desktop window's /api is in-process with no cookie and isn't held to it. Gateway mode shows every page but Agents on a machine that is only a gateway (GATEWAY_HIDES); the Library has its MCP servers and the MCP router alone, for other computers' apps to reach with a gateway key (treeman_26897 on Discord, gateway-mode.test.cjs, library-mcp-agentless.test.cjs). webHandler gzips the page's text files and the API's JSON for a browser that takes gzip (webCompressed, with a -gzip ETag that still answers 304; never an event stream, which gzip would hold back until its buffer fills); the app's own windows read the page in-process and get it uncompressed. The page's port answers the gateway's client routes too (onePort, gateway.ClientPath: /v1/…, /v1beta/…, /mcp/…, the Codex backend path and the routes without /v1; never /api/* or /_magpie/*, never a path that isn't clean), so one reverse-proxy location serves the page and the agents (zgcwkj on Discord). They skip the page's key and gzip and go to the gateway's own guards, always as a request from another machine (gateway.FromPagePort, the X-Magpie-Page-Port mark: local is false for it, from loopback too and under MAGPIE_TRUST_PROXY, so magpie must be shared and the request carry an enabled gateway key), since a raw TCP forward or a proxy that adds no forwarding header reaches this port from loopback looking like an agent here (reported privately by Coffemon); agents here use the gateway's own port. Server.Front (lanGuard over Handler) serves them in process when this process serves the gateway, or toGateway, a reverse proxy to gateway.URL(), when another magpie does; it keeps the Host, the forwarding headers and the mark, adds X-Forwarded-For for a peer that isn't loopback, and the peer's loopback address as X-Forwarded-For when none came, so a gateway of an older magpie that doesn't know the mark still asks for a key. lanGuard moves the mark into the request's context and takes the header off, so it never goes upstream. The page itself calls no client route. See TestWebOnePortServedHere, TestWebOnePortServedElsewhere, TestWebOnePortAgentsHereUseTheGatewayPort, TestPagePortMarkIsNeverLocal and TestClientPathCoversHandler. |
web.go, web_lazycat.go, gatewaymode.go, oneport.go |
| The app's page in a browser | Settings › Network and sharing › Browser access (renderWebPage in plugins/gateway/settings.js, drawn with the Web pages rows) has the app serve its own page to a browser while it runs, so a tunnel (Cloudflare Tunnel, SSH) or a computer on the network can reach it without magpie web kept running in a terminal (jiakun_zhao on X). Off, This computer (127.0.0.1, which a tunnel's service points at) or Local network (every address; a "Not encrypted" row without --tls-cert). It is magpie web's page and guard, not a second kind: startAppPage (from Run, after startBackend) serves webServed over a Handler of its own, whose Windows is appWebHost (a browser tab for isWeb, but not ownWeb, so the app's windows aren't taken for magpie web's: webPage and gateway mode stay the app's; quitting quits the app, and a restart to update from it brings back the windows the app has up, restartFrom). The key is always asked for: no mode serves without it. It lives with the mode and port in web-page.json beside settings.json (0600, never in settings.json, so sync and backup don't carry it), is made the first time the page is turned on, kept across restarts (a browser's cookie stays good), and replaced by New key, which turns away every browser signed in with the old one (the guard is swapped atomically, appPage.cur). A file that can't be read, or names no known mode, is off and says why; Settings rewrites it only given a whole choice. A port another program holds (magpie web; the magpie before a restart to update) is said and tried again every 4 s (appPageRetry); the port must be 1024 up and not the gateway's. GET/POST /api/web-page are on the app's own windows' API only, never a browser's, so a browser on the page can neither read the key it came in without nor turn the page off under itself. magpie web on the port the app serves prints the app's link and opens it rather than starting a second (gui.AppPage, samePort). Sessions are warmed once a process however many Handlers there are (warmOnce). See TestAppPageServesOnlyWithItsKey, TestAppPageWaitsForABusyPort, TestAppPageUnreadFileServesNothing, TestAppPageTurnsDownBadChoices, TestAppPageBrowserIsATab and browser-access.test.cjs. |
apppage.go, web_cli.go |
| Another magpie in a window | Settings › Network and sharing › Another magpie (renderRemote in plugins/gateway/settings.js) opens a magpie elsewhere, a server's (magpie daemon install --web, magpie web, another app's Browser access), in a window of the app's own, so its routing and usage are read from the desktop (xuanwo on X). The window (OpenRemote, remote_app.go) loads that magpie's own web page with ?k= and signs in through its webGuard as a browser does: nothing is served here, and the page in it reaches that magpie alone (a remote page gets no bound calls). The address is the link that magpie printed (its k= taken out as the key) or a bare address, https:// when no scheme is typed; plain http only to an IP, localhost, a .local or a one-word name (remoteAddr), as a Mac's webview allows, so the key never crosses the internet in the clear. Before the window opens, remoteProbe asks for the link without following it: only a 303 setting a magpie_web_* cookie is that magpie taking the key; a 401, a 403 (allowed addresses), an untrusted certificate, no answer or anything else is said in Settings. Address and key live in remote-magpie.json beside settings.json (0600, never in settings.json); GET /api/remote says the address and whether a key is kept, never the key, and POST /api/remote with no key uses the one kept for the same address. The routes are on the app's own windows' API only (!isWeb), and a host that can't open windows refuses. See TestRemoteAddr, TestRemoteOpensTheOtherMagpie, TestRemoteNotMagpie, TestRemoteNotOnBrowserPages and another-magpie.test.cjs. |
remote.go, remote_app.go |
| The page | app.js keeps one state object per view and renders it into a list, with no framework. The views have their own files: plugins.js and context.js, and those a plugin adds under assets/plugins/<id>/ (the Gateway, Sessions, Library, Routing and Usage pages, see plugin runtime) (Usage's Context tab, and the context window card the Routing page draws under a request's story, fed by /api/context in context.go, which scores and tags each agent; a client whose User-Agent names only an HTTP library, a runtime or an API SDK (usage.IsLibrary: curl, Bun, python-httpx, Go-http-client, OpenAI/Python), or nothing (other), is no agent and goes on one card, scripts, named Scripts with its libraries listed, read from each route's kept agent so older history folds too, while the Usage page's Agents list keeps each by its own name (theforeveriris on X, context_scripts_test.go, context-scripts.test.cjs); clicking a part, a cell or an item opens its text from /api/context/text, the last 10 requests' masked bodies in memory, else the request archive's copy masked the same way, with a 404 saying why there is none (archive: off, missing, cut, unread; context_archive.go), and its Reply the reply from /api/context/reply (openCtxText, in ctxtext.js, context-text.test.cjs), rendered 100 items and 20000 characters at a time; a session's details on the Sessions page and Usage's Sessions list draw a Context line of its requests from /api/context/session, which reads only the days from its first to its last (30 at most) and keeps that one session, so the tab's 80-session cap never leaves it out (sessCtxLine in plugins/usage/page.js, liang_yongxiang on Discord, context_session_test.go, sessions-context-line.test.cjs); its "Tuned for you" cards are fed by /api/tune in tune.go, see agent wiring). Strings go through t() with translations in i18n.js, and a plugin's own in its i18n.js (zh, zh-TW, ja and de; the English text is the key and the fallback). zh-TW is Traditional Chinese with Taiwan's words; a system language of zh-TW, zh-HK, zh-MO or any zh-Hant picks it, and the tray menu and notifications follow (trayLang). Dropdowns use openProtoMenu. Every app menu (openProtoMenu, openRowMenu, openSessCombo) is placed by placeMenu: under its anchor, or over it when the window runs out below; one that fits neither way takes the larger room, its height held to it, and scrolls inside itself, and a scroll inside a menu doesn't close it (#1437, removed-groups-menu-scroll.test.cjs). The highest any popover goes is popTop: 8px under header.top on a Mac window, where the traffic lights are drawn over the page, and 8px from the top elsewhere; placeMenu, the field picker's placePop (which also holds #pop's height to that room) and an agent's model list (openAgentModels) all use it (#1573, popover-mac-chrome.test.cjs). Scrolling is done only by scrollOnPurpose(e) with the reader's event. |
assets/app.js, assets/i18n.js |
| Window navigation | In the window from 1024 points wide (SIDE_AT, the same width as app.css's side-nav rules), layoutNav moves the brand, the pages (#nav) and Settings into the sidebar (#side): the pages in four groups (Work, Models, Insights, Extend; a group none of whose pages shows, as in gateway mode, leaves out its name), the gateway's address at its foot (sideGwRead, read from /api/providers only while there is a sidebar, or drawn at once from boot.js's sideGateway; on a page other machines open, magpie web, it is MAGPIE_PUBLIC_URL while they are let in, as the Gateway page's address and About's Gateway URL are, noahhrreion on Discord; a port applied in Settings redraws it), and the header a breadcrumb (renderCrumb). A page whose head holds only its tools (Library, Plugins, Settings) has them in the title bar after the breadcrumb, tools setting the room between it and the window's own buttons. When they don't fit there the tools show their icons alone (tools-tight; each keeps its name as aria-label and in its tooltip), then the breadcrumb drops its leading parts, and last the page's name is cut at its end, so no tool lies over the title (#2625, title-bar-tools.test.cjs). The open page's own tabs (NAV_SUBS: Usage, Library, Plugins, Settings) are listed under it as .nav-s rows (role="tab", data-of the page tab's id) and the page's strip is hidden; Settings' are listed above its button at the foot, which is laid from its end (.side-foot's column-reverse, its rows kept whole and scrolled from the end when the window is too short), so the list grows up from the button and the button and the gateway's line stay where they were clicked (jen_celeus on X, sidebar-settings-steady.test.cjs); a row's click clicks that tab at once, the selection (.nav-hl) having set off as the row was pressed (navSubGlide; back if the press leaves the row), and is the list's only shape: a row hovered or pressed has no ground of its own, and a MutationObserver draws the list again when the strip changes. A page's tabs share its one scroll, so a row that picks another tab opens it at its top (scrollOnPurpose with the row's click); the tab already open, picked again, leaves the page where it is (sidebar-tab-top.test.cjs). The list opens and folds with an iOS-like spring (navSubEnter, navSubLeave; none under reduced motion), and a folding list is out of reach at once. The open page's row folds its list and unfolds it, as a Mac sidebar's disclosure (hkwok06 on X: Settings' list unrolled and only another page, the gateway, put it away): the row carries a muted chevron (.nav-fold, aria-expanded), turned down to the list while it shows (up for Settings', which opens above its button) and to the side while folded, and the row clicked again, or Enter on it, folds or unfolds the list and leaves the page and its tab as they were (navFold and navFoldRows in navicons.js, imported with the first list; navSubs asks navList("Folded")). A folded list stays folded, per page, in localStorage magpie.navFolded, until its row opens it again. See nav-sub-fold.test.cjs. The open page's own row is marked the same way, by one shape (.nav-top-hl, the rows' own ground given up to it, hovered or pressed too) that navTopGo moves to the row picked on a damped spring, as iOS moves a selection (NAV_SPRING, SwiftUI's response 0.42s and damping 0.84; navTopStep steps it each frame): it sets off as the row is pressed and comes back if the press leaves the row or the page isn't left, turns with the speed it has when the press changes its mind, and follows its row while the list above it folds, landing where the row ends up. It is put in place, not sent, when the window opens on a page or the rows move under it at rest (a ResizeObserver), is away while Settings is open (it has its own selection at the foot), comes back fading in on its row, jumps under reduced motion, and isn't drawn in the header's tabs, which have their .thumb. #nav is position: relative in the sidebar for it, so .seg's centring left and top are reset. See sidebar-glide.test.cjs. Narrower, the page beside a sidebar would be narrower than Usage's requests table needs (768 points), so they go back into the header's row, as a Mac sidebar gives way in a narrow window. At every width the reader can pick the sidebar or the header's tabs from the title bar's button (#sideToggle, ⌃⌘S or Ctrl+Shift+S; toggleSideNav), kept in localStorage magpie.navLayout (side or top) and so laid out from the first frame; none picked, the sidebar comes from SIDE_AT. Picked in a narrow window the sidebar is narrower (184 points under 860), and magpie web on a phone keeps its own tab bar and has no button. That tab bar (phoneWeb, app.css body.web .top #nav) lies at the window's foot, as an iPhone app's, over the home indicator's inset (--tabbar), with each page's icon over its name. It holds five tabs: with more pages shown than that, the first four and More, whose app menu lists the rest with their icons and ticks the open one, and More is marked while one of them is open and carries a page's dot (phonetabs.js, imported by layoutNav the first time the page is a phone's; a MutationObserver fits it again when a page is shown, left out or opened). Before it the tabs were a strip that scrolled sideways with nothing saying it did, and Agents and the Library lay past its edge (geraldpppppp on X). Status messages sit above the bar. See phone-tabs.test.cjs. The two layouts trade places in a view transition (navMorph, app.css .nav-morph): the sidebar slides, each page's tab flies to its place in the other, and the page slides as one (its old image dropped, so no line prints twice); without view transitions, under reduced motion, or in the Linux app the change is at once: WebKitGTK with compositing off (WEBKIT_DISABLE_COMPOSITING_MODE, which webkit_linux.go sets under Wayland) crashes in a view transition. Elsewhere a transition still going after MORPH_MAX (1.5s) is skipped, so a webview that never ends one can't leave the window on the old layout's picture. See side-toggle.test.cjs. A window made wider or narrower drops what a click held (heldWidth): the page laid out again isn't the click's doing. The reader's own place is kept instead for a second while the page is laid out again (relaid, a ResizeObserver on the open page's parts calling backToReader): crossing SIDE_AT the browser clamps the scroll to each layout it passes through, and the page ended short of its foot (#1672, text-size.test.cjs). See sidebar.test.cjs. A sidebar longer than a short window keeps no scroll bar beside its pages: the native bars of .side-scroll and .side-foot are hidden, and sideBars lays a thin bar over each box's edge that shows while it scrolls, fades about a second after it stops (kept while hovered or dragged), can be dragged or clicked to page, and is gone when the box fits, the same in WebKit, WebView2 and WebKitGTK. See sidebar-overlay-scrollbar.test.cjs. The window opens on the page the reader last left, as a Mac app comes back as it was (molvqingtai and lc on Discord): show keeps the page in localStorage magpie.lastView (which the app's webview keeps across restarts, as it keeps magpie.navLayout), and keptView opens it at start. A page asked for in the address (?view=, the tray's links, a reload) wins, Agents too; a kept name that is no page opens the first page, and one gateway mode leaves out opens Providers (show). Settings › General › Sidebar pages (navpages.js, loaded when Settings draws; youimark on X) leaves pages out of the sidebar for this browser alone: localStorage magpie.navHidden, read by navMine (through navList, which reads magpie.navFolded too), which navHides and offView ask beside gateway mode and the built-in plugins, so a hidden page's link or kept place opens Providers (Agents hidden: start.js), and Providers cannot be hidden (nav-pages-hidden.test.cjs). The same menu puts the built-in pages in the reader's order (chet030714 on X): a row dragged by its grip (with a mouse, a finger or a pen: dragRows through dragListen, which cancels only on the row's own lostpointercapture, since a finger's implicit capture on the grip is lost to the row and bubbles up; 40 points wide where the pointer is coarse), or moved with Alt+↑/↓, is kept in localStorage magpie.navOrder; navArrange in navorder.js (which navHides imports only once an order is kept, and navpages.js with the menu) moves the #nav buttons into it, so the sidebar, the header's tabs and a phone's tab bar (phonetabs.js: the first four, the rest under More) all follow, and while the order isn't the home one the groups' names are taken out of #nav. navOrder puts a page the kept order doesn't name (new in an update) after the page it follows at home; Default order removes the key. Plugin pages keep their own order in their group (nav-pages-order.test.cjs). Opening on it scrolls nothing. See last-page.test.cjs. |
assets/app.js, assets/app.css |
| Settings › Privacy | The page opens on what masking kept from vendors (drawMaskObs in app.js, fed by /api/masking/summary): the values masked over 7 or 30 days with a chart of the days, the kinds, what only the local model found, agents to providers, and the values masked most, each shown only while pointed at (maskTip, /api/masking/value, which says it is gone after a restart). Its records (drawMaskRecs, /api/masking/records and /api/masking/record) take the page's place, filtered by kind, finder, agent or provider, a day at a time, each opening on the text the vendor saw with its placeholders marked. maskedBadge, on the Gateway page's recent calls and the Routing page's log, opens a request's own record (openMaskRecord), in amber with the count sent as written when every value found was on Warn. Below the card, What to mask, How it's found (the rules, always on while anything is masked, and the local model on top of them), When a value is found (Mask, Warn or Block per kind, the secret kinds first and the personal ones behind Show all kinds, and the Never mask list; renderMaskActions, with Never mask and Masked words drawn a value a row by wordList in plugins/redact/settings.js, saved as the same list of strings the one comma-separated box saved, redact-words-list.test.cjs), Try it (renderMaskTry, the text as the vendor would get it from /api/masking/preview, kept in no storage) and Sharing. Agents' session history (renderSessionReads, read from /api/sessions/reads only while the Privacy part is shown) has Agents found later and a row per agent found, the choice the Sessions page asks first on a fresh install; see gateway sessions. While anything is masked, Instead of masking, send to (redactRouteRow in plugins/redact/settings.js, the redact plugin's part of Settings, which wraps renderRedact so app.js carries none of it) picks, in the app menu, a model a request masking would change goes to as written: Off by default, and only the models /api/settings lists as maskRouteModels (every route of theirs unmasked, gateway.MaskRoute), saved with POST /api/settings/redact-route (redact-route.test.cjs). See gateway routing for what is recorded. |
assets/app.js, masking.go |
| Built-in plugins | Plugins › Built-in, the page's first tab (drawBuiltin in plugins.js, rows by renderBuiltins in app.js), lists magpie's built-in plugins, each with a name, a line on what it is and a switch: Routing groups, Library, Observability, Sessions, Warm-up and check-in, and the Gateway and Routing pages (Essential). A plugin on with settings has their rows under its row, drawn from its schema by the kernel's ui.form, and a change posts {id, config}. The Gateway page is drawn by its plugin's own scripts through the window's kernel (kernel.js, assets/plugins/gateway/); see the plugin runtime, "The window's kernel". They are plugins/* registered with the plugin runtime; GET /api/plugins/builtin says each one (builtinJSON: on is active, the user's own choice, what of it is in use) and POST {id, on} (or {id, config}) writes plugins.yml. A page marks what goes with a plugin data-feature="<id>". Off, featureStyle hides everything so marked (rows drawn later too), navHides leaves its page's tab out of the sidebar and the header, show opens Agents for an address kept for it, and setSetTab, partShows and findSettings leave its Settings tab and rows out, of the search too. Settings' search lists the built-ins themselves after its own rows, off or on, by name, line or a setting in their schema (Gateway's Recent calls at a time is on its own page), and Open lights the row in Plugins › Built-in (setFeatsFind in the lazy setfeats.js, settings-search.test.cjs). Its provider links are drawn the first time a search wants them (provlinks.js). One in use stays on: its switch is disabled and the row says what uses it, and the POST refuses it off. A plugins.yml that doesn't parse is said above the list and no switch moves. boot.js says which are off (featuresOff) and their settings (pluginConfig) before the first paint, and settings.builtins carries the list on every state read. The TUI doesn't follow them. See builtins.test.cjs, builtins_test.go. |
builtins.go, assets/plugins.js, assets/app.js |
| The app's log | runGUI and runPanel (so magpie, app, tray, panel, a window view and a magpie: link) call startLog before gui.Run: applog.Start sends the standard logger, which the gateway, the plugin host and Wails' error handler write to, to app.log in appdir.Logs as well as stderr (quiet, which never fails, first, since io.MultiWriter stops at a failed writer and an app opened from Explorer has no stderr), and points debug.SetCrashOutput at it, so a panic is in it. Opened from the Finder, the Dock or the Start menu the app has no terminal, and wrote its log nowhere (rayem1w on X, 0.1.2330). The folder is ~/Library/Logs/magpie on macOS (beside the launch agent's serve.log, which launchd writes for magpie serve: the two processes never share a file), %LOCALAPPDATA%\magpie\logs on Windows, $XDG_STATE_HOME/magpie (~/.local/state/magpie) elsewhere, and logs in a portable data folder. The file is 0600. At 5 MiB (Limit) it becomes app.old.log; when another magpie (an update's new process) rotated it already (os.SameFile of the open file and the path differs), it is only opened again, and when it can't be moved it is emptied. Each line goes through scrub, which masks bearer and basic credentials, key and token query parameters, and sk-, AIza, gh?_ and JWT shapes, though nothing logged is meant to carry one. Settings › About's Log row (#logRow, settingsJSON.Log from applog.Current, so magpie web, which writes no file, shows none) has its path and an Open (POST /api/settings/log/reveal) that shows its folder; magpie log prints where every log is, -n the last lines, -f follows across a rotation (TestTheAppWritesItsLog, TestLogFollows). |
internal/applog/applog.go, gui_on.go, log_cli.go |
| No GUI build | -tags nogui builds magpie without the GUI: hasGUI is false and runGUI says to use magpie tui. The files of internal/gui that need Wails build under !nogui. |
gui_off.go |
| The terminal quitting | magpie tui that served the gateway with an agent connected hands the gateway on as it quits, on Linux where nothing opens magpie at login (a WSL distro, a server over SSH; zaidu259434 on X): keepGateway starts magpie's service when it is installed, installs it (daemon.Install) when the user never removed it (daemon.Removed, a mark magpie daemon uninstall leaves), and otherwise starts magpie serve in its own session (serveInBackground, log in magpie's cache). Elsewhere, or with nothing connected, it only says the gateway stopped. Where magpie opens at login (autostart.Enabled, which on Linux counts a package's own autostart entry, also on a box no desktop logs into) it leaves the gateway to the app, and the note says magpie autostart off has the terminal hand it on where no desktop logs in (atLoginNote, #3756). |
keep.go |
| The app quitting | A Quit the user chooses (the tray's Quit, the panel's and window's Quit, Command-Q on the Mac) while agents are connected to the gateway this process serves asks first (see A Quit asks while agents go through magpie). Closing the window only hides it: magpie stays in the menu bar or the system tray and the gateway keeps serving, on Windows too. | quitask.go, quitask_app.go, quitask.js |
Runtime path
magpiewith no arguments,magpie appormagpie traycallsrunGUI, which starts the app's log (startLog, above) and callsgui.Run. Anoguibuild runs the TUI instead. A second launch hands over to the instance already running. On Windows, before any window is made,webView2Checkasks Wails whether the WebView2 runtime is there (Env.Info().PlatformInfo["WebView2"], "" when its lookup fails; a key Wails doesn't set counts as there). Without it Wails would exit on the first window with nothing on screen, so magpie logs it, shows a Windows message box in the reader's language naming the runtime, Microsoft's download page (webView2Page) andmagpie web/magpie tui, opens the page on Yes, andRunends (#1806,webview2.go,TestWebView2MissingFromWailson Windows). The box can't come fromErrorHandler, which runs on the thread Wails makes its windows on.startBackendbrings up the gateway, or finds another magpie serving it.- The panel and the window load
index.htmlfromHandler.boot.jspasses the saved language, theme, colorblind mode, text size and desktop font choices before the first paint. It also puts in the look of the reader's own (appearance.go, CHENGJIAHEGOXIS on X): Settings › General's Accent color (accent,#rrggbb;accentVarsdarkens it on the light theme and lightens it on the dark one until it reads as text at 4.5:1; it also sets--mark, the ink of what is chosen: the open page's sidebar icon, a switch's or tab's chosen option, Library's switches and radios.--markisvar(--fg), graphite, until the user picks an accent, so a picked colour shows on the page it is picked on. A picked colour also tints the theme's grounds, the window's and the tray panel's (--bg,--card, the pills, lines and the dark menus'--pop-bg;tintVars): each takes 5% (light) or 8% (dark) of the colour's hue, its own lightness kept, so a grey pick changes nothing and text keeps its contrast. A dark pick, one whose OKLab lightness is under 0.4 (Graphite and every preset are lighter), takes the dark grounds as far toward black as it is dark (ground,darkness), losing app.css's cool grey cast and taking more of the pick's hue as they go: black draws a #000000 page with its cards, pills, lines and menus the same neutral steps above it, and a deep navy a near-black navy page (TestDarkPickDarkensPage). Black's ink starts most of the way to white (lifted, bydepth), so it is not Graphite's grey; on the light theme black is black ink, and white the light theme's dark ink (TestBlackIsBlack); with no accent, or under Omarchy, they are app.css's own.TestTintBasesAreAppCSSholds the Go bases to app.css, andTestLookFixturethe GUI tests'fixtures/look-accents.jsontolookCSS) and Background image (a PNG, JPEG, GIF or WebP of 16 MB at most, saved aswallpaperin magpie's folder byPOST /api/appearance/wallpaperas base64 JSON,{remove: true}to take it away;settings.Wallpaperis its stamp), drawn behind the window's pages under a veil of the theme's background, never in the tray panel or under Omarchy.bootPrefs.looksays which look was drawn;applyPrefsasks/api/appearance/cssagain only when the settings' look differs, and the rows are drawn by the lazyappearance.js(appearance-look.test.cjs,appearance_test.go). - The page reads
GET /api/stateand writes throughPOSTroutes. Each write answers with the new state, built underheld. - Closing the window hides it. On the Mac a full-screen window first leaves full screen (
closeStep). The system's close on the panel (a title bar's X, Alt+F4, a window manager's close key) hides it as Escape does, so the tray icon opens it again; a panel lightweight mode let go, no longerh.panel, closes (makePanel,TestPanelCloseHidesIt). A hidden macOS window keeps its WKWebView's page marked visible, sohideWebviewtells the page it is out of sight beforeorderOut; that makesdocument.hiddenandvisibilityStatetrue, stops the page's polling and frame loops, and pauses CSS animations.showWebviewtells it it is visible again (#4293). Lightweight mode lets go only of a window closed this way: one covered by another app's window, minimised, or open as magpie was hidden is still open (windowUp, not Wails'IsVisible, which is the occlusion state), and so is it for the Dock while the window is open and for a restart (#1381,TestCoveredWindowStaysUp). On the Mac the tray icon and a usage cell close an open panel by the same test (windowOpenintogglePanelNowandtrayCellClick, not Wails'ToggleWindow), so under a window over the whole screen, such as a remote-desktop server's privacy curtain, the icon still closes the panel instead of showing it again (#1661,TestTrayCellClickReleasedPanel). On Windows a hidden window's WebView2 is put on its low memory target (lowWhileHidden,memtarget_windows.go:ICoreWebView2_19::put_MemoryUsageTargetLevel, on each hide, on a page that comes while hidden, and back to normal on each show), so the panel and the window kept loaded in the tray stop holding what they last drew; the page stays loaded and running, unlike lightweight mode. In the tray the WebView2 processes' private working set went from ~170 MB to 20 to 40 MB, while their commit charge stayed where it was (molamaker11 on X). WKWebView and WebKitGTK have nothing magpie can set for it. - The window opens as it was last left. Its settled size and whether it was maximised are kept in
settings.Windowandsettings.WindowMaximised(settle; per machine, seeKeepOwn). A maximised window keeps the size it restores to.makeMainopens it at that size (openSize). On its first show,placeMainmaximises it again on the Mac and Windows (on Windows once the page has come). On Linux,makeMainmakes it maximised withStartState. On Windows a size larger than the screen's work area is fitted and centred (fitRoom), and the larger size stays kept. Where it was left is kept too, insettings.WindowAt(its top left corner across every screen, in the system's coordinates), so after a restart or an update it opens there rather than in the middle (jorbenzhu on Discord).keepAtsaves it once a move or resize has rested for half a second, unless the window is maximised, full screen, minimised or hidden;settings.Savewrites through temp and rename, and a settings file that can't be read is left alone. On its first showplaceMainputs it back (putBack):openAttakes the screen holding most of the window, moves the window fully onto that screen's work area, and leaves it centred when no screen holds any of it, such as a monitor that is gone, or when the screens or the file can't be read (TestOpenAt). Under Wayland a window can't place itself, so nothing is kept or put back there unless GDK_BACKEND is x11 (keepsPlace,TestKeepsPlace). The pin in the window's title bar, between Refresh and Settings (#pin,renderOnTop; NovaStudiosss on X, to watch Usage and Routing while working in another app), keeps the window above other apps' windows:POST /api/window/ontop?on=1(or0) savessettings.OnTop(SetOnTop, this computer's own, kept through a Settings save) and callsSetAlwaysOnTop, andmakeMainopens the window pinned when it is set. boot.js says whether there is a pin (pin,pinnableinontop.go) and whether it is pressed (onTop) before the first paint. There is none in the panel, in a browser page ormagpie web, or under Wayland (the samekeepsPlace: GTK's keep-above does nothing there), and the route refuses there with 400 and saves nothing (TestPinKeepsWindowOnTop,TestPinRefusedWithoutAWindowToPin,window-pin.test.cjs). The tray's panel isn't kept: on the Mac and Windows it opens under the tray icon, and on Linux where the click was. - The page's header is the window's title bar.
plainTitlebarsets it up once the app has started, and again on a window lightweight mode made again (madeAgain). On Linux it hides GTK's title bar and keeps the shadow and the resize edges; GTK 3 leaves the corners square. On the Mac the traffic lights are inset into the header (MacTitleBarHiddenInset). In the design of macOS 26 a window with a toolbar has larger corners than one with a plain title bar, soinsetLights(titlebar_darwin.go) takes the toolbar off, andMagpieLightskeeps the lights and the title bar's height where the toolbar had them: after a resize, a new title, light or dark, more contrast or less transparency, and leaving full screen. A sheet, such as the folder chooser, still begins below the title bar. A first press while another app is in front still moves the window from anywhere in that title bar (firstPress), as AppKit moved it with the toolbar; AppKit itself now does so only in a plain title bar's top 32pt. 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 ask for the earlier design (UIDesignRequiresCompatibility);designOf26reads each at run time, as the SDK depends on the toolchain that built magpie. The toolbar stays where it doesn't change the corners: in the earlier design, and on macOS 27, which gives a window with a toolbar a plain title bar's 16pt corners (toolbarRounderholds the window's radius against a window of its style with no toolbar, never shown); with the lights on the right (a right-to-left language), or when the title bar isn't laid out as expected; this is decided once, when the window is set up. In full screen the title bar is AppKit's own. On Windows the main window is frameless (mainFramelessinmainwindow.go), so a wallpaper or the page's colour runs to its top instead of stopping under a separate strip (258a14 on X). Wails keeps the frame's styles, so it still has its shadow and Windows 11's rounded corners, and snaps with Win+arrows and by dragging to a screen's edge. Wails' frameless window has no frame left to resize from, only a band 4px wide inside the page, and the page's scrollbar covers it on the right (Puremilk_chun on X), so the main window keeps Windows' own resize border on its left, right and bottom, outside the page as on a framed window (mainFrameCalcinmainframe_windows.go, asked first byappWndProc;keepResizeFramenames the window once Wails' runtime is ready;TestMainWindowKeepsResizeBorder). Its top is still the page's, resized by Wails' band; maximised or in full screen Wails sizes it as before. The page draws the caption buttons at the header's right (#wincap, shown by app.css underhtml.winfromlayout.jsin the window and not on the web, run bywincap.js, which app.js imports in that window alone, Segoe Fluent Icons' glyphs, Close red on hover); they minimise, maximise or restore, and close (hide; the tray stays), and stay over a dialog's scrim (wincap.jsundoes theinertthatmodalBackgroundsets on them). The header's own tools sit left of them. A double click on anything that drags the window maximises or restores it. The app tells the page whether the window is maximised (captionJS, on Wails' runtime ready and on a resize that changes it), which swaps maximise for restore and keeps Wails' resize edges inside the page off while maximised, so the top-right pixel is Close's (TestCaptionKeepsEdgesOffWhileMaximised,win-caption.test.cjs). Windows 11's snap layouts flyout over maximise isn't shown: it needs Wails' composition hosting (--wails-non-client-region), which forwards input bySendMouseInputonly. The panel keeps its own window as before. - On the Mac, Settings › Show in Dock puts magpie in the Dock never (
DockNever), while the window is open (the default;DockWindowrecords it chosen, for an older magpie that took none for never) or always (Dock, which wins). The default was never until ShouguangCao on X found the open window out of Command-Tab, so going back to it to paste a key copied elsewhere took the menu bar; a new install (no settings.json) reads With window, and Hide is a choice of its own (inDock,dockChoicein app.js,TestDockFollowsWindowByDefault,dock-choice.test.cjs). A file written before that has nodockSettled, and stored Hide as nothing, so a user who chose Hide can't be told from one who never chose: such a file with no Dock choice reads as Hide, and the first save writes it so withdockSettled(settleDock,TestOlderSettingsKeepHide,TestNewInstallFollowsWindow). A file nobody can read reads the same way. The page never sendsdockSettled; the save keeps the file's (TestSettingsSaveKeepsDockReading). It is this computer's own, as the Dock choice is (KeepOwn). A full-screen window joins it whatever the setting (inDock,dockOnFullscreen).openMainjoins before it shows the window (setDockruns on the main thread at once). An app activated out of the Dock (the quick panel's focus) that then joins it stays last in Command-Tab's order though it is in front, so joining to the front activates magpie by way of the Dock (dockStep,activateAgain; #1381,TestDockStep,TestDockJoinLeadsCommandTab). It does so without asking NSApp whether magpie is active: the Mac makes it the front app at once, and NSApp says so only once the main thread has taken that in, after the join on a busy Mac (#1651). - Settings › General › Quick panel shortcut binds a key combination that opens the tray's panel from any app (ben hanks on Discord); none is set by default. The page records the keys and posts them to
POST /api/settings/panel-shortcut, which checks them (panelShortcut: a letter, digit, Space or F1–F20 with Ctrl, Alt/Option or Cmd/Super, or an F key alone, written as Wails' accelerator), has the running app bind them (onPanelShortcut,bindPanelKeythrough Wails'GlobalShortcut: Carbon's hot keys on the Mac,RegisterHotKeyon Windows,XGrabKeyon X11) and saves them only once bound. One the system refuses (on Windows and X11, another app holding it) is not saved and the old one stays bound; one saved but refused as magpie starts is retried after a handed-over magpie exits and else said in the row (panelKeysJSON.Taken). A pressed shortcut toggles the panel as a tray click does (togglePanel). The Mac's Carbon hot keys don't refuse a combination another app registered too, so there both are taken and magpie can't tell the user. The shortcut is per computer (KeepOwn), and the Mac's old process lets go of it as it hands over (leaveMenuBar). On Wayland no app may grab keys itself, so the field is off and the row says the command to bind in the desktop's own keyboard settings (magpie panel); Wails' GlobalShortcuts portal is not used, since the compositor decides its keys and Hyprland binds none unless configured. From there a not-connected Claude Code's or Codex's opened row switches its account (shuizhuyu on X, Switch accounts only). - A click on the tray icon opens the quick panel, or the main window when Settings › General › Click the tray icon to says so. The panel opens the main window from one control, on its edge nearest the tray (isaac_bai on Discord): hung below its icon (the Mac's menu bar, a taskbar or bar at the top) it is the header's icon (
#open, named "Open the main window"); standing above it (Windows' taskbar at the bottom, a bottom panel on Linux) it is the foot's "Open the main window" left of Quit (#openMain), and the header has no icon. The two are never shown together (yogurt36 on Discord). OncetogglePanelNowhas placed and shown the panel,tellPanelSidereads the panel's bounds and its screen's and sendsmagpiePanelOpenAt("foot")when the panel is nearer the screen's bottom,"head"otherwise (panelOpenAt; the Mac is alwayshead). Under Wayland a window can't read where the compositor put it, and until the app says, layout.js setsbody[data-open-at]by the system:footon Windows,headelsewhere (panelside.go,TestPanelOpensTheWindowFromTheEdgeNearestTheTray,panel-open-once.test.cjs). On Windows a double-click on the icon opens the main window too (isaac_bai on Discord): Wails passes the icon'sWM_LBUTTONDBLCLKon asOnDoubleClick, the panel its first click opened is hidden byopenMain, and theWM_LBUTTONUPthat ends the double-click is swallowed once (trayDouble, withintrayDoubleRelease) so it does not open the panel over the window. The Mac's status item calls its action on each mouse-down with no click count, and Linux's StatusNotifierItem has onlyActivate, so there a double-click is two clicks and is left as such (trayDoubleClicks,TestTrayDoubleClickOpensTheWindowOnWindowsOnly,TestTrayDoubleClickReleaseSwallowedOnce;traydouble.go).
Constraints and failure behavior
First opening of an agent's Details
In the main window, expandLink in
app.js reads an agent's own settings
and loads its Long conversations controls before drawing and measuring its
opened row. While these are loading, Details shows Loading and is disabled.
A failed read keeps the row closed, reports the error and allows retry.
A later agent click or leaving Agents supersedes the pending opening.
Once prepared, the row slides to its full height; reduced motion opens it
at once. Later openings reuse the settings and controls already loaded.
agent-details-ready.test.cjs holds both responses and checks the final
animation frame against the natural height in both engines and five languages.
Allowance card refreshes
A card refresh applies only the requested account from the API's full
card list. A whole-page read begun before that refresh completed keeps
the newer card when its older response arrives; other cards still update,
and a later whole-page read can replace or remove the card. This also
keeps two different card refreshes from undoing each other's results.
If a refresh first supplies the account's name, its provider's cards are
replaced while newer card refreshes and other providers stay. The replaced
keys are protected too: an older whole-page response cannot restore an
unnamed card or erase its newly named replacement. Only a completed
whole-page read retires the ordering markers it no longer needs.
A remote magpie's summary can likewise become its namespaced child cards;
refreshing it preserves local providers and other remote magpies.
keepRefreshedQuotas and quotaRefresh in
app.js own this publication order;
quota-refresh-order.test.cjs covers held responses and failures, and
usage-card-refresh.test.cjs checks the real button in both browser
engines and all five languages. A cached readDeferred card says no
refresh was requested this time; a failed read retains its failure notice.
The tray panel's Allowances cards use the same quotaRefresh, at the
start of the line under the account (the reset deadline, the error, or a
balance's name), opened as the card is hovered or the button is focused.
That line names the deadline ("Resets 14:26"), so no bare ↻ stands for
it; renderPanelQuota puts the focus back on the button after the redraw.
panel-quota-refresh.test.cjs covers it in both engines, all five
languages, at 440 and 360px.
Redrawing the cards preserves their refresh controls and any running turn.
A read of every card (loadQuotas) draws the cards again in one go, as
their reset countdowns need, but keeps each card's logo node
(keepIcons in renderQuotas): a logo made afresh blinks out while its
picture loads. While such a read is on its way for longer than 200 ms,
#subscriptionUsage is .reading and each card's refresh turns
(quotaReading in plugins/usage/page.js). The Overview's skeleton
(renderUsageLoading) is put up only for a first read or another period
or zone (usageFor); its tab pressed again while it shows that read reads
quietly (refreshUsage), so no card leaves and the scroll stays put, and
the refresh beside the period turns while it reads. Its lists keep their
logos too. See usage-quiet-refresh.test.cjs (jiabubu on Discord).
The reply updates the reading immediately; the icon then finishes its
current full turn before stopping (no rotation under reduced motion).
A manual refresh whose HTTP reply succeeds but whose requested card has
an error reports that error through the status line too (#4817), including
when the card already showed it. Errors on other cards in the reply do
not become the requested account's error. An unnamed provider or remote
summary that gains named cards reports only failures accepted from that
reply; an older error replaced by a newer reading is not reported again.
Claude Code's first-run screens are gone through by the helper itself
(claude-subscription-bridge.md); one it can't get past ends the read, and
that is said on the editor row, Usage card, tray card and refresh notice:
finish Claude Code's first-run setup, then refresh; magpie claude-code
names the executable, including a build magpie downloaded. The original
error stays in the card's tooltip, and the read never falls back to -p.
claude-quota-onboarding.test.cjs presses the active account's button in
both engines and all five languages, with an account error in a successful
HTTP reply, then a successful read after setup and an unrelated card error.
Streamed output speed
Usage rows and aggregates use Record.Decode and DecodeOf in
internal/usage/usage.go. Routing uses
decodeOf in plugins/routing/client.js; Usage
rows use ledDecode in plugins/usage/page.js.
When an answer follows reasoning, only answer tokens are timed from the
first answer text. Without answer text, all output tokens are timed only
when the gateway records paced visible reasoning and a usable content flow.
firstToken.reasoningMs in
ttft.go requires reasoning at the first
content and subsequent reasoning deltas at least 100 ms later. It excludes
native Responses and Gemini, whose summaries do not measure their reported
reasoning tokens, and redacted thinking, including translated sealed blocks.
The upstream protocol is retained when the client receives a translation.
These are receive-side timing checks, not access to the vendor's generation
clock: a relay that releases a buffered reply evenly can still look paced.
Without an upstream guarantee, this is an observed output-rate estimate.
Summaries stay excluded rather than extending their visible portion's time
to an unobserved reasoning-token count.
Record.FirstReasoning (first_reasoning_ms) and the corresponding
Call, Route and Try field (firstReasoning) record this evidence with
the same origin as their duration. Historical records have no evidence and
keep their previous speed. Request-page caches and compressed snapshots
preserve the optional field; the packed row keeps ReasoningHidden in
its own Flags bit (rowReasoningHidden), apart from pricing's
swapKnown, which every priced row carries. ReasoningHidden (reasoning_hidden in the
ledger, reasoningHidden in traces) suppresses a no-text speed even when
redacted/encrypted thinking has no reported reasoning-token count. A
Responses summary is marked this way on its own-login path too, and after
an endpoint fallback, where the try's protocol still names the first
endpoint, by the upstream that answered (summaryUpstream in
continuation.go). Optional
OTel attributes carry the evidence without response text. The existing burst and held-content limits in
DecodeOf still apply, and hidden reasoning does not enter average speed.
A streamed request's duration (Millis, which ends every speed window)
ends when its last try's reply ended, not when serve returns: what the
gateway writes down after an answer (answered's sticks, the provider's
last answer in NoteServed) goes to disk, and on a busy disk took
seconds, which made a paced reply read as held back and tell no speed
(#1939, TestSpeedEndsWithTheReply). A decision group's row is timed the
same way.
TestVisibleReasoningSpeed, TestReasoningSpeedEvidence,
TestReasoningSpeedThroughGateway, TestMixedRedactedReasoning,
TestHiddenReasoningThroughTranslation, TestSlowReleasedReasoningIsUntimed,
TestPricedRowKeepsReasoningEvidence, TestSummaryAfterEndpointFallbackStaysHidden and
reasoning-speed.test.cjs
cover the calculation, cache round trip, translated streams and both pages.
Routing purpose filter
The request heading's purpose menu in plugins/routing/client.js
uses openProtoMenu's live checkbox selection: each tick immediately shows
requests matching any selected purpose, with the menu kept open. An empty
selection, All purposes or Clear filter restores every purpose without
changing the day or request/session view. A live menu stays open when its
redraw clamps the list's scroll; the reader scrolling outside still dismisses it.
Choosing All purposes closes the menu and returns keyboard focus to the
purpose button without scrolling; unticking the last checkbox keeps the
menu open and focused on that checkbox.
A Claude Code subagent's turn has the Subagent tag (tagKind,
Route.SubagentID) and no kind, so it stays under Unmarked, as on the
Usage page. Counts, the current story and replay
follow the same filtered list. Selected purposes remain available when a day
has no matching requests. Opening a request from another page clears the
filter only when that request is excluded. Usage's purpose picker remains a
single choice sent to the ledger API. See purpose-filter.test.cjs and
routing-purpose-state.test.cjs.
Routing group lookup caches
The routing script's groupIndexOf in
plugins/routing/client.js
lazily indexes the current /api/groups response by model, group and account
ID and caches parsed member IDs. Exact model IDs take precedence over
reasoning suffixes; duplicate IDs retain the first match, as array lookup did.
A new response replaces the indexes on the next lookup. The maps reference
response objects, not copies. They serve both Routing and Routing groups,
and are released after both pages have been out of sight for five minutes
(including a hidden browser tab); returning cancels expiry. A later lookup
rebuilds them from current data. This changes no saved configuration or
routing behavior. group-index.test.cjs checks lookup work, member semantics,
data replacement and expiry with a controlled clock.
hayMatches caches each group's lower-case search text in that same cache.
Queries retain AND and substring matching over group names, IDs, refs,
patterns and member labels (including accounts, reasoning and fast/free).
Changing the language discards the text cache; a new groups response also
invalidates it, including model/provider/account renames and membership
changes. Default routing settings and quota readings do not affect search
text. group-search-cache.test.cjs verifies reuse and invalidation.
The group's input event and Escape use drawGroups' filter-only path:
matching cards are retained, unmatched cards detached and reused if the
query changes back. The toolbar, settings and provider pools are left in
place, and an open editor and import text keep their live DOM and draft.
Bulk selection still drops groups outside the query and rebuilds its
selection controls for the shown list. A data, language, settings or quota
redraw discards the row cache; filtering also falls back to a full redraw
when the data or language changed since the last one. A filter-only draw
does not mark new quota readings as painted: after the input loses focus,
the usual quota tick refreshes the cards. Detached cards are
released with the lookup cache after five minutes away. This is display
only; saving, ordering and routing semantics are unchanged.
The Hide plans button follows the filtered cards: it appears only when a
shown card has a quota line, and its folded choice survives filtering.
group-filter-render.test.cjs exercises node reuse, drafts and expiry with
4,000 models in both browser engines and all five languages; existing
filter-ime, group-pick-filter, group-bulk-remove, group-arrange,
group-import-replace and group-morph tests cover their neighboring flows.
Routing mode chip
The stage's chip and the Accounts and keys heading in
plugins/routing/client.js name how a route
routes only where that can be changed: a group, or a provider in
/api/groups' pools (two or more accounts or keys on). There they are
.rt-go controls (goTo, goRouting) that bring the group's card or the
provider's row under Several accounts or keys into view through
scrollOnPurpose, mark it (rt-found) and focus its routing. A provider
with one on names no routing, and the mode paragraph says how to get one
(LONE). The header is drawn again when the groups come in (headOf).
See routing-mode-goes.test.cjs.
Routing key and account folds
Three or more API keys, or three or more accounts, of one provider standing
next to each other for one model (same fixed effort, fallback and
group-in-group heading) fold into one stage row, li.rt-fold in
plugins/routing/client.js (FOLD_AT,
rebuild). It shows the count and their state together: the one that is
lit and what it is doing, how many are available and how many rest
(together). Requests that land on a folded seat fly to the fold
(shownRow). Clicking it (or Enter / Space) shows each in place, wired
from the fold. Accounts and keys folds a provider's keys, and its accounts,
into one .rt-keys row each with their summed tally.
A folded fold of accounts, live, also says what they have left together,
first in its line, with a bar under it like an account row's (foldQuota,
chen2652 on Discord): the Usage page's readings of its accounts (cardOf)
put together by quotaall.js's mergeQuotas, the same as the Usage page's
"All N accounts" strip, its tightest window that says a share as the figure
and the bar, then when that window first starts again, the soonest of the
accounts' ("renews in 2h", as an account's row says it; Sdsi134a on X),
every window and when the first of them resets on hover. Only
when every account in it was read, none is free, and all are on one plan;
otherwise, while the fold is open or a kept day is shown, and while the
groups page's Hide plans is on (plansHidden, magpie.routingGroupPlans),
it says nothing of it and each account's row has its own. See
routing-fold-accounts-together.test.cjs.
A group in the group's heading (li.rt-sub, subNode) folds the same way
(toggleSub): folded, it says how many it routes to and what they do
together, a request to any seat under it flies to the heading
(row.shut), and its wire is the last one drawn (wiresTo).
Keys start folded. Accounts and group-in-group headings start open when
they hold fewer than LONG (6), folded otherwise (Aiirobyte on Discord: a
group of many accounts took the page). What the reader opens is kept in
localStorage magpie.routingKeysOpen and what they fold in
magpie.routingFolded (keepOpen, isOpen), keyed provider/model for
keys and provider/model@ for accounts on the stage, provider/* and
provider/@ in the list, and group/<id> for a heading. Display only: the
gateway's order and choice of seat don't change. Two stay two rows. See
routing-keys-fold.test.cjs and routing-group-fold.test.cjs.
How far the stage opens is the reader's to pick (ipsikent on X: often only
which model a route uses matters). Expand, at the end of the stage's top
line (#rtDepth, DEPTHS, openTo), offers Automatic (as above), Models
(two or more accounts or keys of a provider fold, foldAt, and start
folded) and Accounts (every fold starts open). Both open every group in
the group. It is kept in localStorage magpie.routingDepth, and picking
one forgets what was opened or folded on the stage (the keys without a
trailing /@ or /*), so every row follows it at once; a row clicked
after it is kept as before. Accounts and keys isn't changed by it. See
routing-depth.test.cjs.
Routing account windows
A subscription account's row in Accounts and keys shows the one figure
routing went by, and each of its windows, with when each resets
("5 hours 40% used · resets in 2h"), on hover over that figure (the
.st's title), as the Usage page reads them (#1833). A row with no figure
of its own (a remote's, or an account not read yet) shows its windows as
its one line instead (.wins, cut to one line, all of it on hover).
cardOf in plugins/routing/client.js matches
the route's account to app.js's quotas: a card of this computer (no
from) whose kind is subscription or none (/api/usage/quotas sends
this computer's cards with no kind; only a remote's are told one, so asking
for subscription alone matched none in the app) whose provider is the account's agent (a plugin's
provider id) or its provider, and whose user is the account's, ignoring
case. winsOf names them with familyWindows, quotaText and
resetInText. Nothing new is read: opening Routing asks
/api/usage/quotas in the ordinary way (show, when the readings are
missing or over a minute old), never ?asked=1. A kept day's list shows
none, since those requests were weighed by readings long gone. See
routing-account-windows.test.cjs.
A Claude (or Codex) joined over the network, a Remote magpie provider's
row, shows the windows of the accounts signed in on that computer the same
way (remoteWinsOf in client.js): the Usage page's cards with from
whose provider id is the remote's, a slash and the card's. The computer
that holds the account tells its usage; this one reads nothing new. A
Claude model's row is told Claude's cards alone and a ChatGPT model's
Codex's; with more than one card the account's user leads each window. A
remote whose read failed, or whose card of the row's family failed there
(the remote read, its Claude's read didn't), shows "Allowance unavailable"
with the reason on hover, never a figure and never nothing; a remote that
holds this computer's key tells why the same way (errRemoteHeld). See routing-remote-windows.test.cjs.
The refresh beside the Accounts and keys heading (#rtReadAllowances,
#1834) reads them again by hand: loadQuotas(true), the asked read the
Usage page's Refresh now makes. It turns while the read is on its way,
and a click then asks nothing more. Nothing on the page reads again by
itself. It shows only live, with a subscription account listed. See
routing-read-allowances.test.cjs.
On the stage, an account's seat tells the same windows in its tooltip,
under its id (render, #1835). The row itself keeps one line: the
fullest window while idle, what it is doing while it answers. See
routing-seat-windows.test.cjs.
Routing account cards
Each row under Accounts and keys is one cell like the others: a dot, its
name, plan and Try now on one line, and under it what is left (or its
rest) in full (ferock4669 and iyou00 on Discord: many keys ran the list
on and on). The dot is green for the one in use (of a provider's rows not
resting, the one that answered last), amber resting, red for what the
reader has to do (.act: sign in again, a restriction or verification, a
key failing with no answer), grey otherwise. Red is only on .act rows:
a quota rest or old failures are muted (danzi002 on Discord, "显示的好
乱"). How it fares (tried, answered, failed, last answered) is a line of
its own only on a row with nothing else to say or one to act on; on the
others (.said) it is in the tooltip with the models it answered, under
its id. A folded row of keys or accounts names no models. Columns are
min(240px, 40vw) wide, so a name and its Try now share a line
(routing-acts-calm.test.cjs). They aren't CSS columns: packActs
places each provider's box (.rt-pgrp) with --px/--py under
.rt-acts.packed, in order down a column and on into the next, the
columns' ends as level as they go, and a .long box's rows run on into
the next column, its heading never last in one. CSS columns balanced
every row again on each layout, ~24ms a layout in WebKit with a hundred
rows, and dragging the window's edge stuttered (lexrus on X). It places
on the window's resize, before the frame is drawn, on a render, and a
frame after a box changes its height. Beside the requests (min1150,
not solo) the list is one scrolled column and nothing is placed. An
account's windows line up with the rows of its own provider (--wk,
--wv, --wr per provider), and no part runs past its row: a width the
whole list's widest window asked for ran the resets over the column
beside. See routing-account-windows-fit.test.cjs.
renderActs in
plugins/routing/client.js
shows the first ACTS_SHOWN (8) rows of a longer list and puts the rest
behind "Show N more" at its foot (.rt-acts-foot), kept across a reload
in localStorage magpie.routingActsAll. The button clicked stays where it
is on the screen while rows come in or go above it (actMore.onclick
scrolls the page by what it moved). Never behind it: a row that needs
the reader (to sign in again, resting, a model resting, failures with no
answer, a remote whose allowance can't be read), the rows under a fold
the reader opened themselves, and the heading of a provider with a row
shown. A row to sign in again is drawn under its fold even while the fold
is shut. Two more alone aren't folded. "View usage" beside it opens the
Usage page's Overview (window.openUsageOverview in
plugins/usage/page.js), where each account's card says it all, without
keeping that tab as the reader's own. See routing-acts-compact.test.cjs.
A provider's accounts together
A Usage card of several accounts (not a card of keys, which has its sum)
has "All N accounts" under its head, and the tray panel's group of
several the same strip above its cards (quotaAll, CryptoSarom on
X). A routing group's row has a line for each provider among its
members: what is left of that provider's accounts together
(groupQuota in plugins/routing/client.js, drawn again when
quotas is new). quotaAll and mergeQuotas are in quotaall.js, which app.js imports
once a provider has two accounts (quotaAllJS) and the Routing page
once a group's member has readings, so they weigh nothing on the core;
each place is drawn again once it is in. All three come from
mergeQuotas, which puts together only what reads alike:
- a counted window (
limit) of one name and unit adds its amounts and limits, its share the share of the sum; a wallet (balance) adds its balances in one unit; - a window said only as a share is the mean of the accounts on one plan, the same allowance each; two plans are never averaged, and a window more than one plan has is named with its plan;
- a share is never added to a count;
textwindows are left out; unlimited only where every account read says so; - an account whose reading failed is unknown, not 0, and is counted
("1 couldn't be read"); a window an
asOfreading stands in for, whose reset has passed, is left out and counted in its tooltip; - a window the account can't spend counts as used up: its
heldBy(provider.WithHeldWindows, set on/api/usage/quotas) names another window that stops the account for every model, is used up and starts again after it, as 7 days at 0% left holds 5 hours at 100% (#4791). Not the other way: a week with room behind five hours used up keeps it. The tooltip counts how many were held; each account's own card still shows the vendor's figure; - only what two or more accounts have goes together; family and pool
stay, so
familyWindowsfolds the result as an account's.
No account is named in it, and each account stays below it as it was.
There is no switch: it is additive, and the figure follows used or left
with the rest. See usage-merge.test.cjs (the merge) and
usage-all-accounts.test.cjs (the three places).
Below the strip each account of a card with several is a card of its own
inside the provider's (.subscription-acct, a box on --card-2 with a
hairline all round; normalcoder_ on X: a hairline between accounts didn't
tell them apart). A card of keys keeps its keys as lines, as does a card
of one account. The account's menu (quotaCardMenu) is found from the
box's first row, its name.
See usage-account-subcards.test.cjs.
On the Usage card and in the panel, a click on the strip or its chevron
(.quota-all-fold, the accounts' own ⌄ with aria-expanded) folds that
provider's accounts away under it, open by default (justfreefall on X).
It is remembered by provider for the window and the panel alike
(magpie.usageAllFolded, quotaAllFolded in quotaall.js). Folded, the
card's "Show … accounts" button keeps its room but is hidden and inert, so
the strip stays where it was. A menu bar cell asking for one of the
accounts unfolds them (focusQuotaCard). See usage-all-fold.test.cjs.
The Usage page's allowances are cards, or a table when the reader picks
Table in the Allowances head (#quotaView; zysicyj on X: a dozen-plus
accounts were hard to scan as cards). The pick is kept in localStorage
magpie.quotaView on this computer and nothing is written until it is
made, so the default stays cards. The table (quotaTable in
quotatable.js, which app.js imports once it is picked) has a row per
account in the cards' order, so what the cards hide or merge is hidden or
merged here too, with the subscription, the account, the four windows most
accounts have (each as its used or left share, a bar and when it resets,
from the same quotaFill and quotaText as the cards, so Used/Left turns
both) and the rest of an account's windows in a last column; a failed read
and a balance say so across the windows. A head sorts by it (most used first
for a window, A first for a name), again the other way, a third time back
to the cards' order; accounts with nothing in that column stay last.
A column is what its windows are of, not their names (columnOf;
normalcoder_ on X: Antigravity's "Gemini · 5 hours" sat in the last column
beside an empty Gemini one). A pooled window goes to its pool's column
(poolWord, "Claude & GPT" under Claude), naming its window in the cell;
any other window goes by its span (spanOf: "Weekly", "7 days" and "7d"
share one column, headed by the name most rows use, a number on a tie),
and a window with no span by its name. A provider with several accounts
(grouped as its card groups them) is one row (jay68xu on X, #6740): its
name, how many accounts, and each column's share averaged over the accounts
that have one; its accounts are rows under it, without the provider's name
again, folded until the row is clicked. What is open is kept by provider in
localStorage magpie.quotaTableOpen. Sorting orders providers by that mean
(a name or account by its first account) and accounts within each. A column
no row fills is left out (Account when no account is named; the window
columns and Other only exist when some row has one). It
scrolls in its own box at a narrow width, the subscription held at the left.
See usage-quota-table.test.cjs and usage-table-groups.test.cjs.
The Sessions page's folders
The Sessions page lists an agent's project folders as one list, newest
session first (client.js).
A row says the folder's name, the folder it is in (home as ~, from the
manage reply's home), its newest session's title, when, and how many.
Temporary folders, the disk's root and apps' hidden folders under home
(scratch) wait folded under Other folders at the end; a search, or a
session opened from elsewhere, unfolds them. A ZCode session started
without a project runs in a folder ZCode made for that one session
(~/.zcode/workspace/draft-<id> or <ms>-<uuid>, ZCode 3.17.2's host):
one folder each was 40 folders of one session each, folded under Other
folders. They stand as one Draft sessions group after the projects, and a row's
tooltip gives the folder it ran in (flandern1211_58540 on Discord, #5754;
sessions-zcode-drafts.test.cjs).
Checkboxes and the
Delete bar come only with Select, and Done lets the pick go. Relocate
project and Delete all sessions are in a folder's ⋯ menu, shown on hover
(always on a touch screen) and on a right-click. See
sessions-folder-list.test.cjs.
Routing day tallies
Live, an account's row under Accounts and keys counts its tried, answered
and failed over the day's whole history, not over the last few requests
the gateway keeps (#3351): the two said different things by orders of
magnitude, and the day tabs above the section count the day. The counts
come with the history read the page already polls (/api/gateway/history
with no day, its tallies), counted by DayTallies in
internal/gateway/history.go from
the same files the Usage page reads, keyed as the page groups accounts
(provider and user, a key or provider by its id). Each look folds in only
the whole lines added to today's files since the last one: a busy day's
file is hundreds of MB (#3383), and the page asks every 15 seconds. A
request done since the last look is counted at the next one. The note
under the heading says the counts are today's. What the history cannot
say — the readings the latest request was weighed by, the rests, one
model resting alone, the accounts in the kept requests — the page still
takes from the trace over these tallies; a day picked, or a purpose
picked, counts its own list as before, and the note then points at that
list. An older answer without tallies counts the kept requests as it
did. See routing-day-tallies.test.cjs.
Stored agent sessions in WSL
The Sessions page uses sessions.ListAgent; Usage → Sessions uses
sessions.List and StatsFor through the handlers in
sessions.go and
sessions_manage.go.
ListAgent also lists a session nothing was said in, so it can be cleared
away; List leaves such a session out. The routes a row opens
(conversation, Markdown, Terminal) look the session up with
sessions.Find. Find finds every session ListAgent lists, empty ones
included, so such a row doesn't answer "no such session" (#2273,
TestFindEmptySession, TestEmptySessionOpens).
On Windows, internal/sessions/wsl.go
reads running distros through their WSL shared paths. A stopped distro keeps
its cached listing and is not opened; running distros are relisted at most
every 30 seconds.
For omp, ompRootsIn includes both
~/.omp/agent/sessions and
~/.omp/profiles/<name>/agent/sessions. Subagents and advisor files count
in their parent session. A profile session's Resume command selects its
own profile with omp --profile <name> --resume <id>, including when
resumed through wsl.exe. Delete and Restore preserve its original
profile path and artifacts. Windows does not discover arbitrary stores
selected by a distro's PI_CODING_AGENT_DIR, XDG variables or
--session-dir.
Desktop fonts
Settings → General offers independent interface and code fonts, each with
the installed family's actual styles. GET /api/fonts calls
fonts.List: DirectWrite on Windows,
CoreText on macOS and Fontconfig on Linux. Discovery is lazy, cached in the
handler, and refreshed by the menu. It returns names and CSS traits, never
font files or paths. A failed refresh answers 503 and preserves the previous
collection; an empty successful collection is distinct from failure.
A nogui build can't read the catalogue and answers the app 404.
A browser tab (magpie web, or the app's page opened in a browser) always
has the same rows (Norcleeh on Discord). Its choice is the
browser's own, kept in localStorage under magpie.fonts and applied by
fonts.js before the first paint: the tab can be on another computer, so
it neither changes nor takes the app's settings.UIFont/CodeFont. A
tab's /api/fonts is the server's families (none in a nogui build such as
Docker or magpie-cli, and none when reading them fails, never an error)
plus commonFamilies in internal/gui/fonts.go, in regular and bold.
The tab keeps those it draws (webFonts.drawn in webfonts.js: text in
the family measures apart from a generic family's on a canvas), so another
computer's fonts, and Safari's user-installed ones, aren't offered. When
none is kept, the rows still offer System default.
Those are the server's names, so fonts installed only on the browser's
computer were missing (Norcleeh again, magpie in Docker). webfonts.js,
which only a tab loads (app.js loadFonts imports it; the app's windows never
need it, and it is outside the core script budget), adds them: where the
Local Font Access API is (Chromium on https or localhost),
queryLocalFonts() is called in the press that opens a family menu, once
a page, and at load when the local-fonts permission is already given;
its style names ("SemiBold Condensed Italic") become weight, slope and
width. Elsewhere (Safari, Firefox, a plain-http LAN address, a refused
permission) the menu's search also takes a typed family: "Use “name”" is
offered when the canvas probe says this browser draws it, and greyed out
when not. A chosen family the server doesn't list stays in the tab's list
on later loads while the browser draws it, so desktopFonts.available
keeps applying it. Until 10-28 the rows were
gated on a boot fonts flag, so a nogui server had none, and what
"flashed and vanished" on a refresh was Text size: the rows a tab never
shows (Text size, the tray click, Open at login, the menu bar's
allowances) are .app-only, which body.web hides before the first paint.
settings.UIFont and settings.CodeFont keep the family, style name,
OpenType weight, CSS slope and width percentage. A missing choice keeps the
platform default. A settings POST can restore that default with an explicit
null; omitting the field preserves it, as does every browser-mode save.
KeepOwn preserves this computer's choices during sync and backup restore.
Invalid traits reject the save without replacing the previous settings.
fonts.js applies choices at boot and
through applyPrefs. After a successful font change host.fontsChanged
notifies both existing webviews through receiveFonts, without waiting for
the other window to gain focus; a released lightweight webview uses boot
settings when recreated. An in-flight local save ignores the notification
and finishes its own queue.
The selected family precedes the existing platform fallback stack. The
interface and code traits apply independently; explicit component weights
still mark emphasis. A choice takes precedence over Omarchy's font, while
restoring the default follows the theme again. If discovery finds a saved
face missing, the page retains its name, explains the fallback and uses the
default until the face is available or the user chooses another. A discovery
error never clears a saved choice. The browser's own typography is unchanged.
The menus support search, keyboard selection and refresh. Styles are ordered by weight, then normal, italic and oblique; width and name break remaining ties. Family changes keep a matching style where possible, otherwise the nearest regular face; named variable instances are offered without arbitrary axis controls.
Instance name
A browser tab's title names the magpie it shows (starballl on X: several
deployed, every tab titled "magpie"): <name> · magpie, plain "magpie"
with none. The name is settings.Name, set in Settings › Network and
sharing › Advanced › Name (instancename.js, imported when Settings is
drawn), else MAGPIE_NAME (settings.InstanceName, EnvName). The env
var only fills in for an empty field and is never written to the file, so
a name typed in Settings always wins. CleanName keeps it one line of at
most 60 characters. boot.js passes the name (name) and the env's
(nameEnv) and, to a browser tab only, sets document.title itself for
the first paint, so app.js's core carries no code for it; applyPrefs
sets the title again from every settings read. Only a browser page
(web) is retitled; the app's windows keep "magpie". The name is this computer's own
(KeepOwn): sync and a restored backup never bring another magpie's. A
Settings save that leaves name out keeps it (settingsapi.Merge). See
TestInstanceName* and instance-name.test.cjs.
Recent-call bodies
providersState in providers.go sends
recent-call metadata without request or response bodies, including after
provider writes (#1521: forty calls' bodies made /api/providers about
20 MB). Each call in the gateway's 40-call ring has an id, numbered in
Server.record. Opening a recent call on Gateway fetches its captured
previews from GET /api/gateway/call?id=… (Server.RecentCall), sent
Cache-Control: no-store. The route sits on the same mux as the rest of
the API, so magpie web's key guard covers it. The bodies are the ones the
ring kept, masked as the request was (redacted); the route doesn't fetch
S3 or change capture, export or archival. A call evicted from the ring, or
a gateway served by another magpie, returns 404. The page keys a row by
that id (callRow), keeps fetched bodies in memory while their calls
remain in the list, preserves them across summary refreshes, and offers a
retry after a failed read. See TestRecentCallBodiesOnDemand and
recent-call-bodies.test.cjs.
A request on the Routing page opens to the same bodies (Fate on Discord):
its story's head has "Request and response", which fetches
GET /api/gateway/call?route=… (Server.RouteCall) only when pressed.
A call carries the Routing request it was (Call.Route, the trace's
Route.ID, set where serve, the Codex backend, a refused title and a
System One request an app sends (/v1/systemone, serveDecideTries)
record it; the Codex backend's refused key and empty failure too, but not
a compaction's, which opens no route: TestCodexKeyRefusedCarriesItsRoute);
a route id is not a call id. When the ring no longer has it,
the story shows the request archive's copy through archivePanel if the
route names one (Route.Archive, call.archiveName(), set only when the
archive was on for that request), and otherwise says how to turn the
archive on; with the archive on (gateway.archive.on in
/api/providers) it says instead that this request isn't in it, made
while the archive was off or not saved (wangb on Discord). With the archive
on, /v1/systemone is kept as a chat request is, and a routing group's
Jev classifier, which magpie asks itself, is kept as it went (archiveOwn
in systemOne; its usage row names it): TestArchiveKeepsSystemOne,
TestArchiveKeepsJevClassifier. Still not archived: the Codex backend,
draw, embeddings and video, and replies magpie writes itself
(answeredHere). The Routing page captures nothing of its own. The archive's switch
(POST /api/settings/archive) sets RequestArchive while sync has an S3
bucket and RequestArchiveLocal while it has none; GET /api/archive?name=… reads this computer's copy first and then the bucket's
(TestArchiveSwitchKeepsOnThisComputer, request-archive.test.cjs). See
TestRoutingRequestOpensItsBodies, TestArchiveWholeBodies and
routing-bodies.test.cjs.
Under the bodies, on Gateway and on Routing, "HTTP headers" folds open a
call's headers both ways (usrname1833 on Discord: 查看原始请求和原始响应的
http头): the client's, as they reached magpie, then each request magpie
sent upstream for the call, its method, address and headers, and the
status, protocol, headers and time of its answer, or the error in place of
one (wireHeadersView in plugins/usage/page.js; headers in
/api/gateway/call, Call.Headers,
wire_headers.go). The client's
are taken by headerLogged in Handler() for every request that isn't a
GET, HEAD or OPTIONS; what goes upstream by rpmTransport, under
s.client, as it is sent (so a header Go's transport adds itself,
Accept-Encoding or Content-Length, isn't there), and by
provider.SendsThroughPlugin for an account served by a plugin, which is
shown as handed to the plugin: the plugin sends it on to its vendor with
headers of its own that magpie doesn't see, and the view says so. A call
keeps its first 8 upstream requests (headerTriesMost) and a count of the
rest. Recording is a copy of each header map; nothing is masked as a
request goes. Secrets are taken out when the headers are read, by what
each header is (redact.SecretHeader: Authorization, cookies, x-api-key,
any *-Key, *-Token, *-Secret, *-Auth, *-Signature but
Idempotency-Key and a count of tokens such as
anthropic-ratelimit-tokens-remaining), any Bearer or Basic value, and any
secret redact.Scrub finds in the rest; an address loses its password, a
secret-named query value (?key=) and its fragment (scrubURL). They live
with the call in the 40-call ring, and the request archive keeps the
upstream ones as upstream beside the request's and response's headers,
masked the same way; magpie's own requests (System One's decision, a
title, a search) keep none. See TestRecentCallHeadersBothWays,
TestRecentCallHeadersEachTry, TestPluginHandOffHeaders,
TestSecretHeaderRealNames and call-headers.test.cjs.
Plugin check-in switches
A plugin's Usage-card Auto check-in button reads the persisted
settings.pluginCheckins[provider] first (pluginCheckinOn in
app.js). /api/state returns that map
without the derived checkinPlugins list included by /api/settings.
An explicit saved false wins over the list; when no saved choice exists,
the list's resolved vendor default remains the fallback, and without the
list (a state refresh) the switch of the built-in check-in the plugin took
over is (PLUGIN_CHECKIN_INHERITS, the ids provider.PluginCheckinOn names;
a test reads both). This keeps a saved
switch on through a focus refresh and lets the next click turn it off.
plugin-checkin.test.cjs
covers both response shapes, refreshes and the subsequent toggle.
Plugin options
A plugin provider's editor shows the options its plugin declares
(pluginOptionsField in app.js; see
provider-plugins.md). The
plugin's label, description and confirm text go in as text, never as HTML.
A change is kept in draft.pluginOptions until Save, which posts each one
to POST /api/settings/plugin-option before the provider's own save. An
option switched back to where it was is dropped from the draft, so it isn't
posted and doesn't make the editor dirty.
plugin-options.test.cjs
covers it.
A plugin's own page
A community plugin that declares magpie.page gets a tab in a Plugins
group at the sidebar's foot (pluginpages.js, loaded after plugins.js),
listed from GET /api/plugin-pages and again whenever Plugins reloads its
list (window.loadPluginPages). The tab's title is the plugin's own and is
not translated; renderCrumb and the sub-nav's label read its plain
<span> where a built-in tab has span[data-t]. The frame is made the
first time the page opens and fills the view (.view.plugin-page,
.plugin-frame). The theme and language reach it on every change of
data-theme, lang, class or style on :root. A page gone off or
away loses its tab, and the window goes to Plugins if it was on it. The
security model, the bridge and the reads are in
plugin-runtime.md.
plugin-page.test.cjs
covers it in both engines, every language and a narrow window.
Shared UI rules
-
Windows desktop windows and tray panels keep the modal's dimming veil without backdrop blur or saturation: full-window filtering can stall WebView2 while a provider test or sign-in dialog is open. The existing
winmarker fromlayout.jsscopes the rule inapp.cssto the desktop app; browser pages and other platforms keep their existing effect.modal-backdrop.test.cjschecks the computed filter and veil in both engines and modes. -
Settings → General is laid out as macOS System Settings is (1ooogle on X): a row says its name alone when that says enough (Appearance, Colorblind mode, Language, Text size, the fonts, the tray click, Open at login, Show in Dock), and keeps one short line where the setting isn't clear from its name or has a consequence (Lightweight mode, Prevent sleep, Session terminal). Codex's, Claude Code's and Grok Build's own settings (Codex subagents, Long conversations, which is all of Grok Build's, background compaction, thread titles and descriptions, composer predictions, the auto-review and memories models) aren't here: they are in the agent's opened row on the Agents page (
AGENT_PREFS,connectPanel), the panel's row has a Settings line that opens them in a sheet (openAgentPrefs), as does the agent's menu, and Settings' search finds them with a row that opens that sheet (#agentPrefLinks). Each row is one element moved between its places, so its handlers and state go with it (the owner, 10-20;agent-prefs.test.cjs). Long conversations is the exception with no Codex, Claude Code or Grok Build here, in gateway mode or a magpie in Docker: it sets the windows the gateway serves, which agents on other computers read, so it stays in General (renderAgentPrefLinks, Linka on Discord). A font row's line shows only while its fonts load or fail; the text size keys are the choices' tooltip, and Colorblind mode's note is its Off/On control's (#colorblindSegs). Colorblind mode (settings.Colorblind,data-colorblind="1"on:root, #2073) switches the chart series (--c1…--c7) in both light and dark themes to an Okabe–Ito palette where adjacent series differ in hue and lightness. On a quota curve each window (data-series, its index mod 7, set bydrawQuotaPlotandquotaCurve's legend only) gets a dash of its own onpath.qc-line, its legend key shows a sample of that line (.qc-sample) for the dot, and the even paces (line.qc-even) are dotted; the curve's tooltip says so. The balance curve sets nodata-seriesand keeps its solid line, dashed fit and dot. The Context tab's "good" grade, which takes--c2as a colour rather than a series, keeps a blue (--c1). Language is one menu button showing the language picked, opened in the app's menu (renderLangPick). Seesettings-general.test.cjsandquota-curve.test.cjs. Open at login readsautostart.Enabled, which on macOS 13 and later also asks Background Task Management about magpie's launch agent (SMAppService.statusForLegacyURL:, matched by the plist's Label, not its path); a record the user switched off in System Settings › General › Login Items reads as needing allowing, and the row keeps On with one line saying so and a button that opens Login Items (/api/openallows that onex-apple.systempreferencesURL). The status read again when the window comes back to the front clears the line. On macOS 12, in a build without cgo, or when the system can't be asked, the plist alone decides, as before (#2120,login-allow.test.cjs,login_allow_test.go). On Linux it reads the autostart entry the desktop starts: the user's own over a package's in$XDG_CONFIG_DIRS(/etc/xdg when unset), as the XDG Autostart spec has it. Off over a package's entry that starts magpie writes a Hidden entry of the user's over it, and on takes that away rather than writing this copy's path (#3372,autostart_other.go). -
A setting row's line under its name (
.row.pref .sub, in Settings, Plugins › Built-in and an agent's own settings) wraps whole beside its control, never cut to one line with an ellipsis (arculongus on Discord,settings-lines-wrap.test.cjs). -
Settings' search-provider picker offers Off, saved as
searcher: "off". Its help explains API-only search and suppresses provider fallback/own-search hints while off; the search priority row is hidden because no provider competes with the APIs. See gateway search behavior,renderSearcher,TestSettingsSearchProviderOffandsearcher-pick.test.cjs. -
A searcher named there gets an "If it fails" row right under it (
renderSearcherThen). The row holds numbered chips forsearcherThen, the providers that search in its place, in order. Add offers every searcher but the one named and the ones already listed. A chip's picker changes it or removes it. The row isn't shown for Automatic or Off. The failure line names the one that searched instead (searchFailed.instead), or says the ones after it failed too. Seesearcher-then.test.cjs. A picker's item is pressed throughpickIteminreader.cjs, which waits for the list drawn again after/api/model-speedsanswers (#4274). -
Settings' search APIs are asked in their listed order: each API's row (with its keys' row) is dragged as one, or moved with Alt+↑/↓, and has a switch that turns it off without removing its key (#2286). See the search APIs' order,
searchArrangeinplugins/search/settings.jsandsearch-order.test.cjs. -
Settings' Search APIs add row has a base URL field under the key for every API (#1580): the vendor's own address is its placeholder, picking an API already added fills in its saved URL so a new key alone keeps it, and Add with no key changes only the URL. See a search API's base URL,
renderSearchandsearch-api.test.cjs. -
Every user-visible string has zh, zh-TW, ja and de translations with the same placeholders.
gui-zh-tw.test.cjs,gui-ja.test.cjsandgui-de.test.cjsfail on a missing one;gui-zh-tw.test.cjsalso fails on a zh-TW string with a Simplified character left in it. -
A click never moves the page. Code scrolls a view only with the reader's event in hand (
scrollOnPurpose);click-scroll.test.cjsguards this. A click is taken where the reader left the view: a scroll not theirs made just before it, whose scroll event the browser sends only at the next frame, after the click, is put back first (backToReaderin the click guard, #1554). What was clicked is held where it was (hold); a view at its top when clicked stays at its top, and what comes in above the control moves it down instead (#2134,update-auto.test.cjs), as long as it moves less than half its own height and so stays under the pointer. When what the click does leaves the page shorter under it (a list emptied), the view keeps room at its foot for it to stay (.view-room), room that goes as the reader scrolls back. A control under what it unrolls (data-unrolls, "Show 7 more") goes down with what it opens: what's held is the part it is in, so the rows open downwards. A heading drawn anew whose only neighbour above is a zero-height pad (the first part of a skill group's windowed list) is marked so too: the hold passes over a neighbour with no height, so it held the next part's heading, which the rows opened pushed down, and the clicked one went off the top (jinpwng on X,partHeadin plugins/library/client.js,library-group-steady.test.cjs). Anything larger above it, as the stage a day picked on Routing brings in above the bar, is scrolled past, and the control stays where it was clicked (routing-days-fit.test.cjs,routing-failed-open.test.cjs). -
A page scrolled a screen down shows Scroll to top and Scroll to bottom (emo172, #1090): a small capsule of two chevron buttons at the open page's lower right, in its right margin when a wide window leaves one, else over its corner; above Providers' sticky Add buttons. It goes again near the page's top and over a dialog, and, over the corner, at the page's foot, where the last row can't scroll out from under it, unless it has the pointer or focus. It is placed again on a scroll, a resize, a page shown or hidden, and whenever the open page or one of its own children changes size (a
ResizeObserver, so a Routing group opened or closed moves it off the editor with no scroll, Jiabubu; seeview-ends-relayout.test.cjs). It never changes the page's height, which the guard below measures. A press is the reader's scroll (scrollOnPurpose, thenarrivedonce the page stands still), smooth unless motion is reduced; Scroll to bottom isaria-disabledat the foot. Each button's name and tooltip are in every language. The code isscrollends.js, imported on the window's first scroll so the core doesn't carry it; the tray panel has none. Home and End scroll a page as before. Seeview-ends.test.cjs. -
A scroll not the reader's is put back, so every way the reader scrolls has to count as theirs: the wheel and a trackpad's coast after the lift (WebKit on the Mac plays the coast itself and the page hears its scrolls with no wheel for each, so the wheel starts the same chain a touch fling does,
flings/flingUntil: each scroll keeps the next one the reader's till it rests, and a click ends it; issenn on Discord,view-trackpad-coast.test.cjs), a wheel or coast the page is never told of (macOS 13's WebKit, Safari 16.6's, scrolled a view under wheels it never dispatched, so every scroll was put back and only the bar's drag moved the page: three scrolls put back the same way within a second are taken as the reader's run and given back, and so is each one after it that goes on the same way within a second of the last, so a wheel turned slowly or on a loaded Mac loses no step; a scroll by code is one, not a run, and two at rest are still put back; issenn on Discord,view-wheel-unheard.test.cjs. Under a click's 4s hold the same holds: only a put-back that comes with the page redrawn since the hold last held (redrawn: the view's height or where the first held parts sit moved fromh.lay) is the hold's and never counts toward a run, so a profile opened on the Agents page and wheeled through at once scrolls, issennknight on Discord,view-wheel-after-click.test.cjs. The partsh.laymeasures are those still in the page that scroll with it: a part drawn again since (the Usage page's tabs, the agents' list under an agent opened or closed) is a redraw once, not at every scroll, and a sticky one (Settings' tabs at a narrow width) is left out, as it sits still while the page scrolls;view-wheel-after-redraw.test.cjs), a touch and its fling, the keys, a drag, the scrollbar's own drag (barDrag, #1089) and the middle button's autoscroll (panning, 多喝热水 on Discord). Chromium and WebView2 give the autoscroll a press of button 1 and then no event of the reader's while it scrolls; from that press the view follows it till Chromium ends it, on the next press (which reaches the page only as a pointerup), a key (a keyup), or the lift after the mouse moved while held. A field the guard brings back into view after putting a scroll back is one focused since the reader last scrolled that view, not one they scrolled away from (scrolledFrom): the middle press focuses the button under it. Seeview-middle-autoscroll.test.cjs. -
A load that lands puts the view back where the reader left it (
show'sbackon the page's first reads, the Providers pages' reload afterrender): what it drew may have pulled the view up, the browser clamping it to a page shorter for a moment. While the reader scrolls, the place last heard is late (the page hears of a scroll a frame or more after it, WebKit scrolling on its own thread), and putting it back took their last steps and stopped their coast each time a load landed under the wheel, so Routing and Usage, scrolled as they opened, shook and snapped back (issennknight on Discord, macOS 13).backAfterLoadkeeps a view that has gone on the way the reader's own scrolls go (readerWay, set from each scroll of theirs) as theirs, and puts back only a move against it, which is a redraw's clamp. The browser's scroll anchoring stays on: as data comes in above, it lowersscrollTopwith what's on the screen still, which the reader never sees, so the test tells a put-back (the view up, what was under the pointer going down with it) from that. -
Where the window's WebKit scrolls under wheels it never tells the page of (macOS 13's, 16.6), each gesture's first scrolls were put back until three the same way made a run (
puttingBack), a shake at the start of every gesture, the first on a page just opened included. The first run given back is remembered (deaf, kept in localStorage asmagpie.unheardWheelsfor the next start); from then on a scroll at rest waits 120ms before it is put back (waitsBack), and one more the same way within 80ms (a frame or a few; code's two scrolls in a row come further apart and are both put back,view-wheel-unheard.test.cjs), with the page's height the same (no redraw between them), makes it the reader's at once. A lone scroll (a redraw's, code's) is still put back, 120ms later; one under a click's hold is put back at once as before. Seeview-open-wheel.test.cjs, which starts the wheel before the first data, tells the page of each scroll 80ms late or never, and counts every write that moves the view up under the wheel. What the wait puts back is recorded as an at-once put-back is, so a wheel heard later than 120ms still gives it back (givesBack). -
Typing never moves the page either. A textarea that grows with its text (the Library's
autosizein plugins/library/client.js: a set's text, an agent's own text, a skill's description, a subagent's fields) is measured at height auto with what holds it kept at its height, so the page never goes short for a moment: a page gone short has its view's scroll clamped by the browser at every input, an input method's every composing step included, and the guard's putting it back pulled a textarea taller than the view to one of its edges (#2636,library-ime-scroll.test.cjs). -
A box that scrolls inside a page keeps the wheel at its ends: wheeled past its top or foot, the page stays where it was (碳碳双键 on Discord, Requests' list on Usage).
holdsin app.js marks every box between the pointer and its.viewthat scrolls vertically and overflows (.holds), onpointeroverand on each wheel, and app.css gives.holdsoverscroll-behavior-y: contain(the Mac's bounce stays, on the box). It is not one CSS rule for every box because Chromium (WebView2, magpie web) holds the wheel in a box told to contain even when it doesn't overflow, and in one that scrolls only sideways, so a short list or a wide table would stop the page..holdsis under:where(), so a rule that passes the wheel on still does (.mchipsin a short window, #833). The page itself (.view) and the document chain as before. An engine with nooverscroll-behavior(Safari 15, macOS 12's WebKit until Safari is updated; Safari 16+, WebKitGTK and Chromium have it) gets the same fromcompat.js: a wheel over a.holdsbox at its end in the wheel's direction is cancelled, so there the Mac's bounce at the box's end is lost. A guard ininner-scroll-contain.test.cjsbuilds every rule in every stylesheet under assets that scrolls a box vertically from its own selector, fills it and points at it, and fails naming the file and selector of one that doesn't hold the wheel (a rule that setsoverscroll-behaviorback to auto, or a boxholdsdoesn't reach). Seeinner-scroll-contain.test.cjs. -
An agent's model list (
openAgentModels) shows every model by default; an agent with none shown can't connect and says so (AllHiddenError opens the list), so the default stays and a saved list is never changed. In its rail of providers (more than two providers, 600px or wider) each row has a tri-state tick at its end (.am-rk,role=checkbox,aria-checkedtrue, mixed or false): a click shows or hides every model of that provider without picking it, a model in use staying shown as Hide all keeps it; All providers' tick is the foot's Show all / Hide all, asked twice (coolAndyHe on X,agent-models-provider-ticks.test.cjs). -
There are no native
<select>elements and no colored left-border stripes. State is shown with a dot or a swatch. A dot never says good or failed by colour alone: a failed state's dot is the same box drawn as an x (--x-mark, a mask over its red, scaled 1.5 so it reads as heavy as the round dot), since red and green dots read as one colour to a red-green colour-blind reader (coolmantou on Discord). That holds for Test models (.tdot), an agent's status line (.ag-dot), the check-in (.ci-dot), the request ledger (.led .st .dot), Routing's tries, steps and preview (.rt-req/.rt-probe,.rt-steps,.ps-dst) and a Library server's health (.lib-health.err); seestatus-dot-shape.test.cjs. -
What the window shows can be selected and copied, its controls can't, as in a Mac app (Outvi V on Discord: nothing could be copied into a bug report). The page is
user-select: none, and two:where()rules afterbodyinapp.cssmake text content selectable (paragraphs,preandcode, a detail's values, hints and notes, every error class, a conversation, a request's story on Routing) and keep every control unselectable with what is in it (buttons, labels, tabs, menus, the navigation, grips). Both have no specificity, so a view's own rule still decides, as a list being sorted does; a field stays selectable. Seeuser-select.test.cjs. -
The tray panel is as tall as the tab showing, from
panelMintopanelMaxand the screen's room (panelFrameintextsize.go), and shrinks as well as grows:fitinapp.jslays every tab out to measure the one showing and asks/api/window/fitfor its height. A tab picked glides the panel's edge there (TAB_GLIDE, 240ms on app.css's--ease-out; a jump under reduced motion), whichglidePanelcarries out by the tray icon: on the Mac the system animates the frame with its top edge under the menu bar, elsewherestepGlidesets the size a frame at a time throughsizeOpenPanel(panelrefit.go), which on Linux places the panel by the icon again. On Windows every refit of the open panel (the fit, each glide step, a text size) keeps the place the tray gave it as it opened, its centre and the edge by the taskbar held inside the work area (panelRefit,TestPanelRefitKeepsItsPlace,TestOpenPanelRefitsInPlaceOnWindows): asking the tray for the icon's place again moved it, since an icon in the taskbar's overflow flyout is put flush right as it opens and over the flyout's arrow once the flyout closes (jiangshangmuyun on X). It was held at the tallest tab's height (#124) until a short tab sat over empty room once a tall one had been opened (refeccd on Discord). Seepanel-fit-tabs.test.cjs. -
The Usage page's cards and the tray panel's Allowances tab share one order,
settings.UsageOrder(byUsageOrder). In the panel a balance-only card stands where that order puts it, and balances next to each other share one Balances grid (panelBalances, #1510); none is gathered after the plans. The panel's Arrange (panelArrange) moves rows in it and hides subscriptions from that tab alone (settings.PanelUsageHidden); both save throughPOST /api/usage/arrange, which changes only the field it is sent, and the Settings save keeps both. Hiding is display only: a menu bar cell's card shows though hidden (panelPeek). The panel also leaves out what Usage › Overview hides (onkashiko on X: a card hidden in the main window still showed in the panel): a card whosecardHideKeyis insettings.UsageCardsHidden, left out beforekeyCardsputs a key's balance on its plan's card as on the Overview (a balance hidden leaves the plan's card without it, a plan hidden leaves its balance on its own), and the rows insettings.UsageWindowsHidden(withoutHiddenRows). A subscription whose every card the page hides counts as hidden in the foot and in Arrange (both frompanelPageCut, in the Usage plugin's page.js, which every window loads), and Show there drops its cards fromUsageCardsHiddentoo, since the panel follows the page. The panel reads settings again each time it is shown (loadBack), so a hide in the main window reaches it with no restart. SeeTestUsageArrangePanelHidden,panel-arrange.test.cjs,panel-page-hidden.test.cjs,panel-hidden-balance.test.cjsandpanel-balance-order.test.cjs. -
An allowance card can be hidden from Usage › Overview (whqtian_07012 on Discord: StepFun's plan wanted, its balance not). The card's "…" button at its head's end (
quotaCardMore; jen_celeus on X looked for a way to hide OpenCode Zen's card, which has no usage to show, and found none), a right-click, or a long press on a touch screen (quotaCardMenusinplugins/usage/page.js) opens the app menu with Hide from Overview. The button shows as the card is hovered, at the head's end, with room kept for it either way (drawn over the end, it hid "Show the other accounts in brief", normalcoder_ on X;usage-card-menu-room.test.cjs); where nothing hovers it is always shown, drawn at 22px and taken at 44 on a phone; an account of a card with several says Hide this account from Overview, and a plan card carrying its key's balance (keyCards) also offers Hide its balance from Overview, which keeps the plan. Each is kept by its tray card id and kind (cardHideKey:stepfun|balance,kimi|me@x|plan) insettings.UsageCardsHiddenthrough the samePOST /api/usage/arrange(cardsHidden), and kept by the Settings save.overviewCardsleaves them out beforekeyCards, so routing, caps, the counting and the Accounts list never hear of it; the tray panel's Allowances tab, the menu bar's cells, tooltip and Windows' tray figure (trayShown), andmagpie tui's Usage page leave it out too (above, andprovider.ShownQuotas). A cell naming an account takes its card the Overview still shows (its balance with its plan hidden); a cell following the account in use is left empty while that account's card is hidden, rather than moving to another.settings.TrayUsageskeeps the cell, so it comes back with the card, andPOST /api/usage/arrangewakes the menu bar (onTrayUsage) whencardsHiddenorwindowsHiddenis sent, with no restart. SeeTestTrayLeavesOutWhatTheOverviewHidesandTestUsageArrangeWakesTheMenuBar. Such a card's menu offers Show in Overview, not Hide again, since the "{n} hidden" line leaves it out while it shows. A "{n} hidden" line under the cards (#quotaHid,renderQuotaHid) opens them, each with Unhide, and Show all from two. The line is drawn in--muted, not--faint, so it can be read and found (3:1 or more), and while any are hidden every card's menu ends with Show {n} Hidden, which opens the line with the keyboard on it and brings it into sight on the menu's click (openHidden; yuu003348 on Discord found no way back). SeeTestUsageArrangeCardsHidden,usage-cards-hide.test.cjs,usage-card-more.test.cjsandusage-hidden-way-back.test.cjs. -
A card's quota rows can be hidden one group at a time from Overview (wangshaowei39 on X: Antigravity's Claude & GPT rows unwanted). A row's right-click or long press (
quotaRowMenuItemsinplugins/usage/page.js) adds Hide {group} from Overview to the card's menu, and the card's "…" lists each group. The group is a pool's or model family's name, else the window's (windowGroup), so a pool's 5-hour and weekly rows go together. Kept asprovider|groupinsettings.UsageWindowsHiddenthroughPOST /api/usage/arrange(windowsHidden), every account of the provider alike, and kept by the Settings save.overviewCardshands the page a copy without them (withoutHiddenRows); caps, routing and counting read the full card; the tray panel, the menu bar andmagpie tui's Usage page leave the rows out as the page does. A card is never left with no row: a card with one group offers no Hide, and one whose every group is named shows all. The "{n} hidden" line counts the rows with the cards, each with Unhide (hideQuotaRows). SeeTestUsageArrangeWindowsHiddenandusage-rows-hide.test.cjs. -
A client in the Usage page's Agents list can be hidden from that list (ikunbots on X): its row's "…" button or right-click opens the row menu with Hide from this list, saved by client id in
settings.UsageAgentsHiddenthrough the samePOST /api/usage/arrange(agentsHidden), and kept by the Settings save. The ledger, the totals and the chart still count a hidden client. A "{n} hidden" line under the list opens them, each with Unhide (hideUsageAgent), and while any are hidden the row menu ends with Show {n} Hidden, which opens it as the cards' does (openHidden). SeeTestUsageArrangeAgentsHidden,usage-agents-hide.test.cjsandusage-hidden-way-back.test.cjs. -
The Agents list folds the clients that are small and idle into one Other row at its foot, with no setting (WJaunita45604 on X: dozens of randomly named test clients of ~10K tokens each, every one a row laid out again at each refresh, made the page crawl). A client not hidden folds when it is past the 5 with the most tokens, under 1% of the period's tokens, and either made no call in the last 3 days or is past the top 20 (
usageFoldAgentsinplugins/usage/page.js); two or more fold, or none do. The last call is the agent group'slast(usage.Group.Last, set bysummaryCounts.addanddirect); a group without one is not idle. Other's numbers are the folded groups' sum (usageSum), so every total stays exact. It opens with a click, Enter or Space (aria-expanded), the page left where it is, and draws the folded rows, each with its own actions, 100 at a time with Show {n} more; closed, they are not drawn at all. With 400 clients a redraw took ~30–54ms in Chromium and ~45–66ms in WebKit; with them folded, one frame (~13–20ms), as with none (usage-foldprobe, N=400 and 2000). SeeTestSummaryAgentsSayTheirLastCall,TestLoggedSummaryAgentsLastCallMovesOnandusage-agents-other.test.cjs. -
Usage › Overview's Agents, Models, Accounts and Gateway keys lists each fold under their heading (#2378): the heading is a
.foldbutton with its chevron, as on the Gateway page, and the click doesn't move the page (backToReader). What is folded is kept per viewer in localStoragemagpie.usageFolded(mountUsageFolds,showUsageFolds). The totals leave the cache out, as before, unless the tokens tile's label, a pop-up button (usageTokensPick, the app menu), is set to With cache: then the tile, the chart and every row's count and share add cache read and written (usageTokens), and the tile says the cache's count; kept in localStoragemagpie.usageWithCache. The Sessions tab counts by the same pick (#2591): its tokens tile carries the same label pop-up and says the cache's count, and the list's rows, the projects and models bars and pickers, the day chart (whose day and week buckets carry the cache's counts), the calendar and the top sessions readusageTokenstoo, the top list ranked again by the count shown (sessTokens,sessSums,renderSessChart,renderSessTop); a pick made on that tab refreshes the tab, not the Overview. The per-session median and p90 stay counted in and out (Stats.Overview). The account cards' whole-window estimate follows the same pick (Anotiaww on X): with cache, it adds the cache read and written that magpie routed in the window, scaled by the same share used, and says so (holdsLine, now in the Usage plugin'spage.js, redrawn with the cards when the pick changes;quota-holds.test.cjs). The Requests tab's total already counts every token (allTokens). A token line in parts (the Requests strip's Tokens card, the Overview's and the Sessions tab's tokens tiles) wraps between its counts and keeps each whole (usageParts,.parts); only a count wider than its card on its own is cut. Seeusage-overview-fold.test.cjsandsessions-cache-tokens.test.cjs. -
A click on a row of the Usage page's Requests (or Enter or Space on it) opens that one request on a page of its own,
#ledReqPanein place of the list, not Routing (geesehowardt7 on X;ledReqOpen,renderLedReq): Requests ‹ or Escape goes back to the list where it was left and to its row (ledReqClose), and leaving the page closes it (ledLeave). The page heads with the model and status, thenledDetail: time, agent, source IP (client_ip; a loopback address is "This computer", a gateway row older than the field "Not recorded"), requested, provider, account, sent, served, effort, then status, error, duration, tokens, cost and the rest; Routing is the View routing link in it. A refresh keeps the page as it was opened (usage-request-page.test.cjs,usage-ledger-detail.test.cjs). -
A request's details in the Usage ledger say its tokens at every width (#1839,
ledDetail): "{i} in · {o} out · {r} cache read · {w} cache creation", 0 said as 0, with how much was written for 5 minutes and for an hour when it says so. A failure that spent nothing has no Tokens row. Seeledger-cache-tokens.test.cjsandusage-ledger-detail.test.cjs. -
The requests magpie makes by itself (a routing classifier's, a web search's, an image description's) are told apart from the agents' on the Usage page (#1839): magpie's row among the agents and its rows in the ledger carry a "magpie's own" mark (
ownBadge), an account's, key's or model's row adds "{n} by magpie itself" from the summary'sown, and an account's card says how many of the period's requests were magpie's own (ownLine, drawn again once the summary comes after the allowances). Seeown-requests.test.cjsandTestSummaryCountsMagpiesOwnCallsApart. -
The Usage page's Allowances head ends in a Settings › link (
#usageToSet, wired inplugins/usage/page.js) to Settings › Allowances, where how the allowances show and their alerts are set (the scattered settings audit after netube99 on X); it lights the Allowance display row (#quotaLeftRow). -
Opening the allowances is asking to see them (#1588,
quotasOpenedinapp.js): the Usage page from the nav or its Overview tab picked, the window brought back to the front on the Overview, the tray panel's Allowances tab picked or the panel brought up on it, and a menu bar cell clicked each loadusage/quotas?asked=1, as Refresh now does. An asked read makes the backend read every account again (AskClaudeUsage), so an opening within 30s (QUOTAS_OPEN_GAP) of the last asked read sends an ordinary read instead, which joins one on its way; Refresh now always asks, with&all=1(loadQuotas("all"),AskEveryClaudeUsage), so saved Claude accounts are read again too, as their cards' refresh reads them (#5380); an opening's asked read on its way doesn't take its place. A panel page loaded while it is put away (hidden, or without focus) doesn't ask. The timed refresh is unchanged and never asks. Seeallowance-open-read.test.cjs. -
The menu bar can show magpie's own totals beside the allowances (#1984):
usage:todayandusage:7dinsettings.TrayUsages, offered after the cards in the same picker.trayUsageCardssums them withusage.QueryPage(p, Filter{}, 0, 1).Sum(the Requests tab's and the panel's cached ledger sum, gateway and session-file calls together) and asks no vendor when only totals are picked;trayTotalCardmakes every token (in, out and cache, asallTokens), markedΣso it doesn't read as the input, over the cost in Settings' currency (with By provider,settings.CurrencyByProvider, in the currency picked for totals,TotalCostIn: a sum of every provider has no one currency of its own; Settings › Usage › Advanced › Menu bar currency,settings.TrayCurrency, per computer throughKeepOwn, sets the menu bar's and its tooltip's apart,TrayCostIn, while Bark's daily message stays in the totals'; the currency rows are drawn bycurrencyprefs.js, imported when Settings draws its usage prefs),+when some calls had no price, the cost row left out when none had one. The Mac draws them as plain cells, the bird beside them saying whose. A click opens the Requests tab at the period (quotaView,?tab=requests&period=) or the panel's Usage tab (panelUseFocus). No 3-day total: the Usage page has no such window. SeeTestTrayTotalsandtray-totals.test.cjs. With By provider, the tray panel's Usage tab and the Requests tab show each cost that is one provider's in that provider's currency (ledProvin app.js): a ranking row and its line in the chart's tooltip, a model every provider of which sells in one currency (fromby.modelAt), and the whole page while it is filtered to one provider (Ledger.provider,usageapi.LedgerPage); a sum, the chart's axis and a model served in both currencies are in the totals' (onkashiko on X;TestLedgerSaysItsOneProvider,panel-currency-provider.test.cjs). Settings › Menu bar cost (settings.TrayNoCost, on by default, on every OS, per computer throughKeepOwn) turned off leaves the money out (BussanQ on Discord):trayMoneydrops the total's cost and its count of unpriced calls beforetrayTotalCardand the no-card tooltiptrayIdleTipsee it, so the cards, their tooltip and the idle tooltip say the tokens and requests alone. A relay's or subscription's balance card is money itself and stays. SeeTestTrayNoCostandtray-cost.test.cjs. -
The tray panel's Usage tab ends in a heatmap of the recent weeks (eiyuuzaki2333 on X), after the chart and ranking so nothing above it moves:
panelHeatCardin the Usage plugin's page.js, which shares its grid (heatGridOf) and tooltip (ledHeatTip) with the window's Requests-tab heatmap. It reads the same cached/api/usage/heatmap(gateway and session-file calls, so it can count more than the tab's totals) with the provider and computer picked, at most once a minute and again when the pick changes, and shows as many weeks as the card fits (8 to 53; about 25 at the panel's 440, 17 at 320). Its shades follow the tab's Tokens/Cost/Requests switch (panelUseMetric) with no new read. Weeks with no call show no card.renderPanelUseadds it only once page.js has run, and page.js draws the tab again when it loads. Seepanel-heatmap.test.cjs. -
The tray's icon is the bird alone where the bar's other icons are glyphs: the Mac's menu bar takes
tray.pngas a template image, and a Linux bar (StatusNotifierItemIconPixmap) gets the same silhouette in one colour on transparency (trayIconFor,linuxTrayIconintrayglyph.go), so a bar that tints its icons by their alpha tints the bird, not a tile (ylorn on Discord). A bar that doesn't tint shows it light, or dark when the portal'sorg.freedesktop.appearancecolor-schemeprefers light (traySchemeLight), and it is drawn again when that changes (watchTrayScheme). NoIconNameis set: a host that found a-symbolicname and drew it untinted would show a black bird on a dark bar, with no pixmap to fall back on. Windows' tray keeps the app's coloured icon, unless a card is in the menu bar: Windows' notification area shows no text beside an icon, so the icon itself is the first card's figure (Benjaminliang_1 on X;trayIconFigure,trayNumberIconintraynumber.go). It is the first row of the first card whose first row is a percentage, used or left as Allowance display has it, through Menu bar windows' pick, its digits alone, drawn in Segoe UI Semibold (Go's bold where the font can't be read) atSM_CXSMICON, white on a dark taskbar and near black on a light one, as tall as fits with a pixel above and below, centred by its ink, and three digits narrowed into the square. A balance or magpie's totals are skipped for the next card; with none the icon is the bird. It is drawn again when the figure, the icon size or the taskbar's theme changes (SystemThemeChangedwakes the loop); the tooltip still says every card. Settings › Tray icon number (settings.TrayNoNumber, Windows' alone, on by default) keeps the bird when off. One icon is set for the current theme, not a light and a dark one: Wails' Windows tray shares one handle between them. Linux keeps its label and tooltip; the Mac its cells. SeeTestTrayIconFigure,TestTrayNumberIconandtray-windows.test.cjs. With no cards in the menu bar the tooltip is magpie over today's total (trayIdleTip: every token, split into input, output and cache as the today card's tooltip is, then the cost and the requests), brought up to date with the cards' refresh; the tray's menu stays Open, the version and Quit. Wails sets the tooltip only on Windows: on LinuxsetTrayTipsets the StatusNotifierItem'sToolTipand sendsNewToolTip(traytip_linux.go), and on the Mac it is the status item's button'stoolTip(trayTipNativeintrayimage_darwin.go; NextCommit on Discord: no hover there showed anything). SeeTestTrayIconPerOS,TestTrayIdleTipandTestMacTrayTipIsSet. Every tooltip, the idle one, magpie's totals' and each card's (its use or what is left, the pace, when it resets, "as of …"), is in magpie's language, as the tray menu is:watchTrayUsagepassestrayLang(settings.Lang, systemLang)totrayCardsView,trayUsageCardsandtrayIdleTip, whose words are intrayWordsbeside the menu's, and a change of language in Settings refreshes it at once (onTrayUsage). A window's name and an error are the card's own (yi_time on Discord: English on a Windows magpie set to Chinese;TestTrayTooltipFollowsMagpiesLanguage). -
A window's Pace is a number on its card's reset line (fflake33 on Discord): the share used less the share of the window gone by, in points, "Pace +12%" over an even pace and "−8%" under it, turned with the meter when it shows what is left, amber while more is used than an even pace would have (
quotaPace,paceLine). The window's start is the gateway's,startsAtfromprovider.WithWindowStarts(its reset less its span,QuotaWindow.Bounds); a window whose span isn't known, with no limit, or a past cycle has none. Settings › Menu bar pace (settings.TrayPace, off by default, hidden on Windows, whose tray shows no text but the first card's figure as its icon) puts the same number beside each figure in the menu bar and in its tooltip (trayPace,QuotaWindow.Pace). SeeTestWindowPace,TestTrayUsagePaceandquota-pace.test.cjs. -
Settings › Menu bar windows (
settings.TrayWindows, StrikingRaw on X) picks which of a subscription's windows its menu bar card shows, keyed by provider id (every account of it, the in-use|*card too) and by window kind, not position:trayWindowKindnames a window by its span ("5h", "1d", "7d", "month", "15m"), byname:its name when the span isn't known. Unset shows every window, as before; a pick none of whose kinds the card still has shows every window again (trayShownKinds), never an empty card. Only the bar's rows, the Linux label and Windows' icon figure are filtered; the tooltip still says every window. Every window shown is drawn, not the first two (jen_celeus on X: Antigravity's four windows, two in the bar): a card with more than two has them in columns of two stacked rows,mpColGapapart, the shortest windows in the first column, a third alone on its column's top line (mpRows,TestTrayImageColumns,TestTrayEveryWindow); the Linux label lists them all. One row draws in the menu bar's own font (13pt regular), two or more stacked rows in 10pt regular, both with digits of one width (mpRowFont,TestTrayRowFont; qingnianxiaozhe on X found the old 9.5pt semibold and 11pt medium heavier than Surge's and iStat Menus' figures beside them). The GUI learns the kinds fromtrayKindon/api/usage/quotas(withTrayKinds; model and aside windows get none). The row lists a pill per ticked subscription with two or more kinds, opening the app's menu (All windows, then each kind), shown on Windows too, where the first card's pick decides the tray icon's figure; its code is intraywindows.js, imported when Settings draws ticked cards. Per computer throughKeepOwn. SeeTestTrayWindowsPicked,TestTrayWindowsKeptandtray-windows.test.cjs. -
In Usage → Allowances, Trends → Cycle offers each account's own recorded cycle menu beside its curve (
quotaCurve,quotaRecordedCyclesinapp.js). The longest window (usually weekly) owns the menu; shorter windows are drawn over the selected dates with their own reset breaks./api/usage/quotas/history?days=45supplies all retained readings, including remote cards. Completed cycles come from observed boundaries, not seven-day arithmetic; an early reset ends the previous cycle at the vendor's new start if it fits between readings, otherwise at the first new reading. Each menu option gives its observed duration, so an early reset is not labelled as a full seven days. The selected meters, plot, legend, tooltip and dashed pace use that cycle's last readings, never today's percentages. A window without a reading in the selected interval says so instead of showing a current value. A local account's past cycle asks/api/usage/quotas/history/holds?provider=&user=&from=&to=once per selection (quotaCycleHoldsOf), which asks no vendor (#2009, NorethSea):HistoricalWindowHoldsinwindow_holds_history.goreckons each window's whole at its own last reading in that cycle, from the request log up to that reading, so the 5-hour figure is the cycle's last 5-hour window, never its short windows added up. Its tooltip names that window's start and the reading's time. It shows "Loading…" until the answer comes. A window it can't reckon says "not enough data" with the reason, as a current card does; a reply that comes after another cycle was picked is dropped, and a card's Refresh or an asked read reckons again. Historical meters show the cycle end and sampling time; current account actions, balances and policies are left out until returning to the current view. Accounts are independent, and a selection survives card refreshes in the same page. Trends → 2 days temporarily shows recent readings; Off removes the curves; the tray always shows its current cycle. Seequota-curve.test.cjsand the history limits and reset inference. -
The Usage page's cards are packed into columns, never all stretched to a row's height (
packUsage, #860): each card in that order goes to the leftmost column that ends highest, on 1px grid rows, so short cards stack beside a tall one. Every card is as tall as what it holds, the last in a column too: ikunbots on X had each column's last reach down to the tallest's end, which left a card with no windows (OpenCode Zen) as tall as Claude's beside it, mostly empty, and jen_celeus on X asked for cards as tall as their content. A head with nothing under it keeps no margin below. The page's order (DOM, dragging, Alt+arrows) staysUsageOrder. The column count is the most 260px columns that fit, or one fewer when that leaves much less empty room; it is chosen again only when the cards change or the width fits another number of columns, so a card opened or folded stays where it is, even as the scrollbar comes in. Seeusage-pack.test.cjs. -
The Providers page has a search box over its list (#1614,
findProvidersinapp.js): 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; Escape or clearing the box shows every row and the fold as it was. A row that is on reorders by dragging its logo, Alt+↑/↓, Alt+Shift+↑/↓ (top, bottom) or its right-click menu (openProviderMenu: Move to top, Move up, Move down, Move to bottom). While searching, a step or a drop moves it among the rows shown (it takes the place of the row it passes,stepProvider,shownToOn) and the hidden ones keep their order; Move to top and Move to bottom go to the ends of the whole list. Every move saves the whole order throughPOST /api/providers/arrange. Seeprovider-find.test.cjsandprovider-order.test.cjs. -
Providers are removed several at once from Select, beside the search box (
#pvSelect, shown with two providers or more; eiyuuzaki2333 on X). Picking (pvSelinapp.js;pickedProviderRow,pvSelBarandremovePickedinpvpick.js, imported when Select is first clicked, so the core carries only the button and two lines inrenderProviders) puts a box on every row, takes the handle and switch away and opens no editor: a click on a row picks it, Shift picks the rows shown between, and the bar's box picks every row shown (a search narrows it; the closed Turned off fold's rows are not shown). Remove asks once, in the app's own dialog (confirmAction), with the count and every name, and postsPOST /api/providers/delete {ids}(providerRoutesinproviders.go). That runsprovider.Deletefor each id, as the editor's Remove does, inside oneagent.Reseat, so agents move once, to where they end up. A provider it can't remove comes back inunremovedwith why, stays picked and is named in the status; it is refused only when nothing was removed. Done, Escape or a removal that leaves nothing picked ends picking. Seeprovider-bulk-remove.test.cjsandTestProvidersDeleteSeveral. -
Hide accounts (
window.hideAccountsat the end ofapp.js) masks every account name and address in the window's text and tooltips, its menus and dialogs too, by one switch for the whole window and the tray panel. Routing's, Usage's and Providers' buttons (#rtMask,#usageMask,#pvMaskbeside Providers' search box) and Settings › Privacy's row are that one switch, stored inmagpie.maskEmails: turned on any page, every page is hidden and every button says so, and another window or the panel follows through thestorageevent (paultian in #feedback: Providers had a switch of its own, so one page was hidden while another wasn't). Amagpie.maskProvidersleft by the versions that had Providers' own switch is folded in once and removed: hidden on either page then is hidden everywhere now. While it is not chosen, it follows Mask personal data, and turning that on turns it on (provider-mask.test.cjs). While it is on, an account's name on the provider editor's row (accountNameButton, and the one-account line) and on its Usage card (quotaWho), and on the tray panel's Usage card (panelQuotaCard's.pq-who, in sight while the card is hovered), has an eye (hideAccounts.eye), in sight on hover or keyboard focus. A click shows that one account, its address and the name the user gave it together (kin), everywhere that page draws it, tooltips included, while the others stay hidden (yogurt36 on Discord, for a screen share). The accounts shown are a set held in memory thathits()skips; nothing stores them. The window and the panel are pages of their own, each with its own set: one shown in the window stays hidden in the panel and the other way round, so a screenshot of either shows only what was shown there. Closing the window hides them again: the page stays loaded while the window is hidden, sohideMainrunsmainClosedJS(hideAccounts.closed) first. Putting the panel away hides the panel's again, from itsvisibilitychange(the one that dropspanelPeek) (account-eye.test.cjs,TestClosingHidesShownAccounts). What it hides is the accounts: their addresses, their vendors' values (user,account, Routing'swho) and a name that stands for one, a plugin's (accountUsers, a card'saliaswithoutnamed) or a seat's. The name the user gave an account (AccountNames; a card'saliaswithnamed, whichwithAccountNamessets) is no account and stays in sight, beside the account it names, hidden (faketrader in #3656: several accounts couldn't be told apart). A label is scoped by its element, never by its value: in the user's own name (.own-name), a plan (.plan, the Providers row's.acct-plan), a model (.model-value) and a Usage card's title (.subscription-head > b) only an address is hidden, so an Antigravity account whose value is "Google" leaves "Google AI Pro" readable while an address written in a plan is still hidden; the same holds for the tooltips of plans and models (TIPS), not for the own name's, which says the account (LABELSin app.js,account-mask-alias-plan.test.cjs). The tray panel card's tooltip joins the account and the plan in one string, and still hides a plan's word that is an account's value. -
A new user's Agents page (the window's first page and the panel's Agents tab) has a Get started card above the agents in the welcome's place (wangye1644294 on X,
guideCardinapp.js). Its three steps are: add a model source; connect an agent, where the agents magpie found that can be connected are named and each is connected in one click (agents/connect); and, optional, a routing group, with the most harmless starter template that can be made from the user's models (provider.Templates, Never stuck first) added in one click throughPOST /api/groups/template. Every tick comes from the state: the models magpie serves (servedin/api/state, groups left out), an agent wired, or a group that isn't automatic. None comes from the card having been seen. The card goes once the first two steps are done. Its close button savessettings.GuideHiddenthroughPOST /api/settings/guide, so the panel, the window and a reload agree, and the Settings save keeps it. Seegetting-started.test.cjs. -
A connected agent's row in the window opens and closes on a click anywhere on it that isn't one of its controls, as a disclosure row does on the Mac (NG_shiyu on X,
connectRowinapp.js): the click is handed to the row's Models {n} link (expandLink), which stays the control the keyboard and a screen reader use and keepsaria-expanded. Buttons, links, inputs, anything with a role, the grip and the opened sheet (.ag-exp) keep their own clicks, and a click that ends a text selection does nothing. The panel's rows did this already (agent-row-disclose.test.cjs). -
An agent whose own model menu is the list picked in magpie (ZCode, Claude Desktop, Cursor Private Inference, …:
listsMenu) says that list as its ticks are, on its button and on the panel row (menuSaidinapp.js): every model ticked is All N models, one or two by their names, more as Showing x / N models, none as No models. It never says the first names and a +N: routing groups come first, so that read as a pick of one group and one model while every model was on (NG_shiyu on X). Other agents' start pickers still say the one model or group they start on (agent-menu-label.test.cjs). -
Every page of the window keeps to one width, at most 1200px of content centred, with a 16px gutter in a narrow window (
padding: max(16px, calc(50% - 600px))on each#view-…, #860). Routing, Usage and Sessions are in that rule too (面条 on Discord), so a large screen doesn't stretch them edge to edge while the others sit in the middle; their columns follow the room they get (byWidth). Seepage-width.test.cjs. -
Every dialog in
#modalis 600px wide (.modal .dialog), a long text's editor 880 (.wide). A provider's editor (drawEditor, its accounts, meters and many rows) is.roomyand grows with a large window as a Mac sheet takes the room its content needs: 600 up to a 1071px window, then 56% of it, at most 880 (5046312 on Discord).openModalcopies both classes from the content, so a question that takes the editor's place (Sign out's) stays 600. Its height already follows the content up to the window. Seeeditor-roomy.test.cjs. -
The page must work in Chromium (Windows' WebView2) and WebKit (macOS, and WebKitGTK on Linux). GUI tests run in both engines.
-
In the design of macOS 26 the main window has the corners of a window with a plain title bar, and its lights stay where the toolbar had them.
TestMainWindowCorners(titlebar_darwin_test.go) measures this in a process of its own, with packagewindowshape: after a new title and size and a new system appearance, as AppKit draws that appearance, where a first press with another app in front begins a window drag, and where a sheet begins. It runs that process as linked against the macOS 26 SDK and against macOS 15's, whatever SDK the toolchain has (runAppKitSDKandstampSDKgive the copy it runs that SDK, and sign it again). Where a toolbar doesn't change the corners (the earlier design, on an older macOS or with macOS 15's SDK, and macOS 27 with either SDK), it checks that the window keeps its toolbar (#3949);TestMainWindowRightToLeftchecks that it keeps it with the lights on the right. Both run in CI's macOS job. No test coversUIDesignRequiresCompatibility: AppKit reads it from an app bundle's Info.plist, LaunchServices registers each bundle that runs, and a press sent within a process run from one doesn't always begin a window drag. -
While a dialog (
#modal) is open the header and sidebar are inert (modalBackground) and, off the Mac, the scrim covers the title bar, so the dialog's last child.modal-gripis a drag strip as high as the bar (--wails-draggable: drag), the dialog lies over it and the scrim's padding keeps the dialog below it, so the bar's middle drags too; on the Mac the scrim begins under the bar and the strip reaches up over it (v0.1.3624 left the Mac's bar inert, ssuuuuooo on X again); a click on the strip still closes the dialog (ssuuuuooo on X,modal-title-drag.test.cjs). The browser's own confirmation (action-confirm, top layer) has no such strip. -
On Linux the panel is frameless and the main window has a hidden title bar (
plainTitlebar). GTK 3 asks KDE's Wayland session (KWin's decoration protocol) for a frame drawn by KWin on any window without client-side decorations, an undecorated one too, soownFrametells KWin the panel draws its own on each realize (#1283). GTK 4 builds ask for none themselves. With no KWin title bar, and with a Wayland window placed by the compositor rather than by the icon, the panel's header is its drag handle on Linux, as the window's is (--wails-draggableinapp.js;panel-drag-linux.test.cjs); on the Mac and Windows the panel isn't dragged (#1430). -
On Linux the panel is a solid window, as the main window is, and its page paints
--bgwhole (panelOptions,body.linux.panelinapp.css). The Mac's and Windows' panels stay translucent. A see-through panel is an RGBA, app-paintable GTK window under a transparent webview, and on KDE Plasma 6 its page, painted at 93%, left a fainter copy of the old scroll position as it scrolled (Wayland and XWayland, compositing mode on or off) while the main window never did (#1803,TestPanelSolidOnLinux,panel-linux-opaque.test.cjs). Xvfb with picom on WebKitGTK 2.54 doesn't show the ghost either way, so the fix rests on the reporter's machine. -
A Wayland window can't place itself, so under Hyprland and niri the compositor is asked to put the panel under the bar. Under Hyprland
placePanelgives it a window rule at the cursor (omarchy.PlacePanel) and closes it on a click outside (omarchy.ReportClicks). The rule names the monitor under the cursor and moves the panel to x, y from that monitor's corner (omarchy.PanelAt): Hyprland adds the window's monitor's place to amove, so a position across the whole layout put the panel off a monitor not at 0,0 (#1785,TestPanelAtMonitorOffScreenOrigin). The cursor and the clients' places thatomarchy.ClickedOutsidecompares are both across the layout. niri (omarchy.Niri,NIRI_SOCKETset) takes no rules at runtime and doesn't report the cursor. Thereomarchy.NiriPanelwatches niri's event stream and moves the panel each time it opens: the window of magpie's pid titledpanelTitle, moved withMoveFloatingWindow(afterMoveWindowToFloatingif it was tiled). It goes 6 px under the working area's top, centred on the x the tray host passed toActivate(x, y). Wails keeps that x in its Linux tray (trayClick,TestTrayClickIsWails), and it is taken across the bar, since that's all a Wayland bar knows. With no click (magpie panel), or with one off the output, it goes top right. Wails'HideOnFocusLostcloses it, since a click on another window takes niri's focus. It still opens in the middle and slides up, and a bar at the bottom or the side isn't accounted for (#1670). -
Wails calls the tray's click handler both for the icon's click (
Activate) and when the tray host opens the icon's menu (dbusmenu's "opened" event). KDE opens the menu on a right-click, and the panel that click opened took the focus and shut the menu on Wayland. On Linux the handler ignores the call when it comes from the menu opening (menuOpeningintrayclick.go, which looks for Wails'(*linuxSystemTray).Eventamong its callers;TestTrayMenuOpenFrameIsWailsfails if Wails renames it or stops calling the handler there) (#1430). -
On Linux the app draws without backdrop blur (
body.linuxrules at the end ofapp.css;linux-no-backdrop-blur.test.cjs):webkit_linux.goturns accelerated compositing off under Wayland and without a GPU, and there a blur is repainted by the CPU on every frame (a full-window modal took 25ms a frame against 16ms with none, in WebKitGTK 2.52 on Xvfb). The modal, pickers and Settings' sticky head are 92% or more opaque, so the blur is barely seen. Not reproduced on NVIDIA under Wayland (no such machine), so a report of lag there may have another part (#3150). -
On GTK 3 builds, the app gives GDK a font DPI before the first webview when it has none (
fontDPI,fontdpi_gtk3.h). GDK's unset value is -1, and WebKitGTK 2.54's GTK 3 settings reader multiplies it by 1024 unchecked, so every page lays out at a negative width with a 9000000px font (#1371). An unset DPI takesgtk-xft-dpi, or 96, times a validGDK_DPI_SCALE; a positive one is left alone. Wails initialises GTK (its GtkApplication) only insideRunand makes each window from a default-idle-priority callback on the main loop, sofontDPI, called just beforeRun, queues the check as aG_PRIORITY_HIGHidle: it runs on the main thread after GTK's own start, before the first window.TestFontDPIUnsetopens a real WebKitGTK page throughmagpie_font_dpiand needs a display (Xvfb). -
Tests never touch a live agent config. The package's
TestMainruns undertestenv's home of its own. A macOS test that shows windows runs them in a process of its own throughrunAppKit(appkit_darwin_test.go). AppKit and WebKit take their home from the account, not from HOME, sorunAppKitgives them a temporary one withCFFIXED_USER_HOME; appearance, contrast and languages still come from the account. The test fails when that process leaves a folder in the real~/Library/WebKitor~/Library/Caches. Playwright tests serveassets/with isolated/apifixtures. -
POST /api/settings/codex-auto-reviewaccepts an empty value (Codex's own choice, or the session's model when Codex's sign-in is on a Free plan),session(the session's own model when it is one of magpie's; "Same as the session" in the picker), or an exact model/group ID inprovider.Served, including unlisted providers. A known provider with an unknown or empty model name is rejected without changing the saved reviewer or catalog tag. Generic gateway request resolution remains permissive; it is not the validator for this setting. SeeHandlerinapi.goandTestCodexAutoReviewSettingincodex_auto_review_test.go. -
Settings -> Sync and backupand/api/davsync/{action}configure and run encrypted WebDAV, S3 or GitHub setup sync. They share the CLI's operations and expose credential presence, never the secrets. State, merge, failure and compatibility behavior are described in Sync and backup.
openModal makes the background inert when an editor opens fresh, leaving
confirmations and menus interactive through redraws. closeModal releases
that background as soon as the close animation starts, so clicks reach the
page while the editor fades away. Opening an editor during that animation
protects the background again. ux-safety.test.cjs checks these transitions.
Routing groups have a page of their own, #view-groups, beside Routing
under Models (11-06; below every request on the Routing page they were a
long scroll down). The routing plugin adds both pages, and routingPage
draws the groups' section (.rt-gsec) into the second one's #rtGroups
(window.routingGroupsHome, again after its Try again), so one draft and
one dirty hook (magpie.call("routing", "dirty")) serve both; rtView
in app.js asks it on leaving either. Its toolbar is the filter, how many
groups there are and how many are on, then Templates, Import, Select and
New group (text primary); the list follows, then Settings (found groups,
the names agents' lists show), then the providers routing over several
keys. A request's group or pool link (goRouting) opens the page first,
then brings the row into sight when the reader's click asked for it.
The window opened with view=groups&newgroup=<model> (mainView keeps
view=routing&newgroup= too) opens a new group of that model
(routing-groups-page.test.cjs). Its tab sits in the sidebar only: the
header's row has no room for it (at 860px it pushed the logo out,
brand.test.cjs), so there app.css hides it, markNav lights Routing's
tab for both pages, and Routing's head shows #rtToGroups instead.
The groups page leads back up as a Mac app's back button does
(unscientific9 on Discord): its toolbar starts with ‹ Routing
(.rt-gback, groupsBack), which shows Routing and gives the request's
group it came from the keyboard again. It shows where the page was opened
from Routing (openedFrom: a request's group, #rtToGroups; .rt-gfrom
on #view-groups, cleared once the page is hidden) and always where the
header has no tab of its own for the page; beside the sidebar, opened from
its own tab, it has none. Escape does the same while the button shows and
nothing on the page takes it: not in a field, nor with a group's editor,
Import or Select open, nor under a modal. The app has no ⌘[ anywhere, so
none here (routing-groups-back.test.cjs).
The page's New group goes through newGroup, which asks before replacing a
dirty group draft; Cancel retains the draft and Discard opens the new editor.
newGroupWith applies the same guard when creating a group from a model and
waits for show("groups") to accept navigation before creating its draft.
Live, the Routing page's card (its head, story and context window) tells of
one request, cur, chosen by told() in plugins/routing/client.js: it
stays on the request it tells of until that one is done, then goes to the
newest, except that a newer request routing hasn't picked for yet does not
take it from one that was routed. Requests that come meanwhile still fly on
the stage, without a caption of their own. With several
conversations sending at once it used to follow the newest and jump between
them (qiang2040 on Discord, routing-concurrent-hold.test.cjs).
While two or more sessions send at once, a block for each sits under the
context window card (renderCtxSessions), so the card never moves when one
comes or goes. Each shows its session's newest reading,
keyed as the card's own line of prompts is (sessionKey, else the
conversation), named by the agent's title for it (sessionName), else
its folder's last level, never its id alone. A session is live while a
request of it is under way or its newest is within 15 minutes of the newest
request; at most six show, the newest session first, and a block keeps its
place while the sessions take turns. The block of the request the card
tells of is lit (aria-pressed); a click picks that session's newest
request. The card's footer names the session by its title too (tjhhhh on
Discord, routing-ctx-sessions.test.cjs).
The Plugins page updates the npm search-results section when a search answers,
leaving suggested plugin cards in place so a click begun before the answer still
opens the intended plugin. plugin-market.test.cjs holds the search response
between pointerdown and pointerup to check this in Chromium and WebKit.
Routing shown by the magpie that serves the gateway
A magpie on this computer that does not serve the gateway shows the serving
one's routing in its Routing page, instead of the notice that its routing
cannot be watched here (#2606). The trigger is served.Load() being nil while
a magpie answers at the gateway's address. Then /api/gateway/trace reads
the serving magpie's GET /v1/magpie/trace over loopback
(OwnerTrace) and answers with it as its
own (mine true, so the page plays it), and /api/lanes reads
GET /v1/magpie/concurrency (OwnerLanes)
so a provider's rows show the same pills. Both are read on loopback alone
(ownerURL): a gateway address on another interface or host is never asked,
whatever MAGPIE_ADDR says, and one listening everywhere is read at
127.0.0.1. OwnerTrace lets a hung magpie go 5s past the 25s long poll, or
when the page stops asking; OwnerLanes waits 700ms, as ServedBy does, and
is asked only when a magpie answers. The state read carries the serving
magpie's serves and pid (gatewayJSON),
and the trace carries them as by. The Routing page's heading names the
magpie from by ("serve (pid 49217) is routing · 127.0.0.1:3525"), so the
name goes with the trace: when the page's trace comes from another magpie
than before (a takeover, either way), it drops the routes it had and reads
the new one's whole trace. Nothing is written; serving and takeover are
unchanged. A
magpie that serves the gateway keeps its own trace, and one older than the
endpoint keeps the notice as before (a refused or unreadable read is unknown,
never empty: OwnerTrace says so with its second result). See
TestConsoleShowsTheServingMagpiesRouting and
TestConsoleKeepsTheNoticeFromAnOlderGateway in
trace_peer_test.go, and
TestGatewayTraceIsLoopbackOnly in
trace_peer_test.go.
A Quit asks while agents go through magpie
Quitting magpie ends the gateway, and each agent wired to it fails until
magpie runs again with nothing to say why: Codex retried "502 Bad Gateway"
on /backend-api/codex/responses five times and gave up, and its user
found magpie's openai_base_url in config.toml only after a long search
(Aisiverto on X). So a Quit the user chooses asks first when
quitAgents (agent.Detected() filtered by Wired) names any agent and
this process serves the gateway (served; when another magpie serves it,
that one keeps serving the agents and the Quit goes on).
- The tray's Quit and the page's Quit (
POST /api/window/quitwithoutnow, on a host that is aquitAsker) callAskQuit. On the Mac,askingQuitputs magpie's own Command-Q item in place of the app menu's Quit role.AskQuitbrings the window up on the question: it opens/?ask=quitwhen the window is gone or loading, else runswindow.askQuit()in the loaded page. quitask.js(lazy-loaded, so it adds nothing to the core) readsGET /api/quitand draws the sheet: the agents, the sentence that they stop while magpie is closed, a note that closing the window keeps magpie running (the menu bar on a Mac, the system tray elsewhere), and Disconnect and quit, Cancel, and Quit (focused). Quit postswindow/quit?now=1. Disconnect and quit postsquit/disconnect(quitDisconnect), which puts every connected agent back as Put agents back when quitting does (agent.RestoreOnQuit, no disconnected mark, recorded inquit.restored), so the next start connects them again (RewireOnStart), whatever that setting says. Each row's Disconnect, which it used, left a mark that kept every switch off at every start after (jtbbtnt54249 on X). A failure leaves magpie open, named in the status line. With nothing connected any more it quits without drawing.- A second Quit within a minute of the question (
quitNow,quitAgain) quits, so a window that can't show the question doesn't trap the user. - Don't ask again (zhujiu on Discord), a tick above the buttons, unticked
each time, goes with the Quit or Disconnect and quit chosen as
noAsk=1: the handler savessettings.QuitNoAsk(SetQuitNoAsk, that field alone) before quitting, and a save that fails keeps magpie open. Cancel saves nothing. WithQuitNoAskset,quitAtOncequits without asking; a settings file that can't be read asks. Settings › General › Ask before quitting (#quitAskRow, the app's only) shows it as On/Off and savesquitNoAskthroughPOST /api/settings, which keeps it when a page doesn't send it. - Put agents back when quitting (tudjam17795 on X: after magpie quits,
the harness it was connected to can't go on) is Settings › General ›
#restoreQuitRow, the app's only, Off by default: a connected agent keeps magpie as it quits, which is what this page's question names. On (settings.RestoreOnQuit,restoreOnQuit),OnShutdownrunsagent.RestoreOnQuitover the agents with magpie in their config (restoreAgentsOnQuit), only when this process serves the gateway: each agent's ownDisconnect, so its files come back as they were before magpie,*.before-magpiebyte for byte. Unlike the Disconnect button it leaves no.disconnectedmark, and it records the ids it put back in the stash (quit.restored). The next start (rewireAgentsOnStart, unless the gateway is paused) connects exactly those again (agent.RewireOnStart, once: the record is taken out first), skipping one the user disconnected meanwhile (the mark) or connected by hand. An agent the user disconnected before the quit is neither touched nor connected again.quitAtOncequits without asking while it is on, as nothing is left to cut off.TestRestoreOnQuitAndRewireOnStart,TestRestoreOnQuitLeavesUserDisconnected,TestRestoreAgentsOnQuit,TestRestoreOnQuitKeptUnlessSentandrestore-on-quit.test.cjs. - Not asked: a restart to update, Uninstall, a browser's page (
magpie web), logging out or shutting down, and the Dock's Quit (AppKit'sterminate:).
See TestWindowQuitAsksFirst, TestQuitListsWiredAgents,
TestQuitAPIListsAgents, TestQuitNow, TestCommandQAsksFirst,
TestQuitDontAskAgain, TestSetQuitNoAsk, TestQuitNoAskKeptUnlessSent,
quit-ask.test.cjs and quit-ask-setting.test.cjs.
Pausing the gateway
Disconnect and quit was the only way to stop the gateway, and it quits
magpie too (me2seeks on X). Pause does the same without the quit: the
tray's Pause Gateway (Resume Gateway while paused), Settings › General ›
Gateway (#gatewayPauseRow, On/Paused, the app's only) and the Gateway
page's Resume gateway, all through POST /api/gateway/pause {"on": bool}
(gatewaypause.go).
pauseGatewaydisconnects each wired agent as its row's Disconnect does (its own settings put back), writes the ids togateway-paused.jsonin the config folder, then stops the gateway this process serves (stopServedLocked, requests in flight drained). An agent that can't be disconnected keeps the gateway serving, those before it connected again, and is named in the status line.- While the file is there
serveGatewayLockedserves nothing, so neither the 15 s watch, a port change nor a handover starts it; a magpie started again stays paused. A file that can't be read or parsed counts as a pause (a failed read is unknown). The file is this computer's alone: backup and sync don't carry it. Only the app pauses (pausable);magpie webandmagpie servenever read it. resumeGatewayremoves the file and serves again (startHere). A port held by something else keeps the pause and says what holds it (gatewayFixSays). Then each agent named in the file that is still there and not connected is connected again.- The Gateway page's Start or Restart (
orResume, outsidegatewayMu) resumes, and so does connecting an agent or picking one of magpie's models for it (resumeOnWire): it would otherwise point at nothing. An agent wired from the CLI while the app is paused does not resume it.
See TestGatewayPauseAndResume, TestGatewayPauseRollsBack,
TestGatewayResumesOnWire, TestGatewayPauseFileUnreadable,
TestTrayMenuLabels and gateway-pause.test.cjs.
The Update pill and its 3-day ×
The header's Update pill (window and tray panel alike) lights as soon as a
newer version is downloaded and waiting (ready), found with downloads off
(found) or out where magpie can't download it (available), unless
/api/update says quiet. A release comes every few minutes, so the ×
(or a right-click) that hid the pill only until the next version had it
back within minutes (certhon520, jkd6688, Yuyuaneth and milianxinqi on X,
11-12): it now also hushes it for update.Quiet (3 days, the Stable
channel's soak) across the releases out meanwhile (quietAgain,
update.QuietAgain), kept across restarts in update-behind.json
(update.Behind.Hushed, for the version running, so an update starts
afresh). Settings › Update button says "Hidden for 3 days" while it holds,
with Show again (unhush, update.Unhush, an empty update-skip).
Nothing else holds the pill. From 0.1.3879 to 0.1.4181 a quiet was also
counted from the first newer version seen; with a release every few
minutes it started over on each update, so a downloaded update waited
with no pill for days (visamzh and normalcoder_ on X, 11-14). Those
versions' notes keep that time as since, which is never read as a
dismissal. An urgent release (a line starting "Urgent release:" in the
latest's notes, or in any release between this one and it,
urgentBetween) lights the pill through a dismissal. Settings › Version,
the tray's Restart to update, quitting and Restart automatically work at
any time. Plugin updates have their own dot on Plugins, which lights only
for a plugin that does not update by itself. See
TestPillLightsWhenANewerVersionIsOut, TestUrgentLightsThePillAtOnce,
TestDismissalHoldsForTheQuiet, TestUpdateQuietUntilBehindAWhile,
update-quiet.test.cjs and update-hide.test.cjs.
When an update downloads
With downloads automatic (NoAutoDownload off, the default), a version
magpie finds is downloaded at once, in the background, by whichever check
found it: the clock's (checkByClock, 5 s after start, then every
UpdateEvery), Check now, the Version row's refresh of a stale "latest"
(refreshLatest), or a page asking in another language (relang sees a
newer version and starts the clock's check). A newer version found while
one is downloaded and waiting replaces it. Only these leave the waiting
copy as it is: the update dialog's check (keep, freshen), which names
it; the clock's check while a restart waits for the gateway to go idle
(waiting); and downloads on a click.
Every restart asks the feed first (recheck, restarting): the page's
Restart to update, the tray's, and the restart Settings' AutoRestart or a
click waits for. A newer version out is downloaded in place of the waiting
copy and the restart goes into it once it is in; the clock's check runs
every half hour or more, and magpie releases many times a day, so the
waiting copy was often behind, and the new version's first check had the
user update again at once (char1es_lu on X, 11-16). The feed isn't asked
when the waiting copy is one a restart's own check downloaded or found to
be the newest (restartGot): the header's Update restarts once a click's
download is in, and asking there again downloaded again and never
restarted (elis_pina on X). Nor is it asked with downloads on a click
(keepsStaged): the copy clicked for is what goes in (sakamotokurome on
X). From 0.1.4051 to this change a restart never asked with a copy
waiting (canlee886 on X); the cost now is that a click may wait for a
download. The header's Update and the tray restart by themselves once it
is in; Settings' Version card shows the download, and a second click on
its Restart to update goes into it without asking again (app.js has no
room left in its budget for the card to follow by itself). See
TestRestartTakesTheNewestOut, TestUpdateStagedGivesWayToNewer,
TestRestartAfterItsDownloadDoesNotAskAgain and
TestRestartPutsInTheClickedDownload.
One download runs at a time (begin refuses a check while one is under
way). A check that comes meanwhile sets again (supersede), and once
the download is in the feed is asked again; a newer version then takes
its place. The minute loop also fetches what was left behind
(fetchDue): a found version once downloads are automatic again, and a
failed download (error with retry) after retryAfter (30 minutes),
not at the next UpdateEvery. See TestUpdateClockFetchesNewerThanWaiting,
TestUpdateCheckDuringDownloadTakesNewer,
TestUpdateWaitingRestartKeepsItsDownload and TestUpdateFetchDue.
A restart to update hands the gateway over
On a Mac and on Linux, a restart into a downloaded update (the Update pill, Settings › Version, the tray's Restart to update, Restart automatically) starts the new version beside the running one and hands it the gateway's listening socket, rather than ending the gateway and waiting for the new one to listen again (xuanwo on X). Nothing an agent sends meanwhile is refused: the port never closes, and requests already in flight finish in the old process.
The trigger is handsOver in
handover.go: the app (Run sets
handoverHost and startExe), on darwin or linux, serving the gateway
itself, not a dev backend (whose own handover is gateway.Handover,
below) and no MAGPIE_NO_HANDOVER in the environment. restartInto in update.go
then calls beginHandover instead of the relaunch-after-exit. The steps:
- The old magpie opens an Offer (
internal/handoff): a unix socket in a 0700 temporary folder (in/tmpwhenTMPDIR's path leaves a socket's name no room,sockDir), named byhandover.jsonin the config folder with its pid, its program path and the time. Then it starts the new version beside itself:open -non the bundle on a Mac (update.OpenBeside), the binary at the path it started from on Linux (update.StartBeside;startExe, since/proc/self/exereads "(deleted)" once the update replaced it). - The new magpie's
RuncallstakeOverbefore anything else: a pointer fresh (2 minutes), of a process still running, for the same program and not its own is dialled, the new one says hello, and receives the listening socket (SCM_RIGHTS) with the address, the bridge's callback socket and the old pid (handoff.Take). The peer's uid is checked on accept.gateway.Inheritkeeps the socket for the nextListenAndServeon the same address (sameAddr; another address lets it go), which serves on it and then acks. - The old one, on the ack (
AwaitAck), withdraws the pointer, hides itself where it can (below), callsgateway.Server.HandOff, ends its backend and waits for its requests, then quits.HandOffcloses the old one's own copy of the socket at once, so every connection from then on waits there for the new one: one the old one took as its end began was closed unanswered (#3568). A handed-off server's shutdown waits up tohandedOffDrain(15 minutes) for requests in flight, not the 2s an ordinary quit gives them (shortDrain), and first lets each connection it took send its first request (unreadWait, 5s at most), sincehttp.Server.Shutdowncloses one whose request it reads after it began. ItsOnShutdownthen skips what goes with the gateway, which the new one now does: ending Codex's failover, porting Codex rollouts and installing the update. - Should the Offer not open, the new version not start, not say hello in
60s (
helloWait), not ack in 90s (ackWait), or drop the connection, the old one keeps the socket, takes its instance lock back and restarts as before: the new one opened once it has exited (fail,update.RelaunchorrelaunchBinary). It first waits, still serving, for its requests in flight to finish (at mostfallbackWait, 15 minutes), since the restart was let go without waiting for them. A second restart click while a handover is under way does nothing (pending).
Once handed over, the old one does nothing beside the new one but finish
its requests (#4938): its loops end with its backend (backendCtx):
the linked instruction sets' sync (library.KeepLinked), quota alerts
(provider.WatchQuotas), the menu bar's usage and the update check and
automatic restart (updates.start); its hidden pages are let go as in
lightweight mode (lighten, so their polls stop); and it exits by the end
of its drain and quitGrace (3 minutes) after, whatever holds its quit up
(quitBy, TestHandedOverQuitsByItsDeadline). Before, a copy an update
left lived on hidden for three hours, writing and fetching beside the new
one.
On Windows there is no handover: the new version is started with
MAGPIE_REPLACES (relaunchBinary) and waits in update.AwaitPredecessor
(awaitGone in
predecessor_windows.go)
for the old magpie, up to 60s, and then for its msedgewebview2 processes,
before it opens the gateway's port and the WebView2 profile. The old one
ends through endProcess (exit_windows.go),
TerminateProcess on itself rather than os.Exit's ExitProcess, whose
DLL detaches (WebView2's, COM's) can wait forever on a thread it already
ended, leaving a process with one thread on port 3425 and the profile and
the new window "Not Responding" (BESTLJP0412 on X). A predecessor that
still sits with one thread for a second (an older version, stuck so) is
ended by the new one (awaitExit). See TestEndProcessSkipsAStuckDetach
and TestAwaitGoneEndsAMagpieStuckInItsExit (Windows). One cause of that
one thread was magpie's own: the no-activate hook, left on while
ExitProcess ran, was called from its FLS cleanup and wedged the exit
(#6705). It is taken off as the app shuts down (unhookNoActivate).
endProcess and awaitExit stay: for the other detaches, for an
os.Exit while the app still runs (Wails' on a fatal error), and for
versions before the fix.
Two magpies never show at once. On a Mac the old one lets go of its
instance lock before it gives the socket (releaseInstance), so the new
one's runningAlready takes it, and once the ack comes the old one hides
its menu bar icon, panel and window and leaves the Dock (onHandedOver,
leaveMenuBar). AppKit keeps a status item's setVisible:NO in the
app's defaults by its autosave name (NSStatusItem VisibleCC Item-0 on
macOS 26), which the new one's item and every later one start from, so
the hide is forgotten once it is made (forgetTrayHiddenLater,
trayshown_darwin.go). From
v0.1.1354 to v0.1.1367 it wasn't, and the icon stayed gone after the
update, through a quit and reopen too (Mitsuha, audie). bringTrayBack
forgets a kept hide once per computer before the tray is made, and a
magpie handed over to by an older one forgets it again once that one has
quit (awaitExit), unless a hide was kept when it started: one kept after
the bring-back is the user's (TestHandoverLeavesTheMenuBarIconForTheNextMagpie).
On Linux the D-Bus name Wails holds can't be let go, so the new one serves
the gateway at once but waits for the old pid to end (awaitExit, at most
handedOffWait, 16 minutes) before it makes its app and tray; the old one
keeps its tray icon until it has drained.
What the old process alone has:
- Sticky routing (which account each conversation stuck to) is flushed to
disk before the socket is given (
gateway.FlushSticks). - Claude Code runs the subscription bridge started send their tool calls
to the gateway's port, which the new one now serves. The old one serves
them on a unix socket in the Offer's folder (
ServeCallbacks), and the new one forwards a claude-mcp token it doesn't know there (ForwardCallbacks,forwardCallback;ownCallbacklets them in while forwarding is on). See Claude subscription bridge. - Bridge turns can't move to another process, so a restart that hands
over waits only for them (
restartBusy,blocking:Busy.Bridgeas Requests,Tools,BridgeLastas Last). The page is told (updateJSON.Handover) and says it waits for the Claude subscription's replies, with other requests carrying on across the restart. - Refreshes of rotating OAuth tokens hold a file lock across both processes (see Providers and accounts).
Not carried over, accepted: each process counts its own requests per minute and concurrency, so for the drain a provider's limits can be exceeded by what the old one still has in flight; a bridge run idle between turns ends with the old process, and the next turn starts a new run as after any restart; the new one's start-up migrations run while the old one still serves its last requests.
Windows has no SCM_RIGHTS for a listening socket in this form, and
magpie web re-executes itself in place; both restart as before, waiting
for the gateway to be idle (#577). make dev keeps its own handover, a
new backend listening beside the old one (gateway.Handover, devBackend).
magpie update in a terminal restarts the app the same way
(gaubeebangeel on X: an agent the gateway serves ran the update at 4am,
and the app ran on as the old version until it was quit and reopened,
which cut the agent off). Once it has put the new version in
(updateCmd in update_cli.go),
restartRunning posts the version to gateway.RestartPath
(/v1/magpie/restart, restart.go),
answered only to a program on this computer over loopback, never to a
page or another Host (restartRefused, the heap profile's rule). The
updater's restartBeside (update_beside.go)
restarts only when it was the copy replaced (replaced, which now also
compares a Mac's .app binary, bundleExe), takes the version as
ready without asking the feed, and runs Settings' AutoRestart restart
(autoRestart): at once when the restart cuts nothing short, else
through waitIdle. It answers restarting, waiting (with Busy),
current (another copy) or unsupported (magpie serve, which has no
restarter and is restarted the way it was started), and the command says
which. A magpie older than this answers 404, and the command says to
quit and reopen it, so the first update into this version still needs
that. On Windows, with no handover, the restart waits for an idle
gateway as above, so nothing in flight is cut but the port is closed
while the new version starts (#4521). See TestUpdateInATerminalRestartsTheAppWithoutCuttingIt in
update_beside_unix_test.go,
TestRestartAskedOnlyFromThisComputer in
restart_test.go and
TestUpdateAsksTheRunningMagpieToRestart.
A restart magpie makes by itself (Settings' Restart automatically,
magpie update from a terminal, a Remote magpie's ask, another copy
replacing this one's binary; restartBySelf in
update.go) comes back in the tray
alone, with no window, on every system, and takes no focus
(quiet_restart.go). It used to
bring the window back when it was up (#2096), minimised if it was
(#3495), and eating_dream on X, with checks every half hour, had it put
back over their work after every update. A restart the user clicked
opens the window as it was. An older version restarting into this one
still asks for its window as it was, and its mark (<seconds> minimised) is still read. See TestRestartBySelfComesBackToTheTray.
A restart magpie makes by itself also waits while the user is using one of
magpie's own windows (BESTLJP0412 on X: the window closed and came back
in the middle of adding a provider, the gateway idle). Every page (the
window, the tray panel, a browser on magpie web) posts
/api/update/using on a press, a key, typing or the wheel, at most
every 20 s and at once when the dialog (#modal) opens or closes, with
whether it is open (app.js, beside renderUpdateBadge). inUseAt in
update_wait.go counts the user
as using magpie for usingFor (2 minutes) after that input, or
openFor (15 minutes) while a dialog was open, which may hold a form
half filled in; waitFor waits through it when the wait wasn't asked
for (waitAsked), and restartBeside doesn't restart at once. The
post writes nothing, so held keeps what it holds. The wait says so
(using in /api/update; Settings › Version and the Update pill add
"waiting while you use magpie"). A restart the user asked for (the pill,
Settings › Version, the tray) never waits for it. A window left open
and unused for longer is not in use, so the restart still comes. See
TestAutoRestartWaitsWhileTheWindowIsUsed,
TestTerminalUpdateWaitsWhileTheWindowIsUsed and update-using.test.cjs.
The app and magpie web open together each have an updater of their own
over the same program, and the gateway's ask reaches only the one serving
the gateway (visamzh on X: one restarted to update, and the other ran on
as the old version, its Update pill still offering the version already
in). So every updater also looks at its binary every 5 s
(followReplaced in update_beside.go,
replacedTick) and, once another magpie replaced it, restarts into it
through restartBeside once, whatever Settings' automatic restart says:
an old version left running is what the user asked to leave behind. A
gateway busy has it wait as above (waitFor restarts into what is on
disk without asking the feed again), a process restarting into its own
install (installed) or already following one (followed) doesn't, and
a build that isn't a release (update.Released; make dev, go build)
is never followed. A browser's page (magpie web, the app's page) learns
the version that served it from boot.js (bootPrefs.version) and reloads
when /api/update's current names another (servedAnew in app.js), on
the reads it already makes (load, focus, coming back into view) and once a
minute while it is shown; the app's own windows come back with their new
process. See TestAnotherMagpiesUpdateRestartsThisOne,
TestOwnUpdateIsNotFollowedAgain, TestOwnBuildRebuiltIsNotFollowed,
TestAnotherMagpiesUpdateWaitsForTheGatewayThenRestarts,
TestUpdateClickedOverAnothersIsNotFollowedAgain and
TestBootNamesTheVersionThatServedThePage in
update_follow_test.go, and
update-served-anew.test.cjs.
A Remote magpie follows this one's version too (nnlrl_75403 on Discord).
provider.KeepRemotesUpdated (started with the updater, and by magpie serve) runs UpdateRemotes 30 s after start and hourly: a released
build with automatic updates on asks each Remote magpie on an older
release (GET /v1) through POST /v1/magpie/update with the provider's
key, once in six hours for a version, and keeps the answer
(RemoteUpdateOf). On the other side updater.updateAsked
(update_remote.go) downloads
(download) and restarts once idle (waitIdle), or answers why not:
nothing newer, automatic updates or downloads off there (the user's
setting stands), or a copy it can't replace (stuck: container,
package with its command, a folder it can't write, a build from
source). magpie serve's serveUpdateAsked
(serve_update.go) puts the
latest in where it runs from, one at a time and never elevated, and
serveFollow restarts into it. The provider's row on the Providers
page appends remoteUpdate (remoteUpdateNote: an English say and
tip the page translates) to its line: "updating to v…" for 30
minutes, or why it can't, with the command over it. See
TestUpdateAskedByAnotherMagpie, TestRemoteUpdateNote,
TestServeUpdateAsked, TestRemoteMagpieAskedToFollow and
remote-update.test.cjs.
See TestRestartHandsTheGatewayOver (the new version a second process,
a stream across the restart finishing whole, requests during it answered,
and the old one quitting only after its stream) and
TestHandoverNotMadeRestartsAsBeforeOnceIdle in
handover_unix_test.go,
TestRestartWaitsForWhatAHandoverCantCarry in
handover_test.go, the gateway's
handover_test.go, the
socket passing in handoff_test.go,
and update-wait.test.cjs.
Where Windows installs magpie
There is no installer: the Windows exe opened from Downloads, the Desktop
or a temp folder installs itself (update.Settle, called from gui.Run).
So does one still named as the site's download (magpie-windows-amd64.exe,
… (1).exe; downloadName) anywhere else, as a browser saving to
D:\下载 or a download moved into a folder and updated in place there
leaves it, but only through the dialog below, never unasked: run there,
deleting the download deleted magpie, and every copy opened was an app of
its own to Windows (@XBJNTMs2mDbsvPH on X). Cancel on such a copy is kept
(HKCU\Software\magpie NotInstalled, the exe's path): it runs where it
is from then on, is not asked about again and never opens the installed
one in its place. A copy renamed (D:\Tools\magpie.exe) is left alone.
The first time, with nothing installed, it asks where in Windows' task
dialog (installDialog in
installdir_windows.go): the
folder, Install, Change… and Cancel, in the tray's language, with a footer
naming the exe it was opened from, which can be deleted once installed:
the install copies it and never deletes it (@jiangshangmuyun on X: "the
original is still there"). Change… opens
the folder picker, and a folder picked gets magpie added unless it is
named that already (update.InstallDir). The default is
%LOCALAPPDATA%\Programs\magpie; another folder is recorded at
HKCU\Software\magpie InstallLocation, so the next exe downloaded
replaces the copy there without asking (feng_21795_78266 on Discord).
A folder only an administrator can write to (Program Files, Windows) or
one downloads land in is refused in the dialog (update.Installable), not
elevated: magpie is installed for the user alone (HKCU's Run, the user's
PATH) and updates itself without elevation, so an admin folder would
stop its updates. Cancel runs the exe where it is. The shortcut, App
Paths, autostart, the magpie:// scheme, PATH and self-update all take
the running exe's folder, so they follow the choice. Uninstall forgets
the record (update.ForgetInstallDir) and leaves the program where it
is, as before. The question comes before anything starts, the gateway
included, since Install opens the installed copy in this one's place; so
a start no one can answer is never asked (unanswerable): CI set (any
CI service's), or a window station no one sees (a service, SSH). Such a
copy kept outside Downloads runs where it is, nothing recorded; one in
Downloads installs to the default as with no dialog. v0.1.4160 to
v0.1.4166's release check waited on the dialog with no gateway
(TestNoInstallQuestionOnCI). See TestSettleAsksAboutADownloadKeptElsewhere,
TestSettleDeclinedElsewhereIsKept, TestDeclinedRecord,
TestSettleInstallsWhereTheUserChose,
TestSettleOffersTheChosenFolderAgain, TestInstallableRefuses in
install_test.go,
TestInstallWordsEveryLanguage and TestInstallDialogSaysTheDownloadCanGo.
Verification
The session readers include Cursor CLI chat stores, Cursor editor project
transcripts and older editor cursorDiskKV conversations. CLI stores win
when the same session ID has a project transcript. Editor conversations are
read only and cannot be resumed by cursor-agent. A chat the editor still keeps
in state.vscdb (its composerData:<id>) is never deleted, the delete API
included: Cursor's own delete clears several keys of a database it holds open,
and its in-memory copy, which magpie can't do from outside. A project
transcript whose chat the editor no longer keeps (fileMore.loose: the store
was read and has no such chat, or there is no store) is files of its own and
is deleted as a CLI chat's are: <id>/, <id>.jsonl and <id>.txt in its
agent-transcripts folder (cursorEditorPaths), never the folder. A store
that can't be read says nothing, so no transcript is loose then. Each row of
an agent magpie deletes from has its delete; one it can't delete carries
undeletable (cursor-editor, read-only; rowDeletable), and the row's
delete is shown off with that reason as its tooltip, never left out (ysm119 on
Discord). A row without Resume, its terminal, Continue in, and a folder without
its ⋯, keep hidden room for them (lanes, slot in plugins/sessions/client.js),
so the right-hand columns line up on every row (TestCursorRowsSayWhetherTheyCanBeDeleted
in cursor_editor_delete_test.go, sessions-cursor-align.test.cjs).
Project transcripts contain no message timestamps or billing data; their
existing file modification time supplies the activity date, and tokens and
cost are not inferred. Database bubbles retain their own timestamps.
The editor database is opened as one read-only snapshot per listing, shared
by its chats and removed when the listing ends. Metadata changes invalidate
the cached summary even if the project transcript has not changed. See
cursor_editor.go,
TestCursorEditorTranscript and TestCursorEditorLiveDatabaseAndMetadataRefresh
in cursor_editor_test.go.
Messages without tokens or an active-time estimate still count as sessions
in the overview. Cursor and OpenCode conversations can be opened through
the existing transcript API, including CLI reasoning and tool calls. So can
Kimi Code's main agent, from its wire.jsonl: a turn's turn.prompt and
loop events from protocol 1.4 on (so a turn still running shows), and the
untimed context.append_message records of a session imported from
kimi-cli; Kimi Code's own timed messages repeat those and are skipped
(transcript_kimi.go,
TestKimiCodeTranscript). Each reply in the conversation names its model
(#2253), muted after its first part and again where it changes inside a
reply: a part's model is what its own line in the agent's file names,
Claude Code's message.model (the model that answered; none for its own
<synthetic> lines), Codex's turn_context.model (the model the turn was
sent to), Pi's and omp's message.model, OpenCode's modelID or OpenCode
2's model.id. Kimi Code (whose model is only on a usage.record after
the reply), Cursor and a gateway transcript (which records the model asked
for, not the one that answered) name none, and nothing is guessed in their
place. The Usage page's per-request content doesn't repeat it. See
TestTranscriptModel* and sessions-talk-model.test.cjs. When the
selected date range is empty but
matching history exists, Usage offers All sessions, preserving the agent,
model, folder and search filters. See sessions-empty-range.test.cjs.
go test -tags nogui ./internal/gui
go test -run TestMainWindow ./internal/gui
GOARCH=amd64 CGO_ENABLED=1 go test -run TestMainWindow ./internal/gui # as for an Intel Mac
go test -run TestWebView2 ./internal/gui # on Windows: Wails' runtime lookup, missing and present
go test -v ./internal/fonts # native discovery on each desktop OS
make test-ui # every internal/gui/tests/*.test.cjs, Chromium and WebKit
BROWSER=webkit node --test internal/gui/tests/click-scroll.test.cjs
make test-ui needs Node.js and Playwright (playwright install chromium webkit). Set NODE_PATH when Playwright is installed outside the repo. The
Test workflow in CI does not run this suite, so a GUI change must run it
locally and report the result. See tests/README.md.
TestMainWindowCorners and TestMainWindowRightToLeft run on a Mac with a
desktop session, as CI's macOS job has, and show a few windows for some
seconds. On macOS 26 they check both designs, whatever SDK the toolchain
links against. CI builds them for arm64. Built for amd64 (under Rosetta on
Apple silicon), they check a program that names its SDK in
LC_VERSION_MIN_MACOSX, as go test links one for an Intel Mac. Their
presses are sent within the test's own process, and no system setting
changes.
Agent visibility management
The Agents page's Manage button sits inside the list's footer beside the fold
control, and stays available when nothing is folded. The tray panel keeps its
existing fold control. The Manage agents dialog includes folded and hidden agents.
Search matches names and IDs; select all and invert apply to the search results,
while Select unconnected agents replaces the selection with matching agents not
on magpie (neither wired, added nor drifting). Selection survives search changes.
Hide selected and Unhide selected each save one arrangement through the existing
POST /api/agents/arrange, preserving order and agents outside the operation.
Only a successful save changes the list; a failure keeps the selection for retry.
While saving, Done, Escape and the backdrop cannot close the manager and expose
conflicting row actions. Closing is restored on either success or failure.
A completed save invalidates older in-flight state reads for the arrangement
fields only. Fresh reads still accept other windows' visibility changes; bulk
unhide does not add a lasting client-side override. These races are covered by
agent-visibility-saving.test.cjs.
While the manager is open, state refreshes update its visibility labels and
action availability in place, preserving the search, selection and keyboard focus.
These operations never connect, disconnect or edit an agent's files. Unhiding
still follows the existing Not set up folding rules. The dialog explains that
restoring visibility does not pin an unconfigured agent into the main list.
See agent-bulk-visibility.test.cjs for persistence, partial selection, failed
saves, narrow layouts and all five languages in Chromium and WebKit.
- The Gateway page's card opens DeepSeek's chat page (Chat page,
gw-chatinplugins/gateway/client.js) at the gateway's address, orMAGPIE_PUBLIC_URL's on a page other machines open, through/api/open, while the gateway runs and isn't paused. It sits with Restart gateway in one.gw-acts, so a narrow card wraps the two together. See gateway routing andgateway-chat-page.test.cjs. - A gateway port another program holds names that program (pluoki on X).
gateway.NoteHeldreads the holder withproc.PortHolder(lsof on the Mac, /proc on Linux, Get-NetTCPConnection on Windows) and, when the daemon is root's and unreadable, falls back totailscale serve status --jsonfor the port. Tailscale's line carriestailscale serve --https=<other> http://127.0.0.1:<port>. The sentence (PortHeld.Sentence) goes to themagpie servestandby line and bind error, the app's log,gatewayHeldin/api/state(Gateway page) and Start'stakenanswer. A holder that can't be read says nothing, and the old wording stands. Nothing is killed or touched. SeeTestWhoHolds,TestListenErrorNamesTheHolder,TestPortHolderNamesTheProgramandgateway-port-holder.test.cjs.