dsh-restart-refresh 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +3 -3
- package/docs/DETAIL.md +3 -3
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.2
|
|
4
|
+
|
|
5
|
+
- Wording only: the marketplace entry and the plugin-list description now say the header button "refreshes the page and hot-reloads plugin code", and the quit/restart note reads "a normal close, not a force kill — no system chime and no error dialog".
|
|
6
|
+
|
|
3
7
|
## 0.6.1
|
|
4
8
|
|
|
5
9
|
- **Safety fix.** The helper now looks the shell up by PID before doing anything (`Win32_Process`): if that PID turns out to run a different executable — Windows recycles PIDs — it aborts instead of closing somebody else's windows, and it also refuses when the Host is not a child of that process.
|
package/README.md
CHANGED
|
@@ -41,13 +41,13 @@ DSH 的插件分两半:
|
|
|
41
41
|
|
|
42
42
|
1. 往临时目录写两个文件:PowerShell 助手(`%TEMP%\dsh-restart-refresh-restart.ps1` / `-quit.ps1`)和一个同名的 `.vbs` 启动器;
|
|
43
43
|
2. 用 `wscript.exe //B 启动器.vbs` 拉起助手——`wscript` 是 GUI 程序,`shell.Run(..., 0, False)` 又是隐藏窗口,所以**全程不会闪命令框**;它立刻返回,助手继续活着;
|
|
44
|
-
3.
|
|
44
|
+
3. 先走**正常关闭**(不是强杀):给主窗口发 `WM_QUERYENDSESSION` + `WM_ENDSESSION`(壳看到会话结束就把随后的关窗放行,而不是「最小化到托盘」),再发 `WM_CLOSE`。于是壳自己走正常退出流程——停 Host、存状态、收托盘,还跳过了「有任务在跑」的二次确认。**这条路不会响 Windows 那声「叮」,也不会弹「操作失败」的报错框**(强杀 GUI 进程才会);
|
|
45
45
|
4. 最多等 8 秒;没退干净就回落到 `taskkill /F`,日志里会写 `graceful shutdown timed out; falling back to a force stop`;
|
|
46
46
|
5. **把同名的残留子进程(renderer / GPU / utility)一起扫掉**,再清掉旧宿主的直系子进程(MCP 服务、语音服务等;bili 代理那个常驻守护会被保留)——它们会拖住 App 的单实例锁,也会让新实例启动时多一点负担;
|
|
47
47
|
6. **启动前清掉 `ELECTRON_RUN_AS_NODE`**:宿主是 `ELECTRON_RUN_AS_NODE=1` 跑起来的,这个变量会一路继承到我们拉起的进程,App 收到它就变成纯 Node 进程——秒退、退码 0、没有窗口(这就是之前“只关闭、打不开”的真正原因);
|
|
48
|
-
7. `-Mode restart` 用同一个可执行文件重新启动 App,并**轮询确认进程真的起来了**;没起来就清干净再试,最多约 25 秒,最后再用 `explorer` 走一次双击式的启动;`-Mode quit`
|
|
48
|
+
7. `-Mode restart` 用同一个可执行文件重新启动 App,并**轮询确认进程真的起来了**;没起来就清干净再试,最多约 25 秒,最后再用 `explorer` 走一次双击式的启动;`-Mode quit` 在正常关闭成功时就到此为止。
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
实测:正常关闭约 1.2 秒关干净;重启从点下到 App 重新起来约 2.2 秒(记事本端到端演练:`restart: shell exited gracefully in 1.2s; relaunching` → `relaunched on round 1 in 2.2s`)。旧版本是先等 1.2 秒、再等 5 秒、最后强杀,合计 6~7 秒、会闪命令框、还会响系统音。
|
|
51
51
|
|
|
52
52
|
日志写在 `%TEMP%\dsh-restart-refresh-restart.log`(每步带耗时;失败时会记下新实例的退出码,以及系统事件日志里的错误),没成功时先看它。
|
|
53
53
|
|
package/docs/DETAIL.md
CHANGED
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
助手脚本:
|
|
24
24
|
|
|
25
25
|
1. 只等 250ms(够 HTTP 响应发回页面),校验 exe 还在;
|
|
26
|
-
2.
|
|
26
|
+
2. **先试正常关闭**(0.4.4):`Add-Type` 编译一个小的 `DshGraceful` 类,用 `EnumWindows` 找出该 pid 的所有顶层窗口,先给全部窗口 `PostMessage(WM_QUERYENDSESSION)` + `WM_ENDSESSION(TRUE)`,再给可见窗口 `WM_CLOSE`。
|
|
27
27
|
- 为什么这样能成:壳的 `window.on("close")` 里有 `if (quitting || shellInstallerOwnsQuit || sessionEnding) return;`,否则就 `preventDefault()` 变成"最小化到托盘";而 `sessionEnding` 正是 `window.on("session-end")` 置位的。窗口先收到会话结束消息,随后那个 `WM_CLOSE` 就不再被拦,窗口真的关掉 → `window-all-closed` → `app.quit()` → `before-quit` 里 `sessionEnding` 让 `finishQuit()` 直接走完(停 Host、存状态、收托盘),还跳过了「有任务在跑」的二次确认。
|
|
28
|
-
- 附带好处:不走 `TerminateProcess`,**不会有 Windows
|
|
28
|
+
- 附带好处:不走 `TerminateProcess`,**不会有 Windows 那声「叮」,也不会弹「操作失败」的报错框**(强杀有窗口的 GUI 进程才会响、才会报错)。
|
|
29
29
|
- 最多等 8 秒;主进程没退干净就记 `graceful shutdown timed out; falling back to a force stop`,继续走下面的强杀流程。主进程退了但 Host 还在,就单独 `taskkill /F /PID <host>` 补一刀。
|
|
30
30
|
3. 强杀兜底:`taskkill /F /PID <host>`、`taskkill /F /PID <main>`(**不带 `/T`**:助手自己是宿主的后代,杀进程树会先杀掉自己);
|
|
31
31
|
4. `Wait-Process` 确认主进程真的没了(最多 4 秒),再按镜像名把**残留的 renderer / GPU / utility 子进程**逐个 `Stop-Process -Force` 清掉(最多 12 轮 × 300ms);
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
4. `-Mode restart` 时先停 400ms,再 `Start-Process -FilePath <exe> -WorkingDirectory <exe 目录> -PassThru`;每轮起完轮询 `Get-Process -Name <exe 名>` 约 2.4 秒,没起来就清残留、等 900ms 再试,最多 10 轮(约 25 秒);日志会记下新实例的退出码(`round N: pid X exited with 0` 就是又撞上单实例锁)。全失败后兜底用 `explorer.exe <exe>` 走一次双击式启动;`-Mode quit` 在第 3 步之后就结束;
|
|
34
34
|
- **关键坑(0.4.3 修)**:宿主进程的环境里有 `ELECTRON_RUN_AS_NODE=1`,wscript → powershell → `Start-Process` 一路继承;App 拿到这个变量后按 Node 运行,秒退、退出码 0、不建窗口。helper 一开始就 `Remove-Item Env:\ELECTRON_RUN_AS_NODE`(顺带清 `ELECTRON_NO_ATTACH_CONSOLE`),并在清掉时记一行日志。`explorer.exe` 那条兜底之所以能成,是因为它用的是 shell 自己的干净环境。
|
|
35
35
|
- 每轮失败后还会清掉旧宿主的直系子进程(`Stop-Children`,按 `ParentProcessId` 递归;跳过 powershell/wscript/conhost,也跳过命令行含 `billion-context` 的常驻代理)。
|
|
36
|
-
5. 全程追加到 `%TEMP%\dsh-restart-refresh-restart.log
|
|
36
|
+
5. 全程追加到 `%TEMP%\dsh-restart-refresh-restart.log`,成功那行带总耗时(实测:正常关闭 1.2s、重启 2.2s)。
|
|
37
37
|
|
|
38
38
|
> 助手脚本是 PowerShell,`node --check` 管不到。改完用 `node test/dump-helper.mjs` 把生成的 `.ps1` 落到 `%TEMP%\dsh-restart-refresh-check-{restart,quit}.ps1`,再用 `[System.Management.Automation.Language.Parser]::ParseFile()` 过一遍语法(踩过坑:早版本把整段包在一个裸的 `{ }` 里,PowerShell 把它当成 ScriptBlock 字面量**静默输出**而不执行,结果优雅退出根本没跑起来,还照样强杀)。
|
|
39
39
|
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "DSH-restart-refresh",
|
|
4
|
-
"description": "Two icons beside the DSH logo in the sidebar
|
|
4
|
+
"description": "Two icons beside the DSH logo in the sidebar restart or quit DSH; the button at the top right of the conversation refreshes the page and hot-reloads plugin code."
|
|
5
5
|
}
|
|
6
6
|
}
|
package/locale/zh.json
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-restart-refresh",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Restart
|
|
5
|
+
"description": "Restart or quit the DSH desktop app from two sidebar icons, and refresh the page / hot-reload plugin code from the conversation header.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"icon": "./icon.svg",
|
|
8
8
|
"os": [
|