f2eb56c6bbde1300dddc402861b59cd4e45e0215
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b9f790d37b |
plugins: panels in magpie's pages, a page that replaces a built-in one, titles in the window's language, and a look that matches
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
|
||
|
|
64b0f3a201 |
plugins: a community plugin's own page in magpie's window, shut in a sandboxed frame (P4)
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).
|
||
|
|
64487d458e |
gui: copying on KDE Wayland no longer breaks the connection to the compositor and quits magpie (#2039, dannisun0412)
dannisun0412 runs magpie on KDE Plasma 6.6.6 (kwin_wayland, libwayland 1.24) and it quit three times in twelve minutes with "Error 22 (Invalid argument) dispatching to Wayland display" / "Error reading events from display: Invalid argument". The cause is the clipboard read-back probe (clipboard_gtk3.h). It made its own wl_data_device and, when done, called wl_data_device_destroy, which only frees the client side. The compositor still thinks the device is live and keeps sending it a fresh wl_data_offer on every later copy. libwayland drops those events for the dead proxy without reserving their new ids, so the client's id map falls behind the server's; the next server-created object whose id lands past the gap makes wl_map_reserve_new return EINVAL and GDK exits. The probe now binds the data device manager at version 3 at most and releases the device with wl_data_device_release (version 2+), so the compositor stops sending to it. On a version-1 manager it doesn't read back at all (returns -2, which the Go side takes as "copy held"). The probe test (testdata/clipboard_probe.c) gets an "again" mode: copy and read back eight times, then make the compositor hand out four offers at once (the "burst" that needs ids past the leak), then check the process is still alive. Run: - Fedora 44 container with kwin_wayland --virtual (SYS_NICE), gtk3/webkit2gtk-4.1, go 1.26.9: with origin/main's header the probe died with EINVAL 6 of 6 times (primary selection on and off) and TestClipboardReadBack failed 3 of 3 with "Error reading events from display: Invalid argument"; with this change the probe stayed alive 6 of 6 and TestClipboardReadBack passed 3 of 3. GOOS=linux go vet with the gtk3 build in the container was clean. - macOS: gofmt -l clean; go vet darwin, linux nogui, windows nogui; go test -tags nogui ./internal/gui passed. Not tried: a real Plasma desktop or the full app over Selkies. |
||
|
|
558a313325 |
gui: a copy on KDE Plasma Wayland reaches the clipboard, and one that doesn't isn't called copied (#1881, BabyLy233)
On KDE Plasma (KWin 6.7.2) Wayland the GUI said "copied" and the clipboard
stayed empty, for wl-paste and Klipper too; GDK_BACKEND=x11 copied.
The reporter's WAYLAND_DEBUG log: KWin took magpie's selection
(set_selection(wl_data_source#43, 17983), then selection(wl_data_offer)),
and every paste asked it (wl_data_source#43.send("text/plain;charset=utf-8",
fd 74), fd 74 again, fd 77 ...) with the same fd number coming back each
time: GTK closed each pipe without writing. Their registry has no
zwp_primary_selection_device_manager_v1, which is KWin with
[Wayland] EnablePrimarySelection=false (middle-click paste off).
Wails v3's clipboardSet sets CLIPBOARD, then PRIMARY. GTK 3's Wayland
selection code (gdkselection-wayland.c, every 3.24 release up to .52) keeps
one source_targets list for both: setting PRIMARY clears it, and with no
primary manager gdk_wayland_selection_add_targets returns before adding
any, so CLIPBOARD's source then answers every send() with a closed pipe.
Wails' SetText answers true whatever happened.
- clipboard_gtk3.h/.go (linux, gtk3): set PRIMARY first, then CLIPBOARD.
On Wayland, read the clipboard back through the compositor on a
wl_data_device of its own (own event queue; GTK's own clipboard API
short-cuts to the local copy and would never see the bug). Copy is true
only when the text reads back whole (copyHeld); an empty, other, short
or unknown read is false, so /api/copy answers 501 and the page tries
its own ways. X11 keeps GTK's word, as before.
- clipboard_other.go: macOS, Windows and non-gtk3 builds keep Wails'
SetText unchanged.
Run:
- go test -tags nogui ./internal/gui (pass); TestCopyHeld red with
copyHeld taking an empty read as held.
- gofmt -l; go vet for darwin (gui and nogui), GOOS=linux and
GOOS=windows -tags nogui.
- Fedora 44 container (GTK 3.24.52, KWin 6.7.5 kwin_wayland --virtual,
Go 1.26.9): go vet -tags gtk3 ./internal/gui; TestClipboardReadBack
(builds testdata/clipboard_probe.c, a GTK 3 window copying with
clipboard_gtk3.h) with EnablePrimarySelection=false: Wails' order reads
back len=0 and wl-paste prints nothing, magpie's reads back the text and
wl-paste prints it; with it true both read back whole (wails subtest
skips). With the order swapped back the "magpie" subtest goes red.
- Same container, the real app (go build -tags "gtk3 dev", sandbox HOME,
shell role's control /copy calling host.Copy): "ok" and wl-paste prints
each text; rebuilt with Wails' order: not ok, wl-paste empty.
Not tried: a real KDE Plasma desktop, Klipper, or GDK_BACKEND=x11 after
the change (that path is Wails' as before).
|
||
|
|
2018882e47 |
davsync, gui: a server file that isn't a backup is said as what it is, and can be replaced by this computer's setup (JasonLeeForOnly on Discord)
JasonLeeForOnly's WebDAV sync failed with only "not a magpie backup" for
several versions, and nothing on the page got past it. A WebDAV GET of the
backup can come back as a body that isn't the file in several ways; each is
now reproduced with an httptest server that answers the way the real one
does:
Unpacked (WebDAV and S3): gzip with or without Content-Encoding (a proxy
that drops the header), x-gzip, zstd with or without the header, deflate
(zlib or raw), and a header that says gzip over a plain body. Bodies are
told by magic number; a backup is JSON, so either magic is never the file.
Brotli (br) can't be unpacked and is said as itself, with what to turn off.
Said, with no upload offered: an HTML page answered with 200 (Nextcloud
login after a redirect, Cloudflare Access, an AList/OpenList web app, an
rclone directory listing, a captive portal), with its <title> and the
host/path a redirect ended at (query, fragment and user dropped), and
where the WebDAV address is for 坚果云 and Nextcloud; an XML answer, by its
root element.
Said, with Upload as the way out: an empty (0-byte) file, a backup cut
short or damaged (the automatic rebuild is unchanged and still goes first
when its rules allow), another app's file ("format": "…"), other JSON,
and any other file by its content type. Messages carry the size, kind and a
page title only, never the file's contents.
backup.Open now tells ErrNotBackup (doesn't begin like a backup) from
ErrCorrupt (begins like one, cut short). The status carries the kind as
serverFile; Settings › Sync and backup says it in the reader's language,
wraps it whole, and shows "Upload this computer's setup" only when the file
may be replaced. davsync.Upload (POST /api/davsync/upload, `magpie webdav
upload`, `magpie s3 upload`) asks first in the GUI, re-reads the file,
refuses a backup this computer opens, one sealed with another passphrase,
a newer magpie's, a page and an XML answer, keeps the server's copy in the
sync folder (0600, newest 5) and writes nothing if that fails, then writes
with If-Match on the version read. New strings in en, zh, zh-TW, ja, de.
Verified: internal/davsync/not_backup_test.go (TestReadCompressedBackup,
TestReadBrotliSaid, TestServerAnswerSaid, TestCutBackupSaidAndUploaded,
TestS3ReadCompressedObject; Upload-only parts stripped to compile) fails
on
|