Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(e2e): give the theme-surface probe deterministic focus

vastsa21738937d95b
diff --git a/scripts/e2e-theme-surfaces.mjs b/scripts/e2e-theme-surfaces.mjs
index a285106e7..2cd2c9839 100644
--- a/scripts/e2e-theme-surfaces.mjs
+++ b/scripts/e2e-theme-surfaces.mjs
@@ -43,6 +43,11 @@ app.whenReady().then(async () => {
window.show();
window.focus();
window.webContents.focus();
+ // Chromium only matches :focus-visible while it believes the page owns focus.
+ // This window cannot be relied on to keep macOS foreground focus across the
+ // probe loop, so emulate it (three-column-layout uses the same command).
+ window.webContents.debugger.attach("1.3");
+ await window.webContents.debugger.sendCommand("Emulation.setFocusEmulationEnabled", { enabled: true });
window.webContents.sendInputEvent({ type: "keyDown", keyCode: "Tab" });
window.webContents.sendInputEvent({ type: "keyUp", keyCode: "Tab" });
const checks = [];
diff --git a/scripts/e2e/theme-surfaces.js b/scripts/e2e/theme-surfaces.js
index 34cafe701..98df79809 100644
--- a/scripts/e2e/theme-surfaces.js
+++ b/scripts/e2e/theme-surfaces.js
@@ -84,7 +84,14 @@ function rgba(color) {
async function settle() {
await document.fonts.ready;
await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
- await Promise.all(document.getAnimations().map((animation) => animation.finished.catch(() => {})));
+ // A running transition can be retargeted when the next state lands, which
+ // rejects its `finished` promise, so poll for a page without animations rather
+ // than trusting them to settle. Sampling mid-transition used to report a
+ // half-way paint as a theme failure.
+ const deadline = performance.now() + 2000;
+ while (document.getAnimations().length > 0 && performance.now() < deadline) {
+ await new Promise((resolve) => requestAnimationFrame(resolve));
+ }
await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
}
function sample(selector) {
@@ -144,9 +151,9 @@ globalThis.themeSurfacesProbe = async (theme, custom) => {
elevatedRgba: rgba(getComputedStyle(document.documentElement).getPropertyValue("--ds-bg-elevated-primary").trim()) };
};
-// The Composer occlusion regression is intentionally independent from the
-// fixture's keyboard-focus checks, whose :focus-visible state depends on the
-// test window owning macOS foreground focus.
+// This mode still isolates the Composer occlusion regression from the keyboard
+// checks: the driver enables Chromium focus emulation for :focus-visible, and
+// this probe only needs the token-driven paint of the dock mask.
globalThis.themeDockMaskProbe = async (theme, custom) => {
const result = await globalThis.themeSurfacesProbe(theme, custom);
const dock = result.values.dockMask;