Skip to content

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

test(window): retain actual native Host replies and stderr

Linuxdazhao4eb55e781ab9
diff --git a/scripts/e2e/fixtures/window-snap/main.cjs b/scripts/e2e/fixtures/window-snap/main.cjs
index b483b8e10..df838f962 100644
--- a/scripts/e2e/fixtures/window-snap/main.cjs
+++ b/scripts/e2e/fixtures/window-snap/main.cjs
@@ -31,6 +31,16 @@ app.whenReady().then(async () => {
env: { PI_DESKTOP_ELECTRON_PID: String(process.pid) }, quiet: true,
});
await host.start();
+ const observedHost = { async call(method, params, timeout) {
+ try {
+ const result = await host.call(method, params, timeout);
+ fs.appendFileSync(path.join(root, "native-rpc.jsonl"), JSON.stringify({ at: new Date().toISOString(), method, result }) + "\n");
+ return result;
+ } catch (error) {
+ fs.appendFileSync(path.join(root, "native-rpc.jsonl"), JSON.stringify({ at: new Date().toISOString(), method, error: String(error) }) + "\n");
+ throw error;
+ }
+ } };
window = new BrowserWindow({
x: 200, y: 140, width: 1200, height: 800,
minWidth: options.minWidth, minHeight: options.minHeight,
@@ -47,9 +57,9 @@ app.whenReady().then(async () => {
assert.ok(foreignHandle);
await assert.rejects(host.call("window.enableNativeSnap", { nativeHandle: foreignHandle, ownerPid: process.pid }),
(error) => error.errorCode === "INTERNAL");
- if (!baseline) snap = await installWindowsNativeSnap(window, () => host, logger);
+ if (!baseline) snap = await installWindowsNativeSnap(window, () => observedHost, logger);
if (legacySurface) installWindowShape(window, 12, screen);
- else corners = await installWindows11CornerController(window, 12, () => host, screen, logger);
+ else corners = await installWindows11CornerController(window, 12, () => observedHost, screen, logger);
window.webContents.on("page-title-updated", (event) => event.preventDefault());
await window.loadURL("data:text/html," + encodeURIComponent(`<style>
html,body{margin:0;width:100%;height:100%;overflow:hidden;background:linear-gradient(90deg,#f6f6f6 50%,#181818 50%)}
@@ -93,6 +103,7 @@ app.whenReady().then(async () => {
}, 25);
}).catch(async (error) => {
fs.writeFileSync(path.join(root, "fixture-error.txt"), String(error.stack || error));
+ if (host) fs.writeFileSync(path.join(root, "host-stderr.txt"), host.stderr);
if (host) await host.stop().catch((cleanupError) => console.error("fixture Host cleanup failed", cleanupError));
app.exit(1);
});
@@ -101,7 +112,10 @@ app.on("before-quit", (event) => {
if (quitting) return;
event.preventDefault(); quitting = true; clearInterval(timer);
void (async () => {
- try { if (host) await host.stop(); app.exit(0); }
+ try {
+ if (host) { await host.stop(); fs.writeFileSync(path.join(root, "host-stderr.txt"), host.stderr); }
+ app.exit(0);
+ }
catch (error) { console.error("fixture Host cleanup failed", error); app.exit(1); }
})();
});
diff --git a/scripts/e2e/run-window-snap.ps1 b/scripts/e2e/run-window-snap.ps1
index 7570dde7a..b326fdf09 100644
--- a/scripts/e2e/run-window-snap.ps1
+++ b/scripts/e2e/run-window-snap.ps1
@@ -55,7 +55,7 @@ try {
& taskkill.exe /PID $process.Id /T /F | Out-Null
}
# Never upload profiles, databases, user paths or unrelated desktop captures.
- foreach ($name in @('result.json', 'ready.json', 'probe.log', 'stdout.txt', 'stderr.txt', 'fixture-error.txt')) {
+ foreach ($name in @('result.json', 'ready.json', 'probe.log', 'stdout.txt', 'stderr.txt', 'host-stderr.txt', 'native-rpc.jsonl', 'fixture-error.txt')) {
$file = Join-Path $runtime $name
if (Test-Path $file) {
$text = [IO.File]::ReadAllText($file)