# Task: Fix AI programming input context menu ## Identity - Task ID: 20260907-input-context-menu-a7c31e - Mode: Feature - Branch: codex/20260907-input-context-menu-a7c31e-input-context-menu - Worktree: D:\Datas\OthersProjects\.codex-worktrees\makelore\20260907-input-context-menu-a7c31e - Base commit: 8c13ae76db6fa47972bdf9ff3de932eb761aaffe - Owner: codex - Status: Ready for Integration ## Scope - Reproduce the AI Programming composer symptom where right-clicking editable text exposes no native editing menu. - Compare the current integrated primary-window wiring with completed task `20260819-context-menu-impl-c7d4a2e1` and reuse only behavior still compatible with the current window lifecycle. - Restore the smallest Main-owned native text-editing context-menu behavior and add focused regression coverage at the real window/event seam. - Update user-facing documentation or Electron E2E coverage only where current behavior and the shared fixture require it. ## Intent And Constraints - Electron Main owns desktop context-menu integration. Do not add Renderer, Preload, IPC, Host API, or direct clipboard access for this fix. - Use the primary window's `webContents` `context-menu` event and native editing roles when that remains the confirmed compatible seam. - Show a menu only for editable controls or an existing text selection; derive enabled actions from the actual Electron edit context. - Preserve Renderer-owned custom menus, Monaco behavior, the detached Agent Browser, existing application-menu behavior, Chinese-only UI, and the single light visual system. - Build a deterministic red-capable feedback loop for the reported input symptom before selecting a cause or changing production code. - Work only in the isolated task worktree; do not modify, adopt, clean, or merge the occupied root `main` worktree or any peer worktree. ## Outcome - Confirmed the failure at the real Electron window seam: a renderer right-click produced no native menu because the primary `webContents` had zero `context-menu` listeners. The earlier implementation in task `20260819-context-menu-impl-c7d4a2e1` exists only on its isolated branch and was never integrated into the current `main` history. - Added a Main-owned text context-menu module that builds native Chinese `cut`, `copy`, `paste`, and `selectAll` roles from Electron's actual `isEditable`, `selectionText`, and `editFlags` context. Ordinary non-editable content still produces no menu. - Registered the listener once during primary-window creation without adding Renderer, Preload, IPC, Host API, or direct clipboard access. - Added five focused unit cases and an Electron E2E regression that dispatches a real right-click inside the primary Renderer window and observes one native menu popup with the expected editing actions. - Synchronized `README.md` with the restored desktop behavior and ownership boundary. ## Verification - Red phase: - `corepack pnpm exec playwright test tests/e2e/context-menu.spec.ts` failed twice with `popupCount: 0` before the production change. - A temporary targeted probe reported zero `context-menu` listeners on the primary `webContents`; the probe was removed before completion. - `corepack pnpm exec vitest run tests/unit/context-menu.test.ts` failed to resolve the absent Main module before implementation. - Green phase: - `corepack pnpm exec vitest run tests/unit/context-menu.test.ts` — 5 passed. - `corepack pnpm exec playwright test tests/e2e/context-menu.spec.ts` — 1 passed. - `corepack pnpm run typecheck` — passed. - `corepack pnpm exec eslint electron/main/context-menu.ts electron/main/index.ts tests/unit/context-menu.test.ts tests/e2e/context-menu.spec.ts` — passed. - `corepack pnpm run lint:check` — passed with 5 pre-existing warnings in untouched files and no errors. - `corepack pnpm run build:vite` — passed for Renderer, Main, Preload, and release utility bundles; only existing chunk/dynamic-import warnings were reported. - `corepack pnpm test` — 226 test files passed; one unrelated real-process timing assertion in `pi-agent-server-process-real.test.ts` measured 2323ms against a 2000ms threshold. Its isolated rerun with `corepack pnpm exec vitest run tests/unit/pi-agent-server-process-real.test.ts --maxWorkers=1` passed all 6 tests, so no unrelated timing code or threshold was changed. - `git diff --check` — passed. ## Follow-ups - Integrate this ready branch through the project Integration Gate after the current owner of the root `main` worktree releases it. ## Promotion Candidates - None recorded.