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(mcp): cover timeout clearing in editor E2E
vastsa39be4debaf73
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 01bb96f6a..5322b171c 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -7656,6 +7656,14 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.- **Discovery regression (#1221):** Local HTTP authorization flow covers root and path issuers, ordered OAuth/OIDC fallbacks, challenge-scope precedence, all protected-resource scopes, and omitted scope when absent. It checks the real callback, PKCE token exchange and storage handoff using synthetic tokens; no external account is contacted.- **Status**: Unit-covered (`apps/desktop/test/mcp-oauth.test.mjs`, `apps/desktop/test/user-mcp.test.mjs`); local HTTP flow covered by `apps/desktop/test/mcp-oauth-discovery.test.mjs`; full UI journey Draft+#### E2E-261: Clear a per-server MCP timeout override++- **Preconditions**: Isolated Electron profile and a saved MCP server with a 45-second timeout override; no live server or provider.+- **Steps**: Open the production MCP editor, enter an out-of-range value and confirm Save is disabled, then clear the timeout field and save.+- **Expected**: An invalid timeout cannot be saved. Clearing an existing override is valid and serializes as `timeoutSeconds: null`, allowing host-core to remove the override and use the default.+- **Acceptance**: `node scripts/e2e-mcp-timeout-clear.mjs` exercises the production editor and save serialization. `apps/desktop/test/mcp-editor-timeout.test.mjs` covers value conversion; host-core MCP tests cover null clearing and default behavior. No live MCP server is contacted.+- **Milestone**: M6++#### E2E-SKILL-import-multiple-folders- **Preconditions:** An isolated Desktop profile and three sibling folders:@@ -9252,6 +9260,7 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.| A / H / Quality — Renderer process crash recovery | E2E-RUNTIME-renderer-crash-recovery || B / F / Security — Provider copy | E2E-PROVIDER-copy-config-without-credentials || B / F / Quality — Selected model order | E2E-MODEL-selected-order-persists |+| E / F / Quality — MCP server timeout override | E2E-261 || A — App startup | E2E-001, E2E-002, E2E-003, E2E-004, E2E-067, E2E-076, E2E-079, E2E-092, E2E-097, E2E-143, E2E-150, E2E-168, E2E-204 || A / C / F / Quality — Tray session navigation | E2E-TRAY-bounded-session-navigation || B — Model config | E2E-005, E2E-006, E2E-007, E2E-038, E2E-050, E2E-052, E2E-055, E2E-066, E2E-080, E2E-082, E2E-102c, E2E-102d, E2E-102e, E2E-151, E2E-154, E2E-163, E2E-166, E2E-172, E2E-174, E2E-197, E2E-005G, E2E-005J, E2E-199, E2E-201, E2E-202, E2E-203, E2E-205, E2E-206, E2E-209 |@@ -9322,6 +9331,7 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.| M6+ | E2E-121, E2E-122, E2E-148, E2E-150, E2E-151, E2E-154, E2E-155, E2E-158, E2E-159, E2E-160, E2E-161, E2E-162, E2E-163, E2E-166, E2E-168, E2E-173, E2E-174, E2E-176, E2E-179, E2E-196a, E2E-196b, E2E-196c, E2E-198, E2E-199, E2E-200, E2E-202, E2E-203, E2E-205, E2E-209, E2E-210, E2E-UPDATE-preference-and-once-only-reminder, E2E-212, E2E-213, E2E-214, E2E-215, E2E-216, E2E-217, E2E-218, E2E-259, E2E-219, E2E-257, E2E-SUBAGENT-settlement-updates-before-parent-poll, E2E-PLUGIN-fs-root-follows-the-calling-session, E2E-SUBAGENT-resume-a-settled-delegation || M6+ (Session Orchestrator) | E2E-PLUGIN-session-orchestrator-real-workers || M6+ (Selected model order) | E2E-MODEL-selected-order-persists |+| M6+ (MCP server timeout override) | E2E-261 || M6+ (Destination loading and focus) | E2E-087b || M6+ (Session list responsiveness) | E2E-SESSION-list-refresh-keeps-desktop-responsive || M6+ (Windows updater cache) | E2E-260 |diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.mdindex d462f6073..cacecde96 100644--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md@@ -4908,6 +4908,14 @@ eleven-tool-round desktop paths are verified by- **里程碑**:M5- **状态**:单元覆盖(`apps/desktop/test/mcp-oauth.test.mjs`、`apps/desktop/test/user-mcp.test.mjs`);完整 UI 之旅草案+#### E2E-261:清除单服务器 MCP 超时覆盖++- **前提**:隔离 Electron 配置及一个超时覆盖为 45 秒的已保存 MCP 服务器;不连接真实服务器或提供商。+- **步骤**:打开生产 MCP 编辑器,输入超出范围的值并确认保存按钮禁用,然后清空超时字段并保存。+- **预期**:无效超时无法保存。清空已有覆盖是有效操作,并序列化为 `timeoutSeconds: null`,使 host-core 删除覆盖并使用默认值。+- **验收**:`node scripts/e2e-mcp-timeout-clear.mjs` 使用生产编辑器验证表单和保存序列化。`apps/desktop/test/mcp-editor-timeout.test.mjs` 覆盖值转换;host-core MCP 测试覆盖 null 清除及默认行为。不连接真实 MCP 服务器。+- **里程碑**:M6++#### E2E-101:用户技能编写一次并限定每个项目的范围- **先决条件**:磁盘上有两个项目。每个中都有一个 Agent 会话。@@ -5519,6 +5527,7 @@ eleven-tool-round desktop paths are verified by| A / H / Quality — 渲染器进程崩溃恢复 | E2E-RUNTIME-renderer-crash-recovery || B / F / Security — 提供商复制 | E2E-PROVIDER-copy-config-without-credentials || B / F / Quality — 已选模型顺序 | E2E-MODEL-selected-order-persists |+| E / F / Quality — MCP 服务器超时覆盖 | E2E-261 || A — 应用程序启动 | E2E-001、E2E-002、E2E-003、E2E-004、E2E-067、E2E-076、E2E-079、E2E-092、E2E-097、E2E-143、E2E-150、E2E-168、E2E-204、E2E-217 || B——模型配置 | E2E-005、E2E-005G、E2E-006、E2E-007、E2E-038、E2E-050、E2E-052、E2E-055、E2E-066、E2E-080、E2E-082、E2E-151、E2E-005J、E2E-199、E2E-201、E2E-202、E2E-203、E2E-209、E2E-166 || C — 对话和直播 | E2E-CHAT-running-status-survives-output-pauses、E2E-008、E2E-008d、E2E-008a、E2E-009、E2E-010、E2E-011、E2E-011a、E2E-011b、E2E-031、E2E-040、E2E-047、E2E-048、E2E-048A、E2E-049、E2E-052、 E2E-053、E2E-054、E2E-055、E2E-059、E2E-059a、E2E-060c、E2E-060d、E2E-061、E2E-061a、E2E-062、E2E-064、E2E-065、E2E-068、E2E-071、 E2E-073、E2E-074、E2E-075、E2E-081、E2E-083、E2E-084、E2E-086、E2E-087、E2E-088、E2E-088b、E2E-089、E2E-090、E2E-094、E2E-095、E2E-096、 E2E-097、E2E-098、E2E-099、E2E-102、E2E-102a、E2E-102b、E2E-106、E2E-109、E2E-111、E2E-114、E2E-116、E2E-117、E2E-118、E2E-119、 E2E-120、E2E-121、E2E-代理-001、E2E-142、E2E-144、E2E-145、E2E-146、E2E-147、E2E-151、E2E-199、E2E-250、E2E-166、E2E-SUBAGENT-resume-a-settled-delegation |@@ -5589,6 +5598,7 @@ eleven-tool-round desktop paths are verified by| M6+ | E2E-121、E2E-122、E2E-123、E2E-142、E2E-148、E2E-150、E2E-151、E2E-168、E2E-199、E2E-200、E2E-202、E2E-203、E2E-209、E2E-211、E2E-UPDATE-preference-and-once-only-reminder、E2E-212、E2E-213、E2E-214、E2E-215、E2E-216、E2E-217、E2E-257、E2E-166、E2E-SUBAGENT-resume-a-settled-delegation || M6+(Session Orchestrator) | E2E-PLUGIN-session-orchestrator-real-workers || M6+(已选模型顺序) | E2E-MODEL-selected-order-persists |+| M6+(MCP 服务器超时覆盖) | E2E-261 || M6+(目的页加载与焦点) | E2E-087b || M6+(会话列表响应性) | E2E-SESSION-list-refresh-keeps-desktop-responsive || M6+(Windows 更新缓存) | E2E-260 |diff --git a/scripts/e2e-mcp-timeout-clear.mjs b/scripts/e2e-mcp-timeout-clear.mjsnew file mode 100644index 000000000..3e2f104a8--- /dev/null+++ b/scripts/e2e-mcp-timeout-clear.mjs@@ -0,0 +1,94 @@+#!/usr/bin/env node+/** Exercise timeout validation and clearing through the production MCP editor in Electron. */+import assert from "node:assert/strict";+import { spawn } from "node:child_process";+import { createRequire } from "node:module";+import { mkdtemp, rm, writeFile } from "node:fs/promises";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { repositoryRoot, resolveElectronBinary } from "./e2e/boot.mjs";++const root = repositoryRoot();+const { build } = createRequire(join(root, "packages/agent-runtime/package.json"))("esbuild");+const temp = await mkdtemp(join(tmpdir(), "pi-mcp-timeout-clear-"));+try {+ await build({+ entryPoints: [join(root, "scripts/e2e/mcp-timeout-clear.tsx")],+ outfile: join(temp, "renderer.js"),+ bundle: true,+ platform: "browser",+ format: "iife",+ jsx: "automatic",+ define: { "process.env.NODE_ENV": '"production"', "import.meta.env.DEV": "false" },+ loader: { ".css": "empty" },+ alias: {+ "@pi-desktop/i18n": join(root, "packages/i18n/src/index.ts"),+ react: join(root, "apps/desktop/node_modules/react"),+ "react-dom": join(root, "apps/desktop/node_modules/react-dom"),+ },+ nodePaths: [join(root, "apps/desktop/node_modules")],+ });+ await writeFile(+ join(temp, "index.html"),+ '<!doctype html><meta charset="utf-8"><div id="root"></div><script src="renderer.js"></script>',+ );+ await writeFile(+ join(temp, "main.cjs"),+ `+const { app, BrowserWindow } = require("electron");+const path = require("node:path");+app.disableHardwareAcceleration();+app.setPath("userData", path.join(__dirname, "profile"));+app.whenReady().then(async () => {+ const window = new BrowserWindow({ show: false, webPreferences: { sandbox: true, contextIsolation: true, nodeIntegration: false, backgroundThrottling: false } });+ window.webContents.on("console-message", (event) => console.error(event.message));+ try {+ await window.loadFile(path.join(__dirname, "index.html"));+ const result = await window.webContents.executeJavaScript("window.mcpTimeoutClearProbe()");+ console.log("MCP_TIMEOUT_CLEAR " + JSON.stringify(result));+ app.exit(0);+ } catch (error) {+ console.error("MCP_TIMEOUT_CLEAR " + (error?.stack ?? String(error)));+ app.exit(1);+ }+});+`,+ );+ const env = { ...process.env };+ delete env.ELECTRON_RUN_AS_NODE;+ const child = spawn(resolveElectronBinary(root).electronBinary, [+ "--headless=new",+ "--disable-gpu",+ join(temp, "main.cjs"),+ ], {+ env,+ stdio: ["ignore", "pipe", "pipe"],+ });+ let output = "";+ for (const stream of [child.stdout, child.stderr]) {+ stream.on("data", (chunk) => { output += chunk; });+ }+ const timeout = setTimeout(() => child.kill("SIGKILL"), 30_000);+ let code;+ try {+ code = await new Promise((resolve, reject) => {+ child.once("error", reject);+ child.once("close", resolve);+ });+ } finally {+ clearTimeout(timeout);+ }+ const line = output.split(/\r?\n/).find((item) => item.startsWith("MCP_TIMEOUT_CLEAR "));+ assert(line, `renderer returned no MCP timeout result (exit=${code}): ${output.slice(-3000)}`);+ const result = JSON.parse(line.slice("MCP_TIMEOUT_CLEAR ".length));+ console.log(line);+ assert.equal(code, 0, output.slice(-3000));+ assert.deepEqual(result, {+ originalValue: "45",+ invalidValueBlocked: true,+ clearedValueEnabled: true,+ savedTimeoutSeconds: null,+ });+} finally {+ await rm(temp, { recursive: true, force: true });+}diff --git a/scripts/e2e/mcp-timeout-clear.tsx b/scripts/e2e/mcp-timeout-clear.tsxnew file mode 100644index 000000000..3b5176ceb--- /dev/null+++ b/scripts/e2e/mcp-timeout-clear.tsx@@ -0,0 +1,116 @@+import { useState } from "react";+import { createRoot } from "react-dom/client";+import { flushSync } from "react-dom";+import { createInstance } from "i18next";+import { I18nextProvider, initReactI18next } from "react-i18next";+import { catalogs, flattenCatalog } from "@pi-desktop/i18n";+import {+ draftFromRecord,+ draftToInput,+ McpEditorSheet,+} from "../../apps/desktop/src/components/extensions/McpEditorSheet";++const record = {+ id: "slow-server",+ label: "Slow server",+ transport: "stdio" as const,+ command: "npx",+ enabled: true,+ timeoutSeconds: 45,+};++const i18n = createInstance();++function Harness() {+ const [draft, setDraft] = useState(() => draftFromRecord(record));+ const save = () => {+ window.__mcpTimeoutSaved = draftToInput(draft).timeoutSeconds;+ };++ return (+ <I18nextProvider i18n={i18n}>+ <McpEditorSheet+ draft={draft}+ setDraft={setDraft}+ editing={record}+ saving={false}+ testing={false}+ projects={[]}+ onClose={() => {}}+ onSave={save}+ onTest={() => {}}+ />+ </I18nextProvider>+ );+}++declare global {+ interface Window {+ __mcpTimeoutSaved?: number | null;+ mcpTimeoutClearProbe: () => Promise<{+ originalValue: string;+ invalidValueBlocked: boolean;+ clearedValueEnabled: boolean;+ savedTimeoutSeconds: number | null | undefined;+ }>;+ }+}++void i18n+ .use(initReactI18next)+ .init({+ lng: "en",+ fallbackLng: "en",+ keySeparator: false,+ resources: { en: { translation: flattenCatalog(catalogs.en) } },+ interpolation: { escapeValue: false },+ })+ .then(() => {+ const root = createRoot(document.getElementById("root")!);+ flushSync(() => root.render(<Harness />));++ window.mcpTimeoutClearProbe = async () => {+ const input = document.querySelector<HTMLInputElement>(+ 'input[type="number"]',+ );+ if (!input) throw new Error("MCP timeout input was not rendered");+ const originalValue = input.value;+ const save = [...document.querySelectorAll<HTMLButtonElement>("button")].find(+ (button) => button.textContent?.trim() === "Save",+ );+ if (!save) throw new Error("MCP save button was not rendered");++ const setInputValue = (value: string) => {+ const setter = Object.getOwnPropertyDescriptor(+ HTMLInputElement.prototype,+ "value",+ )?.set;+ if (!setter) throw new Error("HTML input value setter is unavailable");+ flushSync(() => {+ setter.call(input, value);+ input.dispatchEvent(new Event("input", { bubbles: true }));+ input.dispatchEvent(new Event("change", { bubbles: true }));+ });+ };++ setInputValue("601");+ const invalidValueBlocked = save.disabled;++ setInputValue("");+ const clearedValueEnabled = !save.disabled;+ if (clearedValueEnabled) {+ flushSync(() => save.click());+ }++ return {+ originalValue,+ invalidValueBlocked,+ clearedValueEnabled,+ savedTimeoutSeconds: window.__mcpTimeoutSaved,+ };+ };+ })+ .catch((error: unknown) => {+ console.error(error);+ throw error;+ });