Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
plugins: a row's picture is asked for as it nears the screen (#909, #1956, #2459)
yetone689cf4142371
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.jsindex 3a466315b..94a50b4e0 100644--- a/internal/gui/assets/app.js+++ b/internal/gui/assets/app.js@@ -295,7 +295,10 @@ function maskSpan(src, failed) {}const pngIcons = new Set(["crush", "zcode", "alma", "hanako", "cindy", "lody", "typesafe", "atomcode", "snow", "mlx-serve", "mothx", "zoo-code"]);-function icon(name) {+// lazy: a picture in a long list (Plugins' rows) is asked for when it+// nears the screen. Each SVG an <img> draws is a document of its own in+// the webview, ~0.6 MB, kept while the page is open (#909)+function icon(name, lazy) {const kept = keptIcons?.get(name || "")?.shift();if (kept) { kept.removeAttribute("title"); return kept; }const e = el("span", "ic");@@ -308,6 +311,7 @@ function icon(name) {if (name?.startsWith("file:")) {// a picture the user gave their own providerconst img = el("img");+ if (lazy) img.loading = "lazy";img.src = "/api/icons/" + encodeURIComponent(name.slice(5));img.alt = "";img.draggable = false;@@ -318,6 +322,7 @@ function icon(name) {if (name) {if (name.endsWith("-color") || pngIcons.has(name)) {const img = el("img");+ if (lazy) img.loading = "lazy";img.src = `icons/${name}.${pngIcons.has(name) ? "png" : "svg"}`;img.alt = "";img.draggable = false;diff --git a/internal/gui/assets/plugins.js b/internal/gui/assets/plugins.jsindex ab4c6b6b1..5c65cba93 100644--- a/internal/gui/assets/plugins.js+++ b/internal/gui/assets/plugins.js@@ -139,7 +139,7 @@}function logo(ic, big, kind) {const box = el("span", "pm-logo" + (big ? " big" : ""));- if (ic) box.append(icon(ic));+ if (ic) box.append(icon(ic, !big));else box.append(glyph({ mw: PIPE, ag: TERM, tl: TOOL, pg: PAGE }[kind] || PUZZLE, big ? 22 : 17, 1.4));return box;}diff --git a/internal/gui/tests/plugin-own-icon.test.cjs b/internal/gui/tests/plugin-own-icon.test.cjsindex 9ac60b46d..0944542ca 100644--- a/internal/gui/tests/plugin-own-icon.test.cjs+++ b/internal/gui/tests/plugin-own-icon.test.cjs@@ -5,7 +5,7 @@// plugin's picture, not its first provider's; the providers keep theirs in// the Add sheet. One whose package gives none still wears its first// provider's, as before. Every language, both engines, wide and narrow;-// the API is faked here.+// the API is faked here. A row's picture loads lazily, the page's at once.const assert = require("node:assert/strict");const fs = require("node:fs/promises");const path = require("node:path");@@ -67,6 +67,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",await suite.waitFor();assert.equal(await suite.locator(".pm-logo img").getAttribute("src"), "/api/icons/suite.png", "the plugin's own, not its first provider's");assert.equal(await row("plain").locator(".pm-logo img").getAttribute("src"), "/api/icons/pc.png", "none of its own: its first provider's, as before");+ // a row's picture is asked for as it nears the screen: each SVG an+ // <img> draws is a document of its own in the webview (#909); one+ // on screen still loads+ assert.equal(await suite.locator(".pm-logo img").getAttribute("loading"), "lazy");+ await page.waitForFunction(() => document.querySelector("#view-plugins .pm-row .pm-logo img")?.naturalWidth > 0);const box = await suite.boundingBox();assert.ok(box.x >= 0 && box.x + box.width <= width, `the row fits: ${JSON.stringify(box)}`);@@ -75,6 +80,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",const dlg = page.locator("#modal .pm-detail");await dlg.waitFor();assert.equal(await dlg.locator(".pm-dhead .pm-logo img").getAttribute("src"), "/api/icons/suite.png");+ assert.equal(await dlg.locator(".pm-dhead .pm-logo img").getAttribute("loading"), null, "the page's own picture loads at once");assert.deepEqual(errors, []);await page.context().close();});