Skip to content

An agent skill for creating detailed, interactive isometric illustrations of real-world machines and complex systems. Generates polished SVGs with optional WebGL shaders and 3D effects.

fix(browser-checks): send native Enter activation

Rudy Celekli573b9e386478
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index bf7b18d..fac0f0d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -25,6 +25,9 @@ jobs:
with:
node-version: 22
+ - name: Enter key regressions
+ run: node --test scripts/enter-key.test.mjs
+
- name: Dial indicator
run: |
node examples/dial-indicator/build.mjs
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8152ae2..e6e7fbf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,8 @@ All notable changes to Anatomy are recorded here. The format follows [Keep a Cha
### Fixed
+- Capture and drive send native Enter activation so button and form checks perform their default action.
+
- `examples/test-rig/` drew its glass button dark in the light theme. `stretch.css` now has light values for its own colours.
### Changed
diff --git a/scripts/capture.mjs b/scripts/capture.mjs
index 755bb0a..601e539 100644
--- a/scripts/capture.mjs
+++ b/scripts/capture.mjs
@@ -191,8 +191,8 @@ async function main() {
if (entry === "Tab") continue;
const key = entry === "Comma" ? "," : entry === "Space" ? " " : entry;
const code = named[key] ?? (/^[0-9]$/.test(key) ? `Digit${key}` : key.length === 1 ? `Key${key.toUpperCase()}` : key);
- await send("Input.dispatchKeyEvent", { type: "keyDown", key, code, text: key.length === 1 ? key : undefined, windowsVirtualKeyCode: key === " " ? 32 : 0 });
- await send("Input.dispatchKeyEvent", { type: "keyUp", key, code });
+ await send("Input.dispatchKeyEvent", { type: "keyDown", key, code, text: key === "Enter" ? "\r" : key.length === 1 ? key : undefined, windowsVirtualKeyCode: key === " " ? 32 : key === "Enter" ? 13 : 0 });
+ await send("Input.dispatchKeyEvent", { type: "keyUp", key, code, windowsVirtualKeyCode: key === "Enter" ? 13 : undefined });
await sleep(250);
}
await sleep(1200);
diff --git a/scripts/drive.mjs b/scripts/drive.mjs
index ef2c90b..7b80673 100644
--- a/scripts/drive.mjs
+++ b/scripts/drive.mjs
@@ -222,8 +222,8 @@ async function main() {
const key = args[0];
const named = { " ": "Space", "-": "Minus", "=": "Equal", ",": "Comma", ".": "Period", "/": "Slash", ";": "Semicolon", "'": "Quote", "[": "BracketLeft", "]": "BracketRight", "\\": "Backslash", "`": "Backquote" };
const code = args[2] ?? (named[key] ?? (/^[0-9]$/.test(key) ? `Digit${key}` : key.length === 1 ? `Key${key.toUpperCase()}` : key));
- await send("Input.dispatchKeyEvent", { type: "keyDown", key, code, text: key.length === 1 ? key : undefined, windowsVirtualKeyCode: key === " " ? 32 : 0 });
- await send("Input.dispatchKeyEvent", { type: "keyUp", key, code });
+ await send("Input.dispatchKeyEvent", { type: "keyDown", key, code, text: key === "Enter" ? "\r" : key.length === 1 ? key : undefined, windowsVirtualKeyCode: key === " " ? 32 : key === "Enter" ? 13 : 0 });
+ await send("Input.dispatchKeyEvent", { type: "keyUp", key, code, windowsVirtualKeyCode: key === "Enter" ? 13 : undefined });
} else if (kind === "eval") console.log("eval:", JSON.stringify(await evaluate(args[0])));
else if (kind === "slow") await evaluate(`window.__driveSpeed=${Number(args[0])}`);
else if (kind === "until") {
diff --git a/scripts/enter-key.test.mjs b/scripts/enter-key.test.mjs
new file mode 100644
index 0000000..a0a3204
--- /dev/null
+++ b/scripts/enter-key.test.mjs
@@ -0,0 +1,38 @@
+import assert from "node:assert/strict";
+import { execFile } from "node:child_process";
+import { mkdtemp, rm, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { promisify } from "node:util";
+import test from "node:test";
+
+const execute = promisify(execFile);
+async function run(kind, args) {
+ const directory = await mkdtemp(join(tmpdir(), "anatomy-enter-key-"));
+ try {
+ const file = join(directory, "figure.html");
+ await writeFile(file, `<!doctype html><div class="iso-plate" style="width:400px;height:180px"><button id="button" type="button" tabindex="0" onclick="window.clicked=(window.clicked||0)+1;document.querySelector('[data-readout]').textContent='activated'">Activate</button><form onsubmit="event.preventDefault();window.submitted=(window.submitted||0)+1"><input id="field" tabindex="0"></form><input id="range" type="range" value="5" min="0" max="10"><span data-readout>waiting</span></div>`);
+ return await execute(process.execPath, ["scripts/" + kind + ".mjs", file, ...(kind === "capture" ? ["--out", join(directory, "shot.png"), "--wait", "0", "--key", args] : [JSON.stringify(args)])], { timeout: 30000 });
+ } finally { await rm(directory, { recursive: true, force: true }); }
+}
+for (const code of [undefined, "NumpadEnter"])
+ test(`drive Enter ${code || "default"} performs the native button action`, async () => {
+ const result = await run("drive", [["key", "Enter", "#button", code], ["eval", "window.clicked||0"]]);
+ assert.match(result.stdout, /eval: 1/);
+ });
+test("drive Enter performs native implicit form submission", async () => {
+ const result = await run("drive", [["key", "Enter", "#field"], ["eval", "window.submitted||0"]]);
+ assert.match(result.stdout, /eval: 1/);
+});
+test("capture Enter applies native activation before the screenshot", async () => {
+ const result = await run("capture", "Enter");
+ assert.match(result.stdout, /readout "activated"/);
+});
+test("drive preserves native Space, arrow and printable key behavior", async () => {
+ const result = await run("drive", [["key", " ", "#button"], ["key", "ArrowRight", "#range"], ["key", "a", "#field"], ["eval", "({clicked:window.clicked||0,range:document.querySelector('#range').value,text:document.querySelector('#field').value})"]]);
+ assert.match(result.stdout, /"clicked":1,"range":"6","text":"a"/);
+});
+test("capture preserves native Space activation", async () => {
+ const result = await run("capture", "Space");
+ assert.match(result.stdout, /readout "activated"/);
+});