feat: rebuild plugin UI with host rendering and standard settings (#4053)

* feat: rebuild plugin pages with host rendering and native settings

* fix(plugins): contain host-view errors, isolate editing, and migrate fixtures

* fix(plugins): migrate remaining permission fixture hosts
This commit is contained in:
陈大猫 authored and GitHub committed 2026-10-28 23:08:31 -07:00
1 parent 7cd57adcea
commit d5a03606b7
227 files changed
+8298 -4172

No files matched your search

+10 -61
View File
@@ -2,66 +2,15 @@ const assert = require("node:assert/strict");
const test = require("node:test");
const fs = require("node:fs");
const path = require("node:path");
const { JSDOM } = require("jsdom");
test("official view examples consume initial/live host HSL tokens and dispose subscriptions", () => {
for (const name of [
"starter-netcatty",
"vault-scratchpad",
"session-scratchpad",
]) {
const root = path.join(__dirname, "../../examples/plugins", name),
dom = new JSDOM("<!doctype html><html></html>", {
runScripts: "outside-only",
});
let listener,
disposed = 0,
subscriptions = 0;
dom.window.netcattyView = {
onDidChangeEnvironment(fn) {
subscriptions++;
listener = fn;
return {
dispose() {
disposed++;
},
};
},
};
dom.window.eval(fs.readFileSync(path.join(root, "theme.js"), "utf8"));
listener({
theme: "light",
themeTokens: {
"--primary": "120 50% 30%",
"--background": "0 0% 100%",
"--unsupported": "ignored",
},
});
assert.equal(
dom.window.document.documentElement.style.getPropertyValue("--primary"),
"120 50% 30%",
);
assert.equal(
dom.window.document.documentElement.style.getPropertyValue(
"--unsupported",
),
"",
);
listener({
theme: "dark",
reducedMotion: true,
themeTokens: { "--primary": "120 50% 70%" },
});
assert.equal(dom.window.document.documentElement.style.colorScheme, "dark");
assert.equal(
dom.window.document.documentElement.style.getPropertyValue(
"--background",
),
"",
);
dom.window.dispatchEvent(new dom.window.Event("pagehide"));
assert.equal(disposed, 1);
dom.window.dispatchEvent(new dom.window.Event("pageshow"));
assert.equal(subscriptions, 2);
dom.window.close();
const { validatePluginStylesheet } = require("../../domain/pluginViewStylePolicy.cjs");
test("official view examples inherit host tokens and all authored styles pass the host policy", () => {
for (const name of ['starter-netcatty', 'vault-scratchpad', 'session-scratchpad', 'hello-vault', 'hello-world-v2', 'settings-view-fixture', 'assistant', 'global-agent', 'database-minimal', 'database-rfam-readonly']) {
const root = path.join(__dirname, '../../examples/plugins', name);
const css = fs.readFileSync(path.join(root, 'view.css'), 'utf8');
assert.ok(validatePluginStylesheet(css), name);
assert.match(css, /var\(--foreground\)/);
assert.doesNotMatch(css, /--background\s*:/);
const manifest = JSON.parse(fs.readFileSync(path.join(root, 'netcatty.plugin.json'), 'utf8'));
for (const view of manifest.contributes.views) { assert.equal(view.entry, undefined); assert.equal(view.rendering, undefined); }
}
});