AI agent skill · by @lovstudio
Sgc Electron App Relaunch
为 Electron 桌面应用实现并验证完整重启,区分 renderer 刷新、用户主动重启、开发态重启和更新安装交接。用户提到重启 App、菜单重启、Cmd+R、app.relaunch 或 restart Electron 时使用。
Archived 2026-10-23 · Source updated 2026-09-14 · License: MIT. Check the original repository for the latest version.
SKILL.md instructions
# 桌面应用重启 · Desktop App Relaunch 为用户提供真正重启桌面应用的入口,并在开发态、生产态和更新安装时保持正确的进程生命周期。 ## Triggers ### Activate when - 用户说“在菜单里增加重启 App”“实现重启 Yoda”或“完整重启 Electron”。 - 用户把 `Cmd+R`、reload、relaunch、退出再打开混在一起,需要修复实际行为。 - User asks to “restart the app from a menu”, “use app.relaunch”, or “make Electron dev restart reliable”. ### Do not activate when - 用户只需要刷新页面或恢复某个 renderer 错误边界;使用 renderer reload。 - 用户要重启某一条 Agent/终端会话;使用会话生命周期或 PTY 工作流。 ## Workflow (MANDATORY) **You MUST follow these steps in order.** ### Step 0: Name the intended action - Map every proposed UI entry to exactly one intent: renderer reload, full app relaunch, or update installation handoff. - Do not bind a standard reload shortcut to full relaunch by accident. In Electron, the built-in View reload role commonly owns `Cmd+R` / `Ctrl+R`. - Read [references/relaunch-contract.md](references/relaunch-contract.md) before implementation. ### Step 1: Centralize the relaunch path - Put full-app restart in one main-process function, then invoke it from the native menu or typed IPC. - In packaged production, call `app.relaunch()` followed by `app.quit()`. - In development, relaunch the actual dev entrypoint with the Node executable and arguments that started the app; do not assume a packaged executable exists. - Keep renderer reload separate and label it accordingly in the UI. ### Step 2: Preserve process ownership - Let main-process shutdown hooks complete according to the product's session policy. - Do not use the ordinary relaunch function to install an update. The updater must take control only after cleanup and staging have completed. - When child processes, PTYs, local servers, or single-instance locks exist, define whether each survives, shuts down, or is reattached after restart. ### Step 3: Verify the real instance - Add focused tests for the dev command construction and production relaunch path. - Run the app, record its PID, executable path, working directory, and start time. - Trigger the native menu item once, then confirm a replacement instance is running with a newer start time and the intended executable. - Do not accept bundle text, menu existence, renderer reload, or a successful build as proof of full restart. ## Dependencies - Electron main-process access to `app` and the target project's development command. ## 通用反馈闭环 用户在 Skill 驱动任务中提出修改意见时,继续当前产物前必须执行: 1. 先判断意见是 `task-specific`(仅本次)还是 `reusable`(可跨任务复用)。 2. `task-specific` 只修改当前任务,不改 Skill。 3. `reusable` 先确定作用域:领域规则先更新对应 canonical Skill;适用于所有 Skill 的规则先更新共享规范。 4. 完成规则更新、版本、lint 与分发核验后,再把修改应用到当前任务。 5. `reusable` 修改会使此前的“确认”“继续”“发吧”失效;完成当前产物修改和回读后必须停下,等待用户下一步指示,不自动进入发布、提交或其他外部写入。