Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
test(window): avoid sharing violations in native probe state exchange
Linuxdazhaof1f6a44aa778
diff --git a/scripts/e2e/fixtures/window-snap/main.cjs b/scripts/e2e/fixtures/window-snap/main.cjsindex c276aea8e..b483b8e10 100644--- a/scripts/e2e/fixtures/window-snap/main.cjs+++ b/scripts/e2e/fixtures/window-snap/main.cjs@@ -19,6 +19,11 @@ let corners;let quitting = false;const logger = { app: (...args) => console.error(...args) };const resolve = (name) => path.isAbsolute(name) ? name : path.join(root, name);+const publish = (name, value) => {+ const destination = path.join(root, name);+ fs.writeFileSync(destination + ".tmp", JSON.stringify(value));+ fs.renameSync(destination + ".tmp", destination);+};app.whenReady().then(async () => {const legacySurface = options.legacySurface || !usesWindows11NativeCorners(process.platform, process.getSystemVersion());@@ -60,7 +65,7 @@ app.whenReady().then(async () => {scaleFactor: screen.getDisplayMatching(window.getBounds()).scaleFactor });const flush = async () => { if (snap) await snap.flush(); if (corners) await corners.flush(); };await flush();- fs.writeFileSync(path.join(root, "ready.json"), JSON.stringify(snapshot()));+ publish("ready.json", snapshot());let active = false;timer = setInterval(async () => {const file = path.join(root, "command.json");@@ -81,7 +86,7 @@ app.whenReady().then(async () => {if (command.action === "fullscreen") setWindowFullScreen(window, command.value, true);await new Promise((done) => setTimeout(done, 500));await flush();- fs.writeFileSync(path.join(root, "state.json"), JSON.stringify({ ...snapshot(), id: command.id }));+ publish("state.json", { ...snapshot(), id: command.id });} catch (error) {fs.writeFileSync(path.join(root, "fixture-error.txt"), String(error.stack || error));} finally { active = false; }diff --git a/scripts/e2e/probe-window-snap.cs b/scripts/e2e/probe-window-snap.csindex 5c1aa8625..933763257 100644--- a/scripts/e2e/probe-window-snap.cs+++ b/scripts/e2e/probe-window-snap.cs@@ -40,7 +40,11 @@ public static class WindowSnapProbe {static int Number(Dictionary<string, object> value, string key) { return Convert.ToInt32(value[key]); }static Dictionary<string, object> Read(string name) {if (!File.Exists(FilePath(name))) return null;- try { return Json.Deserialize<Dictionary<string, object>>(File.ReadAllText(FilePath(name))); }+ try {+ using(var stream=new FileStream(FilePath(name),FileMode.Open,FileAccess.Read,FileShare.ReadWrite|FileShare.Delete))+ using(var reader=new StreamReader(stream)) return Json.Deserialize<Dictionary<string, object>>(reader.ReadToEnd());+ }+ catch (FileNotFoundException) { return null; }catch (ArgumentException) { return null; }}static void Wait(Func<bool> predicate, string message, int milliseconds = 5000) {