A plugin's page kept its frame, with its scripts, timers and
connections, for as long as the window was open once it had been
looked at: show() only hid its view, and a frame in a hidden view isn't
hidden to itself (its visibilityState doesn't change), so a page
couldn't even pause on its own. Asked by the owner: is that by design?
Only the lazy first load was.
- The kernel's leave hook now reaches the page part: the page is told
{event: "visibility", data: {visible}} as the reader leaves and comes
back. The bridge has magpie.visible and magpie.onVisibility(fn); hello
carries visible, for a page left before it said hello.
- A page left 10 minutes (IDLE_MS) has its frame removed and loads again
when next opened. Back sooner, it is the same frame. Its hello timer is
cleared, so nothing says it broke.
- magpie.page.keepAlive: true (plugin.PageSpec.KeepAlive, keepAlive in
/api/plugin-pages) keeps a page however long, for one that works while
no one looks at it. Anything but true is false, read as raw JSON so a
wrong type never drops the package's page.
- plugin-runtime.md's page row says so.
Run on mote. The Go suite and most GUI files ran at this change on
557f51dbf. After rebasing onto 30cd39f19 (none of these files changed
upstream), the budgets, TestWindow* and the page GUI files ran again
at this tree:
- plugin-page-idle (new), plugin-page and plugin-panels, chromium and
webkit: 14/14 at 557f51dbf. At the rebased tree, the first run was
13/14: plugin-page's chromium "draws in its frame, shut in" was red
once, and its assertion wasn't kept (#4589). After that: 42/42 over
3 runs, then 16/16 chromium over 4.
- i18n-keys, plugin-actions, plugin-kinds-discover, plugin-kernel,
plugin-replaced, plugin-proxy-page: 51/52. The red is i18n-keys'
"Unmarked", the same on origin/main e0eb74987 (#4524).
- go test -timeout 45m ./...: every package ok except three reds, none in
code touched here:
- TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
TestMainWindowCorners (#3949) fail the same on origin/main e0eb74987.
- TestUnroutedHeldReportSaved (#4300) failed in the full run only.
Alone, -count=5, it passes.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./..., go build ./..., gofmt -l: clean.
Broken by hand: with the leave hook taken out of the page part, the new
test is red in both engines.
Not tried: a real plugin page in the desktop app or WebKitGTK. The
IDLE_MS length (10 minutes) is a judgement, not measured.
package.json's magpie.actions: [{id, menu, title, titles}] puts items in
the row menus magpie draws, after its own: a provider row's (right-click)
and an agent row's (its handle, or right-click). Picking one opens the
plugin's page and posts it {event: "action", data: {id, provider|agent:
{id, name}}}, nothing else of the row; the bridge's magpie.onAction(fn)
gets it, and an action picked before fn was given waits for it.
- plugin.Window reads them (page.go): menu one of ActionMenus (provider,
agent; a session's menu is left out, its title is user content), id
^[a-z0-9][a-z0-9-]{0,39}$, an id given twice is the first's, 8 at most,
none for a plugin with no page.
- /api/plugin-pages carries them on the page; a missing title is the
page's, in each language (pluginpage.go).
- pluginpages.js: magpie.actions(menu, context) gives the row menu's
items; openRowMenu draws a plugin's name as written (literal), not
through t().
- The Plugins page says which menus a plugin adds to (actionsLine),
translated in zh, zh-TW, ja and de.
- Docs: plugin-runtime.md's P6 section and verification; the site's
plugin docs (en, zh, ja) gain "Items in magpie's menus".
- The core's budget (TestCoreScriptBudget) is not raised (#2710): with
P6 the core came to 1,447,648 bytes, 648 over. pluginpages.js's header
now says P5's and P6's part in one paragraph and points to
plugin-runtime.md, which says it in full, and plugins.js's panels and
actions lines share whereLine: 1,446,845, 155 under.
Run:
- Full: this series (P5, the Plugins dot, the probe test, P6, and a
built-ins-on commit since dropped for main's own 5a2414acd) was run
together, at load 200-660.
At the pushed tree, 88dfab2d3 on origin/main 5380114da (rebased
from 210bc2b77, no conflicts; its GUI assets and tests are the same
bytes as the tree the GUI runs below used, diff -rq): gofmt clean,
vet darwin/linux nogui/windows ok, TestCoreScriptBudget ok
(1,446,845 of 1,447,000). go test -timeout 45m ./... at load
193-278: 62 packages ok, red in TestMainWindowCorners (#1936) and
TestPluginStreamLargeReplies JSON_fast (client timeout; alone 1 of
3 red here, 0 of 3 on 5380114da side by side at load ~280; the
series doesn't touch the stream path; #2551 reopened with the
output, taken). Two earlier runs at this tree are discarded: one
stopped when the disk filled, one when another session's go clean
-cache emptied the build cache mid-run. The whole GUI suite at
this tree was not finished (the disk filled); the files the series
reaches ran (1318 tests, 124 red), and the 39 red files ran again
at concurrency 1 on both trees: here 148 ok 120 red, origin/main
135 ok 127 red. Both sides' reds are page.goto/launch timeouts
under load (66 here, 71 there) and the same assertions:
title-bar-tools' and settings-proxy-auth's "access control checks"
on a cut-off /api/providers read (#2740, taken next), sidebar's
"the list unrolls" and WebKit "#prefs pressed darkens" (#2684;
alone, 1 red here, 3 on main), side-toggle (#2732); plugin-move
red on main only. Six files again one by one on both trees:
plugin-actions red 1 of 6 here, a 5s goto of ?view=plugins at load
260; plugin-clash red on both; plugin-own-icon, plugin-gateway,
plugin-checkin ok on both; settings-proxy-auth ok here, 3 red on
main.
At 976c9893a (on origin/main 6f950653f): go test -timeout 45m ./...
red only in TestMainWindowCorners (#1936, the window's process
killed at its deadline) and TestSetAnswersWhileDevinAndProvidersHang
(#1375, 3 of 3 alone). The whole GUI suite, both engines: 10834
tests, 237 red in 73 files, 184 of them a 180s browser launch. Those
73 files run again at concurrency 2: 52 green, among them every
plugin-* and agent-* file and plugin-actions; the 21 still red were
run at origin/main f191d6423 and are red there too: codex-predictions
(#2624), lightweight (#2638), segs-glide (#2683), usage-agents-hide
(#2276), provider-advanced-fold (#2552), routing-bodies (#2559),
routing-model-rest and rest-try-now (#2115, #2564), routing-keys-fold
(#1612), routing-wb-restricted (#1905), routing-request-metrics
(#2571), quota-count-wrap and quota-name-translated (#2228), s3-sync
(#2448), usage-checkin (#2549), usage-ledger-abort (#2700),
tencent-access-key (#2733), usage-range (#2734); side-toggle's WebKit
motion red 1 of 3 on main, 0 of 3 here (#2732); usage-fold green alone.
Rebased onto origin/main 717b69f78 (60725faa1, no conflicts): gofmt
clean, vet darwin/linux nogui/windows ok; go test -timeout 45m ./...
red in TestSetAnswersWhileDevinAndProvidersHang (#1375) and agent and
gateway at the 45m alarm with tests still moving at load 400+, both ok
alone (1173s, 1167s); 105 GUI files the series reaches (plugin*,
sidebar*, side-*, settings*, title*, header*, agent-*): 1322 tests,
23 red, run alone 214 of 218 ok, the 4 left in sidebar and
sidebar-overlay-scrollbar (WebKit), red on 717b69f78 too (#2684,
#1863). The whole GUI suite was not run again after the rebase.
- gofmt -l clean; go vet darwin, linux (-tags nogui) and windows ok;
TestCoreScriptBudget ok.
- go test -run 'TestWindowActions|TestPluginPageActions' ok: duplicate,
malformed and session-menu ids dropped, 12 actions kept to 8, none
without a page, an off plugin's not served.
- plugin-actions.test.cjs: chromium and webkit, en zh zh-TW ja de, at
1100 and 420: no page adds nothing; the agent menu ends with Hide then
the plugin's item; the provider menu's item is in the window's
language; a pick opens the page, which gets exactly {id, provider|
agent: {id, name}} once, in one frame, though it calls onAction 400ms
late. The Plugins row says which menus.
- Broken by hand, each red then restored: the bridge not holding an
action picked before onAction (the late-registering fixture), the
provider's whole row posted in place of {id, name} (the exact-data
check), any id and any menu accepted (TestWindowActions).
- Neighbours in both engines: plugin-page, agent-cli-missing,
agent-disconnect, group-bulk-remove, model-test-why and provider-find
ok; plugin-panels red before P5's fixture fix (padding, in that
commit), ok after.
- Real use: a dev build (-tags dev) in a sandbox HOME with a
local plugin of two actions; WebKit on its dev UI picked "Inspect
agent" on Claude Code and "Inspect provider" on a local provider, and
the page logged {"id":"about-agent","agent":{"id":"claude","name":
"Claude Code"}} then {"id":"about-provider","provider":{"id":
"local-try","name":"Local Try"}}, one frame. Not clicked in the
WKWebView window itself; the frame's loading there is
TestPluginPageLoadsItsFilesInTheWindow's.
P5 of the plugin runtime (docs/subsystems/plugin-runtime.md):
- Panels (magpie.panels): a plugin draws a frame into a slot of a
built-in page (a provider's editor, Settings, Usage); magpie.context
says where it is, and the frame is as tall as what it draws.
- A page can replace a built-in one (magpie.page.replaces); show() opens
it in that page's place, and the sidebar row goes to it.
- page.titles and a panel's titles name it in the window's language
({"zh": …}); a malformed map is dropped, the title kept
(TestWindowTitles).
- main's #2501 already names wails:// in the policy of a page in the
desktop window (through ownWindow), which is why the usage page drew as
bare HTML from v0.1.1259. TestPluginPageLoadsItsFilesInTheWindow loads
a page through ownWindow in a real WKWebView, which Playwright on http
can't; the subsystem page says how.
- The bridge adds magpie's look for what a page leaves unstyled, every
rule in :where() so any rule of the page's wins, and the theme's
colours as --magpie-* variables.
One commit: the panels, the replacing pages and the titles share hunks
in page.go, pluginpage.go, pluginpages.js and the docs, and couldn't be
split cleanly.
Run:
- Full: this series (P5, the Plugins dot, the probe test, P6, and a
built-ins-on commit since dropped for main's own 5a2414acd) was run
together, at load 200-660.
At the pushed tree, 88dfab2d3 on origin/main 5380114da (rebased
from 210bc2b77, no conflicts; its GUI assets and tests are the same
bytes as the tree the GUI runs below used, diff -rq): gofmt clean,
vet darwin/linux nogui/windows ok, TestCoreScriptBudget ok
(1,446,845 of 1,447,000). go test -timeout 45m ./... at load
193-278: 62 packages ok, red in TestMainWindowCorners (#1936) and
TestPluginStreamLargeReplies JSON_fast (client timeout; alone 1 of
3 red here, 0 of 3 on 5380114da side by side at load ~280; the
series doesn't touch the stream path; #2551 reopened with the
output, taken). Two earlier runs at this tree are discarded: one
stopped when the disk filled, one when another session's go clean
-cache emptied the build cache mid-run. The whole GUI suite at
this tree was not finished (the disk filled); the files the series
reaches ran (1318 tests, 124 red), and the 39 red files ran again
at concurrency 1 on both trees: here 148 ok 120 red, origin/main
135 ok 127 red. Both sides' reds are page.goto/launch timeouts
under load (66 here, 71 there) and the same assertions:
title-bar-tools' and settings-proxy-auth's "access control checks"
on a cut-off /api/providers read (#2740, taken next), sidebar's
"the list unrolls" and WebKit "#prefs pressed darkens" (#2684;
alone, 1 red here, 3 on main), side-toggle (#2732); plugin-move
red on main only. Six files again one by one on both trees:
plugin-actions red 1 of 6 here, a 5s goto of ?view=plugins at load
260; plugin-clash red on both; plugin-own-icon, plugin-gateway,
plugin-checkin ok on both; settings-proxy-auth ok here, 3 red on
main.
At 976c9893a (on origin/main 6f950653f): go test -timeout 45m ./...
red only in TestMainWindowCorners (#1936, the window's process
killed at its deadline) and TestSetAnswersWhileDevinAndProvidersHang
(#1375, 3 of 3 alone). The whole GUI suite, both engines: 10834
tests, 237 red in 73 files, 184 of them a 180s browser launch. Those
73 files run again at concurrency 2: 52 green, among them every
plugin-* and agent-* file and plugin-actions; the 21 still red were
run at origin/main f191d6423 and are red there too: codex-predictions
(#2624), lightweight (#2638), segs-glide (#2683), usage-agents-hide
(#2276), provider-advanced-fold (#2552), routing-bodies (#2559),
routing-model-rest and rest-try-now (#2115, #2564), routing-keys-fold
(#1612), routing-wb-restricted (#1905), routing-request-metrics
(#2571), quota-count-wrap and quota-name-translated (#2228), s3-sync
(#2448), usage-checkin (#2549), usage-ledger-abort (#2700),
tencent-access-key (#2733), usage-range (#2734); side-toggle's WebKit
motion red 1 of 3 on main, 0 of 3 here (#2732); usage-fold green alone.
Rebased onto origin/main 717b69f78 (60725faa1, no conflicts): gofmt
clean, vet darwin/linux nogui/windows ok; go test -timeout 45m ./...
red in TestSetAnswersWhileDevinAndProvidersHang (#1375) and agent and
gateway at the 45m alarm with tests still moving at load 400+, both ok
alone (1173s, 1167s); 105 GUI files the series reaches (plugin*,
sidebar*, side-*, settings*, title*, header*, agent-*): 1322 tests,
23 red, run alone 214 of 218 ok, the 4 left in sidebar and
sidebar-overlay-scrollbar (WebKit), red on 717b69f78 too (#2684,
#1863). The whole GUI suite was not run again after the rebase.
- plugin-panels' tall panel (body{margin:0}) measured 220, not 180,
after the look above gave an unstyled body 20px of padding; the
fixture now sets padding:0 too, as a page that wants none would.
plugin-panels ok in chromium and webkit after.
- gofmt -l clean; go vet darwin, linux (-tags nogui) and windows ok.
- GUI: plugin-page and plugin-panels in chromium and webkit, en zh zh-TW
ja de, wide and narrow, ok.
- Broken by hand, each red then green: titled() in pluginpages.js
(the "draws in its frame" test), the wails:// scheme in pagePolicy
(the WKWebView test, before the rebase onto #2501), titles' parsing
(TestWindowTitles).
- Real use: the published @magpie-community/page-usage 0.1.1 in a
sandbox magpie window, its tiles styled.
A plugin's package.json may declare magpie.page {title, file, icon} and
magpie.permissions.reads. While the plugin is on, its page gets a tab in a
"Plugins" group after the built-in pages, drawn in an iframe sandboxed to
allow-scripts only (an opaque origin: no cookie, no storage, no parent).
Its files come from /_magpie/plugin/<token>/ (HMAC of the spec with a
per-process secret) under a CSP with connect-src 'none' and
frame-ancestors 'self'; a path that leaves the page's folder, a symlink
out, or an off plugin's token is refused. The window's postMessage bridge
answers only that frame (event.source checked) with theme and language,
the plugin's own options.get/set (throttled), and the reads it declared;
any other read is refused in the window and again by the server, and no
read carries a secret. /api refuses Origin: null and frame/iframe
fetch-dest requests (noFramedAPI), so the frame never reaches the GUI's
API even with the cookie. A page that throws or never says hello shows
the kernel's broken-page state with Try again. The Plugins page shows the
page and what it reads before the plugin is turned on.
Docs: gui-shell.md, plugin-runtime.md (P4 section), site docs en/zh/ja
with an example plugin; i18n zh, zh-TW, ja, de; fixture in
internal/gui/testdata/page-plugin.
Run (worktree at base 4df1ba0c6, -p 2, one package at a time):
- go test -count=1 -timeout 45m: internal/gui ok, internal/plugin ok,
internal/pluginrt ok, plugins/... (budget groups middleware otel redact
rotation search) ok.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean.
- Playwright (chromium + webkit, 5 languages, narrow widths): plugin-page 4/4,
plugin-kernel 4/4, builtins 4/4, i18n-keys, gui-de, gui-ja, gui-zh-tw 3/3,
plugin-middleware 24/24, plugin-own-icon 22/22, plugin-options 22/22,
plugin-local 8/8, plugin-agent 22/22, click-scroll 22/22.
Broken by hand, each went red: CSP without connect-src; apiFramed always
false; the server's read check removed; the noFramedAPI wrap removed from
api.go (red through the real Handler); inside() letting every path
through; CORP same-origin re-added; in JS the client read check removed,
the ev.source check removed, and allow-same-origin added to the sandbox.
Without the Array.isArray guard on /api/plugin-pages, plugin-kernel,
builtins and plugin-middleware/own-icon/options went red (their mocks
answer a non-list) - that was found by the run, then fixed.
Real use: built magpie, `magpie web` on 127.0.0.1:3472 (gateway 3471) in a
sandbox HOME with the example plugin added. curl: the page file loads
with the CSP and no cookie, traversal and a bad token are 404, /api with
Origin: null or Sec-Fetch-Dest: iframe is 403 even with the cookie, an
undeclared read 403, a declared one 200. Chromium and WebKit at 1100 and
420: the page draws its declared read, the probe's fetch/absolute
fetch/top access/undeclared read are all refused, an <img> of /api is
refused, no page errors. Real use found that a
Cross-Origin-Resource-Policy: same-origin header blocked the frame's own
files (its origin is opaque); it is gone and a test guards it.
Not tried: the desktop (Wails) window. Market cards of plugins not yet
installed don't show a page's reads. The Playwright suite mirrors the
CSP in a mock route rather than the Go server (the Go tests and real use
cover the server).