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(desktop): stabilize native editing menu interactions
Lanc3b4673c61d4
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 6df53d1eb..d910618df 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -202,6 +202,8 @@ jobs:env:DEBUG_E2E: "1"run: xvfb-run --auto-servernum pnpm test:e2e:trusted-extensions+ - name: Run editable context menu interaction test+ run: xvfb-run --auto-servernum sh -c 'openbox >/dev/null 2>&1 & exec node --test apps/desktop/test/editable-context-menu-user-path.test.mjs'- name: Run MCP market owner E2Erun: xvfb-run --auto-servernum node --test apps/desktop/test/mcp-market-owner-user-path.test.mjs- name: Run File Manager theme E2Ediff --git a/apps/desktop/test/editable-context-menu-user-path.test.mjs b/apps/desktop/test/editable-context-menu-user-path.test.mjsindex 5e517a7ce..b9e4dffe2 100644--- a/apps/desktop/test/editable-context-menu-user-path.test.mjs+++ b/apps/desktop/test/editable-context-menu-user-path.test.mjs@@ -40,14 +40,14 @@ const main = `import assert from "node:assert/strict";import { app, BrowserWindow, Menu } from "electron";import { installEditableContextMenu } from "../../apps/desktop/electron/main/application-menu";+import { waitFor } from "./wait.mjs";app.setPath("userData", process.argv[2]);app.whenReady().then(async () => {const win = new BrowserWindow({ show: true, width: 800, height: 600,webPreferences: { sandbox: true, contextIsolation: true, nodeIntegration: false, backgroundThrottling: false } });const wc = win.webContents;let opened;-// Only the popup boundary is replaced. The role each item was built with is asserted-// before the platform performs the edit, so a mis-wired menu cannot pass.+// Keep native editing roles while replacing the OS popup boundary.Menu.prototype.popup = function (options) { opened = { menu: this, options }; };installEditableContextMenu(win);const read = (expression) => wc.executeJavaScript(expression);@@ -59,18 +59,18 @@ async function openMenu() {wc.sendInputEvent({ type: "mouseUp", button: "right", clickCount: 1, ...point });return event;}-function command(role) {+async function command(role, expression, expected) {const item = opened.menu.items.find((candidate) => candidate.role === role);assert.equal(item?.enabled, true, role + " must be enabled");- // The role assert above runs before anything executes, so a menu that wires the wrong- // role fails here even though the platform performs the edit itself.if (process.platform === "darwin") Menu.sendActionToFirstResponder(role === "selectall" ? "selectAll:" : role + ":");else item.click({}, win, wc);+ await waitFor(async () => (await read(expression)) === expected, 5_000, role + " to update the editor");}try {Menu.setApplicationMenu(null);await win.loadFile(process.argv[3]);win.focus();+ await waitFor(() => win.isFocused(), 5_000, "fixture window focus");await read('document.querySelector(".composer-input").focus()');await wc.insertText("alpha beta");await read('const range = document.createRange(); const node = document.querySelector(".composer-input").firstChild; range.setStart(node, 0); range.setEnd(node, 5); window.getSelection().removeAllRanges(); window.getSelection().addRange(range)');@@ -85,16 +85,11 @@ try {assert.equal(await read('window.getSelection().toString()'), "alpha");await wc.insertText("gamma");assert.equal(await read("window.probe.value"), "gamma beta");- await openMenu(); command("undo");- assert.equal(await read("window.probe.value"), "alpha beta");- await openMenu(); command("redo");- assert.equal(await read("window.probe.value"), "gamma beta");- await openMenu(); command("selectall");- assert.equal(await read('window.getSelection().toString()'), "gamma beta");+ await openMenu(); await command("undo", "window.probe.value", "alpha beta");+ await openMenu(); await command("redo", "window.probe.value", "gamma beta");+ await openMenu(); await command("selectall", "window.getSelection().toString()", "gamma beta");await read('document.querySelector(".composer-input").contentEditable = "false"');await openMenu();- // A read-only control must not open this menu at all; whatever Electron itself does on a- // real right-click is outside this test's replaced popup boundary.assert.equal(opened, undefined, "read-only controls do not open the editing menu");console.log("EDITABLE_MENU_PROBE passed");} catch (error) {diff --git a/docs/spec/06-delivery/e2e/ui-shell.md b/docs/spec/06-delivery/e2e/ui-shell.mdindex 5fd8ed53e..a27e4e6e6 100644--- a/docs/spec/06-delivery/e2e/ui-shell.md+++ b/docs/spec/06-delivery/e2e/ui-shell.md@@ -84,9 +84,7 @@`04-ux/09-interaction-patterns.md`- **Acceptance**: Quality (key operations feel polished)- **Milestone**: M5-- **Status**: Unit-covered (`user-select.test.mjs`); native composer menu,- selection, and undo/redo automated (`editable-context-menu-user-path.test.mjs`);- full shell scenario Documented.+- **Status**: Unit-covered (`user-select.test.mjs`); scenario Documented## E2E-047b: Sidebar session hover card surfaces rich metadata