Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

gui: the masking demo shows no video where WebKitGTK can't play one (avk458 on X)

yetone6af83172d328
diff --git a/internal/gui/api.go b/internal/gui/api.go
index 121c06544..92ea2033e 100644
--- a/internal/gui/api.go
+++ b/internal/gui/api.go
@@ -403,9 +403,6 @@ type settingsJSON struct {
GatewayOn bool `json:"gatewayOn,omitempty"`
GatewayWhy string `json:"gatewayWhy,omitempty"`
Web bool `json:"web,omitempty"`
- // NoVideo: this app's webview would crash on a <video> (Linux without
- // gst-plugins-good, webkitPlaysVideo), so the pages show no video
- NoVideo bool `json:"noVideo,omitempty"`
// the proxy vendor requests go through now, and where it came from:
// settings, environment, system, off or none
ProxyNow string `json:"proxyNow"`
@@ -630,7 +627,6 @@ func settingsState() settingsJSON {
}
s.WSL = runtime.GOOS == "windows"
s.Web = webPage.Load()
- s.NoVideo = !s.Web && !webkitPlaysVideo()
s.GatewayOn, s.GatewayWhy = gatewayMode(s.Web)
s.LANKey = "" // the retained credential belongs on disk, not in UI state
// the GitHub token, masked, and where the library's requests take one
@@ -859,6 +855,14 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {
if !isWeb(w) {
boot["uiFont"], boot["codeFont"] = s.UIFont, s.CodeFont
}
+ // and whether this app's webview would crash on a <video> (Linux
+ // without gst-plugins-good, webkitPlaysVideo), so the pages show
+ // none. Here, not in the settings: the page's settings come from
+ // /api/state, which never said it, so the masking demo set its
+ // video and the web process aborted (avk458 on X, omarchy)
+ if !isWeb(w) && !webkitPlaysVideo() {
+ boot["noVideo"] = true
+ }
// and whether it is a gateway's page alone (gatewaymode.go), so the
// pages left out never show
if on, _ := gatewayMode(ownWeb(w)); on {
diff --git a/internal/gui/assets/plugins/redact/demo.js b/internal/gui/assets/plugins/redact/demo.js
index bf10a5186..7c7387511 100644
--- a/internal/gui/assets/plugins/redact/demo.js
+++ b/internal/gui/assets/plugins/redact/demo.js
@@ -8,8 +8,10 @@
// sheets, the notebook and the boxes are the page's, moved over her. The
// video is fetched when the row is first opened, never before. It plays
// while the row is open and on screen, once through, and rests on its last
-// step; with reduced motion it starts there. Where the app's webview would
-// crash on a video (state.settings.noVideo), she is her poster.
+// step; with reduced motion it starts there. Folded, or with the page left,
+// the video lets its source go, so a folded demo holds no decoder or
+// buffered video. Where the app's webview would crash on a video
+// (bootPrefs.noVideo: Linux without gst-plugins-good), she is her poster.
const XQD_END = 27.5;
const XQD_STEPS = [
@@ -364,18 +366,31 @@ function maskDemoBuild(body) {
// video plays T leans toward its time, so she and the sheets keep step.
// Without the video (it can't load or play) the frame clock alone runs.
const vid = stage.querySelector("video");
- let T = 0, playing = !calm(), open = false, seen = false, raf = 0, last = 0, fixed = 0, theme = "";
+ let T = 0, playing = !calm(), open = false, seen = false, raf = 0, last = 0, fixed = 0, theme = "", take = "";
const dark = matchMedia("(prefers-color-scheme: dark)");
+ // boot.js says it before the page draws: /api/state's settings don't
+ // carry it, so a demo opened before Settings was never told (avk458 on X)
+ const noVideo = !!window.bootPrefs?.noVideo;
const pickVid = () => {
const th = document.documentElement.dataset.theme || (dark.matches ? "dark" : "light");
if (th === theme) return;
theme = th;
vid.poster = `plugins/redact/xq_${th}.jpg`;
- if (!state.settings?.noVideo) vid.src = `plugins/redact/xq_${th}.webm`;
+ take = noVideo ? "" : `plugins/redact/xq_${th}.webm`;
// a new source starts paused: it goes on where the old one was
seek(T);
wake();
};
+ // the take is the video's source only while the row is open on the page
+ // shown; let go, the video frees its decoder and what it buffered
+ const hold = () => {
+ if (take && open && vp.getClientRects().length) {
+ if (vid.getAttribute("src") !== take) vid.src = take;
+ } else if (vid.hasAttribute("src")) {
+ vid.removeAttribute("src");
+ vid.load();
+ }
+ };
const seek = (t0) => { T = t0; if (vid.readyState >= 1) vid.currentTime = Math.min(t0, vid.duration - .02); };
vid.addEventListener("loadedmetadata", () => seek(T));
let lastScrub = -1;
@@ -417,6 +432,7 @@ function maskDemoBuild(body) {
// wake starts or stops it as the row, the page and the window say
function wake() {
open = $("#mdRow")?.getAttribute("aria-expanded") === "true";
+ hold();
if (live() && playing) {
seek(T);
vid.play().catch(() => {});
@@ -440,6 +456,6 @@ function maskDemoBuild(body) {
if (!playing) seek(25.6);
render(T); sync();
setPlaying(playing);
- root.__state = () => ({ T, ct: vid.currentTime, paused: vid.paused, rs: vid.readyState, src: vid.currentSrc.split("/").pop(), playing, raf: !!raf });
+ root.__state = () => ({ T, ct: vid.currentTime, paused: vid.paused, rs: vid.readyState, src: vid.getAttribute("src") ? vid.currentSrc.split("/").pop() : "", playing, raf: !!raf });
return { wake, root };
}
diff --git a/internal/gui/novideo_test.go b/internal/gui/novideo_test.go
new file mode 100644
index 000000000..d5aced56f
--- /dev/null
+++ b/internal/gui/novideo_test.go
@@ -0,0 +1,36 @@
+package gui
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "testing"
+)
+
+// Where the app's webview would crash on a <video> (Linux without
+// gst-plugins-good), boot.js says so before the page draws, and the
+// state the page loads first doesn't need to: the masking demo read it from
+// /api/state's settings, which never carried it, set its video and the web
+// process aborted on omarchy (avk458 on X). A browser tab plays video in
+// the user's own browser and is never told.
+func TestBootSaysNoVideo(t *testing.T) {
+ builtinHome(t)
+ prev := webkitPlaysVideo
+ t.Cleanup(func() { webkitPlaysVideo = prev })
+ boot := func(h http.Handler) string {
+ rec := httptest.NewRecorder()
+ h.ServeHTTP(rec, httptest.NewRequest("GET", "/boot.js", nil))
+ return rec.Body.String()
+ }
+ webkitPlaysVideo = func() bool { return false }
+ if b := boot(Handler(nil, nil)); !strings.Contains(b, `"noVideo":true`) {
+ t.Fatalf("the app, with no video: %s", b)
+ }
+ if b := boot(Handler(webHost{}, nil)); strings.Contains(b, "noVideo") {
+ t.Fatalf("a browser tab plays its own video: %s", b)
+ }
+ webkitPlaysVideo = func() bool { return true }
+ if b := boot(Handler(nil, nil)); strings.Contains(b, "noVideo") {
+ t.Fatalf("the app, with video: %s", b)
+ }
+}
diff --git a/internal/gui/tests/masking-demo.test.cjs b/internal/gui/tests/masking-demo.test.cjs
index e4bf81d05..f7e637e0e 100644
--- a/internal/gui/tests/masking-demo.test.cjs
+++ b/internal/gui/tests/masking-demo.test.cjs
@@ -18,12 +18,12 @@ const K = "1792987654321000001";
const record = { key: K, t: new Date(Date.now() - 60e3).toISOString(), route: "messages", what: "chat", agent: "claude", provider: "anthropic", model: "claude-opus-4-1", n: 1,
values: [{ p: "{{PERSON_bbbb2222}}", k: "PERSON", b: "model", h: "", l: 3, n: 1 }], snips: { "{{PERSON_bbbb2222}}": "ask {{PERSON_bbbb2222}} about it" } };
-function serve(lang, theme, fetched, more) {
+function serve(lang, theme, fetched, more, boot = {}) {
const settings = { theme, lang, tray: "panel", currency: "usd", redact: true, redactPersonal: true, ...more };
return async (route) => {
const req = route.request(), url = new URL(req.url());
const json = (data) => route.fulfill({ json: data });
- if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"${theme}",web:true};` });
+ if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = ${JSON.stringify({ lang, theme, web: true, ...boot })};` });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json({ agents: [{ id: "claude", name: "Claude Code", icon: "claudecode-color", fields: [] }], profiles: [], settings });
if (url.pathname === "/api/settings") return json(settings);
@@ -56,7 +56,7 @@ async function open(engine, lang, width, opts = {}) {
page.setDefaultTimeout(8000);
const errors = [], fetched = [];
page.on("pageerror", (e) => errors.push(e.message));
- await page.route("**/*", serve(lang, opts.theme || "light", fetched, opts.settings));
+ await page.route("**/*", serve(lang, opts.theme || "light", fetched, opts.settings, opts.boot));
await page.goto("http://magpie.test/?view=masking");
await page.locator("#mdRow").waitFor();
return { browser, page, errors, fetched };
@@ -227,9 +227,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.deepEqual(errors, []);
});
// on Linux without gst-plugins-good WebKitGTK's web process aborts on any
- // video (stock Omarchy), so there she is her poster and the sheets still move
+ // video (stock Omarchy), so there she is her poster and the sheets still
+ // move. The app says so in boot.js, as the server does; /api/state's
+ // settings never carry it (avk458 on X: the demo crashed omarchy's app)
test(`${engine}: where the app can't play video she is her poster, and the demo still plays`, async (t) => {
- const { browser, page, errors, fetched } = await open(engine, "en", 1100, { motion: true, settings: { noVideo: true } });
+ const { browser, page, errors, fetched } = await open(engine, "en", 1100, { motion: true, boot: { noVideo: true } });
t.after(() => browser.close());
await page.locator("#mdRow").click();
await until(async () => (await state(page)).T > 1, 8000, page);
@@ -241,6 +243,27 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await until(async () => (await state(page)).T > a.T + .5, 8000, page);
assert.deepEqual(errors, []);
});
+ // folded, or with the page left, the video lets go of its source, so it
+ // holds no decoder or buffered video; opened again it goes on where it was
+ test(`${engine}: folded or left, the demo holds no video; opened again it goes on`, async (t) => {
+ const { browser, page, errors } = await open(engine, "en", 1100, { motion: true });
+ t.after(() => browser.close());
+ const src = () => page.evaluate(() => document.querySelector(".xqd video").getAttribute("src"));
+ await page.locator("#mdRow").click();
+ await until(async () => { const s = await state(page); return !s.paused && s.ct > 1; }, 8000, page);
+ await page.locator("#mdRow").click();
+ await until(async () => (await src()) === null, 8000, page);
+ const folded = await state(page);
+ assert.equal(folded.rs, 0, "no data held while folded");
+ await page.locator("#mdRow").click();
+ await until(async () => { const s = await state(page); return s.src === "xq_light.webm" && !s.paused && s.ct > folded.T; }, 8000, page);
+ // another page: the masking view hidden
+ await page.evaluate(() => { document.querySelector("#view-masking").hidden = true; });
+ await until(async () => (await src()) === null, 8000, page);
+ await page.evaluate(() => { document.querySelector("#view-masking").hidden = false; });
+ await until(async () => (await src()) !== null, 8000, page);
+ assert.deepEqual(errors, []);
+ });
}
// her background is the card's: the video's own corners, against the card
diff --git a/internal/gui/webkit_other.go b/internal/gui/webkit_other.go
index f64d7672a..cc9b76b63 100644
--- a/internal/gui/webkit_other.go
+++ b/internal/gui/webkit_other.go
@@ -6,4 +6,4 @@ package gui
func webkitDefaults() {}
// webkitPlaysVideo: the other systems' webviews play video.
-func webkitPlaysVideo() bool { return true }
+var webkitPlaysVideo = func() bool { return true }