Skip to content

feat(webui): 电源键点开后可选关机或重启 - #384

Open
Voemp wants to merge 3 commits into
Pal-AI-Lab:mainfrom
Voemp:feat/rail-power-menu
Open

Voemp wants to merge 3 commits into
Pal-AI-Lab:mainfrom
Voemp:feat/rail-power-menu

Conversation

@Voemp

@Voemp Voemp commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

中文

左下角的电源键现在点开一个菜单,可选「关机」或「重启」,不再直接进入关机确认。重启沿用扩展页已有的语义:写入重启标志后规范关机,由启动器把新进程拉起来;页面轮询 /api/run/lifecycle,等同一部署换了 bootId 且就绪后刷新,因此 bot 与 World 的更新会随重启生效。重启开始后整页盖一层遮罩,中间是加载动画和「正在重启…」,遮罩不响应 Esc、点击或关闭键,直到新进程就绪、页面刷新。没有启动器循环时先说明进程只会退出、需要手动启动,确认后才执行,而且不用遮罩,因为那只是一次退出;关机仍是原来的两道确认。等待新进程的逻辑从扩展页提到 core/restart.ts,两处共用。菜单在 Esc、点菜单外面或焦点离开时收起,↑↓ 在两项间移动;某项能力没挂时,菜单与键名只写实际可用的那一项。

English

The power button in the left rail now opens a menu with "shut down" and "restart" instead of going straight to the shutdown confirmation. Restart keeps the meaning it already has on the extensions page: write the restart flag, run the normal shutdown, and let the launcher bring a new process up; the page polls /api/run/lifecycle and reloads once the same deployment reports a new bootId and is ready, so bot and World updates take effect with the restart. Once the restart begins, a full-page scrim with a spinner and "Restarting…" covers the WebUI; it ignores Escape, clicks and close controls until the new process is ready and the page reloads. Without a launcher loop it first says the process will only exit and must be started by hand, and asks before doing it; there is no scrim then, because nothing comes back on its own. Shutdown keeps its two confirmations. The wait-for-the-new-process logic moved from the extensions page to core/restart.ts and is shared by both. The menu closes on Escape, an outside click or focus leaving it, and the arrow keys move between items; when a capability is not mounted, the menu and the control's name mention only the actions that exist.

Checks

  • pnpm test — 本机 Node 26 上以 NODE_OPTIONS=--localstorage-file=… 跑完整套:286/288 个文件、5203/5208 个用例通过。剩下 2 个失败在未改动的 client-language 与 client-ui,它们断言 jsdom 的 localStorage 语义,而 Node 26 自带的 localStorage 全局改变了这个前提。不带该参数时,8 个 jsdom 文件在初始化阶段因 localStorage 为 undefined 失败(改动前的文件同样失败)。CI 的 Node 22 没有这个全局。
  • pnpm run typecheck
  • pnpm typecheck:web (browser code changed / 改了浏览器代码)
  • A bug fix carries a test that fails before the fix / 修 bug 附带修复前会失败的测试 — 本 PR 是新功能;菜单开关、重启请求、无启动器确认和轮询停止都有测试。

Voemp added 3 commits November 5, 2026 16:17
- 重启沿用扩展页的语义:落重启标志后规范关机,启动器拉起新进程;页面等同一部署换了 bootId 且就绪后刷新,让 bot 与 World 的更新生效
- 没有启动器循环时先说明进程只会退出、需要手动启动,确认后才执行
- 等新进程的逻辑从扩展页提到 core/restart.ts,两处共用
- 菜单按 Esc、点外面或焦点离开收起,↑↓ 在两项间移动;能力缺席的项不画,键名只写可用的动作
- 测试覆盖菜单开关、重启请求、无启动器时的确认与轮询停止
- 遮罩复用 ui.busy:不响应 Esc、遮罩点击与关闭键,只有返回的句柄或页面卸载能关
- busy 卡片加加载动画,标题居中;只在启动器会重新拉起进程的重启上用
- 没有启动器循环时仍是一次退出:照旧确认,回执写明需要手动启动
- 测试覆盖遮罩出现,以及应答换成另一个部署时撤下遮罩
标题从 modalhead 移进卡片正文并居中,加载动画是新增的 busyspin。

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant